@timeax/form-palette 0.0.17 → 0.0.19

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.mts CHANGED
@@ -8,7 +8,6 @@ import { DayPicker } from 'react-day-picker';
8
8
  import * as class_variance_authority_types from 'class-variance-authority/types';
9
9
  import { VariantProps } from 'class-variance-authority';
10
10
  import * as SwitchPrimitive from '@radix-ui/react-switch';
11
- import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
12
11
  import { $ZodError } from 'zod/v4/core';
13
12
  import './../../../../node_modules/@inertiajs/core/types/types.d';
14
13
  import 'axios';
@@ -1870,8 +1869,6 @@ interface ShadcnToggleUiProps extends Omit<React.ComponentProps<typeof Switch>,
1870
1869
  */
1871
1870
  type ShadcnToggleVariantProps$1 = ShadcnToggleUiProps & Pick<BaseProps, "value" | "onValue" | "error">;
1872
1871
 
1873
- declare function RadioGroup({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Root>): react_jsx_runtime.JSX.Element;
1874
-
1875
1872
  /**
1876
1873
  * Visual size of the radio UI.
1877
1874
  */
@@ -1919,6 +1916,7 @@ interface RadioRenderOptionContext<TValue> {
1919
1916
  disabled: boolean;
1920
1917
  size: RadioSize;
1921
1918
  density: RadioDensity;
1919
+ click(): void;
1922
1920
  /**
1923
1921
  * DOM id of this option (tied to the underlying RadioGroupItem).
1924
1922
  */
@@ -1956,7 +1954,7 @@ interface ShadcnRadioUiProps<TItem, TValue> {
1956
1954
  * items = [{ id: "free", title: "Free" }]
1957
1955
  * optionValue = "id"
1958
1956
  */
1959
- optionValue?: keyof TItem;
1957
+ optionValue?: (keyof TItem) | string;
1960
1958
  /**
1961
1959
  * Property name on TItem that holds the **label**.
1962
1960
  *
@@ -1964,7 +1962,7 @@ interface ShadcnRadioUiProps<TItem, TValue> {
1964
1962
  * items = [{ id: "free", title: "Free" }]
1965
1963
  * optionLabel = "title"
1966
1964
  */
1967
- optionLabel?: keyof TItem;
1965
+ optionLabel?: (keyof TItem) | string;
1968
1966
  /**
1969
1967
  * Optional custom renderer for each option.
1970
1968
  *
@@ -2027,8 +2025,9 @@ interface ShadcnRadioUiProps<TItem, TValue> {
2027
2025
  /**
2028
2026
  * Full props for the Shadcn-based radio variant.
2029
2027
  */
2030
- type ShadcnRadioVariantProps<TValue, TItem = RadioItem<TValue>> = ShadcnRadioUiProps<TItem, TValue> & Pick<VariantBaseProps<TValue | undefined>, "value" | "onValue" | "error" | "disabled" | "required"> & Pick<React.ComponentProps<typeof RadioGroup>, "name"> & {
2028
+ type ShadcnRadioVariantProps<TValue, TItem = RadioItem<TValue>> = ShadcnRadioUiProps<TItem, TValue> & Pick<VariantBaseProps<TValue | undefined>, "value" | "onValue" | "error" | "disabled" | "required"> & {
2031
2029
  id?: string;
2030
+ name?: string;
2032
2031
  className?: string;
2033
2032
  "aria-describedby"?: string;
2034
2033
  };
@@ -2094,6 +2093,7 @@ interface CheckboxRenderOptionContext<TValue> {
2094
2093
  size: CheckboxSize;
2095
2094
  density: CheckboxDensity;
2096
2095
  checkboxId?: string;
2096
+ click(): void;
2097
2097
  /**
2098
2098
  * Prebuilt Shadcn checkbox node.
2099
2099
  */
@@ -2354,6 +2354,7 @@ interface ShadcnMultiSelectVariantProps extends Pick<VariantBaseProps<SelectPrim
2354
2354
  selected: boolean;
2355
2355
  index: number;
2356
2356
  option: React.ReactNode;
2357
+ click(): void;
2357
2358
  }) => React.ReactNode;
2358
2359
  /**
2359
2360
  * Custom renderer for the trigger summary.
@@ -2760,6 +2761,7 @@ interface ShadcnTreeSelectVariantProps extends Pick<VariantBaseProps<TreeValue>,
2760
2761
  selected: boolean;
2761
2762
  index: number;
2762
2763
  option: React.ReactNode;
2764
+ click(): void;
2763
2765
  }) => React.ReactNode;
2764
2766
  renderValue?: (ctx: {
2765
2767
  selectedItems: NormalizedTreeItem[];
@@ -2974,6 +2976,7 @@ interface ShadcnSelectVariantProps extends Pick<VariantBaseProps<SelectPrimitive
2974
2976
  selected: boolean;
2975
2977
  index: number;
2976
2978
  option: React.ReactNode;
2979
+ click(): void;
2977
2980
  }) => React.ReactNode;
2978
2981
  /**
2979
2982
  * Custom renderer for the trigger value.
package/dist/index.d.ts CHANGED
@@ -8,7 +8,6 @@ import { DayPicker } from 'react-day-picker';
8
8
  import * as class_variance_authority_types from 'class-variance-authority/types';
9
9
  import { VariantProps } from 'class-variance-authority';
10
10
  import * as SwitchPrimitive from '@radix-ui/react-switch';
11
- import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
12
11
  import { $ZodError } from 'zod/v4/core';
13
12
  import './../../../../node_modules/@inertiajs/core/types/types.d';
14
13
  import 'axios';
@@ -1870,8 +1869,6 @@ interface ShadcnToggleUiProps extends Omit<React.ComponentProps<typeof Switch>,
1870
1869
  */
1871
1870
  type ShadcnToggleVariantProps$1 = ShadcnToggleUiProps & Pick<BaseProps, "value" | "onValue" | "error">;
1872
1871
 
1873
- declare function RadioGroup({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Root>): react_jsx_runtime.JSX.Element;
1874
-
1875
1872
  /**
1876
1873
  * Visual size of the radio UI.
1877
1874
  */
@@ -1919,6 +1916,7 @@ interface RadioRenderOptionContext<TValue> {
1919
1916
  disabled: boolean;
1920
1917
  size: RadioSize;
1921
1918
  density: RadioDensity;
1919
+ click(): void;
1922
1920
  /**
1923
1921
  * DOM id of this option (tied to the underlying RadioGroupItem).
1924
1922
  */
@@ -1956,7 +1954,7 @@ interface ShadcnRadioUiProps<TItem, TValue> {
1956
1954
  * items = [{ id: "free", title: "Free" }]
1957
1955
  * optionValue = "id"
1958
1956
  */
1959
- optionValue?: keyof TItem;
1957
+ optionValue?: (keyof TItem) | string;
1960
1958
  /**
1961
1959
  * Property name on TItem that holds the **label**.
1962
1960
  *
@@ -1964,7 +1962,7 @@ interface ShadcnRadioUiProps<TItem, TValue> {
1964
1962
  * items = [{ id: "free", title: "Free" }]
1965
1963
  * optionLabel = "title"
1966
1964
  */
1967
- optionLabel?: keyof TItem;
1965
+ optionLabel?: (keyof TItem) | string;
1968
1966
  /**
1969
1967
  * Optional custom renderer for each option.
1970
1968
  *
@@ -2027,8 +2025,9 @@ interface ShadcnRadioUiProps<TItem, TValue> {
2027
2025
  /**
2028
2026
  * Full props for the Shadcn-based radio variant.
2029
2027
  */
2030
- type ShadcnRadioVariantProps<TValue, TItem = RadioItem<TValue>> = ShadcnRadioUiProps<TItem, TValue> & Pick<VariantBaseProps<TValue | undefined>, "value" | "onValue" | "error" | "disabled" | "required"> & Pick<React.ComponentProps<typeof RadioGroup>, "name"> & {
2028
+ type ShadcnRadioVariantProps<TValue, TItem = RadioItem<TValue>> = ShadcnRadioUiProps<TItem, TValue> & Pick<VariantBaseProps<TValue | undefined>, "value" | "onValue" | "error" | "disabled" | "required"> & {
2031
2029
  id?: string;
2030
+ name?: string;
2032
2031
  className?: string;
2033
2032
  "aria-describedby"?: string;
2034
2033
  };
@@ -2094,6 +2093,7 @@ interface CheckboxRenderOptionContext<TValue> {
2094
2093
  size: CheckboxSize;
2095
2094
  density: CheckboxDensity;
2096
2095
  checkboxId?: string;
2096
+ click(): void;
2097
2097
  /**
2098
2098
  * Prebuilt Shadcn checkbox node.
2099
2099
  */
@@ -2354,6 +2354,7 @@ interface ShadcnMultiSelectVariantProps extends Pick<VariantBaseProps<SelectPrim
2354
2354
  selected: boolean;
2355
2355
  index: number;
2356
2356
  option: React.ReactNode;
2357
+ click(): void;
2357
2358
  }) => React.ReactNode;
2358
2359
  /**
2359
2360
  * Custom renderer for the trigger summary.
@@ -2760,6 +2761,7 @@ interface ShadcnTreeSelectVariantProps extends Pick<VariantBaseProps<TreeValue>,
2760
2761
  selected: boolean;
2761
2762
  index: number;
2762
2763
  option: React.ReactNode;
2764
+ click(): void;
2763
2765
  }) => React.ReactNode;
2764
2766
  renderValue?: (ctx: {
2765
2767
  selectedItems: NormalizedTreeItem[];
@@ -2974,6 +2976,7 @@ interface ShadcnSelectVariantProps extends Pick<VariantBaseProps<SelectPrimitive
2974
2976
  selected: boolean;
2975
2977
  index: number;
2976
2978
  option: React.ReactNode;
2979
+ click(): void;
2977
2980
  }) => React.ReactNode;
2978
2981
  /**
2979
2982
  * Custom renderer for the trigger value.
package/dist/index.js CHANGED
@@ -35570,6 +35570,7 @@ var InnerShadcnRadioVariant = (props, ref) => {
35570
35570
  () => normalizeItems(
35571
35571
  items,
35572
35572
  mappers,
35573
+ //@ts-ignore
35573
35574
  optionValue,
35574
35575
  optionLabel
35575
35576
  ),
@@ -35702,6 +35703,10 @@ var InnerShadcnRadioVariant = (props, ref) => {
35702
35703
  size: size4,
35703
35704
  density,
35704
35705
  optionId,
35706
+ click() {
35707
+ if (optionDisabled) return;
35708
+ handleSelect(displayItem.value);
35709
+ },
35705
35710
  radio: radioNode
35706
35711
  })
35707
35712
  },
@@ -36593,6 +36598,11 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
36593
36598
  size: size4,
36594
36599
  density,
36595
36600
  checkboxId,
36601
+ click() {
36602
+ if (optionDisabled) return;
36603
+ const nextInternal = effectiveTristate ? internalState === "none" ? true : internalState === true ? false : "none" : internalState === true ? false : true;
36604
+ updateGroupValue(item.value, nextInternal, effectiveTristate);
36605
+ },
36596
36606
  checkbox: checkboxNode
36597
36607
  }),
36598
36608
  hiddenInput
@@ -36658,11 +36668,9 @@ var checkboxModule = {
36658
36668
  tags: ["checkbox", "group", "boolean", "tri-state"]
36659
36669
  }
36660
36670
  };
36661
- function capitalizeFirst3(label) {
36662
- if (!label) return label;
36663
- return label.charAt(0).toUpperCase() + label.slice(1);
36664
- }
36665
- function normalizeOptions(opts, config3) {
36671
+
36672
+ // src/lib/normalise-selects.ts
36673
+ function globalNormalizeOptions(opts, config3) {
36666
36674
  if (!opts || !opts.length) return [];
36667
36675
  return opts.map((raw, index2) => {
36668
36676
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
@@ -36689,6 +36697,13 @@ function normalizeOptions(opts, config3) {
36689
36697
  };
36690
36698
  });
36691
36699
  }
36700
+ function capitalizeFirst3(label) {
36701
+ if (!label) return label;
36702
+ return label.charAt(0).toUpperCase() + label.slice(1);
36703
+ }
36704
+ function normalizeOptions(opts, config3) {
36705
+ return globalNormalizeOptions(opts, config3);
36706
+ }
36692
36707
  function triggerHeight(size4) {
36693
36708
  switch (size4) {
36694
36709
  case "sm":
@@ -37014,7 +37029,13 @@ var ShadcnSelectVariant = React54__namespace.forwardRef(function ShadcnSelectVar
37014
37029
  item,
37015
37030
  selected: selectedItem != null && String(selectedItem.value) === String(item.value),
37016
37031
  index: index2,
37017
- option: optionNode
37032
+ option: optionNode,
37033
+ click() {
37034
+ if (disabled || readOnly || item.disabled) return;
37035
+ handleChange(String(item.value));
37036
+ setOpen(false);
37037
+ setQuery("");
37038
+ }
37018
37039
  });
37019
37040
  }),
37020
37041
  virtualScroll && renderedItems.length < filteredItems.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1 text-[10px] text-muted-foreground text-center", children: "Scroll to load more\u2026" })
@@ -37304,36 +37325,8 @@ function removeSelectValue(current, valueToRemove) {
37304
37325
  const target = String(valueToRemove);
37305
37326
  return current.filter((v) => String(v) !== target);
37306
37327
  }
37307
- function capitalizeFirst4(label) {
37308
- if (!label) return label;
37309
- return label.charAt(0).toUpperCase() + label.slice(1);
37310
- }
37311
37328
  function normalizeOptions2(opts, config3) {
37312
- if (!opts || !opts.length) return [];
37313
- return opts.map((raw, index2) => {
37314
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
37315
- const asObj = typeof raw === "string" || typeof raw === "number" ? { label: String(raw), value: raw } : raw;
37316
- const value = typeof config3.optionValue === "function" ? config3.optionValue(raw) : typeof config3.optionValue === "string" ? asObj[config3.optionValue] : (_c = (_b = (_a = asObj.value) != null ? _a : asObj.id) != null ? _b : asObj.key) != null ? _c : String(index2);
37317
- let labelNode = typeof config3.optionLabel === "function" ? config3.optionLabel(raw) : typeof config3.optionLabel === "string" ? (_e = (_d = asObj[config3.optionLabel]) != null ? _d : asObj.label) != null ? _e : String(value) : (_f = asObj.label) != null ? _f : String(value);
37318
- if (config3.autoCap && typeof labelNode === "string") {
37319
- labelNode = capitalizeFirst4(labelNode);
37320
- }
37321
- const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
37322
- const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;
37323
- const disabled = typeof config3.optionDisabled === "function" ? config3.optionDisabled(raw) : typeof config3.optionDisabled === "string" ? !!asObj[config3.optionDisabled] : !!asObj.disabled;
37324
- const icon = typeof config3.optionIcon === "function" ? config3.optionIcon(raw) : typeof config3.optionIcon === "string" ? asObj[config3.optionIcon] : asObj.icon;
37325
- const key = typeof config3.optionKey === "function" ? config3.optionKey(raw, index2) : typeof config3.optionKey === "string" ? (_i = (_h = asObj[config3.optionKey]) != null ? _h : value) != null ? _i : index2 : (_k = (_j = asObj.key) != null ? _j : value) != null ? _k : index2;
37326
- return {
37327
- key: String(key),
37328
- value,
37329
- labelNode,
37330
- labelText,
37331
- description,
37332
- disabled,
37333
- icon,
37334
- raw
37335
- };
37336
- });
37329
+ return globalNormalizeOptions(opts, config3);
37337
37330
  }
37338
37331
  function triggerHeight2(size4) {
37339
37332
  switch (size4) {
@@ -37437,9 +37430,7 @@ var ShadcnMultiSelectVariant = React54__namespace.forwardRef(function ShadcnMult
37437
37430
  const filteredItems = React54__namespace.useMemo(() => {
37438
37431
  if (!query) return items;
37439
37432
  const q = query.toLowerCase();
37440
- return items.filter(
37441
- (it) => it.labelText.toLowerCase().includes(q)
37442
- );
37433
+ return items.filter((it) => it.labelText.toLowerCase().includes(q));
37443
37434
  }, [items, query]);
37444
37435
  const selectableItems = React54__namespace.useMemo(
37445
37436
  () => items.filter((it) => !it.disabled),
@@ -37592,7 +37583,7 @@ var ShadcnMultiSelectVariant = React54__namespace.forwardRef(function ShadcnMult
37592
37583
  type: "button",
37593
37584
  disabled: disabledTrigger,
37594
37585
  className: cn(
37595
- "flex w-full items-center justify-between rounded-md border border-input bg-background px-3 text-left shadow-xs",
37586
+ "flex w-full items-center justify-between rounded-md border border-input bg-surfaces-input px-3 text-left shadow-xs",
37596
37587
  "focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:border-ring",
37597
37588
  "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
37598
37589
  heightCls,
@@ -37717,9 +37708,7 @@ var ShadcnMultiSelectVariant = React54__namespace.forwardRef(function ShadcnMult
37717
37708
  }
37718
37709
  ),
37719
37710
  filteredItems.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: emptySearchText != null ? emptySearchText : "No results found" }) : filteredItems.map((item, index2) => {
37720
- const selected = selectedValues.has(
37721
- item.value
37722
- );
37711
+ const selected = selectedValues.has(item.value);
37723
37712
  const row = /* @__PURE__ */ jsxRuntime.jsxs(
37724
37713
  "button",
37725
37714
  {
@@ -37756,7 +37745,11 @@ var ShadcnMultiSelectVariant = React54__namespace.forwardRef(function ShadcnMult
37756
37745
  item,
37757
37746
  selected,
37758
37747
  index: index2,
37759
- option: row
37748
+ option: row,
37749
+ click() {
37750
+ if (item.disabled) return;
37751
+ handleToggleValue(item.value);
37752
+ }
37760
37753
  });
37761
37754
  }),
37762
37755
  showSelectAll && selectAllPosition === "bottom" && /* @__PURE__ */ jsxRuntime.jsxs(
@@ -37846,9 +37839,7 @@ var ShadcnMultiSelectVariant = React54__namespace.forwardRef(function ShadcnMult
37846
37839
  /* @__PURE__ */ jsxRuntime.jsx(
37847
37840
  "div",
37848
37841
  {
37849
- className: cn(
37850
- "flex-1 min-w-0 flex items-stretch"
37851
- ),
37842
+ className: cn("flex-1 min-w-0 flex items-stretch"),
37852
37843
  "data-slot": "select-region",
37853
37844
  children: MultiSelectCore
37854
37845
  }
@@ -40077,7 +40068,7 @@ function Badge({
40077
40068
  }
40078
40069
  );
40079
40070
  }
40080
- function capitalizeFirst5(label) {
40071
+ function capitalizeFirst4(label) {
40081
40072
  if (!label) return label;
40082
40073
  return label.charAt(0).toUpperCase() + label.slice(1);
40083
40074
  }
@@ -40089,7 +40080,7 @@ function normalizeTree(opts, config3, level = 0, parentValue, path = []) {
40089
40080
  const value = typeof config3.optionValue === "function" ? config3.optionValue(raw) : typeof config3.optionValue === "string" ? asObj[config3.optionValue] : (_c = (_b = (_a = asObj.value) != null ? _a : asObj.id) != null ? _b : asObj.key) != null ? _c : String(index2);
40090
40081
  let labelNode = typeof config3.optionLabel === "function" ? config3.optionLabel(raw) : typeof config3.optionLabel === "string" ? (_e = (_d = asObj[config3.optionLabel]) != null ? _d : asObj.label) != null ? _e : String(value) : (_f = asObj.label) != null ? _f : String(value);
40091
40082
  if (config3.autoCap && typeof labelNode === "string") {
40092
- labelNode = capitalizeFirst5(labelNode);
40083
+ labelNode = capitalizeFirst4(labelNode);
40093
40084
  }
40094
40085
  const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
40095
40086
  const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;
@@ -40399,7 +40390,7 @@ var ShadcnTreeSelectVariant = React54__namespace.forwardRef(function ShadcnTreeS
40399
40390
  displayedNodes.map((item, index2) => {
40400
40391
  const selected = selectedValues.includes(item.value);
40401
40392
  const isExpanded = expanded.has(item.value);
40402
- return /* @__PURE__ */ jsxRuntime.jsxs(
40393
+ const optionNode = /* @__PURE__ */ jsxRuntime.jsxs(
40403
40394
  "div",
40404
40395
  {
40405
40396
  className: cn(
@@ -40457,6 +40448,16 @@ var ShadcnTreeSelectVariant = React54__namespace.forwardRef(function ShadcnTreeS
40457
40448
  },
40458
40449
  item.key
40459
40450
  );
40451
+ if (!renderOption) return optionNode;
40452
+ return renderOption({
40453
+ item,
40454
+ selected,
40455
+ index: index2,
40456
+ option: optionNode,
40457
+ click() {
40458
+ if (!item.disabled) handleToggleValue(item);
40459
+ }
40460
+ });
40460
40461
  })
40461
40462
  ] });
40462
40463
  const SelectBody = /* @__PURE__ */ jsxRuntime.jsxs(
@@ -43133,7 +43134,7 @@ function normalizeValue(val, multiple) {
43133
43134
  if (Array.isArray(val)) return val[0] || "";
43134
43135
  return val || "";
43135
43136
  }
43136
- function capitalizeFirst6(label) {
43137
+ function capitalizeFirst5(label) {
43137
43138
  if (!label) return label;
43138
43139
  return label.charAt(0).toUpperCase() + label.slice(1);
43139
43140
  }
@@ -43159,7 +43160,7 @@ function normalizeOption(input, {
43159
43160
  label2 = String(rawValue != null ? rawValue : value2);
43160
43161
  }
43161
43162
  if (autoCap && typeof label2 === "string") {
43162
- label2 = capitalizeFirst6(label2);
43163
+ label2 = capitalizeFirst5(label2);
43163
43164
  }
43164
43165
  const icon = optionIcon != null ? anyInput[optionIcon] : (_b = anyInput.icon) != null ? _b : void 0;
43165
43166
  const disabled = optionDisabled != null ? !!anyInput[optionDisabled] : !!anyInput.disabled;
@@ -43181,7 +43182,7 @@ function normalizeOption(input, {
43181
43182
  const value2 = String(input);
43182
43183
  let label2 = value2;
43183
43184
  if (autoCap && typeof label2 === "string") {
43184
- label2 = capitalizeFirst6(label2);
43185
+ label2 = capitalizeFirst5(label2);
43185
43186
  }
43186
43187
  return {
43187
43188
  ui: {
@@ -43195,7 +43196,7 @@ function normalizeOption(input, {
43195
43196
  const value = String(baseValue);
43196
43197
  let label = anyInput.label != null ? anyInput.label : String(value);
43197
43198
  if (autoCap && typeof label === "string") {
43198
- label = capitalizeFirst6(label);
43199
+ label = capitalizeFirst5(label);
43199
43200
  }
43200
43201
  return {
43201
43202
  ui: {