@zohodesk/components 1.6.34 → 1.6.35
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/CHANGELOG.md +4 -0
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +20 -0
- package/assets/Appearance/dark/themes/blue/blue_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/dark/themes/green/green_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/dark/themes/orange/orange_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/dark/themes/red/red_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/dark/themes/yellow/yellow_componentsCTA_DarkModifyCategory.module.css +2 -0
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +20 -0
- package/assets/Appearance/light/themes/blue/blue_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/light/themes/green/green_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/light/themes/orange/orange_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/light/themes/red/red_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/light/themes/yellow/yellow_componentsCTA_LightModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +20 -0
- package/assets/Appearance/pureDark/themes/blue/blue_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/themes/green/green_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/themes/orange/orange_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/themes/red/red_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/assets/Appearance/pureDark/themes/yellow/yellow_componentsCTA_PureDarkModifyCategory.module.css +2 -0
- package/cbt.config.js +1 -0
- package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +497 -497
- package/es/index.d.ts +39 -0
- package/es/index.js +12 -12
- package/es/v1/Tab/Tab.js +159 -0
- package/es/v1/Tab/TabList.js +153 -0
- package/es/v1/Tab/TabMoreMenu.js +245 -0
- package/es/v1/Tab/TabPanel.js +51 -0
- package/es/v1/Tab/Tabs.js +125 -0
- package/es/v1/Tab/__tests__/Tab.spec.js +1082 -0
- package/es/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +4933 -0
- package/es/v1/Tab/constants/index.js +112 -0
- package/es/v1/Tab/constants/presets.js +36 -0
- package/es/v1/Tab/context.js +19 -0
- package/es/v1/Tab/core/Tab.js +60 -0
- package/es/v1/Tab/core/TabList.js +51 -0
- package/es/v1/Tab/core/TabListFocusScope.js +18 -0
- package/es/v1/Tab/core/TabPanel.js +54 -0
- package/es/v1/Tab/core/Tabs.js +45 -0
- package/es/v1/Tab/core/index.js +6 -0
- package/es/v1/Tab/css/Tab_v1.module.css +335 -0
- package/es/v1/Tab/css/cssJSLogic.js +1 -0
- package/es/v1/Tab/css/tab.cva.js +205 -0
- package/es/v1/Tab/index.js +8 -0
- package/es/v1/Tab/props/defaultProps.js +55 -0
- package/es/v1/Tab/props/propTypes.js +221 -0
- package/es/v1/Tab/utils/pinSelectedTab.js +44 -0
- package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +497 -497
- package/lib/index.d.ts +39 -0
- package/lib/index.js +270 -173
- package/lib/v1/Tab/Tab.js +180 -0
- package/lib/v1/Tab/TabList.js +191 -0
- package/lib/v1/Tab/TabMoreMenu.js +284 -0
- package/lib/v1/Tab/TabPanel.js +64 -0
- package/lib/v1/Tab/Tabs.js +151 -0
- package/lib/v1/Tab/__tests__/Tab.spec.js +1174 -0
- package/lib/v1/Tab/__tests__/__snapshots__/Tab.spec.js.snap +4933 -0
- package/lib/v1/Tab/constants/index.js +113 -0
- package/lib/v1/Tab/constants/presets.js +64 -0
- package/lib/v1/Tab/context.js +30 -0
- package/lib/v1/Tab/core/Tab.js +89 -0
- package/lib/v1/Tab/core/TabList.js +82 -0
- package/lib/v1/Tab/core/TabListFocusScope.js +28 -0
- package/lib/v1/Tab/core/TabPanel.js +85 -0
- package/lib/v1/Tab/core/Tabs.js +63 -0
- package/lib/v1/Tab/core/index.js +109 -0
- package/lib/v1/Tab/css/Tab_v1.module.css +335 -0
- package/lib/v1/Tab/css/cssJSLogic.js +25 -0
- package/lib/v1/Tab/css/tab.cva.js +192 -0
- package/lib/v1/Tab/index.js +159 -0
- package/lib/v1/Tab/props/defaultProps.js +69 -0
- package/lib/v1/Tab/props/propTypes.js +246 -0
- package/lib/v1/Tab/utils/pinSelectedTab.js +59 -0
- package/package.json +13 -11
- package/tsconfig.jest.json +5 -0
- package/tsconfig.json +9 -0
- package/ut.config.js +2 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { SIZE, VARIANT, POSITION, LABEL_STYLE, ACTIVATION, ICON_PLACEMENT, ICON_SPACING, TEXT_TRANSFORM, TEXT_TRUNCATE, PANEL_SCROLL } from "../constants";
|
|
3
|
+
const valueType = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
|
4
|
+
const renderableType = PropTypes.oneOfType([PropTypes.node, PropTypes.func]);
|
|
5
|
+
const classType = PropTypes.string;
|
|
6
|
+
const tabSlotClasses = {
|
|
7
|
+
tab: classType,
|
|
8
|
+
content: classType,
|
|
9
|
+
iconBox: classType,
|
|
10
|
+
tabText: classType
|
|
11
|
+
};
|
|
12
|
+
const moreMenuSlotClasses = {
|
|
13
|
+
moreWrapper: classType,
|
|
14
|
+
more: classType,
|
|
15
|
+
moreBox: classType,
|
|
16
|
+
moreListWrapper: classType,
|
|
17
|
+
moreMenuHeight: classType,
|
|
18
|
+
moreItem: classType,
|
|
19
|
+
moreItemIcon: classType,
|
|
20
|
+
search: classType,
|
|
21
|
+
emptyStateContainer: classType,
|
|
22
|
+
emptyStateTitle: classType
|
|
23
|
+
};
|
|
24
|
+
const groupSlotClasses = {
|
|
25
|
+
root: classType,
|
|
26
|
+
list: classType,
|
|
27
|
+
panel: classType,
|
|
28
|
+
...tabSlotClasses,
|
|
29
|
+
...moreMenuSlotClasses
|
|
30
|
+
};
|
|
31
|
+
const moreMenuType = PropTypes.shape({
|
|
32
|
+
iconName: PropTypes.string,
|
|
33
|
+
iconSize: PropTypes.number,
|
|
34
|
+
ariaLabel: PropTypes.string,
|
|
35
|
+
searchThreshold: PropTypes.number,
|
|
36
|
+
searchPlaceholder: PropTypes.string,
|
|
37
|
+
searchErrorText: PropTypes.string,
|
|
38
|
+
searchBoxSize: PropTypes.string,
|
|
39
|
+
renderTarget: renderableType,
|
|
40
|
+
onScroll: PropTypes.func,
|
|
41
|
+
defaultPosition: PropTypes.string,
|
|
42
|
+
positionsOffset: PropTypes.object,
|
|
43
|
+
targetOffset: PropTypes.object
|
|
44
|
+
});
|
|
45
|
+
/** Raw Popup-HOC options for the overflow menu, authored via `customProps.popup`. */
|
|
46
|
+
|
|
47
|
+
const popupOptionsShape = {
|
|
48
|
+
isAbsolutePositioningNeeded: PropTypes.bool,
|
|
49
|
+
isOutsideScrollBlocked: PropTypes.bool,
|
|
50
|
+
popupGroup: PropTypes.string,
|
|
51
|
+
isArrow: PropTypes.bool,
|
|
52
|
+
scrollDebounceTime: PropTypes.number,
|
|
53
|
+
closeOnScroll: PropTypes.bool,
|
|
54
|
+
customOrder: PropTypes.arrayOf(PropTypes.string),
|
|
55
|
+
sizeModifiers: PropTypes.oneOfType([PropTypes.func, PropTypes.arrayOf(PropTypes.func)]),
|
|
56
|
+
needResizeHandling: PropTypes.bool
|
|
57
|
+
};
|
|
58
|
+
export const Tabs_propTypes = {
|
|
59
|
+
children: PropTypes.node,
|
|
60
|
+
selectedValue: valueType,
|
|
61
|
+
defaultValue: valueType,
|
|
62
|
+
onChange: PropTypes.func,
|
|
63
|
+
position: PropTypes.oneOf(Object.values(POSITION)),
|
|
64
|
+
labelStyle: PropTypes.oneOf(Object.values(LABEL_STYLE)),
|
|
65
|
+
activation: PropTypes.oneOf(Object.values(ACTIVATION)),
|
|
66
|
+
size: PropTypes.oneOf(Object.values(SIZE)),
|
|
67
|
+
variant: PropTypes.oneOf(Object.values(VARIANT)),
|
|
68
|
+
isFullWidth: PropTypes.bool,
|
|
69
|
+
hasScroll: PropTypes.bool,
|
|
70
|
+
hasSurface: PropTypes.bool,
|
|
71
|
+
hasListBorder: PropTypes.bool,
|
|
72
|
+
hasListPadding: PropTypes.bool,
|
|
73
|
+
textTransform: PropTypes.oneOf(Object.values(TEXT_TRANSFORM)),
|
|
74
|
+
textTruncate: PropTypes.oneOf(Object.values(TEXT_TRUNCATE)),
|
|
75
|
+
iconPlacement: PropTypes.oneOf(Object.values(ICON_PLACEMENT)),
|
|
76
|
+
iconSpacing: PropTypes.oneOf(ICON_SPACING),
|
|
77
|
+
uniqueId: PropTypes.string,
|
|
78
|
+
customClass: PropTypes.shape(groupSlotClasses),
|
|
79
|
+
customProps: PropTypes.shape({
|
|
80
|
+
root: PropTypes.object
|
|
81
|
+
}),
|
|
82
|
+
customAttributes: PropTypes.shape({
|
|
83
|
+
root: PropTypes.object
|
|
84
|
+
}),
|
|
85
|
+
a11yAttributes: PropTypes.object,
|
|
86
|
+
customId: PropTypes.string,
|
|
87
|
+
testId: PropTypes.string,
|
|
88
|
+
dataSelectorId: PropTypes.string
|
|
89
|
+
};
|
|
90
|
+
const tabItemShape = PropTypes.shape({
|
|
91
|
+
value: valueType.isRequired,
|
|
92
|
+
text: PropTypes.string,
|
|
93
|
+
iconName: PropTypes.string,
|
|
94
|
+
iconSize: PropTypes.number,
|
|
95
|
+
isDisabled: PropTypes.bool,
|
|
96
|
+
ariaLabel: PropTypes.string,
|
|
97
|
+
title: PropTypes.string,
|
|
98
|
+
tourId: PropTypes.string,
|
|
99
|
+
tagName: PropTypes.string,
|
|
100
|
+
isAnchor: PropTypes.bool,
|
|
101
|
+
a11yAttributes: PropTypes.object,
|
|
102
|
+
href: PropTypes.string,
|
|
103
|
+
target: PropTypes.string,
|
|
104
|
+
rel: PropTypes.string,
|
|
105
|
+
renderIcon: renderableType,
|
|
106
|
+
renderBefore: renderableType,
|
|
107
|
+
renderAfter: renderableType,
|
|
108
|
+
customClass: PropTypes.shape(tabSlotClasses),
|
|
109
|
+
customId: PropTypes.string,
|
|
110
|
+
testId: PropTypes.string,
|
|
111
|
+
dataSelectorId: PropTypes.string
|
|
112
|
+
});
|
|
113
|
+
export const TabList_propTypes = {
|
|
114
|
+
children: PropTypes.node,
|
|
115
|
+
items: PropTypes.arrayOf(tabItemShape),
|
|
116
|
+
minVisibleTabs: PropTypes.number,
|
|
117
|
+
moreMenu: moreMenuType,
|
|
118
|
+
ariaLabel: PropTypes.string,
|
|
119
|
+
ariaLabelledBy: PropTypes.string,
|
|
120
|
+
customClass: PropTypes.shape({
|
|
121
|
+
list: classType,
|
|
122
|
+
...moreMenuSlotClasses
|
|
123
|
+
}),
|
|
124
|
+
customProps: PropTypes.shape({
|
|
125
|
+
focusScopeProps: PropTypes.object,
|
|
126
|
+
DropBoxProps: PropTypes.object,
|
|
127
|
+
ListItemProps: PropTypes.object,
|
|
128
|
+
TextBoxIconProps: PropTypes.object,
|
|
129
|
+
popup: PropTypes.shape(popupOptionsShape)
|
|
130
|
+
}),
|
|
131
|
+
customAttributes: PropTypes.shape({
|
|
132
|
+
list: PropTypes.object
|
|
133
|
+
}),
|
|
134
|
+
a11yAttributes: PropTypes.object,
|
|
135
|
+
customId: PropTypes.string,
|
|
136
|
+
testId: PropTypes.string,
|
|
137
|
+
dataSelectorId: PropTypes.string
|
|
138
|
+
};
|
|
139
|
+
export const Tab_propTypes = {
|
|
140
|
+
value: valueType.isRequired,
|
|
141
|
+
text: PropTypes.string,
|
|
142
|
+
children: PropTypes.node,
|
|
143
|
+
isDisabled: PropTypes.bool,
|
|
144
|
+
ariaLabel: PropTypes.string,
|
|
145
|
+
title: PropTypes.string,
|
|
146
|
+
tourId: PropTypes.string,
|
|
147
|
+
tagName: PropTypes.string,
|
|
148
|
+
isAnchor: PropTypes.bool,
|
|
149
|
+
href: PropTypes.string,
|
|
150
|
+
target: PropTypes.string,
|
|
151
|
+
rel: PropTypes.string,
|
|
152
|
+
iconName: PropTypes.string,
|
|
153
|
+
iconSize: PropTypes.number,
|
|
154
|
+
renderIcon: renderableType,
|
|
155
|
+
renderBefore: renderableType,
|
|
156
|
+
renderAfter: renderableType,
|
|
157
|
+
onClick: PropTypes.func,
|
|
158
|
+
getRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
159
|
+
customClass: PropTypes.shape(tabSlotClasses),
|
|
160
|
+
customProps: PropTypes.shape({
|
|
161
|
+
text: PropTypes.object,
|
|
162
|
+
icon: PropTypes.object
|
|
163
|
+
}),
|
|
164
|
+
customAttributes: PropTypes.shape({
|
|
165
|
+
tab: PropTypes.object,
|
|
166
|
+
content: PropTypes.object,
|
|
167
|
+
iconBox: PropTypes.object,
|
|
168
|
+
tabText: PropTypes.object
|
|
169
|
+
}),
|
|
170
|
+
a11yAttributes: PropTypes.object,
|
|
171
|
+
customId: PropTypes.string,
|
|
172
|
+
testId: PropTypes.string,
|
|
173
|
+
dataSelectorId: PropTypes.string
|
|
174
|
+
};
|
|
175
|
+
export const TabPanel_propTypes = {
|
|
176
|
+
value: valueType.isRequired,
|
|
177
|
+
children: PropTypes.node,
|
|
178
|
+
shouldUnmount: PropTypes.bool,
|
|
179
|
+
isStatic: PropTypes.bool,
|
|
180
|
+
scroll: PropTypes.oneOf(Object.values(PANEL_SCROLL)),
|
|
181
|
+
customClass: PropTypes.shape({
|
|
182
|
+
panel: classType
|
|
183
|
+
}),
|
|
184
|
+
customAttributes: PropTypes.shape({
|
|
185
|
+
panel: PropTypes.object
|
|
186
|
+
}),
|
|
187
|
+
a11yAttributes: PropTypes.object,
|
|
188
|
+
customId: PropTypes.string,
|
|
189
|
+
testId: PropTypes.string,
|
|
190
|
+
dataSelectorId: PropTypes.string
|
|
191
|
+
};
|
|
192
|
+
export const TabMoreMenu_propTypes = {
|
|
193
|
+
items: PropTypes.arrayOf(tabItemShape),
|
|
194
|
+
classes: PropTypes.object,
|
|
195
|
+
moreMenu: moreMenuType,
|
|
196
|
+
selectedValue: valueType,
|
|
197
|
+
onSelect: PropTypes.func,
|
|
198
|
+
moreRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
199
|
+
customProps: PropTypes.shape({
|
|
200
|
+
focusScopeProps: PropTypes.object,
|
|
201
|
+
DropBoxProps: PropTypes.object,
|
|
202
|
+
ListItemProps: PropTypes.object,
|
|
203
|
+
TextBoxIconProps: PropTypes.object
|
|
204
|
+
}),
|
|
205
|
+
customId: PropTypes.string,
|
|
206
|
+
testId: PropTypes.string,
|
|
207
|
+
dataSelectorId: PropTypes.string,
|
|
208
|
+
|
|
209
|
+
/* Popup HOC passthrough, authored via TabList's customProps.popup (see Popup.js getters) */
|
|
210
|
+
...popupOptionsShape,
|
|
211
|
+
|
|
212
|
+
/* injected by Popup() */
|
|
213
|
+
isPopupOpen: PropTypes.bool,
|
|
214
|
+
isPopupReady: PropTypes.bool,
|
|
215
|
+
position: PropTypes.string,
|
|
216
|
+
togglePopup: PropTypes.func,
|
|
217
|
+
closePopupOnly: PropTypes.func,
|
|
218
|
+
getTargetRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
219
|
+
getContainerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
220
|
+
removeClose: PropTypes.func
|
|
221
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default function pinSelectedTab({
|
|
2
|
+
dataList,
|
|
3
|
+
visible,
|
|
4
|
+
overflow,
|
|
5
|
+
selectedValue
|
|
6
|
+
}) {
|
|
7
|
+
if (!overflow || overflow.length === 0) {
|
|
8
|
+
return {
|
|
9
|
+
visible,
|
|
10
|
+
overflow: overflow || []
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const overflowIndex = overflow.findIndex(item => item.value === selectedValue);
|
|
15
|
+
|
|
16
|
+
if (overflowIndex === -1) {
|
|
17
|
+
return {
|
|
18
|
+
visible,
|
|
19
|
+
overflow
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const selectedItem = overflow[overflowIndex];
|
|
24
|
+
const withoutSelected = overflow.filter((_item, index) => index !== overflowIndex);
|
|
25
|
+
|
|
26
|
+
if (visible.length === 0) {
|
|
27
|
+
return {
|
|
28
|
+
visible: [selectedItem],
|
|
29
|
+
overflow: withoutSelected
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const demoted = visible[visible.length - 1];
|
|
34
|
+
const nextVisible = visible.slice(0, -1).concat(selectedItem);
|
|
35
|
+
const nextOverflow = withoutSelected.concat(demoted);
|
|
36
|
+
const order = new Map(dataList.map((item, index) => [item.value, index]));
|
|
37
|
+
|
|
38
|
+
const byDeclarationOrder = (a, b) => order.get(a.value) - order.get(b.value);
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
visible: nextVisible.sort(byDeclarationOrder),
|
|
42
|
+
overflow: nextOverflow.sort(byDeclarationOrder)
|
|
43
|
+
};
|
|
44
|
+
}
|