@coveord/plasma-mantine 52.13.0 → 52.13.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.
Files changed (80) hide show
  1. package/.eslintrc.js +1 -1
  2. package/.turbo/turbo-build.log +3 -3
  3. package/.turbo/turbo-test.log +31 -31
  4. package/__mocks__/@monaco-editor/react.tsx +2 -2
  5. package/dist/.tsbuildinfo +1 -1
  6. package/dist/cjs/components/button/Button.js.map +1 -1
  7. package/dist/cjs/components/button/ButtonWithDisabledTooltip.js.map +1 -1
  8. package/dist/cjs/components/collection/Collection.js.map +1 -1
  9. package/dist/cjs/components/date-range-picker/DateRangePickerPresetSelect.js.map +1 -1
  10. package/dist/cjs/components/header/Header.js.map +1 -1
  11. package/dist/cjs/components/inline-confirm/InlineConfirm.js.map +1 -1
  12. package/dist/cjs/components/inline-confirm/InlineConfirmButton.js.map +1 -1
  13. package/dist/cjs/components/inline-confirm/InlineConfirmMenuItem.js.map +1 -1
  14. package/dist/cjs/components/menu/Menu.js.map +1 -1
  15. package/dist/cjs/components/modal-wizard/ModalWizard.js.map +1 -1
  16. package/dist/cjs/components/table/layouts/RowLayout.d.ts.map +1 -1
  17. package/dist/cjs/components/table/layouts/RowLayout.js +2 -1
  18. package/dist/cjs/components/table/layouts/RowLayout.js.map +1 -1
  19. package/dist/cjs/components/table/useRowSelection.js.map +1 -1
  20. package/dist/cjs/form/FormProvider.js.map +1 -1
  21. package/dist/cjs/form/useForm.js.map +1 -1
  22. package/dist/cjs/theme/Theme.d.ts.map +1 -1
  23. package/dist/cjs/theme/Theme.js +4 -2
  24. package/dist/cjs/theme/Theme.js.map +1 -1
  25. package/dist/cjs/utils/overrideComponent.js.map +1 -1
  26. package/dist/esm/components/button/Button.js.map +1 -1
  27. package/dist/esm/components/button/ButtonWithDisabledTooltip.js.map +1 -1
  28. package/dist/esm/components/collection/Collection.js.map +1 -1
  29. package/dist/esm/components/date-range-picker/DateRangePickerPresetSelect.js.map +1 -1
  30. package/dist/esm/components/header/Header.js.map +1 -1
  31. package/dist/esm/components/inline-confirm/InlineConfirm.js.map +1 -1
  32. package/dist/esm/components/inline-confirm/InlineConfirmButton.js.map +1 -1
  33. package/dist/esm/components/inline-confirm/InlineConfirmMenuItem.js.map +1 -1
  34. package/dist/esm/components/menu/Menu.js.map +1 -1
  35. package/dist/esm/components/modal-wizard/ModalWizard.js.map +1 -1
  36. package/dist/esm/components/table/layouts/RowLayout.d.ts.map +1 -1
  37. package/dist/esm/components/table/layouts/RowLayout.js +2 -1
  38. package/dist/esm/components/table/layouts/RowLayout.js.map +1 -1
  39. package/dist/esm/components/table/useRowSelection.js.map +1 -1
  40. package/dist/esm/form/FormProvider.js.map +1 -1
  41. package/dist/esm/form/useForm.js.map +1 -1
  42. package/dist/esm/theme/Theme.d.ts.map +1 -1
  43. package/dist/esm/theme/Theme.js +4 -2
  44. package/dist/esm/theme/Theme.js.map +1 -1
  45. package/dist/esm/utils/overrideComponent.js.map +1 -1
  46. package/package.json +6 -4
  47. package/src/components/button/Button.tsx +1 -1
  48. package/src/components/button/ButtonWithDisabledTooltip.tsx +2 -2
  49. package/src/components/button/__tests__/Button.spec.tsx +6 -6
  50. package/src/components/button/__tests__/ButtonWithDisabledTooltip.spec.tsx +3 -3
  51. package/src/components/collection/Collection.tsx +1 -1
  52. package/src/components/date-range-picker/DateRangePickerPresetSelect.tsx +1 -1
  53. package/src/components/date-range-picker/__tests__/DateRangePickerInlineCalendar.spec.tsx +8 -4
  54. package/src/components/date-range-picker/__tests__/DateRangePickerPresetSelect.spec.tsx +4 -4
  55. package/src/components/header/Header.tsx +1 -1
  56. package/src/components/header/__tests__/Header.spec.tsx +4 -4
  57. package/src/components/inline-confirm/InlineConfirm.tsx +1 -1
  58. package/src/components/inline-confirm/InlineConfirmButton.tsx +1 -1
  59. package/src/components/inline-confirm/InlineConfirmMenuItem.tsx +1 -1
  60. package/src/components/inline-confirm/__tests__/InlineConfirm.spec.tsx +5 -5
  61. package/src/components/menu/Menu.tsx +1 -1
  62. package/src/components/modal-wizard/ModalWizard.tsx +3 -3
  63. package/src/components/modal-wizard/__tests__/ModalWizard.spec.tsx +21 -21
  64. package/src/components/prompt/__tests__/Prompt.spec.tsx +2 -2
  65. package/src/components/sticky-footer/__tests__/StickyFooter.spec.tsx +1 -1
  66. package/src/components/table/__tests__/Table.spec.tsx +15 -15
  67. package/src/components/table/__tests__/TableActions.spec.tsx +3 -3
  68. package/src/components/table/__tests__/TableDateRangePicker.spec.tsx +2 -2
  69. package/src/components/table/__tests__/TableFilter.spec.tsx +7 -7
  70. package/src/components/table/__tests__/TableLastUpdated.spec.tsx +2 -2
  71. package/src/components/table/__tests__/TablePagination.spec.tsx +6 -6
  72. package/src/components/table/__tests__/TablePerPage.spec.tsx +10 -10
  73. package/src/components/table/__tests__/TablePredicate.spec.tsx +2 -2
  74. package/src/components/table/layouts/RowLayout.tsx +1 -0
  75. package/src/components/table/layouts/__tests__/RowLayout.spec.tsx +16 -16
  76. package/src/components/table/useRowSelection.ts +4 -4
  77. package/src/form/FormProvider.tsx +2 -2
  78. package/src/form/useForm.ts +1 -1
  79. package/src/theme/Theme.tsx +2 -0
  80. package/src/utils/overrideComponent.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import {Button as MantineButton, ButtonProps as MantineButtonProps} from '@mantine/core';\nimport {forwardRef, MouseEvent, MouseEventHandler, useState} from 'react';\n\nimport {createPolymorphicComponent} from '../../utils';\nimport {ButtonWithDisabledTooltip, ButtonWithDisabledTooltipProps} from './ButtonWithDisabledTooltip';\n\nexport interface ButtonProps extends MantineButtonProps, ButtonWithDisabledTooltipProps {\n /* Handler executed on click */\n onClick?: MouseEventHandler<HTMLButtonElement>;\n}\n\nconst useLoadingHandler = (handler?: MouseEventHandler<HTMLButtonElement>) => {\n const [isLoading, setIsLoading] = useState(false);\n\n const handleClick = async (event: MouseEvent<HTMLButtonElement>) => {\n const possiblePromise: unknown = handler?.(event);\n try {\n if (possiblePromise instanceof Promise) {\n setIsLoading(true);\n await possiblePromise;\n setIsLoading(false);\n }\n } catch (err) {\n setIsLoading(false);\n console.error(err);\n }\n };\n\n return {isLoading, handleClick};\n};\n\nconst _Button = forwardRef<HTMLButtonElement, ButtonProps>(\n ({disabledTooltip, disabled, disabledTooltipProps, loading, onClick, ...others}, ref) => {\n const {isLoading, handleClick} = useLoadingHandler(onClick);\n return (\n <ButtonWithDisabledTooltip\n disabled={disabled}\n disabledTooltip={disabledTooltip}\n disabledTooltipProps={disabledTooltipProps}\n fullWidth={others.fullWidth}\n >\n <MantineButton\n loaderProps={{variant: 'oval'}}\n ref={ref}\n loading={isLoading || loading}\n onClick={handleClick}\n disabled={disabled}\n {...others}\n />\n </ButtonWithDisabledTooltip>\n );\n }\n);\n\nexport const Button = createPolymorphicComponent<'button', ButtonProps, {Group: typeof MantineButton.Group}>(_Button);\nButton.Group = MantineButton.Group;\n"],"names":["Button","useLoadingHandler","handler","useState","isLoading","setIsLoading","handleClick","event","possiblePromise","err","Promise","console","error","_Button","forwardRef","ref","disabledTooltip","disabled","disabledTooltipProps","loading","onClick","others","ButtonWithDisabledTooltip","fullWidth","MantineButton","loaderProps","variant","createPolymorphicComponent","Group"],"mappings":";;;;+BAsDaA;;;eAAAA;;;;;;;;;;oBAtD4D;qBACP;qBAEzB;yCAC+B;AAOxE,IAAMC,oBAAoB,SAACC;IACvB,IAAkCC,+BAAAA,IAAAA,eAAQ,EAAC,YAApCC,YAA2BD,cAAhBE,eAAgBF;IAElC,IAAMG;mBAAc,sBAAA,SAAOC;gBACUL,UAA3BM,iBAOGC;;;;wBAPHD,mBAA2BN,WAAAA,qBAAAA,+BAAAA,SAAUK;;;;;;;;;6BAEnCC,AAAe,aAAYE,CAA3BF,iBAA2BE,UAA3BF;;;;wBACAH,aAAa;wBACb;;4BAAMG;;;wBAAN;wBACAH,aAAa;;;;;;;;wBAEZI;wBACLJ,aAAa;wBACbM,QAAQC,KAAK,CAACH;;;;;;;;;;;QAEtB;wBAZMH,YAAqBC;;;;IAc3B,OAAO;QAACH,WAAAA;QAAWE,aAAAA;IAAW;AAClC;AAEA,IAAMO,wBAAUC,IAAAA,iBAAU,EACtB,iBAAiFC;QAA/EC,yBAAAA,iBAAiBC,kBAAAA,UAAUC,8BAAAA,sBAAsBC,iBAAAA,SAASC,iBAAAA,SAAYC;QAAtEL;QAAiBC;QAAUC;QAAsBC;QAASC;;IACxD,IAAiCnB,qBAAAA,kBAAkBmB,UAA5ChB,YAA0BH,mBAA1BG,WAAWE,cAAeL,mBAAfK;IAClB,qBACI,qBAACgB,oDAAyB;QACtBL,UAAUA;QACVD,iBAAiBA;QACjBE,sBAAsBA;QACtBK,WAAWF,OAAOE,SAAS;kBAE3B,cAAA,qBAACC,YAAa;YACVC,aAAa;gBAACC,SAAS;YAAM;YAC7BX,KAAKA;YACLI,SAASf,aAAae;YACtBC,SAASd;YACTW,UAAUA;WACNI;;AAIpB;AAGG,IAAMrB,SAAS2B,IAAAA,iCAA0B,EAA6Dd;AAC7Gb,OAAO4B,KAAK,GAAGJ,YAAa,CAACI,KAAK"}
1
+ {"version":3,"sources":["../../../../src/components/button/Button.tsx"],"sourcesContent":["import {Button as MantineButton, ButtonProps as MantineButtonProps} from '@mantine/core';\nimport {forwardRef, MouseEvent, MouseEventHandler, useState} from 'react';\n\nimport {createPolymorphicComponent} from '../../utils';\nimport {ButtonWithDisabledTooltip, ButtonWithDisabledTooltipProps} from './ButtonWithDisabledTooltip';\n\nexport interface ButtonProps extends MantineButtonProps, ButtonWithDisabledTooltipProps {\n /* Handler executed on click */\n onClick?: MouseEventHandler<HTMLButtonElement>;\n}\n\nconst useLoadingHandler = (handler?: MouseEventHandler<HTMLButtonElement>) => {\n const [isLoading, setIsLoading] = useState(false);\n\n const handleClick = async (event: MouseEvent<HTMLButtonElement>) => {\n const possiblePromise: unknown = handler?.(event);\n try {\n if (possiblePromise instanceof Promise) {\n setIsLoading(true);\n await possiblePromise;\n setIsLoading(false);\n }\n } catch (err) {\n setIsLoading(false);\n console.error(err);\n }\n };\n\n return {isLoading, handleClick};\n};\n\nconst _Button = forwardRef<HTMLButtonElement, ButtonProps>(\n ({disabledTooltip, disabled, disabledTooltipProps, loading, onClick, ...others}, ref) => {\n const {isLoading, handleClick} = useLoadingHandler(onClick);\n return (\n <ButtonWithDisabledTooltip\n disabled={disabled}\n disabledTooltip={disabledTooltip}\n disabledTooltipProps={disabledTooltipProps}\n fullWidth={others.fullWidth}\n >\n <MantineButton\n loaderProps={{variant: 'oval'}}\n ref={ref}\n loading={isLoading || loading}\n onClick={handleClick}\n disabled={disabled}\n {...others}\n />\n </ButtonWithDisabledTooltip>\n );\n },\n);\n\nexport const Button = createPolymorphicComponent<'button', ButtonProps, {Group: typeof MantineButton.Group}>(_Button);\nButton.Group = MantineButton.Group;\n"],"names":["Button","useLoadingHandler","handler","useState","isLoading","setIsLoading","handleClick","event","possiblePromise","err","Promise","console","error","_Button","forwardRef","ref","disabledTooltip","disabled","disabledTooltipProps","loading","onClick","others","ButtonWithDisabledTooltip","fullWidth","MantineButton","loaderProps","variant","createPolymorphicComponent","Group"],"mappings":";;;;+BAsDaA;;;eAAAA;;;;;;;;;;oBAtD4D;qBACP;qBAEzB;yCAC+B;AAOxE,IAAMC,oBAAoB,SAACC;IACvB,IAAkCC,+BAAAA,IAAAA,eAAQ,EAAC,YAApCC,YAA2BD,cAAhBE,eAAgBF;IAElC,IAAMG;mBAAc,sBAAA,SAAOC;gBACUL,UAA3BM,iBAOGC;;;;wBAPHD,mBAA2BN,WAAAA,qBAAAA,+BAAAA,SAAUK;;;;;;;;;6BAEnCC,AAAe,aAAYE,CAA3BF,iBAA2BE,UAA3BF;;;;wBACAH,aAAa;wBACb;;4BAAMG;;;wBAAN;wBACAH,aAAa;;;;;;;;wBAEZI;wBACLJ,aAAa;wBACbM,QAAQC,KAAK,CAACH;;;;;;;;;;;QAEtB;wBAZMH,YAAqBC;;;;IAc3B,OAAO;QAACH,WAAAA;QAAWE,aAAAA;IAAW;AAClC;AAEA,IAAMO,wBAAUC,IAAAA,iBAAU,EACtB,iBAAiFC;QAA/EC,yBAAAA,iBAAiBC,kBAAAA,UAAUC,8BAAAA,sBAAsBC,iBAAAA,SAASC,iBAAAA,SAAYC;QAAtEL;QAAiBC;QAAUC;QAAsBC;QAASC;;IACxD,IAAiCnB,qBAAAA,kBAAkBmB,UAA5ChB,YAA0BH,mBAA1BG,WAAWE,cAAeL,mBAAfK;IAClB,qBACI,qBAACgB,oDAAyB;QACtBL,UAAUA;QACVD,iBAAiBA;QACjBE,sBAAsBA;QACtBK,WAAWF,OAAOE,SAAS;kBAE3B,cAAA,qBAACC,YAAa;YACVC,aAAa;gBAACC,SAAS;YAAM;YAC7BX,KAAKA;YACLI,SAASf,aAAae;YACtBC,SAASd;YACTW,UAAUA;WACNI;;AAIpB;AAGG,IAAMrB,SAAS2B,IAAAA,iCAA0B,EAA6Dd;AAC7Gb,OAAO4B,KAAK,GAAGJ,YAAa,CAACI,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/button/ButtonWithDisabledTooltip.tsx"],"sourcesContent":["import {Box, Tooltip, TooltipProps} from '@mantine/core';\nimport {forwardRef, ReactNode} from 'react';\n\nimport {createPolymorphicComponent} from '../../utils';\n\nexport interface ButtonWithDisabledTooltipProps {\n /**\n * The tooltip message to display when disabled\n */\n disabledTooltip?: string;\n /**\n * Whether the button underneath the tooltip is disabled\n */\n disabled?: boolean;\n children?: ReactNode;\n /**\n * Additional tooltip props to set on the disabled button tooltip\n */\n disabledTooltipProps?: Omit<TooltipProps, 'disabled' | 'label' | 'children'>;\n /**\n * Sets button width to 100% of parent element\n */\n fullWidth?: boolean;\n}\n\nconst _ButtonWithDisabledTooltip = forwardRef<HTMLDivElement, ButtonWithDisabledTooltipProps>(\n ({disabledTooltip, disabled, children, disabledTooltipProps, fullWidth, ...others}, ref) =>\n disabledTooltip ? (\n <Tooltip label={disabledTooltip} disabled={!disabled} {...disabledTooltipProps}>\n <Box ref={ref} sx={{'&:hover': {cursor: 'not-allowed'}, width: fullWidth && '100%'}} {...others}>\n {children}\n </Box>\n </Tooltip>\n ) : (\n <>{children}</>\n )\n);\n\nexport const ButtonWithDisabledTooltip = createPolymorphicComponent<'div', ButtonWithDisabledTooltipProps>(\n _ButtonWithDisabledTooltip\n);\n"],"names":["ButtonWithDisabledTooltip","_ButtonWithDisabledTooltip","forwardRef","ref","disabledTooltip","disabled","children","disabledTooltipProps","fullWidth","others","Tooltip","label","Box","sx","cursor","width","createPolymorphicComponent"],"mappings":";;;;+BAsCaA;;;eAAAA;;;;;;;oBAtC4B;qBACL;qBAEK;AAsBzC,IAAMC,2CAA6BC,IAAAA,iBAAU,EACzC,iBAAoFC;QAAlFC,yBAAAA,iBAAiBC,kBAAAA,UAAUC,kBAAAA,UAAUC,8BAAAA,sBAAsBC,mBAAAA,WAAcC;QAAzEL;QAAiBC;QAAUC;QAAUC;QAAsBC;;WACzDJ,gCACI,qBAACM,aAAO;QAACC,OAAOP;QAAiBC,UAAU,CAACA;OAAcE;kBACtD,cAAA,qBAACK,SAAG;YAACT,KAAKA;YAAKU,IAAI;gBAAC,WAAW;oBAACC,QAAQ;gBAAa;gBAAGC,OAAOP,aAAa;YAAM;WAAOC;sBACpFH;;wBAIT;kBAAGA;;AACP;AAGD,IAAMN,4BAA4BgB,IAAAA,iCAA0B,EAC/Df"}
1
+ {"version":3,"sources":["../../../../src/components/button/ButtonWithDisabledTooltip.tsx"],"sourcesContent":["import {Box, Tooltip, TooltipProps} from '@mantine/core';\nimport {forwardRef, ReactNode} from 'react';\n\nimport {createPolymorphicComponent} from '../../utils';\n\nexport interface ButtonWithDisabledTooltipProps {\n /**\n * The tooltip message to display when disabled\n */\n disabledTooltip?: string;\n /**\n * Whether the button underneath the tooltip is disabled\n */\n disabled?: boolean;\n children?: ReactNode;\n /**\n * Additional tooltip props to set on the disabled button tooltip\n */\n disabledTooltipProps?: Omit<TooltipProps, 'disabled' | 'label' | 'children'>;\n /**\n * Sets button width to 100% of parent element\n */\n fullWidth?: boolean;\n}\n\nconst _ButtonWithDisabledTooltip = forwardRef<HTMLDivElement, ButtonWithDisabledTooltipProps>(\n ({disabledTooltip, disabled, children, disabledTooltipProps, fullWidth, ...others}, ref) =>\n disabledTooltip ? (\n <Tooltip label={disabledTooltip} disabled={!disabled} {...disabledTooltipProps}>\n <Box ref={ref} sx={{'&:hover': {cursor: 'not-allowed'}, width: fullWidth && '100%'}} {...others}>\n {children}\n </Box>\n </Tooltip>\n ) : (\n <>{children}</>\n ),\n);\n\nexport const ButtonWithDisabledTooltip = createPolymorphicComponent<'div', ButtonWithDisabledTooltipProps>(\n _ButtonWithDisabledTooltip,\n);\n"],"names":["ButtonWithDisabledTooltip","_ButtonWithDisabledTooltip","forwardRef","ref","disabledTooltip","disabled","children","disabledTooltipProps","fullWidth","others","Tooltip","label","Box","sx","cursor","width","createPolymorphicComponent"],"mappings":";;;;+BAsCaA;;;eAAAA;;;;;;;oBAtC4B;qBACL;qBAEK;AAsBzC,IAAMC,2CAA6BC,IAAAA,iBAAU,EACzC,iBAAoFC;QAAlFC,yBAAAA,iBAAiBC,kBAAAA,UAAUC,kBAAAA,UAAUC,8BAAAA,sBAAsBC,mBAAAA,WAAcC;QAAzEL;QAAiBC;QAAUC;QAAUC;QAAsBC;;WACzDJ,gCACI,qBAACM,aAAO;QAACC,OAAOP;QAAiBC,UAAU,CAACA;OAAcE;kBACtD,cAAA,qBAACK,SAAG;YAACT,KAAKA;YAAKU,IAAI;gBAAC,WAAW;oBAACC,QAAQ;gBAAa;gBAAGC,OAAOP,aAAa;YAAM;WAAOC;sBACpFH;;wBAIT;kBAAGA;;AACP;AAGD,IAAMN,4BAA4BgB,IAAAA,iCAA0B,EAC/Df"}
@@ -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":["Collection","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","getItemId","id","props","allowAdd","useComponentDefaultProps","value","onChange","onRemoveItem","onReorderItem","onInsertItem","children","newItem","label","labelProps","withAsterisk","description","descriptionProps","error","errorProps","classNames","className","styles","unstyled","others","useStyles","name","classes","cx","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","coordinateGetter","sortableKeyboardCoordinates","hasOnlyOneItem","length","useDidUpdate","JSON","stringify","isRequired","_label","Input","Label","_description","Description","_error","Error","_header","standardizedItems","map","item","index","String","data","items","CollectionItem","onRemove","removable","addAllowed","_addButton","Group","Tooltip","Box","Button","variant","leftIcon","AddSize16Px","height","onClick","getIndex","findIndex","handleDragEnd","over","active","activeIndex","overIndex","from","to","DndContext","onDragEnd","modifiers","restrictToVerticalAxis","restrictToParentElement","SortableContext","strategy","verticalListSortingStrategy","root","Stack"],"mappings":";;;;+BA0IaA;;;eAAAA;;;;;;;;gCA1Ia;oBACmE;yBAC/B;wBAC0B;qBAYjF;qBAEoB;sBAGN;yEACC;8BACO;AA0G7B,IAAMC,eAAkD;IACpDC,WAAW;IACXC,UAAU;IACVC,oBAAoB;IACpBC,UAAU;IACVC,SAAS;IACTC,UAAU;IACVC,WAAW;YAAEC,WAAAA;eAAaA;;AAC9B;AAEO,IAAMT,aAAa,SAAKU;QAqFRC;IApFnB,IA+BIC,4BAAAA,IAAAA,+BAAwB,EAAC,cAAcX,cAAoCS,QA9B3EG,QA8BAD,0BA9BAC,OACAC,WA6BAF,0BA7BAE,UACAC,eA4BAH,0BA5BAG,cACAC,gBA2BAJ,0BA3BAI,eACAC,eA0BAL,0BA1BAK,cACAZ,WAyBAO,0BAzBAP,UACAH,YAwBAU,0BAxBAV,WACAgB,WAuBAN,0BAvBAM,UACAZ,UAsBAM,0BAtBAN,SACAC,WAqBAK,0BArBAL,UACAY,UAoBAP,0BApBAO,SACAhB,WAmBAS,0BAnBAT,UACAC,qBAkBAQ,0BAlBAR,oBACAO,WAiBAC,0BAjBAD,UACAS,QAgBAR,0B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AAA;QAC1B,IAAID,MAAM;YACN,IAAME,cAAcL,SAASjB,OAAOqB,OAAOzE,EAAE;YAC7C,IAAM2E,YAAYN,SAASjB,OAAOoB,KAAKxE,EAAE;YACzC,IAAI0E,gBAAgBC,WAAW;oBAC3BpE;iBAAAA,iBAAAA,2BAAAA,qCAAAA,eAAgB;oBAACqE,MAAMF;oBAAaG,IAAIF;gBAAS;YACrD;QACJ;IACJ;IAEA,qBACI,qBAACG,gBAAU;QACPC,WAAWR;QACX5C,SAASA;QACTqD,WAAW;YAACC,iCAAsB;YAAEC,kCAAuB;SAAC;kBAE5D,cAAA,qBAACC,yBAAe;YAAC7B,OAAON;YAAmBoC,UAAUC,qCAA2B;sBAC5E,cAAA,sBAACvB,UAAG;gBAAC3C,WAAWO,GAAGD,QAAQ6D,IAAI,EAAEnE;eAAgBG;;oBAC5CyB;kCACD,sBAACwC,YAAK;wBAAC1F,SAASA;;4BACXyD;4BACAK;4BACAd;;;;;;;AAMzB"}
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":["Collection","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","spacing","required","getItemId","id","props","allowAdd","useComponentDefaultProps","value","onChange","onRemoveItem","onReorderItem","onInsertItem","children","newItem","label","labelProps","withAsterisk","description","descriptionProps","error","errorProps","classNames","className","styles","unstyled","others","useStyles","name","classes","cx","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","coordinateGetter","sortableKeyboardCoordinates","hasOnlyOneItem","length","useDidUpdate","JSON","stringify","isRequired","_label","Input","Label","_description","Description","_error","Error","_header","standardizedItems","map","item","index","String","data","items","CollectionItem","onRemove","removable","addAllowed","_addButton","Group","Tooltip","Box","Button","variant","leftIcon","AddSize16Px","height","onClick","getIndex","findIndex","handleDragEnd","over","active","activeIndex","overIndex","from","to","DndContext","onDragEnd","modifiers","restrictToVerticalAxis","restrictToParentElement","SortableContext","strategy","verticalListSortingStrategy","root","Stack"],"mappings":";;;;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;kCACD,sBAACwC,YAAK;wBAAC1F,SAASA;;4BACXyD;4BACAK;4BACAd;;;;;;;AAMzB"}
@@ -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 maxDropdownHeight={240}\n />\n );\n};\n"],"names":["DateRangePickerPresetSelect","presets","value","onChange","selectProps","selectData","Object","entries","map","val","label","getSelectedPreset","dayjs","unix","selected","find","id","range","isSame","useState","selectedPreset","setSelectedPreset","useEffect","newPreset","onChangePreset","presetId","Select","placeholder","data","maxDropdownHeight"],"mappings":";;;;+BAiBaA;;;eAAAA;;;;;;;;oBAjBiC;8DAC5B;qBACgB;AAe3B,IAAMA,8BAA8B;QACvCC,gBAAAA,SACAC,cAAAA,OACAC,iBAAAA,qCACAC,aAAAA,8CAAc,CAAC;IAEf,IAAMC,aAA2BC,OAAOC,OAAO,CAACN,SAASO,GAAG,CAAC;mDAAEC,iBAAK,AAACC,kBAAAA;eAAa;YAACR,OAAOO;YAAKC,OAAAA;QAAK;;IAEpG,IAAMC,oBAAoB;QACtB,IAAIT,KAAK,CAAC,EAAE,KAAK,QAAQA,KAAK,CAAC,EAAE,KAAK,QAAQU,IAAAA,cAAK,EAACV,KAAK,CAAC,EAAE,EAAEW,IAAI,OAAOD,IAAAA,cAAK,EAACV,KAAK,CAAC,EAAE,EAAEW,IAAI,IAAI;YAC7F,IAAMC,WAAWR,OAAOC,OAAO,CAACN,SAASc,IAAI,CACzC;2DAAEC,gBAAI,AAACC,kBAAAA;uBAAYL,IAAAA,cAAK,EAACK,KAAK,CAAC,EAAE,EAAGC,MAAM,CAAChB,KAAK,CAAC,EAAE,KAAKU,IAAAA,cAAK,EAACV,KAAK,CAAC,EAAE,EAAGgB,MAAM,CAAChB,KAAK,CAAC,EAAE;;YAE5F,IAAIY,UAAU;gBACV,OAAOA,QAAQ,CAAC,EAAE;YACtB;QACJ;QACA,OAAO;IACX;IAEA,IAA4CK,+BAAAA,IAAAA,eAAQ,EAAgBR,0BAA7DS,iBAAqCD,cAArBE,oBAAqBF;IAE5CG,IAAAA,gBAAS,EAAC;QACN,IAAMC,YAAYZ;QAClB,IAAIY,cAAcH,gBAAgB;YAC9BC,kBAAkBE;QACtB;IACJ,GAAG;QAACrB;KAAM;IAEV,IAAMsB,iBAAiB,SAACC;YAEpBtB;QADA,IAAMc,QAAQhB,OAAO,CAACwB,SAAS,CAACR,KAAK;SACrCd,YAAAA,sBAAAA,gCAAAA,UAAWc;IACf;IAEA,qBACI,qBAACS,YAAM;QACHhB,OAAM;QACNiB,aAAY;OACRvB;QACJF,OAAOkB;QACPjB,UAAUqB;QACVI,MAAMvB;QACNwB,mBAAmB;;AAG/B"}
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":["DateRangePickerPresetSelect","presets","value","onChange","selectProps","selectData","Object","entries","map","val","label","getSelectedPreset","dayjs","unix","selected","find","id","range","isSame","useState","selectedPreset","setSelectedPreset","useEffect","newPreset","onChangePreset","presetId","Select","placeholder","data","maxDropdownHeight"],"mappings":";;;;+BAiBaA;;;eAAAA;;;;;;;;oBAjBiC;8DAC5B;qBACgB;AAe3B,IAAMA,8BAA8B;QACvCC,gBAAAA,SACAC,cAAAA,OACAC,iBAAAA,qCACAC,aAAAA,8CAAc,CAAC;IAEf,IAAMC,aAA2BC,OAAOC,OAAO,CAACN,SAASO,GAAG,CAAC;mDAAEC,iBAAK,AAACC,kBAAAA;eAAa;YAACR,OAAOO;YAAKC,OAAAA;QAAK;;IAEpG,IAAMC,oBAAoB;QACtB,IAAIT,KAAK,CAAC,EAAE,KAAK,QAAQA,KAAK,CAAC,EAAE,KAAK,QAAQU,IAAAA,cAAK,EAACV,KAAK,CAAC,EAAE,EAAEW,IAAI,OAAOD,IAAAA,cAAK,EAACV,KAAK,CAAC,EAAE,EAAEW,IAAI,IAAI;YAC7F,IAAMC,WAAWR,OAAOC,OAAO,CAACN,SAASc,IAAI,CACzC;2DAAEC,gBAAI,AAACC,kBAAAA;uBAAYL,IAAAA,cAAK,EAACK,KAAK,CAAC,EAAE,EAAGC,MAAM,CAAChB,KAAK,CAAC,EAAE,KAAKU,IAAAA,cAAK,EAACV,KAAK,CAAC,EAAE,EAAGgB,MAAM,CAAChB,KAAK,CAAC,EAAE;;YAE5F,IAAIY,UAAU;gBACV,OAAOA,QAAQ,CAAC,EAAE;YACtB;QACJ;QACA,OAAO;IACX;IAEA,IAA4CK,+BAAAA,IAAAA,eAAQ,EAAgBR,0BAA7DS,iBAAqCD,cAArBE,oBAAqBF;IAE5CG,IAAAA,gBAAS,EAAC;QACN,IAAMC,YAAYZ;QAClB,IAAIY,cAAcH,gBAAgB;YAC9BC,kBAAkBE;QACtB;IACJ,GAAG;QAACrB;KAAM;IAEV,IAAMsB,iBAAiB,SAACC;YAEpBtB;QADA,IAAMc,QAAQhB,OAAO,CAACwB,SAAS,CAACR,KAAK;SACrCd,YAAAA,sBAAAA,gCAAAA,UAAWc;IACf;IAEA,qBACI,qBAACS,YAAM;QACHhB,OAAM;QACNiB,aAAY;OACRvB;QACJF,OAAOkB;QACPjB,UAAUqB;QACVI,MAAMvB;QACNwB,mBAAmB;;AAG/B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/header/Header.tsx"],"sourcesContent":["import {QuestionSize16Px} from '@coveord/plasma-react-icons';\nimport {Anchor, Breadcrumbs, DefaultProps, Divider, Group, Stack, Text, Title, Tooltip} from '@mantine/core';\nimport {Children, FunctionComponent, ReactElement, ReactNode} from 'react';\n\nexport interface HeaderProps extends DefaultProps {\n /**\n * The description text displayed inside the header underneath the title\n */\n description?: ReactNode;\n /**\n * Whether the header should have a border on the bottom\n */\n borderBottom?: boolean;\n /**\n * Use the modal variant when displaying the header inside a modal\n *\n * @default 'page'\n */\n variant?: 'page' | 'modal';\n /**\n * The title of the header.\n */\n children: ReactNode;\n}\n\ninterface HeaderType {\n (props: HeaderProps): ReactElement;\n Breadcrumbs: typeof HeaderBreadcrumbs;\n Actions: typeof HeaderActions;\n DocAnchor: typeof HeaderDocAnchor;\n}\n\nexport const Header: HeaderType = ({description, borderBottom, children, variant = 'page', ...others}) => {\n const convertedChildren = Children.toArray(children) as ReactElement[];\n const breadcrumbs = convertedChildren.find((child) => child.type === HeaderBreadcrumbs);\n const actions = convertedChildren.find((child) => child.type === HeaderActions);\n const docAnchor = convertedChildren.find((child) => child.type === HeaderDocAnchor);\n const otherChildren = convertedChildren.filter(\n (child) => child.type !== HeaderBreadcrumbs && child.type !== HeaderActions && child.type !== HeaderDocAnchor\n );\n return (\n <>\n <Group\n position=\"apart\"\n p={variant === 'page' ? 'xl' : undefined}\n pb={variant === 'page' ? 'lg' : undefined}\n {...others}\n >\n <Stack spacing={0}>\n {breadcrumbs}\n <Title\n order={variant === 'page' ? 1 : 3}\n color={variant === 'page' ? 'gray.5' : undefined}\n sx={{wordBreak: 'break-word'}}\n >\n {otherChildren}\n {docAnchor}\n </Title>\n <Text size={variant === 'page' ? 'md' : 'sm'} color=\"gray.6\">\n {description}\n </Text>\n </Stack>\n {actions}\n </Group>\n {borderBottom ? <Divider size=\"xs\" /> : null}\n </>\n );\n};\n\nconst HeaderBreadcrumbs: FunctionComponent<{children: ReactNode}> = ({children}) => (\n <Breadcrumbs\n styles={(theme) => ({\n breadcrumb: {fontSize: theme.fontSizes.sm, fontWeight: 300},\n separator: {color: theme.colors.gray[5]},\n })}\n >\n {children}\n </Breadcrumbs>\n);\n\nconst HeaderActions: FunctionComponent<{children: ReactNode}> = ({children}) => <Group spacing=\"sm\">{children}</Group>;\n\nexport interface HeaderDocAnchorProps {\n /**\n * A href pointing to documentation related to the current panel.\n * When provided, an info icon is rendered next to the title as link to this documentation\n */\n href: string;\n /**\n * The tooltip text shown when hovering over the doc link icon\n */\n label?: string;\n}\n\nconst HeaderDocAnchor: FunctionComponent<HeaderDocAnchorProps> = ({href: docLink, label: docLinkTooltipLabel}) => (\n <Tooltip label={docLinkTooltipLabel} disabled={!docLinkTooltipLabel} position=\"right\">\n <Anchor inline href={docLink} target=\"_blank\" ml=\"xs\" style={{verticalAlign: 'middle'}}>\n <QuestionSize16Px height={16} />\n </Anchor>\n </Tooltip>\n);\n\nHeader.Breadcrumbs = HeaderBreadcrumbs;\nHeader.Actions = HeaderActions;\nHeader.DocAnchor = HeaderDocAnchor;\n"],"names":["Header","description","borderBottom","children","variant","others","convertedChildren","Children","toArray","breadcrumbs","find","child","type","HeaderBreadcrumbs","actions","HeaderActions","docAnchor","HeaderDocAnchor","otherChildren","filter","Group","position","p","undefined","pb","Stack","spacing","Title","order","color","sx","wordBreak","Text","size","Divider","Breadcrumbs","styles","theme","breadcrumb","fontSize","fontSizes","sm","fontWeight","separator","colors","gray","href","docLink","label","docLinkTooltipLabel","Tooltip","disabled","Anchor","inline","target","ml","style","verticalAlign","QuestionSize16Px","height","Actions","DocAnchor"],"mappings":";;;;+BAgCaA;;;eAAAA;;;;;;;gCAhCkB;oBAC8D;qBAC1B;AA8B5D,IAAMA,SAAqB;QAAEC,qBAAAA,aAAaC,sBAAAA,cAAcC,kBAAAA,kCAAUC,SAAAA,sCAAU,yBAAWC;QAA1DJ;QAAaC;QAAcC;QAAUC;;IACrE,IAAME,oBAAoBC,eAAQ,CAACC,OAAO,CAACL;IAC3C,IAAMM,cAAcH,kBAAkBI,IAAI,CAAC,SAACC;eAAUA,MAAMC,IAAI,KAAKC;;IACrE,IAAMC,UAAUR,kBAAkBI,IAAI,CAAC,SAACC;eAAUA,MAAMC,IAAI,KAAKG;;IACjE,IAAMC,YAAYV,kBAAkBI,IAAI,CAAC,SAACC;eAAUA,MAAMC,IAAI,KAAKK;;IACnE,IAAMC,gBAAgBZ,kBAAkBa,MAAM,CAC1C,SAACR;eAAUA,MAAMC,IAAI,KAAKC,qBAAqBF,MAAMC,IAAI,KAAKG,iBAAiBJ,MAAMC,IAAI,KAAKK;;IAElG,qBACI;;0BACI,sBAACG,WAAK;gBACFC,UAAS;gBACTC,GAAGlB,YAAY,SAAS,OAAOmB;gBAC/BC,IAAIpB,YAAY,SAAS,OAAOmB;eAC5BlB;;kCAEJ,sBAACoB,WAAK;wBAACC,SAAS;;4BACXjB;0CACD,sBAACkB,WAAK;gCACFC,OAAOxB,YAAY,SAAS,IAAI;gCAChCyB,OAAOzB,YAAY,SAAS,WAAWmB;gCACvCO,IAAI;oCAACC,WAAW;gCAAY;;oCAE3Bb;oCACAF;;;0CAEL,qBAACgB,UAAI;gCAACC,MAAM7B,YAAY,SAAS,OAAO;gCAAMyB,OAAM;0CAC/C5B;;;;oBAGRa;;;YAEJZ,6BAAe,qBAACgC,aAAO;gBAACD,MAAK;iBAAU;;;AAGpD;AAEA,IAAMpB,oBAA8D;QAAEV,iBAAAA;yBAClE,qBAACgC,iBAAW;QACRC,QAAQ,SAACC;mBAAW;gBAChBC,YAAY;oBAACC,UAAUF,MAAMG,SAAS,CAACC,EAAE;oBAAEC,YAAY;gBAAG;gBAC1DC,WAAW;oBAACd,OAAOQ,MAAMO,MAAM,CAACC,IAAI,CAAC,EAAE;gBAAA;YAC3C;;kBAEC1C;;;AAIT,IAAMY,gBAA0D;QAAEZ,iBAAAA;yBAAc,qBAACiB,WAAK;QAACM,SAAQ;kBAAMvB;;;AAcrG,IAAMc,kBAA2D;QAAE6B,AAAMC,gBAAND,MAAeE,AAAOC,4BAAPD;yBAC9E,qBAACE,aAAO;QAACF,OAAOC;QAAqBE,UAAU,CAACF;QAAqB5B,UAAS;kBAC1E,cAAA,qBAAC+B,YAAM;YAACC,MAAM;YAACP,MAAMC;YAASO,QAAO;YAASC,IAAG;YAAKC,OAAO;gBAACC,eAAe;YAAQ;sBACjF,cAAA,qBAACC,kCAAgB;gBAACC,QAAQ;;;;;AAKtC3D,OAAOmC,WAAW,GAAGtB;AACrBb,OAAO4D,OAAO,GAAG7C;AACjBf,OAAO6D,SAAS,GAAG5C"}
1
+ {"version":3,"sources":["../../../../src/components/header/Header.tsx"],"sourcesContent":["import {QuestionSize16Px} from '@coveord/plasma-react-icons';\nimport {Anchor, Breadcrumbs, DefaultProps, Divider, Group, Stack, Text, Title, Tooltip} from '@mantine/core';\nimport {Children, FunctionComponent, ReactElement, ReactNode} from 'react';\n\nexport interface HeaderProps extends DefaultProps {\n /**\n * The description text displayed inside the header underneath the title\n */\n description?: ReactNode;\n /**\n * Whether the header should have a border on the bottom\n */\n borderBottom?: boolean;\n /**\n * Use the modal variant when displaying the header inside a modal\n *\n * @default 'page'\n */\n variant?: 'page' | 'modal';\n /**\n * The title of the header.\n */\n children: ReactNode;\n}\n\ninterface HeaderType {\n (props: HeaderProps): ReactElement;\n Breadcrumbs: typeof HeaderBreadcrumbs;\n Actions: typeof HeaderActions;\n DocAnchor: typeof HeaderDocAnchor;\n}\n\nexport const Header: HeaderType = ({description, borderBottom, children, variant = 'page', ...others}) => {\n const convertedChildren = Children.toArray(children) as ReactElement[];\n const breadcrumbs = convertedChildren.find((child) => child.type === HeaderBreadcrumbs);\n const actions = convertedChildren.find((child) => child.type === HeaderActions);\n const docAnchor = convertedChildren.find((child) => child.type === HeaderDocAnchor);\n const otherChildren = convertedChildren.filter(\n (child) => child.type !== HeaderBreadcrumbs && child.type !== HeaderActions && child.type !== HeaderDocAnchor,\n );\n return (\n <>\n <Group\n position=\"apart\"\n p={variant === 'page' ? 'xl' : undefined}\n pb={variant === 'page' ? 'lg' : undefined}\n {...others}\n >\n <Stack spacing={0}>\n {breadcrumbs}\n <Title\n order={variant === 'page' ? 1 : 3}\n color={variant === 'page' ? 'gray.5' : undefined}\n sx={{wordBreak: 'break-word'}}\n >\n {otherChildren}\n {docAnchor}\n </Title>\n <Text size={variant === 'page' ? 'md' : 'sm'} color=\"gray.6\">\n {description}\n </Text>\n </Stack>\n {actions}\n </Group>\n {borderBottom ? <Divider size=\"xs\" /> : null}\n </>\n );\n};\n\nconst HeaderBreadcrumbs: FunctionComponent<{children: ReactNode}> = ({children}) => (\n <Breadcrumbs\n styles={(theme) => ({\n breadcrumb: {fontSize: theme.fontSizes.sm, fontWeight: 300},\n separator: {color: theme.colors.gray[5]},\n })}\n >\n {children}\n </Breadcrumbs>\n);\n\nconst HeaderActions: FunctionComponent<{children: ReactNode}> = ({children}) => <Group spacing=\"sm\">{children}</Group>;\n\nexport interface HeaderDocAnchorProps {\n /**\n * A href pointing to documentation related to the current panel.\n * When provided, an info icon is rendered next to the title as link to this documentation\n */\n href: string;\n /**\n * The tooltip text shown when hovering over the doc link icon\n */\n label?: string;\n}\n\nconst HeaderDocAnchor: FunctionComponent<HeaderDocAnchorProps> = ({href: docLink, label: docLinkTooltipLabel}) => (\n <Tooltip label={docLinkTooltipLabel} disabled={!docLinkTooltipLabel} position=\"right\">\n <Anchor inline href={docLink} target=\"_blank\" ml=\"xs\" style={{verticalAlign: 'middle'}}>\n <QuestionSize16Px height={16} />\n </Anchor>\n </Tooltip>\n);\n\nHeader.Breadcrumbs = HeaderBreadcrumbs;\nHeader.Actions = HeaderActions;\nHeader.DocAnchor = HeaderDocAnchor;\n"],"names":["Header","description","borderBottom","children","variant","others","convertedChildren","Children","toArray","breadcrumbs","find","child","type","HeaderBreadcrumbs","actions","HeaderActions","docAnchor","HeaderDocAnchor","otherChildren","filter","Group","position","p","undefined","pb","Stack","spacing","Title","order","color","sx","wordBreak","Text","size","Divider","Breadcrumbs","styles","theme","breadcrumb","fontSize","fontSizes","sm","fontWeight","separator","colors","gray","href","docLink","label","docLinkTooltipLabel","Tooltip","disabled","Anchor","inline","target","ml","style","verticalAlign","QuestionSize16Px","height","Actions","DocAnchor"],"mappings":";;;;+BAgCaA;;;eAAAA;;;;;;;gCAhCkB;oBAC8D;qBAC1B;AA8B5D,IAAMA,SAAqB;QAAEC,qBAAAA,aAAaC,sBAAAA,cAAcC,kBAAAA,kCAAUC,SAAAA,sCAAU,yBAAWC;QAA1DJ;QAAaC;QAAcC;QAAUC;;IACrE,IAAME,oBAAoBC,eAAQ,CAACC,OAAO,CAACL;IAC3C,IAAMM,cAAcH,kBAAkBI,IAAI,CAAC,SAACC;eAAUA,MAAMC,IAAI,KAAKC;;IACrE,IAAMC,UAAUR,kBAAkBI,IAAI,CAAC,SAACC;eAAUA,MAAMC,IAAI,KAAKG;;IACjE,IAAMC,YAAYV,kBAAkBI,IAAI,CAAC,SAACC;eAAUA,MAAMC,IAAI,KAAKK;;IACnE,IAAMC,gBAAgBZ,kBAAkBa,MAAM,CAC1C,SAACR;eAAUA,MAAMC,IAAI,KAAKC,qBAAqBF,MAAMC,IAAI,KAAKG,iBAAiBJ,MAAMC,IAAI,KAAKK;;IAElG,qBACI;;0BACI,sBAACG,WAAK;gBACFC,UAAS;gBACTC,GAAGlB,YAAY,SAAS,OAAOmB;gBAC/BC,IAAIpB,YAAY,SAAS,OAAOmB;eAC5BlB;;kCAEJ,sBAACoB,WAAK;wBAACC,SAAS;;4BACXjB;0CACD,sBAACkB,WAAK;gCACFC,OAAOxB,YAAY,SAAS,IAAI;gCAChCyB,OAAOzB,YAAY,SAAS,WAAWmB;gCACvCO,IAAI;oCAACC,WAAW;gCAAY;;oCAE3Bb;oCACAF;;;0CAEL,qBAACgB,UAAI;gCAACC,MAAM7B,YAAY,SAAS,OAAO;gCAAMyB,OAAM;0CAC/C5B;;;;oBAGRa;;;YAEJZ,6BAAe,qBAACgC,aAAO;gBAACD,MAAK;iBAAU;;;AAGpD;AAEA,IAAMpB,oBAA8D;QAAEV,iBAAAA;yBAClE,qBAACgC,iBAAW;QACRC,QAAQ,SAACC;mBAAW;gBAChBC,YAAY;oBAACC,UAAUF,MAAMG,SAAS,CAACC,EAAE;oBAAEC,YAAY;gBAAG;gBAC1DC,WAAW;oBAACd,OAAOQ,MAAMO,MAAM,CAACC,IAAI,CAAC,EAAE;gBAAA;YAC3C;;kBAEC1C;;;AAIT,IAAMY,gBAA0D;QAAEZ,iBAAAA;yBAAc,qBAACiB,WAAK;QAACM,SAAQ;kBAAMvB;;;AAcrG,IAAMc,kBAA2D;QAAE6B,AAAMC,gBAAND,MAAeE,AAAOC,4BAAPD;yBAC9E,qBAACE,aAAO;QAACF,OAAOC;QAAqBE,UAAU,CAACF;QAAqB5B,UAAS;kBAC1E,cAAA,qBAAC+B,YAAM;YAACC,MAAM;YAACP,MAAMC;YAASO,QAAO;YAASC,IAAG;YAAKC,OAAO;gBAACC,eAAe;YAAQ;sBACjF,cAAA,qBAACC,kCAAgB;gBAACC,QAAQ;;;;;AAKtC3D,OAAOmC,WAAW,GAAGtB;AACrBb,OAAO4D,OAAO,GAAG7C;AACjBf,OAAO6D,SAAS,GAAG5C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/inline-confirm/InlineConfirm.tsx"],"sourcesContent":["import {Children, FunctionComponent, PropsWithChildren, ReactElement, useState} from 'react';\n\nimport {InlineConfirmButton} from './InlineConfirmButton';\nimport {InlineConfirmContext} from './InlineConfirmContext';\nimport {InlineConfirmMenuItem} from './InlineConfirmMenuItem';\nimport {InlineConfirmPrompt} from './InlineConfirmPrompt';\n\ntype InlineConfirmType = FunctionComponent<PropsWithChildren> & {\n Prompt: typeof InlineConfirmPrompt;\n Button: typeof InlineConfirmButton;\n MenuItem: typeof InlineConfirmMenuItem;\n};\n\nexport const InlineConfirm: InlineConfirmType = ({children}) => {\n const [confirmingId, setConfirmingId] = useState<string | null>(null);\n\n const convertedChildren = Children.toArray(children) as ReactElement[];\n const prompt = convertedChildren.find(\n (child) => child.type === InlineConfirmPrompt && child.props.id === confirmingId\n );\n const clearConfirm = () => setConfirmingId(null);\n\n return (\n <InlineConfirmContext.Provider value={{confirmingId, setConfirmingId, clearConfirm}}>\n {prompt ?? children}\n </InlineConfirmContext.Provider>\n );\n};\n\nInlineConfirm.Prompt = InlineConfirmPrompt;\nInlineConfirm.Button = InlineConfirmButton;\nInlineConfirm.MenuItem = InlineConfirmMenuItem;\n"],"names":["InlineConfirm","children","useState","confirmingId","setConfirmingId","convertedChildren","Children","toArray","prompt","find","child","type","InlineConfirmPrompt","props","id","clearConfirm","InlineConfirmContext","Provider","value","Prompt","Button","InlineConfirmButton","MenuItem","InlineConfirmMenuItem"],"mappings":";;;;+BAaaA;;;eAAAA;;;;;qBAbwE;mCAEnD;oCACC;qCACC;mCACF;AAQ3B,IAAMA,gBAAmC;QAAEC,iBAAAA;IAC9C,IAAwCC,+BAAAA,IAAAA,eAAQ,EAAgB,WAAzDC,eAAiCD,cAAnBE,kBAAmBF;IAExC,IAAMG,oBAAoBC,eAAQ,CAACC,OAAO,CAACN;IAC3C,IAAMO,SAASH,kBAAkBI,IAAI,CACjC,SAACC;eAAUA,MAAMC,IAAI,KAAKC,wCAAmB,IAAIF,MAAMG,KAAK,CAACC,EAAE,KAAKX;;IAExE,IAAMY,eAAe;eAAMX,gBAAgB;;IAE3C,qBACI,qBAACY,0CAAoB,CAACC,QAAQ;QAACC,OAAO;YAACf,cAAAA;YAAcC,iBAAAA;YAAiBW,cAAAA;QAAY;kBAC7EP,mBAAAA,oBAAAA,SAAUP;;AAGvB;AAEAD,cAAcmB,MAAM,GAAGP,wCAAmB;AAC1CZ,cAAcoB,MAAM,GAAGC,wCAAmB;AAC1CrB,cAAcsB,QAAQ,GAAGC,4CAAqB"}
1
+ {"version":3,"sources":["../../../../src/components/inline-confirm/InlineConfirm.tsx"],"sourcesContent":["import {Children, FunctionComponent, PropsWithChildren, ReactElement, useState} from 'react';\n\nimport {InlineConfirmButton} from './InlineConfirmButton';\nimport {InlineConfirmContext} from './InlineConfirmContext';\nimport {InlineConfirmMenuItem} from './InlineConfirmMenuItem';\nimport {InlineConfirmPrompt} from './InlineConfirmPrompt';\n\ntype InlineConfirmType = FunctionComponent<PropsWithChildren> & {\n Prompt: typeof InlineConfirmPrompt;\n Button: typeof InlineConfirmButton;\n MenuItem: typeof InlineConfirmMenuItem;\n};\n\nexport const InlineConfirm: InlineConfirmType = ({children}) => {\n const [confirmingId, setConfirmingId] = useState<string | null>(null);\n\n const convertedChildren = Children.toArray(children) as ReactElement[];\n const prompt = convertedChildren.find(\n (child) => child.type === InlineConfirmPrompt && child.props.id === confirmingId,\n );\n const clearConfirm = () => setConfirmingId(null);\n\n return (\n <InlineConfirmContext.Provider value={{confirmingId, setConfirmingId, clearConfirm}}>\n {prompt ?? children}\n </InlineConfirmContext.Provider>\n );\n};\n\nInlineConfirm.Prompt = InlineConfirmPrompt;\nInlineConfirm.Button = InlineConfirmButton;\nInlineConfirm.MenuItem = InlineConfirmMenuItem;\n"],"names":["InlineConfirm","children","useState","confirmingId","setConfirmingId","convertedChildren","Children","toArray","prompt","find","child","type","InlineConfirmPrompt","props","id","clearConfirm","InlineConfirmContext","Provider","value","Prompt","Button","InlineConfirmButton","MenuItem","InlineConfirmMenuItem"],"mappings":";;;;+BAaaA;;;eAAAA;;;;;qBAbwE;mCAEnD;oCACC;qCACC;mCACF;AAQ3B,IAAMA,gBAAmC;QAAEC,iBAAAA;IAC9C,IAAwCC,+BAAAA,IAAAA,eAAQ,EAAgB,WAAzDC,eAAiCD,cAAnBE,kBAAmBF;IAExC,IAAMG,oBAAoBC,eAAQ,CAACC,OAAO,CAACN;IAC3C,IAAMO,SAASH,kBAAkBI,IAAI,CACjC,SAACC;eAAUA,MAAMC,IAAI,KAAKC,wCAAmB,IAAIF,MAAMG,KAAK,CAACC,EAAE,KAAKX;;IAExE,IAAMY,eAAe;eAAMX,gBAAgB;;IAE3C,qBACI,qBAACY,0CAAoB,CAACC,QAAQ;QAACC,OAAO;YAACf,cAAAA;YAAcC,iBAAAA;YAAiBW,cAAAA;QAAY;kBAC7EP,mBAAAA,oBAAAA,SAAUP;;AAGvB;AAEAD,cAAcmB,MAAM,GAAGP,wCAAmB;AAC1CZ,cAAcoB,MAAM,GAAGC,wCAAmB;AAC1CrB,cAAcsB,QAAQ,GAAGC,4CAAqB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/inline-confirm/InlineConfirmButton.tsx"],"sourcesContent":["import {Button} from '@mantine/core';\nimport {forwardRef, MouseEventHandler} from 'react';\n\nimport {ButtonProps} from '../button';\nimport {useInlineConfirm} from './useInlineConfirm';\n\nexport interface InlineConfirmButtonProps extends ButtonProps {\n id: string;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n}\n\nexport const InlineConfirmButton = forwardRef<HTMLButtonElement, InlineConfirmButtonProps>(\n ({onClick, id, ...others}, ref) => {\n const {setConfirmingId} = useInlineConfirm();\n const handleOnClick: MouseEventHandler<HTMLButtonElement> = (e) => {\n setConfirmingId(id);\n onClick?.(e);\n };\n\n return <Button ref={ref} onClick={handleOnClick} {...others} />;\n }\n);\n"],"names":["InlineConfirmButton","forwardRef","ref","onClick","id","others","setConfirmingId","useInlineConfirm","handleOnClick","e","Button"],"mappings":";;;;+BAWaA;;;eAAAA;;;;;;oBAXQ;qBACuB;gCAGb;AAOxB,IAAMA,oCAAsBC,IAAAA,iBAAU,EACzC,iBAA2BC;QAAzBC,iBAAAA,SAASC,YAAAA,IAAOC;QAAhBF;QAASC;;IACP,IAAM,AAACE,kBAAmBC,IAAAA,kCAAgB,IAAnCD;IACP,IAAME,gBAAsD,SAACC;YAEzDN;QADAG,gBAAgBF;SAChBD,WAAAA,qBAAAA,+BAAAA,SAAUM;IACd;IAEA,qBAAO,qBAACC,YAAM;QAACR,KAAKA;QAAKC,SAASK;OAAmBH;AACzD"}
1
+ {"version":3,"sources":["../../../../src/components/inline-confirm/InlineConfirmButton.tsx"],"sourcesContent":["import {Button} from '@mantine/core';\nimport {forwardRef, MouseEventHandler} from 'react';\n\nimport {ButtonProps} from '../button';\nimport {useInlineConfirm} from './useInlineConfirm';\n\nexport interface InlineConfirmButtonProps extends ButtonProps {\n id: string;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n}\n\nexport const InlineConfirmButton = forwardRef<HTMLButtonElement, InlineConfirmButtonProps>(\n ({onClick, id, ...others}, ref) => {\n const {setConfirmingId} = useInlineConfirm();\n const handleOnClick: MouseEventHandler<HTMLButtonElement> = (e) => {\n setConfirmingId(id);\n onClick?.(e);\n };\n\n return <Button ref={ref} onClick={handleOnClick} {...others} />;\n },\n);\n"],"names":["InlineConfirmButton","forwardRef","ref","onClick","id","others","setConfirmingId","useInlineConfirm","handleOnClick","e","Button"],"mappings":";;;;+BAWaA;;;eAAAA;;;;;;oBAXQ;qBACuB;gCAGb;AAOxB,IAAMA,oCAAsBC,IAAAA,iBAAU,EACzC,iBAA2BC;QAAzBC,iBAAAA,SAASC,YAAAA,IAAOC;QAAhBF;QAASC;;IACP,IAAM,AAACE,kBAAmBC,IAAAA,kCAAgB,IAAnCD;IACP,IAAME,gBAAsD,SAACC;YAEzDN;QADAG,gBAAgBF;SAChBD,WAAAA,qBAAAA,+BAAAA,SAAUM;IACd;IAEA,qBAAO,qBAACC,YAAM;QAACR,KAAKA;QAAKC,SAASK;OAAmBH;AACzD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/inline-confirm/InlineConfirmMenuItem.tsx"],"sourcesContent":["import {forwardRef, MouseEventHandler} from 'react';\n\nimport {Menu, MenuItemProps} from '../menu';\nimport {useInlineConfirm} from './useInlineConfirm';\n\nexport interface InlineConfirmMenuItemProps extends MenuItemProps {\n id: string;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n}\n\nexport const InlineConfirmMenuItem = forwardRef<HTMLButtonElement, InlineConfirmMenuItemProps>(\n ({onClick, id, ...others}, ref) => {\n const {setConfirmingId} = useInlineConfirm();\n const handleOnClick: MouseEventHandler<HTMLButtonElement> = (e) => {\n setConfirmingId(id);\n onClick?.(e);\n };\n\n return <Menu.Item ref={ref} onClick={handleOnClick} {...others} />;\n }\n);\n"],"names":["InlineConfirmMenuItem","forwardRef","ref","onClick","id","others","setConfirmingId","useInlineConfirm","handleOnClick","e","Menu","Item"],"mappings":";;;;+BAUaA;;;eAAAA;;;;;;qBAV+B;oBAEV;gCACH;AAOxB,IAAMA,sCAAwBC,IAAAA,iBAAU,EAC3C,iBAA2BC;QAAzBC,iBAAAA,SAASC,YAAAA,IAAOC;QAAhBF;QAASC;;IACP,IAAM,AAACE,kBAAmBC,IAAAA,kCAAgB,IAAnCD;IACP,IAAME,gBAAsD,SAACC;YAEzDN;QADAG,gBAAgBF;SAChBD,WAAAA,qBAAAA,+BAAAA,SAAUM;IACd;IAEA,qBAAO,qBAACC,UAAI,CAACC,IAAI;QAACT,KAAKA;QAAKC,SAASK;OAAmBH;AAC5D"}
1
+ {"version":3,"sources":["../../../../src/components/inline-confirm/InlineConfirmMenuItem.tsx"],"sourcesContent":["import {forwardRef, MouseEventHandler} from 'react';\n\nimport {Menu, MenuItemProps} from '../menu';\nimport {useInlineConfirm} from './useInlineConfirm';\n\nexport interface InlineConfirmMenuItemProps extends MenuItemProps {\n id: string;\n onClick?: MouseEventHandler<HTMLButtonElement>;\n}\n\nexport const InlineConfirmMenuItem = forwardRef<HTMLButtonElement, InlineConfirmMenuItemProps>(\n ({onClick, id, ...others}, ref) => {\n const {setConfirmingId} = useInlineConfirm();\n const handleOnClick: MouseEventHandler<HTMLButtonElement> = (e) => {\n setConfirmingId(id);\n onClick?.(e);\n };\n\n return <Menu.Item ref={ref} onClick={handleOnClick} {...others} />;\n },\n);\n"],"names":["InlineConfirmMenuItem","forwardRef","ref","onClick","id","others","setConfirmingId","useInlineConfirm","handleOnClick","e","Menu","Item"],"mappings":";;;;+BAUaA;;;eAAAA;;;;;;qBAV+B;oBAEV;gCACH;AAOxB,IAAMA,sCAAwBC,IAAAA,iBAAU,EAC3C,iBAA2BC;QAAzBC,iBAAAA,SAASC,YAAAA,IAAOC;QAAhBF;QAASC;;IACP,IAAM,AAACE,kBAAmBC,IAAAA,kCAAgB,IAAnCD;IACP,IAAME,gBAAsD,SAACC;YAEzDN;QADAG,gBAAgBF;SAChBD,WAAAA,qBAAAA,+BAAAA,SAAUM;IACd;IAEA,qBAAO,qBAACC,UAAI,CAACC,IAAI;QAACT,KAAKA;QAAKC,SAASK;OAAmBH;AAC5D"}
@@ -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","_MenuItem","forwardRef","ref","disabledTooltip","disabled","disabledTooltipProps","others","ButtonWithDisabledTooltip","MantineMenu","Item","MenuItem","createPolymorphicComponent","overrideComponent","displayName"],"mappings":";;;;+BAuBaA;;;eAAAA;;;;;;oBAvB4D;qBAChD;qBAEmC;yCAEpB;AAIxC,IAAMC,0BAAYC,IAAAA,iBAAU,EACxB,iBAA+DC;QAA7DC,yBAAAA,iBAAiBC,kBAAAA,UAAUC,8BAAAA,sBAAyBC;QAApDH;QAAiBC;QAAUC;;WACzB,qBAACE,oDAAyB;QACtBH,UAAUA;QACVD,iBAAiBA;QACjBE,sBAAsBA;kBAEtB,cAAA,qBAACG,UAAW,CAACC,IAAI;YAACP,KAAKA;YAAKE,UAAUA;WAAcE;;AAC7B;AAInC,IAAMI,WAAWC,IAAAA,iCAA0B,EAA0BX;AAE9D,IAAMD,OAAOa,IAAAA,wBAAiB,EAACJ,UAAW,EAAE;IAC/CK,aAAa;IACbJ,MAAMC;AACV"}
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","_MenuItem","forwardRef","ref","disabledTooltip","disabled","disabledTooltipProps","others","ButtonWithDisabledTooltip","MantineMenu","Item","MenuItem","createPolymorphicComponent","overrideComponent","displayName"],"mappings":";;;;+BAuBaA;;;eAAAA;;;;;;oBAvB4D;qBAChD;qBAEmC;yCAEpB;AAIxC,IAAMC,0BAAYC,IAAAA,iBAAU,EACxB,iBAA+DC;QAA7DC,yBAAAA,iBAAiBC,kBAAAA,UAAUC,8BAAAA,sBAAyBC;QAApDH;QAAiBC;QAAUC;;WACzB,qBAACE,oDAAyB;QACtBH,UAAUA;QACVD,iBAAiBA;QACjBE,sBAAsBA;kBAEtB,cAAA,qBAACG,UAAW,CAACC,IAAI;YAACP,KAAKA;YAAKE,UAAUA;WAAcE;;AAC7B;AAInC,IAAMI,WAAWC,IAAAA,iCAA0B,EAA0BX;AAE9D,IAAMD,OAAOa,IAAAA,wBAAiB,EAACJ,UAAW,EAAE;IAC/CK,aAAa;IACbJ,MAAMC;AACV"}
@@ -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":["ModalWizard","useStyles","createStyles","content","display","flexDirection","body","flex","cancelButtonLabel","nextButtonLabel","previousButtonLabel","finishButtonLabel","opened","onNext","onPrevious","onClose","onFinish","isDirty","handleDirtyState","classNames","styles","unstyled","children","isStepValidatedOnNext","modalProps","currentStep","name","classes","cx","useState","currentStepIndex","setCurrentStepIndex","modalSteps","Children","toArray","filter","child","type","ModalWizardStep","numberOfSteps","length","isFirstStep","isLastStep","step","index","isValid","props","validateStep","useEffect","handleClose","confirmDirty","isModalDirty","discardChanges","resolveStepDependentProp","prop","getProgress","useMemo","currStepIndex","totalNumberOfSteps","countsAsProgress","numberOfCompletedSteps","Modal","centered","withCloseButton","padding","Header","p","pr","variant","description","borderBottom","showProgressBar","DocAnchor","href","label","Actions","CloseButton","aria-label","onClick","Progress","color","size","radius","value","Box","sx","marginTop","StickyFooter","borderTop","Button","disabled","Step"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AoBE;;sCAGvC,qBAAC+E,cAAM;4BACHC,UAAU,CAAC7C;4BACXiC,SAAS;gCACL,IAAIpC,YAAY;wCACZ1B;wCAAAA;oCAAAA,CAAAA,cAAAA,YAAAA,sBAAAA,gCAAAA,yBAAAA,wBAAAA,aAAgBiC,YAAY;gCAChC,OAAO;wCACHpC;qCAAAA,UAAAA,oBAAAA,8BAAAA,QAASiB,mBAAmB,GAAGC;oCAE/B,IAAI,CAACR,uBAAuB;wCACxBQ,oBAAoBD,mBAAmB;oCAC3C;gCACJ;4BACJ;sCAECY,aAAa/B,oBAAoBF;;;;;;;AAM1D;AAEAT,YAAY2F,IAAI,GAAGrD,gCAAe"}
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":["ModalWizard","useStyles","createStyles","content","display","flexDirection","body","flex","cancelButtonLabel","nextButtonLabel","previousButtonLabel","finishButtonLabel","opened","onNext","onPrevious","onClose","onFinish","isDirty","handleDirtyState","classNames","styles","unstyled","children","isStepValidatedOnNext","modalProps","currentStep","name","classes","cx","useState","currentStepIndex","setCurrentStepIndex","modalSteps","Children","toArray","filter","child","type","ModalWizardStep","numberOfSteps","length","isFirstStep","isLastStep","step","index","isValid","props","validateStep","useEffect","handleClose","confirmDirty","isModalDirty","discardChanges","resolveStepDependentProp","prop","getProgress","useMemo","currStepIndex","totalNumberOfSteps","countsAsProgress","numberOfCompletedSteps","Modal","centered","withCloseButton","padding","Header","p","pr","variant","description","borderBottom","showProgressBar","DocAnchor","href","label","Actions","CloseButton","aria-label","onClick","Progress","color","size","radius","value","Box","sx","marginTop","StickyFooter","borderTop","Button","disabled","Step"],"mappings":";;;;+BAoGaA;;;eAAAA;;;;;;;;oBApGsF;qBAChC;sBAE9C;sBACA;4BACM;+BACsC;AAEjE,IAAMC,YAAYC,IAAAA,kBAAY,EAAC;WAAO;QAClCC,SAAS;YACLC,SAAS;YACTC,eAAe;QACnB;QACAC,MAAM;YACFC,MAAM;YACNH,SAAS;YACTC,eAAe;QACnB;IACJ;;AAkFO,IAAML,cAA+B;0CACxCQ,mBAAAA,0DAAoB,qEACpBC,iBAAAA,sDAAkB,qEAClBC,qBAAAA,8DAAsB,2EACtBC,mBAAAA,0DAAoB,qC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AoBF;;;;;;;AAM1D;AAEAT,YAAY2F,IAAI,GAAGrD,gCAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"RowLayout.d.ts","sourceRoot":"","sources":["../../../../../src/components/table/layouts/RowLayout.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAC,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AA+L7D,eAAO,MAAM,SAAS,EAAE,WAKvB,CAAC"}
1
+ {"version":3,"file":"RowLayout.d.ts","sourceRoot":"","sources":["../../../../../src/components/table/layouts/RowLayout.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAC,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AAgM7D,eAAO,MAAM,SAAS,EAAE,WAKvB,CAAC"}
@@ -156,7 +156,8 @@ var RowLayoutBody = function(param) {
156
156
  style: {
157
157
  width: (_columnSizing_size = columnSizing.size) !== null && _columnSizing_size !== void 0 ? _columnSizing_size : "auto",
158
158
  minWidth: columnSizing.minSize,
159
- maxWidth: columnSizing.maxSize
159
+ maxWidth: columnSizing.maxSize,
160
+ overflowWrap: "break-word"
160
161
  },
161
162
  className: cx(classes.cell, _define_property._({}, classes.rowCollapsibleButtonCell, cell.column.id === _TableCollapsibleColumn.TableCollapsibleColumn.id)),
162
163
  onClick: onCollapsibleCellClick,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/table/layouts/RowLayout.tsx"],"sourcesContent":["import {ListSize16Px} from '@coveord/plasma-react-icons';\nimport {Box, Collapse, createStyles, rem} from '@mantine/core';\nimport {flexRender} from '@tanstack/react-table';\nimport {defaultColumnSizing} from '@tanstack/table-core';\nimport {Fragment, type MouseEvent} from 'react';\nimport {TableLayout, TableLayoutProps} from '../Table.types';\nimport {TableCollapsibleColumn} from '../TableCollapsibleColumn';\nimport {useTable} from '../TableContext';\nimport {TableLoading} from '../TableLoading';\nimport {TableSelectableColumn} from '../TableSelectableColumn';\nimport {Th} from '../Th';\n\ninterface TableStylesParams {\n multiRowSelectionEnabled: boolean;\n disableRowSelection: boolean;\n}\n\nconst useStyles = createStyles<string, TableStylesParams>((theme, {multiRowSelectionEnabled, disableRowSelection}) => {\n const rowBackgroundColor =\n theme.colorScheme === 'dark' ? theme.fn.rgba(theme.colors[theme.primaryColor][7], 0.2) : theme.colors.gray[1];\n const border = `${rem(1)} solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`;\n return {\n headerColumns: {\n '& th:first-of-type > *': {\n paddingLeft: '40px',\n },\n\n '& input[type=checkbox]': {\n backgroundColor: disableRowSelection ? `${theme.colors.gray[2]}` : undefined,\n borderColor: disableRowSelection ? `${theme.colors.gray[3]}` : `${theme.colors.gray[4]}`,\n pointerEvents: disableRowSelection ? 'none' : 'auto',\n cursor: disableRowSelection ? 'not-allowed' : 'default',\n\n '& + svg': {\n color: disableRowSelection ? `${theme.colors.gray[5]}` : 'inherit',\n },\n },\n },\n\n rowSelected: {\n backgroundColor: multiRowSelectionEnabled ? undefined : rowBackgroundColor,\n },\n\n rowUnselectable: {\n '& input[type=checkbox]': {\n backgroundColor: `${theme.colors.gray[2]}`,\n borderColor: `${theme.colors.gray[3]}`,\n pointerEvents: 'none',\n cursor: 'not-allowed',\n\n '&:checked + svg': {\n color: `${theme.colors.gray[5]}`,\n },\n },\n },\n\n rowCollapsibleButtonCell: {\n textAlign: 'right',\n padding: `calc(${theme.spacing.xs}/2) ${theme.spacing.sm} !important`,\n },\n\n row: {\n '& td:first-of-type': {\n paddingLeft: '40px',\n },\n '&:hover': {\n backgroundColor: rowBackgroundColor,\n },\n },\n\n cell: {\n verticalAlign: 'middle',\n // We must use height instead of minHeight here, otherwise it doesn't apply\n height: '56px',\n padding: `${theme.spacing.xs} ${theme.spacing.sm}`,\n borderBottom: border,\n },\n\n collapsible: {\n backgroundColor: rowBackgroundColor,\n borderBottom: border,\n },\n };\n});\n\nconst RowLayoutHeader = <T,>({table}: TableLayoutProps<T>) => {\n const {multiRowSelectionEnabled, disableRowSelection} = useTable();\n const {classes} = useStyles({disableRowSelection, multiRowSelectionEnabled});\n const headers = table.getHeaderGroups().map((headerGroup) => (\n <tr key={headerGroup.id} className={classes.headerColumns}>\n {headerGroup.headers.map((columnHeader) => (\n <Th key={columnHeader.id} header={columnHeader} />\n ))}\n </tr>\n ));\n return <>{headers}</>;\n};\n\nconst RowLayoutBody = <T,>({\n table,\n doubleClickAction,\n getExpandChildren,\n loading,\n keepSelection,\n}: TableLayoutProps<T>) => {\n const {multiRowSelectionEnabled, disableRowSelection} = useTable();\n const {classes, cx} = useStyles({disableRowSelection, multiRowSelectionEnabled});\n\n const toggleCollapsible = (el: HTMLTableRowElement) => {\n const cell = el.children[el.children.length - 1] as HTMLTableCellElement;\n cell.querySelector('button').click();\n };\n\n const rows = table.getRowModel().rows.map((row) => {\n const rowChildren = getExpandChildren?.(row.original) ?? null;\n const isSelected = !!row.getIsSelected();\n const shouldKeepSelection = keepSelection && isSelected;\n const onClick = (event: MouseEvent<HTMLTableRowElement>) => {\n if (rowChildren) {\n toggleCollapsible(event.currentTarget);\n }\n if (!disableRowSelection && !multiRowSelectionEnabled && !shouldKeepSelection) {\n row.toggleSelected();\n }\n };\n\n return (\n <Fragment key={row.id}>\n <tr\n onClick={onClick}\n onDoubleClick={() => doubleClickAction?.(row.original)}\n className={cx(classes.row, {\n [classes.rowSelected]: isSelected,\n [classes.rowUnselectable]: disableRowSelection,\n })}\n aria-selected={isSelected}\n data-testid={row.id}\n >\n {row.getVisibleCells().map((cell) => {\n const columnSizing = {\n ...defaultColumnSizing,\n size: cell.column.columnDef.size,\n minSize: cell.column.columnDef.minSize,\n maxSize: cell.column.columnDef.maxSize,\n };\n\n const onCollapsibleCellClick = (event: MouseEvent<HTMLTableCellElement>) => {\n if (cell.column.id === TableSelectableColumn.id && !disableRowSelection) {\n event.stopPropagation();\n row.getToggleSelectedHandler();\n }\n };\n return (\n <td\n key={cell.id}\n data-testid={cell.id}\n style={{\n width: columnSizing.size ?? 'auto',\n minWidth: columnSizing.minSize,\n maxWidth: columnSizing.maxSize,\n }}\n className={cx(classes.cell, {\n [classes.rowCollapsibleButtonCell]: cell.column.id === TableCollapsibleColumn.id,\n })}\n onClick={onCollapsibleCellClick}\n >\n <TableLoading visible={loading}>\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </TableLoading>\n </td>\n );\n })}\n </tr>\n {rowChildren ? (\n <tr>\n <td\n colSpan={table.getAllColumns().length}\n style={{\n padding: 0,\n }}\n >\n <Collapse in={row.getIsExpanded()}>\n <Box className={classes.collapsible} px=\"sm\" py=\"xs\">\n {rowChildren}\n </Box>\n </Collapse>\n </td>\n </tr>\n ) : null}\n </Fragment>\n );\n });\n\n return <>{rows}</>;\n};\n\nexport const RowLayout: TableLayout = {\n name: 'Rows',\n icon: ListSize16Px,\n Header: RowLayoutHeader,\n Body: RowLayoutBody,\n};\n"],"names":["RowLayout","useStyles","createStyles","theme","multiRowSelectionEnabled","disableRowSelection","rowBackgroundColor","colorScheme","fn","rgba","colors","primaryColor","gray","border","rem","dark","headerColumns","paddingLeft","backgroundColor","undefined","borderColor","pointerEvents","cursor","color","rowSelected","rowUnselectable","rowCollapsibleButtonCell","textAlign","padding","spacing","xs","sm","row","cell","verticalAlign","height","borderBottom","collapsible","RowLayoutHeader","table","useTable","classes","headers","getHeaderGroups","map","headerGroup","tr","className","columnHeader","Th","header","id","RowLayoutBody","doubleClickAction","getExpandChildren","loading","keepSelection","cx","toggleCollapsible","el","children","length","querySelector","click","rows","getRowModel","rowChildren","original","isSelected","getIsSelected","shouldKeepSelection","onClick","event","currentTarget","toggleSelected","Fragment","onDoubleClick","aria-selected","data-testid","getVisibleCells","columnSizing","defaultColumnSizing","size","column","columnDef","minSize","maxSize","onCollapsibleCellClick","TableSelectableColumn","stopPropagation","getToggleSelectedHandler","td","style","width","minWidth","maxWidth","TableCollapsibleColumn","TableLoading","visible","flexRender","getContext","colSpan","getAllColumns","Collapse","in","getIsExpanded","Box","px","py","name","icon","ListSize16Px","Header","Body"],"mapp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3C1C;;;;qBAKjB;;WA7DOlC,IAAImB,EAAE;IAgE7B;IAEA,qBAAO;kBAAGa;;AACd;AAEO,IAAMhE,YAAyB;IAClC6G,MAAM;IACNC,MAAMC,8BAAY;IAClBC,QAAQ1E;IACR2E,MAAM7D;AACV"}
1
+ {"version":3,"sources":["../../../../../src/components/table/layouts/RowLayout.tsx"],"sourcesContent":["import {ListSize16Px} from '@coveord/plasma-react-icons';\nimport {Box, Collapse, createStyles, rem} from '@mantine/core';\nimport {flexRender} from '@tanstack/react-table';\nimport {defaultColumnSizing} from '@tanstack/table-core';\nimport {Fragment, type MouseEvent} from 'react';\nimport {TableLayout, TableLayoutProps} from '../Table.types';\nimport {TableCollapsibleColumn} from '../TableCollapsibleColumn';\nimport {useTable} from '../TableContext';\nimport {TableLoading} from '../TableLoading';\nimport {TableSelectableColumn} from '../TableSelectableColumn';\nimport {Th} from '../Th';\n\ninterface TableStylesParams {\n multiRowSelectionEnabled: boolean;\n disableRowSelection: boolean;\n}\n\nconst useStyles = createStyles<string, TableStylesParams>((theme, {multiRowSelectionEnabled, disableRowSelection}) => {\n const rowBackgroundColor =\n theme.colorScheme === 'dark' ? theme.fn.rgba(theme.colors[theme.primaryColor][7], 0.2) : theme.colors.gray[1];\n const border = `${rem(1)} solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`;\n return {\n headerColumns: {\n '& th:first-of-type > *': {\n paddingLeft: '40px',\n },\n\n '& input[type=checkbox]': {\n backgroundColor: disableRowSelection ? `${theme.colors.gray[2]}` : undefined,\n borderColor: disableRowSelection ? `${theme.colors.gray[3]}` : `${theme.colors.gray[4]}`,\n pointerEvents: disableRowSelection ? 'none' : 'auto',\n cursor: disableRowSelection ? 'not-allowed' : 'default',\n\n '& + svg': {\n color: disableRowSelection ? `${theme.colors.gray[5]}` : 'inherit',\n },\n },\n },\n\n rowSelected: {\n backgroundColor: multiRowSelectionEnabled ? undefined : rowBackgroundColor,\n },\n\n rowUnselectable: {\n '& input[type=checkbox]': {\n backgroundColor: `${theme.colors.gray[2]}`,\n borderColor: `${theme.colors.gray[3]}`,\n pointerEvents: 'none',\n cursor: 'not-allowed',\n\n '&:checked + svg': {\n color: `${theme.colors.gray[5]}`,\n },\n },\n },\n\n rowCollapsibleButtonCell: {\n textAlign: 'right',\n padding: `calc(${theme.spacing.xs}/2) ${theme.spacing.sm} !important`,\n },\n\n row: {\n '& td:first-of-type': {\n paddingLeft: '40px',\n },\n '&:hover': {\n backgroundColor: rowBackgroundColor,\n },\n },\n\n cell: {\n verticalAlign: 'middle',\n // We must use height instead of minHeight here, otherwise it doesn't apply\n height: '56px',\n padding: `${theme.spacing.xs} ${theme.spacing.sm}`,\n borderBottom: border,\n },\n\n collapsible: {\n backgroundColor: rowBackgroundColor,\n borderBottom: border,\n },\n };\n});\n\nconst RowLayoutHeader = <T,>({table}: TableLayoutProps<T>) => {\n const {multiRowSelectionEnabled, disableRowSelection} = useTable();\n const {classes} = useStyles({disableRowSelection, multiRowSelectionEnabled});\n const headers = table.getHeaderGroups().map((headerGroup) => (\n <tr key={headerGroup.id} className={classes.headerColumns}>\n {headerGroup.headers.map((columnHeader) => (\n <Th key={columnHeader.id} header={columnHeader} />\n ))}\n </tr>\n ));\n return <>{headers}</>;\n};\n\nconst RowLayoutBody = <T,>({\n table,\n doubleClickAction,\n getExpandChildren,\n loading,\n keepSelection,\n}: TableLayoutProps<T>) => {\n const {multiRowSelectionEnabled, disableRowSelection} = useTable();\n const {classes, cx} = useStyles({disableRowSelection, multiRowSelectionEnabled});\n\n const toggleCollapsible = (el: HTMLTableRowElement) => {\n const cell = el.children[el.children.length - 1] as HTMLTableCellElement;\n cell.querySelector('button').click();\n };\n\n const rows = table.getRowModel().rows.map((row) => {\n const rowChildren = getExpandChildren?.(row.original) ?? null;\n const isSelected = !!row.getIsSelected();\n const shouldKeepSelection = keepSelection && isSelected;\n const onClick = (event: MouseEvent<HTMLTableRowElement>) => {\n if (rowChildren) {\n toggleCollapsible(event.currentTarget);\n }\n if (!disableRowSelection && !multiRowSelectionEnabled && !shouldKeepSelection) {\n row.toggleSelected();\n }\n };\n\n return (\n <Fragment key={row.id}>\n <tr\n onClick={onClick}\n onDoubleClick={() => doubleClickAction?.(row.original)}\n className={cx(classes.row, {\n [classes.rowSelected]: isSelected,\n [classes.rowUnselectable]: disableRowSelection,\n })}\n aria-selected={isSelected}\n data-testid={row.id}\n >\n {row.getVisibleCells().map((cell) => {\n const columnSizing = {\n ...defaultColumnSizing,\n size: cell.column.columnDef.size,\n minSize: cell.column.columnDef.minSize,\n maxSize: cell.column.columnDef.maxSize,\n };\n\n const onCollapsibleCellClick = (event: MouseEvent<HTMLTableCellElement>) => {\n if (cell.column.id === TableSelectableColumn.id && !disableRowSelection) {\n event.stopPropagation();\n row.getToggleSelectedHandler();\n }\n };\n return (\n <td\n key={cell.id}\n data-testid={cell.id}\n style={{\n width: columnSizing.size ?? 'auto',\n minWidth: columnSizing.minSize,\n maxWidth: columnSizing.maxSize,\n overflowWrap: 'break-word',\n }}\n className={cx(classes.cell, {\n [classes.rowCollapsibleButtonCell]: cell.column.id === TableCollapsibleColumn.id,\n })}\n onClick={onCollapsibleCellClick}\n >\n <TableLoading visible={loading}>\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </TableLoading>\n </td>\n );\n })}\n </tr>\n {rowChildren ? (\n <tr>\n <td\n colSpan={table.getAllColumns().length}\n style={{\n padding: 0,\n }}\n >\n <Collapse in={row.getIsExpanded()}>\n <Box className={classes.collapsible} px=\"sm\" py=\"xs\">\n {rowChildren}\n </Box>\n </Collapse>\n </td>\n </tr>\n ) : null}\n </Fragment>\n );\n });\n\n return <>{rows}</>;\n};\n\nexport const RowLayout: TableLayout = {\n name: 'Rows',\n icon: ListSize16Px,\n Header: RowLayoutHeader,\n Body: RowLayoutBody,\n};\n"],"names":["RowLayout","useStyles","createStyles","theme","multiRowSelectionEnabled","disableRowSelection","rowBackgroundColor","colorScheme","fn","rgba","colors","primaryColor","gray","border","rem","dark","headerColumns","paddingLeft","backgroundColor","undefined","borderColor","pointerEvents","cursor","color","rowSelected","rowUnselectable","rowCollapsibleButtonCell","textAlign","padding","spacing","xs","sm","row","cell","verticalAlign","height","borderBottom","collapsible","RowLayoutHeader","table","useTable","classes","headers","getHeaderGroups","map","headerGroup","tr","className","columnHeader","Th","header","id","RowLayoutBody","doubleClickAction","getExpandChildren","loading","keepSelection","cx","toggleCollapsible","el","children","length","querySelector","click","rows","getRowModel","rowChildren","original","isSelected","getIsSelected","shouldKeepSelection","onClick","event","currentTarget","toggleSelected","Fragment","onDoubleClick","aria-selected","data-testid","getVisibleCells","columnSizing","defaultColumnSizing","size","column","columnDef","minSize","maxSize","onCollapsibleCellClick","TableSelectableColumn","stopPropagation","getToggleSelectedHandler","td","style","width","minWidth","maxWidth","overflowWrap","TableCollapsibleColumn","TableLoading","visible","flexRender","getContext","colSpan","getAllColumns","Collapse","in","getIsExpanded","Box","px","py","name","icon","ListSize16Px","Header","Body"],"mappings":";;;;+BAqMaA;;;eAAAA;;;;;;;gCArMc;oBACoB;0BACtB;yBACS;qBACM;sCAEH;4BACd;4BACI;qCACS;kBACnB;AAOjB,IAAMC,YAAYC,IAAAA,kBAAY,EAA4B,SAACC;QAAQC,iCAAAA,0BAA0BC,4BAAAA;IACzF,IAAMC,qBACFH,MAAMI,WAAW,KAAK,SAASJ,MAAMK,EAAE,CAACC,IAAI,CAACN,MAAMO,MAAM,CAACP,MAAMQ,YAAY,CAAC,CAAC,EAAE,EAAE,OAAOR,MAAMO,MAAM,CAACE,IAAI,CAAC,EAAE;IACjH,IAAMC,SAAS,AAAC,GAAkBV,OAAhBW,IAAAA,SAAG,EAAC,IAAG,WAAoF,OAA3EX,MAAMI,WAAW,KAAK,SAASJ,MAAMO,MAAM,CAACK,IAAI,CAAC,EAAE,GAAGZ,MAAMO,MAAM,CAACE,IAAI,CAAC,EAAE;IAC5G,OAAO;QACHI,eAAe;YACX,0BAA0B;gBACtBC,aAAa;Y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AAaM,OAAO;gCAC9BU,cAAc;4BAClB;4BACAjD,WAAWU,GAAGhB,QAAQR,IAAI,EACtB,uBAACQ,QAAQf,wBAAwB,EAAGO,KAAKkD,MAAM,CAAChC,EAAE,KAAK8C,8CAAsB,CAAC9C,EAAE;4BAEpFoB,SAASgB;sCAET,cAAA,qBAACW,0BAAY;gCAACC,SAAS5C;0CAClB6C,IAAAA,sBAAU,EAACnE,KAAKkD,MAAM,CAACC,SAAS,CAACnD,IAAI,EAAEA,KAAKoE,UAAU;;2BAdtDpE,KAAKkB,EAAE;oBAkBxB;;gBAEHe,4BACG,qBAACpB;8BACG,cAAA,qBAAC6C;wBACGW,SAAS/D,MAAMgE,aAAa,GAAG1C,MAAM;wBACrC+B,OAAO;4BACHhE,SAAS;wBACb;kCAEA,cAAA,qBAAC4E,cAAQ;4BAACC,IAAIzE,IAAI0E,aAAa;sCAC3B,cAAA,qBAACC,SAAG;gCAAC5D,WAAWN,QAAQJ,WAAW;gCAAEuE,IAAG;gCAAKC,IAAG;0CAC3C3C;;;;qBAKjB;;WA9DOlC,IAAImB,EAAE;IAiE7B;IAEA,qBAAO;kBAAGa;;AACd;AAEO,IAAMhE,YAAyB;IAClC8G,MAAM;IACNC,MAAMC,8BAAY;IAClBC,QAAQ3E;IACR4E,MAAM9D;AACV"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/table/useRowSelection.ts"],"sourcesContent":["import {useClickOutside, useDidUpdate} from '@mantine/hooks';\nimport {functionalUpdate, RowSelectionState, Table} from '@tanstack/table-core';\nimport isEqual from 'fast-deep-equal';\n\nimport {useRef} from 'react';\nimport {RowSelectionWithData, TableProps, TableState} from './Table.types';\n\nexport const useRowSelection = <T>(\n table: Table<T>,\n {\n onRowSelectionChange,\n multiRowSelectionEnabled,\n additionalRootNodes = [],\n }: Pick<TableProps<T>, 'onRowSelectionChange' | 'multiRowSelectionEnabled' | 'additionalRootNodes'>\n) => {\n const outsideClickRef = useRef<HTMLDivElement>();\n useClickOutside(\n () => {\n if (!multiRowSelectionEnabled) {\n clearSelection();\n }\n },\n null,\n [outsideClickRef.current, ...additionalRootNodes]\n );\n\n // Need to call this outside of the onRowSelectionChange of the table to avoid rendering conflicts if the callback queues an update in a parent component.\n // See this warning introduced in React v.16.13.0: https://legacy.reactjs.org/blog/2020/02/26/react-v16.13.0.html#warnings-for-some-updates-during-render\n useDidUpdate(() => {\n onRowSelectionChange?.(getSelectedRows());\n }, [table.getState().rowSelection]);\n\n table.setOptions((prev) => ({\n ...prev,\n onRowSelectionChange: (rowSelectionUpdater) => {\n table.setState((old) => {\n const newRowSelection = functionalUpdate(\n rowSelectionUpdater,\n old['rowSelection']\n ) as RowSelectionWithData<T>;\n\n if (isEqual(old['rowSelection'], newRowSelection)) {\n return old;\n }\n\n const rows = table.getRowModel().rowsById;\n\n Object.keys(newRowSelection).forEach((rowId) => {\n if (newRowSelection[rowId] === true) {\n if (!rows[rowId]) {\n console.error(\n 'The table was not initialized properly, the rowSelection state should contain an object of type Record<string, TData>.'\n );\n }\n newRowSelection[rowId] = rows[rowId]?.original ?? (true as T);\n }\n });\n\n return {\n ...old,\n rowSelection: newRowSelection as RowSelectionState,\n };\n });\n },\n }));\n\n const clearSelection = () => {\n table.resetRowSelection(true);\n };\n\n const getSelectedRows = () => Object.values((table.getState() as TableState<T>).rowSelection);\n\n const getSelectedRow = () => getSelectedRows()[0] ?? null;\n\n return {clearSelection, getSelectedRow, getSelectedRows, outsideClickRef};\n};\n"],"names":["useRowSelection","table","onRowSelectionChange","multiRowSelectionEnabled","additionalRootNodes","outsideClickRef","useRef","useClickOutside","clearSelection","current","useDidUpdate","getSelectedRows","getState","rowSelection","setOptions","prev","rowSelectionUpdater","setState","old","newRowSelection","functionalUpdate","isEqual","rows","getRowModel","rowsById","Object","keys","forEach","rowId","console","error","original","resetRowSelection","values","getSelectedRow"],"mappings":";;;;+BAOaA;;;eAAAA;;;;;;;qBAP+B;yBACa;sEACrC;qBAEC;AAGd,IAAMA,kB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C,AAAChC,MAAMW,QAAQ,GAAqBC,YAAY;;QAE/DF;IAA7B,IAAMuB,iBAAiB;eAAMvB,CAAAA,oBAAAA,iBAAiB,CAAC,EAAE,cAApBA,+BAAAA,oBAAwB;;IAErD,OAAO;QAACH,gBAAAA;QAAgB0B,gBAAAA;QAAgBvB,iBAAAA;QAAiBN,iBAAAA;IAAe;AAC5E"}
1
+ {"version":3,"sources":["../../../../src/components/table/useRowSelection.ts"],"sourcesContent":["import {useClickOutside, useDidUpdate} from '@mantine/hooks';\nimport {functionalUpdate, RowSelectionState, Table} from '@tanstack/table-core';\nimport isEqual from 'fast-deep-equal';\n\nimport {useRef} from 'react';\nimport {RowSelectionWithData, TableProps, TableState} from './Table.types';\n\nexport const useRowSelection = <T>(\n table: Table<T>,\n {\n onRowSelectionChange,\n multiRowSelectionEnabled,\n additionalRootNodes = [],\n }: Pick<TableProps<T>, 'onRowSelectionChange' | 'multiRowSelectionEnabled' | 'additionalRootNodes'>,\n) => {\n const outsideClickRef = useRef<HTMLDivElement>();\n useClickOutside(\n () => {\n if (!multiRowSelectionEnabled) {\n clearSelection();\n }\n },\n null,\n [outsideClickRef.current, ...additionalRootNodes],\n );\n\n // Need to call this outside of the onRowSelectionChange of the table to avoid rendering conflicts if the callback queues an update in a parent component.\n // See this warning introduced in React v.16.13.0: https://legacy.reactjs.org/blog/2020/02/26/react-v16.13.0.html#warnings-for-some-updates-during-render\n useDidUpdate(() => {\n onRowSelectionChange?.(getSelectedRows());\n }, [table.getState().rowSelection]);\n\n table.setOptions((prev) => ({\n ...prev,\n onRowSelectionChange: (rowSelectionUpdater) => {\n table.setState((old) => {\n const newRowSelection = functionalUpdate(\n rowSelectionUpdater,\n old['rowSelection'],\n ) as RowSelectionWithData<T>;\n\n if (isEqual(old['rowSelection'], newRowSelection)) {\n return old;\n }\n\n const rows = table.getRowModel().rowsById;\n\n Object.keys(newRowSelection).forEach((rowId) => {\n if (newRowSelection[rowId] === true) {\n if (!rows[rowId]) {\n console.error(\n 'The table was not initialized properly, the rowSelection state should contain an object of type Record<string, TData>.',\n );\n }\n newRowSelection[rowId] = rows[rowId]?.original ?? (true as T);\n }\n });\n\n return {\n ...old,\n rowSelection: newRowSelection as RowSelectionState,\n };\n });\n },\n }));\n\n const clearSelection = () => {\n table.resetRowSelection(true);\n };\n\n const getSelectedRows = () => Object.values((table.getState() as TableState<T>).rowSelection);\n\n const getSelectedRow = () => getSelectedRows()[0] ?? null;\n\n return {clearSelection, getSelectedRow, getSelectedRows, outsideClickRef};\n};\n"],"names":["useRowSelection","table","onRowSelectionChange","multiRowSelectionEnabled","additionalRootNodes","outsideClickRef","useRef","useClickOutside","clearSelection","current","useDidUpdate","getSelectedRows","getState","rowSelection","setOptions","prev","rowSelectionUpdater","setState","old","newRowSelection","functionalUpdate","isEqual","rows","getRowModel","rowsById","Object","keys","forEach","rowId","console","error","original","resetRowSelection","values","getSelectedRow"],"mappings":";;;;+BAOaA;;;eAAAA;;;;;;;qBAP+B;yBACa;sEACrC;qBAEC;AAGd,IAAMA,kBAAkB,SAC3BC;QAEIC,6BAAAA,sBACAC,iCAAAA,6DACAC,qBAAAA,8DAAsB,EAAE;IAG5B,IAAMC,kBAAkBC,IAAAA,aAAM;IAC9BC,IAAAA,sBAAe,EACX;QACI,IAAI,CAACJ,0BAA0B;YAC3BK;QACJ;IACJ,GACA,MACA;QAACH,gBAAgBI,OAAO;KAAyB,CAAjD,OAA0B,uBAAGL;IAGjC,0JAA0J;IAC1J,yJAAyJ;IACzJM,IAAAA,mBAAY,EAAC;YACTR;SAAAA,wBAAAA,kCAAAA,4CAAAA,sBAAuBS;IAC3B,GAAG;QAACV,MAAMW,QAAQ,GAAGC,YAAY;KAAC;IAElCZ,MAAMa,UAAU,CAAC,SAACC;eAAU,4CACrBA;YACHb,sBAAsB,SAACc;gBACnBf,MAAMgB,QAAQ,CAAC,SAACC;oBACZ,IAAMC,kBAAkBC,IAAAA,2BAAgB,EACpCJ,qBACAE,GAAG,CAAC,eAAe;oBAGvB,IAAIG,IAAAA,sBAAO,EAACH,GAAG,CAAC,eAAe,EAAEC,kBAAkB;wBAC/C,OAAOD;oBACX;oBAEA,IAAMI,OAAOrB,MAAMsB,WAAW,GAAGC,QAAQ;oBAEzCC,OAAOC,IAAI,CAACP,iBAAiBQ,OAAO,CAAC,SAACC;wBAClC,IAAIT,eAAe,CAACS,MAAM,KAAK,MAAM;gCAMRN;4BALzB,IAAI,CAACA,IAAI,CAACM,MAAM,EAAE;gCACdC,QAAQC,KAAK,CACT;4BAER;gCACyBR;4BAAzBH,eAAe,CAACS,MAAM,GAAGN,CAAAA,wBAAAA,cAAAA,IAAI,CAACM,MAAM,cAAXN,kCAAAA,YAAaS,QAAQ,cAArBT,kCAAAA,uBAA0B;wBACvD;oBACJ;oBAEA,OAAO,4CACAJ;wBACHL,cAAcM;;gBAEtB;YACJ;;;IAGJ,IAAMX,iBAAiB;QACnBP,MAAM+B,iBAAiB,CAAC;IAC5B;IAEA,IAAMrB,kBAAkB;eAAMc,OAAOQ,MAAM,CAAC,AAAChC,MAAMW,QAAQ,GAAqBC,YAAY;;QAE/DF;IAA7B,IAAMuB,iBAAiB;eAAMvB,CAAAA,oBAAAA,iBAAiB,CAAC,EAAE,cAApBA,+BAAAA,oBAAwB;;IAErD,OAAO;QAACH,gBAAAA;QAAgB0B,gBAAAA;QAAgBvB,iBAAAA;QAAiBN,iBAAAA;IAAe;AAC5E"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/form/FormProvider.tsx"],"sourcesContent":["/* eslint-disable prefer-arrow/prefer-arrow-functions */\nimport {_TransformValues, UseForm, UseFormReturnType} from '@mantine/form/lib/types';\nimport React, {createContext, useContext} from 'react';\n\nimport {useForm} from './useForm';\n\nexport interface FormProviderProps<Form> {\n form: Form;\n children: React.ReactNode;\n}\n\nexport function createFormContext<\n Values,\n TransformValues extends _TransformValues<Values> = (values: Values) => Values\n>() {\n type Form = UseFormReturnType<Values, TransformValues>;\n\n const FormContext = createContext<Form>(null);\n\n function FormProvider({form, children}: FormProviderProps<Form>) {\n return <FormContext.Provider value={form}>{children}</FormContext.Provider>;\n }\n\n function useFormContext() {\n const ctx = useContext(FormContext);\n if (!ctx) {\n throw new Error('useFormContext was called outside of FormProvider context');\n }\n\n return ctx;\n }\n\n return [FormProvider, useFormContext, useForm] as [\n React.FC<FormProviderProps<Form>>,\n () => Form,\n UseForm<Values, TransformValues>\n ];\n}\n"],"names":["createFormContext","FormProvider","form","children","FormContext","Provider","value","useFormContext","ctx","useContext","Error","createContext","useForm"],"mappings":"AAAA,sDAAsD;;;;+BAWtCA;;;eAAAA;;;;;+DAT+B;uBAEzB;AAOf,SAASA;QAQHC,eAAT,SAASA,aAAa,KAAyC;YAAxCC,OAAD,MAACA,MAAMC,WAAP,MAAOA;QACzB,qBAAO,qBAACC,YAAYC,QAAQ;YAACC,OAAOJ;sBAAOC;;IAC/C;QAESI,iBAAT,SAASA;QACL,IAAMC,MAAMC,IAAAA,iBAAU,EAACL;QACvB,IAAI,CAACI,KAAK;YACN,MAAM,IAAIE,MAAM;QACpB;QAEA,OAAOF;IACX;IAbA,IAAMJ,4BAAcO,IAAAA,oBAAa,EAAO;IAexC,OAAO;QAACV;QAAcM;QAAgBK,gBAAO;KAAC;AAKlD"}
1
+ {"version":3,"sources":["../../../src/form/FormProvider.tsx"],"sourcesContent":["/* eslint-disable prefer-arrow/prefer-arrow-functions */\nimport {_TransformValues, UseForm, UseFormReturnType} from '@mantine/form/lib/types';\nimport React, {createContext, useContext} from 'react';\n\nimport {useForm} from './useForm';\n\nexport interface FormProviderProps<Form> {\n form: Form;\n children: React.ReactNode;\n}\n\nexport function createFormContext<\n Values,\n TransformValues extends _TransformValues<Values> = (values: Values) => Values,\n>() {\n type Form = UseFormReturnType<Values, TransformValues>;\n\n const FormContext = createContext<Form>(null);\n\n function FormProvider({form, children}: FormProviderProps<Form>) {\n return <FormContext.Provider value={form}>{children}</FormContext.Provider>;\n }\n\n function useFormContext() {\n const ctx = useContext(FormContext);\n if (!ctx) {\n throw new Error('useFormContext was called outside of FormProvider context');\n }\n\n return ctx;\n }\n\n return [FormProvider, useFormContext, useForm] as [\n React.FC<FormProviderProps<Form>>,\n () => Form,\n UseForm<Values, TransformValues>,\n ];\n}\n"],"names":["createFormContext","FormProvider","form","children","FormContext","Provider","value","useFormContext","ctx","useContext","Error","createContext","useForm"],"mappings":"AAAA,sDAAsD;;;;+BAWtCA;;;eAAAA;;;;;+DAT+B;uBAEzB;AAOf,SAASA;QAQHC,eAAT,SAASA,aAAa,KAAyC;YAAxCC,OAAD,MAACA,MAAMC,WAAP,MAAOA;QACzB,qBAAO,qBAACC,YAAYC,QAAQ;YAACC,OAAOJ;sBAAOC;;IAC/C;QAESI,iBAAT,SAASA;QACL,IAAMC,MAAMC,IAAAA,iBAAU,EAACL;QACvB,IAAI,CAACI,KAAK;YACN,MAAM,IAAIE,MAAM;QACpB;QAEA,OAAOF;IACX;IAbA,IAAMJ,4BAAcO,IAAAA,oBAAa,EAAO;IAexC,OAAO;QAACV;QAAcM;QAAgBK,gBAAO;KAAC;AAKlD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/form/useForm.ts"],"sourcesContent":["import {useForm as useMantineForm} from '@mantine/form';\nimport {GetInputProps} from '@mantine/form/lib/types';\n\nexport const useForm: typeof useMantineForm = (options) => {\n const form = useMantineForm(options);\n\n const getInputProps: GetInputProps<Record<string, unknown>> = (\n path,\n {type = 'input', withError = type === 'input', withFocus = true} = {}\n ) => {\n const originalPayload = form.getInputProps(path, {type, withError, withFocus});\n if (Array.isArray(originalPayload.value)) {\n return {\n ...originalPayload,\n onReorderItem: (payload: Record<'from' | 'to', number>) => form.reorderListItem(path, payload),\n onRemoveItem: (index: number) => form.removeListItem(path, index),\n onInsertItem: (valueToInsert: unknown, index: number) =>\n form.insertListItem(path, valueToInsert, index),\n };\n }\n\n return originalPayload;\n };\n\n return {...form, getInputProps};\n};\n"],"names":["useForm","options","form","useMantineForm","getInputProps","path","type","withError","withFocus","originalPayload","Array","isArray","value","onReorderItem","payload","reorderListItem","onRemoveItem","index","removeListItem","onInsertItem","valueToInsert","insertListItem"],"mappings":";;;;+BAGaA;;;eAAAA;;;;;oBAH2B;AAGjC,IAAMA,UAAiC,SAACC;IAC3C,IAAMC,OAAOC,IAAAA,aAAc,EAACF;IAE5B,IAAMG,gBAAwD,SAC1DC;oFACmE,CAAC,oBAAnEC,MAAAA,8BAAO,2CAASC,WAAAA,wCAAYD,SAAS,gDAASE,WAAAA,wCAAY;QAE3D,IAAMC,kBAAkBP,KAAKE,aAAa,CAACC,MAAM;YAACC,MAAAA;YAAMC,WAAAA;YAAWC,WAAAA;QAAS;QAC5E,IAAIE,MAAMC,OAAO,CAACF,gBAAgBG,KAAK,GAAG;YACtC,OAAO,4CACAH;gBACHI,eAAe,SAACC;2BAA2CZ,KAAKa,eAAe,CAACV,MAAMS;;gBACtFE,cAAc,SAACC;2BAAkBf,KAAKgB,cAAc,CAACb,MAAMY;;gBAC3DE,cAAc,SAACC,eAAwBH;2BACnCf,KAAKmB,cAAc,CAAChB,MAAMe,eAAeH;;;QAErD;QAEA,OAAOR;IACX;IAEA,OAAO,4CAAIP;QAAME,eAAAA;;AACrB"}
1
+ {"version":3,"sources":["../../../src/form/useForm.ts"],"sourcesContent":["import {useForm as useMantineForm} from '@mantine/form';\nimport {GetInputProps} from '@mantine/form/lib/types';\n\nexport const useForm: typeof useMantineForm = (options) => {\n const form = useMantineForm(options);\n\n const getInputProps: GetInputProps<Record<string, unknown>> = (\n path,\n {type = 'input', withError = type === 'input', withFocus = true} = {},\n ) => {\n const originalPayload = form.getInputProps(path, {type, withError, withFocus});\n if (Array.isArray(originalPayload.value)) {\n return {\n ...originalPayload,\n onReorderItem: (payload: Record<'from' | 'to', number>) => form.reorderListItem(path, payload),\n onRemoveItem: (index: number) => form.removeListItem(path, index),\n onInsertItem: (valueToInsert: unknown, index: number) =>\n form.insertListItem(path, valueToInsert, index),\n };\n }\n\n return originalPayload;\n };\n\n return {...form, getInputProps};\n};\n"],"names":["useForm","options","form","useMantineForm","getInputProps","path","type","withError","withFocus","originalPayload","Array","isArray","value","onReorderItem","payload","reorderListItem","onRemoveItem","index","removeListItem","onInsertItem","valueToInsert","insertListItem"],"mappings":";;;;+BAGaA;;;eAAAA;;;;;oBAH2B;AAGjC,IAAMA,UAAiC,SAACC;IAC3C,IAAMC,OAAOC,IAAAA,aAAc,EAACF;IAE5B,IAAMG,gBAAwD,SAC1DC;oFACmE,CAAC,oBAAnEC,MAAAA,8BAAO,2CAASC,WAAAA,wCAAYD,SAAS,gDAASE,WAAAA,wCAAY;QAE3D,IAAMC,kBAAkBP,KAAKE,aAAa,CAACC,MAAM;YAACC,MAAAA;YAAMC,WAAAA;YAAWC,WAAAA;QAAS;QAC5E,IAAIE,MAAMC,OAAO,CAACF,gBAAgBG,KAAK,GAAG;YACtC,OAAO,4CACAH;gBACHI,eAAe,SAACC;2BAA2CZ,KAAKa,eAAe,CAACV,MAAMS;;gBACtFE,cAAc,SAACC;2BAAkBf,KAAKgB,cAAc,CAACb,MAAMY;;gBAC3DE,cAAc,SAACC,eAAwBH;2BACnCf,KAAKmB,cAAc,CAAChB,MAAMe,eAAeH;;;QAErD;QAEA,OAAOR;IACX;IAEA,OAAO,4CAAIP;QAAME,eAAAA;;AACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../../src/theme/Theme.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGH,KAAK,oBAAoB,EAK5B,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,WAAW,EAAE,oBA0XzB,CAAC"}
1
+ {"version":3,"file":"Theme.d.ts","sourceRoot":"","sources":["../../../src/theme/Theme.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGH,KAAK,oBAAoB,EAK5B,MAAM,eAAe,CAAC;AAIvB,eAAO,MAAM,WAAW,EAAE,oBA4XzB,CAAC"}
@@ -187,14 +187,16 @@ var plasmaTheme = {
187
187
  description: {
188
188
  fontSize: theme.fontSizes.sm,
189
189
  color: theme.colors.gray[7],
190
- marginBottom: theme.spacing.xs
190
+ marginBottom: theme.spacing.xs,
191
+ lineHeight: theme.lineHeight
191
192
  },
192
193
  invalid: {
193
194
  color: theme.colors.red[9],
194
195
  borderColor: theme.colors.red[6]
195
196
  },
196
197
  error: {
197
- color: theme.colors.red[9]
198
+ color: theme.colors.red[9],
199
+ lineHeight: theme.lineHeight
198
200
  }
199
201
  };
200
202
  }