@doist/reactist 22.0.0-beta → 22.0.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.
Files changed (42) hide show
  1. package/dist/reactist.cjs.development.js +60 -517
  2. package/dist/reactist.cjs.development.js.map +1 -1
  3. package/dist/reactist.cjs.production.min.js +1 -1
  4. package/dist/reactist.cjs.production.min.js.map +1 -1
  5. package/es/index.js +1 -2
  6. package/es/index.js.map +1 -1
  7. package/es/menu/menu.js +56 -301
  8. package/es/menu/menu.js.map +1 -1
  9. package/es/text-area/text-area.module.css.js +1 -1
  10. package/es/toast/use-toasts.js +5 -3
  11. package/es/toast/use-toasts.js.map +1 -1
  12. package/lib/index.d.ts +0 -1
  13. package/lib/index.js +1 -1
  14. package/lib/menu/index.d.ts +2 -1
  15. package/lib/menu/menu.d.ts +23 -163
  16. package/lib/menu/menu.js +1 -1
  17. package/lib/menu/menu.js.map +1 -1
  18. package/lib/text-area/text-area.module.css.js +1 -1
  19. package/lib/toast/use-toasts.d.ts +5 -1
  20. package/lib/toast/use-toasts.js +1 -1
  21. package/lib/toast/use-toasts.js.map +1 -1
  22. package/package.json +1 -2
  23. package/styles/menu.css +1 -8
  24. package/styles/reactist.css +4 -5
  25. package/styles/text-area.css +1 -1
  26. package/styles/text-area.module.css.css +1 -1
  27. package/es/deprecated-modal/modal.js +0 -219
  28. package/es/deprecated-modal/modal.js.map +0 -1
  29. package/es/deprecated-modal/modal.module.css.js +0 -4
  30. package/es/deprecated-modal/modal.module.css.js.map +0 -1
  31. package/es/menu/menu.module.css.js +0 -4
  32. package/es/menu/menu.module.css.js.map +0 -1
  33. package/lib/deprecated-modal/index.d.ts +0 -1
  34. package/lib/deprecated-modal/modal.d.ts +0 -157
  35. package/lib/deprecated-modal/modal.js +0 -2
  36. package/lib/deprecated-modal/modal.js.map +0 -1
  37. package/lib/deprecated-modal/modal.module.css.js +0 -2
  38. package/lib/deprecated-modal/modal.module.css.js.map +0 -1
  39. package/lib/deprecated-modal/modal.test.d.ts +0 -1
  40. package/lib/menu/menu.module.css.js +0 -2
  41. package/lib/menu/menu.module.css.js.map +0 -1
  42. package/styles/menu.module.css.css +0 -1
package/es/index.js CHANGED
@@ -28,7 +28,7 @@ export { Avatar } from './avatar/avatar.js';
28
28
  export { Badge } from './badge/badge.js';
29
29
  export { Modal, ModalActions, ModalBody, ModalCloseButton, ModalFooter, ModalHeader } from './modal/modal.js';
30
30
  export { Tab, TabAwareSlot, TabList, TabPanel, Tabs } from './tabs/tabs.js';
31
- export { ContextMenuTrigger, IconMenuItem, IconsMenuGroup, Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu, SubMenuItem, SubMenuList } from './menu/menu.js';
31
+ export { ContextMenuTrigger, Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu } from './menu/menu.js';
32
32
  export { default as DeprecatedButton } from './components/deprecated-button/index.js';
33
33
  export { default as DeprecatedDropdown } from './components/deprecated-dropdown/index.js';
34
34
  export { COLORS } from './components/color-picker/color-picker.js';
@@ -40,5 +40,4 @@ export { default as ProgressBar } from './components/progress-bar/index.js';
40
40
  export { default as Time } from './components/time/index.js';
41
41
  export { default as DeprecatedInput } from './components/deprecated-input/index.js';
42
42
  export { default as DeprecatedSelect } from './components/deprecated-select/index.js';
43
- export { DeprecatedModal, DeprecatedModalActions, DeprecatedModalBody, DeprecatedModalCloseButton, DeprecatedModalFooter, DeprecatedModalHeader } from './deprecated-modal/modal.js';
44
43
  //# sourceMappingURL=index.js.map
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/es/menu/menu.js CHANGED
@@ -1,25 +1,16 @@
1
1
  import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import { forwardRef, useState, useMemo, useEffect, useImperativeHandle, useCallback, createElement, useContext, Children, cloneElement, createContext } from 'react';
2
+ import { useState, useMemo, useEffect, useCallback, createElement, useContext, forwardRef, Children, cloneElement, createContext } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { polymorphicComponent } from '../utils/polymorphism.js';
5
- import { Box } from '../box/box.js';
6
- import { Tooltip } from '../tooltip/tooltip.js';
7
- import { useId } from '../utils/common-helpers.js';
8
- import { Text } from '../text/text.js';
9
5
  import { Portal } from 'ariakit/portal';
10
6
  import { useMenuState, MenuButton as MenuButton$1, Menu as Menu$1, MenuItem as MenuItem$1, MenuGroup as MenuGroup$1 } from 'ariakit/menu';
11
- import styles from './menu.module.css.js';
12
7
 
13
8
  const _excluded = ["children", "onItemSelect"],
14
9
  _excluded2 = ["exceptionallySetClassName"],
15
- _excluded3 = ["exceptionallySetClassName", "label", "icon"],
16
- _excluded4 = ["as"],
17
- _excluded5 = ["exceptionallySetClassName", "modal"],
18
- _excluded6 = ["exceptionallySetClassName", "modal"],
19
- _excluded7 = ["value", "label", "description", "icon", "shortcut", "tone", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
20
- _excluded8 = ["label", "info", "children", "exceptionallySetClassName"],
21
- _excluded9 = ["value", "label", "description", "icon", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
22
- _excluded10 = ["children"];
10
+ _excluded3 = ["as"],
11
+ _excluded4 = ["exceptionallySetClassName", "modal"],
12
+ _excluded5 = ["value", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
13
+ _excluded6 = ["label", "children", "exceptionallySetClassName"];
23
14
  const MenuContext = /*#__PURE__*/createContext( // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn
24
15
  // (it is normally obtained by calling useMenuState but we can't call hooks outside components).
25
16
  // This is however of little consequence since this value is only used if some of the components
@@ -31,7 +22,7 @@ const MenuContext = /*#__PURE__*/createContext( // Ariakit gives us no means to
31
22
  * management for the menu components inside it.
32
23
  */
33
24
 
34
- const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, ref) {
25
+ function Menu(_ref) {
35
26
  let {
36
27
  children,
37
28
  onItemSelect
@@ -51,9 +42,6 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, ref) {
51
42
  useEffect(() => {
52
43
  if (!state.open) handleAnchorRectChange(null);
53
44
  }, [state.open]);
54
- useImperativeHandle(ref, () => ({
55
- open: state.show
56
- }));
57
45
  const handleItemSelect = useCallback(function handleItemSelect(value) {
58
46
  if (onItemSelect) onItemSelect(value);
59
47
  }, [onItemSelect]);
@@ -65,11 +53,12 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, ref) {
65
53
  return /*#__PURE__*/createElement(MenuContext.Provider, {
66
54
  value: value
67
55
  }, children);
68
- });
56
+ }
69
57
  /**
70
58
  * A button to toggle a dropdown menu open or closed.
71
59
  */
72
60
 
61
+
73
62
  const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2, ref) {
74
63
  let {
75
64
  exceptionallySetClassName
@@ -82,104 +71,17 @@ const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2,
82
71
  return /*#__PURE__*/createElement(MenuButton$1, _objectSpread2(_objectSpread2({}, props), {}, {
83
72
  state: state,
84
73
  ref: ref,
85
- className: exceptionallySetClassName
86
- }));
87
- });
88
- /**
89
- * Renders the content inside a standard MenuItem. It is extracted into a component for reuse in
90
- * the SubMenuItem, which is a MenuItem visually, but semantically it's closer to be a MenuButton.
91
- * @private
92
- */
93
-
94
- function MenuItemContent({
95
- label,
96
- description,
97
- icon,
98
- shortcut,
99
- id
100
- }) {
101
- if (!label) return null;
102
- return /*#__PURE__*/createElement(Box, {
103
- display: "flex",
104
- gap: "small",
105
- alignItems: "center",
106
- width: "full",
107
- "aria-hidden": true
108
- }, icon ? /*#__PURE__*/createElement("div", {
109
- className: styles.menuItemIcon
110
- }, icon) : null, /*#__PURE__*/createElement(Box, {
111
- display: "inlineFlex",
112
- flexDirection: "column",
113
- gap: "xsmall",
114
- paddingY: "xsmall",
115
- alignItems: "flexStart",
116
- overflow: "hidden",
117
- flexGrow: 1
118
- }, /*#__PURE__*/createElement(Text, {
119
- id: id + "-label",
120
- weight: description ? 'semibold' : 'regular',
121
- size: "copy",
122
- lineClamp: 1,
123
- exceptionallySetClassName: styles.menuItemLabel
124
- }, label), description ? /*#__PURE__*/createElement(Text, {
125
- id: id + "-description",
126
- size: "copy",
127
- tone: "secondary",
128
- exceptionallySetClassName: styles.menuItemDescription
129
- }, description) : null), shortcut ? /*#__PURE__*/createElement("div", null, shortcut) : null);
130
- } //
131
- // SubMenuItem
132
- //
133
-
134
-
135
- function ArrowRightIcon() {
136
- return /*#__PURE__*/createElement("svg", {
137
- width: "24",
138
- height: "24"
139
- }, /*#__PURE__*/createElement("path", {
140
- d: "M14.243 12L9.646 7.404a.5.5 0 1 1 .708-.707l4.95 4.95a.5.5 0 0 1 0 .707l-4.95 4.95a.5.5 0 0 1-.708-.708L14.243 12z",
141
- fill: "currentColor",
142
- fillRule: "evenodd"
143
- }));
144
- }
145
- /**
146
- * A menu item to toggle a sub-menu open or closed.
147
- */
148
-
149
-
150
- const SubMenuItem = /*#__PURE__*/polymorphicComponent(function SubMenuItem(_ref3, ref) {
151
- let {
152
- exceptionallySetClassName,
153
- label,
154
- icon
155
- } = _ref3,
156
- props = _objectWithoutProperties(_ref3, _excluded3);
157
-
158
- const id = useId(props.id);
159
- const {
160
- state
161
- } = useContext(MenuContext);
162
- return /*#__PURE__*/createElement(MenuButton$1, _objectSpread2(_objectSpread2({
163
- "aria-labelledby": label && !props['aria-label'] ? id + "-label" : undefined
164
- }, props), {}, {
165
- state: state,
166
- ref: ref,
167
- className: classNames(styles.menuItem, exceptionallySetClassName)
168
- }), /*#__PURE__*/createElement(MenuItemContent, {
169
- id: id,
170
- icon: icon,
171
- label: label,
172
- shortcut: /*#__PURE__*/createElement(ArrowRightIcon, null)
74
+ className: classNames('reactist_menubutton', exceptionallySetClassName)
173
75
  }));
174
76
  }); //
175
77
  // ContextMenuTrigger
176
78
  //
177
79
 
178
- const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(_ref4, ref) {
80
+ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(_ref3, ref) {
179
81
  let {
180
82
  as: component = 'div'
181
- } = _ref4,
182
- props = _objectWithoutProperties(_ref4, _excluded4);
83
+ } = _ref3,
84
+ props = _objectWithoutProperties(_ref3, _excluded3);
183
85
 
184
86
  const {
185
87
  handleAnchorRectChange,
@@ -202,59 +104,42 @@ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMen
202
104
  * The dropdown menu itself, containing a list of menu items.
203
105
  */
204
106
 
205
- const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref5, ref) {
107
+ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref) {
206
108
  let {
207
109
  exceptionallySetClassName,
208
110
  modal = true
209
- } = _ref5,
210
- props = _objectWithoutProperties(_ref5, _excluded5);
111
+ } = _ref4,
112
+ props = _objectWithoutProperties(_ref4, _excluded4);
211
113
 
212
114
  const {
213
115
  state
214
116
  } = useContext(MenuContext);
215
- if (!state.open) return null;
216
- return /*#__PURE__*/createElement(Portal, {
117
+ return state.open ? /*#__PURE__*/createElement(Portal, {
217
118
  preserveTabOrder: true
218
119
  }, /*#__PURE__*/createElement(Menu$1, _objectSpread2(_objectSpread2({}, props), {}, {
219
120
  state: state,
220
121
  ref: ref,
221
- className: classNames(styles.menuList, exceptionallySetClassName),
122
+ className: classNames('reactist_menulist', exceptionallySetClassName),
222
123
  modal: modal
223
- })));
124
+ }))) : null;
224
125
  });
225
126
  /**
226
- * Mostly equivalent to the `MenuList`, but to be used inside a `SubMenu`.
127
+ * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
128
+ * callback.
227
129
  */
228
130
 
229
- const SubMenuList = /*#__PURE__*/polymorphicComponent(function SubMenuList(_ref6, ref) {
131
+ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref) {
230
132
  let {
133
+ value,
134
+ children,
135
+ onSelect,
136
+ hideOnSelect = true,
137
+ onClick,
231
138
  exceptionallySetClassName,
232
- modal = true
233
- } = _ref6,
234
- props = _objectWithoutProperties(_ref6, _excluded6);
235
-
236
- const {
237
- state
238
- } = useContext(MenuContext);
239
- if (!state.open) return null;
240
- return /*#__PURE__*/createElement(Portal, {
241
- preserveTabOrder: true
242
- }, /*#__PURE__*/createElement(Menu$1, _objectSpread2(_objectSpread2({}, props), {}, {
243
- state: state,
244
- ref: ref,
245
- className: classNames(styles.menuList, styles.subMenuList, exceptionallySetClassName),
246
- modal: modal
247
- })));
248
- }); //
249
- // MenuItem
250
- //
139
+ as = 'button'
140
+ } = _ref5,
141
+ props = _objectWithoutProperties(_ref5, _excluded5);
251
142
 
252
- function useMenuItemClickHandler({
253
- value,
254
- hideOnSelect,
255
- onClick,
256
- onSelect
257
- }) {
258
143
  const {
259
144
  handleItemSelect,
260
145
  state
@@ -262,95 +147,42 @@ function useMenuItemClickHandler({
262
147
  const {
263
148
  hide
264
149
  } = state;
265
- return useCallback(function handleClick(event) {
150
+ const handleClick = useCallback(function handleClick(event) {
266
151
  onClick == null ? void 0 : onClick(event);
267
152
  const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
268
153
  const shouldClose = onSelectResult !== false && hideOnSelect;
269
154
  handleItemSelect(value);
270
155
  if (shouldClose) hide();
271
156
  }, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
272
- }
273
- /**
274
- * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
275
- * callback.
276
- */
277
-
278
-
279
- const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref7, ref) {
280
- let {
281
- value,
282
- label,
283
- description,
284
- icon,
285
- shortcut,
286
- tone,
287
- children,
288
- onSelect,
289
- hideOnSelect = true,
290
- onClick,
291
- exceptionallySetClassName,
292
- as = 'button'
293
- } = _ref7,
294
- props = _objectWithoutProperties(_ref7, _excluded7);
295
-
296
- const id = useId(props.id);
297
- const {
298
- state
299
- } = useContext(MenuContext);
300
- const handleClick = useMenuItemClickHandler({
301
- value,
302
- onSelect,
303
- onClick,
304
- hideOnSelect
305
- });
306
- return /*#__PURE__*/createElement(MenuItem$1, _objectSpread2(_objectSpread2({
307
- "aria-labelledby": label && !props['aria-label'] ? id + "-label" : undefined,
308
- "aria-describedby": label && description ? id + "-description" : undefined
309
- }, props), {}, {
157
+ return /*#__PURE__*/createElement(MenuItem$1, _objectSpread2(_objectSpread2({}, props), {}, {
310
158
  as: as,
311
159
  state: state,
312
160
  ref: ref,
313
161
  onClick: handleClick,
314
- className: classNames(styles.menuItem, tone === 'destructive' ? styles.destructive : null, exceptionallySetClassName),
162
+ className: exceptionallySetClassName,
315
163
  hideOnClick: false
316
- }), children ? /*#__PURE__*/createElement(Box, {
317
- width: "full",
318
- className: label ? undefined : styles.legacyLayout
319
- }, children) : null, /*#__PURE__*/createElement(MenuItemContent, {
320
- id: id,
321
- icon: icon,
322
- label: label,
323
- description: description,
324
- shortcut: shortcut
325
- }));
164
+ }), children);
326
165
  });
327
166
  /**
328
- * This component can be rendered alongside other `MenuItem` elements inside a `MenuList` to show a
329
- * sub-menu.
330
- *
331
- * Its children are expected to be exactly two elements, in the following order:
332
- *
333
- * 1. A `SubMenuItem` element: the menu item that triggers the sub-menu to open.
334
- * 2. A `SubMenuList` element: the list of menu items that will be shown when the sub-menu is open.
167
+ * This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have
168
+ * a sub-menu.
335
169
  *
336
- * ## Usage
170
+ * Its children are expected to have the structure of a first level menu (a `MenuButton` and a
171
+ * `MenuList`).
337
172
  *
338
173
  * ```jsx
339
- * <Menu>
340
- * <MenuButton>Menu</MenuButton>
174
+ * <MenuItem label="Edit profile" />
175
+ * <SubMenu>
176
+ * <MenuButton>More options</MenuButton>
341
177
  * <MenuList>
342
- * <MenuItem label="Item 1" />
343
- * <MenuItem label="Item 2" />
344
- * <SubMenu>
345
- * <SubMenuItem label="Submenu" />
346
- * <SubMenuList>
347
- * <MenuItem label="Submenu Item 1" />
348
- * <MenuItem label="Submenu Item 2" />
349
- * </SubMenuList>
350
- * </SubMenu>
178
+ * <MenuItem label="Preferences" />
179
+ * <MenuItem label="Sign out" />
351
180
  * </MenuList>
352
- * </Menu>
181
+ * </SubMenu>
353
182
  * ```
183
+ *
184
+ * The `MenuButton` will become a menu item in the current menu items list, and it will lead to
185
+ * opening a sub-menu with the menu items list below it.
354
186
  */
355
187
 
356
188
  const SubMenu = /*#__PURE__*/forwardRef(function SubMenu({
@@ -382,9 +214,7 @@ const SubMenu = /*#__PURE__*/forwardRef(function SubMenu({
382
214
  state: state,
383
215
  ref: ref,
384
216
  hideOnClick: false
385
- }, renderMenuButton), /*#__PURE__*/createElement("div", {
386
- className: styles.subMenuContainer
387
- }, list));
217
+ }, renderMenuButton), list);
388
218
  });
389
219
  /**
390
220
  * A way to semantically group some menu items.
@@ -393,101 +223,26 @@ const SubMenu = /*#__PURE__*/forwardRef(function SubMenu({
393
223
  * before and/or after the group if you so wish.
394
224
  */
395
225
 
396
- const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref8, ref) {
226
+ const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, ref) {
397
227
  let {
398
228
  label,
399
- info,
400
229
  children,
401
230
  exceptionallySetClassName
402
- } = _ref8,
403
- props = _objectWithoutProperties(_ref8, _excluded8);
231
+ } = _ref6,
232
+ props = _objectWithoutProperties(_ref6, _excluded6);
404
233
 
405
- const id = useId(props.id);
406
234
  const {
407
235
  state
408
236
  } = useContext(MenuContext);
409
- return /*#__PURE__*/createElement(MenuGroup$1, _objectSpread2(_objectSpread2({
410
- "aria-labelledby": "menugroup-label-" + id
411
- }, props), {}, {
412
- id: id,
237
+ return /*#__PURE__*/createElement(MenuGroup$1, _objectSpread2(_objectSpread2({}, props), {}, {
413
238
  ref: ref,
414
239
  state: state,
415
240
  className: exceptionallySetClassName
416
- }), /*#__PURE__*/createElement(Box, {
417
- display: "flex",
418
- alignItems: "center",
419
- gap: "small",
420
- className: styles.menuGroupLabel
421
- }, /*#__PURE__*/createElement(Text, {
422
- id: "menugroup-label-" + id,
423
- size: "copy",
424
- weight: "semibold"
425
- }, label), info ? /*#__PURE__*/createElement(Box, {
426
- flexShrink: 0,
427
- display: "flex",
428
- alignItems: "center",
429
- justifyContent: "center",
430
- className: styles.menuGroupInfo
431
- }, info) : null), children);
432
- });
433
- /**
434
- * A menu item that visually only shows as an icon. It must be used inside an `IconsMenuGroup`.
435
- */
436
-
437
- const IconMenuItem = /*#__PURE__*/polymorphicComponent(function IconMenuItem(_ref9, ref) {
438
- let {
439
- value,
440
- label,
441
- description,
442
- icon,
443
- onSelect,
444
- hideOnSelect = true,
445
- onClick,
446
- exceptionallySetClassName,
447
- as = 'button'
448
- } = _ref9,
449
- props = _objectWithoutProperties(_ref9, _excluded9);
450
-
451
- const id = useId(props.id);
452
- const {
453
- state
454
- } = useContext(MenuContext);
455
- const handleClick = useMenuItemClickHandler({
456
- value,
457
- onSelect,
458
- onClick,
459
- hideOnSelect
460
- });
461
- return /*#__PURE__*/createElement(Tooltip, {
462
- content: label
463
- }, /*#__PURE__*/createElement(MenuItem$1, _objectSpread2(_objectSpread2({
464
- "aria-label": label,
465
- "aria-describedby": id + "-description"
466
- }, props), {}, {
467
- as: as,
468
- state: state,
469
- ref: ref,
470
- onClick: handleClick,
471
- className: classNames(styles.iconMenuItem, exceptionallySetClassName),
472
- hideOnClick: false
473
- }), icon));
474
- });
475
- /**
476
- * Semantically equivalent to `MenuGroup`, but meant to group `IconMenuItem`s only.
477
- */
478
-
479
- const IconsMenuGroup = /*#__PURE__*/polymorphicComponent(function IconsMenuGroup(_ref10, ref) {
480
- let {
481
- children
482
- } = _ref10,
483
- props = _objectWithoutProperties(_ref10, _excluded10);
484
-
485
- return /*#__PURE__*/createElement(MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
486
- ref: ref
487
- }), /*#__PURE__*/createElement("div", {
488
- className: styles.iconsMenuGroup
489
- }, children));
241
+ }), label ? /*#__PURE__*/createElement("div", {
242
+ role: "presentation",
243
+ className: "reactist_menugroup__label"
244
+ }, label) : null, children);
490
245
  });
491
246
 
492
- export { ContextMenuTrigger, IconMenuItem, IconsMenuGroup, Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu, SubMenuItem, SubMenuList };
247
+ export { ContextMenuTrigger, Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu };
493
248
  //# sourceMappingURL=menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","sources":["../../src/menu/menu.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport { polymorphicComponent } from '../utils/polymorphism'\n\n//\n// Reactist menu is a thin wrapper around Ariakit's menu components. This may or may not be\n// temporary. Our goal is to make it transparent for the users of Reactist of this implementation\n// detail. We may change in the future the external lib we use, or even implement it all internally,\n// as long as we keep the same outer interface as intact as possible.\n//\n// Around the heavy lifting of the external lib we just add some features to better integrate the\n// menu to Reactist's more opinionated approach (e.g. using our button with its custom variants and\n// other features, easily show keyboard shortcuts in menu items, etc.)\n//\nimport * as Ariakit from 'ariakit/menu'\nimport { Portal } from 'ariakit/portal'\n\nimport { Box } from '../box'\nimport { Text } from '../text'\nimport { useId } from '../utils/common-helpers'\n\nimport styles from './menu.module.css'\nimport { Tooltip } from '../tooltip'\n\ntype NativeProps<E extends HTMLElement> = React.DetailedHTMLProps<React.HTMLAttributes<E>, E>\n\ntype MenuContextState = {\n state: Ariakit.MenuState\n handleItemSelect: (value: string | null | undefined) => void\n handleAnchorRectChange: (value: { x: number; y: number } | null) => void\n}\n\nconst MenuContext = React.createContext<MenuContextState>(\n // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn\n // (it is normally obtained by calling useMenuState but we can't call hooks outside components).\n // This is however of little consequence since this value is only used if some of the components\n // are used outside Menu, something that should not happen and we do not support.\n // @ts-expect-error\n {},\n)\n\n//\n// Menu\n//\n\ntype MenuProps = Omit<Ariakit.MenuStateProps, 'visible'> & {\n /**\n * The `Menu` must contain a `MenuList` that defines the menu options. It must also contain a\n * `MenuButton` that triggers the menu to be opened or closed.\n */\n children: React.ReactNode\n\n /**\n * An optional callback that will be called back whenever a menu item is selected. It receives\n * the `value` of the selected `MenuItem`.\n *\n * If you pass down this callback, it is recommended that you properly memoize it so it does not\n * change on every render.\n */\n onItemSelect?: (value: string | null | undefined) => void\n}\n\ntype MenuHandle = {\n open: () => void\n}\n\n/**\n * Wrapper component to control a menu. It does not render anything, only providing the state\n * management for the menu components inside it.\n */\nconst Menu = React.forwardRef<MenuHandle, MenuProps>(function Menu(\n { children, onItemSelect, ...props },\n ref,\n) {\n const [anchorRect, handleAnchorRectChange] = React.useState<{ x: number; y: number } | null>(\n null,\n )\n const getAnchorRect = React.useMemo(() => {\n return anchorRect ? () => anchorRect : undefined\n }, [anchorRect])\n\n const state = Ariakit.useMenuState({\n focusLoop: true,\n gutter: 8,\n shift: 4,\n getAnchorRect,\n ...props,\n })\n\n React.useEffect(() => {\n if (!state.open) handleAnchorRectChange(null)\n }, [state.open])\n\n React.useImperativeHandle(ref, () => ({ open: state.show }))\n\n const handleItemSelect = React.useCallback(\n function handleItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n },\n [onItemSelect],\n )\n\n const value: MenuContextState = React.useMemo(\n () => ({\n state,\n handleItemSelect,\n handleAnchorRectChange,\n }),\n [state, handleItemSelect],\n )\n\n return <MenuContext.Provider value={value}>{children}</MenuContext.Provider>\n})\n\n//\n// MenuButton\n//\n\ntype MenuButtonProps = Omit<Ariakit.MenuButtonProps, 'state' | 'className' | 'as'>\n\n/**\n * A button to toggle a dropdown menu open or closed.\n */\nconst MenuButton = polymorphicComponent<'button', MenuButtonProps>(function MenuButton(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n return (\n <Ariakit.MenuButton\n {...props}\n state={state}\n ref={ref}\n className={exceptionallySetClassName}\n />\n )\n})\n\n//\n// MenuItemContent\n//\n\ntype MenuItemContentProps = {\n id: string\n\n /**\n * The menu item's label.\n */\n label?: NonNullable<React.ReactNode>\n\n /**\n * The menu item's description, typically used to provide additional information about what the\n * menu item does.\n *\n * When used, it is rendered below the label. The label is also shown more prominently (e.g.\n * using bold text), while the description is rendered using text in secondary tone.\n *\n * Therefore, for the description to be rendered, you must also provide a `label`.\n */\n description?: React.ReactNode\n\n /**\n * An optional icon to render next to the menu item's label.\n *\n * For the icon to be rendered, you must also provide a `label`.\n */\n icon?: React.ReactNode\n\n /**\n * An optional element to render to the right of the menu item's label. It is often used to\n * show a keyboard shortcut for the menu item.\n *\n * For the shortcut to be rendered, you must also provide a `label`.\n */\n shortcut?: React.ReactNode\n}\n\n/**\n * Renders the content inside a standard MenuItem. It is extracted into a component for reuse in\n * the SubMenuItem, which is a MenuItem visually, but semantically it's closer to be a MenuButton.\n * @private\n */\nfunction MenuItemContent({ label, description, icon, shortcut, id }: MenuItemContentProps) {\n if (!label) return null\n return (\n <Box\n display=\"flex\"\n gap=\"small\"\n alignItems=\"center\"\n width=\"full\"\n aria-hidden // the menu item is labelled via aria-labelledby and aria-describedby\n >\n {icon ? <div className={styles.menuItemIcon}>{icon}</div> : null}\n <Box\n display=\"inlineFlex\"\n flexDirection=\"column\"\n gap=\"xsmall\"\n paddingY=\"xsmall\"\n alignItems=\"flexStart\"\n overflow=\"hidden\"\n flexGrow={1}\n >\n <Text\n id={`${id}-label`}\n weight={description ? 'semibold' : 'regular'}\n size=\"copy\"\n lineClamp={1}\n exceptionallySetClassName={styles.menuItemLabel}\n >\n {label}\n </Text>\n {description ? (\n <Text\n id={`${id}-description`}\n size=\"copy\"\n tone=\"secondary\"\n exceptionallySetClassName={styles.menuItemDescription}\n >\n {description}\n </Text>\n ) : null}\n </Box>\n {shortcut ? <div>{shortcut}</div> : null}\n </Box>\n )\n}\n\n//\n// SubMenuItem\n//\n\nfunction ArrowRightIcon() {\n return (\n <svg width=\"24\" height=\"24\">\n <path\n d=\"M14.243 12L9.646 7.404a.5.5 0 1 1 .708-.707l4.95 4.95a.5.5 0 0 1 0 .707l-4.95 4.95a.5.5 0 0 1-.708-.708L14.243 12z\"\n fill=\"currentColor\"\n fillRule=\"evenodd\"\n />\n </svg>\n )\n}\n\ntype SubMenuItemProps = Omit<Ariakit.MenuButtonProps, 'state' | 'className' | 'as' | 'children'> &\n Pick<MenuItemProps, 'label' | 'icon'>\n\n/**\n * A menu item to toggle a sub-menu open or closed.\n */\nconst SubMenuItem = polymorphicComponent<'button', SubMenuItemProps>(function SubMenuItem(\n { exceptionallySetClassName, label, icon, ...props },\n ref,\n) {\n const id = useId(props.id)\n const { state } = React.useContext(MenuContext)\n return (\n <Ariakit.MenuButton\n aria-labelledby={label && !props['aria-label'] ? `${id}-label` : undefined}\n {...props}\n state={state}\n ref={ref}\n className={classNames(styles.menuItem, exceptionallySetClassName)}\n >\n <MenuItemContent id={id} icon={icon} label={label} shortcut={<ArrowRightIcon />} />\n </Ariakit.MenuButton>\n )\n})\n\n//\n// ContextMenuTrigger\n//\nconst ContextMenuTrigger = polymorphicComponent<'div', unknown>(function ContextMenuTrigger(\n { as: component = 'div', ...props },\n ref,\n) {\n const { handleAnchorRectChange, state } = React.useContext(MenuContext)\n const handleContextMenu = React.useCallback(\n (event: React.MouseEvent) => {\n event.preventDefault()\n handleAnchorRectChange({ x: event.clientX, y: event.clientY })\n state.show()\n },\n [handleAnchorRectChange, state],\n )\n\n return React.createElement(component, { ...props, onContextMenu: handleContextMenu, ref })\n})\n\n//\n// MenuList and SubMenuList\n//\n\ntype MenuListProps = Omit<Ariakit.MenuProps, 'state' | 'className'>\n\n/**\n * The dropdown menu itself, containing a list of menu items.\n */\nconst MenuList = polymorphicComponent<'div', MenuListProps>(function MenuList(\n { exceptionallySetClassName, modal = true, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n if (!state.open) return null\n\n return (\n <Portal preserveTabOrder>\n <Ariakit.Menu\n {...props}\n state={state}\n ref={ref}\n className={classNames(styles.menuList, exceptionallySetClassName)}\n modal={modal}\n />\n </Portal>\n )\n})\n\n/**\n * Mostly equivalent to the `MenuList`, but to be used inside a `SubMenu`.\n */\nconst SubMenuList = polymorphicComponent<'div', MenuListProps>(function SubMenuList(\n { exceptionallySetClassName, modal = true, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n if (!state.open) return null\n\n return (\n <Portal preserveTabOrder>\n <Ariakit.Menu\n {...props}\n state={state}\n ref={ref}\n className={classNames(\n styles.menuList,\n styles.subMenuList,\n exceptionallySetClassName,\n )}\n modal={modal}\n />\n </Portal>\n )\n})\n\n//\n// MenuItem\n//\n\nfunction useMenuItemClickHandler({\n value,\n hideOnSelect,\n onClick,\n onSelect,\n}: Pick<MenuItemProps, 'value' | 'hideOnSelect' | 'onClick' | 'onSelect'>) {\n const { handleItemSelect, state } = React.useContext(MenuContext)\n const { hide } = state\n\n return React.useCallback(\n function handleClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event)\n const onSelectResult: unknown =\n onSelect && !event.defaultPrevented ? onSelect() : undefined\n const shouldClose = onSelectResult !== false && hideOnSelect\n handleItemSelect(value)\n if (shouldClose) hide()\n },\n [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value],\n )\n}\n\ntype MenuItemProps = {\n /**\n * An optional value given to this menu item.\n *\n * It is passed on to the parent `Menu`'s `onItemSelect` when you provide that instead of (or\n * alongside) providing individual `onSelect` callbacks to each menu item.\n */\n value?: string\n\n /**\n * The menu item's content.\n *\n * Prefer using `label` instead. In addition to `label`, you can also use `description`, `icon`\n * and `shortcut`, to provide richer content inside the menu item.\n *\n * However, you can still use `children` to provide arbitrary content inside the menu item. You\n * can even combine `children` with the other props to provide a richer menu item. The\n * `children` content will be rendered first, followed by the regular menu item content\n * generated using the `label`, `description`, `icon` and `shortcut` props (if the `label` is\n * present).\n */\n children?: React.ReactNode\n\n /**\n * The menu item's label.\n */\n label?: NonNullable<React.ReactNode>\n\n /**\n * The menu item's description, typically used to provide additional information about what the\n * menu item does.\n *\n * When used, it is rendered below the label. The label is also shown more prominently (e.g.\n * using bold text), while the description is rendered using text in secondary tone.\n *\n * Therefore, for the description to be rendered, you must also provide a `label`.\n */\n description?: React.ReactNode\n\n /**\n * An optional icon to render next to the menu item's label.\n *\n * For the icon to be rendered, you must also provide a `label`.\n */\n icon?: NonNullable<React.ReactNode>\n\n /**\n * An optional element to render to the right of the menu item's label. It is often used to\n * show a keyboard shortcut for the menu item.\n *\n * For the shortcut to be rendered, you must also provide a `label`.\n */\n shortcut?: React.ReactNode\n\n /**\n * The tone to use for the menu item.\n */\n tone?: 'normal' | 'destructive'\n\n /**\n * When `true` the menu item is disabled and won't be selectable or be part of the keyboard\n * navigation across the menu options.\n *\n * @default true\n */\n disabled?: boolean\n\n /**\n * When `true` the menu will close when the menu item is selected, in addition to performing the\n * action that the menu item is set out to do.\n *\n * Set this to `false` to make sure that a given menu item does not auto-closes the menu when\n * selected. This should be the exception and not the norm, as the default is to auto-close.\n *\n * @default true\n */\n hideOnSelect?: boolean\n\n /**\n * The action to perform when the menu item is selected.\n *\n * If you return `false` from this function, the menu will not auto-close when this menu item\n * is selected. Though you should use `hideOnSelect` for this purpose, this allows you to\n * achieve the same effect conditionally and dynamically deciding at run time.\n */\n onSelect?: () => unknown\n\n /**\n * The event handler called when the menu item is clicked.\n *\n * This is similar to `onSelect`, but a bit different. You can certainly use it to trigger the\n * action that the menu item represents. But in general you should prefer `onSelect` for that.\n *\n * The main use for this handler is to get access to the click event. This can be used, for\n * example, to call `event.preventDefault()`, which will effectively prevent the rest of the\n * consequences of the click, including preventing `onSelect` from being called. In particular,\n * this is useful in menu items that are links, and you want the click to not trigger navigation\n * under some circumstances.\n */\n onClick?: (event: React.MouseEvent) => void\n}\n\n/**\n * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`\n * callback.\n */\nconst MenuItem = polymorphicComponent<'button', MenuItemProps>(function MenuItem(\n {\n value,\n label,\n description,\n icon,\n shortcut,\n tone,\n children,\n onSelect,\n hideOnSelect = true,\n onClick,\n exceptionallySetClassName,\n as = 'button',\n ...props\n },\n ref,\n) {\n const id = useId(props.id)\n const { state } = React.useContext(MenuContext)\n const handleClick = useMenuItemClickHandler({ value, onSelect, onClick, hideOnSelect })\n\n return (\n <Ariakit.MenuItem\n aria-labelledby={label && !props['aria-label'] ? `${id}-label` : undefined}\n aria-describedby={label && description ? `${id}-description` : undefined}\n {...props}\n as={as}\n state={state}\n ref={ref}\n onClick={handleClick}\n className={classNames(\n styles.menuItem,\n tone === 'destructive' ? styles.destructive : null,\n exceptionallySetClassName,\n )}\n hideOnClick={false}\n >\n {children ? (\n <Box width=\"full\" className={label ? undefined : styles.legacyLayout}>\n {children}\n </Box>\n ) : null}\n\n <MenuItemContent\n id={id}\n icon={icon}\n label={label}\n description={description}\n shortcut={shortcut}\n />\n </Ariakit.MenuItem>\n )\n})\n\n//\n// SubMenu\n//\n\ntype SubMenuProps = Pick<MenuProps, 'children' | 'onItemSelect'>\n\n/**\n * This component can be rendered alongside other `MenuItem` elements inside a `MenuList` to show a\n * sub-menu.\n *\n * Its children are expected to be exactly two elements, in the following order:\n *\n * 1. A `SubMenuItem` element: the menu item that triggers the sub-menu to open.\n * 2. A `SubMenuList` element: the list of menu items that will be shown when the sub-menu is open.\n *\n * ## Usage\n *\n * ```jsx\n * <Menu>\n * <MenuButton>Menu</MenuButton>\n * <MenuList>\n * <MenuItem label=\"Item 1\" />\n * <MenuItem label=\"Item 2\" />\n * <SubMenu>\n * <SubMenuItem label=\"Submenu\" />\n * <SubMenuList>\n * <MenuItem label=\"Submenu Item 1\" />\n * <MenuItem label=\"Submenu Item 2\" />\n * </SubMenuList>\n * </SubMenu>\n * </MenuList>\n * </Menu>\n * ```\n */\nconst SubMenu = React.forwardRef<HTMLDivElement, SubMenuProps>(function SubMenu(\n { children, onItemSelect },\n ref,\n) {\n const { handleItemSelect: parentMenuItemSelect, state } = React.useContext(MenuContext)\n const { hide: parentMenuHide } = state\n\n const handleSubItemSelect = React.useCallback(\n function handleSubItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n parentMenuItemSelect(value)\n parentMenuHide()\n },\n [parentMenuHide, parentMenuItemSelect, onItemSelect],\n )\n\n const [button, list] = React.Children.toArray(children)\n\n // Ariakit needs to be able to pass props to the MenuButton\n // and combine it with the MenuItem component\n const renderMenuButton = React.useCallback(\n function renderMenuButton(props: MenuButtonProps) {\n return React.cloneElement(button as React.ReactElement, props)\n },\n [button],\n )\n\n return (\n <Menu onItemSelect={handleSubItemSelect}>\n <Ariakit.MenuItem as=\"div\" state={state} ref={ref} hideOnClick={false}>\n {renderMenuButton}\n </Ariakit.MenuItem>\n <div className={styles.subMenuContainer}>{list}</div>\n </Menu>\n )\n})\n\n//\n// MenuGroup\n//\n\ntype MenuGroupProps = Omit<NativeProps<HTMLDivElement>, 'className'> & {\n /**\n * A label to be shown visually and also used to semantically label the group.\n */\n label: NonNullable<React.ReactNode>\n\n /**\n * An optional info element to be shown to the right of the label.\n *\n * This is useful and often used to:\n * - Provide a link to any documentation related to the menu items in the group\n * - Show a keyboard shortcut that triggers the menu items in the group\n *\n * It is strongly recommended that this should be a icon-only element. It is also strongly\n * recommended that, when using it to provide a link, you use the very `IconMenuItem` component\n * to make the link be yet another menu item accessible in the menu via keyboard navigation.\n * Here's an example of how to do that:\n *\n * ```jsx\n * <MenuGroup\n * label=\"A group of related options\"\n * info={\n * <IconMenuItem\n * label=\"Help about this group of options\"\n * icon=\"ℹ️\"\n * as=\"a\"\n * href=\"http://help.example.com\"\n * target=\"_blank\"\n * rel=\"noreferrer noopener\"\n * />\n * }\n * >\n * <MenuItem label=\"First option\" icon={<FirstIcon />} />\n * <MenuItem label=\"Second option\" icon={<SecondIcon />} />\n * </MenuGroup>\n * ```\n */\n info?: React.ReactNode\n}\n\n/**\n * A way to semantically group some menu items.\n *\n * This group does not add any visual separator. You can do that yourself adding `<hr />` elements\n * before and/or after the group if you so wish.\n */\nconst MenuGroup = polymorphicComponent<'div', MenuGroupProps>(function MenuGroup(\n { label, info, children, exceptionallySetClassName, ...props },\n ref,\n) {\n const id = useId(props.id)\n const { state } = React.useContext(MenuContext)\n return (\n <Ariakit.MenuGroup\n aria-labelledby={`menugroup-label-${id}`}\n {...props}\n id={id}\n ref={ref}\n state={state}\n className={exceptionallySetClassName}\n >\n <Box display=\"flex\" alignItems=\"center\" gap=\"small\" className={styles.menuGroupLabel}>\n <Text id={`menugroup-label-${id}`} size=\"copy\" weight=\"semibold\">\n {label}\n </Text>\n {info ? (\n <Box\n flexShrink={0}\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n className={styles.menuGroupInfo}\n >\n {info}\n </Box>\n ) : null}\n </Box>\n {children}\n </Ariakit.MenuGroup>\n )\n})\n\n//\n// IconMenuItem & IconsMenuGroup\n//\n\ntype IconMenuItemProps = Pick<MenuItemProps, 'value' | 'hideOnSelect' | 'onSelect' | 'onClick'> & {\n /**\n * A label for assistive technologies to describe the menu item.\n *\n * When not provided, the `label` is used. But this is useful when you want the tooltip label\n * to be different from the label for assistive technologies.\n */\n 'aria-label'?: string\n\n /**\n * The menu item's label, which is not shown visually on the menu item, but it is used to\n * show a tooltip for the menu item when hovered or focused.\n *\n * It is also used as the semantic label for assistive technologies, unless you provide an\n * `aria-label` as well.\n */\n label: string\n\n /**\n * A description for assistive technologies to describe the menu item.\n */\n description?: React.ReactNode\n\n /**\n * The icon to show on the menu item.\n */\n icon: NonNullable<React.ReactNode>\n}\n\n/**\n * A menu item that visually only shows as an icon. It must be used inside an `IconsMenuGroup`.\n */\nconst IconMenuItem = polymorphicComponent<'button', IconMenuItemProps>(function IconMenuItem(\n {\n value,\n label,\n description,\n icon,\n onSelect,\n hideOnSelect = true,\n onClick,\n exceptionallySetClassName,\n as = 'button',\n ...props\n },\n ref,\n) {\n const id = useId(props.id)\n const { state } = React.useContext(MenuContext)\n const handleClick = useMenuItemClickHandler({ value, onSelect, onClick, hideOnSelect })\n\n return (\n <Tooltip content={label}>\n <Ariakit.MenuItem\n aria-label={label}\n aria-describedby={`${id}-description`}\n {...props}\n as={as}\n state={state}\n ref={ref}\n onClick={handleClick}\n className={classNames(styles.iconMenuItem, exceptionallySetClassName)}\n hideOnClick={false}\n >\n {icon}\n </Ariakit.MenuItem>\n </Tooltip>\n )\n})\n\n/**\n * Semantically equivalent to `MenuGroup`, but meant to group `IconMenuItem`s only.\n */\nconst IconsMenuGroup = polymorphicComponent<'div', MenuGroupProps>(function IconsMenuGroup(\n { children, ...props },\n ref,\n) {\n return (\n <MenuGroup {...props} ref={ref}>\n <div className={styles.iconsMenuGroup}>{children}</div>\n </MenuGroup>\n )\n})\n\nexport {\n ContextMenuTrigger,\n IconMenuItem,\n IconsMenuGroup,\n Menu,\n MenuButton,\n MenuGroup,\n MenuItem,\n MenuList,\n SubMenu,\n SubMenuItem,\n SubMenuList,\n}\n\nexport type {\n IconMenuItemProps,\n MenuButtonProps,\n MenuGroupProps,\n MenuHandle,\n MenuItemProps,\n MenuListProps,\n MenuProps,\n SubMenuItemProps,\n SubMenuProps,\n}\n"],"names":["MenuContext","React","Menu","ref","children","onItemSelect","props","anchorRect","handleAnchorRectChange","getAnchorRect","undefined","state","Ariakit","focusLoop","gutter","shift","open","show","handleItemSelect","value","Provider","MenuButton","polymorphicComponent","exceptionallySetClassName","className","MenuItemContent","label","description","icon","shortcut","id","Box","display","gap","alignItems","width","styles","menuItemIcon","flexDirection","paddingY","overflow","flexGrow","Text","weight","size","lineClamp","menuItemLabel","tone","menuItemDescription","ArrowRightIcon","height","d","fill","fillRule","SubMenuItem","useId","classNames","menuItem","ContextMenuTrigger","as","component","handleContextMenu","event","preventDefault","x","clientX","y","clientY","onContextMenu","MenuList","modal","Portal","preserveTabOrder","menuList","SubMenuList","subMenuList","useMenuItemClickHandler","hideOnSelect","onClick","onSelect","hide","handleClick","onSelectResult","defaultPrevented","shouldClose","MenuItem","destructive","hideOnClick","legacyLayout","SubMenu","parentMenuItemSelect","parentMenuHide","handleSubItemSelect","button","list","toArray","renderMenuButton","subMenuContainer","MenuGroup","info","menuGroupLabel","flexShrink","justifyContent","menuGroupInfo","IconMenuItem","Tooltip","content","iconMenuItem","IconsMenuGroup","iconsMenuGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAMA,WAAW,gBAAGC,aAAA;AAEhB;AACA;AACA;AACA;AACA,EANgB,CAApB;AAkCA;;;;;MAIMC,IAAI,gBAAGD,UAAA,CAAwC,SAASC,IAAT,OAEjDC,GAFiD;MACjD;IAAEC,QAAF;IAAYC;;MAAiBC;;EAG7B,MAAM,CAACC,UAAD,EAAaC,sBAAb,IAAuCP,QAAA,CACzC,IADyC,CAA7C;EAGA,MAAMQ,aAAa,GAAGR,OAAA,CAAc;IAChC,OAAOM,UAAU,GAAG,MAAMA,UAAT,GAAsBG,SAAvC;GADkB,EAEnB,CAACH,UAAD,CAFmB,CAAtB;EAIA,MAAMI,KAAK,GAAGC,YAAA;IACVC,SAAS,EAAE,IADD;IAEVC,MAAM,EAAE,CAFE;IAGVC,KAAK,EAAE,CAHG;IAIVN;KACGH,KALO,EAAd;EAQAL,SAAA,CAAgB;IACZ,IAAI,CAACU,KAAK,CAACK,IAAX,EAAiBR,sBAAsB,CAAC,IAAD,CAAtB;GADrB,EAEG,CAACG,KAAK,CAACK,IAAP,CAFH;EAIAf,mBAAA,CAA0BE,GAA1B,EAA+B,OAAO;IAAEa,IAAI,EAAEL,KAAK,CAACM;GAArB,CAA/B;EAEA,MAAMC,gBAAgB,GAAGjB,WAAA,CACrB,SAASiB,gBAAT,CAA0BC,K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uBAAuB,CAAC;IAAEzD,KAAF;IAAS4D,QAAT;IAAmBD,OAAnB;IAA4BD;GAA7B,CAA3C;EAEA,oBACI5E,aAAA,CAACwG,OAAD;IAASC,OAAO,EAAEhF;GAAlB,eACIzB,aAAA,CAACW,UAAD;kBACgBc,KADhB;wBAEyBI;KACjBxB,KAHR;IAIIqD,EAAE,EAAEA,EAJR;IAKIhD,KAAK,EAAEA,KALX;IAMIR,GAAG,EAAEA,GANT;IAOI2E,OAAO,EAAEG,WAPb;IAQIzD,SAAS,EAAEgC,UAAU,CAACpB,MAAM,CAACuE,YAAR,EAAsBpF,yBAAtB,CARzB;IASIgE,WAAW,EAAE;MAEZ3D,IAXL,CADJ,CADJ;AAiBH,CApCwC;AAsCzC;;;;MAGMgF,cAAc,gBAAGtF,oBAAoB,CAAwB,SAASsF,cAAT,SAE/DzG,GAF+D;MAC/D;IAAEC;;MAAaE;;EAGf,oBACIL,aAAA,CAACiG,SAAD,oCAAe5F,KAAf;IAAsBH,GAAG,EAAEA;mBACvBF,aAAA,MAAA;IAAKuB,SAAS,EAAEY,MAAM,CAACyE;GAAvB,EAAwCzG,QAAxC,CADJ,CADJ;AAKH,CAT0C;;;;"}
1
+ {"version":3,"file":"menu.js","sources":["../../src/menu/menu.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport { polymorphicComponent } from '../utils/polymorphism'\n\n//\n// Reactist menu is a thin wrapper around Ariakit's menu components. This may or may not be\n// temporary. Our goal is to make it transparent for the users of Reactist of this implementation\n// detail. We may change in the future the external lib we use, or even implement it all internally,\n// as long as we keep the same outer interface as intact as possible.\n//\n// Around the heavy lifting of the external lib we just add some features to better integrate the\n// menu to Reactist's more opinionated approach (e.g. using our button with its custom variants and\n// other features, easily show keyboard shortcuts in menu items, etc.)\n//\nimport * as Ariakit from 'ariakit/menu'\nimport { Portal } from 'ariakit/portal'\n\nimport './menu.less'\n\ntype NativeProps<E extends HTMLElement> = React.DetailedHTMLProps<React.HTMLAttributes<E>, E>\n\ntype MenuContextState = {\n state: Ariakit.MenuState\n handleItemSelect: (value: string | null | undefined) => void\n handleAnchorRectChange: (value: { x: number; y: number } | null) => void\n}\n\nconst MenuContext = React.createContext<MenuContextState>(\n // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn\n // (it is normally obtained by calling useMenuState but we can't call hooks outside components).\n // This is however of little consequence since this value is only used if some of the components\n // are used outside Menu, something that should not happen and we do not support.\n // @ts-expect-error\n {},\n)\n\n//\n// Menu\n//\n\ntype MenuProps = Omit<Ariakit.MenuStateProps, 'visible'> & {\n /**\n * The `Menu` must contain a `MenuList` that defines the menu options. It must also contain a\n * `MenuButton` that triggers the menu to be opened or closed.\n */\n children: React.ReactNode\n\n /**\n * An optional callback that will be called back whenever a menu item is selected. It receives\n * the `value` of the selected `MenuItem`.\n *\n * If you pass down this callback, it is recommended that you properly memoize it so it does not\n * change on every render.\n */\n onItemSelect?: (value: string | null | undefined) => void\n}\n\n/**\n * Wrapper component to control a menu. It does not render anything, only providing the state\n * management for the menu components inside it.\n */\nfunction Menu({ children, onItemSelect, ...props }: MenuProps) {\n const [anchorRect, handleAnchorRectChange] = React.useState<{ x: number; y: number } | null>(\n null,\n )\n const getAnchorRect = React.useMemo(() => {\n return anchorRect ? () => anchorRect : undefined\n }, [anchorRect])\n\n const state = Ariakit.useMenuState({\n focusLoop: true,\n gutter: 8,\n shift: 4,\n getAnchorRect,\n ...props,\n })\n\n React.useEffect(() => {\n if (!state.open) handleAnchorRectChange(null)\n }, [state.open])\n\n const handleItemSelect = React.useCallback(\n function handleItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n },\n [onItemSelect],\n )\n\n const value: MenuContextState = React.useMemo(\n () => ({\n state,\n handleItemSelect,\n handleAnchorRectChange,\n }),\n [state, handleItemSelect],\n )\n\n return <MenuContext.Provider value={value}>{children}</MenuContext.Provider>\n}\n\n//\n// MenuButton\n//\n\ntype MenuButtonProps = Omit<Ariakit.MenuButtonProps, 'state' | 'className' | 'as'>\n\n/**\n * A button to toggle a dropdown menu open or closed.\n */\nconst MenuButton = polymorphicComponent<'button', MenuButtonProps>(function MenuButton(\n { exceptionallySetClassName, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n return (\n <Ariakit.MenuButton\n {...props}\n state={state}\n ref={ref}\n className={classNames('reactist_menubutton', exceptionallySetClassName)}\n />\n )\n})\n\n//\n// ContextMenuTrigger\n//\nconst ContextMenuTrigger = polymorphicComponent<'div', unknown>(function ContextMenuTrigger(\n { as: component = 'div', ...props },\n ref,\n) {\n const { handleAnchorRectChange, state } = React.useContext(MenuContext)\n const handleContextMenu = React.useCallback(\n (event: React.MouseEvent) => {\n event.preventDefault()\n handleAnchorRectChange({ x: event.clientX, y: event.clientY })\n state.show()\n },\n [handleAnchorRectChange, state],\n )\n\n return React.createElement(component, { ...props, onContextMenu: handleContextMenu, ref })\n})\n\n//\n// MenuList\n//\n\ntype MenuListProps = Omit<Ariakit.MenuProps, 'state' | 'className'>\n\n/**\n * The dropdown menu itself, containing a list of menu items.\n */\nconst MenuList = polymorphicComponent<'div', MenuListProps>(function MenuList(\n { exceptionallySetClassName, modal = true, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n\n return state.open ? (\n <Portal preserveTabOrder>\n <Ariakit.Menu\n {...props}\n state={state}\n ref={ref}\n className={classNames('reactist_menulist', exceptionallySetClassName)}\n modal={modal}\n />\n </Portal>\n ) : null\n})\n\n//\n// MenuItem\n//\n\ntype MenuItemProps = {\n /**\n * An optional value given to this menu item. It is passed on to the parent `Menu`'s\n * `onItemSelect` when you provide that instead of (or alongside) providing individual\n * `onSelect` callbacks to each menu item.\n */\n value?: string\n /**\n * The content inside the menu item.\n */\n children: React.ReactNode\n /**\n * When `true` the menu item is disabled and won't be selectable or be part of the keyboard\n * navigation across the menu options.\n *\n * @default true\n */\n disabled?: boolean\n /**\n * When `true` the menu will close when the menu item is selected, in addition to performing the\n * action that the menu item is set out to do.\n *\n * Set this to `false` to make sure that a given menu item does not auto-closes the menu when\n * selected. This should be the exception and not the norm, as the default is to auto-close.\n *\n * @default true\n */\n hideOnSelect?: boolean\n /**\n * The action to perform when the menu item is selected.\n *\n * If you return `false` from this function, the menu will not auto-close when this menu item\n * is selected. Though you should use `hideOnSelect` for this purpose, this allows you to\n * achieve the same effect conditionally and dynamically deciding at run time.\n */\n onSelect?: () => unknown\n /**\n * The event handler called when the menu item is clicked.\n *\n * This is similar to `onSelect`, but a bit different. You can certainly use it to trigger the\n * action that the menu item represents. But in general you should prefer `onSelect` for that.\n *\n * The main use for this handler is to get access to the click event. This can be used, for\n * example, to call `event.preventDefault()`, which will effectively prevent the rest of the\n * consequences of the click, including preventing `onSelect` from being called. In particular,\n * this is useful in menu items that are links, and you want the click to not trigger navigation\n * under some circumstances.\n */\n onClick?: (event: React.MouseEvent) => void\n}\n\n/**\n * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`\n * callback.\n */\nconst MenuItem = polymorphicComponent<'button', MenuItemProps>(function MenuItem(\n {\n value,\n children,\n onSelect,\n hideOnSelect = true,\n onClick,\n exceptionallySetClassName,\n as = 'button',\n ...props\n },\n ref,\n) {\n const { handleItemSelect, state } = React.useContext(MenuContext)\n const { hide } = state\n\n const handleClick = React.useCallback(\n function handleClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event)\n const onSelectResult: unknown =\n onSelect && !event.defaultPrevented ? onSelect() : undefined\n const shouldClose = onSelectResult !== false && hideOnSelect\n handleItemSelect(value)\n if (shouldClose) hide()\n },\n [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value],\n )\n\n return (\n <Ariakit.MenuItem\n {...props}\n as={as}\n state={state}\n ref={ref}\n onClick={handleClick}\n className={exceptionallySetClassName}\n hideOnClick={false}\n >\n {children}\n </Ariakit.MenuItem>\n )\n})\n\n//\n// SubMenu\n//\n\ntype SubMenuProps = Pick<MenuProps, 'children' | 'onItemSelect'>\n\n/**\n * This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have\n * a sub-menu.\n *\n * Its children are expected to have the structure of a first level menu (a `MenuButton` and a\n * `MenuList`).\n *\n * ```jsx\n * <MenuItem label=\"Edit profile\" />\n * <SubMenu>\n * <MenuButton>More options</MenuButton>\n * <MenuList>\n * <MenuItem label=\"Preferences\" />\n * <MenuItem label=\"Sign out\" />\n * </MenuList>\n * </SubMenu>\n * ```\n *\n * The `MenuButton` will become a menu item in the current menu items list, and it will lead to\n * opening a sub-menu with the menu items list below it.\n */\nconst SubMenu = React.forwardRef<HTMLDivElement, SubMenuProps>(function SubMenu(\n { children, onItemSelect },\n ref,\n) {\n const { handleItemSelect: parentMenuItemSelect, state } = React.useContext(MenuContext)\n const { hide: parentMenuHide } = state\n\n const handleSubItemSelect = React.useCallback(\n function handleSubItemSelect(value: string | null | undefined) {\n if (onItemSelect) onItemSelect(value)\n parentMenuItemSelect(value)\n parentMenuHide()\n },\n [parentMenuHide, parentMenuItemSelect, onItemSelect],\n )\n\n const [button, list] = React.Children.toArray(children)\n\n // Ariakit needs to be able to pass props to the MenuButton\n // and combine it with the MenuItem component\n const renderMenuButton = React.useCallback(\n function renderMenuButton(props: MenuButtonProps) {\n return React.cloneElement(button as React.ReactElement, props)\n },\n [button],\n )\n\n return (\n <Menu onItemSelect={handleSubItemSelect}>\n <Ariakit.MenuItem as=\"div\" state={state} ref={ref} hideOnClick={false}>\n {renderMenuButton}\n </Ariakit.MenuItem>\n {list}\n </Menu>\n )\n})\n\n//\n// MenuGroup\n//\n\ntype MenuGroupProps = Omit<NativeProps<HTMLDivElement>, 'className'> & {\n /**\n * A label to be shown visually and also used to semantically label the group.\n */\n label: string\n}\n\n/**\n * A way to semantically group some menu items.\n *\n * This group does not add any visual separator. You can do that yourself adding `<hr />` elements\n * before and/or after the group if you so wish.\n */\nconst MenuGroup = polymorphicComponent<'div', MenuGroupProps>(function MenuGroup(\n { label, children, exceptionallySetClassName, ...props },\n ref,\n) {\n const { state } = React.useContext(MenuContext)\n return (\n <Ariakit.MenuGroup {...props} ref={ref} state={state} className={exceptionallySetClassName}>\n {label ? (\n <div role=\"presentation\" className=\"reactist_menugroup__label\">\n {label}\n </div>\n ) : null}\n {children}\n </Ariakit.MenuGroup>\n )\n})\n\nexport { ContextMenuTrigger, Menu, MenuButton, MenuList, MenuItem, SubMenu, MenuGroup }\nexport type { MenuButtonProps, MenuListProps, MenuItemProps, MenuGroupProps }\n"],"names":["MenuContext","React","Menu","children","onItemSelect","props","anchorRect","handleAnchorRectChange","getAnchorRect","undefined","state","Ariakit","focusLoop","gutter","shift","open","handleItemSelect","value","Provider","MenuButton","polymorphicComponent","ref","exceptionallySetClassName","className","classNames","ContextMenuTrigger","as","component","handleContextMenu","event","preventDefault","x","clientX","y","clientY","show","onContextMenu","MenuList","modal","Portal","preserveTabOrder","MenuItem","onSelect","hideOnSelect","onClick","hide","handleClick","onSelectResult","defaultPrevented","shouldClose","hideOnClick","SubMenu","parentMenuItemSelect","parentMenuHide","handleSubItemSelect","button","list","toArray","renderMenuButton","MenuGroup","label","role"],"mappings":";;;;;;;;;;;;;AA4BA,MAAMA,WAAW,gBAAGC,aAAA;AAEhB;AACA;AACA;AACA;AACA,EANgB,CAApB;AA8BA;;;;;AAIA,SAASC,IAAT;MAAc;IAAEC,QAAF;IAAYC;;MAAiBC;;EACvC,MAAM,CAACC,UAAD,EAAaC,sBAAb,IAAuCN,QAAA,CACzC,IADyC,CAA7C;EAGA,MAAMO,aAAa,GAAGP,OAAA,CAAc;IAChC,OAAOK,UAAU,GAAG,MAAMA,UAAT,GAAsBG,SAAvC;GADkB,EAEnB,CAACH,UAAD,CAFmB,CAAtB;EAIA,MAAMI,KAAK,GAAGC,YAAA;IACVC,SAAS,EAAE,IADD;IAEVC,MAAM,EAAE,CAFE;IAGVC,KAAK,EAAE,CAHG;IAIVN;KACGH,KALO,EAAd;EAQAJ,SAAA,CAAgB;IACZ,IAAI,CAACS,KAAK,CAACK,IAAX,EAAiBR,sBAAsB,CAAC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A,oBACItD,aAAA,CAACC,IAAD;IAAME,YAAY,EAAEkD;GAApB,eACIrD,aAAA,CAACU,UAAD;IAAkBe,EAAE,EAAC;IAAMhB,KAAK,EAAEA;IAAOW,GAAG,EAAEA;IAAK6B,WAAW,EAAE;GAAhE,EACKQ,gBADL,CADJ,EAIKF,IAJL,CADJ;AAQH,CAnCe;AAgDhB;;;;;;;MAMMG,SAAS,gBAAGvC,oBAAoB,CAAwB,SAASuC,SAAT,QAE1DtC,GAF0D;MAC1D;IAAEuC,KAAF;IAASzD,QAAT;IAAmBmB;;MAA8BjB;;EAGjD,MAAM;IAAEK;MAAUT,UAAA,CAAiBD,WAAjB,CAAlB;EACA,oBACIC,aAAA,CAACU,WAAD,oCAAuBN,KAAvB;IAA8BgB,GAAG,EAAEA,GAAnC;IAAwCX,KAAK,EAAEA,KAA/C;IAAsDa,SAAS,EAAED;MAC5DsC,KAAK,gBACF3D,aAAA,MAAA;IAAK4D,IAAI,EAAC;IAAetC,SAAS,EAAC;GAAnC,EACKqC,KADL,CADE,GAIF,IALR,EAMKzD,QANL,CADJ;AAUH,CAfqC;;;;"}
@@ -1,4 +1,4 @@
1
- var modules_2728c236 = {"textAreaContainer":"fdc243b3","innerContainer":"_5c1dd8bc","bordered":"_269f9e63","error":"d1e4b585","autoExpand":"_10c6f2ef"};
1
+ var modules_2728c236 = {"textAreaContainer":"_29503131","innerContainer":"_6ea894ce","bordered":"e1e8b6a7","error":"_1b94ff46","autoExpand":"e82223c4"};
2
2
 
3
3
  export default modules_2728c236;
4
4
  //# sourceMappingURL=text-area.module.css.js.map