b44ui 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +16 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1765,9 +1765,10 @@ export declare const Input: ({ state, cn, cnIgnoreWrongUsage, grow, gap, p, wd,
|
|
|
1765
1765
|
export declare const Textarea: ({ cn, cnIgnoreWrongUsage, ref, grow, gap, p, wd, ht, ...rest }: DProps & React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
1766
1766
|
ref?: React.RefObject<HTMLTextAreaElement | null>;
|
|
1767
1767
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
1768
|
-
export declare const Select: <T extends SelectValue>({ state, options, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, onChange, children, ...rest }: DProps & Omit<React.SelectHTMLAttributes<HTMLSelectElement>, "value" | "defaultValue"> & {
|
|
1768
|
+
export declare const Select: <T extends SelectValue>({ state, options, title, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, onChange, children, ...rest }: DProps & Omit<React.SelectHTMLAttributes<HTMLSelectElement>, "value" | "defaultValue" | "title"> & {
|
|
1769
1769
|
state?: SelectState<T>;
|
|
1770
1770
|
options?: Record<string, T>;
|
|
1771
|
+
title?: string;
|
|
1771
1772
|
value?: T;
|
|
1772
1773
|
defaultValue?: T;
|
|
1773
1774
|
}) => import("react/jsx-runtime").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -129,16 +129,27 @@ export const Textarea = ({ cn, cnIgnoreWrongUsage, ref, grow, gap, p, wd, ht, ..
|
|
|
129
129
|
const c = rcn({ cn, cnIgnoreWrongUsage, className: rest.className });
|
|
130
130
|
return _jsx("textarea", { ref: ref, ...rest, className: CN('rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm outline-none w-full', growCn(grow), c), style: dStyle({ gap, p, wd, ht, style: rest.style }) });
|
|
131
131
|
};
|
|
132
|
-
export const Select = ({ state, options, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, onChange, children, ...rest }) => {
|
|
132
|
+
export const Select = ({ state, options, title, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, onChange, children, ...rest }) => {
|
|
133
133
|
const c = rcn({ cn, cnIgnoreWrongUsage, className: rest.className });
|
|
134
134
|
const entries = options ? Object.entries(options) : undefined;
|
|
135
|
-
|
|
135
|
+
const [showTitle, setShowTitle] = useState(!!title);
|
|
136
|
+
const [innerValue, setInnerValue] = useState(rest.defaultValue);
|
|
137
|
+
const value = showTitle ? '' : state ? state[0] : rest.value ?? innerValue;
|
|
138
|
+
return _jsxs("select", { ...rest, className: CN('rounded bg-zinc-800 border border-zinc-700 px-3 py-2 text-sm outline-none cursor-pointer', growCn(grow), c), style: dStyle({ gap, p, wd, ht, style: rest.style }), value: value, onChange: e => {
|
|
139
|
+
if (title && e.target.value === '') {
|
|
140
|
+
setShowTitle(true);
|
|
141
|
+
onChange?.(e);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
136
144
|
const value = entries?.find(([, value]) => String(value) === e.target.value)?.[1] ?? e.target.value;
|
|
145
|
+
setShowTitle(false);
|
|
146
|
+
if (!state && rest.value === undefined)
|
|
147
|
+
setInnerValue(value);
|
|
137
148
|
state?.[1](value);
|
|
138
149
|
onChange?.(e);
|
|
139
|
-
}, children: entries
|
|
140
|
-
|
|
141
|
-
|
|
150
|
+
}, children: [title && _jsx("option", { value: '', children: title }), entries
|
|
151
|
+
? entries.map(([label, value]) => _jsx("option", { value: value, children: label }, `${label}:${value}`))
|
|
152
|
+
: children] });
|
|
142
153
|
};
|
|
143
154
|
export const Grid = ({ children, cols, gap, ...rest }) => _jsx(D, { ...rest, cn: CN('grid ui-grid', rcn(rest)), gap: gap ?? 4, style: { ['--cols']: cols ?? Children.count(children), ...rest.style }, children: children });
|
|
144
155
|
export const Scroll = ({ grow = true, ...rest }) => _jsx(D, { ...rest, cn: CN('min-h-0 overflow-y-auto', rcn(rest)), grow: grow });
|