@pingux/astro 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +8 -2
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +5 -2
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +8 -3
- 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/CodeView/CodeView.js +3 -3
- package/lib/cjs/components/ListView/ListView.stories.js +3 -0
- 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 +11 -66
- 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/SelectFieldBase/SelectFieldBase.js +8 -1
- package/lib/cjs/context/NavBarContext/index.js +20 -0
- package/lib/cjs/hooks/index.js +9 -0
- package/lib/cjs/hooks/useNavBarPress/index.js +18 -0
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.js +38 -0
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.test.js +42 -0
- package/lib/cjs/index.js +80 -58
- package/lib/cjs/styles/variants/accordion.js +39 -7
- package/lib/cjs/styles/variants/boxes.js +1 -24
- package/lib/cjs/styles/variants/buttons.js +7 -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 +7 -2
- package/lib/components/AccordionGridItem/AccordionGridItemBody.js +4 -2
- package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +9 -4
- 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/CodeView/CodeView.js +2 -2
- package/lib/components/ListView/ListView.stories.js +3 -0
- package/lib/components/Loader/Loader.stories.js +1 -1
- package/lib/components/Modal/Modal.js +4 -1
- package/lib/components/Modal/Modal.stories.js +10 -59
- 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/SelectFieldBase/SelectFieldBase.js +8 -1
- package/lib/context/NavBarContext/index.js +5 -0
- package/lib/hooks/index.js +1 -0
- 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/index.js +2 -0
- package/lib/styles/variants/accordion.js +26 -5
- package/lib/styles/variants/boxes.js +1 -24
- package/lib/styles/variants/buttons.js +7 -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 +3 -1
- package/lib/cjs/recipes/ArrayField.stories.js +0 -169
- package/lib/recipes/ArrayField.stories.js +0 -134
@@ -0,0 +1,196 @@
|
|
1
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
3
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
4
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
5
|
+
import React from 'react';
|
6
|
+
import { OverlayProvider } from '@react-aria/overlays';
|
7
|
+
import { v4 as uuid } from 'uuid';
|
8
|
+
import { ArrayField, ArrayFieldDeleteButton, Item, SelectField, TextField } from '../../index';
|
9
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
|
+
export default {
|
11
|
+
title: 'Form/ArrayField',
|
12
|
+
parameters: {
|
13
|
+
actions: {
|
14
|
+
argTypesRegex: '^on.*'
|
15
|
+
},
|
16
|
+
docs: {
|
17
|
+
source: {
|
18
|
+
type: 'code'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
},
|
22
|
+
argTypes: {
|
23
|
+
label: {
|
24
|
+
defaultValue: 'Array field label',
|
25
|
+
control: {
|
26
|
+
type: 'text'
|
27
|
+
}
|
28
|
+
},
|
29
|
+
helperText: {
|
30
|
+
defaultValue: 'Helper text info...',
|
31
|
+
control: {
|
32
|
+
type: 'text'
|
33
|
+
}
|
34
|
+
},
|
35
|
+
addButtonLabel: {
|
36
|
+
defaultValue: '+ Add field',
|
37
|
+
control: {
|
38
|
+
type: 'text'
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
};
|
43
|
+
var defaultData = [{
|
44
|
+
id: uuid(),
|
45
|
+
value: 'Hello'
|
46
|
+
}, {
|
47
|
+
id: uuid(),
|
48
|
+
value: 'World'
|
49
|
+
}];
|
50
|
+
export var Uncontrolled = function Uncontrolled(_ref) {
|
51
|
+
var args = _extends({}, _ref);
|
52
|
+
|
53
|
+
return ___EmotionJSX(ArrayField, _extends({
|
54
|
+
defaultValue: defaultData,
|
55
|
+
renderField: function renderField(id, fieldValue, onFieldValueChange, onFieldDelete, isDisabled, otherFieldProps) {
|
56
|
+
return ___EmotionJSX(TextField, _extends({
|
57
|
+
"aria-label": "Text field",
|
58
|
+
value: fieldValue,
|
59
|
+
onChange: function onChange(e) {
|
60
|
+
return onFieldValueChange(e, id);
|
61
|
+
},
|
62
|
+
mr: "xs",
|
63
|
+
slots: {
|
64
|
+
inContainer: ___EmotionJSX(ArrayFieldDeleteButton, {
|
65
|
+
isDisabled: isDisabled,
|
66
|
+
onDelete: function onDelete() {
|
67
|
+
return onFieldDelete(id);
|
68
|
+
}
|
69
|
+
})
|
70
|
+
}
|
71
|
+
}, otherFieldProps));
|
72
|
+
},
|
73
|
+
sx: {
|
74
|
+
width: '400px'
|
75
|
+
}
|
76
|
+
}, args));
|
77
|
+
};
|
78
|
+
export var Controlled = function Controlled() {
|
79
|
+
var defaultDataSelectField = [{
|
80
|
+
id: uuid(),
|
81
|
+
fieldValue: 'red',
|
82
|
+
onComponentRender: function onComponentRender(id, fieldValue, onFieldValueChange, onFieldDelete, isDisabled, otherFieldProps) {
|
83
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(SelectField, _extends({
|
84
|
+
defaultSelectedKey: fieldValue,
|
85
|
+
onSelectionChange: function onSelectionChange(e) {
|
86
|
+
return onFieldValueChange(e, id);
|
87
|
+
},
|
88
|
+
width: "100%",
|
89
|
+
slots: {
|
90
|
+
inContainer: ___EmotionJSX(ArrayFieldDeleteButton, {
|
91
|
+
isDisabled: isDisabled,
|
92
|
+
onDelete: function onDelete() {
|
93
|
+
return onFieldDelete(id);
|
94
|
+
}
|
95
|
+
})
|
96
|
+
}
|
97
|
+
}, otherFieldProps), ___EmotionJSX(Item, {
|
98
|
+
key: "red"
|
99
|
+
}, "Red"), ___EmotionJSX(Item, {
|
100
|
+
key: "blue"
|
101
|
+
}, "Blue"), ___EmotionJSX(Item, {
|
102
|
+
key: "yellow"
|
103
|
+
}, "Yellow")));
|
104
|
+
}
|
105
|
+
}, {
|
106
|
+
id: uuid(),
|
107
|
+
fieldValue: 'black',
|
108
|
+
onComponentRender: function onComponentRender(id, fieldValue, onFieldValueChange, onFieldDelete, isDisabled, otherFieldProps) {
|
109
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(SelectField, _extends({
|
110
|
+
defaultSelectedKey: fieldValue,
|
111
|
+
onSelectionChange: function onSelectionChange(key) {
|
112
|
+
return onFieldValueChange(key, id);
|
113
|
+
},
|
114
|
+
width: "100%",
|
115
|
+
slots: {
|
116
|
+
inContainer: ___EmotionJSX(ArrayFieldDeleteButton, {
|
117
|
+
isDisabled: isDisabled,
|
118
|
+
onDelete: function onDelete() {
|
119
|
+
return onFieldDelete(id);
|
120
|
+
}
|
121
|
+
})
|
122
|
+
}
|
123
|
+
}, otherFieldProps), ___EmotionJSX(Item, {
|
124
|
+
key: "orange"
|
125
|
+
}, "Orange"), ___EmotionJSX(Item, {
|
126
|
+
key: "purple"
|
127
|
+
}, "Purple"), ___EmotionJSX(Item, {
|
128
|
+
key: "black"
|
129
|
+
}, "Black")));
|
130
|
+
}
|
131
|
+
}];
|
132
|
+
var defaultEmptyField = {
|
133
|
+
id: uuid(),
|
134
|
+
fieldValue: 'blue',
|
135
|
+
onComponentRender: function onComponentRender(id, fieldValue, onFieldValueChange, onFieldDelete, isDisabled, otherFieldProps) {
|
136
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(SelectField, _extends({
|
137
|
+
defaultSelectedKey: fieldValue,
|
138
|
+
onSelectionChange: function onSelectionChange(e) {
|
139
|
+
return onFieldValueChange(e, id);
|
140
|
+
},
|
141
|
+
width: "100%",
|
142
|
+
slots: {
|
143
|
+
inContainer: ___EmotionJSX(ArrayFieldDeleteButton, {
|
144
|
+
isDisabled: isDisabled,
|
145
|
+
onDelete: function onDelete() {
|
146
|
+
return onFieldDelete(id);
|
147
|
+
}
|
148
|
+
})
|
149
|
+
}
|
150
|
+
}, otherFieldProps), ___EmotionJSX(Item, {
|
151
|
+
key: "blue"
|
152
|
+
}, "Blue"), ___EmotionJSX(Item, {
|
153
|
+
key: "teal"
|
154
|
+
}, "Teal"), ___EmotionJSX(Item, {
|
155
|
+
key: "turquoise"
|
156
|
+
}, "Turquoise")));
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
var _React$useState = React.useState(defaultDataSelectField),
|
161
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
162
|
+
fieldValues = _React$useState2[0],
|
163
|
+
setFieldValues = _React$useState2[1];
|
164
|
+
|
165
|
+
function handleOnChange(values) {
|
166
|
+
setFieldValues(values);
|
167
|
+
}
|
168
|
+
|
169
|
+
function handleOnAdd() {
|
170
|
+
setFieldValues(function (oldValues) {
|
171
|
+
var _context;
|
172
|
+
|
173
|
+
return _concatInstanceProperty(_context = []).call(_context, oldValues, [defaultEmptyField]);
|
174
|
+
});
|
175
|
+
}
|
176
|
+
|
177
|
+
function handleOnDelete(fieldId) {
|
178
|
+
setFieldValues(function (oldValues) {
|
179
|
+
return _filterInstanceProperty(oldValues).call(oldValues, function (_ref2) {
|
180
|
+
var id = _ref2.id;
|
181
|
+
return id !== fieldId;
|
182
|
+
});
|
183
|
+
});
|
184
|
+
}
|
185
|
+
|
186
|
+
return ___EmotionJSX(ArrayField, {
|
187
|
+
value: fieldValues,
|
188
|
+
helperText: "Here is some helpful text...",
|
189
|
+
onAdd: handleOnAdd,
|
190
|
+
onChange: handleOnChange,
|
191
|
+
onDelete: handleOnDelete,
|
192
|
+
sx: {
|
193
|
+
width: '400px'
|
194
|
+
}
|
195
|
+
});
|
196
|
+
};
|
@@ -0,0 +1,185 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import React from 'react';
|
3
|
+
import ArrayField from './ArrayField';
|
4
|
+
import ArrayFieldDeleteButton from './ArrayFieldDeleteButton';
|
5
|
+
import TextField from '../TextField';
|
6
|
+
import { fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
7
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
|
+
jest.mock('uuid', function () {
|
9
|
+
return {
|
10
|
+
v4: function v4() {
|
11
|
+
return 'testid';
|
12
|
+
}
|
13
|
+
};
|
14
|
+
});
|
15
|
+
var defaultData = [{
|
16
|
+
id: '1',
|
17
|
+
value: 'Hello'
|
18
|
+
}, {
|
19
|
+
id: '2',
|
20
|
+
value: 'World'
|
21
|
+
}];
|
22
|
+
var defaultProps = {
|
23
|
+
defaultValue: defaultData
|
24
|
+
};
|
25
|
+
|
26
|
+
var getComponent = function getComponent() {
|
27
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
28
|
+
return render(___EmotionJSX(ArrayField, _extends({}, defaultProps, props)));
|
29
|
+
};
|
30
|
+
|
31
|
+
var renderField = function renderField(id, value, onFieldValueChange, onFieldDelete, otherFieldProps) {
|
32
|
+
return ___EmotionJSX(TextField, _extends({
|
33
|
+
label: "Text field",
|
34
|
+
value: value,
|
35
|
+
onChange: function onChange(e) {
|
36
|
+
return onFieldValueChange(e, id);
|
37
|
+
},
|
38
|
+
mr: "xs",
|
39
|
+
slots: {
|
40
|
+
inContainer: ___EmotionJSX(ArrayFieldDeleteButton, {
|
41
|
+
isDisabled: false,
|
42
|
+
onDelete: function onDelete() {
|
43
|
+
return onFieldDelete(id);
|
44
|
+
}
|
45
|
+
})
|
46
|
+
}
|
47
|
+
}, otherFieldProps));
|
48
|
+
};
|
49
|
+
|
50
|
+
test('displays multiple text fields', function () {
|
51
|
+
var onChange = jest.fn();
|
52
|
+
getComponent({
|
53
|
+
onChange: onChange,
|
54
|
+
renderField: renderField
|
55
|
+
});
|
56
|
+
expect(screen.getAllByLabelText('Text field')).toHaveLength(2);
|
57
|
+
});
|
58
|
+
test('adds one text field and new empty field is added', function () {
|
59
|
+
getComponent({
|
60
|
+
renderField: renderField
|
61
|
+
});
|
62
|
+
fireEvent.click(screen.getByText('+ Add'));
|
63
|
+
expect(screen.getAllByLabelText('Text field')).toHaveLength(3);
|
64
|
+
});
|
65
|
+
test('onAdd callback is fired when adding field', function () {
|
66
|
+
var onAdd = jest.fn();
|
67
|
+
getComponent({
|
68
|
+
onAdd: onAdd,
|
69
|
+
renderField: renderField
|
70
|
+
});
|
71
|
+
fireEvent.click(screen.getByText('+ Add'));
|
72
|
+
expect(onAdd).toHaveBeenCalled();
|
73
|
+
});
|
74
|
+
test('deletes one text field and only one field is left', function () {
|
75
|
+
getComponent({
|
76
|
+
renderField: renderField
|
77
|
+
});
|
78
|
+
fireEvent.click(screen.getAllByRole('button')[0]);
|
79
|
+
expect(screen.getByLabelText('Text field')).toBeInTheDocument();
|
80
|
+
});
|
81
|
+
test('onDelete callback is fired when deleting field', function () {
|
82
|
+
var onDelete = jest.fn();
|
83
|
+
var value = defaultData;
|
84
|
+
var defaultValue = null;
|
85
|
+
getComponent({
|
86
|
+
value: value,
|
87
|
+
defaultValue: defaultValue,
|
88
|
+
onDelete: onDelete,
|
89
|
+
renderField: renderField
|
90
|
+
});
|
91
|
+
fireEvent.click(screen.getAllByRole('button')[0]);
|
92
|
+
expect(onDelete).toHaveBeenCalled();
|
93
|
+
});
|
94
|
+
test('Values are changed in text field', function () {
|
95
|
+
getComponent({
|
96
|
+
renderField: renderField
|
97
|
+
});
|
98
|
+
fireEvent.change(screen.getAllByLabelText('Text field')[0], {
|
99
|
+
target: {
|
100
|
+
value: '123'
|
101
|
+
}
|
102
|
+
});
|
103
|
+
expect(screen.getByDisplayValue('123')).toBeInTheDocument();
|
104
|
+
});
|
105
|
+
test('onChange gets called when field values are changed', function () {
|
106
|
+
var onChange = jest.fn();
|
107
|
+
var value = defaultData;
|
108
|
+
var defaultValue = null;
|
109
|
+
getComponent({
|
110
|
+
value: value,
|
111
|
+
onChange: onChange,
|
112
|
+
renderField: renderField,
|
113
|
+
defaultValue: defaultValue
|
114
|
+
});
|
115
|
+
fireEvent.change(screen.getAllByLabelText('Text field')[0], {
|
116
|
+
target: {
|
117
|
+
value: '123'
|
118
|
+
}
|
119
|
+
});
|
120
|
+
expect(onChange).toHaveBeenNthCalledWith(1, [{
|
121
|
+
id: '1',
|
122
|
+
value: '123'
|
123
|
+
}, {
|
124
|
+
id: '2',
|
125
|
+
value: 'World'
|
126
|
+
}]);
|
127
|
+
});
|
128
|
+
test('onComponentRender displays fields correctly', function () {
|
129
|
+
var onChange = jest.fn();
|
130
|
+
var componentRenderData = [{
|
131
|
+
id: '1',
|
132
|
+
value: 'Hello',
|
133
|
+
onComponentRender: function onComponentRender(id, value, onFieldValueChange, onFieldDelete, otherFieldProps) {
|
134
|
+
return ___EmotionJSX(TextField, _extends({
|
135
|
+
label: "Text field",
|
136
|
+
value: value,
|
137
|
+
onChange: function onChange(e) {
|
138
|
+
return onFieldValueChange(e, id);
|
139
|
+
},
|
140
|
+
mr: "xs",
|
141
|
+
slots: {
|
142
|
+
inContainer: ___EmotionJSX(ArrayFieldDeleteButton, {
|
143
|
+
isDisabled: false,
|
144
|
+
onDelete: function onDelete() {
|
145
|
+
return onFieldDelete(id);
|
146
|
+
}
|
147
|
+
})
|
148
|
+
}
|
149
|
+
}, otherFieldProps));
|
150
|
+
}
|
151
|
+
}, {
|
152
|
+
id: '2',
|
153
|
+
value: 'World',
|
154
|
+
onComponentRender: function onComponentRender(id, value, onFieldValueChange, onFieldDelete, otherFieldProps) {
|
155
|
+
return ___EmotionJSX(TextField, _extends({
|
156
|
+
label: "Text field 2",
|
157
|
+
value: value,
|
158
|
+
onChange: function onChange(e) {
|
159
|
+
return onFieldValueChange(e, id);
|
160
|
+
},
|
161
|
+
mr: "xs",
|
162
|
+
slots: {
|
163
|
+
inContainer: ___EmotionJSX(ArrayFieldDeleteButton, {
|
164
|
+
isDisabled: false,
|
165
|
+
onDelete: function onDelete() {
|
166
|
+
return onFieldDelete(id);
|
167
|
+
}
|
168
|
+
})
|
169
|
+
}
|
170
|
+
}, otherFieldProps));
|
171
|
+
}
|
172
|
+
}];
|
173
|
+
render(___EmotionJSX(ArrayField, {
|
174
|
+
defaultValue: componentRenderData,
|
175
|
+
onChange: onChange
|
176
|
+
}));
|
177
|
+
expect(screen.getByLabelText('Text field')).toBeInTheDocument();
|
178
|
+
expect(screen.getByLabelText('Text field 2')).toBeInTheDocument();
|
179
|
+
});
|
180
|
+
test('creates empty field when no data passed', function () {
|
181
|
+
render(___EmotionJSX(ArrayField, {
|
182
|
+
renderField: renderField
|
183
|
+
}));
|
184
|
+
expect(screen.getByLabelText('Text field')).toBeInTheDocument();
|
185
|
+
});
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import TrashIcon from 'mdi-react/TrashIcon';
|
4
|
+
import Icon from '../Icon';
|
5
|
+
import IconButton from '../IconButton';
|
6
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
|
+
|
8
|
+
var ArrayFieldDeleteButton = function ArrayFieldDeleteButton(_ref) {
|
9
|
+
var label = _ref.label,
|
10
|
+
isDisabled = _ref.isDisabled,
|
11
|
+
id = _ref.id,
|
12
|
+
onDelete = _ref.onDelete;
|
13
|
+
return ___EmotionJSX(IconButton, {
|
14
|
+
onPress: function onPress() {
|
15
|
+
return onDelete(id);
|
16
|
+
},
|
17
|
+
isDisabled: isDisabled,
|
18
|
+
sx: {
|
19
|
+
position: 'absolute',
|
20
|
+
right: -35,
|
21
|
+
width: 32,
|
22
|
+
height: 32,
|
23
|
+
top: 5,
|
24
|
+
cursor: 'pointer'
|
25
|
+
},
|
26
|
+
title: label
|
27
|
+
}, ___EmotionJSX(Icon, {
|
28
|
+
icon: TrashIcon,
|
29
|
+
size: 20,
|
30
|
+
color: "neutral.40"
|
31
|
+
}));
|
32
|
+
};
|
33
|
+
|
34
|
+
ArrayFieldDeleteButton.propTypes = {
|
35
|
+
label: PropTypes.string,
|
36
|
+
id: PropTypes.number,
|
37
|
+
isDisabled: PropTypes.bool,
|
38
|
+
onDelete: PropTypes.func
|
39
|
+
};
|
40
|
+
ArrayFieldDeleteButton.defaultProps = {
|
41
|
+
label: 'Delete field'
|
42
|
+
};
|
43
|
+
export default ArrayFieldDeleteButton;
|
@@ -22,9 +22,9 @@ import { useFocusRing } from '@react-aria/focus';
|
|
22
22
|
import { useHover } from '@react-aria/interactions';
|
23
23
|
import { mergeProps } from '@react-aria/utils';
|
24
24
|
import Highlight, { defaultProps } from 'prism-react-renderer';
|
25
|
-
import github from 'prism-react-renderer/themes/github';
|
26
25
|
import { useStatusClasses } from '../../hooks';
|
27
26
|
import { Box, CopyText } from '../..';
|
27
|
+
import codeView from '../../styles/variants/codeView';
|
28
28
|
/**
|
29
29
|
* Component for code syntax highlighting.
|
30
30
|
* Built on top of [prism-react-renderer](https://github.com/FormidableLabs/prism-react-renderer).
|
@@ -61,7 +61,7 @@ var CodeView = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
61
61
|
};
|
62
62
|
|
63
63
|
var content = ___EmotionJSX(Highlight, _extends({}, defaultProps, {
|
64
|
-
theme:
|
64
|
+
theme: codeView.theme,
|
65
65
|
code: (children === null || children === void 0 ? void 0 : _trimInstanceProperty(children).call(children)) || '',
|
66
66
|
language: language
|
67
67
|
}), function (_ref) {
|
@@ -734,6 +734,9 @@ InfiniteLoadingList.parameters = {
|
|
734
734
|
description: {
|
735
735
|
story: 'Note: Keep in mind the maxHeight may impact when the scroll callback is triggered. If you notice it\'s being called too often, try adjusting that value or loading more objects to prevent this behavior.'
|
736
736
|
}
|
737
|
+
},
|
738
|
+
chromatic: {
|
739
|
+
delay: 5000
|
737
740
|
}
|
738
741
|
};
|
739
742
|
export var MultipleSelection = function MultipleSelection(_ref6) {
|
@@ -31,7 +31,7 @@ export default {
|
|
31
31
|
export var Default = function Default(args) {
|
32
32
|
return ___EmotionJSX(Loader, args);
|
33
33
|
};
|
34
|
-
export var
|
34
|
+
export var CustomColor = function CustomColor() {
|
35
35
|
return ___EmotionJSX(Loader, {
|
36
36
|
color: "neutral.60"
|
37
37
|
});
|
@@ -24,7 +24,7 @@ import Box from '../Box';
|
|
24
24
|
import IconButton from '../IconButton';
|
25
25
|
import Icon from '../Icon';
|
26
26
|
import Text from '../Text';
|
27
|
-
import { useStatusClasses } from '../../hooks';
|
27
|
+
import { useStatusClasses, useDeprecationWarning } from '../../hooks';
|
28
28
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
29
29
|
var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
|
30
30
|
var className = props.className,
|
@@ -85,6 +85,9 @@ var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
85
85
|
}),
|
86
86
|
classNames = _useStatusClasses.classNames;
|
87
87
|
|
88
|
+
useDeprecationWarning('The "dark" variant for Modal will be deprecated in Astro-UI 2.0.0.', {
|
89
|
+
isActive: others.variant === 'modal.dark'
|
90
|
+
});
|
88
91
|
return ___EmotionJSX(OverlayContainer, null, ___EmotionJSX(Box, _extends({
|
89
92
|
className: classNames,
|
90
93
|
variant: "modal.container"
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
-
import
|
3
|
-
import React, { useCallback, useState } from 'react';
|
2
|
+
import React from 'react';
|
4
3
|
import { useModalState } from '../../hooks';
|
5
|
-
import { OverlayProvider, Box, Button, Text, Modal
|
4
|
+
import { OverlayProvider, Box, Button, Text, Modal } from '../../index';
|
6
5
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
6
|
export default {
|
8
7
|
title: 'Modal',
|
@@ -12,7 +11,7 @@ export default {
|
|
12
11
|
control: {
|
13
12
|
type: 'text'
|
14
13
|
},
|
15
|
-
defaultValue: '
|
14
|
+
defaultValue: 'Continue'
|
16
15
|
},
|
17
16
|
role: {},
|
18
17
|
id: {
|
@@ -20,7 +19,9 @@ export default {
|
|
20
19
|
type: 'text'
|
21
20
|
}
|
22
21
|
},
|
23
|
-
hasCloseButton: {
|
22
|
+
hasCloseButton: {
|
23
|
+
defaultValue: true
|
24
|
+
},
|
24
25
|
isClosedOnBlur: {},
|
25
26
|
isDismissable: {},
|
26
27
|
isKeyboardDismissDisabled: {},
|
@@ -68,16 +69,6 @@ export default {
|
|
68
69
|
};
|
69
70
|
export var Default = function Default(args) {
|
70
71
|
var state = useModalState();
|
71
|
-
|
72
|
-
var _useState = useState(''),
|
73
|
-
_useState2 = _slicedToArray(_useState, 2),
|
74
|
-
inputValue = _useState2[0],
|
75
|
-
setInputValue = _useState2[1];
|
76
|
-
|
77
|
-
var onTextFieldChange = useCallback(function (_ref) {
|
78
|
-
var value = _ref.target.value;
|
79
|
-
setInputValue(value.toUpperCase());
|
80
|
-
}, []);
|
81
72
|
return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
82
73
|
// readers when an overlay opens.
|
83
74
|
___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
@@ -88,56 +79,16 @@ export var Default = function Default(args) {
|
|
88
79
|
onClose: state.close
|
89
80
|
}), ___EmotionJSX(Text, {
|
90
81
|
pt: "lg"
|
91
|
-
}, "
|
92
|
-
pt: "lg"
|
93
|
-
}, "Type the word DELETE to confirm deletion of this group"), ___EmotionJSX(TextField, {
|
94
|
-
value: inputValue,
|
95
|
-
onChange: onTextFieldChange,
|
96
|
-
"aria-label": "user input"
|
97
|
-
}), ___EmotionJSX(Box, {
|
98
|
-
isRow: true,
|
99
|
-
pt: "lg",
|
100
|
-
mr: "auto"
|
101
|
-
}, ___EmotionJSX(Button, {
|
102
|
-
variant: "critical",
|
103
|
-
onPress: state.close,
|
104
|
-
mr: "md",
|
105
|
-
isDisabled: Boolean(inputValue !== 'DELETE'),
|
106
|
-
"aria-label": "Delete"
|
107
|
-
}, "Delete"), ___EmotionJSX(Button, {
|
108
|
-
onPress: state.close,
|
109
|
-
"aria-label": "Cancel"
|
110
|
-
}, "Cancel"))))
|
111
|
-
);
|
112
|
-
};
|
113
|
-
export var DarkVariant = function DarkVariant() {
|
114
|
-
var state = useModalState();
|
115
|
-
return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
116
|
-
// readers when a modal opens.
|
117
|
-
___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
118
|
-
onPress: state.open,
|
119
|
-
"aria-label": "Open modal"
|
120
|
-
}, "Open Modal"), state.isOpen && ___EmotionJSX(Modal, {
|
121
|
-
variant: "modal.dark",
|
122
|
-
title: "Question",
|
123
|
-
isOpen: state.isOpen,
|
124
|
-
onClose: state.close,
|
125
|
-
isDismissable: true,
|
126
|
-
hasCloseButton: true
|
127
|
-
}, ___EmotionJSX(Text, {
|
128
|
-
variant: "subtitle",
|
129
|
-
color: "white",
|
130
|
-
pt: "lg"
|
131
|
-
}, "Would you ever really just click a button?"), ___EmotionJSX(Box, {
|
82
|
+
}, "Do you want to continue with this action that you\u2018re performing?"), ___EmotionJSX(Box, {
|
132
83
|
isRow: true,
|
133
84
|
pt: "lg",
|
134
85
|
mr: "auto"
|
135
86
|
}, ___EmotionJSX(Button, {
|
136
87
|
variant: "primary",
|
137
|
-
mr: "md",
|
138
88
|
onPress: state.close,
|
139
|
-
|
140
|
-
|
89
|
+
mr: "md",
|
90
|
+
"aria-label": "Continue"
|
91
|
+
}, "Continue"), ___EmotionJSX(Button, {
|
141
92
|
variant: "link",
|
142
93
|
onPress: state.close,
|
143
94
|
"aria-label": "Cancel"
|
@@ -1,4 +1,7 @@
|
|
1
|
-
import
|
1
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import React, { useState } from 'react';
|
3
|
+
import { NavBarContext } from '../../context/NavBarContext';
|
4
|
+
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
2
5
|
import Box from '../Box/Box';
|
3
6
|
/**
|
4
7
|
* Composed component that spreads children.
|
@@ -14,11 +17,29 @@ import Box from '../Box/Box';
|
|
14
17
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
18
|
|
16
19
|
var NavBar = function NavBar(props) {
|
17
|
-
|
18
|
-
|
20
|
+
var defaultSelectedKeys = props.defaultSelectedKeys;
|
21
|
+
|
22
|
+
var _useState = useState(defaultSelectedKeys),
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
24
|
+
selectedKeys = _useState2[0],
|
25
|
+
setSelectedKeys = _useState2[1];
|
26
|
+
|
27
|
+
return ___EmotionJSX(NavBarContext.Provider, {
|
28
|
+
value: {
|
29
|
+
selectedKeys: selectedKeys,
|
30
|
+
setSelectedKeys: setSelectedKeys
|
31
|
+
}
|
32
|
+
}, ___EmotionJSX(Box, {
|
33
|
+
variant: "navBar.container",
|
19
34
|
role: "navigation",
|
20
35
|
as: "nav"
|
21
|
-
}, props.children);
|
36
|
+
}, props.children));
|
22
37
|
};
|
23
38
|
|
39
|
+
NavBar.propTypes = {
|
40
|
+
defaultSelectedKeys: isIterableProp
|
41
|
+
};
|
42
|
+
NavBar.defaultProps = {
|
43
|
+
defaultSelectedKeys: []
|
44
|
+
};
|
24
45
|
export default NavBar;
|