@hanzogui/z-index-stack 3.0.2 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/package.json +7 -7
  2. package/src/types.ts +1 -1
  3. package/src/useStackedZIndex.tsx +1 -1
  4. package/types/types.d.ts +1 -1
  5. package/dist/cjs/StackZIndex.cjs +0 -42
  6. package/dist/cjs/StackZIndex.native.js +0 -46
  7. package/dist/cjs/StackZIndex.native.js.map +0 -1
  8. package/dist/cjs/context.cjs +0 -29
  9. package/dist/cjs/context.native.js +0 -32
  10. package/dist/cjs/context.native.js.map +0 -1
  11. package/dist/cjs/index.cjs +0 -20
  12. package/dist/cjs/index.native.js +0 -23
  13. package/dist/cjs/index.native.js.map +0 -1
  14. package/dist/cjs/types.cjs +0 -16
  15. package/dist/cjs/types.native.js +0 -19
  16. package/dist/cjs/types.native.js.map +0 -1
  17. package/dist/cjs/useStackedZIndex.cjs +0 -80
  18. package/dist/cjs/useStackedZIndex.native.js +0 -89
  19. package/dist/cjs/useStackedZIndex.native.js.map +0 -1
  20. package/dist/esm/StackZIndex.mjs +0 -19
  21. package/dist/esm/StackZIndex.mjs.map +0 -1
  22. package/dist/esm/StackZIndex.native.js +0 -20
  23. package/dist/esm/StackZIndex.native.js.map +0 -1
  24. package/dist/esm/context.mjs +0 -5
  25. package/dist/esm/context.mjs.map +0 -1
  26. package/dist/esm/context.native.js +0 -5
  27. package/dist/esm/context.native.js.map +0 -1
  28. package/dist/esm/index.js +0 -4
  29. package/dist/esm/index.js.map +0 -1
  30. package/dist/esm/index.mjs +0 -4
  31. package/dist/esm/index.mjs.map +0 -1
  32. package/dist/esm/index.native.js +0 -4
  33. package/dist/esm/index.native.js.map +0 -1
  34. package/dist/esm/types.mjs +0 -2
  35. package/dist/esm/types.mjs.map +0 -1
  36. package/dist/esm/types.native.js +0 -2
  37. package/dist/esm/types.native.js.map +0 -1
  38. package/dist/esm/useStackedZIndex.mjs +0 -57
  39. package/dist/esm/useStackedZIndex.mjs.map +0 -1
  40. package/dist/esm/useStackedZIndex.native.js +0 -63
  41. package/dist/esm/useStackedZIndex.native.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzogui/z-index-stack",
3
- "version": "3.0.2",
3
+ "version": "7.0.0",
4
4
  "source": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -30,16 +30,16 @@
30
30
  "access": "public"
31
31
  },
32
32
  "scripts": {
33
- "build": "hanzo-gui-build",
34
- "watch": "hanzo-gui-build --watch",
35
- "clean": "hanzo-gui-build clean",
36
- "clean:build": "hanzo-gui-build clean:build"
33
+ "build": "hanzogui-build",
34
+ "watch": "hanzogui-build --watch",
35
+ "clean": "hanzogui-build clean",
36
+ "clean:build": "hanzogui-build clean:build"
37
37
  },
38
38
  "devDependencies": {
39
- "@hanzogui/build": "3.0.1",
39
+ "@hanzogui/build": "^7.0.0",
40
40
  "react": ">=19"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": ">=19"
44
44
  }
45
- }
45
+ }
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Gui will attempt to stack z-index in a smart way when true, it does this
2
+ * Hanzogui will attempt to stack z-index in a smart way when true, it does this
3
3
  * by automatically increasing z-index both horizontally and vertically in the component tree.
4
4
  *
5
5
  * Basically - if two stackable items are at the same level, then the order of mounting
@@ -12,7 +12,7 @@ export const useStackedZIndex = (props: {
12
12
  zIndex?: number
13
13
  stackZIndex?: StackZIndexProp
14
14
  }) => {
15
- if (process.env.HANZO_GUI_STACK_Z_INDEX_GLOBAL) {
15
+ if (process.env.TAMAGUI_STACK_Z_INDEX_GLOBAL) {
16
16
  const { stackZIndex, zIndex: zIndexProp } = props
17
17
  const id = useId()
18
18
 
package/types/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Gui will attempt to stack z-index in a smart way when true, it does this
2
+ * Hanzogui will attempt to stack z-index in a smart way when true, it does this
3
3
  * by automatically increasing z-index both horizontally and vertically in the component tree.
4
4
  *
5
5
  * Basically - if two stackable items are at the same level, then the order of mounting
@@ -1,42 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- return to;
17
- };
18
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
20
- }), mod);
21
- var StackZIndex_exports = {};
22
- __export(StackZIndex_exports, {
23
- StackZIndexContext: () => StackZIndexContext
24
- });
25
- module.exports = __toCommonJS(StackZIndex_exports);
26
- var import_react = require("react"),
27
- import_context = require("./context.cjs"),
28
- import_jsx_runtime = require("react/jsx-runtime");
29
- const StackZIndexContext = ({
30
- children,
31
- zIndex
32
- }) => {
33
- const existing = (0, import_react.useContext)(import_context.ZIndexStackContext);
34
- let content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_context.ZIndexStackContext.Provider, {
35
- value: existing + 1,
36
- children
37
- });
38
- return typeof zIndex < "u" && (content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_context.ZIndexHardcodedContext.Provider, {
39
- value: zIndex,
40
- children: content
41
- })), content;
42
- };
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
22
- }), mod);
23
- var StackZIndex_exports = {};
24
- __export(StackZIndex_exports, {
25
- StackZIndexContext: () => StackZIndexContext
26
- });
27
- module.exports = __toCommonJS(StackZIndex_exports);
28
- var import_jsx_runtime = require("react/jsx-runtime"),
29
- import_react = require("react"),
30
- import_context = require("./context.native.js"),
31
- StackZIndexContext = function (param) {
32
- var {
33
- children,
34
- zIndex
35
- } = param,
36
- existing = (0, import_react.useContext)(import_context.ZIndexStackContext),
37
- content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_context.ZIndexStackContext.Provider, {
38
- value: existing + 1,
39
- children
40
- });
41
- return typeof zIndex < "u" && (content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_context.ZIndexHardcodedContext.Provider, {
42
- value: zIndex,
43
- children: content
44
- })), content;
45
- };
46
- //# sourceMappingURL=StackZIndex.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","StackZIndex_exports","__export","StackZIndexContext","module","exports","import_jsx_runtime","require","import_react","import_context","param","children","zIndex","existing","useContext","ZIndexStackContext","content","jsx","Provider","ZIndexHardcodedContext"],"sources":["../../src/StackZIndex.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,mBAAA;AAAAC,QAAA,CAAAD,mBAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA2B,CAAAK,mBAC3B;AAEO,IAAAK,kBAAM,GAAAC,OAAsB;EAAAC,YAAA,GAAAD,OAAA;EAAAE,cAAA,GAAAF,OAAA;EAAAJ,kBAAA,YAAAA,CAAAO,KAAA;IACjC;QAAAC,QAAA;QAAAC;MAAA,IAAAF,KAAA;MAAAG,QAAA,OAAAL,YAAA,CAAAM,UAAA,EAAAL,cAAA,CAAAM,kBAAA;MAAAC,OAAA,sBAAAV,kBAAA,CAAAW,GAAA,EAAAR,cAAA,CAAAM,kBAAA,CAAAG,QAAA;QACAlB,KAAA,EAAAa,QAAA;QACFF;MAIE;IAEA,OAAI,OACFC,MAAA,WAAAI,OAAA,mBAAC,GAAAV,kBAAA,CAAAW,GAAA,EAAAR,cAAmB,CAAAU,sBAA2B,CAAAD,QAC5C;MAILlB,KAAI,EAAAY,MAAO;MASbD,QAAA,EAAAK","ignoreList":[]}
@@ -1,29 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- return to;
17
- };
18
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
20
- }), mod);
21
- var context_exports = {};
22
- __export(context_exports, {
23
- ZIndexHardcodedContext: () => ZIndexHardcodedContext,
24
- ZIndexStackContext: () => ZIndexStackContext
25
- });
26
- module.exports = __toCommonJS(context_exports);
27
- var import_react = require("react");
28
- const ZIndexStackContext = (0, import_react.createContext)(1),
29
- ZIndexHardcodedContext = (0, import_react.createContext)(void 0);
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
22
- }), mod);
23
- var context_exports = {};
24
- __export(context_exports, {
25
- ZIndexHardcodedContext: () => ZIndexHardcodedContext,
26
- ZIndexStackContext: () => ZIndexStackContext
27
- });
28
- module.exports = __toCommonJS(context_exports);
29
- var import_react = require("react"),
30
- ZIndexStackContext = (0, import_react.createContext)(1),
31
- ZIndexHardcodedContext = (0, import_react.createContext)(void 0);
32
- //# sourceMappingURL=context.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","context_exports","__export","ZIndexHardcodedContext","ZIndexStackContext","module","exports","import_react","require","createContext"],"sources":["../../src/context.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,eAAA;AAAAC,QAAA,CAAAD,eAAA;EAAAE,sBAAA,EAAAA,CAAA,KAAAA,sBAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAV,YAA8B,CAAAK,eAAA;AAGvB,IAAAM,YAAM,GAAAC,OAAA,QAAqB;EAAAJ,kBAAA,IAAc,CAAC,EAAAG,YAGpC,CAAAE,aAAA,IAAyB;EAAAN,sBAAA,IAAkC,GAAAI,YAAS,CAAAE,aAAA","ignoreList":[]}
@@ -1,20 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
- get: () => from[key],
8
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
- });
10
- return to;
11
- },
12
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
- value: !0
15
- }), mod);
16
- var index_exports = {};
17
- module.exports = __toCommonJS(index_exports);
18
- __reExport(index_exports, require("./useStackedZIndex.cjs"), module.exports);
19
- __reExport(index_exports, require("./StackZIndex.cjs"), module.exports);
20
- __reExport(index_exports, require("./context.cjs"), module.exports);
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
- get: () => from[key],
10
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
- });
12
- return to;
13
- },
14
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
- value: !0
17
- }), mod);
18
- var index_exports = {};
19
- module.exports = __toCommonJS(index_exports);
20
- __reExport(index_exports, require("./useStackedZIndex.native.js"), module.exports);
21
- __reExport(index_exports, require("./StackZIndex.native.js"), module.exports);
22
- __reExport(index_exports, require("./context.native.js"), module.exports);
23
- //# sourceMappingURL=index.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,+BADd,GAAAH,MAAA,CAAAC,OAAA;AAEAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,0BAFd,GAAAH,MAAA,CAAAC,OAAA","ignoreList":[]}
@@ -1,16 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
- get: () => from[key],
8
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
- });
10
- return to;
11
- };
12
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
13
- value: !0
14
- }), mod);
15
- var types_exports = {};
16
- module.exports = __toCommonJS(types_exports);
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
- get: () => from[key],
10
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
- });
12
- return to;
13
- };
14
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
15
- value: !0
16
- }), mod);
17
- var types_exports = {};
18
- module.exports = __toCommonJS(types_exports);
19
- //# sourceMappingURL=types.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","types_exports"],"sources":["../../src/types.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA","ignoreList":[]}
@@ -1,80 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- return to;
17
- };
18
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
20
- }), mod);
21
- var useStackedZIndex_exports = {};
22
- __export(useStackedZIndex_exports, {
23
- useStackedZIndex: () => useStackedZIndex
24
- });
25
- module.exports = __toCommonJS(useStackedZIndex_exports);
26
- var import_react = require("react"),
27
- import_context = require("./context.cjs");
28
- const ZIndicesByContext = {},
29
- CurrentPortalZIndices = {},
30
- useStackedZIndex = props => {
31
- if (process.env.HANZO_GUI_STACK_Z_INDEX_GLOBAL) {
32
- const {
33
- stackZIndex,
34
- zIndex: zIndexProp
35
- } = props,
36
- id = (0, import_react.useId)(),
37
- zIndex = (0, import_react.useMemo)(() => {
38
- if (stackZIndex && stackZIndex !== "global" && zIndexProp === void 0) {
39
- const highest = Object.values(CurrentPortalZIndices).reduce((acc, cur) => Math.max(acc, cur), 0);
40
- return Math.max(stackZIndex === !0 ? 1 : stackZIndex, highest + 1);
41
- }
42
- return zIndexProp ?? 1e3;
43
- }, [stackZIndex]);
44
- return (0, import_react.useEffect)(() => {
45
- if (typeof stackZIndex == "number") return CurrentPortalZIndices[id] = stackZIndex, () => {
46
- delete CurrentPortalZIndices[id];
47
- };
48
- }, [stackZIndex]), zIndex;
49
- } else {
50
- const {
51
- stackZIndex,
52
- zIndex: zIndexProp
53
- } = props,
54
- id = (0, import_react.useId)(),
55
- stackingContextLevel = (0, import_react.useContext)(import_context.ZIndexStackContext),
56
- stackLayer = stackZIndex === "global" ? 0 : stackingContextLevel,
57
- hardcoded = (0, import_react.useContext)(import_context.ZIndexHardcodedContext);
58
- ZIndicesByContext[stackLayer] ||= {};
59
- const stackContext = ZIndicesByContext[stackLayer],
60
- zIndex = (0, import_react.useMemo)(() => {
61
- if (typeof zIndexProp == "number") return zIndexProp;
62
- if (stackZIndex) {
63
- if (hardcoded) return hardcoded + 1;
64
- const entries = Object.values(stackContext),
65
- baseForLayer = stackLayer * 5e3,
66
- nextLayerBase = (stackLayer + 1) * 5e3,
67
- validEntries = entries.filter(z => z < nextLayerBase),
68
- highest = validEntries.length > 0 ? Math.max(...validEntries) : baseForLayer,
69
- nextZIndex = highest === baseForLayer ? baseForLayer + 1 : highest + 1;
70
- return typeof stackZIndex == "number" ? stackZIndex + nextZIndex : nextZIndex;
71
- }
72
- return 1;
73
- }, [stackLayer, zIndexProp, stackZIndex]);
74
- return (0, import_react.useEffect)(() => {
75
- if (stackZIndex) return stackContext[id] = zIndex, () => {
76
- delete stackContext[id];
77
- };
78
- }, [zIndex]), zIndex;
79
- }
80
- };
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- return to;
19
- };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
22
- }), mod);
23
- var useStackedZIndex_exports = {};
24
- __export(useStackedZIndex_exports, {
25
- useStackedZIndex: () => useStackedZIndex
26
- });
27
- module.exports = __toCommonJS(useStackedZIndex_exports);
28
- var import_react = require("react"),
29
- import_context = require("./context.native.js"),
30
- ZIndicesByContext = {},
31
- CurrentPortalZIndices = {},
32
- useStackedZIndex = function (props) {
33
- if (process.env.HANZO_GUI_STACK_Z_INDEX_GLOBAL) {
34
- var {
35
- stackZIndex,
36
- zIndex: zIndexProp
37
- } = props,
38
- id = (0, import_react.useId)(),
39
- zIndex = (0, import_react.useMemo)(function () {
40
- if (stackZIndex && stackZIndex !== "global" && zIndexProp === void 0) {
41
- var highest = Object.values(CurrentPortalZIndices).reduce(function (acc, cur) {
42
- return Math.max(acc, cur);
43
- }, 0);
44
- return Math.max(stackZIndex === !0 ? 1 : stackZIndex, highest + 1);
45
- }
46
- return zIndexProp ?? 1e3;
47
- }, [stackZIndex]);
48
- return (0, import_react.useEffect)(function () {
49
- if (typeof stackZIndex == "number") return CurrentPortalZIndices[id] = stackZIndex, function () {
50
- delete CurrentPortalZIndices[id];
51
- };
52
- }, [stackZIndex]), zIndex;
53
- } else {
54
- var _ZIndicesByContext,
55
- _stackLayer,
56
- {
57
- stackZIndex: stackZIndex1,
58
- zIndex: zIndexProp1
59
- } = props,
60
- id1 = (0, import_react.useId)(),
61
- stackingContextLevel = (0, import_react.useContext)(import_context.ZIndexStackContext),
62
- stackLayer = stackZIndex1 === "global" ? 0 : stackingContextLevel,
63
- hardcoded = (0, import_react.useContext)(import_context.ZIndexHardcodedContext);
64
- (_ZIndicesByContext = ZIndicesByContext)[_stackLayer = stackLayer] || (_ZIndicesByContext[_stackLayer] = {});
65
- var stackContext = ZIndicesByContext[stackLayer],
66
- zIndex1 = (0, import_react.useMemo)(function () {
67
- if (typeof zIndexProp1 == "number") return zIndexProp1;
68
- if (stackZIndex1) {
69
- if (hardcoded) return hardcoded + 1;
70
- var entries = Object.values(stackContext),
71
- baseForLayer = stackLayer * 5e3,
72
- nextLayerBase = (stackLayer + 1) * 5e3,
73
- validEntries = entries.filter(function (z) {
74
- return z < nextLayerBase;
75
- }),
76
- highest = validEntries.length > 0 ? Math.max(...validEntries) : baseForLayer,
77
- nextZIndex = highest === baseForLayer ? baseForLayer + 1 : highest + 1;
78
- return typeof stackZIndex1 == "number" ? stackZIndex1 + nextZIndex : nextZIndex;
79
- }
80
- return 1;
81
- }, [stackLayer, zIndexProp1, stackZIndex1]);
82
- return (0, import_react.useEffect)(function () {
83
- if (stackZIndex1) return stackContext[id1] = zIndex1, function () {
84
- delete stackContext[id1];
85
- };
86
- }, [zIndex1]), zIndex1;
87
- }
88
- };
89
- //# sourceMappingURL=useStackedZIndex.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useStackedZIndex_exports","__export","useStackedZIndex","module","exports","import_react","require","import_context","ZIndicesByContext","CurrentPortalZIndices","props","process","env","HANZO_GUI_STACK_Z_INDEX_GLOBAL","stackZIndex","zIndex","zIndexProp","id","useId","useMemo","highest","Object","values","reduce","acc","cur","Math","max","useEffect","_ZIndicesByContext","_stackLayer","stackZIndex1","zIndexProp1","id1","stackingContextLevel","useContext","ZIndexStackContext","stackLayer","hardcoded","ZIndexHardcodedContext","stackContext","zIndex1","entries","baseForLayer","nextLayerBase","validEntries","filter","z","length","nextZIndex"],"sources":["../../src/useStackedZIndex.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,wBAAA;AAAAC,QAAA,CAAAD,wBAAA;EAAAE,gBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAsD,CAAAK,wBACK;AAI3D,IAAAK,YAAM,GAAAC,OAA4D,CAAC,OAG7D;EAAAC,cAAA,GAAgDD,OAEzC;EAAAE,iBAGP;EAAAC,qBAAA;EAAAP,gBAAA,YAAAA,CAAAQ,KAAA;IACJ,IAAIC,OAAA,CAAQC,GAAA,CAAIC,8BAAA,EAAgC;MAC9C;UAAMC,WAAE;UAAAC,MAAa,EAAAC;QAAQ,IAAWN,KAAI;QAAAO,EACtC,OAAAZ,YAAK,CAAAa,KAAA;QAAMH,MAEX,OAAAV,YAAS,CAAAc,OAAA,cAAc;UAC3B,IAAIL,WAAA,IAAeA,WAAA,KAAgB,YAAYE,UAAA,KAAe,QAAW;YACvE,IAAAI,OAAM,GAAAC,MAAU,CAAA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WAAAC,CAAA;gBACL,OAAAA,CAAA,GAAYH,aAAY;cAE5B;cAAAxB,OAAA,GAAAyB,YAAA,CAAAG,MAAU,IAAM,GAAAtB,IAAA,CAAAC,GAAA,IAAAkB,YAAA,IAAAF,YAAA;cAAAM,UAAA,GAAA7B,OAAA,KAAAuB,YAAA,GAAAA,YAAA,OAAAvB,OAAA;YACd,OAAI,OAAAW,YAAA,eAAAA,YAAA,GAAAkB,UAAA,GAAAA,UAAA;UACF;UAEE;QAAsB,IAG5BZ,UAAW,EAGbL,WAAA,EACFD,YAAA,C","ignoreList":[]}
@@ -1,19 +0,0 @@
1
- import { useContext } from "react";
2
- import { ZIndexHardcodedContext, ZIndexStackContext } from "./context.mjs";
3
- import { jsx } from "react/jsx-runtime";
4
- const StackZIndexContext = ({
5
- children,
6
- zIndex
7
- }) => {
8
- const existing = useContext(ZIndexStackContext);
9
- let content = /* @__PURE__ */jsx(ZIndexStackContext.Provider, {
10
- value: existing + 1,
11
- children
12
- });
13
- return typeof zIndex < "u" && (content = /* @__PURE__ */jsx(ZIndexHardcodedContext.Provider, {
14
- value: zIndex,
15
- children: content
16
- })), content;
17
- };
18
- export { StackZIndexContext };
19
- //# sourceMappingURL=StackZIndex.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useContext","ZIndexHardcodedContext","ZIndexStackContext","jsx","StackZIndexContext","children","zIndex","existing","content","Provider","value"],"sources":["../../src/StackZIndex.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,QAAkB;AAC3B,SAASC,sBAAA,EAAwBC,kBAAA,QAA0B;AAYvD,SAAAC,GAAA;AAVG,MAAMC,kBAAA,GAAqBA,CAAC;EACjCC,QAAA;EACAC;AACF,MAGM;EACJ,MAAMC,QAAA,GAAWP,UAAA,CAAWE,kBAAkB;EAE9C,IAAIM,OAAA,GACF,eAAAL,GAAA,CAACD,kBAAA,CAAmBO,QAAA,EAAnB;IAA4BC,KAAA,EAAOH,QAAA,GAAW;IAC5CF;EAAA,CACH;EAGF,OAAI,OAAOC,MAAA,GAAW,QACpBE,OAAA,GACE,eAAAL,GAAA,CAACF,sBAAA,CAAuBQ,QAAA,EAAvB;IAAgCC,KAAA,EAAOJ,MAAA;IACrCD,QAAA,EAAAG;EAAA,CACH,IAIGA,OAAA;AACT","ignoreList":[]}
@@ -1,20 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useContext } from "react";
3
- import { ZIndexHardcodedContext, ZIndexStackContext } from "./context.native.js";
4
- var StackZIndexContext = function (param) {
5
- var {
6
- children,
7
- zIndex
8
- } = param,
9
- existing = useContext(ZIndexStackContext),
10
- content = /* @__PURE__ */_jsx(ZIndexStackContext.Provider, {
11
- value: existing + 1,
12
- children
13
- });
14
- return typeof zIndex < "u" && (content = /* @__PURE__ */_jsx(ZIndexHardcodedContext.Provider, {
15
- value: zIndex,
16
- children: content
17
- })), content;
18
- };
19
- export { StackZIndexContext };
20
- //# sourceMappingURL=StackZIndex.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["jsx","_jsx","useContext","ZIndexHardcodedContext","ZIndexStackContext","StackZIndexContext","param","children","zIndex","existing","content","Provider","value"],"sources":["../../src/StackZIndex.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,QAAkB;AAC3B,SAASC,UAAA,eAAwB;AAY7B,SAAAC,sBAAA,EAAAC,kBAAA;AAVG,IAAAC,kBAAM,YAAAA,CAAsBC,KAAA;EACjC;MAAAC,QAAA;MAAAC;IAAA,IAAAF,KAAA;IAAAG,QAAA,GAAAP,UAAA,CAAAE,kBAAA;IAAAM,OAAA,kBAAAT,IAAA,CAAAG,kBAAA,CAAAO,QAAA;MACAC,KAAA,EAAAH,QAAA;MACFF;IAIE;EAEA,OAAI,OACFC,MAAA,WAAAE,OAAC,kBAAmBT,IAAA,CAAAE,sBAA2B,CAAAQ,QAC5C;IAILC,KAAI,EAAAJ,MAAO;IASbD,QAAA,EAAAG","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- import { createContext } from "react";
2
- const ZIndexStackContext = createContext(1),
3
- ZIndexHardcodedContext = createContext(void 0);
4
- export { ZIndexHardcodedContext, ZIndexStackContext };
5
- //# sourceMappingURL=context.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createContext","ZIndexStackContext","ZIndexHardcodedContext"],"sources":["../../src/context.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,aAAA,QAAqB;AAGvB,MAAMC,kBAAA,GAAqBD,aAAA,CAAc,CAAC;EAGpCE,sBAAA,GAAyBF,aAAA,CAAkC,MAAS","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- import { createContext } from "react";
2
- var ZIndexStackContext = createContext(1),
3
- ZIndexHardcodedContext = createContext(void 0);
4
- export { ZIndexHardcodedContext, ZIndexStackContext };
5
- //# sourceMappingURL=context.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createContext","ZIndexStackContext","ZIndexHardcodedContext"],"sources":["../../src/context.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,aAAA,QAAqB;AAGvB,IAAAC,kBAAM,GAAAD,aAAqB,GAAc;EAACE,sBAGpC,GAAAF,aAAyB,MAAkC","ignoreList":[]}
package/dist/esm/index.js DELETED
@@ -1,4 +0,0 @@
1
- export * from "./useStackedZIndex.mjs";
2
- export * from "./StackZIndex.mjs";
3
- export * from "./context.mjs";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- export * from "./useStackedZIndex.mjs";
2
- export * from "./StackZIndex.mjs";
3
- export * from "./context.mjs";
4
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- export * from "./useStackedZIndex.native.js";
2
- export * from "./StackZIndex.native.js";
3
- export * from "./context.native.js";
4
- //# sourceMappingURL=index.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc","ignoreList":[]}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=types.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
@@ -1,57 +0,0 @@
1
- import { useContext, useEffect, useId, useMemo } from "react";
2
- import { ZIndexHardcodedContext, ZIndexStackContext } from "./context.mjs";
3
- const ZIndicesByContext = {},
4
- CurrentPortalZIndices = {},
5
- useStackedZIndex = props => {
6
- if (process.env.HANZO_GUI_STACK_Z_INDEX_GLOBAL) {
7
- const {
8
- stackZIndex,
9
- zIndex: zIndexProp
10
- } = props,
11
- id = useId(),
12
- zIndex = useMemo(() => {
13
- if (stackZIndex && stackZIndex !== "global" && zIndexProp === void 0) {
14
- const highest = Object.values(CurrentPortalZIndices).reduce((acc, cur) => Math.max(acc, cur), 0);
15
- return Math.max(stackZIndex === !0 ? 1 : stackZIndex, highest + 1);
16
- }
17
- return zIndexProp ?? 1e3;
18
- }, [stackZIndex]);
19
- return useEffect(() => {
20
- if (typeof stackZIndex == "number") return CurrentPortalZIndices[id] = stackZIndex, () => {
21
- delete CurrentPortalZIndices[id];
22
- };
23
- }, [stackZIndex]), zIndex;
24
- } else {
25
- const {
26
- stackZIndex,
27
- zIndex: zIndexProp
28
- } = props,
29
- id = useId(),
30
- stackingContextLevel = useContext(ZIndexStackContext),
31
- stackLayer = stackZIndex === "global" ? 0 : stackingContextLevel,
32
- hardcoded = useContext(ZIndexHardcodedContext);
33
- ZIndicesByContext[stackLayer] ||= {};
34
- const stackContext = ZIndicesByContext[stackLayer],
35
- zIndex = useMemo(() => {
36
- if (typeof zIndexProp == "number") return zIndexProp;
37
- if (stackZIndex) {
38
- if (hardcoded) return hardcoded + 1;
39
- const entries = Object.values(stackContext),
40
- baseForLayer = stackLayer * 5e3,
41
- nextLayerBase = (stackLayer + 1) * 5e3,
42
- validEntries = entries.filter(z => z < nextLayerBase),
43
- highest = validEntries.length > 0 ? Math.max(...validEntries) : baseForLayer,
44
- nextZIndex = highest === baseForLayer ? baseForLayer + 1 : highest + 1;
45
- return typeof stackZIndex == "number" ? stackZIndex + nextZIndex : nextZIndex;
46
- }
47
- return 1;
48
- }, [stackLayer, zIndexProp, stackZIndex]);
49
- return useEffect(() => {
50
- if (stackZIndex) return stackContext[id] = zIndex, () => {
51
- delete stackContext[id];
52
- };
53
- }, [zIndex]), zIndex;
54
- }
55
- };
56
- export { useStackedZIndex };
57
- //# sourceMappingURL=useStackedZIndex.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useContext","useEffect","useId","useMemo","ZIndexHardcodedContext","ZIndexStackContext","ZIndicesByContext","CurrentPortalZIndices","useStackedZIndex","props","process","env","HANZO_GUI_STACK_Z_INDEX_GLOBAL","stackZIndex","zIndex","zIndexProp","id","highest","Object","values","reduce","acc","cur","Math","max","stackingContextLevel","stackLayer","hardcoded","stackContext","entries","baseForLayer","nextLayerBase","validEntries","filter","z","length","nextZIndex"],"sources":["../../src/useStackedZIndex.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,EAAYC,SAAA,EAAWC,KAAA,EAAOC,OAAA,QAAe;AACtD,SAASC,sBAAA,EAAwBC,kBAAA,QAA0B;AAI3D,MAAMC,iBAAA,GAA4D,CAAC;EAG7DC,qBAAA,GAAgD,CAAC;EAE1CC,gBAAA,GAAoBC,KAAA,IAG3B;IACJ,IAAIC,OAA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a;YACf,IAAIc,SAAA,EACF,OAAOA,SAAA,GAAY;YAGrB,MAAME,OAAA,GAAUX,MAAA,CAAOC,MAAA,CAAOS,YAAY;cACpCE,YAAA,GAAeJ,UAAA,GAAa;cAC5BK,aAAA,IAAiBL,UAAA,GAAa,KAAK;cAInCM,YAAA,GAAeH,OAAA,CAAQI,MAAA,CAAQC,CAAA,IAAMA,CAAA,GAAIH,aAAa;cAEtDd,OAAA,GAAUe,YAAA,CAAaG,MAAA,GAAS,IAAIZ,IAAA,CAAKC,GAAA,CAAI,GAAGQ,YAAY,IAAIF,YAAA;cAGhEM,UAAA,GAAanB,OAAA,KAAYa,YAAA,GAAeA,YAAA,GAAe,IAAIb,OAAA,GAAU;YAG3E,OAAO,OAAOJ,WAAA,IAAgB,WAAWA,WAAA,GAAcuB,UAAA,GAAaA,UAAA;UACtE;UAEA,OAAO;QACT,GAAG,CAACV,UAAA,EAAYX,UAAA,EAAYF,WAAW,CAAC;MAExC,OAAAZ,SAAA,CAAU,MAAM;QACd,IAAIY,WAAA,EACF,OAAAe,YAAA,CAAaZ,EAAE,IAAIF,MAAA,EACZ,MAAM;UACX,OAAOc,YAAA,CAAaZ,EAAE;QACxB;MAEJ,GAAG,CAACF,MAAM,CAAC,GAEJA,MAAA;IACT;EACF","ignoreList":[]}
@@ -1,63 +0,0 @@
1
- import { useContext, useEffect, useId, useMemo } from "react";
2
- import { ZIndexHardcodedContext, ZIndexStackContext } from "./context.native.js";
3
- var ZIndicesByContext = {},
4
- CurrentPortalZIndices = {},
5
- useStackedZIndex = function (props) {
6
- if (process.env.HANZO_GUI_STACK_Z_INDEX_GLOBAL) {
7
- var {
8
- stackZIndex,
9
- zIndex: zIndexProp
10
- } = props,
11
- id = useId(),
12
- zIndex = useMemo(function () {
13
- if (stackZIndex && stackZIndex !== "global" && zIndexProp === void 0) {
14
- var highest = Object.values(CurrentPortalZIndices).reduce(function (acc, cur) {
15
- return Math.max(acc, cur);
16
- }, 0);
17
- return Math.max(stackZIndex === !0 ? 1 : stackZIndex, highest + 1);
18
- }
19
- return zIndexProp ?? 1e3;
20
- }, [stackZIndex]);
21
- return useEffect(function () {
22
- if (typeof stackZIndex == "number") return CurrentPortalZIndices[id] = stackZIndex, function () {
23
- delete CurrentPortalZIndices[id];
24
- };
25
- }, [stackZIndex]), zIndex;
26
- } else {
27
- var _ZIndicesByContext,
28
- _stackLayer,
29
- {
30
- stackZIndex: stackZIndex1,
31
- zIndex: zIndexProp1
32
- } = props,
33
- id1 = useId(),
34
- stackingContextLevel = useContext(ZIndexStackContext),
35
- stackLayer = stackZIndex1 === "global" ? 0 : stackingContextLevel,
36
- hardcoded = useContext(ZIndexHardcodedContext);
37
- (_ZIndicesByContext = ZIndicesByContext)[_stackLayer = stackLayer] || (_ZIndicesByContext[_stackLayer] = {});
38
- var stackContext = ZIndicesByContext[stackLayer],
39
- zIndex1 = useMemo(function () {
40
- if (typeof zIndexProp1 == "number") return zIndexProp1;
41
- if (stackZIndex1) {
42
- if (hardcoded) return hardcoded + 1;
43
- var entries = Object.values(stackContext),
44
- baseForLayer = stackLayer * 5e3,
45
- nextLayerBase = (stackLayer + 1) * 5e3,
46
- validEntries = entries.filter(function (z) {
47
- return z < nextLayerBase;
48
- }),
49
- highest = validEntries.length > 0 ? Math.max(...validEntries) : baseForLayer,
50
- nextZIndex = highest === baseForLayer ? baseForLayer + 1 : highest + 1;
51
- return typeof stackZIndex1 == "number" ? stackZIndex1 + nextZIndex : nextZIndex;
52
- }
53
- return 1;
54
- }, [stackLayer, zIndexProp1, stackZIndex1]);
55
- return useEffect(function () {
56
- if (stackZIndex1) return stackContext[id1] = zIndex1, function () {
57
- delete stackContext[id1];
58
- };
59
- }, [zIndex1]), zIndex1;
60
- }
61
- };
62
- export { useStackedZIndex };
63
- //# sourceMappingURL=useStackedZIndex.native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useContext","useEffect","useId","useMemo","ZIndexHardcodedContext","ZIndexStackContext","ZIndicesByContext","CurrentPortalZIndices","useStackedZIndex","props","process","env","HANZO_GUI_STACK_Z_INDEX_GLOBAL","stackZIndex","zIndex","zIndexProp","id","highest","Object","values","reduce","acc","cur","Math","max","_ZIndicesByContext","_stackLayer","stackZIndex1","zIndexProp1","id1","stackingContextLevel","stackLayer","hardcoded","stackContext","zIndex1","entries","baseForLayer","nextLayerBase","validEntries","filter","z","length","nextZIndex"],"sources":["../../src/useStackedZIndex.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,EAAYC,SAAA,EAAWC,KAAA,EAAOC,OAAA,QAAe;AACtD,SAASC,sBAAA,EAAwBC,kBAAA,QAA0B;AAI3D,IAAAC,iBAAM,KAA4D;EAACC,qBAG7D,KAAgD;EAACC,gBAE1C,YAAAA,CAAoBC,KAG3B;IACJ,IAAIC,OAAA,CAAQC,GAAA,CAAIC,8BAAA,EAAgC;MAC9C;UAAMC,WAAE;UAAAC,MAAa,EAAAC;QAAQ,IAAWN,KAAI;QAAAO,EACtC,GAAAd,KAAK;QAAMY,MAEX,GAAAX,OAAS,aAAc;UAC3B,IAAIU,WAAA,IAAeA,WAAA,KAAgB,YAAYE,UAAA,KAAe,QAAW;YACvE,IAAAE,OAAM,GAAAC,MAAU,CAAAC,MAAO,CAAAZ,qBAAO,EAAqBa,MAAE,WAAAC,GAAA,EAAAC,GAAA;cACnD,OAAMC,IAAA,CAAAC,GAAQ,CAAAH,GAAK,EAAAC,GAAI;YAAQ,GAC/B;YACF,OAAAC,IAAA,CAAAC,GAAA,CAAAX,WAAA,cAAAA,WAAA,EAAAI,OAAA;UACA;UACF,OAAAF,UAAA;QACA,IACFF,WAAI,CAEJ;MACE,OAAIZ,SAAO,aAAgB;QACzB,WAAAY,WAAA,YAAwB,EAEtB,OAAAN,qBAAO,CAAAS,EAAsB,IAAEH,WAAA;UACjC,OAAAN,qBAAA,CAAAS,EAAA;QAEA;MAGN,IACEH,WAAQ,CAMR,GAAAC,MAAA;IACA;MAGE,IAAAW,kBAAW;QAAAC,W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