@wipco/sdui 0.2.0 → 0.3.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.
- package/LICENSE +21 -0
- package/NOTICE +27 -0
- package/dist/chunk-4SU2KYPU.js +59 -0
- package/dist/chunk-56KKWLNI.js +186 -0
- package/dist/chunk-7Y4J7EOK.js +115 -0
- package/dist/chunk-APCXOCAO.js +110 -0
- package/dist/chunk-AROOQ5W6.js +119 -0
- package/dist/chunk-DGPRX4MU.js +251 -0
- package/dist/chunk-IL2KS4WS.js +25 -0
- package/dist/chunk-KADFN76X.js +541 -0
- package/dist/chunk-KBHI3IUR.js +40 -0
- package/dist/chunk-LZJTKVMO.js +767 -0
- package/dist/chunk-MOIU7MUA.js +282 -0
- package/dist/chunk-MSAV4J4I.js +77 -0
- package/dist/chunk-OOHHW4K4.js +159 -0
- package/dist/chunk-Q6SBH63R.js +190 -0
- package/dist/chunk-QZQDHSMD.js +78 -0
- package/dist/chunk-RH7ESUE6.js +309 -0
- package/dist/chunk-SEBPBUZR.js +260 -0
- package/dist/chunk-USKRM22W.js +39 -0
- package/dist/chunk-WNYWTFGW.js +61 -0
- package/dist/chunk-WVRCIVAD.js +72 -0
- package/dist/chunk-YJMD6MOE.js +404 -0
- package/dist/chunk-ZNITJ4KK.js +433 -0
- package/dist/chunk-ZQR3ULVH.js +193 -0
- package/dist/{chunk-QJHD6HVQ.js → chunk-ZUCI34QY.js} +106 -390
- package/dist/index.d.ts +306 -53
- package/dist/index.js +276 -720
- package/dist/meta.d.ts +8 -0
- package/dist/meta.js +147 -8
- package/dist/rich.js +3 -2
- package/dist/styles.css +246 -0
- package/dist/widgets/AutocompleteField.d.ts +96 -0
- package/dist/widgets/AutocompleteField.js +3 -0
- package/dist/widgets/ColumnBoard.d.ts +47 -0
- package/dist/widgets/ColumnBoard.js +2 -0
- package/dist/widgets/DiffView.d.ts +30 -0
- package/dist/widgets/DiffView.js +2 -0
- package/dist/widgets/Disclosure.d.ts +20 -0
- package/dist/widgets/Disclosure.js +2 -0
- package/dist/widgets/EventCalendar.d.ts +59 -0
- package/dist/widgets/EventCalendar.js +2 -0
- package/dist/widgets/ImageLightbox.d.ts +25 -0
- package/dist/widgets/ImageLightbox.js +2 -0
- package/dist/widgets/InlineEdit.d.ts +23 -0
- package/dist/widgets/InlineEdit.js +2 -0
- package/dist/widgets/JsonField.d.ts +24 -0
- package/dist/widgets/JsonField.js +2 -0
- package/dist/widgets/LiveClock.d.ts +21 -0
- package/dist/widgets/LiveClock.js +1 -0
- package/dist/widgets/OrgChart.d.ts +32 -0
- package/dist/widgets/OrgChart.js +2 -0
- package/dist/widgets/PeriodFilter.d.ts +48 -0
- package/dist/widgets/PeriodFilter.js +2 -0
- package/dist/widgets/PrintSheet.d.ts +23 -0
- package/dist/widgets/PrintSheet.js +2 -0
- package/dist/widgets/SearchableMultiPicker.d.ts +29 -0
- package/dist/widgets/SearchableMultiPicker.js +3 -0
- package/dist/widgets/SecureScreen.d.ts +25 -0
- package/dist/widgets/SecureScreen.js +2 -0
- package/dist/widgets/StackedMeter.d.ts +26 -0
- package/dist/widgets/StackedMeter.js +1 -0
- package/dist/widgets/Strip.d.ts +20 -0
- package/dist/widgets/Strip.js +1 -0
- package/dist/widgets/SummaryTable.d.ts +31 -0
- package/dist/widgets/SummaryTable.js +1 -0
- package/dist/widgets/TagMultiSelect.d.ts +25 -0
- package/dist/widgets/TagMultiSelect.js +2 -0
- package/dist/widgets/Timeline.d.ts +30 -0
- package/dist/widgets/Timeline.js +3 -0
- package/dist/widgets/TreePicker.d.ts +21 -0
- package/dist/widgets/TreePicker.js +3 -0
- package/dist/widgets/TreeView.d.ts +26 -0
- package/dist/widgets/TreeView.js +2 -0
- package/dist/widgets/index.d.ts +76 -0
- package/dist/widgets/index.js +69 -0
- package/package.json +93 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WIPCO
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# 제3자 고지
|
|
2
|
+
|
|
3
|
+
이 저장소는 MIT 라이선스로 배포됩니다(LICENSE 참고). 아래 구성 요소는 원저작자의
|
|
4
|
+
라이선스를 따르며, 그 고지를 여기에 유지합니다.
|
|
5
|
+
|
|
6
|
+
## Lucide 아이콘 (ISC License)
|
|
7
|
+
|
|
8
|
+
`packages/sdui/src/icons.ts`의 아이콘 기하 130종은 Lucide에서 가져왔습니다.
|
|
9
|
+
소스 SVG를 `scripts/gen-icons.mjs`가 구조화 노드로 변환한 것이며 도형 자체는 원본과 같습니다.
|
|
10
|
+
|
|
11
|
+
https://github.com/lucide-icons/lucide
|
|
12
|
+
|
|
13
|
+
ISC License
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2020, Lucide Contributors
|
|
16
|
+
|
|
17
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
18
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
19
|
+
copyright notice and this permission notice appear in all copies.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
22
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
23
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
24
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
25
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
26
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
27
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Badge, Tag } from './chunk-ZUCI34QY.js';
|
|
2
|
+
import { useState, useMemo } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function TagMultiSelect({
|
|
6
|
+
options,
|
|
7
|
+
values,
|
|
8
|
+
onChange,
|
|
9
|
+
disabled = false,
|
|
10
|
+
emptyText = "\uC120\uD0DD\uD560 \uD56D\uBAA9\uC774 \uC5C6\uC2B5\uB2C8\uB2E4"
|
|
11
|
+
}) {
|
|
12
|
+
const safeOptions = options ?? [];
|
|
13
|
+
const isControlled = values !== void 0 && typeof onChange === "function";
|
|
14
|
+
const [internalValues, setInternalValues] = useState(values ?? []);
|
|
15
|
+
const current = isControlled ? values : internalValues;
|
|
16
|
+
const currentSet = useMemo(() => new Set(current), [current]);
|
|
17
|
+
const toggle = (value) => {
|
|
18
|
+
const set = new Set(currentSet);
|
|
19
|
+
if (set.has(value)) set.delete(value);
|
|
20
|
+
else set.add(value);
|
|
21
|
+
const next = [
|
|
22
|
+
...safeOptions.filter((option) => set.has(option.value)).map((option) => option.value),
|
|
23
|
+
...current.filter(
|
|
24
|
+
(item) => set.has(item) && !safeOptions.some((option) => option.value === item)
|
|
25
|
+
)
|
|
26
|
+
];
|
|
27
|
+
setInternalValues(next);
|
|
28
|
+
onChange?.(next);
|
|
29
|
+
};
|
|
30
|
+
if (safeOptions.length === 0) {
|
|
31
|
+
return /* @__PURE__ */ jsx("span", { className: "wp-caption", children: emptyText });
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx("div", { className: "wp-row", role: "group", style: { flexWrap: "wrap", gap: "var(--wp-space-1)" }, children: safeOptions.map((option) => {
|
|
34
|
+
const selected = currentSet.has(option.value);
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
"button",
|
|
37
|
+
{
|
|
38
|
+
type: "button",
|
|
39
|
+
"aria-pressed": selected,
|
|
40
|
+
disabled,
|
|
41
|
+
title: selected ? `${option.label} \u2014 \uC120\uD0DD \uD574\uC81C` : `${option.label} \u2014 \uC120\uD0DD`,
|
|
42
|
+
onClick: () => toggle(option.value),
|
|
43
|
+
style: {
|
|
44
|
+
display: "inline-flex",
|
|
45
|
+
background: "none",
|
|
46
|
+
border: 0,
|
|
47
|
+
padding: 0,
|
|
48
|
+
borderRadius: "var(--wp-radius-pill)",
|
|
49
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
50
|
+
opacity: disabled ? 0.55 : void 0
|
|
51
|
+
},
|
|
52
|
+
children: selected ? /* @__PURE__ */ jsx(Badge, { tone: "brand", size: "lg", children: option.label }) : /* @__PURE__ */ jsx(Tag, { children: option.label })
|
|
53
|
+
},
|
|
54
|
+
option.value
|
|
55
|
+
);
|
|
56
|
+
}) });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { TagMultiSelect };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { includesLooseSearch } from './chunk-KADFN76X.js';
|
|
2
|
+
import { Button, Dialog, Input, Tag, Checkbox } from './chunk-ZUCI34QY.js';
|
|
3
|
+
import React, { useMemo, useState, useEffect } from 'react';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
function SearchableMultiPicker({
|
|
7
|
+
title,
|
|
8
|
+
options,
|
|
9
|
+
values,
|
|
10
|
+
onChange,
|
|
11
|
+
trigger,
|
|
12
|
+
disabled = false
|
|
13
|
+
}) {
|
|
14
|
+
const safeOptions = useMemo(() => options ?? [], [options]);
|
|
15
|
+
const isControlled = values !== void 0 && typeof onChange === "function";
|
|
16
|
+
const [internalValues, setInternalValues] = useState(values ?? []);
|
|
17
|
+
const committed = isControlled ? values : internalValues;
|
|
18
|
+
const [open, setOpen] = useState(false);
|
|
19
|
+
const [query, setQuery] = useState("");
|
|
20
|
+
const [draft, setDraft] = useState([]);
|
|
21
|
+
const [selectedAtOpen, setSelectedAtOpen] = useState(/* @__PURE__ */ new Set());
|
|
22
|
+
const optionByValue = useMemo(
|
|
23
|
+
() => new Map(safeOptions.map((option) => [option.value, option])),
|
|
24
|
+
[safeOptions]
|
|
25
|
+
);
|
|
26
|
+
const sortByOptionOrder = (list) => {
|
|
27
|
+
const set = new Set(list);
|
|
28
|
+
const known = safeOptions.filter((option) => set.has(option.value)).map((option) => option.value);
|
|
29
|
+
const unknown = list.filter((item) => !optionByValue.has(item));
|
|
30
|
+
return [...known, ...unknown];
|
|
31
|
+
};
|
|
32
|
+
const openDialog = () => {
|
|
33
|
+
if (disabled) return;
|
|
34
|
+
const current = committed ?? [];
|
|
35
|
+
setDraft(sortByOptionOrder(current));
|
|
36
|
+
setSelectedAtOpen(new Set(current));
|
|
37
|
+
setQuery("");
|
|
38
|
+
setOpen(true);
|
|
39
|
+
};
|
|
40
|
+
const closeDialog = () => setOpen(false);
|
|
41
|
+
const commit = () => {
|
|
42
|
+
const next = sortByOptionOrder(draft);
|
|
43
|
+
setInternalValues(next);
|
|
44
|
+
onChange?.(next);
|
|
45
|
+
setOpen(false);
|
|
46
|
+
};
|
|
47
|
+
const toggle = (value, checked) => {
|
|
48
|
+
setDraft(
|
|
49
|
+
(current) => sortByOptionOrder(checked ? [...current, value] : current.filter((item) => item !== value))
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!open) return;
|
|
54
|
+
const closeOnEscape = (event) => {
|
|
55
|
+
if (event.key === "Escape") setOpen(false);
|
|
56
|
+
};
|
|
57
|
+
document.addEventListener("keydown", closeOnEscape);
|
|
58
|
+
return () => document.removeEventListener("keydown", closeOnEscape);
|
|
59
|
+
}, [open]);
|
|
60
|
+
const visibleOptions = useMemo(() => {
|
|
61
|
+
const selectedFirst = [
|
|
62
|
+
...safeOptions.filter((option) => selectedAtOpen.has(option.value)),
|
|
63
|
+
...safeOptions.filter((option) => !selectedAtOpen.has(option.value))
|
|
64
|
+
];
|
|
65
|
+
return selectedFirst.filter(
|
|
66
|
+
(option) => includesLooseSearch(`${option.label} ${option.sub ?? ""}`, query)
|
|
67
|
+
);
|
|
68
|
+
}, [safeOptions, selectedAtOpen, query]);
|
|
69
|
+
const draftChips = draft.map((value) => ({
|
|
70
|
+
value,
|
|
71
|
+
label: optionByValue.get(value)?.label ?? value
|
|
72
|
+
}));
|
|
73
|
+
let triggerNode;
|
|
74
|
+
if (trigger !== void 0 && trigger !== null && React.isValidElement(trigger)) {
|
|
75
|
+
const element = trigger;
|
|
76
|
+
triggerNode = React.cloneElement(element, {
|
|
77
|
+
onClick: (event) => {
|
|
78
|
+
element.props.onClick?.(event);
|
|
79
|
+
openDialog();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
} else if (trigger !== void 0 && trigger !== null) {
|
|
83
|
+
triggerNode = /* @__PURE__ */ jsx(
|
|
84
|
+
"span",
|
|
85
|
+
{
|
|
86
|
+
role: "button",
|
|
87
|
+
tabIndex: disabled ? -1 : 0,
|
|
88
|
+
onClick: openDialog,
|
|
89
|
+
onKeyDown: (event) => {
|
|
90
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
openDialog();
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
style: { cursor: disabled ? "not-allowed" : "pointer", display: "inline-flex" },
|
|
96
|
+
children: trigger
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
} else {
|
|
100
|
+
triggerNode = /* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", icon: "list-filter", disabled, onClick: openDialog, children: committed.length > 0 ? `\uC120\uD0DD (${committed.length})` : "\uC120\uD0DD" });
|
|
101
|
+
}
|
|
102
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
103
|
+
triggerNode,
|
|
104
|
+
open ? /* @__PURE__ */ jsx(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
style: { position: "fixed", inset: 0, zIndex: "var(--wp-z-dialog)" },
|
|
108
|
+
onClick: (event) => {
|
|
109
|
+
if (event.target instanceof HTMLElement && event.target.classList.contains("wp-overlay")) {
|
|
110
|
+
closeDialog();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
children: /* @__PURE__ */ jsx(
|
|
114
|
+
Dialog,
|
|
115
|
+
{
|
|
116
|
+
title: title ?? "\uD56D\uBAA9 \uC120\uD0DD",
|
|
117
|
+
subtitle: `\uC804\uCCB4 ${safeOptions.length}\uAC1C \uC911\uC5D0\uC11C \uC120\uD0DD`,
|
|
118
|
+
icon: "list-filter",
|
|
119
|
+
size: "md",
|
|
120
|
+
onClose: closeDialog,
|
|
121
|
+
footer: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
122
|
+
/* @__PURE__ */ jsx("div", { style: { marginRight: "auto" }, children: /* @__PURE__ */ jsx(
|
|
123
|
+
Button,
|
|
124
|
+
{
|
|
125
|
+
type: "button",
|
|
126
|
+
variant: "ghost",
|
|
127
|
+
size: "sm",
|
|
128
|
+
icon: "rotate-ccw",
|
|
129
|
+
disabled: draft.length === 0,
|
|
130
|
+
onClick: () => setDraft([]),
|
|
131
|
+
children: "\uC804\uCCB4 \uD574\uC81C"
|
|
132
|
+
}
|
|
133
|
+
) }),
|
|
134
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "primary", size: "sm", onClick: commit, children: "\uC644\uB8CC" })
|
|
135
|
+
] }),
|
|
136
|
+
children: /* @__PURE__ */ jsxs("div", { className: "wp-col", style: { gap: "var(--wp-space-3)" }, children: [
|
|
137
|
+
/* @__PURE__ */ jsx(
|
|
138
|
+
Input,
|
|
139
|
+
{
|
|
140
|
+
icon: "search",
|
|
141
|
+
placeholder: "\uC774\uB984\xB7\uC124\uBA85\uC73C\uB85C \uAC80\uC0C9",
|
|
142
|
+
autoFocus: true,
|
|
143
|
+
value: query,
|
|
144
|
+
onChange: (event) => setQuery(event.target.value)
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
/* @__PURE__ */ jsxs("div", { className: "wp-row", style: { flexWrap: "wrap", gap: "var(--wp-space-1)" }, children: [
|
|
148
|
+
/* @__PURE__ */ jsxs("span", { className: "wp-caption", style: { flex: "none" }, children: [
|
|
149
|
+
"\uC120\uD0DD ",
|
|
150
|
+
draft.length,
|
|
151
|
+
"\uAC1C"
|
|
152
|
+
] }),
|
|
153
|
+
draftChips.map((chip) => /* @__PURE__ */ jsx(Tag, { onRemove: () => toggle(chip.value, false), children: chip.label }, chip.value))
|
|
154
|
+
] }),
|
|
155
|
+
/* @__PURE__ */ jsx(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: "wp-col",
|
|
159
|
+
style: {
|
|
160
|
+
maxHeight: 320,
|
|
161
|
+
overflowY: "auto",
|
|
162
|
+
gap: "var(--wp-space-1)",
|
|
163
|
+
borderTop: "var(--wp-border-w) solid var(--wp-divider)",
|
|
164
|
+
paddingTop: "var(--wp-space-2)"
|
|
165
|
+
},
|
|
166
|
+
children: visibleOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "wp-caption", style: { padding: "var(--wp-space-2) 0" }, children: "\uACB0\uACFC \uC5C6\uC74C" }) : visibleOptions.map((option) => /* @__PURE__ */ jsx(
|
|
167
|
+
Checkbox,
|
|
168
|
+
{
|
|
169
|
+
label: option.label,
|
|
170
|
+
description: option.sub,
|
|
171
|
+
checked: draft.includes(option.value),
|
|
172
|
+
onChange: (event) => toggle(option.value, event.target.checked)
|
|
173
|
+
},
|
|
174
|
+
option.value
|
|
175
|
+
))
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
] })
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
) : null
|
|
183
|
+
] });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { SearchableMultiPicker };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
// src/widgets/StackedMeter.tsx
|
|
4
|
+
var resolveColor = (color, index) => {
|
|
5
|
+
if (!color) return `var(--wp-series-${index % 8 + 1})`;
|
|
6
|
+
if (/^[1-8]$/.test(color)) return `var(--wp-series-${color})`;
|
|
7
|
+
return color;
|
|
8
|
+
};
|
|
9
|
+
var formatValue = (v) => v.toLocaleString("ko-KR", { maximumFractionDigits: 1 });
|
|
10
|
+
var formatPercent = (v) => `${v.toLocaleString("ko-KR", { maximumFractionDigits: 1 })}%`;
|
|
11
|
+
var dotStyle = (color) => ({
|
|
12
|
+
width: 8,
|
|
13
|
+
height: 8,
|
|
14
|
+
borderRadius: "var(--wp-radius-pill)",
|
|
15
|
+
background: color,
|
|
16
|
+
flexShrink: 0
|
|
17
|
+
});
|
|
18
|
+
function StackedMeter({
|
|
19
|
+
segments,
|
|
20
|
+
showLegend = true,
|
|
21
|
+
height = 10
|
|
22
|
+
}) {
|
|
23
|
+
const positive = segments.filter((s) => s.value > 0);
|
|
24
|
+
const total = positive.reduce((sum, s) => sum + s.value, 0);
|
|
25
|
+
const pctOf = (v) => total > 0 ? v / total * 100 : 0;
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
role: "img",
|
|
31
|
+
"aria-label": total > 0 ? segments.map((s) => `${s.label} ${formatPercent(pctOf(s.value))}`).join(", ") : "\uB370\uC774\uD130 \uC5C6\uC74C",
|
|
32
|
+
style: {
|
|
33
|
+
display: "flex",
|
|
34
|
+
gap: "var(--wp-space-half)",
|
|
35
|
+
width: "100%",
|
|
36
|
+
height,
|
|
37
|
+
borderRadius: "var(--wp-radius-pill)",
|
|
38
|
+
background: "var(--wp-surface-sunken)",
|
|
39
|
+
overflow: "hidden"
|
|
40
|
+
},
|
|
41
|
+
children: total > 0 && segments.map((s, i) => {
|
|
42
|
+
if (s.value <= 0) return null;
|
|
43
|
+
const pct = pctOf(s.value);
|
|
44
|
+
return /* @__PURE__ */ jsx(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
title: `${s.label} \xB7 ${formatValue(s.value)} (${formatPercent(pct)})`,
|
|
48
|
+
style: {
|
|
49
|
+
width: `${pct}%`,
|
|
50
|
+
minWidth: 2,
|
|
51
|
+
height: "100%",
|
|
52
|
+
background: resolveColor(s.color, i)
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
`${s.label}-${i}`
|
|
56
|
+
);
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
showLegend && segments.length > 0 && /* @__PURE__ */ jsx(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
style: {
|
|
64
|
+
display: "flex",
|
|
65
|
+
flexDirection: "column",
|
|
66
|
+
gap: "var(--wp-space-1)",
|
|
67
|
+
marginTop: "var(--wp-space-3)"
|
|
68
|
+
},
|
|
69
|
+
children: segments.map((s, i) => /* @__PURE__ */ jsxs(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
className: "wp-body-sm",
|
|
73
|
+
style: {
|
|
74
|
+
display: "flex",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
gap: "var(--wp-space-2)"
|
|
77
|
+
},
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, style: dotStyle(resolveColor(s.color, i)) }),
|
|
80
|
+
/* @__PURE__ */ jsx("span", { style: { color: "var(--wp-text-default)" }, children: s.label }),
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
"span",
|
|
83
|
+
{
|
|
84
|
+
style: {
|
|
85
|
+
marginLeft: "auto",
|
|
86
|
+
paddingLeft: "var(--wp-space-3)",
|
|
87
|
+
color: "var(--wp-text-strong)",
|
|
88
|
+
fontWeight: "var(--wp-weight-medium)",
|
|
89
|
+
fontVariantNumeric: "tabular-nums"
|
|
90
|
+
},
|
|
91
|
+
children: formatValue(s.value)
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
"span",
|
|
96
|
+
{
|
|
97
|
+
className: "wp-caption",
|
|
98
|
+
style: {
|
|
99
|
+
width: 52,
|
|
100
|
+
textAlign: "right",
|
|
101
|
+
fontVariantNumeric: "tabular-nums"
|
|
102
|
+
},
|
|
103
|
+
children: s.value > 0 && total > 0 ? formatPercent(pctOf(s.value)) : "0%"
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
`${s.label}-${i}`
|
|
109
|
+
))
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { StackedMeter };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Icon } from './chunk-ZUCI34QY.js';
|
|
2
|
+
import { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var DEFAULT_NOTICE = "\uAC1C\uC778\uC815\uBCF4 \uBCF4\uD638\uB97C \uC704\uD574 \uD654\uBA74\uC744 \uAC00\uB838\uC2B5\uB2C8\uB2E4. \uD654\uBA74\uC744 \uD074\uB9AD\uD558\uBA74 \uB2E4\uC2DC \uD45C\uC2DC\uB429\uB2C8\uB2E4.";
|
|
6
|
+
var PRINT_NOTICE = "\uAC1C\uC778\uC815\uBCF4 \uBCF4\uD638 \uD654\uBA74\uC740 \uC778\uC1C4\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.";
|
|
7
|
+
var CLIPBOARD_WARNING = "[WIPCO ERP] \uAC1C\uC778\uC815\uBCF4 \uBCF4\uD638 \uD654\uBA74\uC785\uB2C8\uB2E4 \u2014 \uD654\uBA74 \uCEA1\uCC98\xB7\uBCF5\uC0AC\uAC00 \uC81C\uD55C\uB418\uBA70, \uC720\uCD9C \uC2DC \uAD00\uB828 \uBC95\uB839\uC5D0 \uB530\uB77C \uCC98\uBC8C\uB420 \uC218 \uC788\uC2B5\uB2C8\uB2E4.";
|
|
8
|
+
var BLOCKED_COMBO_KEYS = /* @__PURE__ */ new Set(["A", "C", "P", "S", "U", "X"]);
|
|
9
|
+
var SECURE_CSS = `
|
|
10
|
+
.erp-secure{position:relative}
|
|
11
|
+
.erp-secure--enabled{user-select:none;-webkit-user-select:none}
|
|
12
|
+
.erp-secure__cover{position:fixed;inset:0;z-index:var(--wp-z-overlay);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--wp-space-3);background-color:var(--wp-surface-overlay);background-image:var(--wp-surface-scrim);backdrop-filter:var(--wp-blur-scrim);-webkit-backdrop-filter:var(--wp-blur-scrim);color:var(--wp-text-inverse);text-align:center;padding:var(--wp-space-6);cursor:pointer}
|
|
13
|
+
.erp-secure__cover-notice{max-width:420px;color:var(--wp-text-inverse)}
|
|
14
|
+
.erp-secure__print-warning{display:none;cursor:default}
|
|
15
|
+
.erp-secure--print .erp-secure__print-warning{display:flex}
|
|
16
|
+
@media print{
|
|
17
|
+
.erp-secure--enabled .erp-secure__content{display:none !important}
|
|
18
|
+
.erp-secure--enabled .erp-secure__print-warning{display:flex !important;position:static;background:none;backdrop-filter:none;-webkit-backdrop-filter:none;color:inherit;cursor:default}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
function SecureStyles() {
|
|
22
|
+
return /* @__PURE__ */ jsx("style", { href: "erp-secure", precedence: "medium", children: SECURE_CSS });
|
|
23
|
+
}
|
|
24
|
+
function overwriteClipboard() {
|
|
25
|
+
try {
|
|
26
|
+
const pending = navigator.clipboard?.writeText(CLIPBOARD_WARNING);
|
|
27
|
+
if (pending) pending.catch(() => void 0);
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function SecureScreen({ enabled = true, notice, children }) {
|
|
32
|
+
const hostRef = useRef(null);
|
|
33
|
+
const [cover, setCover] = useState(null);
|
|
34
|
+
const [prevEnabled, setPrevEnabled] = useState(enabled);
|
|
35
|
+
if (prevEnabled !== enabled) {
|
|
36
|
+
setPrevEnabled(enabled);
|
|
37
|
+
if (!enabled) setCover(null);
|
|
38
|
+
}
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!enabled) return;
|
|
41
|
+
const host = hostRef.current;
|
|
42
|
+
const block = (event) => event.preventDefault();
|
|
43
|
+
const guarded = ["contextmenu", "copy", "cut", "dragstart", "selectstart"];
|
|
44
|
+
guarded.forEach((name) => host?.addEventListener(name, block));
|
|
45
|
+
const onKeyDown = (event) => {
|
|
46
|
+
if ((event.ctrlKey || event.metaKey) && BLOCKED_COMBO_KEYS.has(event.key.toUpperCase())) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (event.key === "PrintScreen") overwriteClipboard();
|
|
52
|
+
};
|
|
53
|
+
const onKeyUp = (event) => {
|
|
54
|
+
if (event.key === "PrintScreen") overwriteClipboard();
|
|
55
|
+
};
|
|
56
|
+
const raiseVeil = () => setCover((current) => current ?? "veil");
|
|
57
|
+
const dropVeil = () => setCover((current) => current === "veil" ? null : current);
|
|
58
|
+
const onVisibility = () => {
|
|
59
|
+
if (document.hidden) raiseVeil();
|
|
60
|
+
else dropVeil();
|
|
61
|
+
};
|
|
62
|
+
const onBeforePrint = () => setCover("print");
|
|
63
|
+
const onAfterPrint = () => setCover((current) => current === "print" ? null : current);
|
|
64
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
65
|
+
document.addEventListener("keyup", onKeyUp, true);
|
|
66
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
67
|
+
window.addEventListener("blur", raiseVeil);
|
|
68
|
+
window.addEventListener("focus", dropVeil);
|
|
69
|
+
window.addEventListener("beforeprint", onBeforePrint);
|
|
70
|
+
window.addEventListener("afterprint", onAfterPrint);
|
|
71
|
+
return () => {
|
|
72
|
+
guarded.forEach((name) => host?.removeEventListener(name, block));
|
|
73
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
74
|
+
document.removeEventListener("keyup", onKeyUp, true);
|
|
75
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
76
|
+
window.removeEventListener("blur", raiseVeil);
|
|
77
|
+
window.removeEventListener("focus", dropVeil);
|
|
78
|
+
window.removeEventListener("beforeprint", onBeforePrint);
|
|
79
|
+
window.removeEventListener("afterprint", onAfterPrint);
|
|
80
|
+
};
|
|
81
|
+
}, [enabled]);
|
|
82
|
+
const classes = ["erp-secure"];
|
|
83
|
+
if (enabled) classes.push("erp-secure--enabled");
|
|
84
|
+
if (enabled && cover === "print") classes.push("erp-secure--print");
|
|
85
|
+
return /* @__PURE__ */ jsxs("div", { ref: hostRef, className: classes.join(" "), children: [
|
|
86
|
+
/* @__PURE__ */ jsx(SecureStyles, {}),
|
|
87
|
+
/* @__PURE__ */ jsx("div", { className: "erp-secure__content", children }),
|
|
88
|
+
enabled && cover === "veil" ? /* @__PURE__ */ jsxs(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
className: "erp-secure__cover",
|
|
92
|
+
role: "alert",
|
|
93
|
+
onClick: () => {
|
|
94
|
+
window.focus();
|
|
95
|
+
setCover(null);
|
|
96
|
+
},
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsx(Icon, { name: "eye-off", size: 24, title: "\uD654\uBA74 \uAC00\uB9BC" }),
|
|
99
|
+
/* @__PURE__ */ jsx("p", { className: "wp-body erp-secure__cover-notice", style: { margin: 0 }, children: notice ?? DEFAULT_NOTICE })
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
) : null,
|
|
103
|
+
enabled ? /* @__PURE__ */ jsxs("div", { className: "erp-secure__cover erp-secure__print-warning", role: "alert", children: [
|
|
104
|
+
/* @__PURE__ */ jsx(Icon, { name: "triangle-alert", size: 24, title: "\uC778\uC1C4 \uCC28\uB2E8" }),
|
|
105
|
+
/* @__PURE__ */ jsx("p", { className: "wp-body erp-secure__cover-notice", style: { margin: 0 }, children: PRINT_NOTICE })
|
|
106
|
+
] }) : null
|
|
107
|
+
] });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { SecureScreen };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Textarea, Icon } from './chunk-ZUCI34QY.js';
|
|
2
|
+
import { useState, useRef, useId, useEffect, useCallback } from 'react';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function formatValue(value) {
|
|
6
|
+
if (value === void 0) return "";
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
if (value.trim() === "") return "";
|
|
9
|
+
try {
|
|
10
|
+
return JSON.stringify(JSON.parse(value), null, 2) ?? "";
|
|
11
|
+
} catch {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return JSON.stringify(value, null, 2) ?? "";
|
|
17
|
+
} catch {
|
|
18
|
+
return String(value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function describeParseError(err, text) {
|
|
22
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
23
|
+
const lineCol = /line\s+(\d+)\s+column\s+(\d+)/i.exec(message);
|
|
24
|
+
if (lineCol) {
|
|
25
|
+
return `JSON \uAD6C\uBB38 \uC624\uB958 \u2014 ${lineCol[1]}\uD589 ${lineCol[2]}\uC5F4: ${message}`;
|
|
26
|
+
}
|
|
27
|
+
const posMatch = /position\s+(\d+)/i.exec(message);
|
|
28
|
+
if (posMatch) {
|
|
29
|
+
const pos = Math.min(Number(posMatch[1]), text.length);
|
|
30
|
+
let line = 1;
|
|
31
|
+
let column = 1;
|
|
32
|
+
for (let i = 0; i < pos; i += 1) {
|
|
33
|
+
if (text.charCodeAt(i) === 10) {
|
|
34
|
+
line += 1;
|
|
35
|
+
column = 1;
|
|
36
|
+
} else {
|
|
37
|
+
column += 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return `JSON \uAD6C\uBB38 \uC624\uB958 \u2014 ${line}\uD589 ${column}\uC5F4(\uC704\uCE58 ${pos}): ${message}`;
|
|
41
|
+
}
|
|
42
|
+
return `JSON \uAD6C\uBB38 \uC624\uB958: ${message}`;
|
|
43
|
+
}
|
|
44
|
+
function JsonField({
|
|
45
|
+
value,
|
|
46
|
+
onChange,
|
|
47
|
+
rows = 6,
|
|
48
|
+
invalid = false,
|
|
49
|
+
disabled = false,
|
|
50
|
+
placeholder
|
|
51
|
+
}) {
|
|
52
|
+
const [text, setText] = useState(() => formatValue(value));
|
|
53
|
+
const [parseError, setParseError] = useState(null);
|
|
54
|
+
const focusedRef = useRef(false);
|
|
55
|
+
const lastFormattedRef = useRef(text);
|
|
56
|
+
const errorId = useId();
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const next = formatValue(value);
|
|
59
|
+
if (next === lastFormattedRef.current) return;
|
|
60
|
+
lastFormattedRef.current = next;
|
|
61
|
+
if (focusedRef.current) return;
|
|
62
|
+
setText(next);
|
|
63
|
+
setParseError(null);
|
|
64
|
+
}, [value]);
|
|
65
|
+
const handleBlur = useCallback(() => {
|
|
66
|
+
focusedRef.current = false;
|
|
67
|
+
if (text.trim() === "") {
|
|
68
|
+
setParseError(null);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const parsed = JSON.parse(text);
|
|
73
|
+
const pretty = JSON.stringify(parsed, null, 2) ?? "";
|
|
74
|
+
setParseError(null);
|
|
75
|
+
setText(pretty);
|
|
76
|
+
lastFormattedRef.current = pretty;
|
|
77
|
+
onChange?.(parsed);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
setParseError(describeParseError(err, text));
|
|
80
|
+
}
|
|
81
|
+
}, [text, onChange]);
|
|
82
|
+
return /* @__PURE__ */ jsxs(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
style: {
|
|
86
|
+
display: "flex",
|
|
87
|
+
flexDirection: "column",
|
|
88
|
+
gap: "var(--wp-space-1)",
|
|
89
|
+
minWidth: 0
|
|
90
|
+
},
|
|
91
|
+
children: [
|
|
92
|
+
/* @__PURE__ */ jsx(
|
|
93
|
+
Textarea,
|
|
94
|
+
{
|
|
95
|
+
className: "wp-mono",
|
|
96
|
+
rows,
|
|
97
|
+
value: text,
|
|
98
|
+
invalid: invalid || parseError !== null,
|
|
99
|
+
disabled,
|
|
100
|
+
placeholder: placeholder ?? "JSON\uC744 \uC785\uB825\uD558\uC138\uC694",
|
|
101
|
+
spellCheck: false,
|
|
102
|
+
"aria-describedby": parseError !== null ? errorId : void 0,
|
|
103
|
+
onFocus: () => {
|
|
104
|
+
focusedRef.current = true;
|
|
105
|
+
},
|
|
106
|
+
onBlur: handleBlur,
|
|
107
|
+
onChange: (e) => setText(e.target.value)
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
parseError !== null ? /* @__PURE__ */ jsxs("p", { id: errorId, className: "wp-field__error", role: "alert", style: { margin: 0 }, children: [
|
|
111
|
+
/* @__PURE__ */ jsx(Icon, { name: "circle-alert", size: 14 }),
|
|
112
|
+
/* @__PURE__ */ jsx("span", { children: parseError })
|
|
113
|
+
] }) : null
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { JsonField };
|