@timeax/form-palette 0.0.34 → 0.0.36
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/extra.d.mts +3 -3
- package/dist/extra.d.ts +3 -3
- package/dist/extra.js +50 -28
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +50 -28
- package/dist/extra.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{variant-DK7UrSwZ.d.mts → variant-BYqslKTy.d.mts} +10 -1
- package/dist/{variant-Dk9A4ceE.d.ts → variant-DLlGPgPJ.d.ts} +10 -1
- package/package.json +1 -1
package/dist/extra.mjs
CHANGED
|
@@ -15406,6 +15406,7 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
15406
15406
|
required,
|
|
15407
15407
|
// radio UI
|
|
15408
15408
|
items,
|
|
15409
|
+
options,
|
|
15409
15410
|
mappers,
|
|
15410
15411
|
optionValue,
|
|
15411
15412
|
optionLabel,
|
|
@@ -15433,13 +15434,13 @@ var InnerShadcnRadioVariant = (props, ref) => {
|
|
|
15433
15434
|
const hasError = !!error;
|
|
15434
15435
|
const normalized = React.useMemo(
|
|
15435
15436
|
() => normalizeItems(
|
|
15436
|
-
items,
|
|
15437
|
+
items != null ? items : options,
|
|
15437
15438
|
mappers,
|
|
15438
15439
|
//@ts-ignore
|
|
15439
15440
|
optionValue,
|
|
15440
15441
|
optionLabel
|
|
15441
15442
|
),
|
|
15442
|
-
[items, mappers, optionValue, optionLabel]
|
|
15443
|
+
[items, options, mappers, optionValue, optionLabel]
|
|
15443
15444
|
);
|
|
15444
15445
|
const selectedString = React.useMemo(() => {
|
|
15445
15446
|
if (value === void 0) return void 0;
|
|
@@ -15768,6 +15769,7 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
15768
15769
|
required,
|
|
15769
15770
|
// UI / behaviour
|
|
15770
15771
|
items,
|
|
15772
|
+
options,
|
|
15771
15773
|
mappers,
|
|
15772
15774
|
optionValue,
|
|
15773
15775
|
optionLabel,
|
|
@@ -15873,12 +15875,12 @@ var InnerShadcnCheckboxVariant = (props, ref) => {
|
|
|
15873
15875
|
const groupValue = asGroupValue(value);
|
|
15874
15876
|
const normalized = React.useMemo(
|
|
15875
15877
|
() => normalizeItems2(
|
|
15876
|
-
items,
|
|
15878
|
+
items != null ? items : options,
|
|
15877
15879
|
mappers,
|
|
15878
15880
|
optionValue,
|
|
15879
15881
|
optionLabel
|
|
15880
15882
|
),
|
|
15881
|
-
[items, mappers, optionValue, optionLabel]
|
|
15883
|
+
[items, options, mappers, optionValue, optionLabel]
|
|
15882
15884
|
);
|
|
15883
15885
|
const {
|
|
15884
15886
|
groupStyle,
|
|
@@ -26411,6 +26413,27 @@ function defaultSearchTarget(search) {
|
|
|
26411
26413
|
function isKey(x2) {
|
|
26412
26414
|
return typeof x2 === "string" || typeof x2 === "number";
|
|
26413
26415
|
}
|
|
26416
|
+
function stringifyForSearch(v2) {
|
|
26417
|
+
if (v2 == null) return "";
|
|
26418
|
+
if (typeof v2 === "string") return v2;
|
|
26419
|
+
if (typeof v2 === "number" || typeof v2 === "boolean" || typeof v2 === "bigint") {
|
|
26420
|
+
return String(v2);
|
|
26421
|
+
}
|
|
26422
|
+
if (v2 instanceof Date) {
|
|
26423
|
+
return Number.isNaN(v2.getTime()) ? "" : v2.toISOString();
|
|
26424
|
+
}
|
|
26425
|
+
if (Array.isArray(v2)) {
|
|
26426
|
+
return v2.map(stringifyForSearch).join(" ");
|
|
26427
|
+
}
|
|
26428
|
+
if (typeof v2 === "object") {
|
|
26429
|
+
try {
|
|
26430
|
+
return JSON.stringify(v2);
|
|
26431
|
+
} catch {
|
|
26432
|
+
return String(v2);
|
|
26433
|
+
}
|
|
26434
|
+
}
|
|
26435
|
+
return String(v2);
|
|
26436
|
+
}
|
|
26414
26437
|
function useData(opts) {
|
|
26415
26438
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
26416
26439
|
const ctx = React.useContext(Ctx);
|
|
@@ -26423,6 +26446,10 @@ function useData(opts) {
|
|
|
26423
26446
|
});
|
|
26424
26447
|
const [loading, setLoading] = React.useState(false);
|
|
26425
26448
|
const [error, setError] = React.useState(void 0);
|
|
26449
|
+
const dataRef = React.useRef(data);
|
|
26450
|
+
React.useEffect(() => {
|
|
26451
|
+
dataRef.current = data;
|
|
26452
|
+
}, [data]);
|
|
26426
26453
|
const [query, _setQuery] = React.useState("");
|
|
26427
26454
|
const [searchMode, _setSearchMode] = React.useState(
|
|
26428
26455
|
(_c = opts.searchMode) != null ? _c : "remote"
|
|
@@ -26460,6 +26487,11 @@ function useData(opts) {
|
|
|
26460
26487
|
const timerRef = React.useRef(null);
|
|
26461
26488
|
const didMountRef = React.useRef(false);
|
|
26462
26489
|
const skipNextModeEffectRef = React.useRef(false);
|
|
26490
|
+
React.useEffect(() => {
|
|
26491
|
+
return () => {
|
|
26492
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
26493
|
+
};
|
|
26494
|
+
}, []);
|
|
26463
26495
|
const inlineDef = React.useMemo(() => {
|
|
26464
26496
|
var _a2;
|
|
26465
26497
|
return makeInlineDef({
|
|
@@ -26505,7 +26537,7 @@ function useData(opts) {
|
|
|
26505
26537
|
const fetchImpl = React.useCallback(
|
|
26506
26538
|
async (override) => {
|
|
26507
26539
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
26508
|
-
if (!enabled) return
|
|
26540
|
+
if (!enabled) return dataRef.current;
|
|
26509
26541
|
const q2 = (_a2 = override == null ? void 0 : override.query) != null ? _a2 : query;
|
|
26510
26542
|
const f2 = (_b2 = override == null ? void 0 : override.filters) != null ? _b2 : filters;
|
|
26511
26543
|
const t4 = (_c2 = override == null ? void 0 : override.searchTarget) != null ? _c2 : searchTarget;
|
|
@@ -26519,6 +26551,7 @@ function useData(opts) {
|
|
|
26519
26551
|
search: payload
|
|
26520
26552
|
});
|
|
26521
26553
|
const list = (_f2 = (_e2 = res == null ? void 0 : res.rawList) != null ? _e2 : res == null ? void 0 : res.raw) != null ? _f2 : [];
|
|
26554
|
+
if (reqIdRef.current !== myReq) return list;
|
|
26522
26555
|
commitSelectedCache(list);
|
|
26523
26556
|
if (selectionMode !== "none" && selectionPrune === "missing") {
|
|
26524
26557
|
const nextIds = /* @__PURE__ */ new Set();
|
|
@@ -26530,29 +26563,27 @@ function useData(opts) {
|
|
|
26530
26563
|
(prev) => prev.filter((x2) => nextIds.has(x2))
|
|
26531
26564
|
);
|
|
26532
26565
|
}
|
|
26533
|
-
if (reqIdRef.current !== myReq) return list;
|
|
26534
26566
|
setData(list);
|
|
26535
26567
|
setLoading(false);
|
|
26536
26568
|
return list;
|
|
26537
26569
|
} catch (e4) {
|
|
26538
|
-
if (reqIdRef.current !== myReq) return
|
|
26570
|
+
if (reqIdRef.current !== myReq) return dataRef.current;
|
|
26539
26571
|
setError(e4);
|
|
26540
26572
|
setLoading(false);
|
|
26541
|
-
return
|
|
26573
|
+
return dataRef.current;
|
|
26542
26574
|
}
|
|
26543
26575
|
},
|
|
26544
26576
|
[
|
|
26545
|
-
commitSelectedCache,
|
|
26546
|
-
ctx,
|
|
26547
|
-
data,
|
|
26548
26577
|
enabled,
|
|
26549
|
-
filters,
|
|
26550
|
-
getItemKey,
|
|
26551
|
-
inlineDef,
|
|
26552
26578
|
query,
|
|
26579
|
+
filters,
|
|
26553
26580
|
searchTarget,
|
|
26581
|
+
ctx,
|
|
26582
|
+
inlineDef,
|
|
26583
|
+
commitSelectedCache,
|
|
26554
26584
|
selectionMode,
|
|
26555
|
-
selectionPrune
|
|
26585
|
+
selectionPrune,
|
|
26586
|
+
getItemKey
|
|
26556
26587
|
]
|
|
26557
26588
|
);
|
|
26558
26589
|
const refresh = React.useCallback(() => {
|
|
@@ -26578,18 +26609,9 @@ function useData(opts) {
|
|
|
26578
26609
|
},
|
|
26579
26610
|
[fetchImpl]
|
|
26580
26611
|
);
|
|
26581
|
-
const setSearchTarget = React.useCallback(
|
|
26582
|
-
(t4)
|
|
26583
|
-
|
|
26584
|
-
if (searchMode === "remote" || searchMode === "hybrid") {
|
|
26585
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
26586
|
-
timerRef.current = setTimeout(() => {
|
|
26587
|
-
void fetchImpl({ searchTarget: t4 });
|
|
26588
|
-
}, debounceMs);
|
|
26589
|
-
}
|
|
26590
|
-
},
|
|
26591
|
-
[debounceMs, fetchImpl, searchMode]
|
|
26592
|
-
);
|
|
26612
|
+
const setSearchTarget = React.useCallback((t4) => {
|
|
26613
|
+
_setSearchTarget(t4);
|
|
26614
|
+
}, []);
|
|
26593
26615
|
const setFilters = React.useCallback(
|
|
26594
26616
|
(next) => _setFilters(next),
|
|
26595
26617
|
[]
|
|
@@ -26657,7 +26679,7 @@ function useData(opts) {
|
|
|
26657
26679
|
);
|
|
26658
26680
|
}
|
|
26659
26681
|
return list.filter(
|
|
26660
|
-
(item) =>
|
|
26682
|
+
(item) => stringifyForSearch(item).toLowerCase().includes(ql)
|
|
26661
26683
|
);
|
|
26662
26684
|
}, [data, getItemKey, query, searchMode, searchTarget]);
|
|
26663
26685
|
const selectedIds = React.useMemo(() => {
|