@doist/reactist 10.0.0-beta.1 → 10.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reactist.cjs.development.js +854 -537
- 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/components/{button/button.js → deprecated-button/deprecated-button.js} +5 -1
- package/es/components/deprecated-button/deprecated-button.js.map +1 -0
- package/es/components/{button → deprecated-button}/index.js +1 -1
- package/es/components/{button → deprecated-button}/index.js.map +0 -0
- package/es/components/{loading/loading.js → deprecated-loading/deprecated-loading.js} +3 -1
- package/es/components/deprecated-loading/deprecated-loading.js.map +1 -0
- package/es/components/{modal/modal.js → deprecated-modal/deprecated-modal.js} +6 -1
- package/es/components/deprecated-modal/deprecated-modal.js.map +1 -0
- package/es/components/{modal → deprecated-modal}/index.js +1 -1
- package/es/components/deprecated-modal/index.js.map +1 -0
- package/es/components/dropdown/dropdown.js +1 -1
- package/es/components/dropdown/dropdown.js.map +1 -1
- package/es/components/menu/menu.js.map +1 -1
- package/es/index.js +7 -5
- package/es/index.js.map +1 -1
- package/es/new-components/base-button/base-button.js +70 -0
- package/es/new-components/base-button/base-button.js.map +1 -0
- package/es/new-components/base-button/base-button.module.css.js +4 -0
- package/es/new-components/base-button/base-button.module.css.js.map +1 -0
- package/es/new-components/base-field/base-field.js +1 -1
- package/es/new-components/base-field/base-field.js.map +1 -1
- package/es/new-components/base-field/base-field.module.css.js +1 -1
- package/es/new-components/box/box.js +6 -5
- package/es/new-components/box/box.js.map +1 -1
- package/es/new-components/box/box.module.css.js +1 -1
- package/es/new-components/button/button.js +40 -0
- package/es/new-components/button/button.js.map +1 -0
- package/es/new-components/button-link/button-link.js +20 -10
- package/es/new-components/button-link/button-link.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-field.js +2 -1
- package/es/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-field.module.css.js +1 -1
- package/es/new-components/columns/columns.js +2 -2
- package/es/new-components/columns/columns.js.map +1 -1
- package/es/new-components/columns/columns.module.css.js +1 -1
- package/es/new-components/divider/divider.js +2 -2
- package/es/new-components/divider/divider.js.map +1 -1
- package/es/new-components/divider/divider.module.css.js +1 -1
- package/es/new-components/heading/heading.js +7 -2
- package/es/new-components/heading/heading.js.map +1 -1
- package/es/new-components/heading/heading.module.css.js +1 -1
- package/es/new-components/loading/loading.js +33 -0
- package/es/new-components/loading/loading.js.map +1 -0
- package/es/new-components/modal/modal.js +201 -0
- package/es/new-components/modal/modal.js.map +1 -0
- package/es/new-components/modal/modal.module.css.js +4 -0
- package/es/new-components/modal/modal.module.css.js.map +1 -0
- package/es/new-components/password-field/password-field.js +1 -1
- package/es/new-components/responsive-props.js +0 -21
- package/es/new-components/responsive-props.js.map +1 -1
- package/es/new-components/select-field/select-field.module.css.js +1 -1
- package/es/new-components/spinner/spinner.js +26 -0
- package/es/new-components/spinner/spinner.js.map +1 -0
- package/es/new-components/spinner/spinner.module.css.js +4 -0
- package/es/new-components/spinner/spinner.module.css.js.map +1 -0
- package/es/new-components/stack/stack.js +6 -6
- package/es/new-components/stack/stack.js.map +1 -1
- package/es/new-components/switch-field/switch-field.js +3 -2
- package/es/new-components/switch-field/switch-field.js.map +1 -1
- package/es/new-components/switch-field/switch-field.module.css.js +1 -1
- package/es/new-components/tabs/tabs.js +11 -8
- package/es/new-components/tabs/tabs.js.map +1 -1
- package/es/new-components/tabs/tabs.module.css.js +1 -1
- package/es/new-components/text/text.js +6 -5
- package/es/new-components/text/text.js.map +1 -1
- package/es/new-components/text/text.module.css.js +1 -1
- package/es/new-components/text-area/text-area.module.css.js +1 -1
- package/es/new-components/text-field/text-field.module.css.js +1 -1
- package/es/utils/polymorphism.js.map +1 -1
- package/lib/components/{button/button.d.ts → deprecated-button/deprecated-button.d.ts} +7 -1
- package/lib/components/{button/button.js → deprecated-button/deprecated-button.js} +1 -1
- package/lib/components/deprecated-button/deprecated-button.js.map +1 -0
- package/lib/components/{button/button.test.d.ts → deprecated-button/deprecated-button.test.d.ts} +0 -0
- package/lib/components/deprecated-button/index.d.ts +4 -0
- package/lib/components/{loading → deprecated-button}/index.js +1 -1
- package/lib/components/{button → deprecated-button}/index.js.map +0 -0
- package/lib/components/{loading/loading.d.ts → deprecated-loading/deprecated-loading.d.ts} +2 -1
- package/lib/components/{loading/loading.js → deprecated-loading/deprecated-loading.js} +1 -1
- package/lib/components/deprecated-loading/deprecated-loading.js.map +1 -0
- package/lib/components/{loading/Loading.test.d.ts → deprecated-loading/deprecated-loading.test.d.ts} +0 -0
- package/lib/components/deprecated-loading/index.d.ts +1 -0
- package/lib/components/{modal/modal.d.ts → deprecated-modal/deprecated-modal.d.ts} +6 -1
- package/lib/components/{modal/modal.js → deprecated-modal/deprecated-modal.js} +1 -1
- package/lib/components/deprecated-modal/deprecated-modal.js.map +1 -0
- package/lib/components/{modal/modal.test.d.ts → deprecated-modal/deprecated-modal.test.d.ts} +0 -0
- package/lib/components/{modal → deprecated-modal}/index.d.ts +2 -2
- package/lib/components/deprecated-modal/index.js +2 -0
- package/lib/components/deprecated-modal/index.js.map +1 -0
- package/lib/components/dropdown/dropdown.js +1 -1
- package/lib/components/dropdown/dropdown.js.map +1 -1
- package/lib/components/menu/menu.d.ts +5 -9
- package/lib/components/menu/menu.js.map +1 -1
- package/lib/index.d.ts +6 -4
- package/lib/index.js +1 -1
- package/lib/new-components/base-button/base-button.d.ts +65 -0
- package/lib/new-components/base-button/base-button.js +2 -0
- package/lib/new-components/base-button/base-button.js.map +1 -0
- package/lib/new-components/base-button/base-button.module.css.js +2 -0
- package/lib/new-components/base-button/base-button.module.css.js.map +1 -0
- package/lib/new-components/base-button/index.d.ts +1 -0
- package/lib/new-components/base-field/base-field.js +1 -1
- package/lib/new-components/base-field/base-field.js.map +1 -1
- package/lib/new-components/base-field/base-field.module.css.js +1 -1
- package/lib/new-components/box/box.d.ts +8 -5
- package/lib/new-components/box/box.js +1 -1
- package/lib/new-components/box/box.js.map +1 -1
- package/lib/new-components/box/box.module.css.js +1 -1
- package/lib/new-components/button/button.d.ts +48 -0
- package/lib/new-components/button/button.js +2 -0
- package/lib/new-components/button/button.js.map +1 -0
- package/lib/new-components/button/button.test.d.ts +1 -0
- package/lib/new-components/button/index.d.ts +1 -0
- package/lib/new-components/button-link/button-link-story-wrapper.d.ts +7 -0
- package/lib/new-components/button-link/button-link.d.ts +14 -7
- package/lib/new-components/button-link/button-link.js +1 -1
- package/lib/new-components/button-link/button-link.js.map +1 -1
- package/lib/new-components/button-link/button-link.test.d.ts +1 -0
- package/lib/new-components/checkbox-field/checkbox-field.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.module.css.js +1 -1
- package/lib/new-components/columns/columns.js +1 -1
- package/lib/new-components/columns/columns.js.map +1 -1
- package/lib/new-components/columns/columns.module.css.js +1 -1
- package/lib/new-components/common-types.d.ts +1 -0
- package/lib/new-components/divider/divider.d.ts +2 -2
- package/lib/new-components/divider/divider.js +1 -1
- package/lib/new-components/divider/divider.js.map +1 -1
- package/lib/new-components/divider/divider.module.css.js +1 -1
- package/lib/new-components/heading/heading.d.ts +101 -3
- package/lib/new-components/heading/heading.js +1 -1
- package/lib/new-components/heading/heading.js.map +1 -1
- package/lib/new-components/heading/heading.module.css.js +1 -1
- package/lib/new-components/heading/heading.test.d.ts +1 -0
- package/lib/new-components/loading/index.d.ts +1 -0
- package/lib/new-components/loading/loading.d.ts +26 -0
- package/lib/new-components/loading/loading.js +2 -0
- package/lib/new-components/loading/loading.js.map +1 -0
- package/lib/new-components/loading/loading.test.d.ts +1 -0
- package/lib/new-components/modal/index.d.ts +1 -0
- package/lib/new-components/modal/modal-stories-components.d.ts +35 -0
- package/lib/new-components/modal/modal.d.ts +151 -0
- package/lib/new-components/modal/modal.js +2 -0
- package/lib/new-components/modal/modal.js.map +1 -0
- package/lib/new-components/modal/modal.module.css.js +2 -0
- package/lib/new-components/modal/modal.module.css.js.map +1 -0
- package/lib/new-components/modal/modal.test.d.ts +1 -0
- package/lib/new-components/password-field/password-field.js +1 -1
- package/lib/new-components/responsive-props.d.ts +1 -1
- package/lib/new-components/responsive-props.js +1 -1
- package/lib/new-components/responsive-props.js.map +1 -1
- package/lib/new-components/select-field/select-field.module.css.js +1 -1
- package/lib/new-components/spinner/index.d.ts +1 -0
- package/lib/new-components/spinner/spinner.d.ts +5 -0
- package/lib/new-components/spinner/spinner.js +2 -0
- package/lib/new-components/spinner/spinner.js.map +1 -0
- package/lib/new-components/spinner/spinner.module.css.js +2 -0
- package/lib/new-components/spinner/spinner.module.css.js.map +1 -0
- package/lib/new-components/stack/stack.d.ts +5 -5
- package/lib/new-components/stack/stack.js +1 -1
- package/lib/new-components/stack/stack.js.map +1 -1
- package/lib/new-components/switch-field/switch-field.js +1 -1
- package/lib/new-components/switch-field/switch-field.js.map +1 -1
- package/lib/new-components/switch-field/switch-field.module.css.js +1 -1
- package/lib/new-components/tabs/tabs.d.ts +6 -6
- package/lib/new-components/tabs/tabs.js +1 -1
- package/lib/new-components/tabs/tabs.js.map +1 -1
- package/lib/new-components/tabs/tabs.module.css.js +1 -1
- package/lib/new-components/text/text.d.ts +36 -1
- package/lib/new-components/text/text.js +1 -1
- package/lib/new-components/text/text.js.map +1 -1
- package/lib/new-components/text/text.module.css.js +1 -1
- package/lib/new-components/text/text.test.d.ts +1 -0
- package/lib/new-components/text-area/text-area.module.css.js +1 -1
- package/lib/new-components/text-field/text-field.module.css.js +1 -1
- package/lib/utils/polymorphism.d.ts +1 -1
- package/lib/utils/polymorphism.js.map +1 -1
- package/package.json +3 -1
- package/styles/alert.css +2 -2
- package/styles/{button-link.css → base-button.css} +4 -2
- package/styles/base-button.module.css.css +1 -0
- package/styles/base-field.css +4 -4
- package/styles/base-field.module.css.css +1 -1
- package/styles/box.css +1 -1
- package/styles/box.module.css.css +1 -1
- package/styles/checkbox-field.css +3 -2
- package/styles/checkbox-field.module.css.css +1 -1
- package/styles/columns.css +2 -2
- package/styles/columns.module.css.css +1 -1
- package/styles/{button.css → deprecated-button.css} +0 -0
- package/styles/deprecated-loading.css +1 -0
- package/styles/deprecated-modal.css +1 -0
- package/styles/divider.css +2 -2
- package/styles/divider.module.css.css +1 -1
- package/styles/heading.css +2 -2
- package/styles/heading.module.css.css +1 -1
- package/styles/hidden-visually.css +1 -1
- package/styles/hidden.css +1 -1
- package/styles/inline.css +1 -1
- package/styles/loading.css +4 -1
- package/styles/modal.css +10 -1
- package/styles/modal.module.css.css +1 -0
- package/styles/notice.css +2 -2
- package/styles/password-field.css +5 -5
- package/styles/reactist.css +20 -19
- package/styles/select-field.css +5 -5
- package/styles/select-field.module.css.css +1 -1
- package/styles/spinner.module.css.css +1 -0
- package/styles/stack.css +2 -2
- package/styles/switch-field.css +5 -5
- package/styles/switch-field.module.css.css +1 -1
- package/styles/tabs.css +2 -2
- package/styles/tabs.module.css.css +1 -1
- package/styles/text-area.css +5 -5
- package/styles/text-area.module.css.css +1 -1
- package/styles/text-field.css +5 -5
- package/styles/text-field.module.css.css +1 -1
- package/styles/text-link.css +1 -1
- package/styles/text.css +2 -2
- package/styles/text.module.css.css +1 -1
- package/es/components/button/button.js.map +0 -1
- package/es/components/loading/index.js +0 -6
- package/es/components/loading/index.js.map +0 -1
- package/es/components/loading/loading.js.map +0 -1
- package/es/components/modal/index.js.map +0 -1
- package/es/components/modal/modal.js.map +0 -1
- package/es/new-components/button-link/button-link.module.css.js +0 -4
- package/es/new-components/button-link/button-link.module.css.js.map +0 -1
- package/es/new-components/loading-spinner/loading-spinner.js +0 -37
- package/es/new-components/loading-spinner/loading-spinner.js.map +0 -1
- package/es/new-components/loading-spinner/loading-spinner.module.css.js +0 -4
- package/es/new-components/loading-spinner/loading-spinner.module.css.js.map +0 -1
- package/lib/components/button/button.js.map +0 -1
- package/lib/components/button/index.d.ts +0 -4
- package/lib/components/button/index.js +0 -2
- package/lib/components/loading/index.d.ts +0 -2
- package/lib/components/loading/index.js.map +0 -1
- package/lib/components/loading/loading.js.map +0 -1
- package/lib/components/modal/index.js +0 -2
- package/lib/components/modal/index.js.map +0 -1
- package/lib/components/modal/modal.js.map +0 -1
- package/lib/new-components/button-link/button-link.module.css.js +0 -2
- package/lib/new-components/button-link/button-link.module.css.js.map +0 -1
- package/lib/new-components/loading-spinner/index.d.ts +0 -1
- package/lib/new-components/loading-spinner/loading-spinner.d.ts +0 -8
- package/lib/new-components/loading-spinner/loading-spinner.js +0 -2
- package/lib/new-components/loading-spinner/loading-spinner.js.map +0 -1
- package/lib/new-components/loading-spinner/loading-spinner.module.css.js +0 -2
- package/lib/new-components/loading-spinner/loading-spinner.module.css.js.map +0 -1
- package/styles/button-link.module.css.css +0 -1
- package/styles/loading-spinner.module.css.css +0 -1
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { useMemo, createElement, useContext, Fragment, Children, createContext } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Box } from '../box/box.js';
|
|
5
|
+
import { Columns, Column } from '../columns/columns.js';
|
|
6
|
+
import { Divider } from '../divider/divider.js';
|
|
7
|
+
import { Inline } from '../inline/inline.js';
|
|
8
|
+
import { CloseIcon } from '../icons/close-icon.js';
|
|
9
|
+
import { Button } from '../button/button.js';
|
|
10
|
+
import { DialogOverlay, DialogContent } from '@reach/dialog';
|
|
11
|
+
import FocusLock from 'react-focus-lock';
|
|
12
|
+
import styles from './modal.module.css.js';
|
|
13
|
+
|
|
14
|
+
var ModalContext = /*#__PURE__*/createContext({
|
|
15
|
+
onDismiss: undefined,
|
|
16
|
+
height: 'fitContent'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function isNotInternalFrame(element) {
|
|
20
|
+
return !(element.ownerDocument === document && element.tagName.toLowerCase() === 'iframe');
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Renders a modal that sits on top of the rest of the content in the entire page.
|
|
24
|
+
*
|
|
25
|
+
* Follows the WAI-ARIA Dialog (Modal) Pattern.
|
|
26
|
+
*
|
|
27
|
+
* @see ModalHeader
|
|
28
|
+
* @see ModalFooter
|
|
29
|
+
* @see ModalBody
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function Modal(_ref) {
|
|
34
|
+
var isOpen = _ref.isOpen,
|
|
35
|
+
onDismiss = _ref.onDismiss,
|
|
36
|
+
_ref$height = _ref.height,
|
|
37
|
+
height = _ref$height === void 0 ? 'fitContent' : _ref$height,
|
|
38
|
+
_ref$width = _ref.width,
|
|
39
|
+
width = _ref$width === void 0 ? 'medium' : _ref$width,
|
|
40
|
+
exceptionallySetClassName = _ref.exceptionallySetClassName,
|
|
41
|
+
_ref$autoFocus = _ref.autoFocus,
|
|
42
|
+
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
43
|
+
children = _ref.children,
|
|
44
|
+
props = _objectWithoutPropertiesLoose(_ref, ["isOpen", "onDismiss", "height", "width", "exceptionallySetClassName", "autoFocus", "children"]);
|
|
45
|
+
|
|
46
|
+
var contextValue = useMemo(function () {
|
|
47
|
+
return {
|
|
48
|
+
onDismiss: onDismiss,
|
|
49
|
+
height: height
|
|
50
|
+
};
|
|
51
|
+
}, [onDismiss, height]);
|
|
52
|
+
return /*#__PURE__*/createElement(DialogOverlay, {
|
|
53
|
+
isOpen: isOpen,
|
|
54
|
+
onDismiss: onDismiss,
|
|
55
|
+
dangerouslyBypassFocusLock // We're setting up our own focus lock below
|
|
56
|
+
: true,
|
|
57
|
+
className: classNames(styles.overlay, styles[height], styles[width]),
|
|
58
|
+
"data-testid": "modal-overlay"
|
|
59
|
+
}, /*#__PURE__*/createElement(FocusLock, {
|
|
60
|
+
autoFocus: autoFocus,
|
|
61
|
+
whiteList: isNotInternalFrame
|
|
62
|
+
}, /*#__PURE__*/createElement(DialogContent, Object.assign({}, props, {
|
|
63
|
+
as: Box,
|
|
64
|
+
borderRadius: "full",
|
|
65
|
+
background: "default",
|
|
66
|
+
display: "flex",
|
|
67
|
+
flexDirection: "column",
|
|
68
|
+
overflow: "hidden",
|
|
69
|
+
height: height === 'expand' ? 'full' : undefined,
|
|
70
|
+
flexGrow: height === 'expand' ? 1 : 0,
|
|
71
|
+
className: [exceptionallySetClassName, styles.container]
|
|
72
|
+
}), /*#__PURE__*/createElement(ModalContext.Provider, {
|
|
73
|
+
value: contextValue
|
|
74
|
+
}, children))));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The close button rendered by ModalHeader. Provided independently so that consumers can customize
|
|
78
|
+
* the button's label.
|
|
79
|
+
*
|
|
80
|
+
* @see ModalHeader
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
function ModalCloseButton(props) {
|
|
84
|
+
var _React$useContext = useContext(ModalContext),
|
|
85
|
+
onDismiss = _React$useContext.onDismiss;
|
|
86
|
+
|
|
87
|
+
return /*#__PURE__*/createElement(Button, Object.assign({}, props, {
|
|
88
|
+
variant: "quaternary",
|
|
89
|
+
onClick: onDismiss,
|
|
90
|
+
icon: /*#__PURE__*/createElement(CloseIcon, null)
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Renders a standard modal header area with an optional close button.
|
|
95
|
+
*
|
|
96
|
+
* @see Modal
|
|
97
|
+
* @see ModalFooter
|
|
98
|
+
* @see ModalBody
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
function ModalHeader(_ref2) {
|
|
102
|
+
var children = _ref2.children,
|
|
103
|
+
_ref2$button = _ref2.button,
|
|
104
|
+
button = _ref2$button === void 0 ? true : _ref2$button,
|
|
105
|
+
_ref2$withDivider = _ref2.withDivider,
|
|
106
|
+
withDivider = _ref2$withDivider === void 0 ? false : _ref2$withDivider,
|
|
107
|
+
exceptionallySetClassName = _ref2.exceptionallySetClassName,
|
|
108
|
+
props = _objectWithoutPropertiesLoose(_ref2, ["children", "button", "withDivider", "exceptionallySetClassName"]);
|
|
109
|
+
|
|
110
|
+
return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Box, Object.assign({}, props, {
|
|
111
|
+
as: "header",
|
|
112
|
+
paddingLeft: "large",
|
|
113
|
+
paddingRight: "small",
|
|
114
|
+
paddingY: "small",
|
|
115
|
+
className: exceptionallySetClassName
|
|
116
|
+
}), /*#__PURE__*/createElement(Columns, {
|
|
117
|
+
space: "large",
|
|
118
|
+
alignY: "center"
|
|
119
|
+
}, /*#__PURE__*/createElement(Column, {
|
|
120
|
+
width: "auto"
|
|
121
|
+
}, children), /*#__PURE__*/createElement(Column, {
|
|
122
|
+
width: "content",
|
|
123
|
+
exceptionallySetClassName: styles.buttonContainer
|
|
124
|
+
}, typeof button !== 'boolean' ? button : button === true ? /*#__PURE__*/createElement(ModalCloseButton, {
|
|
125
|
+
"aria-label": "Close modal"
|
|
126
|
+
}) : null))), withDivider ? /*#__PURE__*/createElement(Divider, null) : null);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Renders the body of a modal.
|
|
130
|
+
*
|
|
131
|
+
* Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other
|
|
132
|
+
* things, that the contet of the modal body expands or contracts depending on the modal height
|
|
133
|
+
* setting or the size of the content. The body content also automatically scrolls when it's too
|
|
134
|
+
* large to fit the available space.
|
|
135
|
+
*
|
|
136
|
+
* @see Modal
|
|
137
|
+
* @see ModalHeader
|
|
138
|
+
* @see ModalFooter
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
function ModalBody(_ref3) {
|
|
142
|
+
var exceptionallySetClassName = _ref3.exceptionallySetClassName,
|
|
143
|
+
children = _ref3.children,
|
|
144
|
+
props = _objectWithoutPropertiesLoose(_ref3, ["exceptionallySetClassName", "children"]);
|
|
145
|
+
|
|
146
|
+
var _React$useContext2 = useContext(ModalContext),
|
|
147
|
+
height = _React$useContext2.height;
|
|
148
|
+
|
|
149
|
+
return /*#__PURE__*/createElement(Box, Object.assign({}, props, {
|
|
150
|
+
className: exceptionallySetClassName,
|
|
151
|
+
flexGrow: height === 'expand' ? 1 : 0,
|
|
152
|
+
height: height === 'expand' ? 'full' : undefined,
|
|
153
|
+
overflow: "auto"
|
|
154
|
+
}), /*#__PURE__*/createElement(Box, {
|
|
155
|
+
padding: "large",
|
|
156
|
+
paddingBottom: "xxlarge"
|
|
157
|
+
}, children));
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Renders a standard modal footer area.
|
|
161
|
+
*
|
|
162
|
+
* @see Modal
|
|
163
|
+
* @see ModalHeader
|
|
164
|
+
* @see ModalBody
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
function ModalFooter(_ref4) {
|
|
168
|
+
var exceptionallySetClassName = _ref4.exceptionallySetClassName,
|
|
169
|
+
_ref4$withDivider = _ref4.withDivider,
|
|
170
|
+
withDivider = _ref4$withDivider === void 0 ? false : _ref4$withDivider,
|
|
171
|
+
props = _objectWithoutPropertiesLoose(_ref4, ["exceptionallySetClassName", "withDivider"]);
|
|
172
|
+
|
|
173
|
+
return /*#__PURE__*/createElement(Fragment, null, withDivider ? /*#__PURE__*/createElement(Divider, null) : null, /*#__PURE__*/createElement(Box, Object.assign({
|
|
174
|
+
as: "footer"
|
|
175
|
+
}, props, {
|
|
176
|
+
className: exceptionallySetClassName,
|
|
177
|
+
padding: "large"
|
|
178
|
+
})));
|
|
179
|
+
} //
|
|
180
|
+
// ModalActions
|
|
181
|
+
//
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* A specific version of the ModalFooter, tailored to showing an inline list of actions (buttons).
|
|
185
|
+
* @see ModalFooter
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
function ModalActions(_ref5) {
|
|
189
|
+
var children = _ref5.children,
|
|
190
|
+
props = _objectWithoutPropertiesLoose(_ref5, ["children"]);
|
|
191
|
+
|
|
192
|
+
return /*#__PURE__*/createElement(ModalFooter, Object.assign({}, props), /*#__PURE__*/createElement(Inline, {
|
|
193
|
+
align: "right",
|
|
194
|
+
space: "large"
|
|
195
|
+
}, Children.map(children, function (child) {
|
|
196
|
+
return /*#__PURE__*/createElement("div", null, child);
|
|
197
|
+
})));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { Modal, ModalActions, ModalBody, ModalCloseButton, ModalFooter, ModalHeader };
|
|
201
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../src/new-components/modal/modal.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { DialogOverlay, DialogContent } from '@reach/dialog'\nimport FocusLock from 'react-focus-lock'\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 { Button, ButtonProps } from '../button'\n\nimport styles from './modal.module.css'\n\ntype ModalWidth = 'small' | 'medium' | 'large'\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'\n>\n\nexport type ModalProps = DivProps & {\n /**\n * The content of the modal.\n */\n children: React.ReactNode\n /**\n * Whether the modal is open and visible or not.\n */\n isOpen: boolean\n /**\n * Called when the user triggers closing the modal.\n */\n onDismiss?(): void\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 * 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 * Whether to set or not the focus initially to the first focusable element inside the modal.\n */\n autoFocus?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\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 autoFocus = true,\n children,\n ...props\n}: ModalProps) {\n const contextValue: ModalContextValue = React.useMemo(() => ({ onDismiss, height }), [\n onDismiss,\n height,\n ])\n\n return (\n <DialogOverlay\n isOpen={isOpen}\n onDismiss={onDismiss}\n dangerouslyBypassFocusLock // We're setting up our own focus lock below\n className={classNames(styles.overlay, styles[height], styles[width])}\n data-testid=\"modal-overlay\"\n >\n <FocusLock autoFocus={autoFocus} whiteList={isNotInternalFrame}>\n <DialogContent\n {...props}\n as={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 className={[exceptionallySetClassName, styles.container]}\n >\n <ModalContext.Provider value={contextValue}>{children}</ModalContext.Provider>\n </DialogContent>\n </FocusLock>\n </DialogOverlay>\n )\n}\n\n//\n// ModalCloseButton\n//\n\nexport type ModalCloseButtonProps = Omit<\n ButtonProps,\n 'type' | 'children' | 'variant' | 'icon' | 'startIcon' | 'endIcon' | 'disabled' | 'loading'\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 return <Button {...props} variant=\"quaternary\" onClick={onDismiss} icon={<CloseIcon />} />\n}\n\n//\n// ModalHeader\n//\n\nexport type ModalHeaderProps = DivProps & {\n /**\n * The content of the header.\n */\n children: React.ReactNode\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 * Whether to render a divider line below the header.\n * @default false\n */\n withDivider?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\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=\"small\"\n paddingY=\"small\"\n className={exceptionallySetClassName}\n >\n <Columns space=\"large\" alignY=\"center\">\n <Column width=\"auto\">{children}</Column>\n <Column width=\"content\" exceptionallySetClassName={styles.buttonContainer}>\n {typeof button !== 'boolean' ? (\n button\n ) : button === true ? (\n <ModalCloseButton aria-label=\"Close modal\" />\n ) : null}\n </Column>\n </Columns>\n </Box>\n {withDivider ? <Divider /> : null}\n </>\n )\n}\n\n//\n// ModalBody\n//\n\nexport type ModalBodyProps = DivProps & {\n /**\n * The content of the modal body.\n */\n children: React.ReactNode\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\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 type ModalFooterProps = DivProps & {\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 * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\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\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 }: ModalFooterProps) {\n return (\n <ModalFooter {...props}>\n <Inline align=\"right\" space=\"large\">\n {React.Children.map(children, (child) => (\n <div>{child}</div>\n ))}\n </Inline>\n </ModalFooter>\n )\n}\n"],"names":["ModalContext","React","onDismiss","undefined","height","isNotInternalFrame","element","ownerDocument","document","tagName","toLowerCase","Modal","isOpen","width","exceptionallySetClassName","autoFocus","children","props","contextValue","DialogOverlay","dangerouslyBypassFocusLock","className","classNames","styles","overlay","FocusLock","whiteList","DialogContent","as","Box","borderRadius","background","display","flexDirection","overflow","flexGrow","container","Provider","value","ModalCloseButton","Button","variant","onClick","icon","CloseIcon","ModalHeader","button","withDivider","paddingLeft","paddingRight","paddingY","Columns","space","alignY","Column","buttonContainer","Divider","ModalBody","padding","paddingBottom","ModalFooter","ModalActions","Inline","align","map","child"],"mappings":";;;;;;;;;;;;;AA0BA,IAAMA,YAAY,gBAAGC,aAAA,CAAuC;AACxDC,EAAAA,SAAS,EAAEC,SAD6C;AAExDC,EAAAA,MAAM,EAAE;AAFgD,CAAvC,CAArB;;AA0DA,SAASC,kBAAT,CAA4BC,OAA5B;AACI,SAAO,EAAEA,OAAO,CAACC,aAAR,KAA0BC,QAA1B,IAAsCF,OAAO,CAACG,OAAR,CAAgBC,WAAhB,OAAkC,QAA1E,CAAP;AACH;AAED;;;;;;;;;;;SASgBC;MACZC,cAAAA;MACAV,iBAAAA;yBACAE;MAAAA,kCAAS;wBACTS;MAAAA,gCAAQ;MACRC,iCAAAA;4BACAC;MAAAA,wCAAY;MACZC,gBAAAA;MACGC;;AAEH,MAAMC,YAAY,GAAsBjB,OAAA,CAAc;AAAA,WAAO;AAAEC,MAAAA,SAAS,EAATA,SAAF;AAAaE,MAAAA,MAAM,EAANA;AAAb,KAAP;AAAA,GAAd,EAA6C,CACjFF,SADiF,EAEjFE,MAFiF,CAA7C,CAAxC;AAKA,sBACIH,aAAA,CAACkB,aAAD;AACIP,IAAAA,MAAM,EAAEA;AACRV,IAAAA,SAAS,EAAEA;AACXkB,IAAAA,0BAA0B;AAAA;AAC1BC,IAAAA,SAAS,EAAEC,UAAU,CAACC,MAAM,CAACC,OAAR,EAAiBD,MAAM,CAACnB,MAAD,CAAvB,EAAiCmB,MAAM,CAACV,KAAD,CAAvC;mBACT;GALhB,eAOIZ,aAAA,CAACwB,SAAD;AAAWV,IAAAA,SAAS,EAAEA;AAAWW,IAAAA,SAAS,EAAErB;GAA5C,e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hB,aAAA,CAAC2D,WAAD,oBAAiB3C,MAAjB,eACIhB,aAAA,CAAC6D,MAAD;AAAQC,IAAAA,KAAK,EAAC;AAAQX,IAAAA,KAAK,EAAC;GAA5B,EACKnD,QAAA,CAAe+D,GAAf,CAAmBhD,QAAnB,EAA6B,UAACiD,KAAD;AAAA,wBAC1BhE,aAAA,MAAA,MAAA,EAAMgE,KAAN,CAD0B;AAAA,GAA7B,CADL,CADJ,CADJ;AASH;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var modules_8f59d13b = {"reach-portal":"_72b0d072","fadein":"_3ef30abf","fitContent":"_99107d2f","container":"badff007","medium":"_3b39110c","small":"fc325d7b","large":"_5751d6d0","overlay":"_0091d9c5","expand":"_52207af6","buttonContainer":"b97b958d"};
|
|
2
|
+
|
|
3
|
+
export default modules_8f59d13b;
|
|
4
|
+
//# sourceMappingURL=modal.module.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { forwardRef, useRef, useState, createElement } from 'react';
|
|
3
3
|
import { Box } from '../box/box.js';
|
|
4
|
-
import { useForkRef } from 'reakit-utils';
|
|
5
4
|
import { Tooltip } from '../../components/tooltip/tooltip.js';
|
|
5
|
+
import { useForkRef } from 'reakit-utils';
|
|
6
6
|
import { useId } from '../common-helpers.js';
|
|
7
7
|
import { BaseField } from '../base-field/base-field.js';
|
|
8
8
|
import { PasswordVisibleIcon } from '../icons/password-visible-icon.js';
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
var DEBUG = process.env.NODE_ENV === 'development';
|
|
2
|
-
|
|
3
|
-
function isResponsivePropArray(responsiveProp) {
|
|
4
|
-
return Array.isArray(responsiveProp);
|
|
5
|
-
}
|
|
6
2
|
/**
|
|
7
3
|
* Builds a css module class name for a given prop + prop-value combination.
|
|
8
4
|
*
|
|
@@ -21,7 +17,6 @@ function isResponsivePropArray(responsiveProp) {
|
|
|
21
17
|
* @param value the given prop's value
|
|
22
18
|
*/
|
|
23
19
|
|
|
24
|
-
|
|
25
20
|
function getClassNames(styles, property, value) {
|
|
26
21
|
if (!value) {
|
|
27
22
|
return null;
|
|
@@ -29,14 +24,6 @@ function getClassNames(styles, property, value) {
|
|
|
29
24
|
|
|
30
25
|
var classList = [];
|
|
31
26
|
|
|
32
|
-
if (isResponsivePropArray(value)) {
|
|
33
|
-
value = {
|
|
34
|
-
mobile: value[0],
|
|
35
|
-
tablet: value[1],
|
|
36
|
-
desktop: value[2]
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
27
|
if (typeof value === 'string') {
|
|
41
28
|
classList.push(styles[property + "-" + value]);
|
|
42
29
|
} else {
|
|
@@ -77,14 +64,6 @@ function mapResponsiveProp(fromValue, mapper) {
|
|
|
77
64
|
return mapper(fromValue);
|
|
78
65
|
}
|
|
79
66
|
|
|
80
|
-
if (isResponsivePropArray(fromValue)) {
|
|
81
|
-
fromValue = {
|
|
82
|
-
mobile: fromValue[0],
|
|
83
|
-
tablet: fromValue[1],
|
|
84
|
-
desktop: fromValue[2]
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
67
|
return {
|
|
89
68
|
mobile: fromValue.mobile ? mapper(fromValue.mobile) : undefined,
|
|
90
69
|
tablet: fromValue.tablet ? mapper(fromValue.tablet) : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responsive-props.js","sources":["../../src/new-components/responsive-props.ts"],"sourcesContent":["type ResponsiveBreakpoints = 'mobile' | 'tablet' | 'desktop'\n\ntype Atom = string | number | boolean\n\n/**\n * A responsive prop supports receiving values of its given base type, or an object mapping a\n * responsive breakpoint name to a value from the prop's base type.\n *\n * Some examples:\n *\n * - `align={{ mobile: 'left', tablet: 'center', desktop: 'right' }}`\n */\ntype ResponsiveProp<AtomType extends Atom> =\n | AtomType\n | Readonly<
|
|
1
|
+
{"version":3,"file":"responsive-props.js","sources":["../../src/new-components/responsive-props.ts"],"sourcesContent":["type ResponsiveBreakpoints = 'mobile' | 'tablet' | 'desktop'\n\ntype Atom = string | number | boolean\n\n/**\n * A responsive prop supports receiving values of its given base type, or an object mapping a\n * responsive breakpoint name to a value from the prop's base type.\n *\n * Some examples:\n *\n * - `align={{ mobile: 'left', tablet: 'center', desktop: 'right' }}`\n */\ntype ResponsiveProp<AtomType extends Atom> =\n | AtomType\n | Readonly<{ [key in ResponsiveBreakpoints]?: AtomType }>\n\nconst DEBUG = process.env.NODE_ENV === 'development'\n\n/**\n * Builds a css module class name for a given prop + prop-value combination.\n *\n * We have a convention of building the internal utility-based class names system in a way that\n * resembles the prop for which it is used and the value of the prop. For instance, in a component\n * with a prop `width` with possible values `narrow` and `wide`, we encode the styles for each of\n * these alternatives in the class-names `.width-narrow` and `.width-wide`.\n *\n * Furthermore, this helper is aware of responsive prop values. For instance, if you provide the\n * `width` prop above with the value `['narrow', 'wide']` this returns `['narrow', 'tablet-wide']`.\n * That is, it returns an array of class names, following the same convention above, but also\n * prefixing by the viewport width variant (`tablet-` or `desktop-`).\n *\n * @param styles the class names mapping imported from a css module\n * @param property the prop name\n * @param value the given prop's value\n */\nfunction getClassNames(\n styles: Record<string, string>,\n property: string,\n value: ResponsiveProp<string> | null | undefined,\n): string[] | null {\n if (!value) {\n return null\n }\n\n const classList: string[] = []\n\n if (typeof value === 'string') {\n classList.push(styles[`${property}-${value}`])\n } else {\n if (value.mobile) classList.push(styles[`${property}-${value.mobile}`])\n if (value.tablet) classList.push(styles[`tablet-${property}-${value.tablet}`])\n if (value.desktop) classList.push(styles[`desktop-${property}-${value.desktop}`])\n }\n\n if (DEBUG && !classList.every(Boolean)) {\n // eslint-disable-next-line no-console\n console.warn('Not all generated class names were found', { property, value, classList })\n }\n\n return classList\n}\n\n/**\n * A mapping over a responsive prop value.\n *\n * Since response values can be an object but also a scalar value, this helper makes it easier to\n * to map the values when it's an object but keeps it consistent for the case when it is a scalar\n * value as well.\n *\n * @param fromValue the responsive prop value\n * @param mapper the mapping function\n */\nfunction mapResponsiveProp<From extends Atom, To extends Atom>(\n fromValue: ResponsiveProp<From> | undefined,\n mapper: (from: From) => To,\n): ResponsiveProp<To> | undefined {\n if (!fromValue) {\n return undefined\n }\n\n if (typeof fromValue !== 'object') {\n return mapper(fromValue)\n }\n\n return {\n mobile: fromValue.mobile ? mapper(fromValue.mobile) : undefined,\n tablet: fromValue.tablet ? mapper(fromValue.tablet) : undefined,\n desktop: fromValue.desktop ? mapper(fromValue.desktop) : undefined,\n }\n}\n\nexport type { ResponsiveProp, ResponsiveBreakpoints }\nexport { getClassNames, mapResponsiveProp }\n"],"names":["DEBUG","process","env","NODE_ENV","getClassNames","styles","property","value","classList","push","mobile","tablet","desktop","every","Boolean","console","warn","mapResponsiveProp","fromValue","mapper","undefined"],"mappings":"AAgBA,IAAMA,KAAK,GAAGC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAAvC;AAEA;;;;;;;;;;;;;;;;;;AAiBA,SAASC,aAAT,CACIC,MADJ,EAEIC,QAFJ,EAGIC,KAHJ;AAKI,MAAI,CAACA,KAAL,EAAY;AACR,WAAO,IAAP;AACH;;AAED,MAAMC,SAAS,GAAa,EAA5B;;AAEA,MAAI,OAAOD,KAAP,KAAiB,QAArB,EAA+B;AAC3BC,IAAAA,SAAS,CAACC,IAAV,CAAeJ,MAAM,CAAIC,QAAJ,SAAgBC,KAAhB,CAArB;AACH,GAFD,MAEO;AACH,QAAIA,KAAK,CAACG,MAAV,EAAkBF,SAAS,CAACC,IAAV,CAAeJ,MAAM,CAAIC,QAAJ,SAAgBC,KAAK,CAACG,MAAtB,CAArB;AAClB,QAAIH,KAAK,CAACI,MAAV,EAAkBH,SAAS,CAACC,IAAV,CAAeJ,MAAM,aAAWC,QAAX,SAAuBC,KAAK,CAACI,MAA7B,CAArB;AAClB,QAAIJ,KAAK,CAACK,OAAV,EAAmBJ,SAAS,CAACC,IAAV,CAAeJ,MAAM,cAAYC,QAAZ,SAAwBC,KAAK,CAACK,OAA9B,CAArB;AACtB;;AAED,MAAIZ,KAAK,IAAI,CAACQ,SAAS,CAACK,KAAV,CAAgBC,OAAhB,CAAd,EAAwC;AACpC;AACAC,IAAAA,OAAO,CAACC,IAAR,CAAa,0CAAb,EAAyD;AAAEV,MAAAA,QAAQ,EAARA,QAAF;AAAYC,MAAAA,KAAK,EAALA,KAAZ;AAAmBC,MAAAA,SAAS,EAATA;AAAnB,KAAzD;AACH;;AAED,SAAOA,SAAP;AACH;AAED;;;;;;;;;;;;AAUA,SAASS,iBAAT,CACIC,SADJ,EAEIC,MAFJ;AAII,MAAI,CAACD,SAAL,EAAgB;AACZ,WAAOE,SAAP;AACH;;AAED,MAAI,OAAOF,SAAP,KAAqB,QAAzB,EAAmC;AAC/B,WAAOC,MAAM,CAACD,SAAD,CAAb;AACH;;AAED,SAAO;AACHR,IAAAA,MAAM,EAAEQ,SAAS,CAACR,MAAV,GAAmBS,MAAM,CAACD,SAAS,CAACR,MAAX,CAAzB,GAA8CU,SADnD;AAEHT,IAAAA,MAAM,EAAEO,SAAS,CAACP,MAAV,GAAmBQ,MAAM,CAACD,SAAS,CAACP,MAAX,CAAzB,GAA8CS,SAFnD;AAGHR,IAAAA,OAAO,EAAEM,SAAS,CAACN,OAAV,GAAoBO,MAAM,CAACD,SAAS,CAACN,OAAX,CAA1B,GAAgDQ;AAHtD,GAAP;AAKH;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import styles from './spinner.module.css.js';
|
|
3
|
+
|
|
4
|
+
function Spinner(_ref) {
|
|
5
|
+
var _ref$size = _ref.size,
|
|
6
|
+
size = _ref$size === void 0 ? 24 : _ref$size;
|
|
7
|
+
return /*#__PURE__*/createElement("svg", {
|
|
8
|
+
"aria-hidden": true,
|
|
9
|
+
width: size,
|
|
10
|
+
height: size,
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
className: styles.svg
|
|
13
|
+
}, /*#__PURE__*/createElement("g", {
|
|
14
|
+
fill: "none",
|
|
15
|
+
fillRule: "nonzero"
|
|
16
|
+
}, /*#__PURE__*/createElement("path", {
|
|
17
|
+
className: styles.tint,
|
|
18
|
+
d: "M17.945 3.958A9.955 9.955 0 0 0 12 2c-2.19 0-4.217.705-5.865 1.9L5.131 2.16A11.945 11.945 0 0 1 12 0c2.59 0 4.99.82 6.95 2.217l-1.005 1.741z"
|
|
19
|
+
}), /*#__PURE__*/createElement("path", {
|
|
20
|
+
className: styles.fill,
|
|
21
|
+
d: "M5.13 2.16L6.136 3.9A9.987 9.987 0 0 0 2 12c0 5.523 4.477 10 10 10s10-4.477 10-10a9.986 9.986 0 0 0-4.055-8.042l1.006-1.741A11.985 11.985 0 0 1 24 12c0 6.627-5.373 12-12 12S0 18.627 0 12c0-4.073 2.029-7.671 5.13-9.84z"
|
|
22
|
+
})));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { Spinner };
|
|
26
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.js","sources":["../../../src/new-components/spinner/spinner.tsx"],"sourcesContent":["import * as React from 'react'\nimport styles from './spinner.module.css'\n\nfunction Spinner({ size = 24 }: { size?: number }) {\n return (\n <svg aria-hidden width={size} height={size} viewBox=\"0 0 24 24\" className={styles.svg}>\n <g fill=\"none\" fillRule=\"nonzero\">\n <path\n className={styles.tint}\n d=\"M17.945 3.958A9.955 9.955 0 0 0 12 2c-2.19 0-4.217.705-5.865 1.9L5.131 2.16A11.945 11.945 0 0 1 12 0c2.59 0 4.99.82 6.95 2.217l-1.005 1.741z\"\n />\n <path\n className={styles.fill}\n d=\"M5.13 2.16L6.136 3.9A9.987 9.987 0 0 0 2 12c0 5.523 4.477 10 10 10s10-4.477 10-10a9.986 9.986 0 0 0-4.055-8.042l1.006-1.741A11.985 11.985 0 0 1 24 12c0 6.627-5.373 12-12 12S0 18.627 0 12c0-4.073 2.029-7.671 5.13-9.84z\"\n />\n </g>\n </svg>\n )\n}\n\nexport { Spinner }\n"],"names":["Spinner","size","React","width","height","viewBox","className","styles","svg","fill","fillRule","tint","d"],"mappings":";;;AAGA,SAASA,OAAT;uBAAmBC;MAAAA,8BAAO;AACtB,sBACIC,aAAA,MAAA;;AAAiBC,IAAAA,KAAK,EAAEF;AAAMG,IAAAA,MAAM,EAAEH;AAAMI,IAAAA,OAAO,EAAC;AAAYC,IAAAA,SAAS,EAAEC,MAAM,CAACC;GAAlF,eACIN,aAAA,IAAA;AAAGO,IAAAA,IAAI,EAAC;AAAOC,IAAAA,QAAQ,EAAC;GAAxB,eACIR,aAAA,OAAA;AACII,IAAAA,SAAS,EAAEC,MAAM,CAACI;AAClBC,IAAAA,CAAC,EAAC;GAFN,CADJ,eAKIV,aAAA,OAAA;AACII,IAAAA,SAAS,EAAEC,MAAM,CAACE;AAClBG,IAAAA,CAAC,EAAC;GAFN,CALJ,CADJ,CADJ;AAcH;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -11,28 +11,28 @@ var Stack = /*#__PURE__*/polymorphicComponent(function Stack(_ref, ref) {
|
|
|
11
11
|
var as = _ref.as,
|
|
12
12
|
space = _ref.space,
|
|
13
13
|
_ref$align = _ref.align,
|
|
14
|
-
align = _ref$align === void 0 ? '
|
|
14
|
+
align = _ref$align === void 0 ? 'start' : _ref$align,
|
|
15
15
|
_ref$dividers = _ref.dividers,
|
|
16
|
-
dividers = _ref$dividers === void 0 ?
|
|
16
|
+
dividers = _ref$dividers === void 0 ? 'none' : _ref$dividers,
|
|
17
17
|
children = _ref.children,
|
|
18
18
|
exceptionallySetClassName = _ref.exceptionallySetClassName,
|
|
19
19
|
props = _objectWithoutPropertiesLoose(_ref, ["as", "space", "align", "dividers", "children", "exceptionallySetClassName"]);
|
|
20
20
|
|
|
21
|
-
var alignProps = align === '
|
|
21
|
+
var alignProps = align === 'start' ? undefined : {
|
|
22
22
|
width: 'full',
|
|
23
23
|
flexDirection: 'column',
|
|
24
24
|
display: 'flex',
|
|
25
25
|
alignItems: mapResponsiveProp(align, function (align) {
|
|
26
|
-
return align === '
|
|
26
|
+
return align === 'start' ? 'flexStart' : align === 'end' ? 'flexEnd' : 'center';
|
|
27
27
|
})
|
|
28
28
|
};
|
|
29
29
|
return /*#__PURE__*/createElement(Box, Object.assign({}, props, alignProps, {
|
|
30
30
|
as: as,
|
|
31
31
|
className: [exceptionallySetClassName, getClassNames(styles, 'space', space)],
|
|
32
32
|
ref: ref
|
|
33
|
-
}), dividers ? Children.map(flattenChildren(children), function (child, index) {
|
|
33
|
+
}), dividers !== 'none' ? Children.map(flattenChildren(children), function (child, index) {
|
|
34
34
|
return index > 0 ? /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement(Divider, {
|
|
35
|
-
weight:
|
|
35
|
+
weight: dividers
|
|
36
36
|
}), child) : child;
|
|
37
37
|
}) : children);
|
|
38
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.js","sources":["../../../src/new-components/stack/stack.tsx"],"sourcesContent":["import * as React from 'react'\nimport flattenChildren from 'react-keyed-flatten-children'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport { getClassNames, mapResponsiveProp } from '../responsive-props'\nimport { Box } from '../box'\nimport { Divider } from '../divider'\n\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { Space } from '../common-types'\nimport type { BoxProps, ReusableBoxProps } from '../box'\
|
|
1
|
+
{"version":3,"file":"stack.js","sources":["../../../src/new-components/stack/stack.tsx"],"sourcesContent":["import * as React from 'react'\nimport flattenChildren from 'react-keyed-flatten-children'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport { getClassNames, mapResponsiveProp } from '../responsive-props'\nimport { Box } from '../box'\nimport { Divider } from '../divider'\n\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { DividerWeight, Space } from '../common-types'\nimport type { BoxProps, ReusableBoxProps } from '../box'\n\nimport styles from './stack.module.css'\n\ntype Align = 'start' | 'center' | 'end'\n\ninterface StackProps extends ReusableBoxProps {\n /** Space between items */\n space?: ResponsiveProp<Space>\n /** Align items horizontally */\n align?: ResponsiveProp<Align>\n /** The weight of the dividers to add. Defaults to 'none', which means no dividers are added */\n dividers?: DividerWeight\n}\n\nconst Stack = polymorphicComponent<'div', StackProps>(function Stack(\n {\n as,\n space,\n align = 'start',\n dividers = 'none',\n children,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const alignProps: BoxProps | undefined =\n align === 'start'\n ? undefined\n : {\n width: 'full',\n flexDirection: 'column',\n display: 'flex',\n alignItems: mapResponsiveProp(align, (align) =>\n align === 'start' ? 'flexStart' : align === 'end' ? 'flexEnd' : 'center',\n ),\n }\n\n return (\n <Box\n {...props}\n {...alignProps}\n as={as}\n className={[exceptionallySetClassName, getClassNames(styles, 'space', space)]}\n ref={ref}\n >\n {dividers !== 'none'\n ? React.Children.map(flattenChildren(children), (child, index) =>\n index > 0 ? (\n <>\n <Divider weight={dividers} />\n {child}\n </>\n ) : (\n child\n ),\n )\n : children}\n </Box>\n )\n})\n\nexport type { StackProps }\nexport { Stack }\n"],"names":["Stack","polymorphicComponent","ref","as","space","align","dividers","children","exceptionallySetClassName","props","alignProps","undefined","width","flexDirection","display","alignItems","mapResponsiveProp","React","Box","className","getClassNames","styles","map","flattenChildren","child","index","Divider","weight"],"mappings":";;;;;;;;;IAwBMA,KAAK,gBAAGC,oBAAoB,CAAoB,SAASD,KAAT,OAUlDE,GAVkD;MAE9CC,UAAAA;MACAC,aAAAA;wBACAC;MAAAA,gCAAQ;2BACRC;MAAAA,sCAAW;MACXC,gBAAAA;MACAC,iCAAAA;MACGC;;AAIP,MAAMC,UAAU,GACZL,KAAK,KAAK,OAAV,GACMM,SADN,GAEM;AACIC,IAAAA,KAAK,EAAE,MADX;AAEIC,IAAAA,aAAa,EAAE,QAFnB;AAGIC,IAAAA,OAAO,EAAE,MAHb;AAIIC,IAAAA,UAAU,EAAEC,iBAAiB,CAACX,KAAD,EAAQ,UAACA,KAAD;AAAA,aACjCA,KAAK,KAAK,OAAV,GAAoB,WAApB,GAAkCA,KAAK,KAAK,KAAV,GAAkB,SAAlB,GAA8B,QAD/B;AAAA,KAAR;AAJjC,GAHV;AAYA,sBACIY,aAAA,CAACC,GAAD,oBACQT,OACAC;AACJP,IAAAA,EAAE,EAAEA;AACJgB,IAAAA,SAAS,EAAE,CAACX,yBAAD,EAA4BY,aAAa,CAACC,MAAD,EAAS,OAAT,EAAkBjB,KAAlB,CAAzC;AACXF,IAAAA,GAAG,EAAEA;IALT,EAOKI,QAAQ,KAAK,MAAb,GACKW,QAAA,CAAeK,GAAf,CAAmBC,eAAe,CAAChB,QAAD,CAAlC,EAA8C,UAACiB,KAAD,EAAQC,KAAR;AAAA,WAC1CA,KAAK,GAAG,CAAR,gBACIR,aAAA,SAAA,MAAA,eACIA,aAAA,CAACS,OAAD;AAASC,MAAAA,MAAM,EAAErB;KAAjB,CADJ,EAEKkB,KAFL,CADJ,GAMIA,KAPsC;AAAA,GAA9C,CADL,GAWKjB,QAlBV,CADJ;AAsBH,CA9CiC;;;;"}
|
|
@@ -3,6 +3,7 @@ import { forwardRef, useState, createElement } from 'react';
|
|
|
3
3
|
import { Box } from '../box/box.js';
|
|
4
4
|
import { Stack } from '../stack/stack.js';
|
|
5
5
|
import { HiddenVisually } from '../hidden-visually/hidden-visually.js';
|
|
6
|
+
import { Text } from '../text/text.js';
|
|
6
7
|
import { useId } from '../common-helpers.js';
|
|
7
8
|
import { FieldHint } from '../base-field/base-field.js';
|
|
8
9
|
import styles from './switch-field.module.css.js';
|
|
@@ -61,8 +62,8 @@ var SwitchField = /*#__PURE__*/forwardRef(function SwitchField(_ref, ref) {
|
|
|
61
62
|
}
|
|
62
63
|
}))), /*#__PURE__*/createElement("span", {
|
|
63
64
|
className: styles.handle
|
|
64
|
-
})), /*#__PURE__*/createElement(
|
|
65
|
-
|
|
65
|
+
})), /*#__PURE__*/createElement(Text, {
|
|
66
|
+
exceptionallySetClassName: styles.label
|
|
66
67
|
}, label)), hint ? /*#__PURE__*/createElement(FieldHint, {
|
|
67
68
|
id: hintId
|
|
68
69
|
}, hint) : null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-field.js","sources":["../../../src/new-components/switch-field/switch-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { HiddenVisually } from '../hidden-visually'\nimport { FieldComponentProps, FieldHint } from '../base-field'\nimport { useId } from '../common-helpers'\nimport styles from './switch-field.module.css'\n\ntype SwitchFieldProps = Omit<\n FieldComponentProps<HTMLInputElement>,\n 'type' | 'secondaryLabel' | 'auxiliaryLabel' | 'maxWidth'\n>\n\nconst SwitchField = React.forwardRef<HTMLInputElement, SwitchFieldProps>(function SwitchField(\n {\n label,\n hint,\n disabled = false,\n hidden,\n defaultChecked,\n id: originalId,\n 'aria-describedby': originalAriaDescribedBy,\n onChange,\n ...props\n },\n ref,\n) {\n const id = useId(originalId)\n const hintId = useId()\n const ariaDescribedBy = originalAriaDescribedBy ?? (hint ? hintId : undefined)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n return (\n <Stack space=\"small\" hidden={hidden}>\n <Box\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n ]}\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n >\n <Box\n position=\"relative\"\n display=\"inlineBlock\"\n overflow=\"visible\"\n marginRight=\"small\"\n flexShrink={0}\n className={styles.toggle}\n >\n <HiddenVisually>\n <input\n {...props}\n id={id}\n type=\"checkbox\"\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n ref={ref}\n checked={isChecked}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n />\n </HiddenVisually>\n <span className={styles.handle} />\n </Box>\n <
|
|
1
|
+
{"version":3,"file":"switch-field.js","sources":["../../../src/new-components/switch-field/switch-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\nimport { HiddenVisually } from '../hidden-visually'\nimport { FieldComponentProps, FieldHint } from '../base-field'\nimport { useId } from '../common-helpers'\nimport styles from './switch-field.module.css'\n\ntype SwitchFieldProps = Omit<\n FieldComponentProps<HTMLInputElement>,\n 'type' | 'secondaryLabel' | 'auxiliaryLabel' | 'maxWidth'\n>\n\nconst SwitchField = React.forwardRef<HTMLInputElement, SwitchFieldProps>(function SwitchField(\n {\n label,\n hint,\n disabled = false,\n hidden,\n defaultChecked,\n id: originalId,\n 'aria-describedby': originalAriaDescribedBy,\n onChange,\n ...props\n },\n ref,\n) {\n const id = useId(originalId)\n const hintId = useId()\n const ariaDescribedBy = originalAriaDescribedBy ?? (hint ? hintId : undefined)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n return (\n <Stack space=\"small\" hidden={hidden}>\n <Box\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n ]}\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n >\n <Box\n position=\"relative\"\n display=\"inlineBlock\"\n overflow=\"visible\"\n marginRight=\"small\"\n flexShrink={0}\n className={styles.toggle}\n >\n <HiddenVisually>\n <input\n {...props}\n id={id}\n type=\"checkbox\"\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n ref={ref}\n checked={isChecked}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n />\n </HiddenVisually>\n <span className={styles.handle} />\n </Box>\n <Text exceptionallySetClassName={styles.label}>{label}</Text>\n </Box>\n {hint ? <FieldHint id={hintId}>{hint}</FieldHint> : null}\n </Stack>\n )\n})\n\nexport { SwitchField }\nexport type { SwitchFieldProps }\n"],"names":["SwitchField","React","ref","label","hint","disabled","hidden","defaultChecked","originalId","id","originalAriaDescribedBy","onChange","props","useId","hintId","ariaDescribedBy","undefined","checked","checkedState","setChecked","isChecked","Stack","space","Box","className","styles","container","as","display","alignItems","position","overflow","marginRight","flexShrink","toggle","HiddenVisually","type","event","defaultPrevented","currentTarget","handle","Text","exceptionallySetClassName","FieldHint"],"mappings":";;;;;;;;;;IAcMA,WAAW,gBAAGC,UAAA,CAAqD,SAASD,WAAT,OAYrEE,GAZqE;;;MAEjEC,aAAAA;MACAC,YAAAA;2BACAC;MAAAA,sCAAW;MACXC,cAAAA;MACAC,sBAAAA;MACIC,kBAAJC;MACoBC,+BAApB;MACAC,iBAAAA;MACGC;;AAIP,MAAMH,EAAE,GAAGI,KAAK,CAACL,UAAD,CAAhB;AACA,MAAMM,MAAM,GAAGD,KAAK,EAApB;AACA,MAAME,eAAe,GAAGL,uBAAH,aAAGA,uBAAH,cAAGA,uBAAH,GAA+BN,IAAI,GAAGU,MAAH,GAAYE,SAApE;;wBACmCf,QAAA,4BAAeW,KAAK,CAACK,OAArB,2DAAgCV,cAAhC,yCAAkD,KAAlD;MAA5BW;MAAcC;;AACrB,MAAMC,SAAS,sBAAGR,KAAK,CAACK,OAAT,6DAAoBC,YAAnC;AACA,sBACIjB,aAAA,CAACoB,KAAD;AAAOC,IAAAA,KAAK,EAAC;AAAQhB,IAAAA,MAAM,EAAEA;GAA7B,eACIL,aAAA,CAACsB,GAAD;AACIC,IAAAA,SAAS,EAAE,CACPC,MAAM,CAACC,SADA,EAEPrB,QAAQ,GAAGoB,MAAM,CAACpB,QAAV,GAAqB,IAFtB,EAGP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"container":"_99a80509","disabled":"b5cf26ef","checked":"a63c43a2","toggle":"f318ae83","label":"_427926b9","handle":"_9fcd994c"};
|
|
2
2
|
|
|
3
3
|
export default modules_8e05f7c9;
|
|
4
4
|
//# sourceMappingURL=switch-field.module.css.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { objectSpread2 as _objectSpread2, objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { useEffect, useMemo, createElement, useContext, useState, createContext } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
+
import { polymorphicComponent } from '../../utils/polymorphism.js';
|
|
4
5
|
import { Inline } from '../inline/inline.js';
|
|
5
6
|
import { useTabState, Tab as Tab$1, TabList as TabList$1, TabPanel as TabPanel$1 } from 'reakit/Tab';
|
|
6
7
|
import { usePrevious } from '../../hooks/use-previous/use-previous.js';
|
|
@@ -46,7 +47,6 @@ function Tabs(_ref) {
|
|
|
46
47
|
* Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.
|
|
47
48
|
*/
|
|
48
49
|
|
|
49
|
-
|
|
50
50
|
function Tab(_ref2) {
|
|
51
51
|
var children = _ref2.children,
|
|
52
52
|
id = _ref2.id;
|
|
@@ -69,7 +69,6 @@ function Tab(_ref2) {
|
|
|
69
69
|
* A component used to group `<Tab>` elements together.
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
|
-
|
|
73
72
|
function TabList(_ref3) {
|
|
74
73
|
var children = _ref3.children,
|
|
75
74
|
_ref3$space = _ref3.space,
|
|
@@ -92,12 +91,14 @@ function TabList(_ref3) {
|
|
|
92
91
|
* Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.
|
|
93
92
|
*/
|
|
94
93
|
|
|
95
|
-
|
|
96
|
-
function TabPanel(_ref4) {
|
|
94
|
+
var TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
|
|
97
95
|
var children = _ref4.children,
|
|
98
96
|
id = _ref4.id,
|
|
97
|
+
as = _ref4.as,
|
|
99
98
|
_ref4$render = _ref4.render,
|
|
100
|
-
render = _ref4$render === void 0 ? 'always' : _ref4$render
|
|
99
|
+
render = _ref4$render === void 0 ? 'always' : _ref4$render,
|
|
100
|
+
props = _objectWithoutPropertiesLoose(_ref4, ["children", "id", "as", "render"]);
|
|
101
|
+
|
|
101
102
|
var tabContextValue = useContext(TabsContext);
|
|
102
103
|
|
|
103
104
|
var _React$useState = useState(false),
|
|
@@ -119,14 +120,16 @@ function TabPanel(_ref4) {
|
|
|
119
120
|
|
|
120
121
|
return /*#__PURE__*/createElement(TabPanel$1, Object.assign({
|
|
121
122
|
tabId: id
|
|
122
|
-
}, tabState
|
|
123
|
-
|
|
123
|
+
}, tabState, props, {
|
|
124
|
+
as: as,
|
|
125
|
+
ref: ref
|
|
126
|
+
}), render === 'always' ? children : null, render === 'active' && tabIsActive ? children : null, render === 'lazy' && (tabIsActive || tabRendered) ? children : null);
|
|
127
|
+
});
|
|
124
128
|
/**
|
|
125
129
|
* Allows content to be rendered based on the current tab being selected while outside of the TabPanel
|
|
126
130
|
* component. Can be placed freely within the main `<Tabs>` component.
|
|
127
131
|
*/
|
|
128
132
|
|
|
129
|
-
|
|
130
133
|
function TabAwareSlot(_ref5) {
|
|
131
134
|
var children = _ref5.children;
|
|
132
135
|
var tabContextValue = useContext(TabsContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sources":["../../../src/new-components/tabs/tabs.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport {\n useTabState,\n Tab as BaseTab,\n TabList as BaseTabList,\n TabPanel as BaseTabPanel,\n TabStateReturn,\n} from 'reakit/Tab'\nimport { Inline } from '../inline'\nimport { usePrevious } from '../../hooks/use-previous'\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { Space } from '../common-types'\n\nimport styles from './tabs.module.css'\n\nconst TabsContext = React.createContext<\n (TabStateReturn & Omit<TabsProps, 'children' | 'selectedId'>) | null\n>(null)\n\ntype TabsProps = {\n /** The `<Tabs>` component must be composed from a `<TabList>` and corresponding `<TabPanel>` components */\n children: React.ReactNode\n /**\n * Determines the primary colour of the tabs\n */\n color?: 'primary' | 'secondary' | 'tertiary'\n /**\n * Determines the style of the tabs\n */\n variant?: 'normal' | 'plain'\n /**\n * The id of the selected tab\n */\n selectedId?: string | null\n}\n\n/**\n * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.\n */\nfunction Tabs({\n children,\n selectedId,\n color = 'primary',\n variant = 'normal',\n}: TabsProps): React.ReactElement {\n const tabState = useTabState({ selectedId })\n const previousSelectedId = usePrevious(selectedId)\n const { selectedId: actualSelectedId, select } = tabState\n\n React.useEffect(\n function selectTab() {\n if (\n previousSelectedId !== selectedId &&\n selectedId !== actualSelectedId &&\n selectedId !== undefined\n ) {\n select(selectedId)\n }\n },\n [selectedId, actualSelectedId, select, previousSelectedId],\n )\n\n const memoizedTabState = React.useMemo(\n function memoizeTabState() {\n return {\n ...tabState,\n color,\n variant,\n }\n },\n // There is no guarantee that useTabState returns a stable object when there are no changes, so\n // following reakit/Tab's example we only return a new objet when any of its values have changed\n // eslint-disable-next-line\n [color, variant, ...Object.values(tabState)],\n )\n\n return <TabsContext.Provider value={memoizedTabState}>{children}</TabsContext.Provider>\n}\n\ntype TabProps = {\n /** The content to render inside of the tab button */\n children: React.ReactNode\n\n /** The tab's identifier. This must match its corresponding `<TabPanel>`'s id */\n id: string\n}\n\n/**\n * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.\n */\nfunction Tab({ children, id }: TabProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTab\n className={classNames(\n styles.tab,\n styles[`tab-${variant ?? ''}`],\n styles[`tab-${color ?? ''}`],\n )}\n id={id}\n {...tabState}\n >\n {children}\n </BaseTab>\n )\n}\n\ntype TabListProps = (\n | {\n /** Labels the tab list for assistive technologies. This must be provided if `aria-labelledby` is omitted. */\n 'aria-label': string\n }\n | {\n /**\n * One or more element IDs used to label the tab list for assistive technologies. Required if\n * `aria-label` is omitted.\n */\n 'aria-labelledby': string\n }\n | {\n /**\n * For cases where multiple instances of the tab list exists, the duplicates may be marked as aria-hidden\n */\n 'aria-hidden': boolean\n }\n) & {\n /**\n * A list of `<Tab>` elements\n */\n children: React.ReactNode\n\n /**\n * Controls the spacing between tabs\n */\n space?: ResponsiveProp<Space>\n}\n\n/**\n * A component used to group `<Tab>` elements together.\n */\nfunction TabList({\n children,\n space = 'medium',\n ...props\n}: TabListProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabList {...props} {...tabState}>\n <Inline space={space}>{children}</Inline>\n </BaseTabList>\n )\n}\n\ntype TabPanelProps = {\n /** The content to be rendered inside the tab */\n children: React.ReactNode\n\n /** The tabPanel's identifier. This must match its corresponding `<Tab>`'s id */\n id: string\n\n /**\n * By default, the tab panel's content is always rendered even when they are not active. This behaviour can be changed to\n * 'active', which renders only when the tab is active, and 'lazy', meaning while inactive tab panels will not be rendered\n * initially, they will remain mounted once they are active until the entire Tabs tree is unmounted.\n */\n render?: 'always' | 'active' | 'lazy'\n}\n\n/**\n * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.\n */\nfunction TabPanel({ children, id, render = 'always' }: TabPanelProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n const [tabRendered, setTabRendered] = React.useState(false)\n const tabIsActive = tabContextValue?.selectedId === id\n\n React.useEffect(\n function trackTabRenderedState() {\n if (!tabRendered && tabIsActive) {\n setTabRendered(true)\n }\n },\n [tabRendered, tabIsActive],\n )\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabPanel tabId={id} {...tabState}>\n {render === 'always' ? children : null}\n {render === 'active' && tabIsActive ? children : null}\n {render === 'lazy' && (tabIsActive || tabRendered) ? children : null}\n </BaseTabPanel>\n )\n}\n\ntype TabAwareSlotProps = {\n /**\n * Render prop used to provide the content to be rendered inside the slot. The render prop will be\n * called with the current `selectedId`\n */\n children: (provided: { selectedId?: string | null }) => React.ReactElement | null\n}\n\n/**\n * Allows content to be rendered based on the current tab being selected while outside of the TabPanel\n * component. Can be placed freely within the main `<Tabs>` component.\n */\nfunction TabAwareSlot({ children }: TabAwareSlotProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n return tabContextValue ? children({ selectedId: tabContextValue.selectedId }) : null\n}\n\nexport { Tabs, TabList, Tab, TabPanel, TabAwareSlot }\n"],"names":["TabsContext","React","Tabs","children","selectedId","color","variant","tabState","useTabState","previousSelectedId","usePrevious","actualSelectedId","select","selectTab","undefined","memoizedTabState","memoizeTabState","Object","values","Provider","value","Tab","id","tabContextValue","BaseTab","className","classNames","styles","tab","TabList","space","props","BaseTabList","Inline","TabPanel","render","tabRendered","setTabRendered","tabIsActive","trackTabRenderedState","BaseTabPanel","tabId","TabAwareSlot"],"mappings":";;;;;;;;AAgBA,IAAMA,WAAW,gBAAGC,aAAA,CAElB,IAFkB,CAApB;AAqBA;;;;AAGA,SAASC,IAAT;MACIC,gBAAAA;MACAC,kBAAAA;wBACAC;MAAAA,gCAAQ;0BACRC;MAAAA,oCAAU;AAEV,MAAMC,QAAQ,GAAGC,WAAW,CAAC;AAAEJ,IAAAA,UAAU,EAAVA;AAAF,GAAD,CAA5B;AACA,MAAMK,kBAAkB,GAAGC,WAAW,CAACN,UAAD,CAAtC;MACoBO,mBAA6BJ,SAAzCH;MAA8BQ,SAAWL,SAAXK;AAEtCX,EAAAA,SAAA,CACI,SAASY,SAAT;AACI,QACIJ,kBAAkB,KAAKL,UAAvB,I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AAAEC,IAAAA,UAAU,EAAEmB,eAAe,CAACnB;AAA9B,GAAD,CAAX,GAA0D,IAAhF;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"tabs.js","sources":["../../../src/new-components/tabs/tabs.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport {\n useTabState,\n Tab as BaseTab,\n TabList as BaseTabList,\n TabPanel as BaseTabPanel,\n TabStateReturn,\n} from 'reakit/Tab'\nimport { Inline } from '../inline'\nimport { usePrevious } from '../../hooks/use-previous'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { Space } from '../common-types'\n\nimport styles from './tabs.module.css'\n\nconst TabsContext = React.createContext<\n (TabStateReturn & Omit<TabsProps, 'children' | 'selectedId'>) | null\n>(null)\n\ntype TabsProps = {\n /** The `<Tabs>` component must be composed from a `<TabList>` and corresponding `<TabPanel>` components */\n children: React.ReactNode\n /**\n * Determines the primary colour of the tabs\n */\n color?: 'primary' | 'secondary' | 'tertiary'\n /**\n * Determines the style of the tabs\n */\n variant?: 'normal' | 'plain'\n /**\n * The id of the selected tab\n */\n selectedId?: string | null\n}\n\n/**\n * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.\n */\nexport function Tabs({\n children,\n selectedId,\n color = 'primary',\n variant = 'normal',\n}: TabsProps): React.ReactElement {\n const tabState = useTabState({ selectedId })\n const previousSelectedId = usePrevious(selectedId)\n const { selectedId: actualSelectedId, select } = tabState\n\n React.useEffect(\n function selectTab() {\n if (\n previousSelectedId !== selectedId &&\n selectedId !== actualSelectedId &&\n selectedId !== undefined\n ) {\n select(selectedId)\n }\n },\n [selectedId, actualSelectedId, select, previousSelectedId],\n )\n\n const memoizedTabState = React.useMemo(\n function memoizeTabState() {\n return {\n ...tabState,\n color,\n variant,\n }\n },\n // There is no guarantee that useTabState returns a stable object when there are no changes, so\n // following reakit/Tab's example we only return a new objet when any of its values have changed\n // eslint-disable-next-line\n [color, variant, ...Object.values(tabState)],\n )\n\n return <TabsContext.Provider value={memoizedTabState}>{children}</TabsContext.Provider>\n}\n\ntype TabProps = {\n /** The content to render inside of the tab button */\n children: React.ReactNode\n\n /** The tab's identifier. This must match its corresponding `<TabPanel>`'s id */\n id: string\n}\n\n/**\n * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.\n */\nexport function Tab({ children, id }: TabProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTab\n className={classNames(\n styles.tab,\n styles[`tab-${variant ?? ''}`],\n styles[`tab-${color ?? ''}`],\n )}\n id={id}\n {...tabState}\n >\n {children}\n </BaseTab>\n )\n}\n\ntype TabListProps = (\n | {\n /** Labels the tab list for assistive technologies. This must be provided if `aria-labelledby` is omitted. */\n 'aria-label': string\n }\n | {\n /**\n * One or more element IDs used to label the tab list for assistive technologies. Required if\n * `aria-label` is omitted.\n */\n 'aria-labelledby': string\n }\n | {\n /**\n * For cases where multiple instances of the tab list exists, the duplicates may be marked as aria-hidden\n */\n 'aria-hidden': boolean\n }\n) & {\n /**\n * A list of `<Tab>` elements\n */\n children: React.ReactNode\n\n /**\n * Controls the spacing between tabs\n */\n space?: ResponsiveProp<Space>\n}\n\n/**\n * A component used to group `<Tab>` elements together.\n */\nexport function TabList({\n children,\n space = 'medium',\n ...props\n}: TabListProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabList {...props} {...tabState}>\n <Inline space={space}>{children}</Inline>\n </BaseTabList>\n )\n}\n\ntype TabPanelProps = {\n /** The content to be rendered inside the tab */\n children: React.ReactNode\n\n /** The tabPanel's identifier. This must match its corresponding `<Tab>`'s id */\n id: string\n\n /**\n * By default, the tab panel's content is always rendered even when they are not active. This behaviour can be changed to\n * 'active', which renders only when the tab is active, and 'lazy', meaning while inactive tab panels will not be rendered\n * initially, they will remain mounted once they are active until the entire Tabs tree is unmounted.\n */\n render?: 'always' | 'active' | 'lazy'\n}\n\n/**\n * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.\n */\nexport const TabPanel = polymorphicComponent<'div', TabPanelProps, 'omitClassName'>(\n function TabPanel(\n { children, id, as, render = 'always', ...props },\n ref,\n ): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n const [tabRendered, setTabRendered] = React.useState(false)\n const tabIsActive = tabContextValue?.selectedId === id\n\n React.useEffect(\n function trackTabRenderedState() {\n if (!tabRendered && tabIsActive) {\n setTabRendered(true)\n }\n },\n [tabRendered, tabIsActive],\n )\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabPanel tabId={id} {...tabState} {...props} as={as} ref={ref}>\n {render === 'always' ? children : null}\n {render === 'active' && tabIsActive ? children : null}\n {render === 'lazy' && (tabIsActive || tabRendered) ? children : null}\n </BaseTabPanel>\n )\n },\n)\n\ntype TabAwareSlotProps = {\n /**\n * Render prop used to provide the content to be rendered inside the slot. The render prop will be\n * called with the current `selectedId`\n */\n children: (provided: { selectedId?: string | null }) => React.ReactElement | null\n}\n\n/**\n * Allows content to be rendered based on the current tab being selected while outside of the TabPanel\n * component. Can be placed freely within the main `<Tabs>` component.\n */\nexport function TabAwareSlot({ children }: TabAwareSlotProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n return tabContextValue ? children({ selectedId: tabContextValue.selectedId }) : null\n}\n"],"names":["TabsContext","React","Tabs","children","selectedId","color","variant","tabState","useTabState","previousSelectedId","usePrevious","actualSelectedId","select","selectTab","undefined","memoizedTabState","memoizeTabState","Object","values","Provider","value","Tab","id","tabContextValue","BaseTab","className","classNames","styles","tab","TabList","space","props","BaseTabList","Inline","TabPanel","polymorphicComponent","ref","as","render","tabRendered","setTabRendered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