@carbon/react 1.17.0-rc.2 → 1.17.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.
Files changed (27) hide show
  1. package/es/components/DatePicker/DatePicker.js +10 -2
  2. package/es/components/FluidDatePicker/FluidDatePicker.Skeleton.js +67 -0
  3. package/es/components/ListBox/ListBoxSelection.js +11 -4
  4. package/es/components/MultiSelect/MultiSelect.js +28 -5
  5. package/es/components/OverflowMenu/index.js +1 -2
  6. package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +2 -1
  7. package/es/components/SkeletonText/SkeletonText.js +1 -1
  8. package/es/components/StructuredList/StructuredList.js +89 -54
  9. package/es/index.js +2 -1
  10. package/es/internal/FloatingMenu.js +3 -1
  11. package/lib/components/DatePicker/DatePicker.js +9 -1
  12. package/lib/components/FluidDatePicker/FluidDatePicker.Skeleton.js +77 -0
  13. package/lib/components/ListBox/ListBoxSelection.js +11 -4
  14. package/lib/components/MultiSelect/MultiSelect.js +28 -5
  15. package/lib/components/OverflowMenu/index.js +1 -22
  16. package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +2 -1
  17. package/lib/components/SkeletonText/SkeletonText.js +1 -1
  18. package/lib/components/StructuredList/StructuredList.js +87 -52
  19. package/lib/index.js +39 -37
  20. package/lib/internal/FloatingMenu.js +3 -1
  21. package/package.json +5 -5
  22. package/es/components/StructuredList/index.js +0 -43
  23. package/es/components/StructuredList/next/StructuredList.js +0 -342
  24. package/es/internal/ComponentToggle.js +0 -42
  25. package/lib/components/StructuredList/index.js +0 -52
  26. package/lib/components/StructuredList/next/StructuredList.js +0 -357
  27. package/lib/internal/ComponentToggle.js +0 -50
@@ -1,357 +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 React = require('react');
14
- var PropTypes = require('prop-types');
15
- var cx = require('classnames');
16
- var useId = require('../../../internal/useId.js');
17
- var deprecate = require('../../../prop-types/deprecate.js');
18
- var usePrefix = require('../../../internal/usePrefix.js');
19
-
20
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
-
22
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
23
- var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
24
- var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
25
-
26
- var _excluded = ["children", "selection", "className", "ariaLabel", "isCondensed", "isFlush"],
27
- _excluded2 = ["children", "className"],
28
- _excluded3 = ["children", "className"],
29
- _excluded4 = ["onKeyDown", "children", "className", "head"],
30
- _excluded5 = ["className", "name", "title", "id"],
31
- _excluded6 = ["children", "className", "head", "noWrap"];
32
- var GridSelectedRowStateContext = /*#__PURE__*/React__default["default"].createContext(null);
33
- var GridSelectedRowDispatchContext = /*#__PURE__*/React__default["default"].createContext(null);
34
- function StructuredListWrapper(props) {
35
- var _classNames;
36
-
37
- var children = props.children,
38
- selection = props.selection,
39
- className = props.className,
40
- ariaLabel = props.ariaLabel,
41
- isCondensed = props.isCondensed,
42
- isFlush = props.isFlush,
43
- other = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
44
-
45
- var prefix = usePrefix.usePrefix();
46
- var classes = cx__default["default"]("".concat(prefix, "--structured-list"), className, (_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--structured-list--selection"), selection), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--structured-list--condensed"), isCondensed), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--structured-list--flush"), isFlush), _classNames));
47
-
48
- var _React$useState = React__default["default"].useState(null),
49
- _React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
50
- selectedRow = _React$useState2[0],
51
- setSelectedRow = _React$useState2[1];
52
-
53
- return /*#__PURE__*/React__default["default"].createElement(GridSelectedRowStateContext.Provider, {
54
- value: selectedRow
55
- }, /*#__PURE__*/React__default["default"].createElement(GridSelectedRowDispatchContext.Provider, {
56
- value: setSelectedRow
57
- }, /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
58
- role: "table",
59
- className: classes
60
- }, other, {
61
- "aria-label": ariaLabel
62
- }), children)));
63
- }
64
- StructuredListWrapper.propTypes = {
65
- /**
66
- * Specify a label to be read by screen readers on the container node
67
- */
68
- ariaLabel: PropTypes__default["default"].string,
69
-
70
- /**
71
- * Provide the contents of your StructuredListWrapper
72
- */
73
- children: PropTypes__default["default"].node,
74
-
75
- /**
76
- * Specify an optional className to be applied to the container node
77
- */
78
- className: PropTypes__default["default"].string,
79
-
80
- /**
81
- * Specify if structured list is condensed, default is false
82
- */
83
- isCondensed: PropTypes__default["default"].bool,
84
-
85
- /**
86
- * Specify if structured list is flush, default is false
87
- */
88
- isFlush: PropTypes__default["default"].bool,
89
-
90
- /**
91
- * Specify whether your StructuredListWrapper should have selections
92
- */
93
- selection: PropTypes__default["default"].bool
94
- };
95
- StructuredListWrapper.defaultProps = {
96
- selection: false,
97
- isCondensed: false,
98
- isFlush: false,
99
- ariaLabel: 'Structured list section'
100
- };
101
- function StructuredListHead(props) {
102
- var children = props.children,
103
- className = props.className,
104
- other = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded2);
105
-
106
- var prefix = usePrefix.usePrefix();
107
- var classes = cx__default["default"]("".concat(prefix, "--structured-list-thead"), className);
108
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
109
- role: "rowgroup",
110
- className: classes
111
- }, other), children);
112
- }
113
- StructuredListHead.propTypes = {
114
- /**
115
- * Provide the contents of your StructuredListHead
116
- */
117
- children: PropTypes__default["default"].node,
118
-
119
- /**
120
- * Specify an optional className to be applied to the node
121
- */
122
- className: PropTypes__default["default"].string
123
- };
124
- function StructuredListBody(props) {
125
- var children = props.children,
126
- className = props.className,
127
- other = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded3);
128
-
129
- var prefix = usePrefix.usePrefix();
130
- var classes = cx__default["default"]("".concat(prefix, "--structured-list-tbody"), className);
131
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
132
- className: classes,
133
- role: "rowgroup"
134
- }, other), children);
135
- }
136
- StructuredListBody.propTypes = {
137
- /**
138
- * Provide the contents of your StructuredListBody
139
- */
140
- children: PropTypes__default["default"].node,
141
-
142
- /**
143
- * Specify an optional className to be applied to the container node
144
- */
145
- className: PropTypes__default["default"].string,
146
- head: PropTypes__default["default"].bool,
147
-
148
- /**
149
- * Provide a handler that is invoked on the key down event for the control
150
- */
151
- onKeyDown: PropTypes__default["default"].func
152
- };
153
- StructuredListBody.defaultProps = {
154
- onKeyDown: function onKeyDown() {}
155
- };
156
- var GridRowContext = /*#__PURE__*/React__default["default"].createContext(null);
157
- function StructuredListRow(props) {
158
- var _classNames2;
159
-
160
- var onKeyDown = props.onKeyDown,
161
- children = props.children,
162
- className = props.className,
163
- head = props.head,
164
- other = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded4);
165
-
166
- var _useState = React.useState(false),
167
- _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
168
- hasFocusWithin = _useState2[0],
169
- setHasFocusWithin = _useState2[1];
170
-
171
- var id = useId.useId('grid-input');
172
- var setSelectedRow = React__default["default"].useContext(GridSelectedRowDispatchContext);
173
- var prefix = usePrefix.usePrefix();
174
- var value = {
175
- id: id
176
- };
177
- var classes = cx__default["default"]("".concat(prefix, "--structured-list-row"), className, (_classNames2 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames2, "".concat(prefix, "--structured-list-row--header-row"), head), _rollupPluginBabelHelpers.defineProperty(_classNames2, "".concat(prefix, "--structured-list-row--focused-within"), hasFocusWithin), _classNames2));
178
- return head ? /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
179
- role: "row"
180
- }, other, {
181
- className: classes
182
- }), children) :
183
- /*#__PURE__*/
184
- // eslint-disable-next-line jsx-a11y/interactive-supports-focus
185
- React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, other, {
186
- role: "row",
187
- className: classes,
188
- onClick: function onClick() {
189
- return setSelectedRow(id);
190
- },
191
- onFocus: function onFocus() {
192
- setHasFocusWithin(true);
193
- },
194
- onBlur: function onBlur() {
195
- setHasFocusWithin(false);
196
- },
197
- onKeyDown: onKeyDown
198
- }), /*#__PURE__*/React__default["default"].createElement(GridRowContext.Provider, {
199
- value: value
200
- }, children));
201
- }
202
- StructuredListRow.propTypes = {
203
- /**
204
- * Provide the contents of your StructuredListRow
205
- */
206
- children: PropTypes__default["default"].node,
207
-
208
- /**
209
- * Specify an optional className to be applied to the container node
210
- */
211
- className: PropTypes__default["default"].string,
212
-
213
- /**
214
- * Specify whether your StructuredListRow should be used as a header row
215
- */
216
- head: PropTypes__default["default"].bool,
217
-
218
- /**
219
- * Specify whether a `<label>` should be used
220
- */
221
- label: deprecate["default"](PropTypes__default["default"].bool, "\nThe `label` prop is no longer needed and will be removed in the next major version of Carbon."),
222
-
223
- /**
224
- * Provide a handler that is invoked on the key down event for the control,
225
- */
226
- onKeyDown: PropTypes__default["default"].func
227
- };
228
- StructuredListRow.defaultProps = {
229
- head: false,
230
- onKeyDown: function onKeyDown() {}
231
- };
232
- function StructuredListInput(props) {
233
- var _row$id;
234
-
235
- var defaultId = useId.useId('structureListInput');
236
-
237
- var className = props.className,
238
- _props$name = props.name,
239
- name = _props$name === void 0 ? "structured-list-input-".concat(defaultId) : _props$name,
240
- title = props.title,
241
- id = props.id,
242
- other = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded5);
243
-
244
- var prefix = usePrefix.usePrefix();
245
- var classes = cx__default["default"]("".concat(prefix, "--structured-list-input"), "".concat(prefix, "--visually-hidden"), className);
246
- var row = React__default["default"].useContext(GridRowContext);
247
- var selectedRow = React__default["default"].useContext(GridSelectedRowStateContext);
248
- var setSelectedRow = React__default["default"].useContext(GridSelectedRowDispatchContext);
249
- return /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({}, other, {
250
- type: "radio",
251
- tabIndex: 0,
252
- checked: row && row.id === selectedRow,
253
- value: (_row$id = row === null || row === void 0 ? void 0 : row.id) !== null && _row$id !== void 0 ? _row$id : '',
254
- onChange: function onChange(event) {
255
- setSelectedRow(event.target.value);
256
- },
257
- id: id !== null && id !== void 0 ? id : defaultId,
258
- className: classes,
259
- name: name,
260
- title: title
261
- }));
262
- }
263
- StructuredListInput.propTypes = {
264
- /**
265
- * Specify an optional className to be applied to the input
266
- */
267
- className: PropTypes__default["default"].string,
268
-
269
- /**
270
- * Specify whether the underlying input should be checked by default
271
- */
272
- defaultChecked: deprecate["default"](PropTypes__default["default"].bool, "\nThe prop `defaultChecked` is no longer needed and will be removed in the next major version of Carbon."),
273
-
274
- /**
275
- * Specify a custom `id` for the input
276
- */
277
- id: PropTypes__default["default"].string,
278
-
279
- /**
280
- * Provide a `name` for the input
281
- */
282
- name: PropTypes__default["default"].string,
283
-
284
- /**
285
- * Provide an optional hook that is called each time the input is updated
286
- */
287
- onChange: deprecate["default"](PropTypes__default["default"].func, "\nThe prop `onChange` will be removed in the next major version of Carbon."),
288
-
289
- /**
290
- * Provide a `title` for the input
291
- */
292
- title: PropTypes__default["default"].string,
293
-
294
- /**
295
- * Specify the value of the input
296
- */
297
- value: deprecate["default"](PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]).isRequired, "\nThe prop `value` will be removed in the next major version of Carbon.")
298
- };
299
- StructuredListInput.defaultProps = {
300
- title: 'title'
301
- };
302
- function StructuredListCell(props) {
303
- var _classNames3;
304
-
305
- var children = props.children,
306
- className = props.className,
307
- head = props.head,
308
- noWrap = props.noWrap,
309
- other = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded6);
310
-
311
- var prefix = usePrefix.usePrefix();
312
- var classes = cx__default["default"](className, (_classNames3 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames3, "".concat(prefix, "--structured-list-th"), head), _rollupPluginBabelHelpers.defineProperty(_classNames3, "".concat(prefix, "--structured-list-td"), !head), _rollupPluginBabelHelpers.defineProperty(_classNames3, "".concat(prefix, "--structured-list-content--nowrap"), noWrap), _classNames3));
313
-
314
- if (head) {
315
- return /*#__PURE__*/React__default["default"].createElement("span", _rollupPluginBabelHelpers["extends"]({
316
- className: classes,
317
- role: "columnheader"
318
- }, other), children);
319
- }
320
-
321
- return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
322
- className: classes,
323
- role: "cell"
324
- }, other), children);
325
- }
326
- StructuredListCell.propTypes = {
327
- /**
328
- * Provide the contents of your StructuredListCell
329
- */
330
- children: PropTypes__default["default"].node,
331
-
332
- /**
333
- * Specify an optional className to be applied to the container node
334
- */
335
- className: PropTypes__default["default"].string,
336
-
337
- /**
338
- * Specify whether your StructuredListCell should be used as a header cell
339
- */
340
- head: PropTypes__default["default"].bool,
341
-
342
- /**
343
- * Specify whether your StructuredListCell should have text wrapping
344
- */
345
- noWrap: PropTypes__default["default"].bool
346
- };
347
- StructuredListCell.defaultProps = {
348
- head: false,
349
- noWrap: false
350
- };
351
-
352
- exports.StructuredListBody = StructuredListBody;
353
- exports.StructuredListCell = StructuredListCell;
354
- exports.StructuredListHead = StructuredListHead;
355
- exports.StructuredListInput = StructuredListInput;
356
- exports.StructuredListRow = StructuredListRow;
357
- exports.StructuredListWrapper = StructuredListWrapper;
@@ -1,50 +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 React = require('react');
14
- var index = require('../components/FeatureFlags/index.js');
15
-
16
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
-
18
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
19
-
20
- function createComponentToggle(spec) {
21
- var name = spec.name,
22
- _spec$flag = spec.flag,
23
- flag = _spec$flag === void 0 ? 'enable-v11-release' : _spec$flag,
24
- next = spec.next,
25
- classic = spec.classic;
26
-
27
- function ComponentToggle(props, ref) {
28
- var enabled = index.useFeatureFlag(flag);
29
-
30
- if (enabled) {
31
- if (next) {
32
- return /*#__PURE__*/React__default["default"].createElement(next, _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, props), {}, {
33
- ref: ref
34
- }));
35
- }
36
-
37
- return null;
38
- }
39
-
40
- return /*#__PURE__*/React__default["default"].createElement(classic, _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, props), {}, {
41
- ref: ref
42
- }));
43
- }
44
-
45
- var wrappedComponent = /*#__PURE__*/React__default["default"].forwardRef(ComponentToggle);
46
- wrappedComponent.displayName = "FeatureToggle(".concat(name, ")");
47
- return wrappedComponent;
48
- }
49
-
50
- exports.createComponentToggle = createComponentToggle;