@atlaskit/button 21.1.5 → 21.1.7

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