vlite3 0.7.11 → 0.7.13

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 (34) hide show
  1. package/components/Badge.vue.d.ts +6 -2
  2. package/components/Badge.vue.js +16 -9
  3. package/components/Button.vue.js +1 -1
  4. package/components/DatePicker.vue.js +1 -1
  5. package/components/FilePicker/FilePicker.vue.js +56 -54
  6. package/components/Form/CustomFields.vue.js +1 -1
  7. package/components/Form/CustomFields.vue2.js +60 -53
  8. package/components/Form/Form.vue.d.ts +12 -2
  9. package/components/Form/Form.vue.js +1 -1
  10. package/components/Form/Form.vue2.js +228 -191
  11. package/components/Form/FormField.vue.d.ts +3 -0
  12. package/components/Form/FormField.vue.js +90 -82
  13. package/components/Form/FormFields.vue.js +2 -2
  14. package/components/Form/FormFields.vue2.js +59 -51
  15. package/components/List/ListFieldRow.vue.d.ts +4 -0
  16. package/components/List/ListFieldRow.vue.js +198 -113
  17. package/components/MultiSelect/MultiSelect.vue.d.ts +6 -0
  18. package/components/MultiSelect/MultiSelect.vue.js +116 -98
  19. package/components/NumberInput.vue.js +2 -2
  20. package/components/NumberInput.vue2.js +36 -35
  21. package/components/PermissionMatrix/PermissionEditor.vue.js +72 -129
  22. package/components/PermissionMatrix/PermissionEditorList.vue.js +1 -1
  23. package/components/PermissionMatrix/PermissionEditorList.vue2.js +101 -111
  24. package/components/PermissionMatrix/PermissionEditorMatrix.vue.js +1 -1
  25. package/components/PermissionMatrix/PermissionEditorMatrix.vue2.js +129 -133
  26. package/components/PermissionMatrix/PermissionMatrix.vue.js +1 -1
  27. package/components/PermissionMatrix/PermissionMatrix.vue2.js +171 -156
  28. package/components/PermissionMatrix/usePermissionSearch.d.ts +13 -0
  29. package/components/PermissionMatrix/usePermissionSearch.js +71 -0
  30. package/components/PermissionMatrix/usePermissionState.d.ts +22 -0
  31. package/components/PermissionMatrix/usePermissionState.js +77 -0
  32. package/components/Screen/ScreenFilter.vue.js +32 -32
  33. package/package.json +1 -1
  34. package/style.css +1 -1
@@ -1,20 +1,20 @@
1
- import { defineComponent as D, ref as S, computed as _, openBlock as n, createElementBlock as c, normalizeClass as r, createVNode as B, createCommentVNode as h, createElementVNode as a, Fragment as y, renderList as v, toDisplayString as x, createBlock as f, withCtx as F } from "vue";
2
- import G from "../CheckBox.vue.js";
3
- import L from "../Switch.vue.js";
4
- import z from "../Icon.vue.js";
5
- import Q from "../Input.vue.js";
1
+ import { defineComponent as Q, ref as L, computed as _, openBlock as n, createElementBlock as c, normalizeClass as r, createVNode as $, createCommentVNode as p, createElementVNode as i, Fragment as h, renderList as w, toDisplayString as v, createBlock as x, isMemoSame as R, withCtx as T } from "vue";
2
+ import N from "../CheckBox.vue.js";
3
+ import j from "../Switch.vue.js";
4
+ import P from "../Icon.vue.js";
5
+ import U from "../Input.vue.js";
6
6
  /* empty css */
7
- import R from "../Tooltip.vue.js";
8
- const T = {
7
+ import I from "../Tooltip.vue.js";
8
+ const J = {
9
9
  key: 0,
10
10
  class: "mb-4"
11
- }, U = {
11
+ }, O = {
12
12
  key: 1,
13
13
  class: "text-center py-12 text-muted-foreground"
14
- }, I = {
14
+ }, W = {
15
15
  key: 2,
16
16
  class: "permission-matrix-wrapper border rounded-lg overflow-auto"
17
- }, J = { class: "w-full border-collapse" }, O = { class: "bg-muted" }, W = { class: "flex flex-col items-center gap-0.5" }, X = { class: "bg-secondary/60" }, Y = ["onClick"], Z = { class: "flex items-center gap-2" }, K = ["onClick"], ee = { class: "flex items-center justify-center pointer-events-none" }, te = { class: "flex items-center gap-2 pl-6" }, se = ["onClick"], le = { class: "flex items-center justify-center pointer-events-none" }, ue = /* @__PURE__ */ D({
17
+ }, X = { class: "w-full border-collapse" }, Y = { class: "bg-muted" }, Z = { class: "flex flex-col items-center gap-0.5" }, K = { class: "bg-secondary/60" }, ee = ["onClick"], te = { class: "flex items-center gap-2" }, se = ["onClick"], le = { class: "flex items-center justify-center pointer-events-none" }, ne = { class: "flex items-center gap-2 pl-6" }, oe = ["onClick"], ae = { class: "flex items-center justify-center pointer-events-none" }, ye = /* @__PURE__ */ Q({
18
18
  __name: "PermissionMatrix",
19
19
  props: {
20
20
  roles: {},
@@ -29,200 +29,215 @@ const T = {
29
29
  class: { default: "" }
30
30
  },
31
31
  emits: ["update:modelValue"],
32
- setup(i, { emit: M }) {
33
- const o = i, P = M, g = S(""), p = S(/* @__PURE__ */ new Set());
34
- function N(s) {
32
+ setup(a, { emit: E }) {
33
+ const o = a, M = E, z = L(""), C = L(/* @__PURE__ */ new Set());
34
+ function H(e) {
35
35
  if (!o.collapsible) return;
36
- const l = new Set(p.value);
37
- l.has(s) ? l.delete(s) : l.add(s), p.value = l;
36
+ const t = new Set(C.value);
37
+ t.has(e) ? t.delete(e) : t.add(e), C.value = t;
38
38
  }
39
- const $ = _(() => {
40
- if (!g.value.trim()) return o.groups;
41
- const s = g.value.toLowerCase();
42
- return o.groups.map((l) => {
43
- const e = l.permissions.filter(
44
- (t) => t.label.toLowerCase().includes(s) || t.key.toLowerCase().includes(s) || l.label.toLowerCase().includes(s)
39
+ const G = _(() => {
40
+ if (!z.value.trim()) return o.groups;
41
+ const e = z.value.toLowerCase();
42
+ return o.groups.map((t) => {
43
+ const l = t.permissions.filter(
44
+ (s) => s.label.toLowerCase().includes(e) || s.key.toLowerCase().includes(e) || t.label.toLowerCase().includes(e)
45
45
  );
46
- return e.length === 0 ? null : { ...l, permissions: e };
46
+ return l.length === 0 ? null : { ...t, permissions: l };
47
47
  }).filter(Boolean);
48
+ }), V = _(() => {
49
+ const e = /* @__PURE__ */ new Map();
50
+ for (const t of o.roles)
51
+ e.set(t.key, new Set(o.modelValue[t.key] || []));
52
+ return e;
48
53
  });
49
- function C(s, l) {
50
- return o.modelValue[s]?.includes(l) ?? !1;
54
+ function B(e, t) {
55
+ return V.value.get(e)?.has(t) ?? !1;
51
56
  }
52
- function j(s, l) {
53
- if (o.readonly || o.roles.find((u) => u.key === s)?.locked) return;
54
- const t = o.modelValue[s] || [], d = t.includes(l) ? t.filter((u) => u !== l) : [...t, l];
55
- P("update:modelValue", { ...o.modelValue, [s]: d });
57
+ function q(e, t) {
58
+ if (o.readonly || o.roles.find((y) => y.key === e)?.locked) return;
59
+ const s = o.modelValue[e] || [], k = V.value.get(e)?.has(t) ? s.filter((y) => y !== t) : [...s, t];
60
+ M("update:modelValue", { ...o.modelValue, [e]: k });
56
61
  }
57
- function w(s, l) {
58
- const e = l.permissions.filter((t) => C(s, t.key));
59
- return e.length === 0 ? "none" : e.length === l.permissions.length ? "all" : "indeterminate";
62
+ function S(e, t) {
63
+ const l = V.value.get(e);
64
+ if (!l) return "none";
65
+ let s = 0;
66
+ for (const k of t.permissions)
67
+ l.has(k.key) && s++;
68
+ return s === 0 ? "none" : s === t.permissions.length ? "all" : "indeterminate";
60
69
  }
61
- function E(s, l) {
62
- if (o.readonly || o.roles.find((m) => m.key === s)?.locked) return;
63
- const t = w(s, l), d = l.permissions.map((m) => m.key), u = o.modelValue[s] || [];
64
- let V;
65
- if (t === "all")
66
- V = u.filter((m) => !d.includes(m));
67
- else {
68
- const m = d.filter((A) => !u.includes(A));
69
- V = [...u, ...m];
70
+ function A(e, t) {
71
+ if (o.readonly || o.roles.find((f) => f.key === e)?.locked) return;
72
+ const s = S(e, t), k = V.value.get(e) ?? /* @__PURE__ */ new Set(), y = o.modelValue[e] || [];
73
+ let m;
74
+ if (s === "all") {
75
+ const f = new Set(t.permissions.map((d) => d.key));
76
+ m = y.filter((d) => !f.has(d));
77
+ } else {
78
+ const f = t.permissions.filter((d) => !k.has(d.key)).map((d) => d.key);
79
+ m = [...y, ...f];
70
80
  }
71
- P("update:modelValue", { ...o.modelValue, [s]: V });
81
+ M("update:modelValue", { ...o.modelValue, [e]: m });
72
82
  }
73
- const k = _(() => o.size === "sm" ? "px-2 py-1" : "px-3 py-2"), b = _(() => o.size === "sm" ? "text-xs" : "text-sm");
74
- function H(s) {
75
- return o.modelValue[s]?.length || 0;
83
+ const b = _(() => o.size === "sm" ? "px-2 py-1" : "px-3 py-2"), g = _(() => o.size === "sm" ? "text-xs" : "text-sm");
84
+ function D(e) {
85
+ return o.modelValue[e]?.length || 0;
76
86
  }
77
- function q() {
78
- return o.groups.reduce((s, l) => s + l.permissions.length, 0);
87
+ function F() {
88
+ return o.groups.reduce((e, t) => e + t.permissions.length, 0);
79
89
  }
80
- return (s, l) => (n(), c("div", {
90
+ return (e, t) => (n(), c("div", {
81
91
  class: r(["permission-matrix", o.class])
82
92
  }, [
83
- i.searchable ? (n(), c("div", T, [
84
- B(Q, {
85
- modelValue: g.value,
86
- "onUpdate:modelValue": l[0] || (l[0] = (e) => g.value = e),
93
+ a.searchable ? (n(), c("div", J, [
94
+ $(U, {
95
+ modelValue: z.value,
96
+ "onUpdate:modelValue": t[0] || (t[0] = (l) => z.value = l),
87
97
  placeholder: "Search permissions...",
88
98
  icon: "lucide:search",
89
- size: i.size,
99
+ size: a.size,
90
100
  "show-clear-button": ""
91
101
  }, null, 8, ["modelValue", "size"])
92
- ])) : h("", !0),
93
- $.value.length === 0 ? (n(), c("div", U, [
94
- B(z, {
102
+ ])) : p("", !0),
103
+ G.value.length === 0 ? (n(), c("div", O, [
104
+ $(P, {
95
105
  icon: "lucide:search-x",
96
106
  class: "w-8 h-8 mx-auto mb-3 opacity-50"
97
107
  }),
98
- a("p", {
99
- class: r(b.value)
108
+ i("p", {
109
+ class: r(g.value)
100
110
  }, "No permissions match your search.", 2)
101
- ])) : (n(), c("div", I, [
102
- a("table", J, [
103
- a("thead", {
104
- class: r(i.stickyHeader ? "sticky top-0 z-10" : "")
111
+ ])) : (n(), c("div", W, [
112
+ i("table", X, [
113
+ i("thead", {
114
+ class: r(a.stickyHeader ? "sticky top-0 z-10" : "")
105
115
  }, [
106
- a("tr", O, [
107
- a("th", {
116
+ i("tr", Y, [
117
+ i("th", {
108
118
  class: r([
109
- k.value,
110
119
  b.value,
120
+ g.value,
111
121
  "text-left font-semibold text-foreground min-w-[220px] sm:min-w-[260px] bg-muted border-b"
112
122
  ])
113
123
  }, " Permission ", 2),
114
- (n(!0), c(y, null, v(i.roles, (e) => (n(), c("th", {
115
- key: e.key,
116
- class: r([k.value, "text-center border-b border-l bg-muted min-w-[100px]"])
124
+ (n(!0), c(h, null, w(a.roles, (l) => (n(), c("th", {
125
+ key: l.key,
126
+ class: r([b.value, "text-center border-b border-l bg-muted min-w-[100px]"])
117
127
  }, [
118
- a("div", W, [
119
- a("span", {
120
- class: r([b.value, "font-semibold text-foreground whitespace-nowrap"])
121
- }, x(e.label), 3),
122
- a("span", {
128
+ i("div", Z, [
129
+ i("span", {
130
+ class: r([g.value, "font-semibold text-foreground whitespace-nowrap"])
131
+ }, v(l.label), 3),
132
+ i("span", {
123
133
  class: r([o.size === "sm" ? "text-[10px]" : "text-xs", "text-muted-foreground"])
124
- }, x(H(e.key)) + "/" + x(q()), 3)
134
+ }, v(D(l.key)) + "/" + v(F()), 3)
125
135
  ])
126
136
  ], 2))), 128))
127
137
  ])
128
138
  ], 2),
129
- a("tbody", null, [
130
- (n(!0), c(y, null, v($.value, (e) => (n(), c(y, {
131
- key: e.key
139
+ i("tbody", null, [
140
+ (n(!0), c(h, null, w(G.value, (l) => (n(), c(h, {
141
+ key: l.key
132
142
  }, [
133
- a("tr", X, [
134
- a("td", {
135
- class: r([k.value, "border-b cursor-pointer select-none"]),
136
- onClick: (t) => N(e.key)
143
+ i("tr", K, [
144
+ i("td", {
145
+ class: r([b.value, "border-b cursor-pointer select-none"]),
146
+ onClick: (s) => H(l.key)
137
147
  }, [
138
- a("div", Z, [
139
- i.collapsible ? (n(), f(z, {
148
+ i("div", te, [
149
+ a.collapsible ? (n(), x(P, {
140
150
  key: 0,
141
151
  icon: "lucide:chevron-right",
142
- class: r(["w-3.5 h-3.5 transition-transform duration-200 text-muted-foreground", { "rotate-90": !p.value.has(e.key) }])
143
- }, null, 8, ["class"])) : h("", !0),
144
- e.icon ? (n(), f(z, {
152
+ class: r(["w-3.5 h-3.5 transition-transform duration-200 text-muted-foreground", { "rotate-90": !C.value.has(l.key) }])
153
+ }, null, 8, ["class"])) : p("", !0),
154
+ l.icon ? (n(), x(P, {
145
155
  key: 1,
146
- icon: e.icon,
156
+ icon: l.icon,
147
157
  class: "w-3.5 h-3.5 text-muted-foreground"
148
- }, null, 8, ["icon"])) : h("", !0),
149
- a("span", {
150
- class: r([b.value, "font-semibold text-foreground"])
151
- }, x(e.label), 3),
152
- a("span", {
158
+ }, null, 8, ["icon"])) : p("", !0),
159
+ i("span", {
160
+ class: r([g.value, "font-semibold text-foreground"])
161
+ }, v(l.label), 3),
162
+ i("span", {
153
163
  class: r([o.size === "sm" ? "text-[10px]" : "text-xs", "text-muted-foreground ml-1"])
154
- }, " (" + x(e.permissions.length) + ") ", 3)
164
+ }, " (" + v(l.permissions.length) + ") ", 3)
155
165
  ])
156
- ], 10, Y),
157
- (n(!0), c(y, null, v(i.roles, (t) => (n(), c("td", {
158
- key: t.key,
159
- class: r([k.value, "text-center border-b border-l cursor-pointer"]),
160
- onClick: (d) => E(t.key, e)
166
+ ], 10, ee),
167
+ (n(!0), c(h, null, w(a.roles, (s) => (n(), c("td", {
168
+ key: s.key,
169
+ class: r([b.value, "text-center border-b border-l cursor-pointer"]),
170
+ onClick: (k) => A(s.key, l)
161
171
  }, [
162
- a("div", ee, [
163
- i.toggleMode === "checkbox" ? (n(), f(G, {
172
+ i("div", le, [
173
+ a.toggleMode === "checkbox" ? (n(), x(N, {
164
174
  key: 0,
165
- "model-value": w(t.key, e) === "all",
166
- indeterminate: w(t.key, e) === "indeterminate",
167
- disabled: i.readonly || t.locked,
168
- size: i.size === "sm" ? "xs" : "sm"
169
- }, null, 8, ["model-value", "indeterminate", "disabled", "size"])) : (n(), f(L, {
175
+ "model-value": S(s.key, l) === "all",
176
+ indeterminate: S(s.key, l) === "indeterminate",
177
+ disabled: a.readonly || s.locked,
178
+ size: a.size === "sm" ? "xs" : "sm"
179
+ }, null, 8, ["model-value", "indeterminate", "disabled", "size"])) : (n(), x(j, {
170
180
  key: 1,
171
- "model-value": w(t.key, e) === "all",
172
- disabled: i.readonly || t.locked
181
+ "model-value": S(s.key, l) === "all",
182
+ disabled: a.readonly || s.locked
173
183
  }, null, 8, ["model-value", "disabled"]))
174
184
  ])
175
- ], 10, K))), 128))
185
+ ], 10, se))), 128))
176
186
  ]),
177
- p.value.has(e.key) ? h("", !0) : (n(!0), c(y, { key: 0 }, v(e.permissions, (t) => (n(), c("tr", {
178
- key: t.key,
179
- class: "hover:bg-accent/40 transition-colors duration-100"
180
- }, [
181
- a("td", {
182
- class: r([k.value, "border-b"])
183
- }, [
184
- a("div", te, [
185
- a("span", {
186
- class: r([b.value, "text-foreground"])
187
- }, x(t.label), 3),
188
- t.description ? (n(), f(R, {
189
- key: 0,
190
- content: t.description,
191
- placement: "top"
192
- }, {
193
- default: F(() => [
194
- B(z, {
195
- icon: "lucide:info",
196
- class: "w-3 h-3 text-muted-foreground cursor-auto shrink-0"
197
- })
198
- ]),
199
- _: 1
200
- }, 8, ["content"])) : h("", !0)
201
- ])
202
- ], 2),
203
- (n(!0), c(y, null, v(i.roles, (d) => (n(), c("td", {
204
- key: d.key,
205
- class: r([
206
- k.value,
207
- "text-center border-b border-l",
208
- !i.readonly && !d.locked ? "cursor-pointer" : ""
209
- ]),
210
- onClick: (u) => j(d.key, t.key)
187
+ C.value.has(l.key) ? p("", !0) : (n(!0), c(h, { key: 0 }, w(l.permissions, (s, k, y, m) => {
188
+ const f = [...a.roles.map((u) => B(u.key, s.key)), a.readonly];
189
+ if (m && m.key === s.key && R(m, f)) return m;
190
+ const d = (n(), c("tr", {
191
+ key: s.key,
192
+ class: "hover:bg-accent/40 transition-colors duration-100"
211
193
  }, [
212
- a("div", le, [
213
- i.toggleMode === "checkbox" ? (n(), f(G, {
214
- key: 0,
215
- "model-value": C(d.key, t.key),
216
- disabled: i.readonly || d.locked,
217
- size: i.size === "sm" ? "xs" : "sm"
218
- }, null, 8, ["model-value", "disabled", "size"])) : (n(), f(L, {
219
- key: 1,
220
- "model-value": C(d.key, t.key),
221
- disabled: i.readonly || d.locked
222
- }, null, 8, ["model-value", "disabled"]))
223
- ])
224
- ], 10, se))), 128))
225
- ]))), 128))
194
+ i("td", {
195
+ class: r([b.value, "border-b"])
196
+ }, [
197
+ i("div", ne, [
198
+ i("span", {
199
+ class: r([g.value, "text-foreground"])
200
+ }, v(s.label), 3),
201
+ s.description ? (n(), x(I, {
202
+ key: 0,
203
+ content: s.description,
204
+ placement: "top"
205
+ }, {
206
+ default: T(() => [
207
+ $(P, {
208
+ icon: "lucide:info",
209
+ class: "w-3 h-3 text-muted-foreground cursor-auto shrink-0"
210
+ })
211
+ ]),
212
+ _: 1
213
+ }, 8, ["content"])) : p("", !0)
214
+ ])
215
+ ], 2),
216
+ (n(!0), c(h, null, w(a.roles, (u) => (n(), c("td", {
217
+ key: u.key,
218
+ class: r([
219
+ b.value,
220
+ "text-center border-b border-l",
221
+ !a.readonly && !u.locked ? "cursor-pointer" : ""
222
+ ]),
223
+ onClick: (ie) => q(u.key, s.key)
224
+ }, [
225
+ i("div", ae, [
226
+ a.toggleMode === "checkbox" ? (n(), x(N, {
227
+ key: 0,
228
+ "model-value": B(u.key, s.key),
229
+ disabled: a.readonly || u.locked,
230
+ size: a.size === "sm" ? "xs" : "sm"
231
+ }, null, 8, ["model-value", "disabled", "size"])) : (n(), x(j, {
232
+ key: 1,
233
+ "model-value": B(u.key, s.key),
234
+ disabled: a.readonly || u.locked
235
+ }, null, 8, ["model-value", "disabled"]))
236
+ ])
237
+ ], 10, oe))), 128))
238
+ ]));
239
+ return d.memo = f, d;
240
+ }, t, 1), 128))
226
241
  ], 64))), 128))
227
242
  ])
228
243
  ])
@@ -231,5 +246,5 @@ const T = {
231
246
  }
232
247
  });
233
248
  export {
234
- ue as default
249
+ ye as default
235
250
  };
@@ -0,0 +1,13 @@
1
+ import { PermissionGroup, PermissionMatrixGroup } from './types';
2
+ /**
3
+ * Encapsulates search query, group-key filter, and collapsed-state management
4
+ * for both list and matrix layouts.
5
+ */
6
+ export declare function usePermissionSearch(isMatrix: () => boolean, getGroups: () => PermissionGroup[], getMatrixGroups: () => PermissionMatrixGroup[], defaultExpanded: () => string[]): {
7
+ searchQuery: import('vue').Ref<string, string>;
8
+ selectedGroupKeys: import('vue').Ref<string[], string[]>;
9
+ collapsedGroups: import('vue').Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
10
+ filteredGroups: import('vue').ComputedRef<PermissionGroup[]>;
11
+ filteredMatrixGroups: import('vue').ComputedRef<PermissionMatrixGroup[]>;
12
+ toggleGroupCollapse: (groupKey: string, collapsible: boolean) => void;
13
+ };
@@ -0,0 +1,71 @@
1
+ import { ref as d, onMounted as S, watch as b, computed as m } from "vue";
2
+ function p(f, i, c, C) {
3
+ const n = d(""), a = d([]), r = d(/* @__PURE__ */ new Set()), w = d(/* @__PURE__ */ new Set());
4
+ function v() {
5
+ const l = C();
6
+ if (l.length > 0) {
7
+ const t = (f() ? c() : i()).map((e) => e.key);
8
+ return new Set(t.filter((e) => !l.includes(e)));
9
+ }
10
+ return /* @__PURE__ */ new Set();
11
+ }
12
+ S(() => {
13
+ const l = v();
14
+ w.value = l, r.value = new Set(l);
15
+ }), b(n, (l) => {
16
+ if (!l.trim()) {
17
+ r.value = new Set(w.value);
18
+ return;
19
+ }
20
+ const t = l.toLowerCase(), e = /* @__PURE__ */ new Set();
21
+ if (f())
22
+ for (const s of c())
23
+ (s.label.toLowerCase().includes(t) || s.rows.some(
24
+ (u) => u.label.toLowerCase().includes(t) || u.key.toLowerCase().includes(t)
25
+ )) && e.add(s.key);
26
+ else
27
+ for (const s of i())
28
+ (s.label.toLowerCase().includes(t) || s.permissions.some(
29
+ (u) => u.label.toLowerCase().includes(t) || u.key.toLowerCase().includes(t)
30
+ )) && e.add(s.key);
31
+ const o = (f() ? c() : i()).map((s) => s.key);
32
+ r.value = new Set(o.filter((s) => !e.has(s)));
33
+ });
34
+ function L(l, t) {
35
+ if (!t) return;
36
+ const e = new Set(r.value);
37
+ e.has(l) ? e.delete(l) : e.add(l), r.value = e, n.value.trim() || (w.value = new Set(e));
38
+ }
39
+ const y = m(() => {
40
+ let l = i();
41
+ if (a.value.length > 0 && (l = l.filter((e) => a.value.includes(e.key))), !n.value.trim()) return l;
42
+ const t = n.value.toLowerCase();
43
+ return l.map((e) => {
44
+ const o = e.permissions.filter(
45
+ (s) => s.label.toLowerCase().includes(t) || s.key.toLowerCase().includes(t) || e.label.toLowerCase().includes(t)
46
+ );
47
+ return o.length === 0 ? null : { ...e, permissions: o };
48
+ }).filter(Boolean);
49
+ }), h = m(() => {
50
+ let l = c();
51
+ if (a.value.length > 0 && (l = l.filter((e) => a.value.includes(e.key))), !n.value.trim()) return l;
52
+ const t = n.value.toLowerCase();
53
+ return l.map((e) => {
54
+ const o = e.rows.filter(
55
+ (s) => s.label.toLowerCase().includes(t) || s.key.toLowerCase().includes(t) || e.label.toLowerCase().includes(t)
56
+ );
57
+ return o.length === 0 ? null : { ...e, rows: o };
58
+ }).filter(Boolean);
59
+ });
60
+ return {
61
+ searchQuery: n,
62
+ selectedGroupKeys: a,
63
+ collapsedGroups: r,
64
+ filteredGroups: y,
65
+ filteredMatrixGroups: h,
66
+ toggleGroupCollapse: L
67
+ };
68
+ }
69
+ export {
70
+ p as usePermissionSearch
71
+ };
@@ -0,0 +1,22 @@
1
+ import { PermissionGroup, PermissionMatrixGroup } from './types';
2
+ export type GroupToggleState = 'all' | 'none' | 'indeterminate';
3
+ /**
4
+ * Provides a cached Set<string> for O(1) permission lookups
5
+ * and helpers for group-level toggle state calculation.
6
+ *
7
+ * The permSet is a computed that rebuilds only when modelValue changes —
8
+ * every consumer (hasPerm, getGroupState, etc.) benefits from the same cache.
9
+ */
10
+ export declare function usePermissionState(getModelValue: () => string[]): {
11
+ permSet: import('vue').ComputedRef<Set<string>>;
12
+ hasPerm: (key: string) => boolean;
13
+ togglePerm: (key: string) => string[];
14
+ getGroupState: (group: PermissionGroup) => GroupToggleState;
15
+ toggleGroup: (group: PermissionGroup) => string[];
16
+ getMatrixGroupState: (group: PermissionMatrixGroup) => GroupToggleState;
17
+ toggleMatrixGroup: (group: PermissionMatrixGroup) => string[];
18
+ selectAllList: (groups: PermissionGroup[]) => string[];
19
+ deselectAllList: () => string[];
20
+ selectAllMatrix: (matrixGroups: PermissionMatrixGroup[], current: string[]) => string[];
21
+ deselectAllMatrix: (matrixGroups: PermissionMatrixGroup[], current: string[]) => string[];
22
+ };
@@ -0,0 +1,77 @@
1
+ import { computed as v } from "vue";
2
+ import { getAllMatrixKeys as u, getMatrixRowPermKeys as m } from "./utils.js";
3
+ function P(o) {
4
+ const a = v(() => new Set(o()));
5
+ function h(t) {
6
+ return a.value.has(t);
7
+ }
8
+ function S(t) {
9
+ return a.value.has(t) ? o().filter((n) => n !== t) : [...o(), t];
10
+ }
11
+ function c(t) {
12
+ const n = a.value;
13
+ let e = 0;
14
+ for (const r of t.permissions)
15
+ n.has(r.key) && e++;
16
+ return e === 0 ? "none" : e === t.permissions.length ? "all" : "indeterminate";
17
+ }
18
+ function p(t) {
19
+ const n = c(t), e = a.value;
20
+ if (n === "all") {
21
+ const i = new Set(t.permissions.map((s) => s.key));
22
+ return o().filter((s) => !i.has(s));
23
+ }
24
+ const r = t.permissions.filter((i) => !e.has(i.key)).map((i) => i.key);
25
+ return [...o(), ...r];
26
+ }
27
+ function f(t) {
28
+ const n = a.value;
29
+ let e = 0, r = 0;
30
+ for (const i of t.rows) {
31
+ const s = m(t.key, i, t.actions);
32
+ e += s.length;
33
+ for (const l of s)
34
+ n.has(l) && r++;
35
+ }
36
+ return e === 0 || r === 0 ? "none" : r === e ? "all" : "indeterminate";
37
+ }
38
+ function y(t) {
39
+ const n = f(t), e = t.rows.flatMap((s) => m(t.key, s, t.actions));
40
+ if (n === "all") {
41
+ const s = new Set(e);
42
+ return o().filter((l) => !s.has(l));
43
+ }
44
+ const r = a.value, i = e.filter((s) => !r.has(s));
45
+ return [...o(), ...i];
46
+ }
47
+ function k(t) {
48
+ return t.flatMap((n) => n.permissions.map((e) => e.key));
49
+ }
50
+ function w() {
51
+ return [];
52
+ }
53
+ function x(t, n) {
54
+ const e = u(t), r = new Set(e);
55
+ return [...n.filter((s) => !r.has(s)), ...e];
56
+ }
57
+ function A(t, n) {
58
+ const e = new Set(u(t));
59
+ return n.filter((r) => !e.has(r));
60
+ }
61
+ return {
62
+ permSet: a,
63
+ hasPerm: h,
64
+ togglePerm: S,
65
+ getGroupState: c,
66
+ toggleGroup: p,
67
+ getMatrixGroupState: f,
68
+ toggleMatrixGroup: y,
69
+ selectAllList: k,
70
+ deselectAllList: w,
71
+ selectAllMatrix: x,
72
+ deselectAllMatrix: A
73
+ };
74
+ }
75
+ export {
76
+ P as usePermissionState
77
+ };