@trackunit/react-components 0.1.114 → 0.1.116
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/index.cjs +757 -503
- package/index.js +748 -502
- package/package.json +3 -4
- package/src/components/Alert/Alert.d.ts +1 -1
- package/src/components/Badge/Badge.d.ts +1 -6
- package/src/components/Badge/Badge.variants.d.ts +3 -0
- package/src/components/Drawer/Drawer.variants.d.ts +4 -0
- package/src/components/Heading/Heading.variants.d.ts +5 -0
- package/src/components/Icon/Icon.d.ts +4 -3
- package/src/components/Icon/Icon.variants.d.ts +8 -0
- package/src/components/Indicator/Indicator.d.ts +1 -1
- package/src/components/Indicator/Indicator.variants.d.ts +10 -0
- package/src/components/PageHeader/PageHeader.variants.d.ts +5 -0
- package/src/components/Pagination/Pagination.variants.d.ts +2 -0
- package/src/components/Popover/Popover.variants.d.ts +5 -0
- package/src/components/Sidebar/Sidebar.variants.d.ts +4 -0
- package/src/components/SkeletonLines/SkeletonLines.variants.d.ts +1 -0
- package/src/components/Spacer/Spacer.d.ts +3 -3
- package/src/components/Spacer/Spacer.variants.d.ts +4 -0
- package/src/components/Spinner/Spinner.variants.d.ts +7 -0
- package/src/components/Tag/Tag.d.ts +3 -2
- package/src/components/Tag/Tag.variants.d.ts +7 -0
- package/src/components/Timeline/Timeline.variants.d.ts +3 -0
- package/src/components/Tip/Tip.d.ts +3 -7
- package/src/components/Tip/Tip.variants.d.ts +4 -0
- package/src/components/Tooltip/Tooltip.variants.d.ts +6 -0
- package/src/components/ValueBar/ValueBar.variants.d.ts +9 -0
- package/src/components/buttons/BackToTopButton/BackToTopButton.d.ts +1 -1
- package/src/components/buttons/BackToTopButton/BackToTopButton.variants.d.ts +3 -0
- package/src/components/buttons/Button/Button.d.ts +1 -10
- package/src/components/buttons/IconButton/IconButton.d.ts +0 -5
- package/src/components/buttons/shared/Button.variants.d.ts +13 -0
- package/src/components/buttons/shared/ButtonProps.d.ts +5 -1
- package/src/index.d.ts +2 -0
- package/index.css +0 -194
- package/src/components/buttons/shared/helpers.d.ts +0 -20
package/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useState, useMemo, createContext, useContext, forwardRef, isValidElement, cloneElement, useCallback, useEffect, Children, useRef, useReducer, memo } from 'react';
|
|
4
4
|
import { tw, tws, twx } from '@trackunit/tailwind-styled-components';
|
|
5
|
-
import { HeroIconsArray, heroIconLookup, TrackunitSolidIconsArray, TrackunitOutlineIconsArray, trackunitIconLookup } from '@trackunit/ui-icons';
|
|
6
5
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
6
|
+
import { HeroIconsArray, heroIconLookup, TrackunitSolidIconsArray, TrackunitOutlineIconsArray, trackunitIconLookup } from '@trackunit/ui-icons';
|
|
7
7
|
import { useMeasure, useCopyToClipboard } from 'react-use';
|
|
8
8
|
import { DayPicker as DayPicker$1 } from 'react-day-picker';
|
|
9
9
|
import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
|
|
@@ -68,6 +68,45 @@ function __rest(s, e) {
|
|
|
68
68
|
return t;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
const cvaSpinner = cvaMerge([
|
|
72
|
+
"bg-transparent",
|
|
73
|
+
"rounded-full",
|
|
74
|
+
"border-2",
|
|
75
|
+
"border-solid",
|
|
76
|
+
"inline-block",
|
|
77
|
+
"animate-spin",
|
|
78
|
+
"cursor-wait",
|
|
79
|
+
"text-current",
|
|
80
|
+
], {
|
|
81
|
+
variants: {
|
|
82
|
+
size: {
|
|
83
|
+
small: ["w-4", "h-4"],
|
|
84
|
+
medium: ["w-6", "h-6"],
|
|
85
|
+
large: ["w-8", "h-8"],
|
|
86
|
+
},
|
|
87
|
+
mode: {
|
|
88
|
+
dark: ["border-white/[0.32]", "border-b-white/75"],
|
|
89
|
+
light: ["border-slate-900/25", "border-b-slate-900/50"],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
defaultVariants: {
|
|
93
|
+
size: "medium",
|
|
94
|
+
mode: "light",
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const cvaSpinnerContainer = cvaMerge(["box-border", "p-0.5", "overflow-hidden"], {
|
|
98
|
+
variants: {
|
|
99
|
+
centering: {
|
|
100
|
+
centered: ["grid", "h-full", "w-full", "place-items-center"],
|
|
101
|
+
vertically: ["grid", "h-full", "items-center"],
|
|
102
|
+
horizontally: ["grid", "w-full", "justify-items-center"],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
defaultVariants: {
|
|
106
|
+
centering: "centered",
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
71
110
|
/**
|
|
72
111
|
* The spinner component provides visual feedback that data is being processed.
|
|
73
112
|
*
|
|
@@ -83,81 +122,195 @@ function __rest(s, e) {
|
|
|
83
122
|
* @returns {JSX.Element} Spinner component
|
|
84
123
|
*/
|
|
85
124
|
const Spinner = ({ mode = "light", size = "medium", centering = "centered", className, containerClassName, dataTestId, }) => {
|
|
86
|
-
return (jsx(
|
|
87
|
-
};
|
|
88
|
-
const getSpinnerStyles = () => ({ $size }) => {
|
|
89
|
-
switch ($size) {
|
|
90
|
-
case "small":
|
|
91
|
-
return tws `tu-spinner--small`;
|
|
92
|
-
case "large":
|
|
93
|
-
return tws `tu-spinner--large`;
|
|
94
|
-
case "medium":
|
|
95
|
-
default:
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const getCenteringStyles = () => ({ $centering }) => {
|
|
100
|
-
switch ($centering) {
|
|
101
|
-
case "centered":
|
|
102
|
-
return tws `tu-spinner--container-centered`;
|
|
103
|
-
case "horizontally":
|
|
104
|
-
return tws `tu-spinner--container-centered-horizontally`;
|
|
105
|
-
case "vertically":
|
|
106
|
-
return tws `tu-spinner--container-centered-vertically`;
|
|
107
|
-
default:
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const StyledSpinner$1 = tw.span `
|
|
112
|
-
tu-spinner
|
|
113
|
-
${p => (p.$mode === "dark" ? tws `tu-spinner--dark` : null)}
|
|
114
|
-
${getSpinnerStyles()}
|
|
115
|
-
`;
|
|
116
|
-
const Container$4 = tw.div `
|
|
117
|
-
tu-spinner--container
|
|
118
|
-
${getCenteringStyles()}
|
|
119
|
-
|
|
120
|
-
`;
|
|
125
|
+
return (jsx("div", Object.assign({ className: cvaSpinnerContainer({ centering, className: containerClassName }) }, { children: jsx("div", { role: "spinbutton", className: cvaSpinner({ size, mode, className }), "data-testid": dataTestId }) })));
|
|
126
|
+
};
|
|
121
127
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
const cvaButton = cvaMerge([
|
|
129
|
+
"flex-row",
|
|
130
|
+
"inline-flex",
|
|
131
|
+
"gap-2",
|
|
132
|
+
"box-border",
|
|
133
|
+
"justify-center",
|
|
134
|
+
"items-center",
|
|
135
|
+
"whitespace-nowrap",
|
|
136
|
+
"max-w-full",
|
|
137
|
+
"outline-0",
|
|
138
|
+
"outline-current",
|
|
139
|
+
"transition-all",
|
|
140
|
+
"ease-in-out",
|
|
141
|
+
"component-button-border",
|
|
142
|
+
"cursor-pointer",
|
|
143
|
+
"flex-none",
|
|
144
|
+
"py-1.5",
|
|
145
|
+
"component-button-padding",
|
|
146
|
+
"component-button-height",
|
|
147
|
+
"focus:ring",
|
|
148
|
+
"focus:ring-offset-1",
|
|
149
|
+
"focus:outline-none",
|
|
150
|
+
"disabled:cursor-not-allowed",
|
|
151
|
+
"text-sm",
|
|
152
|
+
"font-medium",
|
|
153
|
+
"align-middle",
|
|
154
|
+
], {
|
|
155
|
+
variants: {
|
|
156
|
+
color: {
|
|
157
|
+
primary: [
|
|
158
|
+
"bg-primary-600",
|
|
159
|
+
"text-white",
|
|
160
|
+
"hover:bg-primary-800",
|
|
161
|
+
"active:bg-primary-700",
|
|
162
|
+
"focus:ring-primary-300",
|
|
163
|
+
"disabled:hover:bg-slate-400",
|
|
164
|
+
"disabled:bg-slate-400",
|
|
165
|
+
"disabled:text-slate-200",
|
|
166
|
+
],
|
|
167
|
+
secondary: [
|
|
168
|
+
"component-button-secondary-color",
|
|
169
|
+
"hover:bg-secondary-400",
|
|
170
|
+
"hover:text-secondary-800",
|
|
171
|
+
"active:text-secondary-700",
|
|
172
|
+
"active:bg-secondary-300",
|
|
173
|
+
"focus:ring-secondary-300",
|
|
174
|
+
"disabled:bg-secondary-200",
|
|
175
|
+
"disabled:hover:bg-secondary-200",
|
|
176
|
+
"disabled:text-secondary-400",
|
|
177
|
+
],
|
|
178
|
+
danger: [
|
|
179
|
+
"bg-danger-600",
|
|
180
|
+
"text-white",
|
|
181
|
+
"hover:bg-danger-800",
|
|
182
|
+
"active:bg-danger-700",
|
|
183
|
+
"focus:ring-danger-300",
|
|
184
|
+
"disabled:bg-slate-200",
|
|
185
|
+
"disabled:hover:bg-slate-200",
|
|
186
|
+
"disabled:text-slate-400",
|
|
187
|
+
],
|
|
188
|
+
warning: [
|
|
189
|
+
"bg-warning-50",
|
|
190
|
+
"text-warning-600",
|
|
191
|
+
"hover:bg-warning-200",
|
|
192
|
+
"hover:text-warning-800",
|
|
193
|
+
"active:text-warning-700",
|
|
194
|
+
"active:bg-warning-100",
|
|
195
|
+
"focus:ring-warning-300",
|
|
196
|
+
"disabled:bg-warning-50",
|
|
197
|
+
"disabled:hover:bg-warning-50",
|
|
198
|
+
"disabled:text-slate-400",
|
|
199
|
+
],
|
|
200
|
+
tertiary: [
|
|
201
|
+
"bg-white",
|
|
202
|
+
"border",
|
|
203
|
+
"text-slate-600",
|
|
204
|
+
"active:bg-slate-100",
|
|
205
|
+
"active:text-slate-700",
|
|
206
|
+
"focus:ring-slate-300",
|
|
207
|
+
"hover:bg-slate-200",
|
|
208
|
+
"hover:text-slate-800",
|
|
209
|
+
"border-slate-300",
|
|
210
|
+
"disabled:bg-slate-200",
|
|
211
|
+
"disabled:hover:bg-slate-200",
|
|
212
|
+
"disabled:text-slate-400",
|
|
213
|
+
],
|
|
135
214
|
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
tertiary: tws `tu-button--transparent-tertiary`,
|
|
141
|
-
warning: tws `tu-button--transparent-warning`,
|
|
215
|
+
size: {
|
|
216
|
+
small: ["py-1", "px-2"],
|
|
217
|
+
medium: "",
|
|
218
|
+
large: ["py-2", "px-4"],
|
|
142
219
|
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
220
|
+
rounded: {
|
|
221
|
+
true: ["rounded-full"],
|
|
222
|
+
false: [],
|
|
223
|
+
},
|
|
224
|
+
fullWidth: {
|
|
225
|
+
true: ["w-full", "flex-auto"],
|
|
226
|
+
false: [],
|
|
227
|
+
},
|
|
228
|
+
square: {
|
|
229
|
+
true: "aspect-square",
|
|
230
|
+
false: "",
|
|
231
|
+
},
|
|
232
|
+
disabled: {
|
|
233
|
+
true: ["cursor-not-allowed", "pointer-events-none", "bg-slate-200", "hover:bg-slate-200", "text-slate-400"],
|
|
234
|
+
false: [],
|
|
235
|
+
},
|
|
236
|
+
variant: {
|
|
237
|
+
transparent: "bg-transparent disabled:hover:bg-transparent border-none",
|
|
238
|
+
filled: "",
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
compoundVariants: [
|
|
242
|
+
{
|
|
243
|
+
color: "primary",
|
|
244
|
+
variant: "transparent",
|
|
245
|
+
className: [
|
|
246
|
+
"text-primary-600",
|
|
247
|
+
"hover:text-primary-700",
|
|
248
|
+
"active:bg-primary-700",
|
|
249
|
+
"focus:ring-primary-300",
|
|
250
|
+
"hover:bg-primary-500/10",
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
color: "secondary",
|
|
255
|
+
variant: "transparent",
|
|
256
|
+
className: [
|
|
257
|
+
"text-secondary-600",
|
|
258
|
+
"hover:text-secondary-800",
|
|
259
|
+
"active:text-secondary-700",
|
|
260
|
+
"active:bg-black/10",
|
|
261
|
+
"focus:ring-secondary-300",
|
|
262
|
+
"hover:bg-black/5",
|
|
263
|
+
],
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
color: "warning",
|
|
267
|
+
variant: "transparent",
|
|
268
|
+
className: [
|
|
269
|
+
"text-warning-600",
|
|
270
|
+
"active:bg-warning-500/20",
|
|
271
|
+
"focus:ring-warning-300",
|
|
272
|
+
"hover:bg-warning-500/10",
|
|
273
|
+
],
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
color: "danger",
|
|
277
|
+
variant: "transparent",
|
|
278
|
+
className: ["text-danger-600", "active:bg-danger-600/10", "focus:ring-danger-300", "hover:bg-danger-600/10"],
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
color: "tertiary",
|
|
282
|
+
variant: "transparent",
|
|
283
|
+
className: ["text-slate-600", "active:bg-slate-200/20", "focus:ring-slate-300", "hover:bg-slate-600/10"],
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
disabled: true,
|
|
287
|
+
variant: "transparent",
|
|
288
|
+
className: ["cursor-not-allowed", "pointer-events-none", "hover:bg-transparent"],
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
defaultVariants: {
|
|
292
|
+
color: "primary",
|
|
293
|
+
size: "medium",
|
|
294
|
+
rounded: false,
|
|
295
|
+
fullWidth: false,
|
|
296
|
+
square: false,
|
|
297
|
+
disabled: false,
|
|
298
|
+
variant: "filled",
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
const cvaButtonSpinner = cvaMerge(["!w-[1em]", "!h-[1em]"]);
|
|
302
|
+
const cvaIconButtonContainer = cvaMerge(["w-5", "h-5", "flex", "justify-center", "items-center", "box-border"], {
|
|
303
|
+
variants: {
|
|
304
|
+
size: {
|
|
305
|
+
small: ["flex", "justify-center", "items-center", "box-border"],
|
|
306
|
+
medium: "",
|
|
307
|
+
large: "",
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
defaultVariants: {
|
|
311
|
+
size: "medium",
|
|
312
|
+
},
|
|
313
|
+
});
|
|
161
314
|
|
|
162
315
|
/**
|
|
163
316
|
* Buttons allow users to perform an action when triggered.
|
|
@@ -166,40 +319,75 @@ const getPadding = () => ({ $size }) => {
|
|
|
166
319
|
* @returns {JSX.Element} Button component
|
|
167
320
|
*/
|
|
168
321
|
const Button = React.forwardRef((_a, ref) => {
|
|
169
|
-
var { onClick, children, loading, disabled, className, fullWidth = false, prefix, suffix, color = "primary", variant = "filled", type = "button", size = "medium", square = false, dataTestId, title, role, tabIndex, renderAs = "button" } = _a, rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "color", "variant", "type", "size", "square", "dataTestId", "title", "role", "tabIndex", "renderAs"]);
|
|
170
|
-
return (jsxs(StyledButton
|
|
322
|
+
var { onClick, children, loading, disabled, className, fullWidth = false, prefix, suffix, color = "primary", variant = "filled", type = "button", size = "medium", square = false, dataTestId, title, role, tabIndex, renderAs = "button", circular } = _a, rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "color", "variant", "type", "size", "square", "dataTestId", "title", "role", "tabIndex", "renderAs", "circular"]);
|
|
323
|
+
return (jsxs(StyledButton, Object.assign({ "$as": renderAs, onClick: onClick, disabled: disabled || loading, type: type, className: cvaButton({ rounded: circular, disabled, size, square, color, variant, fullWidth, className }), title: title, "aria-label": title, role: role, tabIndex: tabIndex, "data-testid": dataTestId, ref: ref }, rest, { children: [loading && jsx(Spinner, { className: cvaButtonSpinner(), centering: "vertically" }), prefix, children, suffix] })));
|
|
171
324
|
});
|
|
172
|
-
const StyledButton
|
|
173
|
-
tu-button
|
|
174
|
-
${p => p.$square && tws `tu-button--square`}
|
|
175
|
-
${p => p.$fullWidth && tws `tu-button--full-width`}
|
|
176
|
-
${p => p.disabled &&
|
|
177
|
-
p.$as !== "button" &&
|
|
178
|
-
(p.$variant === "transparent" ? tws `tu-button__disabled--transparent` : tws `tu-button__disabled`)}
|
|
179
|
-
${getStyles()}
|
|
180
|
-
${getPadding()}
|
|
181
|
-
`;
|
|
182
|
-
const StyledSpinner = twx(Spinner) `
|
|
183
|
-
tu-button__spinner
|
|
184
|
-
`;
|
|
325
|
+
const StyledButton = tw.button ``;
|
|
185
326
|
|
|
186
327
|
const IconButton = React.forwardRef((_a, ref) => {
|
|
187
|
-
var { icon, size = "small", square = true,
|
|
188
|
-
return (jsx(
|
|
328
|
+
var { icon, size = "small", square = true, loading, disabled } = _a, rest = __rest(_a, ["icon", "size", "square", "loading", "disabled"]);
|
|
329
|
+
return (jsx(Button, Object.assign({ size: size, square: square, disabled: disabled || loading, ref: ref }, rest, { children: jsx("div", Object.assign({ className: cvaIconButtonContainer({ size }) }, { children: loading ? jsx(Spinner, { size: size }) : icon })) })));
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
const cvaIcon = cvaMerge(["aspect-square", "inline-grid", "relative"], {
|
|
333
|
+
variants: {
|
|
334
|
+
color: {
|
|
335
|
+
primary: "text-primary-600",
|
|
336
|
+
secondary: "text-secondary-600",
|
|
337
|
+
accent: "text-accent-600",
|
|
338
|
+
neutral: "text-neutral-600",
|
|
339
|
+
info: "text-info-600",
|
|
340
|
+
success: "text-success-600",
|
|
341
|
+
warning: "text-warning-600",
|
|
342
|
+
danger: "text-danger-600",
|
|
343
|
+
good: "text-good-600",
|
|
344
|
+
low: "text-low-600",
|
|
345
|
+
critical: "text-critical-600",
|
|
346
|
+
working: "text-working-600",
|
|
347
|
+
idle: "text-idle-600",
|
|
348
|
+
moving: "text-moving",
|
|
349
|
+
active: "text-active",
|
|
350
|
+
stopped: "text-stopped-600",
|
|
351
|
+
unknown: "text-unknown-600",
|
|
352
|
+
default: "text-current",
|
|
353
|
+
black: "text-black",
|
|
354
|
+
white: "text-white",
|
|
355
|
+
},
|
|
356
|
+
size: {
|
|
357
|
+
small: "w-4",
|
|
358
|
+
medium: "w-5",
|
|
359
|
+
large: "w-6",
|
|
360
|
+
font: "w-[1em]",
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
defaultVariants: {
|
|
364
|
+
color: "default",
|
|
365
|
+
size: "large",
|
|
366
|
+
},
|
|
189
367
|
});
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
368
|
+
const cvaIconComponent = cvaMerge([], {
|
|
369
|
+
variants: {
|
|
370
|
+
iconType: {
|
|
371
|
+
solid: "fill-current stroke-transparent",
|
|
372
|
+
outline: "fill-transparent stroke-current",
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
const cvaLoadingDot = cvaMerge([
|
|
377
|
+
"relative",
|
|
378
|
+
"aspect-square",
|
|
379
|
+
"after:content-['']",
|
|
380
|
+
"after:absolute",
|
|
381
|
+
"after:h-2",
|
|
382
|
+
"after:w-2",
|
|
383
|
+
"after:bg-current",
|
|
384
|
+
"after:rounded-full",
|
|
385
|
+
"after:inset-1/2",
|
|
386
|
+
"after:-translate-x-1/2",
|
|
387
|
+
"after:-translate-y-1/2",
|
|
388
|
+
"after:opacity-50",
|
|
389
|
+
]);
|
|
197
390
|
|
|
198
|
-
const IconSizeClassMap = {
|
|
199
|
-
small: tws `tu-icon--small`,
|
|
200
|
-
medium: tws `tu-icon--medium`,
|
|
201
|
-
large: tws `tu-icon--large`, // 24x24px
|
|
202
|
-
};
|
|
203
391
|
/**
|
|
204
392
|
* - The Icon component is used to display an Icon.
|
|
205
393
|
* - Icons are semantic vector graphics that adds character and improves the visual appeal of elements when combined with.
|
|
@@ -209,9 +397,7 @@ const IconSizeClassMap = {
|
|
|
209
397
|
* @returns {JSX.Element} Icon component
|
|
210
398
|
*/
|
|
211
399
|
const Icon = ({ name, size = "large", className, dataTestId, color, onClick, fillColor, type, style, forwardedRef, }) => {
|
|
212
|
-
const iconSizeClassName = React.useMemo(() => IconSizeClassMap[size], [size]);
|
|
213
400
|
const correctIconType = React.useMemo(() => (type ? type : size === "large" ? "outline" : "solid"), [type, size]);
|
|
214
|
-
const colorClassNames = React.useMemo(() => (correctIconType === "solid" ? tws `fill-current stroke-transparent` : tws `fill-transparent stroke-current`), [correctIconType]);
|
|
215
401
|
let IconComponent = null;
|
|
216
402
|
if (HeroIconsArray.find(icon => icon === name)) {
|
|
217
403
|
IconComponent = heroIconLookup(name, correctIconType);
|
|
@@ -223,54 +409,10 @@ const Icon = ({ name, size = "large", className, dataTestId, color, onClick, fil
|
|
|
223
409
|
if (!IconComponent) {
|
|
224
410
|
return null;
|
|
225
411
|
}
|
|
226
|
-
return (jsx(React.Suspense, Object.assign({ fallback: jsx(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
`;
|
|
231
|
-
const Root$5 = tw.span `
|
|
232
|
-
tu-icon
|
|
233
|
-
${({ $color }) => {
|
|
234
|
-
switch ($color) {
|
|
235
|
-
case "primary":
|
|
236
|
-
return tws `tu-icon--primary`;
|
|
237
|
-
case "secondary":
|
|
238
|
-
return tws `tu-icon--secondary`;
|
|
239
|
-
case "accent":
|
|
240
|
-
return tws `tu-icon--accent`;
|
|
241
|
-
case "neutral":
|
|
242
|
-
return tws `tu-icon--neutral`;
|
|
243
|
-
case "info":
|
|
244
|
-
return tws `tu-icon--info`;
|
|
245
|
-
case "success":
|
|
246
|
-
return tws `tu-icon--success`;
|
|
247
|
-
case "warning":
|
|
248
|
-
return tws `tu-icon--warning`;
|
|
249
|
-
case "danger":
|
|
250
|
-
return tws `tu-icon--danger`;
|
|
251
|
-
case "good":
|
|
252
|
-
return tws `tu-icon--good`;
|
|
253
|
-
case "low":
|
|
254
|
-
return tws `tu-icon--low`;
|
|
255
|
-
case "critical":
|
|
256
|
-
return tws `tu-icon--critical`;
|
|
257
|
-
case "working":
|
|
258
|
-
return tws `tu-icon--working`;
|
|
259
|
-
case "idle":
|
|
260
|
-
return tws `tu-icon--idle`;
|
|
261
|
-
case "stopped":
|
|
262
|
-
return tws `tu-icon--stopped`;
|
|
263
|
-
case "moving":
|
|
264
|
-
return tws `tu-icon--moving`;
|
|
265
|
-
case "unknown":
|
|
266
|
-
return tws `tu-icon--unknown`;
|
|
267
|
-
case "white":
|
|
268
|
-
return tws `text-white`;
|
|
269
|
-
default:
|
|
270
|
-
return "tu-icon--default";
|
|
271
|
-
}
|
|
272
|
-
}}
|
|
273
|
-
`;
|
|
412
|
+
return (jsx(React.Suspense, Object.assign({ fallback: jsx("span", { className: cvaLoadingDot(), "data-testid": dataTestId }) }, { children: jsx("span", Object.assign({ className: cvaIcon({ color, size, className }), onClick: onClick, "data-testid": dataTestId, ref: forwardedRef }, { children: jsx(IconComponent, { "data-testid": dataTestId ? `${dataTestId}-${name}` : name, className: cvaIconComponent({
|
|
413
|
+
iconType: correctIconType,
|
|
414
|
+
}), style: fillColor ? Object.assign(Object.assign({}, style), { fill: fillColor }) : Object.assign({}, style) }) })) })));
|
|
415
|
+
};
|
|
274
416
|
|
|
275
417
|
/**
|
|
276
418
|
* The StarButton component is used for favorite actions or similar.
|
|
@@ -279,20 +421,8 @@ const Root$5 = tw.span `
|
|
|
279
421
|
* @returns {JSX.Element} StarButton component
|
|
280
422
|
*/
|
|
281
423
|
const StarButton = ({ starred, onClick }) => {
|
|
282
|
-
return (jsx(
|
|
283
|
-
};
|
|
284
|
-
const Flex$1 = tw.div `
|
|
285
|
-
flex
|
|
286
|
-
items-center
|
|
287
|
-
`;
|
|
288
|
-
const CustomIcon = twx(Icon) `
|
|
289
|
-
cursor-pointer
|
|
290
|
-
w-5
|
|
291
|
-
h-5
|
|
292
|
-
hover:!fill-primary-400
|
|
293
|
-
hover:!stroke-transparent
|
|
294
|
-
${p => (p.$starred ? tws `!fill-primary-600 !stroke-transparent` : tws `!fill-transparent !stroke-neutral-800`)}
|
|
295
|
-
`;
|
|
424
|
+
return (jsx("div", Object.assign({ onClick: onClick, "data-test-id": "starred-filter" }, { children: jsx(Icon, { name: "StarIcon", color: starred ? "primary" : "neutral", type: starred ? "solid" : "outline", size: "medium" }) })));
|
|
425
|
+
};
|
|
296
426
|
|
|
297
427
|
/**
|
|
298
428
|
* The Text component is used to apply Trackunit default typography styles to text.
|
|
@@ -304,8 +434,8 @@ const CustomIcon = twx(Icon) `
|
|
|
304
434
|
* @param {TextProps} props - The props for the Text component
|
|
305
435
|
* @returns {JSX.Element} Text component
|
|
306
436
|
*/
|
|
307
|
-
const Text
|
|
308
|
-
return (jsx(StyledText
|
|
437
|
+
const Text = ({ children, type = "p", size = "medium", align = "left", weight = "normal", underline = false, inverted = false, subtle = false, italicize = false, uppercase = false, className, dataTestId, }) => {
|
|
438
|
+
return (jsx(StyledText, Object.assign({ "$as": type, className: className, "$align": align, "$inverted": inverted, "$subtle": subtle, "$italicize": italicize, "$uppercase": uppercase, "$size": size, "$weight": weight, "$underline": underline, "data-testid": dataTestId }, { children: children })));
|
|
309
439
|
};
|
|
310
440
|
const getTextSize = () => ({ $size }) => {
|
|
311
441
|
const sizes = {
|
|
@@ -323,7 +453,7 @@ const getTextWeight = () => ({ $weight }) => {
|
|
|
323
453
|
};
|
|
324
454
|
return weights[$weight];
|
|
325
455
|
};
|
|
326
|
-
const getFontColor
|
|
456
|
+
const getFontColor = () => ({ $inverted, $subtle }) => {
|
|
327
457
|
const subtle = $inverted ? tws `tu-text--subtle-inverted` : tws `tu-text--subtle`;
|
|
328
458
|
const inverted = $inverted ? tws `tu-text--inverted` : null;
|
|
329
459
|
return $subtle ? subtle : inverted;
|
|
@@ -336,9 +466,9 @@ const getTextAlignment = () => ({ $align }) => {
|
|
|
336
466
|
};
|
|
337
467
|
return alignments[$align];
|
|
338
468
|
};
|
|
339
|
-
const StyledText
|
|
469
|
+
const StyledText = tw.text `
|
|
340
470
|
tu-text
|
|
341
|
-
${getFontColor
|
|
471
|
+
${getFontColor()}
|
|
342
472
|
${p => (p.$italicize ? tws `tu-text--italic` : "")}
|
|
343
473
|
${p => (p.$uppercase ? tws `tu-text--uppercase` : "")}
|
|
344
474
|
${getTextAlignment()}
|
|
@@ -442,7 +572,7 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
442
572
|
return "primary";
|
|
443
573
|
}
|
|
444
574
|
};
|
|
445
|
-
const body = inline ? (jsxs("div", { children: [title && jsx(Text
|
|
575
|
+
const body = inline ? (jsxs("div", { children: [title && jsx(Text, Object.assign({ weight: "bold" }, { children: title !== null && title !== void 0 ? title : children })), children && jsx(Text, Object.assign({ weight: !title ? "bold" : "normal" }, { children: children }))] })) : (jsxs(Fragment, { children: [title && jsx(Text, Object.assign({ weight: "bold" }, { children: title !== null && title !== void 0 ? title : children })), children && jsx(Text, Object.assign({ weight: !title ? "bold" : "normal" }, { children: children }))] }));
|
|
446
576
|
React.useEffect(() => {
|
|
447
577
|
if (autoScroll) {
|
|
448
578
|
ref && ref.current && ref.current.scrollIntoView && ref.current.scrollIntoView();
|
|
@@ -452,6 +582,37 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
452
582
|
return (jsxs("div", Object.assign({ className: cvaAlert({ color, layout, className }), "data-testid": dataTestId, ref: ref, role: "alert" }, { children: [jsx("div", Object.assign({ className: cvaAlertIconContainer({ layout }) }, { children: getIconFromColor() })), jsxs("div", Object.assign({ className: cvaAlertContent({ layout }) }, { children: [jsxs("div", Object.assign({ className: cvaAlertDetails() }, { children: [jsx("div", Object.assign({ className: cvaAlertContentBody() }, { children: body })), onClose && !inline ? (jsx("div", Object.assign({ className: cvaAlertCloseButtonContainer({ layout }) }, { children: jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsx(Icon, { name: "XMarkIcon", size: "small" }), title: "Close Alert", circular: true }) }))) : null] })), (primaryAction || secondaryAction || onClose) && (jsxs("div", Object.assign({ className: cvaAlertRightAligned({ layout }) }, { children: [secondaryAction && (jsx(Button, Object.assign({ size: "small", variant: "transparent", color: getButtonColor(), onClick: secondaryAction.onClick, loading: secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.loading }, { children: secondaryAction.label }))), primaryAction && (jsx(Button, Object.assign({ size: "small", color: getButtonColor(), onClick: primaryAction.onClick, loading: primaryAction === null || primaryAction === void 0 ? void 0 : primaryAction.loading }, { children: primaryAction.label }))), onClose && inline ? (jsx("div", Object.assign({ className: cvaAlertCloseButtonContainer({ layout }) }, { children: jsx(IconButton, { size: "small", variant: "transparent", color: "secondary", onClick: onClose, icon: jsx(Icon, { name: "XMarkIcon", size: "small" }), title: "Close Alert", circular: true }) }))) : null] })))] }))] })));
|
|
453
583
|
};
|
|
454
584
|
|
|
585
|
+
const cvaBadge = cvaMerge([
|
|
586
|
+
"uppercase",
|
|
587
|
+
"align-middle",
|
|
588
|
+
"box-border",
|
|
589
|
+
"whitespace-nowrap",
|
|
590
|
+
"overflow-hidden",
|
|
591
|
+
"text-ellipsis",
|
|
592
|
+
"inline-block",
|
|
593
|
+
"rounded-full",
|
|
594
|
+
"font-bold",
|
|
595
|
+
"text-center",
|
|
596
|
+
"tabular-nums",
|
|
597
|
+
"w-min",
|
|
598
|
+
"h-min",
|
|
599
|
+
"min-h-[0.5rem]",
|
|
600
|
+
"min-w-[1.5rem]",
|
|
601
|
+
"text-xs",
|
|
602
|
+
"px-1",
|
|
603
|
+
"py-0.5",
|
|
604
|
+
], {
|
|
605
|
+
variants: {
|
|
606
|
+
color: {
|
|
607
|
+
primary: "bg-primary-600 text-white",
|
|
608
|
+
danger: "bg-danger-700 text-white",
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
defaultVariants: {
|
|
612
|
+
color: "primary",
|
|
613
|
+
},
|
|
614
|
+
});
|
|
615
|
+
|
|
455
616
|
/**
|
|
456
617
|
* The Badge component is used to display a notification badge with an optional number value.
|
|
457
618
|
*
|
|
@@ -459,25 +620,13 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
459
620
|
* @returns {JSX.Element} Badge component
|
|
460
621
|
*/
|
|
461
622
|
const Badge = (_a) => {
|
|
462
|
-
var { color = "primary",
|
|
623
|
+
var { color = "primary", className, count, max, hideZero = false, dataTestId } = _a; __rest(_a, ["color", "className", "count", "max", "hideZero", "dataTestId"]);
|
|
463
624
|
if (hideZero && count === 0) {
|
|
464
625
|
return null;
|
|
465
626
|
}
|
|
466
627
|
const displayedCount = count && max ? (count > max ? `${max}+` : count) : count;
|
|
467
|
-
return (jsx(
|
|
468
|
-
};
|
|
469
|
-
const getBadgeModifierClass = () => ({ $color, $subtle }) => {
|
|
470
|
-
const colorClasses = {
|
|
471
|
-
primary: $subtle ? tws `tu-badge--primary-subtle` : tws `tu-badge--primary`,
|
|
472
|
-
danger: $subtle ? tws `tu-badge--danger-subtle` : tws `tu-badge--danger`,
|
|
473
|
-
};
|
|
474
|
-
return colorClasses[$color];
|
|
475
|
-
};
|
|
476
|
-
const StyledText$2 = tw.text `
|
|
477
|
-
tu-badge
|
|
478
|
-
${({ $count }) => ($count === null || $count === undefined) && tws `tu-badge--square`}
|
|
479
|
-
${getBadgeModifierClass()}
|
|
480
|
-
`;
|
|
628
|
+
return (jsx("span", Object.assign({ className: cvaBadge({ color, className }), "data-testid": dataTestId }, { children: displayedCount })));
|
|
629
|
+
};
|
|
481
630
|
|
|
482
631
|
const cvaCard = cvaMerge([
|
|
483
632
|
"flex",
|
|
@@ -616,40 +765,53 @@ const CardFooter = ({ dataTestId, className, children, density, hideSeparator =
|
|
|
616
765
|
return (jsx(DensityContainer, Object.assign({ dataTestId: dataTestId, className: cvaCardFooterDensityContainer({ border: hideSeparator ? "borderless" : "default", className }), density: density, direction: "row" }, { children: children })));
|
|
617
766
|
};
|
|
618
767
|
|
|
768
|
+
const cvaHeading = cvaMerge(["m-0", "leading-normal", "text-black"], {
|
|
769
|
+
variants: {
|
|
770
|
+
subtle: {
|
|
771
|
+
true: "text-neutral-600",
|
|
772
|
+
false: "",
|
|
773
|
+
},
|
|
774
|
+
inverted: {
|
|
775
|
+
true: "text-white",
|
|
776
|
+
false: "",
|
|
777
|
+
},
|
|
778
|
+
size: {
|
|
779
|
+
primary: "text-3xl font-semibold",
|
|
780
|
+
secondary: "text-lg font-semibold",
|
|
781
|
+
tertiary: "text-base font-semibold",
|
|
782
|
+
subtitle: "text-base font-normal",
|
|
783
|
+
},
|
|
784
|
+
},
|
|
785
|
+
compoundVariants: [
|
|
786
|
+
{
|
|
787
|
+
inverted: true,
|
|
788
|
+
subtle: true,
|
|
789
|
+
className: "text-neutral-300",
|
|
790
|
+
},
|
|
791
|
+
],
|
|
792
|
+
defaultVariants: {
|
|
793
|
+
subtle: false,
|
|
794
|
+
inverted: false,
|
|
795
|
+
size: "primary",
|
|
796
|
+
},
|
|
797
|
+
});
|
|
798
|
+
|
|
619
799
|
/**
|
|
620
800
|
* The Heading is used for a heading of a section (h1,h2,h3,h4).
|
|
621
801
|
*
|
|
622
802
|
* @param {HeadingProps} props - The props for the Heading component
|
|
623
803
|
* @returns {JSX.Element} Heading component
|
|
624
804
|
*/
|
|
625
|
-
const Heading
|
|
805
|
+
const Heading = ({ children, variant = "primary", inverted = false, subtle = false, className, dataTestId, }) => {
|
|
626
806
|
const semanticType = {
|
|
627
807
|
primary: "h1",
|
|
628
808
|
secondary: "h2",
|
|
629
809
|
tertiary: "h3",
|
|
630
810
|
subtitle: "h4",
|
|
631
811
|
};
|
|
632
|
-
return (jsx(StyledHeading, Object.assign({ "$as": semanticType[variant], className:
|
|
633
|
-
};
|
|
634
|
-
const getVariantStyles = () => ({ $variant }) => {
|
|
635
|
-
const variants = {
|
|
636
|
-
primary: tws `tu-heading--primary`,
|
|
637
|
-
secondary: tws `tu-heading--secondary`,
|
|
638
|
-
tertiary: tws `tu-heading--tertiary`,
|
|
639
|
-
subtitle: tws `tu-heading--subtitle`,
|
|
640
|
-
};
|
|
641
|
-
return variants[$variant];
|
|
812
|
+
return (jsx(StyledHeading, Object.assign({ "$as": semanticType[variant], className: cvaHeading({ subtle, inverted, size: variant, className }), "data-testid": dataTestId }, { children: children })));
|
|
642
813
|
};
|
|
643
|
-
const
|
|
644
|
-
const subtle = $inverted ? tws `tu-heading--subtle-inverted` : tws `tu-heading--subtle`;
|
|
645
|
-
const inverted = $inverted ? tws `tu-heading--inverted` : null;
|
|
646
|
-
return $subtle ? subtle : inverted;
|
|
647
|
-
};
|
|
648
|
-
const StyledHeading = tw.div `
|
|
649
|
-
tu-heading
|
|
650
|
-
${getFontColor()}
|
|
651
|
-
${getVariantStyles()}
|
|
652
|
-
`;
|
|
814
|
+
const StyledHeading = tw.div ``;
|
|
653
815
|
|
|
654
816
|
/**
|
|
655
817
|
* Header for Cards and Modals.
|
|
@@ -658,7 +820,7 @@ const StyledHeading = tw.div `
|
|
|
658
820
|
* @returns {JSX.Element} CardHeader component
|
|
659
821
|
*/
|
|
660
822
|
const CardHeader = ({ heading, headingVariant = "primary", subHeading, onClose, dataTestId, className, children, accessories, density, extraClassName, hideSeparator = false, }) => {
|
|
661
|
-
return (jsx(DensityContainer, Object.assign({ dataTestId: dataTestId, className: cvaCardHeaderDensityContainer({ border: hideSeparator ? "borderless" : "default", className }), density: density }, { children: jsxs("div", Object.assign({ className: cvaCardHeader() }, { children: [jsxs("div", Object.assign({ className: extraClassName }, { children: [jsxs("div", Object.assign({ className: cvaCardHeaderHeadingContainer() }, { children: [jsx(Heading
|
|
823
|
+
return (jsx(DensityContainer, Object.assign({ dataTestId: dataTestId, className: cvaCardHeaderDensityContainer({ border: hideSeparator ? "borderless" : "default", className }), density: density }, { children: jsxs("div", Object.assign({ className: cvaCardHeader() }, { children: [jsxs("div", Object.assign({ className: extraClassName }, { children: [jsxs("div", Object.assign({ className: cvaCardHeaderHeadingContainer() }, { children: [jsx(Heading, Object.assign({ className: "self-center", variant: headingVariant }, { children: heading })), accessories] })), subHeading && (jsx(Heading, Object.assign({ subtle: true, variant: "subtitle" }, { children: subHeading }))), children] })), onClose && (jsx(IconButton, { dataTestId: "card-header-close-button", variant: "transparent", color: "secondary", onClick: onClose, icon: jsx(Icon, { name: "XMarkIcon", size: "small" }), className: "!h-min" }))] })) })));
|
|
662
824
|
};
|
|
663
825
|
|
|
664
826
|
const cvaCollapse = cvaMerge([
|
|
@@ -704,7 +866,7 @@ const Collapse = ({ id, initialExpanded = false, onToggle, label, children, clas
|
|
|
704
866
|
}
|
|
705
867
|
setExpanded(!expanded);
|
|
706
868
|
}, [expanded, onToggle]);
|
|
707
|
-
return (jsxs("div", Object.assign({ className: cvaCollapse({ className }), "data-testid": dataTestId }, { children: [jsx("div", Object.assign({ className: cvaCollapseLabel(), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick }, { children: jsxs("div", Object.assign({ className: cvaCollapseLabelContainer() }, { children: [jsx(Text
|
|
869
|
+
return (jsxs("div", Object.assign({ className: cvaCollapse({ className }), "data-testid": dataTestId }, { children: [jsx("div", Object.assign({ className: cvaCollapseLabel(), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick }, { children: jsxs("div", Object.assign({ className: cvaCollapseLabelContainer() }, { children: [jsx(Text, Object.assign({ weight: "bold" }, { children: label })), jsx(IconButton, { icon: jsx(Icon, { className: cvaCollapseIcon({ expanded }), name: "ChevronDownIcon", size: "small" }), size: "medium", variant: "transparent", color: "secondary" })] })) })), jsx(Collapsible, Object.assign({ expanded: expanded, id: id }, { children: children }))] })));
|
|
708
870
|
};
|
|
709
871
|
const Collapsible = ({ children, expanded, id }) => {
|
|
710
872
|
const [ref, { height }] = useMeasure();
|
|
@@ -883,12 +1045,23 @@ const Popover = (_a) => {
|
|
|
883
1045
|
return jsx(PopoverContext.Provider, Object.assign({ value: popover }, { children: children }));
|
|
884
1046
|
};
|
|
885
1047
|
|
|
1048
|
+
const cvaPopoverContainer = cvaMerge(["component-popover-border", "z-popover", "animate-fade-in-fast"]);
|
|
1049
|
+
const cvaPopoverTitleContainer = cvaMerge(["flex", "items-center", "px-2", "py-1"], {
|
|
1050
|
+
variants: {
|
|
1051
|
+
divider: {
|
|
1052
|
+
true: ["border-b", "border-solid", "border-b-neutral-100", "mb-1"],
|
|
1053
|
+
false: "",
|
|
1054
|
+
},
|
|
1055
|
+
},
|
|
1056
|
+
});
|
|
1057
|
+
const cvaPopoverTitleText = cvaMerge(["flex-1", "text-neutral-500"]);
|
|
1058
|
+
|
|
886
1059
|
const PopoverContent = React__default.forwardRef(function PopoverContent(_a, propRef) {
|
|
887
|
-
var _b, _c, _d
|
|
1060
|
+
var _b, _c, _d;
|
|
888
1061
|
var { className, dataTestId, children } = _a, props = __rest(_a, ["className", "dataTestId", "children"]);
|
|
889
|
-
const
|
|
1062
|
+
const _e = usePopoverContext(), { context: floatingContext, customProps } = _e, context = __rest(_e, ["context", "customProps"]);
|
|
890
1063
|
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
891
|
-
return (jsx(FloatingPortal, Object.assign({ id: "tu-floating-ui" }, { children: context.isOpen && (jsx(FloatingFocusManager, Object.assign({ guards: false, context: floatingContext, modal: context.isModal, order: ["reference", "content"], returnFocus: false }, { children: jsx("div", Object.assign({ ref: ref, className:
|
|
1064
|
+
return (jsx(FloatingPortal, Object.assign({ id: "tu-floating-ui" }, { children: context.isOpen && (jsx(FloatingFocusManager, Object.assign({ guards: false, context: floatingContext, modal: context.isModal, order: ["reference", "content"], returnFocus: false }, { children: jsx("div", Object.assign({ ref: ref, className: cvaPopoverContainer({ className: className !== null && className !== void 0 ? className : customProps.className }), "data-testid": (_b = dataTestId !== null && dataTestId !== void 0 ? dataTestId : customProps.dataTestId) !== null && _b !== void 0 ? _b : "popover-content", style: Object.assign({ position: context.strategy, top: (_c = context.y) !== null && _c !== void 0 ? _c : 0, left: (_d = context.x) !== null && _d !== void 0 ? _d : 0, width: "max-content" }, props.style), "aria-labelledby": context.labelId, "aria-describedby": context.descriptionId }, context.getFloatingProps(props), { children: typeof children === "function" ? children(() => context.setIsOpen(false)) : children })) }))) })));
|
|
892
1065
|
});
|
|
893
1066
|
|
|
894
1067
|
/**
|
|
@@ -898,15 +1071,8 @@ const PopoverContent = React__default.forwardRef(function PopoverContent(_a, pro
|
|
|
898
1071
|
* @returns {JSX.Element} PopoverTitle component
|
|
899
1072
|
*/
|
|
900
1073
|
const PopoverTitle = ({ children, action, divider = false, className, dataTestId }) => {
|
|
901
|
-
return (jsxs(
|
|
902
|
-
};
|
|
903
|
-
const Container$3 = tw.div `
|
|
904
|
-
tu-popover-title-container
|
|
905
|
-
${p => p.$divider && `tu-popover-title-container--divider`}
|
|
906
|
-
`;
|
|
907
|
-
const StyledText$1 = twx(Text$1) `
|
|
908
|
-
tu-popover-title-text
|
|
909
|
-
`;
|
|
1074
|
+
return (jsxs("div", Object.assign({ className: cvaPopoverTitleContainer({ divider, className }), "data-testid": dataTestId }, { children: [jsx(Text, Object.assign({ className: cvaPopoverTitleText(), type: "div", subtle: true, size: "small", weight: "bold", uppercase: true }, { children: children })), action] })));
|
|
1075
|
+
};
|
|
910
1076
|
|
|
911
1077
|
const PopoverTrigger = forwardRef(function PopoverTrigger(_a, propRef) {
|
|
912
1078
|
var { children, renderButton } = _a, props = __rest(_a, ["children", "renderButton"]);
|
|
@@ -953,6 +1119,29 @@ const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, dataTestId,
|
|
|
953
1119
|
return (jsx(DayPicker$1, { mode: "range", onSelect: onSelect, selected: selectedDays, defaultMonth: selectedDays && selectedDays.from, locale: locale, disabled: disabledDays, className: `custom-day-picker range-picker ${className !== null && className !== void 0 ? className : ""}`, max: max, footer: jsx("div", { "data-testid": dataTestId }) }));
|
|
954
1120
|
};
|
|
955
1121
|
|
|
1122
|
+
const cvaDrawerOverlay = cvaMerge([
|
|
1123
|
+
"bg-black/30",
|
|
1124
|
+
"block",
|
|
1125
|
+
"z-toast",
|
|
1126
|
+
"inset-0",
|
|
1127
|
+
"absolute",
|
|
1128
|
+
"cursor-pointer",
|
|
1129
|
+
"animate-fade-in-fast",
|
|
1130
|
+
]);
|
|
1131
|
+
const cvaDrawerCard = cvaMerge(["fixed", "z-toast"], {
|
|
1132
|
+
variants: {
|
|
1133
|
+
position: {
|
|
1134
|
+
left: "top-0 left-0 animate-slide-in-left h-full rounded-l-none",
|
|
1135
|
+
right: "top-0 right-0 animate-slide-in-right h-full rounded-r-none",
|
|
1136
|
+
bottom: "right-0 left-0 bottom-0 animate-slide-in-bottom w-full rounded-b-none",
|
|
1137
|
+
top: "top-0 left-0 animate-slide-in-top w-full rounded-t-none",
|
|
1138
|
+
},
|
|
1139
|
+
},
|
|
1140
|
+
defaultVariants: {
|
|
1141
|
+
position: "left",
|
|
1142
|
+
},
|
|
1143
|
+
});
|
|
1144
|
+
|
|
956
1145
|
/**
|
|
957
1146
|
* The drawer provides a slideover which can be used to provide access to different locations in the application.
|
|
958
1147
|
*
|
|
@@ -975,35 +1164,10 @@ const Drawer = ({ open, onClose = () => { }, children, disableOverlay = false, p
|
|
|
975
1164
|
window.removeEventListener("keyup", onKeyPress);
|
|
976
1165
|
};
|
|
977
1166
|
}, [open, onClose]);
|
|
978
|
-
return (jsx(FloatingFocusManager, Object.assign({ context: context }, { children: open ? (jsxs(
|
|
1167
|
+
return (jsx(FloatingFocusManager, Object.assign({ context: context }, { children: open ? (jsxs("div", Object.assign({ id: "drawer" }, { children: [!disableOverlay && (jsx("div", { className: cvaDrawerOverlay(), "aria-hidden": open, onClick: onClose, id: "drawer__overlay" })), jsx(Card, Object.assign({ "aria-hidden": open, "data-testId": dataTestId, id: "drawer__card", className: cvaDrawerCard({ position, className }) }, { children: children }))] }))) : (
|
|
979
1168
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
980
1169
|
jsx(Fragment, {})) })));
|
|
981
|
-
};
|
|
982
|
-
const getPositionStyles = ($position) => {
|
|
983
|
-
switch ($position) {
|
|
984
|
-
case "top":
|
|
985
|
-
return tws `tu-drawer__card--top`;
|
|
986
|
-
case "right":
|
|
987
|
-
return tws `tu-drawer__card--right`;
|
|
988
|
-
case "bottom":
|
|
989
|
-
return tws `tu-drawer__card--bottom`;
|
|
990
|
-
case "left":
|
|
991
|
-
default:
|
|
992
|
-
return tws `tu-drawer__card--left`;
|
|
993
|
-
}
|
|
994
|
-
};
|
|
995
|
-
const StyledCard$1 = twx(Card) `
|
|
996
|
-
tu-drawer__card
|
|
997
|
-
${({ $open }) => $open && tws `tu-drawer__card--open`}
|
|
998
|
-
${({ $position }) => getPositionStyles($position)}
|
|
999
|
-
`;
|
|
1000
|
-
const Root$4 = tw.div `
|
|
1001
|
-
tu-drawer
|
|
1002
|
-
`;
|
|
1003
|
-
const Overlay = tw.div `
|
|
1004
|
-
tu-drawer__overlay
|
|
1005
|
-
${({ $open }) => $open && tws `tu-drawer__overlay--open`}
|
|
1006
|
-
`;
|
|
1170
|
+
};
|
|
1007
1171
|
|
|
1008
1172
|
/**
|
|
1009
1173
|
* The external link component is used to link to an external page outside the Trackunit Manager.
|
|
@@ -1015,6 +1179,90 @@ const ExternalLink = ({ rel = "noreferrer", target = "_blank", href, className,
|
|
|
1015
1179
|
return (jsx("a", Object.assign({ "data-testid": dataTestId, className: className, title: title, href: href, rel: rel, target: target }, { children: children })));
|
|
1016
1180
|
};
|
|
1017
1181
|
|
|
1182
|
+
const cvaIndicator = cvaMerge(["flex", "items-center"]);
|
|
1183
|
+
const cvaIndicatorIcon = cvaMerge(["mr-2"]);
|
|
1184
|
+
const cvaIndicatorLabel = cvaMerge(["pl-2", "pr-2", "font-medium", "capitalize", "text-sm", "xl:text-base"]);
|
|
1185
|
+
const cvaIndicatorPing = cvaMerge(["animate-ping-sm", "absolute", "inline-flex", "h-full", "w-full", "rounded-full", "opacity-75", "bg-neutral-600"], {
|
|
1186
|
+
variants: {
|
|
1187
|
+
color: {
|
|
1188
|
+
primary: "bg-primary-600",
|
|
1189
|
+
secondary: "bg-secondary-600",
|
|
1190
|
+
accent: "bg-accent-600",
|
|
1191
|
+
neutral: "bg-neutral-600",
|
|
1192
|
+
info: "bg-info-600",
|
|
1193
|
+
success: "bg-success-600",
|
|
1194
|
+
warning: "bg-warning-600",
|
|
1195
|
+
danger: "bg-danger-600",
|
|
1196
|
+
good: "bg-good-600",
|
|
1197
|
+
low: "bg-low-600",
|
|
1198
|
+
critical: "bg-critical-600",
|
|
1199
|
+
working: "bg-working-600",
|
|
1200
|
+
idle: "bg-idle-600",
|
|
1201
|
+
stopped: "bg-stopped-600",
|
|
1202
|
+
moving: "bg-moving",
|
|
1203
|
+
active: "bg-active",
|
|
1204
|
+
unknown: "bg-unknown-600",
|
|
1205
|
+
unused: "bg-unused-400",
|
|
1206
|
+
utilized: "bg-utilized-600",
|
|
1207
|
+
heavily_utilized: "bg-heavily_utilized-500",
|
|
1208
|
+
available: "bg-available-600",
|
|
1209
|
+
on_rent: "bg-on_rent-600",
|
|
1210
|
+
pickup_ready: "bg-pickup_ready-600",
|
|
1211
|
+
transfer: "bg-transfer-600",
|
|
1212
|
+
in_repair: "bg-in_repair-600",
|
|
1213
|
+
returned: "bg-returned-600",
|
|
1214
|
+
other_rental_status: "bg-other_rental_status-600",
|
|
1215
|
+
site: "bg-neutral-600",
|
|
1216
|
+
white: "bg-white",
|
|
1217
|
+
black: "bg-black",
|
|
1218
|
+
},
|
|
1219
|
+
},
|
|
1220
|
+
});
|
|
1221
|
+
const cvaIndicatorIconBackground = cvaMerge(["rounded-full", "items-center", "justify-center", "flex", "relative"], {
|
|
1222
|
+
variants: {
|
|
1223
|
+
color: {
|
|
1224
|
+
primary: "bg-primary-100 text-primary-600",
|
|
1225
|
+
secondary: "bg-secondary-100 text-secondary-600",
|
|
1226
|
+
accent: "bg-accent-100 text-accent-600",
|
|
1227
|
+
neutral: "bg-neutral-100 text-neutral-600",
|
|
1228
|
+
info: "bg-info-100 text-info-600",
|
|
1229
|
+
success: "bg-success-100 text-success-600",
|
|
1230
|
+
warning: "bg-warning-100 text-warning-600",
|
|
1231
|
+
danger: "bg-danger-100 text-danger-600",
|
|
1232
|
+
good: "bg-good-100 text-good-600",
|
|
1233
|
+
low: "bg-low-100 text-low-600",
|
|
1234
|
+
critical: "bg-critical-100 text-critical-600",
|
|
1235
|
+
working: "bg-working-100 text-working-600",
|
|
1236
|
+
idle: "bg-idle-100 text-idle-600",
|
|
1237
|
+
stopped: "bg-stopped-100 text-stopped-600",
|
|
1238
|
+
moving: "bg-neutral-100 text-moving",
|
|
1239
|
+
active: "bg-neutral-100 text-active",
|
|
1240
|
+
unknown: "bg-unknown-100 text-unknown-600",
|
|
1241
|
+
unused: "bg-unused-300 text-unused-400",
|
|
1242
|
+
utilized: "bg-utilized-400 text-utilized-600",
|
|
1243
|
+
heavily_utilized: "bg-heavily_utilized-300 text-heavily_utilized-500",
|
|
1244
|
+
available: "bg-available-100 text-available-600",
|
|
1245
|
+
on_rent: "bg-on_rent-100 text-on_rent-600",
|
|
1246
|
+
pickup_ready: "bg-pickup_ready-100 text-pickup_ready-600",
|
|
1247
|
+
transfer: "bg-transfer-100 text-transfer-600",
|
|
1248
|
+
in_repair: "bg-in_repair-100 text-in_repair-600",
|
|
1249
|
+
returned: "bg-returned-100 text-returned-600",
|
|
1250
|
+
other_rental_status: "bg-other_rental_status-100 text-other_rental_status-600",
|
|
1251
|
+
site: "bg-neutral-100 text-neutral-600",
|
|
1252
|
+
white: "bg-white text-black",
|
|
1253
|
+
black: "bg-black text-white",
|
|
1254
|
+
},
|
|
1255
|
+
background: {
|
|
1256
|
+
visible: ["p-[6px]"],
|
|
1257
|
+
hidden: ["bg-white", "p-0"],
|
|
1258
|
+
},
|
|
1259
|
+
},
|
|
1260
|
+
defaultVariants: {
|
|
1261
|
+
background: "visible",
|
|
1262
|
+
color: "neutral",
|
|
1263
|
+
},
|
|
1264
|
+
});
|
|
1265
|
+
|
|
1018
1266
|
/**
|
|
1019
1267
|
* Indicators are non-interactive elements that communicate essential aspects of the state of an asset.
|
|
1020
1268
|
*
|
|
@@ -1028,83 +1276,9 @@ const ExternalLink = ({ rel = "noreferrer", target = "_blank", href, className,
|
|
|
1028
1276
|
* @returns {JSX.Element} Indicator component
|
|
1029
1277
|
*/
|
|
1030
1278
|
const Indicator = (_a) => {
|
|
1031
|
-
var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false } = _a, rest = __rest(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping"]);
|
|
1032
|
-
return (jsxs(
|
|
1033
|
-
};
|
|
1034
|
-
const Container$2 = tw.div `
|
|
1035
|
-
tu-indicator
|
|
1036
|
-
${({ $color }) => {
|
|
1037
|
-
switch ($color) {
|
|
1038
|
-
case "primary":
|
|
1039
|
-
return tws `tu-indicator--primary`;
|
|
1040
|
-
case "secondary":
|
|
1041
|
-
return tws `tu-indicator--secondary`;
|
|
1042
|
-
case "accent":
|
|
1043
|
-
return tws `tu-indicator--accent`;
|
|
1044
|
-
case "neutral":
|
|
1045
|
-
return tws `tu-indicator--neutral`;
|
|
1046
|
-
case "info":
|
|
1047
|
-
return tws `tu-indicator--info`;
|
|
1048
|
-
case "success":
|
|
1049
|
-
return tws `tu-indicator--success`;
|
|
1050
|
-
case "warning":
|
|
1051
|
-
return tws `tu-indicator--warning`;
|
|
1052
|
-
case "danger":
|
|
1053
|
-
return tws `tu-indicator--danger`;
|
|
1054
|
-
case "good":
|
|
1055
|
-
return tws `tu-indicator--good`;
|
|
1056
|
-
case "low":
|
|
1057
|
-
return tws `tu-indicator--low`;
|
|
1058
|
-
case "critical":
|
|
1059
|
-
return tws `tu-indicator--critical`;
|
|
1060
|
-
case "working":
|
|
1061
|
-
return tws `tu-indicator--working`;
|
|
1062
|
-
case "idle":
|
|
1063
|
-
return tws `tu-indicator--idle`;
|
|
1064
|
-
case "stopped":
|
|
1065
|
-
return tws `tu-indicator--stopped`;
|
|
1066
|
-
case "moving":
|
|
1067
|
-
return tws `tu-indicator--moving`;
|
|
1068
|
-
case "unknown":
|
|
1069
|
-
return tws `tu-indicator--unknown`;
|
|
1070
|
-
case "unused":
|
|
1071
|
-
return tws `tu-indicator--unused`;
|
|
1072
|
-
case "utilized":
|
|
1073
|
-
return tws `tu-indicator--utilized`;
|
|
1074
|
-
case "heavily_utilized":
|
|
1075
|
-
return tws `tu-indicator--heavily-utilized`;
|
|
1076
|
-
case "on_rent":
|
|
1077
|
-
return tws `tu-indicator--on-rent`;
|
|
1078
|
-
case "available":
|
|
1079
|
-
return tws `tu-indicator--available`;
|
|
1080
|
-
case "pickup_ready":
|
|
1081
|
-
return tws `tu-indicator--pickup-ready`;
|
|
1082
|
-
case "transfer":
|
|
1083
|
-
return tws `tu-indicator--transfer`;
|
|
1084
|
-
case "in_repair":
|
|
1085
|
-
return tws `tu-indicator--in-repair`;
|
|
1086
|
-
case "returned":
|
|
1087
|
-
return tws `tu-indicator--returned`;
|
|
1088
|
-
case "other_rental_status":
|
|
1089
|
-
return tws `tu-indicator--other-rental-status`;
|
|
1090
|
-
default:
|
|
1091
|
-
return "";
|
|
1092
|
-
}
|
|
1093
|
-
}}
|
|
1094
|
-
`;
|
|
1095
|
-
const IconBackground = tw.div `
|
|
1096
|
-
tu-indicator__icon-background
|
|
1097
|
-
|
|
1098
|
-
${({ $withBackground }) => {
|
|
1099
|
-
return $withBackground ? "" : "tu-indicator__icon-background--none";
|
|
1100
|
-
}}
|
|
1101
|
-
`;
|
|
1102
|
-
const Label$1 = tw.div `
|
|
1103
|
-
tu-indicator__label
|
|
1104
|
-
`;
|
|
1105
|
-
const Ping = tw.span `
|
|
1106
|
-
tu-indicator__ping
|
|
1107
|
-
`;
|
|
1279
|
+
var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, className } = _a, rest = __rest(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping", "className"]);
|
|
1280
|
+
return (jsxs("div", Object.assign({ className: cvaIndicator({ className }), "data-testid": dataTestId }, rest, { title: !withLabel ? label : undefined }, { children: [jsxs("div", Object.assign({ className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background" }, { children: [ping && (jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] })), label !== undefined && withLabel && (jsx("div", Object.assign({ className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label" }, { children: label })))] })));
|
|
1281
|
+
};
|
|
1108
1282
|
|
|
1109
1283
|
/**
|
|
1110
1284
|
* The MenuItem component is used to display a menu, primarily meant to be used in a list form.
|
|
@@ -1488,11 +1662,11 @@ const MoreMenu = ({ className, dataTestId, menuPlacement, iconProps = {
|
|
|
1488
1662
|
useClickOutside(actionMenuRef, () => {
|
|
1489
1663
|
setActionMenuIsOpen(false);
|
|
1490
1664
|
});
|
|
1491
|
-
return (jsx(Root
|
|
1665
|
+
return (jsx(Root, Object.assign({ ref: actionMenuRef, className: className, "data-testid": dataTestId }, { children: jsxs(Popover, Object.assign({ placement: menuPlacement }, { children: [jsx(PopoverTrigger, { children: customButton !== null && customButton !== void 0 ? customButton : (jsx(IconButton, Object.assign({}, iconButtonProps, { icon: iconProps.name ? jsx(Icon, Object.assign({}, iconProps, { name: iconProps.name })) : null, onClick: () => {
|
|
1492
1666
|
setActionMenuIsOpen(!actionMenuIsOpen);
|
|
1493
1667
|
} }))) }), jsx(PopoverContent, { children: close => (typeof children === "function" ? children(close) : children) })] })) })));
|
|
1494
1668
|
};
|
|
1495
|
-
const Root
|
|
1669
|
+
const Root = tw.div `
|
|
1496
1670
|
tu-more-menu
|
|
1497
1671
|
${({ variant }) => (variant === "primary" ? tws `tu-more-menu--primary` : "")}
|
|
1498
1672
|
`;
|
|
@@ -1571,6 +1745,63 @@ const useModal = ({ closeOnOutsideClick } = {}) => {
|
|
|
1571
1745
|
};
|
|
1572
1746
|
};
|
|
1573
1747
|
|
|
1748
|
+
const cvaTag = cvaMerge([
|
|
1749
|
+
"inline-flex",
|
|
1750
|
+
"justify-center",
|
|
1751
|
+
"items-center",
|
|
1752
|
+
"rounded-full",
|
|
1753
|
+
"py-1",
|
|
1754
|
+
"px-2",
|
|
1755
|
+
"text-center",
|
|
1756
|
+
"whitespace-nowrap",
|
|
1757
|
+
"h-min",
|
|
1758
|
+
"min-w-[1.5rem]",
|
|
1759
|
+
"font-medium",
|
|
1760
|
+
"truncate",
|
|
1761
|
+
"max-w-full",
|
|
1762
|
+
"w-min",
|
|
1763
|
+
"text-xs",
|
|
1764
|
+
], {
|
|
1765
|
+
variants: {
|
|
1766
|
+
size: {
|
|
1767
|
+
small: "px-2 py-px",
|
|
1768
|
+
medium: "",
|
|
1769
|
+
},
|
|
1770
|
+
layout: {
|
|
1771
|
+
withIcon: "pr-1 gap-2",
|
|
1772
|
+
default: "",
|
|
1773
|
+
},
|
|
1774
|
+
color: {
|
|
1775
|
+
primary: "bg-primary-100 text-primary-700",
|
|
1776
|
+
secondary: "bg-secondary-100 text-secondary-700",
|
|
1777
|
+
accent: "bg-accent-100 text-accent-700",
|
|
1778
|
+
neutral: "bg-neutral-100 text-neutral-700",
|
|
1779
|
+
black: "bg-neutral-100 text-neutral-700",
|
|
1780
|
+
white: "bg-white-100 text-white-700",
|
|
1781
|
+
info: "bg-info-100 text-info-700",
|
|
1782
|
+
success: "bg-success-100 text-success-700",
|
|
1783
|
+
warning: "bg-warning-100 text-warning-700",
|
|
1784
|
+
danger: "bg-danger-100 text-danger-700",
|
|
1785
|
+
good: "bg-good-100 text-good-700",
|
|
1786
|
+
low: "bg-low-100 text-low-700",
|
|
1787
|
+
critical: "bg-critical-100 text-critical-700",
|
|
1788
|
+
working: "bg-working-100 text-working-700",
|
|
1789
|
+
stopped: "bg-stopped-100 text-stopped-700",
|
|
1790
|
+
idle: "bg-idle-100 text-idle-700",
|
|
1791
|
+
unknown: "bg-unknown-100 text-unknown-700",
|
|
1792
|
+
moving: "bg-neutral-100 text-neutral-700",
|
|
1793
|
+
active: "bg-neutral-100 text-neutral-700",
|
|
1794
|
+
},
|
|
1795
|
+
},
|
|
1796
|
+
defaultVariants: {
|
|
1797
|
+
size: "medium",
|
|
1798
|
+
layout: "default",
|
|
1799
|
+
color: "primary",
|
|
1800
|
+
},
|
|
1801
|
+
});
|
|
1802
|
+
const cvaTagIconContainer = cvaMerge(["inline-flex", "self-center"]);
|
|
1803
|
+
const cvaTagIcon = cvaMerge(["cursor-pointer", "transition-opacity", "hover:opacity-70"]);
|
|
1804
|
+
|
|
1574
1805
|
/**
|
|
1575
1806
|
* The tag component is used to categorize elements in the ui.
|
|
1576
1807
|
*
|
|
@@ -1585,71 +1816,23 @@ const useModal = ({ closeOnOutsideClick } = {}) => {
|
|
|
1585
1816
|
*/
|
|
1586
1817
|
const Tag = React.forwardRef((_a, ref) => {
|
|
1587
1818
|
var { className, dataTestId, children, size = "medium", onClose, color = "primary" } = _a; __rest(_a, ["className", "dataTestId", "children", "size", "onClose", "color"]);
|
|
1588
|
-
return (jsxs(
|
|
1819
|
+
return (jsxs("span", Object.assign({ className: cvaTag({ className, size, color, layout: Boolean(onClose) ? "withIcon" : "default" }), "data-testid": dataTestId && `${dataTestId}-tag`, ref: ref }, { children: [children, Boolean(onClose) && (
|
|
1589
1820
|
// a fix for multiselect deselecting tags working together with fade out animation
|
|
1590
|
-
jsx(
|
|
1591
|
-
});
|
|
1592
|
-
const getSizeModifierClass = () => ({ $size, $withXIcon }) => {
|
|
1593
|
-
const tagSizeModifierClass = {
|
|
1594
|
-
medium: $withXIcon ? tws `tu-tag--with-icon ` : tws ` `,
|
|
1595
|
-
small: $withXIcon ? tws `tu-tag--small tu-tag--with-icon` : tws `tu-tag--small`,
|
|
1596
|
-
};
|
|
1597
|
-
return tagSizeModifierClass[$size];
|
|
1598
|
-
};
|
|
1599
|
-
const getColorModifierClass = () => ({ $color }) => {
|
|
1600
|
-
const colorClasses = {
|
|
1601
|
-
primary: tws `tu-tag--primary`,
|
|
1602
|
-
secondary: tws `tu-tag--secondary`,
|
|
1603
|
-
accent: tws `tu-tag--accent`,
|
|
1604
|
-
success: tws `tu-tag--success`,
|
|
1605
|
-
danger: tws `tu-tag--danger`,
|
|
1606
|
-
warning: tws `tu-tag--warning`,
|
|
1607
|
-
info: tws `tu-tag--info`,
|
|
1608
|
-
neutral: tws `tu-tag--neutral`,
|
|
1609
|
-
good: tws `tu-tag--good`,
|
|
1610
|
-
low: tws `tu-tag--low`,
|
|
1611
|
-
critical: tws `tu-tag--critical`,
|
|
1612
|
-
working: tws `tu-tag--working`,
|
|
1613
|
-
idle: tws `tu-tag--idle`,
|
|
1614
|
-
stopped: tws `tu-tag--stopped`,
|
|
1615
|
-
unknown: tws `tu-tag--unknown`,
|
|
1616
|
-
};
|
|
1617
|
-
return colorClasses[$color];
|
|
1618
|
-
};
|
|
1619
|
-
const StyledText = tw.span `
|
|
1620
|
-
tu-tag
|
|
1621
|
-
${getSizeModifierClass()}
|
|
1622
|
-
${getColorModifierClass()}
|
|
1623
|
-
`;
|
|
1624
|
-
const IconContainer = tw.div `
|
|
1625
|
-
tu-tag__icon-container
|
|
1626
|
-
`;
|
|
1821
|
+
jsx("div", Object.assign({ className: cvaTagIconContainer(), onMouseDown: onClose }, { children: jsx(Icon, { name: "XCircleIcon", dataTestId: dataTestId + "Icon", type: "solid", size: size, style: { WebkitTransition: "-webkit-transform 0.150s" }, className: cvaTagIcon() }) })))] })));
|
|
1822
|
+
});
|
|
1627
1823
|
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
return (jsx(TooltipContainer, Object.assign({ dataTestId: dataTestId }, rest, { children: wrappedChildren })));
|
|
1641
|
-
};
|
|
1642
|
-
const TooltipContainer = ({ label, placement = "bottom", mode = "dark", contentTextType = "p", children, dataTestId, }) => (jsxs(StyledPopover, Object.assign({ className: "tu-tooltip__container", placement: placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "" }, { children: [jsx(PopoverTrigger, { children: children }), jsx(PopoverContent, { children: jsx(Content, Object.assign({ "$mode": mode }, { children: jsx(Text$1, Object.assign({ inverted: mode === "dark", type: contentTextType }, { children: label })) })) })] })));
|
|
1643
|
-
const Flex = tw.div `
|
|
1644
|
-
inline-flex
|
|
1645
|
-
`;
|
|
1646
|
-
const StyledPopover = twx(Popover) `
|
|
1647
|
-
tu-tooltip__container
|
|
1648
|
-
`;
|
|
1649
|
-
const Content = tw.div `
|
|
1650
|
-
tu-tooltip__content
|
|
1651
|
-
${p => (p.$mode === "light" ? tws `tu-tooltip--light` : null)}
|
|
1652
|
-
`;
|
|
1824
|
+
const cvaTip = cvaMerge("flex transition text-slate-300 hover:text-slate-500");
|
|
1825
|
+
const cvaTipContent = cvaMerge("p-2 rounded max-w-sm flex gap-2 items-center text-sm", {
|
|
1826
|
+
variants: {
|
|
1827
|
+
color: {
|
|
1828
|
+
light: "shadow-md bg-white",
|
|
1829
|
+
dark: "text-white bg-neutral-800",
|
|
1830
|
+
},
|
|
1831
|
+
},
|
|
1832
|
+
defaultVariants: {
|
|
1833
|
+
color: "light",
|
|
1834
|
+
},
|
|
1835
|
+
});
|
|
1653
1836
|
|
|
1654
1837
|
/**
|
|
1655
1838
|
* The Tip component is used to show helpful tips or contextual information to the users.
|
|
@@ -1658,13 +1841,35 @@ const Content = tw.div `
|
|
|
1658
1841
|
* @param {TipProps} props - The props for the Tip component
|
|
1659
1842
|
* @returns {JSX.Element} Tip component
|
|
1660
1843
|
*/
|
|
1661
|
-
const Tip = ({ children, iconProps, dataTestId,
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1667
|
-
|
|
1844
|
+
const Tip = ({ children, iconProps, dataTestId, className, placement = "bottom", mode = "dark", link, }) => {
|
|
1845
|
+
return (jsx("span", Object.assign({ "data-testid": dataTestId, className: cvaTip({ className }) }, { children: jsxs(Popover, Object.assign({ placement: placement, activation: { click: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "" }, { children: [jsx(PopoverTrigger, { children: jsx("div", Object.assign({ "data-testid": dataTestId && `${dataTestId}-trigger` }, { children: jsx(Icon, Object.assign({ name: "QuestionMarkCircleIcon", size: "medium", dataTestId: dataTestId && `${dataTestId}-icon` }, iconProps)) })) }), jsx(PopoverContent, { children: jsxs("div", Object.assign({ className: cvaTipContent({ color: mode }) }, { children: [jsx("div", { children: typeof children === "string" ? jsx("p", { children: children }) : children }), link ? (jsx("a", Object.assign({ href: link }, { children: jsx(Icon, { name: "ArrowRightCircleIcon" }) }))) : null] })) })] })) })));
|
|
1846
|
+
};
|
|
1847
|
+
|
|
1848
|
+
const cvaPageHeader = cvaMerge([
|
|
1849
|
+
"min-h-[72px]",
|
|
1850
|
+
"box-border",
|
|
1851
|
+
"bg-white",
|
|
1852
|
+
"px-6",
|
|
1853
|
+
"py-5",
|
|
1854
|
+
"flex",
|
|
1855
|
+
"flex-wrap",
|
|
1856
|
+
"items-center",
|
|
1857
|
+
"gap-x-4",
|
|
1858
|
+
"gap-y-1",
|
|
1859
|
+
"justify-between",
|
|
1860
|
+
"border-b",
|
|
1861
|
+
"border-b-secondary-200",
|
|
1862
|
+
]);
|
|
1863
|
+
const cvaPageHeaderHeading = cvaMerge(["flex", "text-slate-900", "text-2xl", "font-bold", "min-w-0"]);
|
|
1864
|
+
const cvaPageHeaderHeadingContainer = cvaMerge(["flex", "gap-x-4", "items-center"]);
|
|
1865
|
+
const cvaPageHeaderHeadingAccessoriesContainer = cvaMerge([
|
|
1866
|
+
"flex",
|
|
1867
|
+
"flex-wrap",
|
|
1868
|
+
"items-center",
|
|
1869
|
+
"gap-x-4",
|
|
1870
|
+
"gap-y-2",
|
|
1871
|
+
]);
|
|
1872
|
+
const cvaPageHeaderChildContainer = cvaMerge(["flex", "flex-wrap", "gap-x-6", "items-center"]);
|
|
1668
1873
|
|
|
1669
1874
|
/**
|
|
1670
1875
|
* Pageheader component is used to display a page header.
|
|
@@ -1675,39 +1880,21 @@ const TipContainer = tw.text `
|
|
|
1675
1880
|
* @returns {JSX.Element} PageHeader component
|
|
1676
1881
|
*/
|
|
1677
1882
|
const PageHeader = ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, children, }) => {
|
|
1678
|
-
return (jsxs(
|
|
1679
|
-
};
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
const StyledPageHeader = tw.div `
|
|
1694
|
-
tu-page-header
|
|
1695
|
-
`;
|
|
1696
|
-
const HeadingAndAccessoriesContainer = tw.div `
|
|
1697
|
-
tu-page-header__heading-accessories-container
|
|
1698
|
-
`;
|
|
1699
|
-
const HeadingContainer = tw.div `
|
|
1700
|
-
tu-page-header__heading-container
|
|
1701
|
-
`;
|
|
1702
|
-
const Heading = tw.h1 `
|
|
1703
|
-
tu-page-header__heading
|
|
1704
|
-
`;
|
|
1705
|
-
const ChildContainer$1 = tw.div `
|
|
1706
|
-
tu-page-header__child-container
|
|
1707
|
-
`;
|
|
1708
|
-
const StyledTip = twx(Tip) `
|
|
1709
|
-
${p => (p.link ? tws `tu-page-header__tip` : null)}
|
|
1710
|
-
`;
|
|
1883
|
+
return (jsxs("div", Object.assign({ className: cvaPageHeader({ className: `${className} tu-page-header` }), "data-testid": dataTestId }, { children: [jsxs("div", Object.assign({ className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container` }, { children: [jsxs("div", Object.assign({ className: cvaPageHeaderHeadingContainer() }, { children: [backTo && (jsx(IconButton, { to: backTo, color: "tertiary", variant: "transparent", size: "small", icon: jsx(Icon, { name: "ArrowLeftIcon" }) })), jsx("h1", Object.assign({ className: cvaPageHeaderHeading(), "data-testid": dataTestId && `${dataTestId}-heading` }, { children: title })), description && !showLoading && (jsx(Tip, Object.assign({ dataTestId: dataTestId && `${dataTestId}-tip`, iconProps: { name: "QuestionMarkCircleIcon" }, link: link }, { children: description })))] })), tag && !showLoading && jsx(Tag, Object.assign({ dataTestId: dataTestId }, { children: tag })), showLoading && jsx(Spinner, { dataTestId: dataTestId && `${dataTestId}-spinner`, centering: "vertically" }), action] })), jsx("div", Object.assign({ className: cvaPageHeaderChildContainer() }, { children: children }))] })));
|
|
1884
|
+
};
|
|
1885
|
+
|
|
1886
|
+
const cvaSkeletonLine = cvaMerge([
|
|
1887
|
+
"rounded-md",
|
|
1888
|
+
"h-3",
|
|
1889
|
+
"opacity-20",
|
|
1890
|
+
"animate-pulse",
|
|
1891
|
+
"bg-black/50",
|
|
1892
|
+
"bg-auto",
|
|
1893
|
+
"bg-gradient-to-r",
|
|
1894
|
+
"from-black/0",
|
|
1895
|
+
"via-black/50",
|
|
1896
|
+
"to-black/20",
|
|
1897
|
+
]);
|
|
1711
1898
|
|
|
1712
1899
|
/**
|
|
1713
1900
|
* Display placeholder lines before the data gets loaded to reduce load-time frustration.
|
|
@@ -1727,14 +1914,14 @@ const SkeletonLines = memo(({ margin = "10px 0", lines = 1, height, width = "100
|
|
|
1727
1914
|
return height;
|
|
1728
1915
|
};
|
|
1729
1916
|
for (let i = 0; i < lines; i++) {
|
|
1730
|
-
skeletonLines.push(jsx(
|
|
1917
|
+
skeletonLines.push(jsx("div", Object.assign({ "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "skeleton-lines", "data-type": "loading-skeleton-line", className: cvaSkeletonLine({ className }), style: { height: getHeight(i), width: getWidth(i), margin: lines > 1 ? margin : "" } }, { children: lines > 1 && jsx(Fragment, { children: "\u00A0" }) }), i));
|
|
1731
1918
|
}
|
|
1732
1919
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
1733
1920
|
return jsx(Fragment, { children: skeletonLines });
|
|
1734
|
-
});
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1921
|
+
});
|
|
1922
|
+
|
|
1923
|
+
const cvaPagination = cvaMerge(["flex", "items-center", "gap-1"]);
|
|
1924
|
+
const cvaPaginationText = cvaMerge("whitespace-nowrap");
|
|
1738
1925
|
|
|
1739
1926
|
/**
|
|
1740
1927
|
* Pagination Description. It could be used when you need navigation for your paging feature.
|
|
@@ -1777,18 +1964,12 @@ const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, page
|
|
|
1777
1964
|
onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange({ from, to, description });
|
|
1778
1965
|
}, [page, onPageChange, previousPage, nextPage]);
|
|
1779
1966
|
if (loading) {
|
|
1780
|
-
return (jsx(
|
|
1967
|
+
return (jsx("div", Object.assign({ className: cvaPagination({ className }) }, { children: jsx(SkeletonLines, { height: 16, width: 150 }) })));
|
|
1781
1968
|
}
|
|
1782
|
-
return (jsxs(
|
|
1969
|
+
return (jsxs("div", Object.assign({ "data-testid": dataTestId, className: cvaPagination({ className }) }, { children: [jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsx(Icon, { name: "ChevronLeftIcon", size: "small" }), size: "small", color: "secondary", variant: "transparent" }), !cursorBase && (jsxs(Fragment, { children: [jsx("div", Object.assign({ className: cvaPaginationText(), "data-testid": "current-page" }, { children: currentPage })), jsx("div", Object.assign({ className: cvaPaginationText(), "data-testid": "page-count" }, { children: pageCount !== null && pageCount !== undefined && getTranslatedCount && getTranslatedCount(pageCount) }))] })), jsx(IconButton, { onClick: () => handlePageChange("next"), disabled: cursorBase
|
|
1783
1970
|
? !canNextPage || false
|
|
1784
1971
|
: page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsx(Icon, { name: "ChevronRightIcon", size: "small" }), size: "small", color: "secondary", variant: "transparent" })] })));
|
|
1785
|
-
};
|
|
1786
|
-
const Root$2 = tw.div `
|
|
1787
|
-
tu-pagination
|
|
1788
|
-
`;
|
|
1789
|
-
const TextStyled = twx(Text$1) `
|
|
1790
|
-
tu-pagination__text
|
|
1791
|
-
`;
|
|
1972
|
+
};
|
|
1792
1973
|
|
|
1793
1974
|
function useConfirmExit(confirmExit, when = true) {
|
|
1794
1975
|
const { navigator } = useContext(UNSAFE_NavigationContext);
|
|
@@ -1843,29 +2024,33 @@ const Prompt = ({ when, message }) => {
|
|
|
1843
2024
|
return null;
|
|
1844
2025
|
};
|
|
1845
2026
|
|
|
2027
|
+
const cvaSpacer = cvaMerge([], {
|
|
2028
|
+
variants: {
|
|
2029
|
+
border: {
|
|
2030
|
+
true: ["border-t", "border-solid", "border-neutral-100", "min-h-[1px]"],
|
|
2031
|
+
false: "",
|
|
2032
|
+
},
|
|
2033
|
+
size: {
|
|
2034
|
+
small: "min-h-[8px]",
|
|
2035
|
+
medium: "min-h-[20px]",
|
|
2036
|
+
large: "min-h-[32px]",
|
|
2037
|
+
},
|
|
2038
|
+
},
|
|
2039
|
+
defaultVariants: {
|
|
2040
|
+
border: false,
|
|
2041
|
+
size: "medium",
|
|
2042
|
+
},
|
|
2043
|
+
});
|
|
2044
|
+
|
|
1846
2045
|
/**
|
|
1847
2046
|
* The Spacer component is used for adding a bit of space in the ui.
|
|
1848
2047
|
*
|
|
1849
2048
|
* @param {SpacerProps} props - The props for the Spacer component
|
|
1850
2049
|
* @returns {JSX.Element} Spacer component
|
|
1851
2050
|
*/
|
|
1852
|
-
const Spacer = ({
|
|
1853
|
-
return jsx(
|
|
1854
|
-
};
|
|
1855
|
-
const GetSpacerHeight = () => ({ $minHeight }) => {
|
|
1856
|
-
switch ($minHeight) {
|
|
1857
|
-
case "normal":
|
|
1858
|
-
return tws `tu-spacer--normal`;
|
|
1859
|
-
case "large":
|
|
1860
|
-
return tws `tu-spacer--large`;
|
|
1861
|
-
default:
|
|
1862
|
-
return "";
|
|
1863
|
-
}
|
|
1864
|
-
};
|
|
1865
|
-
const Space = tw.div `
|
|
1866
|
-
${p => `${p.$border ? `tu-spacer--border` : null}`}
|
|
1867
|
-
${GetSpacerHeight()}
|
|
1868
|
-
`;
|
|
2051
|
+
const Spacer = ({ size = "medium", border = false, dataTestId, className }) => {
|
|
2052
|
+
return jsx("div", { "data-testid": dataTestId, className: cvaSpacer({ className, border, size }) });
|
|
2053
|
+
};
|
|
1869
2054
|
|
|
1870
2055
|
/**
|
|
1871
2056
|
* The SectionHeader component is used on sections to set the section title.
|
|
@@ -1874,10 +2059,9 @@ const Space = tw.div `
|
|
|
1874
2059
|
* @returns {JSX.Element} SectionHeader component
|
|
1875
2060
|
*/
|
|
1876
2061
|
const SectionHeader = ({ title, subtitle, dataTestId, addons }) => {
|
|
1877
|
-
return (jsxs(SectionHeaderContainer, { children: [jsx(HelmetProvider, { children: jsx(Helmet, { title: title }) }), jsxs(StyledFlex, Object.assign({ className: "flex-row mb-2" }, { children: [jsxs(StyledFlex, Object.assign({ className: "flex-col grow" }, { children: [jsx(Heading
|
|
2062
|
+
return (jsxs(SectionHeaderContainer, { children: [jsx(HelmetProvider, { children: jsx(Helmet, { title: title }) }), jsxs(StyledFlex, Object.assign({ className: "flex-row mb-2" }, { children: [jsxs(StyledFlex, Object.assign({ className: "flex-col grow" }, { children: [jsx(Heading, Object.assign({ variant: "secondary", dataTestId: dataTestId }, { children: title })), subtitle && (jsx(Heading, Object.assign({ variant: "subtitle", subtle: true }, { children: subtitle })))] })), addons && jsx(StyledFlex, { children: addons })] })), jsx(Spacer, { size: "small" })] }));
|
|
1878
2063
|
};
|
|
1879
2064
|
const SectionHeaderContainer = tw.div `
|
|
1880
|
-
tu-section-header
|
|
1881
2065
|
flex
|
|
1882
2066
|
flex-col
|
|
1883
2067
|
`;
|
|
@@ -1886,6 +2070,21 @@ const StyledFlex = tw.div `
|
|
|
1886
2070
|
gap-2
|
|
1887
2071
|
`;
|
|
1888
2072
|
|
|
2073
|
+
const cvaSidebar = cvaMerge(["apply grid", "grid-cols-fr-min", "items-center"]);
|
|
2074
|
+
const cvaSidebarChildContainer = cvaMerge(["apply flex", "overflow-hidden", "gap-2", "p-1", "max-w-full"], {
|
|
2075
|
+
variants: {
|
|
2076
|
+
breakpoint: {
|
|
2077
|
+
xs: ["xs:overflow-visible", "xs:p-0", "xs:grid", "xs:grid-cols-1", "xs:w-full"],
|
|
2078
|
+
sm: ["sm:overflow-visible", "sm:p-0", "sm:grid", "sm:grid-cols-1", "sm:w-full"],
|
|
2079
|
+
md: ["md:overflow-visible", "md:p-0", "md:grid", "md:grid-cols-1", "md:w-full"],
|
|
2080
|
+
lg: ["lg:overflow-visible", "lg:p-0", "lg:grid", "lg:grid-cols-1", "lg:w-full"],
|
|
2081
|
+
xl: ["xl:overflow-visible", "xl:p-0", "xl:grid", "xl:grid-cols-1", "xl:w-full"],
|
|
2082
|
+
"2xl": ["2xl:overflow-visible", "2xl:p-0", "2xl:grid", "2xl:grid-cols-1", "2xl:w-full"],
|
|
2083
|
+
"3xl": ["3xl:overflow-visible", "3xl:p-0", "3xl:grid", "3xl:grid-cols-1", "3xl:w-full"],
|
|
2084
|
+
},
|
|
2085
|
+
},
|
|
2086
|
+
});
|
|
2087
|
+
|
|
1889
2088
|
/**
|
|
1890
2089
|
* A hook used to detect what children are overflowing a container.
|
|
1891
2090
|
*
|
|
@@ -1962,7 +2161,7 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
1962
2161
|
}
|
|
1963
2162
|
return tws `visible`;
|
|
1964
2163
|
};
|
|
1965
|
-
return (jsxs(
|
|
2164
|
+
return (jsxs("div", Object.assign({ className: cvaSidebar({ className }), "data-testid": dataTestId }, { children: [jsx("div", Object.assign({ ref: overflowContainerRef, className: cvaSidebarChildContainer({ breakpoint, className: childContainerClassName }), "data-testid": dataTestId && `${dataTestId}-child-container` }, { children: React__default.Children.map(children, child => {
|
|
1966
2165
|
return React__default.cloneElement(child, {
|
|
1967
2166
|
className: `${child.props.className} ${itemVisibilityClassName(child.props.id)}`,
|
|
1968
2167
|
});
|
|
@@ -1981,23 +2180,20 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
1981
2180
|
})
|
|
1982
2181
|
: null;
|
|
1983
2182
|
}) }))) }))) : null] })));
|
|
1984
|
-
};
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
"
|
|
1995
|
-
"
|
|
1996
|
-
|
|
1997
|
-
const
|
|
1998
|
-
tu-sidebar__child-container
|
|
1999
|
-
${({ $breakpoint }) => breakpointClasses[$breakpoint]}
|
|
2000
|
-
`;
|
|
2183
|
+
};
|
|
2184
|
+
|
|
2185
|
+
const cvaTimeline = cvaMerge("ml-4");
|
|
2186
|
+
const cvaTimelineElement = cvaMerge([
|
|
2187
|
+
"grid",
|
|
2188
|
+
"grid-cols-[min-content_auto]",
|
|
2189
|
+
"grid-rows-[auto_auto]",
|
|
2190
|
+
"items-start",
|
|
2191
|
+
"border-l-[8px]",
|
|
2192
|
+
"border-gray-100",
|
|
2193
|
+
"pb-4",
|
|
2194
|
+
"last:border-transparent",
|
|
2195
|
+
]);
|
|
2196
|
+
const cvaTimelineDot = cvaMerge(["flex", "space-x-4", "items-start", "ml-[calc(-50%-8px)]"]);
|
|
2001
2197
|
|
|
2002
2198
|
/**
|
|
2003
2199
|
* Timeline - used to contain TimelineElements for building a sequence of timed entries - each rendered on a line
|
|
@@ -2009,7 +2205,7 @@ const ChildContainer = tw.div `
|
|
|
2009
2205
|
* @returns {JSX.Element} Timeline component
|
|
2010
2206
|
*/
|
|
2011
2207
|
const Timeline = ({ className, dataTestId, children }) => {
|
|
2012
|
-
return (jsx("ol", Object.assign({ className:
|
|
2208
|
+
return (jsx("ol", Object.assign({ className: cvaTimeline({ className }), "data-testid": dataTestId }, { children: children })));
|
|
2013
2209
|
};
|
|
2014
2210
|
/**
|
|
2015
2211
|
* TimelineElement - entry on a timeline - rendered with an icon on the timeline
|
|
@@ -2019,8 +2215,7 @@ const Timeline = ({ className, dataTestId, children }) => {
|
|
|
2019
2215
|
* @returns {JSX.Element} component
|
|
2020
2216
|
*/
|
|
2021
2217
|
const TimelineElement = ({ date, showTime, children, className, dataTestId = "timeline-date", headerClassName, dot = jsx(Indicator, { className: tws `mt-[-1px]`, color: "neutral", icon: jsx(Icon, { name: "CalendarIcon", size: "large" }) }), header = defaultHeader(date, showTime), onClick, }) => {
|
|
2022
|
-
|
|
2023
|
-
return (jsxs("li", Object.assign({ className: `${tws `tu-timeline-element`}${(_a = " " + className) !== null && _a !== void 0 ? _a : ""} `, "data-date": date, "data-testid": dataTestId && dataTestId, onClick: () => onClick && onClick() }, { children: [jsx("div", Object.assign({ className: tws `tu-timeline-element__dot` }, { children: dot })), jsx("div", Object.assign({ className: headerClassName }, { children: header })), jsx("div", {}), jsx("div", { children: jsx("div", { children: children }) })] })));
|
|
2218
|
+
return (jsxs("li", Object.assign({ className: cvaTimelineElement({ className }), "data-date": `${date}`, "data-testid": dataTestId && `${dataTestId}`, onClick: () => onClick && onClick() }, { children: [jsx("div", Object.assign({ className: cvaTimelineDot() }, { children: dot })), jsx("div", { children: header }), jsx("div", {}), jsx("div", { children: jsx("div", { children: children }) })] })));
|
|
2024
2219
|
};
|
|
2025
2220
|
function defaultHeader(date, showTime) {
|
|
2026
2221
|
return `${format(date, showTime ? "MMM d, yyyy H:mm" : "MMM d, yyyy")} (${formatDistance(date, new Date(), {
|
|
@@ -2028,6 +2223,71 @@ function defaultHeader(date, showTime) {
|
|
|
2028
2223
|
})})`;
|
|
2029
2224
|
}
|
|
2030
2225
|
|
|
2226
|
+
const cvaTooltipFlexContainer = cvaMerge("inline-flex");
|
|
2227
|
+
const cvaTooltipPopover = cvaMerge("pointer-events-none origin-center");
|
|
2228
|
+
cvaMerge("pointer-events-none origin-center");
|
|
2229
|
+
const cvaTooltipContent = cvaMerge("p-2 rounded max-w-sm", {
|
|
2230
|
+
variants: {
|
|
2231
|
+
color: {
|
|
2232
|
+
light: "shadow-md bg-white",
|
|
2233
|
+
dark: "text-white bg-neutral-800",
|
|
2234
|
+
},
|
|
2235
|
+
},
|
|
2236
|
+
defaultVariants: {
|
|
2237
|
+
color: "light",
|
|
2238
|
+
},
|
|
2239
|
+
});
|
|
2240
|
+
|
|
2241
|
+
/**
|
|
2242
|
+
* The Tooltip component is used to show helpful tips or contextual information to the users.
|
|
2243
|
+
*
|
|
2244
|
+
* @param {TooltipProps} props - The props for the Tooltip component
|
|
2245
|
+
* @returns {JSX.Element} Tooltip component
|
|
2246
|
+
*/
|
|
2247
|
+
const Tooltip = (_a) => {
|
|
2248
|
+
var { children, dataTestId, disabled, className } = _a, rest = __rest(_a, ["children", "dataTestId", "disabled", "className"]);
|
|
2249
|
+
const wrappedChildren = (jsx("div", Object.assign({ className: cvaTooltipFlexContainer({ className }), "data-testid": dataTestId && `${dataTestId}-parent` }, { children: children })));
|
|
2250
|
+
if (disabled) {
|
|
2251
|
+
return wrappedChildren;
|
|
2252
|
+
}
|
|
2253
|
+
return (jsx(TooltipContainer, Object.assign({ dataTestId: dataTestId }, rest, { children: wrappedChildren })));
|
|
2254
|
+
};
|
|
2255
|
+
const TooltipContainer = ({ label, placement = "bottom", mode = "dark", contentTextType = "p", children, dataTestId, }) => (jsxs(Popover, Object.assign({ className: cvaTooltipPopover(), placement: placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "" }, { children: [jsx(PopoverTrigger, { children: children }), jsx(PopoverContent, { children: jsx("div", Object.assign({ className: cvaTooltipContent({ color: mode }) }, { children: jsx(Text, Object.assign({ inverted: mode === "dark", type: contentTextType }, { children: label })) })) })] })));
|
|
2256
|
+
|
|
2257
|
+
const cvaValueBar = cvaMerge(["w-full"], {
|
|
2258
|
+
variants: {
|
|
2259
|
+
size: {
|
|
2260
|
+
small: "h-3",
|
|
2261
|
+
large: "h-9",
|
|
2262
|
+
},
|
|
2263
|
+
},
|
|
2264
|
+
defaultVariants: {
|
|
2265
|
+
size: "small",
|
|
2266
|
+
},
|
|
2267
|
+
});
|
|
2268
|
+
const cvaValueBarProgress = cvaMerge(["h-full", "rounded"], {
|
|
2269
|
+
variants: {
|
|
2270
|
+
fill: {
|
|
2271
|
+
default: "",
|
|
2272
|
+
background: "fill-slate-100",
|
|
2273
|
+
},
|
|
2274
|
+
},
|
|
2275
|
+
defaultVariants: {
|
|
2276
|
+
fill: "default",
|
|
2277
|
+
},
|
|
2278
|
+
});
|
|
2279
|
+
const cvaValueBarText = cvaMerge([], {
|
|
2280
|
+
variants: {
|
|
2281
|
+
size: {
|
|
2282
|
+
small: "font-bold text-sm",
|
|
2283
|
+
large: "drop-shadow-lg",
|
|
2284
|
+
},
|
|
2285
|
+
},
|
|
2286
|
+
defaultVariants: {
|
|
2287
|
+
size: "small",
|
|
2288
|
+
},
|
|
2289
|
+
});
|
|
2290
|
+
|
|
2031
2291
|
/**
|
|
2032
2292
|
* Helper function to get normalized score in range 0-1 used by the ValueBar
|
|
2033
2293
|
*
|
|
@@ -2101,22 +2361,8 @@ const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors
|
|
|
2101
2361
|
const score = getScore(value, min, max);
|
|
2102
2362
|
const barFillColor = levelColors ? getFillColor(score, levelColors) : getDefaultFillColor(score);
|
|
2103
2363
|
const barWidth = showValue && size === "small" ? 90 : 100;
|
|
2104
|
-
return (jsx(
|
|
2105
|
-
};
|
|
2106
|
-
const Root = tw.svg `
|
|
2107
|
-
tu-value-bar
|
|
2108
|
-
${({ $size }) => ($size === "small" ? tws `tu-value-bar--small` : tws `tu-value-bar--large`)}
|
|
2109
|
-
`;
|
|
2110
|
-
const Text = tw.text `
|
|
2111
|
-
tu-value-bar__text
|
|
2112
|
-
${({ $size }) => ($size === "small" ? tws `tu-value-bar__text--small` : tws `tu-value-bar__text--large`)}
|
|
2113
|
-
`;
|
|
2114
|
-
const Background = tw.rect `
|
|
2115
|
-
tu-value-bar__background
|
|
2116
|
-
`;
|
|
2117
|
-
const Bar = tw.rect `
|
|
2118
|
-
tu-value-bar__bar
|
|
2119
|
-
`;
|
|
2364
|
+
return (jsx("svg", Object.assign({ className: cvaValueBar({ size, className }), "data-testid": dataTestId }, { children: jsxs("g", { children: [jsx("rect", { className: cvaValueBarProgress({ fill: "background" }), width: `${barWidth}%`, rx: "5" }), jsx("rect", { className: cvaValueBarProgress(), width: `${score * barWidth}%`, fill: barFillColor, rx: "5" }), showValue && size === "large" && (jsxs("text", Object.assign({ className: cvaValueBarText({ size }), x: "12", y: "23", fill: valueColor !== null && valueColor !== void 0 ? valueColor : "white" }, { children: [Number(value.toFixed(1)), unit || ""] }))), showValue && size === "small" && (jsxs("text", Object.assign({ className: cvaValueBarText({ size }), x: `${barWidth + 2}%`, y: "11", fill: valueColor !== null && valueColor !== void 0 ? valueColor : color("NEUTRAL", 400, "CSS") }, { children: [Number(value.toFixed(1)), unit || ""] })))] }) })));
|
|
2365
|
+
};
|
|
2120
2366
|
|
|
2121
2367
|
const cvaClickable = cvaMerge([
|
|
2122
2368
|
"shadow-lg",
|
|
@@ -2329,4 +2575,4 @@ const Layout = tw.div `
|
|
|
2329
2575
|
tu-layout-TwoColumnLayout
|
|
2330
2576
|
`;
|
|
2331
2577
|
|
|
2332
|
-
export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, ContentGridArea, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, ExternalLink, FilterListMapLayout, FullWidthRepeatingLayout, GridArea, Heading
|
|
2578
|
+
export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, ContentGridArea, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, ExternalLink, FilterListMapLayout, FullWidthRepeatingLayout, GridArea, Heading, Icon, IconButton, Indicator, IntrinsicallyResponsiveGrid, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MoreMenu, NavGridArea, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, Timeline, TimelineElement, Tip, TitleGridArea, TitleNavContentLayout, Tooltip, TwoColumnLayout, ValueBar, cvaButton, cvaButtonSpinner, cvaClickable, cvaIconButtonContainer, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, docs, getDevicePixelRatio, getValueBarColorByValue, useClickOutside, useContainerProps, useDebounce, useDevicePixelRatio, useHover, useIsFirstRender, useLocalStorage, useLocalStorageReducer, useModal, usePopoverContext, usePrompt, useResize, useTimeout };
|