@owp/core 2.0.2 → 2.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@owp/core",
3
3
  "private": false,
4
- "version": "2.0.2",
4
+ "version": "2.0.4",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -1,120 +0,0 @@
1
- var D = Object.defineProperty;
2
- var n = (e, r) => D(e, "name", { value: r, configurable: !0 });
3
- import p, { useState as w, useEffect as R, useRef as v } from "react";
4
- import { d as C } from "./isTypedArray-CCnDZ5HJ.js";
5
- import { useTheme as M } from "@mui/material/styles";
6
- import { g as G, e as y } from "./treeGridUtil-CPNva4kL.js";
7
- import { b as N } from "./useShortcuts-BjtlXprQ.js";
8
- function _(e, r, { signal: t, edges: o } = {}) {
9
- let l, i = null;
10
- const u = o != null && o.includes("leading"), c = o == null || o.includes("trailing"), a = /* @__PURE__ */ n(() => {
11
- i !== null && (e.apply(l, i), l = void 0, i = null);
12
- }, "invoke"), f = /* @__PURE__ */ n(() => {
13
- c && a(), E();
14
- }, "onTimerEnd");
15
- let s = null;
16
- const m = /* @__PURE__ */ n(() => {
17
- s != null && clearTimeout(s), s = setTimeout(() => {
18
- s = null, f();
19
- }, r);
20
- }, "schedule"), d = /* @__PURE__ */ n(() => {
21
- s !== null && (clearTimeout(s), s = null);
22
- }, "cancelTimer"), E = /* @__PURE__ */ n(() => {
23
- d(), l = void 0, i = null;
24
- }, "cancel"), b = /* @__PURE__ */ n(() => {
25
- a();
26
- }, "flush"), h = /* @__PURE__ */ n(function(...g) {
27
- if (t != null && t.aborted)
28
- return;
29
- l = this, i = g;
30
- const x = s == null;
31
- m(), u && x && a();
32
- }, "debounced");
33
- return h.schedule = m, h.cancel = E, h.flush = b, t == null || t.addEventListener("abort", E, { once: !0 }), h;
34
- }
35
- n(_, "debounce$1");
36
- function Q(e, r = 0, t = {}) {
37
- typeof t != "object" && (t = {});
38
- const { leading: o = !1, trailing: l = !0, maxWait: i } = t, u = Array(2);
39
- o && (u[0] = "leading"), l && (u[1] = "trailing");
40
- let c, a = null;
41
- const f = _(function(...d) {
42
- c = e.apply(this, d), a = null;
43
- }, r, { edges: u }), s = /* @__PURE__ */ n(function(...d) {
44
- return i != null && (a === null && (a = Date.now()), Date.now() - a >= i) ? (c = e.apply(this, d), a = Date.now(), f.cancel(), f.schedule(), c) : (f.apply(this, d), c);
45
- }, "debounced"), m = /* @__PURE__ */ n(() => (f.flush(), c), "flush");
46
- return s.cancel = f.cancel, s.flush = m, s;
47
- }
48
- n(Q, "debounce");
49
- function k(e) {
50
- if (!e || !e.length)
51
- throw new Error(
52
- "useDeepCompareEffect should not be used with no dependencies. Use React.useEffect instead."
53
- );
54
- if (e.every(A))
55
- throw new Error(
56
- "useDeepCompareEffect should not be used with dependencies that are all primitive values. Use React.useEffect instead."
57
- );
58
- }
59
- n(k, "checkDeps");
60
- function A(e) {
61
- return e == null || /^[sbn]/.test(typeof e);
62
- }
63
- n(A, "isPrimitive");
64
- function T(e) {
65
- const r = p.useRef(e), t = p.useRef(0);
66
- return C(e, r.current) || (r.current = e, t.current += 1), p.useMemo(() => r.current, [t.current]);
67
- }
68
- n(T, "useDeepCompareMemoize");
69
- function U(e, r) {
70
- return process.env.NODE_ENV !== "production" && k(r), p.useEffect(e, T(r));
71
- }
72
- n(U, "useDeepCompareEffect");
73
- function j(e, r) {
74
- return p.useEffect(e, T(r));
75
- }
76
- n(j, "useDeepCompareEffectNoCheck");
77
- function z(e) {
78
- const r = M(), t = e(r).replace("@media ", "");
79
- function o(u) {
80
- return window.matchMedia(u).matches;
81
- }
82
- n(o, "getMatches");
83
- const [l, i] = w(o(t));
84
- return R(
85
- () => {
86
- const u = window.matchMedia(t);
87
- i(o(t));
88
- const c = /* @__PURE__ */ n((a) => i(a.matches), "handler");
89
- return u.addEventListener("change", c), () => u.removeEventListener("change", c);
90
- },
91
- [t]
92
- ), l;
93
- }
94
- n(z, "useThemeMediaQuery");
95
- const F = /* @__PURE__ */ n((e) => {
96
- const { t: r } = N(), t = v(!1), [o, l] = w(!1);
97
- return { exportByTreeGrid: /* @__PURE__ */ n(async (u) => {
98
- if (t.current)
99
- return;
100
- t.current = !0, l(!0);
101
- const c = G(e);
102
- try {
103
- return typeof u == "string" ? await y(c, { exportName: u, t: r }) : await y(c, {
104
- ...u,
105
- t: r
106
- });
107
- } finally {
108
- t.current = !1, l(!1);
109
- }
110
- }, "exportByTreeGrid"), isExporting: o };
111
- }, "useTreeGridExcelExport");
112
- export {
113
- U as a,
114
- j as b,
115
- z as c,
116
- Q as d,
117
- F as e,
118
- T as u
119
- };
120
- //# sourceMappingURL=useTreeGridExcelExport-C1QPr9Dp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTreeGridExcelExport-C1QPr9Dp.js","sources":["../../../node_modules/.pnpm/es-toolkit@1.39.10/node_modules/es-toolkit/dist/function/debounce.mjs","../../../node_modules/.pnpm/es-toolkit@1.39.10/node_modules/es-toolkit/dist/compat/function/debounce.mjs","../src/hooks/useDeepCompareEffect.ts","../src/hooks/useThemeMediaQuery.ts","../src/hooks/useTreeGridExcelExport.ts"],"sourcesContent":["function debounce(func, debounceMs, { signal, edges } = {}) {\n let pendingThis = undefined;\n let pendingArgs = null;\n const leading = edges != null && edges.includes('leading');\n const trailing = edges == null || edges.includes('trailing');\n const invoke = () => {\n if (pendingArgs !== null) {\n func.apply(pendingThis, pendingArgs);\n pendingThis = undefined;\n pendingArgs = null;\n }\n };\n const onTimerEnd = () => {\n if (trailing) {\n invoke();\n }\n cancel();\n };\n let timeoutId = null;\n const schedule = () => {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n timeoutId = setTimeout(() => {\n timeoutId = null;\n onTimerEnd();\n }, debounceMs);\n };\n const cancelTimer = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n const cancel = () => {\n cancelTimer();\n pendingThis = undefined;\n pendingArgs = null;\n };\n const flush = () => {\n invoke();\n };\n const debounced = function (...args) {\n if (signal?.aborted) {\n return;\n }\n pendingThis = this;\n pendingArgs = args;\n const isFirstCall = timeoutId == null;\n schedule();\n if (leading && isFirstCall) {\n invoke();\n }\n };\n debounced.schedule = schedule;\n debounced.cancel = cancel;\n debounced.flush = flush;\n signal?.addEventListener('abort', cancel, { once: true });\n return debounced;\n}\n\nexport { debounce };\n","import { debounce as debounce$1 } from '../../function/debounce.mjs';\n\nfunction debounce(func, debounceMs = 0, options = {}) {\n if (typeof options !== 'object') {\n options = {};\n }\n const { leading = false, trailing = true, maxWait } = options;\n const edges = Array(2);\n if (leading) {\n edges[0] = 'leading';\n }\n if (trailing) {\n edges[1] = 'trailing';\n }\n let result = undefined;\n let pendingAt = null;\n const _debounced = debounce$1(function (...args) {\n result = func.apply(this, args);\n pendingAt = null;\n }, debounceMs, { edges });\n const debounced = function (...args) {\n if (maxWait != null) {\n if (pendingAt === null) {\n pendingAt = Date.now();\n }\n if (Date.now() - pendingAt >= maxWait) {\n result = func.apply(this, args);\n pendingAt = Date.now();\n _debounced.cancel();\n _debounced.schedule();\n return result;\n }\n }\n _debounced.apply(this, args);\n return result;\n };\n const flush = () => {\n _debounced.flush();\n return result;\n };\n debounced.cancel = _debounced.cancel;\n debounced.flush = flush;\n return debounced;\n}\n\nexport { debounce };\n","import { isEqual as deepEqual } from 'es-toolkit/compat';\nimport React from 'react';\n\ntype UseEffectParamsType = Parameters<typeof React.useEffect>;\ntype EffectCallbackType = UseEffectParamsType[0];\ntype DependencyListType = UseEffectParamsType[1];\n\n// yes, I know it's void, but I like what this communicates about\n// the intent of these functions: It's just like useEffect\ntype UseEffectReturn = ReturnType<typeof React.useEffect>;\n\n/**\n * The checkDeps function checks if the dependency list is valid for use with useDeepCompareEffect.\n * It throws an error if the dependency list is empty or contains only primitive values.\n */\nfunction checkDeps(deps: DependencyListType) {\n if (!deps || !deps.length) {\n throw new Error(\n 'useDeepCompareEffect should not be used with no dependencies. Use React.useEffect instead.',\n );\n }\n\n if (deps.every(isPrimitive)) {\n throw new Error(\n 'useDeepCompareEffect should not be used with dependencies that are all primitive values. Use React.useEffect instead.',\n );\n }\n}\n\n/**\n * The isPrimitive function checks if a value is a primitive type.\n * It returns true if the value is null, undefined, a string, a boolean, or a number.\n */\nfunction isPrimitive(val: unknown) {\n return val == null || /^[sbn]/.test(typeof val);\n}\n\n/**\n * The isPrimitive function checks if a value is a primitive type.\n * It returns true if the value is null, undefined, a string, a boolean, or a number.\n */\nexport function useDeepCompareMemoize<T>(value: T) {\n const ref = React.useRef<T>(value);\n const signalRef = React.useRef<number>(0);\n\n if (!deepEqual(value, ref.current)) {\n ref.current = value;\n signalRef.current += 1;\n }\n\n return React.useMemo(() => ref.current, [signalRef.current]);\n}\n\n/**\n * The isPrimitive function checks if a value is a primitive type.\n * It returns true if the value is null, undefined, a string, a boolean, or a number.\n */\nexport function useDeepCompareEffect(\n callback: EffectCallbackType,\n dependencies: DependencyListType,\n): UseEffectReturn {\n if (process.env.NODE_ENV !== 'production') {\n checkDeps(dependencies);\n }\n\n return React.useEffect(callback, useDeepCompareMemoize(dependencies));\n}\n\n/**\n * deep compare effect 훅\n * @param callback effect 콜백\n * @param dependencies 의존성 목록\n */\nexport function useDeepCompareEffectNoCheck(\n callback: EffectCallbackType,\n dependencies: DependencyListType,\n): UseEffectReturn {\n return React.useEffect(callback, useDeepCompareMemoize(dependencies));\n}\n","import { useTheme, type Theme } from '@mui/material/styles';\nimport { useEffect, useState } from 'react';\n\n/**\n * The useThemeMediaQuery function is a custom hook that returns a boolean indicating whether the current screen matches the specified media query.\n * It takes in a themeCallbackFunc as a parameter, which is a function that returns a string representing the media query to match.\n * It returns a boolean indicating whether the current screen matches the specified media query.\n */\nexport function useThemeMediaQuery(themeCallbackFunc: (theme: Theme) => string) {\n const theme = useTheme();\n\n const query = themeCallbackFunc(theme).replace('@media ', '');\n\n \n function getMatches(q: string) {\n return window.matchMedia(q).matches;\n }\n\n const [matches, setMatches] = useState(getMatches(query));\n\n useEffect(\n () => {\n const mediaQuery = window.matchMedia(query);\n\n \n setMatches(getMatches(query));\n\n \n const handler = (event: MediaQueryListEvent) => setMatches(event.matches);\n\n \n mediaQuery.addEventListener('change', handler);\n\n \n return () => mediaQuery.removeEventListener('change', handler);\n },\n [query], \n );\n\n return matches;\n}\n","import {\n ExportTreeGridExcelOptions,\n exportTreeGridExcel,\n} from '@/utils/treeGridExportExcelUtil';\nimport { getTreeGridById } from '@/utils/treeGridUtil';\nimport { useRef, useState } from 'react';\nimport { useOwpTranslation } from './useOwpTranslation';\n\nexport type UseTreeGridExcelExportOptions = Omit<ExportTreeGridExcelOptions, 't'> | string;\n\n/**\n * TreeGrid 엑셀 내보내기 훅\n * @param gridId TreeGrid 인스턴스 ID\n */\nexport const useTreeGridExcelExport = (gridId: string) => {\n const { t } = useOwpTranslation();\n const exportPendingRef = useRef(false);\n const [isExporting, setIsExporting] = useState(false);\n\n \n const exportByTreeGrid = async (options?: UseTreeGridExcelExportOptions) => {\n if (exportPendingRef.current) {\n return;\n }\n\n exportPendingRef.current = true;\n setIsExporting(true);\n\n const grid = getTreeGridById(gridId);\n\n try {\n if (typeof options === 'string') {\n return await exportTreeGridExcel(grid, { exportName: options, t });\n }\n\n return await exportTreeGridExcel(grid, {\n ...options,\n t,\n });\n } finally {\n exportPendingRef.current = false;\n setIsExporting(false);\n }\n };\n\n return { exportByTreeGrid, isExporting };\n};\n"],"names":["debounce","func","debounceMs","signal","edges","pendingThis","pendingArgs","leading","trailing","invoke","__name","onTimerEnd","cancel","timeoutId","schedule","cancelTimer","flush","debounced","args","isFirstCall","options","maxWait","result","pendingAt","_debounced","debounce$1","checkDeps","deps","isPrimitive","val","useDeepCompareMemoize","value","ref","React","signalRef","deepEqual","useDeepCompareEffect","callback","dependencies","useDeepCompareEffectNoCheck","useThemeMediaQuery","themeCallbackFunc","theme","useTheme","query","getMatches","q","matches","setMatches","useState","useEffect","mediaQuery","handler","event","useTreeGridExcelExport","gridId","t","useOwpTranslation","exportPendingRef","useRef","isExporting","setIsExporting","grid","getTreeGridById","exportTreeGridExcel"],"mappings":";;;;;;;AAAA,SAASA,EAASC,GAAMC,GAAY,EAAE,QAAAC,GAAQ,OAAAC,EAAK,IAAK,IAAI;AACxD,MAAIC,GACAC,IAAc;AAClB,QAAMC,IAAUH,KAAS,QAAQA,EAAM,SAAS,SAAS,GACnDI,IAAWJ,KAAS,QAAQA,EAAM,SAAS,UAAU,GACrDK,IAAS,gBAAAC,EAAA,MAAM;AACjB,IAAIJ,MAAgB,SAChBL,EAAK,MAAMI,GAAaC,CAAW,GACnCD,IAAc,QACdC,IAAc;AAAA,EAEtB,GANe,WAOTK,IAAa,gBAAAD,EAAA,MAAM;AACrB,IAAIF,KACAC,EAAM,GAEVG,EAAM;AAAA,EACV,GALmB;AAMnB,MAAIC,IAAY;AAChB,QAAMC,IAAW,gBAAAJ,EAAA,MAAM;AACnB,IAAIG,KAAa,QACb,aAAaA,CAAS,GAE1BA,IAAY,WAAW,MAAM;AACzB,MAAAA,IAAY,MACZF,EAAU;AAAA,IACd,GAAGT,CAAU;AAAA,EACjB,GARiB,aASXa,IAAc,gBAAAL,EAAA,MAAM;AACtB,IAAIG,MAAc,SACd,aAAaA,CAAS,GACtBA,IAAY;AAAA,EAEpB,GALoB,gBAMdD,IAAS,gBAAAF,EAAA,MAAM;AACjB,IAAAK,EAAW,GACXV,IAAc,QACdC,IAAc;AAAA,EAClB,GAJe,WAKTU,IAAQ,gBAAAN,EAAA,MAAM;AAChB,IAAAD,EAAM;AAAA,EACV,GAFc,UAGRQ,IAAY,gBAAAP,EAAA,YAAaQ,GAAM;AACjC,QAAIf,KAAA,QAAAA,EAAQ;AACR;AAEJ,IAAAE,IAAc,MACdC,IAAcY;AACd,UAAMC,IAAcN,KAAa;AACjC,IAAAC,EAAQ,GACJP,KAAWY,KACXV,EAAM;AAAA,EAEd,GAXkB;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