@muraldevkit/ui-toolkit 4.78.2 → 4.79.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/avatar/MrlAvatarButton/MrlAvatarButton.js +2 -1
- package/dist/cjs/components/avatar/MrlAvatarButton/MrlAvatarButton.js.map +1 -1
- package/dist/cjs/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js +4 -2
- package/dist/cjs/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js.map +1 -1
- package/dist/cjs/components/button/MrlButton/MrlButton.js +2 -1
- package/dist/cjs/components/button/MrlButton/MrlButton.js.map +1 -1
- package/dist/cjs/components/button/MrlIconButton/MrlIconButton.js +3 -1
- package/dist/cjs/components/button/MrlIconButton/MrlIconButton.js.map +1 -1
- package/dist/cjs/components/link/MrlLinkButton/MrlLinkButton.js +2 -1
- package/dist/cjs/components/link/MrlLinkButton/MrlLinkButton.js.map +1 -1
- package/dist/cjs/components/pagination/MrlPaginationButton/MrlPaginationButton.js +4 -2
- package/dist/cjs/components/pagination/MrlPaginationButton/MrlPaginationButton.js.map +1 -1
- package/dist/cjs/components/toolbar/MrlToolbarButton/MrlToolbarButton.js.map +1 -1
- package/dist/cjs/components/tooltip/MrlTooltip/MrlTooltip.js +5 -0
- package/dist/cjs/components/tooltip/MrlTooltip/MrlTooltip.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/components/avatar/MrlAvatarButton/MrlAvatarButton.d.ts +2 -1
- package/dist/components/button/MrlButton/MrlButton.d.ts +1 -19
- package/dist/components/button/MrlIconButton/MrlIconButton.d.ts +8 -0
- package/dist/components/link/MrlLinkButton/MrlLinkButton.d.ts +1 -1
- package/dist/components/pagination/MrlPaginationButton/MrlPaginationButton.d.ts +9 -1
- package/dist/components/svg/config.d.ts +1 -1
- package/dist/components/toolbar/MrlToolbarButton/MrlToolbarButton.d.ts +1 -0
- package/dist/components/tooltip/MrlTooltip/MrlTooltip.d.ts +11 -3
- package/dist/components/tooltip/MrlTooltip/index.d.ts +1 -1
- package/dist/esm/components/avatar/MrlAvatarButton/MrlAvatarButton.js +2 -1
- package/dist/esm/components/avatar/MrlAvatarButton/MrlAvatarButton.js.map +1 -1
- package/dist/esm/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js +4 -2
- package/dist/esm/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js.map +1 -1
- package/dist/esm/components/button/MrlButton/MrlButton.js +2 -1
- package/dist/esm/components/button/MrlButton/MrlButton.js.map +1 -1
- package/dist/esm/components/button/MrlIconButton/MrlIconButton.js +3 -1
- package/dist/esm/components/button/MrlIconButton/MrlIconButton.js.map +1 -1
- package/dist/esm/components/link/MrlLinkButton/MrlLinkButton.js +2 -1
- package/dist/esm/components/link/MrlLinkButton/MrlLinkButton.js.map +1 -1
- package/dist/esm/components/pagination/MrlPaginationButton/MrlPaginationButton.js +4 -2
- package/dist/esm/components/pagination/MrlPaginationButton/MrlPaginationButton.js.map +1 -1
- package/dist/esm/components/toolbar/MrlToolbarButton/MrlToolbarButton.js.map +1 -1
- package/dist/esm/components/tooltip/MrlTooltip/MrlTooltip.js +5 -0
- package/dist/esm/components/tooltip/MrlTooltip/MrlTooltip.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/components/avatar/MrlAvatarButton/MrlAvatarButton.d.ts +2 -1
- package/dist/types/components/button/MrlButton/MrlButton.d.ts +1 -19
- package/dist/types/components/button/MrlIconButton/MrlIconButton.d.ts +8 -0
- package/dist/types/components/link/MrlLinkButton/MrlLinkButton.d.ts +1 -1
- package/dist/types/components/pagination/MrlPaginationButton/MrlPaginationButton.d.ts +9 -1
- package/dist/types/components/toolbar/MrlToolbarButton/MrlToolbarButton.d.ts +1 -0
- package/dist/types/components/tooltip/MrlTooltip/MrlTooltip.d.ts +11 -3
- package/dist/types/components/tooltip/MrlTooltip/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlTooltip.js","sources":["../../../../../src/components/tooltip/MrlTooltip/MrlTooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { AttrsObject, getUniqueId } from '../../../utils';\nimport {\n\tMrlTooltipAnchor,\n\tMrlTooltipDefaults,\n\tMrlTooltipPosition,\n\tMrlTooltipState\n} from '../constants';\nimport { MrlTooltipContent } from '../MrlTooltipContent/MrlTooltipContent';\nimport { curryHandlers } from '../utils';\nimport classNames from 'classnames';\nimport { MrlPortal } from '../../portal';\nimport '../../../styles/shared/a11y-helpers/a11y.global.scss';\nimport { useTooltipPosition } from '../useTooltipPosition';\nimport { useTransition, animated } from '@react-spring/web';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\ninterface MrlTooltipProps {\n\t/** The arrow position of the tooltip in relation to its trigger's content */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * Attributes that are applied to the component during the initial render.\n\t *\n\t * Example usage: html attributes, custom data attributes (data-qa), aria\n\t * @deprecated please use props for component instead\n\t */\n\tattrs?: AttrsObject;\n\n\t/**\n\t * Children to be rendered within the tooltip. The first child is used as the trigger.\n\t *\n\t * Warning: The tooltip is only setup to work with a single trigger. If multiple children\n\t * are passed in the component will not have event handling for the additional child elements.\n\t */\n\tchildren: React.ReactElement;\n\n\t/** Whether the tooltip should close when clicked */\n\tclickToClose?: boolean;\n\n\t/** The data-qa attribute for the tooltip */\n\tdataQa?: string;\n\n\t/** The state value to determine if the tooltip should be displayed */\n\tdisplay?: MrlTooltipState;\n\n\t/** Whether to disable the tooltip hover action that keeps it open */\n\tdisableTooltipHover?: boolean;\n\n\t/** The placement of the tooltip in relation to its trigger */\n\tposition?: MrlTooltipPosition;\n\n\t/** Whether to announce the tooltip content to screen readers */\n\tsrAnnouncement?: boolean;\n\n\t/** The textual label of tooltip */\n\ttext: string;\n\n\t/** A custom class selector to be applied to the tooltip wrapper */\n\ttooltipClass?: string;\n\n\t/** A class to be applied ot the tooltip content */\n\ttooltipContentClass?: string;\n\n\t/** A custom render function to render the tooltip content */\n\tcustomRender?: (text?: string) => React.ReactNode;\n\n\t/**\n\t * Enables interaction tracking for this tooltip. Provide a stable, non-PII id\n\t * (e.g. 'facilitation-timer-tooltip'). When omitted, the tooltip emits no analytics.\n\t *\n\t * Note: tooltips open on hover, so an instrumented tooltip is a high-volume source.\n\t * Only add an id where the reveal itself is the signal you need.\n\t */\n\teventId?: string;\n}\n\n/**\n * MrlTooltip Component\n *\n * This component is not displayed when rendering this component if the primary pointing device can’t hover. Examples include touchscreens and screens that use a basic drawing stylus.\n * Pointing devices that can hover, but for which doing so is inconvenient and not part of the normal way they are used, also match this criteria. For example, a touchscreen where a long press is treated as hovering.\n * @param {MrlTooltipProps} props - The props of the component\n * @returns {HTMLElement} a configured Tooltip component\n */\nexport const MrlTooltip = React.memo((props: MrlTooltipProps): React.ReactElement => {\n\tconst {\n\t\tchildren,\n\t\tclickToClose = true,\n\t\tdisableTooltipHover = false,\n\t\tdisplay: defaultDisplay = 'hide',\n\t\ttext,\n\t\tattrs = {},\n\t\tdataQa,\n\t\tposition = MrlTooltipDefaults.position || 'top',\n\t\tanchor = MrlTooltipDefaults.anchor,\n\t\tsrAnnouncement = true,\n\t\ttooltipClass,\n\t\ttooltipContentClass,\n\t\teventId,\n\t\t...rest\n\t} = props;\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlTooltip', eventId);\n\n\tconst [interaction, setInteraction] = React.useState('mouse');\n\n\tconst triggerRef = React.useRef<HTMLElement | null>(null);\n\n\tconst tooltipRef = React.useRef<HTMLDivElement>(null);\n\n\t/**\n\t * State value to determine if the tooltip should be displayed\n\t */\n\tconst [display, setDisplay] = React.useState<MrlTooltipState>(defaultDisplay);\n\n\t/**\n\t * State value to determine if the tooltip should be displayed\n\t */\n\tconst [id, setId] = React.useState<string>('');\n\n\t/**\n\t * The tooltip shows and hides from hover, focus and click, so open/close is emitted\n\t * from the resulting display state rather than from each individual handler.\n\t */\n\tconst previousDisplayRef = React.useRef<MrlTooltipState>(defaultDisplay);\n\n\tReact.useEffect(() => {\n\t\tif (previousDisplayRef.current === display) return;\n\n\t\tpreviousDisplayRef.current = display;\n\n\t\ttrackInteraction({\n\t\t\taction: display === 'show' ? 'open' : 'close',\n\t\t\tmetadata: { interaction },\n\t\t\tvariant: position\n\t\t});\n\t\t// `interaction` only annotates the event; it must not re-trigger it\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [display, position, trackInteraction]);\n\n\t/**\n\t * Event handler to show tooltip when the trigger is focused\n\t */\n\tconst handleShowTooltip = React.useCallback(() => {\n\t\tsetDisplay('show');\n\t}, []);\n\n\tconst handleFocus = React.useCallback(() => {\n\t\tif (interaction === 'keyboard') {\n\t\t\thandleShowTooltip();\n\t\t}\n\t}, [interaction, handleShowTooltip]);\n\n\t/**\n\t * Event handler to hide the tooltip on mouseout\n\t */\n\tconst handleHideTooltip = (): void => {\n\t\tsetDisplay('hide');\n\t};\n\n\t/**\n\t * Event handler to hide the tooltip when a user presses escape\n\t * @param {React.KeyboardEvent} e Keyboard event\n\t */\n\tconst handleKeyDown = (e: React.KeyboardEvent): void => {\n\t\tif (e.key === 'Escape' || e.key === 'Enter' || e.key === ' ') {\n\t\t\thandleHideTooltip();\n\t\t}\n\t};\n\n\tconst handleSetKeyboardInteraction = (e: KeyboardEvent) => {\n\t\tif (e.key === 'Tab' || e.key === 'Enter' || e.key === ' ') {\n\t\t\tsetInteraction('keyboard');\n\t\t}\n\t};\n\n\tconst handlesetMouseInteraction = () => setInteraction('mouse');\n\n\t/**\n\t * Setup of the initial component attributes and events\n\t */\n\tReact.useEffect(() => {\n\t\tif (id === '') setId(getUniqueId('mrl-tooltip'));\n\t}, [id]);\n\n\tReact.useEffect(() => {\n\t\tsetDisplay(defaultDisplay);\n\t}, [defaultDisplay]);\n\n\t/**\n\t * Setting the triggerRef to the trigger element\n\t *\n\t * We need to use 'querySelector' because we cannot pass a ref to the child object. There are\n\t * some situations where the child component may not accept a ref, for example: a react router\n\t * link is passed as a child. In older versions of react router you could not pass a ref to the\n\t * component so this causes an issue.\n\t */\n\tReact.useEffect(() => {\n\t\tconst trigger = document.querySelector(`[data-tooltip-id=\"${id}\"]`);\n\t\ttriggerRef.current = trigger as HTMLElement;\n\t}, [id]);\n\n\tReact.useEffect(() => {\n\t\tconst currentTooltipRef = tooltipRef.current;\n\n\t\tdocument.addEventListener('keydown', handleSetKeyboardInteraction);\n\t\tdocument.addEventListener('mousedown', handlesetMouseInteraction);\n\n\t\tif (!disableTooltipHover && currentTooltipRef) {\n\t\t\tcurrentTooltipRef.addEventListener('mouseover', handleShowTooltip);\n\t\t\tcurrentTooltipRef.addEventListener('mouseout', handleHideTooltip);\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (!disableTooltipHover && currentTooltipRef) {\n\t\t\t\tcurrentTooltipRef.removeEventListener('mouseover', handleShowTooltip);\n\t\t\t\tcurrentTooltipRef.removeEventListener('mouseout', handleHideTooltip);\n\t\t\t}\n\n\t\t\tdocument.removeEventListener('keydown', handleSetKeyboardInteraction);\n\t\t\tdocument.removeEventListener('mousedown', handlesetMouseInteraction);\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [handleShowTooltip, tooltipRef.current]);\n\n\tconst positionStyles = useTooltipPosition(\n\t\ttriggerRef,\n\t\ttooltipRef,\n\t\t{\n\t\t\talign: anchor,\n\t\t\tposition: position\n\t\t},\n\t\tdisplay === 'show',\n\t\t-1\n\t);\n\n\tconst inlineStyles = {\n\t\tmenu: {\n\t\t\tleft: positionStyles.left,\n\t\t\tposition: 'fixed' as const,\n\t\t\ttop: positionStyles.top\n\t\t}\n\t};\n\n\tconst transitions = useTransition(display === 'show', {\n\t\tconfig: { duration: display === 'show' ? 150 : 25 },\n\t\tenter: { opacity: 1 },\n\t\tfrom: { opacity: 0 },\n\t\tleave: { opacity: 0 }\n\t});\n\n\treturn (\n\t\t<>\n\t\t\t{React.Children.map(children, (child, index) => {\n\t\t\t\tif (index === 0 && React.isValidElement(child)) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\tonBlur,\n\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\tonKeyDown,\n\t\t\t\t\t\tonMouseOver,\n\t\t\t\t\t\tonMouseOut,\n\t\t\t\t\t\tonMouseUp,\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t...otherProps\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t} = (child as any).props;\n\n\t\t\t\t\treturn React.cloneElement(child as React.ReactElement, {\n\t\t\t\t\t\t'aria-describedby': display === 'show' && srAnnouncement ? id : undefined,\n\t\t\t\t\t\tclassName: classNames(\n\t\t\t\t\t\t\ttooltipClass,\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t'mrl-tooltip-trigger',\n\t\t\t\t\t\t\tdisplay === 'show' && 'mrl-tooltip-trigger--active'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tonBlur: curryHandlers(onBlur, handleHideTooltip),\n\t\t\t\t\t\t...(clickToClose && !disableTooltipHover\n\t\t\t\t\t\t\t? { onMouseUp: curryHandlers(onMouseUp, handleHideTooltip) }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\tonFocus: curryHandlers(onFocus, handleFocus),\n\t\t\t\t\t\tonKeyDown: curryHandlers(onKeyDown, handleKeyDown),\n\t\t\t\t\t\tonMouseOut: curryHandlers(onMouseOut, handleHideTooltip),\n\t\t\t\t\t\tonMouseOver: curryHandlers(onMouseOver, handleShowTooltip),\n\t\t\t\t\t\t...otherProps,\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t['data-tooltip-id']: id\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn child;\n\t\t\t})}\n\t\t\t<MrlPortal\n\t\t\t\tid={PORTAL_LAYERS.TOOLTIP.name}\n\t\t\t\tlayer={PORTAL_LAYERS.TOOLTIP}\n\t\t\t\tclassName={PORTAL_LAYERS.TOOLTIP.name}\n\t\t\t\tdata-qa={PORTAL_LAYERS.TOOLTIP.name}\n\t\t\t>\n\t\t\t\t{transitions(\n\t\t\t\t\t(style, item) =>\n\t\t\t\t\t\titem && (\n\t\t\t\t\t\t\t<animated.div ref={tooltipRef} style={{ ...inlineStyles.menu, ...style }}>\n\t\t\t\t\t\t\t\t<MrlTooltipContent\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t\tattrs={attrs}\n\t\t\t\t\t\t\t\t\tanchor={anchor}\n\t\t\t\t\t\t\t\t\tdataQa={dataQa}\n\t\t\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\t\t\tposition={position}\n\t\t\t\t\t\t\t\t\ttext={text}\n\t\t\t\t\t\t\t\t\ttooltipContentClass={tooltipContentClass}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</animated.div>\n\t\t\t\t\t\t)\n\t\t\t\t)}\n\t\t\t</MrlPortal>\n\t\t</>\n\t);\n});\n\nMrlTooltip.displayName = 'MrlTooltip';\n"],"names":["MrlTooltip","React","memo","props","children","_props$clickToClose","clickToClose","_props$disableTooltip","disableTooltipHover","_props$display","display","defaultDisplay","text","_props$attrs","attrs","dataQa","_props$position","position","MrlTooltipDefaults","_props$anchor","anchor","_props$srAnnouncement","srAnnouncement","tooltipClass","tooltipContentClass","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","_React$useState","useState","_React$useState2","_slicedToArray","interaction","setInteraction","triggerRef","useRef","tooltipRef","_React$useState3","_React$useState4","setDisplay","_React$useState5","_React$useState6","id","setId","previousDisplayRef","useEffect","current","action","metadata","variant","handleShowTooltip","useCallback","handleFocus","handleHideTooltip","handleKeyDown","e","key","handleSetKeyboardInteraction","handlesetMouseInteraction","getUniqueId","trigger","document","querySelector","concat","currentTooltipRef","addEventListener","removeEventListener","positionStyles","useTooltipPosition","align","inlineStyles","menu","left","top","transitions","useTransition","config","duration","enter","opacity","from","leave","createElement","Fragment","Children","map","child","index","isValidElement","_props","className","onBlur","onFocus","onKeyDown","onMouseOver","onMouseOut","onMouseUp","otherProps","_excluded2","cloneElement","_objectSpread","undefined","classNames","curryHandlers","MrlPortal","PORTAL_LAYERS","TOOLTIP","name","layer","style","item","animated","div","ref","MrlTooltipContent","_extends","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,UAAU,gBAAGC,gBAAK,CAACC,IAAI,CAAEC,KAAsB,IAAyB;AACpF,EAAA,IACCC,QAAQ,GAcLD,KAAK,CAdRC,QAAQ;IAAAC,mBAAA,GAcLF,KAAK,CAbRG,YAAY;AAAZA,IAAAA,YAAY,GAAAD,mBAAA,KAAA,MAAA,GAAG,IAAI,GAAAA,mBAAA;IAAAE,qBAAA,GAahBJ,KAAK,CAZRK,mBAAmB;AAAnBA,IAAAA,mBAAmB,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;IAAAE,cAAA,GAYxBN,KAAK,CAXRO,OAAO;AAAEC,IAAAA,cAAc,GAAAF,cAAA,KAAA,MAAA,GAAG,MAAM,GAAAA,cAAA;IAChCG,IAAI,GAUDT,KAAK,CAVRS,IAAI;IAAAC,YAAA,GAUDV,KAAK,CATRW,KAAK;AAALA,IAAAA,KAAK,GAAAD,YAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,YAAA;IACVE,MAAM,GAQHZ,KAAK,CARRY,MAAM;IAAAC,eAAA,GAQHb,KAAK,CAPRc,QAAQ;IAARA,QAAQ,GAAAD,eAAA,KAAA,MAAA,GAAGE,4BAAkB,CAACD,QAAQ,IAAI,KAAK,GAAAD,eAAA;IAAAG,aAAA,GAO5ChB,KAAK,CANRiB,M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iB,EAAAC,iCAAA,KACb5F,IAAI,EAAA;AACRZ,IAAAA,KAAK,EAAEA,KAAM;AACbM,IAAAA,MAAM,EAAEA,MAAO;AACfL,IAAAA,MAAM,EAAEA,MAAO;AACf8B,IAAAA,EAAE,EAAEA,EAAG;AACP5B,IAAAA,QAAQ,EAAEA,QAAS;AACnBL,IAAAA,IAAI,EAAEA,IAAK;AACXY,IAAAA,mBAAmB,EAAEA;AAAoB,GAAA,CACzC,CACY,CAEjB,CACU,CACV,CAAC;AAEL,CAAC;AAEDxB,UAAU,CAACuH,WAAW,GAAG,YAAY;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlTooltip.js","sources":["../../../../../src/components/tooltip/MrlTooltip/MrlTooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { AttrsObject, getUniqueId } from '../../../utils';\nimport {\n\tMrlTooltipAnchor,\n\tMrlTooltipDefaults,\n\tMrlTooltipPosition,\n\tMrlTooltipState\n} from '../constants';\nimport { MrlTooltipContent } from '../MrlTooltipContent/MrlTooltipContent';\nimport { curryHandlers } from '../utils';\nimport classNames from 'classnames';\nimport { MrlPortal } from '../../portal';\nimport '../../../styles/shared/a11y-helpers/a11y.global.scss';\nimport { useTooltipPosition } from '../useTooltipPosition';\nimport { useTransition, animated } from '@react-spring/web';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport interface MrlTooltipProps {\n\t/** The arrow position of the tooltip in relation to its trigger's content */\n\tanchor?: MrlTooltipAnchor;\n\n\t/**\n\t * Attributes that are applied to the component during the initial render.\n\t *\n\t * Example usage: html attributes, custom data attributes (data-qa), aria\n\t * @deprecated please use props for component instead\n\t */\n\tattrs?: AttrsObject;\n\n\t/**\n\t * Children to be rendered within the tooltip. The first child is used as the trigger.\n\t *\n\t * Warning: The tooltip is only setup to work with a single trigger. If multiple children\n\t * are passed in the component will not have event handling for the additional child elements.\n\t */\n\tchildren: React.ReactElement;\n\n\t/** Whether the tooltip should close when clicked */\n\tclickToClose?: boolean;\n\n\t/** The data-qa attribute for the tooltip */\n\tdataQa?: string;\n\n\t/** The state value to determine if the tooltip should be displayed */\n\tdisplay?: MrlTooltipState;\n\n\t/** Whether to disable the tooltip hover action that keeps it open */\n\tdisableTooltipHover?: boolean;\n\n\t/** The placement of the tooltip in relation to its trigger */\n\tposition?: MrlTooltipPosition;\n\n\t/** Whether to announce the tooltip content to screen readers */\n\tsrAnnouncement?: boolean;\n\n\t/** The textual label of tooltip */\n\ttext: string;\n\n\t/** A custom class selector to be applied to the tooltip wrapper */\n\ttooltipClass?: string;\n\n\t/** A class to be applied ot the tooltip content */\n\ttooltipContentClass?: string;\n\n\t/**\n\t * Renders custom tooltip content instead of the plain `text`. Receives `text` as\n\t * its argument. `text` is still required and used for accessibility.\n\t *\n\t * Note: `MrlTooltip` is memoized, so this function should be memoized by consumers.\n\t */\n\tcustomRender?: (text?: string) => React.ReactNode;\n\n\t/**\n\t * Enables interaction tracking for this tooltip. Provide a stable, non-PII id\n\t * (e.g. 'facilitation-timer-tooltip'). When omitted, the tooltip emits no analytics.\n\t *\n\t * Note: tooltips open on hover, so an instrumented tooltip is a high-volume source.\n\t * Only add an id where the reveal itself is the signal you need.\n\t */\n\teventId?: string;\n}\n\n/**\n * Tooltip configuration for components that wrap `MrlTooltip` (e.g. `MrlButton`).\n */\nexport type TooltipConfig = Pick<\n\tMrlTooltipProps,\n\t'anchor' | 'customRender' | 'dataQa' | 'position' | 'text'\n>;\n\n/**\n * MrlTooltip Component\n *\n * This component is not displayed when rendering this component if the primary pointing device can’t hover. Examples include touchscreens and screens that use a basic drawing stylus.\n * Pointing devices that can hover, but for which doing so is inconvenient and not part of the normal way they are used, also match this criteria. For example, a touchscreen where a long press is treated as hovering.\n * @param {MrlTooltipProps} props - The props of the component\n * @returns {HTMLElement} a configured Tooltip component\n */\nexport const MrlTooltip = React.memo((props: MrlTooltipProps): React.ReactElement => {\n\tconst {\n\t\tchildren,\n\t\tclickToClose = true,\n\t\tdisableTooltipHover = false,\n\t\tdisplay: defaultDisplay = 'hide',\n\t\ttext,\n\t\tattrs = {},\n\t\tdataQa,\n\t\tposition = MrlTooltipDefaults.position || 'top',\n\t\tanchor = MrlTooltipDefaults.anchor,\n\t\tsrAnnouncement = true,\n\t\ttooltipClass,\n\t\ttooltipContentClass,\n\t\teventId,\n\t\t...rest\n\t} = props;\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlTooltip', eventId);\n\n\tconst [interaction, setInteraction] = React.useState('mouse');\n\n\tconst triggerRef = React.useRef<HTMLElement | null>(null);\n\n\tconst tooltipRef = React.useRef<HTMLDivElement>(null);\n\n\t/**\n\t * State value to determine if the tooltip should be displayed\n\t */\n\tconst [display, setDisplay] = React.useState<MrlTooltipState>(defaultDisplay);\n\n\t/**\n\t * State value to determine if the tooltip should be displayed\n\t */\n\tconst [id, setId] = React.useState<string>('');\n\n\t/**\n\t * The tooltip shows and hides from hover, focus and click, so open/close is emitted\n\t * from the resulting display state rather than from each individual handler.\n\t */\n\tconst previousDisplayRef = React.useRef<MrlTooltipState>(defaultDisplay);\n\n\tReact.useEffect(() => {\n\t\tif (previousDisplayRef.current === display) return;\n\n\t\tpreviousDisplayRef.current = display;\n\n\t\ttrackInteraction({\n\t\t\taction: display === 'show' ? 'open' : 'close',\n\t\t\tmetadata: { interaction },\n\t\t\tvariant: position\n\t\t});\n\t\t// `interaction` only annotates the event; it must not re-trigger it\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [display, position, trackInteraction]);\n\n\t/**\n\t * Event handler to show tooltip when the trigger is focused\n\t */\n\tconst handleShowTooltip = React.useCallback(() => {\n\t\tsetDisplay('show');\n\t}, []);\n\n\tconst handleFocus = React.useCallback(() => {\n\t\tif (interaction === 'keyboard') {\n\t\t\thandleShowTooltip();\n\t\t}\n\t}, [interaction, handleShowTooltip]);\n\n\t/**\n\t * Event handler to hide the tooltip on mouseout\n\t */\n\tconst handleHideTooltip = (): void => {\n\t\tsetDisplay('hide');\n\t};\n\n\t/**\n\t * Event handler to hide the tooltip when a user presses escape\n\t * @param {React.KeyboardEvent} e Keyboard event\n\t */\n\tconst handleKeyDown = (e: React.KeyboardEvent): void => {\n\t\tif (e.key === 'Escape' || e.key === 'Enter' || e.key === ' ') {\n\t\t\thandleHideTooltip();\n\t\t}\n\t};\n\n\tconst handleSetKeyboardInteraction = (e: KeyboardEvent) => {\n\t\tif (e.key === 'Tab' || e.key === 'Enter' || e.key === ' ') {\n\t\t\tsetInteraction('keyboard');\n\t\t}\n\t};\n\n\tconst handlesetMouseInteraction = () => setInteraction('mouse');\n\n\t/**\n\t * Setup of the initial component attributes and events\n\t */\n\tReact.useEffect(() => {\n\t\tif (id === '') setId(getUniqueId('mrl-tooltip'));\n\t}, [id]);\n\n\tReact.useEffect(() => {\n\t\tsetDisplay(defaultDisplay);\n\t}, [defaultDisplay]);\n\n\t/**\n\t * Setting the triggerRef to the trigger element\n\t *\n\t * We need to use 'querySelector' because we cannot pass a ref to the child object. There are\n\t * some situations where the child component may not accept a ref, for example: a react router\n\t * link is passed as a child. In older versions of react router you could not pass a ref to the\n\t * component so this causes an issue.\n\t */\n\tReact.useEffect(() => {\n\t\tconst trigger = document.querySelector(`[data-tooltip-id=\"${id}\"]`);\n\t\ttriggerRef.current = trigger as HTMLElement;\n\t}, [id]);\n\n\tReact.useEffect(() => {\n\t\tconst currentTooltipRef = tooltipRef.current;\n\n\t\tdocument.addEventListener('keydown', handleSetKeyboardInteraction);\n\t\tdocument.addEventListener('mousedown', handlesetMouseInteraction);\n\n\t\tif (!disableTooltipHover && currentTooltipRef) {\n\t\t\tcurrentTooltipRef.addEventListener('mouseover', handleShowTooltip);\n\t\t\tcurrentTooltipRef.addEventListener('mouseout', handleHideTooltip);\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (!disableTooltipHover && currentTooltipRef) {\n\t\t\t\tcurrentTooltipRef.removeEventListener('mouseover', handleShowTooltip);\n\t\t\t\tcurrentTooltipRef.removeEventListener('mouseout', handleHideTooltip);\n\t\t\t}\n\n\t\t\tdocument.removeEventListener('keydown', handleSetKeyboardInteraction);\n\t\t\tdocument.removeEventListener('mousedown', handlesetMouseInteraction);\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [handleShowTooltip, tooltipRef.current]);\n\n\tconst positionStyles = useTooltipPosition(\n\t\ttriggerRef,\n\t\ttooltipRef,\n\t\t{\n\t\t\talign: anchor,\n\t\t\tposition: position\n\t\t},\n\t\tdisplay === 'show',\n\t\t-1\n\t);\n\n\tconst inlineStyles = {\n\t\tmenu: {\n\t\t\tleft: positionStyles.left,\n\t\t\tposition: 'fixed' as const,\n\t\t\ttop: positionStyles.top\n\t\t}\n\t};\n\n\tconst transitions = useTransition(display === 'show', {\n\t\tconfig: { duration: display === 'show' ? 150 : 25 },\n\t\tenter: { opacity: 1 },\n\t\tfrom: { opacity: 0 },\n\t\tleave: { opacity: 0 }\n\t});\n\n\treturn (\n\t\t<>\n\t\t\t{React.Children.map(children, (child, index) => {\n\t\t\t\tif (index === 0 && React.isValidElement(child)) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\tonBlur,\n\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\tonKeyDown,\n\t\t\t\t\t\tonMouseOver,\n\t\t\t\t\t\tonMouseOut,\n\t\t\t\t\t\tonMouseUp,\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t...otherProps\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t} = (child as any).props;\n\n\t\t\t\t\treturn React.cloneElement(child as React.ReactElement, {\n\t\t\t\t\t\t'aria-describedby': display === 'show' && srAnnouncement ? id : undefined,\n\t\t\t\t\t\tclassName: classNames(\n\t\t\t\t\t\t\ttooltipClass,\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t'mrl-tooltip-trigger',\n\t\t\t\t\t\t\tdisplay === 'show' && 'mrl-tooltip-trigger--active'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tonBlur: curryHandlers(onBlur, handleHideTooltip),\n\t\t\t\t\t\t...(clickToClose && !disableTooltipHover\n\t\t\t\t\t\t\t? { onMouseUp: curryHandlers(onMouseUp, handleHideTooltip) }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\tonFocus: curryHandlers(onFocus, handleFocus),\n\t\t\t\t\t\tonKeyDown: curryHandlers(onKeyDown, handleKeyDown),\n\t\t\t\t\t\tonMouseOut: curryHandlers(onMouseOut, handleHideTooltip),\n\t\t\t\t\t\tonMouseOver: curryHandlers(onMouseOver, handleShowTooltip),\n\t\t\t\t\t\t...otherProps,\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t['data-tooltip-id']: id\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn child;\n\t\t\t})}\n\t\t\t<MrlPortal\n\t\t\t\tid={PORTAL_LAYERS.TOOLTIP.name}\n\t\t\t\tlayer={PORTAL_LAYERS.TOOLTIP}\n\t\t\t\tclassName={PORTAL_LAYERS.TOOLTIP.name}\n\t\t\t\tdata-qa={PORTAL_LAYERS.TOOLTIP.name}\n\t\t\t>\n\t\t\t\t{transitions(\n\t\t\t\t\t(style, item) =>\n\t\t\t\t\t\titem && (\n\t\t\t\t\t\t\t<animated.div ref={tooltipRef} style={{ ...inlineStyles.menu, ...style }}>\n\t\t\t\t\t\t\t\t<MrlTooltipContent\n\t\t\t\t\t\t\t\t\t{...rest}\n\t\t\t\t\t\t\t\t\tattrs={attrs}\n\t\t\t\t\t\t\t\t\tanchor={anchor}\n\t\t\t\t\t\t\t\t\tdataQa={dataQa}\n\t\t\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\t\t\tposition={position}\n\t\t\t\t\t\t\t\t\ttext={text}\n\t\t\t\t\t\t\t\t\ttooltipContentClass={tooltipContentClass}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</animated.div>\n\t\t\t\t\t\t)\n\t\t\t\t)}\n\t\t\t</MrlPortal>\n\t\t</>\n\t);\n});\n\nMrlTooltip.displayName = 'MrlTooltip';\n"],"names":["MrlTooltip","React","memo","props","children","_props$clickToClose","clickToClose","_props$disableTooltip","disableTooltipHover","_props$display","display","defaultDisplay","text","_props$attrs","attrs","dataQa","_props$position","position","MrlTooltipDefaults","_props$anchor","anchor","_props$srAnnouncement","srAnnouncement","tooltipClass","tooltipContentClass","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","_React$useState","useState","_React$useState2","_slicedToArray","interaction","setInteraction","triggerRef","useRef","tooltipRef","_React$useState3","_React$useState4","setDisplay","_React$useState5","_React$useState6","id","setId","previousDisplayRef","useEffect","current","action","metadata","variant","handleShowTooltip","useCallback","handleFocus","handleHideTooltip","handleKeyDown","e","key","handleSetKeyboardInteraction","handlesetMouseInteraction","getUniqueId","trigger","document","querySelector","concat","currentTooltipRef","addEventListener","removeEventListener","positionStyles","useTooltipPosition","align","inlineStyles","menu","left","top","transitions","useTransition","config","duration","enter","opacity","from","leave","createElement","Fragment","Children","map","child","index","isValidElement","_props","className","onBlur","onFocus","onKeyDown","onMouseOver","onMouseOut","onMouseUp","otherProps","_excluded2","cloneElement","_objectSpread","undefined","classNames","curryHandlers","MrlPortal","PORTAL_LAYERS","TOOLTIP","name","layer","style","item","animated","div","ref","MrlTooltipContent","_extends","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,UAAU,gBAAGC,gBAAK,CAACC,IAAI,CAAEC,KAAsB,IAAyB;AACpF,EAAA,IACCC,QAAQ,GAcLD,KAAK,CAdRC,QAAQ;IAAAC,mBAAA,GAcLF,KAAK,CAbRG,YAAY;AAAZA,IAAAA,YAAY,GAAAD,mBAAA,KAAA,MAAA,GAAG,IAAI,GAAAA,mBAAA;I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AAK;AACb,EAAA,CAAC,CAAC,eACFxF,gBAAA,CAAAoF,aAAA,CAACsB,mBAAS,EAAA;AACT9D,IAAAA,EAAE,EAAE+D,qBAAa,CAACC,OAAO,CAACC,IAAK;IAC/BC,KAAK,EAAEH,qBAAa,CAACC,OAAQ;AAC7BhB,IAAAA,SAAS,EAAEe,qBAAa,CAACC,OAAO,CAACC,IAAK;IACtC,SAAA,EAASF,qBAAa,CAACC,OAAO,CAACC;AAAK,GAAA,EAEnCjC,WAAW,CACX,CAACmC,KAAK,EAAEC,IAAI,KACXA,IAAI,iBACHhH,gBAAA,CAAAoF,aAAA,CAAC6B,YAAQ,CAACC,GAAG,EAAA;AAACC,IAAAA,GAAG,EAAE7E,UAAW;IAACyE,KAAK,EAAAT,uCAAA,CAAAA,uCAAA,KAAO9B,YAAY,CAACC,IAAI,CAAA,EAAKsC,KAAK;GAAG,eACxE/G,gBAAA,CAAAoF,aAAA,CAACgC,mCAAiB,EAAAC,iCAAA,KACb5F,IAAI,EAAA;AACRZ,IAAAA,KAAK,EAAEA,KAAM;AACbM,IAAAA,MAAM,EAAEA,MAAO;AACfL,IAAAA,MAAM,EAAEA,MAAO;AACf8B,IAAAA,EAAE,EAAEA,EAAG;AACP5B,IAAAA,QAAQ,EAAEA,QAAS;AACnBL,IAAAA,IAAI,EAAEA,IAAK;AACXY,IAAAA,mBAAmB,EAAEA;AAAoB,GAAA,CACzC,CACY,CAEjB,CACU,CACV,CAAC;AAEL,CAAC;AAEDxB,UAAU,CAACuH,WAAW,GAAG,YAAY;;;;"}
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.79.0\";"],"names":["TOOLKIT_VERSION"],"mappings":";;AAAO,IAAMA,eAAe,GAAG;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { MrlButtonState
|
|
2
|
+
import type { MrlButtonState } from '../../button/MrlButton/MrlButton';
|
|
3
|
+
import { type TooltipConfig } from '../../tooltip/MrlTooltip/MrlTooltip';
|
|
3
4
|
import { MrlAvatarPropTypes } from '../MrlAvatar/MrlAvatar';
|
|
4
5
|
import { ToggleAria } from '../../button/constants';
|
|
5
6
|
export interface MrlAvatarButtonPropTypes extends MrlAvatarPropTypes, React.HTMLAttributes<HTMLButtonElement> {
|
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { allowedButtonValues, MrlButtonKind, MrlButtonSize, ToggleAria, IconPosition } from '../constants';
|
|
3
|
-
import {
|
|
3
|
+
import { type TooltipConfig } from '../../tooltip/MrlTooltip/MrlTooltip';
|
|
4
4
|
import { AttrsObject, MrlComponentProps } from '../../../utils';
|
|
5
5
|
import './MrlButton.global.scss';
|
|
6
6
|
export type MrlButtonState = (typeof allowedButtonValues.states)[number];
|
|
7
7
|
export type ToggleStyle = (typeof allowedButtonValues.toggleStyles)[number];
|
|
8
|
-
export interface TooltipConfig {
|
|
9
|
-
/**
|
|
10
|
-
* The text to display in the tooltip
|
|
11
|
-
*/
|
|
12
|
-
text: string;
|
|
13
|
-
/**
|
|
14
|
-
* The position of the tooltip relative to the button
|
|
15
|
-
*/
|
|
16
|
-
position?: MrlTooltipPosition;
|
|
17
|
-
/**
|
|
18
|
-
* The anchor of the tooltip relative to the button
|
|
19
|
-
*/
|
|
20
|
-
anchor?: MrlTooltipAnchor;
|
|
21
|
-
/**
|
|
22
|
-
* The data-qa attribute for the tooltip
|
|
23
|
-
*/
|
|
24
|
-
dataQa?: string;
|
|
25
|
-
}
|
|
26
8
|
export interface MrlButtonProps extends Omit<MrlComponentProps, 'style'>, React.ComponentProps<'button'> {
|
|
27
9
|
/**
|
|
28
10
|
* Applies additional HTML attributes to the button element.
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { MrlButtonKind, MrlButtonSize, MrlGhostIconButtonSize, ToggleAria } from '../constants';
|
|
3
3
|
import { AttrsObject, MrlComponentProps } from '../../../utils';
|
|
4
4
|
import { MrlTooltipAnchor, MrlTooltipPosition } from '../../tooltip/constants';
|
|
5
|
+
import { type MrlTooltipProps } from '../../tooltip/MrlTooltip/MrlTooltip';
|
|
5
6
|
import type { MrlButtonState, ToggleStyle } from '../MrlButton/MrlButton';
|
|
6
7
|
import './MrlIconButton.scss';
|
|
7
8
|
export interface MrlIconButtonProps extends Omit<MrlComponentProps, 'style'>, React.ComponentProps<'button'> {
|
|
@@ -80,6 +81,13 @@ export interface MrlIconButtonProps extends Omit<MrlComponentProps, 'style'>, Re
|
|
|
80
81
|
* The arrow position of the tooltip in relation to the button.
|
|
81
82
|
*/
|
|
82
83
|
tipAnchor?: MrlTooltipAnchor;
|
|
84
|
+
/**
|
|
85
|
+
* Renders custom tooltip content instead of the plain `text`. Receives `text` as
|
|
86
|
+
* its argument. `text` is still required and used for accessibility.
|
|
87
|
+
*
|
|
88
|
+
* Note: `MrlTooltip` is memoized, so this function should be memoized by consumers.
|
|
89
|
+
*/
|
|
90
|
+
tooltipCustomRender?: MrlTooltipProps['customRender'];
|
|
83
91
|
/**
|
|
84
92
|
* Enables interaction tracking for this button. Provide a stable, non-PII id
|
|
85
93
|
* (e.g. 'board-share-cta'). When omitted, the button emits no analytics.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MrlButtonSize, IconPosition } from '../../button/constants';
|
|
3
3
|
import { LinkTargetType, MrlLinkButtonKind } from '../constants';
|
|
4
|
-
import type
|
|
4
|
+
import { type TooltipConfig } from '../../tooltip/MrlTooltip/MrlTooltip';
|
|
5
5
|
import { MrlComponentProps } from '../../../utils';
|
|
6
6
|
import './MrlLinkButton.global.scss';
|
|
7
7
|
export interface MrlLinkButtonProps extends Omit<MrlComponentProps, 'style'>, React.ComponentProps<'a'> {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { MrlIconButtonProps } from '../../button/MrlIconButton/MrlIconButton';
|
|
2
3
|
import { MrlTooltipAnchor, MrlTooltipPosition } from '../../tooltip/constants';
|
|
3
4
|
import { PaginationButtonType } from '../constants';
|
|
4
5
|
interface MrlPaginationButtonProps {
|
|
@@ -35,11 +36,18 @@ interface MrlPaginationButtonProps {
|
|
|
35
36
|
tooltipAnchor?: MrlTooltipAnchor;
|
|
36
37
|
/** The placement of the tooltips on the buttons */
|
|
37
38
|
tooltipPosition?: MrlTooltipPosition;
|
|
39
|
+
/**
|
|
40
|
+
* Renders custom tooltip content instead of the plain label. Receives the resolved
|
|
41
|
+
* label (`text` or the default for `kind`) so defaults can be decorated.
|
|
42
|
+
*
|
|
43
|
+
* Note: `MrlTooltip` is memoized, so this function should be memoized by consumers.
|
|
44
|
+
*/
|
|
45
|
+
tooltipCustomRender?: MrlIconButtonProps['tooltipCustomRender'];
|
|
38
46
|
}
|
|
39
47
|
/**
|
|
40
48
|
* Pagination button component
|
|
41
49
|
* @param {MrlPaginationButtonProps} props - the component props
|
|
42
50
|
* @returns a pagintaion button
|
|
43
51
|
*/
|
|
44
|
-
export declare function MrlPaginationButton({ buttonClass, className, disabled, kind, handleClick, text, tooltipAnchor, tooltipPosition, eventId, ...rest }: MrlPaginationButtonProps): JSX.Element;
|
|
52
|
+
export declare function MrlPaginationButton({ buttonClass, className, disabled, kind, handleClick, text, tooltipAnchor, tooltipPosition, tooltipCustomRender, eventId, ...rest }: MrlPaginationButtonProps): JSX.Element;
|
|
45
53
|
export {};
|
|
@@ -50,6 +50,7 @@ export interface MrlToolbarButtonProps {
|
|
|
50
50
|
size?: MrlIconButtonProps['size'];
|
|
51
51
|
state?: MrlIconButtonProps['state'];
|
|
52
52
|
tipAnchor?: MrlIconButtonProps['tipAnchor'];
|
|
53
|
+
tooltipCustomRender?: MrlIconButtonProps['tooltipCustomRender'];
|
|
53
54
|
toggleAria?: MrlIconButtonProps['toggleAria'];
|
|
54
55
|
toggleStyle?: MrlIconButtonProps['toggleStyle'];
|
|
55
56
|
};
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { AttrsObject } from '../../../utils';
|
|
3
3
|
import { MrlTooltipAnchor, MrlTooltipPosition, MrlTooltipState } from '../constants';
|
|
4
4
|
import '../../../styles/shared/a11y-helpers/a11y.global.scss';
|
|
5
|
-
interface MrlTooltipProps {
|
|
5
|
+
export interface MrlTooltipProps {
|
|
6
6
|
/** The arrow position of the tooltip in relation to its trigger's content */
|
|
7
7
|
anchor?: MrlTooltipAnchor;
|
|
8
8
|
/**
|
|
@@ -37,7 +37,12 @@ interface MrlTooltipProps {
|
|
|
37
37
|
tooltipClass?: string;
|
|
38
38
|
/** A class to be applied ot the tooltip content */
|
|
39
39
|
tooltipContentClass?: string;
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Renders custom tooltip content instead of the plain `text`. Receives `text` as
|
|
42
|
+
* its argument. `text` is still required and used for accessibility.
|
|
43
|
+
*
|
|
44
|
+
* Note: `MrlTooltip` is memoized, so this function should be memoized by consumers.
|
|
45
|
+
*/
|
|
41
46
|
customRender?: (text?: string) => React.ReactNode;
|
|
42
47
|
/**
|
|
43
48
|
* Enables interaction tracking for this tooltip. Provide a stable, non-PII id
|
|
@@ -48,6 +53,10 @@ interface MrlTooltipProps {
|
|
|
48
53
|
*/
|
|
49
54
|
eventId?: string;
|
|
50
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Tooltip configuration for components that wrap `MrlTooltip` (e.g. `MrlButton`).
|
|
58
|
+
*/
|
|
59
|
+
export type TooltipConfig = Pick<MrlTooltipProps, 'anchor' | 'customRender' | 'dataQa' | 'position' | 'text'>;
|
|
51
60
|
/**
|
|
52
61
|
* MrlTooltip Component
|
|
53
62
|
*
|
|
@@ -57,4 +66,3 @@ interface MrlTooltipProps {
|
|
|
57
66
|
* @returns {HTMLElement} a configured Tooltip component
|
|
58
67
|
*/
|
|
59
68
|
export declare const MrlTooltip: React.MemoExoticComponent<(props: MrlTooltipProps) => React.ReactElement>;
|
|
60
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MrlTooltip } from './MrlTooltip';
|
|
1
|
+
export { MrlTooltip, type MrlTooltipProps, type TooltipConfig } from './MrlTooltip';
|
|
@@ -108,7 +108,8 @@ var MrlAvatarButton = _ref => {
|
|
|
108
108
|
position: tooltip.position || 'bottom',
|
|
109
109
|
anchor: tooltip.anchor || 'center',
|
|
110
110
|
text: tooltip.text,
|
|
111
|
-
dataQa: tooltip.dataQa
|
|
111
|
+
dataQa: tooltip.dataQa,
|
|
112
|
+
customRender: tooltip.customRender
|
|
112
113
|
}, renderAvatarButton());
|
|
113
114
|
};
|
|
114
115
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlAvatarButton.js","sources":["../../../../../src/components/avatar/MrlAvatarButton/MrlAvatarButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classNames from 'classnames';\nimport type { MrlButtonState, TooltipConfig } from '../../button/MrlButton/MrlButton';\nimport { MrlSpinner } from '../../loader/MrlSpinner/MrlSpinner';\nimport { MrlTooltip } from '../../tooltip/MrlTooltip/MrlTooltip';\nimport { MrlAvatar, MrlAvatarPropTypes } from '../MrlAvatar/MrlAvatar';\nimport { _isDisabled, _isSelected } from '../../button/helpers';\nimport { ToggleAria, buttonDefaults } from '../../button/constants';\nimport { setAttributes } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlAvatarButton.module.scss';\n\nexport interface MrlAvatarButtonPropTypes\n\textends MrlAvatarPropTypes,\n\t\tReact.HTMLAttributes<HTMLButtonElement> {\n\t/**\n\t * An optional class name to add to button wrapping the MrlAvatar.\n\t */\n\tbuttonClassName?: string;\n\n\t/**\n\t * An optional boolean prop to include the button in roving tabindex\n\t */\n\tincludeInRoving?: boolean;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\tisToggleButton?: boolean;\n\n\t/**\n\t * An optional aria-label to apply to the button element\n\t */\n\tlabel?: string;\n\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\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 * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'workspace-member-avatar'). When omitted, the button emits no analytics.\n\t */\n\teventId?: string;\n\n\t/**\n\t * Reference to the DOM element that is the MrlAvatarButton\n\t */\n\ttriggerRef?: React.RefObject<HTMLButtonElement>;\n}\n\n/**\n * Renders an avatar button\n * @param {MrlAvatarButtonPropTypes} props the props for your MrlAvatarButton\n * @returns {React.ReactElement} an avatar button containing the props you pass\n */\nexport const MrlAvatarButton = ({\n\tbuttonClassName,\n\tdataQa,\n\tid,\n\tincludeInRoving,\n\tisToggleButton,\n\tlabel,\n\tloading = false,\n\tloadingText = 'Loading',\n\tonClick,\n\tsize,\n\tstate = 'default',\n\ttoggleAria = buttonDefaults.toggleAria,\n\ttooltip,\n\teventId,\n\ttriggerRef,\n\t...rest\n}: MrlAvatarButtonPropTypes): React.ReactElement => {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlAvatarButton', eventId);\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\tconst spinner = (\n\t\t<MrlSpinner\n\t\t\tclassName=\"mrlButton-spinner MrlAvatarButton-spinner\"\n\t\t\tkind=\"default\"\n\t\t\trole=\"none\"\n\t\t\tsize=\"small\"\n\t\t\ttext={loadingText}\n\t\t/>\n\t);\n\n\tconst attributes = setAttributes(\n\t\t{},\n\t\t{\n\t\t\t'aria-disabled': _isDisabled(state, loading),\n\t\t\t'aria-label': label,\n\t\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\t\t'data-roving': includeInRoving ? 'true' : undefined,\n\t\t\trole: 'button',\n\t\t\ttype: 'button'\n\t\t}\n\t);\n\n\t/**\n\t * Handle onClick events\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)) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: size });\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 buttonClasses = classNames('MrlAvatarButton', styles['MrlAvatarButton'], buttonClassName, {\n\t\t[styles['MrlAvatarButton--large']]: size && size === 'large'\n\t});\n\n\tconst renderAvatarButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\taria-label={tooltip && tooltip.text}\n\t\t\tclassName={buttonClasses}\n\t\t\tdata-qa={dataQa && `${dataQa}-button`}\n\t\t\tid={id}\n\t\t\tonClick={handleOnClick}\n\t\t\tref={triggerRef}\n\t\t>\n\t\t\t{loading ? spinner : <MrlAvatar dataQa={dataQa} size={size} {...rest} />}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderAvatarButton()\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{renderAvatarButton()}\n\t\t</MrlTooltip>\n\t);\n};\n"],"names":["MrlAvatarButton","_ref","buttonClassName","dataQa","id","includeInRoving","isToggleButton","label","_ref$loading","loading","_ref$loadingText","loadingText","onClick","size","_ref$state","state","_ref$toggleAria","toggleAria","buttonDefaults","tooltip","eventId","triggerRef","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","useEffect","spinner","createElement","MrlSpinner","className","kind","role","text","attributes","setAttributes","_objectSpread","_isDisabled","concat","undefined","type","handleOnClick","e","stopPropagation","action","variant","prevIsSelected","buttonClasses","classNames","styles","renderAvatarButton","_extends","ref","MrlAvatar","MrlTooltip","position","anchor"],"mappings":";;;;;;;;;;;;;AAoFA;AACA;AACA;AACA;AACA;AACO,IAAMA,eAAe,GAAGC,IAAA,IAiBqB;AAAA,EAAA,IAhBnDC,eAAe,GAAAD,IAAA,CAAfC,eAAe;IACfC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,EAAE,GAAAH,IAAA,CAAFG,EAAE;IACFC,eAAe,GAAAJ,IAAA,C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":"MrlAvatarButton.js","sources":["../../../../../src/components/avatar/MrlAvatarButton/MrlAvatarButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport classNames from 'classnames';\nimport type { MrlButtonState } from '../../button/MrlButton/MrlButton';\nimport { MrlSpinner } from '../../loader/MrlSpinner/MrlSpinner';\nimport { MrlTooltip, type TooltipConfig } from '../../tooltip/MrlTooltip/MrlTooltip';\nimport { MrlAvatar, MrlAvatarPropTypes } from '../MrlAvatar/MrlAvatar';\nimport { _isDisabled, _isSelected } from '../../button/helpers';\nimport { ToggleAria, buttonDefaults } from '../../button/constants';\nimport { setAttributes } from '../../../utils';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlAvatarButton.module.scss';\n\nexport interface MrlAvatarButtonPropTypes\n\textends MrlAvatarPropTypes,\n\t\tReact.HTMLAttributes<HTMLButtonElement> {\n\t/**\n\t * An optional class name to add to button wrapping the MrlAvatar.\n\t */\n\tbuttonClassName?: string;\n\n\t/**\n\t * An optional boolean prop to include the button in roving tabindex\n\t */\n\tincludeInRoving?: boolean;\n\n\t/**\n\t * Selected state variant when the button is a Toggle Button. Setting this prop\n\t * informs the component that this is a toggle button and to add that functionality\n\t */\n\tisToggleButton?: boolean;\n\n\t/**\n\t * An optional aria-label to apply to the button element\n\t */\n\tlabel?: string;\n\n\t/**\n\t * Displays a spinner in the button to indicate some action is in progress.\n\t */\n\tloading?: boolean;\n\n\t/**\n\t * Text for the spinner when the button is in a loading state.\n\t */\n\tloadingText?: string;\n\n\t/**\n\t * onClick event for the button.\n\t */\n\tonClick?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;\n\n\t/**\n\t * Changes the state of the button based on user permissions or actions.\n\t */\n\tstate?: MrlButtonState;\n\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 * Enables interaction tracking for this button. Provide a stable, non-PII id\n\t * (e.g. 'workspace-member-avatar'). When omitted, the button emits no analytics.\n\t */\n\teventId?: string;\n\n\t/**\n\t * Reference to the DOM element that is the MrlAvatarButton\n\t */\n\ttriggerRef?: React.RefObject<HTMLButtonElement>;\n}\n\n/**\n * Renders an avatar button\n * @param {MrlAvatarButtonPropTypes} props the props for your MrlAvatarButton\n * @returns {React.ReactElement} an avatar button containing the props you pass\n */\nexport const MrlAvatarButton = ({\n\tbuttonClassName,\n\tdataQa,\n\tid,\n\tincludeInRoving,\n\tisToggleButton,\n\tlabel,\n\tloading = false,\n\tloadingText = 'Loading',\n\tonClick,\n\tsize,\n\tstate = 'default',\n\ttoggleAria = buttonDefaults.toggleAria,\n\ttooltip,\n\teventId,\n\ttriggerRef,\n\t...rest\n}: MrlAvatarButtonPropTypes): React.ReactElement => {\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlAvatarButton', eventId);\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\tconst spinner = (\n\t\t<MrlSpinner\n\t\t\tclassName=\"mrlButton-spinner MrlAvatarButton-spinner\"\n\t\t\tkind=\"default\"\n\t\t\trole=\"none\"\n\t\t\tsize=\"small\"\n\t\t\ttext={loadingText}\n\t\t/>\n\t);\n\n\tconst attributes = setAttributes(\n\t\t{},\n\t\t{\n\t\t\t'aria-disabled': _isDisabled(state, loading),\n\t\t\t'aria-label': label,\n\t\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\t\t'data-roving': includeInRoving ? 'true' : undefined,\n\t\t\trole: 'button',\n\t\t\ttype: 'button'\n\t\t}\n\t);\n\n\t/**\n\t * Handle onClick events\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)) {\n\t\t\treturn;\n\t\t}\n\n\t\ttrackInteraction({ action: 'click', variant: size });\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 buttonClasses = classNames('MrlAvatarButton', styles['MrlAvatarButton'], buttonClassName, {\n\t\t[styles['MrlAvatarButton--large']]: size && size === 'large'\n\t});\n\n\tconst renderAvatarButton = () => (\n\t\t<button\n\t\t\t{...attributes}\n\t\t\taria-label={tooltip && tooltip.text}\n\t\t\tclassName={buttonClasses}\n\t\t\tdata-qa={dataQa && `${dataQa}-button`}\n\t\t\tid={id}\n\t\t\tonClick={handleOnClick}\n\t\t\tref={triggerRef}\n\t\t>\n\t\t\t{loading ? spinner : <MrlAvatar dataQa={dataQa} size={size} {...rest} />}\n\t\t</button>\n\t);\n\n\treturn !tooltip ? (\n\t\trenderAvatarButton()\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\tcustomRender={tooltip.customRender}\n\t\t>\n\t\t\t{renderAvatarButton()}\n\t\t</MrlTooltip>\n\t);\n};\n"],"names":["MrlAvatarButton","_ref","buttonClassName","dataQa","id","includeInRoving","isToggleButton","label","_ref$loading","loading","_ref$loadingText","loadingText","onClick","size","_ref$state","state","_ref$toggleAria","toggleAria","buttonDefaults","tooltip","eventId","triggerRef","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_isSelected","_React$useState2","_slicedToArray","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","useEffect","spinner","createElement","MrlSpinner","className","kind","role","text","attributes","setAttributes","_objectSpread","_isDisabled","concat","undefined","type","handleOnClick","e","stopPropagation","action","variant","prevIsSelected","buttonClasses","classNames","styles","renderAvatarButton","_extends","ref","MrlAvatar","MrlTooltip","position","anchor","customRender"],"mappings":";;;;;;;;;;;;;AAoFA;AACA;AACA;AACA;AACA;AACO,IAAMA,eAAe,GAAGC,IAAA,IAiBqB;AAAA,EAAA,IAhBnDC,eAAe,GAAAD,IAAA,CAAfC,eAAe;IACfC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,EAAE,GAAAH,IAAA,CAAFG,EAAE;IACFC,eAAe,GAAAJ,IAAA,CAAfI,eAAe;IACfC,cAAc,GAAAL,IAAA,CAAdK,cAAc;IACdC,KAAK,GAAAN,IAAA,CAALM,KAAK;IAAAC,YAAA,GAAAP,IAAA,CACLQ,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,YAAA;IAAAE,gBAAA,GAAAT,IAAA,CACfU,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAA,MAAA,GAAG,SAAS,GAAAA,gBAAA;IACvBE,OAAO,GAAAX,IAAA,CAAPW,OAAO;IACPC,IAAI,GAAAZ,IAAA,CAAJY,IAAI;IAAAC,UAAA,GAAAb,IAAA,CACJc,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,SAAS,GAAAA,UAAA;IAAAE,eAAA,GAAAf,IAAA,CACjBgB,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAA,MAAA,GAAGE,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EAAEA,EAAG;AACPQ,IAAAA,OAAO,EAAEsC,aAAc;AACvBW,IAAAA,GAAG,EAAExC;GAAW,CAAA,EAEfZ,OAAO,GAAG2B,OAAO,gBAAGV,KAAA,CAAAW,aAAA,CAACyB,SAAS,EAAAF,QAAA,CAAA;AAACzD,IAAAA,MAAM,EAAEA,MAAO;AAACU,IAAAA,IAAI,EAAEA;GAAK,EAAKS,IAAI,CAAG,CAChE,CACR;EAED,OAAO,CAACH,OAAO,GACdwC,kBAAkB,EAAE,gBAEpBjC,KAAA,CAAAW,aAAA,CAAC0B,UAAU,EAAA;AACVC,IAAAA,QAAQ,EAAE7C,OAAO,CAAC6C,QAAQ,IAAI,QAAS;AACvCC,IAAAA,MAAM,EAAE9C,OAAO,CAAC8C,MAAM,IAAI,QAAS;IACnCvB,IAAI,EAAEvB,OAAO,CAACuB,IAAK;IACnBvC,MAAM,EAAEgB,OAAO,CAAChB,MAAO;IACvB+D,YAAY,EAAE/C,OAAO,CAAC+C;GAAa,EAElCP,kBAAkB,EACR,CACZ;AACF;;;;"}
|
|
@@ -9,7 +9,7 @@ import { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics/useMrlAna
|
|
|
9
9
|
import { setAttributes } from '../../../utils/setAttributes/setAttributes.js';
|
|
10
10
|
import { MrlTooltip } from '../../tooltip/MrlTooltip/MrlTooltip.js';
|
|
11
11
|
|
|
12
|
-
var _excluded = ["attrs", "badge", "disableEvents", "icon", "kind", "loading", "onClick", "position", "toggleAria", "toggleStyle", "text", "tipAnchor", "eventId", "size", "state"];
|
|
12
|
+
var _excluded = ["attrs", "badge", "disableEvents", "icon", "kind", "loading", "onClick", "position", "toggleAria", "toggleStyle", "text", "tipAnchor", "tooltipCustomRender", "eventId", "size", "state"];
|
|
13
13
|
var MrlAnimatedIconButton = /*#__PURE__*/React.forwardRef(function MrlAnimatedIconButton(_ref, ref) {
|
|
14
14
|
var _ref$attrs = _ref.attrs,
|
|
15
15
|
attrs = _ref$attrs === void 0 ? {} : _ref$attrs,
|
|
@@ -30,6 +30,7 @@ var MrlAnimatedIconButton = /*#__PURE__*/React.forwardRef(function MrlAnimatedIc
|
|
|
30
30
|
text = _ref.text,
|
|
31
31
|
_ref$tipAnchor = _ref.tipAnchor,
|
|
32
32
|
tipAnchor = _ref$tipAnchor === void 0 ? MrlTooltipDefaults.anchor : _ref$tipAnchor,
|
|
33
|
+
tooltipCustomRender = _ref.tooltipCustomRender,
|
|
33
34
|
eventId = _ref.eventId,
|
|
34
35
|
_ref$size = _ref.size,
|
|
35
36
|
size = _ref$size === void 0 ? buttonDefaults.size : _ref$size,
|
|
@@ -184,7 +185,8 @@ var MrlAnimatedIconButton = /*#__PURE__*/React.forwardRef(function MrlAnimatedIc
|
|
|
184
185
|
return /*#__PURE__*/React.createElement(MrlTooltip, {
|
|
185
186
|
anchor: tipAnchor,
|
|
186
187
|
position: position,
|
|
187
|
-
text: text
|
|
188
|
+
text: text,
|
|
189
|
+
customRender: tooltipCustomRender
|
|
188
190
|
}, /*#__PURE__*/React.createElement("button", _extends({}, attributes, remainingProps, {
|
|
189
191
|
className: classNames,
|
|
190
192
|
ref: buttonRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlAnimatedIconButton.js","sources":["../../../../../src/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport * as React from 'react';\nimport { setAttributes } from '../../../utils';\nimport { MrlSvgAnimate, MrlSvgAnimateProps } from '../../svg/MrlSvgAnimate/MrlSvgAnimate';\nimport { AnimatedState } from '../../svg/constants';\nimport { MrlTooltip } from '../../tooltip';\nimport { MrlTooltipDefaults } from '../../tooltip/constants';\nimport { MrlIconButtonProps } from '../MrlIconButton/MrlIconButton';\nimport { buttonDefaults } from '../constants';\nimport { _isDisabled, _isSelected, _isToggleButton } from '../helpers';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport './MrlAnimatedIconButton.scss';\n\ninterface MrlAnimatedIconButtonProps extends Omit<MrlIconButtonProps, 'icon'> {\n\ticon: MrlSvgAnimateProps;\n}\n\ntype animationEvent = 'hover' | 'blur' | 'focus';\n\nexport const MrlAnimatedIconButton = React.forwardRef<\n\tHTMLButtonElement,\n\tMrlAnimatedIconButtonProps\n>(function MrlAnimatedIconButton(\n\t{\n\t\tattrs = {},\n\t\tbadge,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\t// We intentionally deviate from the basic button for icon-buttons since the vast\n\t\t// majority of icon buttons are ghost buttons. The proptype remains\n\t\t// consistent with the basic button however to keep our code DRY.\n\t\tkind = 'ghost-inverse',\n\t\tloading = false,\n\t\tonClick,\n\t\tposition = MrlTooltipDefaults.position,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\ttipAnchor = MrlTooltipDefaults.anchor,\n\t\teventId,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\t...remainingProps\n\t}: MrlAnimatedIconButtonProps,\n\tref\n) {\n\t/**\n\t * State value to determine if the icon should be animating\n\t */\n\tconst [isAnimating, setAnimation] = React.useState<AnimatedState>('stop');\n\n\tconst [isHovered, setHover] = React.useState(false);\n\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlAnimatedIconButton', eventId);\n\n\tconst buttonRef = React.useRef<HTMLButtonElement>(null);\n\t/**\n\t * `useImperativeHandle` customizes the instance value\n\t * that is exposed to parent components when using ref.\n\t */\n\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\tref,\n\t\t() => buttonRef.current\n\t);\n\n\t/**\n\t * MrlAnimatedIconButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && _isToggleButton(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 * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tconst handleOnClick = (e: React.MouseEvent<HTMLButtonElement>): void => {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || 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\t/**\n\t * Handle animation status for mouse events exclusively\n\t * @param {boolean} mouseEnter - Determines if this is a mouseEnter event\n\t * @returns {void}\n\t */\n\tconst handleMouseInteraction = (mouseEnter: boolean): void => {\n\t\t/** Set hover status of button */\n\t\tsetHover(mouseEnter);\n\n\t\t/**\n\t\t * If the button is in focus and we trigger a mouse event\n\t\t * we don't need to change the animation state.\n\t\t */\n\t\tif (document.activeElement === buttonRef.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (isAnimating === 'play') {\n\t\t\tsetAnimation('stop');\n\t\t} else {\n\t\t\tsetAnimation('play');\n\t\t}\n\t};\n\n\t/**\n\t * Handle animation status for mouse and keyboard events\n\t * @param {animationEvent} eventType - The type of interaction that is triggering the animation update.\n\t * @param {boolean} startEvent - Whether or not this event should start an animation\n\t * @returns {void}\n\t */\n\tconst handleAnimation = (eventType: animationEvent, startEvent = false): void => {\n\t\t/** If the button is diabled or selected, the animation must be stopped */\n\t\tif (isSelected || _isDisabled(state, loading)) {\n\t\t\tsetAnimation('stop');\n\t\t\t/** We still need to track the hover state */\n\t\t\tsetHover(startEvent);\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * If the event is a hover interaction, handle them appropriately.\n\t\t * We do this to ensure you can hover and focus without restarting\n\t\t * or stopping the animation incorrectly.\n\t\t */\n\t\tif (eventType === 'hover') {\n\t\t\thandleMouseInteraction(startEvent);\n\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * Keyboard events\n\t\t */\n\t\tif (isAnimating === 'play') {\n\t\t\t/**\n\t\t\t * If a button is hovered and focused, do not stop the\n\t\t\t * animation on blur.\n\t\t\t */\n\t\t\tif (isHovered) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAnimation('stop');\n\t\t\treturn;\n\t\t}\n\n\t\tsetAnimation('play');\n\t};\n\n\tconst handleBlur = () => {\n\t\thandleAnimation('blur');\n\t};\n\n\tconst handleFocus = () => {\n\t\thandleAnimation('focus');\n\t};\n\n\tconst handleMouseEnter = () => {\n\t\thandleAnimation('hover', true);\n\t};\n\n\tconst handleMouseLeave = () => {\n\t\thandleAnimation('hover');\n\t};\n\n\tconst classNames = classnames(\n\t\t'mrlIconButton',\n\t\t`mrlIconButton--${size}`,\n\t\t`mrlIconButton--${kind}`,\n\t\t'mrlAnimatedIconButton',\n\t\t`toggleStyle--${toggleStyle}`\n\t);\n\n\tconst attributes = setAttributes(attrs, {\n\t\t'aria-disabled': _isDisabled(state, loading),\n\t\t'aria-label': text,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\ttype: 'button'\n\t});\n\n\treturn (\n\t\t<MrlTooltip anchor={tipAnchor} position={position} text={text}>\n\t\t\t<button\n\t\t\t\t{...attributes}\n\t\t\t\t{...remainingProps}\n\t\t\t\tclassName={classNames}\n\t\t\t\tref={buttonRef}\n\t\t\t\tonBlur={handleBlur}\n\t\t\t\tonClick={handleOnClick}\n\t\t\t\tonFocus={handleFocus}\n\t\t\t\tonMouseEnter={handleMouseEnter}\n\t\t\t\tonMouseLeave={handleMouseLeave}\n\t\t\t>\n\t\t\t\t<div className=\"mrlAnimatedIconButton-iconContainer\">\n\t\t\t\t\t<MrlSvgAnimate {...icon} state={isAnimating} />\n\t\t\t\t</div>\n\t\t\t\t{badge}\n\t\t\t</button>\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlAnimatedIconButton","React","forwardRef","_ref","ref","_ref$attrs","attrs","badge","_ref$disableEvents","disableEvents","icon","_ref$kind","kind","_ref$loading","loading","onClick","_ref$position","position","MrlTooltipDefaults","_ref$toggleAria","toggleAria","buttonDefaults","toggleStyle","text","_ref$tipAnchor","tipAnchor","anchor","eventId","_ref$size","size","_ref$state","state","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_React$useState2","_slicedToArray","isAnimating","setAnimation","_React$useState3","_React$useState4","isHovered","setHover","_React$useState5","_isSelected","_React$useState6","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","buttonRef","useRef","useImperativeHandle","current","isToggleButton","_isToggleButton","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","handleMouseInteraction","mouseEnter","document","activeElement","handleAnimation","eventType","startEvent","arguments","length","undefined","handleBlur","handleFocus","handleMouseEnter","handleMouseLeave","classNames","classnames","concat","attributes","setAttributes","_objectSpread","type","createElement","MrlTooltip","_extends","className","onBlur","onFocus","onMouseEnter","onMouseLeave","MrlSvgAnimate"],"mappings":";;;;;;;;;;;;AAoBO,IAAMA,qBAAqB,gBAAGC,KAAK,CAACC,UAAU,CAGnD,SAASF,qBAAqBA,CAAAG,IAAA,EAsB/BC,GAAG,EACF;AAAA,EAAA,IAAAC,UAAA,GAAAF,IAAA,CArBAG,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAAC,kBAAA,GAAAL,IAAA,CACLM,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,kBAAA;IACrBE,IAAI,GAAAP,IAAA,CAAJO,IAAI;IAAAC,SAAA,GAAAR,IAAA,CAIJS,IAA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AACC,UAAU,EAAA;AAAC9D,IAAAA,MAAM,EAAED,SAAU;AAACR,IAAAA,QAAQ,EAAEA,QAAS;AAACM,IAAAA,IAAI,EAAEA;GAAK,eAC7DtB,KAAA,CAAAsF,aAAA,CAAA,QAAA,EAAAE,QAAA,CAAA,EAAA,EACKN,UAAU,EACVnD,cAAc,EAAA;AAClB0D,IAAAA,SAAS,EAAEV,UAAW;AACtB5E,IAAAA,GAAG,EAAEgD,SAAU;AACfuC,IAAAA,MAAM,EAAEf,UAAW;AACnB7D,IAAAA,OAAO,EAAE4C,aAAc;AACvBiC,IAAAA,OAAO,EAAEf,WAAY;AACrBgB,IAAAA,YAAY,EAAEf,gBAAiB;AAC/BgB,IAAAA,YAAY,EAAEf;GAAiB,CAAA,eAE/B9E,KAAA,CAAAsF,aAAA,CAAA,KAAA,EAAA;AAAKG,IAAAA,SAAS,EAAC;GAAqC,eACnDzF,KAAA,CAAAsF,aAAA,CAACQ,aAAa,EAAAN,QAAA,KAAK/E,IAAI,EAAA;AAAEqB,IAAAA,KAAK,EAAEQ;AAAY,GAAA,CAAE,CAC1C,CAAC,EACLhC,KACM,CACG,CAAC;AAEf,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlAnimatedIconButton.js","sources":["../../../../../src/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport * as React from 'react';\nimport { setAttributes } from '../../../utils';\nimport { MrlSvgAnimate, MrlSvgAnimateProps } from '../../svg/MrlSvgAnimate/MrlSvgAnimate';\nimport { AnimatedState } from '../../svg/constants';\nimport { MrlTooltip } from '../../tooltip';\nimport { MrlTooltipDefaults } from '../../tooltip/constants';\nimport { MrlIconButtonProps } from '../MrlIconButton/MrlIconButton';\nimport { buttonDefaults } from '../constants';\nimport { _isDisabled, _isSelected, _isToggleButton } from '../helpers';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nimport './MrlAnimatedIconButton.scss';\n\ninterface MrlAnimatedIconButtonProps extends Omit<MrlIconButtonProps, 'icon'> {\n\ticon: MrlSvgAnimateProps;\n}\n\ntype animationEvent = 'hover' | 'blur' | 'focus';\n\nexport const MrlAnimatedIconButton = React.forwardRef<\n\tHTMLButtonElement,\n\tMrlAnimatedIconButtonProps\n>(function MrlAnimatedIconButton(\n\t{\n\t\tattrs = {},\n\t\tbadge,\n\t\tdisableEvents = false,\n\t\ticon,\n\t\t// We intentionally deviate from the basic button for icon-buttons since the vast\n\t\t// majority of icon buttons are ghost buttons. The proptype remains\n\t\t// consistent with the basic button however to keep our code DRY.\n\t\tkind = 'ghost-inverse',\n\t\tloading = false,\n\t\tonClick,\n\t\tposition = MrlTooltipDefaults.position,\n\t\ttoggleAria = buttonDefaults.toggleAria,\n\t\ttoggleStyle,\n\t\ttext,\n\t\ttipAnchor = MrlTooltipDefaults.anchor,\n\t\ttooltipCustomRender,\n\t\teventId,\n\t\tsize = buttonDefaults.size,\n\t\tstate = buttonDefaults.state,\n\t\t...remainingProps\n\t}: MrlAnimatedIconButtonProps,\n\tref\n) {\n\t/**\n\t * State value to determine if the icon should be animating\n\t */\n\tconst [isAnimating, setAnimation] = React.useState<AnimatedState>('stop');\n\n\tconst [isHovered, setHover] = React.useState(false);\n\n\tconst [isSelected, setIsSelected] = React.useState(() => _isSelected(state));\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlAnimatedIconButton', eventId);\n\n\tconst buttonRef = React.useRef<HTMLButtonElement>(null);\n\t/**\n\t * `useImperativeHandle` customizes the instance value\n\t * that is exposed to parent components when using ref.\n\t */\n\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\tref,\n\t\t() => buttonRef.current\n\t);\n\n\t/**\n\t * MrlAnimatedIconButton could behave as a toggle button if toggleStyle is 'default' or 'secondary'\n\t */\n\tconst isToggleButton = toggleStyle && _isToggleButton(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 * @param {React.MouseEvent<HTMLButtonElement>} e - mouse event\n\t */\n\tconst handleOnClick = (e: React.MouseEvent<HTMLButtonElement>): void => {\n\t\te.stopPropagation();\n\n\t\tif (_isDisabled(state, loading) || 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\t/**\n\t * Handle animation status for mouse events exclusively\n\t * @param {boolean} mouseEnter - Determines if this is a mouseEnter event\n\t * @returns {void}\n\t */\n\tconst handleMouseInteraction = (mouseEnter: boolean): void => {\n\t\t/** Set hover status of button */\n\t\tsetHover(mouseEnter);\n\n\t\t/**\n\t\t * If the button is in focus and we trigger a mouse event\n\t\t * we don't need to change the animation state.\n\t\t */\n\t\tif (document.activeElement === buttonRef.current) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (isAnimating === 'play') {\n\t\t\tsetAnimation('stop');\n\t\t} else {\n\t\t\tsetAnimation('play');\n\t\t}\n\t};\n\n\t/**\n\t * Handle animation status for mouse and keyboard events\n\t * @param {animationEvent} eventType - The type of interaction that is triggering the animation update.\n\t * @param {boolean} startEvent - Whether or not this event should start an animation\n\t * @returns {void}\n\t */\n\tconst handleAnimation = (eventType: animationEvent, startEvent = false): void => {\n\t\t/** If the button is diabled or selected, the animation must be stopped */\n\t\tif (isSelected || _isDisabled(state, loading)) {\n\t\t\tsetAnimation('stop');\n\t\t\t/** We still need to track the hover state */\n\t\t\tsetHover(startEvent);\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * If the event is a hover interaction, handle them appropriately.\n\t\t * We do this to ensure you can hover and focus without restarting\n\t\t * or stopping the animation incorrectly.\n\t\t */\n\t\tif (eventType === 'hover') {\n\t\t\thandleMouseInteraction(startEvent);\n\n\t\t\treturn;\n\t\t}\n\n\t\t/**\n\t\t * Keyboard events\n\t\t */\n\t\tif (isAnimating === 'play') {\n\t\t\t/**\n\t\t\t * If a button is hovered and focused, do not stop the\n\t\t\t * animation on blur.\n\t\t\t */\n\t\t\tif (isHovered) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetAnimation('stop');\n\t\t\treturn;\n\t\t}\n\n\t\tsetAnimation('play');\n\t};\n\n\tconst handleBlur = () => {\n\t\thandleAnimation('blur');\n\t};\n\n\tconst handleFocus = () => {\n\t\thandleAnimation('focus');\n\t};\n\n\tconst handleMouseEnter = () => {\n\t\thandleAnimation('hover', true);\n\t};\n\n\tconst handleMouseLeave = () => {\n\t\thandleAnimation('hover');\n\t};\n\n\tconst classNames = classnames(\n\t\t'mrlIconButton',\n\t\t`mrlIconButton--${size}`,\n\t\t`mrlIconButton--${kind}`,\n\t\t'mrlAnimatedIconButton',\n\t\t`toggleStyle--${toggleStyle}`\n\t);\n\n\tconst attributes = setAttributes(attrs, {\n\t\t'aria-disabled': _isDisabled(state, loading),\n\t\t'aria-label': text,\n\t\t...(isToggleButton && { [`aria-${toggleAria}`]: isSelected || false }),\n\t\ttype: 'button'\n\t});\n\n\treturn (\n\t\t<MrlTooltip\n\t\t\tanchor={tipAnchor}\n\t\t\tposition={position}\n\t\t\ttext={text}\n\t\t\tcustomRender={tooltipCustomRender}\n\t\t>\n\t\t\t<button\n\t\t\t\t{...attributes}\n\t\t\t\t{...remainingProps}\n\t\t\t\tclassName={classNames}\n\t\t\t\tref={buttonRef}\n\t\t\t\tonBlur={handleBlur}\n\t\t\t\tonClick={handleOnClick}\n\t\t\t\tonFocus={handleFocus}\n\t\t\t\tonMouseEnter={handleMouseEnter}\n\t\t\t\tonMouseLeave={handleMouseLeave}\n\t\t\t>\n\t\t\t\t<div className=\"mrlAnimatedIconButton-iconContainer\">\n\t\t\t\t\t<MrlSvgAnimate {...icon} state={isAnimating} />\n\t\t\t\t</div>\n\t\t\t\t{badge}\n\t\t\t</button>\n\t\t</MrlTooltip>\n\t);\n});\n"],"names":["MrlAnimatedIconButton","React","forwardRef","_ref","ref","_ref$attrs","attrs","badge","_ref$disableEvents","disableEvents","icon","_ref$kind","kind","_ref$loading","loading","onClick","_ref$position","position","MrlTooltipDefaults","_ref$toggleAria","toggleAria","buttonDefaults","toggleStyle","text","_ref$tipAnchor","tipAnchor","anchor","tooltipCustomRender","eventId","_ref$size","size","_ref$state","state","remainingProps","_objectWithoutProperties","_excluded","_React$useState","useState","_React$useState2","_slicedToArray","isAnimating","setAnimation","_React$useState3","_React$useState4","isHovered","setHover","_React$useState5","_isSelected","_React$useState6","isSelected","setIsSelected","trackInteraction","useMrlTrackInteraction","buttonRef","useRef","useImperativeHandle","current","isToggleButton","_isToggleButton","useEffect","handleOnClick","e","stopPropagation","_isDisabled","action","variant","prevIsSelected","handleMouseInteraction","mouseEnter","document","activeElement","handleAnimation","eventType","startEvent","arguments","length","undefined","handleBlur","handleFocus","handleMouseEnter","handleMouseLeave","classNames","classnames","concat","attributes","setAttributes","_objectSpread","type","createElement","MrlTooltip","customRender","_extends","className","onBlur","onFocus","onMouseEnter","onMouseLeave","MrlSvgAnimate"],"mappings":";;;;;;;;;;;;AAoBO,IAAMA,qBAAqB,gBAAGC,KAAK,CAACC,UAAU,CAGnD,SAASF,qBAAqBA,CAAAG,IAAA,EAuB/BC,GAAG,EACF;AAAA,EAAA,IAAAC,UAAA,GAAAF,IAAA,CAtBAG,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,KAAK,GAAAJ,IAAA,CAALI,KAAK;IAAAC,kBAAA,GAAAL,IAAA,CACLM,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAA,MAAA,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AA,GAAK6B,UAAU,IAAI;GAAO,CAAA,EAAA,EAAA,EAAA;AACrEsC,IAAAA,IAAI,EAAE;AAAQ,GAAA,CACd,CAAC;AAEF,EAAA,oBACCtF,KAAA,CAAAuF,aAAA,CAACC,UAAU,EAAA;AACV/D,IAAAA,MAAM,EAAED,SAAU;AAClBR,IAAAA,QAAQ,EAAEA,QAAS;AACnBM,IAAAA,IAAI,EAAEA,IAAK;AACXmE,IAAAA,YAAY,EAAE/D;GAAoB,eAElC1B,KAAA,CAAAuF,aAAA,CAAA,QAAA,EAAAG,QAAA,CAAA,EAAA,EACKP,UAAU,EACVnD,cAAc,EAAA;AAClB2D,IAAAA,SAAS,EAAEX,UAAW;AACtB7E,IAAAA,GAAG,EAAEiD,SAAU;AACfwC,IAAAA,MAAM,EAAEhB,UAAW;AACnB9D,IAAAA,OAAO,EAAE6C,aAAc;AACvBkC,IAAAA,OAAO,EAAEhB,WAAY;AACrBiB,IAAAA,YAAY,EAAEhB,gBAAiB;AAC/BiB,IAAAA,YAAY,EAAEhB;GAAiB,CAAA,eAE/B/E,KAAA,CAAAuF,aAAA,CAAA,KAAA,EAAA;AAAKI,IAAAA,SAAS,EAAC;GAAqC,eACnD3F,KAAA,CAAAuF,aAAA,CAACS,aAAa,EAAAN,QAAA,KAAKjF,IAAI,EAAA;AAAEsB,IAAAA,KAAK,EAAEQ;AAAY,GAAA,CAAE,CAC1C,CAAC,EACLjC,KACM,CACG,CAAC;AAEf,CAAC;;;;"}
|
|
@@ -118,7 +118,8 @@ var MrlButton = /*#__PURE__*/React.forwardRef(function MrlButton(_ref, ref) {
|
|
|
118
118
|
position: tooltip.position || 'bottom',
|
|
119
119
|
anchor: tooltip.anchor || 'center',
|
|
120
120
|
text: tooltip.text,
|
|
121
|
-
dataQa: tooltip.dataQa
|
|
121
|
+
dataQa: tooltip.dataQa,
|
|
122
|
+
customRender: tooltip.customRender
|
|
122
123
|
}, renderButton());
|
|
123
124
|
});
|
|
124
125
|
|
|
@@ -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\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,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,GA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AAA,OAAA,CAAAc,MAAA,CAASpC,UAAU,CAAA,GAAKkB,UAAU,IAAI;GAAO,CAAA,EAAA,EAAA,EAAA;AACrEyB,IAAAA,IAAI,EAAE,QAAQ;AACdI,IAAAA,IAAI,EAAE;AAAQ,GAAA,CACd,CAAC;AAEF,EAAA,IAAMC,YAAY,GAAGA,mBACpBzE,KAAA,CAAAkE,aAAA,CAAA,QAAA,EAAAQ,QAAA,CAAA,EAAA,EACKL,UAAU,EACVnC,cAAc,EAAA;AAClB5B,IAAAA,SAAS,EAAEqD,UAAW;AACtBxD,IAAAA,GAAG,EAAEA,GAAI;AACToB,IAAAA,OAAO,EAAE6B;GAAc,CAAA,EAEtBlC,OAAO,GAAG+C,OAAO,GAAGrD,IAAI,eACzBZ,KAAA,CAAAkE,aAAA,CAAA,MAAA,EAAA;AAAM5D,IAAAA,SAAS,EAAC;AAAgB,GAAA,EAAEgB,IAAW,CAAC,EAC7CjB,KACM,CACR;EAED,OAAO,CAAC2B,OAAO,GACdyC,YAAY,EAAE,gBAEdzE,KAAA,CAAAkE,aAAA,CAACS,UAAU,EAAA;AACVC,IAAAA,QAAQ,EAAE5C,OAAO,CAAC4C,QAAQ,IAAI,QAAS;AACvCC,IAAAA,MAAM,EAAE7C,OAAO,CAAC6C,MAAM,IAAI,QAAS;IACnCvD,IAAI,EAAEU,OAAO,CAACV,IAAK;IACnBwD,MAAM,EAAE9C,OAAO,CAAC8C;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 { MrlTooltip, type TooltipConfig } 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 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\tcustomRender={tooltip.customRender}\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","customRender"],"mappings":";;;;;;;;;;;;AAuHO,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,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;IAClCI,OAAO,GAAArB,IAAA,CAAPqB,OAAO;IAAAC,eAAA,GAAAtB,IAAA,CACPuB,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAA,MAA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EAAEgB,IAAW,CAAC,EAC7CjB,KACM,CACR;EAED,OAAO,CAAC2B,OAAO,GACdyC,YAAY,EAAE,gBAEdzE,KAAA,CAAAkE,aAAA,CAACS,UAAU,EAAA;AACVC,IAAAA,QAAQ,EAAE5C,OAAO,CAAC4C,QAAQ,IAAI,QAAS;AACvCC,IAAAA,MAAM,EAAE7C,OAAO,CAAC6C,MAAM,IAAI,QAAS;IACnCvD,IAAI,EAAEU,OAAO,CAACV,IAAK;IACnBwD,MAAM,EAAE9C,OAAO,CAAC8C,MAAO;IACvBC,YAAY,EAAE/C,OAAO,CAAC+C;GAAa,EAElCN,YAAY,EACF,CACZ;AACF,CAAC;;;;"}
|
|
@@ -10,7 +10,7 @@ import { spinnerDefaults } from '../../loader/constants.js';
|
|
|
10
10
|
import { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics/useMrlAnalytics.js';
|
|
11
11
|
import { setAttributes, getUniqueId } from '../../../utils/setAttributes/setAttributes.js';
|
|
12
12
|
|
|
13
|
-
var _excluded = ["aria-label", "attrs", "badge", "className", "disableEvents", "disableTooltipHover", "icon", "kind", "loading", "loadingText", "onClick", "onKeyUp", "onMouseUp", "position", "toggleAria", "toggleStyle", "text", "tipAnchor", "eventId", "size", "state", "wrapperClassName", "controlledState"];
|
|
13
|
+
var _excluded = ["aria-label", "attrs", "badge", "className", "disableEvents", "disableTooltipHover", "icon", "kind", "loading", "loadingText", "onClick", "onKeyUp", "onMouseUp", "position", "toggleAria", "toggleStyle", "text", "tipAnchor", "tooltipCustomRender", "eventId", "size", "state", "wrapperClassName", "controlledState"];
|
|
14
14
|
var MrlIconButton = /*#__PURE__*/React.forwardRef(function MrlIconButton(_ref, ref) {
|
|
15
15
|
var ariaLabel = _ref['aria-label'],
|
|
16
16
|
_ref$attrs = _ref.attrs,
|
|
@@ -39,6 +39,7 @@ var MrlIconButton = /*#__PURE__*/React.forwardRef(function MrlIconButton(_ref, r
|
|
|
39
39
|
text = _ref.text,
|
|
40
40
|
_ref$tipAnchor = _ref.tipAnchor,
|
|
41
41
|
tipAnchor = _ref$tipAnchor === void 0 ? MrlTooltipDefaults.anchor : _ref$tipAnchor,
|
|
42
|
+
tooltipCustomRender = _ref.tooltipCustomRender,
|
|
42
43
|
eventId = _ref.eventId,
|
|
43
44
|
_ref$size = _ref.size,
|
|
44
45
|
size = _ref$size === void 0 ? buttonDefaults.size : _ref$size,
|
|
@@ -140,6 +141,7 @@ var MrlIconButton = /*#__PURE__*/React.forwardRef(function MrlIconButton(_ref, r
|
|
|
140
141
|
dataQa: tooltipQa,
|
|
141
142
|
position: position,
|
|
142
143
|
text: text,
|
|
144
|
+
customRender: tooltipCustomRender,
|
|
143
145
|
tooltipClass: classnames('mrlIconButton-wrapper', wrapperClassName),
|
|
144
146
|
tooltipContentClass: tooltipContentClass,
|
|
145
147
|
disableTooltipHover: disableTooltipHover,
|