@coveord/plasma-mantine 52.9.0 → 52.10.1
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/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-test.log +33 -32
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/code-editor/CodeEditor.d.ts.map +1 -1
- package/dist/cjs/components/code-editor/CodeEditor.js +8 -3
- package/dist/cjs/components/code-editor/CodeEditor.js.map +1 -1
- package/dist/cjs/components/collection/Collection.js +5 -3
- package/dist/cjs/components/collection/Collection.js.map +1 -1
- package/dist/cjs/components/date-range-picker/DateRangePickerPresetSelect.d.ts.map +1 -1
- package/dist/cjs/components/date-range-picker/DateRangePickerPresetSelect.js +2 -1
- package/dist/cjs/components/date-range-picker/DateRangePickerPresetSelect.js.map +1 -1
- package/dist/cjs/components/date-range-picker/EditableDateRangePicker.js +2 -2
- package/dist/cjs/components/date-range-picker/EditableDateRangePicker.js.map +1 -1
- package/dist/cjs/components/modal-wizard/ModalWizard.js +2 -2
- package/dist/cjs/components/modal-wizard/ModalWizard.js.map +1 -1
- package/dist/cjs/components/table/Table.d.ts.map +1 -1
- package/dist/cjs/components/table/Table.js +25 -13
- package/dist/cjs/components/table/Table.js.map +1 -1
- package/dist/cjs/components/table/Table.styles.d.ts.map +1 -1
- package/dist/cjs/components/table/Table.styles.js +1 -10
- package/dist/cjs/components/table/Table.styles.js.map +1 -1
- package/dist/cjs/components/table/Table.types.d.ts +14 -3
- package/dist/cjs/components/table/Table.types.d.ts.map +1 -1
- package/dist/cjs/components/table/TableFooter.js +2 -2
- package/dist/cjs/components/table/TableFooter.js.map +1 -1
- package/dist/cjs/components/table/TableHeader.js +1 -1
- package/dist/cjs/components/table/TableHeader.js.map +1 -1
- package/dist/cjs/components/table/TableLastUpdated.d.ts +24 -0
- package/dist/cjs/components/table/TableLastUpdated.d.ts.map +1 -0
- package/dist/cjs/components/table/TableLastUpdated.js +73 -0
- package/dist/cjs/components/table/TableLastUpdated.js.map +1 -0
- package/dist/cjs/components/table/TablePagination.d.ts.map +1 -1
- package/dist/cjs/components/table/TablePagination.js +1 -0
- package/dist/cjs/components/table/TablePagination.js.map +1 -1
- package/dist/cjs/components/table/TablePerPage.js +5 -3
- package/dist/cjs/components/table/TablePerPage.js.map +1 -1
- package/dist/cjs/components/table/layouts/RowLayout.d.ts.map +1 -1
- package/dist/cjs/components/table/layouts/RowLayout.js +41 -9
- package/dist/cjs/components/table/layouts/RowLayout.js.map +1 -1
- package/dist/cjs/components/table/useRowSelection.d.ts +2 -2
- package/dist/cjs/components/table/useRowSelection.d.ts.map +1 -1
- package/dist/cjs/components/table/useRowSelection.js +8 -3
- package/dist/cjs/components/table/useRowSelection.js.map +1 -1
- package/dist/cjs/theme/Theme.js +1 -1
- package/dist/cjs/theme/Theme.js.map +1 -1
- package/dist/esm/components/code-editor/CodeEditor.d.ts.map +1 -1
- package/dist/esm/components/code-editor/CodeEditor.js +8 -3
- package/dist/esm/components/code-editor/CodeEditor.js.map +1 -1
- package/dist/esm/components/collection/Collection.js +5 -3
- package/dist/esm/components/collection/Collection.js.map +1 -1
- package/dist/esm/components/date-range-picker/DateRangePickerPresetSelect.d.ts.map +1 -1
- package/dist/esm/components/date-range-picker/DateRangePickerPresetSelect.js +2 -1
- package/dist/esm/components/date-range-picker/DateRangePickerPresetSelect.js.map +1 -1
- package/dist/esm/components/date-range-picker/EditableDateRangePicker.js +2 -2
- package/dist/esm/components/date-range-picker/EditableDateRangePicker.js.map +1 -1
- package/dist/esm/components/modal-wizard/ModalWizard.js +2 -2
- package/dist/esm/components/modal-wizard/ModalWizard.js.map +1 -1
- package/dist/esm/components/table/Table.d.ts.map +1 -1
- package/dist/esm/components/table/Table.js +27 -15
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.styles.d.ts.map +1 -1
- package/dist/esm/components/table/Table.styles.js +1 -10
- package/dist/esm/components/table/Table.styles.js.map +1 -1
- package/dist/esm/components/table/Table.types.d.ts +14 -3
- package/dist/esm/components/table/Table.types.d.ts.map +1 -1
- package/dist/esm/components/table/Table.types.js.map +1 -1
- package/dist/esm/components/table/TableFooter.js +2 -2
- package/dist/esm/components/table/TableFooter.js.map +1 -1
- package/dist/esm/components/table/TableHeader.js +1 -1
- package/dist/esm/components/table/TableHeader.js.map +1 -1
- package/dist/esm/components/table/TableLastUpdated.d.ts +24 -0
- package/dist/esm/components/table/TableLastUpdated.d.ts.map +1 -0
- package/dist/esm/components/table/TableLastUpdated.js +62 -0
- package/dist/esm/components/table/TableLastUpdated.js.map +1 -0
- package/dist/esm/components/table/TablePagination.d.ts.map +1 -1
- package/dist/esm/components/table/TablePagination.js +1 -0
- package/dist/esm/components/table/TablePagination.js.map +1 -1
- package/dist/esm/components/table/TablePerPage.js +5 -3
- package/dist/esm/components/table/TablePerPage.js.map +1 -1
- package/dist/esm/components/table/layouts/RowLayout.d.ts.map +1 -1
- package/dist/esm/components/table/layouts/RowLayout.js +42 -10
- package/dist/esm/components/table/layouts/RowLayout.js.map +1 -1
- package/dist/esm/components/table/useRowSelection.d.ts +2 -2
- package/dist/esm/components/table/useRowSelection.d.ts.map +1 -1
- package/dist/esm/components/table/useRowSelection.js +8 -3
- package/dist/esm/components/table/useRowSelection.js.map +1 -1
- package/dist/esm/theme/Theme.js +1 -1
- package/dist/esm/theme/Theme.js.map +1 -1
- package/package.json +17 -17
- package/src/__tests__/VitestSetup.ts +12 -0
- package/src/components/code-editor/CodeEditor.tsx +5 -3
- package/src/components/code-editor/__tests__/CodeEditor.spec.tsx +1 -0
- package/src/components/date-range-picker/DateRangePickerPresetSelect.tsx +1 -0
- package/src/components/date-range-picker/__tests__/DateRangePickerInlineCalendar.spec.tsx +2 -0
- package/src/components/date-range-picker/__tests__/DateRangePickerPopoverCalendar.spec.tsx +4 -19
- package/src/components/date-range-picker/__tests__/EditableDateRangePicker.spec.tsx +3 -3
- package/src/components/modal-wizard/__tests__/ModalWizard.spec.tsx +19 -4
- package/src/components/table/Table.styles.ts +0 -9
- package/src/components/table/Table.tsx +22 -13
- package/src/components/table/Table.types.ts +14 -3
- package/src/components/table/TableFooter.tsx +1 -1
- package/src/components/table/TableHeader.tsx +1 -1
- package/src/components/table/TableLastUpdated.tsx +51 -0
- package/src/components/table/TablePagination.tsx +1 -0
- package/src/components/table/TablePerPage.tsx +3 -3
- package/src/components/table/__tests__/Table.spec.tsx +44 -5
- package/src/components/table/__tests__/TableActions.spec.tsx +4 -3
- package/src/components/table/__tests__/TableDateRangePicker.spec.tsx +26 -59
- package/src/components/table/__tests__/TableLastUpdated.spec.tsx +97 -0
- package/src/components/table/__tests__/TablePredicate.spec.tsx +7 -55
- package/src/components/table/layouts/RowLayout.tsx +45 -11
- package/src/components/table/useRowSelection.ts +13 -6
package/dist/cjs/theme/Theme.js
CHANGED
|
@@ -16,7 +16,6 @@ var _plasmareacticons = require("@coveord/plasma-react-icons");
|
|
|
16
16
|
var _plasmatokens = require("@coveord/plasma-tokens");
|
|
17
17
|
var _core = require("@mantine/core");
|
|
18
18
|
var _PlasmaColors = require("./PlasmaColors");
|
|
19
|
-
var _theme_colors;
|
|
20
19
|
var plasmaTheme = {
|
|
21
20
|
// These are overrides over https://github.com/mantinedev/mantine/blob/master/src/mantine-styles/src/theme/default-theme.ts
|
|
22
21
|
colorScheme: "light",
|
|
@@ -299,6 +298,7 @@ var plasmaTheme = {
|
|
|
299
298
|
Notification: {
|
|
300
299
|
styles: function(theme, param) {
|
|
301
300
|
var notificationType = param.color;
|
|
301
|
+
var _theme_colors;
|
|
302
302
|
return {
|
|
303
303
|
root: {
|
|
304
304
|
borderColor: theme.colors.gray[3],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/theme/Theme.tsx"],"sourcesContent":["import {CheckSize16Px, InfoSize24Px} from '@coveord/plasma-react-icons';\nimport {color} from '@coveord/plasma-tokens';\nimport {\n getSize,\n rem,\n type MantineThemeOverride,\n type NotificationProps,\n type StepperStylesParams,\n type TabsStylesParams,\n} from '@mantine/core';\n\nimport {PlasmaColors} from './PlasmaColors';\n\nexport const plasmaTheme: MantineThemeOverride = {\n // These are overrides over https://github.com/mantinedev/mantine/blob/master/src/mantine-styles/src/theme/default-theme.ts\n colorScheme: 'light',\n fontFamily: 'canada-type-gibson, sans-serif',\n black: color.primary.gray[9],\n defaultRadius: 8,\n lineHeight: 1.5,\n spacing: {\n xs: '8px',\n sm: '16px',\n md: '24px',\n lg: '32px',\n xl: '40px',\n },\n primaryColor: 'action',\n headings: {\n fontFamily: 'canada-type-gibson, sans-serif',\n fontWeight: 500,\n sizes: {\n h1: {fontSize: '48px', lineHeight: undefined, fontWeight: 300},\n h2: {fontSize: '32px', lineHeight: undefined, fontWeight: 500},\n h3: {fontSize: '24px', lineHeight: undefined, fontWeight: 500},\n h4: {fontSize: '18px', lineHeight: undefined, fontWeight: 300},\n h5: {fontSize: '14px', lineHeight: undefined, fontWeight: 500},\n h6: {fontSize: '12px', lineHeight: undefined, fontWeight: 500},\n },\n },\n shadows: {\n xs: '0px 1px 0px rgba(4, 8, 31, 0.08)',\n sm: '0px 2px 4px rgba(4, 8, 31, 0.12)',\n md: '0px 4px 8px rgba(4, 8, 31, 0.08)',\n lg: '0px 8px 16px rgba(7, 12, 41, 0.06)',\n xl: '0px 16px 24px rgba(4, 8, 31, 0.06)',\n },\n colors: PlasmaColors,\n components: {\n Alert: {\n defaultProps: {\n icon: <InfoSize24Px height={24} />,\n color: 'navy',\n },\n styles: {\n title: {\n fontWeight: 500,\n },\n },\n },\n Title: {\n styles: {\n root: {\n '&:is(h1,h2,h3,h4,h5,h6)': {letterSpacing: '0.011em'},\n },\n },\n },\n Text: {\n defaultProps: {\n weight: 300,\n },\n styles: (theme, {}, {size}) => ({\n root: {\n fontSize: getSize({size: size ?? 'sm', sizes: theme.fontSizes}),\n },\n }),\n },\n Button: {\n styles: () => ({\n root: {\n fontWeight: 400,\n },\n }),\n variants: {\n outline: () => ({\n root: {\n backgroundColor: 'white',\n },\n }),\n },\n },\n Modal: {\n styles: (theme, {fullScreen, padding}, {size, variant}) => ({\n content: {\n flex: fullScreen\n ? '0 0 100%'\n : `0 0 ${getSize({\n size,\n sizes: {\n xs: rem(432),\n sm: rem(664),\n md: rem(896),\n lg: rem(1120),\n xl: rem('88%'),\n },\n })}`,\n overflow: 'auto',\n },\n title: {\n width: '100%',\n fontSize: theme.headings.sizes.h3.fontSize,\n lineHeight: theme.headings.sizes.h3.lineHeight,\n fontWeight: 500,\n },\n header: {\n borderBottom: variant !== 'prompt' ? `1px solid ${color.primary.gray[3]}` : null,\n },\n body: {\n '&:not(:only-child)': {\n paddingTop: variant === 'prompt' ? 0 : getSize({size: padding, sizes: plasmaTheme.spacing}),\n },\n },\n }),\n },\n ModalOverlay: {\n defaultProps: {\n color: color.primary.navy[9],\n opacity: 0.9,\n },\n },\n InputWrapper: {\n defaultProps: {\n withAsterisk: false,\n },\n styles: (theme) => ({\n label: {\n marginBottom: theme.spacing.xs,\n },\n description: {\n fontSize: theme.fontSizes.sm,\n color: theme.colors.gray[7],\n marginBottom: theme.spacing.xs,\n },\n invalid: {\n color: theme.colors.red[9],\n borderColor: theme.colors.red[6],\n },\n error: {\n color: theme.colors.red[9],\n },\n }),\n },\n TextInput: {\n defaultProps: {\n radius: 8,\n },\n },\n Tooltip: {\n defaultProps: {\n color: 'navy',\n withArrow: true,\n withinPortal: true,\n multiline: true,\n zIndex: 10000,\n },\n },\n Loader: {\n defaultProps: {\n variant: 'dots',\n color: 'action',\n },\n },\n DateRangePicker: {\n styles: {\n cell: {\n textAlign: 'center',\n },\n },\n },\n Anchor: {\n defaultProps: {\n color: 'action.6',\n },\n styles: (theme) => ({\n root: {\n ...theme.fn.hover({\n textDecoration: 'underline',\n color: theme.colors.action[8],\n }),\n },\n }),\n },\n Checkbox: {\n defaultProps: {\n radius: 'sm',\n },\n styles: (theme) => ({\n label: {\n fontSize: theme.fontSizes.sm,\n fontWeight: 300,\n },\n }),\n },\n List: {\n styles: () => ({\n root: {\n listStyleType: 'disc',\n },\n }),\n },\n Radio: {\n styles: {\n labelWrapper: {\n display: 'flex',\n alignItems: 'flex-start',\n },\n },\n },\n Popover: {\n defaultProps: {\n shadow: 'md',\n withArrow: true,\n },\n },\n Badge: {\n styles: {\n root: {\n textTransform: 'none',\n padding: '4px 8px',\n fontWeight: 500,\n },\n },\n },\n ColorSwatch: {\n defaultProps: {\n size: 8,\n withShadow: false,\n },\n },\n MenuItem: {\n defaultProps: {\n fw: 300,\n },\n },\n Notification: {\n styles: (theme, {color: notificationType}: NotificationProps) => ({\n root: {\n borderColor: theme.colors.gray[3],\n backgroundColor: theme.colors.gray[0],\n boxShadow: theme.shadows.lg,\n padding: theme.spacing.sm,\n '&[data-with-icon]': {\n paddingLeft: theme.spacing.sm,\n },\n },\n icon: {\n backgroundColor: 'transparent',\n marginRight: theme.spacing.sm,\n color: theme.colors?.[notificationType][6],\n },\n closeButton: {\n margin: theme.spacing.xs,\n color: theme.colors.gray[5],\n },\n }),\n defaultProps: {\n icon: <InfoSize24Px height={24} />,\n color: 'info',\n },\n },\n Skeleton: {\n styles: {\n visible: {\n '&::before': {zIndex: 'unset'},\n '&::after': {zIndex: 'unset'},\n },\n },\n },\n SegmentedControl: {\n styles: (theme) => ({\n root: {\n backgroundColor: theme.colors.gray[2],\n },\n }),\n },\n Stepper: {\n defaultProps: {\n size: 'xs',\n completedIcon: <CheckSize16Px />,\n },\n styles: (theme, {}: StepperStylesParams, {size}) => ({\n step: {\n '&[disabled]': {\n color: theme.colors.gray[5],\n '& .mantine-Stepper-stepDescription': {\n color: theme.colors.gray[5],\n },\n '& .mantine-Stepper-stepIcon': {\n borderColor: theme.colors.gray[1],\n },\n },\n },\n stepIcon: {\n fontWeight: 500,\n backgroundColor: theme.colors.gray[1],\n color: 'inherit',\n border: `${rem(1)} solid ${theme.colors.gray[3]}`,\n '&[data-progress]': {\n backgroundColor: theme.white,\n },\n\n '&[data-completed]': {\n backgroundColor: theme.white,\n borderColor: theme.colors.lime[6],\n color: theme.colors.lime[6],\n },\n },\n stepCompletedIcon: {\n color: theme.colors.lime[6],\n fontSize: rem(16),\n },\n stepDescription: {\n color: theme.colors.gray[7],\n fontSize: getSize({size, sizes: theme.fontSizes}),\n },\n separator: {\n height: rem(1),\n backgroundColor: theme.colors.gray[3],\n },\n separatorActive: {\n backgroundColor: theme.colors.gray[3],\n },\n verticalSeparator: {\n borderLeft: `${rem(1)} solid ${theme.colors.gray[3]}`,\n },\n verticalSeparatorActive: {\n borderColor: theme.colors.gray[3],\n },\n }),\n },\n Tabs: {\n styles: (theme, {orientation}: TabsStylesParams) => ({\n tabsList: {\n [orientation === 'horizontal' ? 'borderBottom' : 'borderRight']: `${rem(1)} solid ${\n theme.colors.gray[3]\n }`,\n },\n tab: {\n [orientation === 'horizontal' ? 'borderBottom' : 'borderRight']: `${rem(1)} solid transparent`,\n [orientation === 'horizontal' ? 'marginBottom' : 'marginRight']: rem(-1),\n },\n }),\n },\n Select: {\n styles: (theme) => ({\n input: {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.colors.gray[7],\n },\n item: {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.colors.gray[7],\n\n '&[data-hovered]': {\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[1],\n },\n\n '&[data-selected]': {\n backgroundColor: theme.fn.variant({variant: 'light'}).background,\n color: theme.fn.variant({variant: 'light'}).color,\n ...theme.fn.hover({backgroundColor: theme.fn.variant({variant: 'light'}).hover}),\n },\n },\n }),\n },\n },\n};\n"],"names":["plasmaTheme","theme","colorScheme","fontFamily","black","color","primary","gray","defaultRadius","lineHeight","spacing","xs","sm","md","lg","xl","primaryColor","headings","fontWeight","sizes","h1","fontSize","undefined","h2","h3","h4","h5","h6","shadows","colors","PlasmaColors","components","Alert","defaultProps","icon","InfoSize24Px","height","styles","title","Title","root","letterSpacing","Text","weight","size","getSize","fontSizes","Button","variants","outline","backgroundColor","Modal","fullScreen","padding","variant","content","flex","rem","overflow","width","header","borderBottom","body","paddingTop","ModalOverlay","navy","opacity","InputWrapper","withAsterisk","label","marginBottom","description","invalid","red","borderColor","error","TextInput","radius","Tooltip","withArrow","withinPortal","multiline","zIndex","Loader","DateRangePicker","cell","textAlign","Anchor","fn","hover","textDecoration","action","Checkbox","List","listStyleType","Radio","labelWrapper","display","alignItems","Popover","shadow","Badge","textTransform","ColorSwatch","withShadow","MenuItem","fw","Notification","notificationType","boxShadow","paddingLeft","marginRight","closeButton","margin","Skeleton","visible","SegmentedControl","Stepper","completedIcon","CheckSize16Px","step","stepIcon","border","white","lime","stepCompletedIcon","stepDescription","separator","separatorActive","verticalSeparator","borderLeft","verticalSeparatorActive","Tabs","orientation","tabsList","tab","Select","input","dark","item","background"],"mappings":";;;;+BAaaA;;;eAAAA;;;;;;;gCAb6B;4BACtB;oBAQb;4BAEoB;IAuPAC;AArPpB,IAAMD,cAAoC;IAC7C,2HAA2H;IAC3HE,aAAa;IACbC,YAAY;IACZC,OAAOC,mBAAK,CAACC,OAAO,CAACC,IAAI,CAAC,EAAE;IAC5BC,eAAe;IACfC,YAAY;IACZC,SAAS;QACLC,IAAI;QACJC,IAAI;QACJC,IAAI;QACJC,IAAI;QACJC,IAAI;IACR;IACAC,cAAc;IACdC,UAAU;QACNd,YAAY;QACZe,YAAY;QACZC,OAAO;YACHC,IAAI;gBAACC,UAAU;gBAAQZ,YAAYa;gBAAWJ,YAAY;YAAG;YAC7DK,IAAI;gBAACF,UAAU;gBAAQZ,YAAYa;gBAAWJ,YAAY;YAAG;YAC7DM,IAAI;gBAACH,UAAU;gBAAQZ,YAAYa;gBAAWJ,YAAY;YAAG;YAC7DO,IAAI;gBAACJ,UAAU;gBAAQZ,YAAYa;gBAAWJ,YAAY;YAAG;YAC7DQ,IAAI;gBAACL,UAAU;gBAAQZ,YAAYa;gBAAWJ,YAAY;YAAG;YAC7DS,IAAI;gBAACN,UAAU;gBAAQZ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,GAAGmC,KAAK;wBAAA;oBAEtF;gBACJ;;QACJ;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"sources":["../../../src/theme/Theme.tsx"],"sourcesContent":["import {CheckSize16Px, InfoSize24Px} from '@coveord/plasma-react-icons';\nimport {color} from '@coveord/plasma-tokens';\nimport {\n getSize,\n rem,\n type MantineThemeOverride,\n type NotificationProps,\n type StepperStylesParams,\n type TabsStylesParams,\n} from '@mantine/core';\n\nimport {PlasmaColors} from './PlasmaColors';\n\nexport const plasmaTheme: MantineThemeOverride = {\n // These are overrides over https://github.com/mantinedev/mantine/blob/master/src/mantine-styles/src/theme/default-theme.ts\n colorScheme: 'light',\n fontFamily: 'canada-type-gibson, sans-serif',\n black: color.primary.gray[9],\n defaultRadius: 8,\n lineHeight: 1.5,\n spacing: {\n xs: '8px',\n sm: '16px',\n md: '24px',\n lg: '32px',\n xl: '40px',\n },\n primaryColor: 'action',\n headings: {\n fontFamily: 'canada-type-gibson, sans-serif',\n fontWeight: 500,\n sizes: {\n h1: {fontSize: '48px', lineHeight: undefined, fontWeight: 300},\n h2: {fontSize: '32px', lineHeight: undefined, fontWeight: 500},\n h3: {fontSize: '24px', lineHeight: undefined, fontWeight: 500},\n h4: {fontSize: '18px', lineHeight: undefined, fontWeight: 300},\n h5: {fontSize: '14px', lineHeight: undefined, fontWeight: 500},\n h6: {fontSize: '12px', lineHeight: undefined, fontWeight: 500},\n },\n },\n shadows: {\n xs: '0px 1px 0px rgba(4, 8, 31, 0.08)',\n sm: '0px 2px 4px rgba(4, 8, 31, 0.12)',\n md: '0px 4px 8px rgba(4, 8, 31, 0.08)',\n lg: '0px 8px 16px rgba(7, 12, 41, 0.06)',\n xl: '0px 16px 24px rgba(4, 8, 31, 0.06)',\n },\n colors: PlasmaColors,\n components: {\n Alert: {\n defaultProps: {\n icon: <InfoSize24Px height={24} />,\n color: 'navy',\n },\n styles: {\n title: {\n fontWeight: 500,\n },\n },\n },\n Title: {\n styles: {\n root: {\n '&:is(h1,h2,h3,h4,h5,h6)': {letterSpacing: '0.011em'},\n },\n },\n },\n Text: {\n defaultProps: {\n weight: 300,\n },\n styles: (theme, {}, {size}) => ({\n root: {\n fontSize: getSize({size: size ?? 'sm', sizes: theme.fontSizes}),\n },\n }),\n },\n Button: {\n styles: () => ({\n root: {\n fontWeight: 400,\n },\n }),\n variants: {\n outline: () => ({\n root: {\n backgroundColor: 'white',\n },\n }),\n },\n },\n Modal: {\n styles: (theme, {fullScreen, padding}, {size, variant}) => ({\n content: {\n flex: fullScreen\n ? '0 0 100%'\n : `0 0 ${getSize({\n size,\n sizes: {\n xs: rem(432),\n sm: rem(664),\n md: rem(896),\n lg: rem(1120),\n xl: rem('88%'),\n },\n })}`,\n overflow: 'auto',\n },\n title: {\n width: '100%',\n fontSize: theme.headings.sizes.h3.fontSize,\n lineHeight: theme.headings.sizes.h3.lineHeight,\n fontWeight: 500,\n },\n header: {\n borderBottom: variant !== 'prompt' ? `1px solid ${color.primary.gray[3]}` : null,\n },\n body: {\n '&:not(:only-child)': {\n paddingTop: variant === 'prompt' ? 0 : getSize({size: padding, sizes: plasmaTheme.spacing}),\n },\n },\n }),\n },\n ModalOverlay: {\n defaultProps: {\n color: color.primary.navy[9],\n opacity: 0.9,\n },\n },\n InputWrapper: {\n defaultProps: {\n withAsterisk: false,\n },\n styles: (theme) => ({\n label: {\n marginBottom: theme.spacing.xs,\n },\n description: {\n fontSize: theme.fontSizes.sm,\n color: theme.colors.gray[7],\n marginBottom: theme.spacing.xs,\n },\n invalid: {\n color: theme.colors.red[9],\n borderColor: theme.colors.red[6],\n },\n error: {\n color: theme.colors.red[9],\n },\n }),\n },\n TextInput: {\n defaultProps: {\n radius: 8,\n },\n },\n Tooltip: {\n defaultProps: {\n color: 'navy',\n withArrow: true,\n withinPortal: true,\n multiline: true,\n zIndex: 10000,\n },\n },\n Loader: {\n defaultProps: {\n variant: 'dots',\n color: 'action',\n },\n },\n DateRangePicker: {\n styles: {\n cell: {\n textAlign: 'center',\n },\n },\n },\n Anchor: {\n defaultProps: {\n color: 'action.6',\n },\n styles: (theme) => ({\n root: {\n ...theme.fn.hover({\n textDecoration: 'underline',\n color: theme.colors.action[8],\n }),\n },\n }),\n },\n Checkbox: {\n defaultProps: {\n radius: 'sm',\n },\n styles: (theme) => ({\n label: {\n fontSize: theme.fontSizes.sm,\n fontWeight: 300,\n },\n }),\n },\n List: {\n styles: () => ({\n root: {\n listStyleType: 'disc',\n },\n }),\n },\n Radio: {\n styles: {\n labelWrapper: {\n display: 'flex',\n alignItems: 'flex-start',\n },\n },\n },\n Popover: {\n defaultProps: {\n shadow: 'md',\n withArrow: true,\n },\n },\n Badge: {\n styles: {\n root: {\n textTransform: 'none',\n padding: '4px 8px',\n fontWeight: 500,\n },\n },\n },\n ColorSwatch: {\n defaultProps: {\n size: 8,\n withShadow: false,\n },\n },\n MenuItem: {\n defaultProps: {\n fw: 300,\n },\n },\n Notification: {\n styles: (theme, {color: notificationType}: NotificationProps) => ({\n root: {\n borderColor: theme.colors.gray[3],\n backgroundColor: theme.colors.gray[0],\n boxShadow: theme.shadows.lg,\n padding: theme.spacing.sm,\n '&[data-with-icon]': {\n paddingLeft: theme.spacing.sm,\n },\n },\n icon: {\n backgroundColor: 'transparent',\n marginRight: theme.spacing.sm,\n color: theme.colors?.[notificationType][6],\n },\n closeButton: {\n margin: theme.spacing.xs,\n color: theme.colors.gray[5],\n },\n }),\n defaultProps: {\n icon: <InfoSize24Px height={24} />,\n color: 'info',\n },\n },\n Skeleton: {\n styles: {\n visible: {\n '&::before': {zIndex: 'unset'},\n '&::after': {zIndex: 'unset'},\n },\n },\n },\n SegmentedControl: {\n styles: (theme) => ({\n root: {\n backgroundColor: theme.colors.gray[2],\n },\n }),\n },\n Stepper: {\n defaultProps: {\n size: 'xs',\n completedIcon: <CheckSize16Px />,\n },\n styles: (theme, {}: StepperStylesParams, {size}) => ({\n step: {\n '&[disabled]': {\n color: theme.colors.gray[5],\n '& .mantine-Stepper-stepDescription': {\n color: theme.colors.gray[5],\n },\n '& .mantine-Stepper-stepIcon': {\n borderColor: theme.colors.gray[1],\n },\n },\n },\n stepIcon: {\n fontWeight: 500,\n backgroundColor: theme.colors.gray[1],\n color: 'inherit',\n border: `${rem(1)} solid ${theme.colors.gray[3]}`,\n '&[data-progress]': {\n backgroundColor: theme.white,\n },\n\n '&[data-completed]': {\n backgroundColor: theme.white,\n borderColor: theme.colors.lime[6],\n color: theme.colors.lime[6],\n },\n },\n stepCompletedIcon: {\n color: theme.colors.lime[6],\n fontSize: rem(16),\n },\n stepDescription: {\n color: theme.colors.gray[7],\n fontSize: getSize({size, sizes: theme.fontSizes}),\n },\n separator: {\n height: rem(1),\n backgroundColor: theme.colors.gray[3],\n },\n separatorActive: {\n backgroundColor: theme.colors.gray[3],\n },\n verticalSeparator: {\n borderLeft: `${rem(1)} solid ${theme.colors.gray[3]}`,\n },\n verticalSeparatorActive: {\n borderColor: theme.colors.gray[3],\n },\n }),\n },\n Tabs: {\n styles: (theme, {orientation}: TabsStylesParams) => ({\n tabsList: {\n [orientation === 'horizontal' ? 'borderBottom' : 'borderRight']: `${rem(1)} solid ${\n theme.colors.gray[3]\n }`,\n },\n tab: {\n [orientation === 'horizontal' ? 'borderBottom' : 'borderRight']: `${rem(1)} solid transparent`,\n [orientation === 'horizontal' ? 'marginBottom' : 'marginRight']: rem(-1),\n },\n }),\n },\n Select: {\n styles: (theme) => ({\n input: {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.colors.gray[7],\n },\n item: {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.colors.gray[7],\n\n '&[data-hovered]': {\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[1],\n },\n\n '&[data-selected]': {\n backgroundColor: theme.fn.variant({variant: 'light'}).background,\n color: theme.fn.variant({variant: 'light'}).color,\n ...theme.fn.hover({backgroundColor: theme.fn.variant({variant: 'light'}).hover}),\n },\n },\n }),\n },\n },\n};\n"],"names":["plasmaTheme","colorScheme","fontFamily","black","color","primary","gray","defaultRadius","lineHeight","spacing","xs","sm","md","lg","xl","primaryColor","headings","fontWeight","sizes","h1","fontSize","undefined","h2","h3","h4","h5","h6","shadows","colors","PlasmaColors","components","Alert","defaultProps","icon","InfoSize24Px","height","styles","title","Title","root","letterSpacing","Text","weight","theme","size","getSize","fontSizes","Button","variants","outline","backgroundColor","Modal","fullScreen","padding","variant","content","flex","rem","overflow","width","header","borderBottom","body","paddingTop","ModalOverlay","navy","opacity","InputWrapper","withAsterisk","label","marginBottom","description","invalid","red","borderColor","error","TextInput","radius","Tooltip","withArrow","withinPortal","multiline","zIndex","Loader","DateRangePicker","cell","textAlign","Anchor","fn","hover","textDecoration","action","Checkbox","List","listStyleType","Radio","labelWrapper","display","alignItems","Popover","shadow","Badge","textTransform","ColorSwatch","withShadow","MenuItem","fw","Notification","notificationType","boxShadow","paddingLeft","marginRight","closeButton","margin","Skeleton","visible","SegmentedControl","Stepper","completedIcon","CheckSize16Px","step","stepIcon","border","white","lime","stepCompletedIcon","stepDescription","separator","separatorActive","verticalSeparator","borderLeft","verticalSeparatorActive","Tabs","orientation","tabsList","tab","Select","input","dark","item","background"],"mappings":";;;;+BAaaA;;;eAAAA;;;;;;;gCAb6B;4BACtB;oBAQb;4BAEoB;AAEpB,IAAMA,cAAoC;IAC7C,2HAA2H;IAC3HC,aAAa;IACbC,YAAY;IACZC,OAAOC,mBAAK,CAACC,OAAO,CAACC,IAAI,CAAC,EAAE;IAC5BC,eAAe;IACfC,YAAY;IACZC,SAAS;QACLC,IAAI;QACJC,IAAI;QACJC,IAAI;QACJC,IAAI;QACJC,IAAI;IACR;IACAC,cAAc;IACdC,UAAU;QACNd,YAAY;QACZe,YAAY;QACZC,OAAO;YACHC,IAAI;gBAACC,UAAU;gBAAQZ,YAAYa;gBAAWJ,YAAY;YAAG;YAC7DK,IAAI;gBAACF,UAAU;gBAAQZ,YAAYa;gBAAWJ,YAAY;YAAG;YAC7DM,I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,EAAE,iBAAiB,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIH,YAAY,EAGZ,qBAAqB,EAGrB,SAAS,EAIZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAC,iBAAiB,EAA8B,MAAM,OAAO,CAAC;AAOrE,QAAA,MAAM,SAAS;;;;;;;CAQZ,CAAC;AAEJ,UAAU,eACN,SAAQ,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,GAAG,mBAAmB,CAAC,EACvE,YAAY,CAAC,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC;IAC7C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,CAAC;IAChE,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,qDAAqD;IACrD,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;CAClC;AASD,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CA2IzD,CAAC"}
|
|
@@ -91,8 +91,10 @@ export var CodeEditor = function(props) {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
var handleSearch = function() {
|
|
94
|
-
editorRef.current
|
|
95
|
-
|
|
94
|
+
if (editorRef.current) {
|
|
95
|
+
editorRef.current.focus();
|
|
96
|
+
editorRef.current.trigger("editor", "actions.find", "");
|
|
97
|
+
}
|
|
96
98
|
};
|
|
97
99
|
useEffect(function() {
|
|
98
100
|
if (monacoLoader === "local") {
|
|
@@ -158,7 +160,10 @@ export var CodeEditor = function(props) {
|
|
|
158
160
|
onMount: function(editor, monaco) {
|
|
159
161
|
editorRef.current = editor;
|
|
160
162
|
registerLanguages(monaco);
|
|
161
|
-
editor.onDidFocusEditorText(
|
|
163
|
+
editor.onDidFocusEditorText(function() {
|
|
164
|
+
var _onFocus;
|
|
165
|
+
return (_onFocus = onFocus) === null || _onFocus === void 0 ? void 0 : _onFocus();
|
|
166
|
+
});
|
|
162
167
|
editor.onDidBlurEditorText(/*#__PURE__*/ _async_to_generator(function() {
|
|
163
168
|
return _ts_generator(this, function(_state) {
|
|
164
169
|
switch(_state.label){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n createStyles,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n Loader,\n px,\n Selectors,\n Space,\n Stack,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {loader, Monaco} from '@monaco-editor/react';\nimport {FunctionComponent, useEffect, useState, useRef} from 'react';\n\nimport {useParentHeight} from '../../hooks';\nimport {XML} from './languages/xml';\nimport {CopyToClipboard} from '../copyToClipboard';\nimport {Search} from './search';\n\nconst useStyles = createStyles((theme) => ({\n root: {},\n editor: {\n border: `1px solid ${theme.colors.gray[2]}`,\n borderRadius: theme.defaultRadius,\n backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,\n height: '100%',\n },\n}));\n\ninterface CodeEditorProps\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml';\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n ...others\n } = useComponentDefaultProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const {classes, theme} = useStyles();\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n const editorRef = useRef(null);\n\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n const handleSearch = () => {\n editorRef.current.focus();\n editorRef.current.trigger('editor', 'actions.find', '');\n };\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _buttons = (\n <Group position=\"right\" spacing={0}>\n <Search handleSearch={handleSearch} />\n <CopyToClipboard value={_value} />\n </Group>\n );\n\n const _editor = loaded ? (\n <Box p=\"md\" pl=\"xs\" className={classes.editor}>\n <Editor\n defaultLanguage={language}\n theme={theme.colorScheme === 'light' ? 'light' : 'vs-dark'}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n wrappingStrategy: 'advanced',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs),\n readOnly: disabled,\n tabSize: 2,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor, monaco) => {\n editorRef.current = editor;\n registerLanguages(monaco);\n editor.onDidFocusEditorText(onFocus);\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={classes.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack\n justify=\"flex-start\"\n className={classes.root}\n spacing={0}\n sx={{height: Math.max(parentHeight, minHeight), maxHeight}}\n ref={ref}\n {...others}\n >\n {_header}\n {_buttons}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["Box","Center","createStyles","Group","Input","Loader","px","Space","Stack","useComponentDefaultProps","useUncontrolled","Editor","loader","useEffect","useState","useRef","useParentHeight","XML","CopyToClipboard","Search","useStyles","theme","root","editor","border","colors","gray","borderRadius","defaultRadius","backgroundColor","colorScheme","white","black","height","defaultProps","language","monacoLoader","defaultValue","minHeight","CodeEditor","props","onChange","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","others","loaded","setLoaded","classes","finalValue","_value","handleChange","parentHeight","ref","editorRef","loadLocalMonaco","monacoInstance","config","monaco","registerLanguages","register","handleSearch","current","focus","trigger","_label","Label","_description","Description","_error","Error","mt","h","_header","_buttons","position","spacing","_editor","p","pl","className","defaultLanguage","options","minimap","enabled","wordWrap","wrappingStrategy","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","tabSize","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","justify","sx","Math","max"],"mappings":";;;;;;;AAAA,SACIA,GAAG,EACHC,MAAM,EACNC,YAAY,EAEZC,KAAK,EACLC,KAAK,EAELC,MAAM,EACNC,EAAE,EAEFC,KAAK,EACLC,KAAK,EACLC,wBAAwB,QACrB,gBAAgB;AACvB,SAAQC,eAAe,QAAO,iBAAiB;AAC/C,OAAOC,UAASC,MAAM,QAAe,uBAAuB;AAC5D,SAA2BC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAO,QAAQ;AAErE,SAAQC,eAAe,QAAO,cAAc;AAC5C,SAAQC,GAAG,QAAO,kBAAkB;AACpC,SAAQC,eAAe,QAAO,qBAAqB;AACnD,SAAQC,MAAM,QAAO,WAAW;AAEhC,IAAMC,YAAYlB,aAAa,SAACmB;WAAW;QACvCC,MAAM,CAAC;QACPC,QAAQ;YACJC,QAAQ,AAAC,aAAiC,OAArBH,MAAMI,MAAM,CAACC,IAAI,CAAC,EAAE;YACzCC,cAAcN,MAAMO,aAAa;YACjCC,iBAAiBR,MAAMS,WAAW,KAAK,UAAUT,MAAMU,KAAK,GAAGV,MAAMW,KAAK;YAC1EC,QAAQ;QACZ;IACJ;;AA6CA,IAAMC,eAAyC;IAC3CC,UAAU;IACVC,cAAc;IACdC,cAAc;IACdC,WAAW;AACf;AAEA,OAAO,IAAMC,aAAiD,SAACC;IAC3D,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,SAAS,CAAC,gCAAgCC,GAAG;;;gCAA1D;;;;;;gBACJ;YACJ;;uBAIR,KAACzG;QAAOuF,WAAWhC,QAAQjC,MAAM;kBAC7B,cAAA,KAAClB;;IAIT,qBACI,MAACG;QACGmG,SAAQ;QACRnB,WAAWhC,QAAQlC,IAAI;QACvB8D,SAAS;QACTwB,IAAI;YAAC3E,QAAQ4E,KAAKC,GAAG,CAAClD,cAActB;YAAYa,WAAAA;QAAS;QACzDU,KAAKA;OACDR;;YAEH4B;YACAC;YACAG;YACAR;;;AAGb,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/code-editor/CodeEditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n createStyles,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n Loader,\n px,\n Selectors,\n Space,\n Stack,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {loader, Monaco} from '@monaco-editor/react';\nimport {FunctionComponent, useEffect, useState, useRef} from 'react';\n\nimport {useParentHeight} from '../../hooks';\nimport {XML} from './languages/xml';\nimport {CopyToClipboard} from '../copyToClipboard';\nimport {Search} from './search';\n\nconst useStyles = createStyles((theme) => ({\n root: {},\n editor: {\n border: `1px solid ${theme.colors.gray[2]}`,\n borderRadius: theme.defaultRadius,\n backgroundColor: theme.colorScheme === 'light' ? theme.white : theme.black,\n height: '100%',\n },\n}));\n\ninterface CodeEditorProps\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml';\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n ...others\n } = useComponentDefaultProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const {classes, theme} = useStyles();\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n const editorRef = useRef(null);\n\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n const handleSearch = () => {\n if (editorRef.current) {\n editorRef.current.focus();\n editorRef.current.trigger('editor', 'actions.find', '');\n }\n };\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? (\n <Input.Error mt=\"xs\" {...errorProps}>\n {error}\n </Input.Error>\n ) : (\n <Space h=\"xs\" />\n );\n\n const _header =\n _label || _description ? (\n <Box>\n {_label}\n {_description}\n </Box>\n ) : null;\n\n const _buttons = (\n <Group position=\"right\" spacing={0}>\n <Search handleSearch={handleSearch} />\n <CopyToClipboard value={_value} />\n </Group>\n );\n\n const _editor = loaded ? (\n <Box p=\"md\" pl=\"xs\" className={classes.editor}>\n <Editor\n defaultLanguage={language}\n theme={theme.colorScheme === 'light' ? 'light' : 'vs-dark'}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n wrappingStrategy: 'advanced',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs),\n readOnly: disabled,\n tabSize: 2,\n }}\n value={_value}\n onChange={handleChange}\n onMount={(editor, monaco) => {\n editorRef.current = editor;\n registerLanguages(monaco);\n editor.onDidFocusEditorText(() => onFocus?.());\n editor.onDidBlurEditorText(async () => {\n await editor.getAction('editor.action.formatDocument').run();\n });\n }}\n />\n </Box>\n ) : (\n <Center className={classes.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack\n justify=\"flex-start\"\n className={classes.root}\n spacing={0}\n sx={{height: Math.max(parentHeight, minHeight), maxHeight}}\n ref={ref}\n {...others}\n >\n {_header}\n {_buttons}\n {_editor}\n {_error}\n </Stack>\n );\n};\n"],"names":["Box","Center","createStyles","Group","Input","Loader","px","Space","Stack","useComponentDefaultProps","useUncontrolled","Editor","loader","useEffect","useState","useRef","useParentHeight","XML","CopyToClipboard","Search","useStyles","theme","root","editor","border","colors","gray","borderRadius","defaultRadius","backgroundColor","colorScheme","white","black","height","defaultProps","language","monacoLoader","defaultValue","minHeight","CodeEditor","props","onChange","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","others","loaded","setLoaded","classes","finalValue","_value","handleChange","parentHeight","ref","editorRef","loadLocalMonaco","monacoInstance","config","monaco","registerLanguages","register","handleSearch","current","focus","trigger","_label","Label","_description","Description","_error","Error","mt","h","_header","_buttons","position","spacing","_editor","p","pl","className","defaultLanguage","options","minimap","enabled","wordWrap","wrappingStrategy","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","tabSize","onMount","onDidFocusEditorText","onDidBlurEditorText","getAction","run","justify","sx","Math","max"],"mappings":";;;;;;;AAAA,SACIA,GAAG,EACHC,MAAM,EACNC,YAAY,EAEZC,KAAK,EACLC,KAAK,EAELC,MAAM,EACNC,EAAE,EAEFC,KAAK,EACLC,KAAK,EACLC,wBAAwB,QACrB,gBAAgB;AACvB,SAAQC,eAAe,QAAO,iBAAiB;AAC/C,OAAOC,UAASC,MAAM,QAAe,uBAAuB;AAC5D,SAA2BC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAO,QAAQ;AAErE,SAAQC,eAAe,QAAO,cAAc;AAC5C,SAAQC,GAAG,QAAO,kBAAkB;AACpC,SAAQC,eAAe,QAAO,qBAAqB;AACnD,SAAQC,MAAM,QAAO,WAAW;AAEhC,IAAMC,YAAYlB,aAAa,SAACmB;WAAW;QACvCC,MAAM,CAAC;QACPC,QAAQ;YACJC,QAAQ,AAAC,aAAiC,OAArBH,MAAMI,MAAM,CAACC,IAAI,CAAC,EAAE;YACzCC,cAAcN,MAAMO,aAAa;YACjCC,iBAAiBR,MAAMS,WAAW,KAAK,UAAUT,MAAMU,KAAK,GAAGV,MAAMW,KAAK;YAC1EC,QAAQ;QACZ;IACJ;;AA6CA,IAAMC,eAAyC;IAC3CC,UAAU;IACVC,cAAc;IACdC,cAAc;IACdC,WAAW;AACf;AAEA,OAAO,IAAMC,aAAiD,SAACC;IAC3D,IAkBI/B,4BAAAA,yBAAyB,cAAcyB,cAAcM,QAjBrDL,WAiBA1B,0BAjBA0B,UACAE,eAgBA5B,0BAhBA4B,cACAI,WAeAhC,0BAfAgC,UACAC,UAcAjC,0BAdAiC,SACAC,QAaAlC,0BAbA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hC,QAAQjC,MAAM;kBAC7B,cAAA,KAAClB;;IAIT,qBACI,MAACG;QACGmG,SAAQ;QACRnB,WAAWhC,QAAQlC,IAAI;QACvB8D,SAAS;QACTwB,IAAI;YAAC3E,QAAQ4E,KAAKC,GAAG,CAAClD,cAActB;YAAYa,WAAAA;QAAS;QACzDU,KAAKA;OACDR;;YAEH4B;YACAC;YACAG;YACAR;;;AAGb,EAAE"}
|
|
@@ -24,7 +24,7 @@ var defaultProps = {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
export var Collection = function(props) {
|
|
27
|
-
var
|
|
27
|
+
var _allowAdd;
|
|
28
28
|
var _useComponentDefaultProps = useComponentDefaultProps("Collection", defaultProps, props), value = _useComponentDefaultProps.value, onChange = _useComponentDefaultProps.onChange, onRemoveItem = _useComponentDefaultProps.onRemoveItem, onReorderItem = _useComponentDefaultProps.onReorderItem, onInsertItem = _useComponentDefaultProps.onInsertItem, disabled = _useComponentDefaultProps.disabled, draggable = _useComponentDefaultProps.draggable, children = _useComponentDefaultProps.children, spacing = _useComponentDefaultProps.spacing, required = _useComponentDefaultProps.required, newItem = _useComponentDefaultProps.newItem, addLabel = _useComponentDefaultProps.addLabel, addDisabledTooltip = _useComponentDefaultProps.addDisabledTooltip, allowAdd = _useComponentDefaultProps.allowAdd, label = _useComponentDefaultProps.label, labelProps = _useComponentDefaultProps.labelProps, withAsterisk = _useComponentDefaultProps.withAsterisk, description = _useComponentDefaultProps.description, descriptionProps = _useComponentDefaultProps.descriptionProps, error = _useComponentDefaultProps.error, errorProps = _useComponentDefaultProps.errorProps, getItemId = _useComponentDefaultProps.getItemId, // Style props
|
|
29
29
|
classNames = _useComponentDefaultProps.classNames, className = _useComponentDefaultProps.className, styles = _useComponentDefaultProps.styles, unstyled = _useComponentDefaultProps.unstyled, others = _object_without_properties(_useComponentDefaultProps, [
|
|
30
30
|
"value",
|
|
@@ -90,10 +90,11 @@ export var Collection = function(props) {
|
|
|
90
90
|
_description
|
|
91
91
|
]
|
|
92
92
|
}) : null;
|
|
93
|
-
var
|
|
93
|
+
var _getItemId;
|
|
94
94
|
var standardizedItems = value.map(function(item, index) {
|
|
95
|
+
var _getItemId1;
|
|
95
96
|
return {
|
|
96
|
-
id: (
|
|
97
|
+
id: (_getItemId = (_getItemId1 = getItemId) === null || _getItemId1 === void 0 ? void 0 : _getItemId1(item)) !== null && _getItemId !== void 0 ? _getItemId : String(index),
|
|
97
98
|
data: item
|
|
98
99
|
};
|
|
99
100
|
});
|
|
@@ -125,6 +126,7 @@ export var Collection = function(props) {
|
|
|
125
126
|
height: 16
|
|
126
127
|
}),
|
|
127
128
|
onClick: function() {
|
|
129
|
+
var _value;
|
|
128
130
|
return onInsertItem(newItem, (_value_length = (_value = value) === null || _value === void 0 ? void 0 : _value.length) !== null && _value_length !== void 0 ? _value_length : 0);
|
|
129
131
|
},
|
|
130
132
|
disabled: !addAllowed,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/collection/Collection.tsx"],"sourcesContent":["import {AddSize16Px} from '@coveord/plasma-react-icons';\nimport {DndContext, DragEndEvent, KeyboardSensor, PointerSensor, useSensor, useSensors} from '@dnd-kit/core';\nimport {restrictToParentElement, restrictToVerticalAxis} from '@dnd-kit/modifiers';\nimport {SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy} from '@dnd-kit/sortable';\nimport {\n Box,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n MantineNumberSize,\n Selectors,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {ReorderPayload} from '@mantine/form/lib/types';\nimport {useDidUpdate} from '@mantine/hooks';\nimport {ReactNode} from 'react';\n\nimport {Button} from '../button';\nimport useStyles from './Collection.styles';\nimport {CollectionItem} from './CollectionItem';\n\ninterface CollectionProps<T>\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The default value each new item should have\n */\n newItem: T;\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * Defines how each item is uniquely identified. It is highly recommended that you specify this prop to an ID that makes sense.\n *\n * This method is required when using this component with ReactHookForm.\n *\n * @see {@link https://react-hook-form.com/api/usefieldarray/} for using a collection with ReactHookForm.\n *\n * @param originalItem The original item\n */\n getItemId?: (originalItem: T) => string;\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Function that gets called whenever a collection item needs to be reordered\n *\n * @param payload The origin and destination index of the item to reorder\n */\n onReorderItem?: (payload: ReorderPayload) => void;\n /**\n * Function that gets called when a new item needs to be added to the collection\n *\n * @param value The the value of the item to insert\n * @param index The index of the new item to insert\n */\n onInsertItem?: (value: T, index: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: (values: T[]) => boolean;\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: string;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The spacing between the colleciton items\n *\n * @default 'xs'\n */\n spacing?: MantineNumberSize;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n spacing: 'xs',\n required: false,\n getItemId: ({id}: any) => id,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T>) => {\n const {\n value,\n onChange,\n onRemoveItem,\n onReorderItem,\n onInsertItem,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n label,\n labelProps,\n withAsterisk,\n description,\n descriptionProps,\n error,\n errorProps,\n getItemId,\n\n // Style props\n classNames,\n className,\n styles,\n unstyled,\n\n ...others\n } = useComponentDefaultProps('Collection', defaultProps as CollectionProps<T>, props);\n const {classes, cx} = useStyles(null, {classNames, name: 'Collection', styles, unstyled});\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n })\n );\n\n const hasOnlyOneItem = value.length === 1;\n\n /**\n * Enforcing onChange when the value is modified will make sure the errors are carried through.\n */\n useDidUpdate(() => {\n onChange?.(value);\n }, [JSON.stringify(value)]);\n\n const isRequired = typeof withAsterisk === 'boolean' ? withAsterisk : required;\n const _label = label ? (\n <Input.Label required={isRequired} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n const _error = error ? <Input.Error {...errorProps}>{error}</Input.Error> : null;\n const _header =\n _label || _description ? (\n <>\n {_label}\n {_description}\n </>\n ) : null;\n\n const standardizedItems = value.map((item, index) => ({id: getItemId?.(item) ?? String(index), data: item}));\n\n const items = standardizedItems.map((item, index) => (\n <CollectionItem\n key={item.id}\n id={item.id}\n disabled={disabled}\n draggable={draggable}\n onRemove={() => onRemoveItem?.(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item.data, index)}\n </CollectionItem>\n ));\n\n const addAllowed = allowAdd?.(value) ?? true;\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={addAllowed}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => onInsertItem(newItem, value?.length ?? 0)}\n disabled={!addAllowed}\n >\n {addLabel}\n </Button>\n </Box>\n </Tooltip>\n </Group>\n );\n\n const getIndex = (id: string) => standardizedItems.findIndex((item) => item.id === id);\n\n const handleDragEnd = ({over, active}: DragEndEvent): void => {\n if (over) {\n const activeIndex = getIndex(String(active.id));\n const overIndex = getIndex(String(over.id));\n if (activeIndex !== overIndex) {\n onReorderItem?.({from: activeIndex, to: overIndex});\n }\n }\n };\n\n return (\n <DndContext\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={standardizedItems} strategy={verticalListSortingStrategy}>\n <Box className={cx(classes.root, className)} {...others}>\n {_header}\n <Stack spacing={spacing}>\n {items}\n {_addButton}\n {_error}\n </Stack>\n </Box>\n </SortableContext>\n </DndContext>\n );\n};\n"],"names":["AddSize16Px","DndContext","KeyboardSensor","PointerSensor","useSensor","useSensors","restrictToParentElement","restrictToVerticalAxis","SortableContext","sortableKeyboardCoordinates","verticalListSortingStrategy","Box","Group","Input","Stack","Tooltip","useComponentDefaultProps","useDidUpdate","Button","useStyles","CollectionItem","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","getItemId","id","Collection","props","allowAdd","value","onChange","onRemoveItem","onReorderItem","onInsertItem","children","newItem","label","labelProps","withAsterisk","description","descriptionProps","error","errorProps","classNames","className","styles","unstyled","others","name","classes","cx","sensors","coordinateGetter","hasOnlyOneItem","length","JSON","stringify","isRequired","_label","Label","_description","Description","_error","Error","_header","standardizedItems","map","item","index","String","data","items","onRemove","removable","addAllowed","_addButton","variant","leftIcon","height","onClick","getIndex","findIndex","handleDragEnd","over","active","activeIndex","overIndex","from","to","onDragEnd","modifiers","strategy","root"],"mappings":";;;;AAAA,SAAQA,WA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ACzF;QACG4F,WAAWP;QACX/B,SAASA;QACTuC,WAAW;YAACvF;YAAwBD;SAAwB;kBAE5D,cAAA,KAACE;YAAgBmE,OAAON;YAAmB0B,UAAUrF;sBACjD,cAAA,MAACC;gBAAIqC,WAAWM,GAAGD,QAAQ2C,IAAI,EAAEhD;eAAgBG;;oBAC5CiB;kCACD,MAACtD;wBAAMY,SAASA;;4BACXiD;4BACAI;4BACAb;;;;;;;AAMzB,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/collection/Collection.tsx"],"sourcesContent":["import {AddSize16Px} from '@coveord/plasma-react-icons';\nimport {DndContext, DragEndEvent, KeyboardSensor, PointerSensor, useSensor, useSensors} from '@dnd-kit/core';\nimport {restrictToParentElement, restrictToVerticalAxis} from '@dnd-kit/modifiers';\nimport {SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy} from '@dnd-kit/sortable';\nimport {\n Box,\n DefaultProps,\n Group,\n Input,\n InputWrapperBaseProps,\n MantineNumberSize,\n Selectors,\n Stack,\n Tooltip,\n useComponentDefaultProps,\n} from '@mantine/core';\nimport {ReorderPayload} from '@mantine/form/lib/types';\nimport {useDidUpdate} from '@mantine/hooks';\nimport {ReactNode} from 'react';\n\nimport {Button} from '../button';\nimport useStyles from './Collection.styles';\nimport {CollectionItem} from './CollectionItem';\n\ninterface CollectionProps<T>\n extends Omit<InputWrapperBaseProps, 'inputContainer' | 'inputWrapperOrder'>,\n DefaultProps<Selectors<typeof useStyles>> {\n /**\n * The default value each new item should have\n */\n newItem: T;\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * Defines how each item is uniquely identified. It is highly recommended that you specify this prop to an ID that makes sense.\n *\n * This method is required when using this component with ReactHookForm.\n *\n * @see {@link https://react-hook-form.com/api/usefieldarray/} for using a collection with ReactHookForm.\n *\n * @param originalItem The original item\n */\n getItemId?: (originalItem: T) => string;\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Function that gets called whenever a collection item needs to be reordered\n *\n * @param payload The origin and destination index of the item to reorder\n */\n onReorderItem?: (payload: ReorderPayload) => void;\n /**\n * Function that gets called when a new item needs to be added to the collection\n *\n * @param value The the value of the item to insert\n * @param index The index of the new item to insert\n */\n onInsertItem?: (value: T, index: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: (values: T[]) => boolean;\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: string;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The spacing between the colleciton items\n *\n * @default 'xs'\n */\n spacing?: MantineNumberSize;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n spacing: 'xs',\n required: false,\n getItemId: ({id}: any) => id,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T>) => {\n const {\n value,\n onChange,\n onRemoveItem,\n onReorderItem,\n onInsertItem,\n disabled,\n draggable,\n children,\n spacing,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n label,\n labelProps,\n withAsterisk,\n description,\n descriptionProps,\n error,\n errorProps,\n getItemId,\n\n // Style props\n classNames,\n className,\n styles,\n unstyled,\n\n ...others\n } = useComponentDefaultProps('Collection', defaultProps as CollectionProps<T>, props);\n const {classes, cx} = useStyles(null, {classNames, name: 'Collection', styles, unstyled});\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n })\n );\n\n const hasOnlyOneItem = value.length === 1;\n\n /**\n * Enforcing onChange when the value is modified will make sure the errors are carried through.\n */\n useDidUpdate(() => {\n onChange?.(value);\n }, [JSON.stringify(value)]);\n\n const isRequired = typeof withAsterisk === 'boolean' ? withAsterisk : required;\n const _label = label ? (\n <Input.Label required={isRequired} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n const _error = error ? <Input.Error {...errorProps}>{error}</Input.Error> : null;\n const _header =\n _label || _description ? (\n <>\n {_label}\n {_description}\n </>\n ) : null;\n\n const standardizedItems = value.map((item, index) => ({id: getItemId?.(item) ?? String(index), data: item}));\n\n const items = standardizedItems.map((item, index) => (\n <CollectionItem\n key={item.id}\n id={item.id}\n disabled={disabled}\n draggable={draggable}\n onRemove={() => onRemoveItem?.(index)}\n styles={styles}\n removable={!(required && hasOnlyOneItem)}\n >\n {children(item.data, index)}\n </CollectionItem>\n ));\n\n const addAllowed = allowAdd?.(value) ?? true;\n\n const _addButton = disabled ? null : (\n <Group>\n <Tooltip label={addDisabledTooltip} disabled={addAllowed}>\n <Box>\n <Button\n variant=\"subtle\"\n leftIcon={<AddSize16Px height={16} />}\n onClick={() => onInsertItem(newItem, value?.length ?? 0)}\n disabled={!addAllowed}\n >\n {addLabel}\n </Button>\n </Box>\n </Tooltip>\n </Group>\n );\n\n const getIndex = (id: string) => standardizedItems.findIndex((item) => item.id === id);\n\n const handleDragEnd = ({over, active}: DragEndEvent): void => {\n if (over) {\n const activeIndex = getIndex(String(active.id));\n const overIndex = getIndex(String(over.id));\n if (activeIndex !== overIndex) {\n onReorderItem?.({from: activeIndex, to: overIndex});\n }\n }\n };\n\n return (\n <DndContext\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={standardizedItems} strategy={verticalListSortingStrategy}>\n <Box className={cx(classes.root, className)} {...others}>\n {_header}\n <Stack spacing={spacing}>\n {items}\n {_addButton}\n {_error}\n </Stack>\n </Box>\n </SortableContext>\n </DndContext>\n );\n};\n"],"names":["AddSize16Px","DndContext","KeyboardSensor","PointerSensor","useSensor","useSensors","restrictToParentElement","restrictToVerticalAxis","SortableContext","sortableKeyboardCoordinates","verticalListSortingStrategy","Box","Group","Input","Stack","Tooltip","useComponentDefaultProps","useDidUpdate","Button","useStyles","CollectionItem","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","getItemId","id","Collection","props","allowAdd","value","onChange","onRemoveItem","onReorderItem","onInsertItem","children","newItem","label","labelProps","withAsterisk","description","descriptionProps","error","errorProps","classNames","className","styles","unstyled","others","name","classes","cx","sensors","coordinateGetter","hasOnlyOneItem","length","JSON","stringify","isRequired","_label","Label","_description","Description","_error","Error","_header","standardizedItems","map","item","index","String","data","items","onRemove","removable","addAllowed","_addButton","variant","leftIcon","height","onClick","getIndex","findIndex","handleDragEnd","over","active","activeIndex","overIndex","from","to","onDragEnd","modifiers","strategy","root"],"mappings":";;;;AAAA,SAAQA,WAAW,QAAO,8BAA8B;AACxD,SAAQC,UAAU,EAAgBC,cAAc,EAAEC,aAAa,EAAEC,SAAS,EAAEC,UAAU,QAAO,gBAAgB;AAC7G,SAAQC,uBAAuB,EAAEC,sBAAsB,QAAO,qBAAqB;AACnF,SAAQC,eAAe,EAAEC,2BAA2B,EAAEC,2BAA2B,QAAO,oBAAoB;AAC5G,SACIC,GAAG,EAEHC,KAAK,EACLC,KAAK,EAILC,KAAK,EACLC,OAAO,EACPC,wBA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
1
|
-
{"version":3,"file":"DateRangePickerPresetSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/date-range-picker/DateRangePickerPresetSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,WAAW,EAAC,MAAM,eAAe,CAAC;AAG9D,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AAErE,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,oBAAoB,CAAC;CAC/B;AAED,UAAU,iCAAiC,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC/C,KAAK,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,CAAC,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC7C,WAAW,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC;CAC3E;AAED,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"DateRangePickerPresetSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/date-range-picker/DateRangePickerPresetSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,WAAW,EAAC,MAAM,eAAe,CAAC;AAG9D,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAC;AAErE,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,oBAAoB,CAAC;CAC/B;AAED,UAAU,iCAAiC,CAAC,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC/C,KAAK,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,CAAC,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC7C,WAAW,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC;CAC3E;AAED,eAAO,MAAM,2BAA2B,sHA6CvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/date-range-picker/DateRangePickerPresetSelect.tsx"],"sourcesContent":["import {Select, SelectItem, SelectProps} from '@mantine/core';\nimport dayjs from 'dayjs';\nimport {useEffect, useState} from 'react';\nimport {DateRangePickerValue} from './DateRangePickerInlineCalendar';\n\nexport interface DateRangePickerPreset {\n label: string;\n range: DateRangePickerValue;\n}\n\ninterface DateRangePickerPresetsSelectProps<T> {\n presets: Record<string, DateRangePickerPreset>;\n value: DateRangePickerValue;\n onChange?(value: DateRangePickerValue): void;\n selectProps?: Partial<Omit<SelectProps, 'data' | 'value' | 'onChange'>>;\n}\n\nexport const DateRangePickerPresetSelect = <T extends unknown>({\n presets,\n value,\n onChange,\n selectProps = {},\n}: DateRangePickerPresetsSelectProps<T>) => {\n const selectData: SelectItem[] = Object.entries(presets).map(([val, {label}]) => ({value: val, label}));\n\n const getSelectedPreset = () => {\n if (value[0] !== null && value[1] !== null && dayjs(value[0]).unix() !== dayjs(value[1]).unix()) {\n const selected = Object.entries(presets).find(\n ([id, {range}]) => dayjs(range[0]!).isSame(value[0]) && dayjs(value[1]!).isSame(value[1]!)\n );\n if (selected) {\n return selected[0];\n }\n }\n return null;\n };\n\n const [selectedPreset, setSelectedPreset] = useState<string | null>(getSelectedPreset());\n\n useEffect(() => {\n const newPreset = getSelectedPreset();\n if (newPreset !== selectedPreset) {\n setSelectedPreset(newPreset);\n }\n }, [value]);\n\n const onChangePreset = (presetId: keyof typeof presets) => {\n const range = presets[presetId].range as any;\n onChange?.(range);\n };\n\n return (\n <Select\n label=\"Date range\"\n placeholder=\"Select a date range\"\n {...selectProps}\n value={selectedPreset}\n onChange={onChangePreset}\n data={selectData}\n />\n );\n};\n"],"names":["Select","dayjs","useEffect","useState","DateRangePickerPresetSelect","presets","value","onChange","selectProps","selectData","Object","entries","map","val","label","getSelectedPreset","unix","selected","find","id","range","isSame","selectedPreset","setSelectedPreset","newPreset","onChangePreset","presetId","placeholder","data"],"mappings":";;;;AAAA,SAAQA,MAAM,QAAgC,gBAAgB;AAC9D,OAAOC,WAAW,QAAQ;AAC1B,SAAQC,SAAS,EAAEC,QAAQ,QAAO,QAAQ;AAe1C,OAAO,IAAMC,8BAA8B;QACvCC,gBAAAA,SACAC,cAAAA,OACAC,iBAAAA,qCACAC,aAAAA,8CAAc,CAAC;IAEf,IAAMC,aAA2BC,OAAOC,OAAO,CAACN,SAASO,GAAG,CAAC;iDAAEC,iBAAK,AAACC,kBAAAA;eAAa;YAACR,OAAOO;YAAKC,OAAAA;QAAK;;IAEpG,IAAMC,oBAAoB;QACtB,IAAIT,KAAK,CAAC,EAAE,KAAK,QAAQA,KAAK,CAAC,EAAE,KAAK,QAAQL,MAAMK,KAAK,CAAC,EAAE,EAAEU,IAAI,OAAOf,MAAMK,KAAK,CAAC,EAAE,EAAEU,IAAI,IAAI;YAC7F,IAAMC,WAAWP,OAAOC,OAAO,CAACN,SAASa,IAAI,CACzC;yDAAEC,gBAAI,AAACC,kBAAAA;uBAAYnB,MAAMmB,KAAK,CAAC,EAAE,EAAGC,MAAM,CAACf,KAAK,CAAC,EAAE,KAAKL,MAAMK,KAAK,CAAC,EAAE,EAAGe,MAAM,CAACf,KAAK,CAAC,EAAE;;YAE5F,IAAIW,UAAU;gBACV,OAAOA,QAAQ,CAAC,EAAE;YACtB;QACJ;QACA,OAAO;IACX;IAEA,IAA4Cd,6BAAAA,SAAwBY,0BAA7DO,iBAAqCnB,cAArBoB,oBAAqBpB;IAE5CD,UAAU;QACN,IAAMsB,YAAYT;QAClB,IAAIS,cAAcF,gBAAgB;YAC9BC,kBAAkBC;QACtB;IACJ,GAAG;QAAClB;KAAM;IAEV,IAAMmB,iBAAiB,SAACC;YAEpBnB;QADA,IAAMa,QAAQf,OAAO,CAACqB,SAAS,CAACN,KAAK;SACrCb,YAAAA,sBAAAA,gCAAAA,UAAWa;IACf;IAEA,qBACI,KAACpB;QACGc,OAAM;QACNa,aAAY;OACRnB;QACJF,OAAOgB;QACPf,UAAUkB;QACVG,MAAMnB;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/date-range-picker/DateRangePickerPresetSelect.tsx"],"sourcesContent":["import {Select, SelectItem, SelectProps} from '@mantine/core';\nimport dayjs from 'dayjs';\nimport {useEffect, useState} from 'react';\nimport {DateRangePickerValue} from './DateRangePickerInlineCalendar';\n\nexport interface DateRangePickerPreset {\n label: string;\n range: DateRangePickerValue;\n}\n\ninterface DateRangePickerPresetsSelectProps<T> {\n presets: Record<string, DateRangePickerPreset>;\n value: DateRangePickerValue;\n onChange?(value: DateRangePickerValue): void;\n selectProps?: Partial<Omit<SelectProps, 'data' | 'value' | 'onChange'>>;\n}\n\nexport const DateRangePickerPresetSelect = <T extends unknown>({\n presets,\n value,\n onChange,\n selectProps = {},\n}: DateRangePickerPresetsSelectProps<T>) => {\n const selectData: SelectItem[] = Object.entries(presets).map(([val, {label}]) => ({value: val, label}));\n\n const getSelectedPreset = () => {\n if (value[0] !== null && value[1] !== null && dayjs(value[0]).unix() !== dayjs(value[1]).unix()) {\n const selected = Object.entries(presets).find(\n ([id, {range}]) => dayjs(range[0]!).isSame(value[0]) && dayjs(value[1]!).isSame(value[1]!)\n );\n if (selected) {\n return selected[0];\n }\n }\n return null;\n };\n\n const [selectedPreset, setSelectedPreset] = useState<string | null>(getSelectedPreset());\n\n useEffect(() => {\n const newPreset = getSelectedPreset();\n if (newPreset !== selectedPreset) {\n setSelectedPreset(newPreset);\n }\n }, [value]);\n\n const onChangePreset = (presetId: keyof typeof presets) => {\n const range = presets[presetId].range as any;\n onChange?.(range);\n };\n\n return (\n <Select\n label=\"Date range\"\n placeholder=\"Select a date range\"\n {...selectProps}\n value={selectedPreset}\n onChange={onChangePreset}\n data={selectData}\n maxDropdownHeight={240}\n />\n );\n};\n"],"names":["Select","dayjs","useEffect","useState","DateRangePickerPresetSelect","presets","value","onChange","selectProps","selectData","Object","entries","map","val","label","getSelectedPreset","unix","selected","find","id","range","isSame","selectedPreset","setSelectedPreset","newPreset","onChangePreset","presetId","placeholder","data","maxDropdownHeight"],"mappings":";;;;AAAA,SAAQA,MAAM,QAAgC,gBAAgB;AAC9D,OAAOC,WAAW,QAAQ;AAC1B,SAAQC,SAAS,EAAEC,QAAQ,QAAO,QAAQ;AAe1C,OAAO,IAAMC,8BAA8B;QACvCC,gBAAAA,SACAC,cAAAA,OACAC,iBAAAA,qCACAC,aAAAA,8CAAc,CAAC;IAEf,IAAMC,aAA2BC,OAAOC,OAAO,CAACN,SAASO,GAAG,CAAC;iDAAEC,iBAAK,AAACC,kBAAAA;eAAa;YAACR,OAAOO;YAAKC,OAAAA;QAAK;;IAEpG,IAAMC,oBAAoB;QACtB,IAAIT,KAAK,CAAC,EAAE,KAAK,QAAQA,KAAK,CAAC,EAAE,KAAK,QAAQL,MAAMK,KAAK,CAAC,EAAE,EAAEU,IAAI,OAAOf,MAAMK,KAAK,CAAC,EAAE,EAAEU,IAAI,IAAI;YAC7F,IAAMC,WAAWP,OAAOC,OAAO,CAACN,SAASa,IAAI,CACzC;yDAAEC,gBAAI,AAACC,kBAAAA;uBAAYnB,MAAMmB,KAAK,CAAC,EAAE,EAAGC,MAAM,CAACf,KAAK,CAAC,EAAE,KAAKL,MAAMK,KAAK,CAAC,EAAE,EAAGe,MAAM,CAACf,KAAK,CAAC,EAAE;;YAE5F,IAAIW,UAAU;gBACV,OAAOA,QAAQ,CAAC,EAAE;YACtB;QACJ;QACA,OAAO;IACX;IAEA,IAA4Cd,6BAAAA,SAAwBY,0BAA7DO,iBAAqCnB,cAArBoB,oBAAqBpB;IAE5CD,UAAU;QACN,IAAMsB,YAAYT;QAClB,IAAIS,cAAcF,gBAAgB;YAC9BC,kBAAkBC;QACtB;IACJ,GAAG;QAAClB;KAAM;IAEV,IAAMmB,iBAAiB,SAACC;YAEpBnB;QADA,IAAMa,QAAQf,OAAO,CAACqB,SAAS,CAACN,KAAK;SACrCb,YAAAA,sBAAAA,gCAAAA,UAAWa;IACf;IAEA,qBACI,KAACpB;QACGc,OAAM;QACNa,aAAY;OACRnB;QACJF,OAAOgB;QACPf,UAAUkB;QACVG,MAAMnB;QACNoB,mBAAmB;;AAG/B,EAAE"}
|
|
@@ -6,14 +6,14 @@ export var EditableDateRangePicker = function(param) {
|
|
|
6
6
|
var value = param.value, onChange = param.onChange, onFocus = param.onFocus, _param_separator = param.separator, separator = _param_separator === void 0 ? "to" : _param_separator, _param_startProps = param.startProps, startProps = _param_startProps === void 0 ? {} : _param_startProps, _param_endProps = param.endProps, endProps = _param_endProps === void 0 ? {} : _param_endProps;
|
|
7
7
|
var _value, _value1;
|
|
8
8
|
var onChangeStart = function(date) {
|
|
9
|
-
var
|
|
9
|
+
var _value, _onChange;
|
|
10
10
|
(_onChange = onChange) === null || _onChange === void 0 ? void 0 : _onChange([
|
|
11
11
|
dayjs(date).startOf("day").toDate(),
|
|
12
12
|
(_value = value) === null || _value === void 0 ? void 0 : _value[1]
|
|
13
13
|
]);
|
|
14
14
|
};
|
|
15
15
|
var onChangeEnd = function(date) {
|
|
16
|
-
var
|
|
16
|
+
var _value, _onChange;
|
|
17
17
|
(_onChange = onChange) === null || _onChange === void 0 ? void 0 : _onChange([
|
|
18
18
|
(_value = value) === null || _value === void 0 ? void 0 : _value[0],
|
|
19
19
|
dayjs(date).endOf("day").toDate()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/date-range-picker/EditableDateRangePicker.tsx"],"sourcesContent":["import {DateInput, DatePickerProps} from '@mantine/dates';\nimport dayjs from 'dayjs';\nimport {ReactNode} from 'react';\nimport {DateRangePickerValue} from './DateRangePickerInlineCalendar';\n\nexport interface EditableDateRangePickerProps {\n value: DateRangePickerValue;\n onChange?(value: DateRangePickerValue): void;\n onFocus?: () => void;\n separator?: ReactNode;\n /**\n * Props for the start input\n */\n startProps?: Omit<Partial<DatePickerProps>, 'value' | 'onChange' | 'onFocus'>;\n /**\n * Props for the end input\n */\n endProps?: Omit<Partial<DatePickerProps>, 'value' | 'onChange' | 'onFocus'>;\n}\n\nexport const EditableDateRangePicker = ({\n value,\n onChange,\n onFocus,\n separator = 'to',\n startProps = {},\n endProps = {},\n}: EditableDateRangePickerProps) => {\n const onChangeStart = (date: Date) => {\n onChange?.([dayjs(date).startOf('day').toDate(), value?.[1]]);\n };\n const onChangeEnd = (date: Date) => {\n onChange?.([value?.[0], dayjs(date).endOf('day').toDate()]);\n };\n\n return (\n <>\n <DateInput\n clearable={false}\n label=\"Start\"\n value={value?.[0]}\n onChange={onChangeStart}\n onFocus={onFocus}\n popoverProps={{styles: {dropdown: {display: 'none'}}}}\n styles={{...startProps.styles}}\n />\n {separator}\n <DateInput\n clearable={false}\n label=\"End\"\n value={value?.[1]}\n onChange={onChangeEnd}\n onFocus={onFocus}\n popoverProps={{styles: {dropdown: {display: 'none'}}}}\n styles={{...endProps.styles}}\n />\n </>\n );\n};\n"],"names":["DateInput","dayjs","EditableDateRangePicker","value","onChange","onFocus","separator","startProps","endProps","onChangeStart","date","startOf","toDate","onChangeEnd","endOf","clearable","label","popoverProps","styles","dropdown","display"],"mappings":";;AAAA,SAAQA,SAAS,QAAwB,iBAAiB;AAC1D,OAAOC,WAAW,QAAQ;AAmB1B,OAAO,IAAMC,0BAA0B;QACnCC,cAAAA,OACAC,iBAAAA,UACAC,gBAAAA,kCACAC,WAAAA,0CAAY,mDACZC,YAAAA,4CAAa,CAAC,+CACdC,UAAAA,wCAAW,CAAC;QAcOL,QAUAA;IAtBnB,IAAMM,gBAAgB,SAACC;
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/date-range-picker/EditableDateRangePicker.tsx"],"sourcesContent":["import {DateInput, DatePickerProps} from '@mantine/dates';\nimport dayjs from 'dayjs';\nimport {ReactNode} from 'react';\nimport {DateRangePickerValue} from './DateRangePickerInlineCalendar';\n\nexport interface EditableDateRangePickerProps {\n value: DateRangePickerValue;\n onChange?(value: DateRangePickerValue): void;\n onFocus?: () => void;\n separator?: ReactNode;\n /**\n * Props for the start input\n */\n startProps?: Omit<Partial<DatePickerProps>, 'value' | 'onChange' | 'onFocus'>;\n /**\n * Props for the end input\n */\n endProps?: Omit<Partial<DatePickerProps>, 'value' | 'onChange' | 'onFocus'>;\n}\n\nexport const EditableDateRangePicker = ({\n value,\n onChange,\n onFocus,\n separator = 'to',\n startProps = {},\n endProps = {},\n}: EditableDateRangePickerProps) => {\n const onChangeStart = (date: Date) => {\n onChange?.([dayjs(date).startOf('day').toDate(), value?.[1]]);\n };\n const onChangeEnd = (date: Date) => {\n onChange?.([value?.[0], dayjs(date).endOf('day').toDate()]);\n };\n\n return (\n <>\n <DateInput\n clearable={false}\n label=\"Start\"\n value={value?.[0]}\n onChange={onChangeStart}\n onFocus={onFocus}\n popoverProps={{styles: {dropdown: {display: 'none'}}}}\n styles={{...startProps.styles}}\n />\n {separator}\n <DateInput\n clearable={false}\n label=\"End\"\n value={value?.[1]}\n onChange={onChangeEnd}\n onFocus={onFocus}\n popoverProps={{styles: {dropdown: {display: 'none'}}}}\n styles={{...endProps.styles}}\n />\n </>\n );\n};\n"],"names":["DateInput","dayjs","EditableDateRangePicker","value","onChange","onFocus","separator","startProps","endProps","onChangeStart","date","startOf","toDate","onChangeEnd","endOf","clearable","label","popoverProps","styles","dropdown","display"],"mappings":";;AAAA,SAAQA,SAAS,QAAwB,iBAAiB;AAC1D,OAAOC,WAAW,QAAQ;AAmB1B,OAAO,IAAMC,0BAA0B;QACnCC,cAAAA,OACAC,iBAAAA,UACAC,gBAAAA,kCACAC,WAAAA,0CAAY,mDACZC,YAAAA,4CAAa,CAAC,+CACdC,UAAAA,wCAAW,CAAC;QAcOL,QAUAA;IAtBnB,IAAMM,gBAAgB,SAACC;YAC8BP,QAAjDC;SAAAA,YAAAA,sBAAAA,gCAAAA,UAAW;YAACH,MAAMS,MAAMC,OAAO,CAAC,OAAOC,MAAM;aAAIT,SAAAA,mBAAAA,6BAAAA,MAAO,CAAC,EAAE;SAAC;IAChE;IACA,IAAMU,cAAc,SAACH;YACLP,QAAZC;SAAAA,YAAAA,sBAAAA,gCAAAA,UAAW;aAACD,SAAAA,mBAAAA,6BAAAA,MAAO,CAAC,EAAE;YAAEF,MAAMS,MAAMI,KAAK,CAAC,OAAOF,MAAM;SAAG;IAC9D;IAEA,qBACI;;0BACI,KAACZ;gBACGe,WAAW;gBACXC,OAAM;gBACNb,KAAK,GAAEA,SAAAA,mBAAAA,6BAAAA,MAAO,CAAC,EAAE;gBACjBC,UAAUK;gBACVJ,SAASA;gBACTY,cAAc;oBAACC,QAAQ;wBAACC,UAAU;4BAACC,SAAS;wBAAM;oBAAC;gBAAC;gBACpDF,QAAQ,mBAAIX,WAAWW,MAAM;;YAEhCZ;0BACD,KAACN;gBACGe,WAAW;gBACXC,OAAM;gBACNb,KAAK,GAAEA,UAAAA,mBAAAA,8BAAAA,OAAO,CAAC,EAAE;gBACjBC,UAAUS;gBACVR,SAASA;gBACTY,cAAc;oBAACC,QAAQ;wBAACC,UAAU;4BAACC,SAAS;wBAAM;oBAAC;gBAAC;gBACpDF,QAAQ,mBAAIV,SAASU,MAAM;;;;AAI3C,EAAE"}
|
|
@@ -41,7 +41,7 @@ export var ModalWizard = function(_param) {
|
|
|
41
41
|
"children",
|
|
42
42
|
"isStepValidatedOnNext"
|
|
43
43
|
]);
|
|
44
|
-
var _currentStep_props_validateStep,
|
|
44
|
+
var _currentStep_props_validateStep, _currentStep_props, _currentStep, _classNames, _classNames1;
|
|
45
45
|
var _useStyles = useStyles(null, {
|
|
46
46
|
name: "ModalWizard",
|
|
47
47
|
classNames: classNames,
|
|
@@ -61,7 +61,7 @@ export var ModalWizard = function(_param) {
|
|
|
61
61
|
var _currentStep_props_validateStep1;
|
|
62
62
|
var isValid = (isStepValidatedOnNext ? {
|
|
63
63
|
isValid: true
|
|
64
|
-
} : (_currentStep_props_validateStep1 = (
|
|
64
|
+
} : (_currentStep_props_validateStep1 = (_currentStep = currentStep) === null || _currentStep === void 0 ? void 0 : (_currentStep_props = _currentStep.props) === null || _currentStep_props === void 0 ? void 0 : (_currentStep_props_validateStep = _currentStep_props.validateStep) === null || _currentStep_props_validateStep === void 0 ? void 0 : _currentStep_props_validateStep.call(_currentStep_props, currentStepIndex, numberOfSteps)) !== null && _currentStep_props_validateStep1 !== void 0 ? _currentStep_props_validateStep1 : {
|
|
65
65
|
isValid: true
|
|
66
66
|
}).isValid;
|
|
67
67
|
useEffect(function() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/modal-wizard/ModalWizard.tsx"],"sourcesContent":["import {Box, CloseButton, createStyles, DefaultProps, Modal, ModalProps, Progress, Selectors} from '@mantine/core';\nimport {Children, ReactElement, useEffect, useMemo, useState} from 'react';\n\nimport {Button} from '../button';\nimport {Header} from '../header';\nimport {StickyFooter} from '../sticky-footer';\nimport {ModalWizardStep, ModalWizardStepProps, ResolveStep} from './ModalWizardStep';\n\nconst useStyles = createStyles(() => ({\n content: {\n display: 'flex',\n flexDirection: 'column',\n },\n body: {\n flex: 1,\n display: 'flex',\n flexDirection: 'column',\n },\n}));\n\ntype ModalWizardStylesNames = Selectors<typeof useStyles>;\n\nexport interface ModalWizardProps\n extends Omit<DefaultProps<ModalWizardStylesNames>, 'classNames' | 'styles'>,\n Omit<ModalProps, 'centered' | 'title'> {\n /**\n * The label of the cancel button\n *\n * @default \"Cancel\"\n */\n cancelButtonLabel?: string;\n\n /**\n * The label of the next button\n *\n * @default \"Next\"\n */\n nextButtonLabel?: string;\n\n /**\n * The label of the previous button\n *\n * @default \"Previous\"\n */\n previousButtonLabel?: string;\n\n /**\n * The label of the finish button\n *\n * @default \"Finish\"\n */\n finishButtonLabel?: string;\n\n /**\n * A callback function that is executed when the user clicks on the next button\n */\n onNext?: (newStep: number, setCurrentStep?: React.Dispatch<number>) => unknown;\n\n /**\n * A callback function that is executed when the user clicks on the previous button\n */\n onPrevious?: (newStep: number) => unknown;\n\n /**\n * A function that is executed when user completes all the steps.\n *\n * @param close A function that closes the modal when called.\n */\n onFinish?: () => unknown;\n\n /**\n * Determine if user interacted with any steps in the modal wizard\n */\n isDirty?: () => boolean;\n\n /**\n * A function to confirm close if the state is dirty before closing\n */\n handleDirtyState?: () => boolean;\n\n /**\n * Children to display in modal wizard\n * */\n children?: Array<ReturnType<typeof ModalWizardStep>>;\n\n /**\n * Indicates if step validation should be performed when clicking on to the next step\n * If true, the next step will always be enabled\n *\n * @default false\n */\n isStepValidatedOnNext?: boolean;\n}\n\ninterface ModalWizardType {\n (props: ModalWizardProps): ReactElement;\n\n Step: typeof ModalWizardStep;\n}\n\nexport const ModalWizard: ModalWizardType = ({\n cancelButtonLabel = 'Cancel',\n nextButtonLabel = 'Next',\n previousButtonLabel = 'Previous',\n finishButtonLabel = 'Finish',\n opened,\n onNext,\n onPrevious,\n onClose,\n onFinish,\n isDirty,\n handleDirtyState,\n classNames,\n styles,\n unstyled,\n children,\n isStepValidatedOnNext,\n ...modalProps\n}) => {\n const {\n classes: {content, body},\n cx,\n } = useStyles(null, {\n name: 'ModalWizard',\n classNames,\n styles,\n unstyled,\n });\n\n const [currentStepIndex, setCurrentStepIndex] = useState(0);\n const modalSteps = (Children.toArray(children) as ReactElement[]).filter((child) => child.type === ModalWizardStep);\n\n const numberOfSteps = modalSteps.length;\n const isFirstStep = currentStepIndex === 0;\n const isLastStep = currentStepIndex === numberOfSteps - 1;\n const currentStep = modalSteps.filter((step: ReactElement, index: number) => index === currentStepIndex)[0];\n\n const {isValid} = isStepValidatedOnNext\n ? {isValid: true}\n : currentStep?.props?.validateStep?.(currentStepIndex, numberOfSteps) ?? {isValid: true};\n\n useEffect(() => {\n if (opened) {\n setCurrentStepIndex(0);\n }\n }, [opened]);\n\n const handleClose = (confirmDirty: boolean) => {\n if (confirmDirty) {\n const isModalDirty = isDirty?.() ?? false;\n if (isModalDirty) {\n const discardChanges = handleDirtyState?.() ?? true;\n if (!discardChanges) {\n return;\n }\n }\n }\n onClose?.();\n };\n\n const resolveStepDependentProp = <P extends keyof ModalWizardStepProps>(\n prop: P\n ): ResolveStep<ModalWizardStepProps[P]> =>\n typeof currentStep.props[prop] === 'function'\n ? currentStep.props[prop](currentStepIndex + 1, numberOfSteps)\n : currentStep.props[prop];\n\n const getProgress = useMemo(\n () => (currStepIndex: number) => {\n const totalNumberOfSteps = modalSteps.filter((step) => step.props.countsAsProgress).length;\n const numberOfCompletedSteps = modalSteps.filter(\n (step, index) => step.props.countsAsProgress && index <= currStepIndex\n ).length;\n return (numberOfCompletedSteps / totalNumberOfSteps) * 100;\n },\n []\n );\n\n return (\n <Modal\n opened={opened}\n classNames={{content: cx(content, classNames?.content), body: cx(body, classNames?.body)}}\n centered\n onClose={() => handleClose(true)}\n withCloseButton={false}\n padding={0}\n {...modalProps}\n >\n <Header\n p=\"lg\"\n pr=\"md\"\n variant=\"modal\"\n description={resolveStepDependentProp('description')}\n borderBottom={!currentStep.props.showProgressBar}\n >\n {resolveStepDependentProp('title')}\n {resolveStepDependentProp('docLink') ? (\n <Header.DocAnchor\n href={resolveStepDependentProp('docLink')}\n label={resolveStepDependentProp('docLinkTooltipLabel')}\n />\n ) : null}\n <Header.Actions>\n <CloseButton aria-label={'close-modal'} onClick={() => handleClose(true)} />\n </Header.Actions>\n </Header>\n {currentStep.props.showProgressBar && (\n <Progress color=\"navy.5\" size=\"sm\" radius={0} value={getProgress(currentStepIndex)} />\n )}\n <Box p=\"lg\">{currentStep}</Box>\n <Box\n sx={{\n marginTop: 'auto',\n }}\n >\n <StickyFooter borderTop>\n <Button\n name={isFirstStep ? cancelButtonLabel : previousButtonLabel}\n variant=\"outline\"\n onClick={() => {\n if (isFirstStep) {\n handleClose(true);\n } else {\n onPrevious?.(currentStepIndex - 1);\n setCurrentStepIndex(currentStepIndex - 1);\n }\n }}\n >\n {isFirstStep ? cancelButtonLabel : previousButtonLabel}\n </Button>\n\n <Button\n disabled={!isValid}\n onClick={() => {\n if (isLastStep) {\n onFinish?.() ?? handleClose(false);\n } else {\n onNext?.(currentStepIndex + 1, setCurrentStepIndex);\n\n if (!isStepValidatedOnNext) {\n setCurrentStepIndex(currentStepIndex + 1);\n }\n }\n }}\n >\n {isLastStep ? finishButtonLabel : nextButtonLabel}\n </Button>\n </StickyFooter>\n </Box>\n </Modal>\n );\n};\n\nModalWizard.Step = ModalWizardStep;\n"],"names":["Box","CloseButton","createStyles","Modal","Progress","Children","useEffect","useMemo","useState","Button","Header","StickyFooter","ModalWizardStep","useStyles","content","display","flexDirection","body","flex","ModalWizard","cancelButtonLabel","nextButtonLabel","previousButtonLabel","finishButtonLabel","opened","onNext","onPrevious","onClose","onFinish","isDirty","handleDirtyState","classNames","styles","unstyled","children","isStepValidatedOnNext","modalProps","currentStep","name","classes","cx","currentStepIndex","setCurrentStepIndex","modalSteps","toArray","filter","child","type","numberOfSteps","length","isFirstStep","isLastStep","step","index","isValid","props","validateStep","handleClose","confirmDirty","isModalDirty","discardChanges","resolveStepDependentProp","prop","getProgress","currStepIndex","totalNumberOfSteps","countsAsProgress","numberOfCompletedSteps","centered","withCloseButton","padding","p","pr","variant","description","borderBottom","showProgressBar","DocAnchor","href","label","Actions","aria-label","onClick","color","size","radius","value","sx","marginTop","borderTop","disabled","Step"],"mappings":";;;;;AAAA,SAAQA,GAAG,EAAEC,WAAW,EAAEC,YAAY,EAAgBC,KAAK,EAAcC,QAAQ,QAAkB,gBAAgB;AACnH,SAAQC,QAAQ,EAAgBC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAO,QAAQ;AAE3E,SAAQC,MAAM,QAAO,YAAY;AACjC,SAAQC,MAAM,QAAO,YAAY;AACjC,SAAQC,YAAY,QAAO,mBAAmB;AAC9C,SAAQC,eAAe,QAA0C,oBAAoB;AAErF,IAAMC,YAAYX,aAAa;WAAO;QAClCY,SAAS;YACLC,SAAS;YACTC,eAAe;QACnB;QACAC,MAAM;YACFC,MAAM;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sCAECU,aAAa5B,oBAAoBF;;;;;;;AAM1D,EAAE;AAEFF,YAAYwE,IAAI,GAAG/E"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/modal-wizard/ModalWizard.tsx"],"sourcesContent":["import {Box, CloseButton, createStyles, DefaultProps, Modal, ModalProps, Progress, Selectors} from '@mantine/core';\nimport {Children, ReactElement, useEffect, useMemo, useState} from 'react';\n\nimport {Button} from '../button';\nimport {Header} from '../header';\nimport {StickyFooter} from '../sticky-footer';\nimport {ModalWizardStep, ModalWizardStepProps, ResolveStep} from './ModalWizardStep';\n\nconst useStyles = createStyles(() => ({\n content: {\n display: 'flex',\n flexDirection: 'column',\n },\n body: {\n flex: 1,\n display: 'flex',\n flexDirection: 'column',\n },\n}));\n\ntype ModalWizardStylesNames = Selectors<typeof useStyles>;\n\nexport interface ModalWizardProps\n extends Omit<DefaultProps<ModalWizardStylesNames>, 'classNames' | 'styles'>,\n Omit<ModalProps, 'centered' | 'title'> {\n /**\n * The label of the cancel button\n *\n * @default \"Cancel\"\n */\n cancelButtonLabel?: string;\n\n /**\n * The label of the next button\n *\n * @default \"Next\"\n */\n nextButtonLabel?: string;\n\n /**\n * The label of the previous button\n *\n * @default \"Previous\"\n */\n previousButtonLabel?: string;\n\n /**\n * The label of the finish button\n *\n * @default \"Finish\"\n */\n finishButtonLabel?: string;\n\n /**\n * A callback function that is executed when the user clicks on the next button\n */\n onNext?: (newStep: number, setCurrentStep?: React.Dispatch<number>) => unknown;\n\n /**\n * A callback function that is executed when the user clicks on the previous button\n */\n onPrevious?: (newStep: number) => unknown;\n\n /**\n * A function that is executed when user completes all the steps.\n *\n * @param close A function that closes the modal when called.\n */\n onFinish?: () => unknown;\n\n /**\n * Determine if user interacted with any steps in the modal wizard\n */\n isDirty?: () => boolean;\n\n /**\n * A function to confirm close if the state is dirty before closing\n */\n handleDirtyState?: () => boolean;\n\n /**\n * Children to display in modal wizard\n * */\n children?: Array<ReturnType<typeof ModalWizardStep>>;\n\n /**\n * Indicates if step validation should be performed when clicking on to the next step\n * If true, the next step will always be enabled\n *\n * @default false\n */\n isStepValidatedOnNext?: boolean;\n}\n\ninterface ModalWizardType {\n (props: ModalWizardProps): ReactElement;\n\n Step: typeof ModalWizardStep;\n}\n\nexport const ModalWizard: ModalWizardType = ({\n cancelButtonLabel = 'Cancel',\n nextButtonLabel = 'Next',\n previousButtonLabel = 'Previous',\n finishButtonLabel = 'Finish',\n opened,\n onNext,\n onPrevious,\n onClose,\n onFinish,\n isDirty,\n handleDirtyState,\n classNames,\n styles,\n unstyled,\n children,\n isStepValidatedOnNext,\n ...modalProps\n}) => {\n const {\n classes: {content, body},\n cx,\n } = useStyles(null, {\n name: 'ModalWizard',\n classNames,\n styles,\n unstyled,\n });\n\n const [currentStepIndex, setCurrentStepIndex] = useState(0);\n const modalSteps = (Children.toArray(children) as ReactElement[]).filter((child) => child.type === ModalWizardStep);\n\n const numberOfSteps = modalSteps.length;\n const isFirstStep = currentStepIndex === 0;\n const isLastStep = currentStepIndex === numberOfSteps - 1;\n const currentStep = modalSteps.filter((step: ReactElement, index: number) => index === currentStepIndex)[0];\n\n const {isValid} = isStepValidatedOnNext\n ? {isValid: true}\n : currentStep?.props?.validateStep?.(currentStepIndex, numberOfSteps) ?? {isValid: true};\n\n useEffect(() => {\n if (opened) {\n setCurrentStepIndex(0);\n }\n }, [opened]);\n\n const handleClose = (confirmDirty: boolean) => {\n if (confirmDirty) {\n const isModalDirty = isDirty?.() ?? false;\n if (isModalDirty) {\n const discardChanges = handleDirtyState?.() ?? true;\n if (!discardChanges) {\n return;\n }\n }\n }\n onClose?.();\n };\n\n const resolveStepDependentProp = <P extends keyof ModalWizardStepProps>(\n prop: P\n ): ResolveStep<ModalWizardStepProps[P]> =>\n typeof currentStep.props[prop] === 'function'\n ? currentStep.props[prop](currentStepIndex + 1, numberOfSteps)\n : currentStep.props[prop];\n\n const getProgress = useMemo(\n () => (currStepIndex: number) => {\n const totalNumberOfSteps = modalSteps.filter((step) => step.props.countsAsProgress).length;\n const numberOfCompletedSteps = modalSteps.filter(\n (step, index) => step.props.countsAsProgress && index <= currStepIndex\n ).length;\n return (numberOfCompletedSteps / totalNumberOfSteps) * 100;\n },\n []\n );\n\n return (\n <Modal\n opened={opened}\n classNames={{content: cx(content, classNames?.content), body: cx(body, classNames?.body)}}\n centered\n onClose={() => handleClose(true)}\n withCloseButton={false}\n padding={0}\n {...modalProps}\n >\n <Header\n p=\"lg\"\n pr=\"md\"\n variant=\"modal\"\n description={resolveStepDependentProp('description')}\n borderBottom={!currentStep.props.showProgressBar}\n >\n {resolveStepDependentProp('title')}\n {resolveStepDependentProp('docLink') ? (\n <Header.DocAnchor\n href={resolveStepDependentProp('docLink')}\n label={resolveStepDependentProp('docLinkTooltipLabel')}\n />\n ) : null}\n <Header.Actions>\n <CloseButton aria-label={'close-modal'} onClick={() => handleClose(true)} />\n </Header.Actions>\n </Header>\n {currentStep.props.showProgressBar && (\n <Progress color=\"navy.5\" size=\"sm\" radius={0} value={getProgress(currentStepIndex)} />\n )}\n <Box p=\"lg\">{currentStep}</Box>\n <Box\n sx={{\n marginTop: 'auto',\n }}\n >\n <StickyFooter borderTop>\n <Button\n name={isFirstStep ? cancelButtonLabel : previousButtonLabel}\n variant=\"outline\"\n onClick={() => {\n if (isFirstStep) {\n handleClose(true);\n } else {\n onPrevious?.(currentStepIndex - 1);\n setCurrentStepIndex(currentStepIndex - 1);\n }\n }}\n >\n {isFirstStep ? cancelButtonLabel : previousButtonLabel}\n </Button>\n\n <Button\n disabled={!isValid}\n onClick={() => {\n if (isLastStep) {\n onFinish?.() ?? handleClose(false);\n } else {\n onNext?.(currentStepIndex + 1, setCurrentStepIndex);\n\n if (!isStepValidatedOnNext) {\n setCurrentStepIndex(currentStepIndex + 1);\n }\n }\n }}\n >\n {isLastStep ? finishButtonLabel : nextButtonLabel}\n </Button>\n </StickyFooter>\n </Box>\n </Modal>\n );\n};\n\nModalWizard.Step = ModalWizardStep;\n"],"names":["Box","CloseButton","createStyles","Modal","Progress","Children","useEffect","useMemo","useState","Button","Header","StickyFooter","ModalWizardStep","useStyles","content","display","flexDirection","body","flex","ModalWizard","cancelButtonLabel","nextButtonLabel","previousButtonLabel","finishButtonLabel","opened","onNext","onPrevious","onClose","onFinish","isDirty","handleDirtyState","classNames","styles","unstyled","children","isStepValidatedOnNext","modalProps","currentStep","name","classes","cx","currentStepIndex","setCurrentStepIndex","modalSteps","toArray","filter","child","type","numberOfSteps","length","isFirstStep","isLastStep","step","index","isValid","props","validateStep","handleClose","confirmDirty","isModalDirty","discardChanges","resolveStepDependentProp","prop","getProgress","currStepIndex","totalNumberOfSteps","countsAsProgress","numberOfCompletedSteps","centered","withCloseButton","padding","p","pr","variant","description","borderBottom","showProgressBar","DocAnchor","href","label","Actions","aria-label","onClick","color","size","radius","value","sx","marginTop","borderTop","disabled","Step"],"mappings":";;;;;AAAA,SAAQA,GAAG,EAAEC,WAAW,EAAEC,YAAY,EAAgBC,KAAK,EAAcC,QAAQ,QAAkB,gBAAgB;AACnH,SAAQC,QAAQ,EAAgBC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAO,QAAQ;AAE3E,SAAQC,MAAM,QAAO,YAAY;AACjC,SAAQC,MAAM,QAAO,YAAY;AACjC,SAAQC,YAAY,QAAO,mBAAmB;AAC9C,SAAQC,eAAe,QAA0C,oBAAoB;AAErF,IAAMC,YAAYX,aAAa;WAAO;QAClCY,SAAS;YACLC,SAAS;YACTC,eAAe;QACnB;QACAC,MAAM;YACFC,MAAM;YACNH,SAAS;YACTC,eAAe;QACnB;IACJ;;AAkFA,OAAO,IAAMG,cAA+B;0CACxCC,mBAAAA,0DAAoB,qEACpBC,iBAAAA,sDAAkB,qEAClBC,qBAAAA,8DAAsB,2EACtBC,mBAAAA,0DAAoB,qCACpBC,gBAAAA,QACAC,gBAAAA,QACAC,oBAAAA,YACAC,iBAAAA,SACAC,kBAAAA,UACAC,iBAAAA,SACAC,0BAAAA,kBACAC,oBAAAA,YAC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C,MAAMjB,yBAAyB;wBAC/BkB,OAAOlB,yBAAyB;yBAEpC;kCACJ,KAACnD,OAAOsE,OAAO;kCACX,cAAA,KAAC/E;4BAAYgF,cAAY;4BAAeC,SAAS;uCAAMzB,YAAY;;;;;;YAG1EpB,YAAYkB,KAAK,CAACqB,eAAe,kBAC9B,KAACxE;gBAAS+E,OAAM;gBAASC,MAAK;gBAAKC,QAAQ;gBAAGC,OAAOvB,YAAYtB;;0BAErE,KAACzC;gBAAIuE,GAAE;0BAAMlC;;0BACb,KAACrC;gBACGuF,IAAI;oBACAC,WAAW;gBACf;0BAEA,cAAA,MAAC7E;oBAAa8E,SAAS;;sCACnB,KAAChF;4BACG6B,MAAMY,cAAc9B,oBAAoBE;4BACxCmD,SAAQ;4BACRS,SAAS;gCACL,IAAIhC,aAAa;oCACbO,YAAY;gCAChB,OAAO;wCACH/B;qCAAAA,cAAAA,wBAAAA,kCAAAA,YAAae,mBAAmB;oCAChCC,oBAAoBD,mBAAmB;gCAC3C;4BACJ;sCAECS,cAAc9B,oBAAoBE;;sCAGvC,KAACb;4BACGiF,UAAU,CAACpC;4BACX4B,SAAS;gCACL,IAAI/B,YAAY;wCACZvB;wCAAAA;oCAAAA,CAAAA,cAAAA,YAAAA,sBAAAA,gCAAAA,yBAAAA,wBAAAA,aAAgB6B,YAAY;gCAChC,OAAO;wCACHhC;qCAAAA,UAAAA,oBAAAA,8BAAAA,QAASgB,mBAAmB,GAAGC;oCAE/B,IAAI,CAACP,uBAAuB;wCACxBO,oBAAoBD,mBAAmB;oCAC3C;gCACJ;4BACJ;sCAECU,aAAa5B,oBAAoBF;;;;;;;AAM1D,EAAE;AAEFF,YAAYwE,IAAI,GAAG/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/table/Table.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/table/Table.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAwC,SAAS,EAAC,MAAM,eAAe,CAAC;AAiB/E,eAAO,MAAM,KAAK,EAAE,SA+KnB,CAAC"}
|