tw-react-components 0.0.164 → 0.0.166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -1
- package/index.esm.js +292 -255
- package/package.json +1 -1
- package/src/components/Badge/index.d.ts +1 -0
- package/src/components/Block/index.d.ts +1 -0
- package/src/components/Button/index.d.ts +1 -0
- package/src/components/Collapsible/index.d.ts +14 -3
- package/src/components/DataTable/index.d.ts +2 -1
- package/src/components/Dialog/ConfirmDialog.d.ts +1 -0
- package/src/components/Dialog/Dialog.d.ts +27 -9
- package/src/components/Dialog/FormDialog.d.ts +2 -1
- package/src/components/Dialog/ListSorterDialog.d.ts +2 -1
- package/src/components/Dialog/PdfViewerDialog.d.ts +1 -0
- package/src/components/DropdownMenu/index.d.ts +62 -29
- package/src/components/Form/controls/Label.d.ts +1 -0
- package/src/components/Form/controls/custom/date-time/DateSelector.d.ts +1 -0
- package/src/components/Form/controls/custom/date-time/DaysView.d.ts +1 -0
- package/src/components/Form/controls/custom/date-time/MonthsView.d.ts +1 -0
- package/src/components/Form/controls/custom/date-time/TimeSelector.d.ts +1 -0
- package/src/components/Form/controls/custom/date-time/YearsView.d.ts +1 -0
- package/src/components/Form/controls/custom/date-time/index.d.ts +1 -1
- package/src/components/Form/controls/custom/file.d.ts +1 -1
- package/src/components/Form/controls/custom/select/index.d.ts +2 -2
- package/src/components/Form/controls/primitive/BasicInput.d.ts +3 -1
- package/src/components/Hint/index.d.ts +7 -3
- package/src/components/Layout/index.d.ts +8 -9
- package/src/components/List/index.d.ts +34 -20
- package/src/components/ListSorter/index.d.ts +2 -1
- package/src/components/Navbar/index.d.ts +1 -0
- package/src/components/Pagination/index.d.ts +1 -0
- package/src/components/Popover/index.d.ts +4 -1
- package/src/components/Separator/index.d.ts +4 -1
- package/src/components/Sheet/index.d.ts +21 -5
- package/src/components/Sidebar/index.d.ts +107 -63
- package/src/components/Skeleton/index.d.ts +4 -1
- package/src/components/Spinner/index.d.ts +1 -0
- package/src/components/Switch/index.d.ts +2 -2
- package/src/components/Table/index.d.ts +30 -8
- package/src/components/Tabs/index.d.ts +18 -5
- package/src/components/ThemeSelector/index.d.ts +1 -0
- package/src/components/Tooltip/index.d.ts +1 -0
- package/src/helpers/getDisplayDate.d.ts +6 -1
- package/src/helpers/getValueFromCookie.d.ts +1 -1
- package/src/test-setup.d.ts +1 -0
package/index.esm.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
|
+
import 'dayjs/locale/en';
|
|
5
6
|
import advancedFormat from 'dayjs/plugin/advancedFormat.js';
|
|
6
7
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
7
8
|
import { HelpCircle, XIcon, AtSignIcon, EyeIcon, EyeOffIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronDownIcon, CalendarIcon, ClockIcon, CheckIcon, CircleIcon, CloudUploadIcon, ChevronsLeftIcon, ChevronsRightIcon, ChevronsDownUpIcon, ChevronsUpDownIcon, ArrowUpDownIcon, SortAscIcon, SortDescIcon, MinusIcon, PlusIcon, PanelLeft, MoonIcon, SunIcon, MonitorIcon } from 'lucide-react';
|
|
@@ -92,20 +93,22 @@ function generalComparator(a, b) {
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
dayjs.extend(advancedFormat);
|
|
95
|
-
function getDisplayDate(date, format, locale) {
|
|
96
|
-
|
|
96
|
+
function getDisplayDate(date, { format = 'YYYY-MM-DD HH:mm:ss', locale = 'en', offset = 0, }) {
|
|
97
|
+
const dateWithOffset = dayjs(date).add(offset, 'minutes');
|
|
98
|
+
return (locale ? dateWithOffset.locale(locale) : dateWithOffset).format(format);
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
function getValueFromCookie(key, _default) {
|
|
100
|
-
var _a
|
|
102
|
+
var _a;
|
|
101
103
|
const transformers = {
|
|
102
|
-
string: String,
|
|
103
|
-
|
|
104
|
+
string: (value) => String(value !== null && value !== void 0 ? value : _default),
|
|
105
|
+
number: (value) => parseInt(value !== null && value !== void 0 ? value : _default) || _default,
|
|
106
|
+
boolean: (value) => (value ? value === 'true' : _default),
|
|
104
107
|
};
|
|
105
108
|
return typeof window !== 'undefined'
|
|
106
|
-
? transformers[typeof _default]((
|
|
109
|
+
? transformers[typeof _default]((_a = window.document.cookie
|
|
107
110
|
.split('; ')
|
|
108
|
-
.find((row) => row.startsWith(key))) === null || _a === void 0 ? void 0 : _a.
|
|
111
|
+
.find((row) => row.startsWith(`${key}=`))) === null || _a === void 0 ? void 0 : _a.replace(`${key}=`, ''))
|
|
109
112
|
: _default;
|
|
110
113
|
}
|
|
111
114
|
|
|
@@ -561,33 +564,42 @@ const sizeClassNames = {
|
|
|
561
564
|
},
|
|
562
565
|
};
|
|
563
566
|
const Button = (_a) => {
|
|
564
|
-
var { children, className, size = 'medium', color = 'slate', variant = 'filled', rounded, prefixIcon: PrefixIcon, suffixIcon: SuffixIcon, unstyled } = _a, props = __rest(_a, ["children", "className", "size", "color", "variant", "rounded", "prefixIcon", "suffixIcon", "unstyled"]);
|
|
567
|
+
var { children, className, size = 'medium', color = 'slate', variant = 'filled', rounded, prefixIcon: PrefixIcon, suffixIcon: SuffixIcon, unstyled, dataTestId = 'button' } = _a, props = __rest(_a, ["children", "className", "size", "color", "variant", "rounded", "prefixIcon", "suffixIcon", "unstyled", "dataTestId"]);
|
|
565
568
|
return (jsxs("button", Object.assign({ className: cn('relative flex aspect-square items-center font-medium duration-200', sizeClassNames[size].base, variantClassNames[variant][color].base, rounded ? 'rounded-full' : 'rounded-md', props.disabled
|
|
566
569
|
? 'cursor-not-allowed opacity-50'
|
|
567
570
|
: !unstyled
|
|
568
571
|
? `${variantClassNames[variant][color].hover} ${variantClassNames[variant][color].focus} ${variantClassNames[variant][color].active}`
|
|
569
|
-
: 'cursor-default', children ? `${sizeClassNames[size].withChildren} aspect-[initial]` : 'justify-center', className), type: "button" }, props, { children: [PrefixIcon && (jsx(PrefixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base })), children, SuffixIcon && (jsx(SuffixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base }))] })));
|
|
572
|
+
: 'cursor-default', children ? `${sizeClassNames[size].withChildren} aspect-[initial]` : 'justify-center', className), "data-testid": dataTestId, type: "button" }, props, { children: [PrefixIcon && (jsx(PrefixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base })), children, SuffixIcon && (jsx(SuffixIcon, { className: children ? sizeClassNames[size].icon.withChildren : sizeClassNames[size].icon.base }))] })));
|
|
570
573
|
};
|
|
571
574
|
|
|
572
575
|
const Badge = (_a) => {
|
|
573
|
-
var { size = 'small' } = _a, props = __rest(_a, ["size"]);
|
|
574
|
-
return (jsx(Button, Object.assign({ size: size }, props)));
|
|
576
|
+
var { size = 'small', dataTestId = 'badge' } = _a, props = __rest(_a, ["size", "dataTestId"]);
|
|
577
|
+
return (jsx(Button, Object.assign({ size: size, dataTestId: dataTestId }, props)));
|
|
575
578
|
};
|
|
576
579
|
|
|
577
580
|
const Block = (_a) => {
|
|
578
|
-
var { children, className, centered, container, fullWidth, fullHeight } = _a, props = __rest(_a, ["children", "className", "centered", "container", "fullWidth", "fullHeight"]);
|
|
579
|
-
return (jsx("div", Object.assign({ className: cn(centered && 'mx-auto', container && 'container', fullWidth && 'w-full', fullHeight && 'h-full', className) }, props, { children: children })));
|
|
581
|
+
var { children, className, centered, container, fullWidth, fullHeight, dataTestId = 'block' } = _a, props = __rest(_a, ["children", "className", "centered", "container", "fullWidth", "fullHeight", "dataTestId"]);
|
|
582
|
+
return (jsx("div", Object.assign({ "data-testid": dataTestId, className: cn(centered && 'mx-auto', container && 'container', fullWidth && 'w-full', fullHeight && 'h-full', className) }, props, { children: children })));
|
|
580
583
|
};
|
|
581
584
|
|
|
582
585
|
const Card = (_a) => {
|
|
583
|
-
var { children, className } = _a, blockProps = __rest(_a, ["children", "className"]);
|
|
584
|
-
return (jsx(Block, Object.assign({ className: cn('rounded-lg border p-2 dark:border-slate-700 dark:bg-slate-900', className) }, blockProps, { children: children })));
|
|
586
|
+
var { children, className, dataTestId = 'card' } = _a, blockProps = __rest(_a, ["children", "className", "dataTestId"]);
|
|
587
|
+
return (jsx(Block, Object.assign({ className: cn('rounded-lg border p-2 dark:border-slate-700 dark:bg-slate-900', className), dataTestId: dataTestId }, blockProps, { children: children })));
|
|
585
588
|
};
|
|
586
589
|
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
590
|
+
const CollapsibleRoot = (_a) => {
|
|
591
|
+
var { dataTestId = 'collapsible' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
592
|
+
return (jsx(CollapsiblePrimitive.Root, Object.assign({ "data-testid": dataTestId }, props)));
|
|
593
|
+
};
|
|
594
|
+
const CollapsibleTrigger = (_a) => {
|
|
595
|
+
var { dataTestId = 'collapsible-trigger' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
596
|
+
return jsx(CollapsiblePrimitive.Trigger, Object.assign({ "data-testid": dataTestId }, props));
|
|
597
|
+
};
|
|
598
|
+
const CollapsibleContent = (_a) => {
|
|
599
|
+
var { dataTestId = 'collapsible-content' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
600
|
+
return jsx(CollapsiblePrimitive.Content, Object.assign({ "data-testid": dataTestId }, props));
|
|
601
|
+
};
|
|
602
|
+
const Collapsible = Object.assign(CollapsibleRoot, {
|
|
591
603
|
Trigger: CollapsibleTrigger,
|
|
592
604
|
Content: CollapsibleContent,
|
|
593
605
|
});
|
|
@@ -614,8 +626,8 @@ const justifyClasses = {
|
|
|
614
626
|
end: 'justify-end',
|
|
615
627
|
};
|
|
616
628
|
const Flex = (_a) => {
|
|
617
|
-
var { children, className, reverse, wrap, direction = 'row', align = 'start', justify = 'start' } = _a, blockProps = __rest(_a, ["children", "className", "reverse", "wrap", "direction", "align", "justify"]);
|
|
618
|
-
return (jsx(Block, Object.assign({ className: cn('flex gap-2', wrap && 'flex-wrap', directionClasses[direction][reverse ? 'reverse' : 'normal'], alignClasses[align], justifyClasses[justify], className) }, blockProps, { children: children })));
|
|
629
|
+
var { children, className, reverse, wrap, direction = 'row', align = 'start', justify = 'start', dataTestId = 'flex' } = _a, blockProps = __rest(_a, ["children", "className", "reverse", "wrap", "direction", "align", "justify", "dataTestId"]);
|
|
630
|
+
return (jsx(Block, Object.assign({ className: cn('flex gap-2', wrap && 'flex-wrap', directionClasses[direction][reverse ? 'reverse' : 'normal'], alignClasses[align], justifyClasses[justify], className), dataTestId: dataTestId }, blockProps, { children: children })));
|
|
619
631
|
};
|
|
620
632
|
|
|
621
633
|
dayjs.extend(localeData);
|
|
@@ -736,7 +748,7 @@ function useOutsideClick(ref, callback) {
|
|
|
736
748
|
function usePagination(currentIndex, totalPages) {
|
|
737
749
|
return useMemo(() => {
|
|
738
750
|
const result = [];
|
|
739
|
-
result.push(currentIndex);
|
|
751
|
+
result.push(Math.min(currentIndex, totalPages));
|
|
740
752
|
if (totalPages > 7 && currentIndex > 4) {
|
|
741
753
|
for (let index = currentIndex - 1; index >= Math.min(totalPages - 4, currentIndex - 1); index--) {
|
|
742
754
|
result.push(index);
|
|
@@ -745,7 +757,7 @@ function usePagination(currentIndex, totalPages) {
|
|
|
745
757
|
result.push(1);
|
|
746
758
|
}
|
|
747
759
|
else {
|
|
748
|
-
for (let index = currentIndex - 1; index > 0; index--) {
|
|
760
|
+
for (let index = Math.min(currentIndex, totalPages) - 1; index > 0; index--) {
|
|
749
761
|
result.push(index);
|
|
750
762
|
}
|
|
751
763
|
}
|
|
@@ -766,13 +778,13 @@ function usePagination(currentIndex, totalPages) {
|
|
|
766
778
|
}, [currentIndex, totalPages]);
|
|
767
779
|
}
|
|
768
780
|
|
|
769
|
-
const Tooltip = ({ children, className, content, asChild, placement }) => (jsx(TooltipPrimitive.Provider, { delayDuration: 200, children: jsxs(TooltipPrimitive.Root, { children: [jsx(TooltipPrimitive.Trigger, { asChild: asChild, children: children }), jsx(TooltipPrimitive.Portal, { children: jsx(TooltipPrimitive.Content, { className: cn('animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-[101] overflow-hidden rounded-md border bg-white px-3 py-1.5 text-sm shadow-md dark:border-slate-700 dark:bg-slate-800 dark:text-white', className), side: placement, sideOffset: 5, children: content }) })] }) }));
|
|
781
|
+
const Tooltip = ({ children, className, content, asChild, placement, dataTestId = 'tooltip', }) => (jsx(TooltipPrimitive.Provider, { delayDuration: 200, children: jsxs(TooltipPrimitive.Root, { children: [jsx(TooltipPrimitive.Trigger, { asChild: asChild, "data-testid": `${dataTestId}-trigger`, children: children }), jsx(TooltipPrimitive.Portal, { children: jsx(TooltipPrimitive.Content, { className: cn('animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-[101] overflow-hidden rounded-md border bg-white px-3 py-1.5 text-sm shadow-md dark:border-slate-700 dark:bg-slate-800 dark:text-white', className), side: placement, sideOffset: 5, "data-testid": `${dataTestId}-content`, children: content }) })] }) }));
|
|
770
782
|
|
|
771
|
-
const Label = ({ children, className, description, required, hasErrors, htmlFor, }) => {
|
|
783
|
+
const Label = ({ children, className, description, required, hasErrors, htmlFor, dataTestId = 'label', }) => {
|
|
772
784
|
return !children ? null : (jsxs("label", { className: cn('flex items-center gap-1 font-medium', {
|
|
773
785
|
'text-slate-700 dark:text-slate-100': !hasErrors,
|
|
774
786
|
'text-red-600 dark:text-red-500': hasErrors,
|
|
775
|
-
}, className), htmlFor: htmlFor, children: [children, description && (jsx(Tooltip, { content: jsx("div", { className: "max-w-xs", children: description }), placement: "top", asChild: true, children: jsx(HelpCircle, { className: "h-4 w-4" }) })), required && jsx("span", { className: "text-red-600", children: "*" })] }));
|
|
787
|
+
}, className), htmlFor: htmlFor, "data-testid": dataTestId, children: [children, description && (jsx(Tooltip, { content: jsx("div", { className: "max-w-xs", children: description }), placement: "top", asChild: true, dataTestId: `${dataTestId}-description-tooltip`, children: jsx(HelpCircle, { className: "h-4 w-4", "data-testid": `${dataTestId}-description-tooltip-icon` }) })), required && jsx("span", { className: "text-red-600", children: "*" })] }));
|
|
776
788
|
};
|
|
777
789
|
|
|
778
790
|
const inputClasses = {
|
|
@@ -824,16 +836,16 @@ const sizeClasses = {
|
|
|
824
836
|
},
|
|
825
837
|
};
|
|
826
838
|
const BasicInput = (_a) => {
|
|
827
|
-
var { className, inputClassName, extensionClassName, type = 'text', label, description, size = 'medium', hasErrors, clearable, suffixIcon: SuffixIcon, onClear, onSuffixIconClick } = _a, props = __rest(_a, ["className", "inputClassName", "extensionClassName", "type", "label", "description", "size", "hasErrors", "clearable", "suffixIcon", "onClear", "onSuffixIconClick"]);
|
|
839
|
+
var { className, inputClassName, extensionClassName, type = 'text', label, description, size = 'medium', hasErrors, clearable, suffixIcon: SuffixIcon, onClear, onSuffixIconClick, dataTestId = 'basic-input' } = _a, props = __rest(_a, ["className", "inputClassName", "extensionClassName", "type", "label", "description", "size", "hasErrors", "clearable", "suffixIcon", "onClear", "onSuffixIconClick", "dataTestId"]);
|
|
828
840
|
const id = useId();
|
|
829
|
-
const memoLabel = useMemo(() => label && (jsx(Label, { className: sizeClasses[size].label, htmlFor: id, description: description, required: props.required, hasErrors: hasErrors, children: label })), [description, hasErrors, id, label, props.required, size]);
|
|
841
|
+
const memoLabel = useMemo(() => label && (jsx(Label, { className: sizeClasses[size].label, htmlFor: id, description: description, required: props.required, hasErrors: hasErrors, dataTestId: `${dataTestId}-label`, children: label })), [description, hasErrors, id, label, props.required, size, dataTestId]);
|
|
830
842
|
const handleClear = (event) => {
|
|
831
843
|
var _a;
|
|
832
844
|
event.stopPropagation();
|
|
833
845
|
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
834
846
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, { target: { value: '', checked: false } });
|
|
835
847
|
};
|
|
836
|
-
return (jsxs("div", { className: cn('w-full dark:text-white', className), children: [type !== 'checkbox' && memoLabel, jsxs("div", { className: cn('group relative flex', {
|
|
848
|
+
return (jsxs("div", { className: cn('w-full dark:text-white', className), "data-testid": dataTestId, children: [type !== 'checkbox' && memoLabel, jsxs("div", { className: cn('group relative flex', {
|
|
837
849
|
'mt-1': label && type !== 'checkbox',
|
|
838
850
|
[`items-center ${sizeClasses[size].checkbox.wrapper}`]: type === 'checkbox',
|
|
839
851
|
}), title: type !== 'textarea' && typeof props.value === 'string' ? props.value : undefined, children: [type === 'textarea' ? (jsx("textarea", Object.assign({ id: id, className: cn(inputClasses.base.input, sizeClasses[size].input.replace(/ h-\d/g, ''), {
|
|
@@ -841,47 +853,60 @@ const BasicInput = (_a) => {
|
|
|
841
853
|
[inputClasses.withoutErrors.input]: !hasErrors,
|
|
842
854
|
[inputClasses.withErrors.input]: hasErrors,
|
|
843
855
|
'rounded-r-none border-r-0': SuffixIcon,
|
|
844
|
-
}, inputClassName) }, props, { value: props.value }))) : type === 'checkbox' ? (jsx("input", Object.assign({ id: id, className: cn('rounded border-slate-300 text-blue-600', sizeClasses[size].checkbox.input, {
|
|
856
|
+
}, inputClassName) }, props, { value: props.value, "data-testid": `${dataTestId}-textarea` }))) : type === 'checkbox' ? (jsx("input", Object.assign({ id: id, className: cn('rounded border-slate-300 text-blue-600', sizeClasses[size].checkbox.input, {
|
|
845
857
|
[inputClasses.base.disabled]: props.disabled,
|
|
846
858
|
'bg-red-100': hasErrors,
|
|
847
|
-
}, inputClassName), type: type, checked: Boolean(props.value) }, props))) : (jsx("input", Object.assign({ id: id, className: cn(inputClasses.base.input, sizeClasses[size].input, {
|
|
859
|
+
}, inputClassName), type: type, checked: Boolean(props.value) }, props, { "data-testid": `${dataTestId}-checkbox` }))) : (jsx("input", Object.assign({ id: id, className: cn(inputClasses.base.input, sizeClasses[size].input, {
|
|
848
860
|
[inputClasses.base.disabled]: props.disabled,
|
|
849
861
|
[inputClasses.withoutErrors.input]: !hasErrors,
|
|
850
862
|
[inputClasses.withErrors.input]: hasErrors,
|
|
851
863
|
'rounded-r-none border-r-0': SuffixIcon,
|
|
852
|
-
}, inputClassName), type: type !== null && type !== void 0 ? type : 'text' }, props, { value: props.value }))), type === 'checkbox' && memoLabel, clearable && (onClear || !!props.value) && !props.disabled && (jsx(XIcon, { className: cn('absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer rounded-full bg-white p-0.5 opacity-0 duration-200 hover:bg-slate-200 group-hover:opacity-100 dark:bg-slate-700 dark:hover:bg-slate-800', sizeClasses[size].clearButton.base, {
|
|
864
|
+
}, inputClassName), type: type !== null && type !== void 0 ? type : 'text' }, props, { value: props.value, "data-testid": `${dataTestId}-input` }))), type === 'checkbox' && memoLabel, clearable && (onClear || !!props.value) && !props.disabled && (jsx(XIcon, { className: cn('absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer rounded-full bg-white p-0.5 opacity-0 duration-200 hover:bg-slate-200 group-hover:opacity-100 dark:bg-slate-700 dark:hover:bg-slate-800', sizeClasses[size].clearButton.base, {
|
|
853
865
|
[sizeClasses[size].clearButton.withSuffixIcon]: SuffixIcon,
|
|
854
|
-
}), onClick: handleClear, onPointerDown: (event) => event.stopPropagation() })), type !== 'checkbox' && SuffixIcon && (jsx(BasicInputExtension, { className: extensionClassName, hasErrors: hasErrors, size: size, disabled: props.disabled, onClick: onSuffixIconClick, children: jsx(SuffixIcon, { className: sizeClasses[size].suffix.icon }) }))] })] }));
|
|
866
|
+
}), onClick: handleClear, onPointerDown: (event) => event.stopPropagation(), "data-testid": `${dataTestId}-clear` })), type !== 'checkbox' && SuffixIcon && (jsx(BasicInputExtension, { className: extensionClassName, hasErrors: hasErrors, size: size, disabled: props.disabled, onClick: onSuffixIconClick, dataTestId: `${dataTestId}-suffix`, children: jsx(SuffixIcon, { className: sizeClasses[size].suffix.icon }) }))] })] }));
|
|
855
867
|
};
|
|
856
|
-
const BasicInputExtension = ({ children, className, size, hasErrors, disabled, onClick }) => (jsx("div", { className: cn('flex aspect-square items-center justify-center rounded-r-md border border-l-0', sizeClasses[size].suffix.wrapper, {
|
|
868
|
+
const BasicInputExtension = ({ children, className, size, hasErrors, disabled, onClick, dataTestId }) => (jsx("div", { className: cn('flex aspect-square items-center justify-center rounded-r-md border border-l-0', sizeClasses[size].suffix.wrapper, {
|
|
857
869
|
[inputClasses.base.disabled]: disabled,
|
|
858
870
|
[inputClasses.withoutErrors.extension]: !hasErrors,
|
|
859
871
|
[inputClasses.withErrors.extension]: hasErrors,
|
|
860
872
|
'cursor-pointer': onClick,
|
|
861
|
-
}, className), onClick: !disabled ? onClick : undefined, onPointerDown: (event) => event.stopPropagation(), children: children }));
|
|
873
|
+
}, className), onClick: !disabled ? onClick : undefined, onPointerDown: (event) => event.stopPropagation(), "data-testid": dataTestId, children: children }));
|
|
862
874
|
|
|
863
|
-
const CheckboxInput = (
|
|
875
|
+
const CheckboxInput = (_a) => {
|
|
876
|
+
var { dataTestId = 'checkbox-input' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
877
|
+
return jsx(BasicInput, Object.assign({ type: "checkbox", dataTestId: dataTestId }, props));
|
|
878
|
+
};
|
|
864
879
|
|
|
865
|
-
const EmailInput = (
|
|
880
|
+
const EmailInput = (_a) => {
|
|
881
|
+
var { dataTestId = 'email-input' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
882
|
+
return (jsx(BasicInput, Object.assign({ type: "email", dataTestId: dataTestId }, props, { suffixIcon: AtSignIcon })));
|
|
883
|
+
};
|
|
866
884
|
|
|
867
885
|
const NumberInput = (_a) => {
|
|
868
|
-
var { unit } = _a, props = __rest(_a, ["unit"]);
|
|
869
|
-
return (jsx(BasicInput, Object.assign({ type: "number", inputClassName: cn(props.clearable && !!props.value && 'pr-8', props.className) }, props, { suffixIcon: unit
|
|
886
|
+
var { unit, dataTestId = 'number-input' } = _a, props = __rest(_a, ["unit", "dataTestId"]);
|
|
887
|
+
return (jsx(BasicInput, Object.assign({ type: "number", inputClassName: cn(props.clearable && !!props.value && 'pr-8', props.className), dataTestId: dataTestId }, props, { suffixIcon: unit
|
|
870
888
|
? ({ className }) => (jsx("div", { className: cn(className, 'flex w-min items-center'), onClick: props.onSuffixIconClick, children: unit }))
|
|
871
889
|
: props.suffixIcon })));
|
|
872
890
|
};
|
|
873
891
|
|
|
874
|
-
const PasswordInput = (
|
|
892
|
+
const PasswordInput = (_a) => {
|
|
893
|
+
var { dataTestId = 'password-input' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
875
894
|
const [type, setType] = useState('password');
|
|
876
895
|
const toggleType = () => setType((type) => (type === 'text' ? 'password' : 'text'));
|
|
877
|
-
return (jsx(BasicInput, Object.assign({ type: type }, props, { suffixIcon: type === 'password' ? EyeIcon : EyeOffIcon, onSuffixIconClick: toggleType })));
|
|
896
|
+
return (jsx(BasicInput, Object.assign({ type: type, dataTestId: dataTestId }, props, { suffixIcon: type === 'password' ? EyeIcon : EyeOffIcon, onSuffixIconClick: toggleType })));
|
|
878
897
|
};
|
|
879
898
|
|
|
880
|
-
const TextareaInput = (
|
|
899
|
+
const TextareaInput = (_a) => {
|
|
900
|
+
var { dataTestId = 'textarea-input' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
901
|
+
return jsx(BasicInput, Object.assign({ type: "textarea", dataTestId: dataTestId }, props));
|
|
902
|
+
};
|
|
881
903
|
|
|
882
|
-
const TextInput = (
|
|
904
|
+
const TextInput = (_a) => {
|
|
905
|
+
var { dataTestId = 'text-input' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
906
|
+
return (jsx(BasicInput, Object.assign({ type: "text", dataTestId: dataTestId }, props)));
|
|
907
|
+
};
|
|
883
908
|
|
|
884
|
-
const DaysView = ({ date, value, month, year, minDate, maxDate, locale, setNewDate, }) => {
|
|
909
|
+
const DaysView = ({ date, value, month, year, minDate, maxDate, locale, dataTestId = 'days-view', setNewDate, }) => {
|
|
885
910
|
const days = useDays(locale);
|
|
886
911
|
const monthDays = useMemo(() => {
|
|
887
912
|
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
|
@@ -938,9 +963,9 @@ const DaysView = ({ date, value, month, year, minDate, maxDate, locale, setNewDa
|
|
|
938
963
|
}
|
|
939
964
|
setNewDate(newDate);
|
|
940
965
|
}, [date, maxDate, minDate, month, setNewDate, year]);
|
|
941
|
-
return (jsxs("div", { className: "gap-1 px-3 py-2", children: [jsx("div", { className: "grid grid-cols-7", children: days.map((day, index) => (jsx("span", { className: "flex h-8 w-8 items-center justify-center text-xs uppercase text-slate-500 dark:text-slate-400", children: day.shortName }, index))) }), jsxs("div", { className: "grid grid-cols-7 gap-1", children: [prefixDays.map((dayNumber, index) => (jsx(Day, { value: value, day: dayNumber, month: (month - 1 + 12) % 12, year: month % 12 ? year : year - 1, minDate: minDate, maxDate: maxDate, setDayNumber: setDayNumber }, `${dayNumber}-${index}`))), monthDays.map((dayNumber, index) => (jsx(Day, { value: value, day: dayNumber, month: month, year: year, minDate: minDate, maxDate: maxDate, primary: true, setDayNumber: setDayNumber }, `${dayNumber}-${index}`))), suffixDays.map((dayNumber, index) => (jsx(Day, { value: value, day: dayNumber, month: (month + 1) % 12, year: (month + 1) % 12 ? year : year + 1, minDate: minDate, maxDate: maxDate, setDayNumber: setDayNumber }, `${dayNumber}-${index}`)))] })] }));
|
|
966
|
+
return (jsxs("div", { className: "gap-1 px-3 py-2", "data-testid": dataTestId, children: [jsx("div", { className: "grid grid-cols-7", children: days.map((day, index) => (jsx("span", { className: "flex h-8 w-8 items-center justify-center text-xs uppercase text-slate-500 dark:text-slate-400", "data-testid": `${dataTestId}-weekday-${index}`, children: day.shortName }, index))) }), jsxs("div", { className: "grid grid-cols-7 gap-1", children: [prefixDays.map((dayNumber, index) => (jsx(Day, { value: value, day: dayNumber, month: (month - 1 + 12) % 12, year: month % 12 ? year : year - 1, minDate: minDate, maxDate: maxDate, setDayNumber: setDayNumber, dataTestId: dataTestId }, `${dayNumber}-${index}`))), monthDays.map((dayNumber, index) => (jsx(Day, { value: value, day: dayNumber, month: month, year: year, minDate: minDate, maxDate: maxDate, primary: true, setDayNumber: setDayNumber, dataTestId: dataTestId }, `${dayNumber}-${index}`))), suffixDays.map((dayNumber, index) => (jsx(Day, { value: value, day: dayNumber, month: (month + 1) % 12, year: (month + 1) % 12 ? year : year + 1, minDate: minDate, maxDate: maxDate, setDayNumber: setDayNumber, dataTestId: dataTestId }, `${dayNumber}-${index}`)))] })] }));
|
|
942
967
|
};
|
|
943
|
-
const Day = ({ value, day, month, year, minDate, maxDate, primary, setDayNumber, }) => {
|
|
968
|
+
const Day = ({ value, day, month, year, minDate, maxDate, primary, dataTestId = 'day', setDayNumber, }) => {
|
|
944
969
|
const dayDate = useMemo(() => new Date(year, month, day), [day, month, year]);
|
|
945
970
|
const isSelectable = useMemo(() => (!minDate || compareDates(dayDate, new Date(minDate), 'day') >= 0) &&
|
|
946
971
|
(!maxDate || compareDates(dayDate, new Date(maxDate), 'day') <= 0), [minDate, dayDate, maxDate]);
|
|
@@ -952,14 +977,14 @@ const Day = ({ value, day, month, year, minDate, maxDate, primary, setDayNumber,
|
|
|
952
977
|
'cursor-pointer': isSelectable,
|
|
953
978
|
'hover:bg-blue-100 dark:hover:bg-blue-800': isSelectable && !isSelected,
|
|
954
979
|
'text-slate-400 dark:text-slate-500': !isSelectable || !primary,
|
|
955
|
-
}), onClick: isSelectable ? setDayNumber(day, month, year) : undefined, children: day }));
|
|
980
|
+
}), onClick: isSelectable ? setDayNumber(day, month, year) : undefined, "data-testid": `${dataTestId}-day-${day}`, children: day }));
|
|
956
981
|
};
|
|
957
982
|
|
|
958
|
-
const MonthsView = ({ date, value, year, minDate, maxDate, locale, selectMonth, }) => {
|
|
983
|
+
const MonthsView = ({ date, value, year, minDate, maxDate, locale, selectMonth, dataTestId = 'months-view', }) => {
|
|
959
984
|
const months = useMonths(locale);
|
|
960
|
-
return (jsx("div", { className: "grid grid-cols-4 gap-1 px-3 py-2", children: months.map((month, index) => (jsx(Month, { date: date, value: value, shortName: month.shortName, month: index, year: year, minDate: minDate, maxDate: maxDate, selectMonth: selectMonth }, index))) }));
|
|
985
|
+
return (jsx("div", { className: "grid grid-cols-4 gap-1 px-3 py-2", "data-testid": dataTestId, children: months.map((month, index) => (jsx(Month, { date: date, value: value, shortName: month.shortName, month: index, year: year, minDate: minDate, maxDate: maxDate, selectMonth: selectMonth, dataTestId: dataTestId }, index))) }));
|
|
961
986
|
};
|
|
962
|
-
const Month = ({ date, value, shortName, month, year, minDate, maxDate, selectMonth, }) => {
|
|
987
|
+
const Month = ({ date, value, shortName, month, year, minDate, maxDate, dataTestId = 'month', selectMonth, }) => {
|
|
963
988
|
const dayDate = useMemo(() => new Date(year, month, date.getDate(), date.getHours(), date.getMinutes()), [date, month, year]);
|
|
964
989
|
const isSelectable = useMemo(() => (!minDate || compareDates(dayDate, new Date(minDate), 'month') >= 0) &&
|
|
965
990
|
(!maxDate || compareDates(dayDate, new Date(maxDate), 'month') <= 0), [dayDate, minDate, maxDate]);
|
|
@@ -972,11 +997,11 @@ const Month = ({ date, value, shortName, month, year, minDate, maxDate, selectMo
|
|
|
972
997
|
'cursor-pointer': isSelectable,
|
|
973
998
|
'hover:bg-blue-100 dark:hover:bg-blue-900': isSelectable && !isSelected,
|
|
974
999
|
'text-slate-400 dark:text-slate-500': !isSelectable,
|
|
975
|
-
}), onClick: isSelectable ? selectMonth(month) : undefined, children: shortName }));
|
|
1000
|
+
}), onClick: isSelectable ? selectMonth(month) : undefined, "data-testid": `${dataTestId}-month-${month}`, children: shortName }));
|
|
976
1001
|
};
|
|
977
1002
|
|
|
978
|
-
const YearsView = ({ date, value, years, minDate, maxDate, selectYear, }) => (jsx("div", { className: "grid grid-cols-4 gap-1 px-3 py-2", children: years.map((year, index) => (jsx(Year, { date: date, value: value, year: year, minDate: minDate, maxDate: maxDate, selectYear: selectYear }, index))) }));
|
|
979
|
-
const Year = ({ date, value, year, minDate, maxDate, selectYear }) => {
|
|
1003
|
+
const YearsView = ({ date, value, years, minDate, maxDate, selectYear, dataTestId = 'years-view', }) => (jsx("div", { className: "grid grid-cols-4 gap-1 px-3 py-2", "data-testid": dataTestId, children: years.map((year, index) => (jsx(Year, { date: date, value: value, year: year, minDate: minDate, maxDate: maxDate, selectYear: selectYear, dataTestId: dataTestId }, index))) }));
|
|
1004
|
+
const Year = ({ date, value, year, minDate, maxDate, dataTestId = 'year', selectYear, }) => {
|
|
980
1005
|
const dayDate = useMemo(() => new Date(year, date.getMonth(), date.getDate(), date.getHours(), date.getMinutes()), [date, year]);
|
|
981
1006
|
const isSelectable = useMemo(() => (!minDate || compareDates(dayDate, new Date(minDate), 'year') >= 0) &&
|
|
982
1007
|
(!maxDate || compareDates(dayDate, new Date(maxDate), 'year') <= 0), [dayDate, minDate, maxDate]);
|
|
@@ -989,10 +1014,10 @@ const Year = ({ date, value, year, minDate, maxDate, selectYear }) => {
|
|
|
989
1014
|
'cursor-pointer': isSelectable,
|
|
990
1015
|
'hover:bg-blue-100 dark:hover:bg-blue-900': isSelectable && !isSelected,
|
|
991
1016
|
'text-slate-400 dark:text-slate-500': !isSelectable,
|
|
992
|
-
}), onClick: isSelectable ? selectYear(year) : undefined, children: year }));
|
|
1017
|
+
}), onClick: isSelectable ? selectYear(year) : undefined, "data-testid": `${dataTestId}-year-${year}`, children: year }));
|
|
993
1018
|
};
|
|
994
1019
|
|
|
995
|
-
const DateSelector = ({ date, value, minDate, maxDate, locale, calendarView, setCalendarView, setNewDate, }) => {
|
|
1020
|
+
const DateSelector = ({ date, value, minDate, maxDate, locale, calendarView, setCalendarView, setNewDate, dataTestId = 'date-selector', }) => {
|
|
996
1021
|
const months = useMonths(locale);
|
|
997
1022
|
const [month, setMonth] = useState(date.getMonth());
|
|
998
1023
|
const [year, setYear] = useState(date.getFullYear());
|
|
@@ -1051,10 +1076,10 @@ const DateSelector = ({ date, value, minDate, maxDate, locale, calendarView, set
|
|
|
1051
1076
|
setYear(year);
|
|
1052
1077
|
setCalendarView('months');
|
|
1053
1078
|
};
|
|
1054
|
-
return (jsxs("div", { className: "select-none", children: [jsxs("div", { className: "flex justify-between px-3 pt-2", children: [jsx("div", { className: "flex cursor-pointer items-center justify-center rounded-lg px-1 transition duration-100 ease-in-out hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:bg-slate-700", onClick: editCalendarViewPage('subtract'), children: jsx(ChevronLeftIcon, { className: "h-5 w-5 text-slate-400" }) }), jsxs("div", { className: "flex cursor-pointer items-center gap-1 rounded px-2 py-1 transition duration-100 ease-in-out hover:bg-slate-100 dark:hover:bg-slate-700", onClick: nextCalendarView, children: [calendarView === 'days' && jsx("span", { className: "capitalize", children: months[month].name }), calendarView !== 'years' ? (jsx("span", { className: "text-slate-500 dark:text-slate-300", children: year })) : (jsxs("span", { className: "text-slate-500 dark:text-slate-300", children: [yearsRange[0], " - ", yearsRange[11]] }))] }), jsx("div", { className: "flex cursor-pointer items-center justify-center rounded-lg px-1 transition duration-100 ease-in-out hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:bg-slate-700", onClick: editCalendarViewPage('add'), children: jsx(ChevronRightIcon, { className: "h-5 w-5 text-slate-400" }) })] }), calendarView === 'days' ? (jsx(DaysView, { date: date, value: value, month: month, year: year, minDate: minDate, maxDate: maxDate, locale: locale, setNewDate: setNewDate })) : calendarView === 'months' ? (jsx(MonthsView, { date: date, value: value, year: year, minDate: minDate, maxDate: maxDate, locale: locale, selectMonth: selectMonth })) : (jsx(YearsView, { date: date, value: value, years: yearsRange, minDate: minDate, maxDate: maxDate, selectYear: selectYear }))] }));
|
|
1079
|
+
return (jsxs("div", { className: "select-none", "data-testid": dataTestId, children: [jsxs("div", { className: "flex justify-between px-3 pt-2", children: [jsx("div", { className: "flex cursor-pointer items-center justify-center rounded-lg px-1 transition duration-100 ease-in-out hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:bg-slate-700", onClick: editCalendarViewPage('subtract'), "data-testid": `${dataTestId}-prev`, children: jsx(ChevronLeftIcon, { className: "h-5 w-5 text-slate-400" }) }), jsxs("div", { className: "flex cursor-pointer items-center gap-1 rounded px-2 py-1 transition duration-100 ease-in-out hover:bg-slate-100 dark:hover:bg-slate-700", onClick: nextCalendarView, "data-testid": `${dataTestId}-view-selector`, children: [calendarView === 'days' && (jsx("span", { className: "capitalize", "data-testid": `${dataTestId}-month`, children: months[month].name })), calendarView !== 'years' ? (jsx("span", { className: "text-slate-500 dark:text-slate-300", "data-testid": `${dataTestId}-year`, children: year })) : (jsxs("span", { className: "text-slate-500 dark:text-slate-300", "data-testid": `${dataTestId}-year-range`, children: [yearsRange[0], " - ", yearsRange[11]] }))] }), jsx("div", { className: "flex cursor-pointer items-center justify-center rounded-lg px-1 transition duration-100 ease-in-out hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:bg-slate-700", onClick: editCalendarViewPage('add'), "data-testid": `${dataTestId}-next`, children: jsx(ChevronRightIcon, { className: "h-5 w-5 text-slate-400" }) })] }), calendarView === 'days' ? (jsx(DaysView, { date: date, value: value, month: month, year: year, minDate: minDate, maxDate: maxDate, locale: locale, setNewDate: setNewDate, dataTestId: `${dataTestId}-days` })) : calendarView === 'months' ? (jsx(MonthsView, { date: date, value: value, year: year, minDate: minDate, maxDate: maxDate, locale: locale, selectMonth: selectMonth, dataTestId: `${dataTestId}-months` })) : (jsx(YearsView, { date: date, value: value, years: yearsRange, minDate: minDate, maxDate: maxDate, selectYear: selectYear, dataTestId: `${dataTestId}-years` }))] }));
|
|
1055
1080
|
};
|
|
1056
1081
|
|
|
1057
|
-
const TimeSelector = ({ date, step = 1, minDate, maxDate, setNewDate, }) => {
|
|
1082
|
+
const TimeSelector = ({ date, step = 1, minDate, maxDate, setNewDate, dataTestId = 'time-selector', }) => {
|
|
1058
1083
|
const editDateField = (field, diff) => () => {
|
|
1059
1084
|
const newDate = dayjs(date).add(diff, field).toDate();
|
|
1060
1085
|
if (minDate && compareDates(newDate, new Date(minDate), 'minute') < 0)
|
|
@@ -1068,11 +1093,11 @@ const TimeSelector = ({ date, step = 1, minDate, maxDate, setNewDate, }) => {
|
|
|
1068
1093
|
const increaseMinutes = useLongPress(editDateField('minutes', step));
|
|
1069
1094
|
const decreaseMinutes = useLongPress(editDateField('minutes', -step));
|
|
1070
1095
|
const onWheel = (field) => (event) => editDateField(field, (event.deltaY < 0 ? 1 : -1) * (field === 'hours' ? 1 : step))();
|
|
1071
|
-
return (jsxs(Fragment, { children: [jsx("label", { className: "text-sm text-slate-700 dark:text-slate-300", children: "Time" }), jsxs("div", { className: "flex flex-grow justify-center gap-2", children: [jsxs("div", { className: "flex flex-col items-center justify-center", children: [jsx(ChevronUpIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('hours', 1) }, increaseHours)), jsx(ChevronDownIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('hours', -1) }, decreaseHours))] }), jsxs("div", { className: "flex items-center rounded-lg border border-slate-100 bg-slate-100 text-right dark:border-slate-700 dark:bg-slate-800", children: [jsx("span", { className: "flex px-2", onWheel: onWheel('hours'), children: date.getHours().toString().padStart(2, '0') }), jsx("span", { children: ":" }), jsx("span", { className: "flex px-2", onWheel: onWheel('minutes'), children: date.getMinutes().toString().padStart(2, '0') })] }), jsxs("div", { className: "flex flex-col items-center justify-center", children: [jsx(ChevronUpIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('minutes', step) }, increaseMinutes)), jsx(ChevronDownIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('minutes', -step) }, decreaseMinutes))] })] })] }));
|
|
1096
|
+
return (jsxs(Fragment, { children: [jsx("label", { className: "text-sm text-slate-700 dark:text-slate-300", children: "Time" }), jsxs("div", { className: "flex flex-grow justify-center gap-2", children: [jsxs("div", { className: "flex flex-col items-center justify-center", children: [jsx(ChevronUpIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('hours', 1) }, increaseHours, { "data-testid": `${dataTestId}-hours-up` })), jsx(ChevronDownIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('hours', -1) }, decreaseHours, { "data-testid": `${dataTestId}-hours-down` }))] }), jsxs("div", { className: "flex items-center rounded-lg border border-slate-100 bg-slate-100 text-right dark:border-slate-700 dark:bg-slate-800", children: [jsx("span", { className: "flex px-2", onWheel: onWheel('hours'), "data-testid": `${dataTestId}-hours`, children: date.getHours().toString().padStart(2, '0') }), jsx("span", { children: ":" }), jsx("span", { className: "flex px-2", onWheel: onWheel('minutes'), "data-testid": `${dataTestId}-minutes`, children: date.getMinutes().toString().padStart(2, '0') })] }), jsxs("div", { className: "flex flex-col items-center justify-center", children: [jsx(ChevronUpIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('minutes', step) }, increaseMinutes, { "data-testid": `${dataTestId}-minutes-up` })), jsx(ChevronDownIcon, Object.assign({ className: "h-4 w-4 rounded hover:bg-slate-100 dark:hover:bg-slate-700", onClick: editDateField('minutes', -step) }, decreaseMinutes, { "data-testid": `${dataTestId}-minutes-down` }))] })] })] }));
|
|
1072
1097
|
};
|
|
1073
1098
|
|
|
1074
1099
|
const DateTimeInput = (_a) => {
|
|
1075
|
-
var { className, value, clearable, type = 'datetime-local', step = 1, minDate, maxDate, hasErrors, onChange, onBlur, displayFormat = 'dddd, MMMM Do YYYY, HH:mm:ss', displayLocale = 'en', ref } = _a, props = __rest(_a, ["className", "value", "clearable", "type", "step", "minDate", "maxDate", "hasErrors", "onChange", "onBlur", "displayFormat", "displayLocale", "ref"]);
|
|
1100
|
+
var { className, value, clearable, type = 'datetime-local', step = 1, minDate, maxDate, hasErrors, onChange, onBlur, displayFormat = 'dddd, MMMM Do YYYY, HH:mm:ss', displayLocale = 'en', ref, dataTestId = 'date-time-input' } = _a, props = __rest(_a, ["className", "value", "clearable", "type", "step", "minDate", "maxDate", "hasErrors", "onChange", "onBlur", "displayFormat", "displayLocale", "ref", "dataTestId"]);
|
|
1076
1101
|
const [isOpen, setIsOpen] = useState();
|
|
1077
1102
|
const [calendarView, setCalendarView] = useState('days');
|
|
1078
1103
|
const date = useMemo(() => {
|
|
@@ -1082,7 +1107,7 @@ const DateTimeInput = (_a) => {
|
|
|
1082
1107
|
result.setMinutes(result.getMinutes() - ((result.getMinutes() + step) % step));
|
|
1083
1108
|
return result;
|
|
1084
1109
|
}, [step, maxDate, minDate, value]);
|
|
1085
|
-
const displayDate = useMemo(() => value && getDisplayDate(date, displayFormat, displayLocale), [date, value, displayFormat, displayLocale]);
|
|
1110
|
+
const displayDate = useMemo(() => value && getDisplayDate(date, { format: displayFormat, locale: displayLocale }), [date, value, displayFormat, displayLocale]);
|
|
1086
1111
|
const calendarRef = useRef(null);
|
|
1087
1112
|
useOutsideClick(calendarRef, () => setIsOpen(false));
|
|
1088
1113
|
useEffect(() => {
|
|
@@ -1124,33 +1149,33 @@ const DateTimeInput = (_a) => {
|
|
|
1124
1149
|
setIsOpen(false);
|
|
1125
1150
|
}
|
|
1126
1151
|
};
|
|
1127
|
-
return (jsxs("div", { className: cn('relative w-full', className), ref: ref, children: [jsx(BasicInput, Object.assign({}, props, { type: "text", readOnly: true, value: displayDate !== null && displayDate !== void 0 ? displayDate : '', hasErrors: hasErrors, onClick: handleOnClick, onKeyUp: handleOnKeyUp, clearable: clearable && !!displayDate, onClear: clearDate, suffixIcon: (type === null || type === void 0 ? void 0 : type.includes('date')) ? CalendarIcon : ClockIcon, onSuffixIconClick: handleOnClick })), isOpen && (jsxs("div", { className: "absolute z-20 mt-2 flex origin-top-left flex-col rounded-md border bg-white shadow duration-200 dark:border-slate-700 dark:bg-slate-900 dark:text-white", tabIndex: 0, onBlur: handleOnBlur, ref: calendarRef, children: [(type === null || type === void 0 ? void 0 : type.includes('date')) && (jsx(DateSelector, { date: date, value: value, minDate: minDate, maxDate: maxDate, locale: displayLocale, calendarView: calendarView, setCalendarView: setCalendarView, setNewDate: setNewDate })), calendarView === 'days' && (jsxs("div", { className: "flex select-none items-center justify-end gap-2 px-3 py-2", children: [(type === null || type === void 0 ? void 0 : type.includes('time')) && (jsx(TimeSelector, { date: date, step: step, minDate: minDate, maxDate: maxDate, setNewDate: setNewDate })), jsx("div", { className: "cursor-pointer rounded-lg border border-transparent p-1 text-sm font-bold uppercase text-blue-600 transition duration-100 ease-in-out hover:bg-slate-100 dark:text-blue-500 dark:hover:bg-slate-700", onClick: () => setIsOpen(false), children: "OK" })] }))] }))] }));
|
|
1152
|
+
return (jsxs("div", { className: cn('relative w-full', className), ref: ref, children: [jsx(BasicInput, Object.assign({}, props, { type: "text", readOnly: true, value: displayDate !== null && displayDate !== void 0 ? displayDate : '', hasErrors: hasErrors, onClick: handleOnClick, onKeyUp: handleOnKeyUp, clearable: clearable && !!displayDate, onClear: clearDate, suffixIcon: (type === null || type === void 0 ? void 0 : type.includes('date')) ? CalendarIcon : ClockIcon, onSuffixIconClick: handleOnClick, dataTestId: dataTestId })), isOpen && (jsxs("div", { className: "absolute z-20 mt-2 flex origin-top-left flex-col rounded-md border bg-white shadow duration-200 dark:border-slate-700 dark:bg-slate-900 dark:text-white", tabIndex: 0, onBlur: handleOnBlur, ref: calendarRef, "data-testid": `${dataTestId}-popup`, children: [(type === null || type === void 0 ? void 0 : type.includes('date')) && (jsx(DateSelector, { date: date, value: value, minDate: minDate, maxDate: maxDate, locale: displayLocale, calendarView: calendarView, setCalendarView: setCalendarView, setNewDate: setNewDate, dataTestId: `${dataTestId}-date-selector` })), calendarView === 'days' && (jsxs("div", { className: "flex select-none items-center justify-end gap-2 px-3 py-2", "data-testid": `${dataTestId}-time-selector`, children: [(type === null || type === void 0 ? void 0 : type.includes('time')) && (jsx(TimeSelector, { date: date, step: step, minDate: minDate, maxDate: maxDate, setNewDate: setNewDate, dataTestId: `${dataTestId}-time-selector` })), jsx("div", { className: "cursor-pointer rounded-lg border border-transparent p-1 text-sm font-bold uppercase text-blue-600 transition duration-100 ease-in-out hover:bg-slate-100 dark:text-blue-500 dark:hover:bg-slate-700", onClick: () => setIsOpen(false), "data-testid": `${dataTestId}-ok`, children: "OK" })] }))] }))] }));
|
|
1128
1153
|
};
|
|
1129
1154
|
|
|
1130
1155
|
const ListContent = (_a) => {
|
|
1131
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1132
|
-
return (jsx(Block, Object.assign({ className: cn('z-50 min-w-[8rem] overflow-hidden rounded-md border border-slate-100 bg-white p-1 text-slate-700 shadow-md dark:border-slate-700 dark:bg-slate-900 dark:text-white', className) }, props)));
|
|
1156
|
+
var { className, dataTestId = 'list' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1157
|
+
return (jsx(Block, Object.assign({ className: cn('z-50 min-w-[8rem] overflow-hidden rounded-md border border-slate-100 bg-white p-1 text-slate-700 shadow-md dark:border-slate-700 dark:bg-slate-900 dark:text-white', className), dataTestId: dataTestId }, props)));
|
|
1133
1158
|
};
|
|
1134
1159
|
const labelSizeClasses = {
|
|
1135
1160
|
small: 'p-1 text-sm',
|
|
1136
1161
|
medium: 'px-2 py-1.5',
|
|
1137
1162
|
};
|
|
1138
1163
|
const ListItem = (_a) => {
|
|
1139
|
-
var { className, size = 'medium', inset } = _a, props = __rest(_a, ["className", "size", "inset"]);
|
|
1140
|
-
return (jsx(Flex, Object.assign({ className: cn(labelSizeClasses[size], 'relative cursor-default select-none gap-2 rounded-md outline-none focus:bg-slate-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-slate-700', inset && 'pl-8', className), align: "center" }, props)));
|
|
1164
|
+
var { className, size = 'medium', inset, dataTestId = 'list-item' } = _a, props = __rest(_a, ["className", "size", "inset", "dataTestId"]);
|
|
1165
|
+
return (jsx(Flex, Object.assign({ className: cn(labelSizeClasses[size], 'relative cursor-default select-none gap-2 rounded-md outline-none focus:bg-slate-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-slate-700', inset && 'pl-8', className), align: "center", dataTestId: dataTestId }, props)));
|
|
1141
1166
|
};
|
|
1142
1167
|
const ListLabel = (_a) => {
|
|
1143
|
-
var { className, size = 'medium', inset } = _a, props = __rest(_a, ["className", "size", "inset"]);
|
|
1144
|
-
return (jsx(Block, Object.assign({ className: cn(labelSizeClasses[size], 'font-semibold text-slate-900 dark:text-slate-300', inset && 'pl-8', className) }, props)));
|
|
1168
|
+
var { className, size = 'medium', inset, dataTestId = 'list-label' } = _a, props = __rest(_a, ["className", "size", "inset", "dataTestId"]);
|
|
1169
|
+
return (jsx(Block, Object.assign({ className: cn(labelSizeClasses[size], 'font-semibold text-slate-900 dark:text-slate-300', inset && 'pl-8', className), dataTestId: dataTestId }, props)));
|
|
1145
1170
|
};
|
|
1146
1171
|
const ListIndicator = (_a) => {
|
|
1147
|
-
var { className, icon: Icon, iconClassName } = _a, props = __rest(_a, ["className", "icon", "iconClassName"]);
|
|
1148
|
-
return (jsx(Flex, Object.assign({ className: cn('absolute left-2 h-3.5 w-3.5', className), align: "center", justify: "center" }, props, { children: jsx(Icon, { className: iconClassName }) })));
|
|
1172
|
+
var { className, icon: Icon, iconClassName, dataTestId = 'list-indicator' } = _a, props = __rest(_a, ["className", "icon", "iconClassName", "dataTestId"]);
|
|
1173
|
+
return (jsx(Flex, Object.assign({ className: cn('absolute left-2 h-3.5 w-3.5', className), align: "center", justify: "center", dataTestId: dataTestId }, props, { children: jsx(Icon, { className: iconClassName }) })));
|
|
1149
1174
|
};
|
|
1150
|
-
const ListIcon = ({ className, icon: Icon, ref, }) => jsx(Icon, { className: cn('h-4 w-4', className), ref: ref });
|
|
1175
|
+
const ListIcon = ({ className, icon: Icon, ref, dataTestId = 'list-icon' }) => (jsx(Icon, { className: cn('h-4 w-4', className), ref: ref, "data-testid": dataTestId }));
|
|
1151
1176
|
const ListSeparator = (_a) => {
|
|
1152
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1153
|
-
return (jsx(Block, Object.assign({ className: cn('-mx-1 my-1 h-px bg-slate-100 dark:bg-slate-700', className) }, props)));
|
|
1177
|
+
var { className, dataTestId = 'list-separator' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1178
|
+
return (jsx(Block, Object.assign({ className: cn('-mx-1 my-1 h-px bg-slate-100 dark:bg-slate-700', className), dataTestId: dataTestId }, props)));
|
|
1154
1179
|
};
|
|
1155
1180
|
const List = Object.assign(ListContent, {
|
|
1156
1181
|
Item: ListItem,
|
|
@@ -1160,54 +1185,69 @@ const List = Object.assign(ListContent, {
|
|
|
1160
1185
|
Separator: ListSeparator,
|
|
1161
1186
|
});
|
|
1162
1187
|
|
|
1163
|
-
const DropdownMenuTrigger =
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1188
|
+
const DropdownMenuTrigger = (_a) => {
|
|
1189
|
+
var { children, dataTestId = 'dropdown-menu-trigger' } = _a, props = __rest(_a, ["children", "dataTestId"]);
|
|
1190
|
+
return (jsx(DropdownMenuPrimitive.Trigger, Object.assign({ "data-testid": dataTestId }, props, { children: children })));
|
|
1191
|
+
};
|
|
1192
|
+
const DropdownMenuGroup = (_a) => {
|
|
1193
|
+
var { children, dataTestId = 'dropdown-menu-group' } = _a, props = __rest(_a, ["children", "dataTestId"]);
|
|
1194
|
+
return (jsx(DropdownMenuPrimitive.Group, Object.assign({ "data-testid": dataTestId }, props, { children: children })));
|
|
1195
|
+
};
|
|
1196
|
+
const DropdownMenuPortal = (_a) => {
|
|
1197
|
+
var { children, dataTestId = 'dropdown-menu-portal' } = _a, props = __rest(_a, ["children", "dataTestId"]);
|
|
1198
|
+
return jsx(DropdownMenuPrimitive.Portal, Object.assign({}, props, { children: children }));
|
|
1199
|
+
};
|
|
1200
|
+
const DropdownMenuSub = (_a) => {
|
|
1201
|
+
var { children, dataTestId = 'dropdown-menu-sub' } = _a, props = __rest(_a, ["children", "dataTestId"]);
|
|
1202
|
+
return jsx(DropdownMenuPrimitive.Sub, Object.assign({}, props, { children: children }));
|
|
1203
|
+
};
|
|
1204
|
+
const DropdownMenuRadioGroup = (_a) => {
|
|
1205
|
+
var { children, dataTestId = 'dropdown-menu-radio-group' } = _a, props = __rest(_a, ["children", "dataTestId"]);
|
|
1206
|
+
return (jsx(DropdownMenuPrimitive.RadioGroup, Object.assign({ "data-testid": dataTestId }, props, { children: children })));
|
|
1207
|
+
};
|
|
1168
1208
|
const DropdownMenuSubTrigger = (_a) => {
|
|
1169
|
-
var { className, inset, children } = _a, props = __rest(_a, ["className", "inset", "children"]);
|
|
1170
|
-
return (jsx(DropdownMenuPrimitive.SubTrigger, Object.assign({}, props, { asChild: true, children: jsxs(List.Item, { className: className, inset: inset, children: [children, jsx(ChevronRightIcon, { className: "ml-auto h-4 w-4" })] }) })));
|
|
1209
|
+
var { className, inset, children, dataTestId = 'dropdown-menu-subtrigger' } = _a, props = __rest(_a, ["className", "inset", "children", "dataTestId"]);
|
|
1210
|
+
return (jsx(DropdownMenuPrimitive.SubTrigger, Object.assign({}, props, { asChild: true, children: jsxs(List.Item, { className: className, inset: inset, "data-testid": dataTestId, children: [children, jsx(ChevronRightIcon, { className: "ml-auto h-4 w-4" })] }) })));
|
|
1171
1211
|
};
|
|
1172
1212
|
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
|
1173
1213
|
const DropdownMenuSubContent = (_a) => {
|
|
1174
|
-
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
1175
|
-
return (jsx(DropdownMenuPrimitive.Portal, { children: jsx(DropdownMenuPrimitive.SubContent, Object.assign({}, props, { asChild: true, children: jsx(List, { className: className, children: children }) })) }));
|
|
1214
|
+
var { className, children, dataTestId = 'dropdown-menu-subcontent' } = _a, props = __rest(_a, ["className", "children", "dataTestId"]);
|
|
1215
|
+
return (jsx(DropdownMenuPrimitive.Portal, { children: jsx(DropdownMenuPrimitive.SubContent, Object.assign({}, props, { asChild: true, children: jsx(List, { className: className, dataTestId: dataTestId, children: children }) })) }));
|
|
1176
1216
|
};
|
|
1177
1217
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
|
1178
1218
|
const DropdownMenuContent = (_a) => {
|
|
1179
|
-
var { className, children, sideOffset = 4 } = _a, props = __rest(_a, ["className", "children", "sideOffset"]);
|
|
1180
|
-
return (jsx(DropdownMenuPrimitive.Portal, { children: jsx(DropdownMenuPrimitive.Content, Object.assign({ sideOffset: sideOffset }, props, { asChild: true, children: jsx(List, { className: className, children: children }) })) }));
|
|
1219
|
+
var { className, children, sideOffset = 4, dataTestId = 'dropdown-menu-content' } = _a, props = __rest(_a, ["className", "children", "sideOffset", "dataTestId"]);
|
|
1220
|
+
return (jsx(DropdownMenuPrimitive.Portal, { children: jsx(DropdownMenuPrimitive.Content, Object.assign({ sideOffset: sideOffset }, props, { asChild: true, children: jsx(List, { className: className, dataTestId: dataTestId, children: children }) })) }));
|
|
1181
1221
|
};
|
|
1182
1222
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
1183
1223
|
const DropdownMenuItem = (_a) => {
|
|
1184
|
-
var { className, inset, children } = _a, props = __rest(_a, ["className", "inset", "children"]);
|
|
1185
|
-
return (jsx(DropdownMenuPrimitive.Item, Object.assign({}, props, { asChild: true, children: jsx(List.Item, { inset: inset, className: className, children: children }) })));
|
|
1224
|
+
var { className, inset, children, dataTestId = 'dropdown-menu-item' } = _a, props = __rest(_a, ["className", "inset", "children", "dataTestId"]);
|
|
1225
|
+
return (jsx(DropdownMenuPrimitive.Item, Object.assign({}, props, { asChild: true, children: jsx(List.Item, { inset: inset, className: className, "data-testid": dataTestId, children: children }) })));
|
|
1186
1226
|
};
|
|
1187
1227
|
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
1188
1228
|
const DropdownMenuCheckboxItem = (_a) => {
|
|
1189
|
-
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
1190
|
-
return (jsx(DropdownMenuPrimitive.CheckboxItem, Object.assign({}, props, { asChild: true, children: jsxs(List.Item, { inset: true, className: className, children: [jsx(DropdownMenuPrimitive.ItemIndicator, { asChild: true, children: jsx(List.Indicator, { icon: CheckIcon, iconClassName: "h-4 w-4" }) }), children] }) })));
|
|
1229
|
+
var { className, children, dataTestId = 'dropdown-menu-checkbox-item' } = _a, props = __rest(_a, ["className", "children", "dataTestId"]);
|
|
1230
|
+
return (jsx(DropdownMenuPrimitive.CheckboxItem, Object.assign({}, props, { asChild: true, children: jsxs(List.Item, { inset: true, className: className, "data-testid": dataTestId, children: [jsx(DropdownMenuPrimitive.ItemIndicator, { asChild: true, children: jsx(List.Indicator, { icon: CheckIcon, iconClassName: "h-4 w-4" }) }), children] }) })));
|
|
1191
1231
|
};
|
|
1192
1232
|
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
1193
1233
|
const DropdownMenuRadioItem = (_a) => {
|
|
1194
|
-
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
1195
|
-
return (jsx(DropdownMenuPrimitive.RadioItem, Object.assign({}, props, { asChild: true, children: jsxs(List.Item, { inset: true, className: className, children: [jsx(DropdownMenuPrimitive.ItemIndicator, { asChild: true, children: jsx(List.Indicator, { icon: CircleIcon, iconClassName: "h-2 w-2 fill-current" }) }), children] }) })));
|
|
1234
|
+
var { className, children, dataTestId = 'dropdown-menu-radio-item' } = _a, props = __rest(_a, ["className", "children", "dataTestId"]);
|
|
1235
|
+
return (jsx(DropdownMenuPrimitive.RadioItem, Object.assign({}, props, { asChild: true, children: jsxs(List.Item, { inset: true, className: className, "data-testid": dataTestId, children: [jsx(DropdownMenuPrimitive.ItemIndicator, { asChild: true, children: jsx(List.Indicator, { icon: CircleIcon, iconClassName: "h-2 w-2 fill-current" }) }), children] }) })));
|
|
1196
1236
|
};
|
|
1197
1237
|
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
1198
1238
|
const DropdownMenuLabel = (_a) => {
|
|
1199
|
-
var { className, inset, children } = _a, props = __rest(_a, ["className", "inset", "children"]);
|
|
1200
|
-
return (jsx(DropdownMenuPrimitive.Label, Object.assign({}, props, { asChild: true, children: jsx(List.Label, { className: className, inset: inset, children: children }) })));
|
|
1239
|
+
var { className, inset, children, dataTestId = 'dropdown-menu-label' } = _a, props = __rest(_a, ["className", "inset", "children", "dataTestId"]);
|
|
1240
|
+
return (jsx(DropdownMenuPrimitive.Label, Object.assign({}, props, { asChild: true, children: jsx(List.Label, { className: className, inset: inset, "data-testid": dataTestId, children: children }) })));
|
|
1201
1241
|
};
|
|
1202
1242
|
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
1203
1243
|
const DropdownMenuSeparator = (_a) => {
|
|
1204
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1205
|
-
return (jsx(DropdownMenuPrimitive.Separator, Object.assign({}, props, { asChild: true, children: jsx(List.Separator, { className: className }) })));
|
|
1244
|
+
var { className, dataTestId = 'dropdown-menu-separator' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1245
|
+
return (jsx(DropdownMenuPrimitive.Separator, Object.assign({}, props, { asChild: true, children: jsx(List.Separator, { className: className, "data-testid": dataTestId }) })));
|
|
1206
1246
|
};
|
|
1207
1247
|
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
1208
1248
|
const DropdownMenuShortcut = (_a) => {
|
|
1209
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1210
|
-
return (jsx("span", Object.assign({ className: cn('ml-auto text-xs tracking-widest text-slate-500', className) }, props)));
|
|
1249
|
+
var { className, dataTestId = 'dropdown-menu-shortcut' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1250
|
+
return (jsx("span", Object.assign({ className: cn('ml-auto text-xs tracking-widest text-slate-500', className), "data-testid": dataTestId }, props)));
|
|
1211
1251
|
};
|
|
1212
1252
|
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
|
|
1213
1253
|
const DropdownMenu = Object.assign(DropdownMenuPrimitive.Root, {
|
|
@@ -1232,7 +1272,7 @@ const defaultRenderItem = (item, selected) => item.label;
|
|
|
1232
1272
|
const defaultSearchPredicate = (item, searchValue) => item.label.toLowerCase().includes(searchValue.toLowerCase());
|
|
1233
1273
|
const defaultSelectPredicate = (a, b) => a === b;
|
|
1234
1274
|
const SelectInput = (_a) => {
|
|
1235
|
-
var { className, items, renderItem = defaultRenderItem, value, multiple, clearable, allowAddition, onNewItemAdded, search, searchPredicate = defaultSearchPredicate, selectPredicate = defaultSelectPredicate, onChange, readOnly, parentRef } = _a, props = __rest(_a, ["className", "items", "renderItem", "value", "multiple", "clearable", "allowAddition", "onNewItemAdded", "search", "searchPredicate", "selectPredicate", "onChange", "readOnly", "parentRef"]);
|
|
1275
|
+
var { className, items, renderItem = defaultRenderItem, value, multiple, clearable, allowAddition, onNewItemAdded, search, searchPredicate = defaultSearchPredicate, selectPredicate = defaultSelectPredicate, onChange, readOnly, parentRef, dataTestId = 'select-input' } = _a, props = __rest(_a, ["className", "items", "renderItem", "value", "multiple", "clearable", "allowAddition", "onNewItemAdded", "search", "searchPredicate", "selectPredicate", "onChange", "readOnly", "parentRef", "dataTestId"]);
|
|
1236
1276
|
const [open, setOpen] = useState(false);
|
|
1237
1277
|
const [searchValue, setSearchValue] = useState('');
|
|
1238
1278
|
const pureItems = useMemo(() => items.flatMap((item) => (item.group ? item.items : [item])), [items]);
|
|
@@ -1309,17 +1349,17 @@ const SelectInput = (_a) => {
|
|
|
1309
1349
|
}), value: String(option.id), checked: isNotNullOrUndefined(selectedMap[option.id]), onSelect: (event) => {
|
|
1310
1350
|
multiple && event.preventDefault();
|
|
1311
1351
|
handleOnSelect(option.id);
|
|
1312
|
-
}, children: jsx("span", { children: renderItem(option, isNotNullOrUndefined(selectedMap[option.id])) }) }));
|
|
1352
|
+
}, dataTestId: option.dataTestId, children: jsx("span", { children: renderItem(option, isNotNullOrUndefined(selectedMap[option.id])) }) }));
|
|
1313
1353
|
}, [ItemComponent, handleOnSelect, multiple, renderItem, selectedMap]);
|
|
1314
|
-
return (jsxs(DropdownMenu, { open: open, onOpenChange: setOpen, children: [jsx(DropdownMenu.Trigger, { className: cn('w-full', className), children: jsx(TextInput, Object.assign({ className: "[&>div>*]:cursor-pointer", inputClassName: "text-left" }, props, { value: text !== null && text !== void 0 ? text : '', clearable: clearable && !!selectedItems.length, onClear: handleOnClear, suffixIcon: ChevronDownIcon, onSuffixIconClick: () => setOpen((open) => !open), readOnly: true })) }), jsxs(DropdownMenu.Content, { className: "flex max-h-80 w-[calc(var(--radix-popper-anchor-width))] flex-col overflow-hidden", children: [search && (jsxs(Fragment, { children: [jsx(TextInput, { value: searchValue, placeholder: "Search...", size: props.size, onChange: handleOnSearchValueChange, onKeyUp: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), clearable: !!searchValue.length, onClear: clearSearchValue }), jsx(DropdownMenu.Separator, { className: "w-full" })] })), filteredItems.length === 0 &&
|
|
1315
|
-
(allowAddition && searchValue ? (jsxs("button", { className: "rounded bg-slate-100 py-1.5 text-center hover:bg-slate-200 dark:bg-slate-900/30 dark:hover:bg-slate-700/30", onClick: handleOnAddItemClicked, children: ["Add '", searchValue, "'"] })) : (jsx("div", { className: "py-1.5 text-center text-slate-500", children: "No items
|
|
1354
|
+
return (jsxs(DropdownMenu, { open: open, onOpenChange: setOpen, children: [jsx(DropdownMenu.Trigger, { className: cn('w-full', className), dataTestId: `${dataTestId}-trigger`, children: jsx(TextInput, Object.assign({ className: "[&>div>*]:cursor-pointer", inputClassName: "text-left" }, props, { value: text !== null && text !== void 0 ? text : '', clearable: clearable && !!selectedItems.length, onClear: handleOnClear, suffixIcon: ChevronDownIcon, onSuffixIconClick: () => setOpen((open) => !open), readOnly: true, dataTestId: dataTestId })) }), jsxs(DropdownMenu.Content, { className: "flex max-h-80 w-[calc(var(--radix-popper-anchor-width))] flex-col overflow-hidden", dataTestId: `${dataTestId}-content`, children: [search && (jsxs(Fragment, { children: [jsx(TextInput, { value: searchValue, placeholder: "Search...", size: props.size, onChange: handleOnSearchValueChange, onKeyUp: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), clearable: !!searchValue.length, onClear: clearSearchValue, dataTestId: `${dataTestId}-search` }), jsx(DropdownMenu.Separator, { className: "w-full", dataTestId: `${dataTestId}-separator` })] })), filteredItems.length === 0 &&
|
|
1355
|
+
(allowAddition && searchValue ? (jsxs("button", { className: "rounded bg-slate-100 py-1.5 text-center hover:bg-slate-200 dark:bg-slate-900/30 dark:hover:bg-slate-700/30", onClick: handleOnAddItemClicked, "data-testid": `${dataTestId}-add-button`, children: ["Add '", searchValue, "'"] })) : (jsx("div", { className: "py-1.5 text-center text-slate-500", "data-testid": `${dataTestId}-no-items`, children: "No items" }))), jsx(GroupComponent, { className: "flex flex-col gap-1 overflow-auto", value: !multiple && selectedItems.length ? String(selectedItems[0].id) : undefined, dataTestId: `${dataTestId}-group`, children: filteredItems.map((item, index) => item.group ? (jsxs(Flex, { className: "gap-1", direction: "column", fullWidth: true, children: [jsx(DropdownMenu.Label, { className: "sticky top-0 z-[51] w-full rounded-md border bg-white py-1 dark:bg-slate-900", dataTestId: `${dataTestId}-group-label-${item.id}`, children: item.label }), item.items.map((subItem) => (jsx(RenderOption, Object.assign({}, subItem, { dataTestId: `${dataTestId}-item-${subItem.id}` }), subItem.id))), index < filteredItems.length - 1 && (jsx("div", { className: "mb-1 h-px w-full bg-slate-200 dark:bg-slate-700" }))] }, item.id)) : (jsx(RenderOption, Object.assign({}, item, { dataTestId: `${dataTestId}-item-${item.id}` }), item.id))) })] })] }));
|
|
1316
1356
|
};
|
|
1317
1357
|
function isNotNullOrUndefined(value) {
|
|
1318
1358
|
return value !== null && value !== undefined;
|
|
1319
1359
|
}
|
|
1320
1360
|
|
|
1321
1361
|
const FileInput = (_a) => {
|
|
1322
|
-
var { className, value, onChange, onFileChange, accept } = _a, props = __rest(_a, ["className", "value", "onChange", "onFileChange", "accept"]);
|
|
1362
|
+
var { className, inputClassName, value, onChange, onFileChange, accept, dataTestId = 'file-input' } = _a, props = __rest(_a, ["className", "inputClassName", "value", "onChange", "onFileChange", "accept", "dataTestId"]);
|
|
1323
1363
|
const fileInputRef = useRef(null);
|
|
1324
1364
|
const handleFileChange = (_a) => __awaiter(void 0, [_a], void 0, function* ({ target: { files } }) {
|
|
1325
1365
|
if (files && files.length > 0) {
|
|
@@ -1328,9 +1368,9 @@ const FileInput = (_a) => {
|
|
|
1328
1368
|
onFileChange === null || onFileChange === void 0 ? void 0 : onFileChange(file);
|
|
1329
1369
|
}
|
|
1330
1370
|
});
|
|
1331
|
-
return (jsxs(Fragment, { children: [jsx(TextInput, Object.assign({ className: cn('[&>div>*]:cursor-pointer', className), inputClassName:
|
|
1371
|
+
return (jsxs(Fragment, { children: [jsx(TextInput, Object.assign({ className: cn('[&>div>*]:cursor-pointer', className), inputClassName: cn('text-left', inputClassName) }, props, { value: value !== null && value !== void 0 ? value : '', onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, suffixIcon: CloudUploadIcon, onSuffixIconClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, dataTestId: dataTestId, readOnly: true })), jsx("input", { ref: (ref) => {
|
|
1332
1372
|
fileInputRef.current = ref;
|
|
1333
|
-
}, type: "file", hidden: true, accept: accept, onChange: handleFileChange })] }));
|
|
1373
|
+
}, type: "file", hidden: true, accept: accept, onChange: handleFileChange, "data-testid": `${dataTestId}-hidden` })] }));
|
|
1334
1374
|
};
|
|
1335
1375
|
|
|
1336
1376
|
const FormGroup = ({ className, label, children }) => (jsxs(Flex, { className: cn('relative !gap-4 rounded-lg border p-4 dark:border-slate-700', className), direction: "column", fullWidth: true, children: [jsx("div", { className: "absolute right-0 top-0 rounded-bl-lg rounded-tr-lg bg-slate-500 px-2 py-1 font-medium text-white dark:bg-slate-900 dark:text-white", children: label }), children] }));
|
|
@@ -1366,7 +1406,7 @@ const FormInputs = {
|
|
|
1366
1406
|
File: withForm(FileInput),
|
|
1367
1407
|
};
|
|
1368
1408
|
|
|
1369
|
-
const HintRoot = ({ children, ref }) => (jsx(Block, { className: "relative", ref: ref, children: children }));
|
|
1409
|
+
const HintRoot = ({ children, ref, dataTestId = 'hint' }) => (jsx(Block, { className: "relative", ref: ref, dataTestId: dataTestId, children: children }));
|
|
1370
1410
|
HintRoot.displayName = 'HintRoot';
|
|
1371
1411
|
const dotSizeClassNames = {
|
|
1372
1412
|
small: {
|
|
@@ -1408,12 +1448,12 @@ const colorClassNames = {
|
|
|
1408
1448
|
pink: 'bg-pink-500 dark:bg-pink-600',
|
|
1409
1449
|
rose: 'bg-rose-500 dark:bg-rose-600',
|
|
1410
1450
|
};
|
|
1411
|
-
const HintDot = ({ size = 'medium', placement = 'top-right', color = 'green', ping, ref, }) => (jsxs(Fragment, { children: [jsx(Block, { className: cn('absolute rounded-full', colorClassNames[color], dotSizeClassNames[size].base, {
|
|
1451
|
+
const HintDot = ({ size = 'medium', placement = 'top-right', color = 'green', ping, ref, dataTestId = 'hint-dot', }) => (jsxs(Fragment, { children: [jsx(Block, { className: cn('absolute rounded-full', colorClassNames[color], dotSizeClassNames[size].base, {
|
|
1412
1452
|
[`${dotSizeClassNames[size].top} ${dotSizeClassNames[size].left}`]: placement === 'top-left',
|
|
1413
1453
|
[`${dotSizeClassNames[size].top} ${dotSizeClassNames[size].right}`]: placement === 'top-right',
|
|
1414
1454
|
[`${dotSizeClassNames[size].bottom} ${dotSizeClassNames[size].right}`]: placement === 'bottom-right',
|
|
1415
1455
|
[`${dotSizeClassNames[size].bottom} ${dotSizeClassNames[size].left}`]: placement === 'bottom-left',
|
|
1416
|
-
}), ref: ref }), ping && (jsx(Block, { className: cn('absolute animate-ping rounded-full', colorClassNames[color], dotSizeClassNames[size].base, {
|
|
1456
|
+
}), ref: ref, "data-testid": dataTestId }), ping && (jsx(Block, { className: cn('absolute animate-ping rounded-full', colorClassNames[color], dotSizeClassNames[size].base, {
|
|
1417
1457
|
[`${dotSizeClassNames[size].top} ${dotSizeClassNames[size].left}`]: placement === 'top-left',
|
|
1418
1458
|
[`${dotSizeClassNames[size].top} ${dotSizeClassNames[size].right}`]: placement === 'top-right',
|
|
1419
1459
|
[`${dotSizeClassNames[size].bottom} ${dotSizeClassNames[size].right}`]: placement === 'bottom-right',
|
|
@@ -1427,26 +1467,26 @@ const badgeSizeClassNames = {
|
|
|
1427
1467
|
left: 'left-2 -translate-x-full',
|
|
1428
1468
|
};
|
|
1429
1469
|
const HintBadge = (_a) => {
|
|
1430
|
-
var { className, size = 'small', placement = 'top-right' } = _a, props = __rest(_a, ["className", "size", "placement"]);
|
|
1470
|
+
var { className, size = 'small', placement = 'top-right', dataTestId = 'hint-badge' } = _a, props = __rest(_a, ["className", "size", "placement", "dataTestId"]);
|
|
1431
1471
|
return (jsx(Badge, Object.assign({ className: cn('absolute z-10 px-1', size === 'small' ? 'h-4' : 'h-5', {
|
|
1432
1472
|
[`${badgeSizeClassNames.top} ${badgeSizeClassNames.left}`]: placement === 'top-left',
|
|
1433
1473
|
[`${badgeSizeClassNames.top} ${badgeSizeClassNames.right}`]: placement === 'top-right',
|
|
1434
1474
|
[`${badgeSizeClassNames.bottom} ${badgeSizeClassNames.right}`]: placement === 'bottom-right',
|
|
1435
1475
|
[`${badgeSizeClassNames.bottom} ${badgeSizeClassNames.left}`]: placement === 'bottom-left',
|
|
1436
|
-
}, className), size: size }, props)));
|
|
1476
|
+
}, className), size: size, dataTestId: dataTestId }, props)));
|
|
1437
1477
|
};
|
|
1438
1478
|
HintBadge.displayName = 'HintBadge';
|
|
1439
1479
|
const Hint = Object.assign(HintRoot, { Dot: HintDot, Badge: HintBadge });
|
|
1440
1480
|
|
|
1441
|
-
const Pagination = ({ disabled, pageSize = 10, currentPage, totalItems, setCurrentPage, }) => {
|
|
1481
|
+
const Pagination = ({ disabled, pageSize = 10, currentPage, totalItems, dataTestId = 'pagination', setCurrentPage, }) => {
|
|
1442
1482
|
const totalPages = useMemo(() => Math.ceil(totalItems / pageSize), [pageSize, totalItems]);
|
|
1443
1483
|
const pagination = usePagination(currentPage + 1, totalPages);
|
|
1444
1484
|
useEffect(() => {
|
|
1445
1485
|
setCurrentPage((page) => Math.min(page, Math.max(0, totalPages - 1)));
|
|
1446
1486
|
}, [setCurrentPage, totalPages]);
|
|
1447
|
-
return (jsx(Flex, { justify: "end", children: jsxs(Flex, { className: "h-9 gap-0 divide-x rounded-md border border-slate-300 bg-white dark:divide-slate-700 dark:border-slate-700 dark:bg-slate-800", children: [jsx(PaginationItem, { title: "First page", onClick: () => setCurrentPage(0), disabled: !currentPage || disabled, children: jsx(ChevronsLeftIcon, { className: "h-4 w-4" }) }), jsx(PaginationItem, { title: "Previous page", onClick: () => currentPage && setCurrentPage(currentPage - 1), disabled: !currentPage || disabled, children: jsx(ChevronLeftIcon, { className: "h-4 w-4" }) }), pagination.map((page, index) => (jsx(PaginationItem, { active: page !== '...' && page - 1 === currentPage, title: page !== '...' ? `Page ${page}` : undefined, onClick: page !== '...' ? () => setCurrentPage(page - 1) : undefined, disabled: page === '...' || disabled, children: page }, index))), jsx(PaginationItem, { title: "Next page", onClick: () => currentPage + 1 < totalPages && setCurrentPage(currentPage + 1), disabled: currentPage + 1 === totalPages || disabled, children: jsx(ChevronRightIcon, { className: "h-4 w-4" }) }), jsx(PaginationItem, { title: "Last page", onClick: () => setCurrentPage(Math.floor(totalItems && !(totalItems % pageSize)
|
|
1487
|
+
return (jsx(Flex, { justify: "end", dataTestId: dataTestId, children: jsxs(Flex, { className: "h-9 gap-0 divide-x rounded-md border border-slate-300 bg-white dark:divide-slate-700 dark:border-slate-700 dark:bg-slate-800", children: [jsx(PaginationItem, { title: "First page", onClick: () => setCurrentPage(0), disabled: !currentPage || disabled, dataTestId: `${dataTestId}-first-page`, children: jsx(ChevronsLeftIcon, { className: "h-4 w-4" }) }), jsx(PaginationItem, { title: "Previous page", onClick: () => currentPage && setCurrentPage(currentPage - 1), disabled: !currentPage || disabled, dataTestId: `${dataTestId}-previous-page`, children: jsx(ChevronLeftIcon, { className: "h-4 w-4" }) }), pagination.map((page, index) => (jsx(PaginationItem, { active: page !== '...' && page - 1 === currentPage, title: page !== '...' ? `Page ${page}` : undefined, onClick: page !== '...' ? () => setCurrentPage(page - 1) : undefined, disabled: page === '...' || disabled, dataTestId: `${dataTestId}-page-${page}`, children: page }, index))), jsx(PaginationItem, { title: "Next page", onClick: () => currentPage + 1 < totalPages && setCurrentPage(currentPage + 1), disabled: currentPage + 1 === totalPages || disabled, dataTestId: `${dataTestId}-next-page`, children: jsx(ChevronRightIcon, { className: "h-4 w-4" }) }), jsx(PaginationItem, { title: "Last page", onClick: () => setCurrentPage(Math.floor(totalItems && !(totalItems % pageSize)
|
|
1448
1488
|
? (totalItems - 1) / pageSize
|
|
1449
|
-
: totalItems / pageSize)), disabled: currentPage + 1 === totalPages || disabled, children: jsx(ChevronsRightIcon, { className: "h-4 w-4" }) })] }) }));
|
|
1489
|
+
: totalItems / pageSize)), disabled: currentPage + 1 === totalPages || disabled, dataTestId: `${dataTestId}-last-page`, children: jsx(ChevronsRightIcon, { className: "h-4 w-4" }) })] }) }));
|
|
1450
1490
|
};
|
|
1451
1491
|
const PaginationItem = (_a) => {
|
|
1452
1492
|
var { children, active, disabled } = _a, props = __rest(_a, ["children", "active", "disabled"]);
|
|
@@ -1457,38 +1497,38 @@ const PaginationItem = (_a) => {
|
|
|
1457
1497
|
}), align: "center", justify: "center", fullHeight: true }, props, { children: children })));
|
|
1458
1498
|
};
|
|
1459
1499
|
|
|
1460
|
-
const Spinner = ({ className, fullScreen }) => (jsx("div", { className: cn('flex w-full items-center justify-center bg-white dark:bg-slate-900', {
|
|
1500
|
+
const Spinner = ({ className, fullScreen, dataTestId = 'spinner' }) => (jsx("div", { className: cn('flex w-full items-center justify-center bg-white dark:bg-slate-900', {
|
|
1461
1501
|
'h-screen': fullScreen,
|
|
1462
1502
|
'h-full': !fullScreen,
|
|
1463
|
-
}, className), children: jsxs("svg", { className: "h-8 w-8 animate-spin text-black dark:text-white", fill: "none", viewBox: "0 0 24 24", children: [jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }) }));
|
|
1503
|
+
}, className), "data-testid": dataTestId, children: jsxs("svg", { className: "h-8 w-8 animate-spin text-black dark:text-white", fill: "none", viewBox: "0 0 24 24", children: [jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }) }));
|
|
1464
1504
|
|
|
1465
1505
|
const $Table = (_a) => {
|
|
1466
|
-
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
1467
|
-
return (jsx(Flex, { className: cn('overflow-auto rounded-lg', className), fullWidth: true, children: jsx("table", Object.assign({ className: "min-w-full divide-y divide-slate-200 dark:divide-slate-800 dark:text-white" }, props, { children: children })) }));
|
|
1506
|
+
var { children, className, dataTestId = 'table' } = _a, props = __rest(_a, ["children", "className", "dataTestId"]);
|
|
1507
|
+
return (jsx(Flex, { className: cn('overflow-auto rounded-lg', className), fullWidth: true, children: jsx("table", Object.assign({ className: "min-w-full divide-y divide-slate-200 dark:divide-slate-800 dark:text-white", "data-testid": dataTestId }, props, { children: children })) }));
|
|
1468
1508
|
};
|
|
1469
1509
|
const TableHead = (_a) => {
|
|
1470
|
-
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
1471
|
-
return (jsx("thead", Object.assign({ className: cn('border-b bg-slate-100 text-slate-800 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300', className) }, props, { children: children })));
|
|
1510
|
+
var { children, className, dataTestId = 'table-head' } = _a, props = __rest(_a, ["children", "className", "dataTestId"]);
|
|
1511
|
+
return (jsx("thead", Object.assign({ className: cn('border-b bg-slate-100 text-slate-800 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300', className), "data-testid": dataTestId }, props, { children: children })));
|
|
1472
1512
|
};
|
|
1473
1513
|
const TableHeadCell = (_a) => {
|
|
1474
|
-
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
1475
|
-
return (jsx("th", Object.assign({ className: cn('px-4 py-2 font-medium', className) }, props, { children: children })));
|
|
1514
|
+
var { children, className, dataTestId = 'table-head-cell' } = _a, props = __rest(_a, ["children", "className", "dataTestId"]);
|
|
1515
|
+
return (jsx("th", Object.assign({ className: cn('px-4 py-2 font-medium', className), "data-testid": dataTestId }, props, { children: children })));
|
|
1476
1516
|
};
|
|
1477
1517
|
const TableBody = (_a) => {
|
|
1478
|
-
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
1479
|
-
return (jsx("tbody", Object.assign({ className: cn('divide-y divide-slate-200 bg-slate-50/80 dark:divide-slate-700 dark:bg-slate-900', className) }, props, { children: children })));
|
|
1518
|
+
var { children, className, dataTestId = 'table-body' } = _a, props = __rest(_a, ["children", "className", "dataTestId"]);
|
|
1519
|
+
return (jsx("tbody", Object.assign({ className: cn('divide-y divide-slate-200 bg-slate-50/80 dark:divide-slate-700 dark:bg-slate-900', className), "data-testid": dataTestId }, props, { children: children })));
|
|
1480
1520
|
};
|
|
1481
1521
|
const TableRow = (_a) => {
|
|
1482
|
-
var { children } = _a, props = __rest(_a, ["children"]);
|
|
1483
|
-
return (jsx("tr", Object.assign({}, props, { children: children })));
|
|
1522
|
+
var { children, dataTestId = 'table-row' } = _a, props = __rest(_a, ["children", "dataTestId"]);
|
|
1523
|
+
return (jsx("tr", Object.assign({ "data-testid": dataTestId }, props, { children: children })));
|
|
1484
1524
|
};
|
|
1485
1525
|
const TableCell = (_a) => {
|
|
1486
|
-
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
1487
|
-
return (jsx("td", Object.assign({ className: cn('px-4 py-2', className) }, props, { children: children })));
|
|
1526
|
+
var { children, className, dataTestId = 'table-cell' } = _a, props = __rest(_a, ["children", "className", "dataTestId"]);
|
|
1527
|
+
return (jsx("td", Object.assign({ className: cn('px-4 py-2', className), "data-testid": dataTestId }, props, { children: children })));
|
|
1488
1528
|
};
|
|
1489
1529
|
const TableFooter = (_a) => {
|
|
1490
|
-
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
1491
|
-
return (jsx("tfoot", Object.assign({ className: cn('bg-slate-100 text-slate-800 dark:bg-slate-800 dark:text-slate-300', className) }, props, { children: children })));
|
|
1530
|
+
var { children, className, dataTestId = 'table-footer' } = _a, props = __rest(_a, ["children", "className", "dataTestId"]);
|
|
1531
|
+
return (jsx("tfoot", Object.assign({ className: cn('bg-slate-100 text-slate-800 dark:bg-slate-800 dark:text-slate-300', className), "data-testid": dataTestId }, props, { children: children })));
|
|
1492
1532
|
};
|
|
1493
1533
|
const Table = Object.assign($Table, {
|
|
1494
1534
|
Head: TableHead,
|
|
@@ -1503,7 +1543,7 @@ const possiblePageSize = [5, 10, 25, 50, 100, 500, 1000];
|
|
|
1503
1543
|
function defaultRender(item, field) {
|
|
1504
1544
|
return resolveTargetObject(item, field.split('.'), '-');
|
|
1505
1545
|
}
|
|
1506
|
-
function DataTable({ className, columns, rows, sorting, pagination, actions = [], isLoading, rowExtraContent, noDataMessage, onRowClick, rowClassName, }) {
|
|
1546
|
+
function DataTable({ className, columns, rows, sorting, pagination, actions = [], isLoading, rowExtraContent, noDataMessage, onRowClick, rowClassName, dataTestId = 'data-table', }) {
|
|
1507
1547
|
var _a;
|
|
1508
1548
|
const footerRef = useRef(null);
|
|
1509
1549
|
const [expandedRows, setExpandedRows] = useState({});
|
|
@@ -1552,41 +1592,41 @@ function DataTable({ className, columns, rows, sorting, pagination, actions = []
|
|
|
1552
1592
|
event.stopPropagation();
|
|
1553
1593
|
setExpandedRows((prev) => (rowExtraContent === null || rowExtraContent === void 0 ? void 0 : rowExtraContent.singleExpansion) ? { [id]: !prev[id] } : Object.assign(Object.assign({}, prev), { [id]: !prev[id] }));
|
|
1554
1594
|
};
|
|
1555
|
-
return (jsxs(Table, { className: cn('border dark:border-slate-700', className), children: [jsx(Table.Head, { className: "sticky top-0 z-10", children: jsxs(Table.Row, { children: [rowExtraContent && (jsx(Table.HeadCell, { align: "center", children: !rowExtraContent.singleExpansion && (jsx(ExpandButton, { folded: !allRowsExpanded, foldComponent: ChevronsDownUpIcon, unfoldComponent: ChevronsUpDownIcon, onClick: handleExpandAll })) })), _columns.map((column, columnIndex) => {
|
|
1595
|
+
return (jsxs(Table, { className: cn('border dark:border-slate-700', className), dataTestId: dataTestId, children: [jsx(Table.Head, { className: "sticky top-0 z-10", dataTestId: `${dataTestId}-head`, children: jsxs(Table.Row, { dataTestId: `${dataTestId}-header-row`, children: [rowExtraContent && (jsx(Table.HeadCell, { align: "center", dataTestId: `${dataTestId}-expand-header`, children: !rowExtraContent.singleExpansion && (jsx(ExpandButton, { folded: !allRowsExpanded, foldComponent: ChevronsDownUpIcon, unfoldComponent: ChevronsUpDownIcon, onClick: handleExpandAll, dataTestId: `${dataTestId}-expand-all-button` })) })), _columns.map((column, columnIndex) => {
|
|
1556
1596
|
var _a, _b, _c;
|
|
1557
1597
|
return (jsxs(Table.HeadCell, { className: cn('group relative', {
|
|
1558
1598
|
'cursor-pointer': !isLoading && sorting && !column.noSorting,
|
|
1559
1599
|
}), align: (_a = column.align) !== null && _a !== void 0 ? _a : 'left', onClick: !isLoading && sorting && !column.noSorting
|
|
1560
1600
|
? handleSorting(column.field, column.comparator)
|
|
1561
|
-
: undefined, children: [column.header, sorting &&
|
|
1601
|
+
: undefined, dataTestId: `${dataTestId}-column-${column.field}`, children: [column.header, sorting &&
|
|
1562
1602
|
!column.noSorting &&
|
|
1563
1603
|
(((_b = sorting.sorting) === null || _b === void 0 ? void 0 : _b.field) !== column.field ? (jsx(ArrowUpDownIcon, { className: "absolute top-1/2 float-right ml-1 hidden h-4 w-4 -translate-y-1/2 group-hover:inline-block" })) : ((_c = sorting.sorting) === null || _c === void 0 ? void 0 : _c.direction) === 'asc' ? (jsx(SortAscIcon, { className: "absolute top-1/2 float-right ml-1 inline-block h-4 w-4 -translate-y-1/2" })) : (jsx(SortDescIcon, { className: "absolute top-1/2 float-right ml-1 inline-block h-4 w-4 -translate-y-1/2" })))] }, columnIndex));
|
|
1564
|
-
}), actions.filter((action) => rows.some((item) => { var _a; return typeof action.hide === 'boolean' ? !action.hide : !((_a = action.hide) === null || _a === void 0 ? void 0 : _a.call(action, item)); })).length > 0 && jsx(Table.HeadCell, { align: "center", children: "Actions" })] }) }), jsxs(Table.Body, { className: "relative", children: [isLoading && (jsx(Table.Row, { children: jsx(Table.Cell, { className: cn('z-10 h-full w-full p-0', {
|
|
1604
|
+
}), actions.filter((action) => rows.some((item) => { var _a; return typeof action.hide === 'boolean' ? !action.hide : !((_a = action.hide) === null || _a === void 0 ? void 0 : _a.call(action, item)); })).length > 0 && (jsx(Table.HeadCell, { align: "center", dataTestId: `${dataTestId}-actions-header`, children: "Actions" }))] }) }), jsxs(Table.Body, { className: "relative", dataTestId: `${dataTestId}-body`, children: [isLoading && (jsx(Table.Row, { dataTestId: `${dataTestId}-loading-row`, children: jsx(Table.Cell, { className: cn('z-10 h-full w-full p-0', {
|
|
1565
1605
|
absolute: rows.length,
|
|
1566
|
-
}), colSpan: columnsLength, children: jsx(Spinner, { className: "bg-white/50 py-4 dark:bg-slate-700/50" }) }) })), !isLoading && !rows.length && (jsx(Table.Row, { children: jsx(Table.Cell, { colSpan: columnsLength, children: jsx(Flex, { className: "text-slate-500", justify: "center", children: noDataMessage !== null && noDataMessage !== void 0 ? noDataMessage : 'No data' }) }) })), rows.map((item, rowIndex) => [
|
|
1606
|
+
}), colSpan: columnsLength, dataTestId: `${dataTestId}-loading-cell`, children: jsx(Spinner, { className: "bg-white/50 py-4 dark:bg-slate-700/50", dataTestId: `${dataTestId}-spinner` }) }) })), !isLoading && !rows.length && (jsx(Table.Row, { dataTestId: `${dataTestId}-empty-row`, children: jsx(Table.Cell, { colSpan: columnsLength, dataTestId: `${dataTestId}-empty-cell`, children: jsx(Flex, { className: "text-slate-500", justify: "center", children: noDataMessage !== null && noDataMessage !== void 0 ? noDataMessage : 'No data' }) }) })), rows.map((item, rowIndex) => [
|
|
1567
1607
|
jsxs(Table.Row, { className: cn({
|
|
1568
1608
|
'cursor-pointer hover:bg-slate-100 dark:hover:bg-slate-800': onRowClick || rowExtraContent,
|
|
1569
|
-
}, rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(item, rowIndex)), onClick: handleRowClicked(item, rowIndex), children: [rowExtraContent && (jsx(Table.Cell, { className: "w-min", align: "center", children: jsx(ExpandButton, { folded: !expandedRows[rowExtraContent.idGetter(item)], foldComponent: MinusIcon, unfoldComponent: PlusIcon, onClick: handleExpandRow(rowExtraContent.idGetter(item)) }) })), _columns.map((column, columnIndex) => {
|
|
1609
|
+
}, rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(item, rowIndex)), onClick: handleRowClicked(item, rowIndex), dataTestId: `${dataTestId}-row-${rowIndex}`, children: [rowExtraContent && (jsx(Table.Cell, { className: "w-min", align: "center", dataTestId: `${dataTestId}-expand-cell-${rowIndex}`, children: jsx(ExpandButton, { folded: !expandedRows[rowExtraContent.idGetter(item)], foldComponent: MinusIcon, unfoldComponent: PlusIcon, onClick: handleExpandRow(rowExtraContent.idGetter(item)), dataTestId: `${dataTestId}-expand-button-${rowIndex}` }) })), _columns.map((column, columnIndex) => {
|
|
1570
1610
|
var _a, _b, _c;
|
|
1571
|
-
return (jsx(Table.Cell, { className: column.className, align: (_a = column.align) !== null && _a !== void 0 ? _a : 'left', children: (_c = (_b = column.render) === null || _b === void 0 ? void 0 : _b.call(column, item, rowIndex)) !== null && _c !== void 0 ? _c : defaultRender(item, column.field) }, columnIndex));
|
|
1572
|
-
}), actions.filter((action) => { var _a; return typeof action.hide === 'boolean' ? !action.hide : !((_a = action.hide) === null || _a === void 0 ? void 0 : _a.call(action, item)); }).length > 0 && (jsx(Table.Cell, { className: "py-3", children: jsx(Flex, { align: "center", justify: "center", children: actions
|
|
1611
|
+
return (jsx(Table.Cell, { className: column.className, align: (_a = column.align) !== null && _a !== void 0 ? _a : 'left', dataTestId: `${dataTestId}-cell-${rowIndex}-${column.field}`, children: (_c = (_b = column.render) === null || _b === void 0 ? void 0 : _b.call(column, item, rowIndex)) !== null && _c !== void 0 ? _c : defaultRender(item, column.field) }, columnIndex));
|
|
1612
|
+
}), actions.filter((action) => { var _a; return typeof action.hide === 'boolean' ? !action.hide : !((_a = action.hide) === null || _a === void 0 ? void 0 : _a.call(action, item)); }).length > 0 && (jsx(Table.Cell, { className: "py-3", dataTestId: `${dataTestId}-actions-cell-${rowIndex}`, children: jsx(Flex, { align: "center", justify: "center", children: actions
|
|
1573
1613
|
.filter((action) => { var _a; return typeof action.hide === 'boolean' ? !action.hide : !((_a = action.hide) === null || _a === void 0 ? void 0 : _a.call(action, item)); })
|
|
1574
1614
|
.map((action, actionIndex) => {
|
|
1575
1615
|
var _a;
|
|
1576
1616
|
const notification = (_a = action.hasNotification) === null || _a === void 0 ? void 0 : _a.call(action, item, rowIndex);
|
|
1577
|
-
return (jsxs("div", { className: "relative", children: [jsx(Button, { size: "small", prefixIcon: action.icon, color: action.color, onClick: handleActionClicked(action, item, rowIndex), children: action.label }), notification &&
|
|
1617
|
+
return (jsxs("div", { className: "relative", children: [jsx(Button, { size: "small", prefixIcon: action.icon, color: action.color, onClick: handleActionClicked(action, item, rowIndex), children: action.label, dataTestId: `${dataTestId}-action-button-${rowIndex}-${actionIndex}` }), notification &&
|
|
1578
1618
|
(notification === true ? (jsx(Hint.Dot, {})) : notification.type === 'dot' ? (jsx(Hint.Dot, Object.assign({}, notification.props))) : (jsx(Hint.Badge, Object.assign({}, notification.props))))] }, actionIndex));
|
|
1579
1619
|
}) }) }))] }, rowIndex),
|
|
1580
|
-
rowExtraContent && expandedRows[rowExtraContent.idGetter(item)] && (jsx(Table.Row, { children: jsx(Table.Cell, { className: "p-0", colSpan: columnsLength, children: jsx(rowExtraContent.component, { item: item, rowIndex: rowIndex }) }) }, `${rowIndex}-expanded`)),
|
|
1581
|
-
])] }), pagination && (jsx(Table.Footer, { className: "sticky -bottom-px", children: jsx(Table.Row, { className: "border-t dark:border-slate-700", children: jsx(Table.Cell, { colSpan: columnsLength, children: jsxs(Flex, { justify: "end", ref: footerRef, children: [jsx(Pagination, Object.assign({ disabled: isLoading }, pagination)), pagination.onPageSizeChange && (jsx(SelectInput, { className: "w-32", value: (_a = pagination.pageSize) !== null && _a !== void 0 ? _a : 10, items: possiblePageSize.map((pageSize) => ({
|
|
1620
|
+
rowExtraContent && expandedRows[rowExtraContent.idGetter(item)] && (jsx(Table.Row, { dataTestId: `${dataTestId}-expanded-row-${rowIndex}`, children: jsx(Table.Cell, { className: "p-0", colSpan: columnsLength, dataTestId: `${dataTestId}-expanded-cell-${rowIndex}`, children: jsx(rowExtraContent.component, { item: item, rowIndex: rowIndex }) }) }, `${rowIndex}-expanded`)),
|
|
1621
|
+
])] }), pagination && (jsx(Table.Footer, { className: "sticky -bottom-px", dataTestId: `${dataTestId}-footer`, children: jsx(Table.Row, { className: "border-t dark:border-slate-700", dataTestId: `${dataTestId}-footer-row`, children: jsx(Table.Cell, { colSpan: columnsLength, dataTestId: `${dataTestId}-footer-cell`, children: jsxs(Flex, { justify: "end", ref: footerRef, children: [jsx(Pagination, Object.assign({ disabled: isLoading }, pagination, { dataTestId: `${dataTestId}-pagination` })), pagination.onPageSizeChange && (jsx(SelectInput, { className: "w-32", value: (_a = pagination.pageSize) !== null && _a !== void 0 ? _a : 10, items: possiblePageSize.map((pageSize) => ({
|
|
1582
1622
|
id: pageSize,
|
|
1583
1623
|
label: String(pageSize),
|
|
1584
1624
|
value: pageSize,
|
|
1585
|
-
})), onChange: (newPageSize) => { var _a; return newPageSize && ((_a = pagination.onPageSizeChange) === null || _a === void 0 ? void 0 : _a.call(pagination, newPageSize)); }, disabled: isLoading, parentRef: footerRef }))] }) }) }) }))] }));
|
|
1625
|
+
})), onChange: (newPageSize) => { var _a; return newPageSize && ((_a = pagination.onPageSizeChange) === null || _a === void 0 ? void 0 : _a.call(pagination, newPageSize)); }, disabled: isLoading, parentRef: footerRef, dataTestId: `${dataTestId}-page-size-select` }))] }) }) }) }))] }));
|
|
1586
1626
|
}
|
|
1587
|
-
const ExpandButton = ({ folded, foldComponent, unfoldComponent, onClick, }) => {
|
|
1627
|
+
const ExpandButton = ({ folded, foldComponent, unfoldComponent, onClick, dataTestId, }) => {
|
|
1588
1628
|
const Icon = folded ? unfoldComponent : foldComponent;
|
|
1589
|
-
return (jsx(Icon, { className: "h-6 w-6 cursor-pointer rounded p-1 hover:bg-slate-300 hover:dark:bg-slate-600", onClick: onClick }));
|
|
1629
|
+
return (jsx(Icon, { className: "h-6 w-6 cursor-pointer rounded p-1 hover:bg-slate-300 hover:dark:bg-slate-600", onClick: onClick, "data-testid": dataTestId }));
|
|
1590
1630
|
};
|
|
1591
1631
|
|
|
1592
1632
|
const $Dialog = (props) => (jsx(DialogPrimitive.Root, Object.assign({}, props)));
|
|
@@ -1595,33 +1635,33 @@ const DialogTrigger = DialogPrimitive.Trigger;
|
|
|
1595
1635
|
const DialogPortal = DialogPrimitive.Portal;
|
|
1596
1636
|
const DialogClose = DialogPrimitive.Close;
|
|
1597
1637
|
const DialogOverlay = (_a) => {
|
|
1598
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1599
|
-
return (jsx(DialogPrimitive.Overlay, Object.assign({ className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', className) }, props)));
|
|
1638
|
+
var { className, dataTestId } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1639
|
+
return (jsx(DialogPrimitive.Overlay, Object.assign({ className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', className), "data-testid": dataTestId }, props)));
|
|
1600
1640
|
};
|
|
1601
1641
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
1602
1642
|
const DialogContent = (_a) => {
|
|
1603
|
-
var { className, fullScreen, children } = _a, props = __rest(_a, ["className", "fullScreen", "children"]);
|
|
1604
|
-
return (jsxs(DialogPortal, { children: [jsx(DialogOverlay, {}), jsxs(DialogPrimitive.Content, Object.assign({ className: cn('bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]', 'fixed left-[50%] top-[50%] z-50 flex max-h-[95dvh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-lg border p-4 shadow-lg duration-200', className, fullScreen && 'h-full max-h-none w-full max-w-none rounded-none'), "aria-describedby": "dialog-content" }, props, { children: [children, jsx(DialogPrimitive.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none", asChild: true, children: jsx(Button, { prefixIcon: XIcon, size: "small", variant: "text" }) }), jsx(DialogPrimitive.Description, { className: "hidden" })] }))] }));
|
|
1643
|
+
var { className, fullScreen, children, dataTestId = 'dialog-content' } = _a, props = __rest(_a, ["className", "fullScreen", "children", "dataTestId"]);
|
|
1644
|
+
return (jsxs(DialogPortal, { children: [jsx(DialogOverlay, { dataTestId: `${dataTestId}-overlay` }), jsxs(DialogPrimitive.Content, Object.assign({ className: cn('bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]', 'fixed left-[50%] top-[50%] z-50 flex max-h-[95dvh] w-full max-w-lg translate-x-[-50%] translate-y-[-50%] flex-col gap-4 rounded-lg border p-4 shadow-lg duration-200', className, fullScreen && 'h-full max-h-none w-full max-w-none rounded-none'), "aria-describedby": "dialog-content", "data-testid": dataTestId }, props, { children: [children, jsx(DialogPrimitive.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none", asChild: true, "data-testid": `${dataTestId}-close-button`, children: jsx(Button, { prefixIcon: XIcon, size: "small", variant: "text" }) }), jsx(DialogPrimitive.Description, { className: "hidden" })] }))] }));
|
|
1605
1645
|
};
|
|
1606
1646
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
1607
1647
|
const DialogHeader = (_a) => {
|
|
1608
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1609
|
-
return (jsx("div", Object.assign({ className: cn('flex flex-col space-y-1.5 text-left', className) }, props)));
|
|
1648
|
+
var { className, dataTestId = 'dialog-header' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1649
|
+
return (jsx("div", Object.assign({ className: cn('flex flex-col space-y-1.5 text-left', className), "data-testid": dataTestId }, props)));
|
|
1610
1650
|
};
|
|
1611
1651
|
DialogHeader.displayName = 'DialogHeader';
|
|
1612
1652
|
const DialogFooter = (_a) => {
|
|
1613
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1614
|
-
return (jsx("div", Object.assign({ className: cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className) }, props)));
|
|
1653
|
+
var { className, dataTestId = 'dialog-footer' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1654
|
+
return (jsx("div", Object.assign({ className: cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className), "data-testid": dataTestId }, props)));
|
|
1615
1655
|
};
|
|
1616
1656
|
DialogFooter.displayName = 'DialogFooter';
|
|
1617
1657
|
const DialogTitle = (_a) => {
|
|
1618
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1619
|
-
return (jsx(DialogPrimitive.Title, Object.assign({ className: cn('text-foreground text-lg font-semibold', className) }, props)));
|
|
1658
|
+
var { className, dataTestId = 'dialog-title' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1659
|
+
return (jsx(DialogPrimitive.Title, Object.assign({ className: cn('text-foreground text-lg font-semibold', className), "data-testid": dataTestId }, props)));
|
|
1620
1660
|
};
|
|
1621
1661
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
1622
1662
|
const DialogDescription = (_a) => {
|
|
1623
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1624
|
-
return (jsx(DialogPrimitive.Description, Object.assign({ className: cn('text-muted-foreground text-sm', className) }, props)));
|
|
1663
|
+
var { className, dataTestId = 'dialog-description' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1664
|
+
return (jsx(DialogPrimitive.Description, Object.assign({ className: cn('text-muted-foreground text-sm', className), "data-testid": dataTestId }, props)));
|
|
1625
1665
|
};
|
|
1626
1666
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
1627
1667
|
const Dialog = Object.assign($Dialog, {
|
|
@@ -1636,16 +1676,14 @@ const Dialog = Object.assign($Dialog, {
|
|
|
1636
1676
|
Description: DialogDescription,
|
|
1637
1677
|
});
|
|
1638
1678
|
|
|
1639
|
-
const ConfirmDialog = ({ open, title, children, yesLabel, noLabel, onConfirm, onClose, }) => (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { children: [jsx(Dialog.Header, { children: jsx(Dialog.Title, { children: title }) }), children, jsxs(Dialog.Footer, { children: [jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "red", children: noLabel !== null && noLabel !== void 0 ? noLabel : 'No' }) }), jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "green", onClick: onConfirm, children: yesLabel !== null && yesLabel !== void 0 ? yesLabel : 'Yes' }) })] })] }) }));
|
|
1679
|
+
const ConfirmDialog = ({ open, title, children, yesLabel, noLabel, onConfirm, onClose, dataTestId = 'confirm-dialog', }) => (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { dataTestId: `${dataTestId}-content`, children: [jsx(Dialog.Header, { dataTestId: `${dataTestId}-header`, children: jsx(Dialog.Title, { dataTestId: `${dataTestId}-title`, children: title }) }), children, jsxs(Dialog.Footer, { dataTestId: `${dataTestId}-footer`, children: [jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "red", "data-testid": `${dataTestId}-no-button`, children: noLabel !== null && noLabel !== void 0 ? noLabel : 'No' }) }), jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "green", onClick: onConfirm, "data-testid": `${dataTestId}-yes-button`, children: yesLabel !== null && yesLabel !== void 0 ? yesLabel : 'Yes' }) })] })] }) }));
|
|
1640
1680
|
|
|
1641
|
-
const $Sheet = (props) => (jsx(DialogPrimitive.Root, Object.assign({}, props)));
|
|
1642
|
-
$Sheet.displayName = DialogPrimitive.Root.displayName;
|
|
1643
1681
|
const SheetTrigger = DialogPrimitive.Trigger;
|
|
1644
1682
|
const SheetClose = DialogPrimitive.Close;
|
|
1645
1683
|
const SheetPortal = DialogPrimitive.Portal;
|
|
1646
1684
|
const SheetOverlay = (_a) => {
|
|
1647
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1648
|
-
return (jsx(DialogPrimitive.Overlay, Object.assign({ className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', className) }, props)));
|
|
1685
|
+
var { className, dataTestId } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1686
|
+
return (jsx(DialogPrimitive.Overlay, Object.assign({ className: cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80', className), "data-testid": dataTestId }, props)));
|
|
1649
1687
|
};
|
|
1650
1688
|
SheetOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
1651
1689
|
const sheetVariants = cva('fixed flex flex-col z-50 gap-4 bg-background p-4 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500', {
|
|
@@ -1662,31 +1700,31 @@ const sheetVariants = cva('fixed flex flex-col z-50 gap-4 bg-background p-4 shad
|
|
|
1662
1700
|
},
|
|
1663
1701
|
});
|
|
1664
1702
|
const SheetContent = (_a) => {
|
|
1665
|
-
var { side = 'right', className, children } = _a, props = __rest(_a, ["side", "className", "children"]);
|
|
1666
|
-
return (jsxs(SheetPortal, { children: [jsx(SheetOverlay, {}), jsxs(DialogPrimitive.Content, Object.assign({ className: cn(sheetVariants({ side }), className) }, props, { children: [children, jsx(DialogPrimitive.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none", asChild: true, children: jsx(Button, { prefixIcon: XIcon, size: "small", variant: "text" }) }), jsx(DialogPrimitive.Description, { className: "hidden" })] }))] }));
|
|
1703
|
+
var { side = 'right', className, children, dataTestId = 'sheet-content' } = _a, props = __rest(_a, ["side", "className", "children", "dataTestId"]);
|
|
1704
|
+
return (jsxs(SheetPortal, { children: [jsx(SheetOverlay, { dataTestId: `${dataTestId}-overlay` }), jsxs(DialogPrimitive.Content, Object.assign({ className: cn(sheetVariants({ side }), className), "data-testid": dataTestId }, props, { children: [children, jsx(DialogPrimitive.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-2 top-2 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none", asChild: true, "data-testid": `${dataTestId}-close-button`, children: jsx(Button, { prefixIcon: XIcon, size: "small", variant: "text" }) }), jsx(DialogPrimitive.Description, { className: "hidden" })] }))] }));
|
|
1667
1705
|
};
|
|
1668
1706
|
SheetContent.displayName = DialogPrimitive.Content.displayName;
|
|
1669
1707
|
const SheetHeader = (_a) => {
|
|
1670
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1671
|
-
return (jsx("div", Object.assign({ className: cn('flex flex-col space-y-2 text-center sm:text-left', className) }, props)));
|
|
1708
|
+
var { className, dataTestId = 'sheet-header' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1709
|
+
return (jsx("div", Object.assign({ className: cn('flex flex-col space-y-2 text-center sm:text-left', className), "data-testid": dataTestId }, props)));
|
|
1672
1710
|
};
|
|
1673
1711
|
SheetHeader.displayName = 'SheetHeader';
|
|
1674
1712
|
const SheetFooter = (_a) => {
|
|
1675
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1676
|
-
return (jsx("div", Object.assign({ className: cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className) }, props)));
|
|
1713
|
+
var { className, dataTestId = 'sheet-footer' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1714
|
+
return (jsx("div", Object.assign({ className: cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className), "data-testid": dataTestId }, props)));
|
|
1677
1715
|
};
|
|
1678
1716
|
SheetFooter.displayName = 'SheetFooter';
|
|
1679
1717
|
const SheetTitle = (_a) => {
|
|
1680
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1681
|
-
return (jsx(DialogPrimitive.Title, Object.assign({ className: cn('text-foreground text-lg font-semibold', className) }, props)));
|
|
1718
|
+
var { className, dataTestId = 'sheet-title' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1719
|
+
return (jsx(DialogPrimitive.Title, Object.assign({ className: cn('text-foreground text-lg font-semibold', className), "data-testid": dataTestId }, props)));
|
|
1682
1720
|
};
|
|
1683
1721
|
SheetTitle.displayName = DialogPrimitive.Title.displayName;
|
|
1684
1722
|
const SheetDescription = (_a) => {
|
|
1685
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1686
|
-
return (jsx(DialogPrimitive.Description, Object.assign({ className: cn('text-muted-foreground text-sm', className) }, props)));
|
|
1723
|
+
var { className, dataTestId = 'sheet-description' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1724
|
+
return (jsx(DialogPrimitive.Description, Object.assign({ className: cn('text-muted-foreground text-sm', className), "data-testid": dataTestId }, props)));
|
|
1687
1725
|
};
|
|
1688
1726
|
SheetDescription.displayName = DialogPrimitive.Description.displayName;
|
|
1689
|
-
const Sheet = Object.assign(
|
|
1727
|
+
const Sheet = Object.assign(DialogPrimitive.Root, {
|
|
1690
1728
|
Portal: SheetPortal,
|
|
1691
1729
|
Overlay: SheetOverlay,
|
|
1692
1730
|
Trigger: SheetTrigger,
|
|
@@ -1698,20 +1736,12 @@ const Sheet = Object.assign($Sheet, {
|
|
|
1698
1736
|
Description: SheetDescription,
|
|
1699
1737
|
});
|
|
1700
1738
|
|
|
1701
|
-
const FormDialog = ({ className, formClassName, open, title, form, children, submitLabel = 'Submit', cancelLabel = 'Cancel', extraAction, as: As = Sheet, onSubmit, onInvalid, onClose, }) => {
|
|
1739
|
+
const FormDialog = ({ className, formClassName, open, title, form, children, submitLabel = 'Submit', cancelLabel = 'Cancel', extraAction, as: As = Sheet, onSubmit, onInvalid, onClose, dataTestId = 'form-dialog', }) => {
|
|
1702
1740
|
const id = useId();
|
|
1703
|
-
|
|
1704
|
-
try {
|
|
1705
|
-
yield onSubmit(data, event);
|
|
1706
|
-
}
|
|
1707
|
-
catch (_a) {
|
|
1708
|
-
// do nothering
|
|
1709
|
-
}
|
|
1710
|
-
});
|
|
1711
|
-
return (jsx(As, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(As.Content, { className: className, children: [jsx(As.Header, { children: jsx(As.Title, { children: title }) }), jsx(FormProvider, Object.assign({}, form, { children: jsx("form", { id: `form-${id}`, className: cn('flex h-full w-full flex-col gap-2 overflow-auto', formClassName), onSubmit: form.handleSubmit(handleSubmit, onInvalid), children: children }) })), jsxs(As.Footer, { className: "w-full sm:justify-between", children: [extraAction, jsxs(As.Footer, { className: "ml-auto", children: [jsx(As.Close, { asChild: true, children: jsx(Button, { color: "red", children: cancelLabel }) }), jsx(Button, { color: "green", type: "submit", form: `form-${id}`, disabled: form.formState.isSubmitting, children: submitLabel })] })] })] }) }));
|
|
1741
|
+
return (jsx(As, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(As.Content, { className: className, dataTestId: `${dataTestId}-content`, children: [jsx(As.Header, { dataTestId: `${dataTestId}-header`, children: jsx(As.Title, { dataTestId: `${dataTestId}-title`, children: title }) }), jsx(FormProvider, Object.assign({}, form, { children: jsx("form", { id: `form-${id}`, className: cn('flex h-full w-full flex-col gap-2 overflow-auto', formClassName), onSubmit: form.handleSubmit(onSubmit, onInvalid), "data-testid": `${dataTestId}-form`, children: children }) })), jsxs(As.Footer, { className: "w-full sm:justify-between", dataTestId: `${dataTestId}-footer`, children: [extraAction, jsxs(As.Footer, { className: "ml-auto", dataTestId: `${dataTestId}-actions`, children: [jsx(As.Close, { asChild: true, children: jsx(Button, { color: "red", dataTestId: `${dataTestId}-cancel-button`, children: cancelLabel }) }), jsx(Button, { color: "green", type: "submit", form: `form-${id}`, disabled: form.formState.isSubmitting, dataTestId: `${dataTestId}-submit-button`, children: submitLabel })] })] })] }) }));
|
|
1712
1742
|
};
|
|
1713
1743
|
|
|
1714
|
-
function ListSorter({ className, items, idResolver, renderer, onChange, }) {
|
|
1744
|
+
function ListSorter({ className, items, dataTestId = 'list-sorter', idResolver, renderer, onChange, }) {
|
|
1715
1745
|
const adaptedItems = useMemo(() => items.map((value, index) => ({ id: idResolver(value, index), value })), [idResolver, items]);
|
|
1716
1746
|
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
|
|
1717
1747
|
const onDragEnd = ({ active, over }) => {
|
|
@@ -1729,39 +1759,39 @@ function ListSorter({ className, items, idResolver, renderer, onChange, }) {
|
|
|
1729
1759
|
}
|
|
1730
1760
|
onChange(sortedItems.map(({ value }) => value));
|
|
1731
1761
|
};
|
|
1732
|
-
return (jsx(DndContext, { sensors: sensors, modifiers: [restrictToFirstScrollableAncestor], collisionDetection: closestCenter, onDragEnd: onDragEnd, children: jsx(SortableContext, { items: adaptedItems, strategy: verticalListSortingStrategy, children: jsx("div", { className: className, children: adaptedItems.map((item, index) => (jsx(SortableItem, { item: item, index: index, renderer: renderer }, item.id))) }) }) }));
|
|
1762
|
+
return (jsx(DndContext, { sensors: sensors, modifiers: [restrictToFirstScrollableAncestor], collisionDetection: closestCenter, onDragEnd: onDragEnd, children: jsx(SortableContext, { items: adaptedItems, strategy: verticalListSortingStrategy, children: jsx("div", { className: className, "data-testid": dataTestId, children: adaptedItems.map((item, index) => (jsx(SortableItem, { item: item, index: index, renderer: renderer, dataTestId: dataTestId }, item.id))) }) }) }));
|
|
1733
1763
|
}
|
|
1734
|
-
function SortableItem({ item, index, renderer, }) {
|
|
1764
|
+
function SortableItem({ item, index, dataTestId, renderer, }) {
|
|
1735
1765
|
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: item.id });
|
|
1736
1766
|
const style = { transform: CSS.Transform.toString(transform), transition };
|
|
1737
|
-
return (jsx("div", Object.assign({ ref: setNodeRef, style: style }, attributes, { children: renderer(item.value, index, listeners) })));
|
|
1767
|
+
return (jsx("div", Object.assign({ ref: setNodeRef, style: style }, attributes, { "data-testid": `${dataTestId}-item-${index}`, children: renderer(item.value, index, listeners) })));
|
|
1738
1768
|
}
|
|
1739
1769
|
|
|
1740
|
-
function ListSorterDialog({ className, open, title, items, idResolver, renderer, cancelLabel, submitLabel, onSubmit, onClose, }) {
|
|
1770
|
+
function ListSorterDialog({ className, open, title, items, idResolver, renderer, cancelLabel, submitLabel, onSubmit, onClose, dataTestId = 'list-sorter-dialog', }) {
|
|
1741
1771
|
const [sortedItems, setSortedItems] = useState(structuredClone(items));
|
|
1742
1772
|
useEffect(() => {
|
|
1743
|
-
|
|
1773
|
+
if (!open) {
|
|
1744
1774
|
setSortedItems(structuredClone(items));
|
|
1745
|
-
}
|
|
1746
|
-
}, [items]);
|
|
1775
|
+
}
|
|
1776
|
+
}, [items, open]);
|
|
1747
1777
|
const preFinish = () => onSubmit(sortedItems);
|
|
1748
|
-
const customRenderer = (item, index, listeners) => (jsxs(Flex, { align: "center", className: "gap-4 p-4 focus:outline-none dark:bg-slate-900 hover:dark:bg-slate-800", children: [jsx(Flex, Object.assign({ align: "center", justify: "center", className: "cursor-move rounded-lg p-2 hover:bg-slate-200 dark:hover:bg-slate-700" }, listeners, { children: jsx(ArrowUpDownIcon, { className: "h-5 w-5" }) })), renderer(item, index, listeners)] }));
|
|
1749
|
-
return (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { className: className, onPointerDownOutside: (event) => event.preventDefault(), children: [jsx(Dialog.Header, { children: jsx(Dialog.Title, { children: title }) }), jsx(ListSorter, { className: "divide-y overflow-auto rounded-lg border dark:divide-slate-700 dark:border-slate-700 dark:text-white", items: sortedItems, idResolver: idResolver, renderer: customRenderer, onChange: setSortedItems }), jsxs(Dialog.Footer, { children: [jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "red", children: cancelLabel !== null && cancelLabel !== void 0 ? cancelLabel : 'Cancel' }) }), jsx(Button, { color: "green", onClick: preFinish, children: submitLabel !== null && submitLabel !== void 0 ? submitLabel : 'Submit' })] })] }) }));
|
|
1778
|
+
const customRenderer = (item, index, listeners) => (jsxs(Flex, { align: "center", className: "gap-4 p-4 focus:outline-none dark:bg-slate-900 hover:dark:bg-slate-800", "data-testid": `${dataTestId}-item-${index}`, children: [jsx(Flex, Object.assign({ align: "center", justify: "center", className: "cursor-move rounded-lg p-2 hover:bg-slate-200 dark:hover:bg-slate-700", "data-testid": `${dataTestId}-drag-handle-${index}` }, listeners, { children: jsx(ArrowUpDownIcon, { className: "h-5 w-5" }) })), renderer(item, index, listeners)] }));
|
|
1779
|
+
return (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { className: className, onPointerDownOutside: (event) => event.preventDefault(), dataTestId: `${dataTestId}-content`, children: [jsx(Dialog.Header, { dataTestId: `${dataTestId}-header`, children: jsx(Dialog.Title, { dataTestId: `${dataTestId}-title`, children: title }) }), jsx(ListSorter, { className: "divide-y overflow-auto rounded-lg border dark:divide-slate-700 dark:border-slate-700 dark:text-white", items: sortedItems, idResolver: idResolver, renderer: customRenderer, onChange: setSortedItems, dataTestId: `${dataTestId}-sorter` }), jsxs(Dialog.Footer, { dataTestId: `${dataTestId}-footer`, children: [jsx(Dialog.Close, { asChild: true, children: jsx(Button, { color: "red", dataTestId: `${dataTestId}-cancel-button`, children: cancelLabel !== null && cancelLabel !== void 0 ? cancelLabel : 'Cancel' }) }), jsx(Button, { color: "green", onClick: preFinish, dataTestId: `${dataTestId}-submit-button`, children: submitLabel !== null && submitLabel !== void 0 ? submitLabel : 'Submit' })] })] }) }));
|
|
1750
1780
|
}
|
|
1751
1781
|
|
|
1752
|
-
const PdfViewerDialog = ({ open, title, url, data, onClose }) => {
|
|
1753
|
-
return !(url || data) ? null : (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { className: "h-[95dvh] max-w-[95dvw]", children: [jsx(Dialog.Header, { children: jsx(Dialog.Title, { children: title }) }), (url || data) && (jsx("embed", { className: "rounded-lg", src: url !== null && url !== void 0 ? url : `data:application/pdf;base64,${data}`, type: "application/pdf", width: "100%", height: "100%" }))] }) }));
|
|
1782
|
+
const PdfViewerDialog = ({ open, title, url, data, onClose, dataTestId = 'pdf-viewer-dialog', }) => {
|
|
1783
|
+
return !(url || data) ? null : (jsx(Dialog, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(Dialog.Content, { className: "h-[95dvh] max-w-[95dvw]", dataTestId: `${dataTestId}-content`, children: [jsx(Dialog.Header, { dataTestId: `${dataTestId}-header`, children: jsx(Dialog.Title, { dataTestId: `${dataTestId}-title`, children: title }) }), (url || data) && (jsx("embed", { className: "rounded-lg", src: url !== null && url !== void 0 ? url : `data:application/pdf;base64,${data}`, type: "application/pdf", width: "100%", height: "100%", "data-testid": `${dataTestId}-embed` }))] }) }));
|
|
1754
1784
|
};
|
|
1755
1785
|
|
|
1756
1786
|
const Separator = (_a) => {
|
|
1757
|
-
var { className, orientation = 'horizontal', decorative = true } = _a, props = __rest(_a, ["className", "orientation", "decorative"]);
|
|
1758
|
-
return (jsx(SeparatorPrimitive.Root, Object.assign({ decorative: decorative, orientation: orientation, className: cn('bg-border shrink-0', orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]', className) }, props)));
|
|
1787
|
+
var { className, orientation = 'horizontal', decorative = true, dataTestId = 'separator' } = _a, props = __rest(_a, ["className", "orientation", "decorative", "dataTestId"]);
|
|
1788
|
+
return (jsx(SeparatorPrimitive.Root, Object.assign({ decorative: decorative, orientation: orientation, className: cn('bg-border shrink-0', orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]', className), "data-testid": dataTestId }, props)));
|
|
1759
1789
|
};
|
|
1760
1790
|
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
1761
1791
|
|
|
1762
1792
|
const Skeleton = (_a) => {
|
|
1763
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1764
|
-
return (jsx("div", Object.assign({ className: cn('bg-muted animate-pulse rounded-md', className) }, props)));
|
|
1793
|
+
var { className, dataTestId = 'skeleton' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1794
|
+
return (jsx("div", Object.assign({ className: cn('bg-muted animate-pulse rounded-md', className), "data-testid": dataTestId }, props)));
|
|
1765
1795
|
};
|
|
1766
1796
|
Skeleton.displayName = 'Skeleton';
|
|
1767
1797
|
|
|
@@ -1830,13 +1860,13 @@ const SidebarContextProvider = (_a) => {
|
|
|
1830
1860
|
};
|
|
1831
1861
|
SidebarContextProvider.displayName = 'SidebarContextProvider';
|
|
1832
1862
|
const SidebarComp = (_a) => {
|
|
1833
|
-
var { side = 'left', variant = 'sidebar', collapsible = 'offcanvas', className, children } = _a, props = __rest(_a, ["side", "variant", "collapsible", "className", "children"]);
|
|
1863
|
+
var { side = 'left', variant = 'sidebar', collapsible = 'offcanvas', className, children, dataTestId = 'sidebar' } = _a, props = __rest(_a, ["side", "variant", "collapsible", "className", "children", "dataTestId"]);
|
|
1834
1864
|
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
1835
1865
|
if (collapsible === 'none') {
|
|
1836
|
-
return (jsx("div", Object.assign({ className: cn('bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col', className) }, props, { children: children })));
|
|
1866
|
+
return (jsx("div", Object.assign({ "data-testid": dataTestId, className: cn('bg-sidebar text-sidebar-foreground flex h-full w-[--sidebar-width] flex-col', className) }, props, { children: children })));
|
|
1837
1867
|
}
|
|
1838
1868
|
if (isMobile) {
|
|
1839
|
-
return (jsx(Sheet, Object.assign({ open: openMobile, onOpenChange: setOpenMobile }, props, { children: jsx(Sheet.Content, { "data-sidebar": "sidebar", "data-mobile": "true", className: "bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden", style: {
|
|
1869
|
+
return (jsx(Sheet, Object.assign({ open: openMobile, onOpenChange: setOpenMobile }, props, { children: jsx(Sheet.Content, { "data-testid": dataTestId, "data-sidebar": "sidebar", "data-mobile": "true", className: "bg-sidebar text-sidebar-foreground w-[--sidebar-width] p-0 [&>button]:hidden", style: {
|
|
1840
1870
|
'--sidebar-width': SIDEBAR_WIDTH_MOBILE,
|
|
1841
1871
|
}, side: side, children: jsx("div", { className: "flex h-full w-full flex-col", children: children }) }) })));
|
|
1842
1872
|
}
|
|
@@ -1848,86 +1878,86 @@ const SidebarComp = (_a) => {
|
|
|
1848
1878
|
// Adjust the padding for floating and inset variants.
|
|
1849
1879
|
variant === 'floating' || variant === 'inset'
|
|
1850
1880
|
? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]'
|
|
1851
|
-
: 'border-sidebar-border group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l', className) }, props, { children: jsx("div", { "data-sidebar": "sidebar", className: "bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow", children: children }) }))] }));
|
|
1881
|
+
: 'border-sidebar-border group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l', className) }, props, { "data-testid": dataTestId, "data-state": state, children: jsx("div", { "data-sidebar": "sidebar", className: "bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow", children: children }) }))] }));
|
|
1852
1882
|
};
|
|
1853
1883
|
SidebarComp.displayName = 'Sidebar';
|
|
1854
1884
|
const SidebarTrigger = (_a) => {
|
|
1855
|
-
var { className, onClick } = _a, props = __rest(_a, ["className", "onClick"]);
|
|
1885
|
+
var { className, onClick, dataTestId = 'sidebar-trigger' } = _a, props = __rest(_a, ["className", "onClick", "dataTestId"]);
|
|
1856
1886
|
const { toggleSidebar } = useSidebar();
|
|
1857
|
-
return (jsx(Button, Object.assign({ "data-sidebar": "trigger", variant: "text", suffixIcon: PanelLeft, className: className, onClick: (event) => {
|
|
1887
|
+
return (jsx(Button, Object.assign({ "data-testid": dataTestId, "data-sidebar": "trigger", variant: "text", suffixIcon: PanelLeft, className: className, onClick: (event) => {
|
|
1858
1888
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
1859
1889
|
toggleSidebar();
|
|
1860
1890
|
} }, props)));
|
|
1861
1891
|
};
|
|
1862
1892
|
SidebarTrigger.displayName = 'SidebarTrigger';
|
|
1863
1893
|
const SidebarRail = (_a) => {
|
|
1864
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1894
|
+
var { className, dataTestId = 'sidebar-rail' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1865
1895
|
const { toggleSidebar } = useSidebar();
|
|
1866
|
-
return (jsx("button", Object.assign({ "data-sidebar": "rail", "aria-label": "Toggle Sidebar", tabIndex: -1, onClick: toggleSidebar, title: "Toggle Sidebar", className: cn('hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex', '[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize', '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize', 'group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full', '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2', '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2', className) }, props)));
|
|
1896
|
+
return (jsx("button", Object.assign({ "data-testid": dataTestId, "data-sidebar": "rail", "aria-label": "Toggle Sidebar", tabIndex: -1, onClick: toggleSidebar, title: "Toggle Sidebar", className: cn('hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex', '[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize', '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize', 'group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full', '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2', '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2', className) }, props)));
|
|
1867
1897
|
};
|
|
1868
1898
|
SidebarRail.displayName = 'SidebarRail';
|
|
1869
1899
|
const SidebarInset = (_a) => {
|
|
1870
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1871
|
-
return (jsx("main", Object.assign({ className: cn('bg-background relative flex min-h-svh flex-1 flex-col', 'peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow', className) }, props)));
|
|
1900
|
+
var { className, dataTestId = 'sidebar-inset' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1901
|
+
return (jsx("main", Object.assign({ "data-testid": dataTestId, className: cn('bg-background relative flex min-h-svh flex-1 flex-col', 'peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow', className) }, props)));
|
|
1872
1902
|
};
|
|
1873
1903
|
SidebarInset.displayName = 'SidebarInset';
|
|
1874
1904
|
const SidebarInput = (_a) => {
|
|
1875
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1876
|
-
return (jsx(BasicInput, Object.assign({ "data-sidebar": "input", className: cn('focus-visible:ring-sidebar-ring focus-visible:ring-2', className) }, props)));
|
|
1905
|
+
var { className, dataTestId = 'sidebar-input' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1906
|
+
return (jsx(BasicInput, Object.assign({ dataTestId: dataTestId, "data-sidebar": "input", className: cn('focus-visible:ring-sidebar-ring focus-visible:ring-2', className) }, props)));
|
|
1877
1907
|
};
|
|
1878
1908
|
SidebarInput.displayName = 'SidebarInput';
|
|
1879
1909
|
const SidebarHeader = (_a) => {
|
|
1880
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1881
|
-
return (jsx("div", Object.assign({ "data-sidebar": "header", className: cn('flex flex-col gap-2 p-2', className) }, props)));
|
|
1910
|
+
var { className, dataTestId = 'sidebar-header' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1911
|
+
return (jsx("div", Object.assign({ "data-testid": dataTestId, "data-sidebar": "header", className: cn('flex flex-col gap-2 p-2', className) }, props)));
|
|
1882
1912
|
};
|
|
1883
1913
|
SidebarHeader.displayName = 'SidebarHeader';
|
|
1884
1914
|
const SidebarFooter = (_a) => {
|
|
1885
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1886
|
-
return (jsx("div", Object.assign({ "data-sidebar": "footer", className: cn('flex flex-col gap-2 p-2', className) }, props)));
|
|
1915
|
+
var { className, dataTestId = 'sidebar-footer' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1916
|
+
return (jsx("div", Object.assign({ "data-testid": dataTestId, "data-sidebar": "footer", className: cn('flex flex-col gap-2 p-2', className) }, props)));
|
|
1887
1917
|
};
|
|
1888
1918
|
SidebarFooter.displayName = 'SidebarFooter';
|
|
1889
1919
|
const SidebarSeparator = (_a) => {
|
|
1890
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1891
|
-
return (jsx(Separator, Object.assign({ "data-sidebar": "separator", className: cn('bg-sidebar-border mx-2 w-auto', className) }, props)));
|
|
1920
|
+
var { className, dataTestId = 'sidebar-separator' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1921
|
+
return (jsx(Separator, Object.assign({ dataTestId: dataTestId, "data-sidebar": "separator", className: cn('bg-sidebar-border mx-2 w-auto', className) }, props)));
|
|
1892
1922
|
};
|
|
1893
1923
|
SidebarSeparator.displayName = 'SidebarSeparator';
|
|
1894
1924
|
const SidebarContent = (_a) => {
|
|
1895
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1896
|
-
return (jsx("div", Object.assign({ "data-sidebar": "content", className: cn('flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden', className) }, props)));
|
|
1925
|
+
var { className, dataTestId = 'sidebar-content' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1926
|
+
return (jsx("div", Object.assign({ "data-testid": dataTestId, "data-sidebar": "content", className: cn('flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden', className) }, props)));
|
|
1897
1927
|
};
|
|
1898
1928
|
SidebarContent.displayName = 'SidebarContent';
|
|
1899
1929
|
const SidebarGroup = (_a) => {
|
|
1900
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1901
|
-
return (jsx("div", Object.assign({ "data-sidebar": "group", className: cn('relative flex w-full min-w-0 flex-col p-2', className) }, props)));
|
|
1930
|
+
var { className, dataTestId = 'sidebar-group' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1931
|
+
return (jsx("div", Object.assign({ "data-testid": dataTestId, "data-sidebar": "group", className: cn('relative flex w-full min-w-0 flex-col p-2', className) }, props)));
|
|
1902
1932
|
};
|
|
1903
1933
|
SidebarGroup.displayName = 'SidebarGroup';
|
|
1904
1934
|
const SidebarGroupLabel = (_a) => {
|
|
1905
|
-
var { className, asChild = false } = _a, props = __rest(_a, ["className", "asChild"]);
|
|
1935
|
+
var { className, asChild = false, dataTestId = 'sidebar-group-label' } = _a, props = __rest(_a, ["className", "asChild", "dataTestId"]);
|
|
1906
1936
|
const Comp = asChild ? Slot : 'div';
|
|
1907
|
-
return (jsx(Comp, Object.assign({ "data-sidebar": "group-label", className: cn('text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-none transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0', 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0', className) }, props)));
|
|
1937
|
+
return (jsx(Comp, Object.assign({ "data-testid": dataTestId, "data-sidebar": "group-label", className: cn('text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-none transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0', 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0', className) }, props)));
|
|
1908
1938
|
};
|
|
1909
1939
|
SidebarGroupLabel.displayName = 'SidebarGroupLabel';
|
|
1910
1940
|
const SidebarGroupAction = (_a) => {
|
|
1911
|
-
var { className, asChild = false } = _a, props = __rest(_a, ["className", "asChild"]);
|
|
1941
|
+
var { className, asChild = false, dataTestId = 'sidebar-group-action' } = _a, props = __rest(_a, ["className", "asChild", "dataTestId"]);
|
|
1912
1942
|
const Comp = asChild ? Slot : 'button';
|
|
1913
|
-
return (jsx(Comp, Object.assign({ "data-sidebar": "group-action", className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
|
|
1943
|
+
return (jsx(Comp, Object.assign({ "data-testid": dataTestId, "data-sidebar": "group-action", className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
|
|
1914
1944
|
// Increases the hit area of the button on mobile.
|
|
1915
1945
|
'after:absolute after:-inset-2 after:md:hidden', 'group-data-[collapsible=icon]:hidden', className) }, props)));
|
|
1916
1946
|
};
|
|
1917
1947
|
SidebarGroupAction.displayName = 'SidebarGroupAction';
|
|
1918
1948
|
const SidebarGroupContent = (_a) => {
|
|
1919
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1920
|
-
return (jsx("div", Object.assign({ "data-sidebar": "group-content", className: cn('w-full text-sm', className) }, props)));
|
|
1949
|
+
var { className, dataTestId = 'sidebar-group-content' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1950
|
+
return (jsx("div", Object.assign({ "data-testid": dataTestId, "data-sidebar": "group-content", className: cn('w-full text-sm', className) }, props)));
|
|
1921
1951
|
};
|
|
1922
1952
|
SidebarGroupContent.displayName = 'SidebarGroupContent';
|
|
1923
1953
|
const SidebarMenu = (_a) => {
|
|
1924
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1925
|
-
return (jsx("ul", Object.assign({ "data-sidebar": "menu", className: cn('flex w-full min-w-0 flex-col gap-1', className) }, props)));
|
|
1954
|
+
var { className, dataTestId = 'sidebar-menu' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1955
|
+
return (jsx("ul", Object.assign({ "data-testid": dataTestId, "data-sidebar": "menu", className: cn('flex w-full min-w-0 flex-col gap-1', className) }, props)));
|
|
1926
1956
|
};
|
|
1927
1957
|
SidebarMenu.displayName = 'SidebarMenu';
|
|
1928
1958
|
const SidebarMenuItem = (_a) => {
|
|
1929
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1930
|
-
return (jsx("li", Object.assign({ "data-sidebar": "menu-item", className: cn('group/menu-item relative', className) }, props)));
|
|
1959
|
+
var { className, dataTestId = 'sidebar-menu-item' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
1960
|
+
return (jsx("li", Object.assign({ "data-testid": dataTestId, "data-sidebar": "menu-item", className: cn('group/menu-item relative', className) }, props)));
|
|
1931
1961
|
};
|
|
1932
1962
|
SidebarMenuItem.displayName = 'SidebarMenuItem';
|
|
1933
1963
|
const sidebarMenuButtonVariants = cva('peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0', {
|
|
@@ -1948,10 +1978,10 @@ const sidebarMenuButtonVariants = cva('peer/menu-button flex w-full items-center
|
|
|
1948
1978
|
},
|
|
1949
1979
|
});
|
|
1950
1980
|
const SidebarMenuButton = (_a) => {
|
|
1951
|
-
var { asChild = false, isActive = false, variant = 'default', size = 'default', tooltip, className } = _a, props = __rest(_a, ["asChild", "isActive", "variant", "size", "tooltip", "className"]);
|
|
1981
|
+
var { asChild = false, isActive = false, variant = 'default', size = 'default', tooltip, className, dataTestId = 'sidebar-menu-button' } = _a, props = __rest(_a, ["asChild", "isActive", "variant", "size", "tooltip", "className", "dataTestId"]);
|
|
1952
1982
|
const Comp = asChild ? Slot : 'button';
|
|
1953
1983
|
const { isMobile, state } = useSidebar();
|
|
1954
|
-
const button = (jsx(Comp, Object.assign({ "data-sidebar": "menu-button", "data-size": size, "data-active": isActive, className: cn(sidebarMenuButtonVariants({ variant, size }), className) }, props)));
|
|
1984
|
+
const button = (jsx(Comp, Object.assign({ "data-testid": dataTestId, "data-sidebar": "menu-button", "data-size": size, "data-active": isActive, className: cn(sidebarMenuButtonVariants({ variant, size }), className) }, props)));
|
|
1955
1985
|
if (!tooltip || state !== 'collapsed' || isMobile) {
|
|
1956
1986
|
return button;
|
|
1957
1987
|
}
|
|
@@ -1964,44 +1994,44 @@ const SidebarMenuButton = (_a) => {
|
|
|
1964
1994
|
};
|
|
1965
1995
|
SidebarMenuButton.displayName = 'SidebarMenuButton';
|
|
1966
1996
|
const SidebarMenuAction = (_a) => {
|
|
1967
|
-
var { className, asChild = false, showOnHover = false } = _a, props = __rest(_a, ["className", "asChild", "showOnHover"]);
|
|
1997
|
+
var { className, asChild = false, showOnHover = false, dataTestId = 'sidebar-menu-action' } = _a, props = __rest(_a, ["className", "asChild", "showOnHover", "dataTestId"]);
|
|
1968
1998
|
const Comp = asChild ? Slot : 'button';
|
|
1969
|
-
return (jsx(Comp, Object.assign({ "data-sidebar": "menu-action", className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
|
|
1999
|
+
return (jsx(Comp, Object.assign({ "data-testid": dataTestId, "data-sidebar": "menu-action", className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
|
|
1970
2000
|
// Increases the hit area of the button on mobile.
|
|
1971
2001
|
'after:absolute after:-inset-2 after:md:hidden', 'peer-data-[size=sm]/menu-button:top-1', 'peer-data-[size=default]/menu-button:top-1.5', 'peer-data-[size=lg]/menu-button:top-2.5', 'group-data-[collapsible=icon]:hidden', showOnHover &&
|
|
1972
2002
|
'peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0', className) }, props)));
|
|
1973
2003
|
};
|
|
1974
2004
|
SidebarMenuAction.displayName = 'SidebarMenuAction';
|
|
1975
2005
|
const SidebarMenuBadge = (_a) => {
|
|
1976
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1977
|
-
return (jsx("div", Object.assign({ "data-sidebar": "menu-badge", className: cn('text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums', 'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground', 'peer-data-[size=sm]/menu-button:top-1', 'peer-data-[size=default]/menu-button:top-1.5', 'peer-data-[size=lg]/menu-button:top-2.5', 'group-data-[collapsible=icon]:hidden', className) }, props)));
|
|
2006
|
+
var { className, dataTestId = 'sidebar-menu-badge' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2007
|
+
return (jsx("div", Object.assign({ "data-testid": dataTestId, "data-sidebar": "menu-badge", className: cn('text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums', 'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground', 'peer-data-[size=sm]/menu-button:top-1', 'peer-data-[size=default]/menu-button:top-1.5', 'peer-data-[size=lg]/menu-button:top-2.5', 'group-data-[collapsible=icon]:hidden', className) }, props)));
|
|
1978
2008
|
};
|
|
1979
2009
|
SidebarMenuBadge.displayName = 'SidebarMenuBadge';
|
|
1980
2010
|
const SidebarMenuSkeleton = (_a) => {
|
|
1981
|
-
var { className, showIcon = false } = _a, props = __rest(_a, ["className", "showIcon"]);
|
|
2011
|
+
var { className, showIcon = false, dataTestId = 'sidebar-menu-skeleton' } = _a, props = __rest(_a, ["className", "showIcon", "dataTestId"]);
|
|
1982
2012
|
// Random width between 50 to 90%.
|
|
1983
2013
|
const width = useMemo(() => {
|
|
1984
2014
|
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
1985
2015
|
}, []);
|
|
1986
|
-
return (jsxs("div", Object.assign({ "data-sidebar": "menu-skeleton", className: cn('flex h-8 items-center gap-2 rounded-md px-2', className) }, props, { children: [showIcon && jsx(Skeleton, { className: "size-4 rounded-md", "data-sidebar": "menu-skeleton-icon" }), jsx(Skeleton, { className: "h-4 max-w-[--skeleton-width] flex-1", "data-sidebar": "menu-skeleton-text", style: {
|
|
2016
|
+
return (jsxs("div", Object.assign({ "data-testid": dataTestId, "data-sidebar": "menu-skeleton", className: cn('flex h-8 items-center gap-2 rounded-md px-2', className) }, props, { children: [showIcon && jsx(Skeleton, { className: "size-4 rounded-md", "data-sidebar": "menu-skeleton-icon" }), jsx(Skeleton, { className: "h-4 max-w-[--skeleton-width] flex-1", "data-sidebar": "menu-skeleton-text", style: {
|
|
1987
2017
|
'--skeleton-width': width,
|
|
1988
2018
|
} })] })));
|
|
1989
2019
|
};
|
|
1990
2020
|
SidebarMenuSkeleton.displayName = 'SidebarMenuSkeleton';
|
|
1991
2021
|
const SidebarMenuSub = (_a) => {
|
|
1992
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
1993
|
-
return (jsx("ul", Object.assign({ "data-sidebar": "menu-sub", className: cn('border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5', 'group-data-[collapsible=icon]:hidden', className) }, props)));
|
|
2022
|
+
var { className, dataTestId = 'sidebar-menu-sub' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2023
|
+
return (jsx("ul", Object.assign({ "data-testid": dataTestId, "data-sidebar": "menu-sub", className: cn('border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5', 'group-data-[collapsible=icon]:hidden', className) }, props)));
|
|
1994
2024
|
};
|
|
1995
2025
|
SidebarMenuSub.displayName = 'SidebarMenuSub';
|
|
1996
2026
|
const SidebarMenuSubItem = (_a) => {
|
|
1997
|
-
var props = __rest(_a, []);
|
|
1998
|
-
return jsx("li", Object.assign({}, props));
|
|
2027
|
+
var { dataTestId = 'sidebar-menu-sub-item' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
2028
|
+
return jsx("li", Object.assign({ "data-testid": dataTestId }, props));
|
|
1999
2029
|
};
|
|
2000
2030
|
SidebarMenuSubItem.displayName = 'SidebarMenuSubItem';
|
|
2001
2031
|
const SidebarMenuSubButton = (_a) => {
|
|
2002
|
-
var { asChild = false, size = 'md', isActive, className } = _a, props = __rest(_a, ["asChild", "size", "isActive", "className"]);
|
|
2032
|
+
var { asChild = false, size = 'md', isActive, className, dataTestId = 'sidebar-menu-sub-button' } = _a, props = __rest(_a, ["asChild", "size", "isActive", "className", "dataTestId"]);
|
|
2003
2033
|
const Comp = asChild ? Slot : 'button';
|
|
2004
|
-
return (jsx(Comp, Object.assign({ "data-sidebar": "menu-sub-button", "data-size": size, "data-active": isActive, className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 w-full min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0', 'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground', size === 'sm' && 'text-xs', size === 'md' && 'text-sm', 'group-data-[collapsible=icon]:hidden', className) }, props)));
|
|
2034
|
+
return (jsx(Comp, Object.assign({ "data-testid": dataTestId, "data-sidebar": "menu-sub-button", "data-size": size, "data-active": isActive, className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 w-full min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0', 'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground', size === 'sm' && 'text-xs', size === 'md' && 'text-sm', 'group-data-[collapsible=icon]:hidden', className) }, props)));
|
|
2005
2035
|
};
|
|
2006
2036
|
SidebarMenuSubButton.displayName = 'SidebarMenuSubButton';
|
|
2007
2037
|
const Sidebar = Object.assign(SidebarComp, {
|
|
@@ -2028,7 +2058,7 @@ const Sidebar = Object.assign(SidebarComp, {
|
|
|
2028
2058
|
Trigger: SidebarTrigger,
|
|
2029
2059
|
});
|
|
2030
2060
|
|
|
2031
|
-
const Navbar = ({ className, sidebarTriggerClassName, leftSlot, rightSlot, }) => (jsx(Block, { className: cn('border-b p-2 dark:border-slate-700', className), fullWidth: true, children: jsxs(Flex, { align: "center", justify: "between", children: [jsxs(Flex, { align: "center", children: [jsx(Sidebar.Trigger, { className: sidebarTriggerClassName }), leftSlot] }), rightSlot] }) }));
|
|
2061
|
+
const Navbar = ({ className, sidebarTriggerClassName, leftSlot, rightSlot, dataTestId = 'navbar', }) => (jsx(Block, { className: cn('border-b p-2 dark:border-slate-700', className), fullWidth: true, dataTestId: dataTestId, children: jsxs(Flex, { align: "center", justify: "between", children: [jsxs(Flex, { align: "center", children: [jsx(Sidebar.Trigger, { className: sidebarTriggerClassName }), leftSlot] }), rightSlot] }) }));
|
|
2032
2062
|
|
|
2033
2063
|
const Layout = (_a) => {
|
|
2034
2064
|
var { children, className } = _a, _b = _a.sidebarProps, { basePath, header, items, extraContent, footer } = _b, sidebarProps = __rest(_b, ["basePath", "header", "items", "extraContent", "footer"]), { navbarProps, NavLink, useLocation } = _a;
|
|
@@ -2055,10 +2085,13 @@ function isLinkStartsWithPathname(link, pathname) {
|
|
|
2055
2085
|
}
|
|
2056
2086
|
|
|
2057
2087
|
const $Popover = PopoverPrimitive.Root;
|
|
2058
|
-
const PopoverTrigger =
|
|
2088
|
+
const PopoverTrigger = (_a) => {
|
|
2089
|
+
var { dataTestId = 'popover-trigger' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
2090
|
+
return (jsx(PopoverPrimitive.Trigger, Object.assign({ "data-testid": dataTestId }, props)));
|
|
2091
|
+
};
|
|
2059
2092
|
const PopoverContent = (_a) => {
|
|
2060
|
-
var { className, align = 'center', sideOffset = 4, container } = _a, props = __rest(_a, ["className", "align", "sideOffset", "container"]);
|
|
2061
|
-
return (jsx(PopoverPrimitive.Portal, { container: container, children: jsx(PopoverPrimitive.Content, Object.assign({ align: align, sideOffset: sideOffset, className: cn('z-50 rounded-md border bg-white p-1 shadow-md outline-none dark:border-slate-700 dark:bg-slate-900 dark:text-white', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', className) }, props)) }));
|
|
2093
|
+
var { className, align = 'center', sideOffset = 4, container, dataTestId = 'popover-content' } = _a, props = __rest(_a, ["className", "align", "sideOffset", "container", "dataTestId"]);
|
|
2094
|
+
return (jsx(PopoverPrimitive.Portal, { container: container, children: jsx(PopoverPrimitive.Content, Object.assign({ align: align, sideOffset: sideOffset, "data-testid": dataTestId, className: cn('z-50 rounded-md border bg-white p-1 shadow-md outline-none dark:border-slate-700 dark:bg-slate-900 dark:text-white', 'data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95', 'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95', 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', className) }, props)) }));
|
|
2062
2095
|
};
|
|
2063
2096
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
2064
2097
|
const Popover = Object.assign($Popover, {
|
|
@@ -2067,27 +2100,31 @@ const Popover = Object.assign($Popover, {
|
|
|
2067
2100
|
});
|
|
2068
2101
|
|
|
2069
2102
|
const Switch = (_a) => {
|
|
2070
|
-
var { className } = _a, _b = _a.thumbProps, _c = _b === void 0 ? {} : _b, { className: thumbClassName } = _c, thumbProps = __rest(_c, ["className"]), props = __rest(_a, ["className", "thumbProps"]);
|
|
2071
|
-
return (jsx(SwitchPrimitives.Root, Object.assign({ className: cn('peer inline-flex h-[calc(1.5rem+6px)] w-[calc(3rem+6px)] shrink-0 cursor-pointer items-center rounded-full border-[3px] border-transparent', 'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-600 focus-visible:ring-offset-2', 'focus-visible:ring-offset-white disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-slate-300', 'dark:focus-visible:ring-slate-200 dark:focus-visible:ring-offset-slate-800 dark:data-[state=checked]:bg-blue-700 dark:data-[state=unchecked]:bg-slate-700', className) }, props, { children: jsx(SwitchPrimitives.Thumb, Object.assign({ className: cn('pointer-events-none block h-6 w-6 rounded-full bg-white shadow-lg ring-0 transition-transform', 'data-[state=checked]:translate-x-6 data-[state=unchecked]:translate-x-0 dark:bg-slate-900', thumbClassName) }, thumbProps)) })));
|
|
2103
|
+
var { className } = _a, _b = _a.thumbProps, _c = _b === void 0 ? {} : _b, { className: thumbClassName } = _c, thumbProps = __rest(_c, ["className"]), { dataTestId = 'switch' } = _a, props = __rest(_a, ["className", "thumbProps", "dataTestId"]);
|
|
2104
|
+
return (jsx(SwitchPrimitives.Root, Object.assign({ className: cn('peer inline-flex h-[calc(1.5rem+6px)] w-[calc(3rem+6px)] shrink-0 cursor-pointer items-center rounded-full border-[3px] border-transparent', 'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-600 focus-visible:ring-offset-2', 'focus-visible:ring-offset-white disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-blue-600 data-[state=unchecked]:bg-slate-300', 'dark:focus-visible:ring-slate-200 dark:focus-visible:ring-offset-slate-800 dark:data-[state=checked]:bg-blue-700 dark:data-[state=unchecked]:bg-slate-700', className), "data-testid": dataTestId }, props, { children: jsx(SwitchPrimitives.Thumb, Object.assign({ className: cn('pointer-events-none block h-6 w-6 rounded-full bg-white shadow-lg ring-0 transition-transform', 'data-[state=checked]:translate-x-6 data-[state=unchecked]:translate-x-0 dark:bg-slate-900', thumbClassName), "data-testid": `${dataTestId}-thumb` }, thumbProps)) })));
|
|
2072
2105
|
};
|
|
2073
2106
|
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
2074
2107
|
|
|
2075
2108
|
const $Tabs = (_a) => {
|
|
2076
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
2077
|
-
return (jsx(TabsPrimitive.Root, Object.assign({ className: cn('flex flex-col gap-2', className) }, props)));
|
|
2109
|
+
var { className, dataTestId = 'tabs' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2110
|
+
return (jsx(TabsPrimitive.Root, Object.assign({ className: cn('flex flex-col gap-2', className), "data-testid": dataTestId }, props)));
|
|
2078
2111
|
};
|
|
2079
2112
|
$Tabs.displayName = TabsPrimitive.Root.displayName;
|
|
2080
2113
|
const TabsList = (_a) => {
|
|
2081
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
2082
|
-
return (jsx(TabsPrimitive.List, Object.assign({ className: cn('inline-flex w-full items-center justify-center gap-1 rounded-lg border bg-slate-100 p-1 text-slate-400 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-500', className) }, props)));
|
|
2114
|
+
var { className, dataTestId = 'tabs-list' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2115
|
+
return (jsx(TabsPrimitive.List, Object.assign({ className: cn('inline-flex w-full items-center justify-center gap-1 rounded-lg border bg-slate-100 p-1 text-slate-400 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-500', className), "data-testid": dataTestId }, props)));
|
|
2083
2116
|
};
|
|
2084
2117
|
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
2085
2118
|
const TabsTrigger = (_a) => {
|
|
2086
|
-
var { className } = _a, props = __rest(_a, ["className"]);
|
|
2087
|
-
return (jsx(TabsPrimitive.Trigger, Object.assign({ className: cn('inline-flex w-full items-center justify-center whitespace-nowrap rounded-md px-2 py-1.5 font-medium transition-all hover:bg-slate-200 disabled:pointer-events-none disabled:opacity-50 dark:hover:bg-slate-800', 'data-[state=active]:bg-white data-[state=active]:text-black data-[state=active]:shadow dark:data-[state=active]:bg-slate-700 dark:data-[state=active]:text-white', className) }, props)));
|
|
2119
|
+
var { className, dataTestId = 'tabs-trigger' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2120
|
+
return (jsx(TabsPrimitive.Trigger, Object.assign({ className: cn('inline-flex w-full items-center justify-center whitespace-nowrap rounded-md px-2 py-1.5 font-medium transition-all hover:bg-slate-200 disabled:pointer-events-none disabled:opacity-50 dark:hover:bg-slate-800', 'data-[state=active]:bg-white data-[state=active]:text-black data-[state=active]:shadow dark:data-[state=active]:bg-slate-700 dark:data-[state=active]:text-white', className), "data-testid": dataTestId }, props)));
|
|
2088
2121
|
};
|
|
2089
2122
|
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
2090
|
-
const TabsContent =
|
|
2123
|
+
const TabsContent = (_a) => {
|
|
2124
|
+
var { dataTestId = 'tabs-content' } = _a, props = __rest(_a, ["dataTestId"]);
|
|
2125
|
+
return (jsx(TabsPrimitive.Content, Object.assign({ "data-testid": dataTestId }, props)));
|
|
2126
|
+
};
|
|
2127
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
2091
2128
|
const Tabs = Object.assign($Tabs, {
|
|
2092
2129
|
List: TabsList,
|
|
2093
2130
|
Trigger: TabsTrigger,
|
|
@@ -2151,9 +2188,9 @@ function getSystemTheme(e) {
|
|
|
2151
2188
|
return e.matches ? 'dark' : 'light';
|
|
2152
2189
|
}
|
|
2153
2190
|
|
|
2154
|
-
const ThemeSelector = ({ className }) => {
|
|
2191
|
+
const ThemeSelector = ({ className, dataTestId = 'theme-selector' }) => {
|
|
2155
2192
|
const { resolvedTheme, setTheme } = useLayoutContext();
|
|
2156
|
-
return (jsxs(DropdownMenu, { children: [jsx(DropdownMenu.Trigger, { asChild: true, children: jsx(Button, { prefixIcon: resolvedTheme === 'dark' ? MoonIcon : SunIcon, className: className, variant: "text" }) }), jsxs(DropdownMenu.Content, { children: [jsxs(DropdownMenu.Item, { onClick: () => setTheme('light'), children: [jsx(DropdownMenu.Icon, { icon: SunIcon }), "Light"] }), jsxs(DropdownMenu.Item, { onClick: () => setTheme('dark'), children: [jsx(DropdownMenu.Icon, { icon: MoonIcon }), "Dark"] }), jsxs(DropdownMenu.Item, { onClick: () => setTheme('system'), children: [jsx(DropdownMenu.Icon, { icon: MonitorIcon }), "System"] })] })] }));
|
|
2193
|
+
return (jsxs(DropdownMenu, { children: [jsx(DropdownMenu.Trigger, { asChild: true, dataTestId: `${dataTestId}-trigger`, children: jsx(Button, { prefixIcon: resolvedTheme === 'dark' ? MoonIcon : SunIcon, className: className, variant: "text" }) }), jsxs(DropdownMenu.Content, { dataTestId: `${dataTestId}-content`, children: [jsxs(DropdownMenu.Item, { onClick: () => setTheme('light'), dataTestId: `${dataTestId}-light`, children: [jsx(DropdownMenu.Icon, { icon: SunIcon }), "Light"] }), jsxs(DropdownMenu.Item, { onClick: () => setTheme('dark'), dataTestId: `${dataTestId}-dark`, children: [jsx(DropdownMenu.Icon, { icon: MoonIcon }), "Dark"] }), jsxs(DropdownMenu.Item, { onClick: () => setTheme('system'), dataTestId: `${dataTestId}-system`, children: [jsx(DropdownMenu.Icon, { icon: MonitorIcon }), "System"] })] })] }));
|
|
2157
2194
|
};
|
|
2158
2195
|
|
|
2159
2196
|
export { Badge, BasicInput, BasicInputExtension, Block, Button, Card, CheckboxInput, Collapsible, ConfirmDialog, DataTable, DateTimeInput, Dialog, DropdownMenu, EmailInput, FileInput, Flex, FormDialog, FormGroup, FormInputs, Hint, Label, Layout, LayoutContext, LayoutContextProvider, List, ListSorter, ListSorterDialog, Navbar, NumberInput, Pagination, PasswordInput, PdfViewerDialog, Popover, SHOW_IDS_COOKIE_MAX_AGE, SHOW_IDS_COOKIE_NAME, SIDEBAR_COOKIE_MAX_AGE, SIDEBAR_COOKIE_NAME, SIDEBAR_KEYBOARD_SHORTCUT, SIDEBAR_WIDTH, SIDEBAR_WIDTH_ICON, SIDEBAR_WIDTH_MOBILE, SelectInput, Separator, Sheet, Sidebar, SidebarContext, SidebarContextProvider, Skeleton, Spinner, Switch, THEME_COOKIE_MAX_AGE, THEME_COOKIE_NAME, THEME_MEDIA_QUERY, Table, Tabs, TextInput, TextareaInput, ThemeSelector, Tooltip, cn, compareDates, generalComparator, getDisplayDate, getValueFromCookie, isEmpty, resolveTargetObject, useDays, useIsMobile, useLayoutContext, useLongPress, useMonths, useOnSwipe, useOutsideClick, usePagination, useSidebar };
|