@uniformdev/design-system 20.39.3-alpha.11 → 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 +117 -41
- package/dist/index.d.mts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +110 -40
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -2275,15 +2275,7 @@ var IconInner = ({ icon, iconColor = "default", size = "1.5rem", ...otherProps }
|
|
|
2275
2275
|
);
|
|
2276
2276
|
return null;
|
|
2277
2277
|
}
|
|
2278
|
-
return /* @__PURE__ */ jsx16(
|
|
2279
|
-
IconComponent,
|
|
2280
|
-
{
|
|
2281
|
-
role: "img",
|
|
2282
|
-
size,
|
|
2283
|
-
...otherProps,
|
|
2284
|
-
css: [IconImg, iconColor ? functionalColors : void 0, customColor[iconColor]]
|
|
2285
|
-
}
|
|
2286
|
-
);
|
|
2278
|
+
return /* @__PURE__ */ jsx16(IconComponent, { role: "img", size, ...otherProps, css: [IconImg, customColor[iconColor]] });
|
|
2287
2279
|
};
|
|
2288
2280
|
var Icon = React3.memo(IconInner);
|
|
2289
2281
|
|
|
@@ -7111,13 +7103,12 @@ var Counter = ({
|
|
|
7111
7103
|
if (typeof count === "undefined") {
|
|
7112
7104
|
return null;
|
|
7113
7105
|
}
|
|
7114
|
-
const
|
|
7115
|
-
const isTripleDigits = isNumber && count > 99 ? /* @__PURE__ */ jsxs39("span", { css: counterTripleValue, title: `${count}`, children: [
|
|
7106
|
+
const isTripleDigits = count > 99 ? /* @__PURE__ */ jsxs39("span", { css: counterTripleValue, title: `${count}`, children: [
|
|
7116
7107
|
"99",
|
|
7117
7108
|
/* @__PURE__ */ jsx60(Icon, { icon: "math-plus", iconColor: "currentColor", size: "0.5rem", css: counterIcon.tripleValue })
|
|
7118
7109
|
] }) : count;
|
|
7119
7110
|
const formatCount = count === 0 ? /* @__PURE__ */ jsx60("span", { css: counterZeroValue, title: `${count}` }) : isTripleDigits;
|
|
7120
|
-
return /* @__PURE__ */ jsxs39("div", { css: [counterContainer(bgColor, Boolean(icon
|
|
7111
|
+
return /* @__PURE__ */ jsxs39("div", { css: [counterContainer(bgColor, Boolean(icon)), sizeStyles[size]], ...props, children: [
|
|
7121
7112
|
icon ? /* @__PURE__ */ jsx60(
|
|
7122
7113
|
"span",
|
|
7123
7114
|
{
|
|
@@ -9489,7 +9480,13 @@ import {
|
|
|
9489
9480
|
verticalListSortingStrategy
|
|
9490
9481
|
} from "@dnd-kit/sortable";
|
|
9491
9482
|
import { CSS } from "@dnd-kit/utilities";
|
|
9492
|
-
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";
|
|
9493
9490
|
|
|
9494
9491
|
// src/utils/useDebouncedCallback.ts
|
|
9495
9492
|
import { useEffect as useEffect10, useMemo as useMemo4, useRef as useRef5 } from "react";
|
|
@@ -9580,8 +9577,12 @@ var KeyValueInput = ({
|
|
|
9580
9577
|
renderIconSelector
|
|
9581
9578
|
}) => {
|
|
9582
9579
|
const [isDragging, setIsDragging] = useState11(false);
|
|
9580
|
+
const [indexToFocus, setIndexToFocus] = useState11(null);
|
|
9583
9581
|
const popoverStoresMap = useRef6({});
|
|
9584
|
-
const
|
|
9582
|
+
const keyInputRefsMap = useRef6({});
|
|
9583
|
+
const [blockAutoGenerateForValues, setBlockAutoGenerateForValues] = useState11(
|
|
9584
|
+
() => new Set(value.map((item) => item.value))
|
|
9585
|
+
);
|
|
9585
9586
|
const sensors = useSensors(
|
|
9586
9587
|
useSensor(PointerSensor),
|
|
9587
9588
|
useSensor(KeyboardSensor, {
|
|
@@ -9591,13 +9592,28 @@ var KeyValueInput = ({
|
|
|
9591
9592
|
const valueWithIds = useMemo5(() => {
|
|
9592
9593
|
return value.map((item, index) => ({ ...item, id: generateItemId(item, index) }));
|
|
9593
9594
|
}, [value]);
|
|
9594
|
-
const handleAddOptionRow = useCallback7(
|
|
9595
|
-
|
|
9596
|
-
|
|
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
|
+
);
|
|
9597
9604
|
const handleDeleteOptionRow = useCallback7(
|
|
9598
9605
|
(deleteIndex) => {
|
|
9599
9606
|
const updatedOptions = value.filter((_, index) => index !== deleteIndex);
|
|
9600
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
|
+
}
|
|
9601
9617
|
},
|
|
9602
9618
|
[value, onChange]
|
|
9603
9619
|
);
|
|
@@ -9621,6 +9637,34 @@ var KeyValueInput = ({
|
|
|
9621
9637
|
},
|
|
9622
9638
|
[onChange, value]
|
|
9623
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
|
+
);
|
|
9624
9668
|
const handleDragEnd = useCallback7(
|
|
9625
9669
|
(e) => {
|
|
9626
9670
|
setIsDragging(false);
|
|
@@ -9644,10 +9688,17 @@ var KeyValueInput = ({
|
|
|
9644
9688
|
setIsDragging(false);
|
|
9645
9689
|
}, [setIsDragging]);
|
|
9646
9690
|
useEffect11(() => {
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
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]);
|
|
9651
9702
|
return /* @__PURE__ */ jsxs59(VerticalRhythm, { gap: "xs", children: [
|
|
9652
9703
|
/* @__PURE__ */ jsx91(HorizontalRhythm, { align: "center", justify: "space-between", css: { marginBottom: "var(--spacing-xs)" }, children: /* @__PURE__ */ jsx91("span", { css: LabelStyles, children: label2 }) }),
|
|
9653
9704
|
/* @__PURE__ */ jsxs59(
|
|
@@ -9685,18 +9736,24 @@ var KeyValueInput = ({
|
|
|
9685
9736
|
}
|
|
9686
9737
|
)
|
|
9687
9738
|
] }),
|
|
9688
|
-
/* @__PURE__ */ jsxs59(HorizontalRhythm, { align: "center",
|
|
9689
|
-
/* @__PURE__ */
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
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
|
+
] })
|
|
9700
9757
|
] })
|
|
9701
9758
|
]
|
|
9702
9759
|
}
|
|
@@ -9714,7 +9771,7 @@ var KeyValueInput = ({
|
|
|
9714
9771
|
KeyValueInputItem,
|
|
9715
9772
|
{
|
|
9716
9773
|
id,
|
|
9717
|
-
firstInputRef:
|
|
9774
|
+
firstInputRef: (ref) => keyInputRefsMap.current[index] = ref,
|
|
9718
9775
|
value: item,
|
|
9719
9776
|
keyLabel: `${keyLabel}, row ${index}`,
|
|
9720
9777
|
valueLabel: `${valueLabel}, row ${index}`,
|
|
@@ -9727,9 +9784,16 @@ var KeyValueInput = ({
|
|
|
9727
9784
|
onDelete: () => handleDeleteOptionRow(index),
|
|
9728
9785
|
onFocusChange: handleFocusChange,
|
|
9729
9786
|
"data-testid": "key-value-input-item",
|
|
9730
|
-
onEnter: handleAddOptionRow,
|
|
9787
|
+
onEnter: () => handleAddOptionRow(index),
|
|
9788
|
+
onKeyPaste: (e) => handleKeyPaste(index, e),
|
|
9731
9789
|
showIconColumn,
|
|
9732
|
-
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
|
+
})
|
|
9733
9797
|
},
|
|
9734
9798
|
isDragging ? id : index
|
|
9735
9799
|
)) })
|
|
@@ -9738,7 +9802,7 @@ var KeyValueInput = ({
|
|
|
9738
9802
|
/* @__PURE__ */ jsx91(
|
|
9739
9803
|
AddListButton,
|
|
9740
9804
|
{
|
|
9741
|
-
onButtonClick: handleAddOptionRow,
|
|
9805
|
+
onButtonClick: () => handleAddOptionRow(value.length - 1),
|
|
9742
9806
|
disabled: disabled2,
|
|
9743
9807
|
"data-testid": "add-input-row-action",
|
|
9744
9808
|
css: { marginTop: "var(--spacing-sm)", marginLeft: "var(--spacing-base)" }
|
|
@@ -9761,8 +9825,11 @@ var KeyValueInputItem = ({
|
|
|
9761
9825
|
disabledDelete = false,
|
|
9762
9826
|
disabledDnd = false,
|
|
9763
9827
|
onEnter,
|
|
9828
|
+
onKeyPaste,
|
|
9764
9829
|
showIconColumn = false,
|
|
9765
|
-
renderIconSelector
|
|
9830
|
+
renderIconSelector,
|
|
9831
|
+
blockAutoGenerateValue,
|
|
9832
|
+
onBlurValue
|
|
9766
9833
|
}) => {
|
|
9767
9834
|
const { attributes, listeners, setNodeRef, transform, transition, setActivatorNodeRef, isSorting } = useSortable({
|
|
9768
9835
|
id,
|
|
@@ -9777,6 +9844,11 @@ var KeyValueInputItem = ({
|
|
|
9777
9844
|
onEnter();
|
|
9778
9845
|
}
|
|
9779
9846
|
};
|
|
9847
|
+
const handleValueKeyDown = (e) => {
|
|
9848
|
+
if (e.key === "Enter") {
|
|
9849
|
+
onEnter();
|
|
9850
|
+
}
|
|
9851
|
+
};
|
|
9780
9852
|
return /* @__PURE__ */ jsxs59("div", { css: rowWrapper, ref: setNodeRef, style, children: [
|
|
9781
9853
|
/* @__PURE__ */ jsx91(DragHandle, { disableDnd: disabledDnd, ref: setActivatorNodeRef, ...attributes, ...listeners }),
|
|
9782
9854
|
/* @__PURE__ */ jsxs59(
|
|
@@ -9820,7 +9892,7 @@ var KeyValueInputItem = ({
|
|
|
9820
9892
|
showLabel: false,
|
|
9821
9893
|
disabled: disabled2,
|
|
9822
9894
|
onChange: (e) => {
|
|
9823
|
-
const hasStoredValue = value.value !== value.key;
|
|
9895
|
+
const hasStoredValue = value.value !== value.key || blockAutoGenerateValue;
|
|
9824
9896
|
onChange == null ? void 0 : onChange({
|
|
9825
9897
|
key: e.currentTarget.value,
|
|
9826
9898
|
value: hasStoredValue ? value.value : e.currentTarget.value,
|
|
@@ -9830,6 +9902,7 @@ var KeyValueInputItem = ({
|
|
|
9830
9902
|
onBlur: () => onFocusChange == null ? void 0 : onFocusChange(false),
|
|
9831
9903
|
onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
|
|
9832
9904
|
onKeyDown: handleEnter,
|
|
9905
|
+
onPaste: onKeyPaste,
|
|
9833
9906
|
value: value.key,
|
|
9834
9907
|
errorMessage: isSorting ? void 0 : error == null ? void 0 : error.key,
|
|
9835
9908
|
"data-testid": "key"
|
|
@@ -9848,9 +9921,12 @@ var KeyValueInputItem = ({
|
|
|
9848
9921
|
icon: value.icon
|
|
9849
9922
|
});
|
|
9850
9923
|
},
|
|
9851
|
-
onBlur: () =>
|
|
9924
|
+
onBlur: () => {
|
|
9925
|
+
onFocusChange == null ? void 0 : onFocusChange(false);
|
|
9926
|
+
onBlurValue == null ? void 0 : onBlurValue(value.value);
|
|
9927
|
+
},
|
|
9852
9928
|
onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
|
|
9853
|
-
onKeyDown:
|
|
9929
|
+
onKeyDown: handleValueKeyDown,
|
|
9854
9930
|
value: value.value,
|
|
9855
9931
|
errorMessage: isSorting ? void 0 : error == null ? void 0 : error.value,
|
|
9856
9932
|
"data-testid": "value"
|
package/dist/index.d.mts
CHANGED
|
@@ -1502,10 +1502,8 @@ declare const MultilineChip: ({ children, onClick, ...props }: MultilineChipProp
|
|
|
1502
1502
|
type CounterBgColors = 'var(--white)' | 'var(--gray-50)' | 'var(--accent-light)' | 'var(--accent-dark)' | 'transparent';
|
|
1503
1503
|
type CounterIconColors = 'auto' | 'var(--utility-caution-icon)' | 'var(--utility-danger-icon)' | 'var(--utility-info-icon)' | 'var(--utility-success-icon)' | 'red';
|
|
1504
1504
|
type CounterProps = {
|
|
1505
|
-
/** sets the count value, a 0 will show a dot instead of a number. Undefined will cause the counter to disappear.
|
|
1506
|
-
|
|
1507
|
-
*/
|
|
1508
|
-
count: number | string | undefined;
|
|
1505
|
+
/** sets the count value, a 0 will show a dot instead of a number. Undefined will cause the counter to disappear. */
|
|
1506
|
+
count: number | undefined;
|
|
1509
1507
|
/** sets the background color
|
|
1510
1508
|
* @default 'transparent'
|
|
1511
1509
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1502,10 +1502,8 @@ declare const MultilineChip: ({ children, onClick, ...props }: MultilineChipProp
|
|
|
1502
1502
|
type CounterBgColors = 'var(--white)' | 'var(--gray-50)' | 'var(--accent-light)' | 'var(--accent-dark)' | 'transparent';
|
|
1503
1503
|
type CounterIconColors = 'auto' | 'var(--utility-caution-icon)' | 'var(--utility-danger-icon)' | 'var(--utility-info-icon)' | 'var(--utility-success-icon)' | 'red';
|
|
1504
1504
|
type CounterProps = {
|
|
1505
|
-
/** sets the count value, a 0 will show a dot instead of a number. Undefined will cause the counter to disappear.
|
|
1506
|
-
|
|
1507
|
-
*/
|
|
1508
|
-
count: number | string | undefined;
|
|
1505
|
+
/** sets the count value, a 0 will show a dot instead of a number. Undefined will cause the counter to disappear. */
|
|
1506
|
+
count: number | undefined;
|
|
1509
1507
|
/** sets the background color
|
|
1510
1508
|
* @default 'transparent'
|
|
1511
1509
|
*/
|
package/dist/index.js
CHANGED
|
@@ -3989,15 +3989,7 @@ var IconInner = ({ icon, iconColor = "default", size = "1.5rem", ...otherProps }
|
|
|
3989
3989
|
);
|
|
3990
3990
|
return null;
|
|
3991
3991
|
}
|
|
3992
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3993
|
-
IconComponent,
|
|
3994
|
-
{
|
|
3995
|
-
role: "img",
|
|
3996
|
-
size,
|
|
3997
|
-
...otherProps,
|
|
3998
|
-
css: [IconImg, iconColor ? functionalColors : void 0, customColor[iconColor]]
|
|
3999
|
-
}
|
|
4000
|
-
);
|
|
3992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(IconComponent, { role: "img", size, ...otherProps, css: [IconImg, customColor[iconColor]] });
|
|
4001
3993
|
};
|
|
4002
3994
|
var Icon = import_react24.default.memo(IconInner);
|
|
4003
3995
|
|
|
@@ -8908,13 +8900,12 @@ var Counter = ({
|
|
|
8908
8900
|
if (typeof count === "undefined") {
|
|
8909
8901
|
return null;
|
|
8910
8902
|
}
|
|
8911
|
-
const
|
|
8912
|
-
const isTripleDigits = isNumber && count > 99 ? /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("span", { css: counterTripleValue, title: `${count}`, children: [
|
|
8903
|
+
const isTripleDigits = count > 99 ? /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("span", { css: counterTripleValue, title: `${count}`, children: [
|
|
8913
8904
|
"99",
|
|
8914
8905
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Icon, { icon: "math-plus", iconColor: "currentColor", size: "0.5rem", css: counterIcon.tripleValue })
|
|
8915
8906
|
] }) : count;
|
|
8916
8907
|
const formatCount = count === 0 ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { css: counterZeroValue, title: `${count}` }) : isTripleDigits;
|
|
8917
|
-
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { css: [counterContainer(bgColor, Boolean(icon
|
|
8908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { css: [counterContainer(bgColor, Boolean(icon)), sizeStyles[size]], ...props, children: [
|
|
8918
8909
|
icon ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
8919
8910
|
"span",
|
|
8920
8911
|
{
|
|
@@ -11437,8 +11428,12 @@ var KeyValueInput = ({
|
|
|
11437
11428
|
renderIconSelector
|
|
11438
11429
|
}) => {
|
|
11439
11430
|
const [isDragging, setIsDragging] = (0, import_react106.useState)(false);
|
|
11431
|
+
const [indexToFocus, setIndexToFocus] = (0, import_react106.useState)(null);
|
|
11440
11432
|
const popoverStoresMap = (0, import_react106.useRef)({});
|
|
11441
|
-
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
|
+
);
|
|
11442
11437
|
const sensors = (0, import_core.useSensors)(
|
|
11443
11438
|
(0, import_core.useSensor)(import_core.PointerSensor),
|
|
11444
11439
|
(0, import_core.useSensor)(import_core.KeyboardSensor, {
|
|
@@ -11448,13 +11443,28 @@ var KeyValueInput = ({
|
|
|
11448
11443
|
const valueWithIds = (0, import_react106.useMemo)(() => {
|
|
11449
11444
|
return value.map((item, index) => ({ ...item, id: generateItemId(item, index) }));
|
|
11450
11445
|
}, [value]);
|
|
11451
|
-
const handleAddOptionRow = (0, import_react106.useCallback)(
|
|
11452
|
-
|
|
11453
|
-
|
|
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
|
+
);
|
|
11454
11455
|
const handleDeleteOptionRow = (0, import_react106.useCallback)(
|
|
11455
11456
|
(deleteIndex) => {
|
|
11456
11457
|
const updatedOptions = value.filter((_, index) => index !== deleteIndex);
|
|
11457
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
|
+
}
|
|
11458
11468
|
},
|
|
11459
11469
|
[value, onChange]
|
|
11460
11470
|
);
|
|
@@ -11478,6 +11488,34 @@ var KeyValueInput = ({
|
|
|
11478
11488
|
},
|
|
11479
11489
|
[onChange, value]
|
|
11480
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
|
+
);
|
|
11481
11519
|
const handleDragEnd = (0, import_react106.useCallback)(
|
|
11482
11520
|
(e) => {
|
|
11483
11521
|
setIsDragging(false);
|
|
@@ -11501,10 +11539,17 @@ var KeyValueInput = ({
|
|
|
11501
11539
|
setIsDragging(false);
|
|
11502
11540
|
}, [setIsDragging]);
|
|
11503
11541
|
(0, import_react106.useEffect)(() => {
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
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]);
|
|
11508
11553
|
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(VerticalRhythm, { gap: "xs", children: [
|
|
11509
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 }) }),
|
|
11510
11555
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
|
|
@@ -11542,18 +11587,24 @@ var KeyValueInput = ({
|
|
|
11542
11587
|
}
|
|
11543
11588
|
)
|
|
11544
11589
|
] }),
|
|
11545
|
-
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(HorizontalRhythm, { align: "center",
|
|
11546
|
-
/* @__PURE__ */ (0, import_jsx_runtime91.
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
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
|
+
] })
|
|
11557
11608
|
] })
|
|
11558
11609
|
]
|
|
11559
11610
|
}
|
|
@@ -11571,7 +11622,7 @@ var KeyValueInput = ({
|
|
|
11571
11622
|
KeyValueInputItem,
|
|
11572
11623
|
{
|
|
11573
11624
|
id,
|
|
11574
|
-
firstInputRef:
|
|
11625
|
+
firstInputRef: (ref) => keyInputRefsMap.current[index] = ref,
|
|
11575
11626
|
value: item,
|
|
11576
11627
|
keyLabel: `${keyLabel}, row ${index}`,
|
|
11577
11628
|
valueLabel: `${valueLabel}, row ${index}`,
|
|
@@ -11584,9 +11635,16 @@ var KeyValueInput = ({
|
|
|
11584
11635
|
onDelete: () => handleDeleteOptionRow(index),
|
|
11585
11636
|
onFocusChange: handleFocusChange,
|
|
11586
11637
|
"data-testid": "key-value-input-item",
|
|
11587
|
-
onEnter: handleAddOptionRow,
|
|
11638
|
+
onEnter: () => handleAddOptionRow(index),
|
|
11639
|
+
onKeyPaste: (e) => handleKeyPaste(index, e),
|
|
11588
11640
|
showIconColumn,
|
|
11589
|
-
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
|
+
})
|
|
11590
11648
|
},
|
|
11591
11649
|
isDragging ? id : index
|
|
11592
11650
|
)) })
|
|
@@ -11595,7 +11653,7 @@ var KeyValueInput = ({
|
|
|
11595
11653
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
11596
11654
|
AddListButton,
|
|
11597
11655
|
{
|
|
11598
|
-
onButtonClick: handleAddOptionRow,
|
|
11656
|
+
onButtonClick: () => handleAddOptionRow(value.length - 1),
|
|
11599
11657
|
disabled: disabled2,
|
|
11600
11658
|
"data-testid": "add-input-row-action",
|
|
11601
11659
|
css: { marginTop: "var(--spacing-sm)", marginLeft: "var(--spacing-base)" }
|
|
@@ -11618,8 +11676,11 @@ var KeyValueInputItem = ({
|
|
|
11618
11676
|
disabledDelete = false,
|
|
11619
11677
|
disabledDnd = false,
|
|
11620
11678
|
onEnter,
|
|
11679
|
+
onKeyPaste,
|
|
11621
11680
|
showIconColumn = false,
|
|
11622
|
-
renderIconSelector
|
|
11681
|
+
renderIconSelector,
|
|
11682
|
+
blockAutoGenerateValue,
|
|
11683
|
+
onBlurValue
|
|
11623
11684
|
}) => {
|
|
11624
11685
|
const { attributes, listeners, setNodeRef, transform, transition, setActivatorNodeRef, isSorting } = (0, import_sortable.useSortable)({
|
|
11625
11686
|
id,
|
|
@@ -11634,6 +11695,11 @@ var KeyValueInputItem = ({
|
|
|
11634
11695
|
onEnter();
|
|
11635
11696
|
}
|
|
11636
11697
|
};
|
|
11698
|
+
const handleValueKeyDown = (e) => {
|
|
11699
|
+
if (e.key === "Enter") {
|
|
11700
|
+
onEnter();
|
|
11701
|
+
}
|
|
11702
|
+
};
|
|
11637
11703
|
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { css: rowWrapper, ref: setNodeRef, style, children: [
|
|
11638
11704
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DragHandle, { disableDnd: disabledDnd, ref: setActivatorNodeRef, ...attributes, ...listeners }),
|
|
11639
11705
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
|
|
@@ -11677,7 +11743,7 @@ var KeyValueInputItem = ({
|
|
|
11677
11743
|
showLabel: false,
|
|
11678
11744
|
disabled: disabled2,
|
|
11679
11745
|
onChange: (e) => {
|
|
11680
|
-
const hasStoredValue = value.value !== value.key;
|
|
11746
|
+
const hasStoredValue = value.value !== value.key || blockAutoGenerateValue;
|
|
11681
11747
|
onChange == null ? void 0 : onChange({
|
|
11682
11748
|
key: e.currentTarget.value,
|
|
11683
11749
|
value: hasStoredValue ? value.value : e.currentTarget.value,
|
|
@@ -11687,6 +11753,7 @@ var KeyValueInputItem = ({
|
|
|
11687
11753
|
onBlur: () => onFocusChange == null ? void 0 : onFocusChange(false),
|
|
11688
11754
|
onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
|
|
11689
11755
|
onKeyDown: handleEnter,
|
|
11756
|
+
onPaste: onKeyPaste,
|
|
11690
11757
|
value: value.key,
|
|
11691
11758
|
errorMessage: isSorting ? void 0 : error == null ? void 0 : error.key,
|
|
11692
11759
|
"data-testid": "key"
|
|
@@ -11705,9 +11772,12 @@ var KeyValueInputItem = ({
|
|
|
11705
11772
|
icon: value.icon
|
|
11706
11773
|
});
|
|
11707
11774
|
},
|
|
11708
|
-
onBlur: () =>
|
|
11775
|
+
onBlur: () => {
|
|
11776
|
+
onFocusChange == null ? void 0 : onFocusChange(false);
|
|
11777
|
+
onBlurValue == null ? void 0 : onBlurValue(value.value);
|
|
11778
|
+
},
|
|
11709
11779
|
onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
|
|
11710
|
-
onKeyDown:
|
|
11780
|
+
onKeyDown: handleValueKeyDown,
|
|
11711
11781
|
value: value.value,
|
|
11712
11782
|
errorMessage: isSorting ? void 0 : error == null ? void 0 : error.value,
|
|
11713
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
|
}
|