Rebuild all 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:
@@ -2,24 +2,24 @@
|
||||
import { Tag, For } from "sigpro";
|
||||
|
||||
export const Select = (props, children) => {
|
||||
const { class: className, ...rest } = props;
|
||||
return Tag("select", {
|
||||
...rest,
|
||||
class: `select ${className || ''}`.trim()
|
||||
}, children);
|
||||
children === undefined && (children = props, props = {});
|
||||
return Tag("select", { ...props, class: `select ${props.class ?? ''}` }, children);
|
||||
};
|
||||
|
||||
export const Options = (props) => {
|
||||
const { items, placeholder, placeholderDisabled = true, ...rest } = props;
|
||||
|
||||
const itemArray = typeof items === "function" ? items() : (items || []);
|
||||
|
||||
return [
|
||||
placeholder && Tag("option", { disabled: placeholderDisabled, selected: true }, placeholder),
|
||||
For(itemArray, (item) => {
|
||||
const placeholderOption = props.placeholder
|
||||
? Tag("option", { disabled: props.placeholderDisabled ?? true, selected: true }, props.placeholder)
|
||||
: null;
|
||||
|
||||
const dynamicOptions = For(
|
||||
() => [...(typeof props.items === "function" ? props.items() : props.items || [])],
|
||||
(item) => {
|
||||
const val = typeof item === "string" ? item : item.value;
|
||||
const label = typeof item === "string" ? item : item.label;
|
||||
return Tag("option", { value: val, ...rest }, label);
|
||||
})
|
||||
];
|
||||
return Tag("option", { value: val }, label);
|
||||
},
|
||||
props.keyFn || ((item) => (typeof item === "string" ? item : item.value))
|
||||
);
|
||||
|
||||
return placeholderOption ? [placeholderOption, dynamicOptions] : dynamicOptions;
|
||||
};
|
||||
Reference in New Issue
Block a user