@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
+ //#region src/styleD/build/typescript/component/tagPicker.d.ts
2
+ /**
3
+ * Do not edit directly, this file was auto-generated.
4
+ */
5
+ declare const componentTagPicker: {
6
+ shared: {
7
+ width: string;
8
+ gap: string;
9
+ };
10
+ select: {
11
+ flexBasis: string;
12
+ };
13
+ offlineSection: {
14
+ justifyContent: string;
15
+ gap: string;
16
+ };
17
+ };
18
+ type ComponentTagPicker = typeof componentTagPicker;
19
+ //#endregion
20
+ export { ComponentTagPicker, componentTagPicker };
@@ -0,0 +1,17 @@
1
+ //#region src/styleD/build/typescript/component/tagPicker.ts
2
+ /**
3
+ * Do not edit directly, this file was auto-generated.
4
+ */
5
+ const componentTagPicker = {
6
+ shared: {
7
+ width: "100%",
8
+ gap: "15px"
9
+ },
10
+ select: { flexBasis: "25%" },
11
+ offlineSection: {
12
+ justifyContent: "flex-start",
13
+ gap: "4px"
14
+ }
15
+ };
16
+ //#endregion
17
+ export { componentTagPicker };
@@ -37,8 +37,8 @@ const componentTagTable = {
37
37
  color: "#ffffff",
38
38
  paddingX: "10px",
39
39
  paddingY: "0px",
40
- backgroundColor: "#8d8d8d",
41
- backgroundHoverColor: "#545454",
40
+ backgroundColor: "#545454",
41
+ backgroundHoverColor: "#333333",
42
42
  fontWeight: 400,
43
43
  fontSize: "13px"
44
44
  },
@@ -37,8 +37,8 @@ const componentTagTable = {
37
37
  color: "#ffffff",
38
38
  paddingX: "10px",
39
39
  paddingY: "0px",
40
- backgroundColor: "#8d8d8d",
41
- backgroundHoverColor: "#545454",
40
+ backgroundColor: "#545454",
41
+ backgroundHoverColor: "#333333",
42
42
  fontWeight: 400,
43
43
  fontSize: "13px"
44
44
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/stand",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "repository": {
5
5
  "url": "https://github.com/guardian/stand"
6
6
  },
@@ -297,6 +297,16 @@
297
297
  "default": "./dist/Layout.cjs"
298
298
  }
299
299
  },
300
+ "./Modal": {
301
+ "import": {
302
+ "types": "./dist/Modal.d.ts",
303
+ "default": "./dist/Modal.js"
304
+ },
305
+ "require": {
306
+ "types": "./dist/Modal.d.cts",
307
+ "default": "./dist/Modal.cjs"
308
+ }
309
+ },
300
310
  "./utils": {
301
311
  "import": {
302
312
  "types": "./dist/utils.d.ts",
@@ -348,7 +358,8 @@
348
358
  "./component/intendedAudienceSignifier.css": "./dist/styleD/build/css/component/intendedAudienceSignifier.css",
349
359
  "./component/link.css": "./dist/styleD/build/css/component/link.css",
350
360
  "./component/grid.css": "./dist/styleD/build/css/component/grid.css",
351
- "./component/layout.css": "./dist/styleD/build/css/component/layout.css"
361
+ "./component/layout.css": "./dist/styleD/build/css/component/layout.css",
362
+ "./component/modal.css": "./dist/styleD/build/css/component/modal.css"
352
363
  },
353
364
  "main": "./dist/index.cjs",
354
365
  "module": "./dist/index.js",
@@ -441,6 +452,9 @@
441
452
  ],
442
453
  "Layout": [
443
454
  "./dist/Layout.d.ts"
455
+ ],
456
+ "Modal": [
457
+ "./dist/Modal.d.ts"
444
458
  ]
445
459
  }
446
460
  },
@@ -1,118 +0,0 @@
1
- const require_Autocomplete = require("./Autocomplete.cjs");
2
- let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
3
- //#region src/components/TagPicker/TagAutocomplete.tsx
4
- /**
5
- * ## TagAutocomplete
6
- *
7
- * *Status: Testing*
8
- *
9
- * Part of the overall TagPicker component, the TagAutocomplete provides an accessible
10
- * autocomplete input for selecting tags from a list of options, based on the [React Aria ComboBox](https://react-spectrum.adobe.com/react-aria/ComboBox) component.
11
- *
12
- * **Peer dependencies:**
13
- * - `react-aria-components`
14
- *
15
- * See the `peerDependencies` section of the `package.json` for compatible versions to install.
16
- *
17
- * ## Usage
18
- *
19
- * *Example with TagAutocomplete and TagTable combined:*
20
- *
21
- * ```tsx
22
- * import { TagAutocomplete, TagTable } from '@guardian/stand';
23
- *
24
- * // Define a type for your tags — it must include `id` and `name`,
25
- * // plus any extra fields TagTable needs (type, sectionName)
26
- * type MyTag = {
27
- * id: number;
28
- * name: string;
29
- * type: string;
30
- * sectionName: string;
31
- * };
32
- *
33
- * const allTags: MyTag[] = [
34
- * { id: 1, name: 'UK news', type: 'Keyword', sectionName: 'World' },
35
- * { id: 2, name: 'US politics', type: 'Keyword', sectionName: 'Politics' },
36
- * // ...
37
- * ];
38
- *
39
- * const Component = () => {
40
- * const [selectedTags, setSelectedTags] = useState<MyTag[]>([]);
41
- * const [options, setOptions] = useState<MyTag[]>([]);
42
- * const [value, setValue] = useState('');
43
- *
44
- * const onTextInputChange = (inputText: string) => {
45
- * setValue(inputText);
46
- * if (inputText === '') {
47
- * setOptions([]);
48
- * return;
49
- * }
50
- *
51
- * if (inputText === '*') {
52
- * setOptions(allTags);
53
- * return;
54
- * }
55
- *
56
- * // Simple filtering against allTags
57
- * const filteredItems = allTags.filter((t) =>
58
- * t.name.toLowerCase().includes(inputText.toLowerCase()),
59
- * );
60
- * setOptions(filteredItems);
61
- * };
62
- *
63
- * return (
64
- * <>
65
- * <div
66
- * css={css`
67
- * display: flex;
68
- * `}
69
- * >
70
- * <TagAutocomplete
71
- * onTextInputChange={onTextInputChange}
72
- * options={options}
73
- * label="Tags"
74
- * addTag={(tag) =>
75
- * setSelectedTags((tags) => [...tags, tag])
76
- * }
77
- * loading={false}
78
- * placeholder={''}
79
- * disabled={false}
80
- * value={value}
81
- * />
82
- * <select>
83
- * <option>All tags</option>
84
- * </select>
85
- * </div>
86
- * <TagTable rows={selectedTags} filterRows={() => true} />
87
- * </>
88
- * );
89
- * };
90
- * ```
91
- *
92
- * #### Props
93
- *
94
- * See {@link TagAutocompleteProps} for a full list of props and descriptions.
95
- *
96
- * #### Example
97
- *
98
- * This is currently still in testing phase, so a production implementation is not yet available.
99
- */
100
- function TagAutocomplete({ addTag, loading, onTextInputChange, options, label, placeholder, disabled, value, "data-testid": dataTestId, loadingIcon, theme, cssOverrides }) {
101
- return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Autocomplete.Autocomplete, {
102
- onTextInputChange,
103
- options,
104
- label,
105
- addSelection: addTag,
106
- loading,
107
- placeholder,
108
- disabled,
109
- value,
110
- "data-testid": dataTestId,
111
- loadingIcon,
112
- addFirstOnEnter: true,
113
- theme,
114
- cssOverrides
115
- });
116
- }
117
- //#endregion
118
- exports.TagAutocomplete = TagAutocomplete;
@@ -1,144 +0,0 @@
1
- import { DeepPartial } from "../../util/types.cjs";
2
- import { ComponentAutocomplete } from "../../styleD/build/typescript/component/autocomplete.cjs";
3
- import { Tag } from "./types.cjs";
4
- import { SerializedStyles } from "@emotion/react";
5
- import { ReactElement } from "react";
6
-
7
- //#region src/components/TagPicker/TagAutocomplete.d.ts
8
- interface TagAutocompleteProps<T extends Tag = Tag> {
9
- /** `addTag` - Function called when an option is picked from the dropdown */
10
- addTag: (tag: T) => void;
11
- /** `loading` - Whether the component is loading options for the dropdown */
12
- loading: boolean;
13
- /** `onTextInputChange` - Function called when the combobox input changes */
14
- onTextInputChange: (inputText: string) => void;
15
- /** `options` - The list of options shown in the dropdown */
16
- options: T[];
17
- /** `label` - An accessible label for the combobox input */
18
- label: string;
19
- /** `placeholder` - A placeholder string for the combobox input */
20
- placeholder: string;
21
- /** `disabled` - Whether the combobox input is disabled */
22
- disabled: boolean;
23
- /** `value` - The value of the combobox input */
24
- value: string;
25
- 'data-testid'?: string;
26
- /** `loadingIcon` - Icon used to show loading happening in the dropdown */
27
- loadingIcon?: ReactElement;
28
- /** `theme` - Used to customise the look and feel of the TagAutocomplete component */
29
- theme?: DeepPartial<ComponentAutocomplete>;
30
- /** `cssOverrides` - Escape hatch for styling that doesn't fall into the theme */
31
- cssOverrides?: SerializedStyles;
32
- }
33
- /**
34
- * ## TagAutocomplete
35
- *
36
- * *Status: Testing*
37
- *
38
- * Part of the overall TagPicker component, the TagAutocomplete provides an accessible
39
- * autocomplete input for selecting tags from a list of options, based on the [React Aria ComboBox](https://react-spectrum.adobe.com/react-aria/ComboBox) component.
40
- *
41
- * **Peer dependencies:**
42
- * - `react-aria-components`
43
- *
44
- * See the `peerDependencies` section of the `package.json` for compatible versions to install.
45
- *
46
- * ## Usage
47
- *
48
- * *Example with TagAutocomplete and TagTable combined:*
49
- *
50
- * ```tsx
51
- * import { TagAutocomplete, TagTable } from '@guardian/stand';
52
- *
53
- * // Define a type for your tags — it must include `id` and `name`,
54
- * // plus any extra fields TagTable needs (type, sectionName)
55
- * type MyTag = {
56
- * id: number;
57
- * name: string;
58
- * type: string;
59
- * sectionName: string;
60
- * };
61
- *
62
- * const allTags: MyTag[] = [
63
- * { id: 1, name: 'UK news', type: 'Keyword', sectionName: 'World' },
64
- * { id: 2, name: 'US politics', type: 'Keyword', sectionName: 'Politics' },
65
- * // ...
66
- * ];
67
- *
68
- * const Component = () => {
69
- * const [selectedTags, setSelectedTags] = useState<MyTag[]>([]);
70
- * const [options, setOptions] = useState<MyTag[]>([]);
71
- * const [value, setValue] = useState('');
72
- *
73
- * const onTextInputChange = (inputText: string) => {
74
- * setValue(inputText);
75
- * if (inputText === '') {
76
- * setOptions([]);
77
- * return;
78
- * }
79
- *
80
- * if (inputText === '*') {
81
- * setOptions(allTags);
82
- * return;
83
- * }
84
- *
85
- * // Simple filtering against allTags
86
- * const filteredItems = allTags.filter((t) =>
87
- * t.name.toLowerCase().includes(inputText.toLowerCase()),
88
- * );
89
- * setOptions(filteredItems);
90
- * };
91
- *
92
- * return (
93
- * <>
94
- * <div
95
- * css={css`
96
- * display: flex;
97
- * `}
98
- * >
99
- * <TagAutocomplete
100
- * onTextInputChange={onTextInputChange}
101
- * options={options}
102
- * label="Tags"
103
- * addTag={(tag) =>
104
- * setSelectedTags((tags) => [...tags, tag])
105
- * }
106
- * loading={false}
107
- * placeholder={''}
108
- * disabled={false}
109
- * value={value}
110
- * />
111
- * <select>
112
- * <option>All tags</option>
113
- * </select>
114
- * </div>
115
- * <TagTable rows={selectedTags} filterRows={() => true} />
116
- * </>
117
- * );
118
- * };
119
- * ```
120
- *
121
- * #### Props
122
- *
123
- * See {@link TagAutocompleteProps} for a full list of props and descriptions.
124
- *
125
- * #### Example
126
- *
127
- * This is currently still in testing phase, so a production implementation is not yet available.
128
- */
129
- declare function TagAutocomplete<T extends Tag = Tag>({
130
- addTag,
131
- loading,
132
- onTextInputChange,
133
- options,
134
- label,
135
- placeholder,
136
- disabled,
137
- value,
138
- 'data-testid': dataTestId,
139
- loadingIcon,
140
- theme,
141
- cssOverrides
142
- }: TagAutocompleteProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
143
- //#endregion
144
- export { TagAutocomplete };
@@ -1,144 +0,0 @@
1
- import { DeepPartial } from "../../util/types.js";
2
- import { ComponentAutocomplete } from "../../styleD/build/typescript/component/autocomplete.js";
3
- import { Tag } from "./types.js";
4
- import { ReactElement } from "react";
5
- import { SerializedStyles } from "@emotion/react";
6
-
7
- //#region src/components/TagPicker/TagAutocomplete.d.ts
8
- interface TagAutocompleteProps<T extends Tag = Tag> {
9
- /** `addTag` - Function called when an option is picked from the dropdown */
10
- addTag: (tag: T) => void;
11
- /** `loading` - Whether the component is loading options for the dropdown */
12
- loading: boolean;
13
- /** `onTextInputChange` - Function called when the combobox input changes */
14
- onTextInputChange: (inputText: string) => void;
15
- /** `options` - The list of options shown in the dropdown */
16
- options: T[];
17
- /** `label` - An accessible label for the combobox input */
18
- label: string;
19
- /** `placeholder` - A placeholder string for the combobox input */
20
- placeholder: string;
21
- /** `disabled` - Whether the combobox input is disabled */
22
- disabled: boolean;
23
- /** `value` - The value of the combobox input */
24
- value: string;
25
- 'data-testid'?: string;
26
- /** `loadingIcon` - Icon used to show loading happening in the dropdown */
27
- loadingIcon?: ReactElement;
28
- /** `theme` - Used to customise the look and feel of the TagAutocomplete component */
29
- theme?: DeepPartial<ComponentAutocomplete>;
30
- /** `cssOverrides` - Escape hatch for styling that doesn't fall into the theme */
31
- cssOverrides?: SerializedStyles;
32
- }
33
- /**
34
- * ## TagAutocomplete
35
- *
36
- * *Status: Testing*
37
- *
38
- * Part of the overall TagPicker component, the TagAutocomplete provides an accessible
39
- * autocomplete input for selecting tags from a list of options, based on the [React Aria ComboBox](https://react-spectrum.adobe.com/react-aria/ComboBox) component.
40
- *
41
- * **Peer dependencies:**
42
- * - `react-aria-components`
43
- *
44
- * See the `peerDependencies` section of the `package.json` for compatible versions to install.
45
- *
46
- * ## Usage
47
- *
48
- * *Example with TagAutocomplete and TagTable combined:*
49
- *
50
- * ```tsx
51
- * import { TagAutocomplete, TagTable } from '@guardian/stand';
52
- *
53
- * // Define a type for your tags — it must include `id` and `name`,
54
- * // plus any extra fields TagTable needs (type, sectionName)
55
- * type MyTag = {
56
- * id: number;
57
- * name: string;
58
- * type: string;
59
- * sectionName: string;
60
- * };
61
- *
62
- * const allTags: MyTag[] = [
63
- * { id: 1, name: 'UK news', type: 'Keyword', sectionName: 'World' },
64
- * { id: 2, name: 'US politics', type: 'Keyword', sectionName: 'Politics' },
65
- * // ...
66
- * ];
67
- *
68
- * const Component = () => {
69
- * const [selectedTags, setSelectedTags] = useState<MyTag[]>([]);
70
- * const [options, setOptions] = useState<MyTag[]>([]);
71
- * const [value, setValue] = useState('');
72
- *
73
- * const onTextInputChange = (inputText: string) => {
74
- * setValue(inputText);
75
- * if (inputText === '') {
76
- * setOptions([]);
77
- * return;
78
- * }
79
- *
80
- * if (inputText === '*') {
81
- * setOptions(allTags);
82
- * return;
83
- * }
84
- *
85
- * // Simple filtering against allTags
86
- * const filteredItems = allTags.filter((t) =>
87
- * t.name.toLowerCase().includes(inputText.toLowerCase()),
88
- * );
89
- * setOptions(filteredItems);
90
- * };
91
- *
92
- * return (
93
- * <>
94
- * <div
95
- * css={css`
96
- * display: flex;
97
- * `}
98
- * >
99
- * <TagAutocomplete
100
- * onTextInputChange={onTextInputChange}
101
- * options={options}
102
- * label="Tags"
103
- * addTag={(tag) =>
104
- * setSelectedTags((tags) => [...tags, tag])
105
- * }
106
- * loading={false}
107
- * placeholder={''}
108
- * disabled={false}
109
- * value={value}
110
- * />
111
- * <select>
112
- * <option>All tags</option>
113
- * </select>
114
- * </div>
115
- * <TagTable rows={selectedTags} filterRows={() => true} />
116
- * </>
117
- * );
118
- * };
119
- * ```
120
- *
121
- * #### Props
122
- *
123
- * See {@link TagAutocompleteProps} for a full list of props and descriptions.
124
- *
125
- * #### Example
126
- *
127
- * This is currently still in testing phase, so a production implementation is not yet available.
128
- */
129
- declare function TagAutocomplete<T extends Tag = Tag>({
130
- addTag,
131
- loading,
132
- onTextInputChange,
133
- options,
134
- label,
135
- placeholder,
136
- disabled,
137
- value,
138
- 'data-testid': dataTestId,
139
- loadingIcon,
140
- theme,
141
- cssOverrides
142
- }: TagAutocompleteProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
143
- //#endregion
144
- export { TagAutocomplete };
@@ -1,118 +0,0 @@
1
- import { Autocomplete } from "./Autocomplete.js";
2
- import { jsx } from "@emotion/react/jsx-runtime";
3
- //#region src/components/TagPicker/TagAutocomplete.tsx
4
- /**
5
- * ## TagAutocomplete
6
- *
7
- * *Status: Testing*
8
- *
9
- * Part of the overall TagPicker component, the TagAutocomplete provides an accessible
10
- * autocomplete input for selecting tags from a list of options, based on the [React Aria ComboBox](https://react-spectrum.adobe.com/react-aria/ComboBox) component.
11
- *
12
- * **Peer dependencies:**
13
- * - `react-aria-components`
14
- *
15
- * See the `peerDependencies` section of the `package.json` for compatible versions to install.
16
- *
17
- * ## Usage
18
- *
19
- * *Example with TagAutocomplete and TagTable combined:*
20
- *
21
- * ```tsx
22
- * import { TagAutocomplete, TagTable } from '@guardian/stand';
23
- *
24
- * // Define a type for your tags — it must include `id` and `name`,
25
- * // plus any extra fields TagTable needs (type, sectionName)
26
- * type MyTag = {
27
- * id: number;
28
- * name: string;
29
- * type: string;
30
- * sectionName: string;
31
- * };
32
- *
33
- * const allTags: MyTag[] = [
34
- * { id: 1, name: 'UK news', type: 'Keyword', sectionName: 'World' },
35
- * { id: 2, name: 'US politics', type: 'Keyword', sectionName: 'Politics' },
36
- * // ...
37
- * ];
38
- *
39
- * const Component = () => {
40
- * const [selectedTags, setSelectedTags] = useState<MyTag[]>([]);
41
- * const [options, setOptions] = useState<MyTag[]>([]);
42
- * const [value, setValue] = useState('');
43
- *
44
- * const onTextInputChange = (inputText: string) => {
45
- * setValue(inputText);
46
- * if (inputText === '') {
47
- * setOptions([]);
48
- * return;
49
- * }
50
- *
51
- * if (inputText === '*') {
52
- * setOptions(allTags);
53
- * return;
54
- * }
55
- *
56
- * // Simple filtering against allTags
57
- * const filteredItems = allTags.filter((t) =>
58
- * t.name.toLowerCase().includes(inputText.toLowerCase()),
59
- * );
60
- * setOptions(filteredItems);
61
- * };
62
- *
63
- * return (
64
- * <>
65
- * <div
66
- * css={css`
67
- * display: flex;
68
- * `}
69
- * >
70
- * <TagAutocomplete
71
- * onTextInputChange={onTextInputChange}
72
- * options={options}
73
- * label="Tags"
74
- * addTag={(tag) =>
75
- * setSelectedTags((tags) => [...tags, tag])
76
- * }
77
- * loading={false}
78
- * placeholder={''}
79
- * disabled={false}
80
- * value={value}
81
- * />
82
- * <select>
83
- * <option>All tags</option>
84
- * </select>
85
- * </div>
86
- * <TagTable rows={selectedTags} filterRows={() => true} />
87
- * </>
88
- * );
89
- * };
90
- * ```
91
- *
92
- * #### Props
93
- *
94
- * See {@link TagAutocompleteProps} for a full list of props and descriptions.
95
- *
96
- * #### Example
97
- *
98
- * This is currently still in testing phase, so a production implementation is not yet available.
99
- */
100
- function TagAutocomplete({ addTag, loading, onTextInputChange, options, label, placeholder, disabled, value, "data-testid": dataTestId, loadingIcon, theme, cssOverrides }) {
101
- return /* @__PURE__ */ jsx(Autocomplete, {
102
- onTextInputChange,
103
- options,
104
- label,
105
- addSelection: addTag,
106
- loading,
107
- placeholder,
108
- disabled,
109
- value,
110
- "data-testid": dataTestId,
111
- loadingIcon,
112
- addFirstOnEnter: true,
113
- theme,
114
- cssOverrides
115
- });
116
- }
117
- //#endregion
118
- export { TagAutocomplete };