@pingux/astro 1.25.1-alpha.2 → 1.25.1-alpha.5
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/lib/cjs/components/MultivaluesField/MultivaluesField.js +28 -6
- package/lib/cjs/components/MultivaluesField/MultivaluesField.stories.js +46 -2
- package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +14 -0
- package/lib/components/MultivaluesField/MultivaluesField.js +26 -7
- package/lib/components/MultivaluesField/MultivaluesField.stories.js +40 -0
- package/lib/components/MultivaluesField/MultivaluesField.test.js +11 -0
- package/package.json +1 -1
@@ -28,6 +28,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
28
28
|
|
29
29
|
exports["default"] = void 0;
|
30
30
|
|
31
|
+
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
32
|
+
|
31
33
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
32
34
|
|
33
35
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
@@ -70,6 +72,10 @@ var _isIterable = require("../../utils/devUtils/props/isIterable");
|
|
70
72
|
|
71
73
|
var _hooks = require("../../hooks");
|
72
74
|
|
75
|
+
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
76
|
+
|
77
|
+
var _FieldHelperText = _interopRequireDefault(require("../FieldHelperText"));
|
78
|
+
|
73
79
|
var _react2 = require("@emotion/react");
|
74
80
|
|
75
81
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -96,8 +102,10 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
96
102
|
direction = props.direction,
|
97
103
|
_props$disabledKeys = props.disabledKeys,
|
98
104
|
disabledKeys = _props$disabledKeys === void 0 ? [] : _props$disabledKeys,
|
105
|
+
containerProps = props.containerProps,
|
99
106
|
hasAutoFocus = props.hasAutoFocus,
|
100
107
|
hasNoStatusIndicator = props.hasNoStatusIndicator,
|
108
|
+
helperText = props.helperText,
|
101
109
|
customInputProps = props.inputProps,
|
102
110
|
isDisabled = props.isDisabled,
|
103
111
|
isNotFlippable = props.isNotFlippable,
|
@@ -117,7 +125,8 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
117
125
|
_props$readOnlyKeys = props.readOnlyKeys,
|
118
126
|
readOnlyKeys = _props$readOnlyKeys === void 0 ? [] : _props$readOnlyKeys,
|
119
127
|
selectedKeys = props.selectedKeys,
|
120
|
-
scrollBoxProps = props.scrollBoxProps
|
128
|
+
scrollBoxProps = props.scrollBoxProps,
|
129
|
+
status = props.status;
|
121
130
|
var hasCustomValue = mode === 'non-restrictive';
|
122
131
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
123
132
|
|
@@ -395,10 +404,11 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
395
404
|
wrapperProps: {
|
396
405
|
ref: inputRef,
|
397
406
|
variant: 'forms.input.multivaluesWrapper'
|
398
|
-
}
|
407
|
+
},
|
408
|
+
status: status
|
399
409
|
});
|
400
410
|
|
401
|
-
return (0, _react2.jsx)(
|
411
|
+
return (0, _react2.jsx)(_.Box, containerProps, (0, _react2.jsx)(_.TextField, (0, _extends2["default"])({
|
402
412
|
onBlur: function onBlur(e) {
|
403
413
|
setIsOpen(false);
|
404
414
|
if (_onBlur) _onBlur(e.nativeEvent);
|
@@ -420,7 +430,9 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
420
430
|
beforeInput: (0, _react2.jsx)(_react["default"].Fragment, null, readOnlyItems, " ", selectedItems)
|
421
431
|
},
|
422
432
|
value: filterString
|
423
|
-
}, inputProps)), (0, _react2.jsx)(
|
433
|
+
}, inputProps)), helperText && (0, _react2.jsx)(_FieldHelperText["default"], {
|
434
|
+
status: status
|
435
|
+
}, helperText), (0, _react2.jsx)(_.PopoverContainer, {
|
424
436
|
ref: popoverRef,
|
425
437
|
hasNoArrow: true,
|
426
438
|
isNonModal: true,
|
@@ -430,6 +442,9 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
430
442
|
}, listbox));
|
431
443
|
});
|
432
444
|
MultivaluesField.propTypes = {
|
445
|
+
/** Props object that is spread directly into the root (top-level) Box component. */
|
446
|
+
containerProps: _propTypes["default"].shape({}),
|
447
|
+
|
433
448
|
/** The initial selected keys in the collection (uncontrolled). */
|
434
449
|
defaultSelectedKeys: _isIterable.isIterableProp,
|
435
450
|
|
@@ -447,6 +462,9 @@ MultivaluesField.propTypes = {
|
|
447
462
|
/** Whether the field has a status indicator. */
|
448
463
|
hasNoStatusIndicator: _propTypes["default"].bool,
|
449
464
|
|
465
|
+
/** Text rendered below the input. */
|
466
|
+
helperText: _propTypes["default"].node,
|
467
|
+
|
450
468
|
/**
|
451
469
|
* Props that get passed as-is to the underlying TextField element
|
452
470
|
*/
|
@@ -545,14 +563,18 @@ MultivaluesField.propTypes = {
|
|
545
563
|
/** @ignore */
|
546
564
|
scrollBoxProps: _propTypes["default"].shape({
|
547
565
|
maxHeight: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object, _propTypes["default"].number])
|
548
|
-
})
|
566
|
+
}),
|
567
|
+
|
568
|
+
/** Determines the input status indicator and helper text styling. */
|
569
|
+
status: _propTypes["default"].oneOf((0, _values["default"])(_statuses["default"]))
|
549
570
|
};
|
550
571
|
MultivaluesField.defaultProps = {
|
551
572
|
direction: 'bottom',
|
552
573
|
mode: 'restrictive',
|
553
574
|
scrollBoxProps: {
|
554
575
|
maxHeight: 300
|
555
|
-
}
|
576
|
+
},
|
577
|
+
status: _statuses["default"].DEFAULT
|
556
578
|
};
|
557
579
|
var _default = MultivaluesField;
|
558
580
|
exports["default"] = _default;
|
@@ -14,7 +14,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
14
14
|
value: true
|
15
15
|
});
|
16
16
|
|
17
|
-
exports["default"] = exports.WithReadOnlyValues = exports.WithDisabledKeys = exports.WithCustomValues = exports.WithCustomSize = exports.Uncontrolled = exports.Default = exports.Controlled = void 0;
|
17
|
+
exports["default"] = exports.WithReadOnlyValues = exports.WithDisabledKeys = exports.WithCustomValues = exports.WithCustomSize = exports.Uncontrolled = exports.Error = exports.Default = exports.Controlled = void 0;
|
18
18
|
|
19
19
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
20
20
|
|
@@ -24,6 +24,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
24
24
|
|
25
25
|
var _ = require("../..");
|
26
26
|
|
27
|
+
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
28
|
+
|
27
29
|
var _react2 = require("@emotion/react");
|
28
30
|
|
29
31
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -67,6 +69,18 @@ var _default = {
|
|
67
69
|
control: {
|
68
70
|
type: 'none'
|
69
71
|
}
|
72
|
+
},
|
73
|
+
status: {
|
74
|
+
control: {
|
75
|
+
type: 'select',
|
76
|
+
options: _statuses["default"]
|
77
|
+
},
|
78
|
+
defaultValue: _statuses["default"].DEFAULT
|
79
|
+
},
|
80
|
+
helperText: {
|
81
|
+
control: {
|
82
|
+
type: 'text'
|
83
|
+
}
|
70
84
|
}
|
71
85
|
},
|
72
86
|
parameters: {
|
@@ -354,4 +368,34 @@ var WithReadOnlyValues = function WithReadOnlyValues(args) {
|
|
354
368
|
}));
|
355
369
|
};
|
356
370
|
|
357
|
-
exports.WithReadOnlyValues = WithReadOnlyValues;
|
371
|
+
exports.WithReadOnlyValues = WithReadOnlyValues;
|
372
|
+
|
373
|
+
var Error = function Error(args) {
|
374
|
+
var _useState17 = (0, _react.useState)(false),
|
375
|
+
_useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
|
376
|
+
isOpen = _useState18[0],
|
377
|
+
setIsOpen = _useState18[1];
|
378
|
+
|
379
|
+
var direction = args.direction;
|
380
|
+
|
381
|
+
var onOpenChange = function onOpenChange() {
|
382
|
+
setIsOpen(true);
|
383
|
+
};
|
384
|
+
|
385
|
+
return (0, _react2.jsx)(_.OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
386
|
+
, {
|
387
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
388
|
+
}, (0, _react2.jsx)(_.MultivaluesField, (0, _extends2["default"])({}, args, {
|
389
|
+
items: items,
|
390
|
+
helperText: "Here is some helpful text...",
|
391
|
+
status: "error",
|
392
|
+
onOpenChange: onOpenChange
|
393
|
+
}), function (item) {
|
394
|
+
return (0, _react2.jsx)(_.Item, {
|
395
|
+
key: item.key,
|
396
|
+
"data-id": item.name
|
397
|
+
}, item.name);
|
398
|
+
}));
|
399
|
+
};
|
400
|
+
|
401
|
+
exports.Error = Error;
|
@@ -18,6 +18,8 @@ var _index = require("../../index");
|
|
18
18
|
|
19
19
|
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
20
20
|
|
21
|
+
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
22
|
+
|
21
23
|
var _react2 = require("@emotion/react");
|
22
24
|
|
23
25
|
var items = [{
|
@@ -479,4 +481,16 @@ test('read only keys', function () {
|
|
479
481
|
expect(secondChip).toBeInTheDocument();
|
480
482
|
var deleteButton2 = firstChip.nextSibling;
|
481
483
|
expect(deleteButton2).toBeNull();
|
484
|
+
});
|
485
|
+
test(' multivalue field with helper text', function () {
|
486
|
+
var helperText = 'helper text';
|
487
|
+
getComponent({
|
488
|
+
helperText: helperText,
|
489
|
+
status: _statuses["default"].ERROR
|
490
|
+
});
|
491
|
+
|
492
|
+
var helper = _testWrapper.screen.getByText(helperText);
|
493
|
+
|
494
|
+
expect(helper).toBeInTheDocument();
|
495
|
+
expect(helper).toHaveClass("is-".concat(_statuses["default"].ERROR));
|
482
496
|
});
|
@@ -5,6 +5,7 @@ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/inst
|
|
5
5
|
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
6
|
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
7
7
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
8
|
+
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
8
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
9
10
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
10
11
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
@@ -27,10 +28,12 @@ import { FocusScope } from '@react-aria/focus';
|
|
27
28
|
import { useListState } from '@react-stately/list';
|
28
29
|
import { DismissButton, useOverlayPosition } from '@react-aria/overlays';
|
29
30
|
import { useLayoutEffect, useResizeObserver } from '@react-aria/utils';
|
30
|
-
import { Chip, Icon, IconButton, PopoverContainer, ScrollBox, TextField } from '../..';
|
31
|
+
import { Box, Chip, Icon, IconButton, PopoverContainer, ScrollBox, TextField } from '../..';
|
31
32
|
import ListBox from '../ListBox';
|
32
33
|
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
33
34
|
import { usePropWarning } from '../../hooks';
|
35
|
+
import statuses from '../../utils/devUtils/constants/statuses';
|
36
|
+
import FieldHelperText from '../FieldHelperText';
|
34
37
|
/**
|
35
38
|
* Complex control that lets you choose several tags from the dropdown list.
|
36
39
|
* Or to add your own values in non-restrictive mode.
|
@@ -49,8 +52,10 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
49
52
|
direction = props.direction,
|
50
53
|
_props$disabledKeys = props.disabledKeys,
|
51
54
|
disabledKeys = _props$disabledKeys === void 0 ? [] : _props$disabledKeys,
|
55
|
+
containerProps = props.containerProps,
|
52
56
|
hasAutoFocus = props.hasAutoFocus,
|
53
57
|
hasNoStatusIndicator = props.hasNoStatusIndicator,
|
58
|
+
helperText = props.helperText,
|
54
59
|
customInputProps = props.inputProps,
|
55
60
|
isDisabled = props.isDisabled,
|
56
61
|
isNotFlippable = props.isNotFlippable,
|
@@ -70,7 +75,8 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
70
75
|
_props$readOnlyKeys = props.readOnlyKeys,
|
71
76
|
readOnlyKeys = _props$readOnlyKeys === void 0 ? [] : _props$readOnlyKeys,
|
72
77
|
selectedKeys = props.selectedKeys,
|
73
|
-
scrollBoxProps = props.scrollBoxProps
|
78
|
+
scrollBoxProps = props.scrollBoxProps,
|
79
|
+
status = props.status;
|
74
80
|
var hasCustomValue = mode === 'non-restrictive';
|
75
81
|
usePropWarning(props, 'disabled', 'isDisabled');
|
76
82
|
|
@@ -350,10 +356,11 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
350
356
|
wrapperProps: {
|
351
357
|
ref: inputRef,
|
352
358
|
variant: 'forms.input.multivaluesWrapper'
|
353
|
-
}
|
359
|
+
},
|
360
|
+
status: status
|
354
361
|
});
|
355
362
|
|
356
|
-
return ___EmotionJSX(
|
363
|
+
return ___EmotionJSX(Box, containerProps, ___EmotionJSX(TextField, _extends({
|
357
364
|
onBlur: function onBlur(e) {
|
358
365
|
setIsOpen(false);
|
359
366
|
if (_onBlur) _onBlur(e.nativeEvent);
|
@@ -375,7 +382,9 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
375
382
|
beforeInput: ___EmotionJSX(React.Fragment, null, readOnlyItems, " ", selectedItems)
|
376
383
|
},
|
377
384
|
value: filterString
|
378
|
-
}, inputProps)), ___EmotionJSX(
|
385
|
+
}, inputProps)), helperText && ___EmotionJSX(FieldHelperText, {
|
386
|
+
status: status
|
387
|
+
}, helperText), ___EmotionJSX(PopoverContainer, {
|
379
388
|
ref: popoverRef,
|
380
389
|
hasNoArrow: true,
|
381
390
|
isNonModal: true,
|
@@ -385,6 +394,9 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
385
394
|
}, listbox));
|
386
395
|
});
|
387
396
|
MultivaluesField.propTypes = {
|
397
|
+
/** Props object that is spread directly into the root (top-level) Box component. */
|
398
|
+
containerProps: PropTypes.shape({}),
|
399
|
+
|
388
400
|
/** The initial selected keys in the collection (uncontrolled). */
|
389
401
|
defaultSelectedKeys: isIterableProp,
|
390
402
|
|
@@ -402,6 +414,9 @@ MultivaluesField.propTypes = {
|
|
402
414
|
/** Whether the field has a status indicator. */
|
403
415
|
hasNoStatusIndicator: PropTypes.bool,
|
404
416
|
|
417
|
+
/** Text rendered below the input. */
|
418
|
+
helperText: PropTypes.node,
|
419
|
+
|
405
420
|
/**
|
406
421
|
* Props that get passed as-is to the underlying TextField element
|
407
422
|
*/
|
@@ -500,13 +515,17 @@ MultivaluesField.propTypes = {
|
|
500
515
|
/** @ignore */
|
501
516
|
scrollBoxProps: PropTypes.shape({
|
502
517
|
maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.number])
|
503
|
-
})
|
518
|
+
}),
|
519
|
+
|
520
|
+
/** Determines the input status indicator and helper text styling. */
|
521
|
+
status: PropTypes.oneOf(_Object$values(statuses))
|
504
522
|
};
|
505
523
|
MultivaluesField.defaultProps = {
|
506
524
|
direction: 'bottom',
|
507
525
|
mode: 'restrictive',
|
508
526
|
scrollBoxProps: {
|
509
527
|
maxHeight: 300
|
510
|
-
}
|
528
|
+
},
|
529
|
+
status: statuses.DEFAULT
|
511
530
|
};
|
512
531
|
export default MultivaluesField;
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
3
3
|
import React, { useState } from 'react';
|
4
4
|
import { Box, Item, MultivaluesField, OverlayProvider } from '../..';
|
5
|
+
import statuses from '../../utils/devUtils/constants/statuses';
|
5
6
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
6
7
|
export default {
|
7
8
|
title: 'Form/MultivaluesField',
|
@@ -40,6 +41,18 @@ export default {
|
|
40
41
|
control: {
|
41
42
|
type: 'none'
|
42
43
|
}
|
44
|
+
},
|
45
|
+
status: {
|
46
|
+
control: {
|
47
|
+
type: 'select',
|
48
|
+
options: statuses
|
49
|
+
},
|
50
|
+
defaultValue: statuses.DEFAULT
|
51
|
+
},
|
52
|
+
helperText: {
|
53
|
+
control: {
|
54
|
+
type: 'text'
|
55
|
+
}
|
43
56
|
}
|
44
57
|
},
|
45
58
|
parameters: {
|
@@ -306,4 +319,31 @@ export var WithReadOnlyValues = function WithReadOnlyValues(args) {
|
|
306
319
|
"data-id": item.name
|
307
320
|
}, item.name);
|
308
321
|
}));
|
322
|
+
};
|
323
|
+
export var Error = function Error(args) {
|
324
|
+
var _useState17 = useState(false),
|
325
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
326
|
+
isOpen = _useState18[0],
|
327
|
+
setIsOpen = _useState18[1];
|
328
|
+
|
329
|
+
var direction = args.direction;
|
330
|
+
|
331
|
+
var onOpenChange = function onOpenChange() {
|
332
|
+
setIsOpen(true);
|
333
|
+
};
|
334
|
+
|
335
|
+
return ___EmotionJSX(OverlayProvider // note: spacing for demo purpose only so that the select list renders in the correct place
|
336
|
+
, {
|
337
|
+
style: setOverlayStyle(direction, isOpen, '50%', '50%', '20%')
|
338
|
+
}, ___EmotionJSX(MultivaluesField, _extends({}, args, {
|
339
|
+
items: items,
|
340
|
+
helperText: "Here is some helpful text...",
|
341
|
+
status: "error",
|
342
|
+
onOpenChange: onOpenChange
|
343
|
+
}), function (item) {
|
344
|
+
return ___EmotionJSX(Item, {
|
345
|
+
key: item.key,
|
346
|
+
"data-id": item.name
|
347
|
+
}, item.name);
|
348
|
+
}));
|
309
349
|
};
|
@@ -6,6 +6,7 @@ import userEvent from '@testing-library/user-event';
|
|
6
6
|
import { axe } from 'jest-axe';
|
7
7
|
import { Item, MultivaluesField, OverlayProvider } from '../../index';
|
8
8
|
import { render, screen, within } from '../../utils/testUtils/testWrapper';
|
9
|
+
import statuses from '../../utils/devUtils/constants/statuses';
|
9
10
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
11
|
var items = [{
|
11
12
|
id: 1,
|
@@ -357,4 +358,14 @@ test('read only keys', function () {
|
|
357
358
|
expect(secondChip).toBeInTheDocument();
|
358
359
|
var deleteButton2 = firstChip.nextSibling;
|
359
360
|
expect(deleteButton2).toBeNull();
|
361
|
+
});
|
362
|
+
test(' multivalue field with helper text', function () {
|
363
|
+
var helperText = 'helper text';
|
364
|
+
getComponent({
|
365
|
+
helperText: helperText,
|
366
|
+
status: statuses.ERROR
|
367
|
+
});
|
368
|
+
var helper = screen.getByText(helperText);
|
369
|
+
expect(helper).toBeInTheDocument();
|
370
|
+
expect(helper).toHaveClass("is-".concat(statuses.ERROR));
|
360
371
|
});
|