@atlaskit/button 21.1.4 → 21.1.6
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/CHANGELOG.md +15 -0
- package/dist/cjs/new-button/containers/split-button/split-button.compiled.css +34 -0
- package/dist/cjs/new-button/containers/split-button/split-button.js +58 -118
- package/dist/cjs/new-button/variants/default/button.js +36 -41
- package/dist/cjs/new-button/variants/default/link.compiled.css +119 -0
- package/dist/cjs/new-button/variants/default/link.js +111 -59
- package/dist/cjs/new-button/variants/icon/button.js +128 -143
- package/dist/cjs/new-button/variants/icon/link.compiled.css +104 -0
- package/dist/cjs/new-button/variants/icon/link.js +101 -75
- package/dist/cjs/new-button/variants/shared/button-base.compiled.css +137 -0
- package/dist/cjs/new-button/variants/shared/button-base.js +223 -0
- package/dist/cjs/new-button/variants/shared/content.compiled.css +19 -0
- package/dist/cjs/new-button/variants/shared/content.js +13 -53
- package/dist/cjs/old-button/shared/button-base.js +1 -1
- package/dist/es2019/new-button/containers/split-button/split-button.compiled.css +34 -0
- package/dist/es2019/new-button/containers/split-button/split-button.js +54 -117
- package/dist/es2019/new-button/variants/default/button.js +47 -56
- package/dist/es2019/new-button/variants/default/link.compiled.css +119 -0
- package/dist/es2019/new-button/variants/default/link.js +113 -63
- package/dist/es2019/new-button/variants/icon/button.js +117 -133
- package/dist/es2019/new-button/variants/icon/link.compiled.css +104 -0
- package/dist/es2019/new-button/variants/icon/link.js +94 -70
- package/dist/es2019/new-button/variants/shared/button-base.compiled.css +137 -0
- package/dist/es2019/new-button/variants/shared/button-base.js +203 -0
- package/dist/es2019/new-button/variants/shared/content.compiled.css +19 -0
- package/dist/es2019/new-button/variants/shared/content.js +13 -52
- package/dist/es2019/old-button/shared/button-base.js +1 -1
- package/dist/esm/new-button/containers/split-button/split-button.compiled.css +34 -0
- package/dist/esm/new-button/containers/split-button/split-button.js +55 -120
- package/dist/esm/new-button/variants/default/button.js +33 -41
- package/dist/esm/new-button/variants/default/link.compiled.css +119 -0
- package/dist/esm/new-button/variants/default/link.js +111 -59
- package/dist/esm/new-button/variants/icon/button.js +128 -143
- package/dist/esm/new-button/variants/icon/link.compiled.css +104 -0
- package/dist/esm/new-button/variants/icon/link.js +98 -72
- package/dist/esm/new-button/variants/shared/button-base.compiled.css +137 -0
- package/dist/esm/new-button/variants/shared/button-base.js +213 -0
- package/dist/esm/new-button/variants/shared/content.compiled.css +19 -0
- package/dist/esm/new-button/variants/shared/content.js +13 -53
- package/dist/esm/old-button/shared/button-base.js +1 -1
- package/dist/types/new-button/containers/split-button/split-button.d.ts +4 -5
- package/dist/types/new-button/variants/default/button.d.ts +5 -1
- package/dist/types/new-button/variants/default/link.d.ts +22 -8
- package/dist/types/new-button/variants/icon/button.d.ts +5 -1
- package/dist/types/new-button/variants/icon/link.d.ts +11 -4
- package/dist/types/new-button/variants/shared/block-events.d.ts +1 -1
- package/dist/types/new-button/variants/shared/button-base.d.ts +45 -0
- package/dist/types/new-button/variants/shared/content.d.ts +5 -1
- package/dist/types/new-button/variants/types.d.ts +26 -6
- package/dist/types-ts4.5/new-button/containers/split-button/split-button.d.ts +4 -5
- package/dist/types-ts4.5/new-button/variants/default/button.d.ts +5 -1
- package/dist/types-ts4.5/new-button/variants/default/link.d.ts +22 -8
- package/dist/types-ts4.5/new-button/variants/icon/button.d.ts +5 -1
- package/dist/types-ts4.5/new-button/variants/icon/link.d.ts +11 -4
- package/dist/types-ts4.5/new-button/variants/shared/block-events.d.ts +1 -1
- package/dist/types-ts4.5/new-button/variants/shared/button-base.d.ts +45 -0
- package/dist/types-ts4.5/new-button/variants/shared/content.d.ts +5 -1
- package/dist/types-ts4.5/new-button/variants/types.d.ts +26 -6
- package/package.json +17 -15
- package/dist/cjs/new-button/variants/default/use-default-button.js +0 -98
- package/dist/cjs/new-button/variants/icon/use-icon-button.js +0 -88
- package/dist/cjs/new-button/variants/shared/use-button-base.js +0 -639
- package/dist/es2019/new-button/variants/default/use-default-button.js +0 -88
- package/dist/es2019/new-button/variants/icon/use-icon-button.js +0 -81
- package/dist/es2019/new-button/variants/shared/use-button-base.js +0 -619
- package/dist/esm/new-button/variants/default/use-default-button.js +0 -88
- package/dist/esm/new-button/variants/icon/use-icon-button.js +0 -81
- package/dist/esm/new-button/variants/shared/use-button-base.js +0 -629
- package/dist/types/new-button/variants/default/use-default-button.d.ts +0 -16
- package/dist/types/new-button/variants/icon/use-icon-button.d.ts +0 -16
- package/dist/types/new-button/variants/shared/use-button-base.d.ts +0 -46
- package/dist/types-ts4.5/new-button/variants/default/use-default-button.d.ts +0 -16
- package/dist/types-ts4.5/new-button/variants/icon/use-icon-button.d.ts +0 -16
- package/dist/types-ts4.5/new-button/variants/shared/use-button-base.d.ts +0 -46
|
@@ -1,619 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
3
|
-
import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
|
|
4
|
-
import { useId } from '@atlaskit/ds-lib/use-id';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
-
import { Box, xcss } from '@atlaskit/primitives';
|
|
7
|
-
import * as colors from '@atlaskit/theme/colors';
|
|
8
|
-
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
9
|
-
import { SplitButtonContext, useSplitButtonContext } from '../../containers/split-button/split-button-context';
|
|
10
|
-
import blockEvents from './block-events';
|
|
11
|
-
import { LOADING_LABEL } from './constants';
|
|
12
|
-
import renderLoadingOverlay from './loading-overlay';
|
|
13
|
-
const buttonStyles = xcss({
|
|
14
|
-
display: 'inline-flex',
|
|
15
|
-
boxSizing: 'border-box',
|
|
16
|
-
width: 'auto',
|
|
17
|
-
maxWidth: '100%',
|
|
18
|
-
position: 'relative',
|
|
19
|
-
alignItems: 'baseline',
|
|
20
|
-
justifyContent: 'center',
|
|
21
|
-
columnGap: 'space.050',
|
|
22
|
-
borderRadius: 'border.radius.100',
|
|
23
|
-
borderWidth: 'border.width.0',
|
|
24
|
-
flexShrink: 0,
|
|
25
|
-
height: '2rem',
|
|
26
|
-
font: 'font.body',
|
|
27
|
-
fontWeight: 'font.weight.medium',
|
|
28
|
-
paddingBlock: 'space.075',
|
|
29
|
-
paddingInlineEnd: 'space.150',
|
|
30
|
-
paddingInlineStart: 'space.150',
|
|
31
|
-
textAlign: 'center',
|
|
32
|
-
transition: 'background 0.1s ease-out',
|
|
33
|
-
verticalAlign: 'middle',
|
|
34
|
-
'::after': {
|
|
35
|
-
borderRadius: 'inherit',
|
|
36
|
-
inset: 'space.0',
|
|
37
|
-
borderStyle: 'solid',
|
|
38
|
-
borderWidth: "var(--ds-border-width, 1px)",
|
|
39
|
-
pointerEvents: 'none',
|
|
40
|
-
position: 'absolute'
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
const defaultInteractiveStyles = xcss({
|
|
44
|
-
':hover': {
|
|
45
|
-
background: "var(--ds-background-neutral-hovered, #091e4214)",
|
|
46
|
-
// @ts-expect-error
|
|
47
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
48
|
-
color: `var(--ds-text, ${colors.N500})`
|
|
49
|
-
},
|
|
50
|
-
':active': {
|
|
51
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
52
|
-
background: `var(--ds-background-neutral-pressed, ${colors.B75})`,
|
|
53
|
-
// @ts-expect-error
|
|
54
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
55
|
-
color: `var(--ds-text, ${colors.B400})`
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
const defaultInteractiveRefreshedStyles = xcss({
|
|
59
|
-
':hover': {
|
|
60
|
-
background: "var(--ds-background-neutral-subtle-hovered, #091E420F)",
|
|
61
|
-
color: 'color.text.subtle'
|
|
62
|
-
},
|
|
63
|
-
':active': {
|
|
64
|
-
background: "var(--ds-background-neutral-subtle-pressed, #091E4224)",
|
|
65
|
-
color: 'color.text.subtle'
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
const defaultStyles = xcss({
|
|
69
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
|
|
70
|
-
background: `var(--ds-background-neutral, ${colors.N20A})`,
|
|
71
|
-
// @ts-expect-error — using tokens for explicit fallback usage.
|
|
72
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- -- Ignored via go/DSP-18766
|
|
73
|
-
color: `var(--ds-text, ${colors.N500})`,
|
|
74
|
-
':visited': {
|
|
75
|
-
// @ts-expect-error
|
|
76
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
77
|
-
color: `var(--ds-text, ${colors.N500})`
|
|
78
|
-
},
|
|
79
|
-
':hover': {
|
|
80
|
-
// @ts-expect-error — using tokens for explicit fallback usage.
|
|
81
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- -- Ignored via go/DSP-18766
|
|
82
|
-
color: `var(--ds-text, ${colors.N500})`
|
|
83
|
-
},
|
|
84
|
-
':active': {
|
|
85
|
-
// @ts-expect-error — using tokens for explicit fallback usage.
|
|
86
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- -- Ignored via go/DSP-18766
|
|
87
|
-
color: `var(--ds-text, ${colors.N500})`
|
|
88
|
-
},
|
|
89
|
-
':focus': {
|
|
90
|
-
// @ts-expect-error — using tokens for explicit fallback usage.
|
|
91
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- -- Ignored via go/DSP-18766
|
|
92
|
-
color: `var(--ds-text, ${colors.N500})`
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
const defaultRefreshedStyles = xcss({
|
|
96
|
-
background: "var(--ds-background-neutral-subtle, #00000000)",
|
|
97
|
-
color: 'color.text.subtle',
|
|
98
|
-
'::after': {
|
|
99
|
-
content: '""',
|
|
100
|
-
borderColor: 'color.border'
|
|
101
|
-
},
|
|
102
|
-
':visited': {
|
|
103
|
-
color: 'color.text.subtle'
|
|
104
|
-
},
|
|
105
|
-
':hover': {
|
|
106
|
-
color: 'color.text.subtle'
|
|
107
|
-
},
|
|
108
|
-
':active': {
|
|
109
|
-
color: 'color.text.subtle'
|
|
110
|
-
},
|
|
111
|
-
':focus': {
|
|
112
|
-
color: 'color.text.subtle'
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
const primaryStyles = xcss({
|
|
116
|
-
background: "var(--ds-background-brand-bold, #0052CC)",
|
|
117
|
-
color: 'color.text.inverse',
|
|
118
|
-
':visited': {
|
|
119
|
-
color: 'color.text.inverse'
|
|
120
|
-
},
|
|
121
|
-
':hover': {
|
|
122
|
-
color: 'color.text.inverse'
|
|
123
|
-
},
|
|
124
|
-
':active': {
|
|
125
|
-
color: 'color.text.inverse'
|
|
126
|
-
},
|
|
127
|
-
':focus': {
|
|
128
|
-
color: 'color.text.inverse'
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
const primaryInteractiveStyles = xcss({
|
|
132
|
-
':hover': {
|
|
133
|
-
// @ts-expect-error
|
|
134
|
-
color: "var(--ds-text-inverse, #FFFFFF)",
|
|
135
|
-
background: "var(--ds-background-brand-bold-hovered, #0065FF)"
|
|
136
|
-
},
|
|
137
|
-
':active': {
|
|
138
|
-
// @ts-expect-error
|
|
139
|
-
color: "var(--ds-text-inverse, #FFFFFF)",
|
|
140
|
-
background: "var(--ds-background-brand-bold-pressed, #0747A6)"
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
const warningStyles = xcss({
|
|
144
|
-
background: "var(--ds-background-warning-bold, #FFAB00)",
|
|
145
|
-
// @ts-expect-error
|
|
146
|
-
color: "var(--ds-text-warning-inverse, #172B4D)",
|
|
147
|
-
':visited': {
|
|
148
|
-
// @ts-expect-error
|
|
149
|
-
color: "var(--ds-text-warning-inverse, #172B4D)"
|
|
150
|
-
},
|
|
151
|
-
':hover': {
|
|
152
|
-
// @ts-expect-error
|
|
153
|
-
color: "var(--ds-text-warning-inverse, #172B4D)"
|
|
154
|
-
},
|
|
155
|
-
':active': {
|
|
156
|
-
// @ts-expect-error
|
|
157
|
-
color: "var(--ds-text-warning-inverse, #172B4D)"
|
|
158
|
-
},
|
|
159
|
-
':focus': {
|
|
160
|
-
// @ts-expect-error
|
|
161
|
-
color: "var(--ds-text-warning-inverse, #172B4D)"
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
const warningInteractiveStyles = xcss({
|
|
165
|
-
':hover': {
|
|
166
|
-
// @ts-expect-error
|
|
167
|
-
color: "var(--ds-text-warning-inverse, #172B4D)",
|
|
168
|
-
background: "var(--ds-background-warning-bold-hovered, #FFC400)"
|
|
169
|
-
},
|
|
170
|
-
':active': {
|
|
171
|
-
// @ts-expect-error
|
|
172
|
-
color: "var(--ds-text-warning-inverse, #172B4D)",
|
|
173
|
-
background: "var(--ds-background-warning-bold-pressed, #FF991F)"
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
const dangerStyles = xcss({
|
|
177
|
-
background: "var(--ds-background-danger-bold, #DE350B)",
|
|
178
|
-
color: 'color.text.inverse',
|
|
179
|
-
':visited': {
|
|
180
|
-
color: 'color.text.inverse'
|
|
181
|
-
},
|
|
182
|
-
':hover': {
|
|
183
|
-
color: 'color.text.inverse'
|
|
184
|
-
},
|
|
185
|
-
':active': {
|
|
186
|
-
color: 'color.text.inverse'
|
|
187
|
-
},
|
|
188
|
-
':focus': {
|
|
189
|
-
color: 'color.text.inverse'
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
const dangerInteractiveStyles = xcss({
|
|
193
|
-
':hover': {
|
|
194
|
-
color: 'color.text.inverse',
|
|
195
|
-
background: "var(--ds-background-danger-bold-hovered, #FF5630)"
|
|
196
|
-
},
|
|
197
|
-
':active': {
|
|
198
|
-
color: 'color.text.inverse',
|
|
199
|
-
background: "var(--ds-background-danger-bold-pressed, #BF2600)"
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
const discoveryStyles = xcss({
|
|
203
|
-
background: "var(--ds-background-discovery-bold, #5243AA)",
|
|
204
|
-
color: 'color.text.inverse',
|
|
205
|
-
':visited': {
|
|
206
|
-
color: 'color.text.inverse'
|
|
207
|
-
},
|
|
208
|
-
':hover': {
|
|
209
|
-
color: 'color.text.inverse'
|
|
210
|
-
},
|
|
211
|
-
':active': {
|
|
212
|
-
color: 'color.text.inverse'
|
|
213
|
-
},
|
|
214
|
-
':focus': {
|
|
215
|
-
color: 'color.text.inverse'
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
const discoveryInteractiveStyles = xcss({
|
|
219
|
-
':hover': {
|
|
220
|
-
color: 'color.text.inverse',
|
|
221
|
-
background: "var(--ds-background-discovery-bold-hovered, #8777D9)"
|
|
222
|
-
},
|
|
223
|
-
':active': {
|
|
224
|
-
color: 'color.text.inverse',
|
|
225
|
-
background: "var(--ds-background-discovery-bold-pressed, #5243AA)"
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
const subtleStyles = xcss({
|
|
229
|
-
background: "var(--ds-background-neutral-subtle, transparent)",
|
|
230
|
-
// @ts-expect-error
|
|
231
|
-
color: "var(--ds-text, #42526E)",
|
|
232
|
-
':visited': {
|
|
233
|
-
// @ts-expect-error
|
|
234
|
-
color: "var(--ds-text, #42526E)"
|
|
235
|
-
},
|
|
236
|
-
':hover': {
|
|
237
|
-
// @ts-expect-error
|
|
238
|
-
color: "var(--ds-text, #42526E)"
|
|
239
|
-
},
|
|
240
|
-
':active': {
|
|
241
|
-
// @ts-expect-error
|
|
242
|
-
color: "var(--ds-text, #42526E)"
|
|
243
|
-
},
|
|
244
|
-
':focus': {
|
|
245
|
-
// @ts-expect-error
|
|
246
|
-
color: "var(--ds-text, #42526E)"
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
const subtleRefreshedStyles = xcss({
|
|
250
|
-
background: "var(--ds-background-neutral-subtle, transparent)",
|
|
251
|
-
color: 'color.text.subtle',
|
|
252
|
-
':visited': {
|
|
253
|
-
color: 'color.text.subtle'
|
|
254
|
-
},
|
|
255
|
-
':hover': {
|
|
256
|
-
color: 'color.text.subtle'
|
|
257
|
-
},
|
|
258
|
-
':active': {
|
|
259
|
-
color: 'color.text.subtle'
|
|
260
|
-
},
|
|
261
|
-
':focus': {
|
|
262
|
-
color: 'color.text.subtle'
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
const subtleInteractiveStyles = xcss({
|
|
266
|
-
':hover': {
|
|
267
|
-
background: "var(--ds-background-neutral-subtle-hovered, #091e4214)",
|
|
268
|
-
// @ts-expect-error
|
|
269
|
-
color: "var(--ds-text, #42526E)"
|
|
270
|
-
},
|
|
271
|
-
':active': {
|
|
272
|
-
background: "var(--ds-background-neutral-subtle-pressed, #B3D4FF)",
|
|
273
|
-
// @ts-expect-error
|
|
274
|
-
color: "var(--ds-text, #42526E)"
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
const subtleInteractiveRefreshedStyles = xcss({
|
|
278
|
-
':hover': {
|
|
279
|
-
background: "var(--ds-background-neutral-subtle-hovered, #091e4214)",
|
|
280
|
-
color: 'color.text.subtle'
|
|
281
|
-
},
|
|
282
|
-
':active': {
|
|
283
|
-
background: "var(--ds-background-neutral-subtle-pressed, #B3D4FF)",
|
|
284
|
-
color: 'color.text.subtle'
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
// Reinforce existing styles with higher specificity
|
|
289
|
-
// to defend against global anchor styles from products,
|
|
290
|
-
// preventing issues in Jira and Confluence.
|
|
291
|
-
const linkDefensiveStyles = xcss({
|
|
292
|
-
textDecoration: 'none',
|
|
293
|
-
':hover': {
|
|
294
|
-
textDecoration: 'none'
|
|
295
|
-
},
|
|
296
|
-
':active': {
|
|
297
|
-
textDecoration: 'none'
|
|
298
|
-
},
|
|
299
|
-
':focus': {
|
|
300
|
-
textDecoration: 'none'
|
|
301
|
-
},
|
|
302
|
-
':visited': {
|
|
303
|
-
textDecoration: 'none'
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
const disabledStyles = xcss({
|
|
307
|
-
cursor: 'not-allowed',
|
|
308
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
309
|
-
background: `var(--ds-background-disabled, ${colors.N20A})`,
|
|
310
|
-
color: 'color.text.disabled',
|
|
311
|
-
'::after': {
|
|
312
|
-
content: 'none'
|
|
313
|
-
},
|
|
314
|
-
':visited': {
|
|
315
|
-
color: 'color.text.disabled'
|
|
316
|
-
},
|
|
317
|
-
':hover': {
|
|
318
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
319
|
-
background: `var(--ds-background-disabled, ${colors.N20A})`,
|
|
320
|
-
color: 'color.text.disabled'
|
|
321
|
-
},
|
|
322
|
-
':active': {
|
|
323
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
324
|
-
background: `var(--ds-background-disabled, ${colors.N20A})`,
|
|
325
|
-
color: 'color.text.disabled'
|
|
326
|
-
},
|
|
327
|
-
':focus': {
|
|
328
|
-
color: 'color.text.disabled'
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
const selectedStyles = xcss({
|
|
332
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
333
|
-
background: `var(--ds-background-selected, ${colors.N700})`,
|
|
334
|
-
// @ts-expect-error
|
|
335
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
336
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
337
|
-
':visited': {
|
|
338
|
-
// @ts-expect-error
|
|
339
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
340
|
-
color: `var(--ds-text-selected, ${colors.N20})`
|
|
341
|
-
},
|
|
342
|
-
':hover': {
|
|
343
|
-
// @ts-expect-error
|
|
344
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
345
|
-
color: `var(--ds-text-selected, ${colors.N20})`
|
|
346
|
-
},
|
|
347
|
-
':active': {
|
|
348
|
-
// @ts-expect-error
|
|
349
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
350
|
-
color: `var(--ds-text-selected, ${colors.N20})`
|
|
351
|
-
},
|
|
352
|
-
':focus': {
|
|
353
|
-
// @ts-expect-error
|
|
354
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
355
|
-
color: `var(--ds-text-selected, ${colors.N20})`
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
const selectedRefreshedStyles = xcss({
|
|
359
|
-
background: "var(--ds-background-selected, #E9F2FF)",
|
|
360
|
-
color: 'color.text.selected',
|
|
361
|
-
'::after': {
|
|
362
|
-
content: '""',
|
|
363
|
-
borderColor: 'color.border.selected'
|
|
364
|
-
},
|
|
365
|
-
':visited': {
|
|
366
|
-
color: 'color.text.selected'
|
|
367
|
-
},
|
|
368
|
-
':hover': {
|
|
369
|
-
color: 'color.text.selected'
|
|
370
|
-
},
|
|
371
|
-
':active': {
|
|
372
|
-
color: 'color.text.selected'
|
|
373
|
-
},
|
|
374
|
-
':focus': {
|
|
375
|
-
color: 'color.text.selected'
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
const selectedInsideSplitButtonStyles = xcss({
|
|
379
|
-
// This is 2 so it appears above the split button divider when selected.
|
|
380
|
-
// See split-button.tsx.
|
|
381
|
-
// @ts-expect-error — We need a local zindex just for button.
|
|
382
|
-
zIndex: 2
|
|
383
|
-
});
|
|
384
|
-
const selectedInteractiveStyles = xcss({
|
|
385
|
-
':hover': {
|
|
386
|
-
// @ts-expect-error
|
|
387
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
388
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
389
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
390
|
-
background: `var(--ds-background-selected-hovered, ${colors.N700})`
|
|
391
|
-
},
|
|
392
|
-
':active': {
|
|
393
|
-
// @ts-expect-error
|
|
394
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
395
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
396
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
397
|
-
background: `var(--ds-background-selected-pressed, ${colors.N700})`
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
// TODO: Remove me once we kill color fallbacks
|
|
402
|
-
const selectedWarningStyles = xcss({
|
|
403
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
404
|
-
background: `var(--ds-background-selected, ${colors.Y400})`,
|
|
405
|
-
// @ts-expect-error
|
|
406
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
407
|
-
color: `var(--ds-text-selected, ${colors.N800})`,
|
|
408
|
-
':hover': {
|
|
409
|
-
// @ts-expect-error
|
|
410
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
411
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
412
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
413
|
-
background: `var(--ds-background-selected, ${colors.Y400})`
|
|
414
|
-
},
|
|
415
|
-
':active': {
|
|
416
|
-
// @ts-expect-error
|
|
417
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
418
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
419
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
420
|
-
background: `var(--ds-background-selected, ${colors.Y400})`
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
// TODO: Remove me once we kill color fallbacks
|
|
425
|
-
const selectedDangerStyles = xcss({
|
|
426
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
427
|
-
background: `var(--ds-background-selected, ${colors.R500})`,
|
|
428
|
-
// @ts-expect-error
|
|
429
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
430
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
431
|
-
':hover': {
|
|
432
|
-
// @ts-expect-error
|
|
433
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
434
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
435
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
436
|
-
background: `var(--ds-background-selected, ${colors.R500})`
|
|
437
|
-
},
|
|
438
|
-
':active': {
|
|
439
|
-
// @ts-expect-error
|
|
440
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
441
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
442
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
443
|
-
background: `var(--ds-background-selected, ${colors.R500})`
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
// TODO: Remove me once we kill color fallbacks
|
|
448
|
-
const selectedDiscoveryStyles = xcss({
|
|
449
|
-
background: "var(--ds-background-selected, #403294)",
|
|
450
|
-
// @ts-expect-error
|
|
451
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
452
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
453
|
-
':hover': {
|
|
454
|
-
// @ts-expect-error
|
|
455
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
456
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
457
|
-
background: "var(--ds-background-selected, #403294)"
|
|
458
|
-
},
|
|
459
|
-
':active': {
|
|
460
|
-
// @ts-expect-error
|
|
461
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
462
|
-
color: `var(--ds-text-selected, ${colors.N20})`,
|
|
463
|
-
background: "var(--ds-background-selected, #403294)"
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
const spacingCompactStyles = xcss({
|
|
467
|
-
columnGap: 'space.050',
|
|
468
|
-
height: '1.5rem',
|
|
469
|
-
paddingBlock: 'space.025',
|
|
470
|
-
paddingInlineEnd: 'space.150',
|
|
471
|
-
paddingInlineStart: 'space.150',
|
|
472
|
-
verticalAlign: 'middle'
|
|
473
|
-
});
|
|
474
|
-
const circleStyles = xcss({
|
|
475
|
-
borderRadius: 'border.radius.circle'
|
|
476
|
-
});
|
|
477
|
-
const fullWidthStyles = xcss({
|
|
478
|
-
width: '100%'
|
|
479
|
-
});
|
|
480
|
-
const loadingStyles = xcss({
|
|
481
|
-
cursor: 'progress'
|
|
482
|
-
});
|
|
483
|
-
const iconButtonStyles = xcss({
|
|
484
|
-
height: '2rem',
|
|
485
|
-
width: '2rem',
|
|
486
|
-
paddingInlineEnd: 'space.0',
|
|
487
|
-
paddingInlineStart: 'space.0'
|
|
488
|
-
});
|
|
489
|
-
const iconButtonCompactStyles = xcss({
|
|
490
|
-
width: '1.5rem',
|
|
491
|
-
height: '1.5rem'
|
|
492
|
-
});
|
|
493
|
-
const buttonIconBeforeStyles = xcss({
|
|
494
|
-
paddingInlineStart: 'space.100'
|
|
495
|
-
});
|
|
496
|
-
const buttonIconAfterStyles = xcss({
|
|
497
|
-
paddingInlineEnd: 'space.100'
|
|
498
|
-
});
|
|
499
|
-
const splitButtonStyles = xcss({
|
|
500
|
-
':focus-visible': {
|
|
501
|
-
zIndex: 'card'
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
const navigationSplitButtonStyles = xcss({
|
|
505
|
-
width: '24px',
|
|
506
|
-
backgroundColor: 'color.background.neutral.subtle',
|
|
507
|
-
paddingInlineEnd: 'space.075',
|
|
508
|
-
paddingInlineStart: 'space.075'
|
|
509
|
-
});
|
|
510
|
-
const loadingOverlayStyles = xcss({
|
|
511
|
-
display: 'flex',
|
|
512
|
-
position: 'absolute',
|
|
513
|
-
alignItems: 'center',
|
|
514
|
-
justifyContent: 'center',
|
|
515
|
-
insetBlockEnd: 'space.0',
|
|
516
|
-
insetBlockStart: 'space.0',
|
|
517
|
-
insetInlineEnd: 'space.0',
|
|
518
|
-
insetInlineStart: 'space.0'
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* __Use button base__
|
|
523
|
-
*
|
|
524
|
-
* A React hook that accepts a set of common Button props,
|
|
525
|
-
* and processes them to return consistent base props for usage
|
|
526
|
-
* across various Button components.
|
|
527
|
-
*
|
|
528
|
-
* It also:
|
|
529
|
-
* - Implements auto focus when enabled.
|
|
530
|
-
* - Appends the `onClick` event with UFO analytics tracking.
|
|
531
|
-
*
|
|
532
|
-
* @private
|
|
533
|
-
*/
|
|
534
|
-
const useButtonBase = ({
|
|
535
|
-
appearance: propAppearance = 'default',
|
|
536
|
-
autoFocus = false,
|
|
537
|
-
buttonType,
|
|
538
|
-
isDisabled: propIsDisabled = false,
|
|
539
|
-
isLoading = false,
|
|
540
|
-
isSelected: propIsSelected = false,
|
|
541
|
-
// TODO: Separate Icon Button styling from button base
|
|
542
|
-
isIconButton = false,
|
|
543
|
-
isCircle = false,
|
|
544
|
-
// TODO: Separate icon slot styling from button base
|
|
545
|
-
hasIconBefore = false,
|
|
546
|
-
hasIconAfter = false,
|
|
547
|
-
children,
|
|
548
|
-
onClick,
|
|
549
|
-
onMouseDownCapture,
|
|
550
|
-
onMouseUpCapture,
|
|
551
|
-
onKeyDownCapture,
|
|
552
|
-
onKeyUpCapture,
|
|
553
|
-
onTouchStartCapture,
|
|
554
|
-
onTouchEndCapture,
|
|
555
|
-
onPointerDownCapture,
|
|
556
|
-
onPointerUpCapture,
|
|
557
|
-
onClickCapture,
|
|
558
|
-
ref,
|
|
559
|
-
shouldFitContainer = false,
|
|
560
|
-
spacing: propSpacing = 'default',
|
|
561
|
-
testId,
|
|
562
|
-
ariaLabel,
|
|
563
|
-
ariaLabelledBy
|
|
564
|
-
}) => {
|
|
565
|
-
const localRef = useRef(null);
|
|
566
|
-
const splitButtonContext = useSplitButtonContext();
|
|
567
|
-
const loadingLabelId = useId();
|
|
568
|
-
const isSplitButton = Boolean(splitButtonContext);
|
|
569
|
-
const isNavigationSplitButton = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isNavigationSplitButton) || false;
|
|
570
|
-
const isDefaultAppearanceSplitButton = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.appearance) === 'default';
|
|
571
|
-
const appearance = isDefaultAppearanceSplitButton && fg('platform-component-visual-refresh') ? 'subtle' : (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.appearance) || propAppearance;
|
|
572
|
-
const spacing = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.spacing) || propSpacing;
|
|
573
|
-
const isDisabled = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isDisabled) || propIsDisabled;
|
|
574
|
-
const isInteractive = !isDisabled && !isLoading;
|
|
575
|
-
// Also treat loading buttons as disabled
|
|
576
|
-
const isEffectivelyDisabled = isDisabled || isLoading;
|
|
577
|
-
const isSelected = propIsSelected && !isDisabled;
|
|
578
|
-
useAutoFocus(localRef, autoFocus);
|
|
579
|
-
return {
|
|
580
|
-
ref: mergeRefs([localRef, ref]),
|
|
581
|
-
xcss: [buttonStyles, appearance === 'default' && (fg('platform-component-visual-refresh') ? defaultRefreshedStyles : defaultStyles), appearance === 'default' && isInteractive && (fg('platform-component-visual-refresh') ? defaultInteractiveRefreshedStyles : defaultInteractiveStyles), appearance === 'primary' && primaryStyles, appearance === 'primary' && isInteractive && primaryInteractiveStyles, appearance === 'warning' && warningStyles, appearance === 'warning' && isInteractive && warningInteractiveStyles, appearance === 'danger' && dangerStyles, appearance === 'danger' && isInteractive && dangerInteractiveStyles, appearance === 'discovery' && discoveryStyles, appearance === 'discovery' && isInteractive && discoveryInteractiveStyles, appearance === 'subtle' && (fg('platform-component-visual-refresh') ? subtleRefreshedStyles : subtleStyles), appearance === 'subtle' && isInteractive && (fg('platform-component-visual-refresh') ? subtleInteractiveRefreshedStyles : subtleInteractiveStyles), buttonType === 'link' && linkDefensiveStyles, isSelected && (fg('platform-component-visual-refresh') ? selectedRefreshedStyles : selectedStyles), isSelected && isSplitButton && selectedInsideSplitButtonStyles, isSelected && isInteractive && selectedInteractiveStyles,
|
|
582
|
-
// TODO: remove me once we kill color fallbacks
|
|
583
|
-
isSelected && appearance === 'danger' && selectedDangerStyles,
|
|
584
|
-
// TODO: remove me once we kill color fallbacks
|
|
585
|
-
isSelected && appearance === 'warning' && selectedWarningStyles,
|
|
586
|
-
// TODO: remove me once we kill color fallbacks
|
|
587
|
-
isSelected && appearance === 'discovery' && selectedDiscoveryStyles, isDisabled && disabledStyles, isCircle && !isSplitButton && circleStyles, spacing === 'compact' && spacingCompactStyles, hasIconBefore && buttonIconBeforeStyles, hasIconAfter && buttonIconAfterStyles, isIconButton && iconButtonStyles, isIconButton && spacing === 'compact' && iconButtonCompactStyles, shouldFitContainer && fullWidthStyles, isLoading && loadingStyles, isSplitButton && splitButtonStyles, isNavigationSplitButton && navigationSplitButtonStyles],
|
|
588
|
-
isDisabled: isEffectivelyDisabled,
|
|
589
|
-
children: /*#__PURE__*/React.createElement(SplitButtonContext.Provider, {
|
|
590
|
-
value: undefined
|
|
591
|
-
}, children, isLoading ? /*#__PURE__*/React.createElement(Box, {
|
|
592
|
-
as: "span",
|
|
593
|
-
xcss: loadingOverlayStyles
|
|
594
|
-
}, renderLoadingOverlay({
|
|
595
|
-
spacing,
|
|
596
|
-
appearance,
|
|
597
|
-
isDisabled,
|
|
598
|
-
isSelected,
|
|
599
|
-
testId
|
|
600
|
-
})) : null, isLoading && (children && !ariaLabel && !ariaLabelledBy || ariaLabelledBy) && /*#__PURE__*/React.createElement(VisuallyHidden, {
|
|
601
|
-
id: loadingLabelId
|
|
602
|
-
}, LOADING_LABEL)),
|
|
603
|
-
'aria-label': isLoading && ariaLabel && !ariaLabelledBy ? `${ariaLabel} ${LOADING_LABEL}` : ariaLabel,
|
|
604
|
-
'aria-labelledby': isLoading && ariaLabelledBy ? `${ariaLabelledBy} ${loadingLabelId}` : ariaLabelledBy,
|
|
605
|
-
...blockEvents(isEffectivelyDisabled, {
|
|
606
|
-
onClick,
|
|
607
|
-
onMouseDownCapture,
|
|
608
|
-
onMouseUpCapture,
|
|
609
|
-
onKeyDownCapture,
|
|
610
|
-
onKeyUpCapture,
|
|
611
|
-
onTouchStartCapture,
|
|
612
|
-
onTouchEndCapture,
|
|
613
|
-
onPointerDownCapture,
|
|
614
|
-
onPointerUpCapture,
|
|
615
|
-
onClickCapture
|
|
616
|
-
})
|
|
617
|
-
};
|
|
618
|
-
};
|
|
619
|
-
export default useButtonBase;
|