@databricks/design-system 1.11.0 → 1.12.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/common-1fb3eeb9.js +35 -0
- package/dist/common-1fb3eeb9.js.map +1 -0
- package/dist/common-819b45d4.js +15 -0
- package/dist/common-819b45d4.js.map +1 -0
- package/dist/design-system/DesignSystemProvider/DesignSystemProvider.d.ts.map +1 -1
- package/dist/design-system/DialogCombobox/DialogCombobox.d.ts +10 -0
- package/dist/design-system/DialogCombobox/DialogCombobox.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxButtonContainer.d.ts +2 -0
- package/dist/design-system/DialogCombobox/DialogComboboxButtonContainer.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxContent.d.ts +14 -0
- package/dist/design-system/DialogCombobox/DialogComboboxContent.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxCountBadge.d.ts +2 -0
- package/dist/design-system/DialogCombobox/DialogComboboxCountBadge.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxLoadingSpinner.d.ts +2 -0
- package/dist/design-system/DialogCombobox/DialogComboboxLoadingSpinner.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionControlledList.d.ts +9 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionControlledList.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionList.d.ts +10 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionList.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionListCheckboxItem.d.ts +11 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionListCheckboxItem.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionListSearch.d.ts +7 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionListSearch.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionListSelectItem.d.ts +10 -0
- package/dist/design-system/DialogCombobox/DialogComboboxOptionListSelectItem.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxSectionHeader.d.ts +2 -0
- package/dist/design-system/DialogCombobox/DialogComboboxSectionHeader.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxSeparator.d.ts +2 -0
- package/dist/design-system/DialogCombobox/DialogComboboxSeparator.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/DialogComboboxTrigger.d.ts +15 -0
- package/dist/design-system/DialogCombobox/DialogComboboxTrigger.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/hooks/useDialogComboboxContext.d.ts +2 -0
- package/dist/design-system/DialogCombobox/hooks/useDialogComboboxContext.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/hooks/useDialogComboboxOptionListContext.d.ts +2 -0
- package/dist/design-system/DialogCombobox/hooks/useDialogComboboxOptionListContext.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/index.d.ts +14 -0
- package/dist/design-system/DialogCombobox/index.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/providers/DialogComboboxContext.d.ts +15 -0
- package/dist/design-system/DialogCombobox/providers/DialogComboboxContext.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/providers/DialogComboboxOptionListContext.d.ts +10 -0
- package/dist/design-system/DialogCombobox/providers/DialogComboboxOptionListContext.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/shared.d.ts +3 -0
- package/dist/design-system/DialogCombobox/shared.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/tests/DialogCombobox.test.d.ts +2 -0
- package/dist/design-system/DialogCombobox/tests/DialogCombobox.test.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxButtonContainer.test.d.ts +2 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxButtonContainer.test.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxContent.test.d.ts +2 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxContent.test.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxOptionList.test.d.ts +2 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxOptionList.test.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxOptionListCheckboxItem.test.d.ts +2 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxOptionListCheckboxItem.test.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxOptionListSelectItem.test.d.ts +2 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxOptionListSelectItem.test.d.ts.map +1 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxTrigger.test.d.ts +2 -0
- package/dist/design-system/DialogCombobox/tests/DialogComboboxTrigger.test.d.ts.map +1 -0
- package/dist/design-system/Drawer/Drawer.d.ts +6 -1
- package/dist/design-system/Drawer/Drawer.d.ts.map +1 -1
- package/dist/design-system/Notification/Notification.d.ts +1 -0
- package/dist/design-system/Notification/Notification.d.ts.map +1 -1
- package/dist/design-system/NotificationV2/NotificationV2.d.ts +1 -0
- package/dist/design-system/NotificationV2/NotificationV2.d.ts.map +1 -1
- package/dist/design-system/Sidebar/Sidebar.d.ts +3 -1
- package/dist/design-system/Sidebar/Sidebar.d.ts.map +1 -1
- package/dist/design-system/TableUI/TableUI.test.d.ts +2 -0
- package/dist/design-system/TableUI/TableUI.test.d.ts.map +1 -0
- package/dist/design-system/TableUI/index.d.ts +101 -0
- package/dist/design-system/TableUI/index.d.ts.map +1 -0
- package/dist/design-system/index.d.ts +2 -0
- package/dist/design-system/index.d.ts.map +1 -1
- package/dist/development/index.d.ts +0 -2
- package/dist/development/index.d.ts.map +1 -1
- package/dist/development.js +5 -1311
- package/dist/development.js.map +1 -1
- package/dist/index.js +4112 -541
- package/dist/index.js.map +1 -1
- package/dist/test-utils/common.d.ts +17 -0
- package/dist/test-utils/common.d.ts.map +1 -1
- package/dist/test-utils/enzyme/index.d.ts +1 -0
- package/dist/test-utils/enzyme/index.d.ts.map +1 -1
- package/dist/test-utils/enzyme/table.d.ts +49 -0
- package/dist/test-utils/enzyme/table.d.ts.map +1 -0
- package/dist/test-utils/enzyme/table.test.d.ts +2 -0
- package/dist/test-utils/enzyme/table.test.d.ts.map +1 -0
- package/dist/test-utils/enzyme/utils.d.ts +6 -0
- package/dist/test-utils/enzyme/utils.d.ts.map +1 -1
- package/dist/test-utils/enzyme.js +123 -18
- package/dist/test-utils/enzyme.js.map +1 -1
- package/dist/test-utils/rtl/index.d.ts +1 -0
- package/dist/test-utils/rtl/index.d.ts.map +1 -1
- package/dist/test-utils/rtl/table.d.ts +50 -0
- package/dist/test-utils/rtl/table.d.ts.map +1 -0
- package/dist/test-utils/rtl/table.test.d.ts +2 -0
- package/dist/test-utils/rtl/table.test.d.ts.map +1 -0
- package/dist/test-utils/rtl.js +109 -19
- package/dist/test-utils/rtl.js.map +1 -1
- package/dist/theme/colorList.d.ts +0 -1
- package/dist/theme/colorList.d.ts.map +1 -1
- package/dist/theme/colors.d.ts +0 -1
- package/dist/theme/colors.d.ts.map +1 -1
- package/dist/useDesignSystemTheme-6e6f5867.js +441 -0
- package/dist/useDesignSystemTheme-6e6f5867.js.map +1 -0
- package/dist/useDesignSystemTheme-ac536b0f.js +443 -0
- package/dist/useDesignSystemTheme-ac536b0f.js.map +1 -0
- package/package.json +3 -3
package/dist/development.js
CHANGED
|
@@ -1,1315 +1,9 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
-
import React__default, { createContext, useContext, useState, useEffect, forwardRef } from 'react';
|
|
3
|
-
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
4
|
-
import { u as useDesignSystemTheme, S as Spinner, c as useDesignSystemContext, i as importantify, j as Checkbox, h as Input, x as SearchIcon, d as CheckIcon, X as XCircleFillIcon, C as ChevronDownIcon, e as Tooltip, B as Button, b as CloseIcon, a as useDesignSystemFlags, T as Typography, y as SortAscendingIcon, z as SortDescendingIcon, E as SortUnsortedIcon } from './Spinner-140f57ac.js';
|
|
5
|
-
import * as Popover from '@radix-ui/react-popover';
|
|
6
2
|
import * as RadixSlider from '@radix-ui/react-slider';
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
9
|
-
import '
|
|
10
|
-
import 'lodash/endsWith';
|
|
11
|
-
import 'lodash/isBoolean';
|
|
12
|
-
import 'lodash/isNumber';
|
|
13
|
-
import 'lodash/isString';
|
|
14
|
-
import 'lodash/mapValues';
|
|
15
|
-
import '@emotion/unitless';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
5
|
+
import { u as useDesignSystemTheme } from './useDesignSystemTheme-6e6f5867.js';
|
|
16
6
|
import 'chroma-js';
|
|
17
|
-
import '@ant-design/icons';
|
|
18
|
-
|
|
19
|
-
const filterContextDefaults = {
|
|
20
|
-
label: '',
|
|
21
|
-
value: [],
|
|
22
|
-
isInsideFilter: false,
|
|
23
|
-
multiSelect: false,
|
|
24
|
-
setValue: () => {},
|
|
25
|
-
setIsControlled: () => {}
|
|
26
|
-
};
|
|
27
|
-
const FilterContext = /*#__PURE__*/createContext(filterContextDefaults);
|
|
28
|
-
const FilterContextProvider = _ref => {
|
|
29
|
-
let {
|
|
30
|
-
children,
|
|
31
|
-
value
|
|
32
|
-
} = _ref;
|
|
33
|
-
return jsx(FilterContext.Provider, {
|
|
34
|
-
value: value,
|
|
35
|
-
children: children
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const useFilterContext = () => {
|
|
40
|
-
return useContext(FilterContext);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const Filter = _ref => {
|
|
44
|
-
let {
|
|
45
|
-
children,
|
|
46
|
-
label,
|
|
47
|
-
value = [],
|
|
48
|
-
...props
|
|
49
|
-
} = _ref;
|
|
50
|
-
// Used to avoid infinite loop when value is controlled from within the component (FilterOptionControlledList)
|
|
51
|
-
// We can't remove setValue altogether because uncontrolled component users need to be able to set the value from root for trigger to update
|
|
52
|
-
const [isControlled, setIsControlled] = useState(false);
|
|
53
|
-
const [selectedValue, setSelectedValue] = useState(value);
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if ((!Array.isArray(selectedValue) || !Array.isArray(value)) && selectedValue !== value || selectedValue && value && selectedValue.length === value.length && selectedValue.every((v, i) => v === value[i])) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (!isControlled) {
|
|
59
|
-
setSelectedValue(value);
|
|
60
|
-
}
|
|
61
|
-
}, [value, isControlled, selectedValue]);
|
|
62
|
-
return jsx(FilterContextProvider, {
|
|
63
|
-
value: {
|
|
64
|
-
label,
|
|
65
|
-
value: selectedValue,
|
|
66
|
-
setValue: setSelectedValue,
|
|
67
|
-
setIsControlled,
|
|
68
|
-
isInsideFilter: true,
|
|
69
|
-
multiSelect: props.multiSelect
|
|
70
|
-
},
|
|
71
|
-
children: jsx(Root$1, {
|
|
72
|
-
...props,
|
|
73
|
-
children: children
|
|
74
|
-
})
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
const Root$1 = props => {
|
|
78
|
-
const {
|
|
79
|
-
children,
|
|
80
|
-
stayOpenOnSelection,
|
|
81
|
-
open,
|
|
82
|
-
multiSelect,
|
|
83
|
-
...restProps
|
|
84
|
-
} = props;
|
|
85
|
-
const {
|
|
86
|
-
value
|
|
87
|
-
} = useFilterContext();
|
|
88
|
-
const [isOpen, setIsOpen] = useState(!!open);
|
|
89
|
-
const handleOpenChange = open => {
|
|
90
|
-
setIsOpen(open);
|
|
91
|
-
};
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
if (!stayOpenOnSelection && (typeof stayOpenOnSelection === 'boolean' || !multiSelect)) {
|
|
94
|
-
setIsOpen(false);
|
|
95
|
-
}
|
|
96
|
-
}, [value, stayOpenOnSelection, multiSelect]);
|
|
97
|
-
return jsx(Popover.Root, {
|
|
98
|
-
open: open !== undefined ? open : isOpen,
|
|
99
|
-
onOpenChange: handleOpenChange,
|
|
100
|
-
...restProps,
|
|
101
|
-
children: children
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const getFilterButtonContainerStyles = theme => {
|
|
106
|
-
return /*#__PURE__*/css({
|
|
107
|
-
display: 'flex',
|
|
108
|
-
flexDirection: 'row',
|
|
109
|
-
justifyContent: 'flex-end',
|
|
110
|
-
alignItems: 'flex-end',
|
|
111
|
-
padding: "".concat(theme.spacing.sm, "px ").concat(theme.spacing.lg / 2, "px ").concat(theme.spacing.sm, "px ").concat(theme.spacing.lg / 2, "px"),
|
|
112
|
-
gap: theme.spacing.sm,
|
|
113
|
-
alignSelf: 'stretch'
|
|
114
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:getFilterButtonContainerStyles;");
|
|
115
|
-
};
|
|
116
|
-
const FilterButtonContainer = _ref => {
|
|
117
|
-
let {
|
|
118
|
-
children,
|
|
119
|
-
...restProps
|
|
120
|
-
} = _ref;
|
|
121
|
-
const {
|
|
122
|
-
theme
|
|
123
|
-
} = useDesignSystemTheme();
|
|
124
|
-
const {
|
|
125
|
-
isInsideFilter
|
|
126
|
-
} = useFilterContext();
|
|
127
|
-
if (!isInsideFilter) {
|
|
128
|
-
throw new Error('`FilterButtonContainer` must be used within `Filter`');
|
|
129
|
-
}
|
|
130
|
-
return jsx("div", {
|
|
131
|
-
...restProps,
|
|
132
|
-
css: getFilterButtonContainerStyles(theme),
|
|
133
|
-
children: children
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const FilterLoadingSpinner = props => {
|
|
138
|
-
const {
|
|
139
|
-
theme
|
|
140
|
-
} = useDesignSystemTheme();
|
|
141
|
-
return jsx(Spinner, {
|
|
142
|
-
css: /*#__PURE__*/css({
|
|
143
|
-
display: 'flex',
|
|
144
|
-
alignSelf: 'center',
|
|
145
|
-
justifyContent: 'center',
|
|
146
|
-
alignItems: 'center',
|
|
147
|
-
height: theme.general.heightSm,
|
|
148
|
-
width: theme.general.heightSm,
|
|
149
|
-
'> span': {
|
|
150
|
-
fontSize: 20
|
|
151
|
-
}
|
|
152
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:FilterLoadingSpinner;"),
|
|
153
|
-
...props
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
function _EMOTION_STRINGIFIED_CSS_ERROR__$6() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
158
|
-
const getContentWrapperStyles = (theme, _ref) => {
|
|
159
|
-
let {
|
|
160
|
-
maxHeight = '100vh',
|
|
161
|
-
maxWidth = '100vw',
|
|
162
|
-
minHeight = 0,
|
|
163
|
-
minWidth = 0
|
|
164
|
-
} = _ref;
|
|
165
|
-
return /*#__PURE__*/css({
|
|
166
|
-
maxHeight,
|
|
167
|
-
maxWidth,
|
|
168
|
-
minHeight,
|
|
169
|
-
minWidth,
|
|
170
|
-
background: theme.colors.backgroundPrimary,
|
|
171
|
-
color: theme.colors.textPrimary,
|
|
172
|
-
overflow: 'auto',
|
|
173
|
-
// Making sure the content popover overlaps the remove button when opens to the right
|
|
174
|
-
zIndex: theme.options.zIndexBase + 10,
|
|
175
|
-
boxSizing: 'border-box',
|
|
176
|
-
padding: "".concat(theme.spacing.xs, "px 0"),
|
|
177
|
-
border: "1px solid ".concat(theme.colors.border),
|
|
178
|
-
boxShadow: theme.general.shadowLow,
|
|
179
|
-
borderRadius: 4,
|
|
180
|
-
colorScheme: theme.isDarkMode ? 'dark' : 'light'
|
|
181
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:getContentWrapperStyles;");
|
|
182
|
-
};
|
|
183
|
-
var _ref3 = process.env.NODE_ENV === "production" ? {
|
|
184
|
-
name: "1ij1o5n",
|
|
185
|
-
styles: "display:flex;flex-direction:column;align-items:flex-start;justify-content:center"
|
|
186
|
-
} : {
|
|
187
|
-
name: "qbojwf-FilterContent",
|
|
188
|
-
styles: "display:flex;flex-direction:column;align-items:flex-start;justify-content:center;label:FilterContent;",
|
|
189
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$6
|
|
190
|
-
};
|
|
191
|
-
const FilterContent = /*#__PURE__*/forwardRef((_ref2, forwardedRef) => {
|
|
192
|
-
let {
|
|
193
|
-
children,
|
|
194
|
-
loading,
|
|
195
|
-
maxHeight,
|
|
196
|
-
maxWidth,
|
|
197
|
-
minHeight,
|
|
198
|
-
minWidth = 240,
|
|
199
|
-
align = 'start',
|
|
200
|
-
side = 'bottom',
|
|
201
|
-
sideOffset = 4,
|
|
202
|
-
...restProps
|
|
203
|
-
} = _ref2;
|
|
204
|
-
const {
|
|
205
|
-
theme
|
|
206
|
-
} = useDesignSystemTheme();
|
|
207
|
-
const {
|
|
208
|
-
label,
|
|
209
|
-
isInsideFilter
|
|
210
|
-
} = useFilterContext();
|
|
211
|
-
const {
|
|
212
|
-
getPopupContainer
|
|
213
|
-
} = useDesignSystemContext();
|
|
214
|
-
if (!isInsideFilter) {
|
|
215
|
-
throw new Error('`FilterContent` must be used within `Filter`');
|
|
216
|
-
}
|
|
217
|
-
return jsx(Popover.Portal, {
|
|
218
|
-
container: getPopupContainer && getPopupContainer(),
|
|
219
|
-
children: jsx(Popover.Content, {
|
|
220
|
-
"aria-label": "".concat(label, " filter options"),
|
|
221
|
-
"aria-busy": loading,
|
|
222
|
-
css: getContentWrapperStyles(theme, {
|
|
223
|
-
maxHeight,
|
|
224
|
-
maxWidth,
|
|
225
|
-
minHeight,
|
|
226
|
-
minWidth
|
|
227
|
-
}),
|
|
228
|
-
align: align,
|
|
229
|
-
side: side,
|
|
230
|
-
sideOffset: sideOffset,
|
|
231
|
-
...restProps,
|
|
232
|
-
ref: forwardedRef,
|
|
233
|
-
children: jsx("div", {
|
|
234
|
-
css: _ref3,
|
|
235
|
-
children: loading ? jsx(FilterLoadingSpinner, {
|
|
236
|
-
"aria-label": "Loading",
|
|
237
|
-
alt: "Loading spinner"
|
|
238
|
-
}) : children
|
|
239
|
-
})
|
|
240
|
-
})
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
const getCountBadgeStyles = theme => /*#__PURE__*/css(importantify({
|
|
245
|
-
display: 'inline-flex',
|
|
246
|
-
alignItems: 'center',
|
|
247
|
-
justifyContent: 'center',
|
|
248
|
-
boxSizing: 'border-box',
|
|
249
|
-
padding: "".concat(theme.spacing.xs / 2, "px ").concat(theme.spacing.xs, "px"),
|
|
250
|
-
background: theme.colors.tagDefault,
|
|
251
|
-
borderRadius: theme.general.borderRadiusBase,
|
|
252
|
-
fontWeight: theme.typography.typographyBoldFontWeight,
|
|
253
|
-
fontSize: theme.typography.fontSizeSm,
|
|
254
|
-
height: 20
|
|
255
|
-
}), process.env.NODE_ENV === "production" ? "" : ";label:getCountBadgeStyles;");
|
|
256
|
-
const FilterCountBadge = props => {
|
|
257
|
-
const {
|
|
258
|
-
theme
|
|
259
|
-
} = useDesignSystemTheme();
|
|
260
|
-
const {
|
|
261
|
-
value
|
|
262
|
-
} = useFilterContext();
|
|
263
|
-
return jsx("div", {
|
|
264
|
-
...props,
|
|
265
|
-
css: getCountBadgeStyles(theme),
|
|
266
|
-
children: Array.isArray(value) ? value.length : value ? 1 : 0
|
|
267
|
-
});
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const FilterOptionListContext = /*#__PURE__*/createContext({});
|
|
271
|
-
const FilterOptionListContextProvider = _ref => {
|
|
272
|
-
let {
|
|
273
|
-
children,
|
|
274
|
-
value
|
|
275
|
-
} = _ref;
|
|
276
|
-
return jsx(FilterOptionListContext.Provider, {
|
|
277
|
-
value: value,
|
|
278
|
-
children: children
|
|
279
|
-
});
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
const useFilterOptionListContext = () => {
|
|
283
|
-
return useContext(FilterOptionListContext);
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
const getFilterOptionItemWrapperStyles = theme => {
|
|
287
|
-
return /*#__PURE__*/css(importantify({
|
|
288
|
-
display: 'flex',
|
|
289
|
-
flexDirection: 'row',
|
|
290
|
-
alignItems: 'center',
|
|
291
|
-
justifyContent: 'flex-start',
|
|
292
|
-
alignSelf: 'stretch',
|
|
293
|
-
padding: '6px 32px 6px 12px',
|
|
294
|
-
lineHeight: theme.typography.lineHeightBase,
|
|
295
|
-
height: theme.typography.lineHeightBase,
|
|
296
|
-
cursor: 'pointer',
|
|
297
|
-
userSelect: 'none',
|
|
298
|
-
'&:hover': {
|
|
299
|
-
background: theme.colors.actionTertiaryBackgroundHover
|
|
300
|
-
}
|
|
301
|
-
}), process.env.NODE_ENV === "production" ? "" : ";label:getFilterOptionItemWrapperStyles;");
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
function _EMOTION_STRINGIFIED_CSS_ERROR__$5() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
305
|
-
var _ref2$3 = process.env.NODE_ENV === "production" ? {
|
|
306
|
-
name: "je8g23",
|
|
307
|
-
styles: "pointer-events:none"
|
|
308
|
-
} : {
|
|
309
|
-
name: "1v7dgvu-FilterOptionListCheckboxItem",
|
|
310
|
-
styles: "pointer-events:none;label:FilterOptionListCheckboxItem;",
|
|
311
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$5
|
|
312
|
-
};
|
|
313
|
-
const FilterOptionListCheckboxItem = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
314
|
-
let {
|
|
315
|
-
value,
|
|
316
|
-
checked,
|
|
317
|
-
indeterminate,
|
|
318
|
-
onChange,
|
|
319
|
-
children,
|
|
320
|
-
...props
|
|
321
|
-
} = _ref;
|
|
322
|
-
const {
|
|
323
|
-
theme
|
|
324
|
-
} = useDesignSystemTheme();
|
|
325
|
-
const {
|
|
326
|
-
isInsideFilterOptionList
|
|
327
|
-
} = useFilterOptionListContext();
|
|
328
|
-
if (!isInsideFilterOptionList) {
|
|
329
|
-
throw new Error('`FilterOptionListCheckboxItem` must be used within `FilterOptionList`');
|
|
330
|
-
}
|
|
331
|
-
const handleSelect = () => {
|
|
332
|
-
if (onChange) {
|
|
333
|
-
onChange(value);
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
return jsx("div", {
|
|
337
|
-
ref: ref,
|
|
338
|
-
role: "option"
|
|
339
|
-
// Using aria-selected instead of aria-checked because the parent listbox
|
|
340
|
-
,
|
|
341
|
-
"aria-selected": indeterminate ? false : checked,
|
|
342
|
-
css: [getFilterOptionItemWrapperStyles(theme), process.env.NODE_ENV === "production" ? "" : ";label:FilterOptionListCheckboxItem;"],
|
|
343
|
-
onClick: handleSelect,
|
|
344
|
-
...props,
|
|
345
|
-
children: jsx(Checkbox, {
|
|
346
|
-
isChecked: indeterminate ? null : checked,
|
|
347
|
-
css: _ref2$3
|
|
348
|
-
// Needed because Antd handles keyboard inputs as clicks
|
|
349
|
-
,
|
|
350
|
-
onClick: e => {
|
|
351
|
-
e.stopPropagation();
|
|
352
|
-
handleSelect();
|
|
353
|
-
},
|
|
354
|
-
children: children !== null && children !== void 0 ? children : value
|
|
355
|
-
})
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
const filterChildren = (children, searchValue) => {
|
|
360
|
-
var _React$Children$map;
|
|
361
|
-
return (_React$Children$map = React__default.Children.map(children, child => {
|
|
362
|
-
if (child !== null && child !== void 0 && child.props.value.toLowerCase().includes(searchValue)) {
|
|
363
|
-
return child;
|
|
364
|
-
}
|
|
365
|
-
return null;
|
|
366
|
-
})) === null || _React$Children$map === void 0 ? void 0 : _React$Children$map.filter(child => child);
|
|
367
|
-
};
|
|
368
|
-
const FilterOptionListSearch = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
369
|
-
var _filteredChildren, _filteredChildren$pro, _filteredChildren2;
|
|
370
|
-
let {
|
|
371
|
-
onChange,
|
|
372
|
-
children,
|
|
373
|
-
hasWrapper,
|
|
374
|
-
...restProps
|
|
375
|
-
} = _ref;
|
|
376
|
-
const {
|
|
377
|
-
theme
|
|
378
|
-
} = useDesignSystemTheme();
|
|
379
|
-
const {
|
|
380
|
-
isInsideFilterOptionList
|
|
381
|
-
} = useFilterOptionListContext();
|
|
382
|
-
const [searchValue, setSearchValue] = React__default.useState();
|
|
383
|
-
if (!isInsideFilterOptionList) {
|
|
384
|
-
throw new Error('`FilterOptionListSearch` must be used within `FilterOptionList`');
|
|
385
|
-
}
|
|
386
|
-
const handleOnChange = event => {
|
|
387
|
-
setSearchValue(event.target.value.toLowerCase());
|
|
388
|
-
};
|
|
389
|
-
let filteredChildren = children;
|
|
390
|
-
if (searchValue) {
|
|
391
|
-
filteredChildren = filterChildren(hasWrapper ? children.props.children : children, searchValue);
|
|
392
|
-
if (hasWrapper) {
|
|
393
|
-
filteredChildren = /*#__PURE__*/React__default.cloneElement(children, {}, filteredChildren);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return jsxs(Fragment, {
|
|
397
|
-
children: [jsx("div", {
|
|
398
|
-
css: /*#__PURE__*/css({
|
|
399
|
-
padding: "".concat(theme.spacing.sm, "px ").concat(theme.spacing.lg / 2, "px ").concat(theme.spacing.sm, "px"),
|
|
400
|
-
width: '100%',
|
|
401
|
-
boxSizing: 'border-box'
|
|
402
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:FilterOptionListSearch;"),
|
|
403
|
-
children: jsx(Input, {
|
|
404
|
-
ref: forwardedRef,
|
|
405
|
-
prefix: jsx(SearchIcon, {}),
|
|
406
|
-
placeholder: "Search",
|
|
407
|
-
onChange: handleOnChange,
|
|
408
|
-
value: searchValue,
|
|
409
|
-
...restProps
|
|
410
|
-
})
|
|
411
|
-
}), hasWrapper && (_filteredChildren = filteredChildren) !== null && _filteredChildren !== void 0 && (_filteredChildren$pro = _filteredChildren.props.children) !== null && _filteredChildren$pro !== void 0 && _filteredChildren$pro.length || !hasWrapper && (_filteredChildren2 = filteredChildren) !== null && _filteredChildren2 !== void 0 && _filteredChildren2.length ? filteredChildren : jsx("div", {
|
|
412
|
-
css: /*#__PURE__*/css({
|
|
413
|
-
color: theme.colors.textSecondary,
|
|
414
|
-
textAlign: 'center',
|
|
415
|
-
padding: '6px 32px 6px 12px',
|
|
416
|
-
width: '100%',
|
|
417
|
-
boxSizing: 'border-box'
|
|
418
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:FilterOptionListSearch;"),
|
|
419
|
-
children: "No results found"
|
|
420
|
-
})]
|
|
421
|
-
});
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
function _EMOTION_STRINGIFIED_CSS_ERROR__$4() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
425
|
-
var _ref2$2 = process.env.NODE_ENV === "production" ? {
|
|
426
|
-
name: "1cjitc6",
|
|
427
|
-
styles: "width:16px"
|
|
428
|
-
} : {
|
|
429
|
-
name: "1lwu3su-FilterOptionListSelectItem",
|
|
430
|
-
styles: "width:16px;label:FilterOptionListSelectItem;",
|
|
431
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$4
|
|
432
|
-
};
|
|
433
|
-
const FilterOptionListSelectItem = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
434
|
-
let {
|
|
435
|
-
value,
|
|
436
|
-
checked,
|
|
437
|
-
onChange,
|
|
438
|
-
children,
|
|
439
|
-
...props
|
|
440
|
-
} = _ref;
|
|
441
|
-
const {
|
|
442
|
-
theme
|
|
443
|
-
} = useDesignSystemTheme();
|
|
444
|
-
const {
|
|
445
|
-
isInsideFilterOptionList
|
|
446
|
-
} = useFilterOptionListContext();
|
|
447
|
-
if (!isInsideFilterOptionList) {
|
|
448
|
-
throw new Error('`FilterOptionListSelectItem` must be used within `FilterOptionList`');
|
|
449
|
-
}
|
|
450
|
-
const handleSelect = () => {
|
|
451
|
-
if (onChange) {
|
|
452
|
-
onChange(value);
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
return jsxs("div", {
|
|
456
|
-
ref: ref,
|
|
457
|
-
css: [getFilterOptionItemWrapperStyles(theme), {
|
|
458
|
-
'&:focus': {
|
|
459
|
-
background: theme.colors.actionTertiaryBackgroundHover,
|
|
460
|
-
outline: 'none'
|
|
461
|
-
}
|
|
462
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:FilterOptionListSelectItem;"],
|
|
463
|
-
...props,
|
|
464
|
-
onClick: handleSelect,
|
|
465
|
-
tabIndex: 0,
|
|
466
|
-
onKeyDown: e => {
|
|
467
|
-
switch (e.key) {
|
|
468
|
-
case 'ArrowDown':
|
|
469
|
-
e.preventDefault();
|
|
470
|
-
const nextSibling = e.currentTarget.nextElementSibling;
|
|
471
|
-
nextSibling === null || nextSibling === void 0 ? void 0 : nextSibling.focus();
|
|
472
|
-
break;
|
|
473
|
-
case 'ArrowUp':
|
|
474
|
-
e.preventDefault();
|
|
475
|
-
const previousSibling = e.currentTarget.previousElementSibling;
|
|
476
|
-
previousSibling === null || previousSibling === void 0 ? void 0 : previousSibling.focus();
|
|
477
|
-
break;
|
|
478
|
-
case ' ':
|
|
479
|
-
case 'Enter':
|
|
480
|
-
e.preventDefault();
|
|
481
|
-
handleSelect();
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
484
|
-
},
|
|
485
|
-
role: "option",
|
|
486
|
-
"aria-selected": checked,
|
|
487
|
-
children: [checked ? jsx(CheckIcon, {}) : jsx("div", {
|
|
488
|
-
css: _ref2$2
|
|
489
|
-
}), jsx("label", {
|
|
490
|
-
style: {
|
|
491
|
-
marginLeft: theme.spacing.sm,
|
|
492
|
-
cursor: 'pointer'
|
|
493
|
-
},
|
|
494
|
-
children: children !== null && children !== void 0 ? children : value
|
|
495
|
-
})]
|
|
496
|
-
});
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
function _EMOTION_STRINGIFIED_CSS_ERROR__$3() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
500
|
-
var _ref2$1 = process.env.NODE_ENV === "production" ? {
|
|
501
|
-
name: "6kz1wu",
|
|
502
|
-
styles: "display:flex;flex-direction:column;align-items:flex-start"
|
|
503
|
-
} : {
|
|
504
|
-
name: "160mr8t-FilterOptionControlledList",
|
|
505
|
-
styles: "display:flex;flex-direction:column;align-items:flex-start;label:FilterOptionControlledList;",
|
|
506
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$3
|
|
507
|
-
};
|
|
508
|
-
const FilterOptionControlledList = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
509
|
-
let {
|
|
510
|
-
options,
|
|
511
|
-
onChange,
|
|
512
|
-
loading,
|
|
513
|
-
withProgressiveLoading,
|
|
514
|
-
withSearch,
|
|
515
|
-
showSelectAndClearAll,
|
|
516
|
-
...restProps
|
|
517
|
-
} = _ref;
|
|
518
|
-
const {
|
|
519
|
-
isInsideFilter,
|
|
520
|
-
multiSelect,
|
|
521
|
-
value,
|
|
522
|
-
setValue,
|
|
523
|
-
setIsControlled
|
|
524
|
-
} = useFilterContext();
|
|
525
|
-
if (!isInsideFilter) {
|
|
526
|
-
throw new Error('`FilterOptionControlledList` must be used within `Filter`');
|
|
527
|
-
}
|
|
528
|
-
const isOptionChecked = options.reduce((acc, option) => {
|
|
529
|
-
acc[option] = value === null || value === void 0 ? void 0 : value.includes(option);
|
|
530
|
-
return acc;
|
|
531
|
-
}, {});
|
|
532
|
-
const handleUpdate = updatedValue => {
|
|
533
|
-
setIsControlled(true);
|
|
534
|
-
let newValue = [];
|
|
535
|
-
if (multiSelect) {
|
|
536
|
-
if (value.find(item => item === updatedValue)) {
|
|
537
|
-
newValue = value.filter(item => item !== updatedValue);
|
|
538
|
-
} else {
|
|
539
|
-
newValue = [...value, updatedValue];
|
|
540
|
-
}
|
|
541
|
-
} else {
|
|
542
|
-
newValue = [updatedValue];
|
|
543
|
-
}
|
|
544
|
-
setValue(newValue);
|
|
545
|
-
isOptionChecked[updatedValue] = !isOptionChecked[updatedValue];
|
|
546
|
-
if (onChange) {
|
|
547
|
-
onChange(newValue);
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
const handleSelectAll = () => {
|
|
551
|
-
setIsControlled(true);
|
|
552
|
-
if (value.length === options.length) {
|
|
553
|
-
setValue([]);
|
|
554
|
-
options.forEach(option => {
|
|
555
|
-
isOptionChecked[option] = false;
|
|
556
|
-
});
|
|
557
|
-
if (onChange) {
|
|
558
|
-
onChange([]);
|
|
559
|
-
}
|
|
560
|
-
} else {
|
|
561
|
-
setValue(options);
|
|
562
|
-
options.forEach(option => {
|
|
563
|
-
isOptionChecked[option] = true;
|
|
564
|
-
});
|
|
565
|
-
if (onChange) {
|
|
566
|
-
onChange(options);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
const renderedOptions = jsxs(Fragment, {
|
|
571
|
-
children: [showSelectAndClearAll && multiSelect && jsx(FilterOptionListCheckboxItem, {
|
|
572
|
-
value: "all",
|
|
573
|
-
onChange: handleSelectAll,
|
|
574
|
-
checked: value.length === options.length,
|
|
575
|
-
indeterminate: !!value.length && value.length !== options.length,
|
|
576
|
-
children: value.length === options.length ? 'Clear all' : 'Select all'
|
|
577
|
-
}), options === null || options === void 0 ? void 0 : options.map((option, key) => multiSelect ? jsx(FilterOptionListCheckboxItem, {
|
|
578
|
-
value: option,
|
|
579
|
-
checked: isOptionChecked[option],
|
|
580
|
-
onChange: handleUpdate,
|
|
581
|
-
children: option
|
|
582
|
-
}, key) : jsx(FilterOptionListSelectItem, {
|
|
583
|
-
value: option,
|
|
584
|
-
checked: isOptionChecked[option],
|
|
585
|
-
onChange: handleUpdate,
|
|
586
|
-
children: option
|
|
587
|
-
}, key))]
|
|
588
|
-
});
|
|
589
|
-
return jsx("div", {
|
|
590
|
-
ref: forwardedRef,
|
|
591
|
-
"aria-busy": loading,
|
|
592
|
-
css: _ref2$1,
|
|
593
|
-
...restProps,
|
|
594
|
-
children: jsx(FilterOptionListContextProvider, {
|
|
595
|
-
value: {
|
|
596
|
-
isInsideFilterOptionList: true
|
|
597
|
-
},
|
|
598
|
-
children: jsx(Fragment, {
|
|
599
|
-
children: loading ? withProgressiveLoading ? jsxs(Fragment, {
|
|
600
|
-
children: [withSearch ? jsx(FilterOptionListSearch, {
|
|
601
|
-
hasWrapper: true,
|
|
602
|
-
children: renderedOptions
|
|
603
|
-
}) : renderedOptions, jsx(FilterLoadingSpinner, {
|
|
604
|
-
"aria-label": "Loading",
|
|
605
|
-
alt: "Loading spinner"
|
|
606
|
-
})]
|
|
607
|
-
}) : jsx(FilterLoadingSpinner, {
|
|
608
|
-
"aria-label": "Loading",
|
|
609
|
-
alt: "Loading spinner"
|
|
610
|
-
}) : withSearch ? jsx(FilterOptionListSearch, {
|
|
611
|
-
hasWrapper: true,
|
|
612
|
-
children: renderedOptions
|
|
613
|
-
}) : renderedOptions
|
|
614
|
-
})
|
|
615
|
-
})
|
|
616
|
-
});
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
function _EMOTION_STRINGIFIED_CSS_ERROR__$2() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
620
|
-
var _ref2 = process.env.NODE_ENV === "production" ? {
|
|
621
|
-
name: "1pgv7dg",
|
|
622
|
-
styles: "display:flex;flex-direction:column;align-items:flex-start;width:100%"
|
|
623
|
-
} : {
|
|
624
|
-
name: "s7a3b7-FilterOptionList",
|
|
625
|
-
styles: "display:flex;flex-direction:column;align-items:flex-start;width:100%;label:FilterOptionList;",
|
|
626
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$2
|
|
627
|
-
};
|
|
628
|
-
const FilterOptionList = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
629
|
-
let {
|
|
630
|
-
children,
|
|
631
|
-
onChange,
|
|
632
|
-
loading,
|
|
633
|
-
withProgressiveLoading,
|
|
634
|
-
...restProps
|
|
635
|
-
} = _ref;
|
|
636
|
-
const {
|
|
637
|
-
isInsideFilter,
|
|
638
|
-
value
|
|
639
|
-
} = useFilterContext();
|
|
640
|
-
if (!isInsideFilter) {
|
|
641
|
-
throw new Error('`FilterOptionList` must be used within `Filter`');
|
|
642
|
-
}
|
|
643
|
-
useEffect(() => {
|
|
644
|
-
if (onChange) {
|
|
645
|
-
onChange(value);
|
|
646
|
-
}
|
|
647
|
-
}, [value, onChange]);
|
|
648
|
-
return jsx("div", {
|
|
649
|
-
ref: forwardedRef,
|
|
650
|
-
"aria-busy": loading,
|
|
651
|
-
role: "list",
|
|
652
|
-
css: _ref2,
|
|
653
|
-
...restProps,
|
|
654
|
-
children: jsx(FilterOptionListContextProvider, {
|
|
655
|
-
value: {
|
|
656
|
-
isInsideFilterOptionList: true
|
|
657
|
-
},
|
|
658
|
-
children: loading ? withProgressiveLoading ? jsxs(Fragment, {
|
|
659
|
-
children: [children, jsx(FilterLoadingSpinner, {
|
|
660
|
-
"aria-label": "Loading",
|
|
661
|
-
alt: "Loading spinner"
|
|
662
|
-
})]
|
|
663
|
-
}) : jsx(FilterLoadingSpinner, {
|
|
664
|
-
"aria-label": "Loading",
|
|
665
|
-
alt: "Loading spinner"
|
|
666
|
-
}) : children
|
|
667
|
-
})
|
|
668
|
-
});
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
const FilterSectionHeader = _ref => {
|
|
672
|
-
let {
|
|
673
|
-
children,
|
|
674
|
-
...props
|
|
675
|
-
} = _ref;
|
|
676
|
-
const {
|
|
677
|
-
theme
|
|
678
|
-
} = useDesignSystemTheme();
|
|
679
|
-
const {
|
|
680
|
-
isInsideFilter
|
|
681
|
-
} = useFilterContext();
|
|
682
|
-
if (!isInsideFilter) {
|
|
683
|
-
throw new Error('`FilterSectionHeader` must be used within `Filter`');
|
|
684
|
-
}
|
|
685
|
-
return jsx("div", {
|
|
686
|
-
...props,
|
|
687
|
-
css: /*#__PURE__*/css({
|
|
688
|
-
display: 'flex',
|
|
689
|
-
flexDirection: 'row',
|
|
690
|
-
alignItems: 'flex-start',
|
|
691
|
-
padding: "".concat(theme.spacing.xs, "px ").concat(theme.spacing.lg / 2, "px"),
|
|
692
|
-
alignSelf: 'stretch',
|
|
693
|
-
fontWeight: 400,
|
|
694
|
-
color: theme.colors.textSecondary
|
|
695
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:FilterSectionHeader;"),
|
|
696
|
-
children: children
|
|
697
|
-
});
|
|
698
|
-
};
|
|
699
|
-
|
|
700
|
-
const FilterSeparator = props => {
|
|
701
|
-
const {
|
|
702
|
-
theme
|
|
703
|
-
} = useDesignSystemTheme();
|
|
704
|
-
const {
|
|
705
|
-
isInsideFilter
|
|
706
|
-
} = useFilterContext();
|
|
707
|
-
if (!isInsideFilter) {
|
|
708
|
-
throw new Error('`FilterSeparator` must be used within `Filter`');
|
|
709
|
-
}
|
|
710
|
-
return jsx("div", {
|
|
711
|
-
...props,
|
|
712
|
-
css: /*#__PURE__*/css({
|
|
713
|
-
display: 'flex',
|
|
714
|
-
flexDirection: 'row',
|
|
715
|
-
alignItems: 'center',
|
|
716
|
-
margin: "".concat(theme.spacing.xs, "px ").concat(theme.spacing.lg / 2, "px"),
|
|
717
|
-
border: "1px solid ".concat(theme.colors.borderDecorative),
|
|
718
|
-
borderBottom: 0,
|
|
719
|
-
alignSelf: 'stretch'
|
|
720
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:FilterSeparator;")
|
|
721
|
-
});
|
|
722
|
-
};
|
|
723
|
-
|
|
724
|
-
const getTriggerWrapperStyles = removable => /*#__PURE__*/css(importantify({
|
|
725
|
-
display: 'inline-flex',
|
|
726
|
-
alignItems: 'center',
|
|
727
|
-
...(removable && {
|
|
728
|
-
'& > button:last-of-type': importantify({
|
|
729
|
-
borderBottomLeftRadius: 0,
|
|
730
|
-
borderTopLeftRadius: 0,
|
|
731
|
-
marginLeft: -1
|
|
732
|
-
})
|
|
733
|
-
})
|
|
734
|
-
}), process.env.NODE_ENV === "production" ? "" : ";label:getTriggerWrapperStyles;");
|
|
735
|
-
const getTriggerStyles = (theme, maxWidth, removable) => {
|
|
736
|
-
const removeButtonInteractionStyles = {
|
|
737
|
-
...(removable && {
|
|
738
|
-
zIndex: theme.options.zIndexBase + 2,
|
|
739
|
-
'&& + button': {
|
|
740
|
-
marginLeft: -1,
|
|
741
|
-
zIndex: theme.options.zIndexBase + 1
|
|
742
|
-
}
|
|
743
|
-
})
|
|
744
|
-
};
|
|
745
|
-
return /*#__PURE__*/css(importantify({
|
|
746
|
-
position: 'relative',
|
|
747
|
-
display: 'inline-flex',
|
|
748
|
-
alignItems: 'center',
|
|
749
|
-
maxWidth: maxWidth,
|
|
750
|
-
justifyContent: 'center',
|
|
751
|
-
background: 'transparent',
|
|
752
|
-
padding: '6px 8px 6px 12px',
|
|
753
|
-
boxSizing: 'border-box',
|
|
754
|
-
height: theme.general.heightSm,
|
|
755
|
-
border: "1px solid ".concat(theme.colors.actionDefaultBorderDefault),
|
|
756
|
-
borderRadius: 4,
|
|
757
|
-
color: theme.colors.textPrimary,
|
|
758
|
-
lineHeight: theme.typography.lineHeightBase,
|
|
759
|
-
cursor: 'pointer',
|
|
760
|
-
...(removable && {
|
|
761
|
-
borderBottomRightRadius: 0,
|
|
762
|
-
borderTopRightRadius: 0,
|
|
763
|
-
borderRightColor: 'transparent'
|
|
764
|
-
}),
|
|
765
|
-
'&:hover': {
|
|
766
|
-
background: theme.colors.actionDefaultBackgroundHover,
|
|
767
|
-
borderColor: theme.colors.actionDefaultBorderHover,
|
|
768
|
-
...removeButtonInteractionStyles
|
|
769
|
-
},
|
|
770
|
-
'&:focus': {
|
|
771
|
-
borderColor: theme.colors.actionDefaultBorderFocus,
|
|
772
|
-
...removeButtonInteractionStyles
|
|
773
|
-
}
|
|
774
|
-
}), process.env.NODE_ENV === "production" ? "" : ";label:getTriggerStyles;");
|
|
775
|
-
};
|
|
776
|
-
const FilterTrigger = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
777
|
-
let {
|
|
778
|
-
removable = false,
|
|
779
|
-
onRemove,
|
|
780
|
-
children,
|
|
781
|
-
maxWidth = 9999,
|
|
782
|
-
withCountBadge,
|
|
783
|
-
showBadgeAfterValueCount = 3,
|
|
784
|
-
allowClear = true,
|
|
785
|
-
controlled,
|
|
786
|
-
onClear,
|
|
787
|
-
...restProps
|
|
788
|
-
} = _ref;
|
|
789
|
-
const {
|
|
790
|
-
theme
|
|
791
|
-
} = useDesignSystemTheme();
|
|
792
|
-
const {
|
|
793
|
-
label,
|
|
794
|
-
value,
|
|
795
|
-
isInsideFilter,
|
|
796
|
-
multiSelect,
|
|
797
|
-
setValue
|
|
798
|
-
} = useFilterContext();
|
|
799
|
-
if (!isInsideFilter) {
|
|
800
|
-
throw new Error('`FilterTrigger` must be used within `Filter`');
|
|
801
|
-
}
|
|
802
|
-
const handleRemove = () => {
|
|
803
|
-
if (!onRemove) {
|
|
804
|
-
console.warn('Filter.Trigger: Attempted remove without providing onRemove handler');
|
|
805
|
-
} else {
|
|
806
|
-
onRemove();
|
|
807
|
-
}
|
|
808
|
-
};
|
|
809
|
-
const handleClear = e => {
|
|
810
|
-
e.stopPropagation();
|
|
811
|
-
if (controlled) {
|
|
812
|
-
setValue([]);
|
|
813
|
-
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
814
|
-
} else if (!onClear) {
|
|
815
|
-
console.warn('Filter.Trigger: Attempted clear without providing onClear handler');
|
|
816
|
-
} else {
|
|
817
|
-
onClear();
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
const [showTooltip, setShowTooltip] = React__default.useState();
|
|
821
|
-
const triggerContentRef = React__default.useRef(null);
|
|
822
|
-
useEffect(() => {
|
|
823
|
-
if ((value === null || value === void 0 ? void 0 : value.length) > showBadgeAfterValueCount) {
|
|
824
|
-
setShowTooltip(true);
|
|
825
|
-
} else if (triggerContentRef.current) {
|
|
826
|
-
const {
|
|
827
|
-
clientWidth,
|
|
828
|
-
scrollWidth
|
|
829
|
-
} = triggerContentRef.current;
|
|
830
|
-
setShowTooltip(clientWidth < scrollWidth);
|
|
831
|
-
}
|
|
832
|
-
}, [showBadgeAfterValueCount, value]);
|
|
833
|
-
const concatenatedValues = Array.isArray(value) ? value.join(', ') : value;
|
|
834
|
-
const displayedValues = jsx("span", {
|
|
835
|
-
children: concatenatedValues
|
|
836
|
-
});
|
|
837
|
-
let ariaLabel = "".concat(label, " filter");
|
|
838
|
-
if (value !== null && value !== void 0 && value.length) {
|
|
839
|
-
ariaLabel += multiSelect ? ", multiselectable, ".concat(value.length, " options selected: ").concat(concatenatedValues) : ", selected option: ".concat(concatenatedValues);
|
|
840
|
-
} else {
|
|
841
|
-
ariaLabel += multiSelect ? ', multiselectable, 0 options selected' : ', no option selected';
|
|
842
|
-
}
|
|
843
|
-
const triggerContent = children !== null && children !== void 0 ? children : jsxs(Popover.Trigger, {
|
|
844
|
-
"aria-label": ariaLabel,
|
|
845
|
-
ref: forwardedRef,
|
|
846
|
-
...restProps,
|
|
847
|
-
css: getTriggerStyles(theme, maxWidth, removable),
|
|
848
|
-
role: "listbox",
|
|
849
|
-
"aria-multiselectable": multiSelect,
|
|
850
|
-
children: [jsxs("span", {
|
|
851
|
-
css: /*#__PURE__*/css({
|
|
852
|
-
whiteSpace: 'nowrap',
|
|
853
|
-
overflow: 'hidden',
|
|
854
|
-
textOverflow: 'ellipsis',
|
|
855
|
-
height: theme.typography.lineHeightBase
|
|
856
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:triggerContent;"),
|
|
857
|
-
ref: triggerContentRef,
|
|
858
|
-
children: [jsx("span", {
|
|
859
|
-
css: /*#__PURE__*/css({
|
|
860
|
-
marginRight: theme.spacing.xs,
|
|
861
|
-
fontWeight: theme.typography.typographyBoldFontWeight
|
|
862
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:triggerContent;"),
|
|
863
|
-
children: label
|
|
864
|
-
}), withCountBadge || (value === null || value === void 0 ? void 0 : value.length) > showBadgeAfterValueCount ? jsx(FilterCountBadge, {
|
|
865
|
-
role: "status",
|
|
866
|
-
"aria-label": "Filter options selected count"
|
|
867
|
-
}) : displayedValues]
|
|
868
|
-
}), allowClear && value !== null && value !== void 0 && value.length ? jsx(XCircleFillIcon, {
|
|
869
|
-
onClick: handleClear,
|
|
870
|
-
css: /*#__PURE__*/css({
|
|
871
|
-
color: theme.colors.textPlaceholder,
|
|
872
|
-
fontSize: theme.typography.fontSizeSm,
|
|
873
|
-
marginLeft: theme.spacing.xs,
|
|
874
|
-
':hover': {
|
|
875
|
-
color: theme.colors.actionTertiaryTextHover
|
|
876
|
-
}
|
|
877
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:triggerContent;")
|
|
878
|
-
}) : null, jsx(ChevronDownIcon, {
|
|
879
|
-
css: /*#__PURE__*/css({
|
|
880
|
-
color: theme.colors.textSecondary,
|
|
881
|
-
marginLeft: 4
|
|
882
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:triggerContent;")
|
|
883
|
-
})]
|
|
884
|
-
});
|
|
885
|
-
return jsxs("div", {
|
|
886
|
-
css: getTriggerWrapperStyles(removable),
|
|
887
|
-
children: [showTooltip && value !== null && value !== void 0 && value.length ? jsx(Tooltip, {
|
|
888
|
-
title: displayedValues,
|
|
889
|
-
children: triggerContent
|
|
890
|
-
}) : triggerContent, removable && jsx(Button, {
|
|
891
|
-
"aria-label": "Remove ".concat(label, " filters"),
|
|
892
|
-
onClick: handleRemove,
|
|
893
|
-
dangerouslySetForceIconStyles: true,
|
|
894
|
-
children: jsx(CloseIcon, {})
|
|
895
|
-
})]
|
|
896
|
-
});
|
|
897
|
-
});
|
|
898
|
-
|
|
899
|
-
function _EMOTION_STRINGIFIED_CSS_ERROR__$1() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
900
|
-
// For performance, these styles are defined outside of the component so they are not redefined on every render.
|
|
901
|
-
// We're also using CSS Variables rather than any dynamic styles so that the style object remains static.
|
|
902
|
-
const tableStyles = {
|
|
903
|
-
row: process.env.NODE_ENV === "production" ? {
|
|
904
|
-
name: "1ezm0qn",
|
|
905
|
-
styles: "display:flex;border-bottom:1px solid;border-color:var(--table-separator-color);&:has([role=\"columnheader\"]){background-color:var(--table-header-background-color);}.table-row-select-cell input[type=\"checkbox\"] ~ *{opacity:var(--row-checkbox-opacity, 0);}&:hover{> *{background-color:var(--table-row-hover);}.table-row-select-cell input[type=\"checkbox\"] ~ *{opacity:1;}}.table-row-select-cell input[type=\"checkbox\"]:focus ~ *{opacity:1;}> *{padding-top:var(--table-row-vertical-padding);padding-bottom:var(--table-row-vertical-padding);}"
|
|
906
|
-
} : {
|
|
907
|
-
name: "eawneg-row",
|
|
908
|
-
styles: "display:flex;border-bottom:1px solid;border-color:var(--table-separator-color);&:has([role=\"columnheader\"]){background-color:var(--table-header-background-color);}.table-row-select-cell input[type=\"checkbox\"] ~ *{opacity:var(--row-checkbox-opacity, 0);}&:hover{> *{background-color:var(--table-row-hover);}.table-row-select-cell input[type=\"checkbox\"] ~ *{opacity:1;}}.table-row-select-cell input[type=\"checkbox\"]:focus ~ *{opacity:1;}> *{padding-top:var(--table-row-vertical-padding);padding-bottom:var(--table-row-vertical-padding);};label:row;",
|
|
909
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
910
|
-
},
|
|
911
|
-
cell: process.env.NODE_ENV === "production" ? {
|
|
912
|
-
name: "11nbh8q",
|
|
913
|
-
styles: "display:inline-grid;position:relative;align-items:var(--table-row-vertical-alignment, flex-start);flex:1;line-height:initial;box-sizing:border-box;padding-left:var(--table-spacing-sm);padding-right:var(--table-spacing-sm);word-break:break-word;overflow:hidden"
|
|
914
|
-
} : {
|
|
915
|
-
name: "pezdmp-cell",
|
|
916
|
-
styles: "display:inline-grid;position:relative;align-items:var(--table-row-vertical-alignment, flex-start);flex:1;line-height:initial;box-sizing:border-box;padding-left:var(--table-spacing-sm);padding-right:var(--table-spacing-sm);word-break:break-word;overflow:hidden;label:cell;",
|
|
917
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
918
|
-
},
|
|
919
|
-
rowMenuContainer: process.env.NODE_ENV === "production" ? {
|
|
920
|
-
name: "1o9y8zx",
|
|
921
|
-
styles: "padding-left:var(--table-spacing-xs);padding-right:var(--table-spacing-xs)"
|
|
922
|
-
} : {
|
|
923
|
-
name: "1gopnk4-rowMenuContainer",
|
|
924
|
-
styles: "padding-left:var(--table-spacing-xs);padding-right:var(--table-spacing-xs);label:rowMenuContainer;",
|
|
925
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
926
|
-
},
|
|
927
|
-
header: process.env.NODE_ENV === "production" ? {
|
|
928
|
-
name: "753xvu",
|
|
929
|
-
styles: "font-weight:bold;align-items:flex-end;display:flex;overflow:hidden;&[aria-sort]{cursor:pointer;user-select:none;}.table-header-text{color:var(--table-header-text-color);}.table-header-icon-container{color:var(--table-header-sort-icon-color);display:none;}&:hover{.table-header-icon-container, .table-header-text{color:var(--table-header-focus-color);}}&:active{.table-header-icon-container, .table-header-text{color:var(--table-header-active-color);}}&:hover, &[aria-sort=\"ascending\"], &[aria-sort=\"descending\"]{.table-header-icon-container{display:inline;}}"
|
|
930
|
-
} : {
|
|
931
|
-
name: "1shmncy-header",
|
|
932
|
-
styles: "font-weight:bold;align-items:flex-end;display:flex;overflow:hidden;&[aria-sort]{cursor:pointer;user-select:none;}.table-header-text{color:var(--table-header-text-color);}.table-header-icon-container{color:var(--table-header-sort-icon-color);display:none;}&:hover{.table-header-icon-container, .table-header-text{color:var(--table-header-focus-color);}}&:active{.table-header-icon-container, .table-header-text{color:var(--table-header-active-color);}}&:hover, &[aria-sort=\"ascending\"], &[aria-sort=\"descending\"]{.table-header-icon-container{display:inline;}};label:header;",
|
|
933
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
934
|
-
},
|
|
935
|
-
headerButtonTarget: process.env.NODE_ENV === "production" ? {
|
|
936
|
-
name: "dpqgee",
|
|
937
|
-
styles: "align-items:flex-end;display:flex;overflow:hidden;width:100%;&:focus{.table-header-text{color:var(--table-header-focus-color);}.table-header-icon-container{color:var(--table-header-focus-color);display:inline;}}&:active{.table-header-icon-container, .table-header-text{color:var(--table-header-active-color);}}"
|
|
938
|
-
} : {
|
|
939
|
-
name: "s60l4r-headerButtonTarget",
|
|
940
|
-
styles: "align-items:flex-end;display:flex;overflow:hidden;width:100%;&:focus{.table-header-text{color:var(--table-header-focus-color);}.table-header-icon-container{color:var(--table-header-focus-color);display:inline;}}&:active{.table-header-icon-container, .table-header-text{color:var(--table-header-active-color);}};label:headerButtonTarget;",
|
|
941
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
942
|
-
},
|
|
943
|
-
checkboxCell: process.env.NODE_ENV === "production" ? {
|
|
944
|
-
name: "mozdib",
|
|
945
|
-
styles: "display:flex;align-items:center;flex:0;padding-left:var(--table-spacing-sm);padding-top:0;padding-bottom:0;min-width:var(--table-spacing-md);max-width:var(--table-spacing-md)"
|
|
946
|
-
} : {
|
|
947
|
-
name: "101mdic-checkboxCell",
|
|
948
|
-
styles: "display:flex;align-items:center;flex:0;padding-left:var(--table-spacing-sm);padding-top:0;padding-bottom:0;min-width:var(--table-spacing-md);max-width:var(--table-spacing-md);label:checkboxCell;",
|
|
949
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
950
|
-
},
|
|
951
|
-
resizeHandleContainer: /*#__PURE__*/css({
|
|
952
|
-
position: 'absolute',
|
|
953
|
-
right: -3,
|
|
954
|
-
top: 'var(--table-spacing-sm)',
|
|
955
|
-
bottom: 'var(--table-spacing-sm)',
|
|
956
|
-
width: 'var(--table-spacing-sm)',
|
|
957
|
-
display: 'flex',
|
|
958
|
-
justifyContent: 'center',
|
|
959
|
-
cursor: 'col-resize',
|
|
960
|
-
userSelect: 'none',
|
|
961
|
-
touchAction: 'none',
|
|
962
|
-
zIndex: 1
|
|
963
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:resizeHandleContainer;"),
|
|
964
|
-
resizeHandle: process.env.NODE_ENV === "production" ? {
|
|
965
|
-
name: "55zery",
|
|
966
|
-
styles: "width:1px;background:var(--table-resize-handle-color)"
|
|
967
|
-
} : {
|
|
968
|
-
name: "1ot7jju-resizeHandle",
|
|
969
|
-
styles: "width:1px;background:var(--table-resize-handle-color);label:resizeHandle;",
|
|
970
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
971
|
-
},
|
|
972
|
-
paginationContainer: process.env.NODE_ENV === "production" ? {
|
|
973
|
-
name: "eb4gqw",
|
|
974
|
-
styles: "display:flex;justify-content:flex-end;margin-top:var(--table-spacing-sm)"
|
|
975
|
-
} : {
|
|
976
|
-
name: "e4q60i-paginationContainer",
|
|
977
|
-
styles: "display:flex;justify-content:flex-end;margin-top:var(--table-spacing-sm);label:paginationContainer;",
|
|
978
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
979
|
-
}
|
|
980
|
-
};
|
|
981
|
-
const TableContext = /*#__PURE__*/createContext({
|
|
982
|
-
size: 'default'
|
|
983
|
-
});
|
|
984
|
-
const Table = _ref => {
|
|
985
|
-
let {
|
|
986
|
-
children,
|
|
987
|
-
size = 'default',
|
|
988
|
-
someRowsSelected,
|
|
989
|
-
style,
|
|
990
|
-
pagination,
|
|
991
|
-
empty
|
|
992
|
-
} = _ref;
|
|
993
|
-
const {
|
|
994
|
-
theme
|
|
995
|
-
} = useDesignSystemTheme();
|
|
996
|
-
const flags = useDesignSystemFlags();
|
|
997
|
-
return jsx(TableContext.Provider, {
|
|
998
|
-
value: {
|
|
999
|
-
size,
|
|
1000
|
-
someRowsSelected
|
|
1001
|
-
},
|
|
1002
|
-
children: jsxs("div", {
|
|
1003
|
-
// This is a performance optimization; we want to statically create the styles for the table,
|
|
1004
|
-
// but for the dynamic theme values, we need to use CSS variables.
|
|
1005
|
-
// See: https://emotion.sh/docs/best-practices#advanced-css-variables-with-style
|
|
1006
|
-
style: {
|
|
1007
|
-
...style,
|
|
1008
|
-
['--table-header-active-color']: theme.colors.actionDefaultTextPress,
|
|
1009
|
-
// This hex is pulled directly from the old table as a temporary style-matching measure.
|
|
1010
|
-
['--table-header-background-color']: flags.USE_UPDATED_TABLE_STYLES ? 'transparent' : '#F2F5F7',
|
|
1011
|
-
['--table-header-focus-color']: theme.colors.actionDefaultTextHover,
|
|
1012
|
-
['--table-header-sort-icon-color']: theme.colors.textSecondary,
|
|
1013
|
-
['--table-header-text-color']: theme.colors.actionDefaultTextDefault,
|
|
1014
|
-
['--table-row-hover']: theme.colors.tableRowHover,
|
|
1015
|
-
['--table-separator-color']: theme.colors.tableSeparatorColor,
|
|
1016
|
-
['--table-resize-handle-color']: flags.USE_UPDATED_TABLE_STYLES ? theme.colors.tableSeparatorColor : theme.colors.grey400,
|
|
1017
|
-
['--table-spacing-md']: "".concat(theme.spacing.md, "px"),
|
|
1018
|
-
['--table-spacing-sm']: "".concat(theme.spacing.sm, "px"),
|
|
1019
|
-
['--table-spacing-xs']: "".concat(theme.spacing.xs, "px")
|
|
1020
|
-
},
|
|
1021
|
-
children: [jsxs("div", {
|
|
1022
|
-
role: "table",
|
|
1023
|
-
children: [children, empty && jsx("div", {
|
|
1024
|
-
css: /*#__PURE__*/css({
|
|
1025
|
-
padding: theme.spacing.lg
|
|
1026
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:Table;"),
|
|
1027
|
-
children: empty
|
|
1028
|
-
})]
|
|
1029
|
-
}), !empty && pagination && jsx("div", {
|
|
1030
|
-
css: tableStyles.paginationContainer,
|
|
1031
|
-
children: pagination
|
|
1032
|
-
})]
|
|
1033
|
-
})
|
|
1034
|
-
});
|
|
1035
|
-
};
|
|
1036
|
-
const TableRowContext = /*#__PURE__*/createContext({
|
|
1037
|
-
isHeader: false
|
|
1038
|
-
});
|
|
1039
|
-
const TableRow = _ref2 => {
|
|
1040
|
-
let {
|
|
1041
|
-
children,
|
|
1042
|
-
isHeader = false,
|
|
1043
|
-
verticalAlignment = 'top'
|
|
1044
|
-
} = _ref2;
|
|
1045
|
-
const {
|
|
1046
|
-
size
|
|
1047
|
-
} = useContext(TableContext);
|
|
1048
|
-
const {
|
|
1049
|
-
theme
|
|
1050
|
-
} = useDesignSystemTheme();
|
|
1051
|
-
|
|
1052
|
-
// Vertical only be larger if the row is a header AND size is large.
|
|
1053
|
-
const shouldUseLargeVerticalPadding = isHeader && size === 'default';
|
|
1054
|
-
let rowPadding;
|
|
1055
|
-
if (shouldUseLargeVerticalPadding) {
|
|
1056
|
-
rowPadding = theme.spacing.sm;
|
|
1057
|
-
} else if (size === 'default') {
|
|
1058
|
-
rowPadding = 6;
|
|
1059
|
-
} else {
|
|
1060
|
-
rowPadding = theme.spacing.xs;
|
|
1061
|
-
}
|
|
1062
|
-
return jsx(TableRowContext.Provider, {
|
|
1063
|
-
value: {
|
|
1064
|
-
isHeader
|
|
1065
|
-
},
|
|
1066
|
-
children: jsx("div", {
|
|
1067
|
-
css: [tableStyles.row, process.env.NODE_ENV === "production" ? "" : ";label:TableRow;"],
|
|
1068
|
-
role: "row",
|
|
1069
|
-
style: {
|
|
1070
|
-
['--table-row-vertical-padding']: "".concat(rowPadding, "px"),
|
|
1071
|
-
['--table-row-vertical-alignment']: verticalAlignment === 'top' ? 'flex-start' : 'center'
|
|
1072
|
-
},
|
|
1073
|
-
children: children
|
|
1074
|
-
})
|
|
1075
|
-
});
|
|
1076
|
-
};
|
|
1077
|
-
const TableCell = _ref3 => {
|
|
1078
|
-
let {
|
|
1079
|
-
children,
|
|
1080
|
-
ellipsis = false,
|
|
1081
|
-
style
|
|
1082
|
-
} = _ref3;
|
|
1083
|
-
const {
|
|
1084
|
-
size
|
|
1085
|
-
} = useContext(TableContext);
|
|
1086
|
-
let typographySize = 'md';
|
|
1087
|
-
if (size === 'small') {
|
|
1088
|
-
typographySize = 'sm';
|
|
1089
|
-
}
|
|
1090
|
-
return jsx("div", {
|
|
1091
|
-
css: [tableStyles.cell, process.env.NODE_ENV === "production" ? "" : ";label:TableCell;"],
|
|
1092
|
-
role: "cell",
|
|
1093
|
-
style: style,
|
|
1094
|
-
children: jsx(Typography.Text, {
|
|
1095
|
-
ellipsis: ellipsis,
|
|
1096
|
-
size: typographySize,
|
|
1097
|
-
title: ellipsis && typeof children === 'string' && children || undefined,
|
|
1098
|
-
children: children
|
|
1099
|
-
})
|
|
1100
|
-
});
|
|
1101
|
-
};
|
|
1102
|
-
const TableHeader = _ref4 => {
|
|
1103
|
-
let {
|
|
1104
|
-
children,
|
|
1105
|
-
ellipsis = false,
|
|
1106
|
-
sortable,
|
|
1107
|
-
sortDirection,
|
|
1108
|
-
onToggleSort,
|
|
1109
|
-
style
|
|
1110
|
-
} = _ref4;
|
|
1111
|
-
const {
|
|
1112
|
-
size
|
|
1113
|
-
} = useContext(TableContext);
|
|
1114
|
-
const {
|
|
1115
|
-
isHeader
|
|
1116
|
-
} = useContext(TableRowContext);
|
|
1117
|
-
if (!isHeader) {
|
|
1118
|
-
throw new Error('`TableHeader` must be used within a `TableRow` with `isHeader` set to true.');
|
|
1119
|
-
}
|
|
1120
|
-
let sortIcon = jsx(Fragment, {});
|
|
1121
|
-
// While most libaries use `asc` and `desc` for the sort value, the ARIA spec
|
|
1122
|
-
// uses `ascending` and `descending`.
|
|
1123
|
-
let ariaSort;
|
|
1124
|
-
if (sortable) {
|
|
1125
|
-
if (sortDirection === 'asc') {
|
|
1126
|
-
sortIcon = jsx(SortAscendingIcon, {});
|
|
1127
|
-
ariaSort = 'ascending';
|
|
1128
|
-
} else if (sortDirection === 'desc') {
|
|
1129
|
-
sortIcon = jsx(SortDescendingIcon, {});
|
|
1130
|
-
ariaSort = 'descending';
|
|
1131
|
-
} else if (sortDirection === 'none') {
|
|
1132
|
-
sortIcon = jsx(SortUnsortedIcon, {});
|
|
1133
|
-
ariaSort = 'none';
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
let typographySize = 'md';
|
|
1137
|
-
if (size === 'small') {
|
|
1138
|
-
typographySize = 'sm';
|
|
1139
|
-
}
|
|
1140
|
-
const textContents = jsx(Typography.Text, {
|
|
1141
|
-
className: "table-header-text"
|
|
1142
|
-
// If sortable, we must use ellipsis to prevent wrapping and misalignment.
|
|
1143
|
-
,
|
|
1144
|
-
ellipsis: ellipsis || sortable,
|
|
1145
|
-
size: typographySize,
|
|
1146
|
-
title: ellipsis && typeof children === 'string' && children || undefined,
|
|
1147
|
-
children: children
|
|
1148
|
-
});
|
|
1149
|
-
return jsx("div", {
|
|
1150
|
-
css: [tableStyles.cell, tableStyles.header, process.env.NODE_ENV === "production" ? "" : ";label:TableHeader;"],
|
|
1151
|
-
role: "columnheader",
|
|
1152
|
-
"aria-sort": sortable && ariaSort || undefined,
|
|
1153
|
-
onClick: onToggleSort,
|
|
1154
|
-
style: {
|
|
1155
|
-
...style
|
|
1156
|
-
},
|
|
1157
|
-
children: sortable ? jsxs("div", {
|
|
1158
|
-
css: [tableStyles.headerButtonTarget, process.env.NODE_ENV === "production" ? "" : ";label:TableHeader;"],
|
|
1159
|
-
role: "button",
|
|
1160
|
-
tabIndex: 0,
|
|
1161
|
-
onKeyDown: event => {
|
|
1162
|
-
if (sortable && (event.key === 'Enter' || event.key === ' ')) {
|
|
1163
|
-
event.preventDefault();
|
|
1164
|
-
return onToggleSort === null || onToggleSort === void 0 ? void 0 : onToggleSort(event);
|
|
1165
|
-
}
|
|
1166
|
-
},
|
|
1167
|
-
children: [textContents, jsx("span", {
|
|
1168
|
-
className: "table-header-icon-container",
|
|
1169
|
-
style: {
|
|
1170
|
-
marginLeft: 4
|
|
1171
|
-
},
|
|
1172
|
-
children: sortIcon
|
|
1173
|
-
})]
|
|
1174
|
-
}) : textContents
|
|
1175
|
-
});
|
|
1176
|
-
};
|
|
1177
|
-
const TableHeaderResizeHandle = _ref5 => {
|
|
1178
|
-
let {
|
|
1179
|
-
style,
|
|
1180
|
-
resizeHandler
|
|
1181
|
-
} = _ref5;
|
|
1182
|
-
const {
|
|
1183
|
-
isHeader
|
|
1184
|
-
} = useContext(TableRowContext);
|
|
1185
|
-
if (!isHeader) {
|
|
1186
|
-
throw new Error('`TableHeaderResizeHandle` must be used within a `TableRow` with `isHeader` set to true.');
|
|
1187
|
-
}
|
|
1188
|
-
return jsx("div", {
|
|
1189
|
-
onMouseDown: resizeHandler,
|
|
1190
|
-
onTouchStart: resizeHandler,
|
|
1191
|
-
css: tableStyles.resizeHandleContainer,
|
|
1192
|
-
style: style,
|
|
1193
|
-
children: jsx("div", {
|
|
1194
|
-
css: tableStyles.resizeHandle
|
|
1195
|
-
})
|
|
1196
|
-
});
|
|
1197
|
-
};
|
|
1198
|
-
const TableRowSelectCell = _ref6 => {
|
|
1199
|
-
let {
|
|
1200
|
-
onChange,
|
|
1201
|
-
checked,
|
|
1202
|
-
indeterminate,
|
|
1203
|
-
noCheckbox
|
|
1204
|
-
} = _ref6;
|
|
1205
|
-
const {
|
|
1206
|
-
isHeader
|
|
1207
|
-
} = useContext(TableRowContext);
|
|
1208
|
-
const {
|
|
1209
|
-
someRowsSelected
|
|
1210
|
-
} = useContext(TableContext);
|
|
1211
|
-
if (typeof someRowsSelected === 'undefined') {
|
|
1212
|
-
throw new Error('`TableRowSelectCell` cannot be used unless `someRowsSelected` has been provided to the `Table` component, see documentation.');
|
|
1213
|
-
}
|
|
1214
|
-
if (!isHeader && indeterminate) {
|
|
1215
|
-
throw new Error('`TableRowSelectCell` cannot be used with `indeterminate` in a non-header row.');
|
|
1216
|
-
}
|
|
1217
|
-
return jsx("div", {
|
|
1218
|
-
css: tableStyles.checkboxCell,
|
|
1219
|
-
style: {
|
|
1220
|
-
['--row-checkbox-opacity']: someRowsSelected ? 1 : 0
|
|
1221
|
-
},
|
|
1222
|
-
role: isHeader ? 'columnheader' : 'cell'
|
|
1223
|
-
// TODO: Ideally we shouldn't need to specify this `className`, but it allows for row-hovering to reveal
|
|
1224
|
-
// the checkbox in `TableRow`'s CSS without extra JS pointerin/out events.
|
|
1225
|
-
,
|
|
1226
|
-
className: "table-row-select-cell",
|
|
1227
|
-
children: !noCheckbox && jsx(Checkbox, {
|
|
1228
|
-
isChecked: checked || indeterminate && null,
|
|
1229
|
-
onChange: (_checked, event) => onChange === null || onChange === void 0 ? void 0 : onChange(event.nativeEvent)
|
|
1230
|
-
})
|
|
1231
|
-
});
|
|
1232
|
-
};
|
|
1233
|
-
const TableRowMenuContainer = _ref7 => {
|
|
1234
|
-
let {
|
|
1235
|
-
children,
|
|
1236
|
-
style
|
|
1237
|
-
} = _ref7;
|
|
1238
|
-
return jsx("div", {
|
|
1239
|
-
css: tableStyles.rowMenuContainer,
|
|
1240
|
-
style: style,
|
|
1241
|
-
children: children
|
|
1242
|
-
});
|
|
1243
|
-
};
|
|
1244
|
-
const TableSkeletonStyles = {
|
|
1245
|
-
container: process.env.NODE_ENV === "production" ? {
|
|
1246
|
-
name: "uxqssl",
|
|
1247
|
-
styles: "display:flex;flex-direction:column;align-items:flex-start;margin:6px 0;gap:12px"
|
|
1248
|
-
} : {
|
|
1249
|
-
name: "1zl9za-container",
|
|
1250
|
-
styles: "display:flex;flex-direction:column;align-items:flex-start;margin:6px 0;gap:12px;label:container;",
|
|
1251
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
1252
|
-
},
|
|
1253
|
-
cell: process.env.NODE_ENV === "production" ? {
|
|
1254
|
-
name: "18wj7jq",
|
|
1255
|
-
styles: "width:100%;height:8px;border-radius:4px;background:var(--table-skeleton-color)"
|
|
1256
|
-
} : {
|
|
1257
|
-
name: "2md9en-cell",
|
|
1258
|
-
styles: "width:100%;height:8px;border-radius:4px;background:var(--table-skeleton-color);label:cell;",
|
|
1259
|
-
toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1
|
|
1260
|
-
}
|
|
1261
|
-
};
|
|
1262
|
-
const TableSkeleton = _ref8 => {
|
|
1263
|
-
let {
|
|
1264
|
-
lines = 1,
|
|
1265
|
-
seed = '',
|
|
1266
|
-
style
|
|
1267
|
-
} = _ref8;
|
|
1268
|
-
const {
|
|
1269
|
-
theme
|
|
1270
|
-
} = useDesignSystemTheme();
|
|
1271
|
-
|
|
1272
|
-
// This is a very simple PRNG that is seeded (so that the output is deterministic).
|
|
1273
|
-
// We need this in order to produce a random ragged edge for the table skeleton.
|
|
1274
|
-
function pseudoRandomNumberGeneratorFromSeed(seed) {
|
|
1275
|
-
// This is a simple way to get a consistent number from a string;
|
|
1276
|
-
// `charCodeAt` returns a number between 0 and 65535, and we then just add them all up.
|
|
1277
|
-
const seedValue = seed.split('').map(char => char.charCodeAt(0)).reduce((prev, curr) => prev + curr, 0);
|
|
1278
|
-
|
|
1279
|
-
// This is a simple sine wave function that will always return a number between 0 and 1.
|
|
1280
|
-
// This produces a value akin to `Math.random()`, but has deterministic output.
|
|
1281
|
-
// Of course, sine curves are not a perfectly random distribution between 0 and 1, but
|
|
1282
|
-
// it's close enough for our purposes.
|
|
1283
|
-
return Math.sin(seedValue) / 2 + 0.5;
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
// This is a simple Fisher-Yates shuffler using the above PRNG.
|
|
1287
|
-
function shuffleArray(arr, seed) {
|
|
1288
|
-
for (let i = arr.length - 1; i > 0; i--) {
|
|
1289
|
-
const j = Math.floor(pseudoRandomNumberGeneratorFromSeed(seed + String(i)) * (i + 1));
|
|
1290
|
-
[arr[i], arr[j]] = [arr[j], arr[i]];
|
|
1291
|
-
}
|
|
1292
|
-
return arr;
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
// Finally, we shuffle a list off offsets to apply to the widths of the cells.
|
|
1296
|
-
// This ensures that the cells are not all the same width, but that they are
|
|
1297
|
-
// random to produce a more realistic looking skeleton.
|
|
1298
|
-
const widths = shuffleArray([48, 24, 0], seed);
|
|
1299
|
-
return jsx("div", {
|
|
1300
|
-
css: TableSkeletonStyles.container,
|
|
1301
|
-
style: {
|
|
1302
|
-
...style,
|
|
1303
|
-
// TODO: Pull this from the themes; it's not currently available.
|
|
1304
|
-
['--table-skeleton-color']: theme.isDarkMode ? 'rgba(255, 255, 255, 0.1)' : 'rgba(31, 38, 45, 0.1)'
|
|
1305
|
-
},
|
|
1306
|
-
children: [...Array(lines)].map((_, idx) => jsx("div", {
|
|
1307
|
-
css: [TableSkeletonStyles.cell, {
|
|
1308
|
-
width: "calc(100% - ".concat(widths[idx % widths.length], "px)")
|
|
1309
|
-
}, process.env.NODE_ENV === "production" ? "" : ";label:TableSkeleton;"]
|
|
1310
|
-
}, idx))
|
|
1311
|
-
});
|
|
1312
|
-
};
|
|
1313
7
|
|
|
1314
8
|
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
1315
9
|
var _ref = process.env.NODE_ENV === "production" ? {
|
|
@@ -1381,7 +75,7 @@ const getThumbStyles = theme => {
|
|
|
1381
75
|
width: 20,
|
|
1382
76
|
height: 20,
|
|
1383
77
|
backgroundColor: theme.colors.actionPrimaryBackgroundDefault,
|
|
1384
|
-
boxShadow:
|
|
78
|
+
boxShadow: `0 2px 4px 0 ${theme.colors.grey400}`,
|
|
1385
79
|
borderRadius: 10,
|
|
1386
80
|
outline: 'none',
|
|
1387
81
|
'&:hover': {
|
|
@@ -1415,5 +109,5 @@ var Slider = /*#__PURE__*/Object.freeze({
|
|
|
1415
109
|
Thumb: Thumb
|
|
1416
110
|
});
|
|
1417
111
|
|
|
1418
|
-
export {
|
|
112
|
+
export { Slider };
|
|
1419
113
|
//# sourceMappingURL=development.js.map
|