@northlight/ui 1.5.1 → 1.5.2

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.
@@ -1,3747 +0,0 @@
1
- import React, { useMemo, Suspense, createContext, useContext, forwardRef as forwardRef$1, useImperativeHandle, useRef, useEffect, cloneElement, memo, useState } from 'react';
2
- import { Switch as Switch$2, Route, Redirect, NavLink, useLocation, useHistory, BrowserRouter, Link as Link$2 } from 'react-router-dom';
3
- import { forwardRef, useStyleConfig, Icon as Icon$2, Text, FormLabel as FormLabel$1, VisuallyHidden, Box, Button as Button$2, IconButton as IconButton$1, useMultiStyleConfig, chakra, Table, Thead, Tbody, Tr, Tag as Tag$2, TagLabel, TagRightIcon, useEditableControls, useEditableState, HStack, Editable, InputGroup, InputLeftElement, Input as Input$1, EditablePreview, EditableInput, InputRightElement, Modal as Modal$2, ModalOverlay, ModalContent, ModalCloseButton, ModalHeader, ModalBody, Stack, Slider, SliderTrack, SliderFilledTrack, SliderThumb, ModalFooter, keyframes, useToken as useToken$1, extendTheme, ChakraProvider, Switch as Switch$3, LinkOverlay, useDisclosure, Card, Grid, Flex, Link as Link$1, FormControl } from '@chakra-ui/react';
4
- import { CheckDuo, SearchDuo, DotsMatrixSolid, XCloseSolid, EditDuo, ZoomInDuo, ArrowCircleRightDuo, NorthlightLogoXs } from '@northlight/icons';
5
- import { useToken, useMultiStyleConfig as useMultiStyleConfig$1, chakra as chakra$1 } from '@chakra-ui/system';
6
- import { palette, WebappSkin as WebappSkin$1, typography, TottSkin as TottSkin$1, coreZIndex, coreSizing, coreSpacing, coreFontWeight, coreBoxShadow, coreFontSize, coreLineHeight, coreBorderRadius } from '@northlight/tokens';
7
- import { ifElse, gt, always, identity, forEach, is, trim, keys, values, equals, isNil, last, map, prop, difference, times, merge, filter, test, toLower, chain, defaultTo, head } from 'ramda';
8
- import { useForm, FormProvider } from 'react-hook-form';
9
- import { useFocusManager } from '@react-aria/focus';
10
- import '@react-aria/checkbox';
11
- import '@react-aria/radio';
12
- import '@react-aria/utils';
13
- import '@react-stately/radio';
14
- import '@react-stately/checkbox';
15
- import '@react-aria/datepicker';
16
- import '@react-stately/datepicker';
17
- import { today, isSameMonth, getWeeksInMonth } from '@internationalized/date';
18
- import '@react-aria/button';
19
- import { I18nProvider as I18nProvider$1 } from '@react-aria/i18n';
20
- import '@react-stately/calendar';
21
- import { useCalendarCell, useCalendarGrid } from '@react-aria/calendar';
22
- import '@chakra-ui/clickable';
23
- import 'framer-motion';
24
- import { chakraComponents, AsyncSelect } from 'chakra-react-select';
25
- import '@dnd-kit/core';
26
- import '@dnd-kit/utilities';
27
- import '@dnd-kit/sortable';
28
- import '@dnd-kit/modifiers';
29
- import { VariableSizeList, VariableSizeGrid } from 'react-window';
30
- import AutoSizer from 'react-virtualized-auto-sizer';
31
- import AvatarEditor from 'react-avatar-editor';
32
- import { randomColor } from '@chakra-ui/theme-tools';
33
- import 'react-input-mask';
34
- import 'react-live';
35
- import 'markdown-to-jsx';
36
- import Fuse from 'fuse.js';
37
- import { I18nManager, I18nContext } from '@shopify/react-i18n';
38
-
39
- const LazyPage = ({ loader, children, ...rest }) => {
40
- const Component = useMemo(() => React.lazy(loader), []);
41
- return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement("p", null, "Loading....") }, children ? children(Component, { ...rest }) : /* @__PURE__ */ React.createElement(Component, { ...rest }));
42
- };
43
-
44
- const normalizePath = ({
45
- basename,
46
- path
47
- }) => basename ? `${basename}${path}` : path;
48
- const Routing = ({ routes, basename, fallback }) => /* @__PURE__ */ React.createElement(Switch$2, null, routes.flatMap(({ path, component, subItems = [] }) => {
49
- const routePath = normalizePath({ basename, path });
50
- const mainRoute = /* @__PURE__ */ React.createElement(
51
- Route,
52
- {
53
- key: routePath,
54
- exact: true,
55
- path: routePath,
56
- render: (props) => /* @__PURE__ */ React.createElement(
57
- LazyPage,
58
- {
59
- ...props,
60
- loader: component
61
- }
62
- )
63
- }
64
- );
65
- const subRoutes = subItems.map(({ path: subPath, component: subComponent, extraProps }) => {
66
- const fullPath = `${path}${subPath}`;
67
- return /* @__PURE__ */ React.createElement(
68
- Route,
69
- {
70
- key: fullPath,
71
- path: fullPath,
72
- render: (props) => /* @__PURE__ */ React.createElement(
73
- LazyPage,
74
- {
75
- ...props,
76
- loader: subComponent,
77
- ...extraProps
78
- }
79
- )
80
- }
81
- );
82
- });
83
- return [mainRoute, ...subRoutes];
84
- }), fallback && /* @__PURE__ */ React.createElement(Redirect, { to: fallback }));
85
-
86
- const Icon$1 = forwardRef(({
87
- as: As,
88
- size,
89
- color,
90
- boxSize,
91
- ...rest
92
- }, ref) => {
93
- const CustomIcon = As ?? (() => /* @__PURE__ */ React.createElement(Icon$2, null));
94
- const styles = useStyleConfig("Icon", { size, color, boxSize });
95
- return /* @__PURE__ */ React.createElement(
96
- Icon$2,
97
- {
98
- ref,
99
- sx: styles,
100
- ...rest
101
- },
102
- /* @__PURE__ */ React.createElement(CustomIcon, null)
103
- );
104
- });
105
-
106
- const luminosity = (hexcolor) => {
107
- let color = hexcolor;
108
- if (color.slice(0, 1) === "#") {
109
- color = color.slice(1);
110
- }
111
- if (color.length === 3) {
112
- color = color.split("").map((hex) => hex + hex).join("");
113
- }
114
- const r = parseInt(color.substring(0, 2), 16);
115
- const g = parseInt(color.substring(2, 4), 16);
116
- const b = parseInt(color.substring(4, 6), 16);
117
- const brightness = (r * 299 + g * 587 + b * 114) / 1e3;
118
- return brightness;
119
- };
120
-
121
- const getContrastColor = (color) => {
122
- const colorTwo = useToken("colors", "text.default");
123
- const colorOne = useToken("colors", "text.inverted");
124
- const colorInHex = useToken("colors", color);
125
- const l1 = luminosity(colorOne);
126
- const l2 = luminosity(colorTwo);
127
- const threshold = (l1 + l2) / 2;
128
- const brightColor = l1 > l2 ? colorOne : colorTwo;
129
- const darkColor = l1 > l2 ? colorTwo : colorOne;
130
- return luminosity(colorInHex) >= threshold ? darkColor : brightColor;
131
- };
132
-
133
- const ring = {
134
- _focusVisible: {
135
- outline: "none",
136
- ring: "2px",
137
- ringColor: "border.wcag",
138
- ringOffset: "1px"
139
- }
140
- };
141
-
142
- const getShades = (startShade, endShade) => {
143
- let start;
144
- let end;
145
- if (!endShade) {
146
- start = startShade;
147
- end = startShade;
148
- } else if (endShade > startShade) {
149
- start = startShade;
150
- end = endShade;
151
- } else {
152
- start = endShade;
153
- end = startShade;
154
- }
155
- return Object.keys(palette).reduce((colors, color) => {
156
- if (color === "mono")
157
- return colors;
158
- return colors.concat(
159
- Object.keys(palette[color]).filter(
160
- (value) => parseInt(value, 10) >= start && parseInt(value, 10) <= end
161
- ).map((shade) => palette[color][shade])
162
- );
163
- }, []);
164
- };
165
-
166
- const createDebounceFunctionInstance = (delay) => {
167
- let timeout;
168
- return (fn) => (...args) => {
169
- clearTimeout(timeout);
170
- timeout = setTimeout(() => {
171
- fn(...args);
172
- }, delay);
173
- };
174
- };
175
-
176
- const CustomTheme = createContext("webappTheme");
177
- const useCurrentTheme = () => {
178
- const theme = useContext(CustomTheme);
179
- return theme;
180
- };
181
-
182
- const P$1 = ({
183
- children,
184
- variant = "16",
185
- sx = {},
186
- ...rest
187
- }) => {
188
- const styles = useStyleConfig("P", { variant, sx });
189
- return /* @__PURE__ */ React.createElement(
190
- Text,
191
- {
192
- variant,
193
- sx: styles,
194
- ...rest
195
- },
196
- children
197
- );
198
- };
199
-
200
- const Capitalized$1 = ({
201
- children,
202
- sx = {},
203
- ...rest
204
- }) => {
205
- const styles = useStyleConfig("Capitalized", { sx });
206
- return /* @__PURE__ */ React.createElement(
207
- Text,
208
- {
209
- as: "span",
210
- sx: styles,
211
- ...rest
212
- },
213
- children
214
- );
215
- };
216
-
217
- const Label$1 = ({
218
- children,
219
- size = "sm",
220
- sx = {},
221
- ...rest
222
- }) => {
223
- const styles = useStyleConfig("Label", { sx, size });
224
- return /* @__PURE__ */ React.createElement(
225
- FormLabel$1,
226
- {
227
- sx: styles,
228
- requiredIndicator: /* @__PURE__ */ React.createElement(VisuallyHidden, null),
229
- ...rest
230
- },
231
- children
232
- );
233
- };
234
-
235
- ifElse(gt(0), always(0), identity);
236
-
237
- const Blinker$1 = ({
238
- color = "",
239
- size,
240
- isBlinking = true,
241
- ...rest
242
- }) => {
243
- const styles = useStyleConfig("Blinker", { color, size, isBlinking });
244
- return /* @__PURE__ */ React.createElement(Box, { sx: styles, "data-testid": "blinker-test-id", ...rest });
245
- };
246
-
247
- const Button$1 = forwardRef$1(
248
- ({ variant = "default", children, ...rest }, ref) => /* @__PURE__ */ React.createElement(Button$2, { variant, ref, ...rest }, children)
249
- );
250
-
251
- const shouldTrim = (value) => is(Array, value) ? values : identity;
252
- const trimFormValues = (obj) => {
253
- const newObj = obj;
254
- forEach((property) => {
255
- const value = obj[property];
256
- if (is(Object, value)) {
257
- const format = shouldTrim(value);
258
- newObj[property] = format(trimFormValues(value));
259
- }
260
- if (is(String, value)) {
261
- newObj[property] = trim(value);
262
- }
263
- }, keys(obj));
264
- return newObj;
265
- };
266
-
267
- forwardRef$1(({
268
- initialValues,
269
- onSubmit,
270
- children,
271
- validate,
272
- formSettings = { mode: "onChange" },
273
- methods = void 0,
274
- enableReinitialize = false,
275
- shouldTrim = true,
276
- ...rest
277
- }, ref) => {
278
- const customResolver = (values, _context, _options) => ({
279
- values,
280
- errors: validate(values)
281
- });
282
- const newMethods = methods || useForm({
283
- defaultValues: initialValues,
284
- resolver: validate ? customResolver : void 0,
285
- ...formSettings
286
- });
287
- useImperativeHandle(ref, always(newMethods), []);
288
- if (enableReinitialize) {
289
- const initalValuesImage = useRef({});
290
- useEffect(() => {
291
- if (!equals(initalValuesImage.current, initialValues)) {
292
- newMethods?.reset(initialValues);
293
- initalValuesImage.current = initialValues;
294
- }
295
- }, [initialValues]);
296
- }
297
- const formatValues = (values) => {
298
- if (!shouldTrim) {
299
- return values;
300
- }
301
- return trimFormValues(values);
302
- };
303
- const handleSubmit = newMethods.formState.isValid ? newMethods.handleSubmit(
304
- (values) => onSubmit(formatValues(values), newMethods)
305
- ) : (e) => {
306
- newMethods.trigger();
307
- e.preventDefault();
308
- };
309
- return /* @__PURE__ */ React.createElement(FormProvider, { ...newMethods, ...rest }, /* @__PURE__ */ React.createElement("form", { style: { width: "100%" }, onSubmit: handleSubmit }, typeof children === "function" ? children(newMethods) : children));
310
- });
311
-
312
- const FormLabel = ({
313
- children: label,
314
- ...rest
315
- }) => /* @__PURE__ */ React.createElement(
316
- Label$1,
317
- {
318
- size: "sm",
319
- sx: {
320
- width: "80%",
321
- maxWidth: "45ch",
322
- marginBottom: 1,
323
- marginInlineEnd: 3
324
- },
325
- requiredIndicator: void 0,
326
- ...rest
327
- },
328
- label
329
- );
330
-
331
- const useArrowFocus = (columns) => {
332
- const {
333
- focusNext: next,
334
- focusPrevious: previous,
335
- focusFirst,
336
- focusLast
337
- } = useFocusManager();
338
- const defaultOpts = {
339
- ArrowRight: {
340
- wrap: true,
341
- repeat: 1
342
- },
343
- ArrowLeft: {
344
- wrap: true,
345
- repeat: 1
346
- },
347
- ArrowDown: {
348
- wrap: false,
349
- repeat: columns
350
- },
351
- ArrowUp: {
352
- wrap: false,
353
- repeat: columns
354
- }
355
- };
356
- const focusPrevious = ({
357
- repeat,
358
- wrap
359
- } = defaultOpts.ArrowLeft) => {
360
- for (let i = 0; i < repeat; i += 1) {
361
- previous({ wrap });
362
- }
363
- };
364
- const focusNext = ({
365
- repeat,
366
- wrap
367
- } = defaultOpts.ArrowRight) => {
368
- for (let i = 0; i < repeat; i += 1) {
369
- next({ wrap });
370
- }
371
- };
372
- const defaultArrows = (e) => {
373
- switch (e.key) {
374
- case "ArrowRight":
375
- focusNext(defaultOpts.ArrowRight);
376
- break;
377
- case "ArrowLeft":
378
- focusPrevious(defaultOpts.ArrowLeft);
379
- break;
380
- case "ArrowDown":
381
- e.preventDefault();
382
- focusNext(defaultOpts.ArrowDown);
383
- break;
384
- case "ArrowUp":
385
- e.preventDefault();
386
- focusPrevious(defaultOpts.ArrowUp);
387
- break;
388
- }
389
- };
390
- return {
391
- defaultArrows,
392
- focusPrevious,
393
- focusNext,
394
- focusFirst,
395
- focusLast
396
- };
397
- };
398
-
399
- const useSelectCallbacks = ({
400
- onChange,
401
- onAdd,
402
- onRemove,
403
- isMulti,
404
- value
405
- }) => {
406
- const items = useRef(value);
407
- const handleChange = (val, event) => {
408
- onChange(val, event);
409
- if (!isMulti && !isNil(value)) {
410
- onAdd(val.value);
411
- } else if (val.length > items.current.length) {
412
- onAdd(last(val)?.value);
413
- } else {
414
- const removedItems = map(
415
- prop("value"),
416
- difference(items.current, val)
417
- );
418
- onRemove(removedItems.length === 1 ? removedItems[0] : removedItems);
419
- }
420
- items.current = val;
421
- };
422
- return handleChange;
423
- };
424
-
425
- const IconButton = forwardRef$1(({
426
- variant = "default",
427
- icon,
428
- "aria-label": ariaLabel,
429
- children,
430
- ...rest
431
- }, ref) => {
432
- const IconComponent = icon ?? children;
433
- const IconWithSize = cloneElement(IconComponent, { size: rest.size });
434
- return /* @__PURE__ */ React.createElement(
435
- IconButton$1,
436
- {
437
- variant,
438
- icon: IconWithSize,
439
- "aria-label": ariaLabel,
440
- ref,
441
- ...rest
442
- }
443
- );
444
- });
445
-
446
- const columns = 5;
447
- getShades(100, 500);
448
- getShades(500);
449
-
450
- forwardRef$1(({
451
- color,
452
- onClick,
453
- size,
454
- selected = false
455
- }, ref) => {
456
- if (!color)
457
- return /* @__PURE__ */ React.createElement(Box, null);
458
- const { defaultArrows, focusPrevious, focusNext } = useArrowFocus(columns);
459
- const onKeyDown = (e) => {
460
- switch (e.key) {
461
- case "PageUp":
462
- e.preventDefault();
463
- focusPrevious({ wrap: false, repeat: columns * 5 });
464
- break;
465
- case "PageDown":
466
- e.preventDefault();
467
- focusNext({ wrap: false, repeat: columns * 5 });
468
- break;
469
- default:
470
- defaultArrows(e);
471
- break;
472
- }
473
- };
474
- const { colorButton } = useMultiStyleConfig("ColorPicker", { size });
475
- return /* @__PURE__ */ React.createElement(
476
- IconButton,
477
- {
478
- bg: color,
479
- ref,
480
- onKeyDown,
481
- "aria-label": `select-${color}`,
482
- onClick,
483
- sx: colorButton,
484
- icon: /* @__PURE__ */ React.createElement(Icon$1, { as: CheckDuo, boxSize: selected ? void 0 : "0" }),
485
- color: getContrastColor(color)
486
- }
487
- );
488
- });
489
-
490
- createContext(null);
491
-
492
- forwardRef$1(
493
- ({ isInvalid, isDisabled, children, variant, ...rest }, ref) => {
494
- const { styledField } = useMultiStyleConfig("DatePicker", { variant });
495
- return /* @__PURE__ */ React.createElement(
496
- Box,
497
- {
498
- ...rest,
499
- ref,
500
- "aria-invalid": isInvalid,
501
- "aria-disabled": isDisabled,
502
- display: "flex",
503
- alignItems: "center",
504
- h: 10,
505
- __css: styledField
506
- },
507
- children
508
- );
509
- }
510
- );
511
-
512
- const CalendarCell = ({
513
- state,
514
- date,
515
- currentMonth
516
- }) => {
517
- const ref = useRef(null);
518
- const { cellProps, buttonProps, isSelected, formattedDate } = useCalendarCell(
519
- { date },
520
- state,
521
- ref
522
- );
523
- const isToday = date.compare(today(state.timeZone)) === 0;
524
- const isOutsideMonth = !isSameMonth(currentMonth, date);
525
- return /* @__PURE__ */ React.createElement(chakra.td, { ...cellProps }, /* @__PURE__ */ React.createElement(
526
- Button$1,
527
- {
528
- ...buttonProps,
529
- ref,
530
- borderRadius: "xs",
531
- boxSize: 8,
532
- hidden: isOutsideMonth,
533
- size: "sm",
534
- fontWeight: "medium",
535
- variant: isSelected ? "brand" : "ghost",
536
- ring: isToday && !isSelected ? "1px" : "0px",
537
- ringColor: "blue.500"
538
- },
539
- formattedDate
540
- ));
541
- };
542
-
543
- const DayLabels = memo(({
544
- weekDays
545
- }) => {
546
- const { dayLabel } = useMultiStyleConfig$1("Calendar");
547
- const weekDaysWithIds = weekDays.map((day, i) => ({ label: day, _id: i }));
548
- return /* @__PURE__ */ React.createElement(chakra$1.tr, null, weekDaysWithIds.map(({ label, _id }) => /* @__PURE__ */ React.createElement(chakra$1.th, { key: _id, __css: dayLabel }, label)));
549
- });
550
-
551
- memo(
552
- ({ state, locale, ...rest }) => {
553
- const startDate = state.visibleRange.start;
554
- const { gridProps, headerProps, weekDays } = useCalendarGrid(rest, state);
555
- const weeksInMonth = getWeeksInMonth(startDate, locale);
556
- return /* @__PURE__ */ React.createElement(Table, { variant: "unstyled", ...gridProps }, /* @__PURE__ */ React.createElement(Thead, { ...headerProps }, /* @__PURE__ */ React.createElement(DayLabels, { weekDays })), /* @__PURE__ */ React.createElement(Tbody, null, times((weekIndex) => /* @__PURE__ */ React.createElement(Tr, { key: weekIndex }, state.getDatesInWeek(weekIndex, startDate).map(
557
- (date) => date ? /* @__PURE__ */ React.createElement(
558
- CalendarCell,
559
- {
560
- key: date.day,
561
- state,
562
- date,
563
- currentMonth: startDate
564
- }
565
- ) : /* @__PURE__ */ React.createElement(chakra.td, null)
566
- )), weeksInMonth)));
567
- }
568
- );
569
-
570
- `1px solid ${palette.gray["100"]}`;
571
-
572
- const searchBarStyles = (sx) => merge({
573
- container: (provided) => ({
574
- ...provided,
575
- width: "100%",
576
- color: "text.default",
577
- alignSelf: "center"
578
- }),
579
- option: (provided, state) => ({
580
- ...provided,
581
- background: state.isFocused && "background.select.option-focus",
582
- _active: {
583
- background: "background.select.option-active"
584
- }
585
- }),
586
- valueContainer: (provided) => ({
587
- ...provided,
588
- paddingInlineStart: "padding-inline.select.default"
589
- }),
590
- downChevron: (provided) => ({
591
- ...provided,
592
- color: "icon.select.default"
593
- }),
594
- placeholder: (provided) => ({
595
- ...provided,
596
- color: "text.select.placeholder"
597
- }),
598
- multiValue: (provided, state) => {
599
- const background = state.data.isFixed ? "background.select.option-disabled" : state.data.color ?? provided.bgColor;
600
- return {
601
- ...provided,
602
- bgColor: background,
603
- color: getContrastColor(background),
604
- ...sx.multiValue
605
- };
606
- },
607
- menuList: (provided) => ({
608
- ...provided,
609
- bgColor: "background.default"
610
- })
611
- }, sx);
612
-
613
- function getComponents() {
614
- return {
615
- DropdownIndicator: (props) => props.selectProps.icon ? /* @__PURE__ */ React.createElement(chakraComponents.DropdownIndicator, { ...props }, /* @__PURE__ */ React.createElement(Icon$1, { as: props.selectProps.icon })) : /* @__PURE__ */ React.createElement(chakraComponents.DropdownIndicator, { ...props }),
616
- Option: (props) => props.selectProps.customOption ? /* @__PURE__ */ React.createElement(chakraComponents.Option, { ...props }, props.selectProps.customOption(props.data)) : /* @__PURE__ */ React.createElement(chakraComponents.Option, { ...props }),
617
- MultiValueContainer: (props) => props.selectProps.customTag ? /* @__PURE__ */ React.createElement(chakraComponents.MultiValueContainer, { ...props }, props.selectProps.customTag(props.data)) : /* @__PURE__ */ React.createElement(chakraComponents.MultiValueContainer, { ...props })
618
- };
619
- }
620
-
621
- const SearchBar = forwardRef$1(
622
- ({
623
- defaultOptions = [],
624
- isMulti = false,
625
- customOption = null,
626
- customTag = null,
627
- sx = {},
628
- debouncedWaitTime = 200,
629
- loadOptions: getCustomOptions = null,
630
- clearInputOnSelect = true,
631
- closeMenuOnSelect = false,
632
- onChange = identity,
633
- onAdd = identity,
634
- onRemove = identity,
635
- "data-testid": testId,
636
- value,
637
- onSearchInputChange = identity,
638
- icon = SearchDuo,
639
- ...rest
640
- }, ref) => {
641
- const [filtered, setFiltered] = useState(defaultOptions);
642
- const [filterInput, setFilterInput] = useState("");
643
- const debounceFunction = useMemo(
644
- () => createDebounceFunctionInstance(debouncedWaitTime),
645
- [debouncedWaitTime]
646
- );
647
- const handleChange = useSelectCallbacks({
648
- onChange,
649
- onAdd,
650
- onRemove,
651
- isMulti,
652
- value: is(Array, value) ? value : []
653
- });
654
- const customComponents = getComponents();
655
- const simpleFilter = (query) => filter(
656
- (option) => test(new RegExp(toLower(query), "g"), toLower(option.label)),
657
- defaultOptions
658
- );
659
- const getOptions = async (query) => {
660
- const newOptions = getCustomOptions ? await getCustomOptions(query) : simpleFilter(query);
661
- setFiltered(newOptions);
662
- return newOptions;
663
- };
664
- const loadOptions = debounceFunction(async (query, callback) => {
665
- const newOptions = await getOptions(query);
666
- callback(newOptions);
667
- return [];
668
- });
669
- const resetFiltered = (v, { action }) => {
670
- if (clearInputOnSelect || action !== "set-value") {
671
- setFilterInput(v);
672
- onSearchInputChange(v);
673
- if (v === "") {
674
- setFiltered(defaultOptions);
675
- }
676
- }
677
- };
678
- return /* @__PURE__ */ React.createElement(Box, { w: "full", "data-testid": testId }, /* @__PURE__ */ React.createElement(
679
- AsyncSelect,
680
- {
681
- cacheOptions: true,
682
- defaultOptions: filtered,
683
- loadOptions,
684
- onChange: handleChange,
685
- placeholder: "Search...",
686
- chakraStyles: searchBarStyles(sx),
687
- isMulti,
688
- useBasicStyles: true,
689
- selectedOptionStyle: "check",
690
- hideSelectedOptions: false,
691
- closeMenuOnSelect,
692
- isClearable: false,
693
- onInputChange: resetFiltered,
694
- inputValue: filterInput,
695
- customOption,
696
- customTag,
697
- icon,
698
- components: customComponents,
699
- ref,
700
- value,
701
- ...rest
702
- }
703
- ));
704
- }
705
- );
706
-
707
- const Tag$1 = forwardRef$1(({
708
- children,
709
- variant = "solid",
710
- bgColor,
711
- colorScheme,
712
- ...rest
713
- }, ref) => /* @__PURE__ */ React.createElement(
714
- Tag$2,
715
- {
716
- bgColor,
717
- colorScheme,
718
- ref,
719
- variant,
720
- ...rest
721
- },
722
- children
723
- ));
724
-
725
- forwardRef$1(
726
- ({
727
- size = "md",
728
- isDragging,
729
- itemLabel = "Drag Me",
730
- bgColor,
731
- ...rest
732
- }, ref) => /* @__PURE__ */ React.createElement(
733
- Tag$1,
734
- {
735
- ref,
736
- cursor: isDragging ? "grabbing" : "grab",
737
- bgColor: bgColor || (isDragging ? "blue.200" : void 0),
738
- size,
739
- minW: "max-content",
740
- ...rest
741
- },
742
- /* @__PURE__ */ React.createElement(TagLabel, null, itemLabel),
743
- /* @__PURE__ */ React.createElement(TagRightIcon, null, /* @__PURE__ */ React.createElement(Icon$1, { as: DotsMatrixSolid }))
744
- )
745
- );
746
-
747
- forwardRef$1(({
748
- itemCount,
749
- itemSize,
750
- direction = "column",
751
- children,
752
- width,
753
- height,
754
- overscanCount = 0,
755
- initialScrollOffset,
756
- ...rest
757
- }, ref) => /* @__PURE__ */ React.createElement(AutoSizer, null, ({ width: autoWidth, height: autoHeight }) => /* @__PURE__ */ React.createElement(
758
- VariableSizeList,
759
- {
760
- itemCount,
761
- itemSize: typeof itemSize === "number" ? (_index) => itemSize : itemSize,
762
- height: height ?? autoHeight,
763
- width: width ?? autoWidth,
764
- layout: direction === "column" ? "vertical" : "horizontal",
765
- initialScrollOffset,
766
- overscanCount,
767
- ref,
768
- ...rest
769
- },
770
- ({ style, index }) => /* @__PURE__ */ React.createElement("div", { style }, typeof children === "function" ? children(index) : children)
771
- )));
772
-
773
- forwardRef$1(({
774
- columns,
775
- rows,
776
- columnSize,
777
- rowSize,
778
- children,
779
- width,
780
- height,
781
- overscanRowCount = 0,
782
- overscanColumnCount = 0,
783
- ...rest
784
- }, ref) => /* @__PURE__ */ React.createElement(AutoSizer, null, ({ width: autoWidth, height: autoHeight }) => /* @__PURE__ */ React.createElement(
785
- VariableSizeGrid,
786
- {
787
- rowCount: rows,
788
- columnCount: columns,
789
- columnWidth: typeof columnSize === "number" ? (_index) => columnSize : columnSize,
790
- rowHeight: typeof rowSize === "number" ? (_index) => rowSize : rowSize,
791
- height: height ?? autoHeight,
792
- width: width ?? autoWidth,
793
- overscanRowCount,
794
- overscanColumnCount,
795
- ref,
796
- ...rest
797
- },
798
- ({ style, rowIndex, columnIndex }) => /* @__PURE__ */ React.createElement("div", { style }, typeof children === "function" ? children(rowIndex, columnIndex) : children)
799
- )));
800
-
801
- const EditableControls = ({ size }) => {
802
- const {
803
- getSubmitButtonProps,
804
- getCancelButtonProps
805
- } = useEditableControls();
806
- const { onEdit, isEditing } = useEditableState();
807
- const { button, icon, controls } = useMultiStyleConfig("EditableText", { size, isEditing });
808
- return /* @__PURE__ */ React.createElement(HStack, { spacing: 1, sx: controls }, isEditing ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
809
- IconButton,
810
- {
811
- "aria-label": "Cancel",
812
- sx: button,
813
- variant: "danger",
814
- ...getCancelButtonProps()
815
- },
816
- /* @__PURE__ */ React.createElement(Icon$1, { sx: icon, as: XCloseSolid })
817
- ), /* @__PURE__ */ React.createElement(
818
- IconButton,
819
- {
820
- "aria-label": "Save",
821
- sx: button,
822
- variant: "success",
823
- ...getSubmitButtonProps()
824
- },
825
- /* @__PURE__ */ React.createElement(Icon$1, { sx: icon, as: CheckDuo })
826
- )) : /* @__PURE__ */ React.createElement(
827
- IconButton,
828
- {
829
- "aria-label": "Edit",
830
- variant: "ghost",
831
- sx: button,
832
- onClick: onEdit
833
- },
834
- /* @__PURE__ */ React.createElement(Icon$1, { sx: icon, as: EditDuo })
835
- ));
836
- };
837
-
838
- const EditableText$1 = ({
839
- size = "md",
840
- value: inputValue,
841
- onSubmit,
842
- leftItem,
843
- ...rest
844
- }) => {
845
- const [value, setValue] = useState(inputValue);
846
- const { input, preview } = useMultiStyleConfig("EditableText", { size });
847
- useEffect(() => {
848
- setValue(inputValue);
849
- }, [inputValue]);
850
- return /* @__PURE__ */ React.createElement(
851
- Editable,
852
- {
853
- isPreviewFocusable: true,
854
- selectAllOnFocus: false,
855
- value,
856
- onChange: (newValue) => setValue(newValue),
857
- onSubmit,
858
- ...rest
859
- },
860
- /* @__PURE__ */ React.createElement(InputGroup, { size }, leftItem && /* @__PURE__ */ React.createElement(InputLeftElement, null, leftItem), /* @__PURE__ */ React.createElement(
861
- Input$1,
862
- {
863
- as: EditablePreview,
864
- sx: preview
865
- }
866
- ), /* @__PURE__ */ React.createElement(
867
- Input$1,
868
- {
869
- as: EditableInput,
870
- size,
871
- sx: input
872
- }
873
- ), /* @__PURE__ */ React.createElement(InputRightElement, { sx: { width: "min-content" } }, /* @__PURE__ */ React.createElement(EditableControls, { size })))
874
- );
875
- };
876
-
877
- const Modal$1 = ({
878
- isCentered = true,
879
- children,
880
- ...rest
881
- }) => /* @__PURE__ */ React.createElement(
882
- Modal$2,
883
- {
884
- isCentered,
885
- scrollBehavior: "inside",
886
- motionPreset: "slideInBottom",
887
- ...rest
888
- },
889
- /* @__PURE__ */ React.createElement(ModalOverlay, null),
890
- /* @__PURE__ */ React.createElement(ModalContent, { "data-testid": "modal-test-id" }, /* @__PURE__ */ React.createElement(ModalCloseButton, { "data-testid": "modal-test-button-id" }), children)
891
- );
892
-
893
- forwardRef$1(({
894
- fileName,
895
- setFileName,
896
- isOpen,
897
- onClose,
898
- image = "",
899
- handleCrop,
900
- isImage,
901
- canEditFileName = true,
902
- canCropImage = false,
903
- ...rest
904
- }, ref) => {
905
- const [zoomLevel, setZoomLevel] = useState(1);
906
- const [position, setPosition] = useState({ x: 0.5, y: 0.5 });
907
- const handleClose = () => {
908
- setZoomLevel(1);
909
- onClose();
910
- };
911
- return /* @__PURE__ */ React.createElement(
912
- Modal$1,
913
- {
914
- isOpen,
915
- onClose,
916
- closeOnOverlayClick: false,
917
- ...rest
918
- },
919
- /* @__PURE__ */ React.createElement(ModalHeader, null, "Edit ", isImage ? "image" : "file"),
920
- /* @__PURE__ */ React.createElement(
921
- ModalBody,
922
- {
923
- display: "flex",
924
- justifyContent: "start",
925
- flexDirection: "column",
926
- alignItems: "center",
927
- gap: 4,
928
- minH: "300px"
929
- },
930
- /* @__PURE__ */ React.createElement(Stack, { display: isImage && canCropImage ? "inherit" : "none" }, /* @__PURE__ */ React.createElement(
931
- AvatarEditor,
932
- {
933
- ref,
934
- image: image || "",
935
- onPositionChange: (pos) => setPosition(pos),
936
- position,
937
- width: 250,
938
- height: 250,
939
- border: 50,
940
- color: [255, 255, 255, 0.7],
941
- scale: zoomLevel,
942
- rotate: 0
943
- }
944
- ), /* @__PURE__ */ React.createElement(HStack, { w: "90%" }, /* @__PURE__ */ React.createElement(FormLabel, null, "Zoom"), /* @__PURE__ */ React.createElement(
945
- Slider,
946
- {
947
- "aria-label": "zoom",
948
- defaultValue: zoomLevel,
949
- maxW: "50%",
950
- min: 0.1,
951
- step: 0.05,
952
- max: 10,
953
- onChange: (value) => setZoomLevel(value)
954
- },
955
- /* @__PURE__ */ React.createElement(SliderTrack, null, /* @__PURE__ */ React.createElement(SliderFilledTrack, null)),
956
- /* @__PURE__ */ React.createElement(SliderThumb, { boxSize: 6 }, /* @__PURE__ */ React.createElement(Icon$1, { as: ZoomInDuo }))
957
- ))),
958
- canEditFileName && /* @__PURE__ */ React.createElement(Stack, { w: "90%", direction: isImage ? "row" : "column", pt: 2 }, /* @__PURE__ */ React.createElement(FormLabel, null, "Name the file:"), /* @__PURE__ */ React.createElement(Box, { maxW: "50%" }, /* @__PURE__ */ React.createElement(EditableText$1, { onSubmit: (v) => setFileName(v), value: fileName, size: "sm" })))
959
- ),
960
- /* @__PURE__ */ React.createElement(ModalFooter, null, /* @__PURE__ */ React.createElement(HStack, null, /* @__PURE__ */ React.createElement(Button$1, { variant: "danger", onClick: handleClose }, "Cancel"), /* @__PURE__ */ React.createElement(Button$1, { variant: "success", onClick: handleCrop }, "Save")))
961
- );
962
- });
963
-
964
- const scrollbarStyles = {
965
- "::-webkit-scrollbar": {
966
- width: "8px",
967
- height: "8px"
968
- },
969
- "::-webkit-scrollbar-track": {
970
- background: "background.scrollbar.track"
971
- },
972
- "::-webkit-scrollbar-thumb": {
973
- borderRadius: "scrollbar.thumb",
974
- border: "2px solid",
975
- borderColor: "border.scrollbar.thumb",
976
- backgroundClip: "padding-box !important",
977
- background: "background.scrollbar.thumb"
978
- },
979
- "::-webkit-scrollbar-thumb:hover": {
980
- borderRadius: "scrollbar.thumb",
981
- border: "1px solid ",
982
- borderColor: "border.scrollbar.thumb",
983
- backgroundClip: "padding-box !important",
984
- background: "background.scrollbar.thumb"
985
- }
986
- };
987
-
988
- const Breadcrumb = {
989
- parts: ["link", "separator"],
990
- baseStyle: {
991
- link: {
992
- padding: [0.5, 1],
993
- color: "primary",
994
- fontWeight: "600",
995
- fontSize: "semibold",
996
- _hover: {
997
- bg: "blue.50",
998
- borderRadius: "base",
999
- textDecor: "none"
1000
- }
1001
- },
1002
- separator: {
1003
- color: "gray.300",
1004
- fontSize: "semibold"
1005
- }
1006
- }
1007
- };
1008
-
1009
- const Button = {
1010
- sizes: {
1011
- xs: ({ theme: { sizes: sizing, space: spacing } }) => ({
1012
- height: sizing.button.xs,
1013
- minWidth: sizing.button.xs,
1014
- paddingInlineStart: spacing["padding-inline"].button.xs,
1015
- paddingInlineEnd: spacing["padding-inline"].button.xs
1016
- }),
1017
- sm: ({ theme: { sizes: sizing, space: spacing } }) => ({
1018
- height: sizing.button.sm,
1019
- minWidth: sizing.button.sm,
1020
- paddingInlineStart: spacing["padding-inline"].button.md,
1021
- paddingInlineEnd: spacing["padding-inline"].button.md
1022
- }),
1023
- md: ({ theme: { sizes: sizing, space: spacing } }) => ({
1024
- height: sizing.button.md,
1025
- minWidth: sizing.button.md,
1026
- paddingInlineStart: spacing["padding-inline"].button.md,
1027
- paddingInlineEnd: spacing["padding-inline"].button.md
1028
- }),
1029
- lg: ({ theme: { sizes: sizing, space: spacing } }) => ({
1030
- height: sizing.button.lg,
1031
- minWidth: sizing.button.lg,
1032
- paddingInlineStart: spacing["padding-inline"].button.lg,
1033
- paddingInlineEnd: spacing["padding-inline"].button.lg
1034
- })
1035
- },
1036
- baseStyle: ({ theme: { colors: color, radii: borderRadius } }) => ({
1037
- color: color.text.default,
1038
- borderRadius: borderRadius.button.default,
1039
- _focusVisible: {
1040
- ring: "2px",
1041
- ringColor: color.border.wcag,
1042
- ringOffset: "1px"
1043
- }
1044
- }),
1045
- variants: {
1046
- default: ({ theme: { colors: color } }) => ({
1047
- bgColor: color.background.button.default,
1048
- _hover: {
1049
- bgColor: color.background.button["default-hover"]
1050
- },
1051
- _active: {
1052
- bgColor: color.background.button["default-active"]
1053
- }
1054
- }),
1055
- danger: ({ theme: { colors: color } }) => ({
1056
- bgColor: color.background.button.danger,
1057
- color: color.text.button.danger,
1058
- _hover: {
1059
- bg: color.background.button["danger-hover"],
1060
- _disabled: {
1061
- bgColor: color.background.button.danger
1062
- }
1063
- },
1064
- _active: {
1065
- bgColor: color.background.button["danger-active"]
1066
- }
1067
- }),
1068
- success: ({ theme: { colors: color } }) => ({
1069
- bgColor: color.background.button.success,
1070
- _hover: {
1071
- bg: color.background.button["success-hover"],
1072
- _disabled: {
1073
- bgColor: color.background.button.success
1074
- }
1075
- },
1076
- _active: {
1077
- bgColor: color.background.button["success-active"]
1078
- }
1079
- }),
1080
- brand: ({ theme: { colors: color } }) => ({
1081
- color: color.text.inverted,
1082
- bgColor: color.background.button.brand,
1083
- _hover: {
1084
- bg: color.background.button["brand-hover"],
1085
- _disabled: {
1086
- bgColor: color.background.button.brand
1087
- }
1088
- },
1089
- _active: {
1090
- bgColor: color.background.button["brand-active"]
1091
- }
1092
- }),
1093
- link: ({ theme: { colors: color } }) => ({
1094
- textDecoration: "underline",
1095
- color: color.text.button.link,
1096
- bgColor: color.background.button.link,
1097
- _hover: {
1098
- color: color.text.button["link-hover"],
1099
- bgColor: color.background.button["link-hover"]
1100
- },
1101
- _active: {
1102
- color: color.text.button["link-hover"],
1103
- bgColor: color.background.button["link-active"]
1104
- }
1105
- }),
1106
- ghost: ({ theme: { colors: color } }) => ({
1107
- color: color.text.default,
1108
- bgColor: color.background.button.ghost,
1109
- _hover: {
1110
- bg: color.background.button["ghost-hover"],
1111
- _disabled: {
1112
- bgColor: color.background.button.ghost
1113
- }
1114
- },
1115
- _active: {
1116
- bgColor: color.background.button["ghost-active"]
1117
- }
1118
- })
1119
- },
1120
- defaultProps: {
1121
- size: "md"
1122
- }
1123
- };
1124
-
1125
- const pulseRing = keyframes`
1126
- 0% {
1127
- transform: scale(0.33);
1128
- }
1129
- 30% {
1130
- transform: scale(0.66);
1131
- },
1132
- 40%,
1133
- 50% {
1134
- opacity: 0;
1135
- }
1136
- 100% {
1137
- opacity: 0;
1138
- }
1139
- `;
1140
- const Blinker = {
1141
- baseStyle: ({ theme: { colors: palette }, color, isBlinking }) => ({
1142
- position: "relative",
1143
- borderRadius: "50%",
1144
- bgColor: color === "" ? palette.blue["500"] : color,
1145
- _before: isBlinking ? {
1146
- content: "''",
1147
- position: "absolute",
1148
- display: "block",
1149
- width: "300%",
1150
- height: "300%",
1151
- marginLeft: "-100%",
1152
- marginTop: "-100%",
1153
- borderRadius: "50%",
1154
- bgColor: color === "" ? "blue.500" : color,
1155
- animation: `2.25s ${pulseRing} cubic-bezier(0.455, 0.03, 0.515, 0.955) -0.4s infinite`,
1156
- zIndex: "base"
1157
- } : {}
1158
- }),
1159
- sizes: {
1160
- "2xs": ({ theme: { sizes: sizing } }) => ({
1161
- height: sizing.blinker["2xs"],
1162
- width: sizing.blinker["2xs"]
1163
- }),
1164
- xs: ({ theme: { sizes: sizing } }) => ({
1165
- height: sizing.blinker.xs,
1166
- width: sizing.blinker.xs
1167
- }),
1168
- sm: ({ theme: { sizes: sizing } }) => ({
1169
- height: sizing.blinker.sm,
1170
- width: sizing.blinker.sm
1171
- }),
1172
- md: ({ theme: { sizes: sizing } }) => ({
1173
- height: sizing.blinker.md,
1174
- width: sizing.blinker.md
1175
- }),
1176
- lg: ({ theme: { sizes: sizing } }) => ({
1177
- height: sizing.blinker.lg,
1178
- width: sizing.blinker.lg
1179
- })
1180
- },
1181
- defaultProps: {
1182
- size: "md",
1183
- color: "blue.500"
1184
- }
1185
- };
1186
-
1187
- const Checkbox = {
1188
- parts: ["control", "label"],
1189
- sizes: {
1190
- sm: {
1191
- control: {
1192
- fontSize: 5
1193
- }
1194
- },
1195
- md: {
1196
- control: {
1197
- fontSize: 7
1198
- }
1199
- },
1200
- lg: {
1201
- control: {
1202
- fontSize: 8
1203
- }
1204
- }
1205
- },
1206
- baseStyle: ({ theme: { colors: color, opacity } }) => ({
1207
- control: {
1208
- borderColor: color.border.checkbox.default,
1209
- bg: color.background.checkbox.default,
1210
- borderWidth: 2,
1211
- _checked: {
1212
- borderColor: color.border.checkbox.checked,
1213
- bg: color.background.checkbox.checked,
1214
- _hover: {
1215
- borderColor: color.border.checkbox.checked,
1216
- bg: color.background.checkbox.checked
1217
- }
1218
- },
1219
- _invalid: {
1220
- borderColor: color.border.checkbox.error,
1221
- bg: color.background.checkbox.default,
1222
- _checked: {
1223
- bg: color.background.checkbox.error
1224
- },
1225
- _hover: {
1226
- borderColor: color.border.checkbox.error,
1227
- bg: color.background.checkbox.default
1228
- }
1229
- },
1230
- _focusVisible: {
1231
- ring: "2px",
1232
- ringColor: color.border.wcag,
1233
- ringOffset: "1px"
1234
- },
1235
- _hover: {
1236
- borderColor: color.border.checkbox["default-hover"],
1237
- bg: color.background.checkbox.default
1238
- },
1239
- _disabled: {
1240
- borderColor: color.border.checkbox.disabled,
1241
- bg: color.background.checkbox.disabled,
1242
- opacity: opacity.checkbox.disabled,
1243
- _checked: {
1244
- borderColor: color.border.checkbox.checked,
1245
- bg: color.background.checkbox.checked,
1246
- opacity: opacity.checkbox.disabled,
1247
- color: "white",
1248
- _hover: {
1249
- borderColor: color.border.checkbox.checked,
1250
- bg: color.background.checkbox.checked,
1251
- opacity: opacity.checkbox.disabled
1252
- }
1253
- },
1254
- _hover: {
1255
- borderColor: color.border.checkbox.disabled,
1256
- bg: color.background.checkbox.disabled,
1257
- opacity: opacity.checkbox.disabled
1258
- }
1259
- }
1260
- }
1261
- }),
1262
- variants: {
1263
- default: ({ theme: { radii: borderRadius } }) => ({
1264
- control: {
1265
- borderRadius: borderRadius.checkbox.default
1266
- }
1267
- }),
1268
- rounded: ({ theme: { radii: borderRadius } }) => ({
1269
- control: {
1270
- borderRadius: borderRadius.checkbox.full
1271
- }
1272
- })
1273
- }
1274
- };
1275
-
1276
- const Input = {
1277
- parts: ["field", "addon"],
1278
- baseStyle: ({ theme: { colors: color } }) => ({
1279
- field: {
1280
- color: color.text.default,
1281
- _placeholder: {
1282
- color: color.text.input.placeholder,
1283
- opacity: 1
1284
- }
1285
- }
1286
- }),
1287
- variants: {
1288
- outline: ({ theme: {
1289
- colors: color,
1290
- space: spacing,
1291
- radii: borderRadius,
1292
- borders: borderWidth,
1293
- opacity
1294
- } }) => ({
1295
- field: {
1296
- paddingInlineStart: spacing["padding-inline"].input.default,
1297
- paddingInlineEnd: spacing["padding-inline"].input.default,
1298
- bgColor: color.background.input["outline-default"],
1299
- borderRadius: borderRadius.input.outline,
1300
- borderWidth: borderWidth.input.default,
1301
- borderColor: color.border.input.default,
1302
- _readOnly: {
1303
- _focusVisible: {
1304
- borderColor: color.border.input.readonly
1305
- },
1306
- _hover: {
1307
- borderColor: color.border.input.readonly
1308
- }
1309
- },
1310
- _focusVisible: {
1311
- bgColor: color.background.input["outline-focus"],
1312
- borderColor: color.border.input.focus,
1313
- _invalid: {
1314
- boxShadow: `0 0 0 1px ${color.border.input.error}`,
1315
- bgColor: color.background.input["outline-error"],
1316
- borderColor: color.border.input.error
1317
- }
1318
- },
1319
- _hover: {
1320
- bgColor: color.background.input["outline-hover"],
1321
- borderColor: color.border.input["default-hover"]
1322
- },
1323
- _invalid: {
1324
- bgColor: color.background.input["outline-error"],
1325
- borderColor: color.border.input.error
1326
- },
1327
- _disabled: {
1328
- bgColor: color.background.input["outline-disabled"],
1329
- borderColor: color.border.input.disabled,
1330
- opacity: opacity.input.disabled
1331
- }
1332
- },
1333
- addon: {
1334
- border: "none",
1335
- background: "none",
1336
- color: color.text.default
1337
- }
1338
- }),
1339
- filled: ({ theme: {
1340
- colors: color,
1341
- space: spacing,
1342
- radii: borderRadius,
1343
- borders: borderWidth,
1344
- opacity
1345
- } }) => ({
1346
- field: {
1347
- paddingInlineStart: spacing["padding-inline"].input.default,
1348
- paddingInlineEnd: spacing["padding-inline"].input.default,
1349
- borderRadius: borderRadius.input.filled,
1350
- borderWidth: borderWidth.input.default,
1351
- bgColor: color.background.input["filled-default"],
1352
- _readOnly: {
1353
- _focusVisible: {
1354
- borderColor: color.border.input.readonly
1355
- },
1356
- _hover: {
1357
- bgColor: color.background.input["filled-default"]
1358
- }
1359
- },
1360
- _hover: {
1361
- bgColor: color.background.input["filled-hover"]
1362
- },
1363
- _focusVisible: {
1364
- boxShadow: `0 0 0 1px ${color.border.input.focus}`,
1365
- borderColor: color.border.input.focus,
1366
- bgColor: color.background.input["filled-focus"],
1367
- _readOnly: {
1368
- bgColor: color.background.input["filled-default"]
1369
- },
1370
- _invalid: {
1371
- boxShadow: `0 0 0 1px ${color.border.input.error}`,
1372
- bgColor: color.background.input["outline-error"],
1373
- borderColor: color.border.input.error
1374
- }
1375
- },
1376
- _invalid: {
1377
- boxShadow: `0 0 0 1px ${color.border.input.error}`,
1378
- bgColor: color.background.input["filled-error"],
1379
- borderColor: color.border.input.error
1380
- },
1381
- _disabled: {
1382
- bgColor: color.background.input["filled-disabled"],
1383
- borderColor: color.border.input.disabled,
1384
- opacity: opacity.input.disabled
1385
- }
1386
- }
1387
- }),
1388
- flushed: ({ theme: {
1389
- colors: color,
1390
- space: spacing,
1391
- radii: borderRadius,
1392
- borders: borderWidth,
1393
- opacity
1394
- } }) => ({
1395
- field: {
1396
- paddingInlineStart: spacing["padding-inline"].input.flushed,
1397
- paddingInlineEnd: spacing["padding-inline"].input.flushed,
1398
- bgColor: color.background.input["flushed-default"],
1399
- borderRadius: borderRadius.input.flushed,
1400
- borderBottomWidth: borderWidth.input.default,
1401
- borderBottomColor: color.border.input.default,
1402
- _readOnly: {
1403
- _focusVisible: {
1404
- borderColor: color.border.input.readonly
1405
- },
1406
- _hover: {
1407
- borderColor: color.border.input.readonly
1408
- }
1409
- },
1410
- _hover: {
1411
- bgColor: color.background.input["flushed-hover"],
1412
- borderColor: color.border.input["default-hover"]
1413
- },
1414
- _focusVisible: {
1415
- _hover: {
1416
- boxShadow: `0 1px 0 0 ${color.border.input.focus}`,
1417
- borderColor: color.border.input.focus
1418
- },
1419
- _invalid: {
1420
- boxShadow: `0 1px 0 0 ${color.border.input.error}`,
1421
- borderColor: color.border.input.error,
1422
- bgColor: color.background.input["flushed-error"]
1423
- }
1424
- },
1425
- _invalid: {
1426
- _hover: {
1427
- boxShadow: `0 1px 0 0 ${color.border.input.error}`,
1428
- borderColor: color.border.input.error
1429
- },
1430
- bgColor: color.background.input["flushed-error"]
1431
- },
1432
- _disabled: {
1433
- bgColor: color.background.input["flushed-disabled"],
1434
- borderColor: color.border.input.disabled,
1435
- opacity: opacity.input.disabled
1436
- }
1437
- }
1438
- })
1439
- }
1440
- };
1441
-
1442
- const PinInput = {
1443
- variants: {
1444
- outline: ({ theme: {
1445
- radii: borderRadius,
1446
- borders: borderWidth,
1447
- colors: color,
1448
- space: spacing,
1449
- opacity
1450
- } }) => ({
1451
- borderColor: color.border.input.default,
1452
- borderRadius: borderRadius.input.outline,
1453
- borderWidth: borderWidth.input.default,
1454
- bg: color.background.input["outline-default"],
1455
- color: color.text.default,
1456
- paddingInline: spacing["padding-inline"].input.default,
1457
- _hover: {
1458
- bg: color.background.input["outline-hover"],
1459
- borderColor: color.border.input["default-hover"]
1460
- },
1461
- _focus: {
1462
- borderColor: color.border.input.focus,
1463
- bg: color.background.input["outline-focus"]
1464
- },
1465
- _invalid: {
1466
- bg: color.background.input["outline-error"],
1467
- borderColor: color.border.input.error,
1468
- _placeholder: {
1469
- color: "transparent"
1470
- }
1471
- },
1472
- _disabled: {
1473
- bg: color.background.input["outline-disabled"],
1474
- borderColor: color.border.input.disabled,
1475
- opacity: opacity.input.disabled,
1476
- _hover: {
1477
- bg: color.background.input["outline-disabled"],
1478
- borderColor: color.border.input.disabled
1479
- }
1480
- },
1481
- _placeholder: {
1482
- color: color.text.input.placeholder
1483
- },
1484
- _readonly: {
1485
- borderColor: color.border.input.readonly
1486
- }
1487
- })
1488
- }
1489
- };
1490
-
1491
- const Select = {
1492
- parts: ["field", "icon"],
1493
- variants: {
1494
- outline: ({ theme: {
1495
- radii: borderRadius,
1496
- borders: borderWidth,
1497
- colors: color,
1498
- space: spacing
1499
- } }) => ({
1500
- field: {
1501
- paddingInlineStart: spacing["padding-inline"].select.default,
1502
- paddingInlineEnd: spacing["padding-inline"].select.default,
1503
- borderWidth: borderWidth.select,
1504
- color: color.text.default,
1505
- borderColor: color.border.select.default,
1506
- borderRadius: borderRadius.select.default,
1507
- _hover: {
1508
- borderColor: color.border.select["default-hover"]
1509
- },
1510
- _focusVisible: {
1511
- borderColor: color.border.select.focus,
1512
- boxShadow: `0 0 0 1px ${color.border.select.focus}`
1513
- },
1514
- _invalid: {
1515
- borderColor: color.border.select.error,
1516
- boxShadow: "none"
1517
- },
1518
- _readOnly: {
1519
- borderWidth: borderWidth.select,
1520
- borderColor: color.border.select.readonly,
1521
- _focusVisible: {
1522
- borderColor: color.border.select.readonly
1523
- }
1524
- },
1525
- _disabled: {
1526
- borderColor: color.border.select.disabled,
1527
- bg: color.background.select.disabled,
1528
- _hover: {
1529
- borderColor: color.border.select.disabled
1530
- }
1531
- },
1532
- _placeholder: {
1533
- color: color.text.select.placeholder
1534
- }
1535
- },
1536
- icon: {
1537
- color: color.icon.select.default
1538
- }
1539
- })
1540
- }
1541
- };
1542
-
1543
- const Radio = {
1544
- parts: ["control", "label", "container"],
1545
- sizes: {
1546
- sm: ({ theme: { borders: borderWidth } }) => ({
1547
- control: {
1548
- _checked: {
1549
- borderWidth: borderWidth.radio["checked-sm"]
1550
- }
1551
- }
1552
- }),
1553
- md: ({ theme: { borders: borderWidth } }) => ({
1554
- control: {
1555
- _checked: {
1556
- borderWidth: borderWidth.radio["checked-md"]
1557
- }
1558
- }
1559
- }),
1560
- lg: ({ theme: { borders: borderWidth } }) => ({
1561
- control: {
1562
- _checked: {
1563
- borderWidth: borderWidth.radio["checked-lg"]
1564
- }
1565
- }
1566
- })
1567
- },
1568
- baseStyle: ({ theme: { borders: borderWidth, colors: color } }) => ({
1569
- control: {
1570
- borderColor: color.border.radio.default,
1571
- bg: color.background.radio.default,
1572
- borderWidth: borderWidth.radio.default,
1573
- _checked: {
1574
- borderColor: color.border.radio.checked,
1575
- bg: color.background.radio.checked,
1576
- _hover: {
1577
- borderColor: color.border.radio.checked,
1578
- bg: color.background.radio.checked
1579
- }
1580
- },
1581
- _hover: {
1582
- borderColor: color.border.radio["default-hover"],
1583
- bg: color.background.radio.default
1584
- },
1585
- _disabled: {
1586
- borderColor: color.border.radio.disabled,
1587
- bg: color.background.radio.disabled,
1588
- _hover: {
1589
- borderColor: color.border.radio.disabled,
1590
- bg: color.background.radio.disabled
1591
- }
1592
- },
1593
- _invalid: {
1594
- borderColor: color.border.radio.error,
1595
- bg: color.background.radio.error,
1596
- borderWidth: borderWidth.radio.default,
1597
- _hover: {
1598
- borderColor: color.border.radio.error,
1599
- bg: color.background.radio.error,
1600
- borderWidth: borderWidth.radio.default
1601
- }
1602
- },
1603
- _focusVisible: {
1604
- ring: "2px",
1605
- ringColor: color.border.wcag,
1606
- ringOffset: "1px"
1607
- }
1608
- },
1609
- defaultProps: {
1610
- size: "md"
1611
- }
1612
- })
1613
- };
1614
-
1615
- const Tabs = {
1616
- parts: ["tab"],
1617
- variants: {
1618
- "soft-rounded": ({ theme: { colors: color } }) => ({
1619
- tab: {
1620
- borderRadius: 999,
1621
- color: color.text.subdued,
1622
- _selected: {
1623
- bg: color.background.tabs["soft-rounded-active"],
1624
- color: color.text.tabs["soft-rounded-active"]
1625
- },
1626
- _focusVisible: {
1627
- ring: "2px",
1628
- ringColor: color.border.wcag,
1629
- ringOffset: "1px"
1630
- }
1631
- }
1632
- })
1633
- }
1634
- };
1635
-
1636
- const Textarea = {
1637
- variants: {
1638
- outline: ({ theme: {
1639
- space: spacing,
1640
- colors: color,
1641
- borders: borderWidth,
1642
- radii: borderRadius
1643
- } }) => ({
1644
- paddingInlineStart: spacing["padding-inline"].textarea.default,
1645
- paddingInlineEnd: spacing["padding-inline"].textarea.default,
1646
- borderRadius: borderRadius.textarea.default,
1647
- borderWidth: borderWidth.textarea.default,
1648
- borderColor: color.border.textarea.default,
1649
- color: color.text.default,
1650
- bgColor: color.background.textarea.default,
1651
- _hover: {
1652
- borderColor: color.border.textarea["default-hover"],
1653
- bgColor: color.background.textarea.hover
1654
- },
1655
- _focusVisible: {
1656
- borderColor: color.border.textarea.focus,
1657
- boxShadow: `0 0 0 1px ${color.border.textarea.focus}`,
1658
- bgColor: color.background.textarea.active
1659
- },
1660
- _invalid: {
1661
- boxShadow: "none",
1662
- borderColor: color.border.textarea.error,
1663
- bgColor: color.background.textarea.error
1664
- },
1665
- _readOnly: {
1666
- _focusVisible: {
1667
- borderColor: color.border.textarea.readonly,
1668
- bgColor: color.background.textarea.default
1669
- },
1670
- _hover: {
1671
- borderColor: color.border.textarea.readonly
1672
- }
1673
- },
1674
- _disabled: {
1675
- bgColor: color.background.textarea.disabled,
1676
- _hover: {
1677
- borderColor: color.border.textarea.default
1678
- }
1679
- },
1680
- _placeholder: {
1681
- color: color.text.textarea.placeholder
1682
- }
1683
- })
1684
- }
1685
- };
1686
-
1687
- const Link = {
1688
- baseStyle: ({ colorScheme }) => ({
1689
- _focus: {
1690
- ring: "2px",
1691
- ringColor: `${colorScheme}.100`,
1692
- ringOffset: "1px"
1693
- }
1694
- }),
1695
- defaultProps: {
1696
- colorScheme: "mediatoolBlue"
1697
- }
1698
- };
1699
-
1700
- const Switch$1 = {
1701
- baseStyle: ({ theme: { colors: color, opacity } }) => ({
1702
- _disabled: {
1703
- opacity: opacity.switch.disabled
1704
- },
1705
- track: {
1706
- bgColor: color.background.switch.default,
1707
- _checked: {
1708
- bgColor: color.background.switch["default-checked"]
1709
- },
1710
- _focusVisible: {
1711
- ring: "2px",
1712
- ringColor: color.border.wcag,
1713
- ringOffset: "1px"
1714
- }
1715
- },
1716
- thumb: {
1717
- bgColor: color.background.switch.thumb
1718
- }
1719
- })
1720
- };
1721
-
1722
- const Tag = {
1723
- parts: ["container"],
1724
- baseStyle: {
1725
- container: {
1726
- fontWeight: "semibold"
1727
- }
1728
- },
1729
- sizes: {
1730
- sm: {
1731
- container: {
1732
- borderRadius: "tag.default"
1733
- }
1734
- },
1735
- md: {
1736
- container: {
1737
- borderRadius: "tag.default"
1738
- }
1739
- },
1740
- lg: {
1741
- container: {
1742
- borderRadius: "tag.default"
1743
- }
1744
- }
1745
- },
1746
- variants: {
1747
- solid: ({ bgColor, colorScheme }) => ({
1748
- container: {
1749
- bgColor: bgColor ?? colorScheme,
1750
- color: getContrastColor(bgColor ?? useToken$1("colors", colorScheme))
1751
- }
1752
- }),
1753
- subtle: () => ({
1754
- container: {
1755
- bgColor: useToken$1("colors", "background.tag.subtle"),
1756
- color: "text.default"
1757
- }
1758
- })
1759
- },
1760
- defaultProps: {
1761
- size: "md",
1762
- colorScheme: "background.tag.default"
1763
- }
1764
- };
1765
-
1766
- const Alert = {
1767
- parts: ["container", "title", "description"],
1768
- baseStyle: ({ theme: {
1769
- radii: borderRadius,
1770
- colors: color,
1771
- space: coreSpacing
1772
- } }) => ({
1773
- container: {
1774
- borderRadius: borderRadius.toast.default,
1775
- color: color.text.default,
1776
- paddingEnd: coreSpacing[8],
1777
- width: "auto",
1778
- display: "flex"
1779
- }
1780
- }),
1781
- variants: {
1782
- success: ({ theme: { colors: color } }) => ({
1783
- container: {
1784
- bgColor: color.background.toast.success
1785
- }
1786
- }),
1787
- warning: ({ theme: { colors: color } }) => ({
1788
- container: {
1789
- bgColor: color.background.toast.warning
1790
- }
1791
- }),
1792
- info: ({ theme: { colors: color } }) => ({
1793
- container: {
1794
- bgColor: color.background.toast.info
1795
- }
1796
- }),
1797
- error: ({ theme: { colors: color } }) => ({
1798
- container: {
1799
- bgColor: color.background.toast.error,
1800
- color: color.text.toast.error
1801
- }
1802
- })
1803
- }
1804
- };
1805
-
1806
- const NumberInput = {
1807
- parts: ["root", "field", "stepper", "stepperGroup"],
1808
- sizes: {
1809
- sm: ({ theme: { radii: borderRadius, sizes: sizing } }) => ({
1810
- field: {
1811
- borderRadius: borderRadius.input.outline
1812
- },
1813
- stepperGroup: {
1814
- height: sizing["8"]
1815
- }
1816
- }),
1817
- md: ({ theme: { sizes: sizing } }) => ({
1818
- stepperGroup: {
1819
- height: sizing["10"]
1820
- }
1821
- }),
1822
- lg: ({ theme: { sizes: sizing } }) => ({
1823
- stepperGroup: {
1824
- height: sizing["12"]
1825
- }
1826
- })
1827
- },
1828
- baseStyle: ({ theme: {
1829
- sizes: sizing,
1830
- space: spacing,
1831
- colors: color,
1832
- radii: borderRadius,
1833
- borders: borderWidth,
1834
- opacity
1835
- }, isReadOnly }) => ({
1836
- root: {
1837
- borderRadius: borderRadius.input.outline
1838
- },
1839
- field: {
1840
- minWidth: sizing["44"],
1841
- paddingInlineStart: spacing["padding-inline"].input.default,
1842
- paddingInlineEnd: spacing["padding-inline"].input.default,
1843
- WebkitPaddingStart: spacing["padding-inline"].input.default,
1844
- WebkitPaddingEnd: spacing["padding-inline"].input.default,
1845
- color: color.text.default,
1846
- bg: color.background.input["outline-default"],
1847
- borderWidth: borderWidth.input.default,
1848
- borderColor: color.border.input.default,
1849
- paddingRight: spacing.paddingRight["number-input"].field,
1850
- _hover: {
1851
- bg: color.background.input["outline-hover"],
1852
- borderColor: color.border.input["default-hover"]
1853
- },
1854
- _focusVisible: {
1855
- bg: color.background.input["outline-focus"],
1856
- borderColor: color.border.input.focus,
1857
- boxShadow: `0 0 0 1px ${color.border.textarea.focus}`
1858
- },
1859
- _invalid: {
1860
- bg: color.background.input["outline-error"],
1861
- borderColor: color.border.input.error,
1862
- boxShadow: `0 0 0 1px ${color.border.input.error}`
1863
- },
1864
- _disabled: {
1865
- bg: color.background.input["outline-disabled"],
1866
- opacity: opacity.input.disabled,
1867
- borderColor: color.border.input.disabled
1868
- },
1869
- _readOnly: {
1870
- _focusVisible: {
1871
- borderColor: color.border.input.readonly,
1872
- boxShadow: "none"
1873
- },
1874
- _hover: {
1875
- borderColor: color.border.input.readonly
1876
- }
1877
- }
1878
- },
1879
- stepperGroup: {
1880
- width: "auto",
1881
- paddingRight: spacing.paddingRight["number-input"].stepper
1882
- },
1883
- stepper: {
1884
- _first: {
1885
- border: "none",
1886
- borderTopRightRadius: borderRadius["input-stepper"].default,
1887
- borderRadius: borderRadius["input-stepper"].default,
1888
- bg: color.background["input-stepper"].default,
1889
- opacity: isReadOnly ? opacity.input.disabled : "auto",
1890
- _hover: {
1891
- bg: isReadOnly ? "none" : color.background["input-stepper"].hover
1892
- },
1893
- _active: {
1894
- bg: color.background["input-stepper"].active
1895
- },
1896
- _disabled: {
1897
- bg: color.background["input-stepper"].disabled,
1898
- color: color.icon["input-stepper"].disabled
1899
- }
1900
- },
1901
- _last: {
1902
- border: "none",
1903
- bg: color.background["input-stepper"].default,
1904
- borderBottomRightRadius: borderRadius["input-stepper"].default,
1905
- borderRadius: borderRadius["input-stepper"].default,
1906
- opacity: isReadOnly ? opacity.input.disabled : "auto",
1907
- _hover: {
1908
- bg: isReadOnly ? "none" : color.background["input-stepper"].hover
1909
- },
1910
- _active: {
1911
- bg: color.background["input-stepper"].active
1912
- },
1913
- _disabled: {
1914
- bg: color.background["input-stepper"].disabled,
1915
- color: color.icon["input-stepper"].disabled
1916
- }
1917
- }
1918
- }
1919
- })
1920
- };
1921
-
1922
- const NotificationIconButton = {
1923
- parts: ["container", "notifier"],
1924
- sizes: {
1925
- xs: {
1926
- notifier: {
1927
- top: "0.5",
1928
- right: "0.5"
1929
- }
1930
- },
1931
- sm: {
1932
- notifier: {
1933
- top: "0.5",
1934
- right: "0.5"
1935
- }
1936
- },
1937
- md: {
1938
- notifier: {
1939
- top: "1",
1940
- right: "1"
1941
- }
1942
- },
1943
- lg: {
1944
- notifier: {
1945
- top: "2",
1946
- right: "2"
1947
- }
1948
- }
1949
- },
1950
- variants: {
1951
- link: {
1952
- notifier: {
1953
- position: "absolute",
1954
- top: "0",
1955
- right: "0",
1956
- zIndex: "base"
1957
- }
1958
- }
1959
- },
1960
- baseStyle: () => ({
1961
- container: {
1962
- position: "relative"
1963
- },
1964
- notifier: {
1965
- position: "absolute",
1966
- top: "1",
1967
- right: "1",
1968
- zIndex: "base"
1969
- }
1970
- })
1971
- };
1972
-
1973
- const Calendar = {
1974
- parts: ["container", "dateSelect", "dayLabel", "rangeCalendarContainer"],
1975
- baseStyle: ({ theme: {
1976
- space: spacing,
1977
- sizes: sizing,
1978
- colors: color
1979
- } }) => ({
1980
- container: {
1981
- p: spacing[2],
1982
- w: sizing[64],
1983
- bgColor: "background.default",
1984
- border: "1px solid",
1985
- borderColor: "border.input.default",
1986
- borderRadius: "input.outline"
1987
- },
1988
- rangeCalendarContainer: {
1989
- p: "3",
1990
- w: "128",
1991
- bgColor: "background.default",
1992
- borderRadius: "input.outline"
1993
- },
1994
- dateSelect: {
1995
- fontWeight: "semibold",
1996
- border: "none",
1997
- padding: "0",
1998
- borderRadius: "md",
1999
- color: color.text.default,
2000
- bgColor: color.background.button.ghost,
2001
- _hover: {
2002
- cursor: "pointer",
2003
- bgColor: color.background.button["ghost-hover"]
2004
- },
2005
- _active: {
2006
- bgColor: color.background.button["ghost-active"]
2007
- },
2008
- ...ring
2009
- },
2010
- dayLabel: {
2011
- color: color.gray[600],
2012
- fontSize: "xs",
2013
- p: spacing[2]
2014
- }
2015
- })
2016
- };
2017
-
2018
- const DragAndDrop = {
2019
- parts: ["dropZone"],
2020
- baseStyle: ({ sx }) => ({
2021
- dropZone: merge({
2022
- borderWidth: "st.border.width.sm",
2023
- borderStyle: "dashed",
2024
- borderColor: "border.default",
2025
- padding: "4",
2026
- display: "flex",
2027
- flexDirection: "column",
2028
- alignItems: "center",
2029
- gap: "4",
2030
- justifyContent: "center",
2031
- textAlign: "center",
2032
- minH: "56",
2033
- minW: "56",
2034
- bgColor: "bg.filled"
2035
- }, sx)
2036
- })
2037
- };
2038
-
2039
- const DatePicker = {
2040
- parts: ["group", "styledField", "dateField", "dateSegment"],
2041
- baseStyle: ({ theme: { colors: color, opacity } }) => ({
2042
- group: {
2043
- position: "relative",
2044
- alignItems: "center",
2045
- flex: 1
2046
- },
2047
- styledField: {
2048
- bgColor: "background.default",
2049
- _focusWithin: {
2050
- bgColor: color.background.input["outline-focus"],
2051
- borderColor: color.border.textarea.focus,
2052
- boxShadow: `0 0 0 1px ${color.border.textarea.focus}`
2053
- },
2054
- _invalid: {
2055
- boxShadow: `0 0 0 1px ${color.border.input.error}`,
2056
- borderColor: color.border.input.error
2057
- },
2058
- _disabled: {
2059
- bgColor: color.background.input["outline-disabled"],
2060
- borderColor: color.border.input.disabled,
2061
- opacity: opacity.input.disabled
2062
- }
2063
- },
2064
- dateField: {
2065
- width: "100%",
2066
- height: "100%",
2067
- alignItems: "center"
2068
- },
2069
- dateSegment: {
2070
- caretColor: "transparent",
2071
- boxSizing: "content-box",
2072
- textAlign: "center",
2073
- outline: "none",
2074
- rounded: "md",
2075
- _focus: {
2076
- bgColor: "blue.500",
2077
- color: color.text.inverted
2078
- },
2079
- _placeholder: {
2080
- color: "red.500"
2081
- }
2082
- }
2083
- }),
2084
- variants: {
2085
- outline: ({
2086
- theme: { colors: color, radii: borderRadius, borders: borderWidth }
2087
- }) => ({
2088
- styledField: {
2089
- bgColor: color.background.input["outline-default"],
2090
- borderRadius: borderRadius.input.outline,
2091
- borderWidth: borderWidth.input.default,
2092
- borderColor: color.border.input.default
2093
- }
2094
- }),
2095
- filled: ({
2096
- theme: { colors: color, radii: borderRadius, borders: borderWidth }
2097
- }) => ({
2098
- styledField: {
2099
- bgColor: color.background.input["filled-default"],
2100
- borderRadius: borderRadius.input.filled,
2101
- borderWidth: borderWidth.input.default,
2102
- borderColor: color.background.input["filled-default"]
2103
- }
2104
- })
2105
- }
2106
- };
2107
-
2108
- const FlipButton = {
2109
- parts: ["container", "button", "buttonIcon"],
2110
- sizes: {
2111
- xs: ({ theme: { sizes: sizing, space: spacing } }) => ({
2112
- button: {
2113
- height: sizing["flip-button"].xs,
2114
- minWidth: sizing["flip-button"].xs,
2115
- paddingInlineStart: spacing["padding-inline"]["flip-button"].xs,
2116
- paddingInlineEnd: spacing["padding-inline"]["flip-button"].xs,
2117
- fontSize: "xs"
2118
- },
2119
- buttonIcon: {
2120
- boxSize: sizing.icon.xs
2121
- }
2122
- }),
2123
- sm: ({ theme: { sizes: sizing, space: spacing } }) => ({
2124
- button: {
2125
- height: sizing["flip-button"].sm,
2126
- minWidth: sizing["flip-button"].sm,
2127
- paddingInlineStart: spacing["padding-inline"]["flip-button"].md,
2128
- paddingInlineEnd: spacing["padding-inline"]["flip-button"].md,
2129
- fontSize: "sm",
2130
- buttonIcon: {
2131
- boxSize: sizing.icon.sm
2132
- }
2133
- }
2134
- }),
2135
- md: ({ theme: { sizes: sizing, space: spacing } }) => ({
2136
- button: {
2137
- height: sizing["flip-button"].md,
2138
- minWidth: sizing["flip-button"].md,
2139
- paddingInlineStart: spacing["padding-inline"]["flip-button"].md,
2140
- paddingInlineEnd: spacing["padding-inline"]["flip-button"].md,
2141
- fontSize: "md",
2142
- buttonIcon: {
2143
- boxSize: sizing.icon.md
2144
- }
2145
- }
2146
- }),
2147
- lg: ({ theme: { sizes: sizing, space: spacing } }) => ({
2148
- button: {
2149
- height: sizing["flip-button"].lg,
2150
- minWidth: sizing["flip-button"].lg,
2151
- paddingInlineStart: spacing["padding-inline"]["flip-button"].lg,
2152
- paddingInlineEnd: spacing["padding-inline"]["flip-button"].lg,
2153
- fontSize: "lg",
2154
- buttonIcon: {
2155
- boxSize: sizing.icon.lg
2156
- }
2157
- }
2158
- })
2159
- },
2160
- baseStyle: ({ theme: {
2161
- space: spacing,
2162
- sizes: sizing,
2163
- colors: color,
2164
- opacity,
2165
- radii: borderRadius,
2166
- fontWeights: coreFontWeight
2167
- }, numberOfButtons }) => ({
2168
- container: {
2169
- borderRadius: borderRadius["flip-button"].default,
2170
- paddingInlineStart: spacing["padding-inline"]["flip-button-group"].default,
2171
- paddingInlineEnd: spacing["padding-inline"]["flip-button-group"].default,
2172
- paddingY: spacing.paddingY["flip-button-group"].default,
2173
- disply: "grid",
2174
- width: "100%",
2175
- gap: spacing["padding-inline"]["flip-button"].gap,
2176
- gridTemplateColumns: `repeat(${numberOfButtons}, minmax(${sizing[32]}, 1fr))`,
2177
- gridTemplateRows: "1fr",
2178
- overflowX: "auto"
2179
- },
2180
- button: {
2181
- width: "100%",
2182
- justifyContent: "center",
2183
- alignItems: "center",
2184
- color: color.text["flip-button"].default,
2185
- cursor: "pointer",
2186
- borderRadius: borderRadius["flip-button"].default,
2187
- fontWeight: coreFontWeight.semiBold,
2188
- _disabled: {
2189
- opacity: opacity["flip-button"].disabled
2190
- },
2191
- _checked: {
2192
- color: color.text["flip-button"].inverted
2193
- }
2194
- }
2195
- }),
2196
- variants: {
2197
- default: ({ theme: { colors: color }, sx }) => ({
2198
- container: merge({
2199
- bgColor: color.background["flip-button"]["default-deselected-blue"]
2200
- }, sx),
2201
- button: {
2202
- bgColor: color.background["flip-button"]["default-deselected-blue"],
2203
- _hover: {
2204
- bgColor: color.background["flip-button"]["hover-deselected-blue"]
2205
- },
2206
- _checked: {
2207
- bgColor: color.background["flip-button"]["default-selected-blue"],
2208
- _hover: {
2209
- bgColor: color.background["flip-button"]["default-selected-blue"]
2210
- }
2211
- }
2212
- }
2213
- }),
2214
- brand: ({ theme: { colors: color }, sx }) => ({
2215
- container: merge({
2216
- bgColor: color.background["flip-button"]["default-deselected-brand"]
2217
- }, sx),
2218
- button: {
2219
- bgColor: color.background["flip-button"]["default-deselected-brand"],
2220
- _hover: {
2221
- bgColor: color.background["flip-button"]["hover-deselected-brand"]
2222
- },
2223
- _checked: {
2224
- bgColor: color.background["flip-button"]["default-selected-brand"],
2225
- _hover: {
2226
- bgColor: color.background["flip-button"]["default-selected-brand"]
2227
- }
2228
- }
2229
- }
2230
- })
2231
- },
2232
- defaultProps: {
2233
- size: "md",
2234
- variant: "default"
2235
- }
2236
- };
2237
-
2238
- const Spinner = {
2239
- baseStyle: ({ theme: { colors: color, borders: borderWidth } }) => ({
2240
- borderWidth: borderWidth.spinner.default,
2241
- color: color.background.spinner.thumb,
2242
- borderBottomColor: color.background.spinner.track,
2243
- borderLeftColor: color.background.spinner.track
2244
- })
2245
- };
2246
-
2247
- const possibleBgColors = getShades(400, 600);
2248
- const getAvatarBgColor = (image, name, color) => {
2249
- if (image)
2250
- return color.background.avatar.image;
2251
- if (name)
2252
- return randomColor({ string: name, colors: possibleBgColors });
2253
- return color.background.avatar.default;
2254
- };
2255
-
2256
- const Avatar = {
2257
- parts: ["container", "text", "badge", "icon"],
2258
- sizes: {
2259
- "2xs": ({ theme: { sizes: sizing } }) => ({
2260
- container: {
2261
- width: sizing.avatar["2xs"],
2262
- height: sizing.avatar["2xs"]
2263
- },
2264
- text: {
2265
- lineHeight: sizing.avatar["2xs"]
2266
- }
2267
- }),
2268
- xs: ({ theme: { sizes: sizing } }) => ({
2269
- container: {
2270
- width: sizing.avatar.xs,
2271
- height: sizing.avatar.xs
2272
- },
2273
- text: {
2274
- lineHeight: sizing.avatar.xs
2275
- }
2276
- }),
2277
- sm: ({ theme: { sizes: sizing } }) => ({
2278
- container: {
2279
- width: sizing.avatar.sm,
2280
- height: sizing.avatar.sm
2281
- },
2282
- text: {
2283
- lineHeight: sizing.avatar.sm
2284
- },
2285
- icon: {
2286
- boxSize: sizing.avatar.sm
2287
- }
2288
- }),
2289
- md: ({ theme: { sizes: sizing } }) => ({
2290
- container: {
2291
- width: sizing.avatar.md,
2292
- height: sizing.avatar.md
2293
- },
2294
- text: {
2295
- lineHeight: sizing.avatar.md
2296
- },
2297
- icon: {
2298
- boxSize: sizing.avatar.md
2299
- }
2300
- }),
2301
- lg: ({ theme: { sizes: sizing } }) => ({
2302
- container: {
2303
- width: sizing.avatar.lg,
2304
- height: sizing.avatar.lg
2305
- },
2306
- text: {
2307
- lineHeight: sizing.avatar.lg
2308
- },
2309
- icon: {
2310
- boxSize: sizing.avatar.lg
2311
- }
2312
- }),
2313
- xl: ({ theme: { sizes: sizing } }) => ({
2314
- container: {
2315
- width: sizing.avatar.xl,
2316
- height: sizing.avatar.xl
2317
- },
2318
- text: {
2319
- lineHeight: sizing.avatar.xl
2320
- }
2321
- }),
2322
- "2xl": ({ theme: { sizes: sizing } }) => ({
2323
- container: {
2324
- width: sizing.avatar["2xl"],
2325
- height: sizing.avatar["2xl"]
2326
- },
2327
- text: {
2328
- lineHeight: sizing.avatar["2xl"]
2329
- }
2330
- })
2331
- },
2332
- baseStyle: ({ theme: {
2333
- colors: color,
2334
- sizes: sizing,
2335
- radii: borderRadius
2336
- }, image, name }) => {
2337
- const avatarBgColor = getAvatarBgColor(image, name, color);
2338
- return {
2339
- container: {
2340
- bgColor: avatarBgColor,
2341
- color: getContrastColor(avatarBgColor),
2342
- display: "grid",
2343
- placeItems: "center",
2344
- objectFit: "cover",
2345
- position: "relative"
2346
- },
2347
- userImage: {
2348
- width: "100%",
2349
- height: "100%",
2350
- objectFit: "cover"
2351
- },
2352
- badge: {
2353
- position: "absolute",
2354
- bottom: `-${sizing["1"]}`,
2355
- right: `-${sizing["1"]}`,
2356
- minWidth: sizing["5"],
2357
- height: sizing["5"],
2358
- display: "flex",
2359
- justifyContent: "center",
2360
- alignItems: "center",
2361
- fontSize: "xs",
2362
- fontWeight: "semibold",
2363
- padding: sizing["0a"],
2364
- bgColor: color.red["500"],
2365
- color: color.text.inverted,
2366
- borderRadius: borderRadius.avatar.square,
2367
- border: "none"
2368
- }
2369
- };
2370
- },
2371
- variants: {
2372
- square: ({ theme: { radii: borderRadius } }) => ({
2373
- container: {
2374
- aspectRatio: "1 / 1",
2375
- borderRadius: borderRadius.avatar.square,
2376
- "> img": {
2377
- borderRadius: borderRadius.avatar.square,
2378
- aspectRatio: "1 / 1"
2379
- }
2380
- },
2381
- badge: {
2382
- borderRadius: borderRadius.avatar.square
2383
- }
2384
- }),
2385
- rounded: ({ theme: { radii: borderRadius } }) => ({
2386
- container: {
2387
- aspectRatio: "1 / 1",
2388
- borderRadius: borderRadius.avatar.rounded,
2389
- "> img": {
2390
- borderRadius: borderRadius.avatar.rounded,
2391
- aspectRatio: "1 / 1"
2392
- }
2393
- },
2394
- badge: {
2395
- borderRadius: borderRadius.avatar.rounded
2396
- }
2397
- })
2398
- }
2399
- };
2400
-
2401
- const CloseButton = {
2402
- baseStyle: ({ theme: { colors: color } }) => ({
2403
- color: color.text.default,
2404
- bgColor: color.background.button.ghost,
2405
- _hover: {
2406
- bg: color.background.button["ghost-hover"],
2407
- _disabled: {
2408
- bgColor: color.background.button.ghost
2409
- }
2410
- },
2411
- _active: {
2412
- bgColor: color.background.button["ghost-active"]
2413
- },
2414
- _focusVisible: {
2415
- ring: "2px",
2416
- ringColor: color.border.wcag,
2417
- ringOffset: "1px"
2418
- }
2419
- }),
2420
- defaultProps: {
2421
- size: "md"
2422
- }
2423
- };
2424
-
2425
- const Modal = {
2426
- parts: ["overlay", "closeButton", "dialog"],
2427
- sizes: {
2428
- huge: {
2429
- dialog: {
2430
- width: "90%",
2431
- maxW: "96rem",
2432
- aspectRatio: "16/9"
2433
- }
2434
- }
2435
- },
2436
- baseStyle: ({ theme }) => {
2437
- const {
2438
- typography: { headings: { h3 } }
2439
- } = theme;
2440
- return {
2441
- overlay: {
2442
- bgColor: "background.modal.overlay",
2443
- backdropFilter: "blur(8px)"
2444
- },
2445
- closeButton: {
2446
- top: 4,
2447
- right: 4
2448
- },
2449
- dialog: {
2450
- bgColor: "background.default",
2451
- borderRadius: "modal.dialog"
2452
- },
2453
- header: {
2454
- fontSize: h3.fontSize,
2455
- paddingTop: "paddingTop.modal.header",
2456
- paddingBottom: "paddingBottom.modal.header",
2457
- border: "modal.header",
2458
- borderBottomColor: "border.modal.header",
2459
- borderBottomStyle: "solid"
2460
- },
2461
- body: {
2462
- paddingTop: "paddingTop.modal.body",
2463
- paddingBottom: "paddingBottom.modal.body"
2464
- },
2465
- footer: {
2466
- paddingTop: "paddingTop.modal.footer",
2467
- paddingBottom: "paddingBottom.modal.footer"
2468
- }
2469
- };
2470
- }
2471
- };
2472
-
2473
- const Tooltip = {
2474
- baseStyle: ({ theme: { colors: color, space: spacing, radii: borderRadius } }) => ({
2475
- backgroundColor: color.background.tooltip.default,
2476
- color: color.text.inverted,
2477
- paddingInline: spacing["padding-inline"].tooltip.default,
2478
- paddingY: spacing.paddingY.tooltip.default,
2479
- borderRadius: borderRadius.tooltip.default
2480
- })
2481
- };
2482
-
2483
- const Icon = {
2484
- sizes: {
2485
- xs: {
2486
- boxSize: "icon.xs"
2487
- },
2488
- sm: {
2489
- boxSize: "icon.sm"
2490
- },
2491
- md: {
2492
- boxSize: "icon.md"
2493
- },
2494
- lg: {
2495
- boxSize: "icon.lg"
2496
- }
2497
- },
2498
- baseStyle: ({ boxSize, color }) => ({
2499
- boxSize: boxSize || "icon.default",
2500
- color: color || "inherit"
2501
- })
2502
- };
2503
-
2504
- const ClipboardInput = {
2505
- parts: ["button", "icon", "tooltip"],
2506
- sizes: {
2507
- sm: ({ theme: { sizes: sizing, space: spacing } }) => ({
2508
- button: {
2509
- height: sizing.button.xs,
2510
- minWidth: sizing.button.xs
2511
- },
2512
- icon: {
2513
- boxSize: sizing.icon.xs
2514
- },
2515
- tooltip: {
2516
- paddingInline: spacing["padding-inline"].tooltip.sm,
2517
- paddingY: spacing.paddingY.tooltip.sm
2518
- }
2519
- }),
2520
- md: ({ theme: { sizes: sizing } }) => ({
2521
- button: {
2522
- height: sizing.button.sm,
2523
- minWidth: sizing.button.sm
2524
- },
2525
- icon: {
2526
- boxSize: sizing.icon.sm
2527
- }
2528
- }),
2529
- lg: ({ theme: { sizes: sizing } }) => ({
2530
- button: {
2531
- height: sizing.button.md,
2532
- minWidth: sizing.button.md
2533
- },
2534
- icon: {
2535
- boxSize: sizing.icon.md
2536
- }
2537
- })
2538
- }
2539
- };
2540
-
2541
- const ColorPicker = {
2542
- parts: ["colorButton", "trigger", "heading"],
2543
- baseStyle: ({ theme, selectedColor }) => {
2544
- const { sizes: sizing, colors: color } = theme;
2545
- return {
2546
- heading: {
2547
- border: "none",
2548
- paddingInlineStart: sizing["4"],
2549
- paddingInlineEnd: sizing["2"],
2550
- paddingBottom: sizing["0"],
2551
- fontSize: "md",
2552
- fontWeight: "semibold"
2553
- },
2554
- trigger: {
2555
- bgColor: selectedColor ?? color.background.button.default,
2556
- color: selectedColor ? getContrastColor(selectedColor) : "unset",
2557
- _hover: {
2558
- bgColor: selectedColor ?? color.background.button["default-hover"]
2559
- },
2560
- _active: {
2561
- bgColor: selectedColor ?? color.background.button["default-active"]
2562
- }
2563
- },
2564
- colorButton: {
2565
- height: sizing.button.sm,
2566
- minWidth: sizing.button.sm,
2567
- _hover: {
2568
- ring: "2px",
2569
- ringOffset: "1px",
2570
- ringColor: `${color.border.input["default-hover"]}`
2571
- }
2572
- }
2573
- };
2574
- },
2575
- sizes: {
2576
- sm: ({ theme: { sizes: sizing } }) => ({
2577
- trigger: {
2578
- height: sizing.button.sm,
2579
- minWidth: sizing.button.sm
2580
- }
2581
- }),
2582
- md: ({ theme: { sizes: sizing } }) => ({
2583
- trigger: {
2584
- height: sizing.button.md,
2585
- minWidth: sizing.button.md
2586
- }
2587
- }),
2588
- lg: ({ theme: { sizes: sizing } }) => ({
2589
- trigger: {
2590
- height: sizing.button.lg,
2591
- minWidth: sizing.button.lg
2592
- }
2593
- })
2594
- }
2595
- };
2596
-
2597
- const Step = {
2598
- parts: ["step", "label", "description"],
2599
- baseStyle: ({ theme: {
2600
- colors: color,
2601
- fontWeights,
2602
- space: spacing,
2603
- borders: borderWidth
2604
- } }) => ({
2605
- step: {
2606
- justifyContent: "start",
2607
- alignItems: "start",
2608
- bgColor: color.background.step.default,
2609
- borderTopWidth: borderWidth.step.default,
2610
- borderColor: color.border.step.default,
2611
- borderBottom: "none",
2612
- paddingInline: spacing["padding-inline"].step.default,
2613
- color: color.text.subdued,
2614
- _hover: {
2615
- bgColor: color.background.step.hover,
2616
- borderColor: color.border.step.hover
2617
- },
2618
- _active: {
2619
- bgColor: color.background.step.active
2620
- },
2621
- _selected: {
2622
- bgColor: color.background.step.selected,
2623
- borderColor: color.border.step.selected,
2624
- color: color.border.step.selected,
2625
- _hover: {
2626
- borderColor: color.border.step.selected,
2627
- color: color.border.step.selected
2628
- }
2629
- }
2630
- },
2631
- label: {
2632
- color: "inherit",
2633
- pt: spacing.paddingTop.step.label,
2634
- textAlign: "start",
2635
- fontWeight: fontWeights.bold
2636
- },
2637
- description: {
2638
- textAlign: "start",
2639
- fontWeight: fontWeights.semiBold,
2640
- color: color.text.default
2641
- }
2642
- })
2643
- };
2644
-
2645
- const StepList = {
2646
- baseStyle: ({ theme: { sizes: sizing }, tabs }) => ({
2647
- display: "grid",
2648
- width: "100%",
2649
- gridTemplateColumns: `repeat(${tabs}, minmax(${sizing[32]}, 1fr))`,
2650
- gridTemplateRows: "1fr",
2651
- overflowX: "auto",
2652
- borderBottom: "none",
2653
- paddingBottom: sizing[2]
2654
- })
2655
- };
2656
-
2657
- const H1 = {
2658
- baseStyle: ({ theme, sx }) => {
2659
- const {
2660
- colors: color,
2661
- typography: { headings: { h1 } }
2662
- } = theme;
2663
- return merge({
2664
- color: color.text.default,
2665
- fontFamily: h1.fontFamily,
2666
- fontWeight: h1.fontWeight,
2667
- lineHeight: h1.lineHeight,
2668
- fontSize: h1.fontSize,
2669
- letterSpacing: h1.letterSpacing,
2670
- textTransform: h1.textCase
2671
- }, sx);
2672
- }
2673
- };
2674
-
2675
- const H2 = {
2676
- baseStyle: ({ theme, sx }) => {
2677
- const {
2678
- colors: color,
2679
- typography: { headings: { h2 } }
2680
- } = theme;
2681
- return merge({
2682
- color: color.text.default,
2683
- fontFamily: h2.fontFamily,
2684
- fontWeight: h2.fontWeight,
2685
- lineHeight: h2.lineHeight,
2686
- fontSize: h2.fontSize,
2687
- letterSpacing: h2.letterSpacing,
2688
- textTransform: h2.textCase
2689
- }, sx);
2690
- }
2691
- };
2692
-
2693
- const H3 = {
2694
- baseStyle: ({ theme, sx }) => {
2695
- const {
2696
- colors: color,
2697
- typography: { headings: { h3 } }
2698
- } = theme;
2699
- return merge({
2700
- color: color.text.default,
2701
- fontFamily: h3.fontFamily,
2702
- fontWeight: h3.fontWeight,
2703
- lineHeight: h3.lineHeight,
2704
- fontSize: h3.fontSize,
2705
- letterSpacing: h3.letterSpacing,
2706
- textTransform: h3.textCase
2707
- }, sx);
2708
- }
2709
- };
2710
-
2711
- const H4 = {
2712
- baseStyle: ({ theme, sx }) => {
2713
- const {
2714
- colors: color,
2715
- typography: { headings: { h4 } }
2716
- } = theme;
2717
- return merge({
2718
- color: color.text.default,
2719
- fontFamily: h4.fontFamily,
2720
- fontWeight: h4.fontWeight,
2721
- lineHeight: h4.lineHeight,
2722
- fontSize: h4.fontSize,
2723
- letterSpacing: h4.letterSpacing,
2724
- textTransform: h4.textCase
2725
- }, sx);
2726
- }
2727
- };
2728
-
2729
- const H5 = {
2730
- baseStyle: ({ theme, sx }) => {
2731
- const {
2732
- colors: color,
2733
- typography: { headings: { h5 } }
2734
- } = theme;
2735
- return merge({
2736
- color: color.text.default,
2737
- fontFamily: h5.fontFamily,
2738
- fontWeight: h5.fontWeight,
2739
- lineHeight: h5.lineHeight,
2740
- fontSize: h5.fontSize,
2741
- letterSpacing: h5.letterSpacing,
2742
- textTransform: h5.textCase
2743
- }, sx);
2744
- }
2745
- };
2746
-
2747
- const H6 = {
2748
- baseStyle: ({ theme, sx }) => {
2749
- const {
2750
- colors: color,
2751
- typography: { headings: { h6 } }
2752
- } = theme;
2753
- return merge({
2754
- color: color.text.default,
2755
- fontFamily: h6.fontFamily,
2756
- fontWeight: h6.fontWeight,
2757
- lineHeight: h6.lineHeight,
2758
- fontSize: h6.fontSize,
2759
- letterSpacing: h6.letterSpacing,
2760
- textTransform: h6.textCase
2761
- }, sx);
2762
- }
2763
- };
2764
-
2765
- const Blockquote = {
2766
- baseStyle: ({ theme, sx }) => {
2767
- const { blockquote } = theme.typography.stylized;
2768
- return merge({
2769
- color: "text.default",
2770
- fontFamily: blockquote.fontFamily,
2771
- fontWeight: blockquote.fontWeight,
2772
- lineHeight: blockquote.lineHeight,
2773
- fontSize: blockquote.fontSize,
2774
- letterSpacing: blockquote.letterSpacing,
2775
- textTransform: blockquote.textCase
2776
- }, sx);
2777
- }
2778
- };
2779
-
2780
- const Tiny = {
2781
- baseStyle: ({ theme, sx }) => {
2782
- const { tiny } = theme.typography.stylized;
2783
- return merge({
2784
- color: "text.default",
2785
- fontFamily: tiny.fontFamily,
2786
- fontWeight: tiny.fontWeight,
2787
- lineHeight: tiny.lineHeight,
2788
- fontSize: tiny.fontSize,
2789
- letterSpacing: tiny.letterSpacing,
2790
- textTransform: tiny.textCase
2791
- }, sx);
2792
- }
2793
- };
2794
-
2795
- const Capitalized = {
2796
- baseStyle: ({ theme, sx }) => {
2797
- const { CAPITALIZED } = theme.typography.stylized;
2798
- return merge({
2799
- color: "text.default",
2800
- fontFamily: CAPITALIZED.fontFamily,
2801
- fontWeight: CAPITALIZED.fontWeight,
2802
- lineHeight: CAPITALIZED.lineHeight,
2803
- fontSize: CAPITALIZED.fontSize,
2804
- letterSpacing: CAPITALIZED.letterSpacing,
2805
- textTransform: CAPITALIZED.textCase
2806
- }, sx);
2807
- }
2808
- };
2809
-
2810
- const Lead = {
2811
- baseStyle: ({ theme, sx }) => {
2812
- const { lead } = theme.typography.stylized;
2813
- return merge({
2814
- color: "text.default",
2815
- fontFamily: lead.fontFamily,
2816
- fontWeight: lead.fontWeight,
2817
- lineHeight: lead.lineHeight,
2818
- fontSize: lead.fontSize,
2819
- letterSpacing: lead.letterSpacing,
2820
- textTransform: lead.textCase
2821
- }, sx);
2822
- }
2823
- };
2824
-
2825
- const Small = {
2826
- baseStyle: ({ theme, sx }) => {
2827
- const { small } = theme.typography.stylized;
2828
- return merge({
2829
- color: "text.default",
2830
- fontFamily: small.fontFamily,
2831
- fontWeight: small.fontWeight,
2832
- lineHeight: small.lineHeight,
2833
- fontSize: small.fontSize,
2834
- letterSpacing: small.letterSpacing,
2835
- textTransform: small.textCase
2836
- }, sx);
2837
- }
2838
- };
2839
-
2840
- const P = {
2841
- variants: {
2842
- 14: ({ theme, sx }) => {
2843
- const { body14 } = theme.typography.body;
2844
- return merge({
2845
- fontFamily: body14.fontFamily,
2846
- fontWeight: body14.fontWeight,
2847
- lineHeight: body14.lineHeight,
2848
- fontSize: body14.fontSize,
2849
- letterSpacing: body14.letterSpacing,
2850
- textTransform: body14.textCase
2851
- }, sx);
2852
- },
2853
- 16: ({ theme, sx }) => {
2854
- const { body16 } = theme.typography.body;
2855
- return merge({
2856
- fontFamily: body16.fontFamily,
2857
- fontWeight: body16.fontWeight,
2858
- lineHeight: body16.lineHeight,
2859
- fontSize: body16.fontSize,
2860
- letterSpacing: body16.letterSpacing,
2861
- textTransform: body16.textCase
2862
- }, sx);
2863
- }
2864
- },
2865
- baseStyle: {
2866
- color: "text.default"
2867
- }
2868
- };
2869
-
2870
- const Label = {
2871
- baseStyle: ({ theme: { sizes: sizing }, sx }) => merge({
2872
- color: "inherit",
2873
- width: "100%",
2874
- maxWidth: "100%",
2875
- marginBottom: sizing[0],
2876
- marginInlineStart: sizing[0],
2877
- marginEnd: sizing[0],
2878
- marginInlineEnd: sizing[0]
2879
- }, sx),
2880
- sizes: {
2881
- "2xs": ({ theme, sx }) => {
2882
- const { tinyLabel } = theme.typography.labels;
2883
- return merge({
2884
- fontFamily: tinyLabel.fontFamily,
2885
- fontWeight: tinyLabel.fontWeight,
2886
- lineHeight: tinyLabel.lineHeight,
2887
- fontSize: tinyLabel.fontSize,
2888
- letterSpacing: tinyLabel.letterSpacing,
2889
- textTransform: tinyLabel.textCase
2890
- }, sx);
2891
- },
2892
- xs: ({ theme, sx }) => {
2893
- const { xsLabel } = theme.typography.labels;
2894
- return merge({
2895
- fontFamily: xsLabel.fontFamily,
2896
- fontWeight: xsLabel.fontWeight,
2897
- lineHeight: xsLabel.lineHeight,
2898
- fontSize: xsLabel.fontSize,
2899
- letterSpacing: xsLabel.letterSpacing,
2900
- textTransform: xsLabel.textCase
2901
- }, sx);
2902
- },
2903
- sm: ({ theme, sx }) => {
2904
- const { smLabel } = theme.typography.labels;
2905
- return merge({
2906
- fontFamily: smLabel.fontFamily,
2907
- fontWeight: smLabel.fontWeight,
2908
- lineHeight: smLabel.lineHeight,
2909
- fontSize: smLabel.fontSize,
2910
- letterSpacing: smLabel.letterSpacing,
2911
- textTransform: smLabel.textCase
2912
- }, sx);
2913
- },
2914
- md: ({ theme, sx }) => {
2915
- const { mdLabel } = theme.typography.labels;
2916
- return merge({
2917
- fontFamily: mdLabel.fontFamily,
2918
- fontWeight: mdLabel.fontWeight,
2919
- lineHeight: mdLabel.lineHeight,
2920
- fontSize: mdLabel.fontSize,
2921
- letterSpacing: mdLabel.letterSpacing,
2922
- textTransform: mdLabel.textCase
2923
- }, sx);
2924
- },
2925
- lg: ({ theme, sx }) => {
2926
- const { lgLabel } = theme.typography.labels;
2927
- return merge({
2928
- fontFamily: lgLabel.fontFamily,
2929
- fontWeight: lgLabel.fontWeight,
2930
- lineHeight: lgLabel.lineHeight,
2931
- fontSize: lgLabel.fontSize,
2932
- letterSpacing: lgLabel.letterSpacing,
2933
- textTransform: lgLabel.textCase
2934
- }, sx);
2935
- }
2936
- }
2937
- };
2938
-
2939
- const SplitPane = {
2940
- baseStyle: ({ minLeftWidth, minRightWidth, initialSplit, isOpen }) => ({
2941
- display: "grid",
2942
- overflow: "hidden",
2943
- gridTemplateColumns: !isOpen ? "1fr" : `minmax(${minLeftWidth}%, var(--split-pos, ${initialSplit}%)) auto minmax(${minRightWidth}%, 1fr)`,
2944
- alignItems: "stretch",
2945
- justifyItems: "stretch",
2946
- height: "100%",
2947
- width: "100%"
2948
- })
2949
- };
2950
- const PaneDivider = {
2951
- baseStyle: ({ theme: { colors: color, sizes: sizing } }) => ({
2952
- bgColor: color.background["pane-divider"].default,
2953
- zIndex: 300,
2954
- cursor: "col-resize",
2955
- height: "100%",
2956
- width: sizing[1],
2957
- _hover: {
2958
- outlineColor: color.border["pane-divider"].hover,
2959
- outlineWidth: sizing["0a"],
2960
- outlineStyle: "solid"
2961
- },
2962
- _active: {
2963
- outlineColor: color.border["pane-divider"].hover,
2964
- outlineWidth: sizing["0a"],
2965
- outlineStyle: "solid"
2966
- }
2967
- })
2968
- };
2969
-
2970
- const Carousel = {
2971
- parts: ["container", "arrow", "radio"],
2972
- baseStyle: {
2973
- container: {
2974
- display: "grid",
2975
- placeItems: "center",
2976
- position: "relative",
2977
- overflow: "hidden",
2978
- width: "full",
2979
- height: "full"
2980
- },
2981
- radio: {
2982
- position: "absolute",
2983
- bottom: "1",
2984
- left: "50%",
2985
- transform: "translateX(-50%)",
2986
- overflowX: "scroll",
2987
- maxWidth: "90%",
2988
- padding: "2"
2989
- },
2990
- arrow: {
2991
- position: "absolute",
2992
- bottom: "0",
2993
- height: "100%",
2994
- cursor: "pointer"
2995
- }
2996
- }
2997
- };
2998
-
2999
- const EditableText = {
3000
- parts: ["button", "icon", "controls", "preview", "input"],
3001
- sizes: {
3002
- sm: ({ isEditing, theme: { sizes: sizing } }) => ({
3003
- button: {
3004
- height: sizing.button.xs,
3005
- minWidth: sizing.button.xs
3006
- },
3007
- icon: {
3008
- boxSize: sizing.icon.xs
3009
- },
3010
- controls: {
3011
- width: !isEditing ? 6 : "3.25rem"
3012
- },
3013
- preview: {
3014
- pt: 1
3015
- },
3016
- input: {
3017
- paddingInlineEnd: 16,
3018
- paddingRight: 16
3019
- }
3020
- }),
3021
- md: ({ isEditing, theme: { sizes: sizing } }) => ({
3022
- button: {
3023
- height: sizing.button.sm,
3024
- minWidth: sizing.button.sm
3025
- },
3026
- icon: {
3027
- boxSize: sizing.icon.sm
3028
- },
3029
- controls: {
3030
- width: !isEditing ? 8 : "4.25rem"
3031
- },
3032
- preview: {
3033
- pt: "7px"
3034
- },
3035
- input: {
3036
- paddingInlineEnd: 20,
3037
- paddingRight: 20
3038
- }
3039
- }),
3040
- lg: ({ isEditing, theme: { sizes: sizing } }) => ({
3041
- button: {
3042
- height: sizing.button.md,
3043
- minWidth: sizing.button.md
3044
- },
3045
- icon: {
3046
- boxSize: sizing.icon.md
3047
- },
3048
- controls: {
3049
- width: !isEditing ? 10 : "5.25rem"
3050
- },
3051
- preview: {
3052
- pt: "8px"
3053
- },
3054
- input: {
3055
- paddingInlineEnd: 24,
3056
- paddingRight: 24
3057
- }
3058
- })
3059
- },
3060
- baseStyle: {
3061
- controls: {
3062
- mr: 1
3063
- },
3064
- preview: {
3065
- fontWeight: "semibold",
3066
- textOverflow: "ellipsis",
3067
- whiteSpace: "nowrap",
3068
- overflow: "hidden",
3069
- paddingTop: 0,
3070
- paddingBottom: 0
3071
- },
3072
- input: {
3073
- fontWeight: "semibold"
3074
- }
3075
- }
3076
- };
3077
-
3078
- const Toolbox = {
3079
- parts: ["container", "header", "body", "footer"],
3080
- baseStyle: ({ theme: { sizes: sizing } }) => ({
3081
- container: {
3082
- position: "relative",
3083
- flexDirection: "column",
3084
- bg: "text.inverted",
3085
- h: "100vh",
3086
- borderLeftWidth: "1px",
3087
- borderLeftStyle: "solid",
3088
- borderLeftColor: "gray.100"
3089
- },
3090
- header: {
3091
- alignItems: "center",
3092
- height: "16",
3093
- borderBottomWidth: "1px",
3094
- borderBottomStyle: "solid",
3095
- borderBottomColor: "gray.100",
3096
- pl: "4",
3097
- pr: "16"
3098
- },
3099
- footer: {
3100
- position: "absolute",
3101
- bottom: "0",
3102
- w: "full",
3103
- p: "4",
3104
- alignItems: "center",
3105
- height: "16",
3106
- borderTopWidth: "1px",
3107
- borderTopStyle: "solid",
3108
- borderTopColor: "gray.100"
3109
- },
3110
- body: {
3111
- p: sizing["4"],
3112
- flexDirection: "column",
3113
- w: "100%",
3114
- h: "100%",
3115
- maxH: `calc(100vh - ${sizing["16"]} * 2)`,
3116
- overflowY: "scroll"
3117
- }
3118
- }),
3119
- sizes: {
3120
- sm: {
3121
- container: {
3122
- w: "xs"
3123
- }
3124
- },
3125
- md: {
3126
- container: {
3127
- w: "md"
3128
- }
3129
- },
3130
- lg: {
3131
- container: {
3132
- w: "xl"
3133
- }
3134
- }
3135
- }
3136
- };
3137
-
3138
- const shakeAnimation = keyframes`
3139
- 0% { transform: translate(1px, 1px) rotate(0deg); }
3140
- 10% { transform: translate(-1px, -2px) rotate(-1deg); }
3141
- 20% { transform: translate(-3px, 0px) rotate(1deg); }
3142
- 30% { transform: translate(3px, 2px) rotate(0deg); }
3143
- 40% { transform: translate(1px, -1px) rotate(1deg); }
3144
- 50% { transform: translate(-1px, 2px) rotate(-1deg); }
3145
- 60% { transform: translate(-3px, 1px) rotate(0deg); }
3146
- 70% { transform: translate(3px, 1px) rotate(-1deg); }
3147
- 80% { transform: translate(-1px, -1px) rotate(1deg); }
3148
- 90% { transform: translate(1px, 2px) rotate(0deg); }
3149
- 100% { transform: translate(1px, -2px) rotate(-1deg); }
3150
- `;
3151
- const thickRing = {
3152
- _focusVisible: {
3153
- outline: "none",
3154
- ring: "3px",
3155
- ringColor: "border.wcag",
3156
- ringOffset: "1px"
3157
- }
3158
- };
3159
- const getBgColor$1 = (currentTheme) => {
3160
- switch (currentTheme) {
3161
- case "webappTheme":
3162
- return "blue.50";
3163
- case "tottTheme":
3164
- return "blue.900";
3165
- default:
3166
- return "bg.filled";
3167
- }
3168
- };
3169
- const getInvalidColorStyles = (isInvalid, isImage = true, currentTheme = "webappTheme") => ({
3170
- borderColor: isInvalid ? "red.500" : "gray.300",
3171
- bgColor: isInvalid && "red.50",
3172
- animation: isInvalid && `500ms ${shakeAnimation} ease`,
3173
- _hover: isImage && {
3174
- bgColor: isInvalid ? "red.50" : getBgColor$1(currentTheme),
3175
- borderColor: isInvalid ? "red.500" : "blue.500"
3176
- }
3177
- });
3178
- const FilePicker = {
3179
- parts: ["filePicker", "fileItem", "multiFilePicker"],
3180
- baseStyle: ({ theme: { sizes, colors }, hasLoaded, isImage, isInvalid, currentTheme }) => ({
3181
- filePicker: {
3182
- display: "flex",
3183
- flexDirection: "column",
3184
- alignItems: "center",
3185
- justifyContent: "center",
3186
- width: "44",
3187
- height: "40",
3188
- textAlign: "center",
3189
- position: "relative",
3190
- borderWidth: hasLoaded && isImage ? "0" : sizes["0a"],
3191
- borderStyle: "dashed",
3192
- borderRadius: "lg",
3193
- ...getInvalidColorStyles(isInvalid, isImage, currentTheme),
3194
- ...thickRing
3195
- },
3196
- multiFilePicker: {
3197
- width: "full",
3198
- maxWidth: "inherit",
3199
- height: "32",
3200
- position: "relative",
3201
- borderWidth: sizes["0a"],
3202
- borderStyle: "dashed",
3203
- borderRadius: "lg",
3204
- ...getInvalidColorStyles(isInvalid, void 0, currentTheme),
3205
- ...thickRing
3206
- },
3207
- fileItem: {
3208
- display: "flex",
3209
- flexDirection: "column",
3210
- alignItems: "center",
3211
- justifyContent: "center",
3212
- paddingX: "2",
3213
- paddingY: "1",
3214
- borderRadius: sizes["2"],
3215
- textAlign: "center",
3216
- position: "relative",
3217
- border: `2px solid ${colors.gray["100"]}`,
3218
- minHeight: "20"
3219
- }
3220
- })
3221
- };
3222
-
3223
- var components = /*#__PURE__*/Object.freeze({
3224
- __proto__: null,
3225
- Alert: Alert,
3226
- Avatar: Avatar,
3227
- Blinker: Blinker,
3228
- Blockquote: Blockquote,
3229
- Breadcrumb: Breadcrumb,
3230
- Button: Button,
3231
- Calendar: Calendar,
3232
- Capitalized: Capitalized,
3233
- Carousel: Carousel,
3234
- Checkbox: Checkbox,
3235
- ClipboardInput: ClipboardInput,
3236
- CloseButton: CloseButton,
3237
- ColorPicker: ColorPicker,
3238
- DatePicker: DatePicker,
3239
- DragAndDrop: DragAndDrop,
3240
- EditableText: EditableText,
3241
- FilePicker: FilePicker,
3242
- FlipButton: FlipButton,
3243
- H1: H1,
3244
- H2: H2,
3245
- H3: H3,
3246
- H4: H4,
3247
- H5: H5,
3248
- H6: H6,
3249
- Icon: Icon,
3250
- Input: Input,
3251
- Label: Label,
3252
- Lead: Lead,
3253
- Link: Link,
3254
- Modal: Modal,
3255
- NotificationIconButton: NotificationIconButton,
3256
- NumberInput: NumberInput,
3257
- P: P,
3258
- PaneDivider: PaneDivider,
3259
- PinInput: PinInput,
3260
- Radio: Radio,
3261
- Select: Select,
3262
- Small: Small,
3263
- Spinner: Spinner,
3264
- SplitPane: SplitPane,
3265
- Step: Step,
3266
- StepList: StepList,
3267
- Switch: Switch$1,
3268
- Tabs: Tabs,
3269
- Tag: Tag,
3270
- Textarea: Textarea,
3271
- Tiny: Tiny,
3272
- Toolbox: Toolbox,
3273
- Tooltip: Tooltip
3274
- });
3275
-
3276
- const WebappSkin = {
3277
- colors: WebappSkin$1.color,
3278
- sizes: WebappSkin$1.sizing,
3279
- space: WebappSkin$1.spacing,
3280
- radii: WebappSkin$1.borderRadius,
3281
- borders: WebappSkin$1.borderWidth,
3282
- opacity: WebappSkin$1.opacity,
3283
- typography,
3284
- shadows: WebappSkin$1.boxShadow
3285
- };
3286
-
3287
- const TottSkin = {
3288
- colors: TottSkin$1.color,
3289
- sizes: TottSkin$1.sizing,
3290
- space: TottSkin$1.spacing,
3291
- radii: TottSkin$1.borderRadius,
3292
- borders: TottSkin$1.borderWidth,
3293
- opacity: TottSkin$1.opacity,
3294
- shadows: TottSkin$1.boxShadow,
3295
- typography
3296
- };
3297
-
3298
- const overrides = {
3299
- config: {
3300
- cssVarPrefix: ""
3301
- },
3302
- semanticTokens: {
3303
- colors: {
3304
- "chakra-body-text": {
3305
- _light: "text.default",
3306
- _dark: "text.inverted"
3307
- }
3308
- }
3309
- },
3310
- styles: {
3311
- global: {
3312
- html: {
3313
- "scroll-behavior": "smooth",
3314
- overflow: "scroll"
3315
- },
3316
- body: {
3317
- height: "100%"
3318
- },
3319
- "#app": {
3320
- height: "100%"
3321
- },
3322
- ...scrollbarStyles
3323
- }
3324
- },
3325
- fonts: {
3326
- heading: "Inter, sans-serif",
3327
- body: "Inter, sans-serif"
3328
- },
3329
- components: { ...components },
3330
- colors: palette,
3331
- zIndices: coreZIndex,
3332
- sizes: coreSizing,
3333
- space: coreSpacing,
3334
- fontWeights: coreFontWeight,
3335
- shadows: coreBoxShadow,
3336
- fontSizes: coreFontSize,
3337
- lineHeights: coreLineHeight,
3338
- radii: coreBorderRadius,
3339
- borderWidths: WebappSkin.borders
3340
- };
3341
- const theme = extendTheme(overrides, WebappSkin);
3342
- const tottTheme = extendTheme(overrides, TottSkin);
3343
-
3344
- const MediatoolThemeProvider = ({
3345
- children,
3346
- theme: theme$1 = theme,
3347
- themeName = "webappTheme"
3348
- }) => /* @__PURE__ */ React.createElement(ChakraProvider, { resetCSS: true, theme: theme$1 }, /* @__PURE__ */ React.createElement(CustomTheme.Provider, { value: themeName }, children));
3349
-
3350
- forwardRef$1(({
3351
- variant = "ghost",
3352
- icon,
3353
- "aria-label": ariaLabel,
3354
- hasNotification = false,
3355
- blinkerColor = "green.500",
3356
- size,
3357
- ...rest
3358
- }, ref) => {
3359
- const [isBlinking, setIsBlinking] = useState(false);
3360
- const { container, notifier } = useMultiStyleConfig("NotificationIconButton", { size, variant });
3361
- return /* @__PURE__ */ React.createElement(
3362
- Box,
3363
- {
3364
- onMouseEnter: () => setIsBlinking(true),
3365
- onMouseLeave: () => setIsBlinking(false),
3366
- sx: container
3367
- },
3368
- hasNotification && /* @__PURE__ */ React.createElement(Box, { sx: notifier }, /* @__PURE__ */ React.createElement(Blinker$1, { isBlinking, color: blinkerColor, size: "2xs" })),
3369
- /* @__PURE__ */ React.createElement(
3370
- IconButton,
3371
- {
3372
- variant,
3373
- icon,
3374
- "aria-label": ariaLabel,
3375
- ref,
3376
- size,
3377
- ...rest
3378
- }
3379
- )
3380
- );
3381
- });
3382
-
3383
- const Switch = ({
3384
- value,
3385
- onChange,
3386
- name,
3387
- size = "md",
3388
- ...rest
3389
- }) => /* @__PURE__ */ React.createElement(
3390
- Switch$3,
3391
- {
3392
- size,
3393
- id: name,
3394
- isChecked: value,
3395
- onChange,
3396
- ...rest
3397
- }
3398
- );
3399
-
3400
- forwardRef((props, ref) => {
3401
- const style = useStyleConfig("PaneDivider");
3402
- return /* @__PURE__ */ React.createElement(
3403
- Box,
3404
- {
3405
- ref,
3406
- sx: style,
3407
- ...props
3408
- }
3409
- );
3410
- });
3411
-
3412
- const MenuItem = ({ path, Icon: IconComponent, title }) => /* @__PURE__ */ React.createElement(
3413
- HStack,
3414
- {
3415
- pl: 2,
3416
- to: path,
3417
- as: NavLink,
3418
- borderRadius: 6,
3419
- _hover: { bgColor: "background.button.default-hover" },
3420
- _activeLink: { bgColor: "background.button.brand", color: "text.inverted" }
3421
- },
3422
- /* @__PURE__ */ React.createElement(HStack, { p: 2 }, /* @__PURE__ */ React.createElement(Icon$1, { as: IconComponent, boxSize: 6 }), /* @__PURE__ */ React.createElement(Label$1, { size: "md", sx: { color: "inherit", cursor: "pointer" } }, title))
3423
- );
3424
- const MainMenu = ({ menuItems }) => /* @__PURE__ */ React.createElement(Stack, { spacing: 2, mb: 6, color: "text.default", bgColor: "bg.layer" }, menuItems.map((item) => /* @__PURE__ */ React.createElement(MenuItem, { key: item.path, ...item })));
3425
-
3426
- const getBgColor = (currentTheme) => {
3427
- switch (currentTheme) {
3428
- case "webappTheme":
3429
- return "blue.100";
3430
- case "tottTheme":
3431
- return "blue.800";
3432
- default:
3433
- return "bg.filled";
3434
- }
3435
- };
3436
- const NavSideLink = ({
3437
- linkName,
3438
- isActive,
3439
- onClick,
3440
- linkProps
3441
- }) => {
3442
- const currentTheme = useCurrentTheme();
3443
- const bgColorHover = getBgColor(currentTheme);
3444
- const color = isActive ? "mono.white" : "text.default";
3445
- return /* @__PURE__ */ React.createElement(
3446
- Button$1,
3447
- {
3448
- p: "4",
3449
- _hover: { bgColor: isActive ? "bg.brand.default" : bgColorHover },
3450
- _active: { bgColor: "bg.brand.default" },
3451
- bgColor: isActive ? "bg.brand.default" : "transparent",
3452
- onClick,
3453
- display: "flex",
3454
- justifyContent: "start"
3455
- },
3456
- /* @__PURE__ */ React.createElement(LinkOverlay, { ...linkProps }, /* @__PURE__ */ React.createElement(P$1, { sx: { color, textAlign: "left" } }, linkName))
3457
- );
3458
- };
3459
-
3460
- const SubMenuItem = ({ path, title }) => {
3461
- const location = useLocation();
3462
- const isActive = location.pathname === path;
3463
- return /* @__PURE__ */ React.createElement(
3464
- NavSideLink,
3465
- {
3466
- linkName: title,
3467
- isActive,
3468
- linkProps: { to: path, as: NavLink }
3469
- }
3470
- );
3471
- };
3472
- const SubMenu = ({ mainRoutes }) => /* @__PURE__ */ React.createElement(
3473
- Stack,
3474
- {
3475
- color: "text.default",
3476
- overflow: "auto",
3477
- h: "calc(100vh - 320px)",
3478
- pr: 2,
3479
- bgColor: "bg.layer",
3480
- sx: {
3481
- "::-webkit-scrollbar": { display: "none" },
3482
- "::-webkit-scrollbar-thumb": { background: "blue.500" },
3483
- _hover: { "::-webkit-scrollbar": { display: "block" } }
3484
- }
3485
- },
3486
- /* @__PURE__ */ React.createElement(Switch$2, null, mainRoutes.map(({ path: mainPath, subItems = [] }) => /* @__PURE__ */ React.createElement(
3487
- Route,
3488
- {
3489
- key: mainPath,
3490
- path: mainPath,
3491
- render: () => subItems.map(({ path, ...rest }) => {
3492
- const subPath = `${mainPath}${path}`;
3493
- return /* @__PURE__ */ React.createElement(SubMenuItem, { key: path, path: subPath, ...rest });
3494
- })
3495
- }
3496
- )))
3497
- );
3498
-
3499
- const searchComponentsBarStyles = {
3500
- loadingIndicator: () => ({ display: "none" }),
3501
- control: (styles, { menuIsOpen, options }) => ({
3502
- ...styles,
3503
- _focusVisible: {},
3504
- border: "none",
3505
- p: "4",
3506
- width: "95%",
3507
- mx: "auto",
3508
- borderBottom: menuIsOpen && options.length > 0 ? `2px dashed ${palette.gray["100"]}` : "2px dashed transparent",
3509
- zIndex: "maxnus"
3510
- }),
3511
- menu: (styles) => ({
3512
- ...styles,
3513
- mb: "0",
3514
- mt: "-1"
3515
- }),
3516
- menuList: (styles) => ({
3517
- ...styles,
3518
- pt: "2",
3519
- pb: "16",
3520
- height: "auto",
3521
- maxHeight: "3xl",
3522
- borderTopLeftRadius: "0",
3523
- borderTopRightRadius: "0",
3524
- borderBottomLeftRadius: "md",
3525
- borderBottomRightRadius: "md",
3526
- border: "none",
3527
- bgColor: "background.default"
3528
- }),
3529
- option: (styles, { isFocused }) => {
3530
- const focusRing = isFocused && {
3531
- outline: "none",
3532
- ring: "2px",
3533
- ringColor: "border.wcag",
3534
- ringOffset: "1px"
3535
- };
3536
- const bgColor = isFocused ? "bg.brand.hover" : "bg.filled";
3537
- const color = getContrastColor(bgColor);
3538
- return {
3539
- ...styles,
3540
- mt: "4",
3541
- p: "4",
3542
- borderRadius: "md",
3543
- w: "90%",
3544
- mx: "auto",
3545
- transition: "none",
3546
- bgColor,
3547
- color,
3548
- fontWeight: "semibold",
3549
- ...focusRing
3550
- };
3551
- }
3552
- };
3553
-
3554
- const ComponentPageLink = ({ label }) => /* @__PURE__ */ React.createElement(HStack, { justifyContent: "space-between", w: "full" }, /* @__PURE__ */ React.createElement(Text, null, label), /* @__PURE__ */ React.createElement(Icon$1, { as: ArrowCircleRightDuo, size: "lg" }));
3555
-
3556
- const SearchComponentsBar = ({
3557
- routes
3558
- }) => {
3559
- const { isOpen, onOpen, onClose } = useDisclosure();
3560
- const history = useHistory();
3561
- const ref = useRef(null);
3562
- const handleKeyboardShortcut = (e) => {
3563
- if ((e.metaKey || e.ctrlKey) && e.key === "k") {
3564
- onOpen();
3565
- }
3566
- };
3567
- useEffect(() => {
3568
- window.addEventListener("keydown", handleKeyboardShortcut);
3569
- return () => {
3570
- window.removeEventListener("keydown", handleKeyboardShortcut);
3571
- };
3572
- }, []);
3573
- const options = chain(
3574
- (route) => defaultTo([], route.subItems).map((subRoute) => ({
3575
- value: `${route.path}${subRoute.path}`,
3576
- label: `${route.title} ${subRoute.title}`
3577
- })),
3578
- routes
3579
- );
3580
- const fuse = useMemo(
3581
- () => new Fuse(options, {
3582
- threshold: 0.2,
3583
- keys: ["label"]
3584
- }),
3585
- [options]
3586
- );
3587
- const handleChange = ({ value }) => {
3588
- history.push(`${value}`);
3589
- onClose();
3590
- };
3591
- const loadOptions = async (query) => map(prop("item"), fuse.search(query));
3592
- const handleKeyDown = (e) => {
3593
- if (e.key === "Escape") {
3594
- onClose();
3595
- }
3596
- };
3597
- return /* @__PURE__ */ React.createElement(Stack, { w: "full" }, /* @__PURE__ */ React.createElement(Card, { w: "full" }, /* @__PURE__ */ React.createElement(SearchBar, { placeholder: "Search", onMenuOpen: onOpen, variant: "filled" })), /* @__PURE__ */ React.createElement(
3598
- Modal$2,
3599
- {
3600
- isOpen,
3601
- onClose,
3602
- size: "4xl",
3603
- autoFocus: true,
3604
- initialFocusRef: ref
3605
- },
3606
- /* @__PURE__ */ React.createElement(ModalOverlay, null),
3607
- /* @__PURE__ */ React.createElement(ModalContent, null, /* @__PURE__ */ React.createElement(
3608
- SearchBar,
3609
- {
3610
- loadOptions,
3611
- debouncedWaitTime: 0,
3612
- closeMenuOnSelect: true,
3613
- onChange: handleChange,
3614
- ref,
3615
- sx: searchComponentsBarStyles,
3616
- customOption: ComponentPageLink,
3617
- noOptionsMessage: () => null,
3618
- loadingMessage: () => null,
3619
- onKeyDown: handleKeyDown,
3620
- placeholder: "Search for components, icons, styles...\u2282(\u2580\xAF\u2580\u2282 )"
3621
- }
3622
- ))
3623
- ));
3624
- };
3625
-
3626
- const users = {
3627
- "obi-wan": {
3628
- name: "Obi-Wan Kenobi",
3629
- country: "Germany",
3630
- image: `
3631
- https://www.gamereactor.se/media/08/redaxresonerar_3470803.jpg
3632
- `,
3633
- preferences: {
3634
- locale: "de-DE",
3635
- currency: "EUR",
3636
- firstDayOfWeek: "monday"
3637
- }
3638
- },
3639
- anakin: {
3640
- name: "Anakin Skywalker",
3641
- country: "US",
3642
- image: `
3643
- https://thenerdstash.com/wp-content/uploads/2021/10/Hayden-Christensen-Anakin-Skywalker.jpg
3644
- `,
3645
- preferences: {
3646
- locale: "en-US",
3647
- currency: "USD",
3648
- firstDayOfWeek: "sunday"
3649
- }
3650
- },
3651
- han: {
3652
- name: "Han Solo",
3653
- country: "Sweden",
3654
- image: `
3655
- https://fictionhorizon.com/wp-content/uploads/2021/09/Han-Solo.jpg
3656
- `,
3657
- preferences: {
3658
- locale: "sv-SE",
3659
- currency: "SEK",
3660
- firstDayOfWeek: "sunday"
3661
- }
3662
- },
3663
- yoda: {
3664
- name: "Yoda",
3665
- country: "England",
3666
- image: `
3667
- https://markerasomolast.files.wordpress.com/2013/08/yoda.jpg
3668
- `,
3669
- preferences: {
3670
- locale: "en-GB",
3671
- currency: "GBP",
3672
- firstDayOfWeek: "monday"
3673
- }
3674
- }
3675
- };
3676
- const UserContext = createContext(null);
3677
- const UserProvider = ({ children }) => {
3678
- const [user, setUser] = useState(users["obi-wan"]);
3679
- const contextValue = useMemo(() => ({
3680
- user,
3681
- setUser
3682
- }), [user]);
3683
- return /* @__PURE__ */ React.createElement(UserContext.Provider, { value: contextValue }, children);
3684
- };
3685
- const useUser = () => {
3686
- const context = useContext(UserContext);
3687
- if (!context) {
3688
- throw new Error("Cannot find <UserProvider> anywhere in your React tree");
3689
- }
3690
- return context;
3691
- };
3692
-
3693
- const I18nProvider = ({ children }) => {
3694
- const { user } = useUser();
3695
- const i18nManager = useMemo(() => {
3696
- const { preferences: { locale, currency } } = user;
3697
- return new I18nManager({
3698
- locale,
3699
- currency
3700
- });
3701
- }, [user]);
3702
- return /* @__PURE__ */ React.createElement(I18nContext.Provider, { value: i18nManager }, children);
3703
- };
3704
-
3705
- const CalendarProvider = ({ children }) => {
3706
- const { user: { preferences: { firstDayOfWeek = "monday" } } } = useUser();
3707
- const calendarLocale = firstDayOfWeek === "monday" ? "en-GB" : "en-US";
3708
- return /* @__PURE__ */ React.createElement(I18nProvider$1, { locale: calendarLocale }, children);
3709
- };
3710
-
3711
- const Sandbox = ({ routes }) => {
3712
- const [tott, setTott] = useState(false);
3713
- return /* @__PURE__ */ React.createElement(MediatoolThemeProvider, { theme: tott ? tottTheme : void 0, themeName: tott ? "tottTheme" : "webappTheme" }, /* @__PURE__ */ React.createElement(UserProvider, null, /* @__PURE__ */ React.createElement(CalendarProvider, null, /* @__PURE__ */ React.createElement(I18nProvider, null, /* @__PURE__ */ React.createElement(BrowserRouter, null, /* @__PURE__ */ React.createElement(
3714
- Grid,
3715
- {
3716
- height: "100vh",
3717
- minHeight: "100vh",
3718
- gridTemplateColumns: "280px auto",
3719
- color: "text.default",
3720
- bgColor: "background.default",
3721
- pl: 4
3722
- },
3723
- /* @__PURE__ */ React.createElement(
3724
- Flex,
3725
- {
3726
- direction: "column",
3727
- overflow: "auto"
3728
- },
3729
- /* @__PURE__ */ React.createElement(
3730
- Link$1,
3731
- {
3732
- as: Link$2,
3733
- to: "/components/",
3734
- sx: { _hover: { textDecoration: "none" }, _focus: { outline: "none" } }
3735
- },
3736
- /* @__PURE__ */ React.createElement(HStack, null, /* @__PURE__ */ React.createElement(Icon$1, { as: NorthlightLogoXs, mt: 4, ml: 2, boxSize: 16 }), /* @__PURE__ */ React.createElement(Capitalized$1, null, "Northlight"))
3737
- ),
3738
- /* @__PURE__ */ React.createElement(FormControl, { display: "flex", alignItems: "center", my: 2, pl: 2 }, /* @__PURE__ */ React.createElement(FormLabel, { htmlFor: "tott", mb: "0" }, "Dark theme"), /* @__PURE__ */ React.createElement(Switch, { id: "tott", onChange: () => setTott(!tott) })),
3739
- /* @__PURE__ */ React.createElement(MainMenu, { menuItems: routes }),
3740
- /* @__PURE__ */ React.createElement(SubMenu, { mainRoutes: routes })
3741
- ),
3742
- /* @__PURE__ */ React.createElement(Stack, { spacing: "5", pt: "4", height: "100vh" }, /* @__PURE__ */ React.createElement(Box, { ml: 10 }, /* @__PURE__ */ React.createElement(SearchComponentsBar, { routes })), /* @__PURE__ */ React.createElement(Routing, { fallback: head(routes)?.path, routes }))
3743
- ))))));
3744
- };
3745
-
3746
- export { LazyPage, MainMenu, Routing, Sandbox, SearchComponentsBar, SubMenu };
3747
- //# sourceMappingURL=sandbox.mjs.map