@muraldevkit/ui-toolkit 4.84.0 → 4.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/cjs/components/avatar/MrlAvatar/MrlAvatar.js.map +1 -1
  2. package/dist/cjs/components/callout/MrlCallout/MrlCallout.js.map +1 -1
  3. package/dist/cjs/components/form/checkbox/MrlCheckbox/MrlCheckbox.js +13 -8
  4. package/dist/cjs/components/form/checkbox/MrlCheckbox/MrlCheckbox.js.map +1 -1
  5. package/dist/cjs/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js +16 -11
  6. package/dist/cjs/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map +1 -1
  7. package/dist/cjs/components/form/constants.js +6 -0
  8. package/dist/cjs/components/form/constants.js.map +1 -1
  9. package/dist/cjs/components/form/textarea/MrlTextarea/MrlTextarea.js.map +1 -1
  10. package/dist/cjs/components/grid/constants.js.map +1 -1
  11. package/dist/cjs/components/live-region/MrlLiveRegion/MrlLiveRegion.js.map +1 -1
  12. package/dist/cjs/components/popover/MrlPopover/MrlPopover.js.map +1 -1
  13. package/dist/cjs/components/portal/MrlPortal.js.map +1 -1
  14. package/dist/cjs/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.js.map +1 -1
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/cjs/version.js.map +1 -1
  17. package/dist/esm/components/avatar/MrlAvatar/MrlAvatar.js.map +1 -1
  18. package/dist/esm/components/callout/MrlCallout/MrlCallout.js.map +1 -1
  19. package/dist/esm/components/form/checkbox/MrlCheckbox/MrlCheckbox.js +13 -8
  20. package/dist/esm/components/form/checkbox/MrlCheckbox/MrlCheckbox.js.map +1 -1
  21. package/dist/esm/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js +16 -11
  22. package/dist/esm/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.js.map +1 -1
  23. package/dist/esm/components/form/constants.js +6 -0
  24. package/dist/esm/components/form/constants.js.map +1 -1
  25. package/dist/esm/components/form/textarea/MrlTextarea/MrlTextarea.js.map +1 -1
  26. package/dist/esm/components/grid/constants.js.map +1 -1
  27. package/dist/esm/components/live-region/MrlLiveRegion/MrlLiveRegion.js.map +1 -1
  28. package/dist/esm/components/popover/MrlPopover/MrlPopover.js.map +1 -1
  29. package/dist/esm/components/portal/MrlPortal.js.map +1 -1
  30. package/dist/esm/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.js.map +1 -1
  31. package/dist/esm/version.js +1 -1
  32. package/dist/esm/version.js.map +1 -1
  33. package/dist/types/components/avatar/MrlAvatar/MrlAvatar.d.ts +2 -2
  34. package/dist/types/components/callout/MrlCallout/MrlCallout.d.ts +1 -2
  35. package/dist/types/components/form/checkbox/MrlCheckbox/MrlCheckbox.d.ts +11 -6
  36. package/dist/types/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.d.ts +11 -9
  37. package/dist/types/components/form/constants.d.ts +6 -0
  38. package/dist/types/components/form/textarea/MrlTextarea/MrlTextarea.d.ts +1 -1
  39. package/dist/types/components/grid/constants.d.ts +2 -3
  40. package/dist/types/components/grid/index.d.ts +1 -1
  41. package/dist/types/components/live-region/MrlLiveRegion/MrlLiveRegion.d.ts +1 -2
  42. package/dist/types/components/live-region/MrlLiveRegion/index.d.ts +1 -1
  43. package/dist/types/components/popover/MrlPopover/MrlPopover.d.ts +1 -2
  44. package/dist/types/components/portal/MrlPortal.d.ts +1 -2
  45. package/dist/types/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.d.ts +1 -1
  46. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MrlAvatar.js","sources":["../../../../../src/components/avatar/MrlAvatar/MrlAvatar.tsx"],"sourcesContent":["import { lock, facilitatorBadge } from '@muraldevkit/ds-icons';\nimport {\n\thexToRgb,\n\tisValidHexColor,\n\tisValidRgbString,\n\tisValidRgbaString,\n\tstickyTextColor\n} from '@tactivos/mural-shared/lib/colors';\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\n\nimport styles from './MrlAvatar.module.scss';\n\ntype AvatarKind = (typeof avatarValues.kind)[number];\ntype AvatarSize = (typeof avatarValues.size)[number];\n\ninterface avatarDefaults {\n\tkind: AvatarKind;\n\tsize: AvatarSize;\n\tavatarColor: string;\n}\n\nexport interface MrlAvatarPropTypes {\n\t/** Alt text when `image` is a URL. Defaults to \"<name>'s avatar\", or \"Participant avatar\" without a name. */\n\talt?: string;\n\tdataQa?: string;\n\t/** Image shown instead of the initials: a URL rendered as an `img`, or a custom element. */\n\timage?: React.ReactNode | string;\n\t/** Badge shown on the corner of small and xsmall avatars: a facilitator badge or a lock icon. Also draws the border in `avatarColor`. */\n\tkind?: AvatarKind;\n\t/** Name of the person. Used for the initials when there is no image, and set as `aria-label` on the avatar content. */\n\tname?: string;\n\t/** Called when the `image` URL fails to load. */\n\tonImageError?: React.ReactEventHandler<HTMLImageElement>;\n\t/** Draws a border in `avatarColor` around the avatar. */\n\tshowBorder?: boolean;\n\t/** Size of the avatar. xsmall shows one initial, the other sizes up to two. */\n\tsize?: AvatarSize;\n\t/** Color of the person as hex, rgb or rgba, used to tint the avatar. */\n\tavatarColor?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst avatarValues = {\n\tkind: ['default', 'facilitator', 'lock'] as const,\n\tsize: ['xsmall', 'small', 'medium', 'large'] as const\n};\n\nexport const defaultAvatarValues: avatarDefaults = {\n\tavatarColor: '#2f2f2f',\n\tkind: 'default',\n\tsize: 'medium'\n};\n\n/**\n * Renders an avatar component\n * @param {MrlAvatarPropTypes} props the props for your MrlAvatar\n * @returns {React.ReactElement} an avatar containing the props you pass\n */\nexport const MrlAvatar = ({\n\talt,\n\tavatarColor = defaultAvatarValues.avatarColor,\n\tdataQa,\n\tkind = defaultAvatarValues.kind,\n\timage,\n\tname,\n\tonImageError,\n\tshowBorder = false,\n\tsize = defaultAvatarValues.size,\n\t...rest\n}: MrlAvatarPropTypes): React.ReactElement => {\n\tconst containerClasses = classNames(styles['MrlAvatar'], 'MrlAvatar', {\n\t\t[styles[`MrlAvatar--${size}`]]: size && size !== 'medium'\n\t});\n\n\tconst isFacilitatorSize = size === 'small' || size === 'xsmall';\n\tconst showIcon = kind !== 'default' && isFacilitatorSize;\n\tconst iconContainerClasses = classNames(styles['MrlAvatar-icon-container'], {\n\t\t[styles[`MrlAvatar-icon-container--${size}`]]: size && size !== 'medium'\n\t});\n\n\tconst getAvatarRgb = () => {\n\t\tif (isValidHexColor(avatarColor)) {\n\t\t\treturn hexToRgb(avatarColor).toString();\n\t\t}\n\n\t\tif (isValidRgbString(avatarColor)) {\n\t\t\treturn avatarColor.substring(4, avatarColor.length - 1);\n\t\t}\n\n\t\tif (isValidRgbaString(avatarColor)) {\n\t\t\tconst lastComma = avatarColor.lastIndexOf(',');\n\n\t\t\treturn avatarColor.substring(5, lastComma);\n\t\t}\n\t};\n\n\tconst renderImage = () => {\n\t\tif (typeof image === 'string') {\n\t\t\tconst imgAltText = alt ? alt : name ? `${name}'s avatar` : 'Participant avatar';\n\n\t\t\treturn (\n\t\t\t\t<img\n\t\t\t\t\talt={imgAltText}\n\t\t\t\t\tclassName={styles['MrlAvatar-image']}\n\t\t\t\t\tdata-qa={`${dataQa || 'avatar'}-image`}\n\t\t\t\t\tonError={onImageError}\n\t\t\t\t\tsrc={image}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn image;\n\t};\n\n\tconst getInitials = (str: string | undefined): string => {\n\t\tif (!str) {\n\t\t\treturn '';\n\t\t}\n\n\t\tconst textLength = size === 'xsmall' ? 1 : 2;\n\n\t\t// Take the name passed in.\n\t\treturn (\n\t\t\tstr\n\t\t\t\t// Split it at each space to create an array of words\n\t\t\t\t.split(' ')\n\t\t\t\t// Take the first character from each word.\n\t\t\t\t.map((item: string) => item.charAt(0).toUpperCase())\n\t\t\t\t// Bring the characters back into one word\n\t\t\t\t.join('')\n\t\t\t\t// Make sure we remove spaces\n\t\t\t\t.replace(/ /g, '')\n\t\t\t\t// Return the correct number of characters\n\t\t\t\t.substring(0, textLength)\n\t\t);\n\t};\n\n\tconst isDarkText = stickyTextColor(avatarColor, '#000000', '#ffffff') === '#ffffff';\n\tconst safeColor = getAvatarRgb();\n\n\tconst backgroundColor =\n\t\timage && typeof image === 'string'\n\t\t\t? 'rgba(var(--mrl-color-white), 1)'\n\t\t\t: `rgba(${safeColor}, 0.08)`;\n\tconst borderColor = showIcon || showBorder ? `rgba(${safeColor}, 1` : 'transparent';\n\tconst textColor = isDarkText ? `rgba(${safeColor}, 1` : 'rgba(--mrl-gray-90, 1)';\n\n\treturn (\n\t\t<div className={containerClasses} data-qa={dataQa} {...rest}>\n\t\t\t<span\n\t\t\t\taria-label={name}\n\t\t\t\tclassName={`${styles['MrlAvatar-content']} MrlAvatar-content`}\n\t\t\t\tdata-qa={dataQa && `avatar-${image ? 'image-container' : 'initials'}`}\n\t\t\t\tstyle={{\n\t\t\t\t\tbackgroundColor: backgroundColor,\n\t\t\t\t\tborderColor: borderColor,\n\t\t\t\t\tcolor: textColor\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{image ? renderImage() : <span aria-hidden=\"true\">{getInitials(name)}</span>}\n\t\t\t</span>\n\t\t\t{showIcon && (\n\t\t\t\t<span\n\t\t\t\t\tclassName={iconContainerClasses}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackgroundColor: borderColor\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\tclassName={styles['MrlAvatar-icon']}\n\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\tsvg={kind === 'facilitator' ? facilitatorBadge : lock}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["defaultAvatarValues","avatarColor","kind","size","MrlAvatar","_ref","alt","_ref$avatarColor","dataQa","_ref$kind","image","name","onImageError","_ref$showBorder","showBorder","_ref$size","rest","_objectWithoutProperties","_excluded","containerClasses","classNames","styles","concat","isFacilitatorSize","showIcon","iconContainerClasses","getAvatarRgb","isValidHexColor","hexToRgb","toString","isValidRgbString","substring","length","isValidRgbaString","lastComma","lastIndexOf","renderImage","imgAltText","React","createElement","className","onError","src","getInitials","str","textLength","split","map","item","charAt","toUpperCase","join","replace","isDarkText","stickyTextColor","safeColor","backgroundColor","borderColor","textColor","_extends","style","color","MrlSvg","svg","facilitatorBadge","lock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDO,IAAMA,mBAAmC,GAAG;AAClDC,EAAAA,WAAW,EAAE,SAAS;AACtBC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,IAAI,EAAE;AACP;;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMC,SAAS,GAAGC,IAAA,IAWqB;AAAA,EAAA,IAV7CC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAAC,gBAAA,GAAAF,IAAA,CACHJ,WAAW;AAAXA,IAAAA,WAAW,GAAAM,gBAAA,KAAA,MAAA,GAAGP,mBAAmB,CAACC,WAAW,GAAAM,gBAAA;IAC7CC,MAAM,GAAAH,IAAA,CAANG,MAAM;IAAAC,SAAA,GAAAJ,IAAA,CACNH,IAAI;AAAJA,IAAAA,IAAI,GAAAO,SAAA,KAAA,MAAA,GAAGT,mBAAmB,CAACE,IAAI,GAAAO,SAAA;IAC/BC,KAAK,GAAAL,IAAA,CAALK,KAAK;IACLC,IAAI,GAAAN,IAAA,CAAJM,IAAI;IACJC,YAAY,GAAAP,IAAA,CAAZO,YAAY;IAAAC,eAAA,GAAAR,IAAA,CACZS,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,eAAA;IAAAE,SAAA,GAAAV,IAAA,CAClBF,IAAI;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AM,EAAA;AACNtB,IAAAA,SAAS,EAAEnB,wBAAM,CAAC,gBAAgB,CAAE;AACpClB,IAAAA,IAAI,EAAC,MAAM;AACX4D,IAAAA,GAAG,EAAE7D,IAAI,KAAK,aAAa,GAAG8D,wBAAgB,GAAGC;GACjD,CACI,CAEH,CAAC;AAER;;;;;"}
1
+ {"version":3,"file":"MrlAvatar.js","sources":["../../../../../src/components/avatar/MrlAvatar/MrlAvatar.tsx"],"sourcesContent":["import { lock, facilitatorBadge } from '@muraldevkit/ds-icons';\nimport {\n\thexToRgb,\n\tisValidHexColor,\n\tisValidRgbString,\n\tisValidRgbaString,\n\tstickyTextColor\n} from '@tactivos/mural-shared/lib/colors';\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { MrlSvg } from '../../svg/MrlSvg/MrlSvg';\n\nimport styles from './MrlAvatar.module.scss';\n\nexport type AvatarKind = (typeof avatarValues.kind)[number];\nexport type AvatarSize = (typeof avatarValues.size)[number];\n\ninterface avatarDefaults {\n\tkind: AvatarKind;\n\tsize: AvatarSize;\n\tavatarColor: string;\n}\n\nexport interface MrlAvatarPropTypes {\n\t/** Alt text when `image` is a URL. Defaults to \"<name>'s avatar\", or \"Participant avatar\" without a name. */\n\talt?: string;\n\tdataQa?: string;\n\t/** Image shown instead of the initials: a URL rendered as an `img`, or a custom element. */\n\timage?: React.ReactNode | string;\n\t/** Badge shown on the corner of small and xsmall avatars: a facilitator badge or a lock icon. Also draws the border in `avatarColor`. */\n\tkind?: AvatarKind;\n\t/** Name of the person. Used for the initials when there is no image, and set as `aria-label` on the avatar content. */\n\tname?: string;\n\t/** Called when the `image` URL fails to load. */\n\tonImageError?: React.ReactEventHandler<HTMLImageElement>;\n\t/** Draws a border in `avatarColor` around the avatar. */\n\tshowBorder?: boolean;\n\t/** Size of the avatar. xsmall shows one initial, the other sizes up to two. */\n\tsize?: AvatarSize;\n\t/** Color of the person as hex, rgb or rgba, used to tint the avatar. */\n\tavatarColor?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst avatarValues = {\n\tkind: ['default', 'facilitator', 'lock'] as const,\n\tsize: ['xsmall', 'small', 'medium', 'large'] as const\n};\n\nexport const defaultAvatarValues: avatarDefaults = {\n\tavatarColor: '#2f2f2f',\n\tkind: 'default',\n\tsize: 'medium'\n};\n\n/**\n * Renders an avatar component\n * @param {MrlAvatarPropTypes} props the props for your MrlAvatar\n * @returns {React.ReactElement} an avatar containing the props you pass\n */\nexport const MrlAvatar = ({\n\talt,\n\tavatarColor = defaultAvatarValues.avatarColor,\n\tdataQa,\n\tkind = defaultAvatarValues.kind,\n\timage,\n\tname,\n\tonImageError,\n\tshowBorder = false,\n\tsize = defaultAvatarValues.size,\n\t...rest\n}: MrlAvatarPropTypes): React.ReactElement => {\n\tconst containerClasses = classNames(styles['MrlAvatar'], 'MrlAvatar', {\n\t\t[styles[`MrlAvatar--${size}`]]: size && size !== 'medium'\n\t});\n\n\tconst isFacilitatorSize = size === 'small' || size === 'xsmall';\n\tconst showIcon = kind !== 'default' && isFacilitatorSize;\n\tconst iconContainerClasses = classNames(styles['MrlAvatar-icon-container'], {\n\t\t[styles[`MrlAvatar-icon-container--${size}`]]: size && size !== 'medium'\n\t});\n\n\tconst getAvatarRgb = () => {\n\t\tif (isValidHexColor(avatarColor)) {\n\t\t\treturn hexToRgb(avatarColor).toString();\n\t\t}\n\n\t\tif (isValidRgbString(avatarColor)) {\n\t\t\treturn avatarColor.substring(4, avatarColor.length - 1);\n\t\t}\n\n\t\tif (isValidRgbaString(avatarColor)) {\n\t\t\tconst lastComma = avatarColor.lastIndexOf(',');\n\n\t\t\treturn avatarColor.substring(5, lastComma);\n\t\t}\n\t};\n\n\tconst renderImage = () => {\n\t\tif (typeof image === 'string') {\n\t\t\tconst imgAltText = alt ? alt : name ? `${name}'s avatar` : 'Participant avatar';\n\n\t\t\treturn (\n\t\t\t\t<img\n\t\t\t\t\talt={imgAltText}\n\t\t\t\t\tclassName={styles['MrlAvatar-image']}\n\t\t\t\t\tdata-qa={`${dataQa || 'avatar'}-image`}\n\t\t\t\t\tonError={onImageError}\n\t\t\t\t\tsrc={image}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn image;\n\t};\n\n\tconst getInitials = (str: string | undefined): string => {\n\t\tif (!str) {\n\t\t\treturn '';\n\t\t}\n\n\t\tconst textLength = size === 'xsmall' ? 1 : 2;\n\n\t\t// Take the name passed in.\n\t\treturn (\n\t\t\tstr\n\t\t\t\t// Split it at each space to create an array of words\n\t\t\t\t.split(' ')\n\t\t\t\t// Take the first character from each word.\n\t\t\t\t.map((item: string) => item.charAt(0).toUpperCase())\n\t\t\t\t// Bring the characters back into one word\n\t\t\t\t.join('')\n\t\t\t\t// Make sure we remove spaces\n\t\t\t\t.replace(/ /g, '')\n\t\t\t\t// Return the correct number of characters\n\t\t\t\t.substring(0, textLength)\n\t\t);\n\t};\n\n\tconst isDarkText = stickyTextColor(avatarColor, '#000000', '#ffffff') === '#ffffff';\n\tconst safeColor = getAvatarRgb();\n\n\tconst backgroundColor =\n\t\timage && typeof image === 'string'\n\t\t\t? 'rgba(var(--mrl-color-white), 1)'\n\t\t\t: `rgba(${safeColor}, 0.08)`;\n\tconst borderColor = showIcon || showBorder ? `rgba(${safeColor}, 1` : 'transparent';\n\tconst textColor = isDarkText ? `rgba(${safeColor}, 1` : 'rgba(--mrl-gray-90, 1)';\n\n\treturn (\n\t\t<div className={containerClasses} data-qa={dataQa} {...rest}>\n\t\t\t<span\n\t\t\t\taria-label={name}\n\t\t\t\tclassName={`${styles['MrlAvatar-content']} MrlAvatar-content`}\n\t\t\t\tdata-qa={dataQa && `avatar-${image ? 'image-container' : 'initials'}`}\n\t\t\t\tstyle={{\n\t\t\t\t\tbackgroundColor: backgroundColor,\n\t\t\t\t\tborderColor: borderColor,\n\t\t\t\t\tcolor: textColor\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{image ? renderImage() : <span aria-hidden=\"true\">{getInitials(name)}</span>}\n\t\t\t</span>\n\t\t\t{showIcon && (\n\t\t\t\t<span\n\t\t\t\t\tclassName={iconContainerClasses}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackgroundColor: borderColor\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\tclassName={styles['MrlAvatar-icon']}\n\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\tsvg={kind === 'facilitator' ? facilitatorBadge : lock}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["defaultAvatarValues","avatarColor","kind","size","MrlAvatar","_ref","alt","_ref$avatarColor","dataQa","_ref$kind","image","name","onImageError","_ref$showBorder","showBorder","_ref$size","rest","_objectWithoutProperties","_excluded","containerClasses","classNames","styles","concat","isFacilitatorSize","showIcon","iconContainerClasses","getAvatarRgb","isValidHexColor","hexToRgb","toString","isValidRgbString","substring","length","isValidRgbaString","lastComma","lastIndexOf","renderImage","imgAltText","React","createElement","className","onError","src","getInitials","str","textLength","split","map","item","charAt","toUpperCase","join","replace","isDarkText","stickyTextColor","safeColor","backgroundColor","borderColor","textColor","_extends","style","color","MrlSvg","svg","facilitatorBadge","lock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDO,IAAMA,mBAAmC,GAAG;AAClDC,EAAAA,WAAW,EAAE,SAAS;AACtBC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,IAAI,EAAE;AACP;;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMC,SAAS,GAAGC,IAAA,IAWqB;AAAA,EAAA,IAV7CC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAAC,gBAAA,GAAAF,IAAA,CACHJ,WAAW;AAAXA,IAAAA,WAAW,GAAAM,gBAAA,KAAA,MAAA,GAAGP,mBAAmB,CAACC,WAAW,GAAAM,gBAAA;IAC7CC,MAAM,GAAAH,IAAA,CAANG,MAAM;IAAA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AAAA,KAAK,EAAEH;AACR;GAAE,EAEDhD,KAAK,GAAG0B,WAAW,EAAE,gBAAGE,gBAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IAAM,aAAA,EAAY;GAAM,EAAEI,WAAW,CAAChC,IAAI,CAAQ,CACtE,CAAC,EACNa,QAAQ,iBACRc,gBAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AACCC,IAAAA,SAAS,EAAEf,oBAAqB;AAChCmC,IAAAA,KAAK,EAAE;AACNJ,MAAAA,eAAe,EAAEC;AAClB;AAAE,GAAA,eAEFnB,gBAAA,CAAAC,aAAA,CAACuB,aAAM,EAAA;AACNtB,IAAAA,SAAS,EAAEnB,wBAAM,CAAC,gBAAgB,CAAE;AACpClB,IAAAA,IAAI,EAAC,MAAM;AACX4D,IAAAA,GAAG,EAAE7D,IAAI,KAAK,aAAa,GAAG8D,wBAAgB,GAAGC;GACjD,CACI,CAEH,CAAC;AAER;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MrlCallout.js","sources":["../../../../../src/components/callout/MrlCallout/MrlCallout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MrlPopover, MrlPopoverProps } from '../../popover';\nimport { MrlText, MrlTextHeading } from '../../text';\nimport styles from './MrlCallout.module.scss';\nimport { MrlButton } from '../../button';\nimport { getUniqueId } from '../../../utils';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport { useRef } from 'react';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport type MrlCalloutPopoverProps = Omit<\n\tMrlPopoverProps,\n\t'children' | 'actionState' | 'isSubMenu' | 'triggerRef' | 'kind'\n>;\n\ninterface MrlCalloutCTA {\n\tonClick: () => void;\n\tdataQa?: string;\n\ttext: string;\n}\n\nexport interface MrlCalloutProps extends MrlCalloutPopoverProps {\n\t/** a unique id that binds the callout content and the trigger for assistive technologies */\n\tariaControls?: string;\n\t/** Has no effect (passed to the popover container, which ignores it). Focus on open is handled by the popover; see `disableFocusTrap`. Kept for backwards compatibility. */\n\tautoFocus?: boolean;\n\tchildren: React.ReactElement;\n\tdisableClickOutside?: boolean;\n\t/** Body text of the callout. A string renders as MrlText; pass an element for rich content. */\n\tdescription?: string | JSX.Element;\n\t/** Short label rendered above the title. */\n\teyebrow?: string;\n\tid?: string;\n\t/** Illustration rendered between the description and the actions. */\n\timage?: JSX.Element;\n\t/** Has no effect. Kept for backwards compatibility. The callout renders in the callout portal layer unless `portalProps` is overridden. */\n\trenderWithPortal?: boolean;\n\t/** Whether the callout is open. The consumer controls visibility; the trigger child gets `aria-expanded` from it. */\n\tshow: boolean;\n\t/** Heading of the callout, rendered as a level 2 heading. */\n\ttitle?: string;\n\t/** Primary action button rendered at the bottom of the callout. */\n\tprimaryCta?: MrlCalloutCTA;\n\t/** Secondary action button rendered before the primary one. */\n\tsecondaryCta?: MrlCalloutCTA;\n\t/**\n\t * Enables interaction tracking for this callout. Provide a stable, non-PII id\n\t * (e.g. 'ai-onboarding-callout'). When omitted, the callout emits no analytics.\n\t *\n\t * Note: title, eyebrow and description text are never emitted.\n\t */\n\teventId?: string;\n}\n\ntype MrlCalloutContent = Pick<\n\tMrlCalloutProps,\n\t'alignment' | 'description' | 'eyebrow' | 'image' | 'title'\n>;\n\n/**\n * MrlCallout component.\n *\n * @param props - The props.\n * @returns {React.ReactElement} The MrlCallout component.\n */\nexport const MrlCallout = (props: MrlCalloutProps): React.ReactElement => {\n\t// In some cases when `show` is false, the content is also null or empty.\n\t// At the same time callout shows fade-out animation and do not disappear immediately.\n\t// Saving last visible content to show it while animating on close.\n\tconst savedContent = useRef<MrlCalloutContent>();\n\tif (props.show) {\n\t\tsavedContent.current = {\n\t\t\talignment: props.alignment,\n\t\t\tdescription: props.description,\n\t\t\teyebrow: props.eyebrow,\n\t\t\timage: props.image,\n\t\t\ttitle: props.title\n\t\t};\n\t}\n\n\tconst {\n\t\tariaControls,\n\t\talignment = 'center',\n\t\tchildren,\n\t\tdescription,\n\t\tdisableClickOutside = true,\n\t\tdisableFocusTrap = true,\n\t\teyebrow,\n\t\thasCloseButton = true,\n\t\timage,\n\t\tonOpen,\n\t\tonClose,\n\t\tpoint = true,\n\t\tposition = 'bottom',\n\t\tprimaryCta,\n\t\tsecondaryCta,\n\t\tshow = true,\n\t\tspacing,\n\t\ttitle,\n\t\t// pulled out of `rest` so the nested MrlPopover doesn't emit a second, less\n\t\t// specific event for the same callout.\n\t\teventId,\n\t\t...rest\n\t} = props.show ? props : { ...props, ...savedContent.current };\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlCallout', eventId);\n\n\t// the callout's visibility is consumer-controlled through `show`, so open/close\n\t// is emitted from that rather than from the popover's internal state.\n\tconst wasShownRef = React.useRef(false);\n\n\tReact.useEffect(() => {\n\t\tif (wasShownRef.current === show) return;\n\n\t\twasShownRef.current = show;\n\n\t\ttrackInteraction({ action: show ? 'open' : 'close' });\n\t}, [show, trackInteraction]);\n\n\tif (React.isValidElement(children) && children.type === React.Fragment) {\n\t\tthrow new Error(\n\t\t\t'MrlCallout accepts a single child and does not accept a React.Fragment as a child.'\n\t\t);\n\t}\n\n\tconst calloutId = React.useMemo(() => getUniqueId('callout-append'), []);\n\tconst triggerRef = React.useRef<HTMLElement | null>(null);\n\n\tconst childElement = React.useMemo(() => {\n\t\treturn React.Children.map(children, (child) => {\n\t\t\treturn React.cloneElement(child, {\n\t\t\t\t...child.props,\n\t\t\t\t/** if the callout is tied to an interactive element we need to ensure that it has role=\"button\" */\n\t\t\t\t...(child.type !== 'button' && { role: 'button' }),\n\t\t\t\t'aria-controls': ariaControls,\n\t\t\t\t'aria-expanded': show,\n\t\t\t\tid: calloutId\n\t\t\t});\n\t\t});\n\t}, [calloutId, children, show, ariaControls]);\n\n\t// Setting trigger ref to the element with the calloutId (set above in the childElement useMemo)\n\t//\n\t// We are using querySelector to set the triggerRef instead of assigning a ref directly in childElement because\n\t// a child element may already have a ref assigned to it and we don't want to override it.\n\tReact.useEffect(() => {\n\t\ttriggerRef.current = document.querySelector(`#${calloutId}`) as HTMLElement;\n\t}, [calloutId]);\n\n\treturn (\n\t\t<>\n\t\t\t{childElement}\n\t\t\t{triggerRef && (\n\t\t\t\t<MrlPopover\n\t\t\t\t\tactionState={{ actionType: 'click', isOpen: show }}\n\t\t\t\t\talignment={alignment}\n\t\t\t\t\tclassName={styles['MrlCallout']}\n\t\t\t\t\tdisableClickToOpen\n\t\t\t\t\tdisableClickOutside={disableClickOutside}\n\t\t\t\t\tdisableFocusTrap={disableFocusTrap}\n\t\t\t\t\thasCloseButton={hasCloseButton}\n\t\t\t\t\tkind=\"inverse\"\n\t\t\t\t\tonClose={onClose}\n\t\t\t\t\tonOpen={onOpen}\n\t\t\t\t\tpoint={point}\n\t\t\t\t\tportalProps={{\n\t\t\t\t\t\tid: PORTAL_LAYERS.CALLOUT.name,\n\t\t\t\t\t\tlayer: PORTAL_LAYERS.CALLOUT\n\t\t\t\t\t}}\n\t\t\t\t\tposition={position}\n\t\t\t\t\tspacing={spacing}\n\t\t\t\t\ttriggerRef={triggerRef}\n\t\t\t\t\t{...rest}\n\t\t\t\t>\n\t\t\t\t\t<div className={styles['MrlCallout--content']}>\n\t\t\t\t\t\t{eyebrow && (\n\t\t\t\t\t\t\t<MrlText attrs={{ className: styles['MrlCallout--eyebrow'] }} text={eyebrow} />\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{title && (\n\t\t\t\t\t\t\t<MrlTextHeading className={styles['MrlCallout--title']} level=\"2\" text={title} />\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{description && (\n\t\t\t\t\t\t\t<div className={styles['MrlCallout--description']}>\n\t\t\t\t\t\t\t\t{typeof description === 'string' ? <MrlText text={description} /> : description}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{image && <div className={styles['MrlCallout--image']}>{image}</div>}\n\t\t\t\t\t\t{(primaryCta || secondaryCta) && (\n\t\t\t\t\t\t\t<div className={styles['MrlCallout--footer']}>\n\t\t\t\t\t\t\t\t{secondaryCta && (\n\t\t\t\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\t\t\t\tdata-qa={secondaryCta.dataQa}\n\t\t\t\t\t\t\t\t\t\tkind=\"ghost-inverse\"\n\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\ttrackInteraction({\n\t\t\t\t\t\t\t\t\t\t\t\taction: 'click',\n\t\t\t\t\t\t\t\t\t\t\t\tmetadata: { cta: 'secondary' }\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tsecondaryCta.onClick();\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\ttext={secondaryCta.text}\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t{primaryCta && (\n\t\t\t\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\t\t\t\tdata-qa={primaryCta.dataQa}\n\t\t\t\t\t\t\t\t\t\tkind=\"inverse\"\n\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\ttrackInteraction({\n\t\t\t\t\t\t\t\t\t\t\t\taction: 'click',\n\t\t\t\t\t\t\t\t\t\t\t\tmetadata: { cta: 'primary' }\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tprimaryCta.onClick();\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\ttext={primaryCta.text}\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</MrlPopover>\n\t\t\t)}\n\t\t</>\n\t);\n};\n"],"names":["MrlCallout","props","savedContent","useRef","show","current","alignment","description","eyebrow","image","title","_ref","_objectSpread","ariaControls","_ref$alignment","children","_ref$disableClickOuts","disableClickOutside","_ref$disableFocusTrap","disableFocusTrap","_ref$hasCloseButton","hasCloseButton","onOpen","onClose","_ref$point","point","_ref$position","position","primaryCta","secondaryCta","_ref$show","spacing","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","wasShownRef","React","useEffect","action","isValidElement","type","Fragment","Error","calloutId","useMemo","getUniqueId","triggerRef","childElement","Children","map","child","cloneElement","role","id","document","querySelector","concat","createElement","MrlPopover","_extends","actionState","actionType","isOpen","className","styles","disableClickToOpen","kind","portalProps","PORTAL_LAYERS","CALLOUT","name","layer","MrlText","attrs","text","MrlTextHeading","level","MrlButton","dataQa","onClick","metadata","cta","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,UAAU,GAAIC,KAAsB,IAAyB;AACzE;AACA;AACA;AACA,EAAA,IAAMC,YAAY,GAAGC,YAAM,EAAqB;EAChD,IAAIF,KAAK,CAACG,IAAI,EAAE;IACfF,YAAY,CAACG,OAAO,GAAG;MACtBC,SAAS,EAAEL,KAAK,CAACK,SAAS;MAC1BC,WAAW,EAAEN,KAAK,CAACM,WAAW;MAC9BC,OAAO,EAAEP,KAAK,CAACO,OAAO;MACtBC,KAAK,EAAER,KAAK,CAACQ,KAAK;MAClBC,KAAK,EAAET,KAAK,CAACS;KACb;AACF,EAAA;AAEA,EAAA,IAAAC,IAAA,GAuBIV,KAAK,CAACG,IAAI,GAAGH,KAAK,GAAAW,uCAAA,CAAAA,uCAAA,CAAA,EAAA,EAAQX,KAAK,GAAKC,YAAY,CAACG,OAAO,CAAE;IAtB7DQ,YAAY,GAAAF,IAAA,CAAZE,YAAY;IAAAC,cAAA,GAAAH,IAAA,CACZL,SAAS;AAATA,IAAAA,SAAS,GAAAQ,cAAA,KAAA,MAAA,GAAG,QAAQ,GAAAA,cAAA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A,MAAM,EAAE,OAAO;AACf0C,QAAAA,QAAQ,EAAE;AAAEC,UAAAA,GAAG,EAAE;AAAY;AAC9B,OAAC,CAAC;MAEFvD,YAAY,CAACqD,OAAO,EAAE;IACvB,CAAE;IACFL,IAAI,EAAEhD,YAAY,CAACgD,IAAK;AACxBQ,IAAAA,IAAI,EAAC;GACL,CACD,EACAzD,UAAU,iBACVW,gBAAA,CAAAqB,aAAA,CAACoB,mBAAS,EAAA;IACT,SAAA,EAASpD,UAAU,CAACqD,MAAO;AAC3BZ,IAAAA,IAAI,EAAC,SAAS;IACda,OAAO,EAAEA,MAAM;AACd9C,MAAAA,gBAAgB,CAAC;AAChBK,QAAAA,MAAM,EAAE,OAAO;AACf0C,QAAAA,QAAQ,EAAE;AAAEC,UAAAA,GAAG,EAAE;AAAU;AAC5B,OAAC,CAAC;MAEFxD,UAAU,CAACsD,OAAO,EAAE;IACrB,CAAE;IACFL,IAAI,EAAEjD,UAAU,CAACiD,IAAK;AACtBQ,IAAAA,IAAI,EAAC;AAAO,GACZ,CAEE,CAEF,CACM,CAEZ,CAAC;AAEL;;;;"}
1
+ {"version":3,"file":"MrlCallout.js","sources":["../../../../../src/components/callout/MrlCallout/MrlCallout.tsx"],"sourcesContent":["import * as React from 'react';\nimport { MrlPopover, MrlPopoverProps } from '../../popover';\nimport { MrlText, MrlTextHeading } from '../../text';\nimport styles from './MrlCallout.module.scss';\nimport { MrlButton } from '../../button';\nimport { getUniqueId } from '../../../utils';\nimport { PORTAL_LAYERS } from '../../../utils/layers';\nimport { useRef } from 'react';\nimport { useMrlTrackInteraction } from '../../../hooks/useMrlAnalytics';\n\nexport type MrlCalloutPopoverProps = Omit<\n\tMrlPopoverProps,\n\t'children' | 'actionState' | 'isSubMenu' | 'triggerRef' | 'kind'\n>;\n\nexport interface MrlCalloutCTA {\n\tonClick: () => void;\n\tdataQa?: string;\n\ttext: string;\n}\n\nexport interface MrlCalloutProps extends MrlCalloutPopoverProps {\n\t/** a unique id that binds the callout content and the trigger for assistive technologies */\n\tariaControls?: string;\n\t/** Has no effect (passed to the popover container, which ignores it). Focus on open is handled by the popover; see `disableFocusTrap`. Kept for backwards compatibility. */\n\tautoFocus?: boolean;\n\tchildren: React.ReactElement;\n\tdisableClickOutside?: boolean;\n\t/** Body text of the callout. A string renders as MrlText; pass an element for rich content. */\n\tdescription?: string | JSX.Element;\n\t/** Short label rendered above the title. */\n\teyebrow?: string;\n\tid?: string;\n\t/** Illustration rendered between the description and the actions. */\n\timage?: JSX.Element;\n\t/** Has no effect. Kept for backwards compatibility. The callout renders in the callout portal layer unless `portalProps` is overridden. */\n\trenderWithPortal?: boolean;\n\t/** Whether the callout is open. The consumer controls visibility; the trigger child gets `aria-expanded` from it. */\n\tshow: boolean;\n\t/** Heading of the callout, rendered as a level 2 heading. */\n\ttitle?: string;\n\t/** Primary action button rendered at the bottom of the callout. */\n\tprimaryCta?: MrlCalloutCTA;\n\t/** Secondary action button rendered before the primary one. */\n\tsecondaryCta?: MrlCalloutCTA;\n\t/**\n\t * Enables interaction tracking for this callout. Provide a stable, non-PII id\n\t * (e.g. 'ai-onboarding-callout'). When omitted, the callout emits no analytics.\n\t *\n\t * Note: title, eyebrow and description text are never emitted.\n\t */\n\teventId?: string;\n}\n\ntype MrlCalloutContent = Pick<\n\tMrlCalloutProps,\n\t'alignment' | 'description' | 'eyebrow' | 'image' | 'title'\n>;\n\n/**\n * MrlCallout component.\n *\n * @param props - The props.\n * @returns {React.ReactElement} The MrlCallout component.\n */\nexport const MrlCallout = (props: MrlCalloutProps): React.ReactElement => {\n\t// In some cases when `show` is false, the content is also null or empty.\n\t// At the same time callout shows fade-out animation and do not disappear immediately.\n\t// Saving last visible content to show it while animating on close.\n\tconst savedContent = useRef<MrlCalloutContent>();\n\tif (props.show) {\n\t\tsavedContent.current = {\n\t\t\talignment: props.alignment,\n\t\t\tdescription: props.description,\n\t\t\teyebrow: props.eyebrow,\n\t\t\timage: props.image,\n\t\t\ttitle: props.title\n\t\t};\n\t}\n\n\tconst {\n\t\tariaControls,\n\t\talignment = 'center',\n\t\tchildren,\n\t\tdescription,\n\t\tdisableClickOutside = true,\n\t\tdisableFocusTrap = true,\n\t\teyebrow,\n\t\thasCloseButton = true,\n\t\timage,\n\t\tonOpen,\n\t\tonClose,\n\t\tpoint = true,\n\t\tposition = 'bottom',\n\t\tprimaryCta,\n\t\tsecondaryCta,\n\t\tshow = true,\n\t\tspacing,\n\t\ttitle,\n\t\t// pulled out of `rest` so the nested MrlPopover doesn't emit a second, less\n\t\t// specific event for the same callout.\n\t\teventId,\n\t\t...rest\n\t} = props.show ? props : { ...props, ...savedContent.current };\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlCallout', eventId);\n\n\t// the callout's visibility is consumer-controlled through `show`, so open/close\n\t// is emitted from that rather than from the popover's internal state.\n\tconst wasShownRef = React.useRef(false);\n\n\tReact.useEffect(() => {\n\t\tif (wasShownRef.current === show) return;\n\n\t\twasShownRef.current = show;\n\n\t\ttrackInteraction({ action: show ? 'open' : 'close' });\n\t}, [show, trackInteraction]);\n\n\tif (React.isValidElement(children) && children.type === React.Fragment) {\n\t\tthrow new Error(\n\t\t\t'MrlCallout accepts a single child and does not accept a React.Fragment as a child.'\n\t\t);\n\t}\n\n\tconst calloutId = React.useMemo(() => getUniqueId('callout-append'), []);\n\tconst triggerRef = React.useRef<HTMLElement | null>(null);\n\n\tconst childElement = React.useMemo(() => {\n\t\treturn React.Children.map(children, (child) => {\n\t\t\treturn React.cloneElement(child, {\n\t\t\t\t...child.props,\n\t\t\t\t/** if the callout is tied to an interactive element we need to ensure that it has role=\"button\" */\n\t\t\t\t...(child.type !== 'button' && { role: 'button' }),\n\t\t\t\t'aria-controls': ariaControls,\n\t\t\t\t'aria-expanded': show,\n\t\t\t\tid: calloutId\n\t\t\t});\n\t\t});\n\t}, [calloutId, children, show, ariaControls]);\n\n\t// Setting trigger ref to the element with the calloutId (set above in the childElement useMemo)\n\t//\n\t// We are using querySelector to set the triggerRef instead of assigning a ref directly in childElement because\n\t// a child element may already have a ref assigned to it and we don't want to override it.\n\tReact.useEffect(() => {\n\t\ttriggerRef.current = document.querySelector(`#${calloutId}`) as HTMLElement;\n\t}, [calloutId]);\n\n\treturn (\n\t\t<>\n\t\t\t{childElement}\n\t\t\t{triggerRef && (\n\t\t\t\t<MrlPopover\n\t\t\t\t\tactionState={{ actionType: 'click', isOpen: show }}\n\t\t\t\t\talignment={alignment}\n\t\t\t\t\tclassName={styles['MrlCallout']}\n\t\t\t\t\tdisableClickToOpen\n\t\t\t\t\tdisableClickOutside={disableClickOutside}\n\t\t\t\t\tdisableFocusTrap={disableFocusTrap}\n\t\t\t\t\thasCloseButton={hasCloseButton}\n\t\t\t\t\tkind=\"inverse\"\n\t\t\t\t\tonClose={onClose}\n\t\t\t\t\tonOpen={onOpen}\n\t\t\t\t\tpoint={point}\n\t\t\t\t\tportalProps={{\n\t\t\t\t\t\tid: PORTAL_LAYERS.CALLOUT.name,\n\t\t\t\t\t\tlayer: PORTAL_LAYERS.CALLOUT\n\t\t\t\t\t}}\n\t\t\t\t\tposition={position}\n\t\t\t\t\tspacing={spacing}\n\t\t\t\t\ttriggerRef={triggerRef}\n\t\t\t\t\t{...rest}\n\t\t\t\t>\n\t\t\t\t\t<div className={styles['MrlCallout--content']}>\n\t\t\t\t\t\t{eyebrow && (\n\t\t\t\t\t\t\t<MrlText attrs={{ className: styles['MrlCallout--eyebrow'] }} text={eyebrow} />\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{title && (\n\t\t\t\t\t\t\t<MrlTextHeading className={styles['MrlCallout--title']} level=\"2\" text={title} />\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{description && (\n\t\t\t\t\t\t\t<div className={styles['MrlCallout--description']}>\n\t\t\t\t\t\t\t\t{typeof description === 'string' ? <MrlText text={description} /> : description}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{image && <div className={styles['MrlCallout--image']}>{image}</div>}\n\t\t\t\t\t\t{(primaryCta || secondaryCta) && (\n\t\t\t\t\t\t\t<div className={styles['MrlCallout--footer']}>\n\t\t\t\t\t\t\t\t{secondaryCta && (\n\t\t\t\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\t\t\t\tdata-qa={secondaryCta.dataQa}\n\t\t\t\t\t\t\t\t\t\tkind=\"ghost-inverse\"\n\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\ttrackInteraction({\n\t\t\t\t\t\t\t\t\t\t\t\taction: 'click',\n\t\t\t\t\t\t\t\t\t\t\t\tmetadata: { cta: 'secondary' }\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tsecondaryCta.onClick();\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\ttext={secondaryCta.text}\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t{primaryCta && (\n\t\t\t\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\t\t\t\tdata-qa={primaryCta.dataQa}\n\t\t\t\t\t\t\t\t\t\tkind=\"inverse\"\n\t\t\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\t\t\ttrackInteraction({\n\t\t\t\t\t\t\t\t\t\t\t\taction: 'click',\n\t\t\t\t\t\t\t\t\t\t\t\tmetadata: { cta: 'primary' }\n\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\tprimaryCta.onClick();\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\ttext={primaryCta.text}\n\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t</MrlPopover>\n\t\t\t)}\n\t\t</>\n\t);\n};\n"],"names":["MrlCallout","props","savedContent","useRef","show","current","alignment","description","eyebrow","image","title","_ref","_objectSpread","ariaControls","_ref$alignment","children","_ref$disableClickOuts","disableClickOutside","_ref$disableFocusTrap","disableFocusTrap","_ref$hasCloseButton","hasCloseButton","onOpen","onClose","_ref$point","point","_ref$position","position","primaryCta","secondaryCta","_ref$show","spacing","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","wasShownRef","React","useEffect","action","isValidElement","type","Fragment","Error","calloutId","useMemo","getUniqueId","triggerRef","childElement","Children","map","child","cloneElement","role","id","document","querySelector","concat","createElement","MrlPopover","_extends","actionState","actionType","isOpen","className","styles","disableClickToOpen","kind","portalProps","PORTAL_LAYERS","CALLOUT","name","layer","MrlText","attrs","text","MrlTextHeading","level","MrlButton","dataQa","onClick","metadata","cta","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,UAAU,GAAIC,KAAsB,IAAyB;AACzE;AACA;AACA;AACA,EAAA,IAAMC,YAAY,GAAGC,YAAM,EAAqB;EAChD,IAAIF,KAAK,CAACG,IAAI,EAAE;IACfF,YAAY,CAACG,OAAO,GAAG;MACtBC,SAAS,EAAEL,KAAK,CAACK,SAAS;MAC1BC,WAAW,EAAEN,KAAK,CAACM,WAAW;MAC9BC,OAAO,EAAEP,KAAK,CAACO,OAAO;MACtBC,KAAK,EAAER,KAAK,CAACQ,KAAK;MAClBC,KAAK,EAAET,KAAK,CAACS;KACb;AACF,EAAA;AAEA,EAAA,IAAAC,IAAA,GAuBIV,KAAK,CAACG,IAAI,GAAGH,KAAK,GAAAW,uCAAA,CAAAA,uCAAA,CAAA,EAAA,EAAQX,KAAK,GAAKC,YAAY,CAACG,OAAO,CAAE;IAtB7DQ,YAAY,GAAAF,IAAA,CAAZE,YAAY;IAAAC,cAAA,GAAAH,IAA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IAAI,EAAC,eAAe;IACpBa,OAAO,EAAEA,MAAM;AACd9C,MAAAA,gBAAgB,CAAC;AAChBK,QAAAA,MAAM,EAAE,OAAO;AACf0C,QAAAA,QAAQ,EAAE;AAAEC,UAAAA,GAAG,EAAE;AAAY;AAC9B,OAAC,CAAC;MAEFvD,YAAY,CAACqD,OAAO,EAAE;IACvB,CAAE;IACFL,IAAI,EAAEhD,YAAY,CAACgD,IAAK;AACxBQ,IAAAA,IAAI,EAAC;GACL,CACD,EACAzD,UAAU,iBACVW,gBAAA,CAAAqB,aAAA,CAACoB,mBAAS,EAAA;IACT,SAAA,EAASpD,UAAU,CAACqD,MAAO;AAC3BZ,IAAAA,IAAI,EAAC,SAAS;IACda,OAAO,EAAEA,MAAM;AACd9C,MAAAA,gBAAgB,CAAC;AAChBK,QAAAA,MAAM,EAAE,OAAO;AACf0C,QAAAA,QAAQ,EAAE;AAAEC,UAAAA,GAAG,EAAE;AAAU;AAC5B,OAAC,CAAC;MAEFxD,UAAU,CAACsD,OAAO,EAAE;IACrB,CAAE;IACFL,IAAI,EAAEjD,UAAU,CAACiD,IAAK;AACtBQ,IAAAA,IAAI,EAAC;AAAO,GACZ,CAEE,CAEF,CACM,CAEZ,CAAC;AAEL;;;;"}
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
35
35
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
36
36
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
37
37
 
38
- var _excluded = ["attrs", "className", "description", "hasMultilineLabel", "state", "selected", "icon", "label", "eventId"];
38
+ var _excluded = ["attrs", "className", "description", "hasMultilineLabel", "state", "selected", "icon", "label", "eventId", "onChange"];
39
39
  /**
40
40
  * Form element with an associated text label that allows the user to select one or more options
41
41
  * from a provided list
@@ -56,6 +56,8 @@ function MrlCheckbox(_ref) {
56
56
  icon = _ref.icon,
57
57
  label = _ref.label,
58
58
  eventId = _ref.eventId,
59
+ _ref$onChange = _ref.onChange,
60
+ onChange = _ref$onChange === void 0 ? attrs.onChange : _ref$onChange,
59
61
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
60
62
  var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlCheckbox', eventId);
61
63
  var checkboxIdRef = React__namespace.useRef(setAttributes.getUniqueId('mrl-checkbox'));
@@ -76,24 +78,27 @@ function MrlCheckbox(_ref) {
76
78
  // setAttributes always sets className="" which always triggers the warning message in the MrlCheckboxStandalone component
77
79
  delete attributes.className;
78
80
 
79
- // the consumer's handler arrives through `attrs`, so wrap it before handing the
80
- // attributes down to the standalone input.
81
- var consumerOnChange = attributes.onChange;
82
- attributes.onChange = e => {
81
+ /**
82
+ * Handle change events
83
+ *
84
+ * @param {React.ChangeEvent<HTMLInputElement>} e - change event
85
+ */
86
+ var handleChange = e => {
83
87
  trackInteraction({
84
88
  action: 'checked',
85
89
  metadata: {
86
90
  selected: e.target.checked
87
91
  }
88
92
  });
89
- consumerOnChange === null || consumerOnChange === void 0 ? void 0 : consumerOnChange(e);
93
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
90
94
  };
91
95
  return /*#__PURE__*/React__namespace.createElement("div", {
92
96
  className: allClasses
93
97
  }, /*#__PURE__*/React__namespace.createElement(MrlCheckboxStandalone.MrlCheckboxStandalone, _rollupPluginBabelHelpers.extends({}, rest, {
98
+ attrs: attributes,
99
+ onChange: handleChange,
94
100
  selected: selected,
95
- state: state,
96
- attrs: attributes
101
+ state: state
97
102
  })), /*#__PURE__*/React__namespace.createElement(MrlLabelWithDescription.MrlLabelWithDescription, {
98
103
  isDisabled: state === 'disabled',
99
104
  isSelected: selected === 'checked',
@@ -1 +1 @@
1
- {"version":3,"file":"MrlCheckbox.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckbox/MrlCheckbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport {\n\tcheckboxDefaults,\n\tCheckboxSelected,\n\tCheckboxStates,\n\tStaticIconConfig\n} from '../../constants';\nimport { MrlCheckboxStandalone } from '../MrlCheckboxStandalone/MrlCheckboxStandalone';\nimport { checkInvalidAttributes } from '../../../../utils/checkInvalidAttributes';\n\nimport './MrlCheckbox.global.scss';\nimport styles from './MrlCheckbox.module.scss';\nimport { MrlLabelWithDescription } from '../../label/MrlLabelWithDescription';\nimport { getDescribedby } from '../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlCheckboxProps {\n\t/** Applies additional HTML attributes to the checkbox element */\n\tattrs?: AttrsObject;\n\t/** Additional class to add to the container of the checkbox and label */\n\tclassName?: string;\n\t/** Adjusts the styles of the label, icon and description when the label is multiline */\n\thasMultilineLabel?: boolean;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/** Sets what selection state the checkbox is in. */\n\tselected?: CheckboxSelected;\n\t/** The text to display as the checkbox's label */\n\tlabel: string;\n\t/** Leading label icon */\n\ticon?: StaticIconConfig;\n\t/**\n\t * Description, additional context text for the user.\n\t * It can be a string or a React component for custom render.\n\t * When using a React component it's necessary to add an id to the custom element and\n\t * pass it to the MrlCheckbox through 'attrs[\"aria-describedby\"]' to make it accessible\n\t * to screen readers.\n\t * Custom description should also implement the disabled state styles\n\t * for text when the input is disabled or set color: inherit.\n\t * @example\n\t * <MrlCheckbox attrs={{ 'aria-describedby': customId }} description={\n\t * <p id={customId}>description</p>\n\t * }>\n\t */\n\tdescription?: string | React.ReactNode;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Form element with an associated text label that allows the user to select one or more options\n * from a provided list\n * @param {MrlCheckboxProps} props - the component props\n * @returns a checkbox element with an associated label\n */\nexport function MrlCheckbox({\n\tattrs = {},\n\tclassName,\n\tdescription,\n\thasMultilineLabel = false,\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\ticon,\n\tlabel,\n\teventId,\n\t...rest\n}: MrlCheckboxProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckbox', eventId);\n\tconst checkboxIdRef = React.useRef<string>(getUniqueId('mrl-checkbox'));\n\tconst descriptionId = `${checkboxIdRef.current}-description`;\n\n\tconst allClasses = classnames(\n\t\tattrs.class || attrs.className,\n\t\tclassName,\n\t\t'MrlCheckbox',\n\t\tstyles['MrlCheckbox'],\n\t\t{\n\t\t\t[styles['mrl-is--disabled']]: state === 'disabled',\n\t\t\t[styles['mrl-is--invalid']]: state === 'error',\n\t\t\t[styles['mrl-is--selected']]: selected === 'checked',\n\t\t\t[styles['mrl-is--indeterminate']]: selected === 'indeterminate'\n\t\t}\n\t);\n\n\tcheckInvalidAttributes(attrs);\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs, {\n\t\t...getDescribedby(\n\t\t\tattrs['aria-describedby'],\n\t\t\ttypeof description === 'string' ? descriptionId : undefined\n\t\t),\n\t\tid: checkboxIdRef.current\n\t});\n\n\t// setAttributes always sets className=\"\" which always triggers the warning message in the MrlCheckboxStandalone component\n\tdelete attributes.className;\n\n\t// the consumer's handler arrives through `attrs`, so wrap it before handing the\n\t// attributes down to the standalone input.\n\tconst consumerOnChange = attributes.onChange as\n\t\t| ((e: React.ChangeEvent<HTMLInputElement>) => void)\n\t\t| undefined;\n\n\tattributes.onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'checked', metadata: { selected: e.target.checked } });\n\n\t\tconsumerOnChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={allClasses}>\n\t\t\t<MrlCheckboxStandalone {...rest} selected={selected} state={state} attrs={attributes} />\n\t\t\t<MrlLabelWithDescription\n\t\t\t\tisDisabled={state === 'disabled'}\n\t\t\t\tisSelected={selected === 'checked'}\n\t\t\t\tisIndeterminate={selected === 'indeterminate'}\n\t\t\t\thasMultilineLabel={hasMultilineLabel}\n\t\t\t\thtmlFor={checkboxIdRef.current}\n\t\t\t\ticon={icon}\n\t\t\t\tlabel={label}\n\t\t\t\tdescription={description}\n\t\t\t\tdescriptionId={descriptionId}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckbox","_ref","_ref$attrs","attrs","className","description","_ref$hasMultilineLabe","hasMultilineLabel","_ref$state","state","checkboxDefaults","_ref$selected","selected","icon","label","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","getUniqueId","descriptionId","concat","current","allClasses","classnames","class","styles","checkInvalidAttributes","attributes","setAttributes","_objectSpread","getDescribedby","undefined","id","consumerOnChange","onChange","e","action","metadata","target","checked","createElement","MrlCheckboxStandalone","_extends","MrlLabelWithDescription","isDisabled","isSelected","isIndeterminate","htmlFor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAAAC,IAAA,EAWO;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAVjCE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;IAAAC,qBAAA,GAAAL,IAAA,CACXM,iBAAiB;AAAjBA,IAAAA,iBAAiB,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;IAAAE,UAAA,GAAAP,IAAA,CACzBQ,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAGE,0BAAgB,CAACD,KAAK,GAAAD,UAAA;IAAAG,aAAA,GAAAV,IAAA,CAC9BW,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAGD,0BAAgB,CAACE,QAA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+ {"version":3,"file":"MrlCheckbox.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckbox/MrlCheckbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport {\n\tcheckboxDefaults,\n\tCheckboxInputProps,\n\tCheckboxSelected,\n\tCheckboxStates,\n\tStaticIconConfig\n} from '../../constants';\nimport { MrlCheckboxStandalone } from '../MrlCheckboxStandalone/MrlCheckboxStandalone';\nimport { checkInvalidAttributes } from '../../../../utils/checkInvalidAttributes';\n\nimport './MrlCheckbox.global.scss';\nimport styles from './MrlCheckbox.module.scss';\nimport { MrlLabelWithDescription } from '../../label/MrlLabelWithDescription';\nimport { getDescribedby } from '../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlCheckboxProps extends CheckboxInputProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element\n\t *\n\t * @deprecated - use the regular HTML attributes instead. When an attribute is passed both\n\t * ways, the regular HTML attribute wins.\n\t */\n\tattrs?: AttrsObject;\n\t/** Additional class to add to the container of the checkbox and label */\n\tclassName?: string;\n\t/** Adjusts the styles of the label, icon and description when the label is multiline */\n\thasMultilineLabel?: boolean;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/** Sets what selection state the checkbox is in. */\n\tselected?: CheckboxSelected;\n\t/** The text to display as the checkbox's label */\n\tlabel: string;\n\t/** Leading label icon */\n\ticon?: StaticIconConfig;\n\t/**\n\t * Description, additional context text for the user.\n\t * It can be a string or a React component for custom render.\n\t * When using a React component it's necessary to add an id to the custom element and\n\t * pass it to the MrlCheckbox through \"aria-describedby\" to make it accessible\n\t * to screen readers.\n\t * Custom description should also implement the disabled state styles\n\t * for text when the input is disabled or set color: inherit.\n\t * @example\n\t * <MrlCheckbox aria-describedby={customId} description={\n\t * <p id={customId}>description</p>\n\t * }>\n\t */\n\tdescription?: string | React.ReactNode;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Form element with an associated text label that allows the user to select one or more options\n * from a provided list\n * @param {MrlCheckboxProps} props - the component props\n * @returns a checkbox element with an associated label\n */\nexport function MrlCheckbox({\n\tattrs = {},\n\tclassName,\n\tdescription,\n\thasMultilineLabel = false,\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\ticon,\n\tlabel,\n\teventId,\n\t// the regular HTML attribute wins over the deprecated `attrs` object\n\tonChange = attrs.onChange,\n\t...rest\n}: MrlCheckboxProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckbox', eventId);\n\tconst checkboxIdRef = React.useRef<string>(getUniqueId('mrl-checkbox'));\n\tconst descriptionId = `${checkboxIdRef.current}-description`;\n\n\tconst allClasses = classnames(\n\t\tattrs.class || attrs.className,\n\t\tclassName,\n\t\t'MrlCheckbox',\n\t\tstyles['MrlCheckbox'],\n\t\t{\n\t\t\t[styles['mrl-is--disabled']]: state === 'disabled',\n\t\t\t[styles['mrl-is--invalid']]: state === 'error',\n\t\t\t[styles['mrl-is--selected']]: selected === 'checked',\n\t\t\t[styles['mrl-is--indeterminate']]: selected === 'indeterminate'\n\t\t}\n\t);\n\n\tcheckInvalidAttributes(attrs);\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs, {\n\t\t...getDescribedby(\n\t\t\tattrs['aria-describedby'],\n\t\t\ttypeof description === 'string' ? descriptionId : undefined\n\t\t),\n\t\tid: checkboxIdRef.current\n\t});\n\n\t// setAttributes always sets className=\"\" which always triggers the warning message in the MrlCheckboxStandalone component\n\tdelete attributes.className;\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'checked', metadata: { selected: e.target.checked } });\n\n\t\tonChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={allClasses}>\n\t\t\t<MrlCheckboxStandalone\n\t\t\t\t{...rest}\n\t\t\t\tattrs={attributes}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tselected={selected}\n\t\t\t\tstate={state}\n\t\t\t/>\n\t\t\t<MrlLabelWithDescription\n\t\t\t\tisDisabled={state === 'disabled'}\n\t\t\t\tisSelected={selected === 'checked'}\n\t\t\t\tisIndeterminate={selected === 'indeterminate'}\n\t\t\t\thasMultilineLabel={hasMultilineLabel}\n\t\t\t\thtmlFor={checkboxIdRef.current}\n\t\t\t\ticon={icon}\n\t\t\t\tlabel={label}\n\t\t\t\tdescription={description}\n\t\t\t\tdescriptionId={descriptionId}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckbox","_ref","_ref$attrs","attrs","className","description","_ref$hasMultilineLabe","hasMultilineLabel","_ref$state","state","checkboxDefaults","_ref$selected","selected","icon","label","eventId","_ref$onChange","onChange","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","getUniqueId","descriptionId","concat","current","allClasses","classnames","class","styles","checkInvalidAttributes","attributes","setAttributes","_objectSpread","getDescribedby","undefined","id","handleChange","e","action","metadata","target","checked","createElement","MrlCheckboxStandalone","_extends","MrlLabelWithDescription","isDisabled","isSelected","isIndeterminate","htmlFor"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAAAC,IAAA,EAaO;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAZjCE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;I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,KAAK,EAAEA;AAAM,GAAA,CACb,CAAC,eACFe,gBAAA,CAAAuB,aAAA,CAACG,+CAAuB,EAAA;IACvBC,UAAU,EAAE1C,KAAK,KAAK,UAAW;IACjC2C,UAAU,EAAExC,QAAQ,KAAK,SAAU;IACnCyC,eAAe,EAAEzC,QAAQ,KAAK,eAAgB;AAC9CL,IAAAA,iBAAiB,EAAEA,iBAAkB;IACrC+C,OAAO,EAAE/B,aAAa,CAACM,OAAQ;AAC/BhB,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,KAAK,EAAEA,KAAM;AACbT,IAAAA,WAAW,EAAEA,WAAY;AACzBsB,IAAAA,aAAa,EAAEA;AAAc,GAC7B,CACG,CAAC;AAER;;;;"}
@@ -33,11 +33,13 @@ function _interopNamespace(e) {
33
33
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
34
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
35
35
 
36
- var _excluded = ["attrs", "state", "selected", "eventId"];
36
+ var _excluded = ["attrs", "state", "selected", "eventId", "id", "onChange", "aria-labelledby"];
37
37
  /**
38
38
  * Input that allows the user to select one or more options from a provided list.
39
39
  * Note, this component does not provide out of the box accessibility for ensuring
40
- * an associated label and must be manually setup during adoption.
40
+ * an associated label and must be manually setup during adoption: pass an `id` referenced
41
+ * by a `<label htmlFor>`, or `aria-labelledby` pointing to visible text (a console warning
42
+ * is logged when both are missing).
41
43
  * @param {MrlCheckboxStandaloneProps} props - the component props
42
44
  * @returns a checkbox element
43
45
  */
@@ -49,13 +51,19 @@ function MrlCheckboxStandalone(_ref) {
49
51
  _ref$selected = _ref.selected,
50
52
  selected = _ref$selected === void 0 ? constants.checkboxDefaults.selected : _ref$selected,
51
53
  eventId = _ref.eventId,
54
+ _ref$id = _ref.id,
55
+ id = _ref$id === void 0 ? attrs.id : _ref$id,
56
+ _ref$onChange = _ref.onChange,
57
+ onChange = _ref$onChange === void 0 ? attrs.onChange : _ref$onChange,
58
+ _ref$ariaLabelledby = _ref['aria-labelledby'],
59
+ ariaLabelledby = _ref$ariaLabelledby === void 0 ? attrs['aria-labelledby'] : _ref$ariaLabelledby,
52
60
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
53
61
  var trackInteraction = useMrlAnalytics.useMrlTrackInteraction('MrlCheckboxStandalone', eventId);
54
- // Use attrs.id if the developer passes in a custom id
62
+ // Use the id if the developer passes in a custom one
55
63
  // but we need to ensure one exists for accessibility
56
- var checkboxIdRef = React__namespace.useRef(attrs.id || setAttributes.getUniqueId('mrl-checkbox'));
64
+ var checkboxIdRef = React__namespace.useRef(id || setAttributes.getUniqueId('mrl-checkbox'));
57
65
  var inputRef = React__namespace.useRef(null);
58
- if (!(attrs.id || attrs['aria-labelledby'])) {
66
+ if (!(id || ariaLabelledby)) {
59
67
  console.warn('Warning: Mural Standalone Checkboxes must have either an id or' + ' aria-labelledby attribute for proper accessibility.');
60
68
  }
61
69
 
@@ -71,10 +79,6 @@ function MrlCheckboxStandalone(_ref) {
71
79
  delete attrs.className;
72
80
  var attributes = setAttributes.setAttributes(attrs);
73
81
 
74
- // the consumer's handler arrives through `attrs`, so wrap it here rather than
75
- // relying on a top-level onChange prop.
76
- var consumerOnChange = attributes.onChange;
77
-
78
82
  /**
79
83
  * Handle change events
80
84
  *
@@ -87,14 +91,15 @@ function MrlCheckboxStandalone(_ref) {
87
91
  selected: e.target.checked
88
92
  }
89
93
  });
90
- consumerOnChange === null || consumerOnChange === void 0 ? void 0 : consumerOnChange(e);
94
+ onChange === null || onChange === void 0 ? void 0 : onChange(e);
91
95
  };
92
96
  return /*#__PURE__*/React__namespace.createElement("div", {
93
97
  className: classnames__default.default(MrlCheckboxStandalone_module.default['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')
94
98
  }, /*#__PURE__*/React__namespace.createElement("span", {
95
99
  className: "mrl-u-focus-wrapper"
96
- }, /*#__PURE__*/React__namespace.createElement("input", _rollupPluginBabelHelpers.extends({}, rest, attributes, {
100
+ }, /*#__PURE__*/React__namespace.createElement("input", _rollupPluginBabelHelpers.extends({}, attributes, rest, {
97
101
  "aria-invalid": state === 'error',
102
+ "aria-labelledby": ariaLabelledby,
98
103
  checked: selected === 'checked',
99
104
  disabled: state === 'disabled',
100
105
  id: checkboxIdRef.current,
@@ -1 +1 @@
1
- {"version":3,"file":"MrlCheckboxStandalone.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport { check, minus } from '@muraldevkit/ds-icons';\nimport { checkboxDefaults, CheckboxSelected, CheckboxStates } from '../../constants';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlCheckboxStandalone.module.scss';\nimport './MrlCheckboxStandalone.global.scss';\n\ninterface MrlCheckboxStandaloneProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element. The component renders no label,\n\t * so label it here: an `id` referenced by a `<label htmlFor>`, or `aria-labelledby` pointing\n\t * to visible text (a console warning is logged when both are missing). Pass the `onChange`\n\t * handler here as well.\n\t */\n\tattrs?: AttrsObject;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/**\n\t * Sets what selection state the checkbox is in. The component is controlled: update it from\n\t * the `onChange` handler passed in `attrs`.\n\t */\n\tselected?: CheckboxSelected;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Input that allows the user to select one or more options from a provided list.\n * Note, this component does not provide out of the box accessibility for ensuring\n * an associated label and must be manually setup during adoption.\n * @param {MrlCheckboxStandaloneProps} props - the component props\n * @returns a checkbox element\n */\nexport function MrlCheckboxStandalone({\n\tattrs = {},\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\teventId,\n\t...rest\n}: MrlCheckboxStandaloneProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckboxStandalone', eventId);\n\t// Use attrs.id if the developer passes in a custom id\n\t// but we need to ensure one exists for accessibility\n\tconst checkboxIdRef = React.useRef<string>(attrs.id || getUniqueId('mrl-checkbox'));\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\n\tif (!(attrs.id || attrs['aria-labelledby'])) {\n\t\tconsole.warn(\n\t\t\t'Warning: Mural Standalone Checkboxes must have either an id or' +\n\t\t\t\t' aria-labelledby attribute for proper accessibility.'\n\t\t);\n\t}\n\n\t// We need to use the ref to set indetermiant attr\n\t// due to not being an intrinsic HTML attr\n\tReact.useEffect(() => {\n\t\tconst indeterminate = selected === 'indeterminate';\n\n\t\tif (inputRef.current) {\n\t\t\tinputRef.current.indeterminate = indeterminate;\n\t\t}\n\t}, [selected]);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs);\n\n\t// the consumer's handler arrives through `attrs`, so wrap it here rather than\n\t// relying on a top-level onChange prop.\n\tconst consumerOnChange = attributes.onChange as\n\t\t| ((e: React.ChangeEvent<HTMLInputElement>) => void)\n\t\t| undefined;\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'change', metadata: { selected: e.target.checked } });\n\n\t\tconsumerOnChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={classnames(styles['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')}>\n\t\t\t<span className=\"mrl-u-focus-wrapper\">\n\t\t\t\t<input\n\t\t\t\t\t{...rest}\n\t\t\t\t\t{...attributes}\n\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\tchecked={selected === 'checked'}\n\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\tid={checkboxIdRef.current}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-input'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-input'\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<span className=\"mrl-u-focus-indicator\"></span>\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-inputDisplay'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-inputDisplay'\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\tsvg={selected !== 'indeterminate' ? check : minus}\n\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\tclassName={styles['MrlCheckboxStandalone-inputDisplay-icon']}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckboxStandalone","_ref","_ref$attrs","attrs","_ref$state","state","checkboxDefaults","_ref$selected","selected","eventId","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","id","getUniqueId","inputRef","console","warn","useEffect","indeterminate","current","class","className","attributes","setAttributes","consumerOnChange","onChange","handleChange","e","action","metadata","target","checked","createElement","classnames","styles","_extends","disabled","ref","type","MrlSvg","svg","check","minus","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAqBA,CAAAC,IAAA,EAMO;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAL3CE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IAAAE,UAAA,GAAAH,IAAA,CACVI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oCACD;AAAE,GAAA,eAEFxB,gBAAA,CAAAsB,aAAA,CAACO,aAAM,EAAA;AACNC,IAAAA,GAAG,EAAEtC,QAAQ,KAAK,eAAe,GAAGuC,aAAK,GAAGC,aAAM;AAClDC,IAAAA,IAAI,EAAC,MAAM;IACXtB,SAAS,EAAEa,oCAAM,CAAC,yCAAyC;GAC3D,CACI,CACD,CACF,CAAC;AAER;;;;"}
1
+ {"version":3,"file":"MrlCheckboxStandalone.js","sources":["../../../../../../src/components/form/checkbox/MrlCheckboxStandalone/MrlCheckboxStandalone.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, getUniqueId, setAttributes } from '../../../../utils';\nimport { check, minus } from '@muraldevkit/ds-icons';\nimport {\n\tcheckboxDefaults,\n\tCheckboxInputProps,\n\tCheckboxSelected,\n\tCheckboxStates\n} from '../../constants';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlCheckboxStandalone.module.scss';\nimport './MrlCheckboxStandalone.global.scss';\n\ninterface MrlCheckboxStandaloneProps extends CheckboxInputProps {\n\t/**\n\t * Applies additional HTML attributes to the checkbox element\n\t *\n\t * @deprecated - use the regular HTML attributes instead. When an attribute is passed both\n\t * ways, the regular HTML attribute wins.\n\t */\n\tattrs?: AttrsObject;\n\t/** The current state of the checkbox input based on user interactions or permissions */\n\tstate?: CheckboxStates;\n\t/**\n\t * Sets what selection state the checkbox is in. The component is controlled: update it from\n\t * the `onChange` handler.\n\t */\n\tselected?: CheckboxSelected;\n\t/**\n\t * Enables interaction tracking for this checkbox. Provide a stable, non-PII id\n\t * (e.g. 'export-include-comments'). When omitted, the checkbox emits no analytics.\n\t */\n\teventId?: string;\n}\n\n/**\n * Input that allows the user to select one or more options from a provided list.\n * Note, this component does not provide out of the box accessibility for ensuring\n * an associated label and must be manually setup during adoption: pass an `id` referenced\n * by a `<label htmlFor>`, or `aria-labelledby` pointing to visible text (a console warning\n * is logged when both are missing).\n * @param {MrlCheckboxStandaloneProps} props - the component props\n * @returns a checkbox element\n */\nexport function MrlCheckboxStandalone({\n\tattrs = {},\n\tstate = checkboxDefaults.state,\n\tselected = checkboxDefaults.selected,\n\teventId,\n\t// the regular HTML attributes win over the deprecated `attrs` object\n\tid = attrs.id,\n\tonChange = attrs.onChange,\n\t'aria-labelledby': ariaLabelledby = attrs['aria-labelledby'],\n\t...rest\n}: MrlCheckboxStandaloneProps): JSX.Element {\n\tconst trackInteraction = useMrlTrackInteraction('MrlCheckboxStandalone', eventId);\n\t// Use the id if the developer passes in a custom one\n\t// but we need to ensure one exists for accessibility\n\tconst checkboxIdRef = React.useRef<string>(id || getUniqueId('mrl-checkbox'));\n\tconst inputRef = React.useRef<HTMLInputElement>(null);\n\n\tif (!(id || ariaLabelledby)) {\n\t\tconsole.warn(\n\t\t\t'Warning: Mural Standalone Checkboxes must have either an id or' +\n\t\t\t\t' aria-labelledby attribute for proper accessibility.'\n\t\t);\n\t}\n\n\t// We need to use the ref to set indetermiant attr\n\t// due to not being an intrinsic HTML attr\n\tReact.useEffect(() => {\n\t\tconst indeterminate = selected === 'indeterminate';\n\n\t\tif (inputRef.current) {\n\t\t\tinputRef.current.indeterminate = indeterminate;\n\t\t}\n\t}, [selected]);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs);\n\n\t/**\n\t * Handle change events\n\t *\n\t * @param {React.ChangeEvent<HTMLInputElement>} e - change event\n\t */\n\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\ttrackInteraction({ action: 'change', metadata: { selected: e.target.checked } });\n\n\t\tonChange?.(e);\n\t};\n\n\treturn (\n\t\t<div className={classnames(styles['MrlCheckboxStandalone'], 'MrlCheckboxStandalone')}>\n\t\t\t<span className=\"mrl-u-focus-wrapper\">\n\t\t\t\t<input\n\t\t\t\t\t{...attributes}\n\t\t\t\t\t{...rest}\n\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\taria-labelledby={ariaLabelledby}\n\t\t\t\t\tchecked={selected === 'checked'}\n\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\tid={checkboxIdRef.current}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tref={inputRef}\n\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-input'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-input'\n\t\t\t\t\t)}\n\t\t\t\t/>\n\t\t\t\t<span className=\"mrl-u-focus-indicator\"></span>\n\t\t\t\t<span\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlCheckboxStandalone-inputDisplay'],\n\t\t\t\t\t\t'MrlCheckboxStandalone-inputDisplay'\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\tsvg={selected !== 'indeterminate' ? check : minus}\n\t\t\t\t\t\tsize=\"auto\"\n\t\t\t\t\t\tclassName={styles['MrlCheckboxStandalone-inputDisplay-icon']}\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n"],"names":["MrlCheckboxStandalone","_ref","_ref$attrs","attrs","_ref$state","state","checkboxDefaults","_ref$selected","selected","eventId","_ref$id","id","_ref$onChange","onChange","_ref$ariaLabelledby","ariaLabelledby","rest","_objectWithoutProperties","_excluded","trackInteraction","useMrlTrackInteraction","checkboxIdRef","React","useRef","getUniqueId","inputRef","console","warn","useEffect","indeterminate","current","class","className","attributes","setAttributes","handleChange","e","action","metadata","target","checked","createElement","classnames","styles","_extends","disabled","ref","type","MrlSvg","svg","check","minus","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAqBA,CAAAC,IAAA,EAUO;AAAA,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K,UAAW;IAC/BM,EAAE,EAAEU,aAAa,CAACS,OAAQ;AAC1BjB,IAAAA,QAAQ,EAAEsB,YAAa;AACvBW,IAAAA,GAAG,EAAErB,QAAS;AACdsB,IAAAA,IAAI,EAAC,UAAU;IACff,SAAS,EAAEU,2BAAU,CACpBC,oCAAM,CAAC,6BAA6B,CAAC,EACrC,6BACD;AAAE,GAAA,CACF,CAAC,eACFrB,gBAAA,CAAAmB,aAAA,CAAA,MAAA,EAAA;AAAMT,IAAAA,SAAS,EAAC;AAAuB,GAAO,CAAC,eAC/CV,gBAAA,CAAAmB,aAAA,CAAA,MAAA,EAAA;IACCT,SAAS,EAAEU,2BAAU,CACpBC,oCAAM,CAAC,oCAAoC,CAAC,EAC5C,oCACD;AAAE,GAAA,eAEFrB,gBAAA,CAAAmB,aAAA,CAACO,aAAM,EAAA;AACNC,IAAAA,GAAG,EAAEzC,QAAQ,KAAK,eAAe,GAAG0C,aAAK,GAAGC,aAAM;AAClDC,IAAAA,IAAI,EAAC,MAAM;IACXpB,SAAS,EAAEW,oCAAM,CAAC,yCAAyC;GAC3D,CACI,CACD,CACF,CAAC;AAER;;;;"}
@@ -21,6 +21,12 @@ var allowedCheckboxValues = {
21
21
  selected: ['default', 'checked', 'indeterminate'],
22
22
  states: ['default', 'disabled', 'error', 'read-only']
23
23
  };
24
+
25
+ /**
26
+ * Native attributes accepted by the checkbox `input`. The omitted ones are driven by the
27
+ * component's own props (`selected`, `state`) or do not apply to the element.
28
+ */
29
+
24
30
  var checkboxDefaults = {
25
31
  selected: 'default',
26
32
  state: 'default'
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../src/components/form/constants.ts"],"sourcesContent":["import * as React from 'react';\nimport { DSIconType } from '../svg';\n\n/*\n * Shared error object for inputs\n * ------------------------------------------------------------------\n */\n/**\n * This should be used to communciate error information for a specific input\n */\nexport interface MrlFormInputError {\n\tmessage: string;\n}\n\n/*\n * Shared input values\n * ------------------------------------------------------------------\n */\nexport type InputStates = 'disabled' | 'error' | 'read-only';\nexport type InputKinds = 'default' | 'inline' | 'inline-label';\nexport type InputSizes = 'default' | 'large';\n\n/*\n * Checkbox component\n * ------------------------------------------------------------------\n */\nexport const allowedCheckboxValues = {\n\tselected: ['default', 'checked', 'indeterminate'] as const,\n\tstates: [\n\t\t'default',\n\t\t'disabled',\n\t\t'error',\n\t\t'read-only'\n\t] as const\n};\n\nexport type CheckboxStates = (typeof allowedCheckboxValues.states)[number];\nexport type CheckboxSelected = (typeof allowedCheckboxValues.selected)[number];\n\ninterface CheckboxDefaults {\n\tselected: CheckboxSelected;\n\tstate: CheckboxStates;\n}\n\nexport const checkboxDefaults: CheckboxDefaults = {\n\tselected: 'default',\n\tstate: 'default'\n};\n\n/*\n * Select component\n * ------------------------------------------------------------------\n */\n\nexport const allowedSelectItemValues = {\n\tstates: ['default', 'disabled', 'selected'] as const\n};\n\nexport type SelectItemStates = (typeof allowedSelectItemValues.states)[number];\n\ninterface SelectItemDefaults {\n\tstate: SelectItemStates;\n}\n\nexport const selectItemDefaults: SelectItemDefaults = {\n\tstate: 'default'\n};\n\nexport const allowedSelectMenuValues = {\n\tpositions: ['bottom', 'top'] as const\n};\n\nexport type SelectMenuPositions = (typeof allowedSelectMenuValues.positions)[number];\n\ninterface SelectMenuDefaults {\n\tposition: SelectMenuPositions;\n}\n\nexport const selectMenuDefaults: SelectMenuDefaults = {\n\tposition: 'bottom'\n};\n\n// Selects are an extension of the shared \"allowedValues\" object but\n// TypeScript won't let me combine the two objects.\nexport const allowedSelectValues = {\n\tstates: [\n\t\t'default',\n\t\t'disabled',\n\t\t'open',\n\t\t'read-only'\n\t] as const\n};\n\nexport type SelectStates = (typeof allowedSelectValues.states)[number];\n\ninterface SelectDefaults {\n\tsize: InputSizes;\n\tkind: InputKinds;\n\tstate: SelectStates;\n}\n\nexport const selectDefaults: SelectDefaults = {\n\tkind: 'default',\n\tsize: 'default',\n\tstate: 'default'\n};\n\n/*\n * Text Input component\n * ------------------------------------------------------------------\n */\nexport interface StaticIconConfig {\n\ticon: DSIconType;\n\ttheme?: string;\n}\n\nexport interface RightActionConfig extends StaticIconConfig {\n\taction: (event: React.MouseEvent | React.KeyboardEvent) => void;\n\tlabel: string;\n}\n\n/*\n * Label component\n * ------------------------------------------------------------------\n */\nexport const allowedLabelValues = {\n\tkinds: ['block', 'inline'] as const,\n\tstates: ['default', 'disabled'] as const\n};\n\nexport type LabelStates = (typeof allowedLabelValues.states)[number];\nexport type LabelKind = (typeof allowedLabelValues.kinds)[number];\n\ninterface LabelDefaults {\n\tkind: LabelKind;\n\tstate: LabelStates;\n}\n\nexport const labelDefaults: LabelDefaults = {\n\tkind: 'block',\n\tstate: 'default'\n};\n\nexport interface FormControlDefaults {\n\tdisabled: boolean;\n\tlabel: string;\n}\n\nexport interface FieldsetDefault {\n\tlabel: string;\n}\n\n/**\n * Default values for props on the Fieldset component;\n * Shared between the component and Storybook\n */\nexport const fieldsetDefault: FieldsetDefault = {\n\tlabel: \"fieldset's legend label\"\n};\n\n/**\n * Default values for props on the Fieldset component which is used to group Textarea components;\n * Shared between the component and Storybook\n */\nexport const textareaDefaults: FormControlDefaults = {\n\tdisabled: false,\n\tlabel: 'Legend'\n};\n"],"names":["allowedCheckboxValues","selected","states","checkboxDefaults","state","allowedSelectItemValues","selectItemDefaults","allowedSelectMenuValues","positions","selectMenuDefaults","position","allowedSelectValues","selectDefaults","kind","size","allowedLabelValues","kinds","labelDefaults","fieldsetDefault","label","textareaDefaults","disabled"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACO,IAAMA,qBAAqB,GAAG;AACpCC,EAAAA,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,CAAU;EAC1DC,MAAM,EAAE,CACP,SAAS,EACT,UAAU,EACV,OAAO,EACP,WAAW;AAEb;AAUO,IAAMC,gBAAkC,GAAG;AACjDF,EAAAA,QAAQ,EAAE,SAAS;AACnBG,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;;AAEO,IAAMC,uBAAuB,GAAG;AACtCH,EAAAA,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU;AAC3C;AAQO,IAAMI,kBAAsC,GAAG;AACrDF,EAAAA,KAAK,EAAE;AACR;AAEO,IAAMG,uBAAuB,GAAG;AACtCC,EAAAA,SAAS,EAAE,CAAC,QAAQ,EAAE,KAAK;AAC5B;AAQO,IAAMC,kBAAsC,GAAG;AACrDC,EAAAA,QAAQ,EAAE;AACX;;AAEA;AACA;AACO,IAAMC,mBAAmB,GAAG;EAClCT,MAAM,EAAE,CACP,SAAS,EACT,UAAU,EACV,MAAM,EACN,WAAW;AAEb;AAUO,IAAMU,cAA8B,GAAG;AAC7CC,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,IAAI,EAAE,SAAS;AACfV,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACO,IAAMW,kBAAkB,GAAG;AACjCC,EAAAA,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAU;AACnCd,EAAAA,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU;AAC/B;AAUO,IAAMe,aAA4B,GAAG;AAC3CJ,EAAAA,IAAI,EAAE,OAAO;AACbT,EAAAA,KAAK,EAAE;AACR;AAWA;AACA;AACA;AACA;AACO,IAAMc,eAAgC,GAAG;AAC/CC,EAAAA,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;AACO,IAAMC,gBAAqC,GAAG;AACpDC,EAAAA,QAAQ,EAAE,KAAK;AACfF,EAAAA,KAAK,EAAE;AACR;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/components/form/constants.ts"],"sourcesContent":["import * as React from 'react';\nimport { DSIconType } from '../svg';\nimport { DataQa } from '../../utils/dataQa';\n\n/*\n * Shared error object for inputs\n * ------------------------------------------------------------------\n */\n/**\n * This should be used to communciate error information for a specific input\n */\nexport interface MrlFormInputError {\n\tmessage: string;\n}\n\n/*\n * Shared input values\n * ------------------------------------------------------------------\n */\nexport type InputStates = 'disabled' | 'error' | 'read-only';\nexport type InputKinds = 'default' | 'inline' | 'inline-label';\nexport type InputSizes = 'default' | 'large';\n\n/*\n * Checkbox component\n * ------------------------------------------------------------------\n */\nexport const allowedCheckboxValues = {\n\tselected: ['default', 'checked', 'indeterminate'] as const,\n\tstates: ['default', 'disabled', 'error', 'read-only'] as const\n};\n\nexport type CheckboxStates = (typeof allowedCheckboxValues.states)[number];\nexport type CheckboxSelected = (typeof allowedCheckboxValues.selected)[number];\n\n/**\n * Native attributes accepted by the checkbox `input`. The omitted ones are driven by the\n * component's own props (`selected`, `state`) or do not apply to the element.\n */\nexport type CheckboxInputProps = Omit<\n\tReact.ComponentPropsWithoutRef<'input'>,\n\t'type' | 'checked' | 'defaultChecked' | 'disabled' | 'children' | 'className' | 'style'\n> &\n\tDataQa;\n\ninterface CheckboxDefaults {\n\tselected: CheckboxSelected;\n\tstate: CheckboxStates;\n}\n\nexport const checkboxDefaults: CheckboxDefaults = {\n\tselected: 'default',\n\tstate: 'default'\n};\n\n/*\n * Select component\n * ------------------------------------------------------------------\n */\n\nexport const allowedSelectItemValues = {\n\tstates: ['default', 'disabled', 'selected'] as const\n};\n\nexport type SelectItemStates = (typeof allowedSelectItemValues.states)[number];\n\ninterface SelectItemDefaults {\n\tstate: SelectItemStates;\n}\n\nexport const selectItemDefaults: SelectItemDefaults = {\n\tstate: 'default'\n};\n\nexport const allowedSelectMenuValues = {\n\tpositions: ['bottom', 'top'] as const\n};\n\nexport type SelectMenuPositions = (typeof allowedSelectMenuValues.positions)[number];\n\ninterface SelectMenuDefaults {\n\tposition: SelectMenuPositions;\n}\n\nexport const selectMenuDefaults: SelectMenuDefaults = {\n\tposition: 'bottom'\n};\n\n// Selects are an extension of the shared \"allowedValues\" object but\n// TypeScript won't let me combine the two objects.\nexport const allowedSelectValues = {\n\tstates: ['default', 'disabled', 'open', 'read-only'] as const\n};\n\nexport type SelectStates = (typeof allowedSelectValues.states)[number];\n\ninterface SelectDefaults {\n\tsize: InputSizes;\n\tkind: InputKinds;\n\tstate: SelectStates;\n}\n\nexport const selectDefaults: SelectDefaults = {\n\tkind: 'default',\n\tsize: 'default',\n\tstate: 'default'\n};\n\n/*\n * Text Input component\n * ------------------------------------------------------------------\n */\nexport interface StaticIconConfig {\n\ticon: DSIconType;\n\ttheme?: string;\n}\n\nexport interface RightActionConfig extends StaticIconConfig {\n\taction: (event: React.MouseEvent | React.KeyboardEvent) => void;\n\tlabel: string;\n}\n\n/*\n * Label component\n * ------------------------------------------------------------------\n */\nexport const allowedLabelValues = {\n\tkinds: ['block', 'inline'] as const,\n\tstates: ['default', 'disabled'] as const\n};\n\nexport type LabelStates = (typeof allowedLabelValues.states)[number];\nexport type LabelKind = (typeof allowedLabelValues.kinds)[number];\n\ninterface LabelDefaults {\n\tkind: LabelKind;\n\tstate: LabelStates;\n}\n\nexport const labelDefaults: LabelDefaults = {\n\tkind: 'block',\n\tstate: 'default'\n};\n\nexport interface FormControlDefaults {\n\tdisabled: boolean;\n\tlabel: string;\n}\n\nexport interface FieldsetDefault {\n\tlabel: string;\n}\n\n/**\n * Default values for props on the Fieldset component;\n * Shared between the component and Storybook\n */\nexport const fieldsetDefault: FieldsetDefault = {\n\tlabel: \"fieldset's legend label\"\n};\n\n/**\n * Default values for props on the Fieldset component which is used to group Textarea components;\n * Shared between the component and Storybook\n */\nexport const textareaDefaults: FormControlDefaults = {\n\tdisabled: false,\n\tlabel: 'Legend'\n};\n"],"names":["allowedCheckboxValues","selected","states","checkboxDefaults","state","allowedSelectItemValues","selectItemDefaults","allowedSelectMenuValues","positions","selectMenuDefaults","position","allowedSelectValues","selectDefaults","kind","size","allowedLabelValues","kinds","labelDefaults","fieldsetDefault","label","textareaDefaults","disabled"],"mappings":";;AAIA;AACA;AACA;AACA;AACA;AAC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A,KAAK,EAAE;AACR;;AAEA;AACA;AACA;AACA;AACO,IAAMC,gBAAqC,GAAG;AACpDC,EAAAA,QAAQ,EAAE,KAAK;AACfF,EAAAA,KAAK,EAAE;AACR;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MrlTextarea.js","sources":["../../../../../../src/components/form/textarea/MrlTextarea/MrlTextarea.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, setAttributes } from '../../../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlTextarea.module.scss';\nimport './MrlTextarea.global.scss';\n\ntype MrlTextareaState = 'default' | 'disabled' | 'error' | 'read-only';\n\ninterface MrlTextareaProps {\n\t/** Applies additional HTML attributes to the textarea element */\n\tattrs?: AttrsObject;\n\t/** The value of the textarea used to make it a controlled input */\n\tvalue?: string;\n\t/**\n\t * The maximum number of characters that the user can enter.\n\t * If undefined or set to \"0\", removes the character counter from the textarea\n\t */\n\tmaxLength?: number;\n\t/**\n\t * Id of the text input.\n\t */\n\tinputId: string;\n\t/**\n\t * Text placeholder for the text input.\n\t */\n\tplaceholder?: string;\n\t/**\n\t * Changes the state of the input based on user permissions or actions.\n\t */\n\tstate?: MrlTextareaState;\n\n\t/** Additional class to add to the textarea */\n\tclassName?: string;\n\n\t/** Autoexpand will automatically adjust the height of the textarea based on the amount of text within it */\n\tautoExpand?: boolean;\n\n\t/**\n\t * Enables interaction tracking for this textarea. Provide a stable, non-PII id\n\t * (e.g. 'template-description'). When omitted, the textarea emits no analytics.\n\t *\n\t * Note: the textarea's value is never emitted, and `change` is emitted once per\n\t * editing session (on blur, when the value actually changed) rather than per keystroke.\n\t */\n\teventId?: string;\n}\n\n/**\n * Allows the user to input plain text in a multi-line format\n * @param {MrlTextareaProps} props - the component props\n * @returns a textarea element\n */\nexport function MrlTextarea({\n\tattrs = {},\n\tclassName,\n\tinputId,\n\tstate = 'default',\n\tmaxLength,\n\tplaceholder,\n\teventId,\n\tvalue,\n\tautoExpand = false,\n\t...rest\n}: MrlTextareaProps): JSX.Element {\n\tconst textareaRef = React.useRef<HTMLTextAreaElement>(null);\n\t// the value when the field gained focus, so `change` can be emitted once per\n\t// editing session instead of once per keystroke.\n\tconst valueOnFocusRef = React.useRef<string>('');\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlTextarea', eventId);\n\n\tReact.useEffect(() => {\n\t\tif (textareaRef.current && attrs.autofocus) {\n\t\t\ttextareaRef.current.focus();\n\t\t}\n\t}, [attrs, textareaRef]);\n\n\tconst dataMaxLength = attrs['data-maxlength'];\n\n\t// Special use-case for AI Chat Input (AI-658)\n\tReact.useEffect(() => {\n\t\tif (autoExpand && textareaRef.current) {\n\t\t\ttextareaRef.current.style.height = '0px';\n\t\t\tconst scrollHeight = textareaRef.current.scrollHeight + 4;\n\t\t\ttextareaRef.current.style.height = scrollHeight + 'px';\n\t\t}\n\t}, [value, autoExpand]);\n\n\tconst hasMaxLength = typeof maxLength !== 'undefined' && Number(maxLength) > 0;\n\tconst hasDataMaxLength = typeof dataMaxLength !== 'undefined' && Number(dataMaxLength) > 0;\n\n\tconst displayCounter = hasMaxLength || hasDataMaxLength;\n\n\tif (hasMaxLength && isNaN(Number(maxLength))) {\n\t\tthrow new Error('maxLength should have type number');\n\t}\n\n\tif (hasDataMaxLength && isNaN(Number(hasDataMaxLength))) {\n\t\tthrow new Error('data-maxlength should have type number');\n\t}\n\n\tif (hasMaxLength && hasDataMaxLength) {\n\t\tthrow new Error('maxLength and data-maxlength should not be used at the same time');\n\t}\n\n\tconst inputClasses = classnames(\n\t\tattrs.class || attrs.className,\n\t\tclassName,\n\t\tstyles['MrlTextarea'],\n\t\t'MrlTextarea',\n\t\t'mrl-textarea',\n\t\t{\n\t\t\t[styles['MrlTextarea--auto-expand']]: autoExpand,\n\t\t\t[styles['MrlTextarea--read-only']]: state === 'read-only'\n\t\t}\n\t);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs);\n\n\t/**\n\t * Handle focus events\n\t *\n\t * @param {React.FocusEvent<HTMLTextAreaElement>} e - focus event\n\t */\n\tconst handleOnFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n\t\tvalueOnFocusRef.current = e.target.value;\n\n\t\tif (typeof attributes.onFocus === 'function') {\n\t\t\tattributes.onFocus(e);\n\t\t}\n\t};\n\n\t/**\n\t * Handle blur events\n\t *\n\t * @param {React.FocusEvent<HTMLTextAreaElement>} e - blur event\n\t */\n\tconst handleOnBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n\t\t// the value itself is never emitted — only the fact that it changed.\n\t\tif (e.target.value !== valueOnFocusRef.current) {\n\t\t\ttrackInteraction({ action: 'change' });\n\t\t}\n\n\t\tif (typeof attributes.onBlur === 'function') {\n\t\t\tattributes.onBlur(e);\n\t\t}\n\t};\n\n\tconst renderCounter = () => {\n\t\tconst displayedValue = dataMaxLength ? dataMaxLength : maxLength;\n\t\tconst valueExceedsDataMaxLength = dataMaxLength && value ? value.length > dataMaxLength : false;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<span\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName={classnames('MrlCounter', {\n\t\t\t\t\t\t'MrlCounter-overMaxLength': valueExceedsDataMaxLength\n\t\t\t\t\t})}\n\t\t\t\t\tid={`${inputId}-visible-counter`}\n\t\t\t\t>\n\t\t\t\t\t{value?.length || 0}/{displayedValue}\n\t\t\t\t</span>\n\t\t\t\t<p style={{ display: 'none' }} id={`${inputId}-counter`}>\n\t\t\t\t\t{`${displayedValue - (value?.length || 0)} of ${displayedValue} characters remaining`}\n\t\t\t\t</p>\n\t\t\t</>\n\t\t);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"MrlTextarea--wrapper\">\n\t\t\t\t<textarea\n\t\t\t\t\t{...rest}\n\t\t\t\t\t{...attributes}\n\t\t\t\t\tid={inputId}\n\t\t\t\t\tonBlur={handleOnBlur}\n\t\t\t\t\tonFocus={handleOnFocus}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\tclassName={inputClasses}\n\t\t\t\t\t// Force value if defined (controlled component) or pass\n\t\t\t\t\t// undefined and fallback to the default (uncontrolled)\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\taria-describedby={`${inputId}-counter`}\n\t\t\t\t\tmaxLength={hasMaxLength ? maxLength : undefined}\n\t\t\t\t\tref={textareaRef}\n\t\t\t\t\treadOnly={state === 'read-only'}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t{displayCounter && state !== 'read-only' && (\n\t\t\t\t<span className={classnames(styles['MrlForm-counter'], 'MrlForm-counter')}>\n\t\t\t\t\t{renderCounter()}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</>\n\t);\n}\n"],"names":["MrlTextarea","_ref","_ref$attrs","attrs","className","inputId","_ref$state","state","maxLength","placeholder","eventId","value","_ref$autoExpand","autoExpand","rest","_objectWithoutProperties","_excluded","textareaRef","React","useRef","valueOnFocusRef","trackInteraction","useMrlTrackInteraction","useEffect","current","autofocus","focus","dataMaxLength","style","height","scrollHeight","hasMaxLength","Number","hasDataMaxLength","displayCounter","isNaN","Error","inputClasses","classnames","class","styles","attributes","setAttributes","handleOnFocus","e","target","onFocus","handleOnBlur","action","onBlur","renderCounter","displayedValue","valueExceedsDataMaxLength","length","createElement","Fragment","id","concat","display","_extends","disabled","undefined","ref","readOnly"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAAAC,IAAA,EAWO;AAAA,EAAA,IAAAC,UAAA,GAAAD,IAAA,CAVjCE,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,SAAS,GAAAH,IAAA,CAATG,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C,IAAAA,GAAG,EAAE7C,WAAY;IACjB8C,QAAQ,EAAExD,KAAK,KAAK;GAAY,CAChC,CACG,CAAC,EACL2B,cAAc,IAAI3B,KAAK,KAAK,WAAW,iBACvCW,gBAAA,CAAAoC,aAAA,CAAA,MAAA,EAAA;IAAMlD,SAAS,EAAEkC,2BAAU,CAACE,0BAAM,CAAC,iBAAiB,CAAC,EAAE,iBAAiB;AAAE,GAAA,EACxEU,aAAa,EACT,CAEN,CAAC;AAEL;;;;"}
1
+ {"version":3,"file":"MrlTextarea.js","sources":["../../../../../../src/components/form/textarea/MrlTextarea/MrlTextarea.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { AttrsObject, setAttributes } from '../../../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlTextarea.module.scss';\nimport './MrlTextarea.global.scss';\n\nexport type MrlTextareaState = 'default' | 'disabled' | 'error' | 'read-only';\n\ninterface MrlTextareaProps {\n\t/** Applies additional HTML attributes to the textarea element */\n\tattrs?: AttrsObject;\n\t/** The value of the textarea used to make it a controlled input */\n\tvalue?: string;\n\t/**\n\t * The maximum number of characters that the user can enter.\n\t * If undefined or set to \"0\", removes the character counter from the textarea\n\t */\n\tmaxLength?: number;\n\t/**\n\t * Id of the text input.\n\t */\n\tinputId: string;\n\t/**\n\t * Text placeholder for the text input.\n\t */\n\tplaceholder?: string;\n\t/**\n\t * Changes the state of the input based on user permissions or actions.\n\t */\n\tstate?: MrlTextareaState;\n\n\t/** Additional class to add to the textarea */\n\tclassName?: string;\n\n\t/** Autoexpand will automatically adjust the height of the textarea based on the amount of text within it */\n\tautoExpand?: boolean;\n\n\t/**\n\t * Enables interaction tracking for this textarea. Provide a stable, non-PII id\n\t * (e.g. 'template-description'). When omitted, the textarea emits no analytics.\n\t *\n\t * Note: the textarea's value is never emitted, and `change` is emitted once per\n\t * editing session (on blur, when the value actually changed) rather than per keystroke.\n\t */\n\teventId?: string;\n}\n\n/**\n * Allows the user to input plain text in a multi-line format\n * @param {MrlTextareaProps} props - the component props\n * @returns a textarea element\n */\nexport function MrlTextarea({\n\tattrs = {},\n\tclassName,\n\tinputId,\n\tstate = 'default',\n\tmaxLength,\n\tplaceholder,\n\teventId,\n\tvalue,\n\tautoExpand = false,\n\t...rest\n}: MrlTextareaProps): JSX.Element {\n\tconst textareaRef = React.useRef<HTMLTextAreaElement>(null);\n\t// the value when the field gained focus, so `change` can be emitted once per\n\t// editing session instead of once per keystroke.\n\tconst valueOnFocusRef = React.useRef<string>('');\n\n\tconst trackInteraction = useMrlTrackInteraction('MrlTextarea', eventId);\n\n\tReact.useEffect(() => {\n\t\tif (textareaRef.current && attrs.autofocus) {\n\t\t\ttextareaRef.current.focus();\n\t\t}\n\t}, [attrs, textareaRef]);\n\n\tconst dataMaxLength = attrs['data-maxlength'];\n\n\t// Special use-case for AI Chat Input (AI-658)\n\tReact.useEffect(() => {\n\t\tif (autoExpand && textareaRef.current) {\n\t\t\ttextareaRef.current.style.height = '0px';\n\t\t\tconst scrollHeight = textareaRef.current.scrollHeight + 4;\n\t\t\ttextareaRef.current.style.height = scrollHeight + 'px';\n\t\t}\n\t}, [value, autoExpand]);\n\n\tconst hasMaxLength = typeof maxLength !== 'undefined' && Number(maxLength) > 0;\n\tconst hasDataMaxLength = typeof dataMaxLength !== 'undefined' && Number(dataMaxLength) > 0;\n\n\tconst displayCounter = hasMaxLength || hasDataMaxLength;\n\n\tif (hasMaxLength && isNaN(Number(maxLength))) {\n\t\tthrow new Error('maxLength should have type number');\n\t}\n\n\tif (hasDataMaxLength && isNaN(Number(hasDataMaxLength))) {\n\t\tthrow new Error('data-maxlength should have type number');\n\t}\n\n\tif (hasMaxLength && hasDataMaxLength) {\n\t\tthrow new Error('maxLength and data-maxlength should not be used at the same time');\n\t}\n\n\tconst inputClasses = classnames(\n\t\tattrs.class || attrs.className,\n\t\tclassName,\n\t\tstyles['MrlTextarea'],\n\t\t'MrlTextarea',\n\t\t'mrl-textarea',\n\t\t{\n\t\t\t[styles['MrlTextarea--auto-expand']]: autoExpand,\n\t\t\t[styles['MrlTextarea--read-only']]: state === 'read-only'\n\t\t}\n\t);\n\n\tdelete attrs.class;\n\tdelete attrs.className;\n\n\tconst attributes = setAttributes(attrs);\n\n\t/**\n\t * Handle focus events\n\t *\n\t * @param {React.FocusEvent<HTMLTextAreaElement>} e - focus event\n\t */\n\tconst handleOnFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n\t\tvalueOnFocusRef.current = e.target.value;\n\n\t\tif (typeof attributes.onFocus === 'function') {\n\t\t\tattributes.onFocus(e);\n\t\t}\n\t};\n\n\t/**\n\t * Handle blur events\n\t *\n\t * @param {React.FocusEvent<HTMLTextAreaElement>} e - blur event\n\t */\n\tconst handleOnBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n\t\t// the value itself is never emitted — only the fact that it changed.\n\t\tif (e.target.value !== valueOnFocusRef.current) {\n\t\t\ttrackInteraction({ action: 'change' });\n\t\t}\n\n\t\tif (typeof attributes.onBlur === 'function') {\n\t\t\tattributes.onBlur(e);\n\t\t}\n\t};\n\n\tconst renderCounter = () => {\n\t\tconst displayedValue = dataMaxLength ? dataMaxLength : maxLength;\n\t\tconst valueExceedsDataMaxLength = dataMaxLength && value ? value.length > dataMaxLength : false;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<span\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName={classnames('MrlCounter', {\n\t\t\t\t\t\t'MrlCounter-overMaxLength': valueExceedsDataMaxLength\n\t\t\t\t\t})}\n\t\t\t\t\tid={`${inputId}-visible-counter`}\n\t\t\t\t>\n\t\t\t\t\t{value?.length || 0}/{displayedValue}\n\t\t\t\t</span>\n\t\t\t\t<p style={{ display: 'none' }} id={`${inputId}-counter`}>\n\t\t\t\t\t{`${displayedValue - (value?.length || 0)} of ${displayedValue} characters remaining`}\n\t\t\t\t</p>\n\t\t\t</>\n\t\t);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"MrlTextarea--wrapper\">\n\t\t\t\t<textarea\n\t\t\t\t\t{...rest}\n\t\t\t\t\t{...attributes}\n\t\t\t\t\tid={inputId}\n\t\t\t\t\tonBlur={handleOnBlur}\n\t\t\t\t\tonFocus={handleOnFocus}\n\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\tclassName={inputClasses}\n\t\t\t\t\t// Force value if defined (controlled component) or pass\n\t\t\t\t\t// undefined and fallback to the default (uncontrolled)\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\taria-describedby={`${inputId}-counter`}\n\t\t\t\t\tmaxLength={hasMaxLength ? maxLength : undefined}\n\t\t\t\t\tref={textareaRef}\n\t\t\t\t\treadOnly={state === 'read-only'}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t{displayCounter && state !== 'read-only' && (\n\t\t\t\t<span className={classnames(styles['MrlForm-counter'], 'MrlForm-counter')}>\n\t\t\t\t\t{renderCounter()}\n\t\t\t\t</span>\n\t\t\t)}\n\t\t</>\n\t);\n}\n"],"names":["MrlTextarea","_ref","_ref$attrs","attrs","className","inputId","_ref$state","state","maxLength","placeholder","eventId","value","_ref$autoExpand","autoExpand","rest","_objectWithoutProperties","_excluded","textareaRef","React","useRef","valueOnFocusRef","trackInteraction","useMrlTrackInteraction","useEffect","current","autofocus","focus","dataMaxLength","style","height","scrollHeight","hasMaxLength","Number","hasDataMaxLength","displayCounter","isNaN","Error","inputClasses","classnames","class","styles","attributes","setAttributes","handleOnFocus","e","target","onFocus","handleOnBlur","action","onBlur","renderCounter","displayedValue","valueExceedsDataMaxLength","length","createElement","Fragment","id","concat","display","_extends","disabled","undefined","ref","readOnly"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAAAC,IAAA,EAWO;AAAA,EA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Q;IAChC,kBAAA,EAAA,EAAA,CAAAkD,MAAA,CAAqBpD,OAAO,EAAA,UAAA,CAAW;AACvCG,IAAAA,SAAS,EAAEuB,YAAY,GAAGvB,SAAS,GAAGqD,SAAU;AAChDC,IAAAA,GAAG,EAAE7C,WAAY;IACjB8C,QAAQ,EAAExD,KAAK,KAAK;GAAY,CAChC,CACG,CAAC,EACL2B,cAAc,IAAI3B,KAAK,KAAK,WAAW,iBACvCW,gBAAA,CAAAoC,aAAA,CAAA,MAAA,EAAA;IAAMlD,SAAS,EAAEkC,2BAAU,CAACE,0BAAM,CAAC,iBAAiB,CAAC,EAAE,iBAAiB;AAAE,GAAA,EACxEU,aAAa,EACT,CAEN,CAAC;AAEL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../src/components/grid/constants.ts"],"sourcesContent":["import { DataQa } from '../../utils/dataQa';\n\n/**\n * Alignment & justification options for grid containers\n */\nexport type AlignOptions = 'start' | 'center' | 'end';\nexport type JustifyOptions = 'start' | 'center' | 'end' | 'between' | 'around';\n\n/**\n * Number of columns a `col` can span. There is no `col-0` class — a column\n * always occupies at least one of the twelve tracks.\n */\nexport type ColSpan = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;\n\n/**\n * Number of columns an `offset` can skip. `0` is meaningful here: it is how a\n * larger breakpoint cancels an offset inherited from a smaller one.\n */\nexport type OffsetSpan = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;\n\n/**\n * @deprecated Use `ColSpan` for spans or `OffsetSpan` for offsets. This union\n * allowed `col={0}`, which never produced a class.\n */\nexport type NumCols = 0 | ColSpan;\n\n/**\n * Interface of available class selectors per breakpoint.\n *\n * Example interface:\n * {\n * col?: number,\n * offset?: number\n * }\n */\ntype GridClassConfig = {\n\tcol?: ColSpan;\n\toffset?: OffsetSpan;\n};\n\n/**\n * Options to configure the number of columns to span on different screen sizes.\n */\ntype ColumnConfig = ColSpan | 'auto' | GridClassConfig | undefined;\n\nexport interface GridColumns {\n\t/**\n\t * Columns that are the same from the smallest of devices to the largest.\n\t */\n\tcol?: ColumnConfig;\n\n\t/**\n\t * @deprecated Alias of `col`, kept for backwards compatibility. It resolves\n\t * to the same un-prefixed tier, so passing both `col` and `xs` emits two\n\t * competing classes and the larger span wins on CSS source order rather\n\t * than the one you wrote last. Pass only one.\n\t */\n\txs?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the sm breakpoint up.\n\t */\n\tsm?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the md breakpoint up.\n\t */\n\tmd?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the lg breakpoint up.\n\t */\n\tlg?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the xl breakpoint up.\n\t */\n\txl?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the xxl breakpoint up.\n\t */\n\txxl?: ColumnConfig;\n}\n\n/**\n * Breakpoint keys in ascending order. Drives both class generation and the\n * filtering that keeps grid props from reaching the DOM.\n */\nexport const GRID_SIZE_KEYS = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const;\n\n/**\n * Available gutter sizes for customizing the grid\n */\nexport type GutterSizes = 0 | 1 | 2;\n\n/**\n * Gutter size to modifier class. `1` is the default declared on `.row`, so it\n * needs no class.\n */\nexport const GUTTER_CLASS: Record<GutterSizes, string | undefined> = {\n\t0: 'MrlRow-gutter--none',\n\t1: undefined,\n\t2: 'MrlRow-gutter--double'\n};\n\n/**\n * Roles a generic layout wrapper may safely carry.\n *\n * Composite widget roles (`grid`, `row`, `gridcell`, `listbox`, `tablist`, …)\n * are deliberately excluded: they promise an APG keyboard contract — roving\n * tabindex or `aria-activedescendant`, arrow-key navigation, selection state —\n * that these divs do not implement. The roles below are structural only and\n * carry no interaction contract, so they are safe to forward.\n *\n * `list`/`listitem` in particular is how a row of columns is announced as\n * \"list, N items\", and is the standard workaround for Safari/VoiceOver\n * dropping implicit list semantics. `region` needs an accessible name to be\n * exposed as a landmark; the type cannot enforce that.\n *\n * Page landmarks belong to the layout components (MrlMain, MrlPage).\n */\nexport type SafeLayoutRole = 'group' | 'list' | 'listitem' | 'none' | 'presentation' | 'region';\n\n/**\n * Shared props for the grid components: every `div` attribute, with `role`\n * narrowed to {@link SafeLayoutRole}.\n */\nexport type GridBaseProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'role'> &\n\tDataQa & {\n\t\t/**\n\t\t * Structural role for the wrapper. Composite widget roles are not\n\t\t * accepted — see {@link SafeLayoutRole}.\n\t\t */\n\t\trole?: SafeLayoutRole;\n\t};\n"],"names":["GRID_SIZE_KEYS","GUTTER_CLASS","undefined"],"mappings":";;AAEA;AACA;AACA;;AAIA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AA2CA;AACA;AACA;AACA;IACaA,cAAc,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;;AAEzE;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,IAAMC,YAAqD,GAAG;AACpE,EAAA,CAAC,EAAE,qBAAqB;AACxB,EAAA,CAAC,EAAEC,SAAS;AACZ,EAAA,CAAC,EAAE;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;;;;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/components/grid/constants.ts"],"sourcesContent":["import { DataQa } from '../../utils/dataQa';\n\n/**\n * Alignment & justification options for grid containers\n */\nexport type AlignOptions = 'start' | 'center' | 'end';\nexport type JustifyOptions = 'start' | 'center' | 'end' | 'between' | 'around';\n\n/**\n * Number of columns a `col` can span. There is no `col-0` class — a column\n * always occupies at least one of the twelve tracks.\n */\nexport type ColSpan = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;\n\n/**\n * Number of columns an `offset` can skip. `0` is meaningful here: it is how a\n * larger breakpoint cancels an offset inherited from a smaller one.\n */\nexport type OffsetSpan = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;\n\n/**\n * @deprecated Use `ColSpan` for spans or `OffsetSpan` for offsets. This union\n * allowed `col={0}`, which never produced a class.\n */\nexport type NumCols = 0 | ColSpan;\n\n/**\n * Interface of available class selectors per breakpoint.\n *\n * Example interface:\n * {\n * col?: number,\n * offset?: number\n * }\n */\nexport type GridClassConfig = {\n\tcol?: ColSpan;\n\toffset?: OffsetSpan;\n};\n\n/**\n * Options to configure the number of columns to span on different screen sizes.\n */\nexport type ColumnConfig = ColSpan | 'auto' | GridClassConfig | undefined;\n\nexport interface GridColumns {\n\t/**\n\t * Columns that are the same from the smallest of devices to the largest.\n\t */\n\tcol?: ColumnConfig;\n\n\t/**\n\t * @deprecated Alias of `col`, kept for backwards compatibility. It resolves\n\t * to the same un-prefixed tier, so passing both `col` and `xs` emits two\n\t * competing classes and the larger span wins on CSS source order rather\n\t * than the one you wrote last. Pass only one.\n\t */\n\txs?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the sm breakpoint up.\n\t */\n\tsm?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the md breakpoint up.\n\t */\n\tmd?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the lg breakpoint up.\n\t */\n\tlg?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the xl breakpoint up.\n\t */\n\txl?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the xxl breakpoint up.\n\t */\n\txxl?: ColumnConfig;\n}\n\n/**\n * Breakpoint keys in ascending order. Drives both class generation and the\n * filtering that keeps grid props from reaching the DOM.\n */\nexport const GRID_SIZE_KEYS = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const;\n\n/**\n * Available gutter sizes for customizing the grid\n */\nexport type GutterSizes = 0 | 1 | 2;\n\n/**\n * Gutter size to modifier class. `1` is the default declared on `.row`, so it\n * needs no class.\n */\nexport const GUTTER_CLASS: Record<GutterSizes, string | undefined> = {\n\t0: 'MrlRow-gutter--none',\n\t1: undefined,\n\t2: 'MrlRow-gutter--double'\n};\n\n/**\n * Roles a generic layout wrapper may safely carry.\n *\n * Composite widget roles (`grid`, `row`, `gridcell`, `listbox`, `tablist`, …)\n * are deliberately excluded: they promise an APG keyboard contract — roving\n * tabindex or `aria-activedescendant`, arrow-key navigation, selection state —\n * that these divs do not implement. The roles below are structural only and\n * carry no interaction contract, so they are safe to forward.\n *\n * `list`/`listitem` in particular is how a row of columns is announced as\n * \"list, N items\", and is the standard workaround for Safari/VoiceOver\n * dropping implicit list semantics. `region` needs an accessible name to be\n * exposed as a landmark; the type cannot enforce that.\n *\n * Page landmarks belong to the layout components (MrlMain, MrlPage).\n */\nexport type SafeLayoutRole = 'group' | 'list' | 'listitem' | 'none' | 'presentation' | 'region';\n\n/**\n * Shared props for the grid components: every `div` attribute, with `role`\n * narrowed to {@link SafeLayoutRole}.\n */\nexport type GridBaseProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'role'> &\n\tDataQa & {\n\t\t/**\n\t\t * Structural role for the wrapper. Composite widget roles are not\n\t\t * accepted — see {@link SafeLayoutRole}.\n\t\t */\n\t\trole?: SafeLayoutRole;\n\t};\n"],"names":["GRID_SIZE_KEYS","GUTTER_CLASS","undefined"],"mappings":";;AAEA;AACA;AACA;;AAIA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AA2CA;AACA;AACA;AACA;IACaA,cAAc,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;;AAEzE;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,IAAMC,YAAqD,GAAG;AACpE,EAAA,CAAC,EAAE,qBAAqB;AACxB,EAAA,CAAC,EAAEC,SAAS;AACZ,EAAA,CAAC,EAAE;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"MrlLiveRegion.js","sources":["../../../../../src/components/live-region/MrlLiveRegion/MrlLiveRegion.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport uniqueId from 'lodash.uniqueid';\nimport * as React from 'react';\nimport { useMemo, useState } from 'react';\n\ntype AriaRelevant = 'additions' | 'all' | 'removals' | 'text' | 'additions text' | undefined;\n\nexport interface MrlLiveRegionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n\t/** Sets `aria-atomic`: announce the whole region on every change instead of only the changed part. */\n\tariaAtomic?: boolean;\n\t/** Sets `aria-live`: how urgently screen readers announce changes. */\n\tariaLive: 'polite' | 'assertive' | 'off';\n\t/** Sets `aria-relevant`: which kinds of change are announced. */\n\tariaRelevant?: AriaRelevant;\n\tid?: string;\n\t/** Empties the region one second after `srContent` changes. */\n\tshouldClearContent?: boolean;\n\t/** Text announced by the live region. */\n\tsrContent: string;\n\t/** Shows the text on screen. By default the region is visually hidden. */\n\tvisible?: boolean;\n}\n\n/**\n * Live region component to render an HTML live region with the provided content.\n *\n * @param props - The live region component props.\n * @returns The live region component.\n */\nexport const MrlLiveRegion = ({\n\tariaAtomic,\n\tariaLive,\n\tariaRelevant,\n\tid,\n\tsrContent,\n\tvisible = false,\n\tshouldClearContent = false,\n\t...props\n}: MrlLiveRegionProps): React.ReactElement => {\n\tconst [content, setContent] = useState('');\n\n\tReact.useEffect(() => {\n\t\tsetContent(srContent);\n\n\t\tif (shouldClearContent) {\n\t\t\tconst contentTimeout = setTimeout(() => {\n\t\t\t\tsetContent('');\n\t\t\t\tclearTimeout(contentTimeout);\n\t\t\t}, 1000);\n\n\t\t\treturn () => clearTimeout(contentTimeout);\n\t\t}\n\t}, [shouldClearContent, srContent]);\n\n\tconst nodeId = useMemo(() => id || uniqueId('live-region-'), [id]);\n\n\tconst dataQaProp = (props as { 'data-qa'?: string })['data-qa'];\n\tconst dataQa = dataQaProp || `${nodeId}-live-region`;\n\n\tconst classes = classNames('MrlLiveRegion', {\n\t\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\t\t'mrl-visually-hidden': !visible\n\t});\n\n\treturn (\n\t\t<p\n\t\t\t{...(ariaAtomic ? { 'aria-atomic': ariaAtomic } : {})}\n\t\t\taria-live={ariaLive}\n\t\t\t{...(ariaRelevant ? { 'aria-relevant': ariaRelevant } : {})}\n\t\t\tclassName={classes}\n\t\t\tdata-qa={dataQa}\n\t\t\tid={nodeId}\n\t\t\t{...props}\n\t\t>\n\t\t\t{content}\n\t\t</p>\n\t);\n};\n"],"names":["MrlLiveRegion","_ref","ariaAtomic","ariaLive","ariaRelevant","id","srContent","_ref$visible","visible","_ref$shouldClearConte","shouldClearContent","props","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","content","setContent","React","useEffect","contentTimeout","setTimeout","clearTimeout","nodeId","useMemo","uniqueId","dataQaProp","dataQa","concat","classes","classNames","createElement","_extends","className"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,aAAa,GAAGC,IAAA,IASiB;AAAA,EAAA,IAR7CC,UAAU,GAAAD,IAAA,CAAVC,UAAU;IACVC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,YAAY,GAAAH,IAAA,CAAZG,YAAY;IACZC,EAAE,GAAAJ,IAAA,CAAFI,EAAE;IACFC,SAAS,GAAAL,IAAA,CAATK,SAAS;IAAAC,YAAA,GAAAN,IAAA,CACTO,OAAO;AAAPA,IAAAA,OAAO,GAAAD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Y,gBAAA,CAAAa,aAAA,MAAAC,iCAAA,CAAA,EAAA,EACMhC,UAAU,GAAG;AAAE,IAAA,aAAa,EAAEA;GAAY,GAAG,EAAE,EAAA;IACpD,WAAA,EAAWC;AAAS,GAAA,EACfC,YAAY,GAAG;AAAE,IAAA,eAAe,EAAEA;GAAc,GAAG,EAAE,EAAA;AAC1D+B,IAAAA,SAAS,EAAEJ,OAAQ;AACnB,IAAA,SAAA,EAASF,MAAO;AAChBxB,IAAAA,EAAE,EAAEoB;GAAO,EACPd,KAAK,CAAA,EAERO,OACC,CAAC;AAEN;;;;"}
1
+ {"version":3,"file":"MrlLiveRegion.js","sources":["../../../../../src/components/live-region/MrlLiveRegion/MrlLiveRegion.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport uniqueId from 'lodash.uniqueid';\nimport * as React from 'react';\nimport { useMemo, useState } from 'react';\n\nexport type AriaRelevant = 'additions' | 'all' | 'removals' | 'text' | 'additions text' | undefined;\n\nexport interface MrlLiveRegionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n\t/** Sets `aria-atomic`: announce the whole region on every change instead of only the changed part. */\n\tariaAtomic?: boolean;\n\t/** Sets `aria-live`: how urgently screen readers announce changes. */\n\tariaLive: 'polite' | 'assertive' | 'off';\n\t/** Sets `aria-relevant`: which kinds of change are announced. */\n\tariaRelevant?: AriaRelevant;\n\tid?: string;\n\t/** Empties the region one second after `srContent` changes. */\n\tshouldClearContent?: boolean;\n\t/** Text announced by the live region. */\n\tsrContent: string;\n\t/** Shows the text on screen. By default the region is visually hidden. */\n\tvisible?: boolean;\n}\n\n/**\n * Live region component to render an HTML live region with the provided content.\n *\n * @param props - The live region component props.\n * @returns The live region component.\n */\nexport const MrlLiveRegion = ({\n\tariaAtomic,\n\tariaLive,\n\tariaRelevant,\n\tid,\n\tsrContent,\n\tvisible = false,\n\tshouldClearContent = false,\n\t...props\n}: MrlLiveRegionProps): React.ReactElement => {\n\tconst [content, setContent] = useState('');\n\n\tReact.useEffect(() => {\n\t\tsetContent(srContent);\n\n\t\tif (shouldClearContent) {\n\t\t\tconst contentTimeout = setTimeout(() => {\n\t\t\t\tsetContent('');\n\t\t\t\tclearTimeout(contentTimeout);\n\t\t\t}, 1000);\n\n\t\t\treturn () => clearTimeout(contentTimeout);\n\t\t}\n\t}, [shouldClearContent, srContent]);\n\n\tconst nodeId = useMemo(() => id || uniqueId('live-region-'), [id]);\n\n\tconst dataQaProp = (props as { 'data-qa'?: string })['data-qa'];\n\tconst dataQa = dataQaProp || `${nodeId}-live-region`;\n\n\tconst classes = classNames('MrlLiveRegion', {\n\t\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\t\t'mrl-visually-hidden': !visible\n\t});\n\n\treturn (\n\t\t<p\n\t\t\t{...(ariaAtomic ? { 'aria-atomic': ariaAtomic } : {})}\n\t\t\taria-live={ariaLive}\n\t\t\t{...(ariaRelevant ? { 'aria-relevant': ariaRelevant } : {})}\n\t\t\tclassName={classes}\n\t\t\tdata-qa={dataQa}\n\t\t\tid={nodeId}\n\t\t\t{...props}\n\t\t>\n\t\t\t{content}\n\t\t</p>\n\t);\n};\n"],"names":["MrlLiveRegion","_ref","ariaAtomic","ariaLive","ariaRelevant","id","srContent","_ref$visible","visible","_ref$shouldClearConte","shouldClearContent","props","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","content","setContent","React","useEffect","contentTimeout","setTimeout","clearTimeout","nodeId","useMemo","uniqueId","dataQaProp","dataQa","concat","classes","classNames","createElement","_extends","className"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,aAAa,GAAGC,IAAA,IASiB;AAAA,EAAA,IAR7CC,UAAU,GAAAD,IAAA,CAAVC,UAAU;IACVC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,YAAY,GAAAH,IAAA,CAAZG,YAAY;IACZC,EAAE,GAAAJ,IAAA,CAAFI,EAAE;IACFC,SAAS,GAA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