@spscommerce/ds-react 5.9.0 → 5.10.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/lib/index.es.js
CHANGED
|
@@ -22798,7 +22798,8 @@ function SpsFieldset({
|
|
|
22798
22798
|
optional = false,
|
|
22799
22799
|
enabled,
|
|
22800
22800
|
onToggled,
|
|
22801
|
-
tooltip
|
|
22801
|
+
tooltip,
|
|
22802
|
+
"data-testid": testId
|
|
22802
22803
|
}) {
|
|
22803
22804
|
const formControlSet = formGroup2 || formArray2;
|
|
22804
22805
|
const legendElement = React.useRef(null);
|
|
@@ -22832,7 +22833,8 @@ function SpsFieldset({
|
|
|
22832
22833
|
return /* @__PURE__ */ React.createElement("div", {
|
|
22833
22834
|
className: "sps-fieldset-container"
|
|
22834
22835
|
}, /* @__PURE__ */ React.createElement("fieldset", {
|
|
22835
|
-
className: fieldsetClasses
|
|
22836
|
+
className: fieldsetClasses,
|
|
22837
|
+
"data-testid": testId
|
|
22836
22838
|
}, /* @__PURE__ */ React.createElement("legend", {
|
|
22837
22839
|
className: "sps-fieldset__legend",
|
|
22838
22840
|
ref: legendElement,
|
|
@@ -22844,12 +22846,14 @@ function SpsFieldset({
|
|
|
22844
22846
|
className: "d-inline-flex",
|
|
22845
22847
|
onChange: () => {
|
|
22846
22848
|
setisChecked(!isChecked);
|
|
22847
|
-
}
|
|
22849
|
+
},
|
|
22850
|
+
"data-testid": `${testId}__checkbox`
|
|
22848
22851
|
}), legend, tooltip && /* @__PURE__ */ React.createElement("span", {
|
|
22849
22852
|
className: "sps-fieldset__legend-icon",
|
|
22850
22853
|
ref: infoCircleElement
|
|
22851
22854
|
}, /* @__PURE__ */ React.createElement(SpsI, {
|
|
22852
|
-
icon: SpsIcon.INFO_CIRCLE
|
|
22855
|
+
icon: SpsIcon.INFO_CIRCLE,
|
|
22856
|
+
"data-testid": `${testId}__info-icon`
|
|
22853
22857
|
}))), tooltip && /* @__PURE__ */ React.createElement(SpsTooltip, {
|
|
22854
22858
|
for: infoCircleElement
|
|
22855
22859
|
}, tooltip), /* @__PURE__ */ React.createElement(SpsTooltip, {
|
|
@@ -32065,7 +32069,7 @@ const SpsSideNavBranch = ({
|
|
|
32065
32069
|
onClick: () => {
|
|
32066
32070
|
setIsBranchExpanded(!isBranchExpanded);
|
|
32067
32071
|
if (!branch.subNavItems) {
|
|
32068
|
-
setActiveBranch(branch.name);
|
|
32072
|
+
setActiveBranch(branch.name, branch.key);
|
|
32069
32073
|
}
|
|
32070
32074
|
},
|
|
32071
32075
|
onKeyDown: (event) => {
|
|
@@ -32074,12 +32078,13 @@ const SpsSideNavBranch = ({
|
|
|
32074
32078
|
event.preventDefault();
|
|
32075
32079
|
setIsBranchExpanded(!isBranchExpanded);
|
|
32076
32080
|
if (!branch.subNavItems) {
|
|
32077
|
-
setActiveBranch(branch.name);
|
|
32081
|
+
setActiveBranch(branch.name, branch.key);
|
|
32078
32082
|
}
|
|
32079
32083
|
}
|
|
32080
32084
|
},
|
|
32081
32085
|
role: "tab",
|
|
32082
|
-
tabIndex: 0
|
|
32086
|
+
tabIndex: 0,
|
|
32087
|
+
"aria-selected": branch.name === activeBranch
|
|
32083
32088
|
}, branch.subNavItems && /* @__PURE__ */ React.createElement("i", {
|
|
32084
32089
|
className: clsx("sps-icon sps-side-nav__toggle", isBranchExpanded ? "sps-icon-chevron-down" : "sps-icon-chevron-right")
|
|
32085
32090
|
}), /* @__PURE__ */ React.createElement("span", {
|
|
@@ -32091,14 +32096,17 @@ const SpsSideNavBranch = ({
|
|
|
32091
32096
|
style: { marginTop: "-2px" }
|
|
32092
32097
|
}, branch.tag && /* @__PURE__ */ React.createElement("span", {
|
|
32093
32098
|
className: `sps-tag sps-tag--${branch.tag}`
|
|
32094
|
-
}, branch.tagContent))), branch.subNavItems && isBranchExpanded && branch.subNavItems.map((subNav) =>
|
|
32095
|
-
|
|
32096
|
-
|
|
32097
|
-
|
|
32098
|
-
|
|
32099
|
-
|
|
32100
|
-
|
|
32101
|
-
|
|
32099
|
+
}, branch.tagContent))), branch.subNavItems && isBranchExpanded && branch.subNavItems.map((subNav) => {
|
|
32100
|
+
var _a;
|
|
32101
|
+
return /* @__PURE__ */ React.createElement(SpsSideNavBranch, {
|
|
32102
|
+
branch: __spreadProps(__spreadValues({}, subNav), {
|
|
32103
|
+
expanded: findParentBranches(subNav.subNavItems, activeBranch)
|
|
32104
|
+
}),
|
|
32105
|
+
setActiveBranch,
|
|
32106
|
+
activeBranch,
|
|
32107
|
+
key: (_a = subNav.key) != null ? _a : subNav.name
|
|
32108
|
+
});
|
|
32109
|
+
})));
|
|
32102
32110
|
};
|
|
32103
32111
|
const findParentBranches = (nav, activeTab) => {
|
|
32104
32112
|
if (nav) {
|
|
@@ -32122,10 +32130,10 @@ const SpsSideNav = ({
|
|
|
32122
32130
|
const [activeBranch, setActiveBranch] = useState(activeNavItem);
|
|
32123
32131
|
const [activeTab, setActiveTab] = useState(initialActiveTab || tabs && tabs[0]);
|
|
32124
32132
|
const [filterValue, setFilterValue] = useState("");
|
|
32125
|
-
const handleNavAction = (branch) => {
|
|
32133
|
+
const handleNavAction = (branch, key) => {
|
|
32126
32134
|
setActiveBranch(branch);
|
|
32127
32135
|
if (onNavChange) {
|
|
32128
|
-
onNavChange(branch);
|
|
32136
|
+
onNavChange(branch, key);
|
|
32129
32137
|
}
|
|
32130
32138
|
};
|
|
32131
32139
|
const handleTabAction = (tab2) => {
|
|
@@ -32140,8 +32148,7 @@ const SpsSideNav = ({
|
|
|
32140
32148
|
}
|
|
32141
32149
|
return false;
|
|
32142
32150
|
};
|
|
32143
|
-
const filteredNavOptions = navOptions.map((option) => ({
|
|
32144
|
-
sectionTitle: option.sectionTitle,
|
|
32151
|
+
const filteredNavOptions = navOptions.map((option) => __spreadProps(__spreadValues({}, option), {
|
|
32145
32152
|
navItems: option.navItems.filter((navItem) => navItem.name.toLowerCase().includes(filterValue) || filterChildBranches(navItem.subNavItems))
|
|
32146
32153
|
}));
|
|
32147
32154
|
if (activeNavItem !== previousActiveNavItem.current) {
|
|
@@ -32190,22 +32197,28 @@ const SpsSideNav = ({
|
|
|
32190
32197
|
onChange: (event) => {
|
|
32191
32198
|
setFilterValue(event.target.value);
|
|
32192
32199
|
}
|
|
32193
|
-
})))), filteredNavOptions.map((section) =>
|
|
32194
|
-
|
|
32195
|
-
|
|
32196
|
-
|
|
32197
|
-
|
|
32198
|
-
|
|
32199
|
-
|
|
32200
|
-
|
|
32201
|
-
|
|
32202
|
-
|
|
32203
|
-
|
|
32204
|
-
|
|
32205
|
-
|
|
32206
|
-
|
|
32207
|
-
|
|
32208
|
-
|
|
32200
|
+
})))), filteredNavOptions.map((section) => {
|
|
32201
|
+
var _a;
|
|
32202
|
+
return /* @__PURE__ */ React.createElement("section", {
|
|
32203
|
+
className: "sps-side-nav__section",
|
|
32204
|
+
key: (_a = section.key) != null ? _a : section.sectionTitle
|
|
32205
|
+
}, section.sectionTitle && /* @__PURE__ */ React.createElement("div", {
|
|
32206
|
+
className: "sps-side-nav__section-title",
|
|
32207
|
+
style: { fontWeight: 400 }
|
|
32208
|
+
}, section.sectionTitle), section.navItems.map((item) => {
|
|
32209
|
+
var _a2;
|
|
32210
|
+
return /* @__PURE__ */ React.createElement(SpsSideNavBranch, {
|
|
32211
|
+
branch: __spreadProps(__spreadValues({}, item), {
|
|
32212
|
+
expanded: findParentBranches(item.subNavItems, activeNavItem)
|
|
32213
|
+
}),
|
|
32214
|
+
activeBranch,
|
|
32215
|
+
setActiveBranch: (branchName, key) => {
|
|
32216
|
+
handleNavAction(branchName, key);
|
|
32217
|
+
},
|
|
32218
|
+
key: (_a2 = item.key) != null ? _a2 : item.name
|
|
32219
|
+
});
|
|
32220
|
+
}));
|
|
32221
|
+
})));
|
|
32209
32222
|
};
|
|
32210
32223
|
const SpsSideNavExamples = {
|
|
32211
32224
|
usage: {
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
/** TODO: Fix circular deps, update to follow our patterns, then remove eslint override */
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import type { SpsIcon, TagKind } from "@spscommerce/ds-shared";
|
|
4
|
-
export interface
|
|
4
|
+
export interface SideNavItem {
|
|
5
5
|
name: string;
|
|
6
6
|
tag?: TagKind;
|
|
7
|
+
key?: string | number;
|
|
7
8
|
tagContent?: string;
|
|
8
|
-
subNavItems?:
|
|
9
|
+
subNavItems?: SideNavItem[];
|
|
9
10
|
icon?: SpsIcon;
|
|
10
11
|
}
|
|
11
12
|
export interface SideNavSection {
|
|
12
|
-
sectionTitle
|
|
13
|
-
|
|
13
|
+
sectionTitle?: string;
|
|
14
|
+
key?: string | number;
|
|
15
|
+
navItems: SideNavItem[];
|
|
14
16
|
}
|
|
15
|
-
export interface SideNavBranch extends
|
|
17
|
+
export interface SideNavBranch extends SideNavItem {
|
|
16
18
|
expanded: boolean;
|
|
17
19
|
}
|
|
18
20
|
export interface SpsSideNavProps {
|
|
19
21
|
title?: string;
|
|
20
22
|
titleIcon?: SpsIcon;
|
|
21
23
|
activeNavItem: string;
|
|
22
|
-
onNavChange?: (newNav: string) => void;
|
|
24
|
+
onNavChange?: (newNav: string, newNavKey?: string | number) => void;
|
|
23
25
|
navOptions: SideNavSection[];
|
|
24
26
|
tabs?: string[];
|
|
25
27
|
initialActiveTab?: string;
|
|
@@ -32,5 +34,5 @@ export interface SpsSideNavProps {
|
|
|
32
34
|
* @param nav SideNavItems[] array of navigation branches to be checked
|
|
33
35
|
* @param activeTab string currently active tab
|
|
34
36
|
*/
|
|
35
|
-
export declare const findParentBranches: (nav:
|
|
37
|
+
export declare const findParentBranches: (nav: SideNavItem[], activeTab: string) => boolean;
|
|
36
38
|
export declare const SpsSideNav: React.FC<SpsSideNavProps>;
|
|
@@ -4,6 +4,6 @@ import type { SideNavBranch } from "./SpsSideNav";
|
|
|
4
4
|
export interface SpsSideNavBranchProps {
|
|
5
5
|
branch: SideNavBranch;
|
|
6
6
|
activeBranch: string;
|
|
7
|
-
setActiveBranch: (activeChildBranchName: string) => void;
|
|
7
|
+
setActiveBranch: (activeChildBranchName: string, activeChildBranchKey?: string | number) => void;
|
|
8
8
|
}
|
|
9
9
|
export declare const SpsSideNavBranch: React.FC<SpsSideNavBranchProps>;
|
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": "5.
|
|
4
|
+
"version": "5.10.0",
|
|
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": "5.
|
|
32
|
-
"@spscommerce/ds-shared": "5.
|
|
33
|
-
"@spscommerce/positioning": "5.
|
|
34
|
-
"@spscommerce/utils": "5.
|
|
31
|
+
"@spscommerce/ds-colors": "5.10.0",
|
|
32
|
+
"@spscommerce/ds-shared": "5.10.0",
|
|
33
|
+
"@spscommerce/positioning": "5.10.0",
|
|
34
|
+
"@spscommerce/utils": "5.10.0",
|
|
35
35
|
"moment": "^2.25.3",
|
|
36
36
|
"moment-timezone": "^0.5.28",
|
|
37
37
|
"react": "^16.9.0",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@react-stately/collections": "^3.3.3",
|
|
42
|
-
"@spscommerce/ds-colors": "5.
|
|
43
|
-
"@spscommerce/ds-shared": "5.
|
|
44
|
-
"@spscommerce/positioning": "5.
|
|
45
|
-
"@spscommerce/utils": "5.
|
|
42
|
+
"@spscommerce/ds-colors": "5.10.0",
|
|
43
|
+
"@spscommerce/ds-shared": "5.10.0",
|
|
44
|
+
"@spscommerce/positioning": "5.10.0",
|
|
45
|
+
"@spscommerce/utils": "5.10.0",
|
|
46
46
|
"@testing-library/react": "^9.3.2",
|
|
47
47
|
"@types/prop-types": "^15.7.1",
|
|
48
48
|
"@types/react": "^16.9.0",
|