@coveord/plasma-mantine 52.26.3 → 52.26.4
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 +34 -128
- package/dist/.tsbuildinfo +1 -1
- package/dist/esm/components/action-icon/ActionIcon.js +29 -80
- package/dist/esm/components/action-icon/ActionIcon.js.map +1 -1
- package/dist/esm/components/action-icon/index.js +1 -1
- package/dist/esm/components/blank-slate/BlankSlate.js +3 -6
- package/dist/esm/components/blank-slate/BlankSlate.js.map +1 -1
- package/dist/esm/components/blank-slate/index.js +1 -1
- package/dist/esm/components/browser-preview/BrowserPreview.js +16 -28
- package/dist/esm/components/browser-preview/BrowserPreview.js.map +1 -1
- package/dist/esm/components/browser-preview/BrowserPreview.styles.js +6 -8
- package/dist/esm/components/browser-preview/BrowserPreview.styles.js.map +1 -1
- package/dist/esm/components/browser-preview/index.js +1 -1
- package/dist/esm/components/button/Button.js +29 -80
- package/dist/esm/components/button/Button.js.map +1 -1
- package/dist/esm/components/button/ButtonWithDisabledTooltip.js +16 -28
- package/dist/esm/components/button/ButtonWithDisabledTooltip.js.map +1 -1
- package/dist/esm/components/button/index.js +1 -1
- package/dist/esm/components/code-editor/CodeEditor.js +76 -144
- package/dist/esm/components/code-editor/CodeEditor.js.map +1 -1
- package/dist/esm/components/code-editor/index.js +1 -1
- package/dist/esm/components/code-editor/languages/xml.js +18 -32
- package/dist/esm/components/code-editor/languages/xml.js.map +1 -1
- package/dist/esm/components/code-editor/search/Search.js +6 -13
- package/dist/esm/components/code-editor/search/Search.js.map +1 -1
- package/dist/esm/components/code-editor/search/index.js +1 -1
- package/dist/esm/components/collection/Collection.js +57 -110
- package/dist/esm/components/collection/Collection.js.map +1 -1
- package/dist/esm/components/collection/Collection.styles.js +7 -9
- package/dist/esm/components/collection/Collection.styles.js.map +1 -1
- package/dist/esm/components/collection/CollectionItem.js +47 -54
- package/dist/esm/components/collection/CollectionItem.js.map +1 -1
- package/dist/esm/components/collection/index.js +1 -1
- package/dist/esm/components/copyToClipboard/CopyToClipboard.js +19 -29
- package/dist/esm/components/copyToClipboard/CopyToClipboard.js.map +1 -1
- package/dist/esm/components/copyToClipboard/index.js +1 -1
- package/dist/esm/components/date-range-picker/DateRangePickerInlineCalendar.js +29 -32
- package/dist/esm/components/date-range-picker/DateRangePickerInlineCalendar.js.map +1 -1
- package/dist/esm/components/date-range-picker/DateRangePickerPopoverCalendar.js +22 -29
- package/dist/esm/components/date-range-picker/DateRangePickerPopoverCalendar.js.map +1 -1
- package/dist/esm/components/date-range-picker/DateRangePickerPresetSelect.js +19 -30
- package/dist/esm/components/date-range-picker/DateRangePickerPresetSelect.js.map +1 -1
- package/dist/esm/components/date-range-picker/EditableDateRangePicker.js +21 -22
- package/dist/esm/components/date-range-picker/EditableDateRangePicker.js.map +1 -1
- package/dist/esm/components/date-range-picker/index.js +3 -3
- package/dist/esm/components/header/Header.js +28 -48
- package/dist/esm/components/header/Header.js.map +1 -1
- package/dist/esm/components/header/Header.styles.js +7 -10
- package/dist/esm/components/header/Header.styles.js.map +1 -1
- package/dist/esm/components/header/HeaderActions/HeaderActions.js +16 -25
- package/dist/esm/components/header/HeaderActions/HeaderActions.js.map +1 -1
- package/dist/esm/components/header/HeaderActions/HeaderActions.styles.js +3 -7
- package/dist/esm/components/header/HeaderActions/HeaderActions.styles.js.map +1 -1
- package/dist/esm/components/header/HeaderBreadcrumbs/HeaderBreadcrumbs.js +13 -22
- package/dist/esm/components/header/HeaderBreadcrumbs/HeaderBreadcrumbs.js.map +1 -1
- package/dist/esm/components/header/HeaderBreadcrumbs/HeaderBreadcrumbs.styles.js +3 -7
- package/dist/esm/components/header/HeaderBreadcrumbs/HeaderBreadcrumbs.styles.js.map +1 -1
- package/dist/esm/components/header/HeaderDocAnchor/HeaderDocAnchor.js +17 -28
- package/dist/esm/components/header/HeaderDocAnchor/HeaderDocAnchor.js.map +1 -1
- package/dist/esm/components/header/HeaderDocAnchor/HeaderDocAnchor.styles.js +4 -8
- package/dist/esm/components/header/HeaderDocAnchor/HeaderDocAnchor.styles.js.map +1 -1
- package/dist/esm/components/header/index.js +1 -1
- package/dist/esm/components/index.js +15 -15
- package/dist/esm/components/inline-confirm/InlineConfirm.js +14 -20
- package/dist/esm/components/inline-confirm/InlineConfirm.js.map +1 -1
- package/dist/esm/components/inline-confirm/InlineConfirmButton.js +11 -17
- package/dist/esm/components/inline-confirm/InlineConfirmButton.js.map +1 -1
- package/dist/esm/components/inline-confirm/InlineConfirmContext.js +2 -2
- package/dist/esm/components/inline-confirm/InlineConfirmContext.js.map +1 -1
- package/dist/esm/components/inline-confirm/InlineConfirmMenuItem.js +11 -17
- package/dist/esm/components/inline-confirm/InlineConfirmMenuItem.js.map +1 -1
- package/dist/esm/components/inline-confirm/InlineConfirmPrompt.js +8 -9
- package/dist/esm/components/inline-confirm/InlineConfirmPrompt.js.map +1 -1
- package/dist/esm/components/inline-confirm/index.js +3 -3
- package/dist/esm/components/inline-confirm/useInlineConfirm.js +5 -5
- package/dist/esm/components/inline-confirm/useInlineConfirm.js.map +1 -1
- package/dist/esm/components/menu/Menu.js +13 -21
- package/dist/esm/components/menu/Menu.js.map +1 -1
- package/dist/esm/components/menu/index.js +1 -1
- package/dist/esm/components/modal-wizard/ModalWizard.js +57 -108
- package/dist/esm/components/modal-wizard/ModalWizard.js.map +1 -1
- package/dist/esm/components/modal-wizard/ModalWizardStep.js +1 -4
- package/dist/esm/components/modal-wizard/ModalWizardStep.js.map +1 -1
- package/dist/esm/components/modal-wizard/index.js +1 -1
- package/dist/esm/components/prompt/Prompt.js +29 -41
- package/dist/esm/components/prompt/Prompt.js.map +1 -1
- package/dist/esm/components/prompt/PromptFooter.js +4 -11
- package/dist/esm/components/prompt/PromptFooter.js.map +1 -1
- package/dist/esm/components/prompt/index.js +1 -1
- package/dist/esm/components/sticky-footer/StickyFooter.js +21 -35
- package/dist/esm/components/sticky-footer/StickyFooter.js.map +1 -1
- package/dist/esm/components/sticky-footer/index.js +1 -1
- package/dist/esm/components/table/Table.js +94 -123
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.styles.js +11 -13
- package/dist/esm/components/table/Table.styles.js.map +1 -1
- package/dist/esm/components/table/TableContext.js +5 -5
- package/dist/esm/components/table/TableContext.js.map +1 -1
- package/dist/esm/components/table/index.js +3 -3
- package/dist/esm/components/table/layouts/RowLayout.js +59 -79
- package/dist/esm/components/table/layouts/RowLayout.js.map +1 -1
- package/dist/esm/components/table/layouts/RowLayout.styles.js +27 -28
- package/dist/esm/components/table/layouts/RowLayout.styles.js.map +1 -1
- package/dist/esm/components/table/layouts/TableLayoutControl.js +10 -13
- package/dist/esm/components/table/layouts/TableLayoutControl.js.map +1 -1
- package/dist/esm/components/table/layouts/TableLayouts.js +2 -2
- package/dist/esm/components/table/layouts/TableLayouts.js.map +1 -1
- package/dist/esm/components/table/table-actions/TableActions.js +17 -26
- package/dist/esm/components/table/table-actions/TableActions.js.map +1 -1
- package/dist/esm/components/table/table-actions/TableActions.styles.js +5 -7
- package/dist/esm/components/table/table-actions/TableActions.styles.js.map +1 -1
- package/dist/esm/components/table/table-column/TableCollapsibleColumn.js +19 -23
- package/dist/esm/components/table/table-column/TableCollapsibleColumn.js.map +1 -1
- package/dist/esm/components/table/table-column/TableSelectableColumn.js +9 -13
- package/dist/esm/components/table/table-column/TableSelectableColumn.js.map +1 -1
- package/dist/esm/components/table/table-consumer/TableConsumer.js +1 -4
- package/dist/esm/components/table/table-consumer/TableConsumer.js.map +1 -1
- package/dist/esm/components/table/table-date-range-picker/TableDateRangePicker.js +28 -43
- package/dist/esm/components/table/table-date-range-picker/TableDateRangePicker.js.map +1 -1
- package/dist/esm/components/table/table-date-range-picker/TableDateRangePicker.styles.js +3 -5
- package/dist/esm/components/table/table-date-range-picker/TableDateRangePicker.styles.js.map +1 -1
- package/dist/esm/components/table/table-filter/TableFilter.js +30 -40
- package/dist/esm/components/table/table-filter/TableFilter.js.map +1 -1
- package/dist/esm/components/table/table-filter/TableFilter.styles.js +4 -6
- package/dist/esm/components/table/table-filter/TableFilter.styles.js.map +1 -1
- package/dist/esm/components/table/table-footer/TableFooter.js +5 -13
- package/dist/esm/components/table/table-footer/TableFooter.js.map +1 -1
- package/dist/esm/components/table/table-header/TableHeader.js +20 -29
- package/dist/esm/components/table/table-header/TableHeader.js.map +1 -1
- package/dist/esm/components/table/table-header/TableHeader.styles.js +8 -10
- package/dist/esm/components/table/table-header/TableHeader.styles.js.map +1 -1
- package/dist/esm/components/table/table-header/Th.js +27 -35
- package/dist/esm/components/table/table-header/Th.js.map +1 -1
- package/dist/esm/components/table/table-header/Th.styles.js +13 -16
- package/dist/esm/components/table/table-header/Th.styles.js.map +1 -1
- package/dist/esm/components/table/table-last-updated/TableLastUpdated.js +24 -35
- package/dist/esm/components/table/table-last-updated/TableLastUpdated.js.map +1 -1
- package/dist/esm/components/table/table-last-updated/TableLastUpdated.styles.js +4 -6
- package/dist/esm/components/table/table-last-updated/TableLastUpdated.styles.js.map +1 -1
- package/dist/esm/components/table/table-loading/TableLoading.js +4 -7
- package/dist/esm/components/table/table-loading/TableLoading.js.map +1 -1
- package/dist/esm/components/table/table-pagination/TablePagination.js +21 -25
- package/dist/esm/components/table/table-pagination/TablePagination.js.map +1 -1
- package/dist/esm/components/table/table-per-page/TablePerPage.js +15 -24
- package/dist/esm/components/table/table-per-page/TablePerPage.js.map +1 -1
- package/dist/esm/components/table/table-predicate/TablePredicate.js +25 -35
- package/dist/esm/components/table/table-predicate/TablePredicate.js.map +1 -1
- package/dist/esm/components/table/table-predicate/TablePredicate.styles.js +3 -5
- package/dist/esm/components/table/table-predicate/TablePredicate.styles.js.map +1 -1
- package/dist/esm/form/FormProvider.js +9 -10
- package/dist/esm/form/FormProvider.js.map +1 -1
- package/dist/esm/form/index.js +2 -2
- package/dist/esm/form/useForm.js +18 -25
- package/dist/esm/form/useForm.js.map +1 -1
- package/dist/esm/hooks/index.js +2 -2
- package/dist/esm/hooks/useControlledList.js +24 -30
- package/dist/esm/hooks/useControlledList.js.map +1 -1
- package/dist/esm/hooks/useParentHeight.js +10 -11
- package/dist/esm/hooks/useParentHeight.js.map +1 -1
- package/dist/esm/hooks/useRowSelection.js +33 -44
- package/dist/esm/hooks/useRowSelection.js.map +1 -1
- package/dist/esm/index.js +11 -11
- package/dist/esm/theme/PlasmaColors.js +13 -15
- package/dist/esm/theme/PlasmaColors.js.map +1 -1
- package/dist/esm/theme/Plasmantine.js +3 -6
- package/dist/esm/theme/Plasmantine.js.map +1 -1
- package/dist/esm/theme/Theme.js +142 -171
- package/dist/esm/theme/Theme.js.map +1 -1
- package/dist/esm/theme/index.js +1 -1
- package/dist/esm/utils/createPolymorphicComponent.js +2 -2
- package/dist/esm/utils/createPolymorphicComponent.js.map +1 -1
- package/dist/esm/utils/index.js +2 -2
- package/dist/esm/utils/overrideComponent.js +2 -8
- package/dist/esm/utils/overrideComponent.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/inline-confirm/InlineConfirmPrompt.tsx"],"sourcesContent":["import {Group} from '@mantine/core';\nimport {FunctionComponent, ReactNode, useEffect} from 'react';\n\nimport {Button} from '../button';\nimport {useInlineConfirm} from './useInlineConfirm';\n\ninterface InlineConfirmPromptProps {\n id: string;\n label: ReactNode;\n onConfirm: () => void;\n confirmLabel?: ReactNode;\n cancelLabel?: ReactNode;\n}\n\nexport const InlineConfirmPrompt: FunctionComponent<InlineConfirmPromptProps> = ({\n id,\n label,\n confirmLabel = 'Delete',\n cancelLabel = 'Cancel',\n onConfirm,\n}) => {\n const {confirmingId, clearConfirm} = useInlineConfirm();\n\n const onClickConfirm = () => {\n onConfirm();\n clearConfirm();\n };\n\n useEffect(() => {\n if (confirmingId !== id) {\n clearConfirm();\n }\n }, []);\n\n if (confirmingId === id) {\n return (\n <Group spacing=\"xs\" noWrap>\n {label}\n <Button onClick={onClickConfirm} color=\"red\">\n {confirmLabel}\n </Button>\n <Button onClick={clearConfirm} variant=\"outline\">\n {cancelLabel}\n </Button>\n </Group>\n );\n }\n return null;\n};\n"],"names":["Group","useEffect","Button","useInlineConfirm","InlineConfirmPrompt","id","label","confirmLabel","cancelLabel","onConfirm","confirmingId","clearConfirm","onClickConfirm","spacing","noWrap","onClick","color","variant"],"mappings":";AAAA,SAAQA,KAAK,QAAO,gBAAgB;AACpC,SAAsCC,SAAS,QAAO,QAAQ;AAE9D,SAAQC,MAAM,QAAO,YAAY;AACjC,SAAQC,gBAAgB,QAAO,qBAAqB;AAUpD,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/inline-confirm/InlineConfirmPrompt.tsx"],"sourcesContent":["import {Group} from '@mantine/core';\nimport {FunctionComponent, ReactNode, useEffect} from 'react';\n\nimport {Button} from '../button';\nimport {useInlineConfirm} from './useInlineConfirm';\n\ninterface InlineConfirmPromptProps {\n id: string;\n label: ReactNode;\n onConfirm: () => void;\n confirmLabel?: ReactNode;\n cancelLabel?: ReactNode;\n}\n\nexport const InlineConfirmPrompt: FunctionComponent<InlineConfirmPromptProps> = ({\n id,\n label,\n confirmLabel = 'Delete',\n cancelLabel = 'Cancel',\n onConfirm,\n}) => {\n const {confirmingId, clearConfirm} = useInlineConfirm();\n\n const onClickConfirm = () => {\n onConfirm();\n clearConfirm();\n };\n\n useEffect(() => {\n if (confirmingId !== id) {\n clearConfirm();\n }\n }, []);\n\n if (confirmingId === id) {\n return (\n <Group spacing=\"xs\" noWrap>\n {label}\n <Button onClick={onClickConfirm} color=\"red\">\n {confirmLabel}\n </Button>\n <Button onClick={clearConfirm} variant=\"outline\">\n {cancelLabel}\n </Button>\n </Group>\n );\n }\n return null;\n};\n"],"names":["Group","useEffect","Button","useInlineConfirm","InlineConfirmPrompt","id","label","confirmLabel","cancelLabel","onConfirm","confirmingId","clearConfirm","onClickConfirm","spacing","noWrap","onClick","color","variant"],"mappings":";AAAA,SAAQA,KAAK,QAAO,gBAAgB;AACpC,SAAsCC,SAAS,QAAO,QAAQ;AAE9D,SAAQC,MAAM,QAAO,YAAY;AACjC,SAAQC,gBAAgB,QAAO,qBAAqB;AAUpD,OAAO,MAAMC,sBAAmE,CAAC,EAC7EC,EAAE,EACFC,KAAK,EACLC,eAAe,QAAQ,EACvBC,cAAc,QAAQ,EACtBC,SAAS,EACZ;IACG,MAAM,EAACC,YAAY,EAAEC,YAAY,EAAC,GAAGR;IAErC,MAAMS,iBAAiB;QACnBH;QACAE;IACJ;IAEAV,UAAU;QACN,IAAIS,iBAAiBL,IAAI;YACrBM;QACJ;IACJ,GAAG,EAAE;IAEL,IAAID,iBAAiBL,IAAI;QACrB,qBACI,MAACL;YAAMa,SAAQ;YAAKC,MAAM;;gBACrBR;8BACD,KAACJ;oBAAOa,SAASH;oBAAgBI,OAAM;8BAClCT;;8BAEL,KAACL;oBAAOa,SAASJ;oBAAcM,SAAQ;8BAClCT;;;;IAIjB;IACA,OAAO;AACX,EAAE"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useContext } from
|
|
2
|
-
import { InlineConfirmContext } from
|
|
3
|
-
export
|
|
4
|
-
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { InlineConfirmContext } from './InlineConfirmContext';
|
|
3
|
+
export const useInlineConfirm = ()=>{
|
|
4
|
+
const ctx = useContext(InlineConfirmContext);
|
|
5
5
|
if (ctx === null) {
|
|
6
|
-
throw new Error(
|
|
6
|
+
throw new Error('useConfirm must be used inside of a InlineConfirmContext.Provider');
|
|
7
7
|
}
|
|
8
8
|
return ctx;
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/inline-confirm/useInlineConfirm.ts"],"sourcesContent":["import {useContext} from 'react';\nimport {InlineConfirmContext} from './InlineConfirmContext';\n\nexport const useInlineConfirm = () => {\n const ctx = useContext(InlineConfirmContext);\n\n if (ctx === null) {\n throw new Error('useConfirm must be used inside of a InlineConfirmContext.Provider');\n }\n\n return ctx;\n};\n"],"names":["useContext","InlineConfirmContext","useInlineConfirm","ctx","Error"],"mappings":"AAAA,SAAQA,UAAU,QAAO,QAAQ;AACjC,SAAQC,oBAAoB,QAAO,yBAAyB;AAE5D,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/inline-confirm/useInlineConfirm.ts"],"sourcesContent":["import {useContext} from 'react';\nimport {InlineConfirmContext} from './InlineConfirmContext';\n\nexport const useInlineConfirm = () => {\n const ctx = useContext(InlineConfirmContext);\n\n if (ctx === null) {\n throw new Error('useConfirm must be used inside of a InlineConfirmContext.Provider');\n }\n\n return ctx;\n};\n"],"names":["useContext","InlineConfirmContext","useInlineConfirm","ctx","Error"],"mappings":"AAAA,SAAQA,UAAU,QAAO,QAAQ;AACjC,SAAQC,oBAAoB,QAAO,yBAAyB;AAE5D,OAAO,MAAMC,mBAAmB;IAC5B,MAAMC,MAAMH,WAAWC;IAEvB,IAAIE,QAAQ,MAAM;QACd,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX,EAAE"}
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
-
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
3
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { Menu as MantineMenu } from
|
|
5
|
-
import { forwardRef } from
|
|
6
|
-
import { createPolymorphicComponent, overrideComponent } from
|
|
7
|
-
import { ButtonWithDisabledTooltip } from
|
|
8
|
-
|
|
9
|
-
var disabledTooltip = _param.disabledTooltip, disabled = _param.disabled, disabledTooltipProps = _param.disabledTooltipProps, others = _object_without_properties(_param, [
|
|
10
|
-
"disabledTooltip",
|
|
11
|
-
"disabled",
|
|
12
|
-
"disabledTooltipProps"
|
|
13
|
-
]);
|
|
14
|
-
return _jsx(ButtonWithDisabledTooltip, {
|
|
2
|
+
import { Menu as MantineMenu } from '@mantine/core';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { createPolymorphicComponent, overrideComponent } from '../../utils';
|
|
5
|
+
import { ButtonWithDisabledTooltip } from '../button/ButtonWithDisabledTooltip';
|
|
6
|
+
const _MenuItem = /*#__PURE__*/ forwardRef(({ disabledTooltip, disabled, disabledTooltipProps, ...others }, ref)=>/*#__PURE__*/ _jsx(ButtonWithDisabledTooltip, {
|
|
15
7
|
disabled: disabled,
|
|
16
8
|
disabledTooltip: disabledTooltip,
|
|
17
9
|
disabledTooltipProps: disabledTooltipProps,
|
|
18
|
-
children: /*#__PURE__*/ _jsx(MantineMenu.Item,
|
|
10
|
+
children: /*#__PURE__*/ _jsx(MantineMenu.Item, {
|
|
19
11
|
ref: ref,
|
|
20
|
-
disabled: disabled
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export
|
|
26
|
-
displayName:
|
|
12
|
+
disabled: disabled,
|
|
13
|
+
...others
|
|
14
|
+
})
|
|
15
|
+
}));
|
|
16
|
+
const MenuItem = createPolymorphicComponent(_MenuItem);
|
|
17
|
+
export const Menu = overrideComponent(MantineMenu, {
|
|
18
|
+
displayName: '@coveord/plasma-mantine/Menu',
|
|
27
19
|
Item: MenuItem
|
|
28
20
|
});
|
|
29
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/menu/Menu.tsx"],"sourcesContent":["import {Menu as MantineMenu, MenuItemProps as MantineMenuItemProps} from '@mantine/core';\nimport {forwardRef} from 'react';\n\nimport {createPolymorphicComponent, overrideComponent} from '../../utils';\nimport {ButtonWithDisabledTooltipProps} from '../button';\nimport {ButtonWithDisabledTooltip} from '../button/ButtonWithDisabledTooltip';\n\nexport interface MenuItemProps extends MantineMenuItemProps, ButtonWithDisabledTooltipProps {}\n\nconst _MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(\n ({disabledTooltip, disabled, disabledTooltipProps, ...others}, ref) => (\n <ButtonWithDisabledTooltip\n disabled={disabled}\n disabledTooltip={disabledTooltip}\n disabledTooltipProps={disabledTooltipProps}\n >\n <MantineMenu.Item ref={ref} disabled={disabled} {...others} />\n </ButtonWithDisabledTooltip>\n ),\n);\n\nconst MenuItem = createPolymorphicComponent<'button', MenuItemProps>(_MenuItem);\n\nexport const Menu = overrideComponent(MantineMenu, {\n displayName: '@coveord/plasma-mantine/Menu',\n Item: MenuItem,\n});\n"],"names":["Menu","MantineMenu","forwardRef","createPolymorphicComponent","overrideComponent","ButtonWithDisabledTooltip","_MenuItem","
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/menu/Menu.tsx"],"sourcesContent":["import {Menu as MantineMenu, MenuItemProps as MantineMenuItemProps} from '@mantine/core';\nimport {forwardRef} from 'react';\n\nimport {createPolymorphicComponent, overrideComponent} from '../../utils';\nimport {ButtonWithDisabledTooltipProps} from '../button';\nimport {ButtonWithDisabledTooltip} from '../button/ButtonWithDisabledTooltip';\n\nexport interface MenuItemProps extends MantineMenuItemProps, ButtonWithDisabledTooltipProps {}\n\nconst _MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(\n ({disabledTooltip, disabled, disabledTooltipProps, ...others}, ref) => (\n <ButtonWithDisabledTooltip\n disabled={disabled}\n disabledTooltip={disabledTooltip}\n disabledTooltipProps={disabledTooltipProps}\n >\n <MantineMenu.Item ref={ref} disabled={disabled} {...others} />\n </ButtonWithDisabledTooltip>\n ),\n);\n\nconst MenuItem = createPolymorphicComponent<'button', MenuItemProps>(_MenuItem);\n\nexport const Menu = overrideComponent(MantineMenu, {\n displayName: '@coveord/plasma-mantine/Menu',\n Item: MenuItem,\n});\n"],"names":["Menu","MantineMenu","forwardRef","createPolymorphicComponent","overrideComponent","ButtonWithDisabledTooltip","_MenuItem","disabledTooltip","disabled","disabledTooltipProps","others","ref","Item","MenuItem","displayName"],"mappings":";AAAA,SAAQA,QAAQC,WAAW,QAA8C,gBAAgB;AACzF,SAAQC,UAAU,QAAO,QAAQ;AAEjC,SAAQC,0BAA0B,EAAEC,iBAAiB,QAAO,cAAc;AAE1E,SAAQC,yBAAyB,QAAO,sCAAsC;AAI9E,MAAMC,0BAAYJ,WACd,CAAC,EAACK,eAAe,EAAEC,QAAQ,EAAEC,oBAAoB,EAAE,GAAGC,QAAO,EAAEC,oBAC3D,KAACN;QACGG,UAAUA;QACVD,iBAAiBA;QACjBE,sBAAsBA;kBAEtB,cAAA,KAACR,YAAYW,IAAI;YAACD,KAAKA;YAAKH,UAAUA;YAAW,GAAGE,MAAM;;;AAKtE,MAAMG,WAAWV,2BAAoDG;AAErE,OAAO,MAAMN,OAAOI,kBAAkBH,aAAa;IAC/Ca,aAAa;IACbF,MAAMC;AACV,GAAG"}
|
|
@@ -1,139 +1,92 @@
|
|
|
1
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
-
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
|
-
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
4
|
-
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
5
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { Box, CloseButton, createStyles, Modal, Progress } from
|
|
7
|
-
import { Children, useEffect, useMemo, useState } from
|
|
8
|
-
import { Button } from
|
|
9
|
-
import { Header } from
|
|
10
|
-
import { StickyFooter } from
|
|
11
|
-
import { ModalWizardStep } from
|
|
12
|
-
|
|
13
|
-
return {
|
|
2
|
+
import { Box, CloseButton, createStyles, Modal, Progress } from '@mantine/core';
|
|
3
|
+
import { Children, useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import { Button } from '../button';
|
|
5
|
+
import { Header } from '../header';
|
|
6
|
+
import { StickyFooter } from '../sticky-footer';
|
|
7
|
+
import { ModalWizardStep } from './ModalWizardStep';
|
|
8
|
+
const useStyles = createStyles(()=>({
|
|
14
9
|
content: {
|
|
15
|
-
display:
|
|
16
|
-
flexDirection:
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'column'
|
|
17
12
|
},
|
|
18
13
|
body: {
|
|
19
14
|
flex: 1,
|
|
20
|
-
display:
|
|
21
|
-
flexDirection:
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flexDirection: 'column'
|
|
22
17
|
}
|
|
23
|
-
};
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"finishButtonLabel",
|
|
31
|
-
"opened",
|
|
32
|
-
"onNext",
|
|
33
|
-
"onPrevious",
|
|
34
|
-
"onClose",
|
|
35
|
-
"onFinish",
|
|
36
|
-
"isDirty",
|
|
37
|
-
"handleDirtyState",
|
|
38
|
-
"classNames",
|
|
39
|
-
"styles",
|
|
40
|
-
"unstyled",
|
|
41
|
-
"children",
|
|
42
|
-
"isStepValidatedOnNext"
|
|
43
|
-
]);
|
|
44
|
-
var _currentStep_props_validateStep, _currentStep_props, _currentStep, _classNames, _classNames1;
|
|
45
|
-
var _useStyles = useStyles(null, {
|
|
46
|
-
name: "ModalWizard",
|
|
47
|
-
classNames: classNames,
|
|
48
|
-
styles: styles,
|
|
49
|
-
unstyled: unstyled
|
|
50
|
-
}), _useStyles_classes = _useStyles.classes, content = _useStyles_classes.content, body = _useStyles_classes.body, cx = _useStyles.cx;
|
|
51
|
-
var _useState = _sliced_to_array(useState(0), 2), currentStepIndex = _useState[0], setCurrentStepIndex = _useState[1];
|
|
52
|
-
var modalSteps = Children.toArray(children).filter(function(child) {
|
|
53
|
-
return child.type === ModalWizardStep;
|
|
18
|
+
}));
|
|
19
|
+
export const ModalWizard = ({ cancelButtonLabel = 'Cancel', nextButtonLabel = 'Next', previousButtonLabel = 'Previous', finishButtonLabel = 'Finish', opened, onNext, onPrevious, onClose, onFinish, isDirty, handleDirtyState, classNames, styles, unstyled, children, isStepValidatedOnNext, ...modalProps })=>{
|
|
20
|
+
const { classes: { content, body }, cx } = useStyles(null, {
|
|
21
|
+
name: 'ModalWizard',
|
|
22
|
+
classNames,
|
|
23
|
+
styles,
|
|
24
|
+
unstyled
|
|
54
25
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var isValid = (isStepValidatedOnNext ? {
|
|
26
|
+
const [currentStepIndex, setCurrentStepIndex] = useState(0);
|
|
27
|
+
const modalSteps = Children.toArray(children).filter((child)=>child.type === ModalWizardStep);
|
|
28
|
+
const numberOfSteps = modalSteps.length;
|
|
29
|
+
const isFirstStep = currentStepIndex === 0;
|
|
30
|
+
const isLastStep = currentStepIndex === numberOfSteps - 1;
|
|
31
|
+
const currentStep = modalSteps.filter((step, index)=>index === currentStepIndex)[0];
|
|
32
|
+
const { isValid } = isStepValidatedOnNext ? {
|
|
63
33
|
isValid: true
|
|
64
|
-
} :
|
|
34
|
+
} : currentStep?.props?.validateStep?.(currentStepIndex, numberOfSteps) ?? {
|
|
65
35
|
isValid: true
|
|
66
|
-
}
|
|
67
|
-
useEffect(
|
|
36
|
+
};
|
|
37
|
+
useEffect(()=>{
|
|
68
38
|
if (opened) {
|
|
69
39
|
setCurrentStepIndex(0);
|
|
70
40
|
}
|
|
71
41
|
}, [
|
|
72
42
|
opened
|
|
73
43
|
]);
|
|
74
|
-
|
|
75
|
-
var _onClose;
|
|
44
|
+
const handleClose = (confirmDirty)=>{
|
|
76
45
|
if (confirmDirty) {
|
|
77
|
-
|
|
78
|
-
var _isDirty1;
|
|
79
|
-
var isModalDirty = (_isDirty1 = (_isDirty = isDirty) === null || _isDirty === void 0 ? void 0 : _isDirty()) !== null && _isDirty1 !== void 0 ? _isDirty1 : false;
|
|
46
|
+
const isModalDirty = isDirty?.() ?? false;
|
|
80
47
|
if (isModalDirty) {
|
|
81
|
-
|
|
82
|
-
var _handleDirtyState1;
|
|
83
|
-
var discardChanges = (_handleDirtyState1 = (_handleDirtyState = handleDirtyState) === null || _handleDirtyState === void 0 ? void 0 : _handleDirtyState()) !== null && _handleDirtyState1 !== void 0 ? _handleDirtyState1 : true;
|
|
48
|
+
const discardChanges = handleDirtyState?.() ?? true;
|
|
84
49
|
if (!discardChanges) {
|
|
85
50
|
return;
|
|
86
51
|
}
|
|
87
52
|
}
|
|
88
53
|
}
|
|
89
|
-
|
|
54
|
+
onClose?.();
|
|
90
55
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return function(currStepIndex) {
|
|
96
|
-
var totalNumberOfSteps = modalSteps.filter(function(step) {
|
|
97
|
-
return step.props.countsAsProgress;
|
|
98
|
-
}).length;
|
|
99
|
-
var numberOfCompletedSteps = modalSteps.filter(function(step, index) {
|
|
100
|
-
return step.props.countsAsProgress && index <= currStepIndex;
|
|
101
|
-
}).length;
|
|
56
|
+
const resolveStepDependentProp = (prop)=>typeof currentStep.props[prop] === 'function' ? currentStep.props[prop](currentStepIndex + 1, numberOfSteps) : currentStep.props[prop];
|
|
57
|
+
const getProgress = useMemo(()=>(currStepIndex)=>{
|
|
58
|
+
const totalNumberOfSteps = modalSteps.filter((step)=>step.props.countsAsProgress).length;
|
|
59
|
+
const numberOfCompletedSteps = modalSteps.filter((step, index)=>step.props.countsAsProgress && index <= currStepIndex).length;
|
|
102
60
|
return numberOfCompletedSteps / totalNumberOfSteps * 100;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
return /*#__PURE__*/ _jsxs(Modal, _object_spread_props(_object_spread({
|
|
61
|
+
}, []);
|
|
62
|
+
return /*#__PURE__*/ _jsxs(Modal, {
|
|
106
63
|
opened: opened,
|
|
107
64
|
classNames: {
|
|
108
|
-
content: cx(content,
|
|
109
|
-
body: cx(body,
|
|
65
|
+
content: cx(content, classNames?.content),
|
|
66
|
+
body: cx(body, classNames?.body)
|
|
110
67
|
},
|
|
111
68
|
centered: true,
|
|
112
|
-
onClose:
|
|
113
|
-
return handleClose(true);
|
|
114
|
-
},
|
|
69
|
+
onClose: ()=>handleClose(true),
|
|
115
70
|
withCloseButton: false,
|
|
116
|
-
padding: 0
|
|
117
|
-
|
|
71
|
+
padding: 0,
|
|
72
|
+
...modalProps,
|
|
118
73
|
children: [
|
|
119
74
|
/*#__PURE__*/ _jsxs(Header, {
|
|
120
75
|
p: "lg",
|
|
121
76
|
pr: "md",
|
|
122
77
|
variant: "modal",
|
|
123
|
-
description: resolveStepDependentProp(
|
|
78
|
+
description: resolveStepDependentProp('description'),
|
|
124
79
|
borderBottom: !currentStep.props.showProgressBar,
|
|
125
80
|
children: [
|
|
126
|
-
resolveStepDependentProp(
|
|
127
|
-
resolveStepDependentProp(
|
|
128
|
-
href: resolveStepDependentProp(
|
|
129
|
-
label: resolveStepDependentProp(
|
|
81
|
+
resolveStepDependentProp('title'),
|
|
82
|
+
resolveStepDependentProp('docLink') ? /*#__PURE__*/ _jsx(Header.DocAnchor, {
|
|
83
|
+
href: resolveStepDependentProp('docLink'),
|
|
84
|
+
label: resolveStepDependentProp('docLinkTooltipLabel')
|
|
130
85
|
}) : null,
|
|
131
86
|
/*#__PURE__*/ _jsx(Header.Actions, {
|
|
132
87
|
children: /*#__PURE__*/ _jsx(CloseButton, {
|
|
133
|
-
"aria-label":
|
|
134
|
-
onClick:
|
|
135
|
-
return handleClose(true);
|
|
136
|
-
}
|
|
88
|
+
"aria-label": 'close-modal',
|
|
89
|
+
onClick: ()=>handleClose(true)
|
|
137
90
|
})
|
|
138
91
|
})
|
|
139
92
|
]
|
|
@@ -150,7 +103,7 @@ export var ModalWizard = function(_param) {
|
|
|
150
103
|
}),
|
|
151
104
|
/*#__PURE__*/ _jsx(Box, {
|
|
152
105
|
sx: {
|
|
153
|
-
marginTop:
|
|
106
|
+
marginTop: 'auto'
|
|
154
107
|
},
|
|
155
108
|
children: /*#__PURE__*/ _jsxs(StickyFooter, {
|
|
156
109
|
borderTop: true,
|
|
@@ -158,12 +111,11 @@ export var ModalWizard = function(_param) {
|
|
|
158
111
|
/*#__PURE__*/ _jsx(Button, {
|
|
159
112
|
name: isFirstStep ? cancelButtonLabel : previousButtonLabel,
|
|
160
113
|
variant: "outline",
|
|
161
|
-
onClick:
|
|
114
|
+
onClick: ()=>{
|
|
162
115
|
if (isFirstStep) {
|
|
163
116
|
handleClose(true);
|
|
164
117
|
} else {
|
|
165
|
-
|
|
166
|
-
(_onPrevious = onPrevious) === null || _onPrevious === void 0 ? void 0 : _onPrevious(currentStepIndex - 1);
|
|
118
|
+
onPrevious?.(currentStepIndex - 1);
|
|
167
119
|
setCurrentStepIndex(currentStepIndex - 1);
|
|
168
120
|
}
|
|
169
121
|
},
|
|
@@ -172,14 +124,11 @@ export var ModalWizard = function(_param) {
|
|
|
172
124
|
/*#__PURE__*/ _jsx(Button, {
|
|
173
125
|
disabledTooltip: currentStep.props.disabledTooltipLabel,
|
|
174
126
|
disabled: !isValid,
|
|
175
|
-
onClick:
|
|
127
|
+
onClick: ()=>{
|
|
176
128
|
if (isLastStep) {
|
|
177
|
-
|
|
178
|
-
var _onFinish1;
|
|
179
|
-
(_onFinish1 = (_onFinish = onFinish) === null || _onFinish === void 0 ? void 0 : _onFinish()) !== null && _onFinish1 !== void 0 ? _onFinish1 : handleClose(false);
|
|
129
|
+
onFinish?.() ?? handleClose(false);
|
|
180
130
|
} else {
|
|
181
|
-
|
|
182
|
-
(_onNext = onNext) === null || _onNext === void 0 ? void 0 : _onNext(currentStepIndex + 1, setCurrentStepIndex);
|
|
131
|
+
onNext?.(currentStepIndex + 1, setCurrentStepIndex);
|
|
183
132
|
if (!isStepValidatedOnNext) {
|
|
184
133
|
setCurrentStepIndex(currentStepIndex + 1);
|
|
185
134
|
}
|
|
@@ -191,7 +140,7 @@ export var ModalWizard = function(_param) {
|
|
|
191
140
|
})
|
|
192
141
|
})
|
|
193
142
|
]
|
|
194
|
-
})
|
|
143
|
+
});
|
|
195
144
|
};
|
|
196
145
|
ModalWizard.Step = ModalWizardStep;
|
|
197
146
|
|
|
@@ -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 disabledTooltip={currentStep.props.disabledTooltipLabel}\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","disabledTooltip","disabledTooltipLabel","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,oBAA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;wBACbC,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,iBAAiBrD,YAAYkB,KAAK,CAACoC,oBAAoB;4BACvDC,UAAU,CAACtC;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,YAAY0E,IAAI,GAAGjF"}
|
|
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 disabledTooltip={currentStep.props.disabledTooltipLabel}\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","classes","cx","name","currentStepIndex","setCurrentStepIndex","modalSteps","toArray","filter","child","type","numberOfSteps","length","isFirstStep","isLastStep","currentStep","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","disabledTooltip","disabledTooltipLabel","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,MAAMC,YAAYX,aAAa,IAAO,CAAA;QAClCY,SAAS;YACLC,SAAS;YACTC,eAAe;QACnB;QACAC,MAAM;YACFC,MAAM;YACNH,SAAS;YACTC,eAAe;QACnB;IACJ,CAAA;AAkFA,OAAO,MAAMG,cAA+B,CAAC,EACzCC,oBAAoB,QAAQ,EAC5BC,kBAAkB,MAAM,EACxBC,sBAAsB,UAAU,EAChCC,oBAAoB,QAAQ,EAC5BC,MAAM,EACNC,MAAM,EACNC,UAAU,EACVC,OAAO,EACPC,QAAQ,EACRC,OAAO,EACPC,gBAAgB,EAChBC,UAAU,EACVC,MAAM,EACNC,QAAQ,EACRC,QAAQ,EACRC,qBAAqB,EACrB,GAAGC,YACN;IACG,MAAM,EACFC,SAAS,EAACvB,OAAO,EAAEG,IAAI,EAAC,EACxBqB,EAAE,EACL,GAAGzB,U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BAAgB6B,YAAY;gCAChC,OAAO;oCACHhC,SAASe,mBAAmB,GAAGC;oCAE/B,IAAI,CAACN,uBAAuB;wCACxBM,oBAAoBD,mBAAmB;oCAC3C;gCACJ;4BACJ;sCAECU,aAAa3B,oBAAoBF;;;;;;;AAM1D,EAAE;AAEFF,YAAY0E,IAAI,GAAGjF"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
var children = param.children;
|
|
4
|
-
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
2
|
+
const ModalWizardStep = ({ children })=>/*#__PURE__*/ _jsx(_Fragment, {
|
|
5
3
|
children: children
|
|
6
4
|
});
|
|
7
|
-
};
|
|
8
5
|
ModalWizardStep.defaultProps = {
|
|
9
6
|
showProgressBar: true,
|
|
10
7
|
countsAsProgress: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/modal-wizard/ModalWizardStep.tsx"],"sourcesContent":["import {FunctionComponent, PropsWithChildren, ReactNode} from 'react';\n\ntype DependsOnStep<T> = (currentStep: number, numberOfSteps: number) => T;\nexport type ResolveStep<P> = P extends infer T | DependsOnStep<infer T> ? T : never;\n\nexport interface ModalWizardStepProps {\n /**\n * The title of the current step. The title can be dependent on the current step if needed\n */\n title?: ReactNode | DependsOnStep<ReactNode>;\n\n /**\n * The description of the current step. The description can be dependent on the current step if needed\n */\n description?: string | DependsOnStep<string>;\n\n /**\n * A link to the documentation for the current step\n */\n docLink?: string | DependsOnStep<string>;\n\n /**\n * A tooltip label for the docLink\n */\n docLinkTooltipLabel?: string | DependsOnStep<string>;\n\n /**\n * A function to validate the current step, it determines if the next step should be enabled or not.\n */\n validateStep?: (currentStep: any, numberOfSteps: any) => {isValid: boolean; messsage?: unknown};\n\n /**\n * Show progress bar at this step\n *\n * @default true\n */\n showProgressBar?: boolean;\n\n /**\n * Does completion of current step count moves the progress bar\n *\n * @default true\n */\n countsAsProgress?: boolean;\n\n /**\n * Tooltip label of the next button when disabled\n */\n disabledTooltipLabel?: string;\n}\n\nconst ModalWizardStep: FunctionComponent<PropsWithChildren<ModalWizardStepProps>> = ({children}) => <>{children}</>;\n\nModalWizardStep.defaultProps = {\n showProgressBar: true,\n countsAsProgress: true,\n};\n\nexport {ModalWizardStep};\n"],"names":["ModalWizardStep","children","defaultProps","showProgressBar","countsAsProgress"],"mappings":";AAmDA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/modal-wizard/ModalWizardStep.tsx"],"sourcesContent":["import {FunctionComponent, PropsWithChildren, ReactNode} from 'react';\n\ntype DependsOnStep<T> = (currentStep: number, numberOfSteps: number) => T;\nexport type ResolveStep<P> = P extends infer T | DependsOnStep<infer T> ? T : never;\n\nexport interface ModalWizardStepProps {\n /**\n * The title of the current step. The title can be dependent on the current step if needed\n */\n title?: ReactNode | DependsOnStep<ReactNode>;\n\n /**\n * The description of the current step. The description can be dependent on the current step if needed\n */\n description?: string | DependsOnStep<string>;\n\n /**\n * A link to the documentation for the current step\n */\n docLink?: string | DependsOnStep<string>;\n\n /**\n * A tooltip label for the docLink\n */\n docLinkTooltipLabel?: string | DependsOnStep<string>;\n\n /**\n * A function to validate the current step, it determines if the next step should be enabled or not.\n */\n validateStep?: (currentStep: any, numberOfSteps: any) => {isValid: boolean; messsage?: unknown};\n\n /**\n * Show progress bar at this step\n *\n * @default true\n */\n showProgressBar?: boolean;\n\n /**\n * Does completion of current step count moves the progress bar\n *\n * @default true\n */\n countsAsProgress?: boolean;\n\n /**\n * Tooltip label of the next button when disabled\n */\n disabledTooltipLabel?: string;\n}\n\nconst ModalWizardStep: FunctionComponent<PropsWithChildren<ModalWizardStepProps>> = ({children}) => <>{children}</>;\n\nModalWizardStep.defaultProps = {\n showProgressBar: true,\n countsAsProgress: true,\n};\n\nexport {ModalWizardStep};\n"],"names":["ModalWizardStep","children","defaultProps","showProgressBar","countsAsProgress"],"mappings":";AAmDA,MAAMA,kBAA8E,CAAC,EAACC,QAAQ,EAAC,iBAAK;kBAAGA;;AAEvGD,gBAAgBE,YAAY,GAAG;IAC3BC,iBAAiB;IACjBC,kBAAkB;AACtB;AAEA,SAAQJ,eAAe,GAAE"}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
-
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
|
-
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
4
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { color } from
|
|
6
|
-
import { createStyles, Modal } from
|
|
7
|
-
import { Children } from
|
|
8
|
-
import { PromptFooter } from
|
|
9
|
-
|
|
10
|
-
return {
|
|
2
|
+
import { color } from '@coveord/plasma-tokens';
|
|
3
|
+
import { createStyles, Modal } from '@mantine/core';
|
|
4
|
+
import { Children } from 'react';
|
|
5
|
+
import { PromptFooter } from './PromptFooter';
|
|
6
|
+
const useStyles = createStyles((theme)=>({
|
|
11
7
|
body: {
|
|
12
8
|
padding: 0
|
|
13
9
|
},
|
|
14
10
|
modalType: {
|
|
15
|
-
overflow:
|
|
11
|
+
overflow: 'hidden',
|
|
16
12
|
width: 550
|
|
17
13
|
},
|
|
18
14
|
innerBody: {
|
|
19
|
-
padding:
|
|
15
|
+
padding: `${theme.spacing.md} ${theme.spacing.xl} ${theme.spacing.lg}`
|
|
20
16
|
},
|
|
21
17
|
header: {
|
|
22
|
-
padding:
|
|
23
|
-
width:
|
|
24
|
-
borderBottom:
|
|
18
|
+
padding: `${theme.spacing.md} ${theme.spacing.xl}`,
|
|
19
|
+
width: '100%',
|
|
20
|
+
borderBottom: `1px solid ${theme.colors.gray[3]}`,
|
|
25
21
|
fontSize: theme.headings.sizes.h3.fontSize,
|
|
26
22
|
lineHeight: theme.headings.sizes.h3.lineHeight,
|
|
27
|
-
overflowWrap:
|
|
23
|
+
overflowWrap: 'anywhere'
|
|
28
24
|
},
|
|
29
25
|
success: {
|
|
30
26
|
backgroundColor: theme.colors.lime[6],
|
|
@@ -44,44 +40,36 @@ var useStyles = createStyles(function(theme) {
|
|
|
44
40
|
},
|
|
45
41
|
whiteClose: {
|
|
46
42
|
color: color.primary.pureWhite,
|
|
47
|
-
|
|
48
|
-
backgroundColor:
|
|
43
|
+
'&:hover': {
|
|
44
|
+
backgroundColor: 'transparent'
|
|
49
45
|
}
|
|
50
46
|
},
|
|
51
47
|
title: {
|
|
52
48
|
color: color.primary.pureWhite
|
|
53
49
|
}
|
|
54
|
-
};
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"classNames"
|
|
63
|
-
]);
|
|
64
|
-
var _useStyles = useStyles(), classes = _useStyles.classes, cx = _useStyles.cx;
|
|
65
|
-
var convertedChildren = Children.toArray(children);
|
|
66
|
-
var otherChildren = convertedChildren.filter(function(child) {
|
|
67
|
-
return child.type !== PromptFooter;
|
|
68
|
-
});
|
|
69
|
-
var footer = convertedChildren.find(function(child) {
|
|
70
|
-
return child.type === PromptFooter;
|
|
71
|
-
});
|
|
72
|
-
var classNames = {
|
|
50
|
+
}));
|
|
51
|
+
export const Prompt = ({ children, variant = 'info', ...otherProps })=>{
|
|
52
|
+
const { classNames: classesProps, ...otherPropsWithoutClasses } = otherProps;
|
|
53
|
+
const { classes, cx } = useStyles();
|
|
54
|
+
const convertedChildren = Children.toArray(children);
|
|
55
|
+
const otherChildren = convertedChildren.filter((child)=>child.type !== PromptFooter);
|
|
56
|
+
const footer = convertedChildren.find((child)=>child.type === PromptFooter);
|
|
57
|
+
const classNames = {
|
|
73
58
|
header: cx(classes.header, classes[variant]),
|
|
74
59
|
close: classes.whiteClose,
|
|
75
60
|
body: classes.body,
|
|
76
61
|
modal: classes.modalType,
|
|
77
62
|
title: classes.title
|
|
78
63
|
};
|
|
79
|
-
return /*#__PURE__*/ _jsxs(Modal,
|
|
64
|
+
return /*#__PURE__*/ _jsxs(Modal, {
|
|
80
65
|
variant: "prompt",
|
|
81
66
|
padding: 0,
|
|
82
|
-
classNames:
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
classNames: {
|
|
68
|
+
...classNames,
|
|
69
|
+
...classesProps
|
|
70
|
+
},
|
|
71
|
+
size: 'sm',
|
|
72
|
+
...otherPropsWithoutClasses,
|
|
85
73
|
children: [
|
|
86
74
|
/*#__PURE__*/ _jsx("div", {
|
|
87
75
|
className: classes.innerBody,
|
|
@@ -89,7 +77,7 @@ export var Prompt = function(_param) {
|
|
|
89
77
|
}),
|
|
90
78
|
footer
|
|
91
79
|
]
|
|
92
|
-
})
|
|
80
|
+
});
|
|
93
81
|
};
|
|
94
82
|
Prompt.Footer = PromptFooter;
|
|
95
83
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/prompt/Prompt.tsx"],"sourcesContent":["import {color} from '@coveord/plasma-tokens';\nimport {createStyles, Modal, ModalProps} from '@mantine/core';\nimport {Children, ReactElement, ReactNode} from 'react';\nimport {PromptFooter} from './PromptFooter';\n\nconst useStyles = createStyles((theme) => ({\n body: {\n padding: 0,\n },\n modalType: {overflow: 'hidden', width: 550},\n innerBody: {\n padding: `${theme.spacing.md} ${theme.spacing.xl} ${theme.spacing.lg}`,\n },\n header: {\n padding: `${theme.spacing.md} ${theme.spacing.xl}`,\n width: '100%',\n borderBottom: `1px solid ${theme.colors.gray[3]}`,\n fontSize: theme.headings.sizes.h3.fontSize,\n lineHeight: theme.headings.sizes.h3.lineHeight,\n overflowWrap: 'anywhere',\n },\n success: {backgroundColor: theme.colors.lime[6], color: color.primary.pureWhite},\n warning: {backgroundColor: theme.colors.yellow[5], color: color.primary.pureWhite},\n critical: {\n backgroundColor: theme.colors.red[6],\n color: color.primary.pureWhite,\n },\n info: {backgroundColor: theme.colors.navy[5], color: color.primary.pureWhite},\n whiteClose: {color: color.primary.pureWhite, '&:hover': {backgroundColor: 'transparent'}},\n title: {\n color: color.primary.pureWhite,\n },\n}));\n\nexport interface PromptProps extends ModalProps {\n /**\n * Controls prompt appearance\n *\n * @default \"info\"\n */\n variant?: 'success' | 'warning' | 'critical' | 'info';\n children: ReactNode;\n}\ninterface PromptType {\n (props: PromptProps): ReactElement;\n Footer: typeof PromptFooter;\n}\n\nexport const Prompt: PromptType = ({children, variant = 'info', ...otherProps}) => {\n const {classNames: classesProps, ...otherPropsWithoutClasses} = otherProps;\n const {classes, cx} = useStyles();\n const convertedChildren = Children.toArray(children) as ReactElement[];\n\n const otherChildren = convertedChildren.filter((child) => child.type !== PromptFooter);\n const footer = convertedChildren.find((child) => child.type === PromptFooter);\n\n const classNames = {\n header: cx(classes.header, classes[variant]),\n close: classes.whiteClose,\n body: classes.body,\n modal: classes.modalType,\n title: classes.title,\n };\n\n return (\n <Modal\n variant=\"prompt\"\n padding={0}\n classNames={{...classNames, ...classesProps}}\n size={'sm'}\n {...otherPropsWithoutClasses}\n >\n <div className={classes.innerBody}>{otherChildren}</div>\n {footer}\n </Modal>\n );\n};\n\nPrompt.Footer = PromptFooter;\n"],"names":["color","createStyles","Modal","Children","PromptFooter","useStyles","theme","body","padding","modalType","overflow","width","innerBody","spacing","md","xl","lg","header","borderBottom","colors","gray","fontSize","headings","sizes","h3","lineHeight","overflowWrap","success","backgroundColor","lime","primary","pureWhite","warning","yellow","critical","red","info","navy","whiteClose","title","Prompt","children","variant","otherProps","classNames","classesProps","otherPropsWithoutClasses","classes","cx","convertedChildren","toArray","otherChildren","filter","child","type","footer","find","close","modal","size","div","className","Footer"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/prompt/Prompt.tsx"],"sourcesContent":["import {color} from '@coveord/plasma-tokens';\nimport {createStyles, Modal, ModalProps} from '@mantine/core';\nimport {Children, ReactElement, ReactNode} from 'react';\nimport {PromptFooter} from './PromptFooter';\n\nconst useStyles = createStyles((theme) => ({\n body: {\n padding: 0,\n },\n modalType: {overflow: 'hidden', width: 550},\n innerBody: {\n padding: `${theme.spacing.md} ${theme.spacing.xl} ${theme.spacing.lg}`,\n },\n header: {\n padding: `${theme.spacing.md} ${theme.spacing.xl}`,\n width: '100%',\n borderBottom: `1px solid ${theme.colors.gray[3]}`,\n fontSize: theme.headings.sizes.h3.fontSize,\n lineHeight: theme.headings.sizes.h3.lineHeight,\n overflowWrap: 'anywhere',\n },\n success: {backgroundColor: theme.colors.lime[6], color: color.primary.pureWhite},\n warning: {backgroundColor: theme.colors.yellow[5], color: color.primary.pureWhite},\n critical: {\n backgroundColor: theme.colors.red[6],\n color: color.primary.pureWhite,\n },\n info: {backgroundColor: theme.colors.navy[5], color: color.primary.pureWhite},\n whiteClose: {color: color.primary.pureWhite, '&:hover': {backgroundColor: 'transparent'}},\n title: {\n color: color.primary.pureWhite,\n },\n}));\n\nexport interface PromptProps extends ModalProps {\n /**\n * Controls prompt appearance\n *\n * @default \"info\"\n */\n variant?: 'success' | 'warning' | 'critical' | 'info';\n children: ReactNode;\n}\ninterface PromptType {\n (props: PromptProps): ReactElement;\n Footer: typeof PromptFooter;\n}\n\nexport const Prompt: PromptType = ({children, variant = 'info', ...otherProps}) => {\n const {classNames: classesProps, ...otherPropsWithoutClasses} = otherProps;\n const {classes, cx} = useStyles();\n const convertedChildren = Children.toArray(children) as ReactElement[];\n\n const otherChildren = convertedChildren.filter((child) => child.type !== PromptFooter);\n const footer = convertedChildren.find((child) => child.type === PromptFooter);\n\n const classNames = {\n header: cx(classes.header, classes[variant]),\n close: classes.whiteClose,\n body: classes.body,\n modal: classes.modalType,\n title: classes.title,\n };\n\n return (\n <Modal\n variant=\"prompt\"\n padding={0}\n classNames={{...classNames, ...classesProps}}\n size={'sm'}\n {...otherPropsWithoutClasses}\n >\n <div className={classes.innerBody}>{otherChildren}</div>\n {footer}\n </Modal>\n );\n};\n\nPrompt.Footer = PromptFooter;\n"],"names":["color","createStyles","Modal","Children","PromptFooter","useStyles","theme","body","padding","modalType","overflow","width","innerBody","spacing","md","xl","lg","header","borderBottom","colors","gray","fontSize","headings","sizes","h3","lineHeight","overflowWrap","success","backgroundColor","lime","primary","pureWhite","warning","yellow","critical","red","info","navy","whiteClose","title","Prompt","children","variant","otherProps","classNames","classesProps","otherPropsWithoutClasses","classes","cx","convertedChildren","toArray","otherChildren","filter","child","type","footer","find","close","modal","size","div","className","Footer"],"mappings":";AAAA,SAAQA,KAAK,QAAO,yBAAyB;AAC7C,SAAQC,YAAY,EAAEC,KAAK,QAAmB,gBAAgB;AAC9D,SAAQC,QAAQ,QAAgC,QAAQ;AACxD,SAAQC,YAAY,QAAO,iBAAiB;AAE5C,MAAMC,YAAYJ,aAAa,CAACK,QAAW,CAAA;QACvCC,MAAM;YACFC,SAAS;QACb;QACAC,WAAW;YAACC,UAAU;YAAUC,OAAO;QAAG;QAC1CC,WAAW;YACPJ,SAAS,CAAC,EAAEF,MAAMO,OAAO,CAACC,EAAE,CAAC,CAAC,EAAER,MAAMO,OAAO,CAACE,EAAE,CAAC,CAAC,EAAET,MAAMO,OAAO,CAACG,EAAE,CAAC,CAAC;QAC1E;QACAC,QAAQ;YACJT,SAAS,CAAC,EAAEF,MAAMO,OAAO,CAACC,EAAE,CAAC,CAAC,EAAER,MAAMO,OAAO,CAACE,EAAE,CAAC,CAAC;YAClDJ,OAAO;YACPO,cAAc,CAAC,UAAU,EAAEZ,MAAMa,MAAM,CAACC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjDC,UAAUf,MAAMgB,QAAQ,CAACC,KAAK,CAACC,EAAE,CAACH,QAAQ;YAC1CI,YAAYnB,MAAMgB,QAAQ,CAACC,KAAK,CAACC,EAAE,CAACC,UAAU;YAC9CC,cAAc;QAClB;QACAC,SAAS;YAACC,iBAAiBtB,MAAMa,MAAM,CAACU,IAAI,CAAC,EAAE;YAAE7B,OAAOA,MAAM8B,OAAO,CAACC,SAAS;QAAA;QAC/EC,SAAS;YAACJ,iBAAiBtB,M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