b44ui 0.2.4 → 0.2.5

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 CHANGED
@@ -27,6 +27,8 @@ type AppProps = DivProps & {
27
27
  htScreen?: boolean;
28
28
  };
29
29
  type InputState = [string, React.Dispatch<React.SetStateAction<string>>];
30
+ type SelectValue = string | number;
31
+ type SelectState<T extends SelectValue = SelectValue> = [T, React.Dispatch<React.SetStateAction<T>>];
30
32
  export declare const D: ({ children, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, row, col, ratio, align, ...rest }: DivProps) => import("react/jsx-runtime").JSX.Element;
31
33
  export declare const H1: ({ children, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, row, col, ratio, align, ...rest }: HeadingProps) => import("react").DetailedReactHTMLElement<{
32
34
  className: string;
@@ -1763,7 +1765,12 @@ export declare const Input: ({ state, cn, cnIgnoreWrongUsage, grow, gap, p, wd,
1763
1765
  export declare const Textarea: ({ cn, cnIgnoreWrongUsage, ref, grow, gap, p, wd, ht, ...rest }: DProps & React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
1764
1766
  ref?: React.RefObject<HTMLTextAreaElement | null>;
1765
1767
  }) => import("react/jsx-runtime").JSX.Element;
1766
- export declare const Select: ({ cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, ...rest }: DProps & React.SelectHTMLAttributes<HTMLSelectElement>) => 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"> & {
1769
+ state?: SelectState<T>;
1770
+ options?: Record<string, T>;
1771
+ value?: T;
1772
+ defaultValue?: T;
1773
+ }) => import("react/jsx-runtime").JSX.Element;
1767
1774
  export declare const Grid: ({ children, cols, gap, ...rest }: DivProps & {
1768
1775
  cols?: number;
1769
1776
  }) => import("react/jsx-runtime").JSX.Element;
package/dist/index.js CHANGED
@@ -129,9 +129,16 @@ 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 = ({ cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, ...rest }) => {
132
+ export const Select = ({ state, options, cn, cnIgnoreWrongUsage, grow, gap, p, wd, ht, onChange, children, ...rest }) => {
133
133
  const c = rcn({ cn, cnIgnoreWrongUsage, className: rest.className });
134
- return _jsx("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 }) });
134
+ const entries = options ? Object.entries(options) : undefined;
135
+ return _jsx("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: state ? state[0] : rest.value, defaultValue: rest.defaultValue, onChange: e => {
136
+ const value = entries?.find(([, value]) => String(value) === e.target.value)?.[1] ?? e.target.value;
137
+ state?.[1](value);
138
+ onChange?.(e);
139
+ }, children: entries
140
+ ? entries.map(([label, value]) => _jsx("option", { value: value, children: label }, `${label}:${value}`))
141
+ : children });
135
142
  };
136
143
  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 });
137
144
  export const Scroll = ({ grow = true, ...rest }) => _jsx(D, { ...rest, cn: CN('min-h-0 overflow-y-auto', rcn(rest)), grow: grow });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b44ui",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "./index.js",