@pingux/astro 2.64.0 → 2.65.0-alpha.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.
Files changed (32) hide show
  1. package/lib/cjs/components/ArrayField/ArrayField.d.ts +4 -0
  2. package/lib/cjs/components/ArrayField/ArrayField.js +9 -42
  3. package/lib/cjs/components/ArrayField/ArrayField.stories.d.ts +11 -0
  4. package/lib/cjs/components/ArrayField/ArrayField.stories.js +4 -2
  5. package/lib/cjs/components/ArrayField/ArrayField.test.d.ts +1 -0
  6. package/lib/cjs/components/ArrayField/ArrayField.test.js +1 -3
  7. package/lib/cjs/components/ArrayField/ArrayFieldDeleteButton.d.ts +4 -0
  8. package/lib/cjs/components/ArrayField/ArrayFieldDeleteButton.js +1 -7
  9. package/lib/cjs/components/ArrayField/index.d.ts +2 -0
  10. package/lib/cjs/components/Calendar/Calendar.stories.d.ts +18 -18
  11. package/lib/cjs/components/ComboBox/ComboBoxInput.js +1 -1
  12. package/lib/cjs/components/ListView/ListView.stories.d.ts +18 -18
  13. package/lib/cjs/components/ListView/listViewAttributes.d.ts +18 -18
  14. package/lib/cjs/types/arrayField.d.ts +46 -0
  15. package/lib/cjs/types/arrayField.js +6 -0
  16. package/lib/cjs/types/callout.d.ts +2 -1
  17. package/lib/cjs/types/fieldHelperText.d.ts +2 -1
  18. package/lib/cjs/types/index.d.ts +1 -0
  19. package/lib/cjs/types/index.js +54 -43
  20. package/lib/cjs/types/item.d.ts +1 -3
  21. package/lib/cjs/types/requirementsList.d.ts +2 -1
  22. package/lib/cjs/utils/docUtils/ariaAttributes.d.ts +21 -21
  23. package/lib/cjs/utils/docUtils/ariaAttributes.js +3 -3
  24. package/lib/components/ArrayField/ArrayField.js +10 -43
  25. package/lib/components/ArrayField/ArrayField.stories.js +4 -2
  26. package/lib/components/ArrayField/ArrayField.test.js +1 -3
  27. package/lib/components/ArrayField/ArrayFieldDeleteButton.js +1 -7
  28. package/lib/components/ComboBox/ComboBoxInput.js +1 -1
  29. package/lib/types/arrayField.js +1 -0
  30. package/lib/types/index.js +1 -0
  31. package/lib/utils/docUtils/ariaAttributes.js +3 -3
  32. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ArrayFieldProps } from '../../types';
3
+ declare const ArrayField: React.ForwardRefExoticComponent<ArrayFieldProps & React.RefAttributes<HTMLDivElement>>;
4
+ export default ArrayField;
@@ -24,14 +24,11 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/hel
24
24
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
25
25
  var _react = _interopRequireWildcard(require("react"));
26
26
  var _reactAria = require("react-aria");
27
- var _propTypes = _interopRequireDefault(require("prop-types"));
28
27
  var _uuid = require("uuid");
29
28
  var _ = require("../..");
30
29
  var _pendoID = require("../../utils/devUtils/constants/pendoID");
31
30
  var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
32
- var _isValidPositiveInt = _interopRequireDefault(require("../../utils/devUtils/props/isValidPositiveInt"));
33
31
  var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
34
- var _statusProp = require("../../utils/docUtils/statusProp");
35
32
  var _react2 = require("@emotion/react");
36
33
  var _excluded = ["addButtonLabel", "defaultValue", "fieldControlWrapperProps", "value", "label", "helperText", "status", "onAdd", "onChange", "onDelete", "renderField", "labelProps", "maxSize", "maxSizeText"],
37
34
  _excluded2 = ["id", "onComponentRender", "fieldValue"];
@@ -91,7 +88,7 @@ var ArrayField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
91
88
  if (typeof event !== 'string') {
92
89
  tempValue = event.target.value;
93
90
  }
94
- if (isControlled) {
91
+ if (isControlled && onChangeRef.current) {
95
92
  onChangeRef.current(mapArrayFieldWithNewValue(valueRef.current, tempValue, fieldId));
96
93
  } else {
97
94
  setFieldValues(function (oldValues) {
@@ -100,7 +97,7 @@ var ArrayField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
100
97
  }
101
98
  }, [isControlled, mapArrayFieldWithNewValue]);
102
99
  var onFieldDelete = (0, _react.useCallback)(function (fieldId) {
103
- if (isControlled) {
100
+ if (isControlled && onDeleteRef.current) {
104
101
  onDeleteRef.current(fieldId);
105
102
  } else {
106
103
  setFieldValues(function (oldValues) {
@@ -113,7 +110,7 @@ var ArrayField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
113
110
  }, [isControlled]);
114
111
  var onFieldAdd = (0, _react.useCallback)(function () {
115
112
  if (isControlled) {
116
- return onAddRef.current();
113
+ return onAddRef.current && onAddRef.current();
117
114
  }
118
115
  return setFieldValues(function (oldValues) {
119
116
  var _context;
@@ -128,7 +125,10 @@ var ArrayField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
128
125
  if (onComponentRender) {
129
126
  return onComponentRender(id, fieldValue, onFieldValueChange, onFieldDelete, isDisabled, labelId, otherFieldProps);
130
127
  }
131
- return renderField(id, fieldValue, onFieldValueChange, onFieldDelete, isDisabled, otherFieldProps);
128
+ if (renderField) {
129
+ return renderField(id, fieldValue, onFieldValueChange, onFieldDelete, isDisabled, otherFieldProps);
130
+ }
131
+ return null;
132
132
  }, [onFieldValueChange, onFieldDelete, renderField, isDisabled]);
133
133
  var _getAriaAttributeProp = (0, _ariaAttributes.getAriaAttributeProps)(others),
134
134
  ariaProps = _getAriaAttributeProp.ariaProps,
@@ -167,42 +167,9 @@ var ArrayField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
167
167
  color: "active"
168
168
  }, addButtonLabel)));
169
169
  });
170
- ArrayField.propTypes = _objectSpread(_objectSpread({
171
- /** Label for add button */
172
- addButtonLabel: _propTypes["default"].string,
173
- /** The default value for the array input field (uncontrolled). */
174
- defaultValue: _propTypes["default"].arrayOf(_propTypes["default"].shape({
175
- id: _propTypes["default"].string,
176
- value: _propTypes["default"].string
177
- })),
178
- /** The default value of the array input field (controlled). */
179
- value: _propTypes["default"].arrayOf(_propTypes["default"].shape({
180
- id: _propTypes["default"].string,
181
- value: _propTypes["default"].string
182
- })),
183
- /** The rendered label for the field. */
184
- label: _propTypes["default"].node,
185
- /** Props object that is spread directly into the label element. */
186
- labelProps: _propTypes["default"].shape({}),
187
- /** Props object that is spread directly into the wrapper rendering the fields. */
188
- fieldControlWrapperProps: _propTypes["default"].shape({}),
189
- /** Text to display before add button. Useful for errors or other info. */
190
- helperText: _propTypes["default"].node,
191
- /** Callback for changing array field data */
192
- onChange: _propTypes["default"].func,
193
- /** Callback for adding new empty field */
194
- onAdd: _propTypes["default"].func,
195
- /** Callback for deleting a field */
196
- onDelete: _propTypes["default"].func,
197
- /** Render prop to display an input field */
198
- renderField: _propTypes["default"].func,
199
- /** Determines the maximum number of items */
200
- maxSize: _isValidPositiveInt["default"],
201
- /** Text to display when the maximum number of items is reached */
202
- maxSizeText: _propTypes["default"].node
203
- }, _statusProp.statusPropTypes), _ariaAttributes.ariaAttributesBasePropTypes);
204
170
  ArrayField.defaultProps = {
205
- addButtonLabel: '+ Add'
171
+ addButtonLabel: '+ Add',
172
+ status: _statuses["default"].DEFAULT
206
173
  };
207
174
  var _default = ArrayField;
208
175
  exports["default"] = _default;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { StoryFn } from '@storybook/react';
3
+ import { ArrayFieldProps } from '../../types';
4
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
5
+ export default _default;
6
+ export declare const Uncontrolled: StoryFn<ArrayFieldProps>;
7
+ export declare const Controlled: StoryFn<ArrayFieldProps>;
8
+ export declare const WithLimitedItemsNumber: StoryFn<ArrayFieldProps>;
9
+ export declare const Customizations: ({ ...args }: {
10
+ [x: string]: any;
11
+ }) => React.JSX.Element;
@@ -63,7 +63,7 @@ var _default = {
63
63
  },
64
64
  maxSize: {
65
65
  control: {
66
- type: 'number'
66
+ type: 'text'
67
67
  }
68
68
  },
69
69
  maxSizeText: {
@@ -286,7 +286,9 @@ var Customizations = function Customizations(_ref5) {
286
286
  maxHeight: '150px'
287
287
  },
288
288
  defaultValue: defaultData,
289
- width: "450px",
289
+ sx: {
290
+ width: '450px'
291
+ },
290
292
  labelProps: {
291
293
  hintText: 'Example Hint',
292
294
  isRequired: true,
@@ -0,0 +1 @@
1
+ export {};
@@ -201,9 +201,7 @@ test('creates empty field when no data passed', function () {
201
201
  expect(_testWrapper.screen.getByLabelText('Text field')).toBeInTheDocument();
202
202
  });
203
203
  test('check if tooltip on delete button renders on hover', function () {
204
- (0, _testWrapper.render)((0, _react2.jsx)(_ArrayFieldDeleteButton["default"], {
205
- renderField: renderField
206
- }));
204
+ (0, _testWrapper.render)((0, _react2.jsx)(_ArrayFieldDeleteButton["default"], null));
207
205
  var button = _testWrapper.screen.getByRole('button');
208
206
  _testWrapper.fireEvent.mouseMove(button);
209
207
  _testWrapper.fireEvent.mouseEnter(button);
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ArrayFieldDeleteButtonProps } from '../../types';
3
+ declare const ArrayFieldDeleteButton: FC<ArrayFieldDeleteButtonProps>;
4
+ export default ArrayFieldDeleteButton;
@@ -8,7 +8,6 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  exports["default"] = void 0;
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _TrashIcon = _interopRequireDefault(require("@pingux/mdi-react/TrashIcon"));
11
- var _propTypes = _interopRequireDefault(require("prop-types"));
12
11
  var _Icon = _interopRequireDefault(require("../Icon"));
13
12
  var _IconButton = _interopRequireDefault(require("../IconButton"));
14
13
  var _react2 = require("@emotion/react");
@@ -18,7 +17,7 @@ var ArrayFieldDeleteButton = function ArrayFieldDeleteButton(_ref) {
18
17
  onDelete = _ref.onDelete;
19
18
  return (0, _react2.jsx)(_IconButton["default"], {
20
19
  onPress: function onPress() {
21
- return onDelete(id);
20
+ return onDelete && onDelete(id);
22
21
  },
23
22
  isDisabled: isDisabled,
24
23
  "aria-label": "delete-button",
@@ -39,10 +38,5 @@ var ArrayFieldDeleteButton = function ArrayFieldDeleteButton(_ref) {
39
38
  }
40
39
  }));
41
40
  };
42
- ArrayFieldDeleteButton.propTypes = {
43
- id: _propTypes["default"].number,
44
- isDisabled: _propTypes["default"].bool,
45
- onDelete: _propTypes["default"].func
46
- };
47
41
  var _default = ArrayFieldDeleteButton;
48
42
  exports["default"] = _default;
@@ -0,0 +1,2 @@
1
+ export { default } from './ArrayField';
2
+ export { default as ArrayFieldDeleteButton } from './ArrayFieldDeleteButton';
@@ -18,73 +18,73 @@ declare const _default: {
18
18
  };
19
19
  argTypes: {
20
20
  'aria-controls': {
21
- type: {
22
- summary: string;
23
- };
24
21
  control: {
25
22
  type: string;
26
23
  };
27
24
  table: {
25
+ type: {
26
+ summary: string;
27
+ };
28
28
  category: string;
29
29
  };
30
30
  description: string;
31
31
  };
32
32
  'aria-describedby': {
33
- type: {
34
- summary: string;
35
- };
36
33
  control: {
37
34
  type: string;
38
35
  };
39
36
  table: {
37
+ type: {
38
+ summary: string;
39
+ };
40
40
  category: string;
41
41
  };
42
42
  description: string;
43
43
  };
44
44
  'aria-details': {
45
- type: {
46
- summary: string;
47
- };
48
45
  control: {
49
46
  type: string;
50
47
  };
51
48
  table: {
49
+ type: {
50
+ summary: string;
51
+ };
52
52
  category: string;
53
53
  };
54
54
  description: string;
55
55
  };
56
56
  'aria-errormessage': {
57
- type: {
58
- summary: string;
59
- };
60
57
  control: {
61
58
  type: string;
62
59
  };
63
60
  table: {
61
+ type: {
62
+ summary: string;
63
+ };
64
64
  category: string;
65
65
  };
66
66
  description: string;
67
67
  };
68
68
  'aria-label': {
69
- type: {
70
- summary: string;
71
- };
72
69
  control: {
73
70
  type: string;
74
71
  };
75
72
  table: {
73
+ type: {
74
+ summary: string;
75
+ };
76
76
  category: string;
77
77
  };
78
78
  description: string;
79
79
  };
80
80
  'aria-labelledby': {
81
- type: {
82
- summary: string;
83
- };
84
81
  control: {
85
82
  type: string;
86
83
  };
87
84
  table: {
85
+ type: {
86
+ summary: string;
87
+ };
88
88
  category: string;
89
89
  };
90
90
  description: string;
@@ -130,7 +130,7 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
130
130
  transform: 'rotate(180deg)'
131
131
  } : null,
132
132
  title: {
133
- name: 'Menu Down Icon'
133
+ name: 'Menu Down'
134
134
  }
135
135
  }))));
136
136
  return (0, _react2.jsx)(_reactAria.FocusRing, {
@@ -38,49 +38,49 @@ declare const _default: {
38
38
  description: string;
39
39
  };
40
40
  'aria-label': {
41
- type: {
42
- summary: string;
43
- };
44
41
  control: {
45
42
  type: string;
46
43
  };
47
44
  table: {
45
+ type: {
46
+ summary: string;
47
+ };
48
48
  category: string;
49
49
  };
50
50
  description: string;
51
51
  };
52
52
  'aria-labelledby': {
53
- type: {
54
- summary: string;
55
- };
56
53
  control: {
57
54
  type: string;
58
55
  };
59
56
  table: {
57
+ type: {
58
+ summary: string;
59
+ };
60
60
  category: string;
61
61
  };
62
62
  description: string;
63
63
  };
64
64
  'aria-describedby': {
65
- type: {
66
- summary: string;
67
- };
68
65
  control: {
69
66
  type: string;
70
67
  };
71
68
  table: {
69
+ type: {
70
+ summary: string;
71
+ };
72
72
  category: string;
73
73
  };
74
74
  description: string;
75
75
  };
76
76
  'aria-details': {
77
- type: {
78
- summary: string;
79
- };
80
77
  control: {
81
78
  type: string;
82
79
  };
83
80
  table: {
81
+ type: {
82
+ summary: string;
83
+ };
84
84
  category: string;
85
85
  };
86
86
  description: string;
@@ -99,25 +99,25 @@ declare const _default: {
99
99
  description: string;
100
100
  };
101
101
  'aria-controls': {
102
- type: {
103
- summary: string;
104
- };
105
102
  control: {
106
103
  type: string;
107
104
  };
108
105
  table: {
106
+ type: {
107
+ summary: string;
108
+ };
109
109
  category: string;
110
110
  };
111
111
  description: string;
112
112
  };
113
113
  'aria-errormessage': {
114
- type: {
115
- summary: string;
116
- };
117
114
  control: {
118
115
  type: string;
119
116
  };
120
117
  table: {
118
+ type: {
119
+ summary: string;
120
+ };
121
121
  category: string;
122
122
  };
123
123
  description: string;
@@ -26,49 +26,49 @@ export declare const listViewArgTypes: {
26
26
  description: string;
27
27
  };
28
28
  'aria-label': {
29
- type: {
30
- summary: string;
31
- };
32
29
  control: {
33
30
  type: string;
34
31
  };
35
32
  table: {
33
+ type: {
34
+ summary: string;
35
+ };
36
36
  category: string;
37
37
  };
38
38
  description: string;
39
39
  };
40
40
  'aria-labelledby': {
41
- type: {
42
- summary: string;
43
- };
44
41
  control: {
45
42
  type: string;
46
43
  };
47
44
  table: {
45
+ type: {
46
+ summary: string;
47
+ };
48
48
  category: string;
49
49
  };
50
50
  description: string;
51
51
  };
52
52
  'aria-describedby': {
53
- type: {
54
- summary: string;
55
- };
56
53
  control: {
57
54
  type: string;
58
55
  };
59
56
  table: {
57
+ type: {
58
+ summary: string;
59
+ };
60
60
  category: string;
61
61
  };
62
62
  description: string;
63
63
  };
64
64
  'aria-details': {
65
- type: {
66
- summary: string;
67
- };
68
65
  control: {
69
66
  type: string;
70
67
  };
71
68
  table: {
69
+ type: {
70
+ summary: string;
71
+ };
72
72
  category: string;
73
73
  };
74
74
  description: string;
@@ -87,25 +87,25 @@ export declare const listViewArgTypes: {
87
87
  description: string;
88
88
  };
89
89
  'aria-controls': {
90
- type: {
91
- summary: string;
92
- };
93
90
  control: {
94
91
  type: string;
95
92
  };
96
93
  table: {
94
+ type: {
95
+ summary: string;
96
+ };
97
97
  category: string;
98
98
  };
99
99
  description: string;
100
100
  };
101
101
  'aria-errormessage': {
102
- type: {
103
- summary: string;
104
- };
105
102
  control: {
106
103
  type: string;
107
104
  };
108
105
  table: {
106
+ type: {
107
+ summary: string;
108
+ };
109
109
  category: string;
110
110
  };
111
111
  description: string;
@@ -0,0 +1,46 @@
1
+ /// <reference types="react" />
2
+ import { ThemeUICSSObject } from 'theme-ui';
3
+ import { LabelProps, Status, ValidPositiveInteger } from '.';
4
+ type RenderFieldFunction = (id: string, fieldValue: string, onFieldValueChange: (e: React.ChangeEvent<HTMLInputElement> | string, fieldId: string) => void, onFieldDelete: (fieldId: string) => void, isDisabled: boolean, otherFieldProps?: Record<string, string>) => React.ReactNode;
5
+ export interface FieldValue {
6
+ id: string;
7
+ value?: string;
8
+ onComponentRender?: RenderFieldFunction;
9
+ fieldValue?: string;
10
+ }
11
+ export interface ArrayFieldProps {
12
+ /** Label for add button */
13
+ addButtonLabel?: string;
14
+ /** The default value for the array input field (uncontrolled). */
15
+ defaultValue?: FieldValue[];
16
+ /** The default value of the array input field (controlled). */
17
+ value?: FieldValue[];
18
+ /** The rendered label for the field. */
19
+ label?: React.ReactNode;
20
+ /** Props object that is spread directly into the label element. */
21
+ labelProps?: LabelProps;
22
+ /** Text to display before add button. Useful for errors or other info. */
23
+ helperText?: React.ReactNode;
24
+ /** Callback for changing array field data */
25
+ onChange?: (value: FieldValue[]) => void;
26
+ /** Callback for adding new empty field */
27
+ onAdd?: () => void;
28
+ /** Callback for deleting a field */
29
+ onDelete?: (fieldId: string) => void;
30
+ /** Render prop to display an input field */
31
+ renderField?: RenderFieldFunction;
32
+ /** Determines the maximum number of items */
33
+ maxSize?: ValidPositiveInteger;
34
+ /** Text to display when the maximum number of items is reached */
35
+ maxSizeText?: React.ReactNode;
36
+ sx?: ThemeUICSSObject;
37
+ status?: Status;
38
+ /** Props object that is spread directly into the wrapper rendering the fields. */
39
+ fieldControlWrapperProps?: Record<string, string>;
40
+ }
41
+ export interface ArrayFieldDeleteButtonProps {
42
+ id?: number;
43
+ isDisabled?: boolean;
44
+ onDelete?: (id?: number) => void;
45
+ }
46
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
@@ -1,4 +1,5 @@
1
1
  import { Status } from './item';
2
2
  import { DOMAttributes, StyleProps } from './shared';
3
- export interface CalloutProps extends StyleProps, DOMAttributes, Status {
3
+ export interface CalloutProps extends StyleProps, DOMAttributes {
4
+ status?: Status;
4
5
  }
@@ -2,7 +2,8 @@ import React from 'react';
2
2
  import { TestingAttributes } from './shared/test';
3
3
  import { Status } from './item';
4
4
  import { TextProps } from './text';
5
- export interface FieldHelperTextProps extends TestingAttributes, TextProps, Status {
5
+ export interface FieldHelperTextProps extends TestingAttributes, TextProps {
6
6
  className?: string;
7
+ status?: Status;
7
8
  children?: React.ReactNode;
8
9
  }
@@ -1,3 +1,4 @@
1
+ export * from './arrayField';
1
2
  export * from './badge';
2
3
  export * from './box';
3
4
  export * from './bracket';