@uniformdev/design-system 20.39.3-alpha.1 → 20.40.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/esm/index.js +114 -29
- package/dist/index.js +107 -28
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -9480,7 +9480,13 @@ import {
|
|
|
9480
9480
|
verticalListSortingStrategy
|
|
9481
9481
|
} from "@dnd-kit/sortable";
|
|
9482
9482
|
import { CSS } from "@dnd-kit/utilities";
|
|
9483
|
-
import {
|
|
9483
|
+
import {
|
|
9484
|
+
useCallback as useCallback7,
|
|
9485
|
+
useEffect as useEffect11,
|
|
9486
|
+
useMemo as useMemo5,
|
|
9487
|
+
useRef as useRef6,
|
|
9488
|
+
useState as useState11
|
|
9489
|
+
} from "react";
|
|
9484
9490
|
|
|
9485
9491
|
// src/utils/useDebouncedCallback.ts
|
|
9486
9492
|
import { useEffect as useEffect10, useMemo as useMemo4, useRef as useRef5 } from "react";
|
|
@@ -9571,8 +9577,12 @@ var KeyValueInput = ({
|
|
|
9571
9577
|
renderIconSelector
|
|
9572
9578
|
}) => {
|
|
9573
9579
|
const [isDragging, setIsDragging] = useState11(false);
|
|
9580
|
+
const [indexToFocus, setIndexToFocus] = useState11(null);
|
|
9574
9581
|
const popoverStoresMap = useRef6({});
|
|
9575
|
-
const
|
|
9582
|
+
const keyInputRefsMap = useRef6({});
|
|
9583
|
+
const [blockAutoGenerateForValues, setBlockAutoGenerateForValues] = useState11(
|
|
9584
|
+
() => new Set(value.map((item) => item.value))
|
|
9585
|
+
);
|
|
9576
9586
|
const sensors = useSensors(
|
|
9577
9587
|
useSensor(PointerSensor),
|
|
9578
9588
|
useSensor(KeyboardSensor, {
|
|
@@ -9582,13 +9592,28 @@ var KeyValueInput = ({
|
|
|
9582
9592
|
const valueWithIds = useMemo5(() => {
|
|
9583
9593
|
return value.map((item, index) => ({ ...item, id: generateItemId(item, index) }));
|
|
9584
9594
|
}, [value]);
|
|
9585
|
-
const handleAddOptionRow = useCallback7(
|
|
9586
|
-
|
|
9587
|
-
|
|
9595
|
+
const handleAddOptionRow = useCallback7(
|
|
9596
|
+
(insertIndex) => {
|
|
9597
|
+
const newValue = [...value];
|
|
9598
|
+
newValue.splice(insertIndex + 1, 0, newItemDefault);
|
|
9599
|
+
setIndexToFocus(insertIndex + 1);
|
|
9600
|
+
onChange(newValue);
|
|
9601
|
+
},
|
|
9602
|
+
[onChange, value, newItemDefault]
|
|
9603
|
+
);
|
|
9588
9604
|
const handleDeleteOptionRow = useCallback7(
|
|
9589
9605
|
(deleteIndex) => {
|
|
9590
9606
|
const updatedOptions = value.filter((_, index) => index !== deleteIndex);
|
|
9591
9607
|
onChange(updatedOptions);
|
|
9608
|
+
setBlockAutoGenerateForValues((current) => {
|
|
9609
|
+
const newSet = new Set(current);
|
|
9610
|
+
newSet.delete(value[deleteIndex].value);
|
|
9611
|
+
return newSet;
|
|
9612
|
+
});
|
|
9613
|
+
if (updatedOptions.length > 0) {
|
|
9614
|
+
const focusIndex = deleteIndex >= updatedOptions.length ? updatedOptions.length - 1 : deleteIndex;
|
|
9615
|
+
setIndexToFocus(focusIndex);
|
|
9616
|
+
}
|
|
9592
9617
|
},
|
|
9593
9618
|
[value, onChange]
|
|
9594
9619
|
);
|
|
@@ -9612,6 +9637,34 @@ var KeyValueInput = ({
|
|
|
9612
9637
|
},
|
|
9613
9638
|
[onChange, value]
|
|
9614
9639
|
);
|
|
9640
|
+
const handleKeyPaste = useCallback7(
|
|
9641
|
+
(rowIndex, e) => {
|
|
9642
|
+
const pastedText = e.clipboardData.getData("text");
|
|
9643
|
+
const lines = pastedText.split("\n").filter((line) => line.trim() !== "");
|
|
9644
|
+
if (lines.length <= 1) {
|
|
9645
|
+
return;
|
|
9646
|
+
}
|
|
9647
|
+
e.preventDefault();
|
|
9648
|
+
const newItems = [];
|
|
9649
|
+
lines.forEach((line) => {
|
|
9650
|
+
const linePieces = line.split(",");
|
|
9651
|
+
const hasMultipleCommas = linePieces.length > 2;
|
|
9652
|
+
if (linePieces.length > 1 && !hasMultipleCommas) {
|
|
9653
|
+
const key = linePieces[0].trim();
|
|
9654
|
+
const val = linePieces[1].trim();
|
|
9655
|
+
newItems.push({ key, value: val });
|
|
9656
|
+
} else {
|
|
9657
|
+
const trimmedLine = line.trim();
|
|
9658
|
+
newItems.push({ key: trimmedLine, value: trimmedLine });
|
|
9659
|
+
}
|
|
9660
|
+
});
|
|
9661
|
+
const newValue = [...value];
|
|
9662
|
+
newValue.splice(rowIndex, 1, ...newItems);
|
|
9663
|
+
onChange(newValue);
|
|
9664
|
+
setIndexToFocus(rowIndex + newItems.length - 1);
|
|
9665
|
+
},
|
|
9666
|
+
[onChange, value]
|
|
9667
|
+
);
|
|
9615
9668
|
const handleDragEnd = useCallback7(
|
|
9616
9669
|
(e) => {
|
|
9617
9670
|
setIsDragging(false);
|
|
@@ -9635,10 +9688,17 @@ var KeyValueInput = ({
|
|
|
9635
9688
|
setIsDragging(false);
|
|
9636
9689
|
}, [setIsDragging]);
|
|
9637
9690
|
useEffect11(() => {
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9691
|
+
const timeoutId = setTimeout(() => {
|
|
9692
|
+
var _a;
|
|
9693
|
+
if (indexToFocus !== null && keyInputRefsMap.current[indexToFocus]) {
|
|
9694
|
+
(_a = keyInputRefsMap.current[indexToFocus]) == null ? void 0 : _a.focus();
|
|
9695
|
+
setIndexToFocus(null);
|
|
9696
|
+
}
|
|
9697
|
+
});
|
|
9698
|
+
return () => {
|
|
9699
|
+
clearTimeout(timeoutId);
|
|
9700
|
+
};
|
|
9701
|
+
}, [indexToFocus]);
|
|
9642
9702
|
return /* @__PURE__ */ jsxs59(VerticalRhythm, { gap: "xs", children: [
|
|
9643
9703
|
/* @__PURE__ */ jsx91(HorizontalRhythm, { align: "center", justify: "space-between", css: { marginBottom: "var(--spacing-xs)" }, children: /* @__PURE__ */ jsx91("span", { css: LabelStyles, children: label2 }) }),
|
|
9644
9704
|
/* @__PURE__ */ jsxs59(
|
|
@@ -9676,18 +9736,24 @@ var KeyValueInput = ({
|
|
|
9676
9736
|
}
|
|
9677
9737
|
)
|
|
9678
9738
|
] }),
|
|
9679
|
-
/* @__PURE__ */ jsxs59(HorizontalRhythm, { align: "center",
|
|
9680
|
-
/* @__PURE__ */
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9739
|
+
/* @__PURE__ */ jsxs59(HorizontalRhythm, { align: "center", justify: "space-between", children: [
|
|
9740
|
+
/* @__PURE__ */ jsxs59(HorizontalRhythm, { align: "center", gap: "xs", children: [
|
|
9741
|
+
/* @__PURE__ */ jsx91("span", { children: valueLabel }),
|
|
9742
|
+
!valueInfoPopover ? null : /* @__PURE__ */ jsx91(
|
|
9743
|
+
Popover3,
|
|
9744
|
+
{
|
|
9745
|
+
buttonText: `${valueLabel} info`,
|
|
9746
|
+
iconColor: "gray",
|
|
9747
|
+
placement: "bottom-start",
|
|
9748
|
+
onInit: ({ store }) => popoverStoresMap.current.value = store,
|
|
9749
|
+
children: valueInfoPopover
|
|
9750
|
+
}
|
|
9751
|
+
)
|
|
9752
|
+
] }),
|
|
9753
|
+
/* @__PURE__ */ jsxs59(Caption, { css: { fontSize: "var(--fs-xs)" }, children: [
|
|
9754
|
+
getFormattedShortcut("enter"),
|
|
9755
|
+
" to insert row"
|
|
9756
|
+
] })
|
|
9691
9757
|
] })
|
|
9692
9758
|
]
|
|
9693
9759
|
}
|
|
@@ -9705,7 +9771,7 @@ var KeyValueInput = ({
|
|
|
9705
9771
|
KeyValueInputItem,
|
|
9706
9772
|
{
|
|
9707
9773
|
id,
|
|
9708
|
-
firstInputRef:
|
|
9774
|
+
firstInputRef: (ref) => keyInputRefsMap.current[index] = ref,
|
|
9709
9775
|
value: item,
|
|
9710
9776
|
keyLabel: `${keyLabel}, row ${index}`,
|
|
9711
9777
|
valueLabel: `${valueLabel}, row ${index}`,
|
|
@@ -9718,9 +9784,16 @@ var KeyValueInput = ({
|
|
|
9718
9784
|
onDelete: () => handleDeleteOptionRow(index),
|
|
9719
9785
|
onFocusChange: handleFocusChange,
|
|
9720
9786
|
"data-testid": "key-value-input-item",
|
|
9721
|
-
onEnter: handleAddOptionRow,
|
|
9787
|
+
onEnter: () => handleAddOptionRow(index),
|
|
9788
|
+
onKeyPaste: (e) => handleKeyPaste(index, e),
|
|
9722
9789
|
showIconColumn,
|
|
9723
|
-
renderIconSelector
|
|
9790
|
+
renderIconSelector,
|
|
9791
|
+
blockAutoGenerateValue: item.value !== "" && blockAutoGenerateForValues.has(item.value),
|
|
9792
|
+
onBlurValue: (value2) => setBlockAutoGenerateForValues((current) => {
|
|
9793
|
+
const newSet = new Set(current);
|
|
9794
|
+
newSet.add(value2);
|
|
9795
|
+
return newSet;
|
|
9796
|
+
})
|
|
9724
9797
|
},
|
|
9725
9798
|
isDragging ? id : index
|
|
9726
9799
|
)) })
|
|
@@ -9729,7 +9802,7 @@ var KeyValueInput = ({
|
|
|
9729
9802
|
/* @__PURE__ */ jsx91(
|
|
9730
9803
|
AddListButton,
|
|
9731
9804
|
{
|
|
9732
|
-
onButtonClick: handleAddOptionRow,
|
|
9805
|
+
onButtonClick: () => handleAddOptionRow(value.length - 1),
|
|
9733
9806
|
disabled: disabled2,
|
|
9734
9807
|
"data-testid": "add-input-row-action",
|
|
9735
9808
|
css: { marginTop: "var(--spacing-sm)", marginLeft: "var(--spacing-base)" }
|
|
@@ -9752,8 +9825,11 @@ var KeyValueInputItem = ({
|
|
|
9752
9825
|
disabledDelete = false,
|
|
9753
9826
|
disabledDnd = false,
|
|
9754
9827
|
onEnter,
|
|
9828
|
+
onKeyPaste,
|
|
9755
9829
|
showIconColumn = false,
|
|
9756
|
-
renderIconSelector
|
|
9830
|
+
renderIconSelector,
|
|
9831
|
+
blockAutoGenerateValue,
|
|
9832
|
+
onBlurValue
|
|
9757
9833
|
}) => {
|
|
9758
9834
|
const { attributes, listeners, setNodeRef, transform, transition, setActivatorNodeRef, isSorting } = useSortable({
|
|
9759
9835
|
id,
|
|
@@ -9768,6 +9844,11 @@ var KeyValueInputItem = ({
|
|
|
9768
9844
|
onEnter();
|
|
9769
9845
|
}
|
|
9770
9846
|
};
|
|
9847
|
+
const handleValueKeyDown = (e) => {
|
|
9848
|
+
if (e.key === "Enter") {
|
|
9849
|
+
onEnter();
|
|
9850
|
+
}
|
|
9851
|
+
};
|
|
9771
9852
|
return /* @__PURE__ */ jsxs59("div", { css: rowWrapper, ref: setNodeRef, style, children: [
|
|
9772
9853
|
/* @__PURE__ */ jsx91(DragHandle, { disableDnd: disabledDnd, ref: setActivatorNodeRef, ...attributes, ...listeners }),
|
|
9773
9854
|
/* @__PURE__ */ jsxs59(
|
|
@@ -9811,7 +9892,7 @@ var KeyValueInputItem = ({
|
|
|
9811
9892
|
showLabel: false,
|
|
9812
9893
|
disabled: disabled2,
|
|
9813
9894
|
onChange: (e) => {
|
|
9814
|
-
const hasStoredValue = value.value !== value.key;
|
|
9895
|
+
const hasStoredValue = value.value !== value.key || blockAutoGenerateValue;
|
|
9815
9896
|
onChange == null ? void 0 : onChange({
|
|
9816
9897
|
key: e.currentTarget.value,
|
|
9817
9898
|
value: hasStoredValue ? value.value : e.currentTarget.value,
|
|
@@ -9821,6 +9902,7 @@ var KeyValueInputItem = ({
|
|
|
9821
9902
|
onBlur: () => onFocusChange == null ? void 0 : onFocusChange(false),
|
|
9822
9903
|
onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
|
|
9823
9904
|
onKeyDown: handleEnter,
|
|
9905
|
+
onPaste: onKeyPaste,
|
|
9824
9906
|
value: value.key,
|
|
9825
9907
|
errorMessage: isSorting ? void 0 : error == null ? void 0 : error.key,
|
|
9826
9908
|
"data-testid": "key"
|
|
@@ -9839,9 +9921,12 @@ var KeyValueInputItem = ({
|
|
|
9839
9921
|
icon: value.icon
|
|
9840
9922
|
});
|
|
9841
9923
|
},
|
|
9842
|
-
onBlur: () =>
|
|
9924
|
+
onBlur: () => {
|
|
9925
|
+
onFocusChange == null ? void 0 : onFocusChange(false);
|
|
9926
|
+
onBlurValue == null ? void 0 : onBlurValue(value.value);
|
|
9927
|
+
},
|
|
9843
9928
|
onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
|
|
9844
|
-
onKeyDown:
|
|
9929
|
+
onKeyDown: handleValueKeyDown,
|
|
9845
9930
|
value: value.value,
|
|
9846
9931
|
errorMessage: isSorting ? void 0 : error == null ? void 0 : error.value,
|
|
9847
9932
|
"data-testid": "value"
|
package/dist/index.js
CHANGED
|
@@ -11428,8 +11428,12 @@ var KeyValueInput = ({
|
|
|
11428
11428
|
renderIconSelector
|
|
11429
11429
|
}) => {
|
|
11430
11430
|
const [isDragging, setIsDragging] = (0, import_react106.useState)(false);
|
|
11431
|
+
const [indexToFocus, setIndexToFocus] = (0, import_react106.useState)(null);
|
|
11431
11432
|
const popoverStoresMap = (0, import_react106.useRef)({});
|
|
11432
|
-
const
|
|
11433
|
+
const keyInputRefsMap = (0, import_react106.useRef)({});
|
|
11434
|
+
const [blockAutoGenerateForValues, setBlockAutoGenerateForValues] = (0, import_react106.useState)(
|
|
11435
|
+
() => new Set(value.map((item) => item.value))
|
|
11436
|
+
);
|
|
11433
11437
|
const sensors = (0, import_core.useSensors)(
|
|
11434
11438
|
(0, import_core.useSensor)(import_core.PointerSensor),
|
|
11435
11439
|
(0, import_core.useSensor)(import_core.KeyboardSensor, {
|
|
@@ -11439,13 +11443,28 @@ var KeyValueInput = ({
|
|
|
11439
11443
|
const valueWithIds = (0, import_react106.useMemo)(() => {
|
|
11440
11444
|
return value.map((item, index) => ({ ...item, id: generateItemId(item, index) }));
|
|
11441
11445
|
}, [value]);
|
|
11442
|
-
const handleAddOptionRow = (0, import_react106.useCallback)(
|
|
11443
|
-
|
|
11444
|
-
|
|
11446
|
+
const handleAddOptionRow = (0, import_react106.useCallback)(
|
|
11447
|
+
(insertIndex) => {
|
|
11448
|
+
const newValue = [...value];
|
|
11449
|
+
newValue.splice(insertIndex + 1, 0, newItemDefault);
|
|
11450
|
+
setIndexToFocus(insertIndex + 1);
|
|
11451
|
+
onChange(newValue);
|
|
11452
|
+
},
|
|
11453
|
+
[onChange, value, newItemDefault]
|
|
11454
|
+
);
|
|
11445
11455
|
const handleDeleteOptionRow = (0, import_react106.useCallback)(
|
|
11446
11456
|
(deleteIndex) => {
|
|
11447
11457
|
const updatedOptions = value.filter((_, index) => index !== deleteIndex);
|
|
11448
11458
|
onChange(updatedOptions);
|
|
11459
|
+
setBlockAutoGenerateForValues((current) => {
|
|
11460
|
+
const newSet = new Set(current);
|
|
11461
|
+
newSet.delete(value[deleteIndex].value);
|
|
11462
|
+
return newSet;
|
|
11463
|
+
});
|
|
11464
|
+
if (updatedOptions.length > 0) {
|
|
11465
|
+
const focusIndex = deleteIndex >= updatedOptions.length ? updatedOptions.length - 1 : deleteIndex;
|
|
11466
|
+
setIndexToFocus(focusIndex);
|
|
11467
|
+
}
|
|
11449
11468
|
},
|
|
11450
11469
|
[value, onChange]
|
|
11451
11470
|
);
|
|
@@ -11469,6 +11488,34 @@ var KeyValueInput = ({
|
|
|
11469
11488
|
},
|
|
11470
11489
|
[onChange, value]
|
|
11471
11490
|
);
|
|
11491
|
+
const handleKeyPaste = (0, import_react106.useCallback)(
|
|
11492
|
+
(rowIndex, e) => {
|
|
11493
|
+
const pastedText = e.clipboardData.getData("text");
|
|
11494
|
+
const lines = pastedText.split("\n").filter((line) => line.trim() !== "");
|
|
11495
|
+
if (lines.length <= 1) {
|
|
11496
|
+
return;
|
|
11497
|
+
}
|
|
11498
|
+
e.preventDefault();
|
|
11499
|
+
const newItems = [];
|
|
11500
|
+
lines.forEach((line) => {
|
|
11501
|
+
const linePieces = line.split(",");
|
|
11502
|
+
const hasMultipleCommas = linePieces.length > 2;
|
|
11503
|
+
if (linePieces.length > 1 && !hasMultipleCommas) {
|
|
11504
|
+
const key = linePieces[0].trim();
|
|
11505
|
+
const val = linePieces[1].trim();
|
|
11506
|
+
newItems.push({ key, value: val });
|
|
11507
|
+
} else {
|
|
11508
|
+
const trimmedLine = line.trim();
|
|
11509
|
+
newItems.push({ key: trimmedLine, value: trimmedLine });
|
|
11510
|
+
}
|
|
11511
|
+
});
|
|
11512
|
+
const newValue = [...value];
|
|
11513
|
+
newValue.splice(rowIndex, 1, ...newItems);
|
|
11514
|
+
onChange(newValue);
|
|
11515
|
+
setIndexToFocus(rowIndex + newItems.length - 1);
|
|
11516
|
+
},
|
|
11517
|
+
[onChange, value]
|
|
11518
|
+
);
|
|
11472
11519
|
const handleDragEnd = (0, import_react106.useCallback)(
|
|
11473
11520
|
(e) => {
|
|
11474
11521
|
setIsDragging(false);
|
|
@@ -11492,10 +11539,17 @@ var KeyValueInput = ({
|
|
|
11492
11539
|
setIsDragging(false);
|
|
11493
11540
|
}, [setIsDragging]);
|
|
11494
11541
|
(0, import_react106.useEffect)(() => {
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11542
|
+
const timeoutId = setTimeout(() => {
|
|
11543
|
+
var _a;
|
|
11544
|
+
if (indexToFocus !== null && keyInputRefsMap.current[indexToFocus]) {
|
|
11545
|
+
(_a = keyInputRefsMap.current[indexToFocus]) == null ? void 0 : _a.focus();
|
|
11546
|
+
setIndexToFocus(null);
|
|
11547
|
+
}
|
|
11548
|
+
});
|
|
11549
|
+
return () => {
|
|
11550
|
+
clearTimeout(timeoutId);
|
|
11551
|
+
};
|
|
11552
|
+
}, [indexToFocus]);
|
|
11499
11553
|
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(VerticalRhythm, { gap: "xs", children: [
|
|
11500
11554
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(HorizontalRhythm, { align: "center", justify: "space-between", css: { marginBottom: "var(--spacing-xs)" }, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { css: LabelStyles, children: label2 }) }),
|
|
11501
11555
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
|
|
@@ -11533,18 +11587,24 @@ var KeyValueInput = ({
|
|
|
11533
11587
|
}
|
|
11534
11588
|
)
|
|
11535
11589
|
] }),
|
|
11536
|
-
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(HorizontalRhythm, { align: "center",
|
|
11537
|
-
/* @__PURE__ */ (0, import_jsx_runtime91.
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11590
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(HorizontalRhythm, { align: "center", justify: "space-between", children: [
|
|
11591
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(HorizontalRhythm, { align: "center", gap: "xs", children: [
|
|
11592
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { children: valueLabel }),
|
|
11593
|
+
!valueInfoPopover ? null : /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
11594
|
+
Popover3,
|
|
11595
|
+
{
|
|
11596
|
+
buttonText: `${valueLabel} info`,
|
|
11597
|
+
iconColor: "gray",
|
|
11598
|
+
placement: "bottom-start",
|
|
11599
|
+
onInit: ({ store }) => popoverStoresMap.current.value = store,
|
|
11600
|
+
children: valueInfoPopover
|
|
11601
|
+
}
|
|
11602
|
+
)
|
|
11603
|
+
] }),
|
|
11604
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Caption, { css: { fontSize: "var(--fs-xs)" }, children: [
|
|
11605
|
+
getFormattedShortcut("enter"),
|
|
11606
|
+
" to insert row"
|
|
11607
|
+
] })
|
|
11548
11608
|
] })
|
|
11549
11609
|
]
|
|
11550
11610
|
}
|
|
@@ -11562,7 +11622,7 @@ var KeyValueInput = ({
|
|
|
11562
11622
|
KeyValueInputItem,
|
|
11563
11623
|
{
|
|
11564
11624
|
id,
|
|
11565
|
-
firstInputRef:
|
|
11625
|
+
firstInputRef: (ref) => keyInputRefsMap.current[index] = ref,
|
|
11566
11626
|
value: item,
|
|
11567
11627
|
keyLabel: `${keyLabel}, row ${index}`,
|
|
11568
11628
|
valueLabel: `${valueLabel}, row ${index}`,
|
|
@@ -11575,9 +11635,16 @@ var KeyValueInput = ({
|
|
|
11575
11635
|
onDelete: () => handleDeleteOptionRow(index),
|
|
11576
11636
|
onFocusChange: handleFocusChange,
|
|
11577
11637
|
"data-testid": "key-value-input-item",
|
|
11578
|
-
onEnter: handleAddOptionRow,
|
|
11638
|
+
onEnter: () => handleAddOptionRow(index),
|
|
11639
|
+
onKeyPaste: (e) => handleKeyPaste(index, e),
|
|
11579
11640
|
showIconColumn,
|
|
11580
|
-
renderIconSelector
|
|
11641
|
+
renderIconSelector,
|
|
11642
|
+
blockAutoGenerateValue: item.value !== "" && blockAutoGenerateForValues.has(item.value),
|
|
11643
|
+
onBlurValue: (value2) => setBlockAutoGenerateForValues((current) => {
|
|
11644
|
+
const newSet = new Set(current);
|
|
11645
|
+
newSet.add(value2);
|
|
11646
|
+
return newSet;
|
|
11647
|
+
})
|
|
11581
11648
|
},
|
|
11582
11649
|
isDragging ? id : index
|
|
11583
11650
|
)) })
|
|
@@ -11586,7 +11653,7 @@ var KeyValueInput = ({
|
|
|
11586
11653
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
11587
11654
|
AddListButton,
|
|
11588
11655
|
{
|
|
11589
|
-
onButtonClick: handleAddOptionRow,
|
|
11656
|
+
onButtonClick: () => handleAddOptionRow(value.length - 1),
|
|
11590
11657
|
disabled: disabled2,
|
|
11591
11658
|
"data-testid": "add-input-row-action",
|
|
11592
11659
|
css: { marginTop: "var(--spacing-sm)", marginLeft: "var(--spacing-base)" }
|
|
@@ -11609,8 +11676,11 @@ var KeyValueInputItem = ({
|
|
|
11609
11676
|
disabledDelete = false,
|
|
11610
11677
|
disabledDnd = false,
|
|
11611
11678
|
onEnter,
|
|
11679
|
+
onKeyPaste,
|
|
11612
11680
|
showIconColumn = false,
|
|
11613
|
-
renderIconSelector
|
|
11681
|
+
renderIconSelector,
|
|
11682
|
+
blockAutoGenerateValue,
|
|
11683
|
+
onBlurValue
|
|
11614
11684
|
}) => {
|
|
11615
11685
|
const { attributes, listeners, setNodeRef, transform, transition, setActivatorNodeRef, isSorting } = (0, import_sortable.useSortable)({
|
|
11616
11686
|
id,
|
|
@@ -11625,6 +11695,11 @@ var KeyValueInputItem = ({
|
|
|
11625
11695
|
onEnter();
|
|
11626
11696
|
}
|
|
11627
11697
|
};
|
|
11698
|
+
const handleValueKeyDown = (e) => {
|
|
11699
|
+
if (e.key === "Enter") {
|
|
11700
|
+
onEnter();
|
|
11701
|
+
}
|
|
11702
|
+
};
|
|
11628
11703
|
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { css: rowWrapper, ref: setNodeRef, style, children: [
|
|
11629
11704
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DragHandle, { disableDnd: disabledDnd, ref: setActivatorNodeRef, ...attributes, ...listeners }),
|
|
11630
11705
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
|
|
@@ -11668,7 +11743,7 @@ var KeyValueInputItem = ({
|
|
|
11668
11743
|
showLabel: false,
|
|
11669
11744
|
disabled: disabled2,
|
|
11670
11745
|
onChange: (e) => {
|
|
11671
|
-
const hasStoredValue = value.value !== value.key;
|
|
11746
|
+
const hasStoredValue = value.value !== value.key || blockAutoGenerateValue;
|
|
11672
11747
|
onChange == null ? void 0 : onChange({
|
|
11673
11748
|
key: e.currentTarget.value,
|
|
11674
11749
|
value: hasStoredValue ? value.value : e.currentTarget.value,
|
|
@@ -11678,6 +11753,7 @@ var KeyValueInputItem = ({
|
|
|
11678
11753
|
onBlur: () => onFocusChange == null ? void 0 : onFocusChange(false),
|
|
11679
11754
|
onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
|
|
11680
11755
|
onKeyDown: handleEnter,
|
|
11756
|
+
onPaste: onKeyPaste,
|
|
11681
11757
|
value: value.key,
|
|
11682
11758
|
errorMessage: isSorting ? void 0 : error == null ? void 0 : error.key,
|
|
11683
11759
|
"data-testid": "key"
|
|
@@ -11696,9 +11772,12 @@ var KeyValueInputItem = ({
|
|
|
11696
11772
|
icon: value.icon
|
|
11697
11773
|
});
|
|
11698
11774
|
},
|
|
11699
|
-
onBlur: () =>
|
|
11775
|
+
onBlur: () => {
|
|
11776
|
+
onFocusChange == null ? void 0 : onFocusChange(false);
|
|
11777
|
+
onBlurValue == null ? void 0 : onBlurValue(value.value);
|
|
11778
|
+
},
|
|
11700
11779
|
onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
|
|
11701
|
-
onKeyDown:
|
|
11780
|
+
onKeyDown: handleValueKeyDown,
|
|
11702
11781
|
value: value.value,
|
|
11703
11782
|
errorMessage: isSorting ? void 0 : error == null ? void 0 : error.value,
|
|
11704
11783
|
"data-testid": "value"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/design-system",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.40.0",
|
|
4
4
|
"description": "Uniform design system components",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"exports": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@storybook/theming": "^8.3.3",
|
|
39
39
|
"@types/react": "18.3.24",
|
|
40
40
|
"@types/react-dom": "18.3.7",
|
|
41
|
-
"@uniformdev/canvas": "^20.
|
|
42
|
-
"@uniformdev/richtext": "^20.
|
|
41
|
+
"@uniformdev/canvas": "^20.40.0",
|
|
42
|
+
"@uniformdev/richtext": "^20.40.0",
|
|
43
43
|
"@vitest/coverage-v8": "3.2.4",
|
|
44
44
|
"autoprefixer": "10.4.21",
|
|
45
45
|
"hygen": "6.2.11",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "5a63373f91355d8865feac0d3fc11be59a5e38bd"
|
|
97
97
|
}
|