@databricks/design-system 1.12.20 → 1.12.21
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/codemods/camelize.ts +5 -5
- package/dist/Popover-CrX63HDP.js +3831 -0
- package/dist/Popover-CrX63HDP.js.map +1 -0
- package/dist/Popover-DQEbjNyV.js +3831 -0
- package/dist/Popover-DQEbjNyV.js.map +1 -0
- package/dist/WizardStepContentWrapper-Bv2MqnDd.js +2276 -0
- package/dist/WizardStepContentWrapper-Bv2MqnDd.js.map +1 -0
- package/dist/WizardStepContentWrapper-CzvxVy-w.js +2278 -0
- package/dist/WizardStepContentWrapper-CzvxVy-w.js.map +1 -0
- package/dist/development.js +3 -3
- package/dist/development.js.map +1 -1
- package/dist/index-BC9PpmGo.js +770 -0
- package/dist/index-BC9PpmGo.js.map +1 -0
- package/dist/index-DxyvNv4-.js +770 -0
- package/dist/index-DxyvNv4-.js.map +1 -0
- package/dist/index.js +162 -66
- package/dist/index.js.map +1 -1
- package/dist/patterns.js +2 -2
- package/package.json +4 -4
- package/scripts/theme_regeneration/common.ts +3 -3
- package/scripts/theme_regeneration/regenerate_color_validity_enums.ts +3 -3
- package/src/assets/icons/RowsIcon.svg +3 -0
- package/src/assets/icons/TokenIcon.svg +8 -0
- package/src/assets/icons/TrendingIcon.svg +1 -0
- package/src/design-system/Accordion/Accordion.tsx +2 -2
- package/src/design-system/Alert/Alert.tsx +1 -1
- package/src/design-system/ApplyGlobalStyles/ApplyGlobalStyles.tsx +1 -1
- package/src/design-system/Card/Card.test.tsx +52 -0
- package/src/design-system/Card/Card.tsx +21 -5
- package/src/design-system/DatePicker/DatePicker.tsx +6 -4
- package/src/design-system/DesignSystemEventProvider/DesignSystemEventProvider.test.tsx +5 -3
- package/src/design-system/DesignSystemProvider/DesignSystemProvider.test.tsx +1 -1
- package/src/design-system/DesignSystemProvider/DesignSystemProvider.tsx +8 -6
- package/src/design-system/Dropdown/Dropdown.tsx +1 -1
- package/src/design-system/Empty/Empty.tsx +1 -1
- package/src/design-system/Grid/Col.tsx +1 -1
- package/src/design-system/Grid/Row.tsx +1 -1
- package/src/design-system/Header/Header.tsx +1 -1
- package/src/design-system/Hooks/useDesignSystemTheme.tsx +3 -1
- package/src/design-system/HoverCard/HoverCard.tsx +11 -5
- package/src/design-system/Icon/Icon.tsx +4 -4
- package/src/design-system/Icon/__generated/icons/{InfoIcon.tsx → RowsIcon.tsx} +6 -7
- package/src/design-system/Icon/__generated/icons/TokenIcon.tsx +28 -0
- package/src/design-system/Icon/__generated/icons/TrendingIcon.tsx +23 -0
- package/src/design-system/Icon/__generated/icons/index.ts +3 -1
- package/src/design-system/Input/Password.tsx +25 -23
- package/src/design-system/LegacyForm/LegacyForm.tsx +5 -1
- package/src/design-system/LegacyPopover/LegacyPopover.tsx +5 -1
- package/src/design-system/LegacySelect/LegacySelect.tsx +2 -2
- package/src/design-system/LegacyTable/LegacyTable.tsx +1 -1
- package/src/design-system/LegacyTabs/index.tsx +4 -1
- package/src/design-system/LegacyTooltip/LegacyTooltip.tsx +1 -1
- package/src/design-system/LoadingState/LoadingState.tsx +1 -1
- package/src/design-system/Modal/Modal.tsx +19 -2
- package/src/design-system/PageWrapper/PageWrapper.tsx +1 -1
- package/src/design-system/Pagination/index.tsx +2 -2
- package/src/design-system/PreviewCard/PreviewCard.test.tsx +70 -0
- package/src/design-system/PreviewCard/PreviewCard.tsx +15 -5
- package/src/design-system/Radio/Radio.tsx +28 -28
- package/src/design-system/SegmentedControl/SegmentedControl.tsx +2 -2
- package/src/design-system/Select/SimpleSelect.tsx +4 -1
- package/src/design-system/Skeleton/TableSkeleton.tsx +4 -2
- package/src/design-system/Skeleton/TitleSkeleton.tsx +10 -2
- package/src/design-system/Space/Space.tsx +1 -1
- package/src/design-system/Spacer/Spacer.tsx +1 -1
- package/src/design-system/Spinner/Spinner.tsx +1 -1
- package/src/design-system/SplitButton/Dropdown/DropdownButton.tsx +1 -1
- package/src/design-system/SplitButton/SplitButton.tsx +3 -1
- package/src/design-system/Stepper/Stepper.tsx +1 -1
- package/src/design-system/Switch/Switch.tsx +1 -1
- package/src/design-system/TableUI/TableCell.tsx +10 -1
- package/src/design-system/Tooltip/Tooltip.tsx +1 -1
- package/src/design-system/TypeaheadCombobox/CountBadge.tsx +5 -1
- package/src/design-system/TypeaheadCombobox/TypeaheadComboboxControls.tsx +1 -1
- package/src/design-system/TypeaheadCombobox/TypeaheadComboboxRoot.tsx +1 -1
- package/src/design-system/TypeaheadCombobox/TypeaheadComboboxSelectedItem.tsx +1 -1
- package/src/design-system/TypeaheadCombobox/tests/TypeaheadCombobox.test.tsx +3 -3
- package/src/design-system/TypeaheadCombobox/tests/testFixtures.tsx +3 -3
- package/src/design-system/utils/css-utils.tsx +6 -6
- package/src/design-system/utils/shadow-dom-storybook-wrapper.tsx +1 -1
- package/src/development/Banner/Banner.tsx +1 -1
- package/src/development/PillControl/PillControl.tsx +1 -0
- package/src/development/TreeGrid/TreeGrid.test.tsx +2 -2
- package/src/development/TreeGrid/TreeGrid.tsx +1 -1
- package/src/theme/convertToLessVars.ts +5 -5
- package/src/~patterns/Wizard/VerticalWizardContent.tsx +3 -1
- package/src/assets/icons/InfoIcon.svg +0 -5
|
@@ -0,0 +1,3831 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from '@emotion/react/jsx-runtime';
|
|
2
|
+
import React__default, { createContext, useContext, useMemo, useEffect, useState, forwardRef, useRef, useLayoutEffect, useCallback, useImperativeHandle } from 'react';
|
|
3
|
+
import { useTheme, ThemeProvider, css, keyframes } from '@emotion/react';
|
|
4
|
+
import { notification, ConfigProvider, Button as Button$1, Typography as Typography$1 } from 'antd';
|
|
5
|
+
import { useMergeRefs } from '@floating-ui/react';
|
|
6
|
+
import AntDIcon from '@ant-design/icons';
|
|
7
|
+
import _, { memoize, uniqueId as uniqueId$1 } from 'lodash';
|
|
8
|
+
import * as Popover$1 from '@radix-ui/react-popover';
|
|
9
|
+
import { TooltipProvider } from '@radix-ui/react-tooltip';
|
|
10
|
+
import unitless from '@emotion/unitless';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Used to hide text visually, but still be readable by screen-readers
|
|
14
|
+
* and other assistive devices.
|
|
15
|
+
*
|
|
16
|
+
* https://www.tpgi.com/the-anatomy-of-visually-hidden/
|
|
17
|
+
*/ const visuallyHidden = {
|
|
18
|
+
'&:not(:focus):not(:active)': {
|
|
19
|
+
clip: 'rect(0 0 0 0)',
|
|
20
|
+
clipPath: 'inset(50%)',
|
|
21
|
+
height: '1px',
|
|
22
|
+
overflow: 'hidden',
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
whiteSpace: 'nowrap',
|
|
25
|
+
width: '1px'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
|
30
|
+
const primitiveColors = {
|
|
31
|
+
blue100: '#F0F8FF',
|
|
32
|
+
blue200: '#D7EDFE',
|
|
33
|
+
blue300: '#BAE1FC',
|
|
34
|
+
blue400: '#8ACAFF',
|
|
35
|
+
blue500: '#4299E0',
|
|
36
|
+
blue600: '#2272B4',
|
|
37
|
+
blue700: '#0E538B',
|
|
38
|
+
blue800: '#04355D',
|
|
39
|
+
brown: '#A6630C',
|
|
40
|
+
coral: '#C83243',
|
|
41
|
+
green100: '#F3FCF6',
|
|
42
|
+
green200: '#D4F7DF',
|
|
43
|
+
green300: '#B1ECC5',
|
|
44
|
+
green400: '#8DDDA8',
|
|
45
|
+
green500: '#3CAA60',
|
|
46
|
+
green600: '#277C43',
|
|
47
|
+
green700: '#115026',
|
|
48
|
+
green800: '#093919',
|
|
49
|
+
grey050: '#F6F7F9',
|
|
50
|
+
grey100: '#E8ECF0',
|
|
51
|
+
grey200: '#D1D9E1',
|
|
52
|
+
grey300: '#C0CDD8',
|
|
53
|
+
grey350: '#92A4B3',
|
|
54
|
+
grey400: '#8396A5',
|
|
55
|
+
grey500: '#5F7281',
|
|
56
|
+
grey600: '#445461',
|
|
57
|
+
grey650: '#37444F',
|
|
58
|
+
grey700: '#1F272D',
|
|
59
|
+
grey800: '#11171C',
|
|
60
|
+
indigo: '#434A93',
|
|
61
|
+
lemon: '#FACB66',
|
|
62
|
+
lime: '#308613',
|
|
63
|
+
pink: '#B45091',
|
|
64
|
+
purple: '#8A63BF',
|
|
65
|
+
red100: '#FFF5F7',
|
|
66
|
+
red200: '#FDE2E8',
|
|
67
|
+
red300: '#FBD0D8',
|
|
68
|
+
red400: '#F792A6',
|
|
69
|
+
red500: '#E65B77',
|
|
70
|
+
red600: '#C82D4C',
|
|
71
|
+
red700: '#9E102C',
|
|
72
|
+
red800: '#630316',
|
|
73
|
+
teal: '#04867D',
|
|
74
|
+
turquoise: '#137DAE',
|
|
75
|
+
white: '#FFFFFF',
|
|
76
|
+
yellow100: '#FFF9EB',
|
|
77
|
+
yellow200: '#FCEACA',
|
|
78
|
+
yellow300: '#F8D4A5',
|
|
79
|
+
yellow400: '#F2BE88',
|
|
80
|
+
yellow500: '#DE7921',
|
|
81
|
+
yellow600: '#BE501E',
|
|
82
|
+
yellow700: '#93320B',
|
|
83
|
+
yellow800: '#5F1B02'
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
|
87
|
+
const borderRadii = {
|
|
88
|
+
borderRadius0: 0,
|
|
89
|
+
borderRadiusSm: 4,
|
|
90
|
+
borderRadiusMd: 8,
|
|
91
|
+
borderRadiusLg: 12,
|
|
92
|
+
borderRadiusFull: 999
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Border variables
|
|
96
|
+
const borders = {
|
|
97
|
+
borderRadiusMd: 4,
|
|
98
|
+
borderRadiusLg: 8
|
|
99
|
+
};
|
|
100
|
+
const getLegacyBorders = ()=>{
|
|
101
|
+
return borders;
|
|
102
|
+
};
|
|
103
|
+
const getBorders = ()=>{
|
|
104
|
+
return borderRadii;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* These values are based on AntD's breakpoints which follow BootStrap 4 media query rules.
|
|
109
|
+
* The numerical values represent the min-width of the given size.
|
|
110
|
+
* AntD values: https://ant.design/components/grid#col
|
|
111
|
+
* Bootstrap: https://getbootstrap.com/docs/4.0/layout/overview/#responsive-breakpoints
|
|
112
|
+
*/ const breakpoints = {
|
|
113
|
+
xs: 0,
|
|
114
|
+
sm: 576,
|
|
115
|
+
md: 768,
|
|
116
|
+
lg: 992,
|
|
117
|
+
xl: 1200,
|
|
118
|
+
xxl: 1600
|
|
119
|
+
};
|
|
120
|
+
const mediaQueries = {
|
|
121
|
+
xs: '@media (max-width: 575.98px)',
|
|
122
|
+
sm: `@media (min-width: ${breakpoints.sm}px)`,
|
|
123
|
+
md: `@media (min-width: ${breakpoints.md}px)`,
|
|
124
|
+
lg: `@media (min-width: ${breakpoints.lg}px)`,
|
|
125
|
+
xl: `@media (min-width: ${breakpoints.xl}px)`,
|
|
126
|
+
xxl: `@media (min-width: ${breakpoints.xxl}px)`
|
|
127
|
+
};
|
|
128
|
+
const responsive = {
|
|
129
|
+
breakpoints,
|
|
130
|
+
mediaQueries
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
|
134
|
+
const darkProtectedColorList = {
|
|
135
|
+
tagBackgroundBrown: 'rgba(171, 86, 2, 0.1000)',
|
|
136
|
+
tagBackgroundCharcoal: primitiveColors.grey300,
|
|
137
|
+
tagBackgroundCoral: 'rgba(240, 0, 64, 0.1000)',
|
|
138
|
+
tagBackgroundDefault: 'rgba(232, 236, 240, 0.0800)',
|
|
139
|
+
tagBackgroundIndigo: 'rgba(1, 68, 255, 0.1200)',
|
|
140
|
+
tagBackgroundLemon: 'rgba(255, 191, 1, 0.1800)',
|
|
141
|
+
tagBackgroundLime: 'rgba(2, 179, 2, 0.0800)',
|
|
142
|
+
tagBackgroundPink: 'rgba(240, 1, 150, 0.1200)',
|
|
143
|
+
tagBackgroundPurple: 'rgba(59, 0, 255, 0.1200)',
|
|
144
|
+
tagBackgroundTeal: 'rgba(2, 192, 150, 0.1200)',
|
|
145
|
+
tagBackgroundTurquoise: 'rgba(2, 192, 213, 0.1200)',
|
|
146
|
+
tagHover: 'rgba(138, 202, 255, 0.0800)',
|
|
147
|
+
tagIconBrown: '#DAB594',
|
|
148
|
+
tagIconCharcoal: primitiveColors.grey650,
|
|
149
|
+
tagIconCoral: '#FF859D',
|
|
150
|
+
tagIconDefault: primitiveColors.grey350,
|
|
151
|
+
tagIconHover: primitiveColors.grey350,
|
|
152
|
+
tagIconIndigo: '#99A2FF',
|
|
153
|
+
tagIconLemon: '#FFCD4D',
|
|
154
|
+
tagIconLime: '#70D083',
|
|
155
|
+
tagIconPink: '#F986C9',
|
|
156
|
+
tagIconPress: primitiveColors.grey350,
|
|
157
|
+
tagIconPurple: '#B399FF',
|
|
158
|
+
tagIconTeal: '#0AD8B6',
|
|
159
|
+
tagIconTurquoise: '#1FD0F3',
|
|
160
|
+
tagInverse: primitiveColors.grey800,
|
|
161
|
+
tagPress: 'rgba(138, 202, 255, 0.1600)',
|
|
162
|
+
tagTextBrown: '#F2E1CA',
|
|
163
|
+
tagTextCharcoal: primitiveColors.grey800,
|
|
164
|
+
tagTextCoral: '#FED2E1',
|
|
165
|
+
tagTextDefault: primitiveColors.grey100,
|
|
166
|
+
tagTextIndigo: '#DDDFFE',
|
|
167
|
+
tagTextLemon: '#FFE7B3',
|
|
168
|
+
tagTextLime: '#C2F0C2',
|
|
169
|
+
tagTextPink: '#FDD1EA',
|
|
170
|
+
tagTextPurple: '#E2DDFE',
|
|
171
|
+
tagTextTeal: '#ADF0DD',
|
|
172
|
+
tagTextTurquoise: '#B6ECF7'
|
|
173
|
+
};
|
|
174
|
+
const lightProtectedColorList = {
|
|
175
|
+
tagBackgroundBrown: 'rgba(171, 86, 2, 0.0800)',
|
|
176
|
+
tagBackgroundCharcoal: primitiveColors.grey650,
|
|
177
|
+
tagBackgroundCoral: 'rgba(240, 0, 64, 0.0600)',
|
|
178
|
+
tagBackgroundDefault: 'rgba(0, 0, 59, 0.0500)',
|
|
179
|
+
tagBackgroundIndigo: 'rgba(1, 68, 255, 0.0600)',
|
|
180
|
+
tagBackgroundLemon: 'rgba(255, 191, 1, 0.1800)',
|
|
181
|
+
tagBackgroundLime: 'rgba(2, 179, 2, 0.0800)',
|
|
182
|
+
tagBackgroundPink: 'rgba(240, 1, 150, 0.0600)',
|
|
183
|
+
tagBackgroundPurple: 'rgba(59, 0, 255, 0.0500)',
|
|
184
|
+
tagBackgroundTeal: 'rgba(2, 192, 150, 0.0900)',
|
|
185
|
+
tagBackgroundTurquoise: 'rgba(2, 192, 213, 0.0900)',
|
|
186
|
+
tagHover: 'rgba(34, 114, 180, 0.0800)',
|
|
187
|
+
tagIconBrown: '#815E46',
|
|
188
|
+
tagIconCharcoal: primitiveColors.grey350,
|
|
189
|
+
tagIconCoral: '#CA244E',
|
|
190
|
+
tagIconDefault: primitiveColors.grey600,
|
|
191
|
+
tagIconHover: primitiveColors.grey600,
|
|
192
|
+
tagIconIndigo: '#3451B2',
|
|
193
|
+
tagIconLemon: '#915830',
|
|
194
|
+
tagIconLime: '#227534',
|
|
195
|
+
tagIconPink: '#C41C87',
|
|
196
|
+
tagIconPress: primitiveColors.grey600,
|
|
197
|
+
tagIconPurple: '#5746AF',
|
|
198
|
+
tagIconTeal: '#00776B',
|
|
199
|
+
tagIconTurquoise: '#00708D',
|
|
200
|
+
tagInverse: primitiveColors.grey800,
|
|
201
|
+
tagPress: 'rgba(34, 114, 180, 0.1600)',
|
|
202
|
+
tagTextBrown: '#3E332E',
|
|
203
|
+
tagTextCharcoal: primitiveColors.grey100,
|
|
204
|
+
tagTextCoral: '#64172B',
|
|
205
|
+
tagTextDefault: primitiveColors.grey800,
|
|
206
|
+
tagTextIndigo: '#101D46',
|
|
207
|
+
tagTextLemon: '#4F3422',
|
|
208
|
+
tagTextLime: '#203C25',
|
|
209
|
+
tagTextPink: '#651249',
|
|
210
|
+
tagTextPurple: '#2F265F',
|
|
211
|
+
tagTextTeal: '#0D3D38',
|
|
212
|
+
tagTextTurquoise: '#0D3C48'
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
|
216
|
+
const darkColorList = {
|
|
217
|
+
actionDangerDefaultBackgroundDefault: 'rgba(247, 146, 166, 0.0000)',
|
|
218
|
+
actionDangerDefaultBackgroundHover: 'rgba(247, 146, 166, 0.0800)',
|
|
219
|
+
actionDangerDefaultBackgroundPress: 'rgba(247, 146, 166, 0.1600)',
|
|
220
|
+
actionDangerDefaultBorderDefault: primitiveColors.red500,
|
|
221
|
+
actionDangerDefaultBorderHover: primitiveColors.red400,
|
|
222
|
+
actionDangerDefaultBorderPress: primitiveColors.red300,
|
|
223
|
+
actionDangerDefaultTextDefault: primitiveColors.red500,
|
|
224
|
+
actionDangerDefaultTextHover: primitiveColors.red400,
|
|
225
|
+
actionDangerDefaultTextPress: primitiveColors.red300,
|
|
226
|
+
actionDangerPrimaryBackgroundDefault: primitiveColors.red500,
|
|
227
|
+
actionDangerPrimaryBackgroundHover: primitiveColors.red400,
|
|
228
|
+
actionDangerPrimaryBackgroundPress: primitiveColors.red300,
|
|
229
|
+
actionDangerPrimaryText: primitiveColors.grey800,
|
|
230
|
+
actionDefaultBackgroundDefault: 'rgba(138, 202, 255, 0.0000)',
|
|
231
|
+
actionDefaultBackgroundHover: 'rgba(138, 202, 255, 0.0800)',
|
|
232
|
+
actionDefaultBackgroundPress: 'rgba(138, 202, 255, 0.1600)',
|
|
233
|
+
actionDefaultBorderDefault: primitiveColors.grey650,
|
|
234
|
+
actionDefaultBorderFocus: primitiveColors.blue400,
|
|
235
|
+
actionDefaultBorderHover: primitiveColors.blue400,
|
|
236
|
+
actionDefaultBorderPress: primitiveColors.blue300,
|
|
237
|
+
actionDefaultIconDefault: primitiveColors.grey350,
|
|
238
|
+
actionDefaultIconHover: primitiveColors.blue400,
|
|
239
|
+
actionDefaultIconPress: primitiveColors.blue300,
|
|
240
|
+
actionDefaultTextDefault: primitiveColors.grey100,
|
|
241
|
+
actionDefaultTextHover: primitiveColors.blue400,
|
|
242
|
+
actionDefaultTextPress: primitiveColors.blue300,
|
|
243
|
+
actionDisabledBackground: primitiveColors.grey650,
|
|
244
|
+
actionDisabledBorder: primitiveColors.grey600,
|
|
245
|
+
actionDisabledText: primitiveColors.grey500,
|
|
246
|
+
actionIconBackgroundDefault: 'rgba(255, 255, 255, 0.0000)',
|
|
247
|
+
actionIconBackgroundHover: 'rgba(255, 255, 255, 0.0800)',
|
|
248
|
+
actionIconBackgroundPress: 'rgba(255, 255, 255, 0.1600)',
|
|
249
|
+
actionIconIconDefault: primitiveColors.grey350,
|
|
250
|
+
actionIconIconHover: primitiveColors.grey300,
|
|
251
|
+
actionIconIconPress: primitiveColors.grey200,
|
|
252
|
+
actionLinkDefault: primitiveColors.blue500,
|
|
253
|
+
actionLinkHover: primitiveColors.blue400,
|
|
254
|
+
actionLinkPress: primitiveColors.blue300,
|
|
255
|
+
actionPrimaryBackgroundDefault: primitiveColors.blue500,
|
|
256
|
+
actionPrimaryBackgroundHover: primitiveColors.blue400,
|
|
257
|
+
actionPrimaryBackgroundPress: primitiveColors.blue300,
|
|
258
|
+
actionPrimaryIcon: primitiveColors.grey800,
|
|
259
|
+
actionPrimaryTextDefault: primitiveColors.grey800,
|
|
260
|
+
actionPrimaryTextHover: primitiveColors.grey800,
|
|
261
|
+
actionPrimaryTextPress: primitiveColors.grey800,
|
|
262
|
+
actionTertiaryBackgroundDefault: 'rgba(143, 205, 255, 0.0000)',
|
|
263
|
+
actionTertiaryBackgroundHover: 'rgba(143, 205, 255, 0.0800)',
|
|
264
|
+
actionTertiaryBackgroundPress: 'rgba(143, 205, 255, 0.1600)',
|
|
265
|
+
actionTertiaryIconDefault: primitiveColors.blue500,
|
|
266
|
+
actionTertiaryIconHover: primitiveColors.blue400,
|
|
267
|
+
actionTertiaryIconPress: primitiveColors.blue300,
|
|
268
|
+
actionTertiaryTextDefault: primitiveColors.blue500,
|
|
269
|
+
actionTertiaryTextHover: primitiveColors.blue400,
|
|
270
|
+
actionTertiaryTextPress: primitiveColors.blue300,
|
|
271
|
+
backgroundDanger: 'rgba(200, 45, 76, 0.1600)',
|
|
272
|
+
backgroundPrimary: primitiveColors.grey800,
|
|
273
|
+
backgroundSecondary: primitiveColors.grey700,
|
|
274
|
+
backgroundSuccess: 'rgba(39, 124, 67, 0.1600)',
|
|
275
|
+
backgroundWarning: 'rgba(190, 80, 30, 0.1600)',
|
|
276
|
+
border: primitiveColors.grey700,
|
|
277
|
+
borderAccessible: primitiveColors.grey300,
|
|
278
|
+
borderDanger: primitiveColors.red500,
|
|
279
|
+
borderWarning: primitiveColors.yellow500,
|
|
280
|
+
codeBackground: primitiveColors.grey650,
|
|
281
|
+
overlayOverlay: 'rgba(0, 0, 0, 0.45)',
|
|
282
|
+
progressFill: primitiveColors.grey500,
|
|
283
|
+
progressFillPrimary: primitiveColors.blue600,
|
|
284
|
+
progressTrack: primitiveColors.grey650,
|
|
285
|
+
skeleton: 'rgba(144, 164, 181, 0.1600)',
|
|
286
|
+
tableBackgroundSelectedDefault: 'rgba(189, 205, 219, 0.0800)',
|
|
287
|
+
tableBackgroundSelectedHover: 'rgba(189, 205, 219, 0.1200)',
|
|
288
|
+
tableBackgroundUnselectedDefault: primitiveColors.grey800,
|
|
289
|
+
tableBackgroundUnselectedHover: 'rgba(189, 205, 219, 0.0400)',
|
|
290
|
+
textPlaceholder: primitiveColors.grey400,
|
|
291
|
+
textPrimary: primitiveColors.grey100,
|
|
292
|
+
textSecondary: primitiveColors.grey350,
|
|
293
|
+
textValidationDanger: primitiveColors.red500,
|
|
294
|
+
textValidationSuccess: primitiveColors.green500,
|
|
295
|
+
textValidationWarning: primitiveColors.yellow500,
|
|
296
|
+
tooltipBackgroundTooltip: primitiveColors.grey100
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
|
300
|
+
const lightColorList = {
|
|
301
|
+
actionDangerDefaultBackgroundDefault: 'rgba(200, 45, 76, 0.0000)',
|
|
302
|
+
actionDangerDefaultBackgroundHover: 'rgba(200, 45, 76, 0.0800)',
|
|
303
|
+
actionDangerDefaultBackgroundPress: 'rgba(200, 45, 76, 0.1600)',
|
|
304
|
+
actionDangerDefaultBorderDefault: primitiveColors.red600,
|
|
305
|
+
actionDangerDefaultBorderHover: primitiveColors.red700,
|
|
306
|
+
actionDangerDefaultBorderPress: primitiveColors.red800,
|
|
307
|
+
actionDangerDefaultTextDefault: primitiveColors.red600,
|
|
308
|
+
actionDangerDefaultTextHover: primitiveColors.red700,
|
|
309
|
+
actionDangerDefaultTextPress: primitiveColors.red800,
|
|
310
|
+
actionDangerPrimaryBackgroundDefault: primitiveColors.red600,
|
|
311
|
+
actionDangerPrimaryBackgroundHover: primitiveColors.red700,
|
|
312
|
+
actionDangerPrimaryBackgroundPress: primitiveColors.red800,
|
|
313
|
+
actionDangerPrimaryText: primitiveColors.white,
|
|
314
|
+
actionDefaultBackgroundDefault: 'rgba(34, 114, 180, 0.0000)',
|
|
315
|
+
actionDefaultBackgroundHover: 'rgba(34, 114, 180, 0.0800)',
|
|
316
|
+
actionDefaultBackgroundPress: 'rgba(34, 114, 180, 0.1600)',
|
|
317
|
+
actionDefaultBorderDefault: primitiveColors.grey300,
|
|
318
|
+
actionDefaultBorderFocus: primitiveColors.blue600,
|
|
319
|
+
actionDefaultBorderHover: primitiveColors.blue600,
|
|
320
|
+
actionDefaultBorderPress: primitiveColors.blue800,
|
|
321
|
+
actionDefaultIconDefault: primitiveColors.grey600,
|
|
322
|
+
actionDefaultIconHover: primitiveColors.blue700,
|
|
323
|
+
actionDefaultIconPress: primitiveColors.blue800,
|
|
324
|
+
actionDefaultTextDefault: primitiveColors.grey800,
|
|
325
|
+
actionDefaultTextHover: primitiveColors.blue700,
|
|
326
|
+
actionDefaultTextPress: primitiveColors.blue800,
|
|
327
|
+
actionDisabledBackground: primitiveColors.grey100,
|
|
328
|
+
actionDisabledBorder: primitiveColors.grey200,
|
|
329
|
+
actionDisabledText: primitiveColors.grey350,
|
|
330
|
+
actionIconBackgroundDefault: 'rgba(34, 114, 180, 0.0000)',
|
|
331
|
+
actionIconBackgroundHover: 'rgba(34, 114, 180, 0.0800)',
|
|
332
|
+
actionIconBackgroundPress: 'rgba(34, 114, 180, 0.1600)',
|
|
333
|
+
actionIconIconDefault: primitiveColors.grey600,
|
|
334
|
+
actionIconIconHover: primitiveColors.blue700,
|
|
335
|
+
actionIconIconPress: primitiveColors.blue800,
|
|
336
|
+
actionLinkDefault: primitiveColors.blue600,
|
|
337
|
+
actionLinkHover: primitiveColors.blue700,
|
|
338
|
+
actionLinkPress: primitiveColors.blue800,
|
|
339
|
+
actionPrimaryBackgroundDefault: primitiveColors.blue600,
|
|
340
|
+
actionPrimaryBackgroundHover: primitiveColors.blue700,
|
|
341
|
+
actionPrimaryBackgroundPress: primitiveColors.blue800,
|
|
342
|
+
actionPrimaryIcon: primitiveColors.white,
|
|
343
|
+
actionPrimaryTextDefault: primitiveColors.white,
|
|
344
|
+
actionPrimaryTextHover: primitiveColors.white,
|
|
345
|
+
actionPrimaryTextPress: primitiveColors.white,
|
|
346
|
+
actionTertiaryBackgroundDefault: 'rgba(34, 114, 180, 0.0000)',
|
|
347
|
+
actionTertiaryBackgroundHover: 'rgba(34, 114, 180, 0.0800)',
|
|
348
|
+
actionTertiaryBackgroundPress: 'rgba(34, 114, 180, 0.1600)',
|
|
349
|
+
actionTertiaryIconDefault: primitiveColors.blue600,
|
|
350
|
+
actionTertiaryIconHover: primitiveColors.blue700,
|
|
351
|
+
actionTertiaryIconPress: primitiveColors.blue800,
|
|
352
|
+
actionTertiaryTextDefault: primitiveColors.blue600,
|
|
353
|
+
actionTertiaryTextHover: primitiveColors.blue700,
|
|
354
|
+
actionTertiaryTextPress: primitiveColors.blue800,
|
|
355
|
+
backgroundDanger: primitiveColors.red100,
|
|
356
|
+
backgroundPrimary: primitiveColors.white,
|
|
357
|
+
backgroundSecondary: primitiveColors.grey050,
|
|
358
|
+
backgroundSuccess: primitiveColors.green100,
|
|
359
|
+
backgroundWarning: primitiveColors.yellow100,
|
|
360
|
+
border: primitiveColors.grey100,
|
|
361
|
+
borderAccessible: primitiveColors.grey500,
|
|
362
|
+
borderDanger: primitiveColors.red300,
|
|
363
|
+
borderWarning: primitiveColors.yellow300,
|
|
364
|
+
codeBackground: 'rgba(68, 83, 95, 0.0800)',
|
|
365
|
+
overlayOverlay: 'rgba(0, 0, 0, 0.26)',
|
|
366
|
+
progressFill: primitiveColors.grey300,
|
|
367
|
+
progressFillPrimary: primitiveColors.blue500,
|
|
368
|
+
progressTrack: primitiveColors.grey100,
|
|
369
|
+
skeleton: 'rgba(144, 164, 181, 0.1600)',
|
|
370
|
+
tableBackgroundSelectedDefault: 'rgba(68, 83, 95, 0.0800)',
|
|
371
|
+
tableBackgroundSelectedHover: 'rgba(68, 83, 95, 0.1200)',
|
|
372
|
+
tableBackgroundUnselectedDefault: primitiveColors.white,
|
|
373
|
+
tableBackgroundUnselectedHover: 'rgba(68, 83, 95, 0.0400)',
|
|
374
|
+
textPlaceholder: primitiveColors.grey500,
|
|
375
|
+
textPrimary: primitiveColors.grey800,
|
|
376
|
+
textSecondary: primitiveColors.grey500,
|
|
377
|
+
textValidationDanger: primitiveColors.red600,
|
|
378
|
+
textValidationSuccess: primitiveColors.green600,
|
|
379
|
+
textValidationWarning: primitiveColors.yellow600,
|
|
380
|
+
tooltipBackgroundTooltip: primitiveColors.grey800
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// Currently these are the same for both light and dark mode, but we may want to change this in the future.
|
|
384
|
+
const branded = {
|
|
385
|
+
ai: {
|
|
386
|
+
/** For AI components, the top-left-oriented start color of gradient treatments. */ gradientStart: '#4299E0',
|
|
387
|
+
/** For AI components, the mid color of gradient treatments. */ gradientMid: '#CA42E0',
|
|
388
|
+
/** For AI components, the bottom-right-oriented end color of gradient treatments. */ gradientEnd: '#FF5F46'
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
const darkColors = {
|
|
392
|
+
...darkColorList,
|
|
393
|
+
...primitiveColors,
|
|
394
|
+
branded
|
|
395
|
+
};
|
|
396
|
+
const lightColors = {
|
|
397
|
+
...lightColorList,
|
|
398
|
+
...primitiveColors,
|
|
399
|
+
branded
|
|
400
|
+
};
|
|
401
|
+
function getSemanticColors(isDarkMode) {
|
|
402
|
+
return isDarkMode ? darkColors : lightColors;
|
|
403
|
+
}
|
|
404
|
+
function getProtectedSemanticColors(isDarkMode) {
|
|
405
|
+
return isDarkMode ? darkProtectedColorList : lightProtectedColorList;
|
|
406
|
+
}
|
|
407
|
+
// When deprecating a color, add it to this object with a comment explaining why it's deprecated and a link to a JIRA ticket.
|
|
408
|
+
// Example: `@deprecated This color supports XXXX will be removed in an upcoming release (FEINF-1234).`
|
|
409
|
+
const deprecatedPrimitiveColors = {
|
|
410
|
+
/** @deprecated This was an alias to `primitiveColors.blue600`, please use that instead.
|
|
411
|
+
* If possible, please use an appropriate semantic color, such as `actionPrimaryBackgroundDefault`. */ primary: primitiveColors.blue600,
|
|
412
|
+
/** @deprecated This was an alias to `primitiveColors.grey600`, please use that instead.
|
|
413
|
+
* If possible, please use an appropriate semantic color, such as `actionPrimaryBackgroundHover`. */ charcoal: primitiveColors.grey600,
|
|
414
|
+
/** @deprecated This color supports legacy radio styles and will be removed in an upcoming release (FEINF-1674). */ radioInteractiveAvailable: primitiveColors.blue600,
|
|
415
|
+
/** @deprecated This color supports legacy radio styles and will be removed in an upcoming release (FEINF-1674). */ radioInteractiveHover: '#186099',
|
|
416
|
+
/** @deprecated This color supports legacy radio styles and will be removed in an upcoming release (FEINF-1674). */ radioInteractivePress: '#0D4F85',
|
|
417
|
+
/** @deprecated This color supports legacy radio styles and will be removed in an upcoming release (FEINF-1674). */ radioDisabled: '#A2AEB8',
|
|
418
|
+
/** @deprecated This color supports legacy radio styles and will be removed in an upcoming release (FEINF-1674). */ radioDefaultBorder: '#64727D',
|
|
419
|
+
/** @deprecated This color supports legacy radio styles and will be removed in an upcoming release (FEINF-1674). */ radioDefaultBackground: '#FFFFFF',
|
|
420
|
+
/** @deprecated This color supports legacy radio styles and will be removed in an upcoming release (FEINF-1674). */ radioInteractiveHoverSecondary: 'rgba(34, 115, 181, 0.08)',
|
|
421
|
+
/** @deprecated This color supports legacy radio styles and will be removed in an upcoming release (FEINF-1674). */ radioInteractivePressSecondary: 'rgba(34, 115, 181, 0.16)'
|
|
422
|
+
};
|
|
423
|
+
const deprecatedSemanticColorsLight = {
|
|
424
|
+
/** @deprecated Use `backgroundDanger` (FEINF-xxxx) */ backgroundValidationDanger: lightColorList.backgroundDanger,
|
|
425
|
+
/** @deprecated Use `backgroundSuccess` (FEINF-xxxx) */ backgroundValidationSuccess: lightColorList.backgroundSuccess,
|
|
426
|
+
/** @deprecated Use `backgroundWarning` (FEINF-xxxx) */ backgroundValidationWarning: lightColorList.backgroundWarning,
|
|
427
|
+
/** @deprecated Use `border` (FEINF-xxxx) */ borderDecorative: lightColorList.border,
|
|
428
|
+
/** @deprecated Use `borderDanger` (FEINF-xxxx) */ borderValidationDanger: lightColorList.borderDanger,
|
|
429
|
+
/** @deprecated Use `borderWarning` (FEINF-xxxx) */ borderValidationWarning: lightColorList.borderWarning,
|
|
430
|
+
/** @deprecated Use `tableBackgroundUnselectedHover` (FEINF-xxxx) */ tableRowHover: lightColorList.tableBackgroundUnselectedHover,
|
|
431
|
+
/** @deprecated Use `textSecondary` (FEINF-xxxx) */ textValidationInfo: lightColorList.textSecondary,
|
|
432
|
+
/** @deprecated Use `codeBackground` (FEINF-xxxx) */ typographyCodeBg: lightColorList.codeBackground,
|
|
433
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagBrown: primitiveColors.brown,
|
|
434
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagCharcoal: primitiveColors.grey600,
|
|
435
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagCoral: primitiveColors.coral,
|
|
436
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagDefault: primitiveColors.grey100,
|
|
437
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagHover: 'rgba(34, 114, 180, 0.0800)',
|
|
438
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagIconHover: primitiveColors.grey600,
|
|
439
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagIconPress: primitiveColors.grey600,
|
|
440
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagIndigo: primitiveColors.indigo,
|
|
441
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagInverse: primitiveColors.grey800,
|
|
442
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagLemon: primitiveColors.lemon,
|
|
443
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagLime: primitiveColors.lime,
|
|
444
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagPink: primitiveColors.pink,
|
|
445
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagPress: 'rgba(34, 114, 180, 0.1600)',
|
|
446
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagPurple: primitiveColors.purple,
|
|
447
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagTeal: primitiveColors.teal,
|
|
448
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagText: primitiveColors.white,
|
|
449
|
+
/** @deprecated Do not use Tag colors (go/updating-tag-colors). Ask in #dubois if you have any questions. */ tagTurquoise: primitiveColors.turquoise
|
|
450
|
+
};
|
|
451
|
+
const deprecatedSemanticColorsDark = {
|
|
452
|
+
backgroundValidationDanger: darkColorList.backgroundDanger,
|
|
453
|
+
backgroundValidationSuccess: darkColorList.backgroundSuccess,
|
|
454
|
+
backgroundValidationWarning: darkColorList.backgroundWarning,
|
|
455
|
+
borderDecorative: darkColorList.border,
|
|
456
|
+
borderValidationDanger: darkColorList.borderDanger,
|
|
457
|
+
borderValidationWarning: darkColorList.borderWarning,
|
|
458
|
+
tableRowHover: darkColorList.tableBackgroundUnselectedHover,
|
|
459
|
+
textValidationInfo: darkColorList.textSecondary,
|
|
460
|
+
typographyCodeBg: darkColorList.codeBackground,
|
|
461
|
+
tagBrown: 'rgba(166, 99, 12, 0.8600)',
|
|
462
|
+
tagCharcoal: 'rgba(68, 83, 95, 0.8600)',
|
|
463
|
+
tagCoral: 'rgba(200, 50, 67, 0.8600)',
|
|
464
|
+
tagDefault: primitiveColors.grey650,
|
|
465
|
+
tagHover: 'rgba(138, 202, 255, 0.0800)',
|
|
466
|
+
tagIconHover: primitiveColors.grey350,
|
|
467
|
+
tagIconPress: primitiveColors.grey350,
|
|
468
|
+
tagIndigo: 'rgba(67, 74, 147, 0.8600)',
|
|
469
|
+
tagInverse: primitiveColors.grey800,
|
|
470
|
+
tagLemon: 'rgba(250, 203, 102, 0.8600)',
|
|
471
|
+
tagLime: 'rgba(48, 134, 19, 0.8600)',
|
|
472
|
+
tagPink: 'rgba(180, 80, 145, 0.8600)',
|
|
473
|
+
tagPress: 'rgba(138, 202, 255, 0.1600)',
|
|
474
|
+
tagPurple: 'rgba(138, 99, 191, 0.8600)',
|
|
475
|
+
tagTeal: 'rgba(4, 134, 125, 0.8600)',
|
|
476
|
+
tagText: primitiveColors.grey100,
|
|
477
|
+
tagTurquoise: 'rgba(19, 125, 174, 0.8600)'
|
|
478
|
+
};
|
|
479
|
+
function getColors(isDarkMode) {
|
|
480
|
+
return {
|
|
481
|
+
...deprecatedPrimitiveColors,
|
|
482
|
+
...isDarkMode ? deprecatedSemanticColorsDark : deprecatedSemanticColorsLight,
|
|
483
|
+
...getSemanticColors(isDarkMode)
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
const DEFAULT_SPACING_UNIT = 8;
|
|
488
|
+
const MODAL_PADDING = 40;
|
|
489
|
+
const spacing = {
|
|
490
|
+
xs: DEFAULT_SPACING_UNIT / 2,
|
|
491
|
+
sm: DEFAULT_SPACING_UNIT,
|
|
492
|
+
md: DEFAULT_SPACING_UNIT * 2,
|
|
493
|
+
lg: DEFAULT_SPACING_UNIT * 3
|
|
494
|
+
};
|
|
495
|
+
// Less variables that are used by AntD
|
|
496
|
+
({
|
|
497
|
+
defaultPaddingLg: spacing.lg,
|
|
498
|
+
defaultPaddingMd: spacing.md,
|
|
499
|
+
defaultPaddingSm: spacing.sm,
|
|
500
|
+
defaultPaddingXs: spacing.sm,
|
|
501
|
+
defaultPaddingXss: spacing.xs,
|
|
502
|
+
paddingLg: spacing.md,
|
|
503
|
+
// TODO: Check if there is a better alternative with team
|
|
504
|
+
paddingMd: spacing.sm,
|
|
505
|
+
paddingSm: spacing.sm,
|
|
506
|
+
paddingXs: spacing.xs,
|
|
507
|
+
paddingXss: 0,
|
|
508
|
+
marginSm: 12,
|
|
509
|
+
marginLg: spacing.lg,
|
|
510
|
+
// Button
|
|
511
|
+
btnPaddingHorizontalBase: DEFAULT_SPACING_UNIT * 2,
|
|
512
|
+
btnPaddingHorizontalLg: DEFAULT_SPACING_UNIT * 2,
|
|
513
|
+
btnPaddingHorizontalSm: DEFAULT_SPACING_UNIT * 2,
|
|
514
|
+
// Input
|
|
515
|
+
inputPaddingHorizontal: DEFAULT_SPACING_UNIT * 1.5,
|
|
516
|
+
inputPaddingHorizontalBase: DEFAULT_SPACING_UNIT * 1.5,
|
|
517
|
+
inputPaddingHorizontalSm: DEFAULT_SPACING_UNIT * 1.5,
|
|
518
|
+
inputPaddingHorizontalLg: DEFAULT_SPACING_UNIT * 1.5,
|
|
519
|
+
inputPaddingVertical: spacing.xs + 1,
|
|
520
|
+
inputPaddingVerticalBase: spacing.xs + 1,
|
|
521
|
+
inputPaddingVerticalSm: spacing.xs + 1,
|
|
522
|
+
inputPaddingVerticalLg: spacing.xs + 1,
|
|
523
|
+
// Modal
|
|
524
|
+
modalPadding: MODAL_PADDING,
|
|
525
|
+
modalLessPadding: MODAL_PADDING - 20,
|
|
526
|
+
modalHeaderPadding: `${MODAL_PADDING}px ${MODAL_PADDING}px ${MODAL_PADDING - 20}px`,
|
|
527
|
+
modalHeaderCloseSize: MODAL_PADDING * 2 + 22,
|
|
528
|
+
modalHeaderBorderWidth: 0,
|
|
529
|
+
modalBodyPadding: `0 ${MODAL_PADDING}px`,
|
|
530
|
+
modalFooterPaddingVertical: 0,
|
|
531
|
+
modalFooterPaddingHorizontal: 0,
|
|
532
|
+
modalFooterBorderWidth: 0,
|
|
533
|
+
// Switch
|
|
534
|
+
switchPadding: 0,
|
|
535
|
+
switchHeight: 16,
|
|
536
|
+
switchMinWidth: 28,
|
|
537
|
+
switchPinSize: 14
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
// eslint-disable-next-line import/no-anonymous-default-export
|
|
541
|
+
var antdVars = {
|
|
542
|
+
// IMPORTANT: Do not read this directly from components. Use `React.useContext`.
|
|
543
|
+
'ant-prefix': 'du-bois'
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
const heightBase = 40;
|
|
547
|
+
const borderWidth = 1;
|
|
548
|
+
const antdGeneralVariables = {
|
|
549
|
+
classnamePrefix: antdVars['ant-prefix'],
|
|
550
|
+
iconfontCssPrefix: 'anticon',
|
|
551
|
+
borderRadiusBase: 4,
|
|
552
|
+
borderWidth: borderWidth,
|
|
553
|
+
heightSm: 32,
|
|
554
|
+
heightBase: heightBase,
|
|
555
|
+
iconSize: 24,
|
|
556
|
+
iconFontSize: 16,
|
|
557
|
+
buttonHeight: heightBase,
|
|
558
|
+
// Height available within button (for label and icon). Same for middle and small buttons.
|
|
559
|
+
buttonInnerHeight: heightBase - spacing.sm * 2 - borderWidth * 2
|
|
560
|
+
};
|
|
561
|
+
const shadowLightRgb = '31, 39, 45';
|
|
562
|
+
const shadowDarkRgb = '0, 0, 0';
|
|
563
|
+
const getShadowVariables = (isDarkMode)=>{
|
|
564
|
+
if (isDarkMode) {
|
|
565
|
+
return {
|
|
566
|
+
/**
|
|
567
|
+
* @deprecated Use new shadow variables under theme.shadows.*, check out go/dubois-elevation-doc decision doc for guidance on choosing the new shadow variable
|
|
568
|
+
*/ shadowLow: `0px 4px 16px rgba(${shadowDarkRgb}, 0.12)`,
|
|
569
|
+
/**
|
|
570
|
+
* @deprecated Use new shadow variables under theme.shadows.*, check out go/dubois-elevation-doc decision doc for guidance on choosing the new shadow variable
|
|
571
|
+
*/ shadowHigh: `0px 8px 24px rgba(${shadowDarkRgb}, 0.2);`
|
|
572
|
+
};
|
|
573
|
+
} else {
|
|
574
|
+
return {
|
|
575
|
+
/**
|
|
576
|
+
* @deprecated Use new shadow variables under theme.shadows.*, check out go/dubois-elevation-doc decision doc for guidance on choosing the new shadow variable
|
|
577
|
+
*/ shadowLow: `0px 4px 16px rgba(${shadowLightRgb}, 0.12)`,
|
|
578
|
+
/**
|
|
579
|
+
* @deprecated Use new shadow variables under theme.shadows.*, check out go/dubois-elevation-doc decision doc for guidance on choosing the new shadow variable
|
|
580
|
+
*/ shadowHigh: `0px 8px 24px rgba(${shadowLightRgb}, 0.2)`
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
function getGradients(isDarkMode) {
|
|
586
|
+
const colors = getColors(isDarkMode);
|
|
587
|
+
return {
|
|
588
|
+
aiBorderGradient: `linear-gradient(135deg, ${colors.branded.ai.gradientStart} 20.5%, ${colors.branded.ai.gradientMid} 46.91%, ${colors.branded.ai.gradientEnd} 79.5%)`
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// Dark mode colors
|
|
593
|
+
const blackAlpha87 = 'rgba(0, 0, 0, 0.87)';
|
|
594
|
+
const blackAlpha61 = 'rgba(0, 0, 0, 0.61)';
|
|
595
|
+
const blackAlpha45 = 'rgba(0, 0, 0, 0.45)';
|
|
596
|
+
const blackAlpha26 = 'rgba(0, 0, 0, 0.26)';
|
|
597
|
+
// Light mode colors
|
|
598
|
+
const blackAlpha13 = 'rgba(0, 0, 0, 0.13)';
|
|
599
|
+
const blackAlpha08 = 'rgba(0, 0, 0, 0.08)';
|
|
600
|
+
const blackAlpha05 = 'rgba(0, 0, 0, 0.05)';
|
|
601
|
+
const blackAlpha02 = 'rgba(0, 0, 0, 0.02)';
|
|
602
|
+
const getShadows = (isDarkMode)=>{
|
|
603
|
+
return isDarkMode ? {
|
|
604
|
+
xs: `0px 1px 0px 0px ${blackAlpha45}`,
|
|
605
|
+
sm: ` 0px 2px 3px -1px ${blackAlpha45}, 0px 1px 0px 0px ${blackAlpha26}`,
|
|
606
|
+
md: `0px 3px 6px 0px ${blackAlpha45}`,
|
|
607
|
+
lg: `0px 2px 16px 0px ${blackAlpha61}`,
|
|
608
|
+
xl: `0px 8px 40px 0px ${blackAlpha87}`
|
|
609
|
+
} : {
|
|
610
|
+
xs: `0px 1px 0px 0px ${blackAlpha05}`,
|
|
611
|
+
sm: ` 0px 2px 3px -1px ${blackAlpha05}, 0px 1px 0px 0px ${blackAlpha02}`,
|
|
612
|
+
md: `0px 3px 6px 0px ${blackAlpha05}`,
|
|
613
|
+
lg: `0px 2px 16px 0px ${blackAlpha08}`,
|
|
614
|
+
xl: `0px 8px 40px 0px ${blackAlpha13}`
|
|
615
|
+
};
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
const FONT_SIZE_BASE = 13;
|
|
619
|
+
// Less variables that are used by AntD
|
|
620
|
+
const antdTypography = {
|
|
621
|
+
fontSizeSm: 12,
|
|
622
|
+
fontSizeBase: FONT_SIZE_BASE,
|
|
623
|
+
fontSizeMd: FONT_SIZE_BASE,
|
|
624
|
+
fontSizeLg: 18,
|
|
625
|
+
fontSizeXl: 22,
|
|
626
|
+
fontSizeXxl: 32,
|
|
627
|
+
lineHeightSm: '16px',
|
|
628
|
+
lineHeightBase: '20px',
|
|
629
|
+
lineHeightMd: '20px',
|
|
630
|
+
lineHeightLg: '24px',
|
|
631
|
+
lineHeightXl: '28px',
|
|
632
|
+
lineHeightXxl: '40px',
|
|
633
|
+
typographyRegularFontWeight: 400,
|
|
634
|
+
typographyBoldFontWeight: 600
|
|
635
|
+
};
|
|
636
|
+
// eslint-disable-next-line import/no-anonymous-default-export
|
|
637
|
+
var typography = {
|
|
638
|
+
...antdTypography
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
const defaultOptions = {
|
|
642
|
+
enableAnimation: false,
|
|
643
|
+
zIndexBase: 1000,
|
|
644
|
+
useNewBorderColors: false
|
|
645
|
+
};
|
|
646
|
+
// Function to get variables for a certain theme.
|
|
647
|
+
// End users should use useDesignSystemTheme instead.
|
|
648
|
+
const getTheme = memoize(getThemeImpl, function(isDarkMode) {
|
|
649
|
+
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultOptions;
|
|
650
|
+
return `${isDarkMode}-${options.enableAnimation}-${options.zIndexBase}-${options.useNewBorderColors}`;
|
|
651
|
+
});
|
|
652
|
+
function getThemeImpl(isDarkMode) {
|
|
653
|
+
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultOptions;
|
|
654
|
+
return {
|
|
655
|
+
colors: {
|
|
656
|
+
...getColors(isDarkMode),
|
|
657
|
+
...options.useNewBorderColors && {
|
|
658
|
+
border: isDarkMode ? primitiveColors.grey700 : primitiveColors.grey100
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
gradients: getGradients(isDarkMode),
|
|
662
|
+
spacing,
|
|
663
|
+
general: {
|
|
664
|
+
...antdGeneralVariables,
|
|
665
|
+
...getShadowVariables(isDarkMode)
|
|
666
|
+
},
|
|
667
|
+
shadows: getShadows(isDarkMode),
|
|
668
|
+
typography,
|
|
669
|
+
legacyBorders: getLegacyBorders(),
|
|
670
|
+
// TODO: Update to use `getBorders`
|
|
671
|
+
borders: getBorders(),
|
|
672
|
+
responsive,
|
|
673
|
+
isDarkMode,
|
|
674
|
+
options,
|
|
675
|
+
DU_BOIS_INTERNAL_ONLY: {
|
|
676
|
+
colors: getProtectedSemanticColors(isDarkMode)
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function getClassNamePrefix(theme) {
|
|
682
|
+
const antdThemeName = theme.isDarkMode ? 'dark' : 'light';
|
|
683
|
+
return `${theme.general.classnamePrefix}-${antdThemeName}`;
|
|
684
|
+
}
|
|
685
|
+
function getPrefixedClassNameFromTheme(theme, className) {
|
|
686
|
+
return [
|
|
687
|
+
getClassNamePrefix(theme),
|
|
688
|
+
className
|
|
689
|
+
].filter(Boolean).join('-');
|
|
690
|
+
}
|
|
691
|
+
function useDesignSystemTheme() {
|
|
692
|
+
const emotionTheme = useTheme();
|
|
693
|
+
const { useNewBorderColors } = useDesignSystemSafexFlags();
|
|
694
|
+
// Graceful fallback to default theme in case a test or developer forgot context.
|
|
695
|
+
const theme = emotionTheme && emotionTheme.general ? emotionTheme : getTheme(false, {
|
|
696
|
+
useNewBorderColors,
|
|
697
|
+
// Default values, safe to remove once the border colors flag is retired
|
|
698
|
+
zIndexBase: 1000,
|
|
699
|
+
enableAnimation: false
|
|
700
|
+
});
|
|
701
|
+
return {
|
|
702
|
+
theme: theme,
|
|
703
|
+
classNamePrefix: getClassNamePrefix(theme),
|
|
704
|
+
getPrefixedClassName: (className)=>getPrefixedClassNameFromTheme(theme, className)
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
// This is a simple typed HOC wrapper around the useDesignSystemTheme hook, for use in older react components.
|
|
708
|
+
function WithDesignSystemThemeHoc(Component) {
|
|
709
|
+
return function WrappedWithDesignSystemTheme(props) {
|
|
710
|
+
const themeValues = useDesignSystemTheme();
|
|
711
|
+
return /*#__PURE__*/ jsx(Component, {
|
|
712
|
+
...props,
|
|
713
|
+
designSystemThemeApi: themeValues
|
|
714
|
+
});
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const DuboisContextDefaults = {
|
|
719
|
+
enableAnimation: false,
|
|
720
|
+
// Prefer to use useDesignSystemTheme.getPrefixedClassName instead
|
|
721
|
+
getPrefixCls: (suffix)=>suffix ? `du-bois-${suffix}` : 'du-bois',
|
|
722
|
+
flags: {}
|
|
723
|
+
};
|
|
724
|
+
const DesignSystemThemeContext = /*#__PURE__*/ createContext({
|
|
725
|
+
isDarkMode: false
|
|
726
|
+
});
|
|
727
|
+
const DesignSystemContext = /*#__PURE__*/ createContext(DuboisContextDefaults);
|
|
728
|
+
const DU_BOIS_ENABLE_ANIMATION_CLASSNAME = 'du-bois-enable-animation';
|
|
729
|
+
function getAnimationCss(enableAnimation) {
|
|
730
|
+
const disableAnimationCss = {
|
|
731
|
+
animationDuration: '0s !important',
|
|
732
|
+
transition: 'none !important'
|
|
733
|
+
};
|
|
734
|
+
return enableAnimation ? {} : {
|
|
735
|
+
// Apply to the current element
|
|
736
|
+
...disableAnimationCss,
|
|
737
|
+
'&::before': disableAnimationCss,
|
|
738
|
+
'&::after': disableAnimationCss,
|
|
739
|
+
// Also apply to all child elements with a class that starts with our prefix
|
|
740
|
+
[`[class*=du-bois]:not(.${DU_BOIS_ENABLE_ANIMATION_CLASSNAME}, .${DU_BOIS_ENABLE_ANIMATION_CLASSNAME} *)`]: {
|
|
741
|
+
...disableAnimationCss,
|
|
742
|
+
// Also target any pseudo-elements associated with those elements, since these can also be animated.
|
|
743
|
+
'&::before': disableAnimationCss,
|
|
744
|
+
'&::after': disableAnimationCss
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
const DesignSystemProviderPropsContext = /*#__PURE__*/ React__default.createContext(null);
|
|
749
|
+
const AntDConfigProviderPropsContext = /*#__PURE__*/ React__default.createContext(null);
|
|
750
|
+
/** Only to be accessed by SupportsDuBoisThemes, except for special exceptions like tests and storybook. Ask in #dubois first if you need to use it. */ const DesignSystemThemeProvider = (param)=>{
|
|
751
|
+
let { isDarkMode = false, children } = param;
|
|
752
|
+
return /*#__PURE__*/ jsx(DesignSystemThemeContext.Provider, {
|
|
753
|
+
value: {
|
|
754
|
+
isDarkMode
|
|
755
|
+
},
|
|
756
|
+
children: children
|
|
757
|
+
});
|
|
758
|
+
};
|
|
759
|
+
const DesignSystemProvider = (param)=>{
|
|
760
|
+
let { children, enableAnimation = false, zIndexBase = 1000, getPopupContainer, flags = {}, // Disable virtualization of legacy AntD components when running tests so that all items are rendered
|
|
761
|
+
disableLegacyAntVirtualization = process.env.NODE_ENV === 'test' ? true : undefined } = param;
|
|
762
|
+
const { isDarkMode } = useContext(DesignSystemThemeContext);
|
|
763
|
+
const { useNewBorderColors } = useDesignSystemSafexFlags();
|
|
764
|
+
const theme = useMemo(()=>getTheme(isDarkMode, {
|
|
765
|
+
enableAnimation,
|
|
766
|
+
zIndexBase,
|
|
767
|
+
useNewBorderColors
|
|
768
|
+
}), // TODO: revisit this
|
|
769
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
770
|
+
[
|
|
771
|
+
isDarkMode,
|
|
772
|
+
zIndexBase,
|
|
773
|
+
useNewBorderColors
|
|
774
|
+
]);
|
|
775
|
+
const providerPropsContext = useMemo(()=>({
|
|
776
|
+
isDarkMode,
|
|
777
|
+
enableAnimation,
|
|
778
|
+
zIndexBase,
|
|
779
|
+
getPopupContainer,
|
|
780
|
+
flags
|
|
781
|
+
}), [
|
|
782
|
+
isDarkMode,
|
|
783
|
+
enableAnimation,
|
|
784
|
+
zIndexBase,
|
|
785
|
+
getPopupContainer,
|
|
786
|
+
flags
|
|
787
|
+
]);
|
|
788
|
+
const classNamePrefix = getClassNamePrefix(theme);
|
|
789
|
+
const value = useMemo(()=>{
|
|
790
|
+
return {
|
|
791
|
+
enableAnimation,
|
|
792
|
+
isDarkMode,
|
|
793
|
+
getPrefixCls: (suffix)=>getPrefixedClassNameFromTheme(theme, suffix),
|
|
794
|
+
getPopupContainer,
|
|
795
|
+
flags
|
|
796
|
+
};
|
|
797
|
+
}, [
|
|
798
|
+
enableAnimation,
|
|
799
|
+
theme,
|
|
800
|
+
isDarkMode,
|
|
801
|
+
getPopupContainer,
|
|
802
|
+
flags
|
|
803
|
+
]);
|
|
804
|
+
useEffect(()=>{
|
|
805
|
+
return ()=>{
|
|
806
|
+
// when the design system context is unmounted, make sure the notification cache is also cleaned up
|
|
807
|
+
notification.destroy();
|
|
808
|
+
};
|
|
809
|
+
}, []);
|
|
810
|
+
return /*#__PURE__*/ jsx(DesignSystemProviderPropsContext.Provider, {
|
|
811
|
+
value: providerPropsContext,
|
|
812
|
+
children: /*#__PURE__*/ jsx(ThemeProvider, {
|
|
813
|
+
theme: theme,
|
|
814
|
+
children: /*#__PURE__*/ jsx(AntDConfigProviderPropsContext.Provider, {
|
|
815
|
+
value: {
|
|
816
|
+
prefixCls: classNamePrefix,
|
|
817
|
+
getPopupContainer,
|
|
818
|
+
virtual: !disableLegacyAntVirtualization
|
|
819
|
+
},
|
|
820
|
+
children: /*#__PURE__*/ jsx(TooltipProvider, {
|
|
821
|
+
children: /*#__PURE__*/ jsx(DesignSystemContext.Provider, {
|
|
822
|
+
value: value,
|
|
823
|
+
children: children
|
|
824
|
+
})
|
|
825
|
+
})
|
|
826
|
+
})
|
|
827
|
+
})
|
|
828
|
+
});
|
|
829
|
+
};
|
|
830
|
+
const ApplyDesignSystemContextOverrides = (param)=>{
|
|
831
|
+
let { enableAnimation, zIndexBase, getPopupContainer, flags, children } = param;
|
|
832
|
+
const parentDesignSystemProviderProps = useContext(DesignSystemProviderPropsContext);
|
|
833
|
+
if (parentDesignSystemProviderProps === null) {
|
|
834
|
+
throw new Error(`ApplyDesignSystemContextOverrides cannot be used standalone - DesignSystemProvider must exist in the React context`);
|
|
835
|
+
}
|
|
836
|
+
const newProps = useMemo(()=>({
|
|
837
|
+
...parentDesignSystemProviderProps,
|
|
838
|
+
enableAnimation: enableAnimation ?? parentDesignSystemProviderProps.enableAnimation,
|
|
839
|
+
zIndexBase: zIndexBase ?? parentDesignSystemProviderProps.zIndexBase,
|
|
840
|
+
getPopupContainer: getPopupContainer ?? parentDesignSystemProviderProps.getPopupContainer,
|
|
841
|
+
flags: {
|
|
842
|
+
...parentDesignSystemProviderProps.flags,
|
|
843
|
+
...flags
|
|
844
|
+
}
|
|
845
|
+
}), [
|
|
846
|
+
parentDesignSystemProviderProps,
|
|
847
|
+
enableAnimation,
|
|
848
|
+
zIndexBase,
|
|
849
|
+
getPopupContainer,
|
|
850
|
+
flags
|
|
851
|
+
]);
|
|
852
|
+
return /*#__PURE__*/ jsx(DesignSystemProvider, {
|
|
853
|
+
...newProps,
|
|
854
|
+
children: children
|
|
855
|
+
});
|
|
856
|
+
};
|
|
857
|
+
// This is a more-specific version of `ApplyDesignSystemContextOverrides` that only allows overriding the flags.
|
|
858
|
+
const ApplyDesignSystemFlags = (param)=>{
|
|
859
|
+
let { flags, children } = param;
|
|
860
|
+
const parentDesignSystemProviderProps = useContext(DesignSystemProviderPropsContext);
|
|
861
|
+
if (parentDesignSystemProviderProps === null) {
|
|
862
|
+
throw new Error(`ApplyDesignSystemFlags cannot be used standalone - DesignSystemProvider must exist in the React context`);
|
|
863
|
+
}
|
|
864
|
+
const newProps = useMemo(()=>({
|
|
865
|
+
...parentDesignSystemProviderProps,
|
|
866
|
+
flags: {
|
|
867
|
+
...parentDesignSystemProviderProps.flags,
|
|
868
|
+
...flags
|
|
869
|
+
}
|
|
870
|
+
}), [
|
|
871
|
+
parentDesignSystemProviderProps,
|
|
872
|
+
flags
|
|
873
|
+
]);
|
|
874
|
+
return /*#__PURE__*/ jsx(DesignSystemProvider, {
|
|
875
|
+
...newProps,
|
|
876
|
+
children: children
|
|
877
|
+
});
|
|
878
|
+
};
|
|
879
|
+
const DesignSystemAntDConfigProvider = (param)=>{
|
|
880
|
+
let { children } = param;
|
|
881
|
+
const antdContext = useAntDConfigProviderContext();
|
|
882
|
+
return /*#__PURE__*/ jsx(ConfigProvider, {
|
|
883
|
+
...antdContext,
|
|
884
|
+
children: children
|
|
885
|
+
});
|
|
886
|
+
};
|
|
887
|
+
const useAntDConfigProviderContext = ()=>{
|
|
888
|
+
return useContext(AntDConfigProviderPropsContext) ?? {
|
|
889
|
+
prefixCls: undefined
|
|
890
|
+
};
|
|
891
|
+
};
|
|
892
|
+
/**
|
|
893
|
+
* When using AntD components inside Design System wrapper components (e.g. Modal, Collapse etc),
|
|
894
|
+
* we don't want Design System's prefix class to override them.
|
|
895
|
+
*
|
|
896
|
+
* Since all Design System's components have are wrapped with DesignSystemAntDConfigProvider,
|
|
897
|
+
* this won't affect their own prefixCls, but just allow nested antd components to keep their ant prefix.
|
|
898
|
+
*/ const RestoreAntDDefaultClsPrefix = (param)=>{
|
|
899
|
+
let { children } = param;
|
|
900
|
+
return /*#__PURE__*/ jsx(ConfigProvider, {
|
|
901
|
+
prefixCls: "ant",
|
|
902
|
+
children: children
|
|
903
|
+
});
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
function useDesignSystemContext() {
|
|
907
|
+
return useContext(DesignSystemContext);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Provides access to http://go/safex flags from the frontend. Note that this is a temporary
|
|
912
|
+
* workaround until direct `safex` imports are available.
|
|
913
|
+
* @param flag The name of the flag to check
|
|
914
|
+
* @param defaultValue The default value to return if the flag is not set
|
|
915
|
+
* @returns
|
|
916
|
+
*/ const safex = (flag, defaultValue)=>{
|
|
917
|
+
// Catching errors here, because we don't have type-safety to ensure
|
|
918
|
+
// that `__debug__safex`'s API hasn't changed.
|
|
919
|
+
try {
|
|
920
|
+
const globalSafex = window.__debug__safex;
|
|
921
|
+
return globalSafex ? globalSafex(flag, defaultValue) : defaultValue;
|
|
922
|
+
} catch (e) {
|
|
923
|
+
return defaultValue;
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
const getDebugOutlineStyles = (theme)=>/*#__PURE__*/ css({
|
|
928
|
+
outline: `1px dashed ${theme.isDarkMode ? theme.colors.lime : theme.colors.lime}`,
|
|
929
|
+
outlineOffset: '2px'
|
|
930
|
+
});
|
|
931
|
+
function addDebugOutlineIfEnabled() {
|
|
932
|
+
return safex('databricks.fe.designsystem.showDebugOutline', false) ? {
|
|
933
|
+
'data-dubois-show-outline': true
|
|
934
|
+
} : {};
|
|
935
|
+
}
|
|
936
|
+
function addDebugOutlineStylesIfEnabled(theme) {
|
|
937
|
+
return safex('databricks.fe.designsystem.showDebugOutline', false) ? getDebugOutlineStyles(theme) : {};
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
const uniqueId = ()=>new Date().getTime() + Array(16).fill('').map(()=>parseInt((Math.random() * 10).toString())).join('');
|
|
941
|
+
function useUniqueId() {
|
|
942
|
+
let prefix = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '';
|
|
943
|
+
return useState(()=>`${prefix}-${uniqueId()}`)[0];
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
const getIconVariantStyles = (theme, color)=>{
|
|
947
|
+
switch(color){
|
|
948
|
+
case 'success':
|
|
949
|
+
return {
|
|
950
|
+
color: `${theme.colors.textValidationSuccess} !important`
|
|
951
|
+
};
|
|
952
|
+
case 'warning':
|
|
953
|
+
return {
|
|
954
|
+
color: `${theme.colors.textValidationWarning} !important`
|
|
955
|
+
};
|
|
956
|
+
case 'danger':
|
|
957
|
+
return {
|
|
958
|
+
color: `${theme.colors.textValidationDanger} !important`
|
|
959
|
+
};
|
|
960
|
+
case 'ai':
|
|
961
|
+
return {
|
|
962
|
+
'svg *': {
|
|
963
|
+
fill: 'var(--ai-icon-gradient)'
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
default:
|
|
967
|
+
return color ? {
|
|
968
|
+
color: `${color} !important`
|
|
969
|
+
} : {};
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
const Icon = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
973
|
+
const { component: Component, dangerouslySetAntdProps, color, style, ...otherProps } = props;
|
|
974
|
+
const { theme } = useDesignSystemTheme();
|
|
975
|
+
const linearGradientId = useUniqueId('ai-linear-gradient');
|
|
976
|
+
const useSmallIcons = safex('databricks.fe.designsystem.useSmallIcons', false);
|
|
977
|
+
const MemoizedComponent = useMemo(()=>Component ? (param)=>{
|
|
978
|
+
let { fill, ...iconProps } = param;
|
|
979
|
+
return(// We don't rely on top-level fills for our colors. Fills are specified
|
|
980
|
+
// with "currentColor" on children of the top-most svg.
|
|
981
|
+
/*#__PURE__*/ jsxs(Fragment, {
|
|
982
|
+
children: [
|
|
983
|
+
/*#__PURE__*/ jsx(Component, {
|
|
984
|
+
fill: "none",
|
|
985
|
+
...iconProps,
|
|
986
|
+
style: {
|
|
987
|
+
...color === 'ai' ? {
|
|
988
|
+
['--ai-icon-gradient']: `url(#${linearGradientId})`,
|
|
989
|
+
...iconProps.style
|
|
990
|
+
} : iconProps.style,
|
|
991
|
+
...useSmallIcons ? {
|
|
992
|
+
padding: '1px'
|
|
993
|
+
} : {}
|
|
994
|
+
}
|
|
995
|
+
}),
|
|
996
|
+
color === 'ai' && /*#__PURE__*/ jsx("svg", {
|
|
997
|
+
width: "0",
|
|
998
|
+
height: "0",
|
|
999
|
+
viewBox: "0 0 0 0",
|
|
1000
|
+
css: visuallyHidden,
|
|
1001
|
+
children: /*#__PURE__*/ jsx("defs", {
|
|
1002
|
+
children: /*#__PURE__*/ jsxs("linearGradient", {
|
|
1003
|
+
id: linearGradientId,
|
|
1004
|
+
x1: "0%",
|
|
1005
|
+
y1: "0%",
|
|
1006
|
+
x2: "100%",
|
|
1007
|
+
y2: "100%",
|
|
1008
|
+
children: [
|
|
1009
|
+
/*#__PURE__*/ jsx("stop", {
|
|
1010
|
+
offset: "20.5%",
|
|
1011
|
+
stopColor: theme.colors.branded.ai.gradientStart
|
|
1012
|
+
}),
|
|
1013
|
+
/*#__PURE__*/ jsx("stop", {
|
|
1014
|
+
offset: "46.91%",
|
|
1015
|
+
stopColor: theme.colors.branded.ai.gradientMid
|
|
1016
|
+
}),
|
|
1017
|
+
/*#__PURE__*/ jsx("stop", {
|
|
1018
|
+
offset: "79.5%",
|
|
1019
|
+
stopColor: theme.colors.branded.ai.gradientEnd
|
|
1020
|
+
})
|
|
1021
|
+
]
|
|
1022
|
+
})
|
|
1023
|
+
})
|
|
1024
|
+
})
|
|
1025
|
+
]
|
|
1026
|
+
}));
|
|
1027
|
+
} : undefined, [
|
|
1028
|
+
Component,
|
|
1029
|
+
color,
|
|
1030
|
+
linearGradientId,
|
|
1031
|
+
theme,
|
|
1032
|
+
useSmallIcons
|
|
1033
|
+
]);
|
|
1034
|
+
return /*#__PURE__*/ jsx(DesignSystemAntDConfigProvider, {
|
|
1035
|
+
children: /*#__PURE__*/ jsx(AntDIcon, {
|
|
1036
|
+
...addDebugOutlineIfEnabled(),
|
|
1037
|
+
ref: forwardedRef,
|
|
1038
|
+
"aria-hidden": "true",
|
|
1039
|
+
css: {
|
|
1040
|
+
fontSize: theme.general.iconFontSize,
|
|
1041
|
+
...getIconVariantStyles(theme, color)
|
|
1042
|
+
},
|
|
1043
|
+
component: MemoizedComponent,
|
|
1044
|
+
style: {
|
|
1045
|
+
...style
|
|
1046
|
+
},
|
|
1047
|
+
...otherProps,
|
|
1048
|
+
...dangerouslySetAntdProps
|
|
1049
|
+
})
|
|
1050
|
+
});
|
|
1051
|
+
});
|
|
1052
|
+
|
|
1053
|
+
function SvgChevronLeftIcon(props) {
|
|
1054
|
+
return /*#__PURE__*/ jsx("svg", {
|
|
1055
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1056
|
+
width: "1em",
|
|
1057
|
+
height: "1em",
|
|
1058
|
+
fill: "none",
|
|
1059
|
+
viewBox: "0 0 16 16",
|
|
1060
|
+
...props,
|
|
1061
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
1062
|
+
fill: "currentColor",
|
|
1063
|
+
fillRule: "evenodd",
|
|
1064
|
+
d: "M7.083 8 10 10.947 8.958 12 5 8l3.958-4L10 5.053z",
|
|
1065
|
+
clipRule: "evenodd"
|
|
1066
|
+
})
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
const ChevronLeftIcon = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
1070
|
+
return /*#__PURE__*/ jsx(Icon, {
|
|
1071
|
+
ref: forwardedRef,
|
|
1072
|
+
...props,
|
|
1073
|
+
component: SvgChevronLeftIcon
|
|
1074
|
+
});
|
|
1075
|
+
});
|
|
1076
|
+
ChevronLeftIcon.displayName = 'ChevronLeftIcon';
|
|
1077
|
+
|
|
1078
|
+
function SvgChevronRightIcon(props) {
|
|
1079
|
+
return /*#__PURE__*/ jsx("svg", {
|
|
1080
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1081
|
+
width: "1em",
|
|
1082
|
+
height: "1em",
|
|
1083
|
+
fill: "none",
|
|
1084
|
+
viewBox: "0 0 16 16",
|
|
1085
|
+
...props,
|
|
1086
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
1087
|
+
fill: "currentColor",
|
|
1088
|
+
fillRule: "evenodd",
|
|
1089
|
+
d: "M8.917 8 6 5.053 7.042 4 11 8l-3.958 4L6 10.947z",
|
|
1090
|
+
clipRule: "evenodd"
|
|
1091
|
+
})
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
const ChevronRightIcon = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
1095
|
+
return /*#__PURE__*/ jsx(Icon, {
|
|
1096
|
+
ref: forwardedRef,
|
|
1097
|
+
...props,
|
|
1098
|
+
component: SvgChevronRightIcon
|
|
1099
|
+
});
|
|
1100
|
+
});
|
|
1101
|
+
ChevronRightIcon.displayName = 'ChevronRightIcon';
|
|
1102
|
+
|
|
1103
|
+
function SvgCloseIcon(props) {
|
|
1104
|
+
return /*#__PURE__*/ jsx("svg", {
|
|
1105
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1106
|
+
width: "1em",
|
|
1107
|
+
height: "1em",
|
|
1108
|
+
fill: "none",
|
|
1109
|
+
viewBox: "0 0 16 16",
|
|
1110
|
+
...props,
|
|
1111
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
1112
|
+
fill: "currentColor",
|
|
1113
|
+
fillRule: "evenodd",
|
|
1114
|
+
d: "M6.97 8.03 2 3.06 3.06 2l4.97 4.97L13 2l1.06 1.06-4.969 4.97 4.97 4.97L13 14.06 8.03 9.092l-4.97 4.97L2 13z",
|
|
1115
|
+
clipRule: "evenodd"
|
|
1116
|
+
})
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
const CloseIcon = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
1120
|
+
return /*#__PURE__*/ jsx(Icon, {
|
|
1121
|
+
ref: forwardedRef,
|
|
1122
|
+
...props,
|
|
1123
|
+
component: SvgCloseIcon
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
1126
|
+
CloseIcon.displayName = 'CloseIcon';
|
|
1127
|
+
|
|
1128
|
+
function SvgDangerIcon(props) {
|
|
1129
|
+
return /*#__PURE__*/ jsxs("svg", {
|
|
1130
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1131
|
+
width: "1em",
|
|
1132
|
+
height: "1em",
|
|
1133
|
+
fill: "none",
|
|
1134
|
+
viewBox: "0 0 16 16",
|
|
1135
|
+
...props,
|
|
1136
|
+
children: [
|
|
1137
|
+
/*#__PURE__*/ jsx("path", {
|
|
1138
|
+
fill: "currentColor",
|
|
1139
|
+
d: "M7.248 10.748a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0M8.748 4.998v4h-1.5v-4z"
|
|
1140
|
+
}),
|
|
1141
|
+
/*#__PURE__*/ jsx("path", {
|
|
1142
|
+
fill: "currentColor",
|
|
1143
|
+
fillRule: "evenodd",
|
|
1144
|
+
d: "m11.533 15.776 4.243-4.243a.75.75 0 0 0 .22-.53v-6.01a.75.75 0 0 0-.22-.53L11.533.22a.75.75 0 0 0-.53-.22h-6.01a.75.75 0 0 0-.53.22L.22 4.462a.75.75 0 0 0-.22.53v6.011c0 .199.079.39.22.53l4.242 4.243c.141.14.332.22.53.22h6.011a.75.75 0 0 0 .53-.22m2.963-10.473v5.39l-3.804 3.803H5.303L1.5 10.692V5.303L5.303 1.5h5.39z",
|
|
1145
|
+
clipRule: "evenodd"
|
|
1146
|
+
})
|
|
1147
|
+
]
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
const DangerIcon = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
1151
|
+
return /*#__PURE__*/ jsx(Icon, {
|
|
1152
|
+
ref: forwardedRef,
|
|
1153
|
+
...props,
|
|
1154
|
+
component: SvgDangerIcon
|
|
1155
|
+
});
|
|
1156
|
+
});
|
|
1157
|
+
DangerIcon.displayName = 'DangerIcon';
|
|
1158
|
+
|
|
1159
|
+
function SvgLoadingIcon(props) {
|
|
1160
|
+
return /*#__PURE__*/ jsx("svg", {
|
|
1161
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1162
|
+
width: "1em",
|
|
1163
|
+
height: "1em",
|
|
1164
|
+
fill: "none",
|
|
1165
|
+
viewBox: "0 0 24 24",
|
|
1166
|
+
...props,
|
|
1167
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
1168
|
+
fill: "currentColor",
|
|
1169
|
+
fillRule: "evenodd",
|
|
1170
|
+
d: "M23.212 12a.79.79 0 0 1-.789-.788 9.6 9.6 0 0 0-.757-3.751 9.66 9.66 0 0 0-5.129-5.129 9.6 9.6 0 0 0-3.749-.755.788.788 0 0 1 0-1.577c1.513 0 2.983.296 4.365.882a11.1 11.1 0 0 1 3.562 2.403 11.157 11.157 0 0 1 3.283 7.927.785.785 0 0 1-.786.788",
|
|
1171
|
+
clipRule: "evenodd"
|
|
1172
|
+
})
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
const LoadingIcon = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
1176
|
+
return /*#__PURE__*/ jsx(Icon, {
|
|
1177
|
+
ref: forwardedRef,
|
|
1178
|
+
...props,
|
|
1179
|
+
component: SvgLoadingIcon
|
|
1180
|
+
});
|
|
1181
|
+
});
|
|
1182
|
+
LoadingIcon.displayName = 'LoadingIcon';
|
|
1183
|
+
|
|
1184
|
+
function SvgNewWindowIcon(props) {
|
|
1185
|
+
return /*#__PURE__*/ jsxs("svg", {
|
|
1186
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1187
|
+
width: "1em",
|
|
1188
|
+
height: "1em",
|
|
1189
|
+
fill: "none",
|
|
1190
|
+
viewBox: "0 0 16 16",
|
|
1191
|
+
...props,
|
|
1192
|
+
children: [
|
|
1193
|
+
/*#__PURE__*/ jsx("path", {
|
|
1194
|
+
fill: "currentColor",
|
|
1195
|
+
d: "M10 1h5v5h-1.5V3.56L8.53 8.53 7.47 7.47l4.97-4.97H10z"
|
|
1196
|
+
}),
|
|
1197
|
+
/*#__PURE__*/ jsx("path", {
|
|
1198
|
+
fill: "currentColor",
|
|
1199
|
+
d: "M1 2.75A.75.75 0 0 1 1.75 2H8v1.5H2.5v10h10V8H14v6.25a.75.75 0 0 1-.75.75H1.75a.75.75 0 0 1-.75-.75z"
|
|
1200
|
+
})
|
|
1201
|
+
]
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
const NewWindowIcon = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
1205
|
+
return /*#__PURE__*/ jsx(Icon, {
|
|
1206
|
+
ref: forwardedRef,
|
|
1207
|
+
...props,
|
|
1208
|
+
component: SvgNewWindowIcon
|
|
1209
|
+
});
|
|
1210
|
+
});
|
|
1211
|
+
NewWindowIcon.displayName = 'NewWindowIcon';
|
|
1212
|
+
|
|
1213
|
+
function SvgWarningIcon(props) {
|
|
1214
|
+
return /*#__PURE__*/ jsxs("svg", {
|
|
1215
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1216
|
+
width: "1em",
|
|
1217
|
+
height: "1em",
|
|
1218
|
+
fill: "none",
|
|
1219
|
+
viewBox: "0 0 16 16",
|
|
1220
|
+
...props,
|
|
1221
|
+
children: [
|
|
1222
|
+
/*#__PURE__*/ jsx("path", {
|
|
1223
|
+
fill: "currentColor",
|
|
1224
|
+
d: "M7.25 10V6.5h1.5V10zM8 12.5A.75.75 0 1 0 8 11a.75.75 0 0 0 0 1.5"
|
|
1225
|
+
}),
|
|
1226
|
+
/*#__PURE__*/ jsx("path", {
|
|
1227
|
+
fill: "currentColor",
|
|
1228
|
+
fillRule: "evenodd",
|
|
1229
|
+
d: "M8 1a.75.75 0 0 1 .649.374l7.25 12.5A.75.75 0 0 1 15.25 15H.75a.75.75 0 0 1-.649-1.126l7.25-12.5A.75.75 0 0 1 8 1m0 2.245L2.052 13.5h11.896z",
|
|
1230
|
+
clipRule: "evenodd"
|
|
1231
|
+
})
|
|
1232
|
+
]
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
const WarningIcon = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
1236
|
+
return /*#__PURE__*/ jsx(Icon, {
|
|
1237
|
+
ref: forwardedRef,
|
|
1238
|
+
...props,
|
|
1239
|
+
component: SvgWarningIcon
|
|
1240
|
+
});
|
|
1241
|
+
});
|
|
1242
|
+
WarningIcon.displayName = 'WarningIcon';
|
|
1243
|
+
|
|
1244
|
+
// Use Symbol to correctly handled null/undefined as stable values
|
|
1245
|
+
const NOT_INITIALIZED = Symbol('NOT_INITIALIZED');
|
|
1246
|
+
/**
|
|
1247
|
+
* Use to keep a stable value on the first mount of a component
|
|
1248
|
+
* that cannot change.
|
|
1249
|
+
*/ function useStable(valueCallback) {
|
|
1250
|
+
const ref = useRef(NOT_INITIALIZED);
|
|
1251
|
+
if (ref.current === NOT_INITIALIZED) {
|
|
1252
|
+
const val = valueCallback();
|
|
1253
|
+
ref.current = val;
|
|
1254
|
+
return val;
|
|
1255
|
+
}
|
|
1256
|
+
return ref.current;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
let sequentialCounter = 0;
|
|
1260
|
+
function useStableUid() {
|
|
1261
|
+
return useStable(()=>sequentialCounter++);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
const LoadingStateContext = /*#__PURE__*/ createContext(null);
|
|
1265
|
+
/**
|
|
1266
|
+
* Indicates that the containing component is in a "loading" state, i.e. that the UI
|
|
1267
|
+
* displayed to the user is semantically equivalent to them seeing a spinner or a
|
|
1268
|
+
* loading indicator. This means that the UI is not in its final settled state yet.
|
|
1269
|
+
*
|
|
1270
|
+
* All components that are in a "loading" state should render a `<LoadingState>`
|
|
1271
|
+
* component, preferrably with an appropriate description.
|
|
1272
|
+
*
|
|
1273
|
+
* By itself, `<LoadingState>` doesn't do anything, but if used within `LoadingStateContext`,
|
|
1274
|
+
* it will call the provided `startLoading()`/`endLoading()` hooks when the component
|
|
1275
|
+
* is mounted/unmounted, which can be used to integrate existing latency instrumentation.
|
|
1276
|
+
*/ const LoadingState = (param)=>{
|
|
1277
|
+
let { description = 'Generic UI loading state' } = param;
|
|
1278
|
+
const uid = useStableUid();
|
|
1279
|
+
const loadingStateContext = useContext(LoadingStateContext);
|
|
1280
|
+
useLayoutEffect(()=>{
|
|
1281
|
+
// mount
|
|
1282
|
+
if (loadingStateContext) {
|
|
1283
|
+
loadingStateContext.startLoading(uid, description);
|
|
1284
|
+
}
|
|
1285
|
+
return ()=>{
|
|
1286
|
+
// unmount
|
|
1287
|
+
if (loadingStateContext) {
|
|
1288
|
+
loadingStateContext.endLoading(uid);
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1291
|
+
}, [
|
|
1292
|
+
uid,
|
|
1293
|
+
description,
|
|
1294
|
+
loadingStateContext
|
|
1295
|
+
]);
|
|
1296
|
+
return null;
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
const rotate = /*#__PURE__*/ keyframes({
|
|
1300
|
+
'0%': {
|
|
1301
|
+
transform: 'rotate(0deg) translate3d(0, 0, 0)'
|
|
1302
|
+
},
|
|
1303
|
+
'100%': {
|
|
1304
|
+
transform: 'rotate(360deg) translate3d(0, 0, 0)'
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
const cssSpinner = function(theme) {
|
|
1308
|
+
let frameRate = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 60, delay = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, animationDuration = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1, inheritColor = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
|
|
1309
|
+
const styles = {
|
|
1310
|
+
animation: `${rotate} ${animationDuration}s steps(${frameRate}, end) infinite`,
|
|
1311
|
+
...inheritColor ? {
|
|
1312
|
+
color: 'inherit'
|
|
1313
|
+
} : {
|
|
1314
|
+
color: theme.colors.textSecondary
|
|
1315
|
+
},
|
|
1316
|
+
animationDelay: `${delay}s`
|
|
1317
|
+
};
|
|
1318
|
+
return /*#__PURE__*/ css(importantify(styles));
|
|
1319
|
+
};
|
|
1320
|
+
const Spinner = (param)=>{
|
|
1321
|
+
let { frameRate, size = 'default', delay, className: propClass, label, animationDuration, inheritColor, loading = true, loadingDescription = 'Spinner', ...props } = param;
|
|
1322
|
+
const { classNamePrefix, theme } = useDesignSystemTheme();
|
|
1323
|
+
// We use Antd classes to keep styling unchanged
|
|
1324
|
+
// TODO(FEINF-1407): We want to move away from Antd classes and use Emotion for styling in the future
|
|
1325
|
+
const sizeSuffix = size === 'small' ? '-sm' : size === 'large' ? '-lg' : '';
|
|
1326
|
+
const sizeClass = sizeSuffix ? `${classNamePrefix}-spin${sizeSuffix}` : '';
|
|
1327
|
+
const wrapperClass = `${propClass || ''} ${classNamePrefix}-spin ${sizeClass} ${classNamePrefix}-spin-spinning ${DU_BOIS_ENABLE_ANIMATION_CLASSNAME}`.trim();
|
|
1328
|
+
const className = `${classNamePrefix}-spin-dot ${DU_BOIS_ENABLE_ANIMATION_CLASSNAME}`.trim();
|
|
1329
|
+
return(// className has to follow {...props}, otherwise is `css` prop is passed down it will overwrite our className
|
|
1330
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1331
|
+
...props,
|
|
1332
|
+
className: wrapperClass,
|
|
1333
|
+
children: [
|
|
1334
|
+
loading && /*#__PURE__*/ jsx(LoadingState, {
|
|
1335
|
+
description: loadingDescription
|
|
1336
|
+
}),
|
|
1337
|
+
/*#__PURE__*/ jsx(AccessibleContainer, {
|
|
1338
|
+
label: label,
|
|
1339
|
+
children: /*#__PURE__*/ jsx(LoadingIcon, {
|
|
1340
|
+
"aria-hidden": "false",
|
|
1341
|
+
css: cssSpinner(theme, frameRate, delay, animationDuration, inheritColor),
|
|
1342
|
+
className: className
|
|
1343
|
+
})
|
|
1344
|
+
})
|
|
1345
|
+
]
|
|
1346
|
+
}));
|
|
1347
|
+
};
|
|
1348
|
+
|
|
1349
|
+
const getDialogComboboxOptionLabelWidth = (theme, width)=>{
|
|
1350
|
+
const paddingLeft = theme.spacing.xs + theme.spacing.sm;
|
|
1351
|
+
const iconWidth = theme.spacing.md;
|
|
1352
|
+
const labelMarginLeft = theme.spacing.sm;
|
|
1353
|
+
if (typeof width === 'string') {
|
|
1354
|
+
return `calc(${width} - ${paddingLeft + iconWidth + labelMarginLeft}px)`;
|
|
1355
|
+
}
|
|
1356
|
+
return width - paddingLeft + iconWidth + labelMarginLeft;
|
|
1357
|
+
};
|
|
1358
|
+
function isOptionDisabled(option) {
|
|
1359
|
+
return option.hasAttribute('disabled') && option.getAttribute('disabled') !== 'false';
|
|
1360
|
+
}
|
|
1361
|
+
function highlightFirstNonDisabledOption(firstOptionItem) {
|
|
1362
|
+
let startAt = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'start', previousSelection = arguments.length > 2 ? arguments[2] : void 0;
|
|
1363
|
+
if (isOptionDisabled(firstOptionItem)) {
|
|
1364
|
+
const firstHighlightableOption = findClosestOptionSibling(firstOptionItem, startAt === 'end' ? 'previous' : 'next');
|
|
1365
|
+
if (firstHighlightableOption) {
|
|
1366
|
+
highlightOption(firstHighlightableOption, previousSelection);
|
|
1367
|
+
}
|
|
1368
|
+
} else {
|
|
1369
|
+
highlightOption(firstOptionItem, previousSelection);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
function findClosestOptionSibling(element, direction) {
|
|
1373
|
+
const nextSibling = direction === 'previous' ? element.previousElementSibling : element.nextElementSibling;
|
|
1374
|
+
if (nextSibling?.getAttribute('role') === 'option') {
|
|
1375
|
+
if (isOptionDisabled(nextSibling)) {
|
|
1376
|
+
return findClosestOptionSibling(nextSibling, direction);
|
|
1377
|
+
}
|
|
1378
|
+
return nextSibling;
|
|
1379
|
+
} else if (nextSibling) {
|
|
1380
|
+
let nextOptionSibling = nextSibling;
|
|
1381
|
+
while(nextOptionSibling && (nextOptionSibling.getAttribute('role') !== 'option' || isOptionDisabled(nextOptionSibling))){
|
|
1382
|
+
nextOptionSibling = direction === 'previous' ? nextOptionSibling.previousElementSibling : nextOptionSibling.nextElementSibling;
|
|
1383
|
+
}
|
|
1384
|
+
return nextOptionSibling;
|
|
1385
|
+
}
|
|
1386
|
+
return null;
|
|
1387
|
+
}
|
|
1388
|
+
const resetAllHighlightedOptions = (currentSelection)=>{
|
|
1389
|
+
const options = getContentOptions(currentSelection);
|
|
1390
|
+
options?.forEach((option)=>{
|
|
1391
|
+
option.setAttribute('tabIndex', '-1');
|
|
1392
|
+
option.setAttribute('data-highlighted', 'false');
|
|
1393
|
+
});
|
|
1394
|
+
};
|
|
1395
|
+
const highlightOption = function(currentSelection, prevSelection) {
|
|
1396
|
+
let focus = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
1397
|
+
if (prevSelection) {
|
|
1398
|
+
prevSelection.setAttribute('tabIndex', '-1');
|
|
1399
|
+
prevSelection.setAttribute('data-highlighted', 'false');
|
|
1400
|
+
}
|
|
1401
|
+
if (focus) {
|
|
1402
|
+
currentSelection.focus();
|
|
1403
|
+
}
|
|
1404
|
+
currentSelection.setAttribute('tabIndex', '0');
|
|
1405
|
+
currentSelection.setAttribute('data-highlighted', 'true');
|
|
1406
|
+
currentSelection.scrollIntoView?.({
|
|
1407
|
+
block: 'center'
|
|
1408
|
+
});
|
|
1409
|
+
};
|
|
1410
|
+
const findHighlightedOption = (options)=>{
|
|
1411
|
+
return options.find((option)=>option.getAttribute('data-highlighted') === 'true') ?? undefined;
|
|
1412
|
+
};
|
|
1413
|
+
const getContentOptions = (element)=>{
|
|
1414
|
+
const options = element.closest('[data-combobox-option-list="true"]')?.querySelectorAll('[role="option"]');
|
|
1415
|
+
return options ? Array.from(options) : undefined;
|
|
1416
|
+
};
|
|
1417
|
+
const getKeyboardNavigationFunctions = (handleSelect, param)=>{
|
|
1418
|
+
let { onKeyDown, onMouseEnter, onDefaultKeyDown, disableMouseOver, setDisableMouseOver } = param;
|
|
1419
|
+
return {
|
|
1420
|
+
onKeyDown: (e)=>{
|
|
1421
|
+
onKeyDown?.(e);
|
|
1422
|
+
switch(e.key){
|
|
1423
|
+
case 'ArrowDown':
|
|
1424
|
+
e.preventDefault();
|
|
1425
|
+
setDisableMouseOver(true);
|
|
1426
|
+
const nextSibling = findClosestOptionSibling(e.currentTarget, 'next');
|
|
1427
|
+
if (nextSibling) {
|
|
1428
|
+
highlightOption(nextSibling, e.currentTarget);
|
|
1429
|
+
} else {
|
|
1430
|
+
const firstOption = getContentOptions(e.currentTarget)?.[0];
|
|
1431
|
+
if (firstOption) {
|
|
1432
|
+
highlightFirstNonDisabledOption(firstOption, 'start', e.currentTarget);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
break;
|
|
1436
|
+
case 'ArrowUp':
|
|
1437
|
+
e.preventDefault();
|
|
1438
|
+
setDisableMouseOver(true);
|
|
1439
|
+
const previousSibling = findClosestOptionSibling(e.currentTarget, 'previous');
|
|
1440
|
+
if (previousSibling) {
|
|
1441
|
+
highlightOption(previousSibling, e.currentTarget);
|
|
1442
|
+
} else {
|
|
1443
|
+
const lastOption = getContentOptions(e.currentTarget)?.slice(-1)[0];
|
|
1444
|
+
if (lastOption) {
|
|
1445
|
+
highlightFirstNonDisabledOption(lastOption, 'end', e.currentTarget);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
break;
|
|
1449
|
+
case 'Enter':
|
|
1450
|
+
e.preventDefault();
|
|
1451
|
+
handleSelect(e);
|
|
1452
|
+
break;
|
|
1453
|
+
default:
|
|
1454
|
+
onDefaultKeyDown?.(e);
|
|
1455
|
+
break;
|
|
1456
|
+
}
|
|
1457
|
+
},
|
|
1458
|
+
onMouseMove: (e)=>{
|
|
1459
|
+
if (disableMouseOver) {
|
|
1460
|
+
setDisableMouseOver(false);
|
|
1461
|
+
}
|
|
1462
|
+
},
|
|
1463
|
+
onMouseEnter: (e)=>{
|
|
1464
|
+
if (!disableMouseOver) {
|
|
1465
|
+
onMouseEnter?.(e);
|
|
1466
|
+
resetTabIndexToFocusedElement(e.currentTarget);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
};
|
|
1470
|
+
};
|
|
1471
|
+
const resetTabIndexToFocusedElement = (elem)=>{
|
|
1472
|
+
resetAllHighlightedOptions(elem);
|
|
1473
|
+
elem.setAttribute('tabIndex', '0');
|
|
1474
|
+
elem.focus();
|
|
1475
|
+
};
|
|
1476
|
+
const dialogComboboxLookAheadKeyDown = (e, setLookAhead, lookAhead)=>{
|
|
1477
|
+
if (e.key === 'Escape' || e.key === 'Tab' || e.key === 'Enter') {
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
e.preventDefault();
|
|
1481
|
+
const siblings = Array.from(e.currentTarget.parentElement?.children ?? []);
|
|
1482
|
+
// Look for the first sibling that starts with the pressed key + recently pressed keys (lookAhead, cleared after 1.5 seconds of inactivity)
|
|
1483
|
+
const nextSiblingIndex = siblings.findIndex((sibling)=>{
|
|
1484
|
+
const siblingLabel = sibling.textContent?.toLowerCase() ?? '';
|
|
1485
|
+
return siblingLabel.startsWith(lookAhead + e.key);
|
|
1486
|
+
});
|
|
1487
|
+
if (nextSiblingIndex !== -1) {
|
|
1488
|
+
const nextSibling = siblings[nextSiblingIndex];
|
|
1489
|
+
nextSibling.focus();
|
|
1490
|
+
if (setLookAhead) {
|
|
1491
|
+
setLookAhead(lookAhead + e.key);
|
|
1492
|
+
}
|
|
1493
|
+
resetTabIndexToFocusedElement(nextSibling);
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
|
|
1497
|
+
const getComboboxContentWrapperStyles = (theme, param)=>{
|
|
1498
|
+
let { maxHeight = '100vh', maxWidth = '100vw', minHeight = 0, minWidth = 0, width, useNewShadows, useNewBorderColors } = param;
|
|
1499
|
+
return /*#__PURE__*/ css({
|
|
1500
|
+
maxHeight,
|
|
1501
|
+
maxWidth,
|
|
1502
|
+
minHeight,
|
|
1503
|
+
minWidth,
|
|
1504
|
+
...width ? {
|
|
1505
|
+
width
|
|
1506
|
+
} : {},
|
|
1507
|
+
background: theme.colors.backgroundPrimary,
|
|
1508
|
+
color: theme.colors.textPrimary,
|
|
1509
|
+
overflow: 'auto',
|
|
1510
|
+
// Making sure the content popover overlaps the remove button when opens to the right
|
|
1511
|
+
zIndex: theme.options.zIndexBase + 10,
|
|
1512
|
+
boxSizing: 'border-box',
|
|
1513
|
+
border: `1px solid ${theme.colors.border}`,
|
|
1514
|
+
boxShadow: useNewShadows ? theme.shadows.lg : theme.general.shadowLow,
|
|
1515
|
+
borderRadius: theme.borders.borderRadiusSm,
|
|
1516
|
+
colorScheme: theme.isDarkMode ? 'dark' : 'light',
|
|
1517
|
+
...getDarkModePortalStyles(theme, useNewShadows, useNewBorderColors)
|
|
1518
|
+
});
|
|
1519
|
+
};
|
|
1520
|
+
const getComboboxMenuItemPadding = (theme)=>[
|
|
1521
|
+
6,
|
|
1522
|
+
theme.spacing.sm,
|
|
1523
|
+
6,
|
|
1524
|
+
theme.spacing.sm
|
|
1525
|
+
];
|
|
1526
|
+
const getComboboxOptionItemWrapperStyles = (theme)=>{
|
|
1527
|
+
const [paddingTop, paddingRight, paddingBottom, paddingLeft] = getComboboxMenuItemPadding(theme);
|
|
1528
|
+
return /*#__PURE__*/ css(importantify({
|
|
1529
|
+
display: 'flex',
|
|
1530
|
+
flexDirection: 'row',
|
|
1531
|
+
alignItems: 'flex-start',
|
|
1532
|
+
justifyContent: 'flex-start',
|
|
1533
|
+
alignSelf: 'stretch',
|
|
1534
|
+
padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
|
|
1535
|
+
lineHeight: theme.typography.lineHeightBase,
|
|
1536
|
+
boxSizing: 'content-box',
|
|
1537
|
+
cursor: 'pointer',
|
|
1538
|
+
userSelect: 'none',
|
|
1539
|
+
'&[data-highlighted="true"]': {
|
|
1540
|
+
background: theme.colors.actionTertiaryBackgroundHover
|
|
1541
|
+
},
|
|
1542
|
+
'&:focus': {
|
|
1543
|
+
background: theme.colors.actionTertiaryBackgroundHover,
|
|
1544
|
+
outline: 'none'
|
|
1545
|
+
},
|
|
1546
|
+
'&[disabled]': {
|
|
1547
|
+
pointerEvents: 'none',
|
|
1548
|
+
color: theme.colors.actionDisabledText,
|
|
1549
|
+
background: theme.colors.backgroundPrimary
|
|
1550
|
+
}
|
|
1551
|
+
}));
|
|
1552
|
+
};
|
|
1553
|
+
const getComboboxOptionLabelStyles = (param)=>{
|
|
1554
|
+
let { theme, dangerouslyHideCheck, textOverflowMode, contentWidth, hasHintColumn, hasIcon, hasDisabledReason } = param;
|
|
1555
|
+
return /*#__PURE__*/ css({
|
|
1556
|
+
marginLeft: !dangerouslyHideCheck ? theme.spacing.sm : 0,
|
|
1557
|
+
fontSize: theme.typography.fontSizeBase,
|
|
1558
|
+
fontStyle: 'normal',
|
|
1559
|
+
fontWeight: 400,
|
|
1560
|
+
cursor: 'pointer',
|
|
1561
|
+
overflow: 'hidden',
|
|
1562
|
+
wordBreak: 'break-word',
|
|
1563
|
+
...textOverflowMode === 'ellipsis' && {
|
|
1564
|
+
textOverflow: 'ellipsis',
|
|
1565
|
+
whiteSpace: 'nowrap'
|
|
1566
|
+
},
|
|
1567
|
+
...contentWidth ? {
|
|
1568
|
+
width: getDialogComboboxOptionLabelWidth(theme, contentWidth)
|
|
1569
|
+
} : {},
|
|
1570
|
+
...hasHintColumn && {
|
|
1571
|
+
display: 'flex'
|
|
1572
|
+
},
|
|
1573
|
+
...hasIcon && hasDisabledReason && {
|
|
1574
|
+
display: 'flex'
|
|
1575
|
+
}
|
|
1576
|
+
});
|
|
1577
|
+
};
|
|
1578
|
+
const getInfoIconStyles = (theme)=>{
|
|
1579
|
+
return /*#__PURE__*/ css({
|
|
1580
|
+
paddingLeft: theme.spacing.xs,
|
|
1581
|
+
color: theme.colors.textSecondary,
|
|
1582
|
+
pointerEvents: 'all',
|
|
1583
|
+
cursor: 'pointer',
|
|
1584
|
+
verticalAlign: 'middle'
|
|
1585
|
+
});
|
|
1586
|
+
};
|
|
1587
|
+
const getCheckboxStyles = (theme, textOverflowMode)=>{
|
|
1588
|
+
return /*#__PURE__*/ css({
|
|
1589
|
+
pointerEvents: 'none',
|
|
1590
|
+
height: 'unset',
|
|
1591
|
+
width: '100%',
|
|
1592
|
+
'& > label': {
|
|
1593
|
+
display: 'flex',
|
|
1594
|
+
width: '100%',
|
|
1595
|
+
fontSize: theme.typography.fontSizeBase,
|
|
1596
|
+
fontStyle: 'normal',
|
|
1597
|
+
fontWeight: 400,
|
|
1598
|
+
cursor: 'pointer',
|
|
1599
|
+
'& > span:first-of-type': {
|
|
1600
|
+
alignSelf: 'flex-start',
|
|
1601
|
+
display: 'inline-flex',
|
|
1602
|
+
alignItems: 'center',
|
|
1603
|
+
paddingTop: theme.spacing.xs / 2
|
|
1604
|
+
},
|
|
1605
|
+
'& > span:last-of-type, & > span:last-of-type > label': {
|
|
1606
|
+
paddingRight: 0,
|
|
1607
|
+
width: '100%',
|
|
1608
|
+
overflow: 'hidden',
|
|
1609
|
+
wordBreak: 'break-word',
|
|
1610
|
+
...textOverflowMode === 'ellipsis' ? {
|
|
1611
|
+
textOverflow: 'ellipsis',
|
|
1612
|
+
whiteSpace: 'nowrap'
|
|
1613
|
+
} : {}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
};
|
|
1618
|
+
const getFooterStyles = (theme)=>{
|
|
1619
|
+
return /*#__PURE__*/ css({
|
|
1620
|
+
width: '100%',
|
|
1621
|
+
background: theme.colors.backgroundPrimary,
|
|
1622
|
+
padding: `${theme.spacing.sm}px ${theme.spacing.lg / 2}px ${theme.spacing.sm}px ${theme.spacing.lg / 2}px`,
|
|
1623
|
+
position: 'sticky',
|
|
1624
|
+
bottom: 0,
|
|
1625
|
+
boxSizing: 'border-box',
|
|
1626
|
+
'&:has(> .combobox-footer-add-button)': {
|
|
1627
|
+
padding: `${theme.spacing.sm}px 0 ${theme.spacing.sm}px 0`,
|
|
1628
|
+
'& > :not(.combobox-footer-add-button)': {
|
|
1629
|
+
marginLeft: `${theme.spacing.lg / 2}px`,
|
|
1630
|
+
marginRight: `${theme.spacing.lg / 2}px`
|
|
1631
|
+
},
|
|
1632
|
+
'& > .combobox-footer-add-button': {
|
|
1633
|
+
justifyContent: 'flex-start !important'
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
};
|
|
1638
|
+
const getSelectItemWithHintColumnStyles = function() {
|
|
1639
|
+
let hintColumnWidthPercent = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 50;
|
|
1640
|
+
return /*#__PURE__*/ css({
|
|
1641
|
+
flexGrow: 1,
|
|
1642
|
+
display: 'inline-grid',
|
|
1643
|
+
gridTemplateColumns: `${100 - hintColumnWidthPercent}% ${hintColumnWidthPercent}%`,
|
|
1644
|
+
alignItems: 'baseline'
|
|
1645
|
+
});
|
|
1646
|
+
};
|
|
1647
|
+
const getHintColumnStyles = (theme, disabled, textOverflowMode)=>{
|
|
1648
|
+
return /*#__PURE__*/ css({
|
|
1649
|
+
color: theme.colors.textSecondary,
|
|
1650
|
+
fontSize: theme.typography.fontSizeSm,
|
|
1651
|
+
textAlign: 'right',
|
|
1652
|
+
...disabled && {
|
|
1653
|
+
color: theme.colors.actionDisabledText
|
|
1654
|
+
},
|
|
1655
|
+
...textOverflowMode === 'ellipsis' && {
|
|
1656
|
+
textOverflow: 'ellipsis',
|
|
1657
|
+
whiteSpace: 'nowrap',
|
|
1658
|
+
overflow: 'hidden'
|
|
1659
|
+
}
|
|
1660
|
+
});
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
|
|
1664
|
+
var ValidSemanticColors = /*#__PURE__*/ function(ValidSemanticColors) {
|
|
1665
|
+
ValidSemanticColors["ActionDangerDefaultBackgroundDefault"] = "actionDangerDefaultBackgroundDefault";
|
|
1666
|
+
ValidSemanticColors["ActionDangerDefaultBackgroundHover"] = "actionDangerDefaultBackgroundHover";
|
|
1667
|
+
ValidSemanticColors["ActionDangerDefaultBackgroundPress"] = "actionDangerDefaultBackgroundPress";
|
|
1668
|
+
ValidSemanticColors["ActionDangerDefaultBorderDefault"] = "actionDangerDefaultBorderDefault";
|
|
1669
|
+
ValidSemanticColors["ActionDangerDefaultBorderHover"] = "actionDangerDefaultBorderHover";
|
|
1670
|
+
ValidSemanticColors["ActionDangerDefaultBorderPress"] = "actionDangerDefaultBorderPress";
|
|
1671
|
+
ValidSemanticColors["ActionDangerDefaultTextDefault"] = "actionDangerDefaultTextDefault";
|
|
1672
|
+
ValidSemanticColors["ActionDangerDefaultTextHover"] = "actionDangerDefaultTextHover";
|
|
1673
|
+
ValidSemanticColors["ActionDangerDefaultTextPress"] = "actionDangerDefaultTextPress";
|
|
1674
|
+
ValidSemanticColors["ActionDangerPrimaryBackgroundDefault"] = "actionDangerPrimaryBackgroundDefault";
|
|
1675
|
+
ValidSemanticColors["ActionDangerPrimaryBackgroundHover"] = "actionDangerPrimaryBackgroundHover";
|
|
1676
|
+
ValidSemanticColors["ActionDangerPrimaryBackgroundPress"] = "actionDangerPrimaryBackgroundPress";
|
|
1677
|
+
ValidSemanticColors["ActionDangerPrimaryText"] = "actionDangerPrimaryText";
|
|
1678
|
+
ValidSemanticColors["ActionDefaultBackgroundDefault"] = "actionDefaultBackgroundDefault";
|
|
1679
|
+
ValidSemanticColors["ActionDefaultBackgroundHover"] = "actionDefaultBackgroundHover";
|
|
1680
|
+
ValidSemanticColors["ActionDefaultBackgroundPress"] = "actionDefaultBackgroundPress";
|
|
1681
|
+
ValidSemanticColors["ActionDefaultBorderDefault"] = "actionDefaultBorderDefault";
|
|
1682
|
+
ValidSemanticColors["ActionDefaultBorderFocus"] = "actionDefaultBorderFocus";
|
|
1683
|
+
ValidSemanticColors["ActionDefaultBorderHover"] = "actionDefaultBorderHover";
|
|
1684
|
+
ValidSemanticColors["ActionDefaultBorderPress"] = "actionDefaultBorderPress";
|
|
1685
|
+
ValidSemanticColors["ActionDefaultIconDefault"] = "actionDefaultIconDefault";
|
|
1686
|
+
ValidSemanticColors["ActionDefaultIconHover"] = "actionDefaultIconHover";
|
|
1687
|
+
ValidSemanticColors["ActionDefaultIconPress"] = "actionDefaultIconPress";
|
|
1688
|
+
ValidSemanticColors["ActionDefaultTextDefault"] = "actionDefaultTextDefault";
|
|
1689
|
+
ValidSemanticColors["ActionDefaultTextHover"] = "actionDefaultTextHover";
|
|
1690
|
+
ValidSemanticColors["ActionDefaultTextPress"] = "actionDefaultTextPress";
|
|
1691
|
+
ValidSemanticColors["ActionDisabledBackground"] = "actionDisabledBackground";
|
|
1692
|
+
ValidSemanticColors["ActionDisabledBorder"] = "actionDisabledBorder";
|
|
1693
|
+
ValidSemanticColors["ActionDisabledText"] = "actionDisabledText";
|
|
1694
|
+
ValidSemanticColors["ActionIconBackgroundDefault"] = "actionIconBackgroundDefault";
|
|
1695
|
+
ValidSemanticColors["ActionIconBackgroundHover"] = "actionIconBackgroundHover";
|
|
1696
|
+
ValidSemanticColors["ActionIconBackgroundPress"] = "actionIconBackgroundPress";
|
|
1697
|
+
ValidSemanticColors["ActionIconIconDefault"] = "actionIconIconDefault";
|
|
1698
|
+
ValidSemanticColors["ActionIconIconHover"] = "actionIconIconHover";
|
|
1699
|
+
ValidSemanticColors["ActionIconIconPress"] = "actionIconIconPress";
|
|
1700
|
+
ValidSemanticColors["ActionLinkDefault"] = "actionLinkDefault";
|
|
1701
|
+
ValidSemanticColors["ActionLinkHover"] = "actionLinkHover";
|
|
1702
|
+
ValidSemanticColors["ActionLinkPress"] = "actionLinkPress";
|
|
1703
|
+
ValidSemanticColors["ActionPrimaryBackgroundDefault"] = "actionPrimaryBackgroundDefault";
|
|
1704
|
+
ValidSemanticColors["ActionPrimaryBackgroundHover"] = "actionPrimaryBackgroundHover";
|
|
1705
|
+
ValidSemanticColors["ActionPrimaryBackgroundPress"] = "actionPrimaryBackgroundPress";
|
|
1706
|
+
ValidSemanticColors["ActionPrimaryIcon"] = "actionPrimaryIcon";
|
|
1707
|
+
ValidSemanticColors["ActionPrimaryTextDefault"] = "actionPrimaryTextDefault";
|
|
1708
|
+
ValidSemanticColors["ActionPrimaryTextHover"] = "actionPrimaryTextHover";
|
|
1709
|
+
ValidSemanticColors["ActionPrimaryTextPress"] = "actionPrimaryTextPress";
|
|
1710
|
+
ValidSemanticColors["ActionTertiaryBackgroundDefault"] = "actionTertiaryBackgroundDefault";
|
|
1711
|
+
ValidSemanticColors["ActionTertiaryBackgroundHover"] = "actionTertiaryBackgroundHover";
|
|
1712
|
+
ValidSemanticColors["ActionTertiaryBackgroundPress"] = "actionTertiaryBackgroundPress";
|
|
1713
|
+
ValidSemanticColors["ActionTertiaryIconDefault"] = "actionTertiaryIconDefault";
|
|
1714
|
+
ValidSemanticColors["ActionTertiaryIconHover"] = "actionTertiaryIconHover";
|
|
1715
|
+
ValidSemanticColors["ActionTertiaryIconPress"] = "actionTertiaryIconPress";
|
|
1716
|
+
ValidSemanticColors["ActionTertiaryTextDefault"] = "actionTertiaryTextDefault";
|
|
1717
|
+
ValidSemanticColors["ActionTertiaryTextHover"] = "actionTertiaryTextHover";
|
|
1718
|
+
ValidSemanticColors["ActionTertiaryTextPress"] = "actionTertiaryTextPress";
|
|
1719
|
+
ValidSemanticColors["BackgroundDanger"] = "backgroundDanger";
|
|
1720
|
+
ValidSemanticColors["BackgroundPrimary"] = "backgroundPrimary";
|
|
1721
|
+
ValidSemanticColors["BackgroundSecondary"] = "backgroundSecondary";
|
|
1722
|
+
ValidSemanticColors["BackgroundSuccess"] = "backgroundSuccess";
|
|
1723
|
+
ValidSemanticColors["BackgroundWarning"] = "backgroundWarning";
|
|
1724
|
+
ValidSemanticColors["Border"] = "border";
|
|
1725
|
+
ValidSemanticColors["BorderAccessible"] = "borderAccessible";
|
|
1726
|
+
ValidSemanticColors["BorderDanger"] = "borderDanger";
|
|
1727
|
+
ValidSemanticColors["BorderWarning"] = "borderWarning";
|
|
1728
|
+
ValidSemanticColors["CodeBackground"] = "codeBackground";
|
|
1729
|
+
ValidSemanticColors["OverlayOverlay"] = "overlayOverlay";
|
|
1730
|
+
ValidSemanticColors["ProgressFill"] = "progressFill";
|
|
1731
|
+
ValidSemanticColors["ProgressFillPrimary"] = "progressFillPrimary";
|
|
1732
|
+
ValidSemanticColors["ProgressTrack"] = "progressTrack";
|
|
1733
|
+
ValidSemanticColors["Skeleton"] = "skeleton";
|
|
1734
|
+
ValidSemanticColors["TableBackgroundSelectedDefault"] = "tableBackgroundSelectedDefault";
|
|
1735
|
+
ValidSemanticColors["TableBackgroundSelectedHover"] = "tableBackgroundSelectedHover";
|
|
1736
|
+
ValidSemanticColors["TableBackgroundUnselectedDefault"] = "tableBackgroundUnselectedDefault";
|
|
1737
|
+
ValidSemanticColors["TableBackgroundUnselectedHover"] = "tableBackgroundUnselectedHover";
|
|
1738
|
+
ValidSemanticColors["TextPlaceholder"] = "textPlaceholder";
|
|
1739
|
+
ValidSemanticColors["TextPrimary"] = "textPrimary";
|
|
1740
|
+
ValidSemanticColors["TextSecondary"] = "textSecondary";
|
|
1741
|
+
ValidSemanticColors["TextValidationDanger"] = "textValidationDanger";
|
|
1742
|
+
ValidSemanticColors["TextValidationSuccess"] = "textValidationSuccess";
|
|
1743
|
+
ValidSemanticColors["TextValidationWarning"] = "textValidationWarning";
|
|
1744
|
+
ValidSemanticColors["TooltipBackgroundTooltip"] = "tooltipBackgroundTooltip";
|
|
1745
|
+
return ValidSemanticColors;
|
|
1746
|
+
}({});
|
|
1747
|
+
|
|
1748
|
+
const ColorVars = {
|
|
1749
|
+
primary: ValidSemanticColors.TextPrimary,
|
|
1750
|
+
secondary: ValidSemanticColors.TextSecondary,
|
|
1751
|
+
info: ValidSemanticColors.TextSecondary,
|
|
1752
|
+
error: ValidSemanticColors.TextValidationDanger,
|
|
1753
|
+
success: ValidSemanticColors.TextValidationSuccess,
|
|
1754
|
+
warning: ValidSemanticColors.TextValidationWarning
|
|
1755
|
+
};
|
|
1756
|
+
|
|
1757
|
+
/**
|
|
1758
|
+
* Recursively appends `!important` to all CSS properties in an Emotion `CSSObject`.
|
|
1759
|
+
* Used to ensure that we always override Ant styles, without worrying about selector precedence.
|
|
1760
|
+
*/ function importantify(obj) {
|
|
1761
|
+
return _.mapValues(obj, (value, key)=>{
|
|
1762
|
+
if (_.isString(value) || _.isNumber(value) || _.isBoolean(value)) {
|
|
1763
|
+
// Make sure we don't double-append important
|
|
1764
|
+
if (_.isString(value) && _.endsWith(value, '!important')) {
|
|
1765
|
+
return value;
|
|
1766
|
+
}
|
|
1767
|
+
if (_.isNumber(value)) {
|
|
1768
|
+
if (unitless[key]) {
|
|
1769
|
+
return `${value}!important`;
|
|
1770
|
+
}
|
|
1771
|
+
return `${value}px!important`;
|
|
1772
|
+
}
|
|
1773
|
+
return `${value}!important`;
|
|
1774
|
+
}
|
|
1775
|
+
if (_.isNil(value)) {
|
|
1776
|
+
return value;
|
|
1777
|
+
}
|
|
1778
|
+
return importantify(value);
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Returns a text color, in case of invalid/missing key and missing fallback color it will return textPrimary
|
|
1783
|
+
* @param theme
|
|
1784
|
+
* @param key - key of TypographyColor
|
|
1785
|
+
* @param fallbackColor - color to return as fallback -- used to remove tertiary check inline
|
|
1786
|
+
*/ function getTypographyColor(theme, key, fallbackColor) {
|
|
1787
|
+
if (theme && key && Object(theme.colors).hasOwnProperty(ColorVars[key])) {
|
|
1788
|
+
return theme.colors[ColorVars[key]];
|
|
1789
|
+
}
|
|
1790
|
+
return fallbackColor ?? theme.colors.textPrimary;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Returns validation color based on state, has default validation colors if params are not provided
|
|
1794
|
+
* @param theme
|
|
1795
|
+
* @param validationState
|
|
1796
|
+
* @param errorColor
|
|
1797
|
+
* @param warningColor
|
|
1798
|
+
* @param successColor
|
|
1799
|
+
*/ function getValidationStateColor(theme, validationState) {
|
|
1800
|
+
let { errorColor, warningColor, successColor } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1801
|
+
switch(validationState){
|
|
1802
|
+
case 'error':
|
|
1803
|
+
return errorColor || theme.colors.actionDangerPrimaryBackgroundDefault;
|
|
1804
|
+
case 'warning':
|
|
1805
|
+
return warningColor || theme.colors.textValidationWarning;
|
|
1806
|
+
case 'success':
|
|
1807
|
+
return successColor || theme.colors.textValidationSuccess;
|
|
1808
|
+
default:
|
|
1809
|
+
return undefined;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
function getDarkModePortalStyles(theme, useNewShadows, useNewBorderColors) {
|
|
1813
|
+
if (!theme || !theme.isDarkMode) {
|
|
1814
|
+
return {};
|
|
1815
|
+
}
|
|
1816
|
+
return {
|
|
1817
|
+
border: `1px solid ${useNewBorderColors ? theme.colors.border : theme.colors.borderDecorative}`,
|
|
1818
|
+
// With the new shadows we have corrected the style of shadows for dark mode, and don't need to disable them.
|
|
1819
|
+
...useNewShadows ? {} : {
|
|
1820
|
+
boxShadow: 'none'
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
const shadowCoverTop = (bgColor)=>`linear-gradient(${bgColor} 30%, rgba(0, 0, 0, 0)) center top`;
|
|
1825
|
+
const shadowCoverBot = (bgColor)=>`linear-gradient(rgba(0, 0, 0, 0), ${bgColor} 70%) center bottom`;
|
|
1826
|
+
const shadowCoverLeft = (bgColor)=>`linear-gradient(to left, rgba(0, 0, 0, 0), ${bgColor} 30%) left center`;
|
|
1827
|
+
const shadowCoverRight = (bgColor)=>`linear-gradient(to left, ${bgColor} 70%, rgba(0, 0, 0, 0)) right center`;
|
|
1828
|
+
const shadowTop = (shadowRgb)=>`radial-gradient(
|
|
1829
|
+
farthest-side at 50% 0,
|
|
1830
|
+
rgba(${shadowRgb}, 0.2),
|
|
1831
|
+
rgba(${shadowRgb}, 0)
|
|
1832
|
+
) center top`;
|
|
1833
|
+
const shadowBot = (shadowRgb)=>`radial-gradient(
|
|
1834
|
+
farthest-side at 50% 100%,
|
|
1835
|
+
rgba(${shadowRgb}, 0.2),
|
|
1836
|
+
rgba(${shadowRgb}, 0)
|
|
1837
|
+
) center bottom`;
|
|
1838
|
+
const shadowLeft = (shadowRgb)=>`radial-gradient(
|
|
1839
|
+
farthest-side at 0 50%,
|
|
1840
|
+
rgba(${shadowRgb}, 0.2),
|
|
1841
|
+
rgba(${shadowRgb}, 0)
|
|
1842
|
+
) left center`;
|
|
1843
|
+
const shadowRight = (shadowRgb)=>`radial-gradient(
|
|
1844
|
+
farthest-side at 100% 50%,
|
|
1845
|
+
rgba(${shadowRgb}, 0.2),
|
|
1846
|
+
rgba(${shadowRgb}, 0)
|
|
1847
|
+
) right center`;
|
|
1848
|
+
const shadowCoverBackgroundSizeVertical = '100% 40px';
|
|
1849
|
+
const shadowCoverBackgroundSizeHorizontal = '40px 100%';
|
|
1850
|
+
const shadowBackgroundSizeVertical = '100% 14px';
|
|
1851
|
+
const shadowBackgroundSizeHorizontal = '14px 100%';
|
|
1852
|
+
const getShadowScrollStylesMemoized = memoize(function getShadowScrollStylesMemoized(theme, backgroundColor) {
|
|
1853
|
+
let orientation = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 'vertical';
|
|
1854
|
+
const bgColor = backgroundColor ?? theme.colors.backgroundPrimary;
|
|
1855
|
+
const shadowColor = theme.isDarkMode ? shadowDarkRgb : shadowLightRgb;
|
|
1856
|
+
if (orientation === 'horizontal') {
|
|
1857
|
+
return {
|
|
1858
|
+
background: `
|
|
1859
|
+
${shadowCoverLeft(bgColor)},
|
|
1860
|
+
${shadowCoverRight(bgColor)},
|
|
1861
|
+
${shadowLeft(shadowColor)},
|
|
1862
|
+
${shadowRight(shadowColor)}`,
|
|
1863
|
+
backgroundRepeat: 'no-repeat',
|
|
1864
|
+
backgroundSize: `
|
|
1865
|
+
${shadowCoverBackgroundSizeHorizontal},
|
|
1866
|
+
${shadowCoverBackgroundSizeHorizontal},
|
|
1867
|
+
${shadowBackgroundSizeHorizontal},
|
|
1868
|
+
${shadowBackgroundSizeHorizontal}`,
|
|
1869
|
+
backgroundAttachment: 'local, local, scroll, scroll'
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
return {
|
|
1873
|
+
background: `
|
|
1874
|
+
${shadowCoverTop(bgColor)},
|
|
1875
|
+
${shadowCoverBot(bgColor)},
|
|
1876
|
+
${shadowTop(shadowColor)},
|
|
1877
|
+
${shadowBot(shadowColor)}`,
|
|
1878
|
+
backgroundRepeat: 'no-repeat',
|
|
1879
|
+
backgroundSize: `
|
|
1880
|
+
${shadowCoverBackgroundSizeVertical},
|
|
1881
|
+
${shadowCoverBackgroundSizeVertical},
|
|
1882
|
+
${shadowBackgroundSizeVertical},
|
|
1883
|
+
${shadowBackgroundSizeVertical}`,
|
|
1884
|
+
backgroundAttachment: 'local, local, scroll, scroll'
|
|
1885
|
+
};
|
|
1886
|
+
}, (theme, backgroundColor, orientation)=>{
|
|
1887
|
+
return `${theme.isDarkMode}-${backgroundColor}-${orientation}`;
|
|
1888
|
+
});
|
|
1889
|
+
const getShadowScrollStyles = function getShadowScrollStyles(theme) {
|
|
1890
|
+
let { backgroundColor, orientation } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1891
|
+
return getShadowScrollStylesMemoized(theme, backgroundColor, orientation);
|
|
1892
|
+
};
|
|
1893
|
+
const getBottomOnlyShadowScrollStylesMemoized = memoize(function getBottomOnlyShadowScrollStylesMemoized(theme, backgroundColor) {
|
|
1894
|
+
const bgColor = backgroundColor ?? theme.colors.backgroundPrimary;
|
|
1895
|
+
return {
|
|
1896
|
+
background: `
|
|
1897
|
+
${shadowCoverBot(bgColor)},
|
|
1898
|
+
${shadowBot(theme.isDarkMode ? shadowDarkRgb : shadowLightRgb)}`,
|
|
1899
|
+
backgroundRepeat: 'no-repeat',
|
|
1900
|
+
backgroundSize: `
|
|
1901
|
+
${shadowCoverBackgroundSizeVertical},
|
|
1902
|
+
${shadowBackgroundSizeVertical}`,
|
|
1903
|
+
backgroundAttachment: 'local, scroll'
|
|
1904
|
+
};
|
|
1905
|
+
});
|
|
1906
|
+
const getBottomOnlyShadowScrollStyles = function getBottomOnlyShadowScrollStyles(theme) {
|
|
1907
|
+
let { backgroundColor } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1908
|
+
return getBottomOnlyShadowScrollStylesMemoized(theme, backgroundColor);
|
|
1909
|
+
};
|
|
1910
|
+
const getHorizontalTabShadowStylesMemoized = memoize(function getHorizontalTabShadowStylesMemoized(theme, backgroundColor) {
|
|
1911
|
+
const bgColor = backgroundColor ?? theme.colors.backgroundPrimary;
|
|
1912
|
+
const shadowValue = theme.shadows.lg;
|
|
1913
|
+
const shadowColorMatch = shadowValue.match(/rgba?\([^)]+\)/);
|
|
1914
|
+
const shadowColor = shadowColorMatch ? shadowColorMatch[0] : 'rgba(0, 0, 0, 0.1)';
|
|
1915
|
+
const shadowCoverLeft = `linear-gradient(to right, ${bgColor} 0%, ${bgColor} 30%, rgba(0, 0, 0, 0) 100%) left center`;
|
|
1916
|
+
const shadowCoverRight = `linear-gradient(to left, ${bgColor} 0%, ${bgColor} 30%, rgba(0, 0, 0, 0) 100%) right center`;
|
|
1917
|
+
const shadowLeft = `linear-gradient(to right, ${shadowColor} 0%, rgba(0, 0, 0, 0) 100%) left center`;
|
|
1918
|
+
const shadowRight = `linear-gradient(to left, ${shadowColor} 0%, rgba(0, 0, 0, 0) 100%) right center`;
|
|
1919
|
+
const shadowSize = '16px 100%';
|
|
1920
|
+
return {
|
|
1921
|
+
background: `
|
|
1922
|
+
${shadowCoverLeft},
|
|
1923
|
+
${shadowCoverRight},
|
|
1924
|
+
${shadowLeft},
|
|
1925
|
+
${shadowRight}`,
|
|
1926
|
+
backgroundRepeat: 'no-repeat',
|
|
1927
|
+
backgroundSize: `${shadowSize}, ${shadowSize}, ${shadowSize}, ${shadowSize}`,
|
|
1928
|
+
backgroundAttachment: 'local, local, scroll, scroll'
|
|
1929
|
+
};
|
|
1930
|
+
});
|
|
1931
|
+
const getHorizontalTabShadowStyles = function getHorizontalTabShadowStyles(theme) {
|
|
1932
|
+
let { backgroundColor } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1933
|
+
return getHorizontalTabShadowStylesMemoized(theme, backgroundColor);
|
|
1934
|
+
};
|
|
1935
|
+
function getVirtualizedComboboxMenuItemStyles(virtualItem) {
|
|
1936
|
+
const theme = getTheme(false); // Since we only need paddings, we can use light mode theme
|
|
1937
|
+
const [top, right, bottom, left] = getComboboxMenuItemPadding(theme);
|
|
1938
|
+
const topBottomPadding = top + bottom;
|
|
1939
|
+
const leftRightPadding = right + left;
|
|
1940
|
+
return {
|
|
1941
|
+
position: 'absolute',
|
|
1942
|
+
width: `calc(100% - ${leftRightPadding}px)`,
|
|
1943
|
+
height: `${virtualItem.size - topBottomPadding}px`,
|
|
1944
|
+
transform: `translateY(${virtualItem.start}px)`
|
|
1945
|
+
};
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
// Define a module-global observer and a WeakMap on elements to hold callbacks
|
|
1949
|
+
let sharedObserver = null;
|
|
1950
|
+
const entryCallbackMap = new WeakMap();
|
|
1951
|
+
const ensureSharedObserverExists = ()=>{
|
|
1952
|
+
if (!sharedObserver) {
|
|
1953
|
+
sharedObserver = new IntersectionObserver((entries)=>{
|
|
1954
|
+
entries.forEach((entry)=>{
|
|
1955
|
+
if (entry.isIntersecting) {
|
|
1956
|
+
const entryCallback = entryCallbackMap.get(entry.target);
|
|
1957
|
+
if (entryCallback) {
|
|
1958
|
+
entryCallback();
|
|
1959
|
+
entryCallbackMap.delete(entry.target);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
});
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
};
|
|
1966
|
+
function observeElement(element, callback) {
|
|
1967
|
+
ensureSharedObserverExists();
|
|
1968
|
+
entryCallbackMap.set(element, callback);
|
|
1969
|
+
sharedObserver?.observe(element);
|
|
1970
|
+
return ()=>{
|
|
1971
|
+
if (element) {
|
|
1972
|
+
sharedObserver?.unobserve(element);
|
|
1973
|
+
entryCallbackMap.delete(element);
|
|
1974
|
+
}
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Checks if the element was viewed and calls the onView callback.
|
|
1979
|
+
* NOTE: This hook only triggers the onView callback once for the element.
|
|
1980
|
+
* @param onView - callback to be called when the element is viewed
|
|
1981
|
+
* @param resetKey - optional key that resets the observer when changed
|
|
1982
|
+
* @typeParam T - extends Element to specify the type of element being observed
|
|
1983
|
+
*/ const useNotifyOnFirstView = (param)=>{
|
|
1984
|
+
let { onView, resetKey, value } = param;
|
|
1985
|
+
const isViewedRef = useRef(false);
|
|
1986
|
+
const elementRef = useRef(null);
|
|
1987
|
+
const previousResetKey = useRef(resetKey);
|
|
1988
|
+
// Only reset isViewedRef when resetKey changes
|
|
1989
|
+
useEffect(()=>{
|
|
1990
|
+
if (previousResetKey.current !== resetKey) {
|
|
1991
|
+
isViewedRef.current = false;
|
|
1992
|
+
previousResetKey.current = resetKey;
|
|
1993
|
+
}
|
|
1994
|
+
}, [
|
|
1995
|
+
resetKey
|
|
1996
|
+
]);
|
|
1997
|
+
useEffect(()=>{
|
|
1998
|
+
const element = elementRef.current;
|
|
1999
|
+
// If already viewed or element is not available, do nothing
|
|
2000
|
+
if (!element || isViewedRef.current) {
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
const callback = ()=>{
|
|
2004
|
+
isViewedRef.current = true;
|
|
2005
|
+
onView(value);
|
|
2006
|
+
};
|
|
2007
|
+
// If IntersectionObserver is not available, assume that the element is visible
|
|
2008
|
+
if (!window.IntersectionObserver) {
|
|
2009
|
+
callback();
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
return observeElement(element, callback);
|
|
2013
|
+
}, [
|
|
2014
|
+
onView,
|
|
2015
|
+
value
|
|
2016
|
+
]);
|
|
2017
|
+
return {
|
|
2018
|
+
elementRef
|
|
2019
|
+
};
|
|
2020
|
+
};
|
|
2021
|
+
|
|
2022
|
+
const useDesignSystemSafexFlags = ()=>{
|
|
2023
|
+
return {
|
|
2024
|
+
useNewShadows: safex('databricks.fe.designsystem.useNewShadows', false),
|
|
2025
|
+
useNewFormUISpacing: safex('databricks.fe.designsystem.useNewFormUISpacing', false),
|
|
2026
|
+
useNewBorderRadii: safex('databricks.fe.designsystem.useNewBorderRadii', false),
|
|
2027
|
+
useNewLargeAlertSizing: safex('databricks.fe.designsystem.useNewLargeAlertSizing', false),
|
|
2028
|
+
useNewBorderColors: safex('databricks.fe.designsystem.useNewBorderColors', false),
|
|
2029
|
+
useNewDatePickerInput: safex('databricks.fe.designsystem.useNewDatePickerInput', false)
|
|
2030
|
+
};
|
|
2031
|
+
};
|
|
2032
|
+
|
|
2033
|
+
function AccessibleContainer(param) {
|
|
2034
|
+
let { children, label } = param;
|
|
2035
|
+
if (!label) {
|
|
2036
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
2037
|
+
children: children
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
2041
|
+
css: {
|
|
2042
|
+
cursor: 'progress'
|
|
2043
|
+
},
|
|
2044
|
+
children: [
|
|
2045
|
+
/*#__PURE__*/ jsx("span", {
|
|
2046
|
+
css: visuallyHidden,
|
|
2047
|
+
children: label
|
|
2048
|
+
}),
|
|
2049
|
+
/*#__PURE__*/ jsx("div", {
|
|
2050
|
+
"aria-hidden": true,
|
|
2051
|
+
children: children
|
|
2052
|
+
})
|
|
2053
|
+
]
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
const DefaultDesignSystemEventSuppressInteractionContextValue = {
|
|
2058
|
+
suppressAnalyticsStartInteraction: false
|
|
2059
|
+
};
|
|
2060
|
+
const DesignSystemEventSuppressInteractionTrueContextValue = {
|
|
2061
|
+
suppressAnalyticsStartInteraction: true
|
|
2062
|
+
};
|
|
2063
|
+
const DesignSystemEventSuppressInteractionProviderContext = /*#__PURE__*/ React__default.createContext(DefaultDesignSystemEventSuppressInteractionContextValue);
|
|
2064
|
+
/**
|
|
2065
|
+
* This gets the event suppress interaction provider, is used to suppress the start interaction for analytics events.
|
|
2066
|
+
*
|
|
2067
|
+
* @returns DesignSystemEventSuppressInteractionContextType
|
|
2068
|
+
*/ const useDesignSystemEventSuppressInteractionContext = ()=>{
|
|
2069
|
+
return useContext(DesignSystemEventSuppressInteractionProviderContext);
|
|
2070
|
+
};
|
|
2071
|
+
|
|
2072
|
+
// Ensure webapp/web/html/index.html version has parity with this function below
|
|
2073
|
+
function generateUuidV4() {
|
|
2074
|
+
const uuid = window.crypto?.randomUUID?.();
|
|
2075
|
+
if (uuid) {
|
|
2076
|
+
return uuid;
|
|
2077
|
+
}
|
|
2078
|
+
// fallback for older browsers
|
|
2079
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c)=>{
|
|
2080
|
+
const r = Math.random() * 16 | 0;
|
|
2081
|
+
const v = c === 'x' ? r : r & 0x3 | 0x8;
|
|
2082
|
+
return v.toString(16);
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
/**
|
|
2086
|
+
* Give the component a stable uuidv4 on mount that can be used to differentiate between
|
|
2087
|
+
* other components. One application is debugging or performance tracing or analytics.
|
|
2088
|
+
*/ function useStableUuidV4() {
|
|
2089
|
+
return useStable(()=>generateUuidV4());
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
var DesignSystemEventProviderComponentTypes = /*#__PURE__*/ function(DesignSystemEventProviderComponentTypes) {
|
|
2093
|
+
DesignSystemEventProviderComponentTypes["Accordion"] = "accordion";
|
|
2094
|
+
DesignSystemEventProviderComponentTypes["Alert"] = "alert";
|
|
2095
|
+
DesignSystemEventProviderComponentTypes["Banner"] = "banner";
|
|
2096
|
+
DesignSystemEventProviderComponentTypes["Button"] = "button";
|
|
2097
|
+
DesignSystemEventProviderComponentTypes["Card"] = "card";
|
|
2098
|
+
DesignSystemEventProviderComponentTypes["Checkbox"] = "checkbox";
|
|
2099
|
+
DesignSystemEventProviderComponentTypes["ContextMenuCheckboxItem"] = "context_menu_checkbox_item";
|
|
2100
|
+
DesignSystemEventProviderComponentTypes["ContextMenuItem"] = "context_menu_item";
|
|
2101
|
+
DesignSystemEventProviderComponentTypes["ContextMenuRadioGroup"] = "context_menu_radio_group";
|
|
2102
|
+
DesignSystemEventProviderComponentTypes["DialogCombobox"] = "dialog_combobox";
|
|
2103
|
+
DesignSystemEventProviderComponentTypes["Drawer"] = "drawer_content";
|
|
2104
|
+
DesignSystemEventProviderComponentTypes["DropdownMenuCheckboxItem"] = "dropdown_menu_checkbox_item";
|
|
2105
|
+
DesignSystemEventProviderComponentTypes["DropdownMenuItem"] = "dropdown_menu_item";
|
|
2106
|
+
DesignSystemEventProviderComponentTypes["DropdownMenuRadioGroup"] = "dropdown_menu_radio_group";
|
|
2107
|
+
DesignSystemEventProviderComponentTypes["Form"] = "form";
|
|
2108
|
+
DesignSystemEventProviderComponentTypes["Input"] = "input";
|
|
2109
|
+
DesignSystemEventProviderComponentTypes["LegacySelect"] = "legacy_select";
|
|
2110
|
+
DesignSystemEventProviderComponentTypes["Listbox"] = "listbox";
|
|
2111
|
+
DesignSystemEventProviderComponentTypes["Modal"] = "modal";
|
|
2112
|
+
DesignSystemEventProviderComponentTypes["Notification"] = "notification";
|
|
2113
|
+
DesignSystemEventProviderComponentTypes["Pagination"] = "pagination";
|
|
2114
|
+
DesignSystemEventProviderComponentTypes["PillControl"] = "pill_control";
|
|
2115
|
+
DesignSystemEventProviderComponentTypes["Popover"] = "popover";
|
|
2116
|
+
DesignSystemEventProviderComponentTypes["PreviewCard"] = "preview_card";
|
|
2117
|
+
DesignSystemEventProviderComponentTypes["Radio"] = "radio";
|
|
2118
|
+
DesignSystemEventProviderComponentTypes["RadioGroup"] = "radio_group";
|
|
2119
|
+
DesignSystemEventProviderComponentTypes["SegmentedControlGroup"] = "segmented_control_group";
|
|
2120
|
+
DesignSystemEventProviderComponentTypes["SimpleSelect"] = "simple_select";
|
|
2121
|
+
DesignSystemEventProviderComponentTypes["Switch"] = "switch";
|
|
2122
|
+
DesignSystemEventProviderComponentTypes["TableHeader"] = "table_header";
|
|
2123
|
+
DesignSystemEventProviderComponentTypes["Tabs"] = "tabs";
|
|
2124
|
+
DesignSystemEventProviderComponentTypes["Tag"] = "tag";
|
|
2125
|
+
DesignSystemEventProviderComponentTypes["TextArea"] = "text_area";
|
|
2126
|
+
DesignSystemEventProviderComponentTypes["ToggleButton"] = "toggle_button";
|
|
2127
|
+
DesignSystemEventProviderComponentTypes["Tooltip"] = "tooltip";
|
|
2128
|
+
DesignSystemEventProviderComponentTypes["TypeaheadCombobox"] = "typeahead_combobox";
|
|
2129
|
+
DesignSystemEventProviderComponentTypes["TypographyLink"] = "typography_link";
|
|
2130
|
+
return DesignSystemEventProviderComponentTypes;
|
|
2131
|
+
}({});
|
|
2132
|
+
var DesignSystemEventProviderAnalyticsEventTypes = /*#__PURE__*/ function(DesignSystemEventProviderAnalyticsEventTypes) {
|
|
2133
|
+
DesignSystemEventProviderAnalyticsEventTypes["OnClick"] = "onClick";
|
|
2134
|
+
DesignSystemEventProviderAnalyticsEventTypes["OnSubmit"] = "onSubmit";
|
|
2135
|
+
DesignSystemEventProviderAnalyticsEventTypes["OnValueChange"] = "onValueChange";
|
|
2136
|
+
DesignSystemEventProviderAnalyticsEventTypes["OnView"] = "onView";
|
|
2137
|
+
return DesignSystemEventProviderAnalyticsEventTypes;
|
|
2138
|
+
}({});
|
|
2139
|
+
var DesignSystemEventProviderComponentSubTypes = /*#__PURE__*/ function(DesignSystemEventProviderComponentSubTypes) {
|
|
2140
|
+
DesignSystemEventProviderComponentSubTypes["Success"] = "success";
|
|
2141
|
+
DesignSystemEventProviderComponentSubTypes["Error"] = "error";
|
|
2142
|
+
DesignSystemEventProviderComponentSubTypes["Warning"] = "warning";
|
|
2143
|
+
DesignSystemEventProviderComponentSubTypes["Info"] = "info";
|
|
2144
|
+
DesignSystemEventProviderComponentSubTypes["InfoLightPurple"] = "info_light_purple";
|
|
2145
|
+
DesignSystemEventProviderComponentSubTypes["InfoDarkPurple"] = "info_dark_purple";
|
|
2146
|
+
return DesignSystemEventProviderComponentSubTypes;
|
|
2147
|
+
}({});
|
|
2148
|
+
const DesignSystemEventProviderComponentSubTypeMap = {
|
|
2149
|
+
success: "success",
|
|
2150
|
+
error: "error",
|
|
2151
|
+
warning: "warning",
|
|
2152
|
+
info: "info",
|
|
2153
|
+
info_light_purple: "info_light_purple",
|
|
2154
|
+
info_dark_purple: "info_dark_purple"
|
|
2155
|
+
};
|
|
2156
|
+
const shouldTriggerCallback = (eventType, analyticsEvents)=>{
|
|
2157
|
+
return analyticsEvents.includes(eventType);
|
|
2158
|
+
};
|
|
2159
|
+
const DefaultEmptyCallbacks = {
|
|
2160
|
+
callback: ()=>{}
|
|
2161
|
+
};
|
|
2162
|
+
const DesignSystemEventProviderContext = /*#__PURE__*/ React__default.createContext(DefaultEmptyCallbacks);
|
|
2163
|
+
/**
|
|
2164
|
+
* This gets the event provider, which is used to pass callbacks to the design system for events such as onClick, onView, and onValueChange.
|
|
2165
|
+
* If the value is undefined, then the expected behavior is to not emit any events.
|
|
2166
|
+
*
|
|
2167
|
+
* @returns DesignSystemEventProviderContextType
|
|
2168
|
+
*/ const useDesignSystemEventProviderContext = ()=>{
|
|
2169
|
+
return useContext(DesignSystemEventProviderContext);
|
|
2170
|
+
};
|
|
2171
|
+
const ComponentFinderContext = /*#__PURE__*/ createContext({
|
|
2172
|
+
dataComponentProps: {}
|
|
2173
|
+
});
|
|
2174
|
+
const useComponentFinderContext = (targetComponentType)=>{
|
|
2175
|
+
const componentFinderContext = useContext(ComponentFinderContext);
|
|
2176
|
+
return targetComponentType === componentFinderContext.dataComponentProps['data-component-type'] ? componentFinderContext.dataComponentProps : {};
|
|
2177
|
+
};
|
|
2178
|
+
/**
|
|
2179
|
+
* NOTE: Manually adding in data-component-* props via spreading dataComponentProps from useDesignSystemEventComponentCallbacks
|
|
2180
|
+
* is preferred over direct use of this function. See Button.tsx for an example.
|
|
2181
|
+
*
|
|
2182
|
+
* The main use case of this function is to avoid adding in extra containers/divs with data-component-* props
|
|
2183
|
+
* that may result in unexpected css changes.
|
|
2184
|
+
*
|
|
2185
|
+
* @returns a react node with injected data-component-* props, if possible
|
|
2186
|
+
*/ function augmentWithDataComponentProps(node, dataComponentProps) {
|
|
2187
|
+
if (/*#__PURE__*/ React__default.isValidElement(node)) {
|
|
2188
|
+
return /*#__PURE__*/ React__default.cloneElement(node, dataComponentProps);
|
|
2189
|
+
}
|
|
2190
|
+
if (Array.isArray(node)) {
|
|
2191
|
+
return node.map((child)=>{
|
|
2192
|
+
return augmentWithDataComponentProps(child, dataComponentProps);
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2195
|
+
return node;
|
|
2196
|
+
}
|
|
2197
|
+
/**
|
|
2198
|
+
* NOTE: This is not suggested for direct usage from engineers, and should emit your own events.
|
|
2199
|
+
* See https://databricks.atlassian.net/wiki/spaces/UN/pages/2533556277/Usage+Logging+in+UI#Send-usage-logging-from-UI for more details.
|
|
2200
|
+
*
|
|
2201
|
+
* This gets the event provider component event type callbacks.
|
|
2202
|
+
* If context & componentId are not undefined, then it will check if the event is in analyticsEvents or the default analyticsEvents for that component.
|
|
2203
|
+
* If the context or componentId are undefined, then the expected behavior is to not emit any events.
|
|
2204
|
+
*
|
|
2205
|
+
* @returns Object of event callbacks
|
|
2206
|
+
*/ const useDesignSystemEventComponentCallbacks = (param)=>{
|
|
2207
|
+
let { componentType, componentId, componentSubType, analyticsEvents, valueHasNoPii, shouldStartInteraction, isInteractionSubject } = param;
|
|
2208
|
+
const context = useDesignSystemEventProviderContext();
|
|
2209
|
+
const suppressInteractionContext = useDesignSystemEventSuppressInteractionContext();
|
|
2210
|
+
// If shouldStartInteraction is explicitly true or has no suppression when shouldStartInteraction
|
|
2211
|
+
// is not defined for an onClick event, then it will start the interaction
|
|
2212
|
+
const shouldStartInteractionComplete = useMemo(()=>shouldStartInteraction || shouldStartInteraction === undefined && !suppressInteractionContext.suppressAnalyticsStartInteraction, [
|
|
2213
|
+
suppressInteractionContext,
|
|
2214
|
+
shouldStartInteraction
|
|
2215
|
+
]);
|
|
2216
|
+
const componentViewId = useStableUuidV4();
|
|
2217
|
+
const callbacks = useMemo(()=>{
|
|
2218
|
+
const dataComponentProps = componentId ? {
|
|
2219
|
+
'data-component-id': componentId,
|
|
2220
|
+
'data-component-type': componentType
|
|
2221
|
+
} : {};
|
|
2222
|
+
if (context === DefaultEmptyCallbacks || componentId === undefined) {
|
|
2223
|
+
return {
|
|
2224
|
+
onClick: ()=>{},
|
|
2225
|
+
onSubmit: ()=>{},
|
|
2226
|
+
onValueChange: ()=>{},
|
|
2227
|
+
onView: ()=>{},
|
|
2228
|
+
dataComponentProps
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2231
|
+
return {
|
|
2232
|
+
onClick: (event)=>{
|
|
2233
|
+
if (shouldTriggerCallback("onClick", analyticsEvents)) {
|
|
2234
|
+
context.callback({
|
|
2235
|
+
eventType: "onClick",
|
|
2236
|
+
componentType,
|
|
2237
|
+
componentId,
|
|
2238
|
+
componentSubType,
|
|
2239
|
+
value: undefined,
|
|
2240
|
+
shouldStartInteraction: shouldStartInteractionComplete,
|
|
2241
|
+
event,
|
|
2242
|
+
isInteractionSubject,
|
|
2243
|
+
componentViewId: componentViewId
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
},
|
|
2247
|
+
onSubmit: (payload)=>{
|
|
2248
|
+
const mode = shouldTriggerCallback("onSubmit", analyticsEvents) ? 'default' : 'associate_event_only';
|
|
2249
|
+
context.callback({
|
|
2250
|
+
eventType: "onSubmit",
|
|
2251
|
+
componentType,
|
|
2252
|
+
componentId,
|
|
2253
|
+
componentSubType,
|
|
2254
|
+
value: undefined,
|
|
2255
|
+
shouldStartInteraction: shouldStartInteractionComplete,
|
|
2256
|
+
event: payload.event,
|
|
2257
|
+
mode,
|
|
2258
|
+
referrerComponent: payload.referrerComponent,
|
|
2259
|
+
formPropertyValues: {
|
|
2260
|
+
initial: payload.initialState,
|
|
2261
|
+
final: payload.finalState
|
|
2262
|
+
}
|
|
2263
|
+
});
|
|
2264
|
+
},
|
|
2265
|
+
onValueChange: (value)=>{
|
|
2266
|
+
if (shouldTriggerCallback("onValueChange", analyticsEvents)) {
|
|
2267
|
+
context.callback({
|
|
2268
|
+
eventType: "onValueChange",
|
|
2269
|
+
componentType,
|
|
2270
|
+
componentId,
|
|
2271
|
+
componentSubType,
|
|
2272
|
+
value: valueHasNoPii ? value : undefined,
|
|
2273
|
+
shouldStartInteraction: false,
|
|
2274
|
+
componentViewId: componentViewId
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
},
|
|
2278
|
+
onView: (value)=>{
|
|
2279
|
+
if (shouldTriggerCallback("onView", analyticsEvents)) {
|
|
2280
|
+
context.callback({
|
|
2281
|
+
eventType: "onView",
|
|
2282
|
+
componentType,
|
|
2283
|
+
componentId,
|
|
2284
|
+
componentSubType,
|
|
2285
|
+
value: valueHasNoPii ? value : undefined,
|
|
2286
|
+
shouldStartInteraction: false,
|
|
2287
|
+
componentViewId: componentViewId
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
},
|
|
2291
|
+
dataComponentProps
|
|
2292
|
+
};
|
|
2293
|
+
}, [
|
|
2294
|
+
context,
|
|
2295
|
+
componentId,
|
|
2296
|
+
analyticsEvents,
|
|
2297
|
+
componentType,
|
|
2298
|
+
componentSubType,
|
|
2299
|
+
shouldStartInteractionComplete,
|
|
2300
|
+
isInteractionSubject,
|
|
2301
|
+
valueHasNoPii,
|
|
2302
|
+
componentViewId
|
|
2303
|
+
]);
|
|
2304
|
+
return callbacks;
|
|
2305
|
+
};
|
|
2306
|
+
/**
|
|
2307
|
+
* NOTE: This is not suggested for direct usage from engineers, and should use RecordEventContext instead.
|
|
2308
|
+
* See https://databricks.atlassian.net/wiki/spaces/UN/pages/2533556277/Usage+Logging+in+UI#Send-usage-logging-from-UI for more details.
|
|
2309
|
+
*
|
|
2310
|
+
* This is the Design System Event Context Provider, and is only used to pass callbacks to the design system for events such as onClick, onView, and onValueChange.
|
|
2311
|
+
*
|
|
2312
|
+
* @param children Children react elements
|
|
2313
|
+
* @param callback The event callback function
|
|
2314
|
+
* @returns Design System Event Context Provider with the children inside
|
|
2315
|
+
*/ function DesignSystemEventProvider(param) {
|
|
2316
|
+
let { children, callback } = param;
|
|
2317
|
+
const contextValue = useMemo(()=>{
|
|
2318
|
+
return {
|
|
2319
|
+
callback
|
|
2320
|
+
};
|
|
2321
|
+
}, [
|
|
2322
|
+
callback
|
|
2323
|
+
]);
|
|
2324
|
+
return /*#__PURE__*/ jsx(DesignSystemEventProviderContext.Provider, {
|
|
2325
|
+
value: contextValue,
|
|
2326
|
+
children: children
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
function getDefaultStyles(theme) {
|
|
2331
|
+
let loading = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
2332
|
+
const defaultStyles = {
|
|
2333
|
+
backgroundColor: theme.colors.actionDefaultBackgroundDefault,
|
|
2334
|
+
borderColor: theme.colors.actionDefaultBorderDefault,
|
|
2335
|
+
color: theme.colors.actionDefaultTextDefault
|
|
2336
|
+
};
|
|
2337
|
+
return {
|
|
2338
|
+
...defaultStyles,
|
|
2339
|
+
lineHeight: theme.typography.lineHeightBase,
|
|
2340
|
+
textDecoration: 'none',
|
|
2341
|
+
'&:hover': {
|
|
2342
|
+
backgroundColor: theme.colors.actionDefaultBackgroundHover,
|
|
2343
|
+
borderColor: theme.colors.actionDefaultBorderHover,
|
|
2344
|
+
color: theme.colors.actionDefaultTextHover
|
|
2345
|
+
},
|
|
2346
|
+
'&:active': {
|
|
2347
|
+
backgroundColor: loading ? theme.colors.actionDefaultBackgroundDefault : theme.colors.actionDefaultBackgroundPress,
|
|
2348
|
+
borderColor: theme.colors.actionDefaultBorderPress,
|
|
2349
|
+
color: theme.colors.actionDefaultTextPress
|
|
2350
|
+
}
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
function getPrimaryStyles(theme) {
|
|
2354
|
+
const defaultStyles = {
|
|
2355
|
+
backgroundColor: theme.colors.actionPrimaryBackgroundDefault,
|
|
2356
|
+
borderColor: 'transparent',
|
|
2357
|
+
color: theme.colors.actionPrimaryTextDefault
|
|
2358
|
+
};
|
|
2359
|
+
return {
|
|
2360
|
+
...defaultStyles,
|
|
2361
|
+
textShadow: 'none',
|
|
2362
|
+
'&:hover': {
|
|
2363
|
+
backgroundColor: theme.colors.actionPrimaryBackgroundHover,
|
|
2364
|
+
borderColor: 'transparent',
|
|
2365
|
+
color: theme.colors.actionPrimaryTextHover
|
|
2366
|
+
},
|
|
2367
|
+
'&:active': {
|
|
2368
|
+
backgroundColor: theme.colors.actionPrimaryBackgroundPress,
|
|
2369
|
+
borderColor: 'transparent',
|
|
2370
|
+
color: theme.colors.actionPrimaryTextPress
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
}
|
|
2374
|
+
function getLinkStyles$1(theme) {
|
|
2375
|
+
const defaultStyles = {
|
|
2376
|
+
backgroundColor: theme.colors.actionTertiaryBackgroundDefault,
|
|
2377
|
+
borderColor: theme.colors.actionTertiaryBackgroundDefault,
|
|
2378
|
+
color: theme.colors.actionTertiaryTextDefault
|
|
2379
|
+
};
|
|
2380
|
+
return {
|
|
2381
|
+
...defaultStyles,
|
|
2382
|
+
'&:hover': {
|
|
2383
|
+
backgroundColor: theme.colors.actionTertiaryBackgroundHover,
|
|
2384
|
+
borderColor: 'transparent',
|
|
2385
|
+
color: theme.colors.actionTertiaryTextHover
|
|
2386
|
+
},
|
|
2387
|
+
'&:active': {
|
|
2388
|
+
backgroundColor: theme.colors.actionTertiaryBackgroundPress,
|
|
2389
|
+
borderColor: 'transparent',
|
|
2390
|
+
color: theme.colors.actionTertiaryTextPress
|
|
2391
|
+
},
|
|
2392
|
+
'&[disabled]:hover': {
|
|
2393
|
+
background: 'none',
|
|
2394
|
+
color: theme.colors.actionDisabledText
|
|
2395
|
+
}
|
|
2396
|
+
};
|
|
2397
|
+
}
|
|
2398
|
+
function getPrimaryDangerStyles(theme) {
|
|
2399
|
+
const defaultStyles = {
|
|
2400
|
+
backgroundColor: theme.colors.actionDangerPrimaryBackgroundDefault,
|
|
2401
|
+
borderColor: 'transparent',
|
|
2402
|
+
color: theme.colors.actionPrimaryTextDefault
|
|
2403
|
+
};
|
|
2404
|
+
return {
|
|
2405
|
+
...defaultStyles,
|
|
2406
|
+
'&:hover': {
|
|
2407
|
+
backgroundColor: theme.colors.actionDangerPrimaryBackgroundHover,
|
|
2408
|
+
borderColor: 'transparent',
|
|
2409
|
+
color: theme.colors.actionPrimaryTextHover
|
|
2410
|
+
},
|
|
2411
|
+
'&:active': {
|
|
2412
|
+
backgroundColor: theme.colors.actionDangerPrimaryBackgroundPress,
|
|
2413
|
+
borderColor: 'transparent',
|
|
2414
|
+
color: theme.colors.actionPrimaryTextPress
|
|
2415
|
+
},
|
|
2416
|
+
'&:focus-visible': {
|
|
2417
|
+
outlineColor: theme.colors.actionDangerPrimaryBackgroundDefault
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2420
|
+
}
|
|
2421
|
+
function getSecondaryDangerStyles(theme) {
|
|
2422
|
+
const defaultStyles = {
|
|
2423
|
+
backgroundColor: theme.colors.actionDangerDefaultBackgroundDefault,
|
|
2424
|
+
borderColor: theme.colors.actionDangerDefaultBorderDefault,
|
|
2425
|
+
color: theme.colors.actionDangerDefaultTextDefault
|
|
2426
|
+
};
|
|
2427
|
+
return {
|
|
2428
|
+
...defaultStyles,
|
|
2429
|
+
'&:hover': {
|
|
2430
|
+
backgroundColor: theme.colors.actionDangerDefaultBackgroundHover,
|
|
2431
|
+
borderColor: theme.colors.actionDangerDefaultBorderHover,
|
|
2432
|
+
color: theme.colors.actionDangerDefaultTextHover
|
|
2433
|
+
},
|
|
2434
|
+
'&:active': {
|
|
2435
|
+
backgroundColor: theme.colors.actionDangerDefaultBackgroundPress,
|
|
2436
|
+
borderColor: theme.colors.actionDangerDefaultBorderPress,
|
|
2437
|
+
color: theme.colors.actionDangerDefaultTextPress
|
|
2438
|
+
},
|
|
2439
|
+
'&:focus-visible': {
|
|
2440
|
+
outlineColor: theme.colors.actionDangerPrimaryBackgroundDefault
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
}
|
|
2444
|
+
function getDisabledDefaultStyles(theme, useNewShadows) {
|
|
2445
|
+
const defaultStyles = {
|
|
2446
|
+
backgroundColor: 'transparent',
|
|
2447
|
+
borderColor: theme.colors.actionDisabledBorder,
|
|
2448
|
+
color: theme.colors.actionDisabledText,
|
|
2449
|
+
...useNewShadows && {
|
|
2450
|
+
boxShadow: 'none'
|
|
2451
|
+
}
|
|
2452
|
+
};
|
|
2453
|
+
return {
|
|
2454
|
+
...defaultStyles,
|
|
2455
|
+
'&:hover': {
|
|
2456
|
+
backgroundColor: 'transparent',
|
|
2457
|
+
borderColor: theme.colors.actionDisabledBorder,
|
|
2458
|
+
color: theme.colors.actionDisabledText
|
|
2459
|
+
},
|
|
2460
|
+
'&:active': {
|
|
2461
|
+
backgroundColor: 'transparent',
|
|
2462
|
+
borderColor: theme.colors.actionDisabledBorder,
|
|
2463
|
+
color: theme.colors.actionDisabledText
|
|
2464
|
+
}
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
function getDisabledPrimaryStyles(theme, useNewShadows) {
|
|
2468
|
+
const defaultStyles = {
|
|
2469
|
+
backgroundColor: theme.colors.actionDisabledBorder,
|
|
2470
|
+
borderColor: 'transparent',
|
|
2471
|
+
color: theme.colors.actionPrimaryTextDefault,
|
|
2472
|
+
...useNewShadows && {
|
|
2473
|
+
boxShadow: 'none'
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
return {
|
|
2477
|
+
...defaultStyles,
|
|
2478
|
+
'&:hover': {
|
|
2479
|
+
backgroundColor: theme.colors.actionDisabledBorder,
|
|
2480
|
+
borderColor: 'transparent',
|
|
2481
|
+
color: theme.colors.actionPrimaryTextDefault
|
|
2482
|
+
},
|
|
2483
|
+
'&:active': {
|
|
2484
|
+
backgroundColor: theme.colors.actionDisabledBorder,
|
|
2485
|
+
borderColor: 'transparent',
|
|
2486
|
+
color: theme.colors.actionPrimaryTextDefault
|
|
2487
|
+
}
|
|
2488
|
+
};
|
|
2489
|
+
}
|
|
2490
|
+
function getDisabledErrorStyles(theme, useNewShadows) {
|
|
2491
|
+
return getDisabledPrimaryStyles(theme, useNewShadows);
|
|
2492
|
+
}
|
|
2493
|
+
function getDisabledTertiaryStyles(theme, useNewShadows) {
|
|
2494
|
+
const defaultStyles = {
|
|
2495
|
+
backgroundColor: theme.colors.actionTertiaryBackgroundDefault,
|
|
2496
|
+
borderColor: 'transparent',
|
|
2497
|
+
color: theme.colors.actionDisabledText,
|
|
2498
|
+
...useNewShadows && {
|
|
2499
|
+
boxShadow: 'none'
|
|
2500
|
+
}
|
|
2501
|
+
};
|
|
2502
|
+
return {
|
|
2503
|
+
...defaultStyles,
|
|
2504
|
+
'&:hover': {
|
|
2505
|
+
backgroundColor: theme.colors.actionTertiaryBackgroundDefault,
|
|
2506
|
+
borderColor: 'transparent',
|
|
2507
|
+
color: theme.colors.actionDisabledText
|
|
2508
|
+
},
|
|
2509
|
+
'&:active': {
|
|
2510
|
+
backgroundColor: theme.colors.actionTertiaryBackgroundDefault,
|
|
2511
|
+
borderColor: 'transparent',
|
|
2512
|
+
color: theme.colors.actionDisabledText
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
function getDisabledSplitButtonStyles(theme, useNewShadows) {
|
|
2517
|
+
const defaultStyles = {
|
|
2518
|
+
backgroundColor: theme.colors.actionDefaultBackgroundDefault,
|
|
2519
|
+
borderColor: theme.colors.actionDisabledBorder,
|
|
2520
|
+
color: theme.colors.actionDisabledText,
|
|
2521
|
+
...useNewShadows && {
|
|
2522
|
+
boxShadow: 'none'
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
return {
|
|
2526
|
+
...defaultStyles,
|
|
2527
|
+
'&:hover': {
|
|
2528
|
+
backgroundColor: theme.colors.actionDefaultBackgroundDefault,
|
|
2529
|
+
borderColor: theme.colors.actionDisabledBorder,
|
|
2530
|
+
color: theme.colors.actionDisabledText
|
|
2531
|
+
},
|
|
2532
|
+
'&:active': {
|
|
2533
|
+
backgroundColor: theme.colors.actionDefaultBackgroundDefault,
|
|
2534
|
+
borderColor: theme.colors.actionDisabledBorder,
|
|
2535
|
+
color: theme.colors.actionDisabledText
|
|
2536
|
+
}
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
function getDisabledPrimarySplitButtonStyles(theme, useNewShadows) {
|
|
2540
|
+
const defaultStyles = {
|
|
2541
|
+
backgroundColor: theme.colors.actionDisabledBorder,
|
|
2542
|
+
color: theme.colors.actionPrimaryTextDefault,
|
|
2543
|
+
...useNewShadows && {
|
|
2544
|
+
boxShadow: 'none'
|
|
2545
|
+
}
|
|
2546
|
+
};
|
|
2547
|
+
return {
|
|
2548
|
+
...defaultStyles,
|
|
2549
|
+
'&:hover': {
|
|
2550
|
+
backgroundColor: theme.colors.actionDisabledBorder,
|
|
2551
|
+
color: theme.colors.actionPrimaryTextDefault
|
|
2552
|
+
},
|
|
2553
|
+
'&:active': {
|
|
2554
|
+
backgroundColor: theme.colors.actionDisabledBorder,
|
|
2555
|
+
color: theme.colors.actionPrimaryTextDefault
|
|
2556
|
+
}
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
const FormContext = /*#__PURE__*/ React__default.createContext({
|
|
2561
|
+
componentId: undefined,
|
|
2562
|
+
isSubmitting: false,
|
|
2563
|
+
formRef: undefined
|
|
2564
|
+
});
|
|
2565
|
+
const useFormContext = ()=>React__default.useContext(FormContext);
|
|
2566
|
+
/**
|
|
2567
|
+
* Form is a wrapper around the form element that allows us to track the active element before the form is submitted.
|
|
2568
|
+
* This is useful for analytics purposes to know what component was last focused when the form was sent for submission.
|
|
2569
|
+
*
|
|
2570
|
+
* NOTE: Form component cannot be nested.
|
|
2571
|
+
*/ const Form = (param)=>{
|
|
2572
|
+
let { children, componentId, analyticsEvents = [
|
|
2573
|
+
DesignSystemEventProviderAnalyticsEventTypes.OnSubmit
|
|
2574
|
+
], onSubmit, shouldStartInteraction, ...otherProps } = param;
|
|
2575
|
+
const formContext = useFormContext();
|
|
2576
|
+
const formRef = useRef(null);
|
|
2577
|
+
const eventRef = useRef(null);
|
|
2578
|
+
if (formContext.componentId !== undefined) {
|
|
2579
|
+
throw new Error('DuBois Form component cannot be nested');
|
|
2580
|
+
}
|
|
2581
|
+
const memoizedAnalyticsEvents = useMemo(()=>analyticsEvents, [
|
|
2582
|
+
analyticsEvents
|
|
2583
|
+
]);
|
|
2584
|
+
const eventContext = useDesignSystemEventComponentCallbacks({
|
|
2585
|
+
componentType: DesignSystemEventProviderComponentTypes.Form,
|
|
2586
|
+
componentId,
|
|
2587
|
+
analyticsEvents: memoizedAnalyticsEvents,
|
|
2588
|
+
shouldStartInteraction
|
|
2589
|
+
});
|
|
2590
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
2591
|
+
const onSubmitHandler = useCallback(async (e)=>{
|
|
2592
|
+
try {
|
|
2593
|
+
setIsSubmitting(true);
|
|
2594
|
+
eventContext.onSubmit({
|
|
2595
|
+
event: e,
|
|
2596
|
+
initialState: undefined,
|
|
2597
|
+
finalState: undefined,
|
|
2598
|
+
referrerComponent: extractReferrerComponent()
|
|
2599
|
+
});
|
|
2600
|
+
await onSubmit(e);
|
|
2601
|
+
} finally{
|
|
2602
|
+
setIsSubmitting(false);
|
|
2603
|
+
}
|
|
2604
|
+
}, [
|
|
2605
|
+
eventContext,
|
|
2606
|
+
onSubmit
|
|
2607
|
+
]);
|
|
2608
|
+
const contextValue = useMemo(()=>({
|
|
2609
|
+
componentId,
|
|
2610
|
+
isSubmitting,
|
|
2611
|
+
eventRef,
|
|
2612
|
+
formRef
|
|
2613
|
+
}), [
|
|
2614
|
+
componentId,
|
|
2615
|
+
isSubmitting
|
|
2616
|
+
]);
|
|
2617
|
+
return /*#__PURE__*/ jsx(FormContext.Provider, {
|
|
2618
|
+
value: contextValue,
|
|
2619
|
+
children: /*#__PURE__*/ jsxs("form", {
|
|
2620
|
+
onSubmit: onSubmitHandler,
|
|
2621
|
+
...otherProps,
|
|
2622
|
+
ref: formRef,
|
|
2623
|
+
...eventContext.dataComponentProps,
|
|
2624
|
+
children: [
|
|
2625
|
+
isSubmitting && /*#__PURE__*/ jsx(LoadingState, {
|
|
2626
|
+
description: componentId
|
|
2627
|
+
}),
|
|
2628
|
+
children
|
|
2629
|
+
]
|
|
2630
|
+
})
|
|
2631
|
+
});
|
|
2632
|
+
};
|
|
2633
|
+
/**
|
|
2634
|
+
* Form is a wrapper around the Form DuBois component to better integrate with React Hook Form and to track the active
|
|
2635
|
+
* element before the form is submitted. This is useful for analytics purposes to know what component was last focused
|
|
2636
|
+
* when the form was sent for submission, along with being able to pass in the initial and final values of the form.
|
|
2637
|
+
*
|
|
2638
|
+
* Internal implementation details:
|
|
2639
|
+
* The form is wrapped in a Form component to share implementation details along with associating the HTML form
|
|
2640
|
+
* submission event with interaction details. The Form component does not emit analytics events, but the RHF
|
|
2641
|
+
* component will emit the events once the RHF lifecycle events occur so we can relay the form property values.
|
|
2642
|
+
*
|
|
2643
|
+
* NOTE: Form components cannot be nested.
|
|
2644
|
+
*/ const RhfForm = (param)=>{
|
|
2645
|
+
let { handleSubmit, handleValid, handleInvalid, processFinalPropertyValues, children, componentId, analyticsEvents = [
|
|
2646
|
+
DesignSystemEventProviderAnalyticsEventTypes.OnSubmit
|
|
2647
|
+
], shouldStartInteraction, initialState, ...otherProps } = param;
|
|
2648
|
+
const memoizedAnalyticsEvents = useMemo(()=>analyticsEvents, [
|
|
2649
|
+
analyticsEvents
|
|
2650
|
+
]);
|
|
2651
|
+
const eventContext = useDesignSystemEventComponentCallbacks({
|
|
2652
|
+
componentType: DesignSystemEventProviderComponentTypes.Form,
|
|
2653
|
+
componentId,
|
|
2654
|
+
analyticsEvents: memoizedAnalyticsEvents,
|
|
2655
|
+
shouldStartInteraction
|
|
2656
|
+
});
|
|
2657
|
+
const onValidWrapper = useCallback(async (data, e)=>{
|
|
2658
|
+
const refinedData = processFinalPropertyValues ? processFinalPropertyValues(data) : data;
|
|
2659
|
+
eventContext.onSubmit({
|
|
2660
|
+
event: e,
|
|
2661
|
+
initialState,
|
|
2662
|
+
finalState: refinedData,
|
|
2663
|
+
referrerComponent: extractReferrerComponent()
|
|
2664
|
+
});
|
|
2665
|
+
await handleValid(data, e);
|
|
2666
|
+
}, [
|
|
2667
|
+
eventContext,
|
|
2668
|
+
initialState,
|
|
2669
|
+
handleValid,
|
|
2670
|
+
processFinalPropertyValues
|
|
2671
|
+
]);
|
|
2672
|
+
const onInvalidWrapper = useCallback(async (errors, e)=>{
|
|
2673
|
+
eventContext.onSubmit({
|
|
2674
|
+
event: e,
|
|
2675
|
+
initialState,
|
|
2676
|
+
finalState: undefined,
|
|
2677
|
+
referrerComponent: extractReferrerComponent()
|
|
2678
|
+
});
|
|
2679
|
+
if (handleInvalid) {
|
|
2680
|
+
await handleInvalid(errors, e);
|
|
2681
|
+
}
|
|
2682
|
+
}, [
|
|
2683
|
+
eventContext,
|
|
2684
|
+
initialState,
|
|
2685
|
+
handleInvalid
|
|
2686
|
+
]);
|
|
2687
|
+
const onSubmitWrapper = useCallback(async (e)=>{
|
|
2688
|
+
await handleSubmit(onValidWrapper, onInvalidWrapper)(e);
|
|
2689
|
+
}, [
|
|
2690
|
+
handleSubmit,
|
|
2691
|
+
onInvalidWrapper,
|
|
2692
|
+
onValidWrapper
|
|
2693
|
+
]);
|
|
2694
|
+
return /*#__PURE__*/ jsx(Form, {
|
|
2695
|
+
componentId: componentId,
|
|
2696
|
+
analyticsEvents: [],
|
|
2697
|
+
onSubmit: onSubmitWrapper,
|
|
2698
|
+
...otherProps,
|
|
2699
|
+
children: children
|
|
2700
|
+
});
|
|
2701
|
+
};
|
|
2702
|
+
function extractReferrerComponent() {
|
|
2703
|
+
const activeElement = document.activeElement;
|
|
2704
|
+
const { componentType, componentId } = activeElement?.dataset ?? {};
|
|
2705
|
+
if (componentType && componentId) {
|
|
2706
|
+
return {
|
|
2707
|
+
type: componentType,
|
|
2708
|
+
id: componentId
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
return undefined;
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
const SMALL_BUTTON_HEIGHT = 24;
|
|
2715
|
+
const buttonStylesCache = new WeakMap();
|
|
2716
|
+
const getMemoizedButtonEmotionStyles = (props)=>{
|
|
2717
|
+
// Theme is a large object, so cache it by ref using a WeakMap,
|
|
2718
|
+
// and then JSON.stringify() the rest of the props as the cache key.
|
|
2719
|
+
const { theme, ...rest } = props;
|
|
2720
|
+
const themeCache = buttonStylesCache.get(theme) || new Map();
|
|
2721
|
+
if (!buttonStylesCache.has(theme)) {
|
|
2722
|
+
buttonStylesCache.set(theme, themeCache);
|
|
2723
|
+
}
|
|
2724
|
+
const cacheKey = JSON.stringify(rest);
|
|
2725
|
+
const cachedStyles = themeCache.get(cacheKey);
|
|
2726
|
+
if (cachedStyles) {
|
|
2727
|
+
return cachedStyles;
|
|
2728
|
+
}
|
|
2729
|
+
const styles = getButtonEmotionStyles(props);
|
|
2730
|
+
themeCache.set(cacheKey, styles);
|
|
2731
|
+
return styles;
|
|
2732
|
+
};
|
|
2733
|
+
function getEndIconClsName(theme) {
|
|
2734
|
+
return `${theme.general.iconfontCssPrefix}-btn-end-icon`;
|
|
2735
|
+
}
|
|
2736
|
+
const getButtonEmotionStyles = (param)=>{
|
|
2737
|
+
let { theme, classNamePrefix, loading, withIcon, onlyIcon, isAnchor, enableAnimation, size, type, useFocusPseudoClass, forceIconStyles, danger, useNewShadows, useNewBorderRadii } = param;
|
|
2738
|
+
const clsIcon = `.${theme.general.iconfontCssPrefix}`;
|
|
2739
|
+
const clsEndIcon = `.${getEndIconClsName(theme)}`;
|
|
2740
|
+
const clsLoadingIcon = `.${classNamePrefix}-btn-loading-icon`;
|
|
2741
|
+
const clsIconOnly = `.${classNamePrefix}-btn-icon-only`;
|
|
2742
|
+
const classPrimary = `.${classNamePrefix}-btn-primary`;
|
|
2743
|
+
const classLink = `.${classNamePrefix}-btn-link`;
|
|
2744
|
+
const classDangerous = `.${classNamePrefix}-btn-dangerous`;
|
|
2745
|
+
const tertiaryColors = {
|
|
2746
|
+
background: theme.colors.actionTertiaryBackgroundDefault,
|
|
2747
|
+
color: theme.colors.actionTertiaryTextDefault,
|
|
2748
|
+
...useNewShadows && {
|
|
2749
|
+
boxShadow: 'none'
|
|
2750
|
+
},
|
|
2751
|
+
'&:hover': {
|
|
2752
|
+
background: theme.colors.actionTertiaryBackgroundHover,
|
|
2753
|
+
color: theme.colors.actionTertiaryTextHover
|
|
2754
|
+
},
|
|
2755
|
+
'&:active': {
|
|
2756
|
+
background: theme.colors.actionTertiaryBackgroundPress,
|
|
2757
|
+
color: theme.colors.actionTertiaryTextPress
|
|
2758
|
+
}
|
|
2759
|
+
};
|
|
2760
|
+
const iconCss = {
|
|
2761
|
+
fontSize: theme.general.iconFontSize,
|
|
2762
|
+
lineHeight: 0,
|
|
2763
|
+
...size === 'small' && {
|
|
2764
|
+
lineHeight: theme.typography.lineHeightSm,
|
|
2765
|
+
height: 16,
|
|
2766
|
+
...(onlyIcon || forceIconStyles) && {
|
|
2767
|
+
fontSize: 16
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
};
|
|
2771
|
+
const inactiveIconCss = {
|
|
2772
|
+
color: theme.colors.textSecondary
|
|
2773
|
+
};
|
|
2774
|
+
const endIconCssSelector = `span > ${clsEndIcon} > ${clsIcon}`;
|
|
2775
|
+
const styles = {
|
|
2776
|
+
lineHeight: theme.typography.lineHeightBase,
|
|
2777
|
+
boxShadow: useNewShadows ? theme.shadows.xs : 'none',
|
|
2778
|
+
height: theme.general.heightSm,
|
|
2779
|
+
display: 'inline-flex',
|
|
2780
|
+
alignItems: 'center',
|
|
2781
|
+
justifyContent: 'center',
|
|
2782
|
+
verticalAlign: 'middle',
|
|
2783
|
+
...useNewBorderRadii && {
|
|
2784
|
+
borderRadius: theme.borders.borderRadiusSm
|
|
2785
|
+
},
|
|
2786
|
+
...!onlyIcon && !forceIconStyles && {
|
|
2787
|
+
'&&': {
|
|
2788
|
+
padding: '4px 12px',
|
|
2789
|
+
...size === 'small' && {
|
|
2790
|
+
padding: '0 8px'
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
},
|
|
2794
|
+
...(onlyIcon || forceIconStyles) && {
|
|
2795
|
+
width: theme.general.heightSm
|
|
2796
|
+
},
|
|
2797
|
+
...size === 'small' && {
|
|
2798
|
+
height: SMALL_BUTTON_HEIGHT,
|
|
2799
|
+
lineHeight: theme.typography.lineHeightBase,
|
|
2800
|
+
...(onlyIcon || forceIconStyles) && {
|
|
2801
|
+
width: SMALL_BUTTON_HEIGHT,
|
|
2802
|
+
paddingTop: 0,
|
|
2803
|
+
paddingBottom: 0,
|
|
2804
|
+
verticalAlign: 'middle'
|
|
2805
|
+
}
|
|
2806
|
+
},
|
|
2807
|
+
'&:focus-visible': {
|
|
2808
|
+
outlineStyle: 'solid',
|
|
2809
|
+
outlineWidth: '2px',
|
|
2810
|
+
outlineOffset: '1px',
|
|
2811
|
+
outlineColor: theme.isDarkMode ? theme.colors.actionDefaultBorderFocus : theme.colors.actionDefaultBorderFocus
|
|
2812
|
+
},
|
|
2813
|
+
...getDefaultStyles(theme, loading),
|
|
2814
|
+
[`&${classPrimary}`]: {
|
|
2815
|
+
...getPrimaryStyles(theme)
|
|
2816
|
+
},
|
|
2817
|
+
[`&${classLink}`]: {
|
|
2818
|
+
...getLinkStyles$1(theme),
|
|
2819
|
+
...type === 'link' && {
|
|
2820
|
+
padding: 'unset',
|
|
2821
|
+
height: 'auto',
|
|
2822
|
+
border: 'none',
|
|
2823
|
+
boxShadow: 'none',
|
|
2824
|
+
'&[disabled],&:hover': {
|
|
2825
|
+
background: 'none'
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
},
|
|
2829
|
+
[`&${classDangerous}${classPrimary}`]: {
|
|
2830
|
+
...getPrimaryDangerStyles(theme)
|
|
2831
|
+
},
|
|
2832
|
+
[`&${classDangerous}`]: {
|
|
2833
|
+
...getSecondaryDangerStyles(theme)
|
|
2834
|
+
},
|
|
2835
|
+
[`&[disabled]`]: {
|
|
2836
|
+
...getDisabledDefaultStyles(theme, useNewShadows)
|
|
2837
|
+
},
|
|
2838
|
+
[`&${classLink}:disabled`]: {
|
|
2839
|
+
...getDisabledTertiaryStyles(theme, useNewShadows)
|
|
2840
|
+
},
|
|
2841
|
+
[`&${classDangerous}:disabled`]: {
|
|
2842
|
+
...getDisabledErrorStyles(theme, useNewShadows)
|
|
2843
|
+
},
|
|
2844
|
+
[`&${classPrimary}:disabled`]: {
|
|
2845
|
+
...getDisabledPrimaryStyles(theme, useNewShadows)
|
|
2846
|
+
},
|
|
2847
|
+
[`&[disabled], &${classDangerous}:disabled`]: {
|
|
2848
|
+
...useNewShadows && {
|
|
2849
|
+
boxShadow: 'none'
|
|
2850
|
+
},
|
|
2851
|
+
...(onlyIcon || forceIconStyles) && {
|
|
2852
|
+
backgroundColor: 'transparent',
|
|
2853
|
+
'&:hover': {
|
|
2854
|
+
backgroundColor: 'transparent'
|
|
2855
|
+
},
|
|
2856
|
+
'&:active': {
|
|
2857
|
+
backgroundColor: 'transparent'
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
},
|
|
2861
|
+
[`&[disabled] > ${clsIcon}`]: {
|
|
2862
|
+
color: 'inherit !important'
|
|
2863
|
+
},
|
|
2864
|
+
[clsLoadingIcon]: {
|
|
2865
|
+
display: 'none'
|
|
2866
|
+
},
|
|
2867
|
+
// Loading styles
|
|
2868
|
+
...loading && {
|
|
2869
|
+
'::before': {
|
|
2870
|
+
opacity: 0
|
|
2871
|
+
},
|
|
2872
|
+
cursor: 'default',
|
|
2873
|
+
[`${clsLoadingIcon}`]: {
|
|
2874
|
+
...onlyIcon ? {
|
|
2875
|
+
// In case of only icon, the icon is already centered but vertically not aligned, this fixes that
|
|
2876
|
+
verticalAlign: 'middle'
|
|
2877
|
+
} : {
|
|
2878
|
+
// Position loading indicator in center
|
|
2879
|
+
// This would break vertical centering of loading circle when onlyIcon is true
|
|
2880
|
+
position: 'absolute'
|
|
2881
|
+
},
|
|
2882
|
+
// Re-enable animation for the loading spinner, since it can be disabled by the global animation CSS.
|
|
2883
|
+
svg: {
|
|
2884
|
+
animationDuration: '1s !important'
|
|
2885
|
+
}
|
|
2886
|
+
},
|
|
2887
|
+
[`& > ${clsLoadingIcon} .anticon`]: {
|
|
2888
|
+
paddingRight: 0
|
|
2889
|
+
},
|
|
2890
|
+
[`> :not(${clsLoadingIcon})`]: {
|
|
2891
|
+
// Hide all content except loading icon
|
|
2892
|
+
opacity: 0,
|
|
2893
|
+
visibility: 'hidden',
|
|
2894
|
+
// Add horizontal space for icon
|
|
2895
|
+
...withIcon && {
|
|
2896
|
+
paddingLeft: theme.general.iconFontSize + theme.spacing.xs
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
},
|
|
2900
|
+
// Icon styles
|
|
2901
|
+
[`> ${clsIcon} + span, > span + ${clsIcon}`]: {
|
|
2902
|
+
marginRight: 0,
|
|
2903
|
+
marginLeft: theme.spacing.xs
|
|
2904
|
+
},
|
|
2905
|
+
[`> ${clsIcon}`]: iconCss,
|
|
2906
|
+
[`> ${endIconCssSelector}`]: {
|
|
2907
|
+
...iconCss,
|
|
2908
|
+
marginLeft: size === 'small' ? theme.spacing.xs : theme.spacing.sm
|
|
2909
|
+
},
|
|
2910
|
+
...!type && !danger && {
|
|
2911
|
+
[`&:enabled:not(:hover):not(:active) > ${clsIcon}`]: inactiveIconCss
|
|
2912
|
+
},
|
|
2913
|
+
...!type && !danger && {
|
|
2914
|
+
[`&:enabled:not(:hover):not(:active) > ${endIconCssSelector}`]: inactiveIconCss
|
|
2915
|
+
},
|
|
2916
|
+
// Disable animations
|
|
2917
|
+
[`&[${classNamePrefix}-click-animating-without-extra-node='true']::after`]: {
|
|
2918
|
+
display: 'none'
|
|
2919
|
+
},
|
|
2920
|
+
[`&${clsIconOnly}`]: {
|
|
2921
|
+
border: 'none',
|
|
2922
|
+
...useNewShadows && {
|
|
2923
|
+
boxShadow: 'none'
|
|
2924
|
+
},
|
|
2925
|
+
[`&:enabled:not(${classLink})`]: {
|
|
2926
|
+
...tertiaryColors,
|
|
2927
|
+
color: theme.colors.textSecondary,
|
|
2928
|
+
'&:hover > .anticon': {
|
|
2929
|
+
color: tertiaryColors['&:hover'].color,
|
|
2930
|
+
...danger && {
|
|
2931
|
+
color: theme.colors.actionDangerDefaultTextHover
|
|
2932
|
+
}
|
|
2933
|
+
},
|
|
2934
|
+
'&:active > .anticon': {
|
|
2935
|
+
color: tertiaryColors['&:active'].color,
|
|
2936
|
+
...danger && {
|
|
2937
|
+
color: theme.colors.actionDangerDefaultTextPress
|
|
2938
|
+
}
|
|
2939
|
+
},
|
|
2940
|
+
...loading && {
|
|
2941
|
+
'&&, &:hover, &:active': {
|
|
2942
|
+
backgroundColor: 'transparent'
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
},
|
|
2946
|
+
[`&:enabled:not(${classLink}) > .anticon`]: {
|
|
2947
|
+
color: theme.colors.textSecondary,
|
|
2948
|
+
...danger && {
|
|
2949
|
+
color: theme.colors.actionDangerDefaultTextDefault
|
|
2950
|
+
}
|
|
2951
|
+
},
|
|
2952
|
+
...isAnchor && {
|
|
2953
|
+
lineHeight: `${theme.general.heightSm}px`,
|
|
2954
|
+
...getLinkStyles$1(theme),
|
|
2955
|
+
'&:disabled': {
|
|
2956
|
+
color: theme.colors.actionDisabledText
|
|
2957
|
+
}
|
|
2958
|
+
},
|
|
2959
|
+
...loading && {
|
|
2960
|
+
'&&, &:hover, &:active': {
|
|
2961
|
+
backgroundColor: 'transparent'
|
|
2962
|
+
}
|
|
2963
|
+
},
|
|
2964
|
+
'&[disabled]:hover': {
|
|
2965
|
+
backgroundColor: 'transparent'
|
|
2966
|
+
}
|
|
2967
|
+
},
|
|
2968
|
+
[`&:focus`]: {
|
|
2969
|
+
...useFocusPseudoClass && {
|
|
2970
|
+
outlineStyle: 'solid',
|
|
2971
|
+
outlineWidth: '2px',
|
|
2972
|
+
outlineOffset: '1px',
|
|
2973
|
+
outlineColor: theme.isDarkMode ? theme.colors.actionDefaultBorderFocus : theme.colors.actionDefaultBorderFocus
|
|
2974
|
+
},
|
|
2975
|
+
[`${clsLoadingIcon}`]: {
|
|
2976
|
+
...onlyIcon && {
|
|
2977
|
+
// Mitigate wrong left offset for loading state with onlyIcon
|
|
2978
|
+
left: 0
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
},
|
|
2982
|
+
...forceIconStyles && {
|
|
2983
|
+
padding: '0 6px',
|
|
2984
|
+
lineHeight: theme.typography.lineHeightSm,
|
|
2985
|
+
color: theme.colors.textSecondary,
|
|
2986
|
+
...loading && {
|
|
2987
|
+
'&&, &:hover, &:active': {
|
|
2988
|
+
backgroundColor: 'transparent',
|
|
2989
|
+
borderColor: theme.colors.actionDefaultBorderDefault
|
|
2990
|
+
},
|
|
2991
|
+
'&[disabled], &[disabled]:hover, &[disabled]:active': {
|
|
2992
|
+
backgroundColor: 'transparent',
|
|
2993
|
+
borderColor: 'transparent'
|
|
2994
|
+
}
|
|
2995
|
+
},
|
|
2996
|
+
'& > span': {
|
|
2997
|
+
verticalAlign: -1,
|
|
2998
|
+
height: theme.general.heightSm / 2,
|
|
2999
|
+
width: theme.general.heightSm / 2
|
|
3000
|
+
},
|
|
3001
|
+
[`& > ${clsLoadingIcon} .anticon`]: {
|
|
3002
|
+
// left: `calc(50% - 6px)!important`,
|
|
3003
|
+
height: theme.general.heightSm / 2,
|
|
3004
|
+
width: theme.general.heightSm / 2,
|
|
3005
|
+
padding: 0
|
|
3006
|
+
}
|
|
3007
|
+
},
|
|
3008
|
+
...getAnimationCss(enableAnimation)
|
|
3009
|
+
};
|
|
3010
|
+
// Moved outside main style object because state & selector matching in the already existing object keys can create bugs and unwanted overwrites
|
|
3011
|
+
const typeStyles = {
|
|
3012
|
+
...type === 'tertiary' && {
|
|
3013
|
+
[`&:enabled:not(${clsIconOnly})`]: tertiaryColors,
|
|
3014
|
+
[`&${classLink}[disabled]`]: {
|
|
3015
|
+
...getDisabledTertiaryStyles(theme, useNewShadows)
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
};
|
|
3019
|
+
const importantStyles = importantify(styles);
|
|
3020
|
+
const importantTypeStyles = importantify(typeStyles);
|
|
3021
|
+
return /*#__PURE__*/ css(importantStyles, importantTypeStyles);
|
|
3022
|
+
};
|
|
3023
|
+
const Button = /* #__PURE__ */ (()=>{
|
|
3024
|
+
const Button = /*#__PURE__*/ forwardRef(function Button(// Keep size out of props passed to AntD to make deprecation and eventual removal have 0 impact
|
|
3025
|
+
param, ref) {
|
|
3026
|
+
let { dangerouslySetAntdProps, children, size, type, loading: loadingProp, loadingDescription, endIcon, onClick, dangerouslySetForceIconStyles, dangerouslyUseFocusPseudoClass, dangerouslyAppendWrapperCss, componentId, analyticsEvents, shouldStartInteraction, ...props } = param;
|
|
3027
|
+
const emitOnView = safex('databricks.fe.observability.defaultButtonComponentView', true);
|
|
3028
|
+
const formContext = useFormContext();
|
|
3029
|
+
const { theme, classNamePrefix } = useDesignSystemTheme();
|
|
3030
|
+
const { useNewShadows, useNewBorderRadii } = useDesignSystemSafexFlags();
|
|
3031
|
+
const memoizedAnalyticsEvents = useMemo(()=>analyticsEvents ?? (emitOnView ? [
|
|
3032
|
+
DesignSystemEventProviderAnalyticsEventTypes.OnClick,
|
|
3033
|
+
DesignSystemEventProviderAnalyticsEventTypes.OnView
|
|
3034
|
+
] : [
|
|
3035
|
+
DesignSystemEventProviderAnalyticsEventTypes.OnClick
|
|
3036
|
+
]), [
|
|
3037
|
+
analyticsEvents,
|
|
3038
|
+
emitOnView
|
|
3039
|
+
]);
|
|
3040
|
+
const eventContext = useDesignSystemEventComponentCallbacks({
|
|
3041
|
+
componentType: DesignSystemEventProviderComponentTypes.Button,
|
|
3042
|
+
componentId,
|
|
3043
|
+
analyticsEvents: memoizedAnalyticsEvents,
|
|
3044
|
+
shouldStartInteraction,
|
|
3045
|
+
// If the button is a submit button and is part of a form, it is not the subject of the interaction, the form submission is
|
|
3046
|
+
isInteractionSubject: !(props.htmlType === 'submit' && formContext.componentId)
|
|
3047
|
+
});
|
|
3048
|
+
const clsEndIcon = getEndIconClsName(theme);
|
|
3049
|
+
const loadingCls = `${classNamePrefix}-btn-loading-icon`;
|
|
3050
|
+
const { elementRef: buttonRef } = useNotifyOnFirstView({
|
|
3051
|
+
onView: eventContext.onView
|
|
3052
|
+
});
|
|
3053
|
+
useImperativeHandle(ref, ()=>buttonRef.current);
|
|
3054
|
+
const loading = loadingProp ?? (props.htmlType === 'submit' && formContext.isSubmitting);
|
|
3055
|
+
// Needed to keep backwards compatibility and support existing unit tests
|
|
3056
|
+
useEffect(()=>{
|
|
3057
|
+
if (buttonRef.current) {
|
|
3058
|
+
if (loading) {
|
|
3059
|
+
buttonRef.current.setAttribute('loading', 'true');
|
|
3060
|
+
buttonRef.current.classList.add(`${classNamePrefix}-btn-loading`);
|
|
3061
|
+
} else {
|
|
3062
|
+
buttonRef.current.setAttribute('loading', 'false');
|
|
3063
|
+
buttonRef.current.classList.remove(`${classNamePrefix}-btn-loading`);
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
}, [
|
|
3067
|
+
loading,
|
|
3068
|
+
classNamePrefix,
|
|
3069
|
+
buttonRef
|
|
3070
|
+
]);
|
|
3071
|
+
const iconOnly = Boolean((props.icon || endIcon) && !children);
|
|
3072
|
+
const handleClick = useCallback((event)=>{
|
|
3073
|
+
if (loading) {
|
|
3074
|
+
return;
|
|
3075
|
+
}
|
|
3076
|
+
eventContext.onClick(event);
|
|
3077
|
+
if (props.htmlType === 'submit' && formContext.formRef?.current) {
|
|
3078
|
+
event.preventDefault();
|
|
3079
|
+
formContext.formRef.current.requestSubmit();
|
|
3080
|
+
}
|
|
3081
|
+
onClick?.(event);
|
|
3082
|
+
}, [
|
|
3083
|
+
loading,
|
|
3084
|
+
props.htmlType,
|
|
3085
|
+
formContext.formRef,
|
|
3086
|
+
eventContext,
|
|
3087
|
+
onClick
|
|
3088
|
+
]);
|
|
3089
|
+
const loadingSpinner = /*#__PURE__*/ jsx(Spinner, {
|
|
3090
|
+
className: loadingCls,
|
|
3091
|
+
animationDuration: 8,
|
|
3092
|
+
inheritColor: true,
|
|
3093
|
+
label: "loading",
|
|
3094
|
+
"aria-label": "loading",
|
|
3095
|
+
loadingDescription: loadingDescription ?? componentId,
|
|
3096
|
+
css: {
|
|
3097
|
+
color: 'inherit !important',
|
|
3098
|
+
pointerEvents: 'none',
|
|
3099
|
+
...!iconOnly && !dangerouslySetForceIconStyles && {
|
|
3100
|
+
'.anticon': {
|
|
3101
|
+
verticalAlign: '-0.2em'
|
|
3102
|
+
}
|
|
3103
|
+
},
|
|
3104
|
+
'[aria-hidden="true"]': {
|
|
3105
|
+
display: 'inline'
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
});
|
|
3109
|
+
return /*#__PURE__*/ jsx(DesignSystemAntDConfigProvider, {
|
|
3110
|
+
children: /*#__PURE__*/ jsx(Button$1, {
|
|
3111
|
+
...addDebugOutlineIfEnabled(),
|
|
3112
|
+
...props,
|
|
3113
|
+
css: getMemoizedButtonEmotionStyles({
|
|
3114
|
+
theme,
|
|
3115
|
+
classNamePrefix,
|
|
3116
|
+
loading: Boolean(loading),
|
|
3117
|
+
withIcon: Boolean(props.icon),
|
|
3118
|
+
onlyIcon: iconOnly,
|
|
3119
|
+
isAnchor: Boolean(props.href && !type),
|
|
3120
|
+
danger: Boolean(props.danger),
|
|
3121
|
+
enableAnimation: theme.options.enableAnimation,
|
|
3122
|
+
size: size || 'middle',
|
|
3123
|
+
type,
|
|
3124
|
+
forceIconStyles: Boolean(dangerouslySetForceIconStyles),
|
|
3125
|
+
useFocusPseudoClass: Boolean(dangerouslyUseFocusPseudoClass),
|
|
3126
|
+
useNewShadows,
|
|
3127
|
+
useNewBorderRadii
|
|
3128
|
+
}),
|
|
3129
|
+
href: props.disabled ? undefined : props.href,
|
|
3130
|
+
...dangerouslySetAntdProps,
|
|
3131
|
+
onClick: handleClick,
|
|
3132
|
+
icon: loading ? loadingSpinner : props.icon,
|
|
3133
|
+
ref: buttonRef,
|
|
3134
|
+
type: type === 'tertiary' ? 'link' : type,
|
|
3135
|
+
...eventContext.dataComponentProps,
|
|
3136
|
+
children: children && /*#__PURE__*/ jsxs("span", {
|
|
3137
|
+
style: {
|
|
3138
|
+
visibility: loading ? 'hidden' : undefined,
|
|
3139
|
+
display: 'inline-flex',
|
|
3140
|
+
alignItems: 'center',
|
|
3141
|
+
...dangerouslyAppendWrapperCss
|
|
3142
|
+
},
|
|
3143
|
+
children: [
|
|
3144
|
+
children,
|
|
3145
|
+
endIcon && /*#__PURE__*/ jsx("span", {
|
|
3146
|
+
className: clsEndIcon,
|
|
3147
|
+
style: {
|
|
3148
|
+
display: 'inline-flex',
|
|
3149
|
+
alignItems: 'center'
|
|
3150
|
+
},
|
|
3151
|
+
children: endIcon
|
|
3152
|
+
})
|
|
3153
|
+
]
|
|
3154
|
+
})
|
|
3155
|
+
})
|
|
3156
|
+
});
|
|
3157
|
+
});
|
|
3158
|
+
// This is needed for other Ant components that wrap Button, such as Tooltip, to correctly
|
|
3159
|
+
// identify it as an Ant button.
|
|
3160
|
+
// This should be removed if the component is rewritten to no longer be a wrapper around Ant.
|
|
3161
|
+
// See: https://github.com/ant-design/ant-design/blob/6dd39c1f89b4d6632e6ed022ff1bc275ca1e0f1f/components/button/button.tsx#L291
|
|
3162
|
+
Button.__ANT_BUTTON = true;
|
|
3163
|
+
return Button;
|
|
3164
|
+
})();
|
|
3165
|
+
|
|
3166
|
+
const { Text: AntDText$1 } = Typography$1;
|
|
3167
|
+
function getTextEmotionStyles$1(theme, props) {
|
|
3168
|
+
return /*#__PURE__*/ css({
|
|
3169
|
+
'&&': {
|
|
3170
|
+
display: 'block',
|
|
3171
|
+
fontSize: theme.typography.fontSizeSm,
|
|
3172
|
+
lineHeight: theme.typography.lineHeightSm,
|
|
3173
|
+
color: theme.colors.textSecondary,
|
|
3174
|
+
...props.withoutMargins && {
|
|
3175
|
+
'&&': {
|
|
3176
|
+
marginTop: 0,
|
|
3177
|
+
marginBottom: 0
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
});
|
|
3182
|
+
}
|
|
3183
|
+
function Hint(userProps) {
|
|
3184
|
+
const { dangerouslySetAntdProps, bold, withoutMargins, color, ...props } = userProps;
|
|
3185
|
+
const { theme } = useDesignSystemTheme();
|
|
3186
|
+
return /*#__PURE__*/ jsx(DesignSystemAntDConfigProvider, {
|
|
3187
|
+
children: /*#__PURE__*/ jsx(AntDText$1, {
|
|
3188
|
+
...addDebugOutlineIfEnabled(),
|
|
3189
|
+
...props,
|
|
3190
|
+
css: getTextEmotionStyles$1(theme, userProps),
|
|
3191
|
+
...dangerouslySetAntdProps
|
|
3192
|
+
})
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
const getLinkStyles = (theme, clsPrefix)=>{
|
|
3197
|
+
const classTypography = `.${clsPrefix}-typography`;
|
|
3198
|
+
const styles = {
|
|
3199
|
+
[`&${classTypography}, &${classTypography}:focus`]: {
|
|
3200
|
+
color: theme.colors.actionTertiaryTextDefault
|
|
3201
|
+
},
|
|
3202
|
+
[`&${classTypography}:hover, &${classTypography}:hover .anticon`]: {
|
|
3203
|
+
color: theme.colors.actionTertiaryTextHover,
|
|
3204
|
+
textDecoration: 'underline'
|
|
3205
|
+
},
|
|
3206
|
+
[`&${classTypography}:active, &${classTypography}:active .anticon`]: {
|
|
3207
|
+
color: theme.colors.actionTertiaryTextPress,
|
|
3208
|
+
textDecoration: 'underline'
|
|
3209
|
+
},
|
|
3210
|
+
[`&${classTypography}:focus-visible`]: {
|
|
3211
|
+
textDecoration: 'underline'
|
|
3212
|
+
},
|
|
3213
|
+
'.anticon': {
|
|
3214
|
+
fontSize: 12,
|
|
3215
|
+
verticalAlign: 'baseline'
|
|
3216
|
+
},
|
|
3217
|
+
// manually update color for link within a LegacyTooltip since tooltip always has an inverted background color for light/dark mode
|
|
3218
|
+
// this is required for accessibility compliance
|
|
3219
|
+
[`.${clsPrefix}-tooltip-inner a&${classTypography}`]: {
|
|
3220
|
+
[`&, :focus`]: {
|
|
3221
|
+
color: theme.colors.blue500,
|
|
3222
|
+
'.anticon': {
|
|
3223
|
+
color: theme.colors.blue500
|
|
3224
|
+
}
|
|
3225
|
+
},
|
|
3226
|
+
':active': {
|
|
3227
|
+
color: theme.colors.blue500,
|
|
3228
|
+
'.anticon': {
|
|
3229
|
+
color: theme.colors.blue500
|
|
3230
|
+
}
|
|
3231
|
+
},
|
|
3232
|
+
':hover': {
|
|
3233
|
+
color: theme.colors.blue400,
|
|
3234
|
+
'.anticon': {
|
|
3235
|
+
color: theme.colors.blue400
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
};
|
|
3240
|
+
return /*#__PURE__*/ css(styles);
|
|
3241
|
+
};
|
|
3242
|
+
const getEllipsisNewTabLinkStyles = ()=>{
|
|
3243
|
+
const styles = {
|
|
3244
|
+
paddingRight: 'calc(2px + 1em)',
|
|
3245
|
+
position: 'relative'
|
|
3246
|
+
};
|
|
3247
|
+
return /*#__PURE__*/ css(styles);
|
|
3248
|
+
};
|
|
3249
|
+
const getIconStyles = (theme)=>{
|
|
3250
|
+
const styles = {
|
|
3251
|
+
marginLeft: 4,
|
|
3252
|
+
color: theme.colors.actionTertiaryTextDefault,
|
|
3253
|
+
position: 'relative',
|
|
3254
|
+
top: '1px'
|
|
3255
|
+
};
|
|
3256
|
+
return /*#__PURE__*/ css(styles);
|
|
3257
|
+
};
|
|
3258
|
+
const getEllipsisIconStyles = (useNewIcons)=>{
|
|
3259
|
+
const styles = {
|
|
3260
|
+
position: 'absolute',
|
|
3261
|
+
right: 0,
|
|
3262
|
+
bottom: 0,
|
|
3263
|
+
top: 0,
|
|
3264
|
+
display: 'flex',
|
|
3265
|
+
alignItems: 'center',
|
|
3266
|
+
...useNewIcons
|
|
3267
|
+
};
|
|
3268
|
+
return /*#__PURE__*/ css(styles);
|
|
3269
|
+
};
|
|
3270
|
+
const Link = /*#__PURE__*/ forwardRef(function Link(param, ref) {
|
|
3271
|
+
let { dangerouslySetAntdProps, componentId, analyticsEvents, onClick, ...props } = param;
|
|
3272
|
+
const emitOnView = safex('databricks.fe.observability.defaultComponentView.typographyLink', false);
|
|
3273
|
+
const { children, openInNewTab, ...restProps } = props;
|
|
3274
|
+
const { theme, classNamePrefix } = useDesignSystemTheme();
|
|
3275
|
+
const memoizedAnalyticsEvents = useMemo(()=>analyticsEvents ?? (emitOnView ? [
|
|
3276
|
+
DesignSystemEventProviderAnalyticsEventTypes.OnClick,
|
|
3277
|
+
DesignSystemEventProviderAnalyticsEventTypes.OnView
|
|
3278
|
+
] : [
|
|
3279
|
+
DesignSystemEventProviderAnalyticsEventTypes.OnClick
|
|
3280
|
+
]), [
|
|
3281
|
+
analyticsEvents,
|
|
3282
|
+
emitOnView
|
|
3283
|
+
]);
|
|
3284
|
+
const eventContext = useDesignSystemEventComponentCallbacks({
|
|
3285
|
+
componentType: DesignSystemEventProviderComponentTypes.TypographyLink,
|
|
3286
|
+
componentId,
|
|
3287
|
+
analyticsEvents: memoizedAnalyticsEvents,
|
|
3288
|
+
shouldStartInteraction: false
|
|
3289
|
+
});
|
|
3290
|
+
const { elementRef: linkRef } = useNotifyOnFirstView({
|
|
3291
|
+
onView: eventContext.onView
|
|
3292
|
+
});
|
|
3293
|
+
const mergedRef = useMergeRefs([
|
|
3294
|
+
ref,
|
|
3295
|
+
linkRef
|
|
3296
|
+
]);
|
|
3297
|
+
const onClickHandler = useCallback((e)=>{
|
|
3298
|
+
eventContext.onClick(e);
|
|
3299
|
+
onClick?.(e);
|
|
3300
|
+
}, [
|
|
3301
|
+
eventContext,
|
|
3302
|
+
onClick
|
|
3303
|
+
]);
|
|
3304
|
+
const newTabProps = {
|
|
3305
|
+
rel: 'noopener noreferrer',
|
|
3306
|
+
target: '_blank'
|
|
3307
|
+
};
|
|
3308
|
+
const linkProps = openInNewTab ? {
|
|
3309
|
+
...restProps,
|
|
3310
|
+
...newTabProps
|
|
3311
|
+
} : {
|
|
3312
|
+
...restProps
|
|
3313
|
+
};
|
|
3314
|
+
const linkStyles = props.ellipsis && openInNewTab ? [
|
|
3315
|
+
getLinkStyles(theme, classNamePrefix),
|
|
3316
|
+
getEllipsisNewTabLinkStyles()
|
|
3317
|
+
] : getLinkStyles(theme, classNamePrefix);
|
|
3318
|
+
const iconStyles = props.ellipsis ? [
|
|
3319
|
+
getIconStyles(theme),
|
|
3320
|
+
getEllipsisIconStyles()
|
|
3321
|
+
] : getIconStyles(theme);
|
|
3322
|
+
return /*#__PURE__*/ jsx(DesignSystemAntDConfigProvider, {
|
|
3323
|
+
children: /*#__PURE__*/ jsxs(Typography$1.Link, {
|
|
3324
|
+
...addDebugOutlineIfEnabled(),
|
|
3325
|
+
"aria-disabled": linkProps.disabled,
|
|
3326
|
+
css: linkStyles,
|
|
3327
|
+
ref: mergedRef,
|
|
3328
|
+
onClick: onClickHandler,
|
|
3329
|
+
...linkProps,
|
|
3330
|
+
...dangerouslySetAntdProps,
|
|
3331
|
+
...eventContext.dataComponentProps,
|
|
3332
|
+
children: [
|
|
3333
|
+
children,
|
|
3334
|
+
openInNewTab ? /*#__PURE__*/ jsx(NewWindowIcon, {
|
|
3335
|
+
css: iconStyles,
|
|
3336
|
+
...newTabProps
|
|
3337
|
+
}) : null
|
|
3338
|
+
]
|
|
3339
|
+
})
|
|
3340
|
+
});
|
|
3341
|
+
});
|
|
3342
|
+
|
|
3343
|
+
const { Paragraph: AntDParagraph } = Typography$1;
|
|
3344
|
+
function getParagraphEmotionStyles(theme, clsPrefix, props) {
|
|
3345
|
+
return /*#__PURE__*/ css({
|
|
3346
|
+
'&&': {
|
|
3347
|
+
fontSize: theme.typography.fontSizeBase,
|
|
3348
|
+
fontWeight: theme.typography.typographyRegularFontWeight,
|
|
3349
|
+
lineHeight: theme.typography.lineHeightBase,
|
|
3350
|
+
color: getTypographyColor(theme, props.color, theme.colors.textPrimary)
|
|
3351
|
+
},
|
|
3352
|
+
'& .anticon': {
|
|
3353
|
+
verticalAlign: 'text-bottom'
|
|
3354
|
+
},
|
|
3355
|
+
[`& .${clsPrefix}-btn-link`]: {
|
|
3356
|
+
verticalAlign: 'baseline !important'
|
|
3357
|
+
}
|
|
3358
|
+
}, props.disabled && {
|
|
3359
|
+
'&&': {
|
|
3360
|
+
color: theme.colors.actionDisabledText
|
|
3361
|
+
}
|
|
3362
|
+
}, props.withoutMargins && {
|
|
3363
|
+
'&&': {
|
|
3364
|
+
marginTop: 0,
|
|
3365
|
+
marginBottom: 0
|
|
3366
|
+
}
|
|
3367
|
+
});
|
|
3368
|
+
}
|
|
3369
|
+
function Paragraph(userProps) {
|
|
3370
|
+
const { dangerouslySetAntdProps, withoutMargins, color, ...props } = userProps;
|
|
3371
|
+
const { theme, classNamePrefix } = useDesignSystemTheme();
|
|
3372
|
+
return /*#__PURE__*/ jsx(DesignSystemAntDConfigProvider, {
|
|
3373
|
+
children: /*#__PURE__*/ jsx(AntDParagraph, {
|
|
3374
|
+
...addDebugOutlineIfEnabled(),
|
|
3375
|
+
...props,
|
|
3376
|
+
className: props.className,
|
|
3377
|
+
css: getParagraphEmotionStyles(theme, classNamePrefix, userProps),
|
|
3378
|
+
...dangerouslySetAntdProps
|
|
3379
|
+
})
|
|
3380
|
+
});
|
|
3381
|
+
}
|
|
3382
|
+
|
|
3383
|
+
const { Text: AntDText } = Typography$1;
|
|
3384
|
+
function getTextEmotionStyles(theme, props) {
|
|
3385
|
+
return /*#__PURE__*/ css({
|
|
3386
|
+
'&&': {
|
|
3387
|
+
fontSize: theme.typography.fontSizeBase,
|
|
3388
|
+
fontWeight: theme.typography.typographyRegularFontWeight,
|
|
3389
|
+
lineHeight: theme.typography.lineHeightBase,
|
|
3390
|
+
color: getTypographyColor(theme, props.color, theme.colors.textPrimary)
|
|
3391
|
+
}
|
|
3392
|
+
}, props.disabled && {
|
|
3393
|
+
'&&': {
|
|
3394
|
+
color: theme.colors.actionDisabledText
|
|
3395
|
+
}
|
|
3396
|
+
}, props.hint && {
|
|
3397
|
+
'&&': {
|
|
3398
|
+
fontSize: theme.typography.fontSizeSm,
|
|
3399
|
+
lineHeight: theme.typography.lineHeightSm
|
|
3400
|
+
}
|
|
3401
|
+
}, props.bold && {
|
|
3402
|
+
'&&': {
|
|
3403
|
+
fontSize: theme.typography.fontSizeBase,
|
|
3404
|
+
fontWeight: theme.typography.typographyBoldFontWeight,
|
|
3405
|
+
lineHeight: theme.typography.lineHeightBase
|
|
3406
|
+
}
|
|
3407
|
+
}, props.code && {
|
|
3408
|
+
'&& > code': {
|
|
3409
|
+
color: theme.colors.textPrimary,
|
|
3410
|
+
fontSize: theme.typography.fontSizeBase,
|
|
3411
|
+
lineHeight: theme.typography.lineHeightBase,
|
|
3412
|
+
background: theme.colors.typographyCodeBg,
|
|
3413
|
+
fontFamily: 'monospace',
|
|
3414
|
+
borderRadius: theme.borders.borderRadiusSm,
|
|
3415
|
+
padding: '2px 4px',
|
|
3416
|
+
border: 'unset',
|
|
3417
|
+
margin: 0
|
|
3418
|
+
}
|
|
3419
|
+
}, props.size && {
|
|
3420
|
+
'&&': (()=>{
|
|
3421
|
+
switch(props.size){
|
|
3422
|
+
case 'xxl':
|
|
3423
|
+
return {
|
|
3424
|
+
fontSize: theme.typography.fontSizeXxl,
|
|
3425
|
+
lineHeight: theme.typography.lineHeightXxl,
|
|
3426
|
+
'& .anticon': {
|
|
3427
|
+
lineHeight: theme.typography.lineHeightXxl,
|
|
3428
|
+
verticalAlign: 'middle'
|
|
3429
|
+
}
|
|
3430
|
+
};
|
|
3431
|
+
case 'xl':
|
|
3432
|
+
return {
|
|
3433
|
+
fontSize: theme.typography.fontSizeXl,
|
|
3434
|
+
lineHeight: theme.typography.lineHeightXl,
|
|
3435
|
+
'& .anticon': {
|
|
3436
|
+
lineHeight: theme.typography.lineHeightXl,
|
|
3437
|
+
verticalAlign: 'middle'
|
|
3438
|
+
}
|
|
3439
|
+
};
|
|
3440
|
+
case 'lg':
|
|
3441
|
+
return {
|
|
3442
|
+
fontSize: theme.typography.fontSizeLg,
|
|
3443
|
+
lineHeight: theme.typography.lineHeightLg,
|
|
3444
|
+
'& .anticon': {
|
|
3445
|
+
lineHeight: theme.typography.lineHeightLg,
|
|
3446
|
+
verticalAlign: 'middle'
|
|
3447
|
+
}
|
|
3448
|
+
};
|
|
3449
|
+
case 'sm':
|
|
3450
|
+
return {
|
|
3451
|
+
fontSize: theme.typography.fontSizeSm,
|
|
3452
|
+
lineHeight: theme.typography.lineHeightSm,
|
|
3453
|
+
'& .anticon': {
|
|
3454
|
+
verticalAlign: '-0.219em'
|
|
3455
|
+
}
|
|
3456
|
+
};
|
|
3457
|
+
default:
|
|
3458
|
+
return {};
|
|
3459
|
+
}
|
|
3460
|
+
})()
|
|
3461
|
+
}, props.withoutMargins && {
|
|
3462
|
+
'&&': {
|
|
3463
|
+
marginTop: 0,
|
|
3464
|
+
marginBottom: 0
|
|
3465
|
+
}
|
|
3466
|
+
});
|
|
3467
|
+
}
|
|
3468
|
+
function Text(userProps) {
|
|
3469
|
+
// Omit props that are not supported by `antd`
|
|
3470
|
+
const { dangerouslySetAntdProps, bold, hint, withoutMargins, color, ...props } = userProps;
|
|
3471
|
+
const { theme } = useDesignSystemTheme();
|
|
3472
|
+
return /*#__PURE__*/ jsx(DesignSystemAntDConfigProvider, {
|
|
3473
|
+
children: /*#__PURE__*/ jsx(AntDText, {
|
|
3474
|
+
...addDebugOutlineIfEnabled(),
|
|
3475
|
+
...props,
|
|
3476
|
+
className: props.className,
|
|
3477
|
+
css: getTextEmotionStyles(theme, userProps),
|
|
3478
|
+
...dangerouslySetAntdProps
|
|
3479
|
+
})
|
|
3480
|
+
});
|
|
3481
|
+
}
|
|
3482
|
+
|
|
3483
|
+
const MiddleElideSuffixLength = 6;
|
|
3484
|
+
function TextMiddleElide(param) {
|
|
3485
|
+
let { text, suffixLength = MiddleElideSuffixLength, ...textProps } = param;
|
|
3486
|
+
const id = useMemo(()=>uniqueId$1('text-middle-elided-'), []);
|
|
3487
|
+
const { start, suffix } = getStartAndSuffix(text, suffixLength);
|
|
3488
|
+
const disableElide = process?.env?.NODE_ENV === 'test'; // so unit tests play nice
|
|
3489
|
+
// use the entire text on select and copy
|
|
3490
|
+
useEffect(()=>{
|
|
3491
|
+
const clipboardCopyHandler = (e)=>{
|
|
3492
|
+
e?.preventDefault();
|
|
3493
|
+
e?.clipboardData?.setData('text/plain', text);
|
|
3494
|
+
};
|
|
3495
|
+
const selector = `.${id}`;
|
|
3496
|
+
document.querySelector(selector)?.addEventListener('copy', clipboardCopyHandler);
|
|
3497
|
+
return ()=>{
|
|
3498
|
+
document.querySelector(selector)?.removeEventListener('copy', clipboardCopyHandler);
|
|
3499
|
+
};
|
|
3500
|
+
}, [
|
|
3501
|
+
id,
|
|
3502
|
+
text
|
|
3503
|
+
]);
|
|
3504
|
+
return /*#__PURE__*/ jsx(Text, {
|
|
3505
|
+
ellipsis: disableElide ? undefined : {
|
|
3506
|
+
suffix
|
|
3507
|
+
},
|
|
3508
|
+
...textProps,
|
|
3509
|
+
"aria-label": text,
|
|
3510
|
+
title: textProps.title ?? text,
|
|
3511
|
+
className: id,
|
|
3512
|
+
children: disableElide ? text : start
|
|
3513
|
+
});
|
|
3514
|
+
}
|
|
3515
|
+
// Exported for unit tests
|
|
3516
|
+
function getStartAndSuffix(text, suffixLength) {
|
|
3517
|
+
if (text.length <= suffixLength) {
|
|
3518
|
+
return {
|
|
3519
|
+
start: text,
|
|
3520
|
+
suffix: undefined
|
|
3521
|
+
};
|
|
3522
|
+
}
|
|
3523
|
+
const start = text.slice(0, text.length - suffixLength).trim();
|
|
3524
|
+
const suffix = text.slice(-suffixLength).trim();
|
|
3525
|
+
return {
|
|
3526
|
+
start,
|
|
3527
|
+
suffix
|
|
3528
|
+
};
|
|
3529
|
+
}
|
|
3530
|
+
|
|
3531
|
+
const { Title: AntDTitle } = Typography$1;
|
|
3532
|
+
function getLevelStyles(theme, props) {
|
|
3533
|
+
switch(props.level){
|
|
3534
|
+
case 1:
|
|
3535
|
+
return /*#__PURE__*/ css({
|
|
3536
|
+
'&&': {
|
|
3537
|
+
fontSize: theme.typography.fontSizeXxl,
|
|
3538
|
+
lineHeight: theme.typography.lineHeightXxl,
|
|
3539
|
+
fontWeight: theme.typography.typographyBoldFontWeight
|
|
3540
|
+
},
|
|
3541
|
+
'& > .anticon': {
|
|
3542
|
+
lineHeight: theme.typography.lineHeightXxl
|
|
3543
|
+
}
|
|
3544
|
+
});
|
|
3545
|
+
case 2:
|
|
3546
|
+
return /*#__PURE__*/ css({
|
|
3547
|
+
'&&': {
|
|
3548
|
+
fontSize: theme.typography.fontSizeXl,
|
|
3549
|
+
lineHeight: theme.typography.lineHeightXl,
|
|
3550
|
+
fontWeight: theme.typography.typographyBoldFontWeight
|
|
3551
|
+
},
|
|
3552
|
+
'& > .anticon': {
|
|
3553
|
+
lineHeight: theme.typography.lineHeightXl
|
|
3554
|
+
}
|
|
3555
|
+
});
|
|
3556
|
+
case 3:
|
|
3557
|
+
return /*#__PURE__*/ css({
|
|
3558
|
+
'&&': {
|
|
3559
|
+
fontSize: theme.typography.fontSizeLg,
|
|
3560
|
+
lineHeight: theme.typography.lineHeightLg,
|
|
3561
|
+
fontWeight: theme.typography.typographyBoldFontWeight
|
|
3562
|
+
},
|
|
3563
|
+
'& > .anticon': {
|
|
3564
|
+
lineHeight: theme.typography.lineHeightLg
|
|
3565
|
+
}
|
|
3566
|
+
});
|
|
3567
|
+
case 4:
|
|
3568
|
+
default:
|
|
3569
|
+
return /*#__PURE__*/ css({
|
|
3570
|
+
'&&': {
|
|
3571
|
+
fontSize: theme.typography.fontSizeMd,
|
|
3572
|
+
lineHeight: theme.typography.lineHeightMd,
|
|
3573
|
+
fontWeight: theme.typography.typographyBoldFontWeight
|
|
3574
|
+
},
|
|
3575
|
+
'& > .anticon': {
|
|
3576
|
+
lineHeight: theme.typography.lineHeightMd
|
|
3577
|
+
}
|
|
3578
|
+
});
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
function getTitleEmotionStyles(theme, props) {
|
|
3582
|
+
return /*#__PURE__*/ css(getLevelStyles(theme, props), {
|
|
3583
|
+
'&&': {
|
|
3584
|
+
color: getTypographyColor(theme, props.color, theme.colors.textPrimary)
|
|
3585
|
+
},
|
|
3586
|
+
'& > .anticon': {
|
|
3587
|
+
verticalAlign: 'middle'
|
|
3588
|
+
}
|
|
3589
|
+
}, props.withoutMargins && {
|
|
3590
|
+
'&&': {
|
|
3591
|
+
marginTop: '0 !important',
|
|
3592
|
+
marginBottom: '0 !important'
|
|
3593
|
+
}
|
|
3594
|
+
});
|
|
3595
|
+
}
|
|
3596
|
+
function Title(userProps) {
|
|
3597
|
+
const { dangerouslySetAntdProps, withoutMargins, color, elementLevel, ...props } = userProps;
|
|
3598
|
+
const { theme } = useDesignSystemTheme();
|
|
3599
|
+
return /*#__PURE__*/ jsx(DesignSystemAntDConfigProvider, {
|
|
3600
|
+
children: /*#__PURE__*/ jsx(AntDTitle, {
|
|
3601
|
+
...addDebugOutlineIfEnabled(),
|
|
3602
|
+
...props,
|
|
3603
|
+
level: elementLevel ?? props.level,
|
|
3604
|
+
className: props.className,
|
|
3605
|
+
css: getTitleEmotionStyles(theme, userProps),
|
|
3606
|
+
...dangerouslySetAntdProps
|
|
3607
|
+
})
|
|
3608
|
+
});
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
const Truncate = (param)=>{
|
|
3612
|
+
let { children, lines = 1, ...props } = param;
|
|
3613
|
+
const [textContent, setTextContent] = useState('');
|
|
3614
|
+
const spanRef = useRef(null);
|
|
3615
|
+
// This ensures that truncated text is always available to the user via a native tooltip
|
|
3616
|
+
useEffect(()=>{
|
|
3617
|
+
if (spanRef.current) {
|
|
3618
|
+
setTextContent(spanRef.current.textContent || '');
|
|
3619
|
+
}
|
|
3620
|
+
}, [
|
|
3621
|
+
spanRef,
|
|
3622
|
+
children
|
|
3623
|
+
]);
|
|
3624
|
+
return /*#__PURE__*/ jsx("span", {
|
|
3625
|
+
ref: spanRef,
|
|
3626
|
+
title: textContent,
|
|
3627
|
+
css: {
|
|
3628
|
+
overflow: 'hidden',
|
|
3629
|
+
textOverflow: 'ellipsis',
|
|
3630
|
+
whiteSpace: 'normal',
|
|
3631
|
+
wordBreak: 'break-word',
|
|
3632
|
+
display: '-webkit-box',
|
|
3633
|
+
webkitLineClamp: lines,
|
|
3634
|
+
WebkitBoxOrient: 'vertical',
|
|
3635
|
+
WebkitLineClamp: lines
|
|
3636
|
+
},
|
|
3637
|
+
...props,
|
|
3638
|
+
children: children
|
|
3639
|
+
});
|
|
3640
|
+
};
|
|
3641
|
+
|
|
3642
|
+
const Typography = /* #__PURE__ */ (()=>{
|
|
3643
|
+
function Typography(param) {
|
|
3644
|
+
let { dangerouslySetAntdProps, ...props } = param;
|
|
3645
|
+
return /*#__PURE__*/ jsx(DesignSystemAntDConfigProvider, {
|
|
3646
|
+
children: /*#__PURE__*/ jsx(Typography$1, {
|
|
3647
|
+
...addDebugOutlineIfEnabled(),
|
|
3648
|
+
...props,
|
|
3649
|
+
...dangerouslySetAntdProps
|
|
3650
|
+
})
|
|
3651
|
+
});
|
|
3652
|
+
}
|
|
3653
|
+
Typography.Text = Text;
|
|
3654
|
+
Typography.Title = Title;
|
|
3655
|
+
Typography.Paragraph = Paragraph;
|
|
3656
|
+
Typography.Link = Link;
|
|
3657
|
+
Typography.Hint = Hint;
|
|
3658
|
+
Typography.Truncate = Truncate;
|
|
3659
|
+
Typography.TextMiddleElide = TextMiddleElide;
|
|
3660
|
+
return Typography;
|
|
3661
|
+
})();
|
|
3662
|
+
|
|
3663
|
+
// WRAPPED RADIX-UI-COMPONENTS
|
|
3664
|
+
const Anchor = Popover$1.Anchor; // Behavioral component only
|
|
3665
|
+
const Root = (param)=>{
|
|
3666
|
+
let { children, onOpenChange, componentId, analyticsEvents = [
|
|
3667
|
+
DesignSystemEventProviderAnalyticsEventTypes.OnView
|
|
3668
|
+
], ...props } = param;
|
|
3669
|
+
const firstView = useRef(true);
|
|
3670
|
+
const memoizedAnalyticsEvents = useMemo(()=>analyticsEvents, [
|
|
3671
|
+
analyticsEvents
|
|
3672
|
+
]);
|
|
3673
|
+
const eventContext = useDesignSystemEventComponentCallbacks({
|
|
3674
|
+
componentType: DesignSystemEventProviderComponentTypes.Popover,
|
|
3675
|
+
componentId: componentId ?? 'design_system.popover',
|
|
3676
|
+
analyticsEvents: memoizedAnalyticsEvents
|
|
3677
|
+
});
|
|
3678
|
+
useEffect(()=>{
|
|
3679
|
+
if (props.open && firstView.current) {
|
|
3680
|
+
eventContext.onView();
|
|
3681
|
+
firstView.current = false;
|
|
3682
|
+
}
|
|
3683
|
+
}, [
|
|
3684
|
+
eventContext,
|
|
3685
|
+
props.open
|
|
3686
|
+
]);
|
|
3687
|
+
const onOpenChangeHandler = useCallback((open)=>{
|
|
3688
|
+
if (open && firstView.current) {
|
|
3689
|
+
eventContext.onView();
|
|
3690
|
+
firstView.current = false;
|
|
3691
|
+
}
|
|
3692
|
+
onOpenChange?.(open);
|
|
3693
|
+
}, [
|
|
3694
|
+
eventContext,
|
|
3695
|
+
onOpenChange
|
|
3696
|
+
]);
|
|
3697
|
+
return /*#__PURE__*/ jsx(Popover$1.Root, {
|
|
3698
|
+
...props,
|
|
3699
|
+
onOpenChange: onOpenChangeHandler,
|
|
3700
|
+
children: /*#__PURE__*/ jsx(ComponentFinderContext.Provider, {
|
|
3701
|
+
value: {
|
|
3702
|
+
dataComponentProps: eventContext.dataComponentProps
|
|
3703
|
+
},
|
|
3704
|
+
children: children
|
|
3705
|
+
})
|
|
3706
|
+
});
|
|
3707
|
+
};
|
|
3708
|
+
const Content = /*#__PURE__*/ forwardRef(function Content(param, ref) {
|
|
3709
|
+
let { children, minWidth = 220, maxWidth, ...props } = param;
|
|
3710
|
+
const { getPopupContainer } = useDesignSystemContext();
|
|
3711
|
+
const { theme } = useDesignSystemTheme();
|
|
3712
|
+
const { useNewShadows, useNewBorderColors } = useDesignSystemSafexFlags();
|
|
3713
|
+
const dataComponentProps = useComponentFinderContext(DesignSystemEventProviderComponentTypes.Popover);
|
|
3714
|
+
return /*#__PURE__*/ jsx(Popover$1.Portal, {
|
|
3715
|
+
container: getPopupContainer && getPopupContainer(),
|
|
3716
|
+
children: /*#__PURE__*/ jsx(Popover$1.Content, {
|
|
3717
|
+
...addDebugOutlineIfEnabled(),
|
|
3718
|
+
ref: ref,
|
|
3719
|
+
css: [
|
|
3720
|
+
contentStyles(theme, useNewShadows, useNewBorderColors),
|
|
3721
|
+
{
|
|
3722
|
+
minWidth,
|
|
3723
|
+
maxWidth
|
|
3724
|
+
}
|
|
3725
|
+
],
|
|
3726
|
+
sideOffset: 4,
|
|
3727
|
+
"aria-label": "Popover content",
|
|
3728
|
+
...props,
|
|
3729
|
+
...dataComponentProps,
|
|
3730
|
+
children: children
|
|
3731
|
+
})
|
|
3732
|
+
});
|
|
3733
|
+
});
|
|
3734
|
+
const Trigger = /*#__PURE__*/ forwardRef(function Trigger(param, ref) {
|
|
3735
|
+
let { children, ...props } = param;
|
|
3736
|
+
return /*#__PURE__*/ jsx(Popover$1.Trigger, {
|
|
3737
|
+
...addDebugOutlineIfEnabled(),
|
|
3738
|
+
ref: ref,
|
|
3739
|
+
...props,
|
|
3740
|
+
children: children
|
|
3741
|
+
});
|
|
3742
|
+
});
|
|
3743
|
+
const Close = /*#__PURE__*/ forwardRef(function Close(param, ref) {
|
|
3744
|
+
let { children, ...props } = param;
|
|
3745
|
+
return /*#__PURE__*/ jsx(Popover$1.Close, {
|
|
3746
|
+
ref: ref,
|
|
3747
|
+
...props,
|
|
3748
|
+
children: children
|
|
3749
|
+
});
|
|
3750
|
+
});
|
|
3751
|
+
const Arrow = /*#__PURE__*/ forwardRef(function Arrow(param, ref) {
|
|
3752
|
+
let { children, ...props } = param;
|
|
3753
|
+
const { theme } = useDesignSystemTheme();
|
|
3754
|
+
return /*#__PURE__*/ jsx(Popover$1.Arrow, {
|
|
3755
|
+
css: {
|
|
3756
|
+
fill: theme.colors.backgroundPrimary,
|
|
3757
|
+
stroke: theme.colors.borderDecorative,
|
|
3758
|
+
strokeDashoffset: -CONSTANTS.arrowBottomLength(),
|
|
3759
|
+
strokeDasharray: CONSTANTS.arrowBottomLength() + 2 * CONSTANTS.arrowSide(),
|
|
3760
|
+
strokeWidth: CONSTANTS.arrowStrokeWidth(),
|
|
3761
|
+
// TODO: This is a temporary fix for the alignment of the Arrow;
|
|
3762
|
+
// Radix has changed the implementation for v1.0.0 (uses floating-ui)
|
|
3763
|
+
// which has new behaviors for alignment that we don't want. Generally
|
|
3764
|
+
// we need to fix the arrow to always be aligned to the left of the menu (with
|
|
3765
|
+
// offset equal to border radius)
|
|
3766
|
+
position: 'relative',
|
|
3767
|
+
top: -1
|
|
3768
|
+
},
|
|
3769
|
+
ref: ref,
|
|
3770
|
+
width: 12,
|
|
3771
|
+
height: 6,
|
|
3772
|
+
...props,
|
|
3773
|
+
children: children
|
|
3774
|
+
});
|
|
3775
|
+
});
|
|
3776
|
+
// CONSTANTS
|
|
3777
|
+
const CONSTANTS = {
|
|
3778
|
+
arrowBottomLength () {
|
|
3779
|
+
// The built in arrow is a polygon: 0,0 30,0 15,10
|
|
3780
|
+
return 30;
|
|
3781
|
+
},
|
|
3782
|
+
arrowHeight () {
|
|
3783
|
+
return 10;
|
|
3784
|
+
},
|
|
3785
|
+
arrowSide () {
|
|
3786
|
+
return 2 * (this.arrowHeight() ** 2 * 2) ** 0.5;
|
|
3787
|
+
},
|
|
3788
|
+
arrowStrokeWidth () {
|
|
3789
|
+
// This is eyeballed b/c relative to the svg viewbox coordinate system
|
|
3790
|
+
return 2;
|
|
3791
|
+
}
|
|
3792
|
+
};
|
|
3793
|
+
const popoverContentStyles = (theme, useNewShadows, useNewBorderColors)=>({
|
|
3794
|
+
backgroundColor: theme.colors.backgroundPrimary,
|
|
3795
|
+
color: theme.colors.textPrimary,
|
|
3796
|
+
lineHeight: theme.typography.lineHeightBase,
|
|
3797
|
+
border: `1px solid ${useNewBorderColors ? theme.colors.border : theme.colors.borderDecorative}`,
|
|
3798
|
+
borderRadius: theme.borders.borderRadiusSm,
|
|
3799
|
+
padding: `${theme.spacing.sm}px`,
|
|
3800
|
+
boxShadow: useNewShadows ? theme.shadows.lg : theme.general.shadowLow,
|
|
3801
|
+
zIndex: theme.options.zIndexBase + 30,
|
|
3802
|
+
...getDarkModePortalStyles(theme, useNewShadows, useNewBorderColors),
|
|
3803
|
+
a: importantify({
|
|
3804
|
+
color: theme.colors.actionTertiaryTextDefault,
|
|
3805
|
+
'&:hover, &:focus': {
|
|
3806
|
+
color: theme.colors.actionTertiaryTextHover
|
|
3807
|
+
}
|
|
3808
|
+
}),
|
|
3809
|
+
'&:focus-visible': {
|
|
3810
|
+
outlineStyle: 'solid',
|
|
3811
|
+
outlineWidth: '2px',
|
|
3812
|
+
outlineOffset: '1px',
|
|
3813
|
+
outlineColor: theme.colors.actionDefaultBorderFocus
|
|
3814
|
+
}
|
|
3815
|
+
});
|
|
3816
|
+
const contentStyles = (theme, useNewShadows, useNewBorderColors)=>({
|
|
3817
|
+
...popoverContentStyles(theme, useNewShadows, useNewBorderColors)
|
|
3818
|
+
});
|
|
3819
|
+
|
|
3820
|
+
var Popover = /*#__PURE__*/Object.freeze({
|
|
3821
|
+
__proto__: null,
|
|
3822
|
+
Anchor: Anchor,
|
|
3823
|
+
Arrow: Arrow,
|
|
3824
|
+
Close: Close,
|
|
3825
|
+
Content: Content,
|
|
3826
|
+
Root: Root,
|
|
3827
|
+
Trigger: Trigger
|
|
3828
|
+
});
|
|
3829
|
+
|
|
3830
|
+
export { getDialogComboboxOptionLabelWidth as $, getDarkModePortalStyles as A, Button as B, CloseIcon as C, DesignSystemAntDConfigProvider as D, getShadowScrollStyles as E, Form as F, DEFAULT_SPACING_UNIT as G, useDesignSystemContext as H, Icon as I, DesignSystemEventProvider as J, useUniqueId as K, LoadingIcon as L, Arrow as M, LoadingState as N, visuallyHidden as O, ComponentFinderContext as P, getComboboxContentWrapperStyles as Q, Root as R, Spinner as S, Typography as T, getFooterStyles as U, highlightFirstNonDisabledOption as V, WarningIcon as W, getInfoIconStyles as X, getKeyboardNavigationFunctions as Y, dialogComboboxLookAheadKeyDown as Z, getCheckboxStyles as _, useDesignSystemSafexFlags as a, getContentOptions as a0, findHighlightedOption as a1, highlightOption as a2, findClosestOptionSibling as a3, getComboboxOptionLabelStyles as a4, getSelectItemWithHintColumnStyles as a5, getHintColumnStyles as a6, useComponentFinderContext as a7, SMALL_BUTTON_HEIGHT as a8, ApplyDesignSystemContextOverrides as a9, getVirtualizedComboboxMenuItemStyles as aA, ColorVars as aB, Title as aa, AccessibleContainer as ab, DU_BOIS_ENABLE_ANIMATION_CLASSNAME as ac, getDefaultStyles as ad, getPrimaryStyles as ae, getDisabledSplitButtonStyles as af, getDisabledPrimarySplitButtonStyles as ag, getHorizontalTabShadowStyles as ah, getMemoizedButtonEmotionStyles as ai, getButtonEmotionStyles as aj, DesignSystemEventProviderComponentSubTypes as ak, useDesignSystemEventSuppressInteractionContext as al, DesignSystemThemeContext as am, DesignSystemContext as an, DesignSystemThemeProvider as ao, DesignSystemProvider as ap, ApplyDesignSystemFlags as aq, useAntDConfigProviderContext as ar, isOptionDisabled as as, resetTabIndexToFocusedElement as at, WithDesignSystemThemeHoc as au, NewWindowIcon as av, LoadingStateContext as aw, Popover as ax, getTypographyColor as ay, getBottomOnlyShadowScrollStyles as az, addDebugOutlineIfEnabled as b, getAnimationCss as c, useFormContext as d, DesignSystemEventProviderAnalyticsEventTypes as e, useDesignSystemEventComponentCallbacks as f, getValidationStateColor as g, DesignSystemEventProviderComponentTypes as h, importantify as i, DesignSystemEventProviderComponentSubTypeMap as j, useNotifyOnFirstView as k, DangerIcon as l, Trigger as m, Content as n, ChevronLeftIcon as o, primitiveColors as p, ChevronRightIcon as q, getComboboxOptionItemWrapperStyles as r, safex as s, RhfForm as t, useDesignSystemTheme as u, DesignSystemEventSuppressInteractionProviderContext as v, DesignSystemEventSuppressInteractionTrueContextValue as w, augmentWithDataComponentProps as x, RestoreAntDDefaultClsPrefix as y, addDebugOutlineStylesIfEnabled as z };
|
|
3831
|
+
//# sourceMappingURL=Popover-CrX63HDP.js.map
|