@muraldevkit/ui-toolkit 4.79.1 → 4.81.0-dev-Rwvu.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/avatar/MrlAvatar/MrlAvatar.js.map +1 -1
- package/dist/cjs/components/badge/MrlBadge/MrlBadge.js.map +1 -1
- package/dist/cjs/components/badge/MrlBadgeNotification/MrlBadgeNotification.js.map +1 -1
- package/dist/cjs/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js.map +1 -1
- package/dist/cjs/components/callout/MrlCallout/MrlCallout.js.map +1 -1
- package/dist/cjs/components/empty/default/MrlEmpty.js.map +1 -1
- package/dist/cjs/components/empty/large/MrlEmptyLarge.js.map +1 -1
- package/dist/cjs/components/form/date-picker/MrlDatePicker.js.map +1 -1
- package/dist/cjs/components/form/select/MrlCreatableSelect/MrlCreatableSelect.js.map +1 -1
- package/dist/cjs/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js.map +1 -1
- package/dist/cjs/components/form/select/MrlMultiSelect/MrlMultiSelect.js.map +1 -1
- package/dist/cjs/components/form/select/MrlSelect/MrlSelect.js.map +1 -1
- package/dist/cjs/components/form/switch/MrlSwitch/MrlSwitch.js.map +1 -1
- package/dist/cjs/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.js.map +1 -1
- package/dist/cjs/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.js.map +1 -1
- package/dist/cjs/components/grid/MrlCol/MrlCol.js +58 -55
- package/dist/cjs/components/grid/MrlCol/MrlCol.js.map +1 -1
- package/dist/cjs/components/grid/MrlGrid/MrlGrid.js +3 -5
- package/dist/cjs/components/grid/MrlGrid/MrlGrid.js.map +1 -1
- package/dist/cjs/components/grid/MrlRow/MrlRow.js +10 -8
- package/dist/cjs/components/grid/MrlRow/MrlRow.js.map +1 -1
- package/dist/cjs/components/grid/constants.js +47 -9
- package/dist/cjs/components/grid/constants.js.map +1 -1
- package/dist/cjs/components/layout/MrlSidebar/MrlSidebar.js.map +1 -1
- package/dist/cjs/components/live-region/MrlLiveRegion/MrlLiveRegion.js.map +1 -1
- package/dist/cjs/components/notification/MrlToast/MrlToast.js.map +1 -1
- package/dist/cjs/components/pagination/MrlPaginationButton/MrlPaginationButton.js.map +1 -1
- package/dist/cjs/components/portal/MrlPortal.js.map +1 -1
- package/dist/cjs/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.js.map +1 -1
- package/dist/cjs/components/svg/MrlSvg/MrlSvg.js.map +1 -1
- package/dist/cjs/components/table/MrlTableCell/MrlTableCell.js.map +1 -1
- package/dist/cjs/components/table/MrlTableColumn/MrlTableColumn.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTab/MrlTab.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTabGroup/MrlTabGroup.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTabLink/MrlTabLink.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTabs/MrlTabs.js.map +1 -1
- package/dist/cjs/components/text/MrlTextHeading/MrlTextHeading.js.map +1 -1
- package/dist/cjs/components/toolbar/MrlToolbar/MrlToolbar.js.map +1 -1
- package/dist/cjs/components/toolbar/MrlToolbarButton/MrlToolbarButton.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/components/avatar/MrlAvatar/MrlAvatar.d.ts +8 -0
- package/dist/components/badge/MrlBadge/MrlBadge.d.ts +2 -0
- package/dist/components/badge/MrlBadgeNotification/MrlBadgeNotification.d.ts +1 -0
- package/dist/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.d.ts +1 -0
- package/dist/components/callout/MrlCallout/MrlCallout.d.ts +9 -0
- package/dist/components/empty/default/MrlEmpty.d.ts +4 -0
- package/dist/components/empty/large/MrlEmptyLarge.d.ts +4 -0
- package/dist/components/form/date-picker/MrlDatePicker.d.ts +2 -0
- package/dist/components/form/select/MrlCreatableSelect/MrlCreatableSelect.d.ts +4 -0
- package/dist/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.d.ts +4 -0
- package/dist/components/form/select/MrlMultiSelect/MrlMultiSelect.d.ts +3 -0
- package/dist/components/form/select/MrlSelect/MrlSelect.d.ts +3 -0
- package/dist/components/form/switch/MrlSwitch/MrlSwitch.d.ts +3 -0
- package/dist/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.d.ts +3 -0
- package/dist/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.d.ts +3 -0
- package/dist/components/grid/MrlCol/MrlCol.d.ts +4 -6
- package/dist/components/grid/MrlCol/index.d.ts +1 -1
- package/dist/components/grid/MrlGrid/MrlGrid.d.ts +4 -4
- package/dist/components/grid/MrlGrid/index.d.ts +1 -1
- package/dist/components/grid/MrlRow/MrlRow.d.ts +7 -7
- package/dist/components/grid/MrlRow/index.d.ts +1 -1
- package/dist/components/grid/constants.d.ts +76 -12
- package/dist/components/grid/index.d.ts +1 -0
- package/dist/components/layout/MrlSidebar/MrlSidebar.d.ts +2 -0
- package/dist/components/live-region/MrlLiveRegion/MrlLiveRegion.d.ts +6 -0
- package/dist/components/notification/MrlToast/MrlToast.d.ts +8 -0
- package/dist/components/pagination/MrlPaginationButton/MrlPaginationButton.d.ts +1 -0
- package/dist/components/portal/MrlPortal.d.ts +1 -0
- package/dist/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.d.ts +10 -0
- package/dist/components/svg/MrlSvg/MrlSvg.d.ts +1 -0
- package/dist/components/table/MrlTableCell/MrlTableCell.d.ts +3 -0
- package/dist/components/table/MrlTableColumn/MrlTableColumn.d.ts +3 -0
- package/dist/components/tabs/MrlTab/MrlTab.d.ts +2 -0
- package/dist/components/tabs/MrlTabGroup/MrlTabGroup.d.ts +1 -0
- package/dist/components/tabs/MrlTabLink/MrlTabLink.d.ts +1 -0
- package/dist/components/tabs/MrlTabs/MrlTabs.d.ts +2 -0
- package/dist/components/text/MrlTextHeading/MrlTextHeading.d.ts +1 -0
- package/dist/components/toolbar/MrlToolbar/MrlToolbar.d.ts +12 -0
- package/dist/components/toolbar/MrlToolbarButton/MrlToolbarButton.d.ts +2 -0
- package/dist/esm/components/avatar/MrlAvatar/MrlAvatar.js.map +1 -1
- package/dist/esm/components/badge/MrlBadge/MrlBadge.js.map +1 -1
- package/dist/esm/components/badge/MrlBadgeNotification/MrlBadgeNotification.js.map +1 -1
- package/dist/esm/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js.map +1 -1
- package/dist/esm/components/callout/MrlCallout/MrlCallout.js.map +1 -1
- package/dist/esm/components/empty/default/MrlEmpty.js.map +1 -1
- package/dist/esm/components/empty/large/MrlEmptyLarge.js.map +1 -1
- package/dist/esm/components/form/date-picker/MrlDatePicker.js.map +1 -1
- package/dist/esm/components/form/select/MrlCreatableSelect/MrlCreatableSelect.js.map +1 -1
- package/dist/esm/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js.map +1 -1
- package/dist/esm/components/form/select/MrlMultiSelect/MrlMultiSelect.js.map +1 -1
- package/dist/esm/components/form/select/MrlSelect/MrlSelect.js.map +1 -1
- package/dist/esm/components/form/switch/MrlSwitch/MrlSwitch.js.map +1 -1
- package/dist/esm/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.js.map +1 -1
- package/dist/esm/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.js.map +1 -1
- package/dist/esm/components/grid/MrlCol/MrlCol.js +59 -56
- package/dist/esm/components/grid/MrlCol/MrlCol.js.map +1 -1
- package/dist/esm/components/grid/MrlGrid/MrlGrid.js +3 -5
- package/dist/esm/components/grid/MrlGrid/MrlGrid.js.map +1 -1
- package/dist/esm/components/grid/MrlRow/MrlRow.js +10 -8
- package/dist/esm/components/grid/MrlRow/MrlRow.js.map +1 -1
- package/dist/esm/components/grid/constants.js +46 -9
- package/dist/esm/components/grid/constants.js.map +1 -1
- package/dist/esm/components/layout/MrlSidebar/MrlSidebar.js.map +1 -1
- package/dist/esm/components/live-region/MrlLiveRegion/MrlLiveRegion.js.map +1 -1
- package/dist/esm/components/notification/MrlToast/MrlToast.js.map +1 -1
- package/dist/esm/components/pagination/MrlPaginationButton/MrlPaginationButton.js.map +1 -1
- package/dist/esm/components/portal/MrlPortal.js.map +1 -1
- package/dist/esm/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.js.map +1 -1
- package/dist/esm/components/svg/MrlSvg/MrlSvg.js.map +1 -1
- package/dist/esm/components/table/MrlTableCell/MrlTableCell.js.map +1 -1
- package/dist/esm/components/table/MrlTableColumn/MrlTableColumn.js.map +1 -1
- package/dist/esm/components/tabs/MrlTab/MrlTab.js.map +1 -1
- package/dist/esm/components/tabs/MrlTabGroup/MrlTabGroup.js.map +1 -1
- package/dist/esm/components/tabs/MrlTabLink/MrlTabLink.js.map +1 -1
- package/dist/esm/components/tabs/MrlTabs/MrlTabs.js.map +1 -1
- package/dist/esm/components/text/MrlTextHeading/MrlTextHeading.js.map +1 -1
- package/dist/esm/components/toolbar/MrlToolbar/MrlToolbar.js.map +1 -1
- package/dist/esm/components/toolbar/MrlToolbarButton/MrlToolbarButton.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/styles/MrlSidebar/module.scss +2 -2
- package/dist/styles/grid/global.scss +97 -2
- package/dist/styles.css +1 -7
- package/dist/types/components/avatar/MrlAvatar/MrlAvatar.d.ts +8 -0
- package/dist/types/components/badge/MrlBadge/MrlBadge.d.ts +2 -0
- package/dist/types/components/badge/MrlBadgeNotification/MrlBadgeNotification.d.ts +1 -0
- package/dist/types/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.d.ts +1 -0
- package/dist/types/components/callout/MrlCallout/MrlCallout.d.ts +9 -0
- package/dist/types/components/empty/default/MrlEmpty.d.ts +4 -0
- package/dist/types/components/empty/large/MrlEmptyLarge.d.ts +4 -0
- package/dist/types/components/form/date-picker/MrlDatePicker.d.ts +2 -0
- package/dist/types/components/form/select/MrlCreatableSelect/MrlCreatableSelect.d.ts +4 -0
- package/dist/types/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.d.ts +4 -0
- package/dist/types/components/form/select/MrlMultiSelect/MrlMultiSelect.d.ts +3 -0
- package/dist/types/components/form/select/MrlSelect/MrlSelect.d.ts +3 -0
- package/dist/types/components/form/switch/MrlSwitch/MrlSwitch.d.ts +3 -0
- package/dist/types/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.d.ts +3 -0
- package/dist/types/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.d.ts +3 -0
- package/dist/types/components/grid/MrlCol/MrlCol.d.ts +4 -6
- package/dist/types/components/grid/MrlCol/index.d.ts +1 -1
- package/dist/types/components/grid/MrlGrid/MrlGrid.d.ts +4 -4
- package/dist/types/components/grid/MrlGrid/index.d.ts +1 -1
- package/dist/types/components/grid/MrlRow/MrlRow.d.ts +7 -7
- package/dist/types/components/grid/MrlRow/index.d.ts +1 -1
- package/dist/types/components/grid/constants.d.ts +76 -12
- package/dist/types/components/grid/index.d.ts +1 -0
- package/dist/types/components/layout/MrlSidebar/MrlSidebar.d.ts +2 -0
- package/dist/types/components/live-region/MrlLiveRegion/MrlLiveRegion.d.ts +6 -0
- package/dist/types/components/notification/MrlToast/MrlToast.d.ts +8 -0
- package/dist/types/components/pagination/MrlPaginationButton/MrlPaginationButton.d.ts +1 -0
- package/dist/types/components/portal/MrlPortal.d.ts +1 -0
- package/dist/types/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.d.ts +10 -0
- package/dist/types/components/svg/MrlSvg/MrlSvg.d.ts +1 -0
- package/dist/types/components/table/MrlTableCell/MrlTableCell.d.ts +3 -0
- package/dist/types/components/table/MrlTableColumn/MrlTableColumn.d.ts +3 -0
- package/dist/types/components/tabs/MrlTab/MrlTab.d.ts +2 -0
- package/dist/types/components/tabs/MrlTabGroup/MrlTabGroup.d.ts +1 -0
- package/dist/types/components/tabs/MrlTabLink/MrlTabLink.d.ts +1 -0
- package/dist/types/components/tabs/MrlTabs/MrlTabs.d.ts +2 -0
- package/dist/types/components/text/MrlTextHeading/MrlTextHeading.d.ts +1 -0
- package/dist/types/components/toolbar/MrlToolbar/MrlToolbar.d.ts +12 -0
- package/dist/types/components/toolbar/MrlToolbarButton/MrlToolbarButton.d.ts +2 -0
- package/package.json +1 -1
- package/dist/styles/grid/variables.scss +0 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/components/grid/constants.ts"],"sourcesContent":["/**\n * Alignment & justification options for grid containers\n */\nexport type AlignOptions = 'start' | 'center' | 'end';\nexport type JustifyOptions = 'start' | 'center' | 'end' | 'between' | 'around';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/grid/constants.ts"],"sourcesContent":["import { DataQa } from '../../utils/dataQa';\n\n/**\n * Alignment & justification options for grid containers\n */\nexport type AlignOptions = 'start' | 'center' | 'end';\nexport type JustifyOptions = 'start' | 'center' | 'end' | 'between' | 'around';\n\n/**\n * Number of columns a `col` can span. There is no `col-0` class — a column\n * always occupies at least one of the twelve tracks.\n */\nexport type ColSpan = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;\n\n/**\n * Number of columns an `offset` can skip. `0` is meaningful here: it is how a\n * larger breakpoint cancels an offset inherited from a smaller one.\n */\nexport type OffsetSpan = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;\n\n/**\n * @deprecated Use `ColSpan` for spans or `OffsetSpan` for offsets. This union\n * allowed `col={0}`, which never produced a class.\n */\nexport type NumCols = 0 | ColSpan;\n\n/**\n * Interface of available class selectors per breakpoint.\n *\n * Example interface:\n * {\n * col?: number,\n * offset?: number\n * }\n */\ntype GridClassConfig = {\n\tcol?: ColSpan;\n\toffset?: OffsetSpan;\n};\n\n/**\n * Options to configure the number of columns to span on different screen sizes.\n */\ntype ColumnConfig = ColSpan | 'auto' | GridClassConfig | undefined;\n\nexport interface GridColumns {\n\t/**\n\t * Columns that are the same from the smallest of devices to the largest.\n\t */\n\tcol?: ColumnConfig;\n\n\t/**\n\t * @deprecated Alias of `col`, kept for backwards compatibility. It resolves\n\t * to the same un-prefixed tier, so passing both `col` and `xs` emits two\n\t * competing classes and the larger span wins on CSS source order rather\n\t * than the one you wrote last. Pass only one.\n\t */\n\txs?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span on small devices.\n\t */\n\tsm?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span on medium devices.\n\t */\n\tmd?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span on large devices.\n\t */\n\tlg?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span on extra large devices.\n\t */\n\txl?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span on extra extra large devices.\n\t */\n\txxl?: ColumnConfig;\n}\n\n/**\n * Breakpoint keys in ascending order. Drives both class generation and the\n * filtering that keeps grid props from reaching the DOM.\n */\nexport const GRID_SIZE_KEYS = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const;\n\n/**\n * Available gutter sizes for customizing the grid\n */\nexport type GutterSizes = 0 | 1 | 2;\n\n/**\n * Gutter size to modifier class. `1` is the default declared on `.row`, so it\n * needs no class.\n */\nexport const GUTTER_CLASS: Record<GutterSizes, string | undefined> = {\n\t0: 'MrlRow-gutter--none',\n\t1: undefined,\n\t2: 'MrlRow-gutter--double'\n};\n\n/**\n * Roles a generic layout wrapper may safely carry.\n *\n * Composite widget roles (`grid`, `row`, `gridcell`, `listbox`, `tablist`, …)\n * are deliberately excluded: they promise an APG keyboard contract — roving\n * tabindex or `aria-activedescendant`, arrow-key navigation, selection state —\n * that these divs do not implement. The roles below are structural only and\n * carry no interaction contract, so they are safe to forward.\n *\n * `list`/`listitem` in particular is how a row of columns is announced as\n * \"list, N items\", and is the standard workaround for Safari/VoiceOver\n * dropping implicit list semantics. `region` needs an accessible name to be\n * exposed as a landmark; the type cannot enforce that.\n *\n * Page landmarks belong to the layout components (MrlMain, MrlPage).\n */\nexport type SafeLayoutRole = 'group' | 'list' | 'listitem' | 'none' | 'presentation' | 'region';\n\n/**\n * Shared props for the grid components: every `div` attribute, with `role`\n * narrowed to {@link SafeLayoutRole}.\n */\nexport type GridBaseProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'role'> &\n\tDataQa & {\n\t\t/**\n\t\t * Structural role for the wrapper. Composite widget roles are not\n\t\t * accepted — see {@link SafeLayoutRole}.\n\t\t */\n\t\trole?: SafeLayoutRole;\n\t};\n"],"names":["GRID_SIZE_KEYS","GUTTER_CLASS","undefined"],"mappings":";;AAEA;AACA;AACA;;AAIA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AA2CA;AACA;AACA;AACA;IACaA,cAAc,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;;AAEzE;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,IAAMC,YAAqD,GAAG;AACpE,EAAA,CAAC,EAAE,qBAAqB;AACxB,EAAA,CAAC,EAAEC,SAAS;AACZ,EAAA,CAAC,EAAE;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlSidebar.js","sources":["../../../../../src/components/layout/MrlSidebar/MrlSidebar.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { menu, close } from '@muraldevkit/ds-icons';\nimport { MrlIconButton } from '../../button/MrlIconButton/MrlIconButton';\nimport { MrlFocusTrap } from '../../focus-trap/MrlFocusTrap/MrlFocusTrap';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { LayoutComponent, LayoutSection } from '../constants';\nimport { useBreakpoint } from '../../../hooks/useBreakpoint';\nimport { isMobile } from '../utils';\nimport { useLayoutContext } from '../context/LayoutContext';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlSidebar.module.scss';\n\nexport type MrlSidebarHookInfo = { source: 'userInteraction' | 'imperativeHandler' };\n\ninterface MrlSidebarHook {\n\thookClose?: (info: MrlSidebarHookInfo) => void;\n\thookOpen?: (info: MrlSidebarHookInfo) => void;\n}\n\ninterface MrlSidebarAnalytics {\n\t/**\n\t * Enables interaction tracking for this sidebar. Provide a stable, non-PII id\n\t * (e.g. 'dashboard-sidebar'). When omitted, the sidebar emits no analytics.\n\t */\n\teventId?: string;\n}\n\ntype MrlSidebar = LayoutComponent & LayoutSection & MrlSidebarHook & MrlSidebarAnalytics;\nexport interface MrlSidebarHandle {\n\tclose: () => void;\n\topen: () => void;\n\ttoggle: () => void;\n}\n\n/**\n * MrlSidebar React component.\n * @param props - component props\n * @returns a MrlSidebar React component.\n */\nexport const MrlSidebar = React.forwardRef<MrlSidebarHandle, MrlSidebar>(function MrlSidebar(\n\t{ children, className = '', hookOpen, hookClose, eventId, ...rest }: MrlSidebar,\n\tref: React.Ref<MrlSidebarHandle>\n): JSX.Element {\n\tconst [isExpanded, setIsExpanded] = React.useState<boolean>(false);\n\tconst trackInteraction = useMrlTrackInteraction('MrlSidebar', eventId);\n\tconst setExpandedAndNotify = React.useCallback(\n\t\t(expanded: boolean, info: MrlSidebarHookInfo) => {\n\t\t\t// every open/close path funnels through here, including the imperative handle\n\t\t\ttrackInteraction({ action: expanded ? 'open' : 'close', metadata: { source: info.source } });\n\n\t\t\tif (expanded) {\n\t\t\t\thookOpen?.(info);\n\t\t\t} else {\n\t\t\t\thookClose?.(info);\n\t\t\t}\n\t\t\tsetIsExpanded(expanded);\n\t\t},\n\t\t[hookOpen, hookClose, trackInteraction]\n\t);\n\n\tconst { isTopbarRendered } = useLayoutContext();\n\n\tReact.useImperativeHandle(ref, () => {\n\t\treturn {\n\t\t\tclose() {\n\t\t\t\tsetExpandedAndNotify(false, { source: 'imperativeHandler' });\n\t\t\t},\n\t\t\topen() {\n\t\t\t\tsetExpandedAndNotify(true, { source: 'imperativeHandler' });\n\t\t\t},\n\t\t\ttoggle() {\n\t\t\t\tsetExpandedAndNotify(!isExpanded, { source: 'imperativeHandler' });\n\t\t\t}\n\t\t};\n\t}, [isExpanded, setExpandedAndNotify]);\n\n\tconst breakpoint = useBreakpoint();\n\tconst renderMobile = isMobile(breakpoint);\n\n\tconst sidebarRef = React.useRef<HTMLDivElement>(null);\n\tconst triggerRef = React.useRef<HTMLButtonElement>(null);\n\n\t// If both of these are true, then we want to set focus trap disabled to \"False\"\n\t// which is kind of confusing, because these values actually return true.\n\t// So, we need to negate them. Don't worry, it works.\n\tconst shouldFocusTrap = !(renderMobile && isExpanded);\n\n\tconst offsetClass = classnames(isTopbarRendered && styles['MrlSidebar--offset']);\n\n\tconst sidebarClasses = classnames(styles['MrlSidebar'], 'MrlSidebar', className, offsetClass, {\n\t\t[styles['MrlSidebar--mobile']]: renderMobile,\n\t\t[styles['MrlSidebar--mobile--open']]: renderMobile && isExpanded\n\t});\n\n\tconst overlayClasses = classnames(\n\t\tstyles['MrlSidebar-overlay'],\n\t\t'MrlSidebar-overlay',\n\t\trenderMobile && isExpanded && styles['MrlSidebar-overlay--visible'],\n\t\toffsetClass\n\t);\n\n\tconst sidebarContentClasses = classnames(styles['MrlSidebar-content'], 'MrlSidebar-content', {\n\t\t[styles['MrlSidebar-content--visible']]: isExpanded || !renderMobile\n\t});\n\n\tconst handleKeyUp = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\n\t\tif (e.key === 'Escape') {\n\t\t\tsetExpandedAndNotify(false, { source: 'userInteraction' });\n\t\t\ttriggerRef.current?.focus();\n\t\t}\n\t};\n\n\tconst handleClick = (e: React.SyntheticEvent<HTMLElement, Event>) => {\n\t\te.preventDefault();\n\t\tsetExpandedAndNotify(!isExpanded, { source: 'userInteraction' });\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{\n\t\t\t\t// If the sidebar is rendered on mobile, we want to render the menu button and overlay.\n\t\t\t\trenderMobile && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\t\twrapperClassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlSidebar-menu-trigger'],\n\t\t\t\t\t\t\t\t\tstyles['MrlSidebar-menu']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\ticon={<MrlSvg svg={menu} />}\n\t\t\t\t\t\t\t\tkind=\"ghost\"\n\t\t\t\t\t\t\t\tonClick={handleClick}\n\t\t\t\t\t\t\t\tposition=\"bottom\"\n\t\t\t\t\t\t\t\tref={triggerRef}\n\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\ttext=\"Open\"\n\t\t\t\t\t\t\t\ttipAnchor=\"center\"\n\t\t\t\t\t\t\t\ttoggleAria=\"expanded\"\n\t\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={overlayClasses}\n\t\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\t\t// we only want to allow click events on the overlay if the sidebar is expanded\n\t\t\t\t\t\t\t// otherwise pointer events are none and no click events are allowed\n\t\t\t\t\t\t\t{...(isExpanded && { onClick: handleClick })}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)\n\t\t\t}\n\t\t\t<section\n\t\t\t\t{...rest}\n\t\t\t\tclassName={sidebarClasses}\n\t\t\t\tonKeyUp={handleKeyUp}\n\t\t\t\tref={sidebarRef}\n\t\t\t\trole=\"presentation\"\n\t\t\t\t{...(renderMobile && { 'aria-hidden': !isExpanded })}\n\t\t\t>\n\t\t\t\t<MrlFocusTrap disabled={shouldFocusTrap} containerRef={sidebarRef}>\n\t\t\t\t\t{isExpanded && (\n\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\twrapperClassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlSidebar-menu-trigger'],\n\t\t\t\t\t\t\t\tstyles['MrlSidebar-menu'],\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t[styles['MrlSidebar-menu-close']]: isExpanded,\n\t\t\t\t\t\t\t\t\t'MrlSidebar-menu-close': isExpanded\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\ticon={<MrlSvg svg={close} />}\n\t\t\t\t\t\t\tkind=\"ghost\"\n\t\t\t\t\t\t\tonClick={handleClick}\n\t\t\t\t\t\t\tposition=\"bottom\"\n\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\ttext=\"Close\"\n\t\t\t\t\t\t\ttipAnchor=\"center\"\n\t\t\t\t\t\t\ttoggleAria=\"expanded\"\n\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t<div className={sidebarContentClasses}>{children}</div>\n\t\t\t\t</MrlFocusTrap>\n\t\t\t</section>\n\t\t</>\n\t);\n});\n"],"names":["MrlSidebar","React","forwardRef","_ref","ref","children","_ref$className","className","hookOpen","hookClose","eventId","rest","_objectWithoutProperties","_excluded","_React$useState","useState","_React$useState2","_slicedToArray","isExpanded","setIsExpanded","trackInteraction","useMrlTrackInteraction","setExpandedAndNotify","useCallback","expanded","info","action","metadata","source","_useLayoutContext","useLayoutContext","isTopbarRendered","useImperativeHandle","close","open","toggle","breakpoint","useBreakpoint","renderMobile","isMobile","sidebarRef","useRef","triggerRef","shouldFocusTrap","offsetClass","classnames","styles","sidebarClasses","overlayClasses","sidebarContentClasses","handleKeyUp","e","preventDefault","stopPropagation","key","_triggerRef$current","current","focus","handleClick","createElement","Fragment","MrlIconButton","wrapperClassName","icon","MrlSvg","svg","menu","kind","onClick","position","size","text","tipAnchor","toggleAria","state","_extends","role","tabIndex","onKeyUp","MrlFocusTrap","disabled","containerRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;AACA;AACA;AACA;AACA;AACO,IAAMA,UAAU,gBAAGC,gBAAK,CAACC,UAAU,CAA+B,SAASF,UAAUA,CAAAG,IAAA,EAE3FC,GAAgC,EAClB;AAAA,EAAA,IAFZC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAAC,cAAA,GAAAH,IAAA,CAAEI,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,cAAA;IAAEE,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,SAAS,GAAAN,IAAA,CAATM,SAAS;IAAEC,OAAO,GAAAP,IAAA,CAAPO,OAAO;AAAKC,IAAAA,IAAI,GAAAC,iDAAA,CAAAT,IAAA,EAAAU,SAAA,CAAA;AAGjE,EAAA,IAAAC,eAAA,GAAoCb,gBAAK,CAACc,QAAQ,CAAU,KAAK,CAAC;IAAAC,gBAAA,GAAAC,uCAAA,CAAAH,eAAA,EAAA,CAAA,CAAA;AAA3DI,IAAAA,UAAU,GAAAF,gBAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,aAAa,GAAAH,gBAAA,CAAA,CAAA,CAAA;AAChC,EAAA,IAAMI,gBAAgB,GAAGC,sCAAsB,CAAC,YAAY,EAAEX,OAAO,CAAC;EACtE,IAAMY,oBAAoB,GAAGrB,gBAAK,CAACsB,WAAW,CAC7C,CAACC,QAAiB,EAAEC,IAAwB,KAAK;AAChD;AACAL,IAAAA,gBAAgB,CAAC;AAAEM,MAAAA,MAAM,EAAEF,QAAQ,GAAG,MAAM,GAAG,OAAO;AAAEG,MAAAA,QAAQ,EAAE;QA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+
{"version":3,"file":"MrlSidebar.js","sources":["../../../../../src/components/layout/MrlSidebar/MrlSidebar.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { menu, close } from '@muraldevkit/ds-icons';\nimport { MrlIconButton } from '../../button/MrlIconButton/MrlIconButton';\nimport { MrlFocusTrap } from '../../focus-trap/MrlFocusTrap/MrlFocusTrap';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { LayoutComponent, LayoutSection } from '../constants';\nimport { useBreakpoint } from '../../../hooks/useBreakpoint';\nimport { isMobile } from '../utils';\nimport { useLayoutContext } from '../context/LayoutContext';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlSidebar.module.scss';\n\nexport type MrlSidebarHookInfo = { source: 'userInteraction' | 'imperativeHandler' };\n\ninterface MrlSidebarHook {\n\t/** Called on every close request, even if the sidebar is already closed. `info.source` tells whether a user or the imperative handle made it. */\n\thookClose?: (info: MrlSidebarHookInfo) => void;\n\t/** Called on every open request, even if the sidebar is already open. `info.source` tells whether a user or the imperative handle made it. */\n\thookOpen?: (info: MrlSidebarHookInfo) => void;\n}\n\ninterface MrlSidebarAnalytics {\n\t/**\n\t * Enables interaction tracking for this sidebar. Provide a stable, non-PII id\n\t * (e.g. 'dashboard-sidebar'). When omitted, the sidebar emits no analytics.\n\t */\n\teventId?: string;\n}\n\ntype MrlSidebar = LayoutComponent & LayoutSection & MrlSidebarHook & MrlSidebarAnalytics;\nexport interface MrlSidebarHandle {\n\tclose: () => void;\n\topen: () => void;\n\ttoggle: () => void;\n}\n\n/**\n * MrlSidebar React component.\n * @param props - component props\n * @returns a MrlSidebar React component.\n */\nexport const MrlSidebar = React.forwardRef<MrlSidebarHandle, MrlSidebar>(function MrlSidebar(\n\t{ children, className = '', hookOpen, hookClose, eventId, ...rest }: MrlSidebar,\n\tref: React.Ref<MrlSidebarHandle>\n): JSX.Element {\n\tconst [isExpanded, setIsExpanded] = React.useState<boolean>(false);\n\tconst trackInteraction = useMrlTrackInteraction('MrlSidebar', eventId);\n\tconst setExpandedAndNotify = React.useCallback(\n\t\t(expanded: boolean, info: MrlSidebarHookInfo) => {\n\t\t\t// every open/close path funnels through here, including the imperative handle\n\t\t\ttrackInteraction({ action: expanded ? 'open' : 'close', metadata: { source: info.source } });\n\n\t\t\tif (expanded) {\n\t\t\t\thookOpen?.(info);\n\t\t\t} else {\n\t\t\t\thookClose?.(info);\n\t\t\t}\n\t\t\tsetIsExpanded(expanded);\n\t\t},\n\t\t[hookOpen, hookClose, trackInteraction]\n\t);\n\n\tconst { isTopbarRendered } = useLayoutContext();\n\n\tReact.useImperativeHandle(ref, () => {\n\t\treturn {\n\t\t\tclose() {\n\t\t\t\tsetExpandedAndNotify(false, { source: 'imperativeHandler' });\n\t\t\t},\n\t\t\topen() {\n\t\t\t\tsetExpandedAndNotify(true, { source: 'imperativeHandler' });\n\t\t\t},\n\t\t\ttoggle() {\n\t\t\t\tsetExpandedAndNotify(!isExpanded, { source: 'imperativeHandler' });\n\t\t\t}\n\t\t};\n\t}, [isExpanded, setExpandedAndNotify]);\n\n\tconst breakpoint = useBreakpoint();\n\tconst renderMobile = isMobile(breakpoint);\n\n\tconst sidebarRef = React.useRef<HTMLDivElement>(null);\n\tconst triggerRef = React.useRef<HTMLButtonElement>(null);\n\n\t// If both of these are true, then we want to set focus trap disabled to \"False\"\n\t// which is kind of confusing, because these values actually return true.\n\t// So, we need to negate them. Don't worry, it works.\n\tconst shouldFocusTrap = !(renderMobile && isExpanded);\n\n\tconst offsetClass = classnames(isTopbarRendered && styles['MrlSidebar--offset']);\n\n\tconst sidebarClasses = classnames(styles['MrlSidebar'], 'MrlSidebar', className, offsetClass, {\n\t\t[styles['MrlSidebar--mobile']]: renderMobile,\n\t\t[styles['MrlSidebar--mobile--open']]: renderMobile && isExpanded\n\t});\n\n\tconst overlayClasses = classnames(\n\t\tstyles['MrlSidebar-overlay'],\n\t\t'MrlSidebar-overlay',\n\t\trenderMobile && isExpanded && styles['MrlSidebar-overlay--visible'],\n\t\toffsetClass\n\t);\n\n\tconst sidebarContentClasses = classnames(styles['MrlSidebar-content'], 'MrlSidebar-content', {\n\t\t[styles['MrlSidebar-content--visible']]: isExpanded || !renderMobile\n\t});\n\n\tconst handleKeyUp = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\n\t\tif (e.key === 'Escape') {\n\t\t\tsetExpandedAndNotify(false, { source: 'userInteraction' });\n\t\t\ttriggerRef.current?.focus();\n\t\t}\n\t};\n\n\tconst handleClick = (e: React.SyntheticEvent<HTMLElement, Event>) => {\n\t\te.preventDefault();\n\t\tsetExpandedAndNotify(!isExpanded, { source: 'userInteraction' });\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{\n\t\t\t\t// If the sidebar is rendered on mobile, we want to render the menu button and overlay.\n\t\t\t\trenderMobile && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\t\twrapperClassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlSidebar-menu-trigger'],\n\t\t\t\t\t\t\t\t\tstyles['MrlSidebar-menu']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\ticon={<MrlSvg svg={menu} />}\n\t\t\t\t\t\t\t\tkind=\"ghost\"\n\t\t\t\t\t\t\t\tonClick={handleClick}\n\t\t\t\t\t\t\t\tposition=\"bottom\"\n\t\t\t\t\t\t\t\tref={triggerRef}\n\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\ttext=\"Open\"\n\t\t\t\t\t\t\t\ttipAnchor=\"center\"\n\t\t\t\t\t\t\t\ttoggleAria=\"expanded\"\n\t\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={overlayClasses}\n\t\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\t\t// we only want to allow click events on the overlay if the sidebar is expanded\n\t\t\t\t\t\t\t// otherwise pointer events are none and no click events are allowed\n\t\t\t\t\t\t\t{...(isExpanded && { onClick: handleClick })}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)\n\t\t\t}\n\t\t\t<section\n\t\t\t\t{...rest}\n\t\t\t\tclassName={sidebarClasses}\n\t\t\t\tonKeyUp={handleKeyUp}\n\t\t\t\tref={sidebarRef}\n\t\t\t\trole=\"presentation\"\n\t\t\t\t{...(renderMobile && { 'aria-hidden': !isExpanded })}\n\t\t\t>\n\t\t\t\t<MrlFocusTrap disabled={shouldFocusTrap} containerRef={sidebarRef}>\n\t\t\t\t\t{isExpanded && (\n\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\twrapperClassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlSidebar-menu-trigger'],\n\t\t\t\t\t\t\t\tstyles['MrlSidebar-menu'],\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t[styles['MrlSidebar-menu-close']]: isExpanded,\n\t\t\t\t\t\t\t\t\t'MrlSidebar-menu-close': isExpanded\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\ticon={<MrlSvg svg={close} />}\n\t\t\t\t\t\t\tkind=\"ghost\"\n\t\t\t\t\t\t\tonClick={handleClick}\n\t\t\t\t\t\t\tposition=\"bottom\"\n\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\ttext=\"Close\"\n\t\t\t\t\t\t\ttipAnchor=\"center\"\n\t\t\t\t\t\t\ttoggleAria=\"expanded\"\n\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t<div className={sidebarContentClasses}>{children}</div>\n\t\t\t\t</MrlFocusTrap>\n\t\t\t</section>\n\t\t</>\n\t);\n});\n"],"names":["MrlSidebar","React","forwardRef","_ref","ref","children","_ref$className","className","hookOpen","hookClose","eventId","rest","_objectWithoutProperties","_excluded","_React$useState","useState","_React$useState2","_slicedToArray","isExpanded","setIsExpanded","trackInteraction","useMrlTrackInteraction","setExpandedAndNotify","useCallback","expanded","info","action","metadata","source","_useLayoutContext","useLayoutContext","isTopbarRendered","useImperativeHandle","close","open","toggle","breakpoint","useBreakpoint","renderMobile","isMobile","sidebarRef","useRef","triggerRef","shouldFocusTrap","offsetClass","classnames","styles","sidebarClasses","overlayClasses","sidebarContentClasses","handleKeyUp","e","preventDefault","stopPropagation","key","_triggerRef$current","current","focus","handleClick","createElement","Fragment","MrlIconButton","wrapperClassName","icon","MrlSvg","svg","menu","kind","onClick","position","size","text","tipAnchor","toggleAria","state","_extends","role","tabIndex","onKeyUp","MrlFocusTrap","disabled","containerRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;AACA;AACA;AACA;AACA;AACO,IAAMA,UAAU,gBAAGC,gBAAK,CAACC,UAAU,CAA+B,SAASF,UAAUA,CAAAG,IAAA,EAE3FC,GAAgC,EAClB;AAAA,EAAA,IAFZC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAAC,cAAA,GAAAH,IAAA,CAAEI,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,cAAA;IAAEE,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAEC,SAAS,GAAAN,IAAA,CAATM,SAAS;IAAEC,OAAO,GAAAP,IAAA,CAAPO,OAAO;AAAKC,IAAAA,IAAI,GAAAC,iDAAA,CAAAT,IAAA,EAAAU,SAAA,CAAA;AAGjE,EAAA,IAAAC,eAAA,GAAoCb,gBAAK,CAACc,QAAQ,CAAU,KAAK,CAAC;IAAAC,gBAAA,GAAAC,uCAAA,CAAAH,eAAA,EAAA,CAAA,CAAA;AAA3DI,IAAAA,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AAO,EAAEV,WAAY;AACrBW,IAAAA,QAAQ,EAAC,QAAQ;AACjBC,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,IAAI,EAAC,OAAO;AACZC,IAAAA,SAAS,EAAC,QAAQ;AAClBC,IAAAA,UAAU,EAAC,UAAU;AACrBC,IAAAA,KAAK,EAAC;AAAS,GACf,CACD,eACDzE,gBAAA,CAAA0D,aAAA,CAAA,KAAA,EAAA;AAAKpD,IAAAA,SAAS,EAAE0C;AAAsB,GAAA,EAAE5C,QAAc,CACzC,CACN,CACR,CAAC;AAEL,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlLiveRegion.js","sources":["../../../../../src/components/live-region/MrlLiveRegion/MrlLiveRegion.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport uniqueId from 'lodash.uniqueid';\nimport * as React from 'react';\nimport { useMemo, useState } from 'react';\n\ntype AriaRelevant = 'additions' | 'all' | 'removals' | 'text' | 'additions text' | undefined;\n\nexport interface MrlLiveRegionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n\tariaAtomic?: boolean;\n\tariaLive: 'polite' | 'assertive' | 'off';\n\tariaRelevant?: AriaRelevant;\n\tid?: string;\n\tshouldClearContent?: boolean;\n\tsrContent: string;\n\tvisible?: boolean;\n}\n\n/**\n * Live region component to render an HTML live region with the provided content.\n *\n * @param props - The live region component props.\n * @returns The live region component.\n */\nexport const MrlLiveRegion = ({\n\tariaAtomic,\n\tariaLive,\n\tariaRelevant,\n\tid,\n\tsrContent,\n\tvisible = false,\n\tshouldClearContent = false,\n\t...props\n}: MrlLiveRegionProps): React.ReactElement => {\n\tconst [content, setContent] = useState('');\n\n\tReact.useEffect(() => {\n\t\tsetContent(srContent);\n\n\t\tif (shouldClearContent) {\n\t\t\tconst contentTimeout = setTimeout(() => {\n\t\t\t\tsetContent('');\n\t\t\t\tclearTimeout(contentTimeout);\n\t\t\t}, 1000);\n\n\t\t\treturn () => clearTimeout(contentTimeout);\n\t\t}\n\t}, [shouldClearContent, srContent]);\n\n\tconst nodeId = useMemo(() => id || uniqueId('live-region-'), [id]);\n\n\tconst dataQaProp = (props as { 'data-qa'?: string })['data-qa'];\n\tconst dataQa = dataQaProp || `${nodeId}-live-region`;\n\n\tconst classes = classNames('MrlLiveRegion', {\n\t\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\t\t'mrl-visually-hidden': !visible\n\t});\n\n\treturn (\n\t\t<p\n\t\t\t{...(ariaAtomic ? { 'aria-atomic': ariaAtomic } : {})}\n\t\t\taria-live={ariaLive}\n\t\t\t{...(ariaRelevant ? { 'aria-relevant': ariaRelevant } : {})}\n\t\t\tclassName={classes}\n\t\t\tdata-qa={dataQa}\n\t\t\tid={nodeId}\n\t\t\t{...props}\n\t\t>\n\t\t\t{content}\n\t\t</p>\n\t);\n};\n"],"names":["MrlLiveRegion","_ref","ariaAtomic","ariaLive","ariaRelevant","id","srContent","_ref$visible","visible","_ref$shouldClearConte","shouldClearContent","props","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","content","setContent","React","useEffect","contentTimeout","setTimeout","clearTimeout","nodeId","useMemo","uniqueId","dataQaProp","dataQa","concat","classes","classNames","createElement","_extends","className"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MrlLiveRegion.js","sources":["../../../../../src/components/live-region/MrlLiveRegion/MrlLiveRegion.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport uniqueId from 'lodash.uniqueid';\nimport * as React from 'react';\nimport { useMemo, useState } from 'react';\n\ntype AriaRelevant = 'additions' | 'all' | 'removals' | 'text' | 'additions text' | undefined;\n\nexport interface MrlLiveRegionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n\t/** Sets `aria-atomic`: announce the whole region on every change instead of only the changed part. */\n\tariaAtomic?: boolean;\n\t/** Sets `aria-live`: how urgently screen readers announce changes. */\n\tariaLive: 'polite' | 'assertive' | 'off';\n\t/** Sets `aria-relevant`: which kinds of change are announced. */\n\tariaRelevant?: AriaRelevant;\n\tid?: string;\n\t/** Empties the region one second after `srContent` changes. */\n\tshouldClearContent?: boolean;\n\t/** Text announced by the live region. */\n\tsrContent: string;\n\t/** Shows the text on screen. By default the region is visually hidden. */\n\tvisible?: boolean;\n}\n\n/**\n * Live region component to render an HTML live region with the provided content.\n *\n * @param props - The live region component props.\n * @returns The live region component.\n */\nexport const MrlLiveRegion = ({\n\tariaAtomic,\n\tariaLive,\n\tariaRelevant,\n\tid,\n\tsrContent,\n\tvisible = false,\n\tshouldClearContent = false,\n\t...props\n}: MrlLiveRegionProps): React.ReactElement => {\n\tconst [content, setContent] = useState('');\n\n\tReact.useEffect(() => {\n\t\tsetContent(srContent);\n\n\t\tif (shouldClearContent) {\n\t\t\tconst contentTimeout = setTimeout(() => {\n\t\t\t\tsetContent('');\n\t\t\t\tclearTimeout(contentTimeout);\n\t\t\t}, 1000);\n\n\t\t\treturn () => clearTimeout(contentTimeout);\n\t\t}\n\t}, [shouldClearContent, srContent]);\n\n\tconst nodeId = useMemo(() => id || uniqueId('live-region-'), [id]);\n\n\tconst dataQaProp = (props as { 'data-qa'?: string })['data-qa'];\n\tconst dataQa = dataQaProp || `${nodeId}-live-region`;\n\n\tconst classes = classNames('MrlLiveRegion', {\n\t\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\t\t'mrl-visually-hidden': !visible\n\t});\n\n\treturn (\n\t\t<p\n\t\t\t{...(ariaAtomic ? { 'aria-atomic': ariaAtomic } : {})}\n\t\t\taria-live={ariaLive}\n\t\t\t{...(ariaRelevant ? { 'aria-relevant': ariaRelevant } : {})}\n\t\t\tclassName={classes}\n\t\t\tdata-qa={dataQa}\n\t\t\tid={nodeId}\n\t\t\t{...props}\n\t\t>\n\t\t\t{content}\n\t\t</p>\n\t);\n};\n"],"names":["MrlLiveRegion","_ref","ariaAtomic","ariaLive","ariaRelevant","id","srContent","_ref$visible","visible","_ref$shouldClearConte","shouldClearContent","props","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","content","setContent","React","useEffect","contentTimeout","setTimeout","clearTimeout","nodeId","useMemo","uniqueId","dataQaProp","dataQa","concat","classes","classNames","createElement","_extends","className"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,aAAa,GAAGC,IAAA,IASiB;AAAA,EAAA,IAR7CC,UAAU,GAAAD,IAAA,CAAVC,UAAU;IACVC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,YAAY,GAAAH,IAAA,CAAZG,YAAY;IACZC,EAAE,GAAAJ,IAAA,CAAFI,EAAE;IACFC,SAAS,GAAAL,IAAA,CAATK,SAAS;IAAAC,YAAA,GAAAN,IAAA,CACTO,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,YAAA;IAAAE,qBAAA,GAAAR,IAAA,CACfS,kBAAkB;AAAlBA,IAAAA,kBAAkB,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;AACvBE,IAAAA,KAAK,GAAAC,iDAAA,CAAAX,IAAA,EAAAY,SAAA,CAAA;AAER,EAAA,IAAAC,SAAA,GAA8BC,cAAQ,CAAC,EAAE,CAAC;IAAAC,UAAA,GAAAC,uCAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAnCI,IAAAA,OAAO,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,UAAU,GAAAH,UAAA,CAAA,CAAA,CAAA;EAE1BI,gBAAK,CAACC,SAAS,CAAC,MAAM;IACrBF,UAAU,CAACb,SAAS,CAAC;AAErB,IAAA,IAAII,kBAAkB,EAAE;AACvB,MAAA,IAAMY,cAAc,GAAGC,UAAU,CAAC,MAAM;QACvCJ,UAAU,CAAC,EAAE,CAAC;QACdK,YAAY,CAACF,cAAc,CAAC;MAC7B,CAAC,EAAE,IAAI,CAAC;AAER,MAAA,OAAO,MAAME,YAAY,CAACF,cAAc,CAAC;AAC1C,IAAA;AACD,EAAA,CAAC,EAAE,CAACZ,kBAAkB,EAAEJ,SAAS,CAAC,CAAC;AAEnC,EAAA,IAAMmB,MAAM,GAAGC,aAAO,CAAC,MAAMrB,EAAE,IAAIsB,yBAAQ,CAAC,cAAc,CAAC,EAAE,CAACtB,EAAE,CAAC,CAAC;AAElE,EAAA,IAAMuB,UAAU,GAAIjB,KAAK,CAA4B,SAAS,CAAC;AAC/D,EAAA,IAAMkB,MAAM,GAAGD,UAAU,OAAAE,MAAA,CAAOL,MAAM,EAAA,cAAA,CAAc;AAEpD,EAAA,IAAMM,OAAO,GAAGC,2BAAU,CAAC,eAAe,EAAE;AAC3C;AACA,IAAA,qBAAqB,EAAE,CAACxB;AACzB,GAAC,CAAC;AAEF,EAAA,oBACCY,gBAAA,CAAAa,aAAA,MAAAC,iCAAA,CAAA,EAAA,EACMhC,UAAU,GAAG;AAAE,IAAA,aAAa,EAAEA;GAAY,GAAG,EAAE,EAAA;IACpD,WAAA,EAAWC;AAAS,GAAA,EACfC,YAAY,GAAG;AAAE,IAAA,eAAe,EAAEA;GAAc,GAAG,EAAE,EAAA;AAC1D+B,IAAAA,SAAS,EAAEJ,OAAQ;AACnB,IAAA,SAAA,EAASF,MAAO;AAChBxB,IAAAA,EAAE,EAAEoB;GAAO,EACPd,KAAK,CAAA,EAERO,OACC,CAAC;AAEN;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlToast.js","sources":["../../../../../src/components/notification/MrlToast/MrlToast.tsx"],"sourcesContent":["import * as React from 'react';\nimport { check, close, error, info, lock, modePrivate, warning } from '@muraldevkit/ds-icons';\nimport { stickyTextColor } from '@tactivos/mural-shared/lib/colors';\nimport { MrlIconButton, MrlButton } from '../../button';\nimport { MrlLink } from '../../link';\nimport { MrlSvg, DSIconType } from '../../svg';\nimport { MrlAvatarPropTypes } from '../../avatar/MrlAvatar';\nimport styles from './MrlToast.module.scss';\nimport classNames from 'classnames';\nimport { NotificationKind } from '../constants';\nimport { PORTAL_LAYERS as layers } from '../../../utils/layers';\nimport { useAutoClose } from '../../../hooks/useAutoClose';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport type MrlToastKind = NotificationKind | 'collaborator' | 'general';\n\nexport type MrlToastPosition = 'bottom' | 'top';\n\nexport interface MrlToastCTA {\n\tonClick: () => void;\n\ttext: string;\n\tdataQa: string;\n}\n\nexport interface MrlToastLink {\n\ttext: string;\n\turl: string;\n}\n\nexport interface MrlToastProps {\n\t['data-qa']?: string;\n\t/**\n\t * Determines whether the Toast Notification should automatically close after the time specified in `closeAfterMs` (default 3000ms).\n\t *\n\t * Note: auto-closing is only possible when no interactive elements (e.g. close button & CTA's) exist on the toast notification\n\t */\n\tautoClose?: boolean;\n\t/**\n\t * A MrlAvatar component instance to display in the toast notification.\n\t *\n\t * Note: This is only applicable when `kind` is set to 'collaborator'. When provided, the avatar will be shown instead of the default icon.\n\t * The `showIcon` prop will be ignored when `avatar` is present.\n\t *\n\t * @example\n\t * ```tsx\n\t * <MrlToast\n\t * kind=\"collaborator\"\n\t * avatar={<MrlAvatar name=\"John Doe\" size=\"small\" avatarColor=\"#FF5733\" />}\n\t * primaryMessage=\"John Doe joined the mural\"\n\t * />\n\t * ```\n\t */\n\tavatar?: React.ReactElement<MrlAvatarPropTypes>;\n\t/**\n\t * Sets the background color of the toast notification.\n\t *\n\t * Note: this is only applicable when the `kind` is set to 'collaborator'.\n\t */\n\tbackgroundColor?: string;\n\tclassName?: string;\n\t/**\n\t * The time in milliseconds after which the toast notification should automatically close.\n\t */\n\tcloseAfterMs?: number;\n\tkind?: MrlToastKind;\n\tlink?: MrlToastLink;\n\tonClose?: () => void;\n\tprimaryCTA?: MrlToastCTA;\n\tprimaryMessage: string | JSX.Element;\n\tsecondaryCTA?: MrlToastCTA;\n\tsecondaryMessage?: string | JSX.Element;\n\t/** Determines whether the close icon button should be shown. */\n\tshowCloseButton?: boolean;\n\tshowIcon?: boolean;\n\t/**\n\t * Enables interaction tracking for this toast. Provide a stable, non-PII id\n\t * (e.g. 'export-complete-toast'). When omitted, the toast emits no analytics.\n\t *\n\t * Note: message text is never emitted.\n\t */\n\teventId?: string;\n}\n\n/**\n * MrlToast component.\n * @param {MrlToastProps} props - The props for the MrlToast component.\n * @returns {React.ReactElement} The MrlToast component.\n */\nexport const MrlToast = ({\n\t['data-qa']: qa = 'toast-notification',\n\tautoClose = true,\n\tavatar,\n\tbackgroundColor,\n\tclassName,\n\tcloseAfterMs = 3000,\n\tkind = 'info',\n\tlink,\n\tonClose,\n\tprimaryCTA,\n\tprimaryMessage,\n\tsecondaryCTA,\n\tsecondaryMessage,\n\tshowCloseButton = false,\n\tshowIcon = true,\n\teventId,\n\t...rest\n}: MrlToastProps): React.ReactElement => {\n\tconst trackInteraction = useMrlTrackInteraction('MrlToast', eventId);\n\t// Set to true if any buttons exist on the toast, false otherwise\n\tconst hasInteractiveElements = showCloseButton || primaryCTA || secondaryCTA;\n\n\t// Allowing autoClose when there are interactive elements in the toast is an anti-pattern\n\t// and should be avoided. If autoClose is set to true and interactive elements exist, the\n\t// toast will not close automatically.\n\tconst shouldAutoClose = autoClose && !hasInteractiveElements;\n\n\t/* Boolean value tracking if the close timeout has been reached */\n\tconst [closed, setClosed] = useAutoClose(shouldAutoClose, closeAfterMs, onClose);\n\n\tconst handleClose = (): void => {\n\t\ttrackInteraction({ action: 'close', variant: kind });\n\n\t\tsetClosed(true);\n\n\t\t// Slightly delay the onClose callback to allow the toast to animate out.\n\t\t// This will prevent the toast from disappearing abruptly depending on how\n\t\t// it is implemented within the application\n\t\tsetTimeout(() => {\n\t\t\tif (onClose) onClose();\n\t\t}, 500);\n\t};\n\n\tconst DEFAULT_ICONS: Partial<Record<MrlToastKind, DSIconType>> = {\n\t\tcollaborator: lock,\n\t\terror,\n\t\tinfo,\n\t\tprivate: modePrivate,\n\t\tsuccess: check,\n\t\twarning\n\t};\n\n\tconst hasAvatar = typeof avatar !== 'undefined' && kind === 'collaborator';\n\n\tconst darkCollaborator =\n\t\tkind === 'collaborator' &&\n\t\tbackgroundColor &&\n\t\tstickyTextColor(backgroundColor, 'light', 'dark') === 'light';\n\n\tconst classes = classNames(styles['MrlToast'], className, styles[`${kind}Notification`], {\n\t\t[styles.darkCollaborator]: !!darkCollaborator,\n\t\t[styles.closing]: closed,\n\t\t[styles['has-cta']]: !!hasInteractiveElements,\n\t\t[styles['has-avatar']]: hasAvatar\n\t});\n\n\tconst closeButtonkind = kind === 'warning' || darkCollaborator ? 'ghost' : 'ghost-inverse';\n\n\tconst customTextColor =\n\t\t!!backgroundColor && kind === 'collaborator'\n\t\t\t? stickyTextColor(backgroundColor, '#000000', '#ffffff')\n\t\t\t: undefined;\n\n\tconst primaryMessageClasses = classNames(styles.primaryMessage, 'MrlToast--primaryMessage');\n\tconst secondaryMessageClasses = classNames(styles.secondaryMessage, 'MrlToast--secondaryMessage');\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tclassName={classes}\n\t\t\tdata-qa={qa}\n\t\t\tstyle={{\n\t\t\t\tbackgroundColor: kind === 'collaborator' ? backgroundColor : undefined,\n\t\t\t\tcolor: customTextColor,\n\t\t\t\tzIndex: layers.TOAST.zIndex\n\t\t\t}}\n\t\t>\n\t\t\t<div className={styles.content}>\n\t\t\t\t{hasAvatar && <span className={styles.avatarWrapper}>{avatar}</span>}\n\t\t\t\t{!hasAvatar && showIcon && (\n\t\t\t\t\t<span className={styles.iconWrapper}>\n\t\t\t\t\t\t<MrlSvg size=\"small\" svg={DEFAULT_ICONS[kind] || info} />\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t<span className={styles.textContent}>\n\t\t\t\t\t<span className={primaryMessageClasses} data-qa=\"toast-primary-content\">\n\t\t\t\t\t\t{primaryMessage}\n\t\t\t\t\t</span>{' '}\n\t\t\t\t\t<span className={secondaryMessageClasses}>{secondaryMessage}</span>\n\t\t\t\t\t{link && (\n\t\t\t\t\t\t<span className={styles.link}>\n\t\t\t\t\t\t\t<MrlLink\n\t\t\t\t\t\t\t\ttext={link.text}\n\t\t\t\t\t\t\t\thref={link.url}\n\t\t\t\t\t\t\t\tkind=\"simple\"\n\t\t\t\t\t\t\t\tstyle={{ color: 'inherit' }}\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t{hasInteractiveElements && (\n\t\t\t\t<div className={styles['cta-container']}>\n\t\t\t\t\t{secondaryCTA && (\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\tclassName: styles['cta--secondary']\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tdata-qa={secondaryCTA.dataQa}\n\t\t\t\t\t\t\tkind=\"inverse\"\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\ttrackInteraction({\n\t\t\t\t\t\t\t\t\taction: 'click',\n\t\t\t\t\t\t\t\t\tmetadata: { cta: 'secondary' },\n\t\t\t\t\t\t\t\t\tvariant: kind\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsecondaryCTA.onClick();\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tsize=\"xsmall\"\n\t\t\t\t\t\t\ttext={secondaryCTA.text}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t{primaryCTA && (\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\tclassName: styles['cta--primary']\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tdata-qa={primaryCTA.dataQa}\n\t\t\t\t\t\t\tkind=\"inverse\"\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\ttrackInteraction({ action: 'click', metadata: { cta: 'primary' }, variant: kind });\n\n\t\t\t\t\t\t\t\tprimaryCTA.onClick();\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tsize=\"xsmall\"\n\t\t\t\t\t\t\ttext={primaryCTA.text}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t{showCloseButton && (\n\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\tclassName: styles['cta--close']\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tdata-qa=\"mrl-toast-close-button\"\n\t\t\t\t\t\t\ticon={<MrlSvg svg={close} />}\n\t\t\t\t\t\t\tkind={closeButtonkind}\n\t\t\t\t\t\t\tonClick={handleClose}\n\t\t\t\t\t\t\tsize=\"xsmall\"\n\t\t\t\t\t\t\ttext=\"Close\"\n\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["MrlToast","_ref","_ref$dataQa","qa","_ref$autoClose","autoClose","avatar","backgroundColor","className","_ref$closeAfterMs","closeAfterMs","_ref$kind","kind","link","onClose","primaryCTA","primaryMessage","secondaryCTA","secondaryMessage","_ref$showCloseButton","showCloseButton","_ref$showIcon","showIcon","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","hasInteractiveElements","shouldAutoClose","_useAutoClose","useAutoClose","_useAutoClose2","_slicedToArray","closed","setClosed","handleClose","action","variant","setTimeout","DEFAULT_ICONS","collaborator","lock","error","info","private","modePrivate","success","check","warning","hasAvatar","darkCollaborator","stickyTextColor","classes","classNames","styles","concat","closing","closeButtonkind","customTextColor","undefined","primaryMessageClasses","secondaryMessageClasses","React","createElement","_extends","style","color","zIndex","layers","TOAST","content","avatarWrapper","iconWrapper","MrlSvg","size","svg","textContent","MrlLink","text","href","url","MrlButton","attrs","dataQa","onClick","metadata","cta","MrlIconButton","icon","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,IAAAA,KAAK,EAAE;MACN5E,SAAS,EAAEgD,uBAAM,CAAC,YAAY;KAC7B;AACF,IAAA,SAAA,EAAQ,wBAAwB;AAChCkC,IAAAA,IAAI,eAAE1B,gBAAA,CAAAC,aAAA,CAACU,aAAM,EAAA;AAACE,MAAAA,GAAG,EAAEc;AAAM,KAAE,CAAE;AAC7B/E,IAAAA,IAAI,EAAE+C,eAAgB;AACtB2B,IAAAA,OAAO,EAAEjD,WAAY;AACrBuC,IAAAA,IAAI,EAAC,QAAQ;AACbI,IAAAA,IAAI,EAAC,OAAO;AACZY,IAAAA,KAAK,EAAC;GACN,CAEE,CAEF,CAAC;AAER;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlToast.js","sources":["../../../../../src/components/notification/MrlToast/MrlToast.tsx"],"sourcesContent":["import * as React from 'react';\nimport { check, close, error, info, lock, modePrivate, warning } from '@muraldevkit/ds-icons';\nimport { stickyTextColor } from '@tactivos/mural-shared/lib/colors';\nimport { MrlIconButton, MrlButton } from '../../button';\nimport { MrlLink } from '../../link';\nimport { MrlSvg, DSIconType } from '../../svg';\nimport { MrlAvatarPropTypes } from '../../avatar/MrlAvatar';\nimport styles from './MrlToast.module.scss';\nimport classNames from 'classnames';\nimport { NotificationKind } from '../constants';\nimport { PORTAL_LAYERS as layers } from '../../../utils/layers';\nimport { useAutoClose } from '../../../hooks/useAutoClose';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport type MrlToastKind = NotificationKind | 'collaborator' | 'general';\n\nexport type MrlToastPosition = 'bottom' | 'top';\n\nexport interface MrlToastCTA {\n\tonClick: () => void;\n\ttext: string;\n\tdataQa: string;\n}\n\nexport interface MrlToastLink {\n\ttext: string;\n\turl: string;\n}\n\nexport interface MrlToastProps {\n\t['data-qa']?: string;\n\t/**\n\t * Determines whether the Toast Notification should automatically close after the time specified in `closeAfterMs` (default 3000ms).\n\t *\n\t * Note: auto-closing is only possible when no interactive elements (e.g. close button & CTA's) exist on the toast notification\n\t */\n\tautoClose?: boolean;\n\t/**\n\t * A MrlAvatar component instance to display in the toast notification.\n\t *\n\t * Note: This is only applicable when `kind` is set to 'collaborator'. When provided, the avatar will be shown instead of the default icon.\n\t * The `showIcon` prop will be ignored when `avatar` is present.\n\t *\n\t * @example\n\t * ```tsx\n\t * <MrlToast\n\t * kind=\"collaborator\"\n\t * avatar={<MrlAvatar name=\"John Doe\" size=\"small\" avatarColor=\"#FF5733\" />}\n\t * primaryMessage=\"John Doe joined the mural\"\n\t * />\n\t * ```\n\t */\n\tavatar?: React.ReactElement<MrlAvatarPropTypes>;\n\t/**\n\t * Sets the background color of the toast notification.\n\t *\n\t * Note: this is only applicable when the `kind` is set to 'collaborator'.\n\t */\n\tbackgroundColor?: string;\n\tclassName?: string;\n\t/**\n\t * The time in milliseconds after which the toast notification should automatically close.\n\t */\n\tcloseAfterMs?: number;\n\t/** Visual variant of the toast. Also picks its default icon. */\n\tkind?: MrlToastKind;\n\t/** Link rendered after the messages. */\n\tlink?: MrlToastLink;\n\t/** Called when the toast closes, through the close button or auto-close. */\n\tonClose?: () => void;\n\t/** Primary action button. */\n\tprimaryCTA?: MrlToastCTA;\n\t/** Main message of the toast. */\n\tprimaryMessage: string | JSX.Element;\n\t/** Secondary action button, rendered before the primary one. */\n\tsecondaryCTA?: MrlToastCTA;\n\t/** Supporting message rendered after the primary one. */\n\tsecondaryMessage?: string | JSX.Element;\n\t/** Determines whether the close icon button should be shown. */\n\tshowCloseButton?: boolean;\n\t/** Shows the icon of the `kind` before the message. Ignored when an `avatar` is shown. */\n\tshowIcon?: boolean;\n\t/**\n\t * Enables interaction tracking for this toast. Provide a stable, non-PII id\n\t * (e.g. 'export-complete-toast'). When omitted, the toast emits no analytics.\n\t *\n\t * Note: message text is never emitted.\n\t */\n\teventId?: string;\n}\n\n/**\n * MrlToast component.\n * @param {MrlToastProps} props - The props for the MrlToast component.\n * @returns {React.ReactElement} The MrlToast component.\n */\nexport const MrlToast = ({\n\t['data-qa']: qa = 'toast-notification',\n\tautoClose = true,\n\tavatar,\n\tbackgroundColor,\n\tclassName,\n\tcloseAfterMs = 3000,\n\tkind = 'info',\n\tlink,\n\tonClose,\n\tprimaryCTA,\n\tprimaryMessage,\n\tsecondaryCTA,\n\tsecondaryMessage,\n\tshowCloseButton = false,\n\tshowIcon = true,\n\teventId,\n\t...rest\n}: MrlToastProps): React.ReactElement => {\n\tconst trackInteraction = useMrlTrackInteraction('MrlToast', eventId);\n\t// Set to true if any buttons exist on the toast, false otherwise\n\tconst hasInteractiveElements = showCloseButton || primaryCTA || secondaryCTA;\n\n\t// Allowing autoClose when there are interactive elements in the toast is an anti-pattern\n\t// and should be avoided. If autoClose is set to true and interactive elements exist, the\n\t// toast will not close automatically.\n\tconst shouldAutoClose = autoClose && !hasInteractiveElements;\n\n\t/* Boolean value tracking if the close timeout has been reached */\n\tconst [closed, setClosed] = useAutoClose(shouldAutoClose, closeAfterMs, onClose);\n\n\tconst handleClose = (): void => {\n\t\ttrackInteraction({ action: 'close', variant: kind });\n\n\t\tsetClosed(true);\n\n\t\t// Slightly delay the onClose callback to allow the toast to animate out.\n\t\t// This will prevent the toast from disappearing abruptly depending on how\n\t\t// it is implemented within the application\n\t\tsetTimeout(() => {\n\t\t\tif (onClose) onClose();\n\t\t}, 500);\n\t};\n\n\tconst DEFAULT_ICONS: Partial<Record<MrlToastKind, DSIconType>> = {\n\t\tcollaborator: lock,\n\t\terror,\n\t\tinfo,\n\t\tprivate: modePrivate,\n\t\tsuccess: check,\n\t\twarning\n\t};\n\n\tconst hasAvatar = typeof avatar !== 'undefined' && kind === 'collaborator';\n\n\tconst darkCollaborator =\n\t\tkind === 'collaborator' &&\n\t\tbackgroundColor &&\n\t\tstickyTextColor(backgroundColor, 'light', 'dark') === 'light';\n\n\tconst classes = classNames(styles['MrlToast'], className, styles[`${kind}Notification`], {\n\t\t[styles.darkCollaborator]: !!darkCollaborator,\n\t\t[styles.closing]: closed,\n\t\t[styles['has-cta']]: !!hasInteractiveElements,\n\t\t[styles['has-avatar']]: hasAvatar\n\t});\n\n\tconst closeButtonkind = kind === 'warning' || darkCollaborator ? 'ghost' : 'ghost-inverse';\n\n\tconst customTextColor =\n\t\t!!backgroundColor && kind === 'collaborator'\n\t\t\t? stickyTextColor(backgroundColor, '#000000', '#ffffff')\n\t\t\t: undefined;\n\n\tconst primaryMessageClasses = classNames(styles.primaryMessage, 'MrlToast--primaryMessage');\n\tconst secondaryMessageClasses = classNames(styles.secondaryMessage, 'MrlToast--secondaryMessage');\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tclassName={classes}\n\t\t\tdata-qa={qa}\n\t\t\tstyle={{\n\t\t\t\tbackgroundColor: kind === 'collaborator' ? backgroundColor : undefined,\n\t\t\t\tcolor: customTextColor,\n\t\t\t\tzIndex: layers.TOAST.zIndex\n\t\t\t}}\n\t\t>\n\t\t\t<div className={styles.content}>\n\t\t\t\t{hasAvatar && <span className={styles.avatarWrapper}>{avatar}</span>}\n\t\t\t\t{!hasAvatar && showIcon && (\n\t\t\t\t\t<span className={styles.iconWrapper}>\n\t\t\t\t\t\t<MrlSvg size=\"small\" svg={DEFAULT_ICONS[kind] || info} />\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t<span className={styles.textContent}>\n\t\t\t\t\t<span className={primaryMessageClasses} data-qa=\"toast-primary-content\">\n\t\t\t\t\t\t{primaryMessage}\n\t\t\t\t\t</span>{' '}\n\t\t\t\t\t<span className={secondaryMessageClasses}>{secondaryMessage}</span>\n\t\t\t\t\t{link && (\n\t\t\t\t\t\t<span className={styles.link}>\n\t\t\t\t\t\t\t<MrlLink\n\t\t\t\t\t\t\t\ttext={link.text}\n\t\t\t\t\t\t\t\thref={link.url}\n\t\t\t\t\t\t\t\tkind=\"simple\"\n\t\t\t\t\t\t\t\tstyle={{ color: 'inherit' }}\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t\t{hasInteractiveElements && (\n\t\t\t\t<div className={styles['cta-container']}>\n\t\t\t\t\t{secondaryCTA && (\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\tclassName: styles['cta--secondary']\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tdata-qa={secondaryCTA.dataQa}\n\t\t\t\t\t\t\tkind=\"inverse\"\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\ttrackInteraction({\n\t\t\t\t\t\t\t\t\taction: 'click',\n\t\t\t\t\t\t\t\t\tmetadata: { cta: 'secondary' },\n\t\t\t\t\t\t\t\t\tvariant: kind\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsecondaryCTA.onClick();\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tsize=\"xsmall\"\n\t\t\t\t\t\t\ttext={secondaryCTA.text}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t{primaryCTA && (\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\tclassName: styles['cta--primary']\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tdata-qa={primaryCTA.dataQa}\n\t\t\t\t\t\t\tkind=\"inverse\"\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\ttrackInteraction({ action: 'click', metadata: { cta: 'primary' }, variant: kind });\n\n\t\t\t\t\t\t\t\tprimaryCTA.onClick();\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tsize=\"xsmall\"\n\t\t\t\t\t\t\ttext={primaryCTA.text}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t{showCloseButton && (\n\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\tclassName: styles['cta--close']\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tdata-qa=\"mrl-toast-close-button\"\n\t\t\t\t\t\t\ticon={<MrlSvg svg={close} />}\n\t\t\t\t\t\t\tkind={closeButtonkind}\n\t\t\t\t\t\t\tonClick={handleClose}\n\t\t\t\t\t\t\tsize=\"xsmall\"\n\t\t\t\t\t\t\ttext=\"Close\"\n\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["MrlToast","_ref","_ref$dataQa","qa","_ref$autoClose","autoClose","avatar","backgroundColor","className","_ref$closeAfterMs","closeAfterMs","_ref$kind","kind","link","onClose","primaryCTA","primaryMessage","secondaryCTA","secondaryMessage","_ref$showCloseButton","showCloseButton","_ref$showIcon","showIcon","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","hasInteractiveElements","shouldAutoClose","_useAutoClose","useAutoClose","_useAutoClose2","_slicedToArray","closed","setClosed","handleClose","action","variant","setTimeout","DEFAULT_ICONS","collaborator","lock","error","info","private","modePrivate","success","check","warning","hasAvatar","darkCollaborator","stickyTextColor","classes","classNames","styles","concat","closing","closeButtonkind","customTextColor","undefined","primaryMessageClasses","secondaryMessageClasses","React","createElement","_extends","style","color","zIndex","layers","TOAST","content","avatarWrapper","iconWrapper","MrlSvg","size","svg","textContent","MrlLink","text","href","url","MrlButton","attrs","dataQa","onClick","metadata","cta","MrlIconButton","icon","close","state"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA;AACA;AACA;AACA;AACA;AACO,IAAMA,QAAQ,GAAGC,IAAA,IAkBiB;AAAA,EAAA,IAAAC,WAAA,GAAAD,IAAA,CAjBvC,SAAS,CAAA;AAAGE,IAAAA,EAAE,GAAAD,WAAA,KAAA,MAAA,GAAG,oBAAoB,GAAAA,WAAA;IAAAE,cAAA,GAAAH,IAAA,CACtCI,SA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,IAAAA,IAAI,EAAC,QAAQ;AACbI,IAAAA,IAAI,EAAC,OAAO;AACZY,IAAAA,KAAK,EAAC;GACN,CAEE,CAEF,CAAC;AAER;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlPaginationButton.js","sources":["../../../../../src/components/pagination/MrlPaginationButton/MrlPaginationButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { MrlIconButton, MrlIconButtonProps } from '../../button/MrlIconButton/MrlIconButton';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { MrlTooltipAnchor, MrlTooltipDefaults, MrlTooltipPosition } from '../../tooltip/constants';\nimport { PaginationButtonType } from '../constants';\nimport {\n\tchevronGoToFirst,\n\tchevronGoToLast,\n\tchevronLeft,\n\tchevronRight\n} from '@muraldevkit/ds-icons';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport styles from '../MrlPagination/MrlPagination.module.scss';\n\ninterface MrlPaginationButtonProps {\n\t/** Additional class to add to the button element */\n\tbuttonClass?: string;\n\t/** Additional class to add to the container element */\n\tclassName?: string;\n\tdisabled?: boolean;\n\t/**\n\t * The type of pagination item.\n\t *\n\t * Known quirk: `kind` doesn't match the rendered aria-label. The `kind` prop is\n\t * `'first' | 'previous' | 'next' | 'last'`, but the rendered aria-labels are\n\t * \"Beginning\", \"Previous\", \"Next\", \"End\" (unless `text` overrides them).\n\t * Matters for tests and for users reading the announcement:\n\t * - `first` → `Beginning`\n\t * - `previous` → `Previous`\n\t * - `next` → `Next`\n\t * - `last` → `End`\n\t */\n\tkind: PaginationButtonType;\n\t/**\n\t * Click event for the button.\n\t */\n\thandleClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/** Pagination heading */\n\ttext?: string;\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'templates-pagination'). When omitted, the button emits no analytics.\n\t */\n\teventId?: string;\n\t/** The anchor of the tooltips on the buttons */\n\ttooltipAnchor?: MrlTooltipAnchor;\n\t/** The placement of the tooltips on the buttons */\n\ttooltipPosition?: MrlTooltipPosition;\n\t/**\n\t * Renders custom tooltip content instead of the plain label. Receives the resolved\n\t * label (`text` or the default for `kind`) so defaults can be decorated.\n\t *\n\t * Note: `MrlTooltip` is memoized, so this function should be memoized by consumers.\n\t */\n\ttooltipCustomRender?: MrlIconButtonProps['tooltipCustomRender'];\n}\n\n/**\n * Pagination button component\n * @param {MrlPaginationButtonProps} props - the component props\n * @returns a pagintaion button\n */\nexport function MrlPaginationButton({\n\tbuttonClass,\n\tclassName,\n\tdisabled,\n\tkind,\n\thandleClick,\n\ttext,\n\ttooltipAnchor = MrlTooltipDefaults.anchor,\n\ttooltipPosition = 'top',\n\ttooltipCustomRender,\n\teventId,\n\t...rest\n}: MrlPaginationButtonProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlPaginationButton', eventId);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.SyntheticEvent<HTMLButtonElement>} e - click event\n\t */\n\tconst handleOnClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {\n\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\thandleClick?.(e);\n\t};\n\n\tconst itemClasses = classnames(styles['MrlPaginationItem'], className);\n\tconst icons = {\n\t\tfirst: chevronGoToFirst,\n\t\tlast: chevronGoToLast,\n\t\tnext: chevronRight,\n\t\tprevious: chevronLeft\n\t};\n\tconst defaultText = {\n\t\tfirst: 'Beginning',\n\t\tlast: 'End',\n\t\tnext: 'Next',\n\t\tprevious: 'Previous'\n\t};\n\n\treturn (\n\t\t<li className={itemClasses}>\n\t\t\t<MrlIconButton\n\t\t\t\t{...rest}\n\t\t\t\tclassName={buttonClass}\n\t\t\t\tkind=\"ghost\"\n\t\t\t\ticon={<MrlSvg svg={icons[kind]} />}\n\t\t\t\tonClick={handleOnClick}\n\t\t\t\tposition={tooltipPosition}\n\t\t\t\tstate={disabled ? 'disabled' : 'default'}\n\t\t\t\ttext={text || defaultText[kind]}\n\t\t\t\tsize=\"xsmall\"\n\t\t\t\ttipAnchor={tooltipAnchor}\n\t\t\t\ttooltipCustomRender={tooltipCustomRender}\n\t\t\t/>\n\t\t</li>\n\t);\n}\n"],"names":["MrlPaginationButton","_ref","buttonClass","className","disabled","kind","handleClick","text","_ref$tooltipAnchor","tooltipAnchor","MrlTooltipDefaults","anchor","_ref$tooltipPosition","tooltipPosition","tooltipCustomRender","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","handleOnClick","e","action","variant","itemClasses","classnames","styles","icons","first","chevronGoToFirst","last","chevronGoToLast","next","chevronRight","previous","chevronLeft","defaultText","React","createElement","MrlIconButton","_extends","icon","MrlSvg","svg","onClick","position","state","size","tipAnchor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MrlPaginationButton.js","sources":["../../../../../src/components/pagination/MrlPaginationButton/MrlPaginationButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { MrlIconButton, MrlIconButtonProps } from '../../button/MrlIconButton/MrlIconButton';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { MrlTooltipAnchor, MrlTooltipDefaults, MrlTooltipPosition } from '../../tooltip/constants';\nimport { PaginationButtonType } from '../constants';\nimport {\n\tchevronGoToFirst,\n\tchevronGoToLast,\n\tchevronLeft,\n\tchevronRight\n} from '@muraldevkit/ds-icons';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport styles from '../MrlPagination/MrlPagination.module.scss';\n\ninterface MrlPaginationButtonProps {\n\t/** Additional class to add to the button element */\n\tbuttonClass?: string;\n\t/** Additional class to add to the container element */\n\tclassName?: string;\n\t/** Disables the button. */\n\tdisabled?: boolean;\n\t/**\n\t * The type of pagination item.\n\t *\n\t * Known quirk: `kind` doesn't match the rendered aria-label. The `kind` prop is\n\t * `'first' | 'previous' | 'next' | 'last'`, but the rendered aria-labels are\n\t * \"Beginning\", \"Previous\", \"Next\", \"End\" (unless `text` overrides them).\n\t * Matters for tests and for users reading the announcement:\n\t * - `first` → `Beginning`\n\t * - `previous` → `Previous`\n\t * - `next` → `Next`\n\t * - `last` → `End`\n\t */\n\tkind: PaginationButtonType;\n\t/**\n\t * Click event for the button.\n\t */\n\thandleClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/** Pagination heading */\n\ttext?: string;\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'templates-pagination'). When omitted, the button emits no analytics.\n\t */\n\teventId?: string;\n\t/** The anchor of the tooltips on the buttons */\n\ttooltipAnchor?: MrlTooltipAnchor;\n\t/** The placement of the tooltips on the buttons */\n\ttooltipPosition?: MrlTooltipPosition;\n\t/**\n\t * Renders custom tooltip content instead of the plain label. Receives the resolved\n\t * label (`text` or the default for `kind`) so defaults can be decorated.\n\t *\n\t * Note: `MrlTooltip` is memoized, so this function should be memoized by consumers.\n\t */\n\ttooltipCustomRender?: MrlIconButtonProps['tooltipCustomRender'];\n}\n\n/**\n * Pagination button component\n * @param {MrlPaginationButtonProps} props - the component props\n * @returns a pagintaion button\n */\nexport function MrlPaginationButton({\n\tbuttonClass,\n\tclassName,\n\tdisabled,\n\tkind,\n\thandleClick,\n\ttext,\n\ttooltipAnchor = MrlTooltipDefaults.anchor,\n\ttooltipPosition = 'top',\n\ttooltipCustomRender,\n\teventId,\n\t...rest\n}: MrlPaginationButtonProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlPaginationButton', eventId);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.SyntheticEvent<HTMLButtonElement>} e - click event\n\t */\n\tconst handleOnClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {\n\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\thandleClick?.(e);\n\t};\n\n\tconst itemClasses = classnames(styles['MrlPaginationItem'], className);\n\tconst icons = {\n\t\tfirst: chevronGoToFirst,\n\t\tlast: chevronGoToLast,\n\t\tnext: chevronRight,\n\t\tprevious: chevronLeft\n\t};\n\tconst defaultText = {\n\t\tfirst: 'Beginning',\n\t\tlast: 'End',\n\t\tnext: 'Next',\n\t\tprevious: 'Previous'\n\t};\n\n\treturn (\n\t\t<li className={itemClasses}>\n\t\t\t<MrlIconButton\n\t\t\t\t{...rest}\n\t\t\t\tclassName={buttonClass}\n\t\t\t\tkind=\"ghost\"\n\t\t\t\ticon={<MrlSvg svg={icons[kind]} />}\n\t\t\t\tonClick={handleOnClick}\n\t\t\t\tposition={tooltipPosition}\n\t\t\t\tstate={disabled ? 'disabled' : 'default'}\n\t\t\t\ttext={text || defaultText[kind]}\n\t\t\t\tsize=\"xsmall\"\n\t\t\t\ttipAnchor={tooltipAnchor}\n\t\t\t\ttooltipCustomRender={tooltipCustomRender}\n\t\t\t/>\n\t\t</li>\n\t);\n}\n"],"names":["MrlPaginationButton","_ref","buttonClass","className","disabled","kind","handleClick","text","_ref$tooltipAnchor","tooltipAnchor","MrlTooltipDefaults","anchor","_ref$tooltipPosition","tooltipPosition","tooltipCustomRender","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","handleOnClick","e","action","variant","itemClasses","classnames","styles","icons","first","chevronGoToFirst","last","chevronGoToLast","next","chevronRight","previous","chevronLeft","defaultText","React","createElement","MrlIconButton","_extends","icon","MrlSvg","svg","onClick","position","state","size","tipAnchor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAmBA,CAAAC,IAAA,EAYO;AAAA,EAAA,IAXzCC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IACXC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,IAAI,GAAAJ,IAAA,CAAJI,IAAI;IACJ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AAE;GACV;EAED,oBACCG,gBAAA,CAAAC,aAAA,CAAA,IAAA,EAAA;AAAIpC,IAAAA,SAAS,EAAEsB;GAAY,eAC1Ba,gBAAA,CAAAC,aAAA,CAACC,2BAAa,EAAAC,iCAAA,KACTzB,IAAI,EAAA;AACRb,IAAAA,SAAS,EAAED,WAAY;AACvBG,IAAAA,IAAI,EAAC,OAAO;AACZqC,IAAAA,IAAI,eAAEJ,gBAAA,CAAAC,aAAA,CAACI,aAAM,EAAA;MAACC,GAAG,EAAEhB,KAAK,CAACvB,IAAI;AAAE,KAAE,CAAE;AACnCwC,IAAAA,OAAO,EAAExB,aAAc;AACvByB,IAAAA,QAAQ,EAAEjC,eAAgB;AAC1BkC,IAAAA,KAAK,EAAE3C,QAAQ,GAAG,UAAU,GAAG,SAAU;AACzCG,IAAAA,IAAI,EAAEA,IAAI,IAAI8B,WAAW,CAAChC,IAAI,CAAE;AAChC2C,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,SAAS,EAAExC,aAAc;AACzBK,IAAAA,mBAAmB,EAAEA;AAAoB,GAAA,CACzC,CACE,CAAC;AAEP;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlPortal.js","sources":["../../../../src/components/portal/MrlPortal.tsx"],"sourcesContent":["import * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { PORTAL_LAYERS } from '../../utils/layers';\n\ntype PortalLayer = (typeof PORTAL_LAYERS)[keyof typeof PORTAL_LAYERS];\nexport interface PortalProps extends React.HTMLAttributes<HTMLDivElement> {\n\tchildren: React.ReactNode;\n\tclassName?: string;\n\t['data-qa']?: string;\n\tid?: string;\n\tlayer?: PortalLayer;\n}\n\nexport const MRL_PORTAL_ID = PORTAL_LAYERS.ROOT.name;\n\n/**\n * Dynamically creates a single portal and send your children to the portal.\n * Where they will live outside of the normal document flow\n *\n * @param PortalProps Portal only takes children. Contact the platform team if you need to extend this.\n * @returns MrlPortal component\n */\nexport const MrlPortal = ({\n\tchildren,\n\tclassName,\n\tid,\n\tlayer,\n\t...remainingProps\n}: PortalProps): React.ReactElement | null => {\n\tconst [portalElement, setPortalElement] = React.useState<HTMLElement | null>(null);\n\tconst element = 'div';\n\tconst portalId = layer?.name || id || MRL_PORTAL_ID;\n\tconst portalLayer = layer || PORTAL_LAYERS.ROOT;\n\n\tReact.useLayoutEffect(() => {\n\t\tlet portal = document.getElementById(portalId);\n\t\tconst dataQa = remainingProps['data-qa'] || id || PORTAL_LAYERS.ROOT.name;\n\n\t\t// create the portal on the fly and reuse the same one each time.\n\t\tif (!portal) {\n\t\t\tportal = document.createElement(element);\n\t\t\tportal.setAttribute('id', portalId);\n\t\t\tportal.setAttribute('data-qa', dataQa);\n\t\t\tportal.setAttribute('data-testid', dataQa);\n\t\t\tif (className) portal.setAttribute('class', className);\n\t\t\tdocument.body.appendChild(portal);\n\t\t}\n\n\t\tsetPortalElement(portal);\n\t}, [
|
|
1
|
+
{"version":3,"file":"MrlPortal.js","sources":["../../../../src/components/portal/MrlPortal.tsx"],"sourcesContent":["import * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { PORTAL_LAYERS } from '../../utils/layers';\n\ntype PortalLayer = (typeof PORTAL_LAYERS)[keyof typeof PORTAL_LAYERS];\nexport interface PortalProps extends React.HTMLAttributes<HTMLDivElement> {\n\tchildren: React.ReactNode;\n\tclassName?: string;\n\t['data-qa']?: string;\n\tid?: string;\n\t/** Stacking layer from `PORTAL_LAYERS`. Its name is used as the container id (over `id`) and its z-index is applied to the container's first child. Without it, the container is `id` or the root portal, with the root z-index. */\n\tlayer?: PortalLayer;\n}\n\nexport const MRL_PORTAL_ID = PORTAL_LAYERS.ROOT.name;\n\n/**\n * Dynamically creates a single portal and send your children to the portal.\n * Where they will live outside of the normal document flow\n *\n * @param PortalProps Portal only takes children. Contact the platform team if you need to extend this.\n * @returns MrlPortal component\n */\nexport const MrlPortal = ({\n\tchildren,\n\tclassName,\n\tid,\n\tlayer,\n\t...remainingProps\n}: PortalProps): React.ReactElement | null => {\n\tconst [portalElement, setPortalElement] = React.useState<HTMLElement | null>(null);\n\tconst element = 'div';\n\tconst portalId = layer?.name || id || MRL_PORTAL_ID;\n\tconst portalLayer = layer || PORTAL_LAYERS.ROOT;\n\n\tReact.useLayoutEffect(() => {\n\t\tlet portal = document.getElementById(portalId);\n\t\tconst dataQa = remainingProps['data-qa'] || id || PORTAL_LAYERS.ROOT.name;\n\n\t\t// create the portal on the fly and reuse the same one each time.\n\t\tif (!portal) {\n\t\t\tportal = document.createElement(element);\n\t\t\tportal.setAttribute('id', portalId);\n\t\t\tportal.setAttribute('data-qa', dataQa);\n\t\t\tportal.setAttribute('data-testid', dataQa);\n\t\t\tif (className) portal.setAttribute('class', className);\n\t\t\tdocument.body.appendChild(portal);\n\t\t}\n\n\t\tsetPortalElement(portal);\n\t}, [portalId, remainingProps, id, className]);\n\n\t/**\n\t * Sets z-index of the first child element of the portal to the layer's z-index\n\t *\n\t * TODO: update to also accept a 'layerId' that will override the default layer\n\t * with the provided layerId\n\t */\n\tif (!portalElement) return null;\n\n\tconst childrenArray = React.Children.toArray(children);\n\tif (childrenArray.length > 0 && portalElement) {\n\t\tconst firstChildElement = portalElement.firstElementChild as HTMLElement | null;\n\t\tif (firstChildElement) {\n\t\t\tfirstChildElement.style.zIndex = `${portalLayer.zIndex}`;\n\t\t}\n\t}\n\n\t// state will be null on the very first render.\n\tif (!portalElement) return null;\n\n\treturn createPortal(children, portalElement);\n};\n"],"names":["MRL_PORTAL_ID","PORTAL_LAYERS","ROOT","name","MrlPortal","_ref","children","className","id","layer","remainingProps","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","portalElement","setPortalElement","element","portalId","portalLayer","useLayoutEffect","portal","document","getElementById","dataQa","createElement","setAttribute","body","appendChild","childrenArray","Children","toArray","length","firstChildElement","firstElementChild","style","zIndex","concat","createPortal"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;IAcaA,aAAa,GA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,MAAM,CAACK,YAAY,CAAC,SAAS,EAAEF,MAAM,CAAC;AACtCH,MAAAA,MAAM,CAACK,YAAY,CAAC,aAAa,EAAEF,MAAM,CAAC;MAC1C,IAAIpB,SAAS,EAAEiB,MAAM,CAACK,YAAY,CAAC,OAAO,EAAEtB,SAAS,CAAC;AACtDkB,MAAAA,QAAQ,CAACK,IAAI,CAACC,WAAW,CAACP,MAAM,CAAC;AAClC,IAAA;IAEAL,gBAAgB,CAACK,MAAM,CAAC;EACzB,CAAC,EAAE,CAACH,QAAQ,EAAEX,cAAc,EAAEF,EAAE,EAAED,SAAS,CAAC,CAAC;;AAE7C;AACD;AACA;AACA;AACA;AACA;AACC,EAAA,IAAI,CAACW,aAAa,EAAE,OAAO,IAAI;EAE/B,IAAMc,aAAa,GAAGlB,gBAAK,CAACmB,QAAQ,CAACC,OAAO,CAAC5B,QAAQ,CAAC;AACtD,EAAA,IAAI0B,aAAa,CAACG,MAAM,GAAG,CAAC,IAAIjB,aAAa,EAAE;AAC9C,IAAA,IAAMkB,iBAAiB,GAAGlB,aAAa,CAACmB,iBAAuC;AAC/E,IAAA,IAAID,iBAAiB,EAAE;MACtBA,iBAAiB,CAACE,KAAK,CAACC,MAAM,GAAA,EAAA,CAAAC,MAAA,CAAMlB,WAAW,CAACiB,MAAM,CAAE;AACzD,IAAA;AACD,EAAA;;AAEA;AACA,EAAA,IAAI,CAACrB,aAAa,EAAE,OAAO,IAAI;AAE/B,EAAA,oBAAOuB,qBAAY,CAACnC,QAAQ,EAAEY,aAAa,CAAC;AAC7C;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlRovingTabindex.js","sources":["../../../../../src/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.tsx"],"sourcesContent":["import * as React from 'react';\n\ntype RefType = HTMLElement | HTMLDivElement | null;\n\n/**\n * Gets tabbable elements in a given bit of the DOM, excluding disabled elements\n * @param {RefType} ref - the ref of the container\n * @param {string} selector - the selector to query (should already exclude disabled elements)\n * @returns {HTMLElement[]} - an array of tabbable HTML elements\n */\nexport const getTabbableElements = (ref: RefType, selector: string): HTMLElement[] => {\n\tconst elements = ref?.querySelectorAll(selector);\n\tif (!elements) return [];\n\treturn Array.prototype.slice.call(elements);\n};\n\nconst arraysEqual = (a: (Element | null)[], b: (Element | null)[]): boolean =>\n\ta.length === b.length && a.every((el, i) => el === b[i]);\n\nexport type FocusOnInitPosition = 'first' | 'last';\nexport interface RovingPropTypes {\n\tactiveSelector?: string;\n\t/**\n\t * If true, disabled elements (with disabled attribute or aria-disabled=\"true\")\n\t * will be included in the roving tabindex. Defaults to true (disabled elements are included).\n\t */\n\tallowDisabled?: boolean;\n\tchildren: React.ReactNode;\n\t/**\n\t * delayMount is used to apply a delay to the mounting\n\t * of the RovingTabindex component. This can be helpful in\n\t * the event that a component's children have not been fully\n\t * rendered by the time the componentDidMount function is triggered\n\t */\n\tdelayMount?: number;\n\tfocusOnInit?: FocusOnInitPosition;\n\tfocusWithShortcut?: boolean;\n\tforceUpdate?: boolean;\n\thasChildRoving?: boolean;\n\tignoreElements?: string;\n\tisFocused?: boolean;\n\tonBlur?: () => void;\n\tonRefocus?: (shouldRefocus: boolean) => void;\n\torientation?: RovingOrientation;\n\tqa?: string;\n}\n\ntype RovingOrientation = 'horizontal' | 'vertical';\ntype NavigationDirection = 'forward' | 'back';\n\n/**\n * Default value for allowDisabled prop.\n * When true, disabled elements are included in the roving tabindex navigation.\n */\nconst DEFAULT_ALLOW_DISABLED = true;\n\n/**\n * CSS selector to exclude disabled elements.\n * Excludes both native disabled attribute and ARIA-compliant disabled elements.\n */\nconst DISABLED_EXCLUSION = ':not([disabled]):not([aria-disabled=\"true\"])';\n\n/**\n * CSS selector suffix to exclude nested roving tabindex elements.\n * Prevents deeply nested elements from being included in parent roving tabindex.\n */\nconst NESTED_ROVING_EXCLUSION =\n\t':not(.helpers-roving-tabindex-container .helpers-roving-tabindex-container [data-roving])';\n\n/**\n * Builds the appropriate CSS selector based on configuration.\n * @param allowDisabled - Whether to include disabled elements in the roving tabindex\n * @param hasChildRoving - Whether nested roving tabindex containers should be excluded\n * @returns CSS selector string for querying roving elements\n */\nconst buildSelector = (allowDisabled: boolean, hasChildRoving: boolean): string => {\n\tconst disabledPart = allowDisabled ? '' : DISABLED_EXCLUSION;\n\tconst nestedPart = hasChildRoving ? NESTED_ROVING_EXCLUSION : '';\n\treturn `[data-roving]${disabledPart}${nestedPart}`;\n};\n\n/**\n * Component to create a Roving Tabindex in the DOM\n * @returns {HTMLDivElement}\n */\nclass MrlRovingTabindex extends React.Component<RovingPropTypes> {\n\telements: Array<Element | null>;\n\torientation: RovingOrientation;\n\tref!: HTMLDivElement | null;\n\tselector: string;\n\n\t/**\n\t * MrlRovingTabindex class constructor\n\t * @param props - the MrlRovingTabindex props\n\t * @returns new instance\n\t */\n\tconstructor(props: RovingPropTypes) {\n\t\tsuper(props);\n\n\t\tconst { allowDisabled = DEFAULT_ALLOW_DISABLED, hasChildRoving = false, orientation } = props;\n\n\t\tthis.elements = [];\n\t\tthis.orientation = orientation || 'horizontal';\n\t\tthis.selector = buildSelector(allowDisabled, hasChildRoving);\n\t}\n\n\t/**\n\t * Runs when the MrlRovingTabindex component mounts\n\t */\n\tcomponentDidMount(): void {\n\t\tconst { delayMount } = this.props;\n\t\tif (delayMount) {\n\t\t\tsetTimeout(() => this.mount(), delayMount);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.mount();\n\t}\n\n\t/**\n\t * Runs when the MrlRovingTabindex component unmounts\n\t */\n\tcomponentWillUnmount(): void {\n\t\t// Remove focus event listener\n\t\tif (this.ref) {\n\t\t\tthis.ref.removeEventListener('focusout', this.handleFocusOut);\n\t\t}\n\t}\n\n\t/**\n\t * Runs when the MrlRovingTabindex component updates\n\t * @param {RovingPropTypes} prevProps - the props before the component updated\n\t */\n\tcomponentDidUpdate(prevProps: RovingPropTypes): void {\n\t\tconst {\n\t\t\tallowDisabled = DEFAULT_ALLOW_DISABLED,\n\t\t\tchildren,\n\t\t\tfocusWithShortcut,\n\t\t\thasChildRoving = false,\n\t\t\tisFocused,\n\t\t\tonBlur,\n\t\t\tonRefocus\n\t\t} = this.props;\n\n\t\t/**\n\t\t * If allowDisabled or hasChildRoving prop changes, rebuild the selector\n\t\t * and re-scan for elements to reflect the new configuration.\n\t\t */\n\t\tif (prevProps.allowDisabled !== allowDisabled || prevProps.hasChildRoving !== hasChildRoving) {\n\t\t\tthis.selector = buildSelector(allowDisabled, hasChildRoving);\n\t\t\tthis.setElements();\n\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t}\n\n\t\t/**\n\t\t * If focus is programatically moved to the MrlRovingTabindex\n\t\t * component from outside of the MrlRovingTabindex, passing\n\t\t * the prop of `onRefocus` will cause the component to go\n\t\t * through and make sure that only the active element\n\t\t * has a tabindex set to 0.\n\t\t */\n\t\tif (onRefocus) {\n\t\t\tthis.handleRefocus();\n\t\t}\n\n\t\t/**\n\t\t * When children change, re-scan for elements and update tabindex values.\n\t\t * This ensures that dynamically added/removed buttons are properly managed.\n\t\t */\n\t\tif (prevProps.children !== children && !focusWithShortcut) {\n\t\t\tthis.setElements();\n\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t}\n\n\t\tif (focusWithShortcut) {\n\t\t\t/**\n\t\t\t * If the component within MrlRovingTabindex shows on the page before it should\n\t\t\t * be reached with a keyboard the prop `focusWithiShortcut` can be used to\n\t\t\t * achieve that. The conditions below handle the various states that a\n\t\t\t * component can experience under this scenario.\n\t\t\t */\n\t\t\tif (!isFocused && !prevProps.isFocused) {\n\t\t\t\t/**\n\t\t\t\t * The component was not focus before and is not ready to be focused on\n\t\t\t\t */\n\t\t\t\tthis.unsetTabbableElements();\n\t\t\t}\n\n\t\t\tif (prevProps.isFocused && !isFocused) {\n\t\t\t\t/**\n\t\t\t\t * The component was focused but is not focused anymore\n\t\t\t\t */\n\t\t\t\tthis.unsetTabbableElements();\n\t\t\t\t// Only call onBlur if focus has truly left the container\n\t\t\t\tif (this.ref && !this.ref.contains(document.activeElement)) {\n\t\t\t\t\tonBlur?.();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!prevProps.isFocused && isFocused) {\n\t\t\t\t/**\n\t\t\t\t * The component was not focused before and is ready to be focused\n\t\t\t\t */\n\t\t\t\tthis.setElements();\n\t\t\t\tthis.setElementFocus(this.getActiveElement());\n\t\t\t}\n\n\t\t\tif (prevProps.children !== children && !isFocused && !prevProps.isFocused) {\n\t\t\t\t/**\n\t\t\t\t * Children changed but component is not focused\n\t\t\t\t * Ensure all new elements have tabindex=-1 to prevent Tab key access\n\t\t\t\t */\n\t\t\t\tthis.setElements();\n\t\t\t\tthis.unsetTabbableElements();\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tprevProps.children !== children &&\n\t\t\t\tprevProps.isFocused &&\n\t\t\t\tisFocused &&\n\t\t\t\t!this.ref?.contains(document.activeElement)\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * While the component was focused an action was performed that\n\t\t\t\t * changed the elements of the component and focus was moved to\n\t\t\t\t * a different element on the page\n\t\t\t\t */\n\t\t\t\tthis.setElements();\n\t\t\t\tthis.setActiveElement(this.getActiveElement());\n\n\t\t\t\tif (this.getActiveElement()) {\n\t\t\t\t\t/**\n\t\t\t\t\t * The active element is still within the roving tabindex so focus\n\t\t\t\t\t * on the element that should receive focus\n\t\t\t\t\t */\n\t\t\t\t\tthis.setElementFocus(this.getActiveElement());\n\t\t\t\t} else {\n\t\t\t\t\t/**\n\t\t\t\t\t * The active element has been moved outside of the MrlRovingTabindex\n\t\t\t\t\t * component so reset the component\n\t\t\t\t\t */\n\t\t\t\t\t// Only call onBlur if focus has truly left the container\n\t\t\t\t\tif (this.ref && !this.ref.contains(document.activeElement)) {\n\t\t\t\t\t\tonBlur?.();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\thandleRef = (ref: HTMLDivElement): HTMLDivElement => {\n\t\tthis.ref = ref;\n\t\t// Set up focus listener when ref becomes available\n\t\tif (ref) {\n\t\t\tref.addEventListener('focusout', this.handleFocusOut);\n\t\t}\n\t\treturn ref;\n\t};\n\n\t/**\n\t * Handles focus out events to detect when focus leaves the roving tabindex container\n\t * @param {FocusEvent} event - the focus out event\n\t * @returns {void}\n\t */\n\thandleFocusOut = (event: FocusEvent): void => {\n\t\tconst { onBlur } = this.props;\n\t\tconst relatedTarget = (event as FocusEvent & { relatedTarget?: HTMLElement }).relatedTarget;\n\n\t\t// Check if focus is moving to an element outside the container\n\t\tif (relatedTarget && !this.ref?.contains(relatedTarget)) {\n\t\t\t// Focus has moved from inside the container to outside\n\t\t\tonBlur?.();\n\t\t}\n\t};\n\n\t/**\n\t * Sets component array of elements\n\t * @returns {void}\n\t */\n\tsetElements = (): void => {\n\t\tif (!this.ref) return;\n\t\tthis.elements = getTabbableElements(this.ref, this.selector);\n\t};\n\n\t/**\n\t * Queries for a single element matching the selector within the container.\n\t * @param selector - CSS selector to query\n\t * @returns The matching element or null\n\t */\n\tqueryElement = (selector: string): HTMLElement | null => {\n\t\treturn this.ref?.querySelector(selector) as HTMLElement | null;\n\t};\n\n\t/**\n\t * Gets the active element based on priority order:\n\t * 1. Element matching the custom `activeSelector` prop (e.g., custom radio elements)\n\t * 2. Element with `data-roving-active` attribute (programmatically set active)\n\t * 3. First element with `data-roving` attribute (default fallback)\n\t *\n\t * Disabled elements are excluded unless `allowDisabled` is true.\n\t * @returns The active HTML element, or undefined if none found\n\t */\n\tgetActiveElement = (): HTMLElement | undefined => {\n\t\tconst { activeSelector, allowDisabled = DEFAULT_ALLOW_DISABLED } = this.props;\n\t\tconst disabledFilter = allowDisabled ? '' : DISABLED_EXCLUSION;\n\n\t\t// Priority 1: Custom active selector (e.g., for radio button groups)\n\t\t// An element with the matching activeSelector prop (example usage: custom radio elements)\n\t\tif (activeSelector) {\n\t\t\tconst customActiveElement = this.queryElement(\n\t\t\t\t`${activeSelector}[data-roving]${disabledFilter}`\n\t\t\t);\n\t\t\tif (customActiveElement) return customActiveElement;\n\t\t}\n\n\t\t// Priority 2: Programmatically marked active element\n\t\t// An element with a `data-roving-active` attribute, indicating the current active element\n\t\tconst markedActiveElement = this.queryElement(\n\t\t\t`[data-roving][data-roving-active]${disabledFilter}`\n\t\t);\n\t\tif (markedActiveElement) return markedActiveElement;\n\n\t\t// Priority 3: First roving element (uses pre-built selector with disabled handling)\n\t\t// If no active element is found, the first instance of an element with `data-roving=\"true\"`\n\t\tconst firstRovingElement = this.ref?.querySelectorAll(this.selector)[0];\n\t\treturn firstRovingElement as HTMLElement | undefined;\n\t};\n\n\t/**\n\t * Sets an element to `tabindex=0` and sets all other elements to `tabindex=-1`\n\t * @param {HTMLElement | undefined} el - the element to set as active\n\t * @returns {void}\n\t */\n\tsetActiveElement = (el: HTMLElement | undefined): void => {\n\t\tif (!el) return;\n\n\t\tthis.unsetTabbableElements();\n\t\tel.setAttribute('tabindex', '0');\n\t};\n\n\t/**\n\t * Sets focus to a specific element\n\t * @param {HTMLElement | undefined} el - the element to set in focus\n\t * @returns {void}\n\t */\n\tsetElementFocus = (el: HTMLElement | undefined): void => {\n\t\tif (!el) return;\n\n\t\t/**\n\t\t * Why data-roving-active?\n\t\t *\n\t\t * We only want to set data-roving-active when 'setElementFocus' is triggered because we don't want [tabindex=0] to be mutally exclusive with\n\t\t * [data-roving-active]. An item with [data-roving-active] can exist without having [tabindex=0] and vice versa. We only want to set [data-roving-active]\n\t\t * intentionally when a user action has occured to change it. Such as a keyboard event or moving focus manually with Javascript.\n\t\t */\n\t\tconst current = this.getActiveElement();\n\t\tif (current) current.removeAttribute('data-roving-active');\n\t\tel.setAttribute('data-roving-active', 'true');\n\n\t\tthis.setActiveElement(el);\n\t\tel.focus();\n\t};\n\n\t/**\n\t * Sets focus to an element based on a direction (`forward` or `back`)\n\t * Disabled elements are already excluded from this.elements via CSS selector\n\t * @param {NavigationDirection} direction 'forward' | 'back'\n\t * @returns {void}\n\t */\n\tsetFocusByDirection = (direction: NavigationDirection): void => {\n\t\tconst itemsLen = this.elements.length;\n\n\t\tif (itemsLen > 0) {\n\t\t\tconst currentIndex = this.elements.indexOf(document.activeElement);\n\n\t\t\tconst directionSum = direction === 'back' ? -1 : 1;\n\t\t\tlet nextIndex = currentIndex + directionSum;\n\n\t\t\tif (direction === 'back') {\n\t\t\t\tnextIndex = nextIndex < 0 ? itemsLen - 1 : nextIndex;\n\t\t\t}\n\n\t\t\tif (direction === 'forward') {\n\t\t\t\tnextIndex = nextIndex >= itemsLen ? 0 : nextIndex;\n\t\t\t}\n\n\t\t\tthis.setElementFocus(this.elements[nextIndex] as HTMLElement);\n\t\t}\n\t};\n\n\t/**\n\t * Sets all tabindex for elements of this component to -1\n\t * Also ensures disabled elements (excluded from roving tabindex) have tabindex=-1\n\t * @returns {void}\n\t */\n\tunsetTabbableElements = (): void => {\n\t\tif (!this.elements) return;\n\n\t\t// Set tabindex=-1 for all roving tabindex elements\n\t\tthis.elements.forEach((el: Element | null) => {\n\t\t\tel && el.setAttribute('tabindex', '-1');\n\t\t});\n\n\t\t// Also set tabindex=-1 for disabled elements that are excluded from roving tabindex\n\t\t// This ensures disabled elements are not tabbable even though they're not in the navigation order\n\t\tif (!this.ref || this.props.allowDisabled) return;\n\n\t\tconst disabledElements = this.ref.querySelectorAll(\n\t\t\t`[data-roving][disabled], [data-roving][aria-disabled=\"true\"]`\n\t\t);\n\t\tdisabledElements.forEach((el) => {\n\t\t\tel.setAttribute('tabindex', '-1');\n\t\t});\n\t};\n\n\t/**\n\t * Will return `false` if the orientation param matches the\n\t * orientation of the component and the actively focused element has a menu or select\n\t * @param orientation : 'horizontal' | 'vertical'\n\t * @returns boolean\n\t */\n\tcanUseArrows = (orientation: RovingOrientation): boolean => {\n\t\tconst { activeElement } = document;\n\t\tconst role = activeElement?.getAttribute('role');\n\t\tconst hasMenuOrSelect =\n\t\t\tactiveElement?.getAttribute('aria-haspopup') === 'true' ||\n\t\t\trole === 'combobox' ||\n\t\t\trole === 'option' ||\n\t\t\trole === 'listbox';\n\n\t\treturn !(this.orientation === orientation && hasMenuOrSelect);\n\t};\n\n\thandleKeyUp = (e: React.KeyboardEvent): void => {\n\t\tconst { ignoreElements } = this.props;\n\t\tconst allowKeyPress = !ignoreElements ? true : !document.activeElement?.closest(ignoreElements);\n\n\t\tconst modifierPressed = e.ctrlKey || e.metaKey || e.shiftKey;\n\n\t\tif (modifierPressed) return;\n\n\t\t/**\n\t\t * If elements within MrlRovingTabindex are added after the component mounts\n\t\t * they will not automatically be a `part of this.elements`. This checks if\n\t\t * `this.elements` contains all elements that MrlRovingTabindex should be aware\n\t\t * of and will update `this.elements` if neccessary.\n\t\t */\n\t\tconst knownTabbableElements = this.elements;\n\t\tconst allTabbableElements = getTabbableElements(this.ref, this.selector);\n\n\t\tif (\n\t\t\tknownTabbableElements.length !== allTabbableElements.length ||\n\t\t\t!arraysEqual(knownTabbableElements, allTabbableElements)\n\t\t) {\n\t\t\tthis.setElements();\n\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t}\n\n\t\tconst isActiveRoving = this.getActiveElement() === document.activeElement;\n\n\t\tif (allowKeyPress && isActiveRoving) {\n\t\t\te.stopPropagation();\n\t\t\tswitch (e.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tif (this.canUseArrows('horizontal')) this.setFocusByDirection('forward');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tif (this.canUseArrows('horizontal')) this.setFocusByDirection('back');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\tif (this.canUseArrows('vertical')) this.setFocusByDirection('forward');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tif (this.canUseArrows('vertical')) this.setFocusByDirection('back');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'End':\n\t\t\t\t\tthis.handleFocusedLast();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tthis.handleFocusedFirst();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\thandleFocusedFirst = (): void => this.setElementFocus(this.elements[0] as HTMLElement);\n\n\thandleFocusedLast = (): void =>\n\t\tthis.setElementFocus(this.elements[this.elements.length - 1] as HTMLElement);\n\n\thandleRefocus = (): void => {\n\t\tthis.setActiveElement(document.activeElement as HTMLElement);\n\t\tthis.props.onRefocus?.(false);\n\t};\n\n\t/**\n\t * Mounts the MrlRovingTabindex component\n\t * @returns {void}\n\t */\n\tmount(): void {\n\t\tconst { focusOnInit, focusWithShortcut, isFocused } = this.props;\n\n\t\tif (!focusWithShortcut) {\n\t\t\t// get initial set of elements for the component\n\t\t\tthis.setElements();\n\n\t\t\t// sets the first element of the component to tabindex=0 but does not move focus\n\t\t\t// this allows users to tab to the component naturally based on tab order\n\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t} else {\n\t\t\t// When focusWithShortcut is true, we need to set up elements\n\t\t\t// but only set tabindex values based on isFocused state\n\t\t\tthis.setElements();\n\n\t\t\tif (!isFocused) {\n\t\t\t\t// If not focused initially, set all elements to tabindex=-1\n\t\t\t\tthis.unsetTabbableElements();\n\t\t\t} else {\n\t\t\t\t// If focused initially, set the active element properly\n\t\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t\t}\n\t\t}\n\n\t\tif (focusOnInit && this.elements.length > 0) {\n\t\t\tif (focusOnInit === 'first') {\n\t\t\t\tthis.handleFocusedFirst();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.handleFocusedLast();\n\t\t}\n\t}\n\n\t/**\n\t * Renders the MrlRovingTabindex component\n\t * @returns {HTMLDivElement} - the rendered MrlRovingTabindex component\n\t */\n\trender(): JSX.Element {\n\t\t/* eslint-disable @typescript-eslint/no-unused-vars */\n\t\t// Destructure component-specific props to prevent them from being spread to the DOM\n\t\tconst {\n\t\t\tactiveSelector,\n\t\t\tallowDisabled,\n\t\t\tchildren,\n\t\t\tdelayMount,\n\t\t\tfocusOnInit,\n\t\t\tfocusWithShortcut,\n\t\t\tforceUpdate,\n\t\t\thasChildRoving,\n\t\t\tignoreElements,\n\t\t\tisFocused,\n\t\t\tonBlur,\n\t\t\tonRefocus,\n\t\t\torientation,\n\t\t\tqa,\n\t\t\t...rest\n\t\t} = this.props;\n\t\t/* eslint-enable @typescript-eslint/no-unused-vars */\n\n\t\tconst dataQa = `${qa || 'generic'}-roving`;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tclassName=\"helpers-roving-tabindex-container\"\n\t\t\t\tdata-qa={dataQa}\n\t\t\t\tonKeyUp={this.handleKeyUp}\n\t\t\t\tref={this.handleRef}\n\t\t\t\trole=\"presentation\"\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n\t\t\t\ttabIndex={-1}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport { MrlRovingTabindex };\n"],"names":["getTabbableElements","ref","selector","elements","querySelectorAll","Array","prototype","slice","call","arraysEqual","a","b","length","every","el","i","DEFAULT_ALLOW_DISABLED","DISABLED_EXCLUSION","NESTED_ROVING_EXCLUSION","buildSelector","allowDisabled","hasChildRoving","disabledPart","nestedPart","concat","MrlRovingTabindex","React","Component","constructor","props","_defineProperty","addEventListener","handleFocusOut","event","_this$ref","onBlur","relatedTarget","contains","_this$ref2","querySelector","_this$ref3","_this$props","activeSelector","_this$props$allowDisa","disabledFilter","customActiveElement","queryElement","markedActiveElement","firstRovingElement","unsetTabbableElements","setAttribute","current","getActiveElement","removeAttribute","setActiveElement","focus","direction","itemsLen","currentIndex","indexOf","document","activeElement","directionSum","nextIndex","setElementFocus","forEach","disabledElements","orientation","_document","role","getAttribute","hasMenuOrSelect","e","_document$activeEleme","ignoreElements","allowKeyPress","closest","modifierPressed","ctrlKey","metaKey","shiftKey","knownTabbableElements","allTabbableElements","setElements","isActiveRoving","stopPropagation","key","canUseArrows","setFocusByDirection","handleFocusedLast","handleFocusedFirst","_this$props$onRefocus","_this$props2","onRefocus","_props$allowDisabled","_props$hasChildRoving","componentDidMount","delayMount","setTimeout","mount","componentWillUnmount","removeEventListener","componentDidUpdate","prevProps","_this$props3","_this$props3$allowDis","children","focusWithShortcut","_this$props3$hasChild","isFocused","handleRefocus","_this$ref4","_this$props4","focusOnInit","render","_this$props5","forceUpdate","qa","rest","_objectWithoutProperties","_excluded","dataQa","createElement","_extends","className","onKeyUp","handleKeyUp","handleRef","tabIndex"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;AACA;AACA;AACA;AACA;AACA;IACaA,mBAAmB,GAAGA,CAACC,GAAY,EAAEC,QAAgB,KAAoB;EACrF,IAAMC,QAAQ,GAAGF,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAA,MAAA,GAAA,MAAA,GAAHA,GAAG,CAAEG,gBAAgB,CAACF,QAAQ,CAAC;AAChD,EAAA,IAAI,CAACC,QAAQ,EAAE,OAAO,EAAE;EACxB,OAAOE,KAAK,CAACC,SAAS,CAACC,KAAK,CAACC,IAAI,CAACL,QAAQ,CAAC;AAC5C;AAEA,IAAMM,WAAW,GAAGA,CAACC,CAAqB,EAAEC,CAAqB,KAChED,CAAC,CAACE,MAAM,KAAKD,CAAC,CAACC,MAAM,IAAIF,CAAC,CAACG,KAAK,CAAC,CAACC,EAAE,EAAEC,CAAC,KAAKD,EAAE,KAAKH,CAAC,CAACI,CAAC,CAAC,CAAC;AAiCzD;AACA;AACA;AACA;AACA,IAAMC,sBAAsB,GAAG,IAAI;;AAEnC;AACA;AACA;AACA;AACA,IAAMC,kBAAkB,GAAG,8CAA8C;;AAEzE;AACA;AACA;AACA;AACA,IAAMC,uBAAuB,GAC5B,2FAA2F;;AAE5F;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,aAAa,GAAGA,CAACC,aAAsB,EAAEC,cAAuB,KAAa;AAClF,EAAA,IAAMC,YAAY,GAAGF,aAAa,GAAG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SAAA,EAASH,MAAO;MAChBI,OAAO,EAAE,IAAI,CAACC,WAAY;MAC1B7H,GAAG,EAAE,IAAI,CAAC8H,SAAU;AACpB1D,MAAAA,IAAI,EAAC;AACL;AAAA;AACA2D,MAAAA,QAAQ,EAAE;AAAG,KAAA,CAAA,EAEZtB,QACG,CAAC;AAER,EAAA;AACD;;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlRovingTabindex.js","sources":["../../../../../src/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.tsx"],"sourcesContent":["import * as React from 'react';\n\ntype RefType = HTMLElement | HTMLDivElement | null;\n\n/**\n * Gets tabbable elements in a given bit of the DOM, excluding disabled elements\n * @param {RefType} ref - the ref of the container\n * @param {string} selector - the selector to query (should already exclude disabled elements)\n * @returns {HTMLElement[]} - an array of tabbable HTML elements\n */\nexport const getTabbableElements = (ref: RefType, selector: string): HTMLElement[] => {\n\tconst elements = ref?.querySelectorAll(selector);\n\tif (!elements) return [];\n\treturn Array.prototype.slice.call(elements);\n};\n\nconst arraysEqual = (a: (Element | null)[], b: (Element | null)[]): boolean =>\n\ta.length === b.length && a.every((el, i) => el === b[i]);\n\nexport type FocusOnInitPosition = 'first' | 'last';\nexport interface RovingPropTypes {\n\t/** CSS selector of the element that starts as the tab stop, for example a checked custom radio. Falls back to `[data-roving-active]`, then to the first `[data-roving]` element. */\n\tactiveSelector?: string;\n\t/**\n\t * If true, disabled elements (with disabled attribute or aria-disabled=\"true\")\n\t * will be included in the roving tabindex. Defaults to true (disabled elements are included).\n\t */\n\tallowDisabled?: boolean;\n\tchildren: React.ReactNode;\n\t/**\n\t * delayMount is used to apply a delay to the mounting\n\t * of the RovingTabindex component. This can be helpful in\n\t * the event that a component's children have not been fully\n\t * rendered by the time the componentDidMount function is triggered\n\t */\n\tdelayMount?: number;\n\t/** Moves focus to the first or last element when the component mounts (after `delayMount`, if set). */\n\tfocusOnInit?: FocusOnInitPosition;\n\t/** Keeps every element out of the tab order until `isFocused` becomes true. For groups reached through a keyboard shortcut instead of Tab. */\n\tfocusWithShortcut?: boolean;\n\t/** Has no effect. Kept for backwards compatibility. */\n\tforceUpdate?: boolean;\n\t/** Set when another roving tabindex is nested inside this one, so its elements are left to the inner instance. */\n\thasChildRoving?: boolean;\n\t/** CSS selector. Keyboard navigation is ignored while focus is inside a matching element, for example a text input. */\n\tignoreElements?: string;\n\t/** With `focusWithShortcut`, whether the group holds focus. Turning it on focuses the active element; turning it off removes the group from the tab order. */\n\tisFocused?: boolean;\n\t/** Called when focus moves from the group to another element outside it. With `focusWithShortcut`, also called when `isFocused` turns off while focus is outside the group. */\n\tonBlur?: () => void;\n\t/** Pass it after moving focus into the group programmatically. On the next update the focused element becomes the tab stop and the callback receives `false`, so the consumer can drop it. */\n\tonRefocus?: (shouldRefocus: boolean) => void;\n\t/** Axis of the group, read once at mount. Every arrow key moves focus, but the keys across the axis are left to a focused element with `aria-haspopup=\"true\"` or role combobox, listbox or option. Defaults to horizontal. */\n\torientation?: RovingOrientation;\n\tqa?: string;\n}\n\ntype RovingOrientation = 'horizontal' | 'vertical';\ntype NavigationDirection = 'forward' | 'back';\n\n/**\n * Default value for allowDisabled prop.\n * When true, disabled elements are included in the roving tabindex navigation.\n */\nconst DEFAULT_ALLOW_DISABLED = true;\n\n/**\n * CSS selector to exclude disabled elements.\n * Excludes both native disabled attribute and ARIA-compliant disabled elements.\n */\nconst DISABLED_EXCLUSION = ':not([disabled]):not([aria-disabled=\"true\"])';\n\n/**\n * CSS selector suffix to exclude nested roving tabindex elements.\n * Prevents deeply nested elements from being included in parent roving tabindex.\n */\nconst NESTED_ROVING_EXCLUSION =\n\t':not(.helpers-roving-tabindex-container .helpers-roving-tabindex-container [data-roving])';\n\n/**\n * Builds the appropriate CSS selector based on configuration.\n * @param allowDisabled - Whether to include disabled elements in the roving tabindex\n * @param hasChildRoving - Whether nested roving tabindex containers should be excluded\n * @returns CSS selector string for querying roving elements\n */\nconst buildSelector = (allowDisabled: boolean, hasChildRoving: boolean): string => {\n\tconst disabledPart = allowDisabled ? '' : DISABLED_EXCLUSION;\n\tconst nestedPart = hasChildRoving ? NESTED_ROVING_EXCLUSION : '';\n\treturn `[data-roving]${disabledPart}${nestedPart}`;\n};\n\n/**\n * Component to create a Roving Tabindex in the DOM\n * @returns {HTMLDivElement}\n */\nclass MrlRovingTabindex extends React.Component<RovingPropTypes> {\n\telements: Array<Element | null>;\n\torientation: RovingOrientation;\n\tref!: HTMLDivElement | null;\n\tselector: string;\n\n\t/**\n\t * MrlRovingTabindex class constructor\n\t * @param props - the MrlRovingTabindex props\n\t * @returns new instance\n\t */\n\tconstructor(props: RovingPropTypes) {\n\t\tsuper(props);\n\n\t\tconst { allowDisabled = DEFAULT_ALLOW_DISABLED, hasChildRoving = false, orientation } = props;\n\n\t\tthis.elements = [];\n\t\tthis.orientation = orientation || 'horizontal';\n\t\tthis.selector = buildSelector(allowDisabled, hasChildRoving);\n\t}\n\n\t/**\n\t * Runs when the MrlRovingTabindex component mounts\n\t */\n\tcomponentDidMount(): void {\n\t\tconst { delayMount } = this.props;\n\t\tif (delayMount) {\n\t\t\tsetTimeout(() => this.mount(), delayMount);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.mount();\n\t}\n\n\t/**\n\t * Runs when the MrlRovingTabindex component unmounts\n\t */\n\tcomponentWillUnmount(): void {\n\t\t// Remove focus event listener\n\t\tif (this.ref) {\n\t\t\tthis.ref.removeEventListener('focusout', this.handleFocusOut);\n\t\t}\n\t}\n\n\t/**\n\t * Runs when the MrlRovingTabindex component updates\n\t * @param {RovingPropTypes} prevProps - the props before the component updated\n\t */\n\tcomponentDidUpdate(prevProps: RovingPropTypes): void {\n\t\tconst {\n\t\t\tallowDisabled = DEFAULT_ALLOW_DISABLED,\n\t\t\tchildren,\n\t\t\tfocusWithShortcut,\n\t\t\thasChildRoving = false,\n\t\t\tisFocused,\n\t\t\tonBlur,\n\t\t\tonRefocus\n\t\t} = this.props;\n\n\t\t/**\n\t\t * If allowDisabled or hasChildRoving prop changes, rebuild the selector\n\t\t * and re-scan for elements to reflect the new configuration.\n\t\t */\n\t\tif (prevProps.allowDisabled !== allowDisabled || prevProps.hasChildRoving !== hasChildRoving) {\n\t\t\tthis.selector = buildSelector(allowDisabled, hasChildRoving);\n\t\t\tthis.setElements();\n\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t}\n\n\t\t/**\n\t\t * If focus is programatically moved to the MrlRovingTabindex\n\t\t * component from outside of the MrlRovingTabindex, passing\n\t\t * the prop of `onRefocus` will cause the component to go\n\t\t * through and make sure that only the active element\n\t\t * has a tabindex set to 0.\n\t\t */\n\t\tif (onRefocus) {\n\t\t\tthis.handleRefocus();\n\t\t}\n\n\t\t/**\n\t\t * When children change, re-scan for elements and update tabindex values.\n\t\t * This ensures that dynamically added/removed buttons are properly managed.\n\t\t */\n\t\tif (prevProps.children !== children && !focusWithShortcut) {\n\t\t\tthis.setElements();\n\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t}\n\n\t\tif (focusWithShortcut) {\n\t\t\t/**\n\t\t\t * If the component within MrlRovingTabindex shows on the page before it should\n\t\t\t * be reached with a keyboard the prop `focusWithiShortcut` can be used to\n\t\t\t * achieve that. The conditions below handle the various states that a\n\t\t\t * component can experience under this scenario.\n\t\t\t */\n\t\t\tif (!isFocused && !prevProps.isFocused) {\n\t\t\t\t/**\n\t\t\t\t * The component was not focus before and is not ready to be focused on\n\t\t\t\t */\n\t\t\t\tthis.unsetTabbableElements();\n\t\t\t}\n\n\t\t\tif (prevProps.isFocused && !isFocused) {\n\t\t\t\t/**\n\t\t\t\t * The component was focused but is not focused anymore\n\t\t\t\t */\n\t\t\t\tthis.unsetTabbableElements();\n\t\t\t\t// Only call onBlur if focus has truly left the container\n\t\t\t\tif (this.ref && !this.ref.contains(document.activeElement)) {\n\t\t\t\t\tonBlur?.();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!prevProps.isFocused && isFocused) {\n\t\t\t\t/**\n\t\t\t\t * The component was not focused before and is ready to be focused\n\t\t\t\t */\n\t\t\t\tthis.setElements();\n\t\t\t\tthis.setElementFocus(this.getActiveElement());\n\t\t\t}\n\n\t\t\tif (prevProps.children !== children && !isFocused && !prevProps.isFocused) {\n\t\t\t\t/**\n\t\t\t\t * Children changed but component is not focused\n\t\t\t\t * Ensure all new elements have tabindex=-1 to prevent Tab key access\n\t\t\t\t */\n\t\t\t\tthis.setElements();\n\t\t\t\tthis.unsetTabbableElements();\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tprevProps.children !== children &&\n\t\t\t\tprevProps.isFocused &&\n\t\t\t\tisFocused &&\n\t\t\t\t!this.ref?.contains(document.activeElement)\n\t\t\t) {\n\t\t\t\t/**\n\t\t\t\t * While the component was focused an action was performed that\n\t\t\t\t * changed the elements of the component and focus was moved to\n\t\t\t\t * a different element on the page\n\t\t\t\t */\n\t\t\t\tthis.setElements();\n\t\t\t\tthis.setActiveElement(this.getActiveElement());\n\n\t\t\t\tif (this.getActiveElement()) {\n\t\t\t\t\t/**\n\t\t\t\t\t * The active element is still within the roving tabindex so focus\n\t\t\t\t\t * on the element that should receive focus\n\t\t\t\t\t */\n\t\t\t\t\tthis.setElementFocus(this.getActiveElement());\n\t\t\t\t} else {\n\t\t\t\t\t/**\n\t\t\t\t\t * The active element has been moved outside of the MrlRovingTabindex\n\t\t\t\t\t * component so reset the component\n\t\t\t\t\t */\n\t\t\t\t\t// Only call onBlur if focus has truly left the container\n\t\t\t\t\tif (this.ref && !this.ref.contains(document.activeElement)) {\n\t\t\t\t\t\tonBlur?.();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\thandleRef = (ref: HTMLDivElement): HTMLDivElement => {\n\t\tthis.ref = ref;\n\t\t// Set up focus listener when ref becomes available\n\t\tif (ref) {\n\t\t\tref.addEventListener('focusout', this.handleFocusOut);\n\t\t}\n\t\treturn ref;\n\t};\n\n\t/**\n\t * Handles focus out events to detect when focus leaves the roving tabindex container\n\t * @param {FocusEvent} event - the focus out event\n\t * @returns {void}\n\t */\n\thandleFocusOut = (event: FocusEvent): void => {\n\t\tconst { onBlur } = this.props;\n\t\tconst relatedTarget = (event as FocusEvent & { relatedTarget?: HTMLElement }).relatedTarget;\n\n\t\t// Check if focus is moving to an element outside the container\n\t\tif (relatedTarget && !this.ref?.contains(relatedTarget)) {\n\t\t\t// Focus has moved from inside the container to outside\n\t\t\tonBlur?.();\n\t\t}\n\t};\n\n\t/**\n\t * Sets component array of elements\n\t * @returns {void}\n\t */\n\tsetElements = (): void => {\n\t\tif (!this.ref) return;\n\t\tthis.elements = getTabbableElements(this.ref, this.selector);\n\t};\n\n\t/**\n\t * Queries for a single element matching the selector within the container.\n\t * @param selector - CSS selector to query\n\t * @returns The matching element or null\n\t */\n\tqueryElement = (selector: string): HTMLElement | null => {\n\t\treturn this.ref?.querySelector(selector) as HTMLElement | null;\n\t};\n\n\t/**\n\t * Gets the active element based on priority order:\n\t * 1. Element matching the custom `activeSelector` prop (e.g., custom radio elements)\n\t * 2. Element with `data-roving-active` attribute (programmatically set active)\n\t * 3. First element with `data-roving` attribute (default fallback)\n\t *\n\t * Disabled elements are excluded unless `allowDisabled` is true.\n\t * @returns The active HTML element, or undefined if none found\n\t */\n\tgetActiveElement = (): HTMLElement | undefined => {\n\t\tconst { activeSelector, allowDisabled = DEFAULT_ALLOW_DISABLED } = this.props;\n\t\tconst disabledFilter = allowDisabled ? '' : DISABLED_EXCLUSION;\n\n\t\t// Priority 1: Custom active selector (e.g., for radio button groups)\n\t\t// An element with the matching activeSelector prop (example usage: custom radio elements)\n\t\tif (activeSelector) {\n\t\t\tconst customActiveElement = this.queryElement(\n\t\t\t\t`${activeSelector}[data-roving]${disabledFilter}`\n\t\t\t);\n\t\t\tif (customActiveElement) return customActiveElement;\n\t\t}\n\n\t\t// Priority 2: Programmatically marked active element\n\t\t// An element with a `data-roving-active` attribute, indicating the current active element\n\t\tconst markedActiveElement = this.queryElement(\n\t\t\t`[data-roving][data-roving-active]${disabledFilter}`\n\t\t);\n\t\tif (markedActiveElement) return markedActiveElement;\n\n\t\t// Priority 3: First roving element (uses pre-built selector with disabled handling)\n\t\t// If no active element is found, the first instance of an element with `data-roving=\"true\"`\n\t\tconst firstRovingElement = this.ref?.querySelectorAll(this.selector)[0];\n\t\treturn firstRovingElement as HTMLElement | undefined;\n\t};\n\n\t/**\n\t * Sets an element to `tabindex=0` and sets all other elements to `tabindex=-1`\n\t * @param {HTMLElement | undefined} el - the element to set as active\n\t * @returns {void}\n\t */\n\tsetActiveElement = (el: HTMLElement | undefined): void => {\n\t\tif (!el) return;\n\n\t\tthis.unsetTabbableElements();\n\t\tel.setAttribute('tabindex', '0');\n\t};\n\n\t/**\n\t * Sets focus to a specific element\n\t * @param {HTMLElement | undefined} el - the element to set in focus\n\t * @returns {void}\n\t */\n\tsetElementFocus = (el: HTMLElement | undefined): void => {\n\t\tif (!el) return;\n\n\t\t/**\n\t\t * Why data-roving-active?\n\t\t *\n\t\t * We only want to set data-roving-active when 'setElementFocus' is triggered because we don't want [tabindex=0] to be mutally exclusive with\n\t\t * [data-roving-active]. An item with [data-roving-active] can exist without having [tabindex=0] and vice versa. We only want to set [data-roving-active]\n\t\t * intentionally when a user action has occured to change it. Such as a keyboard event or moving focus manually with Javascript.\n\t\t */\n\t\tconst current = this.getActiveElement();\n\t\tif (current) current.removeAttribute('data-roving-active');\n\t\tel.setAttribute('data-roving-active', 'true');\n\n\t\tthis.setActiveElement(el);\n\t\tel.focus();\n\t};\n\n\t/**\n\t * Sets focus to an element based on a direction (`forward` or `back`)\n\t * Disabled elements are already excluded from this.elements via CSS selector\n\t * @param {NavigationDirection} direction 'forward' | 'back'\n\t * @returns {void}\n\t */\n\tsetFocusByDirection = (direction: NavigationDirection): void => {\n\t\tconst itemsLen = this.elements.length;\n\n\t\tif (itemsLen > 0) {\n\t\t\tconst currentIndex = this.elements.indexOf(document.activeElement);\n\n\t\t\tconst directionSum = direction === 'back' ? -1 : 1;\n\t\t\tlet nextIndex = currentIndex + directionSum;\n\n\t\t\tif (direction === 'back') {\n\t\t\t\tnextIndex = nextIndex < 0 ? itemsLen - 1 : nextIndex;\n\t\t\t}\n\n\t\t\tif (direction === 'forward') {\n\t\t\t\tnextIndex = nextIndex >= itemsLen ? 0 : nextIndex;\n\t\t\t}\n\n\t\t\tthis.setElementFocus(this.elements[nextIndex] as HTMLElement);\n\t\t}\n\t};\n\n\t/**\n\t * Sets all tabindex for elements of this component to -1\n\t * Also ensures disabled elements (excluded from roving tabindex) have tabindex=-1\n\t * @returns {void}\n\t */\n\tunsetTabbableElements = (): void => {\n\t\tif (!this.elements) return;\n\n\t\t// Set tabindex=-1 for all roving tabindex elements\n\t\tthis.elements.forEach((el: Element | null) => {\n\t\t\tel && el.setAttribute('tabindex', '-1');\n\t\t});\n\n\t\t// Also set tabindex=-1 for disabled elements that are excluded from roving tabindex\n\t\t// This ensures disabled elements are not tabbable even though they're not in the navigation order\n\t\tif (!this.ref || this.props.allowDisabled) return;\n\n\t\tconst disabledElements = this.ref.querySelectorAll(\n\t\t\t`[data-roving][disabled], [data-roving][aria-disabled=\"true\"]`\n\t\t);\n\t\tdisabledElements.forEach((el) => {\n\t\t\tel.setAttribute('tabindex', '-1');\n\t\t});\n\t};\n\n\t/**\n\t * Will return `false` if the orientation param matches the\n\t * orientation of the component and the actively focused element has a menu or select\n\t * @param orientation : 'horizontal' | 'vertical'\n\t * @returns boolean\n\t */\n\tcanUseArrows = (orientation: RovingOrientation): boolean => {\n\t\tconst { activeElement } = document;\n\t\tconst role = activeElement?.getAttribute('role');\n\t\tconst hasMenuOrSelect =\n\t\t\tactiveElement?.getAttribute('aria-haspopup') === 'true' ||\n\t\t\trole === 'combobox' ||\n\t\t\trole === 'option' ||\n\t\t\trole === 'listbox';\n\n\t\treturn !(this.orientation === orientation && hasMenuOrSelect);\n\t};\n\n\thandleKeyUp = (e: React.KeyboardEvent): void => {\n\t\tconst { ignoreElements } = this.props;\n\t\tconst allowKeyPress = !ignoreElements ? true : !document.activeElement?.closest(ignoreElements);\n\n\t\tconst modifierPressed = e.ctrlKey || e.metaKey || e.shiftKey;\n\n\t\tif (modifierPressed) return;\n\n\t\t/**\n\t\t * If elements within MrlRovingTabindex are added after the component mounts\n\t\t * they will not automatically be a `part of this.elements`. This checks if\n\t\t * `this.elements` contains all elements that MrlRovingTabindex should be aware\n\t\t * of and will update `this.elements` if neccessary.\n\t\t */\n\t\tconst knownTabbableElements = this.elements;\n\t\tconst allTabbableElements = getTabbableElements(this.ref, this.selector);\n\n\t\tif (\n\t\t\tknownTabbableElements.length !== allTabbableElements.length ||\n\t\t\t!arraysEqual(knownTabbableElements, allTabbableElements)\n\t\t) {\n\t\t\tthis.setElements();\n\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t}\n\n\t\tconst isActiveRoving = this.getActiveElement() === document.activeElement;\n\n\t\tif (allowKeyPress && isActiveRoving) {\n\t\t\te.stopPropagation();\n\t\t\tswitch (e.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tif (this.canUseArrows('horizontal')) this.setFocusByDirection('forward');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tif (this.canUseArrows('horizontal')) this.setFocusByDirection('back');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\tif (this.canUseArrows('vertical')) this.setFocusByDirection('forward');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tif (this.canUseArrows('vertical')) this.setFocusByDirection('back');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'End':\n\t\t\t\t\tthis.handleFocusedLast();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'Home':\n\t\t\t\t\tthis.handleFocusedFirst();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\thandleFocusedFirst = (): void => this.setElementFocus(this.elements[0] as HTMLElement);\n\n\thandleFocusedLast = (): void =>\n\t\tthis.setElementFocus(this.elements[this.elements.length - 1] as HTMLElement);\n\n\thandleRefocus = (): void => {\n\t\tthis.setActiveElement(document.activeElement as HTMLElement);\n\t\tthis.props.onRefocus?.(false);\n\t};\n\n\t/**\n\t * Mounts the MrlRovingTabindex component\n\t * @returns {void}\n\t */\n\tmount(): void {\n\t\tconst { focusOnInit, focusWithShortcut, isFocused } = this.props;\n\n\t\tif (!focusWithShortcut) {\n\t\t\t// get initial set of elements for the component\n\t\t\tthis.setElements();\n\n\t\t\t// sets the first element of the component to tabindex=0 but does not move focus\n\t\t\t// this allows users to tab to the component naturally based on tab order\n\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t} else {\n\t\t\t// When focusWithShortcut is true, we need to set up elements\n\t\t\t// but only set tabindex values based on isFocused state\n\t\t\tthis.setElements();\n\n\t\t\tif (!isFocused) {\n\t\t\t\t// If not focused initially, set all elements to tabindex=-1\n\t\t\t\tthis.unsetTabbableElements();\n\t\t\t} else {\n\t\t\t\t// If focused initially, set the active element properly\n\t\t\t\tthis.setActiveElement(this.getActiveElement());\n\t\t\t}\n\t\t}\n\n\t\tif (focusOnInit && this.elements.length > 0) {\n\t\t\tif (focusOnInit === 'first') {\n\t\t\t\tthis.handleFocusedFirst();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.handleFocusedLast();\n\t\t}\n\t}\n\n\t/**\n\t * Renders the MrlRovingTabindex component\n\t * @returns {HTMLDivElement} - the rendered MrlRovingTabindex component\n\t */\n\trender(): JSX.Element {\n\t\t/* eslint-disable @typescript-eslint/no-unused-vars */\n\t\t// Destructure component-specific props to prevent them from being spread to the DOM\n\t\tconst {\n\t\t\tactiveSelector,\n\t\t\tallowDisabled,\n\t\t\tchildren,\n\t\t\tdelayMount,\n\t\t\tfocusOnInit,\n\t\t\tfocusWithShortcut,\n\t\t\tforceUpdate,\n\t\t\thasChildRoving,\n\t\t\tignoreElements,\n\t\t\tisFocused,\n\t\t\tonBlur,\n\t\t\tonRefocus,\n\t\t\torientation,\n\t\t\tqa,\n\t\t\t...rest\n\t\t} = this.props;\n\t\t/* eslint-enable @typescript-eslint/no-unused-vars */\n\n\t\tconst dataQa = `${qa || 'generic'}-roving`;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tclassName=\"helpers-roving-tabindex-container\"\n\t\t\t\tdata-qa={dataQa}\n\t\t\t\tonKeyUp={this.handleKeyUp}\n\t\t\t\tref={this.handleRef}\n\t\t\t\trole=\"presentation\"\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n\t\t\t\ttabIndex={-1}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport { MrlRovingTabindex };\n"],"names":["getTabbableElements","ref","selector","elements","querySelectorAll","Array","prototype","slice","call","arraysEqual","a","b","length","every","el","i","DEFAULT_ALLOW_DISABLED","DISABLED_EXCLUSION","NESTED_ROVING_EXCLUSION","buildSelector","allowDisabled","hasChildRoving","disabledPart","nestedPart","concat","MrlRovingTabindex","React","Component","constructor","props","_defineProperty","addEventListener","handleFocusOut","event","_this$ref","onBlur","relatedTarget","contains","_this$ref2","querySelector","_this$ref3","_this$props","activeSelector","_this$props$allowDisa","disabledFilter","customActiveElement","queryElement","markedActiveElement","firstRovingElement","unsetTabbableElements","setAttribute","current","getActiveElement","removeAttribute","setActiveElement","focus","direction","itemsLen","currentIndex","indexOf","document","activeElement","directionSum","nextIndex","setElementFocus","forEach","disabledElements","orientation","_document","role","getAttribute","hasMenuOrSelect","e","_document$activeEleme","ignoreElements","allowKeyPress","closest","modifierPressed","ctrlKey","metaKey","shiftKey","knownTabbableElements","allTabbableElements","setElements","isActiveRoving","stopPropagation","key","canUseArrows","setFocusByDirection","handleFocusedLast","handleFocusedFirst","_this$props$onRefocus","_this$props2","onRefocus","_props$allowDisabled","_props$hasChildRoving","componentDidMount","delayMount","setTimeout","mount","componentWillUnmount","removeEventListener","componentDidUpdate","prevProps","_this$props3","_this$props3$allowDis","children","focusWithShortcut","_this$props3$hasChild","isFocused","handleRefocus","_this$ref4","_this$props4","focusOnInit","render","_this$props5","forceUpdate","qa","rest","_objectWithoutProperties","_excluded","dataQa","createElement","_extends","className","onKeyUp","handleKeyUp","handleRef","tabIndex"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;AACA;AACA;AACA;AACA;AACA;IACaA,mBAAmB,GAAGA,CAACC,GAAY,EAAEC,QAAgB,KAAoB;EACrF,IAAMC,QAAQ,GAAGF,GAAG,KAAA,IAAA,IAAHA,GAAG,KAAA,MAAA,GAAA,MAAA,GAAHA,GAAG,CAAEG,gBAAgB,CAACF,QAAQ,CAAC;AAChD,EAAA,IAAI,CAACC,QAAQ,EAAE,OAAO,EAAE;EACxB,OAAOE,KAAK,CAACC,SAAS,CAACC,KAAK,CAACC,IAAI,CAACL,QAAQ,CAAC;AAC5C;AAEA,IAAMM,WAAW,GAAGA,CAACC,CAAqB,EAAEC,CAAqB,KAChED,CAAC,CAACE,MAAM,KAAKD,CAAC,CAACC,MAAM,IAAIF,CAAC,CAACG,KAAK,CAAC,CAACC,EAAE,EAAEC,CAAC,KAAKD,EAAE,KAAKH,CAAC,CAACI,CAAC,CAAC,CAAC;AA2CzD;AACA;AACA;AACA;AACA,IAAMC,sBAAsB,GAAG,IAAI;;AAEnC;AACA;AACA;AACA;AACA,IAAMC,kBAAkB,GAAG,8CAA8C;;AAEzE;AACA;AACA;AACA;AACA,IAAMC,uBAAuB,GAC5B,2FAA2F;;AAE5F;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,aAAa,GAAGA,CAACC,aAAsB,EAAEC,cAAuB,KAAa;AAClF,EAAA,IAAMC,YAAY,GAAGF,aAAa,GAAG,EAAE,GAAGH,kBAAkB;AAC5D,EAAA,IAAMM,UAAU,GAAGF,cAAc,GAAGH,uBAAuB,GAAG,EAAE;AAChE,EAAA,OAAA,eAAA,CAAAM,MAAA,CAAuBF,YAAY,CAAA,CA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QAAQ,EAAE;AAAG,KAAA,CAAA,EAEZtB,QACG,CAAC;AAER,EAAA;AACD;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlSvg.js","sources":["../../../../../src/components/svg/MrlSvg/MrlSvg.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport {\n\tMrlComponentProps,\n\ttype AttrsObject,\n\tisObject,\n\tgetCamelCase,\n\tgetUniqueId,\n\tsetAttributes\n} from '../../../utils';\nimport { svgDefaults, SVGSize, SVGObject } from '../constants';\nimport styles from './MrlSvg.module.scss';\n\nexport type DSIcons = typeof import('@muraldevkit/ds-icons');\nexport type DSPictograms = typeof import('@muraldevkit/ds-pictograms');\nexport type DSIconType = DSIcons[keyof DSIcons] | DSPictograms[keyof DSPictograms];\n\n// If we dont omit style from MrlComponentProps and re-add it in SvgPropTypes, we get an error.\nexport interface SvgPropTypes\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tOmit<React.ComponentProps<'svg'>, 'ref'> {\n\t/** Any additional classes to style the SVG's container */\n\tclassName?: string;\n\t/**\n\t * URL path to a static SVG file. Must provide either path or svg prop.\n\t */\n\tpath?: string;\n\t/** Enable lazy loading when a path is provided. */\n\tlazyLoad?: boolean;\n\tisClone?: boolean;\n\t/** The size of an SVG Component */\n\tsize?: SVGSize;\n\t/**\n\t * A object of CSS properties. Please use style sparingly, and only in cases where your\n\t * needs can not be met by passing a class to the component.\n\t */\n\tstyle?: Record<string, unknown>;\n\t/** The SVG object to parse into an HTML SVG element. Must provide either path or svg prop. */\n\tsvg?: DSIconType;\n}\n\n/**\n * Creating and exporting component class for Mural SVG\n *\n * Supports both static SVG objects and dynamic URL loading.\n *\n * @param {SvgPropTypes} props the props for your MrlSvg\n * @returns {React.ReactElement} a rendered SVG\n */\nexport const MrlSvg = React.memo((props: SvgPropTypes): React.ReactElement => {\n\tconst {\n\t\tclassName,\n\t\tsize = 'medium',\n\t\tsvg,\n\t\tpath,\n\t\tattrs = {},\n\t\tisClone = false,\n\t\tlazyLoad,\n\t\t...remainingProps\n\t} = props;\n\n\tconst GENERIC_WARNING_MESSAGE = 'There has been an issue rendering your SVG!';\n\n\t/**\n\t * Checks to ensure a string is valid JSON before parsing\n\t *\n\t * @param {Record<string, unknown>} svgData - the SVG code\n\t * @returns {boolean} - a boolean for whether or not the string is valid JSON\n\t */\n\tconst isValidJSON = (svgData: Record<string, unknown>): boolean => {\n\t\ttry {\n\t\t\tisObject(svgData);\n\t\t} catch (err) {\n\t\t\t// This is not valid JSON\n\t\t\tconsole.warn(`${GENERIC_WARNING_MESSAGE} Invalid SVG code:`);\n\t\t\tconsole.warn(svgData);\n\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Parses a JS Object of SVG code into an SVG HTML Element\n\t *\n\t * @param {SVGObject} svgObj - a JS object of SVG code\n\t * @param {AttrsObject} userAttributes - an optional set of attributes to be applied to the SVG\n\t * @param {string} classes - an optional object of classes to be applied to the SVG\n\t * @param {string} slot - an optional slot attribute for use in web components\n\t * @returns {React.ReactElement} - an SVG HTML Element\n\t */\n\tconst parseSVG = (\n\t\tsvgObj: SVGObject,\n\t\tuserAttributes = {},\n\t\tclasses?: string,\n\t\tslot?: string\n\t): React.ReactElement => {\n\t\tif (svgObj.type === 'text') {\n\t\t\treturn svgObj.value;\n\t\t}\n\n\t\tconst Tag = svgObj.name;\n\t\tconst tagAttributes = svgObj.attributes || {};\n\n\t\t/**\n\t\t * Formats SVG attributes to from kebab case to camel case for React syntax\n\t\t * Note: this excudes `data-` attributes\n\t\t *\n\t\t * @todo: Create react component for DS Icons and remove this code\n\t\t */\n\t\tObject.keys(tagAttributes).forEach((key) => {\n\t\t\tlet newKey = key;\n\t\t\tif (key === 'class') {\n\t\t\t\tnewKey = 'className';\n\t\t\t} else if (key.slice(0, 5) !== 'data-') {\n\t\t\t\tnewKey = getCamelCase(key);\n\t\t\t}\n\n\t\t\ttagAttributes[newKey] = tagAttributes[key];\n\n\t\t\tif (key !== newKey) {\n\t\t\t\tdelete tagAttributes[key];\n\t\t\t}\n\t\t});\n\n\t\t/**\n\t\t * We render the `svg` element explicitly here to ensure that the user applied\n\t\t * attributes and classes only get applied to the `svg` element.\n\t\t */\n\t\tif (Tag === 'svg') {\n\t\t\treturn (\n\t\t\t\t<span\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\tstyles.MrlSvgContainer,\n\t\t\t\t\t\tstyles[`MrlSvgContainer--${size}`],\n\t\t\t\t\t\t'MrlSvgContainer',\n\t\t\t\t\t\tclasses\n\t\t\t\t\t)}\n\t\t\t\t\tslot={slot}\n\t\t\t\t>\n\t\t\t\t\t<svg\n\t\t\t\t\t\t{...tagAttributes}\n\t\t\t\t\t\t{...userAttributes}\n\t\t\t\t\t\t{...remainingProps}\n\t\t\t\t\t\tclassName={cn(styles.MrlSvg, styles[`MrlSvg--${size}`], 'mrl-svg')}\n\t\t\t\t\t\tkey={getUniqueId()}\n\t\t\t\t\t>\n\t\t\t\t\t\t{Array.isArray(svgObj.children) &&\n\t\t\t\t\t\t\tsvgObj.children.map((child: Record<string, unknown>) => parseSVG(child))}\n\t\t\t\t\t</svg>\n\t\t\t\t</span>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<Tag {...tagAttributes} key={getUniqueId()}>\n\t\t\t\t{Array.isArray(svgObj.children) &&\n\t\t\t\t\tsvgObj.children.map((child: Record<string, unknown>) => parseSVG(child))}\n\t\t\t</Tag>\n\t\t);\n\t};\n\n\t// We do not want to re-render the icon if it's a cloned version\n\tif (isClone) {\n\t\treturn <span></span>;\n\t}\n\n\t// Validation: must provide either path or svg\n\tif (!path && !svg) {\n\t\tconsole.warn(`${GENERIC_WARNING_MESSAGE} Must provide either \"path\" or \"svg\" prop`);\n\t\treturn <span></span>;\n\t}\n\n\t// Validation: cannot provide both path and svg\n\tif (path && svg) {\n\t\tconsole.warn(\n\t\t\t`${GENERIC_WARNING_MESSAGE} Cannot provide both \"path\" and \"svg\" props. Using \"svg\" prop.`\n\t\t);\n\t}\n\n\t// Handle path prop with img tag (only if svg is not provided)\n\tif (path && !svg) {\n\t\treturn (\n\t\t\t<span\n\t\t\t\tclassName={cn(\n\t\t\t\t\tstyles.MrlSvgContainer,\n\t\t\t\t\tstyles[`MrlSvgContainer--${size}`],\n\t\t\t\t\t'MrlSvgContainer',\n\t\t\t\t\tclassName\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tsrc={path}\n\t\t\t\t\talt=\"\"\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName={cn(styles.MrlSvg, styles[`MrlSvg--${size}`], 'mrl-svg')}\n\t\t\t\t\tloading={lazyLoad ? 'lazy' : 'eager'}\n\t\t\t\t/>\n\t\t\t</span>\n\t\t);\n\t}\n\n\t// don't render if SVG value is not defined\n\tif (!svg) {\n\t\treturn <span></span>;\n\t}\n\n\tconst slot = attrs.slot;\n\tdelete attrs.slot;\n\n\tconst allClasses = cn(attrs.class, attrs.className, className);\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs, svgDefaults.attrs);\n\n\tconst isSvgString = typeof svg === 'string';\n\n\tlet svgObject: SVGObject;\n\n\tif (isSvgString) {\n\t\ttry {\n\t\t\tconst parsedSvg = JSON.parse(svg);\n\t\t\tif (!isValidJSON(parsedSvg)) {\n\t\t\t\treturn <span></span>;\n\t\t\t}\n\t\t\tsvgObject = parsedSvg;\n\t\t} catch (err) {\n\t\t\tconsole.warn(`${GENERIC_WARNING_MESSAGE} Invalid JSON in svg prop:`, err);\n\t\t\treturn <span></span>;\n\t\t}\n\t} else {\n\t\tsvgObject = svg;\n\t}\n\n\treturn parseSVG(svgObject, attributes, allClasses, slot);\n});\n\nMrlSvg.displayName = 'MrlSvg';\n"],"names":["MrlSvg","React","memo","props","className","_props$size","size","svg","path","_props$attrs","attrs","_props$isClone","isClone","lazyLoad","remainingProps","_objectWithoutProperties","_excluded","GENERIC_WARNING_MESSAGE","isValidJSON","svgData","isObject","err","console","warn","concat","parseSVG","svgObj","userAttributes","arguments","length","undefined","classes","slot","type","value","Tag","name","tagAttributes","attributes","Object","keys","forEach","key","newKey","slice","getCamelCase","createElement","cn","styles","MrlSvgContainer","_extends","getUniqueId","Array","isArray","children","map","child","src","alt","loading","allClasses","class","setAttributes","svgDefaults","isSvgString","svgObject","parsedSvg","JSON","parse","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,MAAM,gBAAGC,gBAAK,CAACC,IAAI,CAAEC,KAAmB,IAAyB;AAC7E,EAAA,IACCC,SAAS,GAQND,KAAK,CARRC,SAAS;IAAAC,WAAA,GAQNF,KAAK,CAPRG,IAAI;AAAJA,IAAAA,IAAI,GAAAD,WAAA,KAAA,MAAA,GAAG,QAAQ,GAAAA,WAAA;IACfE,GAAG,GAMAJ,KAAK,CANRI,GAAG;IACHC,IAAI,GAKDL,KAAK,CALRK,IAAI;IAAAC,YAAA,GAKDN,KAAK,CAJRO,KAAK;AAALA,IAAAA,KAAK,GAAAD,YAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,YAAA;IAAAE,cAAA,GAIPR,KAAK,CAHRS,OAAO;AAAPA,IAAAA,OAAO,GAAAD,cAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,cAAA;IACfE,QAAQ,GAELV,KAAK,CAFRU,QAAQ;AACLC,IAAAA,cAAc,GAAAC,iDAAA,CACdZ,KAAK,EAAAa,SAAA,CAAA;EAET,IAAMC,uBAAuB,GAAG,6CAA6C;;AAE7E;AACD;AACA;AACA;AACA;AACA;EACC,IAAMC,WAAW,GAAIC,OAAgC,IAAc;IAClE,IAAI;MACHC,iBAAQ,CAACD,OAAO,CAAC;IAClB,CAAC,CAAC,OAAOE,GAAG,EAAE;AACb;AACAC,MAAAA,OAAO,CAACC,IAAI,CAAA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sources":["../../../../../src/components/svg/MrlSvg/MrlSvg.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport {\n\tMrlComponentProps,\n\ttype AttrsObject,\n\tisObject,\n\tgetCamelCase,\n\tgetUniqueId,\n\tsetAttributes\n} from '../../../utils';\nimport { svgDefaults, SVGSize, SVGObject } from '../constants';\nimport styles from './MrlSvg.module.scss';\n\nexport type DSIcons = typeof import('@muraldevkit/ds-icons');\nexport type DSPictograms = typeof import('@muraldevkit/ds-pictograms');\nexport type DSIconType = DSIcons[keyof DSIcons] | DSPictograms[keyof DSPictograms];\n\n// If we dont omit style from MrlComponentProps and re-add it in SvgPropTypes, we get an error.\nexport interface SvgPropTypes\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tOmit<React.ComponentProps<'svg'>, 'ref'> {\n\t/** Any additional classes to style the SVG's container */\n\tclassName?: string;\n\t/**\n\t * URL path to a static SVG file. Must provide either path or svg prop.\n\t */\n\tpath?: string;\n\t/** Enable lazy loading when a path is provided. */\n\tlazyLoad?: boolean;\n\t/** Renders an empty span instead of the SVG. */\n\tisClone?: boolean;\n\t/** The size of an SVG Component */\n\tsize?: SVGSize;\n\t/**\n\t * A object of CSS properties. Please use style sparingly, and only in cases where your\n\t * needs can not be met by passing a class to the component.\n\t */\n\tstyle?: Record<string, unknown>;\n\t/** The SVG object to parse into an HTML SVG element. Must provide either path or svg prop. */\n\tsvg?: DSIconType;\n}\n\n/**\n * Creating and exporting component class for Mural SVG\n *\n * Supports both static SVG objects and dynamic URL loading.\n *\n * @param {SvgPropTypes} props the props for your MrlSvg\n * @returns {React.ReactElement} a rendered SVG\n */\nexport const MrlSvg = React.memo((props: SvgPropTypes): React.ReactElement => {\n\tconst {\n\t\tclassName,\n\t\tsize = 'medium',\n\t\tsvg,\n\t\tpath,\n\t\tattrs = {},\n\t\tisClone = false,\n\t\tlazyLoad,\n\t\t...remainingProps\n\t} = props;\n\n\tconst GENERIC_WARNING_MESSAGE = 'There has been an issue rendering your SVG!';\n\n\t/**\n\t * Checks to ensure a string is valid JSON before parsing\n\t *\n\t * @param {Record<string, unknown>} svgData - the SVG code\n\t * @returns {boolean} - a boolean for whether or not the string is valid JSON\n\t */\n\tconst isValidJSON = (svgData: Record<string, unknown>): boolean => {\n\t\ttry {\n\t\t\tisObject(svgData);\n\t\t} catch (err) {\n\t\t\t// This is not valid JSON\n\t\t\tconsole.warn(`${GENERIC_WARNING_MESSAGE} Invalid SVG code:`);\n\t\t\tconsole.warn(svgData);\n\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Parses a JS Object of SVG code into an SVG HTML Element\n\t *\n\t * @param {SVGObject} svgObj - a JS object of SVG code\n\t * @param {AttrsObject} userAttributes - an optional set of attributes to be applied to the SVG\n\t * @param {string} classes - an optional object of classes to be applied to the SVG\n\t * @param {string} slot - an optional slot attribute for use in web components\n\t * @returns {React.ReactElement} - an SVG HTML Element\n\t */\n\tconst parseSVG = (\n\t\tsvgObj: SVGObject,\n\t\tuserAttributes = {},\n\t\tclasses?: string,\n\t\tslot?: string\n\t): React.ReactElement => {\n\t\tif (svgObj.type === 'text') {\n\t\t\treturn svgObj.value;\n\t\t}\n\n\t\tconst Tag = svgObj.name;\n\t\tconst tagAttributes = svgObj.attributes || {};\n\n\t\t/**\n\t\t * Formats SVG attributes to from kebab case to camel case for React syntax\n\t\t * Note: this excudes `data-` attributes\n\t\t *\n\t\t * @todo: Create react component for DS Icons and remove this code\n\t\t */\n\t\tObject.keys(tagAttributes).forEach((key) => {\n\t\t\tlet newKey = key;\n\t\t\tif (key === 'class') {\n\t\t\t\tnewKey = 'className';\n\t\t\t} else if (key.slice(0, 5) !== 'data-') {\n\t\t\t\tnewKey = getCamelCase(key);\n\t\t\t}\n\n\t\t\ttagAttributes[newKey] = tagAttributes[key];\n\n\t\t\tif (key !== newKey) {\n\t\t\t\tdelete tagAttributes[key];\n\t\t\t}\n\t\t});\n\n\t\t/**\n\t\t * We render the `svg` element explicitly here to ensure that the user applied\n\t\t * attributes and classes only get applied to the `svg` element.\n\t\t */\n\t\tif (Tag === 'svg') {\n\t\t\treturn (\n\t\t\t\t<span\n\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\tstyles.MrlSvgContainer,\n\t\t\t\t\t\tstyles[`MrlSvgContainer--${size}`],\n\t\t\t\t\t\t'MrlSvgContainer',\n\t\t\t\t\t\tclasses\n\t\t\t\t\t)}\n\t\t\t\t\tslot={slot}\n\t\t\t\t>\n\t\t\t\t\t<svg\n\t\t\t\t\t\t{...tagAttributes}\n\t\t\t\t\t\t{...userAttributes}\n\t\t\t\t\t\t{...remainingProps}\n\t\t\t\t\t\tclassName={cn(styles.MrlSvg, styles[`MrlSvg--${size}`], 'mrl-svg')}\n\t\t\t\t\t\tkey={getUniqueId()}\n\t\t\t\t\t>\n\t\t\t\t\t\t{Array.isArray(svgObj.children) &&\n\t\t\t\t\t\t\tsvgObj.children.map((child: Record<string, unknown>) => parseSVG(child))}\n\t\t\t\t\t</svg>\n\t\t\t\t</span>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<Tag {...tagAttributes} key={getUniqueId()}>\n\t\t\t\t{Array.isArray(svgObj.children) &&\n\t\t\t\t\tsvgObj.children.map((child: Record<string, unknown>) => parseSVG(child))}\n\t\t\t</Tag>\n\t\t);\n\t};\n\n\t// We do not want to re-render the icon if it's a cloned version\n\tif (isClone) {\n\t\treturn <span></span>;\n\t}\n\n\t// Validation: must provide either path or svg\n\tif (!path && !svg) {\n\t\tconsole.warn(`${GENERIC_WARNING_MESSAGE} Must provide either \"path\" or \"svg\" prop`);\n\t\treturn <span></span>;\n\t}\n\n\t// Validation: cannot provide both path and svg\n\tif (path && svg) {\n\t\tconsole.warn(\n\t\t\t`${GENERIC_WARNING_MESSAGE} Cannot provide both \"path\" and \"svg\" props. Using \"svg\" prop.`\n\t\t);\n\t}\n\n\t// Handle path prop with img tag (only if svg is not provided)\n\tif (path && !svg) {\n\t\treturn (\n\t\t\t<span\n\t\t\t\tclassName={cn(\n\t\t\t\t\tstyles.MrlSvgContainer,\n\t\t\t\t\tstyles[`MrlSvgContainer--${size}`],\n\t\t\t\t\t'MrlSvgContainer',\n\t\t\t\t\tclassName\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<img\n\t\t\t\t\tsrc={path}\n\t\t\t\t\talt=\"\"\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName={cn(styles.MrlSvg, styles[`MrlSvg--${size}`], 'mrl-svg')}\n\t\t\t\t\tloading={lazyLoad ? 'lazy' : 'eager'}\n\t\t\t\t/>\n\t\t\t</span>\n\t\t);\n\t}\n\n\t// don't render if SVG value is not defined\n\tif (!svg) {\n\t\treturn <span></span>;\n\t}\n\n\tconst slot = attrs.slot;\n\tdelete attrs.slot;\n\n\tconst allClasses = cn(attrs.class, attrs.className, className);\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs, svgDefaults.attrs);\n\n\tconst isSvgString = typeof svg === 'string';\n\n\tlet svgObject: SVGObject;\n\n\tif (isSvgString) {\n\t\ttry {\n\t\t\tconst parsedSvg = JSON.parse(svg);\n\t\t\tif (!isValidJSON(parsedSvg)) {\n\t\t\t\treturn <span></span>;\n\t\t\t}\n\t\t\tsvgObject = parsedSvg;\n\t\t} catch (err) {\n\t\t\tconsole.warn(`${GENERIC_WARNING_MESSAGE} Invalid JSON in svg prop:`, err);\n\t\t\treturn <span></span>;\n\t\t}\n\t} else {\n\t\tsvgObject = svg;\n\t}\n\n\treturn parseSVG(svgObject, attributes, allClasses, slot);\n});\n\nMrlSvg.displayName = 'MrlSvg';\n"],"names":["MrlSvg","React","memo","props","className","_props$size","size","svg","path","_props$attrs","attrs","_props$isClone","isClone","lazyLoad","remainingProps","_objectWithoutProperties","_excluded","GENERIC_WARNING_MESSAGE","isValidJSON","svgData","isObject","err","console","warn","concat","parseSVG","svgObj","userAttributes","arguments","length","undefined","classes","slot","type","value","Tag","name","tagAttributes","attributes","Object","keys","forEach","key","newKey","slice","getCamelCase","createElement","cn","styles","MrlSvgContainer","_extends","getUniqueId","Array","isArray","children","map","child","src","alt","loading","allClasses","class","setAttributes","svgDefaults","isSvgString","svgObject","parsedSvg","JSON","parse","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,MAAM,gBAAGC,gBAAK,CAACC,IAAI,CAAEC,KAAmB,IAAyB;AAC7E,EAAA,IACCC,SAAS,GAQND,KAAK,CARRC,SAAS;IAAAC,WAAA,GAQNF,KAAK,CAPRG,IAAI;AAAJA,IAAAA,IAAI,GAAAD,WAAA,KAAA,MAAA,GAAG,QAAQ,GAAAA,WAAA;IACfE,GAAG,GAMAJ,KAAK,CANRI,GAAG;IACHC,IAAI,GAKDL,KAAK,CALRK,IAAI;IAAAC,YAAA,GAKDN,KAAK,CAJRO,KAAK;AAALA,IAAAA,KAAK,GAAAD,YAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,YAAA;IAAAE,cAAA,GAIPR,KAAK,CAHRS,OAAO;AAAPA,IAAAA,OAAO,GAAAD,cAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,cAAA;IACfE,QAAQ,GAELV,KAAK,CAFRU,QAAQ;AACLC,IAAAA,cAAc,GAAAC,iDAAA,CACdZ,KAAK,EAAAa,SAAA,CAAA;EAET,IAAMC,uBAAuB,GAAG,6CAA6C;;AAE7E;AACD;AACA;AACA;AACA;AACA;EACC,IAAMC,WAAW,GAAIC,OAAgC,IAAc;IAClE,IAAI;MACHC,iBAAQ,CAACD,OAAO,CAAC;IAClB,CAAC,CAAC,OAAOE,GAAG,EAAE;AACb;AACAC,MAAAA,OAAO,CAACC,IAAI,CAAA,EAAA,CAAAC,MAAA,CAAIP,uBAAuB,uBAAoB,CAAC;AAC5DK,MAAAA,OAAO,CAACC,IAAI,CAACJ,OAAO,CAAC;A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,IAAI;AAEjB,EAAA,IAAM4B,UAAU,GAAGb,2BAAE,CAACrC,KAAK,CAACmD,KAAK,EAAEnD,KAAK,CAACN,SAAS,EAAEA,SAAS,CAAC;EAC9D,OAAOM,KAAK,CAACmD,KAAK;EAClB,OAAOnD,KAAK,CAACN,SAAS;EAEtB,IAAMkC,UAAU,GAAGwB,2BAAa,CAACpD,KAAK,EAAEqD,qBAAW,CAACrD,KAAK,CAAC;AAE1D,EAAA,IAAMsD,WAAW,GAAG,OAAOzD,GAAG,KAAK,QAAQ;AAE3C,EAAA,IAAI0D,SAAoB;AAExB,EAAA,IAAID,WAAW,EAAE;IAChB,IAAI;AACH,MAAA,IAAME,SAAS,GAAGC,IAAI,CAACC,KAAK,CAAC7D,GAAG,CAAC;AACjC,MAAA,IAAI,CAACW,WAAW,CAACgD,SAAS,CAAC,EAAE;AAC5B,QAAA,oBAAOjE,gBAAA,CAAA6C,aAAA,CAAA,MAAA,EAAA,IAAY,CAAC;AACrB,MAAA;AACAmB,MAAAA,SAAS,GAAGC,SAAS;IACtB,CAAC,CAAC,OAAO7C,GAAG,EAAE;MACbC,OAAO,CAACC,IAAI,CAAA,EAAA,CAAAC,MAAA,CAAIP,uBAAuB,EAAA,4BAAA,CAAA,EAA8BI,GAAG,CAAC;AACzE,MAAA,oBAAOpB,gBAAA,CAAA6C,aAAA,CAAA,MAAA,EAAA,IAAY,CAAC;AACrB,IAAA;AACD,EAAA,CAAC,MAAM;AACNmB,IAAAA,SAAS,GAAG1D,GAAG;AAChB,EAAA;EAEA,OAAOkB,SAAQ,CAACwC,SAAS,EAAE3B,UAAU,EAAEsB,UAAU,EAAE5B,IAAI,CAAC;AACzD,CAAC;AAEDhC,MAAM,CAACqE,WAAW,GAAG,QAAQ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlTableCell.js","sources":["../../../../../src/components/table/MrlTableCell/MrlTableCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { getUniqueId } from '../../../utils';\nimport type { MrlTableColumnSticky } from '../MrlSmartTable';\n\nimport styles from './MrlTableCell.module.scss';\nimport { MrlTableCellHorizontalAlign } from '../constants';\n\nconst COMPONENT_NAME = 'MrlTableCell';\n\nexport interface MrlTableCellProps extends React.ComponentPropsWithoutRef<'td'> {\n\t/**\n\t * An element id (and if not provided, a unique value decorated\n\t * to prevent conflict with aria controls will be generated).\n\t *\n\t * @default `${id}-mrl-table-cell`\n\t */\n\tid?: string;\n\t/**\n\t * Whether this cell is sticky 'left' or sticky 'right' or not sticky at all\n\t */\n\tsticky?: MrlTableColumnSticky;\n\thasScrollShadowLeft?: boolean;\n\thasScrollShadowRight?: boolean;\n\thorizontalAlign?: MrlTableCellHorizontalAlign;\n}\n\n/**\n * MrlTableCell Component\n *\n * @param {MrlTableCellProps} props - MrlTableCell component props\n * @returns a table cell element\n */\nexport function MrlTableCell(props: MrlTableCellProps): JSX.Element {\n\tconst { hasScrollShadowLeft, hasScrollShadowRight, className, sticky, horizontalAlign, ...rest } =\n\t\tprops;\n\tconst idRef = React.useRef<string>(rest.id || getUniqueId('mrl-table-cell'));\n\tconst classes = classnames(className, COMPONENT_NAME, styles[COMPONENT_NAME], {\n\t\t[`${styles['sticky']} ${styles[`${sticky}`]}`]: !!sticky,\n\t\t[`${styles['align-right']}`]: horizontalAlign === 'right',\n\t\t[`${styles[`left-shadow`]}`]: sticky === 'left' && hasScrollShadowLeft,\n\t\t[`${styles[`right-shadow`]}`]: sticky === 'right' && hasScrollShadowRight\n\t});\n\treturn <td className={classes} id={idRef.current} data-sticky={!!sticky} {...rest} />;\n}\n"],"names":["COMPONENT_NAME","MrlTableCell","props","hasScrollShadowLeft","hasScrollShadowRight","className","sticky","horizontalAlign","rest","_objectWithoutProperties","_excluded","idRef","React","useRef","id","getUniqueId","classes","classnames","styles","concat","createElement","_extends","current"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAMA,cAAc,GAAG,cAAc;
|
|
1
|
+
{"version":3,"file":"MrlTableCell.js","sources":["../../../../../src/components/table/MrlTableCell/MrlTableCell.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { getUniqueId } from '../../../utils';\nimport type { MrlTableColumnSticky } from '../MrlSmartTable';\n\nimport styles from './MrlTableCell.module.scss';\nimport { MrlTableCellHorizontalAlign } from '../constants';\n\nconst COMPONENT_NAME = 'MrlTableCell';\n\nexport interface MrlTableCellProps extends React.ComponentPropsWithoutRef<'td'> {\n\t/**\n\t * An element id (and if not provided, a unique value decorated\n\t * to prevent conflict with aria controls will be generated).\n\t *\n\t * @default `${id}-mrl-table-cell`\n\t */\n\tid?: string;\n\t/**\n\t * Whether this cell is sticky 'left' or sticky 'right' or not sticky at all\n\t */\n\tsticky?: MrlTableColumnSticky;\n\t/** Draws the scroll shadow on a cell that is sticky 'left'. Set it while the content is scrolled away from the left edge. */\n\thasScrollShadowLeft?: boolean;\n\t/** Draws the scroll shadow on a cell that is sticky 'right'. Set it while more columns remain to the right. */\n\thasScrollShadowRight?: boolean;\n\t/** Horizontal alignment of the cell content. */\n\thorizontalAlign?: MrlTableCellHorizontalAlign;\n}\n\n/**\n * MrlTableCell Component\n *\n * @param {MrlTableCellProps} props - MrlTableCell component props\n * @returns a table cell element\n */\nexport function MrlTableCell(props: MrlTableCellProps): JSX.Element {\n\tconst { hasScrollShadowLeft, hasScrollShadowRight, className, sticky, horizontalAlign, ...rest } =\n\t\tprops;\n\tconst idRef = React.useRef<string>(rest.id || getUniqueId('mrl-table-cell'));\n\tconst classes = classnames(className, COMPONENT_NAME, styles[COMPONENT_NAME], {\n\t\t[`${styles['sticky']} ${styles[`${sticky}`]}`]: !!sticky,\n\t\t[`${styles['align-right']}`]: horizontalAlign === 'right',\n\t\t[`${styles[`left-shadow`]}`]: sticky === 'left' && hasScrollShadowLeft,\n\t\t[`${styles[`right-shadow`]}`]: sticky === 'right' && hasScrollShadowRight\n\t});\n\treturn <td className={classes} id={idRef.current} data-sticky={!!sticky} {...rest} />;\n}\n"],"names":["COMPONENT_NAME","MrlTableCell","props","hasScrollShadowLeft","hasScrollShadowRight","className","sticky","horizontalAlign","rest","_objectWithoutProperties","_excluded","idRef","React","useRef","id","getUniqueId","classes","classnames","styles","concat","createElement","_extends","current"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAMA,cAAc,GAAG,cAAc;AAsBrC;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAACC,KAAwB,EAAe;AACnE,EAAA,IAAQC,mBAAmB,GAC1BD,KAAK,CADEC,mBAAmB;IAAEC,oBAAoB,GAChDF,KAAK,CADuBE,oBAAoB;IAAEC,SAAS,GAC3DH,KAAK,CAD6CG,SAAS;IAAEC,MAAM,GACnEJ,KAAK,CADwDI,MAAM;IAAEC,eAAe,GACpFL,KAAK,CADgEK,eAAe;AAAKC,IAAAA,IAAI,GAAAC,iDAAA,CAC7FP,KAAK,EAAAQ,SAAA,CAAA;AACN,EAAA,IAAMC,KAAK,GAAGC,gBAAK,CAACC,MAAM,CAASL,IAAI,CAACM,EAAE,IAAIC,yBAAW,CAAC,gBAAgB,CAAC,CAAC;AAC5E,EAAA,IAAMC,OAAO,GAAGC,2BAAU,CAACZ,SAAS,EAAEL,cAAc,EAAEkB,2BAAM,CAAClB,cAAc,CAAC,EAAE;AAC7E,IAAA,CAAA,EAAA,CAAAmB,MAAA,CAAID,2BAAM,CAAC,QAAQ,CAAC,OAAAC,MAAA,CAAID,2BAAM,CAAA,EAAA,CAAAC,MAAA,CAAIb,MAAM,EAAG,CAAA,GAAK,CAAC,CAACA,MAAM;IACxD,CAAA,EAAA,CAAAa,MAAA,CAAID,2BAAM,CAAC,aAAa,CAAC,CAAA,GAAKX,eAAe,KAAK,OAAO;IACzD,CAAA,EAAA,CAAAY,MAAA,CAAID,2BAAM,CAAA,aAAA,CAAe,IAAKZ,MAAM,KAAK,MAAM,IAAIH,mBAAmB;IACtE,CAAA,EAAA,CAAAgB,MAAA,CAAID,2BAAM,CAAA,cAAA,CAAgB,IAAKZ,MAAM,KAAK,OAAO,IAAIF;AACtD,GAAC,CAAC;AACF,EAAA,oBAAOQ,gBAAA,CAAAQ,aAAA,CAAA,IAAA,EAAAC,iCAAA,CAAA;AAAIhB,IAAAA,SAAS,EAAEW,OAAQ;IAACF,EAAE,EAAEH,KAAK,CAACW,OAAQ;AAAC,IAAA,aAAA,EAAa,CAAC,CAAChB;GAAO,EAAKE,IAAI,CAAG,CAAC;AACtF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlTableColumn.js","sources":["../../../../../src/components/table/MrlTableColumn/MrlTableColumn.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { getUniqueId } from '../../../utils';\nimport type { MrlTableColumnSticky } from '../MrlSmartTable';\n\nimport styles from './MrlTableColumn.module.scss';\nimport { MrlTableCellHorizontalAlign } from '../constants';\n\nconst COMPONENT_NAME = 'MrlTableColumn';\n\nexport interface MrlTableColumnProps extends React.ComponentPropsWithoutRef<'th'> {\n\t/**\n\t * An element id (and if not provided, a unique value decorated\n\t * to prevent conflict with aria controls will be generated).\n\t *\n\t * @default `${id}-mrl-table-column`\n\t */\n\tid?: string;\n\t/**\n\t * Whether this column is sticky 'left' or sticky 'right' or not sticky at all\n\t */\n\tsticky?: MrlTableColumnSticky;\n\thasScrollShadowLeft?: boolean;\n\thasScrollShadowRight?: boolean;\n\thorizontalAlign?: MrlTableCellHorizontalAlign;\n}\n\n/**\n * MrlTableColumn Component\n *\n * @param {MrlTableColumnProps} props - MrlTableColumn component props\n * @returns a table column element\n */\nexport function MrlTableColumn(props: MrlTableColumnProps): JSX.Element {\n\tconst { hasScrollShadowLeft, hasScrollShadowRight, className, sticky, horizontalAlign, ...rest } =\n\t\tprops;\n\tconst idRef = React.useRef<string>(rest.id || getUniqueId('mrl-table-column'));\n\tconst classes = classnames(className, COMPONENT_NAME, styles[COMPONENT_NAME], {\n\t\t[styles['clickable']]: !!rest.onClick,\n\t\t[styles['align-right']]: horizontalAlign === 'right',\n\t\t[`${styles['sticky']} ${styles[`${sticky}`]}`]: !!sticky,\n\t\t[`${styles[`left-shadow`]}`]: sticky === 'left' && hasScrollShadowLeft,\n\t\t[`${styles[`right-shadow`]}`]: sticky === 'right' && hasScrollShadowRight\n\t});\n\treturn <th className={classes} id={idRef.current} data-sticky={!!sticky} {...rest} />;\n}\n"],"names":["COMPONENT_NAME","MrlTableColumn","props","hasScrollShadowLeft","hasScrollShadowRight","className","sticky","horizontalAlign","rest","_objectWithoutProperties","_excluded","idRef","React","useRef","id","getUniqueId","classes","classnames","styles","onClick","concat","createElement","_extends","current"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAMA,cAAc,GAAG,gBAAgB;
|
|
1
|
+
{"version":3,"file":"MrlTableColumn.js","sources":["../../../../../src/components/table/MrlTableColumn/MrlTableColumn.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { getUniqueId } from '../../../utils';\nimport type { MrlTableColumnSticky } from '../MrlSmartTable';\n\nimport styles from './MrlTableColumn.module.scss';\nimport { MrlTableCellHorizontalAlign } from '../constants';\n\nconst COMPONENT_NAME = 'MrlTableColumn';\n\nexport interface MrlTableColumnProps extends React.ComponentPropsWithoutRef<'th'> {\n\t/**\n\t * An element id (and if not provided, a unique value decorated\n\t * to prevent conflict with aria controls will be generated).\n\t *\n\t * @default `${id}-mrl-table-column`\n\t */\n\tid?: string;\n\t/**\n\t * Whether this column is sticky 'left' or sticky 'right' or not sticky at all\n\t */\n\tsticky?: MrlTableColumnSticky;\n\t/** Draws the scroll shadow on a header cell that is sticky 'left'. Set it while the content is scrolled away from the left edge. */\n\thasScrollShadowLeft?: boolean;\n\t/** Draws the scroll shadow on a header cell that is sticky 'right'. Set it while more columns remain to the right. */\n\thasScrollShadowRight?: boolean;\n\t/** Horizontal alignment of the header cell content. */\n\thorizontalAlign?: MrlTableCellHorizontalAlign;\n}\n\n/**\n * MrlTableColumn Component\n *\n * @param {MrlTableColumnProps} props - MrlTableColumn component props\n * @returns a table column element\n */\nexport function MrlTableColumn(props: MrlTableColumnProps): JSX.Element {\n\tconst { hasScrollShadowLeft, hasScrollShadowRight, className, sticky, horizontalAlign, ...rest } =\n\t\tprops;\n\tconst idRef = React.useRef<string>(rest.id || getUniqueId('mrl-table-column'));\n\tconst classes = classnames(className, COMPONENT_NAME, styles[COMPONENT_NAME], {\n\t\t[styles['clickable']]: !!rest.onClick,\n\t\t[styles['align-right']]: horizontalAlign === 'right',\n\t\t[`${styles['sticky']} ${styles[`${sticky}`]}`]: !!sticky,\n\t\t[`${styles[`left-shadow`]}`]: sticky === 'left' && hasScrollShadowLeft,\n\t\t[`${styles[`right-shadow`]}`]: sticky === 'right' && hasScrollShadowRight\n\t});\n\treturn <th className={classes} id={idRef.current} data-sticky={!!sticky} {...rest} />;\n}\n"],"names":["COMPONENT_NAME","MrlTableColumn","props","hasScrollShadowLeft","hasScrollShadowRight","className","sticky","horizontalAlign","rest","_objectWithoutProperties","_excluded","idRef","React","useRef","id","getUniqueId","classes","classnames","styles","onClick","concat","createElement","_extends","current"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAMA,cAAc,GAAG,gBAAgB;AAsBvC;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAACC,KAA0B,EAAe;AACvE,EAAA,IAAQC,mBAAmB,GAC1BD,KAAK,CADEC,mBAAmB;IAAEC,oBAAoB,GAChDF,KAAK,CADuBE,oBAAoB;IAAEC,SAAS,GAC3DH,KAAK,CAD6CG,SAAS;IAAEC,MAAM,GACnEJ,KAAK,CADwDI,MAAM;IAAEC,eAAe,GACpFL,KAAK,CADgEK,eAAe;AAAKC,IAAAA,IAAI,GAAAC,iDAAA,CAC7FP,KAAK,EAAAQ,SAAA,CAAA;AACN,EAAA,IAAMC,KAAK,GAAGC,gBA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