@pingux/astro 2.242.0-alpha.0 → 2.243.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 (35) hide show
  1. package/lib/cjs/components/CodeView/CodeView.js +8 -4
  2. package/lib/cjs/components/CopyText/CopyButton.js +2 -7
  3. package/lib/cjs/components/CopyText/CopyText.js +10 -3
  4. package/lib/cjs/components/MultivaluesField/BadgeLabelTooltip.d.ts +3 -0
  5. package/lib/cjs/components/MultivaluesField/BadgeLabelTooltip.js +3 -3
  6. package/lib/cjs/components/MultivaluesField/CondensedMultivaluesField.d.ts +4 -0
  7. package/lib/cjs/components/MultivaluesField/CondensedMultivaluesField.js +24 -132
  8. package/lib/cjs/components/MultivaluesField/DefaultMultivaluesField.d.ts +4 -0
  9. package/lib/cjs/components/MultivaluesField/DefaultMultivaluesField.js +33 -139
  10. package/lib/cjs/components/MultivaluesField/MultivaluesField.d.ts +4 -0
  11. package/lib/cjs/components/MultivaluesField/MultivaluesField.js +6 -104
  12. package/lib/cjs/components/MultivaluesField/index.d.ts +1 -0
  13. package/lib/cjs/components/RadioGroupField/RadioGroupField.js +1 -1
  14. package/lib/cjs/styles/themes/next-gen/codeView/codeView.d.ts +6 -42
  15. package/lib/cjs/styles/themes/next-gen/codeView/codeView.js +2 -14
  16. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +10 -70
  17. package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +2 -14
  18. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +4 -28
  19. package/lib/cjs/types/MultivaluesField.d.ts +212 -0
  20. package/lib/cjs/types/MultivaluesField.js +5 -0
  21. package/lib/cjs/types/copyText.d.ts +1 -0
  22. package/lib/cjs/types/index.d.ts +1 -0
  23. package/lib/cjs/types/index.js +11 -0
  24. package/lib/components/CodeView/CodeView.js +8 -4
  25. package/lib/components/CopyText/CopyButton.js +2 -7
  26. package/lib/components/CopyText/CopyText.js +10 -3
  27. package/lib/components/MultivaluesField/BadgeLabelTooltip.js +3 -3
  28. package/lib/components/MultivaluesField/CondensedMultivaluesField.js +24 -132
  29. package/lib/components/MultivaluesField/DefaultMultivaluesField.js +33 -139
  30. package/lib/components/MultivaluesField/MultivaluesField.js +7 -105
  31. package/lib/components/RadioGroupField/RadioGroupField.js +1 -1
  32. package/lib/styles/themes/next-gen/codeView/codeView.js +2 -14
  33. package/lib/types/MultivaluesField.js +1 -0
  34. package/lib/types/index.js +1 -0
  35. package/package.json +1 -1
@@ -143,10 +143,14 @@ const CodeView = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
143
143
  ref: ref,
144
144
  mode: "rightText",
145
145
  textToCopy: textToCopy || children,
146
- iconButtonProps: {
147
- ...iconButtonProps,
148
- variant
149
- }
146
+ iconProps: {
147
+ sx: {
148
+ '&& path': {
149
+ fill: variant === 'light' ? 'black' : 'white'
150
+ }
151
+ }
152
+ },
153
+ iconButtonProps: iconButtonProps
150
154
  })), content);
151
155
  }
152
156
  if (hasNoCopyButton) {
@@ -14,22 +14,17 @@ var _IconButton = _interopRequireDefault(require("../IconButton"));
14
14
  var _react2 = require("@emotion/react");
15
15
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
16
  const CopyButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
17
- /* istanbul ignore next */
18
17
  const {
19
18
  iconProps,
20
- variant = 'default',
21
19
  ...others
22
20
  } = props;
23
21
  const {
24
- copyButtonSize,
25
- themeState
22
+ copyButtonSize
26
23
  } = (0, _hooks.useGetTheme)();
27
- /* istanbul ignore next */
28
- const themeVariant = themeState.isOnyx ? `copyButton.${variant}` : 'copyButton';
29
24
  return (0, _react2.jsx)(_IconButton.default, (0, _extends2.default)({
30
25
  ref: ref,
31
26
  "aria-label": "copy to clipboard",
32
- variant: themeVariant
27
+ variant: "copyButton"
33
28
  }, others), (0, _react2.jsx)(_Icon.default, (0, _extends2.default)({
34
29
  icon: _ContentCopyIcon.default,
35
30
  size: copyButtonSize,
@@ -33,6 +33,7 @@ const CopyText = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
33
33
  tooltipProps,
34
34
  wrapperProps,
35
35
  iconButtonProps,
36
+ iconProps,
36
37
  ...others
37
38
  } = props;
38
39
  const value = textToCopy || (mode === 'link' ? children?.props?.href : children.props?.children);
@@ -113,7 +114,9 @@ const CopyText = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
113
114
  role: "presentation"
114
115
  }), content, (0, _react2.jsx)(_CopyButton.default, (0, _extends2.default)({
115
116
  onPress: copyToClipboard
116
- }, focusProps, iconButtonProps))));
117
+ }, focusProps, {
118
+ iconProps: iconProps
119
+ }, iconButtonProps))));
117
120
  }
118
121
  if (mode === 'link') {
119
122
  return (0, _react2.jsx)(_index.Box, (0, _extends2.default)({
@@ -126,7 +129,9 @@ const CopyText = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
126
129
  tooltip: tooltip
127
130
  }, tooltipProps), (0, _react2.jsx)(_CopyButton.default, (0, _extends2.default)({
128
131
  onPress: copyToClipboard
129
- }, (0, _reactAria.mergeProps)(hoverProps, focusProps, iconButtonProps)))));
132
+ }, (0, _reactAria.mergeProps)(hoverProps, focusProps, iconButtonProps), {
133
+ iconProps: iconProps
134
+ }))));
130
135
  }
131
136
  return (0, _react2.jsx)(TooltipWrapper, (0, _extends2.default)({
132
137
  isOpen: isTooltipOpen,
@@ -148,7 +153,9 @@ const CopyText = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
148
153
  gap: "sm"
149
154
  }), mode !== 'rightText' && content, (0, _react2.jsx)(_CopyButton.default, (0, _extends2.default)({
150
155
  onPress: copyToClipboard
151
- }, focusProps, iconButtonProps)), mode === 'rightText' && content)));
156
+ }, focusProps, {
157
+ iconProps: iconProps
158
+ }, iconButtonProps)), mode === 'rightText' && content)));
152
159
  });
153
160
  CopyText.defaultProps = {
154
161
  mode: 'text',
@@ -0,0 +1,3 @@
1
+ import { BadgeLabelTooltipProps } from '../../types/MultivaluesField';
2
+ declare const BadgeLabelTooltip: ({ item, index, deleteItem, closeBadgeRefs, }: BadgeLabelTooltipProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default BadgeLabelTooltip;
@@ -21,13 +21,13 @@ const BadgeLabelTooltip = ({
21
21
  deleteItem,
22
22
  closeBadgeRefs
23
23
  }) => {
24
- const isLong = item.name.length > BADGE_TOOLTIP_CHAR_THRESHOLD;
24
+ const isLong = (item.name || '').length > BADGE_TOOLTIP_CHAR_THRESHOLD;
25
25
  const {
26
26
  hoverProps,
27
27
  isHovered
28
28
  } = (0, _interactions.useHover)({});
29
29
  const textProps = (0, _reactAria.mergeProps)(item.badgeProps?.textProps || {}, hoverProps);
30
- const badgeRef = (0, _react.useRef)();
30
+ const badgeRef = (0, _react.useRef)(null);
31
31
  return (0, _react2.jsx)(_.Box, {
32
32
  as: "li"
33
33
  }, (0, _react2.jsx)(_TooltipTrigger.default, {
@@ -47,7 +47,7 @@ const BadgeLabelTooltip = ({
47
47
  }), (0, _react2.jsx)(_.IconButton, (0, _extends2.default)({
48
48
  "aria-label": `delete ${item.name}`,
49
49
  "data-item": item.name,
50
- onPress: e => deleteItem(item.key, e),
50
+ onPress: e => item.key !== undefined && deleteItem(item.key, e),
51
51
  ref: el => closeBadgeRefs.current[index] = el // eslint-disable-line
52
52
  ,
53
53
  variant: "badge.deleteButton",
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { CondensedMultivaluesFieldProps } from '../../types/MultivaluesField';
3
+ declare const CondensedMultivaluesField: React.ForwardRefExoticComponent<CondensedMultivaluesFieldProps & React.RefAttributes<HTMLDivElement>>;
4
+ export default CondensedMultivaluesField;
@@ -13,16 +13,12 @@ var _interactions = require("@react-aria/interactions");
13
13
  var _utils = require("@react-aria/utils");
14
14
  var _visuallyHidden = require("@react-aria/visually-hidden");
15
15
  var _list = require("@react-stately/list");
16
- var _propTypes = _interopRequireDefault(require("prop-types"));
17
16
  var _ = require("../..");
18
17
  var _MultivaluesContext = require("../../context/MultivaluesContext");
19
18
  var _hooks = require("../../hooks");
20
19
  var _loadingStates = _interopRequireDefault(require("../../utils/devUtils/constants/loadingStates"));
21
20
  var _pendoID = require("../../utils/devUtils/constants/pendoID");
22
- var _isIterable = require("../../utils/devUtils/props/isIterable");
23
- var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
24
- var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
25
- var _statusProp = require("../../utils/docUtils/statusProp");
21
+ var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
26
22
  var _ListBox = _interopRequireDefault(require("../ListBox"));
27
23
  var _Popover = _interopRequireDefault(require("../Popover/Popover"));
28
24
  var _react2 = require("@emotion/react");
@@ -30,7 +26,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
30
26
  const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
31
27
  const {
32
28
  defaultSelectedKeys,
33
- direction,
29
+ direction = 'bottom',
34
30
  disabledKeys = [],
35
31
  containerProps,
36
32
  filter,
@@ -42,7 +38,7 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
42
38
  isDisabled,
43
39
  isFilteringDisabled,
44
40
  isNotFlippable,
45
- isReadOnly,
41
+ isReadOnly = false,
46
42
  isRequired,
47
43
  items,
48
44
  label,
@@ -60,8 +56,10 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
60
56
  placeholder,
61
57
  selectedKeys,
62
58
  selectedOptionText: selectedOptionTextProp,
63
- scrollBoxProps,
64
- status,
59
+ scrollBoxProps = {
60
+ maxHeight: 300
61
+ },
62
+ status = _statuses.default.DEFAULT,
65
63
  ...others
66
64
  } = props;
67
65
  (0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
@@ -69,9 +67,9 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
69
67
  const [isOpen, setIsOpen] = (0, _react.useState)(false);
70
68
  const [hasFocusWithin, setFocusWithin] = (0, _react.useState)(false);
71
69
  const [activeDescendant, setActiveDescendant] = (0, _react.useState)('');
72
- const inputWrapperRef = (0, _react.useRef)();
73
- const inputRef = (0, _react.useRef)();
74
- const buttonRef = (0, _react.useRef)();
70
+ const inputWrapperRef = (0, _react.useRef)(null);
71
+ const inputRef = (0, _react.useRef)(null);
72
+ const buttonRef = (0, _react.useRef)(null);
75
73
  const {
76
74
  icons,
77
75
  themeState: {
@@ -141,8 +139,8 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
141
139
  (0, _react.useImperativeHandle)(ref, () => inputWrapperRef.current);
142
140
  /* istanbul ignore next */
143
141
  (0, _react.useImperativeHandle)(ref, () => inputRef.current);
144
- const listBoxRef = (0, _react.useRef)();
145
- const popoverRef = (0, _react.useRef)();
142
+ const listBoxRef = (0, _react.useRef)(null);
143
+ const popoverRef = (0, _react.useRef)(null);
146
144
 
147
145
  // Measure the width of the input to inform the width of the menu (below).
148
146
  const [menuWidth, setMenuWidth] = (0, _react.useState)(null);
@@ -222,11 +220,15 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
222
220
  setIsOpen(false);
223
221
  };
224
222
  const [selectionState, setSelectionState] = (0, _react.useState)('Select All');
225
- const arrayItems = Array.from(items);
223
+ const arrayItems = items || [];
226
224
  const itemCount = arrayItems.reduce((count, obj) => count + (obj.children ? obj.children.length : 1), 0);
227
225
  const selectedKeysSize = selectionManager.selectedKeys.size;
228
- const selectedOptionText = selectedOptionTextProp || `${itemCount === selectedKeysSize ? 'All' : selectionManager.state.selectedKeys?.size} Selected`;
229
- const checkboxSelected = selectionManager.state.selectedKeys?.size !== 0 && (0, _react2.jsx)(_.Text, {
226
+
227
+ // `selectionManager.state` is private in the react-stately typings but is
228
+ // read throughout this component; the access is kept via a cast.
229
+ const selectionManagerState = selectionManager.state;
230
+ const selectedOptionText = selectedOptionTextProp || `${itemCount === selectedKeysSize ? 'All' : selectionManagerState.selectedKeys?.size} Selected`;
231
+ const checkboxSelected = selectionManagerState.selectedKeys?.size !== 0 && (0, _react2.jsx)(_.Text, {
230
232
  color: "text.secondary"
231
233
  }, selectedOptionText);
232
234
  (0, _react.useEffect)(() => {
@@ -236,7 +238,7 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
236
238
  }, [itemCount, selectedKeysSize]);
237
239
  const handleSelection = () => {
238
240
  if (selectedKeysSize < itemCount) {
239
- const allItemNames = arrayItems.flatMap(obj => obj.children ? obj.children.map(child => child.key) : obj.key);
241
+ const allItemNames = arrayItems.flatMap(obj => obj.children ? obj.children.map(child => child.key) : obj.key).filter(key => key !== undefined);
240
242
  selectionManager.setSelectedKeys(allItemNames);
241
243
  setSelectionState('Deselect All');
242
244
  } else if (selectionState === 'Deselect All') {
@@ -282,7 +284,7 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
282
284
  id: "emptyKeysState"
283
285
  }, "Nothing Selected");
284
286
  };
285
- const placeholderText = selectionManager.state.selectedKeys?.size === 0 ? placeholder || 'Select' : '';
287
+ const placeholderText = selectionManagerState.selectedKeys?.size === 0 ? placeholder || 'Select' : '';
286
288
  const inputProps = {
287
289
  ...customInputProps,
288
290
  controlProps: {
@@ -300,7 +302,7 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
300
302
  isDisabled,
301
303
  isReadOnly,
302
304
  isRequired,
303
- label,
305
+ label: label,
304
306
  placeholder: placeholderText,
305
307
  wrapperProps: {
306
308
  ref: inputWrapperRef,
@@ -315,7 +317,7 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
315
317
  const handleButtonPress = () => {
316
318
  if (!isOpen) {
317
319
  setIsOpen(true);
318
- inputRef.current.focus();
320
+ inputRef.current?.focus();
319
321
  } else {
320
322
  setIsOpen(false);
321
323
  }
@@ -375,7 +377,7 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
375
377
  beforeInput: (0, _react2.jsx)(_react.default.Fragment, null, checkboxSelected, selectionManager.selectedKeys.size > 0 && visuallyHidden)
376
378
  },
377
379
  value: filterString,
378
- helperText: helperText,
380
+ helperText,
379
381
  "aria-invalid": status === 'error' && true
380
382
  }, (0, _pendoID.getPendoID)('MultivaluesField'), others, inputProps)), (0, _react2.jsx)(_Popover.default, {
381
383
  hasNoArrow: true,
@@ -390,114 +392,4 @@ const CondensedMultivaluesField = /*#__PURE__*/(0, _react.forwardRef)((props, re
390
392
  onBlur: e => handleBlur(e)
391
393
  }, listbox), (0, _react2.jsx)(EmptyVisuallyHidden, null)));
392
394
  });
393
- CondensedMultivaluesField.propTypes = {
394
- /** The initial selected keys in the collection (uncontrolled). */
395
- defaultSelectedKeys: _isIterable.isIterableProp,
396
- /** Where the menu opens relative to its trigger. */
397
- direction: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left']),
398
- /**
399
- * The item keys that are disabled. These items cannot be selected.
400
- */
401
- disabledKeys: _isIterable.isIterableProp,
402
- /** Whether the element should receive focus on render. */
403
- hasAutoFocus: _propTypes.default.bool,
404
- /** Whether the field has the select all button. */
405
- hasNoSelectAll: _propTypes.default.bool,
406
- /** Whether the field has a status indicator. */
407
- hasNoStatusIndicator: _propTypes.default.bool,
408
- /** Text rendered below the input. */
409
- helperText: _propTypes.default.node,
410
- /**
411
- * Props that get passed as-is to the underlying TextField element
412
- */
413
- inputProps: _propTypes.default.shape({}),
414
- /** Whether the input is disabled. */
415
- isDisabled: _propTypes.default.bool,
416
- /**
417
- * Whether the menu is prevented from flipping directions when insufficient space is
418
- * available for the given `direction` placement.
419
- */
420
- isNotFlippable: _propTypes.default.bool,
421
- /** Whether the input can be selected but not changed by the user. */
422
- isReadOnly: _propTypes.default.bool,
423
- /** Whether user input is required on the input before form submission. */
424
- isRequired: _propTypes.default.bool,
425
- /** The list of items.
426
- *
427
- * **Note:** Every item needs to have key and name properties.
428
- *
429
- * `Array<{key: string, name: string}>`
430
- */
431
- items: _isIterable.isIterableProp,
432
- /** The rendered label for the field. */
433
- label: _propTypes.default.string,
434
- /** Whether the component allows to create new values or only choose from the selection list */
435
- mode: _propTypes.default.oneOf(['restrictive', 'non-restrictive', 'condensed']),
436
- /**
437
- * Handler that is called when the element loses focus.
438
- *
439
- * `(e: FocusEvent) => void`
440
- */
441
- onBlur: _propTypes.default.func,
442
- /**
443
- * Handler that is called when the element receives focus.
444
- *
445
- * `(e: FocusEvent) => void`
446
- */
447
- onFocus: _propTypes.default.func,
448
- /**
449
- * Handler that is called when the input value changes.
450
- *
451
- * `(value: string) => void`
452
- */
453
- onInputChange: _propTypes.default.func,
454
- /**
455
- * Handler that is called when a key is pressed.
456
- *
457
- * `(e: KeyboardEvent) => void`
458
- */
459
- onKeyDown: _propTypes.default.func,
460
- /**
461
- * Handler that is called when a key is released.
462
- *
463
- * `(e: KeyboardEvent) => void`
464
- */
465
- onKeyUp: _propTypes.default.func,
466
- /**
467
- * Method that is called when the open state of the menu changes.
468
- *
469
- * `(isOpen: boolean) => void`
470
- */
471
- onOpenChange: _propTypes.default.func,
472
- /**
473
- * Handler that is called when the selection changes.
474
- *
475
- * `(keys: Iterable<Key>) => any`
476
- */
477
- onSelectionChange: _propTypes.default.func,
478
- /** Temporary text that occupies the text input when it is empty. */
479
- placeholder: _propTypes.default.string,
480
- /**
481
- * The item keys that are readonly. These items cannot be changed or selected.
482
- */
483
- readOnlyKeys: _propTypes.default.arrayOf(_propTypes.default.string),
484
- /** The currently selected keys in the collection (controlled). */
485
- selectedKeys: _isIterable.isIterableProp,
486
- // /** Props object that is spread directly into the ScrollBox element. */
487
- /** @ignore */
488
- scrollBoxProps: _propTypes.default.shape({
489
- maxHeight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object, _propTypes.default.number])
490
- }),
491
- ..._statusProp.statusPropTypes,
492
- ..._ariaAttributes.ariaAttributesBasePropTypes,
493
- ..._fieldAttributes.inputFieldAttributesBasePropTypes
494
- };
495
- CondensedMultivaluesField.defaultProps = {
496
- direction: 'bottom',
497
- isReadOnly: false,
498
- scrollBoxProps: {
499
- maxHeight: 300
500
- },
501
- ..._statusProp.statusDefaultProp
502
- };
503
395
  var _default = exports.default = CondensedMultivaluesField;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { DefaultMultivaluesFieldProps } from '../../types/MultivaluesField';
3
+ declare const DefaultMultivaluesField: React.ForwardRefExoticComponent<DefaultMultivaluesFieldProps & React.RefAttributes<HTMLDivElement>>;
4
+ export default DefaultMultivaluesField;