@wipco/sdui 0.27.0 → 0.29.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.
@@ -0,0 +1,340 @@
1
+ import { useSduiAdapter, hostFetchOf, defaultAdapter } from './chunk-DVOPZFQS.js';
2
+ import { Icon, Badge, Checkbox, Select, Button } from './chunk-WIDDHR7L.js';
3
+ import { boxed } from './chunk-SAN4IX6N.js';
4
+ import { useRef, useEffect, useMemo, useState } from 'react';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+
7
+ var OPERATIONS = [
8
+ { key: "read", label: "\uC870\uD68C" },
9
+ { key: "create", label: "\uC0DD\uC131" },
10
+ { key: "update", label: "\uC218\uC815" },
11
+ { key: "delete", label: "\uC0AD\uC81C" }
12
+ ];
13
+ var SCOPE_OPTIONS = [
14
+ { value: "team", label: "\uD300" },
15
+ { value: "headquarter", label: "\uBCF8\uBD80" },
16
+ { value: "all", label: "\uC804\uCCB4" }
17
+ ];
18
+ var CATEGORY_LABELS = {
19
+ fi: "\uC7AC\uBB34",
20
+ asset: "\uC790\uC0B0",
21
+ hr: "\uC778\uC0AC",
22
+ core: "\uACF5\uD1B5",
23
+ rbac: "\uAD8C\uD55C"
24
+ };
25
+ var CATEGORY_ORDER = ["fi", "asset", "hr", "core", "rbac"];
26
+ var entityOf = (code) => {
27
+ const i = code.lastIndexOf(".");
28
+ return i > 0 ? code.slice(0, i) : code;
29
+ };
30
+ var operationOf = (code) => {
31
+ const i = code.lastIndexOf(".");
32
+ const op = i > 0 ? code.slice(i + 1) : "";
33
+ return OPERATIONS.some((o) => o.key === op) ? op : null;
34
+ };
35
+ function groupCatalog(catalog) {
36
+ const categories = /* @__PURE__ */ new Map();
37
+ for (const entry of catalog) {
38
+ if (!entry || typeof entry.code !== "string") continue;
39
+ const category = entry.category?.trim() || "\uAE30\uD0C0";
40
+ const entity = entityOf(entry.code);
41
+ const byEntity = categories.get(category) ?? /* @__PURE__ */ new Map();
42
+ categories.set(category, byEntity);
43
+ const row = byEntity.get(entity) ?? { entity, label: "", cells: {}, extras: [] };
44
+ byEntity.set(entity, row);
45
+ const op = operationOf(entry.code);
46
+ if (op) {
47
+ row.cells[op] = entry;
48
+ if (!row.label) row.label = entry.name.replace(/\s*(조회|생성|수정|삭제)\s*$/, "") || entity;
49
+ } else {
50
+ row.extras.push(entry);
51
+ if (!row.label) row.label = entry.name;
52
+ }
53
+ }
54
+ const order = (c) => {
55
+ const i = CATEGORY_ORDER.indexOf(c);
56
+ return i < 0 ? CATEGORY_ORDER.length : i;
57
+ };
58
+ return [...categories.entries()].sort((a, b) => order(a[0]) - order(b[0]) || a[0].localeCompare(b[0])).map(([category, byEntity]) => ({
59
+ category,
60
+ label: CATEGORY_LABELS[category] ?? category,
61
+ rows: [...byEntity.values()].sort((a, b) => a.entity.localeCompare(b.entity))
62
+ }));
63
+ }
64
+ function PermissionMatrixEditorImpl({
65
+ permissions,
66
+ value,
67
+ onChange,
68
+ sourceEndpoint,
69
+ disabled = false
70
+ }) {
71
+ const adapter = useSduiAdapter();
72
+ const api = hostFetchOf(adapter) ?? defaultAdapter.fetch;
73
+ const onChangeRef = useRef(onChange);
74
+ onChangeRef.current = onChange;
75
+ const seededFor = useRef(null);
76
+ useEffect(() => {
77
+ if (!sourceEndpoint || seededFor.current === sourceEndpoint) return;
78
+ seededFor.current = sourceEndpoint;
79
+ api(sourceEndpoint, { method: "GET" }).then((response) => {
80
+ if (seededFor.current !== sourceEndpoint) return;
81
+ const body = response;
82
+ const rows = Array.isArray(body?.permissions) ? body.permissions : [];
83
+ onChangeRef.current?.(
84
+ rows.flatMap((row) => {
85
+ if (typeof row !== "object" || row === null) return [];
86
+ const { code, scope } = row;
87
+ if (typeof code !== "string" || !code) return [];
88
+ return [{ code, scope: typeof scope === "string" ? scope : "all" }];
89
+ })
90
+ );
91
+ }).catch(() => {
92
+ });
93
+ }, [sourceEndpoint]);
94
+ const grants = useMemo(() => Array.isArray(value) ? value : [], [value]);
95
+ const catalog = useMemo(
96
+ () => Array.isArray(permissions) ? permissions : [],
97
+ [permissions]
98
+ );
99
+ const groups = useMemo(() => groupCatalog(catalog), [catalog]);
100
+ const granted = useMemo(() => new Set(grants.map((g) => g.code)), [grants]);
101
+ const scopeOf = useMemo(() => {
102
+ const map = /* @__PURE__ */ new Map();
103
+ for (const g of grants) {
104
+ const e = entityOf(g.code);
105
+ if (!map.has(e) && g.scope) map.set(e, g.scope);
106
+ }
107
+ return map;
108
+ }, [grants]);
109
+ const [closed, setClosed] = useState(/* @__PURE__ */ new Set());
110
+ const toggleCategory = (c) => setClosed((prev) => {
111
+ const next = new Set(prev);
112
+ if (next.has(c)) next.delete(c);
113
+ else next.add(c);
114
+ return next;
115
+ });
116
+ const emit = (nextGranted, nextScopes) => {
117
+ onChange?.(
118
+ [...nextGranted].sort().map((code) => ({
119
+ code,
120
+ scope: nextScopes.get(entityOf(code)) ?? "all"
121
+ }))
122
+ );
123
+ };
124
+ const toggleCode = (code, on) => {
125
+ const next = new Set(granted);
126
+ if (on) next.add(code);
127
+ else next.delete(code);
128
+ emit(next, scopeOf);
129
+ };
130
+ const setEntityScope = (entity, scope) => {
131
+ const next = new Map(scopeOf);
132
+ next.set(entity, scope);
133
+ emit(granted, next);
134
+ };
135
+ const toggleRow = (row, on) => {
136
+ const next = new Set(granted);
137
+ for (const op of OPERATIONS) {
138
+ const cell = row.cells[op.key];
139
+ if (!cell) continue;
140
+ if (on) next.add(cell.code);
141
+ else next.delete(cell.code);
142
+ }
143
+ for (const extra of row.extras) {
144
+ if (on) next.add(extra.code);
145
+ else next.delete(extra.code);
146
+ }
147
+ emit(next, scopeOf);
148
+ };
149
+ if (catalog.length === 0) {
150
+ return /* @__PURE__ */ jsx(
151
+ "div",
152
+ {
153
+ className: "wp-body-sm",
154
+ style: {
155
+ border: "var(--wp-border-w) dashed var(--wp-border-default)",
156
+ borderRadius: "var(--wp-radius-lg)",
157
+ padding: "var(--wp-space-4)",
158
+ textAlign: "center",
159
+ color: "var(--wp-text-muted)"
160
+ },
161
+ children: "\uAD8C\uD55C \uCE74\uD0C8\uB85C\uADF8\uAC00 \uBE44\uC5B4 \uC788\uC2B5\uB2C8\uB2E4 \u2014 \uD398\uC774\uC9C0\uC758 data \uC120\uC5B8(/permissions?limit=1000)\uC744 \uD655\uC778\uD558\uC138\uC694."
162
+ }
163
+ );
164
+ }
165
+ return /* @__PURE__ */ jsxs("div", { className: "wp-col", style: { gap: "var(--wp-space-2)" }, children: [
166
+ /* @__PURE__ */ jsxs("span", { className: "wp-caption", children: [
167
+ "\uAD8C\uD55C ",
168
+ catalog.length,
169
+ "\uC885 \uC911 ",
170
+ granted.size,
171
+ "\uAC1C \uBD80\uC5EC\uB428 \xB7 \uBC94\uC704\uB294 \uC5D4\uD2F0\uD2F0 \uB2E8\uC704\uB85C \uC801\uC6A9\uB429\uB2C8\uB2E4 (\uD300 < \uBCF8\uBD80 < \uC804\uCCB4)"
172
+ ] }),
173
+ /* @__PURE__ */ jsx(
174
+ "div",
175
+ {
176
+ style: {
177
+ position: "relative",
178
+ border: "var(--wp-border-w) solid var(--wp-border-default)",
179
+ borderRadius: "var(--wp-radius-lg)",
180
+ overflowY: "auto",
181
+ maxHeight: "min(46vh, 400px)",
182
+ minHeight: 160
183
+ },
184
+ children: groups.map((group) => {
185
+ const total = group.rows.reduce(
186
+ (a, r) => a + Object.keys(r.cells).length + r.extras.length,
187
+ 0
188
+ );
189
+ const on = group.rows.reduce(
190
+ (a, r) => a + OPERATIONS.filter((o) => r.cells[o.key] && granted.has(r.cells[o.key].code)).length + r.extras.filter((x) => granted.has(x.code)).length,
191
+ 0
192
+ );
193
+ const isClosed = closed.has(group.category);
194
+ return /* @__PURE__ */ jsxs("div", { children: [
195
+ /* @__PURE__ */ jsxs(
196
+ "button",
197
+ {
198
+ type: "button",
199
+ className: "wp-row",
200
+ onClick: () => toggleCategory(group.category),
201
+ style: {
202
+ position: "sticky",
203
+ top: 0,
204
+ zIndex: 1,
205
+ width: "100%",
206
+ alignItems: "center",
207
+ padding: "var(--wp-space-2) var(--wp-space-3)",
208
+ background: "var(--wp-surface-sunken)",
209
+ border: "none",
210
+ borderTop: "var(--wp-border-w) solid var(--wp-border-default)",
211
+ cursor: "pointer",
212
+ textAlign: "left"
213
+ },
214
+ "aria-expanded": !isClosed,
215
+ children: [
216
+ /* @__PURE__ */ jsx(Icon, { name: isClosed ? "chevron-right" : "chevron-down", size: 14 }),
217
+ /* @__PURE__ */ jsx("span", { className: "wp-label", style: { flex: 1 }, children: group.label }),
218
+ /* @__PURE__ */ jsxs(Badge, { tone: on > 0 ? "brand" : "neutral", children: [
219
+ on,
220
+ "/",
221
+ total
222
+ ] })
223
+ ]
224
+ }
225
+ ),
226
+ isClosed ? null : /* @__PURE__ */ jsxs("div", { className: "wp-col", style: { gap: 0 }, children: [
227
+ /* @__PURE__ */ jsxs(
228
+ "div",
229
+ {
230
+ className: "wp-row wp-caption",
231
+ style: {
232
+ alignItems: "center",
233
+ padding: "var(--wp-space-1) var(--wp-space-3)",
234
+ borderTop: "var(--wp-border-w) solid var(--wp-divider)",
235
+ color: "var(--wp-text-muted)"
236
+ },
237
+ children: [
238
+ /* @__PURE__ */ jsx("span", { style: { flex: 1.6 }, children: "\uC5D4\uD2F0\uD2F0" }),
239
+ OPERATIONS.map((op) => /* @__PURE__ */ jsx("span", { style: { flex: "none", width: 52, textAlign: "center" }, children: op.label }, op.key)),
240
+ /* @__PURE__ */ jsx("span", { style: { flex: "none", width: 96, textAlign: "center" }, children: "\uBC94\uC704" }),
241
+ /* @__PURE__ */ jsx("span", { style: { flex: "none", width: 60 } })
242
+ ]
243
+ }
244
+ ),
245
+ group.rows.map((row) => {
246
+ const rowCodes = [
247
+ ...OPERATIONS.flatMap(
248
+ (o) => row.cells[o.key] ? [row.cells[o.key].code] : []
249
+ ),
250
+ ...row.extras.map((x) => x.code)
251
+ ];
252
+ const allOn = rowCodes.length > 0 && rowCodes.every((c) => granted.has(c));
253
+ const anyOn = rowCodes.some((c) => granted.has(c));
254
+ return /* @__PURE__ */ jsxs(
255
+ "div",
256
+ {
257
+ className: "wp-row",
258
+ style: {
259
+ alignItems: "center",
260
+ padding: "var(--wp-space-1) var(--wp-space-3)",
261
+ borderTop: "var(--wp-border-w) solid var(--wp-divider)"
262
+ },
263
+ children: [
264
+ /* @__PURE__ */ jsxs("span", { className: "wp-body-sm", style: { flex: 1.6, minWidth: 0 }, children: [
265
+ row.label || row.entity,
266
+ /* @__PURE__ */ jsx(
267
+ "span",
268
+ {
269
+ className: "wp-caption",
270
+ style: {
271
+ marginLeft: "var(--wp-space-2)",
272
+ color: "var(--wp-text-muted)"
273
+ },
274
+ children: row.entity
275
+ }
276
+ )
277
+ ] }),
278
+ OPERATIONS.map((op) => {
279
+ const cell = row.cells[op.key];
280
+ return /* @__PURE__ */ jsx(
281
+ "span",
282
+ {
283
+ style: {
284
+ flex: "none",
285
+ width: 52,
286
+ display: "inline-flex",
287
+ justifyContent: "center"
288
+ },
289
+ children: cell ? /* @__PURE__ */ jsx(
290
+ Checkbox,
291
+ {
292
+ "aria-label": `${row.label || row.entity} ${op.label}`,
293
+ checked: granted.has(cell.code),
294
+ disabled,
295
+ onChange: (event) => toggleCode(cell.code, event.target.checked)
296
+ }
297
+ ) : /* @__PURE__ */ jsx("span", { className: "wp-caption", style: { color: "var(--wp-text-muted)" }, children: "\u2013" })
298
+ },
299
+ op.key
300
+ );
301
+ }),
302
+ /* @__PURE__ */ jsx("span", { style: { flex: "none", width: 96 }, children: /* @__PURE__ */ jsx(
303
+ Select,
304
+ {
305
+ "aria-label": `${row.label || row.entity} \uBC94\uC704`,
306
+ value: scopeOf.get(row.entity) ?? "all",
307
+ options: SCOPE_OPTIONS,
308
+ disabled: disabled || !anyOn,
309
+ onChange: (event) => setEntityScope(row.entity, event.target.value)
310
+ }
311
+ ) }),
312
+ /* @__PURE__ */ jsx("span", { style: { flex: "none", width: 60, textAlign: "right" }, children: /* @__PURE__ */ jsx(
313
+ Button,
314
+ {
315
+ type: "button",
316
+ size: "sm",
317
+ variant: "ghost",
318
+ disabled,
319
+ onClick: () => toggleRow(row, !allOn),
320
+ children: allOn ? "\uD574\uC81C" : "\uC804\uCCB4"
321
+ }
322
+ ) })
323
+ ]
324
+ },
325
+ row.entity
326
+ );
327
+ })
328
+ ] })
329
+ ] }, group.category);
330
+ })
331
+ }
332
+ )
333
+ ] });
334
+ }
335
+ var PermissionMatrixEditor = boxed(
336
+ PermissionMatrixEditorImpl,
337
+ "PermissionMatrixEditor"
338
+ );
339
+
340
+ export { PermissionMatrixEditor };
@@ -0,0 +1,333 @@
1
+ import { useSduiAdapter, hostFetchOf, defaultAdapter } from './chunk-DVOPZFQS.js';
2
+ import { Alert, Badge, Spinner, Button, Input, Checkbox } from './chunk-WIDDHR7L.js';
3
+ import { boxed } from './chunk-SAN4IX6N.js';
4
+ import { useMemo, useState, useRef, useCallback, useEffect } from 'react';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ var deptOf = (row) => row.department_name ?? row.department?.name ?? null;
8
+ function parseMembers(json) {
9
+ if (typeof json !== "object" || json === null) return [];
10
+ const obj = json;
11
+ const rows = Array.isArray(obj.employees) ? obj.employees : Array.isArray(obj.data) ? obj.data : [];
12
+ return rows.filter(
13
+ (row) => typeof row === "object" && row !== null && typeof row.id === "string"
14
+ );
15
+ }
16
+ var messageOf = (err, fallback) => err instanceof Error && err.message ? err.message : fallback;
17
+ var searchTextOf = (row) => [row.name, row.employee_number, deptOf(row), row.job_title, row.work_email].filter(Boolean).join(" ").toLowerCase();
18
+ var boxStyle = {
19
+ border: "var(--wp-border-w) solid var(--wp-border-default)",
20
+ borderRadius: "var(--wp-radius-lg)",
21
+ overflow: "hidden"
22
+ };
23
+ function RoleMemberPickerImpl({
24
+ catalogEndpoint = "/employees",
25
+ employees,
26
+ sourceEndpoint,
27
+ disabled = false
28
+ }) {
29
+ const adapter = useSduiAdapter();
30
+ const api = hostFetchOf(adapter) ?? defaultAdapter.fetch;
31
+ const base = useMemo(() => sourceEndpoint ? sourceEndpoint.split("?")[0] : null, [sourceEndpoint]);
32
+ const [members, setMembers] = useState(null);
33
+ const [membersLoading, setMembersLoading] = useState(false);
34
+ const [error, setError] = useState(null);
35
+ const [adding, setAdding] = useState(false);
36
+ const [search, setSearch] = useState("");
37
+ const [selected, setSelected] = useState([]);
38
+ const [saving, setSaving] = useState(false);
39
+ const [removingId, setRemovingId] = useState(null);
40
+ const requestSeq = useRef(0);
41
+ const fetchMembers = useCallback((endpoint) => {
42
+ const seq = ++requestSeq.current;
43
+ setMembersLoading(true);
44
+ api(endpoint, { method: "GET" }).then((response) => {
45
+ if (requestSeq.current !== seq) return;
46
+ setMembers(parseMembers(response));
47
+ }).catch((err) => {
48
+ if (requestSeq.current !== seq) return;
49
+ setMembers((prev) => prev ?? []);
50
+ if (!(err?.status === 503)) {
51
+ setError(messageOf(err, "\uC5ED\uD560\uC5D0 \uBD80\uC5EC\uB41C \uC0AC\uC6A9\uC790\uB97C \uBD88\uB7EC\uC624\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4."));
52
+ }
53
+ }).finally(() => {
54
+ if (requestSeq.current === seq) setMembersLoading(false);
55
+ });
56
+ }, []);
57
+ const seededFor = useRef(null);
58
+ useEffect(() => {
59
+ if (!sourceEndpoint || seededFor.current === sourceEndpoint) return;
60
+ seededFor.current = sourceEndpoint;
61
+ setAdding(false);
62
+ setSearch("");
63
+ setSelected([]);
64
+ setError(null);
65
+ fetchMembers(sourceEndpoint);
66
+ }, [sourceEndpoint, fetchMembers]);
67
+ const givenCatalog = useMemo(
68
+ () => Array.isArray(employees) ? employees.filter((row) => row && typeof row.id === "string") : [],
69
+ [employees]
70
+ );
71
+ const [fetchedCatalog, setFetchedCatalog] = useState(null);
72
+ useEffect(() => {
73
+ if (givenCatalog.length > 0 || fetchedCatalog !== null) return;
74
+ let alive = true;
75
+ (async () => {
76
+ const rows = [];
77
+ for (let page = 0; page < 10; page += 1) {
78
+ const response = await api(`${catalogEndpoint}?limit=500&offset=${rows.length}`, {
79
+ method: "GET"
80
+ });
81
+ const batch = Array.isArray(response?.data) ? response.data : [];
82
+ rows.push(...batch.filter((row) => row && typeof row.id === "string"));
83
+ const total = typeof response?.total === "number" ? response.total : rows.length;
84
+ if (batch.length === 0 || rows.length >= total) break;
85
+ }
86
+ if (alive) setFetchedCatalog(rows);
87
+ })().catch(() => {
88
+ if (alive) setFetchedCatalog([]);
89
+ });
90
+ return () => {
91
+ alive = false;
92
+ };
93
+ }, [givenCatalog, fetchedCatalog, api, catalogEndpoint]);
94
+ const catalog = givenCatalog.length > 0 ? givenCatalog : fetchedCatalog ?? [];
95
+ const catalogLoading = givenCatalog.length === 0 && fetchedCatalog === null;
96
+ const memberIds = useMemo(() => new Set((members ?? []).map((row) => row.id)), [members]);
97
+ const candidates = useMemo(() => {
98
+ const available = catalog.filter((row) => !memberIds.has(row.id));
99
+ const keyword = search.trim().toLowerCase();
100
+ if (!keyword) return available;
101
+ return available.filter((row) => searchTextOf(row).includes(keyword));
102
+ }, [catalog, memberIds, search]);
103
+ const selectedSet = useMemo(() => new Set(selected), [selected]);
104
+ const toggleSelected = (id, on) => {
105
+ setSelected(
106
+ (current) => on ? current.includes(id) ? current : [...current, id] : current.filter((item) => item !== id)
107
+ );
108
+ };
109
+ const addSelected = () => {
110
+ if (!base || selected.length === 0 || saving) return;
111
+ setSaving(true);
112
+ setError(null);
113
+ api(base, { method: "POST", body: { employees: selected } }).then((response) => {
114
+ setMembers(parseMembers(response));
115
+ setSelected([]);
116
+ setSearch("");
117
+ setAdding(false);
118
+ }).catch((err) => setError(messageOf(err, "\uC5ED\uD560 \uBD80\uC5EC\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."))).finally(() => setSaving(false));
119
+ };
120
+ const removeMember = (id) => {
121
+ if (!base || removingId) return;
122
+ setRemovingId(id);
123
+ setError(null);
124
+ api(`${base}/${encodeURIComponent(id)}`, { method: "DELETE" }).then((response) => setMembers(parseMembers(response))).catch((err) => setError(messageOf(err, "\uC5ED\uD560 \uD574\uC81C\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."))).finally(() => setRemovingId(null));
125
+ };
126
+ const memberRows = members ?? [];
127
+ const busy = disabled || membersLoading;
128
+ return /* @__PURE__ */ jsxs("div", { className: "wp-col", style: { gap: "var(--wp-space-3)" }, children: [
129
+ error ? /* @__PURE__ */ jsx(Alert, { tone: "danger", onClose: () => setError(null), children: error }) : null,
130
+ /* @__PURE__ */ jsxs("div", { className: "wp-row", style: { alignItems: "center", gap: "var(--wp-space-2)" }, children: [
131
+ /* @__PURE__ */ jsxs(Badge, { tone: memberRows.length > 0 ? "brand" : "neutral", children: [
132
+ memberRows.length,
133
+ "\uBA85"
134
+ ] }),
135
+ /* @__PURE__ */ jsxs("span", { className: "wp-body-sm", style: { flex: 1 }, children: [
136
+ "\uC5D0\uAC8C \uBD80\uC5EC\uB428",
137
+ membersLoading ? /* @__PURE__ */ jsx(Spinner, { size: "sm", label: "\uBD88\uB7EC\uC624\uB294 \uC911", style: { marginLeft: "var(--wp-space-2)" } }) : null
138
+ ] }),
139
+ /* @__PURE__ */ jsx(
140
+ Button,
141
+ {
142
+ type: "button",
143
+ size: "sm",
144
+ variant: "secondary",
145
+ icon: "refresh-ccw",
146
+ disabled: !sourceEndpoint || membersLoading,
147
+ onClick: () => sourceEndpoint && fetchMembers(sourceEndpoint),
148
+ children: "\uC0C8\uB85C\uACE0\uCE68"
149
+ }
150
+ ),
151
+ /* @__PURE__ */ jsx(
152
+ Button,
153
+ {
154
+ type: "button",
155
+ size: "sm",
156
+ variant: "primary",
157
+ icon: "user-plus",
158
+ disabled: busy || !base,
159
+ onClick: () => {
160
+ setSearch("");
161
+ setSelected([]);
162
+ setAdding((current) => !current);
163
+ },
164
+ children: "\uC0AC\uC6A9\uC790 \uCD94\uAC00"
165
+ }
166
+ )
167
+ ] }),
168
+ adding ? /* @__PURE__ */ jsxs(
169
+ "div",
170
+ {
171
+ className: "wp-col",
172
+ style: {
173
+ gap: "var(--wp-space-2)",
174
+ border: "var(--wp-border-w) solid var(--wp-border-brand)",
175
+ borderRadius: "var(--wp-radius-lg)",
176
+ padding: "var(--wp-space-3)"
177
+ },
178
+ children: [
179
+ /* @__PURE__ */ jsx(
180
+ Input,
181
+ {
182
+ icon: "search",
183
+ size: "sm",
184
+ value: search,
185
+ placeholder: "\uC774\uB984, \uC0AC\uBC88, \uBD80\uC11C, \uC9C1\uCC45, \uC774\uBA54\uC77C \uAC80\uC0C9",
186
+ onChange: (event) => setSearch(event.target.value)
187
+ }
188
+ ),
189
+ /* @__PURE__ */ jsx("div", { style: { ...boxStyle, maxHeight: 280, overflowY: "auto" }, children: catalogLoading ? /* @__PURE__ */ jsx("div", { className: "wp-row", style: { justifyContent: "center", padding: "var(--wp-space-4)" }, children: /* @__PURE__ */ jsx(Spinner, { size: "sm", label: "\uC9C1\uC6D0\uC744 \uBD88\uB7EC\uC624\uB294 \uC911" }) }) : candidates.length === 0 ? /* @__PURE__ */ jsx(
190
+ "div",
191
+ {
192
+ className: "wp-body-sm",
193
+ style: { padding: "var(--wp-space-4)", textAlign: "center", color: "var(--wp-text-muted)" },
194
+ children: "\uCD94\uAC00\uD560 \uC218 \uC788\uB294 \uC0AC\uC6A9\uC790\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
195
+ }
196
+ ) : candidates.map((row, index) => /* @__PURE__ */ jsxs(
197
+ "label",
198
+ {
199
+ className: "wp-row",
200
+ style: {
201
+ alignItems: "center",
202
+ gap: "var(--wp-space-2)",
203
+ padding: "var(--wp-space-2) var(--wp-space-3)",
204
+ borderTop: index > 0 ? "var(--wp-border-w) solid var(--wp-divider)" : void 0,
205
+ cursor: "pointer"
206
+ },
207
+ children: [
208
+ /* @__PURE__ */ jsx(
209
+ Checkbox,
210
+ {
211
+ checked: selectedSet.has(row.id),
212
+ disabled: busy || saving,
213
+ onChange: (event) => toggleSelected(row.id, event.target.checked)
214
+ }
215
+ ),
216
+ /* @__PURE__ */ jsxs("span", { className: "wp-col", style: { gap: 0, minWidth: 0 }, children: [
217
+ /* @__PURE__ */ jsxs("span", { className: "wp-body-sm", style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
218
+ row.name || row.id,
219
+ row.job_title ? ` \xB7 ${row.job_title}` : ""
220
+ ] }),
221
+ /* @__PURE__ */ jsxs("span", { className: "wp-caption", style: { color: "var(--wp-text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
222
+ deptOf(row) || "-",
223
+ row.employee_number ? ` \xB7 ${row.employee_number}` : "",
224
+ row.work_email ? ` \xB7 ${row.work_email}` : ""
225
+ ] })
226
+ ] })
227
+ ]
228
+ },
229
+ row.id
230
+ )) }),
231
+ /* @__PURE__ */ jsxs("div", { className: "wp-row", style: { alignItems: "center", gap: "var(--wp-space-2)" }, children: [
232
+ /* @__PURE__ */ jsxs("span", { className: "wp-caption", style: { flex: 1, color: "var(--wp-text-muted)" }, children: [
233
+ selected.length,
234
+ "\uBA85 \uC120\uD0DD\uB428"
235
+ ] }),
236
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", disabled: saving, onClick: () => setAdding(false), children: "\uCDE8\uC18C" }),
237
+ /* @__PURE__ */ jsx(
238
+ Button,
239
+ {
240
+ type: "button",
241
+ size: "sm",
242
+ variant: "primary",
243
+ icon: "user-plus",
244
+ loading: saving,
245
+ disabled: busy || selected.length === 0,
246
+ onClick: addSelected,
247
+ children: "\uCD94\uAC00"
248
+ }
249
+ )
250
+ ] })
251
+ ]
252
+ }
253
+ ) : null,
254
+ /* @__PURE__ */ jsxs("div", { style: boxStyle, children: [
255
+ /* @__PURE__ */ jsxs(
256
+ "div",
257
+ {
258
+ className: "wp-row wp-caption",
259
+ style: {
260
+ alignItems: "center",
261
+ padding: "var(--wp-space-1) var(--wp-space-3)",
262
+ background: "var(--wp-surface-sunken)",
263
+ color: "var(--wp-text-muted)"
264
+ },
265
+ children: [
266
+ /* @__PURE__ */ jsx("span", { style: { flex: 1.4 }, children: "\uC0AC\uC6A9\uC790" }),
267
+ /* @__PURE__ */ jsx("span", { style: { flex: 1 }, children: "\uBD80\uC11C" }),
268
+ /* @__PURE__ */ jsx("span", { style: { flex: 1.4 }, children: "\uC774\uBA54\uC77C" }),
269
+ /* @__PURE__ */ jsx("span", { style: { flex: "none", width: 64 } })
270
+ ]
271
+ }
272
+ ),
273
+ memberRows.length === 0 ? /* @__PURE__ */ jsx(
274
+ "div",
275
+ {
276
+ className: "wp-body-sm",
277
+ style: {
278
+ padding: "var(--wp-space-5) var(--wp-space-3)",
279
+ textAlign: "center",
280
+ color: "var(--wp-text-muted)",
281
+ borderTop: "var(--wp-border-w) solid var(--wp-divider)"
282
+ },
283
+ children: membersLoading ? "\uBD88\uB7EC\uC624\uB294 \uC911..." : "\uC774 \uC5ED\uD560\uC744 \uBD80\uC5EC\uBC1B\uC740 \uC0AC\uC6A9\uC790\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."
284
+ }
285
+ ) : memberRows.map((row) => /* @__PURE__ */ jsxs(
286
+ "div",
287
+ {
288
+ className: "wp-row",
289
+ style: {
290
+ alignItems: "center",
291
+ padding: "var(--wp-space-2) var(--wp-space-3)",
292
+ borderTop: "var(--wp-border-w) solid var(--wp-divider)"
293
+ },
294
+ children: [
295
+ /* @__PURE__ */ jsxs("span", { className: "wp-col", style: { flex: 1.4, gap: 0, minWidth: 0 }, children: [
296
+ /* @__PURE__ */ jsx("span", { className: "wp-body-sm", children: row.name || row.id }),
297
+ /* @__PURE__ */ jsxs("span", { className: "wp-caption", style: { color: "var(--wp-text-muted)" }, children: [
298
+ row.employee_number || "-",
299
+ row.job_title ? ` \xB7 ${row.job_title}` : ""
300
+ ] })
301
+ ] }),
302
+ /* @__PURE__ */ jsx("span", { className: "wp-body-sm", style: { flex: 1, minWidth: 0, color: "var(--wp-text-muted)" }, children: deptOf(row) || "-" }),
303
+ /* @__PURE__ */ jsx(
304
+ "span",
305
+ {
306
+ className: "wp-body-sm",
307
+ style: { flex: 1.4, minWidth: 0, color: "var(--wp-text-muted)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
308
+ children: row.work_email || "-"
309
+ }
310
+ ),
311
+ /* @__PURE__ */ jsx("span", { style: { flex: "none", width: 64, textAlign: "right" }, children: /* @__PURE__ */ jsx(
312
+ Button,
313
+ {
314
+ type: "button",
315
+ size: "sm",
316
+ variant: "ghost",
317
+ icon: "trash-2",
318
+ loading: removingId === row.id,
319
+ disabled: busy || removingId !== null && removingId !== row.id,
320
+ onClick: () => removeMember(row.id),
321
+ children: "\uD574\uC81C"
322
+ }
323
+ ) })
324
+ ]
325
+ },
326
+ row.id
327
+ ))
328
+ ] })
329
+ ] });
330
+ }
331
+ var RoleMemberPicker = boxed(RoleMemberPickerImpl, "RoleMemberPicker");
332
+
333
+ export { RoleMemberPicker };