@autoguru/overdrive 4.63.0 → 4.64.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 (51) hide show
  1. package/dist/components/Alert/Alert.d.ts +4 -1
  2. package/dist/components/Alert/Alert.d.ts.map +1 -1
  3. package/dist/components/Alert/Alert.js +11 -5
  4. package/dist/components/FilterChip/FilterChip.css.d.ts +64 -0
  5. package/dist/components/FilterChip/FilterChip.css.d.ts.map +1 -0
  6. package/dist/components/FilterChip/FilterChip.css.js +243 -0
  7. package/dist/components/FilterChip/FilterChip.d.ts +112 -0
  8. package/dist/components/FilterChip/FilterChip.d.ts.map +1 -0
  9. package/dist/components/FilterChip/FilterChip.js +152 -0
  10. package/dist/components/FilterChip/default.d.ts +2 -0
  11. package/dist/components/FilterChip/default.d.ts.map +1 -0
  12. package/dist/components/FilterChip/default.js +1 -0
  13. package/dist/components/FilterChip/index.d.ts +3 -0
  14. package/dist/components/FilterChip/index.d.ts.map +1 -0
  15. package/dist/components/FilterChip/index.js +1 -0
  16. package/dist/components/MinimalModal/MinimalModal.css.js +4 -4
  17. package/dist/components/StandardModal/StandardModal.css.js +2 -2
  18. package/dist/components/StandardModal/StandardModal.js +3 -2
  19. package/dist/components/Tabs/Tab.css.d.ts +40 -0
  20. package/dist/components/Tabs/Tab.css.d.ts.map +1 -1
  21. package/dist/components/Tabs/Tab.css.js +69 -8
  22. package/dist/components/Tabs/Tab.js +1 -1
  23. package/dist/components/Tabs/TabList.css.d.ts +1 -0
  24. package/dist/components/Tabs/TabList.css.d.ts.map +1 -1
  25. package/dist/components/Tabs/TabList.css.js +2 -1
  26. package/dist/components/Tabs/TabList.d.ts.map +1 -1
  27. package/dist/components/Tabs/TabList.js +5 -2
  28. package/dist/components/Tabs/TabPane.js +2 -1
  29. package/dist/components/Tabs/TabPanes.js +2 -1
  30. package/dist/components/Tabs/Tabs.d.ts +2 -0
  31. package/dist/components/Tabs/Tabs.d.ts.map +1 -1
  32. package/dist/components/Tabs/Tabs.js +4 -1
  33. package/dist/components/Tabs/index.d.ts +4 -3
  34. package/dist/components/Tabs/index.d.ts.map +1 -1
  35. package/dist/components/index.d.ts +2 -1
  36. package/dist/components/index.d.ts.map +1 -1
  37. package/dist/components/index.js +1 -0
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/themes/flat_red/index.d.ts +5 -0
  42. package/dist/themes/flat_red/index.d.ts.map +1 -1
  43. package/dist/themes/flat_red/tokens.d.ts +5 -0
  44. package/dist/themes/flat_red/tokens.d.ts.map +1 -1
  45. package/dist/themes/flat_red/tokens.js +10 -0
  46. package/dist/themes/neutral/index.d.ts +5 -0
  47. package/dist/themes/neutral/index.d.ts.map +1 -1
  48. package/dist/themes/neutral/tokens.d.ts +5 -0
  49. package/dist/themes/neutral/tokens.d.ts.map +1 -1
  50. package/dist/themes/neutral/tokens.js +11 -0
  51. package/package.json +1 -1
@@ -9,6 +9,9 @@ export interface AlertProps extends IntentStripeProps {
9
9
  dismissible?: boolean;
10
10
  onRequestClose?: ComponentProps<typeof Button>['onClick'];
11
11
  }
12
- export declare const Alert: ({ children, className, intent, inline, onRequestClose, dismissible, }: AlertProps) => React.JSX.Element;
12
+ export declare const Alert: {
13
+ ({ children, className, intent, inline, onRequestClose, dismissible, }: AlertProps): React.JSX.Element;
14
+ displayName: string;
15
+ };
13
16
  export default Alert;
14
17
  //# sourceMappingURL=Alert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../lib/components/Alert/Alert.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKnE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAK5D,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAG7D,MAAM,WAAW,UAAW,SAAQ,iBAAiB;IACpD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,cAAc,CAAC,EAAE,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC;CAC1D;AASD,eAAO,MAAM,KAAK,GAAI,uEAOnB,UAAU,sBA6DZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../lib/components/Alert/Alert.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAInE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAK5D,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAG7D,MAAM,WAAW,UAAW,SAAQ,iBAAiB;IACpD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,cAAc,CAAC,EAAE,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC;CAC1D;AAmBD,eAAO,MAAM,KAAK;4EAOf,UAAU;;CAiEZ,CAAC;AAIF,eAAe,KAAK,CAAC"}
@@ -2,7 +2,6 @@ import { AlertCircleIcon, WarningIcon, CheckCircleIcon, InformationIcon, XIcon }
2
2
  import clsx from 'clsx';
3
3
  import React from 'react';
4
4
  import { sprinkles } from "../../styles/index.js";
5
- import { sprinklesLegacyText } from "../../styles/typography.css.js";
6
5
  import { Box } from "../Box/Box.js";
7
6
  import { Button } from "../Button/Button.js";
8
7
  import { Icon } from "../Icon/Icon.js";
@@ -16,6 +15,12 @@ const iconMapForIntent = {
16
15
  success: CheckCircleIcon,
17
16
  warning: WarningIcon
18
17
  };
18
+ const textColorForIntent = {
19
+ danger: 'alertForeground',
20
+ information: 'infoForeground',
21
+ success: 'successForeground',
22
+ warning: 'warningForeground'
23
+ };
19
24
  export const Alert = ({
20
25
  children,
21
26
  className = '',
@@ -25,8 +30,8 @@ export const Alert = ({
25
30
  dismissible = typeof onRequestClose === 'function'
26
31
  }) => {
27
32
  return /*#__PURE__*/_jsxs(Box, {
28
- className: clsx(className, sprinklesLegacyText({
29
- color: intent
33
+ className: clsx(className, sprinkles({
34
+ color: textColorForIntent[intent]
30
35
  }), {
31
36
  [styles.contained]: !inline
32
37
  }),
@@ -36,8 +41,8 @@ export const Alert = ({
36
41
  backgroundColor: "white",
37
42
  borderWidth: "1",
38
43
  borderColor: "default",
39
- borderRadius: "1",
40
- boxShadow: inline ? 'none' : '4',
44
+ borderRadius: "xsmall",
45
+ boxShadow: inline ? 'none' : 'z4',
41
46
  padding: "2",
42
47
  odComponent: "alert",
43
48
  children: [/*#__PURE__*/_jsx(IntentStripe, {
@@ -85,4 +90,5 @@ export const Alert = ({
85
90
  })]
86
91
  });
87
92
  };
93
+ Alert.displayName = 'Alert';
88
94
  export default Alert;
@@ -0,0 +1,64 @@
1
+ import { type RecipeVariants } from '@vanilla-extract/recipes';
2
+ import { cssLayerComponent } from '../../styles/layers.css';
3
+ export declare const chip: import("@vanilla-extract/recipes").RuntimeFn<{
4
+ variant: {
5
+ filter: {
6
+ '@layer': {
7
+ [cssLayerComponent]: {
8
+ backgroundColor: `var(--${string})`;
9
+ borderColor: `var(--${string})`;
10
+ color: `var(--${string})`;
11
+ };
12
+ };
13
+ };
14
+ add: {
15
+ '@layer': {
16
+ [cssLayerComponent]: {
17
+ backgroundColor: "transparent";
18
+ borderColor: `var(--${string})`;
19
+ borderStyle: "dashed";
20
+ color: `var(--${string})`;
21
+ };
22
+ };
23
+ };
24
+ };
25
+ selected: {
26
+ true: {};
27
+ false: {};
28
+ };
29
+ interactive: {
30
+ true: {};
31
+ false: {};
32
+ };
33
+ }>;
34
+ export type StyledFilterChipProps = NonNullable<RecipeVariants<typeof chip>>;
35
+ export declare const chipBody: import("@vanilla-extract/recipes").RuntimeFn<{
36
+ withRemove: {
37
+ true: {
38
+ '@layer': {
39
+ [cssLayerComponent]: {
40
+ paddingInlineEnd: `var(--${string})`;
41
+ };
42
+ };
43
+ };
44
+ false: {};
45
+ };
46
+ }>;
47
+ export declare const buttonFont: string;
48
+ export declare const innerButtonText: string;
49
+ export declare const removeButton: string;
50
+ export declare const labelText: string;
51
+ export declare const valueText: string;
52
+ export declare const categoryLabel: import("@vanilla-extract/recipes").RuntimeFn<{
53
+ selected: {
54
+ true: {
55
+ '@layer': {
56
+ [cssLayerComponent]: {
57
+ color: `var(--${string})`;
58
+ };
59
+ };
60
+ };
61
+ false: {};
62
+ };
63
+ }>;
64
+ //# sourceMappingURL=FilterChip.css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterChip.css.d.ts","sourceRoot":"","sources":["../../../lib/components/FilterChip/FilterChip.css.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAe,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAczE,eAAO,MAAM,IAAI;;;;gBAsCZ,CAAC,iBAAiB,CAAC;;;;kBAIlB;;;;;gBAKD,CAAC,iBAAiB,CAAC;;;;;kBAKlB;;;;;;;;;;;;EA6EJ,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;AAE7E,eAAO,MAAM,QAAQ;;;;gBAmBhB,CAAC,iBAAiB,CAAC;;kBAElB;;;;;EAUJ,CAAC;AAEH,eAAO,MAAM,UAAU,QAOrB,CAAC;AAEH,eAAO,MAAM,eAAe,QAQ1B,CAAC;AAEH,eAAO,MAAM,YAAY,QAavB,CAAC;AAEH,eAAO,MAAM,SAAS,QAOpB,CAAC;AAEH,eAAO,MAAM,SAAS,QAQpB,CAAC;AAEH,eAAO,MAAM,aAAa;;;;gBAYrB,CAAC,iBAAiB,CAAC;;kBAElB;;;;;EASJ,CAAC"}
@@ -0,0 +1,243 @@
1
+ import * as __vanilla_filescope__ from '@vanilla-extract/css/fileScope';
2
+ __vanilla_filescope__.setFileScope("lib/components/FilterChip/FilterChip.css.ts", "@autoguru/overdrive");
3
+ import { globalLayer, style } from '@vanilla-extract/css';
4
+ import { recipe } from '@vanilla-extract/recipes';
5
+ import { LAYER_ORDER, cssLayerComponent } from "../../styles/layers.css.js";
6
+ import { selectors } from "../../styles/selectors.js";
7
+ import { overdriveTokens as vars } from "../../themes/theme.css.js";
8
+ globalLayer(LAYER_ORDER);
9
+ const TRANSITION_DURATION = '150ms';
10
+ const FOCUS_RING_WIDTH = vars.border.width['2'];
11
+ const FOCUS_COLOUR = vars.color.info.foreground;
12
+ const chipHover = '&:is(button):hover, &:has(button:hover)';
13
+ export const chip = recipe({
14
+ base: {
15
+ '@layer': {
16
+ [cssLayerComponent]: {
17
+ alignItems: 'center',
18
+ borderRadius: vars.border.radius.pill,
19
+ borderStyle: 'solid',
20
+ borderWidth: vars.border.width['1'],
21
+ display: 'inline-flex',
22
+ fontSize: vars.typography.size['4'].fontSize,
23
+ lineHeight: vars.typography.size['4'].lineHeight,
24
+ maxWidth: '100%',
25
+ minWidth: 0,
26
+ position: 'relative',
27
+ transitionDuration: TRANSITION_DURATION,
28
+ transitionProperty: 'background-color, border-color, color',
29
+ transitionTimingFunction: vars.animation.easing.standard,
30
+ selectors: {
31
+ [`&:focus-visible, &[data-focus-visible], &:has(:focus-visible), &:has([data-focus-visible])`]: {
32
+ borderColor: FOCUS_COLOUR,
33
+ outline: `solid ${FOCUS_RING_WIDTH} ${FOCUS_COLOUR}`,
34
+ outlineOffset: FOCUS_RING_WIDTH
35
+ }
36
+ },
37
+ '@media': {
38
+ '(prefers-reduced-motion: reduce)': {
39
+ transitionDuration: '0s'
40
+ }
41
+ }
42
+ }
43
+ }
44
+ },
45
+ variants: {
46
+ variant: {
47
+ filter: {
48
+ '@layer': {
49
+ [cssLayerComponent]: {
50
+ backgroundColor: vars.color.background.emphasisInactive,
51
+ borderColor: vars.color.border.default,
52
+ color: vars.color.foreground.primary
53
+ }
54
+ }
55
+ },
56
+ add: {
57
+ '@layer': {
58
+ [cssLayerComponent]: {
59
+ backgroundColor: 'transparent',
60
+ borderColor: vars.color.border.default,
61
+ borderStyle: 'dashed',
62
+ color: vars.color.foreground.secondary
63
+ }
64
+ }
65
+ }
66
+ },
67
+ selected: {
68
+ true: {},
69
+ false: {}
70
+ },
71
+ interactive: {
72
+ true: {},
73
+ false: {}
74
+ }
75
+ },
76
+ compoundVariants: [{
77
+ variants: {
78
+ variant: 'filter',
79
+ interactive: true
80
+ },
81
+ style: {
82
+ '@layer': {
83
+ [cssLayerComponent]: {
84
+ selectors: {
85
+ [chipHover]: {
86
+ backgroundColor: vars.color.background.emphasisLight,
87
+ borderColor: vars.color.border.emphasis
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }, {
94
+ variants: {
95
+ variant: 'add',
96
+ interactive: true
97
+ },
98
+ style: {
99
+ '@layer': {
100
+ [cssLayerComponent]: {
101
+ selectors: {
102
+ [chipHover]: {
103
+ borderColor: vars.color.border.selected,
104
+ color: vars.color.foreground.primary
105
+ },
106
+ [selectors.focusVisible]: {
107
+ borderColor: FOCUS_COLOUR,
108
+ color: vars.color.foreground.primary
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }, {
115
+ variants: {
116
+ variant: 'filter',
117
+ selected: true
118
+ },
119
+ style: {
120
+ '@layer': {
121
+ [cssLayerComponent]: {
122
+ backgroundColor: vars.color.brand.solid,
123
+ borderColor: vars.color.brand.solid,
124
+ color: vars.color.brand.onSolid,
125
+ selectors: {
126
+ [chipHover]: {
127
+ backgroundColor: vars.color.brand.solid,
128
+ borderColor: vars.color.brand.solid
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }],
135
+ defaultVariants: {
136
+ variant: 'filter',
137
+ selected: false,
138
+ interactive: false
139
+ }
140
+ }, "chip");
141
+ export const chipBody = recipe({
142
+ base: {
143
+ '@layer': {
144
+ [cssLayerComponent]: {
145
+ alignItems: 'center',
146
+ display: 'inline-flex',
147
+ gap: vars.space['1'],
148
+ minWidth: 0,
149
+ paddingBlock: vars.space['2'],
150
+ paddingInlineEnd: vars.space['3'],
151
+ paddingInlineStart: vars.space['3']
152
+ }
153
+ }
154
+ },
155
+ variants: {
156
+ withRemove: {
157
+ true: {
158
+ '@layer': {
159
+ [cssLayerComponent]: {
160
+ paddingInlineEnd: vars.space['1']
161
+ }
162
+ }
163
+ },
164
+ false: {}
165
+ }
166
+ },
167
+ defaultVariants: {
168
+ withRemove: false
169
+ }
170
+ }, "chipBody");
171
+ export const buttonFont = style({
172
+ '@layer': {
173
+ [cssLayerComponent]: {
174
+ fontFamily: 'inherit',
175
+ fontWeight: 'inherit'
176
+ }
177
+ }
178
+ }, "buttonFont");
179
+ export const innerButtonText = style({
180
+ '@layer': {
181
+ [cssLayerComponent]: {
182
+ color: 'inherit',
183
+ fontSize: 'inherit',
184
+ lineHeight: 'inherit'
185
+ }
186
+ }
187
+ }, "innerButtonText");
188
+ export const removeButton = style({
189
+ '@layer': {
190
+ [cssLayerComponent]: {
191
+ alignItems: 'center',
192
+ alignSelf: 'stretch',
193
+ display: 'inline-flex',
194
+ flexShrink: 0,
195
+ justifyContent: 'center',
196
+ paddingBlock: vars.space['2'],
197
+ paddingInlineEnd: vars.space['3'],
198
+ paddingInlineStart: 0
199
+ }
200
+ }
201
+ }, "removeButton");
202
+ export const labelText = style({
203
+ '@layer': {
204
+ [cssLayerComponent]: {
205
+ flexShrink: 0,
206
+ whiteSpace: 'nowrap'
207
+ }
208
+ }
209
+ }, "labelText");
210
+ export const valueText = style({
211
+ '@layer': {
212
+ [cssLayerComponent]: {
213
+ overflow: 'hidden',
214
+ textOverflow: 'ellipsis',
215
+ whiteSpace: 'nowrap'
216
+ }
217
+ }
218
+ }, "valueText");
219
+ export const categoryLabel = recipe({
220
+ base: {
221
+ '@layer': {
222
+ [cssLayerComponent]: {
223
+ color: vars.color.foreground.secondary
224
+ }
225
+ }
226
+ },
227
+ variants: {
228
+ selected: {
229
+ true: {
230
+ '@layer': {
231
+ [cssLayerComponent]: {
232
+ color: vars.color.brand.onSolid
233
+ }
234
+ }
235
+ },
236
+ false: {}
237
+ }
238
+ },
239
+ defaultVariants: {
240
+ selected: false
241
+ }
242
+ }, "categoryLabel");
243
+ __vanilla_filescope__.endFileScope();
@@ -0,0 +1,112 @@
1
+ import React, { type HTMLAttributes, type MouseEventHandler } from 'react';
2
+ import type { TestIdProp } from '../../types';
3
+ /** Attributes forwarded to the chip body. */
4
+ type FilterChipBodyAttributes = Pick<HTMLAttributes<HTMLElement>, 'aria-controls' | 'aria-describedby' | 'aria-haspopup' | 'aria-label' | 'aria-labelledby' | 'id' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'onMouseEnter' | 'onMouseLeave'>;
5
+ interface FilterChipBaseProps extends FilterChipBodyAttributes, TestIdProp {
6
+ /** The category name, or the chip's only text for `simple` and `add`. */
7
+ label: string;
8
+ /** Override class name with additional styles */
9
+ className?: string;
10
+ }
11
+ /** The props every chip except `add` shares. */
12
+ interface FilterChipStateProps {
13
+ /**
14
+ * Reflects the persistent chosen state as an inverted surface. Purely
15
+ * visual — the chip's own text is what tells a screen reader which filter is
16
+ * applied. Use `pressed` if the chip is a toggle.
17
+ * @default false
18
+ */
19
+ selected?: boolean;
20
+ /**
21
+ * Marks the chip as an on/off toggle and reports `aria-pressed`. Only set
22
+ * this when clicking the chip applies and unapplies the filter in place; a
23
+ * chip whose body opens an editor is not a toggle and must leave it unset.
24
+ */
25
+ pressed?: boolean;
26
+ /**
27
+ * Whether the popover or dropdown this chip controls is open. When
28
+ * supplied the chip is exposed as a disclosure rather than a toggle, and
29
+ * `aria-haspopup` is set unless you specify it yourself. Pair it with
30
+ * `aria-controls` and the forwarded `ref`, which `Popover` needs to anchor
31
+ * itself to the chip.
32
+ */
33
+ expanded?: boolean;
34
+ /** Activates the chip body. Omit to render the chip non-interactively. */
35
+ onClick?: MouseEventHandler<HTMLButtonElement>;
36
+ /**
37
+ * Removes the filter. Supplying this renders the trailing `×` button.
38
+ */
39
+ onRemove?: MouseEventHandler<HTMLButtonElement>;
40
+ /**
41
+ * Accessible name for the `×` button. Defaults to naming the filter and its
42
+ * value — `Remove State QLD filter` — so that two chips from the same
43
+ * category are distinguishable. Any trailing colon is stripped.
44
+ */
45
+ removeLabel?: string;
46
+ }
47
+ /** A category and its chosen value, e.g. `Vehicle type: Truck`. */
48
+ interface SelectChipProps extends FilterChipBaseProps, FilterChipStateProps {
49
+ type?: 'select';
50
+ /** The chosen value. */
51
+ value?: string;
52
+ operator?: never;
53
+ }
54
+ /** A category, a comparison operator and a value, e.g. `Usage (km): over 100,000 km`. */
55
+ interface NumericChipProps extends FilterChipBaseProps, FilterChipStateProps {
56
+ type: 'numeric';
57
+ /** The chosen value. */
58
+ value?: string;
59
+ /** The comparison word, e.g. `over`. */
60
+ operator?: string;
61
+ }
62
+ /** A bare label with no value, e.g. `Serviced`. */
63
+ interface SimpleChipProps extends FilterChipBaseProps, FilterChipStateProps {
64
+ type: 'simple';
65
+ value?: never;
66
+ operator?: never;
67
+ }
68
+ /**
69
+ * The dashed "Add Filter" affordance that opens a filter picker. It holds no
70
+ * filter, so it takes no value, no state and nothing to remove, and `onClick` is
71
+ * required.
72
+ */
73
+ interface AddChipProps extends FilterChipBaseProps {
74
+ type: 'add';
75
+ onClick: MouseEventHandler<HTMLButtonElement>;
76
+ value?: never;
77
+ operator?: never;
78
+ selected?: never;
79
+ pressed?: never;
80
+ expanded?: never;
81
+ onRemove?: never;
82
+ removeLabel?: never;
83
+ }
84
+ /** All FilterChip props, discriminated on `type`. */
85
+ export type FilterChipProps = SelectChipProps | NumericChipProps | SimpleChipProps | AddChipProps;
86
+ /**
87
+ * The four filter chip shapes.
88
+ *
89
+ * - `select` — a category and its chosen value, e.g. `Vehicle type: Truck`
90
+ * - `numeric` — a category, a comparison operator and a value, e.g. `Usage (km): over 100,000 km`
91
+ * - `simple` — a bare label with no value
92
+ * - `add` — the dashed "Add Filter" affordance that opens a filter picker
93
+ */
94
+ export type FilterChipType = NonNullable<FilterChipProps['type']>;
95
+ /**
96
+ * A filter chip represents one active filter in a filter bar. The body opens an
97
+ * editor for the filter's value and the trailing `×` clears it.
98
+ *
99
+ * Distinct from `Badge`, which is a static, non-interactive label.
100
+ *
101
+ * The forwarded `ref` lands on the chip body, which is what a `Popover` anchors
102
+ * to. It is attached only when the body is a button — that is, when `onClick` is
103
+ * supplied. A chip without one has an inert `<span>` body and receives no ref,
104
+ * whether or not it has a `×`.
105
+ *
106
+ * Removal is by the `×` button only — the WAI-ARIA APG chip pattern also removes
107
+ * a focused chip on `Backspace`/`Delete`, which this component does not
108
+ * implement.
109
+ */
110
+ export declare const FilterChip: React.ForwardRefExoticComponent<FilterChipProps & React.RefAttributes<HTMLButtonElement>>;
111
+ export {};
112
+ //# sourceMappingURL=FilterChip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterChip.d.ts","sourceRoot":"","sources":["../../../lib/components/FilterChip/FilterChip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAEb,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAEtB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAM9C,6CAA6C;AAC7C,KAAK,wBAAwB,GAAG,IAAI,CACnC,cAAc,CAAC,WAAW,CAAC,EACzB,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,YAAY,GACZ,iBAAiB,GACjB,IAAI,GACJ,QAAQ,GACR,SAAS,GACT,WAAW,GACX,cAAc,GACd,cAAc,CAChB,CAAC;AAEF,UAAU,mBAAoB,SAAQ,wBAAwB,EAAE,UAAU;IACzE,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,gDAAgD;AAChD,UAAU,oBAAoB;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC/C;;OAEG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAChD;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,mEAAmE;AACnE,UAAU,eAAgB,SAAQ,mBAAmB,EAAE,oBAAoB;IAC1E,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC;CACjB;AAED,yFAAyF;AACzF,UAAU,gBAAiB,SAAQ,mBAAmB,EAAE,oBAAoB;IAC3E,IAAI,EAAE,SAAS,CAAC;IAChB,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,mDAAmD;AACnD,UAAU,eAAgB,SAAQ,mBAAmB,EAAE,oBAAoB;IAC1E,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;CACjB;AAED;;;;GAIG;AACH,UAAU,YAAa,SAAQ,mBAAmB;IACjD,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,WAAW,CAAC,EAAE,KAAK,CAAC;CACpB;AAED,qDAAqD;AACrD,MAAM,MAAM,eAAe,GACxB,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,YAAY,CAAC;AAEhB;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;AAElE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,2FAqItB,CAAC"}
@@ -0,0 +1,152 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ const _excluded = ["type", "label", "value", "operator", "selected", "pressed", "expanded", "onClick", "onRemove", "removeLabel", "className", "testId", "aria-haspopup"];
4
+ 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; }
5
+ 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; }
6
+ import { PlusIcon, XIcon } from '@autoguru/icons';
7
+ import clsx from 'clsx';
8
+ import React, { forwardRef } from 'react';
9
+ import { useNullCheck } from "../../hooks/useNullCheck/index.js";
10
+ import { useBox } from "../Box/useBox/useBox.js";
11
+ import { Icon } from "../Icon/Icon.js";
12
+ import * as styles from "./FilterChip.css.js";
13
+ /** Attributes forwarded to the chip body. */
14
+ /** The props every chip except `add` shares. */
15
+ /** A category and its chosen value, e.g. `Vehicle type: Truck`. */
16
+ /** A category, a comparison operator and a value, e.g. `Usage (km): over 100,000 km`. */
17
+ /** A bare label with no value, e.g. `Serviced`. */
18
+ /**
19
+ * The dashed "Add Filter" affordance that opens a filter picker. It holds no
20
+ * filter, so it takes no value, no state and nothing to remove, and `onClick` is
21
+ * required.
22
+ */
23
+ /** All FilterChip props, discriminated on `type`. */
24
+ /**
25
+ * The four filter chip shapes.
26
+ *
27
+ * - `select` — a category and its chosen value, e.g. `Vehicle type: Truck`
28
+ * - `numeric` — a category, a comparison operator and a value, e.g. `Usage (km): over 100,000 km`
29
+ * - `simple` — a bare label with no value
30
+ * - `add` — the dashed "Add Filter" affordance that opens a filter picker
31
+ */
32
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
33
+ /**
34
+ * A filter chip represents one active filter in a filter bar. The body opens an
35
+ * editor for the filter's value and the trailing `×` clears it.
36
+ *
37
+ * Distinct from `Badge`, which is a static, non-interactive label.
38
+ *
39
+ * The forwarded `ref` lands on the chip body, which is what a `Popover` anchors
40
+ * to. It is attached only when the body is a button — that is, when `onClick` is
41
+ * supplied. A chip without one has an inert `<span>` body and receives no ref,
42
+ * whether or not it has a `×`.
43
+ *
44
+ * Removal is by the `×` button only — the WAI-ARIA APG chip pattern also removes
45
+ * a focused chip on `Backspace`/`Delete`, which this component does not
46
+ * implement.
47
+ */
48
+ export const FilterChip = /*#__PURE__*/forwardRef((_ref, ref) => {
49
+ let {
50
+ type = 'select',
51
+ label,
52
+ value,
53
+ operator,
54
+ selected = false,
55
+ pressed,
56
+ expanded,
57
+ onClick,
58
+ onRemove,
59
+ removeLabel,
60
+ className,
61
+ testId,
62
+ 'aria-haspopup': ariaHasPopup
63
+ } = _ref,
64
+ bodyAttrs = _objectWithoutProperties(_ref, _excluded);
65
+ const isAdd = type === 'add';
66
+ const isSelected = !isAdd && selected;
67
+ const showRemove = !isAdd && typeof onRemove === 'function';
68
+ const isInteractive = typeof onClick === 'function' || showRemove;
69
+ useNullCheck(!isAdd || typeof onClick === 'function', 'FilterChip: an "add" chip needs an onClick — without one it renders as static text that still looks like a button.');
70
+ useNullCheck(typeof onClick === 'function' || expanded === undefined && pressed === undefined, 'FilterChip: "expanded" and "pressed" describe the chip body, which is only a button when onClick is supplied. Without one they are dropped.');
71
+ const accessibleName = label.replace(/:\s*$/, '');
72
+ const removeName = [accessibleName, operator, value].filter(Boolean).join(' ');
73
+ const stateProps = {
74
+ 'aria-expanded': expanded,
75
+ 'aria-haspopup': ariaHasPopup !== null && ariaHasPopup !== void 0 ? ariaHasPopup : expanded === undefined ? undefined : true,
76
+ 'aria-pressed': isAdd ? undefined : pressed
77
+ };
78
+ const isBodyButton = typeof onClick === 'function';
79
+ const bodyInteractionProps = isBodyButton ? _objectSpread(_objectSpread({}, stateProps), {}, {
80
+ onClick,
81
+ ref,
82
+ type: 'button'
83
+ }) : {};
84
+ const bodyAs = isBodyButton ? 'button' : 'span';
85
+ const rootAs = showRemove ? 'div' : bodyAs;
86
+ const {
87
+ Component: Root,
88
+ componentProps: rootProps
89
+ } = useBox(_objectSpread({
90
+ as: rootAs,
91
+ className: [styles.chip({
92
+ variant: isAdd ? 'add' : 'filter',
93
+ selected: isSelected,
94
+ interactive: isInteractive
95
+ }), !showRemove && styles.chipBody(), !showRemove && isBodyButton && styles.buttonFont, className],
96
+ odComponent: 'filter-chip',
97
+ testId
98
+ }, showRemove ? {} : _objectSpread(_objectSpread({}, bodyAttrs), bodyInteractionProps)));
99
+ const {
100
+ Component: Body,
101
+ componentProps: bodyProps
102
+ } = useBox(_objectSpread(_objectSpread({
103
+ as: bodyAs,
104
+ className: [styles.chipBody({
105
+ withRemove: true
106
+ }), styles.innerButtonText, isBodyButton && styles.buttonFont]
107
+ }, bodyAttrs), bodyInteractionProps));
108
+ const {
109
+ Component: Remove,
110
+ componentProps: removeProps
111
+ } = useBox({
112
+ as: 'button',
113
+ className: [styles.buttonFont, styles.innerButtonText, styles.removeButton],
114
+ 'aria-label': removeLabel !== null && removeLabel !== void 0 ? removeLabel : `Remove ${removeName} filter`,
115
+ onClick: onRemove,
116
+ type: 'button'
117
+ });
118
+ const content = /*#__PURE__*/_jsxs(_Fragment, {
119
+ children: [isAdd && /*#__PURE__*/_jsx(Icon, {
120
+ icon: PlusIcon,
121
+ size: "small"
122
+ }), /*#__PURE__*/_jsx("span", {
123
+ className: clsx(styles.labelText, (type === 'select' || type === 'numeric') && styles.categoryLabel({
124
+ selected: isSelected
125
+ })),
126
+ children: label
127
+ }), type === 'numeric' && operator ? /*#__PURE__*/_jsx("span", {
128
+ className: styles.labelText,
129
+ children: operator
130
+ }) : null, (type === 'select' || type === 'numeric') && value ? /*#__PURE__*/_jsx("span", {
131
+ className: styles.valueText,
132
+ title: value,
133
+ children: value
134
+ }) : null]
135
+ });
136
+ if (showRemove) {
137
+ return /*#__PURE__*/_jsxs(Root, _objectSpread(_objectSpread({}, rootProps), {}, {
138
+ children: [/*#__PURE__*/_jsx(Body, _objectSpread(_objectSpread({}, bodyProps), {}, {
139
+ children: content
140
+ })), /*#__PURE__*/_jsx(Remove, _objectSpread(_objectSpread({}, removeProps), {}, {
141
+ children: /*#__PURE__*/_jsx(Icon, {
142
+ icon: XIcon,
143
+ size: "small"
144
+ })
145
+ }))]
146
+ }));
147
+ }
148
+ return /*#__PURE__*/_jsx(Root, _objectSpread(_objectSpread({}, rootProps), {}, {
149
+ children: content
150
+ }));
151
+ });
152
+ FilterChip.displayName = 'FilterChip';
@@ -0,0 +1,2 @@
1
+ export { FilterChip as default } from './FilterChip';
2
+ //# sourceMappingURL=default.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../lib/components/FilterChip/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export { FilterChip as default } from "./FilterChip.js";
@@ -0,0 +1,3 @@
1
+ export { FilterChip } from './FilterChip';
2
+ export type { FilterChipProps, FilterChipType } from './FilterChip';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/FilterChip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export { FilterChip } from "./FilterChip.js";