@vuu-ui/vuu-popups 0.8.93 → 0.8.95
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/cjs/dialog/useDialog.js +5 -2
- package/cjs/dialog/useDialog.js.map +1 -1
- package/cjs/menu/ContextMenu.js +1 -2
- package/cjs/menu/ContextMenu.js.map +1 -1
- package/cjs/notifications/NotificationsProvider.js +6 -3
- package/cjs/notifications/NotificationsProvider.js.map +1 -1
- package/cjs/popup/popup-service.js +14 -9
- package/cjs/popup/popup-service.js.map +1 -1
- package/cjs/prompt/Prompt.js +1 -1
- package/esm/dialog/useDialog.js +5 -2
- package/esm/dialog/useDialog.js.map +1 -1
- package/esm/menu/ContextMenu.js +1 -2
- package/esm/menu/ContextMenu.js.map +1 -1
- package/esm/notifications/NotificationsProvider.js +6 -3
- package/esm/notifications/NotificationsProvider.js.map +1 -1
- package/esm/popup/popup-service.js +14 -9
- package/esm/popup/popup-service.js.map +1 -1
- package/esm/prompt/Prompt.js +1 -1
- package/package.json +5 -5
package/cjs/dialog/useDialog.js
CHANGED
|
@@ -4,6 +4,9 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var core = require('@salt-ds/core');
|
|
5
5
|
var React = require('react');
|
|
6
6
|
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
10
|
const useDialog = () => {
|
|
8
11
|
const [dialogState, setDialogState] = React.useState();
|
|
9
12
|
const closeDialog = React.useCallback(() => {
|
|
@@ -43,8 +46,8 @@ const defaultCloseDialog = () => {
|
|
|
43
46
|
};
|
|
44
47
|
class DialogContextObject {
|
|
45
48
|
constructor() {
|
|
46
|
-
this
|
|
47
|
-
this
|
|
49
|
+
__publicField(this, "showDialog", defaultShowDialog);
|
|
50
|
+
__publicField(this, "closeDialog", defaultCloseDialog);
|
|
48
51
|
}
|
|
49
52
|
setDialogDispatchers(showDialog, closeDialog) {
|
|
50
53
|
this.showDialog = showDialog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDialog.js","sources":["../../src/dialog/useDialog.tsx"],"sourcesContent":["import {\n Dialog,\n DialogActions,\n DialogCloseButton,\n DialogContent,\n DialogHeader,\n} from \"@salt-ds/core\";\nimport {\n createContext,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nexport type DialogState = {\n actions?: ReactElement[];\n content: ReactElement;\n title: string;\n hideCloseButton?: boolean;\n};\n\nexport type SetDialog = (dialogState?: DialogState) => void;\n\nexport type ShowDialog = (\n dialogContent: ReactElement,\n title: string,\n dialogActionButtons?: ReactElement[],\n hideCloseButton?: boolean\n) => void;\n\nexport interface DialogContextProps {\n showDialog: ShowDialog;\n closeDialog: () => void;\n setDialogDispatchers: (\n showDialog: ShowDialog,\n closeDialog: () => void\n ) => void;\n}\n\nexport const useDialog = () => {\n const [dialogState, setDialogState] = useState<DialogState>();\n\n const closeDialog = useCallback(() => {\n setDialogState(undefined);\n }, []);\n\n const handleOpenChange = useCallback(\n (open?: boolean) => {\n if (open !== true) {\n closeDialog();\n }\n },\n [closeDialog]\n );\n\n const dialog = dialogState ? (\n <Dialog open={true} onOpenChange={handleOpenChange}>\n <DialogHeader header={dialogState.title} />\n <DialogContent>{dialogState.content}</DialogContent>\n {dialogState.hideCloseButton !== true ? (\n <DialogCloseButton\n data-embedded\n data-icon=\"close\"\n onClick={closeDialog}\n />\n ) : null}\n {dialogState.actions ? (\n <DialogActions>{dialogState.actions}</DialogActions>\n ) : null}\n </Dialog>\n ) : null;\n\n return {\n dialog,\n setDialogState,\n };\n};\n\nconst defaultShowDialog: ShowDialog = () => {\n console.warn(\"No DialogProvider in place\");\n};\nconst defaultCloseDialog = () => {\n console.warn(\"No DialogProvider in place\");\n};\n\nclass DialogContextObject implements DialogContextProps {\n showDialog = defaultShowDialog;\n closeDialog = defaultCloseDialog;\n setDialogDispatchers(showDialog: ShowDialog, closeDialog: () => void) {\n this.showDialog = showDialog;\n this.closeDialog = closeDialog;\n }\n}\n\nconst DialogContext = createContext<DialogContextProps>(\n new DialogContextObject()\n);\n\nconst DialogHost = ({ context }: { context: DialogContextProps }) => {\n const { dialog, setDialogState } = useDialog();\n const showDialog: ShowDialog = useCallback(\n (dialogContent, title, actionButtons, hideCloseButton) => {\n setDialogState({\n actions: actionButtons,\n content: dialogContent,\n title,\n hideCloseButton,\n });\n },\n [setDialogState]\n );\n const closeDialog = useCallback(() => {\n setDialogState(undefined);\n }, [setDialogState]);\n\n useMemo(() => {\n context.setDialogDispatchers(showDialog, closeDialog);\n }, [closeDialog, context, showDialog]);\n return dialog;\n};\n\nexport const DialogProvider = ({ children }: { children: ReactNode }) => {\n const context = useContext(DialogContext);\n return (\n <DialogContext.Provider value={context}>\n <DialogHost context={context} />\n {children}\n </DialogContext.Provider>\n );\n};\n\nexport const useDialogContext = () => {\n const { closeDialog, showDialog } = useContext(DialogContext);\n return { showDialog, closeDialog };\n};\n"],"names":["useState","useCallback","jsxs","Dialog","jsx","DialogHeader","DialogContent","DialogCloseButton","DialogActions","createContext","useMemo","useContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDialog.js","sources":["../../src/dialog/useDialog.tsx"],"sourcesContent":["import {\n Dialog,\n DialogActions,\n DialogCloseButton,\n DialogContent,\n DialogHeader,\n} from \"@salt-ds/core\";\nimport {\n createContext,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nexport type DialogState = {\n actions?: ReactElement[];\n content: ReactElement;\n title: string;\n hideCloseButton?: boolean;\n};\n\nexport type SetDialog = (dialogState?: DialogState) => void;\n\nexport type ShowDialog = (\n dialogContent: ReactElement,\n title: string,\n dialogActionButtons?: ReactElement[],\n hideCloseButton?: boolean\n) => void;\n\nexport interface DialogContextProps {\n showDialog: ShowDialog;\n closeDialog: () => void;\n setDialogDispatchers: (\n showDialog: ShowDialog,\n closeDialog: () => void\n ) => void;\n}\n\nexport const useDialog = () => {\n const [dialogState, setDialogState] = useState<DialogState>();\n\n const closeDialog = useCallback(() => {\n setDialogState(undefined);\n }, []);\n\n const handleOpenChange = useCallback(\n (open?: boolean) => {\n if (open !== true) {\n closeDialog();\n }\n },\n [closeDialog]\n );\n\n const dialog = dialogState ? (\n <Dialog open={true} onOpenChange={handleOpenChange}>\n <DialogHeader header={dialogState.title} />\n <DialogContent>{dialogState.content}</DialogContent>\n {dialogState.hideCloseButton !== true ? (\n <DialogCloseButton\n data-embedded\n data-icon=\"close\"\n onClick={closeDialog}\n />\n ) : null}\n {dialogState.actions ? (\n <DialogActions>{dialogState.actions}</DialogActions>\n ) : null}\n </Dialog>\n ) : null;\n\n return {\n dialog,\n setDialogState,\n };\n};\n\nconst defaultShowDialog: ShowDialog = () => {\n console.warn(\"No DialogProvider in place\");\n};\nconst defaultCloseDialog = () => {\n console.warn(\"No DialogProvider in place\");\n};\n\nclass DialogContextObject implements DialogContextProps {\n showDialog = defaultShowDialog;\n closeDialog = defaultCloseDialog;\n setDialogDispatchers(showDialog: ShowDialog, closeDialog: () => void) {\n this.showDialog = showDialog;\n this.closeDialog = closeDialog;\n }\n}\n\nconst DialogContext = createContext<DialogContextProps>(\n new DialogContextObject()\n);\n\nconst DialogHost = ({ context }: { context: DialogContextProps }) => {\n const { dialog, setDialogState } = useDialog();\n const showDialog: ShowDialog = useCallback(\n (dialogContent, title, actionButtons, hideCloseButton) => {\n setDialogState({\n actions: actionButtons,\n content: dialogContent,\n title,\n hideCloseButton,\n });\n },\n [setDialogState]\n );\n const closeDialog = useCallback(() => {\n setDialogState(undefined);\n }, [setDialogState]);\n\n useMemo(() => {\n context.setDialogDispatchers(showDialog, closeDialog);\n }, [closeDialog, context, showDialog]);\n return dialog;\n};\n\nexport const DialogProvider = ({ children }: { children: ReactNode }) => {\n const context = useContext(DialogContext);\n return (\n <DialogContext.Provider value={context}>\n <DialogHost context={context} />\n {children}\n </DialogContext.Provider>\n );\n};\n\nexport const useDialogContext = () => {\n const { closeDialog, showDialog } = useContext(DialogContext);\n return { showDialog, closeDialog };\n};\n"],"names":["useState","useCallback","jsxs","Dialog","jsx","DialogHeader","DialogContent","DialogCloseButton","DialogActions","createContext","useMemo","useContext"],"mappings":";;;;;;;;;AA0CO,MAAM,YAAY,MAAM;AAC7B,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAIA,cAAsB,EAAA,CAAA;AAE5D,EAAM,MAAA,WAAA,GAAcC,kBAAY,MAAM;AACpC,IAAA,cAAA,CAAe,KAAS,CAAA,CAAA,CAAA;AAAA,GAC1B,EAAG,EAAE,CAAA,CAAA;AAEL,EAAA,MAAM,gBAAmB,GAAAA,iBAAA;AAAA,IACvB,CAAC,IAAmB,KAAA;AAClB,MAAA,IAAI,SAAS,IAAM,EAAA;AACjB,QAAY,WAAA,EAAA,CAAA;AAAA,OACd;AAAA,KACF;AAAA,IACA,CAAC,WAAW,CAAA;AAAA,GACd,CAAA;AAEA,EAAA,MAAM,SAAS,WACb,mBAAAC,eAAA,CAACC,eAAO,IAAM,EAAA,IAAA,EAAM,cAAc,gBAChC,EAAA,QAAA,EAAA;AAAA,oBAACC,cAAA,CAAAC,iBAAA,EAAA,EAAa,MAAQ,EAAA,WAAA,CAAY,KAAO,EAAA,CAAA;AAAA,oBACzCD,cAAA,CAACE,kBAAe,EAAA,EAAA,QAAA,EAAA,WAAA,CAAY,OAAQ,EAAA,CAAA;AAAA,IACnC,WAAA,CAAY,oBAAoB,IAC/B,mBAAAF,cAAA;AAAA,MAACG,sBAAA;AAAA,MAAA;AAAA,QACC,eAAa,EAAA,IAAA;AAAA,QACb,WAAU,EAAA,OAAA;AAAA,QACV,OAAS,EAAA,WAAA;AAAA,OAAA;AAAA,KAET,GAAA,I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AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,IACA,CAAC,cAAc,CAAA;AAAA,GACjB,CAAA;AACA,EAAM,MAAA,WAAA,GAAcA,kBAAY,MAAM;AACpC,IAAA,cAAA,CAAe,KAAS,CAAA,CAAA,CAAA;AAAA,GAC1B,EAAG,CAAC,cAAc,CAAC,CAAA,CAAA;AAEnB,EAAAS,aAAA,CAAQ,MAAM;AACZ,IAAQ,OAAA,CAAA,oBAAA,CAAqB,YAAY,WAAW,CAAA,CAAA;AAAA,GACnD,EAAA,CAAC,WAAa,EAAA,OAAA,EAAS,UAAU,CAAC,CAAA,CAAA;AACrC,EAAO,OAAA,MAAA,CAAA;AACT,CAAA,CAAA;AAEO,MAAM,cAAiB,GAAA,CAAC,EAAE,QAAA,EAAwC,KAAA;AACvE,EAAM,MAAA,OAAA,GAAUC,iBAAW,aAAa,CAAA,CAAA;AACxC,EAAA,uBACGT,eAAA,CAAA,aAAA,CAAc,QAAd,EAAA,EAAuB,OAAO,OAC7B,EAAA,QAAA,EAAA;AAAA,oBAAAE,cAAA,CAAC,cAAW,OAAkB,EAAA,CAAA;AAAA,IAC7B,QAAA;AAAA,GACH,EAAA,CAAA,CAAA;AAEJ,EAAA;AAEO,MAAM,mBAAmB,MAAM;AACpC,EAAA,MAAM,EAAE,WAAA,EAAa,UAAW,EAAA,GAAIO,iBAAW,aAAa,CAAA,CAAA;AAC5D,EAAO,OAAA,EAAE,YAAY,WAAY,EAAA,CAAA;AACnC;;;;;;"}
|
package/cjs/menu/ContextMenu.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var vuuUtils = require('@vuu-ui/vuu-utils');
|
|
6
|
-
require('
|
|
7
|
-
require('react-dom');
|
|
6
|
+
require('../popup/popup-service.js');
|
|
8
7
|
var Popup = require('../popup/Popup.js');
|
|
9
8
|
var Portal = require('../portal/Portal.js');
|
|
10
9
|
var MenuList = require('./MenuList.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","sources":["../../src/menu/ContextMenu.tsx"],"sourcesContent":["import { useId } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useRef } from \"react\";\nimport { PopupCloseCallback, PopupComponent } from \"../popup\";\nimport { Portal, PortalProps } from \"../portal\";\nimport { MenuList, MenuListProps } from \"./MenuList\";\nimport { useCascade } from \"./use-cascade\";\nimport { useItemsWithIdsNext } from \"./use-items-with-ids-next\";\nimport { MenuCloseHandler } from \"./use-keyboard-navigation\";\nimport { ContextMenuOptions } from \"./useContextMenu\";\n\nexport interface ContextMenuProps extends Omit<MenuListProps, \"onCloseMenu\"> {\n PortalProps?: Partial<PortalProps>;\n onClose?: PopupCloseCallback;\n position?: { x: number; y: number };\n withPortal?: boolean;\n}\n\nconst noop = () => undefined;\n\nexport const ContextMenu = ({\n PortalProps,\n activatedByKeyboard,\n children: childrenProp,\n className,\n id: idProp,\n onClose = () => undefined,\n position = { x: 0, y: 0 },\n style,\n ...menuListProps\n}: ContextMenuProps) => {\n const id = useId(idProp);\n const closeMenuRef = useRef<(location?: string) => void>(noop);\n const [menus, actions] = useItemsWithIdsNext(childrenProp, id);\n const navigatingWithKeyboard = useRef(activatedByKeyboard);\n const handleMouseEnterItem = useCallback(() => {\n navigatingWithKeyboard.current = false;\n }, []);\n\n const handleActivate = useCallback(\n (menuItemId: string) => {\n const actionId = menuItemId.slice(9);\n const { action, options } = actions[actionId];\n closeMenuRef.current(id);\n onClose({\n type: \"menu-action\",\n menuId: action,\n options: options as ContextMenuOptions,\n });\n },\n [actions, id, onClose],\n );\n\n const {\n closeMenu,\n listItemProps,\n openMenu: onOpenMenu,\n openMenus,\n handleRender,\n } = useCascade({\n // FIXME\n id: `${id}`,\n onActivate: handleActivate,\n onMouseEnterItem: handleMouseEnterItem,\n position,\n });\n closeMenuRef.current = closeMenu;\n\n const handleCloseMenu = useCallback<MenuCloseHandler>(\n (evt, reason) => {\n navigatingWithKeyboard.current = true;\n closeMenu();\n if (reason === \"tab-away\") {\n // TODO we should fire onclose whenever we're closing\n // the root menu, not just on Tab\n onClose({\n event: evt,\n type: \"tab-away\",\n });\n }\n },\n [closeMenu, onClose],\n );\n\n const handleHighlightMenuItem = () => {\n // console.log(`highlight ${idx}`);\n };\n\n const lastMenu = openMenus.length - 1;\n\n const getChildMenuId = (i: number) => {\n if (i >= lastMenu) {\n return undefined;\n } else {\n const { id } = openMenus[i + 1];\n return id;\n }\n };\n\n return (\n <>\n {openMenus.map(({ id: menuId, left, top }, i, all) => {\n const childMenuId = getChildMenuId(i);\n return (\n <Portal {...PortalProps} key={i} onRender={handleRender}>\n <PopupComponent\n anchorElement={{ current: document.body }}\n placement=\"absolute\"\n position={{ left, top }}\n >\n <MenuList\n {...menuListProps}\n activatedByKeyboard={navigatingWithKeyboard.current}\n childMenuShowing={childMenuId}\n className={className}\n id={menuId}\n isRoot={i === 0}\n key={i}\n listItemProps={listItemProps}\n onActivate={handleActivate}\n onHighlightMenuItem={handleHighlightMenuItem}\n onCloseMenu={handleCloseMenu}\n openMenu={onOpenMenu}\n style={style}\n tabIndex={i === all.length - 1 ? 0 : undefined}\n >\n {menus[menuId]}\n </MenuList>\n </PopupComponent>\n </Portal>\n );\n })}\n </>\n );\n};\n\nContextMenu.displayName = \"ContextMenu\";\n"],"names":["PortalProps","useId","useRef","useItemsWithIdsNext","useCallback","useCascade","id","jsx","Fragment","Portal","PopupComponent","createElement","MenuList"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","sources":["../../src/menu/ContextMenu.tsx"],"sourcesContent":["import { useId } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useRef } from \"react\";\nimport { PopupCloseCallback, PopupComponent } from \"../popup\";\nimport { Portal, PortalProps } from \"../portal\";\nimport { MenuList, MenuListProps } from \"./MenuList\";\nimport { useCascade } from \"./use-cascade\";\nimport { useItemsWithIdsNext } from \"./use-items-with-ids-next\";\nimport { MenuCloseHandler } from \"./use-keyboard-navigation\";\nimport { ContextMenuOptions } from \"./useContextMenu\";\n\nexport interface ContextMenuProps extends Omit<MenuListProps, \"onCloseMenu\"> {\n PortalProps?: Partial<PortalProps>;\n onClose?: PopupCloseCallback;\n position?: { x: number; y: number };\n withPortal?: boolean;\n}\n\nconst noop = () => undefined;\n\nexport const ContextMenu = ({\n PortalProps,\n activatedByKeyboard,\n children: childrenProp,\n className,\n id: idProp,\n onClose = () => undefined,\n position = { x: 0, y: 0 },\n style,\n ...menuListProps\n}: ContextMenuProps) => {\n const id = useId(idProp);\n const closeMenuRef = useRef<(location?: string) => void>(noop);\n const [menus, actions] = useItemsWithIdsNext(childrenProp, id);\n const navigatingWithKeyboard = useRef(activatedByKeyboard);\n const handleMouseEnterItem = useCallback(() => {\n navigatingWithKeyboard.current = false;\n }, []);\n\n const handleActivate = useCallback(\n (menuItemId: string) => {\n const actionId = menuItemId.slice(9);\n const { action, options } = actions[actionId];\n closeMenuRef.current(id);\n onClose({\n type: \"menu-action\",\n menuId: action,\n options: options as ContextMenuOptions,\n });\n },\n [actions, id, onClose],\n );\n\n const {\n closeMenu,\n listItemProps,\n openMenu: onOpenMenu,\n openMenus,\n handleRender,\n } = useCascade({\n // FIXME\n id: `${id}`,\n onActivate: handleActivate,\n onMouseEnterItem: handleMouseEnterItem,\n position,\n });\n closeMenuRef.current = closeMenu;\n\n const handleCloseMenu = useCallback<MenuCloseHandler>(\n (evt, reason) => {\n navigatingWithKeyboard.current = true;\n closeMenu();\n if (reason === \"tab-away\") {\n // TODO we should fire onclose whenever we're closing\n // the root menu, not just on Tab\n onClose({\n event: evt,\n type: \"tab-away\",\n });\n }\n },\n [closeMenu, onClose],\n );\n\n const handleHighlightMenuItem = () => {\n // console.log(`highlight ${idx}`);\n };\n\n const lastMenu = openMenus.length - 1;\n\n const getChildMenuId = (i: number) => {\n if (i >= lastMenu) {\n return undefined;\n } else {\n const { id } = openMenus[i + 1];\n return id;\n }\n };\n\n return (\n <>\n {openMenus.map(({ id: menuId, left, top }, i, all) => {\n const childMenuId = getChildMenuId(i);\n return (\n <Portal {...PortalProps} key={i} onRender={handleRender}>\n <PopupComponent\n anchorElement={{ current: document.body }}\n placement=\"absolute\"\n position={{ left, top }}\n >\n <MenuList\n {...menuListProps}\n activatedByKeyboard={navigatingWithKeyboard.current}\n childMenuShowing={childMenuId}\n className={className}\n id={menuId}\n isRoot={i === 0}\n key={i}\n listItemProps={listItemProps}\n onActivate={handleActivate}\n onHighlightMenuItem={handleHighlightMenuItem}\n onCloseMenu={handleCloseMenu}\n openMenu={onOpenMenu}\n style={style}\n tabIndex={i === all.length - 1 ? 0 : undefined}\n >\n {menus[menuId]}\n </MenuList>\n </PopupComponent>\n </Portal>\n );\n })}\n </>\n );\n};\n\nContextMenu.displayName = \"ContextMenu\";\n"],"names":["PortalProps","useId","useRef","useItemsWithIdsNext","useCallback","useCascade","id","jsx","Fragment","Portal","PopupComponent","createElement","MenuList"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,OAAO,MAAM,KAAA,CAAA,CAAA;AAEZ,MAAM,cAAc,CAAC;AAAA,EAC1B,WAAAA,EAAAA,YAAAA;AAAA,EACA,mBAAA;AAAA,EACA,QAAU,EAAA,YAAA;AAAA,EACV,SAAA;AAAA,EACA,EAAI,EAAA,MAAA;AAAA,EACJ,UAAU,MAAM,KAAA,CAAA;AAAA,EAChB,QAAW,GAAA,EAAE,CAAG,EAAA,CAAA,EAAG,GAAG,CAAE,EAAA;AAAA,EACxB,KAAA;AAAA,EACA,GAAG,aAAA;AACL,CAAwB,KAAA;AACtB,EAAM,MAAA,EAAA,GAAKC,eAAM,MAAM,CAAA,CAAA;AACvB,EAAM,MAAA,YAAA,GAAeC,aAAoC,IAAI,CAAA,CAAA;AAC7D,EAAA,MAAM,CAAC,KAAO,EAAA,OAAO,CAAI,GAAAC,uCAAA,CAAoB,cAAc,EAAE,CAAA,CAAA;AAC7D,EAAM,MAAA,sBAAA,GAA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,YAClB,SAAA;AAAA,YACA,EAAI,EAAA,MAAA;AAAA,YACJ,QAAQ,CAAM,KAAA,CAAA;AAAA,YACd,GAAK,EAAA,CAAA;AAAA,YACL,aAAA;AAAA,YACA,UAAY,EAAA,cAAA;AAAA,YACZ,mBAAqB,EAAA,uBAAA;AAAA,YACrB,WAAa,EAAA,eAAA;AAAA,YACb,QAAU,EAAA,UAAA;AAAA,YACV,KAAA;AAAA,YACA,QAAU,EAAA,CAAA,KAAM,GAAI,CAAA,MAAA,GAAS,IAAI,CAAI,GAAA,KAAA,CAAA;AAAA,WAAA;AAAA,UAEpC,MAAM,MAAM,CAAA;AAAA,SACf;AAAA,OAAA;AAAA,KAEJ,CAAA,CAAA;AAAA,GAEH,CACH,EAAA,CAAA,CAAA;AAEJ,EAAA;AAEA,WAAA,CAAY,WAAc,GAAA,aAAA;;;;"}
|
|
@@ -4,9 +4,12 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var NotificationsCenter = require('./NotificationsCenter.js');
|
|
6
6
|
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
7
8
|
var __typeError = (msg) => {
|
|
8
9
|
throw TypeError(msg);
|
|
9
10
|
};
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
10
13
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
11
14
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
12
15
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -16,10 +19,10 @@ class NotificationsContextObject {
|
|
|
16
19
|
constructor() {
|
|
17
20
|
__privateAdd(this, _notify, () => console.log("have you forgotten to provide a NotificationsCenter?"));
|
|
18
21
|
// We want the public notify method to be stable, setNotify call should not trigger re-renders
|
|
19
|
-
this
|
|
20
|
-
this
|
|
22
|
+
__publicField(this, "notify", (notification) => __privateGet(this, _notify).call(this, notification));
|
|
23
|
+
__publicField(this, "setNotify", (dispatcher) => {
|
|
21
24
|
__privateSet(this, _notify, dispatcher);
|
|
22
|
-
};
|
|
25
|
+
});
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
_notify = new WeakMap();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsProvider.js","sources":["../../src/notifications/NotificationsProvider.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport { NotificationsCenter } from \"./NotificationsCenter\";\nimport { Notification } from \"./notificationTypes\";\n\nexport type DispatchNotification = (\n notification: Omit<Notification, \"id\">\n) => void;\n\nexport type NotificationsContext = {\n notify: DispatchNotification;\n setNotify: (dispatcher: DispatchNotification) => void;\n};\n\n/*\n The Context is not exposed outside this module, only the notify\n prop can be accessed via the useNotifications hook.\n The NotificationsCenter receives the full context object and\n sets the notify method. State management around dispatched\n notifications is handled entirely within the NotificationsCenter,\n avoiding rerendering our children when notifications are \n dispatched.\n*/\nclass NotificationsContextObject implements NotificationsContext {\n #notify: DispatchNotification = () =>\n console.log(\"have you forgotten to provide a NotificationsCenter?\");\n // We want the public notify method to be stable, setNotify call should not trigger re-renders\n notify: DispatchNotification = (notification) => this.#notify(notification);\n setNotify = (dispatcher: DispatchNotification) => {\n this.#notify = dispatcher;\n };\n}\n\nconst NotificationsContext = React.createContext<NotificationsContext>(\n new NotificationsContextObject()\n);\n\nexport const NotificationsProvider = (props: {\n children: JSX.Element | JSX.Element[];\n}) => {\n const context = useContext(NotificationsContext);\n return (\n <NotificationsContext.Provider value={context}>\n <NotificationsCenter notificationsContext={context} />\n {props.children}\n </NotificationsContext.Provider>\n );\n};\n\nexport const useNotifications = () => {\n const { notify } = useContext(NotificationsContext);\n return notify;\n};\n"],"names":["useContext","jsxs","jsx","NotificationsCenter"],"mappings":"
|
|
1
|
+
{"version":3,"file":"NotificationsProvider.js","sources":["../../src/notifications/NotificationsProvider.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport { NotificationsCenter } from \"./NotificationsCenter\";\nimport { Notification } from \"./notificationTypes\";\n\nexport type DispatchNotification = (\n notification: Omit<Notification, \"id\">\n) => void;\n\nexport type NotificationsContext = {\n notify: DispatchNotification;\n setNotify: (dispatcher: DispatchNotification) => void;\n};\n\n/*\n The Context is not exposed outside this module, only the notify\n prop can be accessed via the useNotifications hook.\n The NotificationsCenter receives the full context object and\n sets the notify method. State management around dispatched\n notifications is handled entirely within the NotificationsCenter,\n avoiding rerendering our children when notifications are \n dispatched.\n*/\nclass NotificationsContextObject implements NotificationsContext {\n #notify: DispatchNotification = () =>\n console.log(\"have you forgotten to provide a NotificationsCenter?\");\n // We want the public notify method to be stable, setNotify call should not trigger re-renders\n notify: DispatchNotification = (notification) => this.#notify(notification);\n setNotify = (dispatcher: DispatchNotification) => {\n this.#notify = dispatcher;\n };\n}\n\nconst NotificationsContext = React.createContext<NotificationsContext>(\n new NotificationsContextObject()\n);\n\nexport const NotificationsProvider = (props: {\n children: JSX.Element | JSX.Element[];\n}) => {\n const context = useContext(NotificationsContext);\n return (\n <NotificationsContext.Provider value={context}>\n <NotificationsCenter notificationsContext={context} />\n {props.children}\n </NotificationsContext.Provider>\n );\n};\n\nexport const useNotifications = () => {\n const { notify } = useContext(NotificationsContext);\n return notify;\n};\n"],"names":["useContext","jsxs","jsx","NotificationsCenter"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA,OAAA,CAAA;AAsBA,MAAM,0BAA2D,CAAA;AAAA,EAAjE,WAAA,GAAA;AACE,IAAgC,YAAA,CAAA,IAAA,EAAA,OAAA,EAAA,MAC9B,OAAQ,CAAA,GAAA,CAAI,sDAAsD,CAAA,CAAA,CAAA;AAEpE;AAAA,IAAA,aAAA,CAAA,IAAA,EAAA,QAAA,EAA+B,CAAC,YAAA,KAAiB,YAAK,CAAA,IAAA,EAAA,OAAA,CAAA,CAAL,IAAa,CAAA,IAAA,EAAA,YAAA,CAAA,CAAA,CAAA;AAC9D,IAAA,aAAA,CAAA,IAAA,EAAA,WAAA,EAAY,CAAC,UAAqC,KAAA;AAChD,MAAA,YAAA,CAAA,IAAA,EAAK,OAAU,EAAA,UAAA,CAAA,CAAA;AAAA,KACjB,CAAA,CAAA;AAAA,GAAA;AACF,CAAA;AAPE,OAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AASF,MAAM,uBAAuB,KAAM,CAAA,aAAA;AAAA,EACjC,IAAI,0BAA2B,EAAA;AACjC,CAAA,CAAA;AAEa,MAAA,qBAAA,GAAwB,CAAC,KAEhC,KAAA;AACJ,EAAM,MAAA,OAAA,GAAUA,iBAAW,oBAAoB,CAAA,CAAA;AAC/C,EAAA,uBACGC,eAAA,CAAA,oBAAA,CAAqB,QAArB,EAAA,EAA8B,OAAO,OACpC,EAAA,QAAA,EAAA;AAAA,oBAACC,cAAA,CAAAC,uCAAA,EAAA,EAAoB,sBAAsB,OAAS,EAAA,CAAA;AAAA,IACnD,KAAM,CAAA,QAAA;AAAA,GACT,EAAA,CAAA,CAAA;AAEJ,EAAA;AAEO,MAAM,mBAAmB,MAAM;AACpC,EAAA,MAAM,EAAE,MAAA,EAAW,GAAAH,gBAAA,CAAW,oBAAoB,CAAA,CAAA;AAClD,EAAO,OAAA,MAAA,CAAA;AACT;;;;;"}
|
|
@@ -5,6 +5,9 @@ var React = require('react');
|
|
|
5
5
|
var ReactDOM = require('react-dom');
|
|
6
6
|
var renderPortal = require('../portal-deprecated/render-portal.js');
|
|
7
7
|
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
11
|
let _dialogOpen = false;
|
|
9
12
|
const _popups = [];
|
|
10
13
|
const reasonIsMenuAction = (reason) => reason?.type === "menu-action";
|
|
@@ -91,7 +94,7 @@ const PopupComponent = ({
|
|
|
91
94
|
return React.createElement("div", { className, style }, children);
|
|
92
95
|
};
|
|
93
96
|
let incrementingKey = 1;
|
|
94
|
-
class
|
|
97
|
+
const _PopupService = class _PopupService {
|
|
95
98
|
static showPopup({
|
|
96
99
|
group = "all",
|
|
97
100
|
name = "anon",
|
|
@@ -106,12 +109,12 @@ class PopupService {
|
|
|
106
109
|
throw Error(`PopupService showPopup, no component supplied`);
|
|
107
110
|
}
|
|
108
111
|
if (typeof component.props.onClose === "function") {
|
|
109
|
-
|
|
112
|
+
_PopupService.onClose = component.props.onClose;
|
|
110
113
|
} else {
|
|
111
|
-
|
|
114
|
+
_PopupService.onClose = void 0;
|
|
112
115
|
}
|
|
113
116
|
popupOpened(name);
|
|
114
|
-
document.addEventListener("keydown",
|
|
117
|
+
document.addEventListener("keydown", _PopupService.escapeKeyListener, true);
|
|
115
118
|
let el = document.body.querySelector(".vuuPopup." + group);
|
|
116
119
|
if (el === null) {
|
|
117
120
|
el = document.createElement("div");
|
|
@@ -129,13 +132,13 @@ class PopupService {
|
|
|
129
132
|
left,
|
|
130
133
|
top,
|
|
131
134
|
() => {
|
|
132
|
-
|
|
135
|
+
_PopupService.keepWithinThePage(el, right);
|
|
133
136
|
}
|
|
134
137
|
);
|
|
135
138
|
}
|
|
136
139
|
static escapeKeyListener(evt) {
|
|
137
140
|
if (evt.key === "Escape") {
|
|
138
|
-
|
|
141
|
+
_PopupService.hidePopup({ type: "escape", event: evt });
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
static hidePopup(reason, name = "anon", group = "all") {
|
|
@@ -148,10 +151,10 @@ class PopupService {
|
|
|
148
151
|
}
|
|
149
152
|
document.removeEventListener(
|
|
150
153
|
"keydown",
|
|
151
|
-
|
|
154
|
+
_PopupService.escapeKeyListener,
|
|
152
155
|
true
|
|
153
156
|
);
|
|
154
|
-
|
|
157
|
+
_PopupService?.onClose?.(
|
|
155
158
|
reason ? {
|
|
156
159
|
...reason,
|
|
157
160
|
closedBy: "popup-service"
|
|
@@ -184,7 +187,9 @@ class PopupService {
|
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
189
|
}
|
|
187
|
-
}
|
|
190
|
+
};
|
|
191
|
+
__publicField(_PopupService, "onClose");
|
|
192
|
+
let PopupService = _PopupService;
|
|
188
193
|
class DialogService {
|
|
189
194
|
static showDialog(dialog) {
|
|
190
195
|
const containerEl = ".vuuDialog";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popup-service.js","sources":["../../src/popup/popup-service.ts"],"sourcesContent":["import cx from \"clsx\";\nimport React, {\n createElement,\n CSSProperties,\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n ReactElement,\n} from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { ContextMenuOptions } from \"../menu\";\nimport { renderPortal } from \"../portal-deprecated\";\n\nlet _dialogOpen = false;\nconst _popups: string[] = [];\n\nexport type PopupCloseCallback = (reason?: PopupCloseReason) => void;\n\nexport type TabAwayClosePopup = {\n closedBy?: string;\n type: \"tab-away\";\n event: ReactKeyboardEvent;\n};\n\nexport type ClickAwayClosePopup = {\n closedBy?: string;\n type: \"click-away\";\n mouseEvt: MouseEvent;\n};\n\nexport type EscapeClosePopup = {\n closedBy?: string;\n event: KeyboardEvent;\n type: \"escape\";\n};\n\nexport type MenuActionClosePopup = {\n closedBy?: string;\n menuId: string;\n options: ContextMenuOptions;\n type: \"menu-action\";\n};\n\nexport type PopupCloseReason =\n | ClickAwayClosePopup\n | EscapeClosePopup\n | MenuActionClosePopup\n | TabAwayClosePopup;\n\nexport const reasonIsMenuAction = (\n reason?: PopupCloseReason\n): reason is MenuActionClosePopup => reason?.type === \"menu-action\";\n\nexport const reasonIsClickAway = (\n reason?: PopupCloseReason\n): reason is ClickAwayClosePopup => reason?.type === \"click-away\";\n\nfunction specialKeyHandler(e: KeyboardEvent) {\n if (e.key === \"Esc\") {\n if (_popups.length) {\n closeAllPopups();\n } else if (_dialogOpen) {\n const dialogRoot = document.body.querySelector(\".vuuDialog\");\n if (dialogRoot) {\n ReactDOM.unmountComponentAtNode(dialogRoot);\n }\n }\n }\n}\n\nfunction outsideClickHandler(e: MouseEvent) {\n if (_popups.length) {\n const popupContainers = document.body.querySelectorAll(\n \".vuuPopup,#vuu-portal-root\"\n );\n for (let i = 0; i < popupContainers.length; i++) {\n if (popupContainers[i].contains(e.target as HTMLElement)) {\n return;\n }\n }\n closeAllPopups({ mouseEvt: e, type: \"click-away\" });\n }\n}\n\nfunction closeAllPopups(reason?: PopupCloseReason) {\n if (_popups.length === 1) {\n PopupService.hidePopup(reason, \"anon\", \"all\");\n } else if (_popups.length) {\n // onsole.log(`closeAllPopups`);\n const popupContainers = document.body.querySelectorAll(\".vuuPopup\");\n for (let i = 0; i < popupContainers.length; i++) {\n ReactDOM.unmountComponentAtNode(popupContainers[i]);\n }\n popupClosed(\"*\");\n }\n}\n\nfunction dialogOpened() {\n if (_dialogOpen === false) {\n _dialogOpen = true;\n window.addEventListener(\"keydown\", specialKeyHandler, true);\n }\n}\n\nfunction dialogClosed() {\n if (_dialogOpen) {\n _dialogOpen = false;\n window.removeEventListener(\"keydown\", specialKeyHandler, true);\n }\n}\n\nfunction popupOpened(name: string) {\n if (_popups.indexOf(name) === -1) {\n _popups.push(name);\n //onsole.log('PopupService, popup opened ' + name + ' popups : ' + _popups);\n if (_dialogOpen === false) {\n window.addEventListener(\"keydown\", specialKeyHandler, true);\n window.addEventListener(\"click\", outsideClickHandler, true);\n }\n }\n}\n\nfunction popupClosed(name: string /*, group=null*/) {\n if (_popups.length) {\n if (name === \"*\") {\n _popups.length = 0;\n } else {\n const pos = _popups.indexOf(name);\n if (pos !== -1) {\n _popups.splice(pos, 1);\n }\n }\n //onsole.log('PopupService, popup closed ' + name + ' popups : ' + _popups);\n if (_popups.length === 0 && _dialogOpen === false) {\n window.removeEventListener(\"keydown\", specialKeyHandler, true);\n window.removeEventListener(\"click\", outsideClickHandler, true);\n }\n }\n}\n\nconst PopupComponent = ({\n children,\n position,\n style,\n}: HTMLAttributes<HTMLDivElement> & {\n position?: \"above\" | \"below\" | \"\";\n style?: CSSProperties;\n}) => {\n const className = cx(\"hwPopup\", \"hwPopupContainer\", position);\n return createElement(\"div\", { className, style }, children);\n};\n\nlet incrementingKey = 1;\n\nexport interface ShowPopupProps {\n depth?: number;\n /**\n * if true, focus will be invoked on first focusable element\n */\n focus?: boolean;\n name?: string;\n group?: string;\n position?: \"above\" | \"below\" | \"\";\n left?: number;\n right?: \"auto\" | number;\n top?: number;\n component: ReactElement;\n width?: number | \"auto\";\n}\n\nexport class PopupService {\n static onClose: PopupCloseCallback | undefined;\n static showPopup({\n group = \"all\",\n name = \"anon\",\n left = 0,\n position = \"\",\n right = \"auto\",\n top = 0,\n width = \"auto\",\n component,\n }: ShowPopupProps) {\n if (!component) {\n throw Error(`PopupService showPopup, no component supplied`);\n }\n\n if (typeof component.props.onClose === \"function\") {\n PopupService.onClose = component.props.onClose;\n } else {\n PopupService.onClose = undefined;\n }\n\n popupOpened(name);\n\n document.addEventListener(\"keydown\", PopupService.escapeKeyListener, true);\n\n let el = document.body.querySelector(\".vuuPopup.\" + group) as HTMLElement;\n if (el === null) {\n el = document.createElement(\"div\") as HTMLElement;\n el.className = \"vuuPopup \" + group;\n document.body.appendChild(el);\n }\n\n const style = { width };\n\n renderPortal(\n createElement(\n PopupComponent,\n { key: incrementingKey++, position, style },\n component\n ),\n el,\n left,\n top,\n () => {\n PopupService.keepWithinThePage(el, right);\n }\n );\n }\n\n static escapeKeyListener(evt: KeyboardEvent) {\n if (evt.key === \"Escape\") {\n PopupService.hidePopup({ type: \"escape\", event: evt });\n }\n }\n\n static hidePopup(reason?: PopupCloseReason, name = \"anon\", group = \"all\") {\n if (_popups.indexOf(name) !== -1) {\n popupClosed(name);\n const popupRoot = document.body.querySelector(`.vuuPopup.${group}`);\n if (popupRoot) {\n ReactDOM.unmountComponentAtNode(popupRoot);\n }\n }\n document.removeEventListener(\n \"keydown\",\n PopupService.escapeKeyListener,\n true\n );\n\n PopupService?.onClose?.(\n reason\n ? {\n ...reason,\n closedBy: \"popup-service\",\n }\n : undefined\n );\n }\n\n static keepWithinThePage(el: HTMLElement, right: number | \"auto\" = \"auto\") {\n const target = el.querySelector(\".vuuPopupContainer > *\") as HTMLElement;\n if (target) {\n const {\n top,\n left,\n width,\n height,\n right: currentRight,\n } = target.getBoundingClientRect();\n\n const w = window.innerWidth;\n const h = window.innerHeight;\n\n const overflowH = h - (top + height);\n if (overflowH < 0) {\n target.style.top = Math.round(top) + overflowH + \"px\";\n }\n\n const overflowW = w - (left + width);\n if (overflowW < 0) {\n target.style.left = Math.round(left) + overflowW + \"px\";\n }\n\n if (typeof right === \"number\" && right !== currentRight) {\n const adjustment = right - currentRight;\n target.style.left = left + adjustment + \"px\";\n }\n }\n }\n}\n\nexport class DialogService {\n static showDialog(dialog: ReactElement) {\n const containerEl = \".vuuDialog\";\n const onClose = dialog.props.onClose;\n\n dialogOpened();\n\n ReactDOM.render(\n React.cloneElement(dialog, {\n container: containerEl,\n onClose: () => {\n DialogService.closeDialog();\n if (onClose) {\n onClose();\n }\n },\n }),\n document.body.querySelector(containerEl)\n );\n }\n\n static closeDialog() {\n dialogClosed();\n const dialogRoot = document.body.querySelector(\".vuuDialog\");\n if (dialogRoot) {\n ReactDOM.unmountComponentAtNode(dialogRoot);\n }\n }\n}\n"],"names":["createElement","renderPortal"],"mappings":";;;;;;;AAYA,IAAI,WAAc,GAAA,KAAA,CAAA;AAClB,MAAM,UAAoB,EAAC,CAAA;AAmCpB,MAAM,kBAAqB,GAAA,CAChC,MACmC,KAAA,MAAA,EAAQ,IAAS,KAAA,cAAA;AAE/C,MAAM,iBAA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AAA,QAAA,CAAS,IAAK,CAAA,aAAA,CAAc,YAAY,CAAA,CAAA;AAC3D,IAAA,IAAI,UAAY,EAAA;AACd,MAAA,QAAA,CAAS,uBAAuB,UAAU,CAAA,CAAA;AAAA,KAC5C;AAAA,GACF;AACF;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"popup-service.js","sources":["../../src/popup/popup-service.ts"],"sourcesContent":["import cx from \"clsx\";\nimport React, {\n createElement,\n CSSProperties,\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n ReactElement,\n} from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { ContextMenuOptions } from \"../menu\";\nimport { renderPortal } from \"../portal-deprecated\";\n\nlet _dialogOpen = false;\nconst _popups: string[] = [];\n\nexport type PopupCloseCallback = (reason?: PopupCloseReason) => void;\n\nexport type TabAwayClosePopup = {\n closedBy?: string;\n type: \"tab-away\";\n event: ReactKeyboardEvent;\n};\n\nexport type ClickAwayClosePopup = {\n closedBy?: string;\n type: \"click-away\";\n mouseEvt: MouseEvent;\n};\n\nexport type EscapeClosePopup = {\n closedBy?: string;\n event: KeyboardEvent;\n type: \"escape\";\n};\n\nexport type MenuActionClosePopup = {\n closedBy?: string;\n menuId: string;\n options: ContextMenuOptions;\n type: \"menu-action\";\n};\n\nexport type PopupCloseReason =\n | ClickAwayClosePopup\n | EscapeClosePopup\n | MenuActionClosePopup\n | TabAwayClosePopup;\n\nexport const reasonIsMenuAction = (\n reason?: PopupCloseReason\n): reason is MenuActionClosePopup => reason?.type === \"menu-action\";\n\nexport const reasonIsClickAway = (\n reason?: PopupCloseReason\n): reason is ClickAwayClosePopup => reason?.type === \"click-away\";\n\nfunction specialKeyHandler(e: KeyboardEvent) {\n if (e.key === \"Esc\") {\n if (_popups.length) {\n closeAllPopups();\n } else if (_dialogOpen) {\n const dialogRoot = document.body.querySelector(\".vuuDialog\");\n if (dialogRoot) {\n ReactDOM.unmountComponentAtNode(dialogRoot);\n }\n }\n }\n}\n\nfunction outsideClickHandler(e: MouseEvent) {\n if (_popups.length) {\n const popupContainers = document.body.querySelectorAll(\n \".vuuPopup,#vuu-portal-root\"\n );\n for (let i = 0; i < popupContainers.length; i++) {\n if (popupContainers[i].contains(e.target as HTMLElement)) {\n return;\n }\n }\n closeAllPopups({ mouseEvt: e, type: \"click-away\" });\n }\n}\n\nfunction closeAllPopups(reason?: PopupCloseReason) {\n if (_popups.length === 1) {\n PopupService.hidePopup(reason, \"anon\", \"all\");\n } else if (_popups.length) {\n // onsole.log(`closeAllPopups`);\n const popupContainers = document.body.querySelectorAll(\".vuuPopup\");\n for (let i = 0; i < popupContainers.length; i++) {\n ReactDOM.unmountComponentAtNode(popupContainers[i]);\n }\n popupClosed(\"*\");\n }\n}\n\nfunction dialogOpened() {\n if (_dialogOpen === false) {\n _dialogOpen = true;\n window.addEventListener(\"keydown\", specialKeyHandler, true);\n }\n}\n\nfunction dialogClosed() {\n if (_dialogOpen) {\n _dialogOpen = false;\n window.removeEventListener(\"keydown\", specialKeyHandler, true);\n }\n}\n\nfunction popupOpened(name: string) {\n if (_popups.indexOf(name) === -1) {\n _popups.push(name);\n //onsole.log('PopupService, popup opened ' + name + ' popups : ' + _popups);\n if (_dialogOpen === false) {\n window.addEventListener(\"keydown\", specialKeyHandler, true);\n window.addEventListener(\"click\", outsideClickHandler, true);\n }\n }\n}\n\nfunction popupClosed(name: string /*, group=null*/) {\n if (_popups.length) {\n if (name === \"*\") {\n _popups.length = 0;\n } else {\n const pos = _popups.indexOf(name);\n if (pos !== -1) {\n _popups.splice(pos, 1);\n }\n }\n //onsole.log('PopupService, popup closed ' + name + ' popups : ' + _popups);\n if (_popups.length === 0 && _dialogOpen === false) {\n window.removeEventListener(\"keydown\", specialKeyHandler, true);\n window.removeEventListener(\"click\", outsideClickHandler, true);\n }\n }\n}\n\nconst PopupComponent = ({\n children,\n position,\n style,\n}: HTMLAttributes<HTMLDivElement> & {\n position?: \"above\" | \"below\" | \"\";\n style?: CSSProperties;\n}) => {\n const className = cx(\"hwPopup\", \"hwPopupContainer\", position);\n return createElement(\"div\", { className, style }, children);\n};\n\nlet incrementingKey = 1;\n\nexport interface ShowPopupProps {\n depth?: number;\n /**\n * if true, focus will be invoked on first focusable element\n */\n focus?: boolean;\n name?: string;\n group?: string;\n position?: \"above\" | \"below\" | \"\";\n left?: number;\n right?: \"auto\" | number;\n top?: number;\n component: ReactElement;\n width?: number | \"auto\";\n}\n\nexport class PopupService {\n static onClose: PopupCloseCallback | undefined;\n static showPopup({\n group = \"all\",\n name = \"anon\",\n left = 0,\n position = \"\",\n right = \"auto\",\n top = 0,\n width = \"auto\",\n component,\n }: ShowPopupProps) {\n if (!component) {\n throw Error(`PopupService showPopup, no component supplied`);\n }\n\n if (typeof component.props.onClose === \"function\") {\n PopupService.onClose = component.props.onClose;\n } else {\n PopupService.onClose = undefined;\n }\n\n popupOpened(name);\n\n document.addEventListener(\"keydown\", PopupService.escapeKeyListener, true);\n\n let el = document.body.querySelector(\".vuuPopup.\" + group) as HTMLElement;\n if (el === null) {\n el = document.createElement(\"div\") as HTMLElement;\n el.className = \"vuuPopup \" + group;\n document.body.appendChild(el);\n }\n\n const style = { width };\n\n renderPortal(\n createElement(\n PopupComponent,\n { key: incrementingKey++, position, style },\n component\n ),\n el,\n left,\n top,\n () => {\n PopupService.keepWithinThePage(el, right);\n }\n );\n }\n\n static escapeKeyListener(evt: KeyboardEvent) {\n if (evt.key === \"Escape\") {\n PopupService.hidePopup({ type: \"escape\", event: evt });\n }\n }\n\n static hidePopup(reason?: PopupCloseReason, name = \"anon\", group = \"all\") {\n if (_popups.indexOf(name) !== -1) {\n popupClosed(name);\n const popupRoot = document.body.querySelector(`.vuuPopup.${group}`);\n if (popupRoot) {\n ReactDOM.unmountComponentAtNode(popupRoot);\n }\n }\n document.removeEventListener(\n \"keydown\",\n PopupService.escapeKeyListener,\n true\n );\n\n PopupService?.onClose?.(\n reason\n ? {\n ...reason,\n closedBy: \"popup-service\",\n }\n : undefined\n );\n }\n\n static keepWithinThePage(el: HTMLElement, right: number | \"auto\" = \"auto\") {\n const target = el.querySelector(\".vuuPopupContainer > *\") as HTMLElement;\n if (target) {\n const {\n top,\n left,\n width,\n height,\n right: currentRight,\n } = target.getBoundingClientRect();\n\n const w = window.innerWidth;\n const h = window.innerHeight;\n\n const overflowH = h - (top + height);\n if (overflowH < 0) {\n target.style.top = Math.round(top) + overflowH + \"px\";\n }\n\n const overflowW = w - (left + width);\n if (overflowW < 0) {\n target.style.left = Math.round(left) + overflowW + \"px\";\n }\n\n if (typeof right === \"number\" && right !== currentRight) {\n const adjustment = right - currentRight;\n target.style.left = left + adjustment + \"px\";\n }\n }\n }\n}\n\nexport class DialogService {\n static showDialog(dialog: ReactElement) {\n const containerEl = \".vuuDialog\";\n const onClose = dialog.props.onClose;\n\n dialogOpened();\n\n ReactDOM.render(\n React.cloneElement(dialog, {\n container: containerEl,\n onClose: () => {\n DialogService.closeDialog();\n if (onClose) {\n onClose();\n }\n },\n }),\n document.body.querySelector(containerEl)\n );\n }\n\n static closeDialog() {\n dialogClosed();\n const dialogRoot = document.body.querySelector(\".vuuDialog\");\n if (dialogRoot) {\n ReactDOM.unmountComponentAtNode(dialogRoot);\n }\n }\n}\n"],"names":["createElement","renderPortal"],"mappings":";;;;;;;;;;AAYA,IAAI,WAAc,GAAA,KAAA,CAAA;AAClB,MAAM,UAAoB,EAAC,CAAA;AAmCpB,MAAM,kBAAqB,GAAA,CAChC,MACmC,KAAA,MAAA,EAAQ,IAAS,KAAA,cAAA;AAE/C,MAAM,iBAAoB,GAAA,CAC/B,MACkC,KAAA,MAAA,EAAQ,IAAS,KAAA,aAAA;AAErD,SAAS,kBAAkB,CAAkB,EAAA;AAC3C,EAAI,IAAA,CAAA,CAAE,QAAQ,KAAO,EAAA;AACnB,IAAA,IAAI,QAAQ,MAAQ,EAAA;AAClB,MAAe,cAAA,EAAA,CAAA;AAAA,eACN,WAAa,EAAA;AACtB,MAAA,MAAM,UAAa,GAAA,QAAA,CA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;;;"}
|
package/cjs/prompt/Prompt.js
CHANGED
|
@@ -7,7 +7,7 @@ var styles = require('@salt-ds/styles');
|
|
|
7
7
|
var window = require('@salt-ds/window');
|
|
8
8
|
var cx = require('clsx');
|
|
9
9
|
var React = require('react');
|
|
10
|
-
require('
|
|
10
|
+
require('../popup/popup-service.js');
|
|
11
11
|
var useAnchoredPosition = require('../popup/useAnchoredPosition.js');
|
|
12
12
|
var Prompt$1 = require('./Prompt.css.js');
|
|
13
13
|
|
package/esm/dialog/useDialog.js
CHANGED
|
@@ -2,6 +2,9 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { Dialog, DialogHeader, DialogContent, DialogCloseButton, DialogActions } from '@salt-ds/core';
|
|
3
3
|
import { createContext, useState, useCallback, useContext, useMemo } from 'react';
|
|
4
4
|
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
8
|
const useDialog = () => {
|
|
6
9
|
const [dialogState, setDialogState] = useState();
|
|
7
10
|
const closeDialog = useCallback(() => {
|
|
@@ -41,8 +44,8 @@ const defaultCloseDialog = () => {
|
|
|
41
44
|
};
|
|
42
45
|
class DialogContextObject {
|
|
43
46
|
constructor() {
|
|
44
|
-
this
|
|
45
|
-
this
|
|
47
|
+
__publicField(this, "showDialog", defaultShowDialog);
|
|
48
|
+
__publicField(this, "closeDialog", defaultCloseDialog);
|
|
46
49
|
}
|
|
47
50
|
setDialogDispatchers(showDialog, closeDialog) {
|
|
48
51
|
this.showDialog = showDialog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDialog.js","sources":["../../src/dialog/useDialog.tsx"],"sourcesContent":["import {\n Dialog,\n DialogActions,\n DialogCloseButton,\n DialogContent,\n DialogHeader,\n} from \"@salt-ds/core\";\nimport {\n createContext,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nexport type DialogState = {\n actions?: ReactElement[];\n content: ReactElement;\n title: string;\n hideCloseButton?: boolean;\n};\n\nexport type SetDialog = (dialogState?: DialogState) => void;\n\nexport type ShowDialog = (\n dialogContent: ReactElement,\n title: string,\n dialogActionButtons?: ReactElement[],\n hideCloseButton?: boolean\n) => void;\n\nexport interface DialogContextProps {\n showDialog: ShowDialog;\n closeDialog: () => void;\n setDialogDispatchers: (\n showDialog: ShowDialog,\n closeDialog: () => void\n ) => void;\n}\n\nexport const useDialog = () => {\n const [dialogState, setDialogState] = useState<DialogState>();\n\n const closeDialog = useCallback(() => {\n setDialogState(undefined);\n }, []);\n\n const handleOpenChange = useCallback(\n (open?: boolean) => {\n if (open !== true) {\n closeDialog();\n }\n },\n [closeDialog]\n );\n\n const dialog = dialogState ? (\n <Dialog open={true} onOpenChange={handleOpenChange}>\n <DialogHeader header={dialogState.title} />\n <DialogContent>{dialogState.content}</DialogContent>\n {dialogState.hideCloseButton !== true ? (\n <DialogCloseButton\n data-embedded\n data-icon=\"close\"\n onClick={closeDialog}\n />\n ) : null}\n {dialogState.actions ? (\n <DialogActions>{dialogState.actions}</DialogActions>\n ) : null}\n </Dialog>\n ) : null;\n\n return {\n dialog,\n setDialogState,\n };\n};\n\nconst defaultShowDialog: ShowDialog = () => {\n console.warn(\"No DialogProvider in place\");\n};\nconst defaultCloseDialog = () => {\n console.warn(\"No DialogProvider in place\");\n};\n\nclass DialogContextObject implements DialogContextProps {\n showDialog = defaultShowDialog;\n closeDialog = defaultCloseDialog;\n setDialogDispatchers(showDialog: ShowDialog, closeDialog: () => void) {\n this.showDialog = showDialog;\n this.closeDialog = closeDialog;\n }\n}\n\nconst DialogContext = createContext<DialogContextProps>(\n new DialogContextObject()\n);\n\nconst DialogHost = ({ context }: { context: DialogContextProps }) => {\n const { dialog, setDialogState } = useDialog();\n const showDialog: ShowDialog = useCallback(\n (dialogContent, title, actionButtons, hideCloseButton) => {\n setDialogState({\n actions: actionButtons,\n content: dialogContent,\n title,\n hideCloseButton,\n });\n },\n [setDialogState]\n );\n const closeDialog = useCallback(() => {\n setDialogState(undefined);\n }, [setDialogState]);\n\n useMemo(() => {\n context.setDialogDispatchers(showDialog, closeDialog);\n }, [closeDialog, context, showDialog]);\n return dialog;\n};\n\nexport const DialogProvider = ({ children }: { children: ReactNode }) => {\n const context = useContext(DialogContext);\n return (\n <DialogContext.Provider value={context}>\n <DialogHost context={context} />\n {children}\n </DialogContext.Provider>\n );\n};\n\nexport const useDialogContext = () => {\n const { closeDialog, showDialog } = useContext(DialogContext);\n return { showDialog, closeDialog };\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDialog.js","sources":["../../src/dialog/useDialog.tsx"],"sourcesContent":["import {\n Dialog,\n DialogActions,\n DialogCloseButton,\n DialogContent,\n DialogHeader,\n} from \"@salt-ds/core\";\nimport {\n createContext,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nexport type DialogState = {\n actions?: ReactElement[];\n content: ReactElement;\n title: string;\n hideCloseButton?: boolean;\n};\n\nexport type SetDialog = (dialogState?: DialogState) => void;\n\nexport type ShowDialog = (\n dialogContent: ReactElement,\n title: string,\n dialogActionButtons?: ReactElement[],\n hideCloseButton?: boolean\n) => void;\n\nexport interface DialogContextProps {\n showDialog: ShowDialog;\n closeDialog: () => void;\n setDialogDispatchers: (\n showDialog: ShowDialog,\n closeDialog: () => void\n ) => void;\n}\n\nexport const useDialog = () => {\n const [dialogState, setDialogState] = useState<DialogState>();\n\n const closeDialog = useCallback(() => {\n setDialogState(undefined);\n }, []);\n\n const handleOpenChange = useCallback(\n (open?: boolean) => {\n if (open !== true) {\n closeDialog();\n }\n },\n [closeDialog]\n );\n\n const dialog = dialogState ? (\n <Dialog open={true} onOpenChange={handleOpenChange}>\n <DialogHeader header={dialogState.title} />\n <DialogContent>{dialogState.content}</DialogContent>\n {dialogState.hideCloseButton !== true ? (\n <DialogCloseButton\n data-embedded\n data-icon=\"close\"\n onClick={closeDialog}\n />\n ) : null}\n {dialogState.actions ? (\n <DialogActions>{dialogState.actions}</DialogActions>\n ) : null}\n </Dialog>\n ) : null;\n\n return {\n dialog,\n setDialogState,\n };\n};\n\nconst defaultShowDialog: ShowDialog = () => {\n console.warn(\"No DialogProvider in place\");\n};\nconst defaultCloseDialog = () => {\n console.warn(\"No DialogProvider in place\");\n};\n\nclass DialogContextObject implements DialogContextProps {\n showDialog = defaultShowDialog;\n closeDialog = defaultCloseDialog;\n setDialogDispatchers(showDialog: ShowDialog, closeDialog: () => void) {\n this.showDialog = showDialog;\n this.closeDialog = closeDialog;\n }\n}\n\nconst DialogContext = createContext<DialogContextProps>(\n new DialogContextObject()\n);\n\nconst DialogHost = ({ context }: { context: DialogContextProps }) => {\n const { dialog, setDialogState } = useDialog();\n const showDialog: ShowDialog = useCallback(\n (dialogContent, title, actionButtons, hideCloseButton) => {\n setDialogState({\n actions: actionButtons,\n content: dialogContent,\n title,\n hideCloseButton,\n });\n },\n [setDialogState]\n );\n const closeDialog = useCallback(() => {\n setDialogState(undefined);\n }, [setDialogState]);\n\n useMemo(() => {\n context.setDialogDispatchers(showDialog, closeDialog);\n }, [closeDialog, context, showDialog]);\n return dialog;\n};\n\nexport const DialogProvider = ({ children }: { children: ReactNode }) => {\n const context = useContext(DialogContext);\n return (\n <DialogContext.Provider value={context}>\n <DialogHost context={context} />\n {children}\n </DialogContext.Provider>\n );\n};\n\nexport const useDialogContext = () => {\n const { closeDialog, showDialog } = useContext(DialogContext);\n return { showDialog, closeDialog };\n};\n"],"names":[],"mappings":";;;;;;;AA0CO,MAAM,YAAY,MAAM;AAC7B,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,QAAsB,EAAA,CAAA;AAE5D,EAAM,MAAA,WAAA,GAAc,YAAY,MAAM;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AAE,QAAA,EAAwC,KAAA;AACvE,EAAM,MAAA,OAAA,GAAU,WAAW,aAAa,CAAA,CAAA;AACxC,EAAA,uBACG,IAAA,CAAA,aAAA,CAAc,QAAd,EAAA,EAAuB,OAAO,OAC7B,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,cAAW,OAAkB,EAAA,CAAA;AAAA,IAC7B,QAAA;AAAA,GACH,EAAA,CAAA,CAAA;AAEJ,EAAA;AAEO,MAAM,mBAAmB,MAAM;AACpC,EAAA,MAAM,EAAE,WAAA,EAAa,UAAW,EAAA,GAAI,WAAW,aAAa,CAAA,CAAA;AAC5D,EAAO,OAAA,EAAE,YAAY,WAAY,EAAA,CAAA;AACnC;;;;"}
|
package/esm/menu/ContextMenu.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useRef, useCallback, createElement } from 'react';
|
|
3
3
|
import { useId } from '@vuu-ui/vuu-utils';
|
|
4
|
-
import '
|
|
5
|
-
import 'react-dom';
|
|
4
|
+
import '../popup/popup-service.js';
|
|
6
5
|
import { PopupComponent } from '../popup/Popup.js';
|
|
7
6
|
import { Portal } from '../portal/Portal.js';
|
|
8
7
|
import { MenuList } from './MenuList.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","sources":["../../src/menu/ContextMenu.tsx"],"sourcesContent":["import { useId } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useRef } from \"react\";\nimport { PopupCloseCallback, PopupComponent } from \"../popup\";\nimport { Portal, PortalProps } from \"../portal\";\nimport { MenuList, MenuListProps } from \"./MenuList\";\nimport { useCascade } from \"./use-cascade\";\nimport { useItemsWithIdsNext } from \"./use-items-with-ids-next\";\nimport { MenuCloseHandler } from \"./use-keyboard-navigation\";\nimport { ContextMenuOptions } from \"./useContextMenu\";\n\nexport interface ContextMenuProps extends Omit<MenuListProps, \"onCloseMenu\"> {\n PortalProps?: Partial<PortalProps>;\n onClose?: PopupCloseCallback;\n position?: { x: number; y: number };\n withPortal?: boolean;\n}\n\nconst noop = () => undefined;\n\nexport const ContextMenu = ({\n PortalProps,\n activatedByKeyboard,\n children: childrenProp,\n className,\n id: idProp,\n onClose = () => undefined,\n position = { x: 0, y: 0 },\n style,\n ...menuListProps\n}: ContextMenuProps) => {\n const id = useId(idProp);\n const closeMenuRef = useRef<(location?: string) => void>(noop);\n const [menus, actions] = useItemsWithIdsNext(childrenProp, id);\n const navigatingWithKeyboard = useRef(activatedByKeyboard);\n const handleMouseEnterItem = useCallback(() => {\n navigatingWithKeyboard.current = false;\n }, []);\n\n const handleActivate = useCallback(\n (menuItemId: string) => {\n const actionId = menuItemId.slice(9);\n const { action, options } = actions[actionId];\n closeMenuRef.current(id);\n onClose({\n type: \"menu-action\",\n menuId: action,\n options: options as ContextMenuOptions,\n });\n },\n [actions, id, onClose],\n );\n\n const {\n closeMenu,\n listItemProps,\n openMenu: onOpenMenu,\n openMenus,\n handleRender,\n } = useCascade({\n // FIXME\n id: `${id}`,\n onActivate: handleActivate,\n onMouseEnterItem: handleMouseEnterItem,\n position,\n });\n closeMenuRef.current = closeMenu;\n\n const handleCloseMenu = useCallback<MenuCloseHandler>(\n (evt, reason) => {\n navigatingWithKeyboard.current = true;\n closeMenu();\n if (reason === \"tab-away\") {\n // TODO we should fire onclose whenever we're closing\n // the root menu, not just on Tab\n onClose({\n event: evt,\n type: \"tab-away\",\n });\n }\n },\n [closeMenu, onClose],\n );\n\n const handleHighlightMenuItem = () => {\n // console.log(`highlight ${idx}`);\n };\n\n const lastMenu = openMenus.length - 1;\n\n const getChildMenuId = (i: number) => {\n if (i >= lastMenu) {\n return undefined;\n } else {\n const { id } = openMenus[i + 1];\n return id;\n }\n };\n\n return (\n <>\n {openMenus.map(({ id: menuId, left, top }, i, all) => {\n const childMenuId = getChildMenuId(i);\n return (\n <Portal {...PortalProps} key={i} onRender={handleRender}>\n <PopupComponent\n anchorElement={{ current: document.body }}\n placement=\"absolute\"\n position={{ left, top }}\n >\n <MenuList\n {...menuListProps}\n activatedByKeyboard={navigatingWithKeyboard.current}\n childMenuShowing={childMenuId}\n className={className}\n id={menuId}\n isRoot={i === 0}\n key={i}\n listItemProps={listItemProps}\n onActivate={handleActivate}\n onHighlightMenuItem={handleHighlightMenuItem}\n onCloseMenu={handleCloseMenu}\n openMenu={onOpenMenu}\n style={style}\n tabIndex={i === all.length - 1 ? 0 : undefined}\n >\n {menus[menuId]}\n </MenuList>\n </PopupComponent>\n </Portal>\n );\n })}\n </>\n );\n};\n\nContextMenu.displayName = \"ContextMenu\";\n"],"names":["PortalProps","id"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","sources":["../../src/menu/ContextMenu.tsx"],"sourcesContent":["import { useId } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useRef } from \"react\";\nimport { PopupCloseCallback, PopupComponent } from \"../popup\";\nimport { Portal, PortalProps } from \"../portal\";\nimport { MenuList, MenuListProps } from \"./MenuList\";\nimport { useCascade } from \"./use-cascade\";\nimport { useItemsWithIdsNext } from \"./use-items-with-ids-next\";\nimport { MenuCloseHandler } from \"./use-keyboard-navigation\";\nimport { ContextMenuOptions } from \"./useContextMenu\";\n\nexport interface ContextMenuProps extends Omit<MenuListProps, \"onCloseMenu\"> {\n PortalProps?: Partial<PortalProps>;\n onClose?: PopupCloseCallback;\n position?: { x: number; y: number };\n withPortal?: boolean;\n}\n\nconst noop = () => undefined;\n\nexport const ContextMenu = ({\n PortalProps,\n activatedByKeyboard,\n children: childrenProp,\n className,\n id: idProp,\n onClose = () => undefined,\n position = { x: 0, y: 0 },\n style,\n ...menuListProps\n}: ContextMenuProps) => {\n const id = useId(idProp);\n const closeMenuRef = useRef<(location?: string) => void>(noop);\n const [menus, actions] = useItemsWithIdsNext(childrenProp, id);\n const navigatingWithKeyboard = useRef(activatedByKeyboard);\n const handleMouseEnterItem = useCallback(() => {\n navigatingWithKeyboard.current = false;\n }, []);\n\n const handleActivate = useCallback(\n (menuItemId: string) => {\n const actionId = menuItemId.slice(9);\n const { action, options } = actions[actionId];\n closeMenuRef.current(id);\n onClose({\n type: \"menu-action\",\n menuId: action,\n options: options as ContextMenuOptions,\n });\n },\n [actions, id, onClose],\n );\n\n const {\n closeMenu,\n listItemProps,\n openMenu: onOpenMenu,\n openMenus,\n handleRender,\n } = useCascade({\n // FIXME\n id: `${id}`,\n onActivate: handleActivate,\n onMouseEnterItem: handleMouseEnterItem,\n position,\n });\n closeMenuRef.current = closeMenu;\n\n const handleCloseMenu = useCallback<MenuCloseHandler>(\n (evt, reason) => {\n navigatingWithKeyboard.current = true;\n closeMenu();\n if (reason === \"tab-away\") {\n // TODO we should fire onclose whenever we're closing\n // the root menu, not just on Tab\n onClose({\n event: evt,\n type: \"tab-away\",\n });\n }\n },\n [closeMenu, onClose],\n );\n\n const handleHighlightMenuItem = () => {\n // console.log(`highlight ${idx}`);\n };\n\n const lastMenu = openMenus.length - 1;\n\n const getChildMenuId = (i: number) => {\n if (i >= lastMenu) {\n return undefined;\n } else {\n const { id } = openMenus[i + 1];\n return id;\n }\n };\n\n return (\n <>\n {openMenus.map(({ id: menuId, left, top }, i, all) => {\n const childMenuId = getChildMenuId(i);\n return (\n <Portal {...PortalProps} key={i} onRender={handleRender}>\n <PopupComponent\n anchorElement={{ current: document.body }}\n placement=\"absolute\"\n position={{ left, top }}\n >\n <MenuList\n {...menuListProps}\n activatedByKeyboard={navigatingWithKeyboard.current}\n childMenuShowing={childMenuId}\n className={className}\n id={menuId}\n isRoot={i === 0}\n key={i}\n listItemProps={listItemProps}\n onActivate={handleActivate}\n onHighlightMenuItem={handleHighlightMenuItem}\n onCloseMenu={handleCloseMenu}\n openMenu={onOpenMenu}\n style={style}\n tabIndex={i === all.length - 1 ? 0 : undefined}\n >\n {menus[menuId]}\n </MenuList>\n </PopupComponent>\n </Portal>\n );\n })}\n </>\n );\n};\n\nContextMenu.displayName = \"ContextMenu\";\n"],"names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3
3
|
import { NotificationsCenter } from './NotificationsCenter.js';
|
|
4
4
|
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
5
6
|
var __typeError = (msg) => {
|
|
6
7
|
throw TypeError(msg);
|
|
7
8
|
};
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
11
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
9
12
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
10
13
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -14,10 +17,10 @@ class NotificationsContextObject {
|
|
|
14
17
|
constructor() {
|
|
15
18
|
__privateAdd(this, _notify, () => console.log("have you forgotten to provide a NotificationsCenter?"));
|
|
16
19
|
// We want the public notify method to be stable, setNotify call should not trigger re-renders
|
|
17
|
-
this
|
|
18
|
-
this
|
|
20
|
+
__publicField(this, "notify", (notification) => __privateGet(this, _notify).call(this, notification));
|
|
21
|
+
__publicField(this, "setNotify", (dispatcher) => {
|
|
19
22
|
__privateSet(this, _notify, dispatcher);
|
|
20
|
-
};
|
|
23
|
+
});
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
_notify = new WeakMap();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationsProvider.js","sources":["../../src/notifications/NotificationsProvider.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport { NotificationsCenter } from \"./NotificationsCenter\";\nimport { Notification } from \"./notificationTypes\";\n\nexport type DispatchNotification = (\n notification: Omit<Notification, \"id\">\n) => void;\n\nexport type NotificationsContext = {\n notify: DispatchNotification;\n setNotify: (dispatcher: DispatchNotification) => void;\n};\n\n/*\n The Context is not exposed outside this module, only the notify\n prop can be accessed via the useNotifications hook.\n The NotificationsCenter receives the full context object and\n sets the notify method. State management around dispatched\n notifications is handled entirely within the NotificationsCenter,\n avoiding rerendering our children when notifications are \n dispatched.\n*/\nclass NotificationsContextObject implements NotificationsContext {\n #notify: DispatchNotification = () =>\n console.log(\"have you forgotten to provide a NotificationsCenter?\");\n // We want the public notify method to be stable, setNotify call should not trigger re-renders\n notify: DispatchNotification = (notification) => this.#notify(notification);\n setNotify = (dispatcher: DispatchNotification) => {\n this.#notify = dispatcher;\n };\n}\n\nconst NotificationsContext = React.createContext<NotificationsContext>(\n new NotificationsContextObject()\n);\n\nexport const NotificationsProvider = (props: {\n children: JSX.Element | JSX.Element[];\n}) => {\n const context = useContext(NotificationsContext);\n return (\n <NotificationsContext.Provider value={context}>\n <NotificationsCenter notificationsContext={context} />\n {props.children}\n </NotificationsContext.Provider>\n );\n};\n\nexport const useNotifications = () => {\n const { notify } = useContext(NotificationsContext);\n return notify;\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NotificationsProvider.js","sources":["../../src/notifications/NotificationsProvider.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport { NotificationsCenter } from \"./NotificationsCenter\";\nimport { Notification } from \"./notificationTypes\";\n\nexport type DispatchNotification = (\n notification: Omit<Notification, \"id\">\n) => void;\n\nexport type NotificationsContext = {\n notify: DispatchNotification;\n setNotify: (dispatcher: DispatchNotification) => void;\n};\n\n/*\n The Context is not exposed outside this module, only the notify\n prop can be accessed via the useNotifications hook.\n The NotificationsCenter receives the full context object and\n sets the notify method. State management around dispatched\n notifications is handled entirely within the NotificationsCenter,\n avoiding rerendering our children when notifications are \n dispatched.\n*/\nclass NotificationsContextObject implements NotificationsContext {\n #notify: DispatchNotification = () =>\n console.log(\"have you forgotten to provide a NotificationsCenter?\");\n // We want the public notify method to be stable, setNotify call should not trigger re-renders\n notify: DispatchNotification = (notification) => this.#notify(notification);\n setNotify = (dispatcher: DispatchNotification) => {\n this.#notify = dispatcher;\n };\n}\n\nconst NotificationsContext = React.createContext<NotificationsContext>(\n new NotificationsContextObject()\n);\n\nexport const NotificationsProvider = (props: {\n children: JSX.Element | JSX.Element[];\n}) => {\n const context = useContext(NotificationsContext);\n return (\n <NotificationsContext.Provider value={context}>\n <NotificationsCenter notificationsContext={context} />\n {props.children}\n </NotificationsContext.Provider>\n );\n};\n\nexport const useNotifications = () => {\n const { notify } = useContext(NotificationsContext);\n return notify;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,IAAA,OAAA,CAAA;AAsBA,MAAM,0BAA2D,CAAA;AAAA,EAAjE,WAAA,GAAA;AACE,IAAgC,YAAA,CAAA,IAAA,EAAA,OAAA,EAAA,MAC9B,OAAQ,CAAA,GAAA,CAAI,sDAAsD,CAAA,CAAA,CAAA;AAEpE;AAAA,IAAA,aAAA,CAAA,IAAA,EAAA,QAAA,EAA+B,CAAC,YAAA,KAAiB,YAAK,CAAA,IAAA,EAAA,OAAA,CAAA,CAAL,IAAa,CAAA,IAAA,EAAA,YAAA,CAAA,CAAA,CAAA;AAC9D,IAAA,aAAA,CAAA,IAAA,EAAA,WAAA,EAAY,CAAC,UAAqC,KAAA;AAChD,MAAA,YAAA,CAAA,IAAA,EAAK,OAAU,EAAA,UAAA,CAAA,CAAA;AAAA,KACjB,CAAA,CAAA;AAAA,GAAA;AACF,CAAA;AAPE,OAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AASF,MAAM,uBAAuB,KAAM,CAAA,aAAA;AAAA,EACjC,IAAI,0BAA2B,EAAA;AACjC,CAAA,CAAA;AAEa,MAAA,qBAAA,GAAwB,CAAC,KAEhC,KAAA;AACJ,EAAM,MAAA,OAAA,GAAU,WAAW,oBAAoB,CAAA,CAAA;AAC/C,EAAA,uBACG,IAAA,CAAA,oBAAA,CAAqB,QAArB,EAAA,EAA8B,OAAO,OACpC,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,mBAAA,EAAA,EAAoB,sBAAsB,OAAS,EAAA,CAAA;AAAA,IACnD,KAAM,CAAA,QAAA;AAAA,GACT,EAAA,CAAA,CAAA;AAEJ,EAAA;AAEO,MAAM,mBAAmB,MAAM;AACpC,EAAA,MAAM,EAAE,MAAA,EAAW,GAAA,UAAA,CAAW,oBAAoB,CAAA,CAAA;AAClD,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
|
|
@@ -3,6 +3,9 @@ import React, { createElement } from 'react';
|
|
|
3
3
|
import ReactDOM__default from 'react-dom';
|
|
4
4
|
import { renderPortal } from '../portal-deprecated/render-portal.js';
|
|
5
5
|
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
9
|
let _dialogOpen = false;
|
|
7
10
|
const _popups = [];
|
|
8
11
|
const reasonIsMenuAction = (reason) => reason?.type === "menu-action";
|
|
@@ -89,7 +92,7 @@ const PopupComponent = ({
|
|
|
89
92
|
return createElement("div", { className, style }, children);
|
|
90
93
|
};
|
|
91
94
|
let incrementingKey = 1;
|
|
92
|
-
class
|
|
95
|
+
const _PopupService = class _PopupService {
|
|
93
96
|
static showPopup({
|
|
94
97
|
group = "all",
|
|
95
98
|
name = "anon",
|
|
@@ -104,12 +107,12 @@ class PopupService {
|
|
|
104
107
|
throw Error(`PopupService showPopup, no component supplied`);
|
|
105
108
|
}
|
|
106
109
|
if (typeof component.props.onClose === "function") {
|
|
107
|
-
|
|
110
|
+
_PopupService.onClose = component.props.onClose;
|
|
108
111
|
} else {
|
|
109
|
-
|
|
112
|
+
_PopupService.onClose = void 0;
|
|
110
113
|
}
|
|
111
114
|
popupOpened(name);
|
|
112
|
-
document.addEventListener("keydown",
|
|
115
|
+
document.addEventListener("keydown", _PopupService.escapeKeyListener, true);
|
|
113
116
|
let el = document.body.querySelector(".vuuPopup." + group);
|
|
114
117
|
if (el === null) {
|
|
115
118
|
el = document.createElement("div");
|
|
@@ -127,13 +130,13 @@ class PopupService {
|
|
|
127
130
|
left,
|
|
128
131
|
top,
|
|
129
132
|
() => {
|
|
130
|
-
|
|
133
|
+
_PopupService.keepWithinThePage(el, right);
|
|
131
134
|
}
|
|
132
135
|
);
|
|
133
136
|
}
|
|
134
137
|
static escapeKeyListener(evt) {
|
|
135
138
|
if (evt.key === "Escape") {
|
|
136
|
-
|
|
139
|
+
_PopupService.hidePopup({ type: "escape", event: evt });
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
142
|
static hidePopup(reason, name = "anon", group = "all") {
|
|
@@ -146,10 +149,10 @@ class PopupService {
|
|
|
146
149
|
}
|
|
147
150
|
document.removeEventListener(
|
|
148
151
|
"keydown",
|
|
149
|
-
|
|
152
|
+
_PopupService.escapeKeyListener,
|
|
150
153
|
true
|
|
151
154
|
);
|
|
152
|
-
|
|
155
|
+
_PopupService?.onClose?.(
|
|
153
156
|
reason ? {
|
|
154
157
|
...reason,
|
|
155
158
|
closedBy: "popup-service"
|
|
@@ -182,7 +185,9 @@ class PopupService {
|
|
|
182
185
|
}
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
|
-
}
|
|
188
|
+
};
|
|
189
|
+
__publicField(_PopupService, "onClose");
|
|
190
|
+
let PopupService = _PopupService;
|
|
186
191
|
class DialogService {
|
|
187
192
|
static showDialog(dialog) {
|
|
188
193
|
const containerEl = ".vuuDialog";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popup-service.js","sources":["../../src/popup/popup-service.ts"],"sourcesContent":["import cx from \"clsx\";\nimport React, {\n createElement,\n CSSProperties,\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n ReactElement,\n} from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { ContextMenuOptions } from \"../menu\";\nimport { renderPortal } from \"../portal-deprecated\";\n\nlet _dialogOpen = false;\nconst _popups: string[] = [];\n\nexport type PopupCloseCallback = (reason?: PopupCloseReason) => void;\n\nexport type TabAwayClosePopup = {\n closedBy?: string;\n type: \"tab-away\";\n event: ReactKeyboardEvent;\n};\n\nexport type ClickAwayClosePopup = {\n closedBy?: string;\n type: \"click-away\";\n mouseEvt: MouseEvent;\n};\n\nexport type EscapeClosePopup = {\n closedBy?: string;\n event: KeyboardEvent;\n type: \"escape\";\n};\n\nexport type MenuActionClosePopup = {\n closedBy?: string;\n menuId: string;\n options: ContextMenuOptions;\n type: \"menu-action\";\n};\n\nexport type PopupCloseReason =\n | ClickAwayClosePopup\n | EscapeClosePopup\n | MenuActionClosePopup\n | TabAwayClosePopup;\n\nexport const reasonIsMenuAction = (\n reason?: PopupCloseReason\n): reason is MenuActionClosePopup => reason?.type === \"menu-action\";\n\nexport const reasonIsClickAway = (\n reason?: PopupCloseReason\n): reason is ClickAwayClosePopup => reason?.type === \"click-away\";\n\nfunction specialKeyHandler(e: KeyboardEvent) {\n if (e.key === \"Esc\") {\n if (_popups.length) {\n closeAllPopups();\n } else if (_dialogOpen) {\n const dialogRoot = document.body.querySelector(\".vuuDialog\");\n if (dialogRoot) {\n ReactDOM.unmountComponentAtNode(dialogRoot);\n }\n }\n }\n}\n\nfunction outsideClickHandler(e: MouseEvent) {\n if (_popups.length) {\n const popupContainers = document.body.querySelectorAll(\n \".vuuPopup,#vuu-portal-root\"\n );\n for (let i = 0; i < popupContainers.length; i++) {\n if (popupContainers[i].contains(e.target as HTMLElement)) {\n return;\n }\n }\n closeAllPopups({ mouseEvt: e, type: \"click-away\" });\n }\n}\n\nfunction closeAllPopups(reason?: PopupCloseReason) {\n if (_popups.length === 1) {\n PopupService.hidePopup(reason, \"anon\", \"all\");\n } else if (_popups.length) {\n // onsole.log(`closeAllPopups`);\n const popupContainers = document.body.querySelectorAll(\".vuuPopup\");\n for (let i = 0; i < popupContainers.length; i++) {\n ReactDOM.unmountComponentAtNode(popupContainers[i]);\n }\n popupClosed(\"*\");\n }\n}\n\nfunction dialogOpened() {\n if (_dialogOpen === false) {\n _dialogOpen = true;\n window.addEventListener(\"keydown\", specialKeyHandler, true);\n }\n}\n\nfunction dialogClosed() {\n if (_dialogOpen) {\n _dialogOpen = false;\n window.removeEventListener(\"keydown\", specialKeyHandler, true);\n }\n}\n\nfunction popupOpened(name: string) {\n if (_popups.indexOf(name) === -1) {\n _popups.push(name);\n //onsole.log('PopupService, popup opened ' + name + ' popups : ' + _popups);\n if (_dialogOpen === false) {\n window.addEventListener(\"keydown\", specialKeyHandler, true);\n window.addEventListener(\"click\", outsideClickHandler, true);\n }\n }\n}\n\nfunction popupClosed(name: string /*, group=null*/) {\n if (_popups.length) {\n if (name === \"*\") {\n _popups.length = 0;\n } else {\n const pos = _popups.indexOf(name);\n if (pos !== -1) {\n _popups.splice(pos, 1);\n }\n }\n //onsole.log('PopupService, popup closed ' + name + ' popups : ' + _popups);\n if (_popups.length === 0 && _dialogOpen === false) {\n window.removeEventListener(\"keydown\", specialKeyHandler, true);\n window.removeEventListener(\"click\", outsideClickHandler, true);\n }\n }\n}\n\nconst PopupComponent = ({\n children,\n position,\n style,\n}: HTMLAttributes<HTMLDivElement> & {\n position?: \"above\" | \"below\" | \"\";\n style?: CSSProperties;\n}) => {\n const className = cx(\"hwPopup\", \"hwPopupContainer\", position);\n return createElement(\"div\", { className, style }, children);\n};\n\nlet incrementingKey = 1;\n\nexport interface ShowPopupProps {\n depth?: number;\n /**\n * if true, focus will be invoked on first focusable element\n */\n focus?: boolean;\n name?: string;\n group?: string;\n position?: \"above\" | \"below\" | \"\";\n left?: number;\n right?: \"auto\" | number;\n top?: number;\n component: ReactElement;\n width?: number | \"auto\";\n}\n\nexport class PopupService {\n static onClose: PopupCloseCallback | undefined;\n static showPopup({\n group = \"all\",\n name = \"anon\",\n left = 0,\n position = \"\",\n right = \"auto\",\n top = 0,\n width = \"auto\",\n component,\n }: ShowPopupProps) {\n if (!component) {\n throw Error(`PopupService showPopup, no component supplied`);\n }\n\n if (typeof component.props.onClose === \"function\") {\n PopupService.onClose = component.props.onClose;\n } else {\n PopupService.onClose = undefined;\n }\n\n popupOpened(name);\n\n document.addEventListener(\"keydown\", PopupService.escapeKeyListener, true);\n\n let el = document.body.querySelector(\".vuuPopup.\" + group) as HTMLElement;\n if (el === null) {\n el = document.createElement(\"div\") as HTMLElement;\n el.className = \"vuuPopup \" + group;\n document.body.appendChild(el);\n }\n\n const style = { width };\n\n renderPortal(\n createElement(\n PopupComponent,\n { key: incrementingKey++, position, style },\n component\n ),\n el,\n left,\n top,\n () => {\n PopupService.keepWithinThePage(el, right);\n }\n );\n }\n\n static escapeKeyListener(evt: KeyboardEvent) {\n if (evt.key === \"Escape\") {\n PopupService.hidePopup({ type: \"escape\", event: evt });\n }\n }\n\n static hidePopup(reason?: PopupCloseReason, name = \"anon\", group = \"all\") {\n if (_popups.indexOf(name) !== -1) {\n popupClosed(name);\n const popupRoot = document.body.querySelector(`.vuuPopup.${group}`);\n if (popupRoot) {\n ReactDOM.unmountComponentAtNode(popupRoot);\n }\n }\n document.removeEventListener(\n \"keydown\",\n PopupService.escapeKeyListener,\n true\n );\n\n PopupService?.onClose?.(\n reason\n ? {\n ...reason,\n closedBy: \"popup-service\",\n }\n : undefined\n );\n }\n\n static keepWithinThePage(el: HTMLElement, right: number | \"auto\" = \"auto\") {\n const target = el.querySelector(\".vuuPopupContainer > *\") as HTMLElement;\n if (target) {\n const {\n top,\n left,\n width,\n height,\n right: currentRight,\n } = target.getBoundingClientRect();\n\n const w = window.innerWidth;\n const h = window.innerHeight;\n\n const overflowH = h - (top + height);\n if (overflowH < 0) {\n target.style.top = Math.round(top) + overflowH + \"px\";\n }\n\n const overflowW = w - (left + width);\n if (overflowW < 0) {\n target.style.left = Math.round(left) + overflowW + \"px\";\n }\n\n if (typeof right === \"number\" && right !== currentRight) {\n const adjustment = right - currentRight;\n target.style.left = left + adjustment + \"px\";\n }\n }\n }\n}\n\nexport class DialogService {\n static showDialog(dialog: ReactElement) {\n const containerEl = \".vuuDialog\";\n const onClose = dialog.props.onClose;\n\n dialogOpened();\n\n ReactDOM.render(\n React.cloneElement(dialog, {\n container: containerEl,\n onClose: () => {\n DialogService.closeDialog();\n if (onClose) {\n onClose();\n }\n },\n }),\n document.body.querySelector(containerEl)\n );\n }\n\n static closeDialog() {\n dialogClosed();\n const dialogRoot = document.body.querySelector(\".vuuDialog\");\n if (dialogRoot) {\n ReactDOM.unmountComponentAtNode(dialogRoot);\n }\n }\n}\n"],"names":["ReactDOM"],"mappings":";;;;;AAYA,IAAI,WAAc,GAAA,KAAA,CAAA;AAClB,MAAM,UAAoB,EAAC,CAAA;AAmCpB,MAAM,kBAAqB,GAAA,CAChC,MACmC,KAAA,MAAA,EAAQ,IAAS,KAAA,cAAA;AAE/C,MAAM,iBAAoB,GAAA,CAC/B,MACkC,KAAA,MAAA,EAAQ,IAAS,KAAA,aAAA;AAErD,SAAS,kBAAkB,CAAkB,EAAA;AAC3C,EAAI,IAAA,CAAA,CAAE,QAAQ,KAAO,EAAA;AACnB,IAAA,IAAI,QAAQ,MAAQ,EAAA;AAClB,MAAe,cAAA,EAAA,CAAA;AAAA,eACN,WAAa,EAAA;AACtB,MAAA,MAAM,UAAa,GAAA,QAAA,CAAS,IAAK,CAAA,aAAA,CAAc,YAAY,CAAA,CAAA;AAC3D,MAAA,IAAI,UAAY,EAAA;AACd,QAAAA,iBAAA,CAAS,uBAAuB,UAAU,CAAA,CAAA;AAAA,OAC5C;AAAA,KACF;AAAA,GACF;AACF,CAAA;AAEA,SAAS,oBAAoB,CAAe,EAAA;AAC1C,EAAA,IAAI,QAAQ,MAAQ,EAAA;AAClB,IAAM,MAAA,eAAA,GAAkB,SAAS,IAAK,CAAA,gBAAA;AAAA,MACpC,4BAAA;AAAA,KACF,CAAA;AACA,IAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,eAA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M,WAAc,GAAA,YAAA,CAAA;AACpB,IAAM,MAAA,OAAA,GAAU,OAAO,KAAM,CAAA,OAAA,CAAA;AAE7B,IAAa,YAAA,EAAA,CAAA;AAEb,IAASA,iBAAA,CAAA,MAAA;AAAA,MACP,KAAA,CAAM,aAAa,MAAQ,EAAA;AAAA,QACzB,SAAW,EAAA,WAAA;AAAA,QACX,SAAS,MAAM;AACb,UAAA,aAAA,CAAc,WAAY,EAAA,CAAA;AAC1B,UAAA,IAAI,OAAS,EAAA;AACX,YAAQ,OAAA,EAAA,CAAA;AAAA,WACV;AAAA,SACF;AAAA,OACD,CAAA;AAAA,MACD,QAAA,CAAS,IAAK,CAAA,aAAA,CAAc,WAAW,CAAA;AAAA,KACzC,CAAA;AAAA,GACF;AAAA,EAEA,OAAO,WAAc,GAAA;AACnB,IAAa,YAAA,EAAA,CAAA;AACb,IAAA,MAAM,UAAa,GAAA,QAAA,CAAS,IAAK,CAAA,aAAA,CAAc,YAAY,CAAA,CAAA;AAC3D,IAAA,IAAI,UAAY,EAAA;AACd,MAAAA,iBAAA,CAAS,uBAAuB,UAAU,CAAA,CAAA;AAAA,KAC5C;AAAA,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"popup-service.js","sources":["../../src/popup/popup-service.ts"],"sourcesContent":["import cx from \"clsx\";\nimport React, {\n createElement,\n CSSProperties,\n HTMLAttributes,\n KeyboardEvent as ReactKeyboardEvent,\n ReactElement,\n} from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { ContextMenuOptions } from \"../menu\";\nimport { renderPortal } from \"../portal-deprecated\";\n\nlet _dialogOpen = false;\nconst _popups: string[] = [];\n\nexport type PopupCloseCallback = (reason?: PopupCloseReason) => void;\n\nexport type TabAwayClosePopup = {\n closedBy?: string;\n type: \"tab-away\";\n event: ReactKeyboardEvent;\n};\n\nexport type ClickAwayClosePopup = {\n closedBy?: string;\n type: \"click-away\";\n mouseEvt: MouseEvent;\n};\n\nexport type EscapeClosePopup = {\n closedBy?: string;\n event: KeyboardEvent;\n type: \"escape\";\n};\n\nexport type MenuActionClosePopup = {\n closedBy?: string;\n menuId: string;\n options: ContextMenuOptions;\n type: \"menu-action\";\n};\n\nexport type PopupCloseReason =\n | ClickAwayClosePopup\n | EscapeClosePopup\n | MenuActionClosePopup\n | TabAwayClosePopup;\n\nexport const reasonIsMenuAction = (\n reason?: PopupCloseReason\n): reason is MenuActionClosePopup => reason?.type === \"menu-action\";\n\nexport const reasonIsClickAway = (\n reason?: PopupCloseReason\n): reason is ClickAwayClosePopup => reason?.type === \"click-away\";\n\nfunction specialKeyHandler(e: KeyboardEvent) {\n if (e.key === \"Esc\") {\n if (_popups.length) {\n closeAllPopups();\n } else if (_dialogOpen) {\n const dialogRoot = document.body.querySelector(\".vuuDialog\");\n if (dialogRoot) {\n ReactDOM.unmountComponentAtNode(dialogRoot);\n }\n }\n }\n}\n\nfunction outsideClickHandler(e: MouseEvent) {\n if (_popups.length) {\n const popupContainers = document.body.querySelectorAll(\n \".vuuPopup,#vuu-portal-root\"\n );\n for (let i = 0; i < popupContainers.length; i++) {\n if (popupContainers[i].contains(e.target as HTMLElement)) {\n return;\n }\n }\n closeAllPopups({ mouseEvt: e, type: \"click-away\" });\n }\n}\n\nfunction closeAllPopups(reason?: PopupCloseReason) {\n if (_popups.length === 1) {\n PopupService.hidePopup(reason, \"anon\", \"all\");\n } else if (_popups.length) {\n // onsole.log(`closeAllPopups`);\n const popupContainers = document.body.querySelectorAll(\".vuuPopup\");\n for (let i = 0; i < popupContainers.length; i++) {\n ReactDOM.unmountComponentAtNode(popupContainers[i]);\n }\n popupClosed(\"*\");\n }\n}\n\nfunction dialogOpened() {\n if (_dialogOpen === false) {\n _dialogOpen = true;\n window.addEventListener(\"keydown\", specialKeyHandler, true);\n }\n}\n\nfunction dialogClosed() {\n if (_dialogOpen) {\n _dialogOpen = false;\n window.removeEventListener(\"keydown\", specialKeyHandler, true);\n }\n}\n\nfunction popupOpened(name: string) {\n if (_popups.indexOf(name) === -1) {\n _popups.push(name);\n //onsole.log('PopupService, popup opened ' + name + ' popups : ' + _popups);\n if (_dialogOpen === false) {\n window.addEventListener(\"keydown\", specialKeyHandler, true);\n window.addEventListener(\"click\", outsideClickHandler, true);\n }\n }\n}\n\nfunction popupClosed(name: string /*, group=null*/) {\n if (_popups.length) {\n if (name === \"*\") {\n _popups.length = 0;\n } else {\n const pos = _popups.indexOf(name);\n if (pos !== -1) {\n _popups.splice(pos, 1);\n }\n }\n //onsole.log('PopupService, popup closed ' + name + ' popups : ' + _popups);\n if (_popups.length === 0 && _dialogOpen === false) {\n window.removeEventListener(\"keydown\", specialKeyHandler, true);\n window.removeEventListener(\"click\", outsideClickHandler, true);\n }\n }\n}\n\nconst PopupComponent = ({\n children,\n position,\n style,\n}: HTMLAttributes<HTMLDivElement> & {\n position?: \"above\" | \"below\" | \"\";\n style?: CSSProperties;\n}) => {\n const className = cx(\"hwPopup\", \"hwPopupContainer\", position);\n return createElement(\"div\", { className, style }, children);\n};\n\nlet incrementingKey = 1;\n\nexport interface ShowPopupProps {\n depth?: number;\n /**\n * if true, focus will be invoked on first focusable element\n */\n focus?: boolean;\n name?: string;\n group?: string;\n position?: \"above\" | \"below\" | \"\";\n left?: number;\n right?: \"auto\" | number;\n top?: number;\n component: ReactElement;\n width?: number | \"auto\";\n}\n\nexport class PopupService {\n static onClose: PopupCloseCallback | undefined;\n static showPopup({\n group = \"all\",\n name = \"anon\",\n left = 0,\n position = \"\",\n right = \"auto\",\n top = 0,\n width = \"auto\",\n component,\n }: ShowPopupProps) {\n if (!component) {\n throw Error(`PopupService showPopup, no component supplied`);\n }\n\n if (typeof component.props.onClose === \"function\") {\n PopupService.onClose = component.props.onClose;\n } else {\n PopupService.onClose = undefined;\n }\n\n popupOpened(name);\n\n document.addEventListener(\"keydown\", PopupService.escapeKeyListener, true);\n\n let el = document.body.querySelector(\".vuuPopup.\" + group) as HTMLElement;\n if (el === null) {\n el = document.createElement(\"div\") as HTMLElement;\n el.className = \"vuuPopup \" + group;\n document.body.appendChild(el);\n }\n\n const style = { width };\n\n renderPortal(\n createElement(\n PopupComponent,\n { key: incrementingKey++, position, style },\n component\n ),\n el,\n left,\n top,\n () => {\n PopupService.keepWithinThePage(el, right);\n }\n );\n }\n\n static escapeKeyListener(evt: KeyboardEvent) {\n if (evt.key === \"Escape\") {\n PopupService.hidePopup({ type: \"escape\", event: evt });\n }\n }\n\n static hidePopup(reason?: PopupCloseReason, name = \"anon\", group = \"all\") {\n if (_popups.indexOf(name) !== -1) {\n popupClosed(name);\n const popupRoot = document.body.querySelector(`.vuuPopup.${group}`);\n if (popupRoot) {\n ReactDOM.unmountComponentAtNode(popupRoot);\n }\n }\n document.removeEventListener(\n \"keydown\",\n PopupService.escapeKeyListener,\n true\n );\n\n PopupService?.onClose?.(\n reason\n ? {\n ...reason,\n closedBy: \"popup-service\",\n }\n : undefined\n );\n }\n\n static keepWithinThePage(el: HTMLElement, right: number | \"auto\" = \"auto\") {\n const target = el.querySelector(\".vuuPopupContainer > *\") as HTMLElement;\n if (target) {\n const {\n top,\n left,\n width,\n height,\n right: currentRight,\n } = target.getBoundingClientRect();\n\n const w = window.innerWidth;\n const h = window.innerHeight;\n\n const overflowH = h - (top + height);\n if (overflowH < 0) {\n target.style.top = Math.round(top) + overflowH + \"px\";\n }\n\n const overflowW = w - (left + width);\n if (overflowW < 0) {\n target.style.left = Math.round(left) + overflowW + \"px\";\n }\n\n if (typeof right === \"number\" && right !== currentRight) {\n const adjustment = right - currentRight;\n target.style.left = left + adjustment + \"px\";\n }\n }\n }\n}\n\nexport class DialogService {\n static showDialog(dialog: ReactElement) {\n const containerEl = \".vuuDialog\";\n const onClose = dialog.props.onClose;\n\n dialogOpened();\n\n ReactDOM.render(\n React.cloneElement(dialog, {\n container: containerEl,\n onClose: () => {\n DialogService.closeDialog();\n if (onClose) {\n onClose();\n }\n },\n }),\n document.body.querySelector(containerEl)\n );\n }\n\n static closeDialog() {\n dialogClosed();\n const dialogRoot = document.body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MAAQ,EAAA;AAAA,QACzB,SAAW,EAAA,WAAA;AAAA,QACX,SAAS,MAAM;AACb,UAAA,aAAA,CAAc,WAAY,EAAA,CAAA;AAC1B,UAAA,IAAI,OAAS,EAAA;AACX,YAAQ,OAAA,EAAA,CAAA;AAAA,WACV;AAAA,SACF;AAAA,OACD,CAAA;AAAA,MACD,QAAA,CAAS,IAAK,CAAA,aAAA,CAAc,WAAW,CAAA;AAAA,KACzC,CAAA;AAAA,GACF;AAAA,EAEA,OAAO,WAAc,GAAA;AACnB,IAAa,YAAA,EAAA,CAAA;AACb,IAAA,MAAM,UAAa,GAAA,QAAA,CAAS,IAAK,CAAA,aAAA,CAAc,YAAY,CAAA,CAAA;AAC3D,IAAA,IAAI,UAAY,EAAA;AACd,MAAAA,iBAAA,CAAS,uBAAuB,UAAU,CAAA,CAAA;AAAA,KAC5C;AAAA,GACF;AACF;;;;"}
|
package/esm/prompt/Prompt.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useComponentCssInjection } from '@salt-ds/styles';
|
|
|
5
5
|
import { useWindow } from '@salt-ds/window';
|
|
6
6
|
import cx from 'clsx';
|
|
7
7
|
import { useRef, useLayoutEffect } from 'react';
|
|
8
|
-
import '
|
|
8
|
+
import '../popup/popup-service.js';
|
|
9
9
|
import { useAnchoredPosition } from '../popup/useAnchoredPosition.js';
|
|
10
10
|
import propmtCss from './Prompt.css.js';
|
|
11
11
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.8.
|
|
2
|
+
"version": "0.8.95",
|
|
3
3
|
"description": "VUU popup components - Context Menu, Dialog etc",
|
|
4
4
|
"author": "heswell",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
"@salt-ds/core": "1.34.0",
|
|
8
8
|
"@salt-ds/styles": "0.2.1",
|
|
9
9
|
"@salt-ds/window": "0.1.1",
|
|
10
|
-
"@vuu-ui/vuu-data-types": "0.8.
|
|
11
|
-
"@vuu-ui/vuu-layout": "0.8.
|
|
12
|
-
"@vuu-ui/vuu-utils": "0.8.
|
|
13
|
-
"@vuu-ui/vuu-ui-controls": "0.8.
|
|
10
|
+
"@vuu-ui/vuu-data-types": "0.8.95",
|
|
11
|
+
"@vuu-ui/vuu-layout": "0.8.95",
|
|
12
|
+
"@vuu-ui/vuu-utils": "0.8.95",
|
|
13
|
+
"@vuu-ui/vuu-ui-controls": "0.8.95"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"clsx": "^2.0.0",
|