@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 +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +54 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -35549,6 +35549,7 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
35549
35549
|
() => normalizeItems(
|
|
35550
35550
|
items,
|
|
35551
35551
|
mappers,
|
|
35552
|
+
//@ts-ignore
|
|
35552
35553
|
optionValue,
|
|
35553
35554
|
optionLabel
|
|
35554
35555
|
),
|
|
@@ -35681,6 +35682,10 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
35681
35682
|
size: size4,
|
|
35682
35683
|
density,
|
|
35683
35684
|
optionId,
|
|
35685
|
+
click() {
|
|
35686
|
+
if (optionDisabled) return;
|
|
35687
|
+
handleSelect(displayItem.value);
|
|
35688
|
+
},
|
|
35684
35689
|
radio: radioNode
|
|
35685
35690
|
})
|
|
35686
35691
|
},
|
|
@@ -36572,6 +36577,11 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
36572
36577
|
size: size4,
|
|
36573
36578
|
density,
|
|
36574
36579
|
checkboxId,
|
|
36580
|
+
click() {
|
|
36581
|
+
if (optionDisabled) return;
|
|
36582
|
+
const nextInternal = effectiveTristate ? internalState === "none" ? true : internalState === true ? false : "none" : internalState === true ? false : true;
|
|
36583
|
+
updateGroupValue(item.value, nextInternal, effectiveTristate);
|
|
36584
|
+
},
|
|
36575
36585
|
checkbox: checkboxNode
|
|
36576
36586
|
}),
|
|
36577
36587
|
hiddenInput
|
|
@@ -36637,11 +36647,9 @@ var checkboxModule = {
|
|
|
36637
36647
|
tags: ["checkbox", "group", "boolean", "tri-state"]
|
|
36638
36648
|
}
|
|
36639
36649
|
};
|
|
36640
|
-
|
|
36641
|
-
|
|
36642
|
-
|
|
36643
|
-
}
|
|
36644
|
-
function normalizeOptions(opts, config3) {
|
|
36650
|
+
|
|
36651
|
+
// src/lib/normalise-selects.ts
|
|
36652
|
+
function globalNormalizeOptions(opts, config3) {
|
|
36645
36653
|
if (!opts || !opts.length) return [];
|
|
36646
36654
|
return opts.map((raw, index2) => {
|
|
36647
36655
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
@@ -36668,6 +36676,13 @@ function normalizeOptions(opts, config3) {
|
|
|
36668
36676
|
};
|
|
36669
36677
|
});
|
|
36670
36678
|
}
|
|
36679
|
+
function capitalizeFirst3(label) {
|
|
36680
|
+
if (!label) return label;
|
|
36681
|
+
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
36682
|
+
}
|
|
36683
|
+
function normalizeOptions(opts, config3) {
|
|
36684
|
+
return globalNormalizeOptions(opts, config3);
|
|
36685
|
+
}
|
|
36671
36686
|
function triggerHeight(size4) {
|
|
36672
36687
|
switch (size4) {
|
|
36673
36688
|
case "sm":
|
|
@@ -36993,7 +37008,13 @@ var ShadcnSelectVariant = React54.forwardRef(function ShadcnSelectVariant2(props
|
|
|
36993
37008
|
item,
|
|
36994
37009
|
selected: selectedItem != null && String(selectedItem.value) === String(item.value),
|
|
36995
37010
|
index: index2,
|
|
36996
|
-
option: optionNode
|
|
37011
|
+
option: optionNode,
|
|
37012
|
+
click() {
|
|
37013
|
+
if (disabled || readOnly || item.disabled) return;
|
|
37014
|
+
handleChange(String(item.value));
|
|
37015
|
+
setOpen(false);
|
|
37016
|
+
setQuery("");
|
|
37017
|
+
}
|
|
36997
37018
|
});
|
|
36998
37019
|
}),
|
|
36999
37020
|
virtualScroll && renderedItems.length < filteredItems.length && /* @__PURE__ */ jsx("div", { className: "px-2 py-1 text-[10px] text-muted-foreground text-center", children: "Scroll to load more\u2026" })
|
|
@@ -37283,36 +37304,8 @@ function removeSelectValue(current, valueToRemove) {
|
|
|
37283
37304
|
const target = String(valueToRemove);
|
|
37284
37305
|
return current.filter((v) => String(v) !== target);
|
|
37285
37306
|
}
|
|
37286
|
-
function capitalizeFirst4(label) {
|
|
37287
|
-
if (!label) return label;
|
|
37288
|
-
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
37289
|
-
}
|
|
37290
37307
|
function normalizeOptions2(opts, config3) {
|
|
37291
|
-
|
|
37292
|
-
return opts.map((raw, index2) => {
|
|
37293
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
37294
|
-
const asObj = typeof raw === "string" || typeof raw === "number" ? { label: String(raw), value: raw } : raw;
|
|
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);
|
|
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);
|
|
37297
|
-
if (config3.autoCap && typeof labelNode === "string") {
|
|
37298
|
-
labelNode = capitalizeFirst4(labelNode);
|
|
37299
|
-
}
|
|
37300
|
-
const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
|
|
37301
|
-
const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;
|
|
37302
|
-
const disabled = typeof config3.optionDisabled === "function" ? config3.optionDisabled(raw) : typeof config3.optionDisabled === "string" ? !!asObj[config3.optionDisabled] : !!asObj.disabled;
|
|
37303
|
-
const icon = typeof config3.optionIcon === "function" ? config3.optionIcon(raw) : typeof config3.optionIcon === "string" ? asObj[config3.optionIcon] : asObj.icon;
|
|
37304
|
-
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;
|
|
37305
|
-
return {
|
|
37306
|
-
key: String(key),
|
|
37307
|
-
value,
|
|
37308
|
-
labelNode,
|
|
37309
|
-
labelText,
|
|
37310
|
-
description,
|
|
37311
|
-
disabled,
|
|
37312
|
-
icon,
|
|
37313
|
-
raw
|
|
37314
|
-
};
|
|
37315
|
-
});
|
|
37308
|
+
return globalNormalizeOptions(opts, config3);
|
|
37316
37309
|
}
|
|
37317
37310
|
function triggerHeight2(size4) {
|
|
37318
37311
|
switch (size4) {
|
|
@@ -37416,9 +37409,7 @@ var ShadcnMultiSelectVariant = React54.forwardRef(function ShadcnMultiSelectVari
|
|
|
37416
37409
|
const filteredItems = React54.useMemo(() => {
|
|
37417
37410
|
if (!query) return items;
|
|
37418
37411
|
const q = query.toLowerCase();
|
|
37419
|
-
return items.filter(
|
|
37420
|
-
(it) => it.labelText.toLowerCase().includes(q)
|
|
37421
|
-
);
|
|
37412
|
+
return items.filter((it) => it.labelText.toLowerCase().includes(q));
|
|
37422
37413
|
}, [items, query]);
|
|
37423
37414
|
const selectableItems = React54.useMemo(
|
|
37424
37415
|
() => items.filter((it) => !it.disabled),
|
|
@@ -37571,7 +37562,7 @@ var ShadcnMultiSelectVariant = React54.forwardRef(function ShadcnMultiSelectVari
|
|
|
37571
37562
|
type: "button",
|
|
37572
37563
|
disabled: disabledTrigger,
|
|
37573
37564
|
className: cn(
|
|
37574
|
-
"flex w-full items-center justify-between rounded-md border border-input bg-
|
|
37565
|
+
"flex w-full items-center justify-between rounded-md border border-input bg-surfaces-input px-3 text-left shadow-xs",
|
|
37575
37566
|
"focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:border-ring",
|
|
37576
37567
|
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
37577
37568
|
heightCls,
|
|
@@ -37696,9 +37687,7 @@ var ShadcnMultiSelectVariant = React54.forwardRef(function ShadcnMultiSelectVari
|
|
|
37696
37687
|
}
|
|
37697
37688
|
),
|
|
37698
37689
|
filteredItems.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: emptySearchText != null ? emptySearchText : "No results found" }) : filteredItems.map((item, index2) => {
|
|
37699
|
-
const selected = selectedValues.has(
|
|
37700
|
-
item.value
|
|
37701
|
-
);
|
|
37690
|
+
const selected = selectedValues.has(item.value);
|
|
37702
37691
|
const row = /* @__PURE__ */ jsxs(
|
|
37703
37692
|
"button",
|
|
37704
37693
|
{
|
|
@@ -37735,7 +37724,11 @@ var ShadcnMultiSelectVariant = React54.forwardRef(function ShadcnMultiSelectVari
|
|
|
37735
37724
|
item,
|
|
37736
37725
|
selected,
|
|
37737
37726
|
index: index2,
|
|
37738
|
-
option: row
|
|
37727
|
+
option: row,
|
|
37728
|
+
click() {
|
|
37729
|
+
if (item.disabled) return;
|
|
37730
|
+
handleToggleValue(item.value);
|
|
37731
|
+
}
|
|
37739
37732
|
});
|
|
37740
37733
|
}),
|
|
37741
37734
|
showSelectAll && selectAllPosition === "bottom" && /* @__PURE__ */ jsxs(
|
|
@@ -37825,9 +37818,7 @@ var ShadcnMultiSelectVariant = React54.forwardRef(function ShadcnMultiSelectVari
|
|
|
37825
37818
|
/* @__PURE__ */ jsx(
|
|
37826
37819
|
"div",
|
|
37827
37820
|
{
|
|
37828
|
-
className: cn(
|
|
37829
|
-
"flex-1 min-w-0 flex items-stretch"
|
|
37830
|
-
),
|
|
37821
|
+
className: cn("flex-1 min-w-0 flex items-stretch"),
|
|
37831
37822
|
"data-slot": "select-region",
|
|
37832
37823
|
children: MultiSelectCore
|
|
37833
37824
|
}
|
|
@@ -40056,7 +40047,7 @@ function Badge({
|
|
|
40056
40047
|
}
|
|
40057
40048
|
);
|
|
40058
40049
|
}
|
|
40059
|
-
function
|
|
40050
|
+
function capitalizeFirst4(label) {
|
|
40060
40051
|
if (!label) return label;
|
|
40061
40052
|
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
40062
40053
|
}
|
|
@@ -40068,7 +40059,7 @@ function normalizeTree(opts, config3, level = 0, parentValue, path = []) {
|
|
|
40068
40059
|
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);
|
|
40069
40060
|
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);
|
|
40070
40061
|
if (config3.autoCap && typeof labelNode === "string") {
|
|
40071
|
-
labelNode =
|
|
40062
|
+
labelNode = capitalizeFirst4(labelNode);
|
|
40072
40063
|
}
|
|
40073
40064
|
const labelText = typeof labelNode === "string" ? labelNode : typeof labelNode === "number" ? String(labelNode) : (_g = asObj.labelText) != null ? _g : String(value);
|
|
40074
40065
|
const description = typeof config3.optionDescription === "function" ? config3.optionDescription(raw) : typeof config3.optionDescription === "string" ? asObj[config3.optionDescription] : asObj.description;
|
|
@@ -40378,7 +40369,7 @@ var ShadcnTreeSelectVariant = React54.forwardRef(function ShadcnTreeSelectVarian
|
|
|
40378
40369
|
displayedNodes.map((item, index2) => {
|
|
40379
40370
|
const selected = selectedValues.includes(item.value);
|
|
40380
40371
|
const isExpanded = expanded.has(item.value);
|
|
40381
|
-
|
|
40372
|
+
const optionNode = /* @__PURE__ */ jsxs(
|
|
40382
40373
|
"div",
|
|
40383
40374
|
{
|
|
40384
40375
|
className: cn(
|
|
@@ -40436,6 +40427,16 @@ var ShadcnTreeSelectVariant = React54.forwardRef(function ShadcnTreeSelectVarian
|
|
|
40436
40427
|
},
|
|
40437
40428
|
item.key
|
|
40438
40429
|
);
|
|
40430
|
+
if (!renderOption) return optionNode;
|
|
40431
|
+
return renderOption({
|
|
40432
|
+
item,
|
|
40433
|
+
selected,
|
|
40434
|
+
index: index2,
|
|
40435
|
+
option: optionNode,
|
|
40436
|
+
click() {
|
|
40437
|
+
if (!item.disabled) handleToggleValue(item);
|
|
40438
|
+
}
|
|
40439
|
+
});
|
|
40439
40440
|
})
|
|
40440
40441
|
] });
|
|
40441
40442
|
const SelectBody = /* @__PURE__ */ jsxs(
|
|
@@ -43112,7 +43113,7 @@ function normalizeValue(val, multiple) {
|
|
|
43112
43113
|
if (Array.isArray(val)) return val[0] || "";
|
|
43113
43114
|
return val || "";
|
|
43114
43115
|
}
|
|
43115
|
-
function
|
|
43116
|
+
function capitalizeFirst5(label) {
|
|
43116
43117
|
if (!label) return label;
|
|
43117
43118
|
return label.charAt(0).toUpperCase() + label.slice(1);
|
|
43118
43119
|
}
|
|
@@ -43138,7 +43139,7 @@ function normalizeOption(input, {
|
|
|
43138
43139
|
label2 = String(rawValue != null ? rawValue : value2);
|
|
43139
43140
|
}
|
|
43140
43141
|
if (autoCap && typeof label2 === "string") {
|
|
43141
|
-
label2 =
|
|
43142
|
+
label2 = capitalizeFirst5(label2);
|
|
43142
43143
|
}
|
|
43143
43144
|
const icon = optionIcon != null ? anyInput[optionIcon] : (_b = anyInput.icon) != null ? _b : void 0;
|
|
43144
43145
|
const disabled = optionDisabled != null ? !!anyInput[optionDisabled] : !!anyInput.disabled;
|
|
@@ -43160,7 +43161,7 @@ function normalizeOption(input, {
|
|
|
43160
43161
|
const value2 = String(input);
|
|
43161
43162
|
let label2 = value2;
|
|
43162
43163
|
if (autoCap && typeof label2 === "string") {
|
|
43163
|
-
label2 =
|
|
43164
|
+
label2 = capitalizeFirst5(label2);
|
|
43164
43165
|
}
|
|
43165
43166
|
return {
|
|
43166
43167
|
ui: {
|
|
@@ -43174,7 +43175,7 @@ function normalizeOption(input, {
|
|
|
43174
43175
|
const value = String(baseValue);
|
|
43175
43176
|
let label = anyInput.label != null ? anyInput.label : String(value);
|
|
43176
43177
|
if (autoCap && typeof label === "string") {
|
|
43177
|
-
label =
|
|
43178
|
+
label = capitalizeFirst5(label);
|
|
43178
43179
|
}
|
|
43179
43180
|
return {
|
|
43180
43181
|
ui: {
|