@flytedan/flytebot-design-system 0.34.0 → 0.35.0
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.cjs +30 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3488,9 +3488,14 @@ function MultiSelectPanel({
|
|
|
3488
3488
|
const [unmatchedTokens, setUnmatchedTokens] = React25.useState([]);
|
|
3489
3489
|
const [pasteError, setPasteError] = React25.useState(null);
|
|
3490
3490
|
const pasteWrapRef = React25.useRef(null);
|
|
3491
|
+
const [resolvedAt, setResolvedAt] = React25.useState(0);
|
|
3491
3492
|
React25.useEffect(() => {
|
|
3492
3493
|
if (mode2 === "paste") pasteWrapRef.current?.querySelector("textarea")?.focus();
|
|
3493
3494
|
}, [mode2]);
|
|
3495
|
+
React25.useLayoutEffect(() => {
|
|
3496
|
+
if (resolvedAt === 0) return;
|
|
3497
|
+
pasteWrapRef.current?.querySelector("textarea")?.focus();
|
|
3498
|
+
}, [resolvedAt]);
|
|
3494
3499
|
const doResolve = () => {
|
|
3495
3500
|
if (!field.resolve) return;
|
|
3496
3501
|
const tokens = Array.from(new Set(pasteText.split(/[\n,]/).map((t) => t.trim()).filter(Boolean)));
|
|
@@ -3513,6 +3518,7 @@ function MultiSelectPanel({
|
|
|
3513
3518
|
return;
|
|
3514
3519
|
}
|
|
3515
3520
|
setPasteText("");
|
|
3521
|
+
setResolvedAt((n) => n + 1);
|
|
3516
3522
|
}, (err) => {
|
|
3517
3523
|
if (!mountedRef.current) return;
|
|
3518
3524
|
setPasteLoading(false);
|
|
@@ -3700,6 +3706,20 @@ function useReseedFromProps(value, applies, reseed) {
|
|
|
3700
3706
|
if (!sameValue(value, applies())) reseed(value);
|
|
3701
3707
|
}, [value, applies, reseed]);
|
|
3702
3708
|
}
|
|
3709
|
+
function usePreserveFocusAcrossRemount(seed) {
|
|
3710
|
+
const pendingId = React25.useRef(null);
|
|
3711
|
+
const capture = (ids) => {
|
|
3712
|
+
const active = document.activeElement;
|
|
3713
|
+
pendingId.current = active instanceof HTMLElement && ids.includes(active.id) ? active.id : null;
|
|
3714
|
+
};
|
|
3715
|
+
React25.useLayoutEffect(() => {
|
|
3716
|
+
const id = pendingId.current;
|
|
3717
|
+
if (!id) return;
|
|
3718
|
+
pendingId.current = null;
|
|
3719
|
+
document.getElementById(id)?.focus();
|
|
3720
|
+
}, [seed]);
|
|
3721
|
+
return capture;
|
|
3722
|
+
}
|
|
3703
3723
|
var rangeDraft = (value) => ({ min: value?.min, max: value?.max });
|
|
3704
3724
|
function RangePanel({
|
|
3705
3725
|
field,
|
|
@@ -3710,6 +3730,9 @@ function RangePanel({
|
|
|
3710
3730
|
}) {
|
|
3711
3731
|
const [draft, setDraft] = React25.useState(() => rangeDraft(value));
|
|
3712
3732
|
const [seed, setSeed] = React25.useState(0);
|
|
3733
|
+
const preserveFocus = usePreserveFocusAcrossRemount(seed);
|
|
3734
|
+
const minId = field.key + "-min";
|
|
3735
|
+
const maxId = field.key + "-max";
|
|
3713
3736
|
const draftRef = React25.useRef(draft);
|
|
3714
3737
|
const shown = () => {
|
|
3715
3738
|
const { min, max } = draftRef.current;
|
|
@@ -3720,6 +3743,7 @@ function RangePanel({
|
|
|
3720
3743
|
};
|
|
3721
3744
|
const validity = useTextValidity(publish);
|
|
3722
3745
|
useReseedFromProps(value, shown, (next) => {
|
|
3746
|
+
preserveFocus([minId, maxId]);
|
|
3723
3747
|
draftRef.current = rangeDraft(next);
|
|
3724
3748
|
setDraft(draftRef.current);
|
|
3725
3749
|
validity.reset();
|
|
@@ -3752,6 +3776,7 @@ function RangePanel({
|
|
|
3752
3776
|
/* @__PURE__ */ jsx45(
|
|
3753
3777
|
NumberInput,
|
|
3754
3778
|
{
|
|
3779
|
+
id: minId,
|
|
3755
3780
|
label: field.minLabel || "At least",
|
|
3756
3781
|
value: draftMin ?? "",
|
|
3757
3782
|
min: field.min,
|
|
@@ -3767,6 +3792,7 @@ function RangePanel({
|
|
|
3767
3792
|
/* @__PURE__ */ jsx45(
|
|
3768
3793
|
NumberInput,
|
|
3769
3794
|
{
|
|
3795
|
+
id: maxId,
|
|
3770
3796
|
label: field.maxLabel || "At most",
|
|
3771
3797
|
value: draftMax ?? "",
|
|
3772
3798
|
min: field.min,
|
|
@@ -3806,6 +3832,8 @@ function DatePanel({
|
|
|
3806
3832
|
const daysConfirmed = React25.useRef(value?.kind === "withinDays");
|
|
3807
3833
|
const [between, setBetween] = React25.useState(initial.between);
|
|
3808
3834
|
const [seed, setSeed] = React25.useState(0);
|
|
3835
|
+
const preserveFocus = usePreserveFocusAcrossRemount(seed);
|
|
3836
|
+
const daysId = field.key + "-days";
|
|
3809
3837
|
const shownWithinDays = () => {
|
|
3810
3838
|
const days = daysRef.current;
|
|
3811
3839
|
return applicable(field, days == null ? void 0 : { kind: "withinDays", days }, validity.allValid());
|
|
@@ -3821,6 +3849,7 @@ function DatePanel({
|
|
|
3821
3849
|
return daysConfirmed.current ? shownWithinDays() : void 0;
|
|
3822
3850
|
};
|
|
3823
3851
|
useReseedFromProps(value, applies, (next) => {
|
|
3852
|
+
preserveFocus([daysId]);
|
|
3824
3853
|
const d = dateDraft(field, next);
|
|
3825
3854
|
setKind(d.kind);
|
|
3826
3855
|
daysRef.current = d.days;
|
|
@@ -3890,6 +3919,7 @@ function DatePanel({
|
|
|
3890
3919
|
kind === "withinDays" ? /* @__PURE__ */ jsx45(
|
|
3891
3920
|
NumberInput,
|
|
3892
3921
|
{
|
|
3922
|
+
id: daysId,
|
|
3893
3923
|
label: "Days",
|
|
3894
3924
|
min: 1,
|
|
3895
3925
|
max: maxDays,
|