@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.
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,101 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.AutocompleteList = void 0;
30
- const jsx_runtime_1 = require("react/jsx-runtime");
31
- const react_1 = __importStar(require("react"));
32
- const styled_1 = __importDefault(require("@emotion/styled"));
33
- const tokens_1 = require("@workday/canvas-kit-react/tokens");
34
- const common_1 = require("@workday/canvas-kit-react/common");
35
- const Combobox_1 = require("./Combobox");
36
- const Autocomplete = (0, styled_1.default)('ul')({
37
- margin: 0,
38
- maxHeight: 200,
39
- boxSizing: 'border-box',
40
- overflowY: 'auto',
41
- padding: `${tokens_1.space.xxs} 0`,
42
- });
43
- const AccessibleHide = (0, styled_1.default)('span')(common_1.accessibleHide);
44
- /**
45
- * @deprecated ⚠️ `AutocompleteList` 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.
46
- */
47
- const AutocompleteList = ({ autocompleteItems, comboboxId, selectedIndex, handleAutocompleteClick, labelId, showGroupText, }) => {
48
- const [randomComponentId] = (0, react_1.useState)(common_1.generateUniqueId); // https://codesandbox.io/s/p2ndq
49
- const componentId = comboboxId || randomComponentId;
50
- const listBoxProps = {
51
- role: 'listbox',
52
- id: `${componentId}-${Combobox_1.listBoxIdPart}`,
53
- 'aria-labelledby': labelId,
54
- };
55
- const createListItem = (listboxItem, itemIndex, groupMessage) => {
56
- const children = [
57
- (0, jsx_runtime_1.jsx)(AccessibleHide, { children: groupMessage }, `group-message-${itemIndex}`),
58
- ...react_1.default.Children.toArray(listboxItem.props.children),
59
- ];
60
- return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: react_1.default.cloneElement(listboxItem, {
61
- children: children,
62
- id: (0, Combobox_1.getOptionId)(componentId, itemIndex),
63
- role: 'option',
64
- isFocused: selectedIndex === itemIndex,
65
- 'aria-selected': selectedIndex === itemIndex ? true : undefined,
66
- onMouseDown: (event) => {
67
- // prevent focus from shifting away from the the combobox
68
- event.preventDefault();
69
- },
70
- onClick: (event) => {
71
- event.preventDefault();
72
- handleAutocompleteClick(event, listboxItem.props);
73
- },
74
- }) }, itemIndex));
75
- };
76
- if (!autocompleteItems.length) {
77
- return null;
78
- }
79
- else if (autocompleteItems[0].hasOwnProperty('header')) {
80
- let itemIndex = 0;
81
- return ((0, jsx_runtime_1.jsx)(Autocomplete, { ...listBoxProps, children: autocompleteItems.map(({ header, items }, groupIndex) => {
82
- const groupLabel = `itemGroup-${componentId}-${groupIndex}`;
83
- return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [react_1.default.cloneElement(header, {
84
- role: 'presentation',
85
- style: { pointerEvents: `none` },
86
- }), items.map((listboxItem) => {
87
- const headerName = (0, Combobox_1.getTextFromElement)(header);
88
- const groupMessage = showGroupText
89
- ? `Entering group ${headerName}, with ${items.length} options.`
90
- : undefined;
91
- const item = createListItem(listboxItem, itemIndex, groupMessage);
92
- itemIndex++;
93
- return item;
94
- })] }, groupLabel));
95
- }) }));
96
- }
97
- else {
98
- return ((0, jsx_runtime_1.jsx)(Autocomplete, { ...listBoxProps, children: autocompleteItems.map((listboxItem, index) => createListItem(listboxItem, index)) }));
99
- }
100
- };
101
- exports.AutocompleteList = AutocompleteList;
@@ -1,79 +0,0 @@
1
- import React from 'react';
2
- import { GrowthBehavior } from '@workday/canvas-kit-react/common';
3
- import { TertiaryButtonProps } from '@workday/canvas-kit-react/button';
4
- import { TextInputProps } from '@workday/canvas-kit-react/text-input';
5
- /**
6
- * @deprecated ⚠️ `ComboBoxMenuItemGroup` 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.
7
- */
8
- export interface ComboBoxMenuItemGroup {
9
- header: React.ReactElement<any>;
10
- items: React.ReactElement<any>[];
11
- }
12
- /**
13
- * @deprecated ⚠️ `ComboboxProps` 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 interface ComboboxProps extends GrowthBehavior, React.HTMLAttributes<HTMLElement> {
16
- /**
17
- * The TextInput child of the Combobox.
18
- */
19
- children: React.ReactElement<TextInputProps>;
20
- /**
21
- * The initial value of the Combobox.
22
- */
23
- initialValue?: string;
24
- /**
25
- * The variant of the Combobox clear button. The default is a TertiaryButton
26
- */
27
- clearButtonVariant?: TertiaryButtonProps['variant'];
28
- /**
29
- * If true, render the Combobox with a button to clear the text input.
30
- * @default false
31
- */
32
- showClearButton?: boolean;
33
- /**
34
- * The `aria-label` for the Combobox clear button.
35
- * @default Reset Search Input
36
- */
37
- clearButtonAriaLabel?: string;
38
- /**
39
- * The autocomplete items of the Combobox. This array of menu items is shown under the text input.
40
- */
41
- autocompleteItems?: React.ReactElement<any>[] | ComboBoxMenuItemGroup[];
42
- /**
43
- * The function called when the Combobox text input changes.
44
- */
45
- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
46
- /**
47
- * The function called when the Combobox text input focuses.
48
- */
49
- onFocus?: React.FocusEventHandler;
50
- /**
51
- * The function called when the Combobox text input blurs.
52
- */
53
- onBlur?: React.FocusEventHandler;
54
- /**
55
- * The id of the form field.
56
- */
57
- labelId?: string;
58
- /**
59
- * The text for screen readers announcing the autocomplete count
60
- */
61
- getStatusText?: (listCount: number) => string;
62
- }
63
- /**
64
- * @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.
65
- */
66
- export declare const listBoxIdPart = "listbox";
67
- /**
68
- * @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.
69
- */
70
- export declare const getOptionId: (baseId?: string, index?: number) => string;
71
- /**
72
- * @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.
73
- */
74
- export declare const getTextFromElement: (children?: React.ReactNode) => string;
75
- /**
76
- * @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.
77
- */
78
- export declare const Combobox: ({ autocompleteItems, children, grow, initialValue, onChange, onFocus, onBlur, showClearButton, clearButtonVariant, clearButtonAriaLabel, labelId, getStatusText, id, ...elemProps }: ComboboxProps) => import("react/jsx-runtime").JSX.Element;
79
- //# sourceMappingURL=Combobox.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../../../combobox/lib/Combobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkE,MAAM,OAAO,CAAC;AAEvF,OAAO,EACL,cAAc,EAKf,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAiB,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAErF,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AAKpE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAEpC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAEhC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IACtF;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAC7C;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,kBAAkB,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACpD;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,GAAG,qBAAqB,EAAE,CAAC;IACxE;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC5D;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAClC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/C;AA6DD;;GAEG;AACH,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,WAAW,YAAa,MAAM,UAAU,MAAM,WACrB,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,kBAAkB,cAAe,MAAM,SAAS,WAc5D,CAAC;AAYF;;GAEG;AACH,eAAO,MAAM,QAAQ,wLAelB,aAAa,4CAmTf,CAAC"}
@@ -1,349 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Combobox = exports.getTextFromElement = exports.getOptionId = exports.listBoxIdPart = void 0;
30
- const jsx_runtime_1 = require("react/jsx-runtime");
31
- const react_1 = __importStar(require("react"));
32
- const react_2 = require("@emotion/react");
33
- const common_1 = require("@workday/canvas-kit-react/common");
34
- const tokens_1 = require("@workday/canvas-kit-react/tokens");
35
- const card_1 = require("@workday/canvas-kit-react/card");
36
- const button_1 = require("@workday/canvas-kit-react/button");
37
- const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
38
- const lodash_flatten_1 = __importDefault(require("lodash.flatten"));
39
- const AutocompleteList_1 = require("./AutocompleteList");
40
- const Status_1 = require("./Status");
41
- const Container = (0, common_1.styled)('div')({
42
- display: 'inline-block',
43
- }, ({ grow }) => ({
44
- width: grow ? '100%' : 'auto',
45
- }));
46
- const InputContainer = (0, common_1.styled)('div')({
47
- display: `flex`,
48
- alignItems: `center`,
49
- position: 'relative',
50
- });
51
- const fadeInKeyframes = (0, react_2.keyframes)({
52
- '0%': {
53
- opacity: 0,
54
- },
55
- '100%': {
56
- opacity: 1,
57
- },
58
- });
59
- const MenuContainer = (0, common_1.styled)(card_1.Card)({
60
- position: 'absolute',
61
- zIndex: 1,
62
- left: 0,
63
- top: '100%',
64
- borderRadius: tokens_1.borderRadius.m,
65
- background: tokens_1.commonColors.background,
66
- border: `none`,
67
- marginTop: `-${tokens_1.borderRadius.m}`,
68
- width: '100%',
69
- minWidth: 0,
70
- animation: `${fadeInKeyframes} 200ms ease-out`,
71
- maxHeight: 200,
72
- overflow: 'hidden',
73
- });
74
- const ResetButton = (0, common_1.styled)(button_1.TertiaryButton, {
75
- shouldForwardProp: (0, common_1.filterOutProps)(['shouldShow']),
76
- })({
77
- position: 'absolute',
78
- margin: `auto ${tokens_1.space.xxxs}`,
79
- top: 0,
80
- bottom: 0,
81
- right: 0,
82
- padding: 0,
83
- zIndex: 2,
84
- transition: 'opacity 120ms',
85
- }, ({ shouldShow }) => ({
86
- visibility: shouldShow ? 'visible' : 'hidden',
87
- opacity: shouldShow ? 1 : 0,
88
- }));
89
- /**
90
- * @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.
91
- */
92
- exports.listBoxIdPart = `listbox`;
93
- const optionIdPart = `option`;
94
- /**
95
- * @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.
96
- */
97
- const getOptionId = (baseId, index) => `${baseId}-${optionIdPart}-${index}`;
98
- exports.getOptionId = getOptionId;
99
- /**
100
- * @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.
101
- */
102
- const getTextFromElement = (children) => {
103
- let text = '';
104
- react_1.default.Children.map(children, child => {
105
- if (child == null || typeof child === 'boolean') {
106
- text += '';
107
- }
108
- else if (typeof child === 'string' || typeof child === 'number') {
109
- text += child.toString();
110
- }
111
- else if (Array.isArray(child)) {
112
- text += (0, exports.getTextFromElement)(child);
113
- }
114
- else if ('props' in child) {
115
- text += (0, exports.getTextFromElement)(child.props.children);
116
- }
117
- });
118
- return text;
119
- };
120
- exports.getTextFromElement = getTextFromElement;
121
- const buildStatusString = (listCount) => {
122
- return `There ${listCount === 1 ? 'is' : 'are'} ${listCount} suggestion${listCount === 1 ? '' : 's'}.`;
123
- };
124
- const isValidSingleChild = (child) => {
125
- return react_1.default.isValidElement(child) && react_1.default.Children.only(child);
126
- };
127
- /**
128
- * @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.
129
- */
130
- const Combobox = ({ autocompleteItems, children, grow, initialValue, onChange, onFocus, onBlur, showClearButton, clearButtonVariant = undefined, clearButtonAriaLabel = `Reset Search Input`, labelId, getStatusText = buildStatusString, id, ...elemProps }) => {
131
- const [isOpened, setIsOpened] = (0, react_1.useState)(false);
132
- const [value, _setValue] = (0, react_1.useState)(''); // Don't call _setValue directly instead call setInputValue to make sure onChange fires correctly
133
- const [showingAutocomplete, setShowingAutocomplete] = (0, react_1.useState)(false);
134
- const [selectedAutocompleteIndex, setSelectedAutocompleteIndex] = (0, react_1.useState)(null);
135
- const [interactiveAutocompleteItems, setInteractiveAutocompleteItems] = (0, react_1.useState)([]);
136
- const [announcementText, setAnnouncementText] = (0, react_1.useState)('');
137
- // Create a ref to the soon-to-be-created TextInput clone for internal use.
138
- // Use useForkRef to combine it with the ref already assigned to the original
139
- // TextInput (if it exists) to create a single callback ref which can be
140
- // forwarded to the TextInput clone.
141
- const inputRef = (0, react_1.useRef)(null);
142
- // We need access to the original TextInput's ref _property_ (not prop) so we
143
- // can combine it with the internal inputRef using useForkRef. ref isn't
144
- // listed in the ReactElement interface, but it's there, so we cast children
145
- // to satisfy TS.
146
- const elementRef = (0, common_1.useForkRef)(children.ref, inputRef);
147
- const comboboxRef = (0, react_1.useRef)(null);
148
- const randomComponentId = (0, common_1.useUniqueId)();
149
- const randomLabelId = (0, common_1.useUniqueId)();
150
- const componentId = id || randomComponentId;
151
- const formLabelId = labelId || randomLabelId;
152
- const [showGroupText, setShowGroupText] = (0, react_1.useState)(false);
153
- // We're using LayoutEffect here because of an issue with the Synthetic event system and typing a key
154
- // after the listbox has been closed. Somehow the key is ignored unless we use `useLayoutEffect`
155
- (0, react_1.useLayoutEffect)(() => {
156
- const shouldShow = interactiveAutocompleteItems.length > 0 && isOpened;
157
- setShowingAutocomplete(shouldShow);
158
- if (shouldShow) {
159
- setAnnouncementText(getStatusText(interactiveAutocompleteItems.length));
160
- }
161
- }, [getStatusText, interactiveAutocompleteItems, isOpened]);
162
- const setInputValue = (0, react_1.useCallback)((newValue) => {
163
- _setValue(newValue);
164
- const inputDomElement = inputRef.current;
165
- // Changing value prop programmatically doesn't fire an Synthetic event or trigger native onChange.
166
- // We can not just update .value= in setState because React library overrides input value setter
167
- // but we can call the function directly on the input as context.
168
- // This will cause onChange events to fire no matter how value is updated.
169
- if (inputDomElement) {
170
- const nativeInputValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(inputDomElement), 'value');
171
- if (nativeInputValue && nativeInputValue.set) {
172
- nativeInputValue.set.call(inputDomElement, newValue);
173
- }
174
- let event;
175
- if (typeof Event === 'function') {
176
- // modern browsers
177
- event = new Event('input', { bubbles: true });
178
- }
179
- else {
180
- // IE 11
181
- event = document.createEvent('Event');
182
- event.initEvent('input', true, true);
183
- }
184
- inputDomElement.dispatchEvent(event);
185
- }
186
- }, [inputRef]);
187
- (0, react_1.useEffect)(() => {
188
- if (initialValue !== null && initialValue !== undefined) {
189
- setInputValue(initialValue);
190
- }
191
- }, [initialValue, setInputValue]);
192
- (0, react_1.useEffect)(() => {
193
- const getInteractiveAutocompleteItems = () => {
194
- if (autocompleteItems &&
195
- autocompleteItems.length &&
196
- autocompleteItems[0].hasOwnProperty('header')) {
197
- return (0, lodash_flatten_1.default)(autocompleteItems.map(group => group.items));
198
- }
199
- return autocompleteItems || [];
200
- };
201
- setInteractiveAutocompleteItems(getInteractiveAutocompleteItems());
202
- }, [autocompleteItems]);
203
- const handleAutocompleteClick = (event, menuItemProps) => {
204
- if (menuItemProps.isDisabled || menuItemProps['aria-disabled']) {
205
- return;
206
- }
207
- setShowingAutocomplete(false);
208
- setIsOpened(false);
209
- setInputValue((0, exports.getTextFromElement)(menuItemProps.children));
210
- if (menuItemProps.onClick) {
211
- menuItemProps.onClick(event);
212
- }
213
- };
214
- const focusInput = () => {
215
- if (inputRef.current) {
216
- inputRef.current.focus();
217
- }
218
- };
219
- const handleClick = (event) => {
220
- if (!showingAutocomplete) {
221
- setShowingAutocomplete(true);
222
- }
223
- };
224
- const handleFocus = (event) => {
225
- setIsOpened(true);
226
- if (onFocus) {
227
- onFocus(event);
228
- }
229
- };
230
- const handleBlur = (event) => {
231
- if (comboboxRef.current) {
232
- const target = event.relatedTarget;
233
- if (target && comboboxRef.current.contains(target)) {
234
- return;
235
- }
236
- }
237
- setIsOpened(false);
238
- if (onBlur) {
239
- onBlur(event);
240
- }
241
- };
242
- const resetSearchInput = () => {
243
- setInputValue('');
244
- focusInput();
245
- };
246
- const getGroupIndex = (itemIndex) => {
247
- if (itemIndex != null &&
248
- autocompleteItems &&
249
- autocompleteItems.length &&
250
- autocompleteItems[0].hasOwnProperty('header')) {
251
- let count = 0;
252
- return autocompleteItems.findIndex(groups => {
253
- count += groups.items.length;
254
- return count > itemIndex;
255
- });
256
- }
257
- else {
258
- return -1;
259
- }
260
- };
261
- const handleKeyboardShortcuts = (event) => {
262
- if (event.ctrlKey || event.altKey || event.metaKey || !interactiveAutocompleteItems.length) {
263
- return;
264
- }
265
- const autoCompleteItemCount = interactiveAutocompleteItems.length;
266
- const firstItem = 0;
267
- const lastItem = autoCompleteItemCount - 1;
268
- let nextIndex = null;
269
- setIsOpened(true);
270
- switch (event.key) {
271
- case 'ArrowUp':
272
- case 'Up': // IE/Edge specific value
273
- const upIndex = selectedAutocompleteIndex !== null ? selectedAutocompleteIndex - 1 : lastItem;
274
- nextIndex = upIndex < 0 ? lastItem : upIndex;
275
- event.stopPropagation();
276
- event.preventDefault();
277
- break;
278
- case 'ArrowDown':
279
- case 'Down': // IE/Edge specific value
280
- const downIndex = selectedAutocompleteIndex !== null ? selectedAutocompleteIndex + 1 : firstItem;
281
- nextIndex = downIndex >= autoCompleteItemCount ? firstItem : downIndex;
282
- event.stopPropagation();
283
- event.preventDefault();
284
- break;
285
- case 'Escape':
286
- case 'Esc': // IE/Edge specific value
287
- resetSearchInput();
288
- break;
289
- case 'Enter':
290
- if (selectedAutocompleteIndex != null) {
291
- const item = interactiveAutocompleteItems[selectedAutocompleteIndex];
292
- handleAutocompleteClick(event, item.props);
293
- if (item.props.isDisabled || item.props['aria-disabled']) {
294
- nextIndex = selectedAutocompleteIndex;
295
- }
296
- event.stopPropagation();
297
- event.preventDefault();
298
- }
299
- break;
300
- default:
301
- }
302
- const lastGroupIndex = getGroupIndex(selectedAutocompleteIndex);
303
- const nextGroupIndex = getGroupIndex(nextIndex);
304
- setShowGroupText(lastGroupIndex !== nextGroupIndex);
305
- setSelectedAutocompleteIndex(nextIndex);
306
- };
307
- const handleSearchInputChange = (event) => {
308
- if (onChange) {
309
- onChange(event);
310
- }
311
- _setValue(event.target.value); // Calling set value directly only for on change event
312
- };
313
- const renderChildren = (inputElement) => {
314
- let cssOverride = { ':focus': { zIndex: 2 } };
315
- if (showClearButton) {
316
- cssOverride = {
317
- ...cssOverride,
318
- paddingInlineEnd: tokens_1.space.xl,
319
- };
320
- }
321
- const newTextInputProps = {
322
- type: 'text',
323
- grow: grow,
324
- value: value,
325
- ref: elementRef,
326
- 'aria-autocomplete': 'list',
327
- 'aria-activedescendant': selectedAutocompleteIndex !== null
328
- ? (0, exports.getOptionId)(componentId, selectedAutocompleteIndex)
329
- : undefined,
330
- onClick: handleClick,
331
- onChange: handleSearchInputChange,
332
- onKeyDown: handleKeyboardShortcuts,
333
- onFocus: handleFocus,
334
- onBlur: handleBlur,
335
- css: cssOverride,
336
- role: 'combobox',
337
- 'aria-owns': showingAutocomplete ? `${componentId}-${exports.listBoxIdPart}` : undefined,
338
- 'aria-haspopup': true,
339
- 'aria-expanded': showingAutocomplete,
340
- };
341
- const cloneElement = (element, props) => (0, react_2.jsx)(element.type, {
342
- ...element.props,
343
- ...props,
344
- });
345
- return cloneElement(inputElement, { ...inputElement.props, ...newTextInputProps });
346
- };
347
- return ((0, jsx_runtime_1.jsxs)(Container, { grow: grow, ...elemProps, children: [(0, jsx_runtime_1.jsxs)(InputContainer, { ref: comboboxRef, children: [isValidSingleChild(children) && react_1.default.Children.map(children, renderChildren), showClearButton && ((0, jsx_runtime_1.jsx)(ResetButton, { shouldShow: !!value, "aria-label": clearButtonAriaLabel, icon: canvas_system_icons_web_1.xSmallIcon, variant: clearButtonVariant, onClick: resetSearchInput, onBlur: handleBlur, "data-part": "combobox-reset-button", size: "small", type: "button" })), showingAutocomplete && autocompleteItems && ((0, jsx_runtime_1.jsx)(MenuContainer, { padding: tokens_1.space.zero, depth: 3, children: (0, jsx_runtime_1.jsx)(card_1.Card.Body, { children: (0, jsx_runtime_1.jsx)(AutocompleteList_1.AutocompleteList, { comboboxId: componentId, autocompleteItems: autocompleteItems, selectedIndex: selectedAutocompleteIndex, handleAutocompleteClick: handleAutocompleteClick, labelId: formLabelId, showGroupText: showGroupText }) }) }))] }), (0, jsx_runtime_1.jsx)(Status_1.Status, { announcementText: announcementText })] }));
348
- };
349
- exports.Combobox = Combobox;
@@ -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,29 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Status = void 0;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
8
- const react_1 = require("react");
9
- const styled_1 = __importDefault(require("@emotion/styled"));
10
- const common_1 = require("@workday/canvas-kit-react/common");
11
- const Container = (0, styled_1.default)('div')(common_1.accessibleHide);
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
- const Status = ({ ariaLive = 'polite', role = 'status', ariaRelevant = 'additions', expireMilliseconds = 500, announcementText = '', ariaAtomic, }) => {
16
- const [displayText, setDisplayText] = (0, react_1.useState)(announcementText);
17
- (0, react_1.useEffect)(() => {
18
- if (!announcementText) {
19
- return;
20
- }
21
- setDisplayText(announcementText);
22
- const clearText = setTimeout(() => setDisplayText(''), expireMilliseconds);
23
- return () => {
24
- clearTimeout(clearText);
25
- };
26
- }, [announcementText, expireMilliseconds]);
27
- return ((0, jsx_runtime_1.jsx)(Container, { "aria-live": ariaLive, role: role, "aria-relevant": ariaRelevant, "aria-atomic": ariaAtomic, children: displayText }));
28
- };
29
- exports.Status = Status;
@@ -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,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./lib/SearchForm"), exports);
18
- __exportStar(require("./lib/themes"), exports);