@muraldevkit/ui-toolkit 4.76.1 → 4.77.0
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/button/MrlButton/MrlButton.js +16 -8
- package/dist/cjs/components/button/MrlButton/MrlButton.js.map +1 -1
- package/dist/cjs/components/filter/MrlFilterItem/MrlFilterItem.js +2 -1
- package/dist/cjs/components/filter/MrlFilterItem/MrlFilterItem.js.map +1 -1
- package/dist/cjs/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map +1 -1
- package/dist/cjs/components/menu/MrlMenuGroup/MrlMenuGroup.js +4 -1
- package/dist/cjs/components/menu/MrlMenuGroup/MrlMenuGroup.js.map +1 -1
- package/dist/cjs/components/menu/MrlMenuItem/MrlMenuItem.js +2 -1
- package/dist/cjs/components/menu/MrlMenuItem/MrlMenuItem.js.map +1 -1
- package/dist/cjs/components/menu/MrlMenuItemLink/MrlMenuItemLink.js +8 -4
- package/dist/cjs/components/menu/MrlMenuItemLink/MrlMenuItemLink.js.map +1 -1
- package/dist/cjs/components/modal/MrlModalContent/MrlModalContent.js +1 -1
- package/dist/cjs/components/modal/MrlModalContent/MrlModalContent.js.map +1 -1
- package/dist/cjs/components/modal/MrlModalFooter/MrlModalFooter.js +2 -1
- package/dist/cjs/components/modal/MrlModalFooter/MrlModalFooter.js.map +1 -1
- package/dist/cjs/components/modal/MrlModalHeader/MrlModalHeader.js +1 -1
- package/dist/cjs/components/modal/MrlModalHeader/MrlModalHeader.js.map +1 -1
- package/dist/cjs/components/panel/MrlPanel/MrlPanel.js.map +1 -1
- package/dist/cjs/components/panel/MrlPanelFooter/MrlPanelFooter.js +2 -1
- package/dist/cjs/components/panel/MrlPanelFooter/MrlPanelFooter.js.map +1 -1
- package/dist/cjs/components/panel/MrlPanelStickyHeader/MrlPanelStickyHeader.js +2 -1
- package/dist/cjs/components/panel/MrlPanelStickyHeader/MrlPanelStickyHeader.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/components/button/MrlButton/MrlButton.d.ts +6 -0
- package/dist/components/filter/MrlFilterItem/MrlFilterItem.d.ts +6 -3
- package/dist/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.d.ts +10 -2
- package/dist/components/menu/MrlMenuGroup/MrlMenuGroup.d.ts +15 -1
- package/dist/components/menu/MrlMenuItem/MrlMenuItem.d.ts +14 -6
- package/dist/components/menu/MrlMenuItemLink/MrlMenuItemLink.d.ts +16 -7
- package/dist/components/modal/MrlModalContent/MrlModalContent.d.ts +5 -2
- package/dist/components/modal/MrlModalFooter/MrlModalFooter.d.ts +4 -2
- package/dist/components/modal/MrlModalHeader/MrlModalHeader.d.ts +4 -3
- package/dist/components/panel/MrlPanel/MrlPanel.d.ts +2 -1
- package/dist/components/panel/MrlPanelFooter/MrlPanelFooter.d.ts +6 -3
- package/dist/components/panel/MrlPanelStickyHeader/MrlPanelStickyHeader.d.ts +4 -2
- package/dist/esm/components/button/MrlButton/MrlButton.js +16 -8
- package/dist/esm/components/button/MrlButton/MrlButton.js.map +1 -1
- package/dist/esm/components/filter/MrlFilterItem/MrlFilterItem.js +2 -1
- package/dist/esm/components/filter/MrlFilterItem/MrlFilterItem.js.map +1 -1
- package/dist/esm/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map +1 -1
- package/dist/esm/components/menu/MrlMenuGroup/MrlMenuGroup.js +4 -1
- package/dist/esm/components/menu/MrlMenuGroup/MrlMenuGroup.js.map +1 -1
- package/dist/esm/components/menu/MrlMenuItem/MrlMenuItem.js +2 -1
- package/dist/esm/components/menu/MrlMenuItem/MrlMenuItem.js.map +1 -1
- package/dist/esm/components/menu/MrlMenuItemLink/MrlMenuItemLink.js +8 -4
- package/dist/esm/components/menu/MrlMenuItemLink/MrlMenuItemLink.js.map +1 -1
- package/dist/esm/components/modal/MrlModalContent/MrlModalContent.js +1 -1
- package/dist/esm/components/modal/MrlModalContent/MrlModalContent.js.map +1 -1
- package/dist/esm/components/modal/MrlModalFooter/MrlModalFooter.js +2 -1
- package/dist/esm/components/modal/MrlModalFooter/MrlModalFooter.js.map +1 -1
- package/dist/esm/components/modal/MrlModalHeader/MrlModalHeader.js +1 -1
- package/dist/esm/components/modal/MrlModalHeader/MrlModalHeader.js.map +1 -1
- package/dist/esm/components/panel/MrlPanel/MrlPanel.js.map +1 -1
- package/dist/esm/components/panel/MrlPanelFooter/MrlPanelFooter.js +2 -1
- package/dist/esm/components/panel/MrlPanelFooter/MrlPanelFooter.js.map +1 -1
- package/dist/esm/components/panel/MrlPanelStickyHeader/MrlPanelStickyHeader.js +2 -1
- package/dist/esm/components/panel/MrlPanelStickyHeader/MrlPanelStickyHeader.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/components/button/MrlButton/MrlButton.d.ts +6 -0
- package/dist/types/components/filter/MrlFilterItem/MrlFilterItem.d.ts +6 -3
- package/dist/types/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.d.ts +10 -2
- package/dist/types/components/menu/MrlMenuGroup/MrlMenuGroup.d.ts +15 -1
- package/dist/types/components/menu/MrlMenuItem/MrlMenuItem.d.ts +14 -6
- package/dist/types/components/menu/MrlMenuItemLink/MrlMenuItemLink.d.ts +16 -7
- package/dist/types/components/modal/MrlModalContent/MrlModalContent.d.ts +5 -2
- package/dist/types/components/modal/MrlModalFooter/MrlModalFooter.d.ts +4 -2
- package/dist/types/components/modal/MrlModalHeader/MrlModalHeader.d.ts +4 -3
- package/dist/types/components/panel/MrlPanel/MrlPanel.d.ts +2 -1
- package/dist/types/components/panel/MrlPanelFooter/MrlPanelFooter.d.ts +6 -3
- package/dist/types/components/panel/MrlPanelStickyHeader/MrlPanelStickyHeader.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlButton.js","sources":["../../../../../src/components/button/MrlButton/MrlButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tallowedButtonValues,\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tToggleAria,\n\tIconPosition\n} from '../constants';\nimport { _isDisabled, _isSelected, _spinnerProps } from '../helpers';\nimport { MrlSpinner } from '../../loader/MrlSpinner/MrlSpinner';\nimport { MrlTooltipAnchor, MrlTooltipPosition } from '../../tooltip/constants';\nimport { MrlTooltip } from '../../tooltip/MrlTooltip/MrlTooltip';\nimport { spinnerDefaults } from '../../loader/constants';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport './MrlButton.global.scss';\n\nexport type MrlButtonState = (typeof allowedButtonValues.states)[number];\nexport type ToggleStyle = (typeof allowedButtonValues.toggleStyles)[number];\n\nexport interface TooltipConfig {\n\t/**\n\t * The text to display in the tooltip\n\t */\n\ttext: string;\n\t/**\n\t * The position of the tooltip relative to the button\n\t */\n\tposition?: MrlTooltipPosition;\n\n\t/**\n\t * The anchor of the tooltip relative to the button\n\t */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * The data-qa attribute for the tooltip\n\t */\n\tdataQa?: string;\n}\n\nexport interface MrlButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t *\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\n\t/**\n\t * @deprecated - Use state=\"disabled\" or \"selected-disabled\" or \"skeleton\" instead.\n\t * Allow developers to change the disabled state based on user interactions.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\t/**\n\t * Allow developers to add icon to buttons.\n\t */\n\ticon?: React.ReactElement;\n\t/**\n\t * Allows developers to right-align an icon within a button.\n\t */\n\ticonPos?: IconPosition;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t */\n\tsize?: MrlButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'board-share-cta'). When omitted, the button emits no analytics.\n\t */\n\teventId?: string;\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n}\n\nexport const MrlButton = React.forwardRef<HTMLButtonElement, MrlButtonProps>(function MrlButton(\n\t{\n\t\tattrs,\n\t\tbadge,\n\t\tclassName,\n\t\tdisabled = buttonDefaults.disabled,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\ticonPos = buttonDefaults.iconPos,\n\t\tkind = buttonDefaults.kind,\n\t\tloading = false,\n\t\tloadingText = spinnerDefaults.text,\n\t\tonClick,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\teventId,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\ttooltip,\n\t\t...remainingProps\n\t}: MrlButtonProps,\n\tref\n) {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlButton', eventId);\n\n\t/**\n\t * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && allowedButtonValues.toggleStyles.includes(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(state));\n\t}, [state]);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || disabled || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\tif (isToggleButton) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'mrlButton',\n\t\t`mrlButton--${size}`,\n\t\t`mrlButton--${kind}`,\n\t\tstate === 'skeleton' && `mrlButton--skeleton`,\n\t\t!icon && loading && `mrlButton--loading`,\n\t\tisToggleButton && `toggleStyle--${toggleStyle}`,\n\t\ticon && `mrlButton--icon-${iconPos}`,\n\t\tclassName,\n\t\tattrs?.class || attrs?.className\n\t);\n\n\tif (attrs && attrs.class) delete attrs.class;\n\tif (attrs && attrs.className) delete attrs.className;\n\n\tconst spinnerProps = _spinnerProps(kind, size);\n\tconst spinner = (\n\t\t<MrlSpinner kind={spinnerProps.kind} role=\"none\" size={spinnerProps.size} text={loadingText} />\n\t);\n\n\tconst attributes = setAttributes(attrs || {}, {\n\t\t'aria-disabled': _isDisabled(state, loading) || disabled,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\trole: 'button',\n\t\ttype: 'button'\n\t});\n\n\tconst renderButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\t{...remainingProps}\n\t\t\tclassName={classNames}\n\t\t\tref={ref}\n\t\t\tonClick={handleOnClick}\n\t\t>\n\t\t\t{loading ? spinner : icon}\n\t\t\t<span className=\"mrlButton-text\">{text}</span>\n\t\t\t{badge}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderButton()}\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlButton","React","forwardRef","_ref","ref","attrs","badge","className","_ref$disabled","disabled","buttonDefaults","_ref$disableEvents","disableEvents","icon","_ref$iconPos","iconPos","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","_ref$toggleAria","toggleAria","toggleStyle","eventId","_ref$size","size","_ref$state","state","tooltip","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","isToggleButton","allowedButtonValues","toggleStyles","includes","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","classNames","classnames","concat","class","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","role","attributes","setAttributes","_objectSpread","type","renderButton","_extends","MrlTooltip","position","anchor","dataQa"],"mappings":";;;;;;;;;;;;AAsIO,IAAMA,SAAS,gBAAGC,KAAK,CAACC,UAAU,CAAoC,SAASF,SAASA,CAAAG,IAAA,EAsB9FC,GAAG,EACF;AAAA,EAAA,IArBAC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IAAAC,aAAA,GAAAL,IAAA,CACTM,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGE,cAAc,CAACD,QAAQ,GAAAD,aAAA;IAAAG,kBAAA,GAAAR,IAAA,CAClCS,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,kBAAA;IACrBE,IAAI,GAAAV,IAAA,CAAJU,IAAI;IAAAC,YAAA,GAAAX,IAAA,CACJY,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAGJ,cAAc,CAACK,OAAO,GAAAD,YAAA;IAAAE,SAAA,GAAAb,IAAA,CAChCc,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAGN,cAAc,CAACO,IAAI,GAAAD,SAAA;IAAAE,YAAA,GAAAf,IAAA,CAC1BgB,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,YAAA;IAAAE,gBAAA,GAAAjB,IAAA,CACfkB,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAA,MAAA,GAAGE,eAAe,CAACC,IAAI,GAAAH,gBAAA;I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AE,gBAEdvE,KAAA,CAAAgE,aAAA,CAACS,UAAU,EAAA;AACVC,IAAAA,QAAQ,EAAE1C,OAAO,CAAC0C,QAAQ,IAAI,QAAS;AACvCC,IAAAA,MAAM,EAAE3C,OAAO,CAAC2C,MAAM,IAAI,QAAS;IACnCrD,IAAI,EAAEU,OAAO,CAACV,IAAK;IACnBsD,MAAM,EAAE5C,OAAO,CAAC4C;GAAO,EAEtBL,YAAY,EACF,CACZ;AACF,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlButton.js","sources":["../../../../../src/components/button/MrlButton/MrlButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tallowedButtonValues,\n\tbuttonDefaults,\n\tMrlButtonKind,\n\tMrlButtonSize,\n\tToggleAria,\n\tIconPosition\n} from '../constants';\nimport { _isDisabled, _isSelected, _spinnerProps } from '../helpers';\nimport { MrlSpinner } from '../../loader/MrlSpinner/MrlSpinner';\nimport { MrlTooltipAnchor, MrlTooltipPosition } from '../../tooltip/constants';\nimport { MrlTooltip } from '../../tooltip/MrlTooltip/MrlTooltip';\nimport { spinnerDefaults } from '../../loader/constants';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport './MrlButton.global.scss';\n\nexport type MrlButtonState = (typeof allowedButtonValues.states)[number];\nexport type ToggleStyle = (typeof allowedButtonValues.toggleStyles)[number];\n\nexport interface TooltipConfig {\n\t/**\n\t * The text to display in the tooltip\n\t */\n\ttext: string;\n\t/**\n\t * The position of the tooltip relative to the button\n\t */\n\tposition?: MrlTooltipPosition;\n\n\t/**\n\t * The anchor of the tooltip relative to the button\n\t */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * The data-qa attribute for the tooltip\n\t */\n\tdataQa?: string;\n}\n\nexport interface MrlButtonProps\n\textends Omit<MrlComponentProps, 'style'>,\n\t\tReact.ComponentProps<'button'> {\n\t/**\n\t * Applies additional HTML attributes to the button element.\n\t *\n\t * @deprecated\n\t */\n\tattrs?: AttrsObject;\n\t/**\n\t * Allow developers to add badge to buttons.\n\t */\n\tbadge?: React.ReactElement;\n\n\t/**\n\t * @deprecated - Use state=\"disabled\" or \"selected-disabled\" or \"skeleton\" instead.\n\t * Allow developers to change the disabled state based on user interactions.\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * Allows developers the ability to disable built in event listeners so they can manage user\n\t * interactions from the application.\n\t */\n\tdisableEvents?: boolean;\n\t/**\n\t * Allow developers to add icon to buttons.\n\t */\n\ticon?: React.ReactElement;\n\t/**\n\t * Allows developers to right-align an icon within a button.\n\t */\n\ticonPos?: IconPosition;\n\t/**\n\t * Changes the visual emphasis of the button.\n\t */\n\tkind?: MrlButtonKind;\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\t/**\n\t * Changes the size of the button so it can scale with its surrounding context.\n\t */\n\tsize?: MrlButtonSize;\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\t/**\n\t * The textual label describing the button's purpose/action.\n\t * Icon buttons require a text label to ensure accessibility.\n\t */\n\ttext: string;\n\t/**\n\t * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'board-share-cta'). When omitted, the button emits no analytics.\n\t */\n\teventId?: string;\n\t/**\n\t * Determines which aria setup to use for various toggle/selected styles.\n\t * pressed - use for an traditional “toggle button”\n\t * selected - use for tabs and custom select options\n\t * expanded - use for menus, panels, and popovers\n\t * checked - use for custom [radiobutton](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton/#wai-aria-roles-states-and-properties-16)\n\t * \t\tor [checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/#wai-aria-roles-states-and-properties-5) inputs\n\t */\n\ttoggleAria?: ToggleAria;\n\n\t/**\n\t * Tooltip configuration for the button\n\t */\n\ttooltip?: TooltipConfig;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. The visual styles\n\t * are also impacted by the \"kind\" prop. Toggle buttons are only supported\n\t * when \"kind\" is set to either \"ghost\" or \"ghost-inverse\". Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\ttoggleStyle?: ToggleStyle;\n\n\t/**\n\t * Controlled state that overrides the internal state management.\n\t * When provided, this takes precedence over the `state` prop and allows\n\t * the parent component to fully control the button's state.\n\t */\n\tcontrolledState?: MrlButtonState;\n}\n\nexport const MrlButton = React.forwardRef<HTMLButtonElement, MrlButtonProps>(function MrlButton(\n\t{\n\t\tattrs,\n\t\tbadge,\n\t\tclassName,\n\t\tdisabled = buttonDefaults.disabled,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\ticonPos = buttonDefaults.iconPos,\n\t\tkind = buttonDefaults.kind,\n\t\tloading = false,\n\t\tloadingText = spinnerDefaults.text,\n\t\tonClick,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\teventId,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\ttooltip,\n\t\tcontrolledState,\n\t\t...remainingProps\n\t}: MrlButtonProps,\n\tref\n) {\n\t/**\n\t * Determine the effective button state.\n\t * Uses controlledState if provided (controlled mode),\n\t * otherwise falls back to the state prop (uncontrolled mode).\n\t * This allows the component to work in both controlled and uncontrolled scenarios.\n\t */\n\tconst effectiveButtonState = controlledState ?? state;\n\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(effectiveButtonState));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlButton', eventId);\n\n\t/**\n\t * MrlButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && allowedButtonValues.toggleStyles.includes(toggleStyle);\n\n\t/**\n\t * We need to watch the value of state to keep in sync\n\t * the value of state passed as props and the internal\n\t * isSelected piece of state.\n\t */\n\tReact.useEffect(() => {\n\t\t// allows consumers to set the 'selected' or 'selected-disabled' state from a parent component.\n\t\tsetIsSelected(_isSelected(effectiveButtonState));\n\t}, [effectiveButtonState]);\n\n\t/**\n\t * Handle onClick events\n\t *\n\t * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tfunction handleOnClick(e: React.MouseEvent<HTMLButtonElement>) {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(effectiveButtonState, loading) || disabled || disableEvents) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: kind });\n\n\t\tif (isToggleButton && !controlledState) {\n\t\t\tsetIsSelected((prevIsSelected) => !prevIsSelected);\n\t\t}\n\n\t\tif (onClick && typeof onClick === 'function') {\n\t\t\tonClick(e);\n\t\t}\n\t}\n\n\tconst classNames = classnames(\n\t\t'mrlButton',\n\t\t`mrlButton--${size}`,\n\t\t`mrlButton--${kind}`,\n\t\teffectiveButtonState === 'skeleton' && `mrlButton--skeleton`,\n\t\t!icon && loading && `mrlButton--loading`,\n\t\tisToggleButton && `toggleStyle--${toggleStyle}`,\n\t\ticon && `mrlButton--icon-${iconPos}`,\n\t\tclassName,\n\t\tattrs?.class || attrs?.className\n\t);\n\n\tif (attrs && attrs.class) delete attrs.class;\n\tif (attrs && attrs.className) delete attrs.className;\n\n\tconst spinnerProps = _spinnerProps(kind, size);\n\tconst spinner = (\n\t\t<MrlSpinner kind={spinnerProps.kind} role=\"none\" size={spinnerProps.size} text={loadingText} />\n\t);\n\n\tconst attributes = setAttributes(attrs || {}, {\n\t\t'aria-disabled': _isDisabled(effectiveButtonState, loading) || disabled,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\trole: 'button',\n\t\ttype: 'button'\n\t});\n\n\tconst renderButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\t{...remainingProps}\n\t\t\tclassName={classNames}\n\t\t\tref={ref}\n\t\t\tonClick={handleOnClick}\n\t\t>\n\t\t\t{loading ? spinner : icon}\n\t\t\t<span className=\"mrlButton-text\">{text}</span>\n\t\t\t{badge}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderButton()\n\t) : (\n\t\t<MrlTooltip\n\t\t\tposition={tooltip.position || 'bottom'}\n\t\t\tanchor={tooltip.anchor || 'center'}\n\t\t\ttext={tooltip.text}\n\t\t\tdataQa={tooltip.dataQa}\n\t\t>\n\t\t\t{renderButton()}\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlButton","React","forwardRef","_ref","ref","attrs","badge","className","_ref$disabled","disabled","buttonDefaults","_ref$disableEvents","disableEvents","icon","_ref$iconPos","iconPos","_ref$kind","kind","_ref$loading","loading","_ref$loadingText","loadingText","spinnerDefaults","text","onClick","_ref$toggleAria","toggleAria","toggleStyle","eventId","_ref$size","size","_ref$state","state","tooltip","controlledState","remainingProps","_objectWithoutProperties","_excluded","effectiveButtonState","_React$useState","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","isToggleButton","allowedButtonValues","toggleStyles","includes","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","classNames","classnames","concat","class","spinnerProps","_spinnerProps","spinner","createElement","MrlSpinner","role","attributes","setAttributes","_objectSpread","type","renderButton","_extends","MrlTooltip","position","anchor","dataQa"],"mappings":";;;;;;;;;;;;AA6IO,IAAMA,SAAS,gBAAGC,KAAK,CAACC,UAAU,CAAoC,SAASF,SAASA,CAAAG,IAAA,EAuB9FC,GAAG,EACF;AAAA,EAAA,IAtBAC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IAAAC,aAAA,GAAAL,IAAA,CACTM,QAAQ;AAARA,IAAA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@ -9,7 +9,8 @@ import { MrlBadge } from '../../badge/MrlBadge/MrlBadge.js';
|
|
|
9
9
|
|
|
10
10
|
var _excluded = ["data-qa", "id", "children", "className", "value", "count", "eventId"];
|
|
11
11
|
/**
|
|
12
|
-
* MrlFilterItem component.
|
|
12
|
+
* MrlFilterItem component. One option of an `MrlFilter`, rendered as a `radio` of the filter's
|
|
13
|
+
* radio group; must be rendered inside `MrlFilter`.
|
|
13
14
|
*
|
|
14
15
|
* @param props - The component props.
|
|
15
16
|
* @returns The MrlFilterItem component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlFilterItem.js","sources":["../../../../../src/components/filter/MrlFilterItem/MrlFilterItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport styles from './MrlFilterItem.module.scss';\nimport { DataQa } from '../../../utils/dataQa';\nimport { getUniqueId } from '../../../utils';\nimport { useMrlFilterContext } from '../MrlFilterContext';\nimport { MrlBadge } from '../../badge';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport type MrlFilterItemProps = {\n\t/**\n\t * The filter item's value.\n\t */\n\tvalue: string;\n\t/**\n\t * The content to be displayed within the filter item.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * The count of items for this filter option.\n\t */\n\tcount?: number;\n\t/**\n\t * Enables interaction tracking for this filter option. Provide a stable, non-PII id\n\t * (e.g. 'templates-category-filter'). When omitted, the option emits no analytics.\n\t *\n\t * Note: the option's value and content are never emitted.\n\t */\n\teventId?: string;\n} & React.ComponentPropsWithoutRef<'span'> &\n\tDataQa;\n\n/**\n * MrlFilterItem component
|
|
1
|
+
{"version":3,"file":"MrlFilterItem.js","sources":["../../../../../src/components/filter/MrlFilterItem/MrlFilterItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport styles from './MrlFilterItem.module.scss';\nimport { DataQa } from '../../../utils/dataQa';\nimport { getUniqueId } from '../../../utils';\nimport { useMrlFilterContext } from '../MrlFilterContext';\nimport { MrlBadge } from '../../badge';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport type MrlFilterItemProps = {\n\t/**\n\t * The filter item's value, reported to `MrlFilter` when the item is selected by click or by\n\t * arrow-key focus. The item is checked while it equals the filter's selected value.\n\t */\n\tvalue: string;\n\t/**\n\t * The content to be displayed within the filter item.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * The count of items for this filter option, shown as a badge and announced as \", N items\"\n\t * after the label.\n\t */\n\tcount?: number;\n\t/**\n\t * Enables interaction tracking for this filter option. Provide a stable, non-PII id\n\t * (e.g. 'templates-category-filter'). When omitted, the option emits no analytics.\n\t *\n\t * Note: the option's value and content are never emitted.\n\t */\n\teventId?: string;\n} & React.ComponentPropsWithoutRef<'span'> &\n\tDataQa;\n\n/**\n * MrlFilterItem component. One option of an `MrlFilter`, rendered as a `radio` of the filter's\n * radio group; must be rendered inside `MrlFilter`.\n *\n * @param props - The component props.\n * @returns The MrlFilterItem component.\n */\nexport function MrlFilterItem(props: MrlFilterItemProps): React.ReactElement {\n\tconst { ['data-qa']: dataQa, id, children, className, value, count, eventId, ...rest } = props;\n\n\tconst { state, dispatch } = useMrlFilterContext();\n\tconst trackInteraction = useMrlTrackInteraction('MrlFilterItem', eventId);\n\n\tfunction handleFilterChange() {\n\t\t// click also focuses the item, so only an actual change in selection is emitted.\n\t\t// the option's value is consumer data and is never emitted.\n\t\tif (state.checked !== value) {\n\t\t\ttrackInteraction({ action: 'select' });\n\t\t}\n\n\t\tdispatch({\n\t\t\tpayload: value,\n\t\t\ttype: 'SET_CHECKED'\n\t\t});\n\t}\n\n\tconst filterItemIdRef = React.useRef<string>(id || getUniqueId('mrl-filter-item'));\n\tconst isChecked = state.checked === value;\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/interactive-supports-focus, jsx-a11y/click-events-have-key-events\n\t\t<span\n\t\t\t{...rest}\n\t\t\tdata-qa={dataQa}\n\t\t\tdata-roving=\"true\"\n\t\t\tonClick={handleFilterChange}\n\t\t\tonFocus={handleFilterChange}\n\t\t\taria-checked={isChecked}\n\t\t\trole=\"radio\"\n\t\t\tid={filterItemIdRef.current}\n\t\t\tclassName={classnames(\n\t\t\t\tstyles['MrlFilterItem'],\n\t\t\t\t'MrlFilterItem',\n\t\t\t\t{\n\t\t\t\t\t[styles['MrlFilterItem-has-count']]: typeof count !== 'undefined'\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t>\n\t\t\t{children}\n\t\t\t{typeof count !== 'undefined' && (\n\t\t\t\t<MrlBadge text={String(count)} aria-label={`, ${count} items`} />\n\t\t\t)}\n\t\t</span>\n\t);\n}\n"],"names":["MrlFilterItem","props","dataQa","id","children","className","value","count","eventId","rest","_objectWithoutProperties","_excluded","_useMrlFilterContext","useMrlFilterContext","state","dispatch","trackInteraction","useMrlTrackInteraction","handleFilterChange","checked","action","payload","type","filterItemIdRef","React","useRef","getUniqueId","isChecked","createElement","_extends","onClick","onFocus","role","current","classnames","styles","MrlBadge","text","String","concat"],"mappings":";;;;;;;;;;AAkCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAACC,KAAyB,EAAsB;AAC5E,EAAA,IAAqBC,MAAM,GAA8DD,KAAK,CAArF,SAAS,CAAA;IAAWE,EAAE,GAA0DF,KAAK,CAAjEE,EAAE;IAAEC,QAAQ,GAAgDH,KAAK,CAA7DG,QAAQ;IAAEC,SAAS,GAAqCJ,KAAK,CAAnDI,SAAS;IAAEC,KAAK,GAA8BL,KAAK,CAAxCK,KAAK;IAAEC,KAAK,GAAuBN,KAAK,CAAjCM,KAAK;IAAEC,OAAO,GAAcP,KAAK,CAA1BO,OAAO;AAAKC,IAAAA,IAAI,GAAAC,wBAAA,CAAKT,KAAK,EAAAU,SAAA,CAAA;AAE9F,EAAA,IAAAC,oBAAA,GAA4BC,mBAAmB,EAAE;IAAzCC,KAAK,GAAAF,oBAAA,CAALE,KAAK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,MAAM,CAAC/B,KAAK,CAAE;MAAC,YAAA,EAAA,IAAA,CAAAgC,MAAA,CAAiBhC,KAAK,EAAA,QAAA;AAAS,KAAE,CAE5D;AAAC;AAET;;;;"}
|
package/dist/esm/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlCheckboxStandalone.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport { check, minus } from '@muraldevkit/ds-icons';\nimport { checkboxDefaults, CheckboxSelected, CheckboxStates } from '../../constants';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlCheckboxStandalone.module.scss';\nimport './MrlCheckboxStandalone.global.scss';\n\ninterface MrlCheckboxStandaloneProps {\n\t
|
|
1
|
+
{"version":3,"file":"MrlCheckboxStandalone.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport { check, minus } from '@muraldevkit/ds-icons';\nimport { checkboxDefaults, CheckboxSelected, CheckboxStates } from '../../constants';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlCheckboxStandalone.module.scss';\nimport './MrlCheckboxStandalone.global.scss';\n\ninterface MrlCheckboxStandaloneProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element. The component renders no label,\n\t * so label it here: an `id` referenced by a `<label htmlFor>`, or `aria-labelledby` pointing\n\t * to visible text (a console warning is logged when both are missing). Pass the `onChange`\n\t * handler here as well.\n\t */\n\tattrs?: AttrsObject;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/**\n\t * Sets what selection state the checkbox is in. The component is controlled: update it from\n\t * the `onChange` handler passed in `attrs`.\n\t */\n\tselected?: CheckboxSelected;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Input that allows the user to select one or more options from a provided list.\n * Note, this component does not provide out of the box accessibility for ensuring\n * an associated label and must be manually setup during adoption.\n * @param {MrlCheckboxStandaloneProps} props - the component props\n * @returns a checkbox element\n */\nexport function MrlCheckboxStandalone({\n\tattrs = {},\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\teventId,\n\t...rest\n}: MrlCheckboxStandaloneProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckboxStandalone', eventId);\n\t// Use attrs.id if the developer passes in a custom id\n\t// but we need to ensure one exists for accessibility\n\tconst checkboxIdRef = React.useRef<string>(attrs.id || getUniqueId('mrl-checkbox'));\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\n\tif (!(attrs.id || attrs['aria-labelledby'])) {\n\t\tconsole.warn(\n\t\t\t'Warning: Mural Standalone Checkboxes must have either an id or' +\n\t\t\t\t' aria-labelledby attribute for proper accessibility.'\n\t\t);\n\t}\n\n\t// We need to use the ref to set indetermiant attr\n\t// due to not being an intrinsic HTML attr\n\tReact.useEffect(() => {\n\t\tconst indeterminate = selected === 'indeterminate';\n\n\t\tif (inputRef.current) {\n\t\t\tinputRef.current.indeterminate = indeterminate;\n\t\t}\n\t}, [selected]);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs);\n\n\t// the consumer's handler arrives through `attrs`, so wrap it here rather than\n\t// relying on a top-level onChange prop.\n\tconst consumerOnChange = attributes.onChange as\n\t\t| ((e: React.ChangeEvent<HTMLInputElement>) => void)\n\t\t| undefined;\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'change', metadata: { selected: e.target.checked } });\n\n\t\tconsumerOnChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={classnames(styles['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')}>\n\t\t\t<span className=\"mrl-u-focus-wrapper\">\n\t\t\t\t<input\n\t\t\t\t\t{...rest}\n\t\t\t\t\t{...attributes}\n\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\tchecked={selected === 'checked'}\n\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\tid={checkboxIdRef.current}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-input'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-input'\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<span className=\"mrl-u-focus-indicator\"></span>\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-inputDisplay'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-inputDisplay'\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\tsvg={selected !== 'indeterminate' ? check : minus}\n\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\tclassName={styles['MrlCheckboxStandalone-inputDisplay-icon']}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckboxStandalone","_ref","_ref$attrs","attrs","_ref$state","state","checkboxDefaults","_ref$selected","selected","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","id","getUniqueId","inputRef","console","warn","useEffect","indeterminate","current","class","className","attributes","setAttributes","consumerOnChange","onChange","handleChange","e","action","metadata","target","checked","createElement","classnames","styles","_extends","disabled","ref","type","MrlSvg","svg","check","minus","size"],"mappings":";;;;;;;;;;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAqBA,CAAAC,IAAA,EAMO;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAL3CE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IAAAE,UAAA,GAAAH,IAAA,CACVI,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAGE,gBAAgB,CAACD,KAAK,GAAAD,UAAA;IAAAG,aAAA,GAAAN,IAAA,CAC9BO,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGD,gBAAgB,CAACE,QAAQ,GAAAD,aAAA;IACpCE,OAAO,GAAAR,IAAA,CAAPQ,OAAO;AACJC,IAAAA,IAAI,GAAAC,wBAAA,CAAAV,IAAA,EAAAW,SAAA,CAAA;AAEP,EAAA,IAAMC,gBAAgB,GAAGC,sBAAsB,CAAC,uBAAuB,EAAEL,OAAO,CAAC;AACjF;AACA;AACA,EAAA,IAAMM,aAAa,GAAGC,KAAK,CAACC,MAAM,CAASd,KAAK,CAACe,EAAE,IAAIC,WAAW,CAAC,cAAc,CAAC,CAAC;AACnF,EAAA,IAAMC,QAAQ,GAAGJ,KAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAErD,IAAI,EAAEd,KAAK,CAACe,EAAE,IAAIf,KAAK,CAAC,iBAAiB,CAAC,CAAC,EAAE;AAC5CkB,IAAAA,OAAO,CAACC,IAAI,CACX,gEAAgE,GAC/D,sDACF,CAAC;AACF,EAAA;;AAEA;AACA;EACAN,KAAK,CAAC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aAAa,CAACU,OAAQ;AAC1BM,IAAAA,QAAQ,EAAEC,YAAa;AACvBW,IAAAA,GAAG,EAAEvB,QAAS;AACdwB,IAAAA,IAAI,EAAC,UAAU;IACfjB,SAAS,EAAEY,UAAU,CACpBC,MAAM,CAAC,6BAA6B,CAAC,EACrC,6BACD;AAAE,GAAA,CACF,CAAC,eACFxB,KAAA,CAAAsB,aAAA,CAAA,MAAA,EAAA;AAAMX,IAAAA,SAAS,EAAC;AAAuB,GAAO,CAAC,eAC/CX,KAAA,CAAAsB,aAAA,CAAA,MAAA,EAAA;IACCX,SAAS,EAAEY,UAAU,CACpBC,MAAM,CAAC,oCAAoC,CAAC,EAC5C,oCACD;AAAE,GAAA,eAEFxB,KAAA,CAAAsB,aAAA,CAACO,MAAM,EAAA;AACNC,IAAAA,GAAG,EAAEtC,QAAQ,KAAK,eAAe,GAAGuC,KAAK,GAAGC,KAAM;AAClDC,IAAAA,IAAI,EAAC,MAAM;IACXtB,SAAS,EAAEa,MAAM,CAAC,yCAAyC;GAC3D,CACI,CACD,CACF,CAAC;AAER;;;;"}
|
|
@@ -6,7 +6,10 @@ import { MrlTextHeading } from '../../text/MrlTextHeading/MrlTextHeading.js';
|
|
|
6
6
|
|
|
7
7
|
var _excluded = ["children", "divider", "groupLabel"];
|
|
8
8
|
/**
|
|
9
|
-
* MrlMenuGroup
|
|
9
|
+
* MrlMenuGroup component
|
|
10
|
+
*
|
|
11
|
+
* Groups related menu items within an MrlMenu, with an optional label and a trailing divider.
|
|
12
|
+
* Must be a direct child of `MrlMenu`.
|
|
10
13
|
* @param props - component properties
|
|
11
14
|
* @returns JSX.Element
|
|
12
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlMenuGroup.js","sources":["../../../../../src/components/menu/MrlMenuGroup/MrlMenuGroup.tsx"],"sourcesContent":["import { MrlTextHeading } from '../../text';\nimport { MrlDivider } from '../../divider';\nimport * as React from 'react';\nimport styles from './MrlMenuGroup.module.scss';\n\nexport interface MrlMenuGroupPropTypes {\n\tchildren: React.ReactNode;\n\tdivider?: boolean;\n\tgroupLabel?: string;\n}\n\n/**\n * MrlMenuGroup\n * @param props - component properties\n * @returns JSX.Element\n */\nexport const MrlMenuGroup = ({\n\tchildren,\n\tdivider = true,\n\tgroupLabel,\n\t...rest\n}: MrlMenuGroupPropTypes): JSX.Element => {\n\treturn (\n\t\t<li role=\"none\" {...rest}>\n\t\t\t{groupLabel && (\n\t\t\t\t<MrlTextHeading\n\t\t\t\t\tattrs={{\n\t\t\t\t\t\tclassName: styles['MrlMenuGroup--label']\n\t\t\t\t\t}}\n\t\t\t\t\thierarchy=\"primary\"\n\t\t\t\t\tkind=\"title\"\n\t\t\t\t\tlevel=\"2\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t>\n\t\t\t\t\t{groupLabel}\n\t\t\t\t</MrlTextHeading>\n\t\t\t)}\n\t\t\t<ul role=\"none\">{children}</ul>\n\t\t\t{divider && <MrlDivider />}\n\t\t</li>\n\t);\n};\n"],"names":["MrlMenuGroup","_ref","children","_ref$divider","divider","groupLabel","rest","_objectWithoutProperties","_excluded","React","createElement","_extends","role","MrlTextHeading","attrs","className","styles","hierarchy","kind","level","size","MrlDivider"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"MrlMenuGroup.js","sources":["../../../../../src/components/menu/MrlMenuGroup/MrlMenuGroup.tsx"],"sourcesContent":["import { MrlTextHeading } from '../../text';\nimport { MrlDivider } from '../../divider';\nimport * as React from 'react';\nimport styles from './MrlMenuGroup.module.scss';\n\nexport interface MrlMenuGroupPropTypes {\n\t/**\n\t * The `MrlMenuItem`s (or `MrlMenuItemLink`s) that belong to the group. They stay part of the\n\t * parent menu's keyboard navigation and close the menu exactly as ungrouped items do.\n\t */\n\tchildren: React.ReactNode;\n\n\t/**\n\t * Renders a divider after the group's items. Set it to `false` on the last group so the menu\n\t * does not end with a divider.\n\t *\n\t * @default true\n\t */\n\tdivider?: boolean;\n\n\t/** Visible heading rendered above the group's items. Omit it to separate items with the divider only */\n\tgroupLabel?: string;\n}\n\n/**\n * MrlMenuGroup component\n *\n * Groups related menu items within an MrlMenu, with an optional label and a trailing divider.\n * Must be a direct child of `MrlMenu`.\n * @param props - component properties\n * @returns JSX.Element\n */\nexport const MrlMenuGroup = ({\n\tchildren,\n\tdivider = true,\n\tgroupLabel,\n\t...rest\n}: MrlMenuGroupPropTypes): JSX.Element => {\n\treturn (\n\t\t<li role=\"none\" {...rest}>\n\t\t\t{groupLabel && (\n\t\t\t\t<MrlTextHeading\n\t\t\t\t\tattrs={{\n\t\t\t\t\t\tclassName: styles['MrlMenuGroup--label']\n\t\t\t\t\t}}\n\t\t\t\t\thierarchy=\"primary\"\n\t\t\t\t\tkind=\"title\"\n\t\t\t\t\tlevel=\"2\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t>\n\t\t\t\t\t{groupLabel}\n\t\t\t\t</MrlTextHeading>\n\t\t\t)}\n\t\t\t<ul role=\"none\">{children}</ul>\n\t\t\t{divider && <MrlDivider />}\n\t\t</li>\n\t);\n};\n"],"names":["MrlMenuGroup","_ref","children","_ref$divider","divider","groupLabel","rest","_objectWithoutProperties","_excluded","React","createElement","_extends","role","MrlTextHeading","attrs","className","styles","hierarchy","kind","level","size","MrlDivider"],"mappings":";;;;;;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,YAAY,GAAGC,IAAA,IAKc;AAAA,EAAA,IAJzCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAAC,YAAA,GAAAF,IAAA,CACRG,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAG,IAAI,GAAAA,YAAA;IACdE,UAAU,GAAAJ,IAAA,CAAVI,UAAU;AACPC,IAAAA,IAAI,GAAAC,wBAAA,CAAAN,IAAA,EAAAO,SAAA,CAAA;AAEP,EAAA,oBACCC,KAAA,CAAAC,aAAA,CAAA,IAAA,EAAAC,QAAA,CAAA;AAAIC,IAAAA,IAAI,EAAC;GAAM,EAAKN,IAAI,GACtBD,UAAU,iBACVI,KAAA,CAAAC,aAAA,CAACG,cAAc,EAAA;AACdC,IAAAA,KAAK,EAAE;MACNC,SAAS,EAAEC,MAAM,CAAC,qBAAqB;KACtC;AACFC,IAAAA,SAAS,EAAC,SAAS;AACnBC,IAAAA,IAAI,EAAC,OAAO;AACZC,IAAAA,KAAK,EAAC,GAAG;AACTC,IAAAA,IAAI,EAAC;AAAO,GAAA,EAEXf,UACc,CAChB,eACDI,KAAA,CAAAC,aAAA,CAAA,IAAA,EAAA;AAAIE,IAAAA,IAAI,EAAC;AAAM,GAAA,EAAEV,QAAa,CAAC,EAC9BE,OAAO,iBAAIK,KAAA,CAAAC,aAAA,CAACW,UAAU,EAAA,IAAE,CACtB,CAAC;AAEP;;;;"}
|
|
@@ -22,7 +22,8 @@ var getSubMenuType = child => {
|
|
|
22
22
|
/**
|
|
23
23
|
* MrlMenuItem component
|
|
24
24
|
*
|
|
25
|
-
* Renders a menu
|
|
25
|
+
* Renders one actionable row of a menu: an `li` wrapping a `button` with the given `role`.
|
|
26
|
+
* Must be a child of `MrlMenu` or `MrlMenuGroup`.
|
|
26
27
|
* @param {MrlMenuItemProps} props - The props for the MrlMenuItem component
|
|
27
28
|
* @returns {Element} - rendered MrlMenuItem component
|
|
28
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlMenuItem.js","sources":["../../../../../src/components/menu/MrlMenuItem/MrlMenuItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport { check, chevronRight } from '@muraldevkit/ds-icons';\nimport classnames from 'classnames';\nimport { getUniqueId } from '../../../utils/setAttributes/setAttributes';\nimport { MrlPopoverProps } from '../../popover/MrlPopover/MrlPopover';\nimport { DSIconType, MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { MrlMenuProps } from '../MrlMenu/MrlMenu';\nimport { SubMenuTypes, ComponentWithComponentType, AriaHasPopup, MenuItemRole } from '../constants';\nimport { MrlMenuContext } from '../context/MrlMenuContext';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlMenuItem.module.scss';\n\nexport interface MrlMenuItemProps {\n\t/** ID for associated description */\n\tariaDescribedBy?: string;\n\n\t/** Indicates whether the menu item has a popup menu using aria-haspopup attribute */\n\tariaHasPopup?: AriaHasPopup;\n\n\t/**\n\t Children to be rendered within the menu component\n\t */\n\tchildren: React.ReactNode | string;\n\n\t/** Classname for the menu item */\n\tclassName?: string;\n\n\t/** If the menu item is disabled */\n\tdisabled?: boolean;\n\n\t/** Icon for menu item */\n\ticon?: DSIconType;\n\n\t/** Unique ID for the menu item */\n\tid?: string;\n\n\t/** Callback to be called when the menu item is clicked */\n\tonClick?: (e?: React.MouseEvent<HTMLButtonElement>) => void;\n\n\t/** Callback to be called when the menu item is hovered */\n\tonMouseOver?: (e?: React.MouseEvent) => void;\n\n\t/** Callback to be called when the menu item is hovered out */\n\tonMouseOut?: (e?: React.MouseEvent) => void;\n\n\t/** Data-qa attribute for the menu item */\n\tdataQa?: string;\n\n\t/**\n\t * Role for the menu item\n\t *\n\t * When using `menuitemcheckbox` or `menuitemradio`, the menu item will be treated as a selectable item,\n\t * aria-checked will be set to 'true' or 'false' based on the selected state.\n\t *\n\t * @default 'menuitem' - for regular menu items\n\t * @example 'menuitemcheckbox' - for checkbox menu items\n\t * @example 'menuitemradio' - for radio menu items\n\t */\n\trole?: MenuItemRole;\n\n\t/** If the menu item is selected */\n\tselected?: boolean;\n\n\t/**\n\t * Enables interaction tracking for this menu item. Provide a stable, non-PII id\n\t * (e.g. 'mural-menu-duplicate'). When omitted, the menu item emits no analytics.\n\t */\n\teventId?: string;\n}\n\nconst getSubMenuType = (child: React.ReactNode): SubMenuTypes | null => {\n\tif (React.isValidElement(child)) {\n\t\tconst type = (child.type as ComponentWithComponentType).componentType;\n\n\t\tif (type === 'Menu' || type === 'Popover') {\n\t\t\treturn type;\n\t\t}\n\t}\n\n\treturn null;\n};\n\n/**\n * MrlMenuItem component\n *\n * Renders a menu item to be used within the MrlMenu component\n * @param {MrlMenuItemProps} props - The props for the MrlMenuItem component\n * @returns {Element} - rendered MrlMenuItem component\n */\nexport function MrlMenuItem({\n\tariaDescribedBy,\n\tariaHasPopup,\n\tchildren,\n\tclassName,\n\tdataQa,\n\tdisabled,\n\ticon,\n\tid,\n\tonClick,\n\tonMouseOut,\n\tonMouseOver,\n\trole = 'menuitem',\n\tselected,\n\teventId,\n\t...rest\n}: MrlMenuItemProps): JSX.Element {\n\tconst context = React.useContext(MrlMenuContext);\n\tconst trackInteraction = useMrlTrackInteraction('MrlMenuItem', eventId);\n\tconst menuItemRef = React.useRef<HTMLButtonElement>(null);\n\tconst [isSubElement, setIsSubElement] = React.useState(false);\n\tconst isSelectable = role === 'menuitemcheckbox' || role === 'menuitemradio';\n\n\tconst setFocusItem = (): void => {\n\t\tif (ariaHasPopup && ariaHasPopup !== 'menu' && context?.triggerRef?.current) {\n\t\t\tconst triggerElement = context.triggerRef.current;\n\t\t\tif (!triggerElement.id) {\n\t\t\t\ttriggerElement.id = getUniqueId('menu-trigger');\n\t\t\t}\n\n\t\t\tdocument.body.setAttribute('data-focus-item', triggerElement.id);\n\t\t}\n\t};\n\n\tconst handleClick = (e: React.MouseEvent<HTMLButtonElement>): void => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\n\t\ttrackInteraction({ action: 'click', metadata: { selected: !!selected }, variant: role });\n\n\t\tonClick?.(e);\n\n\t\tsetFocusItem();\n\n\t\tif (context && !!context.closeMenu && !isSubElement) {\n\t\t\tcontext.closeMenu();\n\t\t}\n\t};\n\n\tconst handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>): void => {\n\t\t// WCAG specifices that space key should toggle the selection of a checkbox or radio button\n\t\t// but not close the menu. When a user presses the enter key on these items the menu should close.\n\t\tif (e.key === ' ' && !disabled) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\n\t\t\ttrackInteraction({ action: 'click', metadata: { selected: !!selected }, variant: role });\n\n\t\t\tonClick?.();\n\n\t\t\t// close the menu if we are not a selectable item (checkbox or radio button)\n\t\t\tif (!isSelectable) {\n\t\t\t\tsetFocusItem();\n\t\t\t\tcontext?.closeMenu?.();\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleDisabled = (e: React.MouseEvent<HTMLButtonElement>): void => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t};\n\n\tconst handleFocusIn = (): void => {\n\t\tonMouseOver?.();\n\t};\n\n\tconst handleFocusOut = (): void => {\n\t\tonMouseOut?.();\n\t};\n\n\tconst renderMenu = () => {\n\t\treturn React.Children.map(children, (child) => {\n\t\t\tif (React.isValidElement(child)) {\n\t\t\t\tconst type = (child.type as ComponentWithComponentType).componentType;\n\n\t\t\t\tif (type === 'Menu') {\n\t\t\t\t\treturn React.cloneElement(child as React.ReactElement<Partial<MrlMenuProps>>, {\n\t\t\t\t\t\talignment: 'start',\n\t\t\t\t\t\tcloseParent: context?.closeParent,\n\t\t\t\t\t\tisSubMenu: true,\n\t\t\t\t\t\tposition: 'right',\n\t\t\t\t\t\ttriggerRef: menuItemRef\n\t\t\t\t\t});\n\t\t\t\t} else if (type === 'Popover') {\n\t\t\t\t\treturn React.cloneElement(child as React.ReactElement<Partial<MrlPopoverProps>>, {\n\t\t\t\t\t\talignment: 'start',\n\t\t\t\t\t\tisSubMenu: true,\n\t\t\t\t\t\tpoint: false,\n\t\t\t\t\t\tposition: 'right',\n\t\t\t\t\t\ttriggerRef: menuItemRef\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}\n\t\t});\n\t};\n\n\tconst renderChildren = () => {\n\t\treturn React.Children.map(children, (child) => {\n\t\t\tif (!getSubMenuType(child)) {\n\t\t\t\treturn child;\n\t\t\t}\n\t\t\treturn null;\n\t\t});\n\t};\n\n\tReact.useEffect(() => {\n\t\tconst hasSubMenu = React.Children.toArray(children).some((child) => getSubMenuType(child));\n\n\t\tsetIsSubElement(hasSubMenu);\n\t}, [children]);\n\n\tconst menuItemClasses = classnames(styles['MrlMenuItem'], 'MrlMenuItem');\n\tconst menuTriggerClasses = classnames(\n\t\tstyles['MrlMenuItem--item'],\n\t\t'MrlMenuItem--item',\n\t\t{\n\t\t\t[styles['MrlMenuItem--item--selected']]: selected,\n\t\t\t[styles['MrlMenuItem--item--withIcon']]: !!icon\n\t\t},\n\t\tclassName\n\t);\n\n\tconst rightIcon = isSubElement ? chevronRight : selected ? check : null;\n\tconst hasPopup = isSubElement ? 'menu' : ariaHasPopup ? ariaHasPopup : undefined;\n\n\treturn (\n\t\t<li {...rest} className={menuItemClasses} data-qa={dataQa}>\n\t\t\t<button\n\t\t\t\taria-describedby={ariaDescribedBy}\n\t\t\t\taria-disabled={disabled}\n\t\t\t\taria-haspopup={hasPopup}\n\t\t\t\t{...(isSelectable ? { 'aria-checked': selected ? 'true' : 'false' } : {})}\n\t\t\t\tdata-selected={selected}\n\t\t\t\tdata-qa={dataQa && `${dataQa}-button`}\n\t\t\t\tid={id}\n\t\t\t\tref={menuItemRef}\n\t\t\t\trole={role}\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={disabled ? handleDisabled : handleClick}\n\t\t\t\tonKeyDown={!disabled ? handleKeyDown : undefined}\n\t\t\t\tonMouseOver={!disabled && onMouseOver ? onMouseOver : undefined}\n\t\t\t\tonMouseOut={!disabled && onMouseOut ? onMouseOut : undefined}\n\t\t\t\tonFocus={!disabled && onMouseOver ? handleFocusIn : undefined}\n\t\t\t\tonBlur={!disabled && onMouseOut ? handleFocusOut : undefined}\n\t\t\t\tclassName={menuTriggerClasses}\n\t\t\t>\n\t\t\t\t{isSubElement && <div className={styles['MrlMenuItem--item--hoverArea']} />}\n\t\t\t\t{icon && (\n\t\t\t\t\t<span className={styles['MrlMenuItem--item--icon-left']}>\n\t\t\t\t\t\t<MrlSvg size=\"small\" svg={icon} />\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{renderChildren()}\n\t\t\t\t{rightIcon && (\n\t\t\t\t\t<span className={styles['MrlMenuItem--item--icon-right']}>\n\t\t\t\t\t\t<span className={styles['MrlMenuItem--item--icon-right-container']}>\n\t\t\t\t\t\t\t<MrlSvg svg={rightIcon} size=\"auto\" />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</button>\n\t\t\t{renderMenu()}\n\t\t</li>\n\t);\n}\n"],"names":["getSubMenuType","child","React","isValidElement","type","componentType","MrlMenuItem","_ref","ariaDescribedBy","ariaHasPopup","children","className","dataQa","disabled","icon","id","onClick","onMouseOut","onMouseOver","_ref$role","role","selected","eventId","rest","_objectWithoutProperties","_excluded","context","useContext","MrlMenuContext","trackInteraction","useMrlTrackInteraction","menuItemRef","useRef","_React$useState","useState","_React$useState2","_slicedToArray","isSubElement","setIsSubElement","isSelectable","setFocusItem","_context$triggerRef","triggerRef","current","triggerElement","getUniqueId","document","body","setAttribute","handleClick","e","preventDefault","stopPropagation","action","metadata","variant","closeMenu","handleKeyDown","key","_context$closeMenu","call","handleDisabled","handleFocusIn","handleFocusOut","renderMenu","Children","map","cloneElement","alignment","closeParent","isSubMenu","position","point","renderChildren","useEffect","hasSubMenu","toArray","some","menuItemClasses","classnames","styles","menuTriggerClasses","rightIcon","chevronRight","check","hasPopup","undefined","createElement","_extends","concat","ref","onKeyDown","onFocus","onBlur","MrlSvg","size","svg"],"mappings":";;;;;;;;;;;AAuEA,IAAMA,cAAc,GAAIC,KAAsB,IAA0B;AACvE,EAAA,iBAAIC,KAAK,CAACC,cAAc,CAACF,KAAK,CAAC,EAAE;AAChC,IAAA,IAAMG,IAAI,GAAIH,KAAK,CAACG,IAAI,CAAgCC,aAAa;AAErE,IAAA,IAAID,IAAI,KAAK,MAAM,IAAIA,IAAI,KAAK,SAAS,EAAE;AAC1C,MAAA,OAAOA,IAAI;AACZ,IAAA;AACD,EAAA;AAEA,EAAA,OAAO,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AM,EAAA;AAACE,IAAAA,GAAG,EAAEd,SAAU;AAACa,IAAAA,IAAI,EAAC;GAAQ,CAChC,CACD,CAEA,CAAC,EACR/B,UAAU,EACR,CAAC;AAEP;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlMenuItem.js","sources":["../../../../../src/components/menu/MrlMenuItem/MrlMenuItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport { check, chevronRight } from '@muraldevkit/ds-icons';\nimport classnames from 'classnames';\nimport { getUniqueId } from '../../../utils/setAttributes/setAttributes';\nimport { MrlPopoverProps } from '../../popover/MrlPopover/MrlPopover';\nimport { DSIconType, MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { MrlMenuProps } from '../MrlMenu/MrlMenu';\nimport { SubMenuTypes, ComponentWithComponentType, AriaHasPopup, MenuItemRole } from '../constants';\nimport { MrlMenuContext } from '../context/MrlMenuContext';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlMenuItem.module.scss';\n\nexport interface MrlMenuItemProps {\n\t/** ID for associated description */\n\tariaDescribedBy?: string;\n\n\t/** Indicates whether the menu item has a popup menu using aria-haspopup attribute */\n\tariaHasPopup?: AriaHasPopup;\n\n\t/**\n\t * Label of the item. Nesting an `MrlMenu` or `MrlPopover` here turns the item into a\n\t * submenu trigger: it gets `aria-haspopup=\"menu\"` and a trailing chevron, opens the submenu\n\t * on hover, `ArrowRight`, `Enter` or `Space`, and does not close its own menu when activated.\n\t */\n\tchildren: React.ReactNode | string;\n\n\t/** Classname for the menu item */\n\tclassName?: string;\n\n\t/** Disables the item: it stays focusable (`aria-disabled`) but ignores clicks and key presses */\n\tdisabled?: boolean;\n\n\t/** Icon for menu item */\n\ticon?: DSIconType;\n\n\t/** Unique ID for the menu item */\n\tid?: string;\n\n\t/**\n\t * Called on click, `Enter` or `Space`. The menu then closes, unless the item wraps a submenu\n\t * or is a `menuitemcheckbox`/`menuitemradio` toggled with `Space`.\n\t */\n\tonClick?: (e?: React.MouseEvent<HTMLButtonElement>) => void;\n\n\t/** Callback to be called when the menu item is hovered */\n\tonMouseOver?: (e?: React.MouseEvent) => void;\n\n\t/** Callback to be called when the menu item is hovered out */\n\tonMouseOut?: (e?: React.MouseEvent) => void;\n\n\t/** Data-qa attribute for the menu item */\n\tdataQa?: string;\n\n\t/**\n\t * Role for the menu item\n\t *\n\t * When using `menuitemcheckbox` or `menuitemradio`, the menu item will be treated as a selectable item,\n\t * aria-checked will be set to 'true' or 'false' based on the selected state. `Space` toggles\n\t * such an item and keeps the menu open; `Enter` or a click toggles it and closes the menu.\n\t * The consumer owns `selected`.\n\t *\n\t * @default 'menuitem' - for regular menu items\n\t * @example 'menuitemcheckbox' - for checkbox menu items\n\t * @example 'menuitemradio' - for radio menu items\n\t */\n\trole?: MenuItemRole;\n\n\t/** Marks the item as selected: shows a trailing check and, for checkbox/radio roles, sets `aria-checked` */\n\tselected?: boolean;\n\n\t/**\n\t * Enables interaction tracking for this menu item. Provide a stable, non-PII id\n\t * (e.g. 'mural-menu-duplicate'). When omitted, the menu item emits no analytics.\n\t */\n\teventId?: string;\n}\n\nconst getSubMenuType = (child: React.ReactNode): SubMenuTypes | null => {\n\tif (React.isValidElement(child)) {\n\t\tconst type = (child.type as ComponentWithComponentType).componentType;\n\n\t\tif (type === 'Menu' || type === 'Popover') {\n\t\t\treturn type;\n\t\t}\n\t}\n\n\treturn null;\n};\n\n/**\n * MrlMenuItem component\n *\n * Renders one actionable row of a menu: an `li` wrapping a `button` with the given `role`.\n * Must be a child of `MrlMenu` or `MrlMenuGroup`.\n * @param {MrlMenuItemProps} props - The props for the MrlMenuItem component\n * @returns {Element} - rendered MrlMenuItem component\n */\nexport function MrlMenuItem({\n\tariaDescribedBy,\n\tariaHasPopup,\n\tchildren,\n\tclassName,\n\tdataQa,\n\tdisabled,\n\ticon,\n\tid,\n\tonClick,\n\tonMouseOut,\n\tonMouseOver,\n\trole = 'menuitem',\n\tselected,\n\teventId,\n\t...rest\n}: MrlMenuItemProps): JSX.Element {\n\tconst context = React.useContext(MrlMenuContext);\n\tconst trackInteraction = useMrlTrackInteraction('MrlMenuItem', eventId);\n\tconst menuItemRef = React.useRef<HTMLButtonElement>(null);\n\tconst [isSubElement, setIsSubElement] = React.useState(false);\n\tconst isSelectable = role === 'menuitemcheckbox' || role === 'menuitemradio';\n\n\tconst setFocusItem = (): void => {\n\t\tif (ariaHasPopup && ariaHasPopup !== 'menu' && context?.triggerRef?.current) {\n\t\t\tconst triggerElement = context.triggerRef.current;\n\t\t\tif (!triggerElement.id) {\n\t\t\t\ttriggerElement.id = getUniqueId('menu-trigger');\n\t\t\t}\n\n\t\t\tdocument.body.setAttribute('data-focus-item', triggerElement.id);\n\t\t}\n\t};\n\n\tconst handleClick = (e: React.MouseEvent<HTMLButtonElement>): void => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\n\t\ttrackInteraction({ action: 'click', metadata: { selected: !!selected }, variant: role });\n\n\t\tonClick?.(e);\n\n\t\tsetFocusItem();\n\n\t\tif (context && !!context.closeMenu && !isSubElement) {\n\t\t\tcontext.closeMenu();\n\t\t}\n\t};\n\n\tconst handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>): void => {\n\t\t// WCAG specifices that space key should toggle the selection of a checkbox or radio button\n\t\t// but not close the menu. When a user presses the enter key on these items the menu should close.\n\t\tif (e.key === ' ' && !disabled) {\n\t\t\te.preventDefault();\n\t\t\te.stopPropagation();\n\n\t\t\ttrackInteraction({ action: 'click', metadata: { selected: !!selected }, variant: role });\n\n\t\t\tonClick?.();\n\n\t\t\t// close the menu if we are not a selectable item (checkbox or radio button)\n\t\t\tif (!isSelectable) {\n\t\t\t\tsetFocusItem();\n\t\t\t\tcontext?.closeMenu?.();\n\t\t\t}\n\t\t}\n\t};\n\n\tconst handleDisabled = (e: React.MouseEvent<HTMLButtonElement>): void => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t};\n\n\tconst handleFocusIn = (): void => {\n\t\tonMouseOver?.();\n\t};\n\n\tconst handleFocusOut = (): void => {\n\t\tonMouseOut?.();\n\t};\n\n\tconst renderMenu = () => {\n\t\treturn React.Children.map(children, (child) => {\n\t\t\tif (React.isValidElement(child)) {\n\t\t\t\tconst type = (child.type as ComponentWithComponentType).componentType;\n\n\t\t\t\tif (type === 'Menu') {\n\t\t\t\t\treturn React.cloneElement(child as React.ReactElement<Partial<MrlMenuProps>>, {\n\t\t\t\t\t\talignment: 'start',\n\t\t\t\t\t\tcloseParent: context?.closeParent,\n\t\t\t\t\t\tisSubMenu: true,\n\t\t\t\t\t\tposition: 'right',\n\t\t\t\t\t\ttriggerRef: menuItemRef\n\t\t\t\t\t});\n\t\t\t\t} else if (type === 'Popover') {\n\t\t\t\t\treturn React.cloneElement(child as React.ReactElement<Partial<MrlPopoverProps>>, {\n\t\t\t\t\t\talignment: 'start',\n\t\t\t\t\t\tisSubMenu: true,\n\t\t\t\t\t\tpoint: false,\n\t\t\t\t\t\tposition: 'right',\n\t\t\t\t\t\ttriggerRef: menuItemRef\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t}\n\t\t});\n\t};\n\n\tconst renderChildren = () => {\n\t\treturn React.Children.map(children, (child) => {\n\t\t\tif (!getSubMenuType(child)) {\n\t\t\t\treturn child;\n\t\t\t}\n\t\t\treturn null;\n\t\t});\n\t};\n\n\tReact.useEffect(() => {\n\t\tconst hasSubMenu = React.Children.toArray(children).some((child) => getSubMenuType(child));\n\n\t\tsetIsSubElement(hasSubMenu);\n\t}, [children]);\n\n\tconst menuItemClasses = classnames(styles['MrlMenuItem'], 'MrlMenuItem');\n\tconst menuTriggerClasses = classnames(\n\t\tstyles['MrlMenuItem--item'],\n\t\t'MrlMenuItem--item',\n\t\t{\n\t\t\t[styles['MrlMenuItem--item--selected']]: selected,\n\t\t\t[styles['MrlMenuItem--item--withIcon']]: !!icon\n\t\t},\n\t\tclassName\n\t);\n\n\tconst rightIcon = isSubElement ? chevronRight : selected ? check : null;\n\tconst hasPopup = isSubElement ? 'menu' : ariaHasPopup ? ariaHasPopup : undefined;\n\n\treturn (\n\t\t<li {...rest} className={menuItemClasses} data-qa={dataQa}>\n\t\t\t<button\n\t\t\t\taria-describedby={ariaDescribedBy}\n\t\t\t\taria-disabled={disabled}\n\t\t\t\taria-haspopup={hasPopup}\n\t\t\t\t{...(isSelectable ? { 'aria-checked': selected ? 'true' : 'false' } : {})}\n\t\t\t\tdata-selected={selected}\n\t\t\t\tdata-qa={dataQa && `${dataQa}-button`}\n\t\t\t\tid={id}\n\t\t\t\tref={menuItemRef}\n\t\t\t\trole={role}\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={disabled ? handleDisabled : handleClick}\n\t\t\t\tonKeyDown={!disabled ? handleKeyDown : undefined}\n\t\t\t\tonMouseOver={!disabled && onMouseOver ? onMouseOver : undefined}\n\t\t\t\tonMouseOut={!disabled && onMouseOut ? onMouseOut : undefined}\n\t\t\t\tonFocus={!disabled && onMouseOver ? handleFocusIn : undefined}\n\t\t\t\tonBlur={!disabled && onMouseOut ? handleFocusOut : undefined}\n\t\t\t\tclassName={menuTriggerClasses}\n\t\t\t>\n\t\t\t\t{isSubElement && <div className={styles['MrlMenuItem--item--hoverArea']} />}\n\t\t\t\t{icon && (\n\t\t\t\t\t<span className={styles['MrlMenuItem--item--icon-left']}>\n\t\t\t\t\t\t<MrlSvg size=\"small\" svg={icon} />\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{renderChildren()}\n\t\t\t\t{rightIcon && (\n\t\t\t\t\t<span className={styles['MrlMenuItem--item--icon-right']}>\n\t\t\t\t\t\t<span className={styles['MrlMenuItem--item--icon-right-container']}>\n\t\t\t\t\t\t\t<MrlSvg svg={rightIcon} size=\"auto\" />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</button>\n\t\t\t{renderMenu()}\n\t\t</li>\n\t);\n}\n"],"names":["getSubMenuType","child","React","isValidElement","type","componentType","MrlMenuItem","_ref","ariaDescribedBy","ariaHasPopup","children","className","dataQa","disabled","icon","id","onClick","onMouseOut","onMouseOver","_ref$role","role","selected","eventId","rest","_objectWithoutProperties","_excluded","context","useContext","MrlMenuContext","trackInteraction","useMrlTrackInteraction","menuItemRef","useRef","_React$useState","useState","_React$useState2","_slicedToArray","isSubElement","setIsSubElement","isSelectable","setFocusItem","_context$triggerRef","triggerRef","current","triggerElement","getUniqueId","document","body","setAttribute","handleClick","e","preventDefault","stopPropagation","action","metadata","variant","closeMenu","handleKeyDown","key","_context$closeMenu","call","handleDisabled","handleFocusIn","handleFocusOut","renderMenu","Children","map","cloneElement","alignment","closeParent","isSubMenu","position","point","renderChildren","useEffect","hasSubMenu","toArray","some","menuItemClasses","classnames","styles","menuTriggerClasses","rightIcon","chevronRight","check","hasPopup","undefined","createElement","_extends","concat","ref","onKeyDown","onFocus","onBlur","MrlSvg","size","svg"],"mappings":";;;;;;;;;;;AA8EA,IAAMA,cAAc,GAAIC,KAAsB,IAA0B;AACvE,EAAA,iBAAIC,KAAK,CAACC,cAAc,CAACF,KAAK,CAAC,EAAE;AAChC,IAAA,IAAMG,IAAI,GAAIH,KAAK,CAACG,IAAI,CAAgCC,aAAa;AAErE,IAAA,IAAID,IAAI,KAAK,MAAM,IAAIA,IAAI,KAAK,SAAS,EAAE;AAC1C,MAAA,OAAOA,IAAI;AACZ,IAAA;AACD,EAAA;AAEA,EAAA,OAAO,IAAI;AACZ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,WAAWA,CAAAC,IAAA,EAgBO;AAAA,EAAA,IAfjCC,eAAe,GAAAD,IAAA,CAAfC,eAAe;IACfC,YAAY,GAAAF,IAAA,CAAZE,YAAY;IACZC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IACTC,MAAM,GAAAL,IAAA,CAANK,MAAM;IACNC,QAAQ,GAAAN,IAAA,CAAR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,UAAU,EAAE,CAACJ,QAAQ,IAAII,UAAU,GAAGA,UAAU,GAAGqE,SAAU;IAC7DM,OAAO,EAAE,CAAC/E,QAAQ,IAAIK,WAAW,GAAG4C,aAAa,GAAGwB,SAAU;IAC9DO,MAAM,EAAE,CAAChF,QAAQ,IAAII,UAAU,GAAG8C,cAAc,GAAGuB,SAAU;AAC7D3E,IAAAA,SAAS,EAAEsE;AAAmB,GAAA,CAAA,EAE7B5C,YAAY,iBAAInC,KAAA,CAAAqF,aAAA,CAAA,KAAA,EAAA;IAAK5E,SAAS,EAAEqE,MAAM,CAAC,8BAA8B;AAAE,GAAE,CAAC,EAC1ElE,IAAI,iBACJZ,KAAA,CAAAqF,aAAA,CAAA,MAAA,EAAA;IAAM5E,SAAS,EAAEqE,MAAM,CAAC,8BAA8B;AAAE,GAAA,eACvD9E,KAAA,CAAAqF,aAAA,CAACO,MAAM,EAAA;AAACC,IAAAA,IAAI,EAAC,OAAO;AAACC,IAAAA,GAAG,EAAElF;GAAO,CAC5B,CACN,EACA2D,cAAc,EAAE,EAChBS,SAAS,iBACThF,KAAA,CAAAqF,aAAA,CAAA,MAAA,EAAA;IAAM5E,SAAS,EAAEqE,MAAM,CAAC,+BAA+B;GAAE,eACxD9E,KAAA,CAAAqF,aAAA,CAAA,MAAA,EAAA;IAAM5E,SAAS,EAAEqE,MAAM,CAAC,yCAAyC;AAAE,GAAA,eAClE9E,KAAA,CAAAqF,aAAA,CAACO,MAAM,EAAA;AAACE,IAAAA,GAAG,EAAEd,SAAU;AAACa,IAAAA,IAAI,EAAC;GAAQ,CAChC,CACD,CAEA,CAAC,EACR/B,UAAU,EACR,CAAC;AAEP;;;;"}
|
|
@@ -8,11 +8,15 @@ import { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics/useMrlAna
|
|
|
8
8
|
|
|
9
9
|
var _excluded = ["ariaDescribedBy", "children", "className", "dataQa", "disabled", "href", "icon", "id", "onClick", "selected", "target", "eventId"];
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* MrlMenuItemLink component
|
|
12
12
|
*
|
|
13
|
-
* Renders a menu item to
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Renders a menu item that navigates to a URL (an anchor with `role="menuitem"`), to be used
|
|
14
|
+
* within the MrlMenu component. Links opened with `target="_blank"` get
|
|
15
|
+
* `rel="noopener noreferrer"` and a trailing external-link icon.
|
|
16
|
+
* Unlike `MrlMenuItem`, it does not close the menu on activation; close it from `onClick`
|
|
17
|
+
* when the navigation keeps the page alive (same-page `#hash` links, `target="_blank"`).
|
|
18
|
+
* @param {MrlMenuItemLinkProps} props - The props for the MrlMenuItemLink component
|
|
19
|
+
* @returns {Element} - rendered MrlMenuItemLink component
|
|
16
20
|
*/
|
|
17
21
|
function MrlMenuItemLink(_ref) {
|
|
18
22
|
var ariaDescribedBy = _ref.ariaDescribedBy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlMenuItemLink.js","sources":["../../../../../src/components/menu/MrlMenuItemLink/MrlMenuItemLink.tsx"],"sourcesContent":["import * as React from 'react';\nimport { linkOpen } from '@muraldevkit/ds-icons';\nimport classnames from 'classnames';\nimport { DSIconType, MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\nimport styles from '../MrlMenuItem/MrlMenuItem.module.scss';\n\nexport interface MrlMenuItemLinkProps {\n\t/** ID for associated description */\n\tariaDescribedBy?: string;\n\n\t/**\n\t Children to be rendered within the menu component\n\t */\n\tchildren: React.ReactNode | string;\n\n\t/** Class names for the menu item */\n\tclassName?: string;\n\n\t/**
|
|
1
|
+
{"version":3,"file":"MrlMenuItemLink.js","sources":["../../../../../src/components/menu/MrlMenuItemLink/MrlMenuItemLink.tsx"],"sourcesContent":["import * as React from 'react';\nimport { linkOpen } from '@muraldevkit/ds-icons';\nimport classnames from 'classnames';\nimport { DSIconType, MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\nimport styles from '../MrlMenuItem/MrlMenuItem.module.scss';\n\nexport interface MrlMenuItemLinkProps {\n\t/** ID for associated description */\n\tariaDescribedBy?: string;\n\n\t/**\n\t Children to be rendered within the menu component\n\t */\n\tchildren: React.ReactNode | string;\n\n\t/** Class names for the menu item */\n\tclassName?: string;\n\n\t/** Disables the link: it stays focusable (`aria-disabled`) but does not navigate */\n\tdisabled?: boolean;\n\n\t/** Href for the menu item */\n\thref: string;\n\n\t/** Icon for menu item */\n\ticon?: DSIconType;\n\n\t/**\n\t * Anchor target. `_blank` marks the link as external: `rel` becomes `noopener noreferrer`\n\t * and a trailing external-link icon is shown.\n\t *\n\t * @default '_self'\n\t */\n\ttarget?: string;\n\n\t/** Unique ID for the menu item */\n\tid?: string;\n\n\t/** Callback to be called when the menu item is clicked */\n\tonClick?: (e: React.MouseEvent<HTMLElement>) => void;\n\n\t/** Data-qa attribute for the menu item */\n\tdataQa?: string;\n\n\t/** If the menu item is selected */\n\tselected?: boolean;\n\n\t/** Rel attribute of the anchor; replaced by `noopener noreferrer` when `target` is `_blank` */\n\trel?: string;\n\n\t/**\n\t * Enables interaction tracking for this menu item. Provide a stable, non-PII id\n\t * (e.g. 'help-menu-docs'). When omitted, the menu item emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * MrlMenuItemLink component\n *\n * Renders a menu item that navigates to a URL (an anchor with `role=\"menuitem\"`), to be used\n * within the MrlMenu component. Links opened with `target=\"_blank\"` get\n * `rel=\"noopener noreferrer\"` and a trailing external-link icon.\n * Unlike `MrlMenuItem`, it does not close the menu on activation; close it from `onClick`\n * when the navigation keeps the page alive (same-page `#hash` links, `target=\"_blank\"`).\n * @param {MrlMenuItemLinkProps} props - The props for the MrlMenuItemLink component\n * @returns {Element} - rendered MrlMenuItemLink component\n */\nexport function MrlMenuItemLink({\n\tariaDescribedBy,\n\tchildren,\n\tclassName,\n\tdataQa,\n\tdisabled,\n\thref,\n\ticon,\n\tid,\n\tonClick,\n\tselected,\n\ttarget = '_self',\n\teventId,\n\t...rest\n}: MrlMenuItemLinkProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlMenuItemLink', eventId);\n\n\tconst handleClick = (e: React.MouseEvent<HTMLElement>): void => {\n\t\ttrackInteraction({ action: 'click', metadata: { target } });\n\n\t\tonClick?.(e);\n\t};\n\n\tconst handleDisabled = (e: React.MouseEvent<HTMLElement>): void => {\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t};\n\n\tconst menuItemClasses = classnames(styles['MrlMenuItem'], 'MrlMenuItem', className);\n\tconst menuTriggerClasses = classnames(styles['MrlMenuItem--item'], 'MrlMenuItem--item');\n\n\tconst isExternalLink = target === '_blank';\n\tconst linkRel = isExternalLink ? 'noopener noreferrer' : rest.rel;\n\n\treturn (\n\t\t<li className={menuItemClasses} data-qa={dataQa}>\n\t\t\t<a\n\t\t\t\t{...rest}\n\t\t\t\taria-describedby={ariaDescribedBy}\n\t\t\t\taria-disabled={disabled}\n\t\t\t\tdata-selected={selected}\n\t\t\t\tdata-qa={dataQa && `${dataQa}-button`}\n\t\t\t\tid={id}\n\t\t\t\trole=\"menuitem\"\n\t\t\t\tonClick={disabled ? handleDisabled : handleClick}\n\t\t\t\tclassName={menuTriggerClasses}\n\t\t\t\trel={linkRel}\n\t\t\t\thref={href}\n\t\t\t\ttarget={target}\n\t\t\t>\n\t\t\t\t{icon && (\n\t\t\t\t\t<span className={styles['MrlMenuItem--item--submenuIcon-left']}>\n\t\t\t\t\t\t<MrlSvg size=\"small\" svg={icon} />\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{children}\n\t\t\t\t{isExternalLink && (\n\t\t\t\t\t<span className={styles['MrlMenuItem--item--icon-right']}>\n\t\t\t\t\t\t<span className={styles['MrlMenuItem--item--linkOpenIcon']}>\n\t\t\t\t\t\t\t<MrlSvg svg={linkOpen} size=\"auto\" />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</a>\n\t\t</li>\n\t);\n}\n"],"names":["MrlMenuItemLink","_ref","ariaDescribedBy","children","className","dataQa","disabled","href","icon","id","onClick","selected","_ref$target","target","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","handleClick","e","action","metadata","handleDisabled","preventDefault","stopPropagation","menuItemClasses","classnames","styles","menuTriggerClasses","isExternalLink","linkRel","rel","React","createElement","_extends","concat","role","MrlSvg","size","svg","linkOpen"],"mappings":";;;;;;;;;AA0DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAeA,CAAAC,IAAA,EAcO;AAAA,EAAA,IAbrCC,eAAe,GAAAD,IAAA,CAAfC,eAAe;IACfC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IACRC,IAAI,GAAAN,IAAA,CAAJM,IAAI;IACJC,IAAI,GAAAP,IAAA,CAAJO,IAAI;IACJC,EAAE,GAAAR,IAAA,CAAFQ,EAAE;IACFC,OAAO,GAAAT,IAAA,CAAPS,OAAO;IACPC,QAAQ,GAAAV,IAAA,CAARU,QAAQ;IAAAC,WAAA,GAAAX,IAAA,CACRY,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAA,MAAA,GAAG,OAAO,GAAAA,WAAA;IAChBE,OAAO,GAAAb,IAAA,CAAPa,OAAO;AACJC,IAAAA,IAAI,GAAAC,wBAAA,CAAAf,IAAA,EAAAgB,SAAA,CAAA;AAEP,EAAA,IAAMC,gBAAgB,GAAGC,sBAAsB,CAAC,iBAAiB,EAAEL,OAAO,CAAC;EAE3E,IAAMM,WAAW,GAAIC,CAAgC,IAAW;AAC/DH,IAAAA,gBAAgB,CAAC;AAAEI,MAAAA,MAAM,EAAE,OA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AA,MAAM,EAAEA;AAAO,GAAA,CAAA,EAEdL,IAAI,iBACJ0B,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IAAM/B,SAAS,EAAEyB,MAAM,CAAC,qCAAqC;AAAE,GAAA,eAC9DK,KAAA,CAAAC,aAAA,CAACI,MAAM,EAAA;AAACC,IAAAA,IAAI,EAAC,OAAO;AAACC,IAAAA,GAAG,EAAEjC;GAAO,CAC5B,CACN,EACAL,QAAQ,EACR4B,cAAc,iBACdG,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IAAM/B,SAAS,EAAEyB,MAAM,CAAC,+BAA+B;GAAE,eACxDK,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IAAM/B,SAAS,EAAEyB,MAAM,CAAC,iCAAiC;AAAE,GAAA,eAC1DK,KAAA,CAAAC,aAAA,CAACI,MAAM,EAAA;AAACE,IAAAA,GAAG,EAAEC,QAAS;AAACF,IAAAA,IAAI,EAAC;AAAM,GAAE,CAC/B,CACD,CAEL,CACA,CAAC;AAEP;;;;"}
|
|
@@ -9,7 +9,7 @@ import { useMrlModalContext } from '../MrlModalContext/MrlModalContext.js';
|
|
|
9
9
|
|
|
10
10
|
var _excluded = ["children", "className"];
|
|
11
11
|
/**
|
|
12
|
-
* Modal Content component for the MrlModal
|
|
12
|
+
* Modal Content component for the MrlModal. Must be rendered inside `MrlModal`.
|
|
13
13
|
* @param {object} props - The props object
|
|
14
14
|
* @param {React.ReactElement} props.children - The children to be rendered within the component
|
|
15
15
|
* @returns {React.ReactElement}} The rendered MrlModalContent component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlModalContent.js","sources":["../../../../../src/components/modal/MrlModalContent/MrlModalContent.tsx"],"sourcesContent":["import * as React from 'react';\nimport classNames from 'classnames';\nimport { isElementScrollable } from '../../../utils/isElementScrollable';\n\nimport styles from './MrlModalContent.module.scss';\nimport { useMrlModalContext } from '../MrlModalContext';\nimport { hasScrollContent } from '../../../utils/hasScrollContent/hasScrollContent';\nimport { useHasFocusableDescendant } from '../../../hooks/useHasFocusableDescendant';\n\ninterface MrlModalContentProps {\n\t/**\n\t *
|
|
1
|
+
{"version":3,"file":"MrlModalContent.js","sources":["../../../../../src/components/modal/MrlModalContent/MrlModalContent.tsx"],"sourcesContent":["import * as React from 'react';\nimport classNames from 'classnames';\nimport { isElementScrollable } from '../../../utils/isElementScrollable';\n\nimport styles from './MrlModalContent.module.scss';\nimport { useMrlModalContext } from '../MrlModalContext';\nimport { hasScrollContent } from '../../../utils/hasScrollContent/hasScrollContent';\nimport { useHasFocusableDescendant } from '../../../hooks/useHasFocusableDescendant';\n\ninterface MrlModalContentProps {\n\t/**\n\t * Body of the modal, rendered between `MrlModalHeader` and `MrlModalFooter`. When it\n\t * overflows, this is the modal's only scrolling area: it is exposed as a `region` labelled\n\t * from the header text, and is focusable (`tabindex=\"0\"`) only when it contains no focusable\n\t * elements, so keyboard users can still scroll it.\n\t */\n\tchildren: React.ReactElement | React.ReactElement[];\n\n\t/**\n\t * Wrapper Class\n\t */\n\tclassName?: string;\n}\n\n/**\n * Modal Content component for the MrlModal. Must be rendered inside `MrlModal`.\n * @param {object} props - The props object\n * @param {React.ReactElement} props.children - The children to be rendered within the component\n * @returns {React.ReactElement}} The rendered MrlModalContent component\n */\nexport const MrlModalContent = ({\n\tchildren,\n\tclassName,\n\t...rest\n}: MrlModalContentProps): JSX.Element => {\n\tconst { scrollableContent, setScrollableContent, title } = useMrlModalContext();\n\tconst contentAreaRef = React.useRef<HTMLDivElement>(null);\n\tconst hasFocusableDescendant = useHasFocusableDescendant(contentAreaRef);\n\n\tReact.useEffect(() => {\n\t\tif (!contentAreaRef.current) return;\n\n\t\t/**\n\t\t * Sets up observer to toggle tabindex value on the scrollable region within the modal. When\n\t\t * the content area is overflowed and has no focusable descendants, we want to set tabindex\n\t\t * to 0 so that keyboard-only users can scroll through the content. Per ACT rule 0ssw9k a\n\t\t * scrollable region passes WCAG 2.1.1 Keyboard either by being focusable itself or by having\n\t\t * a focusable descendant, so we omit `tabindex=\"0\"` whenever a descendant control is\n\t\t * already keyboard reachable. The labeled `role=\"region\"` is preserved whenever the modal\n\t\t * content overflows so screen-reader users get a landmark in either case.\n\t\t * https://www.w3.org/WAI/standards-guidelines/act/rules/0ssw9k/\n\t\t */\n\t\tconst contentArea = contentAreaRef.current;\n\n\t\tcontentArea.addEventListener('scroll', () => {\n\t\t\tsetScrollableContent({\n\t\t\t\t...hasScrollContent(contentArea),\n\t\t\t\tisContentScrollable: isElementScrollable(contentArea)\n\t\t\t});\n\t\t});\n\n\t\tconst observer = new ResizeObserver(() => {\n\t\t\tsetScrollableContent({\n\t\t\t\t...hasScrollContent(contentArea),\n\t\t\t\tisContentScrollable: isElementScrollable(contentArea)\n\t\t\t});\n\t\t});\n\n\t\tobserver.observe(contentArea);\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [setScrollableContent]);\n\n\tconst contentClasses = classNames('mrl-modal-content', className, styles['mrl-modal-content'], {\n\t\t'mrl-modal-content-scrollable': scrollableContent.isContentScrollable\n\t});\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tref={contentAreaRef}\n\t\t\tclassName={contentClasses}\n\t\t\t{...(scrollableContent.isContentScrollable && {\n\t\t\t\t'aria-label': title ? `${title} modal scrollable content` : 'modal scrollable content',\n\t\t\t\trole: 'region',\n\t\t\t\t...(!hasFocusableDescendant && { tabIndex: 0 })\n\t\t\t})}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n};\n"],"names":["MrlModalContent","_ref","children","className","rest","_objectWithoutProperties","_excluded","_useMrlModalContext","useMrlModalContext","scrollableContent","setScrollableContent","title","contentAreaRef","React","useRef","hasFocusableDescendant","useHasFocusableDescendant","useEffect","current","contentArea","addEventListener","_objectSpread","hasScrollContent","isContentScrollable","isElementScrollable","observer","ResizeObserver","observe","disconnect","contentClasses","classNames","styles","createElement","_extends","ref","concat","role","tabIndex"],"mappings":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AAC,CAAC;AAEFM,IAAAA,QAAQ,CAACE,OAAO,CAACR,WAAW,CAAC;AAE7B,IAAA,OAAO,MAAM;MACZM,QAAQ,CAACG,UAAU,EAAE;IACtB,CAAC;AACF,EAAA,CAAC,EAAE,CAAClB,oBAAoB,CAAC,CAAC;AAE1B,EAAA,IAAMmB,cAAc,GAAGC,UAAU,CAAC,mBAAmB,EAAE3B,SAAS,EAAE4B,MAAM,CAAC,mBAAmB,CAAC,EAAE;IAC9F,8BAA8B,EAAEtB,iBAAiB,CAACc;AACnD,GAAC,CAAC;AAEF,EAAA,oBACCV,KAAA,CAAAmB,aAAA,CAAA,KAAA,EAAAC,QAAA,KACK7B,IAAI,EAAA;AACR8B,IAAAA,GAAG,EAAEtB,cAAe;AACpBT,IAAAA,SAAS,EAAE0B;AAAe,GAAA,EACrBpB,iBAAiB,CAACc,mBAAmB,IAAAF,cAAA,CAAA;AACzC,IAAA,YAAY,EAAEV,KAAK,GAAA,EAAA,CAAAwB,MAAA,CAAMxB,KAAK,iCAA8B,0BAA0B;AACtFyB,IAAAA,IAAI,EAAE;GAAQ,EACV,CAACrB,sBAAsB,IAAI;AAAEsB,IAAAA,QAAQ,EAAE;GAAG,CAC9C,CAAA,EAEAnC,QACG,CAAC;AAER;;;;"}
|
|
@@ -8,7 +8,8 @@ import { setAttributes } from '../../../utils/setAttributes/setAttributes.js';
|
|
|
8
8
|
|
|
9
9
|
var _excluded = ["attrs", "children", "className"];
|
|
10
10
|
/**
|
|
11
|
-
* Modal Footer component for the MrlModal
|
|
11
|
+
* Modal Footer component for the MrlModal. Must be rendered inside `MrlModal`, after
|
|
12
|
+
* `MrlModalContent`.
|
|
12
13
|
* @param {AttrsObject} attrs - Additional HTML attributes for the `mrl-modal` element
|
|
13
14
|
* @returns {React.ReactElement} The rendered MrlModalFooter component
|
|
14
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlModalFooter.js","sources":["../../../../../src/components/modal/MrlModalFooter/MrlModalFooter.tsx"],"sourcesContent":["import * as React from 'react';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport classNames from 'classnames';\n\nimport styles from './MrlModalFooter.module.scss';\nimport './MrlModalFooter.global.scss';\nimport { useBreakpoint } from '../../../hooks/useBreakpoint';\nimport { useMrlModalContext } from '../MrlModalContext';\n\ninterface MrlModalFooterProps extends MrlComponentProps {\n\t/**\n\t *
|
|
1
|
+
{"version":3,"file":"MrlModalFooter.js","sources":["../../../../../src/components/modal/MrlModalFooter/MrlModalFooter.tsx"],"sourcesContent":["import * as React from 'react';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport classNames from 'classnames';\n\nimport styles from './MrlModalFooter.module.scss';\nimport './MrlModalFooter.global.scss';\nimport { useBreakpoint } from '../../../hooks/useBreakpoint';\nimport { useMrlModalContext } from '../MrlModalContext';\n\ninterface MrlModalFooterProps extends MrlComponentProps {\n\t/**\n\t * Actions of the modal, laid out in a row and stacked at full width on the `xs` breakpoint.\n\t * Order them from least to most prominent, ending with the primary action.\n\t */\n\tchildren?: React.ReactElement | React.ReactElement[];\n\n\t/**\n\t * Wrapper Class\n\t */\n\tclassName?: string;\n}\n\n/**\n * Modal Footer component for the MrlModal. Must be rendered inside `MrlModal`, after\n * `MrlModalContent`.\n * @param {AttrsObject} attrs - Additional HTML attributes for the `mrl-modal` element\n * @returns {React.ReactElement} The rendered MrlModalFooter component\n */\nexport const MrlModalFooter = ({\n\tattrs = {},\n\tchildren,\n\tclassName,\n\t...rest\n}: MrlModalFooterProps): JSX.Element => {\n\tconst { scrollableContent } = useMrlModalContext();\n\tconst breakpoint = useBreakpoint();\n\tconst attributes = setAttributes(attrs);\n\tconst modalFooterClasses = classNames(className, 'mrl-modal-footer', styles['mrl-modal-footer'], {\n\t\t[styles['slotted']]: breakpoint === 'xs',\n\t\t[styles['mrl-modal-scroll-shadow-bottom']]: scrollableContent.hasScrollBottom\n\t});\n\n\tdelete attributes.class;\n\tdelete attributes.className;\n\n\treturn (\n\t\t<div {...rest} {...attributes} className={modalFooterClasses}>\n\t\t\t<div className={classNames('mrl-modal-footer-wrapper', styles['mrl-modal-footer-wrapper'])}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n"],"names":["MrlModalFooter","_ref","_ref$attrs","attrs","children","className","rest","_objectWithoutProperties","_excluded","_useMrlModalContext","useMrlModalContext","scrollableContent","breakpoint","useBreakpoint","attributes","setAttributes","modalFooterClasses","classNames","styles","hasScrollBottom","class","React","createElement","_extends"],"mappings":";;;;;;;;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,cAAc,GAAGC,IAAA,IAKU;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAJvCE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,SAAS,GAAAJ,IAAA,CAATI,SAAS;AACNC,IAAAA,IAAI,GAAAC,wBAAA,CAAAN,IAAA,EAAAO,SAAA,CAAA;AAEP,EAAA,IAAAC,mBAAA,GAA8BC,kBAAkB,EAAE;IAA1CC,iBAAiB,GAAAF,mBAAA,CAAjBE,iBAAiB;AACzB,EAAA,IAAMC,UAAU,GAAGC,aAAa,EAAE;AAClC,EAAA,IAAMC,UAAU,GAAGC,aAAa,CAACZ,KAAK,CAAC;AACvC,EAAA,IAAMa,kBAAkB,GAAGC,UAAU,CAACZ,SAAS,EAAE,kBAAkB,EAAEa,MAAM,CAAC,kBAAkB,CAAC,EAAE;AAChG,IAAA,CAACA,MAAM,CAAC,SAAS,CAAC,GAAGN,UAAU,KAAK,IAAI;AACxC,IAAA,CAACM,MAAM,CAAC,gCAAgC,CAAC,GAAGP,iBAAiB,CAACQ;AAC/D,GAAC,CAAC;EAEF,OAAOL,UAAU,CAACM,KAAK;EACvB,OAAON,UAAU,CAACT,SAAS;EAE3B,oBACCgB,KAAA,CAAAC,aAAA,CAAA,KAAA,EAAAC,QAAA,CAAA,EAAA,EAASjB,IAAI,EAAMQ,UAAU,EAAA;AAAET,IAAAA,SAAS,EAAEW;GAAmB,CAAA,eAC5DK,KAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;IAAKjB,SAAS,EAAEY,UAAU,CAAC,0BAA0B,EAAEC,MAAM,CAAC,0BAA0B,CAAC;GAAE,EACzFd,QACG,CACD,CAAC;AAER;;;;"}
|
|
@@ -8,7 +8,7 @@ import { setAttributes } from '../../../utils/setAttributes/setAttributes.js';
|
|
|
8
8
|
|
|
9
9
|
var _excluded = ["attrs", "children", "className", "text"];
|
|
10
10
|
/**
|
|
11
|
-
* Modal Header component for the MrlModal.
|
|
11
|
+
* Modal Header component for the MrlModal. Must be rendered inside `MrlModal`.
|
|
12
12
|
* @param {MrlModalHeaderProps} props - The props for the MrlModalFooter component
|
|
13
13
|
* @param {AttrsObject} props.attrs - Additional HTML attributes for the `mrl-modal` element
|
|
14
14
|
* @returns {React.ReactElement} The rendered MrlModalFooter component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlModalHeader.js","sources":["../../../../../src/components/modal/MrlModalHeader/MrlModalHeader.tsx"],"sourcesContent":["import * as React from 'react';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport classNames from 'classnames';\nimport { MrlTextHeading } from '../../text/MrlTextHeading/MrlTextHeading';\n\nimport styles from './MrlModalHeader.module.scss';\nimport { useMrlModalContext } from '../MrlModalContext';\n\nexport interface MrlModalHeaderProps extends MrlComponentProps {\n\t/**\n\t * Content
|
|
1
|
+
{"version":3,"file":"MrlModalHeader.js","sources":["../../../../../src/components/modal/MrlModalHeader/MrlModalHeader.tsx"],"sourcesContent":["import * as React from 'react';\nimport { AttrsObject, MrlComponentProps, setAttributes } from '../../../utils';\nimport classNames from 'classnames';\nimport { MrlTextHeading } from '../../text/MrlTextHeading/MrlTextHeading';\n\nimport styles from './MrlModalHeader.module.scss';\nimport { useMrlModalContext } from '../MrlModalContext';\n\nexport interface MrlModalHeaderProps extends MrlComponentProps {\n\t/**\n\t * Content rendered after the heading, inside the header row. The close button is not part of\n\t * the header; `MrlModal` renders it.\n\t */\n\tchildren?: React.ReactNode;\n\n\t/**\n\t * Wrapper Class\n\t */\n\tclassName?: string;\n\n\t/**\n\t * Text of the modal header `h2` element. It also labels the modal's scrollable content region.\n\t */\n\ttext: string;\n}\n\n/**\n * Modal Header component for the MrlModal. Must be rendered inside `MrlModal`.\n * @param {MrlModalHeaderProps} props - The props for the MrlModalFooter component\n * @param {AttrsObject} props.attrs - Additional HTML attributes for the `mrl-modal` element\n * @returns {React.ReactElement} The rendered MrlModalFooter component\n */\nexport const MrlModalHeader = ({\n\tattrs = {},\n\tchildren,\n\tclassName,\n\ttext,\n\t...rest\n}: MrlModalHeaderProps): JSX.Element => {\n\tconst { scrollableContent, setTitle } = useMrlModalContext();\n\tconst attributes = setAttributes(attrs);\n\tconst classes = classNames(className, 'mrl-modal-header', styles['mrl-modal-header'], {\n\t\t[styles['mrl-modal-scroll-shadow-top']]: scrollableContent.hasScrollTop\n\t});\n\n\tReact.useEffect(() => {\n\t\tsetTitle(text);\n\t}, [text, setTitle]);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\treturn (\n\t\t<div {...rest} {...attributes} className={classes}>\n\t\t\t<MrlTextHeading\n\t\t\t\tattrs={{ className: 'mrl-modal-text-heading' }}\n\t\t\t\tlevel=\"2\"\n\t\t\t\ttext={text}\n\t\t\t\tsize=\"large\"\n\t\t\t/>\n\t\t\t{children}\n\t\t\t{/* Looking for the close button? The close button is intentionally part of the overall modal container, not the header */}\n\t\t</div>\n\t);\n};\n"],"names":["MrlModalHeader","_ref","_ref$attrs","attrs","children","className","text","rest","_objectWithoutProperties","_excluded","_useMrlModalContext","useMrlModalContext","scrollableContent","setTitle","attributes","setAttributes","classes","classNames","styles","hasScrollTop","React","useEffect","class","createElement","_extends","MrlTextHeading","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B;AAC/CqB,IAAAA,KAAK,EAAC,GAAG;AACTpB,IAAAA,IAAI,EAAEA,IAAK;AACXqB,IAAAA,IAAI,EAAC;GACL,CAAC,EACDvB,QAEG,CAAC;AAER;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlPanel.js","sources":["../../../../../src/components/panel/MrlPanel/MrlPanel.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport styles from './MrlPanel.module.scss';\nimport { MrlIconButton } from '../../button';\nimport { MrlSvg } from '../../svg';\nimport { close } from '@muraldevkit/ds-icons';\nimport { MrlFocusTrap } from '../../focus-trap';\nimport { MrlText, MrlTextHeading } from '../../text';\nimport { MrlDivider } from '../../divider';\nimport { MrlPanelContext } from '../MrlPanelContext';\nimport { useHasFocusableDescendant } from '../../../hooks/useHasFocusableDescendant';\nimport { useScrollbarInfo } from '../../../hooks/useScrollbarInfo';\nimport { getUniqueId } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\n/**\n * Props for the MrlPanel component.\n */\ninterface MrlPanelProps extends React.ComponentPropsWithRef<'div'> {\n\t/**\n\t * A string value used for data-qa attribute.\n\t */\n\t['data-qa']?: string;\n\n\t/**\n\t * Callback function that is called when the panel is closed.\n\t */\n\tonClose?: () => void;\n\n\t/**\n\t * The custom header element to be rendered in the panel.\n\t * When a custom header is used developers need to provide th aria-label and aria-describedby.\n\t */\n\theader?: React.ReactNode;\n\n\t/**\n\t * The custom top actions to be rendered in the panel header.\n\t * By default top actions are rendered on the right side of the title and include a MrlDivider at the end.\n\t * The close button should not be included as part of the top actions.\n\t */\n\ttopActions?: React.ReactNode;\n\n\t/**\n\t * The title of the panel.\n\t */\n\ttitle?: string;\n\n\t/**\n\t * The description of the panel.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Specifies whether to disable autofocus on the panel.\n\t */\n\tdisableAutofocus?: boolean;\n\n\t/**\n\t * Specifies whether the panel has a sticky header to adjust styles.\n\t */\n\thasStickyHeader?: boolean;\n\n\t/**\n\t * hasDataScrollAnchor is required to enable infinite scroll\n\t */\n\thasDataScrollAnchor?: boolean;\n\n\t/**\n\t * Enables interaction tracking for this panel. Provide a stable, non-PII id\n\t * (e.g. 'comments-panel'). When omitted, the panel emits no analytics.\n\t *\n\t * `open` is emitted when the panel mounts, since consumers control the panel's\n\t * presence by rendering it.\n\t */\n\teventId?: string;\n}\n\n/**\n * MrlPanel component.\n *\n * @param props The MrlPanel component properties.\n * @returns The MrlPanel component.\n */\nexport const MrlPanel = React.forwardRef<HTMLDivElement, MrlPanelProps>(\n\tfunction MrlPanel(props, ref): JSX.Element {\n\t\tconst {\n\t\t\tclassName,\n\t\t\ttitle,\n\t\t\tid,\n\t\t\tchildren,\n\t\t\thasStickyHeader,\n\t\t\theader,\n\t\t\tdescription,\n\t\t\tdisableAutofocus,\n\t\t\ttopActions,\n\t\t\thasDataScrollAnchor,\n\t\t\tonClose,\n\t\t\teventId,\n\t\t\t['data-qa']: qa = 'panel',\n\t\t\t...rest\n\t\t} = props;\n\n\t\tconst panelRef = React.useRef<HTMLDivElement>(null);\n\n\t\tconst trackInteraction = useMrlTrackInteraction('MrlPanel', eventId);\n\n\t\tReact.useEffect(() => {\n\t\t\ttrackInteraction({ action: 'open' });\n\t\t\t// the panel is open for as long as the consumer renders it\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, []);\n\n\t\t/**\n\t\t * Handles closing the panel from both the close button and the escape key.\n\t\t */\n\t\tconst handleClose = React.useCallback(() => {\n\t\t\ttrackInteraction({ action: 'close' });\n\n\t\t\tonClose?.();\n\t\t}, [onClose, trackInteraction]);\n\n\t\t// Unique ID for aria-describedby\n\t\tconst descriptionIdRef = React.useRef<string>(\n\t\t\tdescription ? getUniqueId('mrl-panel-description') : ''\n\t\t);\n\n\t\tconst {\n\t\t\tscrollableContainerRef,\n\t\t\thasVerticalScrollbar,\n\t\t\thasHorizontalScrollbar,\n\t\t\thorizontalScrollbarHeight,\n\t\t\tverticalScrollbarWidth\n\t\t} = useScrollbarInfo<HTMLDivElement>();\n\n\t\tconst hasFocusableDescendant = useHasFocusableDescendant(scrollableContainerRef);\n\n\t\tReact.useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => {\n\t\t\treturn panelRef.current;\n\t\t});\n\n\t\tconst handleKeyDown = React.useCallback(\n\t\t\t(e: React.KeyboardEvent<HTMLDivElement>) => {\n\t\t\t\tif (e.key === 'Escape' && typeof onClose === 'function') {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\thandleClose();\n\t\t\t\t}\n\t\t\t},\n\t\t\t[onClose, handleClose]\n\t\t);\n\n\t\tconst panelClasses = classnames(styles['MrlPanel'], 'MrlPanel', className);\n\n\t\treturn (\n\t\t\t<MrlPanelContext.Provider\n\t\t\t\tvalue={{\n\t\t\t\t\thasHorizontalScrollbar,\n\t\t\t\t\thasVerticalScrollbar,\n\t\t\t\t\thorizontalScrollbarHeight,\n\t\t\t\t\tverticalScrollbarWidth\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n\t\t\t\t<div\n\t\t\t\t\t{...rest}\n\t\t\t\t\tclassName={panelClasses}\n\t\t\t\t\taria-describedby={descriptionIdRef.current || props['aria-describedby']}\n\t\t\t\t\taria-label={title || props['aria-label']}\n\t\t\t\t\taria-modal=\"false\"\n\t\t\t\t\tdata-qa={qa}\n\t\t\t\t\tid={id}\n\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\tref={panelRef}\n\t\t\t\t>\n\t\t\t\t\t<MrlFocusTrap containerRef={panelRef} disableAutofocus={disableAutofocus}>\n\t\t\t\t\t\t<header className={classnames(styles['MrlPanel--header'], 'MrlPanel--header')}>\n\t\t\t\t\t\t\t{!header && (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\t\tstyles['MrlPanel--header-content'],\n\t\t\t\t\t\t\t\t\t\t'MrlPanel--header-content',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t[styles['MrlPanel--header-content-description']]: !!description\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<MrlTextHeading\n\t\t\t\t\t\t\t\t\t\tclassName={styles['MrlPanel--title']}\n\t\t\t\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\t\t\t\t'data-qa': `${qa}-header-title`,\n\t\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\thierarchy=\"primary\"\n\t\t\t\t\t\t\t\t\t\tkind=\"title\"\n\t\t\t\t\t\t\t\t\t\tlevel=\"2\"\n\t\t\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\t\t\ttext={title}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{topActions && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles['MrlPanel--top-actions'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t'MrlPanel--top-actions'\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{topActions}\n\t\t\t\t\t\t\t\t\t\t\t\t<MrlDivider\n\t\t\t\t\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tspacing=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tlength=\"var(--mrl-spacing-06)\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyles['MrlPanel--top-actions-divider'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'MrlPanel--top-actions-divider'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{header}\n\t\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\t\tdata-qa={`${qa}-close-button`}\n\t\t\t\t\t\t\t\twrapperClassName={classnames(styles['MrlPanel--close'], 'MrlPanel--close')}\n\t\t\t\t\t\t\t\ticon={<MrlSvg svg={close} />}\n\t\t\t\t\t\t\t\tonClick={handleClose}\n\t\t\t\t\t\t\t\ttext=\"Close\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t\t\tposition=\"bottom\"\n\t\t\t\t\t\t\t\ttipAnchor=\"center\"\n\t\t\t\t\t\t\t\tkind=\"ghost\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</header>\n\n\t\t\t\t\t\t{/*\n\t\t\t\t\t\t * Scrollable container — includes description, sticky header and main\n\t\t\t\t\t\t * content. Per ACT rule 0ssw9k a scrollable element passes WCAG 2.1.1\n\t\t\t\t\t\t * Keyboard if it is itself focusable OR has a focusable descendant. We\n\t\t\t\t\t\t * therefore expose `tabindex=\"0\"` only when the wrapper has no focusable\n\t\t\t\t\t\t * descendants, which avoids the \"meaningless tab stop\" finding for\n\t\t\t\t\t\t * panels filled with interactive controls while still making text-only\n\t\t\t\t\t\t * panels keyboard-scrollable. The labeled `role=\"region\"` is preserved\n\t\t\t\t\t\t * whenever the panel overflows so screen-reader users get a landmark.\n\t\t\t\t\t\t * https://www.w3.org/WAI/standards-guidelines/act/rules/0ssw9k/\n\t\t\t\t\t\t */}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={scrollableContainerRef}\n\t\t\t\t\t\t\tdata-scroll-anchor={hasDataScrollAnchor}\n\t\t\t\t\t\t\tdata-qa={`${qa}-scrollable`}\n\t\t\t\t\t\t\tclassName={classnames(styles['MrlPanel--scrollable'], 'MrlPanel--scrollable', {\n\t\t\t\t\t\t\t\t[styles['MrlPanel--scrollable-has-sticky-header']]: hasStickyHeader\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t{...(verticalScrollbarWidth > 0 && {\n\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\tpaddingRight: `calc(var(--mrl-spacing-06) - ${verticalScrollbarWidth}px)`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t{...(hasVerticalScrollbar && {\n\t\t\t\t\t\t\t\t'aria-label': title\n\t\t\t\t\t\t\t\t\t? `${title} panel scrollable content`\n\t\t\t\t\t\t\t\t\t: 'Panel scrollable content',\n\t\t\t\t\t\t\t\trole: 'region',\n\t\t\t\t\t\t\t\t...(!hasFocusableDescendant && {\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n\t\t\t\t\t\t\t\t\ttabIndex: 0\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{description && (\n\t\t\t\t\t\t\t\t<MrlText\n\t\t\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\t\t\tclassName: classnames(styles['MrlPanel--description'], 'MrlPanel--description'),\n\t\t\t\t\t\t\t\t\t\tid: descriptionIdRef.current\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tsize=\"xsmall\"\n\t\t\t\t\t\t\t\t\ttext={description}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</MrlFocusTrap>\n\t\t\t\t</div>\n\t\t\t</MrlPanelContext.Provider>\n\t\t);\n\t}\n);\n"],"names":["MrlPanel","React","forwardRef","props","ref","className","title","id","children","hasStickyHeader","header","description","disableAutofocus","topActions","hasDataScrollAnchor","onClose","eventId","_props$dataQa","qa","rest","_objectWithoutProperties","_excluded","panelRef","useRef","trackInteraction","useMrlTrackInteraction","useEffect","action","handleClose","useCallback","descriptionIdRef","getUniqueId","_useScrollbarInfo","useScrollbarInfo","scrollableContainerRef","hasVerticalScrollbar","hasHorizontalScrollbar","horizontalScrollbarHeight","verticalScrollbarWidth","hasFocusableDescendant","useHasFocusableDescendant","useImperativeHandle","current","handleKeyDown","e","key","preventDefault","stopPropagation","panelClasses","classnames","styles","createElement","MrlPanelContext","Provider","value","_extends","onKeyDown","role","MrlFocusTrap","containerRef","MrlTextHeading","attrs","concat","hierarchy","kind","level","size","text","Fragment","MrlDivider","orientation","spacing","length","MrlIconButton","wrapperClassName","icon","MrlSvg","svg","close","onClick","state","position","tipAnchor","style","paddingRight","_objectSpread","tabIndex","MrlText"],"mappings":";;;;;;;;;;;;;;;;;;;AAeA;AACA;AACA;;AA4DA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,QAAQ,gBAAGC,KAAK,CAACC,UAAU,CACvC,SAASF,QAAQA,CAACG,KAAK,EAAEC,GAAG,EAAe;AAC1C,EAAA,IACCC,SAAS,GAcNF,KAAK,CAdRE,SAAS;IACTC,KAAK,GAaFH,KAAK,CAbRG,KAAK;IACLC,EAAE,GAYCJ,KAAK,CAZRI,EAAE;IACFC,QAAQ,GAWLL,KAAK,CAXRK,QAAQ;IACRC,eAAe,GAUZN,KAAK,CAVRM,eAAe;IACfC,MAAM,GASHP,KAAK,CATRO,MAAM;IACNC,WAAW,GAQRR,KAAK,CARRQ,WAAW;IACXC,gBAAgB,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B,sBAAsB,GAAG,CAAC,IAAI;AAClC6C,IAAAA,KAAK,EAAE;MACNC,YAAY,EAAA,+BAAA,CAAAtB,MAAA,CAAkCxB,sBAAsB,EAAA,KAAA;AACrE;GACA,EACIH,oBAAoB,IAAAkD,cAAA,CAAA;AACxB,IAAA,YAAY,EAAE/E,KAAK,GAAA,EAAA,CAAAwD,MAAA,CACbxD,KAAK,iCACR,0BAA0B;AAC7BmD,IAAAA,IAAI,EAAE;GAAQ,EACV,CAAClB,sBAAsB,IAAI;AAC9B;AACA+C,IAAAA,QAAQ,EAAE;GACV,CACD,GAEA3E,WAAW,iBACXV,KAAA,CAAAkD,aAAA,CAACoC,OAAO,EAAA;AACP1B,IAAAA,KAAK,EAAE;MACNxD,SAAS,EAAE4C,UAAU,CAACC,MAAM,CAAC,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;MAC/E3C,EAAE,EAAEuB,gBAAgB,CAACY;KACpB;AACFwB,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,IAAI,EAAExD;AAAY,GAClB,CACD,EACAH,QACG,CACQ,CACV,CACoB,CAAC;AAE7B,CACD;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlPanel.js","sources":["../../../../../src/components/panel/MrlPanel/MrlPanel.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport styles from './MrlPanel.module.scss';\nimport { MrlIconButton } from '../../button';\nimport { MrlSvg } from '../../svg';\nimport { close } from '@muraldevkit/ds-icons';\nimport { MrlFocusTrap } from '../../focus-trap';\nimport { MrlText, MrlTextHeading } from '../../text';\nimport { MrlDivider } from '../../divider';\nimport { MrlPanelContext } from '../MrlPanelContext';\nimport { useHasFocusableDescendant } from '../../../hooks/useHasFocusableDescendant';\nimport { useScrollbarInfo } from '../../../hooks/useScrollbarInfo';\nimport { getUniqueId } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\n/**\n * Props for the MrlPanel component.\n */\ninterface MrlPanelProps extends React.ComponentPropsWithRef<'div'> {\n\t/**\n\t * A string value used for data-qa attribute.\n\t */\n\t['data-qa']?: string;\n\n\t/**\n\t * Callback function that is called when the panel is closed.\n\t */\n\tonClose?: () => void;\n\n\t/**\n\t * The custom header element to be rendered in the panel.\n\t * When a custom header is used developers need to provide th aria-label and aria-describedby.\n\t */\n\theader?: React.ReactNode;\n\n\t/**\n\t * The custom top actions to be rendered in the panel header.\n\t * By default top actions are rendered on the right side of the title and include a MrlDivider at the end.\n\t * The close button should not be included as part of the top actions.\n\t */\n\ttopActions?: React.ReactNode;\n\n\t/**\n\t * The title of the panel.\n\t */\n\ttitle?: string;\n\n\t/**\n\t * The description of the panel.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Specifies whether to disable autofocus on the panel.\n\t */\n\tdisableAutofocus?: boolean;\n\n\t/**\n\t * Specifies whether the panel has a sticky header to adjust styles. Set it when the first child\n\t * is an `MrlPanelStickyHeader`, so the scroll area leaves room for it.\n\t */\n\thasStickyHeader?: boolean;\n\n\t/**\n\t * hasDataScrollAnchor is required to enable infinite scroll\n\t */\n\thasDataScrollAnchor?: boolean;\n\n\t/**\n\t * Enables interaction tracking for this panel. Provide a stable, non-PII id\n\t * (e.g. 'comments-panel'). When omitted, the panel emits no analytics.\n\t *\n\t * `open` is emitted when the panel mounts, since consumers control the panel's\n\t * presence by rendering it.\n\t */\n\teventId?: string;\n}\n\n/**\n * MrlPanel component.\n *\n * @param props The MrlPanel component properties.\n * @returns The MrlPanel component.\n */\nexport const MrlPanel = React.forwardRef<HTMLDivElement, MrlPanelProps>(\n\tfunction MrlPanel(props, ref): JSX.Element {\n\t\tconst {\n\t\t\tclassName,\n\t\t\ttitle,\n\t\t\tid,\n\t\t\tchildren,\n\t\t\thasStickyHeader,\n\t\t\theader,\n\t\t\tdescription,\n\t\t\tdisableAutofocus,\n\t\t\ttopActions,\n\t\t\thasDataScrollAnchor,\n\t\t\tonClose,\n\t\t\teventId,\n\t\t\t['data-qa']: qa = 'panel',\n\t\t\t...rest\n\t\t} = props;\n\n\t\tconst panelRef = React.useRef<HTMLDivElement>(null);\n\n\t\tconst trackInteraction = useMrlTrackInteraction('MrlPanel', eventId);\n\n\t\tReact.useEffect(() => {\n\t\t\ttrackInteraction({ action: 'open' });\n\t\t\t// the panel is open for as long as the consumer renders it\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, []);\n\n\t\t/**\n\t\t * Handles closing the panel from both the close button and the escape key.\n\t\t */\n\t\tconst handleClose = React.useCallback(() => {\n\t\t\ttrackInteraction({ action: 'close' });\n\n\t\t\tonClose?.();\n\t\t}, [onClose, trackInteraction]);\n\n\t\t// Unique ID for aria-describedby\n\t\tconst descriptionIdRef = React.useRef<string>(\n\t\t\tdescription ? getUniqueId('mrl-panel-description') : ''\n\t\t);\n\n\t\tconst {\n\t\t\tscrollableContainerRef,\n\t\t\thasVerticalScrollbar,\n\t\t\thasHorizontalScrollbar,\n\t\t\thorizontalScrollbarHeight,\n\t\t\tverticalScrollbarWidth\n\t\t} = useScrollbarInfo<HTMLDivElement>();\n\n\t\tconst hasFocusableDescendant = useHasFocusableDescendant(scrollableContainerRef);\n\n\t\tReact.useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => {\n\t\t\treturn panelRef.current;\n\t\t});\n\n\t\tconst handleKeyDown = React.useCallback(\n\t\t\t(e: React.KeyboardEvent<HTMLDivElement>) => {\n\t\t\t\tif (e.key === 'Escape' && typeof onClose === 'function') {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\te.stopPropagation();\n\t\t\t\t\thandleClose();\n\t\t\t\t}\n\t\t\t},\n\t\t\t[onClose, handleClose]\n\t\t);\n\n\t\tconst panelClasses = classnames(styles['MrlPanel'], 'MrlPanel', className);\n\n\t\treturn (\n\t\t\t<MrlPanelContext.Provider\n\t\t\t\tvalue={{\n\t\t\t\t\thasHorizontalScrollbar,\n\t\t\t\t\thasVerticalScrollbar,\n\t\t\t\t\thorizontalScrollbarHeight,\n\t\t\t\t\tverticalScrollbarWidth\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n\t\t\t\t<div\n\t\t\t\t\t{...rest}\n\t\t\t\t\tclassName={panelClasses}\n\t\t\t\t\taria-describedby={descriptionIdRef.current || props['aria-describedby']}\n\t\t\t\t\taria-label={title || props['aria-label']}\n\t\t\t\t\taria-modal=\"false\"\n\t\t\t\t\tdata-qa={qa}\n\t\t\t\t\tid={id}\n\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\tref={panelRef}\n\t\t\t\t>\n\t\t\t\t\t<MrlFocusTrap containerRef={panelRef} disableAutofocus={disableAutofocus}>\n\t\t\t\t\t\t<header className={classnames(styles['MrlPanel--header'], 'MrlPanel--header')}>\n\t\t\t\t\t\t\t{!header && (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\t\tstyles['MrlPanel--header-content'],\n\t\t\t\t\t\t\t\t\t\t'MrlPanel--header-content',\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t[styles['MrlPanel--header-content-description']]: !!description\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<MrlTextHeading\n\t\t\t\t\t\t\t\t\t\tclassName={styles['MrlPanel--title']}\n\t\t\t\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\t\t\t\t'data-qa': `${qa}-header-title`,\n\t\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\thierarchy=\"primary\"\n\t\t\t\t\t\t\t\t\t\tkind=\"title\"\n\t\t\t\t\t\t\t\t\t\tlevel=\"2\"\n\t\t\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\t\t\ttext={title}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{topActions && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles['MrlPanel--top-actions'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t'MrlPanel--top-actions'\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t{topActions}\n\t\t\t\t\t\t\t\t\t\t\t\t<MrlDivider\n\t\t\t\t\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tspacing=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tlength=\"var(--mrl-spacing-06)\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyles['MrlPanel--top-actions-divider'],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'MrlPanel--top-actions-divider'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{header}\n\t\t\t\t\t\t\t<MrlIconButton\n\t\t\t\t\t\t\t\tdata-qa={`${qa}-close-button`}\n\t\t\t\t\t\t\t\twrapperClassName={classnames(styles['MrlPanel--close'], 'MrlPanel--close')}\n\t\t\t\t\t\t\t\ticon={<MrlSvg svg={close} />}\n\t\t\t\t\t\t\t\tonClick={handleClose}\n\t\t\t\t\t\t\t\ttext=\"Close\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\tstate=\"default\"\n\t\t\t\t\t\t\t\tposition=\"bottom\"\n\t\t\t\t\t\t\t\ttipAnchor=\"center\"\n\t\t\t\t\t\t\t\tkind=\"ghost\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</header>\n\n\t\t\t\t\t\t{/*\n\t\t\t\t\t\t * Scrollable container — includes description, sticky header and main\n\t\t\t\t\t\t * content. Per ACT rule 0ssw9k a scrollable element passes WCAG 2.1.1\n\t\t\t\t\t\t * Keyboard if it is itself focusable OR has a focusable descendant. We\n\t\t\t\t\t\t * therefore expose `tabindex=\"0\"` only when the wrapper has no focusable\n\t\t\t\t\t\t * descendants, which avoids the \"meaningless tab stop\" finding for\n\t\t\t\t\t\t * panels filled with interactive controls while still making text-only\n\t\t\t\t\t\t * panels keyboard-scrollable. The labeled `role=\"region\"` is preserved\n\t\t\t\t\t\t * whenever the panel overflows so screen-reader users get a landmark.\n\t\t\t\t\t\t * https://www.w3.org/WAI/standards-guidelines/act/rules/0ssw9k/\n\t\t\t\t\t\t */}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={scrollableContainerRef}\n\t\t\t\t\t\t\tdata-scroll-anchor={hasDataScrollAnchor}\n\t\t\t\t\t\t\tdata-qa={`${qa}-scrollable`}\n\t\t\t\t\t\t\tclassName={classnames(styles['MrlPanel--scrollable'], 'MrlPanel--scrollable', {\n\t\t\t\t\t\t\t\t[styles['MrlPanel--scrollable-has-sticky-header']]: hasStickyHeader\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t{...(verticalScrollbarWidth > 0 && {\n\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\tpaddingRight: `calc(var(--mrl-spacing-06) - ${verticalScrollbarWidth}px)`\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t{...(hasVerticalScrollbar && {\n\t\t\t\t\t\t\t\t'aria-label': title\n\t\t\t\t\t\t\t\t\t? `${title} panel scrollable content`\n\t\t\t\t\t\t\t\t\t: 'Panel scrollable content',\n\t\t\t\t\t\t\t\trole: 'region',\n\t\t\t\t\t\t\t\t...(!hasFocusableDescendant && {\n\t\t\t\t\t\t\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n\t\t\t\t\t\t\t\t\ttabIndex: 0\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{description && (\n\t\t\t\t\t\t\t\t<MrlText\n\t\t\t\t\t\t\t\t\tattrs={{\n\t\t\t\t\t\t\t\t\t\tclassName: classnames(styles['MrlPanel--description'], 'MrlPanel--description'),\n\t\t\t\t\t\t\t\t\t\tid: descriptionIdRef.current\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tsize=\"xsmall\"\n\t\t\t\t\t\t\t\t\ttext={description}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</MrlFocusTrap>\n\t\t\t\t</div>\n\t\t\t</MrlPanelContext.Provider>\n\t\t);\n\t}\n);\n"],"names":["MrlPanel","React","forwardRef","props","ref","className","title","id","children","hasStickyHeader","header","description","disableAutofocus","topActions","hasDataScrollAnchor","onClose","eventId","_props$dataQa","qa","rest","_objectWithoutProperties","_excluded","panelRef","useRef","trackInteraction","useMrlTrackInteraction","useEffect","action","handleClose","useCallback","descriptionIdRef","getUniqueId","_useScrollbarInfo","useScrollbarInfo","scrollableContainerRef","hasVerticalScrollbar","hasHorizontalScrollbar","horizontalScrollbarHeight","verticalScrollbarWidth","hasFocusableDescendant","useHasFocusableDescendant","useImperativeHandle","current","handleKeyDown","e","key","preventDefault","stopPropagation","panelClasses","classnames","styles","createElement","MrlPanelContext","Provider","value","_extends","onKeyDown","role","MrlFocusTrap","containerRef","MrlTextHeading","attrs","concat","hierarchy","kind","level","size","text","Fragment","MrlDivider","orientation","spacing","length","MrlIconButton","wrapperClassName","icon","MrlSvg","svg","close","onClick","state","position","tipAnchor","style","paddingRight","_objectSpread","tabIndex","MrlText"],"mappings":";;;;;;;;;;;;;;;;;;;AAeA;AACA;AACA;;AA6DA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,QAAQ,gBAAGC,KAAK,CAACC,UAAU,CACvC,SAASF,QAAQA,CAACG,KAAK,EAAEC,GAAG,EAAe;AAC1C,EAAA,IACCC,SAAS,GAcNF,KAAK,CAdRE,SAAS;IACTC,KAAK,GAaFH,KAAK,CAbRG,KAAK;IACLC,EAAE,GAYCJ,KAAK,CAZRI,EAAE;IACFC,QAAQ,GAWLL,KAAK,CAXRK,QAAQ;IACRC,eAAe,GAUZN,KAAK,CAVRM,eAAe;IACfC,MAAM,GASHP,KAAK,CATRO,MAAM;IACNC,WAAW,GAQRR,KAAK,CARRQ,WAAW;IACXC,gBAAgB,GAObT,KAAK,CAPRS,gBAAgB;IAChBC,UAAU,GAMPV,KAAK,CANRU,UAAU;IACVC,mBAAmB,GAKhBX,KAAK,CALRW,mBAAmB;IACnBC,OAAO,GAIJZ,KAAK,CAJRY,OAAO;IACPC,OAAO,GAGJb,KAAK,CAHRa,OAAO;IAAAC,aAAA,GAGJd,KAAK,CAFP,SAAS,CAAA;AAAGe,IAAAA,EAAE,GAAAD,aAAA,KAAA,MAAA,GAAG,OAAO,GAAAA,aAAA;AACtBE,IAAAA,IAAI,GAAAC,wBAAA,CACJjB,KAAK,EAAAkB,SAAA,CAAA;AAET,EAAA,IAAMC,QAAQ,GAAGrB,KAAK,CAACsB,MAAM,CAAiB,IAAI,CAAC;AAEnD,EAAA,IAAMC,gBAAgB,GAAGC,sBAAsB,CAAC,UAAU,EAAET,OAAO,CAAC;EAEpEf,KAAK,CAACyB,SAAS,CAAC,MAAM;AACrBF,IAAAA,gBAAgB,CAAC;AAAEG,MAAAA,MAAM,EAAE;AAAO,KAAC,CAAC;A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AExD;AAAY,GAClB,CACD,EACAH,QACG,CACQ,CACV,CACoB,CAAC;AAE7B,CACD;;;;"}
|
|
@@ -12,7 +12,8 @@ var _excluded = ["children", "hasDivider", "className"];
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* MrlPanelFooter component.
|
|
15
|
+
* MrlPanelFooter component. Pins a short note, such as an attribution, to the bottom of an
|
|
16
|
+
* `MrlPanel`; render it as the panel's last child.
|
|
16
17
|
*
|
|
17
18
|
* @param props The MrlPanelFooter component properties.
|
|
18
19
|
* @returns The MrlPanelFooter component.
|