@doist/reactist 25.0.0-beta.2 → 25.0.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/README.md +35 -16
- package/dist/reactist.cjs.development.js +448 -422
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/alert/alert.js +13 -13
- package/es/alert/alert.js.map +1 -1
- package/es/alert/alert.module.css.js +1 -1
- package/es/avatar/avatar.js +6 -6
- package/es/avatar/avatar.js.map +1 -1
- package/es/avatar/avatar.module.css.js +1 -1
- package/es/avatar/utils.js.map +1 -1
- package/es/badge/badge.js +4 -4
- package/es/badge/badge.js.map +1 -1
- package/es/badge/badge.module.css.js +1 -1
- package/es/banner/banner.js +16 -16
- package/es/banner/banner.js.map +1 -1
- package/es/banner/banner.module.css.js +1 -1
- package/es/base-field/base-field.js +25 -25
- package/es/base-field/base-field.js.map +1 -1
- package/es/base-field/base-field.module.css.js +1 -1
- package/es/box/box.js +12 -12
- package/es/box/box.js.map +1 -1
- package/es/box/box.module.css.js +1 -1
- package/es/box/gap.module.css.js +1 -1
- package/es/box/margin.module.css.js +1 -1
- package/es/box/padding.module.css.js +1 -1
- package/es/box/width.module.css.js +1 -1
- package/es/button/button.js +19 -19
- package/es/button/button.js.map +1 -1
- package/es/button/button.module.css.js +1 -1
- package/es/checkbox-field/checkbox-field.js +16 -16
- package/es/checkbox-field/checkbox-field.js.map +1 -1
- package/es/checkbox-field/checkbox-field.module.css.js +1 -1
- package/es/checkbox-field/checkbox-icon.js +3 -3
- package/es/checkbox-field/checkbox-icon.js.map +1 -1
- package/es/checkbox-field/use-fork-ref.js.map +1 -1
- package/es/columns/columns.js +6 -6
- package/es/columns/columns.js.map +1 -1
- package/es/columns/columns.module.css.js +1 -1
- package/es/components/color-picker/color-picker.js +11 -11
- package/es/components/color-picker/color-picker.js.map +1 -1
- package/es/components/color-picker/index.js +1 -5
- package/es/components/color-picker/index.js.map +1 -1
- package/es/components/deprecated-button/deprecated-button.js +4 -4
- package/es/components/deprecated-button/deprecated-button.js.map +1 -1
- package/es/components/deprecated-button/index.js +1 -4
- package/es/components/deprecated-button/index.js.map +1 -1
- package/es/components/deprecated-dropdown/dropdown.js +11 -11
- package/es/components/deprecated-dropdown/dropdown.js.map +1 -1
- package/es/components/deprecated-dropdown/index.js +1 -4
- package/es/components/deprecated-dropdown/index.js.map +1 -1
- package/es/components/deprecated-input/index.js +1 -4
- package/es/components/deprecated-input/index.js.map +1 -1
- package/es/components/deprecated-input/input.js +3 -3
- package/es/components/deprecated-input/input.js.map +1 -1
- package/es/components/deprecated-select/index.js +1 -4
- package/es/components/deprecated-select/index.js.map +1 -1
- package/es/components/deprecated-select/select.js +3 -3
- package/es/components/deprecated-select/select.js.map +1 -1
- package/es/components/key-capturer/index.js +1 -5
- package/es/components/key-capturer/index.js.map +1 -1
- package/es/components/key-capturer/key-capturer.js +3 -3
- package/es/components/key-capturer/key-capturer.js.map +1 -1
- package/es/components/keyboard-shortcut/index.js +1 -4
- package/es/components/keyboard-shortcut/index.js.map +1 -1
- package/es/components/keyboard-shortcut/keyboard-shortcut.js +4 -4
- package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/es/components/progress-bar/index.js +1 -4
- package/es/components/progress-bar/index.js.map +1 -1
- package/es/components/progress-bar/progress-bar.js +5 -5
- package/es/components/progress-bar/progress-bar.js.map +1 -1
- package/es/components/time/index.js +1 -4
- package/es/components/time/index.js.map +1 -1
- package/es/components/time/time-utils.js.map +1 -1
- package/es/components/time/time.js +5 -5
- package/es/components/time/time.js.map +1 -1
- package/es/divider/divider.js +4 -4
- package/es/divider/divider.js.map +1 -1
- package/es/divider/divider.module.css.js +1 -1
- package/es/heading/heading.js +5 -5
- package/es/heading/heading.js.map +1 -1
- package/es/heading/heading.module.css.js +1 -1
- package/es/hidden/hidden.js +5 -5
- package/es/hidden/hidden.js.map +1 -1
- package/es/hidden/hidden.module.css.js +1 -1
- package/es/hidden-visually/hidden-visually.js +4 -4
- package/es/hidden-visually/hidden-visually.js.map +1 -1
- package/es/hidden-visually/hidden-visually.module.css.js +1 -1
- package/es/icons/alert-icon.js +10 -10
- package/es/icons/alert-icon.js.map +1 -1
- package/es/icons/close-icon.js +3 -3
- package/es/icons/close-icon.js.map +1 -1
- package/es/icons/password-hidden-icon.js +6 -6
- package/es/icons/password-hidden-icon.js.map +1 -1
- package/es/icons/password-visible-icon.js +5 -5
- package/es/icons/password-visible-icon.js.map +1 -1
- package/es/index.js +13 -15
- package/es/index.js.map +1 -1
- package/es/inline/inline.js +2 -2
- package/es/inline/inline.js.map +1 -1
- package/es/loading/loading.js +3 -3
- package/es/loading/loading.js.map +1 -1
- package/es/menu/menu.js +32 -32
- package/es/menu/menu.js.map +1 -1
- package/es/modal/modal.js +45 -45
- package/es/modal/modal.js.map +1 -1
- package/es/modal/modal.module.css.js +1 -1
- package/es/notice/notice.js +8 -8
- package/es/notice/notice.js.map +1 -1
- package/es/notice/notice.module.css.js +1 -1
- package/es/password-field/password-field.js +7 -7
- package/es/password-field/password-field.js.map +1 -1
- package/es/prose/prose.js +4 -4
- package/es/prose/prose.js.map +1 -1
- package/es/prose/prose.module.css.js +1 -1
- package/es/select-field/select-field.js +11 -11
- package/es/select-field/select-field.js.map +1 -1
- package/es/select-field/select-field.module.css.js +1 -1
- package/es/spinner/spinner.js +9 -9
- package/es/spinner/spinner.js.map +1 -1
- package/es/spinner/spinner.module.css.js +1 -1
- package/es/stack/stack.js +4 -4
- package/es/stack/stack.js.map +1 -1
- package/es/switch-field/switch-field.js +18 -18
- package/es/switch-field/switch-field.js.map +1 -1
- package/es/switch-field/switch-field.module.css.js +1 -1
- package/es/tabs/tabs.js +23 -23
- package/es/tabs/tabs.js.map +1 -1
- package/es/tabs/tabs.module.css.js +1 -1
- package/es/text/text.js +5 -5
- package/es/text/text.js.map +1 -1
- package/es/text/text.module.css.js +1 -1
- package/es/text-area/text-area.js +14 -14
- package/es/text-area/text-area.js.map +1 -1
- package/es/text-area/text-area.module.css.js +1 -1
- package/es/text-field/text-field.js +13 -13
- package/es/text-field/text-field.js.map +1 -1
- package/es/text-field/text-field.module.css.js +1 -1
- package/es/text-link/text-link.js +5 -5
- package/es/text-link/text-link.js.map +1 -1
- package/es/text-link/text-link.module.css.js +1 -1
- package/es/toast/static-toast.js +5 -5
- package/es/toast/static-toast.js.map +1 -1
- package/es/toast/toast-animation.js.map +1 -1
- package/es/toast/toast.module.css.js +1 -1
- package/es/toast/use-toasts.js +4 -4
- package/es/toast/use-toasts.js.map +1 -1
- package/es/tooltip/tooltip.js +9 -9
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/tooltip/tooltip.module.css.js +1 -1
- package/es/utils/common-helpers.js +2 -2
- package/es/utils/common-helpers.js.map +1 -1
- package/es/utils/polymorphism.js +2 -2
- package/es/utils/polymorphism.js.map +1 -1
- package/es/utils/responsive-props.js.map +1 -1
- package/lib/alert/alert.d.ts +3 -3
- package/lib/alert/alert.js +1 -1
- package/lib/alert/alert.js.map +1 -1
- package/lib/avatar/avatar.d.ts +2 -2
- package/lib/avatar/avatar.js +1 -1
- package/lib/avatar/avatar.js.map +1 -1
- package/lib/avatar/utils.js.map +1 -1
- package/lib/badge/badge.d.ts +2 -2
- package/lib/badge/badge.js +1 -1
- package/lib/badge/badge.js.map +1 -1
- package/lib/banner/banner.d.ts +2 -2
- package/lib/banner/banner.js +1 -1
- package/lib/banner/banner.js.map +1 -1
- package/lib/base-field/base-field.d.ts +9 -9
- package/lib/base-field/base-field.js +1 -1
- package/lib/base-field/base-field.js.map +1 -1
- package/lib/box/box.d.ts +15 -15
- package/lib/box/box.js +1 -1
- package/lib/box/box.js.map +1 -1
- package/lib/button/button.d.ts +4 -4
- package/lib/button/button.js +1 -1
- package/lib/button/button.js.map +1 -1
- package/lib/checkbox-field/checkbox-field.js +1 -1
- package/lib/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/checkbox-field/checkbox-icon.d.ts +1 -1
- package/lib/checkbox-field/checkbox-icon.js +1 -1
- package/lib/checkbox-field/checkbox-icon.js.map +1 -1
- package/lib/checkbox-field/use-fork-ref.js.map +1 -1
- package/lib/columns/columns.d.ts +4 -4
- package/lib/columns/columns.js +1 -1
- package/lib/columns/columns.js.map +1 -1
- package/lib/components/color-picker/color-picker.d.ts +3 -3
- package/lib/components/color-picker/color-picker.js +1 -1
- package/lib/components/color-picker/color-picker.js.map +1 -1
- package/lib/components/deprecated-button/deprecated-button.d.ts +4 -4
- package/lib/components/deprecated-button/deprecated-button.js +1 -1
- package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
- package/lib/components/deprecated-dropdown/dropdown.d.ts +5 -5
- package/lib/components/deprecated-dropdown/dropdown.js +1 -1
- package/lib/components/deprecated-dropdown/dropdown.js.map +1 -1
- package/lib/components/deprecated-input/input.js +1 -1
- package/lib/components/deprecated-input/input.js.map +1 -1
- package/lib/components/deprecated-select/select.d.ts +2 -2
- package/lib/components/deprecated-select/select.js +1 -1
- package/lib/components/deprecated-select/select.js.map +1 -1
- package/lib/components/key-capturer/key-capturer.d.ts +5 -5
- package/lib/components/key-capturer/key-capturer.js +1 -1
- package/lib/components/key-capturer/key-capturer.js.map +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.d.ts +3 -3
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/lib/components/progress-bar/progress-bar.d.ts +1 -1
- package/lib/components/progress-bar/progress-bar.js +1 -1
- package/lib/components/progress-bar/progress-bar.js.map +1 -1
- package/lib/components/time/time-utils.d.ts +1 -1
- package/lib/components/time/time-utils.js +1 -1
- package/lib/components/time/time-utils.js.map +1 -1
- package/lib/components/time/time.d.ts +2 -2
- package/lib/components/time/time.js +1 -1
- package/lib/components/time/time.js.map +1 -1
- package/lib/divider/divider.js +1 -1
- package/lib/divider/divider.js.map +1 -1
- package/lib/heading/heading.d.ts +2 -2
- package/lib/heading/heading.js +1 -1
- package/lib/heading/heading.js.map +1 -1
- package/lib/hidden/hidden.d.ts +4 -4
- package/lib/hidden/hidden.js +1 -1
- package/lib/hidden/hidden.js.map +1 -1
- package/lib/hidden-visually/hidden-visually.d.ts +1 -1
- package/lib/hidden-visually/hidden-visually.js +1 -1
- package/lib/hidden-visually/hidden-visually.js.map +1 -1
- package/lib/icons/alert-icon.js +1 -1
- package/lib/icons/alert-icon.js.map +1 -1
- package/lib/icons/close-icon.js +1 -1
- package/lib/icons/close-icon.js.map +1 -1
- package/lib/icons/password-hidden-icon.js +1 -1
- package/lib/icons/password-hidden-icon.js.map +1 -1
- package/lib/icons/password-visible-icon.js +1 -1
- package/lib/icons/password-visible-icon.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/inline/inline.d.ts +1 -1
- package/lib/inline/inline.js +1 -1
- package/lib/inline/inline.js.map +1 -1
- package/lib/loading/loading.d.ts +3 -3
- package/lib/loading/loading.js +1 -1
- package/lib/loading/loading.js.map +1 -1
- package/lib/menu/menu.d.ts +1 -1
- package/lib/menu/menu.js +1 -1
- package/lib/menu/menu.js.map +1 -1
- package/lib/modal/modal-stories-components.d.ts +2 -2
- package/lib/modal/modal.d.ts +4 -4
- package/lib/modal/modal.js +1 -1
- package/lib/modal/modal.js.map +1 -1
- package/lib/notice/notice.d.ts +1 -1
- package/lib/notice/notice.js +1 -1
- package/lib/notice/notice.js.map +1 -1
- package/lib/password-field/password-field.js +1 -1
- package/lib/password-field/password-field.js.map +1 -1
- package/lib/prose/prose.js +1 -1
- package/lib/prose/prose.js.map +1 -1
- package/lib/select-field/select-field.js +1 -1
- package/lib/select-field/select-field.js.map +1 -1
- package/lib/spinner/spinner.js +1 -1
- package/lib/spinner/spinner.js.map +1 -1
- package/lib/stack/stack.d.ts +1 -1
- package/lib/stack/stack.js +1 -1
- package/lib/stack/stack.js.map +1 -1
- package/lib/switch-field/switch-field.js +1 -1
- package/lib/switch-field/switch-field.js.map +1 -1
- package/lib/tabs/tabs.d.ts +5 -6
- package/lib/tabs/tabs.js +1 -1
- package/lib/tabs/tabs.js.map +1 -1
- package/lib/text/text.d.ts +1 -1
- package/lib/text/text.js +1 -1
- package/lib/text/text.js.map +1 -1
- package/lib/text-area/text-area.js +1 -1
- package/lib/text-area/text-area.js.map +1 -1
- package/lib/text-field/text-field.d.ts +1 -1
- package/lib/text-field/text-field.js +1 -1
- package/lib/text-field/text-field.js.map +1 -1
- package/lib/text-link/text-link.d.ts +1 -1
- package/lib/text-link/text-link.js +1 -1
- package/lib/text-link/text-link.js.map +1 -1
- package/lib/toast/static-toast.d.ts +2 -2
- package/lib/toast/static-toast.js +1 -1
- package/lib/toast/static-toast.js.map +1 -1
- package/lib/toast/toast-animation.d.ts +1 -1
- package/lib/toast/toast-animation.js.map +1 -1
- package/lib/toast/use-toasts.d.ts +3 -3
- package/lib/toast/use-toasts.js +1 -1
- package/lib/toast/use-toasts.js.map +1 -1
- package/lib/tooltip/tooltip.js +1 -1
- package/lib/tooltip/tooltip.js.map +1 -1
- package/lib/utils/common-helpers.js +1 -1
- package/lib/utils/common-helpers.js.map +1 -1
- package/lib/utils/common-types.d.ts +8 -8
- package/lib/utils/polymorphism.d.ts +9 -9
- package/lib/utils/polymorphism.js +1 -1
- package/lib/utils/polymorphism.js.map +1 -1
- package/lib/utils/responsive-props.d.ts +3 -3
- package/lib/utils/responsive-props.js.map +1 -1
- package/lib/utils/test-helpers.d.ts +1 -1
- package/package.json +13 -7
- package/lib/alert/alert.test.d.ts +0 -1
- package/lib/avatar/avatar.test.d.ts +0 -1
- package/lib/avatar/utils.test.d.ts +0 -1
- package/lib/badge/badge.test.d.ts +0 -1
- package/lib/banner/banner.test.d.ts +0 -1
- package/lib/box/box.test.d.ts +0 -1
- package/lib/button/button.test.d.ts +0 -1
- package/lib/checkbox-field/checkbox-field.test.d.ts +0 -1
- package/lib/columns/columns.test.d.ts +0 -1
- package/lib/components/color-picker/color-picker.test.d.ts +0 -1
- package/lib/components/deprecated-button/deprecated-button.test.d.ts +0 -1
- package/lib/components/deprecated-dropdown/dropdown.test.d.ts +0 -1
- package/lib/components/deprecated-input/input.test.d.ts +0 -1
- package/lib/components/deprecated-select/select.test.d.ts +0 -1
- package/lib/components/key-capturer/key-capturer.test.d.ts +0 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.test.d.ts +0 -1
- package/lib/components/progress-bar/progress-bar.test.d.ts +0 -1
- package/lib/components/time/time-utils.test.d.ts +0 -1
- package/lib/components/time/time.test.d.ts +0 -1
- package/lib/heading/heading.test.d.ts +0 -1
- package/lib/hidden/hidden.test.d.ts +0 -1
- package/lib/hidden-visually/hidden-visually.test.d.ts +0 -1
- package/lib/inline/inline.test.d.ts +0 -1
- package/lib/loading/loading.test.d.ts +0 -1
- package/lib/menu/menu.test.d.ts +0 -1
- package/lib/modal/modal.test.d.ts +0 -1
- package/lib/notice/notice.test.d.ts +0 -1
- package/lib/password-field/password-field.test.d.ts +0 -1
- package/lib/prose/prose.test.d.ts +0 -1
- package/lib/select-field/select-field.test.d.ts +0 -1
- package/lib/stack/stack.test.d.ts +0 -1
- package/lib/switch-field/switch-field.test.d.ts +0 -1
- package/lib/tabs/tabs.test.d.ts +0 -1
- package/lib/text/text.test.d.ts +0 -1
- package/lib/text-area/text-area.test.d.ts +0 -1
- package/lib/text-field/text-field.test.d.ts +0 -1
- package/lib/toast/toast.test.d.ts +0 -1
- package/lib/tooltip/tooltip.test.d.ts +0 -1
- package/styles/color-picker.css +0 -9
- package/styles/deprecated-button.css +0 -7
- package/styles/dropdown.css +0 -8
- package/styles/progress-bar.css +0 -7
- package/styles/select.css +0 -1
- package/styles/time.css +0 -7
- /package/styles/{input.css → index.css} +0 -0
- /package/styles/{spinner.module.css.css → spinner.css} +0 -0
package/es/modal/modal.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import
|
|
4
|
+
import FocusLock from 'react-focus-lock';
|
|
5
|
+
import { hideOthers } from 'aria-hidden';
|
|
6
|
+
import { useDialogStore, Portal, Dialog } from '@ariakit/react';
|
|
7
|
+
import { CloseIcon } from '../icons/close-icon.js';
|
|
5
8
|
import { Columns, Column } from '../columns/columns.js';
|
|
6
|
-
import { Divider } from '../divider/divider.js';
|
|
7
9
|
import { Inline } from '../inline/inline.js';
|
|
8
|
-
import {
|
|
10
|
+
import { Divider } from '../divider/divider.js';
|
|
11
|
+
import { Box } from '../box/box.js';
|
|
9
12
|
import { IconButton } from '../button/button.js';
|
|
10
|
-
import
|
|
11
|
-
import FocusLock from 'react-focus-lock';
|
|
12
|
-
import { hideOthers } from 'aria-hidden';
|
|
13
|
-
import styles from './modal.module.css.js';
|
|
13
|
+
import modules_8f59d13b from './modal.module.css.js';
|
|
14
14
|
|
|
15
15
|
const _excluded = ["isOpen", "onDismiss", "height", "width", "exceptionallySetClassName", "exceptionallySetOverlayClassName", "autoFocus", "hideOnEscape", "hideOnInteractOutside", "children", "portalElement", "onKeyDown", "className"],
|
|
16
16
|
_excluded2 = ["children", "button", "withDivider", "exceptionallySetClassName"],
|
|
17
17
|
_excluded3 = ["exceptionallySetClassName", "children"],
|
|
18
18
|
_excluded4 = ["exceptionallySetClassName", "withDivider"],
|
|
19
19
|
_excluded5 = ["children"];
|
|
20
|
-
const ModalContext = /*#__PURE__*/createContext({
|
|
20
|
+
const ModalContext = /*#__PURE__*/React.createContext({
|
|
21
21
|
onDismiss: undefined,
|
|
22
22
|
height: 'fitContent'
|
|
23
23
|
});
|
|
@@ -55,7 +55,7 @@ function Modal(_ref) {
|
|
|
55
55
|
} = _ref,
|
|
56
56
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
57
57
|
|
|
58
|
-
const setOpen = useCallback(visible => {
|
|
58
|
+
const setOpen = React.useCallback(visible => {
|
|
59
59
|
if (!visible) {
|
|
60
60
|
onDismiss == null ? void 0 : onDismiss();
|
|
61
61
|
}
|
|
@@ -64,14 +64,14 @@ function Modal(_ref) {
|
|
|
64
64
|
open: isOpen,
|
|
65
65
|
setOpen
|
|
66
66
|
});
|
|
67
|
-
const contextValue = useMemo(() => ({
|
|
67
|
+
const contextValue = React.useMemo(() => ({
|
|
68
68
|
onDismiss,
|
|
69
69
|
height
|
|
70
70
|
}), [onDismiss, height]);
|
|
71
|
-
const portalRef = useRef(null);
|
|
72
|
-
const dialogRef = useRef(null);
|
|
73
|
-
const backdropRef = useRef(null);
|
|
74
|
-
const handleBackdropClick = useCallback(event => {
|
|
71
|
+
const portalRef = React.useRef(null);
|
|
72
|
+
const dialogRef = React.useRef(null);
|
|
73
|
+
const backdropRef = React.useRef(null);
|
|
74
|
+
const handleBackdropClick = React.useCallback(event => {
|
|
75
75
|
var _dialogRef$current, _backdropRef$current;
|
|
76
76
|
|
|
77
77
|
if ( // The focus lock element takes up the same space as the backdrop and is where the event bubbles up from,
|
|
@@ -82,14 +82,14 @@ function Modal(_ref) {
|
|
|
82
82
|
onDismiss == null ? void 0 : onDismiss();
|
|
83
83
|
}
|
|
84
84
|
}, [onDismiss]);
|
|
85
|
-
useLayoutEffect(function disableAccessibilityTreeOutside() {
|
|
85
|
+
React.useLayoutEffect(function disableAccessibilityTreeOutside() {
|
|
86
86
|
if (!isOpen || !portalRef.current) {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
return hideOthers(portalRef.current);
|
|
91
91
|
}, [isOpen]);
|
|
92
|
-
const handleKeyDown = useCallback(function handleKeyDown(event) {
|
|
92
|
+
const handleKeyDown = React.useCallback(function handleKeyDown(event) {
|
|
93
93
|
if (hideOnEscape && onDismiss != null && event.key === 'Escape' && !event.defaultPrevented) {
|
|
94
94
|
event.stopPropagation();
|
|
95
95
|
onDismiss();
|
|
@@ -102,13 +102,13 @@ function Modal(_ref) {
|
|
|
102
102
|
return null;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
return /*#__PURE__*/createElement(Portal, {
|
|
105
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
|
106
106
|
portalRef: portalRef,
|
|
107
107
|
portalElement: portalElement
|
|
108
|
-
}, /*#__PURE__*/createElement(Box, {
|
|
108
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
109
109
|
"data-testid": "modal-overlay",
|
|
110
110
|
"data-overlay": true,
|
|
111
|
-
className: classNames(
|
|
111
|
+
className: classNames(modules_8f59d13b.overlay, modules_8f59d13b[height], modules_8f59d13b[width], exceptionallySetOverlayClassName),
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* We're using `onPointerDown` instead of `onClick` to prevent the modal from
|
|
@@ -116,13 +116,13 @@ function Modal(_ref) {
|
|
|
116
116
|
*/
|
|
117
117
|
onPointerDown: hideOnInteractOutside ? handleBackdropClick : undefined,
|
|
118
118
|
ref: backdropRef
|
|
119
|
-
}, /*#__PURE__*/createElement(FocusLock, {
|
|
119
|
+
}, /*#__PURE__*/React.createElement(FocusLock, {
|
|
120
120
|
autoFocus: autoFocus,
|
|
121
121
|
whiteList: isNotInternalFrame,
|
|
122
122
|
returnFocus: true
|
|
123
|
-
}, /*#__PURE__*/createElement(Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
123
|
+
}, /*#__PURE__*/React.createElement(Dialog, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
124
124
|
ref: dialogRef,
|
|
125
|
-
render: /*#__PURE__*/createElement(Box, {
|
|
125
|
+
render: /*#__PURE__*/React.createElement(Box, {
|
|
126
126
|
borderRadius: "full",
|
|
127
127
|
background: "default",
|
|
128
128
|
display: "flex",
|
|
@@ -131,7 +131,7 @@ function Modal(_ref) {
|
|
|
131
131
|
height: height === 'expand' ? 'full' : undefined,
|
|
132
132
|
flexGrow: height === 'expand' ? 1 : 0
|
|
133
133
|
}),
|
|
134
|
-
className: classNames(exceptionallySetClassName,
|
|
134
|
+
className: classNames(exceptionallySetClassName, modules_8f59d13b.container),
|
|
135
135
|
store: store,
|
|
136
136
|
preventBodyScroll: true,
|
|
137
137
|
// Disable focus lock as we set up our own using ReactFocusLock
|
|
@@ -145,7 +145,7 @@ function Modal(_ref) {
|
|
|
145
145
|
hideOnInteractOutside: false,
|
|
146
146
|
hideOnEscape: false,
|
|
147
147
|
onKeyDown: handleKeyDown
|
|
148
|
-
}), /*#__PURE__*/createElement(ModalContext.Provider, {
|
|
148
|
+
}), /*#__PURE__*/React.createElement(ModalContext.Provider, {
|
|
149
149
|
value: contextValue
|
|
150
150
|
}, children)))));
|
|
151
151
|
}
|
|
@@ -159,20 +159,20 @@ function Modal(_ref) {
|
|
|
159
159
|
function ModalCloseButton(props) {
|
|
160
160
|
const {
|
|
161
161
|
onDismiss
|
|
162
|
-
} = useContext(ModalContext);
|
|
163
|
-
const [includeInTabOrder, setIncludeInTabOrder] = useState(false);
|
|
164
|
-
const [isMounted, setIsMounted] = useState(false);
|
|
165
|
-
useEffect(function skipAutoFocus() {
|
|
162
|
+
} = React.useContext(ModalContext);
|
|
163
|
+
const [includeInTabOrder, setIncludeInTabOrder] = React.useState(false);
|
|
164
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
165
|
+
React.useEffect(function skipAutoFocus() {
|
|
166
166
|
if (isMounted) {
|
|
167
167
|
setIncludeInTabOrder(true);
|
|
168
168
|
} else {
|
|
169
169
|
setIsMounted(true);
|
|
170
170
|
}
|
|
171
171
|
}, [isMounted]);
|
|
172
|
-
return /*#__PURE__*/createElement(IconButton, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
172
|
+
return /*#__PURE__*/React.createElement(IconButton, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
173
173
|
variant: "quaternary",
|
|
174
174
|
onClick: onDismiss,
|
|
175
|
-
icon: /*#__PURE__*/createElement(CloseIcon, null),
|
|
175
|
+
icon: /*#__PURE__*/React.createElement(CloseIcon, null),
|
|
176
176
|
tabIndex: includeInTabOrder ? 0 : -1
|
|
177
177
|
}));
|
|
178
178
|
}
|
|
@@ -193,27 +193,27 @@ function ModalHeader(_ref2) {
|
|
|
193
193
|
} = _ref2,
|
|
194
194
|
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
195
195
|
|
|
196
|
-
return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
196
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
197
197
|
as: "header",
|
|
198
198
|
paddingLeft: "large",
|
|
199
199
|
paddingRight: button === false || button === null ? 'large' : 'small',
|
|
200
200
|
paddingY: "small",
|
|
201
201
|
className: exceptionallySetClassName
|
|
202
|
-
}), /*#__PURE__*/createElement(Columns, {
|
|
202
|
+
}), /*#__PURE__*/React.createElement(Columns, {
|
|
203
203
|
space: "large",
|
|
204
204
|
alignY: "center"
|
|
205
|
-
}, /*#__PURE__*/createElement(Column, {
|
|
205
|
+
}, /*#__PURE__*/React.createElement(Column, {
|
|
206
206
|
width: "auto"
|
|
207
|
-
}, children), button === false || button === null ? /*#__PURE__*/createElement("div", {
|
|
208
|
-
className:
|
|
209
|
-
}) : /*#__PURE__*/createElement(Column, {
|
|
207
|
+
}, children), button === false || button === null ? /*#__PURE__*/React.createElement("div", {
|
|
208
|
+
className: modules_8f59d13b.headerContent
|
|
209
|
+
}) : /*#__PURE__*/React.createElement(Column, {
|
|
210
210
|
width: "content",
|
|
211
|
-
exceptionallySetClassName:
|
|
211
|
+
exceptionallySetClassName: modules_8f59d13b.buttonContainer,
|
|
212
212
|
"data-testid": "button-container"
|
|
213
|
-
}, typeof button === 'boolean' ? /*#__PURE__*/createElement(ModalCloseButton, {
|
|
213
|
+
}, typeof button === 'boolean' ? /*#__PURE__*/React.createElement(ModalCloseButton, {
|
|
214
214
|
"aria-label": "Close modal",
|
|
215
215
|
autoFocus: false
|
|
216
|
-
}) : button))), withDivider ? /*#__PURE__*/createElement(Divider, null) : null);
|
|
216
|
+
}) : button))), withDivider ? /*#__PURE__*/React.createElement(Divider, null) : null);
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
219
|
* Renders the body of a modal.
|
|
@@ -237,13 +237,13 @@ function ModalBody(_ref3) {
|
|
|
237
237
|
|
|
238
238
|
const {
|
|
239
239
|
height
|
|
240
|
-
} = useContext(ModalContext);
|
|
241
|
-
return /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
240
|
+
} = React.useContext(ModalContext);
|
|
241
|
+
return /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
242
242
|
className: exceptionallySetClassName,
|
|
243
243
|
flexGrow: height === 'expand' ? 1 : 0,
|
|
244
244
|
height: height === 'expand' ? 'full' : undefined,
|
|
245
245
|
overflow: "auto"
|
|
246
|
-
}), /*#__PURE__*/createElement(Box, {
|
|
246
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
247
247
|
padding: "large",
|
|
248
248
|
paddingBottom: "xxlarge"
|
|
249
249
|
}, children));
|
|
@@ -263,7 +263,7 @@ function ModalFooter(_ref4) {
|
|
|
263
263
|
} = _ref4,
|
|
264
264
|
props = _objectWithoutProperties(_ref4, _excluded4);
|
|
265
265
|
|
|
266
|
-
return /*#__PURE__*/createElement(Fragment, null, withDivider ? /*#__PURE__*/createElement(Divider, null) : null, /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({
|
|
266
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, withDivider ? /*#__PURE__*/React.createElement(Divider, null) : null, /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({
|
|
267
267
|
as: "footer"
|
|
268
268
|
}, props), {}, {
|
|
269
269
|
className: exceptionallySetClassName,
|
|
@@ -281,7 +281,7 @@ function ModalActions(_ref5) {
|
|
|
281
281
|
} = _ref5,
|
|
282
282
|
props = _objectWithoutProperties(_ref5, _excluded5);
|
|
283
283
|
|
|
284
|
-
return /*#__PURE__*/createElement(ModalFooter, _objectSpread2({}, props), /*#__PURE__*/createElement(Inline, {
|
|
284
|
+
return /*#__PURE__*/React.createElement(ModalFooter, _objectSpread2({}, props), /*#__PURE__*/React.createElement(Inline, {
|
|
285
285
|
align: "right",
|
|
286
286
|
space: "large"
|
|
287
287
|
}, children));
|
package/es/modal/modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../src/modal/modal.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport FocusLock from 'react-focus-lock'\nimport { hideOthers } from 'aria-hidden'\n\nimport { Dialog, DialogOptions, useDialogStore, Portal, PortalOptions } from '@ariakit/react'\n\nimport { CloseIcon } from '../icons/close-icon'\nimport { Column, Columns } from '../columns'\nimport { Inline } from '../inline'\nimport { Divider } from '../divider'\nimport { Box } from '../box'\nimport { IconButtonProps, IconButton } from '../button'\n\nimport styles from './modal.module.css'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ntype ModalWidth = 'small' | 'medium' | 'large' | 'xlarge' | 'full'\ntype ModalHeightMode = 'expand' | 'fitContent'\n\n//\n// ModalContext\n//\n\ntype ModalContextValue = {\n onDismiss?(this: void): void\n height: ModalHeightMode\n}\n\nconst ModalContext = React.createContext<ModalContextValue>({\n onDismiss: undefined,\n height: 'fitContent',\n})\n\n//\n// Modal container\n//\n\ntype DivProps = Omit<\n React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLDivElement>, HTMLDivElement>,\n 'className' | 'children' | `aria-label` | `aria-labelledby`\n>\n\nexport interface ModalProps extends DivProps, ObfuscatedClassName {\n /**\n * The content of the modal.\n */\n children: React.ReactNode\n\n /**\n * Whether the modal is open and visible or not.\n */\n isOpen: boolean\n\n /**\n * Called when the user triggers closing the modal.\n */\n onDismiss?(): void\n\n /**\n * A descriptive setting for how wide the modal should aim to be, depending on how much space\n * it has on screen.\n * @default 'medium'\n */\n width?: ModalWidth\n\n /**\n * A descriptive setting for how tall the modal should aim to be.\n *\n * - 'expand': the modal aims to fill most of the available screen height, leaving only a small\n * padding above and below.\n * - 'fitContent': the modal shrinks to the smallest size that allow it to fit its content.\n *\n * In either case, if content does not fit, the content of the main body is set to scroll\n * (provided you use `ModalBody`) so that the modal never has to strech vertically beyond the\n * viewport boundaries.\n *\n * If you do not use `ModalBody`, the modal still prevents overflow, and you are in charge of\n * the inner layout to ensure scroll, or whatever other strategy you may want.\n */\n height?: ModalHeightMode\n\n /**\n * Whether to set or not the focus initially to the first focusable element inside the modal.\n */\n autoFocus?: boolean\n\n /**\n * Controls if the modal is dismissed when pressing \"Escape\".\n */\n hideOnEscape?: DialogOptions['hideOnEscape']\n\n /**\n * Controls if the modal is dismissed when clicking outside the modal body, on the overlay.\n */\n hideOnInteractOutside?: DialogOptions['hideOnInteractOutside']\n\n /**\n * An escape hatch in case you need to provide a custom class name to the overlay element.\n */\n exceptionallySetOverlayClassName?: string\n\n /**\n * Defines a string value that labels the current modal for assistive technologies.\n */\n 'aria-label'?: string\n\n /**\n * Identifies the element (or elements) that labels the current modal for assistive technologies.\n */\n 'aria-labelledby'?: string\n\n /**\n * An HTML element or a memoized callback function that returns an HTML element to be used as\n * the portal element. By default, the portal element will be a `div` element appended to the\n * `document.body`.\n *\n * @default HTMLDivElement\n *\n * @example\n * const [portal, setPortal] = useState(null);\n * <Portal portalElement={portal} />;\n * <div ref={setPortal} />;\n *\n * @example\n * const getPortalElement = useCallback(() => {\n * const div = document.createElement(\"div\");\n * const portalRoot = document.getElementById(\"portal-root\");\n * portalRoot.appendChild(div);\n * return div;\n * }, []);\n * <Portal portalElement={getPortalElement} />;\n */\n portalElement?: PortalOptions['portalElement']\n}\n\nfunction isNotInternalFrame(element: HTMLElement) {\n return !(element.ownerDocument === document && element.tagName.toLowerCase() === 'iframe')\n}\n\n/**\n * Renders a modal that sits on top of the rest of the content in the entire page.\n *\n * Follows the WAI-ARIA Dialog (Modal) Pattern.\n *\n * @see ModalHeader\n * @see ModalFooter\n * @see ModalBody\n */\nexport function Modal({\n isOpen,\n onDismiss,\n height = 'fitContent',\n width = 'medium',\n exceptionallySetClassName,\n exceptionallySetOverlayClassName,\n autoFocus = true,\n hideOnEscape = true,\n hideOnInteractOutside = true,\n children,\n portalElement,\n onKeyDown,\n // @ts-expect-error we want to make sure to not pass it to the Dialog component\n className,\n ...props\n}: ModalProps) {\n const setOpen = React.useCallback(\n (visible: boolean) => {\n if (!visible) {\n onDismiss?.()\n }\n },\n [onDismiss],\n )\n const store = useDialogStore({ open: isOpen, setOpen })\n\n const contextValue: ModalContextValue = React.useMemo(() => ({ onDismiss, height }), [\n onDismiss,\n height,\n ])\n\n const portalRef = React.useRef<HTMLElement | null>(null)\n const dialogRef = React.useRef<HTMLDivElement | null>(null)\n const backdropRef = React.useRef<HTMLDivElement | null>(null)\n const handleBackdropClick = React.useCallback(\n (event: React.MouseEvent) => {\n if (\n // The focus lock element takes up the same space as the backdrop and is where the event bubbles up from,\n // so instead of checking the backdrop as the event target, we need to make sure it's just above the dialog\n !dialogRef.current?.contains(event.target as Node) &&\n // Events fired from other portals will bubble up to the backdrop, even if it isn't a child in the DOM\n backdropRef.current?.contains(event.target as Node)\n ) {\n event.stopPropagation()\n onDismiss?.()\n }\n },\n [onDismiss],\n )\n\n React.useLayoutEffect(\n function disableAccessibilityTreeOutside() {\n if (!isOpen || !portalRef.current) {\n return\n }\n\n return hideOthers(portalRef.current)\n },\n [isOpen],\n )\n\n const handleKeyDown = React.useCallback(\n function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n if (\n hideOnEscape &&\n onDismiss != null &&\n event.key === 'Escape' &&\n !event.defaultPrevented\n ) {\n event.stopPropagation()\n onDismiss()\n }\n onKeyDown?.(event)\n },\n [onDismiss, hideOnEscape, onKeyDown],\n )\n\n if (!isOpen) {\n return null\n }\n\n return (\n <Portal portalRef={portalRef} portalElement={portalElement}>\n <Box\n data-testid=\"modal-overlay\"\n data-overlay\n className={classNames(\n styles.overlay,\n styles[height],\n styles[width],\n exceptionallySetOverlayClassName,\n )}\n /**\n * We're using `onPointerDown` instead of `onClick` to prevent the modal from\n * closing when the click starts inside the modal and ends on the backdrop.\n */\n onPointerDown={hideOnInteractOutside ? handleBackdropClick : undefined}\n ref={backdropRef}\n >\n <FocusLock autoFocus={autoFocus} whiteList={isNotInternalFrame} returnFocus={true}>\n <Dialog\n {...props}\n ref={dialogRef}\n render={\n <Box\n borderRadius=\"full\"\n background=\"default\"\n display=\"flex\"\n flexDirection=\"column\"\n overflow=\"hidden\"\n height={height === 'expand' ? 'full' : undefined}\n flexGrow={height === 'expand' ? 1 : 0}\n />\n }\n className={classNames(exceptionallySetClassName, styles.container)}\n store={store}\n preventBodyScroll\n // Disable focus lock as we set up our own using ReactFocusLock\n modal={false}\n autoFocus={false}\n autoFocusOnShow={false}\n autoFocusOnHide={false}\n // Disable portal and backdrop as we control their markup\n portal={false}\n backdrop={false}\n hideOnInteractOutside={false}\n hideOnEscape={false}\n onKeyDown={handleKeyDown}\n >\n <ModalContext.Provider value={contextValue}>\n {children}\n </ModalContext.Provider>\n </Dialog>\n </FocusLock>\n </Box>\n </Portal>\n )\n}\n\n//\n// ModalCloseButton\n//\n\nexport interface ModalCloseButtonProps\n extends Omit<\n IconButtonProps,\n 'type' | 'variant' | 'icon' | 'disabled' | 'loading' | 'tabIndex' | 'ref'\n > {\n /**\n * The descriptive label of the button.\n */\n 'aria-label': string\n}\n\n/**\n * The close button rendered by ModalHeader. Provided independently so that consumers can customize\n * the button's label.\n *\n * @see ModalHeader\n */\nexport function ModalCloseButton(props: ModalCloseButtonProps) {\n const { onDismiss } = React.useContext(ModalContext)\n const [includeInTabOrder, setIncludeInTabOrder] = React.useState(false)\n const [isMounted, setIsMounted] = React.useState(false)\n\n React.useEffect(\n function skipAutoFocus() {\n if (isMounted) {\n setIncludeInTabOrder(true)\n } else {\n setIsMounted(true)\n }\n },\n [isMounted],\n )\n\n return (\n <IconButton\n {...props}\n variant=\"quaternary\"\n onClick={onDismiss}\n icon={<CloseIcon />}\n tabIndex={includeInTabOrder ? 0 : -1}\n />\n )\n}\n\n//\n// ModalHeader\n//\n\nexport interface ModalHeaderProps extends DivProps, ObfuscatedClassName {\n /**\n * The content of the header.\n */\n children: React.ReactNode\n\n /**\n * Allows to provide a custom button element, or to omit the close button if set to false.\n * @see ModalCloseButton\n */\n button?: React.ReactNode | boolean\n\n /**\n * Whether to render a divider line below the header.\n * @default false\n */\n withDivider?: boolean\n}\n\n/**\n * Renders a standard modal header area with an optional close button.\n *\n * @see Modal\n * @see ModalFooter\n * @see ModalBody\n */\nexport function ModalHeader({\n children,\n button = true,\n withDivider = false,\n exceptionallySetClassName,\n ...props\n}: ModalHeaderProps) {\n return (\n <>\n <Box\n {...props}\n as=\"header\"\n paddingLeft=\"large\"\n paddingRight={button === false || button === null ? 'large' : 'small'}\n paddingY=\"small\"\n className={exceptionallySetClassName}\n >\n <Columns space=\"large\" alignY=\"center\">\n <Column width=\"auto\">{children}</Column>\n {button === false || button === null ? (\n <div className={styles.headerContent} />\n ) : (\n <Column\n width=\"content\"\n exceptionallySetClassName={styles.buttonContainer}\n data-testid=\"button-container\"\n >\n {typeof button === 'boolean' ? (\n <ModalCloseButton aria-label=\"Close modal\" autoFocus={false} />\n ) : (\n button\n )}\n </Column>\n )}\n </Columns>\n </Box>\n {withDivider ? <Divider /> : null}\n </>\n )\n}\n\n//\n// ModalBody\n//\n\nexport interface ModalBodyProps extends DivProps, ObfuscatedClassName {\n /**\n * The content of the modal body.\n */\n children: React.ReactNode\n}\n\n/**\n * Renders the body of a modal.\n *\n * Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other\n * things, that the contet of the modal body expands or contracts depending on the modal height\n * setting or the size of the content. The body content also automatically scrolls when it's too\n * large to fit the available space.\n *\n * @see Modal\n * @see ModalHeader\n * @see ModalFooter\n */\nexport function ModalBody({ exceptionallySetClassName, children, ...props }: ModalBodyProps) {\n const { height } = React.useContext(ModalContext)\n return (\n <Box\n {...props}\n className={exceptionallySetClassName}\n flexGrow={height === 'expand' ? 1 : 0}\n height={height === 'expand' ? 'full' : undefined}\n overflow=\"auto\"\n >\n <Box padding=\"large\" paddingBottom=\"xxlarge\">\n {children}\n </Box>\n </Box>\n )\n}\n\n//\n// ModalFooter\n//\n\nexport interface ModalFooterProps extends DivProps, ObfuscatedClassName {\n /**\n * The contant of the modal footer.\n */\n children: React.ReactNode\n /**\n * Whether to render a divider line below the footer.\n * @default false\n */\n withDivider?: boolean\n}\n\n/**\n * Renders a standard modal footer area.\n *\n * @see Modal\n * @see ModalHeader\n * @see ModalBody\n */\nexport function ModalFooter({\n exceptionallySetClassName,\n withDivider = false,\n ...props\n}: ModalFooterProps) {\n return (\n <>\n {withDivider ? <Divider /> : null}\n <Box as=\"footer\" {...props} className={exceptionallySetClassName} padding=\"large\" />\n </>\n )\n}\n\n//\n// ModalActions\n//\n\nexport type ModalActionsProps = ModalFooterProps\n\n/**\n * A specific version of the ModalFooter, tailored to showing an inline list of actions (buttons).\n * @see ModalFooter\n */\nexport function ModalActions({ children, ...props }: ModalActionsProps) {\n return (\n <ModalFooter {...props}>\n <Inline align=\"right\" space=\"large\">\n {children}\n </Inline>\n </ModalFooter>\n )\n}\n"],"names":["ModalContext","React","onDismiss","undefined","height","isNotInternalFrame","element","ownerDocument","document","tagName","toLowerCase","Modal","isOpen","width","exceptionallySetClassName","exceptionallySetOverlayClassName","autoFocus","hideOnEscape","hideOnInteractOutside","children","portalElement","onKeyDown","className","props","setOpen","visible","store","useDialogStore","open","contextValue","portalRef","dialogRef","backdropRef","handleBackdropClick","event","current","contains","target","stopPropagation","disableAccessibilityTreeOutside","hideOthers","handleKeyDown","key","defaultPrevented","Portal","Box","classNames","styles","overlay","onPointerDown","ref","FocusLock","whiteList","returnFocus","Dialog","render","borderRadius","background","display","flexDirection","overflow","flexGrow","container","preventBodyScroll","modal","autoFocusOnShow","autoFocusOnHide","portal","backdrop","Provider","value","ModalCloseButton","includeInTabOrder","setIncludeInTabOrder","isMounted","setIsMounted","skipAutoFocus","IconButton","variant","onClick","icon","CloseIcon","tabIndex","ModalHeader","button","withDivider","as","paddingLeft","paddingRight","paddingY","Columns","space","alignY","Column","headerContent","buttonContainer","Divider","ModalBody","padding","paddingBottom","ModalFooter","ModalActions","Inline","align"],"mappings":";;;;;;;;;;;;;;;;;;;AA6BA,MAAMA,YAAY,gBAAGC,aAAA,CAAuC;EACxDC,SAAS,EAAEC,SAD6C;EAExDC,MAAM,EAAE;AAFgD,CAAvC,CAArB;;AA2GA,SAASC,kBAAT,CAA4BC,OAA5B;EACI,OAAO,EAAEA,OAAO,CAACC,aAAR,KAA0BC,QAA1B,IAAsCF,OAAO,CAACG,OAAR,CAAgBC,WAAhB,OAAkC,QAA1E,CAAP;AACH;AAED;;;;;;;;;;;SASgBC;MAAM;IAClBC,MADkB;IAElBV,SAFkB;IAGlBE,MAAM,GAAG,YAHS;IAIlBS,KAAK,GAAG,QAJU;IAKlBC,yBALkB;IAMlBC,gCANkB;IAOlBC,SAAS,GAAG,IAPM;IAQlBC,YAAY,GAAG,IARG;IASlBC,qBAAqB,GAAG,IATN;IAUlBC,QAVkB;IAWlBC,aAXkB;IAYlBC,SAZkB;;IAclBC;;MACGC;;EAEH,MAAMC,OAAO,GAAGvB,WAAA,CACXwB,OAAD;IACI,IAAI,CAACA,OAAL,EAAc;MACVvB,SAAS,QAAT,YAAAA,SAAS;;GAHL,EAMZ,CAACA,SAAD,CANY,CAAhB;EAQA,MAAMwB,KAAK,GAAGC,cAAc,CAAC;IAAEC,IAAI,EAAEhB,MAAR;IAAgBY;GAAjB,CAA5B;EAEA,MAAMK,YAAY,GAAsB5B,OAAA,CAAc,OAAO;IAAEC,SAAF;IAAaE;GAApB,CAAd,EAA6C,CACjFF,SADiF,EAEjFE,MAFiF,CA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KAAK,EAAC;GAA5B,EACKxE,QADL,CADJ,CADJ;AAOH;;;;"}
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../src/modal/modal.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport FocusLock from 'react-focus-lock'\nimport { hideOthers } from 'aria-hidden'\n\nimport { Dialog, DialogOptions, useDialogStore, Portal, PortalOptions } from '@ariakit/react'\n\nimport { CloseIcon } from '../icons/close-icon'\nimport { Column, Columns } from '../columns'\nimport { Inline } from '../inline'\nimport { Divider } from '../divider'\nimport { Box } from '../box'\nimport { IconButtonProps, IconButton } from '../button'\n\nimport styles from './modal.module.css'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ntype ModalWidth = 'small' | 'medium' | 'large' | 'xlarge' | 'full'\ntype ModalHeightMode = 'expand' | 'fitContent'\n\n//\n// ModalContext\n//\n\ntype ModalContextValue = {\n onDismiss?(this: void): void\n height: ModalHeightMode\n}\n\nconst ModalContext = React.createContext<ModalContextValue>({\n onDismiss: undefined,\n height: 'fitContent',\n})\n\n//\n// Modal container\n//\n\ntype DivProps = Omit<\n React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLDivElement>, HTMLDivElement>,\n 'className' | 'children' | `aria-label` | `aria-labelledby`\n>\n\nexport interface ModalProps extends DivProps, ObfuscatedClassName {\n /**\n * The content of the modal.\n */\n children: React.ReactNode\n\n /**\n * Whether the modal is open and visible or not.\n */\n isOpen: boolean\n\n /**\n * Called when the user triggers closing the modal.\n */\n onDismiss?(): void\n\n /**\n * A descriptive setting for how wide the modal should aim to be, depending on how much space\n * it has on screen.\n * @default 'medium'\n */\n width?: ModalWidth\n\n /**\n * A descriptive setting for how tall the modal should aim to be.\n *\n * - 'expand': the modal aims to fill most of the available screen height, leaving only a small\n * padding above and below.\n * - 'fitContent': the modal shrinks to the smallest size that allow it to fit its content.\n *\n * In either case, if content does not fit, the content of the main body is set to scroll\n * (provided you use `ModalBody`) so that the modal never has to strech vertically beyond the\n * viewport boundaries.\n *\n * If you do not use `ModalBody`, the modal still prevents overflow, and you are in charge of\n * the inner layout to ensure scroll, or whatever other strategy you may want.\n */\n height?: ModalHeightMode\n\n /**\n * Whether to set or not the focus initially to the first focusable element inside the modal.\n */\n autoFocus?: boolean\n\n /**\n * Controls if the modal is dismissed when pressing \"Escape\".\n */\n hideOnEscape?: DialogOptions['hideOnEscape']\n\n /**\n * Controls if the modal is dismissed when clicking outside the modal body, on the overlay.\n */\n hideOnInteractOutside?: DialogOptions['hideOnInteractOutside']\n\n /**\n * An escape hatch in case you need to provide a custom class name to the overlay element.\n */\n exceptionallySetOverlayClassName?: string\n\n /**\n * Defines a string value that labels the current modal for assistive technologies.\n */\n 'aria-label'?: string\n\n /**\n * Identifies the element (or elements) that labels the current modal for assistive technologies.\n */\n 'aria-labelledby'?: string\n\n /**\n * An HTML element or a memoized callback function that returns an HTML element to be used as\n * the portal element. By default, the portal element will be a `div` element appended to the\n * `document.body`.\n *\n * @default HTMLDivElement\n *\n * @example\n * const [portal, setPortal] = useState(null);\n * <Portal portalElement={portal} />;\n * <div ref={setPortal} />;\n *\n * @example\n * const getPortalElement = useCallback(() => {\n * const div = document.createElement(\"div\");\n * const portalRoot = document.getElementById(\"portal-root\");\n * portalRoot.appendChild(div);\n * return div;\n * }, []);\n * <Portal portalElement={getPortalElement} />;\n */\n portalElement?: PortalOptions['portalElement']\n}\n\nfunction isNotInternalFrame(element: HTMLElement) {\n return !(element.ownerDocument === document && element.tagName.toLowerCase() === 'iframe')\n}\n\n/**\n * Renders a modal that sits on top of the rest of the content in the entire page.\n *\n * Follows the WAI-ARIA Dialog (Modal) Pattern.\n *\n * @see ModalHeader\n * @see ModalFooter\n * @see ModalBody\n */\nexport function Modal({\n isOpen,\n onDismiss,\n height = 'fitContent',\n width = 'medium',\n exceptionallySetClassName,\n exceptionallySetOverlayClassName,\n autoFocus = true,\n hideOnEscape = true,\n hideOnInteractOutside = true,\n children,\n portalElement,\n onKeyDown,\n // @ts-expect-error we want to make sure to not pass it to the Dialog component\n className,\n ...props\n}: ModalProps) {\n const setOpen = React.useCallback(\n (visible: boolean) => {\n if (!visible) {\n onDismiss?.()\n }\n },\n [onDismiss],\n )\n const store = useDialogStore({ open: isOpen, setOpen })\n\n const contextValue: ModalContextValue = React.useMemo(() => ({ onDismiss, height }), [\n onDismiss,\n height,\n ])\n\n const portalRef = React.useRef<HTMLElement | null>(null)\n const dialogRef = React.useRef<HTMLDivElement | null>(null)\n const backdropRef = React.useRef<HTMLDivElement | null>(null)\n const handleBackdropClick = React.useCallback(\n (event: React.MouseEvent) => {\n if (\n // The focus lock element takes up the same space as the backdrop and is where the event bubbles up from,\n // so instead of checking the backdrop as the event target, we need to make sure it's just above the dialog\n !dialogRef.current?.contains(event.target as Node) &&\n // Events fired from other portals will bubble up to the backdrop, even if it isn't a child in the DOM\n backdropRef.current?.contains(event.target as Node)\n ) {\n event.stopPropagation()\n onDismiss?.()\n }\n },\n [onDismiss],\n )\n\n React.useLayoutEffect(\n function disableAccessibilityTreeOutside() {\n if (!isOpen || !portalRef.current) {\n return\n }\n\n return hideOthers(portalRef.current)\n },\n [isOpen],\n )\n\n const handleKeyDown = React.useCallback(\n function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n if (\n hideOnEscape &&\n onDismiss != null &&\n event.key === 'Escape' &&\n !event.defaultPrevented\n ) {\n event.stopPropagation()\n onDismiss()\n }\n onKeyDown?.(event)\n },\n [onDismiss, hideOnEscape, onKeyDown],\n )\n\n if (!isOpen) {\n return null\n }\n\n return (\n <Portal portalRef={portalRef} portalElement={portalElement}>\n <Box\n data-testid=\"modal-overlay\"\n data-overlay\n className={classNames(\n styles.overlay,\n styles[height],\n styles[width],\n exceptionallySetOverlayClassName,\n )}\n /**\n * We're using `onPointerDown` instead of `onClick` to prevent the modal from\n * closing when the click starts inside the modal and ends on the backdrop.\n */\n onPointerDown={hideOnInteractOutside ? handleBackdropClick : undefined}\n ref={backdropRef}\n >\n <FocusLock autoFocus={autoFocus} whiteList={isNotInternalFrame} returnFocus={true}>\n <Dialog\n {...props}\n ref={dialogRef}\n render={\n <Box\n borderRadius=\"full\"\n background=\"default\"\n display=\"flex\"\n flexDirection=\"column\"\n overflow=\"hidden\"\n height={height === 'expand' ? 'full' : undefined}\n flexGrow={height === 'expand' ? 1 : 0}\n />\n }\n className={classNames(exceptionallySetClassName, styles.container)}\n store={store}\n preventBodyScroll\n // Disable focus lock as we set up our own using ReactFocusLock\n modal={false}\n autoFocus={false}\n autoFocusOnShow={false}\n autoFocusOnHide={false}\n // Disable portal and backdrop as we control their markup\n portal={false}\n backdrop={false}\n hideOnInteractOutside={false}\n hideOnEscape={false}\n onKeyDown={handleKeyDown}\n >\n <ModalContext.Provider value={contextValue}>\n {children}\n </ModalContext.Provider>\n </Dialog>\n </FocusLock>\n </Box>\n </Portal>\n )\n}\n\n//\n// ModalCloseButton\n//\n\nexport interface ModalCloseButtonProps\n extends Omit<\n IconButtonProps,\n 'type' | 'variant' | 'icon' | 'disabled' | 'loading' | 'tabIndex' | 'ref'\n > {\n /**\n * The descriptive label of the button.\n */\n 'aria-label': string\n}\n\n/**\n * The close button rendered by ModalHeader. Provided independently so that consumers can customize\n * the button's label.\n *\n * @see ModalHeader\n */\nexport function ModalCloseButton(props: ModalCloseButtonProps) {\n const { onDismiss } = React.useContext(ModalContext)\n const [includeInTabOrder, setIncludeInTabOrder] = React.useState(false)\n const [isMounted, setIsMounted] = React.useState(false)\n\n React.useEffect(\n function skipAutoFocus() {\n if (isMounted) {\n setIncludeInTabOrder(true)\n } else {\n setIsMounted(true)\n }\n },\n [isMounted],\n )\n\n return (\n <IconButton\n {...props}\n variant=\"quaternary\"\n onClick={onDismiss}\n icon={<CloseIcon />}\n tabIndex={includeInTabOrder ? 0 : -1}\n />\n )\n}\n\n//\n// ModalHeader\n//\n\nexport interface ModalHeaderProps extends DivProps, ObfuscatedClassName {\n /**\n * The content of the header.\n */\n children: React.ReactNode\n\n /**\n * Allows to provide a custom button element, or to omit the close button if set to false.\n * @see ModalCloseButton\n */\n button?: React.ReactNode | boolean\n\n /**\n * Whether to render a divider line below the header.\n * @default false\n */\n withDivider?: boolean\n}\n\n/**\n * Renders a standard modal header area with an optional close button.\n *\n * @see Modal\n * @see ModalFooter\n * @see ModalBody\n */\nexport function ModalHeader({\n children,\n button = true,\n withDivider = false,\n exceptionallySetClassName,\n ...props\n}: ModalHeaderProps) {\n return (\n <>\n <Box\n {...props}\n as=\"header\"\n paddingLeft=\"large\"\n paddingRight={button === false || button === null ? 'large' : 'small'}\n paddingY=\"small\"\n className={exceptionallySetClassName}\n >\n <Columns space=\"large\" alignY=\"center\">\n <Column width=\"auto\">{children}</Column>\n {button === false || button === null ? (\n <div className={styles.headerContent} />\n ) : (\n <Column\n width=\"content\"\n exceptionallySetClassName={styles.buttonContainer}\n data-testid=\"button-container\"\n >\n {typeof button === 'boolean' ? (\n <ModalCloseButton aria-label=\"Close modal\" autoFocus={false} />\n ) : (\n button\n )}\n </Column>\n )}\n </Columns>\n </Box>\n {withDivider ? <Divider /> : null}\n </>\n )\n}\n\n//\n// ModalBody\n//\n\nexport interface ModalBodyProps extends DivProps, ObfuscatedClassName {\n /**\n * The content of the modal body.\n */\n children: React.ReactNode\n}\n\n/**\n * Renders the body of a modal.\n *\n * Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other\n * things, that the contet of the modal body expands or contracts depending on the modal height\n * setting or the size of the content. The body content also automatically scrolls when it's too\n * large to fit the available space.\n *\n * @see Modal\n * @see ModalHeader\n * @see ModalFooter\n */\nexport function ModalBody({ exceptionallySetClassName, children, ...props }: ModalBodyProps) {\n const { height } = React.useContext(ModalContext)\n return (\n <Box\n {...props}\n className={exceptionallySetClassName}\n flexGrow={height === 'expand' ? 1 : 0}\n height={height === 'expand' ? 'full' : undefined}\n overflow=\"auto\"\n >\n <Box padding=\"large\" paddingBottom=\"xxlarge\">\n {children}\n </Box>\n </Box>\n )\n}\n\n//\n// ModalFooter\n//\n\nexport interface ModalFooterProps extends DivProps, ObfuscatedClassName {\n /**\n * The contant of the modal footer.\n */\n children: React.ReactNode\n /**\n * Whether to render a divider line below the footer.\n * @default false\n */\n withDivider?: boolean\n}\n\n/**\n * Renders a standard modal footer area.\n *\n * @see Modal\n * @see ModalHeader\n * @see ModalBody\n */\nexport function ModalFooter({\n exceptionallySetClassName,\n withDivider = false,\n ...props\n}: ModalFooterProps) {\n return (\n <>\n {withDivider ? <Divider /> : null}\n <Box as=\"footer\" {...props} className={exceptionallySetClassName} padding=\"large\" />\n </>\n )\n}\n\n//\n// ModalActions\n//\n\nexport type ModalActionsProps = ModalFooterProps\n\n/**\n * A specific version of the ModalFooter, tailored to showing an inline list of actions (buttons).\n * @see ModalFooter\n */\nexport function ModalActions({ children, ...props }: ModalActionsProps) {\n return (\n <ModalFooter {...props}>\n <Inline align=\"right\" space=\"large\">\n {children}\n </Inline>\n </ModalFooter>\n )\n}\n"],"names":["ModalContext","React","createContext","onDismiss","undefined","height","isNotInternalFrame","element","ownerDocument","document","tagName","toLowerCase","Modal","isOpen","width","exceptionallySetClassName","exceptionallySetOverlayClassName","autoFocus","hideOnEscape","hideOnInteractOutside","children","portalElement","onKeyDown","className","props","setOpen","useCallback","visible","store","useDialogStore","open","contextValue","useMemo","portalRef","useRef","dialogRef","backdropRef","handleBackdropClick","event","current","contains","target","stopPropagation","useLayoutEffect","disableAccessibilityTreeOutside","hideOthers","handleKeyDown","key","defaultPrevented","createElement","Portal","Box","classNames","styles","overlay","onPointerDown","ref","FocusLock","whiteList","returnFocus","Dialog","render","borderRadius","background","display","flexDirection","overflow","flexGrow","container","preventBodyScroll","modal","autoFocusOnShow","autoFocusOnHide","portal","backdrop","Provider","value","ModalCloseButton","useContext","includeInTabOrder","setIncludeInTabOrder","useState","isMounted","setIsMounted","useEffect","skipAutoFocus","IconButton","variant","onClick","icon","CloseIcon","tabIndex","ModalHeader","button","withDivider","Fragment","as","paddingLeft","paddingRight","paddingY","Columns","space","alignY","Column","headerContent","buttonContainer","Divider","ModalBody","padding","paddingBottom","ModalFooter","_objectSpread","ModalActions","Inline","align"],"mappings":";;;;;;;;;;;;;;;;;;;AA6BA,MAAMA,YAAY,gBAAGC,KAAK,CAACC,aAAN,CAAuC;AACxDC,EAAAA,SAAS,EAAEC,SAD6C;AAExDC,EAAAA,MAAM,EAAE,YAAA;AAFgD,CAAvC,CAArB,CAAA;;AA2GA,SAASC,kBAAT,CAA4BC,OAA5B,EAAgD;AAC5C,EAAA,OAAO,EAAEA,OAAO,CAACC,aAAR,KAA0BC,QAA1B,IAAsCF,OAAO,CAACG,OAAR,CAAgBC,WAAhB,EAAA,KAAkC,QAA1E,CAAP,CAAA;AACH,CAAA;AAED;;;;;;;;AAQG;;;SACaC,MAgBH,IAAA,EAAA;EAAA,IAhBS;IAClBC,MADkB;IAElBV,SAFkB;AAGlBE,IAAAA,MAAM,GAAG,YAHS;AAIlBS,IAAAA,KAAK,GAAG,QAJU;IAKlBC,yBALkB;IAMlBC,gCANkB;AAOlBC,IAAAA,SAAS,GAAG,IAPM;AAQlBC,IAAAA,YAAY,GAAG,IARG;AASlBC,IAAAA,qBAAqB,GAAG,IATN;IAUlBC,QAVkB;IAWlBC,aAXkB;IAYlBC,SAZkB;AAalB;AACAC,IAAAA,SAAAA;GAES,GAAA,IAAA;AAAA,MADNC,KACM,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACT,EAAA,MAAMC,OAAO,GAAGxB,KAAK,CAACyB,WAAN,CACXC,OAAD,IAAqB;IACjB,IAAI,CAACA,OAAL,EAAc;MACVxB,SAAS,IAAA,IAAT,YAAAA,SAAS,EAAA,CAAA;AACZ,KAAA;AACJ,GALW,EAMZ,CAACA,SAAD,CANY,CAAhB,CAAA;EAQA,MAAMyB,KAAK,GAAGC,cAAc,CAAC;AAAEC,IAAAA,IAAI,EAAEjB,MAAR;AAAgBY,IAAAA,OAAAA;AAAhB,GAAD,CAA5B,CAAA;AAEA,EAAA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A4BD,IAAAA,SAAS,EAAER,yBAAvC;AAAkE6F,IAAAA,OAAO,EAAC,OAAA;AAA1E,GAAA,CAAA,CAFJ,CADJ,CAAA;AAMH,CAAA;AAQD;;;AAGG;;AACG,SAAUI,YAAV,CAAgE,KAAA,EAAA;EAAA,IAAzC;AAAE5F,IAAAA,QAAAA;GAAuC,GAAA,KAAA;AAAA,MAA1BI,KAA0B,GAAA,wBAAA,CAAA,KAAA,EAAA,UAAA,CAAA,CAAA;;AAClE,EAAA,oBACIvB,KAAA,CAAAgD,aAAA,CAAC6D,WAAD,EAAAC,cAAA,CAAA,EAAA,EAAiBvF,KAAjB,CAAA,eACIvB,KAAA,CAAAgD,aAAA,CAACgE,MAAD,EAAO;AAACC,IAAAA,KAAK,EAAC,OAAP;AAAeb,IAAAA,KAAK,EAAC,OAAA;GAA5B,EACKjF,QADL,CADJ,CADJ,CAAA;AAOH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
var modules_8f59d13b = {"overlay":"_8aa86dd3","fadein":"_20c07ee6","fitContent":"_713bc08f","container":"_45139719","full":"ec8619a2","large":"_86a1d5a4","medium":"_11d61de3","small":"aee19643","xlarge":"fe449c81","expand":"_61ffb38f","buttonContainer":"_49ffdac0","headerContent":"ee92ccb3"};
|
|
2
2
|
|
|
3
|
-
export default
|
|
3
|
+
export { modules_8f59d13b as default };
|
|
4
4
|
//# sourceMappingURL=modal.module.css.js.map
|
package/es/notice/notice.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { getClassNames } from '../utils/responsive-props.js';
|
|
3
3
|
import { Box } from '../box/box.js';
|
|
4
4
|
import { Columns, Column } from '../columns/columns.js';
|
|
5
5
|
import { AlertIcon } from '../icons/alert-icon.js';
|
|
6
|
-
import
|
|
6
|
+
import modules_1b547e7e from './notice.module.css.js';
|
|
7
7
|
|
|
8
8
|
function Notice({
|
|
9
9
|
id,
|
|
10
10
|
children,
|
|
11
11
|
tone
|
|
12
12
|
}) {
|
|
13
|
-
return /*#__PURE__*/createElement(Box, {
|
|
13
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
14
14
|
id: id,
|
|
15
15
|
role: "alert",
|
|
16
16
|
"aria-live": "polite",
|
|
17
|
-
className: [
|
|
18
|
-
}, /*#__PURE__*/createElement(Columns, {
|
|
17
|
+
className: [modules_1b547e7e.container, getClassNames(modules_1b547e7e, 'tone', tone)]
|
|
18
|
+
}, /*#__PURE__*/React.createElement(Columns, {
|
|
19
19
|
space: "small",
|
|
20
20
|
alignY: "top"
|
|
21
|
-
}, /*#__PURE__*/createElement(Column, {
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Column, {
|
|
22
22
|
width: "content"
|
|
23
|
-
}, /*#__PURE__*/createElement(AlertIcon, {
|
|
23
|
+
}, /*#__PURE__*/React.createElement(AlertIcon, {
|
|
24
24
|
tone: tone
|
|
25
|
-
})), /*#__PURE__*/createElement(Column, null, /*#__PURE__*/createElement(Box, {
|
|
25
|
+
})), /*#__PURE__*/React.createElement(Column, null, /*#__PURE__*/React.createElement(Box, {
|
|
26
26
|
paddingY: "xsmall"
|
|
27
27
|
}, children))));
|
|
28
28
|
}
|
package/es/notice/notice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notice.js","sources":["../../src/notice/notice.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../utils/responsive-props'\nimport { Box } from '../box'\nimport { Columns, Column } from '../columns'\nimport { AlertIcon } from '../icons/alert-icon'\n\nimport type { AlertTone } from '../utils/common-types'\n\nimport styles from './notice.module.css'\n\ntype NoticeProps = {\n id?: string\n children: React.ReactNode\n tone: AlertTone\n}\n\nfunction Notice({ id, children, tone }: NoticeProps) {\n return (\n <Box\n id={id}\n role=\"alert\"\n aria-live=\"polite\"\n className={[styles.container, getClassNames(styles, 'tone', tone)]}\n >\n <Columns space=\"small\" alignY=\"top\">\n <Column width=\"content\">\n <AlertIcon tone={tone} />\n </Column>\n <Column>\n <Box paddingY=\"xsmall\">{children}</Box>\n </Column>\n </Columns>\n </Box>\n )\n}\n\nexport { Notice }\nexport type { NoticeProps }\n"],"names":["Notice","id","children","tone","React","Box","role","className","styles","container","getClassNames","Columns","space","alignY","Column","width","AlertIcon","paddingY"],"mappings":";;;;;;;AAgBA,SAASA,MAAT,CAAgB;EAAEC,EAAF;EAAMC,QAAN;
|
|
1
|
+
{"version":3,"file":"notice.js","sources":["../../src/notice/notice.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../utils/responsive-props'\nimport { Box } from '../box'\nimport { Columns, Column } from '../columns'\nimport { AlertIcon } from '../icons/alert-icon'\n\nimport type { AlertTone } from '../utils/common-types'\n\nimport styles from './notice.module.css'\n\ntype NoticeProps = {\n id?: string\n children: React.ReactNode\n tone: AlertTone\n}\n\nfunction Notice({ id, children, tone }: NoticeProps) {\n return (\n <Box\n id={id}\n role=\"alert\"\n aria-live=\"polite\"\n className={[styles.container, getClassNames(styles, 'tone', tone)]}\n >\n <Columns space=\"small\" alignY=\"top\">\n <Column width=\"content\">\n <AlertIcon tone={tone} />\n </Column>\n <Column>\n <Box paddingY=\"xsmall\">{children}</Box>\n </Column>\n </Columns>\n </Box>\n )\n}\n\nexport { Notice }\nexport type { NoticeProps }\n"],"names":["Notice","id","children","tone","React","createElement","Box","role","className","styles","container","getClassNames","Columns","space","alignY","Column","width","AlertIcon","paddingY"],"mappings":";;;;;;;AAgBA,SAASA,MAAT,CAAgB;EAAEC,EAAF;EAAMC,QAAN;AAAgBC,EAAAA,IAAAA;AAAhB,CAAhB,EAAmD;AAC/C,EAAA,oBACIC,KAAA,CAAAC,aAAA,CAACC,GAAD,EAAI;AACAL,IAAAA,EAAE,EAAEA,EADJ;AAEAM,IAAAA,IAAI,EAAC,OAFL;AAEY,IAAA,WAAA,EACF,QAHV;AAIAC,IAAAA,SAAS,EAAE,CAACC,gBAAM,CAACC,SAAR,EAAmBC,aAAa,CAACF,gBAAD,EAAS,MAAT,EAAiBN,IAAjB,CAAhC,CAAA;AAJX,GAAJ,eAMIC,KAAC,CAAAC,aAAD,CAACO,OAAD;AAASC,IAAAA,KAAK,EAAC;AAAQC,IAAAA,MAAM,EAAC,KAAA;GAA9B,eACIV,KAAA,CAAAC,aAAA,CAACU,MAAD,EAAO;AAACC,IAAAA,KAAK,EAAC,SAAA;AAAP,GAAP,eACIZ,KAAA,CAAAC,aAAA,CAACY,SAAD,EAAW;AAAAd,IAAAA,IAAI,EAAEA,IAAAA;AAAN,GAAX,CADJ,CADJ,eAIIC,KAAA,CAAAC,aAAA,CAACU,MAAD,EAAO,IAAP,eACIX,KAAA,CAAAC,aAAA,CAACC,GAAD,EAAI;AAACY,IAAAA,QAAQ,EAAC,QAAA;AAAV,GAAJ,EAAwBhB,QAAxB,CADJ,CAJJ,CANJ,CADJ,CAAA;AAiBH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
var modules_1b547e7e = {"container":"_464500ae","tone-info":"_1abfe147","tone-positive":"_36ce9859","tone-caution":"f92214b7","tone-critical":"be6cf28e"};
|
|
2
2
|
|
|
3
|
-
export default
|
|
3
|
+
export { modules_1b547e7e as default };
|
|
4
4
|
//# sourceMappingURL=notice.module.css.js.map
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
3
|
-
import { IconButton } from '../button/button.js';
|
|
2
|
+
import * as React from 'react';
|
|
4
3
|
import { PasswordVisibleIcon } from '../icons/password-visible-icon.js';
|
|
5
4
|
import { PasswordHiddenIcon } from '../icons/password-hidden-icon.js';
|
|
6
5
|
import { TextField } from '../text-field/text-field.js';
|
|
6
|
+
import { IconButton } from '../button/button.js';
|
|
7
7
|
|
|
8
8
|
const _excluded = ["togglePasswordLabel"];
|
|
9
|
-
const PasswordField = /*#__PURE__*/forwardRef(function PasswordField(_ref, ref) {
|
|
9
|
+
const PasswordField = /*#__PURE__*/React.forwardRef(function PasswordField(_ref, ref) {
|
|
10
10
|
let {
|
|
11
11
|
togglePasswordLabel = 'Toggle password visibility'
|
|
12
12
|
} = _ref,
|
|
13
13
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
14
14
|
|
|
15
|
-
const [isPasswordVisible, setPasswordVisible] = useState(false);
|
|
15
|
+
const [isPasswordVisible, setPasswordVisible] = React.useState(false);
|
|
16
16
|
const Icon = isPasswordVisible ? PasswordVisibleIcon : PasswordHiddenIcon;
|
|
17
|
-
return /*#__PURE__*/createElement(TextField, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
17
|
+
return /*#__PURE__*/React.createElement(TextField, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
18
18
|
ref: ref,
|
|
19
19
|
// @ts-expect-error TextField does not support type="password", so we override the type check here
|
|
20
20
|
type: isPasswordVisible ? 'text' : 'password',
|
|
21
|
-
endSlot: /*#__PURE__*/createElement(IconButton, {
|
|
21
|
+
endSlot: /*#__PURE__*/React.createElement(IconButton, {
|
|
22
22
|
variant: "quaternary",
|
|
23
|
-
icon: /*#__PURE__*/createElement(Icon, {
|
|
23
|
+
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
24
24
|
"aria-hidden": true
|
|
25
25
|
}),
|
|
26
26
|
"aria-label": togglePasswordLabel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-field.js","sources":["../../src/password-field/password-field.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { PasswordVisibleIcon } from '../icons/password-visible-icon'\nimport { PasswordHiddenIcon } from '../icons/password-hidden-icon'\n\nimport { TextField, TextFieldProps } from '../text-field'\nimport { IconButton } from '../button'\n\nimport type { BaseFieldVariantProps } from '../base-field'\n\ninterface PasswordFieldProps\n extends Omit<TextFieldProps, 'type' | 'startSlot' | 'endSlot'>,\n BaseFieldVariantProps {\n togglePasswordLabel?: string\n}\n\nconst PasswordField = React.forwardRef<HTMLInputElement, PasswordFieldProps>(function PasswordField(\n { togglePasswordLabel = 'Toggle password visibility', ...props },\n ref,\n) {\n const [isPasswordVisible, setPasswordVisible] = React.useState(false)\n const Icon = isPasswordVisible ? PasswordVisibleIcon : PasswordHiddenIcon\n return (\n <TextField\n {...props}\n ref={ref}\n // @ts-expect-error TextField does not support type=\"password\", so we override the type check here\n type={isPasswordVisible ? 'text' : 'password'}\n endSlot={\n <IconButton\n variant=\"quaternary\"\n icon={<Icon aria-hidden />}\n aria-label={togglePasswordLabel}\n onClick={() => setPasswordVisible((v) => !v)}\n />\n }\n />\n )\n})\n\nexport { PasswordField }\nexport type { PasswordFieldProps }\n"],"names":["PasswordField","React","ref","togglePasswordLabel","props","isPasswordVisible","setPasswordVisible","Icon","PasswordVisibleIcon","PasswordHiddenIcon","TextField","type","endSlot","IconButton","variant","icon","onClick","v"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"password-field.js","sources":["../../src/password-field/password-field.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { PasswordVisibleIcon } from '../icons/password-visible-icon'\nimport { PasswordHiddenIcon } from '../icons/password-hidden-icon'\n\nimport { TextField, TextFieldProps } from '../text-field'\nimport { IconButton } from '../button'\n\nimport type { BaseFieldVariantProps } from '../base-field'\n\ninterface PasswordFieldProps\n extends Omit<TextFieldProps, 'type' | 'startSlot' | 'endSlot'>,\n BaseFieldVariantProps {\n togglePasswordLabel?: string\n}\n\nconst PasswordField = React.forwardRef<HTMLInputElement, PasswordFieldProps>(function PasswordField(\n { togglePasswordLabel = 'Toggle password visibility', ...props },\n ref,\n) {\n const [isPasswordVisible, setPasswordVisible] = React.useState(false)\n const Icon = isPasswordVisible ? PasswordVisibleIcon : PasswordHiddenIcon\n return (\n <TextField\n {...props}\n ref={ref}\n // @ts-expect-error TextField does not support type=\"password\", so we override the type check here\n type={isPasswordVisible ? 'text' : 'password'}\n endSlot={\n <IconButton\n variant=\"quaternary\"\n icon={<Icon aria-hidden />}\n aria-label={togglePasswordLabel}\n onClick={() => setPasswordVisible((v) => !v)}\n />\n }\n />\n )\n})\n\nexport { PasswordField }\nexport type { PasswordFieldProps }\n"],"names":["PasswordField","React","forwardRef","ref","togglePasswordLabel","props","isPasswordVisible","setPasswordVisible","useState","Icon","PasswordVisibleIcon","PasswordHiddenIcon","TextField","type","endSlot","IconButton","variant","icon","createElement","onClick","v"],"mappings":";;;;;;;;AAgBMA,MAAAA,aAAa,gBAAGC,KAAK,CAACC,UAAN,CAAuD,SAASF,aAAT,CAEzEG,IAAAA,EAAAA,GAFyE,EAEtE;EAAA,IADH;AAAEC,IAAAA,mBAAmB,GAAG,4BAAA;GACrB,GAAA,IAAA;AAAA,MADsDC,KACtD,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;EAEH,MAAM,CAACC,iBAAD,EAAoBC,kBAApB,CAAA,GAA0CN,KAAK,CAACO,QAAN,CAAe,KAAf,CAAhD,CAAA;AACA,EAAA,MAAMC,IAAI,GAAGH,iBAAiB,GAAGI,mBAAH,GAAyBC,kBAAvD,CAAA;AACA,EAAA,oBACIV,mBAAA,CAACW,SAAD,oCACQP,KADR,CAAA,EAAA,EAAA,EAAA;AAEIF,IAAAA,GAAG,EAAEA,GAFT;AAGI;AACAU,IAAAA,IAAI,EAAEP,iBAAiB,GAAG,MAAH,GAAY,UAJvC;AAKIQ,IAAAA,OAAO,eACHb,mBAAA,CAACc,UAAD,EAAW;AACPC,MAAAA,OAAO,EAAC,YADD;AAEPC,MAAAA,IAAI,eAAEhB,KAAA,CAAAiB,aAAA,CAACT,IAAD,EAAoB;QAAA,aAAA,EAAA,IAAA;AAAA,OAApB,CAFC;AAEmB,MAAA,YAAA,EACdL,mBAHL;AAIPe,MAAAA,OAAO,EAAE,MAAMZ,kBAAkB,CAAEa,CAAD,IAAO,CAACA,CAAT,CAAA;KAJrC,CAAA;GAPZ,CAAA,CAAA,CAAA;AAgBH,CAtBqB;;;;"}
|
package/es/prose/prose.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { Box } from '../box/box.js';
|
|
4
|
-
import
|
|
4
|
+
import modules_8ebe6db0 from './prose.module.css.js';
|
|
5
5
|
|
|
6
6
|
const _excluded = ["darkModeTypography", "exceptionallySetClassName"];
|
|
7
7
|
/**
|
|
@@ -15,8 +15,8 @@ function Prose(_ref) {
|
|
|
15
15
|
} = _ref,
|
|
16
16
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
17
17
|
|
|
18
|
-
return /*#__PURE__*/createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
19
|
-
className: [
|
|
18
|
+
return /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
19
|
+
className: [modules_8ebe6db0.prose, darkModeTypography ? modules_8ebe6db0.darkModeTypography : null, exceptionallySetClassName]
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
22
22
|
|
package/es/prose/prose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prose.js","sources":["../../src/prose/prose.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport styles from './prose.module.css'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ninterface ProseProps extends ObfuscatedClassName {\n /**\n * The prose content.\n *\n * This must consist of React nodes and elements. It is the consumer’s responsibility to\n * generate this from other sources, such as converting raw markdown content to React elements,\n * etc.\n *\n * Alternatively, you can use `<Prose dangerouslySetInnerHTML={{ __html: htmlString }}` />`\n * instead.\n */\n children?: React.ReactNode\n\n /**\n * Sets the prose content to be raw HTML stored in a string value.\n *\n * Warning: be advised that setting HTML content in this way is risky, because you can\n * inadvertently be vulnerable to a cross-site scripting (XSS) attack. Make sure you only use\n * this option with HTML content that has been sanitized (especially if it comes from user\n * provided content) or content that you fully control how it's generated, that cannot possibly\n * have any XSS content in it.\n *\n * @see https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml\n */\n dangerouslySetInnerHTML?: { __html: string } | undefined\n\n /**\n * Whether to customize the typography styles for dark mode.\n *\n * Applies finessed optimizations since our eyes perceive space differently when looking at dark\n * text on a light background and light text on a dark background.\n *\n * This does not apply a dark theme on the text. That's still the consumer apps’ responsibility.\n */\n darkModeTypography: boolean\n}\n\n/**\n * Used to style HTML you don’t control, like HTML content generated from Markdown.\n */\nfunction Prose({ darkModeTypography, exceptionallySetClassName, ...props }: ProseProps) {\n return (\n <Box\n {...props}\n className={[\n styles.prose,\n darkModeTypography ? styles.darkModeTypography : null,\n exceptionallySetClassName,\n ]}\n />\n )\n}\n\nexport { Prose }\nexport type { ProseProps }\n"],"names":["Prose","darkModeTypography","exceptionallySetClassName","props","React","Box","className","styles","prose"],"mappings":";;;;;;AA0CA
|
|
1
|
+
{"version":3,"file":"prose.js","sources":["../../src/prose/prose.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport styles from './prose.module.css'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ninterface ProseProps extends ObfuscatedClassName {\n /**\n * The prose content.\n *\n * This must consist of React nodes and elements. It is the consumer’s responsibility to\n * generate this from other sources, such as converting raw markdown content to React elements,\n * etc.\n *\n * Alternatively, you can use `<Prose dangerouslySetInnerHTML={{ __html: htmlString }}` />`\n * instead.\n */\n children?: React.ReactNode\n\n /**\n * Sets the prose content to be raw HTML stored in a string value.\n *\n * Warning: be advised that setting HTML content in this way is risky, because you can\n * inadvertently be vulnerable to a cross-site scripting (XSS) attack. Make sure you only use\n * this option with HTML content that has been sanitized (especially if it comes from user\n * provided content) or content that you fully control how it's generated, that cannot possibly\n * have any XSS content in it.\n *\n * @see https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml\n */\n dangerouslySetInnerHTML?: { __html: string } | undefined\n\n /**\n * Whether to customize the typography styles for dark mode.\n *\n * Applies finessed optimizations since our eyes perceive space differently when looking at dark\n * text on a light background and light text on a dark background.\n *\n * This does not apply a dark theme on the text. That's still the consumer apps’ responsibility.\n */\n darkModeTypography: boolean\n}\n\n/**\n * Used to style HTML you don’t control, like HTML content generated from Markdown.\n */\nfunction Prose({ darkModeTypography, exceptionallySetClassName, ...props }: ProseProps) {\n return (\n <Box\n {...props}\n className={[\n styles.prose,\n darkModeTypography ? styles.darkModeTypography : null,\n exceptionallySetClassName,\n ]}\n />\n )\n}\n\nexport { Prose }\nexport type { ProseProps }\n"],"names":["Prose","darkModeTypography","exceptionallySetClassName","props","React","createElement","Box","className","styles","prose"],"mappings":";;;;;;AA0CA;;AAEG;;AACH,SAASA,KAAT,CAAsF,IAAA,EAAA;EAAA,IAAvE;IAAEC,kBAAF;AAAsBC,IAAAA,yBAAAA;GAAiD,GAAA,IAAA;AAAA,MAAnBC,KAAmB,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAClF,EAAA,oBACIC,KAAC,CAAAC,aAAD,CAACC,GAAD,oCACQH,KADR,CAAA,EAAA,EAAA,EAAA;AAEII,IAAAA,SAAS,EAAE,CACPC,gBAAM,CAACC,KADA,EAEPR,kBAAkB,GAAGO,gBAAM,CAACP,kBAAV,GAA+B,IAF1C,EAGPC,yBAHO,CAAA;GAHnB,CAAA,CAAA,CAAA;AAUH;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import
|
|
3
|
-
import { Box } from '../box/box.js';
|
|
2
|
+
import * as React from 'react';
|
|
4
3
|
import { BaseField } from '../base-field/base-field.js';
|
|
5
|
-
import
|
|
4
|
+
import { Box } from '../box/box.js';
|
|
5
|
+
import modules_1fa9b208 from './select-field.module.css.js';
|
|
6
6
|
|
|
7
7
|
const _excluded = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "maxWidth", "children", "hidden", "aria-describedby"];
|
|
8
|
-
const SelectField = /*#__PURE__*/forwardRef(function SelectField(_ref, ref) {
|
|
8
|
+
const SelectField = /*#__PURE__*/React.forwardRef(function SelectField(_ref, ref) {
|
|
9
9
|
let {
|
|
10
10
|
variant = 'default',
|
|
11
11
|
id,
|
|
@@ -22,7 +22,7 @@ const SelectField = /*#__PURE__*/forwardRef(function SelectField(_ref, ref) {
|
|
|
22
22
|
} = _ref,
|
|
23
23
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
24
|
|
|
25
|
-
return /*#__PURE__*/createElement(BaseField, {
|
|
25
|
+
return /*#__PURE__*/React.createElement(BaseField, {
|
|
26
26
|
variant: variant,
|
|
27
27
|
id: id,
|
|
28
28
|
label: label,
|
|
@@ -34,23 +34,23 @@ const SelectField = /*#__PURE__*/forwardRef(function SelectField(_ref, ref) {
|
|
|
34
34
|
maxWidth: maxWidth,
|
|
35
35
|
hidden: hidden,
|
|
36
36
|
"aria-describedby": ariaDescribedBy
|
|
37
|
-
}, extraProps => /*#__PURE__*/createElement(Box, {
|
|
37
|
+
}, extraProps => /*#__PURE__*/React.createElement(Box, {
|
|
38
38
|
"data-testid": "select-wrapper",
|
|
39
|
-
className: [
|
|
40
|
-
}, /*#__PURE__*/createElement("select", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
|
|
39
|
+
className: [modules_1fa9b208.selectWrapper, tone === 'error' ? modules_1fa9b208.error : null, variant === 'bordered' ? modules_1fa9b208.bordered : null]
|
|
40
|
+
}, /*#__PURE__*/React.createElement("select", _objectSpread2(_objectSpread2(_objectSpread2({}, props), extraProps), {}, {
|
|
41
41
|
ref: ref
|
|
42
|
-
}), children), /*#__PURE__*/createElement(SelectChevron, {
|
|
42
|
+
}), children), /*#__PURE__*/React.createElement(SelectChevron, {
|
|
43
43
|
"aria-hidden": true
|
|
44
44
|
})));
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
function SelectChevron(props) {
|
|
48
|
-
return /*#__PURE__*/createElement("svg", _objectSpread2({
|
|
48
|
+
return /*#__PURE__*/React.createElement("svg", _objectSpread2({
|
|
49
49
|
width: "16",
|
|
50
50
|
height: "16",
|
|
51
51
|
fill: "none",
|
|
52
52
|
xmlns: "http://www.w3.org/2000/svg"
|
|
53
|
-
}, props), /*#__PURE__*/createElement("path", {
|
|
53
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
54
54
|
d: "M11.646 5.646a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L8 9.293l3.646-3.647z",
|
|
55
55
|
fill: "currentColor"
|
|
56
56
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-field.js","sources":["../../src/select-field/select-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './select-field.module.css'\n\ninterface SelectFieldProps extends FieldComponentProps<HTMLSelectElement>, BaseFieldVariantProps {}\n\nconst SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>(function SelectField(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n children,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n data-testid=\"select-wrapper\"\n className={[\n styles.selectWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n >\n <select {...props} {...extraProps} ref={ref}>\n {children}\n </select>\n <SelectChevron aria-hidden />\n </Box>\n )}\n </BaseField>\n )\n})\n\nfunction SelectChevron(props: JSX.IntrinsicElements['svg']) {\n return (\n <svg width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M11.646 5.646a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L8 9.293l3.646-3.647z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nexport { SelectField }\nexport type { SelectFieldProps }\n"],"names":["SelectField","React","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","children","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","selectWrapper","error","bordered","SelectChevron","width","height","fill","xmlns","d"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"select-field.js","sources":["../../src/select-field/select-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './select-field.module.css'\n\ninterface SelectFieldProps extends FieldComponentProps<HTMLSelectElement>, BaseFieldVariantProps {}\n\nconst SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>(function SelectField(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n children,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n data-testid=\"select-wrapper\"\n className={[\n styles.selectWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n >\n <select {...props} {...extraProps} ref={ref}>\n {children}\n </select>\n <SelectChevron aria-hidden />\n </Box>\n )}\n </BaseField>\n )\n})\n\nfunction SelectChevron(props: JSX.IntrinsicElements['svg']) {\n return (\n <svg width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M11.646 5.646a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L8 9.293l3.646-3.647z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nexport { SelectField }\nexport type { SelectFieldProps }\n"],"names":["SelectField","React","forwardRef","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","children","hidden","ariaDescribedBy","props","createElement","BaseField","extraProps","Box","className","styles","selectWrapper","error","bordered","_objectSpread","SelectChevron","width","height","fill","xmlns","d"],"mappings":";;;;;;;AAOMA,MAAAA,WAAW,gBAAGC,KAAK,CAACC,UAAN,CAAsD,SAASF,WAAT,CAgBtEG,IAAAA,EAAAA,GAhBsE,EAgBnE;EAAA,IAfH;AACIC,IAAAA,OAAO,GAAG,SADd;IAEIC,EAFJ;IAGIC,KAHJ;IAIIC,cAJJ;IAKIC,cALJ;IAMIC,IANJ;IAOIC,OAPJ;IAQIC,IARJ;IASIC,QATJ;IAUIC,QAVJ;IAWIC,MAXJ;IAYI,kBAAoBC,EAAAA,eAAAA;GAGrB,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,oBACIf,KAAC,CAAAgB,aAAD,CAACC,SAAD,EACI;AAAAd,IAAAA,OAAO,EAAEA,OAAT;AACAC,IAAAA,EAAE,EAAEA,EADJ;AAEAC,IAAAA,KAAK,EAAEA,KAFP;AAGAC,IAAAA,cAAc,EAAEA,cAHhB;AAIAC,IAAAA,cAAc,EAAEA,cAJhB;AAKAC,IAAAA,IAAI,EAAEA,IALN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