@telus-uds/components-base 1.50.0 → 1.51.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/CHANGELOG.md +14 -2
- package/component-docs.json +106 -8
- package/lib/Link/LinkBase.js +1 -1
- package/lib/MultiSelectFilter/ModalOverlay.js +24 -8
- package/lib/MultiSelectFilter/MultiSelectFilter.js +154 -21
- package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +62 -41
- package/lib/StepTracker/Step.js +35 -14
- package/lib/StepTracker/StepTracker.js +5 -2
- package/lib/StepTracker/dictionary.js +24 -4
- package/lib-module/Link/LinkBase.js +1 -1
- package/lib-module/MultiSelectFilter/ModalOverlay.js +25 -9
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +154 -23
- package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +64 -43
- package/lib-module/StepTracker/Step.js +35 -14
- package/lib-module/StepTracker/StepTracker.js +5 -2
- package/lib-module/StepTracker/dictionary.js +24 -4
- package/package.json +2 -2
- package/src/Link/LinkBase.jsx +3 -1
- package/src/MultiSelectFilter/ModalOverlay.jsx +30 -6
- package/src/MultiSelectFilter/MultiSelectFilter.jsx +142 -20
- package/src/QuickLinksFeature/QuickLinksFeatureItem.jsx +42 -35
- package/src/StepTracker/Step.jsx +34 -10
- package/src/StepTracker/StepTracker.jsx +11 -2
- package/src/StepTracker/dictionary.js +24 -4
- package/src/Typography/Typography.jsx +1 -0
|
@@ -56,6 +56,7 @@ const selectContainerStyle = _ref => {
|
|
|
56
56
|
} = _ref;
|
|
57
57
|
return {
|
|
58
58
|
textAlign,
|
|
59
|
+
outline: 'red',
|
|
59
60
|
width: contentMaxDimension,
|
|
60
61
|
overflow: 'hidden'
|
|
61
62
|
};
|
|
@@ -67,6 +68,15 @@ const selectImageContainerStyle = contentMaxDimension => ({
|
|
|
67
68
|
justifyContent: 'center',
|
|
68
69
|
alignItems: 'center'
|
|
69
70
|
});
|
|
71
|
+
|
|
72
|
+
const selectLinkToken = _ref2 => {
|
|
73
|
+
let {
|
|
74
|
+
outerBorderColor
|
|
75
|
+
} = _ref2;
|
|
76
|
+
return {
|
|
77
|
+
outerBorderColor
|
|
78
|
+
};
|
|
79
|
+
};
|
|
70
80
|
/**
|
|
71
81
|
* Component export along with QuickLinksFeature to be used as children
|
|
72
82
|
*
|
|
@@ -74,7 +84,7 @@ const selectImageContainerStyle = contentMaxDimension => ({
|
|
|
74
84
|
*/
|
|
75
85
|
|
|
76
86
|
|
|
77
|
-
const QuickLinksFeatureItem = /*#__PURE__*/(0, _react.forwardRef)((
|
|
87
|
+
const QuickLinksFeatureItem = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
78
88
|
let {
|
|
79
89
|
tokens,
|
|
80
90
|
variant,
|
|
@@ -82,52 +92,63 @@ const QuickLinksFeatureItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =
|
|
|
82
92
|
imageAccessibilityLabel,
|
|
83
93
|
imageSource,
|
|
84
94
|
...rest
|
|
85
|
-
} =
|
|
95
|
+
} = _ref3;
|
|
86
96
|
const viewport = (0, _ViewportProvider.useViewport)();
|
|
87
97
|
const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('QuickLinksFeatureItem', tokens, variant);
|
|
88
|
-
const [hover, setHover] = (0, _react.useState)(false);
|
|
89
|
-
const {
|
|
90
|
-
contentDirection,
|
|
91
|
-
contentSpace,
|
|
92
|
-
contentAlignItems,
|
|
93
|
-
contentMaxDimension,
|
|
94
|
-
imageDimension,
|
|
95
|
-
textAlign
|
|
96
|
-
} = getTokens({
|
|
97
|
-
viewport,
|
|
98
|
-
hover
|
|
99
|
-
});
|
|
100
98
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link.Link, {
|
|
101
99
|
ref: ref,
|
|
102
|
-
tokens: state => {
|
|
103
|
-
setHover(state.hover);
|
|
104
|
-
return getTokens(state);
|
|
105
|
-
},
|
|
106
100
|
...selectProps(rest),
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
tokens: state => selectLinkToken(getTokens(state)),
|
|
102
|
+
children: _ref4 => {
|
|
103
|
+
let {
|
|
104
|
+
hovered: hover,
|
|
105
|
+
pressed,
|
|
106
|
+
focused: focus
|
|
107
|
+
} = _ref4;
|
|
108
|
+
const {
|
|
109
|
+
contentDirection,
|
|
110
|
+
contentSpace,
|
|
111
|
+
contentAlignItems,
|
|
109
112
|
contentMaxDimension,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
113
|
+
imageDimension,
|
|
114
|
+
textLine,
|
|
115
|
+
gap,
|
|
116
|
+
...themeTokens
|
|
117
|
+
} = getTokens({
|
|
118
|
+
viewport,
|
|
119
|
+
hover,
|
|
120
|
+
pressed,
|
|
121
|
+
focus
|
|
122
|
+
});
|
|
123
|
+
const textStyle = { ...(0, _ThemeProvider.applyTextStyles)(themeTokens),
|
|
124
|
+
textDecorationLine: textLine
|
|
125
|
+
};
|
|
126
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
127
|
+
style: selectContainerStyle({ ...themeTokens,
|
|
128
|
+
contentMaxDimension
|
|
129
|
+
}),
|
|
130
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.StackWrap, {
|
|
131
|
+
direction: contentDirection,
|
|
132
|
+
space: contentSpace,
|
|
133
|
+
gap: gap,
|
|
134
|
+
tokens: {
|
|
135
|
+
alignItems: contentAlignItems
|
|
136
|
+
},
|
|
137
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
138
|
+
style: selectImageContainerStyle(contentMaxDimension),
|
|
139
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image.default, {
|
|
140
|
+
accessibilityIgnoresInvertColors: true,
|
|
141
|
+
imageAccessibilityLabel: imageAccessibilityLabel,
|
|
142
|
+
source: imageSource,
|
|
143
|
+
style: selectImageStyle(imageDimension)
|
|
144
|
+
})
|
|
145
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
146
|
+
style: textStyle,
|
|
147
|
+
children: children
|
|
148
|
+
})]
|
|
149
|
+
})
|
|
150
|
+
});
|
|
151
|
+
}
|
|
131
152
|
});
|
|
132
153
|
});
|
|
133
154
|
QuickLinksFeatureItem.displayName = 'QuickLinksFeatureItem';
|
package/lib/StepTracker/Step.js
CHANGED
|
@@ -96,17 +96,18 @@ const selectKnobStyles = (_ref4, isCompleted, isCurrent) => {
|
|
|
96
96
|
height: knobSize,
|
|
97
97
|
width: knobSize,
|
|
98
98
|
...(isCompleted && {
|
|
99
|
-
backgroundColor: knobCompletedBackgroundColor,
|
|
100
|
-
borderColor: knobCompletedBorderColor,
|
|
101
|
-
paddingLeft: knobCompletedPaddingLeft,
|
|
102
|
-
paddingTop: knobCompletedPaddingTop
|
|
103
|
-
}),
|
|
104
|
-
...(isCurrent && {
|
|
105
99
|
backgroundColor: knobCurrentBackgroundColor,
|
|
106
100
|
borderColor: knobCurrentBorderColor,
|
|
107
101
|
borderWidth: knobCurrentBorderWidth,
|
|
108
102
|
paddingLeft: knobCurrentPaddingLeft,
|
|
109
103
|
paddingTop: knobCurrentPaddingTop
|
|
104
|
+
}),
|
|
105
|
+
...(isCurrent && {
|
|
106
|
+
backgroundColor: knobCompletedBackgroundColor,
|
|
107
|
+
borderColor: knobCompletedBorderColor,
|
|
108
|
+
borderWidth: knobCurrentBorderWidth,
|
|
109
|
+
paddingLeft: knobCompletedPaddingLeft,
|
|
110
|
+
paddingTop: knobCompletedPaddingTop
|
|
110
111
|
})
|
|
111
112
|
};
|
|
112
113
|
};
|
|
@@ -128,7 +129,26 @@ const selectLabelContainerStyles = _ref5 => {
|
|
|
128
129
|
};
|
|
129
130
|
};
|
|
130
131
|
|
|
131
|
-
const
|
|
132
|
+
const selectStepLabelStyles = (_ref6, themeOptions, isCurrent) => {
|
|
133
|
+
let {
|
|
134
|
+
stepLabelColor,
|
|
135
|
+
labelCurrentColor,
|
|
136
|
+
stepLabelFontWeight,
|
|
137
|
+
stepLabelFontSize,
|
|
138
|
+
stepLabelFontName,
|
|
139
|
+
stepLabelLineHeight
|
|
140
|
+
} = _ref6;
|
|
141
|
+
return (0, _ThemeProvider.applyTextStyles)({
|
|
142
|
+
color: isCurrent ? labelCurrentColor : stepLabelColor,
|
|
143
|
+
fontSize: stepLabelFontSize,
|
|
144
|
+
lineHeight: stepLabelLineHeight,
|
|
145
|
+
fontWeight: stepLabelFontWeight,
|
|
146
|
+
fontName: stepLabelFontName,
|
|
147
|
+
themeOptions
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const selectLabelStyles = (_ref7, themeOptions, isCurrent) => {
|
|
132
152
|
let {
|
|
133
153
|
labelColor,
|
|
134
154
|
labelCurrentColor,
|
|
@@ -137,7 +157,7 @@ const selectLabelStyles = (_ref6, themeOptions, isCurrent) => {
|
|
|
137
157
|
labelFontWeight,
|
|
138
158
|
labelFontName,
|
|
139
159
|
labelLineHeight
|
|
140
|
-
} =
|
|
160
|
+
} = _ref7;
|
|
141
161
|
return (0, _ThemeProvider.applyTextStyles)({
|
|
142
162
|
color: isCurrent ? labelCurrentColor : labelColor,
|
|
143
163
|
fontSize: labelFontSize,
|
|
@@ -164,7 +184,7 @@ const getStepTestID = (isCompleted, isCurrent) => {
|
|
|
164
184
|
*/
|
|
165
185
|
|
|
166
186
|
|
|
167
|
-
const Step =
|
|
187
|
+
const Step = _ref8 => {
|
|
168
188
|
let {
|
|
169
189
|
label,
|
|
170
190
|
name,
|
|
@@ -173,11 +193,12 @@ const Step = _ref7 => {
|
|
|
173
193
|
stepIndex = 0,
|
|
174
194
|
tokens,
|
|
175
195
|
...rest
|
|
176
|
-
} =
|
|
196
|
+
} = _ref8;
|
|
177
197
|
const {
|
|
178
198
|
completedIcon,
|
|
179
199
|
showStepLabel,
|
|
180
200
|
showStepName,
|
|
201
|
+
textStepTrackerLabel,
|
|
181
202
|
...themeTokens
|
|
182
203
|
} = tokens;
|
|
183
204
|
const isFirst = stepIndex === 0;
|
|
@@ -211,11 +232,11 @@ const Step = _ref7 => {
|
|
|
211
232
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
212
233
|
style: [staticStyles.knob, selectKnobStyles(themeTokens, isCompleted, isCurrent)],
|
|
213
234
|
testID: getStepTestID(isCompleted, isCurrent),
|
|
214
|
-
children: [isCompleted && completedIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
235
|
+
children: [(isCompleted && completedIcon || isCurrent && !completedIcon) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
236
|
+
style: selectCurrentInnerStyles(themeTokens)
|
|
237
|
+
}), isCurrent && completedIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
215
238
|
icon: completedIcon,
|
|
216
239
|
tokens: selectCompletedIconTokens(themeTokens)
|
|
217
|
-
}), isCurrent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
218
|
-
style: selectCurrentInnerStyles(themeTokens)
|
|
219
240
|
})]
|
|
220
241
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
221
242
|
style: [staticStyles.connector, !isLast && selectConnectorStyles(themeTokens, isCompleted)]
|
|
@@ -223,7 +244,7 @@ const Step = _ref7 => {
|
|
|
223
244
|
}), showStepLabel && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
224
245
|
style: [staticStyles.stepLabelContainer, selectLabelContainerStyles(tokens)],
|
|
225
246
|
children: [showStepName && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
|
|
226
|
-
style: [staticStyles.centeredText,
|
|
247
|
+
style: [staticStyles.centeredText, selectStepLabelStyles(tokens, themeOptions, isCurrent)],
|
|
227
248
|
children: name
|
|
228
249
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
|
|
229
250
|
direction: "row",
|
|
@@ -131,13 +131,16 @@ const StepTracker = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
|
|
|
131
131
|
} = (0, _ThemeProvider.useThemeTokens)('StepTracker', tokens, variant, {
|
|
132
132
|
viewport
|
|
133
133
|
});
|
|
134
|
+
const {
|
|
135
|
+
textStepTrackerLabel
|
|
136
|
+
} = themeTokens;
|
|
134
137
|
const getCopy = (0, _useCopy.default)({
|
|
135
138
|
dictionary,
|
|
136
139
|
copy
|
|
137
140
|
});
|
|
138
|
-
const stepTrackerLabel = showStepTrackerLabel ? getCopy('stepTrackerLabel').replace('%{stepNumber}', current < steps.length ? current + 1 : steps.length).replace('%{stepCount}', steps.length).replace('%{stepLabel}', current < steps.length ? steps[current] : steps[steps.length - 1]) : '';
|
|
141
|
+
const stepTrackerLabel = showStepTrackerLabel ? (typeof copy === 'string' ? getCopy(textStepTrackerLabel ?? 1).stepTrackerLabel : getCopy('stepTrackerLabel')).replace('%{stepNumber}', current < steps.length ? current + 1 : steps.length).replace('%{stepCount}', steps.length).replace('%{stepLabel}', current < steps.length ? steps[current] : steps[steps.length - 1]) : '';
|
|
139
142
|
|
|
140
|
-
const getStepLabel = index => themeTokens.showStepLabel ? getCopy('stepLabel').replace('%{stepNumber}', index + 1) : '';
|
|
143
|
+
const getStepLabel = index => themeTokens.showStepLabel ? (typeof copy === 'string' ? getCopy(textStepTrackerLabel ?? 1).stepLabel : getCopy('stepLabel')).replace('%{stepNumber}', index + 1) : '';
|
|
141
144
|
|
|
142
145
|
const {
|
|
143
146
|
themeOptions
|
|
@@ -6,12 +6,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _default = {
|
|
8
8
|
en: {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
1: {
|
|
10
|
+
stepLabel: 'Step %{stepNumber}',
|
|
11
|
+
stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
|
|
12
|
+
},
|
|
13
|
+
2: {
|
|
14
|
+
stepLabel: '%{stepNumber}.',
|
|
15
|
+
stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
|
|
16
|
+
},
|
|
17
|
+
3: {
|
|
18
|
+
stepLabel: 'Step %{stepNumber}',
|
|
19
|
+
stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
|
|
20
|
+
}
|
|
11
21
|
},
|
|
12
22
|
fr: {
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
1: {
|
|
24
|
+
stepLabel: 'Étape %{stepNumber}',
|
|
25
|
+
stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
|
|
26
|
+
},
|
|
27
|
+
2: {
|
|
28
|
+
stepLabel: '%{stepNumber}.',
|
|
29
|
+
stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
|
|
30
|
+
},
|
|
31
|
+
3: {
|
|
32
|
+
stepLabel: 'Étape %{stepNumber}',
|
|
33
|
+
stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
|
|
34
|
+
}
|
|
15
35
|
}
|
|
16
36
|
};
|
|
17
37
|
exports.default = _default;
|
|
@@ -201,7 +201,7 @@ const LinkBase = /*#__PURE__*/forwardRef((_ref6, ref) => {
|
|
|
201
201
|
},
|
|
202
202
|
children: /*#__PURE__*/_jsx(Text, {
|
|
203
203
|
style: [textStyles, blockTextStyles, staticStyles.baseline],
|
|
204
|
-
children: children
|
|
204
|
+
children: typeof children === 'function' ? children(linkState) : children
|
|
205
205
|
})
|
|
206
206
|
});
|
|
207
207
|
}
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import View from "react-native-web/dist/exports/View";
|
|
4
4
|
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
5
5
|
import { Portal } from '@gorhom/portal';
|
|
6
|
-
import {
|
|
6
|
+
import { useCopy, copyPropTypes, getTokensPropType, variantProp } from '../utils';
|
|
7
7
|
import { useViewport } from '../ViewportProvider';
|
|
8
8
|
import { useThemeTokens } from '../ThemeProvider';
|
|
9
9
|
import dictionary from './dictionary';
|
|
@@ -16,7 +16,6 @@ const staticStyles = StyleSheet.create({
|
|
|
16
16
|
flex: 1,
|
|
17
17
|
// Grow to maxWidth when possible, shrink when not possible
|
|
18
18
|
position: 'absolute',
|
|
19
|
-
height: 330,
|
|
20
19
|
zIndex: 10000 // Position on top of all the other overlays, including backdrops and modals
|
|
21
20
|
|
|
22
21
|
},
|
|
@@ -62,6 +61,11 @@ const ModalOverlay = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
62
61
|
let {
|
|
63
62
|
children,
|
|
64
63
|
isReady = false,
|
|
64
|
+
maxHeight,
|
|
65
|
+
maxHeightSize,
|
|
66
|
+
maxWidthSize,
|
|
67
|
+
minHeight,
|
|
68
|
+
minWidth,
|
|
65
69
|
overlaidPosition,
|
|
66
70
|
onLayout,
|
|
67
71
|
variant,
|
|
@@ -74,9 +78,18 @@ const ModalOverlay = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
74
78
|
viewport,
|
|
75
79
|
maxWidth: false
|
|
76
80
|
});
|
|
81
|
+
const containerWidthHeight = {
|
|
82
|
+
minWidth,
|
|
83
|
+
minHeight,
|
|
84
|
+
...(tokens.maxWidth && maxWidthSize && {
|
|
85
|
+
maxWidth: maxWidthSize
|
|
86
|
+
}),
|
|
87
|
+
...(maxHeight && maxHeightSize && {
|
|
88
|
+
maxHeight: maxHeightSize
|
|
89
|
+
})
|
|
90
|
+
};
|
|
77
91
|
const {
|
|
78
|
-
closeIcon: CloseIconComponent
|
|
79
|
-
maxWidth
|
|
92
|
+
closeIcon: CloseIconComponent
|
|
80
93
|
} = themeTokens;
|
|
81
94
|
const getCopy = useCopy({
|
|
82
95
|
dictionary,
|
|
@@ -87,9 +100,7 @@ const ModalOverlay = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
87
100
|
children: /*#__PURE__*/_jsx(View, {
|
|
88
101
|
ref: ref,
|
|
89
102
|
onLayout: onLayout,
|
|
90
|
-
style: [overlaidPosition,
|
|
91
|
-
minWidth: maxWidth
|
|
92
|
-
}, staticStyles.positioner, !isReady && staticStyles.hidden],
|
|
103
|
+
style: [overlaidPosition, containerWidthHeight, staticStyles.positioner, !isReady && staticStyles.hidden],
|
|
93
104
|
children: /*#__PURE__*/_jsxs(Card, {
|
|
94
105
|
tokens: selectPaddingContainerStyles(themeTokens),
|
|
95
106
|
children: [/*#__PURE__*/_jsx(View, {
|
|
@@ -98,8 +109,7 @@ const ModalOverlay = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
98
109
|
onPress: onClose,
|
|
99
110
|
icon: CloseIconComponent,
|
|
100
111
|
accessibilityRole: "button",
|
|
101
|
-
accessibilityLabel: closeLabel
|
|
102
|
-
tokens: selectTokens('IconButton', themeTokens, 'close')
|
|
112
|
+
accessibilityLabel: closeLabel
|
|
103
113
|
})
|
|
104
114
|
}), children]
|
|
105
115
|
})
|
|
@@ -115,6 +125,12 @@ ModalOverlay.propTypes = {
|
|
|
115
125
|
left: PropTypes.number,
|
|
116
126
|
width: PropTypes.number
|
|
117
127
|
}),
|
|
128
|
+
minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
129
|
+
minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
130
|
+
maxHeightSize: PropTypes.number,
|
|
131
|
+
maxWidthSize: PropTypes.number,
|
|
132
|
+
maxHeight: PropTypes.bool,
|
|
133
|
+
maxWidth: PropTypes.bool,
|
|
118
134
|
onLayout: PropTypes.func,
|
|
119
135
|
variant: variantProp.propType,
|
|
120
136
|
tokens: getTokensPropType('Modal'),
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider';
|
|
3
|
+
import { useThemeTokens, useThemeTokensCallback, applyTextStyles } from '../ThemeProvider';
|
|
4
4
|
import { containUniqueFields, getTokensPropType, getPressHandlersWithArgs, selectTokens, useOverlaidPosition, useCopy, useMultipleInputValues, useResponsiveProp, variantProp } from '../utils';
|
|
5
5
|
import dictionary from './dictionary';
|
|
6
|
+
import { useViewport } from '../ViewportProvider';
|
|
6
7
|
import Box from '../Box';
|
|
7
8
|
import { Button, ButtonDropdown } from '../Button';
|
|
8
9
|
import { CheckboxGroup } from '../Checkbox';
|
|
@@ -13,6 +14,7 @@ import StackView from '../StackView';
|
|
|
13
14
|
import Typography from '../Typography';
|
|
14
15
|
import { TextButton } from '../Link';
|
|
15
16
|
import ModalOverlay from './ModalOverlay';
|
|
17
|
+
import Modal from '../Modal';
|
|
16
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
19
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -54,6 +56,7 @@ const MultiSelectFilter = _ref3 => {
|
|
|
54
56
|
tokens,
|
|
55
57
|
items = [],
|
|
56
58
|
values,
|
|
59
|
+
maxHeight = false,
|
|
57
60
|
initialValues,
|
|
58
61
|
maxValues,
|
|
59
62
|
onChange,
|
|
@@ -63,6 +66,7 @@ const MultiSelectFilter = _ref3 => {
|
|
|
63
66
|
rowLimit = 12,
|
|
64
67
|
...rest
|
|
65
68
|
} = _ref3;
|
|
69
|
+
const viewport = useViewport();
|
|
66
70
|
const {
|
|
67
71
|
currentValues,
|
|
68
72
|
setValues
|
|
@@ -73,6 +77,9 @@ const MultiSelectFilter = _ref3 => {
|
|
|
73
77
|
onChange,
|
|
74
78
|
readOnly
|
|
75
79
|
});
|
|
80
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
81
|
+
const [checkedIds, setCheckedIds] = useState(currentValues ?? []);
|
|
82
|
+
const [maxWidth, setMaxWidth] = useState(false);
|
|
76
83
|
const themeTokens = useThemeTokens('ButtonDropdown', tokens, variant);
|
|
77
84
|
const getItemTokens = useThemeTokensCallback('ButtonDropdown', tokens, variant);
|
|
78
85
|
|
|
@@ -82,10 +89,34 @@ const MultiSelectFilter = _ref3 => {
|
|
|
82
89
|
dictionary,
|
|
83
90
|
copy
|
|
84
91
|
});
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
92
|
+
const colSizeNotMobile = items.length > rowLimit ? 2 : 1;
|
|
93
|
+
const colSize = viewport !== 'xs' ? colSizeNotMobile : 1;
|
|
94
|
+
const itemsLengthNotMobile = items.length > 24 ? items.length / 2 : rowLimit;
|
|
88
95
|
const isSelected = currentValues.length > 0;
|
|
96
|
+
const rowLength = viewport !== 'xs' ? itemsLengthNotMobile : items.length;
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (colSize === 1) return setMaxWidth(false);
|
|
99
|
+
return colSize === 2 && setMaxWidth(true);
|
|
100
|
+
}, [colSize]);
|
|
101
|
+
const {
|
|
102
|
+
headerFontColor,
|
|
103
|
+
headerFontSize,
|
|
104
|
+
buttonDirection,
|
|
105
|
+
headerFontWeight,
|
|
106
|
+
headerLineHeight,
|
|
107
|
+
subHeaderFontWeight,
|
|
108
|
+
subHeaderFontSize,
|
|
109
|
+
maxHeightSize,
|
|
110
|
+
maxWidthSize,
|
|
111
|
+
subHeaderLineHeight,
|
|
112
|
+
minHeight,
|
|
113
|
+
minWidth
|
|
114
|
+
} = useThemeTokens('MultiSelectFilter', tokens, { ...variant,
|
|
115
|
+
maxHeight,
|
|
116
|
+
maxWidth
|
|
117
|
+
}, {
|
|
118
|
+
viewport
|
|
119
|
+
});
|
|
89
120
|
const uniqueFields = ['id', 'label'];
|
|
90
121
|
|
|
91
122
|
if (!containUniqueFields(items, uniqueFields)) {
|
|
@@ -109,6 +140,11 @@ const MultiSelectFilter = _ref3 => {
|
|
|
109
140
|
setIsOpen(false);
|
|
110
141
|
};
|
|
111
142
|
|
|
143
|
+
const onClear = () => {
|
|
144
|
+
setCheckedIds(() => []);
|
|
145
|
+
onApply([]);
|
|
146
|
+
};
|
|
147
|
+
|
|
112
148
|
const {
|
|
113
149
|
align,
|
|
114
150
|
offsets
|
|
@@ -116,9 +152,7 @@ const MultiSelectFilter = _ref3 => {
|
|
|
116
152
|
xs: {
|
|
117
153
|
align: {
|
|
118
154
|
top: 'top',
|
|
119
|
-
left: 'left'
|
|
120
|
-
bottom: 'bottom',
|
|
121
|
-
right: 'right'
|
|
155
|
+
left: 'left'
|
|
122
156
|
}
|
|
123
157
|
},
|
|
124
158
|
sm: {
|
|
@@ -131,6 +165,16 @@ const MultiSelectFilter = _ref3 => {
|
|
|
131
165
|
}
|
|
132
166
|
}
|
|
133
167
|
});
|
|
168
|
+
const headerStyles = applyTextStyles({
|
|
169
|
+
fontSize: headerFontSize,
|
|
170
|
+
fontWeight: headerFontWeight,
|
|
171
|
+
fontColor: headerFontColor
|
|
172
|
+
});
|
|
173
|
+
const subeHeaderStyles = applyTextStyles({
|
|
174
|
+
fontSize: subHeaderFontSize,
|
|
175
|
+
fontWeight: subHeaderFontWeight,
|
|
176
|
+
fontColor: selectSubTitleTokens(themeTokens)
|
|
177
|
+
});
|
|
134
178
|
const {
|
|
135
179
|
overlaidPosition,
|
|
136
180
|
onTargetLayout,
|
|
@@ -151,20 +195,96 @@ const MultiSelectFilter = _ref3 => {
|
|
|
151
195
|
onChange: handleChange,
|
|
152
196
|
tokens: getButtonTokens,
|
|
153
197
|
inactive: inactive
|
|
154
|
-
}, id), isOpen && /*#__PURE__*/_jsxs(
|
|
198
|
+
}, id), isOpen && viewport === 'xs' && /*#__PURE__*/_jsxs(Modal, {
|
|
199
|
+
isOpen: isOpen,
|
|
200
|
+
onClose: () => setIsOpen(false),
|
|
201
|
+
children: [/*#__PURE__*/_jsx(Row, {
|
|
202
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
203
|
+
tokens: { ...headerStyles,
|
|
204
|
+
lineHeight: headerLineHeight
|
|
205
|
+
},
|
|
206
|
+
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label.toLowerCase())
|
|
207
|
+
})
|
|
208
|
+
}), subtitle && /*#__PURE__*/_jsxs(_Fragment, {
|
|
209
|
+
children: [/*#__PURE__*/_jsx(Spacer, {
|
|
210
|
+
space: 5
|
|
211
|
+
}), /*#__PURE__*/_jsx(Row, {
|
|
212
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
213
|
+
tokens: { ...subeHeaderStyles,
|
|
214
|
+
lineHeight: subHeaderLineHeight
|
|
215
|
+
},
|
|
216
|
+
children: subtitle
|
|
217
|
+
})
|
|
218
|
+
})]
|
|
219
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
220
|
+
space: 4
|
|
221
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
222
|
+
scroll: true,
|
|
223
|
+
children: /*#__PURE__*/_jsx(Row, {
|
|
224
|
+
distribute: "between",
|
|
225
|
+
children: [...Array(colSize).keys()].map(i => /*#__PURE__*/_jsxs(Col, {
|
|
226
|
+
xs: 12 / colSize,
|
|
227
|
+
children: [/*#__PURE__*/_jsx(CheckboxGroup, {
|
|
228
|
+
items: items.slice(i * rowLength, (i + 1) * rowLength),
|
|
229
|
+
checkedIds: checkedIds,
|
|
230
|
+
onChange: e => setCheckedIds(e, i)
|
|
231
|
+
}), /*#__PURE__*/_jsx(Spacer, {
|
|
232
|
+
size: 4
|
|
233
|
+
})]
|
|
234
|
+
}, i))
|
|
235
|
+
})
|
|
236
|
+
}), /*#__PURE__*/_jsx(Divider, {
|
|
237
|
+
variant: selectDividerToknes({ ...themeTokens,
|
|
238
|
+
width: 'full'
|
|
239
|
+
}),
|
|
240
|
+
space: 4
|
|
241
|
+
}), /*#__PURE__*/_jsx(Row, {
|
|
242
|
+
horizontalAlign: buttonDirection === 'column' ? 'center' : 'start',
|
|
243
|
+
children: /*#__PURE__*/_jsxs(StackView, {
|
|
244
|
+
direction: buttonDirection,
|
|
245
|
+
space: 3,
|
|
246
|
+
tokens: {
|
|
247
|
+
alignItems: 'center',
|
|
248
|
+
...(viewport === 'xs' && {
|
|
249
|
+
flexGrow: 1
|
|
250
|
+
})
|
|
251
|
+
},
|
|
252
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
253
|
+
onPress: () => onApply(checkedIds),
|
|
254
|
+
variant: {
|
|
255
|
+
size: 'small',
|
|
256
|
+
priority: 'high',
|
|
257
|
+
...(viewport === 'xs' && {
|
|
258
|
+
width: 'full'
|
|
259
|
+
})
|
|
260
|
+
},
|
|
261
|
+
children: getCopy('applyButtonLabel')
|
|
262
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
263
|
+
children: /*#__PURE__*/_jsx(TextButton, {
|
|
264
|
+
onPress: () => onClear(),
|
|
265
|
+
children: getCopy('clearButtonLabel')
|
|
266
|
+
})
|
|
267
|
+
})]
|
|
268
|
+
})
|
|
269
|
+
})]
|
|
270
|
+
}), isOpen && viewport !== 'xs' && /*#__PURE__*/_jsxs(ModalOverlay, {
|
|
155
271
|
overlaidPosition: overlaidPosition,
|
|
156
|
-
variant: {
|
|
157
|
-
width: colSize > 1 ? 'size576' : 's'
|
|
158
|
-
},
|
|
159
272
|
onClose: () => setIsOpen(false),
|
|
160
|
-
|
|
273
|
+
maxHeight: maxHeight,
|
|
274
|
+
maxHeightSize: maxHeightSize,
|
|
275
|
+
maxWidthSize: maxWidthSize,
|
|
276
|
+
minHeight: minHeight,
|
|
277
|
+
minWidth: minWidth,
|
|
278
|
+
tokens: { ...tokens,
|
|
279
|
+
maxWidth
|
|
280
|
+
},
|
|
161
281
|
copy: copy,
|
|
162
282
|
isReady: isReady,
|
|
163
283
|
onLayout: onTargetLayout,
|
|
164
284
|
children: [/*#__PURE__*/_jsx(Row, {
|
|
165
285
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
166
|
-
|
|
167
|
-
|
|
286
|
+
tokens: { ...headerStyles,
|
|
287
|
+
lineHeight: headerLineHeight
|
|
168
288
|
},
|
|
169
289
|
children: getCopy('filterByLabel').replace(/%\{filterCategory\}/g, label.toLowerCase())
|
|
170
290
|
})
|
|
@@ -173,10 +293,9 @@ const MultiSelectFilter = _ref3 => {
|
|
|
173
293
|
space: 5
|
|
174
294
|
}), /*#__PURE__*/_jsx(Row, {
|
|
175
295
|
children: /*#__PURE__*/_jsx(Typography, {
|
|
176
|
-
|
|
177
|
-
|
|
296
|
+
tokens: { ...subeHeaderStyles,
|
|
297
|
+
lineHeight: subHeaderLineHeight
|
|
178
298
|
},
|
|
179
|
-
tokens: selectSubTitleTokens(themeTokens),
|
|
180
299
|
children: subtitle
|
|
181
300
|
})
|
|
182
301
|
})]
|
|
@@ -189,7 +308,7 @@ const MultiSelectFilter = _ref3 => {
|
|
|
189
308
|
children: [...Array(colSize).keys()].map(i => /*#__PURE__*/_jsxs(Col, {
|
|
190
309
|
xs: 12 / colSize,
|
|
191
310
|
children: [/*#__PURE__*/_jsx(CheckboxGroup, {
|
|
192
|
-
items: items.slice(i *
|
|
311
|
+
items: items.slice(i * rowLength, (i + 1) * rowLength),
|
|
193
312
|
checkedIds: checkedIds,
|
|
194
313
|
onChange: e => setCheckedIds(e, i)
|
|
195
314
|
}), /*#__PURE__*/_jsx(Spacer, {
|
|
@@ -203,22 +322,29 @@ const MultiSelectFilter = _ref3 => {
|
|
|
203
322
|
}),
|
|
204
323
|
space: 4
|
|
205
324
|
}), /*#__PURE__*/_jsx(Row, {
|
|
325
|
+
horizontalAlign: buttonDirection === 'column' ? 'center' : 'start',
|
|
206
326
|
children: /*#__PURE__*/_jsxs(StackView, {
|
|
207
|
-
direction:
|
|
327
|
+
direction: buttonDirection,
|
|
208
328
|
space: 3,
|
|
209
329
|
tokens: {
|
|
210
|
-
alignItems: 'center'
|
|
330
|
+
alignItems: 'center',
|
|
331
|
+
...(viewport === 'xs' && {
|
|
332
|
+
flexGrow: 1
|
|
333
|
+
})
|
|
211
334
|
},
|
|
212
335
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
213
336
|
onPress: () => onApply(checkedIds),
|
|
214
337
|
variant: {
|
|
215
338
|
size: 'small',
|
|
216
|
-
priority: 'high'
|
|
339
|
+
priority: 'high',
|
|
340
|
+
...(viewport === 'xs' && {
|
|
341
|
+
width: 'full'
|
|
342
|
+
})
|
|
217
343
|
},
|
|
218
344
|
children: getCopy('applyButtonLabel')
|
|
219
345
|
}), /*#__PURE__*/_jsx(Box, {
|
|
220
346
|
children: /*#__PURE__*/_jsx(TextButton, {
|
|
221
|
-
onPress: () =>
|
|
347
|
+
onPress: () => onClear(),
|
|
222
348
|
children: getCopy('clearButtonLabel')
|
|
223
349
|
})
|
|
224
350
|
})]
|
|
@@ -292,6 +418,11 @@ MultiSelectFilter.propTypes = {
|
|
|
292
418
|
*/
|
|
293
419
|
maxValues: PropTypes.number,
|
|
294
420
|
|
|
421
|
+
/**
|
|
422
|
+
* If provided sets maxHeight to be active
|
|
423
|
+
*/
|
|
424
|
+
maxHeight: PropTypes.bool,
|
|
425
|
+
|
|
295
426
|
/**
|
|
296
427
|
* If provided, this function is called when the current selection is changed
|
|
297
428
|
* and is passed an array of the `id`s of all currently selected `items`.
|