@muraldevkit/ui-toolkit 4.76.0 → 4.76.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72,7 +72,7 @@ var _excluded = ["accept", "className", "errorMessage", "eventId", "fileName", "
72
72
  * @returns The MrlFileUpload component.
73
73
  */
74
74
  function MrlFileUpload(props) {
75
- var _ref, _ref2;
75
+ var _ref;
76
76
  var _props$accept = props.accept,
77
77
  accept = _props$accept === void 0 ? constants.fileUploadDefaults.accept : _props$accept,
78
78
  className = props.className,
@@ -128,7 +128,10 @@ function MrlFileUpload(props) {
128
128
  // A disabled zone outranks both — it cannot have accepted a file.
129
129
  var effectiveState = isDisabled ? 'disabled' : validationError ? 'error' : state;
130
130
  var displayName = (_ref = fileName !== null && fileName !== void 0 ? fileName : selectedName) !== null && _ref !== void 0 ? _ref : '';
131
- var displayError = (_ref2 = validationError !== null && validationError !== void 0 ? validationError : errorMessage) !== null && _ref2 !== void 0 ? _ref2 : null;
131
+ // `||` rather than `??`: an empty message is as good as no message, and has
132
+ // to fall through — to the consumer's `errorMessage`, and then to the
133
+ // default below — or an errored zone renders with no text at all.
134
+ var displayError = validationError || errorMessage || null;
132
135
  // An errored zone always carries text. The types forbid reporting 'error'
133
136
  // without a message, but a JavaScript consumer can still reach it, and colour
134
137
  // alone reaches neither assistive technology nor anyone who cannot see the hue.
@@ -1 +1 @@
1
- {"version":3,"file":"MrlFileUpload.js","sources":["../../../../../src/components/file-upload/MrlFileUpload/MrlFileUpload.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { check, importIcon } from '@muraldevkit/ds-icons';\nimport { MrlButton } from '../../button/MrlButton/MrlButton';\nimport { MrlInlineMessage } from '../../notification/MrlInlineMessage/MrlInlineMessage';\nimport { MrlLiveRegion } from '../../live-region/MrlLiveRegion/MrlLiveRegion';\nimport { MrlProgressBar } from '../../loader/MrlProgressBar/MrlProgressBar';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { MrlText } from '../../text/MrlText/MrlText';\nimport { ProgressRange } from '../../loader/constants';\nimport { DataQa } from '../../../utils/dataQa';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\nimport { DEFAULT_ERROR_MESSAGE, fileUploadDefaults, MrlFileUploadState } from '../constants';\nimport { describeConstraints, formatAcceptList, formatBytes, isAccepted } from '../helpers';\nimport styles from './MrlFileUpload.module.scss';\n\n/**\n * The resting half of the state contract: anything but a reported failure.\n */\ntype MrlFileUploadRestingProps = {\n\t/**\n\t * Message for a failure the consumer is not currently reporting — kept across\n\t * a retry, for instance. Rendered only in the error state.\n\t */\n\terrorMessage?: string;\n\t/**\n\t * The visual state of the zone, owned by the consumer. The component tracks\n\t * drag state and local validation itself, but never starts, advances or\n\t * completes an upload — pass 'uploading' with a `percent`, then 'complete'.\n\t * Reporting 'error' requires an `errorMessage`, so it lives in the other half\n\t * of this union.\n\t *\n\t * 'disabled' blocks all interaction: drag, drop and click handlers return\n\t * early rather than relying on `pointer-events` alone. Because it is a value\n\t * of this union rather than a separate flag, it replaces the lifecycle state\n\t * rather than composing with it — a zone cannot be disabled *and* report\n\t * progress at the same time.\n\t */\n\tstate?: Exclude<MrlFileUploadState, 'error'>;\n};\n\n/**\n * The failure half: reporting an error means saying what went wrong.\n */\ntype MrlFileUploadErrorProps = {\n\t/**\n\t * Why the upload failed. Required alongside `state=\"error\"`: the failure has\n\t * to reach people who cannot see the border colour.\n\t *\n\t * A retry that fails with the identical message is announced only once — a\n\t * live region re-set to the text it already holds says nothing, and the\n\t * component cannot tell a retry from a re-render. Pass through a non-error\n\t * state between attempts (back to 'idle', or 'uploading' while the retry is\n\t * in flight) so the second failure is a genuine change.\n\t */\n\terrorMessage: string;\n\t/**\n\t * Reports a failed upload. A local validation failure supplies its own\n\t * message and takes precedence over `errorMessage`.\n\t */\n\tstate: 'error';\n};\n\n/**\n * The zone's state and, when it reports a failure, the message that explains it.\n *\n * The two are a union rather than two independent props so that `state=\"error\"`\n * without an `errorMessage` does not compile. An errored zone with no text is\n * signalled by border colour alone, which reaches neither assistive technology\n * nor anyone who cannot distinguish the error hue. A consumer holding the state\n * in a variable typed as the whole union has to narrow it before rendering —\n * that is the point, not an accident.\n */\nexport type MrlFileUploadStateProps = MrlFileUploadRestingProps | MrlFileUploadErrorProps;\n\nexport type MrlFileUploadProps = {\n\t/**\n\t * Accepted file types, in the same format as the native `accept` attribute\n\t * (e.g. '.gif,.jpg,.jpeg,.png' or 'image/*'). Also enforced on drop, which\n\t * the native attribute does not cover.\n\t */\n\taccept?: string;\n\t/**\n\t * Name of the file being uploaded, shown in the progress and completed copy\n\t * and announced to assistive technology. Falls back to the name of the file\n\t * the user last selected.\n\t */\n\tfileName?: string;\n\t/**\n\t * Headline inside the drop zone.\n\t */\n\theading?: string;\n\t/**\n\t * Supporting line describing what is accepted.\n\t */\n\thelperText?: string;\n\t/**\n\t * Field label rendered above the drop zone, and the zone's accessible name.\n\t */\n\tlabel?: string;\n\t/**\n\t * Maximum accepted file size in bytes. Omit for no limit.\n\t */\n\tmaxSizeBytes?: number;\n\t/**\n\t * Fired when the user cancels an upload in progress. The consumer owns the\n\t * abort — the component only returns itself to its resting state.\n\t */\n\tonCancel?: () => void;\n\t/**\n\t * Fired when a file fails local validation, with the message shown to the\n\t * user. Transport failures are reported by the consumer through\n\t * `state=\"error\"` instead.\n\t */\n\tonError?: (message: string, file: File) => void;\n\t/**\n\t * Fired when a file passes validation and is ready to upload. The consumer\n\t * performs the upload and drives `state` and `percent` from its result.\n\t */\n\tonFilesSelected?: (file: File) => void;\n\t/**\n\t * Fired when the user removes a completed upload.\n\t */\n\tonRemove?: () => void;\n\t/**\n\t * Upload progress, 0–100. Only read while `state` is 'uploading'.\n\t */\n\tpercent?: ProgressRange;\n\t/**\n\t * Shows `helperText` inside the drop zone.\n\t */\n\tshowHelperText?: boolean;\n\t/**\n\t * Repeats `helperText` as an inline message below the drop zone. Off by\n\t * default — with `showHelperText` on, enabling both prints the same sentence\n\t * twice. A validation or upload error always renders below the zone\n\t * regardless of this flag.\n\t */\n\tshowInlineAlert?: boolean;\n\t/**\n\t * Additional validation, run after the built-in `accept` and `maxSizeBytes`\n\t * checks and only if those pass. Return a message to reject the file — it is\n\t * shown and reported exactly like a built-in failure — or `null` to accept it.\n\t */\n\tvalidate?: (file: File) => string | null;\n\t/**\n\t * Enables interaction tracking for this upload control. Provide a stable,\n\t * non-PII id (e.g. 'workspace-logo-upload'). When omitted, the component\n\t * emits no analytics.\n\t *\n\t * Note: file names, sizes and types are never emitted — only the fact of a\n\t * selection and whether it was accepted.\n\t */\n\teventId?: string;\n} & MrlFileUploadStateProps &\n\tOmit<React.ComponentPropsWithoutRef<'div'>, 'onError'> &\n\tDataQa;\n\n/**\n * A drag-and-drop file upload zone with a keyboard-accessible browse button.\n *\n * The component owns presentation, drag tracking and local validation\n * (`accept`, `maxSizeBytes`); the consumer owns the upload itself and drives\n * `state` and `percent`. Drag and drop is pointer-only by nature, so the\n * button inside the zone is the equivalent path for everyone else and is the\n * affordance exposed to the accessibility tree.\n *\n * @param props - The component props.\n * @returns The MrlFileUpload component.\n */\nexport function MrlFileUpload(props: MrlFileUploadProps): React.ReactElement {\n\tconst {\n\t\taccept = fileUploadDefaults.accept,\n\t\tclassName,\n\t\terrorMessage,\n\t\teventId,\n\t\tfileName,\n\t\theading = fileUploadDefaults.heading,\n\t\thelperText,\n\t\tlabel,\n\t\tmaxSizeBytes,\n\t\tonCancel,\n\t\tonError,\n\t\tonFilesSelected,\n\t\tonRemove,\n\t\tpercent = 0,\n\t\tshowHelperText = fileUploadDefaults.showHelperText,\n\t\tshowInlineAlert = fileUploadDefaults.showInlineAlert,\n\t\tstate = fileUploadDefaults.state,\n\t\tvalidate,\n\t\t['data-qa']: dataQa,\n\t\t...rest\n\t} = props;\n\n\tconst [isDragging, setIsDragging] = React.useState(false);\n\tconst [validationError, setValidationError] = React.useState<string | null>(null);\n\tconst [selectedName, setSelectedName] = React.useState<string | null>(null);\n\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\t// The action button of whichever view is showing — Browse, Cancel or Remove.\n\tconst actionRef = React.useRef<HTMLButtonElement>(null);\n\t// Armed when an interaction puts focus on that button, so the next view swap\n\t// can hand it back rather than dropping it.\n\tconst shouldRestoreFocus = React.useRef(false);\n\t// dragenter/dragleave fire for descendants too; counting keeps the state stable.\n\tconst dragDepth = React.useRef(0);\n\n\tconst reactId = React.useId();\n\tconst labelId = `${reactId}-label`;\n\tconst messageId = `${reactId}-message`;\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlFileUpload', eventId);\n\n\tconst isDisabled = state === 'disabled';\n\t// A failed local validation outranks the consumer's state: no upload started.\n\t// A disabled zone outranks both — it cannot have accepted a file.\n\tconst effectiveState: MrlFileUploadState = isDisabled\n\t\t? 'disabled'\n\t\t: validationError\n\t\t\t? 'error'\n\t\t\t: state;\n\tconst displayName = fileName ?? selectedName ?? '';\n\tconst displayError = validationError ?? errorMessage ?? null;\n\t// An errored zone always carries text. The types forbid reporting 'error'\n\t// without a message, but a JavaScript consumer can still reach it, and colour\n\t// alone reaches neither assistive technology nor anyone who cannot see the hue.\n\tconst resolvedError =\n\t\teffectiveState === 'error' ? (displayError ?? DEFAULT_ERROR_MESSAGE) : displayError;\n\t// Derived rather than defaulted, so the copy cannot contradict what validation\n\t// enforces — and so the size limit is stated before it rejects anyone.\n\tconst resolvedHelperText = helperText ?? describeConstraints(accept, maxSizeBytes);\n\tconst isBusy = effectiveState === 'uploading';\n\n\t/**\n\t * Validates a file — against `accept` and `maxSizeBytes`, then against the\n\t * consumer's own `validate` — and hands it over, or reports why it was\n\t * rejected. Emits exactly one analytics event per selection.\n\t *\n\t * @param file - the file the user chose or dropped\n\t * @param source - how the file arrived, for analytics only\n\t */\n\tconst acceptFile = React.useCallback(\n\t\t(file: File | undefined, source: 'browse' | 'drop') => {\n\t\t\tif (!file) return;\n\n\t\t\tlet rejection: string | null = null;\n\n\t\t\tif (!isAccepted(file, accept)) {\n\t\t\t\t// The rule that rejected the file is the only reliable source for what\n\t\t\t\t// would be accepted; a hand-written list drifts away from `accept`.\n\t\t\t\tconst types = formatAcceptList(accept);\n\t\t\t\trejection = types\n\t\t\t\t\t? `File type is not valid. Accepted types: ${types}`\n\t\t\t\t\t: 'File type is not valid';\n\t\t\t} else if (maxSizeBytes !== undefined && file.size > maxSizeBytes) {\n\t\t\t\trejection = `File is larger than ${formatBytes(maxSizeBytes)}`;\n\t\t\t} else {\n\t\t\t\t// The consumer's rules run last, so a file that fails the component's\n\t\t\t\t// own checks never reaches them.\n\t\t\t\trejection = validate?.(file) ?? null;\n\t\t\t}\n\n\t\t\t// The file's name, size and type are consumer data and are never emitted.\n\t\t\ttrackInteraction({\n\t\t\t\taction: 'select',\n\t\t\t\tmetadata: { outcome: rejection ? 'rejected' : 'accepted', source }\n\t\t\t});\n\n\t\t\tif (rejection) {\n\t\t\t\tsetSelectedName(file.name);\n\t\t\t\tsetValidationError(rejection);\n\t\t\t\tonError?.(rejection, file);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetSelectedName(file.name);\n\t\t\tsetValidationError(null);\n\t\t\t// A browse selection leaves focus on the Browse button, which the consumer\n\t\t\t// is about to unmount by moving to 'uploading'. A drop does not: it is\n\t\t\t// pointer-only, and focus was never in the zone to begin with.\n\t\t\tif (source === 'browse') shouldRestoreFocus.current = true;\n\t\t\tonFilesSelected?.(file);\n\t\t},\n\t\t[accept, maxSizeBytes, onError, onFilesSelected, trackInteraction, validate]\n\t);\n\n\t/**\n\t * Returns the zone to its resting state and clears the native input so the\n\t * same file can be chosen again.\n\t */\n\tconst reset = React.useCallback(() => {\n\t\tdragDepth.current = 0;\n\t\tsetIsDragging(false);\n\t\tsetSelectedName(null);\n\t\tsetValidationError(null);\n\t\tif (inputRef.current) inputRef.current.value = '';\n\t}, []);\n\n\tconst handleBrowse = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tinputRef.current?.click();\n\t}, [isDisabled]);\n\n\tconst handleCancel = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tshouldRestoreFocus.current = true;\n\t\ttrackInteraction({ action: 'click', metadata: { control: 'cancel' } });\n\t\treset();\n\t\tonCancel?.();\n\t}, [isDisabled, onCancel, reset, trackInteraction]);\n\n\tconst handleRemove = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tshouldRestoreFocus.current = true;\n\t\ttrackInteraction({ action: 'clear', metadata: { control: 'remove' } });\n\t\treset();\n\t\tonRemove?.();\n\t}, [isDisabled, onRemove, reset, trackInteraction]);\n\n\tconst handleDragEnter = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current += 1;\n\t\t\tsetIsDragging(true);\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDragOver = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\t// Required, or the browser treats the drop as navigation and opens the file.\n\t\t\tevent.preventDefault();\n\t\t\tevent.dataTransfer.dropEffect = 'copy';\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDragLeave = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current = Math.max(0, dragDepth.current - 1);\n\t\t\t// Leaving without dropping restores the previous view rather than resetting,\n\t\t\t// so a completed or errored zone is not cleared by a passing cursor.\n\t\t\tif (dragDepth.current === 0) setIsDragging(false);\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDrop = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current = 0;\n\t\t\tsetIsDragging(false);\n\t\t\tacceptFile(event.dataTransfer.files?.[0], 'drop');\n\t\t},\n\t\t[acceptFile, isDisabled, isBusy]\n\t);\n\n\tconst handleInputChange = React.useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tconst file = event.target.files?.[0];\n\t\t\t// Cleared before validating: the native control fires `change` only when\n\t\t\t// the selection changes, so re-picking a corrected file would be silent.\n\t\t\tevent.target.value = '';\n\t\t\tacceptFile(file, 'browse');\n\t\t},\n\t\t[acceptFile]\n\t);\n\n\tconst view = isDragging ? 'dragging' : effectiveState;\n\n\t/*\n\t * Each view renders its action button at a different position inside the zone,\n\t * so React unmounts one and mounts another rather than reusing it, and the\n\t * browser drops focus to the body — sending a keyboard user back to the top of\n\t * the page mid-task. Hand focus to the button that replaced it, but only when\n\t * it was genuinely lost: never take it from someone who has tabbed away.\n\t */\n\tReact.useLayoutEffect(() => {\n\t\tif (!shouldRestoreFocus.current) return;\n\n\t\tconst focusWasLost = !document.activeElement || document.activeElement === document.body;\n\t\tshouldRestoreFocus.current = false;\n\n\t\tif (focusWasLost) {\n\t\t\tactionRef.current?.focus();\n\t\t\t// Focus is inside the zone again, so keep the chain armed for the next\n\t\t\t// swap — an upload the consumer completes on its own included.\n\t\t\tshouldRestoreFocus.current = true;\n\t\t}\n\t}, [view]);\n\n\t/* eslint-disable sort-keys */\n\tconst zoneClasses = classnames({\n\t\t[styles['MrlFileUpload-zone']]: true,\n\t\t'MrlFileUpload-zone': true,\n\t\t[styles[`MrlFileUpload-zone--${view}`]]: view !== 'idle'\n\t});\n\t/* eslint-enable sort-keys */\n\n\tconst inlineKind = resolvedError ? 'error' : 'helper';\n\tconst inlineMessage = resolvedError ?? (showInlineAlert ? resolvedHelperText : null);\n\n\tconst announcement = () => {\n\t\tif (effectiveState === 'uploading') {\n\t\t\t// Quantised to 10% steps. A live region queues announcements rather than\n\t\t\t// replacing them, so narrating every tick buries 'upload successful'\n\t\t\t// behind a backlog that is usually discarded before it is spoken.\n\t\t\tconst step = Math.floor(Math.round(percent) / 10) * 10;\n\t\t\treturn `Uploading ${displayName}, ${step}%`;\n\t\t}\n\t\tif (effectiveState === 'complete') return `Upload of ${displayName} successful`;\n\t\tif (effectiveState === 'error' && resolvedError) {\n\t\t\t// Prefixed with the file name so two failures for the same reason are two\n\t\t\t// different strings: a live region re-set to the same text stays silent.\n\t\t\treturn displayName ? `${displayName}: ${resolvedError}` : resolvedError;\n\t\t}\n\t\treturn '';\n\t};\n\n\tconst restingContent = (\n\t\t<>\n\t\t\t<div className={classnames(styles['MrlFileUpload-content'], 'MrlFileUpload-content')}>\n\t\t\t\t<p className={classnames(styles['MrlFileUpload-heading'], 'MrlFileUpload-heading')}>\n\t\t\t\t\t{heading}\n\t\t\t\t</p>\n\t\t\t\t{showHelperText && resolvedHelperText && (\n\t\t\t\t\t<MrlText size=\"small\">{resolvedHelperText}</MrlText>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<MrlButton\n\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\tkind=\"secondary\"\n\t\t\t\tref={actionRef}\n\t\t\t\tsize=\"small\"\n\t\t\t\tstate={isDisabled ? 'disabled' : 'default'}\n\t\t\t\ttext=\"Browse files\"\n\t\t\t\tonClick={handleBrowse}\n\t\t\t/>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tdata-qa={dataQa}\n\t\t\tclassName={classnames(styles['MrlFileUpload'], 'MrlFileUpload', className)}\n\t\t>\n\t\t\t{label && (\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(styles['MrlFileUpload-label'], 'MrlFileUpload-label')}\n\t\t\t\t\tid={labelId}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t)}\n\n\t\t\t<div\n\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\taria-disabled={isDisabled || undefined}\n\t\t\t\taria-label={label ? undefined : heading}\n\t\t\t\taria-labelledby={label ? labelId : undefined}\n\t\t\t\tclassName={zoneClasses}\n\t\t\t\trole=\"group\"\n\t\t\t\tonDragEnter={handleDragEnter}\n\t\t\t\tonDragLeave={handleDragLeave}\n\t\t\t\tonDragOver={handleDragOver}\n\t\t\t\tonDrop={handleDrop}\n\t\t\t>\n\t\t\t\t{(view === 'idle' || view === 'error' || view === 'disabled') && restingContent}\n\n\t\t\t\t{view === 'dragging' && (\n\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon'],\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon--accent']\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\t\tsvg={importIcon}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--accent']\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tDrop your files\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\n\t\t\t\t{view === 'uploading' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-progress'])}>\n\t\t\t\t\t\t\t\t<MrlProgressBar\n\t\t\t\t\t\t\t\t\tname={`Uploading ${displayName || 'file'}`}\n\t\t\t\t\t\t\t\t\tpercent={Math.round(percent) as ProgressRange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--strong']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tUploading {displayName}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\t\t\t\tkind=\"secondary\"\n\t\t\t\t\t\t\tref={actionRef}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ttext=\"Cancel\"\n\t\t\t\t\t\t\tonClick={handleCancel}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\n\t\t\t\t{view === 'complete' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon--success']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\t\t\tsvg={check}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--strong']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tUpload of {displayName} successful!\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\t\t\t\tkind=\"secondary\"\n\t\t\t\t\t\t\tref={actionRef}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ttext=\"Remove\"\n\t\t\t\t\t\t\tonClick={handleRemove}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{inlineMessage && (\n\t\t\t\t<MrlInlineMessage id={messageId} kind={inlineKind} message={inlineMessage} />\n\t\t\t)}\n\n\t\t\t{/*\n\t\t\t * The real control, opened by the \"Browse files\" button. It is removed from\n\t\t\t * the tab order and the accessibility tree deliberately: the button is the\n\t\t\t * accessible affordance, and a focusable invisible input would be a keyboard\n\t\t\t * trap with no visible focus ring. Do not make it focusable.\n\t\t\t */}\n\t\t\t<input\n\t\t\t\taccept={accept || undefined}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tclassName={classnames(styles['MrlFileUpload-input'])}\n\t\t\t\tdisabled={isDisabled}\n\t\t\t\tref={inputRef}\n\t\t\t\ttabIndex={-1}\n\t\t\t\ttype=\"file\"\n\t\t\t\tonChange={handleInputChange}\n\t\t\t/>\n\n\t\t\t<MrlLiveRegion ariaLive=\"polite\" srContent={announcement()} />\n\t\t</div>\n\t);\n}\n"],"names":["MrlFileUpload","props","_ref","_ref2","_props$accept","accept","fileUploadDefaults","className","errorMessage","eventId","fileName","_props$heading","heading","helperText","label","maxSizeBytes","onCancel","onError","onFilesSelected","onRemove","_props$percent","percent","_props$showHelperText","showHelperText","_props$showInlineAler","showInlineAlert","_props$state","state","validate","dataQa","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","isDragging","setIsDragging","_React$useState3","_React$useState4","validationError","setValidationError","_React$useState5","_React$useState6","selectedName","setSelectedName","inputRef","useRef","actionRef","shouldRestoreFocus","dragDepth","reactId","useId","labelId","concat","messageId","trackInteraction","useMrlTrackInteraction","isDisabled","effectiveState","displayName","displayError","resolvedError","DEFAULT_ERROR_MESSAGE","resolvedHelperText","describeConstraints","isBusy","acceptFile","useCallback","file","source","rejection","isAccepted","types","formatAcceptList","undefined","size","formatBytes","_validate","action","metadata","outcome","name","current","reset","value","handleBrowse","_inputRef$current","click","handleCancel","control","handleRemove","handleDragEnter","event","preventDefault","handleDragOver","dataTransfer","dropEffect","handleDragLeave","Math","max","handleDrop","_event$dataTransfer$f","files","handleInputChange","_event$target$files","target","view","useLayoutEffect","focusWasLost","document","activeElement","body","_actionRef$current","focus","zoneClasses","classnames","styles","inlineKind","inlineMessage","announcement","step","floor","round","restingContent","createElement","Fragment","MrlText","MrlButton","kind","ref","text","onClick","_extends","id","role","onDragEnter","onDragLeave","onDragOver","onDrop","MrlSvg","svg","importIcon","MrlProgressBar","check","MrlInlineMessage","message","disabled","tabIndex","type","onChange","MrlLiveRegion","ariaLive","srContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA;AACA;AACA;;AAuBA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAACC,KAAyB,EAAsB;EAAA,IAAAC,IAAA,EAAAC,KAAA;AAC5E,EAAA,IAAAC,aAAA,GAqBIH,KAAK,CApBRI,MAAM;AAANA,IAAAA,MAAM,GAAAD,aAAA,KAAA,MAAA,GAAGE,4BAAkB,CAACD,MAAM,GAAAD,aAAA;IAClCG,SAAS,GAmBNN,KAAK,CAnBRM,SAAS;IACTC,YAAY,GAkBTP,KAAK,CAlBRO,YAAY;IACZC,OAAO,GAiBJR,KAAK,CAjBRQ,OAAO;IACPC,QAAQ,GAgBLT,KAAK,CAhBRS,QAAQ;IAAAC,cAAA,GAgBLV,KAAK,CAfRW,OAAO;AAAPA,IAAAA,OAAO,GAAAD,cAAA,KAAA,MAAA,GAAGL,4BAAkB,CAACM,OAAO,GAAAD,cAAA;IACpCE,UAAU,GAcPZ,KAAK,CAdRY,UAAU;IACVC,KAAK,GAaFb,KAAK,CAbRa,KAAK;IACLC,YAAY,GAYTd,KAAK,CAZRc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H,MAAM,EAAEA,MAAM,IAAIwE,SAAU;AAC5B,IAAA,aAAA,EAAY,MAAM;AAClBtE,IAAAA,SAAS,EAAE+G,2BAAU,CAACC,4BAAM,CAAC,qBAAqB,CAAC,CAAE;AACrD8B,IAAAA,QAAQ,EAAEzF,UAAW;AACrBwE,IAAAA,GAAG,EAAEpF,QAAS;IACdsG,QAAQ,EAAE,EAAG;AACbC,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,QAAQ,EAAE9C;AAAkB,GAC5B,CAAC,eAEFxE,gBAAA,CAAA6F,aAAA,CAAC0B,2BAAa,EAAA;AAACC,IAAAA,QAAQ,EAAC,QAAQ;IAACC,SAAS,EAAEjC,YAAY;AAAG,GAAE,CACzD,CAAC;AAER;;;;"}
1
+ {"version":3,"file":"MrlFileUpload.js","sources":["../../../../../src/components/file-upload/MrlFileUpload/MrlFileUpload.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { check, importIcon } from '@muraldevkit/ds-icons';\nimport { MrlButton } from '../../button/MrlButton/MrlButton';\nimport { MrlInlineMessage } from '../../notification/MrlInlineMessage/MrlInlineMessage';\nimport { MrlLiveRegion } from '../../live-region/MrlLiveRegion/MrlLiveRegion';\nimport { MrlProgressBar } from '../../loader/MrlProgressBar/MrlProgressBar';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { MrlText } from '../../text/MrlText/MrlText';\nimport { ProgressRange } from '../../loader/constants';\nimport { DataQa } from '../../../utils/dataQa';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\nimport { DEFAULT_ERROR_MESSAGE, fileUploadDefaults, MrlFileUploadState } from '../constants';\nimport { describeConstraints, formatAcceptList, formatBytes, isAccepted } from '../helpers';\nimport styles from './MrlFileUpload.module.scss';\n\n/**\n * The resting half of the state contract: anything but a reported failure.\n */\ntype MrlFileUploadRestingProps = {\n\t/**\n\t * Message for a failure the consumer is not currently reporting — kept across\n\t * a retry, for instance. Rendered only in the error state.\n\t */\n\terrorMessage?: string;\n\t/**\n\t * The visual state of the zone, owned by the consumer. The component tracks\n\t * drag state and local validation itself, but never starts, advances or\n\t * completes an upload — pass 'uploading' with a `percent`, then 'complete'.\n\t * Reporting 'error' requires an `errorMessage`, so it lives in the other half\n\t * of this union.\n\t *\n\t * 'disabled' blocks all interaction: drag, drop and click handlers return\n\t * early rather than relying on `pointer-events` alone. Because it is a value\n\t * of this union rather than a separate flag, it replaces the lifecycle state\n\t * rather than composing with it — a zone cannot be disabled *and* report\n\t * progress at the same time.\n\t */\n\tstate?: Exclude<MrlFileUploadState, 'error'>;\n};\n\n/**\n * The failure half: reporting an error means saying what went wrong.\n */\ntype MrlFileUploadErrorProps = {\n\t/**\n\t * Why the upload failed. Required alongside `state=\"error\"`: the failure has\n\t * to reach people who cannot see the border colour.\n\t *\n\t * A retry that fails with the identical message is announced only once — a\n\t * live region re-set to the text it already holds says nothing, and the\n\t * component cannot tell a retry from a re-render. Pass through a non-error\n\t * state between attempts (back to 'idle', or 'uploading' while the retry is\n\t * in flight) so the second failure is a genuine change.\n\t */\n\terrorMessage: string;\n\t/**\n\t * Reports a failed upload. A local validation failure supplies its own\n\t * message and takes precedence over `errorMessage`.\n\t */\n\tstate: 'error';\n};\n\n/**\n * The zone's state and, when it reports a failure, the message that explains it.\n *\n * The two are a union rather than two independent props so that `state=\"error\"`\n * without an `errorMessage` does not compile. An errored zone with no text is\n * signalled by border colour alone, which reaches neither assistive technology\n * nor anyone who cannot distinguish the error hue. A consumer holding the state\n * in a variable typed as the whole union has to narrow it before rendering —\n * that is the point, not an accident.\n */\nexport type MrlFileUploadStateProps = MrlFileUploadRestingProps | MrlFileUploadErrorProps;\n\nexport type MrlFileUploadProps = {\n\t/**\n\t * Accepted file types, in the same format as the native `accept` attribute\n\t * (e.g. '.gif,.jpg,.jpeg,.png' or 'image/*'). Also enforced on drop, which\n\t * the native attribute does not cover.\n\t */\n\taccept?: string;\n\t/**\n\t * Name of the file being uploaded, shown in the progress and completed copy\n\t * and announced to assistive technology. Falls back to the name of the file\n\t * the user last selected.\n\t */\n\tfileName?: string;\n\t/**\n\t * Headline inside the drop zone.\n\t */\n\theading?: string;\n\t/**\n\t * Supporting line describing what is accepted.\n\t */\n\thelperText?: string;\n\t/**\n\t * Field label rendered above the drop zone, and the zone's accessible name.\n\t */\n\tlabel?: string;\n\t/**\n\t * Maximum accepted file size in bytes. Omit for no limit.\n\t */\n\tmaxSizeBytes?: number;\n\t/**\n\t * Fired when the user cancels an upload in progress. The consumer owns the\n\t * abort — the component only returns itself to its resting state.\n\t */\n\tonCancel?: () => void;\n\t/**\n\t * Fired when a file fails local validation, with the message shown to the\n\t * user. Transport failures are reported by the consumer through\n\t * `state=\"error\"` instead.\n\t */\n\tonError?: (message: string, file: File) => void;\n\t/**\n\t * Fired when a file passes validation and is ready to upload. The consumer\n\t * performs the upload and drives `state` and `percent` from its result.\n\t */\n\tonFilesSelected?: (file: File) => void;\n\t/**\n\t * Fired when the user removes a completed upload.\n\t */\n\tonRemove?: () => void;\n\t/**\n\t * Upload progress, 0–100. Only read while `state` is 'uploading'.\n\t */\n\tpercent?: ProgressRange;\n\t/**\n\t * Shows `helperText` inside the drop zone.\n\t */\n\tshowHelperText?: boolean;\n\t/**\n\t * Repeats `helperText` as an inline message below the drop zone. Off by\n\t * default — with `showHelperText` on, enabling both prints the same sentence\n\t * twice. A validation or upload error always renders below the zone\n\t * regardless of this flag.\n\t */\n\tshowInlineAlert?: boolean;\n\t/**\n\t * Additional validation, run after the built-in `accept` and `maxSizeBytes`\n\t * checks and only if those pass. Return a message to reject the file — it is\n\t * shown and reported exactly like a built-in failure — or `null` to accept it.\n\t */\n\tvalidate?: (file: File) => string | null;\n\t/**\n\t * Enables interaction tracking for this upload control. Provide a stable,\n\t * non-PII id (e.g. 'workspace-logo-upload'). When omitted, the component\n\t * emits no analytics.\n\t *\n\t * Note: file names, sizes and types are never emitted — only the fact of a\n\t * selection and whether it was accepted.\n\t */\n\teventId?: string;\n} & MrlFileUploadStateProps &\n\tOmit<React.ComponentPropsWithoutRef<'div'>, 'onError'> &\n\tDataQa;\n\n/**\n * A drag-and-drop file upload zone with a keyboard-accessible browse button.\n *\n * The component owns presentation, drag tracking and local validation\n * (`accept`, `maxSizeBytes`); the consumer owns the upload itself and drives\n * `state` and `percent`. Drag and drop is pointer-only by nature, so the\n * button inside the zone is the equivalent path for everyone else and is the\n * affordance exposed to the accessibility tree.\n *\n * @param props - The component props.\n * @returns The MrlFileUpload component.\n */\nexport function MrlFileUpload(props: MrlFileUploadProps): React.ReactElement {\n\tconst {\n\t\taccept = fileUploadDefaults.accept,\n\t\tclassName,\n\t\terrorMessage,\n\t\teventId,\n\t\tfileName,\n\t\theading = fileUploadDefaults.heading,\n\t\thelperText,\n\t\tlabel,\n\t\tmaxSizeBytes,\n\t\tonCancel,\n\t\tonError,\n\t\tonFilesSelected,\n\t\tonRemove,\n\t\tpercent = 0,\n\t\tshowHelperText = fileUploadDefaults.showHelperText,\n\t\tshowInlineAlert = fileUploadDefaults.showInlineAlert,\n\t\tstate = fileUploadDefaults.state,\n\t\tvalidate,\n\t\t['data-qa']: dataQa,\n\t\t...rest\n\t} = props;\n\n\tconst [isDragging, setIsDragging] = React.useState(false);\n\tconst [validationError, setValidationError] = React.useState<string | null>(null);\n\tconst [selectedName, setSelectedName] = React.useState<string | null>(null);\n\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\t// The action button of whichever view is showing — Browse, Cancel or Remove.\n\tconst actionRef = React.useRef<HTMLButtonElement>(null);\n\t// Armed when an interaction puts focus on that button, so the next view swap\n\t// can hand it back rather than dropping it.\n\tconst shouldRestoreFocus = React.useRef(false);\n\t// dragenter/dragleave fire for descendants too; counting keeps the state stable.\n\tconst dragDepth = React.useRef(0);\n\n\tconst reactId = React.useId();\n\tconst labelId = `${reactId}-label`;\n\tconst messageId = `${reactId}-message`;\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlFileUpload', eventId);\n\n\tconst isDisabled = state === 'disabled';\n\t// A failed local validation outranks the consumer's state: no upload started.\n\t// A disabled zone outranks both — it cannot have accepted a file.\n\tconst effectiveState: MrlFileUploadState = isDisabled\n\t\t? 'disabled'\n\t\t: validationError\n\t\t\t? 'error'\n\t\t\t: state;\n\tconst displayName = fileName ?? selectedName ?? '';\n\t// `||` rather than `??`: an empty message is as good as no message, and has\n\t// to fall through — to the consumer's `errorMessage`, and then to the\n\t// default below — or an errored zone renders with no text at all.\n\tconst displayError = validationError || errorMessage || null;\n\t// An errored zone always carries text. The types forbid reporting 'error'\n\t// without a message, but a JavaScript consumer can still reach it, and colour\n\t// alone reaches neither assistive technology nor anyone who cannot see the hue.\n\tconst resolvedError =\n\t\teffectiveState === 'error' ? (displayError ?? DEFAULT_ERROR_MESSAGE) : displayError;\n\t// Derived rather than defaulted, so the copy cannot contradict what validation\n\t// enforces — and so the size limit is stated before it rejects anyone.\n\tconst resolvedHelperText = helperText ?? describeConstraints(accept, maxSizeBytes);\n\tconst isBusy = effectiveState === 'uploading';\n\n\t/**\n\t * Validates a file — against `accept` and `maxSizeBytes`, then against the\n\t * consumer's own `validate` — and hands it over, or reports why it was\n\t * rejected. Emits exactly one analytics event per selection.\n\t *\n\t * @param file - the file the user chose or dropped\n\t * @param source - how the file arrived, for analytics only\n\t */\n\tconst acceptFile = React.useCallback(\n\t\t(file: File | undefined, source: 'browse' | 'drop') => {\n\t\t\tif (!file) return;\n\n\t\t\tlet rejection: string | null = null;\n\n\t\t\tif (!isAccepted(file, accept)) {\n\t\t\t\t// The rule that rejected the file is the only reliable source for what\n\t\t\t\t// would be accepted; a hand-written list drifts away from `accept`.\n\t\t\t\tconst types = formatAcceptList(accept);\n\t\t\t\trejection = types\n\t\t\t\t\t? `File type is not valid. Accepted types: ${types}`\n\t\t\t\t\t: 'File type is not valid';\n\t\t\t} else if (maxSizeBytes !== undefined && file.size > maxSizeBytes) {\n\t\t\t\trejection = `File is larger than ${formatBytes(maxSizeBytes)}`;\n\t\t\t} else {\n\t\t\t\t// The consumer's rules run last, so a file that fails the component's\n\t\t\t\t// own checks never reaches them.\n\t\t\t\trejection = validate?.(file) ?? null;\n\t\t\t}\n\n\t\t\t// The file's name, size and type are consumer data and are never emitted.\n\t\t\ttrackInteraction({\n\t\t\t\taction: 'select',\n\t\t\t\tmetadata: { outcome: rejection ? 'rejected' : 'accepted', source }\n\t\t\t});\n\n\t\t\tif (rejection) {\n\t\t\t\tsetSelectedName(file.name);\n\t\t\t\tsetValidationError(rejection);\n\t\t\t\tonError?.(rejection, file);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetSelectedName(file.name);\n\t\t\tsetValidationError(null);\n\t\t\t// A browse selection leaves focus on the Browse button, which the consumer\n\t\t\t// is about to unmount by moving to 'uploading'. A drop does not: it is\n\t\t\t// pointer-only, and focus was never in the zone to begin with.\n\t\t\tif (source === 'browse') shouldRestoreFocus.current = true;\n\t\t\tonFilesSelected?.(file);\n\t\t},\n\t\t[accept, maxSizeBytes, onError, onFilesSelected, trackInteraction, validate]\n\t);\n\n\t/**\n\t * Returns the zone to its resting state and clears the native input so the\n\t * same file can be chosen again.\n\t */\n\tconst reset = React.useCallback(() => {\n\t\tdragDepth.current = 0;\n\t\tsetIsDragging(false);\n\t\tsetSelectedName(null);\n\t\tsetValidationError(null);\n\t\tif (inputRef.current) inputRef.current.value = '';\n\t}, []);\n\n\tconst handleBrowse = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tinputRef.current?.click();\n\t}, [isDisabled]);\n\n\tconst handleCancel = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tshouldRestoreFocus.current = true;\n\t\ttrackInteraction({ action: 'click', metadata: { control: 'cancel' } });\n\t\treset();\n\t\tonCancel?.();\n\t}, [isDisabled, onCancel, reset, trackInteraction]);\n\n\tconst handleRemove = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tshouldRestoreFocus.current = true;\n\t\ttrackInteraction({ action: 'clear', metadata: { control: 'remove' } });\n\t\treset();\n\t\tonRemove?.();\n\t}, [isDisabled, onRemove, reset, trackInteraction]);\n\n\tconst handleDragEnter = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current += 1;\n\t\t\tsetIsDragging(true);\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDragOver = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\t// Required, or the browser treats the drop as navigation and opens the file.\n\t\t\tevent.preventDefault();\n\t\t\tevent.dataTransfer.dropEffect = 'copy';\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDragLeave = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current = Math.max(0, dragDepth.current - 1);\n\t\t\t// Leaving without dropping restores the previous view rather than resetting,\n\t\t\t// so a completed or errored zone is not cleared by a passing cursor.\n\t\t\tif (dragDepth.current === 0) setIsDragging(false);\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDrop = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current = 0;\n\t\t\tsetIsDragging(false);\n\t\t\tacceptFile(event.dataTransfer.files?.[0], 'drop');\n\t\t},\n\t\t[acceptFile, isDisabled, isBusy]\n\t);\n\n\tconst handleInputChange = React.useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tconst file = event.target.files?.[0];\n\t\t\t// Cleared before validating: the native control fires `change` only when\n\t\t\t// the selection changes, so re-picking a corrected file would be silent.\n\t\t\tevent.target.value = '';\n\t\t\tacceptFile(file, 'browse');\n\t\t},\n\t\t[acceptFile]\n\t);\n\n\tconst view = isDragging ? 'dragging' : effectiveState;\n\n\t/*\n\t * Each view renders its action button at a different position inside the zone,\n\t * so React unmounts one and mounts another rather than reusing it, and the\n\t * browser drops focus to the body — sending a keyboard user back to the top of\n\t * the page mid-task. Hand focus to the button that replaced it, but only when\n\t * it was genuinely lost: never take it from someone who has tabbed away.\n\t */\n\tReact.useLayoutEffect(() => {\n\t\tif (!shouldRestoreFocus.current) return;\n\n\t\tconst focusWasLost = !document.activeElement || document.activeElement === document.body;\n\t\tshouldRestoreFocus.current = false;\n\n\t\tif (focusWasLost) {\n\t\t\tactionRef.current?.focus();\n\t\t\t// Focus is inside the zone again, so keep the chain armed for the next\n\t\t\t// swap — an upload the consumer completes on its own included.\n\t\t\tshouldRestoreFocus.current = true;\n\t\t}\n\t}, [view]);\n\n\t/* eslint-disable sort-keys */\n\tconst zoneClasses = classnames({\n\t\t[styles['MrlFileUpload-zone']]: true,\n\t\t'MrlFileUpload-zone': true,\n\t\t[styles[`MrlFileUpload-zone--${view}`]]: view !== 'idle'\n\t});\n\t/* eslint-enable sort-keys */\n\n\tconst inlineKind = resolvedError ? 'error' : 'helper';\n\tconst inlineMessage = resolvedError ?? (showInlineAlert ? resolvedHelperText : null);\n\n\tconst announcement = () => {\n\t\tif (effectiveState === 'uploading') {\n\t\t\t// Quantised to 10% steps. A live region queues announcements rather than\n\t\t\t// replacing them, so narrating every tick buries 'upload successful'\n\t\t\t// behind a backlog that is usually discarded before it is spoken.\n\t\t\tconst step = Math.floor(Math.round(percent) / 10) * 10;\n\t\t\treturn `Uploading ${displayName}, ${step}%`;\n\t\t}\n\t\tif (effectiveState === 'complete') return `Upload of ${displayName} successful`;\n\t\tif (effectiveState === 'error' && resolvedError) {\n\t\t\t// Prefixed with the file name so two failures for the same reason are two\n\t\t\t// different strings: a live region re-set to the same text stays silent.\n\t\t\treturn displayName ? `${displayName}: ${resolvedError}` : resolvedError;\n\t\t}\n\t\treturn '';\n\t};\n\n\tconst restingContent = (\n\t\t<>\n\t\t\t<div className={classnames(styles['MrlFileUpload-content'], 'MrlFileUpload-content')}>\n\t\t\t\t<p className={classnames(styles['MrlFileUpload-heading'], 'MrlFileUpload-heading')}>\n\t\t\t\t\t{heading}\n\t\t\t\t</p>\n\t\t\t\t{showHelperText && resolvedHelperText && (\n\t\t\t\t\t<MrlText size=\"small\">{resolvedHelperText}</MrlText>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<MrlButton\n\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\tkind=\"secondary\"\n\t\t\t\tref={actionRef}\n\t\t\t\tsize=\"small\"\n\t\t\t\tstate={isDisabled ? 'disabled' : 'default'}\n\t\t\t\ttext=\"Browse files\"\n\t\t\t\tonClick={handleBrowse}\n\t\t\t/>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tdata-qa={dataQa}\n\t\t\tclassName={classnames(styles['MrlFileUpload'], 'MrlFileUpload', className)}\n\t\t>\n\t\t\t{label && (\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(styles['MrlFileUpload-label'], 'MrlFileUpload-label')}\n\t\t\t\t\tid={labelId}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t)}\n\n\t\t\t<div\n\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\taria-disabled={isDisabled || undefined}\n\t\t\t\taria-label={label ? undefined : heading}\n\t\t\t\taria-labelledby={label ? labelId : undefined}\n\t\t\t\tclassName={zoneClasses}\n\t\t\t\trole=\"group\"\n\t\t\t\tonDragEnter={handleDragEnter}\n\t\t\t\tonDragLeave={handleDragLeave}\n\t\t\t\tonDragOver={handleDragOver}\n\t\t\t\tonDrop={handleDrop}\n\t\t\t>\n\t\t\t\t{(view === 'idle' || view === 'error' || view === 'disabled') && restingContent}\n\n\t\t\t\t{view === 'dragging' && (\n\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon'],\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon--accent']\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\t\tsvg={importIcon}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--accent']\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tDrop your files\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\n\t\t\t\t{view === 'uploading' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-progress'])}>\n\t\t\t\t\t\t\t\t<MrlProgressBar\n\t\t\t\t\t\t\t\t\tname={`Uploading ${displayName || 'file'}`}\n\t\t\t\t\t\t\t\t\tpercent={Math.round(percent) as ProgressRange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--strong']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tUploading {displayName}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\t\t\t\tkind=\"secondary\"\n\t\t\t\t\t\t\tref={actionRef}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ttext=\"Cancel\"\n\t\t\t\t\t\t\tonClick={handleCancel}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\n\t\t\t\t{view === 'complete' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon--success']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\t\t\tsvg={check}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--strong']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tUpload of {displayName} successful!\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\t\t\t\tkind=\"secondary\"\n\t\t\t\t\t\t\tref={actionRef}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ttext=\"Remove\"\n\t\t\t\t\t\t\tonClick={handleRemove}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{inlineMessage && (\n\t\t\t\t<MrlInlineMessage id={messageId} kind={inlineKind} message={inlineMessage} />\n\t\t\t)}\n\n\t\t\t{/*\n\t\t\t * The real control, opened by the \"Browse files\" button. It is removed from\n\t\t\t * the tab order and the accessibility tree deliberately: the button is the\n\t\t\t * accessible affordance, and a focusable invisible input would be a keyboard\n\t\t\t * trap with no visible focus ring. Do not make it focusable.\n\t\t\t */}\n\t\t\t<input\n\t\t\t\taccept={accept || undefined}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tclassName={classnames(styles['MrlFileUpload-input'])}\n\t\t\t\tdisabled={isDisabled}\n\t\t\t\tref={inputRef}\n\t\t\t\ttabIndex={-1}\n\t\t\t\ttype=\"file\"\n\t\t\t\tonChange={handleInputChange}\n\t\t\t/>\n\n\t\t\t<MrlLiveRegion ariaLive=\"polite\" srContent={announcement()} />\n\t\t</div>\n\t);\n}\n"],"names":["MrlFileUpload","props","_ref","_props$accept","accept","fileUploadDefaults","className","errorMessage","eventId","fileName","_props$heading","heading","helperText","label","maxSizeBytes","onCancel","onError","onFilesSelected","onRemove","_props$percent","percent","_props$showHelperText","showHelperText","_props$showInlineAler","showInlineAlert","_props$state","state","validate","dataQa","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","isDragging","setIsDragging","_React$useState3","_React$useState4","validationError","setValidationError","_React$useState5","_React$useState6","selectedName","setSelectedName","inputRef","useRef","actionRef","shouldRestoreFocus","dragDepth","reactId","useId","labelId","concat","messageId","trackInteraction","useMrlTrackInteraction","isDisabled","effectiveState","displayName","displayError","resolvedError","DEFAULT_ERROR_MESSAGE","resolvedHelperText","describeConstraints","isBusy","acceptFile","useCallback","file","source","rejection","isAccepted","types","formatAcceptList","undefined","size","formatBytes","_validate","action","metadata","outcome","name","current","reset","value","handleBrowse","_inputRef$current","click","handleCancel","control","handleRemove","handleDragEnter","event","preventDefault","handleDragOver","dataTransfer","dropEffect","handleDragLeave","Math","max","handleDrop","_event$dataTransfer$f","files","handleInputChange","_event$target$files","target","view","useLayoutEffect","focusWasLost","document","activeElement","body","_actionRef$current","focus","zoneClasses","classnames","styles","inlineKind","inlineMessage","announcement","step","floor","round","restingContent","createElement","Fragment","MrlText","MrlButton","kind","ref","text","onClick","_extends","id","role","onDragEnter","onDragLeave","onDragOver","onDrop","MrlSvg","svg","importIcon","MrlProgressBar","check","MrlInlineMessage","message","disabled","tabIndex","type","onChange","MrlLiveRegion","ariaLive","srContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA;AACA;AACA;;AAuBA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAACC,KAAyB,EAAsB;AAAA,EAAA,IAAAC,IAAA;AAC5E,EAAA,IAAAC,aAAA,GAqBIF,KAAK,CApBRG,MAAM;AAANA,IAAAA,MAAM,GAAAD,aAAA,KAAA,MAAA,GAAGE,4BAAkB,CAACD,MAAM,GAAAD,aAAA;IAClCG,SAAS,GAmBNL,KAAK,CAnBRK,SAAS;IACTC,YAAY,GAkBTN,KAAK,CAlBRM,YAAY;IACZC,OAAO,GAiBJP,KAAK,CAjBRO,OAAO;IACPC,QAAQ,GAgBLR,KAAK,CAhBRQ,QAAQ;IAAAC,cAAA,GAgBLT,KAAK,CAfRU,OAAO;AAAPA,IAAAA,OAAO,GAAAD,cAAA,KAAA,MAAA,GAAGL,4BAAkB,CAACM,OAAO,GAAAD,cAAA;IACpCE,UAAU,GAcPX,KAAK,CAdRW,UAAU;IACVC,KAAK,GAaFZ,KAAK,CAbRY,KAAK;IACLC,YAAY,GAYTb,KAAK,CAZRa,YAAY;IACZC,QAAQ,GAWLd,KAAK,CAXRc,QAAQ;IACRC,OAAO,GAUJf,KAAK,CAVRe,OAAO;IACPC,eAAe,GASZhB,KAAK,CATRgB,eAAe;IACfC,QAAQ,GAQLjB,KAAK,CARRiB,QAAQ;IAAAC,cAAA,GAQLlB,KAAK,CAPRmB,OAAO;AAAPA,IAAAA,OAAO,GAAAD,cAAA,KAAA,MAAA,GAAG,CAAC,GAAAA,cAAA;IAAAE,qBAAA,GAORpB,KAAK,CANRqB,cAAc;AAAdA,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jC,YAAY;AAAG,GAAE,CACzD,CAAC;AAER;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MrlMenu.js","sources":["../../../../../src/components/menu/MrlMenu/MrlMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MrlPortal, PortalProps } from '../../portal/MrlPortal';\nimport { useTriggerPosition } from '../../../hooks/useTriggerPosition';\nimport { useClickOutside } from '../../../hooks/useClickOutside';\nimport { useSubMenuElementPosition } from '../hooks/useSubMenuElementPosition';\nimport {\n\tMenuPosition,\n\tMenuAlignment,\n\tActionState,\n\tActionType,\n\tCustomMenuPosition\n} from '../constants';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport {\n\tfindAdjacentInteractiveElement,\n\tpreventDefault,\n\tisElementAriaDisabled\n} from '../../../utils';\nimport classnames from 'classnames';\nimport { MrlMenuContext } from '../context/MrlMenuContext';\nimport styles from './MrlMenu.module.scss';\nimport itemStyles from '../MrlMenuItem/MrlMenuItem.module.scss';\nimport { useTransition, animated } from '@react-spring/web';\nimport { isTouchDevice } from '../../../utils/isTouch';\nimport { getScrollableParent } from '../utilities/get-scrollable-parent';\nimport { useMenuScroll } from '../hooks/useMenuScroll';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport interface MrlMenuProps {\n\t/** Custom position for the menu */\n\tcustomPosition?: CustomMenuPosition;\n\n\t/** Children to be rendered within the menu component*/\n\tchildren: React.ReactNode;\n\n\t/** Event to close the menu */\n\tclickOutsideEvent?: 'mousedown' | 'mouseup' | 'click';\n\n\t/**\n\t * Enables closing the menu when scrolling. Default is false.\n\t *\n\t */\n\tcloseOnScroll?: boolean;\n\n\t/**\n\t * Private closeParent prop for use with MrlMenuItem\n\t *\n\t * !!! Please do not use this prop directly, it is only used internally by MrlMenuItem !!!\n\t * @private\n\t */\n\tcloseParent?: () => void;\n\n\t/**\n\t * Disable arrows from opening the menu\n\t * - This is useful when you want to disable the default browser behavior of opening a menu on arrow down.\n\t *\n\t * Example usage: the menu is within a vertical toolbar and you want to use the arrow keys to navigate the toolbar.\n\t * By using this prop you can disable the arrow key open/close so that navigating the toolbar does not conflict\n\t * with opening/closing the menu.\n\t */\n\tdisableArrowOpen?: boolean;\n\n\t/**\n\t * Disable flipping of the menu when it goes off the screen\n\t * @default false\n\t */\n\tdisableFlipping?: boolean;\n\n\t/** Unique identifier for the menu */\n\tid?: string;\n\n\t/**\n\t * Use when the menu is embedded within another component\n\t * Removes the following styles:\n\t * - padding on the menu\n\t * - drop shadow and border\n\t * @default false\n\t */\n\tisInternal?: boolean;\n\n\t/**\n\t * Private isSubMenu prop for use with MrlMenuItem\n\t *\n\t * !!! Please do not use this prop directly, it is only used internally by MrlMenuItem !!!\n\t * @private\n\t */\n\tisSubMenu?: boolean;\n\n\t/**\n\t * spacing of menu\n\t * - compact has less padding\n\t * @default 'default'\n\t */\n\tspacing?: 'default' | 'compact';\n\n\t/**\n\t * Offset of the menu from the trigger element in pixels\n\t * @default 10px\n\t */\n\tmenuOffset?: number;\n\n\t/**\n\t * Configuration for the portal component\n\t */\n\tportalProps?: Omit<PortalProps, 'children'>;\n\n\t/**\n\t * Horizontal and vertical alignment of the menu relative to the trigger element\n\t * - position 'left', 'right', 'top', 'bottom' position relative to the trigger\n\t * - position 'static' renders the menu in place, not using the portal\n\t * - position 'ignore' will not position the menu, allowing you to use the customPosition prop to position the element\n\t * @default 'bottom'\n\t */\n\tposition?: MenuPosition;\n\n\t/**\n\t * Set initial state of menu\n\t * @default { actionType: null, isOpen: false }\n\t */\n\tactionState?: ActionState;\n\n\t/**\n\t * Reference to the DOM element that triggers this menu.\n\t */\n\ttriggerRef?: React.RefObject<HTMLButtonElement>;\n\n\t/**\n\t * Trigger stop propagation on click\n\t *\n\t * In some instances we may want the trigger element to stop propogation to the\n\t * rest of the DOM. Use this flag to enable and disable it.\n\t * @default false\n\t */\n\ttriggerStopPropagation?: boolean;\n\n\t/**\n\t * Vertical and horizontal alignment of the menu relative to the position of the menu with the trigger\n\t * - 'left' and 'right' work with position 'top' and 'bottom'\n\t * - 'top' and 'bottom' work with position 'left' and 'right'\n\t * - 'center' works with all positions\n\t *\n\t * This does not impact submenus\n\t */\n\talignment?: MenuAlignment;\n\n\t/**\n\t * Callback to be called when the menu is closed\n\t * @param type - type of close event\n\t */\n\tonClose?: (type?: string) => void;\n\n\t/**\n\t * Enables interaction tracking for this menu. Provide a stable, non-PII id\n\t * (e.g. 'mural-context-menu'). When omitted, the menu emits no analytics.\n\t */\n\teventId?: string;\n}\n\nconst MENU_ITEM_SELECTOR = '[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]';\n\n/**\n * MrlMenu component\n *\n * Renders a menu component with alignment relative to a trigger element\n * @param {MrlMenuProps} props - The props for the MrlMenu component\n * @returns {Element} - rendered MrlMenu component\n */\nexport function MrlMenu({\n\tactionState = { actionType: null, isOpen: false },\n\talignment = 'center',\n\tchildren,\n\tcloseOnScroll = false,\n\tcloseParent,\n\tcustomPosition,\n\tclickOutsideEvent = 'mouseup',\n\tdisableArrowOpen,\n\tdisableFlipping = false,\n\tid,\n\tisInternal = false,\n\tisSubMenu = false,\n\tspacing = 'default',\n\tmenuOffset = 10,\n\tportalProps = { id: PORTAL_LAYERS.MENU.name },\n\tposition = 'bottom',\n\ttriggerStopPropagation = false,\n\tonClose,\n\teventId,\n\ttriggerRef,\n\t...remainingProps\n}: MrlMenuProps): JSX.Element {\n\tconst defaultOpenState = position === 'static' || false;\n\n\tconst [state, setState] = React.useState({\n\t\tactionType: null,\n\t\tisOpen: defaultOpenState\n\t} as ActionState);\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlMenu', eventId);\n\t// the menu opens and closes from several paths (click, keyboard, hover, click outside),\n\t// so open/close is emitted from the resulting state rather than each individual handler.\n\tconst wasOpenRef = React.useRef(defaultOpenState);\n\n\tReact.useEffect(() => {\n\t\tif (wasOpenRef.current === state.isOpen) return;\n\n\t\twasOpenRef.current = state.isOpen;\n\n\t\ttrackInteraction({\n\t\t\taction: state.isOpen ? 'open' : 'close',\n\t\t\tmetadata: { isSubMenu, trigger: state.actionType ?? 'unknown' },\n\t\t\tvariant: position\n\t\t});\n\t}, [state.isOpen, state.actionType, isSubMenu, position, trackInteraction]);\n\n\tconst menuRef = React.useRef<HTMLDivElement>(null);\n\tconst listRef = React.useRef<HTMLUListElement>(null);\n\tconst [menuItems, setMenuItems] = React.useState<HTMLButtonElement[]>([]);\n\tconst [menuRect, setMenuRect] = React.useState<DOMRect | null>(null);\n\n\t/**\n\t * Checks if the trigger element is disabled\n\t * @returns {boolean} - true if the trigger element is disabled, false otherwise\n\t */\n\tconst isTriggerDisabled = React.useCallback((): boolean => {\n\t\treturn isElementAriaDisabled(triggerRef?.current);\n\t}, [triggerRef]);\n\n\t/**\n\t * Sets up trigger event listeners to open and close the menu\n\t * @param e - mouse event\n\t */\n\tconst toggleMenuTrigger = React.useCallback(\n\t\t(e: MouseEvent) => {\n\t\t\tif (isTriggerDisabled()) return;\n\n\t\t\tif (triggerStopPropagation) {\n\t\t\t\tpreventDefault(e);\n\t\t\t}\n\n\t\t\tsetState((prevState) => ({ actionType: 'click', isOpen: !prevState.isOpen }));\n\t\t},\n\t\t[triggerStopPropagation, isTriggerDisabled]\n\t);\n\n\t/**\n\t * Used to display the menu when hovering over a menu item that has a submenu\n\t */\n\tconst showMenuHover = React.useCallback(() => {\n\t\tsetState({ actionType: 'click', isOpen: true });\n\t}, []);\n\n\tconst showMenuTap = React.useCallback(() => {\n\t\tsetState((prevState) => ({ actionType: 'click', isOpen: !prevState.isOpen }));\n\t}, []);\n\n\tconst hideMenuHover = React.useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tconst relatedTarget = event.relatedTarget as Node;\n\n\t\t\t// If the related target is not a child of the menu, close the menu\n\t\t\t// This prevents the menu from closing when hovering over a submenu item or trigger\n\t\t\tif (\n\t\t\t\ttriggerRef &&\n\t\t\t\tmenuRef.current &&\n\t\t\t\t!menuRef.current.contains(relatedTarget) &&\n\t\t\t\ttriggerRef.current &&\n\t\t\t\t!triggerRef.current.contains(relatedTarget)\n\t\t\t) {\n\t\t\t\tsetState({ actionType: null, isOpen: false });\n\t\t\t}\n\t\t},\n\t\t[triggerRef]\n\t);\n\n\t/**\n\t * Sets up trigger event listeners to open and close the menu with a keyboard\n\t */\n\tconst toggleMenuKey = React.useCallback(\n\t\t(e: KeyboardEvent) => {\n\t\t\tconst openMenu = () => {\n\t\t\t\tif (isTriggerDisabled()) return;\n\t\t\t\tsetState({ actionType: e.key as ActionType, isOpen: true });\n\t\t\t};\n\n\t\t\tif (!state.isOpen) {\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\tswitch (e.key) {\n\t\t\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\t\tcase 'Enter':\n\t\t\t\t\t\tcase ' ':\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\topenMenu();\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tswitch (e.key) {\n\t\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\t\tif (!disableArrowOpen && !isTriggerDisabled()) {\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\topenMenu();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Enter':\n\t\t\t\t\tcase ' ':\n\t\t\t\t\t\tif (isTriggerDisabled()) return;\n\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\topenMenu();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[state.isOpen, isTriggerDisabled, disableArrowOpen, isSubMenu]\n\t);\n\n\tconst closeMenu = React.useCallback(\n\t\t(shouldCloseParent = true) => {\n\t\t\tif (position === 'static') return;\n\n\t\t\t/**\n\t\t\t * What is closeParent?\n\t\t\t *\n\t\t\t * It is passed from the context provider to the MenuItem (which helps render our submenus)\n\t\t\t * When we render the submenu, we pass the closeMenu function as \"closeParent\" to the submenu.\n\t\t\t * This allows us to trigger closing the parent menu when the submenu is closed. And that's\n\t\t\t * what this call is for.\n\t\t\t */\n\t\t\tif (shouldCloseParent && closeParent) closeParent();\n\n\t\t\tsetState({ actionType: null, isOpen: false });\n\t\t\tonClose?.();\n\t\t},\n\t\t[position, closeParent, onClose]\n\t);\n\n\t/**\n\t * Click outside to dismiss the menu\n\t * @param e\n\t */\n\tconst disableClickOutside = !state.isOpen || position === 'static';\n\tuseClickOutside(menuRef, triggerRef, clickOutsideEvent, closeMenu, disableClickOutside);\n\n\tconst handleMenuKeyUp = (e: React.KeyboardEvent) => {\n\t\tconst actions: ActionType[] = ['ArrowUp', 'ArrowDown', 'ArrowRight', 'Enter', 'Escape', ' '];\n\n\t\tif (actions.includes(e.key as ActionType)) {\n\t\t\tpreventDefault(e);\n\t\t}\n\t};\n\n\t/**\n\t * Focus management when someone is using a keyboard to navigate the menu\n\t * @param e - keyboard event\n\t */\n\tconst handleMenuKey = (e: React.KeyboardEvent) => {\n\t\tconst currentIndex = menuItems.findIndex((item) => document.activeElement === item);\n\t\tlet nextIndex: number;\n\n\t\tif (state.isOpen) {\n\t\t\tswitch (e.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tnextIndex = currentIndex < menuItems.length - 1 ? currentIndex + 1 : currentIndex;\n\t\t\t\t\tmenuItems[nextIndex]?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tnextIndex = currentIndex > 0 ? currentIndex - 1 : 0;\n\t\t\t\t\tmenuItems[nextIndex]?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Escape':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\ttriggerRef?.current?.focus();\n\t\t\t\t\tcloseMenu(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Tab':\n\t\t\t\t\tif (!isSubMenu && position !== 'static') {\n\t\t\t\t\t\tif (e.shiftKey) {\n\t\t\t\t\t\t\t// Handle shift + tab: move focus to the previous item\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\tif (triggerRef) {\n\t\t\t\t\t\t\t\tconst prevElement = findAdjacentInteractiveElement(triggerRef, 'previous');\n\t\t\t\t\t\t\t\tprevElement?.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Regular tab: close the menu or move to the next item\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\tif (triggerRef) {\n\t\t\t\t\t\t\t\tconst nextElement = findAdjacentInteractiveElement(triggerRef);\n\t\t\t\t\t\t\t\tnextElement?.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcloseMenu();\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * useEffect hooks to handle menu state changes\n\t */\n\n\tReact.useEffect(() => {\n\t\tif (triggerRef?.current) {\n\t\t\ttriggerRef.current.setAttribute('aria-haspopup', 'menu');\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\tReact.useEffect(() => {\n\t\tif (position === 'static') {\n\t\t\tsetState({ actionType: 'click', isOpen: true });\n\t\t}\n\t}, [position]);\n\n\tReact.useEffect(() => {\n\t\ttriggerRef?.current?.setAttribute('aria-expanded', state.isOpen.toString());\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen]);\n\n\tReact.useEffect(() => {\n\t\tif (!isSubMenu && position !== 'static')\n\t\t\tsetState({ actionType: actionState.actionType, isOpen: actionState.isOpen });\n\t}, [actionState.isOpen, actionState.actionType, isSubMenu, position]);\n\n\t// setup event handlers for mouse, keyboard, and scroll interactions\n\tReact.useEffect(() => {\n\t\tconst triggerElement = triggerRef?.current;\n\t\tconst menuElement = menuRef?.current;\n\t\tconst menuItems = menuElement?.querySelectorAll(MENU_ITEM_SELECTOR);\n\n\t\tlet scrollableParent: HTMLElement | Window;\n\n\t\tif (triggerElement) {\n\t\t\ttriggerElement.addEventListener('mousedown', preventDefault);\n\t\t\tif (!isSubMenu) triggerElement.addEventListener('click', toggleMenuTrigger);\n\t\t\ttriggerElement.addEventListener('keydown', toggleMenuKey);\n\n\t\t\t// Setup event listeners for when the menu is a submenu\n\t\t\tif (isSubMenu) {\n\t\t\t\ttriggerElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\ttriggerElement.addEventListener('mouseout', hideMenuHover);\n\n\t\t\t\tif (isTouchDevice()) {\n\t\t\t\t\ttriggerElement.addEventListener('touchend', showMenuTap);\n\t\t\t\t}\n\n\t\t\t\tif (menuElement) {\n\t\t\t\t\tmenuElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\t\tmenuElement.addEventListener('mouseout', hideMenuHover);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (closeOnScroll) {\n\t\t\t\tscrollableParent = getScrollableParent(triggerElement);\n\t\t\t\tif (scrollableParent) {\n\t\t\t\t\tscrollableParent.addEventListener('scroll', () => closeMenu(), {\n\t\t\t\t\t\tcapture: true,\n\t\t\t\t\t\tpassive: true\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\ttriggerElement.removeEventListener('mousedown', preventDefault);\n\t\t\t\tif (!isSubMenu) triggerElement.removeEventListener('click', toggleMenuTrigger);\n\t\t\t\ttriggerElement.removeEventListener('keydown', toggleMenuKey);\n\n\t\t\t\tif (menuItems) {\n\t\t\t\t\tmenuItems.forEach((item: Element) => {\n\t\t\t\t\t\tif (!item.getAttribute('aria-haspopup')) {\n\t\t\t\t\t\t\titem.removeEventListener('mousedown', () => closeMenu());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\ttriggerElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\ttriggerElement.removeEventListener('mouseout', hideMenuHover);\n\n\t\t\t\t\tif (isTouchDevice()) {\n\t\t\t\t\t\ttriggerElement.removeEventListener('touchstart', showMenuHover);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (menuElement) {\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseout', hideMenuHover);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (closeOnScroll && scrollableParent) {\n\t\t\t\t\tscrollableParent.removeEventListener('scroll', () => closeMenu());\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}, [\n\t\tcloseOnScroll,\n\t\tisSubMenu,\n\t\ttriggerRef,\n\t\ttoggleMenuTrigger,\n\t\ttoggleMenuKey,\n\t\tshowMenuHover,\n\t\thideMenuHover,\n\t\tcloseMenu,\n\t\tshowMenuTap\n\t]);\n\n\t// This use effect handles a few things when we open the menu:\n\t// - making sure that the menu component is aware of it's menu items\n\t// - adding a class to the trigger element when the submenu is open for styling\n\t// - storing the menu rect in state for positioning calculations\n\tReact.useEffect(() => {\n\t\tif (state.isOpen) {\n\t\t\tconst foundMenuItems = Array.from(\n\t\t\t\tmenuRef.current?.querySelectorAll(MENU_ITEM_SELECTOR) || []\n\t\t\t) as HTMLButtonElement[];\n\n\t\t\tsetMenuItems(foundMenuItems);\n\t\t}\n\n\t\tif (state.isOpen && isSubMenu) {\n\t\t\ttriggerRef?.current?.classList.add(itemStyles['MrlMenuItem--item--submenuOpen']);\n\t\t} else if (!state.isOpen && isSubMenu) {\n\t\t\ttriggerRef?.current?.classList.remove(itemStyles['MrlMenuItem--item--submenuOpen']);\n\t\t}\n\n\t\t// For consistent submenu calculations, we are storing the menu rect in state\n\t\t// Anytime we need to use the menu rect, we want to make sure the values are based\n\t\t// on the original state of the menu for proper transformations\n\t\tif (!menuRect && menuRef.current) {\n\t\t\tconst newRect = menuRef.current?.getBoundingClientRect();\n\t\t\tsetMenuRect(newRect || null);\n\t\t}\n\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, menuRect, isSubMenu]);\n\n\t/**\n\t * Focus management for when the menu is opening or closing\n\t */\n\tReact.useEffect(() => {\n\t\tif (menuItems.length > 0) {\n\t\t\tlet menuItemToFocus;\n\n\t\t\tswitch (state.actionType) {\n\t\t\t\tcase 'Enter':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\tcase ' ':\n\t\t\t\t\tmenuItemToFocus = menuItems[0];\n\t\t\t\t\tmenuItemToFocus?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tmenuItemToFocus = menuItems[menuItems.length - 1];\n\t\t\t\t\tmenuItemToFocus?.focus();\n\n\t\t\t\t\t// Scroll to the bottom of the menu when the last item is focused\n\t\t\t\t\t// setTimeout is required to ensure the element has been rendered\n\t\t\t\t\t// and the scrollHeight is accurate prior to scrolling\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tif (listRef.current) {\n\t\t\t\t\t\t\tlistRef.current.scrollTo(0, listRef.current.scrollHeight);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 20);\n\t\t\t}\n\n\t\t\tif (isSubMenu && state.actionType === 'ArrowRight') {\n\t\t\t\tmenuItemToFocus = menuItems[0];\n\t\t\t\tmenuItemToFocus?.focus();\n\t\t\t}\n\t\t}\n\t}, [isSubMenu, menuItems, state.actionType]);\n\n\t/**\n\t * Menu scroll behavior\n\t *\n\t * When the menu cannot fit in the preferred or flipped position,\n\t * this hook constrains the menu height and enables internal scrolling.\n\t * Called before useTriggerPosition so that isScrolling can disable flipping,\n\t * preventing the positioning hook from fighting the scroll constraint.\n\t */\n\tconst disableMenuScroll =\n\t\tisSubMenu || !state.isOpen || position === 'static' || position === 'ignore';\n\n\t/**\n\t * Sets overflow (scrolling) on menu when there is no space to display\n\t * the menu in the preferred or flipped position.\n\t */\n\tconst menuScroll = useMenuScroll(\n\t\ttriggerRef,\n\t\tlistRef,\n\t\tposition,\n\t\tmenuOffset,\n\t\tstate.isOpen,\n\t\tdisableMenuScroll\n\t);\n\n\t/**\n\t * Primary menu positioning, alignment, and transition styling\n\t *\n\t * This hook is only enabled if isSubMenu is FALSE\n\t */\n\tconst disableTriggerPosition = isSubMenu || !state.isOpen || position === 'static';\n\tconst menuPositionStyles = useTriggerPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\t{\n\t\t\talign: alignment,\n\t\t\tcustomPosition: customPosition,\n\t\t\tposition: position\n\t\t},\n\t\tstate.isOpen,\n\t\tmenuOffset,\n\t\tdisableTriggerPosition,\n\t\tdisableFlipping || menuScroll.isScrolling\n\t);\n\n\t/**\n\t * Submenu positioning and alignment\n\t *\n\t * This hook is only enabled if isSubMenu is TRUE\n\t */\n\tconst subMenuPosition = useSubMenuElementPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\tisSubMenu,\n\t\tstate.isOpen,\n\t\tmenuRect,\n\t\t// disable the subelement positioning if it's not a submenu\n\t\t!isSubMenu\n\t);\n\n\tconst inlineStyles = {\n\t\tmenu: {\n\t\t\tleft: menuPositionStyles.left,\n\t\t\tposition: 'fixed' as const,\n\t\t\ttop: menuPositionStyles.top\n\t\t},\n\t\tsubmenu: {\n\t\t\tleft: subMenuPosition.left,\n\t\t\ttop: subMenuPosition.top\n\t\t}\n\t};\n\n\t/**\n\t * React Spring transitions for the menu\n\t */\n\tconst transitionConfig = {\n\t\tconfig: { duration: state.isOpen ? 300 : 150 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' },\n\t\tfrom: { opacity: 0, transform: 'translateY(4px)' },\n\t\tleave: { opacity: 0, transform: 'translateY(4px)' }\n\t};\n\n\tconst transitionStatic = {\n\t\tconfig: { duration: 0 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' }\n\t};\n\n\tconst transitions = useTransition(\n\t\tstate.isOpen,\n\t\tposition === 'static' ? transitionStatic : transitionConfig\n\t);\n\n\tconst menuClasses = classnames(styles['MrlMenu'], 'MrlMenu', {\n\t\t[styles['MrlMenu--submenu']]: isSubMenu,\n\t\t[styles.open]: state.isOpen,\n\t\t[styles['MrlMenu--compact']]: spacing === 'compact',\n\t\t[styles['MrlMenu--static']]: position === 'static',\n\t\t[styles['MrlMenu--internal']]: isInternal,\n\t\t[styles['MrlMenu--scrolling']]: menuScroll.isScrolling,\n\t\t[styles['MrlMenu--ignore']]: position === 'ignore'\n\t});\n\n\tconst positionStyles = isSubMenu\n\t\t? inlineStyles.submenu\n\t\t: position !== 'static'\n\t\t\t? inlineStyles.menu\n\t\t\t: {};\n\n\tconst menuScrollStyles =\n\t\t(menuScroll.maxHeight !== undefined && { maxHeight: menuScroll.maxHeight }) || undefined;\n\n\tconst renderMenu = () => {\n\t\treturn (\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\n\t\t\t\t\t\t\t\tclassName={menuClasses}\n\t\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\t\tstyle={{ ...positionStyles, ...style }}\n\t\t\t\t\t\t\t\tonKeyUp={handleMenuKeyUp}\n\t\t\t\t\t\t\t\tonKeyDown={handleMenuKey}\n\t\t\t\t\t\t\t\tref={menuRef}\n\t\t\t\t\t\t\t\trole=\"none\"\n\t\t\t\t\t\t\t\t{...remainingProps}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ul ref={listRef} role=\"menu\" style={menuScrollStyles}>\n\t\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t\t</ul>\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</>\n\t\t);\n\t};\n\n\t// For managing and restoring focus to the original menu trigger\n\t// Ensures the triggerRef in context is always the parent triggerRef\n\tconst parentContext = React.useContext(MrlMenuContext);\n\tconst contextTriggerRef = isSubMenu ? parentContext?.triggerRef : triggerRef;\n\n\treturn (\n\t\t<MrlMenuContext.Provider\n\t\t\tvalue={{\n\t\t\t\tcloseMenu,\n\t\t\t\tcloseParent: !isSubMenu ? closeMenu : undefined,\n\t\t\t\ttriggerRef: contextTriggerRef\n\t\t\t}}\n\t\t>\n\t\t\t{isSubMenu || position === 'static' ? (\n\t\t\t\trenderMenu()\n\t\t\t) : (\n\t\t\t\t<MrlPortal layer={portalProps.layer || PORTAL_LAYERS.MENU} {...portalProps}>\n\t\t\t\t\t{renderMenu()}\n\t\t\t\t</MrlPortal>\n\t\t\t)}\n\t\t</MrlMenuContext.Provider>\n\t);\n\t/* eslint-enable */\n}\n\nMrlMenu.componentType = 'Menu';\n"],"names":["MENU_ITEM_SELECTOR","MrlMenu","_ref","_ref$actionState","actionState","actionType","isOpen","_ref$alignment","alignment","children","_ref$closeOnScroll","closeOnScroll","closeParent","customPosition","_ref$clickOutsideEven","clickOutsideEvent","disableArrowOpen","_ref$disableFlipping","disableFlipping","id","_ref$isInternal","isInternal","_ref$isSubMenu","isSubMenu","_ref$spacing","spacing","_ref$menuOffset","menuOffset","_ref$portalProps","portalProps","PORTAL_LAYERS","MENU","name","_ref$position","position","_ref$triggerStopPropa","triggerStopPropagation","onClose","eventId","triggerRef","remainingProps","_objectWithoutProperties","_excluded","defaultOpenState","_React$useState","React","useState","_React$useState2","_slicedToArray","state","setState","trackInteraction","useMrlTrackInteraction","wasOpenRef","useRef","useEffect","_state$actionType","current","action","metadata","trigger","variant","menuRef","listRef","_React$useState3","_React$useState4","menuItems","setMenuItems","_React$useState5","_React$useState6","menuRect","setMenuRect","isTriggerDisabled","useCallback","isElementAriaDisabled","toggleMenuTrigger","e","preventDefault","prevState","showMenuHover","showMenuTap","hideMenuHover","event","relatedTarget","contains","toggleMenuKey","openMenu","key","closeMenu","shouldCloseParent","arguments","length","undefined","disableClickOutside","useClickOutside","handleMenuKeyUp","actions","includes","handleMenuKey","_menuItems$nextIndex","_menuItems$nextIndex2","_triggerRef$current","currentIndex","findIndex","item","document","activeElement","nextIndex","focus","shiftKey","prevElement","findAdjacentInteractiveElement","nextElement","setAttribute","_triggerRef$current2","toString","triggerElement","menuElement","querySelectorAll","scrollableParent","addEventListener","isTouchDevice","getScrollableParent","capture","passive","removeEventListener","forEach","getAttribute","_menuRef$current","foundMenuItems","Array","from","_triggerRef$current3","classList","add","itemStyles","_triggerRef$current4","remove","_menuRef$current2","newRect","getBoundingClientRect","_menuItemToFocus","_menuItemToFocus2","menuItemToFocus","setTimeout","scrollTo","scrollHeight","_menuItemToFocus3","disableMenuScroll","menuScroll","useMenuScroll","disableTriggerPosition","menuPositionStyles","useTriggerPosition","align","isScrolling","subMenuPosition","useSubMenuElementPosition","inlineStyles","menu","left","top","submenu","transitionConfig","config","duration","enter","opacity","transform","leave","transitionStatic","transitions","useTransition","menuClasses","classnames","styles","open","positionStyles","menuScrollStyles","maxHeight","renderMenu","createElement","Fragment","style","animated","div","_extends","className","_objectSpread","onKeyUp","onKeyDown","ref","role","parentContext","useContext","MrlMenuContext","contextTriggerRef","Provider","value","MrlPortal","layer","componentType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8JA,IAAMA,kBAAkB,GAAG,sEAAsE;;AAEjG;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAAAC,IAAA,EAsBO;AAAA,EAAA,IAAAC,gBAAA,GAAAD,IAAA,CArB7BE,WAAW;IAAXA,WAAW,GAAAD,gBAAA,KAAA,MAAA,GAAG;AAAEE,MAAAA,UAAU,EAAE,IAAI;AAAEC,MAAAA,MAAM,EAAE;AAAM,KAAC,GAAAH,gBAAA;IAAAI,cAAA,GAAAL,IAAA,CACjDM,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,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EAEL,CAAC;;AAED;AACA;AACA,EAAA,IAAMwL,aAAa,GAAGpJ,gBAAK,CAACqJ,UAAU,CAACC,6BAAc,CAAC;AACtD,EAAA,IAAMC,iBAAiB,GAAG7K,SAAS,GAAG0K,aAAa,KAAA,IAAA,IAAbA,aAAa,KAAA,MAAA,GAAA,MAAA,GAAbA,aAAa,CAAE1J,UAAU,GAAGA,UAAU;AAE5E,EAAA,oBACCM,gBAAA,CAAAwI,aAAA,CAACc,6BAAc,CAACE,QAAQ,EAAA;AACvBC,IAAAA,KAAK,EAAE;MACN9G,SAAS;AACT5E,MAAAA,WAAW,EAAE,CAACW,SAAS,GAAGiE,SAAS,GAAGI,SAAS;AAC/CrD,MAAAA,UAAU,EAAE6J;AACb;AAAE,GAAA,EAED7K,SAAS,IAAIW,QAAQ,KAAK,QAAQ,GAClCkJ,UAAU,EAAE,gBAEZvI,gBAAA,CAAAwI,aAAA,CAACkB,mBAAS,EAAAb,iCAAA,CAAA;AAACc,IAAAA,KAAK,EAAE3K,WAAW,CAAC2K,KAAK,IAAI1K,mBAAa,CAACC;AAAK,GAAA,EAAKF,WAAW,CAAA,EACxEuJ,UAAU,EACD,CAEY,CAAC;AAE3B;AACD;AAEAnL,OAAO,CAACwM,aAAa,GAAG,MAAM;;;;"}
1
+ {"version":3,"file":"MrlMenu.js","sources":["../../../../../src/components/menu/MrlMenu/MrlMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MrlPortal, PortalProps } from '../../portal/MrlPortal';\nimport { useTriggerPosition } from '../../../hooks/useTriggerPosition';\nimport { useClickOutside } from '../../../hooks/useClickOutside';\nimport { useSubMenuElementPosition } from '../hooks/useSubMenuElementPosition';\nimport {\n\tMenuPosition,\n\tMenuAlignment,\n\tActionState,\n\tActionType,\n\tCustomMenuPosition\n} from '../constants';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport {\n\tfindAdjacentInteractiveElement,\n\tpreventDefault,\n\tisElementAriaDisabled\n} from '../../../utils';\nimport classnames from 'classnames';\nimport { MrlMenuContext } from '../context/MrlMenuContext';\nimport styles from './MrlMenu.module.scss';\nimport itemStyles from '../MrlMenuItem/MrlMenuItem.module.scss';\nimport { useTransition, animated } from '@react-spring/web';\nimport { isTouchDevice } from '../../../utils/isTouch';\nimport { getScrollableParent } from '../utilities/get-scrollable-parent';\nimport { useMenuScroll } from '../hooks/useMenuScroll';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport interface MrlMenuProps {\n\t/** Custom position for the menu */\n\tcustomPosition?: CustomMenuPosition;\n\n\t/** Children to be rendered within the menu component*/\n\tchildren: React.ReactNode;\n\n\t/** Event to close the menu */\n\tclickOutsideEvent?: 'mousedown' | 'mouseup' | 'click';\n\n\t/**\n\t * Enables closing the menu when scrolling. Default is false.\n\t *\n\t */\n\tcloseOnScroll?: boolean;\n\n\t/**\n\t * Private closeParent prop for use with MrlMenuItem\n\t *\n\t * !!! Please do not use this prop directly, it is only used internally by MrlMenuItem !!!\n\t * @private\n\t */\n\tcloseParent?: () => void;\n\n\t/**\n\t * Disable arrows from opening the menu\n\t * - This is useful when you want to disable the default browser behavior of opening a menu on arrow down.\n\t *\n\t * Example usage: the menu is within a vertical toolbar and you want to use the arrow keys to navigate the toolbar.\n\t * By using this prop you can disable the arrow key open/close so that navigating the toolbar does not conflict\n\t * with opening/closing the menu.\n\t */\n\tdisableArrowOpen?: boolean;\n\n\t/**\n\t * Disable flipping of the menu when it goes off the screen\n\t * @default false\n\t */\n\tdisableFlipping?: boolean;\n\n\t/** Unique identifier for the menu */\n\tid?: string;\n\n\t/**\n\t * Use when the menu is embedded within another component\n\t * Removes the following styles:\n\t * - padding on the menu\n\t * - drop shadow and border\n\t * @default false\n\t */\n\tisInternal?: boolean;\n\n\t/**\n\t * Private isSubMenu prop for use with MrlMenuItem\n\t *\n\t * !!! Please do not use this prop directly, it is only used internally by MrlMenuItem !!!\n\t * @private\n\t */\n\tisSubMenu?: boolean;\n\n\t/**\n\t * spacing of menu\n\t * - compact has less padding\n\t * @default 'default'\n\t */\n\tspacing?: 'default' | 'compact';\n\n\t/**\n\t * Offset of the menu from the trigger element in pixels\n\t * @default 10px\n\t */\n\tmenuOffset?: number;\n\n\t/**\n\t * Configuration for the portal component\n\t */\n\tportalProps?: Omit<PortalProps, 'children'>;\n\n\t/**\n\t * Horizontal and vertical alignment of the menu relative to the trigger element\n\t * - position 'left', 'right', 'top', 'bottom' position relative to the trigger\n\t * - position 'static' renders the menu in place, not using the portal\n\t * - position 'ignore' will not position the menu, allowing you to use the customPosition prop to position the element\n\t * @default 'bottom'\n\t */\n\tposition?: MenuPosition;\n\n\t/**\n\t * Opens or closes the menu from outside. Not just an initial value: whenever\n\t * `isOpen` or `actionType` changes, the menu syncs its internal state to it.\n\t * The menu can still close itself (item select, click outside, Escape, Tab),\n\t * so pair this with `onClose` to reset your state. Prefer `triggerRef` when\n\t * there is a trigger element. Ignored for submenus and `position=\"static\"`.\n\t * @default { actionType: null, isOpen: false }\n\t */\n\tactionState?: ActionState;\n\n\t/**\n\t * Reference to the DOM element that triggers this menu. This alone wires up\n\t * click and keyboard open/close and the trigger's ARIA attributes; no\n\t * `actionState` or `onClick` toggle is needed.\n\t */\n\ttriggerRef?: React.RefObject<HTMLButtonElement>;\n\n\t/**\n\t * Trigger stop propagation on click\n\t *\n\t * In some instances we may want the trigger element to stop propogation to the\n\t * rest of the DOM. Use this flag to enable and disable it.\n\t * @default false\n\t */\n\ttriggerStopPropagation?: boolean;\n\n\t/**\n\t * Vertical and horizontal alignment of the menu relative to the position of the menu with the trigger\n\t * - 'left' and 'right' work with position 'top' and 'bottom'\n\t * - 'top' and 'bottom' work with position 'left' and 'right'\n\t * - 'center' works with all positions\n\t *\n\t * This does not impact submenus\n\t */\n\talignment?: MenuAlignment;\n\n\t/**\n\t * Called when the menu closes itself: item select, click outside, Escape, Tab,\n\t * or scroll with `closeOnScroll`. Not called when a trigger click toggles it closed.\n\t * @param type - type of close event\n\t */\n\tonClose?: (type?: string) => void;\n\n\t/**\n\t * Enables interaction tracking for this menu. Provide a stable, non-PII id\n\t * (e.g. 'mural-context-menu'). When omitted, the menu emits no analytics.\n\t */\n\teventId?: string;\n}\n\nconst MENU_ITEM_SELECTOR = '[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]';\n\n/**\n * MrlMenu component\n *\n * Renders a menu component with alignment relative to a trigger element\n * @param {MrlMenuProps} props - The props for the MrlMenu component\n * @returns {Element} - rendered MrlMenu component\n */\nexport function MrlMenu({\n\tactionState = { actionType: null, isOpen: false },\n\talignment = 'center',\n\tchildren,\n\tcloseOnScroll = false,\n\tcloseParent,\n\tcustomPosition,\n\tclickOutsideEvent = 'mouseup',\n\tdisableArrowOpen,\n\tdisableFlipping = false,\n\tid,\n\tisInternal = false,\n\tisSubMenu = false,\n\tspacing = 'default',\n\tmenuOffset = 10,\n\tportalProps = { id: PORTAL_LAYERS.MENU.name },\n\tposition = 'bottom',\n\ttriggerStopPropagation = false,\n\tonClose,\n\teventId,\n\ttriggerRef,\n\t...remainingProps\n}: MrlMenuProps): JSX.Element {\n\tconst defaultOpenState = position === 'static' || false;\n\n\tconst [state, setState] = React.useState({\n\t\tactionType: null,\n\t\tisOpen: defaultOpenState\n\t} as ActionState);\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlMenu', eventId);\n\t// the menu opens and closes from several paths (click, keyboard, hover, click outside),\n\t// so open/close is emitted from the resulting state rather than each individual handler.\n\tconst wasOpenRef = React.useRef(defaultOpenState);\n\n\tReact.useEffect(() => {\n\t\tif (wasOpenRef.current === state.isOpen) return;\n\n\t\twasOpenRef.current = state.isOpen;\n\n\t\ttrackInteraction({\n\t\t\taction: state.isOpen ? 'open' : 'close',\n\t\t\tmetadata: { isSubMenu, trigger: state.actionType ?? 'unknown' },\n\t\t\tvariant: position\n\t\t});\n\t}, [state.isOpen, state.actionType, isSubMenu, position, trackInteraction]);\n\n\tconst menuRef = React.useRef<HTMLDivElement>(null);\n\tconst listRef = React.useRef<HTMLUListElement>(null);\n\tconst [menuItems, setMenuItems] = React.useState<HTMLButtonElement[]>([]);\n\tconst [menuRect, setMenuRect] = React.useState<DOMRect | null>(null);\n\n\t/**\n\t * Checks if the trigger element is disabled\n\t * @returns {boolean} - true if the trigger element is disabled, false otherwise\n\t */\n\tconst isTriggerDisabled = React.useCallback((): boolean => {\n\t\treturn isElementAriaDisabled(triggerRef?.current);\n\t}, [triggerRef]);\n\n\t/**\n\t * Sets up trigger event listeners to open and close the menu\n\t * @param e - mouse event\n\t */\n\tconst toggleMenuTrigger = React.useCallback(\n\t\t(e: MouseEvent) => {\n\t\t\tif (isTriggerDisabled()) return;\n\n\t\t\tif (triggerStopPropagation) {\n\t\t\t\tpreventDefault(e);\n\t\t\t}\n\n\t\t\tsetState((prevState) => ({ actionType: 'click', isOpen: !prevState.isOpen }));\n\t\t},\n\t\t[triggerStopPropagation, isTriggerDisabled]\n\t);\n\n\t/**\n\t * Used to display the menu when hovering over a menu item that has a submenu\n\t */\n\tconst showMenuHover = React.useCallback(() => {\n\t\tsetState({ actionType: 'click', isOpen: true });\n\t}, []);\n\n\tconst showMenuTap = React.useCallback(() => {\n\t\tsetState((prevState) => ({ actionType: 'click', isOpen: !prevState.isOpen }));\n\t}, []);\n\n\tconst hideMenuHover = React.useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tconst relatedTarget = event.relatedTarget as Node;\n\n\t\t\t// If the related target is not a child of the menu, close the menu\n\t\t\t// This prevents the menu from closing when hovering over a submenu item or trigger\n\t\t\tif (\n\t\t\t\ttriggerRef &&\n\t\t\t\tmenuRef.current &&\n\t\t\t\t!menuRef.current.contains(relatedTarget) &&\n\t\t\t\ttriggerRef.current &&\n\t\t\t\t!triggerRef.current.contains(relatedTarget)\n\t\t\t) {\n\t\t\t\tsetState({ actionType: null, isOpen: false });\n\t\t\t}\n\t\t},\n\t\t[triggerRef]\n\t);\n\n\t/**\n\t * Sets up trigger event listeners to open and close the menu with a keyboard\n\t */\n\tconst toggleMenuKey = React.useCallback(\n\t\t(e: KeyboardEvent) => {\n\t\t\tconst openMenu = () => {\n\t\t\t\tif (isTriggerDisabled()) return;\n\t\t\t\tsetState({ actionType: e.key as ActionType, isOpen: true });\n\t\t\t};\n\n\t\t\tif (!state.isOpen) {\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\tswitch (e.key) {\n\t\t\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\t\tcase 'Enter':\n\t\t\t\t\t\tcase ' ':\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\topenMenu();\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tswitch (e.key) {\n\t\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\t\tif (!disableArrowOpen && !isTriggerDisabled()) {\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\topenMenu();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Enter':\n\t\t\t\t\tcase ' ':\n\t\t\t\t\t\tif (isTriggerDisabled()) return;\n\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\topenMenu();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[state.isOpen, isTriggerDisabled, disableArrowOpen, isSubMenu]\n\t);\n\n\tconst closeMenu = React.useCallback(\n\t\t(shouldCloseParent = true) => {\n\t\t\tif (position === 'static') return;\n\n\t\t\t/**\n\t\t\t * What is closeParent?\n\t\t\t *\n\t\t\t * It is passed from the context provider to the MenuItem (which helps render our submenus)\n\t\t\t * When we render the submenu, we pass the closeMenu function as \"closeParent\" to the submenu.\n\t\t\t * This allows us to trigger closing the parent menu when the submenu is closed. And that's\n\t\t\t * what this call is for.\n\t\t\t */\n\t\t\tif (shouldCloseParent && closeParent) closeParent();\n\n\t\t\tsetState({ actionType: null, isOpen: false });\n\t\t\tonClose?.();\n\t\t},\n\t\t[position, closeParent, onClose]\n\t);\n\n\t/**\n\t * Click outside to dismiss the menu\n\t * @param e\n\t */\n\tconst disableClickOutside = !state.isOpen || position === 'static';\n\tuseClickOutside(menuRef, triggerRef, clickOutsideEvent, closeMenu, disableClickOutside);\n\n\tconst handleMenuKeyUp = (e: React.KeyboardEvent) => {\n\t\tconst actions: ActionType[] = ['ArrowUp', 'ArrowDown', 'ArrowRight', 'Enter', 'Escape', ' '];\n\n\t\tif (actions.includes(e.key as ActionType)) {\n\t\t\tpreventDefault(e);\n\t\t}\n\t};\n\n\t/**\n\t * Focus management when someone is using a keyboard to navigate the menu\n\t * @param e - keyboard event\n\t */\n\tconst handleMenuKey = (e: React.KeyboardEvent) => {\n\t\tconst currentIndex = menuItems.findIndex((item) => document.activeElement === item);\n\t\tlet nextIndex: number;\n\n\t\tif (state.isOpen) {\n\t\t\tswitch (e.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tnextIndex = currentIndex < menuItems.length - 1 ? currentIndex + 1 : currentIndex;\n\t\t\t\t\tmenuItems[nextIndex]?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tnextIndex = currentIndex > 0 ? currentIndex - 1 : 0;\n\t\t\t\t\tmenuItems[nextIndex]?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Escape':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\ttriggerRef?.current?.focus();\n\t\t\t\t\tcloseMenu(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Tab':\n\t\t\t\t\tif (!isSubMenu && position !== 'static') {\n\t\t\t\t\t\tif (e.shiftKey) {\n\t\t\t\t\t\t\t// Handle shift + tab: move focus to the previous item\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\tif (triggerRef) {\n\t\t\t\t\t\t\t\tconst prevElement = findAdjacentInteractiveElement(triggerRef, 'previous');\n\t\t\t\t\t\t\t\tprevElement?.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Regular tab: close the menu or move to the next item\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\tif (triggerRef) {\n\t\t\t\t\t\t\t\tconst nextElement = findAdjacentInteractiveElement(triggerRef);\n\t\t\t\t\t\t\t\tnextElement?.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcloseMenu();\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * useEffect hooks to handle menu state changes\n\t */\n\n\tReact.useEffect(() => {\n\t\tif (triggerRef?.current) {\n\t\t\ttriggerRef.current.setAttribute('aria-haspopup', 'menu');\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\tReact.useEffect(() => {\n\t\tif (position === 'static') {\n\t\t\tsetState({ actionType: 'click', isOpen: true });\n\t\t}\n\t}, [position]);\n\n\tReact.useEffect(() => {\n\t\ttriggerRef?.current?.setAttribute('aria-expanded', state.isOpen.toString());\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen]);\n\n\tReact.useEffect(() => {\n\t\tif (!isSubMenu && position !== 'static')\n\t\t\tsetState({ actionType: actionState.actionType, isOpen: actionState.isOpen });\n\t}, [actionState.isOpen, actionState.actionType, isSubMenu, position]);\n\n\t// setup event handlers for mouse, keyboard, and scroll interactions\n\tReact.useEffect(() => {\n\t\tconst triggerElement = triggerRef?.current;\n\t\tconst menuElement = menuRef?.current;\n\t\tconst menuItems = menuElement?.querySelectorAll(MENU_ITEM_SELECTOR);\n\n\t\tlet scrollableParent: HTMLElement | Window;\n\n\t\tif (triggerElement) {\n\t\t\ttriggerElement.addEventListener('mousedown', preventDefault);\n\t\t\tif (!isSubMenu) triggerElement.addEventListener('click', toggleMenuTrigger);\n\t\t\ttriggerElement.addEventListener('keydown', toggleMenuKey);\n\n\t\t\t// Setup event listeners for when the menu is a submenu\n\t\t\tif (isSubMenu) {\n\t\t\t\ttriggerElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\ttriggerElement.addEventListener('mouseout', hideMenuHover);\n\n\t\t\t\tif (isTouchDevice()) {\n\t\t\t\t\ttriggerElement.addEventListener('touchend', showMenuTap);\n\t\t\t\t}\n\n\t\t\t\tif (menuElement) {\n\t\t\t\t\tmenuElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\t\tmenuElement.addEventListener('mouseout', hideMenuHover);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (closeOnScroll) {\n\t\t\t\tscrollableParent = getScrollableParent(triggerElement);\n\t\t\t\tif (scrollableParent) {\n\t\t\t\t\tscrollableParent.addEventListener('scroll', () => closeMenu(), {\n\t\t\t\t\t\tcapture: true,\n\t\t\t\t\t\tpassive: true\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\ttriggerElement.removeEventListener('mousedown', preventDefault);\n\t\t\t\tif (!isSubMenu) triggerElement.removeEventListener('click', toggleMenuTrigger);\n\t\t\t\ttriggerElement.removeEventListener('keydown', toggleMenuKey);\n\n\t\t\t\tif (menuItems) {\n\t\t\t\t\tmenuItems.forEach((item: Element) => {\n\t\t\t\t\t\tif (!item.getAttribute('aria-haspopup')) {\n\t\t\t\t\t\t\titem.removeEventListener('mousedown', () => closeMenu());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\ttriggerElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\ttriggerElement.removeEventListener('mouseout', hideMenuHover);\n\n\t\t\t\t\tif (isTouchDevice()) {\n\t\t\t\t\t\ttriggerElement.removeEventListener('touchstart', showMenuHover);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (menuElement) {\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseout', hideMenuHover);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (closeOnScroll && scrollableParent) {\n\t\t\t\t\tscrollableParent.removeEventListener('scroll', () => closeMenu());\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}, [\n\t\tcloseOnScroll,\n\t\tisSubMenu,\n\t\ttriggerRef,\n\t\ttoggleMenuTrigger,\n\t\ttoggleMenuKey,\n\t\tshowMenuHover,\n\t\thideMenuHover,\n\t\tcloseMenu,\n\t\tshowMenuTap\n\t]);\n\n\t// This use effect handles a few things when we open the menu:\n\t// - making sure that the menu component is aware of it's menu items\n\t// - adding a class to the trigger element when the submenu is open for styling\n\t// - storing the menu rect in state for positioning calculations\n\tReact.useEffect(() => {\n\t\tif (state.isOpen) {\n\t\t\tconst foundMenuItems = Array.from(\n\t\t\t\tmenuRef.current?.querySelectorAll(MENU_ITEM_SELECTOR) || []\n\t\t\t) as HTMLButtonElement[];\n\n\t\t\tsetMenuItems(foundMenuItems);\n\t\t}\n\n\t\tif (state.isOpen && isSubMenu) {\n\t\t\ttriggerRef?.current?.classList.add(itemStyles['MrlMenuItem--item--submenuOpen']);\n\t\t} else if (!state.isOpen && isSubMenu) {\n\t\t\ttriggerRef?.current?.classList.remove(itemStyles['MrlMenuItem--item--submenuOpen']);\n\t\t}\n\n\t\t// For consistent submenu calculations, we are storing the menu rect in state\n\t\t// Anytime we need to use the menu rect, we want to make sure the values are based\n\t\t// on the original state of the menu for proper transformations\n\t\tif (!menuRect && menuRef.current) {\n\t\t\tconst newRect = menuRef.current?.getBoundingClientRect();\n\t\t\tsetMenuRect(newRect || null);\n\t\t}\n\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, menuRect, isSubMenu]);\n\n\t/**\n\t * Focus management for when the menu is opening or closing\n\t */\n\tReact.useEffect(() => {\n\t\tif (menuItems.length > 0) {\n\t\t\tlet menuItemToFocus;\n\n\t\t\tswitch (state.actionType) {\n\t\t\t\tcase 'Enter':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\tcase ' ':\n\t\t\t\t\tmenuItemToFocus = menuItems[0];\n\t\t\t\t\tmenuItemToFocus?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tmenuItemToFocus = menuItems[menuItems.length - 1];\n\t\t\t\t\tmenuItemToFocus?.focus();\n\n\t\t\t\t\t// Scroll to the bottom of the menu when the last item is focused\n\t\t\t\t\t// setTimeout is required to ensure the element has been rendered\n\t\t\t\t\t// and the scrollHeight is accurate prior to scrolling\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tif (listRef.current) {\n\t\t\t\t\t\t\tlistRef.current.scrollTo(0, listRef.current.scrollHeight);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 20);\n\t\t\t}\n\n\t\t\tif (isSubMenu && state.actionType === 'ArrowRight') {\n\t\t\t\tmenuItemToFocus = menuItems[0];\n\t\t\t\tmenuItemToFocus?.focus();\n\t\t\t}\n\t\t}\n\t}, [isSubMenu, menuItems, state.actionType]);\n\n\t/**\n\t * Menu scroll behavior\n\t *\n\t * When the menu cannot fit in the preferred or flipped position,\n\t * this hook constrains the menu height and enables internal scrolling.\n\t * Called before useTriggerPosition so that isScrolling can disable flipping,\n\t * preventing the positioning hook from fighting the scroll constraint.\n\t */\n\tconst disableMenuScroll =\n\t\tisSubMenu || !state.isOpen || position === 'static' || position === 'ignore';\n\n\t/**\n\t * Sets overflow (scrolling) on menu when there is no space to display\n\t * the menu in the preferred or flipped position.\n\t */\n\tconst menuScroll = useMenuScroll(\n\t\ttriggerRef,\n\t\tlistRef,\n\t\tposition,\n\t\tmenuOffset,\n\t\tstate.isOpen,\n\t\tdisableMenuScroll\n\t);\n\n\t/**\n\t * Primary menu positioning, alignment, and transition styling\n\t *\n\t * This hook is only enabled if isSubMenu is FALSE\n\t */\n\tconst disableTriggerPosition = isSubMenu || !state.isOpen || position === 'static';\n\tconst menuPositionStyles = useTriggerPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\t{\n\t\t\talign: alignment,\n\t\t\tcustomPosition: customPosition,\n\t\t\tposition: position\n\t\t},\n\t\tstate.isOpen,\n\t\tmenuOffset,\n\t\tdisableTriggerPosition,\n\t\tdisableFlipping || menuScroll.isScrolling\n\t);\n\n\t/**\n\t * Submenu positioning and alignment\n\t *\n\t * This hook is only enabled if isSubMenu is TRUE\n\t */\n\tconst subMenuPosition = useSubMenuElementPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\tisSubMenu,\n\t\tstate.isOpen,\n\t\tmenuRect,\n\t\t// disable the subelement positioning if it's not a submenu\n\t\t!isSubMenu\n\t);\n\n\tconst inlineStyles = {\n\t\tmenu: {\n\t\t\tleft: menuPositionStyles.left,\n\t\t\tposition: 'fixed' as const,\n\t\t\ttop: menuPositionStyles.top\n\t\t},\n\t\tsubmenu: {\n\t\t\tleft: subMenuPosition.left,\n\t\t\ttop: subMenuPosition.top\n\t\t}\n\t};\n\n\t/**\n\t * React Spring transitions for the menu\n\t */\n\tconst transitionConfig = {\n\t\tconfig: { duration: state.isOpen ? 300 : 150 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' },\n\t\tfrom: { opacity: 0, transform: 'translateY(4px)' },\n\t\tleave: { opacity: 0, transform: 'translateY(4px)' }\n\t};\n\n\tconst transitionStatic = {\n\t\tconfig: { duration: 0 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' }\n\t};\n\n\tconst transitions = useTransition(\n\t\tstate.isOpen,\n\t\tposition === 'static' ? transitionStatic : transitionConfig\n\t);\n\n\tconst menuClasses = classnames(styles['MrlMenu'], 'MrlMenu', {\n\t\t[styles['MrlMenu--submenu']]: isSubMenu,\n\t\t[styles.open]: state.isOpen,\n\t\t[styles['MrlMenu--compact']]: spacing === 'compact',\n\t\t[styles['MrlMenu--static']]: position === 'static',\n\t\t[styles['MrlMenu--internal']]: isInternal,\n\t\t[styles['MrlMenu--scrolling']]: menuScroll.isScrolling,\n\t\t[styles['MrlMenu--ignore']]: position === 'ignore'\n\t});\n\n\tconst positionStyles = isSubMenu\n\t\t? inlineStyles.submenu\n\t\t: position !== 'static'\n\t\t\t? inlineStyles.menu\n\t\t\t: {};\n\n\tconst menuScrollStyles =\n\t\t(menuScroll.maxHeight !== undefined && { maxHeight: menuScroll.maxHeight }) || undefined;\n\n\tconst renderMenu = () => {\n\t\treturn (\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\n\t\t\t\t\t\t\t\tclassName={menuClasses}\n\t\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\t\tstyle={{ ...positionStyles, ...style }}\n\t\t\t\t\t\t\t\tonKeyUp={handleMenuKeyUp}\n\t\t\t\t\t\t\t\tonKeyDown={handleMenuKey}\n\t\t\t\t\t\t\t\tref={menuRef}\n\t\t\t\t\t\t\t\trole=\"none\"\n\t\t\t\t\t\t\t\t{...remainingProps}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ul ref={listRef} role=\"menu\" style={menuScrollStyles}>\n\t\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t\t</ul>\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</>\n\t\t);\n\t};\n\n\t// For managing and restoring focus to the original menu trigger\n\t// Ensures the triggerRef in context is always the parent triggerRef\n\tconst parentContext = React.useContext(MrlMenuContext);\n\tconst contextTriggerRef = isSubMenu ? parentContext?.triggerRef : triggerRef;\n\n\treturn (\n\t\t<MrlMenuContext.Provider\n\t\t\tvalue={{\n\t\t\t\tcloseMenu,\n\t\t\t\tcloseParent: !isSubMenu ? closeMenu : undefined,\n\t\t\t\ttriggerRef: contextTriggerRef\n\t\t\t}}\n\t\t>\n\t\t\t{isSubMenu || position === 'static' ? (\n\t\t\t\trenderMenu()\n\t\t\t) : (\n\t\t\t\t<MrlPortal layer={portalProps.layer || PORTAL_LAYERS.MENU} {...portalProps}>\n\t\t\t\t\t{renderMenu()}\n\t\t\t\t</MrlPortal>\n\t\t\t)}\n\t\t</MrlMenuContext.Provider>\n\t);\n\t/* eslint-enable */\n}\n\nMrlMenu.componentType = 'Menu';\n"],"names":["MENU_ITEM_SELECTOR","MrlMenu","_ref","_ref$actionState","actionState","actionType","isOpen","_ref$alignment","alignment","children","_ref$closeOnScroll","closeOnScroll","closeParent","customPosition","_ref$clickOutsideEven","clickOutsideEvent","disableArrowOpen","_ref$disableFlipping","disableFlipping","id","_ref$isInternal","isInternal","_ref$isSubMenu","isSubMenu","_ref$spacing","spacing","_ref$menuOffset","menuOffset","_ref$portalProps","portalProps","PORTAL_LAYERS","MENU","name","_ref$position","position","_ref$triggerStopPropa","triggerStopPropagation","onClose","eventId","triggerRef","remainingProps","_objectWithoutProperties","_excluded","defaultOpenState","_React$useState","React","useState","_React$useState2","_slicedToArray","state","setState","trackInteraction","useMrlTrackInteraction","wasOpenRef","useRef","useEffect","_state$actionType","current","action","metadata","trigger","variant","menuRef","listRef","_React$useState3","_React$useState4","menuItems","setMenuItems","_React$useState5","_React$useState6","menuRect","setMenuRect","isTriggerDisabled","useCallback","isElementAriaDisabled","toggleMenuTrigger","e","preventDefault","prevState","showMenuHover","showMenuTap","hideMenuHover","event","relatedTarget","contains","toggleMenuKey","openMenu","key","closeMenu","shouldCloseParent","arguments","length","undefined","disableClickOutside","useClickOutside","handleMenuKeyUp","actions","includes","handleMenuKey","_menuItems$nextIndex","_menuItems$nextIndex2","_triggerRef$current","currentIndex","findIndex","item","document","activeElement","nextIndex","focus","shiftKey","prevElement","findAdjacentInteractiveElement","nextElement","setAttribute","_triggerRef$current2","toString","triggerElement","menuElement","querySelectorAll","scrollableParent","addEventListener","isTouchDevice","getScrollableParent","capture","passive","removeEventListener","forEach","getAttribute","_menuRef$current","foundMenuItems","Array","from","_triggerRef$current3","classList","add","itemStyles","_triggerRef$current4","remove","_menuRef$current2","newRect","getBoundingClientRect","_menuItemToFocus","_menuItemToFocus2","menuItemToFocus","setTimeout","scrollTo","scrollHeight","_menuItemToFocus3","disableMenuScroll","menuScroll","useMenuScroll","disableTriggerPosition","menuPositionStyles","useTriggerPosition","align","isScrolling","subMenuPosition","useSubMenuElementPosition","inlineStyles","menu","left","top","submenu","transitionConfig","config","duration","enter","opacity","transform","leave","transitionStatic","transitions","useTransition","menuClasses","classnames","styles","open","positionStyles","menuScrollStyles","maxHeight","renderMenu","createElement","Fragment","style","animated","div","_extends","className","_objectSpread","onKeyUp","onKeyDown","ref","role","parentContext","useContext","MrlMenuContext","contextTriggerRef","Provider","value","MrlPortal","layer","componentType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqKA,IAAMA,kBAAkB,GAAG,sEAAsE;;AAEjG;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAAAC,IAAA,EAsBO;AAAA,EAAA,IAAAC,gBAAA,GAAAD,IAAA,CArB7BE,WAAW;IAAXA,WAAW,GAAAD,gBAAA,KAAA,MAAA,GAAG;AAAEE,MAAAA,UAAU,EAAE,IAAI;AAAEC,MAAAA,MAAM,EAAE;AAAM,KAAC,GAAAH,gBAAA;IAAAI,cAAA,GAAAL,IAAA,CACjDM,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,MAAA,GAAG,QAAQ,GAAAA,cAAA;IACpBE,QAAQ,GAAAP,IAAA,CAARO,QAAQ;IAAAC,kBAAA,GAAAR,IAAA,CACRS,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,kBAAA;IACrBE,W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AA,MAAA,GAAbA,aAAa,CAAE1J,UAAU,GAAGA,UAAU;AAE5E,EAAA,oBACCM,gBAAA,CAAAwI,aAAA,CAACc,6BAAc,CAACE,QAAQ,EAAA;AACvBC,IAAAA,KAAK,EAAE;MACN9G,SAAS;AACT5E,MAAAA,WAAW,EAAE,CAACW,SAAS,GAAGiE,SAAS,GAAGI,SAAS;AAC/CrD,MAAAA,UAAU,EAAE6J;AACb;AAAE,GAAA,EAED7K,SAAS,IAAIW,QAAQ,KAAK,QAAQ,GAClCkJ,UAAU,EAAE,gBAEZvI,gBAAA,CAAAwI,aAAA,CAACkB,mBAAS,EAAAb,iCAAA,CAAA;AAACc,IAAAA,KAAK,EAAE3K,WAAW,CAAC2K,KAAK,IAAI1K,mBAAa,CAACC;AAAK,GAAA,EAAKF,WAAW,CAAA,EACxEuJ,UAAU,EACD,CAEY,CAAC;AAE3B;AACD;AAEAnL,OAAO,CAACwM,aAAa,GAAG,MAAM;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var TOOLKIT_VERSION = "4.76.0";
3
+ var TOOLKIT_VERSION = "4.76.1";
4
4
 
5
5
  exports.TOOLKIT_VERSION = TOOLKIT_VERSION;
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.76.0\";"],"names":["TOOLKIT_VERSION"],"mappings":";;AAAO,IAAMA,eAAe,GAAG;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.76.1\";"],"names":["TOOLKIT_VERSION"],"mappings":";;AAAO,IAAMA,eAAe,GAAG;;;;"}
@@ -75,12 +75,18 @@ export interface MrlMenuProps {
75
75
  */
76
76
  position?: MenuPosition;
77
77
  /**
78
- * Set initial state of menu
78
+ * Opens or closes the menu from outside. Not just an initial value: whenever
79
+ * `isOpen` or `actionType` changes, the menu syncs its internal state to it.
80
+ * The menu can still close itself (item select, click outside, Escape, Tab),
81
+ * so pair this with `onClose` to reset your state. Prefer `triggerRef` when
82
+ * there is a trigger element. Ignored for submenus and `position="static"`.
79
83
  * @default { actionType: null, isOpen: false }
80
84
  */
81
85
  actionState?: ActionState;
82
86
  /**
83
- * Reference to the DOM element that triggers this menu.
87
+ * Reference to the DOM element that triggers this menu. This alone wires up
88
+ * click and keyboard open/close and the trigger's ARIA attributes; no
89
+ * `actionState` or `onClick` toggle is needed.
84
90
  */
85
91
  triggerRef?: React.RefObject<HTMLButtonElement>;
86
92
  /**
@@ -101,7 +107,8 @@ export interface MrlMenuProps {
101
107
  */
102
108
  alignment?: MenuAlignment;
103
109
  /**
104
- * Callback to be called when the menu is closed
110
+ * Called when the menu closes itself: item select, click outside, Escape, Tab,
111
+ * or scroll with `closeOnScroll`. Not called when a trigger click toggles it closed.
105
112
  * @param type - type of close event
106
113
  */
107
114
  onClose?: (type?: string) => void;
@@ -47,7 +47,7 @@ var _excluded = ["accept", "className", "errorMessage", "eventId", "fileName", "
47
47
  * @returns The MrlFileUpload component.
48
48
  */
49
49
  function MrlFileUpload(props) {
50
- var _ref, _ref2;
50
+ var _ref;
51
51
  var _props$accept = props.accept,
52
52
  accept = _props$accept === void 0 ? fileUploadDefaults.accept : _props$accept,
53
53
  className = props.className,
@@ -103,7 +103,10 @@ function MrlFileUpload(props) {
103
103
  // A disabled zone outranks both — it cannot have accepted a file.
104
104
  var effectiveState = isDisabled ? 'disabled' : validationError ? 'error' : state;
105
105
  var displayName = (_ref = fileName !== null && fileName !== void 0 ? fileName : selectedName) !== null && _ref !== void 0 ? _ref : '';
106
- var displayError = (_ref2 = validationError !== null && validationError !== void 0 ? validationError : errorMessage) !== null && _ref2 !== void 0 ? _ref2 : null;
106
+ // `||` rather than `??`: an empty message is as good as no message, and has
107
+ // to fall through — to the consumer's `errorMessage`, and then to the
108
+ // default below — or an errored zone renders with no text at all.
109
+ var displayError = validationError || errorMessage || null;
107
110
  // An errored zone always carries text. The types forbid reporting 'error'
108
111
  // without a message, but a JavaScript consumer can still reach it, and colour
109
112
  // alone reaches neither assistive technology nor anyone who cannot see the hue.
@@ -1 +1 @@
1
- {"version":3,"file":"MrlFileUpload.js","sources":["../../../../../src/components/file-upload/MrlFileUpload/MrlFileUpload.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { check, importIcon } from '@muraldevkit/ds-icons';\nimport { MrlButton } from '../../button/MrlButton/MrlButton';\nimport { MrlInlineMessage } from '../../notification/MrlInlineMessage/MrlInlineMessage';\nimport { MrlLiveRegion } from '../../live-region/MrlLiveRegion/MrlLiveRegion';\nimport { MrlProgressBar } from '../../loader/MrlProgressBar/MrlProgressBar';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { MrlText } from '../../text/MrlText/MrlText';\nimport { ProgressRange } from '../../loader/constants';\nimport { DataQa } from '../../../utils/dataQa';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\nimport { DEFAULT_ERROR_MESSAGE, fileUploadDefaults, MrlFileUploadState } from '../constants';\nimport { describeConstraints, formatAcceptList, formatBytes, isAccepted } from '../helpers';\nimport styles from './MrlFileUpload.module.scss';\n\n/**\n * The resting half of the state contract: anything but a reported failure.\n */\ntype MrlFileUploadRestingProps = {\n\t/**\n\t * Message for a failure the consumer is not currently reporting — kept across\n\t * a retry, for instance. Rendered only in the error state.\n\t */\n\terrorMessage?: string;\n\t/**\n\t * The visual state of the zone, owned by the consumer. The component tracks\n\t * drag state and local validation itself, but never starts, advances or\n\t * completes an upload — pass 'uploading' with a `percent`, then 'complete'.\n\t * Reporting 'error' requires an `errorMessage`, so it lives in the other half\n\t * of this union.\n\t *\n\t * 'disabled' blocks all interaction: drag, drop and click handlers return\n\t * early rather than relying on `pointer-events` alone. Because it is a value\n\t * of this union rather than a separate flag, it replaces the lifecycle state\n\t * rather than composing with it — a zone cannot be disabled *and* report\n\t * progress at the same time.\n\t */\n\tstate?: Exclude<MrlFileUploadState, 'error'>;\n};\n\n/**\n * The failure half: reporting an error means saying what went wrong.\n */\ntype MrlFileUploadErrorProps = {\n\t/**\n\t * Why the upload failed. Required alongside `state=\"error\"`: the failure has\n\t * to reach people who cannot see the border colour.\n\t *\n\t * A retry that fails with the identical message is announced only once — a\n\t * live region re-set to the text it already holds says nothing, and the\n\t * component cannot tell a retry from a re-render. Pass through a non-error\n\t * state between attempts (back to 'idle', or 'uploading' while the retry is\n\t * in flight) so the second failure is a genuine change.\n\t */\n\terrorMessage: string;\n\t/**\n\t * Reports a failed upload. A local validation failure supplies its own\n\t * message and takes precedence over `errorMessage`.\n\t */\n\tstate: 'error';\n};\n\n/**\n * The zone's state and, when it reports a failure, the message that explains it.\n *\n * The two are a union rather than two independent props so that `state=\"error\"`\n * without an `errorMessage` does not compile. An errored zone with no text is\n * signalled by border colour alone, which reaches neither assistive technology\n * nor anyone who cannot distinguish the error hue. A consumer holding the state\n * in a variable typed as the whole union has to narrow it before rendering —\n * that is the point, not an accident.\n */\nexport type MrlFileUploadStateProps = MrlFileUploadRestingProps | MrlFileUploadErrorProps;\n\nexport type MrlFileUploadProps = {\n\t/**\n\t * Accepted file types, in the same format as the native `accept` attribute\n\t * (e.g. '.gif,.jpg,.jpeg,.png' or 'image/*'). Also enforced on drop, which\n\t * the native attribute does not cover.\n\t */\n\taccept?: string;\n\t/**\n\t * Name of the file being uploaded, shown in the progress and completed copy\n\t * and announced to assistive technology. Falls back to the name of the file\n\t * the user last selected.\n\t */\n\tfileName?: string;\n\t/**\n\t * Headline inside the drop zone.\n\t */\n\theading?: string;\n\t/**\n\t * Supporting line describing what is accepted.\n\t */\n\thelperText?: string;\n\t/**\n\t * Field label rendered above the drop zone, and the zone's accessible name.\n\t */\n\tlabel?: string;\n\t/**\n\t * Maximum accepted file size in bytes. Omit for no limit.\n\t */\n\tmaxSizeBytes?: number;\n\t/**\n\t * Fired when the user cancels an upload in progress. The consumer owns the\n\t * abort — the component only returns itself to its resting state.\n\t */\n\tonCancel?: () => void;\n\t/**\n\t * Fired when a file fails local validation, with the message shown to the\n\t * user. Transport failures are reported by the consumer through\n\t * `state=\"error\"` instead.\n\t */\n\tonError?: (message: string, file: File) => void;\n\t/**\n\t * Fired when a file passes validation and is ready to upload. The consumer\n\t * performs the upload and drives `state` and `percent` from its result.\n\t */\n\tonFilesSelected?: (file: File) => void;\n\t/**\n\t * Fired when the user removes a completed upload.\n\t */\n\tonRemove?: () => void;\n\t/**\n\t * Upload progress, 0–100. Only read while `state` is 'uploading'.\n\t */\n\tpercent?: ProgressRange;\n\t/**\n\t * Shows `helperText` inside the drop zone.\n\t */\n\tshowHelperText?: boolean;\n\t/**\n\t * Repeats `helperText` as an inline message below the drop zone. Off by\n\t * default — with `showHelperText` on, enabling both prints the same sentence\n\t * twice. A validation or upload error always renders below the zone\n\t * regardless of this flag.\n\t */\n\tshowInlineAlert?: boolean;\n\t/**\n\t * Additional validation, run after the built-in `accept` and `maxSizeBytes`\n\t * checks and only if those pass. Return a message to reject the file — it is\n\t * shown and reported exactly like a built-in failure — or `null` to accept it.\n\t */\n\tvalidate?: (file: File) => string | null;\n\t/**\n\t * Enables interaction tracking for this upload control. Provide a stable,\n\t * non-PII id (e.g. 'workspace-logo-upload'). When omitted, the component\n\t * emits no analytics.\n\t *\n\t * Note: file names, sizes and types are never emitted — only the fact of a\n\t * selection and whether it was accepted.\n\t */\n\teventId?: string;\n} & MrlFileUploadStateProps &\n\tOmit<React.ComponentPropsWithoutRef<'div'>, 'onError'> &\n\tDataQa;\n\n/**\n * A drag-and-drop file upload zone with a keyboard-accessible browse button.\n *\n * The component owns presentation, drag tracking and local validation\n * (`accept`, `maxSizeBytes`); the consumer owns the upload itself and drives\n * `state` and `percent`. Drag and drop is pointer-only by nature, so the\n * button inside the zone is the equivalent path for everyone else and is the\n * affordance exposed to the accessibility tree.\n *\n * @param props - The component props.\n * @returns The MrlFileUpload component.\n */\nexport function MrlFileUpload(props: MrlFileUploadProps): React.ReactElement {\n\tconst {\n\t\taccept = fileUploadDefaults.accept,\n\t\tclassName,\n\t\terrorMessage,\n\t\teventId,\n\t\tfileName,\n\t\theading = fileUploadDefaults.heading,\n\t\thelperText,\n\t\tlabel,\n\t\tmaxSizeBytes,\n\t\tonCancel,\n\t\tonError,\n\t\tonFilesSelected,\n\t\tonRemove,\n\t\tpercent = 0,\n\t\tshowHelperText = fileUploadDefaults.showHelperText,\n\t\tshowInlineAlert = fileUploadDefaults.showInlineAlert,\n\t\tstate = fileUploadDefaults.state,\n\t\tvalidate,\n\t\t['data-qa']: dataQa,\n\t\t...rest\n\t} = props;\n\n\tconst [isDragging, setIsDragging] = React.useState(false);\n\tconst [validationError, setValidationError] = React.useState<string | null>(null);\n\tconst [selectedName, setSelectedName] = React.useState<string | null>(null);\n\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\t// The action button of whichever view is showing — Browse, Cancel or Remove.\n\tconst actionRef = React.useRef<HTMLButtonElement>(null);\n\t// Armed when an interaction puts focus on that button, so the next view swap\n\t// can hand it back rather than dropping it.\n\tconst shouldRestoreFocus = React.useRef(false);\n\t// dragenter/dragleave fire for descendants too; counting keeps the state stable.\n\tconst dragDepth = React.useRef(0);\n\n\tconst reactId = React.useId();\n\tconst labelId = `${reactId}-label`;\n\tconst messageId = `${reactId}-message`;\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlFileUpload', eventId);\n\n\tconst isDisabled = state === 'disabled';\n\t// A failed local validation outranks the consumer's state: no upload started.\n\t// A disabled zone outranks both — it cannot have accepted a file.\n\tconst effectiveState: MrlFileUploadState = isDisabled\n\t\t? 'disabled'\n\t\t: validationError\n\t\t\t? 'error'\n\t\t\t: state;\n\tconst displayName = fileName ?? selectedName ?? '';\n\tconst displayError = validationError ?? errorMessage ?? null;\n\t// An errored zone always carries text. The types forbid reporting 'error'\n\t// without a message, but a JavaScript consumer can still reach it, and colour\n\t// alone reaches neither assistive technology nor anyone who cannot see the hue.\n\tconst resolvedError =\n\t\teffectiveState === 'error' ? (displayError ?? DEFAULT_ERROR_MESSAGE) : displayError;\n\t// Derived rather than defaulted, so the copy cannot contradict what validation\n\t// enforces — and so the size limit is stated before it rejects anyone.\n\tconst resolvedHelperText = helperText ?? describeConstraints(accept, maxSizeBytes);\n\tconst isBusy = effectiveState === 'uploading';\n\n\t/**\n\t * Validates a file — against `accept` and `maxSizeBytes`, then against the\n\t * consumer's own `validate` — and hands it over, or reports why it was\n\t * rejected. Emits exactly one analytics event per selection.\n\t *\n\t * @param file - the file the user chose or dropped\n\t * @param source - how the file arrived, for analytics only\n\t */\n\tconst acceptFile = React.useCallback(\n\t\t(file: File | undefined, source: 'browse' | 'drop') => {\n\t\t\tif (!file) return;\n\n\t\t\tlet rejection: string | null = null;\n\n\t\t\tif (!isAccepted(file, accept)) {\n\t\t\t\t// The rule that rejected the file is the only reliable source for what\n\t\t\t\t// would be accepted; a hand-written list drifts away from `accept`.\n\t\t\t\tconst types = formatAcceptList(accept);\n\t\t\t\trejection = types\n\t\t\t\t\t? `File type is not valid. Accepted types: ${types}`\n\t\t\t\t\t: 'File type is not valid';\n\t\t\t} else if (maxSizeBytes !== undefined && file.size > maxSizeBytes) {\n\t\t\t\trejection = `File is larger than ${formatBytes(maxSizeBytes)}`;\n\t\t\t} else {\n\t\t\t\t// The consumer's rules run last, so a file that fails the component's\n\t\t\t\t// own checks never reaches them.\n\t\t\t\trejection = validate?.(file) ?? null;\n\t\t\t}\n\n\t\t\t// The file's name, size and type are consumer data and are never emitted.\n\t\t\ttrackInteraction({\n\t\t\t\taction: 'select',\n\t\t\t\tmetadata: { outcome: rejection ? 'rejected' : 'accepted', source }\n\t\t\t});\n\n\t\t\tif (rejection) {\n\t\t\t\tsetSelectedName(file.name);\n\t\t\t\tsetValidationError(rejection);\n\t\t\t\tonError?.(rejection, file);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetSelectedName(file.name);\n\t\t\tsetValidationError(null);\n\t\t\t// A browse selection leaves focus on the Browse button, which the consumer\n\t\t\t// is about to unmount by moving to 'uploading'. A drop does not: it is\n\t\t\t// pointer-only, and focus was never in the zone to begin with.\n\t\t\tif (source === 'browse') shouldRestoreFocus.current = true;\n\t\t\tonFilesSelected?.(file);\n\t\t},\n\t\t[accept, maxSizeBytes, onError, onFilesSelected, trackInteraction, validate]\n\t);\n\n\t/**\n\t * Returns the zone to its resting state and clears the native input so the\n\t * same file can be chosen again.\n\t */\n\tconst reset = React.useCallback(() => {\n\t\tdragDepth.current = 0;\n\t\tsetIsDragging(false);\n\t\tsetSelectedName(null);\n\t\tsetValidationError(null);\n\t\tif (inputRef.current) inputRef.current.value = '';\n\t}, []);\n\n\tconst handleBrowse = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tinputRef.current?.click();\n\t}, [isDisabled]);\n\n\tconst handleCancel = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tshouldRestoreFocus.current = true;\n\t\ttrackInteraction({ action: 'click', metadata: { control: 'cancel' } });\n\t\treset();\n\t\tonCancel?.();\n\t}, [isDisabled, onCancel, reset, trackInteraction]);\n\n\tconst handleRemove = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tshouldRestoreFocus.current = true;\n\t\ttrackInteraction({ action: 'clear', metadata: { control: 'remove' } });\n\t\treset();\n\t\tonRemove?.();\n\t}, [isDisabled, onRemove, reset, trackInteraction]);\n\n\tconst handleDragEnter = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current += 1;\n\t\t\tsetIsDragging(true);\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDragOver = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\t// Required, or the browser treats the drop as navigation and opens the file.\n\t\t\tevent.preventDefault();\n\t\t\tevent.dataTransfer.dropEffect = 'copy';\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDragLeave = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current = Math.max(0, dragDepth.current - 1);\n\t\t\t// Leaving without dropping restores the previous view rather than resetting,\n\t\t\t// so a completed or errored zone is not cleared by a passing cursor.\n\t\t\tif (dragDepth.current === 0) setIsDragging(false);\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDrop = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current = 0;\n\t\t\tsetIsDragging(false);\n\t\t\tacceptFile(event.dataTransfer.files?.[0], 'drop');\n\t\t},\n\t\t[acceptFile, isDisabled, isBusy]\n\t);\n\n\tconst handleInputChange = React.useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tconst file = event.target.files?.[0];\n\t\t\t// Cleared before validating: the native control fires `change` only when\n\t\t\t// the selection changes, so re-picking a corrected file would be silent.\n\t\t\tevent.target.value = '';\n\t\t\tacceptFile(file, 'browse');\n\t\t},\n\t\t[acceptFile]\n\t);\n\n\tconst view = isDragging ? 'dragging' : effectiveState;\n\n\t/*\n\t * Each view renders its action button at a different position inside the zone,\n\t * so React unmounts one and mounts another rather than reusing it, and the\n\t * browser drops focus to the body — sending a keyboard user back to the top of\n\t * the page mid-task. Hand focus to the button that replaced it, but only when\n\t * it was genuinely lost: never take it from someone who has tabbed away.\n\t */\n\tReact.useLayoutEffect(() => {\n\t\tif (!shouldRestoreFocus.current) return;\n\n\t\tconst focusWasLost = !document.activeElement || document.activeElement === document.body;\n\t\tshouldRestoreFocus.current = false;\n\n\t\tif (focusWasLost) {\n\t\t\tactionRef.current?.focus();\n\t\t\t// Focus is inside the zone again, so keep the chain armed for the next\n\t\t\t// swap — an upload the consumer completes on its own included.\n\t\t\tshouldRestoreFocus.current = true;\n\t\t}\n\t}, [view]);\n\n\t/* eslint-disable sort-keys */\n\tconst zoneClasses = classnames({\n\t\t[styles['MrlFileUpload-zone']]: true,\n\t\t'MrlFileUpload-zone': true,\n\t\t[styles[`MrlFileUpload-zone--${view}`]]: view !== 'idle'\n\t});\n\t/* eslint-enable sort-keys */\n\n\tconst inlineKind = resolvedError ? 'error' : 'helper';\n\tconst inlineMessage = resolvedError ?? (showInlineAlert ? resolvedHelperText : null);\n\n\tconst announcement = () => {\n\t\tif (effectiveState === 'uploading') {\n\t\t\t// Quantised to 10% steps. A live region queues announcements rather than\n\t\t\t// replacing them, so narrating every tick buries 'upload successful'\n\t\t\t// behind a backlog that is usually discarded before it is spoken.\n\t\t\tconst step = Math.floor(Math.round(percent) / 10) * 10;\n\t\t\treturn `Uploading ${displayName}, ${step}%`;\n\t\t}\n\t\tif (effectiveState === 'complete') return `Upload of ${displayName} successful`;\n\t\tif (effectiveState === 'error' && resolvedError) {\n\t\t\t// Prefixed with the file name so two failures for the same reason are two\n\t\t\t// different strings: a live region re-set to the same text stays silent.\n\t\t\treturn displayName ? `${displayName}: ${resolvedError}` : resolvedError;\n\t\t}\n\t\treturn '';\n\t};\n\n\tconst restingContent = (\n\t\t<>\n\t\t\t<div className={classnames(styles['MrlFileUpload-content'], 'MrlFileUpload-content')}>\n\t\t\t\t<p className={classnames(styles['MrlFileUpload-heading'], 'MrlFileUpload-heading')}>\n\t\t\t\t\t{heading}\n\t\t\t\t</p>\n\t\t\t\t{showHelperText && resolvedHelperText && (\n\t\t\t\t\t<MrlText size=\"small\">{resolvedHelperText}</MrlText>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<MrlButton\n\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\tkind=\"secondary\"\n\t\t\t\tref={actionRef}\n\t\t\t\tsize=\"small\"\n\t\t\t\tstate={isDisabled ? 'disabled' : 'default'}\n\t\t\t\ttext=\"Browse files\"\n\t\t\t\tonClick={handleBrowse}\n\t\t\t/>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tdata-qa={dataQa}\n\t\t\tclassName={classnames(styles['MrlFileUpload'], 'MrlFileUpload', className)}\n\t\t>\n\t\t\t{label && (\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(styles['MrlFileUpload-label'], 'MrlFileUpload-label')}\n\t\t\t\t\tid={labelId}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t)}\n\n\t\t\t<div\n\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\taria-disabled={isDisabled || undefined}\n\t\t\t\taria-label={label ? undefined : heading}\n\t\t\t\taria-labelledby={label ? labelId : undefined}\n\t\t\t\tclassName={zoneClasses}\n\t\t\t\trole=\"group\"\n\t\t\t\tonDragEnter={handleDragEnter}\n\t\t\t\tonDragLeave={handleDragLeave}\n\t\t\t\tonDragOver={handleDragOver}\n\t\t\t\tonDrop={handleDrop}\n\t\t\t>\n\t\t\t\t{(view === 'idle' || view === 'error' || view === 'disabled') && restingContent}\n\n\t\t\t\t{view === 'dragging' && (\n\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon'],\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon--accent']\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\t\tsvg={importIcon}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--accent']\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tDrop your files\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\n\t\t\t\t{view === 'uploading' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-progress'])}>\n\t\t\t\t\t\t\t\t<MrlProgressBar\n\t\t\t\t\t\t\t\t\tname={`Uploading ${displayName || 'file'}`}\n\t\t\t\t\t\t\t\t\tpercent={Math.round(percent) as ProgressRange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--strong']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tUploading {displayName}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\t\t\t\tkind=\"secondary\"\n\t\t\t\t\t\t\tref={actionRef}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ttext=\"Cancel\"\n\t\t\t\t\t\t\tonClick={handleCancel}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\n\t\t\t\t{view === 'complete' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon--success']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\t\t\tsvg={check}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--strong']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tUpload of {displayName} successful!\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\t\t\t\tkind=\"secondary\"\n\t\t\t\t\t\t\tref={actionRef}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ttext=\"Remove\"\n\t\t\t\t\t\t\tonClick={handleRemove}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{inlineMessage && (\n\t\t\t\t<MrlInlineMessage id={messageId} kind={inlineKind} message={inlineMessage} />\n\t\t\t)}\n\n\t\t\t{/*\n\t\t\t * The real control, opened by the \"Browse files\" button. It is removed from\n\t\t\t * the tab order and the accessibility tree deliberately: the button is the\n\t\t\t * accessible affordance, and a focusable invisible input would be a keyboard\n\t\t\t * trap with no visible focus ring. Do not make it focusable.\n\t\t\t */}\n\t\t\t<input\n\t\t\t\taccept={accept || undefined}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tclassName={classnames(styles['MrlFileUpload-input'])}\n\t\t\t\tdisabled={isDisabled}\n\t\t\t\tref={inputRef}\n\t\t\t\ttabIndex={-1}\n\t\t\t\ttype=\"file\"\n\t\t\t\tonChange={handleInputChange}\n\t\t\t/>\n\n\t\t\t<MrlLiveRegion ariaLive=\"polite\" srContent={announcement()} />\n\t\t</div>\n\t);\n}\n"],"names":["MrlFileUpload","props","_ref","_ref2","_props$accept","accept","fileUploadDefaults","className","errorMessage","eventId","fileName","_props$heading","heading","helperText","label","maxSizeBytes","onCancel","onError","onFilesSelected","onRemove","_props$percent","percent","_props$showHelperText","showHelperText","_props$showInlineAler","showInlineAlert","_props$state","state","validate","dataQa","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","isDragging","setIsDragging","_React$useState3","_React$useState4","validationError","setValidationError","_React$useState5","_React$useState6","selectedName","setSelectedName","inputRef","useRef","actionRef","shouldRestoreFocus","dragDepth","reactId","useId","labelId","concat","messageId","trackInteraction","useMrlTrackInteraction","isDisabled","effectiveState","displayName","displayError","resolvedError","DEFAULT_ERROR_MESSAGE","resolvedHelperText","describeConstraints","isBusy","acceptFile","useCallback","file","source","rejection","isAccepted","types","formatAcceptList","undefined","size","formatBytes","_validate","action","metadata","outcome","name","current","reset","value","handleBrowse","_inputRef$current","click","handleCancel","control","handleRemove","handleDragEnter","event","preventDefault","handleDragOver","dataTransfer","dropEffect","handleDragLeave","Math","max","handleDrop","_event$dataTransfer$f","files","handleInputChange","_event$target$files","target","view","useLayoutEffect","focusWasLost","document","activeElement","body","_actionRef$current","focus","zoneClasses","classnames","styles","inlineKind","inlineMessage","announcement","step","floor","round","restingContent","createElement","Fragment","MrlText","MrlButton","kind","ref","text","onClick","_extends","id","role","onDragEnter","onDragLeave","onDragOver","onDrop","MrlSvg","svg","importIcon","MrlProgressBar","check","MrlInlineMessage","message","disabled","tabIndex","type","onChange","MrlLiveRegion","ariaLive","srContent"],"mappings":";;;;;;;;;;;;;;;;;AAgBA;AACA;AACA;;AAuBA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAACC,KAAyB,EAAsB;EAAA,IAAAC,IAAA,EAAAC,KAAA;AAC5E,EAAA,IAAAC,aAAA,GAqBIH,KAAK,CApBRI,MAAM;AAANA,IAAAA,MAAM,GAAAD,aAAA,KAAA,MAAA,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AA,IAAI,EAAC,OAAO;AACZuD,IAAAA,IAAI,EAAC,QAAQ;AACbC,IAAAA,OAAO,EAAEzC;GACT,CACA,CAEC,CAAC,EAEL4B,aAAa,iBACbvF,KAAA,CAAA6F,aAAA,CAACoB,gBAAgB,EAAA;AAACX,IAAAA,EAAE,EAAE/E,SAAU;AAAC0E,IAAAA,IAAI,EAAEX,UAAW;AAAC4B,IAAAA,OAAO,EAAE3B;AAAc,GAAE,CAC5E,eAQDvF,KAAA,CAAA6F,aAAA,CAAA,OAAA,EAAA;IACC1H,MAAM,EAAEA,MAAM,IAAIwE,SAAU;AAC5B,IAAA,aAAA,EAAY,MAAM;AAClBtE,IAAAA,SAAS,EAAE+G,UAAU,CAACC,MAAM,CAAC,qBAAqB,CAAC,CAAE;AACrD8B,IAAAA,QAAQ,EAAEzF,UAAW;AACrBwE,IAAAA,GAAG,EAAEpF,QAAS;IACdsG,QAAQ,EAAE,EAAG;AACbC,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,QAAQ,EAAE9C;AAAkB,GAC5B,CAAC,eAEFxE,KAAA,CAAA6F,aAAA,CAAC0B,aAAa,EAAA;AAACC,IAAAA,QAAQ,EAAC,QAAQ;IAACC,SAAS,EAAEjC,YAAY;AAAG,GAAE,CACzD,CAAC;AAER;;;;"}
1
+ {"version":3,"file":"MrlFileUpload.js","sources":["../../../../../src/components/file-upload/MrlFileUpload/MrlFileUpload.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { check, importIcon } from '@muraldevkit/ds-icons';\nimport { MrlButton } from '../../button/MrlButton/MrlButton';\nimport { MrlInlineMessage } from '../../notification/MrlInlineMessage/MrlInlineMessage';\nimport { MrlLiveRegion } from '../../live-region/MrlLiveRegion/MrlLiveRegion';\nimport { MrlProgressBar } from '../../loader/MrlProgressBar/MrlProgressBar';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\nimport { MrlText } from '../../text/MrlText/MrlText';\nimport { ProgressRange } from '../../loader/constants';\nimport { DataQa } from '../../../utils/dataQa';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\nimport { DEFAULT_ERROR_MESSAGE, fileUploadDefaults, MrlFileUploadState } from '../constants';\nimport { describeConstraints, formatAcceptList, formatBytes, isAccepted } from '../helpers';\nimport styles from './MrlFileUpload.module.scss';\n\n/**\n * The resting half of the state contract: anything but a reported failure.\n */\ntype MrlFileUploadRestingProps = {\n\t/**\n\t * Message for a failure the consumer is not currently reporting — kept across\n\t * a retry, for instance. Rendered only in the error state.\n\t */\n\terrorMessage?: string;\n\t/**\n\t * The visual state of the zone, owned by the consumer. The component tracks\n\t * drag state and local validation itself, but never starts, advances or\n\t * completes an upload — pass 'uploading' with a `percent`, then 'complete'.\n\t * Reporting 'error' requires an `errorMessage`, so it lives in the other half\n\t * of this union.\n\t *\n\t * 'disabled' blocks all interaction: drag, drop and click handlers return\n\t * early rather than relying on `pointer-events` alone. Because it is a value\n\t * of this union rather than a separate flag, it replaces the lifecycle state\n\t * rather than composing with it — a zone cannot be disabled *and* report\n\t * progress at the same time.\n\t */\n\tstate?: Exclude<MrlFileUploadState, 'error'>;\n};\n\n/**\n * The failure half: reporting an error means saying what went wrong.\n */\ntype MrlFileUploadErrorProps = {\n\t/**\n\t * Why the upload failed. Required alongside `state=\"error\"`: the failure has\n\t * to reach people who cannot see the border colour.\n\t *\n\t * A retry that fails with the identical message is announced only once — a\n\t * live region re-set to the text it already holds says nothing, and the\n\t * component cannot tell a retry from a re-render. Pass through a non-error\n\t * state between attempts (back to 'idle', or 'uploading' while the retry is\n\t * in flight) so the second failure is a genuine change.\n\t */\n\terrorMessage: string;\n\t/**\n\t * Reports a failed upload. A local validation failure supplies its own\n\t * message and takes precedence over `errorMessage`.\n\t */\n\tstate: 'error';\n};\n\n/**\n * The zone's state and, when it reports a failure, the message that explains it.\n *\n * The two are a union rather than two independent props so that `state=\"error\"`\n * without an `errorMessage` does not compile. An errored zone with no text is\n * signalled by border colour alone, which reaches neither assistive technology\n * nor anyone who cannot distinguish the error hue. A consumer holding the state\n * in a variable typed as the whole union has to narrow it before rendering —\n * that is the point, not an accident.\n */\nexport type MrlFileUploadStateProps = MrlFileUploadRestingProps | MrlFileUploadErrorProps;\n\nexport type MrlFileUploadProps = {\n\t/**\n\t * Accepted file types, in the same format as the native `accept` attribute\n\t * (e.g. '.gif,.jpg,.jpeg,.png' or 'image/*'). Also enforced on drop, which\n\t * the native attribute does not cover.\n\t */\n\taccept?: string;\n\t/**\n\t * Name of the file being uploaded, shown in the progress and completed copy\n\t * and announced to assistive technology. Falls back to the name of the file\n\t * the user last selected.\n\t */\n\tfileName?: string;\n\t/**\n\t * Headline inside the drop zone.\n\t */\n\theading?: string;\n\t/**\n\t * Supporting line describing what is accepted.\n\t */\n\thelperText?: string;\n\t/**\n\t * Field label rendered above the drop zone, and the zone's accessible name.\n\t */\n\tlabel?: string;\n\t/**\n\t * Maximum accepted file size in bytes. Omit for no limit.\n\t */\n\tmaxSizeBytes?: number;\n\t/**\n\t * Fired when the user cancels an upload in progress. The consumer owns the\n\t * abort — the component only returns itself to its resting state.\n\t */\n\tonCancel?: () => void;\n\t/**\n\t * Fired when a file fails local validation, with the message shown to the\n\t * user. Transport failures are reported by the consumer through\n\t * `state=\"error\"` instead.\n\t */\n\tonError?: (message: string, file: File) => void;\n\t/**\n\t * Fired when a file passes validation and is ready to upload. The consumer\n\t * performs the upload and drives `state` and `percent` from its result.\n\t */\n\tonFilesSelected?: (file: File) => void;\n\t/**\n\t * Fired when the user removes a completed upload.\n\t */\n\tonRemove?: () => void;\n\t/**\n\t * Upload progress, 0–100. Only read while `state` is 'uploading'.\n\t */\n\tpercent?: ProgressRange;\n\t/**\n\t * Shows `helperText` inside the drop zone.\n\t */\n\tshowHelperText?: boolean;\n\t/**\n\t * Repeats `helperText` as an inline message below the drop zone. Off by\n\t * default — with `showHelperText` on, enabling both prints the same sentence\n\t * twice. A validation or upload error always renders below the zone\n\t * regardless of this flag.\n\t */\n\tshowInlineAlert?: boolean;\n\t/**\n\t * Additional validation, run after the built-in `accept` and `maxSizeBytes`\n\t * checks and only if those pass. Return a message to reject the file — it is\n\t * shown and reported exactly like a built-in failure — or `null` to accept it.\n\t */\n\tvalidate?: (file: File) => string | null;\n\t/**\n\t * Enables interaction tracking for this upload control. Provide a stable,\n\t * non-PII id (e.g. 'workspace-logo-upload'). When omitted, the component\n\t * emits no analytics.\n\t *\n\t * Note: file names, sizes and types are never emitted — only the fact of a\n\t * selection and whether it was accepted.\n\t */\n\teventId?: string;\n} & MrlFileUploadStateProps &\n\tOmit<React.ComponentPropsWithoutRef<'div'>, 'onError'> &\n\tDataQa;\n\n/**\n * A drag-and-drop file upload zone with a keyboard-accessible browse button.\n *\n * The component owns presentation, drag tracking and local validation\n * (`accept`, `maxSizeBytes`); the consumer owns the upload itself and drives\n * `state` and `percent`. Drag and drop is pointer-only by nature, so the\n * button inside the zone is the equivalent path for everyone else and is the\n * affordance exposed to the accessibility tree.\n *\n * @param props - The component props.\n * @returns The MrlFileUpload component.\n */\nexport function MrlFileUpload(props: MrlFileUploadProps): React.ReactElement {\n\tconst {\n\t\taccept = fileUploadDefaults.accept,\n\t\tclassName,\n\t\terrorMessage,\n\t\teventId,\n\t\tfileName,\n\t\theading = fileUploadDefaults.heading,\n\t\thelperText,\n\t\tlabel,\n\t\tmaxSizeBytes,\n\t\tonCancel,\n\t\tonError,\n\t\tonFilesSelected,\n\t\tonRemove,\n\t\tpercent = 0,\n\t\tshowHelperText = fileUploadDefaults.showHelperText,\n\t\tshowInlineAlert = fileUploadDefaults.showInlineAlert,\n\t\tstate = fileUploadDefaults.state,\n\t\tvalidate,\n\t\t['data-qa']: dataQa,\n\t\t...rest\n\t} = props;\n\n\tconst [isDragging, setIsDragging] = React.useState(false);\n\tconst [validationError, setValidationError] = React.useState<string | null>(null);\n\tconst [selectedName, setSelectedName] = React.useState<string | null>(null);\n\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\t// The action button of whichever view is showing — Browse, Cancel or Remove.\n\tconst actionRef = React.useRef<HTMLButtonElement>(null);\n\t// Armed when an interaction puts focus on that button, so the next view swap\n\t// can hand it back rather than dropping it.\n\tconst shouldRestoreFocus = React.useRef(false);\n\t// dragenter/dragleave fire for descendants too; counting keeps the state stable.\n\tconst dragDepth = React.useRef(0);\n\n\tconst reactId = React.useId();\n\tconst labelId = `${reactId}-label`;\n\tconst messageId = `${reactId}-message`;\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlFileUpload', eventId);\n\n\tconst isDisabled = state === 'disabled';\n\t// A failed local validation outranks the consumer's state: no upload started.\n\t// A disabled zone outranks both — it cannot have accepted a file.\n\tconst effectiveState: MrlFileUploadState = isDisabled\n\t\t? 'disabled'\n\t\t: validationError\n\t\t\t? 'error'\n\t\t\t: state;\n\tconst displayName = fileName ?? selectedName ?? '';\n\t// `||` rather than `??`: an empty message is as good as no message, and has\n\t// to fall through — to the consumer's `errorMessage`, and then to the\n\t// default below — or an errored zone renders with no text at all.\n\tconst displayError = validationError || errorMessage || null;\n\t// An errored zone always carries text. The types forbid reporting 'error'\n\t// without a message, but a JavaScript consumer can still reach it, and colour\n\t// alone reaches neither assistive technology nor anyone who cannot see the hue.\n\tconst resolvedError =\n\t\teffectiveState === 'error' ? (displayError ?? DEFAULT_ERROR_MESSAGE) : displayError;\n\t// Derived rather than defaulted, so the copy cannot contradict what validation\n\t// enforces — and so the size limit is stated before it rejects anyone.\n\tconst resolvedHelperText = helperText ?? describeConstraints(accept, maxSizeBytes);\n\tconst isBusy = effectiveState === 'uploading';\n\n\t/**\n\t * Validates a file — against `accept` and `maxSizeBytes`, then against the\n\t * consumer's own `validate` — and hands it over, or reports why it was\n\t * rejected. Emits exactly one analytics event per selection.\n\t *\n\t * @param file - the file the user chose or dropped\n\t * @param source - how the file arrived, for analytics only\n\t */\n\tconst acceptFile = React.useCallback(\n\t\t(file: File | undefined, source: 'browse' | 'drop') => {\n\t\t\tif (!file) return;\n\n\t\t\tlet rejection: string | null = null;\n\n\t\t\tif (!isAccepted(file, accept)) {\n\t\t\t\t// The rule that rejected the file is the only reliable source for what\n\t\t\t\t// would be accepted; a hand-written list drifts away from `accept`.\n\t\t\t\tconst types = formatAcceptList(accept);\n\t\t\t\trejection = types\n\t\t\t\t\t? `File type is not valid. Accepted types: ${types}`\n\t\t\t\t\t: 'File type is not valid';\n\t\t\t} else if (maxSizeBytes !== undefined && file.size > maxSizeBytes) {\n\t\t\t\trejection = `File is larger than ${formatBytes(maxSizeBytes)}`;\n\t\t\t} else {\n\t\t\t\t// The consumer's rules run last, so a file that fails the component's\n\t\t\t\t// own checks never reaches them.\n\t\t\t\trejection = validate?.(file) ?? null;\n\t\t\t}\n\n\t\t\t// The file's name, size and type are consumer data and are never emitted.\n\t\t\ttrackInteraction({\n\t\t\t\taction: 'select',\n\t\t\t\tmetadata: { outcome: rejection ? 'rejected' : 'accepted', source }\n\t\t\t});\n\n\t\t\tif (rejection) {\n\t\t\t\tsetSelectedName(file.name);\n\t\t\t\tsetValidationError(rejection);\n\t\t\t\tonError?.(rejection, file);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetSelectedName(file.name);\n\t\t\tsetValidationError(null);\n\t\t\t// A browse selection leaves focus on the Browse button, which the consumer\n\t\t\t// is about to unmount by moving to 'uploading'. A drop does not: it is\n\t\t\t// pointer-only, and focus was never in the zone to begin with.\n\t\t\tif (source === 'browse') shouldRestoreFocus.current = true;\n\t\t\tonFilesSelected?.(file);\n\t\t},\n\t\t[accept, maxSizeBytes, onError, onFilesSelected, trackInteraction, validate]\n\t);\n\n\t/**\n\t * Returns the zone to its resting state and clears the native input so the\n\t * same file can be chosen again.\n\t */\n\tconst reset = React.useCallback(() => {\n\t\tdragDepth.current = 0;\n\t\tsetIsDragging(false);\n\t\tsetSelectedName(null);\n\t\tsetValidationError(null);\n\t\tif (inputRef.current) inputRef.current.value = '';\n\t}, []);\n\n\tconst handleBrowse = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tinputRef.current?.click();\n\t}, [isDisabled]);\n\n\tconst handleCancel = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tshouldRestoreFocus.current = true;\n\t\ttrackInteraction({ action: 'click', metadata: { control: 'cancel' } });\n\t\treset();\n\t\tonCancel?.();\n\t}, [isDisabled, onCancel, reset, trackInteraction]);\n\n\tconst handleRemove = React.useCallback(() => {\n\t\tif (isDisabled) return;\n\t\tshouldRestoreFocus.current = true;\n\t\ttrackInteraction({ action: 'clear', metadata: { control: 'remove' } });\n\t\treset();\n\t\tonRemove?.();\n\t}, [isDisabled, onRemove, reset, trackInteraction]);\n\n\tconst handleDragEnter = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current += 1;\n\t\t\tsetIsDragging(true);\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDragOver = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\t// Required, or the browser treats the drop as navigation and opens the file.\n\t\t\tevent.preventDefault();\n\t\t\tevent.dataTransfer.dropEffect = 'copy';\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDragLeave = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current = Math.max(0, dragDepth.current - 1);\n\t\t\t// Leaving without dropping restores the previous view rather than resetting,\n\t\t\t// so a completed or errored zone is not cleared by a passing cursor.\n\t\t\tif (dragDepth.current === 0) setIsDragging(false);\n\t\t},\n\t\t[isDisabled, isBusy]\n\t);\n\n\tconst handleDrop = React.useCallback(\n\t\t(event: React.DragEvent<HTMLDivElement>) => {\n\t\t\tif (isDisabled || isBusy) return;\n\t\t\tevent.preventDefault();\n\t\t\tdragDepth.current = 0;\n\t\t\tsetIsDragging(false);\n\t\t\tacceptFile(event.dataTransfer.files?.[0], 'drop');\n\t\t},\n\t\t[acceptFile, isDisabled, isBusy]\n\t);\n\n\tconst handleInputChange = React.useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tconst file = event.target.files?.[0];\n\t\t\t// Cleared before validating: the native control fires `change` only when\n\t\t\t// the selection changes, so re-picking a corrected file would be silent.\n\t\t\tevent.target.value = '';\n\t\t\tacceptFile(file, 'browse');\n\t\t},\n\t\t[acceptFile]\n\t);\n\n\tconst view = isDragging ? 'dragging' : effectiveState;\n\n\t/*\n\t * Each view renders its action button at a different position inside the zone,\n\t * so React unmounts one and mounts another rather than reusing it, and the\n\t * browser drops focus to the body — sending a keyboard user back to the top of\n\t * the page mid-task. Hand focus to the button that replaced it, but only when\n\t * it was genuinely lost: never take it from someone who has tabbed away.\n\t */\n\tReact.useLayoutEffect(() => {\n\t\tif (!shouldRestoreFocus.current) return;\n\n\t\tconst focusWasLost = !document.activeElement || document.activeElement === document.body;\n\t\tshouldRestoreFocus.current = false;\n\n\t\tif (focusWasLost) {\n\t\t\tactionRef.current?.focus();\n\t\t\t// Focus is inside the zone again, so keep the chain armed for the next\n\t\t\t// swap — an upload the consumer completes on its own included.\n\t\t\tshouldRestoreFocus.current = true;\n\t\t}\n\t}, [view]);\n\n\t/* eslint-disable sort-keys */\n\tconst zoneClasses = classnames({\n\t\t[styles['MrlFileUpload-zone']]: true,\n\t\t'MrlFileUpload-zone': true,\n\t\t[styles[`MrlFileUpload-zone--${view}`]]: view !== 'idle'\n\t});\n\t/* eslint-enable sort-keys */\n\n\tconst inlineKind = resolvedError ? 'error' : 'helper';\n\tconst inlineMessage = resolvedError ?? (showInlineAlert ? resolvedHelperText : null);\n\n\tconst announcement = () => {\n\t\tif (effectiveState === 'uploading') {\n\t\t\t// Quantised to 10% steps. A live region queues announcements rather than\n\t\t\t// replacing them, so narrating every tick buries 'upload successful'\n\t\t\t// behind a backlog that is usually discarded before it is spoken.\n\t\t\tconst step = Math.floor(Math.round(percent) / 10) * 10;\n\t\t\treturn `Uploading ${displayName}, ${step}%`;\n\t\t}\n\t\tif (effectiveState === 'complete') return `Upload of ${displayName} successful`;\n\t\tif (effectiveState === 'error' && resolvedError) {\n\t\t\t// Prefixed with the file name so two failures for the same reason are two\n\t\t\t// different strings: a live region re-set to the same text stays silent.\n\t\t\treturn displayName ? `${displayName}: ${resolvedError}` : resolvedError;\n\t\t}\n\t\treturn '';\n\t};\n\n\tconst restingContent = (\n\t\t<>\n\t\t\t<div className={classnames(styles['MrlFileUpload-content'], 'MrlFileUpload-content')}>\n\t\t\t\t<p className={classnames(styles['MrlFileUpload-heading'], 'MrlFileUpload-heading')}>\n\t\t\t\t\t{heading}\n\t\t\t\t</p>\n\t\t\t\t{showHelperText && resolvedHelperText && (\n\t\t\t\t\t<MrlText size=\"small\">{resolvedHelperText}</MrlText>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<MrlButton\n\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\tkind=\"secondary\"\n\t\t\t\tref={actionRef}\n\t\t\t\tsize=\"small\"\n\t\t\t\tstate={isDisabled ? 'disabled' : 'default'}\n\t\t\t\ttext=\"Browse files\"\n\t\t\t\tonClick={handleBrowse}\n\t\t\t/>\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tdata-qa={dataQa}\n\t\t\tclassName={classnames(styles['MrlFileUpload'], 'MrlFileUpload', className)}\n\t\t>\n\t\t\t{label && (\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(styles['MrlFileUpload-label'], 'MrlFileUpload-label')}\n\t\t\t\t\tid={labelId}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t)}\n\n\t\t\t<div\n\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\taria-disabled={isDisabled || undefined}\n\t\t\t\taria-label={label ? undefined : heading}\n\t\t\t\taria-labelledby={label ? labelId : undefined}\n\t\t\t\tclassName={zoneClasses}\n\t\t\t\trole=\"group\"\n\t\t\t\tonDragEnter={handleDragEnter}\n\t\t\t\tonDragLeave={handleDragLeave}\n\t\t\t\tonDragOver={handleDragOver}\n\t\t\t\tonDrop={handleDrop}\n\t\t\t>\n\t\t\t\t{(view === 'idle' || view === 'error' || view === 'disabled') && restingContent}\n\n\t\t\t\t{view === 'dragging' && (\n\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon'],\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon--accent']\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\t\tsvg={importIcon}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--accent']\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\tDrop your files\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\n\t\t\t\t{view === 'uploading' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-progress'])}>\n\t\t\t\t\t\t\t\t<MrlProgressBar\n\t\t\t\t\t\t\t\t\tname={`Uploading ${displayName || 'file'}`}\n\t\t\t\t\t\t\t\t\tpercent={Math.round(percent) as ProgressRange}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--strong']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tUploading {displayName}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\t\t\t\tkind=\"secondary\"\n\t\t\t\t\t\t\tref={actionRef}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ttext=\"Cancel\"\n\t\t\t\t\t\t\tonClick={handleCancel}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\n\t\t\t\t{view === 'complete' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className={classnames(styles['MrlFileUpload-preloader'])}>\n\t\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-icon--success']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\t\t\tsvg={check}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading'],\n\t\t\t\t\t\t\t\t\tstyles['MrlFileUpload-heading--strong']\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\tUpload of {displayName} successful!\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\taria-describedby={inlineMessage ? messageId : undefined}\n\t\t\t\t\t\t\tkind=\"secondary\"\n\t\t\t\t\t\t\tref={actionRef}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\ttext=\"Remove\"\n\t\t\t\t\t\t\tonClick={handleRemove}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{inlineMessage && (\n\t\t\t\t<MrlInlineMessage id={messageId} kind={inlineKind} message={inlineMessage} />\n\t\t\t)}\n\n\t\t\t{/*\n\t\t\t * The real control, opened by the \"Browse files\" button. It is removed from\n\t\t\t * the tab order and the accessibility tree deliberately: the button is the\n\t\t\t * accessible affordance, and a focusable invisible input would be a keyboard\n\t\t\t * trap with no visible focus ring. Do not make it focusable.\n\t\t\t */}\n\t\t\t<input\n\t\t\t\taccept={accept || undefined}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tclassName={classnames(styles['MrlFileUpload-input'])}\n\t\t\t\tdisabled={isDisabled}\n\t\t\t\tref={inputRef}\n\t\t\t\ttabIndex={-1}\n\t\t\t\ttype=\"file\"\n\t\t\t\tonChange={handleInputChange}\n\t\t\t/>\n\n\t\t\t<MrlLiveRegion ariaLive=\"polite\" srContent={announcement()} />\n\t\t</div>\n\t);\n}\n"],"names":["MrlFileUpload","props","_ref","_props$accept","accept","fileUploadDefaults","className","errorMessage","eventId","fileName","_props$heading","heading","helperText","label","maxSizeBytes","onCancel","onError","onFilesSelected","onRemove","_props$percent","percent","_props$showHelperText","showHelperText","_props$showInlineAler","showInlineAlert","_props$state","state","validate","dataQa","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","isDragging","setIsDragging","_React$useState3","_React$useState4","validationError","setValidationError","_React$useState5","_React$useState6","selectedName","setSelectedName","inputRef","useRef","actionRef","shouldRestoreFocus","dragDepth","reactId","useId","labelId","concat","messageId","trackInteraction","useMrlTrackInteraction","isDisabled","effectiveState","displayName","displayError","resolvedError","DEFAULT_ERROR_MESSAGE","resolvedHelperText","describeConstraints","isBusy","acceptFile","useCallback","file","source","rejection","isAccepted","types","formatAcceptList","undefined","size","formatBytes","_validate","action","metadata","outcome","name","current","reset","value","handleBrowse","_inputRef$current","click","handleCancel","control","handleRemove","handleDragEnter","event","preventDefault","handleDragOver","dataTransfer","dropEffect","handleDragLeave","Math","max","handleDrop","_event$dataTransfer$f","files","handleInputChange","_event$target$files","target","view","useLayoutEffect","focusWasLost","document","activeElement","body","_actionRef$current","focus","zoneClasses","classnames","styles","inlineKind","inlineMessage","announcement","step","floor","round","restingContent","createElement","Fragment","MrlText","MrlButton","kind","ref","text","onClick","_extends","id","role","onDragEnter","onDragLeave","onDragOver","onDrop","MrlSvg","svg","importIcon","MrlProgressBar","check","MrlInlineMessage","message","disabled","tabIndex","type","onChange","MrlLiveRegion","ariaLive","srContent"],"mappings":";;;;;;;;;;;;;;;;;AAgBA;AACA;AACA;;AAuBA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAACC,KAAyB,EAAsB;AAAA,EAAA,IAAAC,IAAA;AAC5E,EAAA,IAAAC,aAAA,GAqBIF,KAAK,CApBRG,MAAM;AAANA,IAAAA,MAAM,GAAAD,aAAA,KAAA,MAAA,GAAGE,kBAAkB,CAACD,MAAM,GAAAD,aAAA;IAClCG,SAAS,GAmBNL,KAAK,CAnBRK,SAAS;IACTC,YAAY,GAkBTN,KAAK,CAlBRM,YAAY;IACZC,OAAO,GAiBJP,KAAK,CAjBRO,OAAO;IACPC,QAAQ,GAgBLR,KAAK,CAhBRQ,QAAQ;IAAAC,cAAA,GAgBLT,KAAK,CAfRU,OAAO;AAAPA,IAAAA,OAAO,GAAAD,cAAA,KAAA,MAAA,GAAGL,kBAAkB,CAACM,OAAO,GAAAD,cAAA;IACpCE,UAAU,GAcPX,KAAK,CAdRW,UAAU;IACVC,KAAK,GAaFZ,KAAK,CAbRY,KAAK;IACLC,YAAY,GAYTb,KAAK,CAZRa,YAAY;IACZC,QAAQ,GAW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AAE,EAAG;AACbC,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,QAAQ,EAAE9C;AAAkB,GAC5B,CAAC,eAEFxE,KAAA,CAAA6F,aAAA,CAAC0B,aAAa,EAAA;AAACC,IAAAA,QAAQ,EAAC,QAAQ;IAACC,SAAS,EAAEjC,YAAY;AAAG,GAAE,CACzD,CAAC;AAER;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MrlMenu.js","sources":["../../../../../src/components/menu/MrlMenu/MrlMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MrlPortal, PortalProps } from '../../portal/MrlPortal';\nimport { useTriggerPosition } from '../../../hooks/useTriggerPosition';\nimport { useClickOutside } from '../../../hooks/useClickOutside';\nimport { useSubMenuElementPosition } from '../hooks/useSubMenuElementPosition';\nimport {\n\tMenuPosition,\n\tMenuAlignment,\n\tActionState,\n\tActionType,\n\tCustomMenuPosition\n} from '../constants';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport {\n\tfindAdjacentInteractiveElement,\n\tpreventDefault,\n\tisElementAriaDisabled\n} from '../../../utils';\nimport classnames from 'classnames';\nimport { MrlMenuContext } from '../context/MrlMenuContext';\nimport styles from './MrlMenu.module.scss';\nimport itemStyles from '../MrlMenuItem/MrlMenuItem.module.scss';\nimport { useTransition, animated } from '@react-spring/web';\nimport { isTouchDevice } from '../../../utils/isTouch';\nimport { getScrollableParent } from '../utilities/get-scrollable-parent';\nimport { useMenuScroll } from '../hooks/useMenuScroll';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport interface MrlMenuProps {\n\t/** Custom position for the menu */\n\tcustomPosition?: CustomMenuPosition;\n\n\t/** Children to be rendered within the menu component*/\n\tchildren: React.ReactNode;\n\n\t/** Event to close the menu */\n\tclickOutsideEvent?: 'mousedown' | 'mouseup' | 'click';\n\n\t/**\n\t * Enables closing the menu when scrolling. Default is false.\n\t *\n\t */\n\tcloseOnScroll?: boolean;\n\n\t/**\n\t * Private closeParent prop for use with MrlMenuItem\n\t *\n\t * !!! Please do not use this prop directly, it is only used internally by MrlMenuItem !!!\n\t * @private\n\t */\n\tcloseParent?: () => void;\n\n\t/**\n\t * Disable arrows from opening the menu\n\t * - This is useful when you want to disable the default browser behavior of opening a menu on arrow down.\n\t *\n\t * Example usage: the menu is within a vertical toolbar and you want to use the arrow keys to navigate the toolbar.\n\t * By using this prop you can disable the arrow key open/close so that navigating the toolbar does not conflict\n\t * with opening/closing the menu.\n\t */\n\tdisableArrowOpen?: boolean;\n\n\t/**\n\t * Disable flipping of the menu when it goes off the screen\n\t * @default false\n\t */\n\tdisableFlipping?: boolean;\n\n\t/** Unique identifier for the menu */\n\tid?: string;\n\n\t/**\n\t * Use when the menu is embedded within another component\n\t * Removes the following styles:\n\t * - padding on the menu\n\t * - drop shadow and border\n\t * @default false\n\t */\n\tisInternal?: boolean;\n\n\t/**\n\t * Private isSubMenu prop for use with MrlMenuItem\n\t *\n\t * !!! Please do not use this prop directly, it is only used internally by MrlMenuItem !!!\n\t * @private\n\t */\n\tisSubMenu?: boolean;\n\n\t/**\n\t * spacing of menu\n\t * - compact has less padding\n\t * @default 'default'\n\t */\n\tspacing?: 'default' | 'compact';\n\n\t/**\n\t * Offset of the menu from the trigger element in pixels\n\t * @default 10px\n\t */\n\tmenuOffset?: number;\n\n\t/**\n\t * Configuration for the portal component\n\t */\n\tportalProps?: Omit<PortalProps, 'children'>;\n\n\t/**\n\t * Horizontal and vertical alignment of the menu relative to the trigger element\n\t * - position 'left', 'right', 'top', 'bottom' position relative to the trigger\n\t * - position 'static' renders the menu in place, not using the portal\n\t * - position 'ignore' will not position the menu, allowing you to use the customPosition prop to position the element\n\t * @default 'bottom'\n\t */\n\tposition?: MenuPosition;\n\n\t/**\n\t * Set initial state of menu\n\t * @default { actionType: null, isOpen: false }\n\t */\n\tactionState?: ActionState;\n\n\t/**\n\t * Reference to the DOM element that triggers this menu.\n\t */\n\ttriggerRef?: React.RefObject<HTMLButtonElement>;\n\n\t/**\n\t * Trigger stop propagation on click\n\t *\n\t * In some instances we may want the trigger element to stop propogation to the\n\t * rest of the DOM. Use this flag to enable and disable it.\n\t * @default false\n\t */\n\ttriggerStopPropagation?: boolean;\n\n\t/**\n\t * Vertical and horizontal alignment of the menu relative to the position of the menu with the trigger\n\t * - 'left' and 'right' work with position 'top' and 'bottom'\n\t * - 'top' and 'bottom' work with position 'left' and 'right'\n\t * - 'center' works with all positions\n\t *\n\t * This does not impact submenus\n\t */\n\talignment?: MenuAlignment;\n\n\t/**\n\t * Callback to be called when the menu is closed\n\t * @param type - type of close event\n\t */\n\tonClose?: (type?: string) => void;\n\n\t/**\n\t * Enables interaction tracking for this menu. Provide a stable, non-PII id\n\t * (e.g. 'mural-context-menu'). When omitted, the menu emits no analytics.\n\t */\n\teventId?: string;\n}\n\nconst MENU_ITEM_SELECTOR = '[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]';\n\n/**\n * MrlMenu component\n *\n * Renders a menu component with alignment relative to a trigger element\n * @param {MrlMenuProps} props - The props for the MrlMenu component\n * @returns {Element} - rendered MrlMenu component\n */\nexport function MrlMenu({\n\tactionState = { actionType: null, isOpen: false },\n\talignment = 'center',\n\tchildren,\n\tcloseOnScroll = false,\n\tcloseParent,\n\tcustomPosition,\n\tclickOutsideEvent = 'mouseup',\n\tdisableArrowOpen,\n\tdisableFlipping = false,\n\tid,\n\tisInternal = false,\n\tisSubMenu = false,\n\tspacing = 'default',\n\tmenuOffset = 10,\n\tportalProps = { id: PORTAL_LAYERS.MENU.name },\n\tposition = 'bottom',\n\ttriggerStopPropagation = false,\n\tonClose,\n\teventId,\n\ttriggerRef,\n\t...remainingProps\n}: MrlMenuProps): JSX.Element {\n\tconst defaultOpenState = position === 'static' || false;\n\n\tconst [state, setState] = React.useState({\n\t\tactionType: null,\n\t\tisOpen: defaultOpenState\n\t} as ActionState);\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlMenu', eventId);\n\t// the menu opens and closes from several paths (click, keyboard, hover, click outside),\n\t// so open/close is emitted from the resulting state rather than each individual handler.\n\tconst wasOpenRef = React.useRef(defaultOpenState);\n\n\tReact.useEffect(() => {\n\t\tif (wasOpenRef.current === state.isOpen) return;\n\n\t\twasOpenRef.current = state.isOpen;\n\n\t\ttrackInteraction({\n\t\t\taction: state.isOpen ? 'open' : 'close',\n\t\t\tmetadata: { isSubMenu, trigger: state.actionType ?? 'unknown' },\n\t\t\tvariant: position\n\t\t});\n\t}, [state.isOpen, state.actionType, isSubMenu, position, trackInteraction]);\n\n\tconst menuRef = React.useRef<HTMLDivElement>(null);\n\tconst listRef = React.useRef<HTMLUListElement>(null);\n\tconst [menuItems, setMenuItems] = React.useState<HTMLButtonElement[]>([]);\n\tconst [menuRect, setMenuRect] = React.useState<DOMRect | null>(null);\n\n\t/**\n\t * Checks if the trigger element is disabled\n\t * @returns {boolean} - true if the trigger element is disabled, false otherwise\n\t */\n\tconst isTriggerDisabled = React.useCallback((): boolean => {\n\t\treturn isElementAriaDisabled(triggerRef?.current);\n\t}, [triggerRef]);\n\n\t/**\n\t * Sets up trigger event listeners to open and close the menu\n\t * @param e - mouse event\n\t */\n\tconst toggleMenuTrigger = React.useCallback(\n\t\t(e: MouseEvent) => {\n\t\t\tif (isTriggerDisabled()) return;\n\n\t\t\tif (triggerStopPropagation) {\n\t\t\t\tpreventDefault(e);\n\t\t\t}\n\n\t\t\tsetState((prevState) => ({ actionType: 'click', isOpen: !prevState.isOpen }));\n\t\t},\n\t\t[triggerStopPropagation, isTriggerDisabled]\n\t);\n\n\t/**\n\t * Used to display the menu when hovering over a menu item that has a submenu\n\t */\n\tconst showMenuHover = React.useCallback(() => {\n\t\tsetState({ actionType: 'click', isOpen: true });\n\t}, []);\n\n\tconst showMenuTap = React.useCallback(() => {\n\t\tsetState((prevState) => ({ actionType: 'click', isOpen: !prevState.isOpen }));\n\t}, []);\n\n\tconst hideMenuHover = React.useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tconst relatedTarget = event.relatedTarget as Node;\n\n\t\t\t// If the related target is not a child of the menu, close the menu\n\t\t\t// This prevents the menu from closing when hovering over a submenu item or trigger\n\t\t\tif (\n\t\t\t\ttriggerRef &&\n\t\t\t\tmenuRef.current &&\n\t\t\t\t!menuRef.current.contains(relatedTarget) &&\n\t\t\t\ttriggerRef.current &&\n\t\t\t\t!triggerRef.current.contains(relatedTarget)\n\t\t\t) {\n\t\t\t\tsetState({ actionType: null, isOpen: false });\n\t\t\t}\n\t\t},\n\t\t[triggerRef]\n\t);\n\n\t/**\n\t * Sets up trigger event listeners to open and close the menu with a keyboard\n\t */\n\tconst toggleMenuKey = React.useCallback(\n\t\t(e: KeyboardEvent) => {\n\t\t\tconst openMenu = () => {\n\t\t\t\tif (isTriggerDisabled()) return;\n\t\t\t\tsetState({ actionType: e.key as ActionType, isOpen: true });\n\t\t\t};\n\n\t\t\tif (!state.isOpen) {\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\tswitch (e.key) {\n\t\t\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\t\tcase 'Enter':\n\t\t\t\t\t\tcase ' ':\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\topenMenu();\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tswitch (e.key) {\n\t\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\t\tif (!disableArrowOpen && !isTriggerDisabled()) {\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\topenMenu();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Enter':\n\t\t\t\t\tcase ' ':\n\t\t\t\t\t\tif (isTriggerDisabled()) return;\n\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\topenMenu();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[state.isOpen, isTriggerDisabled, disableArrowOpen, isSubMenu]\n\t);\n\n\tconst closeMenu = React.useCallback(\n\t\t(shouldCloseParent = true) => {\n\t\t\tif (position === 'static') return;\n\n\t\t\t/**\n\t\t\t * What is closeParent?\n\t\t\t *\n\t\t\t * It is passed from the context provider to the MenuItem (which helps render our submenus)\n\t\t\t * When we render the submenu, we pass the closeMenu function as \"closeParent\" to the submenu.\n\t\t\t * This allows us to trigger closing the parent menu when the submenu is closed. And that's\n\t\t\t * what this call is for.\n\t\t\t */\n\t\t\tif (shouldCloseParent && closeParent) closeParent();\n\n\t\t\tsetState({ actionType: null, isOpen: false });\n\t\t\tonClose?.();\n\t\t},\n\t\t[position, closeParent, onClose]\n\t);\n\n\t/**\n\t * Click outside to dismiss the menu\n\t * @param e\n\t */\n\tconst disableClickOutside = !state.isOpen || position === 'static';\n\tuseClickOutside(menuRef, triggerRef, clickOutsideEvent, closeMenu, disableClickOutside);\n\n\tconst handleMenuKeyUp = (e: React.KeyboardEvent) => {\n\t\tconst actions: ActionType[] = ['ArrowUp', 'ArrowDown', 'ArrowRight', 'Enter', 'Escape', ' '];\n\n\t\tif (actions.includes(e.key as ActionType)) {\n\t\t\tpreventDefault(e);\n\t\t}\n\t};\n\n\t/**\n\t * Focus management when someone is using a keyboard to navigate the menu\n\t * @param e - keyboard event\n\t */\n\tconst handleMenuKey = (e: React.KeyboardEvent) => {\n\t\tconst currentIndex = menuItems.findIndex((item) => document.activeElement === item);\n\t\tlet nextIndex: number;\n\n\t\tif (state.isOpen) {\n\t\t\tswitch (e.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tnextIndex = currentIndex < menuItems.length - 1 ? currentIndex + 1 : currentIndex;\n\t\t\t\t\tmenuItems[nextIndex]?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tnextIndex = currentIndex > 0 ? currentIndex - 1 : 0;\n\t\t\t\t\tmenuItems[nextIndex]?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Escape':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\ttriggerRef?.current?.focus();\n\t\t\t\t\tcloseMenu(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Tab':\n\t\t\t\t\tif (!isSubMenu && position !== 'static') {\n\t\t\t\t\t\tif (e.shiftKey) {\n\t\t\t\t\t\t\t// Handle shift + tab: move focus to the previous item\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\tif (triggerRef) {\n\t\t\t\t\t\t\t\tconst prevElement = findAdjacentInteractiveElement(triggerRef, 'previous');\n\t\t\t\t\t\t\t\tprevElement?.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Regular tab: close the menu or move to the next item\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\tif (triggerRef) {\n\t\t\t\t\t\t\t\tconst nextElement = findAdjacentInteractiveElement(triggerRef);\n\t\t\t\t\t\t\t\tnextElement?.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcloseMenu();\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * useEffect hooks to handle menu state changes\n\t */\n\n\tReact.useEffect(() => {\n\t\tif (triggerRef?.current) {\n\t\t\ttriggerRef.current.setAttribute('aria-haspopup', 'menu');\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\tReact.useEffect(() => {\n\t\tif (position === 'static') {\n\t\t\tsetState({ actionType: 'click', isOpen: true });\n\t\t}\n\t}, [position]);\n\n\tReact.useEffect(() => {\n\t\ttriggerRef?.current?.setAttribute('aria-expanded', state.isOpen.toString());\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen]);\n\n\tReact.useEffect(() => {\n\t\tif (!isSubMenu && position !== 'static')\n\t\t\tsetState({ actionType: actionState.actionType, isOpen: actionState.isOpen });\n\t}, [actionState.isOpen, actionState.actionType, isSubMenu, position]);\n\n\t// setup event handlers for mouse, keyboard, and scroll interactions\n\tReact.useEffect(() => {\n\t\tconst triggerElement = triggerRef?.current;\n\t\tconst menuElement = menuRef?.current;\n\t\tconst menuItems = menuElement?.querySelectorAll(MENU_ITEM_SELECTOR);\n\n\t\tlet scrollableParent: HTMLElement | Window;\n\n\t\tif (triggerElement) {\n\t\t\ttriggerElement.addEventListener('mousedown', preventDefault);\n\t\t\tif (!isSubMenu) triggerElement.addEventListener('click', toggleMenuTrigger);\n\t\t\ttriggerElement.addEventListener('keydown', toggleMenuKey);\n\n\t\t\t// Setup event listeners for when the menu is a submenu\n\t\t\tif (isSubMenu) {\n\t\t\t\ttriggerElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\ttriggerElement.addEventListener('mouseout', hideMenuHover);\n\n\t\t\t\tif (isTouchDevice()) {\n\t\t\t\t\ttriggerElement.addEventListener('touchend', showMenuTap);\n\t\t\t\t}\n\n\t\t\t\tif (menuElement) {\n\t\t\t\t\tmenuElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\t\tmenuElement.addEventListener('mouseout', hideMenuHover);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (closeOnScroll) {\n\t\t\t\tscrollableParent = getScrollableParent(triggerElement);\n\t\t\t\tif (scrollableParent) {\n\t\t\t\t\tscrollableParent.addEventListener('scroll', () => closeMenu(), {\n\t\t\t\t\t\tcapture: true,\n\t\t\t\t\t\tpassive: true\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\ttriggerElement.removeEventListener('mousedown', preventDefault);\n\t\t\t\tif (!isSubMenu) triggerElement.removeEventListener('click', toggleMenuTrigger);\n\t\t\t\ttriggerElement.removeEventListener('keydown', toggleMenuKey);\n\n\t\t\t\tif (menuItems) {\n\t\t\t\t\tmenuItems.forEach((item: Element) => {\n\t\t\t\t\t\tif (!item.getAttribute('aria-haspopup')) {\n\t\t\t\t\t\t\titem.removeEventListener('mousedown', () => closeMenu());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\ttriggerElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\ttriggerElement.removeEventListener('mouseout', hideMenuHover);\n\n\t\t\t\t\tif (isTouchDevice()) {\n\t\t\t\t\t\ttriggerElement.removeEventListener('touchstart', showMenuHover);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (menuElement) {\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseout', hideMenuHover);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (closeOnScroll && scrollableParent) {\n\t\t\t\t\tscrollableParent.removeEventListener('scroll', () => closeMenu());\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}, [\n\t\tcloseOnScroll,\n\t\tisSubMenu,\n\t\ttriggerRef,\n\t\ttoggleMenuTrigger,\n\t\ttoggleMenuKey,\n\t\tshowMenuHover,\n\t\thideMenuHover,\n\t\tcloseMenu,\n\t\tshowMenuTap\n\t]);\n\n\t// This use effect handles a few things when we open the menu:\n\t// - making sure that the menu component is aware of it's menu items\n\t// - adding a class to the trigger element when the submenu is open for styling\n\t// - storing the menu rect in state for positioning calculations\n\tReact.useEffect(() => {\n\t\tif (state.isOpen) {\n\t\t\tconst foundMenuItems = Array.from(\n\t\t\t\tmenuRef.current?.querySelectorAll(MENU_ITEM_SELECTOR) || []\n\t\t\t) as HTMLButtonElement[];\n\n\t\t\tsetMenuItems(foundMenuItems);\n\t\t}\n\n\t\tif (state.isOpen && isSubMenu) {\n\t\t\ttriggerRef?.current?.classList.add(itemStyles['MrlMenuItem--item--submenuOpen']);\n\t\t} else if (!state.isOpen && isSubMenu) {\n\t\t\ttriggerRef?.current?.classList.remove(itemStyles['MrlMenuItem--item--submenuOpen']);\n\t\t}\n\n\t\t// For consistent submenu calculations, we are storing the menu rect in state\n\t\t// Anytime we need to use the menu rect, we want to make sure the values are based\n\t\t// on the original state of the menu for proper transformations\n\t\tif (!menuRect && menuRef.current) {\n\t\t\tconst newRect = menuRef.current?.getBoundingClientRect();\n\t\t\tsetMenuRect(newRect || null);\n\t\t}\n\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, menuRect, isSubMenu]);\n\n\t/**\n\t * Focus management for when the menu is opening or closing\n\t */\n\tReact.useEffect(() => {\n\t\tif (menuItems.length > 0) {\n\t\t\tlet menuItemToFocus;\n\n\t\t\tswitch (state.actionType) {\n\t\t\t\tcase 'Enter':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\tcase ' ':\n\t\t\t\t\tmenuItemToFocus = menuItems[0];\n\t\t\t\t\tmenuItemToFocus?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tmenuItemToFocus = menuItems[menuItems.length - 1];\n\t\t\t\t\tmenuItemToFocus?.focus();\n\n\t\t\t\t\t// Scroll to the bottom of the menu when the last item is focused\n\t\t\t\t\t// setTimeout is required to ensure the element has been rendered\n\t\t\t\t\t// and the scrollHeight is accurate prior to scrolling\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tif (listRef.current) {\n\t\t\t\t\t\t\tlistRef.current.scrollTo(0, listRef.current.scrollHeight);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 20);\n\t\t\t}\n\n\t\t\tif (isSubMenu && state.actionType === 'ArrowRight') {\n\t\t\t\tmenuItemToFocus = menuItems[0];\n\t\t\t\tmenuItemToFocus?.focus();\n\t\t\t}\n\t\t}\n\t}, [isSubMenu, menuItems, state.actionType]);\n\n\t/**\n\t * Menu scroll behavior\n\t *\n\t * When the menu cannot fit in the preferred or flipped position,\n\t * this hook constrains the menu height and enables internal scrolling.\n\t * Called before useTriggerPosition so that isScrolling can disable flipping,\n\t * preventing the positioning hook from fighting the scroll constraint.\n\t */\n\tconst disableMenuScroll =\n\t\tisSubMenu || !state.isOpen || position === 'static' || position === 'ignore';\n\n\t/**\n\t * Sets overflow (scrolling) on menu when there is no space to display\n\t * the menu in the preferred or flipped position.\n\t */\n\tconst menuScroll = useMenuScroll(\n\t\ttriggerRef,\n\t\tlistRef,\n\t\tposition,\n\t\tmenuOffset,\n\t\tstate.isOpen,\n\t\tdisableMenuScroll\n\t);\n\n\t/**\n\t * Primary menu positioning, alignment, and transition styling\n\t *\n\t * This hook is only enabled if isSubMenu is FALSE\n\t */\n\tconst disableTriggerPosition = isSubMenu || !state.isOpen || position === 'static';\n\tconst menuPositionStyles = useTriggerPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\t{\n\t\t\talign: alignment,\n\t\t\tcustomPosition: customPosition,\n\t\t\tposition: position\n\t\t},\n\t\tstate.isOpen,\n\t\tmenuOffset,\n\t\tdisableTriggerPosition,\n\t\tdisableFlipping || menuScroll.isScrolling\n\t);\n\n\t/**\n\t * Submenu positioning and alignment\n\t *\n\t * This hook is only enabled if isSubMenu is TRUE\n\t */\n\tconst subMenuPosition = useSubMenuElementPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\tisSubMenu,\n\t\tstate.isOpen,\n\t\tmenuRect,\n\t\t// disable the subelement positioning if it's not a submenu\n\t\t!isSubMenu\n\t);\n\n\tconst inlineStyles = {\n\t\tmenu: {\n\t\t\tleft: menuPositionStyles.left,\n\t\t\tposition: 'fixed' as const,\n\t\t\ttop: menuPositionStyles.top\n\t\t},\n\t\tsubmenu: {\n\t\t\tleft: subMenuPosition.left,\n\t\t\ttop: subMenuPosition.top\n\t\t}\n\t};\n\n\t/**\n\t * React Spring transitions for the menu\n\t */\n\tconst transitionConfig = {\n\t\tconfig: { duration: state.isOpen ? 300 : 150 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' },\n\t\tfrom: { opacity: 0, transform: 'translateY(4px)' },\n\t\tleave: { opacity: 0, transform: 'translateY(4px)' }\n\t};\n\n\tconst transitionStatic = {\n\t\tconfig: { duration: 0 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' }\n\t};\n\n\tconst transitions = useTransition(\n\t\tstate.isOpen,\n\t\tposition === 'static' ? transitionStatic : transitionConfig\n\t);\n\n\tconst menuClasses = classnames(styles['MrlMenu'], 'MrlMenu', {\n\t\t[styles['MrlMenu--submenu']]: isSubMenu,\n\t\t[styles.open]: state.isOpen,\n\t\t[styles['MrlMenu--compact']]: spacing === 'compact',\n\t\t[styles['MrlMenu--static']]: position === 'static',\n\t\t[styles['MrlMenu--internal']]: isInternal,\n\t\t[styles['MrlMenu--scrolling']]: menuScroll.isScrolling,\n\t\t[styles['MrlMenu--ignore']]: position === 'ignore'\n\t});\n\n\tconst positionStyles = isSubMenu\n\t\t? inlineStyles.submenu\n\t\t: position !== 'static'\n\t\t\t? inlineStyles.menu\n\t\t\t: {};\n\n\tconst menuScrollStyles =\n\t\t(menuScroll.maxHeight !== undefined && { maxHeight: menuScroll.maxHeight }) || undefined;\n\n\tconst renderMenu = () => {\n\t\treturn (\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\n\t\t\t\t\t\t\t\tclassName={menuClasses}\n\t\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\t\tstyle={{ ...positionStyles, ...style }}\n\t\t\t\t\t\t\t\tonKeyUp={handleMenuKeyUp}\n\t\t\t\t\t\t\t\tonKeyDown={handleMenuKey}\n\t\t\t\t\t\t\t\tref={menuRef}\n\t\t\t\t\t\t\t\trole=\"none\"\n\t\t\t\t\t\t\t\t{...remainingProps}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ul ref={listRef} role=\"menu\" style={menuScrollStyles}>\n\t\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t\t</ul>\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</>\n\t\t);\n\t};\n\n\t// For managing and restoring focus to the original menu trigger\n\t// Ensures the triggerRef in context is always the parent triggerRef\n\tconst parentContext = React.useContext(MrlMenuContext);\n\tconst contextTriggerRef = isSubMenu ? parentContext?.triggerRef : triggerRef;\n\n\treturn (\n\t\t<MrlMenuContext.Provider\n\t\t\tvalue={{\n\t\t\t\tcloseMenu,\n\t\t\t\tcloseParent: !isSubMenu ? closeMenu : undefined,\n\t\t\t\ttriggerRef: contextTriggerRef\n\t\t\t}}\n\t\t>\n\t\t\t{isSubMenu || position === 'static' ? (\n\t\t\t\trenderMenu()\n\t\t\t) : (\n\t\t\t\t<MrlPortal layer={portalProps.layer || PORTAL_LAYERS.MENU} {...portalProps}>\n\t\t\t\t\t{renderMenu()}\n\t\t\t\t</MrlPortal>\n\t\t\t)}\n\t\t</MrlMenuContext.Provider>\n\t);\n\t/* eslint-enable */\n}\n\nMrlMenu.componentType = 'Menu';\n"],"names":["MENU_ITEM_SELECTOR","MrlMenu","_ref","_ref$actionState","actionState","actionType","isOpen","_ref$alignment","alignment","children","_ref$closeOnScroll","closeOnScroll","closeParent","customPosition","_ref$clickOutsideEven","clickOutsideEvent","disableArrowOpen","_ref$disableFlipping","disableFlipping","id","_ref$isInternal","isInternal","_ref$isSubMenu","isSubMenu","_ref$spacing","spacing","_ref$menuOffset","menuOffset","_ref$portalProps","portalProps","PORTAL_LAYERS","MENU","name","_ref$position","position","_ref$triggerStopPropa","triggerStopPropagation","onClose","eventId","triggerRef","remainingProps","_objectWithoutProperties","_excluded","defaultOpenState","_React$useState","React","useState","_React$useState2","_slicedToArray","state","setState","trackInteraction","useMrlTrackInteraction","wasOpenRef","useRef","useEffect","_state$actionType","current","action","metadata","trigger","variant","menuRef","listRef","_React$useState3","_React$useState4","menuItems","setMenuItems","_React$useState5","_React$useState6","menuRect","setMenuRect","isTriggerDisabled","useCallback","isElementAriaDisabled","toggleMenuTrigger","e","preventDefault","prevState","showMenuHover","showMenuTap","hideMenuHover","event","relatedTarget","contains","toggleMenuKey","openMenu","key","closeMenu","shouldCloseParent","arguments","length","undefined","disableClickOutside","useClickOutside","handleMenuKeyUp","actions","includes","handleMenuKey","_menuItems$nextIndex","_menuItems$nextIndex2","_triggerRef$current","currentIndex","findIndex","item","document","activeElement","nextIndex","focus","shiftKey","prevElement","findAdjacentInteractiveElement","nextElement","setAttribute","_triggerRef$current2","toString","triggerElement","menuElement","querySelectorAll","scrollableParent","addEventListener","isTouchDevice","getScrollableParent","capture","passive","removeEventListener","forEach","getAttribute","_menuRef$current","foundMenuItems","Array","from","_triggerRef$current3","classList","add","itemStyles","_triggerRef$current4","remove","_menuRef$current2","newRect","getBoundingClientRect","_menuItemToFocus","_menuItemToFocus2","menuItemToFocus","setTimeout","scrollTo","scrollHeight","_menuItemToFocus3","disableMenuScroll","menuScroll","useMenuScroll","disableTriggerPosition","menuPositionStyles","useTriggerPosition","align","isScrolling","subMenuPosition","useSubMenuElementPosition","inlineStyles","menu","left","top","submenu","transitionConfig","config","duration","enter","opacity","transform","leave","transitionStatic","transitions","useTransition","menuClasses","classnames","styles","open","positionStyles","menuScrollStyles","maxHeight","renderMenu","createElement","Fragment","style","animated","div","_extends","className","_objectSpread","onKeyUp","onKeyDown","ref","role","parentContext","useContext","MrlMenuContext","contextTriggerRef","Provider","value","MrlPortal","layer","componentType"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8JA,IAAMA,kBAAkB,GAAG,sEAAsE;;AAEjG;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAAAC,IAAA,EAsBO;AAAA,EAAA,IAAAC,gBAAA,GAAAD,IAAA,CArB7BE,WAAW;IAAXA,WAAW,GAAAD,gBAAA,KAAA,MAAA,GAAG;AA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EAAC,MAAM;AAACT,MAAAA,KAAK,EAAEL;AAAiB,KAAA,EACpDzK,QACE,CACS,CAEjB,CACC,CAAC;EAEL,CAAC;;AAED;AACA;AACA,EAAA,IAAMwL,aAAa,GAAGpJ,KAAK,CAACqJ,UAAU,CAACC,cAAc,CAAC;AACtD,EAAA,IAAMC,iBAAiB,GAAG7K,SAAS,GAAG0K,aAAa,KAAA,IAAA,IAAbA,aAAa,KAAA,MAAA,GAAA,MAAA,GAAbA,aAAa,CAAE1J,UAAU,GAAGA,UAAU;AAE5E,EAAA,oBACCM,KAAA,CAAAwI,aAAA,CAACc,cAAc,CAACE,QAAQ,EAAA;AACvBC,IAAAA,KAAK,EAAE;MACN9G,SAAS;AACT5E,MAAAA,WAAW,EAAE,CAACW,SAAS,GAAGiE,SAAS,GAAGI,SAAS;AAC/CrD,MAAAA,UAAU,EAAE6J;AACb;AAAE,GAAA,EAED7K,SAAS,IAAIW,QAAQ,KAAK,QAAQ,GAClCkJ,UAAU,EAAE,gBAEZvI,KAAA,CAAAwI,aAAA,CAACkB,SAAS,EAAAb,QAAA,CAAA;AAACc,IAAAA,KAAK,EAAE3K,WAAW,CAAC2K,KAAK,IAAI1K,aAAa,CAACC;AAAK,GAAA,EAAKF,WAAW,CAAA,EACxEuJ,UAAU,EACD,CAEY,CAAC;AAE3B;AACD;AAEAnL,OAAO,CAACwM,aAAa,GAAG,MAAM;;;;"}
1
+ {"version":3,"file":"MrlMenu.js","sources":["../../../../../src/components/menu/MrlMenu/MrlMenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MrlPortal, PortalProps } from '../../portal/MrlPortal';\nimport { useTriggerPosition } from '../../../hooks/useTriggerPosition';\nimport { useClickOutside } from '../../../hooks/useClickOutside';\nimport { useSubMenuElementPosition } from '../hooks/useSubMenuElementPosition';\nimport {\n\tMenuPosition,\n\tMenuAlignment,\n\tActionState,\n\tActionType,\n\tCustomMenuPosition\n} from '../constants';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport {\n\tfindAdjacentInteractiveElement,\n\tpreventDefault,\n\tisElementAriaDisabled\n} from '../../../utils';\nimport classnames from 'classnames';\nimport { MrlMenuContext } from '../context/MrlMenuContext';\nimport styles from './MrlMenu.module.scss';\nimport itemStyles from '../MrlMenuItem/MrlMenuItem.module.scss';\nimport { useTransition, animated } from '@react-spring/web';\nimport { isTouchDevice } from '../../../utils/isTouch';\nimport { getScrollableParent } from '../utilities/get-scrollable-parent';\nimport { useMenuScroll } from '../hooks/useMenuScroll';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport interface MrlMenuProps {\n\t/** Custom position for the menu */\n\tcustomPosition?: CustomMenuPosition;\n\n\t/** Children to be rendered within the menu component*/\n\tchildren: React.ReactNode;\n\n\t/** Event to close the menu */\n\tclickOutsideEvent?: 'mousedown' | 'mouseup' | 'click';\n\n\t/**\n\t * Enables closing the menu when scrolling. Default is false.\n\t *\n\t */\n\tcloseOnScroll?: boolean;\n\n\t/**\n\t * Private closeParent prop for use with MrlMenuItem\n\t *\n\t * !!! Please do not use this prop directly, it is only used internally by MrlMenuItem !!!\n\t * @private\n\t */\n\tcloseParent?: () => void;\n\n\t/**\n\t * Disable arrows from opening the menu\n\t * - This is useful when you want to disable the default browser behavior of opening a menu on arrow down.\n\t *\n\t * Example usage: the menu is within a vertical toolbar and you want to use the arrow keys to navigate the toolbar.\n\t * By using this prop you can disable the arrow key open/close so that navigating the toolbar does not conflict\n\t * with opening/closing the menu.\n\t */\n\tdisableArrowOpen?: boolean;\n\n\t/**\n\t * Disable flipping of the menu when it goes off the screen\n\t * @default false\n\t */\n\tdisableFlipping?: boolean;\n\n\t/** Unique identifier for the menu */\n\tid?: string;\n\n\t/**\n\t * Use when the menu is embedded within another component\n\t * Removes the following styles:\n\t * - padding on the menu\n\t * - drop shadow and border\n\t * @default false\n\t */\n\tisInternal?: boolean;\n\n\t/**\n\t * Private isSubMenu prop for use with MrlMenuItem\n\t *\n\t * !!! Please do not use this prop directly, it is only used internally by MrlMenuItem !!!\n\t * @private\n\t */\n\tisSubMenu?: boolean;\n\n\t/**\n\t * spacing of menu\n\t * - compact has less padding\n\t * @default 'default'\n\t */\n\tspacing?: 'default' | 'compact';\n\n\t/**\n\t * Offset of the menu from the trigger element in pixels\n\t * @default 10px\n\t */\n\tmenuOffset?: number;\n\n\t/**\n\t * Configuration for the portal component\n\t */\n\tportalProps?: Omit<PortalProps, 'children'>;\n\n\t/**\n\t * Horizontal and vertical alignment of the menu relative to the trigger element\n\t * - position 'left', 'right', 'top', 'bottom' position relative to the trigger\n\t * - position 'static' renders the menu in place, not using the portal\n\t * - position 'ignore' will not position the menu, allowing you to use the customPosition prop to position the element\n\t * @default 'bottom'\n\t */\n\tposition?: MenuPosition;\n\n\t/**\n\t * Opens or closes the menu from outside. Not just an initial value: whenever\n\t * `isOpen` or `actionType` changes, the menu syncs its internal state to it.\n\t * The menu can still close itself (item select, click outside, Escape, Tab),\n\t * so pair this with `onClose` to reset your state. Prefer `triggerRef` when\n\t * there is a trigger element. Ignored for submenus and `position=\"static\"`.\n\t * @default { actionType: null, isOpen: false }\n\t */\n\tactionState?: ActionState;\n\n\t/**\n\t * Reference to the DOM element that triggers this menu. This alone wires up\n\t * click and keyboard open/close and the trigger's ARIA attributes; no\n\t * `actionState` or `onClick` toggle is needed.\n\t */\n\ttriggerRef?: React.RefObject<HTMLButtonElement>;\n\n\t/**\n\t * Trigger stop propagation on click\n\t *\n\t * In some instances we may want the trigger element to stop propogation to the\n\t * rest of the DOM. Use this flag to enable and disable it.\n\t * @default false\n\t */\n\ttriggerStopPropagation?: boolean;\n\n\t/**\n\t * Vertical and horizontal alignment of the menu relative to the position of the menu with the trigger\n\t * - 'left' and 'right' work with position 'top' and 'bottom'\n\t * - 'top' and 'bottom' work with position 'left' and 'right'\n\t * - 'center' works with all positions\n\t *\n\t * This does not impact submenus\n\t */\n\talignment?: MenuAlignment;\n\n\t/**\n\t * Called when the menu closes itself: item select, click outside, Escape, Tab,\n\t * or scroll with `closeOnScroll`. Not called when a trigger click toggles it closed.\n\t * @param type - type of close event\n\t */\n\tonClose?: (type?: string) => void;\n\n\t/**\n\t * Enables interaction tracking for this menu. Provide a stable, non-PII id\n\t * (e.g. 'mural-context-menu'). When omitted, the menu emits no analytics.\n\t */\n\teventId?: string;\n}\n\nconst MENU_ITEM_SELECTOR = '[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]';\n\n/**\n * MrlMenu component\n *\n * Renders a menu component with alignment relative to a trigger element\n * @param {MrlMenuProps} props - The props for the MrlMenu component\n * @returns {Element} - rendered MrlMenu component\n */\nexport function MrlMenu({\n\tactionState = { actionType: null, isOpen: false },\n\talignment = 'center',\n\tchildren,\n\tcloseOnScroll = false,\n\tcloseParent,\n\tcustomPosition,\n\tclickOutsideEvent = 'mouseup',\n\tdisableArrowOpen,\n\tdisableFlipping = false,\n\tid,\n\tisInternal = false,\n\tisSubMenu = false,\n\tspacing = 'default',\n\tmenuOffset = 10,\n\tportalProps = { id: PORTAL_LAYERS.MENU.name },\n\tposition = 'bottom',\n\ttriggerStopPropagation = false,\n\tonClose,\n\teventId,\n\ttriggerRef,\n\t...remainingProps\n}: MrlMenuProps): JSX.Element {\n\tconst defaultOpenState = position === 'static' || false;\n\n\tconst [state, setState] = React.useState({\n\t\tactionType: null,\n\t\tisOpen: defaultOpenState\n\t} as ActionState);\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlMenu', eventId);\n\t// the menu opens and closes from several paths (click, keyboard, hover, click outside),\n\t// so open/close is emitted from the resulting state rather than each individual handler.\n\tconst wasOpenRef = React.useRef(defaultOpenState);\n\n\tReact.useEffect(() => {\n\t\tif (wasOpenRef.current === state.isOpen) return;\n\n\t\twasOpenRef.current = state.isOpen;\n\n\t\ttrackInteraction({\n\t\t\taction: state.isOpen ? 'open' : 'close',\n\t\t\tmetadata: { isSubMenu, trigger: state.actionType ?? 'unknown' },\n\t\t\tvariant: position\n\t\t});\n\t}, [state.isOpen, state.actionType, isSubMenu, position, trackInteraction]);\n\n\tconst menuRef = React.useRef<HTMLDivElement>(null);\n\tconst listRef = React.useRef<HTMLUListElement>(null);\n\tconst [menuItems, setMenuItems] = React.useState<HTMLButtonElement[]>([]);\n\tconst [menuRect, setMenuRect] = React.useState<DOMRect | null>(null);\n\n\t/**\n\t * Checks if the trigger element is disabled\n\t * @returns {boolean} - true if the trigger element is disabled, false otherwise\n\t */\n\tconst isTriggerDisabled = React.useCallback((): boolean => {\n\t\treturn isElementAriaDisabled(triggerRef?.current);\n\t}, [triggerRef]);\n\n\t/**\n\t * Sets up trigger event listeners to open and close the menu\n\t * @param e - mouse event\n\t */\n\tconst toggleMenuTrigger = React.useCallback(\n\t\t(e: MouseEvent) => {\n\t\t\tif (isTriggerDisabled()) return;\n\n\t\t\tif (triggerStopPropagation) {\n\t\t\t\tpreventDefault(e);\n\t\t\t}\n\n\t\t\tsetState((prevState) => ({ actionType: 'click', isOpen: !prevState.isOpen }));\n\t\t},\n\t\t[triggerStopPropagation, isTriggerDisabled]\n\t);\n\n\t/**\n\t * Used to display the menu when hovering over a menu item that has a submenu\n\t */\n\tconst showMenuHover = React.useCallback(() => {\n\t\tsetState({ actionType: 'click', isOpen: true });\n\t}, []);\n\n\tconst showMenuTap = React.useCallback(() => {\n\t\tsetState((prevState) => ({ actionType: 'click', isOpen: !prevState.isOpen }));\n\t}, []);\n\n\tconst hideMenuHover = React.useCallback(\n\t\t(event: MouseEvent) => {\n\t\t\tconst relatedTarget = event.relatedTarget as Node;\n\n\t\t\t// If the related target is not a child of the menu, close the menu\n\t\t\t// This prevents the menu from closing when hovering over a submenu item or trigger\n\t\t\tif (\n\t\t\t\ttriggerRef &&\n\t\t\t\tmenuRef.current &&\n\t\t\t\t!menuRef.current.contains(relatedTarget) &&\n\t\t\t\ttriggerRef.current &&\n\t\t\t\t!triggerRef.current.contains(relatedTarget)\n\t\t\t) {\n\t\t\t\tsetState({ actionType: null, isOpen: false });\n\t\t\t}\n\t\t},\n\t\t[triggerRef]\n\t);\n\n\t/**\n\t * Sets up trigger event listeners to open and close the menu with a keyboard\n\t */\n\tconst toggleMenuKey = React.useCallback(\n\t\t(e: KeyboardEvent) => {\n\t\t\tconst openMenu = () => {\n\t\t\t\tif (isTriggerDisabled()) return;\n\t\t\t\tsetState({ actionType: e.key as ActionType, isOpen: true });\n\t\t\t};\n\n\t\t\tif (!state.isOpen) {\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\tswitch (e.key) {\n\t\t\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\t\tcase 'Enter':\n\t\t\t\t\t\tcase ' ':\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\topenMenu();\n\t\t\t\t\t}\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tswitch (e.key) {\n\t\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\t\tif (!disableArrowOpen && !isTriggerDisabled()) {\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\topenMenu();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'Enter':\n\t\t\t\t\tcase ' ':\n\t\t\t\t\t\tif (isTriggerDisabled()) return;\n\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\topenMenu();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[state.isOpen, isTriggerDisabled, disableArrowOpen, isSubMenu]\n\t);\n\n\tconst closeMenu = React.useCallback(\n\t\t(shouldCloseParent = true) => {\n\t\t\tif (position === 'static') return;\n\n\t\t\t/**\n\t\t\t * What is closeParent?\n\t\t\t *\n\t\t\t * It is passed from the context provider to the MenuItem (which helps render our submenus)\n\t\t\t * When we render the submenu, we pass the closeMenu function as \"closeParent\" to the submenu.\n\t\t\t * This allows us to trigger closing the parent menu when the submenu is closed. And that's\n\t\t\t * what this call is for.\n\t\t\t */\n\t\t\tif (shouldCloseParent && closeParent) closeParent();\n\n\t\t\tsetState({ actionType: null, isOpen: false });\n\t\t\tonClose?.();\n\t\t},\n\t\t[position, closeParent, onClose]\n\t);\n\n\t/**\n\t * Click outside to dismiss the menu\n\t * @param e\n\t */\n\tconst disableClickOutside = !state.isOpen || position === 'static';\n\tuseClickOutside(menuRef, triggerRef, clickOutsideEvent, closeMenu, disableClickOutside);\n\n\tconst handleMenuKeyUp = (e: React.KeyboardEvent) => {\n\t\tconst actions: ActionType[] = ['ArrowUp', 'ArrowDown', 'ArrowRight', 'Enter', 'Escape', ' '];\n\n\t\tif (actions.includes(e.key as ActionType)) {\n\t\t\tpreventDefault(e);\n\t\t}\n\t};\n\n\t/**\n\t * Focus management when someone is using a keyboard to navigate the menu\n\t * @param e - keyboard event\n\t */\n\tconst handleMenuKey = (e: React.KeyboardEvent) => {\n\t\tconst currentIndex = menuItems.findIndex((item) => document.activeElement === item);\n\t\tlet nextIndex: number;\n\n\t\tif (state.isOpen) {\n\t\t\tswitch (e.key) {\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tnextIndex = currentIndex < menuItems.length - 1 ? currentIndex + 1 : currentIndex;\n\t\t\t\t\tmenuItems[nextIndex]?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tnextIndex = currentIndex > 0 ? currentIndex - 1 : 0;\n\t\t\t\t\tmenuItems[nextIndex]?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Escape':\n\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\ttriggerRef?.current?.focus();\n\t\t\t\t\tcloseMenu(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Tab':\n\t\t\t\t\tif (!isSubMenu && position !== 'static') {\n\t\t\t\t\t\tif (e.shiftKey) {\n\t\t\t\t\t\t\t// Handle shift + tab: move focus to the previous item\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\tif (triggerRef) {\n\t\t\t\t\t\t\t\tconst prevElement = findAdjacentInteractiveElement(triggerRef, 'previous');\n\t\t\t\t\t\t\t\tprevElement?.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Regular tab: close the menu or move to the next item\n\t\t\t\t\t\t\tpreventDefault(e);\n\t\t\t\t\t\t\tif (triggerRef) {\n\t\t\t\t\t\t\t\tconst nextElement = findAdjacentInteractiveElement(triggerRef);\n\t\t\t\t\t\t\t\tnextElement?.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcloseMenu();\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * useEffect hooks to handle menu state changes\n\t */\n\n\tReact.useEffect(() => {\n\t\tif (triggerRef?.current) {\n\t\t\ttriggerRef.current.setAttribute('aria-haspopup', 'menu');\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\tReact.useEffect(() => {\n\t\tif (position === 'static') {\n\t\t\tsetState({ actionType: 'click', isOpen: true });\n\t\t}\n\t}, [position]);\n\n\tReact.useEffect(() => {\n\t\ttriggerRef?.current?.setAttribute('aria-expanded', state.isOpen.toString());\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen]);\n\n\tReact.useEffect(() => {\n\t\tif (!isSubMenu && position !== 'static')\n\t\t\tsetState({ actionType: actionState.actionType, isOpen: actionState.isOpen });\n\t}, [actionState.isOpen, actionState.actionType, isSubMenu, position]);\n\n\t// setup event handlers for mouse, keyboard, and scroll interactions\n\tReact.useEffect(() => {\n\t\tconst triggerElement = triggerRef?.current;\n\t\tconst menuElement = menuRef?.current;\n\t\tconst menuItems = menuElement?.querySelectorAll(MENU_ITEM_SELECTOR);\n\n\t\tlet scrollableParent: HTMLElement | Window;\n\n\t\tif (triggerElement) {\n\t\t\ttriggerElement.addEventListener('mousedown', preventDefault);\n\t\t\tif (!isSubMenu) triggerElement.addEventListener('click', toggleMenuTrigger);\n\t\t\ttriggerElement.addEventListener('keydown', toggleMenuKey);\n\n\t\t\t// Setup event listeners for when the menu is a submenu\n\t\t\tif (isSubMenu) {\n\t\t\t\ttriggerElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\ttriggerElement.addEventListener('mouseout', hideMenuHover);\n\n\t\t\t\tif (isTouchDevice()) {\n\t\t\t\t\ttriggerElement.addEventListener('touchend', showMenuTap);\n\t\t\t\t}\n\n\t\t\t\tif (menuElement) {\n\t\t\t\t\tmenuElement.addEventListener('mouseover', showMenuHover);\n\t\t\t\t\tmenuElement.addEventListener('mouseout', hideMenuHover);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (closeOnScroll) {\n\t\t\t\tscrollableParent = getScrollableParent(triggerElement);\n\t\t\t\tif (scrollableParent) {\n\t\t\t\t\tscrollableParent.addEventListener('scroll', () => closeMenu(), {\n\t\t\t\t\t\tcapture: true,\n\t\t\t\t\t\tpassive: true\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\ttriggerElement.removeEventListener('mousedown', preventDefault);\n\t\t\t\tif (!isSubMenu) triggerElement.removeEventListener('click', toggleMenuTrigger);\n\t\t\t\ttriggerElement.removeEventListener('keydown', toggleMenuKey);\n\n\t\t\t\tif (menuItems) {\n\t\t\t\t\tmenuItems.forEach((item: Element) => {\n\t\t\t\t\t\tif (!item.getAttribute('aria-haspopup')) {\n\t\t\t\t\t\t\titem.removeEventListener('mousedown', () => closeMenu());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (isSubMenu) {\n\t\t\t\t\ttriggerElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\ttriggerElement.removeEventListener('mouseout', hideMenuHover);\n\n\t\t\t\t\tif (isTouchDevice()) {\n\t\t\t\t\t\ttriggerElement.removeEventListener('touchstart', showMenuHover);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (menuElement) {\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseover', showMenuHover);\n\t\t\t\t\t\tmenuElement.removeEventListener('mouseout', hideMenuHover);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (closeOnScroll && scrollableParent) {\n\t\t\t\t\tscrollableParent.removeEventListener('scroll', () => closeMenu());\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}, [\n\t\tcloseOnScroll,\n\t\tisSubMenu,\n\t\ttriggerRef,\n\t\ttoggleMenuTrigger,\n\t\ttoggleMenuKey,\n\t\tshowMenuHover,\n\t\thideMenuHover,\n\t\tcloseMenu,\n\t\tshowMenuTap\n\t]);\n\n\t// This use effect handles a few things when we open the menu:\n\t// - making sure that the menu component is aware of it's menu items\n\t// - adding a class to the trigger element when the submenu is open for styling\n\t// - storing the menu rect in state for positioning calculations\n\tReact.useEffect(() => {\n\t\tif (state.isOpen) {\n\t\t\tconst foundMenuItems = Array.from(\n\t\t\t\tmenuRef.current?.querySelectorAll(MENU_ITEM_SELECTOR) || []\n\t\t\t) as HTMLButtonElement[];\n\n\t\t\tsetMenuItems(foundMenuItems);\n\t\t}\n\n\t\tif (state.isOpen && isSubMenu) {\n\t\t\ttriggerRef?.current?.classList.add(itemStyles['MrlMenuItem--item--submenuOpen']);\n\t\t} else if (!state.isOpen && isSubMenu) {\n\t\t\ttriggerRef?.current?.classList.remove(itemStyles['MrlMenuItem--item--submenuOpen']);\n\t\t}\n\n\t\t// For consistent submenu calculations, we are storing the menu rect in state\n\t\t// Anytime we need to use the menu rect, we want to make sure the values are based\n\t\t// on the original state of the menu for proper transformations\n\t\tif (!menuRect && menuRef.current) {\n\t\t\tconst newRect = menuRef.current?.getBoundingClientRect();\n\t\t\tsetMenuRect(newRect || null);\n\t\t}\n\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [state.isOpen, menuRect, isSubMenu]);\n\n\t/**\n\t * Focus management for when the menu is opening or closing\n\t */\n\tReact.useEffect(() => {\n\t\tif (menuItems.length > 0) {\n\t\t\tlet menuItemToFocus;\n\n\t\t\tswitch (state.actionType) {\n\t\t\t\tcase 'Enter':\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\tcase ' ':\n\t\t\t\t\tmenuItemToFocus = menuItems[0];\n\t\t\t\t\tmenuItemToFocus?.focus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\tmenuItemToFocus = menuItems[menuItems.length - 1];\n\t\t\t\t\tmenuItemToFocus?.focus();\n\n\t\t\t\t\t// Scroll to the bottom of the menu when the last item is focused\n\t\t\t\t\t// setTimeout is required to ensure the element has been rendered\n\t\t\t\t\t// and the scrollHeight is accurate prior to scrolling\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tif (listRef.current) {\n\t\t\t\t\t\t\tlistRef.current.scrollTo(0, listRef.current.scrollHeight);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 20);\n\t\t\t}\n\n\t\t\tif (isSubMenu && state.actionType === 'ArrowRight') {\n\t\t\t\tmenuItemToFocus = menuItems[0];\n\t\t\t\tmenuItemToFocus?.focus();\n\t\t\t}\n\t\t}\n\t}, [isSubMenu, menuItems, state.actionType]);\n\n\t/**\n\t * Menu scroll behavior\n\t *\n\t * When the menu cannot fit in the preferred or flipped position,\n\t * this hook constrains the menu height and enables internal scrolling.\n\t * Called before useTriggerPosition so that isScrolling can disable flipping,\n\t * preventing the positioning hook from fighting the scroll constraint.\n\t */\n\tconst disableMenuScroll =\n\t\tisSubMenu || !state.isOpen || position === 'static' || position === 'ignore';\n\n\t/**\n\t * Sets overflow (scrolling) on menu when there is no space to display\n\t * the menu in the preferred or flipped position.\n\t */\n\tconst menuScroll = useMenuScroll(\n\t\ttriggerRef,\n\t\tlistRef,\n\t\tposition,\n\t\tmenuOffset,\n\t\tstate.isOpen,\n\t\tdisableMenuScroll\n\t);\n\n\t/**\n\t * Primary menu positioning, alignment, and transition styling\n\t *\n\t * This hook is only enabled if isSubMenu is FALSE\n\t */\n\tconst disableTriggerPosition = isSubMenu || !state.isOpen || position === 'static';\n\tconst menuPositionStyles = useTriggerPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\t{\n\t\t\talign: alignment,\n\t\t\tcustomPosition: customPosition,\n\t\t\tposition: position\n\t\t},\n\t\tstate.isOpen,\n\t\tmenuOffset,\n\t\tdisableTriggerPosition,\n\t\tdisableFlipping || menuScroll.isScrolling\n\t);\n\n\t/**\n\t * Submenu positioning and alignment\n\t *\n\t * This hook is only enabled if isSubMenu is TRUE\n\t */\n\tconst subMenuPosition = useSubMenuElementPosition(\n\t\ttriggerRef,\n\t\tmenuRef,\n\t\tisSubMenu,\n\t\tstate.isOpen,\n\t\tmenuRect,\n\t\t// disable the subelement positioning if it's not a submenu\n\t\t!isSubMenu\n\t);\n\n\tconst inlineStyles = {\n\t\tmenu: {\n\t\t\tleft: menuPositionStyles.left,\n\t\t\tposition: 'fixed' as const,\n\t\t\ttop: menuPositionStyles.top\n\t\t},\n\t\tsubmenu: {\n\t\t\tleft: subMenuPosition.left,\n\t\t\ttop: subMenuPosition.top\n\t\t}\n\t};\n\n\t/**\n\t * React Spring transitions for the menu\n\t */\n\tconst transitionConfig = {\n\t\tconfig: { duration: state.isOpen ? 300 : 150 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' },\n\t\tfrom: { opacity: 0, transform: 'translateY(4px)' },\n\t\tleave: { opacity: 0, transform: 'translateY(4px)' }\n\t};\n\n\tconst transitionStatic = {\n\t\tconfig: { duration: 0 },\n\t\tenter: { opacity: 1, transform: 'translateY(0)' }\n\t};\n\n\tconst transitions = useTransition(\n\t\tstate.isOpen,\n\t\tposition === 'static' ? transitionStatic : transitionConfig\n\t);\n\n\tconst menuClasses = classnames(styles['MrlMenu'], 'MrlMenu', {\n\t\t[styles['MrlMenu--submenu']]: isSubMenu,\n\t\t[styles.open]: state.isOpen,\n\t\t[styles['MrlMenu--compact']]: spacing === 'compact',\n\t\t[styles['MrlMenu--static']]: position === 'static',\n\t\t[styles['MrlMenu--internal']]: isInternal,\n\t\t[styles['MrlMenu--scrolling']]: menuScroll.isScrolling,\n\t\t[styles['MrlMenu--ignore']]: position === 'ignore'\n\t});\n\n\tconst positionStyles = isSubMenu\n\t\t? inlineStyles.submenu\n\t\t: position !== 'static'\n\t\t\t? inlineStyles.menu\n\t\t\t: {};\n\n\tconst menuScrollStyles =\n\t\t(menuScroll.maxHeight !== undefined && { maxHeight: menuScroll.maxHeight }) || undefined;\n\n\tconst renderMenu = () => {\n\t\treturn (\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\n\t\t\t\t\t\t\t\tclassName={menuClasses}\n\t\t\t\t\t\t\t\tid={id}\n\t\t\t\t\t\t\t\tstyle={{ ...positionStyles, ...style }}\n\t\t\t\t\t\t\t\tonKeyUp={handleMenuKeyUp}\n\t\t\t\t\t\t\t\tonKeyDown={handleMenuKey}\n\t\t\t\t\t\t\t\tref={menuRef}\n\t\t\t\t\t\t\t\trole=\"none\"\n\t\t\t\t\t\t\t\t{...remainingProps}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ul ref={listRef} role=\"menu\" style={menuScrollStyles}>\n\t\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t\t</ul>\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</>\n\t\t);\n\t};\n\n\t// For managing and restoring focus to the original menu trigger\n\t// Ensures the triggerRef in context is always the parent triggerRef\n\tconst parentContext = React.useContext(MrlMenuContext);\n\tconst contextTriggerRef = isSubMenu ? parentContext?.triggerRef : triggerRef;\n\n\treturn (\n\t\t<MrlMenuContext.Provider\n\t\t\tvalue={{\n\t\t\t\tcloseMenu,\n\t\t\t\tcloseParent: !isSubMenu ? closeMenu : undefined,\n\t\t\t\ttriggerRef: contextTriggerRef\n\t\t\t}}\n\t\t>\n\t\t\t{isSubMenu || position === 'static' ? (\n\t\t\t\trenderMenu()\n\t\t\t) : (\n\t\t\t\t<MrlPortal layer={portalProps.layer || PORTAL_LAYERS.MENU} {...portalProps}>\n\t\t\t\t\t{renderMenu()}\n\t\t\t\t</MrlPortal>\n\t\t\t)}\n\t\t</MrlMenuContext.Provider>\n\t);\n\t/* eslint-enable */\n}\n\nMrlMenu.componentType = 'Menu';\n"],"names":["MENU_ITEM_SELECTOR","MrlMenu","_ref","_ref$actionState","actionState","actionType","isOpen","_ref$alignment","alignment","children","_ref$closeOnScroll","closeOnScroll","closeParent","customPosition","_ref$clickOutsideEven","clickOutsideEvent","disableArrowOpen","_ref$disableFlipping","disableFlipping","id","_ref$isInternal","isInternal","_ref$isSubMenu","isSubMenu","_ref$spacing","spacing","_ref$menuOffset","menuOffset","_ref$portalProps","portalProps","PORTAL_LAYERS","MENU","name","_ref$position","position","_ref$triggerStopPropa","triggerStopPropagation","onClose","eventId","triggerRef","remainingProps","_objectWithoutProperties","_excluded","defaultOpenState","_React$useState","React","useState","_React$useState2","_slicedToArray","state","setState","trackInteraction","useMrlTrackInteraction","wasOpenRef","useRef","useEffect","_state$actionType","current","action","metadata","trigger","variant","menuRef","listRef","_React$useState3","_React$useState4","menuItems","setMenuItems","_React$useState5","_React$useState6","menuRect","setMenuRect","isTriggerDisabled","useCallback","isElementAriaDisabled","toggleMenuTrigger","e","preventDefault","prevState","showMenuHover","showMenuTap","hideMenuHover","event","relatedTarget","contains","toggleMenuKey","openMenu","key","closeMenu","shouldCloseParent","arguments","length","undefined","disableClickOutside","useClickOutside","handleMenuKeyUp","actions","includes","handleMenuKey","_menuItems$nextIndex","_menuItems$nextIndex2","_triggerRef$current","currentIndex","findIndex","item","document","activeElement","nextIndex","focus","shiftKey","prevElement","findAdjacentInteractiveElement","nextElement","setAttribute","_triggerRef$current2","toString","triggerElement","menuElement","querySelectorAll","scrollableParent","addEventListener","isTouchDevice","getScrollableParent","capture","passive","removeEventListener","forEach","getAttribute","_menuRef$current","foundMenuItems","Array","from","_triggerRef$current3","classList","add","itemStyles","_triggerRef$current4","remove","_menuRef$current2","newRect","getBoundingClientRect","_menuItemToFocus","_menuItemToFocus2","menuItemToFocus","setTimeout","scrollTo","scrollHeight","_menuItemToFocus3","disableMenuScroll","menuScroll","useMenuScroll","disableTriggerPosition","menuPositionStyles","useTriggerPosition","align","isScrolling","subMenuPosition","useSubMenuElementPosition","inlineStyles","menu","left","top","submenu","transitionConfig","config","duration","enter","opacity","transform","leave","transitionStatic","transitions","useTransition","menuClasses","classnames","styles","open","positionStyles","menuScrollStyles","maxHeight","renderMenu","createElement","Fragment","style","animated","div","_extends","className","_objectSpread","onKeyUp","onKeyDown","ref","role","parentContext","useContext","MrlMenuContext","contextTriggerRef","Provider","value","MrlPortal","layer","componentType"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqKA,IAAMA,kBAAkB,GAAG,sEAAsE;;AAEjG;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAAAC,IAAA,EAsBO;AAAA,EAAA,IAAAC,gBAAA,GAAAD,IAAA,CArB7BE,WAAW;IAAXA,WAAW,GAAAD,gBAAA,KAAA,MAAA,GAAG;AAAEE,MAAAA,UAAU,EAAE,IAAI;AAAEC,MAAAA,MAAM,EAAE;AAAM,KAAC,GAAAH,gBAAA;IAAAI,cAAA,GAAAL,IAAA,CACjDM,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,MAAA,GAAG,QAAQ,GAAAA,cAAA;IACpBE,QAAQ,GAAAP,IAAA,CAARO,QAAQ;IAAAC,kBAAA,GAAAR,IAAA,CACRS,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA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1J,UAAU,GAAGA,UAAU;AAE5E,EAAA,oBACCM,KAAA,CAAAwI,aAAA,CAACc,cAAc,CAACE,QAAQ,EAAA;AACvBC,IAAAA,KAAK,EAAE;MACN9G,SAAS;AACT5E,MAAAA,WAAW,EAAE,CAACW,SAAS,GAAGiE,SAAS,GAAGI,SAAS;AAC/CrD,MAAAA,UAAU,EAAE6J;AACb;AAAE,GAAA,EAED7K,SAAS,IAAIW,QAAQ,KAAK,QAAQ,GAClCkJ,UAAU,EAAE,gBAEZvI,KAAA,CAAAwI,aAAA,CAACkB,SAAS,EAAAb,QAAA,CAAA;AAACc,IAAAA,KAAK,EAAE3K,WAAW,CAAC2K,KAAK,IAAI1K,aAAa,CAACC;AAAK,GAAA,EAAKF,WAAW,CAAA,EACxEuJ,UAAU,EACD,CAEY,CAAC;AAE3B;AACD;AAEAnL,OAAO,CAACwM,aAAa,GAAG,MAAM;;;;"}
@@ -1,4 +1,4 @@
1
- var TOOLKIT_VERSION = "4.76.0";
1
+ var TOOLKIT_VERSION = "4.76.1";
2
2
 
3
3
  export { TOOLKIT_VERSION };
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.76.0\";"],"names":["TOOLKIT_VERSION"],"mappings":"AAAO,IAAMA,eAAe,GAAG;;;;"}
1
+ {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["export const TOOLKIT_VERSION = \"4.76.1\";"],"names":["TOOLKIT_VERSION"],"mappings":"AAAO,IAAMA,eAAe,GAAG;;;;"}
@@ -75,12 +75,18 @@ export interface MrlMenuProps {
75
75
  */
76
76
  position?: MenuPosition;
77
77
  /**
78
- * Set initial state of menu
78
+ * Opens or closes the menu from outside. Not just an initial value: whenever
79
+ * `isOpen` or `actionType` changes, the menu syncs its internal state to it.
80
+ * The menu can still close itself (item select, click outside, Escape, Tab),
81
+ * so pair this with `onClose` to reset your state. Prefer `triggerRef` when
82
+ * there is a trigger element. Ignored for submenus and `position="static"`.
79
83
  * @default { actionType: null, isOpen: false }
80
84
  */
81
85
  actionState?: ActionState;
82
86
  /**
83
- * Reference to the DOM element that triggers this menu.
87
+ * Reference to the DOM element that triggers this menu. This alone wires up
88
+ * click and keyboard open/close and the trigger's ARIA attributes; no
89
+ * `actionState` or `onClick` toggle is needed.
84
90
  */
85
91
  triggerRef?: React.RefObject<HTMLButtonElement>;
86
92
  /**
@@ -101,7 +107,8 @@ export interface MrlMenuProps {
101
107
  */
102
108
  alignment?: MenuAlignment;
103
109
  /**
104
- * Callback to be called when the menu is closed
110
+ * Called when the menu closes itself: item select, click outside, Escape, Tab,
111
+ * or scroll with `closeOnScroll`. Not called when a trigger click toggles it closed.
105
112
  * @param type - type of close event
106
113
  */
107
114
  onClose?: (type?: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muraldevkit/ui-toolkit",
3
- "version": "4.76.0",
3
+ "version": "4.76.1",
4
4
  "description": "Mural's UI Toolkit",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",