@trackunit/react-components 0.0.36
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/README.md +36 -0
- package/common/CommonProps.d.ts +17 -0
- package/common/StorybookProps.d.ts +6 -0
- package/common/index.d.ts +3 -0
- package/common/useContainerProps.d.ts +8 -0
- package/components/NumberField/NumberField.d.ts +15 -0
- package/components/NumberInput/NumberInput.d.ts +12 -0
- package/components/TextInput/TextInput.d.ts +12 -0
- package/components/alert/Alert.d.ts +69 -0
- package/components/alert/index.d.ts +1 -0
- package/components/badge/Badge.d.ts +74 -0
- package/components/badge/index.d.ts +1 -0
- package/components/baseInput/BaseInput.d.ts +82 -0
- package/components/baseInput/index.d.ts +1 -0
- package/components/buttons/button/Button.d.ts +55 -0
- package/components/buttons/icon-button/IconButton.d.ts +33 -0
- package/components/buttons/index.d.ts +4 -0
- package/components/buttons/shared/ButtonProps.d.ts +61 -0
- package/components/buttons/shared/helpers.d.ts +9 -0
- package/components/buttons/star-button/StarButton.d.ts +7 -0
- package/components/card/Card.d.ts +33 -0
- package/components/card/CardBody.d.ts +21 -0
- package/components/card/CardFooter.d.ts +16 -0
- package/components/card/CardHeader.d.ts +39 -0
- package/components/card/DensityContainer.d.ts +36 -0
- package/components/card/index.d.ts +5 -0
- package/components/chart/Chart.d.ts +105 -0
- package/components/chart/index.d.ts +1 -0
- package/components/checkbox/CheckIcon.d.ts +4 -0
- package/components/checkbox/Checkbox.d.ts +53 -0
- package/components/checkbox/IndeterminateIcon.d.ts +4 -0
- package/components/checkbox/index.d.ts +1 -0
- package/components/collapse/Collapse.d.ts +33 -0
- package/components/collapse/index.d.ts +1 -0
- package/components/copyableText/CopyableText.d.ts +8 -0
- package/components/copyableText/index.d.ts +1 -0
- package/components/dateField/DateField.d.ts +46 -0
- package/components/dateField/index.d.ts +1 -0
- package/components/dayPicker/DayPicker.d.ts +9 -0
- package/components/dayPicker/DayPickerPopover.d.ts +16 -0
- package/components/dayPicker/DayRangePicker.d.ts +11 -0
- package/components/dayPicker/index.d.ts +21 -0
- package/components/dayPicker/useLocale.d.ts +2 -0
- package/components/drawer/Drawer.d.ts +32 -0
- package/components/drawer/index.d.ts +1 -0
- package/components/formGroup/FormGroup.d.ts +42 -0
- package/components/heading/Heading.d.ts +34 -0
- package/components/heading/index.d.ts +1 -0
- package/components/icon/Icon.d.ts +49 -0
- package/components/index.d.ts +37 -0
- package/components/indicator/Indicator.d.ts +34 -0
- package/components/indicator/index.d.ts +1 -0
- package/components/label/Label.d.ts +33 -0
- package/components/label/index.d.ts +1 -0
- package/components/legendItem/LegendItem.d.ts +11 -0
- package/components/legendItem/index.d.ts +1 -0
- package/components/menu/MenuButton.d.ts +7 -0
- package/components/menu/MenuItem.d.ts +9 -0
- package/components/menu/MenuList.d.ts +11 -0
- package/components/menu/index.d.ts +3 -0
- package/components/modal/Modal.d.ts +42 -0
- package/components/modal/ModalBackdrop.d.ts +7 -0
- package/components/modal/index.d.ts +3 -0
- package/components/modal/useModal.d.ts +15 -0
- package/components/multiRowTableCell/MultiRowTableCell.d.ts +30 -0
- package/components/multiRowTableCell/index.d.ts +1 -0
- package/components/pageHeading/PageHeading.d.ts +9 -0
- package/components/pageHeading/index.d.ts +1 -0
- package/components/popover/AnimatedPopover.d.ts +15 -0
- package/components/popover/PopoverList.d.ts +6 -0
- package/components/popover/PopoverListItem.d.ts +16 -0
- package/components/popover/PopoverTitle.d.ts +8 -0
- package/components/popover/index.d.ts +5 -0
- package/components/popover/usePopover.d.ts +24 -0
- package/components/prompt/Prompt.d.ts +10 -0
- package/components/prompt/index.d.ts +1 -0
- package/components/radioGroup/RadioGroup.d.ts +14 -0
- package/components/radioGroup/RadioGroupContext.d.ts +10 -0
- package/components/radioGroup/RadioItem.d.ts +8 -0
- package/components/radioGroup/index.d.ts +2 -0
- package/components/select/CreatableSelect.d.ts +4 -0
- package/components/select/FieldContainer.d.ts +14 -0
- package/components/select/Select.d.ts +4 -0
- package/components/select/index.d.ts +3 -0
- package/components/select/shared.d.ts +83 -0
- package/components/skeletonLines/SkeletonLines.d.ts +41 -0
- package/components/skeletonLines/index.d.ts +1 -0
- package/components/spacer/Spacer.d.ts +21 -0
- package/components/spacer/index.d.ts +1 -0
- package/components/spinner/Spinner.d.ts +24 -0
- package/components/spinner/index.d.ts +1 -0
- package/components/text/Text.d.ts +79 -0
- package/components/text/index.d.ts +1 -0
- package/components/textArea/TextArea.d.ts +25 -0
- package/components/textArea/index.d.ts +1 -0
- package/components/textField/TextField.d.ts +23 -0
- package/components/textField/TextLenghtIndicator.d.ts +6 -0
- package/components/textField/index.d.ts +1 -0
- package/components/theme/DefaultTheme.d.ts +2 -0
- package/components/theme/index.d.ts +1 -0
- package/components/tip/Tip.d.ts +13 -0
- package/components/tip/index.d.ts +1 -0
- package/components/toggle/Toggle.d.ts +15 -0
- package/components/toggle/index.d.ts +1 -0
- package/components/tooltip/Tooltip.d.ts +69 -0
- package/components/tooltip/index.d.ts +1 -0
- package/constants/colors.d.ts +65 -0
- package/constants/index.d.ts +1 -0
- package/hooks/index.d.ts +3 -0
- package/hooks/useDebounce.d.ts +1 -0
- package/hooks/useLocalStorage.d.ts +2 -0
- package/hooks/useTimeout.d.ts +9 -0
- package/index.d.ts +5 -0
- package/index.js +3829 -0
- package/layout/helper/MinTopFullContentLayout.d.ts +12 -0
- package/layout/index.d.ts +7 -0
- package/layout/responsive/FilterListMapLayout.d.ts +19 -0
- package/layout/responsive/FullWidthRepeatingLayout.d.ts +16 -0
- package/layout/responsive/GridArea.d.ts +12 -0
- package/layout/responsive/IntrinsicallyResponsiveGrid.d.ts +26 -0
- package/layout/responsive/TitleNavContentLayout.d.ts +6 -0
- package/layout/responsive/TwoColumnLayout.d.ts +6 -0
- package/package.json +32 -0
- package/test-config/jest.setup.d.ts +1 -0
- package/test-utils/hooks.d.ts +4 -0
- package/test-utils/test-utils.d.ts +5 -0
package/index.js
ADDED
|
@@ -0,0 +1,3829 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { tw, tws } from '@trackunit/tailwind-styled-components';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useMemo, useState, forwardRef, useCallback, useRef, Fragment as Fragment$1, createElement, useContext, useEffect, memo } from 'react';
|
|
5
|
+
import { HeroIconsArray, heroIconLookup, TrackunitSolidIconsArray, TrackunitOutlineIconsArray, trackunitIconLookup } from '@trackunit/ui-icons';
|
|
6
|
+
import EChart from 'echarts-for-react';
|
|
7
|
+
import { v4 } from 'uuid';
|
|
8
|
+
import { animated, useSpring, useTransition } from '@react-spring/web';
|
|
9
|
+
import { useMeasure, useCopyToClipboard, useKeyPressEvent } from 'react-use';
|
|
10
|
+
import { DayPicker as DayPicker$1 } from 'react-day-picker';
|
|
11
|
+
import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
|
|
12
|
+
import usePortal from 'react-useportal';
|
|
13
|
+
import { createPopper } from '@popperjs/core';
|
|
14
|
+
import { Helmet } from 'react-helmet';
|
|
15
|
+
import { UNSAFE_LocationContext, UNSAFE_NavigationContext } from 'react-router-dom';
|
|
16
|
+
import ReactAsyncCreatableSelect from 'react-select/async-creatable';
|
|
17
|
+
import ReactCreatableSelect from 'react-select/creatable';
|
|
18
|
+
import ReactSelect from 'react-select';
|
|
19
|
+
import ReactAsyncSelect from 'react-select/async';
|
|
20
|
+
|
|
21
|
+
const docs = {
|
|
22
|
+
source: {
|
|
23
|
+
type: "dynamic",
|
|
24
|
+
excludeDecorators: true
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const useContainerProps = ({
|
|
29
|
+
className,
|
|
30
|
+
dataTestId
|
|
31
|
+
}) => {
|
|
32
|
+
const containerProps = {
|
|
33
|
+
className,
|
|
34
|
+
"data-testid": dataTestId
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (containerProps["data-testid"] === undefined) {
|
|
38
|
+
delete containerProps["data-testid"];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (containerProps.className === undefined) {
|
|
42
|
+
delete containerProps.className;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return containerProps;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/******************************************************************************
|
|
49
|
+
Copyright (c) Microsoft Corporation.
|
|
50
|
+
|
|
51
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
52
|
+
purpose with or without fee is hereby granted.
|
|
53
|
+
|
|
54
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
55
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
56
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
57
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
58
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
59
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
60
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
61
|
+
***************************************************************************** */
|
|
62
|
+
|
|
63
|
+
function __rest(s, e) {
|
|
64
|
+
var t = {};
|
|
65
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
66
|
+
t[p] = s[p];
|
|
67
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
68
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
69
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
70
|
+
t[p[i]] = s[p[i]];
|
|
71
|
+
}
|
|
72
|
+
return t;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const Spinner = ({
|
|
76
|
+
mode = "light",
|
|
77
|
+
size = "regular",
|
|
78
|
+
centered = false,
|
|
79
|
+
className,
|
|
80
|
+
containerClassName,
|
|
81
|
+
dataTestId
|
|
82
|
+
}) => {
|
|
83
|
+
return jsx(Container$8, Object.assign({
|
|
84
|
+
"$mode": mode,
|
|
85
|
+
"$centered": centered,
|
|
86
|
+
className: containerClassName
|
|
87
|
+
}, {
|
|
88
|
+
children: jsx(StyledSpinner, {
|
|
89
|
+
"$size": size,
|
|
90
|
+
"$mode": mode,
|
|
91
|
+
role: "spinbutton",
|
|
92
|
+
className: className,
|
|
93
|
+
"data-testid": dataTestId
|
|
94
|
+
})
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const getSpinnerStyles = () => ({
|
|
99
|
+
$size
|
|
100
|
+
}) => {
|
|
101
|
+
switch ($size) {
|
|
102
|
+
case "small":
|
|
103
|
+
return tws`spinner--small`;
|
|
104
|
+
|
|
105
|
+
case "large":
|
|
106
|
+
return tws`spinner--large`;
|
|
107
|
+
|
|
108
|
+
case "regular":
|
|
109
|
+
default:
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const StyledSpinner = tw.span`
|
|
115
|
+
spinner
|
|
116
|
+
${p => p.$mode === "dark" ? tws`spinner--dark` : null}
|
|
117
|
+
${getSpinnerStyles()}
|
|
118
|
+
`;
|
|
119
|
+
const Container$8 = tw.div`
|
|
120
|
+
spinner--container
|
|
121
|
+
${p => p.$centered ? tws`spinner--container-centered` : null}
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
const getStyles = () => ({
|
|
125
|
+
$intent,
|
|
126
|
+
$variant
|
|
127
|
+
}) => {
|
|
128
|
+
const styles = {
|
|
129
|
+
filled: {
|
|
130
|
+
primary: tws`button--primary`,
|
|
131
|
+
secondary: tws`button--secondary`,
|
|
132
|
+
danger: tws`button--danger`,
|
|
133
|
+
tertiary: tws`button--tertiary`,
|
|
134
|
+
warning: tws`button--warning`
|
|
135
|
+
},
|
|
136
|
+
transparent: {
|
|
137
|
+
primary: tws`button--transparent button--transparent-primary`,
|
|
138
|
+
secondary: tws`button--transparent button--transparent-secondary`,
|
|
139
|
+
danger: tws`button--transparent button--transparent-danger`,
|
|
140
|
+
tertiary: tws`button--transparent button--transparent-tertiary`,
|
|
141
|
+
warning: tws`button--transparent button--transparent-warning`
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
return styles[$variant][$intent];
|
|
145
|
+
};
|
|
146
|
+
const getPadding = () => ({
|
|
147
|
+
$size
|
|
148
|
+
}) => {
|
|
149
|
+
switch ($size) {
|
|
150
|
+
case "small":
|
|
151
|
+
return tws`button--small`;
|
|
152
|
+
|
|
153
|
+
case "large":
|
|
154
|
+
return tws`button--large`;
|
|
155
|
+
|
|
156
|
+
default:
|
|
157
|
+
return "";
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const Button = React.forwardRef((_a, ref) => {
|
|
162
|
+
var {
|
|
163
|
+
onClick,
|
|
164
|
+
children,
|
|
165
|
+
loading,
|
|
166
|
+
disabled,
|
|
167
|
+
className,
|
|
168
|
+
fullWidth = false,
|
|
169
|
+
prefix,
|
|
170
|
+
suffix,
|
|
171
|
+
intent = "primary",
|
|
172
|
+
variant = "filled",
|
|
173
|
+
type = "button",
|
|
174
|
+
size = "normal",
|
|
175
|
+
square = false,
|
|
176
|
+
dataTestId,
|
|
177
|
+
title,
|
|
178
|
+
role,
|
|
179
|
+
tabIndex,
|
|
180
|
+
renderAs = "button"
|
|
181
|
+
} = _a,
|
|
182
|
+
rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "intent", "variant", "type", "size", "square", "dataTestId", "title", "role", "tabIndex", "renderAs"]);
|
|
183
|
+
|
|
184
|
+
return jsxs(StyledButton$1, Object.assign({
|
|
185
|
+
"$as": renderAs,
|
|
186
|
+
onClick: onClick,
|
|
187
|
+
disabled: disabled || loading,
|
|
188
|
+
type: type,
|
|
189
|
+
className: className,
|
|
190
|
+
"$intent": intent,
|
|
191
|
+
"$fullWidth": fullWidth,
|
|
192
|
+
"$variant": variant,
|
|
193
|
+
"$size": size,
|
|
194
|
+
"$square": square,
|
|
195
|
+
title: title,
|
|
196
|
+
"aria-label": title,
|
|
197
|
+
role: role,
|
|
198
|
+
tabIndex: tabIndex,
|
|
199
|
+
"data-testid": dataTestId,
|
|
200
|
+
ref: ref
|
|
201
|
+
}, rest, {
|
|
202
|
+
children: [loading && jsx(Spinner, {
|
|
203
|
+
centered: true
|
|
204
|
+
}), prefix, children, suffix]
|
|
205
|
+
}));
|
|
206
|
+
});
|
|
207
|
+
const StyledButton$1 = tw.button`
|
|
208
|
+
button
|
|
209
|
+
${p => p.$square ? tws`button--square` : null}
|
|
210
|
+
${p => p.$fullWidth ? tws`button--fullWidth` : null}
|
|
211
|
+
${getStyles()}
|
|
212
|
+
${getPadding()}
|
|
213
|
+
`;
|
|
214
|
+
Button.displayName = "Button";
|
|
215
|
+
|
|
216
|
+
const IconButton = React.forwardRef((_a, ref) => {
|
|
217
|
+
var {
|
|
218
|
+
icon,
|
|
219
|
+
size = "small",
|
|
220
|
+
square = true,
|
|
221
|
+
circular,
|
|
222
|
+
loading,
|
|
223
|
+
disabled
|
|
224
|
+
} = _a,
|
|
225
|
+
rest = __rest(_a, ["icon", "size", "square", "circular", "loading", "disabled"]);
|
|
226
|
+
|
|
227
|
+
return jsx(StyledButton, Object.assign({
|
|
228
|
+
size: size,
|
|
229
|
+
square: square,
|
|
230
|
+
"$circular": circular,
|
|
231
|
+
disabled: disabled || loading,
|
|
232
|
+
ref: ref
|
|
233
|
+
}, rest, {
|
|
234
|
+
children: loading ? jsx(Spinner, {}) : icon
|
|
235
|
+
}));
|
|
236
|
+
});
|
|
237
|
+
IconButton.displayName = "IconButton";
|
|
238
|
+
const StyledButton = tw(Button)`
|
|
239
|
+
${p => p.$circular ? tws`button--rounded` : null}
|
|
240
|
+
`;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* ? A collection of all the types and tokens related to the named colors in the default theme.
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The general color palette
|
|
248
|
+
* Should be available in most if not all colored components
|
|
249
|
+
*/
|
|
250
|
+
const generalColors = {
|
|
251
|
+
PRIMARY: "primary",
|
|
252
|
+
ACCENT: "accent",
|
|
253
|
+
NEUTRAL: "neutral"
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* The intent color palette
|
|
257
|
+
* Should be available for most colored components such as "Button", "Alert", "Indicator", "Badge"
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
const intentColors = {
|
|
261
|
+
INFO: "info",
|
|
262
|
+
SUCCESS: "success",
|
|
263
|
+
WARNING: "warning",
|
|
264
|
+
DANGER: "danger"
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* The Criticality color palette
|
|
268
|
+
* Should be available in any component that could be used to display the criticality of an asset or event
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
const criticalityColors = {
|
|
272
|
+
GOOD: "good",
|
|
273
|
+
LOW: "low",
|
|
274
|
+
CRITICAL: "critical"
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* The Activity color palette
|
|
278
|
+
* Should be available in any component that could be used to display the Activity state of an asset
|
|
279
|
+
*/
|
|
280
|
+
|
|
281
|
+
const activityColors = {
|
|
282
|
+
WORKING: "working",
|
|
283
|
+
IDLE: "idle",
|
|
284
|
+
STOPPED: "stopped",
|
|
285
|
+
UNKNOWN: "unknown"
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* The full color palette
|
|
289
|
+
*/
|
|
290
|
+
|
|
291
|
+
const colors = Object.assign(Object.assign(Object.assign(Object.assign({}, generalColors), intentColors), criticalityColors), activityColors);
|
|
292
|
+
|
|
293
|
+
const IconSizeClassMap = {
|
|
294
|
+
small: tws`w-4`,
|
|
295
|
+
normal: tws`w-5`,
|
|
296
|
+
large: tws`w-6` // 24x24px
|
|
297
|
+
|
|
298
|
+
};
|
|
299
|
+
const Icon$1 = ({
|
|
300
|
+
name,
|
|
301
|
+
size = "large",
|
|
302
|
+
className,
|
|
303
|
+
dataTestId,
|
|
304
|
+
color,
|
|
305
|
+
onClick,
|
|
306
|
+
fillColor,
|
|
307
|
+
type,
|
|
308
|
+
forwardedRef
|
|
309
|
+
}) => {
|
|
310
|
+
const iconSizeClassName = React.useMemo(() => IconSizeClassMap[size], [size]);
|
|
311
|
+
const correctIconType = React.useMemo(() => type ? type : size === "large" ? "outline" : "solid", [type, size]);
|
|
312
|
+
const colorClassNames = React.useMemo(() => correctIconType === "solid" ? tws`fill-current stroke-transparent` : tws`fill-transparent stroke-current`, [correctIconType]);
|
|
313
|
+
let IconComponent = null;
|
|
314
|
+
|
|
315
|
+
if (HeroIconsArray.find(icon => icon === name)) {
|
|
316
|
+
IconComponent = heroIconLookup(name, correctIconType);
|
|
317
|
+
} else if (TrackunitSolidIconsArray.find(icon => icon === name) || TrackunitOutlineIconsArray.find(icon => icon === name)) {
|
|
318
|
+
IconComponent = trackunitIconLookup(name, correctIconType);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (!IconComponent) {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return jsx(React.Suspense, Object.assign({
|
|
326
|
+
fallback: jsx(LoadingDot, {
|
|
327
|
+
className: iconSizeClassName
|
|
328
|
+
})
|
|
329
|
+
}, {
|
|
330
|
+
children: jsx(Root$3, Object.assign({
|
|
331
|
+
"$color": color,
|
|
332
|
+
onClick: onClick,
|
|
333
|
+
"data-testid": dataTestId,
|
|
334
|
+
ref: forwardedRef
|
|
335
|
+
}, {
|
|
336
|
+
children: jsx(IconComponent, {
|
|
337
|
+
"data-testid": `${dataTestId}-${name}`,
|
|
338
|
+
className: `${iconSizeClassName} ${colorClassNames} ${className} ${name} aspect-square`,
|
|
339
|
+
style: fillColor ? {
|
|
340
|
+
fill: fillColor
|
|
341
|
+
} : {}
|
|
342
|
+
})
|
|
343
|
+
}))
|
|
344
|
+
}));
|
|
345
|
+
};
|
|
346
|
+
const LoadingDot = tw.span`
|
|
347
|
+
relative
|
|
348
|
+
aspect-square
|
|
349
|
+
|
|
350
|
+
after:content-['']
|
|
351
|
+
after:absolute
|
|
352
|
+
after:h-2
|
|
353
|
+
after:w-2
|
|
354
|
+
after:bg-current
|
|
355
|
+
after:rounded-full
|
|
356
|
+
after:inset-1/2
|
|
357
|
+
after:-translate-x-1/2
|
|
358
|
+
after:-translate-y-1/2
|
|
359
|
+
after:opacity-50
|
|
360
|
+
`;
|
|
361
|
+
const Root$3 = tw.span`
|
|
362
|
+
inline-block
|
|
363
|
+
relative
|
|
364
|
+
|
|
365
|
+
${({
|
|
366
|
+
$color
|
|
367
|
+
}) => {
|
|
368
|
+
switch ($color) {
|
|
369
|
+
case colors.PRIMARY:
|
|
370
|
+
return tws`text-primary-600`;
|
|
371
|
+
|
|
372
|
+
case colors.ACCENT:
|
|
373
|
+
return tws`text-accent-600`;
|
|
374
|
+
|
|
375
|
+
case colors.NEUTRAL:
|
|
376
|
+
return tws`text-neutral-600`;
|
|
377
|
+
|
|
378
|
+
case colors.INFO:
|
|
379
|
+
return tws`text-info-600`;
|
|
380
|
+
|
|
381
|
+
case colors.SUCCESS:
|
|
382
|
+
return tws`text-success-600`;
|
|
383
|
+
|
|
384
|
+
case colors.WARNING:
|
|
385
|
+
return tws`text-warning-600`;
|
|
386
|
+
|
|
387
|
+
case colors.DANGER:
|
|
388
|
+
return tws`text-danger-600`;
|
|
389
|
+
|
|
390
|
+
case colors.GOOD:
|
|
391
|
+
return tws`text-good-600`;
|
|
392
|
+
|
|
393
|
+
case colors.LOW:
|
|
394
|
+
return tws`text-low-600`;
|
|
395
|
+
|
|
396
|
+
case colors.CRITICAL:
|
|
397
|
+
return tws`text-critical-600`;
|
|
398
|
+
|
|
399
|
+
case colors.WORKING:
|
|
400
|
+
return tws`text-working-600`;
|
|
401
|
+
|
|
402
|
+
case colors.IDLE:
|
|
403
|
+
return tws`text-idle-600`;
|
|
404
|
+
|
|
405
|
+
case colors.STOPPED:
|
|
406
|
+
return tws`text-stopped-600`;
|
|
407
|
+
|
|
408
|
+
case colors.UNKNOWN:
|
|
409
|
+
return tws`text-unknown-600`;
|
|
410
|
+
|
|
411
|
+
default:
|
|
412
|
+
return "text-current";
|
|
413
|
+
}
|
|
414
|
+
}}
|
|
415
|
+
`;
|
|
416
|
+
|
|
417
|
+
const StarButton = ({
|
|
418
|
+
starred,
|
|
419
|
+
onClick
|
|
420
|
+
}) => {
|
|
421
|
+
return jsx(Flex$2, Object.assign({
|
|
422
|
+
onClick: onClick,
|
|
423
|
+
"data-test-id": "starred-filter"
|
|
424
|
+
}, {
|
|
425
|
+
children: jsx(CustomIcon, {
|
|
426
|
+
name: "StarIcon",
|
|
427
|
+
"$starred": starred
|
|
428
|
+
})
|
|
429
|
+
}));
|
|
430
|
+
};
|
|
431
|
+
const Flex$2 = tw.div`
|
|
432
|
+
flex
|
|
433
|
+
items-center
|
|
434
|
+
`;
|
|
435
|
+
const CustomIcon = tw(Icon$1)`
|
|
436
|
+
cursor-pointer
|
|
437
|
+
w-5
|
|
438
|
+
h-5
|
|
439
|
+
hover:!fill-primary-400
|
|
440
|
+
hover:!stroke-transparent
|
|
441
|
+
${p => p.$starred ? tws`!fill-primary-600 !stroke-transparent` : tws`!fill-transparent !stroke-neutral-800`}
|
|
442
|
+
`;
|
|
443
|
+
|
|
444
|
+
const Text = ({
|
|
445
|
+
children,
|
|
446
|
+
type = "p",
|
|
447
|
+
size = "default",
|
|
448
|
+
align = "left",
|
|
449
|
+
weight = "default",
|
|
450
|
+
underline = false,
|
|
451
|
+
inverted = false,
|
|
452
|
+
subtle = false,
|
|
453
|
+
italicize = false,
|
|
454
|
+
uppercase = false,
|
|
455
|
+
className,
|
|
456
|
+
dataTestId
|
|
457
|
+
}) => {
|
|
458
|
+
return jsx(StyledText$3, Object.assign({
|
|
459
|
+
"$as": type,
|
|
460
|
+
className: className,
|
|
461
|
+
"$align": align,
|
|
462
|
+
"$inverted": inverted,
|
|
463
|
+
"$subtle": subtle,
|
|
464
|
+
"$italicize": italicize,
|
|
465
|
+
"$uppercase": uppercase,
|
|
466
|
+
"$size": size,
|
|
467
|
+
"$weight": weight,
|
|
468
|
+
"$underline": underline,
|
|
469
|
+
"data-testid": dataTestId
|
|
470
|
+
}, {
|
|
471
|
+
children: children
|
|
472
|
+
}));
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
const getTextSize = () => ({
|
|
476
|
+
$size
|
|
477
|
+
}) => {
|
|
478
|
+
const sizes = {
|
|
479
|
+
small: tws`tu-text--small`,
|
|
480
|
+
large: tws`tu-text--large`,
|
|
481
|
+
default: null
|
|
482
|
+
};
|
|
483
|
+
return sizes[$size];
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const getTextWeight = () => ({
|
|
487
|
+
$weight
|
|
488
|
+
}) => {
|
|
489
|
+
const weights = {
|
|
490
|
+
thick: tws`tu-text--medium`,
|
|
491
|
+
bold: tws`tu-text--semibold`,
|
|
492
|
+
default: null
|
|
493
|
+
};
|
|
494
|
+
return weights[$weight];
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
const getFontColor$1 = () => ({
|
|
498
|
+
$inverted,
|
|
499
|
+
$subtle
|
|
500
|
+
}) => {
|
|
501
|
+
const subtle = $inverted ? tws`tu-text--subtle-inverted` : tws`tu-text--subtle`;
|
|
502
|
+
const inverted = $inverted ? tws`tu-text--inverted` : null;
|
|
503
|
+
return $subtle ? subtle : inverted;
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
const getTextAlignment = () => ({
|
|
507
|
+
$align
|
|
508
|
+
}) => {
|
|
509
|
+
const alignments = {
|
|
510
|
+
left: tws`tu-text--align-left`,
|
|
511
|
+
center: tws`tu-text--align-center`,
|
|
512
|
+
right: tws`tu-text--align-right`
|
|
513
|
+
};
|
|
514
|
+
return alignments[$align];
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
const StyledText$3 = tw.text`
|
|
518
|
+
tu-text
|
|
519
|
+
${getFontColor$1()}
|
|
520
|
+
${p => p.$italicize ? tws`tu-text--italic` : ""}
|
|
521
|
+
${p => p.$uppercase ? tws`tu-text--uppercase` : ""}
|
|
522
|
+
${getTextAlignment()}
|
|
523
|
+
${p => p.$underline ? tws`tu-text--underline` : ""}
|
|
524
|
+
${getTextSize()}
|
|
525
|
+
${getTextWeight()}
|
|
526
|
+
`;
|
|
527
|
+
|
|
528
|
+
const Alert = ({
|
|
529
|
+
intent = "info",
|
|
530
|
+
title,
|
|
531
|
+
className,
|
|
532
|
+
children,
|
|
533
|
+
primaryAction,
|
|
534
|
+
secondaryAction,
|
|
535
|
+
onClose,
|
|
536
|
+
dataTestId,
|
|
537
|
+
autoScroll,
|
|
538
|
+
inline = false
|
|
539
|
+
}) => {
|
|
540
|
+
const ref = React.useRef();
|
|
541
|
+
|
|
542
|
+
const getIconFromIntent = () => {
|
|
543
|
+
switch (intent) {
|
|
544
|
+
case "danger":
|
|
545
|
+
return jsx(Icon$1, {
|
|
546
|
+
name: "ExclamationIcon",
|
|
547
|
+
color: "danger"
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
case "warning":
|
|
551
|
+
return jsx(Icon$1, {
|
|
552
|
+
name: "ExclamationCircleIcon",
|
|
553
|
+
color: "warning"
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
case "success":
|
|
557
|
+
return jsx(Icon$1, {
|
|
558
|
+
name: "CheckCircleIcon",
|
|
559
|
+
color: "success"
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
default:
|
|
563
|
+
return jsx(Icon$1, {
|
|
564
|
+
name: "InformationCircleIcon"
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
const getButtonIntent = () => {
|
|
570
|
+
switch (intent) {
|
|
571
|
+
case "danger":
|
|
572
|
+
return "danger";
|
|
573
|
+
|
|
574
|
+
case "warning":
|
|
575
|
+
return "warning";
|
|
576
|
+
|
|
577
|
+
default:
|
|
578
|
+
return "primary";
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const body = inline ? jsxs("div", {
|
|
583
|
+
children: [title && jsx(Text, Object.assign({
|
|
584
|
+
weight: "bold"
|
|
585
|
+
}, {
|
|
586
|
+
children: title !== null && title !== void 0 ? title : children
|
|
587
|
+
})), children && jsx(Description$1, Object.assign({
|
|
588
|
+
weight: !title ? "bold" : "default",
|
|
589
|
+
"$hasTitle": !!title
|
|
590
|
+
}, {
|
|
591
|
+
children: children
|
|
592
|
+
}))]
|
|
593
|
+
}) : jsxs(Fragment, {
|
|
594
|
+
children: [title && jsx(Text, Object.assign({
|
|
595
|
+
weight: "bold"
|
|
596
|
+
}, {
|
|
597
|
+
children: title !== null && title !== void 0 ? title : children
|
|
598
|
+
})), children && jsx(Description$1, Object.assign({
|
|
599
|
+
weight: !title ? "bold" : "default",
|
|
600
|
+
"$hasTitle": !!title
|
|
601
|
+
}, {
|
|
602
|
+
children: children
|
|
603
|
+
}))]
|
|
604
|
+
});
|
|
605
|
+
React.useEffect(() => {
|
|
606
|
+
if (autoScroll) {
|
|
607
|
+
ref && ref.current && ref.current.scrollIntoView();
|
|
608
|
+
}
|
|
609
|
+
}, [ref, autoScroll]);
|
|
610
|
+
return jsxs(Container$7, Object.assign({
|
|
611
|
+
"$intent": intent,
|
|
612
|
+
className: className,
|
|
613
|
+
"data-testid": dataTestId,
|
|
614
|
+
"$inline": inline,
|
|
615
|
+
ref: ref
|
|
616
|
+
}, {
|
|
617
|
+
children: [jsx(IconContainer, Object.assign({
|
|
618
|
+
"$inline": inline
|
|
619
|
+
}, {
|
|
620
|
+
children: getIconFromIntent()
|
|
621
|
+
})), jsxs(Content$2, Object.assign({
|
|
622
|
+
"$inline": inline
|
|
623
|
+
}, {
|
|
624
|
+
children: [body, (primaryAction || secondaryAction) && jsxs(RightAligned, Object.assign({
|
|
625
|
+
"$inline": inline
|
|
626
|
+
}, {
|
|
627
|
+
children: [secondaryAction && jsx(Button, Object.assign({
|
|
628
|
+
size: "small",
|
|
629
|
+
variant: "transparent",
|
|
630
|
+
intent: getButtonIntent(),
|
|
631
|
+
onClick: secondaryAction.onClick,
|
|
632
|
+
loading: secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.loading
|
|
633
|
+
}, {
|
|
634
|
+
children: secondaryAction.label
|
|
635
|
+
})), primaryAction && jsx(Button, Object.assign({
|
|
636
|
+
size: "small",
|
|
637
|
+
intent: getButtonIntent(),
|
|
638
|
+
onClick: primaryAction.onClick,
|
|
639
|
+
loading: primaryAction === null || primaryAction === void 0 ? void 0 : primaryAction.loading
|
|
640
|
+
}, {
|
|
641
|
+
children: primaryAction.label
|
|
642
|
+
}))]
|
|
643
|
+
}))]
|
|
644
|
+
})), onClose ? jsx(CloseButtonContainer, Object.assign({
|
|
645
|
+
"$inline": inline
|
|
646
|
+
}, {
|
|
647
|
+
children: jsx(IconButton, {
|
|
648
|
+
size: "small",
|
|
649
|
+
variant: "transparent",
|
|
650
|
+
intent: "secondary",
|
|
651
|
+
onClick: onClose,
|
|
652
|
+
icon: jsx(Icon$1, {
|
|
653
|
+
name: "XIcon",
|
|
654
|
+
size: "small"
|
|
655
|
+
}),
|
|
656
|
+
title: "Close Alert",
|
|
657
|
+
circular: true
|
|
658
|
+
})
|
|
659
|
+
})) : null]
|
|
660
|
+
}));
|
|
661
|
+
};
|
|
662
|
+
const CloseButtonContainer = tw.div`
|
|
663
|
+
${p => p.$inline ? tws`alert__close-button-container--inline` : tws`alert__close-button-container`}
|
|
664
|
+
`;
|
|
665
|
+
|
|
666
|
+
const getBackgroundColor = () => ({
|
|
667
|
+
$intent
|
|
668
|
+
}) => {
|
|
669
|
+
const colors = {
|
|
670
|
+
danger: tws`alert--danger`,
|
|
671
|
+
warning: tws`alert--warning`,
|
|
672
|
+
success: tws`alert--success`,
|
|
673
|
+
info: tws`alert--info`
|
|
674
|
+
};
|
|
675
|
+
return colors[$intent];
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
const Container$7 = tw.div`
|
|
679
|
+
alert
|
|
680
|
+
${p => p.$inline ? tws`alert--inline` : null}
|
|
681
|
+
${getBackgroundColor()}
|
|
682
|
+
`;
|
|
683
|
+
const Content$2 = tw.div`
|
|
684
|
+
${p => p.$inline ? tws`alert__content--inline` : tws`alert__content`}
|
|
685
|
+
`;
|
|
686
|
+
const Description$1 = tw(Text)`
|
|
687
|
+
${p => p.$hasTitle ? tws`alert__description` : null}
|
|
688
|
+
`;
|
|
689
|
+
const RightAligned = tw.div`
|
|
690
|
+
alert__right-aligned
|
|
691
|
+
${p => p.$inline ? tws`alert__right-aligned--inline` : null}
|
|
692
|
+
`;
|
|
693
|
+
const IconContainer = tw.div`
|
|
694
|
+
alert__icon-container
|
|
695
|
+
${p => p.$inline ? tws`alert__icon-container--inline` : null}
|
|
696
|
+
`;
|
|
697
|
+
|
|
698
|
+
const Badge = _a => {
|
|
699
|
+
var {
|
|
700
|
+
intent = "secondary",
|
|
701
|
+
subtle = false,
|
|
702
|
+
className,
|
|
703
|
+
variant = "badge",
|
|
704
|
+
dataTestId,
|
|
705
|
+
children,
|
|
706
|
+
size = "default"
|
|
707
|
+
} = _a,
|
|
708
|
+
rest = __rest(_a, ["intent", "subtle", "className", "variant", "dataTestId", "children", "size"]);
|
|
709
|
+
|
|
710
|
+
const isPill = variant === "pill";
|
|
711
|
+
const tagProps = rest;
|
|
712
|
+
return jsxs(StyledText$2, Object.assign({
|
|
713
|
+
"$variant": variant,
|
|
714
|
+
className: className,
|
|
715
|
+
"$intent": intent,
|
|
716
|
+
"$size": size,
|
|
717
|
+
"$subtle": subtle ? subtle : isPill,
|
|
718
|
+
"data-testid": dataTestId,
|
|
719
|
+
"$as": "span",
|
|
720
|
+
"$withXIcon": tagProps.onClose ? true : false
|
|
721
|
+
}, {
|
|
722
|
+
children: [isPill ? children !== undefined && children !== null ? children > 99 ? "99+" : children : "" : children, variant === "tag" && tagProps.onClose && jsx(StyledIcon, {
|
|
723
|
+
name: "XCircleIcon",
|
|
724
|
+
dataTestId: dataTestId + "Icon",
|
|
725
|
+
onClick: tagProps.onClose,
|
|
726
|
+
type: "solid",
|
|
727
|
+
size: size === "default" ? "normal" : "large"
|
|
728
|
+
})]
|
|
729
|
+
}));
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
const getSizeModifierClass = () => ({
|
|
733
|
+
$size,
|
|
734
|
+
$variant,
|
|
735
|
+
$withXIcon
|
|
736
|
+
}) => {
|
|
737
|
+
const sizeModifierClass = {
|
|
738
|
+
large: tws`badge--large`,
|
|
739
|
+
default: ""
|
|
740
|
+
};
|
|
741
|
+
const tagSizeModifierClass = {
|
|
742
|
+
large: $withXIcon ? tws`tag--icon tag--icon-large` : tws`tag--icon tag--large`,
|
|
743
|
+
default: $withXIcon ? tws`tag--icon tag--icon-small` : ""
|
|
744
|
+
};
|
|
745
|
+
return $variant === "tag" ? tagSizeModifierClass[$size] : sizeModifierClass[$size];
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
const getBadgeModifierClass = () => ({
|
|
749
|
+
$intent,
|
|
750
|
+
$subtle
|
|
751
|
+
}) => {
|
|
752
|
+
const intentClass = {
|
|
753
|
+
primary: $subtle ? tws`badge--primary-subtle` : tws`badge--primary`,
|
|
754
|
+
secondary: $subtle ? tws`badge--secondary-subtle` : tws`badge--secondary`,
|
|
755
|
+
success: $subtle ? tws`badge--success-subtle` : tws`badge--success`,
|
|
756
|
+
danger: $subtle ? tws`badge--danger-subtle` : tws`badge--danger`,
|
|
757
|
+
warning: $subtle ? tws`badge--warning-subtle` : tws`badge--warning`
|
|
758
|
+
};
|
|
759
|
+
return intentClass[$intent];
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
const StyledText$2 = tw.text`
|
|
763
|
+
${p => {
|
|
764
|
+
switch (p.$variant) {
|
|
765
|
+
case "badge":
|
|
766
|
+
return tws`badge`;
|
|
767
|
+
|
|
768
|
+
case "tag":
|
|
769
|
+
return tws`badge--tag`;
|
|
770
|
+
|
|
771
|
+
case "pill":
|
|
772
|
+
return tws`badge--pill`;
|
|
773
|
+
|
|
774
|
+
default:
|
|
775
|
+
return tws`badge`;
|
|
776
|
+
}
|
|
777
|
+
}}
|
|
778
|
+
${getBadgeModifierClass()}
|
|
779
|
+
${getSizeModifierClass()}
|
|
780
|
+
`;
|
|
781
|
+
const StyledIcon = tw(Icon$1)`
|
|
782
|
+
tag__icon
|
|
783
|
+
`;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* A base input component that can be used for text inputs, password inputs, etc.
|
|
787
|
+
* A reference to the input element is provided as the `ref` prop.
|
|
788
|
+
* Extends props from [React.InputHTMLAttributes](https://reactjs.org/docs/dom-elements.html#input)
|
|
789
|
+
*
|
|
790
|
+
* For specific input types make sure to use the corresponding input component.
|
|
791
|
+
* This is a base used by our other input components such as TextInput, NumberInput, PasswordInput, etc.
|
|
792
|
+
*/
|
|
793
|
+
|
|
794
|
+
const BaseInput = React.forwardRef((_a, ref) => {
|
|
795
|
+
var {
|
|
796
|
+
className,
|
|
797
|
+
isInvalid,
|
|
798
|
+
dataTestId,
|
|
799
|
+
prefix,
|
|
800
|
+
suffix,
|
|
801
|
+
addonBefore,
|
|
802
|
+
addonAfter,
|
|
803
|
+
actions,
|
|
804
|
+
fieldSize = "default"
|
|
805
|
+
} = _a,
|
|
806
|
+
rest = __rest(_a, ["className", "isInvalid", "dataTestId", "prefix", "suffix", "addonBefore", "addonAfter", "actions", "fieldSize"]);
|
|
807
|
+
|
|
808
|
+
return jsxs(InputContainer, Object.assign({
|
|
809
|
+
"$fieldSize": fieldSize,
|
|
810
|
+
"$invalid": isInvalid,
|
|
811
|
+
"$disabled": rest.disabled,
|
|
812
|
+
className: className,
|
|
813
|
+
"data-testid": `${dataTestId}-container`
|
|
814
|
+
}, {
|
|
815
|
+
children: [addonBefore !== null && addonBefore !== undefined ? jsx(AddonBefore, Object.assign({
|
|
816
|
+
"data-testid": `${dataTestId}-addonBefore`
|
|
817
|
+
}, {
|
|
818
|
+
children: addonBefore
|
|
819
|
+
})) : null, prefix !== null && addonBefore !== prefix ? jsx(InputPrefix, Object.assign({
|
|
820
|
+
"data-testid": `${dataTestId}-prefix`
|
|
821
|
+
}, {
|
|
822
|
+
children: prefix
|
|
823
|
+
})) : null, jsx("input", Object.assign({
|
|
824
|
+
ref: ref,
|
|
825
|
+
"data-testid": dataTestId,
|
|
826
|
+
className: tws`input__field`
|
|
827
|
+
}, rest)), suffix !== null && addonBefore !== suffix ? jsx(InputSuffix, Object.assign({
|
|
828
|
+
"data-testid": `${dataTestId}-suffix`
|
|
829
|
+
}, {
|
|
830
|
+
children: suffix
|
|
831
|
+
})) : null, actions !== null && addonBefore !== actions ? actions : null, addonAfter !== null && addonBefore !== addonAfter ? jsx(AddonAfter, Object.assign({
|
|
832
|
+
"data-testid": `${dataTestId}-addonAfter`
|
|
833
|
+
}, {
|
|
834
|
+
children: addonAfter
|
|
835
|
+
})) : null]
|
|
836
|
+
}));
|
|
837
|
+
});
|
|
838
|
+
const InputPrefix = tw.div`
|
|
839
|
+
input__prefix
|
|
840
|
+
`;
|
|
841
|
+
const InputSuffix = tw.div`
|
|
842
|
+
input__suffix
|
|
843
|
+
`;
|
|
844
|
+
const AddonBefore = tw.div`
|
|
845
|
+
input__addon-before
|
|
846
|
+
`;
|
|
847
|
+
const AddonAfter = tw.div`
|
|
848
|
+
input__addon-after
|
|
849
|
+
`;
|
|
850
|
+
const InputContainer = tw.div`
|
|
851
|
+
input
|
|
852
|
+
${({
|
|
853
|
+
$invalid
|
|
854
|
+
}) => $invalid ? tws`input--invalid` : null}
|
|
855
|
+
${({
|
|
856
|
+
$disabled
|
|
857
|
+
}) => $disabled ? tws`input--disabled` : null}
|
|
858
|
+
${({
|
|
859
|
+
$fieldSize
|
|
860
|
+
}) => $fieldSize === "small" ? tws`input--small` : null}
|
|
861
|
+
`;
|
|
862
|
+
BaseInput.displayName = "BaseInput";
|
|
863
|
+
|
|
864
|
+
const ROLE_CARD = "region";
|
|
865
|
+
const Card = ({
|
|
866
|
+
children,
|
|
867
|
+
onClick,
|
|
868
|
+
fullHeight = false,
|
|
869
|
+
onMouseEnter,
|
|
870
|
+
onMouseLeave,
|
|
871
|
+
className,
|
|
872
|
+
dataTestId,
|
|
873
|
+
overflow = "visible",
|
|
874
|
+
gridArea
|
|
875
|
+
}) => {
|
|
876
|
+
return jsx(StyledCard$1, Object.assign({
|
|
877
|
+
"$fullHeight": fullHeight,
|
|
878
|
+
"$overflow": overflow,
|
|
879
|
+
onClick: onClick,
|
|
880
|
+
className: className,
|
|
881
|
+
onMouseEnter: onMouseEnter,
|
|
882
|
+
onMouseLeave: onMouseLeave,
|
|
883
|
+
"data-testid": dataTestId,
|
|
884
|
+
role: ROLE_CARD,
|
|
885
|
+
style: {
|
|
886
|
+
gridArea
|
|
887
|
+
}
|
|
888
|
+
}, {
|
|
889
|
+
children: children
|
|
890
|
+
}));
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
const getOverflow$1 = () => ({
|
|
894
|
+
$overflow
|
|
895
|
+
}) => {
|
|
896
|
+
if (!$overflow) {
|
|
897
|
+
return null;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
const overflows = {
|
|
901
|
+
visible: tws`overflow-visible`,
|
|
902
|
+
hidden: tws`overflow-hidden`,
|
|
903
|
+
scroll: tws`overflow-scroll`,
|
|
904
|
+
auto: tws`overflow-auto`
|
|
905
|
+
};
|
|
906
|
+
return overflows[$overflow];
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
const StyledCard$1 = tw.div`
|
|
910
|
+
card
|
|
911
|
+
${p => p.$fullHeight ? `h-full` : null}
|
|
912
|
+
|
|
913
|
+
${p => p.onClick && `card--clickable`}
|
|
914
|
+
${getOverflow$1()}
|
|
915
|
+
`;
|
|
916
|
+
|
|
917
|
+
const DensityContainer = ({
|
|
918
|
+
children,
|
|
919
|
+
className,
|
|
920
|
+
dataTestId,
|
|
921
|
+
$density,
|
|
922
|
+
$disableGap,
|
|
923
|
+
$direction
|
|
924
|
+
}) => {
|
|
925
|
+
return jsx(StyledDensityContainer$1, Object.assign({
|
|
926
|
+
"$disableGap": $disableGap,
|
|
927
|
+
"$density": $density,
|
|
928
|
+
"$direction": $direction,
|
|
929
|
+
"data-testid": dataTestId,
|
|
930
|
+
className: className
|
|
931
|
+
}, {
|
|
932
|
+
children: children
|
|
933
|
+
}));
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
const getDirection = () => ({
|
|
937
|
+
$direction
|
|
938
|
+
}) => {
|
|
939
|
+
$direction = $direction ? $direction : "column";
|
|
940
|
+
const directions = {
|
|
941
|
+
row: tws`flex-row`,
|
|
942
|
+
"row-reverse": tws`flex-row-reverse`,
|
|
943
|
+
column: tws`flex-col`,
|
|
944
|
+
"column-reverse": tws`flex-col-reverse`
|
|
945
|
+
};
|
|
946
|
+
return directions[$direction];
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
const densityAuto = tws`
|
|
950
|
+
gap-3
|
|
951
|
+
p-3
|
|
952
|
+
sm:gap-4
|
|
953
|
+
sm:p-4
|
|
954
|
+
md:gap-4
|
|
955
|
+
md:p-6
|
|
956
|
+
`;
|
|
957
|
+
|
|
958
|
+
const DensityFinder = ({
|
|
959
|
+
$density
|
|
960
|
+
}) => {
|
|
961
|
+
switch ($density) {
|
|
962
|
+
case "none":
|
|
963
|
+
return;
|
|
964
|
+
|
|
965
|
+
case "compact":
|
|
966
|
+
return tws`gap-3 p-3`;
|
|
967
|
+
|
|
968
|
+
case "comfortable":
|
|
969
|
+
return tws`gap-4 p-4`;
|
|
970
|
+
|
|
971
|
+
case "spacious":
|
|
972
|
+
return tws`gap-4 p-6`;
|
|
973
|
+
|
|
974
|
+
case "auto":
|
|
975
|
+
default:
|
|
976
|
+
return densityAuto;
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
const StyledDensityContainer$1 = tw.div`
|
|
981
|
+
flex
|
|
982
|
+
${getDirection()}
|
|
983
|
+
${p => p.$disableGap ? tws`gap-0` : null}
|
|
984
|
+
${DensityFinder}
|
|
985
|
+
`;
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* @summary
|
|
989
|
+
* For applying padding and gap to a Card.
|
|
990
|
+
*
|
|
991
|
+
* @description
|
|
992
|
+
* The padding must live here, and not on the Card itself, as to not inset the scrollbar in case of overflow
|
|
993
|
+
*/
|
|
994
|
+
|
|
995
|
+
const CardBody = ({
|
|
996
|
+
density = "auto",
|
|
997
|
+
overflow = "auto",
|
|
998
|
+
children,
|
|
999
|
+
dataTestId,
|
|
1000
|
+
className,
|
|
1001
|
+
disableGap
|
|
1002
|
+
}) => {
|
|
1003
|
+
return jsx(StyledDensityContainer, Object.assign({
|
|
1004
|
+
"$overflow": overflow,
|
|
1005
|
+
"$density": density,
|
|
1006
|
+
dataTestId: dataTestId,
|
|
1007
|
+
className: className,
|
|
1008
|
+
"$disableGap": disableGap
|
|
1009
|
+
}, {
|
|
1010
|
+
children: children
|
|
1011
|
+
}));
|
|
1012
|
+
};
|
|
1013
|
+
|
|
1014
|
+
const getOverflow = () => ({
|
|
1015
|
+
$overflow
|
|
1016
|
+
}) => {
|
|
1017
|
+
if (!$overflow) {
|
|
1018
|
+
return null;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
const overflows = {
|
|
1022
|
+
visible: tws`overflow-visible`,
|
|
1023
|
+
hidden: tws`overflow-hidden`,
|
|
1024
|
+
scroll: tws`overflow-scroll`,
|
|
1025
|
+
auto: tws`overflow-auto`
|
|
1026
|
+
};
|
|
1027
|
+
return overflows[$overflow];
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
const StyledDensityContainer = tw(DensityContainer)`
|
|
1031
|
+
${getOverflow()}
|
|
1032
|
+
card__body
|
|
1033
|
+
`;
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* A simple footer intended to use with Cards and Modals.
|
|
1037
|
+
* Currently only intended to contain Buttons.
|
|
1038
|
+
* The buttons justifies to the right, but if you style a button with "margin-right: auto" it will move to the left
|
|
1039
|
+
*
|
|
1040
|
+
* @param {CardFooterProps} { dataTestId, className, children, density }
|
|
1041
|
+
* @return {*}
|
|
1042
|
+
*/
|
|
1043
|
+
|
|
1044
|
+
const CardFooter = ({
|
|
1045
|
+
dataTestId,
|
|
1046
|
+
className,
|
|
1047
|
+
children,
|
|
1048
|
+
density
|
|
1049
|
+
}) => {
|
|
1050
|
+
return jsx(TopBorderedDensityContainer, Object.assign({
|
|
1051
|
+
dataTestId: dataTestId,
|
|
1052
|
+
className: className,
|
|
1053
|
+
"$density": density
|
|
1054
|
+
}, {
|
|
1055
|
+
children: jsx(StyledFlex$1, {
|
|
1056
|
+
children: children
|
|
1057
|
+
})
|
|
1058
|
+
}));
|
|
1059
|
+
};
|
|
1060
|
+
const TopBorderedDensityContainer = tw(DensityContainer)`
|
|
1061
|
+
border-t-2
|
|
1062
|
+
border-neutral-200
|
|
1063
|
+
`;
|
|
1064
|
+
const StyledFlex$1 = tw.div`
|
|
1065
|
+
flex
|
|
1066
|
+
gap-2
|
|
1067
|
+
flex-wrap
|
|
1068
|
+
justify-end
|
|
1069
|
+
`;
|
|
1070
|
+
|
|
1071
|
+
const Heading = ({
|
|
1072
|
+
children,
|
|
1073
|
+
variant = "primary",
|
|
1074
|
+
inverted = false,
|
|
1075
|
+
subtle = false,
|
|
1076
|
+
className,
|
|
1077
|
+
dataTestId
|
|
1078
|
+
}) => {
|
|
1079
|
+
const semanticType = {
|
|
1080
|
+
primary: "h1",
|
|
1081
|
+
secondary: "h2",
|
|
1082
|
+
tertiary: "h3",
|
|
1083
|
+
subtitle: "h4"
|
|
1084
|
+
};
|
|
1085
|
+
return jsx(StyledHeading, Object.assign({
|
|
1086
|
+
"$as": semanticType[variant],
|
|
1087
|
+
className: className,
|
|
1088
|
+
"$variant": variant,
|
|
1089
|
+
"$inverted": inverted,
|
|
1090
|
+
"$subtle": subtle,
|
|
1091
|
+
"data-testid": dataTestId
|
|
1092
|
+
}, {
|
|
1093
|
+
children: children
|
|
1094
|
+
}));
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
const getVariantStyles = () => ({
|
|
1098
|
+
$variant
|
|
1099
|
+
}) => {
|
|
1100
|
+
const variants = {
|
|
1101
|
+
primary: tws`heading--primary`,
|
|
1102
|
+
secondary: tws`heading--secondary`,
|
|
1103
|
+
tertiary: tws`heading--tertiary`,
|
|
1104
|
+
subtitle: tws`heading--subtitle`
|
|
1105
|
+
};
|
|
1106
|
+
return variants[$variant];
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
const getFontColor = () => ({
|
|
1110
|
+
$inverted,
|
|
1111
|
+
$subtle
|
|
1112
|
+
}) => {
|
|
1113
|
+
const subtle = $inverted ? tws`heading--subtle-inverted` : tws`heading--subtle`;
|
|
1114
|
+
const inverted = $inverted ? tws`heading--inverted` : null;
|
|
1115
|
+
return $subtle ? subtle : inverted;
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
const StyledHeading = tw.div`
|
|
1119
|
+
heading
|
|
1120
|
+
${getFontColor()}
|
|
1121
|
+
${getVariantStyles()}
|
|
1122
|
+
`;
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Header for Cards and Models.
|
|
1126
|
+
*
|
|
1127
|
+
*
|
|
1128
|
+
* @param {CardHeaderProps} {
|
|
1129
|
+
* heading,
|
|
1130
|
+
* headingVariant = "primary",
|
|
1131
|
+
* subHeading,
|
|
1132
|
+
* onClose,
|
|
1133
|
+
* dataTestId,
|
|
1134
|
+
* className,
|
|
1135
|
+
* children,
|
|
1136
|
+
* density,
|
|
1137
|
+
* }
|
|
1138
|
+
* @return {*}
|
|
1139
|
+
*/
|
|
1140
|
+
|
|
1141
|
+
const CardHeader = ({
|
|
1142
|
+
heading,
|
|
1143
|
+
headingVariant = "primary",
|
|
1144
|
+
subHeading,
|
|
1145
|
+
onClose,
|
|
1146
|
+
dataTestId,
|
|
1147
|
+
className,
|
|
1148
|
+
children,
|
|
1149
|
+
accessories,
|
|
1150
|
+
density
|
|
1151
|
+
}) => {
|
|
1152
|
+
return jsx(BottomBorderedDensityContainer, Object.assign({
|
|
1153
|
+
dataTestId: dataTestId,
|
|
1154
|
+
className: className,
|
|
1155
|
+
"$density": density
|
|
1156
|
+
}, {
|
|
1157
|
+
children: jsxs(Container$6, {
|
|
1158
|
+
children: [jsxs("div", {
|
|
1159
|
+
children: [jsxs(HeadingContainer, {
|
|
1160
|
+
children: [jsx(Heading, Object.assign({
|
|
1161
|
+
variant: headingVariant
|
|
1162
|
+
}, {
|
|
1163
|
+
children: heading
|
|
1164
|
+
})), accessories]
|
|
1165
|
+
}), subHeading && jsx(Heading, Object.assign({
|
|
1166
|
+
subtle: true,
|
|
1167
|
+
variant: "subtitle"
|
|
1168
|
+
}, {
|
|
1169
|
+
children: subHeading
|
|
1170
|
+
})), children]
|
|
1171
|
+
}), onClose && jsx(IconButton, {
|
|
1172
|
+
dataTestId: "card-header-close-button",
|
|
1173
|
+
variant: "transparent",
|
|
1174
|
+
intent: "secondary",
|
|
1175
|
+
onClick: onClose,
|
|
1176
|
+
icon: jsx(Icon$1, {
|
|
1177
|
+
name: "XIcon",
|
|
1178
|
+
size: "small"
|
|
1179
|
+
})
|
|
1180
|
+
})]
|
|
1181
|
+
})
|
|
1182
|
+
}));
|
|
1183
|
+
};
|
|
1184
|
+
const BottomBorderedDensityContainer = tw(DensityContainer)`
|
|
1185
|
+
border-b-2
|
|
1186
|
+
border-neutral-200`;
|
|
1187
|
+
const Container$6 = tw.div`
|
|
1188
|
+
flex
|
|
1189
|
+
justify-between
|
|
1190
|
+
items-start
|
|
1191
|
+
`;
|
|
1192
|
+
const HeadingContainer = tw.div`
|
|
1193
|
+
flex
|
|
1194
|
+
items-center
|
|
1195
|
+
gap-4
|
|
1196
|
+
`;
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* A wrapper component for Echarts.
|
|
1200
|
+
* Handles events and click functionality.
|
|
1201
|
+
*/
|
|
1202
|
+
|
|
1203
|
+
const Chart = ({
|
|
1204
|
+
options,
|
|
1205
|
+
showLoading,
|
|
1206
|
+
className,
|
|
1207
|
+
style,
|
|
1208
|
+
onChartReady,
|
|
1209
|
+
onClick,
|
|
1210
|
+
onDataZoom,
|
|
1211
|
+
onBrush,
|
|
1212
|
+
onBrushSelected,
|
|
1213
|
+
mouseLeaveChart,
|
|
1214
|
+
merge = true,
|
|
1215
|
+
loadingOption,
|
|
1216
|
+
timezoneLabel,
|
|
1217
|
+
renderer = "canvas"
|
|
1218
|
+
}) => {
|
|
1219
|
+
const echartsRef = React.useRef(null);
|
|
1220
|
+
const eventHandlers = React.useMemo(() => {
|
|
1221
|
+
const values = {};
|
|
1222
|
+
|
|
1223
|
+
if (onDataZoom !== undefined) {
|
|
1224
|
+
values.dataZoom = onDataZoom;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
if (onBrush !== undefined) {
|
|
1228
|
+
values.brush = onBrush;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
if (onBrushSelected !== undefined) {
|
|
1232
|
+
values.brushSelected = onBrushSelected;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
if (mouseLeaveChart !== undefined) {
|
|
1236
|
+
values.globalout = mouseLeaveChart;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
return values;
|
|
1240
|
+
}, [onDataZoom, onBrush, onBrushSelected, mouseLeaveChart]);
|
|
1241
|
+
React.useEffect(() => {
|
|
1242
|
+
var _a;
|
|
1243
|
+
|
|
1244
|
+
const instance = (_a = echartsRef === null || echartsRef === void 0 ? void 0 : echartsRef.current) === null || _a === void 0 ? void 0 : _a.getEchartsInstance();
|
|
1245
|
+
|
|
1246
|
+
if (instance && onClick) {
|
|
1247
|
+
instance.on("click", onClick);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
return () => {
|
|
1251
|
+
if (instance && !instance.isDisposed()) {
|
|
1252
|
+
instance.off("click", onClick);
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
}, [onClick, echartsRef]);
|
|
1256
|
+
|
|
1257
|
+
const getTypesafeDimension = dimension => {
|
|
1258
|
+
if (typeof dimension === "string") {
|
|
1259
|
+
return dimension;
|
|
1260
|
+
} else if (typeof dimension === "number") {
|
|
1261
|
+
return `${dimension}px`;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
return "auto";
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
const classDimensions = React.useMemo(() => {
|
|
1268
|
+
var _a, _b;
|
|
1269
|
+
|
|
1270
|
+
const height = (_a = style === null || style === void 0 ? void 0 : style.height) !== null && _a !== void 0 ? _a : "300px";
|
|
1271
|
+
const width = (_b = style === null || style === void 0 ? void 0 : style.width) !== null && _b !== void 0 ? _b : "100%";
|
|
1272
|
+
return `h-[${getTypesafeDimension(height)}] w-[${getTypesafeDimension(width)}]`;
|
|
1273
|
+
}, [style === null || style === void 0 ? void 0 : style.height, style === null || style === void 0 ? void 0 : style.width]);
|
|
1274
|
+
return jsx(ChartContainer, {
|
|
1275
|
+
children: showLoading ? jsxs(SpinnerContainer, Object.assign({
|
|
1276
|
+
dimensions: classDimensions
|
|
1277
|
+
}, {
|
|
1278
|
+
children: [jsx(Spinner, {
|
|
1279
|
+
centered: true
|
|
1280
|
+
}), (loadingOption === null || loadingOption === void 0 ? void 0 : loadingOption.text) && jsx(Text, Object.assign({
|
|
1281
|
+
align: "center",
|
|
1282
|
+
subtle: true
|
|
1283
|
+
}, {
|
|
1284
|
+
children: loadingOption.text
|
|
1285
|
+
}))]
|
|
1286
|
+
})) : jsxs(Fragment, {
|
|
1287
|
+
children: [jsx(EChart, {
|
|
1288
|
+
ref: echartsRef,
|
|
1289
|
+
option: options,
|
|
1290
|
+
opts: {
|
|
1291
|
+
width: "auto",
|
|
1292
|
+
height: "auto",
|
|
1293
|
+
renderer: renderer
|
|
1294
|
+
},
|
|
1295
|
+
notMerge: !merge,
|
|
1296
|
+
onEvents: eventHandlers,
|
|
1297
|
+
className: className,
|
|
1298
|
+
style: style,
|
|
1299
|
+
onChartReady: onChartReady
|
|
1300
|
+
}), timezoneLabel]
|
|
1301
|
+
})
|
|
1302
|
+
});
|
|
1303
|
+
};
|
|
1304
|
+
const SpinnerContainer = tw.div`
|
|
1305
|
+
chart-spinner-container
|
|
1306
|
+
${p => `${p.dimensions}`}
|
|
1307
|
+
`;
|
|
1308
|
+
const ChartContainer = tw.div`
|
|
1309
|
+
chart-container
|
|
1310
|
+
`;
|
|
1311
|
+
|
|
1312
|
+
const CheckIcon = ({
|
|
1313
|
+
className
|
|
1314
|
+
}) => {
|
|
1315
|
+
return jsx("svg", Object.assign({
|
|
1316
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1317
|
+
className: className,
|
|
1318
|
+
fill: "none",
|
|
1319
|
+
viewBox: "0 0 10 10",
|
|
1320
|
+
stroke: "currentColor",
|
|
1321
|
+
strokeWidth: "2"
|
|
1322
|
+
}, {
|
|
1323
|
+
children: jsx("path", {
|
|
1324
|
+
strokeLinecap: "round",
|
|
1325
|
+
strokeLinejoin: "round",
|
|
1326
|
+
d: "m2 5.5 2 2L8.5 3"
|
|
1327
|
+
})
|
|
1328
|
+
}));
|
|
1329
|
+
};
|
|
1330
|
+
|
|
1331
|
+
const IndeterminateIcon = ({
|
|
1332
|
+
className
|
|
1333
|
+
}) => jsx("svg", Object.assign({
|
|
1334
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1335
|
+
className: className,
|
|
1336
|
+
fill: "none",
|
|
1337
|
+
viewBox: "0 0 10 10",
|
|
1338
|
+
stroke: "currentColor",
|
|
1339
|
+
strokeWidth: "2"
|
|
1340
|
+
}, {
|
|
1341
|
+
children: jsx("path", {
|
|
1342
|
+
strokeLinecap: "round",
|
|
1343
|
+
strokeLinejoin: "round",
|
|
1344
|
+
d: "M3 5h4"
|
|
1345
|
+
})
|
|
1346
|
+
}));
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* A base checkbox component that can be used for boolean inputs, selectors etc.
|
|
1350
|
+
* A reference to the input element is provided as the `ref` prop.
|
|
1351
|
+
* Extends props from [React.InputHTMLAttributes](https://reactjs.org/docs/dom-elements.html#input)
|
|
1352
|
+
*/
|
|
1353
|
+
|
|
1354
|
+
const Checkbox = React.forwardRef((_a, ref) => {
|
|
1355
|
+
var {
|
|
1356
|
+
className,
|
|
1357
|
+
dataTestId,
|
|
1358
|
+
onChange,
|
|
1359
|
+
checked = false,
|
|
1360
|
+
disabled = false,
|
|
1361
|
+
isInvalid = false,
|
|
1362
|
+
readOnly,
|
|
1363
|
+
indeterminate = false,
|
|
1364
|
+
children,
|
|
1365
|
+
label,
|
|
1366
|
+
tabIndex = 0
|
|
1367
|
+
} = _a,
|
|
1368
|
+
rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "children", "label", "tabIndex"]);
|
|
1369
|
+
|
|
1370
|
+
const icon = indeterminate ? jsx(StyledIndeterminateIcon, {}) : checked && jsx(StyledCheckIcon, {});
|
|
1371
|
+
const internalRef = React.useRef(null);
|
|
1372
|
+
|
|
1373
|
+
const onKeyPress = e => {
|
|
1374
|
+
var _a;
|
|
1375
|
+
|
|
1376
|
+
if ("Space" === e.code) {
|
|
1377
|
+
(_a = internalRef === null || internalRef === void 0 ? void 0 : internalRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
const uuid = rest.id ? rest.id : v4();
|
|
1382
|
+
return jsxs(CheckboxContainer, Object.assign({
|
|
1383
|
+
"data-testid": `${dataTestId}Container`,
|
|
1384
|
+
htmlFor: uuid,
|
|
1385
|
+
className: className
|
|
1386
|
+
}, {
|
|
1387
|
+
children: [jsx(HiddenInput$1, Object.assign({
|
|
1388
|
+
type: "checkbox",
|
|
1389
|
+
checked: !indeterminate && checked,
|
|
1390
|
+
onChange: onChange,
|
|
1391
|
+
disabled: disabled,
|
|
1392
|
+
"data-testid": dataTestId,
|
|
1393
|
+
readOnly: readOnly,
|
|
1394
|
+
"aria-checked": !indeterminate && checked,
|
|
1395
|
+
role: "checkbox",
|
|
1396
|
+
id: uuid
|
|
1397
|
+
}, rest, {
|
|
1398
|
+
ref: ref
|
|
1399
|
+
})), jsx(CheckboxWrapper, Object.assign({
|
|
1400
|
+
"$disabled": disabled,
|
|
1401
|
+
"$checked": checked,
|
|
1402
|
+
"$indeterminate": indeterminate,
|
|
1403
|
+
"$isInvalid": disabled ? false : isInvalid,
|
|
1404
|
+
className: className,
|
|
1405
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
1406
|
+
onKeyPress: onKeyPress
|
|
1407
|
+
}, {
|
|
1408
|
+
children: icon
|
|
1409
|
+
})), label && jsx(Label$4, Object.assign({
|
|
1410
|
+
ref: internalRef,
|
|
1411
|
+
htmlFor: uuid,
|
|
1412
|
+
"$disabled": disabled,
|
|
1413
|
+
"$isInvalid": disabled ? false : isInvalid,
|
|
1414
|
+
"data-testid": dataTestId ? `${dataTestId}Label` : ""
|
|
1415
|
+
}, {
|
|
1416
|
+
children: label
|
|
1417
|
+
})), children]
|
|
1418
|
+
}));
|
|
1419
|
+
});
|
|
1420
|
+
Checkbox.displayName = "Checkbox";
|
|
1421
|
+
const StyledCheckIcon = tw(CheckIcon)`
|
|
1422
|
+
checkbox--icon
|
|
1423
|
+
`;
|
|
1424
|
+
const StyledIndeterminateIcon = tw(IndeterminateIcon)`
|
|
1425
|
+
checkbox--icon
|
|
1426
|
+
`;
|
|
1427
|
+
const CheckboxWrapper = tw.span`
|
|
1428
|
+
checkbox
|
|
1429
|
+
${({
|
|
1430
|
+
$checked,
|
|
1431
|
+
$disabled,
|
|
1432
|
+
$indeterminate
|
|
1433
|
+
}) => {
|
|
1434
|
+
if ($disabled) {
|
|
1435
|
+
return tws`checkbox--disabled`;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
return $indeterminate ? tws`checkbox--indeterminate` : $checked ? tws`checkbox--selected` : tws`checkbox--deselected`;
|
|
1439
|
+
}}
|
|
1440
|
+
|
|
1441
|
+
${({
|
|
1442
|
+
$isInvalid
|
|
1443
|
+
}) => {
|
|
1444
|
+
if ($isInvalid) {
|
|
1445
|
+
return tws`checkbox--invalid`;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
return tws``;
|
|
1449
|
+
}}
|
|
1450
|
+
`;
|
|
1451
|
+
const HiddenInput$1 = tw.input`
|
|
1452
|
+
checkbox--input
|
|
1453
|
+
`;
|
|
1454
|
+
const CheckboxContainer = tw.label`
|
|
1455
|
+
checkbox--container group
|
|
1456
|
+
`;
|
|
1457
|
+
const Label$4 = tw.label`
|
|
1458
|
+
checkbox__label
|
|
1459
|
+
${({
|
|
1460
|
+
$disabled
|
|
1461
|
+
}) => $disabled ? tws`checkbox-item--disabled` : null}
|
|
1462
|
+
${({
|
|
1463
|
+
$isInvalid
|
|
1464
|
+
}) => $isInvalid ? tws`checkbox--invalid` : null}
|
|
1465
|
+
`;
|
|
1466
|
+
|
|
1467
|
+
const Collapse = ({
|
|
1468
|
+
id,
|
|
1469
|
+
initialExpanded = false,
|
|
1470
|
+
onToggle,
|
|
1471
|
+
label,
|
|
1472
|
+
children,
|
|
1473
|
+
className,
|
|
1474
|
+
dataTestId
|
|
1475
|
+
}) => {
|
|
1476
|
+
const [expanded, setExpanded] = React.useState(initialExpanded);
|
|
1477
|
+
const handleClick = React.useCallback(e => {
|
|
1478
|
+
if (onToggle) {
|
|
1479
|
+
onToggle(e, !expanded);
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
setExpanded(!expanded);
|
|
1483
|
+
}, [expanded, onToggle]);
|
|
1484
|
+
return jsxs(StyledCollapse, Object.assign({
|
|
1485
|
+
className: className,
|
|
1486
|
+
"data-testid": dataTestId
|
|
1487
|
+
}, {
|
|
1488
|
+
children: [jsx(CollapseLabel, Object.assign({
|
|
1489
|
+
role: "button",
|
|
1490
|
+
"aria-expanded": expanded,
|
|
1491
|
+
"aria-controls": id,
|
|
1492
|
+
onClick: handleClick
|
|
1493
|
+
}, {
|
|
1494
|
+
children: jsxs(LabelContainer, {
|
|
1495
|
+
children: [jsx(Text, Object.assign({
|
|
1496
|
+
weight: "bold"
|
|
1497
|
+
}, {
|
|
1498
|
+
children: label
|
|
1499
|
+
})), jsx(IconButton, {
|
|
1500
|
+
icon: jsx(Rotate, {
|
|
1501
|
+
name: "ChevronDownIcon",
|
|
1502
|
+
size: "small",
|
|
1503
|
+
"$expanded": expanded
|
|
1504
|
+
}),
|
|
1505
|
+
size: "normal",
|
|
1506
|
+
variant: "transparent",
|
|
1507
|
+
intent: "secondary"
|
|
1508
|
+
})]
|
|
1509
|
+
})
|
|
1510
|
+
})), jsx(Collapsible, Object.assign({
|
|
1511
|
+
expanded: expanded,
|
|
1512
|
+
id: id
|
|
1513
|
+
}, {
|
|
1514
|
+
children: children
|
|
1515
|
+
}))]
|
|
1516
|
+
}));
|
|
1517
|
+
};
|
|
1518
|
+
const Rotate = tw(Icon$1)`
|
|
1519
|
+
${p => p.$expanded ? tws`icon--animated-rotate-expanded` : null}
|
|
1520
|
+
icon--animated-rotate
|
|
1521
|
+
`;
|
|
1522
|
+
const StyledCollapse = tw.div`
|
|
1523
|
+
collapse
|
|
1524
|
+
`;
|
|
1525
|
+
const CollapseLabel = tw.div`
|
|
1526
|
+
collapse__label
|
|
1527
|
+
`;
|
|
1528
|
+
const LabelContainer = tw.div`
|
|
1529
|
+
collapse__label__container
|
|
1530
|
+
`;
|
|
1531
|
+
|
|
1532
|
+
const Collapsible = ({
|
|
1533
|
+
children,
|
|
1534
|
+
expanded,
|
|
1535
|
+
id
|
|
1536
|
+
}) => {
|
|
1537
|
+
const [ref, {
|
|
1538
|
+
height
|
|
1539
|
+
}] = useMeasure();
|
|
1540
|
+
const props = useSpring({
|
|
1541
|
+
config: {
|
|
1542
|
+
tension: expanded ? 2000 : 1500,
|
|
1543
|
+
friction: 100,
|
|
1544
|
+
precision: 0.01
|
|
1545
|
+
},
|
|
1546
|
+
from: {
|
|
1547
|
+
height: 0
|
|
1548
|
+
},
|
|
1549
|
+
to: expanded ? {
|
|
1550
|
+
// We add 8 pixels to the bottom to prevent overflow issues.
|
|
1551
|
+
height: height + 8
|
|
1552
|
+
} : {
|
|
1553
|
+
height: 0
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
return jsx(AnimatedCollapsible, Object.assign({
|
|
1557
|
+
id: id,
|
|
1558
|
+
style: props
|
|
1559
|
+
}, {
|
|
1560
|
+
children: jsx(StyledCollapsible, Object.assign({
|
|
1561
|
+
ref: ref
|
|
1562
|
+
}, {
|
|
1563
|
+
children: children
|
|
1564
|
+
}))
|
|
1565
|
+
}));
|
|
1566
|
+
};
|
|
1567
|
+
|
|
1568
|
+
const AnimatedCollapsible = tw(animated.div)`
|
|
1569
|
+
collapsible--animated
|
|
1570
|
+
`;
|
|
1571
|
+
const StyledCollapsible = tw.div`
|
|
1572
|
+
collapsible
|
|
1573
|
+
`;
|
|
1574
|
+
|
|
1575
|
+
const CopyableText = ({
|
|
1576
|
+
text,
|
|
1577
|
+
alternativeText,
|
|
1578
|
+
dataTestId
|
|
1579
|
+
}) => {
|
|
1580
|
+
const value = useMemo(() => {
|
|
1581
|
+
var _a;
|
|
1582
|
+
|
|
1583
|
+
return (_a = alternativeText !== null && alternativeText !== void 0 ? alternativeText : text) !== null && _a !== void 0 ? _a : "";
|
|
1584
|
+
}, [alternativeText, text]);
|
|
1585
|
+
const [animating, setAnimating] = useState(false);
|
|
1586
|
+
const [, copyToClipboard] = useCopyToClipboard();
|
|
1587
|
+
|
|
1588
|
+
const handleOnClick = () => {
|
|
1589
|
+
copyToClipboard(value);
|
|
1590
|
+
setAnimating(true);
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1593
|
+
return jsx(CopyableTextContainer, Object.assign({
|
|
1594
|
+
"data-testid": dataTestId,
|
|
1595
|
+
onClick: handleOnClick,
|
|
1596
|
+
onAnimationEnd: () => setAnimating(false),
|
|
1597
|
+
"$animating": animating
|
|
1598
|
+
}, {
|
|
1599
|
+
children: text
|
|
1600
|
+
}));
|
|
1601
|
+
};
|
|
1602
|
+
const CopyableTextContainer = tw.span`
|
|
1603
|
+
py-1
|
|
1604
|
+
px-2
|
|
1605
|
+
border
|
|
1606
|
+
border-dashed
|
|
1607
|
+
border-neutral-600
|
|
1608
|
+
rounded
|
|
1609
|
+
cursor-pointer
|
|
1610
|
+
inline
|
|
1611
|
+
transition-all
|
|
1612
|
+
ease-in-out
|
|
1613
|
+
leading-7
|
|
1614
|
+
break-words
|
|
1615
|
+
${p => p.$animating ? tws`animate-copy` : null}`;
|
|
1616
|
+
|
|
1617
|
+
const localeLookup = {
|
|
1618
|
+
en: enGB,
|
|
1619
|
+
"en-US": enUS,
|
|
1620
|
+
"en-GB": enGB,
|
|
1621
|
+
da,
|
|
1622
|
+
de,
|
|
1623
|
+
cs,
|
|
1624
|
+
nl,
|
|
1625
|
+
fr,
|
|
1626
|
+
fi,
|
|
1627
|
+
hu,
|
|
1628
|
+
it,
|
|
1629
|
+
nb,
|
|
1630
|
+
pl,
|
|
1631
|
+
pt,
|
|
1632
|
+
ru,
|
|
1633
|
+
ro,
|
|
1634
|
+
es,
|
|
1635
|
+
sv,
|
|
1636
|
+
ja,
|
|
1637
|
+
th
|
|
1638
|
+
};
|
|
1639
|
+
const useLocale = language => {
|
|
1640
|
+
return localeLookup[language] || localeLookup.en;
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
const DayPicker = _a => {
|
|
1644
|
+
var {
|
|
1645
|
+
onDaySelect,
|
|
1646
|
+
disabledDays,
|
|
1647
|
+
selectedDays,
|
|
1648
|
+
language
|
|
1649
|
+
} = _a,
|
|
1650
|
+
rest = __rest(_a, ["onDaySelect", "disabledDays", "selectedDays", "language"]);
|
|
1651
|
+
|
|
1652
|
+
const locale = useLocale(language);
|
|
1653
|
+
return jsx(DayPicker$1, Object.assign({
|
|
1654
|
+
onDayClick: onDaySelect,
|
|
1655
|
+
selected: selectedDays,
|
|
1656
|
+
locale: locale,
|
|
1657
|
+
disabled: disabledDays,
|
|
1658
|
+
className: "custom-day-picker"
|
|
1659
|
+
}, rest));
|
|
1660
|
+
};
|
|
1661
|
+
|
|
1662
|
+
var PopoverLifecycle;
|
|
1663
|
+
|
|
1664
|
+
(function (PopoverLifecycle) {
|
|
1665
|
+
PopoverLifecycle["closed"] = "closed";
|
|
1666
|
+
PopoverLifecycle["open"] = "open";
|
|
1667
|
+
PopoverLifecycle["closing"] = "closing";
|
|
1668
|
+
})(PopoverLifecycle || (PopoverLifecycle = {}));
|
|
1669
|
+
|
|
1670
|
+
const usePopover = ({
|
|
1671
|
+
targetRef,
|
|
1672
|
+
popoverRef,
|
|
1673
|
+
placement = "bottom-start",
|
|
1674
|
+
offset = [0, 8]
|
|
1675
|
+
}) => {
|
|
1676
|
+
const [lifecycle, setLifecycle] = React.useState(PopoverLifecycle.closed);
|
|
1677
|
+
const popperRef = React.useRef(null);
|
|
1678
|
+
React.useLayoutEffect(() => {
|
|
1679
|
+
if (targetRef.current && popoverRef.current) {
|
|
1680
|
+
popperRef.current = createPopper(targetRef.current, popoverRef.current, {
|
|
1681
|
+
placement,
|
|
1682
|
+
strategy: "fixed",
|
|
1683
|
+
modifiers: [{
|
|
1684
|
+
name: "offset",
|
|
1685
|
+
options: {
|
|
1686
|
+
offset
|
|
1687
|
+
}
|
|
1688
|
+
}]
|
|
1689
|
+
});
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
return () => {
|
|
1693
|
+
var _a;
|
|
1694
|
+
|
|
1695
|
+
(_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1696
|
+
};
|
|
1697
|
+
}, [popoverRef, targetRef, lifecycle, placement, offset]);
|
|
1698
|
+
|
|
1699
|
+
const onShow = () => {
|
|
1700
|
+
if (lifecycle !== PopoverLifecycle.open) {
|
|
1701
|
+
setLifecycle(PopoverLifecycle.open);
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
|
|
1705
|
+
const onHide = () => {
|
|
1706
|
+
setLifecycle(PopoverLifecycle.closing);
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
const onClosed = () => {
|
|
1710
|
+
setLifecycle(PopoverLifecycle.closed);
|
|
1711
|
+
};
|
|
1712
|
+
|
|
1713
|
+
return {
|
|
1714
|
+
targetRef,
|
|
1715
|
+
popoverRef,
|
|
1716
|
+
onShow,
|
|
1717
|
+
onHide,
|
|
1718
|
+
popoverProps: {
|
|
1719
|
+
lifecycle,
|
|
1720
|
+
onClosed
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1723
|
+
};
|
|
1724
|
+
|
|
1725
|
+
const AnimatedPopover = React.forwardRef(({
|
|
1726
|
+
lifecycle,
|
|
1727
|
+
onRequestClose,
|
|
1728
|
+
children,
|
|
1729
|
+
onClosed,
|
|
1730
|
+
enterDelay,
|
|
1731
|
+
exitDelay,
|
|
1732
|
+
className,
|
|
1733
|
+
dataTestId,
|
|
1734
|
+
bindTo,
|
|
1735
|
+
enableBackdrop = true
|
|
1736
|
+
}, ref) => {
|
|
1737
|
+
const {
|
|
1738
|
+
Portal
|
|
1739
|
+
} = usePortal({
|
|
1740
|
+
bindTo
|
|
1741
|
+
});
|
|
1742
|
+
|
|
1743
|
+
const onClose = e => {
|
|
1744
|
+
if (lifecycle === PopoverLifecycle.open) {
|
|
1745
|
+
e.preventDefault();
|
|
1746
|
+
e.stopPropagation();
|
|
1747
|
+
onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
|
|
1748
|
+
}
|
|
1749
|
+
};
|
|
1750
|
+
|
|
1751
|
+
useKeyPressEvent("Escape", onClose);
|
|
1752
|
+
|
|
1753
|
+
if (lifecycle === PopoverLifecycle.closed) {
|
|
1754
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
1755
|
+
return jsx(Fragment, {});
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
return jsxs(Portal, {
|
|
1759
|
+
children: [lifecycle !== PopoverLifecycle.closing && enableBackdrop && jsx(Backdrop$1, {
|
|
1760
|
+
onClick: onClose
|
|
1761
|
+
}), jsx(StyledContainer, Object.assign({
|
|
1762
|
+
ref: ref,
|
|
1763
|
+
className: className,
|
|
1764
|
+
"data-testid": dataTestId
|
|
1765
|
+
}, {
|
|
1766
|
+
children: jsx(AnimatedContainer, Object.assign({
|
|
1767
|
+
lifecycle: lifecycle,
|
|
1768
|
+
onClosed: onClosed,
|
|
1769
|
+
enterDelay: enterDelay,
|
|
1770
|
+
exitDelay: exitDelay
|
|
1771
|
+
}, {
|
|
1772
|
+
children: children
|
|
1773
|
+
}))
|
|
1774
|
+
}))]
|
|
1775
|
+
});
|
|
1776
|
+
});
|
|
1777
|
+
AnimatedPopover.displayName = "AnimatedPopover";
|
|
1778
|
+
const Backdrop$1 = tw.div`
|
|
1779
|
+
fixed
|
|
1780
|
+
inset-0
|
|
1781
|
+
z-popover
|
|
1782
|
+
`;
|
|
1783
|
+
|
|
1784
|
+
const AnimatedContainer = ({
|
|
1785
|
+
lifecycle,
|
|
1786
|
+
onClosed,
|
|
1787
|
+
enterDelay = 0,
|
|
1788
|
+
exitDelay = 0,
|
|
1789
|
+
children
|
|
1790
|
+
}) => {
|
|
1791
|
+
const props = useSpring({
|
|
1792
|
+
config: {
|
|
1793
|
+
tension: lifecycle === PopoverLifecycle.closing ? 2000 : 1500,
|
|
1794
|
+
friction: 100,
|
|
1795
|
+
precision: 0.1
|
|
1796
|
+
},
|
|
1797
|
+
from: {
|
|
1798
|
+
opacity: 0,
|
|
1799
|
+
transform: "scale(0.98)"
|
|
1800
|
+
},
|
|
1801
|
+
to: lifecycle === PopoverLifecycle.open ? {
|
|
1802
|
+
opacity: 1,
|
|
1803
|
+
transform: "scale(1)"
|
|
1804
|
+
} : lifecycle === PopoverLifecycle.closing ? {
|
|
1805
|
+
opacity: 0,
|
|
1806
|
+
transform: "scale(0.98)"
|
|
1807
|
+
} : {},
|
|
1808
|
+
delay: lifecycle === PopoverLifecycle.open ? enterDelay : exitDelay,
|
|
1809
|
+
onRest: () => lifecycle === PopoverLifecycle.closing && (onClosed === null || onClosed === void 0 ? void 0 : onClosed())
|
|
1810
|
+
});
|
|
1811
|
+
return jsx(animated.div, Object.assign({
|
|
1812
|
+
style: props
|
|
1813
|
+
}, {
|
|
1814
|
+
children: children
|
|
1815
|
+
}));
|
|
1816
|
+
};
|
|
1817
|
+
|
|
1818
|
+
const StyledContainer = tw.div`
|
|
1819
|
+
z-[21]
|
|
1820
|
+
`;
|
|
1821
|
+
|
|
1822
|
+
const PopoverList = ({
|
|
1823
|
+
className,
|
|
1824
|
+
children,
|
|
1825
|
+
dataTestId
|
|
1826
|
+
}) => {
|
|
1827
|
+
return jsx(Card, Object.assign({
|
|
1828
|
+
className: className,
|
|
1829
|
+
dataTestId: dataTestId
|
|
1830
|
+
}, {
|
|
1831
|
+
children: jsx(StyledCardBody, Object.assign({
|
|
1832
|
+
density: "comfortable"
|
|
1833
|
+
}, {
|
|
1834
|
+
children: jsx(List, {
|
|
1835
|
+
children: children
|
|
1836
|
+
})
|
|
1837
|
+
}))
|
|
1838
|
+
}));
|
|
1839
|
+
};
|
|
1840
|
+
const List = tw.ul`
|
|
1841
|
+
list-none
|
|
1842
|
+
p-0
|
|
1843
|
+
m-0
|
|
1844
|
+
`;
|
|
1845
|
+
const StyledCardBody = tw(CardBody)`
|
|
1846
|
+
max-h-full
|
|
1847
|
+
`;
|
|
1848
|
+
|
|
1849
|
+
const DateField = forwardRef(({
|
|
1850
|
+
defaultValue,
|
|
1851
|
+
onChange,
|
|
1852
|
+
disabled = false,
|
|
1853
|
+
id,
|
|
1854
|
+
dataTestId,
|
|
1855
|
+
placeholder,
|
|
1856
|
+
disabledDays,
|
|
1857
|
+
preventDeselect = false
|
|
1858
|
+
}, ref) => {
|
|
1859
|
+
const [selectedDay, setSelectedDay] = useState(defaultValue ? new Date(defaultValue) : undefined);
|
|
1860
|
+
const onChangeHandler = useCallback(value => {
|
|
1861
|
+
const newValue = (value === null || value === void 0 ? void 0 : value.toLocaleDateString()) === (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) && !preventDeselect ? undefined : value;
|
|
1862
|
+
setSelectedDay(newValue);
|
|
1863
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
1864
|
+
}, [setSelectedDay, onChange, selectedDay, preventDeselect]);
|
|
1865
|
+
const target = useRef(null);
|
|
1866
|
+
const popover = useRef(null);
|
|
1867
|
+
const {
|
|
1868
|
+
popoverRef,
|
|
1869
|
+
targetRef,
|
|
1870
|
+
onShow,
|
|
1871
|
+
onHide,
|
|
1872
|
+
popoverProps
|
|
1873
|
+
} = usePopover({
|
|
1874
|
+
targetRef: target,
|
|
1875
|
+
popoverRef: popover,
|
|
1876
|
+
placement: "bottom"
|
|
1877
|
+
});
|
|
1878
|
+
return jsxs(Fragment, {
|
|
1879
|
+
children: [jsx(BaseInput, {
|
|
1880
|
+
placeholder: placeholder,
|
|
1881
|
+
value: (selectedDay === null || selectedDay === void 0 ? void 0 : selectedDay.toLocaleDateString()) || "",
|
|
1882
|
+
onChange: () => {},
|
|
1883
|
+
disabled: disabled,
|
|
1884
|
+
dataTestId: dataTestId,
|
|
1885
|
+
id: id,
|
|
1886
|
+
ref: ref,
|
|
1887
|
+
suffix: jsx(Icon$1, {
|
|
1888
|
+
dataTestId: "calendar",
|
|
1889
|
+
name: "CalendarIcon",
|
|
1890
|
+
size: "normal",
|
|
1891
|
+
type: "solid",
|
|
1892
|
+
onClick: !disabled ? onShow : undefined,
|
|
1893
|
+
forwardedRef: targetRef
|
|
1894
|
+
})
|
|
1895
|
+
}), jsx(AnimatedPopover, Object.assign({
|
|
1896
|
+
ref: popoverRef,
|
|
1897
|
+
onRequestClose: () => {
|
|
1898
|
+
var _a;
|
|
1899
|
+
|
|
1900
|
+
onHide();
|
|
1901
|
+
(_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
1902
|
+
}
|
|
1903
|
+
}, popoverProps, {
|
|
1904
|
+
children: jsx(PopoverList, {
|
|
1905
|
+
children: jsx(DayPicker, {
|
|
1906
|
+
onDaySelect: onChangeHandler,
|
|
1907
|
+
disabledDays: disabledDays,
|
|
1908
|
+
selectedDays: selectedDay,
|
|
1909
|
+
language: navigator.language
|
|
1910
|
+
})
|
|
1911
|
+
})
|
|
1912
|
+
}))]
|
|
1913
|
+
});
|
|
1914
|
+
});
|
|
1915
|
+
|
|
1916
|
+
const PopoverListItem = ({
|
|
1917
|
+
selected,
|
|
1918
|
+
children,
|
|
1919
|
+
disabled,
|
|
1920
|
+
ariaLabel,
|
|
1921
|
+
url,
|
|
1922
|
+
onClick,
|
|
1923
|
+
prefix,
|
|
1924
|
+
suffix,
|
|
1925
|
+
renderAs,
|
|
1926
|
+
dataTestId
|
|
1927
|
+
}) => {
|
|
1928
|
+
const content = jsxs("div", Object.assign({
|
|
1929
|
+
className: "flex items-center gap-3"
|
|
1930
|
+
}, {
|
|
1931
|
+
children: [prefix && jsx("div", {
|
|
1932
|
+
children: prefix
|
|
1933
|
+
}), jsx(StyledText$1, Object.assign({
|
|
1934
|
+
weight: selected ? "bold" : "default",
|
|
1935
|
+
"$selected": selected
|
|
1936
|
+
}, {
|
|
1937
|
+
children: children
|
|
1938
|
+
})), suffix && jsx("div", {
|
|
1939
|
+
children: suffix
|
|
1940
|
+
})]
|
|
1941
|
+
}));
|
|
1942
|
+
|
|
1943
|
+
return jsx(ListItem, Object.assign({
|
|
1944
|
+
"$selected": selected,
|
|
1945
|
+
disabled: disabled,
|
|
1946
|
+
onClick: onClick,
|
|
1947
|
+
"aria-label": ariaLabel,
|
|
1948
|
+
"data-testid": dataTestId
|
|
1949
|
+
}, {
|
|
1950
|
+
children: url ? jsx(UnstyledAnchor, Object.assign({
|
|
1951
|
+
"$as": renderAs,
|
|
1952
|
+
to: url
|
|
1953
|
+
}, {
|
|
1954
|
+
children: content
|
|
1955
|
+
})) : content
|
|
1956
|
+
}));
|
|
1957
|
+
};
|
|
1958
|
+
const StyledText$1 = tw(Text)`
|
|
1959
|
+
${p => p.$selected ? tws`text-primary-600` : tws`text-neutral-600`}
|
|
1960
|
+
group-hover:text-primary-500
|
|
1961
|
+
`;
|
|
1962
|
+
const ListItem = tw.li`
|
|
1963
|
+
group
|
|
1964
|
+
cursor-pointer
|
|
1965
|
+
whitespace-nowrap
|
|
1966
|
+
py-1
|
|
1967
|
+
px-2
|
|
1968
|
+
${p => !p.disabled ? tws`hover:bg-neutral-50` : null}
|
|
1969
|
+
`;
|
|
1970
|
+
const UnstyledAnchor = tw.a`
|
|
1971
|
+
block
|
|
1972
|
+
w-full
|
|
1973
|
+
text-inherit
|
|
1974
|
+
`;
|
|
1975
|
+
|
|
1976
|
+
const PopoverTitle = ({
|
|
1977
|
+
children,
|
|
1978
|
+
action,
|
|
1979
|
+
divider = false,
|
|
1980
|
+
className,
|
|
1981
|
+
dataTestId
|
|
1982
|
+
}) => {
|
|
1983
|
+
return jsxs(Container$5, Object.assign({
|
|
1984
|
+
"$divider": divider,
|
|
1985
|
+
className: className,
|
|
1986
|
+
"data-testid": dataTestId
|
|
1987
|
+
}, {
|
|
1988
|
+
children: [jsx(StyledText, Object.assign({
|
|
1989
|
+
type: "div",
|
|
1990
|
+
subtle: true,
|
|
1991
|
+
size: "small",
|
|
1992
|
+
weight: "bold",
|
|
1993
|
+
uppercase: true
|
|
1994
|
+
}, {
|
|
1995
|
+
children: children
|
|
1996
|
+
})), action]
|
|
1997
|
+
}));
|
|
1998
|
+
};
|
|
1999
|
+
const Container$5 = tw.div`
|
|
2000
|
+
flex
|
|
2001
|
+
items-center
|
|
2002
|
+
px-2
|
|
2003
|
+
py-1
|
|
2004
|
+
|
|
2005
|
+
${p => p.$divider ? `
|
|
2006
|
+
border-b
|
|
2007
|
+
border-solid
|
|
2008
|
+
border-b-neutral-100
|
|
2009
|
+
mb-1
|
|
2010
|
+
` : null}
|
|
2011
|
+
`;
|
|
2012
|
+
const StyledText = tw(Text)`
|
|
2013
|
+
flex-1
|
|
2014
|
+
text-neutral-500
|
|
2015
|
+
`;
|
|
2016
|
+
|
|
2017
|
+
const DayPickerPopover = ({
|
|
2018
|
+
disabledDays,
|
|
2019
|
+
className,
|
|
2020
|
+
selectedDay,
|
|
2021
|
+
onDaySelect,
|
|
2022
|
+
intent = "secondary",
|
|
2023
|
+
placement = "bottom",
|
|
2024
|
+
size = "small",
|
|
2025
|
+
buttonContent,
|
|
2026
|
+
language
|
|
2027
|
+
}) => {
|
|
2028
|
+
const target = useRef(null);
|
|
2029
|
+
const popover = useRef(null);
|
|
2030
|
+
const {
|
|
2031
|
+
popoverRef,
|
|
2032
|
+
targetRef,
|
|
2033
|
+
onShow,
|
|
2034
|
+
onHide,
|
|
2035
|
+
popoverProps
|
|
2036
|
+
} = usePopover({
|
|
2037
|
+
targetRef: target,
|
|
2038
|
+
popoverRef: popover,
|
|
2039
|
+
placement: placement
|
|
2040
|
+
});
|
|
2041
|
+
return jsxs(Fragment$1, {
|
|
2042
|
+
children: [jsx(Button, Object.assign({
|
|
2043
|
+
intent: intent,
|
|
2044
|
+
size: size,
|
|
2045
|
+
className: className,
|
|
2046
|
+
prefix: jsx(Icon$1, {
|
|
2047
|
+
name: "CalendarIcon",
|
|
2048
|
+
size: "small"
|
|
2049
|
+
}),
|
|
2050
|
+
ref: targetRef,
|
|
2051
|
+
onClick: onShow
|
|
2052
|
+
}, {
|
|
2053
|
+
children: buttonContent
|
|
2054
|
+
})), jsx(AnimatedPopover, Object.assign({
|
|
2055
|
+
ref: popoverRef,
|
|
2056
|
+
onRequestClose: () => {
|
|
2057
|
+
var _a;
|
|
2058
|
+
|
|
2059
|
+
onHide();
|
|
2060
|
+
(_a = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
2061
|
+
}
|
|
2062
|
+
}, popoverProps, {
|
|
2063
|
+
children: jsx(PopoverList, {
|
|
2064
|
+
children: jsx(DayPicker, {
|
|
2065
|
+
disabledDays: disabledDays,
|
|
2066
|
+
onDaySelect: onDaySelect,
|
|
2067
|
+
selectedDays: selectedDay,
|
|
2068
|
+
language: language
|
|
2069
|
+
})
|
|
2070
|
+
})
|
|
2071
|
+
}))]
|
|
2072
|
+
});
|
|
2073
|
+
};
|
|
2074
|
+
|
|
2075
|
+
const DayRangePicker = ({
|
|
2076
|
+
onRangeSelect,
|
|
2077
|
+
selectedDays,
|
|
2078
|
+
disabledDays,
|
|
2079
|
+
dataTestId,
|
|
2080
|
+
language
|
|
2081
|
+
}) => {
|
|
2082
|
+
const locale = useLocale(language);
|
|
2083
|
+
const onSelect = useCallback(range => {
|
|
2084
|
+
if (onRangeSelect && range === undefined) {
|
|
2085
|
+
onRangeSelect(undefined);
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
if (onRangeSelect && range) {
|
|
2089
|
+
const from = range.from;
|
|
2090
|
+
const to = range.to ? range.to : range.from;
|
|
2091
|
+
onRangeSelect({
|
|
2092
|
+
from,
|
|
2093
|
+
to
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
}, [onRangeSelect]);
|
|
2097
|
+
return jsx("div", Object.assign({
|
|
2098
|
+
"data-testid": dataTestId
|
|
2099
|
+
}, {
|
|
2100
|
+
children: jsx(DayPicker$1, {
|
|
2101
|
+
mode: "range",
|
|
2102
|
+
onSelect: onSelect,
|
|
2103
|
+
selected: selectedDays,
|
|
2104
|
+
defaultMonth: selectedDays && selectedDays.from,
|
|
2105
|
+
locale: locale,
|
|
2106
|
+
disabled: disabledDays,
|
|
2107
|
+
className: "custom-day-picker range-picker"
|
|
2108
|
+
})
|
|
2109
|
+
}));
|
|
2110
|
+
};
|
|
2111
|
+
|
|
2112
|
+
const Tooltip = ({
|
|
2113
|
+
label,
|
|
2114
|
+
placement = "bottom",
|
|
2115
|
+
children,
|
|
2116
|
+
dataTestId,
|
|
2117
|
+
disabled,
|
|
2118
|
+
mode = "dark",
|
|
2119
|
+
offset,
|
|
2120
|
+
className,
|
|
2121
|
+
contentTextType = "p"
|
|
2122
|
+
}) => {
|
|
2123
|
+
const target = React.useRef(null);
|
|
2124
|
+
const popover = React.useRef(null);
|
|
2125
|
+
const {
|
|
2126
|
+
popoverRef,
|
|
2127
|
+
targetRef,
|
|
2128
|
+
onShow,
|
|
2129
|
+
onHide,
|
|
2130
|
+
popoverProps
|
|
2131
|
+
} = usePopover({
|
|
2132
|
+
targetRef: target,
|
|
2133
|
+
popoverRef: popover,
|
|
2134
|
+
placement,
|
|
2135
|
+
offset
|
|
2136
|
+
});
|
|
2137
|
+
return jsxs(Fragment, {
|
|
2138
|
+
children: [jsx(Flex$1, Object.assign({
|
|
2139
|
+
className: className,
|
|
2140
|
+
onMouseEnter: onShow,
|
|
2141
|
+
onMouseLeave: onHide,
|
|
2142
|
+
ref: targetRef,
|
|
2143
|
+
"data-testid": dataTestId && `${dataTestId}-parent`
|
|
2144
|
+
}, {
|
|
2145
|
+
children: children
|
|
2146
|
+
})), !disabled && jsx(Container$4, Object.assign({
|
|
2147
|
+
ref: popoverRef,
|
|
2148
|
+
onRequestClose: onHide,
|
|
2149
|
+
enterDelay: 450
|
|
2150
|
+
}, popoverProps, {
|
|
2151
|
+
dataTestId: dataTestId,
|
|
2152
|
+
enableBackdrop: false
|
|
2153
|
+
}, {
|
|
2154
|
+
children: jsx(Content$1, Object.assign({
|
|
2155
|
+
"$mode": mode
|
|
2156
|
+
}, {
|
|
2157
|
+
children: jsx(Text, Object.assign({
|
|
2158
|
+
inverted: mode === "dark",
|
|
2159
|
+
type: contentTextType
|
|
2160
|
+
}, {
|
|
2161
|
+
children: label
|
|
2162
|
+
}))
|
|
2163
|
+
}))
|
|
2164
|
+
}))]
|
|
2165
|
+
});
|
|
2166
|
+
};
|
|
2167
|
+
const Flex$1 = tw.div`
|
|
2168
|
+
inline-flex
|
|
2169
|
+
`;
|
|
2170
|
+
const Container$4 = tw(AnimatedPopover)`
|
|
2171
|
+
tooltip__container
|
|
2172
|
+
`;
|
|
2173
|
+
const Content$1 = tw.div`
|
|
2174
|
+
tooltip__content
|
|
2175
|
+
${p => p.$mode === "light" ? tws`tooltip--light` : null}
|
|
2176
|
+
`;
|
|
2177
|
+
|
|
2178
|
+
const Tip = _a => {
|
|
2179
|
+
var _b;
|
|
2180
|
+
|
|
2181
|
+
var {
|
|
2182
|
+
children,
|
|
2183
|
+
iconProps,
|
|
2184
|
+
tooltipProps,
|
|
2185
|
+
dataTestId
|
|
2186
|
+
} = _a,
|
|
2187
|
+
rest = __rest(_a, ["children", "iconProps", "tooltipProps", "dataTestId"]);
|
|
2188
|
+
|
|
2189
|
+
return jsx(TipContainer, Object.assign({
|
|
2190
|
+
"data-testid": dataTestId
|
|
2191
|
+
}, rest, {
|
|
2192
|
+
children: jsx(Tooltip, Object.assign({
|
|
2193
|
+
label: children,
|
|
2194
|
+
dataTestId: `${dataTestId}-tooltip`
|
|
2195
|
+
}, tooltipProps, {
|
|
2196
|
+
className: `${(_b = tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.className) !== null && _b !== void 0 ? _b : ""} ${tws`inline-flex`}`
|
|
2197
|
+
}, {
|
|
2198
|
+
children: jsx(Icon$1, Object.assign({
|
|
2199
|
+
name: "QuestionMarkCircleIcon",
|
|
2200
|
+
size: "normal",
|
|
2201
|
+
dataTestId: `${dataTestId}-icon`
|
|
2202
|
+
}, iconProps))
|
|
2203
|
+
}))
|
|
2204
|
+
}));
|
|
2205
|
+
};
|
|
2206
|
+
const TipContainer = tw.span`
|
|
2207
|
+
tip
|
|
2208
|
+
`;
|
|
2209
|
+
Tip.displayName = "Tip";
|
|
2210
|
+
|
|
2211
|
+
const FormGroup = ({
|
|
2212
|
+
isInvalid,
|
|
2213
|
+
helpText,
|
|
2214
|
+
helpAddon,
|
|
2215
|
+
tip,
|
|
2216
|
+
className,
|
|
2217
|
+
dataTestId,
|
|
2218
|
+
label,
|
|
2219
|
+
children
|
|
2220
|
+
}) => {
|
|
2221
|
+
return jsxs(FormGroupRoot, Object.assign({
|
|
2222
|
+
className: className,
|
|
2223
|
+
"data-testid": dataTestId
|
|
2224
|
+
}, {
|
|
2225
|
+
children: [jsxs(ContainerBefore, {
|
|
2226
|
+
children: [jsx(StyledTitle, Object.assign({
|
|
2227
|
+
"data-testid": `${dataTestId}-label`
|
|
2228
|
+
}, {
|
|
2229
|
+
children: label
|
|
2230
|
+
})), tip && jsx(Tip, Object.assign({
|
|
2231
|
+
dataTestId: `${dataTestId}-tip`
|
|
2232
|
+
}, {
|
|
2233
|
+
children: tip
|
|
2234
|
+
}))]
|
|
2235
|
+
}), children, jsxs(ContainerAfter, Object.assign({
|
|
2236
|
+
"$isInvalid": isInvalid
|
|
2237
|
+
}, {
|
|
2238
|
+
children: [helpText && jsx("span", Object.assign({
|
|
2239
|
+
"data-testid": `${dataTestId}-helpText`
|
|
2240
|
+
}, {
|
|
2241
|
+
children: helpText
|
|
2242
|
+
})), helpAddon && jsx(HelpAddon, Object.assign({
|
|
2243
|
+
"data-testid": `${dataTestId}-helpAddon`
|
|
2244
|
+
}, {
|
|
2245
|
+
children: helpAddon
|
|
2246
|
+
}))]
|
|
2247
|
+
}))]
|
|
2248
|
+
}));
|
|
2249
|
+
};
|
|
2250
|
+
const FormGroupRoot = tw.label`
|
|
2251
|
+
formgroup
|
|
2252
|
+
`; // TODO: Update and use Label component instead
|
|
2253
|
+
|
|
2254
|
+
const StyledTitle = tw.span`
|
|
2255
|
+
block
|
|
2256
|
+
text-sm
|
|
2257
|
+
text-slate-700
|
|
2258
|
+
font-medium
|
|
2259
|
+
mb-1
|
|
2260
|
+
`;
|
|
2261
|
+
const ContainerBefore = tw.div`
|
|
2262
|
+
formGroup-container-before
|
|
2263
|
+
`;
|
|
2264
|
+
const ContainerAfter = tw.div`
|
|
2265
|
+
formGroup-container-after
|
|
2266
|
+
${({
|
|
2267
|
+
$isInvalid
|
|
2268
|
+
}) => $isInvalid ? tws`formGroup-container-after--invalid` : null}
|
|
2269
|
+
`;
|
|
2270
|
+
const HelpAddon = tw.span`
|
|
2271
|
+
formGroup-helpAddon
|
|
2272
|
+
`;
|
|
2273
|
+
|
|
2274
|
+
const Indicator$1 = _a => {
|
|
2275
|
+
var {
|
|
2276
|
+
dataTestId,
|
|
2277
|
+
icon,
|
|
2278
|
+
label,
|
|
2279
|
+
color,
|
|
2280
|
+
withBackground = true
|
|
2281
|
+
} = _a,
|
|
2282
|
+
rest = __rest(_a, ["dataTestId", "icon", "label", "color", "withBackground"]);
|
|
2283
|
+
|
|
2284
|
+
return jsxs(Container$3, Object.assign({
|
|
2285
|
+
"$color": color,
|
|
2286
|
+
"data-testid": dataTestId
|
|
2287
|
+
}, rest, {
|
|
2288
|
+
children: [jsx(IconBackground, Object.assign({
|
|
2289
|
+
"data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background",
|
|
2290
|
+
"$withBackground": withBackground
|
|
2291
|
+
}, {
|
|
2292
|
+
children: icon
|
|
2293
|
+
})), label !== undefined && jsx(Label$3, Object.assign({
|
|
2294
|
+
"data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label"
|
|
2295
|
+
}, {
|
|
2296
|
+
children: label
|
|
2297
|
+
}))]
|
|
2298
|
+
}));
|
|
2299
|
+
};
|
|
2300
|
+
const Container$3 = tw.div`
|
|
2301
|
+
indicator
|
|
2302
|
+
${({
|
|
2303
|
+
$color
|
|
2304
|
+
}) => {
|
|
2305
|
+
switch ($color) {
|
|
2306
|
+
case colors.PRIMARY:
|
|
2307
|
+
return tws`indicator--primary`;
|
|
2308
|
+
|
|
2309
|
+
case colors.ACCENT:
|
|
2310
|
+
return tws`indicator--accent`;
|
|
2311
|
+
|
|
2312
|
+
case colors.NEUTRAL:
|
|
2313
|
+
return tws`indicator--neutral`;
|
|
2314
|
+
|
|
2315
|
+
case colors.INFO:
|
|
2316
|
+
return tws`indicator--info`;
|
|
2317
|
+
|
|
2318
|
+
case colors.SUCCESS:
|
|
2319
|
+
return tws`indicator--success`;
|
|
2320
|
+
|
|
2321
|
+
case colors.WARNING:
|
|
2322
|
+
return tws`indicator--warning`;
|
|
2323
|
+
|
|
2324
|
+
case colors.DANGER:
|
|
2325
|
+
return tws`indicator--danger`;
|
|
2326
|
+
|
|
2327
|
+
case colors.GOOD:
|
|
2328
|
+
return tws`indicator--good`;
|
|
2329
|
+
|
|
2330
|
+
case colors.LOW:
|
|
2331
|
+
return tws`indicator--low`;
|
|
2332
|
+
|
|
2333
|
+
case colors.CRITICAL:
|
|
2334
|
+
return tws`indicator--critical`;
|
|
2335
|
+
|
|
2336
|
+
case colors.WORKING:
|
|
2337
|
+
return tws`indicator--working`;
|
|
2338
|
+
|
|
2339
|
+
case colors.IDLE:
|
|
2340
|
+
return tws`indicator--idle`;
|
|
2341
|
+
|
|
2342
|
+
case colors.STOPPED:
|
|
2343
|
+
return tws`indicator--stopped`;
|
|
2344
|
+
|
|
2345
|
+
case colors.UNKNOWN:
|
|
2346
|
+
return tws`indicator--unknown`;
|
|
2347
|
+
|
|
2348
|
+
default:
|
|
2349
|
+
return "";
|
|
2350
|
+
}
|
|
2351
|
+
}}
|
|
2352
|
+
`;
|
|
2353
|
+
const IconBackground = tw.div`
|
|
2354
|
+
indicator__icon-background
|
|
2355
|
+
|
|
2356
|
+
${({
|
|
2357
|
+
$withBackground
|
|
2358
|
+
}) => {
|
|
2359
|
+
return $withBackground ? "" : "indicator__icon-background--none";
|
|
2360
|
+
}}
|
|
2361
|
+
`;
|
|
2362
|
+
const Label$3 = tw.div`
|
|
2363
|
+
indicator__label
|
|
2364
|
+
`;
|
|
2365
|
+
|
|
2366
|
+
const Label$2 = ({
|
|
2367
|
+
id,
|
|
2368
|
+
htmlFor,
|
|
2369
|
+
label,
|
|
2370
|
+
description,
|
|
2371
|
+
className,
|
|
2372
|
+
dataTestId
|
|
2373
|
+
}) => {
|
|
2374
|
+
const labelEl = jsx(Text, Object.assign({
|
|
2375
|
+
weight: "thick",
|
|
2376
|
+
className: className,
|
|
2377
|
+
dataTestId: dataTestId
|
|
2378
|
+
}, {
|
|
2379
|
+
children: label
|
|
2380
|
+
}));
|
|
2381
|
+
|
|
2382
|
+
return jsxs(Fragment, {
|
|
2383
|
+
children: [htmlFor === false ? labelEl : jsx("label", Object.assign({
|
|
2384
|
+
id: id,
|
|
2385
|
+
htmlFor: htmlFor
|
|
2386
|
+
}, {
|
|
2387
|
+
children: labelEl
|
|
2388
|
+
})), jsx(Description, Object.assign({
|
|
2389
|
+
subtle: true
|
|
2390
|
+
}, {
|
|
2391
|
+
children: description
|
|
2392
|
+
}))]
|
|
2393
|
+
});
|
|
2394
|
+
};
|
|
2395
|
+
const Description = tw(Text)`
|
|
2396
|
+
label
|
|
2397
|
+
`;
|
|
2398
|
+
|
|
2399
|
+
const LegendItem = ({
|
|
2400
|
+
className,
|
|
2401
|
+
label,
|
|
2402
|
+
disabled,
|
|
2403
|
+
selected,
|
|
2404
|
+
onClick,
|
|
2405
|
+
color,
|
|
2406
|
+
dataTestId
|
|
2407
|
+
}) => {
|
|
2408
|
+
const handleOnClick = onClick && !disabled ? () => onClick() : undefined;
|
|
2409
|
+
return jsxs(Root$2, Object.assign({
|
|
2410
|
+
"data-testid": dataTestId,
|
|
2411
|
+
disabled: disabled,
|
|
2412
|
+
className: className,
|
|
2413
|
+
selected: selected,
|
|
2414
|
+
onClick: handleOnClick
|
|
2415
|
+
}, {
|
|
2416
|
+
children: [jsx(Indicator, {
|
|
2417
|
+
color: color
|
|
2418
|
+
}), jsx(Label$1, {
|
|
2419
|
+
children: label
|
|
2420
|
+
})]
|
|
2421
|
+
}));
|
|
2422
|
+
};
|
|
2423
|
+
const Root$2 = tw.div`
|
|
2424
|
+
inline-flex
|
|
2425
|
+
items-center
|
|
2426
|
+
transition-all
|
|
2427
|
+
ease-in-out
|
|
2428
|
+
duration-200
|
|
2429
|
+
text-neutral-500
|
|
2430
|
+
${p => p.disabled ? tws`text-neutral-300` : p.selected ? tws`text-black` : tws`text-neutral-500`}
|
|
2431
|
+
${p => p.selected ? tws`font-medium` : null}
|
|
2432
|
+
${p => p.onClick ? tws`cursor-pointer` : tws`cursor-default`}
|
|
2433
|
+
`;
|
|
2434
|
+
const Indicator = tw.span`
|
|
2435
|
+
block
|
|
2436
|
+
w-3
|
|
2437
|
+
h-3
|
|
2438
|
+
rounded-[50%]
|
|
2439
|
+
mr-2
|
|
2440
|
+
${p => p.color}
|
|
2441
|
+
`;
|
|
2442
|
+
const Label$1 = tw.span`
|
|
2443
|
+
text-sm
|
|
2444
|
+
`;
|
|
2445
|
+
|
|
2446
|
+
const MenuButton = ({
|
|
2447
|
+
onClick,
|
|
2448
|
+
className
|
|
2449
|
+
}) => {
|
|
2450
|
+
return jsx(MobileIconButton, {
|
|
2451
|
+
icon: jsx(Icon$1, {
|
|
2452
|
+
name: "DotsHorizontalIcon",
|
|
2453
|
+
size: "small"
|
|
2454
|
+
}),
|
|
2455
|
+
size: "small",
|
|
2456
|
+
circular: true,
|
|
2457
|
+
onClick: onClick,
|
|
2458
|
+
className: className
|
|
2459
|
+
});
|
|
2460
|
+
};
|
|
2461
|
+
const MobileIconButton = tw(IconButton)`
|
|
2462
|
+
!text-gray-800
|
|
2463
|
+
!bg-white
|
|
2464
|
+
active:outline-gray-400
|
|
2465
|
+
active:!shadow-none
|
|
2466
|
+
focus:!shadow-none
|
|
2467
|
+
shadow-lg
|
|
2468
|
+
!border
|
|
2469
|
+
!border-solid
|
|
2470
|
+
!border-gray-300
|
|
2471
|
+
`;
|
|
2472
|
+
|
|
2473
|
+
const MenuItem = ({
|
|
2474
|
+
className,
|
|
2475
|
+
dataTestId,
|
|
2476
|
+
label,
|
|
2477
|
+
icon,
|
|
2478
|
+
onClick
|
|
2479
|
+
}) => {
|
|
2480
|
+
const containerProps = useContainerProps({
|
|
2481
|
+
className,
|
|
2482
|
+
dataTestId
|
|
2483
|
+
});
|
|
2484
|
+
return jsx(Container$2, Object.assign({}, containerProps, {
|
|
2485
|
+
onClick: onClick
|
|
2486
|
+
}, {
|
|
2487
|
+
children: jsxs(Content, {
|
|
2488
|
+
children: [jsx(Label, {
|
|
2489
|
+
children: label
|
|
2490
|
+
}), icon && jsx(Icon, {
|
|
2491
|
+
children: icon
|
|
2492
|
+
})]
|
|
2493
|
+
})
|
|
2494
|
+
}));
|
|
2495
|
+
};
|
|
2496
|
+
const Container$2 = tw.div`
|
|
2497
|
+
group menuItem
|
|
2498
|
+
`;
|
|
2499
|
+
const Content = tw.div`
|
|
2500
|
+
menuItem__content
|
|
2501
|
+
`;
|
|
2502
|
+
const Icon = tw.div`
|
|
2503
|
+
menuItem__icon
|
|
2504
|
+
`;
|
|
2505
|
+
const Label = tw.div`
|
|
2506
|
+
menuItem__label
|
|
2507
|
+
`;
|
|
2508
|
+
|
|
2509
|
+
const MenuList = ({
|
|
2510
|
+
dataTestId,
|
|
2511
|
+
className,
|
|
2512
|
+
menuItems
|
|
2513
|
+
}) => {
|
|
2514
|
+
const containerProps = useContainerProps({
|
|
2515
|
+
className,
|
|
2516
|
+
dataTestId
|
|
2517
|
+
});
|
|
2518
|
+
return jsx(Wrapper, {
|
|
2519
|
+
children: jsx(Container$1, Object.assign({}, containerProps, {
|
|
2520
|
+
children: menuItems.map((props, index) => {
|
|
2521
|
+
const item = createElement(MenuItem, Object.assign({}, props, {
|
|
2522
|
+
key: `${index}-${props.label}`,
|
|
2523
|
+
onClick: props.onClick
|
|
2524
|
+
}));
|
|
2525
|
+
|
|
2526
|
+
return props.showDivider ? jsxs(Fragment, {
|
|
2527
|
+
children: [jsx(Divider, {}), " ", item]
|
|
2528
|
+
}) : item;
|
|
2529
|
+
})
|
|
2530
|
+
}))
|
|
2531
|
+
});
|
|
2532
|
+
};
|
|
2533
|
+
const Wrapper = tw.div`
|
|
2534
|
+
menuList__wrapper
|
|
2535
|
+
`;
|
|
2536
|
+
const Container$1 = tw.div`
|
|
2537
|
+
menuList
|
|
2538
|
+
`;
|
|
2539
|
+
const Divider = tw.div`
|
|
2540
|
+
menuList__divider
|
|
2541
|
+
`;
|
|
2542
|
+
|
|
2543
|
+
const ModalBackdrop = ({
|
|
2544
|
+
children,
|
|
2545
|
+
isVisible,
|
|
2546
|
+
onClick
|
|
2547
|
+
}) => {
|
|
2548
|
+
const transitions = useTransition(isVisible, {
|
|
2549
|
+
from: {
|
|
2550
|
+
opacity: 0
|
|
2551
|
+
},
|
|
2552
|
+
enter: {
|
|
2553
|
+
opacity: 1
|
|
2554
|
+
},
|
|
2555
|
+
leave: {
|
|
2556
|
+
opacity: 0
|
|
2557
|
+
},
|
|
2558
|
+
config: {
|
|
2559
|
+
tension: 300,
|
|
2560
|
+
friction: 30,
|
|
2561
|
+
precision: 0.1
|
|
2562
|
+
}
|
|
2563
|
+
});
|
|
2564
|
+
const ref = React.useRef(null);
|
|
2565
|
+
return jsx(React.Fragment, {
|
|
2566
|
+
children: transitions((props, item) => item && jsx(Backdrop, Object.assign({
|
|
2567
|
+
ref: ref,
|
|
2568
|
+
onMouseDown: e => {
|
|
2569
|
+
var _a, _b; // only react on click on backdrop - accessing first child to get around styled element element
|
|
2570
|
+
|
|
2571
|
+
|
|
2572
|
+
if (ref.current !== null) {
|
|
2573
|
+
if ((e === null || e === void 0 ? void 0 : e.target) === ((_b = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b[0])) {
|
|
2574
|
+
onClick();
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
},
|
|
2578
|
+
style: props
|
|
2579
|
+
}, {
|
|
2580
|
+
children: children
|
|
2581
|
+
})))
|
|
2582
|
+
});
|
|
2583
|
+
};
|
|
2584
|
+
const Backdrop = tw(animated.div)`
|
|
2585
|
+
modal--backdrop
|
|
2586
|
+
`;
|
|
2587
|
+
|
|
2588
|
+
/** Preferred usage is with useModal(), so the modal is placed at highest level. */
|
|
2589
|
+
|
|
2590
|
+
const Modal = React.forwardRef(({
|
|
2591
|
+
isOpen,
|
|
2592
|
+
children,
|
|
2593
|
+
maxWidth = "full",
|
|
2594
|
+
dataTestId,
|
|
2595
|
+
className,
|
|
2596
|
+
onDismissClick = () => {
|
|
2597
|
+
return;
|
|
2598
|
+
}
|
|
2599
|
+
}, ref) => {
|
|
2600
|
+
const transitions = useTransition(isOpen, {
|
|
2601
|
+
from: {
|
|
2602
|
+
opacity: 0,
|
|
2603
|
+
transform: "scale(0.9)"
|
|
2604
|
+
},
|
|
2605
|
+
enter: {
|
|
2606
|
+
opacity: 1,
|
|
2607
|
+
transform: "scale(1)"
|
|
2608
|
+
},
|
|
2609
|
+
leave: {
|
|
2610
|
+
opacity: 0,
|
|
2611
|
+
transform: "scale(0.9)"
|
|
2612
|
+
},
|
|
2613
|
+
config: {
|
|
2614
|
+
tension: 300,
|
|
2615
|
+
friction: 30,
|
|
2616
|
+
precision: 0.1
|
|
2617
|
+
}
|
|
2618
|
+
});
|
|
2619
|
+
return jsx(ModalBackdrop, Object.assign({
|
|
2620
|
+
isVisible: isOpen,
|
|
2621
|
+
onClick: onDismissClick
|
|
2622
|
+
}, {
|
|
2623
|
+
children: transitions((props, item) => item && jsx(AnimatedDiv, Object.assign({
|
|
2624
|
+
ref: ref,
|
|
2625
|
+
style: props
|
|
2626
|
+
}, {
|
|
2627
|
+
children: jsx(StyledCard, Object.assign({
|
|
2628
|
+
dataTestId: dataTestId,
|
|
2629
|
+
className: className,
|
|
2630
|
+
maxWidth: maxWidth
|
|
2631
|
+
}, {
|
|
2632
|
+
children: children
|
|
2633
|
+
}))
|
|
2634
|
+
})))
|
|
2635
|
+
}));
|
|
2636
|
+
});
|
|
2637
|
+
|
|
2638
|
+
const getCardMaxWidth = () => ({
|
|
2639
|
+
maxWidth
|
|
2640
|
+
}) => {
|
|
2641
|
+
maxWidth = maxWidth ? maxWidth : "full";
|
|
2642
|
+
const widths = {
|
|
2643
|
+
slim: tws`modal-card--slim`,
|
|
2644
|
+
narrow: tws`modal-card--narrow`,
|
|
2645
|
+
wide: tws`modal-card--wide`,
|
|
2646
|
+
normal: tws`modal-card--normal`,
|
|
2647
|
+
full: ""
|
|
2648
|
+
};
|
|
2649
|
+
return widths[maxWidth];
|
|
2650
|
+
};
|
|
2651
|
+
|
|
2652
|
+
const StyledCard = tw(Card)`
|
|
2653
|
+
modal__card
|
|
2654
|
+
${getCardMaxWidth()}
|
|
2655
|
+
`;
|
|
2656
|
+
const StyledDiv = tw.div`
|
|
2657
|
+
modal__container
|
|
2658
|
+
`;
|
|
2659
|
+
const AnimatedDiv = animated(StyledDiv);
|
|
2660
|
+
|
|
2661
|
+
const useModal = ({
|
|
2662
|
+
closeOnOutsideClick
|
|
2663
|
+
} = {}) => {
|
|
2664
|
+
const modalRef = useRef(null);
|
|
2665
|
+
const {
|
|
2666
|
+
isOpen,
|
|
2667
|
+
togglePortal,
|
|
2668
|
+
openPortal,
|
|
2669
|
+
closePortal,
|
|
2670
|
+
Portal
|
|
2671
|
+
} = usePortal({
|
|
2672
|
+
closeOnOutsideClick,
|
|
2673
|
+
onPortalClick: ({
|
|
2674
|
+
target
|
|
2675
|
+
}) => {
|
|
2676
|
+
if (!closeOnOutsideClick) {
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
const clickingOutsideModal = modalRef && modalRef.current && !modalRef.current.contains(target);
|
|
2681
|
+
|
|
2682
|
+
if (clickingOutsideModal) {
|
|
2683
|
+
closePortal();
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
});
|
|
2687
|
+
|
|
2688
|
+
const PortalWrapper = props => jsx(Portal, {
|
|
2689
|
+
children: jsx(Modal, Object.assign({
|
|
2690
|
+
ref: modalRef,
|
|
2691
|
+
isOpen: isOpen
|
|
2692
|
+
}, props))
|
|
2693
|
+
});
|
|
2694
|
+
|
|
2695
|
+
PortalWrapper.displayName = "Modal";
|
|
2696
|
+
const WrappedModal = useCallback(PortalWrapper, [Portal, isOpen]);
|
|
2697
|
+
return {
|
|
2698
|
+
Modal: WrappedModal,
|
|
2699
|
+
toggleModal: togglePortal,
|
|
2700
|
+
openModal: openPortal,
|
|
2701
|
+
closeModal: closePortal,
|
|
2702
|
+
isOpen
|
|
2703
|
+
};
|
|
2704
|
+
};
|
|
2705
|
+
|
|
2706
|
+
const MinTopFullContentLayout = ({
|
|
2707
|
+
children,
|
|
2708
|
+
className,
|
|
2709
|
+
dataTestId
|
|
2710
|
+
}) => jsx(Layout$5, Object.assign({
|
|
2711
|
+
className: className,
|
|
2712
|
+
"data-testid": dataTestId
|
|
2713
|
+
}, {
|
|
2714
|
+
children: children
|
|
2715
|
+
}));
|
|
2716
|
+
const Layout$5 = tw.span`
|
|
2717
|
+
grid
|
|
2718
|
+
h-full
|
|
2719
|
+
grid-rows-min-fr
|
|
2720
|
+
`;
|
|
2721
|
+
|
|
2722
|
+
const FilterListMapLayout = ({
|
|
2723
|
+
children
|
|
2724
|
+
}) => jsx(Layout$4, {
|
|
2725
|
+
children: children
|
|
2726
|
+
});
|
|
2727
|
+
const Layout$4 = tw.span`
|
|
2728
|
+
layout-FilterListMap
|
|
2729
|
+
`;
|
|
2730
|
+
|
|
2731
|
+
const FullWidthRepeatingLayout = ({
|
|
2732
|
+
children,
|
|
2733
|
+
rowSizing = "Unmanaged",
|
|
2734
|
+
rowMinHeight,
|
|
2735
|
+
dataTestId,
|
|
2736
|
+
className
|
|
2737
|
+
}) => jsx(Layout$3, Object.assign({
|
|
2738
|
+
"data-testid": dataTestId,
|
|
2739
|
+
className: className,
|
|
2740
|
+
"$rowSizing": rowSizing,
|
|
2741
|
+
"$rowMinHeight": rowMinHeight !== null && rowMinHeight !== void 0 ? rowMinHeight : 0
|
|
2742
|
+
}, {
|
|
2743
|
+
children: children
|
|
2744
|
+
}));
|
|
2745
|
+
const Layout$3 = tw.span`
|
|
2746
|
+
layout-FullWidthRepeatingLayout
|
|
2747
|
+
|
|
2748
|
+
${({
|
|
2749
|
+
$rowSizing
|
|
2750
|
+
}) => {
|
|
2751
|
+
switch ($rowSizing) {
|
|
2752
|
+
case "MinContent":
|
|
2753
|
+
return tws` layout-FullWidthRepeatingLayout--MinContent`;
|
|
2754
|
+
|
|
2755
|
+
case "Equal":
|
|
2756
|
+
return tws` layout-FullWidthRepeatingLayout--Equal`;
|
|
2757
|
+
|
|
2758
|
+
case "Unmanaged":
|
|
2759
|
+
default:
|
|
2760
|
+
return null;
|
|
2761
|
+
}
|
|
2762
|
+
}}
|
|
2763
|
+
`;
|
|
2764
|
+
|
|
2765
|
+
/**
|
|
2766
|
+
* Simply applies a Grid Area to the element
|
|
2767
|
+
* @param {string} area
|
|
2768
|
+
*/
|
|
2769
|
+
|
|
2770
|
+
const GridArea = ({
|
|
2771
|
+
area,
|
|
2772
|
+
dataTestId,
|
|
2773
|
+
className,
|
|
2774
|
+
children
|
|
2775
|
+
}) => jsx("section", Object.assign({
|
|
2776
|
+
className: className,
|
|
2777
|
+
"data-testid": dataTestId,
|
|
2778
|
+
style: {
|
|
2779
|
+
gridArea: area
|
|
2780
|
+
}
|
|
2781
|
+
}, {
|
|
2782
|
+
children: children
|
|
2783
|
+
}));
|
|
2784
|
+
|
|
2785
|
+
/**
|
|
2786
|
+
* A grid container that has a flexible number of columns.
|
|
2787
|
+
* Adds more columns if constraints allow it, otherwise wraps to next row
|
|
2788
|
+
*
|
|
2789
|
+
* @component
|
|
2790
|
+
* @prop children - the children to be laid out,
|
|
2791
|
+
* @prop occupation = "auto-fill" - stretch a little, till there's room for another column. Optionally set "auto-fit" to stretch children to fit entire container width,
|
|
2792
|
+
* @prop minColumnWidth = "normal" - "small" | "normal" | "large"
|
|
2793
|
+
* @prop gap = "auto" - the gap size between children,
|
|
2794
|
+
* @prop dataTestId,
|
|
2795
|
+
* @prop className ,
|
|
2796
|
+
|
|
2797
|
+
*/
|
|
2798
|
+
|
|
2799
|
+
const IntrinsicallyResponsiveGrid = ({
|
|
2800
|
+
children,
|
|
2801
|
+
occupation = "auto-fill",
|
|
2802
|
+
minColumnWidth = "normal",
|
|
2803
|
+
gap = "auto",
|
|
2804
|
+
dataTestId,
|
|
2805
|
+
className
|
|
2806
|
+
}) => jsx(Layout$2, Object.assign({
|
|
2807
|
+
"$minColumnWidth": minColumnWidth,
|
|
2808
|
+
"data-testid": dataTestId,
|
|
2809
|
+
"$gap": gap,
|
|
2810
|
+
"$occupation": occupation,
|
|
2811
|
+
className: className
|
|
2812
|
+
}, {
|
|
2813
|
+
children: children
|
|
2814
|
+
}));
|
|
2815
|
+
const Layout$2 = tw.span`
|
|
2816
|
+
layout-IntrinsicallyResponsiveGrid
|
|
2817
|
+
${({
|
|
2818
|
+
$occupation
|
|
2819
|
+
}) => {
|
|
2820
|
+
switch ($occupation) {
|
|
2821
|
+
case "auto-fit":
|
|
2822
|
+
return tws`layout-IntrinsicallyResponsiveGrid--fit`;
|
|
2823
|
+
|
|
2824
|
+
case "auto-fill":
|
|
2825
|
+
default:
|
|
2826
|
+
return tws`layout-IntrinsicallyResponsiveGrid--fill`;
|
|
2827
|
+
}
|
|
2828
|
+
}}
|
|
2829
|
+
|
|
2830
|
+
${({
|
|
2831
|
+
$minColumnWidth
|
|
2832
|
+
}) => {
|
|
2833
|
+
switch ($minColumnWidth) {
|
|
2834
|
+
case "slim":
|
|
2835
|
+
return tws`layout-IntrinsicallyResponsiveGrid--slim`;
|
|
2836
|
+
|
|
2837
|
+
case "narrow":
|
|
2838
|
+
return tws`layout-IntrinsicallyResponsiveGrid--narrow`;
|
|
2839
|
+
|
|
2840
|
+
case "wide":
|
|
2841
|
+
return tws`layout-IntrinsicallyResponsiveGrid--wide`;
|
|
2842
|
+
|
|
2843
|
+
case "normal":
|
|
2844
|
+
default:
|
|
2845
|
+
return tws`layout-IntrinsicallyResponsiveGrid--normal`;
|
|
2846
|
+
}
|
|
2847
|
+
}}
|
|
2848
|
+
|
|
2849
|
+
${({
|
|
2850
|
+
$gap
|
|
2851
|
+
}) => {
|
|
2852
|
+
switch ($gap) {
|
|
2853
|
+
case "tiny":
|
|
2854
|
+
return tws`gap-1`;
|
|
2855
|
+
|
|
2856
|
+
case "mini":
|
|
2857
|
+
return tws`gap-2`;
|
|
2858
|
+
|
|
2859
|
+
case "small":
|
|
2860
|
+
return tws`gap-3`;
|
|
2861
|
+
|
|
2862
|
+
case "medium":
|
|
2863
|
+
return tws`gap-4`;
|
|
2864
|
+
|
|
2865
|
+
case "large":
|
|
2866
|
+
return tws`gap-6`;
|
|
2867
|
+
|
|
2868
|
+
case "giant":
|
|
2869
|
+
return tws`gap-8`;
|
|
2870
|
+
|
|
2871
|
+
case "enormous":
|
|
2872
|
+
return tws`gap-10`;
|
|
2873
|
+
|
|
2874
|
+
case "none":
|
|
2875
|
+
return tws`gap-0`;
|
|
2876
|
+
|
|
2877
|
+
case "inherit":
|
|
2878
|
+
return tws`gap-[inherit]`;
|
|
2879
|
+
|
|
2880
|
+
case "auto":
|
|
2881
|
+
default:
|
|
2882
|
+
return tws`gap-3 sm:gap-4 md:gap-6`;
|
|
2883
|
+
}
|
|
2884
|
+
}};
|
|
2885
|
+
`;
|
|
2886
|
+
|
|
2887
|
+
const TitleNavContentLayout = ({
|
|
2888
|
+
children
|
|
2889
|
+
}) => jsx(Layout$1, {
|
|
2890
|
+
children: children
|
|
2891
|
+
});
|
|
2892
|
+
const Layout$1 = tw.div`
|
|
2893
|
+
layout-TitleNavContentLayout
|
|
2894
|
+
`;
|
|
2895
|
+
|
|
2896
|
+
const TwoColumnLayout = ({
|
|
2897
|
+
children
|
|
2898
|
+
}) => jsx(Layout, {
|
|
2899
|
+
children: children
|
|
2900
|
+
});
|
|
2901
|
+
const Layout = tw.div`
|
|
2902
|
+
layout-TwoColumnLayout
|
|
2903
|
+
`;
|
|
2904
|
+
|
|
2905
|
+
/**
|
|
2906
|
+
* Extending Table Cell component formats your content supporting 2 rows.
|
|
2907
|
+
*/
|
|
2908
|
+
|
|
2909
|
+
const MultiRowTableCell = ({
|
|
2910
|
+
main,
|
|
2911
|
+
secondary,
|
|
2912
|
+
area = "none",
|
|
2913
|
+
dataTestId
|
|
2914
|
+
}) => {
|
|
2915
|
+
return jsxs(Root$1, Object.assign({
|
|
2916
|
+
area: area,
|
|
2917
|
+
dataTestId: dataTestId
|
|
2918
|
+
}, {
|
|
2919
|
+
children: [jsx(Header, {
|
|
2920
|
+
children: main
|
|
2921
|
+
}), secondary && jsx(Secondary, {
|
|
2922
|
+
children: secondary
|
|
2923
|
+
})]
|
|
2924
|
+
}));
|
|
2925
|
+
};
|
|
2926
|
+
const Root$1 = tw(GridArea)`
|
|
2927
|
+
multi-row-table-cell-container
|
|
2928
|
+
`;
|
|
2929
|
+
const Header = tw.div`
|
|
2930
|
+
multi-row-table-cell
|
|
2931
|
+
multi-row-table-cell__header
|
|
2932
|
+
`;
|
|
2933
|
+
const Secondary = tw.div`
|
|
2934
|
+
multi-row-table-cell
|
|
2935
|
+
multi-row-table-cell__secondary
|
|
2936
|
+
`;
|
|
2937
|
+
|
|
2938
|
+
/**
|
|
2939
|
+
* A thin wrapper arround the `BaseInput` component for number input fields.
|
|
2940
|
+
*
|
|
2941
|
+
* *NOTE: If shown with a label, please use the `NumberField` component instead.*
|
|
2942
|
+
*/
|
|
2943
|
+
|
|
2944
|
+
const NumberInput = forwardRef((props, ref) => jsx(BaseInput, Object.assign({
|
|
2945
|
+
ref: ref,
|
|
2946
|
+
type: "number"
|
|
2947
|
+
}, props)));
|
|
2948
|
+
NumberInput.displayName = "NumberInput";
|
|
2949
|
+
|
|
2950
|
+
const NumberField = forwardRef((_a, ref) => {
|
|
2951
|
+
var {
|
|
2952
|
+
label,
|
|
2953
|
+
tip,
|
|
2954
|
+
helpText,
|
|
2955
|
+
errorMessage,
|
|
2956
|
+
helpAddon,
|
|
2957
|
+
isInvalid,
|
|
2958
|
+
maxLength,
|
|
2959
|
+
className,
|
|
2960
|
+
value,
|
|
2961
|
+
dataTestId
|
|
2962
|
+
} = _a,
|
|
2963
|
+
rest = __rest(_a, ["label", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "maxLength", "className", "value", "dataTestId"]);
|
|
2964
|
+
|
|
2965
|
+
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2966
|
+
return jsx(FormGroup, Object.assign({
|
|
2967
|
+
label: label,
|
|
2968
|
+
tip: tip,
|
|
2969
|
+
isInvalid: renderAsInvalid,
|
|
2970
|
+
helpText: errorMessage || helpText,
|
|
2971
|
+
helpAddon: helpAddon,
|
|
2972
|
+
dataTestId: `${dataTestId}-FormGroup`
|
|
2973
|
+
}, {
|
|
2974
|
+
children: jsx(NumberInput, Object.assign({
|
|
2975
|
+
ref: ref,
|
|
2976
|
+
maxLength: maxLength,
|
|
2977
|
+
value: value,
|
|
2978
|
+
isInvalid: renderAsInvalid
|
|
2979
|
+
}, rest, {
|
|
2980
|
+
className: className,
|
|
2981
|
+
dataTestId: dataTestId
|
|
2982
|
+
}))
|
|
2983
|
+
}));
|
|
2984
|
+
});
|
|
2985
|
+
NumberField.displayName = "NumberField";
|
|
2986
|
+
|
|
2987
|
+
const GetSpacerHeight = () => ({
|
|
2988
|
+
minHeight
|
|
2989
|
+
}) => {
|
|
2990
|
+
if (!minHeight) {
|
|
2991
|
+
return "";
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
switch (minHeight) {
|
|
2995
|
+
case "normal":
|
|
2996
|
+
return tws`min-h-[8px]`;
|
|
2997
|
+
|
|
2998
|
+
case "large":
|
|
2999
|
+
return tws`min-h-[32px]`;
|
|
3000
|
+
|
|
3001
|
+
default:
|
|
3002
|
+
return "";
|
|
3003
|
+
}
|
|
3004
|
+
};
|
|
3005
|
+
|
|
3006
|
+
const Spacer = ({
|
|
3007
|
+
minHeight = "",
|
|
3008
|
+
border,
|
|
3009
|
+
dataTestId
|
|
3010
|
+
}) => {
|
|
3011
|
+
return jsx(Space, {
|
|
3012
|
+
"data-testid": dataTestId,
|
|
3013
|
+
minHeight: minHeight,
|
|
3014
|
+
border: border
|
|
3015
|
+
});
|
|
3016
|
+
};
|
|
3017
|
+
const Space = tw.div`
|
|
3018
|
+
${p => `${p.border ? `spacer--border` : null}`}
|
|
3019
|
+
${GetSpacerHeight()}
|
|
3020
|
+
`;
|
|
3021
|
+
|
|
3022
|
+
const PageHeading = ({
|
|
3023
|
+
title,
|
|
3024
|
+
subtitle,
|
|
3025
|
+
dataTestId,
|
|
3026
|
+
badge
|
|
3027
|
+
}) => {
|
|
3028
|
+
return jsxs("div", Object.assign({
|
|
3029
|
+
className: "w-full"
|
|
3030
|
+
}, {
|
|
3031
|
+
children: [jsx(Helmet, {
|
|
3032
|
+
title: title
|
|
3033
|
+
}), jsxs(StyledFlex, {
|
|
3034
|
+
children: [jsx(Heading, Object.assign({
|
|
3035
|
+
variant: "secondary",
|
|
3036
|
+
dataTestId: dataTestId
|
|
3037
|
+
}, {
|
|
3038
|
+
children: title
|
|
3039
|
+
})), badge && jsx(Badge, Object.assign({
|
|
3040
|
+
intent: "primary"
|
|
3041
|
+
}, {
|
|
3042
|
+
children: badge
|
|
3043
|
+
}))]
|
|
3044
|
+
}), subtitle && jsx(Heading, Object.assign({
|
|
3045
|
+
variant: "subtitle",
|
|
3046
|
+
subtle: true
|
|
3047
|
+
}, {
|
|
3048
|
+
children: subtitle
|
|
3049
|
+
})), jsx(Spacer, {
|
|
3050
|
+
minHeight: "normal"
|
|
3051
|
+
})]
|
|
3052
|
+
}));
|
|
3053
|
+
};
|
|
3054
|
+
const StyledFlex = tw.div`
|
|
3055
|
+
flex
|
|
3056
|
+
items-center
|
|
3057
|
+
flex-wrap-reverse
|
|
3058
|
+
gap-2
|
|
3059
|
+
`;
|
|
3060
|
+
|
|
3061
|
+
function useInRouterContext() {
|
|
3062
|
+
return useContext(UNSAFE_LocationContext) !== null;
|
|
3063
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3064
|
+
|
|
3065
|
+
function invariant(cond, message) {
|
|
3066
|
+
if (!cond) {
|
|
3067
|
+
throw new Error(message);
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
function useBlocker(blocker, when = true) {
|
|
3072
|
+
invariant(useInRouterContext(), `useBlocker() may be used only in the context of a <Router> component.`);
|
|
3073
|
+
const {
|
|
3074
|
+
navigator
|
|
3075
|
+
} = useContext(UNSAFE_NavigationContext);
|
|
3076
|
+
useEffect(() => {
|
|
3077
|
+
if (!when) {
|
|
3078
|
+
return;
|
|
3079
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3080
|
+
|
|
3081
|
+
|
|
3082
|
+
const unblock = navigator.block(tx => {
|
|
3083
|
+
const autoUnblockingTx = Object.assign(Object.assign({}, tx), {
|
|
3084
|
+
retry() {
|
|
3085
|
+
unblock();
|
|
3086
|
+
tx.retry();
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
});
|
|
3090
|
+
blocker(autoUnblockingTx);
|
|
3091
|
+
});
|
|
3092
|
+
return unblock;
|
|
3093
|
+
}, [navigator, blocker, when]);
|
|
3094
|
+
}
|
|
3095
|
+
function usePrompt(message, when = true) {
|
|
3096
|
+
const blocker = useCallback(tx => {
|
|
3097
|
+
if (window.confirm(message)) {
|
|
3098
|
+
tx.retry();
|
|
3099
|
+
}
|
|
3100
|
+
}, [message]);
|
|
3101
|
+
useBlocker(blocker, when);
|
|
3102
|
+
}
|
|
3103
|
+
const Prompt = ({
|
|
3104
|
+
when,
|
|
3105
|
+
message
|
|
3106
|
+
}) => {
|
|
3107
|
+
usePrompt(message, when);
|
|
3108
|
+
return null;
|
|
3109
|
+
};
|
|
3110
|
+
|
|
3111
|
+
const RadioGroupContext = React.createContext(null);
|
|
3112
|
+
|
|
3113
|
+
const RadioGroup = ({
|
|
3114
|
+
children,
|
|
3115
|
+
id,
|
|
3116
|
+
name,
|
|
3117
|
+
value,
|
|
3118
|
+
disabled,
|
|
3119
|
+
onChange,
|
|
3120
|
+
label,
|
|
3121
|
+
inline,
|
|
3122
|
+
className,
|
|
3123
|
+
dataTestId
|
|
3124
|
+
}) => {
|
|
3125
|
+
return jsxs(Flex, Object.assign({
|
|
3126
|
+
"$inline": inline,
|
|
3127
|
+
className: className,
|
|
3128
|
+
"data-testid": dataTestId
|
|
3129
|
+
}, {
|
|
3130
|
+
children: [label && jsx(Text, Object.assign({
|
|
3131
|
+
subtle: true,
|
|
3132
|
+
size: "small"
|
|
3133
|
+
}, {
|
|
3134
|
+
children: label
|
|
3135
|
+
})), jsx(RadioGroupContext.Provider, Object.assign({
|
|
3136
|
+
value: {
|
|
3137
|
+
id,
|
|
3138
|
+
value,
|
|
3139
|
+
name: name || id,
|
|
3140
|
+
onChange,
|
|
3141
|
+
disabled
|
|
3142
|
+
}
|
|
3143
|
+
}, {
|
|
3144
|
+
children: children
|
|
3145
|
+
}))]
|
|
3146
|
+
}));
|
|
3147
|
+
};
|
|
3148
|
+
const Flex = tw.div`
|
|
3149
|
+
flex
|
|
3150
|
+
gap-2
|
|
3151
|
+
${({
|
|
3152
|
+
$inline
|
|
3153
|
+
}) => $inline ? tws`flex-row items-center` : tws`flex-col items-start`}
|
|
3154
|
+
`;
|
|
3155
|
+
|
|
3156
|
+
const RadioItem = ({
|
|
3157
|
+
label,
|
|
3158
|
+
value,
|
|
3159
|
+
dataTestId,
|
|
3160
|
+
className
|
|
3161
|
+
}) => {
|
|
3162
|
+
const groupCtx = React.useContext(RadioGroupContext);
|
|
3163
|
+
const isChecked = (groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.value) === value;
|
|
3164
|
+
return jsxs(CustomFlex, Object.assign({
|
|
3165
|
+
className: className
|
|
3166
|
+
}, {
|
|
3167
|
+
children: [jsx("input", {
|
|
3168
|
+
id: `${label}_${value}`,
|
|
3169
|
+
type: "radio",
|
|
3170
|
+
className: "hover:cursor-pointer",
|
|
3171
|
+
value: value,
|
|
3172
|
+
checked: isChecked,
|
|
3173
|
+
disabled: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.disabled,
|
|
3174
|
+
onChange: groupCtx === null || groupCtx === void 0 ? void 0 : groupCtx.onChange,
|
|
3175
|
+
"data-testid": dataTestId
|
|
3176
|
+
}), jsx("label", Object.assign({
|
|
3177
|
+
className: "w-full hover:cursor-pointer",
|
|
3178
|
+
htmlFor: `${label}_${value}`
|
|
3179
|
+
}, {
|
|
3180
|
+
children: typeof label === "string" ? jsx(Text, {
|
|
3181
|
+
children: label
|
|
3182
|
+
}) : label
|
|
3183
|
+
}))]
|
|
3184
|
+
}));
|
|
3185
|
+
};
|
|
3186
|
+
const CustomFlex = tw.div`
|
|
3187
|
+
flex
|
|
3188
|
+
items-center
|
|
3189
|
+
gap-2
|
|
3190
|
+
hover:cursor-pointer
|
|
3191
|
+
`;
|
|
3192
|
+
|
|
3193
|
+
const SelectContainer = ({
|
|
3194
|
+
children,
|
|
3195
|
+
label,
|
|
3196
|
+
hideLabel,
|
|
3197
|
+
id,
|
|
3198
|
+
hasError,
|
|
3199
|
+
error,
|
|
3200
|
+
description,
|
|
3201
|
+
info,
|
|
3202
|
+
dataTestId
|
|
3203
|
+
}) => {
|
|
3204
|
+
return jsxs(Container, Object.assign({
|
|
3205
|
+
"data-testid": dataTestId
|
|
3206
|
+
}, {
|
|
3207
|
+
children: [label && !hideLabel && jsx(Label$2, {
|
|
3208
|
+
label: label,
|
|
3209
|
+
htmlFor: id !== null && id !== void 0 ? id : false,
|
|
3210
|
+
description: description
|
|
3211
|
+
}), children, (hasError || info) && jsx(InformativeText$1, Object.assign({
|
|
3212
|
+
size: "small",
|
|
3213
|
+
"$hasError": hasError !== null && hasError !== void 0 ? hasError : false
|
|
3214
|
+
}, {
|
|
3215
|
+
children: hasError ? error : info
|
|
3216
|
+
}))]
|
|
3217
|
+
}));
|
|
3218
|
+
};
|
|
3219
|
+
const Container = tw.label`
|
|
3220
|
+
select__container
|
|
3221
|
+
`;
|
|
3222
|
+
const InformativeText$1 = tw(Text)`
|
|
3223
|
+
informative-text
|
|
3224
|
+
${p => p.$hasError ? `informative-text--error` : null}
|
|
3225
|
+
`;
|
|
3226
|
+
|
|
3227
|
+
const getSelectHeight = size => {
|
|
3228
|
+
const tokens = {
|
|
3229
|
+
small: "var(--spacing-8)",
|
|
3230
|
+
default: "var(--spacing-10)"
|
|
3231
|
+
};
|
|
3232
|
+
return tokens[size];
|
|
3233
|
+
};
|
|
3234
|
+
|
|
3235
|
+
const useCustomStyles = (styles, hasError, isInvalid, size) => {
|
|
3236
|
+
const customStyles = React.useMemo(() => {
|
|
3237
|
+
return Object.assign({
|
|
3238
|
+
control: (base, state) => Object.assign(Object.assign({}, base), {
|
|
3239
|
+
minHeight: getSelectHeight(size),
|
|
3240
|
+
borderRadius: "var(--spacing-1)",
|
|
3241
|
+
backgroundColor: state.isDisabled ? "rgb(var(--color-neutral-50))" : "#FFF",
|
|
3242
|
+
border: "none",
|
|
3243
|
+
fontSize: "0.875rem",
|
|
3244
|
+
color: state.isDisabled ? "rgb(var(--color-neutral-50))" : "#1a1b1c",
|
|
3245
|
+
cursor: state.isDisabled ? "not-allowed" : "pointer",
|
|
3246
|
+
boxShadow: state.isFocused ? `inset 0 0 0 2px ${hasError ? "rgb(var(--color-danger-600))" : "rgb(var(--color-primary-600))"}, 0 0 0 2px ${hasError ? "rgb(var(--color-danger-100))" : "rgb(var(--color-primary-300))"}` : `inset 0 0 0 2px ${hasError ? "rgb(var(--color-danger-500))" : isInvalid ? "rgb(var(--color-warning-300))" : "rgb(var(--color-neutral-300))"}`,
|
|
3247
|
+
"&:hover": {
|
|
3248
|
+
boxShadow: state.isDisabled ? "" : `inset 0 0 0 2px ${hasError ? "rgb(var(--color-danger-600))" : "rgb(var(--color-neutral-400))"}`
|
|
3249
|
+
}
|
|
3250
|
+
}),
|
|
3251
|
+
singleValue: base => Object.assign(Object.assign({}, base), {
|
|
3252
|
+
color: "#1a1b1c"
|
|
3253
|
+
}),
|
|
3254
|
+
multiValue: base => Object.assign(Object.assign({}, base), {
|
|
3255
|
+
backgroundColor: "rgb(var(--color-neutral-100))"
|
|
3256
|
+
}),
|
|
3257
|
+
multiValueLabel: base => Object.assign(Object.assign({}, base), {
|
|
3258
|
+
fontWeight: 600,
|
|
3259
|
+
fontSize: "rgb(var(--color-neutral-400))",
|
|
3260
|
+
color: "#1a1b1c"
|
|
3261
|
+
}),
|
|
3262
|
+
indicatorsContainer: base => Object.assign(Object.assign({}, base), {
|
|
3263
|
+
color: "rgb(var(--color-neutral-300))"
|
|
3264
|
+
}),
|
|
3265
|
+
menu: base => Object.assign(Object.assign({}, base), {
|
|
3266
|
+
borderRadius: "var(--spacing-1)",
|
|
3267
|
+
marginTop: "var(--spacing-1)",
|
|
3268
|
+
fontSize: "var(--font-size-sm)",
|
|
3269
|
+
zIndex: "var(--z-popover)"
|
|
3270
|
+
}),
|
|
3271
|
+
input: base => Object.assign(Object.assign({}, base), {
|
|
3272
|
+
color: "#1a1b1c"
|
|
3273
|
+
}),
|
|
3274
|
+
placeholder: base => Object.assign(Object.assign({}, base), {
|
|
3275
|
+
color: "rgb(var(--color-neutral-500))"
|
|
3276
|
+
}),
|
|
3277
|
+
option: base => Object.assign(Object.assign({}, base), {
|
|
3278
|
+
cursor: "pointer"
|
|
3279
|
+
}),
|
|
3280
|
+
menuPortal: base => Object.assign(Object.assign({}, base), {
|
|
3281
|
+
zIndex: "var(--z-popover)"
|
|
3282
|
+
})
|
|
3283
|
+
}, styles);
|
|
3284
|
+
}, [styles, size, hasError, isInvalid]);
|
|
3285
|
+
return {
|
|
3286
|
+
customStyles
|
|
3287
|
+
};
|
|
3288
|
+
};
|
|
3289
|
+
const useCustomComponents = components => {
|
|
3290
|
+
const customComponents = React.useMemo(() => {
|
|
3291
|
+
return Object.assign({
|
|
3292
|
+
LoadingIndicator: loadingIndicatorProps => {
|
|
3293
|
+
const loadingIndicatorStyles = loadingIndicatorProps === null || loadingIndicatorProps === void 0 ? void 0 : loadingIndicatorProps.getStyles("loadingIndicator", loadingIndicatorProps);
|
|
3294
|
+
delete loadingIndicatorStyles.label;
|
|
3295
|
+
return jsx("div", Object.assign({
|
|
3296
|
+
style: loadingIndicatorStyles
|
|
3297
|
+
}, {
|
|
3298
|
+
children: jsx(Spinner, {})
|
|
3299
|
+
}));
|
|
3300
|
+
}
|
|
3301
|
+
}, components);
|
|
3302
|
+
}, [components]);
|
|
3303
|
+
return {
|
|
3304
|
+
customComponents
|
|
3305
|
+
};
|
|
3306
|
+
};
|
|
3307
|
+
|
|
3308
|
+
const CreatableSelect = _a => {
|
|
3309
|
+
var {
|
|
3310
|
+
dataTestId,
|
|
3311
|
+
size = "default",
|
|
3312
|
+
id,
|
|
3313
|
+
label,
|
|
3314
|
+
hideLabel,
|
|
3315
|
+
description,
|
|
3316
|
+
error,
|
|
3317
|
+
info,
|
|
3318
|
+
isInvalid,
|
|
3319
|
+
maxMenuHeight = 308,
|
|
3320
|
+
styles,
|
|
3321
|
+
components
|
|
3322
|
+
} = _a,
|
|
3323
|
+
props = __rest(_a, ["dataTestId", "size", "id", "label", "hideLabel", "description", "error", "info", "isInvalid", "maxMenuHeight", "styles", "components"]);
|
|
3324
|
+
|
|
3325
|
+
const hasError = !!error;
|
|
3326
|
+
const {
|
|
3327
|
+
customStyles
|
|
3328
|
+
} = useCustomStyles(styles, hasError, isInvalid, size);
|
|
3329
|
+
const {
|
|
3330
|
+
customComponents
|
|
3331
|
+
} = useCustomComponents(components);
|
|
3332
|
+
return jsx(SelectContainer, Object.assign({
|
|
3333
|
+
label: label,
|
|
3334
|
+
hideLabel: hideLabel,
|
|
3335
|
+
id: id,
|
|
3336
|
+
hasError: hasError,
|
|
3337
|
+
error: error,
|
|
3338
|
+
description: description,
|
|
3339
|
+
info: info,
|
|
3340
|
+
dataTestId: dataTestId
|
|
3341
|
+
}, {
|
|
3342
|
+
children: props.isAsync ? jsx(ReactAsyncCreatableSelect, Object.assign({
|
|
3343
|
+
"aria-label": label,
|
|
3344
|
+
maxMenuHeight: maxMenuHeight,
|
|
3345
|
+
"data-testid": dataTestId,
|
|
3346
|
+
styles: customStyles,
|
|
3347
|
+
components: customComponents
|
|
3348
|
+
}, props)) : jsx(ReactCreatableSelect, Object.assign({
|
|
3349
|
+
"aria-label": label,
|
|
3350
|
+
maxMenuHeight: maxMenuHeight,
|
|
3351
|
+
"data-testid": dataTestId,
|
|
3352
|
+
styles: customStyles,
|
|
3353
|
+
components: customComponents
|
|
3354
|
+
}, props))
|
|
3355
|
+
}));
|
|
3356
|
+
};
|
|
3357
|
+
|
|
3358
|
+
const Select = _a => {
|
|
3359
|
+
var {
|
|
3360
|
+
dataTestId,
|
|
3361
|
+
size = "default",
|
|
3362
|
+
id,
|
|
3363
|
+
label,
|
|
3364
|
+
hideLabel,
|
|
3365
|
+
description,
|
|
3366
|
+
error,
|
|
3367
|
+
info,
|
|
3368
|
+
isInvalid,
|
|
3369
|
+
maxMenuHeight = 308,
|
|
3370
|
+
styles,
|
|
3371
|
+
components
|
|
3372
|
+
} = _a,
|
|
3373
|
+
props = __rest(_a, ["dataTestId", "size", "id", "label", "hideLabel", "description", "error", "info", "isInvalid", "maxMenuHeight", "styles", "components"]);
|
|
3374
|
+
|
|
3375
|
+
const hasError = !!error;
|
|
3376
|
+
const {
|
|
3377
|
+
customStyles
|
|
3378
|
+
} = useCustomStyles(styles, hasError, isInvalid, size);
|
|
3379
|
+
const {
|
|
3380
|
+
customComponents
|
|
3381
|
+
} = useCustomComponents(components);
|
|
3382
|
+
return jsx(SelectContainer, Object.assign({
|
|
3383
|
+
label: label,
|
|
3384
|
+
hideLabel: hideLabel,
|
|
3385
|
+
id: id,
|
|
3386
|
+
hasError: hasError,
|
|
3387
|
+
error: error,
|
|
3388
|
+
description: description,
|
|
3389
|
+
info: info,
|
|
3390
|
+
dataTestId: dataTestId
|
|
3391
|
+
}, {
|
|
3392
|
+
children: props.isAsync ? jsx(ReactAsyncSelect, Object.assign({
|
|
3393
|
+
"aria-label": label,
|
|
3394
|
+
maxMenuHeight: maxMenuHeight,
|
|
3395
|
+
"data-testid": dataTestId,
|
|
3396
|
+
styles: customStyles,
|
|
3397
|
+
menuPortalTarget: document.body,
|
|
3398
|
+
components: customComponents,
|
|
3399
|
+
menuPlacement: "auto",
|
|
3400
|
+
menuShouldBlockScroll //Temp fix. See https://github.com/JedWatson/react-select/issues/4088
|
|
3401
|
+
: true
|
|
3402
|
+
}, props)) : jsx(ReactSelect, Object.assign({
|
|
3403
|
+
"aria-label": label,
|
|
3404
|
+
maxMenuHeight: maxMenuHeight,
|
|
3405
|
+
"data-testid": dataTestId,
|
|
3406
|
+
styles: customStyles,
|
|
3407
|
+
menuPortalTarget: document.body,
|
|
3408
|
+
components: customComponents,
|
|
3409
|
+
menuPlacement: "auto",
|
|
3410
|
+
menuShouldBlockScroll // Temp fix.
|
|
3411
|
+
: true
|
|
3412
|
+
}, props))
|
|
3413
|
+
}));
|
|
3414
|
+
};
|
|
3415
|
+
|
|
3416
|
+
const SkeletonLines = memo(({
|
|
3417
|
+
margin = "10px 0",
|
|
3418
|
+
lines = 1,
|
|
3419
|
+
height,
|
|
3420
|
+
width = "100%",
|
|
3421
|
+
className,
|
|
3422
|
+
dataTestId
|
|
3423
|
+
}) => {
|
|
3424
|
+
const skeletonLines = [];
|
|
3425
|
+
|
|
3426
|
+
const getWidth = index => {
|
|
3427
|
+
if (width instanceof Array) {
|
|
3428
|
+
return width[index] || "100%";
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3431
|
+
return width;
|
|
3432
|
+
};
|
|
3433
|
+
|
|
3434
|
+
const getHeight = index => {
|
|
3435
|
+
if (height instanceof Array) {
|
|
3436
|
+
return height[index] || "auto";
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3439
|
+
return height;
|
|
3440
|
+
};
|
|
3441
|
+
|
|
3442
|
+
for (let i = 0; i < lines; i++) {
|
|
3443
|
+
skeletonLines.push(jsx(SkeletonLine, Object.assign({
|
|
3444
|
+
"data-testid": dataTestId,
|
|
3445
|
+
margin: margin,
|
|
3446
|
+
"data-type": "loading-skeleton-line",
|
|
3447
|
+
className: className,
|
|
3448
|
+
style: {
|
|
3449
|
+
height: getHeight(i),
|
|
3450
|
+
width: getWidth(i)
|
|
3451
|
+
}
|
|
3452
|
+
}, {
|
|
3453
|
+
children: "\u00A0"
|
|
3454
|
+
}), i));
|
|
3455
|
+
} // eslint-disable-next-line react/jsx-no-useless-fragment
|
|
3456
|
+
|
|
3457
|
+
|
|
3458
|
+
return jsx(Fragment, {
|
|
3459
|
+
children: skeletonLines
|
|
3460
|
+
});
|
|
3461
|
+
});
|
|
3462
|
+
const SkeletonLine = tw.div`
|
|
3463
|
+
skeleton-line
|
|
3464
|
+
`;
|
|
3465
|
+
SkeletonLines.displayName = "SkeletonLines";
|
|
3466
|
+
|
|
3467
|
+
const TextArea = React.forwardRef(({
|
|
3468
|
+
id,
|
|
3469
|
+
name,
|
|
3470
|
+
label,
|
|
3471
|
+
description,
|
|
3472
|
+
info,
|
|
3473
|
+
error,
|
|
3474
|
+
value,
|
|
3475
|
+
rows,
|
|
3476
|
+
disabled,
|
|
3477
|
+
placeholder,
|
|
3478
|
+
readOnly,
|
|
3479
|
+
tabIndex,
|
|
3480
|
+
onChange,
|
|
3481
|
+
onFocus,
|
|
3482
|
+
onBlur,
|
|
3483
|
+
maxLength,
|
|
3484
|
+
resize = "vertical",
|
|
3485
|
+
defaultValue,
|
|
3486
|
+
className,
|
|
3487
|
+
required,
|
|
3488
|
+
dataTestId
|
|
3489
|
+
}, ref) => {
|
|
3490
|
+
const hasError = !!error;
|
|
3491
|
+
return jsxs(TextAreaContainer, Object.assign({
|
|
3492
|
+
className: className,
|
|
3493
|
+
"data-testid": dataTestId
|
|
3494
|
+
}, {
|
|
3495
|
+
children: [jsx(Label$2, {
|
|
3496
|
+
htmlFor: id !== null && id !== void 0 ? id : false,
|
|
3497
|
+
id: id,
|
|
3498
|
+
label: label,
|
|
3499
|
+
description: description
|
|
3500
|
+
}), jsx(StyledTextArea, {
|
|
3501
|
+
name: name,
|
|
3502
|
+
value: value,
|
|
3503
|
+
rows: rows,
|
|
3504
|
+
disabled: disabled,
|
|
3505
|
+
placeholder: placeholder,
|
|
3506
|
+
readOnly: readOnly,
|
|
3507
|
+
tabIndex: tabIndex,
|
|
3508
|
+
onChange: onChange,
|
|
3509
|
+
onFocus: onFocus,
|
|
3510
|
+
onBlur: onBlur,
|
|
3511
|
+
maxLength: maxLength,
|
|
3512
|
+
"$resize": resize,
|
|
3513
|
+
"$hasError": hasError,
|
|
3514
|
+
ref: ref,
|
|
3515
|
+
defaultValue: defaultValue,
|
|
3516
|
+
required: required
|
|
3517
|
+
}), (hasError || info) && jsx(InformativeText, Object.assign({
|
|
3518
|
+
size: "small",
|
|
3519
|
+
"$hasError": hasError
|
|
3520
|
+
}, {
|
|
3521
|
+
children: hasError ? error : info
|
|
3522
|
+
}))]
|
|
3523
|
+
}));
|
|
3524
|
+
});
|
|
3525
|
+
TextArea.displayName = "TextArea";
|
|
3526
|
+
const TextAreaContainer = tw.div``;
|
|
3527
|
+
const StyledTextArea = tw.textarea`
|
|
3528
|
+
input
|
|
3529
|
+
w-full
|
|
3530
|
+
block
|
|
3531
|
+
p-2
|
|
3532
|
+
overflow-auto
|
|
3533
|
+
appearance-none
|
|
3534
|
+
text-base
|
|
3535
|
+
text-slate-900
|
|
3536
|
+
placeholder-slate-400
|
|
3537
|
+
focus-visible:outline-none
|
|
3538
|
+
border-box
|
|
3539
|
+
h-20
|
|
3540
|
+
|
|
3541
|
+
transition
|
|
3542
|
+
|
|
3543
|
+
${({
|
|
3544
|
+
$hasError
|
|
3545
|
+
}) => $hasError ? tws`input--invalid` : null}
|
|
3546
|
+
${({
|
|
3547
|
+
disabled
|
|
3548
|
+
}) => disabled ? tws`input--disabled` : null}
|
|
3549
|
+
${({
|
|
3550
|
+
$resize
|
|
3551
|
+
}) => {
|
|
3552
|
+
switch ($resize) {
|
|
3553
|
+
case "both":
|
|
3554
|
+
return tws`resize`;
|
|
3555
|
+
|
|
3556
|
+
case "horizontal":
|
|
3557
|
+
return tws`resize-x`;
|
|
3558
|
+
|
|
3559
|
+
case "vertical":
|
|
3560
|
+
return tws`resize-y`;
|
|
3561
|
+
|
|
3562
|
+
case "none":
|
|
3563
|
+
return tws`resize-none`;
|
|
3564
|
+
|
|
3565
|
+
default:
|
|
3566
|
+
return null;
|
|
3567
|
+
}
|
|
3568
|
+
}};
|
|
3569
|
+
|
|
3570
|
+
|
|
3571
|
+
`;
|
|
3572
|
+
const InformativeText = tw(Text)`
|
|
3573
|
+
mt-1
|
|
3574
|
+
${p => p.$hasError ? tws`text-red-500` : tws`text-neutral-600`};
|
|
3575
|
+
`;
|
|
3576
|
+
|
|
3577
|
+
/**
|
|
3578
|
+
* A thin wrapper arround the `BaseInput` component for text input fields.
|
|
3579
|
+
*
|
|
3580
|
+
* *NOTE: If shown with a label, please use the `TextField` component instead.*
|
|
3581
|
+
*/
|
|
3582
|
+
|
|
3583
|
+
const TextInput = forwardRef((props, ref) => jsx(BaseInput, Object.assign({
|
|
3584
|
+
ref: ref,
|
|
3585
|
+
type: "text"
|
|
3586
|
+
}, props)));
|
|
3587
|
+
TextInput.displayName = "TextInput";
|
|
3588
|
+
|
|
3589
|
+
const TextLengthIndicator = ({
|
|
3590
|
+
length,
|
|
3591
|
+
maxLength
|
|
3592
|
+
}) => {
|
|
3593
|
+
return jsxs(Root, {
|
|
3594
|
+
children: [length, "/", maxLength]
|
|
3595
|
+
});
|
|
3596
|
+
};
|
|
3597
|
+
const Root = tw.span`
|
|
3598
|
+
font-mono
|
|
3599
|
+
`;
|
|
3600
|
+
|
|
3601
|
+
const TextField = React.forwardRef((_a, ref) => {
|
|
3602
|
+
var {
|
|
3603
|
+
label,
|
|
3604
|
+
tip,
|
|
3605
|
+
helpText,
|
|
3606
|
+
helpAddon,
|
|
3607
|
+
errorMessage,
|
|
3608
|
+
isInvalid,
|
|
3609
|
+
maxLength,
|
|
3610
|
+
onChange,
|
|
3611
|
+
className,
|
|
3612
|
+
value,
|
|
3613
|
+
dataTestId
|
|
3614
|
+
} = _a,
|
|
3615
|
+
rest = __rest(_a, ["label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
|
|
3616
|
+
|
|
3617
|
+
const [valueLength, setValueLength] = React.useState(value ? `${value}`.length : 0);
|
|
3618
|
+
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
3619
|
+
const handleChange = React.useCallback(event => {
|
|
3620
|
+
setValueLength(event.target.value.length);
|
|
3621
|
+
|
|
3622
|
+
if (onChange) {
|
|
3623
|
+
onChange(event);
|
|
3624
|
+
}
|
|
3625
|
+
}, [onChange]);
|
|
3626
|
+
return jsx(FormGroup, Object.assign({
|
|
3627
|
+
label: label,
|
|
3628
|
+
tip: tip,
|
|
3629
|
+
isInvalid: renderAsInvalid,
|
|
3630
|
+
helpText: errorMessage || helpText,
|
|
3631
|
+
helpAddon: helpAddon || maxLength !== null && maxLength !== undefined && jsx(TextLengthIndicator, {
|
|
3632
|
+
length: valueLength,
|
|
3633
|
+
maxLength: maxLength
|
|
3634
|
+
}),
|
|
3635
|
+
dataTestId: `${dataTestId}-FormGroup`
|
|
3636
|
+
}, {
|
|
3637
|
+
children: jsx(TextInput, Object.assign({
|
|
3638
|
+
ref: ref,
|
|
3639
|
+
maxLength: maxLength,
|
|
3640
|
+
value: value,
|
|
3641
|
+
isInvalid: renderAsInvalid
|
|
3642
|
+
}, rest, {
|
|
3643
|
+
className: className,
|
|
3644
|
+
onChange: handleChange,
|
|
3645
|
+
dataTestId: dataTestId
|
|
3646
|
+
}))
|
|
3647
|
+
}));
|
|
3648
|
+
});
|
|
3649
|
+
TextField.displayName = "TextField";
|
|
3650
|
+
|
|
3651
|
+
const Toggle = React.forwardRef(({
|
|
3652
|
+
toggled = false,
|
|
3653
|
+
onChange,
|
|
3654
|
+
disabled,
|
|
3655
|
+
size = "default",
|
|
3656
|
+
id,
|
|
3657
|
+
tabIndex,
|
|
3658
|
+
required,
|
|
3659
|
+
className,
|
|
3660
|
+
dataTestId,
|
|
3661
|
+
onBlur,
|
|
3662
|
+
name
|
|
3663
|
+
}, ref) => {
|
|
3664
|
+
return jsxs(React.Fragment, {
|
|
3665
|
+
children: [jsx(HiddenInput, {
|
|
3666
|
+
name: name,
|
|
3667
|
+
type: "checkbox",
|
|
3668
|
+
checked: toggled,
|
|
3669
|
+
disabled: disabled,
|
|
3670
|
+
onChange: e => {
|
|
3671
|
+
e.stopPropagation();
|
|
3672
|
+
onChange(!toggled, e);
|
|
3673
|
+
},
|
|
3674
|
+
id: id,
|
|
3675
|
+
"aria-checked": toggled,
|
|
3676
|
+
role: "checkbox",
|
|
3677
|
+
tabIndex: tabIndex,
|
|
3678
|
+
required: required,
|
|
3679
|
+
ref: ref,
|
|
3680
|
+
"data-testid": dataTestId,
|
|
3681
|
+
onBlur: onBlur
|
|
3682
|
+
}), jsx(SwitchContainer, Object.assign({
|
|
3683
|
+
toggled: toggled,
|
|
3684
|
+
htmlFor: id,
|
|
3685
|
+
disabled: disabled,
|
|
3686
|
+
"$size": size,
|
|
3687
|
+
className: className
|
|
3688
|
+
}, {
|
|
3689
|
+
children: jsx(Switch, {
|
|
3690
|
+
"$toggled": toggled,
|
|
3691
|
+
"$size": size
|
|
3692
|
+
})
|
|
3693
|
+
}))]
|
|
3694
|
+
});
|
|
3695
|
+
});
|
|
3696
|
+
Toggle.displayName = "Toggle";
|
|
3697
|
+
const Switch = tw.span`
|
|
3698
|
+
rounded-full
|
|
3699
|
+
bg-white
|
|
3700
|
+
h-full
|
|
3701
|
+
aspect-square
|
|
3702
|
+
${({
|
|
3703
|
+
$toggled
|
|
3704
|
+
}) => $toggled ? tws`translate-x-4` : tws`translate-x-0`}
|
|
3705
|
+
transition-all
|
|
3706
|
+
`;
|
|
3707
|
+
const SwitchContainer = tw.label`
|
|
3708
|
+
flex
|
|
3709
|
+
items-center
|
|
3710
|
+
rounded-full
|
|
3711
|
+
p-1
|
|
3712
|
+
${({
|
|
3713
|
+
disabled
|
|
3714
|
+
}) => disabled ? tws`cursor-not-allowed pointer-events-none` : tws`cursor-pointer`};
|
|
3715
|
+
${({
|
|
3716
|
+
$size
|
|
3717
|
+
}) => $size === "small" ? tws`w-8 h-4` : tws`w-10 h-6`};
|
|
3718
|
+
${({
|
|
3719
|
+
toggled,
|
|
3720
|
+
disabled
|
|
3721
|
+
}) => disabled ? tws`bg-neutral-300` : toggled ? tws`bg-primary-400` : tws`bg-neutral-500`}
|
|
3722
|
+
transition-all
|
|
3723
|
+
active:shadow
|
|
3724
|
+
`;
|
|
3725
|
+
const HiddenInput = tw.input`
|
|
3726
|
+
absolute
|
|
3727
|
+
opacity-0
|
|
3728
|
+
-z-10
|
|
3729
|
+
`;
|
|
3730
|
+
|
|
3731
|
+
const useDebounce = (value, delay = 500) => {
|
|
3732
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
3733
|
+
useEffect(() => {
|
|
3734
|
+
const handler = setTimeout(() => {
|
|
3735
|
+
setDebouncedValue(value);
|
|
3736
|
+
}, delay);
|
|
3737
|
+
return () => {
|
|
3738
|
+
clearTimeout(handler);
|
|
3739
|
+
};
|
|
3740
|
+
}, [value, delay]);
|
|
3741
|
+
return debouncedValue;
|
|
3742
|
+
};
|
|
3743
|
+
|
|
3744
|
+
const useLocalStorage = (key, initialValue) => {
|
|
3745
|
+
if (!key) {
|
|
3746
|
+
throw new Error("useLocalStorage key may not be falsy");
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
const setLocalStorageItem = useCallback(value => window.localStorage.setItem(key, typeof value === "object" ? JSON.stringify(value) : `${value}`), [key]);
|
|
3750
|
+
const removeLocalStorageItem = useCallback(() => window.localStorage.removeItem(key), [key]);
|
|
3751
|
+
const [item, setValue] = useState(() => {
|
|
3752
|
+
const value = window.localStorage.getItem(key);
|
|
3753
|
+
|
|
3754
|
+
if (value !== undefined && value !== null) {
|
|
3755
|
+
const parsedValue = tryParse(value);
|
|
3756
|
+
return parsedValue;
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
return initialValue !== null && initialValue !== void 0 ? initialValue : null;
|
|
3760
|
+
});
|
|
3761
|
+
useEffect(() => {
|
|
3762
|
+
if (item !== undefined && item !== null) {
|
|
3763
|
+
setLocalStorageItem(item);
|
|
3764
|
+
} else {
|
|
3765
|
+
removeLocalStorageItem();
|
|
3766
|
+
}
|
|
3767
|
+
}, [item, setLocalStorageItem, removeLocalStorageItem, key]);
|
|
3768
|
+
/*
|
|
3769
|
+
// Sync local storage between tabs / windows
|
|
3770
|
+
useEffect(() => {
|
|
3771
|
+
const handleStorageChange = (e: StorageEvent) => {
|
|
3772
|
+
if (e.key === key) {
|
|
3773
|
+
setValue(tryParse(e.newValue));
|
|
3774
|
+
}
|
|
3775
|
+
};
|
|
3776
|
+
window.addEventListener("storage", handleStorageChange);
|
|
3777
|
+
return () => {
|
|
3778
|
+
window.removeEventListener("storage", handleStorageChange);
|
|
3779
|
+
};
|
|
3780
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3781
|
+
}, []);
|
|
3782
|
+
*/
|
|
3783
|
+
|
|
3784
|
+
const removeItem = () => {
|
|
3785
|
+
setValue(null);
|
|
3786
|
+
};
|
|
3787
|
+
|
|
3788
|
+
return [item, setValue, removeItem];
|
|
3789
|
+
};
|
|
3790
|
+
|
|
3791
|
+
function tryParse(value) {
|
|
3792
|
+
try {
|
|
3793
|
+
return JSON.parse(value);
|
|
3794
|
+
} catch (_a) {
|
|
3795
|
+
return value;
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
|
|
3799
|
+
const useTimeout = ({
|
|
3800
|
+
onTimeout,
|
|
3801
|
+
duration
|
|
3802
|
+
}) => {
|
|
3803
|
+
const [activated, setActivated] = useState(true);
|
|
3804
|
+
const timeoutRef = useRef();
|
|
3805
|
+
const startTimeout = useCallback(() => {
|
|
3806
|
+
setActivated(true);
|
|
3807
|
+
}, []);
|
|
3808
|
+
const stopTimeout = useCallback(() => {
|
|
3809
|
+
window.clearTimeout(timeoutRef.current);
|
|
3810
|
+
setActivated(false);
|
|
3811
|
+
}, []);
|
|
3812
|
+
useEffect(() => {
|
|
3813
|
+
if (activated) {
|
|
3814
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
3815
|
+
onTimeout();
|
|
3816
|
+
}, duration);
|
|
3817
|
+
}
|
|
3818
|
+
|
|
3819
|
+
return () => {
|
|
3820
|
+
stopTimeout();
|
|
3821
|
+
};
|
|
3822
|
+
}, [onTimeout, activated, duration, stopTimeout]);
|
|
3823
|
+
return {
|
|
3824
|
+
startTimeout,
|
|
3825
|
+
stopTimeout
|
|
3826
|
+
};
|
|
3827
|
+
};
|
|
3828
|
+
|
|
3829
|
+
export { Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuButton, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiRowTableCell, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SkeletonLines, Spacer, Spinner, StarButton, Text, TextArea, TextField, TextInput, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, activityColors, colors, criticalityColors, docs, generalColors, intentColors, useBlocker, useContainerProps, useCustomComponents, useCustomStyles, useDebounce, useInRouterContext, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
|