@workday/canvas-kit-labs-react 15.0.0-alpha.0064-next.0 → 15.0.0-alpha.0075-next.0
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/commonjs/ai-ingress-button/lib/AIIngressButton.js +5 -5
- package/dist/commonjs/index.d.ts +0 -2
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +0 -2
- package/dist/commonjs/side-panel/lib/SidePanel.js +7 -7
- package/dist/commonjs/side-panel/lib/SidePanelToggleButton.js +11 -11
- package/dist/commonjs/version/lib/version.js +1 -1
- package/dist/es6/ai-ingress-button/lib/AIIngressButton.js +5 -5
- package/dist/es6/index.d.ts +0 -2
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +0 -2
- package/dist/es6/side-panel/lib/SidePanel.js +7 -7
- package/dist/es6/side-panel/lib/SidePanelToggleButton.js +11 -11
- package/dist/es6/version/lib/version.js +1 -1
- package/index.ts +0 -2
- package/package.json +4 -4
- package/combobox/index.ts +0 -1
- package/combobox/lib/AutocompleteList.tsx +0 -137
- package/combobox/lib/Combobox.tsx +0 -505
- package/combobox/lib/Status.tsx +0 -52
- package/combobox/package.json +0 -6
- package/dist/commonjs/combobox/index.d.ts +0 -2
- package/dist/commonjs/combobox/index.d.ts.map +0 -1
- package/dist/commonjs/combobox/index.js +0 -17
- package/dist/commonjs/combobox/lib/AutocompleteList.d.ts +0 -34
- package/dist/commonjs/combobox/lib/AutocompleteList.d.ts.map +0 -1
- package/dist/commonjs/combobox/lib/AutocompleteList.js +0 -101
- package/dist/commonjs/combobox/lib/Combobox.d.ts +0 -79
- package/dist/commonjs/combobox/lib/Combobox.d.ts.map +0 -1
- package/dist/commonjs/combobox/lib/Combobox.js +0 -349
- package/dist/commonjs/combobox/lib/Status.d.ts +0 -16
- package/dist/commonjs/combobox/lib/Status.d.ts.map +0 -1
- package/dist/commonjs/combobox/lib/Status.js +0 -29
- package/dist/commonjs/search-form/index.d.ts +0 -3
- package/dist/commonjs/search-form/index.d.ts.map +0 -1
- package/dist/commonjs/search-form/index.js +0 -18
- package/dist/commonjs/search-form/lib/SearchForm.d.ts +0 -450
- package/dist/commonjs/search-form/lib/SearchForm.d.ts.map +0 -1
- package/dist/commonjs/search-form/lib/SearchForm.js +0 -236
- package/dist/commonjs/search-form/lib/themes.d.ts +0 -33
- package/dist/commonjs/search-form/lib/themes.d.ts.map +0 -1
- package/dist/commonjs/search-form/lib/themes.js +0 -47
- package/dist/es6/combobox/index.d.ts +0 -2
- package/dist/es6/combobox/index.d.ts.map +0 -1
- package/dist/es6/combobox/index.js +0 -1
- package/dist/es6/combobox/lib/AutocompleteList.d.ts +0 -34
- package/dist/es6/combobox/lib/AutocompleteList.d.ts.map +0 -1
- package/dist/es6/combobox/lib/AutocompleteList.js +0 -71
- package/dist/es6/combobox/lib/Combobox.d.ts +0 -79
- package/dist/es6/combobox/lib/Combobox.d.ts.map +0 -1
- package/dist/es6/combobox/lib/Combobox.js +0 -317
- package/dist/es6/combobox/lib/Status.d.ts +0 -16
- package/dist/es6/combobox/lib/Status.d.ts.map +0 -1
- package/dist/es6/combobox/lib/Status.js +0 -22
- package/dist/es6/search-form/index.d.ts +0 -3
- package/dist/es6/search-form/index.d.ts.map +0 -1
- package/dist/es6/search-form/index.js +0 -2
- package/dist/es6/search-form/lib/SearchForm.d.ts +0 -450
- package/dist/es6/search-form/lib/SearchForm.d.ts.map +0 -1
- package/dist/es6/search-form/lib/SearchForm.js +0 -207
- package/dist/es6/search-form/lib/themes.d.ts +0 -33
- package/dist/es6/search-form/lib/themes.d.ts.map +0 -1
- package/dist/es6/search-form/lib/themes.js +0 -44
- package/search-form/index.ts +0 -2
- package/search-form/lib/SearchForm.tsx +0 -651
- package/search-form/lib/themes.ts +0 -67
- package/search-form/package.json +0 -6
|
@@ -1,651 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
GrowthBehavior,
|
|
4
|
-
generateUniqueId,
|
|
5
|
-
accessibleHideStyles,
|
|
6
|
-
} from '@workday/canvas-kit-react/common';
|
|
7
|
-
import {TertiaryButton, TertiaryButtonProps} from '@workday/canvas-kit-react/button';
|
|
8
|
-
import {searchIcon, xIcon} from '@workday/canvas-system-icons-web';
|
|
9
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
10
|
-
import {Combobox} from '@workday/canvas-kit-labs-react/combobox';
|
|
11
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
12
|
-
import {searchThemes, SearchTheme, SearchThemeAttributes} from './themes';
|
|
13
|
-
import chroma from 'chroma-js';
|
|
14
|
-
import {CSProps, calc, createStencil, cssVar, px2rem} from '@workday/canvas-kit-styling';
|
|
15
|
-
import {brand, system} from '@workday/canvas-tokens-web';
|
|
16
|
-
import {mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated ⚠️ `SearchFormProps` is deprecated and will be removed in a future major version. Please reference our [Autocomplete example](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs#usage).
|
|
19
|
-
*/
|
|
20
|
-
export interface SearchFormProps
|
|
21
|
-
extends GrowthBehavior,
|
|
22
|
-
React.FormHTMLAttributes<HTMLFormElement>,
|
|
23
|
-
CSProps {
|
|
24
|
-
/**
|
|
25
|
-
* The function called when the SearchForm form is submitted. The current input value is passed to the callback function.
|
|
26
|
-
*/
|
|
27
|
-
onSubmit: React.FormEventHandler<HTMLFormElement>;
|
|
28
|
-
/**
|
|
29
|
-
* If true, collapse the SearchForm text input into a toggle icon. Useful for responsive layouts.
|
|
30
|
-
* @default false
|
|
31
|
-
*/
|
|
32
|
-
isCollapsed?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* The function called when the SearchForm text input changes.
|
|
35
|
-
*/
|
|
36
|
-
onInputChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
37
|
-
/**
|
|
38
|
-
* The autocomplete items of the SearchForm. This array of menu items is shown under the search bar.
|
|
39
|
-
*/
|
|
40
|
-
autocompleteItems?: React.ReactElement<any>[];
|
|
41
|
-
/**
|
|
42
|
-
* The theme of the header the search input is being rendered in.
|
|
43
|
-
*/
|
|
44
|
-
searchTheme?: SearchTheme | SearchThemeAttributes;
|
|
45
|
-
/**
|
|
46
|
-
* The placeholder text of the SearchForm text input.
|
|
47
|
-
* @default Search
|
|
48
|
-
*/
|
|
49
|
-
placeholder?: string;
|
|
50
|
-
/**
|
|
51
|
-
* The initial value of the SearchForm text input.
|
|
52
|
-
*/
|
|
53
|
-
initialValue?: string;
|
|
54
|
-
/**
|
|
55
|
-
* If true, right-align the SearchForm. If false, the text input should grow to left-align the SearchForm.
|
|
56
|
-
* @default false
|
|
57
|
-
*/
|
|
58
|
-
rightAlign?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* The screenreader label text for the SearchForm text input.
|
|
61
|
-
* @default Search
|
|
62
|
-
*/
|
|
63
|
-
inputLabel?: string;
|
|
64
|
-
/**
|
|
65
|
-
* The screenreader label text for the SearchForm submit button.
|
|
66
|
-
* @default Search
|
|
67
|
-
*/
|
|
68
|
-
submitAriaLabel?: string;
|
|
69
|
-
/**
|
|
70
|
-
* The screenreader label text for the SearchForm clear button.
|
|
71
|
-
* @default Reset Search Form
|
|
72
|
-
*/
|
|
73
|
-
clearButtonAriaLabel?: string;
|
|
74
|
-
/**
|
|
75
|
-
* The screenreader label text for the button to open the collapsed SearchForm.
|
|
76
|
-
* @default Open Search
|
|
77
|
-
*/
|
|
78
|
-
openButtonAriaLabel?: string;
|
|
79
|
-
/**
|
|
80
|
-
* The screenreader label text for the button to close the open SearchForm.
|
|
81
|
-
* @default Cancel
|
|
82
|
-
*/
|
|
83
|
-
closeButtonAriaLabel?: string;
|
|
84
|
-
/**
|
|
85
|
-
* If true, render the SearchForm with a button to clear the text input.
|
|
86
|
-
* @default true
|
|
87
|
-
*/
|
|
88
|
-
showClearButton?: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Height of the Search Form in pixels
|
|
91
|
-
* @default 40
|
|
92
|
-
*/
|
|
93
|
-
height?: number;
|
|
94
|
-
/**
|
|
95
|
-
* If true, allow onSubmit being called when input value is empty.
|
|
96
|
-
* @default false
|
|
97
|
-
*/
|
|
98
|
-
allowEmptyStringSearch?: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Sets the `id` for the label
|
|
101
|
-
* @default unique identifier
|
|
102
|
-
*/
|
|
103
|
-
labelId?: string;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* @deprecated ⚠️ `SearchFormState` is deprecated and will be removed in a future major version. Please reference our [Autocomplete example](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs#usage).
|
|
107
|
-
*/
|
|
108
|
-
export interface SearchFormState {
|
|
109
|
-
showForm: boolean;
|
|
110
|
-
searchQuery: string;
|
|
111
|
-
isFocused: boolean;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function getInputColors(theme: SearchThemeAttributes, isFocused?: boolean) {
|
|
115
|
-
return {
|
|
116
|
-
background: isFocused && theme.backgroundFocus ? theme.backgroundFocus : theme.background,
|
|
117
|
-
backgroundHover: theme.backgroundHover,
|
|
118
|
-
color: isFocused && theme.colorFocus ? theme.colorFocus : theme.color,
|
|
119
|
-
placeholderColor:
|
|
120
|
-
isFocused && theme.placeholderColorFocus
|
|
121
|
-
? theme.placeholderColorFocus
|
|
122
|
-
: theme.placeholderColor,
|
|
123
|
-
boxShadow: isFocused && theme.boxShadowFocus ? theme.boxShadowFocus : theme.boxShadow,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const formCollapsedBackground = '#fff';
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @deprecated ⚠️ `searchFormStencil` is deprecated and will be removed in a future major version. Please reference our [Autocomplete example](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs#usage).
|
|
131
|
-
*/
|
|
132
|
-
export const searchFormStencil = createStencil({
|
|
133
|
-
vars: {
|
|
134
|
-
minWidth: '',
|
|
135
|
-
maxWidth: '',
|
|
136
|
-
height: '',
|
|
137
|
-
background: '',
|
|
138
|
-
backgroundFocus: '',
|
|
139
|
-
backgroundHover: '',
|
|
140
|
-
color: '',
|
|
141
|
-
colorFocus: '',
|
|
142
|
-
placeholderColor: '',
|
|
143
|
-
placeholderColorFocus: '',
|
|
144
|
-
boxShadow: '',
|
|
145
|
-
boxShadowFocus: '',
|
|
146
|
-
},
|
|
147
|
-
parts: {
|
|
148
|
-
searchContainer: 'search-form-container',
|
|
149
|
-
combobox: 'search-form-combobox',
|
|
150
|
-
closeButton: 'search-form-close-button',
|
|
151
|
-
searchField: 'search-form-field',
|
|
152
|
-
submitSearchIcon: 'search-form-submit-search-icon',
|
|
153
|
-
openSearchIcon: 'search-form-open-search-icon',
|
|
154
|
-
searchInput: 'search-form-input',
|
|
155
|
-
closeButtonPart: 'search-form-close-button',
|
|
156
|
-
},
|
|
157
|
-
base: ({
|
|
158
|
-
minWidth,
|
|
159
|
-
maxWidth,
|
|
160
|
-
searchContainerPart,
|
|
161
|
-
height,
|
|
162
|
-
comboboxPart,
|
|
163
|
-
closeButtonPart,
|
|
164
|
-
searchFieldPart,
|
|
165
|
-
submitSearchIconPart,
|
|
166
|
-
openSearchIconPart,
|
|
167
|
-
searchInputPart,
|
|
168
|
-
background,
|
|
169
|
-
backgroundFocus,
|
|
170
|
-
backgroundHover,
|
|
171
|
-
color,
|
|
172
|
-
colorFocus,
|
|
173
|
-
placeholderColor,
|
|
174
|
-
placeholderColorFocus,
|
|
175
|
-
boxShadow,
|
|
176
|
-
boxShadowFocus,
|
|
177
|
-
}) => ({
|
|
178
|
-
position: 'relative',
|
|
179
|
-
flexGrow: 1,
|
|
180
|
-
display: 'flex',
|
|
181
|
-
alignItems: 'center',
|
|
182
|
-
marginInlineStart: system.space.x6,
|
|
183
|
-
minWidth: cssVar(minWidth, px2rem(120)),
|
|
184
|
-
maxWidth: cssVar(maxWidth, px2rem(480)),
|
|
185
|
-
[searchContainerPart]: {
|
|
186
|
-
position: `relative`,
|
|
187
|
-
display: 'flex',
|
|
188
|
-
alignItems: 'center',
|
|
189
|
-
width: `100%`,
|
|
190
|
-
textAlign: 'left',
|
|
191
|
-
minHeight: cssVar(height, system.space.x10),
|
|
192
|
-
},
|
|
193
|
-
[comboboxPart]: {
|
|
194
|
-
width: `100%`,
|
|
195
|
-
},
|
|
196
|
-
[closeButtonPart]: {
|
|
197
|
-
position: `absolute`,
|
|
198
|
-
top: 0,
|
|
199
|
-
bottom: 0,
|
|
200
|
-
right: 0,
|
|
201
|
-
margin: `auto ${system.space.x2}`,
|
|
202
|
-
zIndex: 3,
|
|
203
|
-
display: 'none',
|
|
204
|
-
},
|
|
205
|
-
[searchFieldPart]: {
|
|
206
|
-
width: '100%',
|
|
207
|
-
height: cssVar(height, system.space.x10),
|
|
208
|
-
maxWidth: cssVar(maxWidth, px2rem(480)),
|
|
209
|
-
marginBottom: 0,
|
|
210
|
-
display: 'inline-block',
|
|
211
|
-
'> div': {
|
|
212
|
-
display: 'block',
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
[`${submitSearchIconPart}, ${openSearchIconPart}`]: {
|
|
216
|
-
position: `absolute`,
|
|
217
|
-
margin: `auto ${system.space.x2}`,
|
|
218
|
-
top: 0,
|
|
219
|
-
bottom: 0,
|
|
220
|
-
left: 0,
|
|
221
|
-
padding: 0,
|
|
222
|
-
zIndex: 3,
|
|
223
|
-
':dir(rtl)': {
|
|
224
|
-
right: 0,
|
|
225
|
-
left: 'auto',
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
[searchInputPart]: {
|
|
229
|
-
maxWidth,
|
|
230
|
-
minWidth,
|
|
231
|
-
paddingInlineStart: calc.add(system.space.x10, system.space.x2),
|
|
232
|
-
paddingInlineEnd: system.space.x10,
|
|
233
|
-
backgroundColor: cssVar(background, system.color.bg.alt.soft),
|
|
234
|
-
height: cssVar(height, system.space.x10),
|
|
235
|
-
fontSize: system.fontSize.subtext.large,
|
|
236
|
-
boxShadow: boxShadow,
|
|
237
|
-
color: cssVar(color, system.color.text.default),
|
|
238
|
-
border: 'none',
|
|
239
|
-
WebkitAppearance: 'none',
|
|
240
|
-
transition: 'background-color 120ms, color 120ms, box-shadow 200ms, border-color 200ms',
|
|
241
|
-
zIndex: 2,
|
|
242
|
-
width: '100%',
|
|
243
|
-
'&::-webkit-search-cancel-button': {
|
|
244
|
-
display: 'none',
|
|
245
|
-
},
|
|
246
|
-
'&::placeholder': {
|
|
247
|
-
color: cssVar(placeholderColor, system.color.text.hint),
|
|
248
|
-
},
|
|
249
|
-
'&:placeholder-shown': {
|
|
250
|
-
textOverflow: 'ellipsis',
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
'&:hover': {
|
|
254
|
-
backgroundColor: cssVar(backgroundHover, cssVar(background, system.color.bg.alt.default)),
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
'&:is(:focus-visible, .focus):where(:not([disabled]))': {
|
|
258
|
-
background: cssVar(backgroundFocus, system.color.bg.alt.soft),
|
|
259
|
-
color: colorFocus,
|
|
260
|
-
borderColor: brand.common.focusOutline,
|
|
261
|
-
outline: `${px2rem(2)} solid transparent`,
|
|
262
|
-
boxShadow: cssVar(
|
|
263
|
-
boxShadowFocus,
|
|
264
|
-
`0 0 0 0px ${system.color.bg.default}, 0 0 0 2px ${brand.common.focusOutline}`
|
|
265
|
-
),
|
|
266
|
-
'::placeholder': {
|
|
267
|
-
color: placeholderColorFocus,
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
}),
|
|
272
|
-
modifiers: {
|
|
273
|
-
isHiddenSubmitSearchIcon: {
|
|
274
|
-
true: ({submitSearchIconPart}) => ({
|
|
275
|
-
[submitSearchIconPart]: {
|
|
276
|
-
display: 'none',
|
|
277
|
-
},
|
|
278
|
-
}),
|
|
279
|
-
},
|
|
280
|
-
isHiddenOpenSeachIcon: {
|
|
281
|
-
true: ({openSearchIconPart}) => ({
|
|
282
|
-
[openSearchIconPart]: {
|
|
283
|
-
display: 'none',
|
|
284
|
-
},
|
|
285
|
-
}),
|
|
286
|
-
},
|
|
287
|
-
isCollapsed: {
|
|
288
|
-
true: ({
|
|
289
|
-
searchFieldPart,
|
|
290
|
-
submitSearchIconPart,
|
|
291
|
-
openSearchIconPart,
|
|
292
|
-
searchInputPart,
|
|
293
|
-
height,
|
|
294
|
-
}) => ({
|
|
295
|
-
top: 0,
|
|
296
|
-
right: 0,
|
|
297
|
-
left: 0,
|
|
298
|
-
bottom: 0,
|
|
299
|
-
margin: 0,
|
|
300
|
-
position: 'relative',
|
|
301
|
-
backgroundColor: system.color.bg.transparent.default,
|
|
302
|
-
transition: 'background-color 120ms',
|
|
303
|
-
maxWidth: calc.add(system.space.x10, system.space.x2),
|
|
304
|
-
minWidth: calc.add(system.space.x10, system.space.x3),
|
|
305
|
-
overflow: 'hidden',
|
|
306
|
-
zIndex: 1,
|
|
307
|
-
[searchFieldPart]: {
|
|
308
|
-
display: 'none',
|
|
309
|
-
maxWidth: '100%',
|
|
310
|
-
},
|
|
311
|
-
[`${submitSearchIconPart}, ${openSearchIconPart}`]: {
|
|
312
|
-
margin: `auto ${system.space.x2}`,
|
|
313
|
-
},
|
|
314
|
-
[searchInputPart]: {
|
|
315
|
-
fontSize: '20px',
|
|
316
|
-
paddingInlineStart: calc.add(system.space.x10, system.space.x4),
|
|
317
|
-
paddingInlineEnd: calc.add(system.space.x10, system.space.x4),
|
|
318
|
-
maxWidth: 'none',
|
|
319
|
-
minWidth: 0,
|
|
320
|
-
backgroundColor: system.color.bg.transparent.default,
|
|
321
|
-
height: cssVar(height, system.space.x10),
|
|
322
|
-
},
|
|
323
|
-
}),
|
|
324
|
-
false: ({searchFieldPart}) => ({
|
|
325
|
-
[searchFieldPart]: {
|
|
326
|
-
display: 'inline-block',
|
|
327
|
-
},
|
|
328
|
-
}),
|
|
329
|
-
},
|
|
330
|
-
rightAlign: {
|
|
331
|
-
true: {
|
|
332
|
-
textAlign: 'right',
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
showForm: {
|
|
336
|
-
true: {},
|
|
337
|
-
false: {},
|
|
338
|
-
},
|
|
339
|
-
grow: {
|
|
340
|
-
true: {
|
|
341
|
-
maxWidth: '100%',
|
|
342
|
-
[`[data-part="search-form-field"], [data-part="search-form-input"]`]: {
|
|
343
|
-
maxWidth: '100%',
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
searchTheme: {
|
|
348
|
-
// Light theme
|
|
349
|
-
light: ({searchInputPart}) => ({
|
|
350
|
-
[searchInputPart]: {
|
|
351
|
-
background: system.color.bg.alt.soft,
|
|
352
|
-
color: system.color.text.default,
|
|
353
|
-
|
|
354
|
-
'::placeholder': {
|
|
355
|
-
color: system.color.text.hint,
|
|
356
|
-
},
|
|
357
|
-
'&:hover': {
|
|
358
|
-
background: system.color.bg.alt.default,
|
|
359
|
-
},
|
|
360
|
-
'&:is(:focus-visible, &.focus):where(:not([disabled]))': {
|
|
361
|
-
background: system.color.bg.alt.soft,
|
|
362
|
-
boxShadow: `0 0 0 0px ${system.color.border.inverse}, 0 0 0 2px ${brand.common.focusOutline}`,
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
}),
|
|
366
|
-
// Dark theme
|
|
367
|
-
dark: ({searchInputPart}) => ({
|
|
368
|
-
[searchInputPart]: {
|
|
369
|
-
backgroundColor: 'rgba(0, 0, 0, 0.2)',
|
|
370
|
-
color: system.color.text.inverse,
|
|
371
|
-
boxShadow: 'none',
|
|
372
|
-
'::placeholder': {
|
|
373
|
-
color: system.color.text.inverse,
|
|
374
|
-
},
|
|
375
|
-
|
|
376
|
-
':hover': {
|
|
377
|
-
background: 'rgba(0, 0, 0, 0.2)',
|
|
378
|
-
},
|
|
379
|
-
|
|
380
|
-
'&:is(:focus-visible, &.focus):where(:not([disabled]))': {
|
|
381
|
-
background: system.color.bg.default,
|
|
382
|
-
color: system.color.text.default,
|
|
383
|
-
'::placeholder': {
|
|
384
|
-
color: system.color.text.hint,
|
|
385
|
-
},
|
|
386
|
-
boxShadow: 'none',
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
}),
|
|
390
|
-
//Transparent theme
|
|
391
|
-
transparent: ({searchInputPart}) => ({
|
|
392
|
-
[searchInputPart]: {
|
|
393
|
-
background: system.color.bg.transparent.default,
|
|
394
|
-
backgroundFocus: system.color.bg.transparent.default,
|
|
395
|
-
color: system.color.text.default,
|
|
396
|
-
colorFocus: system.color.text.default,
|
|
397
|
-
placeholderColor: system.color.text.hint,
|
|
398
|
-
placeholderColorFocus: system.color.text.hint,
|
|
399
|
-
boxShadow: 'none',
|
|
400
|
-
boxShadowFocus: 'none',
|
|
401
|
-
},
|
|
402
|
-
}),
|
|
403
|
-
},
|
|
404
|
-
},
|
|
405
|
-
compound: [
|
|
406
|
-
{
|
|
407
|
-
modifiers: {showForm: 'true', isCollapsed: 'true'},
|
|
408
|
-
styles: {
|
|
409
|
-
position: 'absolute',
|
|
410
|
-
backgroundColor: system.color.bg.default,
|
|
411
|
-
maxWidth: 'none',
|
|
412
|
-
overflow: 'visible',
|
|
413
|
-
'& [data-part="search-form-close-button"]': {
|
|
414
|
-
display: 'inline-block',
|
|
415
|
-
},
|
|
416
|
-
'& [data-part="search-form-field"]': {
|
|
417
|
-
display: 'inline-block',
|
|
418
|
-
},
|
|
419
|
-
'& [data-part="search-form-input"]': {
|
|
420
|
-
boxShadow: 'none',
|
|
421
|
-
background: system.color.bg.transparent.default,
|
|
422
|
-
':hover': {
|
|
423
|
-
background: system.color.bg.transparent.default,
|
|
424
|
-
},
|
|
425
|
-
|
|
426
|
-
'&:is(:focus-visible, &.focus):where(:not([disabled]))': {
|
|
427
|
-
background: system.color.bg.transparent.default,
|
|
428
|
-
boxShadow: 'none',
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
modifiers: {isCollapsed: 'true', showForm: 'true'},
|
|
435
|
-
styles: {
|
|
436
|
-
'& [data-part="search-form-field"]': {
|
|
437
|
-
display: 'inline-block',
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
},
|
|
441
|
-
],
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* @deprecated ⚠️ `SearchForm` is deprecated and will be removed in a future major version. Please reference our [Autocomplete example](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs#usage).
|
|
446
|
-
*/
|
|
447
|
-
export class SearchForm extends React.Component<SearchFormProps, SearchFormState> {
|
|
448
|
-
static Theme = SearchTheme;
|
|
449
|
-
private inputRef = React.createRef<HTMLInputElement>();
|
|
450
|
-
private openRef = React.createRef<HTMLButtonElement>();
|
|
451
|
-
private defaultLabelId = generateUniqueId();
|
|
452
|
-
|
|
453
|
-
state: Readonly<SearchFormState> = {
|
|
454
|
-
showForm: false,
|
|
455
|
-
searchQuery: '',
|
|
456
|
-
isFocused: false,
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
private getTheme = () => {
|
|
460
|
-
let theme: SearchThemeAttributes;
|
|
461
|
-
if (typeof this.props.searchTheme === 'string') {
|
|
462
|
-
theme = searchThemes[this.props.searchTheme];
|
|
463
|
-
} else if (this.props.searchTheme) {
|
|
464
|
-
theme = this.props.searchTheme;
|
|
465
|
-
} else {
|
|
466
|
-
theme = searchThemes[SearchTheme.Light];
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
return theme;
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
private getThemeColors = (): ReturnType<typeof getInputColors> => {
|
|
473
|
-
const theme =
|
|
474
|
-
this.props.isCollapsed && this.state.showForm
|
|
475
|
-
? searchThemes[SearchTheme.Transparent]
|
|
476
|
-
: this.getTheme();
|
|
477
|
-
return getInputColors(theme, this.state.isFocused);
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
getIconButtonType = (): TertiaryButtonProps['variant'] => {
|
|
481
|
-
let background = this.getThemeColors().background || `#fff`;
|
|
482
|
-
if (this.props.isCollapsed && this.state.showForm) {
|
|
483
|
-
background = formCollapsedBackground;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
const isDarkBackground = chroma(background as string).get('lab.l') < 70;
|
|
487
|
-
|
|
488
|
-
return isDarkBackground ? 'inverse' : undefined;
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
handleSubmit = (event: React.FormEvent<HTMLFormElement>): void => {
|
|
492
|
-
event.preventDefault();
|
|
493
|
-
if (this.props.allowEmptyStringSearch || this.state.searchQuery.trim()) {
|
|
494
|
-
this.props.onSubmit(event);
|
|
495
|
-
} else {
|
|
496
|
-
this.focusInput();
|
|
497
|
-
}
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
openCollapsedSearch = (): void => {
|
|
501
|
-
if (this.props.isCollapsed && !this.state.showForm) {
|
|
502
|
-
this.setState({showForm: true});
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
|
|
506
|
-
closeCollapsedSearch = (): void => {
|
|
507
|
-
if (this.props.isCollapsed && this.state.showForm) {
|
|
508
|
-
this.setState({showForm: false});
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
componentDidUpdate(prevProps: SearchFormProps, prevState: SearchFormState) {
|
|
513
|
-
const showFormToggled = this.state.showForm !== prevState.showForm;
|
|
514
|
-
if (showFormToggled) {
|
|
515
|
-
if (this.state.showForm) {
|
|
516
|
-
this.focusInput();
|
|
517
|
-
} else {
|
|
518
|
-
this.focusOpen();
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
focusInput = (): void => {
|
|
524
|
-
if (this.inputRef.current) {
|
|
525
|
-
this.inputRef.current.focus();
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
focusOpen = (): void => {
|
|
530
|
-
if (this.openRef.current) {
|
|
531
|
-
this.openRef.current.focus();
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
handleFocus = (): void => {
|
|
536
|
-
this.setState({isFocused: true});
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
handleBlur = (): void => {
|
|
540
|
-
this.setState({isFocused: false});
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
handleSearchInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
|
544
|
-
event.preventDefault();
|
|
545
|
-
this.setState({searchQuery: event.target.value});
|
|
546
|
-
if (this.props.onInputChange) {
|
|
547
|
-
this.props.onInputChange(event);
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
render() {
|
|
552
|
-
const {
|
|
553
|
-
clearButtonAriaLabel = 'Reset Search Form',
|
|
554
|
-
placeholder = 'Search',
|
|
555
|
-
inputLabel = 'Search',
|
|
556
|
-
submitAriaLabel = 'Search',
|
|
557
|
-
openButtonAriaLabel = 'Open Search',
|
|
558
|
-
closeButtonAriaLabel = 'Cancel',
|
|
559
|
-
labelId = this.defaultLabelId,
|
|
560
|
-
showClearButton = true,
|
|
561
|
-
height = px2rem(40),
|
|
562
|
-
grow,
|
|
563
|
-
onSubmit,
|
|
564
|
-
isCollapsed,
|
|
565
|
-
onInputChange,
|
|
566
|
-
autocompleteItems,
|
|
567
|
-
initialValue,
|
|
568
|
-
searchTheme,
|
|
569
|
-
rightAlign,
|
|
570
|
-
allowEmptyStringSearch = false,
|
|
571
|
-
...elemProps
|
|
572
|
-
} = this.props;
|
|
573
|
-
|
|
574
|
-
return (
|
|
575
|
-
<form
|
|
576
|
-
role="search"
|
|
577
|
-
action="."
|
|
578
|
-
aria-labelledby={labelId}
|
|
579
|
-
onSubmit={this.handleSubmit}
|
|
580
|
-
{...mergeStyles(
|
|
581
|
-
elemProps,
|
|
582
|
-
searchFormStencil({
|
|
583
|
-
grow,
|
|
584
|
-
rightAlign,
|
|
585
|
-
isCollapsed: isCollapsed ? 'true' : 'false',
|
|
586
|
-
showForm: this.state.showForm ? 'true' : 'false',
|
|
587
|
-
height: typeof height === 'number' ? px2rem(height) : height,
|
|
588
|
-
isHiddenSubmitSearchIcon: !!isCollapsed && !this.state.showForm,
|
|
589
|
-
isHiddenOpenSeachIcon: !isCollapsed || (!!isCollapsed && this.state.showForm),
|
|
590
|
-
searchTheme: typeof searchTheme === 'string' ? searchTheme : undefined,
|
|
591
|
-
...(typeof searchTheme !== 'string' ? searchTheme : {}),
|
|
592
|
-
})
|
|
593
|
-
)}
|
|
594
|
-
>
|
|
595
|
-
<div {...searchFormStencil.parts.searchContainer}>
|
|
596
|
-
<TertiaryButton
|
|
597
|
-
aria-label={submitAriaLabel}
|
|
598
|
-
icon={searchIcon}
|
|
599
|
-
variant={this.getIconButtonType()}
|
|
600
|
-
type="submit"
|
|
601
|
-
size="small"
|
|
602
|
-
{...searchFormStencil.parts.submitSearchIcon}
|
|
603
|
-
/>
|
|
604
|
-
<TertiaryButton
|
|
605
|
-
aria-label={openButtonAriaLabel}
|
|
606
|
-
icon={searchIcon}
|
|
607
|
-
variant={this.getIconButtonType()}
|
|
608
|
-
onClick={this.openCollapsedSearch}
|
|
609
|
-
ref={this.openRef}
|
|
610
|
-
type="button"
|
|
611
|
-
{...searchFormStencil.parts.openSearchIcon}
|
|
612
|
-
/>
|
|
613
|
-
<FormField id={labelId} {...searchFormStencil.parts.searchField}>
|
|
614
|
-
<FormField.Label cs={accessibleHideStyles}>{inputLabel}</FormField.Label>
|
|
615
|
-
<Combobox
|
|
616
|
-
initialValue={initialValue}
|
|
617
|
-
clearButtonVariant={this.getIconButtonType()}
|
|
618
|
-
autocompleteItems={autocompleteItems}
|
|
619
|
-
onChange={this.handleSearchInputChange}
|
|
620
|
-
onFocus={this.handleFocus}
|
|
621
|
-
onBlur={this.handleBlur}
|
|
622
|
-
showClearButton={!isCollapsed && showClearButton}
|
|
623
|
-
clearButtonAriaLabel={clearButtonAriaLabel}
|
|
624
|
-
labelId={labelId}
|
|
625
|
-
{...searchFormStencil.parts.combobox}
|
|
626
|
-
>
|
|
627
|
-
<FormField.Input
|
|
628
|
-
as={TextInput}
|
|
629
|
-
ref={this.inputRef as any}
|
|
630
|
-
cs={this.state.isFocused ? 'focus' : undefined}
|
|
631
|
-
onBlur={this.handleBlur}
|
|
632
|
-
value={this.state.searchQuery}
|
|
633
|
-
placeholder={placeholder}
|
|
634
|
-
name="search"
|
|
635
|
-
autoComplete="off"
|
|
636
|
-
{...searchFormStencil.parts.searchInput}
|
|
637
|
-
/>
|
|
638
|
-
</Combobox>
|
|
639
|
-
</FormField>
|
|
640
|
-
<TertiaryButton
|
|
641
|
-
icon={xIcon}
|
|
642
|
-
aria-label={closeButtonAriaLabel}
|
|
643
|
-
onClick={this.closeCollapsedSearch}
|
|
644
|
-
id="foo"
|
|
645
|
-
{...searchFormStencil.parts.closeButton}
|
|
646
|
-
/>
|
|
647
|
-
</div>
|
|
648
|
-
</form>
|
|
649
|
-
);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {focusRing} from '@workday/canvas-kit-react/common';
|
|
2
|
-
import {colors} from '@workday/canvas-kit-react/tokens';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated ⚠️ `SearchTheme` is deprecated and will be removed in a future major version. Please our CSS tokens to theme components.
|
|
6
|
-
*/
|
|
7
|
-
export enum SearchTheme {
|
|
8
|
-
Light = 'light',
|
|
9
|
-
Dark = 'dark',
|
|
10
|
-
Transparent = 'transparent',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated ⚠️ `SearchThemeAttributes` is deprecated and will be removed in a future major version. Please our CSS tokens to theme components.
|
|
15
|
-
*/
|
|
16
|
-
export interface SearchThemeAttributes {
|
|
17
|
-
background?: string;
|
|
18
|
-
backgroundFocus?: string;
|
|
19
|
-
backgroundHover?: string;
|
|
20
|
-
color?: string;
|
|
21
|
-
colorFocus?: string;
|
|
22
|
-
placeholderColor?: string;
|
|
23
|
-
placeholderColorFocus?: string;
|
|
24
|
-
boxShadow?: string;
|
|
25
|
-
boxShadowFocus?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated ⚠️ `SearchThemes` is deprecated and will be removed in a future major version. Please our CSS tokens to theme components.
|
|
30
|
-
*/
|
|
31
|
-
export interface SearchThemes {
|
|
32
|
-
[key: string]: SearchThemeAttributes;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @deprecated ⚠️ `searchThemes` is deprecated and will be removed in a future major version. Please our CSS tokens to theme components.
|
|
37
|
-
*/
|
|
38
|
-
export const searchThemes: SearchThemes = {
|
|
39
|
-
[SearchTheme.Transparent]: {
|
|
40
|
-
background: 'rgba(0, 0, 0, 0)',
|
|
41
|
-
backgroundFocus: 'rgba(0, 0, 0, 0)',
|
|
42
|
-
color: colors.blackPepper300,
|
|
43
|
-
colorFocus: colors.blackPepper300,
|
|
44
|
-
placeholderColor: colors.licorice300,
|
|
45
|
-
placeholderColorFocus: colors.licorice300,
|
|
46
|
-
boxShadow: 'none',
|
|
47
|
-
boxShadowFocus: 'none',
|
|
48
|
-
},
|
|
49
|
-
[SearchTheme.Light]: {
|
|
50
|
-
background: colors.soap200,
|
|
51
|
-
backgroundFocus: colors.soap200,
|
|
52
|
-
backgroundHover: colors.soap300,
|
|
53
|
-
color: colors.blackPepper300,
|
|
54
|
-
placeholderColor: colors.licorice300,
|
|
55
|
-
boxShadow: 'none',
|
|
56
|
-
boxShadowFocus: focusRing().boxShadow as SearchThemeAttributes['boxShadowFocus'],
|
|
57
|
-
},
|
|
58
|
-
[SearchTheme.Dark]: {
|
|
59
|
-
background: 'rgba(0, 0, 0, 0.2)',
|
|
60
|
-
backgroundFocus: colors.frenchVanilla100,
|
|
61
|
-
color: colors.frenchVanilla100,
|
|
62
|
-
colorFocus: colors.blackPepper300,
|
|
63
|
-
placeholderColor: colors.frenchVanilla100,
|
|
64
|
-
placeholderColorFocus: colors.licorice300,
|
|
65
|
-
boxShadow: 'none',
|
|
66
|
-
},
|
|
67
|
-
};
|