@owp/core 2.5.2 → 2.5.3
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/dist/_virtual/index16.js +4 -4
- package/dist/_virtual/index17.js +4 -4
- package/dist/_virtual/index18.js +4 -4
- package/dist/_virtual/index19.js +4 -4
- package/dist/components/{OwpFileUploadButton/OwpFileUploadButton.js → OwpFilePickerButton/OwpFilePickerButton.js} +15 -15
- package/dist/components/OwpFilePickerButton/OwpFilePickerButton.js.map +1 -0
- package/dist/components/OwpLanguageSwitcherSelect/OwpLanguageSwitcherSelect.js.map +1 -1
- package/dist/components/OwpMoreActionsButton/OwpMoreActionsButton.js +27 -27
- package/dist/components/OwpMoreActionsButton/OwpMoreActionsButton.js.map +1 -1
- package/dist/components/OwpMrtTable/OwpMrtTable.js +335 -317
- package/dist/components/OwpMrtTable/OwpMrtTable.js.map +1 -1
- package/dist/components/OwpTable/OwpDataTable.js +273 -251
- package/dist/components/OwpTable/OwpDataTable.js.map +1 -1
- package/dist/components/OwpTable/OwpTable.js +180 -159
- package/dist/components/OwpTable/OwpTable.js.map +1 -1
- package/dist/components/OwpTreeGrid/OwpTreeGrid.js +267 -184
- package/dist/components/OwpTreeGrid/OwpTreeGrid.js.map +1 -1
- package/dist/components/{OwpTreeGridExcelButton/OwpTreeGridExcelButton.js → OwpTreeGridExportExcelButton/OwpTreeGridExportExcelButton.js} +7 -7
- package/dist/components/OwpTreeGridExportExcelButton/OwpTreeGridExportExcelButton.js.map +1 -0
- package/dist/constants/gridTheme.js +28 -0
- package/dist/constants/gridTheme.js.map +1 -0
- package/dist/hooks/useFormDataUploadMutation.js.map +1 -1
- package/dist/index.js +28 -28
- package/dist/layout/components/toggles/NavigationSearchToggle.js +3 -3
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/CODE128/constants.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/EAN_UPC/constants.js +1 -1
- package/dist/node_modules/.pnpm/jsbarcode@3.12.1/node_modules/jsbarcode/bin/barcodes/ITF/constants.js +1 -1
- package/dist/node_modules/.pnpm/react-overlays@5.2.1_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/react-overlays/esm/Portal.js +1 -1
- package/dist/types/components/{OwpFileUploadButton/OwpFileUploadButton.d.ts → OwpFilePickerButton/OwpFilePickerButton.d.ts} +4 -4
- package/dist/types/components/OwpFilePickerButton/index.d.ts +1 -0
- package/dist/types/components/OwpLanguageSwitcherSelect/OwpLanguageSwitcherSelect.d.ts +1 -1
- package/dist/types/components/OwpMoreActionsButton/OwpMoreActionsButton.d.ts +4 -4
- package/dist/types/components/OwpTable/OwpTable.d.ts +2 -0
- package/dist/types/components/OwpTreeGridExportExcelButton/OwpTreeGridExportExcelButton.d.ts +12 -0
- package/dist/types/components/OwpTreeGridExportExcelButton/index.d.ts +1 -0
- package/dist/types/constants/gridTheme.d.ts +30 -0
- package/dist/types/hooks/useFormDataUploadMutation.d.ts +4 -3
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types/OwpGridThemeTypes.d.ts +14 -0
- package/dist/types/types/OwpSettingsTypes.d.ts +2 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/utils/createFormDataBody.js +19 -14
- package/dist/utils/createFormDataBody.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/OwpFileUploadButton/OwpFileUploadButton.js.map +0 -1
- package/dist/components/OwpTreeGridExcelButton/OwpTreeGridExcelButton.js.map +0 -1
- package/dist/types/components/OwpFileUploadButton/index.d.ts +0 -1
- package/dist/types/components/OwpTreeGridExcelButton/OwpTreeGridExcelButton.d.ts +0 -12
- package/dist/types/components/OwpTreeGridExcelButton/index.d.ts +0 -1
package/dist/_virtual/index16.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
2
|
-
import { __require as
|
|
3
|
-
var
|
|
4
|
-
const
|
|
2
|
+
import { __require as o } from "../node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js";
|
|
3
|
+
var p = /* @__PURE__ */ o();
|
|
4
|
+
const s = /* @__PURE__ */ r(p);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
s as default
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=index16.js.map
|
package/dist/_virtual/index17.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
2
|
-
import { __require as
|
|
3
|
-
var o =
|
|
4
|
-
const
|
|
2
|
+
import { __require as t } from "../node_modules/.pnpm/autosuggest-highlight@3.3.4/node_modules/autosuggest-highlight/match/index.js";
|
|
3
|
+
var o = t();
|
|
4
|
+
const m = /* @__PURE__ */ r(o);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
m as default
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=index17.js.map
|
package/dist/_virtual/index18.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
2
|
-
import { __require as
|
|
3
|
-
var o =
|
|
4
|
-
const
|
|
2
|
+
import { __require as e } from "../node_modules/.pnpm/autosuggest-highlight@3.3.4/node_modules/autosuggest-highlight/parse/index.js";
|
|
3
|
+
var o = e();
|
|
4
|
+
const s = /* @__PURE__ */ r(o);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
s as default
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=index18.js.map
|
package/dist/_virtual/index19.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
2
|
-
import { __require as
|
|
3
|
-
var
|
|
4
|
-
const
|
|
2
|
+
import { __require as t } from "../node_modules/.pnpm/react-autosuggest@10.1.0_react@19.2.4/node_modules/react-autosuggest/dist/index.js";
|
|
3
|
+
var o = t();
|
|
4
|
+
const i = /* @__PURE__ */ r(o);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
i as default
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=index19.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var s = Object.defineProperty;
|
|
2
|
-
var i = (
|
|
2
|
+
var i = (r, n) => s(r, "name", { value: n, configurable: !0 });
|
|
3
3
|
import { jsxs as m, jsx as a } from "../../node_modules/.pnpm/@emotion_react@11.14.0_@types_react@19.2.14_react@19.2.4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
|
|
4
4
|
import f from "@mui/material/Button";
|
|
5
5
|
import { styled as d } from "@mui/material/styles";
|
|
@@ -15,15 +15,15 @@ const E = "image/x-png,image/gif,image/jpeg,image/jpg", b = d("input")({
|
|
|
15
15
|
whiteSpace: "nowrap",
|
|
16
16
|
width: 1
|
|
17
17
|
});
|
|
18
|
-
function
|
|
19
|
-
title:
|
|
20
|
-
multiple:
|
|
21
|
-
onChange:
|
|
18
|
+
function y({
|
|
19
|
+
title: r,
|
|
20
|
+
multiple: n,
|
|
21
|
+
onChange: o,
|
|
22
22
|
onCancel: e,
|
|
23
|
-
accept:
|
|
24
|
-
...
|
|
23
|
+
accept: c,
|
|
24
|
+
...l
|
|
25
25
|
}) {
|
|
26
|
-
const p = g(null), u =
|
|
26
|
+
const p = g(null), u = l;
|
|
27
27
|
return v(() => {
|
|
28
28
|
const t = p.current;
|
|
29
29
|
if (!(!t || !e))
|
|
@@ -39,26 +39,26 @@ function B({
|
|
|
39
39
|
tabIndex: -1,
|
|
40
40
|
...u,
|
|
41
41
|
children: [
|
|
42
|
-
|
|
42
|
+
r,
|
|
43
43
|
/* @__PURE__ */ a(
|
|
44
44
|
b,
|
|
45
45
|
{
|
|
46
46
|
ref: p,
|
|
47
47
|
type: "file",
|
|
48
|
-
accept:
|
|
48
|
+
accept: c ?? E,
|
|
49
49
|
onClick: /* @__PURE__ */ i((t) => {
|
|
50
50
|
t.currentTarget.value = "";
|
|
51
51
|
}, "onClick"),
|
|
52
|
-
onChange: /* @__PURE__ */ i((t) =>
|
|
53
|
-
multiple: !!
|
|
52
|
+
onChange: /* @__PURE__ */ i((t) => o == null ? void 0 : o(t), "onChange"),
|
|
53
|
+
multiple: !!n
|
|
54
54
|
}
|
|
55
55
|
)
|
|
56
56
|
]
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
i(
|
|
60
|
+
i(y, "OwpFilePickerButton");
|
|
61
61
|
export {
|
|
62
|
-
|
|
62
|
+
y as OwpFilePickerButton
|
|
63
63
|
};
|
|
64
|
-
//# sourceMappingURL=
|
|
64
|
+
//# sourceMappingURL=OwpFilePickerButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OwpFilePickerButton.js","sources":["../../../src/components/OwpFilePickerButton/OwpFilePickerButton.tsx"],"sourcesContent":["import Button, { type ButtonProps } from '@mui/material/Button';\nimport { styled } from '@mui/material/styles';\nimport { type ChangeEvent, type ReactNode, useEffect, useRef } from 'react';\n\nexport interface OwpFilePickerButtonOwnProps {\n multiple?: boolean;\n accept?: string;\n title?: ReactNode;\n onChange?: (evt: ChangeEvent<HTMLInputElement>) => void;\n onCancel?: (evt: Event) => void;\n}\n\nexport type OwpFilePickerButtonProps = OwpFilePickerButtonOwnProps &\n Omit<ButtonProps, 'title' | 'onChange' | 'onCancel'>;\n\nconst DEFAULT_ACCEPT = 'image/x-png,image/gif,image/jpeg,image/jpg';\n\nconst VisuallyHiddenInput = styled('input')({\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n height: 1,\n overflow: 'hidden',\n position: 'absolute',\n bottom: 0,\n left: 0,\n whiteSpace: 'nowrap',\n width: 1,\n});\n\n/**\n * OwpFilePickerButton 컴포넌트\n * @param title 제목\n * @param multiple multiple 값\n * @param onChange onChange 핸들러\n * @param onCancel onCancel 핸들러\n * @param accept accept 값\n */\nexport function OwpFilePickerButton({\n title,\n multiple,\n onChange,\n onCancel,\n accept,\n ...restProps\n}: OwpFilePickerButtonProps) {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const buttonProps = restProps as unknown as Omit<ButtonProps<'label'>, 'children' | 'component'>;\n\n useEffect(() => {\n const inputElement = inputRef.current;\n if (!inputElement || !onCancel) {\n return;\n }\n\n inputElement.addEventListener('cancel', onCancel);\n\n return () => {\n inputElement.removeEventListener('cancel', onCancel);\n };\n }, [onCancel]);\n\n return (\n <Button\n component=\"label\"\n role={undefined}\n variant=\"contained\"\n tabIndex={-1}\n {...buttonProps}\n >\n {title}\n <VisuallyHiddenInput\n ref={inputRef}\n type=\"file\"\n accept={accept ?? DEFAULT_ACCEPT}\n onClick={(event) => {\n event.currentTarget.value = '';\n }}\n onChange={(event) => onChange?.(event)}\n multiple={Boolean(multiple)}\n />\n </Button>\n );\n}\n"],"names":["DEFAULT_ACCEPT","VisuallyHiddenInput","styled","OwpFilePickerButton","title","multiple","onChange","onCancel","accept","restProps","inputRef","useRef","buttonProps","useEffect","inputElement","jsxs","Button","jsx","__name","event"],"mappings":";;;;;;AAeA,MAAMA,IAAiB,8CAEjBC,IAAsBC,EAAO,OAAO,EAAE;AAAA,EAC1C,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,OAAO;AACT,CAAC;AAUM,SAASC,EAAoB;AAAA,EAClC,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,GAAGC;AACL,GAA6B;AAC3B,QAAMC,IAAWC,EAAgC,IAAI,GAC/CC,IAAcH;AAEpB,SAAAI,EAAU,MAAM;AACd,UAAMC,IAAeJ,EAAS;AAC9B,QAAI,GAACI,KAAgB,CAACP;AAItB,aAAAO,EAAa,iBAAiB,UAAUP,CAAQ,GAEzC,MAAM;AACX,QAAAO,EAAa,oBAAoB,UAAUP,CAAQ;AAAA,MACrD;AAAA,EACF,GAAG,CAACA,CAAQ,CAAC,GAGX,gBAAAQ;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAQ;AAAA,MACR,UAAU;AAAA,MACT,GAAGJ;AAAA,MAEH,UAAA;AAAA,QAAAR;AAAA,QACD,gBAAAa;AAAA,UAAChB;AAAA,UAAA;AAAA,YACC,KAAKS;AAAA,YACL,MAAK;AAAA,YACL,QAAQF,KAAUR;AAAA,YAClB,SAAS,gBAAAkB,EAAA,CAACC,MAAU;AAClB,cAAAA,EAAM,cAAc,QAAQ;AAAA,YAC9B,GAFS;AAAA,YAGT,UAAU,gBAAAD,EAAA,CAACC,MAAUb,KAAA,gBAAAA,EAAWa,IAAtB;AAAA,YACV,UAAU,EAAQd;AAAA,UAAQ;AAAA,QAAA;AAAA,MAC5B;AAAA,IAAA;AAAA,EAAA;AAGN;AA7CgBa,EAAAf,GAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OwpLanguageSwitcherSelect.js","sources":["../../../src/components/OwpLanguageSwitcherSelect/OwpLanguageSwitcherSelect.tsx"],"sourcesContent":["import {\n CurrentLanguage,\n useGetCurrentLanguage,\n useGetLanguageList,\n useSetCurrentLanguage,\n} from '@/hooks/useCurrentLanguage';\nimport { useOwpTranslation } from '@/hooks/useOwpTranslation';\nimport { FormControl, InputLabel } from '@mui/material';\nimport MenuItem from '@mui/material/MenuItem';\nimport Select, { SelectChangeEvent, SelectProps } from '@mui/material/Select';\nimport { useNavigate } from 'react-router-dom';\n\n/**\n * The language switcher.\n */\nexport function OwpLanguageSwitcherSelect({\n label,\n fullWidth,\n canRefresh,\n ...restSelectProps\n}: Omit<SelectProps, 'value
|
|
1
|
+
{"version":3,"file":"OwpLanguageSwitcherSelect.js","sources":["../../../src/components/OwpLanguageSwitcherSelect/OwpLanguageSwitcherSelect.tsx"],"sourcesContent":["import {\n CurrentLanguage,\n useGetCurrentLanguage,\n useGetLanguageList,\n useSetCurrentLanguage,\n} from '@/hooks/useCurrentLanguage';\nimport { useOwpTranslation } from '@/hooks/useOwpTranslation';\nimport { FormControl, InputLabel } from '@mui/material';\nimport MenuItem from '@mui/material/MenuItem';\nimport Select, { SelectChangeEvent, SelectProps } from '@mui/material/Select';\nimport { useNavigate } from 'react-router-dom';\n\n/**\n * The language switcher.\n */\nexport function OwpLanguageSwitcherSelect({\n label,\n fullWidth,\n canRefresh,\n ...restSelectProps\n}: Omit<SelectProps, 'value' | 'onChange'> & { canRefresh?: boolean }) {\n const currentLanguage = useGetCurrentLanguage();\n const setLanguage = useSetCurrentLanguage();\n const languageList = useGetLanguageList();\n const navigate = useNavigate();\n\n const { i18n } = useOwpTranslation();\n\n const handleLanguageChange = (event: SelectChangeEvent) => {\n const selectedLangId = event.target.value as string;\n const nextLangData = languageList.find((item) => item.id === selectedLangId);\n\n setLanguage(nextLangData as CurrentLanguage);\n i18n.changeLanguage(selectedLangId);\n\n if (canRefresh) {\n navigate(0);\n }\n };\n\n return (\n <FormControl fullWidth>\n <InputLabel id=\"lang-switcher-select-label\">{label}</InputLabel>\n <Select\n labelId=\"lang-switcher-select-label\"\n id=\"lang-switcher-select\"\n variant=\"standard\"\n {...restSelectProps}\n fullWidth={fullWidth}\n value={currentLanguage.id}\n label={label}\n onChange={handleLanguageChange}\n >\n {languageList.map((item) => (\n <MenuItem key={`lang-switcher-item-${item.id}`} value={item.id}>\n {item.title}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n );\n}\n"],"names":["OwpLanguageSwitcherSelect","label","fullWidth","canRefresh","restSelectProps","currentLanguage","useGetCurrentLanguage","setLanguage","useSetCurrentLanguage","languageList","useGetLanguageList","navigate","useNavigate","i18n","useOwpTranslation","handleLanguageChange","__name","event","selectedLangId","nextLangData","item","jsxs","FormControl","jsx","InputLabel","Select","MenuItem"],"mappings":";;;;;;;;;AAeO,SAASA,EAA0B;AAAA,EACxC,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,GAAuE;AACrE,QAAMC,IAAkBC,EAAA,GAClBC,IAAcC,EAAA,GACdC,IAAeC,EAAA,GACfC,IAAWC,EAAA,GAEX,EAAE,MAAAC,EAAA,IAASC,EAAA,GAEXC,IAAuB,gBAAAC,EAAA,CAACC,MAA6B;AACzD,UAAMC,IAAiBD,EAAM,OAAO,OAC9BE,IAAeV,EAAa,KAAK,CAACW,MAASA,EAAK,OAAOF,CAAc;AAE3E,IAAAX,EAAYY,CAA+B,GAC3CN,EAAK,eAAeK,CAAc,GAE9Bf,KACFQ,EAAS,CAAC;AAAA,EAEd,GAV6B;AAY7B,SACE,gBAAAU,EAACC,GAAA,EAAY,WAAS,IACpB,UAAA;AAAA,IAAA,gBAAAC,EAACC,GAAA,EAAW,IAAG,8BAA8B,UAAAvB,GAAM;AAAA,IACnD,gBAAAsB;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,IAAG;AAAA,QACH,SAAQ;AAAA,QACP,GAAGrB;AAAA,QACJ,WAAAF;AAAA,QACA,OAAOG,EAAgB;AAAA,QACvB,OAAAJ;AAAA,QACA,UAAUc;AAAA,QAET,UAAAN,EAAa,IAAI,CAACW,wBAChBM,GAAA,EAA+C,OAAON,EAAK,IACzD,YAAK,MAAA,GADO,sBAAsBA,EAAK,EAAE,EAE5C,CACD;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GACF;AAEJ;AA9CgBJ,EAAAhB,GAAA;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var J = Object.defineProperty;
|
|
2
2
|
var o = (r, t) => J(r, "name", { value: t, configurable: !0 });
|
|
3
|
-
import { jsxs as K, jsx as
|
|
3
|
+
import { jsxs as K, jsx as i, Fragment as L } from "../../node_modules/.pnpm/@emotion_react@11.14.0_@types_react@19.2.14_react@19.2.4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
|
|
4
4
|
import { useOwpTranslation as O } from "../../hooks/useOwpTranslation.js";
|
|
5
5
|
import Q from "../../node_modules/.pnpm/@mui_icons-material@7.3.9_@mui_material@7.3.9_@emotion_react@11.14.0_@types_react@19.2._dc2be6bc014bebdac88a574e3e02c144/node_modules/@mui/icons-material/esm/MoreVert.js";
|
|
6
6
|
import { IconButton as X, MenuItem as v, Menu as Y } from "@mui/material";
|
|
@@ -8,7 +8,7 @@ import { useTheme as Z, alpha as _ } from "@mui/material/styles";
|
|
|
8
8
|
import { clsx as u } from "../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
9
9
|
import { useState as ee, useMemo as re, useCallback as y } from "react";
|
|
10
10
|
import { exportTreeGridToExcelById as te } from "../../utils/treeGridUtil.js";
|
|
11
|
-
import {
|
|
11
|
+
import { OwpFilePickerButton as oe } from "../OwpFilePickerButton/OwpFilePickerButton.js";
|
|
12
12
|
import { uniqueId as le } from "../../node_modules/.pnpm/es-toolkit@1.39.10/node_modules/es-toolkit/dist/compat/util/uniqueId.js";
|
|
13
13
|
const se = [
|
|
14
14
|
"primary",
|
|
@@ -17,10 +17,10 @@ const se = [
|
|
|
17
17
|
"info",
|
|
18
18
|
"success",
|
|
19
19
|
"warning"
|
|
20
|
-
], f = /* @__PURE__ */ o((r) => r ? Array.isArray(r) ? r.filter((t) => !!t) : [r] : [], "flattenSx"), ne = /* @__PURE__ */ o((r) => typeof r == "string" && se.includes(r), "isPaletteActionColor"),
|
|
20
|
+
], f = /* @__PURE__ */ o((r) => r ? Array.isArray(r) ? r.filter((t) => !!t) : [r] : [], "flattenSx"), ne = /* @__PURE__ */ o((r) => typeof r == "string" && se.includes(r), "isPaletteActionColor"), ie = /* @__PURE__ */ o((r, t) => {
|
|
21
21
|
const c = ne(t) ? r.palette[t].main : t === "inherit" || t === "default" ? r.palette.secondary.main : t ?? r.palette.secondary.main, s = r.palette.getContrastText(c);
|
|
22
22
|
return { main: c, contrast: s };
|
|
23
|
-
}, "getActionColors"),
|
|
23
|
+
}, "getActionColors"), ae = /* @__PURE__ */ o((r) => r.type === "treeGridExportExcel" ? "success" : "secondary", "getDefaultActionColor"), we = /* @__PURE__ */ o(({
|
|
24
24
|
actions: r,
|
|
25
25
|
open: t,
|
|
26
26
|
defaultOpen: c = !1,
|
|
@@ -34,8 +34,8 @@ const se = [
|
|
|
34
34
|
() => r.map((e) => ({ action: e, id: le("owp-more-") })),
|
|
35
35
|
[r]
|
|
36
36
|
), d = y(
|
|
37
|
-
(e,
|
|
38
|
-
x || R(e ?
|
|
37
|
+
(e, a = null) => {
|
|
38
|
+
x || R(e ? a : null), s == null || s(e);
|
|
39
39
|
},
|
|
40
40
|
[x, s]
|
|
41
41
|
), z = y(
|
|
@@ -47,17 +47,17 @@ const se = [
|
|
|
47
47
|
d(!1, null);
|
|
48
48
|
}, [d]);
|
|
49
49
|
return /* @__PURE__ */ K(L, { children: [
|
|
50
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ i(
|
|
51
51
|
X,
|
|
52
52
|
{
|
|
53
53
|
className: u(W),
|
|
54
54
|
disabled: G,
|
|
55
55
|
onClick: z,
|
|
56
56
|
sx: F,
|
|
57
|
-
children: /* @__PURE__ */
|
|
57
|
+
children: /* @__PURE__ */ i(Q, {})
|
|
58
58
|
}
|
|
59
59
|
),
|
|
60
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ i(
|
|
61
61
|
Y,
|
|
62
62
|
{
|
|
63
63
|
anchorEl: w,
|
|
@@ -77,9 +77,9 @@ const se = [
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
children: $.map(
|
|
80
|
-
({ action: e, id:
|
|
81
|
-
var C,
|
|
82
|
-
const P =
|
|
80
|
+
({ action: e, id: a }, H) => (() => {
|
|
81
|
+
var C, g, U, A, I, B, E, N, k, T, M, j, S;
|
|
82
|
+
const P = ie(D, e.color ?? ae(e)), h = {
|
|
83
83
|
bgcolor: P.main,
|
|
84
84
|
color: P.contrast,
|
|
85
85
|
"&:hover": {
|
|
@@ -87,18 +87,18 @@ const se = [
|
|
|
87
87
|
opacity: 0.9
|
|
88
88
|
},
|
|
89
89
|
...H > 0 ? {
|
|
90
|
-
borderTop: /* @__PURE__ */ o((
|
|
90
|
+
borderTop: /* @__PURE__ */ o((p) => `1px solid ${_(p.palette.common.white, 0.35)}`, "borderTop"),
|
|
91
91
|
mt: 0
|
|
92
92
|
} : null
|
|
93
93
|
};
|
|
94
|
-
return e.type === "fileUpload" ? /* @__PURE__ */
|
|
94
|
+
return e.type === "fileUpload" ? /* @__PURE__ */ i(
|
|
95
95
|
oe,
|
|
96
96
|
{
|
|
97
97
|
...e.fileUploadProps,
|
|
98
98
|
title: e.label ?? b("Button.엑셀 업로드"),
|
|
99
99
|
startIcon: ((C = e.fileUploadProps) == null ? void 0 : C.startIcon) ?? e.icon,
|
|
100
|
-
fullWidth: ((
|
|
101
|
-
variant: ((
|
|
100
|
+
fullWidth: ((g = e.fileUploadProps) == null ? void 0 : g.fullWidth) ?? !0,
|
|
101
|
+
variant: ((U = e.fileUploadProps) == null ? void 0 : U.variant) ?? "text",
|
|
102
102
|
role: ((A = e.fileUploadProps) == null ? void 0 : A.role) ?? "menuitem",
|
|
103
103
|
tabIndex: ((I = e.fileUploadProps) == null ? void 0 : I.tabIndex) ?? -1,
|
|
104
104
|
className: u(
|
|
@@ -110,30 +110,30 @@ const se = [
|
|
|
110
110
|
{ justifyContent: "flex-start", px: 2, py: 1 },
|
|
111
111
|
h,
|
|
112
112
|
...f((N = e.itemProps) == null ? void 0 : N.sx),
|
|
113
|
-
...f((
|
|
113
|
+
...f((k = e.fileUploadProps) == null ? void 0 : k.sx)
|
|
114
114
|
],
|
|
115
|
-
onChange: /* @__PURE__ */ o((
|
|
115
|
+
onChange: /* @__PURE__ */ o((p) => {
|
|
116
116
|
var l, m;
|
|
117
|
-
(m = (l = e.fileUploadProps) == null ? void 0 : l.onChange) == null || m.call(l,
|
|
117
|
+
(m = (l = e.fileUploadProps) == null ? void 0 : l.onChange) == null || m.call(l, p), n();
|
|
118
118
|
}, "onChange"),
|
|
119
|
-
onCancel: /* @__PURE__ */ o((
|
|
119
|
+
onCancel: /* @__PURE__ */ o((p) => {
|
|
120
120
|
var l, m;
|
|
121
|
-
(m = (l = e.fileUploadProps) == null ? void 0 : l.onCancel) == null || m.call(l,
|
|
121
|
+
(m = (l = e.fileUploadProps) == null ? void 0 : l.onCancel) == null || m.call(l, p), n();
|
|
122
122
|
}, "onCancel")
|
|
123
123
|
},
|
|
124
|
-
|
|
125
|
-
) : e.type === "treeGridExportExcel" ? /* @__PURE__ */
|
|
124
|
+
a
|
|
125
|
+
) : e.type === "treeGridExportExcel" ? /* @__PURE__ */ i(
|
|
126
126
|
v,
|
|
127
127
|
{
|
|
128
|
-
className: u("min-h-40 min-w-128 text-lg", (
|
|
128
|
+
className: u("min-h-40 min-w-128 text-lg", (T = e.itemProps) == null ? void 0 : T.className),
|
|
129
129
|
onClick: /* @__PURE__ */ o(() => {
|
|
130
130
|
te(...e.exportExcelArgs), n();
|
|
131
131
|
}, "onClick"),
|
|
132
132
|
sx: [h, ...f((M = e.itemProps) == null ? void 0 : M.sx)],
|
|
133
133
|
children: e.label ?? b("Button.엑셀 다운로드")
|
|
134
134
|
},
|
|
135
|
-
|
|
136
|
-
) : /* @__PURE__ */
|
|
135
|
+
a
|
|
136
|
+
) : /* @__PURE__ */ i(
|
|
137
137
|
v,
|
|
138
138
|
{
|
|
139
139
|
className: u("min-h-40 min-w-128 text-lg", (j = e.itemProps) == null ? void 0 : j.className),
|
|
@@ -143,7 +143,7 @@ const se = [
|
|
|
143
143
|
sx: [h, ...f((S = e.itemProps) == null ? void 0 : S.sx)],
|
|
144
144
|
children: e.label
|
|
145
145
|
},
|
|
146
|
-
|
|
146
|
+
a
|
|
147
147
|
);
|
|
148
148
|
})()
|
|
149
149
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OwpMoreActionsButton.js","sources":["../../../src/components/OwpMoreActionsButton/OwpMoreActionsButton.tsx"],"sourcesContent":["import { useOwpTranslation } from '@/hooks/useOwpTranslation';\nimport MoreVertIcon from '@mui/icons-material/MoreVert';\nimport { IconButton, Menu, MenuItem } from '@mui/material';\nimport type { IconButtonProps } from '@mui/material/IconButton';\nimport type { SxProps, Theme } from '@mui/material/styles';\nimport { alpha, useTheme } from '@mui/material/styles';\nimport clsx from 'clsx';\nimport { uniqueId } from 'es-toolkit/compat';\nimport type { MouseEvent, ReactNode } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\nimport { exportTreeGridToExcelById } from '../../utils/treeGridUtil';\nimport {\n OwpFileUploadButton,\n type OwpFileUploadButtonProps,\n} from '../OwpFileUploadButton/OwpFileUploadButton';\n\nexport type OwpMoreButtonActionColor = NonNullable<IconButtonProps['color']> | string;\n\ntype OwpMoreButtonActionBase = {\n icon?: ReactNode;\n color?: OwpMoreButtonActionColor;\n label?: ReactNode;\n labelProps?: { className?: string; sx?: SxProps<Theme> };\n itemProps?: { className?: string; sx?: SxProps<Theme> };\n};\n\nexport type OwpMoreButtonClickAction = OwpMoreButtonActionBase & {\n type?: 'button';\n onClick: (args: { close: () => void }) => void;\n};\n\nexport type OwpMoreButtonFileUploadAction = OwpMoreButtonActionBase & {\n type: 'fileUpload';\n fileUploadProps?: Omit<OwpFileUploadButtonProps, 'title' | 'onChange' | 'onCancel'> & {\n onChange?: OwpFileUploadButtonProps['onChange'];\n onCancel?: OwpFileUploadButtonProps['onCancel'];\n };\n};\n\nexport type OwpMoreButtonTreeGridExportExcelAction = OwpMoreButtonActionBase & {\n type: 'treeGridExportExcel';\n exportExcelArgs: Parameters<typeof exportTreeGridToExcelById>;\n};\n\nexport type OwpMoreButtonAction =\n | OwpMoreButtonClickAction\n | OwpMoreButtonFileUploadAction\n | OwpMoreButtonTreeGridExportExcelAction;\n\nexport type OwpMoreActionsButtonProps = {\n actions: OwpMoreButtonAction[];\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n disabled?: boolean;\n className?: string;\n containerSx?: SxProps<Theme>;\n actionsSx?: SxProps<Theme>;\n};\n\ntype OwpFlatSx = NonNullable<Exclude<SxProps<Theme>, readonly unknown[]>>;\ntype OwpPaletteActionColor = 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';\n\nconst owpPaletteActionColors = [\n 'primary',\n 'secondary',\n 'error',\n 'info',\n 'success',\n 'warning',\n] as const;\n\nconst flattenSx = (sx?: SxProps<Theme>): OwpFlatSx[] => {\n if (!sx) return [];\n if (Array.isArray(sx)) return sx.filter((item): item is OwpFlatSx => Boolean(item));\n return [sx as OwpFlatSx];\n};\n\nconst isPaletteActionColor = (color: OwpMoreButtonActionColor | undefined): color is OwpPaletteActionColor =>\n typeof color === 'string' && owpPaletteActionColors.includes(color as OwpPaletteActionColor);\n\nconst getActionColors = (theme: Theme, color?: OwpMoreButtonActionColor) => {\n const main = isPaletteActionColor(color)\n ? theme.palette[color].main\n : color === 'inherit' || color === 'default'\n ? theme.palette.secondary.main\n : ((color as string) ?? theme.palette.secondary.main);\n\n const contrast = theme.palette.getContrastText(main);\n return { main, contrast };\n};\n\nconst getDefaultActionColor = (action: OwpMoreButtonAction): OwpMoreButtonActionColor => {\n if (action.type === 'treeGridExportExcel') {\n return 'success';\n }\n\n return 'secondary';\n};\n\n/**\n * OwpMoreActionsButton 컴포넌트\n * @param actions 액션 영역\n * @param openProp openProp 값\n * @param defaultOpen defaultOpen 값\n * @param onOpenChange onOpenChange 핸들러\n * @param disabled disabled 값\n * @param className CSS 클래스명\n */\nexport const OwpMoreActionsButton = ({\n actions,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n disabled,\n className,\n containerSx,\n actionsSx,\n}: OwpMoreActionsButtonProps) => {\n const { t } = useOwpTranslation();\n const theme = useTheme();\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n const controlled = openProp != null;\n const open = controlled ? Boolean(openProp) : Boolean(anchorEl) || defaultOpen;\n const keyedActions = useMemo(\n () => actions.map((action) => ({ action, id: uniqueId('owp-more-') })),\n [actions],\n );\n\n const setOpen = useCallback(\n (next: boolean, el: HTMLElement | null = null) => {\n if (!controlled) setAnchorEl(next ? el : null);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const handleOpen = useCallback(\n (event: MouseEvent<HTMLElement>) => {\n setOpen(true, event.currentTarget);\n },\n [setOpen],\n );\n\n const handleClose = useCallback(() => {\n setOpen(false, null);\n }, [setOpen]);\n\n return (\n <>\n <IconButton\n className={clsx(className)}\n disabled={disabled}\n onClick={handleOpen}\n sx={containerSx}\n >\n <MoreVertIcon />\n </IconButton>\n\n <Menu\n anchorEl={anchorEl}\n open={open}\n sx={actionsSx}\n onClose={handleClose}\n slotProps={{\n list: { disablePadding: true, sx: { p: 0 } },\n paper: {\n sx: {\n p: 0,\n mt: 0.75,\n minWidth: 200,\n borderRadius: 1.5,\n boxShadow: (t) => t.shadows[8],\n },\n },\n }}\n >\n {keyedActions.map(({ action, id }, idx) =>\n (() => {\n const colors = getActionColors(theme, action.color ?? getDefaultActionColor(action));\n const baseItemSx: OwpFlatSx = {\n bgcolor: colors.main,\n color: colors.contrast,\n '&:hover': {\n bgcolor: colors.main,\n opacity: 0.9,\n },\n ...(idx > 0\n ? {\n borderTop: (t: Theme) => `1px solid ${alpha(t.palette.common.white, 0.35)}`,\n mt: 0,\n }\n : null),\n };\n\n if (action.type === 'fileUpload') {\n return (\n <OwpFileUploadButton\n key={id}\n {...action.fileUploadProps}\n title={action.label ?? t('Button.엑셀 업로드')}\n startIcon={action.fileUploadProps?.startIcon ?? action.icon}\n fullWidth={action.fileUploadProps?.fullWidth ?? true}\n variant={action.fileUploadProps?.variant ?? 'text'}\n role={action.fileUploadProps?.role ?? 'menuitem'}\n tabIndex={action.fileUploadProps?.tabIndex ?? -1}\n className={clsx(\n 'min-h-40 min-w-128 justify-start rounded-none text-lg',\n action.itemProps?.className,\n action.fileUploadProps?.className,\n )}\n sx={[\n { justifyContent: 'flex-start', px: 2, py: 1 },\n baseItemSx,\n ...flattenSx(action.itemProps?.sx),\n ...flattenSx(action.fileUploadProps?.sx),\n ]}\n onChange={(event) => {\n action.fileUploadProps?.onChange?.(event);\n handleClose();\n }}\n onCancel={(event) => {\n action.fileUploadProps?.onCancel?.(event);\n handleClose();\n }}\n />\n );\n }\n\n if (action.type === 'treeGridExportExcel') {\n return (\n <MenuItem\n key={id}\n className={clsx('min-h-40 min-w-128 text-lg', action.itemProps?.className)}\n onClick={() => {\n exportTreeGridToExcelById(...action.exportExcelArgs);\n handleClose();\n }}\n sx={[baseItemSx, ...flattenSx(action.itemProps?.sx)]}\n >\n {action.label ?? t('Button.엑셀 다운로드')}\n </MenuItem>\n );\n }\n\n return (\n <MenuItem\n key={id}\n className={clsx('min-h-40 min-w-128 text-lg', action.itemProps?.className)}\n onClick={() => {\n action.onClick({ close: handleClose });\n handleClose();\n }}\n sx={[baseItemSx, ...flattenSx(action.itemProps?.sx)]}\n >\n {action.label}\n </MenuItem>\n );\n })(),\n )}\n </Menu>\n </>\n );\n};\n"],"names":["owpPaletteActionColors","flattenSx","__name","sx","item","isPaletteActionColor","color","getActionColors","theme","main","contrast","getDefaultActionColor","action","OwpMoreActionsButton","actions","openProp","defaultOpen","onOpenChange","disabled","className","containerSx","actionsSx","t","useOwpTranslation","useTheme","anchorEl","setAnchorEl","useState","controlled","open","keyedActions","useMemo","uniqueId","setOpen","useCallback","next","el","handleOpen","event","handleClose","jsxs","Fragment","jsx","IconButton","clsx","MoreVertIcon","Menu","id","idx","colors","baseItemSx","alpha","OwpFileUploadButton","_a","_b","_c","_d","_e","_f","_g","_h","_i","MenuItem","_j","exportTreeGridToExcelById","_k","_l","_m"],"mappings":";;;;;;;;;;;;AA+D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AWX,GAAA;AAAA,QAAG;AAAA,MACL;AAAA,IAAA;AAAA,EACF,GACF;AAEJ,GA1JoC;"}
|
|
1
|
+
{"version":3,"file":"OwpMoreActionsButton.js","sources":["../../../src/components/OwpMoreActionsButton/OwpMoreActionsButton.tsx"],"sourcesContent":["import { useOwpTranslation } from '@/hooks/useOwpTranslation';\nimport MoreVertIcon from '@mui/icons-material/MoreVert';\nimport { IconButton, Menu, MenuItem } from '@mui/material';\nimport type { IconButtonProps } from '@mui/material/IconButton';\nimport type { SxProps, Theme } from '@mui/material/styles';\nimport { alpha, useTheme } from '@mui/material/styles';\nimport clsx from 'clsx';\nimport { uniqueId } from 'es-toolkit/compat';\nimport type { MouseEvent, ReactNode } from 'react';\nimport { useCallback, useMemo, useState } from 'react';\nimport { exportTreeGridToExcelById } from '../../utils/treeGridUtil';\nimport {\n OwpFilePickerButton,\n type OwpFilePickerButtonProps,\n} from '../OwpFilePickerButton/OwpFilePickerButton';\n\nexport type OwpMoreButtonActionColor = NonNullable<IconButtonProps['color']> | string;\n\ntype OwpMoreButtonActionBase = {\n icon?: ReactNode;\n color?: OwpMoreButtonActionColor;\n label?: ReactNode;\n labelProps?: { className?: string; sx?: SxProps<Theme> };\n itemProps?: { className?: string; sx?: SxProps<Theme> };\n};\n\nexport type OwpMoreButtonClickAction = OwpMoreButtonActionBase & {\n type?: 'button';\n onClick: (args: { close: () => void }) => void;\n};\n\nexport type OwpMoreButtonFileUploadAction = OwpMoreButtonActionBase & {\n type: 'fileUpload';\n fileUploadProps?: Omit<OwpFilePickerButtonProps, 'title' | 'onChange' | 'onCancel'> & {\n onChange?: OwpFilePickerButtonProps['onChange'];\n onCancel?: OwpFilePickerButtonProps['onCancel'];\n };\n};\n\nexport type OwpMoreButtonTreeGridExportExcelAction = OwpMoreButtonActionBase & {\n type: 'treeGridExportExcel';\n exportExcelArgs: Parameters<typeof exportTreeGridToExcelById>;\n};\n\nexport type OwpMoreButtonAction =\n | OwpMoreButtonClickAction\n | OwpMoreButtonFileUploadAction\n | OwpMoreButtonTreeGridExportExcelAction;\n\nexport type OwpMoreActionsButtonProps = {\n actions: OwpMoreButtonAction[];\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n disabled?: boolean;\n className?: string;\n containerSx?: SxProps<Theme>;\n actionsSx?: SxProps<Theme>;\n};\n\ntype OwpFlatSx = NonNullable<Exclude<SxProps<Theme>, readonly unknown[]>>;\ntype OwpPaletteActionColor = 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';\n\nconst owpPaletteActionColors = [\n 'primary',\n 'secondary',\n 'error',\n 'info',\n 'success',\n 'warning',\n] as const;\n\nconst flattenSx = (sx?: SxProps<Theme>): OwpFlatSx[] => {\n if (!sx) return [];\n if (Array.isArray(sx)) return sx.filter((item): item is OwpFlatSx => Boolean(item));\n return [sx as OwpFlatSx];\n};\n\nconst isPaletteActionColor = (color: OwpMoreButtonActionColor | undefined): color is OwpPaletteActionColor =>\n typeof color === 'string' && owpPaletteActionColors.includes(color as OwpPaletteActionColor);\n\nconst getActionColors = (theme: Theme, color?: OwpMoreButtonActionColor) => {\n const main = isPaletteActionColor(color)\n ? theme.palette[color].main\n : color === 'inherit' || color === 'default'\n ? theme.palette.secondary.main\n : ((color as string) ?? theme.palette.secondary.main);\n\n const contrast = theme.palette.getContrastText(main);\n return { main, contrast };\n};\n\nconst getDefaultActionColor = (action: OwpMoreButtonAction): OwpMoreButtonActionColor => {\n if (action.type === 'treeGridExportExcel') {\n return 'success';\n }\n\n return 'secondary';\n};\n\n/**\n * OwpMoreActionsButton 컴포넌트\n * @param actions 액션 영역\n * @param openProp openProp 값\n * @param defaultOpen defaultOpen 값\n * @param onOpenChange onOpenChange 핸들러\n * @param disabled disabled 값\n * @param className CSS 클래스명\n */\nexport const OwpMoreActionsButton = ({\n actions,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n disabled,\n className,\n containerSx,\n actionsSx,\n}: OwpMoreActionsButtonProps) => {\n const { t } = useOwpTranslation();\n const theme = useTheme();\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n const controlled = openProp != null;\n const open = controlled ? Boolean(openProp) : Boolean(anchorEl) || defaultOpen;\n const keyedActions = useMemo(\n () => actions.map((action) => ({ action, id: uniqueId('owp-more-') })),\n [actions],\n );\n\n const setOpen = useCallback(\n (next: boolean, el: HTMLElement | null = null) => {\n if (!controlled) setAnchorEl(next ? el : null);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const handleOpen = useCallback(\n (event: MouseEvent<HTMLElement>) => {\n setOpen(true, event.currentTarget);\n },\n [setOpen],\n );\n\n const handleClose = useCallback(() => {\n setOpen(false, null);\n }, [setOpen]);\n\n return (\n <>\n <IconButton\n className={clsx(className)}\n disabled={disabled}\n onClick={handleOpen}\n sx={containerSx}\n >\n <MoreVertIcon />\n </IconButton>\n\n <Menu\n anchorEl={anchorEl}\n open={open}\n sx={actionsSx}\n onClose={handleClose}\n slotProps={{\n list: { disablePadding: true, sx: { p: 0 } },\n paper: {\n sx: {\n p: 0,\n mt: 0.75,\n minWidth: 200,\n borderRadius: 1.5,\n boxShadow: (t) => t.shadows[8],\n },\n },\n }}\n >\n {keyedActions.map(({ action, id }, idx) =>\n (() => {\n const colors = getActionColors(theme, action.color ?? getDefaultActionColor(action));\n const baseItemSx: OwpFlatSx = {\n bgcolor: colors.main,\n color: colors.contrast,\n '&:hover': {\n bgcolor: colors.main,\n opacity: 0.9,\n },\n ...(idx > 0\n ? {\n borderTop: (t: Theme) => `1px solid ${alpha(t.palette.common.white, 0.35)}`,\n mt: 0,\n }\n : null),\n };\n\n if (action.type === 'fileUpload') {\n return (\n <OwpFilePickerButton\n key={id}\n {...action.fileUploadProps}\n title={action.label ?? t('Button.엑셀 업로드')}\n startIcon={action.fileUploadProps?.startIcon ?? action.icon}\n fullWidth={action.fileUploadProps?.fullWidth ?? true}\n variant={action.fileUploadProps?.variant ?? 'text'}\n role={action.fileUploadProps?.role ?? 'menuitem'}\n tabIndex={action.fileUploadProps?.tabIndex ?? -1}\n className={clsx(\n 'min-h-40 min-w-128 justify-start rounded-none text-lg',\n action.itemProps?.className,\n action.fileUploadProps?.className,\n )}\n sx={[\n { justifyContent: 'flex-start', px: 2, py: 1 },\n baseItemSx,\n ...flattenSx(action.itemProps?.sx),\n ...flattenSx(action.fileUploadProps?.sx),\n ]}\n onChange={(event) => {\n action.fileUploadProps?.onChange?.(event);\n handleClose();\n }}\n onCancel={(event) => {\n action.fileUploadProps?.onCancel?.(event);\n handleClose();\n }}\n />\n );\n }\n\n if (action.type === 'treeGridExportExcel') {\n return (\n <MenuItem\n key={id}\n className={clsx('min-h-40 min-w-128 text-lg', action.itemProps?.className)}\n onClick={() => {\n exportTreeGridToExcelById(...action.exportExcelArgs);\n handleClose();\n }}\n sx={[baseItemSx, ...flattenSx(action.itemProps?.sx)]}\n >\n {action.label ?? t('Button.엑셀 다운로드')}\n </MenuItem>\n );\n }\n\n return (\n <MenuItem\n key={id}\n className={clsx('min-h-40 min-w-128 text-lg', action.itemProps?.className)}\n onClick={() => {\n action.onClick({ close: handleClose });\n handleClose();\n }}\n sx={[baseItemSx, ...flattenSx(action.itemProps?.sx)]}\n >\n {action.label}\n </MenuItem>\n );\n })(),\n )}\n </Menu>\n </>\n );\n};\n"],"names":["owpPaletteActionColors","flattenSx","__name","sx","item","isPaletteActionColor","color","getActionColors","theme","main","contrast","getDefaultActionColor","action","OwpMoreActionsButton","actions","openProp","defaultOpen","onOpenChange","disabled","className","containerSx","actionsSx","t","useOwpTranslation","useTheme","anchorEl","setAnchorEl","useState","controlled","open","keyedActions","useMemo","uniqueId","setOpen","useCallback","next","el","handleOpen","event","handleClose","jsxs","Fragment","jsx","IconButton","clsx","MoreVertIcon","Menu","id","idx","colors","baseItemSx","alpha","OwpFilePickerButton","_a","_b","_c","_d","_e","_f","_g","_h","_i","MenuItem","_j","exportTreeGridToExcelById","_k","_l","_m"],"mappings":";;;;;;;;;;;;AA+DA,MA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