@elliemae/ds-menu-items 3.18.0-next.4 → 3.18.0-next.5

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.
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var getChevronHandlers_exports = {};
30
+ __export(getChevronHandlers_exports, {
31
+ getChevronHandlers: () => getChevronHandlers
32
+ });
33
+ module.exports = __toCommonJS(getChevronHandlers_exports);
34
+ var React = __toESM(require("react"));
35
+ const getChevronHandlers = ({
36
+ isSubmenuOpened,
37
+ onMouseEnter,
38
+ onSubmenuOpen,
39
+ onSubmenuClose,
40
+ onMouseLeave
41
+ }) => {
42
+ const timeoutRef = { current: null };
43
+ const onMouseEnterHandler = (e) => {
44
+ if (timeoutRef.current !== null)
45
+ clearTimeout(timeoutRef.current);
46
+ else if (!isSubmenuOpened)
47
+ onSubmenuOpen?.(e);
48
+ timeoutRef.current = null;
49
+ onMouseEnter?.(e);
50
+ };
51
+ const onMouseLeaveHandler = (e) => {
52
+ if (timeoutRef.current === null) {
53
+ timeoutRef.current = setTimeout(() => {
54
+ timeoutRef.current = null;
55
+ onSubmenuClose?.(e);
56
+ }, 300);
57
+ }
58
+ onMouseLeave?.(e);
59
+ };
60
+ const onEllipsisClick = () => {
61
+ throw new Error("Invoking onEllipsisClick from chevron handlers... this should never happen");
62
+ };
63
+ return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };
64
+ };
65
+ //# sourceMappingURL=getChevronHandlers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/SubmenuItem/getChevronHandlers.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import type { DSMenuItemT } from '../../react-desc-prop-types.js';\n\n// what we are trying to do:\n// onMouseEnter -> open submenu\n// onMouseLeave -> close submenu\n// onEllipsisClick -> we should not even invoke this handler, as the \"ellipsis\" should not even exist?\n\n// what are the \"challenges\" of the task:\n// - the submenu close has an animation and we ideally want to be sure state changes after the animation is done\n// (we do it via an hardcoded 300ms delay, this is know to cause issues in some cases)\n// - \"what is open and what is closed\" state lives under ds-dropdownmenu,\n// we manipulate it via \"onSubmenuOpen\" and \"onSubmenuClose\" callbacks\n// - we have created the API in such a way that we implement a \"bridge\" and \"inversion of control\" pattern\n// this requires extra care when handling the logic and designing the solution\n\n// important and relevant info:\n// when this comment has been written,\n// onSubmenuOpen coming from SingleWithSubmenuProps is forcing only one submenu to be open at a time internally\n// the logic for this is implemented in ds-dropdownmenu,\n// we had a bug in which we were invoking a stale callback,\n// we monkeypatching it by ensuring the callback never changes\n// in the future we should create code with \"hydraters\" to avoid this as per shuttle-v2\n\nexport const getChevronHandlers = ({\n isSubmenuOpened,\n onMouseEnter,\n onSubmenuOpen,\n onSubmenuClose,\n onMouseLeave,\n}: Required<DSMenuItemT.SingleWithSubmenuProps>) => {\n const timeoutRef: { current: NodeJS.Timeout | null } = { current: null };\n\n const onMouseEnterHandler = (e: React.MouseEvent) => {\n if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);\n else if (!isSubmenuOpened) onSubmenuOpen?.(e);\n timeoutRef.current = null;\n onMouseEnter?.(e);\n };\n\n const onMouseLeaveHandler = (e: React.MouseEvent) => {\n if (timeoutRef.current === null) {\n timeoutRef.current = setTimeout(() => {\n timeoutRef.current = null;\n onSubmenuClose?.(e);\n }, 300);\n }\n onMouseLeave?.(e);\n };\n const onEllipsisClick = () => {\n throw new Error('Invoking onEllipsisClick from chevron handlers... this should never happen');\n };\n\n return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADuBhB,MAAM,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAoD;AAClD,QAAM,aAAiD,EAAE,SAAS,KAAK;AAEvE,QAAM,sBAAsB,CAAC,MAAwB;AACnD,QAAI,WAAW,YAAY;AAAM,mBAAa,WAAW,OAAO;AAAA,aACvD,CAAC;AAAiB,sBAAgB,CAAC;AAC5C,eAAW,UAAU;AACrB,mBAAe,CAAC;AAAA,EAClB;AAEA,QAAM,sBAAsB,CAAC,MAAwB;AACnD,QAAI,WAAW,YAAY,MAAM;AAC/B,iBAAW,UAAU,WAAW,MAAM;AACpC,mBAAW,UAAU;AACrB,yBAAiB,CAAC;AAAA,MACpB,GAAG,GAAG;AAAA,IACR;AACA,mBAAe,CAAC;AAAA,EAClB;AACA,QAAM,kBAAkB,MAAM;AAC5B,UAAM,IAAI,MAAM,4EAA4E;AAAA,EAC9F;AAEA,SAAO,EAAE,qBAAqB,qBAAqB,gBAAgB;AACrE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var getEllipsisHandlers_exports = {};
30
+ __export(getEllipsisHandlers_exports, {
31
+ getEllipsisHandlers: () => getEllipsisHandlers
32
+ });
33
+ module.exports = __toCommonJS(getEllipsisHandlers_exports);
34
+ var React = __toESM(require("react"));
35
+ const getEllipsisHandlers = ({
36
+ disabled,
37
+ isSubmenuOpened,
38
+ onMouseEnter,
39
+ onSubmenuOpen,
40
+ onSubmenuClose,
41
+ onMouseLeave
42
+ }) => {
43
+ const onMouseEnterHandler = (e) => onMouseEnter?.(e);
44
+ const onMouseLeaveHandler = (e) => onMouseLeave?.(e);
45
+ const onEllipsisClick = (e) => {
46
+ if (disabled)
47
+ return;
48
+ e.stopPropagation();
49
+ if (isSubmenuOpened)
50
+ onSubmenuClose(e);
51
+ else
52
+ onSubmenuOpen(e);
53
+ };
54
+ return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };
55
+ };
56
+ //# sourceMappingURL=getEllipsisHandlers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/SubmenuItem/getEllipsisHandlers.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import type { DSMenuItemT } from '../../react-desc-prop-types.js';\n\n// what we are trying to do:\n// onMouseEnter -> be transparently \"doing nothing\" as hover does nothing by design for \"ellipsis\"\n// onMouseLeave -> be transparently \"doing nothing\" as hover does nothing by design for \"ellipsis\"\n// onEllipsisClick -> toggle the submenu open/close as per design\n\n// what are the \"challenges\" of the task:\n// - we have created the API in such a way that we implement a \"bridge\" and \"inversion of control\" pattern\n// this requires extra care when handling the logic and designing the solution\n\nexport const getEllipsisHandlers = ({\n disabled,\n isSubmenuOpened,\n onMouseEnter,\n onSubmenuOpen,\n onSubmenuClose,\n onMouseLeave,\n}: Required<DSMenuItemT.SingleWithSubmenuProps>) => {\n // why not just onMouseEnterHandler = onMouseEnter?\n // we expect onMouseEnterHandler/onMouseLeaveHandler\n // to always exist even if onMouseEnter/onMouseLeave are undefined\n // also, if in the future we need custom logic for these handlers, we can add it here\n const onMouseEnterHandler: React.MouseEventHandler = (e) => onMouseEnter?.(e);\n const onMouseLeaveHandler: React.MouseEventHandler = (e) => onMouseLeave?.(e);\n\n const onEllipsisClick: React.MouseEventHandler = (e) => {\n if (disabled) return;\n e.stopPropagation();\n if (isSubmenuOpened) onSubmenuClose(e);\n else onSubmenuOpen(e);\n };\n\n return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADWhB,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAoD;AAKlD,QAAM,sBAA+C,CAAC,MAAM,eAAe,CAAC;AAC5E,QAAM,sBAA+C,CAAC,MAAM,eAAe,CAAC;AAE5E,QAAM,kBAA2C,CAAC,MAAM;AACtD,QAAI;AAAU;AACd,MAAE,gBAAgB;AAClB,QAAI;AAAiB,qBAAe,CAAC;AAAA;AAChC,oBAAc,CAAC;AAAA,EACtB;AAEA,SAAO,EAAE,qBAAqB,qBAAqB,gBAAgB;AACrE;",
6
+ "names": []
7
+ }
@@ -33,55 +33,14 @@ __export(useGetSubmenuHandlers_exports, {
33
33
  module.exports = __toCommonJS(useGetSubmenuHandlers_exports);
34
34
  var React = __toESM(require("react"));
35
35
  var import_react = require("react");
36
- const useGetSubmenuHandlers = ({
37
- disabled,
38
- rightAddon,
39
- isSubmenuOpened,
40
- onMouseEnter,
41
- onSubmenuOpen,
42
- onSubmenuClose,
43
- onMouseLeave
44
- }) => {
45
- const timeoutRef = (0, import_react.useRef)(null);
46
- const onMouseEnterHandler = (0, import_react.useCallback)(
47
- (e) => {
48
- if (rightAddon !== "ellipsis") {
49
- if (timeoutRef.current !== null)
50
- clearTimeout(timeoutRef.current);
51
- else if (!isSubmenuOpened)
52
- onSubmenuOpen(e);
53
- timeoutRef.current = null;
54
- }
55
- onMouseEnter(e);
56
- },
57
- [isSubmenuOpened, onMouseEnter, onSubmenuOpen, rightAddon]
58
- );
59
- const onMouseLeaveHandler = (0, import_react.useCallback)(
60
- (e) => {
61
- if (rightAddon !== "ellipsis") {
62
- if (timeoutRef.current === null) {
63
- timeoutRef.current = setTimeout(() => {
64
- timeoutRef.current = null;
65
- onSubmenuClose(e);
66
- }, 300);
67
- }
68
- }
69
- onMouseLeave(e);
70
- },
71
- [onMouseLeave, onSubmenuClose, rightAddon]
72
- );
73
- const onEllipsisClick = (0, import_react.useCallback)(
74
- (e) => {
75
- if (disabled)
76
- return;
77
- e.stopPropagation();
78
- if (isSubmenuOpened)
79
- onSubmenuClose(e);
80
- else
81
- onSubmenuOpen(e);
82
- },
83
- [disabled, isSubmenuOpened, onSubmenuClose, onSubmenuOpen]
84
- );
85
- return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };
36
+ var import_getEllipsisHandlers = require("./getEllipsisHandlers.js");
37
+ var import_getChevronHandlers = require("./getChevronHandlers.js");
38
+ const useGetSubmenuHandlers = (submenuProps) => {
39
+ const { rightAddon } = submenuProps;
40
+ return (0, import_react.useMemo)(() => {
41
+ if (rightAddon === "ellipsis")
42
+ return (0, import_getEllipsisHandlers.getEllipsisHandlers)(submenuProps);
43
+ return (0, import_getChevronHandlers.getChevronHandlers)(submenuProps);
44
+ }, [submenuProps, rightAddon]);
86
45
  };
87
46
  //# sourceMappingURL=useGetSubmenuHandlers.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/SubmenuItem/useGetSubmenuHandlers.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useRef, useCallback } from 'react';\nimport type { DSMenuItemT } from '../../react-desc-prop-types.js';\n\nexport const useGetSubmenuHandlers = ({\n disabled,\n rightAddon,\n isSubmenuOpened,\n onMouseEnter,\n onSubmenuOpen,\n onSubmenuClose,\n onMouseLeave,\n}: Required<DSMenuItemT.SubmenuProps>) => {\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n const onMouseEnterHandler = useCallback(\n (e: React.MouseEvent) => {\n if (rightAddon !== 'ellipsis') {\n if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);\n else if (!isSubmenuOpened) onSubmenuOpen(e);\n timeoutRef.current = null;\n }\n onMouseEnter(e);\n },\n [isSubmenuOpened, onMouseEnter, onSubmenuOpen, rightAddon],\n );\n\n const onMouseLeaveHandler = useCallback(\n (e: React.MouseEvent) => {\n if (rightAddon !== 'ellipsis') {\n if (timeoutRef.current === null) {\n timeoutRef.current = setTimeout(() => {\n timeoutRef.current = null;\n onSubmenuClose(e);\n }, 300);\n }\n }\n onMouseLeave(e);\n },\n [onMouseLeave, onSubmenuClose, rightAddon],\n );\n\n const onEllipsisClick: React.MouseEventHandler = useCallback(\n (e) => {\n if (disabled) return;\n e.stopPropagation();\n if (isSubmenuOpened) onSubmenuClose(e);\n else onSubmenuOpen(e);\n },\n [disabled, isSubmenuOpened, onSubmenuClose, onSubmenuOpen],\n );\n\n return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAoC;AAG7B,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0C;AACxC,QAAM,iBAAa,qBAA8B,IAAI;AAErD,QAAM,0BAAsB;AAAA,IAC1B,CAAC,MAAwB;AACvB,UAAI,eAAe,YAAY;AAC7B,YAAI,WAAW,YAAY;AAAM,uBAAa,WAAW,OAAO;AAAA,iBACvD,CAAC;AAAiB,wBAAc,CAAC;AAC1C,mBAAW,UAAU;AAAA,MACvB;AACA,mBAAa,CAAC;AAAA,IAChB;AAAA,IACA,CAAC,iBAAiB,cAAc,eAAe,UAAU;AAAA,EAC3D;AAEA,QAAM,0BAAsB;AAAA,IAC1B,CAAC,MAAwB;AACvB,UAAI,eAAe,YAAY;AAC7B,YAAI,WAAW,YAAY,MAAM;AAC/B,qBAAW,UAAU,WAAW,MAAM;AACpC,uBAAW,UAAU;AACrB,2BAAe,CAAC;AAAA,UAClB,GAAG,GAAG;AAAA,QACR;AAAA,MACF;AACA,mBAAa,CAAC;AAAA,IAChB;AAAA,IACA,CAAC,cAAc,gBAAgB,UAAU;AAAA,EAC3C;AAEA,QAAM,sBAA2C;AAAA,IAC/C,CAAC,MAAM;AACL,UAAI;AAAU;AACd,QAAE,gBAAgB;AAClB,UAAI;AAAiB,uBAAe,CAAC;AAAA;AAChC,sBAAc,CAAC;AAAA,IACtB;AAAA,IACA,CAAC,UAAU,iBAAiB,gBAAgB,aAAa;AAAA,EAC3D;AAEA,SAAO,EAAE,qBAAqB,qBAAqB,gBAAgB;AACrE;",
4
+ "sourcesContent": ["import { useMemo } from 'react';\nimport type { DSMenuItemT } from '../../react-desc-prop-types.js';\nimport { getEllipsisHandlers } from './getEllipsisHandlers.js';\nimport { getChevronHandlers } from './getChevronHandlers.js';\n\n// what we are trying to do:\n// Ellipsis case:\n// onMouseEnter -> open submenu\n// onMouseLeave -> close submenu\n// onEllipsisClick -> we should not even invoke this handler, as the \"ellipsis\" should not even exist?\n// Chevron case:\n// onMouseEnter -> be transparently \"doing nothing\" as hover does nothing by design for \"ellipsis\"\n// onMouseLeave -> be transparently \"doing nothing\" as hover does nothing by design for \"ellipsis\"\n// onEllipsisClick -> toggle the submenu open/close as per design\n\n// what are the \"challenges\" of the task:\n// - we have chosen to abstract multiple possible logical \"flows\" into the same layer for some reason\n// specifically speaking this is trying to solve the\n// \"rightAddons\" is \"ellipsis\" case\n// at the same time as the\n// \"rightAddons\" is \"chevron\" case\n// they have more differences than similarities, so this is messy\n\n// @yuri since I'm both lazy and stupid, I want my code to be as stupid simple as me\n// I am removing one layer of abstraction,\n// ellipsis gets it's own logical flow\n// as does chevron\n// if you are a DRY advocate, you will probably hate me for this, I'm all for AHA (Avoid Hasty Abstractions).\nexport const useGetSubmenuHandlers = (submenuProps: Required<DSMenuItemT.SingleWithSubmenuProps>) => {\n const { rightAddon } = submenuProps;\n return useMemo(() => {\n if (rightAddon === 'ellipsis') return getEllipsisHandlers(submenuProps);\n return getChevronHandlers(submenuProps);\n }, [submenuProps, rightAddon]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwB;AAExB,iCAAoC;AACpC,gCAAmC;AAyB5B,MAAM,wBAAwB,CAAC,iBAA+D;AACnG,QAAM,EAAE,WAAW,IAAI;AACvB,aAAO,sBAAQ,MAAM;AACnB,QAAI,eAAe;AAAY,iBAAO,gDAAoB,YAAY;AACtE,eAAO,8CAAmB,YAAY;AAAA,EACxC,GAAG,CAAC,cAAc,UAAU,CAAC;AAC/B;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,35 @@
1
+ import * as React from "react";
2
+ const getChevronHandlers = ({
3
+ isSubmenuOpened,
4
+ onMouseEnter,
5
+ onSubmenuOpen,
6
+ onSubmenuClose,
7
+ onMouseLeave
8
+ }) => {
9
+ const timeoutRef = { current: null };
10
+ const onMouseEnterHandler = (e) => {
11
+ if (timeoutRef.current !== null)
12
+ clearTimeout(timeoutRef.current);
13
+ else if (!isSubmenuOpened)
14
+ onSubmenuOpen?.(e);
15
+ timeoutRef.current = null;
16
+ onMouseEnter?.(e);
17
+ };
18
+ const onMouseLeaveHandler = (e) => {
19
+ if (timeoutRef.current === null) {
20
+ timeoutRef.current = setTimeout(() => {
21
+ timeoutRef.current = null;
22
+ onSubmenuClose?.(e);
23
+ }, 300);
24
+ }
25
+ onMouseLeave?.(e);
26
+ };
27
+ const onEllipsisClick = () => {
28
+ throw new Error("Invoking onEllipsisClick from chevron handlers... this should never happen");
29
+ };
30
+ return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };
31
+ };
32
+ export {
33
+ getChevronHandlers
34
+ };
35
+ //# sourceMappingURL=getChevronHandlers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/SubmenuItem/getChevronHandlers.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSMenuItemT } from '../../react-desc-prop-types.js';\n\n// what we are trying to do:\n// onMouseEnter -> open submenu\n// onMouseLeave -> close submenu\n// onEllipsisClick -> we should not even invoke this handler, as the \"ellipsis\" should not even exist?\n\n// what are the \"challenges\" of the task:\n// - the submenu close has an animation and we ideally want to be sure state changes after the animation is done\n// (we do it via an hardcoded 300ms delay, this is know to cause issues in some cases)\n// - \"what is open and what is closed\" state lives under ds-dropdownmenu,\n// we manipulate it via \"onSubmenuOpen\" and \"onSubmenuClose\" callbacks\n// - we have created the API in such a way that we implement a \"bridge\" and \"inversion of control\" pattern\n// this requires extra care when handling the logic and designing the solution\n\n// important and relevant info:\n// when this comment has been written,\n// onSubmenuOpen coming from SingleWithSubmenuProps is forcing only one submenu to be open at a time internally\n// the logic for this is implemented in ds-dropdownmenu,\n// we had a bug in which we were invoking a stale callback,\n// we monkeypatching it by ensuring the callback never changes\n// in the future we should create code with \"hydraters\" to avoid this as per shuttle-v2\n\nexport const getChevronHandlers = ({\n isSubmenuOpened,\n onMouseEnter,\n onSubmenuOpen,\n onSubmenuClose,\n onMouseLeave,\n}: Required<DSMenuItemT.SingleWithSubmenuProps>) => {\n const timeoutRef: { current: NodeJS.Timeout | null } = { current: null };\n\n const onMouseEnterHandler = (e: React.MouseEvent) => {\n if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);\n else if (!isSubmenuOpened) onSubmenuOpen?.(e);\n timeoutRef.current = null;\n onMouseEnter?.(e);\n };\n\n const onMouseLeaveHandler = (e: React.MouseEvent) => {\n if (timeoutRef.current === null) {\n timeoutRef.current = setTimeout(() => {\n timeoutRef.current = null;\n onSubmenuClose?.(e);\n }, 300);\n }\n onMouseLeave?.(e);\n };\n const onEllipsisClick = () => {\n throw new Error('Invoking onEllipsisClick from chevron handlers... this should never happen');\n };\n\n return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACuBhB,MAAM,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAoD;AAClD,QAAM,aAAiD,EAAE,SAAS,KAAK;AAEvE,QAAM,sBAAsB,CAAC,MAAwB;AACnD,QAAI,WAAW,YAAY;AAAM,mBAAa,WAAW,OAAO;AAAA,aACvD,CAAC;AAAiB,sBAAgB,CAAC;AAC5C,eAAW,UAAU;AACrB,mBAAe,CAAC;AAAA,EAClB;AAEA,QAAM,sBAAsB,CAAC,MAAwB;AACnD,QAAI,WAAW,YAAY,MAAM;AAC/B,iBAAW,UAAU,WAAW,MAAM;AACpC,mBAAW,UAAU;AACrB,yBAAiB,CAAC;AAAA,MACpB,GAAG,GAAG;AAAA,IACR;AACA,mBAAe,CAAC;AAAA,EAClB;AACA,QAAM,kBAAkB,MAAM;AAC5B,UAAM,IAAI,MAAM,4EAA4E;AAAA,EAC9F;AAEA,SAAO,EAAE,qBAAqB,qBAAqB,gBAAgB;AACrE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,26 @@
1
+ import * as React from "react";
2
+ const getEllipsisHandlers = ({
3
+ disabled,
4
+ isSubmenuOpened,
5
+ onMouseEnter,
6
+ onSubmenuOpen,
7
+ onSubmenuClose,
8
+ onMouseLeave
9
+ }) => {
10
+ const onMouseEnterHandler = (e) => onMouseEnter?.(e);
11
+ const onMouseLeaveHandler = (e) => onMouseLeave?.(e);
12
+ const onEllipsisClick = (e) => {
13
+ if (disabled)
14
+ return;
15
+ e.stopPropagation();
16
+ if (isSubmenuOpened)
17
+ onSubmenuClose(e);
18
+ else
19
+ onSubmenuOpen(e);
20
+ };
21
+ return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };
22
+ };
23
+ export {
24
+ getEllipsisHandlers
25
+ };
26
+ //# sourceMappingURL=getEllipsisHandlers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/SubmenuItem/getEllipsisHandlers.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSMenuItemT } from '../../react-desc-prop-types.js';\n\n// what we are trying to do:\n// onMouseEnter -> be transparently \"doing nothing\" as hover does nothing by design for \"ellipsis\"\n// onMouseLeave -> be transparently \"doing nothing\" as hover does nothing by design for \"ellipsis\"\n// onEllipsisClick -> toggle the submenu open/close as per design\n\n// what are the \"challenges\" of the task:\n// - we have created the API in such a way that we implement a \"bridge\" and \"inversion of control\" pattern\n// this requires extra care when handling the logic and designing the solution\n\nexport const getEllipsisHandlers = ({\n disabled,\n isSubmenuOpened,\n onMouseEnter,\n onSubmenuOpen,\n onSubmenuClose,\n onMouseLeave,\n}: Required<DSMenuItemT.SingleWithSubmenuProps>) => {\n // why not just onMouseEnterHandler = onMouseEnter?\n // we expect onMouseEnterHandler/onMouseLeaveHandler\n // to always exist even if onMouseEnter/onMouseLeave are undefined\n // also, if in the future we need custom logic for these handlers, we can add it here\n const onMouseEnterHandler: React.MouseEventHandler = (e) => onMouseEnter?.(e);\n const onMouseLeaveHandler: React.MouseEventHandler = (e) => onMouseLeave?.(e);\n\n const onEllipsisClick: React.MouseEventHandler = (e) => {\n if (disabled) return;\n e.stopPropagation();\n if (isSubmenuOpened) onSubmenuClose(e);\n else onSubmenuOpen(e);\n };\n\n return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACWhB,MAAM,sBAAsB,CAAC;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAoD;AAKlD,QAAM,sBAA+C,CAAC,MAAM,eAAe,CAAC;AAC5E,QAAM,sBAA+C,CAAC,MAAM,eAAe,CAAC;AAE5E,QAAM,kBAA2C,CAAC,MAAM;AACtD,QAAI;AAAU;AACd,MAAE,gBAAgB;AAClB,QAAI;AAAiB,qBAAe,CAAC;AAAA;AAChC,oBAAc,CAAC;AAAA,EACtB;AAEA,SAAO,EAAE,qBAAqB,qBAAqB,gBAAgB;AACrE;",
6
+ "names": []
7
+ }
@@ -1,55 +1,14 @@
1
1
  import * as React from "react";
2
- import { useRef, useCallback } from "react";
3
- const useGetSubmenuHandlers = ({
4
- disabled,
5
- rightAddon,
6
- isSubmenuOpened,
7
- onMouseEnter,
8
- onSubmenuOpen,
9
- onSubmenuClose,
10
- onMouseLeave
11
- }) => {
12
- const timeoutRef = useRef(null);
13
- const onMouseEnterHandler = useCallback(
14
- (e) => {
15
- if (rightAddon !== "ellipsis") {
16
- if (timeoutRef.current !== null)
17
- clearTimeout(timeoutRef.current);
18
- else if (!isSubmenuOpened)
19
- onSubmenuOpen(e);
20
- timeoutRef.current = null;
21
- }
22
- onMouseEnter(e);
23
- },
24
- [isSubmenuOpened, onMouseEnter, onSubmenuOpen, rightAddon]
25
- );
26
- const onMouseLeaveHandler = useCallback(
27
- (e) => {
28
- if (rightAddon !== "ellipsis") {
29
- if (timeoutRef.current === null) {
30
- timeoutRef.current = setTimeout(() => {
31
- timeoutRef.current = null;
32
- onSubmenuClose(e);
33
- }, 300);
34
- }
35
- }
36
- onMouseLeave(e);
37
- },
38
- [onMouseLeave, onSubmenuClose, rightAddon]
39
- );
40
- const onEllipsisClick = useCallback(
41
- (e) => {
42
- if (disabled)
43
- return;
44
- e.stopPropagation();
45
- if (isSubmenuOpened)
46
- onSubmenuClose(e);
47
- else
48
- onSubmenuOpen(e);
49
- },
50
- [disabled, isSubmenuOpened, onSubmenuClose, onSubmenuOpen]
51
- );
52
- return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };
2
+ import { useMemo } from "react";
3
+ import { getEllipsisHandlers } from "./getEllipsisHandlers.js";
4
+ import { getChevronHandlers } from "./getChevronHandlers.js";
5
+ const useGetSubmenuHandlers = (submenuProps) => {
6
+ const { rightAddon } = submenuProps;
7
+ return useMemo(() => {
8
+ if (rightAddon === "ellipsis")
9
+ return getEllipsisHandlers(submenuProps);
10
+ return getChevronHandlers(submenuProps);
11
+ }, [submenuProps, rightAddon]);
53
12
  };
54
13
  export {
55
14
  useGetSubmenuHandlers
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/SubmenuItem/useGetSubmenuHandlers.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef, useCallback } from 'react';\nimport type { DSMenuItemT } from '../../react-desc-prop-types.js';\n\nexport const useGetSubmenuHandlers = ({\n disabled,\n rightAddon,\n isSubmenuOpened,\n onMouseEnter,\n onSubmenuOpen,\n onSubmenuClose,\n onMouseLeave,\n}: Required<DSMenuItemT.SubmenuProps>) => {\n const timeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n const onMouseEnterHandler = useCallback(\n (e: React.MouseEvent) => {\n if (rightAddon !== 'ellipsis') {\n if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);\n else if (!isSubmenuOpened) onSubmenuOpen(e);\n timeoutRef.current = null;\n }\n onMouseEnter(e);\n },\n [isSubmenuOpened, onMouseEnter, onSubmenuOpen, rightAddon],\n );\n\n const onMouseLeaveHandler = useCallback(\n (e: React.MouseEvent) => {\n if (rightAddon !== 'ellipsis') {\n if (timeoutRef.current === null) {\n timeoutRef.current = setTimeout(() => {\n timeoutRef.current = null;\n onSubmenuClose(e);\n }, 300);\n }\n }\n onMouseLeave(e);\n },\n [onMouseLeave, onSubmenuClose, rightAddon],\n );\n\n const onEllipsisClick: React.MouseEventHandler = useCallback(\n (e) => {\n if (disabled) return;\n e.stopPropagation();\n if (isSubmenuOpened) onSubmenuClose(e);\n else onSubmenuOpen(e);\n },\n [disabled, isSubmenuOpened, onSubmenuClose, onSubmenuOpen],\n );\n\n return { onMouseEnterHandler, onMouseLeaveHandler, onEllipsisClick };\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,QAAQ,mBAAmB;AAG7B,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0C;AACxC,QAAM,aAAa,OAA8B,IAAI;AAErD,QAAM,sBAAsB;AAAA,IAC1B,CAAC,MAAwB;AACvB,UAAI,eAAe,YAAY;AAC7B,YAAI,WAAW,YAAY;AAAM,uBAAa,WAAW,OAAO;AAAA,iBACvD,CAAC;AAAiB,wBAAc,CAAC;AAC1C,mBAAW,UAAU;AAAA,MACvB;AACA,mBAAa,CAAC;AAAA,IAChB;AAAA,IACA,CAAC,iBAAiB,cAAc,eAAe,UAAU;AAAA,EAC3D;AAEA,QAAM,sBAAsB;AAAA,IAC1B,CAAC,MAAwB;AACvB,UAAI,eAAe,YAAY;AAC7B,YAAI,WAAW,YAAY,MAAM;AAC/B,qBAAW,UAAU,WAAW,MAAM;AACpC,uBAAW,UAAU;AACrB,2BAAe,CAAC;AAAA,UAClB,GAAG,GAAG;AAAA,QACR;AAAA,MACF;AACA,mBAAa,CAAC;AAAA,IAChB;AAAA,IACA,CAAC,cAAc,gBAAgB,UAAU;AAAA,EAC3C;AAEA,QAAM,kBAA2C;AAAA,IAC/C,CAAC,MAAM;AACL,UAAI;AAAU;AACd,QAAE,gBAAgB;AAClB,UAAI;AAAiB,uBAAe,CAAC;AAAA;AAChC,sBAAc,CAAC;AAAA,IACtB;AAAA,IACA,CAAC,UAAU,iBAAiB,gBAAgB,aAAa;AAAA,EAC3D;AAEA,SAAO,EAAE,qBAAqB,qBAAqB,gBAAgB;AACrE;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport type { DSMenuItemT } from '../../react-desc-prop-types.js';\nimport { getEllipsisHandlers } from './getEllipsisHandlers.js';\nimport { getChevronHandlers } from './getChevronHandlers.js';\n\n// what we are trying to do:\n// Ellipsis case:\n// onMouseEnter -> open submenu\n// onMouseLeave -> close submenu\n// onEllipsisClick -> we should not even invoke this handler, as the \"ellipsis\" should not even exist?\n// Chevron case:\n// onMouseEnter -> be transparently \"doing nothing\" as hover does nothing by design for \"ellipsis\"\n// onMouseLeave -> be transparently \"doing nothing\" as hover does nothing by design for \"ellipsis\"\n// onEllipsisClick -> toggle the submenu open/close as per design\n\n// what are the \"challenges\" of the task:\n// - we have chosen to abstract multiple possible logical \"flows\" into the same layer for some reason\n// specifically speaking this is trying to solve the\n// \"rightAddons\" is \"ellipsis\" case\n// at the same time as the\n// \"rightAddons\" is \"chevron\" case\n// they have more differences than similarities, so this is messy\n\n// @yuri since I'm both lazy and stupid, I want my code to be as stupid simple as me\n// I am removing one layer of abstraction,\n// ellipsis gets it's own logical flow\n// as does chevron\n// if you are a DRY advocate, you will probably hate me for this, I'm all for AHA (Avoid Hasty Abstractions).\nexport const useGetSubmenuHandlers = (submenuProps: Required<DSMenuItemT.SingleWithSubmenuProps>) => {\n const { rightAddon } = submenuProps;\n return useMemo(() => {\n if (rightAddon === 'ellipsis') return getEllipsisHandlers(submenuProps);\n return getChevronHandlers(submenuProps);\n }, [submenuProps, rightAddon]);\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe;AAExB,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AAyB5B,MAAM,wBAAwB,CAAC,iBAA+D;AACnG,QAAM,EAAE,WAAW,IAAI;AACvB,SAAO,QAAQ,MAAM;AACnB,QAAI,eAAe;AAAY,aAAO,oBAAoB,YAAY;AACtE,WAAO,mBAAmB,YAAY;AAAA,EACxC,GAAG,CAAC,cAAc,UAAU,CAAC;AAC/B;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,6 @@
1
+ import type { DSMenuItemT } from '../../react-desc-prop-types.js';
2
+ export declare const getChevronHandlers: ({ isSubmenuOpened, onMouseEnter, onSubmenuOpen, onSubmenuClose, onMouseLeave, }: Required<DSMenuItemT.SingleWithSubmenuProps>) => {
3
+ onMouseEnterHandler: (e: React.MouseEvent) => void;
4
+ onMouseLeaveHandler: (e: React.MouseEvent) => void;
5
+ onEllipsisClick: () => never;
6
+ };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { DSMenuItemT } from '../../react-desc-prop-types.js';
3
+ export declare const getEllipsisHandlers: ({ disabled, isSubmenuOpened, onMouseEnter, onSubmenuOpen, onSubmenuClose, onMouseLeave, }: Required<DSMenuItemT.SingleWithSubmenuProps>) => {
4
+ onMouseEnterHandler: import("react").MouseEventHandler<Element>;
5
+ onMouseLeaveHandler: import("react").MouseEventHandler<Element>;
6
+ onEllipsisClick: import("react").MouseEventHandler<Element>;
7
+ };
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import type { DSMenuItemT } from '../../react-desc-prop-types.js';
3
- export declare const useGetSubmenuHandlers: ({ disabled, rightAddon, isSubmenuOpened, onMouseEnter, onSubmenuOpen, onSubmenuClose, onMouseLeave, }: Required<DSMenuItemT.SubmenuProps>) => {
4
- onMouseEnterHandler: (e: React.MouseEvent) => void;
5
- onMouseLeaveHandler: (e: React.MouseEvent) => void;
3
+ export declare const useGetSubmenuHandlers: (submenuProps: Required<DSMenuItemT.SingleWithSubmenuProps>) => {
4
+ onMouseEnterHandler: import("react").MouseEventHandler<Element>;
5
+ onMouseLeaveHandler: import("react").MouseEventHandler<Element>;
6
6
  onEllipsisClick: import("react").MouseEventHandler<Element>;
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-menu-items",
3
- "version": "3.18.0-next.4",
3
+ "version": "3.18.0-next.5",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Menu Items",
6
6
  "files": [
@@ -37,11 +37,11 @@
37
37
  "dependencies": {
38
38
  "@xstyled/system": "~3.7.3",
39
39
  "@xstyled/util": "3.7.0",
40
- "@elliemae/ds-form-checkbox": "3.18.0-next.4",
41
- "@elliemae/ds-icons": "3.18.0-next.4",
42
- "@elliemae/ds-props-helpers": "3.18.0-next.4",
43
- "@elliemae/ds-grid": "3.18.0-next.4",
44
- "@elliemae/ds-system": "3.18.0-next.4"
40
+ "@elliemae/ds-form-checkbox": "3.18.0-next.5",
41
+ "@elliemae/ds-grid": "3.18.0-next.5",
42
+ "@elliemae/ds-icons": "3.18.0-next.5",
43
+ "@elliemae/ds-props-helpers": "3.18.0-next.5",
44
+ "@elliemae/ds-system": "3.18.0-next.5"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "lodash": "^4.17.21",