@pingux/astro 1.23.0-alpha.1 → 1.23.0-alpha.4

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 (25) hide show
  1. package/lib/cjs/components/ArrayField/ArrayField.js +2 -2
  2. package/lib/cjs/components/ArrayField/ArrayField.test.js +4 -0
  3. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +0 -1
  4. package/lib/cjs/components/CollapsiblePanelItem/CollapsiblePanelItem.js +2 -1
  5. package/lib/cjs/components/ListView/ListView.js +6 -0
  6. package/lib/cjs/components/PopoverContainer/PopoverContainer.js +69 -9
  7. package/lib/cjs/components/SwitchField/SwitchField.js +10 -2
  8. package/lib/cjs/components/TooltipTrigger/TooltipTrigger.js +15 -3
  9. package/lib/cjs/components/TooltipTrigger/TooltipTrigger.stories.js +18 -1
  10. package/lib/cjs/components/TooltipTrigger/TooltipTrigger.test.js +10 -0
  11. package/lib/cjs/recipes/CollapsiblePanel.stories.js +7 -1
  12. package/lib/cjs/styles/forms/switch.js +3 -3
  13. package/lib/components/ArrayField/ArrayField.js +2 -2
  14. package/lib/components/ArrayField/ArrayField.test.js +4 -0
  15. package/lib/components/Breadcrumbs/Breadcrumbs.js +0 -1
  16. package/lib/components/CollapsiblePanelItem/CollapsiblePanelItem.js +2 -1
  17. package/lib/components/ListView/ListView.js +6 -0
  18. package/lib/components/PopoverContainer/PopoverContainer.js +69 -9
  19. package/lib/components/SwitchField/SwitchField.js +9 -2
  20. package/lib/components/TooltipTrigger/TooltipTrigger.js +15 -3
  21. package/lib/components/TooltipTrigger/TooltipTrigger.stories.js +11 -0
  22. package/lib/components/TooltipTrigger/TooltipTrigger.test.js +8 -0
  23. package/lib/recipes/CollapsiblePanel.stories.js +8 -2
  24. package/lib/styles/forms/switch.js +3 -3
  25. package/package.json +1 -1
@@ -172,7 +172,7 @@ var ArrayField = function ArrayField(props) {
172
172
  }
173
173
  }, [isControlled]);
174
174
  var onFieldAdd = (0, _react.useCallback)(function () {
175
- if (onAddRef.current) {
175
+ if (isControlled) {
176
176
  return onAddRef.current();
177
177
  }
178
178
 
@@ -181,7 +181,7 @@ var ArrayField = function ArrayField(props) {
181
181
 
182
182
  return (0, _concat["default"])(_context = []).call(_context, oldValues, [createEmptyField()]);
183
183
  });
184
- }, [createEmptyField]);
184
+ }, [createEmptyField, isControlled]);
185
185
 
186
186
  var _useLabel = (0, _label.useLabel)(_objectSpread({}, props)),
187
187
  raLabelProps = _useLabel.labelProps;
@@ -79,7 +79,11 @@ test('adds one text field and new empty field is added', function () {
79
79
  });
80
80
  test('onAdd callback is fired when adding field', function () {
81
81
  var onAdd = jest.fn();
82
+ var value = defaultData;
83
+ var defaultValue = null;
82
84
  getComponent({
85
+ value: value,
86
+ defaultValue: defaultValue,
83
87
  onAdd: onAdd,
84
88
  renderField: renderField
85
89
  });
@@ -102,7 +102,6 @@ var Breadcrumbs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
102
102
  ref: breadcrumbsRef,
103
103
  isRow: true,
104
104
  sx: {
105
- overflow: 'auto',
106
105
  paddingInlineStart: 'unset'
107
106
  },
108
107
  as: "ol"
@@ -54,7 +54,8 @@ var CollapsiblePanelItem = /*#__PURE__*/(0, _react.forwardRef)(function (props,
54
54
  fill: 'inherit'
55
55
  }
56
56
  },
57
- onPress: onPress
57
+ onPress: onPress,
58
+ "aria-label": "icon"
58
59
  }, iconElement)));
59
60
  });
60
61
  CollapsiblePanelItem.propTypes = {
@@ -105,6 +105,12 @@ function useListLayout(state) {
105
105
  * ListViews are used to display a list of items. Users can select,
106
106
  * view, or edit items in this list. This virtualized component supports
107
107
  * asynchronous data in infinitely scrollable lists.
108
+ *
109
+ * NOTE: be careful with putting focusable elements inside ListView.
110
+ * It is using a grid (useList hook) with its own event listeners under the hood.
111
+ * [react-specttrum-github-issue](https://github.com/adobe/react-spectrum/issues/2801)
112
+ * If you decided to add a focusable element inside ListView,
113
+ * you should stop bubbling of a pointerDown event and put a focus on the element.
108
114
  */
109
115
 
110
116
 
@@ -48,8 +48,9 @@ var _Box = _interopRequireDefault(require("../Box"));
48
48
 
49
49
  var _react2 = require("@emotion/react");
50
50
 
51
- var _excluded = ["children", "placement", "arrowProps", "onClose", "isNotClosedOnBlur", "hasNoArrow", "isKeyboardDismissDisabled", "isNonModal", "isDismissable"],
52
- _excluded2 = ["children", "className", "placement", "arrowProps", "isOpen", "hasNoArrow", "isNotClosedOnBlur", "isKeyboardDismissDisabled", "isNonModal", "isDismissable"];
51
+ var _excluded = ["children", "placement", "arrowProps", "arrowCrossOffset", "onClose", "isNotClosedOnBlur", "hasNoArrow", "isKeyboardDismissDisabled", "isNonModal", "isDismissable", "width", "direction"],
52
+ _excluded2 = ["children", "className", "placement", "arrowProps", "arrowCrossOffset", "isOpen", "hasNoArrow", "isNotClosedOnBlur", "isKeyboardDismissDisabled", "isNonModal", "isDismissable", "width", "direction", "sx"],
53
+ _excluded3 = ["arrowCrossOffset", "sx", "direction"];
53
54
 
54
55
  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); }
55
56
 
@@ -66,12 +67,15 @@ var PopoverContainer = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
66
67
  var children = props.children,
67
68
  placement = props.placement,
68
69
  arrowProps = props.arrowProps,
70
+ arrowCrossOffset = props.arrowCrossOffset,
69
71
  onClose = props.onClose,
70
72
  isNotClosedOnBlur = props.isNotClosedOnBlur,
71
73
  hasNoArrow = props.hasNoArrow,
72
74
  isKeyboardDismissDisabled = props.isKeyboardDismissDisabled,
73
75
  isNonModal = props.isNonModal,
74
76
  isDismissable = props.isDismissable,
77
+ width = props.width,
78
+ direction = props.direction,
75
79
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
76
80
  return (0, _react2.jsx)(_overlays.OverlayContainer, null, (0, _react2.jsx)(PopoverWrapper, (0, _extends2["default"])({
77
81
  ref: ref,
@@ -82,7 +86,10 @@ var PopoverContainer = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
82
86
  isKeyboardDismissDisabled: isKeyboardDismissDisabled,
83
87
  hasNoArrow: hasNoArrow,
84
88
  isNonModal: isNonModal,
85
- isDismissable: isDismissable
89
+ isDismissable: isDismissable,
90
+ arrowCrossOffset: arrowCrossOffset,
91
+ width: width,
92
+ direction: direction
86
93
  }, others), children));
87
94
  });
88
95
  PopoverContainer.propTypes = {
@@ -93,19 +100,26 @@ PopoverContainer.propTypes = {
93
100
  hasNoArrow: _propTypes["default"].bool,
94
101
  isKeyboardDismissDisabled: _propTypes["default"].bool,
95
102
  isNonModal: _propTypes["default"].bool,
96
- isDismissable: _propTypes["default"].bool
103
+ isDismissable: _propTypes["default"].bool,
104
+ width: _propTypes["default"].string,
105
+ arrowCrossOffset: _propTypes["default"].string,
106
+ direction: _propTypes["default"].oneOf(['top', 'right', 'bottom', 'left'])
97
107
  };
98
108
  var PopoverWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
99
109
  var children = props.children,
100
110
  className = props.className,
101
111
  placement = props.placement,
102
112
  arrowProps = props.arrowProps,
113
+ arrowCrossOffset = props.arrowCrossOffset,
103
114
  isOpen = props.isOpen,
104
115
  hasNoArrow = props.hasNoArrow,
105
116
  isNotClosedOnBlur = props.isNotClosedOnBlur,
106
117
  isKeyboardDismissDisabled = props.isKeyboardDismissDisabled,
107
118
  isNonModal = props.isNonModal,
108
119
  isDismissable = props.isDismissable,
120
+ width = props.width,
121
+ direction = props.direction,
122
+ sx = props.sx,
109
123
  others = (0, _objectWithoutProperties2["default"])(props, _excluded2);
110
124
  var popoverRef = (0, _react.useRef)();
111
125
  /* istanbul ignore next */
@@ -135,8 +149,14 @@ var PopoverWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
135
149
  className: classNames,
136
150
  role: "presentation",
137
151
  "data-popover-placement": placement,
138
- "data-testid": "popover-container"
139
- }), children, hasNoArrow ? null : (0, _react2.jsx)(PopoverArrow, arrowProps)));
152
+ "data-testid": "popover-container",
153
+ sx: _objectSpread(_objectSpread({}, sx), {}, {
154
+ width: width
155
+ })
156
+ }), children, hasNoArrow ? null : (0, _react2.jsx)(PopoverArrow, (0, _extends2["default"])({}, arrowProps, {
157
+ arrowCrossOffset: arrowCrossOffset,
158
+ direction: direction
159
+ }))));
140
160
  });
141
161
  exports.PopoverWrapper = PopoverWrapper;
142
162
  PopoverWrapper.propTypes = {
@@ -147,21 +167,61 @@ PopoverWrapper.propTypes = {
147
167
  isNotClosedOnBlur: _propTypes["default"].bool,
148
168
  isKeyboardDismissDisabled: _propTypes["default"].bool,
149
169
  isNonModal: _propTypes["default"].bool,
150
- isDismissable: _propTypes["default"].bool
170
+ isDismissable: _propTypes["default"].bool,
171
+ width: _propTypes["default"].string,
172
+ arrowCrossOffset: _propTypes["default"].string,
173
+ sx: _propTypes["default"].shape({}),
174
+ direction: _propTypes["default"].oneOf(['top', 'right', 'bottom', 'left'])
151
175
  };
152
176
  PopoverWrapper.defaultProps = {
153
177
  placement: 'bottom'
154
178
  };
155
179
 
156
180
  var PopoverArrow = function PopoverArrow(props) {
157
- var others = (0, _extends2["default"])({}, props);
181
+ var arrowCrossOffset = props.arrowCrossOffset,
182
+ sx = props.sx,
183
+ direction = props.direction,
184
+ others = (0, _objectWithoutProperties2["default"])(props, _excluded3);
185
+ /* istanbul ignore next */
186
+
187
+ var calculateOffset = function calculateOffset() {
188
+ switch (true) {
189
+ case direction === 'top':
190
+ case direction === 'bottom':
191
+ return {
192
+ '&:before': {
193
+ left: "calc(50% - ".concat(arrowCrossOffset, ") !important")
194
+ }
195
+ };
196
+
197
+ case direction === 'left':
198
+ case direction === 'right':
199
+ return {
200
+ '&:before': {
201
+ top: "calc(50% - ".concat(arrowCrossOffset, ") !important")
202
+ }
203
+ };
204
+
205
+ default:
206
+ return {};
207
+ }
208
+ };
209
+
158
210
  return (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
159
211
  variant: "popoverMenu.arrow",
160
212
  "data-popover-arrow": "arrow",
161
213
  "data-testid": "popover-arrow"
162
- }, others));
214
+ }, others, {
215
+ sx: _objectSpread(_objectSpread({}, arrowCrossOffset && calculateOffset()), sx)
216
+ }));
163
217
  };
164
218
 
165
219
  exports.PopoverArrow = PopoverArrow;
220
+ PopoverArrow.propTypes = {
221
+ width: _propTypes["default"].string,
222
+ arrowCrossOffset: _propTypes["default"].string,
223
+ sx: _propTypes["default"].shape({}),
224
+ direction: _propTypes["default"].oneOf(['top', 'right', 'bottom', 'left'])
225
+ };
166
226
  var _default = PopoverContainer;
167
227
  exports["default"] = _default;
@@ -48,6 +48,8 @@ var _toggle = require("@react-stately/toggle");
48
48
 
49
49
  var _switch = require("@react-aria/switch");
50
50
 
51
+ var _interactions = require("@react-aria/interactions");
52
+
51
53
  var _hooks = require("../../hooks");
52
54
 
53
55
  var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
@@ -113,6 +115,12 @@ var SwitchField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
113
115
  var state = (0, _toggle.useToggleState)(_objectSpread({
114
116
  defaultSelected: isDefaultSelected
115
117
  }, props));
118
+
119
+ var _usePress = (0, _interactions.usePress)({
120
+ isDisabled: isDisabled
121
+ }),
122
+ containerPressProps = _usePress.pressProps;
123
+
116
124
  var whitelistedProps = (0, _omit["default"])(props, (0, _keys["default"])(others));
117
125
 
118
126
  var _useSwitch = (0, _switch.useSwitch)(_objectSpread({
@@ -124,9 +132,9 @@ var SwitchField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
124
132
  isSelected: inputProps.checked
125
133
  };
126
134
 
127
- var _useField = (0, _hooks.useField)(_objectSpread(_objectSpread({
135
+ var _useField = (0, _hooks.useField)(_objectSpread(_objectSpread(_objectSpread({
128
136
  statusClasses: statusClasses
129
- }, props), {}, {
137
+ }, containerPressProps), props), {}, {
130
138
  controlProps: _objectSpread(_objectSpread({}, controlProps), inputProps)
131
139
  })),
132
140
  fieldContainerProps = _useField.fieldContainerProps,
@@ -57,7 +57,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
57
57
  var TooltipTrigger = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
58
58
  var _context, _useStatusClasses2;
59
59
 
60
- var children = props.children,
60
+ var arrowCrossOffset = props.arrowCrossOffset,
61
+ children = props.children,
61
62
  crossOffset = props.crossOffset,
62
63
  isDisabled = props.isDisabled,
63
64
  align = props.align,
@@ -68,7 +69,8 @@ var TooltipTrigger = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
68
69
  isNotFlippable = props.isNotFlippable,
69
70
  isDarkMode = props.isDarkMode,
70
71
  hasNoArrow = props.hasNoArrow,
71
- targetRef = props.targetRef;
72
+ targetRef = props.targetRef,
73
+ width = props.width;
72
74
 
73
75
  var _React$Children$toArr = _react["default"].Children.toArray(children),
74
76
  _React$Children$toArr2 = (0, _slicedToArray2["default"])(_React$Children$toArr, 2),
@@ -116,7 +118,10 @@ var TooltipTrigger = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
116
118
  placement: placement,
117
119
  arrowProps: arrowProps,
118
120
  className: classNames,
119
- hasNoArrow: hasNoArrow
121
+ hasNoArrow: hasNoArrow,
122
+ arrowCrossOffset: arrowCrossOffset,
123
+ width: width,
124
+ direction: direction
120
125
  }, positionProps, tooltipProps), tooltip);
121
126
  return (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_interactions.PressResponder, (0, _extends2["default"])({}, triggerProps, {
122
127
  ref: tooltipTriggerRef
@@ -166,12 +171,19 @@ TooltipTrigger.propTypes = {
166
171
  /** Tooltip offset relative to its trigger. */
167
172
  offset: _propTypes["default"].number,
168
173
 
174
+ /** Arrow offset relative to the left of the tooltip.
175
+ * Must be passed as a px or percentage. */
176
+ arrowCrossOffset: _propTypes["default"].string,
177
+
169
178
  /** The placement of the element with respect to its anchor element. */
170
179
  placement: _propTypes["default"].string,
171
180
 
172
181
  /** By default, opens for both focus and hover. Can be made to open only for focus. */
173
182
  trigger: _propTypes["default"].string,
174
183
 
184
+ /** Width applied to the wrapper of the tooltip component. */
185
+ width: _propTypes["default"].string,
186
+
175
187
  /* The ref for the element which the overlay positions itself with respect to. */
176
188
  targetRef: _propTypes["default"].shape({})
177
189
  };
@@ -8,7 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
 
11
- exports.withDirectionProp = exports.withDelayProp = exports.withAlignProp = exports.isOpen = exports["default"] = exports.TextWithTooltip = exports.IconWithTooltip = exports.Disabled = exports.Default = exports.ChipWithTooltip = void 0;
11
+ exports.withWidthProp = exports.withDirectionProp = exports.withDelayProp = exports.withArrowCrossOffsetProp = exports.withAlignProp = exports.isOpen = exports["default"] = exports.TextWithTooltip = exports.IconWithTooltip = exports.Disabled = exports.Default = exports.ChipWithTooltip = void 0;
12
12
 
13
13
  var _react = _interopRequireDefault(require("react"));
14
14
 
@@ -60,6 +60,23 @@ var withDelayProp = function withDelayProp() {
60
60
 
61
61
  exports.withDelayProp = withDelayProp;
62
62
 
63
+ var withWidthProp = function withWidthProp() {
64
+ return (0, _react2.jsx)(_index.TooltipTrigger, {
65
+ width: "200px"
66
+ }, (0, _react2.jsx)(_index.Button, null, "Hover Over Me!"), (0, _react2.jsx)(_index.Tooltip, null, "Custom width display"));
67
+ };
68
+
69
+ exports.withWidthProp = withWidthProp;
70
+
71
+ var withArrowCrossOffsetProp = function withArrowCrossOffsetProp() {
72
+ return (0, _react2.jsx)(_index.TooltipTrigger, {
73
+ arrowCrossOffset: "30px",
74
+ isOpen: true
75
+ }, (0, _react2.jsx)(_index.Button, null, "Hover Over Me!"), (0, _react2.jsx)(_index.Tooltip, null, "Display with a delay"));
76
+ };
77
+
78
+ exports.withArrowCrossOffsetProp = withArrowCrossOffsetProp;
79
+
63
80
  var isOpen = function isOpen() {
64
81
  return (0, _react2.jsx)(_index.TooltipTrigger, {
65
82
  isOpen: true
@@ -106,4 +106,14 @@ test('trigger press events work when a tooltip is disabled', function () {
106
106
  _userEvent["default"].click(button);
107
107
 
108
108
  expect(onPress).toHaveBeenCalledTimes(1);
109
+ });
110
+ test('passing in width applies the correct width to the container', function () {
111
+ getComponent({
112
+ isOpen: true,
113
+ width: '100px'
114
+ });
115
+
116
+ var arrow = _testWrapper.screen.getByTestId('popover-container');
117
+
118
+ expect(arrow).toHaveStyle('width: 100px');
109
119
  });
@@ -150,6 +150,8 @@ var Default = function Default() {
150
150
  searchValue = _useState4[0],
151
151
  setSearchValue = _useState4[1];
152
152
 
153
+ var checkBoxRef = (0, _react.useRef)(null);
154
+
153
155
  var _useFilter = (0, _i18n.useFilter)({
154
156
  sensitivity: 'base'
155
157
  }),
@@ -325,7 +327,11 @@ var Default = function Default() {
325
327
  },
326
328
  isSelected: (0, _some["default"])(selectedItems).call(selectedItems, function (el) {
327
329
  return el.key === item.key;
328
- })
330
+ }),
331
+ ref: checkBoxRef,
332
+ onClick: function onClick() {
333
+ return checkBoxRef.current.focus();
334
+ }
329
335
  }));
330
336
  })), (0, _react2.jsx)(_.CollapsiblePanel, {
331
337
  items: selectedItems,
@@ -54,11 +54,11 @@ var thumbContainer = {
54
54
  border: '1px solid',
55
55
  borderColor: 'neutral.80',
56
56
  borderRadius: 9999,
57
- '.is-selected &': {
57
+ 'label.is-selected &': {
58
58
  bg: 'active',
59
59
  borderColor: 'active'
60
60
  },
61
- '.is-focused &, &:focus': _objectSpread({}, _buttons.defaultFocus)
61
+ 'label.is-focused &, &:focus': _objectSpread({}, _buttons.defaultFocus)
62
62
  };
63
63
  exports.thumbContainer = thumbContainer;
64
64
  var thumb = {
@@ -73,7 +73,7 @@ var thumb = {
73
73
  transitionTimingFunction: 'ease-out',
74
74
  transitionDuration: '0.1s',
75
75
  transform: 'translateX(0)',
76
- '.is-selected &': {
76
+ 'label.is-selected &': {
77
77
  transform: 'translateX(20px)',
78
78
  borderColor: 'active'
79
79
  }
@@ -118,7 +118,7 @@ var ArrayField = function ArrayField(props) {
118
118
  }
119
119
  }, [isControlled]);
120
120
  var onFieldAdd = useCallback(function () {
121
- if (onAddRef.current) {
121
+ if (isControlled) {
122
122
  return onAddRef.current();
123
123
  }
124
124
 
@@ -127,7 +127,7 @@ var ArrayField = function ArrayField(props) {
127
127
 
128
128
  return _concatInstanceProperty(_context = []).call(_context, oldValues, [createEmptyField()]);
129
129
  });
130
- }, [createEmptyField]);
130
+ }, [createEmptyField, isControlled]);
131
131
 
132
132
  var _useLabel = useLabel(_objectSpread({}, props)),
133
133
  raLabelProps = _useLabel.labelProps;
@@ -66,7 +66,11 @@ test('adds one text field and new empty field is added', function () {
66
66
  });
67
67
  test('onAdd callback is fired when adding field', function () {
68
68
  var onAdd = jest.fn();
69
+ var value = defaultData;
70
+ var defaultValue = null;
69
71
  getComponent({
72
+ value: value,
73
+ defaultValue: defaultValue,
70
74
  onAdd: onAdd,
71
75
  renderField: renderField
72
76
  });
@@ -68,7 +68,6 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function (props, ref) {
68
68
  ref: breadcrumbsRef,
69
69
  isRow: true,
70
70
  sx: {
71
- overflow: 'auto',
72
71
  paddingInlineStart: 'unset'
73
72
  },
74
73
  as: "ol"
@@ -30,7 +30,8 @@ var CollapsiblePanelItem = /*#__PURE__*/forwardRef(function (props, ref) {
30
30
  fill: 'inherit'
31
31
  }
32
32
  },
33
- onPress: onPress
33
+ onPress: onPress,
34
+ "aria-label": "icon"
34
35
  }, iconElement)));
35
36
  });
36
37
  CollapsiblePanelItem.propTypes = {
@@ -59,6 +59,12 @@ export function useListLayout(state) {
59
59
  * ListViews are used to display a list of items. Users can select,
60
60
  * view, or edit items in this list. This virtualized component supports
61
61
  * asynchronous data in infinitely scrollable lists.
62
+ *
63
+ * NOTE: be careful with putting focusable elements inside ListView.
64
+ * It is using a grid (useList hook) with its own event listeners under the hood.
65
+ * [react-specttrum-github-issue](https://github.com/adobe/react-spectrum/issues/2801)
66
+ * If you decided to add a focusable element inside ListView,
67
+ * you should stop bubbling of a pointerDown event and put a focus on the element.
62
68
  */
63
69
 
64
70
  var ListView = /*#__PURE__*/forwardRef(function (props, ref) {
@@ -9,8 +9,9 @@ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
9
9
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
10
10
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
11
11
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
12
- var _excluded = ["children", "placement", "arrowProps", "onClose", "isNotClosedOnBlur", "hasNoArrow", "isKeyboardDismissDisabled", "isNonModal", "isDismissable"],
13
- _excluded2 = ["children", "className", "placement", "arrowProps", "isOpen", "hasNoArrow", "isNotClosedOnBlur", "isKeyboardDismissDisabled", "isNonModal", "isDismissable"];
12
+ var _excluded = ["children", "placement", "arrowProps", "arrowCrossOffset", "onClose", "isNotClosedOnBlur", "hasNoArrow", "isKeyboardDismissDisabled", "isNonModal", "isDismissable", "width", "direction"],
13
+ _excluded2 = ["children", "className", "placement", "arrowProps", "arrowCrossOffset", "isOpen", "hasNoArrow", "isNotClosedOnBlur", "isKeyboardDismissDisabled", "isNonModal", "isDismissable", "width", "direction", "sx"],
14
+ _excluded3 = ["arrowCrossOffset", "sx", "direction"];
14
15
 
15
16
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
17
 
@@ -31,12 +32,15 @@ var PopoverContainer = /*#__PURE__*/forwardRef(function (props, ref) {
31
32
  var children = props.children,
32
33
  placement = props.placement,
33
34
  arrowProps = props.arrowProps,
35
+ arrowCrossOffset = props.arrowCrossOffset,
34
36
  onClose = props.onClose,
35
37
  isNotClosedOnBlur = props.isNotClosedOnBlur,
36
38
  hasNoArrow = props.hasNoArrow,
37
39
  isKeyboardDismissDisabled = props.isKeyboardDismissDisabled,
38
40
  isNonModal = props.isNonModal,
39
41
  isDismissable = props.isDismissable,
42
+ width = props.width,
43
+ direction = props.direction,
40
44
  others = _objectWithoutProperties(props, _excluded);
41
45
 
42
46
  return ___EmotionJSX(OverlayContainer, null, ___EmotionJSX(PopoverWrapper, _extends({
@@ -48,7 +52,10 @@ var PopoverContainer = /*#__PURE__*/forwardRef(function (props, ref) {
48
52
  isKeyboardDismissDisabled: isKeyboardDismissDisabled,
49
53
  hasNoArrow: hasNoArrow,
50
54
  isNonModal: isNonModal,
51
- isDismissable: isDismissable
55
+ isDismissable: isDismissable,
56
+ arrowCrossOffset: arrowCrossOffset,
57
+ width: width,
58
+ direction: direction
52
59
  }, others), children));
53
60
  });
54
61
  PopoverContainer.propTypes = {
@@ -59,19 +66,26 @@ PopoverContainer.propTypes = {
59
66
  hasNoArrow: PropTypes.bool,
60
67
  isKeyboardDismissDisabled: PropTypes.bool,
61
68
  isNonModal: PropTypes.bool,
62
- isDismissable: PropTypes.bool
69
+ isDismissable: PropTypes.bool,
70
+ width: PropTypes.string,
71
+ arrowCrossOffset: PropTypes.string,
72
+ direction: PropTypes.oneOf(['top', 'right', 'bottom', 'left'])
63
73
  };
64
74
  export var PopoverWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
65
75
  var children = props.children,
66
76
  className = props.className,
67
77
  placement = props.placement,
68
78
  arrowProps = props.arrowProps,
79
+ arrowCrossOffset = props.arrowCrossOffset,
69
80
  isOpen = props.isOpen,
70
81
  hasNoArrow = props.hasNoArrow,
71
82
  isNotClosedOnBlur = props.isNotClosedOnBlur,
72
83
  isKeyboardDismissDisabled = props.isKeyboardDismissDisabled,
73
84
  isNonModal = props.isNonModal,
74
85
  isDismissable = props.isDismissable,
86
+ width = props.width,
87
+ direction = props.direction,
88
+ sx = props.sx,
75
89
  others = _objectWithoutProperties(props, _excluded2);
76
90
 
77
91
  var popoverRef = useRef();
@@ -102,8 +116,14 @@ export var PopoverWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
102
116
  className: classNames,
103
117
  role: "presentation",
104
118
  "data-popover-placement": placement,
105
- "data-testid": "popover-container"
106
- }), children, hasNoArrow ? null : ___EmotionJSX(PopoverArrow, arrowProps)));
119
+ "data-testid": "popover-container",
120
+ sx: _objectSpread(_objectSpread({}, sx), {}, {
121
+ width: width
122
+ })
123
+ }), children, hasNoArrow ? null : ___EmotionJSX(PopoverArrow, _extends({}, arrowProps, {
124
+ arrowCrossOffset: arrowCrossOffset,
125
+ direction: direction
126
+ }))));
107
127
  });
108
128
  PopoverWrapper.propTypes = {
109
129
  placement: PropTypes.string,
@@ -113,18 +133,58 @@ PopoverWrapper.propTypes = {
113
133
  isNotClosedOnBlur: PropTypes.bool,
114
134
  isKeyboardDismissDisabled: PropTypes.bool,
115
135
  isNonModal: PropTypes.bool,
116
- isDismissable: PropTypes.bool
136
+ isDismissable: PropTypes.bool,
137
+ width: PropTypes.string,
138
+ arrowCrossOffset: PropTypes.string,
139
+ sx: PropTypes.shape({}),
140
+ direction: PropTypes.oneOf(['top', 'right', 'bottom', 'left'])
117
141
  };
118
142
  PopoverWrapper.defaultProps = {
119
143
  placement: 'bottom'
120
144
  };
121
145
  export var PopoverArrow = function PopoverArrow(props) {
122
- var others = _extends({}, props);
146
+ var arrowCrossOffset = props.arrowCrossOffset,
147
+ sx = props.sx,
148
+ direction = props.direction,
149
+ others = _objectWithoutProperties(props, _excluded3);
150
+ /* istanbul ignore next */
151
+
152
+
153
+ var calculateOffset = function calculateOffset() {
154
+ switch (true) {
155
+ case direction === 'top':
156
+ case direction === 'bottom':
157
+ return {
158
+ '&:before': {
159
+ left: "calc(50% - ".concat(arrowCrossOffset, ") !important")
160
+ }
161
+ };
162
+
163
+ case direction === 'left':
164
+ case direction === 'right':
165
+ return {
166
+ '&:before': {
167
+ top: "calc(50% - ".concat(arrowCrossOffset, ") !important")
168
+ }
169
+ };
170
+
171
+ default:
172
+ return {};
173
+ }
174
+ };
123
175
 
124
176
  return ___EmotionJSX(Box, _extends({
125
177
  variant: "popoverMenu.arrow",
126
178
  "data-popover-arrow": "arrow",
127
179
  "data-testid": "popover-arrow"
128
- }, others));
180
+ }, others, {
181
+ sx: _objectSpread(_objectSpread({}, arrowCrossOffset && calculateOffset()), sx)
182
+ }));
183
+ };
184
+ PopoverArrow.propTypes = {
185
+ width: PropTypes.string,
186
+ arrowCrossOffset: PropTypes.string,
187
+ sx: PropTypes.shape({}),
188
+ direction: PropTypes.oneOf(['top', 'right', 'bottom', 'left'])
129
189
  };
130
190
  export default PopoverContainer;
@@ -21,6 +21,7 @@ import PropTypes from 'prop-types';
21
21
  import omit from 'lodash/omit';
22
22
  import { useToggleState } from '@react-stately/toggle';
23
23
  import { useSwitch } from '@react-aria/switch';
24
+ import { usePress } from '@react-aria/interactions';
24
25
  import { useField, usePropWarning } from '../../hooks';
25
26
  import statuses from '../../utils/devUtils/constants/statuses';
26
27
  import Box from '../Box';
@@ -71,6 +72,12 @@ var SwitchField = /*#__PURE__*/forwardRef(function (props, ref) {
71
72
  var state = useToggleState(_objectSpread({
72
73
  defaultSelected: isDefaultSelected
73
74
  }, props));
75
+
76
+ var _usePress = usePress({
77
+ isDisabled: isDisabled
78
+ }),
79
+ containerPressProps = _usePress.pressProps;
80
+
74
81
  var whitelistedProps = omit(props, _Object$keys(others));
75
82
 
76
83
  var _useSwitch = useSwitch(_objectSpread({
@@ -82,9 +89,9 @@ var SwitchField = /*#__PURE__*/forwardRef(function (props, ref) {
82
89
  isSelected: inputProps.checked
83
90
  };
84
91
 
85
- var _useField = useField(_objectSpread(_objectSpread({
92
+ var _useField = useField(_objectSpread(_objectSpread(_objectSpread({
86
93
  statusClasses: statusClasses
87
- }, props), {}, {
94
+ }, containerPressProps), props), {}, {
88
95
  controlProps: _objectSpread(_objectSpread({}, controlProps), inputProps)
89
96
  })),
90
97
  fieldContainerProps = _useField.fieldContainerProps,
@@ -22,7 +22,8 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
22
22
  var TooltipTrigger = /*#__PURE__*/forwardRef(function (props, ref) {
23
23
  var _context, _useStatusClasses2;
24
24
 
25
- var children = props.children,
25
+ var arrowCrossOffset = props.arrowCrossOffset,
26
+ children = props.children,
26
27
  crossOffset = props.crossOffset,
27
28
  isDisabled = props.isDisabled,
28
29
  align = props.align,
@@ -33,7 +34,8 @@ var TooltipTrigger = /*#__PURE__*/forwardRef(function (props, ref) {
33
34
  isNotFlippable = props.isNotFlippable,
34
35
  isDarkMode = props.isDarkMode,
35
36
  hasNoArrow = props.hasNoArrow,
36
- targetRef = props.targetRef;
37
+ targetRef = props.targetRef,
38
+ width = props.width;
37
39
 
38
40
  var _React$Children$toArr = React.Children.toArray(children),
39
41
  _React$Children$toArr2 = _slicedToArray(_React$Children$toArr, 2),
@@ -81,7 +83,10 @@ var TooltipTrigger = /*#__PURE__*/forwardRef(function (props, ref) {
81
83
  placement: placement,
82
84
  arrowProps: arrowProps,
83
85
  className: classNames,
84
- hasNoArrow: hasNoArrow
86
+ hasNoArrow: hasNoArrow,
87
+ arrowCrossOffset: arrowCrossOffset,
88
+ width: width,
89
+ direction: direction
85
90
  }, positionProps, tooltipProps), tooltip);
86
91
 
87
92
  return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(PressResponder, _extends({}, triggerProps, {
@@ -132,12 +137,19 @@ TooltipTrigger.propTypes = {
132
137
  /** Tooltip offset relative to its trigger. */
133
138
  offset: PropTypes.number,
134
139
 
140
+ /** Arrow offset relative to the left of the tooltip.
141
+ * Must be passed as a px or percentage. */
142
+ arrowCrossOffset: PropTypes.string,
143
+
135
144
  /** The placement of the element with respect to its anchor element. */
136
145
  placement: PropTypes.string,
137
146
 
138
147
  /** By default, opens for both focus and hover. Can be made to open only for focus. */
139
148
  trigger: PropTypes.string,
140
149
 
150
+ /** Width applied to the wrapper of the tooltip component. */
151
+ width: PropTypes.string,
152
+
141
153
  /* The ref for the element which the overlay positions itself with respect to. */
142
154
  targetRef: PropTypes.shape({})
143
155
  };
@@ -27,6 +27,17 @@ export var withDelayProp = function withDelayProp() {
27
27
  delay: 700
28
28
  }, ___EmotionJSX(Button, null, "Hover Over Me!"), ___EmotionJSX(Tooltip, null, "Display with a delay"));
29
29
  };
30
+ export var withWidthProp = function withWidthProp() {
31
+ return ___EmotionJSX(TooltipTrigger, {
32
+ width: "200px"
33
+ }, ___EmotionJSX(Button, null, "Hover Over Me!"), ___EmotionJSX(Tooltip, null, "Custom width display"));
34
+ };
35
+ export var withArrowCrossOffsetProp = function withArrowCrossOffsetProp() {
36
+ return ___EmotionJSX(TooltipTrigger, {
37
+ arrowCrossOffset: "30px",
38
+ isOpen: true
39
+ }, ___EmotionJSX(Button, null, "Hover Over Me!"), ___EmotionJSX(Tooltip, null, "Display with a delay"));
40
+ };
30
41
  export var isOpen = function isOpen() {
31
42
  return ___EmotionJSX(TooltipTrigger, {
32
43
  isOpen: true
@@ -71,4 +71,12 @@ test('trigger press events work when a tooltip is disabled', function () {
71
71
  expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
72
72
  userEvent.click(button);
73
73
  expect(onPress).toHaveBeenCalledTimes(1);
74
+ });
75
+ test('passing in width applies the correct width to the container', function () {
76
+ getComponent({
77
+ isOpen: true,
78
+ width: '100px'
79
+ });
80
+ var arrow = screen.getByTestId('popover-container');
81
+ expect(arrow).toHaveStyle('width: 100px');
74
82
  });
@@ -16,7 +16,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
16
16
 
17
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
18
18
 
19
- import React, { useMemo, useState } from 'react';
19
+ import React, { useMemo, useState, useRef } from 'react';
20
20
  import { useFilter } from '@react-aria/i18n';
21
21
  import AccountIcon from 'mdi-react/AccountIcon';
22
22
  import AccountGroupIcon from 'mdi-react/AccountGroupIcon';
@@ -106,6 +106,8 @@ export var Default = function Default() {
106
106
  searchValue = _useState4[0],
107
107
  setSearchValue = _useState4[1];
108
108
 
109
+ var checkBoxRef = useRef(null);
110
+
109
111
  var _useFilter = useFilter({
110
112
  sensitivity: 'base'
111
113
  }),
@@ -281,7 +283,11 @@ export var Default = function Default() {
281
283
  },
282
284
  isSelected: _someInstanceProperty(selectedItems).call(selectedItems, function (el) {
283
285
  return el.key === item.key;
284
- })
286
+ }),
287
+ ref: checkBoxRef,
288
+ onClick: function onClick() {
289
+ return checkBoxRef.current.focus();
290
+ }
285
291
  }));
286
292
  })), ___EmotionJSX(CollapsiblePanel, {
287
293
  items: selectedItems,
@@ -33,11 +33,11 @@ export var thumbContainer = {
33
33
  border: '1px solid',
34
34
  borderColor: 'neutral.80',
35
35
  borderRadius: 9999,
36
- '.is-selected &': {
36
+ 'label.is-selected &': {
37
37
  bg: 'active',
38
38
  borderColor: 'active'
39
39
  },
40
- '.is-focused &, &:focus': _objectSpread({}, defaultFocus)
40
+ 'label.is-focused &, &:focus': _objectSpread({}, defaultFocus)
41
41
  };
42
42
  export var thumb = {
43
43
  width: 20,
@@ -51,7 +51,7 @@ export var thumb = {
51
51
  transitionTimingFunction: 'ease-out',
52
52
  transitionDuration: '0.1s',
53
53
  transform: 'translateX(0)',
54
- '.is-selected &': {
54
+ 'label.is-selected &': {
55
55
  transform: 'translateX(20px)',
56
56
  borderColor: 'active'
57
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.23.0-alpha.1",
3
+ "version": "1.23.0-alpha.4",
4
4
  "description": "PingUX themeable React component library",
5
5
  "author": "ux-development@pingidentity.com",
6
6
  "license": "Apache-2.0",