@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.cjs
CHANGED
|
@@ -3728,9 +3728,14 @@ function MultiSelectPanel({
|
|
|
3728
3728
|
const [unmatchedTokens, setUnmatchedTokens] = React25.useState([]);
|
|
3729
3729
|
const [pasteError, setPasteError] = React25.useState(null);
|
|
3730
3730
|
const pasteWrapRef = React25.useRef(null);
|
|
3731
|
+
const [resolvedAt, setResolvedAt] = React25.useState(0);
|
|
3731
3732
|
React25.useEffect(() => {
|
|
3732
3733
|
if (mode2 === "paste") pasteWrapRef.current?.querySelector("textarea")?.focus();
|
|
3733
3734
|
}, [mode2]);
|
|
3735
|
+
React25.useLayoutEffect(() => {
|
|
3736
|
+
if (resolvedAt === 0) return;
|
|
3737
|
+
pasteWrapRef.current?.querySelector("textarea")?.focus();
|
|
3738
|
+
}, [resolvedAt]);
|
|
3734
3739
|
const doResolve = () => {
|
|
3735
3740
|
if (!field.resolve) return;
|
|
3736
3741
|
const tokens = Array.from(new Set(pasteText.split(/[\n,]/).map((t) => t.trim()).filter(Boolean)));
|
|
@@ -3753,6 +3758,7 @@ function MultiSelectPanel({
|
|
|
3753
3758
|
return;
|
|
3754
3759
|
}
|
|
3755
3760
|
setPasteText("");
|
|
3761
|
+
setResolvedAt((n) => n + 1);
|
|
3756
3762
|
}, (err) => {
|
|
3757
3763
|
if (!mountedRef.current) return;
|
|
3758
3764
|
setPasteLoading(false);
|
|
@@ -3940,6 +3946,20 @@ function useReseedFromProps(value, applies, reseed) {
|
|
|
3940
3946
|
if (!sameValue(value, applies())) reseed(value);
|
|
3941
3947
|
}, [value, applies, reseed]);
|
|
3942
3948
|
}
|
|
3949
|
+
function usePreserveFocusAcrossRemount(seed) {
|
|
3950
|
+
const pendingId = React25.useRef(null);
|
|
3951
|
+
const capture = (ids) => {
|
|
3952
|
+
const active = document.activeElement;
|
|
3953
|
+
pendingId.current = active instanceof HTMLElement && ids.includes(active.id) ? active.id : null;
|
|
3954
|
+
};
|
|
3955
|
+
React25.useLayoutEffect(() => {
|
|
3956
|
+
const id = pendingId.current;
|
|
3957
|
+
if (!id) return;
|
|
3958
|
+
pendingId.current = null;
|
|
3959
|
+
document.getElementById(id)?.focus();
|
|
3960
|
+
}, [seed]);
|
|
3961
|
+
return capture;
|
|
3962
|
+
}
|
|
3943
3963
|
var rangeDraft = (value) => ({ min: value?.min, max: value?.max });
|
|
3944
3964
|
function RangePanel({
|
|
3945
3965
|
field,
|
|
@@ -3950,6 +3970,9 @@ function RangePanel({
|
|
|
3950
3970
|
}) {
|
|
3951
3971
|
const [draft, setDraft] = React25.useState(() => rangeDraft(value));
|
|
3952
3972
|
const [seed, setSeed] = React25.useState(0);
|
|
3973
|
+
const preserveFocus = usePreserveFocusAcrossRemount(seed);
|
|
3974
|
+
const minId = field.key + "-min";
|
|
3975
|
+
const maxId = field.key + "-max";
|
|
3953
3976
|
const draftRef = React25.useRef(draft);
|
|
3954
3977
|
const shown = () => {
|
|
3955
3978
|
const { min, max } = draftRef.current;
|
|
@@ -3960,6 +3983,7 @@ function RangePanel({
|
|
|
3960
3983
|
};
|
|
3961
3984
|
const validity = useTextValidity(publish);
|
|
3962
3985
|
useReseedFromProps(value, shown, (next) => {
|
|
3986
|
+
preserveFocus([minId, maxId]);
|
|
3963
3987
|
draftRef.current = rangeDraft(next);
|
|
3964
3988
|
setDraft(draftRef.current);
|
|
3965
3989
|
validity.reset();
|
|
@@ -3992,6 +4016,7 @@ function RangePanel({
|
|
|
3992
4016
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
3993
4017
|
NumberInput,
|
|
3994
4018
|
{
|
|
4019
|
+
id: minId,
|
|
3995
4020
|
label: field.minLabel || "At least",
|
|
3996
4021
|
value: draftMin ?? "",
|
|
3997
4022
|
min: field.min,
|
|
@@ -4007,6 +4032,7 @@ function RangePanel({
|
|
|
4007
4032
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4008
4033
|
NumberInput,
|
|
4009
4034
|
{
|
|
4035
|
+
id: maxId,
|
|
4010
4036
|
label: field.maxLabel || "At most",
|
|
4011
4037
|
value: draftMax ?? "",
|
|
4012
4038
|
min: field.min,
|
|
@@ -4046,6 +4072,8 @@ function DatePanel({
|
|
|
4046
4072
|
const daysConfirmed = React25.useRef(value?.kind === "withinDays");
|
|
4047
4073
|
const [between, setBetween] = React25.useState(initial.between);
|
|
4048
4074
|
const [seed, setSeed] = React25.useState(0);
|
|
4075
|
+
const preserveFocus = usePreserveFocusAcrossRemount(seed);
|
|
4076
|
+
const daysId = field.key + "-days";
|
|
4049
4077
|
const shownWithinDays = () => {
|
|
4050
4078
|
const days = daysRef.current;
|
|
4051
4079
|
return applicable(field, days == null ? void 0 : { kind: "withinDays", days }, validity.allValid());
|
|
@@ -4061,6 +4089,7 @@ function DatePanel({
|
|
|
4061
4089
|
return daysConfirmed.current ? shownWithinDays() : void 0;
|
|
4062
4090
|
};
|
|
4063
4091
|
useReseedFromProps(value, applies, (next) => {
|
|
4092
|
+
preserveFocus([daysId]);
|
|
4064
4093
|
const d = dateDraft(field, next);
|
|
4065
4094
|
setKind(d.kind);
|
|
4066
4095
|
daysRef.current = d.days;
|
|
@@ -4130,6 +4159,7 @@ function DatePanel({
|
|
|
4130
4159
|
kind === "withinDays" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4131
4160
|
NumberInput,
|
|
4132
4161
|
{
|
|
4162
|
+
id: daysId,
|
|
4133
4163
|
label: "Days",
|
|
4134
4164
|
min: 1,
|
|
4135
4165
|
max: maxDays,
|