@jbrowse/core 3.5.0 → 3.6.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.
@@ -1,5 +1,5 @@
1
1
  import type { MenuItem as JBMenuItem } from './Menu';
2
- import type { PopupState } from 'material-ui-popup-state/hooks';
2
+ import type { PopupState } from './hooks';
3
3
  declare function CascadingMenuChildren(props: {
4
4
  onMenuItemClick: Function;
5
5
  closeAfterItemClick?: boolean;
@@ -7,15 +7,15 @@ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const react_1 = require("react");
8
8
  const ChevronRight_1 = __importDefault(require("@mui/icons-material/ChevronRight"));
9
9
  const material_1 = require("@mui/material");
10
- const HoverMenu_1 = __importDefault(require("material-ui-popup-state/HoverMenu"));
11
- const hooks_1 = require("material-ui-popup-state/hooks");
10
+ const HoverMenu_1 = __importDefault(require("./HoverMenu"));
12
11
  const Menu_1 = require("./Menu");
12
+ const hooks_1 = require("./hooks");
13
13
  const CascadingContext = (0, react_1.createContext)({
14
- parentPopupState: null,
15
- rootPopupState: null,
14
+ parentPopupState: undefined,
15
+ rootPopupState: undefined,
16
16
  });
17
17
  function CascadingMenuItem({ onClick, closeAfterItemClick, ...props }) {
18
- const { rootPopupState } = (0, react_1.useContext)(CascadingContext);
18
+ const { rootPopupState, parentPopupState } = (0, react_1.useContext)(CascadingContext);
19
19
  if (!rootPopupState) {
20
20
  throw new Error('must be used inside a CascadingMenu');
21
21
  }
@@ -24,16 +24,25 @@ function CascadingMenuItem({ onClick, closeAfterItemClick, ...props }) {
24
24
  rootPopupState.close();
25
25
  }
26
26
  onClick === null || onClick === void 0 ? void 0 : onClick(event);
27
+ }, onMouseOver: () => {
28
+ if (parentPopupState === null || parentPopupState === void 0 ? void 0 : parentPopupState.childHandle) {
29
+ parentPopupState.childHandle.close();
30
+ parentPopupState.setChildHandle(undefined);
31
+ }
27
32
  } }));
28
33
  }
29
- function CascadingSubmenu({ title, Icon, inset, popupId, ...props }) {
34
+ function CascadingSubmenu({ title, Icon, inset, ...props }) {
30
35
  const { parentPopupState } = (0, react_1.useContext)(CascadingContext);
31
36
  const popupState = (0, hooks_1.usePopupState)({
32
- popupId,
33
- variant: 'popover',
34
37
  parentPopupState,
35
38
  });
36
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, { ...(0, hooks_1.bindHover)(popupState), ...(0, hooks_1.bindFocus)(popupState), children: [Icon ? ((0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon, {}) })) : null, (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: title, inset: inset }), (0, jsx_runtime_1.jsx)(ChevronRight_1.default, {})] }), (0, jsx_runtime_1.jsx)(CascadingSubmenuHover, { ...props, anchorOrigin: { vertical: 'top', horizontal: 'right' }, transformOrigin: { vertical: 'top', horizontal: 'left' }, popupState: popupState })] }));
39
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, { ...(0, hooks_1.bindFocus)(popupState), onMouseOver: (event) => {
40
+ if (parentPopupState === null || parentPopupState === void 0 ? void 0 : parentPopupState.childHandle) {
41
+ parentPopupState.childHandle.close();
42
+ parentPopupState.setChildHandle(undefined);
43
+ }
44
+ (0, hooks_1.bindHover)(popupState).onMouseOver(event);
45
+ }, children: [Icon ? ((0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon, {}) })) : null, (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: title, inset: inset }), (0, jsx_runtime_1.jsx)(ChevronRight_1.default, {})] }), (0, jsx_runtime_1.jsx)(CascadingSubmenuHover, { ...props, anchorOrigin: { vertical: 'top', horizontal: 'right' }, transformOrigin: { vertical: 'top', horizontal: 'left' }, popupState: popupState })] }));
37
46
  }
38
47
  function CascadingSubmenuHover({ popupState, onMenuItemClick, menuItems, classes, ...props }) {
39
48
  const { rootPopupState } = (0, react_1.useContext)(CascadingContext);
@@ -61,18 +70,20 @@ function EndDecoration({ item }) {
61
70
  return null;
62
71
  }
63
72
  function CascadingMenuList({ onMenuItemClick, closeAfterItemClick, menuItems, ...props }) {
64
- function handleClick(callback) {
65
- return (event) => {
66
- onMenuItemClick(event, callback);
67
- };
68
- }
69
73
  const hasIcon = menuItems.some(m => 'icon' in m && m.icon);
70
74
  return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: menuItems
71
- .sort((a, b) => (b.priority || 0) - (a.priority || 0))
75
+ .toSorted((a, b) => (b.priority || 0) - (a.priority || 0))
72
76
  .map((item, idx) => {
73
- return 'subMenu' in item ? ((0, jsx_runtime_1.jsx)(CascadingSubmenu, { popupId: `subMenu-${item.label}`, title: item.label, Icon: item.icon, inset: hasIcon && !item.icon, onMenuItemClick: onMenuItemClick, menuItems: item.subMenu, children: (0, jsx_runtime_1.jsx)(CascadingMenuList, { ...props, closeAfterItemClick: closeAfterItemClick, onMenuItemClick: onMenuItemClick, menuItems: item.subMenu }) }, `subMenu-${item.label}-${idx}`)) : item.type === 'divider' ? ((0, jsx_runtime_1.jsx)(material_1.Divider, { component: "li" }, `divider-${JSON.stringify(item)}-${idx}`)) : item.type === 'subHeader' ? ((0, jsx_runtime_1.jsx)(material_1.ListSubheader, { children: item.label }, `subHeader-${item.label}-${idx}`)) : ((0, jsx_runtime_1.jsxs)(CascadingMenuItem, { closeAfterItemClick: closeAfterItemClick, onClick: 'onClick' in item ? handleClick(item.onClick) : undefined, disabled: Boolean(item.disabled), children: [item.icon ? ((0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(item.icon, {}) })) : null, ' ', (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: item.label, secondary: item.subLabel, inset: hasIcon && !item.icon }), (0, jsx_runtime_1.jsx)("div", { style: { flexGrow: 1, minWidth: 10 } }), (0, jsx_runtime_1.jsx)(EndDecoration, { item: item })] }, `${item.label}-${idx}`));
77
+ return 'subMenu' in item ? ((0, jsx_runtime_1.jsx)(CascadingSubmenu, { title: item.label, Icon: item.icon, inset: hasIcon && !item.icon, onMenuItemClick: onMenuItemClick, menuItems: item.subMenu, children: (0, jsx_runtime_1.jsx)(CascadingMenuList, { ...props, closeAfterItemClick: closeAfterItemClick, onMenuItemClick: onMenuItemClick, menuItems: item.subMenu }) }, `subMenu-${item.label}-${idx}`)) : item.type === 'divider' ? ((0, jsx_runtime_1.jsx)(material_1.Divider, { component: "li" }, `divider-${JSON.stringify(item)}-${idx}`)) : item.type === 'subHeader' ? ((0, jsx_runtime_1.jsx)(material_1.ListSubheader, { children: item.label }, `subHeader-${item.label}-${idx}`)) : ((0, jsx_runtime_1.jsxs)(CascadingMenuItem, { closeAfterItemClick: closeAfterItemClick, onClick: 'onClick' in item
78
+ ? event => {
79
+ onMenuItemClick(event, item.onClick);
80
+ }
81
+ : undefined, disabled: Boolean(item.disabled), children: [item.icon ? ((0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(item.icon, {}) })) : null, ' ', (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: item.label, secondary: item.subLabel, inset: hasIcon && !item.icon }), (0, jsx_runtime_1.jsx)(CascadingSpacer, {}), (0, jsx_runtime_1.jsx)(EndDecoration, { item: item })] }, `${item.label}-${idx}`));
74
82
  }) }));
75
83
  }
84
+ function CascadingSpacer() {
85
+ return (0, jsx_runtime_1.jsx)("div", { style: { flexGrow: 1, minWidth: 10 } });
86
+ }
76
87
  function CascadingMenuChildren(props) {
77
88
  const { closeAfterItemClick = true, ...rest } = props;
78
89
  return ((0, jsx_runtime_1.jsx)(CascadingMenu, { ...rest, children: (0, jsx_runtime_1.jsx)(CascadingMenuList, { ...rest, closeAfterItemClick: closeAfterItemClick }) }));
@@ -7,14 +7,11 @@ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const react_1 = require("react");
8
8
  const CascadingMenu_1 = __importDefault(require("@jbrowse/core/ui/CascadingMenu"));
9
9
  const material_1 = require("@mui/material");
10
- const hooks_1 = require("material-ui-popup-state/hooks");
11
10
  const mobx_react_1 = require("mobx-react");
11
+ const hooks_1 = require("./hooks");
12
12
  const CascadingMenuButton = (0, mobx_react_1.observer)(function CascadingMenuButton({ children, menuItems, closeAfterItemClick = true, stopPropagation, setOpen, onClick: onClickExtra, ...rest }) {
13
- const popupState = (0, hooks_1.usePopupState)({
14
- popupId: 'viewMenu',
15
- variant: 'popover',
16
- });
17
- const { onClick, onTouchStart, ...rest2 } = (0, hooks_1.bindTrigger)(popupState);
13
+ const popupState = (0, hooks_1.usePopupState)();
14
+ const { onClick, ...rest2 } = (0, hooks_1.bindTrigger)(popupState);
18
15
  const { isOpen } = popupState;
19
16
  (0, react_1.useEffect)(() => {
20
17
  setOpen === null || setOpen === void 0 ? void 0 : setOpen(isOpen);
@@ -25,12 +22,6 @@ const CascadingMenuButton = (0, mobx_react_1.observer)(function CascadingMenuBut
25
22
  }
26
23
  onClick(event);
27
24
  onClickExtra === null || onClickExtra === void 0 ? void 0 : onClickExtra();
28
- }, onTouchStart: event => {
29
- if (stopPropagation) {
30
- event.stopPropagation();
31
- }
32
- onTouchStart(event);
33
- onClickExtra === null || onClickExtra === void 0 ? void 0 : onClickExtra();
34
25
  }, ...rest2, ...rest, disabled: menuItems.length === 0, children: children }), (0, jsx_runtime_1.jsx)(CascadingMenu_1.default, { ...(0, hooks_1.bindPopover)(popupState), onMenuItemClick: (_, callback) => {
35
26
  callback();
36
27
  }, menuItems: menuItems, closeAfterItemClick: closeAfterItemClick, popupState: popupState })] }));
@@ -1,7 +1,8 @@
1
1
  import type { MenuItem } from './Menu';
2
+ import type { AbstractSessionModel } from '../util';
2
3
  declare const DropDownMenu: ({ menuTitle, session, menuItems, }: {
3
4
  menuTitle: string;
4
- session: any;
5
- menuItems: MenuItem[];
5
+ session: AbstractSessionModel;
6
+ menuItems: MenuItem[] | (() => MenuItem[]);
6
7
  }) => import("react/jsx-runtime").JSX.Element;
7
8
  export default DropDownMenu;
@@ -27,11 +27,11 @@ const DropDownMenu = (0, mobx_react_1.observer)(function ({ menuTitle, session,
27
27
  function handleClose() {
28
28
  setOpen(false);
29
29
  }
30
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Button, { ref: anchorEl, onClick: () => {
30
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Button, { ref: anchorEl, color: "inherit", "data-testid": "dropDownMenuButton", classes: { root: classes.buttonRoot }, onClick: () => {
31
31
  setOpen(!open);
32
- }, color: "inherit", "data-testid": "dropDownMenuButton", classes: { root: classes.buttonRoot }, children: [menuTitle, (0, jsx_runtime_1.jsx)(ArrowDropDown_1.default, {})] }), (0, jsx_runtime_1.jsx)(Menu_1.default, { anchorEl: anchorEl.current, anchorOrigin: { vertical: 'bottom', horizontal: 'left' }, onMenuItemClick: (_event, callback) => {
32
+ }, children: [menuTitle, (0, jsx_runtime_1.jsx)(ArrowDropDown_1.default, {})] }), open ? ((0, jsx_runtime_1.jsx)(Menu_1.default, { open: true, anchorEl: anchorEl.current, anchorOrigin: { vertical: 'bottom', horizontal: 'left' }, onClose: handleClose, menuItems: typeof menuItems === 'function' ? menuItems() : menuItems, onMenuItemClick: (_event, callback) => {
33
33
  callback(session);
34
34
  handleClose();
35
- }, open: open, onClose: handleClose, menuItems: menuItems })] }));
35
+ } })) : null] }));
36
36
  });
37
37
  exports.default = DropDownMenu;
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import type { MenuProps } from '@mui/material';
3
+ declare const HoverMenu: React.ComponentType<MenuProps>;
4
+ export default HoverMenu;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const jsx_runtime_1 = require("react/jsx-runtime");
37
+ const React = __importStar(require("react"));
38
+ const material_1 = require("@mui/material");
39
+ const HoverMenu = React.forwardRef(function HoverMenu(props, ref) {
40
+ return ((0, jsx_runtime_1.jsx)(material_1.Menu, { ...props, ref: ref, style: {
41
+ pointerEvents: 'none',
42
+ ...props.style,
43
+ }, slotProps: {
44
+ ...props.slotProps,
45
+ paper: {
46
+ style: { pointerEvents: 'auto' },
47
+ },
48
+ } }));
49
+ });
50
+ exports.default = HoverMenu;
package/ui/Icons.d.ts CHANGED
@@ -1,10 +1,5 @@
1
1
  import type { SvgIconProps } from '@mui/material/SvgIcon';
2
- export declare function ContentCopy(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
3
2
  export declare function Indexing(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
4
- export declare function ContentCut(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
5
- export declare function ContentPaste(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
6
3
  export declare function TrackSelector(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
7
- export declare function SaveAs(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
8
- export declare function Save(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
9
4
  export declare function DNA(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
10
5
  export declare function Cable(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
package/ui/Icons.js CHANGED
@@ -3,38 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ContentCopy = ContentCopy;
7
6
  exports.Indexing = Indexing;
8
- exports.ContentCut = ContentCut;
9
- exports.ContentPaste = ContentPaste;
10
7
  exports.TrackSelector = TrackSelector;
11
- exports.SaveAs = SaveAs;
12
- exports.Save = Save;
13
8
  exports.DNA = DNA;
14
9
  exports.Cable = Cable;
15
10
  const jsx_runtime_1 = require("react/jsx-runtime");
16
11
  const SvgIcon_1 = __importDefault(require("@mui/material/SvgIcon"));
17
- function ContentCopy(props) {
18
- return ((0, jsx_runtime_1.jsx)(SvgIcon_1.default, { ...props, children: (0, jsx_runtime_1.jsx)("path", { d: "M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" }) }));
19
- }
20
12
  function Indexing(props) {
21
13
  return ((0, jsx_runtime_1.jsx)(SvgIcon_1.default, { ...props, children: (0, jsx_runtime_1.jsx)("path", { d: "M19.31 18.9L22.39 22L21 23.39L17.88 20.32C17.19 20.75 16.37 21 15.5 21C13 21 11 19 11 16.5C11 14 13 12 15.5 12C18 12 20 14 20 16.5C20 17.38 19.75 18.21 19.31 18.9M15.5 19C16.88 19 18 17.88 18 16.5C18 15.12 16.88 14 15.5 14C14.12 14 13 15.12 13 16.5C13 17.88 14.12 19 15.5 19M21 4V6H3V4H21M3 16V14H9V16H3M3 11V9H21V11H18.97C17.96 10.37 16.77 10 15.5 10C14.23 10 13.04 10.37 12.03 11H3Z" }) }));
22
14
  }
23
- function ContentCut(props) {
24
- return ((0, jsx_runtime_1.jsx)(SvgIcon_1.default, { ...props, children: (0, jsx_runtime_1.jsx)("path", { d: "M19,3L13,9L15,11L22,4V3M12,12.5A0.5,0.5 0 0,1 11.5,12A0.5,0.5 0 0,1 12,11.5A0.5,0.5 0 0,1 12.5,12A0.5,0.5 0 0,1 12,12.5M6,20A2,2 0 0,1 4,18C4,16.89 4.9,16 6,16A2,2 0 0,1 8,18C8,19.11 7.1,20 6,20M6,8A2,2 0 0,1 4,6C4,4.89 4.9,4 6,4A2,2 0 0,1 8,6C8,7.11 7.1,8 6,8M9.64,7.64C9.87,7.14 10,6.59 10,6A4,4 0 0,0 6,2A4,4 0 0,0 2,6A4,4 0 0,0 6,10C6.59,10 7.14,9.87 7.64,9.64L10,12L7.64,14.36C7.14,14.13 6.59,14 6,14A4,4 0 0,0 2,18A4,4 0 0,0 6,22A4,4 0 0,0 10,18C10,17.41 9.87,16.86 9.64,16.36L12,14L19,21H22V20L9.64,7.64Z" }) }));
25
- }
26
- function ContentPaste(props) {
27
- return ((0, jsx_runtime_1.jsx)(SvgIcon_1.default, { ...props, children: (0, jsx_runtime_1.jsx)("path", { d: "M19,20H5V4H7V7H17V4H19M12,2A1,1 0 0,1 13,3A1,1 0 0,1 12,4A1,1 0 0,1 11,3A1,1 0 0,1 12,2M19,2H14.82C14.4,0.84 13.3,0 12,0C10.7,0 9.6,0.84 9.18,2H5A2,2 0 0,0 3,4V20A2,2 0 0,0 5,22H19A2,2 0 0,0 21,20V4A2,2 0 0,0 19,2Z" }) }));
28
- }
29
15
  function TrackSelector(props) {
30
16
  return ((0, jsx_runtime_1.jsx)(SvgIcon_1.default, { ...props, children: (0, jsx_runtime_1.jsx)("path", { d: "M21 19v-2H8v2h13m0-6v-2H8v2h13M8 7h13V5H8v2M4 5v2h2V5H4M3 5a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 01-1 1H4a1 1 0 01-1-1V5m1 6v2h2v-2H4m-1 0a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 01-1 1H4a1 1 0 01-1-1v-2m1 6v2h2v-2H4m-1 0a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 01-1 1H4a1 1 0 01-1-1v-2z" }) }));
31
17
  }
32
- function SaveAs(props) {
33
- return ((0, jsx_runtime_1.jsx)(SvgIcon_1.default, { ...props, children: (0, jsx_runtime_1.jsx)("path", { fill: "currentColor", d: "M10,19L10.14,18.86C8.9,18.5 8,17.36 8,16A3,3 0 0,1 11,13C12.36,13 13.5,13.9 13.86,15.14L20,9V7L16,3H4C2.89,3 2,3.9 2,5V19A2,2 0 0,0 4,21H10V19M4,5H14V9H4V5M20.04,12.13C19.9,12.13 19.76,12.19 19.65,12.3L18.65,13.3L20.7,15.35L21.7,14.35C21.92,14.14 21.92,13.79 21.7,13.58L20.42,12.3C20.31,12.19 20.18,12.13 20.04,12.13M18.07,13.88L12,19.94V22H14.06L20.12,15.93L18.07,13.88Z" }) }));
34
- }
35
- function Save(props) {
36
- return ((0, jsx_runtime_1.jsx)(SvgIcon_1.default, { ...props, children: (0, jsx_runtime_1.jsx)("path", { fill: "currentColor", d: "M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z" }) }));
37
- }
38
18
  function DNA(props) {
39
19
  return ((0, jsx_runtime_1.jsx)(SvgIcon_1.default, { ...props, children: (0, jsx_runtime_1.jsx)("path", { fill: "currentColor", d: "M4,2H6V4C6,5.44 6.68,6.61 7.88,7.78C8.74,8.61 9.89,9.41 11.09,10.2L9.26,11.39C8.27,10.72 7.31,10 6.5,9.21C5.07,7.82 4,6.1 4,4V2M18,2H20V4C20,6.1 18.93,7.82 17.5,9.21C16.09,10.59 14.29,11.73 12.54,12.84C10.79,13.96 9.09,15.05 7.88,16.22C6.68,17.39 6,18.56 6,20V22H4V20C4,17.9 5.07,16.18 6.5,14.79C7.91,13.41 9.71,12.27 11.46,11.16C13.21,10.04 14.91,8.95 16.12,7.78C17.32,6.61 18,5.44 18,4V2M14.74,12.61C15.73,13.28 16.69,14 17.5,14.79C18.93,16.18 20,17.9 20,20V22H18V20C18,18.56 17.32,17.39 16.12,16.22C15.26,15.39 14.11,14.59 12.91,13.8L14.74,12.61M7,3H17V4L16.94,4.5H7.06L7,4V3M7.68,6H16.32C16.08,6.34 15.8,6.69 15.42,7.06L14.91,7.5H9.07L8.58,7.06C8.2,6.69 7.92,6.34 7.68,6M9.09,16.5H14.93L15.42,16.94C15.8,17.31 16.08,17.66 16.32,18H7.68C7.92,17.66 8.2,17.31 8.58,16.94L9.09,16.5M7.06,19.5H16.94L17,20V21H7V20L7.06,19.5Z" }) }));
40
20
  }
package/ui/hooks.d.ts ADDED
@@ -0,0 +1,66 @@
1
+ import { type SyntheticEvent } from 'react';
2
+ import * as React from 'react';
3
+ export interface ChildHandle {
4
+ close: () => void;
5
+ popupId: string;
6
+ }
7
+ export interface PopupState {
8
+ open: (event?: React.MouseEvent | React.FocusEvent) => void;
9
+ close: (event?: React.MouseEvent) => void;
10
+ toggle: (event?: React.MouseEvent) => void;
11
+ setOpen: (open: boolean, eventOrAnchorEl?: SyntheticEvent | Element) => void;
12
+ isOpen: boolean;
13
+ anchorEl: Element | undefined;
14
+ setAnchorEl: (anchorEl: Element | undefined) => any;
15
+ setAnchorElUsed: boolean;
16
+ popupId: string | undefined;
17
+ hovered: boolean;
18
+ focused: boolean;
19
+ _openEventType?: string;
20
+ childHandle?: ChildHandle;
21
+ setChildHandle: (popupState?: ChildHandle) => void;
22
+ }
23
+ export interface CoreState {
24
+ isOpen: boolean;
25
+ setAnchorElUsed: boolean;
26
+ anchorEl: Element | undefined;
27
+ hovered: boolean;
28
+ focused: boolean;
29
+ _openEventType?: string;
30
+ _childHandle?: PopupState;
31
+ }
32
+ export declare function usePopupState(arg?: {
33
+ parentPopupState?: PopupState;
34
+ variant?: string;
35
+ }): PopupState;
36
+ export declare function bindTrigger(popupState: PopupState): {
37
+ onClick: (event?: React.MouseEvent | React.FocusEvent) => void;
38
+ };
39
+ export declare function bindToggle(popupState: PopupState): {
40
+ onClick: (event?: React.MouseEvent) => void;
41
+ };
42
+ export declare function bindHover(popupState: PopupState): {
43
+ onMouseOver: (event?: React.MouseEvent | React.FocusEvent) => void;
44
+ };
45
+ export declare function bindFocus(popupState: PopupState): {
46
+ onFocus: (event?: React.MouseEvent | React.FocusEvent) => void;
47
+ };
48
+ export declare function bindPopover({ isOpen, anchorEl, close, popupId }: PopupState): {
49
+ id: string | undefined;
50
+ anchorEl: Element | undefined;
51
+ anchorReference: "anchorEl";
52
+ open: boolean;
53
+ onClose: (event?: React.MouseEvent) => void;
54
+ };
55
+ export declare function bindMenu({ isOpen, anchorEl, close, popupId }: PopupState): {
56
+ id: string | undefined;
57
+ anchorEl: Element | undefined;
58
+ anchorReference: "anchorEl";
59
+ open: boolean;
60
+ onClose: (event?: React.MouseEvent) => void;
61
+ };
62
+ export declare function bindPopper({ isOpen, anchorEl, popupId }: PopupState): {
63
+ id: string | undefined;
64
+ anchorEl: Element | undefined;
65
+ open: boolean;
66
+ };
package/ui/hooks.js ADDED
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.usePopupState = usePopupState;
37
+ exports.bindTrigger = bindTrigger;
38
+ exports.bindToggle = bindToggle;
39
+ exports.bindHover = bindHover;
40
+ exports.bindFocus = bindFocus;
41
+ exports.bindPopover = bindPopover;
42
+ exports.bindMenu = bindMenu;
43
+ exports.bindPopper = bindPopper;
44
+ const react_1 = require("react");
45
+ const React = __importStar(require("react"));
46
+ function usePopupState(arg) {
47
+ const { parentPopupState } = arg || {};
48
+ const popupId = React.useId();
49
+ const [isOpen, setIsOpen] = (0, react_1.useState)(false);
50
+ const [setAnchorElUsed, setSetAnchorElUsed] = (0, react_1.useState)(false);
51
+ const [anchorEl, _setAnchorEl] = (0, react_1.useState)();
52
+ const [hovered, setHovered] = (0, react_1.useState)(false);
53
+ const [focused, setFocused] = (0, react_1.useState)(false);
54
+ const [openEventType, setOpenEventType] = (0, react_1.useState)();
55
+ const [childHandle, setChildHandle] = (0, react_1.useState)();
56
+ const setAnchorEl = (0, react_1.useCallback)((el) => {
57
+ setSetAnchorElUsed(true);
58
+ _setAnchorEl(el);
59
+ }, []);
60
+ const toggle = (eventOrAnchorEl) => {
61
+ if (isOpen) {
62
+ close(eventOrAnchorEl);
63
+ }
64
+ else {
65
+ open(eventOrAnchorEl);
66
+ }
67
+ };
68
+ const open = (eventOrAnchorEl) => {
69
+ const event = eventOrAnchorEl instanceof Element ? undefined : eventOrAnchorEl;
70
+ const element = eventOrAnchorEl instanceof Element
71
+ ? eventOrAnchorEl
72
+ : (eventOrAnchorEl === null || eventOrAnchorEl === void 0 ? void 0 : eventOrAnchorEl.currentTarget) instanceof Element
73
+ ? eventOrAnchorEl.currentTarget
74
+ : undefined;
75
+ if ((event === null || event === void 0 ? void 0 : event.type) === 'touchstart') {
76
+ return;
77
+ }
78
+ if (parentPopupState) {
79
+ if (!parentPopupState.isOpen) {
80
+ return;
81
+ }
82
+ parentPopupState.setChildHandle(undefined);
83
+ setTimeout(() => {
84
+ parentPopupState.setChildHandle({
85
+ popupId,
86
+ close,
87
+ });
88
+ });
89
+ }
90
+ setIsOpen(true);
91
+ setHovered(prev => (event === null || event === void 0 ? void 0 : event.type) === 'mouseover' || prev);
92
+ setFocused(prev => (event === null || event === void 0 ? void 0 : event.type) === 'focus' || prev);
93
+ setOpenEventType(event === null || event === void 0 ? void 0 : event.type);
94
+ if (!setAnchorElUsed) {
95
+ if (event === null || event === void 0 ? void 0 : event.currentTarget) {
96
+ _setAnchorEl(event.currentTarget);
97
+ }
98
+ else if (element) {
99
+ _setAnchorEl(element);
100
+ }
101
+ }
102
+ };
103
+ const close = (eventOrAnchorEl) => {
104
+ const event = eventOrAnchorEl instanceof Element ? undefined : eventOrAnchorEl;
105
+ if ((event === null || event === void 0 ? void 0 : event.type) === 'touchstart') {
106
+ return;
107
+ }
108
+ childHandle === null || childHandle === void 0 ? void 0 : childHandle.close();
109
+ parentPopupState === null || parentPopupState === void 0 ? void 0 : parentPopupState.setChildHandle(undefined);
110
+ setIsOpen(false);
111
+ setHovered(false);
112
+ setFocused(false);
113
+ };
114
+ const setOpen = (nextOpen, eventOrAnchorEl) => {
115
+ if (nextOpen) {
116
+ open(eventOrAnchorEl);
117
+ }
118
+ else {
119
+ close(eventOrAnchorEl);
120
+ }
121
+ };
122
+ return {
123
+ isOpen,
124
+ anchorEl,
125
+ setAnchorElUsed,
126
+ setAnchorEl,
127
+ popupId,
128
+ open,
129
+ close,
130
+ toggle,
131
+ setOpen,
132
+ hovered,
133
+ focused,
134
+ _openEventType: openEventType,
135
+ childHandle,
136
+ setChildHandle,
137
+ };
138
+ }
139
+ function bindTrigger(popupState) {
140
+ return {
141
+ onClick: popupState.open,
142
+ };
143
+ }
144
+ function bindToggle(popupState) {
145
+ return {
146
+ onClick: popupState.toggle,
147
+ };
148
+ }
149
+ function bindHover(popupState) {
150
+ const { open } = popupState;
151
+ return {
152
+ onMouseOver: open,
153
+ };
154
+ }
155
+ function bindFocus(popupState) {
156
+ const { open } = popupState;
157
+ return {
158
+ onFocus: open,
159
+ };
160
+ }
161
+ function bindPopover({ isOpen, anchorEl, close, popupId }) {
162
+ return {
163
+ id: popupId,
164
+ anchorEl,
165
+ anchorReference: 'anchorEl',
166
+ open: isOpen,
167
+ onClose: close,
168
+ };
169
+ }
170
+ function bindMenu({ isOpen, anchorEl, close, popupId }) {
171
+ return {
172
+ id: popupId,
173
+ anchorEl,
174
+ anchorReference: 'anchorEl',
175
+ open: isOpen,
176
+ onClose: close,
177
+ };
178
+ }
179
+ function bindPopper({ isOpen, anchorEl, popupId }) {
180
+ return {
181
+ id: popupId,
182
+ anchorEl,
183
+ open: isOpen,
184
+ };
185
+ }
@@ -59,7 +59,7 @@ function u(e) {
59
59
  const t = (0, react_1.useRef)(e), o = (0, react_1.useRef)(e => {
60
60
  t.current && t.current(e);
61
61
  });
62
- return (t.current = e), o.current;
62
+ return ((t.current = e), o.current);
63
63
  }
64
64
  const i = (e, r = 0, t = 1) => (e > t ? t : e < r ? r : e), d = e => 'touches' in e, f = e => (e && e.ownerDocument.defaultView) || self, h = (e, r, t) => {
65
65
  const o = e.getBoundingClientRect(), a = d(r)
@@ -80,14 +80,16 @@ const i = (e, r = 0, t = 1) => (e > t ? t : e < r ? r : e), d = e => 'touches' i
80
80
  let { onMove: l, onKey: n } = a, i = c(a, ['onMove', 'onKey']);
81
81
  const m = (0, react_1.useRef)(null), g = u(l), p = u(n), b = (0, react_1.useRef)(null), _ = (0, react_1.useRef)(!1), [x, C, E] = (0, react_1.useMemo)(() => {
82
82
  const e = e => {
83
- v(e),
83
+ ;
84
+ (v(e),
84
85
  (d(e) ? e.touches.length > 0 : e.buttons > 0) && m.current
85
86
  ? g(h(m.current, e, b.current))
86
- : t(!1);
87
+ : t(!1));
87
88
  }, r = () => t(!1);
88
89
  function t(t) {
89
90
  const o = _.current, a = f(m.current), l = t ? a.addEventListener : a.removeEventListener;
90
- l(o ? 'touchmove' : 'mousemove', e), l(o ? 'touchend' : 'mouseup', r);
91
+ (l(o ? 'touchmove' : 'mousemove', e),
92
+ l(o ? 'touchend' : 'mouseup', r));
91
93
  }
92
94
  return [
93
95
  ({ nativeEvent: e }) => {
@@ -98,7 +100,8 @@ const i = (e, r = 0, t = 1) => (e > t ? t : e < r ? r : e), d = e => 'touches' i
98
100
  const r = e.changedTouches || [];
99
101
  r.length && (b.current = r[0].identifier);
100
102
  }
101
- r.focus(), g(h(r, e, b.current)), t(!0);
103
+ ;
104
+ (r.focus(), g(h(r, e, b.current)), t(!0));
102
105
  }
103
106
  },
104
107
  e => {
@@ -174,7 +177,7 @@ const i = (e, r = 0, t = 1) => (e > t ? t : e < r ? r : e), d = e => 'touches' i
174
177
  return `hsla(${r}, ${t}%, ${o}%, ${a})`;
175
178
  }, y = ({ h: e, s: r, v: t, a: o }) => {
176
179
  ;
177
- (e = (e / 360) * 6), (r /= 100), (t /= 100);
180
+ ((e = (e / 360) * 6), (r /= 100), (t /= 100));
178
181
  const a = Math.floor(e), l = t * (1 - r), n = t * (1 - (e - a) * r), s = t * (1 - (1 - e + a) * r), c = a % 6;
179
182
  return {
180
183
  r: b(255 * [t, n, l, l, s, t][c]),
@@ -265,10 +268,10 @@ const i = (e, r = 0, t = 1) => (e > t ? t : e < r ? r : e), d = e => 'touches' i
265
268
  }, A = (e, r) => e.replace(/\s/g, '') === r.replace(/\s/g, '');
266
269
  function S(e, t, n) {
267
270
  const s = u(n), [c, i] = (0, react_1.useState)(() => e.toHsva(t)), d = (0, react_1.useRef)({ color: t, hsva: c });
268
- (0, react_1.useEffect)(() => {
271
+ ((0, react_1.useEffect)(() => {
269
272
  if (!e.equal(t, d.current.color)) {
270
273
  const r = e.toHsva(t);
271
- (d.current = { hsva: r, color: t }), i(r);
274
+ ((d.current = { hsva: r, color: t }), i(r));
272
275
  }
273
276
  }, [t, e]),
274
277
  (0, react_1.useEffect)(() => {
@@ -276,7 +279,7 @@ function S(e, t, n) {
276
279
  L(c, d.current.hsva) ||
277
280
  e.equal((r = e.fromHsva(c)), d.current.color) ||
278
281
  ((d.current = { hsva: c, color: r }), s(r));
279
- }, [c, e, s]);
282
+ }, [c, e, s]));
280
283
  const f = (0, react_1.useCallback)(e => {
281
284
  i(r => Object.assign({}, r, e));
282
285
  }, []);
@@ -291,11 +294,11 @@ const P = () => F || ('undefined' != typeof __webpack_nonce__ ? __webpack_nonce_
291
294
  const r = e.current ? e.current.ownerDocument : document;
292
295
  if (void 0 !== r && !Y.has(r)) {
293
296
  const e = r.createElement('style');
294
- (e.innerHTML =
297
+ ((e.innerHTML =
295
298
  '.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url(\'data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>\')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}'),
296
- Y.set(r, e);
299
+ Y.set(r, e));
297
300
  const t = P();
298
- t && e.setAttribute('nonce', t), r.head.appendChild(e);
301
+ (t && e.setAttribute('nonce', t), r.head.appendChild(e));
299
302
  }
300
303
  }, []);
301
304
  }, V = t => {
@@ -420,9 +423,10 @@ const P = () => F || ('undefined' != typeof __webpack_nonce__ ? __webpack_nonce_
420
423
  'process',
421
424
  ]), [g, p] = (0, react_1.useState)(() => d(t)), b = u(n), _ = u(i), x = (0, react_1.useCallback)(e => {
422
425
  const r = d(e.target.value);
423
- p(r), f(r) && b(v ? v(r) : r);
426
+ (p(r), f(r) && b(v ? v(r) : r));
424
427
  }, [d, v, f, b]), C = (0, react_1.useCallback)(e => {
425
- f(e.target.value) || p(d(t)), _(e);
428
+ ;
429
+ (f(e.target.value) || p(d(t)), _(e));
426
430
  }, [t, d, f, _]);
427
431
  return ((0, react_1.useEffect)(() => {
428
432
  p(d(t));
@@ -0,0 +1 @@
1
+ export declare function useEvent<Fn extends (...args: any[]) => any>(handler: Fn): Fn;