@simplybusiness/mobius 10.4.2 → 10.4.4
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/CHANGELOG.md +17 -0
- package/dist/cjs/components/AddressLookup/AddressLookup.js +39 -36
- package/dist/cjs/components/AddressLookup/AddressLookup.js.map +3 -3
- package/dist/cjs/components/AddressLookup/index.js +39 -36
- package/dist/cjs/components/AddressLookup/index.js.map +3 -3
- package/dist/cjs/components/Breadcrumbs/Breadcrumbs.js +3 -7
- package/dist/cjs/components/Breadcrumbs/Breadcrumbs.js.map +2 -2
- package/dist/cjs/components/Breadcrumbs/index.js +3 -7
- package/dist/cjs/components/Breadcrumbs/index.js.map +2 -2
- package/dist/cjs/components/Combobox/Combobox.js +35 -32
- package/dist/cjs/components/Combobox/Combobox.js.map +3 -3
- package/dist/cjs/components/Combobox/index.js +35 -32
- package/dist/cjs/components/Combobox/index.js.map +3 -3
- package/dist/cjs/components/DateField/DateField.js +11 -8
- package/dist/cjs/components/DateField/DateField.js.map +3 -3
- package/dist/cjs/components/DateField/index.js +11 -8
- package/dist/cjs/components/DateField/index.js.map +3 -3
- package/dist/cjs/components/DropdownMenu/Item.js +3 -6
- package/dist/cjs/components/DropdownMenu/Item.js.map +2 -2
- package/dist/cjs/components/DropdownMenu/index.js +3 -6
- package/dist/cjs/components/DropdownMenu/index.js.map +2 -2
- package/dist/cjs/components/MaskedField/MaskedField.js +11 -8
- package/dist/cjs/components/MaskedField/MaskedField.js.map +3 -3
- package/dist/cjs/components/MaskedField/index.js +13 -10
- package/dist/cjs/components/MaskedField/index.js.map +3 -3
- package/dist/cjs/components/NumberField/NumberField.js +10 -7
- package/dist/cjs/components/NumberField/NumberField.js.map +3 -3
- package/dist/cjs/components/NumberField/index.js +10 -7
- package/dist/cjs/components/NumberField/index.js.map +3 -3
- package/dist/cjs/components/PasswordField/PasswordField.js +9 -6
- package/dist/cjs/components/PasswordField/PasswordField.js.map +3 -3
- package/dist/cjs/components/PasswordField/index.js +9 -6
- package/dist/cjs/components/PasswordField/index.js.map +3 -3
- package/dist/cjs/components/Popover/Arrow.js +43 -0
- package/dist/cjs/components/Popover/Arrow.js.map +7 -0
- package/dist/cjs/components/Popover/Popover.js +258 -83
- package/dist/cjs/components/Popover/Popover.js.map +4 -4
- package/dist/cjs/components/Popover/index.js +258 -83
- package/dist/cjs/components/Popover/index.js.map +4 -4
- package/dist/cjs/components/Popover/useAutoUpdate.js +53 -0
- package/dist/cjs/components/Popover/useAutoUpdate.js.map +7 -0
- package/dist/cjs/components/Popover/useFloatingPosition.js +128 -0
- package/dist/cjs/components/Popover/useFloatingPosition.js.map +7 -0
- package/dist/cjs/components/Popover/useOutsidePress.js +46 -0
- package/dist/cjs/components/Popover/useOutsidePress.js.map +7 -0
- package/dist/cjs/components/TextField/TextField.js +6 -3
- package/dist/cjs/components/TextField/TextField.js.map +3 -3
- package/dist/cjs/components/TextField/adornmentWithClassName.js +3 -2
- package/dist/cjs/components/TextField/adornmentWithClassName.js.map +2 -2
- package/dist/cjs/components/TextField/index.js +6 -3
- package/dist/cjs/components/TextField/index.js.map +3 -3
- package/dist/cjs/components/index.js +550 -377
- package/dist/cjs/components/index.js.map +4 -4
- package/dist/cjs/index.js +550 -377
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/meta.json +490 -121
- package/dist/esm/chunk-26KZYRE6.js +108 -0
- package/dist/esm/chunk-26KZYRE6.js.map +7 -0
- package/dist/esm/{chunk-XNEQHHNV.js → chunk-5QMKPWB4.js} +2 -2
- package/dist/esm/{chunk-IQKS662C.js → chunk-6RDK3FM2.js} +5 -3
- package/dist/esm/chunk-6RDK3FM2.js.map +7 -0
- package/dist/esm/{chunk-4HI2AOBC.js → chunk-6TSYA7CJ.js} +4 -7
- package/dist/esm/{chunk-4HI2AOBC.js.map → chunk-6TSYA7CJ.js.map} +2 -2
- package/dist/esm/chunk-CAL44W47.js +23 -0
- package/dist/esm/chunk-CAL44W47.js.map +7 -0
- package/dist/esm/{chunk-PEEQNAIN.js → chunk-DMYDWKKA.js} +4 -4
- package/dist/esm/{chunk-IM3I5CZL.js → chunk-I6CFRGID.js} +4 -3
- package/dist/esm/{chunk-IM3I5CZL.js.map → chunk-I6CFRGID.js.map} +2 -2
- package/dist/esm/chunk-K3ECDAUR.js +33 -0
- package/dist/esm/chunk-K3ECDAUR.js.map +7 -0
- package/dist/esm/{chunk-GJBH37DH.js → chunk-KFHPI67N.js} +4 -4
- package/dist/esm/{chunk-OEDU5ZEA.js → chunk-KUH5AB5T.js} +2 -2
- package/dist/esm/{chunk-JFDDW3IV.js → chunk-P7TPNRU4.js} +4 -8
- package/dist/esm/{chunk-JFDDW3IV.js.map → chunk-P7TPNRU4.js.map} +2 -2
- package/dist/esm/{chunk-F5ELD54X.js → chunk-QNOBB5HT.js} +2 -2
- package/dist/esm/{chunk-GV36OVX7.js → chunk-R67C5QTH.js} +2 -2
- package/dist/esm/{chunk-S4CU4XRB.js → chunk-VGFVSRWH.js} +2 -2
- package/dist/esm/chunk-VZ3IWSK6.js +158 -0
- package/dist/esm/chunk-VZ3IWSK6.js.map +7 -0
- package/dist/esm/{chunk-X4CMSAET.js → chunk-WSQWMVA2.js} +2 -2
- package/dist/esm/chunk-WYJP7HVL.js +26 -0
- package/dist/esm/chunk-WYJP7HVL.js.map +7 -0
- package/dist/esm/{chunk-OAG5T7NC.js → chunk-XEP6X7JU.js} +5 -5
- package/dist/esm/chunk-XEP6X7JU.js.map +7 -0
- package/dist/esm/components/AddressLookup/AddressLookup.js +6 -6
- package/dist/esm/components/AddressLookup/index.js +8 -8
- package/dist/esm/components/Breadcrumbs/Breadcrumbs.js +1 -1
- package/dist/esm/components/Breadcrumbs/index.js +3 -3
- package/dist/esm/components/Checkbox/index.js +1 -1
- package/dist/esm/components/Combobox/Combobox.js +5 -5
- package/dist/esm/components/Combobox/index.js +5 -5
- package/dist/esm/components/DateField/DateField.js +3 -3
- package/dist/esm/components/DateField/index.js +3 -3
- package/dist/esm/components/Drawer/index.js +3 -3
- package/dist/esm/components/DropdownMenu/Item.js +1 -1
- package/dist/esm/components/DropdownMenu/index.js +2 -2
- package/dist/esm/components/MaskedField/MaskedField.js +2 -2
- package/dist/esm/components/MaskedField/index.js +3 -3
- package/dist/esm/components/Modal/index.js +3 -3
- package/dist/esm/components/NumberField/NumberField.js +3 -3
- package/dist/esm/components/NumberField/index.js +3 -3
- package/dist/esm/components/PasswordField/PasswordField.js +3 -3
- package/dist/esm/components/PasswordField/index.js +3 -3
- package/dist/esm/components/Popover/Arrow.js +8 -0
- package/dist/esm/components/Popover/Arrow.js.map +7 -0
- package/dist/esm/components/Popover/Popover.js +5 -1
- package/dist/esm/components/Popover/index.js +5 -1
- package/dist/esm/components/Popover/useAutoUpdate.js +8 -0
- package/dist/esm/components/Popover/useAutoUpdate.js.map +7 -0
- package/dist/esm/components/Popover/useFloatingPosition.js +8 -0
- package/dist/esm/components/Popover/useFloatingPosition.js.map +7 -0
- package/dist/esm/components/Popover/useOutsidePress.js +8 -0
- package/dist/esm/components/Popover/useOutsidePress.js.map +7 -0
- package/dist/esm/components/TextField/TextField.js +2 -2
- package/dist/esm/components/TextField/adornmentWithClassName.js +1 -1
- package/dist/esm/components/TextField/index.js +2 -2
- package/dist/esm/components/index.js +81 -77
- package/dist/esm/index.js +81 -77
- package/dist/esm/meta.json +3495 -3149
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/Accordion/Accordion.d.ts +4 -4
- package/dist/types/components/Accordion/AccordionList.d.ts +4 -4
- package/dist/types/components/AddressLookup/AddressLookup.d.ts +4 -4
- package/dist/types/components/AddressLookup/LoqateAddressLookupService.d.ts +1 -1
- package/dist/types/components/Alert/Alert.d.ts +4 -4
- package/dist/types/components/Box/Box.d.ts +4 -4
- package/dist/types/components/Breadcrumbs/BreadcrumbItem.d.ts +4 -4
- package/dist/types/components/Breadcrumbs/Breadcrumbs.d.ts +4 -4
- package/dist/types/components/Button/Button.d.ts +4 -4
- package/dist/types/components/Checkbox/Checkbox.d.ts +4 -4
- package/dist/types/components/Checkbox/CheckboxGroup.d.ts +4 -4
- package/dist/types/components/Combobox/Combobox.d.ts +2 -5
- package/dist/types/components/Combobox/useComboboxOptions.d.ts +1 -1
- package/dist/types/components/Container/Container.d.ts +4 -4
- package/dist/types/components/DateField/DateField.d.ts +4 -4
- package/dist/types/components/Divider/Divider.d.ts +4 -4
- package/dist/types/components/Drawer/Content.d.ts +4 -4
- package/dist/types/components/Drawer/Drawer.d.ts +4 -4
- package/dist/types/components/Drawer/Header.d.ts +4 -4
- package/dist/types/components/DropdownMenu/DropdownMenu.d.ts +4 -4
- package/dist/types/components/DropdownMenu/Item.d.ts +4 -4
- package/dist/types/components/ErrorMessage/ErrorMessage.d.ts +4 -4
- package/dist/types/components/ExpandableText/ExpandableText.d.ts +4 -4
- package/dist/types/components/Fieldset/Fieldset.d.ts +4 -4
- package/dist/types/components/Flex/Flex.d.ts +4 -4
- package/dist/types/components/Grid/Grid.d.ts +4 -4
- package/dist/types/components/Grid/Item.d.ts +4 -4
- package/dist/types/components/Image/Image.d.ts +4 -4
- package/dist/types/components/Label/Label.d.ts +4 -4
- package/dist/types/components/Link/Link.d.ts +4 -4
- package/dist/types/components/List/List.d.ts +4 -4
- package/dist/types/components/List/ListItem.d.ts +4 -4
- package/dist/types/components/LoadingIndicator/LoadingIndicator.d.ts +4 -4
- package/dist/types/components/Logo/Logo.d.ts +4 -4
- package/dist/types/components/MaskedField/MaskedField.d.ts +4 -4
- package/dist/types/components/Modal/Content.d.ts +4 -4
- package/dist/types/components/Modal/Header.d.ts +4 -4
- package/dist/types/components/Modal/Modal.d.ts +4 -4
- package/dist/types/components/NumberField/NumberField.d.ts +4 -4
- package/dist/types/components/Option/Option.d.ts +4 -4
- package/dist/types/components/PasswordField/PasswordField.d.ts +4 -4
- package/dist/types/components/Popover/Arrow.d.ts +9 -0
- package/dist/types/components/Popover/useAutoUpdate.d.ts +9 -0
- package/dist/types/components/Popover/useFloatingPosition.d.ts +17 -0
- package/dist/types/components/Popover/useOutsidePress.d.ts +9 -0
- package/dist/types/components/Progress/Progress.d.ts +4 -4
- package/dist/types/components/Radio/Radio.d.ts +4 -4
- package/dist/types/components/Radio/RadioGroup.d.ts +4 -4
- package/dist/types/components/SVG/SVG.d.ts +4 -4
- package/dist/types/components/Segment/Segment.d.ts +4 -4
- package/dist/types/components/Segment/SegmentGroup.d.ts +4 -4
- package/dist/types/components/Select/Select.d.ts +4 -4
- package/dist/types/components/Stack/Stack.d.ts +4 -4
- package/dist/types/components/Switch/Switch.d.ts +4 -4
- package/dist/types/components/Table/Body.d.ts +4 -4
- package/dist/types/components/Table/Cell.d.ts +4 -4
- package/dist/types/components/Table/Foot.d.ts +4 -4
- package/dist/types/components/Table/Head.d.ts +4 -4
- package/dist/types/components/Table/HeaderCell.d.ts +4 -4
- package/dist/types/components/Table/Row.d.ts +4 -4
- package/dist/types/components/Table/Table.d.ts +4 -4
- package/dist/types/components/Text/Text.d.ts +4 -4
- package/dist/types/components/TextArea/TextArea.d.ts +4 -4
- package/dist/types/components/TextAreaInput/TextAreaInput.d.ts +4 -4
- package/dist/types/components/TextField/TextField.d.ts +1 -4
- package/dist/types/components/TextField/adornmentWithClassName.d.ts +3 -1
- package/dist/types/components/TextOrHTML/TextOrHTML.d.ts +4 -4
- package/dist/types/components/Title/Title.d.ts +4 -4
- package/dist/types/components/Toast/ToastOptionsDoc.d.ts +4 -8
- package/dist/types/components/Toast/Toaster.d.ts +4 -4
- package/dist/types/hooks/useButton/useButton.d.ts +5 -5
- package/dist/types/hooks/useLabel/useLabel.d.ts +1 -1
- package/package.json +11 -11
- package/src/components/Box/Box.test.tsx +1 -2
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +3 -7
- package/src/components/Button/Button.stories.tsx +1 -1
- package/src/components/Combobox/Combobox.tsx +2 -4
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +1 -1
- package/src/components/DropdownMenu/Item.tsx +3 -6
- package/src/components/Grid/Grid.stories.tsx +1 -1
- package/src/components/Popover/Arrow.tsx +25 -0
- package/src/components/Popover/Popover.characterization.test.tsx +269 -0
- package/src/components/Popover/Popover.stories.tsx +40 -3
- package/src/components/Popover/Popover.test.tsx +6 -2
- package/src/components/Popover/Popover.tsx +87 -81
- package/src/components/Popover/useAutoUpdate.ts +43 -0
- package/src/components/Popover/useFloatingPosition.ts +177 -0
- package/src/components/Popover/useOutsidePress.ts +31 -0
- package/src/components/TextField/TextField.tsx +3 -1
- package/src/components/TextField/adornmentWithClassName.ts +4 -3
- package/src/hooks/useBreakpoint/useBreakpoint.test.tsx +4 -4
- package/src/styles.d.ts +2 -0
- package/dist/esm/chunk-IQKS662C.js.map +0 -7
- package/dist/esm/chunk-O5YEU5TG.js +0 -155
- package/dist/esm/chunk-O5YEU5TG.js.map +0 -7
- package/dist/esm/chunk-OAG5T7NC.js.map +0 -7
- /package/dist/esm/{chunk-XNEQHHNV.js.map → chunk-5QMKPWB4.js.map} +0 -0
- /package/dist/esm/{chunk-PEEQNAIN.js.map → chunk-DMYDWKKA.js.map} +0 -0
- /package/dist/esm/{chunk-GJBH37DH.js.map → chunk-KFHPI67N.js.map} +0 -0
- /package/dist/esm/{chunk-OEDU5ZEA.js.map → chunk-KUH5AB5T.js.map} +0 -0
- /package/dist/esm/{chunk-F5ELD54X.js.map → chunk-QNOBB5HT.js.map} +0 -0
- /package/dist/esm/{chunk-GV36OVX7.js.map → chunk-R67C5QTH.js.map} +0 -0
- /package/dist/esm/{chunk-S4CU4XRB.js.map → chunk-VGFVSRWH.js.map} +0 -0
- /package/dist/esm/{chunk-X4CMSAET.js.map → chunk-WSQWMVA2.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/PasswordField/index.tsx", "../../../../src/components/PasswordField/PasswordField.tsx", "../../../../src/utils/mergeRefs.ts", "../../../../src/components/TextField/TextField.tsx", "../../../../src/utils/spaceDelimitedList.ts", "../../../../src/hooks/useLabel/useLabel.tsx", "../../../../src/hooks/useTextField/useTextField.tsx", "../../../../src/hooks/useValidationClasses/useValidationClasses.ts", "../../../../src/components/ErrorMessage/ErrorMessage.tsx", "../../../../src/components/Icon/Icon.tsx", "../../../../src/components/TextOrHTML/TextOrHTML.tsx", "../../../../src/components/Text/Text.tsx", "../../../../src/components/Label/Label.tsx", "../../../../src/components/Stack/Stack.tsx", "../../../../src/components/TextField/adornmentWithClassName.ts", "../../../../src/components/PasswordField/ShowHideButton.tsx"],
|
|
4
|
-
"sourcesContent": ["export * from \"./PasswordField\";\n", "\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport { useRef, useState } from \"react\";\nimport { mergeRefs } from \"../../utils/mergeRefs\";\nimport {\n TextField,\n type TextFieldElementType,\n type TextFieldProps,\n} from \"../TextField\";\nimport { ShowHideButton } from \"./ShowHideButton\";\nimport \"./PasswordField.css\";\n\nexport type PasswordFieldAutoComplete = \"current-password\" | \"new-password\";\n\nexport interface PasswordFieldProps extends TextFieldProps {\n autoComplete?: PasswordFieldAutoComplete;\n}\n\nexport const PasswordField = ({\n ref,\n className,\n autoComplete = \"current-password\",\n ...props\n}: PasswordFieldProps) => {\n const [show, setShow] = useState(false);\n const type = show ? \"text\" : \"password\";\n const classes = classNames(\"mobius-password-field\", className);\n const localRef = useRef<TextFieldElementType>(null);\n\n const handleShowHideButtonClick = () => {\n const selectionStart = localRef.current?.selectionStart;\n const selectionEnd = localRef.current?.selectionEnd;\n\n setShow(oldShow => !oldShow);\n requestAnimationFrame(() => {\n localRef.current?.focus();\n if (selectionStart != null && selectionEnd != null) {\n localRef.current?.setSelectionRange(selectionStart, selectionEnd);\n }\n });\n };\n\n return (\n <TextField\n ref={mergeRefs([localRef, ref])}\n className={classes}\n {...props}\n autoComplete={autoComplete}\n type={type}\n suffixInside={\n <ShowHideButton onClick={handleShowHideButtonClick} show={show} />\n }\n />\n );\n};\n\nPasswordField.displayName = \"PasswordField\";\n", "// Ref: https://github.com/gregberge/react-merge-refs/blob/812fefa4390884a4a2d1bc489d869bd088df8ff5/src/index.tsx\nimport type { MutableRefObject, LegacyRef, RefCallback } from \"react\";\n\nexport function mergeRefs<T = unknown>(\n refs: Array<MutableRefObject<T> | LegacyRef<T> | undefined>,\n): RefCallback<T> {\n return value => {\n refs.forEach(ref => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref != null) {\n (ref as MutableRefObject<T | null>).current = value;\n }\n });\n };\n}\n", "\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport type {\n HTMLInputTypeAttribute,\n ReactElement,\n ReactNode,\n Ref,\n RefAttributes,\n} from \"react\";\nimport type { UseTextFieldProps } from \"../../hooks\";\nimport { useTextField, useValidationClasses } from \"../../hooks\";\nimport type { DOMProps, FocusEvents } from \"../../types\";\nimport { ErrorMessage } from \"../ErrorMessage\";\nimport { Label } from \"../Label\";\nimport { Stack } from \"../Stack\";\nimport { adornmentWithClassName } from \"./adornmentWithClassName\";\nimport \"./TextField.css\";\n\nexport type TextFieldElementType = HTMLInputElement;\nexport interface TextFieldProps\n extends\n DOMProps,\n FocusEvents,\n UseTextFieldProps,\n RefAttributes<TextFieldElementType> {\n className?: string;\n errorMessage?: string;\n children?: ReactNode;\n label?: string;\n type?: Exclude<\n HTMLInputTypeAttribute,\n | \"button\"\n | \"checkbox\"\n | \"color\"\n | \"date\"\n | \"datetime-local\"\n | \"file\"\n | \"image\"\n | \"month\"\n | \"radio\"\n | \"range\"\n | \"reset\"\n | \"submit\"\n | \"week\"\n >;\n prefixInside?: ReactElement;\n prefixOutside?: ReactElement;\n suffixInside?: ReactElement;\n suffixOutside?: ReactElement;\n}\n\nexport type TextFieldRef = Ref<TextFieldElementType>;\n\nconst TextField = ({ ref, ...props }: TextFieldProps) => {\n const {\n isDisabled,\n type = \"text\",\n isInvalid,\n className,\n label,\n errorMessage,\n children,\n isRequired,\n prefixInside,\n prefixOutside,\n suffixInside,\n suffixOutside,\n autoComplete,\n isReadOnly,\n ...otherProps\n } = props;\n\n const resolvedAutoComplete =\n autoComplete ??\n (type === \"email\" ? \"email\" : type === \"tel\" ? \"tel\" : undefined);\n\n const { inputProps, labelProps, errorMessageProps } = useTextField({\n ...props,\n autoComplete: resolvedAutoComplete,\n \"aria-errormessage\": errorMessage,\n });\n\n const hidden = type === \"hidden\";\n\n const validationClasses = useValidationClasses({ isInvalid });\n\n const textfieldClasses = {\n \"--is-disabled\": isDisabled,\n \"--is-required\": typeof isRequired === \"boolean\" && isRequired,\n \"--is-optional\": typeof isRequired === \"boolean\" && !isRequired,\n \"--is-hidden\": hidden,\n [className || \"\"]: true,\n };\n\n const sharedClasses = classNames(validationClasses, textfieldClasses);\n\n const labelClasses = classNames(\n {\n \"--is-disabled\": isDisabled,\n },\n validationClasses,\n );\n\n const containerClasses = classNames(\n \"mobius\",\n \"mobius-text-field\",\n sharedClasses,\n );\n\n const inputClasses = classNames(\n \"mobius\",\n \"mobius-text-field__input\",\n sharedClasses,\n );\n\n const inputWrapperClasses = classNames(\n \"mobius-text-field__input-wrapper\",\n sharedClasses,\n );\n\n return (\n <Stack gap=\"xs\" className={containerClasses}>\n {label && !hidden && (\n <Label {...labelProps} className={labelClasses}>\n {label}\n </Label>\n )}\n <div className=\"mobius-text-field__inner-container\">\n {adornmentWithClassName(\n prefixOutside,\n labelClasses,\n \"mobius-text-field__prefix-outside\",\n )}\n <div className={inputWrapperClasses}>\n {adornmentWithClassName(\n prefixInside,\n labelClasses,\n \"mobius-text-field__prefix-inside\",\n )}\n <input\n {...otherProps}\n {...inputProps}\n ref={ref}\n type={type}\n className={inputClasses}\n />\n {adornmentWithClassName(\n suffixInside,\n labelClasses,\n \"mobius-text-field__suffix-inside\",\n )}\n </div>\n {adornmentWithClassName(\n suffixOutside,\n labelClasses,\n \"mobius-text-field__suffix-outside\",\n )}\n </div>\n {children && (\n <div className=\"mobius-text-field__children\">{children}</div>\n )}\n\n <ErrorMessage {...errorMessageProps} errorMessage={errorMessage} />\n </Stack>\n );\n};\n\nTextField.displayName = \"TextField\";\nexport { TextField };\n", "export function spaceDelimitedList(\n list: (string | null | undefined)[],\n): string | undefined {\n return list.filter(Boolean).join(\" \") || undefined;\n}\n", "import type { LabelHTMLAttributes } from \"react\";\nimport { useId, useRef } from \"react\";\n\nexport type UseLabelProps = {\n id?: string | undefined;\n label?: string | undefined;\n \"aria-label\"?: string | undefined;\n \"aria-labelledby\"?: string | undefined;\n labelElementType?: \"label\" | \"span\" | undefined;\n};\n\nexport type UseLabelReturn = {\n labelProps: {\n id?: string | undefined;\n } & LabelHTMLAttributes<HTMLLabelElement>;\n fieldProps: LabellingProps;\n};\n\nexport type LabellingProps = {\n id?: string | undefined;\n \"aria-label\"?: string | undefined;\n \"aria-labelledby\"?: string | undefined;\n \"aria-describedby\"?: string | undefined;\n \"aria-details\"?: string | undefined;\n};\n\nexport function useLabel({\n id: providedId,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n labelElementType = \"label\",\n}: UseLabelProps) {\n let labelProps: UseLabelReturn[\"labelProps\"] = {};\n let fieldProps: UseLabelReturn[\"fieldProps\"] = {};\n\n const hasWarnedAboutMissingLabels = useRef(false);\n\n const fallbackId = useId();\n const id = providedId || fallbackId;\n const labelId = useId();\n\n if (label) {\n ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;\n labelProps = {\n id: labelId,\n htmlFor: labelElementType === \"label\" ? id : undefined,\n };\n } else if (\n !ariaLabelledby &&\n !ariaLabel &&\n !hasWarnedAboutMissingLabels.current\n ) {\n hasWarnedAboutMissingLabels.current = true;\n console.warn(\n \"If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility\",\n );\n }\n\n fieldProps = {\n id,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n };\n\n return {\n labelProps,\n fieldProps,\n };\n}\n", "import { useId } from \"react\";\nimport { spaceDelimitedList } from \"../../utils/spaceDelimitedList\";\nimport { useLabel } from \"../useLabel/useLabel\";\nimport type { UseTextFieldProps, UseTextFieldReturn } from \"./types\";\n\nexport function useTextField(props: UseTextFieldProps): UseTextFieldReturn {\n const {\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n inputElementType = \"input\",\n } = props;\n const { labelProps, fieldProps } = useLabel(props);\n\n const descriptionId = useId();\n const descriptionProps = { id: descriptionId };\n\n const errorMessageId = useId();\n const errorMessageProps = { id: errorMessageId };\n\n const ariaDescribedBy = spaceDelimitedList([\n props.description && descriptionId,\n props.errorMessage && errorMessageId,\n props[\"aria-describedby\"],\n ]);\n\n return {\n descriptionProps,\n errorMessageProps,\n labelProps,\n inputProps: {\n defaultValue: props.defaultValue,\n value: props.value,\n onChange: props.onChange,\n disabled: isDisabled,\n readOnly: isReadOnly,\n required: isRequired,\n \"aria-required\": isRequired === true ? true : undefined,\n \"aria-invalid\": props.isInvalid,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": props[\"aria-errormessage\"],\n role: props.role,\n\n type: inputElementType === \"input\" ? props.type : undefined,\n pattern: inputElementType === \"input\" ? props.pattern : undefined,\n\n autoComplete: props.autoComplete,\n maxLength: props.maxLength,\n minLength: props.minLength,\n name: props.name,\n placeholder: props.placeholder,\n inputMode: props.inputMode,\n\n // Clipboard events\n onCopy: props.onCopy,\n onCut: props.onCut,\n onPaste: props.onPaste,\n\n // Composition events\n onCompositionEnd: props.onCompositionEnd,\n onCompositionStart: props.onCompositionStart,\n onCompositionUpdate: props.onCompositionUpdate,\n\n // Selection events\n onSelect: props.onSelect,\n\n // Input events\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n\n // Focus events\n onFocus: props.onFocus,\n onBlur: props.onBlur,\n\n ...fieldProps,\n },\n };\n}\n", "import type { Validation } from \"../../types\";\n\nexport type GetValidationClassesProps = Pick<Validation, \"isInvalid\">;\n\nexport const useValidationClasses = (props: GetValidationClassesProps) => {\n const { isInvalid } = props;\n\n if (isInvalid) {\n return \"--is-invalid\";\n }\n\n if (isInvalid === false) {\n return \"--is-valid\";\n }\n\n return \"\";\n};\n", "import { error } from \"@simplybusiness/icons\";\nimport classNames from \"classnames/dedupe\";\nimport { Icon } from \"../Icon\";\nimport { TextOrHTML } from \"../TextOrHTML\";\nimport \"./ErrorMessage.css\";\n\nexport interface ErrorMessageProps {\n errorMessage?: string;\n id?: string;\n className?: string;\n}\n\nexport const ErrorMessage = ({\n id,\n errorMessage,\n className,\n}: ErrorMessageProps) => {\n const classes = classNames(\"mobius\", \"mobius-error-message\", className);\n\n if (!errorMessage) return null;\n\n return (\n <div id={id} className={classes} data-testid=\"ErrorMessage\" role=\"alert\">\n <Icon\n icon={error}\n className=\"mobius-error-message__icon\"\n aria-hidden=\"true\"\n />\n <TextOrHTML\n elementType=\"span\"\n className=\"mobius-error-message__text\"\n text={errorMessage}\n />\n </div>\n );\n};\n\nErrorMessage.displayName = \"ErrorMessage\";\n", "import classNames from \"classnames/dedupe\";\nimport type { IconProps } from \"./types\";\nimport \"./Icon.css\";\n\nconst ICON_PREFIX = \"mobius-icon\";\n\nconst capitaliseFirstLetter = (str: string) =>\n str.charAt(0).toUpperCase() + str.slice(1);\n\nexport function Icon({\n ref,\n icon,\n className,\n size = \"xs\",\n color,\n fixedWidth,\n spin,\n spinReverse,\n title,\n ...otherProps\n}: IconProps) {\n if (!icon) {\n throw new Error(\"Must specify icon object\");\n }\n\n const classes = classNames(\n \"mobius\",\n \"mobius-icon\",\n `svg-inline--${ICON_PREFIX}`,\n `--size-${size}`,\n className,\n {\n [`${ICON_PREFIX}-fw`]: fixedWidth,\n [`${ICON_PREFIX}-spin`]: spin || spinReverse,\n [`${ICON_PREFIX}-spin-reverse`]: spinReverse,\n },\n );\n\n const { iconName, width, height, svgPathData } = icon;\n const formattedIconName = iconName.split(\"-\").join(\" \");\n\n const defaultTitle = `${capitaliseFirstLetter(formattedIconName)} icon`;\n const titleText = title || defaultTitle;\n\n return (\n <svg\n ref={ref}\n focusable=\"false\"\n data-icon={iconName}\n className={classes}\n role=\"img\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox={`0 0 ${width} ${height}`}\n style={{ color }}\n {...otherProps}\n >\n <title>{titleText}</title>\n <path fill=\"currentColor\" d={svgPathData} />\n </svg>\n );\n}\n", "import classNames from \"classnames/dedupe\";\nimport type { RefAttributes } from \"react\";\nimport { useMemo } from \"react\";\nimport type { TextElementType, TextProps } from \"../Text/Text\";\nimport { Text, getElementType } from \"../Text/Text\";\n\nexport type HTMLElementType = \"span\" | \"div\";\n\n// Block-level tags that cannot be nested inside <p>.\nconst BLOCK_TAG =\n /<(div|p|ul|ol|li|h[1-6]|table|tr|td|th|blockquote|pre|hr|dl|dt|dd)[\\s>/]/i;\nconst containsBlockHTML = (text: string) => BLOCK_TAG.test(text);\nconst containsHTML = (text: string) =>\n /<[a-z/]/i.test(text) || /&(?:#\\d+|#x[\\da-f]+|[a-z]\\w*);/i.test(text); // tag or entity\n\nconst buildTextClasses = (\n textProps: Omit<TextProps, \"children\">,\n htmlClassName?: string,\n) => {\n const { variant, elementType, spacing, className } = textProps;\n const variantType = variant || getElementType(variant, elementType);\n return classNames(\n \"mobius\",\n \"mobius-text\",\n { [`--is-${variantType}`]: variantType },\n { [`--has-line-height-${spacing}`]: spacing },\n className,\n htmlClassName,\n );\n};\n\nexport interface TextOrHTMLProps\n extends Omit<TextProps, \"children\">, RefAttributes<TextElementType> {\n /** HTML string to be rendered with dangerouslySetInnerHTML */\n text: string;\n /** Custom class name for the dangerous HTML element */\n htmlClassName?: string;\n /** HTML element type for the dangerous HTML element */\n htmlElementType?: HTMLElementType;\n /** If true, wraps the dangerous HTML element inside a Text component */\n textWrapper?: boolean;\n /** If true, auto-detects whether text is HTML or plain text to determine wrapping and element type */\n autoDetect?: boolean;\n}\n\nconst TextOrHTML = ({\n ref,\n text,\n htmlClassName,\n htmlElementType,\n textWrapper = false,\n autoDetect = false,\n ...textProps\n}: TextOrHTMLProps) => {\n const hasBlockContent = autoDetect && containsBlockHTML(text);\n\n // Memoize the dangerouslySetInnerHTML object to prevent unnecessary re-renders\n // See: https://github.com/facebook/react/issues/31660\n const dangerousHTML = useMemo(() => ({ __html: text }), [text]);\n\n // Non-block text with autoDetect: render directly on a Text-equivalent element,\n // avoiding unnecessary <span> nesting inside <p>.\n if (autoDetect && !hasBlockContent) {\n const { variant, spacing, elementType, className, ...domProps } = textProps;\n const Element = getElementType(variant, elementType);\n const classes = buildTextClasses(textProps, htmlClassName);\n\n return containsHTML(text) ? (\n <Element\n ref={ref}\n {...domProps}\n className={classes}\n dangerouslySetInnerHTML={dangerousHTML}\n />\n ) : (\n <Element ref={ref} {...domProps} className={classes}>\n {text}\n </Element>\n );\n }\n\n const DangerousComponent =\n htmlElementType ?? (hasBlockContent ? \"div\" : \"span\");\n const dangerousElement = (\n <DangerousComponent\n className={htmlClassName}\n dangerouslySetInnerHTML={dangerousHTML}\n />\n );\n\n if (textWrapper) {\n return (\n <Text ref={ref} {...textProps}>\n {dangerousElement}\n </Text>\n );\n }\n\n return dangerousElement;\n};\n\nTextOrHTML.displayName = \"TextOrHTML\";\nexport { TextOrHTML };\n", "import type { ReactNode, RefAttributes } from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport type { DOMProps } from \"../../types/dom\";\nimport \"./Text.css\";\n\nexport type TextElementType = HTMLHeadingElement | HTMLParagraphElement;\nexport type TextVariantType =\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"body\"\n | \"small\"\n | \"legal\"\n | \"title\";\nexport type ElementType = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"p\" | \"span\";\nexport interface TextProps extends DOMProps, RefAttributes<TextElementType> {\n /** HTML element for the text */\n elementType?: ElementType;\n /** Specify font size override */\n variant?: TextVariantType;\n /** Specify compact line height override */\n spacing?: \"loose\" | \"tight\";\n /** Custom class name for setting specific CSS */\n className?: string;\n children: ReactNode;\n style?: React.CSSProperties;\n}\n\nexport const getElementType = (\n variant: TextVariantType | undefined,\n elementType: ElementType | undefined,\n): ElementType => {\n // Explicit elementType always wins\n if (elementType) {\n return elementType;\n }\n // Infer element from variant\n if (variant && [\"h1\", \"h2\", \"h3\", \"h4\"].includes(variant)) {\n return variant as ElementType;\n }\n return \"p\";\n};\n\nconst Text = ({ ref, elementType, ...props }: TextProps) => {\n // Remove non-DOM props from element\n const { variant, className, spacing, ...otherProps } = props;\n\n // If a variant is supplied, set the class name and element type\n const Element: ElementType = getElementType(variant, elementType);\n const variantType = variant || Element;\n const classes = classNames(\n \"mobius\",\n \"mobius-text\",\n { [`--is-${variantType}`]: variantType },\n { [`--has-line-height-${spacing}`]: spacing },\n className,\n );\n\n return <Element ref={ref} {...otherProps} className={classes} />;\n};\n\nText.displayName = \"Text\";\nexport { Text };\n", "import type React from \"react\";\nimport type { ReactNode, RefAttributes } from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport type { DOMProps } from \"../../types/dom\";\nimport \"./Label.css\";\n\nexport type LabelElementType = HTMLLabelElement;\nexport type IntrinsicLabel = Omit<\n React.JSX.IntrinsicElements[\"label\"],\n \"css\" | \"color\" | \"ref\"\n>;\n\nexport interface LabelProps\n extends IntrinsicLabel, DOMProps, RefAttributes<LabelElementType> {\n children?: ReactNode;\n className?: string;\n elementType?: \"label\" | \"span\";\n}\n\nconst Label = ({ ref, ...props }: LabelProps) => {\n const { elementType: Element = \"label\", children, ...otherProps } = props;\n\n const classes = classNames(\"mobius\", \"mobius-label\", props.className);\n otherProps.className = classes;\n\n return (\n <Element ref={ref} {...otherProps} className={classes}>\n {children}\n </Element>\n );\n};\n\nLabel.displayName = \"Label\";\nexport { Label };\n", "import type { Ref, RefAttributes, ReactNode } from \"react\";\nimport type React from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport type { DOMProps } from \"../../types/dom\";\nimport type { SpacingType } from \"../../types\";\nimport \"./Stack.css\";\n\nexport type StackElementType = HTMLDivElement;\n\nexport interface StackProps extends DOMProps, RefAttributes<StackElementType> {\n children?: ReactNode;\n /** How big a gap between items */\n gap?: SpacingType;\n /** Custom class name for setting specific CSS */\n className?: string;\n elementType?: React.ElementType;\n}\n\nexport type StackRef = Ref<StackElementType>;\n\nexport const Stack = ({ ref, ...props }: StackProps) => {\n const { elementType: Element = \"div\", gap, ...otherProps } = props;\n\n const classes = classNames(\n \"mobius\",\n \"mobius-stack\",\n {\n [`--gap-${gap}`]: gap,\n },\n otherProps.className,\n );\n\n return <Element ref={ref} {...otherProps} className={classes} />;\n};\n\nStack.displayName = \"Stack\";\n", "import classNames from \"classnames/dedupe\";\nimport type { ReactElement } from \"react\";\nimport { cloneElement } from \"react\";\n\nexport const adornmentWithClassName = (\n component?: ReactElement,\n validationClasses?: string,\n className?: string,\n) => {\n if (!component) return null;\n\n return cloneElement(component, {\n className: classNames(\n (component.props as { className?: string }).className,\n validationClasses,\n className,\n ),\n } as { className: string });\n};\n", "import { eye, eyeSlash } from \"@simplybusiness/icons\";\nimport { Icon } from \"../Icon\";\n\nexport interface ShowHideButtonProps {\n show?: boolean;\n onClick: () => void;\n}\n\nexport const ShowHideButton = ({\n show = false,\n onClick,\n}: ShowHideButtonProps) => (\n <button\n className=\"mobius-password-field__show-button\"\n type=\"button\"\n onClick={e => {\n e.preventDefault();\n onClick();\n }}\n aria-label={`${show ? \"Hide\" : \"Show\"} password`}\n data-testid=\"show-hide-button\"\n >\n <Icon icon={show ? eyeSlash : eye} aria-hidden=\"true\" />\n </button>\n);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAAA,iBAAuB;AACvB,IAAAC,gBAAiC;;;ACA1B,SAAS,UACd,MACgB;AAChB,SAAO,WAAS;AACd,SAAK,QAAQ,SAAO;AAClB,UAAI,OAAO,QAAQ,YAAY;AAC7B,YAAI,KAAK;AAAA,MACX,WAAW,OAAO,MAAM;AACtB,QAAC,IAAmC,UAAU;AAAA,MAChD;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;ACbA,IAAAC,iBAAuB;;;
|
|
6
|
-
"names": ["import_dedupe", "import_react", "import_dedupe", "import_react", "import_dedupe", "classNames", "import_dedupe", "import_react", "import_dedupe", "import_jsx_runtime", "classNames", "import_jsx_runtime", "classNames", "import_jsx_runtime", "classNames", "import_dedupe", "import_jsx_runtime", "classNames", "import_dedupe", "import_jsx_runtime", "classNames", "import_dedupe", "import_react", "classNames", "import_jsx_runtime", "classNames", "import_icons", "import_jsx_runtime", "import_jsx_runtime", "classNames"]
|
|
4
|
+
"sourcesContent": ["export * from \"./PasswordField\";\n", "\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport { useRef, useState } from \"react\";\nimport { mergeRefs } from \"../../utils/mergeRefs\";\nimport {\n TextField,\n type TextFieldElementType,\n type TextFieldProps,\n} from \"../TextField\";\nimport { ShowHideButton } from \"./ShowHideButton\";\nimport \"./PasswordField.css\";\n\nexport type PasswordFieldAutoComplete = \"current-password\" | \"new-password\";\n\nexport interface PasswordFieldProps extends TextFieldProps {\n autoComplete?: PasswordFieldAutoComplete;\n}\n\nexport const PasswordField = ({\n ref,\n className,\n autoComplete = \"current-password\",\n ...props\n}: PasswordFieldProps) => {\n const [show, setShow] = useState(false);\n const type = show ? \"text\" : \"password\";\n const classes = classNames(\"mobius-password-field\", className);\n const localRef = useRef<TextFieldElementType>(null);\n\n const handleShowHideButtonClick = () => {\n const selectionStart = localRef.current?.selectionStart;\n const selectionEnd = localRef.current?.selectionEnd;\n\n setShow(oldShow => !oldShow);\n requestAnimationFrame(() => {\n localRef.current?.focus();\n if (selectionStart != null && selectionEnd != null) {\n localRef.current?.setSelectionRange(selectionStart, selectionEnd);\n }\n });\n };\n\n return (\n <TextField\n ref={mergeRefs([localRef, ref])}\n className={classes}\n {...props}\n autoComplete={autoComplete}\n type={type}\n suffixInside={\n <ShowHideButton onClick={handleShowHideButtonClick} show={show} />\n }\n />\n );\n};\n\nPasswordField.displayName = \"PasswordField\";\n", "// Ref: https://github.com/gregberge/react-merge-refs/blob/812fefa4390884a4a2d1bc489d869bd088df8ff5/src/index.tsx\nimport type { MutableRefObject, LegacyRef, RefCallback } from \"react\";\n\nexport function mergeRefs<T = unknown>(\n refs: Array<MutableRefObject<T> | LegacyRef<T> | undefined>,\n): RefCallback<T> {\n return value => {\n refs.forEach(ref => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref != null) {\n (ref as MutableRefObject<T | null>).current = value;\n }\n });\n };\n}\n", "\"use client\";\n\nimport classNames from \"classnames/dedupe\";\nimport { memo } from \"react\";\nimport type {\n HTMLInputTypeAttribute,\n ReactElement,\n ReactNode,\n Ref,\n RefAttributes,\n} from \"react\";\nimport type { UseTextFieldProps } from \"../../hooks\";\nimport { useTextField, useValidationClasses } from \"../../hooks\";\nimport type { DOMProps, FocusEvents } from \"../../types\";\nimport { ErrorMessage } from \"../ErrorMessage\";\nimport { Label } from \"../Label\";\nimport { Stack } from \"../Stack\";\nimport { adornmentWithClassName } from \"./adornmentWithClassName\";\nimport \"./TextField.css\";\n\nexport type TextFieldElementType = HTMLInputElement;\nexport interface TextFieldProps\n extends\n DOMProps,\n FocusEvents,\n UseTextFieldProps,\n RefAttributes<TextFieldElementType> {\n className?: string;\n errorMessage?: string;\n children?: ReactNode;\n label?: string;\n type?: Exclude<\n HTMLInputTypeAttribute,\n | \"button\"\n | \"checkbox\"\n | \"color\"\n | \"date\"\n | \"datetime-local\"\n | \"file\"\n | \"image\"\n | \"month\"\n | \"radio\"\n | \"range\"\n | \"reset\"\n | \"submit\"\n | \"week\"\n >;\n prefixInside?: ReactElement;\n prefixOutside?: ReactElement;\n suffixInside?: ReactElement;\n suffixOutside?: ReactElement;\n}\n\nexport type TextFieldRef = Ref<TextFieldElementType>;\n\nconst TextFieldInner = ({ ref, ...props }: TextFieldProps) => {\n const {\n isDisabled,\n type = \"text\",\n isInvalid,\n className,\n label,\n errorMessage,\n children,\n isRequired,\n prefixInside,\n prefixOutside,\n suffixInside,\n suffixOutside,\n autoComplete,\n isReadOnly,\n ...otherProps\n } = props;\n\n const resolvedAutoComplete =\n autoComplete ??\n (type === \"email\" ? \"email\" : type === \"tel\" ? \"tel\" : undefined);\n\n const { inputProps, labelProps, errorMessageProps } = useTextField({\n ...props,\n autoComplete: resolvedAutoComplete,\n \"aria-errormessage\": errorMessage,\n });\n\n const hidden = type === \"hidden\";\n\n const validationClasses = useValidationClasses({ isInvalid });\n\n const textfieldClasses = {\n \"--is-disabled\": isDisabled,\n \"--is-required\": typeof isRequired === \"boolean\" && isRequired,\n \"--is-optional\": typeof isRequired === \"boolean\" && !isRequired,\n \"--is-hidden\": hidden,\n [className || \"\"]: true,\n };\n\n const sharedClasses = classNames(validationClasses, textfieldClasses);\n\n const labelClasses = classNames(\n {\n \"--is-disabled\": isDisabled,\n },\n validationClasses,\n );\n\n const containerClasses = classNames(\n \"mobius\",\n \"mobius-text-field\",\n sharedClasses,\n );\n\n const inputClasses = classNames(\n \"mobius\",\n \"mobius-text-field__input\",\n sharedClasses,\n );\n\n const inputWrapperClasses = classNames(\n \"mobius-text-field__input-wrapper\",\n sharedClasses,\n );\n\n return (\n <Stack gap=\"xs\" className={containerClasses}>\n {label && !hidden && (\n <Label {...labelProps} className={labelClasses}>\n {label}\n </Label>\n )}\n <div className=\"mobius-text-field__inner-container\">\n {adornmentWithClassName(\n prefixOutside,\n labelClasses,\n \"mobius-text-field__prefix-outside\",\n )}\n <div className={inputWrapperClasses}>\n {adornmentWithClassName(\n prefixInside,\n labelClasses,\n \"mobius-text-field__prefix-inside\",\n )}\n <input\n {...otherProps}\n {...inputProps}\n ref={ref}\n type={type}\n className={inputClasses}\n />\n {adornmentWithClassName(\n suffixInside,\n labelClasses,\n \"mobius-text-field__suffix-inside\",\n )}\n </div>\n {adornmentWithClassName(\n suffixOutside,\n labelClasses,\n \"mobius-text-field__suffix-outside\",\n )}\n </div>\n {children && (\n <div className=\"mobius-text-field__children\">{children}</div>\n )}\n\n <ErrorMessage {...errorMessageProps} errorMessage={errorMessage} />\n </Stack>\n );\n};\n\nconst TextField = memo(TextFieldInner);\nTextField.displayName = \"TextField\";\nexport { TextField };\n", "export function spaceDelimitedList(\n list: (string | null | undefined)[],\n): string | undefined {\n return list.filter(Boolean).join(\" \") || undefined;\n}\n", "import type { LabelHTMLAttributes } from \"react\";\nimport { useId, useRef } from \"react\";\n\nexport type UseLabelProps = {\n id?: string | undefined;\n label?: string | undefined;\n \"aria-label\"?: string | undefined;\n \"aria-labelledby\"?: string | undefined;\n labelElementType?: \"label\" | \"span\" | undefined;\n};\n\nexport type UseLabelReturn = {\n labelProps: {\n id?: string | undefined;\n } & LabelHTMLAttributes<HTMLLabelElement>;\n fieldProps: LabellingProps;\n};\n\nexport type LabellingProps = {\n id?: string | undefined;\n \"aria-label\"?: string | undefined;\n \"aria-labelledby\"?: string | undefined;\n \"aria-describedby\"?: string | undefined;\n \"aria-details\"?: string | undefined;\n};\n\nexport function useLabel({\n id: providedId,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n labelElementType = \"label\",\n}: UseLabelProps) {\n let labelProps: UseLabelReturn[\"labelProps\"] = {};\n let fieldProps: UseLabelReturn[\"fieldProps\"] = {};\n\n const hasWarnedAboutMissingLabels = useRef(false);\n\n const fallbackId = useId();\n const id = providedId || fallbackId;\n const labelId = useId();\n\n if (label) {\n ariaLabelledby = ariaLabelledby ? `${labelId} ${ariaLabelledby}` : labelId;\n labelProps = {\n id: labelId,\n htmlFor: labelElementType === \"label\" ? id : undefined,\n };\n } else if (\n !ariaLabelledby &&\n !ariaLabel &&\n !hasWarnedAboutMissingLabels.current\n ) {\n hasWarnedAboutMissingLabels.current = true;\n console.warn(\n \"If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility\",\n );\n }\n\n fieldProps = {\n id,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n };\n\n return {\n labelProps,\n fieldProps,\n };\n}\n", "import { useId } from \"react\";\nimport { spaceDelimitedList } from \"../../utils/spaceDelimitedList\";\nimport { useLabel } from \"../useLabel/useLabel\";\nimport type { UseTextFieldProps, UseTextFieldReturn } from \"./types\";\n\nexport function useTextField(props: UseTextFieldProps): UseTextFieldReturn {\n const {\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n inputElementType = \"input\",\n } = props;\n const { labelProps, fieldProps } = useLabel(props);\n\n const descriptionId = useId();\n const descriptionProps = { id: descriptionId };\n\n const errorMessageId = useId();\n const errorMessageProps = { id: errorMessageId };\n\n const ariaDescribedBy = spaceDelimitedList([\n props.description && descriptionId,\n props.errorMessage && errorMessageId,\n props[\"aria-describedby\"],\n ]);\n\n return {\n descriptionProps,\n errorMessageProps,\n labelProps,\n inputProps: {\n defaultValue: props.defaultValue,\n value: props.value,\n onChange: props.onChange,\n disabled: isDisabled,\n readOnly: isReadOnly,\n required: isRequired,\n \"aria-required\": isRequired === true ? true : undefined,\n \"aria-invalid\": props.isInvalid,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": props[\"aria-errormessage\"],\n role: props.role,\n\n type: inputElementType === \"input\" ? props.type : undefined,\n pattern: inputElementType === \"input\" ? props.pattern : undefined,\n\n autoComplete: props.autoComplete,\n maxLength: props.maxLength,\n minLength: props.minLength,\n name: props.name,\n placeholder: props.placeholder,\n inputMode: props.inputMode,\n\n // Clipboard events\n onCopy: props.onCopy,\n onCut: props.onCut,\n onPaste: props.onPaste,\n\n // Composition events\n onCompositionEnd: props.onCompositionEnd,\n onCompositionStart: props.onCompositionStart,\n onCompositionUpdate: props.onCompositionUpdate,\n\n // Selection events\n onSelect: props.onSelect,\n\n // Input events\n onBeforeInput: props.onBeforeInput,\n onInput: props.onInput,\n\n // Focus events\n onFocus: props.onFocus,\n onBlur: props.onBlur,\n\n ...fieldProps,\n },\n };\n}\n", "import type { Validation } from \"../../types\";\n\nexport type GetValidationClassesProps = Pick<Validation, \"isInvalid\">;\n\nexport const useValidationClasses = (props: GetValidationClassesProps) => {\n const { isInvalid } = props;\n\n if (isInvalid) {\n return \"--is-invalid\";\n }\n\n if (isInvalid === false) {\n return \"--is-valid\";\n }\n\n return \"\";\n};\n", "import { error } from \"@simplybusiness/icons\";\nimport classNames from \"classnames/dedupe\";\nimport { Icon } from \"../Icon\";\nimport { TextOrHTML } from \"../TextOrHTML\";\nimport \"./ErrorMessage.css\";\n\nexport interface ErrorMessageProps {\n errorMessage?: string;\n id?: string;\n className?: string;\n}\n\nexport const ErrorMessage = ({\n id,\n errorMessage,\n className,\n}: ErrorMessageProps) => {\n const classes = classNames(\"mobius\", \"mobius-error-message\", className);\n\n if (!errorMessage) return null;\n\n return (\n <div id={id} className={classes} data-testid=\"ErrorMessage\" role=\"alert\">\n <Icon\n icon={error}\n className=\"mobius-error-message__icon\"\n aria-hidden=\"true\"\n />\n <TextOrHTML\n elementType=\"span\"\n className=\"mobius-error-message__text\"\n text={errorMessage}\n />\n </div>\n );\n};\n\nErrorMessage.displayName = \"ErrorMessage\";\n", "import classNames from \"classnames/dedupe\";\nimport type { IconProps } from \"./types\";\nimport \"./Icon.css\";\n\nconst ICON_PREFIX = \"mobius-icon\";\n\nconst capitaliseFirstLetter = (str: string) =>\n str.charAt(0).toUpperCase() + str.slice(1);\n\nexport function Icon({\n ref,\n icon,\n className,\n size = \"xs\",\n color,\n fixedWidth,\n spin,\n spinReverse,\n title,\n ...otherProps\n}: IconProps) {\n if (!icon) {\n throw new Error(\"Must specify icon object\");\n }\n\n const classes = classNames(\n \"mobius\",\n \"mobius-icon\",\n `svg-inline--${ICON_PREFIX}`,\n `--size-${size}`,\n className,\n {\n [`${ICON_PREFIX}-fw`]: fixedWidth,\n [`${ICON_PREFIX}-spin`]: spin || spinReverse,\n [`${ICON_PREFIX}-spin-reverse`]: spinReverse,\n },\n );\n\n const { iconName, width, height, svgPathData } = icon;\n const formattedIconName = iconName.split(\"-\").join(\" \");\n\n const defaultTitle = `${capitaliseFirstLetter(formattedIconName)} icon`;\n const titleText = title || defaultTitle;\n\n return (\n <svg\n ref={ref}\n focusable=\"false\"\n data-icon={iconName}\n className={classes}\n role=\"img\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox={`0 0 ${width} ${height}`}\n style={{ color }}\n {...otherProps}\n >\n <title>{titleText}</title>\n <path fill=\"currentColor\" d={svgPathData} />\n </svg>\n );\n}\n", "import classNames from \"classnames/dedupe\";\nimport type { RefAttributes } from \"react\";\nimport { useMemo } from \"react\";\nimport type { TextElementType, TextProps } from \"../Text/Text\";\nimport { Text, getElementType } from \"../Text/Text\";\n\nexport type HTMLElementType = \"span\" | \"div\";\n\n// Block-level tags that cannot be nested inside <p>.\nconst BLOCK_TAG =\n /<(div|p|ul|ol|li|h[1-6]|table|tr|td|th|blockquote|pre|hr|dl|dt|dd)[\\s>/]/i;\nconst containsBlockHTML = (text: string) => BLOCK_TAG.test(text);\nconst containsHTML = (text: string) =>\n /<[a-z/]/i.test(text) || /&(?:#\\d+|#x[\\da-f]+|[a-z]\\w*);/i.test(text); // tag or entity\n\nconst buildTextClasses = (\n textProps: Omit<TextProps, \"children\">,\n htmlClassName?: string,\n) => {\n const { variant, elementType, spacing, className } = textProps;\n const variantType = variant || getElementType(variant, elementType);\n return classNames(\n \"mobius\",\n \"mobius-text\",\n { [`--is-${variantType}`]: variantType },\n { [`--has-line-height-${spacing}`]: spacing },\n className,\n htmlClassName,\n );\n};\n\nexport interface TextOrHTMLProps\n extends Omit<TextProps, \"children\">, RefAttributes<TextElementType> {\n /** HTML string to be rendered with dangerouslySetInnerHTML */\n text: string;\n /** Custom class name for the dangerous HTML element */\n htmlClassName?: string;\n /** HTML element type for the dangerous HTML element */\n htmlElementType?: HTMLElementType;\n /** If true, wraps the dangerous HTML element inside a Text component */\n textWrapper?: boolean;\n /** If true, auto-detects whether text is HTML or plain text to determine wrapping and element type */\n autoDetect?: boolean;\n}\n\nconst TextOrHTML = ({\n ref,\n text,\n htmlClassName,\n htmlElementType,\n textWrapper = false,\n autoDetect = false,\n ...textProps\n}: TextOrHTMLProps) => {\n const hasBlockContent = autoDetect && containsBlockHTML(text);\n\n // Memoize the dangerouslySetInnerHTML object to prevent unnecessary re-renders\n // See: https://github.com/facebook/react/issues/31660\n const dangerousHTML = useMemo(() => ({ __html: text }), [text]);\n\n // Non-block text with autoDetect: render directly on a Text-equivalent element,\n // avoiding unnecessary <span> nesting inside <p>.\n if (autoDetect && !hasBlockContent) {\n const { variant, spacing, elementType, className, ...domProps } = textProps;\n const Element = getElementType(variant, elementType);\n const classes = buildTextClasses(textProps, htmlClassName);\n\n return containsHTML(text) ? (\n <Element\n ref={ref}\n {...domProps}\n className={classes}\n dangerouslySetInnerHTML={dangerousHTML}\n />\n ) : (\n <Element ref={ref} {...domProps} className={classes}>\n {text}\n </Element>\n );\n }\n\n const DangerousComponent =\n htmlElementType ?? (hasBlockContent ? \"div\" : \"span\");\n const dangerousElement = (\n <DangerousComponent\n className={htmlClassName}\n dangerouslySetInnerHTML={dangerousHTML}\n />\n );\n\n if (textWrapper) {\n return (\n <Text ref={ref} {...textProps}>\n {dangerousElement}\n </Text>\n );\n }\n\n return dangerousElement;\n};\n\nTextOrHTML.displayName = \"TextOrHTML\";\nexport { TextOrHTML };\n", "import type { ReactNode, RefAttributes } from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport type { DOMProps } from \"../../types/dom\";\nimport \"./Text.css\";\n\nexport type TextElementType = HTMLHeadingElement | HTMLParagraphElement;\nexport type TextVariantType =\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"body\"\n | \"small\"\n | \"legal\"\n | \"title\";\nexport type ElementType = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"p\" | \"span\";\nexport interface TextProps extends DOMProps, RefAttributes<TextElementType> {\n /** HTML element for the text */\n elementType?: ElementType;\n /** Specify font size override */\n variant?: TextVariantType;\n /** Specify compact line height override */\n spacing?: \"loose\" | \"tight\";\n /** Custom class name for setting specific CSS */\n className?: string;\n children: ReactNode;\n style?: React.CSSProperties;\n}\n\nexport const getElementType = (\n variant: TextVariantType | undefined,\n elementType: ElementType | undefined,\n): ElementType => {\n // Explicit elementType always wins\n if (elementType) {\n return elementType;\n }\n // Infer element from variant\n if (variant && [\"h1\", \"h2\", \"h3\", \"h4\"].includes(variant)) {\n return variant as ElementType;\n }\n return \"p\";\n};\n\nconst Text = ({ ref, elementType, ...props }: TextProps) => {\n // Remove non-DOM props from element\n const { variant, className, spacing, ...otherProps } = props;\n\n // If a variant is supplied, set the class name and element type\n const Element: ElementType = getElementType(variant, elementType);\n const variantType = variant || Element;\n const classes = classNames(\n \"mobius\",\n \"mobius-text\",\n { [`--is-${variantType}`]: variantType },\n { [`--has-line-height-${spacing}`]: spacing },\n className,\n );\n\n return <Element ref={ref} {...otherProps} className={classes} />;\n};\n\nText.displayName = \"Text\";\nexport { Text };\n", "import type React from \"react\";\nimport type { ReactNode, RefAttributes } from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport type { DOMProps } from \"../../types/dom\";\nimport \"./Label.css\";\n\nexport type LabelElementType = HTMLLabelElement;\nexport type IntrinsicLabel = Omit<\n React.JSX.IntrinsicElements[\"label\"],\n \"css\" | \"color\" | \"ref\"\n>;\n\nexport interface LabelProps\n extends IntrinsicLabel, DOMProps, RefAttributes<LabelElementType> {\n children?: ReactNode;\n className?: string;\n elementType?: \"label\" | \"span\";\n}\n\nconst Label = ({ ref, ...props }: LabelProps) => {\n const { elementType: Element = \"label\", children, ...otherProps } = props;\n\n const classes = classNames(\"mobius\", \"mobius-label\", props.className);\n otherProps.className = classes;\n\n return (\n <Element ref={ref} {...otherProps} className={classes}>\n {children}\n </Element>\n );\n};\n\nLabel.displayName = \"Label\";\nexport { Label };\n", "import type { Ref, RefAttributes, ReactNode } from \"react\";\nimport type React from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport type { DOMProps } from \"../../types/dom\";\nimport type { SpacingType } from \"../../types\";\nimport \"./Stack.css\";\n\nexport type StackElementType = HTMLDivElement;\n\nexport interface StackProps extends DOMProps, RefAttributes<StackElementType> {\n children?: ReactNode;\n /** How big a gap between items */\n gap?: SpacingType;\n /** Custom class name for setting specific CSS */\n className?: string;\n elementType?: React.ElementType;\n}\n\nexport type StackRef = Ref<StackElementType>;\n\nexport const Stack = ({ ref, ...props }: StackProps) => {\n const { elementType: Element = \"div\", gap, ...otherProps } = props;\n\n const classes = classNames(\n \"mobius\",\n \"mobius-stack\",\n {\n [`--gap-${gap}`]: gap,\n },\n otherProps.className,\n );\n\n return <Element ref={ref} {...otherProps} className={classes} />;\n};\n\nStack.displayName = \"Stack\";\n", "import classNames from \"classnames/dedupe\";\nimport type { ReactElement } from \"react\";\nimport { cloneElement } from \"react\";\n\nexport const adornmentWithClassName = (\n component?: ReactElement,\n validationClasses?: string,\n className?: string,\n) => {\n if (!component) return null;\n\n const typedComponent = component as ReactElement<{ className?: string }>;\n return cloneElement(typedComponent, {\n className: classNames(\n typedComponent.props.className,\n validationClasses,\n className,\n ),\n });\n};\n", "import { eye, eyeSlash } from \"@simplybusiness/icons\";\nimport { Icon } from \"../Icon\";\n\nexport interface ShowHideButtonProps {\n show?: boolean;\n onClick: () => void;\n}\n\nexport const ShowHideButton = ({\n show = false,\n onClick,\n}: ShowHideButtonProps) => (\n <button\n className=\"mobius-password-field__show-button\"\n type=\"button\"\n onClick={e => {\n e.preventDefault();\n onClick();\n }}\n aria-label={`${show ? \"Hide\" : \"Show\"} password`}\n data-testid=\"show-hide-button\"\n >\n <Icon icon={show ? eyeSlash : eye} aria-hidden=\"true\" />\n </button>\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAAA,iBAAuB;AACvB,IAAAC,gBAAiC;;;ACA1B,SAAS,UACd,MACgB;AAChB,SAAO,WAAS;AACd,SAAK,QAAQ,SAAO;AAClB,UAAI,OAAO,QAAQ,YAAY;AAC7B,YAAI,KAAK;AAAA,MAC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W,CAAC,OAAO;AAC3B,0BAAsB,MAAM;AAC1B,eAAS,SAAS,MAAM;AACxB,UAAI,kBAAkB,QAAQ,gBAAgB,MAAM;AAClD,iBAAS,SAAS,kBAAkB,gBAAgB,YAAY;AAAA,MAClE;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK,UAAU,CAAC,UAAU,GAAG,CAAC;AAAA,MAC9B,WAAW;AAAA,MACV,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA,cACE,6CAAC,kBAAe,SAAS,2BAA2B,MAAY;AAAA;AAAA,EAEpE;AAEJ;AAEA,cAAc,cAAc;",
|
|
6
|
+
"names": ["import_dedupe", "import_react", "import_dedupe", "import_react", "import_react", "import_dedupe", "classNames", "import_dedupe", "import_react", "import_dedupe", "import_jsx_runtime", "classNames", "import_jsx_runtime", "classNames", "import_jsx_runtime", "classNames", "import_dedupe", "import_jsx_runtime", "classNames", "import_dedupe", "import_jsx_runtime", "classNames", "import_dedupe", "import_react", "classNames", "import_jsx_runtime", "classNames", "import_icons", "import_jsx_runtime", "import_jsx_runtime", "classNames"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/Popover/Arrow.tsx
|
|
21
|
+
var Arrow_exports = {};
|
|
22
|
+
__export(Arrow_exports, {
|
|
23
|
+
Arrow: () => Arrow
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Arrow_exports);
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var Arrow = ({ ref, width = 20, className, style }) => {
|
|
28
|
+
const height = width / 2;
|
|
29
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
30
|
+
"svg",
|
|
31
|
+
{
|
|
32
|
+
ref,
|
|
33
|
+
className,
|
|
34
|
+
"aria-hidden": "true",
|
|
35
|
+
width,
|
|
36
|
+
height,
|
|
37
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
38
|
+
style,
|
|
39
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: `M0,0 H${width} L${width / 2},${height} Z` })
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=Arrow.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/Popover/Arrow.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { CSSProperties, Ref } from \"react\";\n\ninterface ArrowProps {\n ref?: Ref<SVGSVGElement>;\n width?: number;\n className?: string;\n style?: CSSProperties;\n}\n\nexport const Arrow = ({ ref, width = 20, className, style }: ArrowProps) => {\n const height = width / 2;\n return (\n <svg\n ref={ref}\n className={className}\n aria-hidden=\"true\"\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n style={style}\n >\n <path d={`M0,0 H${width} L${width / 2},${height} Z`} />\n </svg>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBM;AAZC,IAAM,QAAQ,CAAC,EAAE,KAAK,QAAQ,IAAI,WAAW,MAAM,MAAkB;AAC1E,QAAM,SAAS,QAAQ;AACvB,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,eAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA,SAAS,OAAO,KAAK,IAAI,MAAM;AAAA,MAC/B;AAAA,MAEA,sDAAC,UAAK,GAAG,SAAS,KAAK,KAAK,QAAQ,CAAC,IAAI,MAAM,MAAM;AAAA;AAAA,EACvD;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -33,10 +33,10 @@ __export(Popover_exports, {
|
|
|
33
33
|
Popover: () => Popover
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(Popover_exports);
|
|
36
|
-
var import_react2 = require("@floating-ui/react");
|
|
37
36
|
var import_icons3 = require("@simplybusiness/icons");
|
|
38
37
|
var import_dedupe3 = __toESM(require("classnames/dedupe"));
|
|
39
|
-
var
|
|
38
|
+
var import_react5 = require("react");
|
|
39
|
+
var import_react_dom = require("react-dom");
|
|
40
40
|
var import_mobius_hooks = require("@simplybusiness/mobius-hooks");
|
|
41
41
|
|
|
42
42
|
// src/components/Button/Button.tsx
|
|
@@ -241,54 +241,224 @@ var Button = ({ ref, ...props }) => {
|
|
|
241
241
|
};
|
|
242
242
|
Button.displayName = "Button";
|
|
243
243
|
|
|
244
|
+
// src/components/Popover/Arrow.tsx
|
|
245
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
246
|
+
var Arrow = ({ ref, width = 20, className, style }) => {
|
|
247
|
+
const height = width / 2;
|
|
248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
249
|
+
"svg",
|
|
250
|
+
{
|
|
251
|
+
ref,
|
|
252
|
+
className,
|
|
253
|
+
"aria-hidden": "true",
|
|
254
|
+
width,
|
|
255
|
+
height,
|
|
256
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
257
|
+
style,
|
|
258
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: `M0,0 H${width} L${width / 2},${height} Z` })
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// src/components/Popover/useAutoUpdate.ts
|
|
264
|
+
var import_react2 = require("react");
|
|
265
|
+
var useAutoUpdate = ({
|
|
266
|
+
referenceRef,
|
|
267
|
+
floatingRef,
|
|
268
|
+
onUpdate,
|
|
269
|
+
enabled
|
|
270
|
+
}) => {
|
|
271
|
+
(0, import_react2.useEffect)(() => {
|
|
272
|
+
if (!enabled) return;
|
|
273
|
+
const reference = referenceRef.current;
|
|
274
|
+
const floating = floatingRef.current;
|
|
275
|
+
const scrollOpts = {
|
|
276
|
+
capture: true,
|
|
277
|
+
passive: true
|
|
278
|
+
};
|
|
279
|
+
window.addEventListener("scroll", onUpdate, scrollOpts);
|
|
280
|
+
window.addEventListener("resize", onUpdate, { passive: true });
|
|
281
|
+
const observer = typeof ResizeObserver === "function" ? new ResizeObserver(onUpdate) : null;
|
|
282
|
+
if (observer && reference) observer.observe(reference);
|
|
283
|
+
if (observer && floating) observer.observe(floating);
|
|
284
|
+
return () => {
|
|
285
|
+
window.removeEventListener("scroll", onUpdate, scrollOpts);
|
|
286
|
+
window.removeEventListener("resize", onUpdate);
|
|
287
|
+
observer?.disconnect();
|
|
288
|
+
};
|
|
289
|
+
}, [enabled, onUpdate, referenceRef, floatingRef]);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// src/components/Popover/useFloatingPosition.ts
|
|
293
|
+
var import_react3 = require("react");
|
|
294
|
+
var ABSOLUTE_FLOATING_STYLES = {
|
|
295
|
+
position: "absolute",
|
|
296
|
+
top: 0,
|
|
297
|
+
left: 0,
|
|
298
|
+
width: "max-content"
|
|
299
|
+
};
|
|
300
|
+
var FIXED_FLOATING_STYLES = {
|
|
301
|
+
position: "fixed",
|
|
302
|
+
top: 0,
|
|
303
|
+
left: 0,
|
|
304
|
+
width: "max-content"
|
|
305
|
+
};
|
|
306
|
+
var INITIAL_ARROW_STYLES = {
|
|
307
|
+
position: "absolute"
|
|
308
|
+
};
|
|
309
|
+
var VIEWPORT_PADDING = 0;
|
|
310
|
+
var createsFixedContainingBlock = (el) => {
|
|
311
|
+
const style = window.getComputedStyle(el);
|
|
312
|
+
return style.transform !== "none" || style.filter !== "none" || style.backdropFilter !== "none" || style.perspective !== "none" || /\b(transform|filter|perspective)\b/.test(style.willChange);
|
|
313
|
+
};
|
|
314
|
+
var useFloatingPosition = ({
|
|
315
|
+
referenceRef,
|
|
316
|
+
floatingRef,
|
|
317
|
+
arrowRef,
|
|
318
|
+
isOpen,
|
|
319
|
+
offsetPx,
|
|
320
|
+
arrowWidth,
|
|
321
|
+
useFixedStrategy
|
|
322
|
+
}) => {
|
|
323
|
+
const update = (0, import_react3.useCallback)(() => {
|
|
324
|
+
const reference = referenceRef.current;
|
|
325
|
+
const floating = floatingRef.current;
|
|
326
|
+
if (!reference || !floating) return;
|
|
327
|
+
const refRect = reference.getBoundingClientRect();
|
|
328
|
+
const floatingWidth = floating.offsetWidth;
|
|
329
|
+
const floatingHeight = floating.offsetHeight;
|
|
330
|
+
const scrollX = useFixedStrategy ? 0 : window.scrollX;
|
|
331
|
+
const scrollY = useFixedStrategy ? 0 : window.scrollY;
|
|
332
|
+
const parent = floating.parentElement;
|
|
333
|
+
const parentIsCb = useFixedStrategy && !!parent && createsFixedContainingBlock(parent);
|
|
334
|
+
const boundsRect = parentIsCb ? parent.getBoundingClientRect() : {
|
|
335
|
+
left: 0,
|
|
336
|
+
top: 0,
|
|
337
|
+
right: window.innerWidth,
|
|
338
|
+
bottom: window.innerHeight
|
|
339
|
+
};
|
|
340
|
+
const bottomTopViewport = refRect.bottom + offsetPx;
|
|
341
|
+
const topTopViewport = refRect.top - floatingHeight - offsetPx;
|
|
342
|
+
const overflowsBottom = bottomTopViewport + floatingHeight > boundsRect.bottom;
|
|
343
|
+
const fitsTop = topTopViewport >= boundsRect.top;
|
|
344
|
+
const nextPlacement = overflowsBottom && fitsTop ? "top" : "bottom";
|
|
345
|
+
const topViewport = nextPlacement === "bottom" ? bottomTopViewport : topTopViewport;
|
|
346
|
+
const rawLeftViewport = refRect.left + refRect.width / 2 - floatingWidth / 2;
|
|
347
|
+
const minLeftViewport = boundsRect.left + VIEWPORT_PADDING;
|
|
348
|
+
const maxLeftViewport = Math.max(
|
|
349
|
+
minLeftViewport,
|
|
350
|
+
boundsRect.right - floatingWidth - VIEWPORT_PADDING
|
|
351
|
+
);
|
|
352
|
+
const leftViewport = Math.min(
|
|
353
|
+
Math.max(minLeftViewport, rawLeftViewport),
|
|
354
|
+
maxLeftViewport
|
|
355
|
+
);
|
|
356
|
+
const cbOffsetLeft = parentIsCb ? boundsRect.left : 0;
|
|
357
|
+
const cbOffsetTop = parentIsCb ? boundsRect.top : 0;
|
|
358
|
+
floating.style.top = `${topViewport + scrollY - cbOffsetTop}px`;
|
|
359
|
+
floating.style.left = `${leftViewport + scrollX - cbOffsetLeft}px`;
|
|
360
|
+
const arrow = arrowRef.current;
|
|
361
|
+
if (!arrow) return;
|
|
362
|
+
const arrowHalf = arrowWidth / 2;
|
|
363
|
+
const refCenterX = refRect.left + refRect.width / 2;
|
|
364
|
+
const rawArrowLeft = refCenterX - leftViewport - arrowHalf;
|
|
365
|
+
const maxArrowLeft = Math.max(0, floatingWidth - arrowWidth);
|
|
366
|
+
const arrowLeft = Math.min(Math.max(0, rawArrowLeft), maxArrowLeft);
|
|
367
|
+
arrow.style.left = `${arrowLeft}px`;
|
|
368
|
+
if (nextPlacement === "bottom") {
|
|
369
|
+
arrow.style.bottom = "100%";
|
|
370
|
+
arrow.style.top = "";
|
|
371
|
+
arrow.style.transform = "rotate(180deg)";
|
|
372
|
+
} else {
|
|
373
|
+
arrow.style.top = "100%";
|
|
374
|
+
arrow.style.bottom = "";
|
|
375
|
+
arrow.style.transform = "";
|
|
376
|
+
}
|
|
377
|
+
}, [
|
|
378
|
+
referenceRef,
|
|
379
|
+
floatingRef,
|
|
380
|
+
arrowRef,
|
|
381
|
+
offsetPx,
|
|
382
|
+
arrowWidth,
|
|
383
|
+
useFixedStrategy
|
|
384
|
+
]);
|
|
385
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
386
|
+
if (!isOpen) return;
|
|
387
|
+
update();
|
|
388
|
+
}, [isOpen, update]);
|
|
389
|
+
return {
|
|
390
|
+
initialFloatingStyles: useFixedStrategy ? FIXED_FLOATING_STYLES : ABSOLUTE_FLOATING_STYLES,
|
|
391
|
+
initialArrowStyles: INITIAL_ARROW_STYLES,
|
|
392
|
+
update
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
// src/components/Popover/useOutsidePress.ts
|
|
397
|
+
var import_react4 = require("react");
|
|
398
|
+
var useOutsidePress = ({
|
|
399
|
+
referenceRef,
|
|
400
|
+
floatingRef,
|
|
401
|
+
enabled,
|
|
402
|
+
onOutsidePress
|
|
403
|
+
}) => {
|
|
404
|
+
(0, import_react4.useEffect)(() => {
|
|
405
|
+
if (!enabled) return;
|
|
406
|
+
const handler = (event) => {
|
|
407
|
+
const target = event.target;
|
|
408
|
+
if (!target) return;
|
|
409
|
+
if (referenceRef.current?.contains(target)) return;
|
|
410
|
+
if (floatingRef.current?.contains(target)) return;
|
|
411
|
+
onOutsidePress(event);
|
|
412
|
+
};
|
|
413
|
+
document.addEventListener("pointerdown", handler);
|
|
414
|
+
return () => document.removeEventListener("pointerdown", handler);
|
|
415
|
+
}, [enabled, onOutsidePress, referenceRef, floatingRef]);
|
|
416
|
+
};
|
|
417
|
+
|
|
244
418
|
// src/components/Popover/Popover.tsx
|
|
245
419
|
var import_Popover = require("@simplybusiness/mobius/src/components/Popover/Popover.css");
|
|
246
|
-
var
|
|
420
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
247
421
|
var OFFSET_FROM_CONTENT_DEFAULT = 10;
|
|
422
|
+
var ARROW_WIDTH = 20;
|
|
248
423
|
var Popover = (props) => {
|
|
249
424
|
const { trigger, children, onOpen, onClose, className } = props;
|
|
250
|
-
const
|
|
251
|
-
const
|
|
252
|
-
const
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
]
|
|
425
|
+
const referenceRef = (0, import_react5.useRef)(null);
|
|
426
|
+
const floatingRef = (0, import_react5.useRef)(null);
|
|
427
|
+
const arrowRef = (0, import_react5.useRef)(null);
|
|
428
|
+
const [isOpen, setIsOpen] = (0, import_react5.useState)(false);
|
|
429
|
+
const [portalTarget, setPortalTarget] = (0, import_react5.useState)(null);
|
|
430
|
+
const isInsideDialog = portalTarget !== null && portalTarget.tagName === "DIALOG";
|
|
431
|
+
const { initialFloatingStyles, initialArrowStyles, update } = useFloatingPosition({
|
|
432
|
+
referenceRef,
|
|
433
|
+
floatingRef,
|
|
434
|
+
arrowRef,
|
|
435
|
+
isOpen,
|
|
436
|
+
offsetPx: OFFSET_FROM_CONTENT_DEFAULT,
|
|
437
|
+
arrowWidth: ARROW_WIDTH,
|
|
438
|
+
useFixedStrategy: isInsideDialog
|
|
265
439
|
});
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
440
|
+
useAutoUpdate({
|
|
441
|
+
referenceRef,
|
|
442
|
+
floatingRef,
|
|
443
|
+
onUpdate: update,
|
|
444
|
+
enabled: isOpen
|
|
445
|
+
});
|
|
446
|
+
useOutsidePress({
|
|
447
|
+
referenceRef,
|
|
448
|
+
floatingRef,
|
|
449
|
+
enabled: isOpen,
|
|
450
|
+
onOutsidePress: () => {
|
|
451
|
+
onClose?.();
|
|
452
|
+
setIsOpen(false);
|
|
275
453
|
}
|
|
276
454
|
});
|
|
277
|
-
const { getReferenceProps, getFloatingProps } = (0, import_react2.useInteractions)([dismiss]);
|
|
278
455
|
const containerClasses = (0, import_dedupe3.default)(
|
|
279
456
|
"mobius",
|
|
280
457
|
"mobius-popover__container",
|
|
281
458
|
className
|
|
282
459
|
);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
refs.setFloating(node);
|
|
286
|
-
floatingContainerRef.current = node;
|
|
287
|
-
},
|
|
288
|
-
[refs]
|
|
289
|
-
);
|
|
290
|
-
(0, import_react3.useEffect)(() => {
|
|
291
|
-
const el = floatingContainerRef.current;
|
|
460
|
+
(0, import_react5.useEffect)(() => {
|
|
461
|
+
const el = floatingRef.current;
|
|
292
462
|
if (!el) return;
|
|
293
463
|
const preventLabelActivation = (e) => {
|
|
294
464
|
const target = e.target;
|
|
@@ -305,68 +475,73 @@ var Popover = (props) => {
|
|
|
305
475
|
onClose?.();
|
|
306
476
|
return;
|
|
307
477
|
}
|
|
478
|
+
const dialog = referenceRef.current?.closest("dialog");
|
|
479
|
+
setPortalTarget(dialog ?? document.body);
|
|
308
480
|
setIsOpen(true);
|
|
309
481
|
onOpen?.();
|
|
310
482
|
};
|
|
311
|
-
const
|
|
312
|
-
|
|
483
|
+
const setReferenceRef = (0, import_react5.useCallback)((node) => {
|
|
484
|
+
referenceRef.current = node;
|
|
485
|
+
}, []);
|
|
486
|
+
const triggerComponent = (0, import_react5.cloneElement)(trigger, {
|
|
487
|
+
ref: setReferenceRef,
|
|
313
488
|
className: (0, import_dedupe3.default)(
|
|
314
489
|
trigger.props.className,
|
|
315
490
|
"mobius-popover__toggle"
|
|
316
491
|
),
|
|
317
|
-
onClick: toggleVisibility
|
|
318
|
-
...getReferenceProps()
|
|
492
|
+
onClick: toggleVisibility
|
|
319
493
|
});
|
|
320
494
|
(0, import_mobius_hooks.useWindowEvent)("keydown", (e) => {
|
|
321
|
-
if (e.key === "Escape") {
|
|
495
|
+
if (e.key === "Escape" && isOpen) {
|
|
496
|
+
setIsOpen(false);
|
|
322
497
|
onClose?.();
|
|
323
498
|
e.preventDefault();
|
|
324
499
|
e.stopPropagation();
|
|
325
500
|
}
|
|
326
501
|
});
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mobius-popover", children: [
|
|
338
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("header", { className: "mobius-popover__header", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
339
|
-
Button,
|
|
340
|
-
{
|
|
341
|
-
type: "button",
|
|
342
|
-
className: "mobius-popover__close-button",
|
|
343
|
-
onClick: toggleVisibility,
|
|
344
|
-
"aria-label": "Close",
|
|
345
|
-
variant: "ghost",
|
|
346
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
347
|
-
Icon,
|
|
348
|
-
{
|
|
349
|
-
icon: import_icons3.cross,
|
|
350
|
-
size: "md",
|
|
351
|
-
className: "mobius-popover__close-icon"
|
|
352
|
-
}
|
|
353
|
-
)
|
|
354
|
-
}
|
|
355
|
-
) }),
|
|
356
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mobius-popover__body", children })
|
|
357
|
-
] }),
|
|
358
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
359
|
-
import_react2.FloatingArrow,
|
|
502
|
+
const floatingElement = isOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
503
|
+
"div",
|
|
504
|
+
{
|
|
505
|
+
className: containerClasses,
|
|
506
|
+
ref: floatingRef,
|
|
507
|
+
style: initialFloatingStyles,
|
|
508
|
+
children: [
|
|
509
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "mobius-popover", children: [
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("header", { className: "mobius-popover__header", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
511
|
+
Button,
|
|
360
512
|
{
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
513
|
+
type: "button",
|
|
514
|
+
className: "mobius-popover__close-button",
|
|
515
|
+
onClick: toggleVisibility,
|
|
516
|
+
"aria-label": "Close",
|
|
517
|
+
variant: "ghost",
|
|
518
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
519
|
+
Icon,
|
|
520
|
+
{
|
|
521
|
+
icon: import_icons3.cross,
|
|
522
|
+
size: "md",
|
|
523
|
+
className: "mobius-popover__close-icon"
|
|
524
|
+
}
|
|
525
|
+
)
|
|
365
526
|
}
|
|
366
|
-
)
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
527
|
+
) }),
|
|
528
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mobius-popover__body", children })
|
|
529
|
+
] }),
|
|
530
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
531
|
+
Arrow,
|
|
532
|
+
{
|
|
533
|
+
ref: arrowRef,
|
|
534
|
+
style: initialArrowStyles,
|
|
535
|
+
className: "mobius-popover__arrow-icon",
|
|
536
|
+
width: ARROW_WIDTH
|
|
537
|
+
}
|
|
538
|
+
)
|
|
539
|
+
]
|
|
540
|
+
}
|
|
541
|
+
) : null;
|
|
542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
543
|
+
triggerComponent,
|
|
544
|
+
floatingElement && portalTarget ? (0, import_react_dom.createPortal)(floatingElement, portalTarget) : null
|
|
370
545
|
] });
|
|
371
546
|
};
|
|
372
547
|
//# sourceMappingURL=Popover.js.map
|