b44ui 0.2.6 → 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.
Files changed (2) hide show
  1. package/dist/index.js +8 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -132,12 +132,19 @@ export const Textarea = ({ cn, cnIgnoreWrongUsage, ref, grow, gap, p, wd, ht, ..
132
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
- 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: state ? state[0] : rest.value, defaultValue: rest.defaultValue, onChange: e => {
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 => {
136
139
  if (title && e.target.value === '') {
140
+ setShowTitle(true);
137
141
  onChange?.(e);
138
142
  return;
139
143
  }
140
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);
141
148
  state?.[1](value);
142
149
  onChange?.(e);
143
150
  }, children: [title && _jsx("option", { value: '', children: title }), entries
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b44ui",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "./index.js",