@wipco/sdui 0.1.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-ZUCI34QY.js +1290 -0
- package/dist/index.d.ts +391 -79
- package/dist/index.js +277 -758
- package/dist/meta.d.ts +10 -2
- package/dist/meta.js +268 -27
- package/dist/rich.js +3 -2
- package/dist/styles.css +334 -13
- 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/dist/chunk-AR2JYE75.js +0 -889
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { SegmentedControl, Select, Input } from './chunk-ZUCI34QY.js';
|
|
2
|
+
import { useState, useMemo } from 'react';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var MODE_ITEMS = [
|
|
6
|
+
{ value: "year", label: "\uC5F0\uAC04" },
|
|
7
|
+
{ value: "half", label: "\uBC18\uAE30" },
|
|
8
|
+
{ value: "quarter", label: "\uBD84\uAE30" },
|
|
9
|
+
{ value: "month", label: "\uC6D4\uAC04" },
|
|
10
|
+
{ value: "custom", label: "\uC9C1\uC811" }
|
|
11
|
+
];
|
|
12
|
+
var MODES = ["year", "half", "quarter", "month", "custom"];
|
|
13
|
+
function normalizeModes(modes) {
|
|
14
|
+
if (!Array.isArray(modes)) return MODE_ITEMS;
|
|
15
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16
|
+
const items = [];
|
|
17
|
+
for (const raw of modes) {
|
|
18
|
+
const value = typeof raw === "string" ? raw : raw?.value;
|
|
19
|
+
if (!MODES.includes(value) || seen.has(value)) continue;
|
|
20
|
+
seen.add(value);
|
|
21
|
+
const preset = MODE_ITEMS.find((item) => item.value === value);
|
|
22
|
+
const given = typeof raw === "string" ? void 0 : raw;
|
|
23
|
+
items.push({ value, label: given?.label ?? preset?.label, icon: given?.icon });
|
|
24
|
+
}
|
|
25
|
+
return items.length > 0 ? items : MODE_ITEMS;
|
|
26
|
+
}
|
|
27
|
+
var pad2 = (n) => String(n).padStart(2, "0");
|
|
28
|
+
var lastDayOfMonth = (year, month) => new Date(year, month, 0).getDate();
|
|
29
|
+
var isIsoDate = (s) => typeof s === "string" && /^\d{4}-\d{2}-\d{2}$/.test(s);
|
|
30
|
+
function clampInt(v, min, max, fallback) {
|
|
31
|
+
const n = typeof v === "number" && Number.isFinite(v) ? Math.round(v) : NaN;
|
|
32
|
+
if (Number.isNaN(n)) return fallback;
|
|
33
|
+
return Math.min(max, Math.max(min, n));
|
|
34
|
+
}
|
|
35
|
+
function rangeOf(p) {
|
|
36
|
+
const y = p.year ?? (/* @__PURE__ */ new Date()).getFullYear();
|
|
37
|
+
switch (p.mode) {
|
|
38
|
+
case "half": {
|
|
39
|
+
return (p.half ?? 1) === 1 ? { from: `${y}-01-01`, to: `${y}-06-30` } : { from: `${y}-07-01`, to: `${y}-12-31` };
|
|
40
|
+
}
|
|
41
|
+
case "quarter": {
|
|
42
|
+
const q = p.quarter ?? 1;
|
|
43
|
+
const startMonth = (q - 1) * 3 + 1;
|
|
44
|
+
const endMonth = q * 3;
|
|
45
|
+
return {
|
|
46
|
+
from: `${y}-${pad2(startMonth)}-01`,
|
|
47
|
+
to: `${y}-${pad2(endMonth)}-${pad2(lastDayOfMonth(y, endMonth))}`
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
case "month": {
|
|
51
|
+
const m = p.month ?? 1;
|
|
52
|
+
return { from: `${y}-${pad2(m)}-01`, to: `${y}-${pad2(m)}-${pad2(lastDayOfMonth(y, m))}` };
|
|
53
|
+
}
|
|
54
|
+
case "custom":
|
|
55
|
+
return { from: p.from ?? "", to: p.to ?? "" };
|
|
56
|
+
case "year":
|
|
57
|
+
default:
|
|
58
|
+
return { from: `${y}-01-01`, to: `${y}-12-31` };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function normalizePeriod(p) {
|
|
62
|
+
const now = /* @__PURE__ */ new Date();
|
|
63
|
+
const curYear = now.getFullYear();
|
|
64
|
+
const curMonth = now.getMonth() + 1;
|
|
65
|
+
const mode = p !== void 0 && MODES.includes(p.mode) ? p.mode : "month";
|
|
66
|
+
const year = clampInt(p?.year, 1970, 2999, curYear);
|
|
67
|
+
switch (mode) {
|
|
68
|
+
case "year":
|
|
69
|
+
return { mode, year };
|
|
70
|
+
case "half":
|
|
71
|
+
return { mode, year, half: clampInt(p?.half, 1, 2, curMonth <= 6 ? 1 : 2) };
|
|
72
|
+
case "quarter":
|
|
73
|
+
return {
|
|
74
|
+
mode,
|
|
75
|
+
year,
|
|
76
|
+
quarter: clampInt(p?.quarter, 1, 4, Math.ceil(curMonth / 3))
|
|
77
|
+
};
|
|
78
|
+
case "month":
|
|
79
|
+
return { mode, year, month: clampInt(p?.month, 1, 12, curMonth) };
|
|
80
|
+
case "custom": {
|
|
81
|
+
const base = rangeOf({ mode: "month", year, month: curMonth });
|
|
82
|
+
const from = isIsoDate(p?.from) ? p.from : base.from;
|
|
83
|
+
let to = isIsoDate(p?.to) ? p.to : base.to;
|
|
84
|
+
if (to < from) to = from;
|
|
85
|
+
return { mode, from, to };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function convertMode(cur, mode) {
|
|
90
|
+
const now = /* @__PURE__ */ new Date();
|
|
91
|
+
let year = cur.year ?? now.getFullYear();
|
|
92
|
+
let month;
|
|
93
|
+
if (cur.mode === "month" && cur.month !== void 0) {
|
|
94
|
+
month = cur.month;
|
|
95
|
+
} else if (cur.mode === "quarter" && cur.quarter !== void 0) {
|
|
96
|
+
month = (cur.quarter - 1) * 3 + 1;
|
|
97
|
+
} else if (cur.mode === "half" && cur.half !== void 0) {
|
|
98
|
+
month = cur.half === 2 ? 7 : 1;
|
|
99
|
+
} else if (cur.mode === "custom" && isIsoDate(cur.from)) {
|
|
100
|
+
year = Number(cur.from.slice(0, 4));
|
|
101
|
+
month = clampInt(Number(cur.from.slice(5, 7)), 1, 12, now.getMonth() + 1);
|
|
102
|
+
} else {
|
|
103
|
+
month = now.getMonth() + 1;
|
|
104
|
+
}
|
|
105
|
+
switch (mode) {
|
|
106
|
+
case "year":
|
|
107
|
+
return normalizePeriod({ mode, year });
|
|
108
|
+
case "half":
|
|
109
|
+
return normalizePeriod({ mode, year, half: month <= 6 ? 1 : 2 });
|
|
110
|
+
case "quarter":
|
|
111
|
+
return normalizePeriod({ mode, year, quarter: Math.ceil(month / 3) });
|
|
112
|
+
case "month":
|
|
113
|
+
return normalizePeriod({ mode, year, month });
|
|
114
|
+
case "custom": {
|
|
115
|
+
const range = rangeOf(cur);
|
|
116
|
+
return normalizePeriod({ mode, year, from: range.from, to: range.to });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
var HALF_OPTIONS = [
|
|
121
|
+
{ value: "1", label: "\uC0C1\uBC18\uAE30" },
|
|
122
|
+
{ value: "2", label: "\uD558\uBC18\uAE30" }
|
|
123
|
+
];
|
|
124
|
+
var QUARTER_OPTIONS = [1, 2, 3, 4].map((q) => ({ value: String(q), label: `${q}\uBD84\uAE30` }));
|
|
125
|
+
var MONTH_OPTIONS = Array.from({ length: 12 }, (_, i) => ({
|
|
126
|
+
value: String(i + 1),
|
|
127
|
+
label: `${i + 1}\uC6D4`
|
|
128
|
+
}));
|
|
129
|
+
function PeriodFilter({ value, onChange, years, modes }) {
|
|
130
|
+
const [inner, setInner] = useState(() => normalizePeriod(value));
|
|
131
|
+
const modeItems = useMemo(() => normalizeModes(modes), [modes]);
|
|
132
|
+
const requested = normalizePeriod(value !== void 0 ? value : inner);
|
|
133
|
+
const period = modeItems.some((item) => item.value === requested.mode) ? requested : convertMode(requested, modeItems[0].value);
|
|
134
|
+
const emit = (next) => {
|
|
135
|
+
setInner(next);
|
|
136
|
+
onChange?.(next);
|
|
137
|
+
};
|
|
138
|
+
const yearOptions = useMemo(() => {
|
|
139
|
+
const curYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
140
|
+
const base = years !== void 0 && years.length > 0 ? [...new Set(years)] : Array.from({ length: 6 }, (_, i) => curYear - i);
|
|
141
|
+
if (period.year !== void 0 && !base.includes(period.year)) base.push(period.year);
|
|
142
|
+
return base.sort((a, b) => b - a).map((y) => ({ value: String(y), label: `${y}\uB144` }));
|
|
143
|
+
}, [years, period.year]);
|
|
144
|
+
const handleFromChange = (from) => {
|
|
145
|
+
if (!isIsoDate(from)) return;
|
|
146
|
+
const to = period.to !== void 0 && period.to >= from ? period.to : from;
|
|
147
|
+
emit({ mode: "custom", from, to });
|
|
148
|
+
};
|
|
149
|
+
const handleToChange = (to) => {
|
|
150
|
+
if (!isIsoDate(to)) return;
|
|
151
|
+
const from = period.from !== void 0 && period.from <= to ? period.from : to;
|
|
152
|
+
emit({ mode: "custom", from, to });
|
|
153
|
+
};
|
|
154
|
+
return /* @__PURE__ */ jsxs(
|
|
155
|
+
"div",
|
|
156
|
+
{
|
|
157
|
+
role: "group",
|
|
158
|
+
"aria-label": "\uAE30\uAC04 \uC120\uD0DD",
|
|
159
|
+
style: {
|
|
160
|
+
display: "flex",
|
|
161
|
+
alignItems: "center",
|
|
162
|
+
flexWrap: "wrap",
|
|
163
|
+
gap: "var(--wp-space-2)"
|
|
164
|
+
},
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ jsx(
|
|
167
|
+
SegmentedControl,
|
|
168
|
+
{
|
|
169
|
+
items: [...modeItems],
|
|
170
|
+
value: period.mode,
|
|
171
|
+
onChange: (m) => emit(convertMode(period, m))
|
|
172
|
+
}
|
|
173
|
+
),
|
|
174
|
+
period.mode !== "custom" ? /* @__PURE__ */ jsx("span", { style: { width: 96, flex: "none" }, children: /* @__PURE__ */ jsx(
|
|
175
|
+
Select,
|
|
176
|
+
{
|
|
177
|
+
"aria-label": "\uC5F0\uB3C4",
|
|
178
|
+
options: yearOptions,
|
|
179
|
+
value: String(period.year),
|
|
180
|
+
onChange: (e) => emit(normalizePeriod({ ...period, year: Number(e.target.value) }))
|
|
181
|
+
}
|
|
182
|
+
) }) : null,
|
|
183
|
+
period.mode === "half" ? /* @__PURE__ */ jsx("span", { style: { width: 100, flex: "none" }, children: /* @__PURE__ */ jsx(
|
|
184
|
+
Select,
|
|
185
|
+
{
|
|
186
|
+
"aria-label": "\uBC18\uAE30",
|
|
187
|
+
options: HALF_OPTIONS,
|
|
188
|
+
value: String(period.half),
|
|
189
|
+
onChange: (e) => emit(normalizePeriod({ ...period, half: Number(e.target.value) }))
|
|
190
|
+
}
|
|
191
|
+
) }) : null,
|
|
192
|
+
period.mode === "quarter" ? /* @__PURE__ */ jsx("span", { style: { width: 96, flex: "none" }, children: /* @__PURE__ */ jsx(
|
|
193
|
+
Select,
|
|
194
|
+
{
|
|
195
|
+
"aria-label": "\uBD84\uAE30",
|
|
196
|
+
options: QUARTER_OPTIONS,
|
|
197
|
+
value: String(period.quarter),
|
|
198
|
+
onChange: (e) => emit(
|
|
199
|
+
normalizePeriod({ ...period, quarter: Number(e.target.value) })
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
) }) : null,
|
|
203
|
+
period.mode === "month" ? /* @__PURE__ */ jsx("span", { style: { width: 88, flex: "none" }, children: /* @__PURE__ */ jsx(
|
|
204
|
+
Select,
|
|
205
|
+
{
|
|
206
|
+
"aria-label": "\uC6D4",
|
|
207
|
+
options: MONTH_OPTIONS,
|
|
208
|
+
value: String(period.month),
|
|
209
|
+
onChange: (e) => emit(normalizePeriod({ ...period, month: Number(e.target.value) }))
|
|
210
|
+
}
|
|
211
|
+
) }) : null,
|
|
212
|
+
period.mode === "custom" ? /* @__PURE__ */ jsxs(
|
|
213
|
+
"span",
|
|
214
|
+
{
|
|
215
|
+
style: {
|
|
216
|
+
display: "inline-flex",
|
|
217
|
+
alignItems: "center",
|
|
218
|
+
gap: "var(--wp-space-1)",
|
|
219
|
+
flex: "none"
|
|
220
|
+
},
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ jsx("span", { style: { width: 148, flex: "none" }, children: /* @__PURE__ */ jsx(
|
|
223
|
+
Input,
|
|
224
|
+
{
|
|
225
|
+
type: "date",
|
|
226
|
+
"aria-label": "\uC2DC\uC791\uC77C",
|
|
227
|
+
value: period.from ?? "",
|
|
228
|
+
max: period.to,
|
|
229
|
+
onChange: (e) => handleFromChange(e.target.value)
|
|
230
|
+
}
|
|
231
|
+
) }),
|
|
232
|
+
/* @__PURE__ */ jsx("span", { style: { color: "var(--wp-text-subtle)" }, "aria-hidden": true, children: "~" }),
|
|
233
|
+
/* @__PURE__ */ jsx("span", { style: { width: 148, flex: "none" }, children: /* @__PURE__ */ jsx(
|
|
234
|
+
Input,
|
|
235
|
+
{
|
|
236
|
+
type: "date",
|
|
237
|
+
"aria-label": "\uC885\uB8CC\uC77C",
|
|
238
|
+
value: period.to ?? "",
|
|
239
|
+
min: period.from,
|
|
240
|
+
onChange: (e) => handleToChange(e.target.value)
|
|
241
|
+
}
|
|
242
|
+
) })
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
) : null
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export { PeriodFilter };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
// src/widgets/Strip.tsx
|
|
5
|
+
var STRIP_CSS = `
|
|
6
|
+
.erp-strip{display:flex;align-items:stretch;overflow-x:auto;min-width:0;padding-bottom:var(--wp-space-1);scrollbar-width:thin;scrollbar-color:var(--wp-border-default) transparent}
|
|
7
|
+
.erp-strip::-webkit-scrollbar{height:6px}
|
|
8
|
+
.erp-strip::-webkit-scrollbar-track{background:transparent}
|
|
9
|
+
.erp-strip::-webkit-scrollbar-thumb{background:var(--wp-border-default);border-radius:var(--wp-radius-pill)}
|
|
10
|
+
.erp-strip--snap{scroll-snap-type:x mandatory}
|
|
11
|
+
.erp-strip__item{flex:0 0 auto;min-width:0}
|
|
12
|
+
.erp-strip--snap .erp-strip__item{scroll-snap-align:start}
|
|
13
|
+
`;
|
|
14
|
+
function StripStyles() {
|
|
15
|
+
return /* @__PURE__ */ jsx("style", { href: "erp-strip", precedence: "medium", children: STRIP_CSS });
|
|
16
|
+
}
|
|
17
|
+
function Strip({ children, gap = "var(--wp-space-3)", snap = false }) {
|
|
18
|
+
const items = React.Children.toArray(children);
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", { className: snap ? "erp-strip erp-strip--snap" : "erp-strip", style: { gap }, children: [
|
|
20
|
+
/* @__PURE__ */ jsx(StripStyles, {}),
|
|
21
|
+
items.map((child, index) => /* @__PURE__ */ jsx("div", { className: "erp-strip__item", children: child }, index))
|
|
22
|
+
] });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { Strip };
|