@workday/canvas-kit-preview-react 15.0.0-alpha.0074-next.0 → 15.0.0-alpha.0076-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/multi-select/lib/MultiSelectedItem.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/multi-select/lib/MultiSelectedItem.js +1 -1
- package/index.ts +0 -2
- package/multi-select/lib/MultiSelectedItem.tsx +1 -1
- package/package.json +4 -4
- package/dist/commonjs/pill/index.d.ts +0 -8
- package/dist/commonjs/pill/index.d.ts.map +0 -1
- package/dist/commonjs/pill/index.js +0 -23
- package/dist/commonjs/pill/lib/Pill.d.ts +0 -265
- package/dist/commonjs/pill/lib/Pill.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/Pill.js +0 -147
- package/dist/commonjs/pill/lib/PillAvatar.d.ts +0 -526
- package/dist/commonjs/pill/lib/PillAvatar.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillAvatar.js +0 -22
- package/dist/commonjs/pill/lib/PillCount.d.ts +0 -12
- package/dist/commonjs/pill/lib/PillCount.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillCount.js +0 -21
- package/dist/commonjs/pill/lib/PillIcon.d.ts +0 -54
- package/dist/commonjs/pill/lib/PillIcon.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillIcon.js +0 -20
- package/dist/commonjs/pill/lib/PillIconButton.d.ts +0 -148
- package/dist/commonjs/pill/lib/PillIconButton.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillIconButton.js +0 -21
- package/dist/commonjs/pill/lib/PillLabel.d.ts +0 -14
- package/dist/commonjs/pill/lib/PillLabel.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/PillLabel.js +0 -17
- package/dist/commonjs/pill/lib/usePillModel.d.ts +0 -46
- package/dist/commonjs/pill/lib/usePillModel.d.ts.map +0 -1
- package/dist/commonjs/pill/lib/usePillModel.js +0 -24
- package/dist/commonjs/select/index.d.ts +0 -3
- package/dist/commonjs/select/index.d.ts.map +0 -1
- package/dist/commonjs/select/index.js +0 -17
- package/dist/commonjs/select/lib/Select.d.ts +0 -31
- package/dist/commonjs/select/lib/Select.d.ts.map +0 -1
- package/dist/commonjs/select/lib/Select.js +0 -486
- package/dist/commonjs/select/lib/SelectBase.d.ts +0 -165
- package/dist/commonjs/select/lib/SelectBase.d.ts.map +0 -1
- package/dist/commonjs/select/lib/SelectBase.js +0 -235
- package/dist/commonjs/select/lib/SelectMenu.d.ts +0 -45
- package/dist/commonjs/select/lib/SelectMenu.d.ts.map +0 -1
- package/dist/commonjs/select/lib/SelectMenu.js +0 -195
- package/dist/commonjs/select/lib/SelectOption.d.ts +0 -38
- package/dist/commonjs/select/lib/SelectOption.d.ts.map +0 -1
- package/dist/commonjs/select/lib/SelectOption.js +0 -73
- package/dist/commonjs/select/lib/scrolling.d.ts +0 -5
- package/dist/commonjs/select/lib/scrolling.d.ts.map +0 -1
- package/dist/commonjs/select/lib/scrolling.js +0 -36
- package/dist/commonjs/select/lib/types.d.ts +0 -37
- package/dist/commonjs/select/lib/types.d.ts.map +0 -1
- package/dist/commonjs/select/lib/types.js +0 -2
- package/dist/commonjs/select/lib/utils.d.ts +0 -10
- package/dist/commonjs/select/lib/utils.d.ts.map +0 -1
- package/dist/commonjs/select/lib/utils.js +0 -27
- package/dist/es6/pill/index.d.ts +0 -8
- package/dist/es6/pill/index.d.ts.map +0 -1
- package/dist/es6/pill/index.js +0 -7
- package/dist/es6/pill/lib/Pill.d.ts +0 -265
- package/dist/es6/pill/lib/Pill.d.ts.map +0 -1
- package/dist/es6/pill/lib/Pill.js +0 -144
- package/dist/es6/pill/lib/PillAvatar.d.ts +0 -526
- package/dist/es6/pill/lib/PillAvatar.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillAvatar.js +0 -19
- package/dist/es6/pill/lib/PillCount.d.ts +0 -12
- package/dist/es6/pill/lib/PillCount.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillCount.js +0 -18
- package/dist/es6/pill/lib/PillIcon.d.ts +0 -54
- package/dist/es6/pill/lib/PillIcon.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillIcon.js +0 -17
- package/dist/es6/pill/lib/PillIconButton.d.ts +0 -148
- package/dist/es6/pill/lib/PillIconButton.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillIconButton.js +0 -18
- package/dist/es6/pill/lib/PillLabel.d.ts +0 -14
- package/dist/es6/pill/lib/PillLabel.d.ts.map +0 -1
- package/dist/es6/pill/lib/PillLabel.js +0 -14
- package/dist/es6/pill/lib/usePillModel.d.ts +0 -46
- package/dist/es6/pill/lib/usePillModel.d.ts.map +0 -1
- package/dist/es6/pill/lib/usePillModel.js +0 -21
- package/dist/es6/select/index.d.ts +0 -3
- package/dist/es6/select/index.d.ts.map +0 -1
- package/dist/es6/select/index.js +0 -1
- package/dist/es6/select/lib/Select.d.ts +0 -31
- package/dist/es6/select/lib/Select.d.ts.map +0 -1
- package/dist/es6/select/lib/Select.js +0 -460
- package/dist/es6/select/lib/SelectBase.d.ts +0 -165
- package/dist/es6/select/lib/SelectBase.d.ts.map +0 -1
- package/dist/es6/select/lib/SelectBase.js +0 -208
- package/dist/es6/select/lib/SelectMenu.d.ts +0 -45
- package/dist/es6/select/lib/SelectMenu.d.ts.map +0 -1
- package/dist/es6/select/lib/SelectMenu.js +0 -191
- package/dist/es6/select/lib/SelectOption.d.ts +0 -38
- package/dist/es6/select/lib/SelectOption.d.ts.map +0 -1
- package/dist/es6/select/lib/SelectOption.js +0 -69
- package/dist/es6/select/lib/scrolling.d.ts +0 -5
- package/dist/es6/select/lib/scrolling.d.ts.map +0 -1
- package/dist/es6/select/lib/scrolling.js +0 -32
- package/dist/es6/select/lib/types.d.ts +0 -37
- package/dist/es6/select/lib/types.d.ts.map +0 -1
- package/dist/es6/select/lib/types.js +0 -1
- package/dist/es6/select/lib/utils.d.ts +0 -10
- package/dist/es6/select/lib/utils.d.ts.map +0 -1
- package/dist/es6/select/lib/utils.js +0 -22
- package/pill/index.ts +0 -7
- package/pill/lib/Pill.tsx +0 -285
- package/pill/lib/PillAvatar.tsx +0 -35
- package/pill/lib/PillCount.tsx +0 -44
- package/pill/lib/PillIcon.tsx +0 -32
- package/pill/lib/PillIconButton.tsx +0 -86
- package/pill/lib/PillLabel.tsx +0 -32
- package/pill/lib/usePillModel.tsx +0 -23
- package/pill/package.json +0 -6
- package/select/index.ts +0 -8
- package/select/lib/Select.tsx +0 -595
- package/select/lib/SelectBase.tsx +0 -493
- package/select/lib/SelectMenu.tsx +0 -304
- package/select/lib/SelectOption.tsx +0 -133
- package/select/lib/scrolling.ts +0 -42
- package/select/lib/types.ts +0 -37
- package/select/lib/utils.ts +0 -30
- package/select/package.json +0 -6
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.SelectBase = exports.buttonBorderWidth = void 0;
|
|
27
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
-
const react_1 = __importStar(require("react"));
|
|
29
|
-
const common_1 = require("@workday/canvas-kit-react/common");
|
|
30
|
-
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
31
|
-
const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
|
|
32
|
-
const icon_1 = require("@workday/canvas-kit-react/icon");
|
|
33
|
-
const SelectMenu_1 = require("./SelectMenu");
|
|
34
|
-
const SelectOption_1 = require("./SelectOption");
|
|
35
|
-
const scrolling_1 = require("./scrolling");
|
|
36
|
-
const utils_1 = require("./utils");
|
|
37
|
-
exports.buttonBorderWidth = 1;
|
|
38
|
-
const menuIconSize = tokens_1.space.m;
|
|
39
|
-
const SelectButton = (0, common_1.styled)('button')({
|
|
40
|
-
...tokens_1.type.levels.subtext.large,
|
|
41
|
-
border: `${exports.buttonBorderWidth}px solid ${tokens_1.inputColors.border}`,
|
|
42
|
-
cursor: 'default',
|
|
43
|
-
display: 'block',
|
|
44
|
-
backgroundColor: tokens_1.inputColors.background,
|
|
45
|
-
borderRadius: tokens_1.borderRadius.m,
|
|
46
|
-
boxSizing: 'border-box',
|
|
47
|
-
height: tokens_1.space.xl,
|
|
48
|
-
outline: 'none',
|
|
49
|
-
overflow: 'hidden',
|
|
50
|
-
padding: `calc(${tokens_1.space.xxs} - ${exports.buttonBorderWidth}px)`,
|
|
51
|
-
paddingRight: `calc(${tokens_1.space.xxs} + ${tokens_1.space.m} + (${tokens_1.space.xxs} + ${exports.buttonBorderWidth}px))`,
|
|
52
|
-
textAlign: 'left',
|
|
53
|
-
textOverflow: 'ellipsis',
|
|
54
|
-
transition: '0.2s box-shadow, 0.2s border-color',
|
|
55
|
-
whiteSpace: 'nowrap',
|
|
56
|
-
// width is required (instead of minWidth) in order for the button to
|
|
57
|
-
// be sized properly for lengthy options
|
|
58
|
-
width: `calc((${tokens_1.space.xxxl} * 7) / 2)`,
|
|
59
|
-
'&::placeholder': {
|
|
60
|
-
color: tokens_1.inputColors.placeholder,
|
|
61
|
-
},
|
|
62
|
-
'&:disabled': {
|
|
63
|
-
backgroundColor: tokens_1.inputColors.disabled.background,
|
|
64
|
-
borderColor: tokens_1.inputColors.disabled.border,
|
|
65
|
-
color: tokens_1.inputColors.disabled.text,
|
|
66
|
-
'&::placeholder': {
|
|
67
|
-
color: tokens_1.inputColors.disabled.text,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
}, ({ error, menuVisibility, theme }) => {
|
|
71
|
-
const themedFocusOutlineColor = theme.canvas.palette.common.focusOutline;
|
|
72
|
-
const buttonFocusStyles = {
|
|
73
|
-
borderColor: themedFocusOutlineColor,
|
|
74
|
-
boxShadow: `inset 0 0 0 1px ${themedFocusOutlineColor}`,
|
|
75
|
-
};
|
|
76
|
-
if (error === undefined) {
|
|
77
|
-
// If there isn't an error, apply focus and hover styles if the menu is
|
|
78
|
-
// closed or in the process of closing (otherwise, the menu is opened
|
|
79
|
-
// or in the process of opening: style the button as if it had focus)
|
|
80
|
-
return menuVisibility === 'closed' || menuVisibility === 'closing'
|
|
81
|
-
? {
|
|
82
|
-
'&:focus:not([disabled])': {
|
|
83
|
-
...buttonFocusStyles,
|
|
84
|
-
},
|
|
85
|
-
'&:hover:not([disabled]):not(:focus)': {
|
|
86
|
-
borderColor: tokens_1.inputColors.hoverBorder,
|
|
87
|
-
},
|
|
88
|
-
}
|
|
89
|
-
: { ...buttonFocusStyles };
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
...(0, common_1.errorRing)(error, theme),
|
|
93
|
-
};
|
|
94
|
-
}, ({ grow }) => grow && {
|
|
95
|
-
width: '100%',
|
|
96
|
-
});
|
|
97
|
-
const SelectMenuIcon = (0, common_1.styled)(icon_1.SystemIcon)({
|
|
98
|
-
position: 'absolute',
|
|
99
|
-
top: tokens_1.space.xxxs,
|
|
100
|
-
right: tokens_1.space.xxxs,
|
|
101
|
-
padding: tokens_1.space.xxxs,
|
|
102
|
-
pointerEvents: 'none',
|
|
103
|
-
'& path': {
|
|
104
|
-
transition: '100ms fill',
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
const SelectInput = (0, common_1.styled)('input')({
|
|
108
|
-
display: 'none',
|
|
109
|
-
});
|
|
110
|
-
const SelectWrapper = (0, common_1.styled)('div')({
|
|
111
|
-
position: 'relative',
|
|
112
|
-
}, ({ grow }) => ({
|
|
113
|
-
display: grow ? 'block' : 'inline-block',
|
|
114
|
-
}), ({ disabled }) => ({
|
|
115
|
-
'&:hover .menu-icon path': {
|
|
116
|
-
fill: disabled ? undefined : tokens_1.colors.licorice500,
|
|
117
|
-
},
|
|
118
|
-
}));
|
|
119
|
-
const defaultRenderOption = option => {
|
|
120
|
-
return (0, jsx_runtime_1.jsx)("div", { children: defaultRenderSelected(option) });
|
|
121
|
-
};
|
|
122
|
-
const defaultRenderSelected = option => {
|
|
123
|
-
return option.label;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* @deprecated ⚠️ `SelectBase` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
|
|
127
|
-
*/
|
|
128
|
-
const SelectBase = ({ 'aria-labelledby': ariaLabelledBy, 'aria-required': ariaRequired, as, forwardedButtonRef, localButtonRef, disabled, error, focusedOptionIndex = 0, grow, inputRef, menuPlacement = 'bottom', menuRef, menuVisibility = 'closed', onChange, onKeyDown, onBlur, onClose, onOptionSelection, options, renderOption = defaultRenderOption, renderSelected = defaultRenderSelected, required, shouldMenuAutoFlip = true, shouldMenuAutoFocus = true, value, ...elemProps }) => {
|
|
129
|
-
const focusedOptionRef = react_1.default.useRef(null);
|
|
130
|
-
const menuId = (0, common_1.useUniqueId)();
|
|
131
|
-
const renderOptions = (renderOption) => {
|
|
132
|
-
const selectedOptionIndex = (0, utils_1.getCorrectedIndexByValue)(options, value);
|
|
133
|
-
return options.map((option, index) => {
|
|
134
|
-
const optionProps = {
|
|
135
|
-
'aria-disabled': option.disabled ? true : undefined,
|
|
136
|
-
'aria-selected': selectedOptionIndex === index ? true : undefined,
|
|
137
|
-
error,
|
|
138
|
-
focused: focusedOptionIndex === index,
|
|
139
|
-
id: option.id,
|
|
140
|
-
interactive: menuVisibility === 'opening' || menuVisibility === 'opened',
|
|
141
|
-
key: option.id,
|
|
142
|
-
optionRef: focusedOptionIndex === index ? focusedOptionRef : undefined,
|
|
143
|
-
value: option.value,
|
|
144
|
-
...(onOptionSelection
|
|
145
|
-
? {
|
|
146
|
-
onClick: (event) => {
|
|
147
|
-
// TODO: Figure out why this preventDefault call exists.
|
|
148
|
-
// Removing it doesn't have any obvious consequences,
|
|
149
|
-
// but need to do more careful testing.
|
|
150
|
-
event.preventDefault();
|
|
151
|
-
onOptionSelection(index);
|
|
152
|
-
},
|
|
153
|
-
}
|
|
154
|
-
: {}),
|
|
155
|
-
};
|
|
156
|
-
// Pass in additional information about the option state: focused, selected
|
|
157
|
-
const normalizedOption = {
|
|
158
|
-
...option,
|
|
159
|
-
focused: optionProps.focused,
|
|
160
|
-
selected: !!optionProps['aria-selected'],
|
|
161
|
-
};
|
|
162
|
-
return (0, jsx_runtime_1.jsx)(SelectOption_1.SelectOption, { ...optionProps, children: renderOption(normalizedOption) });
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
// If the focused option changed, scroll the newly focused option into view (if
|
|
166
|
-
// necessary) but do NOT center it
|
|
167
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
168
|
-
const focusedOption = focusedOptionRef.current;
|
|
169
|
-
if (focusedOption) {
|
|
170
|
-
// TODO: Figure out if rAF is the best approach here. I initially added
|
|
171
|
-
// rAF to get the Select States Menu On story to render correctly in IE.
|
|
172
|
-
// Without rAF, the menu is scrolled slightly further down than it should
|
|
173
|
-
// be (only in IE, and only in the Menu On visual testing stories), which
|
|
174
|
-
// triggers a visual regression. We're inside useLayoutEffect here so I
|
|
175
|
-
// didn't expect to need rAF in order to make proper measurements, but it
|
|
176
|
-
// seems to be necessary in IE.
|
|
177
|
-
//
|
|
178
|
-
// This rAF call also has the additional benefit of fixing a jarring menu
|
|
179
|
-
// placement issue in IE (https://github.com/Workday/canvas-kit/issues/791),
|
|
180
|
-
// so I'm leaving it in for now.
|
|
181
|
-
const animateId = requestAnimationFrame(() => {
|
|
182
|
-
// We cannot use the native Element.scrollIntoView() here because it
|
|
183
|
-
// doesn't work properly with the portalled menu: when using the keyboard
|
|
184
|
-
// to advance focus through the options, using scrollIntoView to keep the
|
|
185
|
-
// newly focused option in view also scrolls the ENTIRE page. Instead, we
|
|
186
|
-
// call our own scrollIntoViewIfNeeded function.
|
|
187
|
-
(0, scrolling_1.scrollIntoViewIfNeeded)(focusedOption, false);
|
|
188
|
-
});
|
|
189
|
-
return () => {
|
|
190
|
-
cancelAnimationFrame(animateId);
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
return undefined;
|
|
194
|
-
}, [focusedOptionIndex]);
|
|
195
|
-
// If the menu was just opened, scroll the focused option into view (if
|
|
196
|
-
// necessary) and center it
|
|
197
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
198
|
-
const focusedOption = focusedOptionRef.current;
|
|
199
|
-
// We need to scroll if the menu is either opening or opened in case we decide to
|
|
200
|
-
// bypass the opening state and jump straight to opened (like in visual testing,
|
|
201
|
-
// for instance)
|
|
202
|
-
if (focusedOption && (menuVisibility === 'opening' || menuVisibility === 'opened')) {
|
|
203
|
-
// TODO: This rAF call is also necessary for the Menu On visual testing
|
|
204
|
-
// stories to render properly in IE (see above, both rAF calls need to be
|
|
205
|
-
// present). It has no bearing on the menu placement issue.
|
|
206
|
-
const animateId = requestAnimationFrame(() => {
|
|
207
|
-
(0, scrolling_1.scrollIntoViewIfNeeded)(focusedOption, true);
|
|
208
|
-
});
|
|
209
|
-
return () => {
|
|
210
|
-
cancelAnimationFrame(animateId);
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
return undefined;
|
|
214
|
-
}, [menuVisibility]);
|
|
215
|
-
// Do a bit of error-checking in case options weren't provided
|
|
216
|
-
const hasOptions = options.length > 0;
|
|
217
|
-
const selectedOption = hasOptions ? options[(0, utils_1.getCorrectedIndexByValue)(options, value)] : null;
|
|
218
|
-
const selectedOptionValue = selectedOption ? selectedOption.value : '';
|
|
219
|
-
return ((0, jsx_runtime_1.jsxs)(SelectWrapper, { grow: grow, disabled: disabled, children: [(0, jsx_runtime_1.jsx)(SelectButton, { "aria-expanded": menuVisibility !== 'closed' ? 'true' : undefined, "aria-haspopup": "listbox", "aria-controls": menuVisibility !== 'closed' ? menuId : undefined, as: as, disabled: disabled, error: error, grow: grow, menuVisibility: menuVisibility, onKeyDown: onKeyDown, onBlur: event => {
|
|
220
|
-
if (menuVisibility === 'closed') {
|
|
221
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
event.preventDefault();
|
|
225
|
-
event.stopPropagation();
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
// Prevent Firefox from triggering click handler on spacebar during
|
|
229
|
-
// type-ahead when the menu is closed (and, thus, incorrectly displaying
|
|
230
|
-
// the menu)
|
|
231
|
-
onKeyUp: e => {
|
|
232
|
-
e.preventDefault();
|
|
233
|
-
}, ref: forwardedButtonRef, type: "button", value: selectedOptionValue, ...elemProps, children: !!selectedOption && renderSelected(selectedOption) }), (0, jsx_runtime_1.jsx)(SelectInput, { onChange: onChange, ref: inputRef, type: "text", value: selectedOptionValue }), hasOptions && menuVisibility !== 'closed' && ((0, jsx_runtime_1.jsx)(SelectMenu_1.SelectMenu, { "aria-activedescendant": options[focusedOptionIndex].id, "aria-labelledby": ariaLabelledBy, "aria-required": ariaRequired || required ? true : undefined, buttonRef: localButtonRef, id: menuId, error: error, menuRef: menuRef, onKeyDown: onKeyDown, onClose: onClose, placement: menuPlacement, shouldAutoFlip: shouldMenuAutoFlip, shouldAutoFocus: shouldMenuAutoFocus, visibility: menuVisibility, children: renderOptions(renderOption) })), (0, jsx_runtime_1.jsx)(SelectMenuIcon, { className: "menu-icon", icon: canvas_system_icons_web_1.caretDownSmallIcon, color: disabled ? tokens_1.colors.licorice100 : tokens_1.colors.licorice200, colorHover: disabled ? tokens_1.colors.licorice100 : tokens_1.colors.licorice500, size: `${menuIconSize}rem` })] }));
|
|
234
|
-
};
|
|
235
|
-
exports.SelectBase = SelectBase;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Themeable } from '@workday/canvas-kit-react/common';
|
|
3
|
-
import { SelectProps } from './Select';
|
|
4
|
-
import { MenuPlacement, MenuVisibility } from './types';
|
|
5
|
-
interface SelectMenuProps extends Themeable, React.HTMLAttributes<HTMLUListElement>, Pick<SelectProps, 'error'> {
|
|
6
|
-
/**
|
|
7
|
-
* The ref to the anchor button element. Required to anchor the menu.
|
|
8
|
-
*/
|
|
9
|
-
buttonRef?: React.RefObject<HTMLButtonElement>;
|
|
10
|
-
/**
|
|
11
|
-
* The ref to the underlying menu/listbox element. Use this to imperatively manipulate the menu.
|
|
12
|
-
*/
|
|
13
|
-
menuRef?: React.RefObject<HTMLUListElement>;
|
|
14
|
-
/**
|
|
15
|
-
* The function called when the menu is closed.
|
|
16
|
-
*/
|
|
17
|
-
onClose?: () => void;
|
|
18
|
-
/**
|
|
19
|
-
* The placement of the SelectMenu relative to its corresponding button.
|
|
20
|
-
* @default 'bottom'
|
|
21
|
-
*/
|
|
22
|
-
placement?: MenuPlacement;
|
|
23
|
-
/**
|
|
24
|
-
* If true, automatically flip the SelectMenu to keep it visible if necessary (e.g., if the the SelectMenu would otherwise display below the visible area of the viewport).
|
|
25
|
-
* @default true
|
|
26
|
-
*/
|
|
27
|
-
shouldAutoFlip?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* If true, focus the SelectMenu when it's shown. Set to false if you don't want to focus the SelectMenu automatically (for visual testing purposes, for example).
|
|
30
|
-
* @default true
|
|
31
|
-
*/
|
|
32
|
-
shouldAutoFocus?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* The visibility state of the SelectMenu.
|
|
35
|
-
* @default 'closed'
|
|
36
|
-
*/
|
|
37
|
-
visibility?: MenuVisibility;
|
|
38
|
-
}
|
|
39
|
-
export declare const menuAnimationDuration = 200;
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated ⚠️ `SelectMenu` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
|
|
42
|
-
*/
|
|
43
|
-
export declare const SelectMenu: ({ buttonRef, children, error, menuRef, onClose, placement, shouldAutoFlip, shouldAutoFocus, visibility, ...elemProps }: SelectMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
44
|
-
export {};
|
|
45
|
-
//# sourceMappingURL=SelectMenu.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMenu.d.ts","sourceRoot":"","sources":["../../../../select/lib/SelectMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAG/E,OAAO,EAAgC,SAAS,EAAS,MAAM,kCAAkC,CAAC;AAYlG,OAAO,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AACrC,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAEtD,UAAU,eACR,SAAQ,SAAS,EACf,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,EACtC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC/C;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED,eAAO,MAAM,qBAAqB,MAAM,CAAC;AA8KzC;;GAEG;AACH,eAAO,MAAM,UAAU,2HAWpB,eAAe,4CA2DjB,CAAC"}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectMenu = exports.menuAnimationDuration = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const common_1 = require("@workday/canvas-kit-react/common");
|
|
7
|
-
const popup_1 = require("@workday/canvas-kit-react/popup");
|
|
8
|
-
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
9
|
-
exports.menuAnimationDuration = 200;
|
|
10
|
-
const menuBorderStyles = (theme, error) => {
|
|
11
|
-
let borderColor = theme.canvas.palette.common.focusOutline;
|
|
12
|
-
let dividerBorderColor = borderColor;
|
|
13
|
-
let dividerBorderWidth = 1;
|
|
14
|
-
if (error === common_1.ErrorType.Error) {
|
|
15
|
-
borderColor = theme.canvas.palette.error.main;
|
|
16
|
-
dividerBorderColor = borderColor;
|
|
17
|
-
}
|
|
18
|
-
else if (error === common_1.ErrorType.Caution) {
|
|
19
|
-
borderColor = theme.canvas.palette.alert.darkest;
|
|
20
|
-
dividerBorderColor = theme.canvas.palette.alert.main;
|
|
21
|
-
dividerBorderWidth = 2;
|
|
22
|
-
}
|
|
23
|
-
const dividerBorder = `${dividerBorderWidth}px solid ${dividerBorderColor}`;
|
|
24
|
-
return {
|
|
25
|
-
borderColor: borderColor,
|
|
26
|
-
// Render the divider using a pseudo-element
|
|
27
|
-
'&:before': {
|
|
28
|
-
backgroundColor: tokens_1.colors.soap400,
|
|
29
|
-
borderLeft: dividerBorder,
|
|
30
|
-
borderRight: dividerBorder,
|
|
31
|
-
boxSizing: 'border-box',
|
|
32
|
-
content: '""',
|
|
33
|
-
display: 'block',
|
|
34
|
-
height: 1,
|
|
35
|
-
position: 'absolute',
|
|
36
|
-
width: '100%',
|
|
37
|
-
'[data-popper-placement="bottom"] &': {
|
|
38
|
-
top: 0,
|
|
39
|
-
},
|
|
40
|
-
'[data-popper-placement="top"] &': {
|
|
41
|
-
bottom: 0,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
const menuListBorderStyles = (theme, error) => {
|
|
47
|
-
let borderColor = theme.canvas.palette.common.focusOutline;
|
|
48
|
-
let borderWidth = 1;
|
|
49
|
-
if (error === common_1.ErrorType.Error) {
|
|
50
|
-
borderColor = theme.canvas.palette.error.main;
|
|
51
|
-
}
|
|
52
|
-
else if (error === common_1.ErrorType.Caution) {
|
|
53
|
-
borderColor = theme.canvas.palette.alert.main;
|
|
54
|
-
borderWidth = 2;
|
|
55
|
-
}
|
|
56
|
-
const border = `${borderWidth}px solid ${borderColor}`;
|
|
57
|
-
return {
|
|
58
|
-
borderLeft: border,
|
|
59
|
-
borderRight: border,
|
|
60
|
-
'[data-popper-placement="bottom"] &': {
|
|
61
|
-
borderBottom: border,
|
|
62
|
-
},
|
|
63
|
-
'[data-popper-placement="top"] &': {
|
|
64
|
-
borderTop: border,
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
const Menu = (0, common_1.styled)('div')({
|
|
69
|
-
backgroundColor: tokens_1.colors.frenchVanilla100,
|
|
70
|
-
border: `1px solid ${tokens_1.inputColors.border}`,
|
|
71
|
-
boxSizing: 'border-box',
|
|
72
|
-
position: 'relative',
|
|
73
|
-
transition: `opacity ${exports.menuAnimationDuration}ms`,
|
|
74
|
-
'[data-popper-placement="bottom"] &': {
|
|
75
|
-
borderRadius: `0 0 ${tokens_1.borderRadius.m} ${tokens_1.borderRadius.m}`,
|
|
76
|
-
borderTop: 0,
|
|
77
|
-
},
|
|
78
|
-
'[data-popper-placement="top"] &': {
|
|
79
|
-
borderRadius: `${tokens_1.borderRadius.m} ${tokens_1.borderRadius.m} 0 0`,
|
|
80
|
-
borderBottom: 0,
|
|
81
|
-
},
|
|
82
|
-
}, ({ error, theme }) => ({
|
|
83
|
-
...menuBorderStyles(theme, error),
|
|
84
|
-
}), ({ visibility }) => ({
|
|
85
|
-
opacity: visibility === 'opening' || visibility === 'opened' || visibility === 'close' ? 1 : 0,
|
|
86
|
-
}), ({ width }) => ({
|
|
87
|
-
width: width,
|
|
88
|
-
}));
|
|
89
|
-
const MenuList = (0, common_1.styled)('ul')({
|
|
90
|
-
listStyle: 'none',
|
|
91
|
-
margin: 0,
|
|
92
|
-
maxHeight: 200,
|
|
93
|
-
outline: 'none',
|
|
94
|
-
overflowY: 'auto',
|
|
95
|
-
padding: 0,
|
|
96
|
-
}, ({ error, theme }) => ({
|
|
97
|
-
...menuListBorderStyles(theme, error),
|
|
98
|
-
}));
|
|
99
|
-
const generatePopperOptions = (props) => {
|
|
100
|
-
const { menuRef, placement, shouldAutoFlip, shouldAutoFocus } = props;
|
|
101
|
-
let fallbackPlacements = [];
|
|
102
|
-
if (shouldAutoFlip) {
|
|
103
|
-
fallbackPlacements = placement === 'top' ? ['bottom'] : ['top'];
|
|
104
|
-
}
|
|
105
|
-
const modifiers = [
|
|
106
|
-
{
|
|
107
|
-
name: 'flip',
|
|
108
|
-
options: {
|
|
109
|
-
fallbackPlacements,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: 'offset',
|
|
114
|
-
options: {
|
|
115
|
-
offset: () => {
|
|
116
|
-
const skidding = 0;
|
|
117
|
-
// Displace menu towards the button to obscure the bottom
|
|
118
|
-
// edge of the button and to create a smooth visual
|
|
119
|
-
// connection between the button and the menu
|
|
120
|
-
const distance = -parseInt(tokens_1.borderRadius.m, 10);
|
|
121
|
-
return [skidding, distance];
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: 'preventOverflow',
|
|
127
|
-
options: {
|
|
128
|
-
// Ensure the menu stays aligned with its reference (button),
|
|
129
|
-
// even if that means the menu is pushed out of view
|
|
130
|
-
mainAxis: false,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
// Disable the fallbackModifier as SelectMenu is properly handled by the
|
|
135
|
-
// flip modifier through shouldAutoFlip prop
|
|
136
|
-
name: 'fallbackModifier',
|
|
137
|
-
enabled: false,
|
|
138
|
-
},
|
|
139
|
-
];
|
|
140
|
-
return {
|
|
141
|
-
modifiers,
|
|
142
|
-
// TODO: Consider using a more general-purpose focus function here rather
|
|
143
|
-
// than relying on Popper's onFirstUpdate for better control over how
|
|
144
|
-
// focus is managed
|
|
145
|
-
onFirstUpdate: () => {
|
|
146
|
-
if (shouldAutoFocus && menuRef && menuRef.current) {
|
|
147
|
-
menuRef.current.focus();
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* @deprecated ⚠️ `SelectMenu` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
|
|
154
|
-
*/
|
|
155
|
-
const SelectMenu = ({ buttonRef, children, error, menuRef, onClose, placement = 'bottom', shouldAutoFlip = true, shouldAutoFocus = true, visibility = 'closed', ...elemProps }) => {
|
|
156
|
-
const model = (0, popup_1.usePopupModel)({
|
|
157
|
-
initialVisibility: 'visible',
|
|
158
|
-
returnFocusRef: buttonRef,
|
|
159
|
-
onHide: onClose,
|
|
160
|
-
});
|
|
161
|
-
const [width, setWidth] = (0, react_1.useState)(0);
|
|
162
|
-
const handleWidthChange = (0, react_1.useCallback)(() => {
|
|
163
|
-
if (buttonRef && buttonRef.current && visibility !== 'closed') {
|
|
164
|
-
const newMenuWidth = buttonRef.current.clientWidth + 2;
|
|
165
|
-
setWidth(newMenuWidth);
|
|
166
|
-
}
|
|
167
|
-
}, [buttonRef, visibility]);
|
|
168
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
169
|
-
handleWidthChange();
|
|
170
|
-
}, [handleWidthChange]);
|
|
171
|
-
// TODO: Figure out a better way to handle width changes in the reference button.
|
|
172
|
-
// Seems like we should resize the menu when the reference button width changes, not
|
|
173
|
-
// necessarily when the window resizes. Resizing the menu on window resize addresses
|
|
174
|
-
// the case when `grow = true` and the user resizes the browser window while the
|
|
175
|
-
// menu is opened, but doesn't address cases where the reference button size changes
|
|
176
|
-
// through other means.
|
|
177
|
-
(0, react_1.useEffect)(() => {
|
|
178
|
-
// Update menu width state on resize to ensure menu resizes as window resizes
|
|
179
|
-
window.addEventListener('resize', handleWidthChange);
|
|
180
|
-
return () => {
|
|
181
|
-
window.removeEventListener('resize', handleWidthChange);
|
|
182
|
-
};
|
|
183
|
-
}, [handleWidthChange]);
|
|
184
|
-
(0, popup_1.useCloseOnEscape)(model);
|
|
185
|
-
(0, popup_1.useCloseOnOutsideClick)(model);
|
|
186
|
-
(0, popup_1.useReturnFocus)(model);
|
|
187
|
-
(0, popup_1.useTransferOnFullscreenExit)(model);
|
|
188
|
-
return ((0, jsx_runtime_1.jsx)(popup_1.Popper, { placement: placement, anchorElement: buttonRef, popperOptions: generatePopperOptions({
|
|
189
|
-
menuRef,
|
|
190
|
-
placement,
|
|
191
|
-
shouldAutoFlip,
|
|
192
|
-
shouldAutoFocus,
|
|
193
|
-
}), ref: model.state.stackRef, children: (0, jsx_runtime_1.jsx)(Menu, { error: error, visibility: visibility, width: width, children: (0, jsx_runtime_1.jsx)(MenuList, { error: error, ref: menuRef, role: "listbox", tabIndex: -1, ...elemProps, children: children }) }) }));
|
|
194
|
-
};
|
|
195
|
-
exports.SelectMenu = SelectMenu;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ErrorType, Themeable } from '@workday/canvas-kit-react/common';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated ⚠️ `SelectOptionProps` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
|
|
5
|
-
*/
|
|
6
|
-
export interface SelectOptionProps extends Themeable, React.LiHTMLAttributes<HTMLLIElement> {
|
|
7
|
-
/**
|
|
8
|
-
* The type of error associated with the SelectOption (if applicable).
|
|
9
|
-
*/
|
|
10
|
-
error?: ErrorType;
|
|
11
|
-
/**
|
|
12
|
-
* If true, set the SelectOption to the focused state.
|
|
13
|
-
* @default false
|
|
14
|
-
*/
|
|
15
|
-
focused?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The HTML `id` of the SelectOption.
|
|
18
|
-
*/
|
|
19
|
-
id?: string;
|
|
20
|
-
/**
|
|
21
|
-
* If true, set the SelectOption to the interactive state. Non-interactive SelectOptions should not give any visual cues that they are interactive (e.g., remove hover styling).
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
interactive?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* The ref to the list item that the styled component renders. Use this to imperatively manipulate the SelectOption (e.g., to scroll to it if it's out of view in the Select menu).
|
|
27
|
-
*/
|
|
28
|
-
optionRef?: React.Ref<HTMLLIElement>;
|
|
29
|
-
/**
|
|
30
|
-
* The value of the SelectOption.
|
|
31
|
-
*/
|
|
32
|
-
value?: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated ⚠️ `SelectOption` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
|
|
36
|
-
*/
|
|
37
|
-
export declare const SelectOption: ({ children, focused, interactive, optionRef, value, ...elemProps }: SelectOptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
//# sourceMappingURL=SelectOption.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SelectOption.d.ts","sourceRoot":"","sources":["../../../../select/lib/SelectOption.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,SAAS,EACT,SAAS,EAGV,MAAM,kCAAkC,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC;IACzF;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACrC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAqED;;GAEG;AACH,eAAO,MAAM,YAAY,uEAOtB,iBAAiB,4CAanB,CAAC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectOption = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const common_1 = require("@workday/canvas-kit-react/common");
|
|
6
|
-
const tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
7
|
-
const optionPadding = 6;
|
|
8
|
-
const activeStyles = (theme) => {
|
|
9
|
-
const activeBgColor = theme.canvas.palette.primary.main;
|
|
10
|
-
return {
|
|
11
|
-
backgroundColor: activeBgColor,
|
|
12
|
-
color: (0, common_1.pickForegroundColor)(activeBgColor),
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
const Option = (0, common_1.styled)('li')({
|
|
16
|
-
...tokens_1.type.levels.subtext.large,
|
|
17
|
-
cursor: 'default',
|
|
18
|
-
// Apply listStyle at the list item style to ensure it's styled properly
|
|
19
|
-
// in Visual Testing States
|
|
20
|
-
listStyle: 'none',
|
|
21
|
-
// In case the content of the option is empty/undefined for some reason
|
|
22
|
-
minHeight: tokens_1.type.levels.subtext.large.lineHeight,
|
|
23
|
-
textAlign: 'left',
|
|
24
|
-
}, ({ 'aria-disabled': disabled, focused, interactive, theme }) => {
|
|
25
|
-
if (disabled) {
|
|
26
|
-
// If the option is disabled, return disabled styles...
|
|
27
|
-
return {
|
|
28
|
-
color: tokens_1.colors.licorice100,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
else if (focused) {
|
|
32
|
-
// ...else if the option is focused, return focused styles...
|
|
33
|
-
return {
|
|
34
|
-
...activeStyles(theme),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
// ...else return hover and selected (via aria-selected) styles
|
|
39
|
-
const selectedBgColor = theme.canvas.palette.primary.lightest;
|
|
40
|
-
const selectedStyles = {
|
|
41
|
-
'&[aria-selected="true"]': {
|
|
42
|
-
backgroundColor: selectedBgColor,
|
|
43
|
-
color: (0, common_1.pickForegroundColor)(selectedBgColor),
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
// Only display interactive (hover/active) styles if the option is interactive
|
|
47
|
-
const interactiveStyles = interactive
|
|
48
|
-
? {
|
|
49
|
-
'&:hover': {
|
|
50
|
-
backgroundColor: tokens_1.commonColors.hoverBackground,
|
|
51
|
-
},
|
|
52
|
-
'&:active, &:active[aria-selected="true"]': {
|
|
53
|
-
...activeStyles(theme),
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
: {};
|
|
57
|
-
return {
|
|
58
|
-
// Place selected styles after interactive styles to have selected styles
|
|
59
|
-
// override interactive styles (subject to CSS specificity rules)
|
|
60
|
-
...interactiveStyles,
|
|
61
|
-
...selectedStyles,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}, ({ error }) => ({
|
|
65
|
-
padding: `${optionPadding}px ${error === common_1.ErrorType.Caution ? optionPadding - 1 : optionPadding}px`,
|
|
66
|
-
}));
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated ⚠️ `SelectOption` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
|
|
69
|
-
*/
|
|
70
|
-
const SelectOption = ({ children, focused = false, interactive = true, optionRef, value, ...elemProps }) => {
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(Option, { "data-value": value, focused: focused, interactive: interactive, ref: optionRef, role: "option", ...elemProps, children: children }));
|
|
72
|
-
};
|
|
73
|
-
exports.SelectOption = SelectOption;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated ⚠️ `scrollIntoViewIfNeeded` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
|
|
3
|
-
*/
|
|
4
|
-
export declare const scrollIntoViewIfNeeded: (elem: HTMLElement, centerIfNeeded?: boolean) => void;
|
|
5
|
-
//# sourceMappingURL=scrolling.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scrolling.d.ts","sourceRoot":"","sources":["../../../../select/lib/scrolling.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,eAAO,MAAM,sBAAsB,SAAU,WAAW,+BAA0B,IAqCjF,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scrollIntoViewIfNeeded = void 0;
|
|
4
|
-
// Modified from https://gist.github.com/hsablonniere/2581101
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated ⚠️ `scrollIntoViewIfNeeded` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
|
|
7
|
-
*/
|
|
8
|
-
const scrollIntoViewIfNeeded = (elem, centerIfNeeded = true) => {
|
|
9
|
-
const parent = elem.parentElement;
|
|
10
|
-
if (elem && parent) {
|
|
11
|
-
const parentComputedStyle = window.getComputedStyle(parent, null);
|
|
12
|
-
const parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'), 10);
|
|
13
|
-
// Check if elem is out of view at the top edge of the parent's viewport
|
|
14
|
-
const overTop = elem.offsetTop < parent.scrollTop + parentBorderTopWidth;
|
|
15
|
-
// Check if elem is out of view at the bottom edge of the parent's viewport
|
|
16
|
-
const overBottom = elem.offsetTop + elem.offsetHeight >
|
|
17
|
-
parent.scrollTop + parentBorderTopWidth + parent.clientHeight;
|
|
18
|
-
if ((overTop || overBottom) && centerIfNeeded) {
|
|
19
|
-
parent.scrollTop = Math.floor(elem.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + elem.clientHeight / 2);
|
|
20
|
-
}
|
|
21
|
-
if ((overTop || overBottom) && !centerIfNeeded) {
|
|
22
|
-
if (overBottom) {
|
|
23
|
-
// elem is out of view at the bottom edge of the parent's viewport;
|
|
24
|
-
// scroll down just far enough for elem to be visible
|
|
25
|
-
parent.scrollTop =
|
|
26
|
-
elem.clientHeight - (parent.clientHeight + parentBorderTopWidth - elem.offsetTop);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
// elem is out of view at the top edge of the parent's viewport;
|
|
30
|
-
// scroll up just far enough for elem to be visible
|
|
31
|
-
parent.scrollTop = elem.offsetTop - parentBorderTopWidth;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
exports.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;
|