@workday/canvas-kit-labs-react 8.0.0-alpha.253-next.22 → 8.0.0-alpha.428-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/common/lib/theming/index.ts +0 -1
- package/common/lib/theming/useThemeRTL.ts +3 -0
- package/dist/commonjs/combobox/lib/AutocompleteList.js +31 -52
- package/dist/commonjs/combobox/lib/Combobox.js +105 -133
- package/dist/commonjs/combobox/lib/Status.js +9 -10
- 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 +19 -42
- package/dist/commonjs/expandable/lib/Expandable.d.ts +45 -12
- package/dist/commonjs/expandable/lib/Expandable.d.ts.map +1 -1
- package/dist/commonjs/expandable/lib/Expandable.js +46 -37
- package/dist/commonjs/expandable/lib/ExpandableAvatar.js +7 -30
- package/dist/commonjs/expandable/lib/ExpandableContent.d.ts +4 -2
- package/dist/commonjs/expandable/lib/ExpandableContent.d.ts.map +1 -1
- package/dist/commonjs/expandable/lib/ExpandableContent.js +8 -31
- package/dist/commonjs/expandable/lib/ExpandableIcon.d.ts +1 -1
- package/dist/commonjs/expandable/lib/ExpandableIcon.d.ts.map +1 -1
- package/dist/commonjs/expandable/lib/ExpandableIcon.js +20 -51
- package/dist/commonjs/expandable/lib/ExpandableTarget.d.ts +7 -2
- package/dist/commonjs/expandable/lib/ExpandableTarget.d.ts.map +1 -1
- package/dist/commonjs/expandable/lib/ExpandableTarget.js +18 -34
- package/dist/commonjs/expandable/lib/ExpandableTitle.d.ts +3 -1
- package/dist/commonjs/expandable/lib/ExpandableTitle.d.ts.map +1 -1
- package/dist/commonjs/expandable/lib/ExpandableTitle.js +6 -29
- package/dist/commonjs/expandable/lib/hooks/index.d.ts +1 -0
- package/dist/commonjs/expandable/lib/hooks/index.d.ts.map +1 -1
- package/dist/commonjs/expandable/lib/hooks/index.js +1 -0
- package/dist/commonjs/expandable/lib/hooks/useExpandableContent.d.ts +4 -6
- package/dist/commonjs/expandable/lib/hooks/useExpandableContent.d.ts.map +1 -1
- package/dist/commonjs/expandable/lib/hooks/useExpandableContent.js +3 -4
- package/dist/commonjs/expandable/lib/hooks/useExpandableIcon.d.ts +4 -6
- package/dist/commonjs/expandable/lib/hooks/useExpandableIcon.d.ts.map +1 -1
- package/dist/commonjs/expandable/lib/hooks/useExpandableIcon.js +3 -4
- package/dist/{es6/expandable/lib → commonjs/expandable/lib/hooks}/useExpandableModel.d.ts +10 -7
- 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 +4 -6
- package/dist/commonjs/expandable/lib/hooks/useExpandableTarget.d.ts.map +1 -1
- package/dist/commonjs/expandable/lib/hooks/useExpandableTarget.js +4 -5
- package/dist/commonjs/index.d.ts +0 -3
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +0 -3
- package/dist/commonjs/search-form/lib/SearchForm.d.ts +6 -1
- package/dist/commonjs/search-form/lib/SearchForm.d.ts.map +1 -1
- package/dist/commonjs/search-form/lib/SearchForm.js +117 -142
- package/dist/commonjs/search-form/lib/themes.js +7 -8
- package/dist/es6/combobox/lib/AutocompleteList.js +26 -47
- package/dist/es6/combobox/lib/Combobox.js +95 -123
- package/dist/es6/combobox/lib/Status.js +6 -7
- 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 +16 -39
- package/dist/es6/expandable/lib/Expandable.d.ts +45 -12
- package/dist/es6/expandable/lib/Expandable.d.ts.map +1 -1
- package/dist/es6/expandable/lib/Expandable.js +40 -31
- package/dist/es6/expandable/lib/ExpandableAvatar.js +4 -27
- package/dist/es6/expandable/lib/ExpandableContent.d.ts +4 -2
- package/dist/es6/expandable/lib/ExpandableContent.d.ts.map +1 -1
- package/dist/es6/expandable/lib/ExpandableContent.js +5 -28
- package/dist/es6/expandable/lib/ExpandableIcon.d.ts +1 -1
- package/dist/es6/expandable/lib/ExpandableIcon.d.ts.map +1 -1
- package/dist/es6/expandable/lib/ExpandableIcon.js +15 -46
- package/dist/es6/expandable/lib/ExpandableTarget.d.ts +7 -2
- package/dist/es6/expandable/lib/ExpandableTarget.d.ts.map +1 -1
- package/dist/es6/expandable/lib/ExpandableTarget.js +15 -31
- package/dist/es6/expandable/lib/ExpandableTitle.d.ts +3 -1
- package/dist/es6/expandable/lib/ExpandableTitle.d.ts.map +1 -1
- package/dist/es6/expandable/lib/ExpandableTitle.js +3 -26
- package/dist/es6/expandable/lib/hooks/index.d.ts +1 -0
- package/dist/es6/expandable/lib/hooks/index.d.ts.map +1 -1
- package/dist/es6/expandable/lib/hooks/index.js +1 -0
- package/dist/es6/expandable/lib/hooks/useExpandableContent.d.ts +4 -6
- package/dist/es6/expandable/lib/hooks/useExpandableContent.d.ts.map +1 -1
- package/dist/es6/expandable/lib/hooks/useExpandableContent.js +2 -3
- package/dist/es6/expandable/lib/hooks/useExpandableIcon.d.ts +4 -6
- package/dist/es6/expandable/lib/hooks/useExpandableIcon.d.ts.map +1 -1
- package/dist/es6/expandable/lib/hooks/useExpandableIcon.js +2 -3
- package/dist/{commonjs/expandable/lib → es6/expandable/lib/hooks}/useExpandableModel.d.ts +10 -7
- 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 +4 -6
- package/dist/es6/expandable/lib/hooks/useExpandableTarget.d.ts.map +1 -1
- package/dist/es6/expandable/lib/hooks/useExpandableTarget.js +3 -4
- package/dist/es6/index.d.ts +0 -3
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +0 -3
- package/dist/es6/search-form/lib/SearchForm.d.ts +6 -1
- package/dist/es6/search-form/lib/SearchForm.d.ts.map +1 -1
- package/dist/es6/search-form/lib/SearchForm.js +107 -133
- package/dist/es6/search-form/lib/themes.js +5 -6
- package/expandable/lib/Expandable.tsx +38 -4
- package/expandable/lib/ExpandableContent.tsx +4 -4
- package/expandable/lib/ExpandableIcon.tsx +2 -1
- package/expandable/lib/ExpandableTarget.tsx +3 -3
- package/expandable/lib/ExpandableTitle.tsx +6 -8
- package/expandable/lib/hooks/index.ts +1 -0
- package/expandable/lib/hooks/useExpandableContent.ts +1 -1
- package/expandable/lib/hooks/useExpandableIcon.ts +1 -1
- package/expandable/lib/{useExpandableModel.tsx → hooks/useExpandableModel.tsx} +3 -0
- package/expandable/lib/hooks/useExpandableTarget.ts +1 -1
- package/index.ts +0 -3
- package/package.json +4 -4
- package/search-form/lib/SearchForm.tsx +11 -5
- package/common/lib/theming/useThemedRing.ts +0 -82
- 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 -3
- package/dist/commonjs/drawer/index.d.ts.map +0 -1
- package/dist/commonjs/drawer/index.js +0 -16
- package/dist/commonjs/drawer/lib/Drawer.d.ts +0 -74
- package/dist/commonjs/drawer/lib/Drawer.d.ts.map +0 -1
- package/dist/commonjs/drawer/lib/Drawer.js +0 -142
- package/dist/commonjs/drawer/lib/DrawerHeader.d.ts +0 -55
- package/dist/commonjs/drawer/lib/DrawerHeader.d.ts.map +0 -1
- package/dist/commonjs/drawer/lib/DrawerHeader.js +0 -113
- package/dist/commonjs/expandable/lib/useExpandableModel.d.ts.map +0 -1
- package/dist/commonjs/expandable/lib/useExpandableModel.js +0 -24
- package/dist/commonjs/toast/index.d.ts +0 -3
- package/dist/commonjs/toast/index.d.ts.map +0 -1
- package/dist/commonjs/toast/index.js +0 -14
- package/dist/commonjs/toast/lib/Toast.d.ts +0 -27
- package/dist/commonjs/toast/lib/Toast.d.ts.map +0 -1
- package/dist/commonjs/toast/lib/Toast.js +0 -78
- package/dist/commonjs/toast/lib/ToastBody.d.ts +0 -6
- package/dist/commonjs/toast/lib/ToastBody.d.ts.map +0 -1
- package/dist/commonjs/toast/lib/ToastBody.js +0 -40
- package/dist/commonjs/toast/lib/ToastCloseIcon.d.ts +0 -6
- package/dist/commonjs/toast/lib/ToastCloseIcon.d.ts.map +0 -1
- package/dist/commonjs/toast/lib/ToastCloseIcon.js +0 -43
- package/dist/commonjs/toast/lib/ToastIcon.d.ts +0 -5
- package/dist/commonjs/toast/lib/ToastIcon.d.ts.map +0 -1
- package/dist/commonjs/toast/lib/ToastIcon.js +0 -26
- package/dist/commonjs/toast/lib/ToastLink.d.ts +0 -9
- package/dist/commonjs/toast/lib/ToastLink.d.ts.map +0 -1
- package/dist/commonjs/toast/lib/ToastLink.js +0 -42
- package/dist/commonjs/toast/lib/ToastMessage.d.ts +0 -11
- package/dist/commonjs/toast/lib/ToastMessage.d.ts.map +0 -1
- package/dist/commonjs/toast/lib/ToastMessage.js +0 -41
- package/dist/commonjs/toast/lib/hooks/useToastModel.d.ts +0 -65
- package/dist/commonjs/toast/lib/hooks/useToastModel.d.ts.map +0 -1
- package/dist/commonjs/toast/lib/hooks/useToastModel.js +0 -35
- 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 -3
- package/dist/es6/drawer/index.d.ts.map +0 -1
- package/dist/es6/drawer/index.js +0 -2
- package/dist/es6/drawer/lib/Drawer.d.ts +0 -74
- package/dist/es6/drawer/lib/Drawer.d.ts.map +0 -1
- package/dist/es6/drawer/lib/Drawer.js +0 -117
- package/dist/es6/drawer/lib/DrawerHeader.d.ts +0 -55
- package/dist/es6/drawer/lib/DrawerHeader.d.ts.map +0 -1
- package/dist/es6/drawer/lib/DrawerHeader.js +0 -88
- package/dist/es6/expandable/lib/useExpandableModel.d.ts.map +0 -1
- package/dist/es6/expandable/lib/useExpandableModel.js +0 -21
- package/dist/es6/toast/index.d.ts +0 -3
- package/dist/es6/toast/index.d.ts.map +0 -1
- package/dist/es6/toast/index.js +0 -2
- package/dist/es6/toast/lib/Toast.d.ts +0 -27
- package/dist/es6/toast/lib/Toast.d.ts.map +0 -1
- package/dist/es6/toast/lib/Toast.js +0 -72
- package/dist/es6/toast/lib/ToastBody.d.ts +0 -6
- package/dist/es6/toast/lib/ToastBody.d.ts.map +0 -1
- package/dist/es6/toast/lib/ToastBody.js +0 -34
- package/dist/es6/toast/lib/ToastCloseIcon.d.ts +0 -6
- package/dist/es6/toast/lib/ToastCloseIcon.d.ts.map +0 -1
- package/dist/es6/toast/lib/ToastCloseIcon.js +0 -37
- package/dist/es6/toast/lib/ToastIcon.d.ts +0 -5
- package/dist/es6/toast/lib/ToastIcon.d.ts.map +0 -1
- package/dist/es6/toast/lib/ToastIcon.js +0 -20
- package/dist/es6/toast/lib/ToastLink.d.ts +0 -9
- package/dist/es6/toast/lib/ToastLink.d.ts.map +0 -1
- package/dist/es6/toast/lib/ToastLink.js +0 -36
- package/dist/es6/toast/lib/ToastMessage.d.ts +0 -11
- package/dist/es6/toast/lib/ToastMessage.d.ts.map +0 -1
- package/dist/es6/toast/lib/ToastMessage.js +0 -35
- package/dist/es6/toast/lib/hooks/useToastModel.d.ts +0 -65
- package/dist/es6/toast/lib/hooks/useToastModel.d.ts.map +0 -1
- package/dist/es6/toast/lib/hooks/useToastModel.js +0 -32
- package/drawer/LICENSE +0 -51
- package/drawer/README.md +0 -35
- package/drawer/index.ts +0 -2
- package/drawer/lib/Drawer.tsx +0 -156
- package/drawer/lib/DrawerHeader.tsx +0 -133
- package/drawer/package.json +0 -6
- package/toast/LICENSE +0 -52
- package/toast/README.md +0 -5
- package/toast/index.ts +0 -2
- package/toast/lib/Toast.tsx +0 -63
- package/toast/lib/ToastBody.tsx +0 -34
- package/toast/lib/ToastCloseIcon.tsx +0 -18
- package/toast/lib/ToastIcon.tsx +0 -24
- package/toast/lib/ToastLink.tsx +0 -27
- package/toast/lib/ToastMessage.tsx +0 -21
- package/toast/lib/hooks/useToastModel.tsx +0 -27
- package/toast/package.json +0 -6
|
@@ -1,28 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __assign = (this && this.__assign) || function () {
|
|
16
|
-
__assign = Object.assign || function(t) {
|
|
17
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
-
s = arguments[i];
|
|
19
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
-
t[p] = s[p];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
return __assign.apply(this, arguments);
|
|
25
|
-
};
|
|
26
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
27
3
|
if (k2 === undefined) k2 = k;
|
|
28
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -42,32 +18,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
42
18
|
__setModuleDefault(result, mod);
|
|
43
19
|
return result;
|
|
44
20
|
};
|
|
45
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
46
|
-
var t = {};
|
|
47
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
48
|
-
t[p] = s[p];
|
|
49
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
50
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
51
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
52
|
-
t[p[i]] = s[p[i]];
|
|
53
|
-
}
|
|
54
|
-
return t;
|
|
55
|
-
};
|
|
56
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
57
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
58
23
|
};
|
|
59
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
25
|
exports.SearchForm = void 0;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
26
|
+
const React = __importStar(require("react"));
|
|
27
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
28
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
29
|
+
const button_1 = require("@workday/canvas-kit-react/button");
|
|
30
|
+
const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
|
|
31
|
+
const form_field_1 = require("@workday/canvas-kit-react/form-field");
|
|
32
|
+
const combobox_1 = require("@workday/canvas-kit-labs-react/combobox");
|
|
33
|
+
const text_input_1 = require("@workday/canvas-kit-react/text-input");
|
|
34
|
+
const themes_1 = require("./themes");
|
|
35
|
+
const chroma_js_1 = __importDefault(require("chroma-js"));
|
|
71
36
|
function getInputColors(theme, isFocused) {
|
|
72
37
|
return {
|
|
73
38
|
background: isFocused && theme.backgroundFocus ? theme.backgroundFocus : theme.background,
|
|
@@ -79,19 +44,18 @@ function getInputColors(theme, isFocused) {
|
|
|
79
44
|
boxShadow: isFocused && theme.boxShadowFocus ? theme.boxShadowFocus : theme.boxShadow,
|
|
80
45
|
};
|
|
81
46
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
47
|
+
const formCollapsedBackground = tokens_1.colors.frenchVanilla100;
|
|
48
|
+
const maxWidth = 480;
|
|
49
|
+
const minWidth = 120;
|
|
50
|
+
const StyledSearchForm = common_1.styled('form')({
|
|
86
51
|
position: 'relative',
|
|
87
52
|
flexGrow: 1,
|
|
88
53
|
display: 'flex',
|
|
89
54
|
alignItems: 'center',
|
|
90
55
|
marginLeft: tokens_1.space.m,
|
|
91
56
|
minWidth: minWidth,
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
var collapseStyles = isCollapsed
|
|
57
|
+
}, ({ isCollapsed, showForm, rightAlign, grow }) => {
|
|
58
|
+
const collapseStyles = isCollapsed
|
|
95
59
|
? {
|
|
96
60
|
top: 0,
|
|
97
61
|
right: 0,
|
|
@@ -107,34 +71,30 @@ var StyledSearchForm = common_1.styled('form')({
|
|
|
107
71
|
zIndex: 1,
|
|
108
72
|
}
|
|
109
73
|
: {};
|
|
110
|
-
|
|
74
|
+
const rightAlignStyles = rightAlign
|
|
111
75
|
? {
|
|
112
76
|
textAlign: 'right',
|
|
113
77
|
maxWidth: grow ? '100%' : maxWidth,
|
|
114
78
|
}
|
|
115
79
|
: {};
|
|
116
|
-
return
|
|
80
|
+
return { ...rightAlignStyles, ...collapseStyles };
|
|
117
81
|
});
|
|
118
|
-
|
|
119
|
-
position:
|
|
82
|
+
const SearchContainer = common_1.styled('div')({
|
|
83
|
+
position: `relative`,
|
|
120
84
|
display: 'flex',
|
|
121
85
|
alignItems: 'center',
|
|
122
|
-
width:
|
|
86
|
+
width: `100%`,
|
|
123
87
|
textAlign: 'left',
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
var SearchCombobox = common_1.styled(combobox_1.Combobox)({
|
|
131
|
-
width: "100%",
|
|
88
|
+
}, ({ height }) => ({
|
|
89
|
+
minHeight: height,
|
|
90
|
+
}));
|
|
91
|
+
const SearchCombobox = common_1.styled(combobox_1.Combobox)({
|
|
92
|
+
width: `100%`,
|
|
132
93
|
});
|
|
133
|
-
|
|
134
|
-
var isCollapsed = _a.isCollapsed, isHidden = _a.isHidden;
|
|
94
|
+
const SearchIcon = common_1.styled(button_1.TertiaryButton)(({ isCollapsed, isHidden }) => {
|
|
135
95
|
return {
|
|
136
|
-
position:
|
|
137
|
-
margin: isCollapsed ?
|
|
96
|
+
position: `absolute`,
|
|
97
|
+
margin: isCollapsed ? `auto ${tokens_1.space.xxs}` : `auto ${tokens_1.space.xxxs}`,
|
|
138
98
|
top: 0,
|
|
139
99
|
bottom: 0,
|
|
140
100
|
left: 0,
|
|
@@ -143,19 +103,25 @@ var SearchIcon = common_1.styled(button_1.TertiaryButton)(function (_a) {
|
|
|
143
103
|
display: isHidden ? 'none' : 'flex',
|
|
144
104
|
};
|
|
145
105
|
});
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
var collapseStyles = isCollapsed && showForm
|
|
106
|
+
const CloseButton = common_1.styled(button_1.TertiaryButton)(({ isCollapsed, showForm }) => {
|
|
107
|
+
const collapseStyles = isCollapsed && showForm
|
|
149
108
|
? {
|
|
150
109
|
display: 'inline-block',
|
|
151
110
|
}
|
|
152
111
|
: {
|
|
153
112
|
display: 'none',
|
|
154
113
|
};
|
|
155
|
-
return
|
|
114
|
+
return {
|
|
115
|
+
position: `absolute`,
|
|
116
|
+
top: 0,
|
|
117
|
+
bottom: 0,
|
|
118
|
+
right: 0,
|
|
119
|
+
margin: `auto ${tokens_1.space.xxs}`,
|
|
120
|
+
zIndex: 3,
|
|
121
|
+
...collapseStyles,
|
|
122
|
+
};
|
|
156
123
|
});
|
|
157
|
-
|
|
158
|
-
var isCollapsed = _a.isCollapsed, showForm = _a.showForm, grow = _a.grow, height = _a.height;
|
|
124
|
+
const SearchField = common_1.styled(form_field_1.FormField)(({ isCollapsed, showForm, grow, height }) => {
|
|
159
125
|
return {
|
|
160
126
|
display: (isCollapsed && showForm) || !isCollapsed ? 'inline-block' : 'none',
|
|
161
127
|
width: '100%',
|
|
@@ -167,16 +133,15 @@ var SearchField = common_1.styled(form_field_1.FormField)(function (_a) {
|
|
|
167
133
|
},
|
|
168
134
|
};
|
|
169
135
|
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
var collapseStyles = isCollapsed
|
|
136
|
+
const SearchInput = common_1.styled(text_input_1.TextInput)(({ isCollapsed, inputColors, grow, height }) => {
|
|
137
|
+
const collapseStyles = isCollapsed
|
|
173
138
|
? {
|
|
174
139
|
fontSize: '20px',
|
|
175
140
|
paddingLeft: tokens_1.spaceNumbers.xl + tokens_1.spaceNumbers.s,
|
|
176
141
|
paddingRight: tokens_1.spaceNumbers.xl + tokens_1.spaceNumbers.s,
|
|
177
142
|
maxWidth: 'none',
|
|
178
143
|
minWidth: 0,
|
|
179
|
-
backgroundColor:
|
|
144
|
+
backgroundColor: `rgba(0, 0, 0, 0)`,
|
|
180
145
|
height: height,
|
|
181
146
|
}
|
|
182
147
|
: {
|
|
@@ -187,11 +152,22 @@ var SearchInput = common_1.styled(text_input_1.TextInput)(function (_a) {
|
|
|
187
152
|
backgroundColor: inputColors.background,
|
|
188
153
|
height: height,
|
|
189
154
|
};
|
|
190
|
-
return
|
|
155
|
+
return {
|
|
156
|
+
fontSize: '14px',
|
|
157
|
+
boxShadow: inputColors.boxShadow,
|
|
158
|
+
color: inputColors.color,
|
|
159
|
+
border: 'none',
|
|
160
|
+
WebkitAppearance: 'none',
|
|
161
|
+
transition: 'background-color 120ms, color 120ms, box-shadow 200ms, border-color 200ms',
|
|
162
|
+
zIndex: 2,
|
|
163
|
+
width: '100%',
|
|
164
|
+
'&::-webkit-search-cancel-button': {
|
|
191
165
|
display: 'none',
|
|
192
|
-
},
|
|
166
|
+
},
|
|
167
|
+
'&::placeholder': {
|
|
193
168
|
color: inputColors.placeholderColor,
|
|
194
|
-
},
|
|
169
|
+
},
|
|
170
|
+
'&:not([disabled])': {
|
|
195
171
|
'&:focus, &:active': {
|
|
196
172
|
outline: 'none',
|
|
197
173
|
boxShadow: inputColors.boxShadow,
|
|
@@ -199,93 +175,93 @@ var SearchInput = common_1.styled(text_input_1.TextInput)(function (_a) {
|
|
|
199
175
|
'&:hover': {
|
|
200
176
|
backgroundColor: inputColors.backgroundHover,
|
|
201
177
|
},
|
|
202
|
-
}
|
|
178
|
+
},
|
|
179
|
+
...collapseStyles,
|
|
180
|
+
};
|
|
203
181
|
});
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
_this.state = {
|
|
182
|
+
class SearchForm extends React.Component {
|
|
183
|
+
constructor() {
|
|
184
|
+
super(...arguments);
|
|
185
|
+
this.inputRef = React.createRef();
|
|
186
|
+
this.openRef = React.createRef();
|
|
187
|
+
this.defaultLabelId = common_1.generateUniqueId();
|
|
188
|
+
this.state = {
|
|
212
189
|
showForm: false,
|
|
213
190
|
searchQuery: '',
|
|
214
191
|
isFocused: false,
|
|
215
192
|
};
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (typeof
|
|
219
|
-
theme = themes_1.searchThemes[
|
|
193
|
+
this.getTheme = () => {
|
|
194
|
+
let theme;
|
|
195
|
+
if (typeof this.props.searchTheme === 'number') {
|
|
196
|
+
theme = themes_1.searchThemes[this.props.searchTheme];
|
|
220
197
|
}
|
|
221
|
-
else if (
|
|
222
|
-
theme =
|
|
198
|
+
else if (this.props.searchTheme) {
|
|
199
|
+
theme = this.props.searchTheme;
|
|
223
200
|
}
|
|
224
201
|
else {
|
|
225
202
|
theme = themes_1.searchThemes[themes_1.SearchTheme.Light];
|
|
226
203
|
}
|
|
227
204
|
return theme;
|
|
228
205
|
};
|
|
229
|
-
|
|
230
|
-
|
|
206
|
+
this.getThemeColors = () => {
|
|
207
|
+
const theme = this.props.isCollapsed && this.state.showForm
|
|
231
208
|
? themes_1.searchThemes[themes_1.SearchTheme.Transparent]
|
|
232
|
-
:
|
|
233
|
-
return getInputColors(theme,
|
|
209
|
+
: this.getTheme();
|
|
210
|
+
return getInputColors(theme, this.state.isFocused);
|
|
234
211
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (
|
|
212
|
+
this.getIconButtonType = () => {
|
|
213
|
+
let background = this.getThemeColors().background || `#fff`;
|
|
214
|
+
if (this.props.isCollapsed && this.state.showForm) {
|
|
238
215
|
background = formCollapsedBackground;
|
|
239
216
|
}
|
|
240
|
-
|
|
217
|
+
const isDarkBackground = chroma_js_1.default(background).get('lab.l') < 70;
|
|
241
218
|
return isDarkBackground ? 'inverse' : undefined;
|
|
242
219
|
};
|
|
243
|
-
|
|
220
|
+
this.handleSubmit = (event) => {
|
|
244
221
|
event.preventDefault();
|
|
245
|
-
if (
|
|
246
|
-
|
|
222
|
+
if (this.props.allowEmptyStringSearch || this.state.searchQuery.trim()) {
|
|
223
|
+
this.props.onSubmit(event);
|
|
247
224
|
}
|
|
248
225
|
else {
|
|
249
|
-
|
|
226
|
+
this.focusInput();
|
|
250
227
|
}
|
|
251
228
|
};
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
|
|
229
|
+
this.openCollapsedSearch = () => {
|
|
230
|
+
if (this.props.isCollapsed && !this.state.showForm) {
|
|
231
|
+
this.setState({ showForm: true });
|
|
255
232
|
}
|
|
256
233
|
};
|
|
257
|
-
|
|
258
|
-
if (
|
|
259
|
-
|
|
234
|
+
this.closeCollapsedSearch = () => {
|
|
235
|
+
if (this.props.isCollapsed && this.state.showForm) {
|
|
236
|
+
this.setState({ showForm: false });
|
|
260
237
|
}
|
|
261
238
|
};
|
|
262
|
-
|
|
263
|
-
if (
|
|
264
|
-
|
|
239
|
+
this.focusInput = () => {
|
|
240
|
+
if (this.inputRef.current) {
|
|
241
|
+
this.inputRef.current.focus();
|
|
265
242
|
}
|
|
266
243
|
};
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
|
|
244
|
+
this.focusOpen = () => {
|
|
245
|
+
if (this.openRef.current) {
|
|
246
|
+
this.openRef.current.focus();
|
|
270
247
|
}
|
|
271
248
|
};
|
|
272
|
-
|
|
273
|
-
|
|
249
|
+
this.handleFocus = () => {
|
|
250
|
+
this.setState({ isFocused: true });
|
|
274
251
|
};
|
|
275
|
-
|
|
276
|
-
|
|
252
|
+
this.handleBlur = () => {
|
|
253
|
+
this.setState({ isFocused: false });
|
|
277
254
|
};
|
|
278
|
-
|
|
255
|
+
this.handleSearchInputChange = (event) => {
|
|
279
256
|
event.preventDefault();
|
|
280
|
-
|
|
281
|
-
if (
|
|
282
|
-
|
|
257
|
+
this.setState({ searchQuery: event.target.value });
|
|
258
|
+
if (this.props.onInputChange) {
|
|
259
|
+
this.props.onInputChange(event);
|
|
283
260
|
}
|
|
284
261
|
};
|
|
285
|
-
return _this;
|
|
286
262
|
}
|
|
287
|
-
|
|
288
|
-
|
|
263
|
+
componentDidUpdate(prevProps, prevState) {
|
|
264
|
+
const showFormToggled = this.state.showForm !== prevState.showForm;
|
|
289
265
|
if (showFormToggled) {
|
|
290
266
|
if (this.state.showForm) {
|
|
291
267
|
this.focusInput();
|
|
@@ -294,19 +270,18 @@ var SearchForm = /** @class */ (function (_super) {
|
|
|
294
270
|
this.focusOpen();
|
|
295
271
|
}
|
|
296
272
|
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return (React.createElement(StyledSearchForm,
|
|
273
|
+
}
|
|
274
|
+
render() {
|
|
275
|
+
const { clearButtonAriaLabel = 'Reset Search Form', placeholder = 'Search', inputLabel = 'Search', submitAriaLabel = 'Search', openButtonAriaLabel = 'Open Search', closeButtonAriaLabel = 'Cancel', labelId = this.defaultLabelId, showClearButton = true, height = 40, grow, onSubmit, isCollapsed, onInputChange, autocompleteItems, initialValue, searchTheme, rightAlign, allowEmptyStringSearch = false, ...elemProps } = this.props;
|
|
276
|
+
return (React.createElement(StyledSearchForm, Object.assign({ role: "search", action: ".", rightAlign: rightAlign, grow: grow, "aria-labelledby": labelId, isCollapsed: isCollapsed, onSubmit: this.handleSubmit, showForm: this.state.showForm }, elemProps),
|
|
301
277
|
React.createElement(SearchContainer, { height: height },
|
|
302
278
|
React.createElement(SearchIcon, { "aria-label": submitAriaLabel, icon: canvas_system_icons_web_1.searchIcon, isCollapsed: isCollapsed, variant: this.getIconButtonType(), type: "submit", isHidden: !!isCollapsed && !this.state.showForm }),
|
|
303
279
|
React.createElement(SearchIcon, { "aria-label": openButtonAriaLabel, icon: canvas_system_icons_web_1.searchIcon, isCollapsed: isCollapsed, variant: this.getIconButtonType(), onClick: this.openCollapsedSearch, ref: this.openRef, type: "button", isHidden: !isCollapsed || (!!isCollapsed && this.state.showForm) }),
|
|
304
|
-
React.createElement(SearchField, { grow: grow, id:
|
|
305
|
-
React.createElement(SearchCombobox, { initialValue: initialValue, clearButtonVariant: this.getIconButtonType(), autocompleteItems: autocompleteItems, onChange: this.handleSearchInputChange, onFocus: this.handleFocus, onBlur: this.handleBlur, showClearButton: !isCollapsed && showClearButton, clearButtonAriaLabel: clearButtonAriaLabel, labelId:
|
|
280
|
+
React.createElement(SearchField, { grow: grow, id: labelId, inputId: `input-${labelId}`, label: inputLabel, labelPosition: form_field_1.FormFieldLabelPosition.Hidden, useFieldset: false, isCollapsed: isCollapsed, showForm: this.state.showForm, height: height },
|
|
281
|
+
React.createElement(SearchCombobox, { initialValue: initialValue, clearButtonVariant: this.getIconButtonType(), autocompleteItems: autocompleteItems, onChange: this.handleSearchInputChange, onFocus: this.handleFocus, onBlur: this.handleBlur, showClearButton: !isCollapsed && showClearButton, clearButtonAriaLabel: clearButtonAriaLabel, labelId: labelId },
|
|
306
282
|
React.createElement(SearchInput, { ref: this.inputRef, value: this.state.searchQuery, placeholder: placeholder, isCollapsed: isCollapsed, inputColors: this.getThemeColors(), height: height, name: "search", autoComplete: "off" }))),
|
|
307
283
|
React.createElement(CloseButton, { "aria-label": closeButtonAriaLabel, icon: canvas_system_icons_web_1.xIcon, isCollapsed: isCollapsed, showForm: this.state.showForm, onClick: this.closeCollapsedSearch, type: "button" }))));
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return SearchForm;
|
|
311
|
-
}(React.Component));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
312
286
|
exports.SearchForm = SearchForm;
|
|
287
|
+
SearchForm.Theme = themes_1.SearchTheme;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.searchThemes = exports.SearchTheme = void 0;
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const common_1 = require("@workday/canvas-kit-react/common");
|
|
5
|
+
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
7
6
|
var SearchTheme;
|
|
8
7
|
(function (SearchTheme) {
|
|
9
8
|
SearchTheme[SearchTheme["Light"] = 0] = "Light";
|
|
10
9
|
SearchTheme[SearchTheme["Dark"] = 1] = "Dark";
|
|
11
10
|
SearchTheme[SearchTheme["Transparent"] = 2] = "Transparent";
|
|
12
11
|
})(SearchTheme = exports.SearchTheme || (exports.SearchTheme = {}));
|
|
13
|
-
exports.searchThemes =
|
|
14
|
-
|
|
12
|
+
exports.searchThemes = {
|
|
13
|
+
[SearchTheme.Transparent]: {
|
|
15
14
|
background: 'rgba(0, 0, 0, 0)',
|
|
16
15
|
backgroundFocus: 'rgba(0, 0, 0, 0)',
|
|
17
16
|
color: tokens_1.colors.blackPepper300,
|
|
@@ -21,7 +20,7 @@ exports.searchThemes = (_a = {},
|
|
|
21
20
|
boxShadow: 'none',
|
|
22
21
|
boxShadowFocus: 'none',
|
|
23
22
|
},
|
|
24
|
-
|
|
23
|
+
[SearchTheme.Light]: {
|
|
25
24
|
background: tokens_1.colors.soap200,
|
|
26
25
|
backgroundFocus: tokens_1.colors.soap200,
|
|
27
26
|
backgroundHover: tokens_1.colors.soap300,
|
|
@@ -30,7 +29,7 @@ exports.searchThemes = (_a = {},
|
|
|
30
29
|
boxShadow: 'none',
|
|
31
30
|
boxShadowFocus: common_1.focusRing().boxShadow,
|
|
32
31
|
},
|
|
33
|
-
|
|
32
|
+
[SearchTheme.Dark]: {
|
|
34
33
|
background: 'rgba(0, 0, 0, 0.2)',
|
|
35
34
|
backgroundFocus: tokens_1.colors.frenchVanilla100,
|
|
36
35
|
color: tokens_1.colors.frenchVanilla100,
|
|
@@ -39,4 +38,4 @@ exports.searchThemes = (_a = {},
|
|
|
39
38
|
placeholderColorFocus: tokens_1.colors.licorice300,
|
|
40
39
|
boxShadow: 'none',
|
|
41
40
|
},
|
|
42
|
-
|
|
41
|
+
};
|
|
@@ -1,58 +1,40 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
13
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
14
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
15
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
16
|
-
r[k] = a[j];
|
|
17
|
-
return r;
|
|
18
|
-
};
|
|
19
1
|
import React, { Fragment, useState } from 'react';
|
|
20
2
|
import styled from '@emotion/styled';
|
|
21
3
|
import { space } from '@workday/canvas-kit-react/tokens';
|
|
22
4
|
import { accessibleHide, generateUniqueId } from '@workday/canvas-kit-react/common';
|
|
23
5
|
import { getOptionId, listBoxIdPart, getTextFromElement } from './Combobox';
|
|
24
|
-
|
|
6
|
+
const Autocomplete = styled('ul')({
|
|
25
7
|
margin: 0,
|
|
26
8
|
maxHeight: 200,
|
|
27
9
|
boxSizing: 'border-box',
|
|
28
10
|
overflowY: 'auto',
|
|
29
|
-
padding: space.xxs
|
|
11
|
+
padding: `${space.xxs} 0`,
|
|
30
12
|
});
|
|
31
|
-
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var listBoxProps = {
|
|
13
|
+
const AccessibleHide = styled('span')(accessibleHide);
|
|
14
|
+
export const AutocompleteList = ({ autocompleteItems, comboboxId, selectedIndex, handleAutocompleteClick, labelId, showGroupText, }) => {
|
|
15
|
+
const [randomComponentId] = useState(generateUniqueId); // https://codesandbox.io/s/p2ndq
|
|
16
|
+
const componentId = comboboxId || randomComponentId;
|
|
17
|
+
const listBoxProps = {
|
|
37
18
|
role: 'listbox',
|
|
38
|
-
id: componentId
|
|
19
|
+
id: `${componentId}-${listBoxIdPart}`,
|
|
39
20
|
'aria-labelledby': labelId,
|
|
40
21
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
React.createElement(AccessibleHide, { key:
|
|
44
|
-
|
|
22
|
+
const createListItem = (listboxItem, itemIndex, groupMessage) => {
|
|
23
|
+
const children = [
|
|
24
|
+
React.createElement(AccessibleHide, { key: `group-message-${itemIndex}` }, groupMessage),
|
|
25
|
+
...React.Children.toArray(listboxItem.props.children),
|
|
26
|
+
];
|
|
45
27
|
return (React.createElement(Fragment, { key: itemIndex }, React.cloneElement(listboxItem, {
|
|
46
28
|
children: children,
|
|
47
29
|
id: getOptionId(componentId, itemIndex),
|
|
48
30
|
role: 'option',
|
|
49
31
|
isFocused: selectedIndex === itemIndex,
|
|
50
32
|
'aria-selected': selectedIndex === itemIndex ? true : undefined,
|
|
51
|
-
onMouseDown:
|
|
33
|
+
onMouseDown: (event) => {
|
|
52
34
|
// prevent focus from shifting away from the the combobox
|
|
53
35
|
event.preventDefault();
|
|
54
36
|
},
|
|
55
|
-
onClick:
|
|
37
|
+
onClick: (event) => {
|
|
56
38
|
event.preventDefault();
|
|
57
39
|
handleAutocompleteClick(event, listboxItem.props);
|
|
58
40
|
},
|
|
@@ -62,29 +44,26 @@ export var AutocompleteList = function (_a) {
|
|
|
62
44
|
return null;
|
|
63
45
|
}
|
|
64
46
|
else if (autocompleteItems[0].hasOwnProperty('header')) {
|
|
65
|
-
|
|
66
|
-
return (React.createElement(Autocomplete,
|
|
67
|
-
|
|
68
|
-
var groupLabel = "itemGroup-" + componentId + "-" + groupIndex;
|
|
47
|
+
let itemIndex = 0;
|
|
48
|
+
return (React.createElement(Autocomplete, Object.assign({}, listBoxProps), autocompleteItems.map(({ header, items }, groupIndex) => {
|
|
49
|
+
const groupLabel = `itemGroup-${componentId}-${groupIndex}`;
|
|
69
50
|
return (React.createElement(Fragment, { key: groupLabel },
|
|
70
51
|
React.cloneElement(header, {
|
|
71
52
|
role: 'presentation',
|
|
72
|
-
style: { pointerEvents:
|
|
53
|
+
style: { pointerEvents: `none` },
|
|
73
54
|
}),
|
|
74
|
-
items.map(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
?
|
|
55
|
+
items.map((listboxItem) => {
|
|
56
|
+
const headerName = getTextFromElement(header);
|
|
57
|
+
const groupMessage = showGroupText
|
|
58
|
+
? `Entering group ${headerName}, with ${items.length} options.`
|
|
78
59
|
: undefined;
|
|
79
|
-
|
|
80
|
-
|
|
60
|
+
const item = createListItem(listboxItem, itemIndex, groupMessage);
|
|
61
|
+
itemIndex++;
|
|
81
62
|
return item;
|
|
82
63
|
})));
|
|
83
64
|
})));
|
|
84
65
|
}
|
|
85
66
|
else {
|
|
86
|
-
return (React.createElement(Autocomplete,
|
|
87
|
-
return createListItem(listboxItem, index);
|
|
88
|
-
})));
|
|
67
|
+
return (React.createElement(Autocomplete, Object.assign({}, listBoxProps), autocompleteItems.map((listboxItem, index) => createListItem(listboxItem, index))));
|
|
89
68
|
}
|
|
90
69
|
};
|