@doist/reactist 21.1.1 → 22.0.0-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.
- package/dist/reactist.cjs.development.js +304 -58
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/base-field/base-field.module.css.js +1 -1
- package/es/index.js +1 -1
- package/es/menu/menu.js +301 -56
- package/es/menu/menu.js.map +1 -1
- package/es/menu/menu.module.css.js +4 -0
- package/es/menu/menu.module.css.js.map +1 -0
- package/es/select-field/select-field.module.css.js +1 -1
- package/es/text-area/text-area.module.css.js +1 -1
- package/es/text-field/text-field.module.css.js +1 -1
- package/lib/base-field/base-field.module.css.js +1 -1
- package/lib/index.js +1 -1
- package/lib/menu/index.d.ts +1 -2
- package/lib/menu/menu.d.ts +163 -23
- package/lib/menu/menu.js +1 -1
- package/lib/menu/menu.js.map +1 -1
- package/lib/menu/menu.module.css.js +2 -0
- package/lib/menu/menu.module.css.js.map +1 -0
- package/lib/select-field/select-field.module.css.js +1 -1
- package/lib/text-area/text-area.module.css.js +1 -1
- package/lib/text-field/text-field.module.css.js +1 -1
- package/package.json +1 -1
- package/styles/base-field.css +1 -1
- package/styles/base-field.module.css.css +1 -1
- package/styles/menu.css +8 -1
- package/styles/menu.module.css.css +1 -0
- package/styles/password-field.css +2 -2
- package/styles/reactist.css +6 -6
- package/styles/select-field.css +2 -2
- package/styles/select-field.module.css.css +1 -1
- package/styles/switch-field.css +1 -1
- package/styles/text-area.css +2 -2
- package/styles/text-area.module.css.css +1 -1
- package/styles/text-field.css +2 -2
- package/styles/text-field.module.css.css +1 -1
|
@@ -1723,7 +1723,7 @@ function PasswordHiddenIcon(props) {
|
|
|
1723
1723
|
})));
|
|
1724
1724
|
}
|
|
1725
1725
|
|
|
1726
|
-
var modules_540a88ff = {"container":"
|
|
1726
|
+
var modules_540a88ff = {"container":"_616a033e","auxiliaryLabel":"_0b88d85e","bordered":"c466cda3","error":"_4156d9cb","primaryLabel":"_274ef80a","secondaryLabel":"_2c4a8aed","messageIcon":"cd105f69"};
|
|
1727
1727
|
|
|
1728
1728
|
function FieldHint(props) {
|
|
1729
1729
|
return /*#__PURE__*/React.createElement(Text, _objectSpread2({
|
|
@@ -1825,7 +1825,7 @@ function BaseField({
|
|
|
1825
1825
|
}, hint) : null);
|
|
1826
1826
|
}
|
|
1827
1827
|
|
|
1828
|
-
var modules_aaf25250 = {"inputWrapper":"
|
|
1828
|
+
var modules_aaf25250 = {"inputWrapper":"_483abe7b","bordered":"fce9399c","error":"_603b8c4b","slot":"_79ca0da5"};
|
|
1829
1829
|
|
|
1830
1830
|
const _excluded$k = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "type", "maxWidth", "hidden", "aria-describedby", "startSlot", "endSlot"];
|
|
1831
1831
|
const TextField = /*#__PURE__*/React.forwardRef(function TextField(_ref, ref) {
|
|
@@ -1914,7 +1914,7 @@ const PasswordField = /*#__PURE__*/React.forwardRef(function PasswordField(_ref,
|
|
|
1914
1914
|
}));
|
|
1915
1915
|
});
|
|
1916
1916
|
|
|
1917
|
-
var modules_1fa9b208 = {"selectWrapper":"
|
|
1917
|
+
var modules_1fa9b208 = {"selectWrapper":"a9cbb3a6","bordered":"f3869290","error":"aefdbdaa"};
|
|
1918
1918
|
|
|
1919
1919
|
const _excluded$m = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "maxWidth", "children", "hidden", "aria-describedby"];
|
|
1920
1920
|
const SelectField = /*#__PURE__*/React.forwardRef(function SelectField(_ref, ref) {
|
|
@@ -2044,7 +2044,7 @@ const SwitchField = /*#__PURE__*/React.forwardRef(function SwitchField(_ref, ref
|
|
|
2044
2044
|
}, hint) : null);
|
|
2045
2045
|
});
|
|
2046
2046
|
|
|
2047
|
-
var modules_2728c236 = {"textAreaContainer":"
|
|
2047
|
+
var modules_2728c236 = {"textAreaContainer":"fdc243b3","innerContainer":"_5c1dd8bc","bordered":"_269f9e63","error":"d1e4b585","autoExpand":"_10c6f2ef"};
|
|
2048
2048
|
|
|
2049
2049
|
const _excluded$o = ["variant", "id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "message", "tone", "maxWidth", "hidden", "aria-describedby", "rows", "autoExpand"];
|
|
2050
2050
|
const TextArea = /*#__PURE__*/React.forwardRef(function TextArea(_ref, ref) {
|
|
@@ -2647,12 +2647,18 @@ function TabAwareSlot({
|
|
|
2647
2647
|
}) : null;
|
|
2648
2648
|
}
|
|
2649
2649
|
|
|
2650
|
+
var modules_2befbba6 = {"menuList":"c63e79f3","subMenuList":"_1e89cfc6","iconMenuItem":"_1b808bea","menuItem":"_8607099d","legacyLayout":"_609759d5","menuGroupLabel":"f1730843","menuItemIcon":"_7cec7dce","menuItemLabel":"_91c012d8","menuItemDescription":"bb494fd4","destructive":"_503b074a","menuGroupInfo":"ad6d2e4a","iconsMenuGroup":"_410b11f2"};
|
|
2651
|
+
|
|
2650
2652
|
const _excluded$t = ["children", "onItemSelect"],
|
|
2651
2653
|
_excluded2$3 = ["exceptionallySetClassName"],
|
|
2652
|
-
_excluded3$2 = ["
|
|
2653
|
-
_excluded4$1 = ["
|
|
2654
|
-
_excluded5$1 = ["
|
|
2655
|
-
_excluded6 = ["
|
|
2654
|
+
_excluded3$2 = ["exceptionallySetClassName", "label", "icon"],
|
|
2655
|
+
_excluded4$1 = ["as"],
|
|
2656
|
+
_excluded5$1 = ["exceptionallySetClassName", "modal"],
|
|
2657
|
+
_excluded6 = ["exceptionallySetClassName", "modal"],
|
|
2658
|
+
_excluded7 = ["value", "label", "description", "icon", "shortcut", "tone", "children", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
|
|
2659
|
+
_excluded8 = ["label", "info", "children", "exceptionallySetClassName"],
|
|
2660
|
+
_excluded9 = ["value", "label", "description", "icon", "onSelect", "hideOnSelect", "onClick", "exceptionallySetClassName", "as"],
|
|
2661
|
+
_excluded10 = ["children"];
|
|
2656
2662
|
const MenuContext = /*#__PURE__*/React.createContext( // Ariakit gives us no means to obtain a valid initial/default value of type MenuStateReturn
|
|
2657
2663
|
// (it is normally obtained by calling useMenuState but we can't call hooks outside components).
|
|
2658
2664
|
// This is however of little consequence since this value is only used if some of the components
|
|
@@ -2664,7 +2670,7 @@ const MenuContext = /*#__PURE__*/React.createContext( // Ariakit gives us no mea
|
|
|
2664
2670
|
* management for the menu components inside it.
|
|
2665
2671
|
*/
|
|
2666
2672
|
|
|
2667
|
-
function Menu(_ref) {
|
|
2673
|
+
const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, ref) {
|
|
2668
2674
|
let {
|
|
2669
2675
|
children,
|
|
2670
2676
|
onItemSelect
|
|
@@ -2684,6 +2690,9 @@ function Menu(_ref) {
|
|
|
2684
2690
|
React.useEffect(() => {
|
|
2685
2691
|
if (!state.open) handleAnchorRectChange(null);
|
|
2686
2692
|
}, [state.open]);
|
|
2693
|
+
React.useImperativeHandle(ref, () => ({
|
|
2694
|
+
open: state.show
|
|
2695
|
+
}));
|
|
2687
2696
|
const handleItemSelect = React.useCallback(function handleItemSelect(value) {
|
|
2688
2697
|
if (onItemSelect) onItemSelect(value);
|
|
2689
2698
|
}, [onItemSelect]);
|
|
@@ -2695,12 +2704,11 @@ function Menu(_ref) {
|
|
|
2695
2704
|
return /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
2696
2705
|
value: value
|
|
2697
2706
|
}, children);
|
|
2698
|
-
}
|
|
2707
|
+
});
|
|
2699
2708
|
/**
|
|
2700
2709
|
* A button to toggle a dropdown menu open or closed.
|
|
2701
2710
|
*/
|
|
2702
2711
|
|
|
2703
|
-
|
|
2704
2712
|
const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2, ref) {
|
|
2705
2713
|
let {
|
|
2706
2714
|
exceptionallySetClassName
|
|
@@ -2713,17 +2721,104 @@ const MenuButton = /*#__PURE__*/polymorphicComponent(function MenuButton(_ref2,
|
|
|
2713
2721
|
return /*#__PURE__*/React.createElement(Ariakit.MenuButton, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2714
2722
|
state: state,
|
|
2715
2723
|
ref: ref,
|
|
2716
|
-
className:
|
|
2724
|
+
className: exceptionallySetClassName
|
|
2725
|
+
}));
|
|
2726
|
+
});
|
|
2727
|
+
/**
|
|
2728
|
+
* Renders the content inside a standard MenuItem. It is extracted into a component for reuse in
|
|
2729
|
+
* the SubMenuItem, which is a MenuItem visually, but semantically it's closer to be a MenuButton.
|
|
2730
|
+
* @private
|
|
2731
|
+
*/
|
|
2732
|
+
|
|
2733
|
+
function MenuItemContent({
|
|
2734
|
+
label,
|
|
2735
|
+
description,
|
|
2736
|
+
icon,
|
|
2737
|
+
shortcut,
|
|
2738
|
+
id
|
|
2739
|
+
}) {
|
|
2740
|
+
if (!label) return null;
|
|
2741
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
2742
|
+
display: "flex",
|
|
2743
|
+
gap: "small",
|
|
2744
|
+
alignItems: "center",
|
|
2745
|
+
width: "full",
|
|
2746
|
+
"aria-hidden": true
|
|
2747
|
+
}, icon ? /*#__PURE__*/React.createElement("div", {
|
|
2748
|
+
className: modules_2befbba6.menuItemIcon
|
|
2749
|
+
}, icon) : null, /*#__PURE__*/React.createElement(Box, {
|
|
2750
|
+
display: "inlineFlex",
|
|
2751
|
+
flexDirection: "column",
|
|
2752
|
+
gap: "xsmall",
|
|
2753
|
+
paddingY: "xsmall",
|
|
2754
|
+
alignItems: "flexStart",
|
|
2755
|
+
overflow: "hidden",
|
|
2756
|
+
flexGrow: 1
|
|
2757
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
2758
|
+
id: id + "-label",
|
|
2759
|
+
weight: description ? 'semibold' : 'regular',
|
|
2760
|
+
size: "copy",
|
|
2761
|
+
lineClamp: 1,
|
|
2762
|
+
exceptionallySetClassName: modules_2befbba6.menuItemLabel
|
|
2763
|
+
}, label), description ? /*#__PURE__*/React.createElement(Text, {
|
|
2764
|
+
id: id + "-description",
|
|
2765
|
+
size: "copy",
|
|
2766
|
+
tone: "secondary",
|
|
2767
|
+
exceptionallySetClassName: modules_2befbba6.menuItemDescription
|
|
2768
|
+
}, description) : null), shortcut ? /*#__PURE__*/React.createElement("div", null, shortcut) : null);
|
|
2769
|
+
} //
|
|
2770
|
+
// SubMenuItem
|
|
2771
|
+
//
|
|
2772
|
+
|
|
2773
|
+
|
|
2774
|
+
function ArrowRightIcon() {
|
|
2775
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
2776
|
+
width: "24",
|
|
2777
|
+
height: "24"
|
|
2778
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
2779
|
+
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",
|
|
2780
|
+
fill: "currentColor",
|
|
2781
|
+
fillRule: "evenodd"
|
|
2782
|
+
}));
|
|
2783
|
+
}
|
|
2784
|
+
/**
|
|
2785
|
+
* A menu item to toggle a sub-menu open or closed.
|
|
2786
|
+
*/
|
|
2787
|
+
|
|
2788
|
+
|
|
2789
|
+
const SubMenuItem = /*#__PURE__*/polymorphicComponent(function SubMenuItem(_ref3, ref) {
|
|
2790
|
+
let {
|
|
2791
|
+
exceptionallySetClassName,
|
|
2792
|
+
label,
|
|
2793
|
+
icon
|
|
2794
|
+
} = _ref3,
|
|
2795
|
+
props = _objectWithoutProperties(_ref3, _excluded3$2);
|
|
2796
|
+
|
|
2797
|
+
const id = useId(props.id);
|
|
2798
|
+
const {
|
|
2799
|
+
state
|
|
2800
|
+
} = React.useContext(MenuContext);
|
|
2801
|
+
return /*#__PURE__*/React.createElement(Ariakit.MenuButton, _objectSpread2(_objectSpread2({
|
|
2802
|
+
"aria-labelledby": label && !props['aria-label'] ? id + "-label" : undefined
|
|
2803
|
+
}, props), {}, {
|
|
2804
|
+
state: state,
|
|
2805
|
+
ref: ref,
|
|
2806
|
+
className: classNames(modules_2befbba6.menuItem, exceptionallySetClassName)
|
|
2807
|
+
}), /*#__PURE__*/React.createElement(MenuItemContent, {
|
|
2808
|
+
id: id,
|
|
2809
|
+
icon: icon,
|
|
2810
|
+
label: label,
|
|
2811
|
+
shortcut: /*#__PURE__*/React.createElement(ArrowRightIcon, null)
|
|
2717
2812
|
}));
|
|
2718
2813
|
}); //
|
|
2719
2814
|
// ContextMenuTrigger
|
|
2720
2815
|
//
|
|
2721
2816
|
|
|
2722
|
-
const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(
|
|
2817
|
+
const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMenuTrigger(_ref4, ref) {
|
|
2723
2818
|
let {
|
|
2724
2819
|
as: component = 'div'
|
|
2725
|
-
} =
|
|
2726
|
-
props = _objectWithoutProperties(
|
|
2820
|
+
} = _ref4,
|
|
2821
|
+
props = _objectWithoutProperties(_ref4, _excluded4$1);
|
|
2727
2822
|
|
|
2728
2823
|
const {
|
|
2729
2824
|
handleAnchorRectChange,
|
|
@@ -2746,42 +2841,59 @@ const ContextMenuTrigger = /*#__PURE__*/polymorphicComponent(function ContextMen
|
|
|
2746
2841
|
* The dropdown menu itself, containing a list of menu items.
|
|
2747
2842
|
*/
|
|
2748
2843
|
|
|
2749
|
-
const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(
|
|
2844
|
+
const MenuList = /*#__PURE__*/polymorphicComponent(function MenuList(_ref5, ref) {
|
|
2750
2845
|
let {
|
|
2751
2846
|
exceptionallySetClassName,
|
|
2752
2847
|
modal = true
|
|
2753
|
-
} =
|
|
2754
|
-
props = _objectWithoutProperties(
|
|
2848
|
+
} = _ref5,
|
|
2849
|
+
props = _objectWithoutProperties(_ref5, _excluded5$1);
|
|
2755
2850
|
|
|
2756
2851
|
const {
|
|
2757
2852
|
state
|
|
2758
2853
|
} = React.useContext(MenuContext);
|
|
2759
|
-
|
|
2854
|
+
if (!state.open) return null;
|
|
2855
|
+
return /*#__PURE__*/React.createElement(portal.Portal, {
|
|
2760
2856
|
preserveTabOrder: true
|
|
2761
2857
|
}, /*#__PURE__*/React.createElement(Ariakit.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2762
2858
|
state: state,
|
|
2763
2859
|
ref: ref,
|
|
2764
|
-
className: classNames(
|
|
2860
|
+
className: classNames(modules_2befbba6.menuList, exceptionallySetClassName),
|
|
2765
2861
|
modal: modal
|
|
2766
|
-
})))
|
|
2862
|
+
})));
|
|
2767
2863
|
});
|
|
2768
2864
|
/**
|
|
2769
|
-
*
|
|
2770
|
-
* callback.
|
|
2865
|
+
* Mostly equivalent to the `MenuList`, but to be used inside a `SubMenu`.
|
|
2771
2866
|
*/
|
|
2772
2867
|
|
|
2773
|
-
const
|
|
2868
|
+
const SubMenuList = /*#__PURE__*/polymorphicComponent(function SubMenuList(_ref6, ref) {
|
|
2774
2869
|
let {
|
|
2775
|
-
value,
|
|
2776
|
-
children,
|
|
2777
|
-
onSelect,
|
|
2778
|
-
hideOnSelect = true,
|
|
2779
|
-
onClick,
|
|
2780
2870
|
exceptionallySetClassName,
|
|
2781
|
-
|
|
2782
|
-
} =
|
|
2783
|
-
props = _objectWithoutProperties(
|
|
2871
|
+
modal = true
|
|
2872
|
+
} = _ref6,
|
|
2873
|
+
props = _objectWithoutProperties(_ref6, _excluded6);
|
|
2784
2874
|
|
|
2875
|
+
const {
|
|
2876
|
+
state
|
|
2877
|
+
} = React.useContext(MenuContext);
|
|
2878
|
+
if (!state.open) return null;
|
|
2879
|
+
return /*#__PURE__*/React.createElement(portal.Portal, {
|
|
2880
|
+
preserveTabOrder: true
|
|
2881
|
+
}, /*#__PURE__*/React.createElement(Ariakit.Menu, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
2882
|
+
state: state,
|
|
2883
|
+
ref: ref,
|
|
2884
|
+
className: classNames(modules_2befbba6.menuList, modules_2befbba6.subMenuList, exceptionallySetClassName),
|
|
2885
|
+
modal: modal
|
|
2886
|
+
})));
|
|
2887
|
+
}); //
|
|
2888
|
+
// MenuItem
|
|
2889
|
+
//
|
|
2890
|
+
|
|
2891
|
+
function useMenuItemClickHandler({
|
|
2892
|
+
value,
|
|
2893
|
+
hideOnSelect,
|
|
2894
|
+
onClick,
|
|
2895
|
+
onSelect
|
|
2896
|
+
}) {
|
|
2785
2897
|
const {
|
|
2786
2898
|
handleItemSelect,
|
|
2787
2899
|
state
|
|
@@ -2789,42 +2901,95 @@ const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref5, ref)
|
|
|
2789
2901
|
const {
|
|
2790
2902
|
hide
|
|
2791
2903
|
} = state;
|
|
2792
|
-
|
|
2904
|
+
return React.useCallback(function handleClick(event) {
|
|
2793
2905
|
onClick == null ? void 0 : onClick(event);
|
|
2794
2906
|
const onSelectResult = onSelect && !event.defaultPrevented ? onSelect() : undefined;
|
|
2795
2907
|
const shouldClose = onSelectResult !== false && hideOnSelect;
|
|
2796
2908
|
handleItemSelect(value);
|
|
2797
2909
|
if (shouldClose) hide();
|
|
2798
2910
|
}, [onSelect, onClick, handleItemSelect, hideOnSelect, hide, value]);
|
|
2799
|
-
|
|
2911
|
+
}
|
|
2912
|
+
/**
|
|
2913
|
+
* A menu item inside a menu list. It can be selected by the user, triggering the `onSelect`
|
|
2914
|
+
* callback.
|
|
2915
|
+
*/
|
|
2916
|
+
|
|
2917
|
+
|
|
2918
|
+
const MenuItem = /*#__PURE__*/polymorphicComponent(function MenuItem(_ref7, ref) {
|
|
2919
|
+
let {
|
|
2920
|
+
value,
|
|
2921
|
+
label,
|
|
2922
|
+
description,
|
|
2923
|
+
icon,
|
|
2924
|
+
shortcut,
|
|
2925
|
+
tone,
|
|
2926
|
+
children,
|
|
2927
|
+
onSelect,
|
|
2928
|
+
hideOnSelect = true,
|
|
2929
|
+
onClick,
|
|
2930
|
+
exceptionallySetClassName,
|
|
2931
|
+
as = 'button'
|
|
2932
|
+
} = _ref7,
|
|
2933
|
+
props = _objectWithoutProperties(_ref7, _excluded7);
|
|
2934
|
+
|
|
2935
|
+
const id = useId(props.id);
|
|
2936
|
+
const {
|
|
2937
|
+
state
|
|
2938
|
+
} = React.useContext(MenuContext);
|
|
2939
|
+
const handleClick = useMenuItemClickHandler({
|
|
2940
|
+
value,
|
|
2941
|
+
onSelect,
|
|
2942
|
+
onClick,
|
|
2943
|
+
hideOnSelect
|
|
2944
|
+
});
|
|
2945
|
+
return /*#__PURE__*/React.createElement(Ariakit.MenuItem, _objectSpread2(_objectSpread2({
|
|
2946
|
+
"aria-labelledby": label && !props['aria-label'] ? id + "-label" : undefined,
|
|
2947
|
+
"aria-describedby": label && description ? id + "-description" : undefined
|
|
2948
|
+
}, props), {}, {
|
|
2800
2949
|
as: as,
|
|
2801
2950
|
state: state,
|
|
2802
2951
|
ref: ref,
|
|
2803
2952
|
onClick: handleClick,
|
|
2804
|
-
className: exceptionallySetClassName,
|
|
2953
|
+
className: classNames(modules_2befbba6.menuItem, tone === 'destructive' ? modules_2befbba6.destructive : null, exceptionallySetClassName),
|
|
2805
2954
|
hideOnClick: false
|
|
2806
|
-
}), children
|
|
2955
|
+
}), children ? /*#__PURE__*/React.createElement(Box, {
|
|
2956
|
+
width: "full",
|
|
2957
|
+
className: label ? undefined : modules_2befbba6.legacyLayout
|
|
2958
|
+
}, children) : null, /*#__PURE__*/React.createElement(MenuItemContent, {
|
|
2959
|
+
id: id,
|
|
2960
|
+
icon: icon,
|
|
2961
|
+
label: label,
|
|
2962
|
+
description: description,
|
|
2963
|
+
shortcut: shortcut
|
|
2964
|
+
}));
|
|
2807
2965
|
});
|
|
2808
2966
|
/**
|
|
2809
|
-
* This component can be rendered alongside other `MenuItem` inside a `MenuList`
|
|
2810
|
-
*
|
|
2967
|
+
* This component can be rendered alongside other `MenuItem` elements inside a `MenuList` to show a
|
|
2968
|
+
* sub-menu.
|
|
2969
|
+
*
|
|
2970
|
+
* Its children are expected to be exactly two elements, in the following order:
|
|
2971
|
+
*
|
|
2972
|
+
* 1. A `SubMenuItem` element: the menu item that triggers the sub-menu to open.
|
|
2973
|
+
* 2. A `SubMenuList` element: the list of menu items that will be shown when the sub-menu is open.
|
|
2811
2974
|
*
|
|
2812
|
-
*
|
|
2813
|
-
* `MenuList`).
|
|
2975
|
+
* ## Usage
|
|
2814
2976
|
*
|
|
2815
2977
|
* ```jsx
|
|
2816
|
-
* <
|
|
2817
|
-
*
|
|
2818
|
-
* <MenuButton>More options</MenuButton>
|
|
2978
|
+
* <Menu>
|
|
2979
|
+
* <MenuButton>Menu</MenuButton>
|
|
2819
2980
|
* <MenuList>
|
|
2820
|
-
* <MenuItem label="
|
|
2821
|
-
* <MenuItem label="
|
|
2981
|
+
* <MenuItem label="Item 1" />
|
|
2982
|
+
* <MenuItem label="Item 2" />
|
|
2983
|
+
* <SubMenu>
|
|
2984
|
+
* <SubMenuItem label="Submenu" />
|
|
2985
|
+
* <SubMenuList>
|
|
2986
|
+
* <MenuItem label="Submenu Item 1" />
|
|
2987
|
+
* <MenuItem label="Submenu Item 2" />
|
|
2988
|
+
* </SubMenuList>
|
|
2989
|
+
* </SubMenu>
|
|
2822
2990
|
* </MenuList>
|
|
2823
|
-
* </
|
|
2991
|
+
* </Menu>
|
|
2824
2992
|
* ```
|
|
2825
|
-
*
|
|
2826
|
-
* The `MenuButton` will become a menu item in the current menu items list, and it will lead to
|
|
2827
|
-
* opening a sub-menu with the menu items list below it.
|
|
2828
2993
|
*/
|
|
2829
2994
|
|
|
2830
2995
|
const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
@@ -2856,7 +3021,9 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
|
2856
3021
|
state: state,
|
|
2857
3022
|
ref: ref,
|
|
2858
3023
|
hideOnClick: false
|
|
2859
|
-
}, renderMenuButton),
|
|
3024
|
+
}, renderMenuButton), /*#__PURE__*/React.createElement("div", {
|
|
3025
|
+
className: modules_2befbba6.subMenuContainer
|
|
3026
|
+
}, list));
|
|
2860
3027
|
});
|
|
2861
3028
|
/**
|
|
2862
3029
|
* A way to semantically group some menu items.
|
|
@@ -2865,25 +3032,100 @@ const SubMenu = /*#__PURE__*/React.forwardRef(function SubMenu({
|
|
|
2865
3032
|
* before and/or after the group if you so wish.
|
|
2866
3033
|
*/
|
|
2867
3034
|
|
|
2868
|
-
const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(
|
|
3035
|
+
const MenuGroup = /*#__PURE__*/polymorphicComponent(function MenuGroup(_ref8, ref) {
|
|
2869
3036
|
let {
|
|
2870
3037
|
label,
|
|
3038
|
+
info,
|
|
2871
3039
|
children,
|
|
2872
3040
|
exceptionallySetClassName
|
|
2873
|
-
} =
|
|
2874
|
-
props = _objectWithoutProperties(
|
|
3041
|
+
} = _ref8,
|
|
3042
|
+
props = _objectWithoutProperties(_ref8, _excluded8);
|
|
2875
3043
|
|
|
3044
|
+
const id = useId(props.id);
|
|
2876
3045
|
const {
|
|
2877
3046
|
state
|
|
2878
3047
|
} = React.useContext(MenuContext);
|
|
2879
|
-
return /*#__PURE__*/React.createElement(Ariakit.MenuGroup, _objectSpread2(_objectSpread2({
|
|
3048
|
+
return /*#__PURE__*/React.createElement(Ariakit.MenuGroup, _objectSpread2(_objectSpread2({
|
|
3049
|
+
"aria-labelledby": "menugroup-label-" + id
|
|
3050
|
+
}, props), {}, {
|
|
3051
|
+
id: id,
|
|
2880
3052
|
ref: ref,
|
|
2881
3053
|
state: state,
|
|
2882
3054
|
className: exceptionallySetClassName
|
|
2883
|
-
}),
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
3055
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
3056
|
+
display: "flex",
|
|
3057
|
+
alignItems: "center",
|
|
3058
|
+
gap: "small",
|
|
3059
|
+
className: modules_2befbba6.menuGroupLabel
|
|
3060
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
3061
|
+
id: "menugroup-label-" + id,
|
|
3062
|
+
size: "copy",
|
|
3063
|
+
weight: "semibold"
|
|
3064
|
+
}, label), info ? /*#__PURE__*/React.createElement(Box, {
|
|
3065
|
+
flexShrink: 0,
|
|
3066
|
+
display: "flex",
|
|
3067
|
+
alignItems: "center",
|
|
3068
|
+
justifyContent: "center",
|
|
3069
|
+
className: modules_2befbba6.menuGroupInfo
|
|
3070
|
+
}, info) : null), children);
|
|
3071
|
+
});
|
|
3072
|
+
/**
|
|
3073
|
+
* A menu item that visually only shows as an icon. It must be used inside an `IconsMenuGroup`.
|
|
3074
|
+
*/
|
|
3075
|
+
|
|
3076
|
+
const IconMenuItem = /*#__PURE__*/polymorphicComponent(function IconMenuItem(_ref9, ref) {
|
|
3077
|
+
let {
|
|
3078
|
+
value,
|
|
3079
|
+
label,
|
|
3080
|
+
description,
|
|
3081
|
+
icon,
|
|
3082
|
+
onSelect,
|
|
3083
|
+
hideOnSelect = true,
|
|
3084
|
+
onClick,
|
|
3085
|
+
exceptionallySetClassName,
|
|
3086
|
+
as = 'button'
|
|
3087
|
+
} = _ref9,
|
|
3088
|
+
props = _objectWithoutProperties(_ref9, _excluded9);
|
|
3089
|
+
|
|
3090
|
+
const id = useId(props.id);
|
|
3091
|
+
const {
|
|
3092
|
+
state
|
|
3093
|
+
} = React.useContext(MenuContext);
|
|
3094
|
+
const handleClick = useMenuItemClickHandler({
|
|
3095
|
+
value,
|
|
3096
|
+
onSelect,
|
|
3097
|
+
onClick,
|
|
3098
|
+
hideOnSelect
|
|
3099
|
+
});
|
|
3100
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
3101
|
+
content: label
|
|
3102
|
+
}, /*#__PURE__*/React.createElement(Ariakit.MenuItem, _objectSpread2(_objectSpread2({
|
|
3103
|
+
"aria-label": label,
|
|
3104
|
+
"aria-describedby": id + "-description"
|
|
3105
|
+
}, props), {}, {
|
|
3106
|
+
as: as,
|
|
3107
|
+
state: state,
|
|
3108
|
+
ref: ref,
|
|
3109
|
+
onClick: handleClick,
|
|
3110
|
+
className: classNames(modules_2befbba6.iconMenuItem, exceptionallySetClassName),
|
|
3111
|
+
hideOnClick: false
|
|
3112
|
+
}), icon));
|
|
3113
|
+
});
|
|
3114
|
+
/**
|
|
3115
|
+
* Semantically equivalent to `MenuGroup`, but meant to group `IconMenuItem`s only.
|
|
3116
|
+
*/
|
|
3117
|
+
|
|
3118
|
+
const IconsMenuGroup = /*#__PURE__*/polymorphicComponent(function IconsMenuGroup(_ref10, ref) {
|
|
3119
|
+
let {
|
|
3120
|
+
children
|
|
3121
|
+
} = _ref10,
|
|
3122
|
+
props = _objectWithoutProperties(_ref10, _excluded10);
|
|
3123
|
+
|
|
3124
|
+
return /*#__PURE__*/React.createElement(MenuGroup, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
3125
|
+
ref: ref
|
|
3126
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
3127
|
+
className: modules_2befbba6.iconsMenuGroup
|
|
3128
|
+
}, children));
|
|
2887
3129
|
});
|
|
2888
3130
|
|
|
2889
3131
|
const _excluded$u = ["type", "variant", "size", "loading", "disabled", "tooltip", "onClick", "children"];
|
|
@@ -3970,6 +4212,8 @@ exports.Divider = Divider;
|
|
|
3970
4212
|
exports.Heading = Heading;
|
|
3971
4213
|
exports.Hidden = Hidden;
|
|
3972
4214
|
exports.HiddenVisually = HiddenVisually;
|
|
4215
|
+
exports.IconMenuItem = IconMenuItem;
|
|
4216
|
+
exports.IconsMenuGroup = IconsMenuGroup;
|
|
3973
4217
|
exports.Inline = Inline;
|
|
3974
4218
|
exports.KeyCapturer = KeyCapturer;
|
|
3975
4219
|
exports.KeyboardShortcut = KeyboardShortcut;
|
|
@@ -3994,6 +4238,8 @@ exports.SelectField = SelectField;
|
|
|
3994
4238
|
exports.Stack = Stack;
|
|
3995
4239
|
exports.StaticToast = StaticToast;
|
|
3996
4240
|
exports.SubMenu = SubMenu;
|
|
4241
|
+
exports.SubMenuItem = SubMenuItem;
|
|
4242
|
+
exports.SubMenuList = SubMenuList;
|
|
3997
4243
|
exports.SwitchField = SwitchField;
|
|
3998
4244
|
exports.Tab = Tab;
|
|
3999
4245
|
exports.TabAwareSlot = TabAwareSlot;
|