@helsenorge/designsystem-react 10.0.2 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AnchorLink.js +2 -2
- package/AnchorLink.js.map +1 -1
- package/Avatar.js +2 -2
- package/Avatar.js.map +1 -1
- package/Badge.js +3 -3
- package/Badge.js.map +1 -1
- package/Button.js +4 -4
- package/Button.js.map +1 -1
- package/CHANGELOG.md +38 -0
- package/Checkbox.js +2 -2
- package/Checkbox.js.map +1 -1
- package/Close.js +2 -2
- package/Close.js.map +1 -1
- package/ErrorBoundary.js +2 -2
- package/ErrorBoundary.js.map +1 -1
- package/Expander.js +2 -2
- package/Expander.js.map +1 -1
- package/FormGroup.js +12 -12
- package/FormGroup.js.map +1 -1
- package/FormLayout.js +3 -3
- package/FormLayout.js.map +1 -1
- package/HelpBubble.js +2 -2
- package/HelpBubble.js.map +1 -1
- package/HighlightPanel.js +2 -2
- package/HighlightPanel.js.map +1 -1
- package/Icon.js +3 -3
- package/Icon.js.map +1 -1
- package/Illustration.js +3 -3
- package/Illustration.js.map +1 -1
- package/Input.js +2 -2
- package/Input.js.map +1 -1
- package/Label.js +8 -8
- package/Label.js.map +1 -1
- package/LazyIcon.js +1 -1
- package/LazyIllustration.js +3 -3
- package/LazyIllustration.js.map +1 -1
- package/LinkList.js +6 -6
- package/LinkList.js.map +1 -1
- package/ListHeader.js +7 -7
- package/ListHeader.js.map +1 -1
- package/Panel.js +2 -2
- package/Panel.js.map +1 -1
- package/PopOver.js +2 -2
- package/PopOver.js.map +1 -1
- package/RadioButton.js +2 -2
- package/RadioButton.js.map +1 -1
- package/Select.js +2 -2
- package/Select.js.map +1 -1
- package/Slider.js +3 -3
- package/Slider.js.map +1 -1
- package/Spacer.js +2 -2
- package/Spacer.js.map +1 -1
- package/StatusDot.js +1 -1
- package/StepButtons.js +4 -4
- package/StepButtons.js.map +1 -1
- package/TabList.js +4 -4
- package/TabList.js.map +1 -1
- package/Table.js +2 -2
- package/Table.js.map +1 -1
- package/TableBody.js +2 -2
- package/TableBody.js.map +1 -1
- package/TableExpandedRow.js +2 -2
- package/TableExpandedRow.js.map +1 -1
- package/TableHead.js +2 -2
- package/TableHead.js.map +1 -1
- package/TableRow.js +2 -2
- package/TableRow.js.map +1 -1
- package/Textarea.js +2 -2
- package/Textarea.js.map +1 -1
- package/Title.js +2 -2
- package/Title.js.map +1 -1
- package/TooltipWord.js +2 -2
- package/TooltipWord.js.map +1 -1
- package/Trigger.js +3 -3
- package/Trigger.js.map +1 -1
- package/components/Button/styles.module.scss +5 -0
- package/components/DictionaryTrigger/index.js +2 -2
- package/components/DictionaryTrigger/index.js.map +1 -1
- package/components/Drawer/Drawer.d.ts +41 -0
- package/components/Drawer/Drawer.test.d.ts +1 -0
- package/components/Drawer/index.d.ts +3 -0
- package/components/Drawer/index.js +350 -0
- package/components/Drawer/index.js.map +1 -0
- package/components/Drawer/styles.module.scss +127 -0
- package/components/Drawer/styles.module.scss.d.ts +16 -0
- package/components/Dropdown/index.js +3 -3
- package/components/Dropdown/index.js.map +1 -1
- package/components/Duolist/index.js +4 -4
- package/components/Duolist/index.js.map +1 -1
- package/components/ExpanderHierarchy/index.js +5 -5
- package/components/ExpanderHierarchy/index.js.map +1 -1
- package/components/ExpanderList/index.js +8 -8
- package/components/ExpanderList/index.js.map +1 -1
- package/components/HelpQuestion/index.js +2 -2
- package/components/HelpQuestion/index.js.map +1 -1
- package/components/HighlightPanel/styles.module.scss +4 -36
- package/components/HighlightPanel/styles.module.scss.d.ts +1 -2
- package/components/Icons/EuropeanHealthCard.js +1 -1
- package/components/Icons/GroupTwins.js +1 -1
- package/components/Icons/Inbox.js +1 -1
- package/components/Icons/LawBook.js +1 -1
- package/components/Icons/PersonCancel.js +1 -1
- package/components/Icons/PersonWithBrain.js +1 -1
- package/components/Icons/Puzzle.js +1 -1
- package/components/Icons/Snapchat.js +1 -1
- package/components/Illustrations/IllustrationNames.d.ts +1 -1
- package/components/Illustrations/IllustrationNames.js +4 -2
- package/components/Illustrations/IllustrationNames.js.map +1 -1
- package/components/Illustrations/ReadLetters.d.ts +9 -0
- package/components/Illustrations/ReadLetters.js +11 -0
- package/components/Illustrations/ReadLetters.js.map +1 -0
- package/components/Illustrations/ReadLettersMedium.d.ts +4 -0
- package/components/Illustrations/ReadLettersMedium.js +110 -0
- package/components/Illustrations/ReadLettersMedium.js.map +1 -0
- package/components/Illustrations/Support2.d.ts +9 -0
- package/components/Illustrations/Support2.js +11 -0
- package/components/Illustrations/Support2.js.map +1 -0
- package/components/Illustrations/Support2Medium.d.ts +4 -0
- package/components/Illustrations/Support2Medium.js +232 -0
- package/components/Illustrations/Support2Medium.js.map +1 -0
- package/components/Label/styles.module.scss +16 -12
- package/components/Label/styles.module.scss.d.ts +3 -1
- package/components/List/styles.module.scss +7 -7
- package/components/Modal/index.js +71 -82
- package/components/Modal/index.js.map +1 -1
- package/components/Modal/styles.module.scss +12 -6
- package/components/NotificationPanel/index.js +3 -3
- package/components/NotificationPanel/index.js.map +1 -1
- package/components/PanelList/index.js +5 -5
- package/components/PanelList/index.js.map +1 -1
- package/components/PopMenu/index.js +5 -5
- package/components/PopMenu/index.js.map +1 -1
- package/components/Portal/index.js +3 -3
- package/components/Portal/index.js.map +1 -1
- package/components/PromoPanel/index.js +2 -2
- package/components/PromoPanel/index.js.map +1 -1
- package/components/StickyNote/index.js +12 -6
- package/components/StickyNote/index.js.map +1 -1
- package/components/Tabs/Tabs.d.ts +2 -0
- package/components/Tabs/index.js +8 -4
- package/components/Tabs/index.js.map +1 -1
- package/components/TagList/index.js +2 -2
- package/components/TagList/index.js.map +1 -1
- package/components/Tile/index.js +6 -6
- package/components/Tile/index.js.map +1 -1
- package/components/Toggle/index.js +3 -3910
- package/components/Toggle/index.js.map +1 -1
- package/components/Tooltip/index.js +2 -2
- package/components/Tooltip/index.js.map +1 -1
- package/components/Validation/index.js +6 -6
- package/components/Validation/index.js.map +1 -1
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/constants.js.map +1 -1
- package/hoc/withBreakpoint/withBreakpoint.js +2 -2
- package/hoc/withBreakpoint/withBreakpoint.js.map +1 -1
- package/hooks/useBreakpoint.d.ts +0 -4
- package/hooks/useBreakpoint.js +23 -18
- package/hooks/useBreakpoint.js.map +1 -1
- package/hooks/useEventListenerState.js +3 -3
- package/hooks/useEventListenerState.js.map +1 -1
- package/hooks/useOutsideEvent.d.ts +4 -4
- package/hooks/useOutsideEvent.js +5 -4
- package/hooks/useOutsideEvent.js.map +1 -1
- package/hooks/useReturnFocusOnUnmount.d.ts +5 -0
- package/hooks/useReturnFocusOnUnmount.js +20 -0
- package/hooks/useReturnFocusOnUnmount.js.map +1 -0
- package/package.json +1 -1
- package/scss/_breakpoints.scss +6 -0
- package/scss/_font-mixins.scss +55 -0
- package/scss/typography.module.scss +24 -0
- package/scss/typography.module.scss.d.ts +6 -0
- package/scss/typography.stories.tsx +24 -0
- package/theme/index.js +2 -2
- package/use-animate.js +3952 -0
- package/use-animate.js.map +1 -0
- package/utils/accessibility.d.ts +1 -0
- package/utils/accessibility.js +6 -1
- package/utils/accessibility.js.map +1 -1
- package/utils/component.js +4 -4
- package/utils/component.js.map +1 -1
package/Textarea.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sources":["../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormOnColor } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper, { ErrorWrapperClassNameProps } from '../ErrorWrapper';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface TextareaProps\n extends ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n | 'value'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n onColor?: keyof typeof FormOnColor;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea = React.forwardRef((props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) => {\n const {\n maxCharacters,\n maxText,\n width,\n testId,\n defaultValue,\n marginBottom: gutterBottom,\n transparent,\n onColor = FormOnColor.onwhite,\n label,\n textareaId = uuid(),\n minRows = 3,\n maxRows = 10,\n grow,\n error,\n errorText,\n errorTextId,\n errorWrapperClassName,\n autoFocus,\n disabled,\n name,\n autoComplete = 'off',\n placeholder,\n readOnly,\n required,\n onChange,\n value,\n ...rest\n } = props;\n\n const [rows, setRows] = useState(minRows);\n const [textareaInput, setTextareaInput] = useState(value || defaultValue || '');\n const referanse = useRef<HTMLDivElement>(null);\n const errorTextUuid = useUuid(errorTextId);\n\n useEffect(() => {\n setTextareaInput(defaultValue || '');\n }, [defaultValue]);\n\n const resizeHeight = (target: HTMLTextAreaElement): void => {\n const textareaLineHeight = 28;\n\n const previousRows = target.rows;\n target.rows = minRows; // reset number of rows in textarea\n\n const currentRows = Math.floor((target.scrollHeight - 16) / textareaLineHeight); // scrollHeight - 16px of padding to calculate the rows\n\n if (currentRows === previousRows) {\n target.rows = currentRows;\n }\n\n if (currentRows >= maxRows) {\n target.rows = maxRows;\n target.scrollTop = target.scrollHeight;\n }\n\n if (currentRows < maxRows) {\n setRows(currentRows);\n } else {\n setRows(maxRows);\n }\n };\n\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && textareaInput.toString().length > maxCharacters;\n const onError = onColor === FormOnColor.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n\n const textareaWrapperClass = cn(styles.textarea, {\n [styles['textarea--gutterBottom']]: gutterBottom,\n });\n\n const contentWrapperClass = cn(styles['input-container'], {\n [styles['input-container--transparent']]: transparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--disabled']]: props.disabled,\n });\n\n const textareaClass = cn(styles['input-container__input'], {\n [styles[`input-container__input--disabled`]]: props.disabled,\n });\n\n useEffect(() => {\n value && setTextareaInput(value);\n\n if (grow && referanse.current?.children && referanse.current?.children[0]) {\n const textarea = referanse.current?.children[0] as HTMLTextAreaElement;\n resizeHeight(textarea);\n }\n }, [value]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n setTextareaInput(e.target.value);\n\n if (onChange) {\n onChange(e);\n }\n\n if (grow) {\n resizeHeight(e.target);\n }\n };\n\n const maxWidth = width ? getTextareaMaxWidth(width) : undefined;\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Textarea} className={textareaWrapperClass}>\n {renderLabel(label, textareaId, onColor as FormOnColor)}\n <div className={contentWrapperClass} ref={referanse} style={{ maxWidth }}>\n <textarea\n {...rest}\n rows={rows}\n defaultValue={defaultValue}\n id={textareaId}\n className={textareaClass}\n ref={ref}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={!!onError}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n disabled={disabled}\n name={name}\n autoComplete={autoComplete ? autoComplete : undefined}\n placeholder={placeholder}\n readOnly={readOnly}\n required={required}\n onChange={onChangeHandler}\n value={value}\n />\n </div>\n {maxCharacters && (\n <MaxCharacters\n maxCharacters={maxCharacters}\n length={textareaInput.toString().length}\n maxText={maxText}\n onColor={onColor}\n maxWidth={maxWidth}\n />\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nTextarea.displayName = 'Textarea';\n\nexport default Textarea;\n"],"names":["cn"],"mappings":";;;;;;;;;;;AA8DA,MAAM,sBAAsB,CAAC,eAA+B;AAC1D,QAAM,eAAe;AACrB,QAAM,iBAAiB;AACvB,QAAM,cAAc;AAEb,SAAA,QAAQ,aAAa,0BAA0B,QAAQ,YAAY,MAAM,cAAc,MAAM,WAAW;AACjH;AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"Textarea.js","sources":["../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormOnColor } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper, { ErrorWrapperClassNameProps } from '../ErrorWrapper';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface TextareaProps\n extends ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n | 'value'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n onColor?: keyof typeof FormOnColor;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea = React.forwardRef((props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) => {\n const {\n maxCharacters,\n maxText,\n width,\n testId,\n defaultValue,\n marginBottom: gutterBottom,\n transparent,\n onColor = FormOnColor.onwhite,\n label,\n textareaId = uuid(),\n minRows = 3,\n maxRows = 10,\n grow,\n error,\n errorText,\n errorTextId,\n errorWrapperClassName,\n autoFocus,\n disabled,\n name,\n autoComplete = 'off',\n placeholder,\n readOnly,\n required,\n onChange,\n value,\n ...rest\n } = props;\n\n const [rows, setRows] = useState(minRows);\n const [textareaInput, setTextareaInput] = useState(value || defaultValue || '');\n const referanse = useRef<HTMLDivElement>(null);\n const errorTextUuid = useUuid(errorTextId);\n\n useEffect(() => {\n setTextareaInput(defaultValue || '');\n }, [defaultValue]);\n\n const resizeHeight = (target: HTMLTextAreaElement): void => {\n const textareaLineHeight = 28;\n\n const previousRows = target.rows;\n target.rows = minRows; // reset number of rows in textarea\n\n const currentRows = Math.floor((target.scrollHeight - 16) / textareaLineHeight); // scrollHeight - 16px of padding to calculate the rows\n\n if (currentRows === previousRows) {\n target.rows = currentRows;\n }\n\n if (currentRows >= maxRows) {\n target.rows = maxRows;\n target.scrollTop = target.scrollHeight;\n }\n\n if (currentRows < maxRows) {\n setRows(currentRows);\n } else {\n setRows(maxRows);\n }\n };\n\n const onDark = onColor === FormOnColor.ondark;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && textareaInput.toString().length > maxCharacters;\n const onError = onColor === FormOnColor.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n\n const textareaWrapperClass = cn(styles.textarea, {\n [styles['textarea--gutterBottom']]: gutterBottom,\n });\n\n const contentWrapperClass = cn(styles['input-container'], {\n [styles['input-container--transparent']]: transparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--disabled']]: props.disabled,\n });\n\n const textareaClass = cn(styles['input-container__input'], {\n [styles[`input-container__input--disabled`]]: props.disabled,\n });\n\n useEffect(() => {\n value && setTextareaInput(value);\n\n if (grow && referanse.current?.children && referanse.current?.children[0]) {\n const textarea = referanse.current?.children[0] as HTMLTextAreaElement;\n resizeHeight(textarea);\n }\n }, [value]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n setTextareaInput(e.target.value);\n\n if (onChange) {\n onChange(e);\n }\n\n if (grow) {\n resizeHeight(e.target);\n }\n };\n\n const maxWidth = width ? getTextareaMaxWidth(width) : undefined;\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Textarea} className={textareaWrapperClass}>\n {renderLabel(label, textareaId, onColor as FormOnColor)}\n <div className={contentWrapperClass} ref={referanse} style={{ maxWidth }}>\n <textarea\n {...rest}\n rows={rows}\n defaultValue={defaultValue}\n id={textareaId}\n className={textareaClass}\n ref={ref}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={!!onError}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n disabled={disabled}\n name={name}\n autoComplete={autoComplete ? autoComplete : undefined}\n placeholder={placeholder}\n readOnly={readOnly}\n required={required}\n onChange={onChangeHandler}\n value={value}\n />\n </div>\n {maxCharacters && (\n <MaxCharacters\n maxCharacters={maxCharacters}\n length={textareaInput.toString().length}\n maxText={maxText}\n onColor={onColor}\n maxWidth={maxWidth}\n />\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nTextarea.displayName = 'Textarea';\n\nexport default Textarea;\n"],"names":["React","cn"],"mappings":";;;;;;;;;;;AA8DA,MAAM,sBAAsB,CAAC,eAA+B;AAC1D,QAAM,eAAe;AACrB,QAAM,iBAAiB;AACvB,QAAM,cAAc;AAEb,SAAA,QAAQ,aAAa,0BAA0B,QAAQ,YAAY,MAAM,cAAc,MAAM,WAAW;AACjH;AAEA,MAAM,WAAWA,eAAM,WAAW,CAAC,OAAsB,QAAwC;AACzF,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA,UAAU,YAAY;AAAA,IACtB;AAAA,IACA,aAAa,KAAK;AAAA,IAClB,UAAU;AAAA,IACV,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,OAAO;AACxC,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,SAAS,gBAAgB,EAAE;AACxE,QAAA,YAAY,OAAuB,IAAI;AACvC,QAAA,gBAAgB,QAAQ,WAAW;AAEzC,YAAU,MAAM;AACd,qBAAiB,gBAAgB,EAAE;AAAA,EAAA,GAClC,CAAC,YAAY,CAAC;AAEX,QAAA,eAAe,CAAC,WAAsC;AAC1D,UAAM,qBAAqB;AAE3B,UAAM,eAAe,OAAO;AAC5B,WAAO,OAAO;AAEd,UAAM,cAAc,KAAK,OAAO,OAAO,eAAe,MAAM,kBAAkB;AAE9E,QAAI,gBAAgB,cAAc;AAChC,aAAO,OAAO;AAAA,IAAA;AAGhB,QAAI,eAAe,SAAS;AAC1B,aAAO,OAAO;AACd,aAAO,YAAY,OAAO;AAAA,IAAA;AAG5B,QAAI,cAAc,SAAS;AACzB,cAAQ,WAAW;AAAA,IAAA,OACd;AACL,cAAQ,OAAO;AAAA,IAAA;AAAA,EAEnB;AAEM,QAAA,SAAS,YAAY,YAAY;AACjC,QAAA,cAAc,YAAY,YAAY;AAC5C,QAAM,wBAAwB,CAAC,CAAC,iBAAiB,cAAc,SAAA,EAAW,SAAS;AAC7E,QAAA,UAAU,YAAY,YAAY,aAAa,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS;AAEzE,QAAA,uBAAuBC,WAAG,OAAO,UAAU;AAAA,IAC/C,CAAC,OAAO,wBAAwB,CAAC,GAAG;AAAA,EAAA,CACrC;AAED,QAAM,sBAAsBA,WAAG,OAAO,iBAAiB,GAAG;AAAA,IACxD,CAAC,OAAO,8BAA8B,CAAC,GAAG;AAAA,IAC1C,CAAC,OAAO,+BAA+B,CAAC,GAAG;AAAA,IAC3C,CAAC,OAAO,0BAA0B,CAAC,GAAG;AAAA,IACtC,CAAC,OAAO,0BAA0B,CAAC,GAAG;AAAA,IACtC,CAAC,OAAO,2BAA2B,CAAC,GAAG,MAAM;AAAA,EAAA,CAC9C;AAED,QAAM,gBAAgBA,WAAG,OAAO,wBAAwB,GAAG;AAAA,IACzD,CAAC,OAAO,kCAAkC,CAAC,GAAG,MAAM;AAAA,EAAA,CACrD;AAED,YAAU,MAAM;;AACd,aAAS,iBAAiB,KAAK;AAE3B,QAAA,UAAQ,eAAU,YAAV,mBAAmB,eAAY,eAAU,YAAV,mBAAmB,SAAS,KAAI;AACzE,YAAM,YAAW,eAAU,YAAV,mBAAmB,SAAS;AAC7C,mBAAa,QAAQ;AAAA,IAAA;AAAA,EACvB,GACC,CAAC,KAAK,CAAC;AAEJ,QAAA,kBAAkB,CAAC,MAAoD;AAC1D,qBAAA,EAAE,OAAO,KAAK;AAE/B,QAAI,UAAU;AACZ,eAAS,CAAC;AAAA,IAAA;AAGZ,QAAI,MAAM;AACR,mBAAa,EAAE,MAAM;AAAA,IAAA;AAAA,EAEzB;AAEA,QAAM,WAAW,QAAQ,oBAAoB,KAAK,IAAI;AAEtD,SACG,oBAAA,cAAA,EAAa,WAAW,uBAAuB,WAAsB,aAAa,eACjF,UAAC,qBAAA,OAAA,EAAI,eAAa,QAAQ,oBAAkB,YAAY,UAAU,WAAW,sBAC1E,UAAA;AAAA,IAAY,YAAA,OAAO,YAAY,OAAsB;AAAA,IACtD,oBAAC,SAAI,WAAW,qBAAqB,KAAK,WAAW,OAAO,EAAE,SAC5D,GAAA,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA;AAAA,QACA,IAAI;AAAA,QACJ,WAAW;AAAA,QACX;AAAA,QACA,oBAAkB,mBAAmB,OAAO,aAAa;AAAA,QACzD,gBAAc,CAAC,CAAC;AAAA,QAEhB;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc,eAAe,eAAe;AAAA,QAC5C;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU;AAAA,QACV;AAAA,MAAA;AAAA,IAAA,GAEJ;AAAA,IACC,iBACC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,QAAQ,cAAc,SAAA,EAAW;AAAA,QACjC;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,EAAA,CAEJ,EACF,CAAA;AAEJ,CAAC;AAED,SAAS,cAAc;"}
|
package/Title.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { AnalyticsId } from "./constants.js";
|
|
5
5
|
import titleStyles from "./components/Title/styles.module.scss";
|
|
6
|
-
const Title =
|
|
6
|
+
const Title = React__default.forwardRef(function TitleForwardedRef(props, ref) {
|
|
7
7
|
const { id, children, className, htmlMarkup = "h1", appearance = "title1", margin = 0, testId } = props;
|
|
8
8
|
const titleClasses = classNames(
|
|
9
9
|
titleStyles.title,
|
package/Title.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Title.js","sources":["../src/components/Title/Title.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\n\nimport titleStyles from './styles.module.scss';\n\nexport type TitleTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';\nexport type TitleAppearances = 'titleFeature' | 'title1' | 'title2' | 'title3' | 'title4' | 'title5' | 'title6';\n\nexport interface TitleProps {\n children: React.ReactNode;\n /** Gives a unique id to the title */\n id?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds top and bottom margin in rem. */\n margin?: number | TitleMargin;\n /** Changes the underlying element of the title. */\n htmlMarkup?: TitleTags;\n /** Changes the appearance of the title. */\n appearance?: TitleAppearances;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Title = React.forwardRef(function TitleForwardedRef(props: TitleProps, ref: React.ForwardedRef<HTMLHeadingElement>) {\n const { id, children, className, htmlMarkup = 'h1', appearance = 'title1', margin = 0, testId } = props;\n const titleClasses = classNames(\n titleStyles.title,\n {\n [titleStyles['title--feature']]: appearance === 'titleFeature',\n [titleStyles['title--title1']]: appearance === 'title1',\n [titleStyles['title--title2']]: appearance === 'title2',\n [titleStyles['title--title3']]: appearance === 'title3',\n [titleStyles['title--title4']]: appearance === 'title4',\n [titleStyles['title--title5']]: appearance === 'title5',\n [titleStyles['title--title6']]: appearance === 'title6',\n },\n className\n );\n const CustomTag = htmlMarkup;\n\n const inlineStyle = instanceOfTitleMargin(margin)\n ? { marginTop: `${margin.marginTop}rem`, marginBottom: `${margin.marginBottom}rem` }\n : { marginTop: `${margin}rem`, marginBottom: `${margin}rem` };\n\n return (\n <CustomTag id={id} className={titleClasses} style={inlineStyle} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Title}>\n {children}\n </CustomTag>\n );\n});\n\nexport interface TitleMargin {\n marginTop: number;\n marginBottom: number;\n}\n\nexport const instanceOfTitleMargin = (margin: unknown): margin is TitleMargin => {\n return Object.prototype.hasOwnProperty.call(margin, 'marginTop') && Object.prototype.hasOwnProperty.call(margin, 'marginBottom');\n};\n\nexport default Title;\n"],"names":[],"mappings":";;;;;AA2BO,MAAM,
|
|
1
|
+
{"version":3,"file":"Title.js","sources":["../src/components/Title/Title.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\n\nimport titleStyles from './styles.module.scss';\n\nexport type TitleTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';\nexport type TitleAppearances = 'titleFeature' | 'title1' | 'title2' | 'title3' | 'title4' | 'title5' | 'title6';\n\nexport interface TitleProps {\n children: React.ReactNode;\n /** Gives a unique id to the title */\n id?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds top and bottom margin in rem. */\n margin?: number | TitleMargin;\n /** Changes the underlying element of the title. */\n htmlMarkup?: TitleTags;\n /** Changes the appearance of the title. */\n appearance?: TitleAppearances;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Title = React.forwardRef(function TitleForwardedRef(props: TitleProps, ref: React.ForwardedRef<HTMLHeadingElement>) {\n const { id, children, className, htmlMarkup = 'h1', appearance = 'title1', margin = 0, testId } = props;\n const titleClasses = classNames(\n titleStyles.title,\n {\n [titleStyles['title--feature']]: appearance === 'titleFeature',\n [titleStyles['title--title1']]: appearance === 'title1',\n [titleStyles['title--title2']]: appearance === 'title2',\n [titleStyles['title--title3']]: appearance === 'title3',\n [titleStyles['title--title4']]: appearance === 'title4',\n [titleStyles['title--title5']]: appearance === 'title5',\n [titleStyles['title--title6']]: appearance === 'title6',\n },\n className\n );\n const CustomTag = htmlMarkup;\n\n const inlineStyle = instanceOfTitleMargin(margin)\n ? { marginTop: `${margin.marginTop}rem`, marginBottom: `${margin.marginBottom}rem` }\n : { marginTop: `${margin}rem`, marginBottom: `${margin}rem` };\n\n return (\n <CustomTag id={id} className={titleClasses} style={inlineStyle} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Title}>\n {children}\n </CustomTag>\n );\n});\n\nexport interface TitleMargin {\n marginTop: number;\n marginBottom: number;\n}\n\nexport const instanceOfTitleMargin = (margin: unknown): margin is TitleMargin => {\n return Object.prototype.hasOwnProperty.call(margin, 'marginTop') && Object.prototype.hasOwnProperty.call(margin, 'marginBottom');\n};\n\nexport default Title;\n"],"names":["React"],"mappings":";;;;;AA2BO,MAAM,QAAQA,eAAM,WAAW,SAAS,kBAAkB,OAAmB,KAA6C;AACzH,QAAA,EAAE,IAAI,UAAU,WAAW,aAAa,MAAM,aAAa,UAAU,SAAS,GAAG,OAAW,IAAA;AAClG,QAAM,eAAe;AAAA,IACnB,YAAY;AAAA,IACZ;AAAA,MACE,CAAC,YAAY,gBAAgB,CAAC,GAAG,eAAe;AAAA,MAChD,CAAC,YAAY,eAAe,CAAC,GAAG,eAAe;AAAA,MAC/C,CAAC,YAAY,eAAe,CAAC,GAAG,eAAe;AAAA,MAC/C,CAAC,YAAY,eAAe,CAAC,GAAG,eAAe;AAAA,MAC/C,CAAC,YAAY,eAAe,CAAC,GAAG,eAAe;AAAA,MAC/C,CAAC,YAAY,eAAe,CAAC,GAAG,eAAe;AAAA,MAC/C,CAAC,YAAY,eAAe,CAAC,GAAG,eAAe;AAAA,IACjD;AAAA,IACA;AAAA,EACF;AACA,QAAM,YAAY;AAEZ,QAAA,cAAc,sBAAsB,MAAM,IAC5C,EAAE,WAAW,GAAG,OAAO,SAAS,OAAO,cAAc,GAAG,OAAO,YAAY,MAAA,IAC3E,EAAE,WAAW,GAAG,MAAM,OAAO,cAAc,GAAG,MAAM,MAAM;AAE9D,SACG,oBAAA,WAAA,EAAU,IAAQ,WAAW,cAAc,OAAO,aAAa,KAAU,eAAa,QAAQ,oBAAkB,YAAY,OAC1H,UACH;AAEJ,CAAC;AAOY,MAAA,wBAAwB,CAAC,WAA2C;AAC/E,SAAO,OAAO,UAAU,eAAe,KAAK,QAAQ,WAAW,KAAK,OAAO,UAAU,eAAe,KAAK,QAAQ,cAAc;AACjI;"}
|
package/TooltipWord.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default from "react";
|
|
3
3
|
import { AnalyticsId } from "./constants.js";
|
|
4
4
|
import styles from "./components/Tooltip/TooltipWord/styles.module.scss";
|
|
5
|
-
const TooltipWord =
|
|
5
|
+
const TooltipWord = React__default.forwardRef(
|
|
6
6
|
({ children, onClick, onFocus, onBlur, onKeyDown, testId, ariaDescribedById }, ref) => /* @__PURE__ */ jsx(
|
|
7
7
|
"button",
|
|
8
8
|
{
|
package/TooltipWord.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipWord.js","sources":["../src/components/Tooltip/TooltipWord/TooltipWord.tsx"],"sourcesContent":["import React from 'react';\n\nimport { AnalyticsId } from '../../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface TooltipWordProps {\n /** Ordet som skal ha en tilhørende tooltip */\n children: string;\n /** Callback når ordet klikkes på */\n onClick: () => void;\n /** Callback når ordet får fokus eller hovres over */\n onFocus: () => void;\n /** Callback når ordet mister fokus eller hover forsvinner */\n onBlur: () => void;\n /** Callback når det skrives på tastaturet */\n onKeyDown: (e: React.KeyboardEvent<HTMLSpanElement>) => void;\n /** ID til element som beskriver ordet */\n ariaDescribedById: string;\n /** Valgfri test-id */\n testId?: string;\n}\n\nconst TooltipWord = React.forwardRef<HTMLButtonElement, TooltipWordProps>(\n ({ children, onClick, onFocus, onBlur, onKeyDown, testId, ariaDescribedById }, ref) => (\n <button\n className={styles.word}\n ref={ref}\n onClick={onClick}\n onMouseEnter={onFocus}\n onMouseLeave={onBlur}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n aria-describedby={ariaDescribedById}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Tooltip}\n >\n {children}\n </button>\n )\n);\n\nTooltipWord.displayName = 'TooltipWord';\n\nexport default TooltipWord;\n"],"names":[],"mappings":";;;;AAuBA,MAAM,
|
|
1
|
+
{"version":3,"file":"TooltipWord.js","sources":["../src/components/Tooltip/TooltipWord/TooltipWord.tsx"],"sourcesContent":["import React from 'react';\n\nimport { AnalyticsId } from '../../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface TooltipWordProps {\n /** Ordet som skal ha en tilhørende tooltip */\n children: string;\n /** Callback når ordet klikkes på */\n onClick: () => void;\n /** Callback når ordet får fokus eller hovres over */\n onFocus: () => void;\n /** Callback når ordet mister fokus eller hover forsvinner */\n onBlur: () => void;\n /** Callback når det skrives på tastaturet */\n onKeyDown: (e: React.KeyboardEvent<HTMLSpanElement>) => void;\n /** ID til element som beskriver ordet */\n ariaDescribedById: string;\n /** Valgfri test-id */\n testId?: string;\n}\n\nconst TooltipWord = React.forwardRef<HTMLButtonElement, TooltipWordProps>(\n ({ children, onClick, onFocus, onBlur, onKeyDown, testId, ariaDescribedById }, ref) => (\n <button\n className={styles.word}\n ref={ref}\n onClick={onClick}\n onMouseEnter={onFocus}\n onMouseLeave={onBlur}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n aria-describedby={ariaDescribedById}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Tooltip}\n >\n {children}\n </button>\n )\n);\n\nTooltipWord.displayName = 'TooltipWord';\n\nexport default TooltipWord;\n"],"names":["React"],"mappings":";;;;AAuBA,MAAM,cAAcA,eAAM;AAAA,EACxB,CAAC,EAAE,UAAU,SAAS,SAAS,QAAQ,WAAW,QAAQ,qBAAqB,QAC7E;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,OAAO;AAAA,MAClB;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA,oBAAkB;AAAA,MAClB,eAAa;AAAA,MACb,oBAAkB,YAAY;AAAA,MAE7B;AAAA,IAAA;AAAA,EAAA;AAGP;AAEA,YAAY,cAAc;"}
|
package/Trigger.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { g as getIcon, I as Icon } from "./Icon.js";
|
|
5
|
-
import {
|
|
5
|
+
import { AnalyticsId, IconSize } from "./constants.js";
|
|
6
6
|
import { useHover } from "./hooks/useHover.js";
|
|
7
7
|
import { getColor } from "./theme/currys/color.js";
|
|
8
8
|
import { getAriaLabelAttributes } from "./utils/accessibility.js";
|
|
@@ -35,7 +35,7 @@ const getIconColor = (onColor, variant, isActive) => {
|
|
|
35
35
|
return getColor("blueberry", depth);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
const Trigger =
|
|
38
|
+
const Trigger = React__default.forwardRef(
|
|
39
39
|
({
|
|
40
40
|
ariaLabel,
|
|
41
41
|
ariaLabelledById,
|
package/Trigger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Trigger.js","sources":["../src/components/Trigger/HelpSign.tsx","../src/components/Trigger/Trigger.tsx"],"sourcesContent":["import React from 'react';\n\nimport { getIcon, SvgPathProps } from '../Icon';\n\nconst HelpSign: React.FC<SvgPathProps> = ({ size, isHovered }: SvgPathProps): React.ReactElement => {\n const normal = (\n <path d=\"M18.854 19.678c0-2.268 1.701-4.74 5.126-4.74 3.358 0 5.172 2.222 5.172 4.536 0 1.793-.952 3.064-2.268 3.992l-.976.682c-.749.521-1.134 1.27-1.134 2.154 0 .047 0 .16.023.296h-2.269a46.85 46.85 0 0 0-.01-.139 8.554 8.554 0 0 1-.036-.724c0-1.36.522-2.471 1.84-3.424l1.042-.75c.75-.544 1.066-1.201 1.066-1.974 0-1.178-.793-2.29-2.45-2.29-1.679 0-2.563 1.293-2.563 2.585 0 .34.045.772.136 1.022l-2.564-.181a3.903 3.903 0 0 1-.135-1.044Zm3.176 10.186c0-.908.726-1.678 1.656-1.678.908 0 1.656.77 1.656 1.678 0 .907-.748 1.657-1.656 1.657-.93 0-1.656-.75-1.656-1.657Z\" />\n );\n\n const normalHover = (\n <path d=\"M18.854 18.178c0-2.268 1.701-4.74 5.126-4.74 3.358 0 5.172 2.223 5.172 4.536 0 1.793-.952 3.064-2.268 3.992l-.976.682c-.749.521-1.134 1.27-1.134 2.154 0 .047 0 .16.023.296h-2.269a46.85 46.85 0 0 0-.01-.139 8.554 8.554 0 0 1-.036-.724c0-1.36.522-2.471 1.838-3.424l1.044-.75c.75-.544 1.066-1.201 1.066-1.974 0-1.178-.793-2.29-2.45-2.29-1.679 0-2.563 1.293-2.563 2.585 0 .34.045.772.135 1.022l-2.563-.181a3.903 3.903 0 0 1-.135-1.044Zm3.176 11.686c0-.908.725-1.678 1.655-1.678.908 0 1.657.77 1.657 1.678 0 .907-.749 1.657-1.657 1.657-.93 0-1.655-.75-1.655-1.657Z\" />\n );\n\n const xSmall = (\n <path d=\"M23.98 14.937c-3.425 0-5.127 2.473-5.127 4.741 0 .363.047.726.137 1.044l2.563.182c-.09-.25-.136-.681-.136-1.022 0-1.292.885-2.586 2.563-2.586 1.658 0 2.45 1.112 2.45 2.291 0 .772-.317 1.43-1.065 1.974l-1.043.749c-1.317.953-1.84 2.065-1.84 3.425 0 .319.024.567.047.862h2.267c-.021-.135-.021-.25-.021-.295 0-.884.385-1.633 1.133-2.154l.976-.681c1.317-.93 2.27-2.2 2.27-3.993 0-2.314-1.816-4.537-5.174-4.537m-.294 13.248c-.93 0-1.656.773-1.656 1.678a1.65 1.65 0 0 0 1.656 1.657c.907 0 1.656-.748 1.656-1.657 0-.905-.749-1.678-1.656-1.678\" />\n );\n\n const xSmallHover = (\n <path d=\"M18.853 18.289c0-2.268 1.701-4.742 5.127-4.742 3.357 0 5.173 2.223 5.173 4.537 0 1.794-.953 3.065-2.27 3.994l-.976.681c-.747.52-1.133 1.27-1.133 2.154 0 .046 0 .16.022.295h-2.267a39.324 39.324 0 0 0-.01-.125 8.468 8.468 0 0 1-.037-.737c0-1.36.523-2.472 1.839-3.425l1.043-.75c.748-.543 1.065-1.201 1.065-1.973 0-1.18-.792-2.29-2.45-2.29-1.678 0-2.562 1.293-2.562 2.585 0 .341.045.772.135 1.022l-2.563-.183a3.914 3.914 0 0 1-.136-1.043Zm3.176 11.575c0-.907.726-1.679 1.656-1.679.908 0 1.657.772 1.657 1.68 0 .907-.749 1.656-1.657 1.656-.93 0-1.656-.749-1.656-1.657Z\" />\n );\n\n return getIcon({ size, isHovered, normal, normalHover, xSmall, xSmallHover });\n};\n\nexport default HelpSign;\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport HelpSign from './HelpSign';\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { getColor } from '../../theme/currys';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { mergeRefs } from '../../utils/refs';\nimport Icon, { SvgIcon } from '../Icon';\n\nimport styles from './styles.module.scss';\n\nexport type TriggerTags = 'button' | 'span';\n\nexport type TriggerVariant = 'help'; // @todo Support variant='info' in later version\n\nexport type TriggerSize = 'medium' | 'large';\n\nexport type TriggerOnColor = 'onlight' | 'ondark';\n\nexport interface TriggerProps extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'aria-haspopup' | 'aria-controls'> {\n /**\n * Sets aria-label of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabel?: string;\n /**\n * Sets aria-labelledby of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabelledById?: string;\n /**\n * Controls the icon and color. Default: help.\n */\n variant?: TriggerVariant;\n /**\n * Changes the design based on the background the trigger is placed on. Default: onlight.\n */\n onColor?: TriggerOnColor;\n /**\n * Size of the trigger. Default: medium.\n */\n size?: TriggerSize;\n /**\n * Indicates that the trigger is in use.\n */\n selected?: boolean;\n /**\n * Indicates that the trigger is hovered. Used in combination with htmlMarkup=span to force visual hover state.\n */\n isHovered?: boolean;\n /**\n * Changes the underlying element of the trigger. If set to span, the trigger will be a non-interactive icon. Default: button\n */\n htmlMarkup?: TriggerTags;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Optional test id.\n */\n testId?: string;\n}\n\nconst iconMap: Record<TriggerVariant, SvgIcon> = {\n help: HelpSign,\n //info: InfoSignStroke, // @todo Support variant='info' in later version\n};\n\nconst iconSizeMap: Record<TriggerSize, IconSize> = {\n medium: IconSize.XSmall,\n large: IconSize.Small,\n};\n\nconst getIconColor = (onColor: TriggerOnColor, variant: TriggerVariant, isActive: boolean): string | undefined => {\n if (onColor === 'ondark') {\n return 'white';\n }\n\n const depth = isActive ? 800 : 600;\n\n if (variant === 'help') {\n return getColor('plum', depth);\n }\n\n if (variant === 'info') {\n return getColor('blueberry', depth);\n }\n};\n\nconst Trigger = React.forwardRef<HTMLButtonElement, TriggerProps>(\n (\n {\n ariaLabel,\n ariaLabelledById,\n variant = 'help',\n onColor = 'onlight',\n size = 'medium',\n selected = false,\n isHovered,\n htmlMarkup = 'button',\n className,\n testId,\n ...rest\n },\n ref\n ) => {\n const { isHovered: buttonIsHovered, hoverRef } = useHover<HTMLButtonElement>();\n\n const triggerClasses = classNames(\n styles.trigger,\n onColor === 'onlight' && styles[`trigger--${variant}`], // variants look the same when onColor=ondark\n onColor === 'ondark' && styles[`trigger--${onColor}`],\n styles[`trigger--${size}`],\n isHovered && styles[`trigger--hovered`],\n selected && styles[`trigger--selected`],\n className\n );\n\n const iconColor = getIconColor(onColor, variant, isHovered || buttonIsHovered || selected);\n\n const icon = <Icon svgIcon={iconMap[variant]} size={iconSizeMap[size]} color={iconColor} isHovered={isHovered || buttonIsHovered} />;\n\n if (htmlMarkup === 'span') {\n return (\n <span data-testid={testId} data-analyticsid={AnalyticsId.Trigger} className={triggerClasses}>\n {icon}\n </span>\n );\n }\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });\n\n return (\n <button\n aria-label={ariaLabel}\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.Trigger}\n className={triggerClasses}\n ref={mergeRefs([ref, hoverRef])}\n aria-expanded={selected}\n {...ariaLabelAttributes}\n {...rest}\n >\n {icon}\n </button>\n );\n }\n);\n\nTrigger.displayName = 'Trigger';\n\nexport default Trigger;\n"],"names":[],"mappings":";;;;;;;;;;AAIA,MAAM,WAAmC,CAAC,EAAE,MAAM,gBAAkD;AAClG,QAAM,SACJ,oBAAC,QAAK,EAAA,GAAE,ijBAAijB,CAAA;AAG3jB,QAAM,cACJ,oBAAC,QAAK,EAAA,GAAE,kjBAAkjB,CAAA;AAG5jB,QAAM,SACJ,oBAAC,QAAK,EAAA,GAAE,yhBAAyhB,CAAA;AAGniB,QAAM,cACJ,oBAAC,QAAK,EAAA,GAAE,sjBAAsjB,CAAA;AAGzjB,SAAA,QAAQ,EAAE,MAAM,WAAW,QAAQ,aAAa,QAAQ,aAAa;AAC9E;AC2CA,MAAM,UAA2C;AAAA,EAC/C,MAAM;AAAA;AAER;AAEA,MAAM,cAA6C;AAAA,EACjD,QAAQ,SAAS;AAAA,EACjB,OAAO,SAAS;AAClB;AAEA,MAAM,eAAe,CAAC,SAAyB,SAAyB,aAA0C;AAChH,MAAI,YAAY,UAAU;AACjB,WAAA;AAAA,EAAA;AAGH,QAAA,QAAQ,WAAW,MAAM;AAE/B,MAAI,YAAY,QAAQ;AACf,WAAA,SAAS,QAAQ,KAAK;AAAA,EAAA;AAG/B,MAAI,YAAY,QAAQ;AACf,WAAA,SAAS,aAAa,KAAK;AAAA,EAAA;AAEtC;AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"Trigger.js","sources":["../src/components/Trigger/HelpSign.tsx","../src/components/Trigger/Trigger.tsx"],"sourcesContent":["import React from 'react';\n\nimport { getIcon, SvgPathProps } from '../Icon';\n\nconst HelpSign: React.FC<SvgPathProps> = ({ size, isHovered }: SvgPathProps): React.ReactElement => {\n const normal = (\n <path d=\"M18.854 19.678c0-2.268 1.701-4.74 5.126-4.74 3.358 0 5.172 2.222 5.172 4.536 0 1.793-.952 3.064-2.268 3.992l-.976.682c-.749.521-1.134 1.27-1.134 2.154 0 .047 0 .16.023.296h-2.269a46.85 46.85 0 0 0-.01-.139 8.554 8.554 0 0 1-.036-.724c0-1.36.522-2.471 1.84-3.424l1.042-.75c.75-.544 1.066-1.201 1.066-1.974 0-1.178-.793-2.29-2.45-2.29-1.679 0-2.563 1.293-2.563 2.585 0 .34.045.772.136 1.022l-2.564-.181a3.903 3.903 0 0 1-.135-1.044Zm3.176 10.186c0-.908.726-1.678 1.656-1.678.908 0 1.656.77 1.656 1.678 0 .907-.748 1.657-1.656 1.657-.93 0-1.656-.75-1.656-1.657Z\" />\n );\n\n const normalHover = (\n <path d=\"M18.854 18.178c0-2.268 1.701-4.74 5.126-4.74 3.358 0 5.172 2.223 5.172 4.536 0 1.793-.952 3.064-2.268 3.992l-.976.682c-.749.521-1.134 1.27-1.134 2.154 0 .047 0 .16.023.296h-2.269a46.85 46.85 0 0 0-.01-.139 8.554 8.554 0 0 1-.036-.724c0-1.36.522-2.471 1.838-3.424l1.044-.75c.75-.544 1.066-1.201 1.066-1.974 0-1.178-.793-2.29-2.45-2.29-1.679 0-2.563 1.293-2.563 2.585 0 .34.045.772.135 1.022l-2.563-.181a3.903 3.903 0 0 1-.135-1.044Zm3.176 11.686c0-.908.725-1.678 1.655-1.678.908 0 1.657.77 1.657 1.678 0 .907-.749 1.657-1.657 1.657-.93 0-1.655-.75-1.655-1.657Z\" />\n );\n\n const xSmall = (\n <path d=\"M23.98 14.937c-3.425 0-5.127 2.473-5.127 4.741 0 .363.047.726.137 1.044l2.563.182c-.09-.25-.136-.681-.136-1.022 0-1.292.885-2.586 2.563-2.586 1.658 0 2.45 1.112 2.45 2.291 0 .772-.317 1.43-1.065 1.974l-1.043.749c-1.317.953-1.84 2.065-1.84 3.425 0 .319.024.567.047.862h2.267c-.021-.135-.021-.25-.021-.295 0-.884.385-1.633 1.133-2.154l.976-.681c1.317-.93 2.27-2.2 2.27-3.993 0-2.314-1.816-4.537-5.174-4.537m-.294 13.248c-.93 0-1.656.773-1.656 1.678a1.65 1.65 0 0 0 1.656 1.657c.907 0 1.656-.748 1.656-1.657 0-.905-.749-1.678-1.656-1.678\" />\n );\n\n const xSmallHover = (\n <path d=\"M18.853 18.289c0-2.268 1.701-4.742 5.127-4.742 3.357 0 5.173 2.223 5.173 4.537 0 1.794-.953 3.065-2.27 3.994l-.976.681c-.747.52-1.133 1.27-1.133 2.154 0 .046 0 .16.022.295h-2.267a39.324 39.324 0 0 0-.01-.125 8.468 8.468 0 0 1-.037-.737c0-1.36.523-2.472 1.839-3.425l1.043-.75c.748-.543 1.065-1.201 1.065-1.973 0-1.18-.792-2.29-2.45-2.29-1.678 0-2.562 1.293-2.562 2.585 0 .341.045.772.135 1.022l-2.563-.183a3.914 3.914 0 0 1-.136-1.043Zm3.176 11.575c0-.907.726-1.679 1.656-1.679.908 0 1.657.772 1.657 1.68 0 .907-.749 1.656-1.657 1.656-.93 0-1.656-.749-1.656-1.657Z\" />\n );\n\n return getIcon({ size, isHovered, normal, normalHover, xSmall, xSmallHover });\n};\n\nexport default HelpSign;\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport HelpSign from './HelpSign';\nimport { AnalyticsId, IconSize } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { getColor } from '../../theme/currys';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { mergeRefs } from '../../utils/refs';\nimport Icon, { SvgIcon } from '../Icon';\n\nimport styles from './styles.module.scss';\n\nexport type TriggerTags = 'button' | 'span';\n\nexport type TriggerVariant = 'help'; // @todo Support variant='info' in later version\n\nexport type TriggerSize = 'medium' | 'large';\n\nexport type TriggerOnColor = 'onlight' | 'ondark';\n\nexport interface TriggerProps extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'aria-haspopup' | 'aria-controls'> {\n /**\n * Sets aria-label of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabel?: string;\n /**\n * Sets aria-labelledby of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabelledById?: string;\n /**\n * Controls the icon and color. Default: help.\n */\n variant?: TriggerVariant;\n /**\n * Changes the design based on the background the trigger is placed on. Default: onlight.\n */\n onColor?: TriggerOnColor;\n /**\n * Size of the trigger. Default: medium.\n */\n size?: TriggerSize;\n /**\n * Indicates that the trigger is in use.\n */\n selected?: boolean;\n /**\n * Indicates that the trigger is hovered. Used in combination with htmlMarkup=span to force visual hover state.\n */\n isHovered?: boolean;\n /**\n * Changes the underlying element of the trigger. If set to span, the trigger will be a non-interactive icon. Default: button\n */\n htmlMarkup?: TriggerTags;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Optional test id.\n */\n testId?: string;\n}\n\nconst iconMap: Record<TriggerVariant, SvgIcon> = {\n help: HelpSign,\n //info: InfoSignStroke, // @todo Support variant='info' in later version\n};\n\nconst iconSizeMap: Record<TriggerSize, IconSize> = {\n medium: IconSize.XSmall,\n large: IconSize.Small,\n};\n\nconst getIconColor = (onColor: TriggerOnColor, variant: TriggerVariant, isActive: boolean): string | undefined => {\n if (onColor === 'ondark') {\n return 'white';\n }\n\n const depth = isActive ? 800 : 600;\n\n if (variant === 'help') {\n return getColor('plum', depth);\n }\n\n if (variant === 'info') {\n return getColor('blueberry', depth);\n }\n};\n\nconst Trigger = React.forwardRef<HTMLButtonElement, TriggerProps>(\n (\n {\n ariaLabel,\n ariaLabelledById,\n variant = 'help',\n onColor = 'onlight',\n size = 'medium',\n selected = false,\n isHovered,\n htmlMarkup = 'button',\n className,\n testId,\n ...rest\n },\n ref\n ) => {\n const { isHovered: buttonIsHovered, hoverRef } = useHover<HTMLButtonElement>();\n\n const triggerClasses = classNames(\n styles.trigger,\n onColor === 'onlight' && styles[`trigger--${variant}`], // variants look the same when onColor=ondark\n onColor === 'ondark' && styles[`trigger--${onColor}`],\n styles[`trigger--${size}`],\n isHovered && styles[`trigger--hovered`],\n selected && styles[`trigger--selected`],\n className\n );\n\n const iconColor = getIconColor(onColor, variant, isHovered || buttonIsHovered || selected);\n\n const icon = <Icon svgIcon={iconMap[variant]} size={iconSizeMap[size]} color={iconColor} isHovered={isHovered || buttonIsHovered} />;\n\n if (htmlMarkup === 'span') {\n return (\n <span data-testid={testId} data-analyticsid={AnalyticsId.Trigger} className={triggerClasses}>\n {icon}\n </span>\n );\n }\n\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });\n\n return (\n <button\n aria-label={ariaLabel}\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.Trigger}\n className={triggerClasses}\n ref={mergeRefs([ref, hoverRef])}\n aria-expanded={selected}\n {...ariaLabelAttributes}\n {...rest}\n >\n {icon}\n </button>\n );\n }\n);\n\nTrigger.displayName = 'Trigger';\n\nexport default Trigger;\n"],"names":["React"],"mappings":";;;;;;;;;;AAIA,MAAM,WAAmC,CAAC,EAAE,MAAM,gBAAkD;AAClG,QAAM,SACJ,oBAAC,QAAK,EAAA,GAAE,ijBAAijB,CAAA;AAG3jB,QAAM,cACJ,oBAAC,QAAK,EAAA,GAAE,kjBAAkjB,CAAA;AAG5jB,QAAM,SACJ,oBAAC,QAAK,EAAA,GAAE,yhBAAyhB,CAAA;AAGniB,QAAM,cACJ,oBAAC,QAAK,EAAA,GAAE,sjBAAsjB,CAAA;AAGzjB,SAAA,QAAQ,EAAE,MAAM,WAAW,QAAQ,aAAa,QAAQ,aAAa;AAC9E;AC2CA,MAAM,UAA2C;AAAA,EAC/C,MAAM;AAAA;AAER;AAEA,MAAM,cAA6C;AAAA,EACjD,QAAQ,SAAS;AAAA,EACjB,OAAO,SAAS;AAClB;AAEA,MAAM,eAAe,CAAC,SAAyB,SAAyB,aAA0C;AAChH,MAAI,YAAY,UAAU;AACjB,WAAA;AAAA,EAAA;AAGH,QAAA,QAAQ,WAAW,MAAM;AAE/B,MAAI,YAAY,QAAQ;AACf,WAAA,SAAS,QAAQ,KAAK;AAAA,EAAA;AAG/B,MAAI,YAAY,QAAQ;AACf,WAAA,SAAS,aAAa,KAAK;AAAA,EAAA;AAEtC;AAEA,MAAM,UAAUA,eAAM;AAAA,EACpB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,UAAU;AAAA,IACV,OAAO;AAAA,IACP,WAAW;AAAA,IACX;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,GAAG;AAAA,KAEL,QACG;AACH,UAAM,EAAE,WAAW,iBAAiB,SAAA,IAAa,SAA4B;AAE7E,UAAM,iBAAiB;AAAA,MACrB,OAAO;AAAA,MACP,YAAY,aAAa,OAAO,YAAY,OAAO,EAAE;AAAA;AAAA,MACrD,YAAY,YAAY,OAAO,YAAY,OAAO,EAAE;AAAA,MACpD,OAAO,YAAY,IAAI,EAAE;AAAA,MACzB,aAAa,OAAO,kBAAkB;AAAA,MACtC,YAAY,OAAO,mBAAmB;AAAA,MACtC;AAAA,IACF;AAEA,UAAM,YAAY,aAAa,SAAS,SAAS,aAAa,mBAAmB,QAAQ;AAEzF,UAAM,OAAO,oBAAC,MAAK,EAAA,SAAS,QAAQ,OAAO,GAAG,MAAM,YAAY,IAAI,GAAG,OAAO,WAAW,WAAW,aAAa,iBAAiB;AAElI,QAAI,eAAe,QAAQ;AAEvB,aAAA,oBAAC,UAAK,eAAa,QAAQ,oBAAkB,YAAY,SAAS,WAAW,gBAC1E,UACH,KAAA,CAAA;AAAA,IAAA;AAIJ,UAAM,sBAAsB,uBAAuB,EAAE,OAAO,WAAW,IAAI,kBAAkB;AAG3F,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,cAAY;AAAA,QACZ,MAAK;AAAA,QACL,eAAa;AAAA,QACb,oBAAkB,YAAY;AAAA,QAC9B,WAAW;AAAA,QACX,KAAK,UAAU,CAAC,KAAK,QAAQ,CAAC;AAAA,QAC9B,iBAAe;AAAA,QACd,GAAG;AAAA,QACH,GAAG;AAAA,QAEH,UAAA;AAAA,MAAA;AAAA,IACH;AAAA,EAAA;AAGN;AAEA,QAAQ,cAAc;"}
|
|
@@ -365,6 +365,11 @@ $with-icons: // icon-class, size-class, padding-left, padding-right, padding-lef
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
@include on-dark;
|
|
368
|
+
|
|
369
|
+
@include tiny-screens-media-query {
|
|
370
|
+
min-height: getSpacer(l);
|
|
371
|
+
padding: 0 getSpacer(xs);
|
|
372
|
+
}
|
|
368
373
|
}
|
|
369
374
|
|
|
370
375
|
.diagonal {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import React__default from "react";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import { AnalyticsId } from "../../constants.js";
|
|
5
5
|
import styles from "./styles.module.scss";
|
|
6
|
-
const DictionaryTrigger =
|
|
6
|
+
const DictionaryTrigger = React__default.forwardRef(
|
|
7
7
|
({ children, selected = false, className, testId, ...rest }, ref) => {
|
|
8
8
|
const triggerClasses = classNames(styles.dictionarytrigger, className);
|
|
9
9
|
return /* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/DictionaryTrigger/DictionaryTrigger.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface DictionaryTriggerProps extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onFocus' | 'onBlur'> {\n /**\n * Sets the content of the trigger.\n */\n children: React.ReactNode;\n /**\n * Indicates that the trigger is in use.\n */\n selected?: boolean;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Sets the data-testid attribute.\n */\n testId?: string;\n}\n\nconst DictionaryTrigger = React.forwardRef<HTMLButtonElement, DictionaryTriggerProps>(\n ({ children, selected = false, className, testId, ...rest }, ref) => {\n const triggerClasses = classNames(styles.dictionarytrigger, className);\n\n return (\n <button\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.DictionaryTrigger}\n className={triggerClasses}\n aria-expanded={selected}\n ref={ref}\n {...rest}\n >\n {children}\n </button>\n );\n }\n);\n\nDictionaryTrigger.displayName = 'DictionaryTrigger';\n\nexport default DictionaryTrigger;\n"],"names":[],"mappings":";;;;;AA2BA,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/DictionaryTrigger/DictionaryTrigger.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface DictionaryTriggerProps extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onFocus' | 'onBlur'> {\n /**\n * Sets the content of the trigger.\n */\n children: React.ReactNode;\n /**\n * Indicates that the trigger is in use.\n */\n selected?: boolean;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Sets the data-testid attribute.\n */\n testId?: string;\n}\n\nconst DictionaryTrigger = React.forwardRef<HTMLButtonElement, DictionaryTriggerProps>(\n ({ children, selected = false, className, testId, ...rest }, ref) => {\n const triggerClasses = classNames(styles.dictionarytrigger, className);\n\n return (\n <button\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.DictionaryTrigger}\n className={triggerClasses}\n aria-expanded={selected}\n ref={ref}\n {...rest}\n >\n {children}\n </button>\n );\n }\n);\n\nDictionaryTrigger.displayName = 'DictionaryTrigger';\n\nexport default DictionaryTrigger;\n"],"names":["React"],"mappings":";;;;;AA2BA,MAAM,oBAAoBA,eAAM;AAAA,EAC9B,CAAC,EAAE,UAAU,WAAW,OAAO,WAAW,QAAQ,GAAG,KAAK,GAAG,QAAQ;AACnE,UAAM,iBAAiB,WAAW,OAAO,mBAAmB,SAAS;AAGnE,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,eAAa;AAAA,QACb,oBAAkB,YAAY;AAAA,QAC9B,WAAW;AAAA,QACX,iBAAe;AAAA,QACf;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IACH;AAAA,EAAA;AAGN;AAEA,kBAAkB,cAAc;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { TitleTags } from '../Title';
|
|
3
|
+
type DesktopDirections = 'left' | 'right';
|
|
4
|
+
export interface DrawerProps extends InnerDrawerProps {
|
|
5
|
+
/** Opens and closes the drawer */
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface InnerDrawerProps {
|
|
9
|
+
/** Sets the aria-label of the drawer */
|
|
10
|
+
ariaLabel?: string;
|
|
11
|
+
/** Sets the aria-labelledby of the drawer */
|
|
12
|
+
ariaLabelledBy?: string;
|
|
13
|
+
/** Close button aria-label */
|
|
14
|
+
ariaLabelCloseBtn?: string;
|
|
15
|
+
/** Direction of the drawer on desktop. Default: left */
|
|
16
|
+
desktopDirection?: DesktopDirections;
|
|
17
|
+
/** Title to display in the header of the drawer */
|
|
18
|
+
title: string;
|
|
19
|
+
/** id of the drawer title */
|
|
20
|
+
titleId?: string;
|
|
21
|
+
/** Changes the underlying element of the title. Default: h3 */
|
|
22
|
+
titleHtmlMarkup?: TitleTags;
|
|
23
|
+
/** Callback that triggers when clicking on close button or outside the drawer, update isOpen state when this triggers */
|
|
24
|
+
onRequestClose: () => void;
|
|
25
|
+
/** Optional footer content that can be rendered instead of default CTA(s) */
|
|
26
|
+
footerContent?: React.ReactNode;
|
|
27
|
+
/** Main content of the drawer */
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
/** Primary CTA callback */
|
|
30
|
+
onPrimaryAction?: () => void;
|
|
31
|
+
/** Text for primary CTA button if you want a default CTA button rendered (instead of `footerContent`) */
|
|
32
|
+
primaryActionText?: string;
|
|
33
|
+
/** Text for secondary CTA button if you want a default CTA button rendered (instead of `footerContent`) */
|
|
34
|
+
secondaryActionText?: string;
|
|
35
|
+
/** Secondary CTA callback */
|
|
36
|
+
onSecondaryAction?: () => void;
|
|
37
|
+
/** Customize the z-index of the drawer */
|
|
38
|
+
zIndex?: number;
|
|
39
|
+
}
|
|
40
|
+
declare const Drawer: React.FC<DrawerProps>;
|
|
41
|
+
export default Drawer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { createContext, useId, useRef, useContext, useInsertionEffect, useCallback, useMemo, useEffect, Children, isValidElement, useLayoutEffect, useState } from "react";
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
import { ZIndex, AnalyticsId } from "../../constants.js";
|
|
6
|
+
import { useBreakpoint } from "../../hooks/useBreakpoint.js";
|
|
7
|
+
import { useFocusTrap } from "../../hooks/useFocusTrap.js";
|
|
8
|
+
import { useOutsideEvent } from "../../hooks/useOutsideEvent.js";
|
|
9
|
+
import { useReturnFocusOnUnmount } from "../../hooks/useReturnFocusOnUnmount.js";
|
|
10
|
+
import { breakpoints } from "../../theme/grid.js";
|
|
11
|
+
import { getAriaLabelAttributes } from "../../utils/accessibility.js";
|
|
12
|
+
import { u as uuid } from "../../uuid.js";
|
|
13
|
+
import { B as Button } from "../../Button.js";
|
|
14
|
+
import { C as Close } from "../../Close.js";
|
|
15
|
+
import { T as Title } from "../../Title.js";
|
|
16
|
+
import styles from "./styles.module.scss";
|
|
17
|
+
import { a as useConstant, i as isBrowser, u as useAnimate } from "../../use-animate.js";
|
|
18
|
+
const LayoutGroupContext = createContext({});
|
|
19
|
+
const PresenceContext = createContext(null);
|
|
20
|
+
const MotionConfigContext = createContext({
|
|
21
|
+
transformPagePoint: (p) => p,
|
|
22
|
+
isStatic: false,
|
|
23
|
+
reducedMotion: "never"
|
|
24
|
+
});
|
|
25
|
+
class PopChildMeasure extends React.Component {
|
|
26
|
+
getSnapshotBeforeUpdate(prevProps) {
|
|
27
|
+
const element = this.props.childRef.current;
|
|
28
|
+
if (element && prevProps.isPresent && !this.props.isPresent) {
|
|
29
|
+
const size = this.props.sizeRef.current;
|
|
30
|
+
size.height = element.offsetHeight || 0;
|
|
31
|
+
size.width = element.offsetWidth || 0;
|
|
32
|
+
size.top = element.offsetTop;
|
|
33
|
+
size.left = element.offsetLeft;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Required with getSnapshotBeforeUpdate to stop React complaining.
|
|
39
|
+
*/
|
|
40
|
+
componentDidUpdate() {
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
return this.props.children;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function PopChild({ children, isPresent }) {
|
|
47
|
+
const id = useId();
|
|
48
|
+
const ref = useRef(null);
|
|
49
|
+
const size = useRef({
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0,
|
|
52
|
+
top: 0,
|
|
53
|
+
left: 0
|
|
54
|
+
});
|
|
55
|
+
const { nonce } = useContext(MotionConfigContext);
|
|
56
|
+
useInsertionEffect(() => {
|
|
57
|
+
const { width, height, top, left } = size.current;
|
|
58
|
+
if (isPresent || !ref.current || !width || !height)
|
|
59
|
+
return;
|
|
60
|
+
ref.current.dataset.motionPopId = id;
|
|
61
|
+
const style = document.createElement("style");
|
|
62
|
+
if (nonce)
|
|
63
|
+
style.nonce = nonce;
|
|
64
|
+
document.head.appendChild(style);
|
|
65
|
+
if (style.sheet) {
|
|
66
|
+
style.sheet.insertRule(`
|
|
67
|
+
[data-motion-pop-id="${id}"] {
|
|
68
|
+
position: absolute !important;
|
|
69
|
+
width: ${width}px !important;
|
|
70
|
+
height: ${height}px !important;
|
|
71
|
+
top: ${top}px !important;
|
|
72
|
+
left: ${left}px !important;
|
|
73
|
+
}
|
|
74
|
+
`);
|
|
75
|
+
}
|
|
76
|
+
return () => {
|
|
77
|
+
document.head.removeChild(style);
|
|
78
|
+
};
|
|
79
|
+
}, [isPresent]);
|
|
80
|
+
return jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, children: React.cloneElement(children, { ref }) });
|
|
81
|
+
}
|
|
82
|
+
const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode }) => {
|
|
83
|
+
const presenceChildren = useConstant(newChildrenMap);
|
|
84
|
+
const id = useId();
|
|
85
|
+
const memoizedOnExitComplete = useCallback((childId) => {
|
|
86
|
+
presenceChildren.set(childId, true);
|
|
87
|
+
for (const isComplete of presenceChildren.values()) {
|
|
88
|
+
if (!isComplete)
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
onExitComplete && onExitComplete();
|
|
92
|
+
}, [presenceChildren, onExitComplete]);
|
|
93
|
+
const context = useMemo(
|
|
94
|
+
() => ({
|
|
95
|
+
id,
|
|
96
|
+
initial,
|
|
97
|
+
isPresent,
|
|
98
|
+
custom,
|
|
99
|
+
onExitComplete: memoizedOnExitComplete,
|
|
100
|
+
register: (childId) => {
|
|
101
|
+
presenceChildren.set(childId, false);
|
|
102
|
+
return () => presenceChildren.delete(childId);
|
|
103
|
+
}
|
|
104
|
+
}),
|
|
105
|
+
/**
|
|
106
|
+
* If the presence of a child affects the layout of the components around it,
|
|
107
|
+
* we want to make a new context value to ensure they get re-rendered
|
|
108
|
+
* so they can detect that layout change.
|
|
109
|
+
*/
|
|
110
|
+
presenceAffectsLayout ? [Math.random(), memoizedOnExitComplete] : [isPresent, memoizedOnExitComplete]
|
|
111
|
+
);
|
|
112
|
+
useMemo(() => {
|
|
113
|
+
presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
|
|
114
|
+
}, [isPresent]);
|
|
115
|
+
React.useEffect(() => {
|
|
116
|
+
!isPresent && !presenceChildren.size && onExitComplete && onExitComplete();
|
|
117
|
+
}, [isPresent]);
|
|
118
|
+
if (mode === "popLayout") {
|
|
119
|
+
children = jsx(PopChild, { isPresent, children });
|
|
120
|
+
}
|
|
121
|
+
return jsx(PresenceContext.Provider, { value: context, children });
|
|
122
|
+
};
|
|
123
|
+
function newChildrenMap() {
|
|
124
|
+
return /* @__PURE__ */ new Map();
|
|
125
|
+
}
|
|
126
|
+
function usePresence(subscribe = true) {
|
|
127
|
+
const context = useContext(PresenceContext);
|
|
128
|
+
if (context === null)
|
|
129
|
+
return [true, null];
|
|
130
|
+
const { isPresent, onExitComplete, register } = context;
|
|
131
|
+
const id = useId();
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (subscribe)
|
|
134
|
+
register(id);
|
|
135
|
+
}, [subscribe]);
|
|
136
|
+
const safeToRemove = useCallback(() => subscribe && onExitComplete && onExitComplete(id), [id, onExitComplete, subscribe]);
|
|
137
|
+
return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
|
|
138
|
+
}
|
|
139
|
+
const getChildKey = (child) => child.key || "";
|
|
140
|
+
function onlyElements(children) {
|
|
141
|
+
const filtered = [];
|
|
142
|
+
Children.forEach(children, (child) => {
|
|
143
|
+
if (isValidElement(child))
|
|
144
|
+
filtered.push(child);
|
|
145
|
+
});
|
|
146
|
+
return filtered;
|
|
147
|
+
}
|
|
148
|
+
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
|
|
149
|
+
const AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = "sync", propagate = false }) => {
|
|
150
|
+
const [isParentPresent, safeToRemove] = usePresence(propagate);
|
|
151
|
+
const presentChildren = useMemo(() => onlyElements(children), [children]);
|
|
152
|
+
const presentKeys = propagate && !isParentPresent ? [] : presentChildren.map(getChildKey);
|
|
153
|
+
const isInitialRender = useRef(true);
|
|
154
|
+
const pendingPresentChildren = useRef(presentChildren);
|
|
155
|
+
const exitComplete = useConstant(() => /* @__PURE__ */ new Map());
|
|
156
|
+
const [diffedChildren, setDiffedChildren] = useState(presentChildren);
|
|
157
|
+
const [renderedChildren, setRenderedChildren] = useState(presentChildren);
|
|
158
|
+
useIsomorphicLayoutEffect(() => {
|
|
159
|
+
isInitialRender.current = false;
|
|
160
|
+
pendingPresentChildren.current = presentChildren;
|
|
161
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
162
|
+
const key = getChildKey(renderedChildren[i]);
|
|
163
|
+
if (!presentKeys.includes(key)) {
|
|
164
|
+
if (exitComplete.get(key) !== true) {
|
|
165
|
+
exitComplete.set(key, false);
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
exitComplete.delete(key);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
|
|
172
|
+
const exitingChildren = [];
|
|
173
|
+
if (presentChildren !== diffedChildren) {
|
|
174
|
+
let nextChildren = [...presentChildren];
|
|
175
|
+
for (let i = 0; i < renderedChildren.length; i++) {
|
|
176
|
+
const child = renderedChildren[i];
|
|
177
|
+
const key = getChildKey(child);
|
|
178
|
+
if (!presentKeys.includes(key)) {
|
|
179
|
+
nextChildren.splice(i, 0, child);
|
|
180
|
+
exitingChildren.push(child);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (mode === "wait" && exitingChildren.length) {
|
|
184
|
+
nextChildren = exitingChildren;
|
|
185
|
+
}
|
|
186
|
+
setRenderedChildren(onlyElements(nextChildren));
|
|
187
|
+
setDiffedChildren(presentChildren);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (process.env.NODE_ENV !== "production" && mode === "wait" && renderedChildren.length > 1) {
|
|
191
|
+
console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
|
|
192
|
+
}
|
|
193
|
+
const { forceRender } = useContext(LayoutGroupContext);
|
|
194
|
+
return jsx(Fragment, { children: renderedChildren.map((child) => {
|
|
195
|
+
const key = getChildKey(child);
|
|
196
|
+
const isPresent = propagate && !isParentPresent ? false : presentChildren === renderedChildren || presentKeys.includes(key);
|
|
197
|
+
const onExit = () => {
|
|
198
|
+
if (exitComplete.has(key)) {
|
|
199
|
+
exitComplete.set(key, true);
|
|
200
|
+
} else {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
let isEveryExitComplete = true;
|
|
204
|
+
exitComplete.forEach((isExitComplete) => {
|
|
205
|
+
if (!isExitComplete)
|
|
206
|
+
isEveryExitComplete = false;
|
|
207
|
+
});
|
|
208
|
+
if (isEveryExitComplete) {
|
|
209
|
+
forceRender === null || forceRender === void 0 ? void 0 : forceRender();
|
|
210
|
+
setRenderedChildren(pendingPresentChildren.current);
|
|
211
|
+
propagate && (safeToRemove === null || safeToRemove === void 0 ? void 0 : safeToRemove());
|
|
212
|
+
onExitComplete && onExitComplete();
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
return jsx(PresenceChild, { isPresent, initial: !isInitialRender.current || initial ? void 0 : false, custom: isPresent ? void 0 : custom, presenceAffectsLayout, mode, onExitComplete: isPresent ? void 0 : onExit, children: child }, key);
|
|
216
|
+
}) });
|
|
217
|
+
};
|
|
218
|
+
const Drawer = (props) => {
|
|
219
|
+
const { isOpen, ...rest } = props;
|
|
220
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(InnerDrawer, { ...rest }) });
|
|
221
|
+
};
|
|
222
|
+
const InnerDrawer = (props) => {
|
|
223
|
+
const {
|
|
224
|
+
ariaLabel,
|
|
225
|
+
ariaLabelledBy,
|
|
226
|
+
ariaLabelCloseBtn,
|
|
227
|
+
children,
|
|
228
|
+
desktopDirection = "left",
|
|
229
|
+
footerContent,
|
|
230
|
+
onPrimaryAction,
|
|
231
|
+
onRequestClose,
|
|
232
|
+
onSecondaryAction,
|
|
233
|
+
primaryActionText,
|
|
234
|
+
secondaryActionText,
|
|
235
|
+
title,
|
|
236
|
+
titleHtmlMarkup = "h3",
|
|
237
|
+
titleId = uuid(),
|
|
238
|
+
zIndex = ZIndex.Modal
|
|
239
|
+
} = props;
|
|
240
|
+
const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledBy, fallbackId: titleId });
|
|
241
|
+
const overlayRef = useRef(null);
|
|
242
|
+
const containerRef = useRef(null);
|
|
243
|
+
const contentRef = useRef(null);
|
|
244
|
+
const breakpoint = useBreakpoint();
|
|
245
|
+
const isMobile = breakpoint < breakpoints.md;
|
|
246
|
+
const [scope, animate] = useAnimate();
|
|
247
|
+
const [isPresent, safeToRemove] = usePresence();
|
|
248
|
+
const contentIsScrollable = contentRef.current && contentRef.current.scrollHeight > contentRef.current.clientHeight;
|
|
249
|
+
useFocusTrap(containerRef, true);
|
|
250
|
+
useReturnFocusOnUnmount(containerRef);
|
|
251
|
+
useOutsideEvent(containerRef, () => {
|
|
252
|
+
onRequestClose && onRequestClose();
|
|
253
|
+
});
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
var _a;
|
|
256
|
+
(_a = containerRef.current) == null ? void 0 : _a.focus();
|
|
257
|
+
}, []);
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
if (!overlayRef.current || !containerRef.current) return;
|
|
260
|
+
if (!isPresent) {
|
|
261
|
+
closeDrawer();
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (isMobile) {
|
|
265
|
+
animate(containerRef.current, { y: "0" }, { duration: 0.3, ease: "easeInOut" });
|
|
266
|
+
} else {
|
|
267
|
+
animate(containerRef.current, { x: "0" }, { duration: 0.3, ease: "easeInOut" });
|
|
268
|
+
}
|
|
269
|
+
animate(overlayRef.current, { opacity: 1, pointerEvents: "auto" }, { duration: 0.3, ease: "easeInOut" });
|
|
270
|
+
}, [isPresent]);
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
}, [isPresent]);
|
|
273
|
+
const closeDrawer = () => {
|
|
274
|
+
if (!overlayRef.current || !containerRef.current) return;
|
|
275
|
+
animate(overlayRef.current, { opacity: 0, pointerEvents: "none" }, { duration: 0.3, ease: "easeInOut" });
|
|
276
|
+
if (isMobile) {
|
|
277
|
+
animate(
|
|
278
|
+
containerRef.current,
|
|
279
|
+
{ y: "100%" },
|
|
280
|
+
{
|
|
281
|
+
duration: 0.3,
|
|
282
|
+
ease: "easeInOut",
|
|
283
|
+
onComplete: () => {
|
|
284
|
+
safeToRemove && safeToRemove();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
} else {
|
|
289
|
+
animate(
|
|
290
|
+
containerRef.current,
|
|
291
|
+
{ x: desktopDirection === "left" ? "-100%" : "100%" },
|
|
292
|
+
{
|
|
293
|
+
duration: 0.3,
|
|
294
|
+
ease: "easeInOut",
|
|
295
|
+
onComplete: () => {
|
|
296
|
+
safeToRemove && safeToRemove();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
const handleCTA = (callback) => {
|
|
303
|
+
if (callback) {
|
|
304
|
+
callback();
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.drawer, ref: scope, style: { zIndex }, "data-analyticsid": AnalyticsId.Drawer, children: [
|
|
308
|
+
/* @__PURE__ */ jsx("div", { className: styles.drawer__overlay, ref: overlayRef, "aria-hidden": "true" }),
|
|
309
|
+
/* @__PURE__ */ jsxs(
|
|
310
|
+
"div",
|
|
311
|
+
{
|
|
312
|
+
className: classNames(styles.drawer__container, {
|
|
313
|
+
[styles["drawer__container--right"]]: desktopDirection === "right"
|
|
314
|
+
}),
|
|
315
|
+
ref: containerRef,
|
|
316
|
+
role: "dialog",
|
|
317
|
+
"aria-modal": "true",
|
|
318
|
+
tabIndex: -1,
|
|
319
|
+
...ariaLabelAttributes,
|
|
320
|
+
children: [
|
|
321
|
+
/* @__PURE__ */ jsxs("div", { className: styles.drawer__container__inner, children: [
|
|
322
|
+
/* @__PURE__ */ jsxs("div", { className: styles.drawer__header, children: [
|
|
323
|
+
/* @__PURE__ */ jsx(Title, { id: ariaLabelAttributes == null ? void 0 : ariaLabelAttributes["aria-labelledby"], htmlMarkup: titleHtmlMarkup, appearance: "title3", children: title }),
|
|
324
|
+
/* @__PURE__ */ jsx(Close, { ariaLabel: ariaLabelCloseBtn, onClick: onRequestClose, small: isMobile })
|
|
325
|
+
] }),
|
|
326
|
+
/* @__PURE__ */ jsx(
|
|
327
|
+
"div",
|
|
328
|
+
{
|
|
329
|
+
className: styles.drawer__content,
|
|
330
|
+
tabIndex: contentIsScrollable ? 0 : void 0,
|
|
331
|
+
role: contentIsScrollable ? "region" : void 0,
|
|
332
|
+
...contentIsScrollable ? ariaLabelAttributes : {},
|
|
333
|
+
ref: contentRef,
|
|
334
|
+
children
|
|
335
|
+
}
|
|
336
|
+
)
|
|
337
|
+
] }),
|
|
338
|
+
/* @__PURE__ */ jsx("div", { className: styles.drawer__footer, children: footerContent ? footerContent : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
339
|
+
primaryActionText && /* @__PURE__ */ jsx(Button, { onClick: () => handleCTA(onPrimaryAction), children: primaryActionText }),
|
|
340
|
+
secondaryActionText && /* @__PURE__ */ jsx(Button, { variant: "borderless", onClick: () => handleCTA(onSecondaryAction), children: secondaryActionText })
|
|
341
|
+
] }) })
|
|
342
|
+
]
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
] });
|
|
346
|
+
};
|
|
347
|
+
export {
|
|
348
|
+
Drawer as default
|
|
349
|
+
};
|
|
350
|
+
//# sourceMappingURL=index.js.map
|