@htlkg/components 0.0.3 → 0.0.4

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.
Files changed (47) hide show
  1. package/dist/AdminWrapper.vue_vue_type_script_setup_true_lang-B32IylcT.js +367 -0
  2. package/dist/AdminWrapper.vue_vue_type_script_setup_true_lang-B32IylcT.js.map +1 -0
  3. package/dist/Alert.vue_vue_type_script_setup_true_lang-DxPCS-Hx.js +263 -0
  4. package/dist/Alert.vue_vue_type_script_setup_true_lang-DxPCS-Hx.js.map +1 -0
  5. package/dist/DateRange.vue_vue_type_script_setup_true_lang-BLVg1Hah.js +580 -0
  6. package/dist/DateRange.vue_vue_type_script_setup_true_lang-BLVg1Hah.js.map +1 -0
  7. package/dist/ProductBadge.vue_vue_type_script_setup_true_lang-Cmr2f4Cy.js +187 -0
  8. package/dist/ProductBadge.vue_vue_type_script_setup_true_lang-Cmr2f4Cy.js.map +1 -0
  9. package/dist/_plugin-vue_export-helper-1tPrXgE0.js +11 -0
  10. package/dist/_plugin-vue_export-helper-1tPrXgE0.js.map +1 -0
  11. package/dist/components.css +15 -0
  12. package/dist/composables/index.js +32 -765
  13. package/dist/composables/index.js.map +1 -1
  14. package/dist/data/index.js +18 -0
  15. package/dist/data/index.js.map +1 -0
  16. package/dist/domain/index.js +8 -0
  17. package/dist/domain/index.js.map +1 -0
  18. package/dist/filterHelpers-DgRyoYSa.js +1386 -0
  19. package/dist/filterHelpers-DgRyoYSa.js.map +1 -0
  20. package/dist/forms/index.js +6 -0
  21. package/dist/forms/index.js.map +1 -0
  22. package/dist/index-DGO_pNgG.js +79 -0
  23. package/dist/index-DGO_pNgG.js.map +1 -0
  24. package/dist/index-QK97OdqQ.js +25 -0
  25. package/dist/index-QK97OdqQ.js.map +1 -0
  26. package/dist/index.js +67 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/navigation/index.js +8 -0
  29. package/dist/navigation/index.js.map +1 -0
  30. package/dist/overlays/index.js +8 -0
  31. package/dist/overlays/index.js.map +1 -0
  32. package/dist/stores/index.js +14 -0
  33. package/dist/stores/index.js.map +1 -0
  34. package/dist/useAdminPage-GhgXp0x8.js +1070 -0
  35. package/dist/useAdminPage-GhgXp0x8.js.map +1 -0
  36. package/dist/useTable-DutR1gkg.js +293 -0
  37. package/dist/useTable-DutR1gkg.js.map +1 -0
  38. package/package.json +37 -11
  39. package/src/composables/index.ts +52 -0
  40. package/src/composables/useAdminPage.ts +462 -0
  41. package/src/composables/useConfirmation.ts +358 -0
  42. package/src/composables/useStats.ts +361 -0
  43. package/src/composables/useWizard.ts +448 -0
  44. package/src/data/columnHelpers.ts +169 -0
  45. package/src/data/filterHelpers.ts +358 -0
  46. package/src/data/index.ts +11 -0
  47. package/src/forms/JsonSchemaForm.vue +4 -1
@@ -1,767 +1,34 @@
1
- // src/composables/useTable.ts
2
- import { ref, computed, unref } from "vue";
3
- function useTable(options) {
4
- const idKey = options.idKey ?? "id";
5
- const items = computed(() => {
6
- try {
7
- const unwrapped = unref(options.items);
8
- if (!unwrapped) return [];
9
- if (!Array.isArray(unwrapped)) {
10
- console.warn("useTable: items is not an array", unwrapped);
11
- return [];
12
- }
13
- return unwrapped;
14
- } catch (error) {
15
- console.error("useTable: Error unwrapping items", error);
16
- return [];
17
- }
18
- });
19
- const currentPage = ref(1);
20
- const pageSize = ref(options.pageSize ?? 10);
21
- const sortKey = ref(options.sortKey ?? "");
22
- const sortOrder = ref(options.sortOrder ?? "asc");
23
- const selectedItems = ref([]);
24
- const selectedItemIds = ref(/* @__PURE__ */ new Set());
25
- const resetSelected = ref(false);
26
- const activeFilters = ref([]);
27
- const hiddenColumns = ref([]);
28
- const filteredItems = computed(() => {
29
- const filters = Array.isArray(activeFilters.value) ? activeFilters.value : [];
30
- if (filters.length === 0) return items.value;
31
- return items.value.filter((item) => {
32
- return filters.every((filter) => {
33
- const { category, operator, value } = filter;
34
- if (value === void 0 || value === null || value === "") return true;
35
- const itemValue = item[category];
36
- switch (operator) {
37
- case "contains":
38
- return String(itemValue).toLowerCase().includes(String(value).toLowerCase());
39
- case "is":
40
- case "=":
41
- return itemValue === value;
42
- case ">":
43
- case "greater":
44
- return Number(itemValue) > Number(value);
45
- case "<":
46
- case "less":
47
- return Number(itemValue) < Number(value);
48
- case ">=":
49
- case "greaterOrEqual":
50
- return Number(itemValue) >= Number(value);
51
- case "<=":
52
- case "lessOrEqual":
53
- return Number(itemValue) <= Number(value);
54
- default:
55
- return String(itemValue).toLowerCase().includes(String(value).toLowerCase());
56
- }
57
- });
58
- });
59
- });
60
- const sortedItems = computed(() => {
61
- if (!sortKey.value) return filteredItems.value;
62
- return [...filteredItems.value].sort((a, b) => {
63
- const aVal = a[sortKey.value];
64
- const bVal = b[sortKey.value];
65
- const order = sortOrder.value === "asc" ? 1 : -1;
66
- if (aVal === bVal) return 0;
67
- if (aVal == null) return 1;
68
- if (bVal == null) return -1;
69
- if (typeof aVal === "string" && typeof bVal === "string") {
70
- return aVal.localeCompare(bVal) * order;
71
- }
72
- return aVal > bVal ? order : -order;
73
- });
74
- });
75
- const paginatedItems = computed(() => {
76
- const start = (currentPage.value - 1) * pageSize.value;
77
- const end = start + pageSize.value;
78
- return sortedItems.value.slice(start, end);
79
- });
80
- const totalPages = computed(
81
- () => Math.ceil(sortedItems.value.length / pageSize.value)
82
- );
83
- const totalItems = computed(() => sortedItems.value.length);
84
- const allSelected = computed(() => {
85
- if (items.value.length === 0) return false;
86
- return selectedItemIds.value.size === items.value.length;
87
- });
88
- const someSelected = computed(() => {
89
- return selectedItemIds.value.size > 0 && !allSelected.value;
90
- });
91
- function setPage(page) {
92
- if (page >= 1 && page <= totalPages.value) {
93
- currentPage.value = page;
94
- }
95
- }
96
- function setPageSize(size) {
97
- pageSize.value = size;
98
- currentPage.value = 1;
99
- }
100
- function handlePageChange(page) {
101
- setPage(page);
102
- }
103
- function handlePageSizeChange(size) {
104
- const numSize = typeof size === "string" ? parseInt(size) : size;
105
- setPageSize(numSize);
106
- }
107
- function setSorting(key, order = "asc") {
108
- if (sortKey.value === key) {
109
- sortOrder.value = sortOrder.value === "asc" ? "desc" : "asc";
110
- } else {
111
- sortKey.value = key;
112
- sortOrder.value = order;
113
- }
114
- }
115
- function handleOrderBy(event) {
116
- sortKey.value = event.value;
117
- sortOrder.value = event.orderDirection;
118
- }
119
- function getItemId(item) {
120
- return item[idKey];
121
- }
122
- function selectItem(item) {
123
- const id = getItemId(item);
124
- if (!selectedItemIds.value.has(id)) {
125
- selectedItemIds.value.add(id);
126
- selectedItems.value.push(item);
127
- }
128
- }
129
- function deselectItem(item) {
130
- const id = getItemId(item);
131
- if (selectedItemIds.value.has(id)) {
132
- selectedItemIds.value.delete(id);
133
- const index = selectedItems.value.findIndex((i) => getItemId(i) === id);
134
- if (index !== -1) {
135
- selectedItems.value.splice(index, 1);
136
- }
137
- }
138
- }
139
- function selectAll() {
140
- selectedItemIds.value.clear();
141
- selectedItems.value.length = 0;
142
- items.value.forEach((item) => {
143
- const id = getItemId(item);
144
- selectedItemIds.value.add(id);
145
- selectedItems.value.push(item);
146
- });
147
- }
148
- function selectAllOnPage() {
149
- paginatedItems.value.forEach((item) => {
150
- selectItem(item);
151
- });
152
- }
153
- function clearSelection() {
154
- selectedItemIds.value.clear();
155
- selectedItems.value.length = 0;
156
- resetSelected.value = true;
157
- setTimeout(() => {
158
- resetSelected.value = false;
159
- }, 100);
160
- }
161
- function isSelected(item) {
162
- const id = getItemId(item);
163
- return selectedItemIds.value.has(id);
164
- }
165
- function applyFilters(filters) {
166
- if (Array.isArray(filters)) {
167
- activeFilters.value = filters;
168
- } else if (filters && typeof filters === "object") {
169
- if ("filters" in filters && Array.isArray(filters.filters)) {
170
- activeFilters.value = filters.filters;
171
- } else {
172
- activeFilters.value = Object.entries(filters).filter(([_, value]) => value !== void 0 && value !== null && value !== "").map(([key, value]) => ({
173
- category: key,
174
- operator: "contains",
175
- value
176
- }));
177
- }
178
- } else {
179
- activeFilters.value = [];
180
- }
181
- currentPage.value = 1;
182
- }
183
- function clearFilters() {
184
- activeFilters.value = [];
185
- currentPage.value = 1;
186
- }
187
- function removeFilter(index) {
188
- if (index >= 0 && index < activeFilters.value.length) {
189
- activeFilters.value.splice(index, 1);
190
- currentPage.value = 1;
191
- }
192
- }
193
- function handleSmartFiltersApplied(filters) {
194
- applyFilters(filters);
195
- }
196
- function handleSmartFiltersCleared() {
197
- clearFilters();
198
- }
199
- function handleSmartFilterDeleted(index) {
200
- removeFilter(index);
201
- }
202
- function toggleColumn(index) {
203
- const hiddenIndex = hiddenColumns.value.indexOf(index);
204
- if (hiddenIndex > -1) {
205
- hiddenColumns.value.splice(hiddenIndex, 1);
206
- } else {
207
- hiddenColumns.value.push(index);
208
- }
209
- }
210
- function showColumn(index) {
211
- const hiddenIndex = hiddenColumns.value.indexOf(index);
212
- if (hiddenIndex > -1) {
213
- hiddenColumns.value.splice(hiddenIndex, 1);
214
- }
215
- }
216
- function hideColumn(index) {
217
- if (!hiddenColumns.value.includes(index)) {
218
- hiddenColumns.value.push(index);
219
- }
220
- }
221
- function handleColumnsVisibilityChanged(event) {
222
- if (event.hidden) {
223
- hideColumn(event.index);
224
- } else {
225
- showColumn(event.index);
226
- }
227
- }
228
- function handleModalAction(event) {
229
- if (event.modal === "selectAllItemsModal" || event.modal.includes("selectAll")) {
230
- if (event.action === "selectAll") {
231
- selectAll();
232
- } else if (event.action === "close") {
233
- selectAllOnPage();
234
- }
235
- }
236
- }
237
- return {
238
- // Pagination
239
- currentPage,
240
- pageSize,
241
- totalPages,
242
- totalItems,
243
- paginatedItems,
244
- // Sorting
245
- sortKey,
246
- sortOrder,
247
- sortedItems,
248
- // Selection
249
- selectedItems,
250
- selectedItemIds,
251
- allSelected,
252
- someSelected,
253
- // Filtering
254
- activeFilters,
255
- filteredItems,
256
- // Column visibility
257
- hiddenColumns,
258
- // Reset state
259
- resetSelected,
260
- // Methods - Pagination
261
- setPage,
262
- setPageSize,
263
- handlePageChange,
264
- handlePageSizeChange,
265
- // Methods - Sorting
266
- setSorting,
267
- handleOrderBy,
268
- // Methods - Selection
269
- selectItem,
270
- deselectItem,
271
- selectAll,
272
- selectAllOnPage,
273
- clearSelection,
274
- isSelected,
275
- // Methods - Filtering
276
- applyFilters,
277
- clearFilters,
278
- removeFilter,
279
- handleSmartFiltersApplied,
280
- handleSmartFiltersCleared,
281
- handleSmartFilterDeleted,
282
- // Methods - Column visibility
283
- toggleColumn,
284
- showColumn,
285
- hideColumn,
286
- handleColumnsVisibilityChanged,
287
- // Methods - Modal actions
288
- handleModalAction
289
- };
290
- }
291
-
292
- // src/composables/useModal.ts
293
- import { ref as ref2 } from "vue";
294
- function useModal(options = {}) {
295
- const isOpen = ref2(options.initialOpen ?? false);
296
- function open() {
297
- isOpen.value = true;
298
- options.onOpen?.();
299
- }
300
- function close() {
301
- isOpen.value = false;
302
- options.onClose?.();
303
- }
304
- function toggle() {
305
- if (isOpen.value) {
306
- close();
307
- } else {
308
- open();
309
- }
310
- }
311
- return {
312
- isOpen,
313
- open,
314
- close,
315
- toggle
316
- };
317
- }
318
-
319
- // src/composables/useTabs.ts
320
- import { ref as ref3, computed as computed2 } from "vue";
321
- function useTabs(options) {
322
- const tabs = ref3(options.tabs);
323
- const activeTab = ref3(
324
- options.initialTab || (tabs.value.length > 0 ? tabs.value[0].id : "")
325
- );
326
- const currentTabIndex = computed2(
327
- () => tabs.value.findIndex((tab) => tab.id === activeTab.value)
328
- );
329
- const isFirstTab = computed2(() => currentTabIndex.value === 0);
330
- const isLastTab = computed2(
331
- () => currentTabIndex.value === tabs.value.length - 1
332
- );
333
- function setActiveTab(tabId) {
334
- const tab = tabs.value.find((t) => t.id === tabId);
335
- if (tab && !tab.disabled) {
336
- activeTab.value = tabId;
337
- options.onChange?.(tabId);
338
- }
339
- }
340
- function nextTab() {
341
- if (!isLastTab.value) {
342
- const nextIndex = currentTabIndex.value + 1;
343
- const nextTab2 = tabs.value[nextIndex];
344
- if (nextTab2 && !nextTab2.disabled) {
345
- setActiveTab(nextTab2.id);
346
- } else if (nextIndex < tabs.value.length - 1) {
347
- activeTab.value = nextTab2.id;
348
- nextTab2();
349
- }
350
- }
351
- }
352
- function previousTab() {
353
- if (!isFirstTab.value) {
354
- const prevIndex = currentTabIndex.value - 1;
355
- const prevTab = tabs.value[prevIndex];
356
- if (prevTab && !prevTab.disabled) {
357
- setActiveTab(prevTab.id);
358
- } else if (prevIndex > 0) {
359
- activeTab.value = prevTab.id;
360
- previousTab();
361
- }
362
- }
363
- }
364
- function isTabActive(tabId) {
365
- return activeTab.value === tabId;
366
- }
367
- function isTabDisabled(tabId) {
368
- const tab = tabs.value.find((t) => t.id === tabId);
369
- return tab?.disabled ?? false;
370
- }
371
- return {
372
- activeTab,
373
- tabs,
374
- currentTabIndex,
375
- isFirstTab,
376
- isLastTab,
377
- setActiveTab,
378
- nextTab,
379
- previousTab,
380
- isTabActive,
381
- isTabDisabled
382
- };
383
- }
384
-
385
- // src/composables/useForm.ts
386
- import { ref as ref4, computed as computed3 } from "vue";
387
- function useForm(options) {
388
- const values = ref4({ ...options.initialValues });
389
- const errors = ref4({});
390
- const touched = ref4({});
391
- const isSubmitting = ref4(false);
392
- const isValid = computed3(() => Object.keys(errors.value).length === 0);
393
- function setFieldValue(field, value) {
394
- values.value[field] = value;
395
- }
396
- function setFieldError(field, error) {
397
- errors.value[field] = error;
398
- }
399
- function setFieldTouched(field, isTouched) {
400
- touched.value[field] = isTouched;
401
- }
402
- async function validateField(field) {
403
- const rules = options.validationRules?.[field];
404
- if (!rules || rules.length === 0) return true;
405
- const value = values.value[field];
406
- for (const rule of rules) {
407
- const isValid2 = await rule.validate(value);
408
- if (!isValid2) {
409
- setFieldError(field, rule.message);
410
- return false;
411
- }
412
- }
413
- delete errors.value[field];
414
- return true;
415
- }
416
- async function validateForm() {
417
- const fields = Object.keys(values.value);
418
- const validationResults = await Promise.all(
419
- fields.map((field) => validateField(field))
420
- );
421
- return validationResults.every((result) => result);
422
- }
423
- async function handleSubmit(event) {
424
- if (event) {
425
- event.preventDefault();
426
- }
427
- if (isSubmitting.value) return;
428
- for (const field of Object.keys(values.value)) {
429
- setFieldTouched(field, true);
430
- }
431
- const isFormValid = await validateForm();
432
- if (!isFormValid) return;
433
- isSubmitting.value = true;
434
- try {
435
- await options.onSubmit?.(values.value);
436
- } finally {
437
- isSubmitting.value = false;
438
- }
439
- }
440
- function resetForm() {
441
- values.value = { ...options.initialValues };
442
- errors.value = {};
443
- touched.value = {};
444
- isSubmitting.value = false;
445
- }
446
- return {
447
- values,
448
- errors,
449
- touched,
450
- isSubmitting,
451
- isValid,
452
- setFieldValue,
453
- setFieldError,
454
- setFieldTouched,
455
- validateField,
456
- validateForm,
457
- handleSubmit,
458
- resetForm
459
- };
460
- }
461
-
462
- // src/composables/useFormValidation.ts
463
- var required = (message = "This field is required") => ({
464
- validate: (value) => {
465
- if (value === null || value === void 0) return false;
466
- if (typeof value === "string") return value.trim().length > 0;
467
- if (Array.isArray(value)) return value.length > 0;
468
- return true;
469
- },
470
- message
471
- });
472
- var minLength = (min2, message) => ({
473
- validate: (value) => {
474
- if (!value) return true;
475
- return value.length >= min2;
476
- },
477
- message: message || `Must be at least ${min2} characters`
478
- });
479
- var maxLength = (max2, message) => ({
480
- validate: (value) => {
481
- if (!value) return true;
482
- return value.length <= max2;
483
- },
484
- message: message || `Must be at most ${max2} characters`
485
- });
486
- var email = (message = "Invalid email address") => ({
487
- validate: (value) => {
488
- if (!value) return true;
489
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
490
- return emailRegex.test(value);
491
- },
492
- message
493
- });
494
- var pattern = (regex, message = "Invalid format") => ({
495
- validate: (value) => {
496
- if (!value) return true;
497
- return regex.test(value);
498
- },
499
- message
500
- });
501
- var min = (minValue, message) => ({
502
- validate: (value) => {
503
- if (value === null || value === void 0) return true;
504
- return value >= minValue;
505
- },
506
- message: message || `Must be at least ${minValue}`
507
- });
508
- var max = (maxValue, message) => ({
509
- validate: (value) => {
510
- if (value === null || value === void 0) return true;
511
- return value <= maxValue;
512
- },
513
- message: message || `Must be at most ${maxValue}`
514
- });
515
- var custom = (validator, message) => ({
516
- validate: validator,
517
- message
518
- });
519
- function useFormValidation() {
520
- return {
521
- required,
522
- minLength,
523
- maxLength,
524
- email,
525
- pattern,
526
- min,
527
- max,
528
- custom
529
- };
530
- }
531
-
532
- // src/composables/useNotifications.ts
533
- import { ref as ref5 } from "vue";
534
- var notifications = ref5([]);
535
- function useNotifications() {
536
- function addNotification(notification) {
537
- const id = `notification-${Date.now()}-${Math.random()}`;
538
- const newNotification = {
539
- ...notification,
540
- id
541
- };
542
- notifications.value.push(newNotification);
543
- if (notification.duration) {
544
- setTimeout(() => {
545
- removeNotification(id);
546
- }, notification.duration);
547
- }
548
- return id;
549
- }
550
- function removeNotification(id) {
551
- const index = notifications.value.findIndex((n) => n.id === id);
552
- if (index !== -1) {
553
- notifications.value.splice(index, 1);
554
- }
555
- }
556
- function clearAll() {
557
- notifications.value = [];
558
- }
559
- function info(message, duration = 3e3) {
560
- return addNotification({ message, type: "info", duration });
561
- }
562
- function success(message, duration = 3e3) {
563
- return addNotification({ message, type: "success", duration });
564
- }
565
- function warning(message, duration = 3e3) {
566
- return addNotification({ message, type: "warning", duration });
567
- }
568
- function error(message, duration = 5e3) {
569
- return addNotification({ message, type: "error", duration });
570
- }
571
- return {
572
- notifications,
573
- addNotification,
574
- removeNotification,
575
- clearAll,
576
- info,
577
- success,
578
- warning,
579
- error
580
- };
581
- }
582
-
583
- // src/composables/usePageContext.ts
584
- import { computed as computed4, inject } from "vue";
585
-
586
- // ../../node_modules/.pnpm/@nanostores+vue@1.0.1_@nanostores+logger@1.0.0_nanostores@1.1.0__nanostores@1.1.0_vue@3.5.25_typescript@5.9.3_/node_modules/@nanostores/vue/use-store/index.js
587
- import {
588
- getCurrentInstance,
589
- getCurrentScope,
590
- onScopeDispose,
591
- readonly,
592
- shallowRef
593
- } from "vue";
594
- function registerStore(store) {
595
- let instance = getCurrentInstance();
596
- if (instance && instance.proxy) {
597
- let vm = instance.proxy;
598
- let cache = "_nanostores" in vm ? vm._nanostores : vm._nanostores = [];
599
- cache.push(store);
600
- }
601
- }
602
- function useStore(store) {
603
- let state = shallowRef();
604
- let unsubscribe = store.subscribe((value) => {
605
- state.value = value;
606
- });
607
- getCurrentScope() && onScopeDispose(unsubscribe);
608
- if (process.env.NODE_ENV !== "production") {
609
- registerStore(store);
610
- return readonly(state);
611
- }
612
- return state;
613
- }
614
-
615
- // ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/clean-stores/index.js
616
- var clean = /* @__PURE__ */ Symbol("clean");
617
-
618
- // ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/atom/index.js
619
- var listenerQueue = [];
620
- var lqIndex = 0;
621
- var QUEUE_ITEMS_PER_LISTENER = 4;
622
- var epoch = 0;
623
- var atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
624
- let listeners = [];
625
- let $atom = {
626
- get() {
627
- if (!$atom.lc) {
628
- $atom.listen(() => {
629
- })();
630
- }
631
- return $atom.value;
632
- },
633
- lc: 0,
634
- listen(listener) {
635
- $atom.lc = listeners.push(listener);
636
- return () => {
637
- for (let i = lqIndex + QUEUE_ITEMS_PER_LISTENER; i < listenerQueue.length; ) {
638
- if (listenerQueue[i] === listener) {
639
- listenerQueue.splice(i, QUEUE_ITEMS_PER_LISTENER);
640
- } else {
641
- i += QUEUE_ITEMS_PER_LISTENER;
642
- }
643
- }
644
- let index = listeners.indexOf(listener);
645
- if (~index) {
646
- listeners.splice(index, 1);
647
- if (!--$atom.lc) $atom.off();
648
- }
649
- };
650
- },
651
- notify(oldValue, changedKey) {
652
- epoch++;
653
- let runListenerQueue = !listenerQueue.length;
654
- for (let listener of listeners) {
655
- listenerQueue.push(listener, $atom.value, oldValue, changedKey);
656
- }
657
- if (runListenerQueue) {
658
- for (lqIndex = 0; lqIndex < listenerQueue.length; lqIndex += QUEUE_ITEMS_PER_LISTENER) {
659
- listenerQueue[lqIndex](
660
- listenerQueue[lqIndex + 1],
661
- listenerQueue[lqIndex + 2],
662
- listenerQueue[lqIndex + 3]
663
- );
664
- }
665
- listenerQueue.length = 0;
666
- }
667
- },
668
- /* It will be called on last listener unsubscribing.
669
- We will redefine it in onMount and onStop. */
670
- off() {
671
- },
672
- set(newValue) {
673
- let oldValue = $atom.value;
674
- if (oldValue !== newValue) {
675
- $atom.value = newValue;
676
- $atom.notify(oldValue);
677
- }
678
- },
679
- subscribe(listener) {
680
- let unbind = $atom.listen(listener);
681
- listener($atom.value);
682
- return unbind;
683
- },
684
- value: initialValue
685
- };
686
- if (process.env.NODE_ENV !== "production") {
687
- $atom[clean] = () => {
688
- listeners = [];
689
- $atom.lc = 0;
690
- $atom.off();
691
- };
692
- }
693
- return $atom;
694
- };
695
-
696
- // src/composables/usePageContext.ts
697
- import { routes } from "@htlkg/core";
698
- var PAGE_CONTEXT_KEY = /* @__PURE__ */ Symbol("pageContext");
699
- var $user = atom(null);
700
- var $currentBrand = atom(null);
701
- function setUser(user) {
702
- $user.set(user);
703
- }
704
- function setCurrentBrand(brand) {
705
- $currentBrand.set(brand);
706
- }
707
- function usePageContext() {
708
- const injected = inject(PAGE_CONTEXT_KEY, null);
709
- if (injected) {
710
- return computed4(() => injected);
711
- }
712
- const user = useStore($user);
713
- const brand = useStore($currentBrand);
714
- return computed4(() => ({
715
- user: user.value,
716
- brand: brand.value ?? void 0,
717
- brandId: brand.value?.id,
718
- isAdmin: user.value?.isAdmin ?? false,
719
- isSuperAdmin: user.value?.isSuperAdmin ?? false,
720
- routes
721
- }));
722
- }
723
- function useHasAccessToBrand(brandId) {
724
- const context = usePageContext();
725
- return computed4(() => {
726
- const user = context.value.user;
727
- if (!user) return false;
728
- if (user.isAdmin || user.isSuperAdmin) return true;
729
- return user.brandIds?.includes(brandId) ?? false;
730
- });
731
- }
732
- function useHasAccessToAccount(accountId) {
733
- const context = usePageContext();
734
- return computed4(() => {
735
- const user = context.value.user;
736
- if (!user) return false;
737
- if (user.isAdmin || user.isSuperAdmin) return true;
738
- return user.accountIds?.includes(accountId) ?? false;
739
- });
740
- }
741
- function useUserRoles() {
742
- const context = usePageContext();
743
- return computed4(() => context.value.user?.roles ?? []);
744
- }
745
- function useHasRole(role) {
746
- const roles = useUserRoles();
747
- return computed4(() => roles.value.includes(role));
748
- }
1
+ import { u } from "../useTable-DutR1gkg.js";
2
+ import { k, $, P, p, n, q, v, j, s, o, w, r, y, b, z, c, t, g, f, i, x, u as u2, d, e, m, a, h, l } from "../useAdminPage-GhgXp0x8.js";
749
3
  export {
750
- $currentBrand,
751
- $user,
752
- PAGE_CONTEXT_KEY,
753
- setCurrentBrand,
754
- setUser,
755
- useForm,
756
- useFormValidation,
757
- useHasAccessToAccount,
758
- useHasAccessToBrand,
759
- useHasRole,
760
- useModal,
761
- useNotifications,
762
- usePageContext,
763
- useTable,
764
- useTabs,
765
- useUserRoles
4
+ k as $currentBrand,
5
+ $ as $user,
6
+ P as PAGE_CONTEXT_KEY,
7
+ p as averageStat,
8
+ n as countStat,
9
+ q as percentageStat,
10
+ v as resetGlobalConfirmation,
11
+ j as setCurrentBrand,
12
+ s as setUser,
13
+ o as sumStat,
14
+ w as useAdminPage,
15
+ r as useConfirmation,
16
+ y as useDetailPage,
17
+ b as useForm,
18
+ z as useFormPage,
19
+ c as useFormValidation,
20
+ t as useGlobalConfirmation,
21
+ g as useHasAccessToAccount,
22
+ f as useHasAccessToBrand,
23
+ i as useHasRole,
24
+ x as useListPage,
25
+ u2 as useModal,
26
+ d as useNotifications,
27
+ e as usePageContext,
28
+ m as useStats,
29
+ u as useTable,
30
+ a as useTabs,
31
+ h as useUserRoles,
32
+ l as useWizard
766
33
  };
767
- //# sourceMappingURL=index.js.map
34
+ //# sourceMappingURL=index.js.map