Before repair nav components
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s
This commit is contained in:
30
components/discarted/Select.js
Normal file
30
components/discarted/Select.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// components/Select.js
|
||||
import { h, each } from "sigpro";
|
||||
|
||||
export const Select = (props) => {
|
||||
const { items, placeholder, placeholderDisabled = true, keyFn, children, ...rest } = props;
|
||||
|
||||
if (children !== undefined) {
|
||||
return h("select", { ...rest, class: `select ${rest.class ?? ''}` }, children);
|
||||
}
|
||||
|
||||
const placeholderOption = placeholder
|
||||
? h("option", { disabled: placeholderDisabled, selected: true }, placeholder)
|
||||
: null;
|
||||
|
||||
const dynamicOptions = each(
|
||||
() => [...(typeof items === "function" ? items() : items || [])],
|
||||
(item) => {
|
||||
const value = typeof item === "string" ? item : item.value;
|
||||
const label = typeof item === "string" ? item : item.label;
|
||||
return h("option", { value }, label);
|
||||
},
|
||||
keyFn || ((item) => (typeof item === "string" ? item : item.value))
|
||||
);
|
||||
|
||||
const options = placeholderOption
|
||||
? [placeholderOption, dynamicOptions]
|
||||
: dynamicOptions;
|
||||
|
||||
return h("select", { ...rest, class: `select ${rest.class ?? ''}` }, options);
|
||||
};
|
||||
Reference in New Issue
Block a user