@workday/canvas-kit-preview-react 15.0.0-alpha.0075-next.0 → 15.0.0-alpha.0077-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/commonjs/index.d.ts +1 -2
  2. package/dist/commonjs/index.d.ts.map +1 -1
  3. package/dist/commonjs/index.js +1 -2
  4. package/dist/es6/index.d.ts +1 -2
  5. package/dist/es6/index.d.ts.map +1 -1
  6. package/dist/es6/index.js +1 -2
  7. package/index.ts +1 -2
  8. package/package.json +4 -4
  9. package/avatar/index.ts +0 -5
  10. package/avatar/lib/Avatar.tsx +0 -156
  11. package/avatar/lib/AvatarImage.tsx +0 -20
  12. package/avatar/lib/AvatarName.tsx +0 -32
  13. package/avatar/lib/BaseAvatar.tsx +0 -127
  14. package/avatar/lib/getInitialsFromName.ts +0 -11
  15. package/avatar/package.json +0 -6
  16. package/dist/commonjs/avatar/index.d.ts +0 -6
  17. package/dist/commonjs/avatar/index.d.ts.map +0 -1
  18. package/dist/commonjs/avatar/index.js +0 -21
  19. package/dist/commonjs/avatar/lib/Avatar.d.ts +0 -281
  20. package/dist/commonjs/avatar/lib/Avatar.d.ts.map +0 -1
  21. package/dist/commonjs/avatar/lib/Avatar.js +0 -53
  22. package/dist/commonjs/avatar/lib/AvatarImage.d.ts +0 -6
  23. package/dist/commonjs/avatar/lib/AvatarImage.d.ts.map +0 -1
  24. package/dist/commonjs/avatar/lib/AvatarImage.js +0 -15
  25. package/dist/commonjs/avatar/lib/AvatarName.d.ts +0 -14
  26. package/dist/commonjs/avatar/lib/AvatarName.d.ts.map +0 -1
  27. package/dist/commonjs/avatar/lib/AvatarName.js +0 -16
  28. package/dist/commonjs/avatar/lib/BaseAvatar.d.ts +0 -148
  29. package/dist/commonjs/avatar/lib/BaseAvatar.d.ts.map +0 -1
  30. package/dist/commonjs/avatar/lib/BaseAvatar.js +0 -47
  31. package/dist/commonjs/avatar/lib/getInitialsFromName.d.ts +0 -2
  32. package/dist/commonjs/avatar/lib/getInitialsFromName.d.ts.map +0 -1
  33. package/dist/commonjs/avatar/lib/getInitialsFromName.js +0 -13
  34. package/dist/commonjs/select/index.d.ts +0 -3
  35. package/dist/commonjs/select/index.d.ts.map +0 -1
  36. package/dist/commonjs/select/index.js +0 -17
  37. package/dist/commonjs/select/lib/Select.d.ts +0 -31
  38. package/dist/commonjs/select/lib/Select.d.ts.map +0 -1
  39. package/dist/commonjs/select/lib/Select.js +0 -486
  40. package/dist/commonjs/select/lib/SelectBase.d.ts +0 -165
  41. package/dist/commonjs/select/lib/SelectBase.d.ts.map +0 -1
  42. package/dist/commonjs/select/lib/SelectBase.js +0 -235
  43. package/dist/commonjs/select/lib/SelectMenu.d.ts +0 -45
  44. package/dist/commonjs/select/lib/SelectMenu.d.ts.map +0 -1
  45. package/dist/commonjs/select/lib/SelectMenu.js +0 -195
  46. package/dist/commonjs/select/lib/SelectOption.d.ts +0 -38
  47. package/dist/commonjs/select/lib/SelectOption.d.ts.map +0 -1
  48. package/dist/commonjs/select/lib/SelectOption.js +0 -73
  49. package/dist/commonjs/select/lib/scrolling.d.ts +0 -5
  50. package/dist/commonjs/select/lib/scrolling.d.ts.map +0 -1
  51. package/dist/commonjs/select/lib/scrolling.js +0 -36
  52. package/dist/commonjs/select/lib/types.d.ts +0 -37
  53. package/dist/commonjs/select/lib/types.d.ts.map +0 -1
  54. package/dist/commonjs/select/lib/types.js +0 -2
  55. package/dist/commonjs/select/lib/utils.d.ts +0 -10
  56. package/dist/commonjs/select/lib/utils.d.ts.map +0 -1
  57. package/dist/commonjs/select/lib/utils.js +0 -27
  58. package/dist/es6/avatar/index.d.ts +0 -6
  59. package/dist/es6/avatar/index.d.ts.map +0 -1
  60. package/dist/es6/avatar/index.js +0 -5
  61. package/dist/es6/avatar/lib/Avatar.d.ts +0 -281
  62. package/dist/es6/avatar/lib/Avatar.d.ts.map +0 -1
  63. package/dist/es6/avatar/lib/Avatar.js +0 -47
  64. package/dist/es6/avatar/lib/AvatarImage.d.ts +0 -6
  65. package/dist/es6/avatar/lib/AvatarImage.d.ts.map +0 -1
  66. package/dist/es6/avatar/lib/AvatarImage.js +0 -12
  67. package/dist/es6/avatar/lib/AvatarName.d.ts +0 -14
  68. package/dist/es6/avatar/lib/AvatarName.d.ts.map +0 -1
  69. package/dist/es6/avatar/lib/AvatarName.js +0 -13
  70. package/dist/es6/avatar/lib/BaseAvatar.d.ts +0 -148
  71. package/dist/es6/avatar/lib/BaseAvatar.d.ts.map +0 -1
  72. package/dist/es6/avatar/lib/BaseAvatar.js +0 -44
  73. package/dist/es6/avatar/lib/getInitialsFromName.d.ts +0 -2
  74. package/dist/es6/avatar/lib/getInitialsFromName.d.ts.map +0 -1
  75. package/dist/es6/avatar/lib/getInitialsFromName.js +0 -9
  76. package/dist/es6/select/index.d.ts +0 -3
  77. package/dist/es6/select/index.d.ts.map +0 -1
  78. package/dist/es6/select/index.js +0 -1
  79. package/dist/es6/select/lib/Select.d.ts +0 -31
  80. package/dist/es6/select/lib/Select.d.ts.map +0 -1
  81. package/dist/es6/select/lib/Select.js +0 -460
  82. package/dist/es6/select/lib/SelectBase.d.ts +0 -165
  83. package/dist/es6/select/lib/SelectBase.d.ts.map +0 -1
  84. package/dist/es6/select/lib/SelectBase.js +0 -208
  85. package/dist/es6/select/lib/SelectMenu.d.ts +0 -45
  86. package/dist/es6/select/lib/SelectMenu.d.ts.map +0 -1
  87. package/dist/es6/select/lib/SelectMenu.js +0 -191
  88. package/dist/es6/select/lib/SelectOption.d.ts +0 -38
  89. package/dist/es6/select/lib/SelectOption.d.ts.map +0 -1
  90. package/dist/es6/select/lib/SelectOption.js +0 -69
  91. package/dist/es6/select/lib/scrolling.d.ts +0 -5
  92. package/dist/es6/select/lib/scrolling.d.ts.map +0 -1
  93. package/dist/es6/select/lib/scrolling.js +0 -32
  94. package/dist/es6/select/lib/types.d.ts +0 -37
  95. package/dist/es6/select/lib/types.d.ts.map +0 -1
  96. package/dist/es6/select/lib/types.js +0 -1
  97. package/dist/es6/select/lib/utils.d.ts +0 -10
  98. package/dist/es6/select/lib/utils.d.ts.map +0 -1
  99. package/dist/es6/select/lib/utils.js +0 -22
  100. package/select/index.ts +0 -8
  101. package/select/lib/Select.tsx +0 -595
  102. package/select/lib/SelectBase.tsx +0 -493
  103. package/select/lib/SelectMenu.tsx +0 -304
  104. package/select/lib/SelectOption.tsx +0 -133
  105. package/select/lib/scrolling.ts +0 -42
  106. package/select/lib/types.ts +0 -37
  107. package/select/lib/utils.ts +0 -30
  108. package/select/package.json +0 -6
@@ -1,304 +0,0 @@
1
- import React, {useState, useEffect, useLayoutEffect, useCallback} from 'react';
2
-
3
- import {CSSObject} from '@emotion/styled';
4
- import {EmotionCanvasTheme, ErrorType, Themeable, styled} from '@workday/canvas-kit-react/common';
5
- import {
6
- Placement,
7
- Popper,
8
- useCloseOnEscape,
9
- useCloseOnOutsideClick,
10
- usePopupModel,
11
- useReturnFocus,
12
- useTransferOnFullscreenExit,
13
- } from '@workday/canvas-kit-react/popup';
14
- import {colors, borderRadius, inputColors} from '@workday/canvas-kit-react/tokens';
15
-
16
- import {SelectProps} from './Select';
17
- import {MenuPlacement, MenuVisibility} from './types';
18
-
19
- interface SelectMenuProps
20
- extends Themeable,
21
- React.HTMLAttributes<HTMLUListElement>,
22
- Pick<SelectProps, 'error'> {
23
- /**
24
- * The ref to the anchor button element. Required to anchor the menu.
25
- */
26
- buttonRef?: React.RefObject<HTMLButtonElement>;
27
- /**
28
- * The ref to the underlying menu/listbox element. Use this to imperatively manipulate the menu.
29
- */
30
- menuRef?: React.RefObject<HTMLUListElement>;
31
- /**
32
- * The function called when the menu is closed.
33
- */
34
- onClose?: () => void;
35
- /**
36
- * The placement of the SelectMenu relative to its corresponding button.
37
- * @default 'bottom'
38
- */
39
- placement?: MenuPlacement;
40
- /**
41
- * 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).
42
- * @default true
43
- */
44
- shouldAutoFlip?: boolean;
45
- /**
46
- * 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).
47
- * @default true
48
- */
49
- shouldAutoFocus?: boolean;
50
- /**
51
- * The visibility state of the SelectMenu.
52
- * @default 'closed'
53
- */
54
- visibility?: MenuVisibility;
55
- }
56
-
57
- export const menuAnimationDuration = 200;
58
-
59
- const menuBorderStyles = (theme: EmotionCanvasTheme, error?: ErrorType): CSSObject => {
60
- let borderColor = theme.canvas.palette.common.focusOutline;
61
- let dividerBorderColor = borderColor;
62
- let dividerBorderWidth = 1;
63
-
64
- if (error === ErrorType.Error) {
65
- borderColor = theme.canvas.palette.error.main;
66
- dividerBorderColor = borderColor;
67
- } else if (error === ErrorType.Caution) {
68
- borderColor = theme.canvas.palette.alert.darkest;
69
- dividerBorderColor = theme.canvas.palette.alert.main;
70
- dividerBorderWidth = 2;
71
- }
72
-
73
- const dividerBorder = `${dividerBorderWidth}px solid ${dividerBorderColor}`;
74
-
75
- return {
76
- borderColor: borderColor,
77
-
78
- // Render the divider using a pseudo-element
79
- '&:before': {
80
- backgroundColor: colors.soap400,
81
- borderLeft: dividerBorder,
82
- borderRight: dividerBorder,
83
- boxSizing: 'border-box',
84
- content: '""',
85
- display: 'block',
86
- height: 1,
87
- position: 'absolute',
88
- width: '100%',
89
-
90
- '[data-popper-placement="bottom"] &': {
91
- top: 0,
92
- },
93
- '[data-popper-placement="top"] &': {
94
- bottom: 0,
95
- },
96
- },
97
- };
98
- };
99
-
100
- const menuListBorderStyles = (theme: EmotionCanvasTheme, error?: ErrorType): CSSObject => {
101
- let borderColor = theme.canvas.palette.common.focusOutline;
102
- let borderWidth = 1;
103
-
104
- if (error === ErrorType.Error) {
105
- borderColor = theme.canvas.palette.error.main;
106
- } else if (error === ErrorType.Caution) {
107
- borderColor = theme.canvas.palette.alert.main;
108
- borderWidth = 2;
109
- }
110
-
111
- const border = `${borderWidth}px solid ${borderColor}`;
112
-
113
- return {
114
- borderLeft: border,
115
- borderRight: border,
116
-
117
- '[data-popper-placement="bottom"] &': {
118
- borderBottom: border,
119
- },
120
- '[data-popper-placement="top"] &': {
121
- borderTop: border,
122
- },
123
- };
124
- };
125
-
126
- const Menu = styled('div')<
127
- Pick<SelectMenuProps, 'error' | 'theme' | 'visibility'> & {width: number}
128
- >(
129
- {
130
- backgroundColor: colors.frenchVanilla100,
131
- border: `1px solid ${inputColors.border}`,
132
- boxSizing: 'border-box',
133
- position: 'relative',
134
- transition: `opacity ${menuAnimationDuration}ms`,
135
-
136
- '[data-popper-placement="bottom"] &': {
137
- borderRadius: `0 0 ${borderRadius.m} ${borderRadius.m}`,
138
- borderTop: 0,
139
- },
140
- '[data-popper-placement="top"] &': {
141
- borderRadius: `${borderRadius.m} ${borderRadius.m} 0 0`,
142
- borderBottom: 0,
143
- },
144
- },
145
- ({error, theme}) => ({
146
- ...menuBorderStyles(theme, error),
147
- }),
148
- ({visibility}) => ({
149
- opacity: visibility === 'opening' || visibility === 'opened' || visibility === 'close' ? 1 : 0,
150
- }),
151
- ({width}) => ({
152
- width: width,
153
- })
154
- );
155
-
156
- const MenuList = styled('ul')<Pick<SelectProps, 'error' | 'theme'>>(
157
- {
158
- listStyle: 'none',
159
- margin: 0,
160
- maxHeight: 200,
161
- outline: 'none',
162
- overflowY: 'auto',
163
- padding: 0,
164
- },
165
- ({error, theme}) => ({
166
- ...menuListBorderStyles(theme, error),
167
- })
168
- );
169
-
170
- const generatePopperOptions = (
171
- props: Pick<SelectMenuProps, 'menuRef' | 'placement' | 'shouldAutoFlip' | 'shouldAutoFocus'>
172
- ) => {
173
- const {menuRef, placement, shouldAutoFlip, shouldAutoFocus} = props;
174
-
175
- let fallbackPlacements: Placement[] = [];
176
- if (shouldAutoFlip) {
177
- fallbackPlacements = placement === 'top' ? ['bottom'] : ['top'];
178
- }
179
-
180
- const modifiers = [
181
- {
182
- name: 'flip',
183
- options: {
184
- fallbackPlacements,
185
- },
186
- },
187
- {
188
- name: 'offset',
189
- options: {
190
- offset: () => {
191
- const skidding = 0;
192
-
193
- // Displace menu towards the button to obscure the bottom
194
- // edge of the button and to create a smooth visual
195
- // connection between the button and the menu
196
- const distance = -parseInt(borderRadius.m, 10);
197
-
198
- return [skidding, distance];
199
- },
200
- },
201
- },
202
- {
203
- name: 'preventOverflow',
204
- options: {
205
- // Ensure the menu stays aligned with its reference (button),
206
- // even if that means the menu is pushed out of view
207
- mainAxis: false,
208
- },
209
- },
210
- {
211
- // Disable the fallbackModifier as SelectMenu is properly handled by the
212
- // flip modifier through shouldAutoFlip prop
213
- name: 'fallbackModifier',
214
- enabled: false,
215
- },
216
- ];
217
-
218
- return {
219
- modifiers,
220
- // TODO: Consider using a more general-purpose focus function here rather
221
- // than relying on Popper's onFirstUpdate for better control over how
222
- // focus is managed
223
- onFirstUpdate: () => {
224
- if (shouldAutoFocus && menuRef && menuRef.current) {
225
- menuRef.current.focus();
226
- }
227
- },
228
- };
229
- };
230
-
231
- /**
232
- * @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.
233
- */
234
- export const SelectMenu = ({
235
- buttonRef,
236
- children,
237
- error,
238
- menuRef,
239
- onClose,
240
- placement = 'bottom',
241
- shouldAutoFlip = true,
242
- shouldAutoFocus = true,
243
- visibility = 'closed',
244
- ...elemProps
245
- }: SelectMenuProps) => {
246
- const model = usePopupModel({
247
- initialVisibility: 'visible',
248
- returnFocusRef: buttonRef,
249
- onHide: onClose,
250
- });
251
-
252
- const [width, setWidth] = useState(0);
253
-
254
- const handleWidthChange = useCallback(() => {
255
- if (buttonRef && buttonRef.current && visibility !== 'closed') {
256
- const newMenuWidth = buttonRef.current.clientWidth + 2;
257
- setWidth(newMenuWidth);
258
- }
259
- }, [buttonRef, visibility]);
260
-
261
- useLayoutEffect(() => {
262
- handleWidthChange();
263
- }, [handleWidthChange]);
264
-
265
- // TODO: Figure out a better way to handle width changes in the reference button.
266
- // Seems like we should resize the menu when the reference button width changes, not
267
- // necessarily when the window resizes. Resizing the menu on window resize addresses
268
- // the case when `grow = true` and the user resizes the browser window while the
269
- // menu is opened, but doesn't address cases where the reference button size changes
270
- // through other means.
271
- useEffect(() => {
272
- // Update menu width state on resize to ensure menu resizes as window resizes
273
- window.addEventListener('resize', handleWidthChange);
274
-
275
- return () => {
276
- window.removeEventListener('resize', handleWidthChange);
277
- };
278
- }, [handleWidthChange]);
279
-
280
- useCloseOnEscape(model);
281
- useCloseOnOutsideClick(model);
282
- useReturnFocus(model);
283
- useTransferOnFullscreenExit(model);
284
-
285
- return (
286
- <Popper
287
- placement={placement}
288
- anchorElement={buttonRef}
289
- popperOptions={generatePopperOptions({
290
- menuRef,
291
- placement,
292
- shouldAutoFlip,
293
- shouldAutoFocus,
294
- })}
295
- ref={model.state.stackRef}
296
- >
297
- <Menu error={error} visibility={visibility} width={width}>
298
- <MenuList error={error} ref={menuRef} role="listbox" tabIndex={-1} {...elemProps}>
299
- {children}
300
- </MenuList>
301
- </Menu>
302
- </Popper>
303
- );
304
- };
@@ -1,133 +0,0 @@
1
- import * as React from 'react';
2
- import {CSSObject} from '@emotion/styled';
3
- import {
4
- EmotionCanvasTheme,
5
- ErrorType,
6
- Themeable,
7
- pickForegroundColor,
8
- styled,
9
- } from '@workday/canvas-kit-react/common';
10
- import {colors, commonColors, type} from '@workday/canvas-kit-react/tokens';
11
- /**
12
- * @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.
13
- */
14
- export interface SelectOptionProps extends Themeable, React.LiHTMLAttributes<HTMLLIElement> {
15
- /**
16
- * The type of error associated with the SelectOption (if applicable).
17
- */
18
- error?: ErrorType;
19
- /**
20
- * If true, set the SelectOption to the focused state.
21
- * @default false
22
- */
23
- focused?: boolean;
24
- /**
25
- * The HTML `id` of the SelectOption.
26
- */
27
- id?: string;
28
- /**
29
- * 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).
30
- * @default true
31
- */
32
- interactive?: boolean;
33
- /**
34
- * 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).
35
- */
36
- optionRef?: React.Ref<HTMLLIElement>;
37
- /**
38
- * The value of the SelectOption.
39
- */
40
- value?: string;
41
- }
42
-
43
- const optionPadding = 6;
44
-
45
- const activeStyles = (theme: EmotionCanvasTheme): CSSObject => {
46
- const activeBgColor = theme.canvas.palette.primary.main;
47
- return {
48
- backgroundColor: activeBgColor,
49
- color: pickForegroundColor(activeBgColor),
50
- };
51
- };
52
-
53
- const Option = styled('li')<SelectOptionProps>(
54
- {
55
- ...type.levels.subtext.large,
56
- cursor: 'default',
57
- // Apply listStyle at the list item style to ensure it's styled properly
58
- // in Visual Testing States
59
- listStyle: 'none',
60
- // In case the content of the option is empty/undefined for some reason
61
- minHeight: type.levels.subtext.large.lineHeight,
62
- textAlign: 'left',
63
- },
64
- ({'aria-disabled': disabled, focused, interactive, theme}) => {
65
- if (disabled) {
66
- // If the option is disabled, return disabled styles...
67
- return {
68
- color: colors.licorice100,
69
- };
70
- } else if (focused) {
71
- // ...else if the option is focused, return focused styles...
72
- return {
73
- ...activeStyles(theme),
74
- };
75
- } else {
76
- // ...else return hover and selected (via aria-selected) styles
77
- const selectedBgColor = theme.canvas.palette.primary.lightest;
78
- const selectedStyles = {
79
- '&[aria-selected="true"]': {
80
- backgroundColor: selectedBgColor,
81
- color: pickForegroundColor(selectedBgColor),
82
- },
83
- };
84
- // Only display interactive (hover/active) styles if the option is interactive
85
- const interactiveStyles = interactive
86
- ? {
87
- '&:hover': {
88
- backgroundColor: commonColors.hoverBackground,
89
- },
90
- '&:active, &:active[aria-selected="true"]': {
91
- ...activeStyles(theme),
92
- },
93
- }
94
- : {};
95
- return {
96
- // Place selected styles after interactive styles to have selected styles
97
- // override interactive styles (subject to CSS specificity rules)
98
- ...interactiveStyles,
99
- ...selectedStyles,
100
- };
101
- }
102
- },
103
- ({error}) => ({
104
- padding: `${optionPadding}px ${
105
- error === ErrorType.Caution ? optionPadding - 1 : optionPadding
106
- }px`,
107
- })
108
- );
109
-
110
- /**
111
- * @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.
112
- */
113
- export const SelectOption = ({
114
- children,
115
- focused = false,
116
- interactive = true,
117
- optionRef,
118
- value,
119
- ...elemProps
120
- }: SelectOptionProps) => {
121
- return (
122
- <Option
123
- data-value={value}
124
- focused={focused}
125
- interactive={interactive}
126
- ref={optionRef}
127
- role="option"
128
- {...elemProps}
129
- >
130
- {children}
131
- </Option>
132
- );
133
- };
@@ -1,42 +0,0 @@
1
- // Modified from https://gist.github.com/hsablonniere/2581101
2
- /**
3
- * @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.
4
- */
5
- export const scrollIntoViewIfNeeded = (elem: HTMLElement, centerIfNeeded = true): void => {
6
- const parent = elem.parentElement;
7
-
8
- if (elem && parent) {
9
- const parentComputedStyle = window.getComputedStyle(parent, null);
10
- const parentBorderTopWidth = parseInt(
11
- parentComputedStyle.getPropertyValue('border-top-width'),
12
- 10
13
- );
14
-
15
- // Check if elem is out of view at the top edge of the parent's viewport
16
- const overTop = elem.offsetTop < parent.scrollTop + parentBorderTopWidth;
17
-
18
- // Check if elem is out of view at the bottom edge of the parent's viewport
19
- const overBottom =
20
- elem.offsetTop + elem.offsetHeight >
21
- parent.scrollTop + parentBorderTopWidth + parent.clientHeight;
22
-
23
- if ((overTop || overBottom) && centerIfNeeded) {
24
- parent.scrollTop = Math.floor(
25
- elem.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + elem.clientHeight / 2
26
- );
27
- }
28
-
29
- if ((overTop || overBottom) && !centerIfNeeded) {
30
- if (overBottom) {
31
- // elem is out of view at the bottom edge of the parent's viewport;
32
- // scroll down just far enough for elem to be visible
33
- parent.scrollTop =
34
- elem.clientHeight - (parent.clientHeight + parentBorderTopWidth - elem.offsetTop);
35
- } else {
36
- // elem is out of view at the top edge of the parent's viewport;
37
- // scroll up just far enough for elem to be visible
38
- parent.scrollTop = elem.offsetTop - parentBorderTopWidth;
39
- }
40
- }
41
- }
42
- };
@@ -1,37 +0,0 @@
1
- /**
2
- * The placement of the menu relative to its corresponding button. This type is a
3
- * subset of the PopperJS.Placement type limited to the `bottom` and `top` values.
4
- *
5
- * We need to use `top` and `bottom` instead of `top-start` and `bottom-start` for
6
- * placements because PopperJS incorrectly rounds the `start` and `end` modifiers:
7
- * https://github.com/popperjs/popper-core/blob/38914aae7a2e91715c6eb2b563517082a40cfa64/src/utils/computeOffsets.js#L68-L81
8
- * This rounding causes problems with browsers that allow subpixel values for elements
9
- * like Firefox and Edge.
10
- *
11
- * @deprecated ⚠️ `MenuPlacement` 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.
12
- */
13
- export type MenuPlacement = 'bottom' | 'top';
14
-
15
- /**
16
- * The visibility state of the menu.
17
- *
18
- * `closed`: The menu is completely closed (not present in the DOM).
19
- * `open`: The menu was previously `closed` and has just been instructed to open.
20
- * The menu has been added to the DOM, but it's not yet visible. This state is
21
- * necessary in order to apply an opacity of 0 to the menu before transitioning it
22
- * to an opacity of 1.0 in the opening state.
23
- * `opening`: The menu is in the process of opening.
24
- * `opened`: The menu is completely open.
25
- * `close`: The menu was previously `open` and has just been instructed to close.
26
- * `closing`: The menu is in the process of closing.
27
- *
28
- * Typically, a menu will transition through states in the following order:
29
- * `closed` > `open` > `opening` > `opened` > `close` > `closing` > `closed`
30
- *
31
- * However, it's possible for a user to open a menu while it's in the process of
32
- * closing in which case the menu can transition from `closing` > `opening` (and
33
- * vice-versa).
34
- *
35
- * @deprecated ⚠️ `MenuVisibility` 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 type MenuVisibility = 'closed' | 'open' | 'opening' | 'opened' | 'close' | 'closing';
@@ -1,30 +0,0 @@
1
- import {NormalizedOption} from './SelectBase';
2
- /**
3
- * @deprecated ⚠️ `getIndexByValue` 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--basic) instead.
4
- */
5
- export const getIndexByValue = (options: NormalizedOption[], value: string | undefined): number => {
6
- if (!options || value === undefined) {
7
- return -1;
8
- }
9
-
10
- for (let i = 0; i < options.length; i++) {
11
- if (options[i].value === value) {
12
- return i;
13
- }
14
- }
15
-
16
- return -1;
17
- };
18
-
19
- // If the value doesn't exist in the options, return index 0
20
- /**
21
- * @deprecated ⚠️ `getCorrectedIndexByValue` 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.
22
- */
23
- export const getCorrectedIndexByValue = (
24
- options: NormalizedOption[],
25
- value: string | undefined
26
- ): number => {
27
- const indexByValue = getIndexByValue(options, value);
28
-
29
- return indexByValue === -1 ? 0 : indexByValue;
30
- };
@@ -1,6 +0,0 @@
1
- {
2
- "main": "../dist/commonjs/select",
3
- "module": "../dist/es6/select",
4
- "sideEffects": false,
5
- "types": "../dist/es6/select"
6
- }