@muraldevkit/ui-toolkit 4.79.1 → 4.81.0-dev-Rwvu.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/badge/MrlBadge/MrlBadge.js.map +1 -1
- package/dist/cjs/components/badge/MrlBadgeNotification/MrlBadgeNotification.js.map +1 -1
- package/dist/cjs/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js.map +1 -1
- package/dist/cjs/components/callout/MrlCallout/MrlCallout.js.map +1 -1
- package/dist/cjs/components/empty/default/MrlEmpty.js.map +1 -1
- package/dist/cjs/components/empty/large/MrlEmptyLarge.js.map +1 -1
- package/dist/cjs/components/form/date-picker/MrlDatePicker.js.map +1 -1
- package/dist/cjs/components/form/select/MrlCreatableSelect/MrlCreatableSelect.js.map +1 -1
- package/dist/cjs/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js.map +1 -1
- package/dist/cjs/components/form/select/MrlMultiSelect/MrlMultiSelect.js.map +1 -1
- package/dist/cjs/components/form/select/MrlSelect/MrlSelect.js.map +1 -1
- package/dist/cjs/components/form/switch/MrlSwitch/MrlSwitch.js.map +1 -1
- package/dist/cjs/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.js.map +1 -1
- package/dist/cjs/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.js.map +1 -1
- package/dist/cjs/components/grid/MrlCol/MrlCol.js +58 -55
- package/dist/cjs/components/grid/MrlCol/MrlCol.js.map +1 -1
- package/dist/cjs/components/grid/MrlGrid/MrlGrid.js +3 -5
- package/dist/cjs/components/grid/MrlGrid/MrlGrid.js.map +1 -1
- package/dist/cjs/components/grid/MrlRow/MrlRow.js +10 -8
- package/dist/cjs/components/grid/MrlRow/MrlRow.js.map +1 -1
- package/dist/cjs/components/grid/constants.js +47 -9
- package/dist/cjs/components/grid/constants.js.map +1 -1
- package/dist/cjs/components/layout/MrlSidebar/MrlSidebar.js.map +1 -1
- package/dist/cjs/components/live-region/MrlLiveRegion/MrlLiveRegion.js.map +1 -1
- package/dist/cjs/components/notification/MrlToast/MrlToast.js.map +1 -1
- package/dist/cjs/components/pagination/MrlPaginationButton/MrlPaginationButton.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/components/svg/MrlSvg/MrlSvg.js.map +1 -1
- package/dist/cjs/components/table/MrlTableCell/MrlTableCell.js.map +1 -1
- package/dist/cjs/components/table/MrlTableColumn/MrlTableColumn.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTab/MrlTab.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTabGroup/MrlTabGroup.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTabLink/MrlTabLink.js.map +1 -1
- package/dist/cjs/components/tabs/MrlTabs/MrlTabs.js.map +1 -1
- package/dist/cjs/components/text/MrlTextHeading/MrlTextHeading.js.map +1 -1
- package/dist/cjs/components/toolbar/MrlToolbar/MrlToolbar.js.map +1 -1
- package/dist/cjs/components/toolbar/MrlToolbarButton/MrlToolbarButton.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/components/avatar/MrlAvatar/MrlAvatar.d.ts +8 -0
- package/dist/components/badge/MrlBadge/MrlBadge.d.ts +2 -0
- package/dist/components/badge/MrlBadgeNotification/MrlBadgeNotification.d.ts +1 -0
- package/dist/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.d.ts +1 -0
- package/dist/components/callout/MrlCallout/MrlCallout.d.ts +9 -0
- package/dist/components/empty/default/MrlEmpty.d.ts +4 -0
- package/dist/components/empty/large/MrlEmptyLarge.d.ts +4 -0
- package/dist/components/form/date-picker/MrlDatePicker.d.ts +2 -0
- package/dist/components/form/select/MrlCreatableSelect/MrlCreatableSelect.d.ts +4 -0
- package/dist/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.d.ts +4 -0
- package/dist/components/form/select/MrlMultiSelect/MrlMultiSelect.d.ts +3 -0
- package/dist/components/form/select/MrlSelect/MrlSelect.d.ts +3 -0
- package/dist/components/form/switch/MrlSwitch/MrlSwitch.d.ts +3 -0
- package/dist/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.d.ts +3 -0
- package/dist/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.d.ts +3 -0
- package/dist/components/grid/MrlCol/MrlCol.d.ts +4 -6
- package/dist/components/grid/MrlCol/index.d.ts +1 -1
- package/dist/components/grid/MrlGrid/MrlGrid.d.ts +4 -4
- package/dist/components/grid/MrlGrid/index.d.ts +1 -1
- package/dist/components/grid/MrlRow/MrlRow.d.ts +7 -7
- package/dist/components/grid/MrlRow/index.d.ts +1 -1
- package/dist/components/grid/constants.d.ts +76 -12
- package/dist/components/grid/index.d.ts +1 -0
- package/dist/components/layout/MrlSidebar/MrlSidebar.d.ts +2 -0
- package/dist/components/live-region/MrlLiveRegion/MrlLiveRegion.d.ts +6 -0
- package/dist/components/notification/MrlToast/MrlToast.d.ts +8 -0
- package/dist/components/pagination/MrlPaginationButton/MrlPaginationButton.d.ts +1 -0
- package/dist/components/portal/MrlPortal.d.ts +1 -0
- package/dist/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.d.ts +10 -0
- package/dist/components/svg/MrlSvg/MrlSvg.d.ts +1 -0
- package/dist/components/table/MrlTableCell/MrlTableCell.d.ts +3 -0
- package/dist/components/table/MrlTableColumn/MrlTableColumn.d.ts +3 -0
- package/dist/components/tabs/MrlTab/MrlTab.d.ts +2 -0
- package/dist/components/tabs/MrlTabGroup/MrlTabGroup.d.ts +1 -0
- package/dist/components/tabs/MrlTabLink/MrlTabLink.d.ts +1 -0
- package/dist/components/tabs/MrlTabs/MrlTabs.d.ts +2 -0
- package/dist/components/text/MrlTextHeading/MrlTextHeading.d.ts +1 -0
- package/dist/components/toolbar/MrlToolbar/MrlToolbar.d.ts +12 -0
- package/dist/components/toolbar/MrlToolbarButton/MrlToolbarButton.d.ts +2 -0
- package/dist/esm/components/avatar/MrlAvatar/MrlAvatar.js.map +1 -1
- package/dist/esm/components/badge/MrlBadge/MrlBadge.js.map +1 -1
- package/dist/esm/components/badge/MrlBadgeNotification/MrlBadgeNotification.js.map +1 -1
- package/dist/esm/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.js.map +1 -1
- package/dist/esm/components/callout/MrlCallout/MrlCallout.js.map +1 -1
- package/dist/esm/components/empty/default/MrlEmpty.js.map +1 -1
- package/dist/esm/components/empty/large/MrlEmptyLarge.js.map +1 -1
- package/dist/esm/components/form/date-picker/MrlDatePicker.js.map +1 -1
- package/dist/esm/components/form/select/MrlCreatableSelect/MrlCreatableSelect.js.map +1 -1
- package/dist/esm/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.js.map +1 -1
- package/dist/esm/components/form/select/MrlMultiSelect/MrlMultiSelect.js.map +1 -1
- package/dist/esm/components/form/select/MrlSelect/MrlSelect.js.map +1 -1
- package/dist/esm/components/form/switch/MrlSwitch/MrlSwitch.js.map +1 -1
- package/dist/esm/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.js.map +1 -1
- package/dist/esm/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.js.map +1 -1
- package/dist/esm/components/grid/MrlCol/MrlCol.js +59 -56
- package/dist/esm/components/grid/MrlCol/MrlCol.js.map +1 -1
- package/dist/esm/components/grid/MrlGrid/MrlGrid.js +3 -5
- package/dist/esm/components/grid/MrlGrid/MrlGrid.js.map +1 -1
- package/dist/esm/components/grid/MrlRow/MrlRow.js +10 -8
- package/dist/esm/components/grid/MrlRow/MrlRow.js.map +1 -1
- package/dist/esm/components/grid/constants.js +46 -9
- package/dist/esm/components/grid/constants.js.map +1 -1
- package/dist/esm/components/layout/MrlSidebar/MrlSidebar.js.map +1 -1
- package/dist/esm/components/live-region/MrlLiveRegion/MrlLiveRegion.js.map +1 -1
- package/dist/esm/components/notification/MrlToast/MrlToast.js.map +1 -1
- package/dist/esm/components/pagination/MrlPaginationButton/MrlPaginationButton.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/components/svg/MrlSvg/MrlSvg.js.map +1 -1
- package/dist/esm/components/table/MrlTableCell/MrlTableCell.js.map +1 -1
- package/dist/esm/components/table/MrlTableColumn/MrlTableColumn.js.map +1 -1
- package/dist/esm/components/tabs/MrlTab/MrlTab.js.map +1 -1
- package/dist/esm/components/tabs/MrlTabGroup/MrlTabGroup.js.map +1 -1
- package/dist/esm/components/tabs/MrlTabLink/MrlTabLink.js.map +1 -1
- package/dist/esm/components/tabs/MrlTabs/MrlTabs.js.map +1 -1
- package/dist/esm/components/text/MrlTextHeading/MrlTextHeading.js.map +1 -1
- package/dist/esm/components/toolbar/MrlToolbar/MrlToolbar.js.map +1 -1
- package/dist/esm/components/toolbar/MrlToolbarButton/MrlToolbarButton.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/styles/MrlSidebar/module.scss +2 -2
- package/dist/styles/grid/global.scss +97 -2
- package/dist/styles.css +1 -7
- package/dist/types/components/avatar/MrlAvatar/MrlAvatar.d.ts +8 -0
- package/dist/types/components/badge/MrlBadge/MrlBadge.d.ts +2 -0
- package/dist/types/components/badge/MrlBadgeNotification/MrlBadgeNotification.d.ts +1 -0
- package/dist/types/components/button/MrlAnimatedIconButton/MrlAnimatedIconButton.d.ts +1 -0
- package/dist/types/components/callout/MrlCallout/MrlCallout.d.ts +9 -0
- package/dist/types/components/empty/default/MrlEmpty.d.ts +4 -0
- package/dist/types/components/empty/large/MrlEmptyLarge.d.ts +4 -0
- package/dist/types/components/form/date-picker/MrlDatePicker.d.ts +2 -0
- package/dist/types/components/form/select/MrlCreatableSelect/MrlCreatableSelect.d.ts +4 -0
- package/dist/types/components/form/select/MrlMultiCreatableSelect/MrlMultiCreatableSelect.d.ts +4 -0
- package/dist/types/components/form/select/MrlMultiSelect/MrlMultiSelect.d.ts +3 -0
- package/dist/types/components/form/select/MrlSelect/MrlSelect.d.ts +3 -0
- package/dist/types/components/form/switch/MrlSwitch/MrlSwitch.d.ts +3 -0
- package/dist/types/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.d.ts +3 -0
- package/dist/types/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.d.ts +3 -0
- package/dist/types/components/grid/MrlCol/MrlCol.d.ts +4 -6
- package/dist/types/components/grid/MrlCol/index.d.ts +1 -1
- package/dist/types/components/grid/MrlGrid/MrlGrid.d.ts +4 -4
- package/dist/types/components/grid/MrlGrid/index.d.ts +1 -1
- package/dist/types/components/grid/MrlRow/MrlRow.d.ts +7 -7
- package/dist/types/components/grid/MrlRow/index.d.ts +1 -1
- package/dist/types/components/grid/constants.d.ts +76 -12
- package/dist/types/components/grid/index.d.ts +1 -0
- package/dist/types/components/layout/MrlSidebar/MrlSidebar.d.ts +2 -0
- package/dist/types/components/live-region/MrlLiveRegion/MrlLiveRegion.d.ts +6 -0
- package/dist/types/components/notification/MrlToast/MrlToast.d.ts +8 -0
- package/dist/types/components/pagination/MrlPaginationButton/MrlPaginationButton.d.ts +1 -0
- package/dist/types/components/portal/MrlPortal.d.ts +1 -0
- package/dist/types/components/rovingTabindex/MrlRovingTabindex/MrlRovingTabindex.d.ts +10 -0
- package/dist/types/components/svg/MrlSvg/MrlSvg.d.ts +1 -0
- package/dist/types/components/table/MrlTableCell/MrlTableCell.d.ts +3 -0
- package/dist/types/components/table/MrlTableColumn/MrlTableColumn.d.ts +3 -0
- package/dist/types/components/tabs/MrlTab/MrlTab.d.ts +2 -0
- package/dist/types/components/tabs/MrlTabGroup/MrlTabGroup.d.ts +1 -0
- package/dist/types/components/tabs/MrlTabLink/MrlTabLink.d.ts +1 -0
- package/dist/types/components/tabs/MrlTabs/MrlTabs.d.ts +2 -0
- package/dist/types/components/text/MrlTextHeading/MrlTextHeading.d.ts +1 -0
- package/dist/types/components/toolbar/MrlToolbar/MrlToolbar.d.ts +12 -0
- package/dist/types/components/toolbar/MrlToolbarButton/MrlToolbarButton.d.ts +2 -0
- package/package.json +1 -1
- package/dist/styles/grid/variables.scss +0 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlSwitch.js","sources":["../../../../../../src/components/form/switch/MrlSwitch/MrlSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { memo, useMemo } from 'react';\nimport { MrlSwitchStandalone } from '../MrlSwitchStandalone/MrlSwitchStandalone';\nimport { getUniqueId } from '../../../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlSwitch.module.scss';\n\ninterface MrlSwitchProps extends React.ComponentPropsWithoutRef<'input'> {\n\tclassName?: string;\n\tdisabled?: boolean;\n\tid?: string;\n\t/**\n\t * Enables interaction tracking for this switch. Provide a stable, non-PII id\n\t * (e.g. 'workspace-sso-toggle'). When omitted, the switch emits no analytics.\n\t */\n\teventId?: string;\n\t/**\n\t * The `label` is best used as a string, which will style according to MrlLabel styles.\n\t * If you need custom styles, you can use `className` or use a span that you style as `label`\n\t */\n\tlabel: string | React.ReactNode;\n\tonChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n\tselected?: boolean;\n}\n\nexport const MrlSwitch = memo(\n\t({\n\t\tclassName,\n\t\tdisabled,\n\t\tid = undefined,\n\t\tlabel,\n\t\tonChange,\n\t\tselected = false,\n\t\t// destructured so it never reaches the nested input as an unknown DOM attribute,\n\t\t// and so the standalone switch doesn't emit a duplicate event.\n\t\teventId,\n\t\t...rest\n\t}: MrlSwitchProps) => {\n\t\tconst inputId = useMemo(() => id || getUniqueId('mrl-toggle-'), [id]);\n\t\tconst trackInteraction = useMrlTrackInteraction('MrlSwitch', eventId);\n\n\t\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\ttrackInteraction({ action: 'toggle', metadata: { selected: e.target.checked } });\n\n\t\t\tonChange(e);\n\t\t};\n\n\t\tconst textOnlyLabel = typeof label === 'string';\n\t\tconst containerClasses = classnames('MrlSwitch', styles['MrlSwitch'], className, {\n\t\t\t['mrl-label']: textOnlyLabel,\n\t\t\t[styles['MrlLabel']]: textOnlyLabel,\n\t\t\t['MrlSwitch-disabled']: disabled,\n\t\t\t[styles['MrlSwitch-disabled']]: disabled\n\t\t});\n\n\t\treturn (\n\t\t\t<label className={containerClasses}>\n\t\t\t\t{label}\n\t\t\t\t<MrlSwitchStandalone\n\t\t\t\t\t{...rest}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tid={inputId}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tselected={selected}\n\t\t\t\t/>\n\t\t\t</label>\n\t\t);\n\t}\n);\n\nMrlSwitch.displayName = 'MrlSwitch';\n"],"names":["MrlSwitch","memo","_ref","className","disabled","_ref$id","id","undefined","label","onChange","_ref$selected","selected","eventId","rest","_objectWithoutProperties","_excluded","inputId","useMemo","getUniqueId","trackInteraction","useMrlTrackInteraction","handleChange","e","action","metadata","target","checked","textOnlyLabel","containerClasses","classnames","styles","React","createElement","MrlSwitchStandalone","_extends","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MrlSwitch.js","sources":["../../../../../../src/components/form/switch/MrlSwitch/MrlSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { memo, useMemo } from 'react';\nimport { MrlSwitchStandalone } from '../MrlSwitchStandalone/MrlSwitchStandalone';\nimport { getUniqueId } from '../../../../utils';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\nimport styles from './MrlSwitch.module.scss';\n\ninterface MrlSwitchProps extends React.ComponentPropsWithoutRef<'input'> {\n\tclassName?: string;\n\t/** Disables the switch. */\n\tdisabled?: boolean;\n\tid?: string;\n\t/**\n\t * Enables interaction tracking for this switch. Provide a stable, non-PII id\n\t * (e.g. 'workspace-sso-toggle'). When omitted, the switch emits no analytics.\n\t */\n\teventId?: string;\n\t/**\n\t * The `label` is best used as a string, which will style according to MrlLabel styles.\n\t * If you need custom styles, you can use `className` or use a span that you style as `label`\n\t */\n\tlabel: string | React.ReactNode;\n\t/** Called with the change event when the switch is toggled. */\n\tonChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n\t/** Whether the switch is on. Syncs when this value changes; the switch also toggles itself on click. */\n\tselected?: boolean;\n}\n\nexport const MrlSwitch = memo(\n\t({\n\t\tclassName,\n\t\tdisabled,\n\t\tid = undefined,\n\t\tlabel,\n\t\tonChange,\n\t\tselected = false,\n\t\t// destructured so it never reaches the nested input as an unknown DOM attribute,\n\t\t// and so the standalone switch doesn't emit a duplicate event.\n\t\teventId,\n\t\t...rest\n\t}: MrlSwitchProps) => {\n\t\tconst inputId = useMemo(() => id || getUniqueId('mrl-toggle-'), [id]);\n\t\tconst trackInteraction = useMrlTrackInteraction('MrlSwitch', eventId);\n\n\t\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\ttrackInteraction({ action: 'toggle', metadata: { selected: e.target.checked } });\n\n\t\t\tonChange(e);\n\t\t};\n\n\t\tconst textOnlyLabel = typeof label === 'string';\n\t\tconst containerClasses = classnames('MrlSwitch', styles['MrlSwitch'], className, {\n\t\t\t['mrl-label']: textOnlyLabel,\n\t\t\t[styles['MrlLabel']]: textOnlyLabel,\n\t\t\t['MrlSwitch-disabled']: disabled,\n\t\t\t[styles['MrlSwitch-disabled']]: disabled\n\t\t});\n\n\t\treturn (\n\t\t\t<label className={containerClasses}>\n\t\t\t\t{label}\n\t\t\t\t<MrlSwitchStandalone\n\t\t\t\t\t{...rest}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\tid={inputId}\n\t\t\t\t\tonChange={handleChange}\n\t\t\t\t\tselected={selected}\n\t\t\t\t/>\n\t\t\t</label>\n\t\t);\n\t}\n);\n\nMrlSwitch.displayName = 'MrlSwitch';\n"],"names":["MrlSwitch","memo","_ref","className","disabled","_ref$id","id","undefined","label","onChange","_ref$selected","selected","eventId","rest","_objectWithoutProperties","_excluded","inputId","useMemo","getUniqueId","trackInteraction","useMrlTrackInteraction","handleChange","e","action","metadata","target","checked","textOnlyLabel","containerClasses","classnames","styles","React","createElement","MrlSwitchStandalone","_extends","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8BaA,SAAS,gBAAGC,UAAI,CAC5BC,IAAA,IAWsB;AAAA,EAAA,IAVrBC,SAAS,GAAAD,IAAA,CAATC,SAAS;IACTC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAAC,OAAA,GAAAH,IAAA,CACRI,EAAE;AAAFA,IAAAA,EAAE,GAAAD,OAAA,KAAA,MAAA,GAAGE,SAAS,GAAAF,OAAA;IACdG,KAAK,GAAAN,IAAA,CAALM,KAAK;IACLC,QAAQ,GAAAP,IAAA,CAARO,QAAQ;IAAAC,aAAA,GAAAR,IAAA,CACRS,QAAQ;AAARA,IAAAA,QAAQ,GAAAD,aAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,aAAA;IAGhBE,OAAO,GAAAV,IAAA,CAAPU,OAAO;AACJC,IAAAA,IAAI,GAAAC,iDAAA,CAAAZ,IAAA,EAAAa,SAAA,CAAA;AAEP,EAAA,IAAMC,OAAO,GAAGC,aAAO,CAAC,MAAMX,EAAE,IAAIY,yBAAW,CAAC,aAAa,CAAC,EAAE,CAACZ,EAAE,CAAC,CAAC;AACrE,EAAA,IAAMa,gBAAgB,GAAGC,sCAAsB,CAAC,WAAW,EAAER,OAAO,CAAC;EAErE,IAAMS,YAAY,GAAIC,CAAsC,IAAK;AAChEH,IAAAA,gBAAgB,CAAC;AAAEI,MAAAA,MAAM,EAAE,QAAQ;AAAEC,MAAAA,QAAQ,EAAE;AAAEb,QAAAA,QAAQ,EAAEW,CAAC,CAACG,MAAM,CAACC;AAAQ;AAAE,KAAC,CAAC;IAEhFjB,QAAQ,CAACa,CAAC,CAAC;EACZ,CAAC;AAED,EAAA,IAAMK,aAAa,GAAG,OAAOnB,KAAK,KAAK,QAAQ;AAC/C,EAAA,IAAMoB,gBAAgB,GAAGC,2BAAU,CAAC,WAAW,EAAEC,wBAAM,CAAC,WAAW,CAAC,EAAE3B,SAAS,EAAE;IAChF,CAAC,WAAW,GAAGwB,aAAa;AAC5B,IAAA,CAACG,wBAAM,CAAC,UAAU,CAAC,GAAGH,aAAa;IACnC,CAAC,oBAAoB,GAAGvB,QAAQ;AAChC,IAAA,CAAC0B,wBAAM,CAAC,oBAAoB,CAAC,GAAG1B;AACjC,GAAC,CAAC;EAEF,oBACC2B,gBAAA,CAAAC,aAAA,CAAA,OAAA,EAAA;AAAO7B,IAAAA,SAAS,EAAEyB;GAAiB,EACjCpB,KAAK,eACNuB,gBAAA,CAAAC,aAAA,CAACC,uCAAmB,EAAAC,iCAAA,CAAA,EAAA,EACfrB,IAAI,EAAA;AACRT,IAAAA,QAAQ,EAAEA,QAAS;AACnBE,IAAAA,EAAE,EAAEU,OAAQ;AACZP,IAAAA,QAAQ,EAAEY,YAAa;AACvBV,IAAAA,QAAQ,EAAEA;AAAS,GAAA,CACnB,CACK,CAAC;AAEV,CACD;AAEAX,SAAS,CAACmC,WAAW,GAAG,WAAW;;;;"}
|
package/dist/cjs/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlEditableTextInput.js","sources":["../../../../../../src/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { InputStates, MrlFormInputError } from '../../constants';\nimport { edit, error as errorIcon } from '@muraldevkit/ds-icons';\nimport styles from './MrlEditableTextInput.module.scss';\nimport './MrlEditableTextInput.global.scss';\nimport { useActiveColor } from '../../hooks/useActiveColor';\nimport { useIsEditable } from '../../hooks/useIsEditable';\nimport { MrlEditableTextInputRightButton } from './MrlEditableTextInputRightIcon';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlEditableTextInputProps extends React.InputHTMLAttributes<HTMLInputElement> {\n\t/** Id of the text input */\n\tinputId: string;\n\t/**\n\t * \tValue of the label text assigned to the input.\n\t * This is used to describe to the user what field they will be editing when interacting with the edit buton.\n\t */\n\tinputLabelText: string;\n\t/** The value of the text input 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/** Text placeholder for the text input */\n\tplaceholder?: string;\n\t/**\n\t * Changes the state of the input based on user permissions or actions.\n\t */\n\tstate?: InputStates;\n\terror?: MrlFormInputError;\n\t'data-qa': string;\n\t/* Expost isEditable and setIsEditable as optionally controlled state */\n\tisEditable?: boolean;\n\tsetIsEditable?: (isEditableUpdate: boolean) => void;\n\n\t/**\n\t * Show icon on hover, if true the icon will be hidden and show on hover and focus\n\t * @default false\n\t */\n\tshowIconOnHover?: boolean;\n\n\t/**\n\t * Enables interaction tracking for this input. Provide a stable, non-PII id\n\t * (e.g. 'mural-title'). When omitted, the input emits no analytics.\n\t *\n\t * Note: the input'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\nexport const MrlEditableTextInput = React.forwardRef<HTMLButtonElement, MrlEditableTextInputProps>(\n\tfunction MrlEditiableTextInput(\n\t\tprops: MrlEditableTextInputProps,\n\t\tref: React.Ref<HTMLButtonElement>\n\t): JSX.Element {\n\t\tconst {\n\t\t\tinputId,\n\t\t\tmaxLength,\n\t\t\tplaceholder,\n\t\t\tstate,\n\t\t\tvalue,\n\t\t\terror,\n\t\t\tisEditable: controlledIsEditable,\n\t\t\tsetIsEditable: controlledIsEditableUpdate,\n\t\t\tshowIconOnHover = false,\n\t\t\tinputLabelText,\n\t\t\teventId,\n\t\t\t...attrs\n\t\t} = props;\n\t\t// html id to be reference by input and error description to relay the error for a specific input\n\t\tconst describedById = `${inputId}-description`;\n\t\tconst textInputRef = React.useRef<HTMLInputElement>(null);\n\t\tconst iconRef = React.useRef<HTMLButtonElement>(null);\n\t\t// the value when the field gained focus, so `change` can be emitted once per\n\t\t// editing session instead of once per keystroke.\n\t\tconst valueOnFocusRef = React.useRef<string>('');\n\n\t\tconst trackInteraction = useMrlTrackInteraction('MrlEditableTextInput', eventId);\n\n\t\tconst { hasActiveColor, setHasActiveColor } = useActiveColor(state);\n\t\tconst { isEditable, isEditing, setIsEditable, setIsEditing } = useIsEditable({\n\t\t\tchangeHandler: controlledIsEditableUpdate,\n\t\t\tinitialValue: false,\n\t\t\tstate,\n\t\t\tvalue: controlledIsEditable\n\t\t});\n\n\t\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\t\tref,\n\t\t\t() => iconRef.current\n\t\t);\n\n\t\tconst unlockInput = React.useCallback(() => {\n\t\t\ttrackInteraction({ action: 'edit' });\n\n\t\t\tsetIsEditable(true);\n\t\t\tsetIsEditing(true);\n\t\t}, [setIsEditable, setIsEditing, trackInteraction]);\n\n\t\tconst lockInput = React.useCallback(() => {\n\t\t\tsetIsEditable(false);\n\t\t\tsetIsEditing(false);\n\t\t}, [setIsEditable, setIsEditing]);\n\t\tconst handleOnClick = (e: React.MouseEvent<HTMLInputElement>) => {\n\t\t\tif (!isEditable && !isEditing) {\n\t\t\t\tunlockInput();\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Only to be executed if onClick is provided as a prop\n\t\t\t */\n\t\t\tif (typeof attrs.onClick === 'function') {\n\t\t\t\tattrs.onClick(e);\n\t\t\t}\n\t\t};\n\n\t\tconst handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n\t\t\tconst { key } = event;\n\n\t\t\t// Selects the item on enter or spacebar and closes the select\n\t\t\tif (key === 'Escape') {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tevent.preventDefault();\n\t\t\t\tlockInput();\n\t\t\t\ticonRef.current?.focus();\n\t\t\t}\n\n\t\t\tif (typeof attrs.onKeyDown === 'function') {\n\t\t\t\tattrs.onKeyDown(event);\n\t\t\t}\n\t\t};\n\n\t\tconst handleOnBlur = React.useCallback(\n\t\t\t(e: React.FocusEvent<HTMLInputElement>) => {\n\t\t\t\tsetHasActiveColor(false);\n\t\t\t\tlockInput();\n\n\t\t\t\t// the value itself is never emitted — only the fact that it changed.\n\t\t\t\tif (e.target.value !== valueOnFocusRef.current) {\n\t\t\t\t\ttrackInteraction({ action: 'change' });\n\t\t\t\t}\n\n\t\t\t\tif (typeof attrs.onBlur === 'function') {\n\t\t\t\t\tattrs.onBlur(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor, lockInput, trackInteraction]\n\t\t);\n\n\t\tconst handleOnFocus = React.useCallback(\n\t\t\t(e: React.FocusEvent<HTMLInputElement>) => {\n\t\t\t\tsetHasActiveColor(true);\n\t\t\t\tvalueOnFocusRef.current = e.target.value;\n\n\t\t\t\tif (typeof attrs.onFocus === 'function') {\n\t\t\t\t\tattrs.onFocus(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tconst handleOnMouseEnter = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLInputElement>) => {\n\t\t\t\tsetHasActiveColor(true);\n\t\t\t\tif (typeof attrs.onMouseEnter === 'function') {\n\t\t\t\t\tattrs.onMouseEnter(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tconst handleOnMouseLeave = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLInputElement>) => {\n\t\t\t\tsetHasActiveColor(false);\n\t\t\t\tif (typeof attrs.onMouseLeave === 'function') {\n\t\t\t\t\tattrs.onMouseLeave(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tReact.useEffect(() => {\n\t\t\tif (iconRef.current) {\n\t\t\t\tif (attrs.autoFocus) {\n\t\t\t\t\ticonRef.current.focus();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// it should only run on the first render\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, []);\n\n\t\tReact.useEffect(() => {\n\t\t\t// when editiable changes focus to current thingy\n\t\t\tif (isEditable && textInputRef.current) {\n\t\t\t\ttextInputRef.current.focus();\n\t\t\t}\n\t\t}, [isEditable, isEditing]);\n\n\t\tconst inputClasses = classnames(\n\t\t\t'MrlEditableTextInput',\n\t\t\tstyles['MrlEditableTextInput'],\n\t\t\tstyles['mrl-textInput'],\n\t\t\t{\n\t\t\t\t[styles['MrlEditableTextInput-errorMessage']]: state === 'error',\n\t\t\t\t[styles['MrlEditableTextInput-errorIcon']]: state === 'error',\n\t\t\t\t[styles['MrlEditableTextInput--dynamicIcon']]: state !== 'read-only',\n\t\t\t\t[styles['MrlEditableTextInput--readOnly']]: state === 'read-only',\n\t\t\t\t[styles['MrlEditableTextInput--active']]: hasActiveColor,\n\t\t\t\t// if an onClick property is provided, we need to apply the class that allows pointer events\n\t\t\t\t[styles['MrlEditableTextInput--allowOnClick']]: typeof attrs.onClick === 'function'\n\t\t\t},\n\t\t\tattrs.className\n\t\t);\n\n\t\tconst hasCounter = typeof maxLength !== 'undefined' && Number(maxLength) > 0;\n\t\tif (hasCounter && isNaN(Number(maxLength))) {\n\t\t\tthrow new Error('maxLength should have type number');\n\t\t}\n\n\t\tconst hasErrorMessage = state === 'error' && error?.message;\n\n\t\t// do not pass class info to child elements/components\n\t\tdelete attrs.className;\n\n\t\tconst iconClasses = classnames(\n\t\t\t'MrlEditableTextInput-right-button',\n\t\t\tstyles['MrlEditableTextInput-right-button'],\n\t\t\t{\n\t\t\t\t[styles['MrlEditableTextInput-hover-button']]: showIconOnHover\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlEditableTextInput--wrapper'],\n\t\t\t\t\t\t'MrlEditableTextInput--wrapper'\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t{...attrs}\n\t\t\t\t\t\tonClick={handleOnClick}\n\t\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\t\taria-describedby={hasErrorMessage ? describedById : undefined}\n\t\t\t\t\t\tclassName={inputClasses}\n\t\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\t\tmaxLength={hasCounter ? maxLength : undefined}\n\t\t\t\t\t\tonBlur={handleOnBlur}\n\t\t\t\t\t\tonFocus={handleOnFocus}\n\t\t\t\t\t\tonMouseEnter={handleOnMouseEnter}\n\t\t\t\t\t\tonMouseLeave={handleOnMouseLeave}\n\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\treadOnly={state === 'read-only' || !isEditable}\n\t\t\t\t\t\ttabIndex={!isEditable ? -1 : 0}\n\t\t\t\t\t\tref={textInputRef}\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t/>\n\t\t\t\t\t{state !== 'read-only' && state !== 'disabled' && (\n\t\t\t\t\t\t<span className={iconClasses}>\n\t\t\t\t\t\t\t<MrlEditableTextInputRightButton\n\t\t\t\t\t\t\t\taction={unlockInput}\n\t\t\t\t\t\t\t\ticon={edit}\n\t\t\t\t\t\t\t\tlabel={`Edit: ${inputLabelText || inputId}`}\n\t\t\t\t\t\t\t\tdataQa={attrs['data-qa'] && `${attrs['data-qa']}-edit`}\n\t\t\t\t\t\t\t\thasActiveColor={hasActiveColor || isEditable}\n\t\t\t\t\t\t\t\tsetHasActiveColor={setHasActiveColor}\n\t\t\t\t\t\t\t\tref={iconRef}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{hasCounter && (\n\t\t\t\t\t<span className={styles['MrlForm-counter']}>\n\t\t\t\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t\t\t\t{value?.length || 0}/{maxLength}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<p style={{ display: 'none' }} id={`${inputId}-counter`}>\n\t\t\t\t\t\t\t{`${maxLength - (value?.length || 0)} of ${maxLength} characters remaining`}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{hasErrorMessage && (\n\t\t\t\t\t<span className={styles['MrlEditableTextInput-errorMessage']}>\n\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\tclassName={styles['MrlEditableTextInput-errorIcon']}\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tsvg={errorIcon}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span id={describedById}>{`${error?.message}`}</span>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</>\n\t\t);\n\t}\n);\n"],"names":["MrlEditableTextInput","React","forwardRef","MrlEditiableTextInput","props","ref","inputId","maxLength","placeholder","state","value","error","controlledIsEditable","isEditable","controlledIsEditableUpdate","setIsEditable","_props$showIconOnHove","showIconOnHover","inputLabelText","eventId","attrs","_objectWithoutProperties","_excluded","describedById","concat","textInputRef","useRef","iconRef","valueOnFocusRef","trackInteraction","useMrlTrackInteraction","_useActiveColor","useActiveColor","hasActiveColor","setHasActiveColor","_useIsEditable","useIsEditable","changeHandler","initialValue","isEditing","setIsEditing","useImperativeHandle","current","unlockInput","useCallback","action","lockInput","handleOnClick","e","onClick","handleKeyDown","event","key","_iconRef$current","stopPropagation","preventDefault","focus","onKeyDown","handleOnBlur","target","onBlur","handleOnFocus","onFocus","handleOnMouseEnter","onMouseEnter","handleOnMouseLeave","onMouseLeave","useEffect","autoFocus","inputClasses","classnames","styles","className","hasCounter","Number","isNaN","Error","hasErrorMessage","message","iconClasses","createElement","Fragment","_extends","type","undefined","disabled","id","readOnly","tabIndex","MrlEditableTextInputRightButton","icon","edit","label","dataQa","length","style","display","MrlSvg","svg","errorIcon","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDO,IAAMA,oBAAoB,gBAAGC,gBAAK,CAACC,UAAU,CACnD,SAASC,qBAAqBA,CAC7BC,KAAgC,EAChCC,GAAiC,EACnB;AACd,EAAA,IACCC,OAAO,GAYJF,KAAK,CAZRE,OAAO;IACPC,SAAS,GAWNH,KAAK,CAXRG,SAAS;IACTC,WAAW,GAURJ,KAAK,CAVRI,WAAW;IACXC,KAAK,GASFL,KAAK,CATRK,KAAK;IACLC,KAAK,GAQFN,KAAK,CARRM,KAAK;IACLC,KAAK,GAOFP,KAAK,CAPRO,KAAK;IACOC,oBAAoB,GAM7BR,KAAK,CANRS,UAAU;IACKC,0BAA0B,GAKtCV,KAAK,CALRW,aAAa;IAAAC,qBAAA,GAKVZ,KAAK,CAJRa,eAAe;AAAfA,IAAAA,eAAe,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;IACvBE,cAAc,GAGXd,KAAK,CAHRc,cAAc;IACdC,OAAO,GAEJf,KAAK,CAFRe,OAAO;AACJC,IAAAA,KAAK,GAAAC,iDAAA,CACLjB,KAAK,EAAAkB,SAAA,CAAA;AACT;AACA,EAAA,IAAMC,aAAa,GAAA,EAAA,CAAAC,MAAA,CAAMlB,OAAO,EAAA,cAAA,CAAc;AAC9C,EAAA,IAAMmB,YAAY,GAAGxB,gBAAK,CAACyB,MAAM,CAAmB,IAAI,CAAC;AACzD,EAAA,I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AAE;KAAS;IAACV,EAAE,EAAA,EAAA,CAAA9D,MAAA,CAAKlB,OAAO,EAAA,UAAA;GAAW,EAAA,EAAA,CAAAkB,MAAA,CACnDjB,SAAS,IAAI,CAAAG,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAEoF,MAAM,KAAI,CAAC,CAAC,EAAA,MAAA,CAAA,CAAAtE,MAAA,CAAOjB,SAAS,EAAA,uBAAA,CAClD,CACE,CACN,EACAsE,eAAe,iBACf5E,gBAAA,CAAA+E,aAAA,CAAA,MAAA,EAAA;IAAMR,SAAS,EAAED,mCAAM,CAAC,mCAAmC;AAAE,GAAA,eAC5DtE,gBAAA,CAAA+E,aAAA,CAACiB,aAAM,EAAA;AACNzB,IAAAA,SAAS,EAAED,mCAAM,CAAC,gCAAgC,CAAE;AACpD,IAAA,aAAA,EAAY,MAAM;AAClB2B,IAAAA,GAAG,EAAEC,aAAU;AACfC,IAAAA,IAAI,EAAC;AAAO,GACZ,CAAC,eACFnG,gBAAA,CAAA+E,aAAA,CAAA,MAAA,EAAA;AAAMM,IAAAA,EAAE,EAAE/D;AAAc,GAAA,EAAA,EAAA,CAAAC,MAAA,CAAKb,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAEmE,OAAO,CAAS,CAC/C,CAEN,CAAC;AAEL,CACD;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlEditableTextInput.js","sources":["../../../../../../src/components/form/text-input/MrlEditableTextInput/MrlEditableTextInput.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { InputStates, MrlFormInputError } from '../../constants';\nimport { edit, error as errorIcon } from '@muraldevkit/ds-icons';\nimport styles from './MrlEditableTextInput.module.scss';\nimport './MrlEditableTextInput.global.scss';\nimport { useActiveColor } from '../../hooks/useActiveColor';\nimport { useIsEditable } from '../../hooks/useIsEditable';\nimport { MrlEditableTextInputRightButton } from './MrlEditableTextInputRightIcon';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlEditableTextInputProps extends React.InputHTMLAttributes<HTMLInputElement> {\n\t/** Id of the text input */\n\tinputId: string;\n\t/**\n\t * \tValue of the label text assigned to the input.\n\t * This is used to describe to the user what field they will be editing when interacting with the edit buton.\n\t */\n\tinputLabelText: string;\n\t/** The value of the text input 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/** Text placeholder for the text input */\n\tplaceholder?: string;\n\t/**\n\t * Changes the state of the input based on user permissions or actions.\n\t */\n\tstate?: InputStates;\n\t/** Error shown under the field when `state` is 'error'. */\n\terror?: MrlFormInputError;\n\t'data-qa': string;\n\t/** Whether the field is in edit mode. Omit to let the component manage it; pair with `setIsEditable` to control it. */\n\tisEditable?: boolean;\n\t/** Called when the field wants to enter or leave edit mode. Required when `isEditable` is controlled. */\n\tsetIsEditable?: (isEditableUpdate: boolean) => void;\n\n\t/**\n\t * Show icon on hover, if true the icon will be hidden and show on hover and focus\n\t * @default false\n\t */\n\tshowIconOnHover?: boolean;\n\n\t/**\n\t * Enables interaction tracking for this input. Provide a stable, non-PII id\n\t * (e.g. 'mural-title'). When omitted, the input emits no analytics.\n\t *\n\t * Note: the input'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\nexport const MrlEditableTextInput = React.forwardRef<HTMLButtonElement, MrlEditableTextInputProps>(\n\tfunction MrlEditiableTextInput(\n\t\tprops: MrlEditableTextInputProps,\n\t\tref: React.Ref<HTMLButtonElement>\n\t): JSX.Element {\n\t\tconst {\n\t\t\tinputId,\n\t\t\tmaxLength,\n\t\t\tplaceholder,\n\t\t\tstate,\n\t\t\tvalue,\n\t\t\terror,\n\t\t\tisEditable: controlledIsEditable,\n\t\t\tsetIsEditable: controlledIsEditableUpdate,\n\t\t\tshowIconOnHover = false,\n\t\t\tinputLabelText,\n\t\t\teventId,\n\t\t\t...attrs\n\t\t} = props;\n\t\t// html id to be reference by input and error description to relay the error for a specific input\n\t\tconst describedById = `${inputId}-description`;\n\t\tconst textInputRef = React.useRef<HTMLInputElement>(null);\n\t\tconst iconRef = React.useRef<HTMLButtonElement>(null);\n\t\t// the value when the field gained focus, so `change` can be emitted once per\n\t\t// editing session instead of once per keystroke.\n\t\tconst valueOnFocusRef = React.useRef<string>('');\n\n\t\tconst trackInteraction = useMrlTrackInteraction('MrlEditableTextInput', eventId);\n\n\t\tconst { hasActiveColor, setHasActiveColor } = useActiveColor(state);\n\t\tconst { isEditable, isEditing, setIsEditable, setIsEditing } = useIsEditable({\n\t\t\tchangeHandler: controlledIsEditableUpdate,\n\t\t\tinitialValue: false,\n\t\t\tstate,\n\t\t\tvalue: controlledIsEditable\n\t\t});\n\n\t\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\t\tref,\n\t\t\t() => iconRef.current\n\t\t);\n\n\t\tconst unlockInput = React.useCallback(() => {\n\t\t\ttrackInteraction({ action: 'edit' });\n\n\t\t\tsetIsEditable(true);\n\t\t\tsetIsEditing(true);\n\t\t}, [setIsEditable, setIsEditing, trackInteraction]);\n\n\t\tconst lockInput = React.useCallback(() => {\n\t\t\tsetIsEditable(false);\n\t\t\tsetIsEditing(false);\n\t\t}, [setIsEditable, setIsEditing]);\n\t\tconst handleOnClick = (e: React.MouseEvent<HTMLInputElement>) => {\n\t\t\tif (!isEditable && !isEditing) {\n\t\t\t\tunlockInput();\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Only to be executed if onClick is provided as a prop\n\t\t\t */\n\t\t\tif (typeof attrs.onClick === 'function') {\n\t\t\t\tattrs.onClick(e);\n\t\t\t}\n\t\t};\n\n\t\tconst handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n\t\t\tconst { key } = event;\n\n\t\t\t// Selects the item on enter or spacebar and closes the select\n\t\t\tif (key === 'Escape') {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tevent.preventDefault();\n\t\t\t\tlockInput();\n\t\t\t\ticonRef.current?.focus();\n\t\t\t}\n\n\t\t\tif (typeof attrs.onKeyDown === 'function') {\n\t\t\t\tattrs.onKeyDown(event);\n\t\t\t}\n\t\t};\n\n\t\tconst handleOnBlur = React.useCallback(\n\t\t\t(e: React.FocusEvent<HTMLInputElement>) => {\n\t\t\t\tsetHasActiveColor(false);\n\t\t\t\tlockInput();\n\n\t\t\t\t// the value itself is never emitted — only the fact that it changed.\n\t\t\t\tif (e.target.value !== valueOnFocusRef.current) {\n\t\t\t\t\ttrackInteraction({ action: 'change' });\n\t\t\t\t}\n\n\t\t\t\tif (typeof attrs.onBlur === 'function') {\n\t\t\t\t\tattrs.onBlur(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor, lockInput, trackInteraction]\n\t\t);\n\n\t\tconst handleOnFocus = React.useCallback(\n\t\t\t(e: React.FocusEvent<HTMLInputElement>) => {\n\t\t\t\tsetHasActiveColor(true);\n\t\t\t\tvalueOnFocusRef.current = e.target.value;\n\n\t\t\t\tif (typeof attrs.onFocus === 'function') {\n\t\t\t\t\tattrs.onFocus(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tconst handleOnMouseEnter = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLInputElement>) => {\n\t\t\t\tsetHasActiveColor(true);\n\t\t\t\tif (typeof attrs.onMouseEnter === 'function') {\n\t\t\t\t\tattrs.onMouseEnter(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tconst handleOnMouseLeave = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLInputElement>) => {\n\t\t\t\tsetHasActiveColor(false);\n\t\t\t\tif (typeof attrs.onMouseLeave === 'function') {\n\t\t\t\t\tattrs.onMouseLeave(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tReact.useEffect(() => {\n\t\t\tif (iconRef.current) {\n\t\t\t\tif (attrs.autoFocus) {\n\t\t\t\t\ticonRef.current.focus();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// it should only run on the first render\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, []);\n\n\t\tReact.useEffect(() => {\n\t\t\t// when editiable changes focus to current thingy\n\t\t\tif (isEditable && textInputRef.current) {\n\t\t\t\ttextInputRef.current.focus();\n\t\t\t}\n\t\t}, [isEditable, isEditing]);\n\n\t\tconst inputClasses = classnames(\n\t\t\t'MrlEditableTextInput',\n\t\t\tstyles['MrlEditableTextInput'],\n\t\t\tstyles['mrl-textInput'],\n\t\t\t{\n\t\t\t\t[styles['MrlEditableTextInput-errorMessage']]: state === 'error',\n\t\t\t\t[styles['MrlEditableTextInput-errorIcon']]: state === 'error',\n\t\t\t\t[styles['MrlEditableTextInput--dynamicIcon']]: state !== 'read-only',\n\t\t\t\t[styles['MrlEditableTextInput--readOnly']]: state === 'read-only',\n\t\t\t\t[styles['MrlEditableTextInput--active']]: hasActiveColor,\n\t\t\t\t// if an onClick property is provided, we need to apply the class that allows pointer events\n\t\t\t\t[styles['MrlEditableTextInput--allowOnClick']]: typeof attrs.onClick === 'function'\n\t\t\t},\n\t\t\tattrs.className\n\t\t);\n\n\t\tconst hasCounter = typeof maxLength !== 'undefined' && Number(maxLength) > 0;\n\t\tif (hasCounter && isNaN(Number(maxLength))) {\n\t\t\tthrow new Error('maxLength should have type number');\n\t\t}\n\n\t\tconst hasErrorMessage = state === 'error' && error?.message;\n\n\t\t// do not pass class info to child elements/components\n\t\tdelete attrs.className;\n\n\t\tconst iconClasses = classnames(\n\t\t\t'MrlEditableTextInput-right-button',\n\t\t\tstyles['MrlEditableTextInput-right-button'],\n\t\t\t{\n\t\t\t\t[styles['MrlEditableTextInput-hover-button']]: showIconOnHover\n\t\t\t}\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div\n\t\t\t\t\tclassName={classnames(\n\t\t\t\t\t\tstyles['MrlEditableTextInput--wrapper'],\n\t\t\t\t\t\t'MrlEditableTextInput--wrapper'\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t{...attrs}\n\t\t\t\t\t\tonClick={handleOnClick}\n\t\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\t\taria-describedby={hasErrorMessage ? describedById : undefined}\n\t\t\t\t\t\tclassName={inputClasses}\n\t\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\t\tmaxLength={hasCounter ? maxLength : undefined}\n\t\t\t\t\t\tonBlur={handleOnBlur}\n\t\t\t\t\t\tonFocus={handleOnFocus}\n\t\t\t\t\t\tonMouseEnter={handleOnMouseEnter}\n\t\t\t\t\t\tonMouseLeave={handleOnMouseLeave}\n\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\treadOnly={state === 'read-only' || !isEditable}\n\t\t\t\t\t\ttabIndex={!isEditable ? -1 : 0}\n\t\t\t\t\t\tref={textInputRef}\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t/>\n\t\t\t\t\t{state !== 'read-only' && state !== 'disabled' && (\n\t\t\t\t\t\t<span className={iconClasses}>\n\t\t\t\t\t\t\t<MrlEditableTextInputRightButton\n\t\t\t\t\t\t\t\taction={unlockInput}\n\t\t\t\t\t\t\t\ticon={edit}\n\t\t\t\t\t\t\t\tlabel={`Edit: ${inputLabelText || inputId}`}\n\t\t\t\t\t\t\t\tdataQa={attrs['data-qa'] && `${attrs['data-qa']}-edit`}\n\t\t\t\t\t\t\t\thasActiveColor={hasActiveColor || isEditable}\n\t\t\t\t\t\t\t\tsetHasActiveColor={setHasActiveColor}\n\t\t\t\t\t\t\t\tref={iconRef}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{hasCounter && (\n\t\t\t\t\t<span className={styles['MrlForm-counter']}>\n\t\t\t\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t\t\t\t{value?.length || 0}/{maxLength}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<p style={{ display: 'none' }} id={`${inputId}-counter`}>\n\t\t\t\t\t\t\t{`${maxLength - (value?.length || 0)} of ${maxLength} characters remaining`}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{hasErrorMessage && (\n\t\t\t\t\t<span className={styles['MrlEditableTextInput-errorMessage']}>\n\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\tclassName={styles['MrlEditableTextInput-errorIcon']}\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tsvg={errorIcon}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span id={describedById}>{`${error?.message}`}</span>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</>\n\t\t);\n\t}\n);\n"],"names":["MrlEditableTextInput","React","forwardRef","MrlEditiableTextInput","props","ref","inputId","maxLength","placeholder","state","value","error","controlledIsEditable","isEditable","controlledIsEditableUpdate","setIsEditable","_props$showIconOnHove","showIconOnHover","inputLabelText","eventId","attrs","_objectWithoutProperties","_excluded","describedById","concat","textInputRef","useRef","iconRef","valueOnFocusRef","trackInteraction","useMrlTrackInteraction","_useActiveColor","useActiveColor","hasActiveColor","setHasActiveColor","_useIsEditable","useIsEditable","changeHandler","initialValue","isEditing","setIsEditing","useImperativeHandle","current","unlockInput","useCallback","action","lockInput","handleOnClick","e","onClick","handleKeyDown","event","key","_iconRef$current","stopPropagation","preventDefault","focus","onKeyDown","handleOnBlur","target","onBlur","handleOnFocus","onFocus","handleOnMouseEnter","onMouseEnter","handleOnMouseLeave","onMouseLeave","useEffect","autoFocus","inputClasses","classnames","styles","className","hasCounter","Number","isNaN","Error","hasErrorMessage","message","iconClasses","createElement","Fragment","_extends","type","undefined","disabled","id","readOnly","tabIndex","MrlEditableTextInputRightButton","icon","edit","label","dataQa","length","style","display","MrlSvg","svg","errorIcon","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDO,IAAMA,oBAAoB,gBAAGC,gBAAK,CAACC,UAAU,CACnD,SAASC,qBAAqBA,CAC7BC,KAAgC,EAChCC,GAAiC,EACnB;AACd,EAAA,IACCC,OAAO,GAYJF,KAAK,CAZRE,OAAO;IACPC,SAAS,GAWNH,KAAK,CAXRG,SAAS;IACTC,WAAW,GAURJ,KAAK,CAVRI,WAAW;IACXC,KAAK,GASFL,KAAK,CATRK,KAAK;IACLC,KAAK,GAQFN,KAAK,CARRM,KAAK;IACLC,KAAK,GAOFP,KAAK,CAPRO,KAAK;IACOC,oBAAoB,GAM7BR,KAAK,CANRS,UAAU;IACKC,0BAA0B,GAKtCV,KAAK,CALRW,aAAa;IAAAC,qBAAA,GAKVZ,KAAK,CAJRa,eAAe;AAAfA,IAAAA,eAAe,GAAAD,qBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,qBAAA;IACvBE,cAAc,GAGXd,KAAK,CAHRc,cAAc;IACdC,OAAO,GAEJf,KAAK,CAFRe,OAAO;AACJC,IAAAA,KAAK,GAAAC,iDAAA,CACLjB,KAAK,EAAAkB,SAAA,CAAA;AACT;AACA,EAAA,IAAMC,aAAa,GAAA,EAAA,CAAAC,MAAA,CAAMlB,OAAO,EAAA,cAAA,CAAc;AAC9C,EAAA,IAAMmB,YAAY,GAAGxB,gBAAK,CAACyB,MAAM,CAAmB,IAAI,CAAC;AACzD,EAAA,IAAMC,OAAO,GAAG1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AAE,EAAA,EAAA,CAAA9D,MAAA,CAAKlB,OAAO,EAAA,UAAA;GAAW,EAAA,EAAA,CAAAkB,MAAA,CACnDjB,SAAS,IAAI,CAAAG,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAEoF,MAAM,KAAI,CAAC,CAAC,EAAA,MAAA,CAAA,CAAAtE,MAAA,CAAOjB,SAAS,EAAA,uBAAA,CAClD,CACE,CACN,EACAsE,eAAe,iBACf5E,gBAAA,CAAA+E,aAAA,CAAA,MAAA,EAAA;IAAMR,SAAS,EAAED,mCAAM,CAAC,mCAAmC;AAAE,GAAA,eAC5DtE,gBAAA,CAAA+E,aAAA,CAACiB,aAAM,EAAA;AACNzB,IAAAA,SAAS,EAAED,mCAAM,CAAC,gCAAgC,CAAE;AACpD,IAAA,aAAA,EAAY,MAAM;AAClB2B,IAAAA,GAAG,EAAEC,aAAU;AACfC,IAAAA,IAAI,EAAC;AAAO,GACZ,CAAC,eACFnG,gBAAA,CAAA+E,aAAA,CAAA,MAAA,EAAA;AAAMM,IAAAA,EAAE,EAAE/D;AAAc,GAAA,EAAA,EAAA,CAAAC,MAAA,CAAKb,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAEmE,OAAO,CAAS,CAC/C,CAEN,CAAC;AAEL,CACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlEditableTextarea.js","sources":["../../../../../../src/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { edit, error as errorIcon } from '@muraldevkit/ds-icons';\n\nimport styles from './MrlEditableTextarea.module.scss';\nimport './MrlEditableTextarea.global.scss';\nimport { useIsEditable } from '../../hooks/useIsEditable';\nimport { useActiveColor } from '../../hooks/useActiveColor';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { InputStates, MrlFormInputError } from '../../constants';\nimport { MrlEditableTextareaRightButton } from './MrlEditableTextareaRightButton';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlEditableTextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n\t/** The value of the textarea used to make it a controlled input */\n\tvalue: string;\n\t/**\n\t * \tValue of the label text assigned to the input.\n\t * This is used to describe to the user what field they will be editing when interacting with the edit buton.\n\t */\n\tinputLabelText: 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?: InputStates;\n\t/** Additional class to add to the textarea */\n\tclassName?: string;\n\t'data-qa': string;\n\terror?: MrlFormInputError;\n\t/* Expost isEditable and setIsEditable as optionally controlled state */\n\tisEditable?: boolean;\n\tsetIsEditable?: (isEditableUpdate: boolean) => void;\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. 'mural-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 {MrlEditableTextareaProps} props - the component props\n * @returns a textarea element\n */\nexport const MrlEditableTextarea = React.forwardRef<HTMLButtonElement, MrlEditableTextareaProps>(\n\tfunction MrlEditableTextarea(\n\t\tprops: MrlEditableTextareaProps,\n\t\tref: React.Ref<HTMLButtonElement>\n\t): JSX.Element {\n\t\tconst {\n\t\t\tautoExpand = false,\n\t\t\tclassName,\n\t\t\tinputId,\n\t\t\tinputLabelText,\n\t\t\tmaxLength,\n\t\t\tplaceholder,\n\t\t\tstate,\n\t\t\tvalue,\n\t\t\terror,\n\t\t\tisEditable: controlledIsEditable,\n\t\t\tsetIsEditable: controlledIsEditableUpdate,\n\t\t\teventId,\n\t\t\t...attrs\n\t\t} = props;\n\n\t\t// html id to be reference by input and error description to relay the error for a specific input\n\t\tconst describedById = `${inputId}-description`;\n\t\tconst textareaRef = React.useRef<HTMLTextAreaElement>(null);\n\t\tconst iconRef = React.useRef<HTMLButtonElement>(null);\n\t\t// the value when the field gained focus, so `change` can be emitted once per\n\t\t// editing session instead of once per keystroke.\n\t\tconst valueOnFocusRef = React.useRef<string>('');\n\n\t\tconst trackInteraction = useMrlTrackInteraction('MrlEditableTextarea', eventId);\n\n\t\tconst { hasActiveColor, setHasActiveColor } = useActiveColor(state);\n\t\tconst { isEditable, isEditing, setIsEditable, setIsEditing } = useIsEditable({\n\t\t\tchangeHandler: controlledIsEditableUpdate,\n\t\t\tinitialValue: false,\n\t\t\tstate,\n\t\t\tvalue: controlledIsEditable\n\t\t});\n\t\t// Allows us to track if the user has edited the input previously.\n\t\t// This helps conditionally focus the icon only when the user is done editing the input.\n\t\tconst [hasEdited, setHasEdited] = React.useState(false);\n\n\t\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\t\tref,\n\t\t\t() => iconRef.current\n\t\t);\n\n\t\tReact.useEffect(() => {\n\t\t\tif (iconRef.current && (attrs.autoFocus || hasEdited)) {\n\t\t\t\ticonRef.current.focus();\n\t\t\t}\n\t\t}, [attrs, iconRef, hasEdited]);\n\n\t\tReact.useEffect(() => {\n\t\t\tif (textareaRef.current) {\n\t\t\t\tif (isEditable) {\n\t\t\t\t\ttextareaRef.current.focus();\n\t\t\t\t} else {\n\t\t\t\t\ttextareaRef.current.style.height = 'auto';\n\t\t\t\t\tif (!textareaRef.current.value || textareaRef.current.value === '') {\n\t\t\t\t\t\ttextareaRef.current.style.height = '40px';\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttextareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, [isEditable, isEditing]);\n\n\t\tReact.useEffect(() => {\n\t\t\tif (!autoExpand || !textareaRef.current) return;\n\n\t\t\ttextareaRef.current.style.height = 'auto';\n\t\t\tif (!textareaRef.current.value || textareaRef.current.value === '') {\n\t\t\t\ttextareaRef.current.style.height = '40px';\n\t\t\t} else {\n\t\t\t\ttextareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\t\t\t}\n\t\t}, [autoExpand, value]);\n\n\t\tconst onKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n\t\t\tconst { key } = event;\n\n\t\t\tif (key === 'Escape') {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsEditable(false);\n\t\t\t\tsetIsEditing(false);\n\t\t\t}\n\t\t};\n\n\t\tconst handleOnBlur = React.useCallback(\n\t\t\t(e: React.FocusEvent<HTMLTextAreaElement>) => {\n\t\t\t\tsetHasActiveColor(false);\n\t\t\t\tsetIsEditable(false);\n\t\t\t\tsetIsEditing(false);\n\t\t\t\tsetHasEdited(false);\n\n\t\t\t\t// the value itself is never emitted — only the fact that it changed.\n\t\t\t\tif (e.target.value !== valueOnFocusRef.current) {\n\t\t\t\t\ttrackInteraction({ action: 'change' });\n\t\t\t\t}\n\n\t\t\t\tif (typeof attrs.onBlur === 'function') {\n\t\t\t\t\tattrs.onBlur(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor, setIsEditable, setIsEditing, trackInteraction]\n\t\t);\n\n\t\tconst handleOnFocus = React.useCallback(\n\t\t\t(e: React.FocusEvent<HTMLTextAreaElement>) => {\n\t\t\t\tsetHasActiveColor(true);\n\t\t\t\tsetIsEditable(true);\n\t\t\t\tsetIsEditing(true);\n\t\t\t\tsetHasEdited(true);\n\t\t\t\tvalueOnFocusRef.current = e.target.value;\n\n\t\t\t\tif (typeof attrs.onFocus === 'function') {\n\t\t\t\t\tattrs.onFocus(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor, setIsEditable, setIsEditing]\n\t\t);\n\n\t\tconst handleOnMouseEnter = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLTextAreaElement>) => {\n\t\t\t\tsetHasActiveColor(true);\n\t\t\t\tif (typeof attrs.onMouseEnter === 'function') {\n\t\t\t\t\tattrs.onMouseEnter(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tconst handleOnMouseLeave = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLTextAreaElement>) => {\n\t\t\t\tsetHasActiveColor(false);\n\t\t\t\tif (typeof attrs.onMouseLeave === 'function') {\n\t\t\t\t\tattrs.onMouseLeave(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tconst onClickEdit = React.useCallback(() => {\n\t\t\ttrackInteraction({ action: 'edit' });\n\n\t\t\tsetIsEditable(true);\n\t\t\tsetIsEditing(true);\n\t\t\tsetHasEdited(true);\n\t\t}, [setIsEditable, setIsEditing, setHasEdited, trackInteraction]);\n\n\t\tconst hasCounter =\n\t\t\ttypeof maxLength !== 'undefined' && Number(maxLength) > 0 && state !== 'read-only';\n\n\t\tif (hasCounter && isNaN(Number(maxLength))) {\n\t\t\tthrow new Error('maxLength should have type number');\n\t\t}\n\n\t\tconst hasErrorMessage = state === 'error' && error?.message;\n\n\t\tconst inputClasses = classnames(\n\t\t\tclassName,\n\t\t\tstyles['MrlEditableTextarea'],\n\t\t\t{\n\t\t\t\t[styles['MrlEditableTextarea--readOnly']]: state === 'read-only'\n\t\t\t},\n\t\t\t'MrlEditableTextarea',\n\t\t\t'mrl-textarea'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div className={`${styles['MrlEditableTextarea--wrapper']} MrlEditableTextarea--wrapper`}>\n\t\t\t\t\t<textarea\n\t\t\t\t\t\t{...attrs}\n\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\tclassName={inputClasses}\n\t\t\t\t\t\tdefaultValue={value}\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\t\taria-describedby={hasErrorMessage ? describedById : undefined}\n\t\t\t\t\t\tonBlur={handleOnBlur}\n\t\t\t\t\t\tonFocus={handleOnFocus}\n\t\t\t\t\t\tonMouseEnter={handleOnMouseEnter}\n\t\t\t\t\t\tonMouseLeave={handleOnMouseLeave}\n\t\t\t\t\t\tonKeyDown={onKeyDown}\n\t\t\t\t\t\tmaxLength={hasCounter ? maxLength : undefined}\n\t\t\t\t\t\treadOnly={state === 'read-only' || !isEditable}\n\t\t\t\t\t\tref={textareaRef}\n\t\t\t\t\t\ttabIndex={!isEditable ? -1 : 0}\n\t\t\t\t\t/>\n\t\t\t\t\t{state !== 'read-only' && state !== 'disabled' && !isEditable && (\n\t\t\t\t\t\t<MrlEditableTextareaRightButton\n\t\t\t\t\t\t\taction={onClickEdit}\n\t\t\t\t\t\t\ticon={edit}\n\t\t\t\t\t\t\tlabel={`Edit ${inputLabelText}`}\n\t\t\t\t\t\t\tdataQa={attrs['data-qa'] && `${attrs['data-qa']}-edit`}\n\t\t\t\t\t\t\thasActiveColor={hasActiveColor || isEditable}\n\t\t\t\t\t\t\tsetHasActiveColor={setHasActiveColor}\n\t\t\t\t\t\t\tref={iconRef}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{hasCounter && isEditable && (\n\t\t\t\t\t<span className={styles['MrlForm-counter']}>\n\t\t\t\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t\t\t\t{value?.length || 0}/{maxLength}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<p style={{ display: 'none' }} aria-live=\"polite\" id={`${inputId}-counter`}>\n\t\t\t\t\t\t\t{`${maxLength - (value?.length || 0)} of ${maxLength} characters remaining`}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{state === 'error' && error?.message && (\n\t\t\t\t\t<span className={styles['MrlEditableTextarea-errorMessage']}>\n\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\tclassName={styles['MrlEditableTextarea-errorIcon']}\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tsvg={errorIcon}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span id={describedById}>{`${error?.message}`}</span>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</>\n\t\t);\n\t}\n);\n"],"names":["MrlEditableTextarea","React","forwardRef","props","ref","_props$autoExpand","autoExpand","className","inputId","inputLabelText","maxLength","placeholder","state","value","error","controlledIsEditable","isEditable","controlledIsEditableUpdate","setIsEditable","eventId","attrs","_objectWithoutProperties","_excluded","describedById","concat","textareaRef","useRef","iconRef","valueOnFocusRef","trackInteraction","useMrlTrackInteraction","_useActiveColor","useActiveColor","hasActiveColor","setHasActiveColor","_useIsEditable","useIsEditable","changeHandler","initialValue","isEditing","setIsEditing","_React$useState","useState","_React$useState2","_slicedToArray","hasEdited","setHasEdited","useImperativeHandle","current","useEffect","autoFocus","focus","style","height","scrollHeight","onKeyDown","event","key","stopPropagation","preventDefault","handleOnBlur","useCallback","e","target","action","onBlur","handleOnFocus","onFocus","handleOnMouseEnter","onMouseEnter","handleOnMouseLeave","onMouseLeave","onClickEdit","hasCounter","Number","isNaN","Error","hasErrorMessage","message","inputClasses","classnames","styles","createElement","Fragment","_extends","id","defaultValue","disabled","undefined","readOnly","tabIndex","MrlEditableTextareaRightButton","icon","edit","label","dataQa","length","display","MrlSvg","svg","errorIcon","size"],"mappings":";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,EAAE,EAAA,EAAA,CAAA7D,MAAA,CAAKhB,OAAO,EAAA,UAAA;AAAW,GAAA,EAAA,EAAA,CAAAgB,MAAA,CACtEd,SAAS,IAAI,CAAAG,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAEmF,MAAM,KAAI,CAAC,CAAC,UAAAxE,MAAA,CAAOd,SAAS,EAAA,uBAAA,CAClD,CACE,CACN,EACAE,KAAK,KAAK,OAAO,KAAIE,KAAK,KAAA,IAAA,IAALA,KAAK,uBAALA,KAAK,CAAEgE,OAAO,CAAA,iBACnC7E,gBAAA,CAAAiF,aAAA,CAAA,MAAA,EAAA;IAAM3E,SAAS,EAAE0E,kCAAM,CAAC,kCAAkC;AAAE,GAAA,eAC3DhF,gBAAA,CAAAiF,aAAA,CAACgB,aAAM,EAAA;AACN3F,IAAAA,SAAS,EAAE0E,kCAAM,CAAC,+BAA+B,CAAE;AACnD,IAAA,aAAA,EAAY,MAAM;AAClBkB,IAAAA,GAAG,EAAEC,aAAU;AACfC,IAAAA,IAAI,EAAC;AAAO,GACZ,CAAC,eACFpG,gBAAA,CAAAiF,aAAA,CAAA,MAAA,EAAA;AAAMG,IAAAA,EAAE,EAAE9D;AAAc,GAAA,EAAA,EAAA,CAAAC,MAAA,CAAKV,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAEgE,OAAO,CAAS,CAC/C,CAEN,CAAC;AAEL,CACD;;;;"}
|
|
1
|
+
{"version":3,"file":"MrlEditableTextarea.js","sources":["../../../../../../src/components/form/textarea/MrlEditableTextarea/MrlEditableTextarea.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { edit, error as errorIcon } from '@muraldevkit/ds-icons';\n\nimport styles from './MrlEditableTextarea.module.scss';\nimport './MrlEditableTextarea.global.scss';\nimport { useIsEditable } from '../../hooks/useIsEditable';\nimport { useActiveColor } from '../../hooks/useActiveColor';\nimport { MrlSvg } from '../../../svg/MrlSvg/MrlSvg';\nimport { InputStates, MrlFormInputError } from '../../constants';\nimport { MrlEditableTextareaRightButton } from './MrlEditableTextareaRightButton';\nimport { useMrlTrackInteraction } from '../../../../hooks/useMrlAnalytics';\n\ninterface MrlEditableTextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n\t/** The value of the textarea used to make it a controlled input */\n\tvalue: string;\n\t/**\n\t * \tValue of the label text assigned to the input.\n\t * This is used to describe to the user what field they will be editing when interacting with the edit buton.\n\t */\n\tinputLabelText: 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?: InputStates;\n\t/** Additional class to add to the textarea */\n\tclassName?: string;\n\t'data-qa': string;\n\t/** Error shown under the field when `state` is 'error'. */\n\terror?: MrlFormInputError;\n\t/** Whether the field is in edit mode. Omit to let the component manage it; pair with `setIsEditable` to control it. */\n\tisEditable?: boolean;\n\t/** Called when the field wants to enter or leave edit mode. Required when `isEditable` is controlled. */\n\tsetIsEditable?: (isEditableUpdate: boolean) => void;\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. 'mural-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 {MrlEditableTextareaProps} props - the component props\n * @returns a textarea element\n */\nexport const MrlEditableTextarea = React.forwardRef<HTMLButtonElement, MrlEditableTextareaProps>(\n\tfunction MrlEditableTextarea(\n\t\tprops: MrlEditableTextareaProps,\n\t\tref: React.Ref<HTMLButtonElement>\n\t): JSX.Element {\n\t\tconst {\n\t\t\tautoExpand = false,\n\t\t\tclassName,\n\t\t\tinputId,\n\t\t\tinputLabelText,\n\t\t\tmaxLength,\n\t\t\tplaceholder,\n\t\t\tstate,\n\t\t\tvalue,\n\t\t\terror,\n\t\t\tisEditable: controlledIsEditable,\n\t\t\tsetIsEditable: controlledIsEditableUpdate,\n\t\t\teventId,\n\t\t\t...attrs\n\t\t} = props;\n\n\t\t// html id to be reference by input and error description to relay the error for a specific input\n\t\tconst describedById = `${inputId}-description`;\n\t\tconst textareaRef = React.useRef<HTMLTextAreaElement>(null);\n\t\tconst iconRef = React.useRef<HTMLButtonElement>(null);\n\t\t// the value when the field gained focus, so `change` can be emitted once per\n\t\t// editing session instead of once per keystroke.\n\t\tconst valueOnFocusRef = React.useRef<string>('');\n\n\t\tconst trackInteraction = useMrlTrackInteraction('MrlEditableTextarea', eventId);\n\n\t\tconst { hasActiveColor, setHasActiveColor } = useActiveColor(state);\n\t\tconst { isEditable, isEditing, setIsEditable, setIsEditing } = useIsEditable({\n\t\t\tchangeHandler: controlledIsEditableUpdate,\n\t\t\tinitialValue: false,\n\t\t\tstate,\n\t\t\tvalue: controlledIsEditable\n\t\t});\n\t\t// Allows us to track if the user has edited the input previously.\n\t\t// This helps conditionally focus the icon only when the user is done editing the input.\n\t\tconst [hasEdited, setHasEdited] = React.useState(false);\n\n\t\tReact.useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(\n\t\t\tref,\n\t\t\t() => iconRef.current\n\t\t);\n\n\t\tReact.useEffect(() => {\n\t\t\tif (iconRef.current && (attrs.autoFocus || hasEdited)) {\n\t\t\t\ticonRef.current.focus();\n\t\t\t}\n\t\t}, [attrs, iconRef, hasEdited]);\n\n\t\tReact.useEffect(() => {\n\t\t\tif (textareaRef.current) {\n\t\t\t\tif (isEditable) {\n\t\t\t\t\ttextareaRef.current.focus();\n\t\t\t\t} else {\n\t\t\t\t\ttextareaRef.current.style.height = 'auto';\n\t\t\t\t\tif (!textareaRef.current.value || textareaRef.current.value === '') {\n\t\t\t\t\t\ttextareaRef.current.style.height = '40px';\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttextareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, [isEditable, isEditing]);\n\n\t\tReact.useEffect(() => {\n\t\t\tif (!autoExpand || !textareaRef.current) return;\n\n\t\t\ttextareaRef.current.style.height = 'auto';\n\t\t\tif (!textareaRef.current.value || textareaRef.current.value === '') {\n\t\t\t\ttextareaRef.current.style.height = '40px';\n\t\t\t} else {\n\t\t\t\ttextareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\t\t\t}\n\t\t}, [autoExpand, value]);\n\n\t\tconst onKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n\t\t\tconst { key } = event;\n\n\t\t\tif (key === 'Escape') {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsEditable(false);\n\t\t\t\tsetIsEditing(false);\n\t\t\t}\n\t\t};\n\n\t\tconst handleOnBlur = React.useCallback(\n\t\t\t(e: React.FocusEvent<HTMLTextAreaElement>) => {\n\t\t\t\tsetHasActiveColor(false);\n\t\t\t\tsetIsEditable(false);\n\t\t\t\tsetIsEditing(false);\n\t\t\t\tsetHasEdited(false);\n\n\t\t\t\t// the value itself is never emitted — only the fact that it changed.\n\t\t\t\tif (e.target.value !== valueOnFocusRef.current) {\n\t\t\t\t\ttrackInteraction({ action: 'change' });\n\t\t\t\t}\n\n\t\t\t\tif (typeof attrs.onBlur === 'function') {\n\t\t\t\t\tattrs.onBlur(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor, setIsEditable, setIsEditing, trackInteraction]\n\t\t);\n\n\t\tconst handleOnFocus = React.useCallback(\n\t\t\t(e: React.FocusEvent<HTMLTextAreaElement>) => {\n\t\t\t\tsetHasActiveColor(true);\n\t\t\t\tsetIsEditable(true);\n\t\t\t\tsetIsEditing(true);\n\t\t\t\tsetHasEdited(true);\n\t\t\t\tvalueOnFocusRef.current = e.target.value;\n\n\t\t\t\tif (typeof attrs.onFocus === 'function') {\n\t\t\t\t\tattrs.onFocus(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor, setIsEditable, setIsEditing]\n\t\t);\n\n\t\tconst handleOnMouseEnter = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLTextAreaElement>) => {\n\t\t\t\tsetHasActiveColor(true);\n\t\t\t\tif (typeof attrs.onMouseEnter === 'function') {\n\t\t\t\t\tattrs.onMouseEnter(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tconst handleOnMouseLeave = React.useCallback(\n\t\t\t(e: React.MouseEvent<HTMLTextAreaElement>) => {\n\t\t\t\tsetHasActiveColor(false);\n\t\t\t\tif (typeof attrs.onMouseLeave === 'function') {\n\t\t\t\t\tattrs.onMouseLeave(e);\n\t\t\t\t}\n\t\t\t},\n\t\t\t[attrs, setHasActiveColor]\n\t\t);\n\n\t\tconst onClickEdit = React.useCallback(() => {\n\t\t\ttrackInteraction({ action: 'edit' });\n\n\t\t\tsetIsEditable(true);\n\t\t\tsetIsEditing(true);\n\t\t\tsetHasEdited(true);\n\t\t}, [setIsEditable, setIsEditing, setHasEdited, trackInteraction]);\n\n\t\tconst hasCounter =\n\t\t\ttypeof maxLength !== 'undefined' && Number(maxLength) > 0 && state !== 'read-only';\n\n\t\tif (hasCounter && isNaN(Number(maxLength))) {\n\t\t\tthrow new Error('maxLength should have type number');\n\t\t}\n\n\t\tconst hasErrorMessage = state === 'error' && error?.message;\n\n\t\tconst inputClasses = classnames(\n\t\t\tclassName,\n\t\t\tstyles['MrlEditableTextarea'],\n\t\t\t{\n\t\t\t\t[styles['MrlEditableTextarea--readOnly']]: state === 'read-only'\n\t\t\t},\n\t\t\t'MrlEditableTextarea',\n\t\t\t'mrl-textarea'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div className={`${styles['MrlEditableTextarea--wrapper']} MrlEditableTextarea--wrapper`}>\n\t\t\t\t\t<textarea\n\t\t\t\t\t\t{...attrs}\n\t\t\t\t\t\tid={inputId}\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\tclassName={inputClasses}\n\t\t\t\t\t\tdefaultValue={value}\n\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\tdisabled={state === 'disabled'}\n\t\t\t\t\t\taria-invalid={state === 'error'}\n\t\t\t\t\t\taria-describedby={hasErrorMessage ? describedById : undefined}\n\t\t\t\t\t\tonBlur={handleOnBlur}\n\t\t\t\t\t\tonFocus={handleOnFocus}\n\t\t\t\t\t\tonMouseEnter={handleOnMouseEnter}\n\t\t\t\t\t\tonMouseLeave={handleOnMouseLeave}\n\t\t\t\t\t\tonKeyDown={onKeyDown}\n\t\t\t\t\t\tmaxLength={hasCounter ? maxLength : undefined}\n\t\t\t\t\t\treadOnly={state === 'read-only' || !isEditable}\n\t\t\t\t\t\tref={textareaRef}\n\t\t\t\t\t\ttabIndex={!isEditable ? -1 : 0}\n\t\t\t\t\t/>\n\t\t\t\t\t{state !== 'read-only' && state !== 'disabled' && !isEditable && (\n\t\t\t\t\t\t<MrlEditableTextareaRightButton\n\t\t\t\t\t\t\taction={onClickEdit}\n\t\t\t\t\t\t\ticon={edit}\n\t\t\t\t\t\t\tlabel={`Edit ${inputLabelText}`}\n\t\t\t\t\t\t\tdataQa={attrs['data-qa'] && `${attrs['data-qa']}-edit`}\n\t\t\t\t\t\t\thasActiveColor={hasActiveColor || isEditable}\n\t\t\t\t\t\t\tsetHasActiveColor={setHasActiveColor}\n\t\t\t\t\t\t\tref={iconRef}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{hasCounter && isEditable && (\n\t\t\t\t\t<span className={styles['MrlForm-counter']}>\n\t\t\t\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t\t\t\t{value?.length || 0}/{maxLength}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<p style={{ display: 'none' }} aria-live=\"polite\" id={`${inputId}-counter`}>\n\t\t\t\t\t\t\t{`${maxLength - (value?.length || 0)} of ${maxLength} characters remaining`}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t\t{state === 'error' && error?.message && (\n\t\t\t\t\t<span className={styles['MrlEditableTextarea-errorMessage']}>\n\t\t\t\t\t\t<MrlSvg\n\t\t\t\t\t\t\tclassName={styles['MrlEditableTextarea-errorIcon']}\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\tsvg={errorIcon}\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<span id={describedById}>{`${error?.message}`}</span>\n\t\t\t\t\t</span>\n\t\t\t\t)}\n\t\t\t</>\n\t\t);\n\t}\n);\n"],"names":["MrlEditableTextarea","React","forwardRef","props","ref","_props$autoExpand","autoExpand","className","inputId","inputLabelText","maxLength","placeholder","state","value","error","controlledIsEditable","isEditable","controlledIsEditableUpdate","setIsEditable","eventId","attrs","_objectWithoutProperties","_excluded","describedById","concat","textareaRef","useRef","iconRef","valueOnFocusRef","trackInteraction","useMrlTrackInteraction","_useActiveColor","useActiveColor","hasActiveColor","setHasActiveColor","_useIsEditable","useIsEditable","changeHandler","initialValue","isEditing","setIsEditing","_React$useState","useState","_React$useState2","_slicedToArray","hasEdited","setHasEdited","useImperativeHandle","current","useEffect","autoFocus","focus","style","height","scrollHeight","onKeyDown","event","key","stopPropagation","preventDefault","handleOnBlur","useCallback","e","target","action","onBlur","handleOnFocus","onFocus","handleOnMouseEnter","onMouseEnter","handleOnMouseLeave","onMouseLeave","onClickEdit","hasCounter","Number","isNaN","Error","hasErrorMessage","message","inputClasses","classnames","styles","createElement","Fragment","_extends","id","defaultValue","disabled","undefined","readOnly","tabIndex","MrlEditableTextareaRightButton","icon","edit","label","dataQa","length","display","MrlSvg","svg","errorIcon","size"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA;AACA;AACA;AACA;AACA;AACO,IAAMA,mBAAmB,gBAAGC,gBAAK,CAACC,UAAU,CAClD,SAASF,mBAAmBA,CAC3BG,KAA+B,EAC/BC,GAAiC,EACnB;AACd,EAAA,IAAAC,iBAAA,GAcIF,KAAK,CAbRG,UAAU;AAAVA,IAAAA,UAAU,GAAAD,iBAAA,KAAA,MAAA,GAAG,KAAK,GAAAA,iBAAA;IAClBE,SAAS,GAYNJ,KAAK,CAZRI,SAAS;IACTC,OAAO,GAWJL,KAAK,CAXRK,OAAO;IACPC,cAAc,GAUXN,KAAK,CAVRM,cAAc;IACdC,SAAS,GASNP,KAAK,CATRO,SAAS;IACTC,WAAW,GAQRR,KAAK,CARRQ,WAAW;IACXC,KAAK,GAOFT,KAAK,CAPRS,KAAK;IACLC,KAAK,GAMFV,KAAK,CANRU,KAAK;IACLC,KAAK,GAKFX,KAAK,CALRW,KAAK;IACOC,oBAAoB,GAI7BZ,KAAK,CAJRa,UAAU;IACKC,0BAA0B,GAGtCd,KAAK,CAHRe,aAAa;IACbC,OAAO,GAEJhB,KAAK,CAFRgB,OAAO;AACJC,IAAAA,KAAK,GAAAC,iDAAA,CACLlB,KAAK,EAAAmB,SAAA,CAAA;;AAET;AACA,EAAA,IAAMC,aAAa,GAAA,EAAA,CAAAC,MAAA,CAAMhB,OAAO,EAAA,cAAA,CAAc;AAC9C,EAAA,IAAMiB,WAAW,GAAGxB,gBAAK,CAACyB,MAAM,CAAsB,IAAI,CAAC;AAC3D,EAAA,IAAMC,OAAO,GAAG1B,gBAAK,CAACyB,MAAM,CAAoB,IAAI,CAAC;AACrD;AACA;AACA,EAAA,IAAME,eAAe,GAAG3B,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CAAC,eACPT,gBAAA,CAAAiF,aAAA,CAAA,GAAA,EAAA;AAAG9B,IAAAA,KAAK,EAAE;AAAE6C,MAAAA,OAAO,EAAE;KAAS;AAAC,IAAA,WAAA,EAAU,QAAQ;IAACZ,EAAE,EAAA,EAAA,CAAA7D,MAAA,CAAKhB,OAAO,EAAA,UAAA;AAAW,GAAA,EAAA,EAAA,CAAAgB,MAAA,CACtEd,SAAS,IAAI,CAAAG,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAEmF,MAAM,KAAI,CAAC,CAAC,UAAAxE,MAAA,CAAOd,SAAS,EAAA,uBAAA,CAClD,CACE,CACN,EACAE,KAAK,KAAK,OAAO,KAAIE,KAAK,KAAA,IAAA,IAALA,KAAK,uBAALA,KAAK,CAAEgE,OAAO,CAAA,iBACnC7E,gBAAA,CAAAiF,aAAA,CAAA,MAAA,EAAA;IAAM3E,SAAS,EAAE0E,kCAAM,CAAC,kCAAkC;AAAE,GAAA,eAC3DhF,gBAAA,CAAAiF,aAAA,CAACgB,aAAM,EAAA;AACN3F,IAAAA,SAAS,EAAE0E,kCAAM,CAAC,+BAA+B,CAAE;AACnD,IAAA,aAAA,EAAY,MAAM;AAClBkB,IAAAA,GAAG,EAAEC,aAAU;AACfC,IAAAA,IAAI,EAAC;AAAO,GACZ,CAAC,eACFpG,gBAAA,CAAAiF,aAAA,CAAA,MAAA,EAAA;AAAMG,IAAAA,EAAE,EAAE9D;AAAc,GAAA,EAAA,EAAA,CAAAC,MAAA,CAAKV,KAAK,KAAA,IAAA,IAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAEgE,OAAO,CAAS,CAC/C,CAEN,CAAC;AAEL,CACD;;;;"}
|
|
@@ -28,39 +28,55 @@ function _interopNamespace(e) {
|
|
|
28
28
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
29
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
30
30
|
|
|
31
|
-
var _excluded = ["children", "className"];
|
|
32
|
-
|
|
31
|
+
var _excluded = ["children", "className", "col", "lg", "md", "sm", "xl", "xs", "xxl"];
|
|
32
|
+
/**
|
|
33
|
+
* Builds a single grid class. The base tier (`col`) and the deprecated `xs`
|
|
34
|
+
* alias are un-prefixed; every other breakpoint carries its infix.
|
|
35
|
+
* @param size - breakpoint key
|
|
36
|
+
* @param type - `col` or `offset`
|
|
37
|
+
* @param val - column count, or `auto`
|
|
38
|
+
* @returns the grid class name
|
|
39
|
+
*/
|
|
40
|
+
var getGridClass = (size, type, val) => size === 'col' || size === 'xs' ? "".concat(type, "-").concat(val) : "".concat(type, "-").concat(size, "-").concat(val);
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* There is no `col-0` class, so a zero span produces nothing. `ColSpan` already
|
|
44
|
+
* rules it out, but this is a published component and JavaScript consumers are
|
|
45
|
+
* not held to that — hence a runtime check rather than a type-level one.
|
|
46
|
+
*/
|
|
47
|
+
var isZeroSpan = val => val === 0;
|
|
33
48
|
|
|
34
49
|
/**
|
|
35
50
|
* Creates the size classes for the grid.
|
|
51
|
+
*
|
|
52
|
+
* `offset: 0` is kept, because `offset-<size>-0` is how a breakpoint cancels an
|
|
53
|
+
* offset set on a smaller one. `col: 0` is dropped, because there is no
|
|
54
|
+
* `col-0` class — a column always spans at least one track.
|
|
36
55
|
* @param props - component props
|
|
37
|
-
* @returns an array of size classes
|
|
56
|
+
* @returns an array of size classes
|
|
38
57
|
*/
|
|
39
58
|
var createSizeClasses = props => {
|
|
40
59
|
var classes = [];
|
|
41
|
-
for (var size of constants.
|
|
60
|
+
for (var size of constants.GRID_SIZE_KEYS) {
|
|
42
61
|
// get the value based on the prop key from the component props
|
|
43
62
|
var value = props[size];
|
|
63
|
+
if (value === undefined) continue;
|
|
44
64
|
|
|
45
|
-
//
|
|
46
|
-
if (value) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
65
|
+
// if the value is a number or `auto`, then it is a column size
|
|
66
|
+
if (typeof value === 'number' || typeof value === 'string') {
|
|
67
|
+
if (!isZeroSpan(value)) classes.push(getGridClass(size, 'col', value));
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
52
70
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}
|
|
71
|
+
// if the value is an object, then we need to compose multiple classes
|
|
72
|
+
// based on the keyvalue pairings
|
|
73
|
+
for (var _ref3 of Object.entries(value)) {
|
|
74
|
+
var _ref2 = _rollupPluginBabelHelpers.slicedToArray(_ref3, 2);
|
|
75
|
+
var key = _ref2[0];
|
|
76
|
+
var val = _ref2[1];
|
|
77
|
+
if (val === undefined) continue;
|
|
78
|
+
if (key === 'col' && isZeroSpan(val)) continue;
|
|
79
|
+
classes.push(getGridClass(size, key, val));
|
|
64
80
|
}
|
|
65
81
|
}
|
|
66
82
|
if (classes.length === 0) classes.push('col');
|
|
@@ -68,44 +84,31 @@ var createSizeClasses = props => {
|
|
|
68
84
|
};
|
|
69
85
|
|
|
70
86
|
/**
|
|
71
|
-
*
|
|
72
|
-
* @param props
|
|
73
|
-
* @returns
|
|
87
|
+
* MrlCol React component. Creates a grid column.
|
|
88
|
+
* @param props - component props
|
|
89
|
+
* @returns a MrlCol React component.
|
|
74
90
|
*/
|
|
75
|
-
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
function MrlCol(_ref4) {
|
|
92
|
+
var children = _ref4.children,
|
|
93
|
+
className = _ref4.className,
|
|
94
|
+
col = _ref4.col,
|
|
95
|
+
lg = _ref4.lg,
|
|
96
|
+
md = _ref4.md,
|
|
97
|
+
sm = _ref4.sm,
|
|
98
|
+
xl = _ref4.xl,
|
|
99
|
+
xs = _ref4.xs,
|
|
100
|
+
xxl = _ref4.xxl,
|
|
101
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref4, _excluded);
|
|
102
|
+
var columnClasses = createSizeClasses({
|
|
86
103
|
col,
|
|
87
|
-
xs,
|
|
88
|
-
sm,
|
|
89
|
-
md,
|
|
90
104
|
lg,
|
|
105
|
+
md,
|
|
106
|
+
sm,
|
|
91
107
|
xl,
|
|
108
|
+
xs,
|
|
92
109
|
xxl
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* MrlCol React component.
|
|
98
|
-
* @param props - component props
|
|
99
|
-
* @returns a MrlCol React component.
|
|
100
|
-
*/
|
|
101
|
-
function MrlCol(props) {
|
|
102
|
-
var children = props.children,
|
|
103
|
-
_props$className = props.className,
|
|
104
|
-
className = _props$className === void 0 ? '' : _props$className,
|
|
105
|
-
rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
|
106
|
-
var gridProps = getGridProps(props);
|
|
107
|
-
var columnClasses = React__namespace.useMemo(() => createSizeClasses(gridProps), [gridProps]);
|
|
108
|
-
var allClasses = classnames__default.default(className, columnClasses);
|
|
110
|
+
});
|
|
111
|
+
var allClasses = classnames__default.default('MrlCol', className, columnClasses);
|
|
109
112
|
return /*#__PURE__*/React__namespace.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
110
113
|
className: allClasses
|
|
111
114
|
}), children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlCol.js","sources":["../../../../../src/components/grid/MrlCol/MrlCol.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {
|
|
1
|
+
{"version":3,"file":"MrlCol.js","sources":["../../../../../src/components/grid/MrlCol/MrlCol.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { GRID_SIZE_KEYS, GridBaseProps, GridColumns } from '../constants';\n\nexport type MrlColProps = GridColumns & GridBaseProps;\n\n/**\n * Builds a single grid class. The base tier (`col`) and the deprecated `xs`\n * alias are un-prefixed; every other breakpoint carries its infix.\n * @param size - breakpoint key\n * @param type - `col` or `offset`\n * @param val - column count, or `auto`\n * @returns the grid class name\n */\nconst getGridClass = (size: string, type: string, val: number | string): string =>\n\tsize === 'col' || size === 'xs' ? `${type}-${val}` : `${type}-${size}-${val}`;\n\n/*\n * There is no `col-0` class, so a zero span produces nothing. `ColSpan` already\n * rules it out, but this is a published component and JavaScript consumers are\n * not held to that — hence a runtime check rather than a type-level one.\n */\nconst isZeroSpan = (val: unknown): boolean => val === 0;\n\n/**\n * Creates the size classes for the grid.\n *\n * `offset: 0` is kept, because `offset-<size>-0` is how a breakpoint cancels an\n * offset set on a smaller one. `col: 0` is dropped, because there is no\n * `col-0` class — a column always spans at least one track.\n * @param props - component props\n * @returns an array of size classes\n */\nconst createSizeClasses = (props: GridColumns): string[] => {\n\tconst classes: string[] = [];\n\n\tfor (const size of GRID_SIZE_KEYS) {\n\t\t// get the value based on the prop key from the component props\n\t\tconst value = props[size];\n\n\t\tif (value === undefined) continue;\n\n\t\t// if the value is a number or `auto`, then it is a column size\n\t\tif (typeof value === 'number' || typeof value === 'string') {\n\t\t\tif (!isZeroSpan(value)) classes.push(getGridClass(size, 'col', value));\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if the value is an object, then we need to compose multiple classes\n\t\t// based on the keyvalue pairings\n\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\tif (val === undefined) continue;\n\t\t\tif (key === 'col' && isZeroSpan(val)) continue;\n\t\t\tclasses.push(getGridClass(size, key, val));\n\t\t}\n\t}\n\n\tif (classes.length === 0) classes.push('col');\n\n\treturn classes;\n};\n\n/**\n * MrlCol React component. Creates a grid column.\n * @param props - component props\n * @returns a MrlCol React component.\n */\nexport function MrlCol({\n\tchildren,\n\tclassName,\n\tcol,\n\tlg,\n\tmd,\n\tsm,\n\txl,\n\txs,\n\txxl,\n\t...rest\n}: MrlColProps): JSX.Element {\n\tconst columnClasses = createSizeClasses({ col, lg, md, sm, xl, xs, xxl });\n\tconst allClasses = classnames('MrlCol', className, columnClasses);\n\n\treturn (\n\t\t<div {...rest} className={allClasses}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],"names":["getGridClass","size","type","val","concat","isZeroSpan","createSizeClasses","props","classes","GRID_SIZE_KEYS","value","undefined","push","_ref3","Object","entries","_ref2","_slicedToArray","key","length","MrlCol","_ref4","children","className","col","lg","md","sm","xl","xs","xxl","rest","_objectWithoutProperties","_excluded","columnClasses","allClasses","classnames","React","createElement","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,YAAY,GAAGA,CAACC,IAAY,EAAEC,IAAY,EAAEC,GAAoB,KACrEF,IAAI,KAAK,KAAK,IAAIA,IAAI,KAAK,IAAI,GAAA,EAAA,CAAAG,MAAA,CAAMF,IAAI,OAAAE,MAAA,CAAID,GAAG,CAAA,GAAA,EAAA,CAAAC,MAAA,CAAQF,IAAI,EAAA,GAAA,CAAA,CAAAE,MAAA,CAAIH,IAAI,EAAA,GAAA,CAAA,CAAAG,MAAA,CAAID,GAAG,CAAE;;AAE9E;AACA;AACA;AACA;AACA;AACA,IAAME,UAAU,GAAIF,GAAY,IAAcA,GAAG,KAAK,CAAC;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMG,iBAAiB,GAAIC,KAAkB,IAAe;EAC3D,IAAMC,OAAiB,GAAG,EAAE;AAE5B,EAAA,KAAK,IAAMP,IAAI,IAAIQ,wBAAc,EAAE;AAClC;AACA,IAAA,IAAMC,KAAK,GAAGH,KAAK,CAACN,IAAI,CAAC;IAEzB,IAAIS,KAAK,KAAKC,SAAS,EAAE;;AAEzB;IACA,IAAI,OAAOD,KAAK,KAAK,QAAQ,IAAI,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AAAA,IAAI,GAAAC,iDAAA,CAAAX,KAAA,EAAAY,SAAA,CAAA;EAEP,IAAMC,aAAa,GAAG5B,iBAAiB,CAAC;IAAEkB,GAAG;IAAEC,EAAE;IAAEC,EAAE;IAAEC,EAAE;IAAEC,EAAE;IAAEC,EAAE;AAAEC,IAAAA;AAAI,GAAC,CAAC;EACzE,IAAMK,UAAU,GAAGC,2BAAU,CAAC,QAAQ,EAAEb,SAAS,EAAEW,aAAa,CAAC;AAEjE,EAAA,oBACCG,gBAAA,CAAAC,aAAA,CAAA,KAAA,EAAAC,iCAAA,KAASR,IAAI,EAAA;AAAER,IAAAA,SAAS,EAAEY;AAAW,GAAA,CAAA,EACnCb,QACG,CAAC;AAER;;;;"}
|
|
@@ -28,18 +28,16 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
28
28
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
29
29
|
|
|
30
30
|
var _excluded = ["children", "className"];
|
|
31
|
-
|
|
32
31
|
/**
|
|
33
|
-
* MrlGrid React component.
|
|
32
|
+
* MrlGrid React component. Primary container of a grid.
|
|
34
33
|
* @param props - component props
|
|
35
34
|
* @returns a MrlGrid React component.
|
|
36
35
|
*/
|
|
37
36
|
function MrlGrid(_ref) {
|
|
38
37
|
var children = _ref.children,
|
|
39
|
-
|
|
40
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
38
|
+
className = _ref.className,
|
|
41
39
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
42
|
-
var allClasses = classnames__default.default('container', className);
|
|
40
|
+
var allClasses = classnames__default.default('container', 'MrlGrid', className);
|
|
43
41
|
return /*#__PURE__*/React__namespace.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
44
42
|
className: allClasses
|
|
45
43
|
}), children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlGrid.js","sources":["../../../../../src/components/grid/MrlGrid/MrlGrid.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {
|
|
1
|
+
{"version":3,"file":"MrlGrid.js","sources":["../../../../../src/components/grid/MrlGrid/MrlGrid.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { GridBaseProps } from '../constants';\nimport '../grid.global.scss';\n\nexport type MrlGridProps = GridBaseProps;\n\n/**\n * MrlGrid React component. Primary container of a grid.\n * @param props - component props\n * @returns a MrlGrid React component.\n */\nexport function MrlGrid({ children, className, ...rest }: MrlGridProps): JSX.Element {\n\tconst allClasses = classnames('container', 'MrlGrid', className);\n\n\treturn (\n\t\t<div {...rest} className={allClasses}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],"names":["MrlGrid","_ref","children","className","rest","_objectWithoutProperties","_excluded","allClasses","classnames","React","createElement","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;AACA;AACA;AACA;AACA;AACO,SAASA,OAAOA,CAAAC,IAAA,EAA8D;AAAA,EAAA,IAA3DC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,SAAS,GAAAF,IAAA,CAATE,SAAS;AAAKC,IAAAA,IAAI,GAAAC,iDAAA,CAAAJ,IAAA,EAAAK,SAAA,CAAA;EACrD,IAAMC,UAAU,GAAGC,2BAAU,CAAC,WAAW,EAAE,SAAS,EAAEL,SAAS,CAAC;AAEhE,EAAA,oBACCM,gBAAA,CAAAC,aAAA,CAAA,KAAA,EAAAC,iCAAA,KAASP,IAAI,EAAA;AAAED,IAAAA,SAAS,EAAEI;AAAW,GAAA,CAAA,EACnCL,QACG,CAAC;AAER;;;;"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
|
+
var constants = require('../constants.js');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -27,25 +28,26 @@ function _interopNamespace(e) {
|
|
|
27
28
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
29
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
29
30
|
|
|
30
|
-
var _excluded = ["align", "children", "className", "justify"];
|
|
31
|
+
var _excluded = ["align", "children", "className", "gutter", "justify"];
|
|
31
32
|
/**
|
|
32
|
-
* MrlRow React component.
|
|
33
|
+
* MrlRow React component. Creates a grid row.
|
|
33
34
|
* @param props - component props
|
|
34
35
|
* @returns a MrlRow React component.
|
|
35
36
|
*/
|
|
36
37
|
function MrlRow(_ref) {
|
|
37
38
|
var align = _ref.align,
|
|
38
39
|
children = _ref.children,
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
className = _ref.className,
|
|
41
|
+
_ref$gutter = _ref.gutter,
|
|
42
|
+
gutter = _ref$gutter === void 0 ? 1 : _ref$gutter,
|
|
41
43
|
justify = _ref.justify,
|
|
42
44
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
43
|
-
var alignClass = align
|
|
45
|
+
var alignClass = align && "align-items-".concat(align);
|
|
44
46
|
var justifyClass = justify && "justify-content-".concat(justify);
|
|
45
|
-
var allClasses = classnames__default.default('row', className, alignClass, justifyClass);
|
|
46
|
-
return /*#__PURE__*/React__namespace.createElement("div", _rollupPluginBabelHelpers.extends({
|
|
47
|
+
var allClasses = classnames__default.default('row', 'MrlRow', className, alignClass, justifyClass, constants.GUTTER_CLASS[gutter]);
|
|
48
|
+
return /*#__PURE__*/React__namespace.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
47
49
|
className: allClasses
|
|
48
|
-
}
|
|
50
|
+
}), children);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
exports.MrlRow = MrlRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlRow.js","sources":["../../../../../src/components/grid/MrlRow/MrlRow.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {
|
|
1
|
+
{"version":3,"file":"MrlRow.js","sources":["../../../../../src/components/grid/MrlRow/MrlRow.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tAlignOptions,\n\tGridBaseProps,\n\tGUTTER_CLASS,\n\tGutterSizes,\n\tJustifyOptions\n} from '../constants';\n\nexport interface MrlRowProps extends GridBaseProps {\n\t/**\n\t * Flex alignment of the children within the component.\n\t */\n\talign?: AlignOptions;\n\n\t/**\n\t * Gutter size for columns within the row.\n\t *\n\t * @default 1\n\t */\n\tgutter?: GutterSizes;\n\n\t/**\n\t * Justify content of the children within the component.\n\t */\n\tjustify?: JustifyOptions;\n}\n\n/**\n * MrlRow React component. Creates a grid row.\n * @param props - component props\n * @returns a MrlRow React component.\n */\nexport function MrlRow({\n\talign,\n\tchildren,\n\tclassName,\n\tgutter = 1,\n\tjustify,\n\t...rest\n}: MrlRowProps): JSX.Element {\n\tconst alignClass = align && `align-items-${align}`;\n\tconst justifyClass = justify && `justify-content-${justify}`;\n\n\tconst allClasses = classnames(\n\t\t'row',\n\t\t'MrlRow',\n\t\tclassName,\n\t\talignClass,\n\t\tjustifyClass,\n\t\tGUTTER_CLASS[gutter]\n\t);\n\n\treturn (\n\t\t<div {...rest} className={allClasses}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],"names":["MrlRow","_ref","align","children","className","_ref$gutter","gutter","justify","rest","_objectWithoutProperties","_excluded","alignClass","concat","justifyClass","allClasses","classnames","GUTTER_CLASS","React","createElement","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA;AACA;AACA;AACA;AACA;AACO,SAASA,MAAMA,CAAAC,IAAA,EAOO;AAAA,EAAA,IAN5BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,SAAS,GAAAH,IAAA,CAATG,SAAS;IAAAC,WAAA,GAAAJ,IAAA,CACTK,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAA,MAAA,GAAG,CAAC,GAAAA,WAAA;IACVE,OAAO,GAAAN,IAAA,CAAPM,OAAO;AACJC,IAAAA,IAAI,GAAAC,iDAAA,CAAAR,IAAA,EAAAS,SAAA,CAAA;AAEP,EAAA,IAAMC,UAAU,GAAGT,KAAK,mBAAAU,MAAA,CAAmBV,KAAK,CAAE;AAClD,EAAA,IAAMW,YAAY,GAAGN,OAAO,uBAAAK,MAAA,CAAuBL,OAAO,CAAE;AAE5D,EAAA,IAAMO,UAAU,GAAGC,2BAAU,CAC5B,KAAK,EACL,QAAQ,EACRX,SAAS,EACTO,UAAU,EACVE,YAAY,EACZG,sBAAY,CAACV,MAAM,CACpB,CAAC;AAED,EAAA,oBACCW,gBAAA,CAAAC,aAAA,CAAA,KAAA,EAAAC,iCAAA,KAASX,IAAI,EAAA;AAAEJ,IAAAA,SAAS,EAAEU;AAAW,GAAA,CAAA,EACnCX,QACG,CAAC;AAER;;;;"}
|
|
@@ -5,23 +5,22 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Number of columns a `col` can span. There is no `col-0` class — a column
|
|
9
|
+
* always occupies at least one of the twelve tracks.
|
|
9
10
|
*/
|
|
10
|
-
var GridSizes = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Number of columns
|
|
13
|
+
* Number of columns an `offset` can skip. `0` is meaningful here: it is how a
|
|
14
|
+
* larger breakpoint cancels an offset inherited from a smaller one.
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - columns "col-<size>-<number>"
|
|
20
|
-
* - offsets "offset-<size>-<number>""
|
|
18
|
+
* @deprecated Use `ColSpan` for spans or `OffsetSpan` for offsets. This union
|
|
19
|
+
* allowed `col={0}`, which never produced a class.
|
|
21
20
|
*/
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
|
-
* Interface of available class selectors
|
|
23
|
+
* Interface of available class selectors per breakpoint.
|
|
25
24
|
*
|
|
26
25
|
* Example interface:
|
|
27
26
|
* {
|
|
@@ -34,9 +33,48 @@ var GridSizes = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
|
34
33
|
* Options to configure the number of columns to span on different screen sizes.
|
|
35
34
|
*/
|
|
36
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Breakpoint keys in ascending order. Drives both class generation and the
|
|
38
|
+
* filtering that keeps grid props from reaching the DOM.
|
|
39
|
+
*/
|
|
40
|
+
var GRID_SIZE_KEYS = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
41
|
+
|
|
37
42
|
/**
|
|
38
43
|
* Available gutter sizes for customizing the grid
|
|
39
44
|
*/
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Gutter size to modifier class. `1` is the default declared on `.row`, so it
|
|
48
|
+
* needs no class.
|
|
49
|
+
*/
|
|
50
|
+
var GUTTER_CLASS = {
|
|
51
|
+
0: 'MrlRow-gutter--none',
|
|
52
|
+
1: undefined,
|
|
53
|
+
2: 'MrlRow-gutter--double'
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Roles a generic layout wrapper may safely carry.
|
|
58
|
+
*
|
|
59
|
+
* Composite widget roles (`grid`, `row`, `gridcell`, `listbox`, `tablist`, …)
|
|
60
|
+
* are deliberately excluded: they promise an APG keyboard contract — roving
|
|
61
|
+
* tabindex or `aria-activedescendant`, arrow-key navigation, selection state —
|
|
62
|
+
* that these divs do not implement. The roles below are structural only and
|
|
63
|
+
* carry no interaction contract, so they are safe to forward.
|
|
64
|
+
*
|
|
65
|
+
* `list`/`listitem` in particular is how a row of columns is announced as
|
|
66
|
+
* "list, N items", and is the standard workaround for Safari/VoiceOver
|
|
67
|
+
* dropping implicit list semantics. `region` needs an accessible name to be
|
|
68
|
+
* exposed as a landmark; the type cannot enforce that.
|
|
69
|
+
*
|
|
70
|
+
* Page landmarks belong to the layout components (MrlMain, MrlPage).
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Shared props for the grid components: every `div` attribute, with `role`
|
|
75
|
+
* narrowed to {@link SafeLayoutRole}.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
exports.GRID_SIZE_KEYS = GRID_SIZE_KEYS;
|
|
79
|
+
exports.GUTTER_CLASS = GUTTER_CLASS;
|
|
42
80
|
//# sourceMappingURL=constants.js.map
|