@pingux/astro 1.2.0-alpha.11 → 1.2.0-alpha.15
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/AccordionGridGroup/AccordionGridGroup.js +32 -25
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +148 -169
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +25 -30
- package/lib/cjs/components/AccordionGridItem/AccordionGridItem.js +29 -14
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +3 -3
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +16 -18
- package/lib/cjs/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +20 -1
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/cjs/components/Button/Button.js +9 -0
- package/lib/cjs/components/Button/Button.stories.js +1 -14
- package/lib/cjs/components/ListView/ListView.js +9 -13
- package/lib/cjs/components/ListViewItem/ListViewItem.js +15 -3
- package/lib/cjs/components/Modal/Modal.stories.js +1 -1
- package/lib/cjs/components/RockerButton/RockerButton.js +14 -22
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.stories.js +4 -22
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -14
- package/lib/cjs/components/SearchField/SearchField.stories.js +1 -15
- package/lib/cjs/components/TextAreaField/TextAreaField.js +53 -8
- package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +33 -1
- package/lib/cjs/components/TextAreaField/TextAreaField.test.js +12 -0
- package/lib/cjs/context/AccordionGridContext/index.js +20 -0
- package/lib/cjs/hooks/useField/useField.js +5 -0
- package/lib/cjs/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/cjs/layouts/ListLayout.stories.js +6 -6
- package/lib/cjs/recipes/ArrayField.stories.js +1 -1
- package/lib/cjs/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/cjs/styles/variants/boxes.js +9 -0
- package/lib/cjs/styles/variants/buttons.js +2 -0
- package/lib/components/AccordionGridGroup/AccordionGridGroup.js +32 -24
- package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +143 -166
- package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +24 -25
- package/lib/components/AccordionGridItem/AccordionGridItem.js +29 -15
- package/lib/components/AccordionGridItem/AccordionGridItemBody.js +4 -4
- package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +19 -20
- package/lib/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/components/AccordionGroup/AccordionGroup.test.js +16 -2
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/components/Button/Button.js +10 -1
- package/lib/components/Button/Button.stories.js +0 -10
- package/lib/components/ListView/ListView.js +9 -12
- package/lib/components/ListViewItem/ListViewItem.js +14 -3
- package/lib/components/Modal/Modal.stories.js +1 -1
- package/lib/components/RockerButton/RockerButton.js +14 -21
- package/lib/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
- package/lib/components/RockerButtonGroup/RockerButtonGroup.stories.js +2 -17
- package/lib/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -11
- package/lib/components/SearchField/SearchField.stories.js +0 -11
- package/lib/components/TextAreaField/TextAreaField.js +53 -9
- package/lib/components/TextAreaField/TextAreaField.stories.js +27 -0
- package/lib/components/TextAreaField/TextAreaField.test.js +13 -0
- package/lib/context/AccordionGridContext/index.js +5 -0
- package/lib/hooks/useField/useField.js +5 -0
- package/lib/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/layouts/ListLayout.stories.js +6 -6
- package/lib/recipes/ArrayField.stories.js +1 -1
- package/lib/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/styles/variants/boxes.js +9 -0
- package/lib/styles/variants/buttons.js +2 -0
- package/package.json +1 -1
- package/lib/cjs/components/AccordionGridGroup/AccordionGridContext.js +0 -17
- package/lib/components/AccordionGridGroup/AccordionGridContext.js +0 -2
@@ -41,15 +41,15 @@ export var Default = function Default(args) {
|
|
41
41
|
onAction: onAction
|
42
42
|
}, args), ___EmotionJSX(Item, {
|
43
43
|
key: "home",
|
44
|
-
variant: "
|
44
|
+
variant: "link",
|
45
45
|
"data-id": "home"
|
46
46
|
}, "Home"), ___EmotionJSX(Item, {
|
47
47
|
key: "trendy",
|
48
|
-
variant: "
|
48
|
+
variant: "link",
|
49
49
|
"data-id": "trendy"
|
50
50
|
}, "Trendy"), ___EmotionJSX(Item, {
|
51
51
|
key: "march 2020 assets",
|
52
|
-
variant: "
|
52
|
+
variant: "link",
|
53
53
|
"data-id": "march"
|
54
54
|
}, "March 2020 Assets"));
|
55
55
|
};
|
@@ -21,7 +21,7 @@ import { useButton } from '@react-aria/button';
|
|
21
21
|
import { useHover } from '@react-aria/interactions';
|
22
22
|
import { useFocusRing } from '@react-aria/focus';
|
23
23
|
import { mergeProps } from '@react-aria/utils';
|
24
|
-
import { useStatusClasses, usePropWarning, useAriaLabelWarning } from '../../hooks';
|
24
|
+
import { useStatusClasses, usePropWarning, useAriaLabelWarning, useDeprecationWarning } from '../../hooks';
|
25
25
|
import Loader from '../Loader';
|
26
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
27
|
var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
@@ -70,6 +70,15 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
70
70
|
}),
|
71
71
|
classNames = _useStatusClasses.classNames;
|
72
72
|
|
73
|
+
useDeprecationWarning('The "icon" variant for `Button` is deprecated in Astro-UI 1.0.0, use the `IconButton` component instead.', {
|
74
|
+
isActive: props.variant === 'icon'
|
75
|
+
});
|
76
|
+
useDeprecationWarning('The "danger" variant for `Button` will be deprecated in Astro-UI 2.0.0, use the `critical` variant instead.', {
|
77
|
+
isActive: props.variant === 'danger'
|
78
|
+
});
|
79
|
+
useDeprecationWarning('The "text" variant for `Button` will be deprecated in Astro-UI 2.0.0, use the `link` variant instead.', {
|
80
|
+
isActive: props.variant === 'text'
|
81
|
+
});
|
73
82
|
var ariaLabel = props['aria-label'];
|
74
83
|
useAriaLabelWarning('Button', ariaLabel, variant === 'filter');
|
75
84
|
return ___EmotionJSX(ThemeUIButton, _extends({
|
@@ -67,16 +67,6 @@ export var TextIconButton = function TextIconButton() {
|
|
67
67
|
size: 20
|
68
68
|
}), "Add a Form"));
|
69
69
|
};
|
70
|
-
export var TextButton = function TextButton() {
|
71
|
-
return ___EmotionJSX(Button, {
|
72
|
-
mb: "sm",
|
73
|
-
variant: "text",
|
74
|
-
"aria-label": "Add option"
|
75
|
-
}, ___EmotionJSX(Text, {
|
76
|
-
variant: "label",
|
77
|
-
color: "active"
|
78
|
-
}, " + Add Option"));
|
79
|
-
};
|
80
70
|
export var InlineButton = function InlineButton() {
|
81
71
|
return ___EmotionJSX(Button, {
|
82
72
|
mb: "sm",
|
@@ -19,7 +19,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
19
19
|
import React, { useMemo, forwardRef, useRef, useImperativeHandle } from 'react';
|
20
20
|
import { GridCollection, useGridState } from '@react-stately/grid';
|
21
21
|
import { GridKeyboardDelegate, useGrid } from '@react-aria/grid';
|
22
|
-
import { mergeProps } from '@react-aria/utils';
|
23
22
|
import { ListLayout } from '@react-stately/layout';
|
24
23
|
import { useListState } from '@react-stately/list';
|
25
24
|
import PropTypes from 'prop-types';
|
@@ -58,12 +57,9 @@ export function useListLayout(state) {
|
|
58
57
|
return layout;
|
59
58
|
}
|
60
59
|
var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
61
|
-
var
|
62
|
-
loadingState = props.loadingState,
|
63
|
-
selectedKeys = props.selectedKeys,
|
60
|
+
var loadingState = props.loadingState,
|
64
61
|
onLoadMore = props.onLoadMore,
|
65
|
-
|
66
|
-
selectionMode = props.selectionMode;
|
62
|
+
selectionStyle = props.selectionStyle;
|
67
63
|
var isLoading = loadingState === loadingStates.LOADING_MORE || loadingState === loadingStates.LOADING;
|
68
64
|
|
69
65
|
var renderWrapper = function renderWrapper(parent, reusableView) {
|
@@ -115,11 +111,9 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
115
111
|
});
|
116
112
|
}, [collection]);
|
117
113
|
var state = useGridState(_objectSpread(_objectSpread({}, props), {}, {
|
118
|
-
disabledKeys: disabledKeys,
|
119
|
-
selectedKeys: selectedKeys,
|
120
114
|
collection: gridCollection,
|
121
|
-
|
122
|
-
|
115
|
+
focusMode: 'cell',
|
116
|
+
selectionBehavior: selectionStyle === 'highlight' ? 'replace' : 'toggle'
|
123
117
|
}));
|
124
118
|
var layout = useListLayout(state);
|
125
119
|
var keyboardDelegate = useMemo(function () {
|
@@ -154,7 +148,7 @@ var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
154
148
|
state: state,
|
155
149
|
keyboardDelegate: keyboardDelegate
|
156
150
|
}
|
157
|
-
}, ___EmotionJSX(Virtualizer, _extends({},
|
151
|
+
}, ___EmotionJSX(Virtualizer, _extends({}, gridProps, {
|
158
152
|
onLoadMore: onLoadMore,
|
159
153
|
ref: listViewRef,
|
160
154
|
focusedKey: focusedKey,
|
@@ -221,6 +215,9 @@ ListView.propTypes = {
|
|
221
215
|
/** The type of selection that is allowed in the collection. */
|
222
216
|
selectionMode: PropTypes.oneOf(['none', 'single', 'multiple']),
|
223
217
|
|
218
|
+
/** */
|
219
|
+
selectionStyle: PropTypes.oneOf(['highlight', undefined]),
|
220
|
+
|
224
221
|
/** Callback function that fires when the selected key changes. */
|
225
222
|
onSelectionChange: PropTypes.func,
|
226
223
|
|
@@ -233,6 +230,6 @@ ListView.propTypes = {
|
|
233
230
|
};
|
234
231
|
ListView.defaultProps = {
|
235
232
|
'aria-label': 'listView',
|
236
|
-
|
233
|
+
selectionMode: 'single'
|
237
234
|
};
|
238
235
|
export default ListView;
|
@@ -6,6 +6,7 @@ import { useFocusRing } from '@react-aria/focus';
|
|
6
6
|
import PropTypes from 'prop-types';
|
7
7
|
import { useGridCell, useGridRow } from '@react-aria/grid';
|
8
8
|
import { useHover } from '@react-aria/interactions';
|
9
|
+
import { useSelectableItem } from '@react-aria/selection';
|
9
10
|
import { ListViewContext } from '../ListView/ListViewContext';
|
10
11
|
import Box from '../Box';
|
11
12
|
import { useStatusClasses } from '../../hooks';
|
@@ -15,7 +16,9 @@ var ListViewItem = function ListViewItem(props) {
|
|
15
16
|
var _context;
|
16
17
|
|
17
18
|
var item = props.item,
|
18
|
-
_props$item
|
19
|
+
_props$item = props.item,
|
20
|
+
key = _props$item.key,
|
21
|
+
_props$item$props = _props$item.props,
|
19
22
|
listItemProps = _props$item$props.listItemProps,
|
20
23
|
rowProps = _props$item$props.rowProps,
|
21
24
|
_props$item$props$has = _props$item$props.hasSeparator,
|
@@ -51,7 +54,7 @@ var ListViewItem = function ListViewItem(props) {
|
|
51
54
|
}, state, rowRef),
|
52
55
|
raRowProps = _useGridRow.rowProps;
|
53
56
|
|
54
|
-
var isSelected =
|
57
|
+
var isSelected = state.selectionManager.isSelected(item.key);
|
55
58
|
|
56
59
|
var _useGridCell = useGridCell({
|
57
60
|
node: cellNode,
|
@@ -59,7 +62,15 @@ var ListViewItem = function ListViewItem(props) {
|
|
59
62
|
}, state, cellRef),
|
60
63
|
gridCellProps = _useGridCell.gridCellProps;
|
61
64
|
|
62
|
-
var
|
65
|
+
var _useSelectableItem = useSelectableItem({
|
66
|
+
isDisabled: isDisabled,
|
67
|
+
selectionManager: state.selectionManager,
|
68
|
+
key: key,
|
69
|
+
ref: cellRef
|
70
|
+
}),
|
71
|
+
selectableItemProps = _useSelectableItem.itemProps;
|
72
|
+
|
73
|
+
var mergedProps = mergeProps(gridCellProps, hoverProps, focusWithinProps, focusProps, selectableItemProps);
|
63
74
|
|
64
75
|
var _useStatusClasses = useStatusClasses(className, {
|
65
76
|
isHovered: isHovered,
|
@@ -138,7 +138,7 @@ export var DarkVariant = function DarkVariant() {
|
|
138
138
|
onPress: state.close,
|
139
139
|
"aria-label": "Yes"
|
140
140
|
}, "Yes"), ___EmotionJSX(Button, {
|
141
|
-
variant: "
|
141
|
+
variant: "link",
|
142
142
|
onPress: state.close,
|
143
143
|
"aria-label": "Cancel"
|
144
144
|
}, "Cancel"))))
|
@@ -17,26 +17,18 @@ import React, { forwardRef, useContext, useImperativeHandle, useRef } from 'reac
|
|
17
17
|
import PropTypes from 'prop-types';
|
18
18
|
import { Item } from '@react-stately/collections';
|
19
19
|
import { useFocusRing } from '@react-aria/focus';
|
20
|
-
import { mergeProps } from '@react-aria/utils';
|
21
20
|
import { useRockerButton, useStatusClasses, usePropWarning } from '../../hooks';
|
22
|
-
import
|
21
|
+
import { Box } from '../../index';
|
23
22
|
import { RockerContext } from '../RockerButtonGroup';
|
24
23
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
25
24
|
export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
26
25
|
var className = props.className,
|
27
|
-
item = props.item
|
28
|
-
buttonGroupDisabled = props.isDisabled;
|
29
|
-
var defaultSelectedStyles = {
|
30
|
-
bg: 'active'
|
31
|
-
};
|
26
|
+
item = props.item;
|
32
27
|
var key = item.key,
|
33
28
|
rendered = item.rendered,
|
34
29
|
itemProps = item.props;
|
35
|
-
var _itemProps$selectedSt = itemProps.selectedStyles,
|
36
|
-
selectedStyles = _itemProps$selectedSt === void 0 ? defaultSelectedStyles : _itemProps$selectedSt,
|
37
|
-
rockerButtonDisabled = itemProps.isDisabled;
|
38
|
-
var isDisabled = buttonGroupDisabled || rockerButtonDisabled;
|
39
30
|
var state = useContext(RockerContext);
|
31
|
+
var isDisabled = state.disabledKeys.has(key);
|
40
32
|
|
41
33
|
var _useFocusRing = useFocusRing(),
|
42
34
|
isFocusVisible = _useFocusRing.isFocusVisible,
|
@@ -46,7 +38,8 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
|
|
46
38
|
|
47
39
|
var _useStatusClasses = useStatusClasses(className, {
|
48
40
|
isFocused: isFocusVisible,
|
49
|
-
isSelected: isSelected
|
41
|
+
isSelected: isSelected,
|
42
|
+
isDisabled: isDisabled
|
50
43
|
}),
|
51
44
|
classNames = _useStatusClasses.classNames;
|
52
45
|
|
@@ -60,25 +53,25 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
|
|
60
53
|
|
61
54
|
var _useRockerButton = useRockerButton({
|
62
55
|
item: item,
|
63
|
-
isDisabled: isDisabled
|
56
|
+
isDisabled: isDisabled,
|
57
|
+
isSelected: isSelected
|
64
58
|
}, state, rockerButtonRef),
|
65
59
|
rockerButtonProps = _useRockerButton.rockerButtonProps;
|
66
60
|
|
67
|
-
return ___EmotionJSX(
|
61
|
+
return ___EmotionJSX(Box, _extends({
|
62
|
+
as: "button",
|
68
63
|
className: classNames,
|
69
|
-
variant: "rocker"
|
70
|
-
},
|
71
|
-
ref: rockerButtonRef
|
64
|
+
variant: "buttons.rocker"
|
65
|
+
}, rockerButtonProps, {
|
66
|
+
ref: rockerButtonRef
|
67
|
+
}, focusProps, itemProps, {
|
72
68
|
sx: {
|
73
|
-
'&.is-selected': _objectSpread({}, selectedStyles)
|
69
|
+
'&.is-selected': _objectSpread({}, itemProps.selectedStyles)
|
74
70
|
}
|
75
71
|
}), rendered);
|
76
72
|
});
|
77
73
|
CollectionRockerButton.displayName = 'CollectionRockerButton';
|
78
74
|
CollectionRockerButton.propTypes = {
|
79
|
-
/** Whether the button is disabled. */
|
80
|
-
isDisabled: PropTypes.bool,
|
81
|
-
|
82
75
|
/** Allows custom styles to be passed to button. */
|
83
76
|
selectedStyles: PropTypes.shape({}),
|
84
77
|
// adding to surface in props table
|
@@ -34,10 +34,10 @@ var RockerButtonGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
34
34
|
var _context;
|
35
35
|
|
36
36
|
var children = props.children,
|
37
|
-
isDisabled = props.isDisabled,
|
38
37
|
onSelectionChange = props.onSelectionChange,
|
39
38
|
tabListProps = props.tabListProps,
|
40
|
-
|
39
|
+
disabledKeys = props.disabledKeys,
|
40
|
+
others = _objectWithoutProperties(props, ["children", "onSelectionChange", "tabListProps", "disabledKeys"]);
|
41
41
|
|
42
42
|
var buttonGroupRef = useRef();
|
43
43
|
usePropWarning(props, 'disabled', 'isDisabled');
|
@@ -67,8 +67,7 @@ var RockerButtonGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
67
67
|
}), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item) {
|
68
68
|
return ___EmotionJSX(CollectionRockerButton, {
|
69
69
|
key: item.key,
|
70
|
-
item: item
|
71
|
-
isDisabled: isDisabled
|
70
|
+
item: item
|
72
71
|
});
|
73
72
|
}))));
|
74
73
|
});
|
@@ -79,14 +78,11 @@ RockerButtonGroup.propTypes = {
|
|
79
78
|
/** The button key that is currently selected. (controlled) */
|
80
79
|
selectedKey: PropTypes.string,
|
81
80
|
|
82
|
-
/**
|
83
|
-
|
81
|
+
/** Which keys should be disabled. */
|
82
|
+
disabledKeys: PropTypes.arrayOf(PropTypes.string),
|
84
83
|
|
85
84
|
/** Handler that is called when the selected button has changed. */
|
86
85
|
onSelectionChange: PropTypes.func
|
87
86
|
};
|
88
|
-
RockerButtonGroup.defaultProps = {
|
89
|
-
isDisabled: false
|
90
|
-
};
|
91
87
|
RockerButtonGroup.displayName = 'RockerButtonGroup';
|
92
88
|
export default RockerButtonGroup;
|
@@ -96,23 +96,8 @@ export var withCustomSelectedColors = function withCustomSelectedColors() {
|
|
96
96
|
};
|
97
97
|
export var DisabledSingleButton = function DisabledSingleButton() {
|
98
98
|
return ___EmotionJSX(RockerButtonGroup, {
|
99
|
-
defaultSelectedKey: "or"
|
100
|
-
|
101
|
-
name: "and",
|
102
|
-
key: "and",
|
103
|
-
isDisabled: true
|
104
|
-
}, "And"), ___EmotionJSX(RockerButton, {
|
105
|
-
name: "or",
|
106
|
-
key: "or"
|
107
|
-
}, "Or"), ___EmotionJSX(RockerButton, {
|
108
|
-
name: "maybe",
|
109
|
-
key: "maybe"
|
110
|
-
}, "Maybe"));
|
111
|
-
};
|
112
|
-
export var DisabledRockerButtonGroup = function DisabledRockerButtonGroup() {
|
113
|
-
return ___EmotionJSX(RockerButtonGroup, {
|
114
|
-
isDisabled: true,
|
115
|
-
defaultSelectedKey: "and"
|
99
|
+
defaultSelectedKey: "or",
|
100
|
+
disabledKeys: ['and']
|
116
101
|
}, ___EmotionJSX(RockerButton, {
|
117
102
|
name: "and",
|
118
103
|
key: "and"
|
@@ -66,9 +66,11 @@ test('buttonGroup is not disabled by default', function () {
|
|
66
66
|
expect(buttonKey).not.toHaveClass('is-disabled');
|
67
67
|
});
|
68
68
|
});
|
69
|
-
test('
|
69
|
+
test('rocker button is disabled when its key is included in disabledKeys', function () {
|
70
70
|
getComponent({
|
71
|
-
|
71
|
+
disabledKeys: _mapInstanceProperty(testButtons).call(testButtons, function (button) {
|
72
|
+
return button.key;
|
73
|
+
})
|
72
74
|
});
|
73
75
|
|
74
76
|
_forEachInstanceProperty(testButtons).call(testButtons, function (button) {
|
@@ -82,24 +84,16 @@ test('rockerButton renders selectedStyles prop when selected', function () {
|
|
82
84
|
expect(buttonColorKey).toHaveClass('is-selected');
|
83
85
|
});
|
84
86
|
test('selected button can be changed by keyboard interaction', function () {
|
85
|
-
getComponent();
|
86
|
-
|
87
|
-
userEvent.tab();
|
87
|
+
getComponent();
|
88
88
|
userEvent.tab();
|
89
89
|
var button0 = screen.getByText(testButtons[0].key);
|
90
90
|
expect(button0).toHaveClass('is-selected');
|
91
91
|
var button1 = screen.getByText(testButtons[1].key);
|
92
92
|
expect(button1).not.toHaveClass('is-selected');
|
93
|
-
userEvent.tab();
|
94
|
-
userEvent.tab();
|
95
93
|
fireEvent.keyDown(screen.getByText(testButtons[0].key), {
|
96
94
|
key: 'ArrowRight',
|
97
95
|
code: 'ArrowRight'
|
98
96
|
});
|
99
|
-
fireEvent.keyDown(screen.getByText(testButtons[1].key), {
|
100
|
-
key: 'ArrowRight',
|
101
|
-
code: 'ArrowRight'
|
102
|
-
});
|
103
97
|
expect(screen.getByText(testButtons[1].key)).toHaveClass('is-selected');
|
104
98
|
expect(screen.getByText(testButtons[0].key)).not.toHaveClass('is-selected');
|
105
99
|
});
|
@@ -101,17 +101,6 @@ export var NoClearButton = function NoClearButton() {
|
|
101
101
|
|
102
102
|
});
|
103
103
|
};
|
104
|
-
export var MaxLength = function MaxLength(args) {
|
105
|
-
return ___EmotionJSX(SearchField, _extends({}, args, {
|
106
|
-
icon: SearchIcon,
|
107
|
-
"aria-label": "Search Groups",
|
108
|
-
onSubmit: function onSubmit(text) {
|
109
|
-
return alert(text);
|
110
|
-
} // eslint-disable-line no-alert
|
111
|
-
,
|
112
|
-
maxLength: 9
|
113
|
-
}));
|
114
|
-
};
|
115
104
|
export var ControlledWithDebouncedInput = function ControlledWithDebouncedInput() {
|
116
105
|
var _useState3 = useState(''),
|
117
106
|
_useState4 = _slicedToArray(_useState3, 2),
|
@@ -14,8 +14,9 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
14
14
|
|
15
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
16
16
|
|
17
|
-
import React, { forwardRef, useRef, useImperativeHandle, useEffect } from 'react';
|
17
|
+
import React, { forwardRef, useRef, useImperativeHandle, useEffect, useCallback } from 'react';
|
18
18
|
import PropTypes from 'prop-types';
|
19
|
+
import { useLayoutEffect, useResizeObserver } from '@react-aria/utils';
|
19
20
|
import { useColumnStyles, useField, useLabelHeight, usePropWarning } from '../../hooks';
|
20
21
|
import statuses from '../../utils/devUtils/constants/statuses';
|
21
22
|
import Box from '../Box';
|
@@ -31,7 +32,8 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
31
32
|
var helperText = props.helperText,
|
32
33
|
isUnresizable = props.isUnresizable,
|
33
34
|
rows = props.rows,
|
34
|
-
status = props.status
|
35
|
+
status = props.status,
|
36
|
+
slots = props.slots;
|
35
37
|
var statusClasses = {
|
36
38
|
isUnresizable: isUnresizable
|
37
39
|
};
|
@@ -45,6 +47,9 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
45
47
|
|
46
48
|
var textAreaRef = useRef();
|
47
49
|
var labelRef = useRef();
|
50
|
+
var containerRef = useRef();
|
51
|
+
var inputContainerRef = useRef();
|
52
|
+
var slotContainer = useRef();
|
48
53
|
usePropWarning(props, 'disabled', 'isDisabled');
|
49
54
|
/* istanbul ignore next */
|
50
55
|
|
@@ -57,6 +62,24 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
57
62
|
/* istanbul ignore next */
|
58
63
|
labelRef.current.style.width = textAreaRef.current.style.width;
|
59
64
|
};
|
65
|
+
/* istanbul ignore next */
|
66
|
+
|
67
|
+
|
68
|
+
var resizeSlotContainer = function resizeSlotContainer() {
|
69
|
+
inputContainerRef.current.style.width = textAreaRef.current.style.width;
|
70
|
+
};
|
71
|
+
|
72
|
+
var onResize = useCallback(function () {
|
73
|
+
/* istanbul ignore next */
|
74
|
+
if (slots === null || slots === void 0 ? void 0 : slots.inContainer) {
|
75
|
+
resizeSlotContainer();
|
76
|
+
}
|
77
|
+
}, [slotContainer]);
|
78
|
+
useResizeObserver({
|
79
|
+
ref: textAreaRef,
|
80
|
+
onResize: onResize
|
81
|
+
});
|
82
|
+
useLayoutEffect(onResize, [onResize]);
|
60
83
|
|
61
84
|
var _useLabelHeight = useLabelHeight({
|
62
85
|
labelRef: labelRef,
|
@@ -68,18 +91,22 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
68
91
|
labelMode: props.labelMode
|
69
92
|
});
|
70
93
|
useEffect(function () {
|
94
|
+
var thisRef = textAreaRef.current;
|
95
|
+
|
71
96
|
if (!props.isUnresizable && props.labelMode === 'float') {
|
72
|
-
|
97
|
+
thisRef.addEventListener('mousemove', props.resizeCallback ? props.resizeCallback : resizeFloatLabel);
|
73
98
|
}
|
74
99
|
|
75
100
|
return function () {
|
76
|
-
|
101
|
+
thisRef.removeEventListener('mousemove', props.resizeCallback ? props.resizeCallback : resizeFloatLabel);
|
77
102
|
};
|
78
|
-
}, []);
|
103
|
+
}, [props.isUnresizable, props.labelMode, props.resizeCallback]);
|
79
104
|
return ___EmotionJSX(Box, _extends({
|
80
105
|
variant: "forms.input.wrapper"
|
81
106
|
}, fieldContainerProps, {
|
82
|
-
sx: _objectSpread(_objectSpread({}, columnStyleProps === null || columnStyleProps === void 0 ? void 0 : columnStyleProps.sx), fieldContainerProps === null || fieldContainerProps === void 0 ? void 0 : fieldContainerProps.sx)
|
107
|
+
sx: _objectSpread(_objectSpread({}, columnStyleProps === null || columnStyleProps === void 0 ? void 0 : columnStyleProps.sx), fieldContainerProps === null || fieldContainerProps === void 0 ? void 0 : fieldContainerProps.sx),
|
108
|
+
ref: containerRef,
|
109
|
+
maxWidth: "100%"
|
83
110
|
}), ___EmotionJSX(Label, _extends({
|
84
111
|
ref: labelRef
|
85
112
|
}, fieldLabelProps, {
|
@@ -87,12 +114,23 @@ var TextAreaField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
87
114
|
gridRow: '1/5'
|
88
115
|
}
|
89
116
|
})), ___EmotionJSX(Box, {
|
117
|
+
isRow: true,
|
90
118
|
variant: "forms.input.container",
|
91
|
-
className: fieldControlProps.className
|
119
|
+
className: fieldControlProps.className,
|
120
|
+
minWidth: "40px",
|
121
|
+
maxWidth: "100%",
|
122
|
+
ref: inputContainerRef
|
92
123
|
}, ___EmotionJSX(TextArea, _extends({
|
93
124
|
ref: textAreaRef,
|
94
125
|
rows: rows
|
95
|
-
}, fieldControlProps
|
126
|
+
}, fieldControlProps, {
|
127
|
+
sx: (slots === null || slots === void 0 ? void 0 : slots.inContainer) && {
|
128
|
+
paddingRight: '35px'
|
129
|
+
}
|
130
|
+
})), (slots === null || slots === void 0 ? void 0 : slots.inContainer) && ___EmotionJSX(Box, {
|
131
|
+
variant: "boxes.textFieldInContainerSlot",
|
132
|
+
ref: slotContainer
|
133
|
+
}, slots === null || slots === void 0 ? void 0 : slots.inContainer)), helperText && ___EmotionJSX(FieldHelperText, {
|
96
134
|
status: status
|
97
135
|
}, helperText));
|
98
136
|
});
|
@@ -187,7 +225,13 @@ TextAreaField.propTypes = {
|
|
187
225
|
controlProps: PropTypes.shape({}),
|
188
226
|
|
189
227
|
/** Props object that is spread directly into the label element. */
|
190
|
-
labelProps: PropTypes.shape({})
|
228
|
+
labelProps: PropTypes.shape({}),
|
229
|
+
|
230
|
+
/** Provides a way to insert markup in specified places. */
|
231
|
+
slots: PropTypes.shape({
|
232
|
+
/** The given node will be inserted into the field container. */
|
233
|
+
inContainer: PropTypes.node
|
234
|
+
})
|
191
235
|
};
|
192
236
|
TextAreaField.defaultProps = {
|
193
237
|
hasAutoFocus: false,
|
@@ -1,7 +1,11 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
3
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
3
4
|
import React, { useState } from 'react';
|
5
|
+
import SearchIcon from 'mdi-react/SearchIcon';
|
4
6
|
import TextAreaField from '.';
|
7
|
+
import Box from '../Box';
|
8
|
+
import Icon from '../Icon';
|
5
9
|
import statuses from '../../utils/devUtils/constants/statuses';
|
6
10
|
import { modes as labelModes } from '../Label/constants';
|
7
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -61,9 +65,32 @@ export default {
|
|
61
65
|
}
|
62
66
|
}
|
63
67
|
};
|
68
|
+
|
69
|
+
var IconSlot = ___EmotionJSX(Box, {
|
70
|
+
isRow: true
|
71
|
+
}, ___EmotionJSX(Icon, {
|
72
|
+
icon: SearchIcon
|
73
|
+
}));
|
74
|
+
|
64
75
|
export var Default = function Default(args) {
|
65
76
|
return ___EmotionJSX(TextAreaField, args);
|
66
77
|
};
|
78
|
+
export var WithSlots = function WithSlots(args) {
|
79
|
+
return (// This is an example of a slot that can be passed into the component
|
80
|
+
// const IconSlot = (
|
81
|
+
// <Box isRow>
|
82
|
+
// <Icon
|
83
|
+
// icon={SearchIcon}
|
84
|
+
// />
|
85
|
+
// </Box>
|
86
|
+
// );
|
87
|
+
___EmotionJSX(TextAreaField, _extends({}, args, {
|
88
|
+
slots: {
|
89
|
+
inContainer: IconSlot
|
90
|
+
}
|
91
|
+
}))
|
92
|
+
);
|
93
|
+
};
|
67
94
|
export var FloatLabel = function FloatLabel() {
|
68
95
|
return ___EmotionJSX(TextAreaField, {
|
69
96
|
label: "Example label",
|
@@ -120,4 +120,17 @@ test('form wrapper will have a max label column width when custom width set', fu
|
|
120
120
|
});
|
121
121
|
var textAreaContainer = screen.getByTestId(testId);
|
122
122
|
expect(textAreaContainer).toHaveStyle('grid-template-columns: 120px auto');
|
123
|
+
});
|
124
|
+
test('providing slot props causes slot to render', function () {
|
125
|
+
var slot = ___EmotionJSX("p", {
|
126
|
+
"data-testid": "testSlot"
|
127
|
+
}, "testText");
|
128
|
+
|
129
|
+
var slots = {
|
130
|
+
inContainer: slot
|
131
|
+
};
|
132
|
+
getComponent({
|
133
|
+
slots: slots
|
134
|
+
});
|
135
|
+
expect(screen.getByTestId('testSlot')).toBeInTheDocument();
|
123
136
|
});
|
@@ -114,6 +114,11 @@ var useField = function useField() {
|
|
114
114
|
setHasValue(true);
|
115
115
|
} else {
|
116
116
|
setHasValue(false);
|
117
|
+
} // adding this function resolves the error brought up in UIP-5116
|
118
|
+
|
119
|
+
|
120
|
+
if (e.persist) {
|
121
|
+
e.persist();
|
117
122
|
} // Make sure to call the original onChange event
|
118
123
|
|
119
124
|
|
@@ -17,24 +17,22 @@ import { useId } from '@react-aria/utils';
|
|
17
17
|
|
18
18
|
var useRockerButton = function useRockerButton(props, state, ref) {
|
19
19
|
var item = props.item,
|
20
|
-
|
20
|
+
isDisabled = props.isDisabled,
|
21
|
+
isSelected = props.isSelected;
|
21
22
|
var key = item.key;
|
22
|
-
var manager = state.selectionManager
|
23
|
-
selectedKey = state.selectedKey;
|
24
|
-
var isSelected = key === selectedKey;
|
23
|
+
var manager = state.selectionManager;
|
25
24
|
|
26
25
|
var _useSelectableItem = useSelectableItem({
|
26
|
+
isDisabled: isDisabled,
|
27
27
|
selectionManager: manager,
|
28
28
|
key: key,
|
29
29
|
ref: ref
|
30
30
|
}),
|
31
31
|
itemProps = _useSelectableItem.itemProps;
|
32
32
|
|
33
|
-
var isDisabled = propsDisabled || state.disabledKeys.has(key);
|
34
33
|
var rockerButtonId = useId();
|
35
34
|
return {
|
36
35
|
rockerButtonProps: _objectSpread(_objectSpread({}, itemProps), {}, {
|
37
|
-
isDisabled: isDisabled,
|
38
36
|
id: rockerButtonId,
|
39
37
|
'aria-pressed': isSelected,
|
40
38
|
'aria-disabled': isDisabled || undefined
|
@@ -547,7 +547,7 @@ export var Default = function Default() {
|
|
547
547
|
mr: "md",
|
548
548
|
"aria-label": "Save Button"
|
549
549
|
}, "Save"), ___EmotionJSX(Button, {
|
550
|
-
variant: "
|
550
|
+
variant: "link",
|
551
551
|
onPress: viewItem,
|
552
552
|
"aria-label": "Cancel Button"
|
553
553
|
}, "Cancel"))), editConfigurationVisible && ___EmotionJSX(OverlayPanel, {
|
@@ -677,7 +677,7 @@ export var Default = function Default() {
|
|
677
677
|
mr: "md",
|
678
678
|
"aria-label": "Save Button"
|
679
679
|
}, "Save"), ___EmotionJSX(Button, {
|
680
|
-
variant: "
|
680
|
+
variant: "link",
|
681
681
|
onPress: viewItem,
|
682
682
|
"aria-label": "Cancel Button"
|
683
683
|
}, "Cancel"))), addItemVisible && ___EmotionJSX(OverlayPanel, {
|
@@ -763,7 +763,7 @@ export var Default = function Default() {
|
|
763
763
|
isRow: true,
|
764
764
|
sx: buttonBarStyles
|
765
765
|
}, ___EmotionJSX(Button, {
|
766
|
-
variant: "
|
766
|
+
variant: "link",
|
767
767
|
onPress: resetListItem,
|
768
768
|
mr: "md",
|
769
769
|
"aria-label": "Cancel Button"
|
@@ -824,7 +824,7 @@ export var Default = function Default() {
|
|
824
824
|
isRow: true,
|
825
825
|
sx: buttonBarStyles
|
826
826
|
}, ___EmotionJSX(Button, {
|
827
|
-
variant: "
|
827
|
+
variant: "link",
|
828
828
|
onPress: resetListItem,
|
829
829
|
mr: "md"
|
830
830
|
}, "Cancel"), ___EmotionJSX(Button, {
|
@@ -846,11 +846,11 @@ export var Default = function Default() {
|
|
846
846
|
pt: "lg",
|
847
847
|
mr: "auto"
|
848
848
|
}, ___EmotionJSX(Button, {
|
849
|
-
variant: "
|
849
|
+
variant: "critical",
|
850
850
|
mr: "md",
|
851
851
|
onPress: deleteItem
|
852
852
|
}, "Delete"), ___EmotionJSX(Button, {
|
853
|
-
variant: "
|
853
|
+
variant: "link",
|
854
854
|
onPress: function onPress() {
|
855
855
|
return setIsDeleting(false);
|
856
856
|
}
|