@jobber/components 4.49.2 → 4.50.1

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 (26) hide show
  1. package/Flex.d.ts +1 -0
  2. package/Flex.js +17 -0
  3. package/dist/Combobox/Combobox.d.ts +1 -12
  4. package/dist/Combobox/Combobox.types.d.ts +121 -0
  5. package/dist/Combobox/components/ComboboxAction/ComboboxAction.d.ts +2 -11
  6. package/dist/Combobox/components/ComboboxAction/index.d.ts +1 -1
  7. package/dist/Combobox/components/ComboboxContent/ComboboxContent.d.ts +2 -43
  8. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/ComboboxContentList.d.ts +3 -0
  9. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/index.d.ts +1 -0
  10. package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/ComboboxContentSearch.d.ts +3 -0
  11. package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/index.d.ts +1 -0
  12. package/dist/Combobox/components/ComboboxTrigger/ComboboxTriggerButton/ComboboxTriggerButton.d.ts +1 -1
  13. package/dist/Combobox/components/ComboboxTrigger/ComboboxTriggerChip/ComboboxTriggerChip.d.ts +1 -1
  14. package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +1 -1
  15. package/dist/Combobox/hooks/useComboboxContent.d.ts +1 -1
  16. package/dist/Combobox/hooks/useComboboxValidation.d.ts +7 -0
  17. package/dist/Combobox/index.d.ts +2 -2
  18. package/dist/Combobox/index.js +16 -17
  19. package/dist/Content/Content.d.ts +1 -1
  20. package/dist/Flex/Flex.d.ts +32 -0
  21. package/dist/Flex/Flex.types.d.ts +6 -0
  22. package/dist/Flex/index.d.ts +1 -0
  23. package/dist/Flex/index.js +40 -0
  24. package/package.json +2 -2
  25. package/dist/Combobox/components/ComboboxContent/ComboboxList.d.ts +0 -15
  26. package/dist/Combobox/components/ComboboxContent/ComboboxSearch.d.ts +0 -7
package/Flex.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist/Flex";
package/Flex.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+
7
+ var Flex = require("./dist/Flex");
8
+
9
+ Object.keys(Flex).forEach(function(key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ Object.defineProperty(exports, key, {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return Flex[key];
15
+ },
16
+ });
17
+ });
@@ -1,18 +1,7 @@
1
- import { ReactElement } from "react";
1
+ import { ComboboxProps } from "@jobber/components/Combobox/Combobox.types";
2
2
  import { ComboboxContent } from "./components/ComboboxContent";
3
3
  import { ComboboxAction } from "./components/ComboboxAction";
4
4
  import { ComboboxTriggerButton, ComboboxTriggerChip } from "./components/ComboboxTrigger";
5
- export interface ComboboxProps {
6
- readonly children: ReactElement | ReactElement[];
7
- /**
8
- * When `true`, `Combobox` will allow for multiple selections
9
- *
10
- * @default false
11
- */
12
- readonly multiSelect?: boolean;
13
- }
14
- export declare const COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = "Combobox can only have one Trigger element";
15
- export declare const COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = "Combobox must have a Trigger and Combobox.Content element";
16
5
  export declare const Combobox: {
17
6
  (props: ComboboxProps): JSX.Element;
18
7
  TriggerButton: typeof ComboboxTriggerButton;
@@ -1,4 +1,15 @@
1
+ import { Dispatch, ReactElement, SetStateAction } from "react";
2
+ import { XOR } from "ts-xor";
1
3
  import { ButtonProps } from "../Button";
4
+ export interface ComboboxProps {
5
+ readonly children: ReactElement | ReactElement[];
6
+ /**
7
+ * When `true`, `Combobox` will allow for multiple selections
8
+ *
9
+ * @default false
10
+ */
11
+ readonly multiSelect?: boolean;
12
+ }
2
13
  export interface ComboboxTriggerProps {
3
14
  /**
4
15
  * The label text of the trigger.
@@ -9,6 +20,116 @@ export interface ComboboxTriggerButtonProps extends ComboboxTriggerProps, Pick<B
9
20
  }
10
21
  export type ComboboxTriggerChipProps = ComboboxTriggerProps;
11
22
  export interface ComboboxOption {
23
+ /**
24
+ * A unique identifier for the option.
25
+ */
12
26
  id: string | number;
27
+ /**
28
+ * The value to be visually displayed in the Combobox options list.
29
+ */
13
30
  label: string;
14
31
  }
32
+ interface ComboboxCloseProps {
33
+ /**
34
+ * Callback function invoked upon the selection of an option. Provides the selected option(s) as an argument.
35
+ */
36
+ readonly onSelect: (selection: ComboboxOption[]) => void;
37
+ }
38
+ interface ComboboxSelectProps {
39
+ /**
40
+ *
41
+ * Callback function invoked upon the Combobox menu closing. Provides the selected option(s) as an argument.
42
+ */
43
+ readonly onClose: (selection: ComboboxOption[]) => void;
44
+ }
45
+ interface ComboboxContentBaseProps {
46
+ /**
47
+ * List of selectable options to display.
48
+ */
49
+ readonly options: ComboboxOption[];
50
+ /**
51
+ * Optional action button(s) to display at the bottom of the list.
52
+ */
53
+ readonly children?: ReactElement | ReactElement[];
54
+ /**
55
+ * Placeholder text to display in the search input. Defaults to "Search".
56
+ */
57
+ readonly searchPlaceholder?: string;
58
+ /**
59
+ * The selected options of the Combobox.
60
+ */
61
+ readonly selected: ComboboxOption[];
62
+ /**
63
+ * The encapsulating noun for the content of the combobox. Used
64
+ * in the empty state, and search placeholder. Should be pluralized.
65
+ */
66
+ readonly subjectNoun?: string;
67
+ }
68
+ export type ComboboxContentProps = ComboboxContentBaseProps & XOR<ComboboxCloseProps, ComboboxSelectProps>;
69
+ export interface ComboboxSearchProps {
70
+ /**
71
+ * The placeholder for the search input.
72
+ */
73
+ placeholder?: string;
74
+ /**
75
+ * The value of the search input
76
+ */
77
+ searchValue: string;
78
+ /**
79
+ * The open state of the Combobox listbox.
80
+ */
81
+ open: boolean;
82
+ /**
83
+ * Setter for the search input value.
84
+ */
85
+ setSearchValue: Dispatch<SetStateAction<string>>;
86
+ }
87
+ export interface ComboboxListProps {
88
+ /**
89
+ * The options to display in the list. May be the full set of the Combobox or could be filtered.
90
+ */
91
+ readonly options: ComboboxOption[];
92
+ /**
93
+ * Used to determine if the empty state should be shown and given priority over the options list.
94
+ */
95
+ readonly showEmptyState: boolean;
96
+ /**
97
+ * The currently selected options.
98
+ */
99
+ readonly selected: ComboboxOption[];
100
+ /**
101
+ * A ref to the list element.
102
+ */
103
+ readonly optionsListRef: React.RefObject<HTMLUListElement>;
104
+ /**
105
+ * Setter for the first selected element, which is used to scroll the list to the first selected element on re-opening.
106
+ */
107
+ readonly setFirstSelectedElement: React.Dispatch<SetStateAction<HTMLElement | null>>;
108
+ /**
109
+ * The callback function to call when an option is selected.
110
+ */
111
+ readonly selectionHandler: (option: ComboboxOption) => void;
112
+ /**
113
+ * The current search term. Used in the no results message.
114
+ */
115
+ readonly searchValue: string;
116
+ /**
117
+ * Determines if it is a single selection or multi selection Combobox.
118
+ */
119
+ readonly multiselect: boolean;
120
+ /**
121
+ * The noun to be used in the empty state message.
122
+ */
123
+ readonly subjectNoun?: string;
124
+ }
125
+ export interface ComboboxActionProps {
126
+ /**
127
+ * The function to call when the action is clicked.
128
+ */
129
+ onClick(event: React.MouseEvent<HTMLButtonElement>): void;
130
+ /**
131
+ * The label text of the action.
132
+ */
133
+ readonly label: string;
134
+ }
135
+ export {};
@@ -1,12 +1,3 @@
1
- import React from "react";
2
- export interface ComboboxActionProps {
3
- /**
4
- * The function to call when the action is clicked.
5
- */
6
- onClick(event: React.MouseEvent<HTMLButtonElement>): void;
7
- /**
8
- * The label text of the action.
9
- */
10
- readonly label: string;
11
- }
1
+ /// <reference types="react" />
2
+ import { ComboboxActionProps } from "@jobber/components/Combobox/Combobox.types";
12
3
  export declare function ComboboxAction(props: ComboboxActionProps): JSX.Element;
@@ -1 +1 @@
1
- export { ComboboxAction, ComboboxActionProps } from "./ComboboxAction";
1
+ export { ComboboxAction } from "./ComboboxAction";
@@ -1,44 +1,3 @@
1
- import { ReactElement } from "react";
2
- import { XOR } from "ts-xor";
3
- import { ComboboxOption } from "../../Combobox.types";
4
- interface ComboboxCloseProps {
5
- /**
6
- * Callback function invoked upon the selection of an option. Provides the selected option(s) as an argument.
7
- */
8
- readonly onSelect: (selection: ComboboxOption[]) => void;
9
- }
10
- interface ComoboboxSelectProps {
11
- /**
12
- *
13
- * Callback function invoked upon the Combobox menu closing. Provides the selected option(s) as an argument.
14
- */
15
- readonly onClose: (selection: ComboboxOption[]) => void;
16
- }
17
- interface ComboboxContentBaseProps {
18
- /**
19
- * List of selectable options to display.
20
- */
21
- readonly options: ComboboxOption[];
22
- /**
23
- * Optional action button(s) to display at the bottom of the list.
24
- */
25
- readonly children?: ReactElement | ReactElement[];
26
- /**
27
- * Placeholder text to display in the search input. Defaults to "Search".
28
- */
29
- readonly searchPlaceholder?: string;
30
- /**
31
- * pre selected option
32
- * @default ""
33
- * @type string
34
- */
35
- readonly selected: ComboboxOption[];
36
- /**
37
- * The encapsulating noun for the content of the combobox. Used
38
- * in the empty state, and search placeholder. Should be pluralized.
39
- */
40
- readonly subjectNoun?: string;
41
- }
42
- type ComboboxContentProps = ComboboxContentBaseProps & XOR<ComboboxCloseProps, ComoboboxSelectProps>;
1
+ /// <reference types="react" />
2
+ import { ComboboxContentProps } from "@jobber/components/Combobox/Combobox.types";
43
3
  export declare function ComboboxContent(props: ComboboxContentProps): JSX.Element;
44
- export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { ComboboxListProps } from "@jobber/components/Combobox/Combobox.types";
3
+ export declare function ComboboxContentList(props: ComboboxListProps): JSX.Element;
@@ -0,0 +1 @@
1
+ export { ComboboxContentList } from "./ComboboxContentList";
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { ComboboxSearchProps } from "@jobber/components/Combobox/Combobox.types";
3
+ export declare function ComboboxContentSearch(props: ComboboxSearchProps): JSX.Element;
@@ -0,0 +1 @@
1
+ export { ComboboxContentSearch } from "./ComboboxContentSearch";
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { ComboboxTriggerButtonProps } from "../../../Combobox.types";
2
+ import { ComboboxTriggerButtonProps } from "@jobber/components/Combobox/Combobox.types";
3
3
  export declare function ComboboxTriggerButton(props: ComboboxTriggerButtonProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { ComboboxTriggerChipProps } from "../../../Combobox.types";
2
+ import { ComboboxTriggerChipProps } from "@jobber/components/Combobox/Combobox.types";
3
3
  export declare function ComboboxTriggerChip(props: ComboboxTriggerChipProps): JSX.Element;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ComboboxOption } from "../Combobox.types";
2
+ import { ComboboxOption } from "@jobber/components/Combobox/Combobox.types";
3
3
  export declare function useComboboxAccessibility(selectionCallback: (selection: ComboboxOption) => void, filteredOptions: ComboboxOption[], optionsListRef: React.RefObject<HTMLUListElement>, open: boolean, setOpen: (open: boolean) => void, wrapperRef: React.RefObject<HTMLDivElement>): {
4
4
  popperRef: React.RefObject<HTMLDivElement>;
5
5
  popperStyles: {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ComboboxOption } from "../Combobox.types";
2
+ import { ComboboxOption } from "@jobber/components/Combobox/Combobox.types";
3
3
  interface useComboboxContent {
4
4
  searchValue: string;
5
5
  setSearchValue: React.Dispatch<React.SetStateAction<string>>;
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from "react";
2
+ export declare const COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = "Combobox can only have one Trigger element";
3
+ export declare const COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = "Combobox must have a Trigger and Combobox.Content element";
4
+ export declare function useComboboxValidation(children: ReactNode): {
5
+ triggerElement: ReactNode;
6
+ contentElement: ReactNode;
7
+ };
@@ -1,3 +1,3 @@
1
- export { Combobox, ComboboxProps, COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE, COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE, } from "./Combobox";
1
+ export { Combobox } from "./Combobox";
2
2
  export { ComboboxContextProvider } from "./ComboboxProvider";
3
- export { ComboboxOption } from "./Combobox.types";
3
+ export { ComboboxOption, ComboboxProps } from "./Combobox.types";
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var useAssert = require('@jobber/hooks/useAssert');
7
6
  var classnames = require('classnames');
8
7
  var ReactDOM = require('react-dom');
9
8
  var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
@@ -15,6 +14,7 @@ var reactPopper = require('react-popper');
15
14
  var useOnKeyDown = require('@jobber/hooks/useOnKeyDown');
16
15
  var Typography = require('../Typography-83915c54.js');
17
16
  var Button = require('../Button-db6114a6.js');
17
+ var useAssert = require('@jobber/hooks/useAssert');
18
18
  require('@jobber/design');
19
19
  require('react-router-dom');
20
20
 
@@ -28,11 +28,11 @@ var css_248z$5 = ".m1w5vdUZ6rQ- {\n z-index: 1002;\n z-index: var(--elevation-
28
28
  var styles$5 = {"content":"m1w5vdUZ6rQ-","hidden":"Zlkv2HA096A-","actions":"YQry-Rd6zfQ-","actionPadding":"TcpqL34s4lI-"};
29
29
  styleInject_es.styleInject(css_248z$5);
30
30
 
31
- var css_248z$4 = ".ifwwZOYTf8U- {\n position: relative;\n}\n\n.gIbHknFkZLI- {\n width: 100%;\n padding: calc(16px * 1);\n padding: var(--space-base);\n padding-right: calc((16px * 1.5) * 2.25);\n padding-right: calc(calc(16px * 1.5) * 2.25);\n padding-right: calc(var(--space-large) * 2.25);\n border: none;\n border-bottom: calc(16px / 16) solid rgb(225, 225, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n font-family: \"Inter\", Helvetica, Arial, sans-serif;\n font-family: var(--typography--fontFamily-normal);\n font-size: calc((16px * 1) * 0.875);\n font-size: calc(calc(16px * 1) * 0.875);\n font-size: var(--typography--fontSize-base);\n}\n\n.dZmEG-amk2U- {\n position: absolute;\n top: 50%;\n right: calc(16px * 1);\n right: var(--space-base);\n z-index: 1002;\n z-index: var(--elevation-tooltip);\n width: calc(16px * 1.5);\n width: var(--space-large);\n height: calc(16px * 1.5);\n height: var(--space-large);\n padding: 0;\n border: none;\n border-radius: 100%;\n border-radius: var(--radius-circle);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n cursor: pointer;\n -webkit-transform: translateY(-50%);\n transform: translateY(-50%);\n}\n\n.dZmEG-amk2U-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n";
32
- var styles$4 = {"search":"ifwwZOYTf8U-","searchInput":"gIbHknFkZLI-","clearSearch":"dZmEG-amk2U-"};
31
+ var css_248z$4 = ".MIyb-oFZg9w- {\n position: relative;\n}\n\n.WZPK91I4aJs- {\n width: 100%;\n padding: calc(16px * 1);\n padding: var(--space-base);\n padding-right: calc((16px * 1.5) * 2.25);\n padding-right: calc(calc(16px * 1.5) * 2.25);\n padding-right: calc(var(--space-large) * 2.25);\n border: none;\n border-bottom: calc(16px / 16) solid rgb(225, 225, 225);\n border-bottom: var(--border-base) solid var(--color-border);\n font-family: \"Inter\", Helvetica, Arial, sans-serif;\n font-family: var(--typography--fontFamily-normal);\n font-size: calc((16px * 1) * 0.875);\n font-size: calc(calc(16px * 1) * 0.875);\n font-size: var(--typography--fontSize-base);\n}\n\n._7loHrVUe-Rk- {\n position: absolute;\n top: 50%;\n right: calc(16px * 1);\n right: var(--space-base);\n z-index: 1002;\n z-index: var(--elevation-tooltip);\n width: calc(16px * 1.5);\n width: var(--space-large);\n height: calc(16px * 1.5);\n height: var(--space-large);\n padding: 0;\n border: none;\n border-radius: 100%;\n border-radius: var(--radius-circle);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n cursor: pointer;\n -webkit-transform: translateY(-50%);\n transform: translateY(-50%);\n}\n\n._7loHrVUe-Rk-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n";
32
+ var styles$4 = {"search":"MIyb-oFZg9w-","searchInput":"WZPK91I4aJs-","clearSearch":"_7loHrVUe-Rk-"};
33
33
  styleInject_es.styleInject(css_248z$4);
34
34
 
35
- function ComboboxSearch(props) {
35
+ function ComboboxContentSearch(props) {
36
36
  const searchRef = React.useRef(null);
37
37
  React.useEffect(() => {
38
38
  if (props.open) {
@@ -56,11 +56,11 @@ function ComboboxSearch(props) {
56
56
  }
57
57
  }
58
58
 
59
- var css_248z$3 = "._5n7VvEn39-Y- {\n position: relative;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n}\n\n.KhX5VfZjAog- {\n display: -ms-flexbox;\n display: flex;\n max-height: calc((16px / 2) * 33.33);\n max-height: calc(calc(16px / 2) * 33.33);\n max-height: calc(var(--space-small) * 33.33);\n margin: 0;\n padding: 0;\n overflow: scroll;\n list-style: none;\n -ms-flex-direction: column;\n flex-direction: column;\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n\n.NNCJVHYx6lc- {\n display: -ms-flexbox;\n display: flex;\n min-height: calc((calc(16px * 3) - calc(16px / 4)));\n min-height: calc((var(--space-largest) - var(--space-smaller)));\n box-sizing: border-box;\n margin: 0 calc(16px / 2);\n margin: 0 var(--space-small);\n padding: calc(16px / 2);\n padding: var(--space-small);\n border-radius: calc(16px / 4);\n border-radius: var(--radius-large);\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n font-weight: 500;\n cursor: pointer;\n transition: all 200ms;\n transition: all var(--timing-base);\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.NNCJVHYx6lc-:hover,\n.NNCJVHYx6lc-:focus {\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n}\n\n.NNCJVHYx6lc-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n\n._2IRm1sf-TUU-,\n.DTuoA8WPNzc- {\n padding: calc(16px / 2) calc(16px * 1);\n padding: var(--space-small) var(--space-base);\n}\n\n._5n7VvEn39-Y-::after {\n content: \"\";\n display: block;\n position: absolute;\n right: 0;\n bottom: calc(16px / 2);\n bottom: var(--space-small);\n left: 0;\n height: calc(16px * 1);\n height: var(--space-base);\n background: linear-gradient(\n 180deg,\n rgba(255, 255, 255, 0) 0%,\n rgb(255, 255, 255) 100%\n );\n}\n\n._5n7VvEn39-Y-::before {\n content: \"\";\n display: block;\n position: absolute;\n top: calc(16px / 2);\n top: var(--space-small);\n right: 0;\n left: 0;\n height: calc(16px * 1);\n height: var(--space-base);\n background: linear-gradient(\n to bottom,\n rgba(255, 255, 255, 1),\n rgba(255, 255, 255, 0)\n );\n}\n";
60
- var styles$3 = {"container":"_5n7VvEn39-Y-","optionsList":"KhX5VfZjAog-","option":"NNCJVHYx6lc-","filterMessage":"_2IRm1sf-TUU-","emptyStateMessage":"DTuoA8WPNzc-"};
59
+ var css_248z$3 = ".SgMzjOcdE-E- {\n position: relative;\n padding: calc(16px / 2) 0;\n padding: var(--space-small) 0;\n}\n\n.TwoTCjgcssc- {\n display: -ms-flexbox;\n display: flex;\n max-height: calc((16px / 2) * 33.33);\n max-height: calc(calc(16px / 2) * 33.33);\n max-height: calc(var(--space-small) * 33.33);\n margin: 0;\n padding: 0;\n overflow: scroll;\n list-style: none;\n -ms-flex-direction: column;\n flex-direction: column;\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n\n._2LVD-wjMRfQ- {\n display: -ms-flexbox;\n display: flex;\n min-height: calc((calc(16px * 3) - calc(16px / 4)));\n min-height: calc((var(--space-largest) - var(--space-smaller)));\n box-sizing: border-box;\n margin: 0 calc(16px / 2);\n margin: 0 var(--space-small);\n padding: calc(16px / 2);\n padding: var(--space-small);\n border-radius: calc(16px / 4);\n border-radius: var(--radius-large);\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n font-weight: 500;\n cursor: pointer;\n transition: all 200ms;\n transition: all var(--timing-base);\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: center;\n align-items: center;\n}\n\n._2LVD-wjMRfQ-:hover,\n._2LVD-wjMRfQ-:focus {\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n}\n\n._2LVD-wjMRfQ-:focus {\n box-shadow: 0px 0px calc(16px / 4) calc(16px / 8)\n rgb(231, 213, 87);\n box-shadow: var(--shadow-focus);\n}\n\n._8T5M7MGwCRE-,\n._4y5NXkNeIQM- {\n padding: calc(16px / 2) calc(16px * 1);\n padding: var(--space-small) var(--space-base);\n}\n\n.SgMzjOcdE-E-::after {\n content: \"\";\n display: block;\n position: absolute;\n right: 0;\n bottom: calc(16px / 2);\n bottom: var(--space-small);\n left: 0;\n height: calc(16px * 1);\n height: var(--space-base);\n background: linear-gradient(\n 180deg,\n rgba(255, 255, 255, 0) 0%,\n rgb(255, 255, 255) 100%\n );\n}\n\n.SgMzjOcdE-E-::before {\n content: \"\";\n display: block;\n position: absolute;\n top: calc(16px / 2);\n top: var(--space-small);\n right: 0;\n left: 0;\n height: calc(16px * 1);\n height: var(--space-base);\n background: linear-gradient(\n to bottom,\n rgba(255, 255, 255, 1),\n rgba(255, 255, 255, 0)\n );\n}\n";
60
+ var styles$3 = {"container":"SgMzjOcdE-E-","optionsList":"TwoTCjgcssc-","option":"_2LVD-wjMRfQ-","filterMessage":"_8T5M7MGwCRE-","emptyStateMessage":"_4y5NXkNeIQM-"};
61
61
  styleInject_es.styleInject(css_248z$3);
62
62
 
63
- function ComboboxList(props) {
63
+ function ComboboxContentList(props) {
64
64
  let hasSeenFirstSelected = false;
65
65
  return (React__default["default"].createElement("div", { className: styles$3.container },
66
66
  !props.showEmptyState && props.options.length > 0 && (React__default["default"].createElement("ul", { className: styles$3.optionsList, role: "listbox", "aria-multiselectable": props.multiselect, ref: props.optionsListRef }, !props.showEmptyState &&
@@ -221,8 +221,8 @@ function ComboboxContent(props) {
221
221
  const { searchValue, setSearchValue, setFirstSelectedElement, filteredOptions, optionsListRef, selectedOptions, setInternalSelected, } = useComboboxContent(props.options, open, props.selected, props.onClose);
222
222
  const { popperRef, popperStyles, attributes } = useComboboxAccessibility(handleSelection, filteredOptions, optionsListRef, open, setOpen, wrapperRef);
223
223
  const template = (React__default["default"].createElement("div", Object.assign({ ref: popperRef, id: "ATL-Combobox-Content", "data-testid": "ATL-Combobox-Content", tabIndex: 0, className: classnames__default["default"](styles$5.content, { [styles$5.hidden]: !open }), style: popperStyles.popper }, attributes.popper),
224
- React__default["default"].createElement(ComboboxSearch, { open: open, placeholder: props.subjectNoun, searchValue: searchValue, setSearchValue: setSearchValue }),
225
- React__default["default"].createElement(ComboboxList, { multiselect: multiselect, showEmptyState: !optionsExist, options: filteredOptions, selected: selectedOptions, optionsListRef: optionsListRef, setFirstSelectedElement: setFirstSelectedElement, selectionHandler: handleSelection, searchValue: searchValue, subjectNoun: props.subjectNoun }),
224
+ React__default["default"].createElement(ComboboxContentSearch, { open: open, placeholder: props.subjectNoun, searchValue: searchValue, setSearchValue: setSearchValue }),
225
+ React__default["default"].createElement(ComboboxContentList, { multiselect: multiselect, showEmptyState: !optionsExist, options: filteredOptions, selected: selectedOptions, optionsListRef: optionsListRef, setFirstSelectedElement: setFirstSelectedElement, selectionHandler: handleSelection, searchValue: searchValue, subjectNoun: props.subjectNoun }),
226
226
  props.children && (React__default["default"].createElement("div", { className: styles$5.actions, role: "group" }, React__default["default"].Children.toArray(props.children).map((child, index, childrenArray) => (React__default["default"].createElement("div", { key: index, className: classnames__default["default"]({
227
227
  [styles$5.actionPadding]: index === childrenArray.length - 1,
228
228
  }) }, child)))))));
@@ -284,12 +284,6 @@ function ComboboxTriggerChip(props) {
284
284
 
285
285
  const COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = "Combobox can only have one Trigger element";
286
286
  const COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = "Combobox must have a Trigger and Combobox.Content element";
287
- const Combobox = (props) => {
288
- const { contentElement, triggerElement } = useComboboxValidation(props.children);
289
- return (React__default["default"].createElement(ComboboxContextProvider, { multiselect: props.multiSelect },
290
- triggerElement,
291
- contentElement));
292
- };
293
287
  function useComboboxValidation(children) {
294
288
  const childrenArray = React__default["default"].Children.toArray(children);
295
289
  let triggerElement, contentElement, multipleTriggersFound = false;
@@ -318,12 +312,17 @@ function isTriggerElement(child) {
318
312
  function isContentElement(child) {
319
313
  return React__default["default"].isValidElement(child) && child.type === ComboboxContent;
320
314
  }
315
+
316
+ const Combobox = (props) => {
317
+ const { contentElement, triggerElement } = useComboboxValidation(props.children);
318
+ return (React__default["default"].createElement(ComboboxContextProvider, { multiselect: props.multiSelect },
319
+ triggerElement,
320
+ contentElement));
321
+ };
321
322
  Combobox.TriggerButton = ComboboxTriggerButton;
322
323
  Combobox.TriggerChip = ComboboxTriggerChip;
323
324
  Combobox.Content = ComboboxContent;
324
325
  Combobox.Action = ComboboxAction;
325
326
 
326
- exports.COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE = COMBOBOX_REQUIRED_CHILDREN_ERROR_MESSAGE;
327
- exports.COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE = COMBOBOX_TRIGGER_COUNT_ERROR_MESSAGE;
328
327
  exports.Combobox = Combobox;
329
328
  exports.ComboboxContextProvider = ComboboxContextProvider;
@@ -12,7 +12,7 @@ interface ContentProps {
12
12
  * Change the wrapping element to be one of the available
13
13
  * semantic tags.
14
14
  *
15
- * @default 'div'
15
+ * @default "div"
16
16
  */
17
17
  readonly type?: "section" | "aside" | "header" | "footer" | "article" | "main" | "div";
18
18
  }
@@ -0,0 +1,32 @@
1
+ import { PropsWithChildren } from "react";
2
+ import { ColumnKeys, Direction, Spacing } from "./Flex.types";
3
+ interface FlexProps extends PropsWithChildren {
4
+ /**
5
+ * Determine how the children gets laid out
6
+ *
7
+ * **Supported keys**
8
+ * - `"grow"` - Grows to the space available. If all children are set to
9
+ * grow, then they'll have equal width.
10
+ * - `"shrink"` - Shrinks to the smallest size possible. Normally the size of
11
+ * the child.
12
+ */
13
+ readonly template: ColumnKeys[];
14
+ /**
15
+ * Adjusts the alignment of the Flex children.
16
+ */
17
+ readonly align?: "start" | "end" | "center";
18
+ /**
19
+ * The spacing between the children.
20
+ *
21
+ * @default "base"
22
+ */
23
+ readonly gap?: Spacing;
24
+ /**
25
+ * The direction of the content.
26
+ *
27
+ * @default "row"
28
+ */
29
+ readonly direction?: Direction;
30
+ }
31
+ export declare function Flex({ align, children, direction, gap, template, }: FlexProps): JSX.Element;
32
+ export {};
@@ -0,0 +1,6 @@
1
+ export type ColumnKeys = "shrink" | "grow";
2
+ export type Direction = "row" | "column";
3
+ export declare const spacing: readonly ["none", "smallest", "smaller", "small", "base", "large"];
4
+ type ValuesOfSpacing<T extends typeof spacing> = T[number];
5
+ export type Spacing = ValuesOfSpacing<typeof spacing>;
6
+ export {};
@@ -0,0 +1 @@
1
+ export { Flex } from "./Flex";
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var classnames = require('classnames');
7
+ var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
+ var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
13
+
14
+ var css_248z = "._8VpnrMKmsqQ- {\n display: grid;\n /* If this gets wrapped in a flex container, it should take the remaining space */\n -ms-flex: 1;\n flex: 1;\n}\n\n.ooF1YfV4Usc- {\n gap: calc(16px / 8);\n gap: var(--space-smallest);\n}\n\n.ppCZfXq-Kqc- {\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n\n.tElkBalXH3g- {\n gap: calc(16px / 2);\n gap: var(--space-small);\n}\n\n._4u3OwUKxxbg- {\n gap: calc(16px * 1);\n gap: var(--space-base);\n}\n\n.RL7CJla0AAI- {\n gap: calc(16px * 1.5);\n gap: var(--space-large);\n}\n\n.fV4cvFYkhgo- {\n gap: 0;\n}\n\n._04xVVjZgr-0- {\n -ms-flex-align: start;\n align-items: start;\n}\n\n.Nc3zrqHHYSg- {\n -ms-flex-align: center;\n align-items: center;\n}\n\n.qA-v50wBX1U- {\n -ms-flex-align: end;\n align-items: end;\n}\n";
15
+ var styles = {"flexible":"_8VpnrMKmsqQ-","smallestGap":"ooF1YfV4Usc-","smallerGap":"ppCZfXq-Kqc-","smallGap":"tElkBalXH3g-","baseGap":"_4u3OwUKxxbg-","largeGap":"RL7CJla0AAI-","noneGap":"fV4cvFYkhgo-","startAlign":"_04xVVjZgr-0-","centerAlign":"Nc3zrqHHYSg-","endAlign":"qA-v50wBX1U-"};
16
+ styleInject_es.styleInject(css_248z);
17
+
18
+ function Flex({ align = "center", children, direction = "row", gap = "base", template, }) {
19
+ return (React__default["default"].createElement("div", { className: classnames__default["default"](styles.flexible, {
20
+ [styles[`${gap}Gap`]]: Boolean(gap),
21
+ [styles[`${align}Align`]]: Boolean(align),
22
+ }), style: generateGridStylesFromTemplate(direction, template) }, children));
23
+ }
24
+ function generateGridStylesFromTemplate(direction, layoutTemplate) {
25
+ const containerStyles = {};
26
+ const templateKeys = {
27
+ row: "gridTemplateColumns",
28
+ column: "gridTemplateRows",
29
+ };
30
+ const templateValues = {
31
+ grow: "1fr",
32
+ shrink: "max-content",
33
+ };
34
+ containerStyles[templateKeys[direction]] = layoutTemplate
35
+ .map(key => templateValues[key])
36
+ .join(" ");
37
+ return containerStyles;
38
+ }
39
+
40
+ exports.Flex = Flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.49.2",
3
+ "version": "4.50.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -84,5 +84,5 @@
84
84
  "> 1%",
85
85
  "IE 10"
86
86
  ],
87
- "gitHead": "363a8b6e95f8fe46e6f7482be321c513377714ae"
87
+ "gitHead": "8c5b021daef4b90c333a3a01f7a1ba564869027e"
88
88
  }
@@ -1,15 +0,0 @@
1
- import React, { SetStateAction } from "react";
2
- import { ComboboxOption } from "../../Combobox.types";
3
- interface ComboboxListProps {
4
- readonly options: ComboboxOption[];
5
- readonly showEmptyState: boolean;
6
- readonly selected: ComboboxOption[];
7
- readonly optionsListRef: React.RefObject<HTMLUListElement>;
8
- readonly setFirstSelectedElement: React.Dispatch<SetStateAction<HTMLElement | null>>;
9
- readonly selectionHandler: (option: ComboboxOption) => void;
10
- readonly searchValue: string;
11
- readonly multiselect: boolean;
12
- readonly subjectNoun?: string;
13
- }
14
- export declare function ComboboxList(props: ComboboxListProps): JSX.Element;
15
- export {};
@@ -1,7 +0,0 @@
1
- import { Dispatch, SetStateAction } from "react";
2
- export declare function ComboboxSearch(props: {
3
- placeholder?: string;
4
- searchValue: string;
5
- open: boolean;
6
- setSearchValue: Dispatch<SetStateAction<string>>;
7
- }): JSX.Element;