@mirohq/design-system-dropdown-menu 3.3.0-dropdown.4 → 3.3.0-dropdown.5
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 +137 -45
- package/dist/main.js.map +1 -1
- package/dist/module.js +138 -46
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +141 -123
- package/package.json +8 -8
package/dist/main.js
CHANGED
|
@@ -10,6 +10,7 @@ var designSystemPrimitive = require('@mirohq/design-system-primitive');
|
|
|
10
10
|
var designSystemStitches = require('@mirohq/design-system-stitches');
|
|
11
11
|
var designSystemStyles = require('@mirohq/design-system-styles');
|
|
12
12
|
var designSystemBaseSwitch = require('@mirohq/design-system-base-switch');
|
|
13
|
+
var designSystemBaseIcon = require('@mirohq/design-system-base-icon');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
16
|
|
|
@@ -54,14 +55,18 @@ const LeftSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div
|
|
|
54
55
|
const IllustrationSlot = designSystemStitches.styled(LeftSlot, {
|
|
55
56
|
width: "$13"
|
|
56
57
|
});
|
|
57
|
-
const
|
|
58
|
+
const StyledRightSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
|
|
58
59
|
display: "flex",
|
|
59
60
|
alignItems: "center",
|
|
60
61
|
marginLeft: "auto",
|
|
61
62
|
paddingLeft: "$200",
|
|
62
|
-
gridArea: "right-slot"
|
|
63
|
+
gridArea: "right-slot",
|
|
64
|
+
minWidth: "max-content",
|
|
65
|
+
textAlign: "right",
|
|
66
|
+
"&:empty": {
|
|
67
|
+
paddingLeft: "$none"
|
|
68
|
+
}
|
|
63
69
|
});
|
|
64
|
-
const HotkeySlot = RightSlot;
|
|
65
70
|
|
|
66
71
|
const itemDefaults = {
|
|
67
72
|
all: "unset",
|
|
@@ -73,16 +78,26 @@ const itemDefaults = {
|
|
|
73
78
|
display: "grid",
|
|
74
79
|
gridTemplateColumns: "auto 1fr auto",
|
|
75
80
|
gridTemplateRows: "1fr auto",
|
|
76
|
-
gridTemplateAreas: `
|
|
77
|
-
'left-slot item-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
minHeight: "$11",
|
|
82
|
-
padding: "$100 $150",
|
|
81
|
+
gridTemplateAreas: `'left-slot item-text right-slot'
|
|
82
|
+
'left-slot item-description right-slot'`,
|
|
83
|
+
alignItems: "start",
|
|
84
|
+
minHeight: "$10",
|
|
85
|
+
padding: "$100 $100",
|
|
83
86
|
position: "relative",
|
|
84
87
|
userSelect: "none",
|
|
85
88
|
cursor: "pointer",
|
|
89
|
+
"&[data-no-left-slot]": {
|
|
90
|
+
gridTemplateColumns: "1fr auto",
|
|
91
|
+
gridTemplateRows: "auto",
|
|
92
|
+
gridTemplateAreas: `'item-text right-slot'
|
|
93
|
+
'item-description right-slot'`
|
|
94
|
+
},
|
|
95
|
+
"&:not(:last-child)": {
|
|
96
|
+
marginBottom: "$50"
|
|
97
|
+
},
|
|
98
|
+
"&:not(:first-child)": {
|
|
99
|
+
marginTop: "$50"
|
|
100
|
+
},
|
|
86
101
|
...designSystemStyles.focus.defaults,
|
|
87
102
|
'&:disabled, &[aria-disabled="true"], &[data-disabled]': {
|
|
88
103
|
pointerEvents: "none",
|
|
@@ -110,7 +125,9 @@ const itemDefaults = {
|
|
|
110
125
|
}
|
|
111
126
|
};
|
|
112
127
|
|
|
113
|
-
const StyledIndicator = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
128
|
+
const StyledIndicator = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
129
|
+
padding: "4px 6px"
|
|
130
|
+
});
|
|
114
131
|
const StyledCheckboxItem = designSystemStitches.styled(RadixDropdownMenu__namespace.CheckboxItem, {
|
|
115
132
|
...itemDefaults,
|
|
116
133
|
[`&[data-state="checked"] ${StyledIndicator}`]: {
|
|
@@ -127,6 +144,53 @@ const StyledCheckboxItem = designSystemStitches.styled(RadixDropdownMenu__namesp
|
|
|
127
144
|
}
|
|
128
145
|
});
|
|
129
146
|
|
|
147
|
+
const Context = React.createContext({
|
|
148
|
+
counter: {
|
|
149
|
+
right: 0,
|
|
150
|
+
left: 0
|
|
151
|
+
},
|
|
152
|
+
increaseCounter: () => {
|
|
153
|
+
},
|
|
154
|
+
decreaseCounter: () => {
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
const SlotsProvider = ({
|
|
158
|
+
children
|
|
159
|
+
}) => {
|
|
160
|
+
const [counter, setCounter] = React.useState({
|
|
161
|
+
right: 0,
|
|
162
|
+
left: 0
|
|
163
|
+
});
|
|
164
|
+
return /* @__PURE__ */ React__default["default"].createElement(Context.Provider, {
|
|
165
|
+
value: {
|
|
166
|
+
counter,
|
|
167
|
+
increaseCounter: (side) => {
|
|
168
|
+
setCounter((counter2) => ({
|
|
169
|
+
...counter2,
|
|
170
|
+
[side]: counter2[side] + 1
|
|
171
|
+
}));
|
|
172
|
+
},
|
|
173
|
+
decreaseCounter: (side) => setCounter((counter2) => ({
|
|
174
|
+
...counter2,
|
|
175
|
+
[side]: counter2[side] - 1
|
|
176
|
+
}))
|
|
177
|
+
}
|
|
178
|
+
}, children);
|
|
179
|
+
};
|
|
180
|
+
const useSlots = () => React.useContext(Context);
|
|
181
|
+
|
|
182
|
+
const RightSlot = (props) => {
|
|
183
|
+
const { increaseCounter, decreaseCounter } = useSlots();
|
|
184
|
+
React.useEffect(() => {
|
|
185
|
+
increaseCounter("right");
|
|
186
|
+
return () => decreaseCounter("right");
|
|
187
|
+
}, []);
|
|
188
|
+
return /* @__PURE__ */ React__default["default"].createElement(StyledRightSlot, {
|
|
189
|
+
...props
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
const HotkeySlot = RightSlot;
|
|
193
|
+
|
|
130
194
|
const useAriaDisabled = ({ "aria-disabled": ariaDisabled, onKeyDown, onSelect }, preventDefault = false) => React.useMemo(
|
|
131
195
|
() => ({
|
|
132
196
|
"aria-disabled": designSystemUtils.booleanify(ariaDisabled) ? ariaDisabled : void 0,
|
|
@@ -164,26 +228,17 @@ const CheckboxItem = React__default["default"].forwardRef(({ children, checked,
|
|
|
164
228
|
}, 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, {
|
|
165
229
|
size: "small"
|
|
166
230
|
}), checked && /* @__PURE__ */ React__default["default"].createElement(designSystemIcons.IconCheckMark, {
|
|
167
|
-
|
|
231
|
+
css: { width: "12px", display: "block" }
|
|
168
232
|
}))));
|
|
169
233
|
});
|
|
170
234
|
|
|
171
|
-
const
|
|
172
|
-
const CONTENT_GUTTER = parseInt(designSystemStitches.theme.space[GUTTER_TOKEN]);
|
|
235
|
+
const CONTENT_GUTTER = parseInt(designSystemStitches.theme.space[150]);
|
|
173
236
|
const CONTENT_OFFSET = parseInt(designSystemStitches.theme.space[50]);
|
|
174
|
-
const ITEM_WITHOUT_RIGHT_SLOT = `[role="menuitem"]:not(:has(${RightSlot}))`;
|
|
175
237
|
const contentDefaults = {
|
|
176
238
|
maxWidth: "$125",
|
|
177
239
|
backgroundColor: "$white",
|
|
178
240
|
borderRadius: "$50",
|
|
179
|
-
padding: `$${GUTTER_TOKEN}`,
|
|
180
241
|
boxShadow: "$50",
|
|
181
|
-
[`&:has(${RightSlot}) > ${ITEM_WITHOUT_RIGHT_SLOT}`]: {
|
|
182
|
-
paddingRight: "44px"
|
|
183
|
-
},
|
|
184
|
-
[`&:has([role="switch"]) > ${ITEM_WITHOUT_RIGHT_SLOT}`]: {
|
|
185
|
-
paddingRight: "56px"
|
|
186
|
-
},
|
|
187
242
|
"@media (prefers-reduced-motion: no-preference)": {
|
|
188
243
|
animationDuration: "150ms",
|
|
189
244
|
animationTimingFunction: "cubic-bezier(0.25, 0.5, 0.5, 0.9)",
|
|
@@ -215,7 +270,28 @@ const contentDefaults = {
|
|
|
215
270
|
zIndex: "$dropdownMenu"
|
|
216
271
|
};
|
|
217
272
|
|
|
218
|
-
const StyledContent = designSystemStitches.styled(RadixDropdownMenu__namespace.Content,
|
|
273
|
+
const StyledContent = designSystemStitches.styled(RadixDropdownMenu__namespace.Content, {
|
|
274
|
+
...contentDefaults,
|
|
275
|
+
variants: {
|
|
276
|
+
containerSpacing: {
|
|
277
|
+
small: {
|
|
278
|
+
'&, [role="menu"]': {
|
|
279
|
+
padding: "$50 $150"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
medium: {
|
|
283
|
+
'&, [role="menu"]': {
|
|
284
|
+
padding: "$150"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
large: {
|
|
288
|
+
'&, [role="menu"]': {
|
|
289
|
+
padding: "$150 $300"
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
219
295
|
|
|
220
296
|
const Content = React__default["default"].forwardRef(
|
|
221
297
|
({
|
|
@@ -228,8 +304,9 @@ const Content = React__default["default"].forwardRef(
|
|
|
228
304
|
avoidCollisions = true,
|
|
229
305
|
sticky = "partial",
|
|
230
306
|
hideWhenDetached = false,
|
|
307
|
+
containerSpacing = "medium",
|
|
231
308
|
...restProps
|
|
232
|
-
}, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledContent, {
|
|
309
|
+
}, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(SlotsProvider, null, /* @__PURE__ */ React__default["default"].createElement(StyledContent, {
|
|
233
310
|
...restProps,
|
|
234
311
|
ref: forwardRef,
|
|
235
312
|
loop,
|
|
@@ -240,20 +317,32 @@ const Content = React__default["default"].forwardRef(
|
|
|
240
317
|
avoidCollisions,
|
|
241
318
|
collisionPadding,
|
|
242
319
|
sticky,
|
|
243
|
-
hideWhenDetached
|
|
244
|
-
|
|
320
|
+
hideWhenDetached,
|
|
321
|
+
containerSpacing
|
|
322
|
+
}))
|
|
245
323
|
);
|
|
246
324
|
|
|
247
|
-
const StyledItem = designSystemStitches.styled(RadixDropdownMenu__namespace.Item,
|
|
325
|
+
const StyledItem = designSystemStitches.styled(RadixDropdownMenu__namespace.Item, {
|
|
326
|
+
...itemDefaults,
|
|
327
|
+
variants: {
|
|
328
|
+
hasRightSlot: {
|
|
329
|
+
true: {
|
|
330
|
+
paddingRight: "$600"
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
});
|
|
248
335
|
|
|
249
336
|
const Item = React__default["default"].forwardRef(
|
|
250
337
|
({ disabled = false, ...restProps }, forwardRef) => {
|
|
338
|
+
const { counter } = useSlots();
|
|
251
339
|
const ariaDisabledProps = useAriaDisabled(restProps);
|
|
252
340
|
return /* @__PURE__ */ React__default["default"].createElement(StyledItem, {
|
|
253
341
|
...restProps,
|
|
254
342
|
...ariaDisabledProps,
|
|
255
343
|
disabled,
|
|
256
|
-
ref: forwardRef
|
|
344
|
+
ref: forwardRef,
|
|
345
|
+
hasRightSlot: counter.right > 0
|
|
257
346
|
});
|
|
258
347
|
}
|
|
259
348
|
);
|
|
@@ -270,7 +359,9 @@ const LinkItem = React__default["default"].forwardRef(({ children, href, ...rest
|
|
|
270
359
|
}, children));
|
|
271
360
|
});
|
|
272
361
|
|
|
273
|
-
const StyledRadioGroup = designSystemStitches.styled(RadixDropdownMenu__namespace.RadioGroup
|
|
362
|
+
const StyledRadioGroup = designSystemStitches.styled(RadixDropdownMenu__namespace.RadioGroup, {
|
|
363
|
+
marginY: "$50"
|
|
364
|
+
});
|
|
274
365
|
|
|
275
366
|
const RadioGroup = React__default["default"].forwardRef((props, forwardRef) => {
|
|
276
367
|
const { onChange, ...restProps } = props;
|
|
@@ -289,7 +380,8 @@ const StyledRadioContainer = designSystemStitches.styled(designSystemPrimitive.P
|
|
|
289
380
|
height: "$4",
|
|
290
381
|
boxSizing: "border-box",
|
|
291
382
|
border: "1px solid $border-neutrals",
|
|
292
|
-
borderRadius: "$half"
|
|
383
|
+
borderRadius: "$half",
|
|
384
|
+
marginTop: "2px"
|
|
293
385
|
});
|
|
294
386
|
const StyledPill = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
295
387
|
display: "none",
|
|
@@ -348,8 +440,7 @@ const RadioItem = React__default["default"].forwardRef(({ disabled = false, chil
|
|
|
348
440
|
});
|
|
349
441
|
|
|
350
442
|
const StyledSeparator = designSystemStitches.styled(RadixDropdownMenu__namespace.Separator, {
|
|
351
|
-
borderTop: "1px solid $border-neutrals-subtle"
|
|
352
|
-
marginY: "$100"
|
|
443
|
+
borderTop: "1px solid $border-neutrals-subtle"
|
|
353
444
|
});
|
|
354
445
|
|
|
355
446
|
const Separator = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledSeparator, {
|
|
@@ -360,7 +451,8 @@ const Separator = React__default["default"].forwardRef((props, forwardRef) => /*
|
|
|
360
451
|
const StyledSwitch = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
361
452
|
...designSystemBaseSwitch.styles.default,
|
|
362
453
|
width: "$7",
|
|
363
|
-
height: "$4"
|
|
454
|
+
height: "$4",
|
|
455
|
+
marginTop: "2px"
|
|
364
456
|
});
|
|
365
457
|
const StyledSwitchItem = designSystemStitches.styled(RadixDropdownMenu__namespace.CheckboxItem, {
|
|
366
458
|
...itemDefaults,
|
|
@@ -387,19 +479,18 @@ const SwitchItem = React__default["default"].forwardRef(
|
|
|
387
479
|
}
|
|
388
480
|
);
|
|
389
481
|
|
|
390
|
-
const defaultStyles = {
|
|
391
|
-
boxSizing: "border-box",
|
|
392
|
-
cursor: "pointer",
|
|
393
|
-
...designSystemStyles.focus.defaults
|
|
394
|
-
};
|
|
395
482
|
const StyledTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.Trigger, {
|
|
396
483
|
variants: {
|
|
397
484
|
unstyled: {
|
|
398
485
|
true: {
|
|
399
486
|
all: "unset",
|
|
400
|
-
|
|
487
|
+
boxSizing: "border-box",
|
|
488
|
+
cursor: "pointer",
|
|
489
|
+
...designSystemStyles.focus.defaults
|
|
401
490
|
},
|
|
402
|
-
false:
|
|
491
|
+
false: {
|
|
492
|
+
cursor: "pointer"
|
|
493
|
+
}
|
|
403
494
|
}
|
|
404
495
|
}
|
|
405
496
|
});
|
|
@@ -413,7 +504,8 @@ const Trigger = React__default["default"].forwardRef(({ asChild = false, onPress
|
|
|
413
504
|
}));
|
|
414
505
|
|
|
415
506
|
const StyledIconContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
|
|
416
|
-
color: "$icon-neutrals-with-text"
|
|
507
|
+
color: "$icon-neutrals-with-text",
|
|
508
|
+
marginRight: "-4px"
|
|
417
509
|
});
|
|
418
510
|
const StyledSubTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.SubTrigger, {
|
|
419
511
|
...itemDefaults,
|
|
@@ -456,7 +548,7 @@ const SubContent = React__default["default"].forwardRef(
|
|
|
456
548
|
hideWhenDetached = false,
|
|
457
549
|
sticky = "partial",
|
|
458
550
|
...restProps
|
|
459
|
-
}, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledSubContent, {
|
|
551
|
+
}, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(SlotsProvider, null, /* @__PURE__ */ React__default["default"].createElement(StyledSubContent, {
|
|
460
552
|
...restProps,
|
|
461
553
|
ref: forwardRef,
|
|
462
554
|
sideOffset,
|
|
@@ -465,7 +557,7 @@ const SubContent = React__default["default"].forwardRef(
|
|
|
465
557
|
loop,
|
|
466
558
|
hideWhenDetached,
|
|
467
559
|
sticky
|
|
468
|
-
})
|
|
560
|
+
}))
|
|
469
561
|
);
|
|
470
562
|
|
|
471
563
|
const StyledSub = designSystemStitches.styled(RadixDropdownMenu__namespace.Sub, {});
|
|
@@ -492,7 +584,7 @@ const Portal = (props) => /* @__PURE__ */ React__default["default"].createElemen
|
|
|
492
584
|
});
|
|
493
585
|
|
|
494
586
|
const StyledIconSlot = designSystemStitches.styled(LeftSlot, {
|
|
495
|
-
|
|
587
|
+
paddingTop: "2px",
|
|
496
588
|
variants: {
|
|
497
589
|
customIcon: {
|
|
498
590
|
true: {
|
|
@@ -504,7 +596,7 @@ const StyledIconSlot = designSystemStitches.styled(LeftSlot, {
|
|
|
504
596
|
|
|
505
597
|
const IconSlot = React__default["default"].forwardRef(({ children, ...restProps }, forwardRef) => {
|
|
506
598
|
const child = React__default["default"].Children.only(children);
|
|
507
|
-
const isIcon =
|
|
599
|
+
const isIcon = designSystemBaseIcon.isIconComponent(child);
|
|
508
600
|
const formattedChild = isIcon ? React__default["default"].cloneElement(child, {
|
|
509
601
|
...child.props,
|
|
510
602
|
size: "small",
|