@muraldevkit/ui-toolkit 4.83.0 → 4.84.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/avatar/MrlAvatar/MrlAvatar.js.map +1 -1
- package/dist/cjs/components/callout/MrlCallout/MrlCallout.js.map +1 -1
- package/dist/cjs/components/form/textarea/MrlTextarea/MrlTextarea.js.map +1 -1
- package/dist/cjs/components/grid/constants.js.map +1 -1
- package/dist/cjs/components/live-region/MrlLiveRegion/MrlLiveRegion.js.map +1 -1
- package/dist/cjs/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.js +1 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.js.map +1 -1
- package/dist/cjs/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.module.scss.js +1 -1
- package/dist/cjs/components/notification/MrlInlineMessage/MrlInlineMessage.js +3 -2
- package/dist/cjs/components/notification/MrlInlineMessage/MrlInlineMessage.js.map +1 -1
- package/dist/cjs/components/popover/MrlPopover/MrlPopover.js.map +1 -1
- package/dist/cjs/components/portal/MrlPortal.js.map +1 -1
- package/dist/cjs/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/components/avatar/MrlAvatar/MrlAvatar.js.map +1 -1
- package/dist/esm/components/callout/MrlCallout/MrlCallout.js.map +1 -1
- package/dist/esm/components/form/textarea/MrlTextarea/MrlTextarea.js.map +1 -1
- package/dist/esm/components/grid/constants.js.map +1 -1
- package/dist/esm/components/live-region/MrlLiveRegion/MrlLiveRegion.js.map +1 -1
- package/dist/esm/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.js +1 -0
- package/dist/esm/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.js.map +1 -1
- package/dist/esm/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.module.scss.js +1 -1
- package/dist/esm/components/notification/MrlInlineMessage/MrlInlineMessage.js +3 -2
- package/dist/esm/components/notification/MrlInlineMessage/MrlInlineMessage.js.map +1 -1
- package/dist/esm/components/popover/MrlPopover/MrlPopover.js.map +1 -1
- package/dist/esm/components/portal/MrlPortal.js.map +1 -1
- package/dist/esm/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/styles/MrlMultiFilterField/module.scss +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/components/avatar/MrlAvatar/MrlAvatar.d.ts +2 -2
- package/dist/types/components/callout/MrlCallout/MrlCallout.d.ts +1 -2
- package/dist/types/components/form/textarea/MrlTextarea/MrlTextarea.d.ts +1 -1
- package/dist/types/components/grid/constants.d.ts +2 -3
- package/dist/types/components/grid/index.d.ts +1 -1
- package/dist/types/components/live-region/MrlLiveRegion/MrlLiveRegion.d.ts +1 -2
- package/dist/types/components/live-region/MrlLiveRegion/index.d.ts +1 -1
- package/dist/types/components/notification/MrlInlineMessage/MrlInlineMessage.d.ts +5 -1
- package/dist/types/components/popover/MrlPopover/MrlPopover.d.ts +1 -2
- package/dist/types/components/portal/MrlPortal.d.ts +1 -2
- package/dist/types/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.d.ts +1 -1
- 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;AAAJA,IAAAA,IAAI,GAAAY,SAAA,KAAA,MAAA,GAAGf,mBAAmB,CAACG,IAAI,GAAAY,SAAA;AAC5BC,IAAAA,IAAI,GAAAC,iDAAA,CAAAZ,IAAA,EAAAa,SAAA,CAAA;EAEP,IAAMC,gBAAgB,G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,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;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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tE,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;IACpBC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IACRR,WAAW,GAAAI,IAAA,CAAXJ,WAAW;IAAAS,qBAAA,GAAAL,IAAA,CACXM,mBAAmB;AAAnBA,IAAAA,mBAAmB,GAAAD,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,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,IAAA,CACZL,SAAS;AAATA,IAAAA,SAAS,GAAAQ,cAAA,KAAA,MAAA,GAAG,QAAQ,GAAAA,cAAA;IACpBC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IACRR,WAAW,GAAAI,I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AAG,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 +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,SAAS;IACTC,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IAAAC,UAAA,GAAAL,IAAA,CACPM,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,SAAS,GAAAA,UAAA;IACjBE,SAAS,GAAAP,IAAA,CAATO,SAAS;IACTC,WAAW,GAAAR,IAAA,CAAXQ,WAAW;IACXC,OAAO,GAAAT,IAAA,CAAPS,OAAO;IACPC,KAAK,GAAAV,IAAA,CAALU,KAAK;IAAAC,eAAA,GAAAX,IAAA,CACLY,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,eAAA;AACfE,IAAAA,IAAI,GAAAC,iDAAA,CAAAd,IAAA,EAAAe,SAAA,CAAA;AAEP,EAAA,IAAMC,WAAW,GAAGC,gBAAK,CAACC,MAAM,CAAsB,IAAI,CAAC;AAC3D;AACA;AACA,EAAA,IAAMC,eAAe,GAAGF,gBAAK,CAACC,MAAM,CAAS,EAAE,CAAC;AAEhD,EAAA,IAAME,gBAAgB,GAAGC,sCAAsB,CAAC,aAAa,EAAEZ,OAAO,CAAC;EAEvEQ,gBAAK,CAACK,SAAS,C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,iCAAA,CAAA,EAAA,EACK7C,IAAI,EACJ2B,UAAU,EAAA;AACde,IAAAA,EAAE,EAAEnD,OAAQ;AACZ4C,IAAAA,MAAM,EAAEF,YAAa;AACrBD,IAAAA,OAAO,EAAEH,aAAc;AACvBlC,IAAAA,WAAW,EAAEA,WAAY;AACzBL,IAAAA,SAAS,EAAEiC;AACX;AACA;AAAA;AACA1B,IAAAA,KAAK,EAAEA,KAAM;IACbiD,QAAQ,EAAErD,KAAK,KAAK,UAAW;IAC/B,cAAA,EAAcA,KAAK,KAAK,OAAQ;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
|
+
{"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,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,OAAO,GAAAJ,IAAA,CAAPI,OAAO;IAAAC,UAAA,GAAAL,IAAA,CACPM,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,SAAS,GAAAA,UAAA;IACjBE,SAAS,GAAAP,IAAA,CAATO,SAAS;IACTC,WAAW,GAAAR,IAAA,CAAXQ,WAAW;IACXC,OAAO,GAAAT,IAAA,CAAPS,OAAO;IACPC,KAAK,GAAAV,IAAA,CAALU,KAAK;IAAAC,eAAA,GAAAX,IAAA,CACLY,UAAU;AAAVA,IAAAA,UAAU,GAAAD,eAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,eAAA;AACfE,IAAAA,IAAI,GAAAC,iDAAA,CAAAd,IAAA,EAAAe,SAAA,CAAA;AAEP,EAAA,IAAMC,WAAW,GAAGC,gBAAK,CAACC,MAAM,CAAsB,IAAI,CAAC;AAC3D;AACA;AACA,EAAA,IAAMC,eAA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AAqC,QAAA,EAAA,IAAA,eACCrC,gBAAA,CAAAoC,aAAA,CAAA,KAAA,EAAA;AAAKlD,IAAAA,SAAS,EAAC;GAAsB,eACpCc,gBAAA,CAAAoC,aAAA,CAAA,UAAA,EAAAK,iCAAA,CAAA,EAAA,EACK7C,IAAI,EACJ2B,UAAU,EAAA;AACde,IAAAA,EAAE,EAAEnD,OAAQ;AACZ4C,IAAAA,MAAM,EAAEF,YAAa;AACrBD,IAAAA,OAAO,EAAEH,aAAc;AACvBlC,IAAAA,WAAW,EAAEA,WAAY;AACzBL,IAAAA,SAAS,EAAEiC;AACX;AACA;AAAA;AACA1B,IAAAA,KAAK,EAAEA,KAAM;IACbiD,QAAQ,EAAErD,KAAK,KAAK,UAAW;IAC/B,cAAA,EAAcA,KAAK,KAAK,OAAQ;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 */\
|
|
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\
|
|
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,GAAAL,IAAA,CAATK,SAAS;IAAAC,YAAA,GAAAN,IAAA,CACTO,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,YAAA;IAAAE,qBAAA,GAAAR,IAAA,CACfS,kBAAkB;AAAlBA,IAAAA,kBAAkB,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;AACvBE,IAAAA,KAAK,GAAAC,iDAAA,CAAAX,IAAA,EAAAY,SAAA,CAAA;AAER,EAAA,IAAAC,SAAA,GAA8BC,cAAQ,CAAC,EAAE,CAAC;IAAAC,UAAA,GAAAC,uCAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAnCI,IAAAA,OAAO,GA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|
@@ -112,6 +112,7 @@ function MrlMultiFilterField(props) {
|
|
|
112
112
|
"data-qa": dataQa,
|
|
113
113
|
ref: elementRef
|
|
114
114
|
}), renderChildren(), errorId && /*#__PURE__*/React__namespace.createElement(MrlInlineMessage.MrlInlineMessage, {
|
|
115
|
+
className: classnames__default.default(MrlMultiFilterField_module.default['MrlMultiFilterField-error'], 'MrlMultiFilterField-error'),
|
|
115
116
|
id: errorId,
|
|
116
117
|
kind: "error",
|
|
117
118
|
message: message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlMultiFilterField.js","sources":["../../../../../src/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport styles from './MrlMultiFilterField.module.scss';\nimport { MrlInlineMessage } from '../../notification/MrlInlineMessage/MrlInlineMessage';\nimport { useOptionalMrlMultiFilterContext } from '../MrlMultiFilterContext/MrlMultiFilterContext';\nimport { DataQa } from '../../../utils/dataQa';\nimport { getUniqueId } from '../../../utils/setAttributes/setAttributes';\n\nexport type MrlMultiFilterFieldRenderProps = {\n\t/**\n\t * Id of the rendered error message, or `undefined` when there is no error. Pass it to the\n\t * form element's `aria-errormessage` (with `aria-invalid`) or `aria-describedby` so the\n\t * error is announced with the field.\n\t */\n\terrorId?: string;\n\t/**\n\t * Whether the field is showing an error. Pass it to the form element's `hasError` (or\n\t * `aria-invalid`) so its error styles and invalid state match the message.\n\t */\n\thasError: boolean;\n};\n\n/**\n * A field of the MrlMultiFilter draft, returned by `getField` from its render prop.\n */\nexport type MrlMultiFilterFieldBinding<V> = {\n\t/**\n\t * The required error message, set while the field is required and empty after Apply.\n\t */\n\terror?: string;\n\t/**\n\t * Name of the field in the draft.\n\t */\n\tname: string;\n\t/**\n\t * Whether the field is required.\n\t */\n\trequired: boolean;\n\t/**\n\t * Updates the field's value in the draft.\n\t */\n\tsetValue: (value: V) => void;\n\t/**\n\t * The field's value in the draft.\n\t */\n\tvalue: V;\n};\n\nexport type MrlMultiFilterFieldBoundRenderProps<V> = MrlMultiFilterFieldRenderProps &\n\tPick<MrlMultiFilterFieldBinding<V>, 'required' | 'setValue' | 'value'>;\n\n/**\n * A field that never shows an error: plain children, no `errorMessage`.\n *\n * Docgen merges the JSDoc of the union members (this one first), so each comment below is\n * written to read on its own and as the first part of the merged description.\n */\ntype MrlMultiFilterFieldWithoutErrorProps = {\n\t/**\n\t * The field content, usually a label and a form element.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * Error message shown below the field. When omitted, no error is rendered.\n\t */\n\terrorMessage?: never;\n\t/**\n\t * Binds the field to the MrlMultiFilter draft. Pass `getField('name')` from the\n\t * MrlMultiFilter render prop.\n\t */\n\tfield?: never;\n\t/**\n\t * Message shown when the field is required and empty on Apply. Defaults to the\n\t * MrlMultiFilter `requiredMessage`.\n\t */\n\trequiredMessage?: never;\n};\n\n/**\n * A field that can show an error: `children` must be a function so the consumer can link the\n * error message to the form element.\n */\ntype MrlMultiFilterFieldWithErrorProps = Omit<\n\tMrlMultiFilterFieldWithoutErrorProps,\n\t'children' | 'errorMessage'\n> & {\n\t/**\n\t * To show an error, pass a function instead. It receives `errorId` and `hasError`: pass\n\t * them to the form element's `aria-errormessage` and `hasError` (or `aria-invalid`).\n\t */\n\tchildren: (renderProps: MrlMultiFilterFieldRenderProps) => React.ReactNode;\n\t/**\n\t * Requires `children` to be a function, so the message can be linked to the form element.\n\t */\n\terrorMessage?: string;\n};\n\n/**\n * A field bound to the MrlMultiFilter draft through `field`.\n */\ntype MrlMultiFilterFieldBoundProps<V> = {\n\t/**\n\t * With `field`, the function also receives `value`, `setValue` and `required`.\n\t */\n\tchildren: (renderProps: MrlMultiFilterFieldBoundRenderProps<V>) => React.ReactNode;\n\t/**\n\t * Takes precedence over the required error.\n\t */\n\terrorMessage?: string;\n\t/**\n\t * Must come from the same MrlMultiFilter.\n\t */\n\tfield: MrlMultiFilterFieldBinding<V>;\n\t/**\n\t * Overrides it for this field.\n\t */\n\trequiredMessage?: string;\n};\n\ntype MrlMultiFilterFieldBaseProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> &\n\tDataQa;\n\nexport type MrlMultiFilterFieldProps<V = unknown> = (\n\t| MrlMultiFilterFieldWithoutErrorProps\n\t| MrlMultiFilterFieldWithErrorProps\n\t| MrlMultiFilterFieldBoundProps<V>\n) &\n\tMrlMultiFilterFieldBaseProps;\n\n/**\n * MrlMultiFilterField component.\n *\n * Wraps a single filter control of the MrlMultiFilter and shows an inline error message\n * below it when `errorMessage` is set. `errorMessage` requires `children` to be a render\n * function, which receives `errorId` and `hasError` so the error is always linked to the form\n * element and its invalid state matches the message. Pass `field={getField('name')}` from the\n * MrlMultiFilter render prop to bind the field to the draft: the function then also receives\n * the typed `value`, `setValue` and `required`, and the required error is shown on Apply.\n *\n * @param props - The component props.\n * @returns The MrlMultiFilterField component.\n */\nexport function MrlMultiFilterField<V>(\n\tprops: MrlMultiFilterFieldBoundProps<V> & MrlMultiFilterFieldBaseProps\n): React.ReactElement;\nexport function MrlMultiFilterField(\n\tprops: (MrlMultiFilterFieldWithoutErrorProps | MrlMultiFilterFieldWithErrorProps) &\n\t\tMrlMultiFilterFieldBaseProps\n): React.ReactElement;\n// Overloads, so TypeScript types the render function of a bound and an unbound field.\nexport function MrlMultiFilterField<V>(props: MrlMultiFilterFieldProps<V>): React.ReactElement {\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\t['data-qa']: dataQa,\n\t\terrorMessage,\n\t\tfield,\n\t\trequiredMessage,\n\t\t...rest\n\t} = props;\n\n\tconst context = useOptionalMrlMultiFilterContext();\n\tconst registerField = context?.registerField;\n\tconst name = field?.name;\n\n\tconst elementRef = React.useRef<HTMLDivElement>(null);\n\tconst errorIdRef = React.useRef<string>(getUniqueId('mrl-multi-filter-field-error'));\n\n\t// Register the element, so validation can focus the field.\n\tReact.useEffect(() => {\n\t\tif (name === undefined || !registerField || !elementRef.current) return;\n\t\treturn registerField(name, elementRef.current);\n\t}, [name, registerField]);\n\n\tconst requiredError = field?.error ? (requiredMessage ?? field.error) : undefined;\n\tconst message = errorMessage ?? requiredError;\n\tconst hasError = Boolean(message);\n\tconst errorId = hasError ? errorIdRef.current : undefined;\n\n\tconst renderChildren = () => {\n\t\tif (typeof children !== 'function') return children;\n\t\tif (!field) {\n\t\t\treturn (children as MrlMultiFilterFieldWithErrorProps['children'])({ errorId, hasError });\n\t\t}\n\t\treturn (children as MrlMultiFilterFieldBoundProps<V>['children'])({\n\t\t\terrorId,\n\t\t\thasError,\n\t\t\trequired: field.required,\n\t\t\tsetValue: field.setValue,\n\t\t\tvalue: field.value\n\t\t});\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tclassName={classnames(styles['MrlMultiFilterField'], 'MrlMultiFilterField', className)}\n\t\t\tdata-qa={dataQa}\n\t\t\tref={elementRef}\n\t\t>\n\t\t\t{renderChildren()}\n\t\t\t{errorId && <MrlInlineMessage id={errorId} kind=\"error\" message={message} />}\n\t\t</div>\n\t);\n}\n"],"names":["MrlMultiFilterField","props","children","className","dataQa","errorMessage","field","requiredMessage","rest","_objectWithoutProperties","_excluded","context","useOptionalMrlMultiFilterContext","registerField","name","elementRef","React","useRef","errorIdRef","getUniqueId","useEffect","undefined","current","requiredError","error","message","hasError","Boolean","errorId","renderChildren","required","setValue","value","createElement","_extends","classnames","styles","ref","MrlInlineMessage","id","kind"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;;AA2BA;AACA;AACA;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;;AAgBA;AACA;AACA;;AA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACO,SAASA,mBAAmBA,CAAIC,KAAkC,EAAsB;AAC9F,EAAA,IACCC,QAAQ,GAOLD,KAAK,CAPRC,QAAQ;IACRC,SAAS,GAMNF,KAAK,CANRE,SA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AAO,CAACF,OAAO,CAAC;EACjC,IAAMG,OAAO,GAAGF,QAAQ,GAAGR,UAAU,CAACI,OAAO,GAAGD,SAAS;EAEzD,IAAMQ,cAAc,GAAGA,MAAM;AAC5B,IAAA,IAAI,OAAO3B,QAAQ,KAAK,UAAU,EAAE,OAAOA,QAAQ;IACnD,IAAI,CAACI,KAAK,EAAE;AACX,MAAA,OAAQJ,QAAQ,CAAmD;QAAE0B,OAAO;AAAEF,QAAAA;AAAS,OAAC,CAAC;AAC1F,IAAA;AACA,IAAA,OAAQxB,QAAQ,CAAkD;MACjE0B,OAAO;MACPF,QAAQ;MACRI,QAAQ,EAAExB,KAAK,CAACwB,QAAQ;MACxBC,QAAQ,EAAEzB,KAAK,CAACyB,QAAQ;MACxBC,KAAK,EAAE1B,KAAK,CAAC0B;AACd,KAAC,CAAC;EACH,CAAC;AAED,EAAA,oBACChB,gBAAA,CAAAiB,aAAA,CAAA,KAAA,EAAAC,iCAAA,KACK1B,IAAI,EAAA;IACRL,SAAS,EAAEgC,2BAAU,CAACC,kCAAM,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,EAAEjC,SAAS,CAAE;AACvF,IAAA,SAAA,EAASC,MAAO;AAChBiC,IAAAA,GAAG,EAAEtB;GAAW,CAAA,EAEfc,cAAc,EAAE,EAChBD,OAAO,iBAAIZ,gBAAA,CAAAiB,aAAA,CAACK,iCAAgB,EAAA;AAACC,IAAAA,EAAE,EAAEX,OAAQ;AAACY,IAAAA,IAAI,EAAC,OAAO;AAACf,IAAAA,OAAO,EAAEA;AAAQ,GAAE,CACvE,CAAC;AAER;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlMultiFilterField.js","sources":["../../../../../src/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport styles from './MrlMultiFilterField.module.scss';\nimport { MrlInlineMessage } from '../../notification/MrlInlineMessage/MrlInlineMessage';\nimport { useOptionalMrlMultiFilterContext } from '../MrlMultiFilterContext/MrlMultiFilterContext';\nimport { DataQa } from '../../../utils/dataQa';\nimport { getUniqueId } from '../../../utils/setAttributes/setAttributes';\n\nexport type MrlMultiFilterFieldRenderProps = {\n\t/**\n\t * Id of the rendered error message, or `undefined` when there is no error. Pass it to the\n\t * form element's `aria-errormessage` (with `aria-invalid`) or `aria-describedby` so the\n\t * error is announced with the field.\n\t */\n\terrorId?: string;\n\t/**\n\t * Whether the field is showing an error. Pass it to the form element's `hasError` (or\n\t * `aria-invalid`) so its error styles and invalid state match the message.\n\t */\n\thasError: boolean;\n};\n\n/**\n * A field of the MrlMultiFilter draft, returned by `getField` from its render prop.\n */\nexport type MrlMultiFilterFieldBinding<V> = {\n\t/**\n\t * The required error message, set while the field is required and empty after Apply.\n\t */\n\terror?: string;\n\t/**\n\t * Name of the field in the draft.\n\t */\n\tname: string;\n\t/**\n\t * Whether the field is required.\n\t */\n\trequired: boolean;\n\t/**\n\t * Updates the field's value in the draft.\n\t */\n\tsetValue: (value: V) => void;\n\t/**\n\t * The field's value in the draft.\n\t */\n\tvalue: V;\n};\n\nexport type MrlMultiFilterFieldBoundRenderProps<V> = MrlMultiFilterFieldRenderProps &\n\tPick<MrlMultiFilterFieldBinding<V>, 'required' | 'setValue' | 'value'>;\n\n/**\n * A field that never shows an error: plain children, no `errorMessage`.\n *\n * Docgen merges the JSDoc of the union members (this one first), so each comment below is\n * written to read on its own and as the first part of the merged description.\n */\ntype MrlMultiFilterFieldWithoutErrorProps = {\n\t/**\n\t * The field content, usually a label and a form element.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * Error message shown below the field. When omitted, no error is rendered.\n\t */\n\terrorMessage?: never;\n\t/**\n\t * Binds the field to the MrlMultiFilter draft. Pass `getField('name')` from the\n\t * MrlMultiFilter render prop.\n\t */\n\tfield?: never;\n\t/**\n\t * Message shown when the field is required and empty on Apply. Defaults to the\n\t * MrlMultiFilter `requiredMessage`.\n\t */\n\trequiredMessage?: never;\n};\n\n/**\n * A field that can show an error: `children` must be a function so the consumer can link the\n * error message to the form element.\n */\ntype MrlMultiFilterFieldWithErrorProps = Omit<\n\tMrlMultiFilterFieldWithoutErrorProps,\n\t'children' | 'errorMessage'\n> & {\n\t/**\n\t * To show an error, pass a function instead. It receives `errorId` and `hasError`: pass\n\t * them to the form element's `aria-errormessage` and `hasError` (or `aria-invalid`).\n\t */\n\tchildren: (renderProps: MrlMultiFilterFieldRenderProps) => React.ReactNode;\n\t/**\n\t * Requires `children` to be a function, so the message can be linked to the form element.\n\t */\n\terrorMessage?: string;\n};\n\n/**\n * A field bound to the MrlMultiFilter draft through `field`.\n */\ntype MrlMultiFilterFieldBoundProps<V> = {\n\t/**\n\t * With `field`, the function also receives `value`, `setValue` and `required`.\n\t */\n\tchildren: (renderProps: MrlMultiFilterFieldBoundRenderProps<V>) => React.ReactNode;\n\t/**\n\t * Takes precedence over the required error.\n\t */\n\terrorMessage?: string;\n\t/**\n\t * Must come from the same MrlMultiFilter.\n\t */\n\tfield: MrlMultiFilterFieldBinding<V>;\n\t/**\n\t * Overrides it for this field.\n\t */\n\trequiredMessage?: string;\n};\n\ntype MrlMultiFilterFieldBaseProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> &\n\tDataQa;\n\nexport type MrlMultiFilterFieldProps<V = unknown> = (\n\t| MrlMultiFilterFieldWithoutErrorProps\n\t| MrlMultiFilterFieldWithErrorProps\n\t| MrlMultiFilterFieldBoundProps<V>\n) &\n\tMrlMultiFilterFieldBaseProps;\n\n/**\n * MrlMultiFilterField component.\n *\n * Wraps a single filter control of the MrlMultiFilter and shows an inline error message\n * below it when `errorMessage` is set. `errorMessage` requires `children` to be a render\n * function, which receives `errorId` and `hasError` so the error is always linked to the form\n * element and its invalid state matches the message. Pass `field={getField('name')}` from the\n * MrlMultiFilter render prop to bind the field to the draft: the function then also receives\n * the typed `value`, `setValue` and `required`, and the required error is shown on Apply.\n *\n * @param props - The component props.\n * @returns The MrlMultiFilterField component.\n */\nexport function MrlMultiFilterField<V>(\n\tprops: MrlMultiFilterFieldBoundProps<V> & MrlMultiFilterFieldBaseProps\n): React.ReactElement;\nexport function MrlMultiFilterField(\n\tprops: (MrlMultiFilterFieldWithoutErrorProps | MrlMultiFilterFieldWithErrorProps) &\n\t\tMrlMultiFilterFieldBaseProps\n): React.ReactElement;\n// Overloads, so TypeScript types the render function of a bound and an unbound field.\nexport function MrlMultiFilterField<V>(props: MrlMultiFilterFieldProps<V>): React.ReactElement {\n\tconst {\n\t\tchildren,\n\t\tclassName,\n\t\t['data-qa']: dataQa,\n\t\terrorMessage,\n\t\tfield,\n\t\trequiredMessage,\n\t\t...rest\n\t} = props;\n\n\tconst context = useOptionalMrlMultiFilterContext();\n\tconst registerField = context?.registerField;\n\tconst name = field?.name;\n\n\tconst elementRef = React.useRef<HTMLDivElement>(null);\n\tconst errorIdRef = React.useRef<string>(getUniqueId('mrl-multi-filter-field-error'));\n\n\t// Register the element, so validation can focus the field.\n\tReact.useEffect(() => {\n\t\tif (name === undefined || !registerField || !elementRef.current) return;\n\t\treturn registerField(name, elementRef.current);\n\t}, [name, registerField]);\n\n\tconst requiredError = field?.error ? (requiredMessage ?? field.error) : undefined;\n\tconst message = errorMessage ?? requiredError;\n\tconst hasError = Boolean(message);\n\tconst errorId = hasError ? errorIdRef.current : undefined;\n\n\tconst renderChildren = () => {\n\t\tif (typeof children !== 'function') return children;\n\t\tif (!field) {\n\t\t\treturn (children as MrlMultiFilterFieldWithErrorProps['children'])({ errorId, hasError });\n\t\t}\n\t\treturn (children as MrlMultiFilterFieldBoundProps<V>['children'])({\n\t\t\terrorId,\n\t\t\thasError,\n\t\t\trequired: field.required,\n\t\t\tsetValue: field.setValue,\n\t\t\tvalue: field.value\n\t\t});\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tclassName={classnames(styles['MrlMultiFilterField'], 'MrlMultiFilterField', className)}\n\t\t\tdata-qa={dataQa}\n\t\t\tref={elementRef}\n\t\t>\n\t\t\t{renderChildren()}\n\t\t\t{errorId && (\n\t\t\t\t<MrlInlineMessage\n\t\t\t\t\tclassName={classnames(styles['MrlMultiFilterField-error'], 'MrlMultiFilterField-error')}\n\t\t\t\t\tid={errorId}\n\t\t\t\t\tkind=\"error\"\n\t\t\t\t\tmessage={message}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"names":["MrlMultiFilterField","props","children","className","dataQa","errorMessage","field","requiredMessage","rest","_objectWithoutProperties","_excluded","context","useOptionalMrlMultiFilterContext","registerField","name","elementRef","React","useRef","errorIdRef","getUniqueId","useEffect","undefined","current","requiredError","error","message","hasError","Boolean","errorId","renderChildren","required","setValue","value","createElement","_extends","classnames","styles","ref","MrlInlineMessage","id","kind"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;;AA2BA;AACA;AACA;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;;AAgBA;AACA;AACA;;AA8BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACO,SAASA,mBAAmBA,CAAIC,KAAkC,EAAsB;AAC9F,EAAA,IACCC,QAAQ,GAOLD,KAAK,CAPRC,QAAQ;IACRC,SAAS,GAMNF,KAAK,CANRE,SAAS;IACIC,MAAM,GAKhBH,KAAK,CALP,SAAS,CAAA;IACVI,YAAY,GAITJ,KAAK,CAJRI,YAAY;IACZC,KAAK,GAGFL,KAAK,CAHRK,KAAK;IACLC,eAAe,GAEZN,KAAK,CAFRM,eAAe;AACZC,IAAAA,IAAI,GAAAC,iDAAA,CACJR,KAAK,EAAAS,SAAA,CAAA;AAET,EAAA,IAAMC,OAAO,GAAGC,sDAAgC,EAAE;EAClD,IAAMC,aAAa,GAAGF,OAAO,KAAA,IAAA,IAAPA,OAAO,KAAA,MAAA,GAAA,MAAA,GAAPA,OAAO,CAAEE,aAAa;EAC5C,IAAMC,IAAI,GAAGR,KAAK,K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QAAQ;MACxBC,QAAQ,EAAEzB,KAAK,CAACyB,QAAQ;MACxBC,KAAK,EAAE1B,KAAK,CAAC0B;AACd,KAAC,CAAC;EACH,CAAC;AAED,EAAA,oBACChB,gBAAA,CAAAiB,aAAA,CAAA,KAAA,EAAAC,iCAAA,KACK1B,IAAI,EAAA;IACRL,SAAS,EAAEgC,2BAAU,CAACC,kCAAM,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,EAAEjC,SAAS,CAAE;AACvF,IAAA,SAAA,EAASC,MAAO;AAChBiC,IAAAA,GAAG,EAAEtB;GAAW,CAAA,EAEfc,cAAc,EAAE,EAChBD,OAAO,iBACPZ,gBAAA,CAAAiB,aAAA,CAACK,iCAAgB,EAAA;IAChBnC,SAAS,EAAEgC,2BAAU,CAACC,kCAAM,CAAC,2BAA2B,CAAC,EAAE,2BAA2B,CAAE;AACxFG,IAAAA,EAAE,EAAEX,OAAQ;AACZY,IAAAA,IAAI,EAAC,OAAO;AACZf,IAAAA,OAAO,EAAEA;AAAQ,GACjB,CAEE,CAAC;AAER;;;;"}
|
package/dist/cjs/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.module.scss.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var styles = {"MrlMultiFilterField":"MrlMultiFilterField--lVlxB"};
|
|
5
|
+
var styles = {"MrlMultiFilterField":"MrlMultiFilterField--lVlxB","MrlMultiFilterField-error":"MrlMultiFilterField-error--jh1El"};
|
|
6
6
|
|
|
7
7
|
exports.default = styles;
|
|
8
8
|
//# sourceMappingURL=MrlMultiFilterField.module.scss.js.map
|
|
@@ -30,7 +30,7 @@ function _interopNamespace(e) {
|
|
|
30
30
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
31
31
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
32
32
|
|
|
33
|
-
var _excluded = ["children", "customIcon", "id", "kind", "message", "data-qa"];
|
|
33
|
+
var _excluded = ["children", "className", "customIcon", "id", "kind", "message", "data-qa"];
|
|
34
34
|
var getIcon = (kind, customIcon) => {
|
|
35
35
|
switch (kind) {
|
|
36
36
|
case 'error':
|
|
@@ -63,6 +63,7 @@ var renderIcon = (icon, iconClasses) => {
|
|
|
63
63
|
*/
|
|
64
64
|
var MrlInlineMessage = _ref => {
|
|
65
65
|
var children = _ref.children,
|
|
66
|
+
className = _ref.className,
|
|
66
67
|
customIcon = _ref.customIcon,
|
|
67
68
|
id = _ref.id,
|
|
68
69
|
kind = _ref.kind,
|
|
@@ -78,7 +79,7 @@ var MrlInlineMessage = _ref => {
|
|
|
78
79
|
[MrlInlineMessage_module.default.success]: kind === 'success',
|
|
79
80
|
[MrlInlineMessage_module.default.warning]: kind === 'warning',
|
|
80
81
|
[MrlInlineMessage_module.default.helper]: kind === 'helper'
|
|
81
|
-
});
|
|
82
|
+
}, className);
|
|
82
83
|
return /*#__PURE__*/React__namespace.createElement("span", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
83
84
|
className: notificationClasses,
|
|
84
85
|
"data-qa": qa,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlInlineMessage.js","sources":["../../../../../src/components/notification/MrlInlineMessage/MrlInlineMessage.tsx"],"sourcesContent":["import * as React from 'react';\nimport { error, info, warning, check } from '@muraldevkit/ds-icons';\nimport { DSIconType, MrlSvg } from '../../svg';\nimport classNames from 'classnames';\nimport styles from './MrlInlineMessage.module.scss';\n\nexport type InlineMessageKind = 'error' | 'info' | 'warning' | 'success' | 'helper';\n\nexport interface MrlInlineMessageProps {\n\t/**\n\t * A custom DS icon which is only applied if the alert is not an error, info, or warning type\n\t */\n\tcustomIcon?: DSIconType;\n\n\t/**\n\t * The id of the notification.\n\t *\n\t * Used to link the notification to a form field using aria-describedby.\n\t */\n\tid: string;\n\n\t/**\n\t * Choose the kind of notification to display.\n\t *\n\t * Accepted values: error, info, warning, success, helper\n\t */\n\tkind: InlineMessageKind;\n\n\t/**\n\t * The text to be displayed in the notification. If not provided, children will be used.\n\t */\n\tmessage?: string;\n\n\t/**\n\t * Children to be rendered within the component, it will be used as the message if message is not provided.\n\t */\n\tchildren?: React.ReactNode;\n\n\t/**\n\t * The data-qa attribute for testing purposes.\n\t */\n\t['data-qa']?: string;\n}\n\nconst getIcon = (kind: InlineMessageKind, customIcon?: DSIconType): DSIconType | undefined => {\n\tswitch (kind) {\n\t\tcase 'error':\n\t\t\treturn error;\n\t\tcase 'info':\n\t\t\treturn info;\n\t\tcase 'warning':\n\t\t\treturn warning;\n\t\tcase 'success':\n\t\t\treturn check;\n\t\tdefault:\n\t\t\treturn customIcon ? customIcon : undefined;\n\t}\n};\n\nconst renderIcon = (\n\ticon: DSIconType | undefined,\n\ticonClasses: string\n): React.ReactElement | undefined => {\n\tif (icon) {\n\t\treturn (\n\t\t\t<span className={iconClasses}>\n\t\t\t\t<MrlSvg size=\"auto\" svg={icon} />\n\t\t\t</span>\n\t\t);\n\t}\n};\n\n/**\n * MrlInlineMessage is a notification component that can be used to display messages to the user.\n * @param props - The properties of the component.\n * @returns A React component.\n */\nexport const MrlInlineMessage = ({\n\tchildren,\n\tcustomIcon,\n\tid,\n\tkind,\n\tmessage,\n\t['data-qa']: qa = 'mrl-inline-notification',\n\t...rest\n}: MrlInlineMessageProps): React.ReactElement => {\n\tconst icon = getIcon(kind, customIcon);\n\tconst iconClasses = classNames(styles['MrlInlineMessage-icon']);\n\n\tconst notificationClasses = classNames(
|
|
1
|
+
{"version":3,"file":"MrlInlineMessage.js","sources":["../../../../../src/components/notification/MrlInlineMessage/MrlInlineMessage.tsx"],"sourcesContent":["import * as React from 'react';\nimport { error, info, warning, check } from '@muraldevkit/ds-icons';\nimport { DSIconType, MrlSvg } from '../../svg';\nimport classNames from 'classnames';\nimport styles from './MrlInlineMessage.module.scss';\n\nexport type InlineMessageKind = 'error' | 'info' | 'warning' | 'success' | 'helper';\n\nexport interface MrlInlineMessageProps {\n\t/**\n\t * A custom DS icon which is only applied if the alert is not an error, info, or warning type\n\t */\n\tcustomIcon?: DSIconType;\n\n\t/**\n\t * The id of the notification.\n\t *\n\t * Used to link the notification to a form field using aria-describedby.\n\t */\n\tid: string;\n\n\t/**\n\t * Choose the kind of notification to display.\n\t *\n\t * Accepted values: error, info, warning, success, helper\n\t */\n\tkind: InlineMessageKind;\n\n\t/**\n\t * The text to be displayed in the notification. If not provided, children will be used.\n\t */\n\tmessage?: string;\n\n\t/**\n\t * Children to be rendered within the component, it will be used as the message if message is not provided.\n\t */\n\tchildren?: React.ReactNode;\n\n\t/**\n\t * Additional class name(s) applied to the root element, merged with the component's own classes.\n\t */\n\tclassName?: string;\n\n\t/**\n\t * The data-qa attribute for testing purposes.\n\t */\n\t['data-qa']?: string;\n}\n\nconst getIcon = (kind: InlineMessageKind, customIcon?: DSIconType): DSIconType | undefined => {\n\tswitch (kind) {\n\t\tcase 'error':\n\t\t\treturn error;\n\t\tcase 'info':\n\t\t\treturn info;\n\t\tcase 'warning':\n\t\t\treturn warning;\n\t\tcase 'success':\n\t\t\treturn check;\n\t\tdefault:\n\t\t\treturn customIcon ? customIcon : undefined;\n\t}\n};\n\nconst renderIcon = (\n\ticon: DSIconType | undefined,\n\ticonClasses: string\n): React.ReactElement | undefined => {\n\tif (icon) {\n\t\treturn (\n\t\t\t<span className={iconClasses}>\n\t\t\t\t<MrlSvg size=\"auto\" svg={icon} />\n\t\t\t</span>\n\t\t);\n\t}\n};\n\n/**\n * MrlInlineMessage is a notification component that can be used to display messages to the user.\n * @param props - The properties of the component.\n * @returns A React component.\n */\nexport const MrlInlineMessage = ({\n\tchildren,\n\tclassName,\n\tcustomIcon,\n\tid,\n\tkind,\n\tmessage,\n\t['data-qa']: qa = 'mrl-inline-notification',\n\t...rest\n}: MrlInlineMessageProps): React.ReactElement => {\n\tconst icon = getIcon(kind, customIcon);\n\tconst iconClasses = classNames(styles['MrlInlineMessage-icon']);\n\n\tconst notificationClasses = classNames(\n\t\tstyles['MrlInlineMessage'],\n\t\t'MrlInlineMessage',\n\t\t{\n\t\t\t[styles.error]: kind === 'error',\n\t\t\t[styles.information]: kind === 'info',\n\t\t\t[styles.success]: kind === 'success',\n\t\t\t[styles.warning]: kind === 'warning',\n\t\t\t[styles.helper]: kind === 'helper'\n\t\t},\n\t\tclassName\n\t);\n\n\treturn (\n\t\t<span {...rest} className={notificationClasses} data-qa={qa} id={id}>\n\t\t\t{renderIcon(icon, iconClasses)}\n\t\t\t<span className=\"MrlInlineMessage-message\">\n\t\t\t\t{typeof message !== 'undefined' ? message : children}\n\t\t\t</span>\n\t\t</span>\n\t);\n};\n"],"names":["getIcon","kind","customIcon","error","info","warning","check","undefined","renderIcon","icon","iconClasses","React","createElement","className","MrlSvg","size","svg","MrlInlineMessage","_ref","children","id","message","_ref$dataQa","qa","rest","_objectWithoutProperties","_excluded","classNames","styles","notificationClasses","information","success","helper","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAMA,OAAO,GAAGA,CAACC,IAAuB,EAAEC,UAAuB,KAA6B;AAC7F,EAAA,QAAQD,IAAI;AACX,IAAA,KAAK,OAAO;AACX,MAAA,OAAOE,aAAK;AACb,IAAA,KAAK,MAAM;AACV,MAAA,OAAOC,YAAI;AACZ,IAAA,KAAK,SAAS;AACb,MAAA,OAAOC,eAAO;AACf,IAAA,KAAK,SAAS;AACb,MAAA,OAAOC,aAAK;AACb,IAAA;AACC,MAAA,OAAOJ,UAAU,GAAGA,UAAU,GAAGK,SAAS;AAC5C;AACD,CAAC;AAED,IAAMC,UAAU,GAAGA,CAClBC,IAA4B,EAC5BC,WAAmB,KACiB;AACpC,EAAA,IAAID,IAAI,EAAE;IACT,oBACCE,gBAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AAAMC,MAAAA,SAAS,EAAEH;AAAY,KAAA,eAC5BC,gBAAA,CAAAC,aAAA,CAACE,aAAM,EAAA;AAACC,MAA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