@loafacto/ui 0.1.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/dist/index.js ADDED
@@ -0,0 +1,729 @@
1
+ import { defineComponent, ref, computed, watch, onBeforeUnmount, openBlock, createElementBlock, normalizeStyle, createCommentVNode, createElementVNode, toDisplayString, Fragment, renderList, normalizeClass, renderSlot, onUnmounted, createBlock, Teleport, createVNode, TransitionGroup, withCtx, unref, withModifiers, Transition } from "vue";
2
+ import { defineStore } from "pinia";
3
+ const _hoisted_1$3 = { class: "lf-shell" };
4
+ const _hoisted_2$2 = { class: "lf-topbar" };
5
+ const _hoisted_3$2 = { class: "lf-topbar__inner" };
6
+ const _hoisted_4$2 = ["href"];
7
+ const _hoisted_5$2 = ["src"];
8
+ const _hoisted_6$2 = {
9
+ key: 1,
10
+ class: "lf-brand__mark",
11
+ "aria-hidden": "true"
12
+ };
13
+ const _hoisted_7$2 = { class: "lf-brand__name" };
14
+ const _hoisted_8$1 = ["aria-expanded"];
15
+ const _hoisted_9 = {
16
+ key: 0,
17
+ class: "lf-switcher__menu",
18
+ role: "menu"
19
+ };
20
+ const _hoisted_10 = ["href", "onClick"];
21
+ const _hoisted_11 = {
22
+ key: 0,
23
+ class: "lf-switcher__icon",
24
+ viewBox: "0 0 24 24",
25
+ "aria-hidden": "true"
26
+ };
27
+ const _hoisted_12 = ["d"];
28
+ const _hoisted_13 = { class: "lf-switcher__label" };
29
+ const _hoisted_14 = {
30
+ key: 1,
31
+ class: "admin-badge admin-badge--gray"
32
+ };
33
+ const _hoisted_15 = {
34
+ key: 1,
35
+ class: "lf-shortcuts",
36
+ "aria-label": "바로가기"
37
+ };
38
+ const _hoisted_16 = ["href", "title", "aria-label"];
39
+ const _hoisted_17 = {
40
+ viewBox: "0 0 24 24",
41
+ "aria-hidden": "true"
42
+ };
43
+ const _hoisted_18 = ["d"];
44
+ const _hoisted_19 = {
45
+ key: 2,
46
+ class: "lf-user"
47
+ };
48
+ const _hoisted_20 = ["src"];
49
+ const _hoisted_21 = {
50
+ key: 1,
51
+ class: "lf-user__avatar lf-user__avatar--fallback"
52
+ };
53
+ const _hoisted_22 = { class: "lf-user__name" };
54
+ const _hoisted_23 = { class: "lf-content" };
55
+ const _hoisted_24 = { class: "site-footer" };
56
+ const _hoisted_25 = { class: "site-footer-inner" };
57
+ const _hoisted_26 = { class: "site-footer-copy" };
58
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
59
+ __name: "AppShell",
60
+ props: {
61
+ services: { default: () => [] },
62
+ currentServiceId: {},
63
+ shortcuts: { default: () => [] },
64
+ brandName: { default: "Loafacto" },
65
+ brandHref: { default: "/" },
66
+ logoUrl: {},
67
+ user: { default: null },
68
+ backgroundColor: {},
69
+ backgroundImage: {},
70
+ year: { default: () => (/* @__PURE__ */ new Date()).getFullYear() }
71
+ },
72
+ emits: ["navigate"],
73
+ setup(__props, { emit: __emit }) {
74
+ const props = __props;
75
+ const emit = __emit;
76
+ const switcherOpen = ref(false);
77
+ const switcherEl = ref(null);
78
+ const currentService = computed(
79
+ () => props.services.find((s) => s.id === props.currentServiceId)
80
+ );
81
+ const userInitial = computed(() => {
82
+ var _a, _b;
83
+ return ((_b = (_a = props.user) == null ? void 0 : _a.displayName) == null ? void 0 : _b.trim().charAt(0).toUpperCase()) || "?";
84
+ });
85
+ function onNavigate(event, path, service) {
86
+ emit("navigate", { path, event, service });
87
+ }
88
+ function onServiceClick(event, svc) {
89
+ if (svc.comingSoon) {
90
+ event.preventDefault();
91
+ return;
92
+ }
93
+ switcherOpen.value = false;
94
+ onNavigate(event, svc.path, svc);
95
+ }
96
+ function onDocumentPointerDown(e) {
97
+ var _a;
98
+ if (!((_a = switcherEl.value) == null ? void 0 : _a.contains(e.target))) switcherOpen.value = false;
99
+ }
100
+ function onDocumentKeydown(e) {
101
+ if (e.key === "Escape") switcherOpen.value = false;
102
+ }
103
+ watch(switcherOpen, (open) => {
104
+ if (open) {
105
+ document.addEventListener("pointerdown", onDocumentPointerDown);
106
+ document.addEventListener("keydown", onDocumentKeydown);
107
+ } else {
108
+ document.removeEventListener("pointerdown", onDocumentPointerDown);
109
+ document.removeEventListener("keydown", onDocumentKeydown);
110
+ }
111
+ });
112
+ onBeforeUnmount(() => {
113
+ document.removeEventListener("pointerdown", onDocumentPointerDown);
114
+ document.removeEventListener("keydown", onDocumentKeydown);
115
+ });
116
+ return (_ctx, _cache) => {
117
+ var _a;
118
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
119
+ __props.backgroundColor || __props.backgroundImage ? (openBlock(), createElementBlock("div", {
120
+ key: 0,
121
+ class: "app-background-layer",
122
+ style: normalizeStyle({
123
+ backgroundColor: __props.backgroundColor || void 0,
124
+ backgroundImage: __props.backgroundImage ? `url(${__props.backgroundImage})` : void 0
125
+ })
126
+ }, null, 4)) : createCommentVNode("", true),
127
+ createElementVNode("header", _hoisted_2$2, [
128
+ createElementVNode("div", _hoisted_3$2, [
129
+ createElementVNode("a", {
130
+ class: "lf-brand",
131
+ href: __props.brandHref,
132
+ onClick: _cache[0] || (_cache[0] = ($event) => onNavigate($event, __props.brandHref))
133
+ }, [
134
+ __props.logoUrl ? (openBlock(), createElementBlock("img", {
135
+ key: 0,
136
+ src: __props.logoUrl,
137
+ alt: "",
138
+ class: "lf-brand__logo"
139
+ }, null, 8, _hoisted_5$2)) : (openBlock(), createElementBlock("span", _hoisted_6$2, toDisplayString(__props.brandName.charAt(0)), 1)),
140
+ createElementVNode("span", _hoisted_7$2, toDisplayString(__props.brandName), 1)
141
+ ], 8, _hoisted_4$2),
142
+ __props.services.length ? (openBlock(), createElementBlock("div", {
143
+ key: 0,
144
+ ref_key: "switcherEl",
145
+ ref: switcherEl,
146
+ class: "lf-switcher"
147
+ }, [
148
+ createElementVNode("button", {
149
+ type: "button",
150
+ class: "lf-switcher__trigger",
151
+ "aria-expanded": switcherOpen.value,
152
+ "aria-haspopup": "menu",
153
+ onClick: _cache[1] || (_cache[1] = ($event) => switcherOpen.value = !switcherOpen.value)
154
+ }, [
155
+ createElementVNode("span", null, toDisplayString(((_a = currentService.value) == null ? void 0 : _a.name) ?? "서비스"), 1),
156
+ _cache[2] || (_cache[2] = createElementVNode("svg", {
157
+ class: "lf-switcher__caret",
158
+ viewBox: "0 0 24 24",
159
+ "aria-hidden": "true"
160
+ }, [
161
+ createElementVNode("path", {
162
+ d: "M7 10l5 5 5-5z",
163
+ fill: "currentColor"
164
+ })
165
+ ], -1))
166
+ ], 8, _hoisted_8$1),
167
+ switcherOpen.value ? (openBlock(), createElementBlock("div", _hoisted_9, [
168
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.services, (svc) => {
169
+ return openBlock(), createElementBlock("a", {
170
+ key: svc.id,
171
+ class: normalizeClass(["lf-switcher__item", {
172
+ "lf-switcher__item--active": svc.id === __props.currentServiceId,
173
+ "lf-switcher__item--disabled": svc.comingSoon
174
+ }]),
175
+ href: svc.comingSoon ? void 0 : svc.path,
176
+ role: "menuitem",
177
+ onClick: ($event) => onServiceClick($event, svc)
178
+ }, [
179
+ svc.iconPath ? (openBlock(), createElementBlock("svg", _hoisted_11, [
180
+ createElementVNode("path", {
181
+ d: svc.iconPath,
182
+ fill: "currentColor"
183
+ }, null, 8, _hoisted_12)
184
+ ])) : createCommentVNode("", true),
185
+ createElementVNode("span", _hoisted_13, toDisplayString(svc.name), 1),
186
+ svc.comingSoon ? (openBlock(), createElementBlock("span", _hoisted_14, "준비 중")) : createCommentVNode("", true)
187
+ ], 10, _hoisted_10);
188
+ }), 128))
189
+ ])) : createCommentVNode("", true)
190
+ ], 512)) : createCommentVNode("", true),
191
+ _cache[3] || (_cache[3] = createElementVNode("div", { class: "lf-topbar__spacer" }, null, -1)),
192
+ __props.shortcuts.length ? (openBlock(), createElementBlock("nav", _hoisted_15, [
193
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.shortcuts, (s) => {
194
+ return openBlock(), createElementBlock("a", {
195
+ key: s.id,
196
+ class: "lf-shortcut",
197
+ href: s.href,
198
+ target: "_blank",
199
+ rel: "noopener noreferrer",
200
+ title: s.label,
201
+ "aria-label": `${s.label} (새 탭에서 열림)`
202
+ }, [
203
+ (openBlock(), createElementBlock("svg", _hoisted_17, [
204
+ createElementVNode("path", {
205
+ d: s.iconPath,
206
+ fill: "currentColor"
207
+ }, null, 8, _hoisted_18)
208
+ ]))
209
+ ], 8, _hoisted_16);
210
+ }), 128))
211
+ ])) : createCommentVNode("", true),
212
+ renderSlot(_ctx.$slots, "actions", {}, void 0, true),
213
+ __props.user ? (openBlock(), createElementBlock("div", _hoisted_19, [
214
+ __props.user.avatarUrl ? (openBlock(), createElementBlock("img", {
215
+ key: 0,
216
+ src: __props.user.avatarUrl,
217
+ alt: "",
218
+ class: "lf-user__avatar"
219
+ }, null, 8, _hoisted_20)) : (openBlock(), createElementBlock("span", _hoisted_21, toDisplayString(userInitial.value), 1)),
220
+ createElementVNode("span", _hoisted_22, toDisplayString(__props.user.displayName), 1),
221
+ renderSlot(_ctx.$slots, "user-menu", {}, void 0, true)
222
+ ])) : renderSlot(_ctx.$slots, "auth-actions", {}, void 0, true, 3)
223
+ ])
224
+ ]),
225
+ createElementVNode("main", _hoisted_23, [
226
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
227
+ ]),
228
+ createElementVNode("footer", _hoisted_24, [
229
+ createElementVNode("div", _hoisted_25, [
230
+ renderSlot(_ctx.$slots, "footer", {}, () => [
231
+ createElementVNode("p", _hoisted_26, "© " + toDisplayString(__props.year) + " Loafacto", 1)
232
+ ], true)
233
+ ])
234
+ ])
235
+ ]);
236
+ };
237
+ }
238
+ });
239
+ const _export_sfc = (sfc, props) => {
240
+ const target = sfc.__vccOpts || sfc;
241
+ for (const [key, val] of props) {
242
+ target[key] = val;
243
+ }
244
+ return target;
245
+ };
246
+ const AppShell = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-92b654c7"]]);
247
+ function generateId() {
248
+ return `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
249
+ }
250
+ const useToastStore = defineStore("toast", () => {
251
+ const items = ref([]);
252
+ function add(message, type = "info", duration = type === "error" ? 5e3 : 3e3) {
253
+ const id = generateId();
254
+ items.value.push({
255
+ id,
256
+ type,
257
+ message,
258
+ duration,
259
+ createdAt: Date.now()
260
+ });
261
+ return id;
262
+ }
263
+ function remove(id) {
264
+ items.value = items.value.filter((item) => item.id !== id);
265
+ }
266
+ function success(message, duration) {
267
+ return add(message, "success", duration);
268
+ }
269
+ function error(message, duration) {
270
+ return add(message, "error", duration);
271
+ }
272
+ function info(message, duration) {
273
+ return add(message, "info", duration);
274
+ }
275
+ function warning(message, duration) {
276
+ return add(message, "warning", duration);
277
+ }
278
+ return { items, add, remove, success, error, info, warning };
279
+ });
280
+ const _hoisted_1$2 = {
281
+ class: "toast-container",
282
+ role: "region",
283
+ "aria-label": "알림"
284
+ };
285
+ const _hoisted_2$1 = ["onClick"];
286
+ const _hoisted_3$1 = {
287
+ class: "toast-icon",
288
+ viewBox: "0 0 24 24",
289
+ "aria-hidden": "true"
290
+ };
291
+ const _hoisted_4$1 = ["d"];
292
+ const _hoisted_5$1 = { class: "toast-message" };
293
+ const _hoisted_6$1 = ["onClick"];
294
+ const _hoisted_7$1 = {
295
+ viewBox: "0 0 24 24",
296
+ "aria-hidden": "true"
297
+ };
298
+ const _hoisted_8 = ["d"];
299
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
300
+ __name: "AppToast",
301
+ setup(__props) {
302
+ const toastStore = useToastStore();
303
+ const timers = /* @__PURE__ */ new Map();
304
+ const ICON_PATHS = {
305
+ success: "M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-1.2 14.6L6.6 12.4 8 11l2.8 2.8L16 8.6 17.4 10l-6.6 6.6z",
306
+ error: "M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",
307
+ warning: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z",
308
+ info: "M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z",
309
+ close: "M19 6.4 17.6 5 12 10.6 6.4 5 5 6.4 10.6 12 5 17.6 6.4 19l5.6-5.6 5.6 5.6 1.4-1.4-5.6-5.6z"
310
+ };
311
+ watch(
312
+ () => toastStore.items,
313
+ (items) => {
314
+ items.forEach((item) => {
315
+ if (timers.has(item.id)) return;
316
+ const t = setTimeout(() => {
317
+ toastStore.remove(item.id);
318
+ timers.delete(item.id);
319
+ }, item.duration);
320
+ timers.set(item.id, t);
321
+ });
322
+ },
323
+ { immediate: true, deep: true }
324
+ );
325
+ onUnmounted(() => {
326
+ timers.forEach(clearTimeout);
327
+ timers.clear();
328
+ });
329
+ return (_ctx, _cache) => {
330
+ return openBlock(), createBlock(Teleport, { to: "body" }, [
331
+ createElementVNode("div", _hoisted_1$2, [
332
+ createVNode(TransitionGroup, { name: "toast" }, {
333
+ default: withCtx(() => [
334
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(toastStore).items, (item) => {
335
+ return openBlock(), createElementBlock("div", {
336
+ key: item.id,
337
+ class: normalizeClass(["toast-item", `toast-item--${item.type}`]),
338
+ role: "alert",
339
+ onClick: ($event) => unref(toastStore).remove(item.id)
340
+ }, [
341
+ (openBlock(), createElementBlock("svg", _hoisted_3$1, [
342
+ createElementVNode("path", {
343
+ d: ICON_PATHS[item.type],
344
+ fill: "currentColor"
345
+ }, null, 8, _hoisted_4$1)
346
+ ])),
347
+ createElementVNode("span", _hoisted_5$1, toDisplayString(item.message), 1),
348
+ createElementVNode("button", {
349
+ type: "button",
350
+ class: "toast-close",
351
+ "aria-label": "닫기",
352
+ onClick: withModifiers(($event) => unref(toastStore).remove(item.id), ["stop"])
353
+ }, [
354
+ (openBlock(), createElementBlock("svg", _hoisted_7$1, [
355
+ createElementVNode("path", {
356
+ d: ICON_PATHS.close,
357
+ fill: "currentColor"
358
+ }, null, 8, _hoisted_8)
359
+ ]))
360
+ ], 8, _hoisted_6$1)
361
+ ], 10, _hoisted_2$1);
362
+ }), 128))
363
+ ]),
364
+ _: 1
365
+ })
366
+ ])
367
+ ]);
368
+ };
369
+ }
370
+ });
371
+ const AppToast = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-284b8ae8"]]);
372
+ const useLoadingStore = defineStore("loading", () => {
373
+ const count = ref(0);
374
+ const loading = computed(() => count.value > 0);
375
+ function start() {
376
+ count.value += 1;
377
+ }
378
+ function stop() {
379
+ if (count.value > 0) count.value -= 1;
380
+ }
381
+ async function withLoading(fn) {
382
+ start();
383
+ try {
384
+ return await fn();
385
+ } finally {
386
+ stop();
387
+ }
388
+ }
389
+ return { loading, count, start, stop, withLoading };
390
+ });
391
+ const _hoisted_1$1 = {
392
+ key: 0,
393
+ class: "loading-overlay",
394
+ role: "status",
395
+ "aria-live": "polite",
396
+ "aria-label": "로딩 중"
397
+ };
398
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
399
+ __name: "AppLoadingOverlay",
400
+ setup(__props) {
401
+ const loadingStore = useLoadingStore();
402
+ return (_ctx, _cache) => {
403
+ return openBlock(), createBlock(Teleport, { to: "body" }, [
404
+ createVNode(Transition, { name: "fade" }, {
405
+ default: withCtx(() => [
406
+ unref(loadingStore).loading ? (openBlock(), createElementBlock("div", _hoisted_1$1, [..._cache[0] || (_cache[0] = [
407
+ createElementVNode("div", {
408
+ class: "loading-spinner",
409
+ "aria-hidden": "true"
410
+ }, null, -1)
411
+ ])])) : createCommentVNode("", true)
412
+ ]),
413
+ _: 1
414
+ })
415
+ ]);
416
+ };
417
+ }
418
+ });
419
+ const AppLoadingOverlay = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-cce3ea3e"]]);
420
+ const useConfirmStore = defineStore("confirm", () => {
421
+ const open = ref(false);
422
+ const title = ref("확인");
423
+ const message = ref("");
424
+ const confirmText = ref("확인");
425
+ const cancelText = ref("취소");
426
+ const danger = ref(false);
427
+ let resolver = null;
428
+ function ask(opts) {
429
+ title.value = opts.title ?? "확인";
430
+ message.value = opts.message;
431
+ confirmText.value = opts.confirmText ?? "확인";
432
+ cancelText.value = opts.cancelText ?? "취소";
433
+ danger.value = opts.danger ?? false;
434
+ open.value = true;
435
+ return new Promise((resolve2) => {
436
+ resolver = resolve2;
437
+ });
438
+ }
439
+ function resolve(v) {
440
+ open.value = false;
441
+ resolver == null ? void 0 : resolver(v);
442
+ resolver = null;
443
+ }
444
+ return { open, title, message, confirmText, cancelText, danger, ask, resolve };
445
+ });
446
+ const _hoisted_1 = {
447
+ key: 0,
448
+ class: "app-confirm-backdrop"
449
+ };
450
+ const _hoisted_2 = {
451
+ class: "app-confirm",
452
+ role: "dialog",
453
+ "aria-modal": "true"
454
+ };
455
+ const _hoisted_3 = { class: "app-confirm__header" };
456
+ const _hoisted_4 = { class: "app-confirm__title" };
457
+ const _hoisted_5 = { class: "app-confirm__body" };
458
+ const _hoisted_6 = { class: "app-confirm__message" };
459
+ const _hoisted_7 = { class: "app-confirm__actions" };
460
+ const _sfc_main = /* @__PURE__ */ defineComponent({
461
+ __name: "AppConfirmModal",
462
+ setup(__props) {
463
+ const store = useConfirmStore();
464
+ return (_ctx, _cache) => {
465
+ return openBlock(), createBlock(Teleport, { to: "body" }, [
466
+ createVNode(Transition, { name: "app-confirm-fade" }, {
467
+ default: withCtx(() => [
468
+ unref(store).open ? (openBlock(), createElementBlock("div", _hoisted_1, [
469
+ createElementVNode("div", _hoisted_2, [
470
+ createElementVNode("div", _hoisted_3, [
471
+ createElementVNode("h3", _hoisted_4, toDisplayString(unref(store).title), 1)
472
+ ]),
473
+ createElementVNode("div", _hoisted_5, [
474
+ createElementVNode("p", _hoisted_6, toDisplayString(unref(store).message), 1)
475
+ ]),
476
+ createElementVNode("div", _hoisted_7, [
477
+ createElementVNode("button", {
478
+ type: "button",
479
+ class: "app-confirm__btn app-confirm__btn--ghost",
480
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(store).resolve(false))
481
+ }, toDisplayString(unref(store).cancelText), 1),
482
+ createElementVNode("button", {
483
+ type: "button",
484
+ class: normalizeClass(["app-confirm__btn", unref(store).danger ? "app-confirm__btn--danger" : "app-confirm__btn--primary"]),
485
+ onClick: _cache[1] || (_cache[1] = ($event) => unref(store).resolve(true))
486
+ }, toDisplayString(unref(store).confirmText), 3)
487
+ ])
488
+ ])
489
+ ])) : createCommentVNode("", true)
490
+ ]),
491
+ _: 1
492
+ })
493
+ ]);
494
+ };
495
+ }
496
+ });
497
+ const AppConfirmModal = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-26427ddf"]]);
498
+ function useToast() {
499
+ const store = useToastStore();
500
+ return {
501
+ success: store.success,
502
+ error: store.error,
503
+ info: store.info,
504
+ warning: store.warning,
505
+ add: store.add
506
+ };
507
+ }
508
+ function useConfirm() {
509
+ const store = useConfirmStore();
510
+ return (opts) => store.ask(opts);
511
+ }
512
+ function hexToRgb(hex) {
513
+ const clean = hex.replace("#", "");
514
+ if (clean.length === 3) {
515
+ const r = parseInt(clean[0] + clean[0], 16);
516
+ const g = parseInt(clean[1] + clean[1], 16);
517
+ const b = parseInt(clean[2] + clean[2], 16);
518
+ return [r, g, b];
519
+ }
520
+ return [
521
+ parseInt(clean.slice(0, 2), 16),
522
+ parseInt(clean.slice(2, 4), 16),
523
+ parseInt(clean.slice(4, 6), 16)
524
+ ];
525
+ }
526
+ function parseRgba(color) {
527
+ const m = color.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/);
528
+ if (!m) return null;
529
+ return [parseInt(m[1]), parseInt(m[2]), parseInt(m[3])];
530
+ }
531
+ function colorToRgb(color) {
532
+ if (color.startsWith("#")) return hexToRgb(color);
533
+ const parsed = parseRgba(color);
534
+ return parsed ?? [0, 0, 0];
535
+ }
536
+ function luminance(r, g, b) {
537
+ const [rs, gs, bs] = [r, g, b].map((c) => {
538
+ const s = c / 255;
539
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
540
+ });
541
+ return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
542
+ }
543
+ function contrastRatio(l1, l2) {
544
+ const lighter = Math.max(l1, l2);
545
+ const darker = Math.min(l1, l2);
546
+ return (lighter + 0.05) / (darker + 0.05);
547
+ }
548
+ function accessibleText(bgLum, light, dark) {
549
+ const lightLum = 0.9505;
550
+ const darkLum = 88e-4;
551
+ const crLight = contrastRatio(bgLum, lightLum);
552
+ const crDark = contrastRatio(bgLum, darkLum);
553
+ return crDark >= crLight ? dark : light;
554
+ }
555
+ function surfaceFromBg(bg, amount = 0.08) {
556
+ const [r, g, b] = colorToRgb(bg);
557
+ const isLight = luminance(r, g, b) > 0.35;
558
+ const a = isLight ? Math.min(amount * 5, 0.5) : amount;
559
+ const target = 255;
560
+ const nr = Math.round(r * (1 - a) + target * a);
561
+ const ng = Math.round(g * (1 - a) + target * a);
562
+ const nb = Math.round(b * (1 - a) + target * a);
563
+ return `rgb(${nr},${ng},${nb})`;
564
+ }
565
+ function isLightBackground(color) {
566
+ const [r, g, b] = colorToRgb(color);
567
+ return luminance(r, g, b) > 0.35;
568
+ }
569
+ function deriveSemanticPalette(bg, sidebar, header, _card, accent) {
570
+ const light = isLightBackground(bg);
571
+ const [ar, ag, ab] = hexToRgb(accent.startsWith("#") ? accent : "#60a5fa");
572
+ const accentRgb = `${ar},${ag},${ab}`;
573
+ const accentLum = luminance(ar, ag, ab);
574
+ const textHeading = light ? "#111827" : "#f9fafb";
575
+ const textBody = light ? "#374151" : "#e5e7eb";
576
+ const textMuted = light ? "#6b7280" : "#9ca3af";
577
+ const border = light ? "rgba(0,0,0,0.1)" : "rgba(255,255,255,0.1)";
578
+ const hover = light ? "rgba(0,0,0,0.05)" : "rgba(255,255,255,0.05)";
579
+ const overlay = light ? "rgba(248,250,252,0.95)" : "rgba(17,24,39,0.95)";
580
+ const surface = surfaceFromBg(bg, 0.08);
581
+ const surfaceAlt = surfaceFromBg(bg, 0.04);
582
+ const accentText = accessibleText(accentLum, "#ffffff", "#111827");
583
+ const accentHover = light ? `rgba(${ar},${ag},${ab},0.85)` : `rgba(${Math.min(ar + 20, 255)},${Math.min(ag + 20, 255)},${Math.min(ab + 20, 255)},1)`;
584
+ const accentMuted = `rgba(${ar},${ag},${ab},0.12)`;
585
+ const accentMutedText = accent;
586
+ const btnPrimaryBg = accent;
587
+ const btnPrimaryText = accentText;
588
+ const btnPrimaryHover = accentHover;
589
+ const inputBg = light ? "rgba(0,0,0,0.04)" : "rgba(0,0,0,0.3)";
590
+ const inputBorder = border;
591
+ const inputFocusBorder = accent;
592
+ const inputFocusShadow = `rgba(${ar},${ag},${ab},0.3)`;
593
+ const statusSuccess = light ? "#16a34a" : "#4ade80";
594
+ const statusError = light ? "#dc2626" : "#f87171";
595
+ const statusWarning = light ? "#d97706" : "#fbbf24";
596
+ const statusInfo = light ? "#2563eb" : "#60a5fa";
597
+ const statusNeutral = light ? "#4b5563" : "#9ca3af";
598
+ const statusPurple = light ? "#9333ea" : "#c084fc";
599
+ const statusTeal = light ? "#0d9488" : "#5eead4";
600
+ const sidebarLight = isLightBackground(sidebar);
601
+ const sidebarText = sidebarLight ? "#374151" : "#e5e7eb";
602
+ const sidebarTextMuted = sidebarLight ? "#6b7280" : "#9ca3af";
603
+ const sidebarActive = sidebarLight ? `rgba(${ar},${ag},${ab},0.15)` : `rgba(${ar},${ag},${ab},0.15)`;
604
+ const headerLight = isLightBackground(header);
605
+ const headerText = headerLight ? "#111827" : "#f9fafb";
606
+ const footerBg = light ? "#1e293b" : "rgba(3, 7, 18, 0.95)";
607
+ const footerText = "#94a3b8";
608
+ const footerBorder = light ? "rgba(255,255,255,0.08)" : "rgba(255,255,255,0.06)";
609
+ return {
610
+ textHeading,
611
+ textBody,
612
+ textMuted,
613
+ border,
614
+ hover,
615
+ overlay,
616
+ surface,
617
+ surfaceAlt,
618
+ accent,
619
+ accentRgb,
620
+ accentText,
621
+ accentHover,
622
+ accentMuted,
623
+ accentMutedText,
624
+ btnPrimaryBg,
625
+ btnPrimaryText,
626
+ btnPrimaryHover,
627
+ inputBg,
628
+ inputBorder,
629
+ inputFocusBorder,
630
+ inputFocusShadow,
631
+ statusSuccess,
632
+ statusError,
633
+ statusWarning,
634
+ statusInfo,
635
+ statusNeutral,
636
+ statusPurple,
637
+ statusTeal,
638
+ sidebarText,
639
+ sidebarTextMuted,
640
+ sidebarActive,
641
+ headerText,
642
+ footerBg,
643
+ footerText,
644
+ footerBorder
645
+ };
646
+ }
647
+ function applySemanticPalette(palette) {
648
+ const el = document.documentElement;
649
+ const s = el.style;
650
+ s.setProperty("--admin-text-heading", palette.textHeading);
651
+ s.setProperty("--admin-text-body", palette.textBody);
652
+ s.setProperty("--admin-text-muted", palette.textMuted);
653
+ s.setProperty("--admin-text-primary", palette.textHeading);
654
+ s.setProperty("--admin-border", palette.border);
655
+ s.setProperty("--admin-hover", palette.hover);
656
+ s.setProperty("--admin-overlay", palette.overlay);
657
+ s.setProperty("--admin-surface", palette.surface);
658
+ s.setProperty("--admin-surface-alt", palette.surfaceAlt);
659
+ s.setProperty("--admin-accent", palette.accent);
660
+ s.setProperty("--admin-accent-rgb", palette.accentRgb);
661
+ s.setProperty("--admin-accent-text", palette.accentText);
662
+ s.setProperty("--admin-accent-hover", palette.accentHover);
663
+ s.setProperty("--admin-accent-muted", palette.accentMuted);
664
+ s.setProperty("--admin-accent-muted-text", palette.accentMutedText);
665
+ s.setProperty("--admin-btn-primary-bg", palette.btnPrimaryBg);
666
+ s.setProperty("--admin-btn-primary-text", palette.btnPrimaryText);
667
+ s.setProperty("--admin-btn-primary-hover", palette.btnPrimaryHover);
668
+ s.setProperty("--admin-input-bg", palette.inputBg);
669
+ s.setProperty("--admin-input-border", palette.inputBorder);
670
+ s.setProperty("--admin-input-focus-border", palette.inputFocusBorder);
671
+ s.setProperty("--admin-input-focus-shadow", palette.inputFocusShadow);
672
+ s.setProperty("--admin-status-success", palette.statusSuccess);
673
+ s.setProperty("--admin-status-error", palette.statusError);
674
+ s.setProperty("--admin-status-warning", palette.statusWarning);
675
+ s.setProperty("--admin-status-info", palette.statusInfo);
676
+ s.setProperty("--admin-status-neutral", palette.statusNeutral);
677
+ s.setProperty("--admin-status-purple", palette.statusPurple);
678
+ s.setProperty("--admin-status-teal", palette.statusTeal);
679
+ s.setProperty("--admin-sidebar-text", palette.sidebarText);
680
+ s.setProperty("--admin-sidebar-text-muted", palette.sidebarTextMuted);
681
+ s.setProperty("--admin-sidebar-active", palette.sidebarActive);
682
+ s.setProperty("--admin-header-text", palette.headerText);
683
+ s.setProperty("--admin-footer-bg", palette.footerBg);
684
+ s.setProperty("--admin-footer-text", palette.footerText);
685
+ s.setProperty("--admin-footer-border", palette.footerBorder);
686
+ s.setProperty("--glass-accent", palette.accent);
687
+ s.setProperty("--glass-accent-rgb", palette.accentRgb);
688
+ }
689
+ const DEFAULT_THEME = {
690
+ bg: "#0f172a",
691
+ sidebar: "rgba(17, 24, 39, 0.6)",
692
+ header: "rgba(15, 23, 42, 0.85)",
693
+ card: "rgba(15, 23, 42, 0.6)",
694
+ accent: "#60a5fa",
695
+ skin: "default"
696
+ };
697
+ function applyTheme(config = {}) {
698
+ const c = { ...DEFAULT_THEME, ...config };
699
+ const s = document.documentElement.style;
700
+ s.setProperty("--admin-bg-color", c.bg);
701
+ s.setProperty("--admin-sidebar-bg", c.sidebar);
702
+ s.setProperty("--admin-header-bg", c.header);
703
+ s.setProperty("--admin-card-bg", c.card);
704
+ s.setProperty("--admin-ui-skin", c.skin ?? "default");
705
+ const palette = deriveSemanticPalette(c.bg, c.sidebar, c.header, c.card, c.accent);
706
+ applySemanticPalette(palette);
707
+ return palette;
708
+ }
709
+ export {
710
+ AppConfirmModal,
711
+ AppLoadingOverlay,
712
+ AppShell,
713
+ AppToast,
714
+ DEFAULT_THEME,
715
+ applySemanticPalette,
716
+ applyTheme,
717
+ colorToRgb,
718
+ contrastRatio,
719
+ deriveSemanticPalette,
720
+ hexToRgb,
721
+ isLightBackground,
722
+ luminance,
723
+ useConfirm,
724
+ useConfirmStore,
725
+ useLoadingStore,
726
+ useToast,
727
+ useToastStore
728
+ };
729
+ //# sourceMappingURL=index.js.map