@mirohq/design-system-dropdown-menu 3.3.0-dropdown.2 → 3.3.0-dropdown.4
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 +180 -91
- package/dist/main.js.map +1 -1
- package/dist/module.js +182 -93
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +470 -11
- package/package.json +5 -5
package/dist/main.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var RadixDropdownMenu = require('@radix-ui/react-dropdown-menu');
|
|
7
7
|
var designSystemIcons = require('@mirohq/design-system-icons');
|
|
8
|
+
var designSystemUtils = require('@mirohq/design-system-utils');
|
|
8
9
|
var designSystemPrimitive = require('@mirohq/design-system-primitive');
|
|
9
10
|
var designSystemStitches = require('@mirohq/design-system-stitches');
|
|
10
11
|
var designSystemStyles = require('@mirohq/design-system-styles');
|
|
@@ -44,6 +45,24 @@ const ItemDescription = designSystemStitches.styled(designSystemPrimitive.Primit
|
|
|
44
45
|
color: "$text-neutrals-subtle"
|
|
45
46
|
});
|
|
46
47
|
|
|
48
|
+
const LeftSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
49
|
+
display: "flex",
|
|
50
|
+
placeContent: "center",
|
|
51
|
+
marginRight: "$100",
|
|
52
|
+
gridArea: "left-slot"
|
|
53
|
+
});
|
|
54
|
+
const IllustrationSlot = designSystemStitches.styled(LeftSlot, {
|
|
55
|
+
width: "$13"
|
|
56
|
+
});
|
|
57
|
+
const RightSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
58
|
+
display: "flex",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
marginLeft: "auto",
|
|
61
|
+
paddingLeft: "$200",
|
|
62
|
+
gridArea: "right-slot"
|
|
63
|
+
});
|
|
64
|
+
const HotkeySlot = RightSlot;
|
|
65
|
+
|
|
47
66
|
const itemDefaults = {
|
|
48
67
|
all: "unset",
|
|
49
68
|
boxSizing: "border-box",
|
|
@@ -64,18 +83,28 @@ const itemDefaults = {
|
|
|
64
83
|
position: "relative",
|
|
65
84
|
userSelect: "none",
|
|
66
85
|
cursor: "pointer",
|
|
67
|
-
"&[data-disabled]": {
|
|
68
|
-
color: "rgba(9, 9, 9, 0.4)",
|
|
69
|
-
pointerEvents: "none"
|
|
70
|
-
},
|
|
71
86
|
...designSystemStyles.focus.defaults,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
boxShadow: "none",
|
|
87
|
+
'&:disabled, &[aria-disabled="true"], &[data-disabled]': {
|
|
88
|
+
pointerEvents: "none",
|
|
75
89
|
[`&, & ${ItemDescription}`]: {
|
|
76
|
-
color: "$text-
|
|
90
|
+
color: "$text-neutrals-disabled"
|
|
91
|
+
},
|
|
92
|
+
[`& ${IllustrationSlot}`]: {
|
|
93
|
+
filter: "grayscale(1)"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"&:hover": {
|
|
97
|
+
background: "$background-primary-subtle-hover",
|
|
98
|
+
color: "$text-primary-hover",
|
|
99
|
+
'&:not([aria-disabled="true"])': {
|
|
100
|
+
boxShadow: "none"
|
|
77
101
|
}
|
|
78
102
|
},
|
|
103
|
+
"&:active": {
|
|
104
|
+
background: "$background-primary-subtle-active",
|
|
105
|
+
boxShadow: "none",
|
|
106
|
+
color: "$text-primary-active"
|
|
107
|
+
},
|
|
79
108
|
'&[tabindex="0"]': {
|
|
80
109
|
zIndex: "1"
|
|
81
110
|
}
|
|
@@ -90,48 +119,54 @@ const StyledCheckboxItem = designSystemStitches.styled(RadixDropdownMenu__namesp
|
|
|
90
119
|
[`&[data-state="checked"]:hover ${StyledIndicator}`]: {
|
|
91
120
|
color: "$icon-primary-hover"
|
|
92
121
|
},
|
|
93
|
-
[
|
|
122
|
+
[`
|
|
123
|
+
&[aria-disabled="true"] ${StyledIndicator},
|
|
124
|
+
&[data-disabled] ${StyledIndicator}
|
|
125
|
+
`]: {
|
|
94
126
|
color: "$icon-neutrals-disabled"
|
|
95
127
|
}
|
|
96
128
|
});
|
|
97
129
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
130
|
+
const useAriaDisabled = ({ "aria-disabled": ariaDisabled, onKeyDown, onSelect }, preventDefault = false) => React.useMemo(
|
|
131
|
+
() => ({
|
|
132
|
+
"aria-disabled": designSystemUtils.booleanify(ariaDisabled) ? ariaDisabled : void 0,
|
|
133
|
+
onKeyDown: (e) => {
|
|
134
|
+
if (designSystemUtils.booleanify(ariaDisabled) && e.code !== "ArrowUp" && e.code !== "ArrowDown") {
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
140
|
+
},
|
|
141
|
+
onSelect: (e) => {
|
|
142
|
+
if (preventDefault) {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
}
|
|
145
|
+
if (designSystemUtils.booleanify(ariaDisabled)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
onSelect == null ? void 0 : onSelect(e);
|
|
149
|
+
}
|
|
150
|
+
}),
|
|
151
|
+
[ariaDisabled, onKeyDown, onSelect, preventDefault]
|
|
152
|
+
);
|
|
117
153
|
|
|
118
|
-
const CheckboxItem = React__default["default"].forwardRef(
|
|
119
|
-
|
|
154
|
+
const CheckboxItem = React__default["default"].forwardRef(({ children, checked, onChange, disabled, ...restProps }, forwardRef) => {
|
|
155
|
+
const ariaDisabledProps = useAriaDisabled(restProps, true);
|
|
156
|
+
const { "aria-disabled": ariaDisabled } = ariaDisabledProps;
|
|
157
|
+
return /* @__PURE__ */ React__default["default"].createElement(StyledCheckboxItem, {
|
|
120
158
|
...restProps,
|
|
159
|
+
...ariaDisabledProps,
|
|
121
160
|
ref: forwardRef,
|
|
122
161
|
checked,
|
|
123
162
|
disabled,
|
|
124
|
-
onCheckedChange: onChange
|
|
125
|
-
|
|
126
|
-
event.preventDefault();
|
|
127
|
-
onSelect == null ? void 0 : onSelect(event);
|
|
128
|
-
}
|
|
129
|
-
}, children, /* @__PURE__ */ React__default["default"].createElement(RightSlot, null, /* @__PURE__ */ React__default["default"].createElement(StyledIndicator, null, disabled === true && !checked && /* @__PURE__ */ React__default["default"].createElement(designSystemIcons.IconProhibit, {
|
|
163
|
+
onCheckedChange: onChange
|
|
164
|
+
}, children, /* @__PURE__ */ React__default["default"].createElement(RightSlot, null, /* @__PURE__ */ React__default["default"].createElement(StyledIndicator, null, (disabled === true || designSystemUtils.booleanify(ariaDisabled)) && !checked && /* @__PURE__ */ React__default["default"].createElement(designSystemIcons.IconProhibit, {
|
|
130
165
|
size: "small"
|
|
131
166
|
}), checked && /* @__PURE__ */ React__default["default"].createElement(designSystemIcons.IconCheckMark, {
|
|
132
167
|
size: "small"
|
|
133
|
-
}))))
|
|
134
|
-
);
|
|
168
|
+
}))));
|
|
169
|
+
});
|
|
135
170
|
|
|
136
171
|
const GUTTER_TOKEN = 150;
|
|
137
172
|
const CONTENT_GUTTER = parseInt(designSystemStitches.theme.space[GUTTER_TOKEN]);
|
|
@@ -212,20 +247,28 @@ const Content = React__default["default"].forwardRef(
|
|
|
212
247
|
const StyledItem = designSystemStitches.styled(RadixDropdownMenu__namespace.Item, itemDefaults);
|
|
213
248
|
|
|
214
249
|
const Item = React__default["default"].forwardRef(
|
|
215
|
-
({ disabled = false, ...restProps }, forwardRef) =>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
250
|
+
({ disabled = false, ...restProps }, forwardRef) => {
|
|
251
|
+
const ariaDisabledProps = useAriaDisabled(restProps);
|
|
252
|
+
return /* @__PURE__ */ React__default["default"].createElement(StyledItem, {
|
|
253
|
+
...restProps,
|
|
254
|
+
...ariaDisabledProps,
|
|
255
|
+
disabled,
|
|
256
|
+
ref: forwardRef
|
|
257
|
+
});
|
|
258
|
+
}
|
|
220
259
|
);
|
|
221
260
|
|
|
222
|
-
const LinkItem = React__default["default"].forwardRef(({ children, href, ...restProps }, forwardRef) =>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
261
|
+
const LinkItem = React__default["default"].forwardRef(({ children, href, ...restProps }, forwardRef) => {
|
|
262
|
+
const ariaDisabledProps = useAriaDisabled(restProps);
|
|
263
|
+
return /* @__PURE__ */ React__default["default"].createElement(Item, {
|
|
264
|
+
asChild: true,
|
|
265
|
+
ref: forwardRef,
|
|
266
|
+
...restProps,
|
|
267
|
+
...ariaDisabledProps
|
|
268
|
+
}, /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
269
|
+
href
|
|
270
|
+
}, children));
|
|
271
|
+
});
|
|
229
272
|
|
|
230
273
|
const StyledRadioGroup = designSystemStitches.styled(RadixDropdownMenu__namespace.RadioGroup);
|
|
231
274
|
|
|
@@ -274,30 +317,38 @@ const StyledRadioItem = designSystemStitches.styled(RadixDropdownMenu__namespace
|
|
|
274
317
|
backgroundColor: "$background-primary-prominent-hover"
|
|
275
318
|
}
|
|
276
319
|
},
|
|
277
|
-
[
|
|
320
|
+
[`
|
|
321
|
+
&[aria-disabled="true"] ${StyledRadioContainer},
|
|
322
|
+
&[data-disabled] ${StyledRadioContainer}
|
|
323
|
+
`]: {
|
|
278
324
|
color: "$icon-neutrals-disabled",
|
|
279
325
|
borderColor: "$border-neutrals-disabled",
|
|
280
326
|
[`& ${StyledPill}`]: {
|
|
281
327
|
backgroundColor: "$icon-neutrals-disabled"
|
|
282
328
|
}
|
|
283
329
|
},
|
|
284
|
-
[
|
|
285
|
-
|
|
330
|
+
'&[data-state="unchecked"]': {
|
|
331
|
+
[`
|
|
332
|
+
&[aria-disabled="true"] ${StyledProhibited},
|
|
333
|
+
&[data-disabled] ${StyledProhibited}
|
|
334
|
+
`]: {
|
|
335
|
+
display: "flex"
|
|
336
|
+
}
|
|
286
337
|
}
|
|
287
338
|
});
|
|
288
339
|
|
|
289
|
-
const RadioItem = React__default["default"].forwardRef(({ disabled = false,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
}
|
|
340
|
+
const RadioItem = React__default["default"].forwardRef(({ disabled = false, children, ...restProps }, forwardRef) => {
|
|
341
|
+
const ariaDisabledProps = useAriaDisabled(restProps, true);
|
|
342
|
+
return /* @__PURE__ */ React__default["default"].createElement(StyledRadioItem, {
|
|
343
|
+
...restProps,
|
|
344
|
+
...ariaDisabledProps,
|
|
345
|
+
disabled,
|
|
346
|
+
ref: forwardRef
|
|
347
|
+
}, children, /* @__PURE__ */ React__default["default"].createElement(RightSlot, null, /* @__PURE__ */ React__default["default"].createElement(StyledRadioContainer, null, /* @__PURE__ */ React__default["default"].createElement(StyledPill, null), /* @__PURE__ */ React__default["default"].createElement(StyledProhibited, null))));
|
|
348
|
+
});
|
|
298
349
|
|
|
299
350
|
const StyledSeparator = designSystemStitches.styled(RadixDropdownMenu__namespace.Separator, {
|
|
300
|
-
borderTop: "1px solid
|
|
351
|
+
borderTop: "1px solid $border-neutrals-subtle",
|
|
301
352
|
marginY: "$100"
|
|
302
353
|
});
|
|
303
354
|
|
|
@@ -316,21 +367,24 @@ const StyledSwitchItem = designSystemStitches.styled(RadixDropdownMenu__namespac
|
|
|
316
367
|
[`&[data-state="checked"] ${StyledSwitch}`]: designSystemBaseSwitch.styles.checked,
|
|
317
368
|
[`&[data-state="checked"]:hover ${StyledSwitch}`]: designSystemBaseSwitch.styles.checkedHovered,
|
|
318
369
|
[`&:hover ${StyledSwitch}`]: designSystemBaseSwitch.styles.hovered,
|
|
319
|
-
[
|
|
370
|
+
[`
|
|
371
|
+
&[aria-disabled="true"] ${StyledSwitch},
|
|
372
|
+
&[data-disabled] ${StyledSwitch}
|
|
373
|
+
`]: designSystemBaseSwitch.styles.disabled
|
|
320
374
|
});
|
|
321
375
|
|
|
322
376
|
const SwitchItem = React__default["default"].forwardRef(
|
|
323
|
-
({ disabled = false, checked, onChange,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
}
|
|
377
|
+
({ disabled = false, checked, onChange, children, ...restProps }, forwardRef) => {
|
|
378
|
+
const ariaDisabledProps = useAriaDisabled(restProps, true);
|
|
379
|
+
return /* @__PURE__ */ React__default["default"].createElement(StyledSwitchItem, {
|
|
380
|
+
...restProps,
|
|
381
|
+
...ariaDisabledProps,
|
|
382
|
+
disabled,
|
|
383
|
+
checked,
|
|
384
|
+
onCheckedChange: onChange,
|
|
385
|
+
ref: forwardRef
|
|
386
|
+
}, children, /* @__PURE__ */ React__default["default"].createElement(RightSlot, null, /* @__PURE__ */ React__default["default"].createElement(StyledSwitch, null, /* @__PURE__ */ React__default["default"].createElement(designSystemBaseSwitch.Thumb, null))));
|
|
387
|
+
}
|
|
334
388
|
);
|
|
335
389
|
|
|
336
390
|
const defaultStyles = {
|
|
@@ -358,26 +412,34 @@ const Trigger = React__default["default"].forwardRef(({ asChild = false, onPress
|
|
|
358
412
|
asChild
|
|
359
413
|
}));
|
|
360
414
|
|
|
415
|
+
const StyledIconContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
416
|
+
color: "$icon-neutrals-with-text"
|
|
417
|
+
});
|
|
361
418
|
const StyledSubTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.SubTrigger, {
|
|
362
419
|
...itemDefaults,
|
|
363
|
-
'&[data-state="open"]': itemDefaults["&:hover"]
|
|
420
|
+
'&[data-state="open"]': itemDefaults["&:hover"],
|
|
421
|
+
[`&[data-state="open"] ${StyledIconContainer}, &:hover ${StyledIconContainer}`]: {
|
|
422
|
+
color: "$icon-primary-hover"
|
|
423
|
+
}
|
|
364
424
|
});
|
|
365
425
|
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
426
|
+
const SubTrigger = React__default["default"].forwardRef(({ children, disabled = false, ...restProps }, forwardRef) => {
|
|
427
|
+
const { onSelect, ...ariaDisabledProps } = useAriaDisabled({
|
|
428
|
+
onKeyDown: restProps.onKeyDown,
|
|
429
|
+
"aria-disabled": restProps["aria-disabled"]
|
|
430
|
+
});
|
|
431
|
+
return /* @__PURE__ */ React__default["default"].createElement(StyledSubTrigger, {
|
|
432
|
+
...restProps,
|
|
433
|
+
...ariaDisabledProps,
|
|
434
|
+
disabled,
|
|
435
|
+
ref: forwardRef
|
|
436
|
+
}, children, /* @__PURE__ */ React__default["default"].createElement(RightSlot, null, /* @__PURE__ */ React__default["default"].createElement(StyledIconContainer, {
|
|
437
|
+
"data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0
|
|
438
|
+
}, /* @__PURE__ */ React__default["default"].createElement(designSystemIcons.IconChevronRight, {
|
|
439
|
+
size: "small",
|
|
440
|
+
weight: "thin"
|
|
441
|
+
}))));
|
|
442
|
+
});
|
|
381
443
|
|
|
382
444
|
const StyledSubContent = designSystemStitches.styled(
|
|
383
445
|
RadixDropdownMenu__namespace.SubContent,
|
|
@@ -429,6 +491,32 @@ const Portal = (props) => /* @__PURE__ */ React__default["default"].createElemen
|
|
|
429
491
|
...props
|
|
430
492
|
});
|
|
431
493
|
|
|
494
|
+
const StyledIconSlot = designSystemStitches.styled(LeftSlot, {
|
|
495
|
+
square: "$5",
|
|
496
|
+
variants: {
|
|
497
|
+
customIcon: {
|
|
498
|
+
true: {
|
|
499
|
+
square: "$icon-200"
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
const IconSlot = React__default["default"].forwardRef(({ children, ...restProps }, forwardRef) => {
|
|
506
|
+
const child = React__default["default"].Children.only(children);
|
|
507
|
+
const isIcon = designSystemIcons.isIconComponent(child);
|
|
508
|
+
const formattedChild = isIcon ? React__default["default"].cloneElement(child, {
|
|
509
|
+
...child.props,
|
|
510
|
+
size: "small",
|
|
511
|
+
weight: "thin"
|
|
512
|
+
}) : child;
|
|
513
|
+
return /* @__PURE__ */ React__default["default"].createElement(StyledIconSlot, {
|
|
514
|
+
ref: forwardRef,
|
|
515
|
+
...restProps,
|
|
516
|
+
customIcon: !isIcon
|
|
517
|
+
}, formattedChild);
|
|
518
|
+
});
|
|
519
|
+
|
|
432
520
|
const DropdownMenu = ({
|
|
433
521
|
defaultOpen = false,
|
|
434
522
|
direction = "ltr",
|
|
@@ -454,6 +542,7 @@ const DropdownMenu = ({
|
|
|
454
542
|
};
|
|
455
543
|
DropdownMenu.CheckboxItem = CheckboxItem;
|
|
456
544
|
DropdownMenu.Content = Content;
|
|
545
|
+
DropdownMenu.HotkeySlot = HotkeySlot;
|
|
457
546
|
DropdownMenu.IconSlot = IconSlot;
|
|
458
547
|
DropdownMenu.IllustrationSlot = IllustrationSlot;
|
|
459
548
|
DropdownMenu.Item = Item;
|