@spscommerce/ds-react 6.18.2 → 6.19.1
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/lib/index.es.js
CHANGED
|
@@ -24832,7 +24832,7 @@ Object.assign(SpsKeyValueListItem, {
|
|
|
24832
24832
|
});
|
|
24833
24833
|
const SpsKeyValueListExamples = {
|
|
24834
24834
|
vertical: {
|
|
24835
|
-
label: "Vertical Key Value
|
|
24835
|
+
label: "Vertical Key Value Lists",
|
|
24836
24836
|
description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h5", null, "Use:"), /* @__PURE__ */ React__default.createElement("ul", null, /* @__PURE__ */ React__default.createElement("li", {
|
|
24837
24837
|
className: "mb-2"
|
|
24838
24838
|
}, "Vertical containers such as a side bar or general card")), /* @__PURE__ */ React__default.createElement("h5", null, "Do Not Use:"), /* @__PURE__ */ React__default.createElement("ul", null, /* @__PURE__ */ React__default.createElement("li", {
|
|
@@ -24931,7 +24931,7 @@ const SpsKeyValueListExamples = {
|
|
|
24931
24931
|
}
|
|
24932
24932
|
},
|
|
24933
24933
|
horizontal: {
|
|
24934
|
-
label: "Horizontal Key Value
|
|
24934
|
+
label: "Horizontal Key Value Lists",
|
|
24935
24935
|
description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h5", null, "Use:"), /* @__PURE__ */ React__default.createElement("ul", null, /* @__PURE__ */ React__default.createElement("li", {
|
|
24936
24936
|
className: "mb-2"
|
|
24937
24937
|
}, "Horizontal containers such as a content row")), /* @__PURE__ */ React__default.createElement("h5", null, "Do Not Use:"), /* @__PURE__ */ React__default.createElement("ul", null, /* @__PURE__ */ React__default.createElement("li", {
|
|
@@ -24948,7 +24948,7 @@ const SpsKeyValueListExamples = {
|
|
|
24948
24948
|
className: "mb-2"
|
|
24949
24949
|
}, "Can be used individually or stacked on top of one another", /* @__PURE__ */ React__default.createElement("ul", null, /* @__PURE__ */ React__default.createElement("li", {
|
|
24950
24950
|
className: "mb-2"
|
|
24951
|
-
}, "When stacking, the value
|
|
24951
|
+
}, "When stacking, the value lists should share a common category or theme"))))),
|
|
24952
24952
|
examples: {
|
|
24953
24953
|
standard: {
|
|
24954
24954
|
description: () => /* @__PURE__ */ React__default.createElement("h4", null, "Standard"),
|
|
@@ -24965,7 +24965,7 @@ const SpsKeyValueListExamples = {
|
|
|
24965
24965
|
`
|
|
24966
24966
|
},
|
|
24967
24967
|
stacked: {
|
|
24968
|
-
description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h4", null, "Stacked"), /* @__PURE__ */ React__default.createElement("p", null, /* @__PURE__ */ React__default.createElement("b", null, "Note:"), " There is no limit to the number of stacked listings, but more than three in a single container should be avoided."), /* @__PURE__ */ React__default.createElement("p", null, /* @__PURE__ */ React__default.createElement("b", null, "Note:"), " Titles are right-aligned in the horizontal Key Value
|
|
24968
|
+
description: () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("h4", null, "Stacked"), /* @__PURE__ */ React__default.createElement("p", null, /* @__PURE__ */ React__default.createElement("b", null, "Note:"), " There is no limit to the number of stacked listings, but more than three in a single container should be avoided."), /* @__PURE__ */ React__default.createElement("p", null, /* @__PURE__ */ React__default.createElement("b", null, "Note:"), " Titles are right-aligned in the horizontal Key Value Lists to optimize scanability of the values.")),
|
|
24969
24969
|
react: code`
|
|
24970
24970
|
function DemoComponent() {
|
|
24971
24971
|
return (
|
|
@@ -38158,7 +38158,7 @@ const MANIFEST = {
|
|
|
38158
38158
|
examples: SpsInsightTileExamples
|
|
38159
38159
|
},
|
|
38160
38160
|
"Key Value Lists": {
|
|
38161
|
-
description: () => /* @__PURE__ */ React.createElement("p", null, "Key Value
|
|
38161
|
+
description: () => /* @__PURE__ */ React.createElement("p", null, "Key Value Lists consist of a title and value, or values, paired together visually. They are ideal for displaying details (a value or values) that require additional context (title)."),
|
|
38162
38162
|
components: [SpsKeyValueList, SpsKeyValueListItem],
|
|
38163
38163
|
examples: SpsKeyValueListExamples
|
|
38164
38164
|
},
|
|
@@ -38610,9 +38610,10 @@ const SpsKeyValueTagExamples = {
|
|
|
38610
38610
|
}
|
|
38611
38611
|
}
|
|
38612
38612
|
};
|
|
38613
|
-
|
|
38614
|
-
|
|
38615
|
-
|
|
38613
|
+
function splitStringByDelimiter(str, delimiters) {
|
|
38614
|
+
const regexForSplit = new RegExp(`[\\t\r
|
|
38615
|
+
${delimiters.join("").replace("]", "\\]").replace(" ", "\\s")}]+`);
|
|
38616
|
+
return str.split(regexForSplit).filter((s) => s !== "");
|
|
38616
38617
|
}
|
|
38617
38618
|
const propsDoc$1 = {
|
|
38618
38619
|
disabled: "boolean",
|
|
@@ -38621,7 +38622,8 @@ const propsDoc$1 = {
|
|
|
38621
38622
|
onChange: "ChangeEventHandler",
|
|
38622
38623
|
onEntryChange: "(searchText: string) => void",
|
|
38623
38624
|
placeholder: "string",
|
|
38624
|
-
value: "any"
|
|
38625
|
+
value: "any",
|
|
38626
|
+
createTagOptions: "string[]"
|
|
38625
38627
|
};
|
|
38626
38628
|
const propTypes$1 = __spreadProps(__spreadValues({}, spsGlobalPropTypes), {
|
|
38627
38629
|
disabled: propTypes$1H.exports.bool,
|
|
@@ -38631,7 +38633,8 @@ const propTypes$1 = __spreadProps(__spreadValues({}, spsGlobalPropTypes), {
|
|
|
38631
38633
|
onChange: fun(),
|
|
38632
38634
|
onEntryChange: fun(),
|
|
38633
38635
|
placeholder: propTypes$1H.exports.string,
|
|
38634
|
-
value: propTypes$1H.exports.any
|
|
38636
|
+
value: propTypes$1H.exports.any,
|
|
38637
|
+
createTagOptions: propTypes$1H.exports.arrayOf(propTypes$1H.exports.string)
|
|
38635
38638
|
});
|
|
38636
38639
|
function SpsMultiValueTextInput(_ma) {
|
|
38637
38640
|
var _na = _ma, {
|
|
@@ -38646,6 +38649,7 @@ function SpsMultiValueTextInput(_ma) {
|
|
|
38646
38649
|
unsafelyReplaceClassName,
|
|
38647
38650
|
value,
|
|
38648
38651
|
icon,
|
|
38652
|
+
createTagOptions = [" ", ","],
|
|
38649
38653
|
"data-testid": testId
|
|
38650
38654
|
} = _na, rest = __objRest(_na, [
|
|
38651
38655
|
"className",
|
|
@@ -38659,6 +38663,7 @@ function SpsMultiValueTextInput(_ma) {
|
|
|
38659
38663
|
"unsafelyReplaceClassName",
|
|
38660
38664
|
"value",
|
|
38661
38665
|
"icon",
|
|
38666
|
+
"createTagOptions",
|
|
38662
38667
|
"data-testid"
|
|
38663
38668
|
]);
|
|
38664
38669
|
const meta = formMeta || formControl2;
|
|
@@ -38706,6 +38711,21 @@ function SpsMultiValueTextInput(_ma) {
|
|
|
38706
38711
|
removeIcon && removeIcon.focus();
|
|
38707
38712
|
}
|
|
38708
38713
|
}
|
|
38714
|
+
const createNewTag = React.useCallback((event) => {
|
|
38715
|
+
patchState({ activeTagIndex: null, searchText: "" });
|
|
38716
|
+
const trimmedText = state.searchText.trim();
|
|
38717
|
+
if (trimmedText && value.indexOf(trimmedText) === -1) {
|
|
38718
|
+
updateValue([...value, ...splitStringByDelimiter(trimmedText, createTagOptions)]);
|
|
38719
|
+
}
|
|
38720
|
+
if ((event.key === "Tab" || event.key === "Enter") && !state.searchText) {
|
|
38721
|
+
return;
|
|
38722
|
+
}
|
|
38723
|
+
event.preventDefault();
|
|
38724
|
+
}, [
|
|
38725
|
+
state.searchText,
|
|
38726
|
+
value,
|
|
38727
|
+
splitStringByDelimiter
|
|
38728
|
+
]);
|
|
38709
38729
|
function handleKeyDown(event) {
|
|
38710
38730
|
if (!disabled) {
|
|
38711
38731
|
const cursorIsAtLeftOfTextInputAndThereIsAtLeastOneSelection = !event.target.selectionStart && value && value.length;
|
|
@@ -38734,15 +38754,7 @@ function SpsMultiValueTextInput(_ma) {
|
|
|
38734
38754
|
break;
|
|
38735
38755
|
case "Enter":
|
|
38736
38756
|
case "Tab":
|
|
38737
|
-
|
|
38738
|
-
case " ":
|
|
38739
|
-
if (state.searchText !== "") {
|
|
38740
|
-
event.preventDefault();
|
|
38741
|
-
}
|
|
38742
|
-
patchState({ activeTagIndex: null, searchText: "" });
|
|
38743
|
-
if (state.searchText.trim() !== "" && value.indexOf(state.searchText) === -1) {
|
|
38744
|
-
updateValue([...value, ...splitStringByDelimiter(state.searchText)]);
|
|
38745
|
-
}
|
|
38757
|
+
createNewTag(event);
|
|
38746
38758
|
break;
|
|
38747
38759
|
case "Up":
|
|
38748
38760
|
case "ArrowUp":
|
|
@@ -38777,6 +38789,11 @@ function SpsMultiValueTextInput(_ma) {
|
|
|
38777
38789
|
}
|
|
38778
38790
|
break;
|
|
38779
38791
|
}
|
|
38792
|
+
for (const option of createTagOptions) {
|
|
38793
|
+
if (event.key === option) {
|
|
38794
|
+
createNewTag(event);
|
|
38795
|
+
}
|
|
38796
|
+
}
|
|
38780
38797
|
event.persist();
|
|
38781
38798
|
patchState({ keyDown: event });
|
|
38782
38799
|
}
|
|
@@ -12,11 +12,12 @@ declare const propTypes: {
|
|
|
12
12
|
onEntryChange: PropTypes.Requireable<(searchText: string) => void>;
|
|
13
13
|
placeholder: PropTypes.Requireable<string>;
|
|
14
14
|
value: PropTypes.Requireable<any>;
|
|
15
|
+
createTagOptions: PropTypes.Requireable<string[]>;
|
|
15
16
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
16
17
|
className: PropTypes.Requireable<string>;
|
|
17
18
|
"data-testid": PropTypes.Requireable<string>;
|
|
18
19
|
unsafelyReplaceClassName: PropTypes.Requireable<string>;
|
|
19
20
|
};
|
|
20
21
|
export declare type SpsMultiValueTextInputProps = PropTypes.InferTS<typeof propTypes, HTMLInputElement>;
|
|
21
|
-
export declare function SpsMultiValueTextInput({ className, disabled, formControl, formMeta, id, onChange, onEntryChange, placeholder, unsafelyReplaceClassName, value, icon, "data-testid": testId, ...rest }: SpsMultiValueTextInputProps): JSX.Element;
|
|
22
|
+
export declare function SpsMultiValueTextInput({ className, disabled, formControl, formMeta, id, onChange, onEntryChange, placeholder, unsafelyReplaceClassName, value, icon, createTagOptions, "data-testid": testId, ...rest }: SpsMultiValueTextInputProps): JSX.Element;
|
|
22
23
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const WHITESPACE_COMMA_TAB_NEWLINE_REGEX: RegExp;
|
|
2
|
-
export declare function splitStringByDelimiter(str: string): string[];
|
|
2
|
+
export declare function splitStringByDelimiter(str: string, delimiters: string[]): string[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spscommerce/ds-react",
|
|
3
3
|
"description": "SPS Design System React components",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.19.1",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/spscommerce/design-system/tree/main/packages/@spscommerce/ds-react",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@react-stately/collections": "^3.3.3",
|
|
31
|
-
"@spscommerce/ds-colors": "6.
|
|
32
|
-
"@spscommerce/ds-illustrations": "6.
|
|
33
|
-
"@spscommerce/ds-shared": "6.
|
|
34
|
-
"@spscommerce/positioning": "6.
|
|
31
|
+
"@spscommerce/ds-colors": "6.19.1",
|
|
32
|
+
"@spscommerce/ds-illustrations": "6.19.1",
|
|
33
|
+
"@spscommerce/ds-shared": "6.19.1",
|
|
34
|
+
"@spscommerce/positioning": "6.19.1",
|
|
35
35
|
"@spscommerce/utils": "^6.11.3",
|
|
36
36
|
"moment": "^2.25.3",
|
|
37
37
|
"moment-timezone": "^0.5.28",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@react-stately/collections": "^3.3.3",
|
|
43
|
-
"@spscommerce/ds-colors": "6.
|
|
44
|
-
"@spscommerce/ds-illustrations": "6.
|
|
45
|
-
"@spscommerce/ds-shared": "6.
|
|
46
|
-
"@spscommerce/positioning": "6.
|
|
43
|
+
"@spscommerce/ds-colors": "6.19.1",
|
|
44
|
+
"@spscommerce/ds-illustrations": "6.19.1",
|
|
45
|
+
"@spscommerce/ds-shared": "6.19.1",
|
|
46
|
+
"@spscommerce/positioning": "6.19.1",
|
|
47
47
|
"@spscommerce/utils": "^6.11.3",
|
|
48
48
|
"@testing-library/react": "^9.3.2",
|
|
49
49
|
"@types/prop-types": "^15.7.1",
|