@carbon/react 1.8.0-rc.0 → 1.9.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/es/components/ComposedModal/next/ComposedModal.js +1 -1
- package/es/components/Menu/Menu.js +1 -1
- package/es/components/Modal/Modal.js +204 -273
- package/es/components/Modal/index.js +2 -8
- package/es/components/ModalWrapper/ModalWrapper.js +1 -1
- package/es/components/NumberInput/NumberInput.Skeleton.js +3 -4
- package/es/components/NumberInput/NumberInput.js +308 -359
- package/es/index.js +3 -3
- package/lib/components/ComposedModal/next/ComposedModal.js +1 -1
- package/lib/components/Menu/Menu.js +1 -1
- package/lib/components/Modal/Modal.js +201 -270
- package/lib/components/Modal/index.js +2 -25
- package/lib/components/ModalWrapper/ModalWrapper.js +2 -2
- package/lib/components/NumberInput/NumberInput.Skeleton.js +3 -4
- package/lib/components/NumberInput/NumberInput.js +305 -376
- package/lib/index.js +80 -80
- package/package.json +6 -6
- package/scss/utilities/_hide-at-breakpoint.scss +9 -0
- package/es/components/Modal/next/Modal.js +0 -274
- package/es/internal/FeatureFlags.js +0 -52
- package/es/prop-types/requiredIfValueExists.js +0 -32
- package/lib/components/Modal/next/Modal.js +0 -284
- package/lib/internal/FeatureFlags.js +0 -56
- package/lib/prop-types/requiredIfValueExists.js +0 -36
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { enabled } from '@carbon/feature-flags';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* This file contains the list of the default values of compile-time feature flags.
|
|
12
|
-
*
|
|
13
|
-
* Build toolchain can replace variable here and/or the references
|
|
14
|
-
* in order to apply non-default values to those feature flags.
|
|
15
|
-
*
|
|
16
|
-
* @example Render `foo` if `aFeatureFlag` is `true`, render `bar` otherwise.
|
|
17
|
-
* import { aFeatureFlag } from '/path/to/FeatureFlags';
|
|
18
|
-
* ...
|
|
19
|
-
* const MyComponent = props => (<div {...props}>{aFeatureFlag ? 'foo' : 'bar'}</div>);
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* With this flag, certain components will be created in either a controlled or controlled
|
|
24
|
-
* mode based on the existence of a value prop.
|
|
25
|
-
*
|
|
26
|
-
* The following components will have the significance of their props slightly altered as outlined below.
|
|
27
|
-
*
|
|
28
|
-
* Components: `<NumberInput>`
|
|
29
|
-
*
|
|
30
|
-
* * `value` → when provided, enables controlled mode.
|
|
31
|
-
* For the rest of the component's lifecycle, it will be controlled by this prop as it's single source of truth.
|
|
32
|
-
* * `defaultValue` → Optional starting value, used for for uncontrolled mode only (no value prop).
|
|
33
|
-
* The value prop takes precedence over defaultValue.
|
|
34
|
-
* * `onChange` → Optional event handler.
|
|
35
|
-
* However, if value is provided and a handler is not, we'll throw a warning indicating the component is now read-only
|
|
36
|
-
* * `readOnly` → silences the above warning, acknowledging the read-only state of the component
|
|
37
|
-
*
|
|
38
|
-
* This flag also disables prop -> state sync in several components, notably `<NumberInput>`.
|
|
39
|
-
*
|
|
40
|
-
* This flag also updates event handlers to pass an up-to-date value in the second parameter,
|
|
41
|
-
* so applications can use it in both controlled and uncontrolled components.
|
|
42
|
-
*
|
|
43
|
-
* * _With_ this feature flag, the signature of the event handler will be altered to provide additional context in the second parameter: `onChange(event, { value, ...rest })` where:
|
|
44
|
-
* * `event` is the (React) raw event
|
|
45
|
-
* * `value` is the new value
|
|
46
|
-
* * `rest` tells you additional information based on the source component
|
|
47
|
-
* * _Without_ this feature flag the event handler has component-specific signature, e.g. `onChange(event, direction)`.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
var useControlledStateWithValue = enabled('enable-use-controlled-state-with-value');
|
|
51
|
-
|
|
52
|
-
export { useControlledStateWithValue };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @param {Function} propType The original prop type checker.
|
|
10
|
-
* @returns {Function} The new prop type checker for `onChange` that makes it required if `value` exists and `readOnly` does not exist.
|
|
11
|
-
*/
|
|
12
|
-
function requiredIfValueExists(propType) {
|
|
13
|
-
return function check(props, propName, componentName) {
|
|
14
|
-
var onChange = props[propName],
|
|
15
|
-
value = props.value,
|
|
16
|
-
readOnly = props.readOnly;
|
|
17
|
-
var exists = onChange !== undefined;
|
|
18
|
-
var valueExists = value !== undefined;
|
|
19
|
-
|
|
20
|
-
if (process.env.NODE_ENV !== "production" && !exists && valueExists && !readOnly) {
|
|
21
|
-
return new Error("You provided a value prop to `".concat(componentName, "` without an `onChange` handler. ") + 'This will render a read-only field. ' + 'If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
25
|
-
rest[_key - 3] = arguments[_key];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return propType.apply(void 0, [props, propName, componentName].concat(rest));
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { requiredIfValueExists as default };
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
|
-
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
-
var PropTypes = require('prop-types');
|
|
14
|
-
var React = require('react');
|
|
15
|
-
var cx = require('classnames');
|
|
16
|
-
var iconsReact = require('@carbon/icons-react');
|
|
17
|
-
var toggleClass = require('../../../tools/toggleClass.js');
|
|
18
|
-
var Button = require('../../Button/Button.js');
|
|
19
|
-
var ButtonSet = require('../../ButtonSet/ButtonSet.js');
|
|
20
|
-
var requiredIfGivenPropIsTruthy = require('../../../prop-types/requiredIfGivenPropIsTruthy.js');
|
|
21
|
-
var wrapFocus = require('../../../internal/wrapFocus.js');
|
|
22
|
-
var setupGetInstanceId = require('../../../tools/setupGetInstanceId.js');
|
|
23
|
-
var usePrefix = require('../../../internal/usePrefix.js');
|
|
24
|
-
|
|
25
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
|
-
|
|
27
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
28
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
29
|
-
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
30
|
-
|
|
31
|
-
var _Modal$propTypes;
|
|
32
|
-
|
|
33
|
-
var _excluded = ["children", "className", "modalHeading", "modalLabel", "modalAriaLabel", "passiveModal", "secondaryButtonText", "primaryButtonText", "open", "onRequestClose", "onRequestSubmit", "onSecondarySubmit", "primaryButtonDisabled", "danger", "alert", "secondaryButtons", "selectorPrimaryFocus", "selectorsFloatingMenus", "shouldSubmitOnEnter", "size", "hasScrollingContent", "closeButtonLabel", "preventCloseOnClickOutside"];
|
|
34
|
-
var getInstanceId = setupGetInstanceId["default"]();
|
|
35
|
-
var Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_ref, ref) {
|
|
36
|
-
var _classNames;
|
|
37
|
-
|
|
38
|
-
var children = _ref.children,
|
|
39
|
-
className = _ref.className,
|
|
40
|
-
modalHeading = _ref.modalHeading,
|
|
41
|
-
modalLabel = _ref.modalLabel,
|
|
42
|
-
modalAriaLabel = _ref.modalAriaLabel,
|
|
43
|
-
passiveModal = _ref.passiveModal,
|
|
44
|
-
secondaryButtonText = _ref.secondaryButtonText,
|
|
45
|
-
primaryButtonText = _ref.primaryButtonText,
|
|
46
|
-
open = _ref.open,
|
|
47
|
-
onRequestClose = _ref.onRequestClose,
|
|
48
|
-
onRequestSubmit = _ref.onRequestSubmit,
|
|
49
|
-
onSecondarySubmit = _ref.onSecondarySubmit,
|
|
50
|
-
primaryButtonDisabled = _ref.primaryButtonDisabled,
|
|
51
|
-
danger = _ref.danger,
|
|
52
|
-
alert = _ref.alert,
|
|
53
|
-
secondaryButtons = _ref.secondaryButtons,
|
|
54
|
-
selectorPrimaryFocus = _ref.selectorPrimaryFocus,
|
|
55
|
-
selectorsFloatingMenus = _ref.selectorsFloatingMenus,
|
|
56
|
-
shouldSubmitOnEnter = _ref.shouldSubmitOnEnter,
|
|
57
|
-
size = _ref.size,
|
|
58
|
-
hasScrollingContent = _ref.hasScrollingContent,
|
|
59
|
-
closeButtonLabel = _ref.closeButtonLabel,
|
|
60
|
-
preventCloseOnClickOutside = _ref.preventCloseOnClickOutside,
|
|
61
|
-
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
62
|
-
|
|
63
|
-
var prefix = usePrefix.usePrefix();
|
|
64
|
-
var button = React.useRef();
|
|
65
|
-
var secondaryButton = React.useRef();
|
|
66
|
-
var innerModal = React.useRef();
|
|
67
|
-
var startTrap = React.useRef();
|
|
68
|
-
var endTrap = React.useRef();
|
|
69
|
-
var modalInstanceId = "modal-".concat(getInstanceId());
|
|
70
|
-
var modalLabelId = "".concat(prefix, "--modal-header__label--").concat(modalInstanceId);
|
|
71
|
-
var modalHeadingId = "".concat(prefix, "--modal-header__heading--").concat(modalInstanceId);
|
|
72
|
-
var modalBodyId = "".concat(prefix, "--modal-body--").concat(modalInstanceId);
|
|
73
|
-
var modalCloseButtonClass = "".concat(prefix, "--modal-close");
|
|
74
|
-
|
|
75
|
-
function isCloseButton(element) {
|
|
76
|
-
return !onSecondarySubmit && element === secondaryButton.current || element.classList.contains(modalCloseButtonClass);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function handleKeyDown(evt) {
|
|
80
|
-
if (open) {
|
|
81
|
-
if (evt.which === 27) {
|
|
82
|
-
onRequestClose(evt);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (evt.which === 13 && shouldSubmitOnEnter && !isCloseButton(evt.target)) {
|
|
86
|
-
onRequestSubmit(evt);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function handleMousedown(evt) {
|
|
92
|
-
if (innerModal.current && !innerModal.current.contains(evt.target) && !wrapFocus.elementOrParentIsFloatingMenu(evt.target, selectorsFloatingMenus) && !preventCloseOnClickOutside) {
|
|
93
|
-
onRequestClose(evt);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function handleBlur(_ref2) {
|
|
98
|
-
var oldActiveNode = _ref2.target,
|
|
99
|
-
currentActiveNode = _ref2.relatedTarget;
|
|
100
|
-
|
|
101
|
-
if (open && currentActiveNode && oldActiveNode) {
|
|
102
|
-
var bodyNode = innerModal.current;
|
|
103
|
-
var startTrapNode = startTrap.current;
|
|
104
|
-
var endTrapNode = endTrap.current;
|
|
105
|
-
wrapFocus["default"]({
|
|
106
|
-
bodyNode: bodyNode,
|
|
107
|
-
startTrapNode: startTrapNode,
|
|
108
|
-
endTrapNode: endTrapNode,
|
|
109
|
-
currentActiveNode: currentActiveNode,
|
|
110
|
-
oldActiveNode: oldActiveNode,
|
|
111
|
-
selectorsFloatingMenus: selectorsFloatingMenus
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
var onSecondaryButtonClick = onSecondarySubmit ? onSecondarySubmit : onRequestClose;
|
|
117
|
-
var modalClasses = cx__default["default"]("".concat(prefix, "--modal"), (_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--modal-tall"), !passiveModal), _rollupPluginBabelHelpers.defineProperty(_classNames, 'is-visible', open), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--modal--danger"), danger), _rollupPluginBabelHelpers.defineProperty(_classNames, className, className), _classNames));
|
|
118
|
-
var containerClasses = cx__default["default"]("".concat(prefix, "--modal-container"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--modal-container--").concat(size), size));
|
|
119
|
-
var contentClasses = cx__default["default"]("".concat(prefix, "--modal-content"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--modal-scroll-content"), hasScrollingContent));
|
|
120
|
-
var footerClasses = cx__default["default"]("".concat(prefix, "--modal-footer"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--modal-footer--three-button"), Array.isArray(secondaryButtons) && secondaryButtons.length === 2));
|
|
121
|
-
var modalButton = /*#__PURE__*/React__default["default"].createElement("button", {
|
|
122
|
-
className: modalCloseButtonClass,
|
|
123
|
-
type: "button",
|
|
124
|
-
onClick: onRequestClose,
|
|
125
|
-
title: ariaLabel,
|
|
126
|
-
"aria-label": closeButtonLabel ? closeButtonLabel : 'close',
|
|
127
|
-
ref: button
|
|
128
|
-
}, /*#__PURE__*/React__default["default"].createElement(iconsReact.Close, {
|
|
129
|
-
size: 20,
|
|
130
|
-
"aria-hidden": "true",
|
|
131
|
-
tabIndex: "-1",
|
|
132
|
-
className: "".concat(modalCloseButtonClass, "__icon")
|
|
133
|
-
}));
|
|
134
|
-
var ariaLabel = modalLabel || ['aria-label'] || modalAriaLabel || modalHeading;
|
|
135
|
-
var getAriaLabelledBy = modalLabel ? modalLabelId : modalHeadingId;
|
|
136
|
-
var hasScrollingContentProps = hasScrollingContent ? {
|
|
137
|
-
tabIndex: 0,
|
|
138
|
-
role: 'region',
|
|
139
|
-
'aria-label': ariaLabel,
|
|
140
|
-
'aria-labelledby': getAriaLabelledBy
|
|
141
|
-
} : {};
|
|
142
|
-
var alertDialogProps = {};
|
|
143
|
-
|
|
144
|
-
if (alert && passiveModal) {
|
|
145
|
-
alertDialogProps.role = 'alert';
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (alert && !passiveModal) {
|
|
149
|
-
alertDialogProps.role = 'alertdialog';
|
|
150
|
-
alertDialogProps['aria-describedby'] = modalBodyId;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
React.useEffect(function () {
|
|
154
|
-
return function () {
|
|
155
|
-
toggleClass["default"](document.body, "".concat(prefix, "--body--with-modal-open"), false);
|
|
156
|
-
};
|
|
157
|
-
}, [prefix]);
|
|
158
|
-
React.useEffect(function () {
|
|
159
|
-
toggleClass["default"](document.body, "".concat(prefix, "--body--with-modal-open"), open);
|
|
160
|
-
}, [open, prefix]);
|
|
161
|
-
React.useEffect(function () {
|
|
162
|
-
var initialFocus = function initialFocus(focusContainerElement) {
|
|
163
|
-
var containerElement = focusContainerElement || innerModal.current;
|
|
164
|
-
var primaryFocusElement = containerElement ? containerElement.querySelector(selectorPrimaryFocus) : null;
|
|
165
|
-
|
|
166
|
-
if (primaryFocusElement) {
|
|
167
|
-
return primaryFocusElement;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return button && button.current;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
var focusButton = function focusButton(focusContainerElement) {
|
|
174
|
-
var target = initialFocus(focusContainerElement);
|
|
175
|
-
|
|
176
|
-
if (target) {
|
|
177
|
-
target.focus();
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
if (open) {
|
|
182
|
-
focusButton(innerModal.current);
|
|
183
|
-
}
|
|
184
|
-
}, [open, selectorPrimaryFocus]);
|
|
185
|
-
var modalBody = /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
186
|
-
ref: innerModal,
|
|
187
|
-
role: "dialog"
|
|
188
|
-
}, alertDialogProps, {
|
|
189
|
-
className: containerClasses,
|
|
190
|
-
"aria-label": ariaLabel,
|
|
191
|
-
"aria-modal": "true",
|
|
192
|
-
tabIndex: "-1"
|
|
193
|
-
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
194
|
-
className: "".concat(prefix, "--modal-header")
|
|
195
|
-
}, passiveModal && modalButton, modalLabel && /*#__PURE__*/React__default["default"].createElement("h2", {
|
|
196
|
-
id: modalLabelId,
|
|
197
|
-
className: "".concat(prefix, "--modal-header__label")
|
|
198
|
-
}, modalLabel), /*#__PURE__*/React__default["default"].createElement("h3", {
|
|
199
|
-
id: modalHeadingId,
|
|
200
|
-
className: "".concat(prefix, "--modal-header__heading")
|
|
201
|
-
}, modalHeading), !passiveModal && modalButton), /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
202
|
-
id: modalBodyId,
|
|
203
|
-
className: contentClasses
|
|
204
|
-
}, hasScrollingContentProps, {
|
|
205
|
-
"aria-labelledby": getAriaLabelledBy
|
|
206
|
-
}), children), hasScrollingContent && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
207
|
-
className: "".concat(prefix, "--modal-content--overflow-indicator")
|
|
208
|
-
}), !passiveModal && /*#__PURE__*/React__default["default"].createElement(ButtonSet["default"], {
|
|
209
|
-
className: footerClasses
|
|
210
|
-
}, Array.isArray(secondaryButtons) && secondaryButtons.length <= 2 ? secondaryButtons.map(function (_ref3, i) {
|
|
211
|
-
var buttonText = _ref3.buttonText,
|
|
212
|
-
onButtonClick = _ref3.onClick;
|
|
213
|
-
return /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
214
|
-
key: "".concat(buttonText, "-").concat(i),
|
|
215
|
-
kind: "secondary",
|
|
216
|
-
onClick: onButtonClick
|
|
217
|
-
}, buttonText);
|
|
218
|
-
}) : secondaryButtonText && /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
219
|
-
kind: "secondary",
|
|
220
|
-
onClick: onSecondaryButtonClick,
|
|
221
|
-
ref: secondaryButton
|
|
222
|
-
}, secondaryButtonText), /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
223
|
-
kind: danger ? 'danger' : 'primary',
|
|
224
|
-
disabled: primaryButtonDisabled,
|
|
225
|
-
onClick: onRequestSubmit,
|
|
226
|
-
ref: button
|
|
227
|
-
}, primaryButtonText)));
|
|
228
|
-
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
229
|
-
onKeyDown: handleKeyDown,
|
|
230
|
-
onMouseDown: handleMousedown,
|
|
231
|
-
onBlur: handleBlur,
|
|
232
|
-
className: modalClasses,
|
|
233
|
-
role: "presentation",
|
|
234
|
-
ref: ref
|
|
235
|
-
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
236
|
-
ref: startTrap,
|
|
237
|
-
tabIndex: "0",
|
|
238
|
-
role: "link",
|
|
239
|
-
className: "".concat(prefix, "--visually-hidden")
|
|
240
|
-
}, "Focus sentinel"), modalBody, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
241
|
-
ref: endTrap,
|
|
242
|
-
tabIndex: "0",
|
|
243
|
-
role: "link",
|
|
244
|
-
className: "".concat(prefix, "--visually-hidden")
|
|
245
|
-
}, "Focus sentinel"));
|
|
246
|
-
});
|
|
247
|
-
Modal.propTypes = (_Modal$propTypes = {
|
|
248
|
-
/**
|
|
249
|
-
* Specify whether the Modal is displaying an alert, error or warning
|
|
250
|
-
* Should go hand in hand with the danger prop.
|
|
251
|
-
*/
|
|
252
|
-
alert: PropTypes__default["default"].bool
|
|
253
|
-
}, _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, 'aria-label', requiredIfGivenPropIsTruthy["default"]('hasScrollingContent', PropTypes__default["default"].string)), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "children", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "className", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "closeButtonLabel", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "danger", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "hasScrollingContent", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "id", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "modalAriaLabel", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "modalHeading", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "modalLabel", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "onKeyDown", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "onRequestClose", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "onRequestSubmit", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "onSecondarySubmit", PropTypes__default["default"].func), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "open", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "passiveModal", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "preventCloseOnClickOutside", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "primaryButtonDisabled", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "primaryButtonText", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "secondaryButtonText", PropTypes__default["default"].node), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "secondaryButtons", function secondaryButtons(props, propName, componentName) {
|
|
254
|
-
if (props.secondaryButtons) {
|
|
255
|
-
if (!Array.isArray(props.secondaryButtons) || props.secondaryButtons.length !== 2) {
|
|
256
|
-
return new Error("".concat(propName, " needs to be an array of two button config objects"));
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
var shape = {
|
|
260
|
-
buttonText: PropTypes__default["default"].node,
|
|
261
|
-
onClick: PropTypes__default["default"].func
|
|
262
|
-
};
|
|
263
|
-
props[propName].forEach(function (secondaryButton) {
|
|
264
|
-
PropTypes__default["default"].checkPropTypes(shape, secondaryButton, propName, componentName);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return null;
|
|
269
|
-
}), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "selectorPrimaryFocus", PropTypes__default["default"].string), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "selectorsFloatingMenus", PropTypes__default["default"].arrayOf(PropTypes__default["default"].string)), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "shouldSubmitOnEnter", PropTypes__default["default"].bool), _rollupPluginBabelHelpers.defineProperty(_Modal$propTypes, "size", PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg'])), _Modal$propTypes);
|
|
270
|
-
Modal.defaultProps = {
|
|
271
|
-
onRequestClose: function onRequestClose() {},
|
|
272
|
-
onRequestSubmit: function onRequestSubmit() {},
|
|
273
|
-
primaryButtonDisabled: false,
|
|
274
|
-
onKeyDown: function onKeyDown() {},
|
|
275
|
-
passiveModal: false,
|
|
276
|
-
modalHeading: '',
|
|
277
|
-
modalLabel: '',
|
|
278
|
-
preventCloseOnClickOutside: false,
|
|
279
|
-
selectorPrimaryFocus: '[data-modal-primary-focus]',
|
|
280
|
-
hasScrollingContent: false
|
|
281
|
-
};
|
|
282
|
-
var ModalNext = Modal;
|
|
283
|
-
|
|
284
|
-
exports["default"] = ModalNext;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
|
-
var FeatureFlags = require('@carbon/feature-flags');
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* This file contains the list of the default values of compile-time feature flags.
|
|
16
|
-
*
|
|
17
|
-
* Build toolchain can replace variable here and/or the references
|
|
18
|
-
* in order to apply non-default values to those feature flags.
|
|
19
|
-
*
|
|
20
|
-
* @example Render `foo` if `aFeatureFlag` is `true`, render `bar` otherwise.
|
|
21
|
-
* import { aFeatureFlag } from '/path/to/FeatureFlags';
|
|
22
|
-
* ...
|
|
23
|
-
* const MyComponent = props => (<div {...props}>{aFeatureFlag ? 'foo' : 'bar'}</div>);
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* With this flag, certain components will be created in either a controlled or controlled
|
|
28
|
-
* mode based on the existence of a value prop.
|
|
29
|
-
*
|
|
30
|
-
* The following components will have the significance of their props slightly altered as outlined below.
|
|
31
|
-
*
|
|
32
|
-
* Components: `<NumberInput>`
|
|
33
|
-
*
|
|
34
|
-
* * `value` → when provided, enables controlled mode.
|
|
35
|
-
* For the rest of the component's lifecycle, it will be controlled by this prop as it's single source of truth.
|
|
36
|
-
* * `defaultValue` → Optional starting value, used for for uncontrolled mode only (no value prop).
|
|
37
|
-
* The value prop takes precedence over defaultValue.
|
|
38
|
-
* * `onChange` → Optional event handler.
|
|
39
|
-
* However, if value is provided and a handler is not, we'll throw a warning indicating the component is now read-only
|
|
40
|
-
* * `readOnly` → silences the above warning, acknowledging the read-only state of the component
|
|
41
|
-
*
|
|
42
|
-
* This flag also disables prop -> state sync in several components, notably `<NumberInput>`.
|
|
43
|
-
*
|
|
44
|
-
* This flag also updates event handlers to pass an up-to-date value in the second parameter,
|
|
45
|
-
* so applications can use it in both controlled and uncontrolled components.
|
|
46
|
-
*
|
|
47
|
-
* * _With_ this feature flag, the signature of the event handler will be altered to provide additional context in the second parameter: `onChange(event, { value, ...rest })` where:
|
|
48
|
-
* * `event` is the (React) raw event
|
|
49
|
-
* * `value` is the new value
|
|
50
|
-
* * `rest` tells you additional information based on the source component
|
|
51
|
-
* * _Without_ this feature flag the event handler has component-specific signature, e.g. `onChange(event, direction)`.
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
var useControlledStateWithValue = FeatureFlags.enabled('enable-use-controlled-state-with-value');
|
|
55
|
-
|
|
56
|
-
exports.useControlledStateWithValue = useControlledStateWithValue;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright IBM Corp. 2016, 2022
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {Function} propType The original prop type checker.
|
|
14
|
-
* @returns {Function} The new prop type checker for `onChange` that makes it required if `value` exists and `readOnly` does not exist.
|
|
15
|
-
*/
|
|
16
|
-
function requiredIfValueExists(propType) {
|
|
17
|
-
return function check(props, propName, componentName) {
|
|
18
|
-
var onChange = props[propName],
|
|
19
|
-
value = props.value,
|
|
20
|
-
readOnly = props.readOnly;
|
|
21
|
-
var exists = onChange !== undefined;
|
|
22
|
-
var valueExists = value !== undefined;
|
|
23
|
-
|
|
24
|
-
if (process.env.NODE_ENV !== "production" && !exists && valueExists && !readOnly) {
|
|
25
|
-
return new Error("You provided a value prop to `".concat(componentName, "` without an `onChange` handler. ") + 'This will render a read-only field. ' + 'If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
29
|
-
rest[_key - 3] = arguments[_key];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return propType.apply(void 0, [props, propName, componentName].concat(rest));
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports["default"] = requiredIfValueExists;
|