@doist/reactist 22.0.0-beta → 22.0.1-beta

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 (53) hide show
  1. package/dist/reactist.cjs.development.js +190 -482
  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/checkbox-field/checkbox-field.js +1 -1
  6. package/es/checkbox-field/checkbox-field.js.map +1 -1
  7. package/es/checkbox-field/use-fork-ref.js +35 -0
  8. package/es/checkbox-field/use-fork-ref.js.map +1 -0
  9. package/es/index.js +1 -1
  10. package/es/menu/menu.js +89 -337
  11. package/es/menu/menu.js.map +1 -1
  12. package/es/modal/modal.js +3 -4
  13. package/es/modal/modal.js.map +1 -1
  14. package/es/tabs/tabs.js +40 -47
  15. package/es/tabs/tabs.js.map +1 -1
  16. package/es/toast/use-toasts.js +1 -1
  17. package/es/toast/use-toasts.js.map +1 -1
  18. package/es/tooltip/tooltip.js +20 -62
  19. package/es/tooltip/tooltip.js.map +1 -1
  20. package/lib/checkbox-field/checkbox-field.js +1 -1
  21. package/lib/checkbox-field/checkbox-field.js.map +1 -1
  22. package/lib/checkbox-field/use-fork-ref.d.ts +11 -0
  23. package/lib/checkbox-field/use-fork-ref.js +2 -0
  24. package/lib/checkbox-field/use-fork-ref.js.map +1 -0
  25. package/lib/index.js +1 -1
  26. package/lib/menu/index.d.ts +2 -1
  27. package/lib/menu/menu.d.ts +27 -167
  28. package/lib/menu/menu.js +1 -1
  29. package/lib/menu/menu.js.map +1 -1
  30. package/lib/modal/modal.d.ts +1 -2
  31. package/lib/modal/modal.js +1 -1
  32. package/lib/modal/modal.js.map +1 -1
  33. package/lib/tabs/tabs.d.ts +10 -8
  34. package/lib/tabs/tabs.js +1 -1
  35. package/lib/tabs/tabs.js.map +1 -1
  36. package/lib/toast/use-toasts.js +1 -1
  37. package/lib/toast/use-toasts.js.map +1 -1
  38. package/lib/tooltip/tooltip.d.ts +2 -4
  39. package/lib/tooltip/tooltip.js +1 -1
  40. package/lib/tooltip/tooltip.js.map +1 -1
  41. package/lib/utils/test-helpers.d.ts +13 -2
  42. package/package.json +2 -4
  43. package/styles/menu.css +1 -8
  44. package/styles/reactist.css +2 -2
  45. package/es/hooks/use-previous/use-previous.js +0 -26
  46. package/es/hooks/use-previous/use-previous.js.map +0 -1
  47. package/es/menu/menu.module.css.js +0 -4
  48. package/es/menu/menu.module.css.js.map +0 -1
  49. package/lib/hooks/use-previous/use-previous.js +0 -2
  50. package/lib/hooks/use-previous/use-previous.js.map +0 -1
  51. package/lib/menu/menu.module.css.js +0 -2
  52. package/lib/menu/menu.module.css.js.map +0 -1
  53. package/styles/menu.module.css.css +0 -1
@@ -2,9 +2,9 @@ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _
2
2
  import { forwardRef, useState, useRef, useEffect, createElement } from 'react';
3
3
  import { Box } from '../box/box.js';
4
4
  import { Text } from '../text/text.js';
5
- import { useForkRef } from 'ariakit-react-utils';
6
5
  import { CheckboxIcon } from './checkbox-icon.js';
7
6
  import styles from './checkbox-field.module.css.js';
7
+ import { useForkRef } from './use-fork-ref.js';
8
8
 
9
9
  const _excluded = ["label", "icon", "disabled", "indeterminate", "defaultChecked", "onChange"];
10
10
  const CheckboxField = /*#__PURE__*/forwardRef(function CheckboxField(_ref, ref) {
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-field.js","sources":["../../src/checkbox-field/checkbox-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useForkRef } from 'ariakit-react-utils'\nimport { Box } from '../box'\nimport { Text } from '../text'\nimport { CheckboxIcon } from './checkbox-icon'\n\nimport styles from './checkbox-field.module.css'\n\ntype CheckboxFieldProps = Omit<\n JSX.IntrinsicElements['input'],\n | 'type'\n | 'className'\n | 'disabled'\n | 'aria-controls'\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n> & {\n 'aria-checked'?: never\n /** Identifies the set of checkboxes controlled by the mixed checkbox for assistive technologies. */\n 'aria-controls'?: string\n /** Identifies the element (or elements) that describes the checkbox for assistive technologies. */\n 'aria-describedby'?: string\n /** Defines a string value that labels the current checkbox for assistive technologies. */\n 'aria-label'?: string\n /** Identifies the element (or elements) that labels the current checkbox for assistive technologies. */\n 'aria-labelledby'?: string\n /** Defines whether or not the checkbox is disabled. */\n disabled?: boolean\n /** The label for the checkbox element. */\n label?: React.ReactNode\n /** The icon that should be added to the checkbox label. */\n icon?: React.ReactChild\n /** Defines whether or not the checkbox can be of a `mixed` state. */\n indeterminate?: boolean\n}\n\nconst CheckboxField = React.forwardRef<HTMLInputElement, CheckboxFieldProps>(function CheckboxField(\n { label, icon, disabled, indeterminate, defaultChecked, onChange, ...props },\n ref,\n) {\n const isControlledComponent = typeof props.checked === 'boolean'\n if (typeof indeterminate === 'boolean' && !isControlledComponent) {\n // eslint-disable-next-line no-console\n console.warn('Cannot use indeterminate on an uncontrolled checkbox')\n indeterminate = undefined\n }\n\n if (!label && !props['aria-label'] && !props['aria-labelledby']) {\n // eslint-disable-next-line no-console\n console.warn('A Checkbox needs a label')\n }\n\n const [keyFocused, setKeyFocused] = React.useState(false)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n\n const internalRef = React.useRef<HTMLInputElement>(null)\n const combinedRef = useForkRef(internalRef, ref)\n React.useEffect(\n function setIndeterminate() {\n if (internalRef.current && typeof indeterminate === 'boolean') {\n internalRef.current.indeterminate = indeterminate\n }\n },\n [indeterminate],\n )\n\n return (\n <Box\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n keyFocused ? styles.keyFocused : null,\n ]}\n >\n <input\n {...props}\n ref={combinedRef}\n type=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : isChecked}\n checked={isChecked}\n disabled={disabled}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n onBlur={(event) => {\n setKeyFocused(false)\n props?.onBlur?.(event)\n }}\n onKeyUp={(event) => {\n setKeyFocused(true)\n props?.onKeyUp?.(event)\n }}\n />\n <CheckboxIcon\n checked={isChecked}\n disabled={disabled}\n indeterminate={indeterminate}\n aria-hidden\n />\n {icon ? (\n <Box display=\"flex\" className={styles.icon} aria-hidden>\n {icon}\n </Box>\n ) : null}\n {label ? (\n <Box display=\"flex\" className={styles.label}>\n <Text>{label}</Text>\n </Box>\n ) : null}\n </Box>\n )\n})\n\nexport { CheckboxField }\nexport type { CheckboxFieldProps }\n"],"names":["CheckboxField","React","ref","label","icon","disabled","indeterminate","defaultChecked","onChange","props","isControlledComponent","checked","console","warn","undefined","keyFocused","setKeyFocused","checkedState","setChecked","isChecked","internalRef","combinedRef","useForkRef","setIndeterminate","current","Box","as","display","alignItems","className","styles","container","type","event","defaultPrevented","currentTarget","onBlur","onKeyUp","CheckboxIcon","Text"],"mappings":"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"}
1
+ {"version":3,"file":"checkbox-field.js","sources":["../../src/checkbox-field/checkbox-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Text } from '../text'\nimport { CheckboxIcon } from './checkbox-icon'\n\nimport styles from './checkbox-field.module.css'\nimport { useForkRef } from './use-fork-ref'\n\ntype CheckboxFieldProps = Omit<\n JSX.IntrinsicElements['input'],\n | 'type'\n | 'className'\n | 'disabled'\n | 'aria-controls'\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n> & {\n 'aria-checked'?: never\n /** Identifies the set of checkboxes controlled by the mixed checkbox for assistive technologies. */\n 'aria-controls'?: string\n /** Identifies the element (or elements) that describes the checkbox for assistive technologies. */\n 'aria-describedby'?: string\n /** Defines a string value that labels the current checkbox for assistive technologies. */\n 'aria-label'?: string\n /** Identifies the element (or elements) that labels the current checkbox for assistive technologies. */\n 'aria-labelledby'?: string\n /** Defines whether or not the checkbox is disabled. */\n disabled?: boolean\n /** The label for the checkbox element. */\n label?: React.ReactNode\n /** The icon that should be added to the checkbox label. */\n icon?: React.ReactChild\n /** Defines whether or not the checkbox can be of a `mixed` state. */\n indeterminate?: boolean\n}\n\nconst CheckboxField = React.forwardRef<HTMLInputElement, CheckboxFieldProps>(function CheckboxField(\n { label, icon, disabled, indeterminate, defaultChecked, onChange, ...props },\n ref,\n) {\n const isControlledComponent = typeof props.checked === 'boolean'\n if (typeof indeterminate === 'boolean' && !isControlledComponent) {\n // eslint-disable-next-line no-console\n console.warn('Cannot use indeterminate on an uncontrolled checkbox')\n indeterminate = undefined\n }\n\n if (!label && !props['aria-label'] && !props['aria-labelledby']) {\n // eslint-disable-next-line no-console\n console.warn('A Checkbox needs a label')\n }\n\n const [keyFocused, setKeyFocused] = React.useState(false)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n\n const internalRef = React.useRef<HTMLInputElement>(null)\n const combinedRef = useForkRef(internalRef, ref)\n React.useEffect(\n function setIndeterminate() {\n if (internalRef.current && typeof indeterminate === 'boolean') {\n internalRef.current.indeterminate = indeterminate\n }\n },\n [indeterminate],\n )\n\n return (\n <Box\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n keyFocused ? styles.keyFocused : null,\n ]}\n >\n <input\n {...props}\n ref={combinedRef}\n type=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : isChecked}\n checked={isChecked}\n disabled={disabled}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n onBlur={(event) => {\n setKeyFocused(false)\n props?.onBlur?.(event)\n }}\n onKeyUp={(event) => {\n setKeyFocused(true)\n props?.onKeyUp?.(event)\n }}\n />\n <CheckboxIcon\n checked={isChecked}\n disabled={disabled}\n indeterminate={indeterminate}\n aria-hidden\n />\n {icon ? (\n <Box display=\"flex\" className={styles.icon} aria-hidden>\n {icon}\n </Box>\n ) : null}\n {label ? (\n <Box display=\"flex\" className={styles.label}>\n <Text>{label}</Text>\n </Box>\n ) : null}\n </Box>\n )\n})\n\nexport { CheckboxField }\nexport type { CheckboxFieldProps }\n"],"names":["CheckboxField","React","ref","label","icon","disabled","indeterminate","defaultChecked","onChange","props","isControlledComponent","checked","console","warn","undefined","keyFocused","setKeyFocused","checkedState","setChecked","isChecked","internalRef","combinedRef","useForkRef","setIndeterminate","current","Box","as","display","alignItems","className","styles","container","type","event","defaultPrevented","currentTarget","onBlur","onKeyUp","CheckboxIcon","Text"],"mappings":"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"}
@@ -0,0 +1,35 @@
1
+ import { useMemo } from 'react';
2
+
3
+ /**
4
+ * Sets both a function and object React ref.
5
+ */
6
+
7
+ function setRef(ref, value) {
8
+ if (typeof ref === 'function') {
9
+ ref(value);
10
+ } else if (ref) {
11
+ ref.current = value;
12
+ }
13
+ }
14
+ /**
15
+ * Merges React Refs into a single memoized function ref so you can pass it to an element.
16
+ * @example
17
+ * const Component = React.forwardRef((props, ref) => {
18
+ * const internalRef = React.useRef();
19
+ * return <div {...props} ref={useForkRef(internalRef, ref)} />;
20
+ * });
21
+ */
22
+
23
+
24
+ function useForkRef(...refs) {
25
+ return useMemo(() => {
26
+ if (!refs.some(Boolean)) return;
27
+ return value => {
28
+ refs.forEach(ref => setRef(ref, value));
29
+ };
30
+ }, // eslint-disable-next-line react-hooks/exhaustive-deps
31
+ refs);
32
+ }
33
+
34
+ export { useForkRef };
35
+ //# sourceMappingURL=use-fork-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-fork-ref.js","sources":["../../src/checkbox-field/use-fork-ref.ts"],"sourcesContent":["import { useMemo } from 'react'\n\n/**\n * Sets both a function and object React ref.\n */\nfunction setRef<T>(\n ref: React.RefCallback<T> | React.MutableRefObject<T> | null | undefined,\n value: T,\n) {\n if (typeof ref === 'function') {\n ref(value)\n } else if (ref) {\n ref.current = value\n }\n}\n\n/**\n * Merges React Refs into a single memoized function ref so you can pass it to an element.\n * @example\n * const Component = React.forwardRef((props, ref) => {\n * const internalRef = React.useRef();\n * return <div {...props} ref={useForkRef(internalRef, ref)} />;\n * });\n */\nfunction useForkRef(...refs: Array<React.Ref<unknown> | undefined>) {\n return useMemo(\n () => {\n if (!refs.some(Boolean)) return\n return (value: unknown) => {\n refs.forEach((ref) => setRef(ref, value))\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n refs,\n )\n}\n\nexport { useForkRef }\n"],"names":["setRef","ref","value","current","useForkRef","refs","useMemo","some","Boolean","forEach"],"mappings":";;AAEA;;;;AAGA,SAASA,MAAT,CACIC,GADJ,EAEIC,KAFJ;EAII,IAAI,OAAOD,GAAP,KAAe,UAAnB,EAA+B;IAC3BA,GAAG,CAACC,KAAD,CAAH;GADJ,MAEO,IAAID,GAAJ,EAAS;IACZA,GAAG,CAACE,OAAJ,GAAcD,KAAd;;AAEP;AAED;;;;;;;;;;AAQA,SAASE,UAAT,CAAoB,GAAGC,IAAvB;EACI,OAAOC,OAAO,CACV;IACI,IAAI,CAACD,IAAI,CAACE,IAAL,CAAUC,OAAV,CAAL,EAAyB;IACzB,OAAQN,KAAD;MACHG,IAAI,CAACI,OAAL,CAAcR,GAAD,IAASD,MAAM,CAACC,GAAD,EAAMC,KAAN,CAA5B;KADJ;GAHM;EAQVG,IARU,CAAd;AAUH;;;;"}
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';
package/es/menu/menu.js CHANGED
@@ -1,25 +1,15 @@
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, 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
- import { Portal } from 'ariakit/portal';
10
- 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';
5
+ import { useMenuStore, MenuButton as MenuButton$1, Portal, Menu as Menu$1, MenuItem as MenuItem$1, MenuGroup as MenuGroup$1 } from '@ariakit/react';
12
6
 
13
7
  const _excluded = ["children", "onItemSelect"],
14
8
  _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"];
9
+ _excluded3 = ["as"],
10
+ _excluded4 = ["exceptionallySetClassName", "modal"],
11
+ _excluded5 = ["value", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
12
+ _excluded6 = ["label", "children", "exceptionallySetClassName"];
23
13
  const MenuContext = /*#__PURE__*/createContext( // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn
24
14
  // (it is normally obtained by calling useMenuState but we can't call hooks outside components).
25
15
  // This is however of little consequence since this value is only used if some of the components
@@ -31,45 +21,36 @@ const MenuContext = /*#__PURE__*/createContext( // Ariakit gives us no means to
31
21
  * management for the menu components inside it.
32
22
  */
33
23
 
34
- const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, ref) {
24
+ function Menu(_ref) {
35
25
  let {
36
26
  children,
37
27
  onItemSelect
38
28
  } = _ref,
39
29
  props = _objectWithoutProperties(_ref, _excluded);
40
30
 
41
- const [anchorRect, handleAnchorRectChange] = useState(null);
42
- const getAnchorRect = useMemo(() => {
43
- return anchorRect ? () => anchorRect : undefined;
44
- }, [anchorRect]);
45
- const state = useMenuState(_objectSpread2({
46
- focusLoop: true,
47
- gutter: 8,
48
- shift: 4,
49
- getAnchorRect
31
+ const [anchorRect, setAnchorRect] = useState(null);
32
+ const getAnchorRect = useMemo(() => anchorRect ? () => anchorRect : null, [anchorRect]);
33
+ const menuStore = useMenuStore(_objectSpread2({
34
+ focusLoop: true
50
35
  }, props));
51
- useEffect(() => {
52
- if (!state.open) handleAnchorRectChange(null);
53
- }, [state.open]);
54
- useImperativeHandle(ref, () => ({
55
- open: state.show
56
- }));
57
36
  const handleItemSelect = useCallback(function handleItemSelect(value) {
58
- if (onItemSelect) onItemSelect(value);
37
+ onItemSelect == null ? void 0 : onItemSelect(value);
59
38
  }, [onItemSelect]);
60
39
  const value = useMemo(() => ({
61
- state,
40
+ menuStore,
62
41
  handleItemSelect,
63
- handleAnchorRectChange
64
- }), [state, handleItemSelect]);
42
+ getAnchorRect,
43
+ setAnchorRect
44
+ }), [menuStore, handleItemSelect, getAnchorRect, setAnchorRect]);
65
45
  return /*#__PURE__*/createElement(MenuContext.Provider, {
66
46
  value: value
67
47
  }, children);
68
- });
48
+ }
69
49
  /**
70
50
  * A button to toggle a dropdown menu open or closed.
71
51
  */
72
52
 
53
+
73
54
  const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2, ref) {
74
55
  let {
75
56
  exceptionallySetClassName
@@ -77,122 +58,35 @@ const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2,
77
58
  props = _objectWithoutProperties(_ref2, _excluded2);
78
59
 
79
60
  const {
80
- state
61
+ menuStore
81
62
  } = useContext(MenuContext);
82
63
  return /*#__PURE__*/createElement(MenuButton$1, _objectSpread2(_objectSpread2({}, props), {}, {
83
- state: state,
64
+ store: menuStore,
84
65
  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)
66
+ className: classNames('reactist_menubutton', exceptionallySetClassName)
173
67
  }));
174
68
  }); //
175
69
  // ContextMenuTrigger
176
70
  //
177
71
 
178
- const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(_ref4, ref) {
72
+ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(_ref3, ref) {
179
73
  let {
180
74
  as: component = 'div'
181
- } = _ref4,
182
- props = _objectWithoutProperties(_ref4, _excluded4);
75
+ } = _ref3,
76
+ props = _objectWithoutProperties(_ref3, _excluded3);
183
77
 
184
78
  const {
185
- handleAnchorRectChange,
186
- state
79
+ setAnchorRect,
80
+ menuStore
187
81
  } = useContext(MenuContext);
188
- const handleContextMenu = useCallback(event => {
82
+ const handleContextMenu = useCallback(function handleContextMenu(event) {
189
83
  event.preventDefault();
190
- handleAnchorRectChange({
84
+ setAnchorRect({
191
85
  x: event.clientX,
192
86
  y: event.clientY
193
87
  });
194
- state.show();
195
- }, [handleAnchorRectChange, state]);
88
+ menuStore.show();
89
+ }, [setAnchorRect, menuStore]);
196
90
  return /*#__PURE__*/createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
197
91
  onContextMenu: handleContextMenu,
198
92
  ref
@@ -202,155 +96,90 @@ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMen
202
96
  * The dropdown menu itself, containing a list of menu items.
203
97
  */
204
98
 
205
- const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref5, ref) {
99
+ const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref4, ref) {
206
100
  let {
207
101
  exceptionallySetClassName,
208
102
  modal = true
209
- } = _ref5,
210
- props = _objectWithoutProperties(_ref5, _excluded5);
103
+ } = _ref4,
104
+ props = _objectWithoutProperties(_ref4, _excluded4);
211
105
 
212
106
  const {
213
- state
107
+ menuStore,
108
+ getAnchorRect
214
109
  } = useContext(MenuContext);
215
- if (!state.open) return null;
216
- return /*#__PURE__*/createElement(Portal, {
110
+ const isOpen = menuStore.useState('open');
111
+ return isOpen ? /*#__PURE__*/createElement(Portal, {
217
112
  preserveTabOrder: true
218
113
  }, /*#__PURE__*/createElement(Menu$1, _objectSpread2(_objectSpread2({}, props), {}, {
219
- state: state,
114
+ store: menuStore,
115
+ gutter: 8,
116
+ shift: 4,
220
117
  ref: ref,
221
- className: classNames(styles.menuList, exceptionallySetClassName),
118
+ className: classNames('reactist_menulist', exceptionallySetClassName),
119
+ getAnchorRect: getAnchorRect != null ? getAnchorRect : undefined,
222
120
  modal: modal
223
- })));
121
+ }))) : null;
224
122
  });
225
123
  /**
226
- * Mostly equivalent to the `MenuList`, but to be used inside a `SubMenu`.
124
+ * A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
125
+ * callback.
227
126
  */
228
127
 
229
- const SubMenuList = /*#__PURE__*/polymorphicComponent(function SubMenuList(_ref6, ref) {
128
+ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref) {
230
129
  let {
130
+ value,
131
+ children,
132
+ onSelect,
133
+ hideOnSelect = true,
134
+ onClick,
231
135
  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
- //
136
+ as = 'button'
137
+ } = _ref5,
138
+ props = _objectWithoutProperties(_ref5, _excluded5);
251
139
 
252
- function useMenuItemClickHandler({
253
- value,
254
- hideOnSelect,
255
- onClick,
256
- onSelect
257
- }) {
258
140
  const {
259
141
  handleItemSelect,
260
- state
142
+ menuStore
261
143
  } = useContext(MenuContext);
262
144
  const {
263
145
  hide
264
- } = state;
265
- return useCallback(function handleClick(event) {
146
+ } = menuStore;
147
+ const handleClick = useCallback(function handleClick(event) {
266
148
  onClick == null ? void 0 : onClick(event);
267
149
  const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
268
150
  const shouldClose = onSelectResult !== false && hideOnSelect;
269
151
  handleItemSelect(value);
270
152
  if (shouldClose) hide();
271
153
  }, [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), {}, {
154
+ return /*#__PURE__*/createElement(MenuItem$1, _objectSpread2(_objectSpread2({}, props), {}, {
310
155
  as: as,
311
- state: state,
156
+ store: menuStore,
312
157
  ref: ref,
313
158
  onClick: handleClick,
314
- className: classNames(styles.menuItem, tone === 'destructive' ? styles.destructive : null, exceptionallySetClassName),
159
+ className: exceptionallySetClassName,
315
160
  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
- }));
161
+ }), children);
326
162
  });
327
163
  /**
328
- * This component can be rendered alongside other `MenuItem` elements inside a `MenuList` to show a
329
- * sub-menu.
164
+ * This component can be rendered alongside other `MenuItem` inside a `MenuList` in order to have
165
+ * a sub-menu.
330
166
  *
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.
335
- *
336
- * ## Usage
167
+ * Its children are expected to have the structure of a first level menu (a `MenuButton` and a
168
+ * `MenuList`).
337
169
  *
338
170
  * ```jsx
339
- * <Menu>
340
- * <MenuButton>Menu</MenuButton>
171
+ * <MenuItem label="Edit profile" />
172
+ * <SubMenu>
173
+ * <MenuButton>More options</MenuButton>
341
174
  * <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>
175
+ * <MenuItem label="Preferences" />
176
+ * <MenuItem label="Sign out" />
351
177
  * </MenuList>
352
- * </Menu>
178
+ * </SubMenu>
353
179
  * ```
180
+ *
181
+ * The `MenuButton` will become a menu item in the current menu items list, and it will lead to
182
+ * opening a sub-menu with the menu items list below it.
354
183
  */
355
184
 
356
185
  const SubMenu = /*#__PURE__*/forwardRef(function SubMenu({
@@ -359,11 +188,11 @@ const SubMenu = /*#__PURE__*/forwardRef(function SubMenu({
359
188
  }, ref) {
360
189
  const {
361
190
  handleItemSelect: parentMenuItemSelect,
362
- state
191
+ menuStore
363
192
  } = useContext(MenuContext);
364
193
  const {
365
194
  hide: parentMenuHide
366
- } = state;
195
+ } = menuStore;
367
196
  const handleSubItemSelect = useCallback(function handleSubItemSelect(value) {
368
197
  if (onItemSelect) onItemSelect(value);
369
198
  parentMenuItemSelect(value);
@@ -379,12 +208,10 @@ const SubMenu = /*#__PURE__*/forwardRef(function SubMenu({
379
208
  onItemSelect: handleSubItemSelect
380
209
  }, /*#__PURE__*/createElement(MenuItem$1, {
381
210
  as: "div",
382
- state: state,
211
+ store: menuStore,
383
212
  ref: ref,
384
213
  hideOnClick: false
385
- }, renderMenuButton), /*#__PURE__*/createElement("div", {
386
- className: styles.subMenuContainer
387
- }, list));
214
+ }, renderMenuButton), list);
388
215
  });
389
216
  /**
390
217
  * A way to semantically group some menu items.
@@ -393,101 +220,26 @@ const SubMenu = /*#__PURE__*/forwardRef(function SubMenu({
393
220
  * before and/or after the group if you so wish.
394
221
  */
395
222
 
396
- const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref8, ref) {
223
+ const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref6, ref) {
397
224
  let {
398
225
  label,
399
- info,
400
226
  children,
401
227
  exceptionallySetClassName
402
- } = _ref8,
403
- props = _objectWithoutProperties(_ref8, _excluded8);
228
+ } = _ref6,
229
+ props = _objectWithoutProperties(_ref6, _excluded6);
404
230
 
405
- const id = useId(props.id);
406
231
  const {
407
- state
232
+ menuStore
408
233
  } = useContext(MenuContext);
409
- return /*#__PURE__*/createElement(MenuGroup$1, _objectSpread2(_objectSpread2({
410
- "aria-labelledby": "menugroup-label-" + id
411
- }, props), {}, {
412
- id: id,
234
+ return /*#__PURE__*/createElement(MenuGroup$1, _objectSpread2(_objectSpread2({}, props), {}, {
413
235
  ref: ref,
414
- state: state,
236
+ store: menuStore,
415
237
  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));
238
+ }), label ? /*#__PURE__*/createElement("div", {
239
+ role: "presentation",
240
+ className: "reactist_menugroup__label"
241
+ }, label) : null, children);
490
242
  });
491
243
 
492
- export { ContextMenuTrigger, IconMenuItem, IconsMenuGroup, Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu, SubMenuItem, SubMenuList };
244
+ export { ContextMenuTrigger, Menu, MenuButton, MenuGroup, MenuItem, MenuList, SubMenu };
493
245
  //# sourceMappingURL=menu.js.map