@pingux/astro 2.163.1-alpha.1 → 2.163.1-alpha.3

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 (58) hide show
  1. package/lib/cjs/components/ComboBoxField/ComboBoxField.js +7 -3
  2. package/lib/cjs/components/ListBox/ListBox.js +15 -0
  3. package/lib/cjs/components/ListBox/ListBox.test.js +14 -1
  4. package/lib/cjs/components/MenuItem/MenuItem.js +22 -13
  5. package/lib/cjs/components/MenuItem/MenuItem.styles.d.ts +1 -1
  6. package/lib/cjs/components/MenuItem/MenuItem.styles.js +1 -1
  7. package/lib/cjs/components/MenuItem/MenuItem.test.js +217 -194
  8. package/lib/cjs/components/MenuSection/MenuSection.js +2 -1
  9. package/lib/cjs/components/PopoverMenu/PopoverMenu.stories.js +57 -33
  10. package/lib/cjs/components/TimeZonePicker/TimeZonePicker.js +117 -140
  11. package/lib/cjs/components/TimeZonePicker/TimeZonePicker.test.js +29 -2
  12. package/lib/cjs/components/TimeZonePicker/helper.d.ts +6 -0
  13. package/lib/cjs/components/TimeZonePicker/helper.js +59 -0
  14. package/lib/cjs/components/TimeZonePicker/helper.test.js +79 -0
  15. package/lib/cjs/hooks/useGetTheme/useGetTheme.d.ts +2 -0
  16. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/colors.d.ts +3 -0
  17. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/colors.js +3 -0
  18. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/icons.d.ts +1 -0
  19. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/index.d.ts +1 -0
  20. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/menu.d.ts +15 -2
  21. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/menu.js +20 -7
  22. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.d.ts +15 -2
  23. package/lib/cjs/styles/themeOverrides/onyxSideNav.d.ts +1 -0
  24. package/lib/cjs/styles/themes/astro/customProperties/icons.d.ts +1 -0
  25. package/lib/cjs/styles/themes/astro/customProperties/icons.js +1 -1
  26. package/lib/cjs/styles/themes/astro/customProperties/index.d.ts +1 -0
  27. package/lib/cjs/styles/themes/next-gen/customProperties/icons.d.ts +1 -0
  28. package/lib/cjs/styles/themes/next-gen/customProperties/icons.js +1 -1
  29. package/lib/cjs/styles/themes/next-gen/customProperties/index.d.ts +1 -0
  30. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +34 -2
  31. package/lib/cjs/styles/themes/next-gen/variants/menu.d.ts +32 -2
  32. package/lib/cjs/styles/themes/next-gen/variants/menu.js +39 -9
  33. package/lib/cjs/styles/themes/next-gen/variants/popoverMenu.d.ts +1 -0
  34. package/lib/cjs/styles/themes/next-gen/variants/popoverMenu.js +1 -0
  35. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +33 -2
  36. package/lib/cjs/styles/themes/next-gen/variants/variants.js +1 -0
  37. package/lib/cjs/types/listBox.d.ts +1 -1
  38. package/lib/components/ComboBoxField/ComboBoxField.js +7 -3
  39. package/lib/components/ListBox/ListBox.js +15 -0
  40. package/lib/components/ListBox/ListBox.test.js +14 -1
  41. package/lib/components/MenuItem/MenuItem.js +25 -16
  42. package/lib/components/MenuItem/MenuItem.styles.js +1 -1
  43. package/lib/components/MenuItem/MenuItem.test.js +224 -201
  44. package/lib/components/MenuSection/MenuSection.js +2 -1
  45. package/lib/components/PopoverMenu/PopoverMenu.stories.js +57 -33
  46. package/lib/components/TimeZonePicker/TimeZonePicker.js +122 -146
  47. package/lib/components/TimeZonePicker/TimeZonePicker.test.js +29 -2
  48. package/lib/components/TimeZonePicker/helper.js +51 -0
  49. package/lib/components/TimeZonePicker/helper.test.js +76 -0
  50. package/lib/styles/themeOverrides/nextGenDarkMode/colors.js +3 -0
  51. package/lib/styles/themeOverrides/nextGenDarkMode/variants/menu.js +20 -7
  52. package/lib/styles/themes/astro/customProperties/icons.js +1 -1
  53. package/lib/styles/themes/next-gen/customProperties/icons.js +1 -1
  54. package/lib/styles/themes/next-gen/variants/menu.js +38 -8
  55. package/lib/styles/themes/next-gen/variants/popoverMenu.js +1 -0
  56. package/lib/styles/themes/next-gen/variants/variants.js +2 -1
  57. package/lib/tsconfig.lib.tsbuildinfo +1 -1
  58. package/package.json +1 -1
@@ -4,29 +4,59 @@ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/obje
4
4
  _Object$defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.menuItem = exports.menu = void 0;
7
+ exports.menuSection = exports.menuItem = exports.menu = void 0;
8
8
  var menu = exports.menu = {
9
9
  p: 'sm',
10
10
  border: '1px solid',
11
11
  borderColor: 'border.base'
12
12
  };
13
+ var menuSection = exports.menuSection = {
14
+ sectionTitle: {
15
+ fontWeight: '1',
16
+ fontSize: 'tiny',
17
+ lineHeight: 'md',
18
+ textTransform: 'uppercase',
19
+ letterSpacing: '1px',
20
+ height: 'unset',
21
+ py: 'sm',
22
+ px: '12px',
23
+ color: 'font.light',
24
+ ml: 0
25
+ }
26
+ };
13
27
  var menuItem = exports.menuItem = {
14
28
  item: {
15
29
  bg: 'transparent',
16
- padding: '10px 10px',
30
+ padding: '12px 12px',
17
31
  outline: 'none',
18
- color: 'text.primary',
32
+ color: 'gray-700',
33
+ fontSize: 'md',
34
+ lineHeight: 'body',
19
35
  cursor: 'pointer',
20
- '&.is-focused, &.is-selected, &.is-pressed': {
36
+ borderRadius: '4px',
37
+ '&.is-hovered': {
38
+ bg: 'gray-100',
39
+ color: '#121518',
40
+ '> *': {
41
+ color: '#121518'
42
+ }
43
+ },
44
+ '&.is-focused': {
21
45
  bg: 'gray-100',
22
- color: 'text.primary',
46
+ color: '#121518',
47
+ outline: '1px solid',
48
+ outlineOffset: '1px',
49
+ outlineColor: 'primary',
23
50
  '> *': {
24
- color: 'text.primary'
51
+ color: '#121518'
25
52
  }
26
53
  },
27
- '&.is-pressed': {
28
- color: 'text.primary',
29
- bg: 'lightblue'
54
+ '&.is-pressed, &.is-selected': {
55
+ bg: 'lightblue',
56
+ color: '#121518',
57
+ '> *': {
58
+ color: '#121518'
59
+ }
30
60
  }
31
61
  },
32
62
  separator: {
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  container: {
3
+ minWidth: string;
3
4
  transition: string;
4
5
  '&.animate': {
5
6
  opacity: number;
@@ -6,6 +6,7 @@ _Object$defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
8
  var container = {
9
+ minWidth: '150px',
9
10
  transition: 'opacity 200ms ease',
10
11
  '&.animate': {
11
12
  opacity: 0
@@ -963,23 +963,53 @@ declare const _default: {
963
963
  padding: string;
964
964
  outline: string;
965
965
  color: string;
966
+ fontSize: string;
967
+ lineHeight: string;
966
968
  cursor: string;
967
- '&.is-focused, &.is-selected, &.is-pressed': {
969
+ borderRadius: string;
970
+ '&.is-hovered': {
968
971
  bg: string;
969
972
  color: string;
970
973
  '> *': {
971
974
  color: string;
972
975
  };
973
976
  };
974
- '&.is-pressed': {
977
+ '&.is-focused': {
978
+ bg: string;
975
979
  color: string;
980
+ outline: string;
981
+ outlineOffset: string;
982
+ outlineColor: string;
983
+ '> *': {
984
+ color: string;
985
+ };
986
+ };
987
+ '&.is-pressed, &.is-selected': {
976
988
  bg: string;
989
+ color: string;
990
+ '> *': {
991
+ color: string;
992
+ };
977
993
  };
978
994
  };
979
995
  separator: {
980
996
  my: string;
981
997
  };
982
998
  };
999
+ menuSection: {
1000
+ sectionTitle: {
1001
+ fontWeight: string;
1002
+ fontSize: string;
1003
+ lineHeight: string;
1004
+ textTransform: string;
1005
+ letterSpacing: string;
1006
+ height: string;
1007
+ py: string;
1008
+ px: string;
1009
+ color: string;
1010
+ ml: number;
1011
+ };
1012
+ };
983
1013
  menuTab: {
984
1014
  ml: string;
985
1015
  };
@@ -1296,6 +1326,7 @@ declare const _default: {
1296
1326
  };
1297
1327
  popoverMenu: {
1298
1328
  container: {
1329
+ minWidth: string;
1299
1330
  transition: string;
1300
1331
  '&.animate': {
1301
1332
  opacity: number;
@@ -429,6 +429,7 @@ var _default = exports["default"] = {
429
429
  loader: loader,
430
430
  menu: _menu.menu,
431
431
  menuItem: _menu.menuItem,
432
+ menuSection: _menu.menuSection,
432
433
  menuTab: _tabs.menuTab,
433
434
  message: _messages.message,
434
435
  modal: modal,
@@ -30,7 +30,7 @@ export interface ListBoxProps extends AriaListBoxOptions<object> {
30
30
  onLoadPrev?: () => void;
31
31
  onScroll?: () => void;
32
32
  state: ListBoxStateType | SelectState<object, 'single'> | ComboBoxState<object>;
33
- renderEmptyState?: React.ReactNode;
33
+ renderEmptyState?: () => ReactNode;
34
34
  variant?: string;
35
35
  children?: CollectionChildren<object>;
36
36
  isCondensed?: boolean;
@@ -10,7 +10,7 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
10
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
11
11
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
12
12
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
13
- var _excluded = ["hasAutoFocus", "hasAddOption", "hasCustomValue", "hasNoEmptySelection", "selectedKey", "onSelectionChange", "defaultItems", "items", "loadingState", "onLoadMore", "inputValue", "isReadOnly", "menuTrigger", "isNotFlippable", "direction", "scrollBoxProps", "controlProps", "defaultFilter", "status", "helperText"],
13
+ var _excluded = ["hasAutoFocus", "hasAddOption", "hasCustomValue", "hasNoEmptySelection", "selectedKey", "onSelectionChange", "defaultItems", "items", "loadingState", "onLoadMore", "inputValue", "isReadOnly", "menuTrigger", "isNotFlippable", "direction", "scrollBoxProps", "controlProps", "defaultFilter", "status", "helperText", "renderEmptyState", "allowsEmptyCollection"],
14
14
  _excluded2 = ["shouldFocusOnHover", "shouldSelectOnPressUp", "UNSTABLE_itemBehavior"];
15
15
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
16
16
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
@@ -56,6 +56,8 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
56
56
  defaultFilter = props.defaultFilter,
57
57
  status = props.status,
58
58
  helperText = props.helperText,
59
+ renderEmptyState = props.renderEmptyState,
60
+ allowsEmptyCollection = props.allowsEmptyCollection,
59
61
  others = _objectWithoutProperties(props, _excluded);
60
62
  var _getAriaAttributeProp = getAriaAttributeProps(others),
61
63
  nonAriaProps = _getAriaAttributeProp.nonAriaProps;
@@ -71,7 +73,8 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
71
73
  menuTrigger: menuTrigger,
72
74
  shouldFlip: !isNotFlippable,
73
75
  direction: direction,
74
- label: 'default'
76
+ label: 'default',
77
+ allowsEmptyCollection: allowsEmptyCollection
75
78
  }, nonAriaProps);
76
79
  var popoverRef = useRef();
77
80
  var buttonRef = useRef();
@@ -197,7 +200,8 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
197
200
  isLoading: loadingState === loadingStates.LOADING_MORE,
198
201
  onLoadMore: onLoadMore,
199
202
  isFocusedOnHover: shouldFocusOnHover,
200
- isSelectedOnPressUp: shouldSelectOnPressUp
203
+ isSelectedOnPressUp: shouldSelectOnPressUp,
204
+ renderEmptyState: renderEmptyState
201
205
  }, otherListBoxProps))), ___EmotionJSX(DismissButton, {
202
206
  onDismiss: state.close
203
207
  })));
@@ -153,6 +153,18 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
153
153
  };
154
154
  }, [isLoading, onLoadPrev, items]);
155
155
  useLoadPrev(memoedLoadMoreProps, listBoxRef);
156
+ var EmptyState = function EmptyState() {
157
+ var emptyState = renderEmptyState ? renderEmptyState() : null;
158
+ if (emptyState == null) {
159
+ return null;
160
+ }
161
+ return ___EmotionJSX(Box, {
162
+ as: "li",
163
+ isRow: true,
164
+ role: "option",
165
+ variant: "listBox.option"
166
+ }, emptyState);
167
+ };
156
168
  return ___EmotionJSX(ListBoxContext.Provider, {
157
169
  value: state
158
170
  }, ___EmotionJSX(Box, {
@@ -194,6 +206,9 @@ var ListBox = /*#__PURE__*/forwardRef(function (props, ref) {
194
206
  "aria-label": "Loading more..."
195
207
  });
196
208
  }
209
+ if (type === collectionTypes.PLACEHOLDER) {
210
+ return ___EmotionJSX(EmptyState, null);
211
+ }
197
212
  return null;
198
213
  })));
199
214
  });
@@ -157,4 +157,17 @@ test('should have is-focused class when hover', /*#__PURE__*/_asyncToGenerator(/
157
157
  return _context.stop();
158
158
  }
159
159
  }, _callee);
160
- })));
160
+ })));
161
+ test('should render empty state when no items', function () {
162
+ getComponent({
163
+ items: [],
164
+ renderEmptyState: function renderEmptyState() {
165
+ return ___EmotionJSX("div", {
166
+ "data-testid": "empty-state"
167
+ }, "No items");
168
+ }
169
+ });
170
+ var emptyState = screen.getByTestId('empty-state');
171
+ expect(emptyState).toBeInTheDocument();
172
+ expect(emptyState).toHaveTextContent('No items');
173
+ });
@@ -1,13 +1,15 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
- import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
2
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
4
3
  var _excluded = ["isSeparator", "isPressed", "data-id"];
5
- import React, { forwardRef, useState } from 'react';
4
+ import React, { forwardRef } from 'react';
6
5
  import { mergeProps, useMenuItem } from 'react-aria';
7
- import { useFocus, useHover, usePress } from '@react-aria/interactions';
6
+ import CheckIcon from '@pingux/mdi-react/CheckIcon';
7
+ import { useFocusRing } from '@react-aria/focus';
8
+ import { useHover, usePress } from '@react-aria/interactions';
8
9
  import { v4 as uuid } from 'uuid';
10
+ import { Icon } from '../..';
9
11
  import { useMenuContext } from '../../context/MenuContext';
10
- import { useLocalOrForwardRef, usePropWarning, useStatusClasses } from '../../hooks';
12
+ import { useGetTheme, useLocalOrForwardRef, usePropWarning, useStatusClasses } from '../../hooks';
11
13
  import Box from '../Box';
12
14
 
13
15
  /**
@@ -20,7 +22,6 @@ var MenuItem = /*#__PURE__*/forwardRef(function (props, ref) {
20
22
  var _item$key;
21
23
  var item = props.item,
22
24
  isPropDisabled = props.isDisabled,
23
- isFocusVisible = props.isFocusVisible,
24
25
  isNotFocusedOnHover = props.isNotFocusedOnHover,
25
26
  className = props.className,
26
27
  state = props.state;
@@ -48,10 +49,6 @@ var MenuItem = /*#__PURE__*/forwardRef(function (props, ref) {
48
49
  closeOnSelect: shouldCloseOnSelect
49
50
  }, state, menuItemRef),
50
51
  menuItemProps = _useMenuItem.menuItemProps;
51
- var _useState = useState(false),
52
- _useState2 = _slicedToArray(_useState, 2),
53
- isFocused = _useState2[0],
54
- setFocused = _useState2[1];
55
52
  var _usePress = usePress({
56
53
  ref: menuItemRef,
57
54
  isDisabled: isDisabled,
@@ -59,34 +56,46 @@ var MenuItem = /*#__PURE__*/forwardRef(function (props, ref) {
59
56
  }),
60
57
  pressProps = _usePress.pressProps,
61
58
  isPressed = _usePress.isPressed;
62
- var _useFocus = useFocus({
63
- onFocusChange: setFocused
64
- }),
65
- focusProps = _useFocus.focusProps;
59
+ var _useFocusRing = useFocusRing(),
60
+ focusProps = _useFocusRing.focusProps,
61
+ isFocusVisible = _useFocusRing.isFocusVisible;
66
62
  var _useHover = useHover({
67
63
  isDisabled: isDisabled
68
64
  }),
69
65
  hoverProps = _useHover.hoverProps,
70
66
  isHovered = _useHover.isHovered;
71
67
  var _useStatusClasses = useStatusClasses(className, {
72
- isFocused: isFocused || isHovered && !isFocusVisible,
68
+ isFocused: isFocusVisible && !isNotFocusedOnHover,
73
69
  isDisabled: isDisabled,
74
70
  isSelected: isSelected,
75
- isPressed: isPressed
71
+ isPressed: isPressed,
72
+ isHovered: isHovered
76
73
  }),
77
74
  classNames = _useStatusClasses.classNames;
78
75
  if (isNotFocusedOnHover) {
79
76
  delete menuItemProps.onPointerEnter;
80
77
  delete menuItemProps.onPointerLeave;
81
78
  }
79
+ var _useGetTheme = useGetTheme(),
80
+ isOnyx = _useGetTheme.themeState.isOnyx;
82
81
  return ___EmotionJSX(Box, _extends({
83
82
  as: "li",
83
+ isRow: true,
84
+ alignItems: "center",
85
+ justifyContent: "space-between",
84
86
  className: classNames,
85
87
  ref: menuItemRef,
86
88
  variant: isSeparator ? 'menuItem.separator' : 'menuItem.item',
87
89
  "data-id": dataId,
88
90
  "aria-disabled": isDisabled
89
- }, mergeProps(pressProps, hoverProps, focusProps, menuItemProps, others)), rendered);
91
+ }, mergeProps(pressProps, hoverProps, focusProps, menuItemProps, others)), rendered, isSelected && isOnyx && ___EmotionJSX(Icon, {
92
+ icon: CheckIcon,
93
+ title: {
94
+ name: 'Check Icon'
95
+ },
96
+ color: "success.bright",
97
+ size: "sm"
98
+ }));
90
99
  });
91
100
  MenuItem.displayName = 'MenuItem';
92
101
  MenuItem.defaultProps = {
@@ -4,7 +4,7 @@ var item = {
4
4
  outline: 'none',
5
5
  cursor: 'pointer',
6
6
  fontFamily: 'standard',
7
- '&.is-focused, &.is-selected, &.is-pressed': {
7
+ '&.is-focused, &.is-selected, &.is-pressed, &.is-hovered': {
8
8
  color: 'white',
9
9
  bg: 'active',
10
10
  '> *': {