@pingux/astro 1.27.0-alpha.0 → 1.27.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/lib/cjs/components/ArrayField/ArrayField.stories.js +6 -6
  2. package/lib/cjs/components/FileInputField/FileInputField.js +8 -5
  3. package/lib/cjs/components/LinkSelectField/LinkSelectField.js +1 -1
  4. package/lib/cjs/components/ListBox/Option.js +4 -1
  5. package/lib/cjs/components/MenuItem/MenuItem.js +2 -1
  6. package/lib/cjs/components/Messages/Message.js +2 -1
  7. package/lib/cjs/components/PageHeader/PageHeader.js +7 -1
  8. package/lib/cjs/components/SelectField/SelectField.js +1 -1
  9. package/lib/cjs/components/Tab/Tab.js +15 -4
  10. package/lib/cjs/components/TabPicker/TabPicker.js +2 -2
  11. package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.test.js +3 -2
  12. package/lib/cjs/hooks/useSelectField/useSelectField.js +9 -1
  13. package/lib/cjs/recipes/CountryPicker.stories.js +25 -12
  14. package/lib/cjs/recipes/EditableInput.stories.js +55 -46
  15. package/lib/cjs/recipes/ListAndPanel.stories.js +102 -87
  16. package/lib/cjs/recipes/PageHeader.stories.js +73 -0
  17. package/lib/components/ArrayField/ArrayField.stories.js +6 -6
  18. package/lib/components/FileInputField/FileInputField.js +8 -5
  19. package/lib/components/LinkSelectField/LinkSelectField.js +1 -1
  20. package/lib/components/ListBox/Option.js +4 -1
  21. package/lib/components/MenuItem/MenuItem.js +2 -1
  22. package/lib/components/Messages/Message.js +2 -1
  23. package/lib/components/PageHeader/PageHeader.js +8 -1
  24. package/lib/components/SelectField/SelectField.js +1 -1
  25. package/lib/components/Tab/Tab.js +15 -4
  26. package/lib/components/TabPicker/TabPicker.js +2 -2
  27. package/lib/hooks/useOverlayPanelState/useOverlayPanelState.test.js +3 -2
  28. package/lib/hooks/useSelectField/useSelectField.js +9 -1
  29. package/lib/recipes/CountryPicker.stories.js +24 -12
  30. package/lib/recipes/EditableInput.stories.js +55 -46
  31. package/lib/recipes/ListAndPanel.stories.js +102 -87
  32. package/lib/recipes/PageHeader.stories.js +53 -0
  33. package/package.json +3 -2
@@ -207,26 +207,26 @@ var Controlled = function Controlled() {
207
207
  fieldValues = _React$useState2[0],
208
208
  setFieldValues = _React$useState2[1];
209
209
 
210
- function handleOnChange(values) {
210
+ var handleOnChange = function handleOnChange(values) {
211
211
  setFieldValues(values);
212
- }
212
+ };
213
213
 
214
- function handleOnAdd() {
214
+ var handleOnAdd = function handleOnAdd() {
215
215
  setFieldValues(function (oldValues) {
216
216
  var _context;
217
217
 
218
218
  return (0, _concat["default"])(_context = []).call(_context, oldValues, [defaultEmptyField]);
219
219
  });
220
- }
220
+ };
221
221
 
222
- function handleOnDelete(fieldId) {
222
+ var handleOnDelete = function handleOnDelete(fieldId) {
223
223
  setFieldValues(function (oldValues) {
224
224
  return (0, _filter["default"])(oldValues).call(oldValues, function (_ref2) {
225
225
  var id = _ref2.id;
226
226
  return id !== fieldId;
227
227
  });
228
228
  });
229
- }
229
+ };
230
230
 
231
231
  return (0, _react2.jsx)(_index.ArrayField, {
232
232
  value: fieldValues,
@@ -230,7 +230,10 @@ var FileInputField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
230
230
  variant: "boxes.fileInputFieldWrapper"
231
231
  }, (0, _utils.mergeProps)(fieldContainerProps, others), {
232
232
  className: classNames
233
- }, getRootProps()), (0, _react2.jsx)(_index.Input, (0, _extends2["default"])({}, (0, _utils.mergeProps)(visuallyHiddenProps, fieldControlProps, getInputProps()), {
233
+ }, getRootProps(), {
234
+ // to pass accessibility test, this removes focusable dependents
235
+ role: "none"
236
+ }), (0, _react2.jsx)(_index.Input, (0, _extends2["default"])({}, (0, _utils.mergeProps)(visuallyHiddenProps, fieldControlProps, getInputProps()), {
234
237
  "aria-label": "File Input",
235
238
  multiple: isMultiple,
236
239
  onChange: handleOnChange,
@@ -294,8 +297,8 @@ FileInputField.propTypes = {
294
297
  * */
295
298
  fileList: _propTypes["default"].arrayOf(_propTypes["default"].shape({
296
299
  fileObj: _propTypes["default"].shape({}),
297
- id: _propTypes["default"].string.required,
298
- name: _propTypes["default"].string.required,
300
+ id: _propTypes["default"].string.isRequired,
301
+ name: _propTypes["default"].string.isRequired,
299
302
  downloadLink: _propTypes["default"].string,
300
303
  status: _propTypes["default"].oneOf((0, _values["default"])(_statuses["default"]))
301
304
  })),
@@ -303,8 +306,8 @@ FileInputField.propTypes = {
303
306
  /** Default array of objects for uploaded files. */
304
307
  defaultFileList: _propTypes["default"].arrayOf(_propTypes["default"].shape({
305
308
  fileObj: _propTypes["default"].shape({}),
306
- id: _propTypes["default"].string.required,
307
- name: _propTypes["default"].string.required,
309
+ id: _propTypes["default"].string.isRequired,
310
+ name: _propTypes["default"].string.isRequired,
308
311
  downloadLink: _propTypes["default"].string,
309
312
  status: _propTypes["default"].oneOf((0, _values["default"])(_statuses["default"]))
310
313
  })),
@@ -168,7 +168,7 @@ LinkSelectField.propTypes = {
168
168
  * *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
169
169
  * For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
170
170
  */
171
- items: _propTypes["default"].arrayOf(_propTypes["default"].any),
171
+ items: _propTypes["default"].arrayOf(_propTypes["default"].shape({})),
172
172
 
173
173
  /** The label for the select element. */
174
174
  label: _propTypes["default"].node,
@@ -124,7 +124,10 @@ Option.propTypes = {
124
124
  hasVirtualFocus: _propTypes["default"].bool,
125
125
  item: _propTypes["default"].shape({
126
126
  key: _propTypes["default"].string,
127
- props: _propTypes["default"].shape({}),
127
+ props: _propTypes["default"].shape({
128
+ 'data-id': _propTypes["default"].string,
129
+ isSeparator: _propTypes["default"].bool
130
+ }),
128
131
  rendered: _propTypes["default"].node
129
132
  }),
130
133
  state: _propTypes["default"].shape({
@@ -174,7 +174,8 @@ MenuItem.propTypes = {
174
174
  key: _propTypes["default"].string,
175
175
  props: _propTypes["default"].shape({
176
176
  'data-id': _propTypes["default"].string,
177
- isSeparator: _propTypes["default"].bool
177
+ isSeparator: _propTypes["default"].bool,
178
+ isPressed: _propTypes["default"].bool
178
179
  }),
179
180
  rendered: _propTypes["default"].node,
180
181
  isDisabled: _propTypes["default"].bool
@@ -184,7 +184,8 @@ Message.propTypes = {
184
184
  icon: _propTypes["default"].elementType,
185
185
 
186
186
  /* Hides the message with an animated transition */
187
- isHidden: _propTypes["default"].bool
187
+ isHidden: _propTypes["default"].bool,
188
+ 'data-id': _propTypes["default"].string
188
189
  })
189
190
  }),
190
191
 
@@ -38,11 +38,17 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "functi
38
38
 
39
39
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
40
40
 
41
+ /**
42
+ * A `Page Header` is a composed component using text and icon button.
43
+ * The component is separated from the body and appears at the top.
44
+ * For customization,
45
+ * please see [Page Header](./?path=/story/recipes-page-header--default) recipe docs.
46
+ */
41
47
  var PageHeader = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
42
48
  var title = props.title,
43
49
  children = props.children,
44
50
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
45
- (0, _hooks.useDeprecationWarning)('The Page Header component will be deprecated in Astro-UI 2.0.0.');
51
+ (0, _hooks.useDeprecationWarning)('The Page Header component will be deprecated in Astro-UI 2.0.0. Use Page Header recipe instead.');
46
52
  return (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
47
53
  isRow: true,
48
54
  justifyContent: "space-between",
@@ -104,7 +104,7 @@ SelectField.propTypes = {
104
104
  * *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
105
105
  * For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
106
106
  */
107
- items: _propTypes["default"].arrayOf(_propTypes["default"].any),
107
+ items: _propTypes["default"].arrayOf(_propTypes["default"].shape({})),
108
108
 
109
109
  /** The label for the select element. */
110
110
  label: _propTypes["default"].node,
@@ -46,7 +46,7 @@ var _ = require("../..");
46
46
 
47
47
  var _react2 = require("@emotion/react");
48
48
 
49
- var _excluded = ["icon", "isDisabled", "separator", "tabLabelProps", "tabLineProps", "content", "titleAttr"];
49
+ var _excluded = ["icon", "isDisabled", "separator", "tabLabelProps", "tabLineProps", "content", "titleAttr", "title"];
50
50
 
51
51
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
52
52
 
@@ -74,6 +74,7 @@ var CollectionTab = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
74
74
  tabLineProps = itemProps.tabLineProps,
75
75
  content = itemProps.content,
76
76
  titleAttr = itemProps.titleAttr,
77
+ title = itemProps.title,
77
78
  otherItemProps = (0, _objectWithoutProperties2["default"])(itemProps, _excluded);
78
79
  var state = (0, _react.useContext)(_Tabs.TabsContext);
79
80
  var isDisabled = tabsDisabled || tabDisabled || state.disabledKeys.has(key);
@@ -149,9 +150,19 @@ CollectionTab.propTypes = {
149
150
  isDisabled: _propTypes["default"].bool,
150
151
  item: _propTypes["default"].shape({
151
152
  key: _propTypes["default"].string,
152
- props: _propTypes["default"].shape({}),
153
- rendered: _propTypes["default"].node,
154
- tabLineProps: _propTypes["default"].shape({})
153
+ props: _propTypes["default"].shape({
154
+ icon: _propTypes["default"].shape({}),
155
+ isDisabled: _propTypes["default"].bool,
156
+ textValue: _propTypes["default"].string,
157
+ tabLineProps: _propTypes["default"].shape({}),
158
+ tabLabelProps: _propTypes["default"].shape({}),
159
+ content: _propTypes["default"].shape({}),
160
+ titleAttr: _propTypes["default"].string,
161
+ title: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].string, _propTypes["default"].object]),
162
+ separator: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].bool]),
163
+ list: _propTypes["default"].arrayOf(_propTypes["default"].shape({}))
164
+ }),
165
+ rendered: _propTypes["default"].node
155
166
  }),
156
167
  mode: _propTypes["default"].oneOf(['default', 'tooltip', 'list']),
157
168
  orientation: _propTypes["default"].oneOf(['horizontal', 'vertical']),
@@ -246,10 +246,10 @@ TabPicker.propTypes = {
246
246
  state: _propTypes["default"].shape({
247
247
  collection: _propTypes["default"].shape({}),
248
248
  selectedKey: _propTypes["default"].string,
249
- setSelectedKey: _propTypes["default"]["function"],
249
+ setSelectedKey: _propTypes["default"].func,
250
250
  selectionManager: _propTypes["default"].shape({
251
251
  focusedKey: _propTypes["default"].string,
252
- setFocusedKey: _propTypes["default"]["function"]
252
+ setFocusedKey: _propTypes["default"].func
253
253
  })
254
254
  })
255
255
  };
@@ -12,7 +12,7 @@ test('default useOverlayPanelState', function () {
12
12
  }),
13
13
  result = _renderHook.result;
14
14
 
15
- expect(result.current).toEqual(expect.objectContaining({
15
+ var obj = {
16
16
  state: {
17
17
  open: expect.any(Function),
18
18
  close: expect.any(Function),
@@ -20,5 +20,6 @@ test('default useOverlayPanelState', function () {
20
20
  isOpen: expect.any(Boolean)
21
21
  },
22
22
  onClose: expect.any(Function)
23
- }));
23
+ };
24
+ expect(result.current).toEqual(obj);
24
25
  });
@@ -143,7 +143,15 @@ var useSelectField = function useSelectField(props, ref) {
143
143
  labelProps = _useSelect.labelProps,
144
144
  triggerProps = _useSelect.triggerProps,
145
145
  valueProps = _useSelect.valueProps,
146
- menuProps = _useSelect.menuProps;
146
+ menuProps = _useSelect.menuProps; // The following props are being passed into multiple
147
+ // DOM elements that leads to multiple test failures
148
+ // and these props are never used in any components
149
+ // that depend on useSelectField
150
+
151
+
152
+ delete menuProps.shouldSelectOnPressUp;
153
+ delete menuProps.shouldFocusOnHover;
154
+ delete menuProps.disallowEmptySelection;
147
155
 
148
156
  var _useField = (0, _.useField)(_objectSpread(_objectSpread({}, props), {}, {
149
157
  placeholder: props.labelMode === _constants.modes.FLOAT ? '' : placeholder,
@@ -50,6 +50,28 @@ var validatePhoneNumber = function validatePhoneNumber(str) {
50
50
  return reg.test(str);
51
51
  };
52
52
 
53
+ var sx = {
54
+ wrapperBox: {
55
+ width: '100%',
56
+ maxWidth: 500,
57
+ position: 'relative'
58
+ },
59
+ comboBoxFieldWrapperOpen: {
60
+ position: 'absolute',
61
+ transition: '0.2s width ease',
62
+ width: '100%'
63
+ },
64
+ comboBoxFieldWrapperClose: {
65
+ position: 'absolute',
66
+ transition: '0.2s width ease',
67
+ width: '110px'
68
+ },
69
+ inputWrapper: {
70
+ width: '100%',
71
+ marginLeft: '110px'
72
+ }
73
+ };
74
+
53
75
  var Default = function Default() {
54
76
  var _useState = (0, _react.useState)(false),
55
77
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
@@ -117,22 +139,14 @@ var Default = function Default() {
117
139
 
118
140
  return (0, _react2.jsx)(_Box["default"], {
119
141
  isRow: true,
120
- sx: {
121
- width: '100%',
122
- maxWidth: 500,
123
- position: 'relative'
124
- }
142
+ sx: sx.wrapperBox
125
143
  }, (0, _react2.jsx)(_ComboBoxField["default"], {
126
144
  mt: -5,
127
145
  width: "100%",
128
146
  isOpen: isOpen,
129
147
  onOpenChange: setIsOpen,
130
148
  wrapperProps: {
131
- sx: {
132
- position: 'absolute',
133
- transition: '0.2s width ease',
134
- width: isOpen ? '100%' : 110
135
- }
149
+ sx: isOpen ? sx.comboBoxFieldWrapperOpen : sx.comboBoxFieldWrapperClose
136
150
  },
137
151
  controlProps: {
138
152
  'aria-label': 'Country Picker'
@@ -151,8 +165,7 @@ var Default = function Default() {
151
165
  key: item[0]
152
166
  }, (0, _concat["default"])(_context = (0, _concat["default"])(_context2 = "".concat(item[1].name)).call(_context2, item[1].name !== item[1]["native"] ? " (".concat(item[1]["native"], ")") : '', " +")).call(_context, item[1].phone.split(',')[0]));
153
167
  }), (0, _react2.jsx)(_Box["default"], {
154
- width: "100%",
155
- ml: 110
168
+ sx: sx.inputWrapper
156
169
  }, (0, _react2.jsx)(_Input["default"], {
157
170
  placeholder: "Phone number...",
158
171
  onChange: onPhoneNumberValueChange,
@@ -70,6 +70,48 @@ var inputProps = {
70
70
  label: 'Example label',
71
71
  ariaLabel: 'Example aria label'
72
72
  };
73
+ var sx = {
74
+ editablePreview: {
75
+ whiteSpace: 'pre-line',
76
+ width: '100%',
77
+ overflowWrap: 'break-word',
78
+ minHeight: '45px',
79
+ paddingLeft: 'xs',
80
+ justifyContent: 'flex-end',
81
+ paddingBottom: 'xs',
82
+ borderBottomColor: 'active',
83
+ color: 'neutral.10',
84
+ fontSize: 'md',
85
+ fontWeight: 1,
86
+ lineHeight: '18px',
87
+ '&:focus': {
88
+ outline: 'none',
89
+ boxShadow: 'focus',
90
+ borderColor: 'active',
91
+ borderWidth: '1px',
92
+ borderStyle: 'solid'
93
+ }
94
+ },
95
+ editableInputWrapper: {
96
+ marginRight: '30px',
97
+ flexGrow: 1
98
+ },
99
+ editableInpuTextArea: {
100
+ maxHeight: '150px'
101
+ },
102
+ editableControlWrapper: {
103
+ position: 'absolute',
104
+ right: '0',
105
+ top: '27.5%',
106
+ alignItems: 'center',
107
+ justifyContent: 'space-between'
108
+ },
109
+ editableControlIconButton: {
110
+ marginRight: 'md',
111
+ width: '20px',
112
+ height: '20px'
113
+ }
114
+ };
73
115
 
74
116
  var Default = function Default() {
75
117
  return (0, _react2.jsx)(Editable, {
@@ -127,6 +169,13 @@ var EditablePreview = function EditablePreview() {
127
169
  hasFocus = _useState4[0],
128
170
  setFocus = _useState4[1];
129
171
 
172
+ var editablePreviewDynamicSx = {
173
+ backgroundColor: hasFocus ? 'accent.95' : 'white',
174
+ borderBottom: editableContext.isEditing ? '0px' : '1px dashed',
175
+ '&:hover': {
176
+ background: editableContext.isEditing ? 'white' : 'accent.95'
177
+ }
178
+ };
130
179
  (0, _react.useEffect)(function () {
131
180
  if (hasFocus && editableContext.isEditing) {
132
181
  setFocus(false);
@@ -153,8 +202,8 @@ var EditablePreview = function EditablePreview() {
153
202
  "aria-hidden": editableContext.isEditing,
154
203
  onClick: handleClick,
155
204
  onKeyDown: handleKeyDown,
156
- "aria-readonly": "false",
157
205
  "aria-label": "Inline editable text field",
206
+ role: "textbox",
158
207
  onFocus: function onFocus() {
159
208
  return setFocus(true);
160
209
  },
@@ -162,32 +211,7 @@ var EditablePreview = function EditablePreview() {
162
211
  return setFocus(false);
163
212
  },
164
213
  placeholder: "Click or press enter to edit text",
165
- sx: {
166
- whiteSpace: 'pre-line',
167
- backgroundColor: hasFocus ? 'accent.95' : 'white',
168
- width: '100%',
169
- overflowWrap: 'break-word',
170
- minHeight: '45px',
171
- paddingLeft: 'xs',
172
- justifyContent: 'flex-end',
173
- paddingBottom: 'xs',
174
- borderBottom: editableContext.isEditing ? '0px' : '1px dashed',
175
- borderBottomColor: 'active',
176
- color: 'neutral.10',
177
- fontSize: 'md',
178
- fontWeight: 1,
179
- lineHeight: '18px',
180
- '&:hover': {
181
- background: editableContext.isEditing ? 'white' : 'accent.95'
182
- },
183
- '&:focus': {
184
- outline: 'none',
185
- boxShadow: 'focus',
186
- borderColor: 'active',
187
- borderWidth: '1px',
188
- borderStyle: 'solid'
189
- }
190
- }
214
+ sx: _objectSpread(_objectSpread({}, editablePreviewDynamicSx), sx.editablePreview)
191
215
  }, editableContext.value);
192
216
  };
193
217
  /**
@@ -256,10 +280,7 @@ var EditableInput = function EditableInput(props) {
256
280
  return (0, _react2.jsx)(_index.Box, {
257
281
  display: editableContext.isEditing ? 'flex' : 'none',
258
282
  "aria-hidden": !editableContext.isEditing,
259
- sx: {
260
- marginRight: '30px',
261
- flexGrow: 1
262
- }
283
+ sx: sx.editableInputWrapper
263
284
  }, (0, _react2.jsx)(_index.TextAreaField, {
264
285
  rows: 1,
265
286
  ref: editableInput,
@@ -270,9 +291,7 @@ var EditableInput = function EditableInput(props) {
270
291
  onKeyDown: handleKeyDown,
271
292
  value: editingValue,
272
293
  "aria-label": ariaLabel,
273
- sx: {
274
- maxHeight: '150px'
275
- },
294
+ sx: sx.editableInpuTextArea,
276
295
  isUnresizable: true
277
296
  }));
278
297
  };
@@ -323,22 +342,12 @@ var EditableControl = function EditableControl(props) {
323
342
  display: editableContext.isEditing ? 'flex' : 'none',
324
343
  "aria-hidden": !editableContext.isEditing,
325
344
  isRow: true,
326
- sx: {
327
- position: 'absolute',
328
- right: '0',
329
- top: '27.5%',
330
- alignItems: 'center',
331
- justifyContent: 'space-between'
332
- }
345
+ sx: sx.editableControlWrapper
333
346
  }, (0, _react2.jsx)(_index.IconButton, {
334
347
  onPress: handleSubmit,
335
348
  "aria-label": confirmBtn.ariaLabel,
336
349
  variant: confirmBtn.variant,
337
- mr: "15px",
338
- sx: {
339
- width: '20px',
340
- height: '20px'
341
- }
350
+ sx: sx.editableControlIconButton
342
351
  }, (0, _react2.jsx)(_index.Icon, {
343
352
  icon: _CheckIcon["default"]
344
353
  })), (0, _react2.jsx)(_index.IconButton, {