@pingux/astro 1.2.0-alpha.9 → 1.3.1
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/CHANGELOG.md +81 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +35 -22
- 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 +8 -5
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +20 -17
- package/lib/cjs/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +20 -1
- package/lib/cjs/components/ArrayField/ArrayField.js +213 -0
- package/lib/cjs/components/ArrayField/ArrayField.stories.js +223 -0
- package/lib/cjs/components/ArrayField/ArrayField.test.js +208 -0
- package/lib/cjs/components/ArrayField/ArrayFieldDeleteButton.js +61 -0
- package/lib/cjs/components/ArrayField/index.js +27 -0
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/cjs/components/Button/Button.js +14 -2
- package/lib/cjs/components/Button/Button.stories.js +33 -33
- package/lib/cjs/components/CheckboxField/CheckboxField.js +4 -1
- package/lib/cjs/components/CodeView/CodeView.js +3 -3
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
- package/lib/cjs/components/Input/Input.js +3 -11
- package/lib/cjs/components/Input/Input.test.js +14 -2
- package/lib/cjs/components/Link/Link.js +2 -1
- package/lib/cjs/components/ListView/ListView.js +9 -13
- package/lib/cjs/components/ListView/ListView.stories.js +3 -0
- package/lib/cjs/components/ListViewItem/ListViewItem.js +15 -3
- package/lib/cjs/components/Loader/Loader.stories.js +3 -3
- package/lib/cjs/components/Modal/Modal.js +3 -0
- package/lib/cjs/components/Modal/Modal.stories.js +12 -67
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +10 -2
- package/lib/cjs/components/NavBar/NavBar.js +30 -4
- package/lib/cjs/components/NavBar/NavBar.stories.js +70 -463
- package/lib/cjs/components/NavBar/NavBar.test.js +51 -1
- package/lib/cjs/components/NavBarSection/NavBarItem.js +137 -0
- package/lib/cjs/components/NavBarSection/NavBarItemButton.js +96 -0
- package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +1 -1
- package/lib/cjs/components/NavBarSection/NavBarItemLink.js +98 -0
- package/lib/cjs/components/NavBarSection/NavBarSection.js +10 -8
- package/lib/cjs/components/NavBarSection/index.js +28 -1
- package/lib/cjs/components/NumberField/NumberField.js +30 -10
- package/lib/cjs/components/NumberField/NumberField.test.js +7 -0
- package/lib/cjs/components/PageHeader/PageHeader.js +3 -0
- package/lib/cjs/components/PageHeader/PageHeader.stories.js +6 -1
- package/lib/cjs/components/RadioGroupField/RadioGroupField.js +9 -5
- 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/SelectField/SelectField.stories.js +3 -55
- package/lib/cjs/components/SelectFieldBase/SelectFieldBase.js +8 -1
- package/lib/cjs/components/Tabs/Tabs.stories.js +1 -15
- package/lib/cjs/components/TextAreaField/TextAreaField.js +54 -9
- package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +31 -52
- package/lib/cjs/components/TextAreaField/TextAreaField.test.js +12 -0
- package/lib/cjs/context/AccordionGridContext/index.js +20 -0
- package/lib/cjs/context/NavBarContext/index.js +20 -0
- package/lib/cjs/hooks/index.js +9 -0
- package/lib/cjs/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/cjs/hooks/useField/useField.js +7 -2
- package/lib/cjs/{components/AccordionGridGroup/AccordionGridContext.js → hooks/useNavBarPress/index.js} +7 -6
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.js +38 -0
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.test.js +42 -0
- package/lib/cjs/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/cjs/index.js +80 -58
- package/lib/cjs/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/cjs/styles/forms/checkbox.js +0 -1
- package/lib/cjs/styles/forms/input.js +1 -1
- package/lib/cjs/styles/forms/label.js +3 -0
- package/lib/cjs/styles/forms/radio.js +1 -1
- package/lib/cjs/styles/forms/switch.js +3 -1
- package/lib/cjs/styles/variants/accordion.js +39 -7
- package/lib/cjs/styles/variants/boxes.js +14 -25
- package/lib/cjs/styles/variants/buttons.js +27 -1
- package/lib/cjs/styles/variants/codeView.js +91 -0
- package/lib/cjs/styles/variants/navBar.js +68 -0
- package/lib/cjs/styles/variants/separator.js +2 -1
- package/lib/cjs/styles/variants/text.js +3 -1
- package/lib/cjs/styles/variants/variants.js +3 -0
- package/lib/components/AccordionGridGroup/AccordionGridGroup.js +35 -22
- 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 +8 -6
- package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +22 -18
- package/lib/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/components/AccordionGroup/AccordionGroup.test.js +16 -2
- package/lib/components/ArrayField/ArrayField.js +179 -0
- package/lib/components/ArrayField/ArrayField.stories.js +196 -0
- package/lib/components/ArrayField/ArrayField.test.js +185 -0
- package/lib/components/ArrayField/ArrayFieldDeleteButton.js +43 -0
- package/lib/components/ArrayField/index.js +2 -0
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/components/Button/Button.js +15 -3
- package/lib/components/Button/Button.stories.js +17 -15
- package/lib/components/CheckboxField/CheckboxField.js +4 -1
- package/lib/components/CodeView/CodeView.js +2 -2
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
- package/lib/components/Input/Input.js +2 -10
- package/lib/components/Input/Input.test.js +11 -2
- package/lib/components/Link/Link.js +2 -1
- package/lib/components/ListView/ListView.js +9 -12
- package/lib/components/ListView/ListView.stories.js +3 -0
- package/lib/components/ListViewItem/ListViewItem.js +14 -3
- package/lib/components/Loader/Loader.stories.js +1 -1
- package/lib/components/Modal/Modal.js +4 -1
- package/lib/components/Modal/Modal.stories.js +11 -60
- package/lib/components/MultivaluesField/MultivaluesField.js +9 -2
- package/lib/components/NavBar/NavBar.js +25 -4
- package/lib/components/NavBar/NavBar.stories.js +71 -462
- package/lib/components/NavBar/NavBar.test.js +39 -2
- package/lib/components/NavBarSection/NavBarItem.js +111 -0
- package/lib/components/NavBarSection/NavBarItemButton.js +69 -0
- package/lib/components/NavBarSection/NavBarItemHeader.js +1 -1
- package/lib/components/NavBarSection/NavBarItemLink.js +71 -0
- package/lib/components/NavBarSection/NavBarSection.js +9 -8
- package/lib/components/NavBarSection/index.js +4 -1
- package/lib/components/NumberField/NumberField.js +32 -12
- package/lib/components/NumberField/NumberField.test.js +5 -0
- package/lib/components/PageHeader/PageHeader.js +2 -0
- package/lib/components/PageHeader/PageHeader.stories.js +5 -1
- package/lib/components/RadioGroupField/RadioGroupField.js +9 -5
- 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/SelectField/SelectField.stories.js +2 -50
- package/lib/components/SelectFieldBase/SelectFieldBase.js +8 -1
- package/lib/components/Tabs/Tabs.stories.js +0 -11
- package/lib/components/TextAreaField/TextAreaField.js +54 -10
- package/lib/components/TextAreaField/TextAreaField.stories.js +26 -42
- package/lib/components/TextAreaField/TextAreaField.test.js +13 -0
- package/lib/context/AccordionGridContext/index.js +5 -0
- package/lib/context/NavBarContext/index.js +5 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/hooks/useField/useField.js +7 -2
- package/lib/hooks/useNavBarPress/index.js +1 -0
- package/lib/hooks/useNavBarPress/useNavBarPress.js +27 -0
- package/lib/hooks/useNavBarPress/useNavBarPress.test.js +36 -0
- package/lib/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/index.js +2 -0
- package/lib/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/styles/forms/checkbox.js +0 -1
- package/lib/styles/forms/input.js +1 -1
- package/lib/styles/forms/label.js +3 -0
- package/lib/styles/forms/radio.js +1 -1
- package/lib/styles/forms/switch.js +3 -1
- package/lib/styles/variants/accordion.js +26 -5
- package/lib/styles/variants/boxes.js +14 -25
- package/lib/styles/variants/buttons.js +27 -1
- package/lib/styles/variants/codeView.js +91 -0
- package/lib/styles/variants/navBar.js +46 -0
- package/lib/styles/variants/separator.js +2 -1
- package/lib/styles/variants/text.js +3 -1
- package/lib/styles/variants/variants.js +2 -0
- package/package.json +4 -2
- package/lib/cjs/layouts/ListLayout.stories.js +0 -895
- package/lib/cjs/layouts/SchemaFormLayout.stories.js +0 -139
- package/lib/cjs/recipes/ArrayField.stories.js +0 -169
- package/lib/components/AccordionGridGroup/AccordionGridContext.js +0 -2
- package/lib/layouts/ListLayout.stories.js +0 -866
- package/lib/layouts/SchemaFormLayout.stories.js +0 -107
- package/lib/recipes/ArrayField.stories.js +0 -134
@@ -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),
|
@@ -16,7 +16,6 @@ import { useAsyncList } from '@react-stately/data';
|
|
16
16
|
import { SelectField, Item, Separator, Section } from '../../index';
|
17
17
|
import statuses from '../../utils/devUtils/constants/statuses';
|
18
18
|
import { modes as labelModes } from '../Label/constants';
|
19
|
-
import Box from '../Box';
|
20
19
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
21
20
|
var animals = [{
|
22
21
|
name: 'Aardvark',
|
@@ -195,52 +194,6 @@ export var FloatLabel = function FloatLabel() {
|
|
195
194
|
key: "yellow"
|
196
195
|
}, "Yellow"));
|
197
196
|
};
|
198
|
-
export var LeftLabel = function LeftLabel() {
|
199
|
-
return ___EmotionJSX(Box, {
|
200
|
-
gap: "xl",
|
201
|
-
width: "100%"
|
202
|
-
}, ___EmotionJSX(SelectField, {
|
203
|
-
helperText: "Here is some helpful text...",
|
204
|
-
label: "Example Label",
|
205
|
-
labelMode: "left"
|
206
|
-
}, ___EmotionJSX(Item, {
|
207
|
-
key: "red"
|
208
|
-
}, "Red"), ___EmotionJSX(Item, {
|
209
|
-
key: "blue"
|
210
|
-
}, "Blue"), ___EmotionJSX(Item, {
|
211
|
-
key: "yellow"
|
212
|
-
}, "Yellow")), ___EmotionJSX(SelectField, {
|
213
|
-
label: "Example Label that is much longer than the previous one",
|
214
|
-
labelMode: "left"
|
215
|
-
}, ___EmotionJSX(Item, {
|
216
|
-
key: "red"
|
217
|
-
}, "Red"), ___EmotionJSX(Item, {
|
218
|
-
key: "blue"
|
219
|
-
}, "Blue"), ___EmotionJSX(Item, {
|
220
|
-
key: "yellow"
|
221
|
-
}, "Yellow")), ___EmotionJSX(SelectField, {
|
222
|
-
label: "Example label with set width",
|
223
|
-
labelMode: "left",
|
224
|
-
containerProps: {
|
225
|
-
sx: {
|
226
|
-
gridTemplateColumns: '120px auto'
|
227
|
-
}
|
228
|
-
}
|
229
|
-
}, ___EmotionJSX(Item, {
|
230
|
-
key: "red"
|
231
|
-
}, "Red"), ___EmotionJSX(Item, {
|
232
|
-
key: "blue"
|
233
|
-
}, "Blue"), ___EmotionJSX(Item, {
|
234
|
-
key: "yellow"
|
235
|
-
}, "Yellow")));
|
236
|
-
};
|
237
|
-
LeftLabel.parameters = {
|
238
|
-
docs: {
|
239
|
-
description: {
|
240
|
-
story: 'Users are able to override the default 40% column width when using left label by providing a new gridTemplatesColumn value, as shown in the example below.'
|
241
|
-
}
|
242
|
-
}
|
243
|
-
};
|
244
197
|
export var Controlled = function Controlled() {
|
245
198
|
var _useState = useState('yellow'),
|
246
199
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -299,15 +252,14 @@ export var DisabledOptions = function DisabledOptions() {
|
|
299
252
|
key: "red"
|
300
253
|
}, "Red"), ___EmotionJSX(Item, {
|
301
254
|
key: "blue"
|
302
|
-
}, "Blue
|
255
|
+
}, "Blue"), ___EmotionJSX(Item, {
|
303
256
|
key: "yellow"
|
304
257
|
}, "Yellow"));
|
305
258
|
};
|
306
259
|
export var NoOptionsAvailable = function NoOptionsAvailable() {
|
307
260
|
return ___EmotionJSX(SelectField, {
|
308
261
|
label: "Select an option...",
|
309
|
-
|
310
|
-
defaultText: "No options available"
|
262
|
+
placeholder: "No options available"
|
311
263
|
});
|
312
264
|
};
|
313
265
|
export var HelperText = function HelperText() {
|
@@ -43,6 +43,7 @@ var SelectFieldBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
43
43
|
name = props.name,
|
44
44
|
placeholder = props.placeholder,
|
45
45
|
status = props.status,
|
46
|
+
slots = props.slots,
|
46
47
|
columnStyleProps = props.columnStyleProps,
|
47
48
|
fieldContainerProps = props.fieldContainerProps,
|
48
49
|
fieldControlProps = props.fieldControlProps,
|
@@ -78,7 +79,7 @@ var SelectFieldBase = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
78
79
|
sx: state.isOpen ? {
|
79
80
|
transform: 'rotate(180deg)'
|
80
81
|
} : null
|
81
|
-
}))));
|
82
|
+
}))), slots === null || slots === void 0 ? void 0 : slots.inContainer);
|
82
83
|
|
83
84
|
return ___EmotionJSX(Box, _extends({
|
84
85
|
ref: ref,
|
@@ -146,6 +147,12 @@ SelectFieldBase.propTypes = {
|
|
146
147
|
})
|
147
148
|
}),
|
148
149
|
|
150
|
+
/** Provides a way to insert markup in specified places. */
|
151
|
+
slots: PropTypes.shape({
|
152
|
+
/** The given node will be inserted into the field container. */
|
153
|
+
inContainer: PropTypes.node
|
154
|
+
}),
|
155
|
+
|
149
156
|
/** Control for interaction with SelectField */
|
150
157
|
trigger: PropTypes.node,
|
151
158
|
|
@@ -161,17 +161,6 @@ export var CustomTabLine = function CustomTabLine() {
|
|
161
161
|
}, item.children);
|
162
162
|
});
|
163
163
|
};
|
164
|
-
export var Orientation = function Orientation() {
|
165
|
-
return ___EmotionJSX(Tabs, {
|
166
|
-
orientation: "vertical",
|
167
|
-
items: tabs
|
168
|
-
}, function (item) {
|
169
|
-
return ___EmotionJSX(Tab, {
|
170
|
-
key: item.name,
|
171
|
-
title: item.name
|
172
|
-
}, item.children);
|
173
|
-
});
|
174
|
-
};
|
175
164
|
export var TabPanelProps = function TabPanelProps() {
|
176
165
|
return ___EmotionJSX(Tabs, {
|
177
166
|
tabPanelProps: {
|
@@ -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,
|
@@ -195,7 +239,7 @@ TextAreaField.defaultProps = {
|
|
195
239
|
isReadOnly: false,
|
196
240
|
isRequired: false,
|
197
241
|
isUnresizable: false,
|
198
|
-
rows:
|
242
|
+
rows: 4,
|
199
243
|
status: statuses.DEFAULT
|
200
244
|
};
|
201
245
|
TextAreaField.displayName = 'TextAreaField';
|
@@ -1,8 +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 '.';
|
5
7
|
import Box from '../Box';
|
8
|
+
import Icon from '../Icon';
|
6
9
|
import statuses from '../../utils/devUtils/constants/statuses';
|
7
10
|
import { modes as labelModes } from '../Label/constants';
|
8
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -62,43 +65,38 @@ export default {
|
|
62
65
|
}
|
63
66
|
}
|
64
67
|
};
|
68
|
+
|
69
|
+
var IconSlot = ___EmotionJSX(Box, {
|
70
|
+
isRow: true
|
71
|
+
}, ___EmotionJSX(Icon, {
|
72
|
+
icon: SearchIcon
|
73
|
+
}));
|
74
|
+
|
65
75
|
export var Default = function Default(args) {
|
66
76
|
return ___EmotionJSX(TextAreaField, args);
|
67
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
|
+
};
|
68
94
|
export var FloatLabel = function FloatLabel() {
|
69
95
|
return ___EmotionJSX(TextAreaField, {
|
70
96
|
label: "Example label",
|
71
97
|
labelMode: "float"
|
72
98
|
});
|
73
99
|
};
|
74
|
-
export var LeftLabel = function LeftLabel() {
|
75
|
-
return ___EmotionJSX(Box, {
|
76
|
-
gap: "xl",
|
77
|
-
width: "fit-content"
|
78
|
-
}, ___EmotionJSX(TextAreaField, {
|
79
|
-
label: "Example label",
|
80
|
-
labelMode: "left"
|
81
|
-
}), ___EmotionJSX(TextAreaField, {
|
82
|
-
label: "Example label that is much longer than the previous one",
|
83
|
-
labelMode: "left",
|
84
|
-
status: "error"
|
85
|
-
}), ___EmotionJSX(TextAreaField, {
|
86
|
-
label: "Example label with set width",
|
87
|
-
labelMode: "left",
|
88
|
-
containerProps: {
|
89
|
-
sx: {
|
90
|
-
gridTemplateColumns: '120px auto'
|
91
|
-
}
|
92
|
-
}
|
93
|
-
}));
|
94
|
-
};
|
95
|
-
LeftLabel.parameters = {
|
96
|
-
docs: {
|
97
|
-
description: {
|
98
|
-
story: 'Users are able to override the default 40% column width when using left label by providing a new gridTemplatesColumn value, as shown in the example below.'
|
99
|
-
}
|
100
|
-
}
|
101
|
-
};
|
102
100
|
export var Controlled = function Controlled() {
|
103
101
|
var _useState = useState(),
|
104
102
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -152,20 +150,6 @@ export var Error = function Error() {
|
|
152
150
|
status: "error"
|
153
151
|
});
|
154
152
|
};
|
155
|
-
export var Success = function Success() {
|
156
|
-
return ___EmotionJSX(TextAreaField, {
|
157
|
-
helperText: "Here is some helpful text...",
|
158
|
-
label: "Example Label",
|
159
|
-
status: "success"
|
160
|
-
});
|
161
|
-
};
|
162
|
-
export var Warning = function Warning() {
|
163
|
-
return ___EmotionJSX(TextAreaField, {
|
164
|
-
helperText: "Here is some helpful text...",
|
165
|
-
label: "Example Label",
|
166
|
-
status: "warning"
|
167
|
-
});
|
168
|
-
};
|
169
153
|
export var WithoutStatusIndicator = function WithoutStatusIndicator() {
|
170
154
|
return ___EmotionJSX(TextAreaField, {
|
171
155
|
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
|
});
|
package/lib/hooks/index.js
CHANGED
@@ -6,6 +6,7 @@ export { default as useLabelHeight } from './useLabelHeight';
|
|
6
6
|
export { default as useModalState } from './useModalState';
|
7
7
|
export { default as useOverlayPanelState } from './useOverlayPanelState';
|
8
8
|
export { default as usePropWarning } from './usePropWarning';
|
9
|
+
export { default as useNavBarPress } from './useNavBarPress';
|
9
10
|
export { default as useRockerButton } from './useRockerButton';
|
10
11
|
export { default as useSelectField } from './useSelectField';
|
11
12
|
export { default as useStatusClasses } from './useStatusClasses';
|
@@ -7,8 +7,9 @@ import { useEffect } from 'react';
|
|
7
7
|
*/
|
8
8
|
|
9
9
|
var useAriaLabelWarning = function useAriaLabelWarning(component, ariaLabel) {
|
10
|
+
var condition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
10
11
|
useEffect(function () {
|
11
|
-
if (process.env.NODE_ENV === 'development' && !ariaLabel) {
|
12
|
+
if (process.env.NODE_ENV === 'development' && condition && !ariaLabel) {
|
12
13
|
// eslint-disable-next-line no-console
|
13
14
|
console.warn("".concat(component, " requires an aria-label"), '\n', '\n', 'NOTE: This is a development-only warning and will not display in production.');
|
14
15
|
}
|
@@ -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
|
|
@@ -151,8 +156,8 @@ var useField = function useField() {
|
|
151
156
|
}),
|
152
157
|
focusWithinProps = _useFocusWithin.focusWithinProps;
|
153
158
|
|
154
|
-
var isFloatLabel = labelMode === labelModes.FLOAT;
|
155
|
-
var isLeftLabel = labelMode === labelModes.LEFT;
|
159
|
+
var isFloatLabel = labelMode === labelModes.FLOAT || (labelProps === null || labelProps === void 0 ? void 0 : labelProps.labelMode) === labelModes.FLOAT;
|
160
|
+
var isLeftLabel = labelMode === labelModes.LEFT || (labelProps === null || labelProps === void 0 ? void 0 : labelProps.labelMode) === labelModes.LEFT;
|
156
161
|
var isFloatLabelActive = isFloatLabel && (hasValue || hasFocusWithin || (containerProps === null || containerProps === void 0 ? void 0 : containerProps.isFloatLabelActive));
|
157
162
|
|
158
163
|
var _useStatusClasses2 = useStatusClasses(containerProps === null || containerProps === void 0 ? void 0 : containerProps.className, {
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useNavBarPress';
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/**
|
2
|
+
* A custom hook that will call an onPressCallback function, if the function is provided.
|
3
|
+
* @param {Object} params The accepted parameters object
|
4
|
+
* @param {string} props.key The unique identifier that is assigned to the element being pressed
|
5
|
+
* @param {Object} state The state object tracking selected keys
|
6
|
+
* @param {function} state.setSelectedKeys The function that sets the selected keys
|
7
|
+
* @callback props.onPressCallback The callback that will be called only if provided
|
8
|
+
*/
|
9
|
+
var useNavBarPress = function useNavBarPress(_ref, state) {
|
10
|
+
var key = _ref.key,
|
11
|
+
onPressCallback = _ref.onPressCallback;
|
12
|
+
var setSelectedKeys = state.setSelectedKeys;
|
13
|
+
|
14
|
+
var onNavPress = function onNavPress() {
|
15
|
+
setSelectedKeys(key);
|
16
|
+
|
17
|
+
if (onPressCallback) {
|
18
|
+
onPressCallback();
|
19
|
+
}
|
20
|
+
};
|
21
|
+
|
22
|
+
return {
|
23
|
+
onNavPress: onNavPress
|
24
|
+
};
|
25
|
+
};
|
26
|
+
|
27
|
+
export default useNavBarPress;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { renderHook } from '@testing-library/react-hooks';
|
2
|
+
import useNavBarPress from './';
|
3
|
+
var key = 'testKey';
|
4
|
+
test('using the onPress prop works as a callback', function () {
|
5
|
+
var onPress = jest.fn();
|
6
|
+
var setSelectedKeys = jest.fn();
|
7
|
+
|
8
|
+
var _renderHook = renderHook(function () {
|
9
|
+
return useNavBarPress({
|
10
|
+
key: key,
|
11
|
+
onPressCallback: onPress
|
12
|
+
}, {
|
13
|
+
setSelectedKeys: setSelectedKeys
|
14
|
+
});
|
15
|
+
}),
|
16
|
+
result = _renderHook.result;
|
17
|
+
|
18
|
+
result.current.onNavPress();
|
19
|
+
expect(onPress).toHaveBeenCalled();
|
20
|
+
});
|
21
|
+
test('if no onPress prop there is no callback', function () {
|
22
|
+
var onPress = jest.fn();
|
23
|
+
var setSelectedKeys = jest.fn();
|
24
|
+
|
25
|
+
var _renderHook2 = renderHook(function () {
|
26
|
+
return useNavBarPress({
|
27
|
+
key: key
|
28
|
+
}, {
|
29
|
+
setSelectedKeys: setSelectedKeys
|
30
|
+
});
|
31
|
+
}),
|
32
|
+
result = _renderHook2.result;
|
33
|
+
|
34
|
+
result.current.onNavPress();
|
35
|
+
expect(onPress).not.toHaveBeenCalled();
|
36
|
+
});
|
@@ -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
|
package/lib/index.js
CHANGED
@@ -11,6 +11,8 @@ export { default as AccordionItem } from './components/AccordionItem';
|
|
11
11
|
export * from './components/AccordionItem';
|
12
12
|
export { default as AccordionGridItem } from './components/AccordionGridItem';
|
13
13
|
export * from './components/AccordionGridItem';
|
14
|
+
export { default as ArrayField } from './components/ArrayField';
|
15
|
+
export * from './components/ArrayField';
|
14
16
|
export { default as Avatar } from './components/Avatar';
|
15
17
|
export * from './components/Avatar';
|
16
18
|
export { default as Box } from './components/Box';
|
@@ -96,7 +96,9 @@ export var Default = function Default() {
|
|
96
96
|
setEditOverviewVisible = _React$useState4[1];
|
97
97
|
|
98
98
|
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
99
|
-
onPress:
|
99
|
+
onPress: function onPress() {
|
100
|
+
return setStaticOverviewVisible(true);
|
101
|
+
}
|
100
102
|
}, "Open Panel"), staticOverviewVisible && ___EmotionJSX(OverlayPanel, {
|
101
103
|
isOpen: staticOverviewVisible
|
102
104
|
}, ___EmotionJSX(Box, null, ___EmotionJSX(Box, {
|
@@ -111,7 +113,9 @@ export var Default = function Default() {
|
|
111
113
|
"aria-label": "edit",
|
112
114
|
variant: "inverted",
|
113
115
|
ml: "xs",
|
114
|
-
onPress:
|
116
|
+
onPress: function onPress() {
|
117
|
+
return setEditOverviewVisible(true);
|
118
|
+
}
|
115
119
|
}, ___EmotionJSX(Icon, {
|
116
120
|
icon: CreateIcon,
|
117
121
|
size: 14
|
@@ -435,7 +439,7 @@ export var Default = function Default() {
|
|
435
439
|
onPress: function onPress() {
|
436
440
|
return setEditOverviewVisible(false);
|
437
441
|
},
|
438
|
-
variant: "
|
442
|
+
variant: "link",
|
439
443
|
"aria-label": "cancel"
|
440
444
|
}, "Cancel"))))));
|
441
445
|
};
|