@mirohq/design-system-dropdown-menu 3.3.0-dropdown.1 → 3.3.0-dropdown.10

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
@@ -5,10 +5,13 @@ 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');
11
- var designSystemSwitch = require('@mirohq/design-system-switch');
12
+ var designSystemScrollArea = require('@mirohq/design-system-scroll-area');
13
+ var designSystemBaseSwitch = require('@mirohq/design-system-base-switch');
14
+ var designSystemBaseIcon = require('@mirohq/design-system-base-icon');
12
15
 
13
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
17
 
@@ -44,6 +47,112 @@ const ItemDescription = designSystemStitches.styled(designSystemPrimitive.Primit
44
47
  color: "$text-neutrals-subtle"
45
48
  });
46
49
 
50
+ const LeftSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
51
+ display: "flex",
52
+ alignItems: "center",
53
+ justifyContent: "center",
54
+ marginRight: "$100",
55
+ gridArea: "left-slot"
56
+ });
57
+
58
+ const StyledIllustrationSlot = designSystemStitches.styled(LeftSlot, {
59
+ width: "$13"
60
+ });
61
+
62
+ const Context$1 = React.createContext({
63
+ rightSlotMount: () => 0,
64
+ rightSlotDestroy: () => {
65
+ },
66
+ containerSpacing: "medium"
67
+ });
68
+ const ContentProvider = ({
69
+ children,
70
+ containerSpacing = "medium"
71
+ }) => {
72
+ const [maxWidth, setMaxWidth] = React.useState(0);
73
+ const maxRef = React.useRef(0);
74
+ const indexRef = React.useRef(0);
75
+ const widthMapRef = React.useRef(/* @__PURE__ */ new Map());
76
+ const updateMaxWith = React.useCallback((value) => {
77
+ maxRef.current = value;
78
+ setMaxWidth(value);
79
+ }, []);
80
+ const rightSlotMount = React.useCallback(
81
+ (width) => {
82
+ indexRef.current++;
83
+ widthMapRef.current.set(indexRef.current, width);
84
+ if (width > maxRef.current) {
85
+ updateMaxWith(width);
86
+ }
87
+ return indexRef.current;
88
+ },
89
+ [updateMaxWith]
90
+ );
91
+ const rightSlotDestroy = React.useCallback(
92
+ (index) => {
93
+ widthMapRef.current.delete(index);
94
+ if (widthMapRef.current.size === 0) {
95
+ updateMaxWith(0);
96
+ } else {
97
+ const maximum = Math.max(...Array.from(widthMapRef.current.values()));
98
+ updateMaxWith(maximum);
99
+ }
100
+ },
101
+ [updateMaxWith]
102
+ );
103
+ const formattedChildren = designSystemUtils.addPropsToChildren(children, () => true, {
104
+ UNSAFE_style: {
105
+ "--right-slot-max-width": `${Math.ceil(maxWidth)}px`
106
+ }
107
+ });
108
+ return /* @__PURE__ */ React__default["default"].createElement(Context$1.Provider, {
109
+ value: {
110
+ rightSlotMount,
111
+ rightSlotDestroy,
112
+ containerSpacing
113
+ }
114
+ }, formattedChildren);
115
+ };
116
+ const useContent = () => React.useContext(Context$1);
117
+
118
+ const StyledRightSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
119
+ display: "flex",
120
+ alignItems: "center",
121
+ justifyContent: "center",
122
+ marginLeft: "auto",
123
+ paddingLeft: "$200",
124
+ gridArea: "right-slot",
125
+ height: "$5",
126
+ width: "$7",
127
+ minWidth: "max-content",
128
+ textAlign: "right",
129
+ "&:empty": {
130
+ paddingLeft: "$none"
131
+ }
132
+ });
133
+
134
+ const RightSlot = (props) => {
135
+ const { rightSlotMount, rightSlotDestroy } = useContent();
136
+ const ref = React.useRef(null);
137
+ React.useEffect(() => {
138
+ if (ref.current !== null) {
139
+ const width = ref.current.getBoundingClientRect().width;
140
+ const index = rightSlotMount(width);
141
+ return () => rightSlotDestroy(index);
142
+ }
143
+ return () => {
144
+ };
145
+ }, [rightSlotMount, rightSlotDestroy, ref]);
146
+ return /* @__PURE__ */ React__default["default"].createElement(StyledRightSlot, {
147
+ ref,
148
+ ...props
149
+ });
150
+ };
151
+
152
+ const HotkeySlot = designSystemStitches.styled(RightSlot, {
153
+ color: "$text-neutrals-subtle"
154
+ });
155
+
47
156
  const itemDefaults = {
48
157
  all: "unset",
49
158
  boxSizing: "border-box",
@@ -52,115 +161,186 @@ const itemDefaults = {
52
161
  color: "$text-neutrals",
53
162
  borderRadius: "$50",
54
163
  display: "grid",
55
- gridTemplateColumns: "auto 1fr auto",
164
+ gridTemplateColumns: "auto 1fr minmax(auto, var(--right-slot-max-width))",
56
165
  gridTemplateRows: "1fr auto",
57
- gridTemplateAreas: `
58
- 'left-slot item-text right-slot'
59
- 'left-slot item-description right-slot'
60
- `,
61
- alignItems: "center",
62
- minHeight: "$11",
63
- padding: "$100 $150",
166
+ gridTemplateAreas: `'left-slot item-text right-slot'
167
+ 'left-slot item-description right-slot'`,
168
+ alignItems: "start",
169
+ minHeight: "$10",
170
+ padding: "$100 $100",
64
171
  position: "relative",
65
172
  userSelect: "none",
66
173
  cursor: "pointer",
67
- "&[data-disabled]": {
68
- color: "rgba(9, 9, 9, 0.4)",
69
- pointerEvents: "none"
174
+ "&[data-no-left-slot]": {
175
+ gridTemplateColumns: "1fr minmax(auto, var(--right-slot-max-width))",
176
+ gridTemplateRows: "auto",
177
+ gridTemplateAreas: `'item-text right-slot'
178
+ 'item-description right-slot'`
179
+ },
180
+ "&:not(:last-child)": {
181
+ marginBottom: "$50"
182
+ },
183
+ "&:not(:first-child)": {
184
+ marginTop: "$50"
70
185
  },
71
186
  ...designSystemStyles.focus.defaults,
72
- "&:hover": {
73
- background: "rgba(232, 236, 255, 1)",
74
- boxShadow: "none",
75
- [`&, & ${ItemDescription}`]: {
76
- color: "$text-primary-hover"
187
+ '&:disabled, &[aria-disabled="true"], &[data-disabled]': {
188
+ cursor: "default",
189
+ [`&, & ${ItemDescription}, & ${HotkeySlot}`]: {
190
+ color: "$text-neutrals-disabled"
191
+ },
192
+ [`& ${StyledIllustrationSlot}`]: {
193
+ filter: "grayscale(1)"
194
+ }
195
+ },
196
+ "&:disabled, &[data-disabled]": {
197
+ pointerEvents: "none"
198
+ },
199
+ '&:hover:not([aria-disabled="true"])': {
200
+ background: "$background-primary-subtle-hover",
201
+ color: "$text-primary-hover",
202
+ '&:not([aria-disabled="true"])': {
203
+ boxShadow: "none"
77
204
  }
78
205
  },
206
+ '&:active:not([aria-disabled="true"])': {
207
+ background: "$background-primary-subtle-active",
208
+ boxShadow: "none",
209
+ color: "$text-primary-active"
210
+ },
79
211
  '&[tabindex="0"]': {
80
212
  zIndex: "1"
81
213
  }
82
214
  };
83
215
 
84
- const StyledIndicator = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {});
85
- const checkboxItemStyles = {
216
+ const StyledIndicator = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
217
+ display: "flex",
218
+ alignItems: "center",
219
+ justifyContent: "center"
220
+ });
221
+ const StyledCheckboxItem = designSystemStitches.styled(RadixDropdownMenu__namespace.CheckboxItem, {
86
222
  ...itemDefaults,
87
223
  [`&[data-state="checked"] ${StyledIndicator}`]: {
88
224
  color: "$icon-primary"
89
225
  },
90
- [`&[data-state="checked"]:hover ${StyledIndicator}`]: {
226
+ [`&[data-state="checked"]:hover:not([aria-disabled="true"]) ${StyledIndicator}`]: {
91
227
  color: "$icon-primary-hover"
92
228
  },
93
- [`&[data-disabled] ${StyledIndicator}`]: {
229
+ [`
230
+ &[aria-disabled="true"] ${StyledIndicator},
231
+ &[data-disabled] ${StyledIndicator}
232
+ `]: {
94
233
  color: "$icon-neutrals-disabled"
95
234
  }
96
- };
97
- const StyledCheckboxItem = designSystemStitches.styled(
98
- RadixDropdownMenu__namespace.CheckboxItem,
99
- checkboxItemStyles
100
- );
101
-
102
- const LeftSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
103
- display: "flex",
104
- placeContent: "center",
105
- marginRight: "$100",
106
- gridArea: "left-slot"
107
- });
108
- const IconSlot = designSystemStitches.styled(LeftSlot, {
109
- width: "$6"
110
- });
111
- const IllustrationSlot = designSystemStitches.styled(LeftSlot, {
112
- width: "$13"
113
- });
114
- const RightSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
115
- display: "flex",
116
- alignItems: "center",
117
- marginLeft: "auto",
118
- paddingLeft: "$200",
119
- gridArea: "right-slot"
120
235
  });
121
236
 
122
- const CheckboxItemRoot = ({
123
- disabled = false,
124
- onChange,
237
+ const useAriaDisabled = ({
238
+ "aria-disabled": ariaDisabled,
239
+ onKeyDown,
125
240
  onSelect,
126
- ref,
127
- ...restProps
128
- }) => /* @__PURE__ */ React__default["default"].createElement(StyledCheckboxItem, {
129
- ...restProps,
130
- ref,
131
- disabled,
132
- onCheckedChange: onChange,
133
- onSelect: (event) => {
134
- event.preventDefault();
135
- onSelect == null ? void 0 : onSelect(event);
241
+ onPointerMove,
242
+ onClick
243
+ }, preventDefault = false) => React.useMemo(
244
+ () => ({
245
+ "aria-disabled": designSystemUtils.booleanify(ariaDisabled) ? ariaDisabled : void 0,
246
+ onKeyDown: (e) => {
247
+ if (designSystemUtils.booleanify(ariaDisabled) && e.code !== "ArrowUp" && e.code !== "ArrowDown") {
248
+ e.preventDefault();
249
+ e.stopPropagation();
250
+ return;
251
+ }
252
+ onKeyDown == null ? void 0 : onKeyDown(e);
253
+ },
254
+ onSelect: (e) => {
255
+ if (preventDefault) {
256
+ e.preventDefault();
257
+ }
258
+ if (designSystemUtils.booleanify(ariaDisabled)) {
259
+ e.preventDefault();
260
+ return;
261
+ }
262
+ onSelect == null ? void 0 : onSelect(e);
263
+ },
264
+ onPointerMove: (e) => {
265
+ if (designSystemUtils.booleanify(ariaDisabled)) {
266
+ e.preventDefault();
267
+ return;
268
+ }
269
+ onPointerMove == null ? void 0 : onPointerMove(e);
270
+ },
271
+ onClick: (e) => {
272
+ if (designSystemUtils.booleanify(ariaDisabled)) {
273
+ e.preventDefault();
274
+ return;
275
+ }
276
+ onClick == null ? void 0 : onClick(e);
277
+ }
278
+ }),
279
+ [ariaDisabled, onKeyDown, onSelect, onPointerMove, onClick, preventDefault]
280
+ );
281
+
282
+ const Context = React.createContext({
283
+ leftSlotMount: () => {
284
+ },
285
+ leftSlotDestroy: () => {
136
286
  }
137
287
  });
138
- const CheckboxItem = React__default["default"].forwardRef(({ children, checked, disabled, ...restProps }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(CheckboxItemRoot, {
139
- ...restProps,
140
- checked,
141
- disabled,
142
- ref: forwardRef
143
- }, 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, {
144
- size: "small"
145
- }), checked && /* @__PURE__ */ React__default["default"].createElement(designSystemIcons.IconCheckMark, {
146
- size: "small"
147
- })))));
148
-
149
- const GUTTER_TOKEN = 150;
150
- const CONTENT_GUTTER = parseInt(designSystemStitches.theme.space[GUTTER_TOKEN]);
288
+ const ItemProvider = ({
289
+ children
290
+ }) => {
291
+ const [hasSlot, setHasSlot] = React.useState(false);
292
+ const leftSlotMount = React.useCallback(() => {
293
+ setHasSlot(true);
294
+ }, []);
295
+ const leftSlotDestroy = React.useCallback(() => {
296
+ setHasSlot(false);
297
+ }, []);
298
+ const formattedChildren = hasSlot ? children : designSystemUtils.addPropsToChildren(children, () => true, {
299
+ "data-no-left-slot": ""
300
+ });
301
+ return /* @__PURE__ */ React__default["default"].createElement(Context.Provider, {
302
+ value: {
303
+ leftSlotMount,
304
+ leftSlotDestroy
305
+ }
306
+ }, formattedChildren);
307
+ };
308
+ const useItem = () => React.useContext(Context);
309
+
310
+ const CheckboxItem = React__default["default"].forwardRef(({ children, checked, onChange, disabled, ...restProps }, forwardRef) => {
311
+ const ariaDisabledProps = useAriaDisabled(restProps, true);
312
+ const { "aria-disabled": ariaDisabled } = ariaDisabledProps;
313
+ return /* @__PURE__ */ React__default["default"].createElement(ItemProvider, null, /* @__PURE__ */ React__default["default"].createElement(StyledCheckboxItem, {
314
+ ...restProps,
315
+ ...ariaDisabledProps,
316
+ ref: forwardRef,
317
+ checked,
318
+ disabled,
319
+ onCheckedChange: onChange
320
+ }, 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, {
321
+ weight: "thin",
322
+ css: { square: "$3", display: "block" }
323
+ }), checked && /* @__PURE__ */ React__default["default"].createElement(designSystemIcons.IconCheckMark, {
324
+ css: { square: "$3", display: "block" }
325
+ })))));
326
+ });
327
+
328
+ const CONTENT_GUTTER = parseInt(designSystemStitches.theme.space[150]);
151
329
  const CONTENT_OFFSET = parseInt(designSystemStitches.theme.space[50]);
152
- const ITEM_WITHOUT_RIGHT_SLOT = `[role="menuitem"]:not(:has(${RightSlot}))`;
330
+ const CONTENT_BORDER_FOCUS_ITEM = "2px";
331
+ const CONTENT_PADDING = {
332
+ small: "$50 $150",
333
+ medium: "$150",
334
+ large: "$150 $300"
335
+ };
153
336
  const contentDefaults = {
154
337
  maxWidth: "$125",
155
- backgroundColor: "$white",
338
+ backgroundColor: "$background-neutrals-container",
156
339
  borderRadius: "$50",
157
- padding: `$${GUTTER_TOKEN}`,
158
340
  boxShadow: "$50",
159
- [`&:has(${RightSlot}) > ${ITEM_WITHOUT_RIGHT_SLOT}`]: {
160
- paddingRight: "44px"
161
- },
162
- [`&:has([role="switch"]) > ${ITEM_WITHOUT_RIGHT_SLOT}`]: {
163
- paddingRight: "56px"
341
+ "& [data-radix-scroll-area-viewport]": {
342
+ padding: `${CONTENT_BORDER_FOCUS_ITEM} $50 ${CONTENT_BORDER_FOCUS_ITEM} ${CONTENT_BORDER_FOCUS_ITEM}`,
343
+ boxSizing: "border-box"
164
344
  },
165
345
  "@media (prefers-reduced-motion: no-preference)": {
166
346
  animationDuration: "150ms",
@@ -193,7 +373,56 @@ const contentDefaults = {
193
373
  zIndex: "$dropdownMenu"
194
374
  };
195
375
 
196
- const StyledContent = designSystemStitches.styled(RadixDropdownMenu__namespace.Content, contentDefaults);
376
+ const StyledContent = designSystemStitches.styled(RadixDropdownMenu__namespace.Content, {
377
+ ...contentDefaults,
378
+ variants: {
379
+ containerSpacing: {
380
+ small: {
381
+ '&, [role="menu"]': {
382
+ padding: CONTENT_PADDING.small
383
+ }
384
+ },
385
+ medium: {
386
+ '&, [role="menu"]': {
387
+ padding: CONTENT_PADDING.medium
388
+ }
389
+ },
390
+ large: {
391
+ '&, [role="menu"]': {
392
+ padding: CONTENT_PADDING.large
393
+ }
394
+ }
395
+ }
396
+ }
397
+ });
398
+
399
+ const ScrollableContent = ({
400
+ children,
401
+ maxHeight,
402
+ overflow,
403
+ containerSpacing
404
+ }) => {
405
+ const getOverflowMaxHeight = React.useCallback(() => {
406
+ const [top, , bottom] = CONTENT_PADDING[containerSpacing].split(" ").map((value) => value.replace("$", ""));
407
+ const topBottom = top !== void 0 && bottom !== void 0 ? `var(--space-${top}) + var(--space-${bottom})` : `var(--space-${top}) + var(--space-${top})`;
408
+ const overflowMaxHeigh = overflow === "auto" ? `calc(var(--radix-dropdown-menu-content-available-height) - (${topBottom}))` : "auto";
409
+ const newMaxHeight = `calc(${maxHeight} - (${topBottom}))`;
410
+ return {
411
+ maxHeight: maxHeight === void 0 ? overflowMaxHeigh : newMaxHeight
412
+ };
413
+ }, [maxHeight, overflow, containerSpacing]);
414
+ if (overflow === "auto") {
415
+ return /* @__PURE__ */ React__default["default"].createElement(designSystemScrollArea.ScrollArea, {
416
+ css: { margin: `-${CONTENT_BORDER_FOCUS_ITEM}` },
417
+ type: "always"
418
+ }, /* @__PURE__ */ React__default["default"].createElement(designSystemScrollArea.ScrollArea.Viewport, {
419
+ css: { ...getOverflowMaxHeight() }
420
+ }, children), /* @__PURE__ */ React__default["default"].createElement(designSystemScrollArea.ScrollArea.Scrollbar, {
421
+ orientation: "vertical"
422
+ }, /* @__PURE__ */ React__default["default"].createElement(designSystemScrollArea.ScrollArea.Thumb, null)));
423
+ }
424
+ return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children);
425
+ };
197
426
 
198
427
  const Content = React__default["default"].forwardRef(
199
428
  ({
@@ -206,8 +435,14 @@ const Content = React__default["default"].forwardRef(
206
435
  avoidCollisions = true,
207
436
  sticky = "partial",
208
437
  hideWhenDetached = false,
438
+ containerSpacing = "medium",
439
+ overflow = "visible",
440
+ maxHeight,
441
+ children,
209
442
  ...restProps
210
- }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledContent, {
443
+ }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(ContentProvider, {
444
+ containerSpacing
445
+ }, /* @__PURE__ */ React__default["default"].createElement(StyledContent, {
211
446
  ...restProps,
212
447
  ref: forwardRef,
213
448
  loop,
@@ -218,29 +453,51 @@ const Content = React__default["default"].forwardRef(
218
453
  avoidCollisions,
219
454
  collisionPadding,
220
455
  sticky,
221
- hideWhenDetached
222
- })
456
+ hideWhenDetached,
457
+ containerSpacing
458
+ }, /* @__PURE__ */ React__default["default"].createElement(ScrollableContent, {
459
+ ...{ containerSpacing, maxHeight, overflow }
460
+ }, children)))
223
461
  );
224
462
 
225
- const StyledItem = designSystemStitches.styled(RadixDropdownMenu__namespace.Item, itemDefaults);
463
+ const StyledItem = designSystemStitches.styled(RadixDropdownMenu__namespace.Item, {
464
+ ...itemDefaults,
465
+ variants: {
466
+ hasRightSlot: {
467
+ true: {
468
+ paddingRight: "$600"
469
+ }
470
+ }
471
+ }
472
+ });
226
473
 
227
474
  const Item = React__default["default"].forwardRef(
228
- ({ disabled = false, ...restProps }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledItem, {
229
- ...restProps,
230
- ref: forwardRef,
231
- disabled
232
- })
475
+ ({ disabled = false, ...restProps }, forwardRef) => {
476
+ const ariaDisabledProps = useAriaDisabled(restProps);
477
+ return /* @__PURE__ */ React__default["default"].createElement(ItemProvider, null, /* @__PURE__ */ React__default["default"].createElement(StyledItem, {
478
+ ...restProps,
479
+ ...ariaDisabledProps,
480
+ disabled,
481
+ ref: forwardRef
482
+ }));
483
+ }
233
484
  );
234
485
 
235
- const LinkItem = React__default["default"].forwardRef(({ children, href, ...restProps }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(Item, {
236
- asChild: true,
237
- ref: forwardRef,
238
- ...restProps
239
- }, /* @__PURE__ */ React__default["default"].createElement("a", {
240
- href
241
- }, children)));
486
+ const LinkItem = React__default["default"].forwardRef(({ children, href, ...restProps }, forwardRef) => {
487
+ const ariaDisabledProps = useAriaDisabled(restProps);
488
+ return /* @__PURE__ */ React__default["default"].createElement(Item, {
489
+ asChild: true,
490
+ ref: forwardRef,
491
+ ...restProps,
492
+ ...ariaDisabledProps
493
+ }, /* @__PURE__ */ React__default["default"].createElement("a", {
494
+ href
495
+ }, children));
496
+ });
242
497
 
243
- const StyledRadioGroup = designSystemStitches.styled(RadixDropdownMenu__namespace.RadioGroup);
498
+ const StyledRadioGroup = designSystemStitches.styled(RadixDropdownMenu__namespace.RadioGroup, {
499
+ marginY: "$50"
500
+ });
244
501
 
245
502
  const RadioGroup = React__default["default"].forwardRef((props, forwardRef) => {
246
503
  const { onChange, ...restProps } = props;
@@ -251,7 +508,7 @@ const RadioGroup = React__default["default"].forwardRef((props, forwardRef) => {
251
508
  });
252
509
  });
253
510
 
254
- const StyledRadioContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
511
+ const StyledRadioContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
255
512
  display: "flex",
256
513
  alignItems: "center",
257
514
  justifyContent: "center",
@@ -261,7 +518,7 @@ const StyledRadioContainer = designSystemStitches.styled(designSystemPrimitive.P
261
518
  border: "1px solid $border-neutrals",
262
519
  borderRadius: "$half"
263
520
  });
264
- const StyledPill = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
521
+ const StyledPill = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
265
522
  display: "none",
266
523
  width: "$2",
267
524
  height: "$2",
@@ -269,7 +526,7 @@ const StyledPill = designSystemStitches.styled(designSystemPrimitive.Primitive.s
269
526
  });
270
527
  const StyledProhibited = designSystemStitches.styled(designSystemIcons.IconProhibit, {
271
528
  display: "none",
272
- width: "$3"
529
+ width: "$3 !important"
273
530
  });
274
531
  const StyledRadioItem = designSystemStitches.styled(RadixDropdownMenu__namespace.RadioItem, {
275
532
  ...itemDefaults,
@@ -281,37 +538,46 @@ const StyledRadioItem = designSystemStitches.styled(RadixDropdownMenu__namespace
281
538
  backgroundColor: "$background-primary-prominent-selected"
282
539
  }
283
540
  },
284
- [`&:hover ${StyledRadioContainer}`]: {
541
+ [`&:hover:not([aria-disabled="true"]) ${StyledRadioContainer}`]: {
285
542
  borderColor: "$border-primary-hover",
286
543
  [`& ${StyledPill}`]: {
287
544
  backgroundColor: "$background-primary-prominent-hover"
288
545
  }
289
546
  },
290
- [`&[data-disabled] ${StyledRadioContainer}`]: {
547
+ [`
548
+ &[aria-disabled="true"] ${StyledRadioContainer},
549
+ &[data-disabled] ${StyledRadioContainer}
550
+ `]: {
291
551
  color: "$icon-neutrals-disabled",
292
552
  borderColor: "$border-neutrals-disabled",
293
553
  [`& ${StyledPill}`]: {
294
554
  backgroundColor: "$icon-neutrals-disabled"
295
555
  }
296
556
  },
297
- [`&[data-state="unchecked"][data-disabled] ${StyledProhibited}`]: {
298
- display: "block"
557
+ '&[data-state="unchecked"]': {
558
+ [`
559
+ &[aria-disabled="true"] ${StyledProhibited},
560
+ &[data-disabled] ${StyledProhibited}
561
+ `]: {
562
+ display: "flex"
563
+ }
299
564
  }
300
565
  });
301
566
 
302
- const RadioItem = React__default["default"].forwardRef(({ disabled = false, onSelect, children, ...restProps }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledRadioItem, {
303
- ...restProps,
304
- ref: forwardRef,
305
- disabled,
306
- onSelect: (event) => {
307
- event.preventDefault();
308
- onSelect == null ? void 0 : onSelect(event);
309
- }
310
- }, 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)))));
567
+ const RadioItem = React__default["default"].forwardRef(({ disabled = false, children, ...restProps }, forwardRef) => {
568
+ const ariaDisabledProps = useAriaDisabled(restProps, true);
569
+ return /* @__PURE__ */ React__default["default"].createElement(ItemProvider, null, /* @__PURE__ */ React__default["default"].createElement(StyledRadioItem, {
570
+ ...restProps,
571
+ ...ariaDisabledProps,
572
+ disabled,
573
+ ref: forwardRef
574
+ }, 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, {
575
+ weight: "thin"
576
+ })))));
577
+ });
311
578
 
312
579
  const StyledSeparator = designSystemStitches.styled(RadixDropdownMenu__namespace.Separator, {
313
- borderTop: "1px solid rgba(235, 235, 239, 1)",
314
- marginY: "$100"
580
+ borderTop: "1px solid $border-neutrals-subtle"
315
581
  });
316
582
 
317
583
  const Separator = React__default["default"].forwardRef((props, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledSeparator, {
@@ -319,33 +585,48 @@ const Separator = React__default["default"].forwardRef((props, forwardRef) => /*
319
585
  ref: forwardRef
320
586
  }));
321
587
 
588
+ const StyledSwitch = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
589
+ ...designSystemBaseSwitch.styles.default,
590
+ width: "$7",
591
+ height: "$4"
592
+ });
593
+ const StyledSwitchItem = designSystemStitches.styled(RadixDropdownMenu__namespace.CheckboxItem, {
594
+ ...itemDefaults,
595
+ [`&[data-state="checked"] ${StyledSwitch}`]: designSystemBaseSwitch.styles.checked,
596
+ [`&[data-state="checked"]:hover:not([aria-disabled="true"]) ${StyledSwitch}`]: designSystemBaseSwitch.styles.checkedHovered,
597
+ [`&:hover:not([aria-disabled="true"]) ${StyledSwitch}`]: designSystemBaseSwitch.styles.hovered,
598
+ [`
599
+ &[aria-disabled="true"] ${StyledSwitch},
600
+ &[data-disabled] ${StyledSwitch}
601
+ `]: designSystemBaseSwitch.styles.disabled
602
+ });
603
+
322
604
  const SwitchItem = React__default["default"].forwardRef(
323
- ({ disabled = false, checked, onSelect, children, ...restProps }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(CheckboxItemRoot, {
324
- ...restProps,
325
- ref: forwardRef,
326
- disabled,
327
- checked
328
- }, children, /* @__PURE__ */ React__default["default"].createElement(RightSlot, null, /* @__PURE__ */ React__default["default"].createElement(designSystemSwitch.Switch, {
329
- checked,
330
- disabled,
331
- onChange: (x) => x,
332
- value: ""
333
- })))
605
+ ({ disabled = false, checked, onChange, children, ...restProps }, forwardRef) => {
606
+ const ariaDisabledProps = useAriaDisabled(restProps, true);
607
+ return /* @__PURE__ */ React__default["default"].createElement(ItemProvider, null, /* @__PURE__ */ React__default["default"].createElement(StyledSwitchItem, {
608
+ ...restProps,
609
+ ...ariaDisabledProps,
610
+ disabled,
611
+ checked,
612
+ onCheckedChange: onChange,
613
+ ref: forwardRef
614
+ }, children, /* @__PURE__ */ React__default["default"].createElement(RightSlot, null, /* @__PURE__ */ React__default["default"].createElement(StyledSwitch, null, /* @__PURE__ */ React__default["default"].createElement(designSystemBaseSwitch.Thumb, null)))));
615
+ }
334
616
  );
335
617
 
336
- const defaultStyles = {
337
- boxSizing: "border-box",
338
- cursor: "pointer",
339
- ...designSystemStyles.focus.defaults
340
- };
341
618
  const StyledTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.Trigger, {
342
619
  variants: {
343
620
  unstyled: {
344
621
  true: {
345
622
  all: "unset",
346
- ...defaultStyles
623
+ boxSizing: "border-box",
624
+ cursor: "pointer",
625
+ ...designSystemStyles.focus.defaults
347
626
  },
348
- false: defaultStyles
627
+ false: {
628
+ cursor: "pointer"
629
+ }
349
630
  }
350
631
  }
351
632
  });
@@ -358,26 +639,36 @@ const Trigger = React__default["default"].forwardRef(({ asChild = false, onPress
358
639
  asChild
359
640
  }));
360
641
 
642
+ const StyledIconContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
643
+ color: "$icon-neutrals-with-text",
644
+ display: "flex",
645
+ alignItems: "center"
646
+ });
361
647
  const StyledSubTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.SubTrigger, {
362
648
  ...itemDefaults,
363
- '&[data-state="open"]': itemDefaults["&:hover"]
364
- });
365
-
366
- const ArrowIcon = () => /* @__PURE__ */ React__default["default"].createElement("svg", {
367
- width: "16",
368
- height: "16",
369
- viewBox: "0 0 16 16",
370
- fill: "currentColor",
371
- xmlns: "http://www.w3.org/2000/svg",
372
- "data-testid": "submenu-arrow-icon"
373
- }, /* @__PURE__ */ React__default["default"].createElement("path", {
374
- d: "M5.29289 3.29289C5.68342 2.90237 6.31658 2.90237 6.70711 3.29289L11.4142 8L6.70711 12.7071C6.31658 13.0976 5.68342 13.0976 5.29289 12.7071C4.90237 12.3166 4.90237 11.6834 5.29289 11.2929L8.58579 8L5.29289 4.70711C4.90237 4.31658 4.90237 3.68342 5.29289 3.29289Z"
375
- }));
376
- const SubTrigger = React__default["default"].forwardRef(({ children, disabled = false, ...restProps }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledSubTrigger, {
377
- ...restProps,
378
- ref: forwardRef,
379
- disabled
380
- }, children, /* @__PURE__ */ React__default["default"].createElement(RightSlot, null, /* @__PURE__ */ React__default["default"].createElement(ArrowIcon, null))));
649
+ '&[data-state="open"]': itemDefaults['&:hover:not([aria-disabled="true"])'],
650
+ [`&[data-state="open"] ${StyledIconContainer}, &:hover:not([aria-disabled="true"]) ${StyledIconContainer}`]: {
651
+ color: "$icon-primary-hover"
652
+ }
653
+ });
654
+
655
+ const SubTrigger = React__default["default"].forwardRef(({ children, disabled = false, ...restProps }, forwardRef) => {
656
+ const { onSelect, ...ariaDisabledProps } = useAriaDisabled({
657
+ onKeyDown: restProps.onKeyDown,
658
+ "aria-disabled": restProps["aria-disabled"]
659
+ });
660
+ return /* @__PURE__ */ React__default["default"].createElement(StyledSubTrigger, {
661
+ ...restProps,
662
+ ...ariaDisabledProps,
663
+ disabled,
664
+ ref: forwardRef
665
+ }, children, /* @__PURE__ */ React__default["default"].createElement(RightSlot, null, /* @__PURE__ */ React__default["default"].createElement(StyledIconContainer, {
666
+ "data-testid": process.env.NODE_ENV === "test" ? "submenu-arrow-icon" : void 0
667
+ }, /* @__PURE__ */ React__default["default"].createElement(designSystemIcons.IconChevronRight, {
668
+ size: "small",
669
+ weight: "thin"
670
+ }))));
671
+ });
381
672
 
382
673
  const StyledSubContent = designSystemStitches.styled(
383
674
  RadixDropdownMenu__namespace.SubContent,
@@ -391,19 +682,29 @@ const SubContent = React__default["default"].forwardRef(
391
682
  alignOffset = -CONTENT_GUTTER,
392
683
  collisionPadding = 0,
393
684
  loop = false,
394
- hideWhenDetached = false,
685
+ hideWhenDetached = true,
395
686
  sticky = "partial",
687
+ overflow = "visible",
688
+ maxHeight,
689
+ children,
396
690
  ...restProps
397
- }, forwardRef) => /* @__PURE__ */ React__default["default"].createElement(StyledSubContent, {
398
- ...restProps,
399
- ref: forwardRef,
400
- sideOffset,
401
- alignOffset,
402
- collisionPadding,
403
- loop,
404
- hideWhenDetached,
405
- sticky
406
- })
691
+ }, forwardRef) => {
692
+ const { containerSpacing } = useContent();
693
+ return /* @__PURE__ */ React__default["default"].createElement(ContentProvider, {
694
+ containerSpacing
695
+ }, /* @__PURE__ */ React__default["default"].createElement(StyledSubContent, {
696
+ ...restProps,
697
+ ref: forwardRef,
698
+ sideOffset,
699
+ alignOffset,
700
+ collisionPadding,
701
+ loop,
702
+ hideWhenDetached,
703
+ sticky
704
+ }, /* @__PURE__ */ React__default["default"].createElement(ScrollableContent, {
705
+ ...{ containerSpacing, maxHeight, overflow }
706
+ }, children)));
707
+ }
407
708
  );
408
709
 
409
710
  const StyledSub = designSystemStitches.styled(RadixDropdownMenu__namespace.Sub, {});
@@ -429,6 +730,47 @@ const Portal = (props) => /* @__PURE__ */ React__default["default"].createElemen
429
730
  ...props
430
731
  });
431
732
 
733
+ const StyledIconSlot = designSystemStitches.styled(LeftSlot, {
734
+ square: "$5",
735
+ "& svg:not([data-icon-component]), & img:not([data-icon-component])": {
736
+ ...designSystemBaseIcon.styles.size.small,
737
+ ...designSystemBaseIcon.styles.weight.thin
738
+ }
739
+ });
740
+
741
+ const IconSlot = React__default["default"].forwardRef(({ children, ...restProps }, forwardRef) => {
742
+ const { leftSlotMount, leftSlotDestroy } = useItem();
743
+ const formattedChildren = designSystemUtils.addPropsToChildren(
744
+ children,
745
+ designSystemBaseIcon.isIconComponent,
746
+ {
747
+ "data-icon-component": "",
748
+ size: "small",
749
+ weight: "thin"
750
+ }
751
+ );
752
+ React.useEffect(() => {
753
+ leftSlotMount();
754
+ return () => leftSlotDestroy();
755
+ }, [leftSlotMount, leftSlotDestroy]);
756
+ return /* @__PURE__ */ React__default["default"].createElement(StyledIconSlot, {
757
+ ref: forwardRef,
758
+ ...restProps
759
+ }, formattedChildren);
760
+ });
761
+
762
+ const IllustrationSlot = React__default["default"].forwardRef((props, forwardRef) => {
763
+ const { leftSlotMount, leftSlotDestroy } = useItem();
764
+ React.useEffect(() => {
765
+ leftSlotMount();
766
+ return () => leftSlotDestroy();
767
+ }, [leftSlotMount, leftSlotDestroy]);
768
+ return /* @__PURE__ */ React__default["default"].createElement(StyledIllustrationSlot, {
769
+ ref: forwardRef,
770
+ ...props
771
+ });
772
+ });
773
+
432
774
  const DropdownMenu = ({
433
775
  defaultOpen = false,
434
776
  direction = "ltr",
@@ -454,6 +796,7 @@ const DropdownMenu = ({
454
796
  };
455
797
  DropdownMenu.CheckboxItem = CheckboxItem;
456
798
  DropdownMenu.Content = Content;
799
+ DropdownMenu.HotkeySlot = HotkeySlot;
457
800
  DropdownMenu.IconSlot = IconSlot;
458
801
  DropdownMenu.IllustrationSlot = IllustrationSlot;
459
802
  DropdownMenu.Item = Item;