@scripso-homepad/ui 0.4.21 → 0.4.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scripso-homepad/ui",
3
- "version": "0.4.21",
3
+ "version": "0.4.22",
4
4
  "type": "module",
5
5
  "description": "Cross-platform UI components for Homepad (React Web + React Native)",
6
6
  "license": "MIT",
@@ -17,6 +17,7 @@ const meta = {
17
17
  placeholder: "placeholder",
18
18
  leftIcon: <KeyIcon />,
19
19
  options: demoOptions,
20
+ allowDeselect: true,
20
21
  },
21
22
  } satisfies Meta<typeof Select>;
22
23
 
@@ -214,6 +214,11 @@ interface SelectBaseProps {
214
214
  hintClassName?: string;
215
215
  /** Shorter option rows for compact filter-style dropdowns. */
216
216
  compact?: boolean;
217
+ /**
218
+ * When true (default), clicking the already-selected option clears the selection
219
+ * in single-select mode. Set to false for required fields that must keep a value.
220
+ */
221
+ allowDeselect?: boolean;
217
222
  }
218
223
 
219
224
  export interface SingleSelectProps extends SelectBaseProps {
@@ -266,6 +271,7 @@ export function Select({
266
271
  errorClassName,
267
272
  hintClassName,
268
273
  compact = false,
274
+ allowDeselect = true,
269
275
  }: SelectProps) {
270
276
  const wrapperRef = useRef<ComponentRef<typeof View>>(null);
271
277
  const triggerRef = useRef<ComponentRef<typeof Pressable>>(null);
@@ -389,9 +395,10 @@ export function Select({
389
395
  return;
390
396
  }
391
397
 
392
- // Keep the current value when the selected option is clicked again.
393
- // Clearing to "" breaks required selects (e.g. language) and shows the placeholder.
394
398
  if (selectedValues.includes(nextValue)) {
399
+ if (allowDeselect) {
400
+ (onValueChange as SingleSelectProps["onValueChange"] | undefined)?.("");
401
+ }
395
402
  closeMenu();
396
403
  return;
397
404
  }