@workday/canvas-kit-labs-react 15.0.0-alpha.1303-next.0 → 15.0.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/ai-ingress-button/lib/AIIngressButton.tsx +22 -20
- package/ai-ingress-button/lib/AIIngressIcon.tsx +2 -2
- package/common/lib/theming/useThemeRTL.ts +3 -2
- package/dist/commonjs/ai-ingress-button/lib/AIIngressButton.d.ts +36 -44
- package/dist/commonjs/ai-ingress-button/lib/AIIngressButton.d.ts.map +1 -1
- package/dist/commonjs/ai-ingress-button/lib/AIIngressButton.js +18 -18
- package/dist/commonjs/ai-ingress-button/lib/AIIngressIcon.d.ts.map +1 -1
- package/dist/commonjs/ai-ingress-button/lib/AIIngressIcon.js +1 -1
- package/dist/commonjs/common/lib/theming/useThemeRTL.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/useThemeRTL.js +1 -1
- 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/version/lib/version.js +1 -1
- package/dist/es6/ai-ingress-button/lib/AIIngressButton.d.ts +36 -44
- package/dist/es6/ai-ingress-button/lib/AIIngressButton.d.ts.map +1 -1
- package/dist/es6/ai-ingress-button/lib/AIIngressButton.js +19 -19
- package/dist/es6/ai-ingress-button/lib/AIIngressIcon.d.ts.map +1 -1
- package/dist/es6/ai-ingress-button/lib/AIIngressIcon.js +1 -1
- package/dist/es6/common/lib/theming/useThemeRTL.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/useThemeRTL.js +1 -1
- 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/version/lib/version.js +1 -1
- package/index.ts +0 -2
- package/package.json +8 -8
- 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,45 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createComponent, focusRing, useUniqueId } from '@workday/canvas-kit-react/common';
|
|
3
2
|
import { BaseButton, buttonStencil } from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {
|
|
5
|
-
import { system, base } from '@workday/canvas-tokens-web';
|
|
3
|
+
import { createComponent, focusRing, useUniqueId } from '@workday/canvas-kit-react/common';
|
|
6
4
|
import { systemIconStencil } from '@workday/canvas-kit-react/icon';
|
|
5
|
+
import { calc, createStencil, handleCsProp } from '@workday/canvas-kit-styling';
|
|
6
|
+
import { base, system } from '@workday/canvas-tokens-web';
|
|
7
7
|
import { getAIIngressIcon } from './AIIngressIcon';
|
|
8
8
|
/**
|
|
9
9
|
* Icon gradient colors
|
|
10
10
|
*/
|
|
11
|
-
const illuminateStopColor1 = base.red200; //'#FFA198'
|
|
12
|
-
const illuminateStopColor2 = base.orange200; //'#FFCAA0'
|
|
13
|
-
const illuminateStopColor3 = base.orange200; //'#FFCA79'
|
|
14
|
-
const illuminateStopColor4 = base.amber200; //'#FDCA44'
|
|
15
|
-
const illuminateStopColor5 = base.amber300; //'#FFB74D';
|
|
11
|
+
const illuminateStopColor1 = base.legacy.red200; //'#FFA198'
|
|
12
|
+
const illuminateStopColor2 = base.legacy.orange200; //'#FFCAA0'
|
|
13
|
+
const illuminateStopColor3 = base.legacy.orange200; //'#FFCA79'
|
|
14
|
+
const illuminateStopColor4 = base.legacy.amber200; //'#FDCA44'
|
|
15
|
+
const illuminateStopColor5 = base.legacy.amber300; //'#FFB74D';
|
|
16
16
|
/**
|
|
17
17
|
* Box shadow glow colors
|
|
18
18
|
*/
|
|
19
|
-
const glowEraser = base.magenta200; //'#FFC2FD';
|
|
20
|
-
const glowHighlighter = base.amber100; //'#FFF3A8';
|
|
21
|
-
const glowLunchBreak = base.amber300; //'#FEC10B';
|
|
22
|
-
const glowHappyHour = base.orange400; //'#FD7E00';
|
|
23
|
-
const glowThumbtack = base.coral500; //'#FC5B05';
|
|
19
|
+
const glowEraser = base.legacy.magenta200; //'#FFC2FD';
|
|
20
|
+
const glowHighlighter = base.legacy.amber100; //'#FFF3A8';
|
|
21
|
+
const glowLunchBreak = base.legacy.amber300; //'#FEC10B';
|
|
22
|
+
const glowHappyHour = base.legacy.orange400; //'#FD7E00';
|
|
23
|
+
const glowThumbtack = base.legacy.coral500; //'#FC5B05';
|
|
24
24
|
export const AIIngressButtonStencil = createStencil({
|
|
25
25
|
extends: buttonStencil,
|
|
26
|
-
base: { name: "
|
|
26
|
+
base: { name: "e9xvb", styles: "box-sizing:border-box;--background-button-c26182:var(--cnvs-sys-color-accent-ai, var(--cnvs-sys-color-bg-ai-stronger, oklch(0.2452 0.0752 254.55 / 1)));border-radius:var(--cnvs-sys-shape-full, var(--cnvs-sys-shape-round, 65rem));height:calc(var(--cnvs-sys-size-md, var(--cnvs-sys-space-x10, 2.5rem)) + var(--cnvs-base-size-50, 0.25rem));width:calc(var(--cnvs-sys-size-md, var(--cnvs-sys-space-x10, 2.5rem)) + var(--cnvs-base-size-50, 0.25rem));transition:box-shadow 300ms ease-out, background 300ms ease-out;.wd-icon-ai-ingress-button{.wd-icon-fill{transition:fill 300ms ease-out;}> linearGradient > stop{transition:300ms ease-out;stop-color:var(--cnvs-sys-color-fg-inverse);}}&:is(:hover, .hover):not(:disabled, .disabled){.wd-icon-ai-ingress-button{linearGradient > stop:first-child{stop-color:var(--cnvs-base-palette-red-200, oklch(0.8339 0.092 28.19 / 1));}linearGradient > stop:nth-child(2){stop-color:var(--cnvs-base-palette-orange-200, oklch(0.8606 0.1002 65.34 / 1));}linearGradient > stop:nth-child(3){stop-color:var(--cnvs-base-palette-orange-200, oklch(0.8606 0.1002 65.34 / 1));}linearGradient > stop:nth-child(4){stop-color:var(--cnvs-base-palette-amber-200, oklch(0.9191 0.1547 99.7 / 1));}linearGradient > stop:nth-child(5){stop-color:var(--cnvs-base-palette-amber-300, oklch(0.8432 0.1713 85.24 / 1));}}}&:disabled, &:disabled:active, &.disabled{opacity:var(--cnvs-sys-opacity-disabled);}&:is(:focus-visible, .focus):not(:disabled, .disabled){box-shadow:0 0 0 0px var(--cnvs-sys-color-border-inverse-default, var(--cnvs-base-palette-neutral-0)), 0 0 0 2px var(--cnvs-brand-common-focus-outline, rgba(8,117,225,1));}" },
|
|
27
27
|
modifiers: {
|
|
28
28
|
variant: {
|
|
29
|
-
inverse: { name: "
|
|
29
|
+
inverse: { name: "1tpq7e", styles: "--background-button-c26182:var(--cnvs-sys-color-bg-default);.wd-icon-ai-ingress-button{.wd-icon-fill{transition:fill 300ms ease-out;}> linearGradient > stop{transition:300ms ease-out;stop-color:var(--cnvs-sys-color-fg-ai);}}&:is(:hover, .hover):not(:disabled, .disabled){.wd-icon-ai-ingress-button{linearGradient > stop:first-child{stop-color:var(--cnvs-base-palette-red-200, oklch(0.8339 0.092 28.19 / 1));}linearGradient > stop:nth-child(2){stop-color:var(--cnvs-base-palette-orange-200, oklch(0.8606 0.1002 65.34 / 1));}linearGradient > stop:nth-child(3){stop-color:var(--cnvs-base-palette-orange-200, oklch(0.8606 0.1002 65.34 / 1));}linearGradient > stop:nth-child(4){stop-color:var(--cnvs-base-palette-amber-200, oklch(0.9191 0.1547 99.7 / 1));}linearGradient > stop:nth-child(5){stop-color:var(--cnvs-base-palette-amber-300, oklch(0.8432 0.1713 85.24 / 1));}}}&:is(:focus-visible, .focus):not(:disabled, .disabled){box-shadow:0 0 0 0px var(--cnvs-sys-color-border-inverse-default, var(--cnvs-base-palette-neutral-0)), 0 0 0 2px var(--cnvs-sys-color-fg-inverse);border:2px solid var(--cnvs-sys-color-accent-ai, var(--cnvs-sys-color-bg-ai-stronger, oklch(0.2452 0.0752 254.55 / 1))) ;}" }
|
|
30
30
|
},
|
|
31
31
|
toggled: {
|
|
32
|
-
true: { name: "
|
|
33
|
-
false: { name: "
|
|
32
|
+
true: { name: "2r27a8", styles: "--background-button-c26182:var(--cnvs-sys-color-bg-default);transition:box-shadow 300ms ease-out, background 300ms ease-out;box-shadow:0px 0px 4.9px 0px var(--cnvs-base-palette-magenta-200, oklch(0.887 0.1029 327.44 / 1)), 0px 0px 0.98px 0px var(--cnvs-base-palette-amber-100, oklch(0.9567 0.0948 100.22 / 1)), 0px 0px 1.96px 0px var(--cnvs-base-palette-amber-300, oklch(0.8432 0.1713 85.24 / 1)), 0px 0px 2.94px 0px var(--cnvs-base-palette-amber-300, oklch(0.8432 0.1713 85.24 / 1)), 0px 0px 4.9px 0px var(--cnvs-base-palette-orange-400, oklch(0.7261 0.1852 52.58 / 1)), 0px 0px 7.36px 0px var(--cnvs-base-palette-coral-500, oklch(0.6779 0.2096 40.36 / 1)), 0px 0px 9.81px 0px var(--cnvs-base-palette-magenta-200, oklch(0.887 0.1029 327.44 / 1)), 0px 0px 12.26px 0px rgba(255, 194, 253, 0.50);.wd-icon-ai-ingress-button{.wd-icon-fill{transition:fill 300ms ease-out;}> linearGradient > stop{transition:300ms ease-out;stop-color:var(--cnvs-sys-color-fg-ai);}}> linearGradient > stop{transition:300ms ease-out;stop-color:var(--cnvs-sys-color-fg-ai);}&:is(:focus-visible, .focus):not(:disabled, .disabled){box-shadow:0 0 0 2px var(--cnvs-sys-color-border-inverse-default, var(--cnvs-base-palette-neutral-0)), 0 0 0 4px var(--cnvs-brand-common-focus-outline, rgba(8,117,225,1));border:1px solid var(--cnvs-sys-color-border-strong, var(--cnvs-sys-color-border-container, oklch(0.2442 0.0693 257.66 / 0.21))) ;}" },
|
|
33
|
+
false: { name: "4bt68m", styles: "transition:box-shadow 300ms ease-out, background 300ms ease-out;" }
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
compound: [
|
|
37
37
|
{
|
|
38
38
|
modifiers: { toggled: true, variant: 'inverse' },
|
|
39
|
-
styles: { name: "
|
|
39
|
+
styles: { name: "1ipp78", styles: "--background-button-c26182:var(--cnvs-sys-color-accent-ai, var(--cnvs-sys-color-bg-ai-stronger, oklch(0.2452 0.0752 254.55 / 1)));.wd-icon-ai-ingress-button{.wd-icon-fill{transition:fill 300ms ease-out;}> linearGradient > stop{transition:300ms ease-out;stop-color:var(--cnvs-sys-color-fg-inverse);}}&:is(:focus-visible, .focus):not(:disabled, .disabled){box-shadow:0 0 0 0px var(--cnvs-sys-color-border-inverse-default, var(--cnvs-base-palette-neutral-0)), 0 0 0 2px var(--cnvs-sys-color-fg-inverse);border:none;}" }
|
|
40
40
|
}
|
|
41
41
|
]
|
|
42
|
-
}, "a-i-ingress-button-
|
|
42
|
+
}, "a-i-ingress-button-5576f1");
|
|
43
43
|
export const AIIngressButton = createComponent('button')({
|
|
44
44
|
displayName: 'AIIngressButton',
|
|
45
45
|
Component: ({ toggled, variant, ...elemProps }, ref, Element) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIIngressIcon.d.ts","sourceRoot":"","sources":["../../../../ai-ingress-button/lib/AIIngressIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AIIngressIcon.d.ts","sourceRoot":"","sources":["../../../../ai-ingress-button/lib/AIIngressIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE/E,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,gBAiBhD,CAAC"}
|
|
@@ -3,7 +3,7 @@ export const getAIIngressIcon = (svgId) => {
|
|
|
3
3
|
return {
|
|
4
4
|
name: 'AIIngressButton',
|
|
5
5
|
type: CanvasIconTypes.System,
|
|
6
|
-
svg: `<svg class="wd-icon-ai-ingress-button" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" >
|
|
6
|
+
svg: `<svg class="wd-icon-ai-ingress-button wd-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" >
|
|
7
7
|
<linearGradient id="${svgId}" x1="10" y1="0.000195292" x2="10" y2="19.9998" gradientUnits="userSpaceOnUse">
|
|
8
8
|
<stop />
|
|
9
9
|
<stop offset="0.25"/>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThemeRTL.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/useThemeRTL.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useThemeRTL.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/useThemeRTL.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAc5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,WAAW;6BAMD,aAAa,EAAE;;EAYxC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useIsRTL, useTheme } from '@workday/canvas-kit-react/common';
|
|
2
1
|
import { useMemo } from 'react';
|
|
3
2
|
import rtlCSSJS from 'rtl-css-js';
|
|
3
|
+
import { useIsRTL, useTheme } from '@workday/canvas-kit-react/common';
|
|
4
4
|
const getDirectionalStyles = (isRTL, ...styles) => {
|
|
5
5
|
return isRTL ? rtlCSSJS(styles) : styles;
|
|
6
6
|
};
|
package/dist/es6/index.d.ts
CHANGED
package/dist/es6/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC"}
|
package/dist/es6/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '
|
|
1
|
+
export const version = '15.0.0';
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-labs-react",
|
|
3
|
-
"version": "15.0.0
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "Canvas Kit Labs is an incubator for new and experimental components. Since we have a rather rigorous process for getting components in at a production level, it can be valuable to make them available earlier while we continuously iterate on the API/functionality. The Labs modules allow us to do that as needed.",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"types": "dist/es6/index.d.ts",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/
|
|
13
|
+
"url": "https://github.com/Workday/canvas-kit.git",
|
|
14
14
|
"directory": "modules/labs-react"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@emotion/react": "^11.7.1",
|
|
50
50
|
"@emotion/styled": "^11.6.0",
|
|
51
|
-
"@workday/canvas-kit-react": "^15.0.0
|
|
52
|
-
"@workday/canvas-kit-styling": "^15.0.0
|
|
53
|
-
"@workday/canvas-system-icons-web": "
|
|
54
|
-
"@workday/canvas-tokens-web": "
|
|
55
|
-
"@workday/design-assets-types": "^0.
|
|
51
|
+
"@workday/canvas-kit-react": "^15.0.0",
|
|
52
|
+
"@workday/canvas-kit-styling": "^15.0.0",
|
|
53
|
+
"@workday/canvas-system-icons-web": "4.0.2",
|
|
54
|
+
"@workday/canvas-tokens-web": "4.3.0",
|
|
55
|
+
"@workday/design-assets-types": "^0.3.0",
|
|
56
56
|
"chroma-js": "^2.2.0",
|
|
57
57
|
"lodash.flatten": "^4.4.0",
|
|
58
58
|
"rtl-css-js": "^1.14.1"
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/lodash.flatten": "^4.4.6"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "d7401bd7648fa6dbe66fdf3400e05770b77b030b"
|
|
64
64
|
}
|
package/combobox/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/Combobox';
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import React, {Fragment, useState} from 'react';
|
|
2
|
-
import styled from '@emotion/styled';
|
|
3
|
-
import {space} from '@workday/canvas-kit-react/tokens';
|
|
4
|
-
import {accessibleHide, generateUniqueId} from '@workday/canvas-kit-react/common';
|
|
5
|
-
import {ComboBoxMenuItemGroup, getOptionId, listBoxIdPart, getTextFromElement} from './Combobox';
|
|
6
|
-
|
|
7
|
-
const Autocomplete = styled('ul')({
|
|
8
|
-
margin: 0,
|
|
9
|
-
maxHeight: 200,
|
|
10
|
-
boxSizing: 'border-box',
|
|
11
|
-
overflowY: 'auto',
|
|
12
|
-
padding: `${space.xxs} 0`,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const AccessibleHide = styled('span')(accessibleHide);
|
|
16
|
-
|
|
17
|
-
interface AutocompleteListProps {
|
|
18
|
-
/**
|
|
19
|
-
* The autocomplete items of the Combobox. This array of menu items is shown under the text input.
|
|
20
|
-
*/
|
|
21
|
-
autocompleteItems: React.ReactElement<any>[] | ComboBoxMenuItemGroup[];
|
|
22
|
-
/**
|
|
23
|
-
* Index of the active autocomplete item
|
|
24
|
-
*/
|
|
25
|
-
selectedIndex: number | null;
|
|
26
|
-
/**
|
|
27
|
-
* The function called when an autocomplete item is selected
|
|
28
|
-
*/
|
|
29
|
-
handleAutocompleteClick: (
|
|
30
|
-
event: React.SyntheticEvent<Element, Event>,
|
|
31
|
-
menuItemProps: any
|
|
32
|
-
) => void;
|
|
33
|
-
/**
|
|
34
|
-
* The id of the form field.
|
|
35
|
-
*/
|
|
36
|
-
labelId: string;
|
|
37
|
-
/**
|
|
38
|
-
* The id of the combobox.
|
|
39
|
-
*/
|
|
40
|
-
comboboxId: string;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* True when group changes via keyboard control
|
|
44
|
-
*/
|
|
45
|
-
showGroupText: boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @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.
|
|
50
|
-
*/
|
|
51
|
-
export const AutocompleteList = ({
|
|
52
|
-
autocompleteItems,
|
|
53
|
-
comboboxId,
|
|
54
|
-
selectedIndex,
|
|
55
|
-
handleAutocompleteClick,
|
|
56
|
-
labelId,
|
|
57
|
-
showGroupText,
|
|
58
|
-
}: AutocompleteListProps) => {
|
|
59
|
-
const [randomComponentId] = useState(generateUniqueId); // https://codesandbox.io/s/p2ndq
|
|
60
|
-
|
|
61
|
-
const componentId = comboboxId || randomComponentId;
|
|
62
|
-
|
|
63
|
-
const listBoxProps = {
|
|
64
|
-
role: 'listbox',
|
|
65
|
-
id: `${componentId}-${listBoxIdPart}`,
|
|
66
|
-
'aria-labelledby': labelId,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const createListItem = (
|
|
70
|
-
listboxItem: React.ReactElement<any>,
|
|
71
|
-
itemIndex: number,
|
|
72
|
-
groupMessage?: string
|
|
73
|
-
) => {
|
|
74
|
-
const children = [
|
|
75
|
-
<AccessibleHide key={`group-message-${itemIndex}`}>{groupMessage}</AccessibleHide>,
|
|
76
|
-
...React.Children.toArray(listboxItem.props.children),
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<Fragment key={itemIndex}>
|
|
81
|
-
{React.cloneElement(listboxItem, {
|
|
82
|
-
children: children,
|
|
83
|
-
id: getOptionId(componentId, itemIndex),
|
|
84
|
-
role: 'option',
|
|
85
|
-
isFocused: selectedIndex === itemIndex,
|
|
86
|
-
'aria-selected': selectedIndex === itemIndex ? true : undefined,
|
|
87
|
-
onMouseDown: (event: React.MouseEvent) => {
|
|
88
|
-
// prevent focus from shifting away from the the combobox
|
|
89
|
-
event.preventDefault();
|
|
90
|
-
},
|
|
91
|
-
onClick: (event: React.MouseEvent) => {
|
|
92
|
-
event.preventDefault();
|
|
93
|
-
handleAutocompleteClick(event, listboxItem.props);
|
|
94
|
-
},
|
|
95
|
-
})}
|
|
96
|
-
</Fragment>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
if (!autocompleteItems.length) {
|
|
101
|
-
return null;
|
|
102
|
-
} else if (autocompleteItems[0].hasOwnProperty('header')) {
|
|
103
|
-
let itemIndex = 0;
|
|
104
|
-
return (
|
|
105
|
-
<Autocomplete {...listBoxProps}>
|
|
106
|
-
{(autocompleteItems as ComboBoxMenuItemGroup[]).map(({header, items}, groupIndex) => {
|
|
107
|
-
const groupLabel = `itemGroup-${componentId}-${groupIndex}`;
|
|
108
|
-
return (
|
|
109
|
-
<Fragment key={groupLabel}>
|
|
110
|
-
{React.cloneElement(header, {
|
|
111
|
-
role: 'presentation',
|
|
112
|
-
style: {pointerEvents: `none`},
|
|
113
|
-
})}
|
|
114
|
-
{items.map((listboxItem: React.ReactElement) => {
|
|
115
|
-
const headerName = getTextFromElement(header);
|
|
116
|
-
const groupMessage = showGroupText
|
|
117
|
-
? `Entering group ${headerName}, with ${items.length} options.`
|
|
118
|
-
: undefined;
|
|
119
|
-
const item = createListItem(listboxItem, itemIndex, groupMessage);
|
|
120
|
-
itemIndex++;
|
|
121
|
-
return item;
|
|
122
|
-
})}
|
|
123
|
-
</Fragment>
|
|
124
|
-
);
|
|
125
|
-
})}
|
|
126
|
-
</Autocomplete>
|
|
127
|
-
);
|
|
128
|
-
} else {
|
|
129
|
-
return (
|
|
130
|
-
<Autocomplete {...listBoxProps}>
|
|
131
|
-
{(autocompleteItems as React.ReactElement<any>[]).map(
|
|
132
|
-
(listboxItem: React.ReactElement, index: number) => createListItem(listboxItem, index)
|
|
133
|
-
)}
|
|
134
|
-
</Autocomplete>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
};
|