@mirohq/design-system-dropdown-menu 3.3.4-use-press.2 → 3.4.1
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 +78 -76
- package/dist/main.js.map +1 -1
- package/dist/module.js +78 -76
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/package.json +9 -9
package/dist/module.js
CHANGED
|
@@ -80,7 +80,7 @@ const ContentProvider = ({
|
|
|
80
80
|
);
|
|
81
81
|
const formattedChildren = addPropsToChildren(children, () => true, {
|
|
82
82
|
UNSAFE_style: {
|
|
83
|
-
"--right-slot-max-width":
|
|
83
|
+
"--right-slot-max-width": "".concat(Math.ceil(maxWidth), "px")
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
return /* @__PURE__ */ jsx(
|
|
@@ -142,8 +142,7 @@ const itemDefaults = {
|
|
|
142
142
|
display: "grid",
|
|
143
143
|
gridTemplateColumns: "auto 1fr minmax(min-content, var(--right-slot-max-width))",
|
|
144
144
|
gridTemplateRows: "auto 1fr",
|
|
145
|
-
gridTemplateAreas:
|
|
146
|
-
'left-slot item-description right-slot'`,
|
|
145
|
+
gridTemplateAreas: "'left-slot item-text right-slot'\n 'left-slot item-description right-slot'",
|
|
147
146
|
alignItems: "start",
|
|
148
147
|
padding: "10px $100",
|
|
149
148
|
position: "relative",
|
|
@@ -151,8 +150,7 @@ const itemDefaults = {
|
|
|
151
150
|
cursor: "pointer",
|
|
152
151
|
"&[data-no-left-slot]": {
|
|
153
152
|
gridTemplateColumns: "1fr minmax(auto, var(--right-slot-max-width))",
|
|
154
|
-
gridTemplateAreas:
|
|
155
|
-
'item-description right-slot'`
|
|
153
|
+
gridTemplateAreas: "'item-text right-slot'\n 'item-description right-slot'"
|
|
156
154
|
},
|
|
157
155
|
"&:not(:last-child)": {
|
|
158
156
|
marginBottom: "$50"
|
|
@@ -166,10 +164,10 @@ const itemDefaults = {
|
|
|
166
164
|
}),
|
|
167
165
|
'&:disabled, &[aria-disabled="true"], &[data-disabled]': {
|
|
168
166
|
cursor: "default",
|
|
169
|
-
[
|
|
167
|
+
["&, & ".concat(ItemDescription, ", & ").concat(HotkeySlot)]: {
|
|
170
168
|
color: "$text-neutrals-disabled"
|
|
171
169
|
},
|
|
172
|
-
[
|
|
170
|
+
["& ".concat(StyledIllustrationSlot)]: {
|
|
173
171
|
filter: "grayscale(1)"
|
|
174
172
|
}
|
|
175
173
|
},
|
|
@@ -200,16 +198,13 @@ const StyledIndicator = styled(Primitive.span, {
|
|
|
200
198
|
});
|
|
201
199
|
const StyledCheckboxItem = styled(RadixDropdownMenu.CheckboxItem, {
|
|
202
200
|
...itemDefaults,
|
|
203
|
-
[
|
|
201
|
+
['&[data-state="checked"] '.concat(StyledIndicator)]: {
|
|
204
202
|
color: "$icon-primary"
|
|
205
203
|
},
|
|
206
|
-
[
|
|
204
|
+
['&[data-state="checked"]:hover:not([aria-disabled="true"]) '.concat(StyledIndicator)]: {
|
|
207
205
|
color: "$icon-primary-hover"
|
|
208
206
|
},
|
|
209
|
-
[
|
|
210
|
-
&[aria-disabled="true"] ${StyledIndicator},
|
|
211
|
-
&[data-disabled] ${StyledIndicator}
|
|
212
|
-
`]: {
|
|
207
|
+
['\n &[aria-disabled="true"] '.concat(StyledIndicator, ",\n &[data-disabled] ").concat(StyledIndicator, "\n ")]: {
|
|
213
208
|
color: "$icon-neutrals-disabled"
|
|
214
209
|
}
|
|
215
210
|
});
|
|
@@ -220,7 +215,7 @@ const useAriaDisabled = ({
|
|
|
220
215
|
onSelect,
|
|
221
216
|
onPointerMove,
|
|
222
217
|
onClick
|
|
223
|
-
},
|
|
218
|
+
}, closeOnCheck = true) => useMemo(
|
|
224
219
|
() => ({
|
|
225
220
|
"aria-disabled": booleanify(ariaDisabled) ? ariaDisabled : void 0,
|
|
226
221
|
onKeyDown: (e) => {
|
|
@@ -232,13 +227,13 @@ const useAriaDisabled = ({
|
|
|
232
227
|
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
233
228
|
},
|
|
234
229
|
onSelect: (e) => {
|
|
235
|
-
if (preventDefault) {
|
|
236
|
-
e.preventDefault();
|
|
237
|
-
}
|
|
238
230
|
if (booleanify(ariaDisabled)) {
|
|
239
231
|
e.preventDefault();
|
|
240
232
|
return;
|
|
241
233
|
}
|
|
234
|
+
if (!closeOnCheck) {
|
|
235
|
+
e.preventDefault();
|
|
236
|
+
}
|
|
242
237
|
onSelect == null ? void 0 : onSelect(e);
|
|
243
238
|
},
|
|
244
239
|
onPointerMove: (e) => {
|
|
@@ -256,7 +251,7 @@ const useAriaDisabled = ({
|
|
|
256
251
|
onClick == null ? void 0 : onClick(e);
|
|
257
252
|
}
|
|
258
253
|
}),
|
|
259
|
-
[ariaDisabled, onKeyDown, onSelect, onPointerMove, onClick,
|
|
254
|
+
[ariaDisabled, onKeyDown, onSelect, onPointerMove, onClick, closeOnCheck]
|
|
260
255
|
);
|
|
261
256
|
|
|
262
257
|
const Context = createContext({
|
|
@@ -291,34 +286,43 @@ const ItemProvider = ({
|
|
|
291
286
|
};
|
|
292
287
|
const useItem = () => useContext(Context);
|
|
293
288
|
|
|
294
|
-
const CheckboxItem = React.forwardRef(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
289
|
+
const CheckboxItem = React.forwardRef(
|
|
290
|
+
({
|
|
291
|
+
children,
|
|
292
|
+
checked,
|
|
293
|
+
onChange,
|
|
294
|
+
disabled,
|
|
295
|
+
closeOnSelect = false,
|
|
296
|
+
...restProps
|
|
297
|
+
}, forwardRef) => {
|
|
298
|
+
const ariaDisabledProps = useAriaDisabled(restProps, closeOnSelect);
|
|
299
|
+
const { "aria-disabled": ariaDisabled } = ariaDisabledProps;
|
|
300
|
+
return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(
|
|
301
|
+
StyledCheckboxItem,
|
|
302
|
+
{
|
|
303
|
+
...restProps,
|
|
304
|
+
...ariaDisabledProps,
|
|
305
|
+
ref: forwardRef,
|
|
306
|
+
checked,
|
|
307
|
+
disabled,
|
|
308
|
+
onCheckedChange: onChange,
|
|
309
|
+
children: [
|
|
310
|
+
children,
|
|
311
|
+
/* @__PURE__ */ jsx(RightSlot, { children: /* @__PURE__ */ jsxs(StyledIndicator, { children: [
|
|
312
|
+
(disabled === true || booleanify(ariaDisabled)) && !checked && /* @__PURE__ */ jsx(
|
|
313
|
+
IconProhibit,
|
|
314
|
+
{
|
|
315
|
+
weight: "thin",
|
|
316
|
+
css: { square: "$3", display: "block" }
|
|
317
|
+
}
|
|
318
|
+
),
|
|
319
|
+
checked && /* @__PURE__ */ jsx(IconCheckMark, { css: { square: "$3", display: "block" } })
|
|
320
|
+
] }) })
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
) });
|
|
324
|
+
}
|
|
325
|
+
);
|
|
322
326
|
|
|
323
327
|
const CONTENT_GUTTER = parseInt(theme.space[150]);
|
|
324
328
|
const CONTENT_OFFSET = parseInt(theme.space[50]);
|
|
@@ -334,7 +338,7 @@ const contentDefaults = {
|
|
|
334
338
|
borderRadius: "$50",
|
|
335
339
|
boxShadow: "$50",
|
|
336
340
|
"& [data-radix-scroll-area-viewport]": {
|
|
337
|
-
padding:
|
|
341
|
+
padding: "".concat(CONTENT_BORDER_FOCUS_ITEM, " $50 ").concat(CONTENT_BORDER_FOCUS_ITEM, " ").concat(CONTENT_BORDER_FOCUS_ITEM),
|
|
338
342
|
boxSizing: "border-box"
|
|
339
343
|
},
|
|
340
344
|
"@media (prefers-reduced-motion: no-preference)": {
|
|
@@ -399,9 +403,9 @@ const ScrollableContent = ({
|
|
|
399
403
|
}) => {
|
|
400
404
|
const getOverflowMaxHeight = useCallback(() => {
|
|
401
405
|
const [top, , bottom] = CONTENT_PADDING[containerSpacing].split(" ").map((value) => value.replace("$", ""));
|
|
402
|
-
const topBottom = top !== void 0 && bottom !== void 0 ?
|
|
403
|
-
const overflowMaxHeigh = overflow === "auto" ?
|
|
404
|
-
const newMaxHeight =
|
|
406
|
+
const topBottom = top !== void 0 && bottom !== void 0 ? "var(--space-".concat(top, ") + var(--space-").concat(bottom, ")") : "var(--space-".concat(top, ") + var(--space-").concat(top, ")");
|
|
407
|
+
const overflowMaxHeigh = overflow === "auto" ? "calc(var(--radix-dropdown-menu-content-available-height) - (".concat(topBottom, "))") : "auto";
|
|
408
|
+
const newMaxHeight = "calc(".concat(maxHeight, " - (").concat(topBottom, "))");
|
|
405
409
|
return {
|
|
406
410
|
maxHeight: maxHeight === void 0 ? overflowMaxHeigh : newMaxHeight
|
|
407
411
|
};
|
|
@@ -410,7 +414,7 @@ const ScrollableContent = ({
|
|
|
410
414
|
return /* @__PURE__ */ jsxs(
|
|
411
415
|
ScrollArea,
|
|
412
416
|
{
|
|
413
|
-
css: { margin:
|
|
417
|
+
css: { margin: "-".concat(CONTENT_BORDER_FOCUS_ITEM) },
|
|
414
418
|
type: "always",
|
|
415
419
|
children: [
|
|
416
420
|
/* @__PURE__ */ jsx(ScrollArea.Viewport, { css: { ...getOverflowMaxHeight() }, children }),
|
|
@@ -529,42 +533,36 @@ const StyledProhibited = styled(IconProhibit, {
|
|
|
529
533
|
});
|
|
530
534
|
const StyledRadioItem = styled(RadixDropdownMenu.RadioItem, {
|
|
531
535
|
...itemDefaults,
|
|
532
|
-
[
|
|
536
|
+
['&[data-state="checked"] '.concat(StyledRadioContainer)]: {
|
|
533
537
|
color: "$icon-primary",
|
|
534
538
|
borderColor: "$border-primary",
|
|
535
|
-
[
|
|
539
|
+
["& ".concat(StyledPill)]: {
|
|
536
540
|
display: "block",
|
|
537
541
|
backgroundColor: "$background-primary-prominent-selected"
|
|
538
542
|
}
|
|
539
543
|
},
|
|
540
|
-
[
|
|
544
|
+
['&:hover:not([aria-disabled="true"]) '.concat(StyledRadioContainer)]: {
|
|
541
545
|
borderColor: "$border-primary-hover",
|
|
542
|
-
[
|
|
546
|
+
["& ".concat(StyledPill)]: {
|
|
543
547
|
backgroundColor: "$background-primary-prominent-hover"
|
|
544
548
|
}
|
|
545
549
|
},
|
|
546
|
-
[
|
|
547
|
-
&[aria-disabled="true"] ${StyledRadioContainer},
|
|
548
|
-
&[data-disabled] ${StyledRadioContainer}
|
|
549
|
-
`]: {
|
|
550
|
+
['\n &[aria-disabled="true"] '.concat(StyledRadioContainer, ",\n &[data-disabled] ").concat(StyledRadioContainer, "\n ")]: {
|
|
550
551
|
color: "$icon-neutrals-disabled",
|
|
551
552
|
borderColor: "$border-neutrals-disabled",
|
|
552
|
-
[
|
|
553
|
+
["& ".concat(StyledPill)]: {
|
|
553
554
|
backgroundColor: "$icon-neutrals-disabled"
|
|
554
555
|
}
|
|
555
556
|
},
|
|
556
557
|
'&[data-state="unchecked"]': {
|
|
557
|
-
[
|
|
558
|
-
&[aria-disabled="true"] ${StyledProhibited},
|
|
559
|
-
&[data-disabled] ${StyledProhibited}
|
|
560
|
-
`]: {
|
|
558
|
+
['\n &[aria-disabled="true"] '.concat(StyledProhibited, ",\n &[data-disabled] ").concat(StyledProhibited, "\n ")]: {
|
|
561
559
|
display: "flex"
|
|
562
560
|
}
|
|
563
561
|
}
|
|
564
562
|
});
|
|
565
563
|
|
|
566
|
-
const RadioItem = React.forwardRef(({ disabled = false,
|
|
567
|
-
const ariaDisabledProps = useAriaDisabled(restProps,
|
|
564
|
+
const RadioItem = React.forwardRef(({ disabled, children, closeOnSelect = false, ...restProps }, forwardRef) => {
|
|
565
|
+
const ariaDisabledProps = useAriaDisabled(restProps, closeOnSelect);
|
|
568
566
|
return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(
|
|
569
567
|
StyledRadioItem,
|
|
570
568
|
{
|
|
@@ -596,18 +594,22 @@ const StyledSwitch = styled(Primitive.span, {
|
|
|
596
594
|
});
|
|
597
595
|
const StyledSwitchItem = styled(RadixDropdownMenu.CheckboxItem, {
|
|
598
596
|
...itemDefaults,
|
|
599
|
-
[
|
|
600
|
-
[
|
|
601
|
-
[
|
|
602
|
-
[
|
|
603
|
-
&[aria-disabled="true"] ${StyledSwitch},
|
|
604
|
-
&[data-disabled] ${StyledSwitch}
|
|
605
|
-
`]: styles.disabled
|
|
597
|
+
['&[data-state="checked"] '.concat(StyledSwitch)]: styles.checked,
|
|
598
|
+
['&[data-state="checked"]:hover:not([aria-disabled="true"]) '.concat(StyledSwitch)]: styles.checkedHovered,
|
|
599
|
+
['&:hover:not([aria-disabled="true"]) '.concat(StyledSwitch)]: styles.hovered,
|
|
600
|
+
['\n &[aria-disabled="true"] '.concat(StyledSwitch, ",\n &[data-disabled] ").concat(StyledSwitch, "\n ")]: styles.disabled
|
|
606
601
|
});
|
|
607
602
|
|
|
608
603
|
const SwitchItem = React.forwardRef(
|
|
609
|
-
({
|
|
610
|
-
|
|
604
|
+
({
|
|
605
|
+
disabled,
|
|
606
|
+
checked,
|
|
607
|
+
onChange,
|
|
608
|
+
children,
|
|
609
|
+
closeOnSelect = false,
|
|
610
|
+
...restProps
|
|
611
|
+
}, forwardRef) => {
|
|
612
|
+
const ariaDisabledProps = useAriaDisabled(restProps, closeOnSelect);
|
|
611
613
|
return /* @__PURE__ */ jsx(ItemProvider, { children: /* @__PURE__ */ jsxs(
|
|
612
614
|
StyledSwitchItem,
|
|
613
615
|
{
|
|
@@ -680,7 +682,7 @@ const StyledIconContainer = styled(Primitive.span, {
|
|
|
680
682
|
const StyledSubTrigger = styled(RadixDropdownMenu.SubTrigger, {
|
|
681
683
|
...itemDefaults,
|
|
682
684
|
'&[data-state="open"]': itemDefaults['&:hover:not([aria-disabled="true"])'],
|
|
683
|
-
[
|
|
685
|
+
['&[data-state="open"] '.concat(StyledIconContainer, ', &:hover:not([aria-disabled="true"]) ').concat(StyledIconContainer)]: {
|
|
684
686
|
color: "$icon-primary-hover"
|
|
685
687
|
}
|
|
686
688
|
});
|