@timeax/form-palette 0.0.13 → 0.0.14
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 +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +68 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1940,6 +1940,7 @@ interface ShadcnRadioUiProps<TItem, TValue> {
|
|
|
1940
1940
|
* - `RadioItem<TValue>[]`, or
|
|
1941
1941
|
* - any custom TItem[] when used with mapping functions
|
|
1942
1942
|
* or optionValue/optionLabel keys.
|
|
1943
|
+
* - primitive arrays such as `string[]` or `number[]` (fallback).
|
|
1943
1944
|
*/
|
|
1944
1945
|
items: readonly TItem[];
|
|
1945
1946
|
/**
|
|
@@ -1996,6 +1997,11 @@ interface ShadcnRadioUiProps<TItem, TValue> {
|
|
|
1996
1997
|
* Default: "comfortable".
|
|
1997
1998
|
*/
|
|
1998
1999
|
density?: RadioDensity;
|
|
2000
|
+
/**
|
|
2001
|
+
* When true, capitalizes the **first letter** of the label
|
|
2002
|
+
* (only applied when the label is a string).
|
|
2003
|
+
*/
|
|
2004
|
+
autoCap?: boolean;
|
|
1999
2005
|
/**
|
|
2000
2006
|
* ARIA overrides for the group.
|
|
2001
2007
|
*/
|
|
@@ -2166,6 +2172,11 @@ interface ShadcnCheckboxUiProps<TItem, TValue> {
|
|
|
2166
2172
|
* Default: "comfortable".
|
|
2167
2173
|
*/
|
|
2168
2174
|
density?: CheckboxDensity;
|
|
2175
|
+
/**
|
|
2176
|
+
* When true, capitalizes the first letter of the label
|
|
2177
|
+
* (only applied when the label is a string).
|
|
2178
|
+
*/
|
|
2179
|
+
autoCap?: boolean;
|
|
2169
2180
|
/**
|
|
2170
2181
|
* ARIA attributes for the group wrapper.
|
|
2171
2182
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1940,6 +1940,7 @@ interface ShadcnRadioUiProps<TItem, TValue> {
|
|
|
1940
1940
|
* - `RadioItem<TValue>[]`, or
|
|
1941
1941
|
* - any custom TItem[] when used with mapping functions
|
|
1942
1942
|
* or optionValue/optionLabel keys.
|
|
1943
|
+
* - primitive arrays such as `string[]` or `number[]` (fallback).
|
|
1943
1944
|
*/
|
|
1944
1945
|
items: readonly TItem[];
|
|
1945
1946
|
/**
|
|
@@ -1996,6 +1997,11 @@ interface ShadcnRadioUiProps<TItem, TValue> {
|
|
|
1996
1997
|
* Default: "comfortable".
|
|
1997
1998
|
*/
|
|
1998
1999
|
density?: RadioDensity;
|
|
2000
|
+
/**
|
|
2001
|
+
* When true, capitalizes the **first letter** of the label
|
|
2002
|
+
* (only applied when the label is a string).
|
|
2003
|
+
*/
|
|
2004
|
+
autoCap?: boolean;
|
|
1999
2005
|
/**
|
|
2000
2006
|
* ARIA overrides for the group.
|
|
2001
2007
|
*/
|
|
@@ -2166,6 +2172,11 @@ interface ShadcnCheckboxUiProps<TItem, TValue> {
|
|
|
2166
2172
|
* Default: "comfortable".
|
|
2167
2173
|
*/
|
|
2168
2174
|
density?: CheckboxDensity;
|
|
2175
|
+
/**
|
|
2176
|
+
* When true, capitalizes the first letter of the label
|
|
2177
|
+
* (only applied when the label is a string).
|
|
2178
|
+
*/
|
|
2179
|
+
autoCap?: boolean;
|
|
2169
2180
|
/**
|
|
2170
2181
|
* ARIA attributes for the group wrapper.
|
|
2171
2182
|
*/
|
package/dist/index.js
CHANGED
|
@@ -35460,6 +35460,10 @@ function descriptionTextSize(size4) {
|
|
|
35460
35460
|
return "text-xs";
|
|
35461
35461
|
}
|
|
35462
35462
|
}
|
|
35463
|
+
function capitalizeFirst(label) {
|
|
35464
|
+
if (!label) return label;
|
|
35465
|
+
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
35466
|
+
}
|
|
35463
35467
|
function normalizeItems(items, mappers, optionValueKey, optionLabelKey) {
|
|
35464
35468
|
if (mappers) {
|
|
35465
35469
|
return items.map((item, index2) => ({
|
|
@@ -35489,7 +35493,19 @@ function normalizeItems(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
35489
35493
|
};
|
|
35490
35494
|
});
|
|
35491
35495
|
}
|
|
35492
|
-
return items
|
|
35496
|
+
return items.map((item, index2) => {
|
|
35497
|
+
if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
|
|
35498
|
+
const v = item;
|
|
35499
|
+
return {
|
|
35500
|
+
value: v,
|
|
35501
|
+
label: String(item),
|
|
35502
|
+
description: void 0,
|
|
35503
|
+
disabled: false,
|
|
35504
|
+
key: index2
|
|
35505
|
+
};
|
|
35506
|
+
}
|
|
35507
|
+
return item;
|
|
35508
|
+
});
|
|
35493
35509
|
}
|
|
35494
35510
|
function isEqualValue(a, b) {
|
|
35495
35511
|
return Object.is(a, b);
|
|
@@ -35513,6 +35529,7 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
35513
35529
|
itemGapPx,
|
|
35514
35530
|
size: size4 = "md",
|
|
35515
35531
|
density = "comfortable",
|
|
35532
|
+
autoCap = false,
|
|
35516
35533
|
"aria-label": ariaLabel,
|
|
35517
35534
|
"aria-labelledby": ariaLabelledBy,
|
|
35518
35535
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -35632,6 +35649,13 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
35632
35649
|
const optionDisabled = !!disabled || !!item.disabled;
|
|
35633
35650
|
const optionKey = (_a = item.key) != null ? _a : index2;
|
|
35634
35651
|
const optionId = id ? `${id}-option-${optionKey}` : void 0;
|
|
35652
|
+
let displayItem = item;
|
|
35653
|
+
if (autoCap && typeof item.label === "string") {
|
|
35654
|
+
displayItem = {
|
|
35655
|
+
...item,
|
|
35656
|
+
label: capitalizeFirst(item.label)
|
|
35657
|
+
};
|
|
35658
|
+
}
|
|
35635
35659
|
const radioNode = /* @__PURE__ */ jsxRuntime.jsx(
|
|
35636
35660
|
RadioGroupItem2,
|
|
35637
35661
|
{
|
|
@@ -35650,7 +35674,7 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
35650
35674
|
"data-disabled": optionDisabled ? "true" : "false",
|
|
35651
35675
|
className: baseOptionClass,
|
|
35652
35676
|
children: renderOption({
|
|
35653
|
-
item,
|
|
35677
|
+
item: displayItem,
|
|
35654
35678
|
index: index2,
|
|
35655
35679
|
selected,
|
|
35656
35680
|
disabled: optionDisabled,
|
|
@@ -35678,8 +35702,8 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
35678
35702
|
children: [
|
|
35679
35703
|
radioNode,
|
|
35680
35704
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-w-0", children: [
|
|
35681
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClassesBase, children:
|
|
35682
|
-
|
|
35705
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClassesBase, children: displayItem.label }),
|
|
35706
|
+
displayItem.description != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: descriptionClassesBase, children: displayItem.description })
|
|
35683
35707
|
] })
|
|
35684
35708
|
]
|
|
35685
35709
|
}
|
|
@@ -36175,6 +36199,10 @@ function descriptionTextSize2(size4) {
|
|
|
36175
36199
|
return "text-xs";
|
|
36176
36200
|
}
|
|
36177
36201
|
}
|
|
36202
|
+
function capitalizeFirst2(label) {
|
|
36203
|
+
if (!label) return label;
|
|
36204
|
+
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
36205
|
+
}
|
|
36178
36206
|
function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
|
|
36179
36207
|
if (!items || !items.length) return [];
|
|
36180
36208
|
if (mappers) {
|
|
@@ -36208,7 +36236,20 @@ function normalizeItems2(items, mappers, optionValueKey, optionLabelKey) {
|
|
|
36208
36236
|
};
|
|
36209
36237
|
});
|
|
36210
36238
|
}
|
|
36211
|
-
return items
|
|
36239
|
+
return items.map((item, index2) => {
|
|
36240
|
+
if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
|
|
36241
|
+
const v = item;
|
|
36242
|
+
return {
|
|
36243
|
+
value: v,
|
|
36244
|
+
label: String(item),
|
|
36245
|
+
description: void 0,
|
|
36246
|
+
disabled: false,
|
|
36247
|
+
key: index2,
|
|
36248
|
+
tristate: void 0
|
|
36249
|
+
};
|
|
36250
|
+
}
|
|
36251
|
+
return item;
|
|
36252
|
+
});
|
|
36212
36253
|
}
|
|
36213
36254
|
function isEqualValue2(a, b) {
|
|
36214
36255
|
return Object.is(a, b);
|
|
@@ -36244,6 +36285,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
36244
36285
|
itemGapPx,
|
|
36245
36286
|
size: size4 = "md",
|
|
36246
36287
|
density = "comfortable",
|
|
36288
|
+
autoCap = false,
|
|
36247
36289
|
"aria-label": ariaLabel,
|
|
36248
36290
|
"aria-labelledby": ariaLabelledBy,
|
|
36249
36291
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -36281,7 +36323,10 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
36281
36323
|
};
|
|
36282
36324
|
onValue(nextPublic, detail);
|
|
36283
36325
|
};
|
|
36284
|
-
|
|
36326
|
+
let labelText = singleLabel != null ? singleLabel : void 0;
|
|
36327
|
+
if (autoCap && typeof labelText === "string") {
|
|
36328
|
+
labelText = capitalizeFirst2(labelText);
|
|
36329
|
+
}
|
|
36285
36330
|
const descriptionText = singleDescription != null ? singleDescription : void 0;
|
|
36286
36331
|
const labelCls = cn(
|
|
36287
36332
|
"text-foreground",
|
|
@@ -36479,6 +36524,13 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
36479
36524
|
const optionDisabled = !!disabled || !!item.disabled;
|
|
36480
36525
|
const optionKey = (_c = item.key) != null ? _c : index2;
|
|
36481
36526
|
const checkboxId = id ? `${id}-option-${optionKey}` : void 0;
|
|
36527
|
+
let displayItem = item;
|
|
36528
|
+
if (autoCap && typeof item.label === "string") {
|
|
36529
|
+
displayItem = {
|
|
36530
|
+
...item,
|
|
36531
|
+
label: capitalizeFirst2(item.label)
|
|
36532
|
+
};
|
|
36533
|
+
}
|
|
36482
36534
|
const checkboxNode = /* @__PURE__ */ jsxRuntime.jsx(
|
|
36483
36535
|
Checkbox2,
|
|
36484
36536
|
{
|
|
@@ -36512,7 +36564,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
36512
36564
|
className: baseOptionClass,
|
|
36513
36565
|
children: [
|
|
36514
36566
|
renderOption({
|
|
36515
|
-
item,
|
|
36567
|
+
item: displayItem,
|
|
36516
36568
|
index: index2,
|
|
36517
36569
|
state: internalState,
|
|
36518
36570
|
effectiveTristate,
|
|
@@ -36543,12 +36595,12 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
36543
36595
|
children: [
|
|
36544
36596
|
checkboxNode,
|
|
36545
36597
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
36546
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClassesBase, children:
|
|
36547
|
-
|
|
36598
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: labelClassesBase, children: displayItem.label }),
|
|
36599
|
+
displayItem.description != null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
36548
36600
|
"span",
|
|
36549
36601
|
{
|
|
36550
36602
|
className: descriptionClassesBase,
|
|
36551
|
-
children:
|
|
36603
|
+
children: displayItem.description
|
|
36552
36604
|
}
|
|
36553
36605
|
)
|
|
36554
36606
|
] })
|
|
@@ -36585,7 +36637,7 @@ var checkboxModule = {
|
|
|
36585
36637
|
tags: ["checkbox", "group", "boolean", "tri-state"]
|
|
36586
36638
|
}
|
|
36587
36639
|
};
|
|
36588
|
-
function
|
|
36640
|
+
function capitalizeFirst3(label) {
|
|
36589
36641
|
if (!label) return label;
|
|
36590
36642
|
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
36591
36643
|
}
|
|
@@ -36597,7 +36649,7 @@ function normalizeOptions(opts, config3) {
|
|
|
36597
36649
|
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);
|
|
36598
36650
|
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);
|
|
36599
36651
|
if (config3.autoCap && typeof labelNode === "string") {
|
|
36600
|
-
labelNode =
|
|
36652
|
+
labelNode = capitalizeFirst3(labelNode);
|
|
36601
36653
|
}
|
|
36602
36654
|
const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
|
|
36603
36655
|
const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;
|
|
@@ -37231,7 +37283,7 @@ function removeSelectValue(current, valueToRemove) {
|
|
|
37231
37283
|
const target = String(valueToRemove);
|
|
37232
37284
|
return current.filter((v) => String(v) !== target);
|
|
37233
37285
|
}
|
|
37234
|
-
function
|
|
37286
|
+
function capitalizeFirst4(label) {
|
|
37235
37287
|
if (!label) return label;
|
|
37236
37288
|
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
37237
37289
|
}
|
|
@@ -37243,7 +37295,7 @@ function normalizeOptions2(opts, config3) {
|
|
|
37243
37295
|
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);
|
|
37244
37296
|
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);
|
|
37245
37297
|
if (config3.autoCap && typeof labelNode === "string") {
|
|
37246
|
-
labelNode =
|
|
37298
|
+
labelNode = capitalizeFirst4(labelNode);
|
|
37247
37299
|
}
|
|
37248
37300
|
const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
|
|
37249
37301
|
const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;
|
|
@@ -40004,7 +40056,7 @@ function Badge({
|
|
|
40004
40056
|
}
|
|
40005
40057
|
);
|
|
40006
40058
|
}
|
|
40007
|
-
function
|
|
40059
|
+
function capitalizeFirst5(label) {
|
|
40008
40060
|
if (!label) return label;
|
|
40009
40061
|
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
40010
40062
|
}
|
|
@@ -40016,7 +40068,7 @@ function normalizeTree(opts, config3, level = 0, parentValue, path = []) {
|
|
|
40016
40068
|
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);
|
|
40017
40069
|
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);
|
|
40018
40070
|
if (config3.autoCap && typeof labelNode === "string") {
|
|
40019
|
-
labelNode =
|
|
40071
|
+
labelNode = capitalizeFirst5(labelNode);
|
|
40020
40072
|
}
|
|
40021
40073
|
const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
|
|
40022
40074
|
const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;
|