@guardian/stand 0.0.4 → 0.0.6

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 (83) hide show
  1. package/README.md +394 -7
  2. package/dist/{byline → components/byline}/Byline.cjs +5 -5
  3. package/dist/{byline → components/byline}/Byline.js +5 -5
  4. package/dist/components/byline/styles.cjs +266 -0
  5. package/dist/components/byline/styles.js +256 -0
  6. package/dist/components/tag-picker/TagAutocomplete.cjs +107 -0
  7. package/dist/components/tag-picker/TagAutocomplete.js +26 -0
  8. package/dist/components/tag-picker/TagTable.cjs +203 -0
  9. package/dist/components/tag-picker/TagTable.js +91 -0
  10. package/dist/components/tag-picker/styles.cjs +198 -0
  11. package/dist/components/tag-picker/styles.js +185 -0
  12. package/dist/components/util.cjs +19 -0
  13. package/dist/components/util.js +17 -0
  14. package/dist/index.cjs +15 -1
  15. package/dist/index.js +8 -1
  16. package/dist/styleD/build/css/css/base/colors.css +122 -0
  17. package/dist/styleD/build/css/css/base/typography.css +43 -0
  18. package/dist/styleD/build/css/css/component/byline.css +36 -0
  19. package/dist/styleD/build/css/css/component/tagAutocomplete.css +23 -0
  20. package/dist/styleD/build/css/css/component/tagTable.css +39 -0
  21. package/dist/styleD/build/css/css/semantic/colors.css +27 -0
  22. package/dist/styleD/build/css/css/semantic/typography.css +138 -0
  23. package/dist/styleD/build/typescript/base/colors.cjs +144 -0
  24. package/dist/styleD/build/typescript/base/colors.js +142 -0
  25. package/dist/styleD/build/typescript/base/typography.cjs +65 -0
  26. package/dist/styleD/build/typescript/base/typography.js +63 -0
  27. package/dist/styleD/build/typescript/component/byline.cjs +42 -0
  28. package/dist/styleD/build/typescript/component/byline.js +40 -0
  29. package/dist/styleD/build/typescript/component/tagAutocomplete.cjs +29 -0
  30. package/dist/styleD/build/typescript/component/tagAutocomplete.js +27 -0
  31. package/dist/styleD/build/typescript/component/tagTable.cjs +53 -0
  32. package/dist/styleD/build/typescript/component/tagTable.js +51 -0
  33. package/dist/styleD/build/typescript/semantic/colors.cjs +37 -0
  34. package/dist/styleD/build/typescript/semantic/colors.js +35 -0
  35. package/dist/styleD/build/typescript/semantic/typography.cjs +462 -0
  36. package/dist/styleD/build/typescript/semantic/typography.js +460 -0
  37. package/dist/styleD/utils/semantic/typography.cjs +17 -0
  38. package/dist/styleD/utils/semantic/typography.js +15 -0
  39. package/dist/types/components/byline/Byline.d.ts +83 -0
  40. package/dist/types/components/byline/styles.d.ts +13 -0
  41. package/dist/types/components/byline/theme.d.ts +3 -0
  42. package/dist/types/components/tag-picker/TagAutocomplete.d.ts +117 -0
  43. package/dist/types/components/tag-picker/TagTable.d.ts +126 -0
  44. package/dist/types/components/tag-picker/example-tags.d.ts +2 -0
  45. package/dist/types/components/tag-picker/styles.d.ts +16 -0
  46. package/dist/types/components/tag-picker/types.d.ts +65 -0
  47. package/dist/types/{byline → components}/util.d.ts +1 -0
  48. package/dist/types/index.d.ts +26 -2
  49. package/dist/types/styleD/build/typescript/base/colors.d.ts +144 -0
  50. package/dist/types/styleD/build/typescript/base/typography.d.ts +65 -0
  51. package/dist/types/styleD/build/typescript/component/byline.d.ts +42 -0
  52. package/dist/types/styleD/build/typescript/component/tagAutocomplete.d.ts +29 -0
  53. package/dist/types/styleD/build/typescript/component/tagTable.d.ts +53 -0
  54. package/dist/types/styleD/build/typescript/semantic/colors.d.ts +37 -0
  55. package/dist/types/styleD/build/typescript/semantic/typography.d.ts +462 -0
  56. package/dist/types/styleD/stories/base/Typography.d.ts +1 -0
  57. package/dist/types/styleD/stories/base/storybookColorPalette.d.ts +19 -0
  58. package/dist/types/styleD/stories/semantic/TypographyPresets.d.ts +1 -0
  59. package/dist/types/styleD/utils/semantic/typography.d.ts +15 -0
  60. package/dist/types/styleD/utils/semantic/typography.test.d.ts +1 -0
  61. package/package.json +67 -22
  62. package/dist/byline/styles.cjs +0 -244
  63. package/dist/byline/styles.js +0 -234
  64. package/dist/types/byline/Byline.d.ts +0 -17
  65. package/dist/types/byline/styles.d.ts +0 -11
  66. package/dist/types/byline/theme.d.ts +0 -44
  67. /package/dist/{byline → components/byline}/Preview.cjs +0 -0
  68. /package/dist/{byline → components/byline}/Preview.js +0 -0
  69. /package/dist/{byline → components/byline}/lib.cjs +0 -0
  70. /package/dist/{byline → components/byline}/lib.js +0 -0
  71. /package/dist/{byline → components/byline}/placeholder.cjs +0 -0
  72. /package/dist/{byline → components/byline}/placeholder.js +0 -0
  73. /package/dist/{byline → components/byline}/plugins.cjs +0 -0
  74. /package/dist/{byline → components/byline}/plugins.js +0 -0
  75. /package/dist/{byline → components/byline}/schema.cjs +0 -0
  76. /package/dist/{byline → components/byline}/schema.js +0 -0
  77. /package/dist/types/{byline → components/byline}/Preview.d.ts +0 -0
  78. /package/dist/types/{byline → components/byline}/contributors-fixture.d.ts +0 -0
  79. /package/dist/types/{byline → components/byline}/lib.d.ts +0 -0
  80. /package/dist/types/{byline → components/byline}/lib.test.d.ts +0 -0
  81. /package/dist/types/{byline → components/byline}/placeholder.d.ts +0 -0
  82. /package/dist/types/{byline → components/byline}/plugins.d.ts +0 -0
  83. /package/dist/types/{byline → components/byline}/schema.d.ts +0 -0
@@ -0,0 +1,266 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var byline = require('../../styleD/build/typescript/component/byline.cjs');
5
+ var util = require('../util.cjs');
6
+
7
+ const bylineContainerStyles = react.css`
8
+ position: relative;
9
+ width: 100%;
10
+ `;
11
+ const bylineEditorStyles = (partialTheme = {}) => {
12
+ const theme = util.mergeDeep(byline.componentByline, partialTheme);
13
+ return react.css`
14
+ border-color: ${theme.borderColor};
15
+ border-style: ${theme.borderStyle};
16
+ border-width: ${theme.borderWidth};
17
+ background-color: ${theme.backgroundColor};
18
+ color: ${theme.color};
19
+
20
+ /* ProseMirror styles from prosemirror-view/styles/prosemirror.css */
21
+ .ProseMirror {
22
+ padding: 4px 4px;
23
+ word-wrap: break-word;
24
+ white-space: pre-wrap;
25
+ white-space: break-spaces;
26
+ -webkit-font-variant-ligatures: none;
27
+ font-variant-ligatures: none;
28
+ font-feature-settings: 'liga' 0; /* the above doesn't seem to work in Edge */
29
+ line-height: ${theme.lineHeight};
30
+ }
31
+
32
+ .ProseMirror[contenteditable='false'] {
33
+ background: ${theme.readonlyBackgroundColor};
34
+ cursor: 'not-allowed';
35
+ }
36
+
37
+ .ProseMirror pre {
38
+ white-space: pre-wrap;
39
+ }
40
+
41
+ .ProseMirror li {
42
+ position: relative;
43
+ }
44
+
45
+ .ProseMirror-hideselection *::selection {
46
+ background: transparent;
47
+ }
48
+ .ProseMirror-hideselection *::-moz-selection {
49
+ background: transparent;
50
+ }
51
+ .ProseMirror-hideselection {
52
+ caret-color: transparent;
53
+ }
54
+
55
+ /* See https://github.com/ProseMirror/prosemirror/issues/1421#issuecomment-1759320191 */
56
+ .ProseMirror [draggable][contenteditable='false'] {
57
+ user-select: text;
58
+ }
59
+
60
+ .ProseMirror-selectednode {
61
+ outline: 1px solid ${theme.chip.selectedBorderColor};
62
+ }
63
+
64
+ /* Make sure li selections wrap around markers */
65
+
66
+ li.ProseMirror-selectednode {
67
+ outline: none;
68
+ }
69
+
70
+ li.ProseMirror-selectednode:after {
71
+ content: '';
72
+ position: absolute;
73
+ left: -32px;
74
+ right: -2px;
75
+ top: -2px;
76
+ bottom: -2px;
77
+ border: 1px solid ${theme.chip.selectedBorderColor};
78
+ pointer-events: none;
79
+ }
80
+
81
+ /* Protect against generic img rules */
82
+
83
+ img.ProseMirror-separator {
84
+ display: inline !important;
85
+ border: none !important;
86
+ margin: 0 !important;
87
+ }
88
+
89
+ .ProseMirror:focus {
90
+ outline: none;
91
+ }
92
+
93
+ /* Invisible styles from @guardian/prosemirror-invisibles/dist/style.css */
94
+
95
+ .invisible {
96
+ /* Chrome in particular dislikes doing the right thing
97
+ * with carets and inline elements when contenteditable
98
+ * is 'false'. See e.g. https://github.com/ProseMirror/prosemirror/issues/1061
99
+ */
100
+ display: inline;
101
+ position: relative;
102
+ pointer-events: none;
103
+ }
104
+
105
+ .invisible:before {
106
+ position: relative;
107
+ caret-color: inherit;
108
+ color: ${theme.invisiblesColor};
109
+ display: inline-block;
110
+ font-weight: 400;
111
+ font-style: normal;
112
+ line-height: initial;
113
+ width: 0;
114
+ top: 0;
115
+ left: 0;
116
+ z-index: 1;
117
+ }
118
+
119
+ .invisible__selected-marker {
120
+ position: absolute;
121
+ caret-color: inherit;
122
+ background-color: #dcdcdc;
123
+ display: inline-block;
124
+ font-weight: 400;
125
+ font-style: normal;
126
+ line-height: initial;
127
+ top: 0;
128
+ left: 0;
129
+ width: 10px;
130
+ height: 100%;
131
+ z-index: 0;
132
+ }
133
+
134
+ .ProseMirror-focused .invisible__selected-marker {
135
+ background-color: #b4d9ff;
136
+ }
137
+
138
+ .ProseMirror-focused .invisible--is-selected::before {
139
+ background-color: #b4d8ff;
140
+ }
141
+
142
+ .invisible--is-selected::before {
143
+ background-color: #dcdcdc;
144
+ }
145
+
146
+ .invisible--space:before {
147
+ content: '·';
148
+ }
149
+
150
+ .invisible--nb-space {
151
+ vertical-align: text-bottom;
152
+ }
153
+
154
+ .invisible--nb-space:before {
155
+ font-size: 15px;
156
+ content: '^';
157
+ position: absolute;
158
+ top: 9px;
159
+ left: -1px;
160
+ }
161
+
162
+ chip {
163
+ border-color: ${theme.chip.borderColor};
164
+ border-style: ${theme.chip.borderStyle};
165
+ border-width: ${theme.chip.borderWidth};
166
+ border-radius: ${theme.chip.borderRadius};
167
+ padding: ${theme.chip.paddingY} ${theme.chip.paddingX};
168
+ color: ${theme.chip.color};
169
+
170
+ cursor: default;
171
+
172
+ &[data-type='tagged'] {
173
+ background-color: ${theme.chip.taggedBackgroundColor};
174
+ }
175
+
176
+ &[data-type='untagged'] {
177
+ color: ${theme.chip.untaggedColor};
178
+ }
179
+
180
+ ::after {
181
+ content: '';
182
+ display: inline-block;
183
+ }
184
+
185
+ span {
186
+ cursor: pointer;
187
+ margin-left: 5px;
188
+ }
189
+ }
190
+
191
+ /* Leave space between subsequent chips */
192
+ chip + chip {
193
+ margin-left: 3px;
194
+ }
195
+
196
+ .placeholder {
197
+ display: inline-block;
198
+ height: 0;
199
+ width: 0;
200
+ white-space: nowrap;
201
+ color: ${theme.placeholderColor};
202
+ pointer-events: none;
203
+ cursor: text;
204
+ }
205
+ `;
206
+ };
207
+ const dropdownContainerStyles = (showDropdown, partialTheme = {}) => {
208
+ const theme = util.mergeDeep(byline.componentByline["dropdown"], partialTheme);
209
+ return react.css`
210
+ position: absolute;
211
+ box-sizing: border-box;
212
+ width: 100%;
213
+ z-index: 1000;
214
+ border-width: ${theme.borderWidth};
215
+ border-style: ${theme.borderStyle};
216
+ border-color: ${theme.borderColor};
217
+ background-color: ${theme.backgroundColor};
218
+ display: ${showDropdown ? "block" : "none"};
219
+ max-height: ${theme.maxHeight};
220
+ overflow-y: auto;
221
+ `;
222
+ };
223
+ const dropdownUlStyles = react.css`
224
+ margin: 0;
225
+ padding: 0;
226
+ list-style-type: none;
227
+ `;
228
+ const dropdownLiStyles = (partialTheme = {}) => {
229
+ const theme = util.mergeDeep(byline.componentByline["dropdown"], partialTheme);
230
+ return react.css`
231
+ cursor: pointer;
232
+ padding: 5px;
233
+ border-bottom-color: ${theme.li.borderBottomColor};
234
+ border-bottom-width: ${theme.li.borderBottomWidth};
235
+ border-bottom-style: ${theme.li.borderBottomStyle};
236
+ color: ${theme.li.color};
237
+ `;
238
+ };
239
+ const selectedDropdownLiStyles = (partialTheme = {}) => {
240
+ const theme = util.mergeDeep(byline.componentByline["dropdown"], partialTheme);
241
+ return react.css`
242
+ background-color: ${theme.li.selectedBackgroundColor};
243
+ color: ${theme.li.selectedColor};
244
+ `;
245
+ };
246
+ const previewStyles = react.css`
247
+ margin-top: 5px;
248
+ white-space: pre-wrap;
249
+ `;
250
+ const previewFreeTextStyles = react.css`
251
+ font-style: italic;
252
+ `;
253
+ const previewContributorStyles = (node) => react.css`
254
+ ${node.attrs.type === "tagged" ? "text-decoration: underline;" : ""}
255
+ color: inherit;
256
+ `;
257
+
258
+ exports.bylineContainerStyles = bylineContainerStyles;
259
+ exports.bylineEditorStyles = bylineEditorStyles;
260
+ exports.dropdownContainerStyles = dropdownContainerStyles;
261
+ exports.dropdownLiStyles = dropdownLiStyles;
262
+ exports.dropdownUlStyles = dropdownUlStyles;
263
+ exports.previewContributorStyles = previewContributorStyles;
264
+ exports.previewFreeTextStyles = previewFreeTextStyles;
265
+ exports.previewStyles = previewStyles;
266
+ exports.selectedDropdownLiStyles = selectedDropdownLiStyles;
@@ -0,0 +1,256 @@
1
+ import { css } from '@emotion/react';
2
+ import { componentByline } from '../../styleD/build/typescript/component/byline.js';
3
+ import { mergeDeep } from '../util.js';
4
+
5
+ const bylineContainerStyles = css`
6
+ position: relative;
7
+ width: 100%;
8
+ `;
9
+ const bylineEditorStyles = (partialTheme = {}) => {
10
+ const theme = mergeDeep(componentByline, partialTheme);
11
+ return css`
12
+ border-color: ${theme.borderColor};
13
+ border-style: ${theme.borderStyle};
14
+ border-width: ${theme.borderWidth};
15
+ background-color: ${theme.backgroundColor};
16
+ color: ${theme.color};
17
+
18
+ /* ProseMirror styles from prosemirror-view/styles/prosemirror.css */
19
+ .ProseMirror {
20
+ padding: 4px 4px;
21
+ word-wrap: break-word;
22
+ white-space: pre-wrap;
23
+ white-space: break-spaces;
24
+ -webkit-font-variant-ligatures: none;
25
+ font-variant-ligatures: none;
26
+ font-feature-settings: 'liga' 0; /* the above doesn't seem to work in Edge */
27
+ line-height: ${theme.lineHeight};
28
+ }
29
+
30
+ .ProseMirror[contenteditable='false'] {
31
+ background: ${theme.readonlyBackgroundColor};
32
+ cursor: 'not-allowed';
33
+ }
34
+
35
+ .ProseMirror pre {
36
+ white-space: pre-wrap;
37
+ }
38
+
39
+ .ProseMirror li {
40
+ position: relative;
41
+ }
42
+
43
+ .ProseMirror-hideselection *::selection {
44
+ background: transparent;
45
+ }
46
+ .ProseMirror-hideselection *::-moz-selection {
47
+ background: transparent;
48
+ }
49
+ .ProseMirror-hideselection {
50
+ caret-color: transparent;
51
+ }
52
+
53
+ /* See https://github.com/ProseMirror/prosemirror/issues/1421#issuecomment-1759320191 */
54
+ .ProseMirror [draggable][contenteditable='false'] {
55
+ user-select: text;
56
+ }
57
+
58
+ .ProseMirror-selectednode {
59
+ outline: 1px solid ${theme.chip.selectedBorderColor};
60
+ }
61
+
62
+ /* Make sure li selections wrap around markers */
63
+
64
+ li.ProseMirror-selectednode {
65
+ outline: none;
66
+ }
67
+
68
+ li.ProseMirror-selectednode:after {
69
+ content: '';
70
+ position: absolute;
71
+ left: -32px;
72
+ right: -2px;
73
+ top: -2px;
74
+ bottom: -2px;
75
+ border: 1px solid ${theme.chip.selectedBorderColor};
76
+ pointer-events: none;
77
+ }
78
+
79
+ /* Protect against generic img rules */
80
+
81
+ img.ProseMirror-separator {
82
+ display: inline !important;
83
+ border: none !important;
84
+ margin: 0 !important;
85
+ }
86
+
87
+ .ProseMirror:focus {
88
+ outline: none;
89
+ }
90
+
91
+ /* Invisible styles from @guardian/prosemirror-invisibles/dist/style.css */
92
+
93
+ .invisible {
94
+ /* Chrome in particular dislikes doing the right thing
95
+ * with carets and inline elements when contenteditable
96
+ * is 'false'. See e.g. https://github.com/ProseMirror/prosemirror/issues/1061
97
+ */
98
+ display: inline;
99
+ position: relative;
100
+ pointer-events: none;
101
+ }
102
+
103
+ .invisible:before {
104
+ position: relative;
105
+ caret-color: inherit;
106
+ color: ${theme.invisiblesColor};
107
+ display: inline-block;
108
+ font-weight: 400;
109
+ font-style: normal;
110
+ line-height: initial;
111
+ width: 0;
112
+ top: 0;
113
+ left: 0;
114
+ z-index: 1;
115
+ }
116
+
117
+ .invisible__selected-marker {
118
+ position: absolute;
119
+ caret-color: inherit;
120
+ background-color: #dcdcdc;
121
+ display: inline-block;
122
+ font-weight: 400;
123
+ font-style: normal;
124
+ line-height: initial;
125
+ top: 0;
126
+ left: 0;
127
+ width: 10px;
128
+ height: 100%;
129
+ z-index: 0;
130
+ }
131
+
132
+ .ProseMirror-focused .invisible__selected-marker {
133
+ background-color: #b4d9ff;
134
+ }
135
+
136
+ .ProseMirror-focused .invisible--is-selected::before {
137
+ background-color: #b4d8ff;
138
+ }
139
+
140
+ .invisible--is-selected::before {
141
+ background-color: #dcdcdc;
142
+ }
143
+
144
+ .invisible--space:before {
145
+ content: '·';
146
+ }
147
+
148
+ .invisible--nb-space {
149
+ vertical-align: text-bottom;
150
+ }
151
+
152
+ .invisible--nb-space:before {
153
+ font-size: 15px;
154
+ content: '^';
155
+ position: absolute;
156
+ top: 9px;
157
+ left: -1px;
158
+ }
159
+
160
+ chip {
161
+ border-color: ${theme.chip.borderColor};
162
+ border-style: ${theme.chip.borderStyle};
163
+ border-width: ${theme.chip.borderWidth};
164
+ border-radius: ${theme.chip.borderRadius};
165
+ padding: ${theme.chip.paddingY} ${theme.chip.paddingX};
166
+ color: ${theme.chip.color};
167
+
168
+ cursor: default;
169
+
170
+ &[data-type='tagged'] {
171
+ background-color: ${theme.chip.taggedBackgroundColor};
172
+ }
173
+
174
+ &[data-type='untagged'] {
175
+ color: ${theme.chip.untaggedColor};
176
+ }
177
+
178
+ ::after {
179
+ content: '';
180
+ display: inline-block;
181
+ }
182
+
183
+ span {
184
+ cursor: pointer;
185
+ margin-left: 5px;
186
+ }
187
+ }
188
+
189
+ /* Leave space between subsequent chips */
190
+ chip + chip {
191
+ margin-left: 3px;
192
+ }
193
+
194
+ .placeholder {
195
+ display: inline-block;
196
+ height: 0;
197
+ width: 0;
198
+ white-space: nowrap;
199
+ color: ${theme.placeholderColor};
200
+ pointer-events: none;
201
+ cursor: text;
202
+ }
203
+ `;
204
+ };
205
+ const dropdownContainerStyles = (showDropdown, partialTheme = {}) => {
206
+ const theme = mergeDeep(componentByline["dropdown"], partialTheme);
207
+ return css`
208
+ position: absolute;
209
+ box-sizing: border-box;
210
+ width: 100%;
211
+ z-index: 1000;
212
+ border-width: ${theme.borderWidth};
213
+ border-style: ${theme.borderStyle};
214
+ border-color: ${theme.borderColor};
215
+ background-color: ${theme.backgroundColor};
216
+ display: ${showDropdown ? "block" : "none"};
217
+ max-height: ${theme.maxHeight};
218
+ overflow-y: auto;
219
+ `;
220
+ };
221
+ const dropdownUlStyles = css`
222
+ margin: 0;
223
+ padding: 0;
224
+ list-style-type: none;
225
+ `;
226
+ const dropdownLiStyles = (partialTheme = {}) => {
227
+ const theme = mergeDeep(componentByline["dropdown"], partialTheme);
228
+ return css`
229
+ cursor: pointer;
230
+ padding: 5px;
231
+ border-bottom-color: ${theme.li.borderBottomColor};
232
+ border-bottom-width: ${theme.li.borderBottomWidth};
233
+ border-bottom-style: ${theme.li.borderBottomStyle};
234
+ color: ${theme.li.color};
235
+ `;
236
+ };
237
+ const selectedDropdownLiStyles = (partialTheme = {}) => {
238
+ const theme = mergeDeep(componentByline["dropdown"], partialTheme);
239
+ return css`
240
+ background-color: ${theme.li.selectedBackgroundColor};
241
+ color: ${theme.li.selectedColor};
242
+ `;
243
+ };
244
+ const previewStyles = css`
245
+ margin-top: 5px;
246
+ white-space: pre-wrap;
247
+ `;
248
+ const previewFreeTextStyles = css`
249
+ font-style: italic;
250
+ `;
251
+ const previewContributorStyles = (node) => css`
252
+ ${node.attrs.type === "tagged" ? "text-decoration: underline;" : ""}
253
+ color: inherit;
254
+ `;
255
+
256
+ export { bylineContainerStyles, bylineEditorStyles, dropdownContainerStyles, dropdownLiStyles, dropdownUlStyles, previewContributorStyles, previewFreeTextStyles, previewStyles, selectedDropdownLiStyles };
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
4
+ var react = require('@emotion/react');
5
+ var reactAriaComponents = require('react-aria-components');
6
+ var styles = require('./styles.cjs');
7
+
8
+ function TagAutocomplete({
9
+ addTag,
10
+ loading,
11
+ onChange,
12
+ options,
13
+ label,
14
+ placeholder,
15
+ disabled,
16
+ value,
17
+ "data-testid": dataTestId,
18
+ loadingIcon,
19
+ theme,
20
+ cssOverrides
21
+ }) {
22
+ return /* @__PURE__ */ jsxRuntime.jsx(
23
+ "div",
24
+ {
25
+ css: [
26
+ react.css`
27
+ position: relative;
28
+ `,
29
+ cssOverrides
30
+ ],
31
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
32
+ reactAriaComponents.ComboBox,
33
+ {
34
+ "aria-label": label,
35
+ inputValue: value,
36
+ onInputChange: onChange,
37
+ onSelectionChange: (key) => {
38
+ const tag = options.find((t) => t.id === key);
39
+ if (tag) {
40
+ addTag(tag);
41
+ onChange("");
42
+ }
43
+ },
44
+ allowsEmptyCollection: true,
45
+ items: options,
46
+ allowsCustomValue: true,
47
+ menuTrigger: "focus",
48
+ shouldFocusWrap: true,
49
+ children: [
50
+ /* @__PURE__ */ jsxRuntime.jsx(
51
+ reactAriaComponents.Input,
52
+ {
53
+ css: styles.tagAutocompleteInputStyles(theme),
54
+ placeholder,
55
+ disabled,
56
+ "data-testid": dataTestId
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsxRuntime.jsx(
60
+ reactAriaComponents.Popover,
61
+ {
62
+ placement: "bottom",
63
+ css: react.css`
64
+ width: var(--trigger-width);
65
+ `,
66
+ offset: 0,
67
+ shouldFlip: false,
68
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
69
+ reactAriaComponents.ListBox,
70
+ {
71
+ css: (value || options.length || loading) && styles.listboxStyles(theme),
72
+ autoFocus: "first",
73
+ renderEmptyState: () => (
74
+ // Only show a "no results" box if user has typed
75
+ value && !loading && /* @__PURE__ */ jsxRuntime.jsx("div", { css: styles.listboxInfoStyles(theme), children: "No results" })
76
+ ),
77
+ children: [
78
+ /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Collection, { items: options, children: (item) => /* @__PURE__ */ jsxRuntime.jsx(
79
+ reactAriaComponents.ListBoxItem,
80
+ {
81
+ css: styles.listboxItemStyles(theme),
82
+ value: item,
83
+ children: item.internalName
84
+ },
85
+ item.id
86
+ ) }),
87
+ /* @__PURE__ */ jsxRuntime.jsx(
88
+ reactAriaComponents.ListBoxLoadMoreItem,
89
+ {
90
+ css: styles.listboxInfoStyles(theme),
91
+ isLoading: loading,
92
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-label": "Loading", children: loadingIcon ?? "Loading..." })
93
+ }
94
+ )
95
+ ]
96
+ }
97
+ )
98
+ }
99
+ )
100
+ ]
101
+ }
102
+ )
103
+ }
104
+ );
105
+ }
106
+
107
+ exports.TagAutocomplete = TagAutocomplete;
@@ -0,0 +1,26 @@
1
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
2
+ import { css } from '@emotion/react';
3
+ import { ComboBox, Input, Popover, ListBox, Collection, ListBoxItem, ListBoxLoadMoreItem } from 'react-aria-components';
4
+ import { tagAutocompleteInputStyles, listboxStyles, listboxItemStyles, listboxInfoStyles } from './styles.js';
5
+
6
+ function TagAutocomplete({ addTag, loading, onChange, options, label, placeholder, disabled, value, "data-testid": dataTestId, loadingIcon, theme, cssOverrides }) {
7
+ return jsx("div", { css: [
8
+ css`
9
+ position: relative;
10
+ `,
11
+ cssOverrides
12
+ ], children: jsxs(ComboBox, { "aria-label": label, inputValue: value, onInputChange: onChange, onSelectionChange: (key) => {
13
+ const tag = options.find((t) => t.id === key);
14
+ if (tag) {
15
+ addTag(tag);
16
+ onChange("");
17
+ }
18
+ }, allowsEmptyCollection: true, items: options, allowsCustomValue: true, menuTrigger: "focus", shouldFocusWrap: true, children: [jsx(Input, { css: tagAutocompleteInputStyles(theme), placeholder, disabled, "data-testid": dataTestId }), jsx(Popover, { placement: "bottom", css: css`
19
+ width: var(--trigger-width);
20
+ `, offset: 0, shouldFlip: false, children: jsxs(ListBox, { css: (value || options.length || loading) && listboxStyles(theme), autoFocus: "first", renderEmptyState: () => (
21
+ // Only show a "no results" box if user has typed
22
+ value && !loading && jsx("div", { css: listboxInfoStyles(theme), children: "No results" })
23
+ ), children: [jsx(Collection, { items: options, children: (item) => jsx(ListBoxItem, { css: listboxItemStyles(theme), value: item, children: item.internalName }, item.id) }), jsx(ListBoxLoadMoreItem, { css: listboxInfoStyles(theme), isLoading: loading, children: jsx("span", { "aria-label": "Loading", children: loadingIcon ?? "Loading..." }) })] }) })] }) });
24
+ }
25
+
26
+ export { TagAutocomplete };