@guardian/stand 0.0.50 → 0.0.52

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 (88) hide show
  1. package/dist/Modal.cjs +7 -0
  2. package/dist/Modal.d.cts +5 -0
  3. package/dist/Modal.d.ts +5 -0
  4. package/dist/Modal.js +3 -0
  5. package/dist/TagPicker.cjs +4 -2
  6. package/dist/TagPicker.d.cts +3 -2
  7. package/dist/TagPicker.d.ts +3 -2
  8. package/dist/TagPicker.js +3 -2
  9. package/dist/components/Form/Form.cjs +1 -0
  10. package/dist/components/Form/Form.js +1 -0
  11. package/dist/components/InlineMessage/InlineMessage.cjs +2 -1
  12. package/dist/components/InlineMessage/InlineMessage.d.cts +1 -0
  13. package/dist/components/InlineMessage/InlineMessage.d.ts +1 -0
  14. package/dist/components/InlineMessage/InlineMessage.js +2 -1
  15. package/dist/components/InlineMessage/types.d.cts +5 -0
  16. package/dist/components/InlineMessage/types.d.ts +5 -0
  17. package/dist/components/Modal/Modal.cjs +97 -0
  18. package/dist/components/Modal/Modal.d.cts +21 -0
  19. package/dist/components/Modal/Modal.d.ts +21 -0
  20. package/dist/components/Modal/Modal.js +93 -0
  21. package/dist/components/Modal/styles.cjs +100 -0
  22. package/dist/components/Modal/styles.d.cts +10 -0
  23. package/dist/components/Modal/styles.d.ts +10 -0
  24. package/dist/components/Modal/styles.js +92 -0
  25. package/dist/components/Modal/types.d.cts +20 -0
  26. package/dist/components/Modal/types.d.ts +20 -0
  27. package/dist/components/Select/Select.cjs +3 -1
  28. package/dist/components/Select/Select.d.cts +2 -0
  29. package/dist/components/Select/Select.d.ts +2 -0
  30. package/dist/components/Select/Select.js +3 -1
  31. package/dist/components/Select/types.d.cts +15 -2
  32. package/dist/components/Select/types.d.ts +15 -2
  33. package/dist/components/TagPicker/Autocomplete.cjs +60 -48
  34. package/dist/components/TagPicker/Autocomplete.d.cts +12 -2
  35. package/dist/components/TagPicker/Autocomplete.d.ts +12 -2
  36. package/dist/components/TagPicker/Autocomplete.js +63 -51
  37. package/dist/components/TagPicker/TagPicker.cjs +105 -0
  38. package/dist/components/TagPicker/TagPicker.d.cts +91 -0
  39. package/dist/components/TagPicker/TagPicker.d.ts +91 -0
  40. package/dist/components/TagPicker/TagPicker.js +105 -0
  41. package/dist/components/TagPicker/TagSearchWithFilters.cjs +53 -0
  42. package/dist/components/TagPicker/TagSearchWithFilters.js +53 -0
  43. package/dist/components/TagPicker/TagTable.cjs +10 -49
  44. package/dist/components/TagPicker/TagTable.d.cts +12 -48
  45. package/dist/components/TagPicker/TagTable.d.ts +12 -48
  46. package/dist/components/TagPicker/TagTable.js +29 -68
  47. package/dist/components/TagPicker/styles.cjs +64 -3
  48. package/dist/components/TagPicker/styles.js +59 -4
  49. package/dist/components/TagPicker/types.d.cts +5 -1
  50. package/dist/components/TagPicker/types.d.ts +5 -1
  51. package/dist/components/Typography/Typography.cjs +7 -4
  52. package/dist/components/Typography/Typography.d.cts +1 -5
  53. package/dist/components/Typography/Typography.d.ts +1 -5
  54. package/dist/components/Typography/Typography.js +7 -4
  55. package/dist/components/Typography/types.d.cts +3 -2
  56. package/dist/components/Typography/types.d.ts +3 -2
  57. package/dist/components/UserMenu/PreferenceRadioGroup.js +5 -5
  58. package/dist/index.cjs +2 -0
  59. package/dist/index.d.cts +4 -3
  60. package/dist/index.d.ts +4 -3
  61. package/dist/index.js +2 -1
  62. package/dist/styleD/build/css/component/autocomplete.css +3 -0
  63. package/dist/styleD/build/css/component/modal.css +51 -0
  64. package/dist/styleD/build/css/component/tagPicker.css +11 -0
  65. package/dist/styleD/build/css/component/tagTable.css +2 -2
  66. package/dist/styleD/build/typescript/component/autocomplete.cjs +5 -0
  67. package/dist/styleD/build/typescript/component/autocomplete.d.cts +5 -0
  68. package/dist/styleD/build/typescript/component/autocomplete.d.ts +5 -0
  69. package/dist/styleD/build/typescript/component/autocomplete.js +5 -0
  70. package/dist/styleD/build/typescript/component/intendedAudienceSignifier.cjs +4 -1
  71. package/dist/styleD/build/typescript/component/intendedAudienceSignifier.d.cts +1 -0
  72. package/dist/styleD/build/typescript/component/intendedAudienceSignifier.d.ts +1 -0
  73. package/dist/styleD/build/typescript/component/intendedAudienceSignifier.js +4 -1
  74. package/dist/styleD/build/typescript/component/modal.cjs +72 -0
  75. package/dist/styleD/build/typescript/component/modal.d.cts +75 -0
  76. package/dist/styleD/build/typescript/component/modal.d.ts +75 -0
  77. package/dist/styleD/build/typescript/component/modal.js +72 -0
  78. package/dist/styleD/build/typescript/component/tagPicker.cjs +17 -0
  79. package/dist/styleD/build/typescript/component/tagPicker.d.cts +20 -0
  80. package/dist/styleD/build/typescript/component/tagPicker.d.ts +20 -0
  81. package/dist/styleD/build/typescript/component/tagPicker.js +17 -0
  82. package/dist/styleD/build/typescript/component/tagTable.cjs +2 -2
  83. package/dist/styleD/build/typescript/component/tagTable.js +2 -2
  84. package/package.json +16 -2
  85. package/dist/components/TagPicker/TagAutocomplete.cjs +0 -118
  86. package/dist/components/TagPicker/TagAutocomplete.d.cts +0 -144
  87. package/dist/components/TagPicker/TagAutocomplete.d.ts +0 -144
  88. package/dist/components/TagPicker/TagAutocomplete.js +0 -118
@@ -0,0 +1,20 @@
1
+ import { DeepPartial, DefaultProps, DefaultPropsWithChildren } from "../../util/types.cjs";
2
+ import { IconButtonProps } from "../IconButton/types.cjs";
3
+ import { TypographyProps } from "../Typography/types.cjs";
4
+ import { DialogTheme, ModalTheme } from "./styles.cjs";
5
+ import { DialogProps, DialogTriggerProps, ModalOverlayProps } from "react-aria-components";
6
+
7
+ //#region src/components/Modal/types.d.ts
8
+ type ModalProps = DefaultProps<ModalTheme, ModalOverlayProps['className']> & ModalOverlayProps;
9
+ type DialogProps$1 = DefaultProps<DialogTheme['container'], DialogProps['className']> & DialogProps;
10
+ type DialogHeaderProps = Omit<TypographyProps, 'theme'> & {
11
+ theme?: DeepPartial<DialogTheme['title']>;
12
+ };
13
+ type DialogButtonsProps = DefaultPropsWithChildren<DialogTheme['ctas']>;
14
+ type DialogContentProps = DefaultPropsWithChildren<DialogTheme['children']>;
15
+ type DialogDismissProps = Omit<IconButtonProps, 'theme'> & {
16
+ theme?: DeepPartial<DialogTheme['dismiss']>;
17
+ };
18
+ type DialogTriggerProps$1 = DialogTriggerProps;
19
+ //#endregion
20
+ export { DialogButtonsProps, DialogContentProps, DialogDismissProps, DialogHeaderProps, DialogProps$1 as DialogProps, DialogTriggerProps$1 as DialogTriggerProps, ModalProps };
@@ -0,0 +1,20 @@
1
+ import { DeepPartial, DefaultProps, DefaultPropsWithChildren } from "../../util/types.js";
2
+ import { IconButtonProps } from "../IconButton/types.js";
3
+ import { TypographyProps } from "../Typography/types.js";
4
+ import { DialogTheme, ModalTheme } from "./styles.js";
5
+ import { DialogProps, DialogTriggerProps, ModalOverlayProps } from "react-aria-components";
6
+
7
+ //#region src/components/Modal/types.d.ts
8
+ type ModalProps = DefaultProps<ModalTheme, ModalOverlayProps['className']> & ModalOverlayProps;
9
+ type DialogProps$1 = DefaultProps<DialogTheme['container'], DialogProps['className']> & DialogProps;
10
+ type DialogHeaderProps = Omit<TypographyProps, 'theme'> & {
11
+ theme?: DeepPartial<DialogTheme['title']>;
12
+ };
13
+ type DialogButtonsProps = DefaultPropsWithChildren<DialogTheme['ctas']>;
14
+ type DialogContentProps = DefaultPropsWithChildren<DialogTheme['children']>;
15
+ type DialogDismissProps = Omit<IconButtonProps, 'theme'> & {
16
+ theme?: DeepPartial<DialogTheme['dismiss']>;
17
+ };
18
+ type DialogTriggerProps$1 = DialogTriggerProps;
19
+ //#endregion
20
+ export { DialogButtonsProps, DialogContentProps, DialogDismissProps, DialogHeaderProps, DialogProps$1 as DialogProps, DialogTriggerProps$1 as DialogTriggerProps, ModalProps };
@@ -34,7 +34,7 @@ function ListBox({ children, theme = {} }) {
34
34
  children: items
35
35
  });
36
36
  }
37
- function Select({ isInvalid, theme = {}, children, ...props }) {
37
+ function Select({ isInvalid, theme = {}, placement, shouldFlip, children, ...props }) {
38
38
  const mergedTheme = require_mergeDeep.mergeDeep(require_styles.defaultSelectTheme, theme);
39
39
  return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(require_Form.FormInputContainer, {
40
40
  as: react_aria_components.Select,
@@ -49,6 +49,8 @@ function Select({ isInvalid, theme = {}, children, ...props }) {
49
49
  })]
50
50
  }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Popover, {
51
51
  css: require_styles.popoverStyles(),
52
+ placement,
53
+ shouldFlip,
52
54
  offset: mergedTheme.shared.offset,
53
55
  containerPadding: mergedTheme.shared.containerPadding,
54
56
  children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ListBox, {
@@ -10,6 +10,8 @@ declare function Option({
10
10
  declare function Select({
11
11
  isInvalid,
12
12
  theme,
13
+ placement,
14
+ shouldFlip,
13
15
  children,
14
16
  ...props
15
17
  }: SelectProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -10,6 +10,8 @@ declare function Option({
10
10
  declare function Select({
11
11
  isInvalid,
12
12
  theme,
13
+ placement,
14
+ shouldFlip,
13
15
  children,
14
16
  ...props
15
17
  }: SelectProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -32,7 +32,7 @@ function ListBox$1({ children, theme = {} }) {
32
32
  children: items
33
33
  });
34
34
  }
35
- function Select$1({ isInvalid, theme = {}, children, ...props }) {
35
+ function Select$1({ isInvalid, theme = {}, placement, shouldFlip, children, ...props }) {
36
36
  const mergedTheme = mergeDeep(defaultSelectTheme, theme);
37
37
  return /* @__PURE__ */ jsxs(FormInputContainer, {
38
38
  as: Select,
@@ -47,6 +47,8 @@ function Select$1({ isInvalid, theme = {}, children, ...props }) {
47
47
  })]
48
48
  }), /* @__PURE__ */ jsx(Popover, {
49
49
  css: popoverStyles(),
50
+ placement,
51
+ shouldFlip,
50
52
  offset: mergedTheme.shared.offset,
51
53
  containerPadding: mergedTheme.shared.containerPadding,
52
54
  children: /* @__PURE__ */ jsx(ListBox$1, {
@@ -1,10 +1,23 @@
1
1
  import { DefaultPropsWithChildren } from "../../util/types.cjs";
2
2
  import { FormInputContainerDefaultProps } from "../Form/types.cjs";
3
3
  import { SelectTheme } from "./styles.cjs";
4
- import { ListBoxItemProps, SelectProps } from "react-aria-components";
4
+ import { ListBoxItemProps, PopoverProps, SelectProps } from "react-aria-components";
5
5
 
6
6
  //#region src/components/Select/types.d.ts
7
7
  interface OptionProps extends DefaultPropsWithChildren<SelectTheme, ListBoxItemProps['className'], string>, Omit<ListBoxItemProps, 'children'> {}
8
- type SelectProps$1 = FormInputContainerDefaultProps<SelectProps<object, 'single' | 'multiple'>, SelectTheme>;
8
+ type SelectProps$1 = FormInputContainerDefaultProps<SelectProps<object, 'single' | 'multiple'> & {
9
+ /**
10
+ * The placement of the options container element with respect to select input.
11
+ * @default
12
+ * 'bottom'
13
+ */
14
+ placement?: PopoverProps['placement'];
15
+ /**
16
+ * Whether the element options container element flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.
17
+ * @default
18
+ * true
19
+ * */
20
+ shouldFlip?: PopoverProps['shouldFlip'];
21
+ }, SelectTheme>;
9
22
  //#endregion
10
23
  export { OptionProps, SelectProps$1 as SelectProps };
@@ -1,10 +1,23 @@
1
1
  import { DefaultPropsWithChildren } from "../../util/types.js";
2
2
  import { FormInputContainerDefaultProps } from "../Form/types.js";
3
3
  import { SelectTheme } from "./styles.js";
4
- import { ListBoxItemProps, SelectProps } from "react-aria-components";
4
+ import { ListBoxItemProps, PopoverProps, SelectProps } from "react-aria-components";
5
5
 
6
6
  //#region src/components/Select/types.d.ts
7
7
  interface OptionProps extends DefaultPropsWithChildren<SelectTheme, ListBoxItemProps['className'], string>, Omit<ListBoxItemProps, 'children'> {}
8
- type SelectProps$1 = FormInputContainerDefaultProps<SelectProps<object, 'single' | 'multiple'>, SelectTheme>;
8
+ type SelectProps$1 = FormInputContainerDefaultProps<SelectProps<object, 'single' | 'multiple'> & {
9
+ /**
10
+ * The placement of the options container element with respect to select input.
11
+ * @default
12
+ * 'bottom'
13
+ */
14
+ placement?: PopoverProps['placement'];
15
+ /**
16
+ * Whether the element options container element flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.
17
+ * @default
18
+ * true
19
+ * */
20
+ shouldFlip?: PopoverProps['shouldFlip'];
21
+ }, SelectTheme>;
9
22
  //#endregion
10
23
  export { OptionProps, SelectProps$1 as SelectProps };
@@ -1,3 +1,4 @@
1
+ const require_Icon = require("../Icon/Icon.cjs");
1
2
  const require_styles = require("./styles.cjs");
2
3
  let react = require("react");
3
4
  let _emotion_react = require("@emotion/react");
@@ -87,10 +88,17 @@ let react_aria_components = require("react-aria-components");
87
88
  *
88
89
  * This is currently still in testing phase, so a production implementation is not yet available.
89
90
  */
90
- function Autocomplete({ addSelection, loading, onTextInputChange, options, label, placeholder, disabled, value, "data-testid": dataTestId, loadingIcon, theme, cssOverrides, addFirstOnEnter }) {
91
+ function Autocomplete({ addSelection, loading, onTextInputChange, options, label, placeholder, disabled, value, "data-testid": dataTestId, loadingIcon, theme, cssOverrides, addFirstOnEnter, symbol, icon }) {
91
92
  const [hoveredItemId, setHoveredItemId] = (0, react.useState)();
92
93
  const [upOrDownKeyPressed, setUpOrDownKeyPressed] = (0, react.useState)(false);
93
94
  const listBoxIsInUse = upOrDownKeyPressed || !!hoveredItemId;
95
+ const iconContent = icon ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Icon.Icon, {
96
+ css: require_styles.iconStyles(theme),
97
+ children: icon
98
+ }) : symbol ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Icon.Icon, {
99
+ symbol,
100
+ css: require_styles.iconStyles(theme)
101
+ }) : null;
94
102
  return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
95
103
  css: [_emotion_react.css`
96
104
  position: relative;
@@ -114,55 +122,59 @@ function Autocomplete({ addSelection, loading, onTextInputChange, options, label
114
122
  allowsCustomValue: true,
115
123
  menuTrigger: "focus",
116
124
  shouldFocusWrap: true,
117
- children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Input, {
118
- css: require_styles.autocompleteInputStyles(theme),
119
- placeholder,
120
- disabled,
121
- "data-testid": dataTestId,
122
- onKeyDown: addFirstOnEnter ? (event) => {
123
- if (event.key === "ArrowDown" || event.key === "ArrowUp") setUpOrDownKeyPressed(true);
124
- if (event.key === "Enter") {
125
- const [firstOption] = options;
126
- if (firstOption && !listBoxIsInUse) addSelection(firstOption);
127
- }
128
- } : void 0
129
- }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Popover, {
130
- placement: "bottom",
131
- css: _emotion_react.css`
125
+ children: [
126
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Input, {
127
+ css: require_styles.autocompleteInputStyles(!!iconContent, theme),
128
+ placeholder,
129
+ disabled,
130
+ "data-testid": dataTestId,
131
+ onKeyDown: addFirstOnEnter ? (event) => {
132
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") setUpOrDownKeyPressed(true);
133
+ if (event.key === "Enter") {
134
+ const [firstOption] = options;
135
+ if (firstOption && !listBoxIsInUse) addSelection(firstOption);
136
+ }
137
+ } : void 0
138
+ }),
139
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Popover, {
140
+ placement: "bottom",
141
+ css: _emotion_react.css`
132
142
  width: var(--trigger-width);
133
143
  `,
134
- offset: 0,
135
- shouldFlip: false,
136
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(react_aria_components.ListBox, {
137
- css: (value || options.length || loading) && require_styles.listboxStyles(theme),
138
- autoFocus: "first",
139
- renderEmptyState: () => value && !loading && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
140
- css: require_styles.listboxInfoStyles(theme),
141
- children: "No results"
142
- }),
143
- children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Collection, {
144
- items: options,
145
- children: (item) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.ListBoxItem, {
146
- css: require_styles.listboxItemStyles(theme),
147
- value: item,
148
- onHoverChange: (isHovering) => {
149
- setHoveredItemId((current) => {
150
- if (isHovering) return item.id;
151
- return current === item.id ? void 0 : current;
152
- });
153
- },
154
- children: item.name
155
- }, item.id)
156
- }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.ListBoxLoadMoreItem, {
157
- css: require_styles.listboxInfoStyles(theme),
158
- isLoading: loading,
159
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
160
- "aria-label": "Loading",
161
- children: loadingIcon ?? "Loading..."
162
- })
163
- })]
164
- })
165
- })]
144
+ offset: 0,
145
+ shouldFlip: false,
146
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(react_aria_components.ListBox, {
147
+ css: (value || options.length || loading) && require_styles.listboxStyles(theme),
148
+ autoFocus: "first",
149
+ renderEmptyState: () => value && !loading && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
150
+ css: require_styles.listboxInfoStyles(theme),
151
+ children: "No results"
152
+ }),
153
+ children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.Collection, {
154
+ items: options,
155
+ children: (item) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.ListBoxItem, {
156
+ css: require_styles.listboxItemStyles(theme),
157
+ value: item,
158
+ onHoverChange: (isHovering) => {
159
+ setHoveredItemId((current) => {
160
+ if (isHovering) return item.id;
161
+ return current === item.id ? void 0 : current;
162
+ });
163
+ },
164
+ children: item.name
165
+ }, item.id)
166
+ }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react_aria_components.ListBoxLoadMoreItem, {
167
+ css: require_styles.listboxInfoStyles(theme),
168
+ isLoading: loading,
169
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
170
+ "aria-label": "Loading",
171
+ children: loadingIcon ?? "Loading..."
172
+ })
173
+ })]
174
+ })
175
+ }),
176
+ iconContent
177
+ ]
166
178
  })
167
179
  });
168
180
  }
@@ -1,7 +1,8 @@
1
1
  import { DeepPartial } from "../../util/types.cjs";
2
+ import { IconProps } from "../Icon/types.cjs";
2
3
  import { ComponentAutocomplete } from "../../styleD/build/typescript/component/autocomplete.cjs";
3
4
  import { SerializedStyles } from "@emotion/react";
4
- import { ReactElement } from "react";
5
+ import { ReactElement, ReactNode } from "react";
5
6
 
6
7
  //#region src/components/TagPicker/Autocomplete.d.ts
7
8
  type AutocompleteOption = {
@@ -33,6 +34,13 @@ interface AutocompleteProps<T extends AutocompleteOption = AutocompleteOption> {
33
34
  theme?: DeepPartial<ComponentAutocomplete>;
34
35
  /** `cssOverrides` - Escape hatch for styling that doesn't fall into the theme */
35
36
  cssOverrides?: SerializedStyles;
37
+ /** An icon to render to the right of the input */
38
+ icon?: ReactNode;
39
+ /**
40
+ * Alternative to using the `icon` prop for rendering a Material Symbol icons on the right of the input
41
+ * you can use the `symbol` prop to specify the icon by its symbol name.
42
+ */
43
+ symbol?: IconProps['symbol'];
36
44
  }
37
45
  /**
38
46
  * ## Autocomplete
@@ -130,7 +138,9 @@ declare function Autocomplete<T extends AutocompleteOption = AutocompleteOption>
130
138
  loadingIcon,
131
139
  theme,
132
140
  cssOverrides,
133
- addFirstOnEnter
141
+ addFirstOnEnter,
142
+ symbol,
143
+ icon
134
144
  }: AutocompleteProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
135
145
  //#endregion
136
146
  export { Autocomplete };
@@ -1,6 +1,7 @@
1
1
  import { DeepPartial } from "../../util/types.js";
2
+ import { IconProps } from "../Icon/types.js";
2
3
  import { ComponentAutocomplete } from "../../styleD/build/typescript/component/autocomplete.js";
3
- import { ReactElement } from "react";
4
+ import { ReactElement, ReactNode } from "react";
4
5
  import { SerializedStyles } from "@emotion/react";
5
6
 
6
7
  //#region src/components/TagPicker/Autocomplete.d.ts
@@ -33,6 +34,13 @@ interface AutocompleteProps<T extends AutocompleteOption = AutocompleteOption> {
33
34
  theme?: DeepPartial<ComponentAutocomplete>;
34
35
  /** `cssOverrides` - Escape hatch for styling that doesn't fall into the theme */
35
36
  cssOverrides?: SerializedStyles;
37
+ /** An icon to render to the right of the input */
38
+ icon?: ReactNode;
39
+ /**
40
+ * Alternative to using the `icon` prop for rendering a Material Symbol icons on the right of the input
41
+ * you can use the `symbol` prop to specify the icon by its symbol name.
42
+ */
43
+ symbol?: IconProps['symbol'];
36
44
  }
37
45
  /**
38
46
  * ## Autocomplete
@@ -130,7 +138,9 @@ declare function Autocomplete<T extends AutocompleteOption = AutocompleteOption>
130
138
  loadingIcon,
131
139
  theme,
132
140
  cssOverrides,
133
- addFirstOnEnter
141
+ addFirstOnEnter,
142
+ symbol,
143
+ icon
134
144
  }: AutocompleteProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
135
145
  //#endregion
136
146
  export { Autocomplete };
@@ -1,7 +1,8 @@
1
- import { autocompleteInputStyles, listboxInfoStyles, listboxItemStyles, listboxStyles } from "./styles.js";
1
+ import { Icon } from "../Icon/Icon.js";
2
+ import { autocompleteInputStyles, iconStyles, listboxInfoStyles, listboxItemStyles, listboxStyles } from "./styles.js";
2
3
  import { useState } from "react";
3
4
  import { css } from "@emotion/react";
4
- import { jsx as jsx$1, jsxs } from "@emotion/react/jsx-runtime";
5
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
5
6
  import { Collection, ComboBox, Input, ListBox, ListBoxItem, ListBoxLoadMoreItem, Popover } from "react-aria-components";
6
7
  //#region src/components/TagPicker/Autocomplete.tsx
7
8
  /**
@@ -87,11 +88,18 @@ import { Collection, ComboBox, Input, ListBox, ListBoxItem, ListBoxLoadMoreItem,
87
88
  *
88
89
  * This is currently still in testing phase, so a production implementation is not yet available.
89
90
  */
90
- function Autocomplete({ addSelection, loading, onTextInputChange, options, label, placeholder, disabled, value, "data-testid": dataTestId, loadingIcon, theme, cssOverrides, addFirstOnEnter }) {
91
+ function Autocomplete({ addSelection, loading, onTextInputChange, options, label, placeholder, disabled, value, "data-testid": dataTestId, loadingIcon, theme, cssOverrides, addFirstOnEnter, symbol, icon }) {
91
92
  const [hoveredItemId, setHoveredItemId] = useState();
92
93
  const [upOrDownKeyPressed, setUpOrDownKeyPressed] = useState(false);
93
94
  const listBoxIsInUse = upOrDownKeyPressed || !!hoveredItemId;
94
- return /* @__PURE__ */ jsx$1("div", {
95
+ const iconContent = icon ? /* @__PURE__ */ jsx(Icon, {
96
+ css: iconStyles(theme),
97
+ children: icon
98
+ }) : symbol ? /* @__PURE__ */ jsx(Icon, {
99
+ symbol,
100
+ css: iconStyles(theme)
101
+ }) : null;
102
+ return /* @__PURE__ */ jsx("div", {
95
103
  css: [css`
96
104
  position: relative;
97
105
  `, cssOverrides],
@@ -114,55 +122,59 @@ function Autocomplete({ addSelection, loading, onTextInputChange, options, label
114
122
  allowsCustomValue: true,
115
123
  menuTrigger: "focus",
116
124
  shouldFocusWrap: true,
117
- children: [/* @__PURE__ */ jsx$1(Input, {
118
- css: autocompleteInputStyles(theme),
119
- placeholder,
120
- disabled,
121
- "data-testid": dataTestId,
122
- onKeyDown: addFirstOnEnter ? (event) => {
123
- if (event.key === "ArrowDown" || event.key === "ArrowUp") setUpOrDownKeyPressed(true);
124
- if (event.key === "Enter") {
125
- const [firstOption] = options;
126
- if (firstOption && !listBoxIsInUse) addSelection(firstOption);
127
- }
128
- } : void 0
129
- }), /* @__PURE__ */ jsx$1(Popover, {
130
- placement: "bottom",
131
- css: css`
125
+ children: [
126
+ /* @__PURE__ */ jsx(Input, {
127
+ css: autocompleteInputStyles(!!iconContent, theme),
128
+ placeholder,
129
+ disabled,
130
+ "data-testid": dataTestId,
131
+ onKeyDown: addFirstOnEnter ? (event) => {
132
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") setUpOrDownKeyPressed(true);
133
+ if (event.key === "Enter") {
134
+ const [firstOption] = options;
135
+ if (firstOption && !listBoxIsInUse) addSelection(firstOption);
136
+ }
137
+ } : void 0
138
+ }),
139
+ /* @__PURE__ */ jsx(Popover, {
140
+ placement: "bottom",
141
+ css: css`
132
142
  width: var(--trigger-width);
133
143
  `,
134
- offset: 0,
135
- shouldFlip: false,
136
- children: /* @__PURE__ */ jsxs(ListBox, {
137
- css: (value || options.length || loading) && listboxStyles(theme),
138
- autoFocus: "first",
139
- renderEmptyState: () => value && !loading && /* @__PURE__ */ jsx$1("div", {
140
- css: listboxInfoStyles(theme),
141
- children: "No results"
142
- }),
143
- children: [/* @__PURE__ */ jsx$1(Collection, {
144
- items: options,
145
- children: (item) => /* @__PURE__ */ jsx$1(ListBoxItem, {
146
- css: listboxItemStyles(theme),
147
- value: item,
148
- onHoverChange: (isHovering) => {
149
- setHoveredItemId((current) => {
150
- if (isHovering) return item.id;
151
- return current === item.id ? void 0 : current;
152
- });
153
- },
154
- children: item.name
155
- }, item.id)
156
- }), /* @__PURE__ */ jsx$1(ListBoxLoadMoreItem, {
157
- css: listboxInfoStyles(theme),
158
- isLoading: loading,
159
- children: /* @__PURE__ */ jsx$1("span", {
160
- "aria-label": "Loading",
161
- children: loadingIcon ?? "Loading..."
162
- })
163
- })]
164
- })
165
- })]
144
+ offset: 0,
145
+ shouldFlip: false,
146
+ children: /* @__PURE__ */ jsxs(ListBox, {
147
+ css: (value || options.length || loading) && listboxStyles(theme),
148
+ autoFocus: "first",
149
+ renderEmptyState: () => value && !loading && /* @__PURE__ */ jsx("div", {
150
+ css: listboxInfoStyles(theme),
151
+ children: "No results"
152
+ }),
153
+ children: [/* @__PURE__ */ jsx(Collection, {
154
+ items: options,
155
+ children: (item) => /* @__PURE__ */ jsx(ListBoxItem, {
156
+ css: listboxItemStyles(theme),
157
+ value: item,
158
+ onHoverChange: (isHovering) => {
159
+ setHoveredItemId((current) => {
160
+ if (isHovering) return item.id;
161
+ return current === item.id ? void 0 : current;
162
+ });
163
+ },
164
+ children: item.name
165
+ }, item.id)
166
+ }), /* @__PURE__ */ jsx(ListBoxLoadMoreItem, {
167
+ css: listboxInfoStyles(theme),
168
+ isLoading: loading,
169
+ children: /* @__PURE__ */ jsx("span", {
170
+ "aria-label": "Loading",
171
+ children: loadingIcon ?? "Loading..."
172
+ })
173
+ })]
174
+ })
175
+ }),
176
+ iconContent
177
+ ]
166
178
  })
167
179
  });
168
180
  }
@@ -0,0 +1,105 @@
1
+ const require_Button = require("../Button/Button.cjs");
2
+ const require_InlineMessage = require("../InlineMessage/InlineMessage.cjs");
3
+ const require_styles = require("./styles.cjs");
4
+ const require_TagTable = require("./TagTable.cjs");
5
+ const require_TagSearchWithFilters = require("./TagSearchWithFilters.cjs");
6
+ let _emotion_react = require("@emotion/react");
7
+ let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
8
+ //#region src/components/TagPicker/TagPicker.tsx
9
+ /**
10
+ * ## TagPicker
11
+ *
12
+ * *Status: Testing*
13
+ *
14
+ * **Peer dependencies:**
15
+ * - `react-aria-components`
16
+ *
17
+ * See the `peerDependencies` section of the `package.json` for compatible versions to install.
18
+ *
19
+ *
20
+ * #### Props
21
+ *
22
+ * See {@link TagPickerProps} for a full list of props and descriptions.
23
+ *
24
+ * #### Example
25
+ *
26
+ * This is currently still in testing phase, so a production implementation is not yet available.
27
+ */
28
+ function TagPicker({ addTag, loading, offline = false, onReorder, onSearch, options, proposedTags, readOnly = false, removeTag, retryConnection, tags, canRemove, filterRows, filterOptions, offlineBackupTags, highlightLeadingTag, searchPlaceholder = "Search for tags", searchLabel = "Search for tags", removeIcon, searchIcon, showTagType, showTagSectionName, theme, tagTableTheme, proposedTagTableTheme, autoCompleteTheme, selectTheme, cssOverrides }) {
29
+ const selectedTagIds = tags.map(({ id }) => id);
30
+ const proposedTagsWithoutSelected = proposedTags.filter(({ id }) => !selectedTagIds.includes(id));
31
+ const backupTagsWithoutSelected = offlineBackupTags?.filter(({ id }) => !selectedTagIds.includes(id)) ?? [];
32
+ const showBackupListWhenOffline = !readOnly && offlineBackupTags && backupTagsWithoutSelected.length > 0;
33
+ const optionsWithoutSelected = options.filter(({ id }) => !selectedTagIds.includes(id));
34
+ return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
35
+ css: [require_styles.tagPickerStyles(theme), cssOverrides],
36
+ children: [
37
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_TagSearchWithFilters.TagSearchWithFilters, {
38
+ icon: searchIcon,
39
+ onSearch,
40
+ addSelection: addTag,
41
+ options: optionsWithoutSelected,
42
+ loading,
43
+ filterOptions,
44
+ disabled: readOnly || offline,
45
+ label: searchLabel,
46
+ placeholder: searchPlaceholder,
47
+ "data-testid": "tag-picker-search-input",
48
+ symbol: "search",
49
+ theme,
50
+ autoCompleteTheme,
51
+ selectTheme
52
+ }),
53
+ offline && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
54
+ css: require_styles.offlineSectionStyles(theme),
55
+ children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(require_InlineMessage.InlineMessage, {
56
+ level: "error",
57
+ children: [
58
+ "Unfortunately, we can't fetch tag information.",
59
+ " ",
60
+ showBackupListWhenOffline && "Choose from the following tags",
61
+ showBackupListWhenOffline && retryConnection && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_emotion_react_jsx_runtime.Fragment, { children: " or " }),
62
+ retryConnection && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Button.Button, {
63
+ size: "xs",
64
+ variant: "secondary",
65
+ onClick: () => retryConnection(),
66
+ children: "Retry"
67
+ })
68
+ ]
69
+ }), showBackupListWhenOffline && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_emotion_react_jsx_runtime.Fragment, { children: backupTagsWithoutSelected.map((tag, index) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Button.Button, {
70
+ onClick: () => addTag(tag),
71
+ variant: "tertiary",
72
+ size: "sm",
73
+ cssOverrides: (0, _emotion_react.css)({ justifyContent: theme?.offlineSection?.justifyContent ?? "flex-start" }),
74
+ "aria-label": `Add ${tag.name}`,
75
+ children: tag.name
76
+ }, index)) })]
77
+ }),
78
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_TagTable.TagTable, {
79
+ rows: tags,
80
+ canRemove,
81
+ removeAction: readOnly ? void 0 : removeTag,
82
+ filterRows,
83
+ onReorder: readOnly ? void 0 : onReorder,
84
+ "data-testid": "selected-tags-table",
85
+ highlightFirstRow: highlightLeadingTag,
86
+ showTagType,
87
+ showTagSectionName,
88
+ removeIcon,
89
+ theme: tagTableTheme
90
+ }),
91
+ !readOnly && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_TagTable.TagTable, {
92
+ heading: "Proposed Tags",
93
+ theme: proposedTagTableTheme,
94
+ filterRows,
95
+ showTagType,
96
+ showTagSectionName,
97
+ rows: proposedTagsWithoutSelected,
98
+ addAction: addTag,
99
+ "data-testid": "proposed-tags-table"
100
+ })
101
+ ]
102
+ });
103
+ }
104
+ //#endregion
105
+ exports.TagPicker = TagPicker;