@workday/canvas-kit-labs-react 15.0.0-alpha.0064-next.0 → 15.0.0-alpha.0074-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.
Files changed (67) hide show
  1. package/dist/commonjs/ai-ingress-button/lib/AIIngressButton.js +5 -5
  2. package/dist/commonjs/index.d.ts +0 -2
  3. package/dist/commonjs/index.d.ts.map +1 -1
  4. package/dist/commonjs/index.js +0 -2
  5. package/dist/commonjs/side-panel/lib/SidePanel.js +7 -7
  6. package/dist/commonjs/side-panel/lib/SidePanelToggleButton.js +11 -11
  7. package/dist/commonjs/version/lib/version.js +1 -1
  8. package/dist/es6/ai-ingress-button/lib/AIIngressButton.js +5 -5
  9. package/dist/es6/index.d.ts +0 -2
  10. package/dist/es6/index.d.ts.map +1 -1
  11. package/dist/es6/index.js +0 -2
  12. package/dist/es6/side-panel/lib/SidePanel.js +7 -7
  13. package/dist/es6/side-panel/lib/SidePanelToggleButton.js +11 -11
  14. package/dist/es6/version/lib/version.js +1 -1
  15. package/index.ts +0 -2
  16. package/package.json +4 -4
  17. package/combobox/index.ts +0 -1
  18. package/combobox/lib/AutocompleteList.tsx +0 -137
  19. package/combobox/lib/Combobox.tsx +0 -505
  20. package/combobox/lib/Status.tsx +0 -52
  21. package/combobox/package.json +0 -6
  22. package/dist/commonjs/combobox/index.d.ts +0 -2
  23. package/dist/commonjs/combobox/index.d.ts.map +0 -1
  24. package/dist/commonjs/combobox/index.js +0 -17
  25. package/dist/commonjs/combobox/lib/AutocompleteList.d.ts +0 -34
  26. package/dist/commonjs/combobox/lib/AutocompleteList.d.ts.map +0 -1
  27. package/dist/commonjs/combobox/lib/AutocompleteList.js +0 -101
  28. package/dist/commonjs/combobox/lib/Combobox.d.ts +0 -79
  29. package/dist/commonjs/combobox/lib/Combobox.d.ts.map +0 -1
  30. package/dist/commonjs/combobox/lib/Combobox.js +0 -349
  31. package/dist/commonjs/combobox/lib/Status.d.ts +0 -16
  32. package/dist/commonjs/combobox/lib/Status.d.ts.map +0 -1
  33. package/dist/commonjs/combobox/lib/Status.js +0 -29
  34. package/dist/commonjs/search-form/index.d.ts +0 -3
  35. package/dist/commonjs/search-form/index.d.ts.map +0 -1
  36. package/dist/commonjs/search-form/index.js +0 -18
  37. package/dist/commonjs/search-form/lib/SearchForm.d.ts +0 -450
  38. package/dist/commonjs/search-form/lib/SearchForm.d.ts.map +0 -1
  39. package/dist/commonjs/search-form/lib/SearchForm.js +0 -236
  40. package/dist/commonjs/search-form/lib/themes.d.ts +0 -33
  41. package/dist/commonjs/search-form/lib/themes.d.ts.map +0 -1
  42. package/dist/commonjs/search-form/lib/themes.js +0 -47
  43. package/dist/es6/combobox/index.d.ts +0 -2
  44. package/dist/es6/combobox/index.d.ts.map +0 -1
  45. package/dist/es6/combobox/index.js +0 -1
  46. package/dist/es6/combobox/lib/AutocompleteList.d.ts +0 -34
  47. package/dist/es6/combobox/lib/AutocompleteList.d.ts.map +0 -1
  48. package/dist/es6/combobox/lib/AutocompleteList.js +0 -71
  49. package/dist/es6/combobox/lib/Combobox.d.ts +0 -79
  50. package/dist/es6/combobox/lib/Combobox.d.ts.map +0 -1
  51. package/dist/es6/combobox/lib/Combobox.js +0 -317
  52. package/dist/es6/combobox/lib/Status.d.ts +0 -16
  53. package/dist/es6/combobox/lib/Status.d.ts.map +0 -1
  54. package/dist/es6/combobox/lib/Status.js +0 -22
  55. package/dist/es6/search-form/index.d.ts +0 -3
  56. package/dist/es6/search-form/index.d.ts.map +0 -1
  57. package/dist/es6/search-form/index.js +0 -2
  58. package/dist/es6/search-form/lib/SearchForm.d.ts +0 -450
  59. package/dist/es6/search-form/lib/SearchForm.d.ts.map +0 -1
  60. package/dist/es6/search-form/lib/SearchForm.js +0 -207
  61. package/dist/es6/search-form/lib/themes.d.ts +0 -33
  62. package/dist/es6/search-form/lib/themes.d.ts.map +0 -1
  63. package/dist/es6/search-form/lib/themes.js +0 -44
  64. package/search-form/index.ts +0 -2
  65. package/search-form/lib/SearchForm.tsx +0 -651
  66. package/search-form/lib/themes.ts +0 -67
  67. package/search-form/package.json +0 -6
@@ -1,317 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useEffect, useLayoutEffect, useRef, useState, useCallback } from 'react';
3
- import { jsx, keyframes } from '@emotion/react';
4
- import { useForkRef, styled, useUniqueId, filterOutProps, } from '@workday/canvas-kit-react/common';
5
- import { space, commonColors, borderRadius } from '@workday/canvas-kit-react/tokens';
6
- import { Card } from '@workday/canvas-kit-react/card';
7
- import { TertiaryButton } from '@workday/canvas-kit-react/button';
8
- import { xSmallIcon } from '@workday/canvas-system-icons-web';
9
- import flatten from 'lodash.flatten';
10
- import { AutocompleteList } from './AutocompleteList';
11
- import { Status } from './Status';
12
- const Container = styled('div')({
13
- display: 'inline-block',
14
- }, ({ grow }) => ({
15
- width: grow ? '100%' : 'auto',
16
- }));
17
- const InputContainer = styled('div')({
18
- display: `flex`,
19
- alignItems: `center`,
20
- position: 'relative',
21
- });
22
- const fadeInKeyframes = keyframes({
23
- '0%': {
24
- opacity: 0,
25
- },
26
- '100%': {
27
- opacity: 1,
28
- },
29
- });
30
- const MenuContainer = styled(Card)({
31
- position: 'absolute',
32
- zIndex: 1,
33
- left: 0,
34
- top: '100%',
35
- borderRadius: borderRadius.m,
36
- background: commonColors.background,
37
- border: `none`,
38
- marginTop: `-${borderRadius.m}`,
39
- width: '100%',
40
- minWidth: 0,
41
- animation: `${fadeInKeyframes} 200ms ease-out`,
42
- maxHeight: 200,
43
- overflow: 'hidden',
44
- });
45
- const ResetButton = styled(TertiaryButton, {
46
- shouldForwardProp: filterOutProps(['shouldShow']),
47
- })({
48
- position: 'absolute',
49
- margin: `auto ${space.xxxs}`,
50
- top: 0,
51
- bottom: 0,
52
- right: 0,
53
- padding: 0,
54
- zIndex: 2,
55
- transition: 'opacity 120ms',
56
- }, ({ shouldShow }) => ({
57
- visibility: shouldShow ? 'visible' : 'hidden',
58
- opacity: shouldShow ? 1 : 0,
59
- }));
60
- /**
61
- * @deprecated ⚠️ `listBoxIdPart` in Labs has been deprecated and will be removed in a future major version. Please use [`Combobox` in Main](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs) instead.
62
- */
63
- export const listBoxIdPart = `listbox`;
64
- const optionIdPart = `option`;
65
- /**
66
- * @deprecated ⚠️ `getOptionId` in Labs has been deprecated and will be removed in a future major version. Please use [`Combobox` in Main](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs) instead.
67
- */
68
- export const getOptionId = (baseId, index) => `${baseId}-${optionIdPart}-${index}`;
69
- /**
70
- * @deprecated ⚠️ `getTextFromElement` in Labs has been deprecated and will be removed in a future major version. Please use [`Combobox` in Main](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs) instead.
71
- */
72
- export const getTextFromElement = (children) => {
73
- let text = '';
74
- React.Children.map(children, child => {
75
- if (child == null || typeof child === 'boolean') {
76
- text += '';
77
- }
78
- else if (typeof child === 'string' || typeof child === 'number') {
79
- text += child.toString();
80
- }
81
- else if (Array.isArray(child)) {
82
- text += getTextFromElement(child);
83
- }
84
- else if ('props' in child) {
85
- text += getTextFromElement(child.props.children);
86
- }
87
- });
88
- return text;
89
- };
90
- const buildStatusString = (listCount) => {
91
- return `There ${listCount === 1 ? 'is' : 'are'} ${listCount} suggestion${listCount === 1 ? '' : 's'}.`;
92
- };
93
- const isValidSingleChild = (child) => {
94
- return React.isValidElement(child) && React.Children.only(child);
95
- };
96
- /**
97
- * @deprecated ⚠️ `Combobox` in Labs has been deprecated and will be removed in a future major version. Please use [`Combobox` in Main](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs) instead.
98
- */
99
- export const Combobox = ({ autocompleteItems, children, grow, initialValue, onChange, onFocus, onBlur, showClearButton, clearButtonVariant = undefined, clearButtonAriaLabel = `Reset Search Input`, labelId, getStatusText = buildStatusString, id, ...elemProps }) => {
100
- const [isOpened, setIsOpened] = useState(false);
101
- const [value, _setValue] = useState(''); // Don't call _setValue directly instead call setInputValue to make sure onChange fires correctly
102
- const [showingAutocomplete, setShowingAutocomplete] = useState(false);
103
- const [selectedAutocompleteIndex, setSelectedAutocompleteIndex] = useState(null);
104
- const [interactiveAutocompleteItems, setInteractiveAutocompleteItems] = useState([]);
105
- const [announcementText, setAnnouncementText] = useState('');
106
- // Create a ref to the soon-to-be-created TextInput clone for internal use.
107
- // Use useForkRef to combine it with the ref already assigned to the original
108
- // TextInput (if it exists) to create a single callback ref which can be
109
- // forwarded to the TextInput clone.
110
- const inputRef = useRef(null);
111
- // We need access to the original TextInput's ref _property_ (not prop) so we
112
- // can combine it with the internal inputRef using useForkRef. ref isn't
113
- // listed in the ReactElement interface, but it's there, so we cast children
114
- // to satisfy TS.
115
- const elementRef = useForkRef(children.ref, inputRef);
116
- const comboboxRef = useRef(null);
117
- const randomComponentId = useUniqueId();
118
- const randomLabelId = useUniqueId();
119
- const componentId = id || randomComponentId;
120
- const formLabelId = labelId || randomLabelId;
121
- const [showGroupText, setShowGroupText] = useState(false);
122
- // We're using LayoutEffect here because of an issue with the Synthetic event system and typing a key
123
- // after the listbox has been closed. Somehow the key is ignored unless we use `useLayoutEffect`
124
- useLayoutEffect(() => {
125
- const shouldShow = interactiveAutocompleteItems.length > 0 && isOpened;
126
- setShowingAutocomplete(shouldShow);
127
- if (shouldShow) {
128
- setAnnouncementText(getStatusText(interactiveAutocompleteItems.length));
129
- }
130
- }, [getStatusText, interactiveAutocompleteItems, isOpened]);
131
- const setInputValue = useCallback((newValue) => {
132
- _setValue(newValue);
133
- const inputDomElement = inputRef.current;
134
- // Changing value prop programmatically doesn't fire an Synthetic event or trigger native onChange.
135
- // We can not just update .value= in setState because React library overrides input value setter
136
- // but we can call the function directly on the input as context.
137
- // This will cause onChange events to fire no matter how value is updated.
138
- if (inputDomElement) {
139
- const nativeInputValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(inputDomElement), 'value');
140
- if (nativeInputValue && nativeInputValue.set) {
141
- nativeInputValue.set.call(inputDomElement, newValue);
142
- }
143
- let event;
144
- if (typeof Event === 'function') {
145
- // modern browsers
146
- event = new Event('input', { bubbles: true });
147
- }
148
- else {
149
- // IE 11
150
- event = document.createEvent('Event');
151
- event.initEvent('input', true, true);
152
- }
153
- inputDomElement.dispatchEvent(event);
154
- }
155
- }, [inputRef]);
156
- useEffect(() => {
157
- if (initialValue !== null && initialValue !== undefined) {
158
- setInputValue(initialValue);
159
- }
160
- }, [initialValue, setInputValue]);
161
- useEffect(() => {
162
- const getInteractiveAutocompleteItems = () => {
163
- if (autocompleteItems &&
164
- autocompleteItems.length &&
165
- autocompleteItems[0].hasOwnProperty('header')) {
166
- return flatten(autocompleteItems.map(group => group.items));
167
- }
168
- return autocompleteItems || [];
169
- };
170
- setInteractiveAutocompleteItems(getInteractiveAutocompleteItems());
171
- }, [autocompleteItems]);
172
- const handleAutocompleteClick = (event, menuItemProps) => {
173
- if (menuItemProps.isDisabled || menuItemProps['aria-disabled']) {
174
- return;
175
- }
176
- setShowingAutocomplete(false);
177
- setIsOpened(false);
178
- setInputValue(getTextFromElement(menuItemProps.children));
179
- if (menuItemProps.onClick) {
180
- menuItemProps.onClick(event);
181
- }
182
- };
183
- const focusInput = () => {
184
- if (inputRef.current) {
185
- inputRef.current.focus();
186
- }
187
- };
188
- const handleClick = (event) => {
189
- if (!showingAutocomplete) {
190
- setShowingAutocomplete(true);
191
- }
192
- };
193
- const handleFocus = (event) => {
194
- setIsOpened(true);
195
- if (onFocus) {
196
- onFocus(event);
197
- }
198
- };
199
- const handleBlur = (event) => {
200
- if (comboboxRef.current) {
201
- const target = event.relatedTarget;
202
- if (target && comboboxRef.current.contains(target)) {
203
- return;
204
- }
205
- }
206
- setIsOpened(false);
207
- if (onBlur) {
208
- onBlur(event);
209
- }
210
- };
211
- const resetSearchInput = () => {
212
- setInputValue('');
213
- focusInput();
214
- };
215
- const getGroupIndex = (itemIndex) => {
216
- if (itemIndex != null &&
217
- autocompleteItems &&
218
- autocompleteItems.length &&
219
- autocompleteItems[0].hasOwnProperty('header')) {
220
- let count = 0;
221
- return autocompleteItems.findIndex(groups => {
222
- count += groups.items.length;
223
- return count > itemIndex;
224
- });
225
- }
226
- else {
227
- return -1;
228
- }
229
- };
230
- const handleKeyboardShortcuts = (event) => {
231
- if (event.ctrlKey || event.altKey || event.metaKey || !interactiveAutocompleteItems.length) {
232
- return;
233
- }
234
- const autoCompleteItemCount = interactiveAutocompleteItems.length;
235
- const firstItem = 0;
236
- const lastItem = autoCompleteItemCount - 1;
237
- let nextIndex = null;
238
- setIsOpened(true);
239
- switch (event.key) {
240
- case 'ArrowUp':
241
- case 'Up': // IE/Edge specific value
242
- const upIndex = selectedAutocompleteIndex !== null ? selectedAutocompleteIndex - 1 : lastItem;
243
- nextIndex = upIndex < 0 ? lastItem : upIndex;
244
- event.stopPropagation();
245
- event.preventDefault();
246
- break;
247
- case 'ArrowDown':
248
- case 'Down': // IE/Edge specific value
249
- const downIndex = selectedAutocompleteIndex !== null ? selectedAutocompleteIndex + 1 : firstItem;
250
- nextIndex = downIndex >= autoCompleteItemCount ? firstItem : downIndex;
251
- event.stopPropagation();
252
- event.preventDefault();
253
- break;
254
- case 'Escape':
255
- case 'Esc': // IE/Edge specific value
256
- resetSearchInput();
257
- break;
258
- case 'Enter':
259
- if (selectedAutocompleteIndex != null) {
260
- const item = interactiveAutocompleteItems[selectedAutocompleteIndex];
261
- handleAutocompleteClick(event, item.props);
262
- if (item.props.isDisabled || item.props['aria-disabled']) {
263
- nextIndex = selectedAutocompleteIndex;
264
- }
265
- event.stopPropagation();
266
- event.preventDefault();
267
- }
268
- break;
269
- default:
270
- }
271
- const lastGroupIndex = getGroupIndex(selectedAutocompleteIndex);
272
- const nextGroupIndex = getGroupIndex(nextIndex);
273
- setShowGroupText(lastGroupIndex !== nextGroupIndex);
274
- setSelectedAutocompleteIndex(nextIndex);
275
- };
276
- const handleSearchInputChange = (event) => {
277
- if (onChange) {
278
- onChange(event);
279
- }
280
- _setValue(event.target.value); // Calling set value directly only for on change event
281
- };
282
- const renderChildren = (inputElement) => {
283
- let cssOverride = { ':focus': { zIndex: 2 } };
284
- if (showClearButton) {
285
- cssOverride = {
286
- ...cssOverride,
287
- paddingInlineEnd: space.xl,
288
- };
289
- }
290
- const newTextInputProps = {
291
- type: 'text',
292
- grow: grow,
293
- value: value,
294
- ref: elementRef,
295
- 'aria-autocomplete': 'list',
296
- 'aria-activedescendant': selectedAutocompleteIndex !== null
297
- ? getOptionId(componentId, selectedAutocompleteIndex)
298
- : undefined,
299
- onClick: handleClick,
300
- onChange: handleSearchInputChange,
301
- onKeyDown: handleKeyboardShortcuts,
302
- onFocus: handleFocus,
303
- onBlur: handleBlur,
304
- css: cssOverride,
305
- role: 'combobox',
306
- 'aria-owns': showingAutocomplete ? `${componentId}-${listBoxIdPart}` : undefined,
307
- 'aria-haspopup': true,
308
- 'aria-expanded': showingAutocomplete,
309
- };
310
- const cloneElement = (element, props) => jsx(element.type, {
311
- ...element.props,
312
- ...props,
313
- });
314
- return cloneElement(inputElement, { ...inputElement.props, ...newTextInputProps });
315
- };
316
- return (_jsxs(Container, { grow: grow, ...elemProps, children: [_jsxs(InputContainer, { ref: comboboxRef, children: [isValidSingleChild(children) && React.Children.map(children, renderChildren), showClearButton && (_jsx(ResetButton, { shouldShow: !!value, "aria-label": clearButtonAriaLabel, icon: xSmallIcon, variant: clearButtonVariant, onClick: resetSearchInput, onBlur: handleBlur, "data-part": "combobox-reset-button", size: "small", type: "button" })), showingAutocomplete && autocompleteItems && (_jsx(MenuContainer, { padding: space.zero, depth: 3, children: _jsx(Card.Body, { children: _jsx(AutocompleteList, { comboboxId: componentId, autocompleteItems: autocompleteItems, selectedIndex: selectedAutocompleteIndex, handleAutocompleteClick: handleAutocompleteClick, labelId: formLabelId, showGroupText: showGroupText }) }) }))] }), _jsx(Status, { announcementText: announcementText })] }));
317
- };
@@ -1,16 +0,0 @@
1
- /**
2
- * @deprecated ⚠️ `StatusProps` in Labs has been deprecated and will be removed in a future major version. Please use [`Combobox` in Main](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs) instead.
3
- */
4
- export interface StatusProps {
5
- ariaLive?: 'polite' | 'assertive' | 'off';
6
- role?: 'log' | 'status' | 'alert' | 'progressbar' | 'marquee' | 'timer';
7
- ariaRelevant?: 'additions' | 'additions text' | 'all' | 'removals' | 'text';
8
- ariaAtomic?: boolean;
9
- expireMilliseconds?: number;
10
- announcementText?: string;
11
- }
12
- /**
13
- * @deprecated ⚠️ `Status` in Labs has been deprecated and will be removed in a future major version. Please use [`Combobox` in Main](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs) instead.
14
- */
15
- export declare const Status: ({ ariaLive, role, ariaRelevant, expireMilliseconds, announcementText, ariaAtomic, }: StatusProps) => import("react/jsx-runtime").JSX.Element;
16
- //# sourceMappingURL=Status.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Status.d.ts","sourceRoot":"","sources":["../../../../combobox/lib/Status.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;IAC1C,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC;IACxE,YAAY,CAAC,EAAE,WAAW,GAAG,gBAAgB,GAAG,KAAK,GAAG,UAAU,GAAG,MAAM,CAAC;IAC5E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAID;;GAEG;AACH,eAAO,MAAM,MAAM,wFAOhB,WAAW,4CAuBb,CAAC"}
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useState, useEffect } from 'react';
3
- import styled from '@emotion/styled';
4
- import { accessibleHide } from '@workday/canvas-kit-react/common';
5
- const Container = styled('div')(accessibleHide);
6
- /**
7
- * @deprecated ⚠️ `Status` in Labs has been deprecated and will be removed in a future major version. Please use [`Combobox` in Main](https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs) instead.
8
- */
9
- export const Status = ({ ariaLive = 'polite', role = 'status', ariaRelevant = 'additions', expireMilliseconds = 500, announcementText = '', ariaAtomic, }) => {
10
- const [displayText, setDisplayText] = useState(announcementText);
11
- useEffect(() => {
12
- if (!announcementText) {
13
- return;
14
- }
15
- setDisplayText(announcementText);
16
- const clearText = setTimeout(() => setDisplayText(''), expireMilliseconds);
17
- return () => {
18
- clearTimeout(clearText);
19
- };
20
- }, [announcementText, expireMilliseconds]);
21
- return (_jsx(Container, { "aria-live": ariaLive, role: role, "aria-relevant": ariaRelevant, "aria-atomic": ariaAtomic, children: displayText }));
22
- };
@@ -1,3 +0,0 @@
1
- export * from './lib/SearchForm';
2
- export * from './lib/themes';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../search-form/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './lib/SearchForm';
2
- export * from './lib/themes';