@timeax/form-palette 0.0.13 → 0.0.15

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.mjs CHANGED
@@ -14069,6 +14069,26 @@ function CoreRoot(props) {
14069
14069
  ] });
14070
14070
  }
14071
14071
  function CoreShell(props) {
14072
+ if (props.wrapped) {
14073
+ const {
14074
+ formProps: formProps2,
14075
+ children: children2,
14076
+ wrapped,
14077
+ // eslint-disable-line @typescript-eslint/no-unused-vars
14078
+ gap,
14079
+ contentClassName,
14080
+ ...coreProps2
14081
+ } = props;
14082
+ const content = /* @__PURE__ */ jsx(
14083
+ "div",
14084
+ {
14085
+ className: contentClassName,
14086
+ style: gap !== void 0 ? { gap } : void 0,
14087
+ children: children2
14088
+ }
14089
+ );
14090
+ return /* @__PURE__ */ jsx(CoreProvider, { ...coreProps2, children: /* @__PURE__ */ jsx(CoreRoot, { ...formProps2 != null ? formProps2 : {}, children: content }) });
14091
+ }
14072
14092
  const { formProps, children, ...coreProps } = props;
14073
14093
  return /* @__PURE__ */ jsx(CoreProvider, { ...coreProps, children: /* @__PURE__ */ jsx(CoreRoot, { ...formProps != null ? formProps : {}, children }) });
14074
14094
  }
@@ -35439,6 +35459,10 @@ function descriptionTextSize(size4) {
35439
35459
  return "text-xs";
35440
35460
  }
35441
35461
  }
35462
+ function capitalizeFirst(label) {
35463
+ if (!label) return label;
35464
+ return label.charAt(0).toUpperCase() + label.slice(1);
35465
+ }
35442
35466
  function normalizeItems(items, mappers, optionValueKey, optionLabelKey) {
35443
35467
  if (mappers) {
35444
35468
  return items.map((item, index2) => ({
@@ -35468,7 +35492,19 @@ function normalizeItems(items, mappers, optionValueKey, optionLabelKey) {
35468
35492
  };
35469
35493
  });
35470
35494
  }
35471
- return items;
35495
+ return items.map((item, index2) => {
35496
+ if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
35497
+ const v = item;
35498
+ return {
35499
+ value: v,
35500
+ label: String(item),
35501
+ description: void 0,
35502
+ disabled: false,
35503
+ key: index2
35504
+ };
35505
+ }
35506
+ return item;
35507
+ });
35472
35508
  }
35473
35509
  function isEqualValue(a, b) {
35474
35510
  return Object.is(a, b);
@@ -35492,6 +35528,7 @@ var InnerShadcnRadioVariant = (props, ref) => {
35492
35528
  itemGapPx,
35493
35529
  size: size4 = "md",
35494
35530
  density = "comfortable",
35531
+ autoCap = false,
35495
35532
  "aria-label": ariaLabel,
35496
35533
  "aria-labelledby": ariaLabelledBy,
35497
35534
  "aria-describedby": ariaDescribedBy,
@@ -35611,6 +35648,13 @@ var InnerShadcnRadioVariant = (props, ref) => {
35611
35648
  const optionDisabled = !!disabled || !!item.disabled;
35612
35649
  const optionKey = (_a = item.key) != null ? _a : index2;
35613
35650
  const optionId = id ? `${id}-option-${optionKey}` : void 0;
35651
+ let displayItem = item;
35652
+ if (autoCap && typeof item.label === "string") {
35653
+ displayItem = {
35654
+ ...item,
35655
+ label: capitalizeFirst(item.label)
35656
+ };
35657
+ }
35614
35658
  const radioNode = /* @__PURE__ */ jsx(
35615
35659
  RadioGroupItem2,
35616
35660
  {
@@ -35629,7 +35673,7 @@ var InnerShadcnRadioVariant = (props, ref) => {
35629
35673
  "data-disabled": optionDisabled ? "true" : "false",
35630
35674
  className: baseOptionClass,
35631
35675
  children: renderOption({
35632
- item,
35676
+ item: displayItem,
35633
35677
  index: index2,
35634
35678
  selected,
35635
35679
  disabled: optionDisabled,
@@ -35657,8 +35701,8 @@ var InnerShadcnRadioVariant = (props, ref) => {
35657
35701
  children: [
35658
35702
  radioNode,
35659
35703
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col min-w-0", children: [
35660
- /* @__PURE__ */ jsx("span", { className: labelClassesBase, children: item.label }),
35661
- item.description != null && /* @__PURE__ */ jsx("span", { className: descriptionClassesBase, children: item.description })
35704
+ /* @__PURE__ */ jsx("span", { className: labelClassesBase, children: displayItem.label }),
35705
+ displayItem.description != null && /* @__PURE__ */ jsx("span", { className: descriptionClassesBase, children: displayItem.description })
35662
35706
  ] })
35663
35707
  ]
35664
35708
  }
@@ -36154,6 +36198,10 @@ function descriptionTextSize2(size4) {
36154
36198
  return "text-xs";
36155
36199
  }
36156
36200
  }
36201
+ function capitalizeFirst2(label) {
36202
+ if (!label) return label;
36203
+ return label.charAt(0).toUpperCase() + label.slice(1);
36204
+ }
36157
36205
  function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
36158
36206
  if (!items || !items.length) return [];
36159
36207
  if (mappers) {
@@ -36187,7 +36235,20 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
36187
36235
  };
36188
36236
  });
36189
36237
  }
36190
- return items;
36238
+ return items.map((item, index2) => {
36239
+ if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
36240
+ const v = item;
36241
+ return {
36242
+ value: v,
36243
+ label: String(item),
36244
+ description: void 0,
36245
+ disabled: false,
36246
+ key: index2,
36247
+ tristate: void 0
36248
+ };
36249
+ }
36250
+ return item;
36251
+ });
36191
36252
  }
36192
36253
  function isEqualValue2(a, b) {
36193
36254
  return Object.is(a, b);
@@ -36223,6 +36284,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
36223
36284
  itemGapPx,
36224
36285
  size: size4 = "md",
36225
36286
  density = "comfortable",
36287
+ autoCap = false,
36226
36288
  "aria-label": ariaLabel,
36227
36289
  "aria-labelledby": ariaLabelledBy,
36228
36290
  "aria-describedby": ariaDescribedBy,
@@ -36260,7 +36322,10 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
36260
36322
  };
36261
36323
  onValue(nextPublic, detail);
36262
36324
  };
36263
- const labelText = singleLabel != null ? singleLabel : void 0;
36325
+ let labelText = singleLabel != null ? singleLabel : void 0;
36326
+ if (autoCap && typeof labelText === "string") {
36327
+ labelText = capitalizeFirst2(labelText);
36328
+ }
36264
36329
  const descriptionText = singleDescription != null ? singleDescription : void 0;
36265
36330
  const labelCls = cn(
36266
36331
  "text-foreground",
@@ -36458,6 +36523,13 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
36458
36523
  const optionDisabled = !!disabled || !!item.disabled;
36459
36524
  const optionKey = (_c = item.key) != null ? _c : index2;
36460
36525
  const checkboxId = id ? `${id}-option-${optionKey}` : void 0;
36526
+ let displayItem = item;
36527
+ if (autoCap && typeof item.label === "string") {
36528
+ displayItem = {
36529
+ ...item,
36530
+ label: capitalizeFirst2(item.label)
36531
+ };
36532
+ }
36461
36533
  const checkboxNode = /* @__PURE__ */ jsx(
36462
36534
  Checkbox2,
36463
36535
  {
@@ -36491,7 +36563,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
36491
36563
  className: baseOptionClass,
36492
36564
  children: [
36493
36565
  renderOption({
36494
- item,
36566
+ item: displayItem,
36495
36567
  index: index2,
36496
36568
  state: internalState,
36497
36569
  effectiveTristate,
@@ -36522,12 +36594,12 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
36522
36594
  children: [
36523
36595
  checkboxNode,
36524
36596
  /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", children: [
36525
- /* @__PURE__ */ jsx("span", { className: labelClassesBase, children: item.label }),
36526
- item.description != null && /* @__PURE__ */ jsx(
36597
+ /* @__PURE__ */ jsx("span", { className: labelClassesBase, children: displayItem.label }),
36598
+ displayItem.description != null && /* @__PURE__ */ jsx(
36527
36599
  "span",
36528
36600
  {
36529
36601
  className: descriptionClassesBase,
36530
- children: item.description
36602
+ children: displayItem.description
36531
36603
  }
36532
36604
  )
36533
36605
  ] })
@@ -36564,7 +36636,7 @@ var checkboxModule = {
36564
36636
  tags: ["checkbox", "group", "boolean", "tri-state"]
36565
36637
  }
36566
36638
  };
36567
- function capitalizeFirst(label) {
36639
+ function capitalizeFirst3(label) {
36568
36640
  if (!label) return label;
36569
36641
  return label.charAt(0).toUpperCase() + label.slice(1);
36570
36642
  }
@@ -36576,7 +36648,7 @@ function normalizeOptions(opts, config3) {
36576
36648
  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);
36577
36649
  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);
36578
36650
  if (config3.autoCap && typeof labelNode === "string") {
36579
- labelNode = capitalizeFirst(labelNode);
36651
+ labelNode = capitalizeFirst3(labelNode);
36580
36652
  }
36581
36653
  const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
36582
36654
  const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;
@@ -37210,7 +37282,7 @@ function removeSelectValue(current, valueToRemove) {
37210
37282
  const target = String(valueToRemove);
37211
37283
  return current.filter((v) => String(v) !== target);
37212
37284
  }
37213
- function capitalizeFirst2(label) {
37285
+ function capitalizeFirst4(label) {
37214
37286
  if (!label) return label;
37215
37287
  return label.charAt(0).toUpperCase() + label.slice(1);
37216
37288
  }
@@ -37222,7 +37294,7 @@ function normalizeOptions2(opts, config3) {
37222
37294
  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);
37223
37295
  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);
37224
37296
  if (config3.autoCap && typeof labelNode === "string") {
37225
- labelNode = capitalizeFirst2(labelNode);
37297
+ labelNode = capitalizeFirst4(labelNode);
37226
37298
  }
37227
37299
  const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
37228
37300
  const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;
@@ -39983,7 +40055,7 @@ function Badge({
39983
40055
  }
39984
40056
  );
39985
40057
  }
39986
- function capitalizeFirst3(label) {
40058
+ function capitalizeFirst5(label) {
39987
40059
  if (!label) return label;
39988
40060
  return label.charAt(0).toUpperCase() + label.slice(1);
39989
40061
  }
@@ -39995,7 +40067,7 @@ function normalizeTree(opts, config3, level = 0, parentValue, path = []) {
39995
40067
  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);
39996
40068
  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);
39997
40069
  if (config3.autoCap && typeof labelNode === "string") {
39998
- labelNode = capitalizeFirst3(labelNode);
40070
+ labelNode = capitalizeFirst5(labelNode);
39999
40071
  }
40000
40072
  const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
40001
40073
  const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;