@guardian/stand 0.0.29 → 0.0.31
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.
- package/dist/components/tag-picker/Autocomplete.cjs +107 -0
- package/dist/components/tag-picker/Autocomplete.js +26 -0
- package/dist/components/tag-picker/TagAutocomplete.cjs +15 -83
- package/dist/components/tag-picker/TagAutocomplete.js +4 -22
- package/dist/components/tag-picker/TagTable.cjs +5 -5
- package/dist/components/tag-picker/TagTable.js +5 -5
- package/dist/components/tag-picker/styles.cjs +10 -7
- package/dist/components/tag-picker/styles.js +10 -7
- package/dist/components/topbar/TopBar.cjs +8 -1
- package/dist/components/topbar/TopBar.js +1 -1
- package/dist/components/topbar/styles.cjs +4 -1
- package/dist/components/topbar/styles.js +4 -1
- package/dist/index.cjs +24 -24
- package/dist/index.js +12 -12
- package/dist/styleD/build/css/component/TopBar.css +5 -1
- package/dist/styleD/build/css/component/autocomplete.css +26 -0
- package/dist/styleD/build/typescript/component/TopBar.cjs +5 -1
- package/dist/styleD/build/typescript/component/TopBar.js +5 -1
- package/dist/styleD/build/typescript/component/{tagAutocomplete.js → autocomplete.cjs} +8 -3
- package/dist/styleD/build/typescript/component/{tagAutocomplete.cjs → autocomplete.js} +6 -5
- package/dist/tag-picker.cjs +6 -4
- package/dist/tag-picker.js +3 -2
- package/dist/types/components/tag-picker/Autocomplete.d.ts +117 -0
- package/dist/types/components/tag-picker/TagAutocomplete.d.ts +34 -23
- package/dist/types/components/tag-picker/example-tags.d.ts +2 -2
- package/dist/types/components/tag-picker/styles.d.ts +5 -5
- package/dist/types/components/tag-picker/types.d.ts +4 -5
- package/dist/types/index.d.ts +24 -24
- package/dist/types/styleD/build/typescript/component/TopBar.d.ts +5 -1
- package/dist/types/styleD/build/typescript/component/{tagAutocomplete.d.ts → autocomplete.d.ts} +5 -2
- package/dist/types/tag-picker.d.ts +4 -3
- package/package.json +2 -2
- package/dist/styleD/build/css/component/tagAutocomplete.css +0 -23
package/dist/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
+
export { componentAutocomplete } from './styleD/build/typescript/component/autocomplete.js';
|
|
1
2
|
export { componentByline } from './styleD/build/typescript/component/byline.js';
|
|
2
|
-
export { componentTagAutocomplete } from './styleD/build/typescript/component/tagAutocomplete.js';
|
|
3
3
|
export { componentTagTable } from './styleD/build/typescript/component/tagTable.js';
|
|
4
4
|
export { componentUserMenu } from './styleD/build/typescript/component/userMenu.js';
|
|
5
|
+
export { componentAlertBanner } from './styleD/build/typescript/component/alertBanner.js';
|
|
5
6
|
export { componentAvatar } from './styleD/build/typescript/component/avatar.js';
|
|
6
7
|
export { componentButton } from './styleD/build/typescript/component/button.js';
|
|
7
|
-
export {
|
|
8
|
-
export { componentIcon } from './styleD/build/typescript/component/icon.js';
|
|
8
|
+
export { componentCheckbox } from './styleD/build/typescript/component/checkbox.js';
|
|
9
9
|
export { componentFavicon } from './styleD/build/typescript/component/favicon.js';
|
|
10
|
-
export {
|
|
10
|
+
export { componentForm } from './styleD/build/typescript/component/form.js';
|
|
11
|
+
export { componentIcon } from './styleD/build/typescript/component/icon.js';
|
|
12
|
+
export { componentInlineMessage } from './styleD/build/typescript/component/inlineMessage.js';
|
|
13
|
+
export { componentMenu } from './styleD/build/typescript/component/menu.js';
|
|
11
14
|
export { componentRadioGroup } from './styleD/build/typescript/component/radioGroup.js';
|
|
12
|
-
export {
|
|
15
|
+
export { componentSelect } from './styleD/build/typescript/component/select.js';
|
|
13
16
|
export { componentTextArea } from './styleD/build/typescript/component/textArea.js';
|
|
14
17
|
export { componentTextInput } from './styleD/build/typescript/component/textInput.js';
|
|
15
|
-
export { componentInlineMessage } from './styleD/build/typescript/component/inlineMessage.js';
|
|
16
|
-
export { componentSelect } from './styleD/build/typescript/component/select.js';
|
|
17
|
-
export { componentMenu } from './styleD/build/typescript/component/menu.js';
|
|
18
18
|
export { componentTopBar } from './styleD/build/typescript/component/TopBar.js';
|
|
19
|
-
export {
|
|
19
|
+
export { componentTypography } from './styleD/build/typescript/component/typography.js';
|
|
20
20
|
export { baseColors } from './styleD/build/typescript/base/colors.js';
|
|
21
|
-
export { baseTypography } from './styleD/build/typescript/base/typography.js';
|
|
22
|
-
export { baseSpacing } from './styleD/build/typescript/base/spacing.js';
|
|
23
|
-
export { baseSizing } from './styleD/build/typescript/base/sizing.js';
|
|
24
21
|
export { baseRadius } from './styleD/build/typescript/base/radius.js';
|
|
22
|
+
export { baseSizing } from './styleD/build/typescript/base/sizing.js';
|
|
23
|
+
export { baseSpacing } from './styleD/build/typescript/base/spacing.js';
|
|
24
|
+
export { baseTypography } from './styleD/build/typescript/base/typography.js';
|
|
25
25
|
export { semanticColors } from './styleD/build/typescript/semantic/colors.js';
|
|
26
26
|
export { semanticTypography } from './styleD/build/typescript/semantic/typography.js';
|
|
27
27
|
export { semanticSizing } from './styleD/build/typescript/semantic/sizing.js';
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
--component-top-bar-display: flex;
|
|
8
8
|
--component-top-bar-height: 4rem;
|
|
9
9
|
--component-top-bar-justify-content: flex-start;
|
|
10
|
-
--component-top-bar-border: 0.0625rem solid #cccccc;
|
|
10
|
+
--component-top-bar-border-right: 0.0625rem solid #cccccc;
|
|
11
|
+
--component-top-bar-border-top: 0.0625rem solid #cccccc;
|
|
12
|
+
--component-top-bar-border-bottom: 0.0625rem solid #cccccc;
|
|
13
|
+
--component-top-bar-border-left: 0.0625rem solid #cccccc;
|
|
11
14
|
--component-top-bar-spacer-margin-left: auto;
|
|
15
|
+
--component-top-bar-collapsed-nav-menu-button-color: #000000;
|
|
12
16
|
--component-top-bar-collapsed-nav-menu-button-margin: 0;
|
|
13
17
|
--component-top-bar-collapsed-nav-menu-button-padding: 0;
|
|
14
18
|
--component-top-bar-collapsed-nav-menu-button-background: none;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not edit directly, this file was auto-generated.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
:root {
|
|
6
|
+
--component-autocomplete-input-color: #000000;
|
|
7
|
+
--component-autocomplete-input-background-color: #ffffff;
|
|
8
|
+
--component-autocomplete-input-disabled-background-color: #dcdcdc;
|
|
9
|
+
--component-autocomplete-input-border-width: 1px;
|
|
10
|
+
--component-autocomplete-input-border-style: solid;
|
|
11
|
+
--component-autocomplete-input-border-color: #8d8d8d;
|
|
12
|
+
--component-autocomplete-input-padding: 11px;
|
|
13
|
+
--component-autocomplete-listbox-border-width: 1px;
|
|
14
|
+
--component-autocomplete-listbox-border-style: solid;
|
|
15
|
+
--component-autocomplete-listbox-border-color: #8d8d8d;
|
|
16
|
+
--component-autocomplete-listbox-padding-y: 8px;
|
|
17
|
+
--component-autocomplete-listbox-padding-x: 0;
|
|
18
|
+
--component-autocomplete-listbox-background-color: #ffffff;
|
|
19
|
+
--component-autocomplete-listbox-item-padding-y: 8px;
|
|
20
|
+
--component-autocomplete-listbox-item-padding-x: 12px;
|
|
21
|
+
--component-autocomplete-listbox-item-background-hover-color: #ededed;
|
|
22
|
+
--component-autocomplete-listbox-item-background-focused-color: #ededed;
|
|
23
|
+
--component-autocomplete-listbox-item-color: #000000;
|
|
24
|
+
--component-autocomplete-listbox-item-color-hover: #000000;
|
|
25
|
+
--component-autocomplete-listbox-item-color-focused: #000000;
|
|
26
|
+
}
|
|
@@ -5,12 +5,16 @@ const componentTopBar = {
|
|
|
5
5
|
display: "flex",
|
|
6
6
|
height: "4rem",
|
|
7
7
|
"justify-content": "flex-start",
|
|
8
|
-
border: "0.0625rem solid #cccccc",
|
|
8
|
+
"border-right": "0.0625rem solid #cccccc",
|
|
9
|
+
"border-top": "0.0625rem solid #cccccc",
|
|
10
|
+
"border-bottom": "0.0625rem solid #cccccc",
|
|
11
|
+
"border-left": "0.0625rem solid #cccccc",
|
|
9
12
|
spacer: {
|
|
10
13
|
"margin-left": "auto"
|
|
11
14
|
},
|
|
12
15
|
collapsedNavMenu: {
|
|
13
16
|
button: {
|
|
17
|
+
color: "#000000",
|
|
14
18
|
margin: "0",
|
|
15
19
|
padding: "0",
|
|
16
20
|
background: "none",
|
|
@@ -3,12 +3,16 @@ const componentTopBar = {
|
|
|
3
3
|
display: "flex",
|
|
4
4
|
height: "4rem",
|
|
5
5
|
"justify-content": "flex-start",
|
|
6
|
-
border: "0.0625rem solid #cccccc",
|
|
6
|
+
"border-right": "0.0625rem solid #cccccc",
|
|
7
|
+
"border-top": "0.0625rem solid #cccccc",
|
|
8
|
+
"border-bottom": "0.0625rem solid #cccccc",
|
|
9
|
+
"border-left": "0.0625rem solid #cccccc",
|
|
7
10
|
spacer: {
|
|
8
11
|
"margin-left": "auto"
|
|
9
12
|
},
|
|
10
13
|
collapsedNavMenu: {
|
|
11
14
|
button: {
|
|
15
|
+
color: "#000000",
|
|
12
16
|
margin: "0",
|
|
13
17
|
padding: "0",
|
|
14
18
|
background: "none",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const componentAutocomplete = {
|
|
2
4
|
input: {
|
|
3
5
|
color: "#000000",
|
|
4
6
|
backgroundColor: "#ffffff",
|
|
@@ -19,9 +21,12 @@ const componentTagAutocomplete = {
|
|
|
19
21
|
paddingY: "8px",
|
|
20
22
|
paddingX: "12px",
|
|
21
23
|
backgroundHoverColor: "#ededed",
|
|
22
|
-
backgroundFocusedColor: "#ededed"
|
|
24
|
+
backgroundFocusedColor: "#ededed",
|
|
25
|
+
color: "#000000",
|
|
26
|
+
colorHover: "#000000",
|
|
27
|
+
colorFocused: "#000000"
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
};
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
exports.componentAutocomplete = componentAutocomplete;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const componentTagAutocomplete = {
|
|
1
|
+
const componentAutocomplete = {
|
|
4
2
|
input: {
|
|
5
3
|
color: "#000000",
|
|
6
4
|
backgroundColor: "#ffffff",
|
|
@@ -21,9 +19,12 @@ const componentTagAutocomplete = {
|
|
|
21
19
|
paddingY: "8px",
|
|
22
20
|
paddingX: "12px",
|
|
23
21
|
backgroundHoverColor: "#ededed",
|
|
24
|
-
backgroundFocusedColor: "#ededed"
|
|
22
|
+
backgroundFocusedColor: "#ededed",
|
|
23
|
+
color: "#000000",
|
|
24
|
+
colorHover: "#000000",
|
|
25
|
+
colorFocused: "#000000"
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
export { componentAutocomplete };
|
package/dist/tag-picker.cjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var Autocomplete = require('./components/tag-picker/Autocomplete.cjs');
|
|
4
4
|
var TagAutocomplete = require('./components/tag-picker/TagAutocomplete.cjs');
|
|
5
|
+
var TagTable = require('./components/tag-picker/TagTable.cjs');
|
|
6
|
+
var autocomplete = require('./styleD/build/typescript/component/autocomplete.cjs');
|
|
5
7
|
var tagTable = require('./styleD/build/typescript/component/tagTable.cjs');
|
|
6
|
-
var tagAutocomplete = require('./styleD/build/typescript/component/tagAutocomplete.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
exports.
|
|
11
|
+
exports.Autocomplete = Autocomplete.Autocomplete;
|
|
11
12
|
exports.TagAutocomplete = TagAutocomplete.TagAutocomplete;
|
|
13
|
+
exports.TagTable = TagTable.TagTable;
|
|
14
|
+
exports.componentAutocomplete = autocomplete.componentAutocomplete;
|
|
12
15
|
exports.componentTagTable = tagTable.componentTagTable;
|
|
13
|
-
exports.componentTagAutocomplete = tagAutocomplete.componentTagAutocomplete;
|
package/dist/tag-picker.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Autocomplete } from './components/tag-picker/Autocomplete.js';
|
|
2
2
|
export { TagAutocomplete } from './components/tag-picker/TagAutocomplete.js';
|
|
3
|
+
export { TagTable } from './components/tag-picker/TagTable.js';
|
|
4
|
+
export { componentAutocomplete } from './styleD/build/typescript/component/autocomplete.js';
|
|
3
5
|
export { componentTagTable } from './styleD/build/typescript/component/tagTable.js';
|
|
4
|
-
export { componentTagAutocomplete } from './styleD/build/typescript/component/tagAutocomplete.js';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { SerializedStyles } from '@emotion/react';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
import type { ComponentAutocomplete } from '../../styleD/build/typescript/component/autocomplete';
|
|
4
|
+
import type { DeepPartial } from '../../util/types';
|
|
5
|
+
export type AutocompleteOption = {
|
|
6
|
+
id: number | string;
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
export interface AutocompleteProps<T extends AutocompleteOption = AutocompleteOption> {
|
|
10
|
+
/** `addSelection` - Function called when an option is picked from the dropdown */
|
|
11
|
+
addSelection: (selection: T) => void;
|
|
12
|
+
/** `loading` - Whether the component is loading options for the dropdown */
|
|
13
|
+
loading: boolean;
|
|
14
|
+
/** `onTextInputChange` - Function called when the combobox input changes */
|
|
15
|
+
onTextInputChange: (inputText: string) => void;
|
|
16
|
+
/** `options` - The list of options shown in the dropdown */
|
|
17
|
+
options: T[];
|
|
18
|
+
/** `label` - An accessible label for the combobox input */
|
|
19
|
+
label: string;
|
|
20
|
+
/** `placeholder` - A placeholder string for the combobox input */
|
|
21
|
+
placeholder: string;
|
|
22
|
+
/** `disabled` - Whether the combobox input is disabled */
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
/** `value` - The value of the combobox input */
|
|
25
|
+
value: string;
|
|
26
|
+
'data-testid'?: string;
|
|
27
|
+
/** `loadingIcon` - Icon used to show loading happening in the dropdown */
|
|
28
|
+
loadingIcon?: ReactElement;
|
|
29
|
+
/** `theme` - Used to customise the look and feel of the Autocomplete component */
|
|
30
|
+
theme?: DeepPartial<ComponentAutocomplete>;
|
|
31
|
+
/** `cssOverrides` - Escape hatch for styling that doesn't fall into the theme */
|
|
32
|
+
cssOverrides?: SerializedStyles;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* ## Autocomplete
|
|
36
|
+
*
|
|
37
|
+
* *Status: Testing*
|
|
38
|
+
*
|
|
39
|
+
* Part of the overall TagPicker component, the Autocomplete provides an accessible
|
|
40
|
+
* 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.
|
|
41
|
+
*
|
|
42
|
+
* **Peer dependencies:**
|
|
43
|
+
* - `react-aria-components`
|
|
44
|
+
*
|
|
45
|
+
* See the `peerDependencies` section of the `package.json` for compatible versions to install.
|
|
46
|
+
*
|
|
47
|
+
* ## Usage
|
|
48
|
+
*
|
|
49
|
+
* *Example with synchronous data:*
|
|
50
|
+
*
|
|
51
|
+
* ```tsx
|
|
52
|
+
* import { useState } from 'react';
|
|
53
|
+
* import { Autocomplete } from '@guardian/stand';
|
|
54
|
+
*
|
|
55
|
+
* const exampleFruits = [
|
|
56
|
+
* { id: 1, name: 'Apple' },
|
|
57
|
+
* { id: 2, name: 'Banana' },
|
|
58
|
+
* { id: 3, name: 'Cherry' },
|
|
59
|
+
* { id: 4, name: 'Date' },
|
|
60
|
+
* { id: 5, name: 'Elderberry' },
|
|
61
|
+
* ];
|
|
62
|
+
*
|
|
63
|
+
* const FruitPicker = () => {
|
|
64
|
+
* const [selectedFruits, setSelectedFruits] = useState<{ id: number; name: string }[]>([]);
|
|
65
|
+
* const [options, setOptions] = useState<{ id: number; name: string }[]>([]);
|
|
66
|
+
* const [value, setValue] = useState('');
|
|
67
|
+
*
|
|
68
|
+
* const onTextInputChange = (inputText: string) => {
|
|
69
|
+
* setValue(inputText);
|
|
70
|
+
* if (inputText === '') {
|
|
71
|
+
* setOptions([]);
|
|
72
|
+
* return;
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* if (inputText === '*') {
|
|
76
|
+
* setOptions(exampleFruits);
|
|
77
|
+
* return;
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* setOptions(
|
|
81
|
+
* exampleFruits.filter((f) =>
|
|
82
|
+
* f.name.toLowerCase().includes(inputText.toLowerCase()),
|
|
83
|
+
* ),
|
|
84
|
+
* );
|
|
85
|
+
* };
|
|
86
|
+
*
|
|
87
|
+
* return (
|
|
88
|
+
* <>
|
|
89
|
+
* <Autocomplete
|
|
90
|
+
* onTextInputChange={onTextInputChange}
|
|
91
|
+
* options={options}
|
|
92
|
+
* label="Fruits"
|
|
93
|
+
* addSelection={(fruit) => setSelectedFruits((prev) => [...prev, fruit])}
|
|
94
|
+
* loading={false}
|
|
95
|
+
* placeholder="Search fruits"
|
|
96
|
+
* disabled={false}
|
|
97
|
+
* value={value}
|
|
98
|
+
* />
|
|
99
|
+
* <ul>
|
|
100
|
+
* {selectedFruits.map((fruit) => (
|
|
101
|
+
* <li key={fruit.id}>{fruit.name}</li>
|
|
102
|
+
* ))}
|
|
103
|
+
* </ul>
|
|
104
|
+
* </>
|
|
105
|
+
* );
|
|
106
|
+
* };
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* #### Props
|
|
110
|
+
*
|
|
111
|
+
* See {@link AutocompleteProps} for a full list of props and descriptions.
|
|
112
|
+
*
|
|
113
|
+
* #### Example
|
|
114
|
+
*
|
|
115
|
+
* This is currently still in testing phase, so a production implementation is not yet available.
|
|
116
|
+
*/
|
|
117
|
+
export declare function Autocomplete<T extends AutocompleteOption = AutocompleteOption>({ addSelection, loading, onTextInputChange, options, label, placeholder, disabled, value, 'data-testid': dataTestId, loadingIcon, theme, cssOverrides, }: AutocompleteProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SerializedStyles } from '@emotion/react';
|
|
2
2
|
import type { ReactElement } from 'react';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentAutocomplete } from '../../styleD/build/typescript/component/autocomplete';
|
|
4
4
|
import type { DeepPartial } from '../../util/types';
|
|
5
5
|
import type { Tag } from './types';
|
|
6
6
|
interface TagAutocompleteProps<T extends Tag = Tag> {
|
|
@@ -8,8 +8,8 @@ interface TagAutocompleteProps<T extends Tag = Tag> {
|
|
|
8
8
|
addTag: (tag: T) => void;
|
|
9
9
|
/** `loading` - Whether the component is loading options for the dropdown */
|
|
10
10
|
loading: boolean;
|
|
11
|
-
/** `
|
|
12
|
-
|
|
11
|
+
/** `onTextInputChange` - Function called when the combobox input changes */
|
|
12
|
+
onTextInputChange: (inputText: string) => void;
|
|
13
13
|
/** `options` - The list of options shown in the dropdown */
|
|
14
14
|
options: T[];
|
|
15
15
|
/** `label` - An accessible label for the combobox input */
|
|
@@ -24,7 +24,7 @@ interface TagAutocompleteProps<T extends Tag = Tag> {
|
|
|
24
24
|
/** `loadingIcon` - Icon used to show loading happening in the dropdown */
|
|
25
25
|
loadingIcon?: ReactElement;
|
|
26
26
|
/** `theme` - Used to customise the look and feel of the TagAutocomplete component */
|
|
27
|
-
theme?: DeepPartial<
|
|
27
|
+
theme?: DeepPartial<ComponentAutocomplete>;
|
|
28
28
|
/** `cssOverrides` - Escape hatch for styling that doesn't fall into the theme */
|
|
29
29
|
cssOverrides?: SerializedStyles;
|
|
30
30
|
}
|
|
@@ -48,14 +48,27 @@ interface TagAutocompleteProps<T extends Tag = Tag> {
|
|
|
48
48
|
* ```tsx
|
|
49
49
|
* import { TagAutocomplete, TagTable } from '@guardian/stand';
|
|
50
50
|
*
|
|
51
|
+
* // Define a type for your tags — it must include `id` and `name`,
|
|
52
|
+
* // plus any extra fields TagTable needs (type, sectionName)
|
|
53
|
+
* type MyTag = {
|
|
54
|
+
* id: number;
|
|
55
|
+
* name: string;
|
|
56
|
+
* type: string;
|
|
57
|
+
* sectionName: string;
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* const allTags: MyTag[] = [
|
|
61
|
+
* { id: 1, name: 'UK news', type: 'Keyword', sectionName: 'World' },
|
|
62
|
+
* { id: 2, name: 'US politics', type: 'Keyword', sectionName: 'Politics' },
|
|
63
|
+
* // ...
|
|
64
|
+
* ];
|
|
65
|
+
*
|
|
51
66
|
* const Component = () => {
|
|
52
|
-
* const [selectedTags, setSelectedTags] = useState<
|
|
53
|
-
*
|
|
54
|
-
* >([]);
|
|
55
|
-
|
|
56
|
-
* const [options, setOptions] = useState<TagManagerObjectData[]>([]);
|
|
67
|
+
* const [selectedTags, setSelectedTags] = useState<MyTag[]>([]);
|
|
68
|
+
* const [options, setOptions] = useState<MyTag[]>([]);
|
|
57
69
|
* const [value, setValue] = useState('');
|
|
58
|
-
*
|
|
70
|
+
*
|
|
71
|
+
* const onTextInputChange = (inputText: string) => {
|
|
59
72
|
* setValue(inputText);
|
|
60
73
|
* if (inputText === '') {
|
|
61
74
|
* setOptions([]);
|
|
@@ -63,32 +76,30 @@ interface TagAutocompleteProps<T extends Tag = Tag> {
|
|
|
63
76
|
* }
|
|
64
77
|
*
|
|
65
78
|
* if (inputText === '*') {
|
|
66
|
-
* setOptions(
|
|
79
|
+
* setOptions(allTags);
|
|
67
80
|
* return;
|
|
68
81
|
* }
|
|
69
82
|
*
|
|
70
|
-
* // Simple filtering against
|
|
71
|
-
* const filteredItems =
|
|
72
|
-
* t.
|
|
83
|
+
* // Simple filtering against allTags
|
|
84
|
+
* const filteredItems = allTags.filter((t) =>
|
|
85
|
+
* t.name.toLowerCase().includes(inputText.toLowerCase()),
|
|
73
86
|
* );
|
|
74
|
-
*
|
|
87
|
+
* setOptions(filteredItems);
|
|
75
88
|
* };
|
|
76
|
-
|
|
89
|
+
*
|
|
77
90
|
* return (
|
|
78
91
|
* <>
|
|
79
92
|
* <div
|
|
80
93
|
* css={css`
|
|
81
|
-
*
|
|
94
|
+
* display: flex;
|
|
82
95
|
* `}
|
|
83
96
|
* >
|
|
84
97
|
* <TagAutocomplete
|
|
85
|
-
*
|
|
98
|
+
* onTextInputChange={onTextInputChange}
|
|
86
99
|
* options={options}
|
|
87
100
|
* label="Tags"
|
|
88
101
|
* addTag={(tag) =>
|
|
89
|
-
*
|
|
90
|
-
* return [...tags, tag];
|
|
91
|
-
* })
|
|
102
|
+
* setSelectedTags((tags) => [...tags, tag])
|
|
92
103
|
* }
|
|
93
104
|
* loading={false}
|
|
94
105
|
* placeholder={''}
|
|
@@ -96,7 +107,7 @@ interface TagAutocompleteProps<T extends Tag = Tag> {
|
|
|
96
107
|
* value={value}
|
|
97
108
|
* />
|
|
98
109
|
* <select>
|
|
99
|
-
*
|
|
110
|
+
* <option>All tags</option>
|
|
100
111
|
* </select>
|
|
101
112
|
* </div>
|
|
102
113
|
* <TagTable rows={selectedTags} filterRows={() => true} />
|
|
@@ -113,5 +124,5 @@ interface TagAutocompleteProps<T extends Tag = Tag> {
|
|
|
113
124
|
*
|
|
114
125
|
* This is currently still in testing phase, so a production implementation is not yet available.
|
|
115
126
|
*/
|
|
116
|
-
export declare function TagAutocomplete<T extends Tag = Tag>({ addTag, loading,
|
|
127
|
+
export declare function TagAutocomplete<T extends Tag = Tag>({ addTag, loading, onTextInputChange, options, label, placeholder, disabled, value, 'data-testid': dataTestId, loadingIcon, theme, cssOverrides, }: TagAutocompleteProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
117
128
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const exampleTags:
|
|
1
|
+
import type { TagManagerObject } from './types';
|
|
2
|
+
export declare const exampleTags: TagManagerObject[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { SerializedStyles } from '@emotion/react';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ComponentAutocomplete } from '../../styleD/build/typescript/component/autocomplete';
|
|
3
3
|
import { type ComponentTagTable } from '../../styleD/build/typescript/component/tagTable';
|
|
4
4
|
import type { DeepPartial } from '../../util/types';
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const listboxStyles: (partialTheme?: DeepPartial<
|
|
7
|
-
export declare const listboxItemStyles: (partialTheme?: DeepPartial<
|
|
8
|
-
export declare const listboxInfoStyles: (partialTheme?: DeepPartial<
|
|
5
|
+
export declare const autocompleteInputStyles: (partialTheme?: DeepPartial<ComponentAutocomplete>) => SerializedStyles;
|
|
6
|
+
export declare const listboxStyles: (partialTheme?: DeepPartial<ComponentAutocomplete>) => SerializedStyles;
|
|
7
|
+
export declare const listboxItemStyles: (partialTheme?: DeepPartial<ComponentAutocomplete>) => SerializedStyles;
|
|
8
|
+
export declare const listboxInfoStyles: (partialTheme?: DeepPartial<ComponentAutocomplete>) => SerializedStyles;
|
|
9
9
|
export declare const tagTableHeadingStyles: (partialTheme?: DeepPartial<ComponentTagTable>) => SerializedStyles;
|
|
10
10
|
export declare const tagTableCellStyles: (partialTheme?: DeepPartial<ComponentTagTable>) => SerializedStyles;
|
|
11
11
|
export declare const tagTableRowStyles: (canDrag: boolean, partialTheme?: DeepPartial<ComponentTagTable>) => SerializedStyles;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export type Tag = {
|
|
2
2
|
id: number;
|
|
3
|
-
|
|
3
|
+
name: string;
|
|
4
4
|
};
|
|
5
5
|
export type TagRow = Tag & {
|
|
6
6
|
type: string;
|
|
7
|
-
|
|
8
|
-
name: string;
|
|
9
|
-
};
|
|
7
|
+
sectionName: string;
|
|
10
8
|
};
|
|
11
|
-
export type
|
|
9
|
+
export type TagManagerObject = {
|
|
12
10
|
id: number;
|
|
13
11
|
type: string;
|
|
14
12
|
internalName: string;
|
|
@@ -63,3 +61,4 @@ export type TagManagerObjectData = {
|
|
|
63
61
|
adBlockingLevel?: 'NONE' | 'SUGGEST' | 'FORCE' | undefined;
|
|
64
62
|
contributionBlockingLevel?: 'NONE' | 'SUGGEST' | 'FORCE' | undefined;
|
|
65
63
|
};
|
|
64
|
+
export type TagManagerObjectData = TagRow & TagManagerObject;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* editorial components tokens exports
|
|
7
7
|
*/
|
|
8
|
+
export { componentAutocomplete } from './styleD/build/typescript/component/autocomplete';
|
|
9
|
+
export type { ComponentAutocomplete } from './styleD/build/typescript/component/autocomplete';
|
|
8
10
|
export { componentByline } from './styleD/build/typescript/component/byline';
|
|
9
11
|
export type { ComponentByline } from './styleD/build/typescript/component/byline';
|
|
10
|
-
export { componentTagAutocomplete } from './styleD/build/typescript/component/tagAutocomplete';
|
|
11
|
-
export type { ComponentTagAutocomplete } from './styleD/build/typescript/component/tagAutocomplete';
|
|
12
12
|
export { componentTagTable } from './styleD/build/typescript/component/tagTable';
|
|
13
13
|
export type { ComponentTagTable } from './styleD/build/typescript/component/tagTable';
|
|
14
14
|
export { componentUserMenu } from './styleD/build/typescript/component/userMenu';
|
|
@@ -16,49 +16,49 @@ export type { ComponentUserMenu } from './styleD/build/typescript/component/user
|
|
|
16
16
|
/**
|
|
17
17
|
* design system components tokens exports
|
|
18
18
|
*/
|
|
19
|
+
export { componentAlertBanner } from './styleD/build/typescript/component/alertBanner';
|
|
20
|
+
export type { ComponentAlertBanner } from './styleD/build/typescript/component/alertBanner';
|
|
19
21
|
export { componentAvatar } from './styleD/build/typescript/component/avatar';
|
|
20
22
|
export type { ComponentAvatar } from './styleD/build/typescript/component/avatar';
|
|
21
23
|
export { componentButton } from './styleD/build/typescript/component/button';
|
|
22
24
|
export type { ComponentButton } from './styleD/build/typescript/component/button';
|
|
23
|
-
export {
|
|
24
|
-
export type {
|
|
25
|
-
export { componentIcon } from './styleD/build/typescript/component/icon';
|
|
26
|
-
export type { ComponentIcon } from './styleD/build/typescript/component/icon';
|
|
25
|
+
export { componentCheckbox } from './styleD/build/typescript/component/checkbox';
|
|
26
|
+
export type { ComponentCheckbox } from './styleD/build/typescript/component/checkbox';
|
|
27
27
|
export { componentFavicon } from './styleD/build/typescript/component/favicon';
|
|
28
28
|
export type { ComponentFavicon } from './styleD/build/typescript/component/favicon';
|
|
29
|
-
export {
|
|
30
|
-
export type {
|
|
29
|
+
export { componentForm } from './styleD/build/typescript/component/form';
|
|
30
|
+
export type { ComponentForm } from './styleD/build/typescript/component/form';
|
|
31
|
+
export { componentIcon } from './styleD/build/typescript/component/icon';
|
|
32
|
+
export type { ComponentIcon } from './styleD/build/typescript/component/icon';
|
|
33
|
+
export { componentInlineMessage } from './styleD/build/typescript/component/inlineMessage';
|
|
34
|
+
export type { ComponentInlineMessage } from './styleD/build/typescript/component/inlineMessage';
|
|
35
|
+
export { componentMenu } from './styleD/build/typescript/component/menu';
|
|
36
|
+
export type { ComponentMenu } from './styleD/build/typescript/component/menu';
|
|
31
37
|
export { componentRadioGroup } from './styleD/build/typescript/component/radioGroup';
|
|
32
38
|
export type { ComponentRadioGroup } from './styleD/build/typescript/component/radioGroup';
|
|
33
|
-
export {
|
|
34
|
-
export type {
|
|
39
|
+
export { componentSelect } from './styleD/build/typescript/component/select';
|
|
40
|
+
export type { ComponentSelect } from './styleD/build/typescript/component/select';
|
|
35
41
|
export { componentTextArea } from './styleD/build/typescript/component/textArea';
|
|
36
42
|
export type { ComponentTextArea } from './styleD/build/typescript/component/textArea';
|
|
37
43
|
export { componentTextInput } from './styleD/build/typescript/component/textInput';
|
|
38
44
|
export type { ComponentTextInput } from './styleD/build/typescript/component/textInput';
|
|
39
|
-
export { componentInlineMessage } from './styleD/build/typescript/component/inlineMessage';
|
|
40
|
-
export type { ComponentInlineMessage } from './styleD/build/typescript/component/inlineMessage';
|
|
41
|
-
export { componentSelect } from './styleD/build/typescript/component/select';
|
|
42
|
-
export type { ComponentSelect } from './styleD/build/typescript/component/select';
|
|
43
|
-
export { componentMenu } from './styleD/build/typescript/component/menu';
|
|
44
|
-
export type { ComponentMenu } from './styleD/build/typescript/component/menu';
|
|
45
45
|
export { componentTopBar } from './styleD/build/typescript/component/TopBar';
|
|
46
46
|
export type { ComponentTopBar } from './styleD/build/typescript/component/TopBar';
|
|
47
|
-
export {
|
|
48
|
-
export type {
|
|
47
|
+
export { componentTypography } from './styleD/build/typescript/component/typography';
|
|
48
|
+
export type { ComponentTypography } from './styleD/build/typescript/component/typography';
|
|
49
49
|
/**
|
|
50
50
|
* style dictionary exports - base
|
|
51
51
|
*/
|
|
52
52
|
export { baseColors } from './styleD/build/typescript/base/colors';
|
|
53
53
|
export type { BaseColors } from './styleD/build/typescript/base/colors';
|
|
54
|
-
export { baseTypography } from './styleD/build/typescript/base/typography';
|
|
55
|
-
export type { BaseTypography } from './styleD/build/typescript/base/typography';
|
|
56
|
-
export { baseSpacing } from './styleD/build/typescript/base/spacing';
|
|
57
|
-
export type { BaseSpacing } from './styleD/build/typescript/base/spacing';
|
|
58
|
-
export { baseSizing } from './styleD/build/typescript/base/sizing';
|
|
59
|
-
export type { BaseSizing } from './styleD/build/typescript/base/sizing';
|
|
60
54
|
export { baseRadius } from './styleD/build/typescript/base/radius';
|
|
61
55
|
export type { BaseRadius } from './styleD/build/typescript/base/radius';
|
|
56
|
+
export { baseSizing } from './styleD/build/typescript/base/sizing';
|
|
57
|
+
export type { BaseSizing } from './styleD/build/typescript/base/sizing';
|
|
58
|
+
export { baseSpacing } from './styleD/build/typescript/base/spacing';
|
|
59
|
+
export type { BaseSpacing } from './styleD/build/typescript/base/spacing';
|
|
60
|
+
export { baseTypography } from './styleD/build/typescript/base/typography';
|
|
61
|
+
export type { BaseTypography } from './styleD/build/typescript/base/typography';
|
|
62
62
|
/**
|
|
63
63
|
* style dictionary exports - semantic
|
|
64
64
|
*/
|
|
@@ -6,12 +6,16 @@ export declare const componentTopBar: {
|
|
|
6
6
|
display: string;
|
|
7
7
|
height: string;
|
|
8
8
|
'justify-content': string;
|
|
9
|
-
border: string;
|
|
9
|
+
'border-right': string;
|
|
10
|
+
'border-top': string;
|
|
11
|
+
'border-bottom': string;
|
|
12
|
+
'border-left': string;
|
|
10
13
|
spacer: {
|
|
11
14
|
'margin-left': string;
|
|
12
15
|
};
|
|
13
16
|
collapsedNavMenu: {
|
|
14
17
|
button: {
|
|
18
|
+
color: string;
|
|
15
19
|
margin: string;
|
|
16
20
|
padding: string;
|
|
17
21
|
background: string;
|
package/dist/types/styleD/build/typescript/component/{tagAutocomplete.d.ts → autocomplete.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Do not edit directly, this file was auto-generated.
|
|
3
3
|
*/
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const componentAutocomplete: {
|
|
5
5
|
input: {
|
|
6
6
|
color: string;
|
|
7
7
|
backgroundColor: string;
|
|
@@ -23,7 +23,10 @@ export declare const componentTagAutocomplete: {
|
|
|
23
23
|
paddingX: string;
|
|
24
24
|
backgroundHoverColor: string;
|
|
25
25
|
backgroundFocusedColor: string;
|
|
26
|
+
color: string;
|
|
27
|
+
colorHover: string;
|
|
28
|
+
colorFocused: string;
|
|
26
29
|
};
|
|
27
30
|
};
|
|
28
31
|
};
|
|
29
|
-
export type
|
|
32
|
+
export type ComponentAutocomplete = typeof componentAutocomplete;
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
* If you only need the built CSS (./component/tagTable.css, ./component/tagAutocomplete.css),
|
|
14
14
|
* you don't need to install these.
|
|
15
15
|
*/
|
|
16
|
-
export {
|
|
16
|
+
export { Autocomplete } from './components/tag-picker/Autocomplete';
|
|
17
17
|
export { TagAutocomplete } from './components/tag-picker/TagAutocomplete';
|
|
18
|
+
export { TagTable } from './components/tag-picker/TagTable';
|
|
19
|
+
export { componentAutocomplete } from './styleD/build/typescript/component/autocomplete';
|
|
20
|
+
export type { ComponentAutocomplete } from './styleD/build/typescript/component/autocomplete';
|
|
18
21
|
export { componentTagTable } from './styleD/build/typescript/component/tagTable';
|
|
19
22
|
export type { ComponentTagTable } from './styleD/build/typescript/component/tagTable';
|
|
20
|
-
export { componentTagAutocomplete } from './styleD/build/typescript/component/tagAutocomplete';
|
|
21
|
-
export type { ComponentTagAutocomplete } from './styleD/build/typescript/component/tagAutocomplete';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guardian/stand",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"//exports": "Each component has its own entry point for optimal tree-shaking. Main entry point only includes design tokens and utilities. New components/foundations should follow the same pattern.",
|
|
6
6
|
"exports": {
|
|
@@ -368,6 +368,6 @@
|
|
|
368
368
|
"test": "jest",
|
|
369
369
|
"test:setup-e2e": "playwright install --with-deps",
|
|
370
370
|
"test:e2e": "playwright test -c playwright-ct.config.ts",
|
|
371
|
-
"test:react-matrix": "./scripts/test-
|
|
371
|
+
"test:react-matrix": "./scripts/test-deps-matrix.sh"
|
|
372
372
|
}
|
|
373
373
|
}
|