@autoguru/overdrive 4.45.2 → 4.47.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 (95) hide show
  1. package/dist/components/Calendar/Calendar.css.d.ts +8 -0
  2. package/dist/components/Calendar/Calendar.css.d.ts.map +1 -0
  3. package/dist/components/Calendar/Calendar.css.js +113 -0
  4. package/dist/components/Calendar/Calendar.d.ts +64 -0
  5. package/dist/components/Calendar/Calendar.d.ts.map +1 -0
  6. package/dist/components/Calendar/Calendar.js +122 -0
  7. package/dist/components/Calendar/CalendarButton.d.ts +7 -0
  8. package/dist/components/Calendar/CalendarButton.d.ts.map +1 -0
  9. package/dist/components/{DateTimePicker → Calendar}/CalendarButton.js +4 -3
  10. package/dist/components/{DateTimePicker → Calendar}/CalendarGrid.d.ts +4 -1
  11. package/dist/components/Calendar/CalendarGrid.d.ts.map +1 -0
  12. package/dist/components/{DateTimePicker → Calendar}/CalendarGrid.js +8 -7
  13. package/dist/components/Calendar/index.d.ts +3 -0
  14. package/dist/components/Calendar/index.d.ts.map +1 -0
  15. package/dist/components/Calendar/index.js +3 -0
  16. package/dist/components/DatePicker/DatePicker.css.d.ts +2 -1
  17. package/dist/components/DatePicker/DatePicker.css.d.ts.map +1 -1
  18. package/dist/components/DatePicker/DatePicker.css.js +60 -30
  19. package/dist/components/DatePicker/DatePicker.d.ts +83 -5
  20. package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
  21. package/dist/components/DatePicker/DatePicker.js +160 -43
  22. package/dist/components/DateTimePicker/DateTimePicker.css.d.ts +0 -15
  23. package/dist/components/DateTimePicker/DateTimePicker.css.d.ts.map +1 -1
  24. package/dist/components/DateTimePicker/DateTimePicker.css.js +16 -99
  25. package/dist/components/DateTimePicker/DateTimePicker.d.ts +5 -2
  26. package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +1 -1
  27. package/dist/components/DateTimePicker/DateTimePicker.js +24 -80
  28. package/dist/components/OptionGrid/OptionGrid.css.d.ts +33 -34
  29. package/dist/components/OptionGrid/OptionGrid.css.d.ts.map +1 -1
  30. package/dist/components/OptionGrid/OptionGrid.css.js +208 -146
  31. package/dist/components/OptionGrid/OptionGrid.d.ts +16 -5
  32. package/dist/components/OptionGrid/OptionGrid.d.ts.map +1 -1
  33. package/dist/components/OptionGrid/OptionGrid.js +38 -13
  34. package/dist/components/OptionList/OptionList.css.d.ts +2 -10
  35. package/dist/components/OptionList/OptionList.css.d.ts.map +1 -1
  36. package/dist/components/OptionList/OptionList.css.js +92 -92
  37. package/dist/components/OptionList/OptionList.d.ts +10 -3
  38. package/dist/components/OptionList/OptionList.d.ts.map +1 -1
  39. package/dist/components/OptionList/OptionListItem.js +3 -3
  40. package/dist/components/Popover/Popover.css.d.ts +4 -0
  41. package/dist/components/Popover/Popover.css.d.ts.map +1 -0
  42. package/dist/components/Popover/Popover.css.js +46 -0
  43. package/dist/components/Popover/Popover.d.ts +34 -0
  44. package/dist/components/Popover/Popover.d.ts.map +1 -0
  45. package/dist/components/Popover/Popover.js +127 -0
  46. package/dist/components/Popover/PopoverTrigger.d.ts +51 -0
  47. package/dist/components/Popover/PopoverTrigger.d.ts.map +1 -0
  48. package/dist/components/Popover/PopoverTrigger.js +94 -0
  49. package/dist/components/Popover/index.d.ts +5 -0
  50. package/dist/components/Popover/index.d.ts.map +1 -0
  51. package/dist/components/Popover/index.js +4 -0
  52. package/dist/components/SearchBar/SearchBar.css.d.ts +7 -12
  53. package/dist/components/SearchBar/SearchBar.css.d.ts.map +1 -1
  54. package/dist/components/SearchBar/SearchBar.css.js +121 -66
  55. package/dist/components/SearchBar/SearchBar.d.ts.map +1 -1
  56. package/dist/components/SearchBar/SearchBar.js +17 -10
  57. package/dist/components/Slider/Slider.css.d.ts +9 -0
  58. package/dist/components/Slider/Slider.css.d.ts.map +1 -0
  59. package/dist/components/Slider/Slider.css.js +92 -0
  60. package/dist/components/Slider/Slider.d.ts +47 -0
  61. package/dist/components/Slider/Slider.d.ts.map +1 -0
  62. package/dist/components/Slider/Slider.js +137 -0
  63. package/dist/components/Slider/index.d.ts +2 -0
  64. package/dist/components/Slider/index.d.ts.map +1 -0
  65. package/dist/components/Slider/index.js +3 -0
  66. package/dist/components/index.d.ts +1 -0
  67. package/dist/components/index.d.ts.map +1 -1
  68. package/dist/components/index.js +1 -0
  69. package/dist/hooks/useMedia/useMedia.spec.d.ts +2 -0
  70. package/dist/hooks/useMedia/useMedia.spec.d.ts.map +1 -0
  71. package/dist/hooks/useMedia/useMedia.spec.js +288 -0
  72. package/dist/styles/selectors.d.ts +14 -0
  73. package/dist/styles/selectors.d.ts.map +1 -0
  74. package/dist/styles/selectors.js +27 -0
  75. package/dist/utils/css.d.ts +0 -22
  76. package/dist/utils/css.d.ts.map +1 -1
  77. package/dist/utils/css.js +0 -52
  78. package/dist/utils/css.spec.d.ts +2 -0
  79. package/dist/utils/css.spec.d.ts.map +1 -0
  80. package/dist/utils/css.spec.js +66 -0
  81. package/dist/utils/dateFormat.d.ts +24 -0
  82. package/dist/utils/dateFormat.d.ts.map +1 -0
  83. package/dist/utils/dateFormat.js +57 -0
  84. package/dist/utils/object.spec.d.ts +2 -0
  85. package/dist/utils/object.spec.d.ts.map +1 -0
  86. package/dist/utils/object.spec.js +135 -0
  87. package/dist/utils/responsiveStyle.spec.d.ts +2 -0
  88. package/dist/utils/responsiveStyle.spec.d.ts.map +1 -0
  89. package/dist/utils/responsiveStyle.spec.js +134 -0
  90. package/dist/utils/utils.spec.d.ts.map +1 -1
  91. package/dist/utils/utils.spec.js +342 -0
  92. package/package.json +25 -25
  93. package/dist/components/DateTimePicker/CalendarButton.d.ts +0 -4
  94. package/dist/components/DateTimePicker/CalendarButton.d.ts.map +0 -1
  95. package/dist/components/DateTimePicker/CalendarGrid.d.ts.map +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- const _excluded = ["className", "columns", "indicator", "label", "layout", "selectionMode", "testId"];
5
+ const _excluded = ["className", "columns", "indicator", "isLoading", "label", "layout", "selectionMode", "testId"];
6
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
8
  import { CheckIcon } from '@autoguru/icons';
@@ -11,7 +11,8 @@ import React from 'react';
11
11
  import { ListBox, ListBoxItem, Text } from 'react-aria-components';
12
12
  import { dataAttrs } from "../../utils/dataAttrs.js";
13
13
  import { Icon } from "../Icon/index.js";
14
- import { descriptionStyle, gridContainerStyle, labelStyle, styledCheckbox, styledGrid, styledGridItem, styledRadioButton, styleIndicator } from "./OptionGrid.css.js";
14
+ import { LoadingBox } from "../LoadingBox/LoadingBox.js";
15
+ import { checkboxStyle, descriptionStyle, gridContainerStyle, gridItemContainerStyle, gridItemStyle, gridVariants, indicatorStyle, labelStyle, radioButtonStyle } from "./OptionGrid.css.js";
15
16
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
16
17
  /**
17
18
  * The OptionGrid is primarily used in the booking flow to provide large selectable tiles to the user. It is not a form
@@ -19,10 +20,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
19
20
  * and implements a listbox behaviour without wrapping an input element. It supports controlled and uncontrolled usage.
20
21
  * Following ARIA guidelines, the arrow keys can be used to navigate withing the group of options.
21
22
  *
23
+ * The ListBox implementation provides a Set of selected keys to the `onSelectionChange` handler. To preselect options
24
+ * in uncontrolled usage, simply provide a default selection using the `defaultSelectedKeys` prop.
22
25
  * See more details on react-aria [ListBox props](https://react-spectrum.adobe.com/react-aria/ListBox.html#listbox-1).
23
26
  *
24
- * Not yet implemented: disabled appearance, empty state, loading state, error state.
25
- *
26
27
  * Accessibility note: The ARIA spec prohibits listbox items from including interactive content such as buttons,
27
28
  * tooltips, etc. For these cases a completely different implementation is required (e.g. react-aria [GridList](
28
29
  * https://react-spectrum.adobe.com/react-aria/GridList.html))
@@ -32,19 +33,36 @@ export const OptionGrid = _ref => {
32
33
  className,
33
34
  columns,
34
35
  indicator = 'checkbox',
36
+ isLoading = false,
35
37
  label,
36
38
  layout = 'grid',
37
39
  selectionMode = 'multiple',
38
40
  testId
39
41
  } = _ref,
40
42
  props = _objectWithoutProperties(_ref, _excluded);
43
+ if (isLoading) {
44
+ return /*#__PURE__*/_jsx("div", {
45
+ className: gridContainerStyle,
46
+ children: /*#__PURE__*/_jsx("div", {
47
+ className: gridVariants({
48
+ columns
49
+ }),
50
+ children: Array.from({
51
+ length: Number(columns) || 1
52
+ }, (_, idx) => /*#__PURE__*/_jsx("div", {
53
+ className: gridItemContainerStyle,
54
+ children: /*#__PURE__*/_jsx(LoadingBox, {})
55
+ }, idx))
56
+ })
57
+ });
58
+ }
41
59
  return /*#__PURE__*/_jsx("div", {
42
60
  className: gridContainerStyle,
43
61
  children: /*#__PURE__*/_jsx(ListBox, _objectSpread(_objectSpread(_objectSpread({
44
62
  "aria-label": label,
45
63
  layout: layout,
46
64
  selectionMode: selectionMode,
47
- className: clsx([styledGrid({
65
+ className: clsx([gridVariants({
48
66
  columns
49
67
  }), className])
50
68
  }, dataAttrs({
@@ -52,13 +70,18 @@ export const OptionGrid = _ref => {
52
70
  })), props), {}, {
53
71
  children: ({
54
72
  description,
73
+ disabled,
55
74
  icon,
56
75
  label,
57
76
  name
58
- }) => /*#__PURE__*/_jsx(ListBoxItem, {
59
- className: styledGridItem(),
77
+ }) => /*#__PURE__*/_jsx(ListBoxItem, _objectSpread(_objectSpread({
78
+ className: gridItemStyle,
60
79
  id: name,
61
- textValue: label,
80
+ isDisabled: disabled,
81
+ textValue: label
82
+ }, dataAttrs({
83
+ disabled
84
+ })), {}, {
62
85
  children: ({
63
86
  isFocusVisible,
64
87
  isHovered,
@@ -71,10 +94,11 @@ export const OptionGrid = _ref => {
71
94
  icon: icon,
72
95
  size: "100%"
73
96
  });
74
- const styledIndicator = indicator === 'radio' ? styledRadioButton : styledCheckbox;
97
+ const styledIndicator = indicator === 'radio' ? radioButtonStyle : checkboxStyle;
75
98
  return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
76
- className: styledIndicator()
99
+ className: styledIndicator
77
100
  }, dataAttrs({
101
+ disabled,
78
102
  'focus-visible': isFocusVisible,
79
103
  hover: isHovered,
80
104
  selected: isSelected
@@ -86,7 +110,7 @@ export const OptionGrid = _ref => {
86
110
  };
87
111
  return /*#__PURE__*/_jsxs(_Fragment, {
88
112
  children: [hasIndicator && /*#__PURE__*/_jsx("div", {
89
- className: styleIndicator,
113
+ className: indicatorStyle,
90
114
  children: /*#__PURE__*/_jsx(IndicatorIcon, {})
91
115
  }), /*#__PURE__*/_jsxs("div", {
92
116
  children: [/*#__PURE__*/_jsx(Text, {
@@ -103,7 +127,8 @@ export const OptionGrid = _ref => {
103
127
  })]
104
128
  });
105
129
  }
106
- })
130
+ }))
107
131
  }))
108
132
  });
109
- };
133
+ };
134
+ OptionGrid.displayName = 'OptionGrid';
@@ -1,15 +1,7 @@
1
1
  export declare const groupStyle: string;
2
2
  export declare const groupLabelStyle: string;
3
3
  export declare const descriptionStyle: string;
4
- export declare const styledOptionItem: import("@vanilla-extract/recipes").RuntimeFn<{
5
- [x: string]: {
6
- [x: string]: string | import("@vanilla-extract/css").ComplexStyleRule;
7
- };
8
- }>;
4
+ export declare const optionItemStyle: string;
9
5
  export declare const itemLabelStyle: string;
10
- export declare const checkbox: import("@vanilla-extract/recipes").RuntimeFn<{
11
- [x: string]: {
12
- [x: string]: string | import("@vanilla-extract/css").ComplexStyleRule;
13
- };
14
- }>;
6
+ export declare const checkbox: string;
15
7
  //# sourceMappingURL=OptionList.css.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OptionList.css.d.ts","sourceRoot":"","sources":["../../../lib/components/OptionList/OptionList.css.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,UAAU,QAA0C,CAAC;AAElE,eAAO,MAAM,eAAe,QAK1B,CAAC;AAEH,eAAO,MAAM,gBAAgB,QAI3B,CAAC;AAIH,eAAO,MAAM,gBAAgB;;;;EA2C3B,CAAC;AAEH,eAAO,MAAM,cAAc,QAKzB,CAAC;AAmBH,eAAO,MAAM,QAAQ;;;;EA2BnB,CAAC"}
1
+ {"version":3,"file":"OptionList.css.d.ts","sourceRoot":"","sources":["../../../lib/components/OptionList/OptionList.css.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,UAAU,QAErB,CAAC;AAEH,eAAO,MAAM,eAAe,QAI1B,CAAC;AAEH,eAAO,MAAM,gBAAgB,QAW3B,CAAC;AAGH,eAAO,MAAM,eAAe,QA4C1B,CAAC;AAEH,eAAO,MAAM,cAAc,QAIzB,CAAC;AAGH,eAAO,MAAM,QAAQ,QAmCnB,CAAC"}
@@ -3,108 +3,108 @@
3
3
  import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
4
4
  __vanilla_filescope__.setFileScope("lib/components/OptionList/OptionList.css.ts", "@autoguru/overdrive");
5
5
  import { style } from '@vanilla-extract/css';
6
- import { recipe } from '@vanilla-extract/recipes';
7
6
  import { focusOutlineStyle } from "../../styles/focusOutline.css.js";
7
+ import { cssLayerComponent } from "../../styles/layers.css.js";
8
+ import { selectors } from "../../styles/selectors.js";
8
9
  import { sprinkles } from "../../styles/sprinkles.css.js";
9
- import { overdriveTokens as tokens } from "../../themes/theme.css.js";
10
- import { interactionStyle } from "../../utils/css.js"; // === Group styles
11
- export const groupStyle = style({
12
- marginTop: tokens.space['6']
13
- }, "groupStyle");
14
- export const groupLabelStyle = style({
15
- fontSize: tokens.typography.size['7'].fontSize,
16
- fontWeight: tokens.typography.fontWeight.bold,
17
- lineHeight: tokens.typography.size['7'].lineHeight,
18
- marginBottom: tokens.space['3']
19
- }, "groupLabelStyle");
20
- export const descriptionStyle = style({
21
- color: tokens.colours.gamut.gray400,
22
- fontSize: tokens.typography.size[4].fontSize,
23
- lineHeight: tokens.typography.size[4].lineHeight
24
- }, "descriptionStyle");
10
+ import { overdriveTokens as tokens } from "../../themes/theme.css.js"; // === Group styles
11
+ export const groupStyle = sprinkles({
12
+ mt: '6'
13
+ });
14
+ export const groupLabelStyle = sprinkles({
15
+ text: '7',
16
+ fontWeight: 'bold',
17
+ mb: '3'
18
+ });
19
+ export const descriptionStyle = style([sprinkles({
20
+ text: '4'
21
+ }), {
22
+ '@layer': {
23
+ [cssLayerComponent]: {
24
+ color: tokens.colours.gamut.gray400
25
+ }
26
+ }
27
+ }], "descriptionStyle");
25
28
 
26
29
  // === Option item styles
27
- const buttonBorderRadius = tokens.border.radius['md'];
28
- export const styledOptionItem = recipe({
29
- base: [{
30
- background: tokens.colours.background.body,
31
- borderColor: tokens.border.colours.gray,
32
- borderStyle: 'solid',
33
- borderWidth: tokens.border.width['1'],
34
- display: 'flex',
35
- gap: tokens.space['2'],
36
- padding: `${tokens.space['3']} ${tokens.space['4']}`,
37
- width: '100%',
38
- userSelect: 'none'
39
- }, interactionStyle({
40
- disabled: {
30
+ export const optionItemStyle = style([sprinkles({
31
+ borderColour: 'gray',
32
+ borderStyle: 'solid',
33
+ borderWidth: '1',
34
+ display: 'flex',
35
+ gap: '2',
36
+ paddingY: '3',
37
+ paddingX: '4',
38
+ userSelect: 'none',
39
+ width: 'full'
40
+ }), {
41
+ '@layer': {
42
+ [cssLayerComponent]: {
41
43
  background: tokens.colours.background.body,
42
- cursor: 'default'
43
- },
44
- hover: {
45
- background: tokens.colours.gamut.gray200,
46
- cursor: 'pointer'
47
- },
48
- focusVisible: {
49
- background: tokens.colours.gamut.gray200
50
- }
51
- }), {
52
- selectors: {
53
- ['&+&']: {
54
- borderTopStyle: 'none'
55
- },
56
- ['&:first-child']: {
57
- borderTopLeftRadius: buttonBorderRadius,
58
- borderTopRightRadius: buttonBorderRadius
59
- },
60
- ['&:last-child']: {
61
- borderBottomLeftRadius: buttonBorderRadius,
62
- borderBottomRightRadius: buttonBorderRadius
44
+ selectors: {
45
+ ['&+&']: {
46
+ borderTopStyle: 'none'
47
+ },
48
+ ['&:first-child']: {
49
+ borderTopLeftRadius: tokens.border.radius.md,
50
+ borderTopRightRadius: tokens.border.radius.md
51
+ },
52
+ ['&:last-child']: {
53
+ borderBottomLeftRadius: tokens.border.radius.md,
54
+ borderBottomRightRadius: tokens.border.radius.md
55
+ },
56
+ [selectors.hoverNotDisabled]: {
57
+ background: tokens.colours.gamut.gray200,
58
+ cursor: 'pointer'
59
+ },
60
+ [selectors.focusVisible]: {
61
+ background: tokens.colours.gamut.gray200
62
+ },
63
+ [selectors.disabled]: {
64
+ background: tokens.colours.background.body,
65
+ cursor: 'default'
66
+ }
63
67
  }
64
68
  }
65
- }, focusOutlineStyle]
66
- }, "styledOptionItem");
67
- export const itemLabelStyle = style({
69
+ }
70
+ }, focusOutlineStyle], "optionItemStyle");
71
+ export const itemLabelStyle = sprinkles({
68
72
  alignSelf: 'center',
69
- fontSize: tokens.typography.size['3'].fontSize,
70
- lineHeight: tokens.typography.size['3'].lineHeight,
71
- width: '100%'
72
- }, "itemLabelStyle");
73
+ text: '3',
74
+ width: 'full'
75
+ });
73
76
 
74
77
  // === Checkbox styles
75
- const checkboxTransition = style({
76
- transitionDuration: '100ms',
77
- transitionProperty: 'background',
78
- transitionTimingFunction: 'ease-in'
79
- }, "checkboxTransition");
80
- const checkboxHovered = style({
81
- selectors: {
82
- [`${styledOptionItem.classNames.base}:hover &:not([data-checked],[data-disabled])`]: {
83
- background: tokens.colours.gamut.gray300,
84
- color: tokens.colours.background.body
78
+ export const checkbox = style([sprinkles({
79
+ alignItems: 'center',
80
+ display: 'flex',
81
+ flexShrink: '0',
82
+ justifyContent: 'center',
83
+ size: '6',
84
+ borderRadius: 'sm',
85
+ borderStyle: 'solid',
86
+ borderWidth: '1'
87
+ }), {
88
+ '@layer': {
89
+ [cssLayerComponent]: {
90
+ background: tokens.colours.background.body,
91
+ borderColor: tokens.border.colours.gray,
92
+ color: 'transparent',
93
+ transitionDuration: '100ms',
94
+ transitionProperty: 'background',
95
+ transitionTimingFunction: 'ease-in',
96
+ selectors: {
97
+ [selectors.checked]: {
98
+ background: tokens.colours.gamut.gray900,
99
+ borderColor: tokens.border.colours.dark,
100
+ color: tokens.colours.background.body
101
+ },
102
+ [`${optionItemStyle}:hover &:not([data-checked],[data-disabled])`]: {
103
+ background: tokens.colours.gamut.gray300,
104
+ color: tokens.colours.background.body
105
+ }
106
+ }
85
107
  }
86
108
  }
87
- }, "checkboxHovered");
88
- export const checkbox = recipe({
89
- base: [{
90
- background: tokens.colours.background.body,
91
- borderColor: tokens.border.colours.gray,
92
- borderStyle: 'solid',
93
- borderRadius: tokens.border.radius['sm'],
94
- borderWidth: tokens.border.width['1'],
95
- color: 'transparent'
96
- }, interactionStyle({
97
- selected: {
98
- background: tokens.colours.gamut.gray900,
99
- borderColor: tokens.border.colours.dark,
100
- color: tokens.colours.background.body
101
- }
102
- }), sprinkles({
103
- alignItems: 'center',
104
- display: 'flex',
105
- flexShrink: '0',
106
- justifyContent: 'center',
107
- size: '6'
108
- }), checkboxHovered, checkboxTransition]
109
- }, "checkbox");
109
+ }], "checkbox");
110
110
  __vanilla_filescope__.endFileScope();
@@ -43,6 +43,7 @@ export declare const OptionList: {
43
43
  Item: {
44
44
  (props: {
45
45
  name?: string | undefined;
46
+ form?: string | undefined;
46
47
  value: string;
47
48
  autoFocus?: boolean | undefined;
48
49
  id?: string | undefined;
@@ -58,13 +59,19 @@ export declare const OptionList: {
58
59
  onChange?: ((isSelected: boolean) => void) | undefined;
59
60
  onKeyDown?: ((e: import("@react-types/shared").KeyboardEvent) => void) | undefined;
60
61
  onKeyUp?: ((e: import("@react-types/shared").KeyboardEvent) => void) | undefined;
61
- isDisabled?: boolean | undefined;
62
- isReadOnly?: boolean | undefined;
63
- onFocusChange?: ((isFocused: boolean) => void) | undefined;
62
+ onClick?: ((e: React.MouseEvent<import("@react-types/shared").FocusableElement>) => void) | undefined;
64
63
  excludeFromTabOrder?: boolean | undefined;
64
+ isDisabled?: boolean | undefined;
65
65
  isRequired?: boolean | undefined;
66
66
  isInvalid?: boolean | undefined;
67
67
  validationState?: import("react-stately").ValidationState | undefined;
68
+ onFocusChange?: ((isFocused: boolean) => void) | undefined;
69
+ isReadOnly?: boolean | undefined;
70
+ onPress?: ((e: import("react-aria").PressEvent) => void) | undefined;
71
+ onPressStart?: ((e: import("react-aria").PressEvent) => void) | undefined;
72
+ onPressEnd?: ((e: import("react-aria").PressEvent) => void) | undefined;
73
+ onPressChange?: ((isPressed: boolean) => void) | undefined;
74
+ onPressUp?: ((e: import("react-aria").PressEvent) => void) | undefined;
68
75
  validationBehavior?: "aria" | "native" | undefined;
69
76
  validate?: ((value: boolean) => import("@react-types/shared").ValidationError | true | null | undefined) | undefined;
70
77
  }): React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"OptionList.d.ts","sourceRoot":"","sources":["../../../lib/components/OptionList/OptionList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAoB,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,eAAe,CAAC;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAU9C,KAAK,iBAAiB,GAAG,IAAI,CAC5B,KAAK,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAClC,WAAW,GAAG,KAAK,GAAG,OAAO,CAC7B,CAAC;AAEF,MAAM,WAAW,eAChB,SAAQ,sBAAsB,EAC7B,iBAAiB,EACjB,UAAU;IACX;;OAEG;IACH,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACvC,WAAW,CAAC,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACtD;;OAEG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;CAC9C;AAED,eAAO,MAAM,iBAAiB,0CAAiD,CAAC;AAEhF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU;YAAW,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BhD,CAAC"}
1
+ {"version":3,"file":"OptionList.d.ts","sourceRoot":"","sources":["../../../lib/components/OptionList/OptionList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAoB,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,eAAe,CAAC;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAU9C,KAAK,iBAAiB,GAAG,IAAI,CAC5B,KAAK,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAClC,WAAW,GAAG,KAAK,GAAG,OAAO,CAC7B,CAAC;AAEF,MAAM,WAAW,eAChB,SAAQ,sBAAsB,EAC7B,iBAAiB,EACjB,UAAU;IACX;;OAEG;IACH,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACvC,WAAW,CAAC,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACpD;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACtD;;OAEG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;CAC9C;AAED,eAAO,MAAM,iBAAiB,0CAAiD,CAAC;AAEhF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU;YAAW,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BhD,CAAC"}
@@ -11,7 +11,7 @@ import { dataAttrs } from "../../utils/dataAttrs.js";
11
11
  import { Icon } from "../Icon/index.js";
12
12
  import { VisuallyHidden } from "../VisuallyHidden/index.js";
13
13
  import { OptionListContext } from "./OptionList.js";
14
- import { checkbox, itemLabelStyle, styledOptionItem } from "./OptionList.css.js";
14
+ import { checkbox, itemLabelStyle, optionItemStyle } from "./OptionList.css.js";
15
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
16
  /**
17
17
  * The OptionListItem is used to populate OptionList. They are outlined with a large interactive area and flexible
@@ -29,7 +29,7 @@ export const OptionListItem = props => {
29
29
  focusProps
30
30
  } = useFocusRing();
31
31
  return /*#__PURE__*/_jsxs("label", _objectSpread(_objectSpread({
32
- className: styledOptionItem()
32
+ className: optionItemStyle
33
33
  }, dataAttrs({
34
34
  'focus-visible': isFocusVisible
35
35
  })), {}, {
@@ -44,7 +44,7 @@ export const OptionListItem = props => {
44
44
  width: 'full'
45
45
  }),
46
46
  children: [/*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
47
- className: checkbox()
47
+ className: checkbox
48
48
  }, dataAttrs({
49
49
  checked: isSelected
50
50
  })), {}, {
@@ -0,0 +1,4 @@
1
+ export declare const overlayStyle: string;
2
+ export declare const triggerStyle: string;
3
+ export declare const fullScreenStyle: string;
4
+ //# sourceMappingURL=Popover.css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popover.css.d.ts","sourceRoot":"","sources":["../../../lib/components/Popover/Popover.css.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,QAiBvB,CAAC;AAEH,eAAO,MAAM,YAAY,QASvB,CAAC;AAEH,eAAO,MAAM,eAAe,QAW1B,CAAC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
4
+ __vanilla_filescope__.setFileScope("lib/components/Popover/Popover.css.ts", "@autoguru/overdrive");
5
+ import { style } from '@vanilla-extract/css';
6
+ import { cssLayerComponent } from "../../styles/layers.css.js";
7
+ import { sprinkles } from "../../styles/sprinkles.css.js";
8
+ import { overdriveTokens as tokens } from "../../themes/theme.css.js";
9
+ export const overlayStyle = style([sprinkles({
10
+ borderRadius: 'md',
11
+ borderWidth: '1',
12
+ borderStyle: 'solid',
13
+ borderColour: 'light',
14
+ padding: '4'
15
+ }), {
16
+ '@layer': {
17
+ [cssLayerComponent]: {
18
+ backgroundColor: tokens.colours.background.body,
19
+ boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
20
+ minWidth: '280px'
21
+ }
22
+ }
23
+ }], "overlayStyle");
24
+ export const triggerStyle = style({
25
+ '@layer': {
26
+ [cssLayerComponent]: {
27
+ background: 'transparent',
28
+ border: 'none',
29
+ cursor: 'pointer',
30
+ padding: 0
31
+ }
32
+ }
33
+ }, "triggerStyle");
34
+ export const fullScreenStyle = style({
35
+ '@layer': {
36
+ [cssLayerComponent]: {
37
+ backgroundColor: tokens.colours.background.body,
38
+ bottom: 0,
39
+ left: 0,
40
+ position: 'fixed',
41
+ right: 0,
42
+ top: 0
43
+ }
44
+ }
45
+ }, "fullScreenStyle");
46
+ __vanilla_filescope__.endFileScope();
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { type AriaPopoverProps } from 'react-aria';
3
+ import { type OverlayTriggerState } from 'react-stately';
4
+ declare const defaultEnglish: {
5
+ readonly close: "close";
6
+ };
7
+ export type Language = Partial<Record<keyof typeof defaultEnglish, string>>;
8
+ /**
9
+ * Internal props for the Popover component.
10
+ */
11
+ export interface PopoverProps extends Omit<AriaPopoverProps, 'popoverRef'> {
12
+ /**
13
+ * Content to display inside the popover
14
+ */
15
+ children: React.ReactNode;
16
+ /**
17
+ * State object that controls the popover's open/close state
18
+ */
19
+ state: OverlayTriggerState;
20
+ /**
21
+ * Reference to the trigger element for positioning
22
+ */
23
+ triggerRef: React.RefObject<HTMLElement | null>;
24
+ /**
25
+ * Language content override
26
+ */
27
+ lang?: Language;
28
+ }
29
+ export declare const Popover: {
30
+ ({ children, offset, state, triggerRef, lang, ...props }: PopoverProps): React.JSX.Element;
31
+ displayName: string;
32
+ };
33
+ export {};
34
+ //# sourceMappingURL=Popover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../lib/components/Popover/Popover.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAKN,KAAK,gBAAgB,EAErB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AASzD,QAAA,MAAM,cAAc;;CAEV,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC;IACzE;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,KAAK,EAAE,mBAAmB,CAAC;IAC3B;;OAEG;IACH,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChD;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;CAChB;AAoBD,eAAO,MAAM,OAAO;8DAOjB,YAAY;;CA6Ed,CAAC"}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ const _excluded = ["children"],
6
+ _excluded2 = ["children", "offset", "state", "triggerRef", "lang"];
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ import { CloseIcon } from '@autoguru/icons';
10
+ import React, { useRef, useEffect } from 'react';
11
+ import { usePopover, useDialog, DismissButton, Overlay } from 'react-aria';
12
+ import { useMedia } from "../../hooks/useMedia/useMedia.js";
13
+ import { sprinkles } from "../../styles/sprinkles.css.js";
14
+ import { Button } from "../Button/Button.js";
15
+ import { Icon } from "../Icon/Icon.js";
16
+ import { fullScreenStyle, overlayStyle } from "./Popover.css.js";
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
+ const defaultEnglish = {
19
+ close: 'close'
20
+ };
21
+
22
+ /**
23
+ * Internal props for the Popover component.
24
+ */
25
+
26
+ /**
27
+ * Internal props for the Dialog wrapper component.
28
+ */
29
+
30
+ const Dialog = _ref => {
31
+ let {
32
+ children
33
+ } = _ref,
34
+ props = _objectWithoutProperties(_ref, _excluded);
35
+ const ref = useRef(null);
36
+ const {
37
+ dialogProps
38
+ } = useDialog(props, ref);
39
+ return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, dialogProps), {}, {
40
+ ref: ref,
41
+ children: children
42
+ }));
43
+ };
44
+ export const Popover = _ref2 => {
45
+ let {
46
+ children,
47
+ offset = 4,
48
+ state,
49
+ triggerRef,
50
+ lang
51
+ } = _ref2,
52
+ props = _objectWithoutProperties(_ref2, _excluded2);
53
+ const popoverRef = useRef(null);
54
+ const [isTablet] = useMedia(['tablet']);
55
+ const isFullScreen = !isTablet;
56
+
57
+ // Handle Esc manually since we have two different modes (popover vs fullscreen dialog)
58
+ // and react-aria would need a slightly different ModalTrigger pattern
59
+ useEffect(() => {
60
+ if (!isFullScreen) return;
61
+ const handleKeyDown = event => {
62
+ if (event.key === 'Escape') {
63
+ event.preventDefault();
64
+ state.close();
65
+ }
66
+ };
67
+ document.addEventListener('keydown', handleKeyDown);
68
+ return () => document.removeEventListener('keydown', handleKeyDown);
69
+ }, [isFullScreen, state]);
70
+ const {
71
+ popoverProps,
72
+ underlayProps
73
+ } = usePopover(_objectSpread(_objectSpread({}, props), {}, {
74
+ offset,
75
+ triggerRef,
76
+ popoverRef
77
+ }), state);
78
+
79
+ // Fullscreen mode: render Dialog directly without popover positioning
80
+ if (isFullScreen) {
81
+ var _lang$close;
82
+ return /*#__PURE__*/_jsx(Overlay, {
83
+ children: /*#__PURE__*/_jsx(Dialog, {
84
+ children: /*#__PURE__*/_jsx("div", {
85
+ className: fullScreenStyle,
86
+ children: /*#__PURE__*/_jsxs("div", {
87
+ className: sprinkles({
88
+ display: 'flex',
89
+ flexDirection: 'column',
90
+ gap: '5',
91
+ p: '3'
92
+ }),
93
+ children: [/*#__PURE__*/_jsx("div", {
94
+ className: sprinkles({
95
+ alignSelf: 'end'
96
+ }),
97
+ children: /*#__PURE__*/_jsx(Button, {
98
+ variant: "secondary",
99
+ minimal: true,
100
+ rounded: true,
101
+ onClick: state.close,
102
+ "aria-label": (_lang$close = lang === null || lang === void 0 ? void 0 : lang.close) !== null && _lang$close !== void 0 ? _lang$close : defaultEnglish.close,
103
+ children: /*#__PURE__*/_jsx(Icon, {
104
+ icon: CloseIcon
105
+ })
106
+ })
107
+ }), children]
108
+ })
109
+ })
110
+ })
111
+ });
112
+ }
113
+
114
+ // Standard popover mode: use popover positioning
115
+ return /*#__PURE__*/_jsxs(Overlay, {
116
+ children: [/*#__PURE__*/_jsx("div", _objectSpread({}, underlayProps)), /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, popoverProps), {}, {
117
+ ref: popoverRef,
118
+ className: overlayStyle,
119
+ children: [/*#__PURE__*/_jsx(Dialog, {
120
+ children: children
121
+ }), /*#__PURE__*/_jsx(DismissButton, {
122
+ onDismiss: state.close
123
+ })]
124
+ }))]
125
+ });
126
+ };
127
+ Popover.displayName = 'Popover';