@mirohq/design-system-button 2.1.2-button.0 → 2.1.2-test-changelog.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -3,295 +3,303 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
+ var button = require('@react-aria/button');
7
+ var utils = require('@react-aria/utils');
6
8
  var designSystemSpinner = require('@mirohq/design-system-spinner');
9
+ var link = require('@react-aria/link');
10
+ var focus = require('@react-aria/focus');
7
11
  var designSystemPrimitive = require('@mirohq/design-system-primitive');
8
12
  var designSystemStitches = require('@mirohq/design-system-stitches');
9
- var designSystemBaseButton = require('@mirohq/design-system-base-button');
13
+ var designSystemStyles = require('@mirohq/design-system-styles');
10
14
 
11
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
16
 
13
17
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
18
 
15
- const StyledIconSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.svg, {});
16
- const IconSlot = React__default["default"].forwardRef(({ children, ...restProps }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledIconSlot, {
17
- ...restProps,
18
- ref: forwardRef,
19
- "aria-hidden": true,
20
- asChild: true
21
- }, children));
22
-
23
- const activeSelector = "&:active, &[data-pressed]";
24
- const disabledSelector = '&[disabled], &[aria-disabled="true"]';
25
- const iconSlotSelector = `& ${StyledIconSlot}`;
26
- const solidDisabled = {
27
- [disabledSelector]: {
28
- backgroundColor: "$background-neutrals-disabled",
29
- color: "$text-neutrals-disabled",
30
- [iconSlotSelector]: {
31
- color: "$icon-neutrals-disabled"
32
- }
19
+ const focusFilled = {
20
+ "&[data-focused]": {
21
+ boxShadow: `inset 0 0 0 1px white, ${designSystemStyles.focus.defaults["&:focus-visible"].boxShadow}`
33
22
  }
34
23
  };
35
- const outlineDisabled = {
36
- [disabledSelector]: {
37
- backgroundColor: "$background-neutrals",
38
- borderColor: "$border-neutrals-disabled",
39
- color: "$text-neutrals-disabled",
40
- [iconSlotSelector]: {
41
- color: "$icon-neutrals-disabled"
42
- }
24
+ const focusOutline = {
25
+ "&[data-focused]": {
26
+ ...designSystemStyles.focus.defaults,
27
+ borderColor: "transparent"
43
28
  }
44
29
  };
45
- const ghostDisabled = {
46
- [disabledSelector]: {
47
- color: "$text-neutrals-disabled",
48
- backgroundColor: "$transparent",
49
- [iconSlotSelector]: {
50
- color: "$icon-neutrals-disabled"
51
- }
52
- }
30
+ const focusDefault = {
31
+ "&[data-focused]": designSystemStyles.focus.defaults
53
32
  };
54
- const LABEL_OFFSET = 2;
55
- const StyledButton = designSystemStitches.styled(designSystemBaseButton.BaseButton, {
56
- userSelect: "none",
33
+ const pressedSelector = "&:active, &[data-pressed]";
34
+ const StyledButton = designSystemStitches.styled(designSystemPrimitive.Primitive.button, {
35
+ boxSizing: "border-box",
36
+ display: "inline-block",
37
+ outline: "none",
57
38
  whiteSpace: "nowrap",
58
39
  textOverflow: "ellipsis",
59
40
  textAlign: "center",
41
+ verticalAlign: "middle",
42
+ userSelect: "none",
43
+ fontFamily: "inherit",
44
+ fontStyle: "normal",
45
+ fontStretch: "normal",
46
+ letterSpacing: "normal",
47
+ fontWeight: "normal",
60
48
  position: "relative",
61
- width: "fit-content",
62
- maxWidth: "100%",
63
- lineHeight: 1.5,
64
- border: "1px solid transparent",
65
- "&[data-focused]": {
66
- boxShadow: "$focus-small-outline",
67
- borderColor: "$blue-500 !important"
68
- },
69
- [`& ${StyledIconSlot}:first-child`]: {
70
- marginLeft: -LABEL_OFFSET,
71
- marginRight: `calc($50 + ${LABEL_OFFSET}px)`
72
- },
73
- [`& ${StyledIconSlot}:last-child`]: {
74
- marginRight: -LABEL_OFFSET,
75
- marginLeft: `calc($50 + ${LABEL_OFFSET}px)`
49
+ cursor: "pointer",
50
+ border: "none",
51
+ textDecoration: "none",
52
+ backgroundColor: "transparent",
53
+ "&[disabled]": {
54
+ pointerEvents: "none",
55
+ opacity: 0.4
76
56
  },
77
57
  variants: {
78
58
  variant: {
79
- "solid-prominent": {
80
- backgroundColor: "$background-primary-prominent",
81
- color: "$text-primary-inverted",
82
- [iconSlotSelector]: {
83
- color: "$icon-primary-inverted"
84
- },
85
- "&:hover": {
86
- backgroundColor: "$background-primary-prominent-hover"
87
- },
88
- [activeSelector]: {
89
- backgroundColor: "$background-primary-prominent-active"
90
- },
91
- ...solidDisabled
59
+ primary: {},
60
+ secondary: {},
61
+ danger: {}
62
+ },
63
+ appearance: {
64
+ filled: {},
65
+ outlined: {},
66
+ flat: {}
67
+ },
68
+ size: {
69
+ large: {
70
+ padding: "14px 32px 18px 32px",
71
+ fontSize: "20px",
72
+ lineHeight: "28px",
73
+ height: "60px"
92
74
  },
93
- "outline-prominent": {
94
- backgroundColor: "$background-neutrals",
95
- borderColor: "$border-primary",
96
- color: "$text-primary",
97
- [iconSlotSelector]: {
98
- color: "$icon-primary"
99
- },
100
- "&:hover": {
101
- backgroundColor: "$background-primary-subtle-hover",
102
- borderColor: "$border-primary-hover",
103
- color: "$text-primary-hover",
104
- [iconSlotSelector]: {
105
- color: "$icon-primary-hover"
106
- }
107
- },
108
- [activeSelector]: {
109
- backgroundColor: "$background-primary-subtle-active",
110
- borderColor: "$border-primary-active",
111
- color: "$text-primary-active",
112
- [iconSlotSelector]: {
113
- color: "$icon-primary-active"
114
- }
115
- },
116
- ...outlineDisabled
75
+ medium: {
76
+ padding: "11px 24px 13px 24px",
77
+ fontSize: "16px",
78
+ lineHeight: "24px",
79
+ height: "48px"
117
80
  },
118
- "ghost-prominent": {
119
- backgroundColor: "transparent",
120
- color: "$text-primary",
121
- "&:hover": {
122
- backgroundColor: "$background-primary-subtle-hover",
123
- color: "$text-primary-hover",
124
- [iconSlotSelector]: {
125
- color: "$icon-primary-hover"
126
- }
127
- },
128
- [activeSelector]: {
129
- backgroundColor: "$background-primary-subtle-active",
130
- color: "$text-primary-active",
131
- [iconSlotSelector]: {
132
- color: "$icon-primary-active"
133
- }
134
- },
135
- ...ghostDisabled
81
+ small: {
82
+ padding: "7px 16px 9px 16px",
83
+ fontSize: "14px",
84
+ lineHeight: "20px",
85
+ height: "36px"
136
86
  },
137
- "solid-subtle": {
138
- backgroundColor: "$background-neutrals-subtle",
139
- color: "$text-neutrals",
140
- [iconSlotSelector]: {
141
- color: "$icon-neutrals"
142
- },
143
- "&:hover": {
144
- backgroundColor: "$background-neutrals-subtle-hover"
145
- },
146
- [activeSelector]: {
147
- backgroundColor: "$background-neutrals-subtle-active"
148
- },
149
- ...solidDisabled
87
+ "x-small": {
88
+ padding: "5px 12px 7px",
89
+ fontSize: "14px",
90
+ lineHeight: "20px",
91
+ height: "32px"
150
92
  },
151
- "outline-subtle": {
152
- backgroundColor: "$background-neutrals",
153
- border: "1px solid $border-neutrals",
154
- color: "$text-neutrals",
155
- [iconSlotSelector]: {
156
- color: "$icon-neutrals"
157
- },
93
+ "xx-small": {
94
+ padding: "3px 12px",
95
+ fontSize: "12px",
96
+ lineHeight: "18px",
97
+ height: "24px"
98
+ }
99
+ },
100
+ rounded: {
101
+ true: {
102
+ borderRadius: "$half"
103
+ }
104
+ },
105
+ loading: {
106
+ true: {
107
+ "&[disabled]": {
108
+ cursor: "default",
109
+ opacity: 1,
110
+ pointerEvents: "none",
111
+ "& > span": {
112
+ visibility: "hidden"
113
+ }
114
+ }
115
+ }
116
+ },
117
+ fluid: {
118
+ true: {
119
+ width: "100%",
120
+ display: "block"
121
+ }
122
+ }
123
+ },
124
+ compoundVariants: [
125
+ {
126
+ size: "small",
127
+ rounded: true,
128
+ css: {
129
+ padding: "10px 16px",
130
+ height: "40px"
131
+ }
132
+ },
133
+ {
134
+ size: "large",
135
+ rounded: false,
136
+ css: {
137
+ borderRadius: "$50"
138
+ }
139
+ },
140
+ {
141
+ size: "medium",
142
+ rounded: false,
143
+ css: {
144
+ borderRadius: "$50"
145
+ }
146
+ },
147
+ {
148
+ size: "small",
149
+ rounded: false,
150
+ css: {
151
+ borderRadius: "$50"
152
+ }
153
+ },
154
+ {
155
+ size: "x-small",
156
+ rounded: false,
157
+ css: {
158
+ borderRadius: "$50"
159
+ }
160
+ },
161
+ {
162
+ size: "xx-small",
163
+ rounded: false,
164
+ css: {
165
+ borderRadius: "$25"
166
+ }
167
+ },
168
+ {
169
+ variant: "primary",
170
+ appearance: "filled",
171
+ css: {
172
+ color: "$white",
173
+ backgroundColor: "$blue-600",
174
+ ...focusFilled,
158
175
  "&:hover": {
159
- backgroundColor: "$background-neutrals-subtle-hover",
160
- borderColor: "$border-neutrals-hover"
161
- },
162
- [activeSelector]: {
163
- backgroundColor: "$background-neutrals-subtle-active",
164
- borderColor: "$border-neutrals-active"
165
- },
166
- ...outlineDisabled
167
- },
168
- "ghost-subtle": {
169
- backgroundColor: "transparent",
170
- color: "$text-neutrals",
171
- [iconSlotSelector]: {
172
- color: "$icon-neutrals"
176
+ color: "$white",
177
+ backgroundColor: "$blue-700"
173
178
  },
179
+ [pressedSelector]: {
180
+ backgroundColor: "$blue-900"
181
+ }
182
+ }
183
+ },
184
+ {
185
+ variant: "primary",
186
+ appearance: "outlined",
187
+ css: {
188
+ color: "rgba(66, 98, 255, 1)",
189
+ border: "1px solid rgba(66, 98, 255, 1)",
190
+ ...focusOutline,
174
191
  "&:hover": {
175
- backgroundColor: "$background-neutrals-subtle-hover"
176
- },
177
- [activeSelector]: {
178
- backgroundColor: "$background-neutrals-subtle-active"
179
- },
180
- ...ghostDisabled
181
- },
182
- "solid-danger": {
183
- backgroundColor: "$background-danger-prominent",
184
- color: "$text-danger-inverted",
185
- [iconSlotSelector]: {
186
- color: "$icon-danger-inverted"
192
+ color: "rgba(66, 98, 255, 1)",
193
+ backgroundColor: "rgba(244, 246, 255, 1)"
187
194
  },
195
+ [pressedSelector]: {
196
+ backgroundColor: "rgba(240, 242, 255, 1)"
197
+ }
198
+ }
199
+ },
200
+ {
201
+ variant: "primary",
202
+ appearance: "flat",
203
+ css: {
204
+ color: "rgba(66, 98, 255, 1)",
205
+ ...focusDefault,
188
206
  "&:hover": {
189
- backgroundColor: "$background-danger-prominent-hover"
190
- },
191
- [activeSelector]: {
192
- backgroundColor: "$background-danger-prominent-active"
193
- },
194
- ...solidDisabled
195
- },
196
- "outline-danger": {
197
- backgroundColor: "$background-neutrals",
198
- borderColor: "$border-danger",
199
- color: "$text-danger",
200
- [iconSlotSelector]: {
201
- color: "$icon-danger"
207
+ color: "rgba(69, 91, 237, 1)",
208
+ backgroundColor: "rgba(245, 245, 247, 1)"
202
209
  },
210
+ [pressedSelector]: {
211
+ color: "rgba(61, 81, 212, 1)"
212
+ }
213
+ }
214
+ },
215
+ {
216
+ variant: "secondary",
217
+ appearance: "filled",
218
+ css: {
219
+ color: "rgba(5, 0, 56, 1)",
220
+ backgroundColor: "rgba(245, 245, 247, 1)",
221
+ ...focusFilled,
203
222
  "&:hover": {
204
- backgroundColor: "$background-danger",
205
- color: "$text-danger-hover",
206
- [iconSlotSelector]: {
207
- color: "$icon-danger-hover"
208
- }
209
- },
210
- [activeSelector]: {
211
- backgroundColor: "$background-danger-hover",
212
- color: "$text-danger-active",
213
- [iconSlotSelector]: {
214
- color: "$icon-danger-active"
215
- }
216
- },
217
- ...outlineDisabled
218
- },
219
- "ghost-danger": {
220
- backgroundColor: "transparent",
221
- color: "$text-danger",
222
- [iconSlotSelector]: {
223
- color: "$icon-danger"
223
+ color: "rgba(5, 0, 56, 1)",
224
+ backgroundColor: "rgba(240, 240, 243, 1)"
224
225
  },
226
+ [pressedSelector]: {
227
+ backgroundColor: "rgba(235, 235, 239, 1)"
228
+ }
229
+ }
230
+ },
231
+ {
232
+ variant: "secondary",
233
+ appearance: "outlined",
234
+ css: {
235
+ color: "rgba(5, 0, 56, 1)",
236
+ border: "1px solid rgba(205, 204, 215, 1)",
237
+ ...focusOutline,
225
238
  "&:hover": {
226
- backgroundColor: "$background-danger",
227
- color: "$text-danger-hover",
228
- [iconSlotSelector]: {
229
- color: "$icon-danger-hover"
230
- }
231
- },
232
- [activeSelector]: {
233
- backgroundColor: "$background-danger-hover",
234
- color: "$text-danger-active",
235
- [iconSlotSelector]: {
236
- color: "$icon-danger-active"
237
- }
239
+ color: "rgba(5, 0, 56, 1)",
240
+ backgroundColor: "rgba(245, 245, 247, 1)"
238
241
  },
239
- ...ghostDisabled
242
+ [pressedSelector]: {
243
+ backgroundColor: "rgba(235, 235, 239, 1)"
244
+ }
240
245
  }
241
246
  },
242
- size: {
243
- "x-large": {
244
- height: designSystemBaseButton.sizes.xLarge,
245
- fontSize: "$200",
246
- paddingX: `calc($200 + ${LABEL_OFFSET}px)`,
247
- [iconSlotSelector]: {
248
- width: "$icon-300",
249
- height: "$icon-300"
250
- }
251
- },
252
- large: {
253
- height: designSystemBaseButton.sizes.large,
254
- fontSize: "$200",
255
- paddingX: `calc($150 + ${LABEL_OFFSET}px)`,
256
- [iconSlotSelector]: {
257
- width: "$icon-300",
258
- height: "$icon-300"
259
- }
260
- },
261
- medium: {
262
- height: designSystemBaseButton.sizes.medium,
263
- fontSize: "$175",
264
- paddingX: `calc($100 + ${LABEL_OFFSET}px)`,
265
- [iconSlotSelector]: {
266
- width: "$icon-200",
267
- height: "$icon-200"
247
+ {
248
+ variant: "secondary",
249
+ appearance: "flat",
250
+ css: {
251
+ color: "rgba(5, 0, 56, 1)",
252
+ ...focusDefault,
253
+ "&:hover": {
254
+ color: "rgba(5, 0, 56, 1)",
255
+ backgroundColor: "rgba(245, 245, 247, 1)"
268
256
  }
269
- },
270
- small: {
271
- fontSize: "$175",
272
- height: "$6",
273
- paddingX: `calc($100 + ${LABEL_OFFSET}px)`,
274
- [iconSlotSelector]: {
275
- width: "$icon-200",
276
- height: "$icon-200"
257
+ }
258
+ },
259
+ {
260
+ variant: "danger",
261
+ appearance: "filled",
262
+ css: {
263
+ color: "$white",
264
+ backgroundColor: "rgba(217, 41, 41, 1)",
265
+ ...focusFilled,
266
+ "&:hover": {
267
+ backgroundColor: "rgba(199, 20, 20, 1)"
268
+ },
269
+ [pressedSelector]: {
270
+ backgroundColor: "rgba(184, 13, 13, 1)"
277
271
  }
278
272
  }
279
273
  },
280
- rounded: {
281
- true: {
282
- borderRadius: "$half"
274
+ {
275
+ variant: "danger",
276
+ appearance: "outlined",
277
+ css: {
278
+ color: "rgba(217, 41, 41, 1)",
279
+ border: "1px solid rgba(217, 41, 41, 1)",
280
+ ...focusOutline,
281
+ "&:hover": {
282
+ color: "rgba(217, 41, 41, 1)",
283
+ backgroundColor: "rgba(254, 247, 247, 1)"
284
+ },
285
+ [pressedSelector]: {
286
+ backgroundColor: "rgba(253, 242, 242, 1)"
287
+ }
283
288
  }
284
289
  },
285
- fluid: {
286
- true: {
287
- width: "100%",
288
- display: "block"
290
+ {
291
+ variant: "danger",
292
+ appearance: "flat",
293
+ css: {
294
+ color: "rgba(217, 41, 41, 1)",
295
+ ...focusDefault,
296
+ "&:hover": {
297
+ color: "rgba(217, 41, 41, 1)",
298
+ backgroundColor: "rgba(245, 245, 247, 1)"
299
+ }
289
300
  }
290
301
  }
291
- }
292
- });
293
- const StyledHiddenContent = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
294
- visibility: "hidden"
302
+ ]
295
303
  });
296
304
  const StyledSpinnerBox = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
297
305
  display: "flex",
@@ -307,44 +315,84 @@ const StyledSpinnerBox = designSystemStitches.styled(designSystemPrimitive.Primi
307
315
 
308
316
  const Button = React__default["default"].forwardRef(
309
317
  ({
310
- variant = "solid-prominent",
311
- size = "large",
318
+ variant = "primary",
319
+ appearance = "filled",
320
+ size = "medium",
312
321
  loading = false,
313
322
  rounded = false,
314
323
  fluid = false,
315
- "aria-disabled": ariaDisabled,
324
+ disabled = false,
325
+ href,
326
+ target,
327
+ rel,
316
328
  children,
329
+ onPress,
330
+ onClick,
331
+ asChild,
317
332
  ...restProps
318
333
  }, forwardRef) => {
319
- let spinnerSize = "medium";
320
- if (typeof size === "string" && ["small", "medium"].includes(size)) {
321
- spinnerSize = "small";
334
+ let spinnerSize;
335
+ if (typeof size === "string") {
336
+ spinnerSize = ["x-small", "xx-small"].includes(size) ? "small" : "medium";
337
+ } else {
338
+ spinnerSize = "medium";
322
339
  }
323
- const shouldHaveAriaDisabled = ariaDisabled === "true" || ariaDisabled === true || loading;
324
- const formattedChildren = React.Children.map(
325
- React.Children.toArray(children),
326
- (child) => {
327
- if (typeof child === "string" || typeof child === "boolean" || typeof child === "number") {
328
- return /* @__PURE__ */ React__default["default"].createElement(designSystemPrimitive.Primitive.span, null, child);
329
- }
330
- return child;
331
- }
340
+ const _loading = loading === "true" || loading === true;
341
+ const shouldBeDisabled = disabled || _loading;
342
+ const asLink = href != null;
343
+ const ref = React.useRef(null);
344
+ const refWithFallback = forwardRef != null ? forwardRef : ref;
345
+ const { buttonProps, isPressed } = button.useButton(
346
+ {
347
+ isDisabled: shouldBeDisabled,
348
+ href,
349
+ onPress: onPress != null ? onPress : onClick,
350
+ allowFocusWhenDisabled: false,
351
+ ...restProps
352
+ },
353
+ refWithFallback
354
+ );
355
+ const { linkProps } = link.useLink(
356
+ {
357
+ isDisabled: disabled,
358
+ onPress: onPress != null ? onPress : onClick,
359
+ ...restProps
360
+ },
361
+ refWithFallback
332
362
  );
333
- const Content = loading ? /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement(StyledSpinnerBox, null, /* @__PURE__ */ React__default["default"].createElement(designSystemSpinner.Spinner, {
363
+ const Content = /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, _loading && /* @__PURE__ */ React__default["default"].createElement(StyledSpinnerBox, null, /* @__PURE__ */ React__default["default"].createElement(designSystemSpinner.Spinner, {
334
364
  size: spinnerSize
335
- })), /* @__PURE__ */ React__default["default"].createElement(StyledHiddenContent, null, formattedChildren)) : formattedChildren;
365
+ })), /* @__PURE__ */ React__default["default"].createElement("span", null, children));
366
+ const tabIndexProp = shouldBeDisabled && {
367
+ tabIndex: -1
368
+ };
369
+ const { isFocusVisible, focusProps } = focus.useFocusRing();
370
+ const elementProps = utils.mergeProps(
371
+ restProps,
372
+ asLink ? linkProps : buttonProps,
373
+ focusProps
374
+ );
336
375
  return /* @__PURE__ */ React__default["default"].createElement(StyledButton, {
337
- ...restProps,
376
+ ...elementProps,
338
377
  variant,
378
+ appearance,
379
+ size,
380
+ loading,
339
381
  rounded,
340
382
  fluid,
341
- size,
342
- "aria-disabled": shouldHaveAriaDisabled ? true : void 0,
343
- ref: forwardRef
344
- }, Content);
383
+ disabled: shouldBeDisabled,
384
+ asChild: asLink || asChild,
385
+ ...tabIndexProp,
386
+ "data-pressed": isPressed ? "" : void 0,
387
+ "data-focused": isFocusVisible ? "" : void 0,
388
+ ref: refWithFallback
389
+ }, asLink ? /* @__PURE__ */ React__default["default"].createElement("a", {
390
+ href,
391
+ target,
392
+ rel: target === "_blank" ? `noopener noreferrer ${rel}` : rel
393
+ }, Content) : Content);
345
394
  }
346
395
  );
347
- Button.IconSlot = IconSlot;
348
396
 
349
397
  exports.Button = Button;
350
398
  //# sourceMappingURL=main.js.map