@mirohq/design-system-dropdown-menu 3.3.0-dropdown.8 → 3.3.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
@@ -44,31 +44,116 @@ const ItemDescription = designSystemStitches.styled(designSystemPrimitive.Primit
44
44
  overflow: "hidden",
45
45
  gridArea: "item-description",
46
46
  fontSize: "$150",
47
+ lineHeight: 1.5,
47
48
  color: "$text-neutrals-subtle"
48
49
  });
49
50
 
50
51
  const LeftSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
51
52
  display: "flex",
52
- placeContent: "center",
53
+ alignItems: "center",
54
+ justifyContent: "center",
53
55
  marginRight: "$100",
54
56
  gridArea: "left-slot"
55
57
  });
58
+
56
59
  const StyledIllustrationSlot = designSystemStitches.styled(LeftSlot, {
57
60
  width: "$13"
58
61
  });
62
+
63
+ const Context$1 = React.createContext({
64
+ rightSlotMount: () => 0,
65
+ rightSlotDestroy: () => {
66
+ },
67
+ containerSpacing: "medium"
68
+ });
69
+ const ContentProvider = ({
70
+ children,
71
+ containerSpacing = "medium"
72
+ }) => {
73
+ const [maxWidth, setMaxWidth] = React.useState(0);
74
+ const maxRef = React.useRef(0);
75
+ const indexRef = React.useRef(0);
76
+ const widthMapRef = React.useRef(/* @__PURE__ */ new Map());
77
+ const updateMaxWith = React.useCallback((value) => {
78
+ maxRef.current = value;
79
+ setMaxWidth(value);
80
+ }, []);
81
+ const rightSlotMount = React.useCallback(
82
+ (width) => {
83
+ indexRef.current++;
84
+ widthMapRef.current.set(indexRef.current, width);
85
+ if (width > maxRef.current) {
86
+ updateMaxWith(width);
87
+ }
88
+ return indexRef.current;
89
+ },
90
+ [updateMaxWith]
91
+ );
92
+ const rightSlotDestroy = React.useCallback(
93
+ (index) => {
94
+ widthMapRef.current.delete(index);
95
+ if (widthMapRef.current.size === 0) {
96
+ updateMaxWith(0);
97
+ } else {
98
+ const maximum = Math.max(...Array.from(widthMapRef.current.values()));
99
+ updateMaxWith(maximum);
100
+ }
101
+ },
102
+ [updateMaxWith]
103
+ );
104
+ const formattedChildren = designSystemUtils.addPropsToChildren(children, () => true, {
105
+ UNSAFE_style: {
106
+ "--right-slot-max-width": `${Math.ceil(maxWidth)}px`
107
+ }
108
+ });
109
+ return /* @__PURE__ */ React__default["default"].createElement(Context$1.Provider, {
110
+ value: {
111
+ rightSlotMount,
112
+ rightSlotDestroy,
113
+ containerSpacing
114
+ }
115
+ }, formattedChildren);
116
+ };
117
+ const useContent = () => React.useContext(Context$1);
118
+
59
119
  const StyledRightSlot = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
60
120
  display: "flex",
61
121
  alignItems: "center",
122
+ justifyContent: "center",
62
123
  marginLeft: "auto",
63
124
  paddingLeft: "$200",
64
125
  gridArea: "right-slot",
126
+ height: "$5",
127
+ width: "$7",
65
128
  minWidth: "max-content",
66
129
  textAlign: "right",
67
130
  "&:empty": {
68
- paddingLeft: "$none"
131
+ paddingLeft: "$0"
69
132
  }
70
133
  });
71
134
 
135
+ const RightSlot = (props) => {
136
+ const { rightSlotMount, rightSlotDestroy } = useContent();
137
+ const ref = React.useRef(null);
138
+ React.useEffect(() => {
139
+ if (ref.current !== null) {
140
+ const width = ref.current.getBoundingClientRect().width;
141
+ const index = rightSlotMount(width);
142
+ return () => rightSlotDestroy(index);
143
+ }
144
+ return () => {
145
+ };
146
+ }, [rightSlotMount, rightSlotDestroy, ref]);
147
+ return /* @__PURE__ */ React__default["default"].createElement(StyledRightSlot, {
148
+ ref,
149
+ ...props
150
+ });
151
+ };
152
+
153
+ const HotkeySlot = designSystemStitches.styled(RightSlot, {
154
+ color: "$text-neutrals-subtle"
155
+ });
156
+
72
157
  const itemDefaults = {
73
158
  all: "unset",
74
159
  boxSizing: "border-box",
@@ -78,18 +163,16 @@ const itemDefaults = {
78
163
  borderRadius: "$50",
79
164
  display: "grid",
80
165
  gridTemplateColumns: "auto 1fr minmax(auto, var(--right-slot-max-width))",
81
- gridTemplateRows: "1fr auto",
166
+ gridTemplateRows: "auto 1fr",
82
167
  gridTemplateAreas: `'left-slot item-text right-slot'
83
168
  'left-slot item-description right-slot'`,
84
169
  alignItems: "start",
85
- minHeight: "$10",
86
- padding: "$100 $100",
170
+ padding: "10px $100",
87
171
  position: "relative",
88
172
  userSelect: "none",
89
173
  cursor: "pointer",
90
174
  "&[data-no-left-slot]": {
91
175
  gridTemplateColumns: "1fr minmax(auto, var(--right-slot-max-width))",
92
- gridTemplateRows: "auto",
93
176
  gridTemplateAreas: `'item-text right-slot'
94
177
  'item-description right-slot'`
95
178
  },
@@ -99,24 +182,30 @@ const itemDefaults = {
99
182
  "&:not(:first-child)": {
100
183
  marginTop: "$50"
101
184
  },
102
- ...designSystemStyles.focus.defaults,
185
+ ...designSystemStyles.focus.css({
186
+ boxShadow: "$focus-small",
187
+ outline: "1px solid transparent"
188
+ }),
103
189
  '&:disabled, &[aria-disabled="true"], &[data-disabled]': {
104
- pointerEvents: "none",
105
- [`&, & ${ItemDescription}`]: {
190
+ cursor: "default",
191
+ [`&, & ${ItemDescription}, & ${HotkeySlot}`]: {
106
192
  color: "$text-neutrals-disabled"
107
193
  },
108
194
  [`& ${StyledIllustrationSlot}`]: {
109
195
  filter: "grayscale(1)"
110
196
  }
111
197
  },
112
- "&:hover": {
198
+ "&:disabled, &[data-disabled]": {
199
+ pointerEvents: "none"
200
+ },
201
+ '&:hover:not([aria-disabled="true"])': {
113
202
  background: "$background-primary-subtle-hover",
114
203
  color: "$text-primary-hover",
115
204
  '&:not([aria-disabled="true"])': {
116
205
  boxShadow: "none"
117
206
  }
118
207
  },
119
- "&:active": {
208
+ '&:active:not([aria-disabled="true"])': {
120
209
  background: "$background-primary-subtle-active",
121
210
  boxShadow: "none",
122
211
  color: "$text-primary-active"
@@ -127,14 +216,16 @@ const itemDefaults = {
127
216
  };
128
217
 
129
218
  const StyledIndicator = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
130
- padding: "4px 6px"
219
+ display: "flex",
220
+ alignItems: "center",
221
+ justifyContent: "center"
131
222
  });
132
223
  const StyledCheckboxItem = designSystemStitches.styled(RadixDropdownMenu__namespace.CheckboxItem, {
133
224
  ...itemDefaults,
134
225
  [`&[data-state="checked"] ${StyledIndicator}`]: {
135
226
  color: "$icon-primary"
136
227
  },
137
- [`&[data-state="checked"]:hover ${StyledIndicator}`]: {
228
+ [`&[data-state="checked"]:hover:not([aria-disabled="true"]) ${StyledIndicator}`]: {
138
229
  color: "$icon-primary-hover"
139
230
  },
140
231
  [`
@@ -145,61 +236,50 @@ const StyledCheckboxItem = designSystemStitches.styled(RadixDropdownMenu__namesp
145
236
  }
146
237
  });
147
238
 
148
- const Context$1 = React.createContext({
149
- rightSlotMount: () => 0,
150
- rightSlotDestroy: () => {
151
- },
152
- containerSpacing: "medium"
153
- });
154
- const ContentProvider = ({
155
- children,
156
- containerSpacing = "medium"
157
- }) => {
158
- const [maxWidth, setMaxWidth] = React.useState(0);
159
- const maxRef = React.useRef(0);
160
- const indexRef = React.useRef(0);
161
- const widthMapRef = React.useRef(/* @__PURE__ */ new Map());
162
- const updateMaxWith = React.useCallback((value) => {
163
- maxRef.current = value;
164
- setMaxWidth(value);
165
- }, []);
166
- const rightSlotMount = React.useCallback(
167
- (width) => {
168
- indexRef.current++;
169
- widthMapRef.current.set(indexRef.current, width);
170
- if (width > maxRef.current) {
171
- updateMaxWith(width);
239
+ const useAriaDisabled = ({
240
+ "aria-disabled": ariaDisabled,
241
+ onKeyDown,
242
+ onSelect,
243
+ onPointerMove,
244
+ onClick
245
+ }, preventDefault = false) => React.useMemo(
246
+ () => ({
247
+ "aria-disabled": designSystemUtils.booleanify(ariaDisabled) ? ariaDisabled : void 0,
248
+ onKeyDown: (e) => {
249
+ if (designSystemUtils.booleanify(ariaDisabled) && e.code !== "ArrowUp" && e.code !== "ArrowDown") {
250
+ e.preventDefault();
251
+ e.stopPropagation();
252
+ return;
172
253
  }
173
- return indexRef.current;
254
+ onKeyDown == null ? void 0 : onKeyDown(e);
174
255
  },
175
- [updateMaxWith]
176
- );
177
- const rightSlotDestroy = React.useCallback(
178
- (index) => {
179
- widthMapRef.current.delete(index);
180
- if (widthMapRef.current.size === 0) {
181
- updateMaxWith(0);
182
- } else {
183
- const maximum = Math.max(...Array.from(widthMapRef.current.values()));
184
- updateMaxWith(maximum);
256
+ onSelect: (e) => {
257
+ if (preventDefault) {
258
+ e.preventDefault();
259
+ }
260
+ if (designSystemUtils.booleanify(ariaDisabled)) {
261
+ e.preventDefault();
262
+ return;
185
263
  }
264
+ onSelect == null ? void 0 : onSelect(e);
186
265
  },
187
- [updateMaxWith]
188
- );
189
- const formattedChildren = designSystemUtils.addPropsToChildren(children, () => true, {
190
- UNSAFE_style: {
191
- "--right-slot-max-width": `${Math.ceil(maxWidth)}px`
192
- }
193
- });
194
- return /* @__PURE__ */ React__default["default"].createElement(Context$1.Provider, {
195
- value: {
196
- rightSlotMount,
197
- rightSlotDestroy,
198
- containerSpacing
266
+ onPointerMove: (e) => {
267
+ if (designSystemUtils.booleanify(ariaDisabled)) {
268
+ e.preventDefault();
269
+ return;
270
+ }
271
+ onPointerMove == null ? void 0 : onPointerMove(e);
272
+ },
273
+ onClick: (e) => {
274
+ if (designSystemUtils.booleanify(ariaDisabled)) {
275
+ e.preventDefault();
276
+ return;
277
+ }
278
+ onClick == null ? void 0 : onClick(e);
199
279
  }
200
- }, formattedChildren);
201
- };
202
- const useContent = () => React.useContext(Context$1);
280
+ }),
281
+ [ariaDisabled, onKeyDown, onSelect, onPointerMove, onClick, preventDefault]
282
+ );
203
283
 
204
284
  const Context = React.createContext({
205
285
  leftSlotMount: () => {
@@ -229,62 +309,6 @@ const ItemProvider = ({
229
309
  };
230
310
  const useItem = () => React.useContext(Context);
231
311
 
232
- const RightSlot = (props) => {
233
- const { rightSlotMount, rightSlotDestroy } = useContent();
234
- const ref = React.useRef(null);
235
- React.useEffect(() => {
236
- if (ref.current !== null) {
237
- const width = ref.current.getBoundingClientRect().width;
238
- const index = rightSlotMount(width);
239
- return () => rightSlotDestroy(index);
240
- }
241
- return () => {
242
- };
243
- }, [rightSlotMount, rightSlotDestroy, ref]);
244
- return /* @__PURE__ */ React__default["default"].createElement(StyledRightSlot, {
245
- ref,
246
- ...props
247
- });
248
- };
249
- const HotkeySlot = designSystemStitches.styled(RightSlot, {
250
- color: "$text-neutrals-subtle"
251
- });
252
- const IllustrationSlot = React__default["default"].forwardRef((props, forwardRef) => {
253
- const { leftSlotMount, leftSlotDestroy } = useItem();
254
- React.useEffect(() => {
255
- leftSlotMount();
256
- return () => leftSlotDestroy();
257
- }, [leftSlotMount, leftSlotDestroy]);
258
- return /* @__PURE__ */ React__default["default"].createElement(StyledIllustrationSlot, {
259
- ref: forwardRef,
260
- ...props
261
- });
262
- });
263
-
264
- const useAriaDisabled = ({ "aria-disabled": ariaDisabled, onKeyDown, onSelect }, preventDefault = false) => React.useMemo(
265
- () => ({
266
- "aria-disabled": designSystemUtils.booleanify(ariaDisabled) ? ariaDisabled : void 0,
267
- onKeyDown: (e) => {
268
- if (designSystemUtils.booleanify(ariaDisabled) && e.code !== "ArrowUp" && e.code !== "ArrowDown") {
269
- e.preventDefault();
270
- e.stopPropagation();
271
- return;
272
- }
273
- onKeyDown == null ? void 0 : onKeyDown(e);
274
- },
275
- onSelect: (e) => {
276
- if (preventDefault) {
277
- e.preventDefault();
278
- }
279
- if (designSystemUtils.booleanify(ariaDisabled)) {
280
- return;
281
- }
282
- onSelect == null ? void 0 : onSelect(e);
283
- }
284
- }),
285
- [ariaDisabled, onKeyDown, onSelect, preventDefault]
286
- );
287
-
288
312
  const CheckboxItem = React__default["default"].forwardRef(({ children, checked, onChange, disabled, ...restProps }, forwardRef) => {
289
313
  const ariaDisabledProps = useAriaDisabled(restProps, true);
290
314
  const { "aria-disabled": ariaDisabled } = ariaDisabledProps;
@@ -296,6 +320,7 @@ const CheckboxItem = React__default["default"].forwardRef(({ children, checked,
296
320
  disabled,
297
321
  onCheckedChange: onChange
298
322
  }, 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, {
323
+ weight: "thin",
299
324
  css: { square: "$3", display: "block" }
300
325
  }), checked && /* @__PURE__ */ React__default["default"].createElement(designSystemIcons.IconCheckMark, {
301
326
  css: { square: "$3", display: "block" }
@@ -485,7 +510,7 @@ const RadioGroup = React__default["default"].forwardRef((props, forwardRef) => {
485
510
  });
486
511
  });
487
512
 
488
- const StyledRadioContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
513
+ const StyledRadioContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
489
514
  display: "flex",
490
515
  alignItems: "center",
491
516
  justifyContent: "center",
@@ -493,10 +518,9 @@ const StyledRadioContainer = designSystemStitches.styled(designSystemPrimitive.P
493
518
  height: "$4",
494
519
  boxSizing: "border-box",
495
520
  border: "1px solid $border-neutrals",
496
- borderRadius: "$half",
497
- margin: "2px 4px"
521
+ borderRadius: "$half"
498
522
  });
499
- const StyledPill = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
523
+ const StyledPill = designSystemStitches.styled(designSystemPrimitive.Primitive.div, {
500
524
  display: "none",
501
525
  width: "$2",
502
526
  height: "$2",
@@ -516,7 +540,7 @@ const StyledRadioItem = designSystemStitches.styled(RadixDropdownMenu__namespace
516
540
  backgroundColor: "$background-primary-prominent-selected"
517
541
  }
518
542
  },
519
- [`&:hover ${StyledRadioContainer}`]: {
543
+ [`&:hover:not([aria-disabled="true"]) ${StyledRadioContainer}`]: {
520
544
  borderColor: "$border-primary-hover",
521
545
  [`& ${StyledPill}`]: {
522
546
  backgroundColor: "$background-primary-prominent-hover"
@@ -549,7 +573,9 @@ const RadioItem = React__default["default"].forwardRef(({ disabled = false, chil
549
573
  ...ariaDisabledProps,
550
574
  disabled,
551
575
  ref: forwardRef
552
- }, 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)))));
576
+ }, 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, {
577
+ weight: "thin"
578
+ })))));
553
579
  });
554
580
 
555
581
  const StyledSeparator = designSystemStitches.styled(RadixDropdownMenu__namespace.Separator, {
@@ -564,14 +590,13 @@ const Separator = React__default["default"].forwardRef((props, forwardRef) => /*
564
590
  const StyledSwitch = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
565
591
  ...designSystemBaseSwitch.styles.default,
566
592
  width: "$7",
567
- height: "$4",
568
- marginTop: "2px"
593
+ height: "$4"
569
594
  });
570
595
  const StyledSwitchItem = designSystemStitches.styled(RadixDropdownMenu__namespace.CheckboxItem, {
571
596
  ...itemDefaults,
572
597
  [`&[data-state="checked"] ${StyledSwitch}`]: designSystemBaseSwitch.styles.checked,
573
- [`&[data-state="checked"]:hover ${StyledSwitch}`]: designSystemBaseSwitch.styles.checkedHovered,
574
- [`&:hover ${StyledSwitch}`]: designSystemBaseSwitch.styles.hovered,
598
+ [`&[data-state="checked"]:hover:not([aria-disabled="true"]) ${StyledSwitch}`]: designSystemBaseSwitch.styles.checkedHovered,
599
+ [`&:hover:not([aria-disabled="true"]) ${StyledSwitch}`]: designSystemBaseSwitch.styles.hovered,
575
600
  [`
576
601
  &[aria-disabled="true"] ${StyledSwitch},
577
602
  &[data-disabled] ${StyledSwitch}
@@ -599,7 +624,10 @@ const StyledTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.T
599
624
  all: "unset",
600
625
  boxSizing: "border-box",
601
626
  cursor: "pointer",
602
- ...designSystemStyles.focus.defaults
627
+ ...designSystemStyles.focus.css({
628
+ boxShadow: "$focus-small",
629
+ outline: "1px solid transparent"
630
+ })
603
631
  },
604
632
  false: {
605
633
  cursor: "pointer"
@@ -618,12 +646,13 @@ const Trigger = React__default["default"].forwardRef(({ asChild = false, onPress
618
646
 
619
647
  const StyledIconContainer = designSystemStitches.styled(designSystemPrimitive.Primitive.span, {
620
648
  color: "$icon-neutrals-with-text",
621
- marginRight: "-4px"
649
+ display: "flex",
650
+ alignItems: "center"
622
651
  });
623
652
  const StyledSubTrigger = designSystemStitches.styled(RadixDropdownMenu__namespace.SubTrigger, {
624
653
  ...itemDefaults,
625
- '&[data-state="open"]': itemDefaults["&:hover"],
626
- [`&[data-state="open"] ${StyledIconContainer}, &:hover ${StyledIconContainer}`]: {
654
+ '&[data-state="open"]': itemDefaults['&:hover:not([aria-disabled="true"])'],
655
+ [`&[data-state="open"] ${StyledIconContainer}, &:hover:not([aria-disabled="true"]) ${StyledIconContainer}`]: {
627
656
  color: "$icon-primary-hover"
628
657
  }
629
658
  });
@@ -707,34 +736,47 @@ const Portal = (props) => /* @__PURE__ */ React__default["default"].createElemen
707
736
  });
708
737
 
709
738
  const StyledIconSlot = designSystemStitches.styled(LeftSlot, {
710
- paddingTop: "2px",
711
- variants: {
712
- customIcon: {
713
- true: {
714
- square: "$icon-200"
715
- }
716
- }
739
+ square: "$5",
740
+ "& svg:not([data-icon-component]), & img:not([data-icon-component])": {
741
+ ...designSystemBaseIcon.styles.size.small,
742
+ ...designSystemBaseIcon.styles.weight.thin
717
743
  }
718
744
  });
719
745
 
720
746
  const IconSlot = React__default["default"].forwardRef(({ children, ...restProps }, forwardRef) => {
721
747
  const { leftSlotMount, leftSlotDestroy } = useItem();
722
- const child = React__default["default"].Children.only(children);
723
- const isIcon = designSystemBaseIcon.isIconComponent(child);
724
- const formattedChild = isIcon ? React__default["default"].cloneElement(child, {
725
- ...child.props,
726
- size: "small",
727
- weight: "thin"
728
- }) : child;
748
+ const formattedChildren = designSystemUtils.addPropsToChildren(
749
+ children,
750
+ designSystemBaseIcon.isIconComponent,
751
+ {
752
+ "data-icon-component": "",
753
+ size: "small",
754
+ weight: "thin"
755
+ }
756
+ );
729
757
  React.useEffect(() => {
730
758
  leftSlotMount();
731
759
  return () => leftSlotDestroy();
732
760
  }, [leftSlotMount, leftSlotDestroy]);
733
761
  return /* @__PURE__ */ React__default["default"].createElement(StyledIconSlot, {
734
762
  ref: forwardRef,
735
- ...restProps,
736
- customIcon: !isIcon
737
- }, formattedChild);
763
+ ...restProps
764
+ }, /* @__PURE__ */ React__default["default"].createElement(designSystemPrimitive.Primitive.svg, {
765
+ asChild: true,
766
+ "aria-hidden": true
767
+ }, formattedChildren));
768
+ });
769
+
770
+ const IllustrationSlot = React__default["default"].forwardRef((props, forwardRef) => {
771
+ const { leftSlotMount, leftSlotDestroy } = useItem();
772
+ React.useEffect(() => {
773
+ leftSlotMount();
774
+ return () => leftSlotDestroy();
775
+ }, [leftSlotMount, leftSlotDestroy]);
776
+ return /* @__PURE__ */ React__default["default"].createElement(StyledIllustrationSlot, {
777
+ ref: forwardRef,
778
+ ...props
779
+ });
738
780
  });
739
781
 
740
782
  const DropdownMenu = ({