@workday/canvas-kit-labs-react 7.1.5 → 7.2.0-427-next.2
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/combobox/README.md +4 -4
- package/combobox/index.ts +0 -4
- package/combobox/lib/AutocompleteList.tsx +5 -8
- package/combobox/lib/Combobox.tsx +14 -20
- package/combobox/lib/Status.tsx +1 -3
- package/common/index.ts +0 -2
- package/common/lib/theming/index.ts +0 -1
- package/common/lib/theming/useThemeRTL.ts +14 -13
- package/dist/commonjs/combobox/index.d.ts +0 -3
- package/dist/commonjs/combobox/index.d.ts.map +1 -1
- package/dist/commonjs/combobox/index.js +0 -7
- package/dist/commonjs/combobox/lib/AutocompleteList.d.ts +4 -5
- package/dist/commonjs/combobox/lib/AutocompleteList.d.ts.map +1 -1
- package/dist/commonjs/combobox/lib/AutocompleteList.js +33 -53
- package/dist/commonjs/combobox/lib/Combobox.d.ts +4 -6
- package/dist/commonjs/combobox/lib/Combobox.d.ts.map +1 -1
- package/dist/commonjs/combobox/lib/Combobox.js +110 -142
- package/dist/commonjs/combobox/lib/Status.d.ts +1 -2
- package/dist/commonjs/combobox/lib/Status.d.ts.map +1 -1
- package/dist/commonjs/combobox/lib/Status.js +11 -11
- package/dist/commonjs/common/index.d.ts +0 -2
- package/dist/commonjs/common/index.d.ts.map +1 -1
- package/dist/commonjs/common/index.js +0 -5
- package/dist/commonjs/common/lib/theming/index.d.ts +0 -1
- package/dist/commonjs/common/lib/theming/index.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/index.js +0 -1
- package/dist/commonjs/common/lib/theming/useThemeRTL.d.ts +3 -0
- package/dist/commonjs/common/lib/theming/useThemeRTL.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/useThemeRTL.js +21 -46
- package/dist/commonjs/expandable/index.d.ts +3 -0
- package/dist/commonjs/expandable/index.d.ts.map +1 -0
- package/dist/commonjs/{drawer → expandable}/index.js +2 -10
- package/dist/commonjs/expandable/lib/Expandable.d.ts +108 -0
- package/dist/commonjs/expandable/lib/Expandable.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/Expandable.js +59 -0
- package/dist/commonjs/expandable/lib/ExpandableAvatar.d.ts +7 -0
- package/dist/commonjs/expandable/lib/ExpandableAvatar.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/ExpandableAvatar.js +23 -0
- package/dist/commonjs/expandable/lib/ExpandableContent.d.ts +21 -0
- package/dist/commonjs/expandable/lib/ExpandableContent.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/ExpandableContent.js +18 -0
- package/dist/commonjs/expandable/lib/ExpandableIcon.d.ts +29 -0
- package/dist/commonjs/expandable/lib/ExpandableIcon.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/ExpandableIcon.js +31 -0
- package/dist/commonjs/expandable/lib/ExpandableTarget.d.ts +33 -0
- package/dist/commonjs/expandable/lib/ExpandableTarget.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/ExpandableTarget.js +32 -0
- package/dist/commonjs/expandable/lib/ExpandableTitle.d.ts +11 -0
- package/dist/commonjs/expandable/lib/ExpandableTitle.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/ExpandableTitle.js +16 -0
- package/dist/commonjs/expandable/lib/hooks/index.d.ts +5 -0
- package/dist/commonjs/expandable/lib/hooks/index.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/hooks/index.js +16 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableContent.d.ts +18 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableContent.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableContent.js +11 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableIcon.d.ts +13 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableIcon.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableIcon.js +10 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableModel.d.ts +53 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableModel.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableModel.js +22 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableTarget.d.ts +15 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableTarget.d.ts.map +1 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableTarget.js +19 -0
- package/dist/commonjs/index.d.ts +1 -2
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +1 -2
- package/dist/commonjs/search-form/lib/SearchForm.d.ts +7 -3
- package/dist/commonjs/search-form/lib/SearchForm.d.ts.map +1 -1
- package/dist/commonjs/search-form/lib/SearchForm.js +118 -145
- package/dist/commonjs/search-form/lib/themes.js +7 -8
- package/dist/es6/combobox/index.d.ts +0 -3
- package/dist/es6/combobox/index.d.ts.map +1 -1
- package/dist/es6/combobox/index.js +0 -3
- package/dist/es6/combobox/lib/AutocompleteList.d.ts +4 -5
- package/dist/es6/combobox/lib/AutocompleteList.d.ts.map +1 -1
- package/dist/es6/combobox/lib/AutocompleteList.js +26 -48
- package/dist/es6/combobox/lib/Combobox.d.ts +4 -6
- package/dist/es6/combobox/lib/Combobox.d.ts.map +1 -1
- package/dist/es6/combobox/lib/Combobox.js +98 -131
- package/dist/es6/combobox/lib/Status.d.ts +1 -2
- package/dist/es6/combobox/lib/Status.d.ts.map +1 -1
- package/dist/es6/combobox/lib/Status.js +6 -8
- package/dist/es6/common/index.d.ts +0 -2
- package/dist/es6/common/index.d.ts.map +1 -1
- package/dist/es6/common/index.js +0 -2
- package/dist/es6/common/lib/theming/index.d.ts +0 -1
- package/dist/es6/common/lib/theming/index.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/index.js +0 -1
- package/dist/es6/common/lib/theming/useThemeRTL.d.ts +3 -0
- package/dist/es6/common/lib/theming/useThemeRTL.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/useThemeRTL.js +19 -44
- package/dist/es6/expandable/index.d.ts +3 -0
- package/dist/es6/expandable/index.d.ts.map +1 -0
- package/dist/es6/expandable/index.js +2 -0
- package/dist/es6/expandable/lib/Expandable.d.ts +108 -0
- package/dist/es6/expandable/lib/Expandable.d.ts.map +1 -0
- package/dist/es6/expandable/lib/Expandable.js +53 -0
- package/dist/es6/expandable/lib/ExpandableAvatar.d.ts +7 -0
- package/dist/es6/expandable/lib/ExpandableAvatar.d.ts.map +1 -0
- package/dist/es6/expandable/lib/ExpandableAvatar.js +17 -0
- package/dist/es6/expandable/lib/ExpandableContent.d.ts +21 -0
- package/dist/es6/expandable/lib/ExpandableContent.d.ts.map +1 -0
- package/dist/es6/expandable/lib/ExpandableContent.js +12 -0
- package/dist/es6/expandable/lib/ExpandableIcon.d.ts +29 -0
- package/dist/es6/expandable/lib/ExpandableIcon.d.ts.map +1 -0
- package/dist/es6/expandable/lib/ExpandableIcon.js +25 -0
- package/dist/es6/expandable/lib/ExpandableTarget.d.ts +33 -0
- package/dist/es6/expandable/lib/ExpandableTarget.d.ts.map +1 -0
- package/dist/es6/expandable/lib/ExpandableTarget.js +26 -0
- package/dist/es6/expandable/lib/ExpandableTitle.d.ts +11 -0
- package/dist/es6/expandable/lib/ExpandableTitle.d.ts.map +1 -0
- package/dist/es6/expandable/lib/ExpandableTitle.js +10 -0
- package/dist/es6/expandable/lib/hooks/index.d.ts +5 -0
- package/dist/es6/expandable/lib/hooks/index.d.ts.map +1 -0
- package/dist/es6/expandable/lib/hooks/index.js +4 -0
- package/dist/es6/expandable/lib/hooks/useExpandableContent.d.ts +18 -0
- package/dist/es6/expandable/lib/hooks/useExpandableContent.d.ts.map +1 -0
- package/dist/es6/expandable/lib/hooks/useExpandableContent.js +8 -0
- package/dist/es6/expandable/lib/hooks/useExpandableIcon.d.ts +13 -0
- package/dist/es6/expandable/lib/hooks/useExpandableIcon.d.ts.map +1 -0
- package/dist/es6/expandable/lib/hooks/useExpandableIcon.js +7 -0
- package/dist/es6/expandable/lib/hooks/useExpandableModel.d.ts +53 -0
- package/dist/es6/expandable/lib/hooks/useExpandableModel.d.ts.map +1 -0
- package/dist/es6/expandable/lib/hooks/useExpandableModel.js +19 -0
- package/dist/es6/expandable/lib/hooks/useExpandableTarget.d.ts +15 -0
- package/dist/es6/expandable/lib/hooks/useExpandableTarget.d.ts.map +1 -0
- package/dist/es6/expandable/lib/hooks/useExpandableTarget.js +16 -0
- package/dist/es6/index.d.ts +1 -2
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +1 -2
- package/dist/es6/search-form/lib/SearchForm.d.ts +7 -3
- package/dist/es6/search-form/lib/SearchForm.d.ts.map +1 -1
- package/dist/es6/search-form/lib/SearchForm.js +108 -136
- package/dist/es6/search-form/lib/themes.js +5 -6
- package/{drawer → expandable}/LICENSE +2 -1
- package/expandable/README.md +11 -0
- package/expandable/index.ts +2 -0
- package/expandable/lib/Expandable.tsx +68 -0
- package/expandable/lib/ExpandableAvatar.tsx +26 -0
- package/expandable/lib/ExpandableContent.tsx +32 -0
- package/expandable/lib/ExpandableIcon.tsx +75 -0
- package/expandable/lib/ExpandableTarget.tsx +67 -0
- package/expandable/lib/ExpandableTitle.tsx +32 -0
- package/expandable/lib/hooks/index.ts +4 -0
- package/expandable/lib/hooks/useExpandableContent.ts +9 -0
- package/expandable/lib/hooks/useExpandableIcon.ts +8 -0
- package/expandable/lib/hooks/useExpandableModel.tsx +20 -0
- package/expandable/lib/hooks/useExpandableTarget.ts +16 -0
- package/expandable/package.json +6 -0
- package/index.ts +1 -2
- package/package.json +5 -5
- package/search-form/lib/SearchForm.tsx +13 -11
- package/common/lib/storybook-utils/ComponentStatesTable.tsx +0 -80
- package/common/lib/storybook-utils/permutateProps.ts +0 -47
- package/common/lib/storybook-utils/propTypes.ts +0 -15
- package/common/lib/theming/useThemedRing.ts +0 -82
- package/dist/commonjs/common/lib/storybook-utils/ComponentStatesTable.d.ts +0 -26
- package/dist/commonjs/common/lib/storybook-utils/ComponentStatesTable.d.ts.map +0 -1
- package/dist/commonjs/common/lib/storybook-utils/ComponentStatesTable.js +0 -48
- package/dist/commonjs/common/lib/storybook-utils/permutateProps.d.ts +0 -5
- package/dist/commonjs/common/lib/storybook-utils/permutateProps.d.ts.map +0 -1
- package/dist/commonjs/common/lib/storybook-utils/permutateProps.js +0 -47
- package/dist/commonjs/common/lib/storybook-utils/propTypes.d.ts +0 -15
- package/dist/commonjs/common/lib/storybook-utils/propTypes.d.ts.map +0 -1
- package/dist/commonjs/common/lib/storybook-utils/propTypes.js +0 -2
- package/dist/commonjs/common/lib/theming/useThemedRing.d.ts +0 -11
- package/dist/commonjs/common/lib/theming/useThemedRing.d.ts.map +0 -1
- package/dist/commonjs/common/lib/theming/useThemedRing.js +0 -67
- package/dist/commonjs/drawer/index.d.ts +0 -6
- package/dist/commonjs/drawer/index.d.ts.map +0 -1
- package/dist/commonjs/drawer/lib/Drawer.d.ts +0 -49
- package/dist/commonjs/drawer/lib/Drawer.d.ts.map +0 -1
- package/dist/commonjs/drawer/lib/Drawer.js +0 -124
- package/dist/commonjs/drawer/lib/DrawerHeader.d.ts +0 -38
- package/dist/commonjs/drawer/lib/DrawerHeader.d.ts.map +0 -1
- package/dist/commonjs/drawer/lib/DrawerHeader.js +0 -105
- package/dist/es6/common/lib/storybook-utils/ComponentStatesTable.d.ts +0 -26
- package/dist/es6/common/lib/storybook-utils/ComponentStatesTable.d.ts.map +0 -1
- package/dist/es6/common/lib/storybook-utils/ComponentStatesTable.js +0 -41
- package/dist/es6/common/lib/storybook-utils/permutateProps.d.ts +0 -5
- package/dist/es6/common/lib/storybook-utils/permutateProps.d.ts.map +0 -1
- package/dist/es6/common/lib/storybook-utils/permutateProps.js +0 -43
- package/dist/es6/common/lib/storybook-utils/propTypes.d.ts +0 -15
- package/dist/es6/common/lib/storybook-utils/propTypes.d.ts.map +0 -1
- package/dist/es6/common/lib/storybook-utils/propTypes.js +0 -1
- package/dist/es6/common/lib/theming/useThemedRing.d.ts +0 -11
- package/dist/es6/common/lib/theming/useThemedRing.d.ts.map +0 -1
- package/dist/es6/common/lib/theming/useThemedRing.js +0 -59
- package/dist/es6/drawer/index.d.ts +0 -6
- package/dist/es6/drawer/index.d.ts.map +0 -1
- package/dist/es6/drawer/index.js +0 -5
- package/dist/es6/drawer/lib/Drawer.d.ts +0 -49
- package/dist/es6/drawer/lib/Drawer.d.ts.map +0 -1
- package/dist/es6/drawer/lib/Drawer.js +0 -99
- package/dist/es6/drawer/lib/DrawerHeader.d.ts +0 -38
- package/dist/es6/drawer/lib/DrawerHeader.d.ts.map +0 -1
- package/dist/es6/drawer/lib/DrawerHeader.js +0 -81
- package/drawer/README.md +0 -35
- package/drawer/index.ts +0 -5
- package/drawer/lib/Drawer.tsx +0 -119
- package/drawer/lib/DrawerHeader.tsx +0 -105
- package/drawer/package.json +0 -6
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -29,46 +18,32 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
18
|
__setModuleDefault(result, mod);
|
|
30
19
|
return result;
|
|
31
20
|
};
|
|
32
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
33
|
-
var t = {};
|
|
34
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
35
|
-
t[p] = s[p];
|
|
36
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
37
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
38
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
39
|
-
t[p[i]] = s[p[i]];
|
|
40
|
-
}
|
|
41
|
-
return t;
|
|
42
|
-
};
|
|
43
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
44
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
45
23
|
};
|
|
46
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
exports.getTextFromElement = exports.getOptionId = exports.listBoxIdPart = void 0;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
25
|
+
exports.Combobox = exports.getTextFromElement = exports.getOptionId = exports.listBoxIdPart = void 0;
|
|
26
|
+
const react_1 = __importStar(require("react"));
|
|
27
|
+
const react_2 = require("@emotion/react");
|
|
28
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
29
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
30
|
+
const card_1 = require("@workday/canvas-kit-react/card");
|
|
31
|
+
const button_1 = require("@workday/canvas-kit-react/button");
|
|
32
|
+
const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
|
|
33
|
+
const lodash_flatten_1 = __importDefault(require("lodash.flatten"));
|
|
34
|
+
const AutocompleteList_1 = require("./AutocompleteList");
|
|
35
|
+
const Status_1 = require("./Status");
|
|
36
|
+
const Container = common_1.styled('div')({
|
|
59
37
|
display: 'inline-block',
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var InputContainer = common_1.styled('div')({
|
|
67
|
-
display: "flex",
|
|
68
|
-
alignItems: "center",
|
|
38
|
+
}, ({ grow }) => ({
|
|
39
|
+
width: grow ? '100%' : 'auto',
|
|
40
|
+
}));
|
|
41
|
+
const InputContainer = common_1.styled('div')({
|
|
42
|
+
display: `flex`,
|
|
43
|
+
alignItems: `center`,
|
|
69
44
|
position: 'relative',
|
|
70
45
|
});
|
|
71
|
-
|
|
46
|
+
const fadeInKeyframes = react_2.keyframes({
|
|
72
47
|
'0%': {
|
|
73
48
|
opacity: 0,
|
|
74
49
|
},
|
|
@@ -76,47 +51,42 @@ var fadeInKeyframes = react_2.keyframes({
|
|
|
76
51
|
opacity: 1,
|
|
77
52
|
},
|
|
78
53
|
});
|
|
79
|
-
|
|
54
|
+
const MenuContainer = common_1.styled(card_1.Card)({
|
|
80
55
|
position: 'absolute',
|
|
81
56
|
zIndex: 1,
|
|
82
57
|
left: 0,
|
|
83
58
|
top: '100%',
|
|
84
59
|
borderRadius: tokens_1.borderRadius.m,
|
|
85
60
|
background: tokens_1.commonColors.background,
|
|
86
|
-
border:
|
|
87
|
-
marginTop:
|
|
61
|
+
border: `none`,
|
|
62
|
+
marginTop: `-${tokens_1.borderRadius.m}`,
|
|
88
63
|
width: '100%',
|
|
89
64
|
minWidth: 0,
|
|
90
|
-
animation: fadeInKeyframes
|
|
65
|
+
animation: `${fadeInKeyframes} 200ms ease-out`,
|
|
91
66
|
maxHeight: 200,
|
|
92
67
|
overflow: 'hidden',
|
|
93
68
|
});
|
|
94
|
-
|
|
69
|
+
const ResetButton = common_1.styled(button_1.TertiaryButton)({
|
|
95
70
|
position: 'absolute',
|
|
96
|
-
margin:
|
|
71
|
+
margin: `auto ${tokens_1.space.xxxs}`,
|
|
97
72
|
top: 0,
|
|
98
73
|
bottom: 0,
|
|
99
74
|
right: 0,
|
|
100
75
|
padding: 0,
|
|
101
76
|
zIndex: 2,
|
|
102
77
|
transition: 'opacity 120ms',
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
exports.listBoxIdPart = "listbox";
|
|
111
|
-
var optionIdPart = "option";
|
|
112
|
-
var getOptionId = function (baseId, index) {
|
|
113
|
-
return baseId + "-" + optionIdPart + "-" + index;
|
|
114
|
-
};
|
|
78
|
+
}, ({ shouldShow }) => ({
|
|
79
|
+
visibility: shouldShow ? 'visible' : 'hidden',
|
|
80
|
+
opacity: shouldShow ? 1 : 0,
|
|
81
|
+
}));
|
|
82
|
+
exports.listBoxIdPart = `listbox`;
|
|
83
|
+
const optionIdPart = `option`;
|
|
84
|
+
const getOptionId = (baseId, index) => `${baseId}-${optionIdPart}-${index}`;
|
|
115
85
|
exports.getOptionId = getOptionId;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
react_1.default.Children.map(children,
|
|
119
|
-
if (child == null || typeof child === 'boolean'
|
|
86
|
+
const getTextFromElement = (children) => {
|
|
87
|
+
let text = '';
|
|
88
|
+
react_1.default.Children.map(children, child => {
|
|
89
|
+
if (child == null || typeof child === 'boolean') {
|
|
120
90
|
text += '';
|
|
121
91
|
}
|
|
122
92
|
else if (typeof child === 'string' || typeof child === 'number') {
|
|
@@ -132,89 +102,88 @@ var getTextFromElement = function (children) {
|
|
|
132
102
|
return text;
|
|
133
103
|
};
|
|
134
104
|
exports.getTextFromElement = getTextFromElement;
|
|
135
|
-
|
|
136
|
-
return
|
|
105
|
+
const buildStatusString = (listCount) => {
|
|
106
|
+
return `There ${listCount === 1 ? 'is' : 'are'} ${listCount} suggestion${listCount === 1 ? '' : 's'}.`;
|
|
137
107
|
};
|
|
138
|
-
|
|
108
|
+
const isValidSingleChild = (child) => {
|
|
139
109
|
return react_1.default.isValidElement(child) && react_1.default.Children.only(child);
|
|
140
110
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
var _k = react_1.useState(''), announcementText = _k[0], setAnnouncementText = _k[1];
|
|
111
|
+
const Combobox = ({ autocompleteItems, children, grow, initialValue, onChange, onFocus, onBlur, showClearButton, clearButtonVariant = undefined, clearButtonAriaLabel = `Reset Search Input`, labelId, getStatusText = buildStatusString, id, ...elemProps }) => {
|
|
112
|
+
const [isOpened, setIsOpened] = react_1.useState(false);
|
|
113
|
+
const [value, _setValue] = react_1.useState(''); // Don't call _setValue directly instead call setInputValue to make sure onChange fires correctly
|
|
114
|
+
const [showingAutocomplete, setShowingAutocomplete] = react_1.useState(false);
|
|
115
|
+
const [selectedAutocompleteIndex, setSelectedAutocompleteIndex] = react_1.useState(null);
|
|
116
|
+
const [interactiveAutocompleteItems, setInteractiveAutocompleteItems] = react_1.useState([]);
|
|
117
|
+
const [announcementText, setAnnouncementText] = react_1.useState('');
|
|
149
118
|
// Create a ref to the soon-to-be-created TextInput clone for internal use.
|
|
150
119
|
// Use useForkRef to combine it with the ref already assigned to the original
|
|
151
120
|
// TextInput (if it exists) to create a single callback ref which can be
|
|
152
121
|
// forwarded to the TextInput clone.
|
|
153
|
-
|
|
122
|
+
const inputRef = react_1.useRef(null);
|
|
154
123
|
// We need access to the original TextInput's ref _property_ (not prop) so we
|
|
155
124
|
// can combine it with the internal inputRef using useForkRef. ref isn't
|
|
156
125
|
// listed in the ReactElement interface, but it's there, so we cast children
|
|
157
126
|
// to satisfy TS.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
127
|
+
const elementRef = common_1.useForkRef(children.ref, inputRef);
|
|
128
|
+
const comboboxRef = react_1.useRef(null);
|
|
129
|
+
const randomComponentId = common_1.useUniqueId();
|
|
130
|
+
const randomLabelId = common_1.useUniqueId();
|
|
131
|
+
const componentId = id || randomComponentId;
|
|
132
|
+
const formLabelId = labelId || randomLabelId;
|
|
133
|
+
const [showGroupText, setShowGroupText] = react_1.useState(false);
|
|
165
134
|
// We're using LayoutEffect here because of an issue with the Synthetic event system and typing a key
|
|
166
135
|
// after the listbox has been closed. Somehow the key is ignored unless we use `useLayoutEffect`
|
|
167
|
-
react_1.useLayoutEffect(
|
|
168
|
-
|
|
136
|
+
react_1.useLayoutEffect(() => {
|
|
137
|
+
const shouldShow = interactiveAutocompleteItems.length > 0 && isOpened;
|
|
169
138
|
setShowingAutocomplete(shouldShow);
|
|
170
139
|
if (shouldShow) {
|
|
171
140
|
setAnnouncementText(getStatusText(interactiveAutocompleteItems.length));
|
|
172
141
|
}
|
|
173
142
|
}, [getStatusText, interactiveAutocompleteItems, isOpened]);
|
|
174
143
|
// Used to set the position of the reset button and the padding direction inside the input container
|
|
175
|
-
|
|
176
|
-
|
|
144
|
+
const isRTL = common_1.useIsRTL();
|
|
145
|
+
const setInputValue = react_1.useCallback((newValue) => {
|
|
177
146
|
_setValue(newValue);
|
|
178
|
-
|
|
147
|
+
const inputDomElement = inputRef.current;
|
|
179
148
|
// Changing value prop programmatically doesn't fire an Synthetic event or trigger native onChange.
|
|
180
149
|
// We can not just update .value= in setState because React library overrides input value setter
|
|
181
150
|
// but we can call the function directly on the input as context.
|
|
182
151
|
// This will cause onChange events to fire no matter how value is updated.
|
|
183
152
|
if (inputDomElement) {
|
|
184
|
-
|
|
153
|
+
const nativeInputValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(inputDomElement), 'value');
|
|
185
154
|
if (nativeInputValue && nativeInputValue.set) {
|
|
186
155
|
nativeInputValue.set.call(inputDomElement, newValue);
|
|
187
156
|
}
|
|
188
|
-
|
|
157
|
+
let event;
|
|
189
158
|
if (typeof Event === 'function') {
|
|
190
159
|
// modern browsers
|
|
191
|
-
|
|
160
|
+
event = new Event('input', { bubbles: true });
|
|
192
161
|
}
|
|
193
162
|
else {
|
|
194
163
|
// IE 11
|
|
195
|
-
|
|
196
|
-
|
|
164
|
+
event = document.createEvent('Event');
|
|
165
|
+
event.initEvent('input', true, true);
|
|
197
166
|
}
|
|
198
|
-
inputDomElement.dispatchEvent(
|
|
167
|
+
inputDomElement.dispatchEvent(event);
|
|
199
168
|
}
|
|
200
169
|
}, [inputRef]);
|
|
201
|
-
react_1.useEffect(
|
|
170
|
+
react_1.useEffect(() => {
|
|
202
171
|
if (initialValue !== null && initialValue !== undefined) {
|
|
203
172
|
setInputValue(initialValue);
|
|
204
173
|
}
|
|
205
174
|
}, [initialValue, setInputValue]);
|
|
206
|
-
react_1.useEffect(
|
|
207
|
-
|
|
175
|
+
react_1.useEffect(() => {
|
|
176
|
+
const getInteractiveAutocompleteItems = () => {
|
|
208
177
|
if (autocompleteItems &&
|
|
209
178
|
autocompleteItems.length &&
|
|
210
179
|
autocompleteItems[0].hasOwnProperty('header')) {
|
|
211
|
-
return lodash_flatten_1.default(autocompleteItems.map(
|
|
180
|
+
return lodash_flatten_1.default(autocompleteItems.map(group => group.items));
|
|
212
181
|
}
|
|
213
182
|
return autocompleteItems || [];
|
|
214
183
|
};
|
|
215
184
|
setInteractiveAutocompleteItems(getInteractiveAutocompleteItems());
|
|
216
185
|
}, [autocompleteItems]);
|
|
217
|
-
|
|
186
|
+
const handleAutocompleteClick = (event, menuItemProps) => {
|
|
218
187
|
if (menuItemProps.isDisabled) {
|
|
219
188
|
return;
|
|
220
189
|
}
|
|
@@ -225,29 +194,25 @@ var Combobox = function (_a) {
|
|
|
225
194
|
menuItemProps.onClick(event);
|
|
226
195
|
}
|
|
227
196
|
};
|
|
228
|
-
|
|
197
|
+
const focusInput = () => {
|
|
229
198
|
if (inputRef.current) {
|
|
230
199
|
inputRef.current.focus();
|
|
231
200
|
}
|
|
232
201
|
};
|
|
233
|
-
|
|
202
|
+
const handleClick = (event) => {
|
|
234
203
|
if (!showingAutocomplete) {
|
|
235
204
|
setShowingAutocomplete(true);
|
|
236
205
|
}
|
|
237
206
|
};
|
|
238
|
-
|
|
207
|
+
const handleFocus = (event) => {
|
|
239
208
|
setIsOpened(true);
|
|
240
209
|
if (onFocus) {
|
|
241
210
|
onFocus(event);
|
|
242
211
|
}
|
|
243
212
|
};
|
|
244
|
-
|
|
213
|
+
const handleBlur = (event) => {
|
|
245
214
|
if (comboboxRef.current) {
|
|
246
|
-
|
|
247
|
-
if (target === null) {
|
|
248
|
-
// IE11 swaps related and active target before it fires the blur event
|
|
249
|
-
target = document.activeElement;
|
|
250
|
-
}
|
|
215
|
+
const target = event.relatedTarget;
|
|
251
216
|
if (target && comboboxRef.current.contains(target)) {
|
|
252
217
|
return;
|
|
253
218
|
}
|
|
@@ -257,45 +222,45 @@ var Combobox = function (_a) {
|
|
|
257
222
|
onBlur(event);
|
|
258
223
|
}
|
|
259
224
|
};
|
|
260
|
-
|
|
225
|
+
const resetSearchInput = () => {
|
|
261
226
|
setInputValue('');
|
|
262
227
|
focusInput();
|
|
263
228
|
};
|
|
264
|
-
|
|
229
|
+
const getGroupIndex = (itemIndex) => {
|
|
265
230
|
if (itemIndex != null &&
|
|
266
231
|
autocompleteItems &&
|
|
267
232
|
autocompleteItems.length &&
|
|
268
233
|
autocompleteItems[0].hasOwnProperty('header')) {
|
|
269
|
-
|
|
270
|
-
return autocompleteItems.findIndex(
|
|
271
|
-
|
|
272
|
-
return
|
|
234
|
+
let count = 0;
|
|
235
|
+
return autocompleteItems.findIndex(groups => {
|
|
236
|
+
count += groups.items.length;
|
|
237
|
+
return count > itemIndex;
|
|
273
238
|
});
|
|
274
239
|
}
|
|
275
240
|
else {
|
|
276
241
|
return -1;
|
|
277
242
|
}
|
|
278
243
|
};
|
|
279
|
-
|
|
244
|
+
const handleKeyboardShortcuts = (event) => {
|
|
280
245
|
if (event.ctrlKey || event.altKey || event.metaKey || !interactiveAutocompleteItems.length) {
|
|
281
246
|
return;
|
|
282
247
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
248
|
+
const autoCompleteItemCount = interactiveAutocompleteItems.length;
|
|
249
|
+
const firstItem = 0;
|
|
250
|
+
const lastItem = autoCompleteItemCount - 1;
|
|
251
|
+
let nextIndex = null;
|
|
287
252
|
setIsOpened(true);
|
|
288
253
|
switch (event.key) {
|
|
289
254
|
case 'ArrowUp':
|
|
290
255
|
case 'Up': // IE/Edge specific value
|
|
291
|
-
|
|
256
|
+
const upIndex = selectedAutocompleteIndex !== null ? selectedAutocompleteIndex - 1 : lastItem;
|
|
292
257
|
nextIndex = upIndex < 0 ? lastItem : upIndex;
|
|
293
258
|
event.stopPropagation();
|
|
294
259
|
event.preventDefault();
|
|
295
260
|
break;
|
|
296
261
|
case 'ArrowDown':
|
|
297
262
|
case 'Down': // IE/Edge specific value
|
|
298
|
-
|
|
263
|
+
const downIndex = selectedAutocompleteIndex !== null ? selectedAutocompleteIndex + 1 : firstItem;
|
|
299
264
|
nextIndex = downIndex >= autoCompleteItemCount ? firstItem : downIndex;
|
|
300
265
|
event.stopPropagation();
|
|
301
266
|
event.preventDefault();
|
|
@@ -306,7 +271,7 @@ var Combobox = function (_a) {
|
|
|
306
271
|
break;
|
|
307
272
|
case 'Enter':
|
|
308
273
|
if (selectedAutocompleteIndex != null) {
|
|
309
|
-
|
|
274
|
+
const item = interactiveAutocompleteItems[selectedAutocompleteIndex];
|
|
310
275
|
handleAutocompleteClick(event, item.props);
|
|
311
276
|
if (item.props.isDisabled) {
|
|
312
277
|
nextIndex = selectedAutocompleteIndex;
|
|
@@ -317,25 +282,27 @@ var Combobox = function (_a) {
|
|
|
317
282
|
break;
|
|
318
283
|
default:
|
|
319
284
|
}
|
|
320
|
-
|
|
321
|
-
|
|
285
|
+
const lastGroupIndex = getGroupIndex(selectedAutocompleteIndex);
|
|
286
|
+
const nextGroupIndex = getGroupIndex(nextIndex);
|
|
322
287
|
setShowGroupText(lastGroupIndex !== nextGroupIndex);
|
|
323
288
|
setSelectedAutocompleteIndex(nextIndex);
|
|
324
289
|
};
|
|
325
|
-
|
|
290
|
+
const handleSearchInputChange = (event) => {
|
|
326
291
|
if (onChange) {
|
|
327
292
|
onChange(event);
|
|
328
293
|
}
|
|
329
294
|
_setValue(event.target.value); // Calling set value directly only for on change event
|
|
330
295
|
};
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var cssOverride = { zIndex: 2 };
|
|
296
|
+
const renderChildren = (inputElement) => {
|
|
297
|
+
let cssOverride = { ':focus': { zIndex: 2 } };
|
|
334
298
|
if (showClearButton) {
|
|
335
|
-
|
|
336
|
-
cssOverride =
|
|
299
|
+
const paddingDirection = isRTL ? 'paddingLeft' : 'paddingRight';
|
|
300
|
+
cssOverride = {
|
|
301
|
+
...cssOverride,
|
|
302
|
+
[paddingDirection]: tokens_1.space.xl,
|
|
303
|
+
};
|
|
337
304
|
}
|
|
338
|
-
|
|
305
|
+
const newTextInputProps = {
|
|
339
306
|
type: 'text',
|
|
340
307
|
id: componentId,
|
|
341
308
|
grow: grow,
|
|
@@ -352,22 +319,23 @@ var Combobox = function (_a) {
|
|
|
352
319
|
onBlur: handleBlur,
|
|
353
320
|
css: cssOverride,
|
|
354
321
|
role: 'combobox',
|
|
355
|
-
'aria-owns': showingAutocomplete ? componentId
|
|
322
|
+
'aria-owns': showingAutocomplete ? `${componentId}-${exports.listBoxIdPart}` : undefined,
|
|
356
323
|
'aria-haspopup': true,
|
|
357
324
|
'aria-expanded': showingAutocomplete,
|
|
358
325
|
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
326
|
+
const cloneElement = (element, props) => react_2.jsx(element.type, {
|
|
327
|
+
...element.props,
|
|
328
|
+
...props,
|
|
329
|
+
});
|
|
330
|
+
return cloneElement(inputElement, { ...inputElement.props, ...newTextInputProps });
|
|
363
331
|
};
|
|
364
|
-
return (react_1.default.createElement(Container,
|
|
332
|
+
return (react_1.default.createElement(Container, Object.assign({ grow: grow }, elemProps),
|
|
365
333
|
react_1.default.createElement(InputContainer, { ref: comboboxRef },
|
|
366
334
|
isValidSingleChild(children) && react_1.default.Children.map(children, renderChildren),
|
|
367
335
|
showClearButton && (react_1.default.createElement(ResetButton, { shouldShow: !!value, "aria-label": clearButtonAriaLabel, icon: canvas_system_icons_web_1.xSmallIcon, variant: clearButtonVariant, onClick: resetSearchInput, onBlur: handleBlur, size: "small", type: "button" })),
|
|
368
336
|
showingAutocomplete && autocompleteItems && (react_1.default.createElement(MenuContainer, { padding: tokens_1.space.zero, depth: 3 },
|
|
369
337
|
react_1.default.createElement(card_1.Card.Body, null,
|
|
370
|
-
react_1.default.createElement(AutocompleteList_1.
|
|
371
|
-
react_1.default.createElement(Status_1.
|
|
338
|
+
react_1.default.createElement(AutocompleteList_1.AutocompleteList, { comboboxId: componentId, autocompleteItems: autocompleteItems, selectedIndex: selectedAutocompleteIndex, handleAutocompleteClick: handleAutocompleteClick, labelId: formLabelId, showGroupText: showGroupText }))))),
|
|
339
|
+
react_1.default.createElement(Status_1.Status, { announcementText: announcementText })));
|
|
372
340
|
};
|
|
373
|
-
exports.
|
|
341
|
+
exports.Combobox = Combobox;
|
|
@@ -6,6 +6,5 @@ export interface StatusProps {
|
|
|
6
6
|
expireMilliseconds?: number;
|
|
7
7
|
announcementText?: string;
|
|
8
8
|
}
|
|
9
|
-
declare const Status: ({ ariaLive, role, ariaRelevant, expireMilliseconds, announcementText, ariaAtomic, }: StatusProps) => JSX.Element;
|
|
10
|
-
export default Status;
|
|
9
|
+
export declare const Status: ({ ariaLive, role, ariaRelevant, expireMilliseconds, announcementText, ariaAtomic, }: StatusProps) => JSX.Element;
|
|
11
10
|
//# sourceMappingURL=Status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Status.d.ts","sourceRoot":"","sources":["../../../../combobox/lib/Status.tsx"],"names":[],"mappings":"AAIA,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,
|
|
1
|
+
{"version":3,"file":"Status.d.ts","sourceRoot":"","sources":["../../../../combobox/lib/Status.tsx"],"names":[],"mappings":"AAIA,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,eAAO,MAAM,MAAM,wFAOhB,WAAW,gBAuBb,CAAC"}
|
|
@@ -22,23 +22,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
react_1.useEffect(
|
|
25
|
+
exports.Status = void 0;
|
|
26
|
+
const react_1 = __importStar(require("react"));
|
|
27
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
28
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
29
|
+
const Container = styled_1.default('div')(common_1.accessibleHide);
|
|
30
|
+
const Status = ({ ariaLive = 'polite', role = 'status', ariaRelevant = 'additions', expireMilliseconds = 500, announcementText = '', ariaAtomic, }) => {
|
|
31
|
+
const [displayText, setDisplayText] = react_1.useState(announcementText);
|
|
32
|
+
react_1.useEffect(() => {
|
|
33
33
|
if (!announcementText) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
setDisplayText(announcementText);
|
|
37
|
-
|
|
38
|
-
return
|
|
37
|
+
const clearText = setTimeout(() => setDisplayText(''), expireMilliseconds);
|
|
38
|
+
return () => {
|
|
39
39
|
clearTimeout(clearText);
|
|
40
40
|
};
|
|
41
41
|
}, [announcementText, expireMilliseconds]);
|
|
42
42
|
return (react_1.default.createElement(Container, { "aria-live": ariaLive, role: role, "aria-relevant": ariaRelevant, "aria-atomic": ariaAtomic }, displayText));
|
|
43
43
|
};
|
|
44
|
-
exports.
|
|
44
|
+
exports.Status = Status;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../common/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../common/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
@@ -10,9 +10,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.permutateProps = exports.ComponentStatesTable = void 0;
|
|
14
13
|
__exportStar(require("./lib/theming"), exports);
|
|
15
|
-
var ComponentStatesTable_1 = require("./lib/storybook-utils/ComponentStatesTable");
|
|
16
|
-
Object.defineProperty(exports, "ComponentStatesTable", { enumerable: true, get: function () { return ComponentStatesTable_1.ComponentStatesTable; } });
|
|
17
|
-
var permutateProps_1 = require("./lib/storybook-utils/permutateProps");
|
|
18
|
-
Object.defineProperty(exports, "permutateProps", { enumerable: true, get: function () { return permutateProps_1.permutateProps; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { CSSProperties } from '@workday/canvas-kit-react/tokens';
|
|
2
2
|
export declare type ComponentStyles = Record<string, CSSProperties>;
|
|
3
3
|
/**
|
|
4
|
+
* @deprecated Now that IE11 is no longer supported, we encourage consumers to use [CSS logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties)
|
|
5
|
+
*
|
|
6
|
+
*
|
|
4
7
|
* A helpful hook for supporting bidirectional styles.
|
|
5
8
|
* * Read below for more detail or [view the docs](https://github.com/Workday/canvas-kit/blob/master/modules/labs-react/common/README.md#useThemeRTL).
|
|
6
9
|
*
|
|
@@ -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":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAI/D,oBAAY,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAc5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,WAAW;6BAMD,aAAa,EAAE;;EAYxC"}
|