@monashakeri/vue-smart-tree-select 1.0.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,297 @@
1
+ import { Fragment as e, Transition as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, createVNode as o, normalizeClass as s, openBlock as c, renderList as l, toDisplayString as u, vModelText as d, vShow as f, withCtx as p, withDirectives as m, withKeys as h, withModifiers as g } from "vue";
2
+ //#region \0plugin-vue:export-helper
3
+ var _ = (e, t) => {
4
+ let n = e.__vccOpts || e;
5
+ for (let [e, r] of t) n[e] = r;
6
+ return n;
7
+ }, v = {
8
+ name: "SmartTreeSelect",
9
+ props: {
10
+ modelValue: {
11
+ type: Array,
12
+ default: () => []
13
+ },
14
+ options: {
15
+ type: Array,
16
+ default: () => []
17
+ },
18
+ placeholder: {
19
+ type: String,
20
+ default: "انتخاب کنید"
21
+ },
22
+ searchPlaceholder: {
23
+ type: String,
24
+ default: "جست‌وجو در موارد..."
25
+ },
26
+ childTitleMode: {
27
+ type: String,
28
+ default: "child",
29
+ validator: (e) => ["child", "parent-child"].includes(e)
30
+ }
31
+ },
32
+ emits: ["update:modelValue", "change"],
33
+ data() {
34
+ return {
35
+ isDropdownOpen: !1,
36
+ searchQuery: "",
37
+ expandedGroups: {},
38
+ expandedDropdownGroups: {}
39
+ };
40
+ },
41
+ computed: {
42
+ selectedCount() {
43
+ return this.modelValue.length;
44
+ },
45
+ filteredOptions() {
46
+ let e = this.searchQuery.trim().toLocaleLowerCase("fa");
47
+ return e ? this.options.map((t) => {
48
+ let n = t.children || [], r = t.title.toLocaleLowerCase("fa").includes(e), i = n.filter((t) => t.title.toLocaleLowerCase("fa").includes(e));
49
+ return !r && !i.length ? null : {
50
+ ...t,
51
+ children: r ? n : i
52
+ };
53
+ }).filter(Boolean) : this.options;
54
+ },
55
+ groupedSelectedItems() {
56
+ let e = new Set(this.modelValue);
57
+ return this.options.map((t) => {
58
+ let n = (t.children || []).filter((t) => e.has(t._id));
59
+ return n.length ? {
60
+ parentId: t._id,
61
+ parentTitle: t.title,
62
+ children: n
63
+ } : null;
64
+ }).filter(Boolean);
65
+ }
66
+ },
67
+ watch: {
68
+ searchQuery(e) {
69
+ e.trim() && this.filteredOptions.forEach((e) => {
70
+ this.expandedDropdownGroups[e._id] = !0;
71
+ });
72
+ },
73
+ groupedSelectedItems: {
74
+ immediate: !0,
75
+ handler(e) {
76
+ e.forEach((e) => {
77
+ this.expandedGroups[e.parentId] === void 0 && (this.expandedGroups[e.parentId] = !0);
78
+ });
79
+ }
80
+ }
81
+ },
82
+ mounted() {
83
+ document.addEventListener("pointerdown", this.handleClickOutside);
84
+ },
85
+ beforeUnmount() {
86
+ document.removeEventListener("pointerdown", this.handleClickOutside);
87
+ },
88
+ methods: {
89
+ handleClickOutside(e) {
90
+ this.$refs.root?.contains(e.target) || this.closeDropdown();
91
+ },
92
+ openDropdown() {
93
+ this.isDropdownOpen = !0, this.$nextTick(() => {
94
+ this.$refs.searchInput?.focus();
95
+ });
96
+ },
97
+ closeDropdown() {
98
+ this.isDropdownOpen = !1, this.searchQuery = "";
99
+ },
100
+ toggleDropdown() {
101
+ this.isDropdownOpen ? this.closeDropdown() : this.openDropdown();
102
+ },
103
+ isExpanded(e) {
104
+ return !!this.expandedDropdownGroups[e];
105
+ },
106
+ toggleDropdownAccordion(e) {
107
+ this.expandedDropdownGroups[e] = !this.expandedDropdownGroups[e];
108
+ },
109
+ toggleAccordion(e) {
110
+ this.expandedGroups[e] = !this.expandedGroups[e];
111
+ },
112
+ formatChildTitle(e, t) {
113
+ return this.childTitleMode === "parent-child" ? `${e} - ${t}` : t;
114
+ },
115
+ isChildSelected(e) {
116
+ return this.modelValue.includes(e._id);
117
+ },
118
+ isParentSelected(e) {
119
+ return e.children?.length > 0 && e.children.every((e) => this.modelValue.includes(e._id));
120
+ },
121
+ isParentIndeterminate(e) {
122
+ let t = (e.children || []).filter((e) => this.modelValue.includes(e._id)).length;
123
+ return t > 0 && t < e.children.length;
124
+ },
125
+ updateValue(e) {
126
+ this.$emit("update:modelValue", e), this.$emit("change", e);
127
+ },
128
+ toggleChild(e) {
129
+ let t = this.isChildSelected(e) ? this.modelValue.filter((t) => t !== e._id) : [...this.modelValue, e._id];
130
+ this.updateValue(t);
131
+ },
132
+ toggleParent(e, t) {
133
+ let n = e.children.map((e) => e._id), r = t.target.checked ? [.../* @__PURE__ */ new Set([...this.modelValue, ...n])] : this.modelValue.filter((e) => !n.includes(e));
134
+ this.updateValue(r);
135
+ },
136
+ clearAll() {
137
+ this.updateValue([]);
138
+ },
139
+ removeChild(e) {
140
+ this.updateValue(this.modelValue.filter((t) => t !== e._id));
141
+ },
142
+ removeGroup(e) {
143
+ let t = new Set(e.children.map((e) => e._id));
144
+ this.updateValue(this.modelValue.filter((e) => !t.has(e)));
145
+ }
146
+ }
147
+ }, y = ["aria-expanded"], b = { class: "select-trigger__content" }, x = {
148
+ key: 0,
149
+ class: "count-badge"
150
+ }, S = { class: "select-trigger__label" }, C = { class: "select-trigger__actions" }, w = { class: "dropdown__header" }, T = { class: "search-box" }, E = ["placeholder"], D = { class: "selection-summary" }, O = {
151
+ class: "tree-list",
152
+ role: "listbox",
153
+ "aria-multiselectable": "true"
154
+ }, k = { class: "parent-row" }, A = { class: "check-control" }, j = [
155
+ "checked",
156
+ "indeterminate",
157
+ "aria-label",
158
+ "onChange"
159
+ ], M = ["aria-expanded", "onClick"], N = { class: "parent-toggle__title" }, P = { class: "parent-toggle__count" }, F = {
160
+ key: 0,
161
+ class: "children-list"
162
+ }, I = ["checked", "onChange"], L = {
163
+ key: 0,
164
+ class: "empty-state"
165
+ }, R = {
166
+ key: 0,
167
+ class: "selected-groups"
168
+ }, z = { class: "selected-group__header" }, B = ["aria-expanded", "onClick"], V = { class: "parent-toggle__count" }, H = ["aria-label", "onClick"], U = { class: "chips" }, W = ["aria-label", "onClick"];
169
+ function G(_, v, G, K, q, J) {
170
+ return c(), r("div", {
171
+ ref: "root",
172
+ class: "smart-tree-select",
173
+ dir: "rtl",
174
+ onKeydown: v[9] ||= h((...e) => J.closeDropdown && J.closeDropdown(...e), ["esc"])
175
+ }, [
176
+ i("button", {
177
+ type: "button",
178
+ class: s(["select-trigger", { "is-open": q.isDropdownOpen }]),
179
+ "aria-expanded": String(q.isDropdownOpen),
180
+ "aria-haspopup": "listbox",
181
+ onClick: v[2] ||= (...e) => J.toggleDropdown && J.toggleDropdown(...e),
182
+ onKeydown: [v[3] ||= h(g((...e) => J.openDropdown && J.openDropdown(...e), ["prevent"]), ["down"]), v[4] ||= h(g((...e) => J.toggleDropdown && J.toggleDropdown(...e), ["prevent"]), ["enter"])]
183
+ }, [i("span", b, [J.selectedCount ? (c(), r("span", x, u(J.selectedCount), 1)) : n("", !0), i("span", S, u(J.selectedCount ? `${J.selectedCount} مورد انتخاب شده` : G.placeholder), 1)]), i("span", C, [J.selectedCount ? (c(), r("span", {
184
+ key: 0,
185
+ class: "clear-button",
186
+ role: "button",
187
+ tabindex: "0",
188
+ "aria-label": "پاک کردن انتخاب‌ها",
189
+ onClick: v[0] ||= g((...e) => J.clearAll && J.clearAll(...e), ["stop"]),
190
+ onKeydown: v[1] ||= h(g((...e) => J.clearAll && J.clearAll(...e), ["stop", "prevent"]), ["enter"])
191
+ }, " × ", 32)) : n("", !0), (c(), r("svg", {
192
+ class: s(["chevron", { "is-open": q.isDropdownOpen }]),
193
+ viewBox: "0 0 20 20"
194
+ }, [...v[10] ||= [i("path", { d: "m5 7 5 5 5-5" }, null, -1)]], 2))])], 42, y),
195
+ o(t, { name: "tree-dropdown" }, {
196
+ default: p(() => [q.isDropdownOpen ? (c(), r("section", {
197
+ key: 0,
198
+ class: "dropdown",
199
+ onClick: v[8] ||= g(() => {}, ["stop"])
200
+ }, [i("div", w, [i("div", T, [
201
+ v[11] ||= i("svg", {
202
+ viewBox: "0 0 20 20",
203
+ "aria-hidden": "true"
204
+ }, [i("circle", {
205
+ cx: "8.5",
206
+ cy: "8.5",
207
+ r: "5.5"
208
+ }), i("path", { d: "m13 13 4 4" })], -1),
209
+ m(i("input", {
210
+ ref: "searchInput",
211
+ "onUpdate:modelValue": v[5] ||= (e) => q.searchQuery = e,
212
+ type: "search",
213
+ autocomplete: "off",
214
+ placeholder: G.searchPlaceholder,
215
+ "aria-label": "جست‌وجو در گزینه‌ها"
216
+ }, null, 8, E), [[d, q.searchQuery]]),
217
+ q.searchQuery ? (c(), r("button", {
218
+ key: 0,
219
+ type: "button",
220
+ class: "search-clear",
221
+ "aria-label": "پاک کردن جست‌وجو",
222
+ onClick: v[6] ||= (e) => q.searchQuery = ""
223
+ }, " × ")) : n("", !0)
224
+ ]), i("div", D, [i("span", null, u(J.selectedCount ? `${J.selectedCount} انتخاب شده` : "هنوز موردی انتخاب نشده"), 1), J.selectedCount ? (c(), r("button", {
225
+ key: 0,
226
+ type: "button",
227
+ class: "text-button",
228
+ onClick: v[7] ||= (...e) => J.clearAll && J.clearAll(...e)
229
+ }, " حذف همه ")) : n("", !0)])]), i("div", O, [(c(!0), r(e, null, l(J.filteredOptions, (a) => (c(), r("article", {
230
+ key: a._id,
231
+ class: "tree-group"
232
+ }, [i("div", k, [i("label", A, [i("input", {
233
+ type: "checkbox",
234
+ checked: J.isParentSelected(a),
235
+ indeterminate: J.isParentIndeterminate(a),
236
+ "aria-label": `انتخاب همه موارد ${a.title}`,
237
+ onChange: (e) => J.toggleParent(a, e)
238
+ }, null, 40, j), v[12] ||= i("span", {
239
+ class: "check-control__box",
240
+ "aria-hidden": "true"
241
+ }, [i("svg", { viewBox: "0 0 16 16" }, [i("path", { d: "m3 8 3 3 7-7" })])], -1)]), i("button", {
242
+ type: "button",
243
+ class: "parent-toggle",
244
+ "aria-expanded": String(J.isExpanded(a._id)),
245
+ onClick: (e) => J.toggleDropdownAccordion(a._id)
246
+ }, [
247
+ i("span", N, u(a.title), 1),
248
+ i("span", P, u(a.children.length), 1),
249
+ (c(), r("svg", {
250
+ class: s(["group-chevron", { "is-open": J.isExpanded(a._id) }]),
251
+ viewBox: "0 0 20 20"
252
+ }, [...v[13] ||= [i("path", { d: "m5 7 5 5 5-5" }, null, -1)]], 2))
253
+ ], 8, M)]), o(t, { name: "tree-children" }, {
254
+ default: p(() => [J.isExpanded(a._id) && a.children.length ? (c(), r("div", F, [(c(!0), r(e, null, l(a.children, (e) => (c(), r("label", {
255
+ key: e._id,
256
+ class: s(["child-row", { "is-selected": J.isChildSelected(e) }])
257
+ }, [
258
+ i("input", {
259
+ type: "checkbox",
260
+ checked: J.isChildSelected(e),
261
+ onChange: (t) => J.toggleChild(e)
262
+ }, null, 40, I),
263
+ v[14] ||= i("span", { class: "native-check" }, null, -1),
264
+ i("span", null, u(J.formatChildTitle(a.title, e.title)), 1)
265
+ ], 2))), 128))])) : n("", !0)]),
266
+ _: 2
267
+ }, 1024)]))), 128)), J.filteredOptions.length ? n("", !0) : (c(), r("div", L, [...v[15] ||= [i("strong", null, "نتیجه‌ای پیدا نشد", -1), i("span", null, "عبارت جست‌وجو را تغییر دهید.", -1)]]))])])) : n("", !0)]),
268
+ _: 1
269
+ }),
270
+ J.groupedSelectedItems.length ? (c(), r("section", R, [(c(!0), r(e, null, l(J.groupedSelectedItems, (t) => (c(), r("div", {
271
+ key: t.parentId,
272
+ class: "selected-group"
273
+ }, [i("div", z, [i("button", {
274
+ type: "button",
275
+ class: "selected-group__toggle",
276
+ "aria-expanded": String(q.expandedGroups[t.parentId]),
277
+ onClick: (e) => J.toggleAccordion(t.parentId)
278
+ }, [i("span", null, u(t.parentTitle), 1), i("span", V, u(t.children.length), 1)], 8, B), i("button", {
279
+ type: "button",
280
+ class: "remove-group",
281
+ "aria-label": `حذف تمام موارد ${t.parentTitle}`,
282
+ onClick: (e) => J.removeGroup(t)
283
+ }, " حذف همه ", 8, H)]), m(i("div", U, [(c(!0), r(e, null, l(t.children, (e) => (c(), r("span", {
284
+ key: e._id,
285
+ class: "chip"
286
+ }, [a(u(J.formatChildTitle(t.parentTitle, e.title)) + " ", 1), i("button", {
287
+ type: "button",
288
+ "aria-label": `حذف ${J.formatChildTitle(t.parentTitle, e.title)}`,
289
+ onClick: (t) => J.removeChild(e)
290
+ }, " × ", 8, W)]))), 128))], 512), [[f, q.expandedGroups[t.parentId]]])]))), 128))])) : n("", !0)
291
+ ], 544);
292
+ }
293
+ //#endregion
294
+ //#region src/index.js
295
+ var K = /* @__PURE__ */ _(v, [["render", G], ["__scopeId", "data-v-31e70ee7"]]);
296
+ //#endregion
297
+ export { K as default };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t(require("vue")):typeof define==`function`&&define.amd?define([`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,e.VueSmartTreeSelect=t(e.Vue))})(this,function(e){var t=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},n={name:`SmartTreeSelect`,props:{modelValue:{type:Array,default:()=>[]},options:{type:Array,default:()=>[]},placeholder:{type:String,default:`انتخاب کنید`},searchPlaceholder:{type:String,default:`جست‌وجو در موارد...`},childTitleMode:{type:String,default:`child`,validator:e=>[`child`,`parent-child`].includes(e)}},emits:[`update:modelValue`,`change`],data(){return{isDropdownOpen:!1,searchQuery:``,expandedGroups:{},expandedDropdownGroups:{}}},computed:{selectedCount(){return this.modelValue.length},filteredOptions(){let e=this.searchQuery.trim().toLocaleLowerCase(`fa`);return e?this.options.map(t=>{let n=t.children||[],r=t.title.toLocaleLowerCase(`fa`).includes(e),i=n.filter(t=>t.title.toLocaleLowerCase(`fa`).includes(e));return!r&&!i.length?null:{...t,children:r?n:i}}).filter(Boolean):this.options},groupedSelectedItems(){let e=new Set(this.modelValue);return this.options.map(t=>{let n=(t.children||[]).filter(t=>e.has(t._id));return n.length?{parentId:t._id,parentTitle:t.title,children:n}:null}).filter(Boolean)}},watch:{searchQuery(e){e.trim()&&this.filteredOptions.forEach(e=>{this.expandedDropdownGroups[e._id]=!0})},groupedSelectedItems:{immediate:!0,handler(e){e.forEach(e=>{this.expandedGroups[e.parentId]===void 0&&(this.expandedGroups[e.parentId]=!0)})}}},mounted(){document.addEventListener(`pointerdown`,this.handleClickOutside)},beforeUnmount(){document.removeEventListener(`pointerdown`,this.handleClickOutside)},methods:{handleClickOutside(e){this.$refs.root?.contains(e.target)||this.closeDropdown()},openDropdown(){this.isDropdownOpen=!0,this.$nextTick(()=>{this.$refs.searchInput?.focus()})},closeDropdown(){this.isDropdownOpen=!1,this.searchQuery=``},toggleDropdown(){this.isDropdownOpen?this.closeDropdown():this.openDropdown()},isExpanded(e){return!!this.expandedDropdownGroups[e]},toggleDropdownAccordion(e){this.expandedDropdownGroups[e]=!this.expandedDropdownGroups[e]},toggleAccordion(e){this.expandedGroups[e]=!this.expandedGroups[e]},formatChildTitle(e,t){return this.childTitleMode===`parent-child`?`${e} - ${t}`:t},isChildSelected(e){return this.modelValue.includes(e._id)},isParentSelected(e){return e.children?.length>0&&e.children.every(e=>this.modelValue.includes(e._id))},isParentIndeterminate(e){let t=(e.children||[]).filter(e=>this.modelValue.includes(e._id)).length;return t>0&&t<e.children.length},updateValue(e){this.$emit(`update:modelValue`,e),this.$emit(`change`,e)},toggleChild(e){let t=this.isChildSelected(e)?this.modelValue.filter(t=>t!==e._id):[...this.modelValue,e._id];this.updateValue(t)},toggleParent(e,t){let n=e.children.map(e=>e._id),r=t.target.checked?[...new Set([...this.modelValue,...n])]:this.modelValue.filter(e=>!n.includes(e));this.updateValue(r)},clearAll(){this.updateValue([])},removeChild(e){this.updateValue(this.modelValue.filter(t=>t!==e._id))},removeGroup(e){let t=new Set(e.children.map(e=>e._id));this.updateValue(this.modelValue.filter(e=>!t.has(e)))}}},r=[`aria-expanded`],i={class:`select-trigger__content`},a={key:0,class:`count-badge`},o={class:`select-trigger__label`},s={class:`select-trigger__actions`},c={class:`dropdown__header`},l={class:`search-box`},u=[`placeholder`],d={class:`selection-summary`},f={class:`tree-list`,role:`listbox`,"aria-multiselectable":`true`},p={class:`parent-row`},m={class:`check-control`},h=[`checked`,`indeterminate`,`aria-label`,`onChange`],g=[`aria-expanded`,`onClick`],_={class:`parent-toggle__title`},v={class:`parent-toggle__count`},y={key:0,class:`children-list`},b=[`checked`,`onChange`],x={key:0,class:`empty-state`},S={key:0,class:`selected-groups`},C={class:`selected-group__header`},w=[`aria-expanded`,`onClick`],T={class:`parent-toggle__count`},E=[`aria-label`,`onClick`],D={class:`chips`},O=[`aria-label`,`onClick`];function k(t,n,k,A,j,M){return(0,e.openBlock)(),(0,e.createElementBlock)(`div`,{ref:`root`,class:`smart-tree-select`,dir:`rtl`,onKeydown:n[9]||=(0,e.withKeys)((...e)=>M.closeDropdown&&M.closeDropdown(...e),[`esc`])},[(0,e.createElementVNode)(`button`,{type:`button`,class:(0,e.normalizeClass)([`select-trigger`,{"is-open":j.isDropdownOpen}]),"aria-expanded":String(j.isDropdownOpen),"aria-haspopup":`listbox`,onClick:n[2]||=(...e)=>M.toggleDropdown&&M.toggleDropdown(...e),onKeydown:[n[3]||=(0,e.withKeys)((0,e.withModifiers)((...e)=>M.openDropdown&&M.openDropdown(...e),[`prevent`]),[`down`]),n[4]||=(0,e.withKeys)((0,e.withModifiers)((...e)=>M.toggleDropdown&&M.toggleDropdown(...e),[`prevent`]),[`enter`])]},[(0,e.createElementVNode)(`span`,i,[M.selectedCount?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,a,(0,e.toDisplayString)(M.selectedCount),1)):(0,e.createCommentVNode)(``,!0),(0,e.createElementVNode)(`span`,o,(0,e.toDisplayString)(M.selectedCount?`${M.selectedCount} مورد انتخاب شده`:k.placeholder),1)]),(0,e.createElementVNode)(`span`,s,[M.selectedCount?((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:0,class:`clear-button`,role:`button`,tabindex:`0`,"aria-label":`پاک کردن انتخاب‌ها`,onClick:n[0]||=(0,e.withModifiers)((...e)=>M.clearAll&&M.clearAll(...e),[`stop`]),onKeydown:n[1]||=(0,e.withKeys)((0,e.withModifiers)((...e)=>M.clearAll&&M.clearAll(...e),[`stop`,`prevent`]),[`enter`])},` × `,32)):(0,e.createCommentVNode)(``,!0),((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,{class:(0,e.normalizeClass)([`chevron`,{"is-open":j.isDropdownOpen}]),viewBox:`0 0 20 20`},[...n[10]||=[(0,e.createElementVNode)(`path`,{d:`m5 7 5 5 5-5`},null,-1)]],2))])],42,r),(0,e.createVNode)(e.Transition,{name:`tree-dropdown`},{default:(0,e.withCtx)(()=>[j.isDropdownOpen?((0,e.openBlock)(),(0,e.createElementBlock)(`section`,{key:0,class:`dropdown`,onClick:n[8]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.createElementVNode)(`div`,c,[(0,e.createElementVNode)(`div`,l,[n[11]||=(0,e.createElementVNode)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`},[(0,e.createElementVNode)(`circle`,{cx:`8.5`,cy:`8.5`,r:`5.5`}),(0,e.createElementVNode)(`path`,{d:`m13 13 4 4`})],-1),(0,e.withDirectives)((0,e.createElementVNode)(`input`,{ref:`searchInput`,"onUpdate:modelValue":n[5]||=e=>j.searchQuery=e,type:`search`,autocomplete:`off`,placeholder:k.searchPlaceholder,"aria-label":`جست‌وجو در گزینه‌ها`},null,8,u),[[e.vModelText,j.searchQuery]]),j.searchQuery?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,type:`button`,class:`search-clear`,"aria-label":`پاک کردن جست‌وجو`,onClick:n[6]||=e=>j.searchQuery=``},` × `)):(0,e.createCommentVNode)(``,!0)]),(0,e.createElementVNode)(`div`,d,[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(M.selectedCount?`${M.selectedCount} انتخاب شده`:`هنوز موردی انتخاب نشده`),1),M.selectedCount?((0,e.openBlock)(),(0,e.createElementBlock)(`button`,{key:0,type:`button`,class:`text-button`,onClick:n[7]||=(...e)=>M.clearAll&&M.clearAll(...e)},` حذف همه `)):(0,e.createCommentVNode)(``,!0)])]),(0,e.createElementVNode)(`div`,f,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(M.filteredOptions,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`article`,{key:t._id,class:`tree-group`},[(0,e.createElementVNode)(`div`,p,[(0,e.createElementVNode)(`label`,m,[(0,e.createElementVNode)(`input`,{type:`checkbox`,checked:M.isParentSelected(t),indeterminate:M.isParentIndeterminate(t),"aria-label":`انتخاب همه موارد ${t.title}`,onChange:e=>M.toggleParent(t,e)},null,40,h),n[12]||=(0,e.createElementVNode)(`span`,{class:`check-control__box`,"aria-hidden":`true`},[(0,e.createElementVNode)(`svg`,{viewBox:`0 0 16 16`},[(0,e.createElementVNode)(`path`,{d:`m3 8 3 3 7-7`})])],-1)]),(0,e.createElementVNode)(`button`,{type:`button`,class:`parent-toggle`,"aria-expanded":String(M.isExpanded(t._id)),onClick:e=>M.toggleDropdownAccordion(t._id)},[(0,e.createElementVNode)(`span`,_,(0,e.toDisplayString)(t.title),1),(0,e.createElementVNode)(`span`,v,(0,e.toDisplayString)(t.children.length),1),((0,e.openBlock)(),(0,e.createElementBlock)(`svg`,{class:(0,e.normalizeClass)([`group-chevron`,{"is-open":M.isExpanded(t._id)}]),viewBox:`0 0 20 20`},[...n[13]||=[(0,e.createElementVNode)(`path`,{d:`m5 7 5 5 5-5`},null,-1)]],2))],8,g)]),(0,e.createVNode)(e.Transition,{name:`tree-children`},{default:(0,e.withCtx)(()=>[M.isExpanded(t._id)&&t.children.length?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,y,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.children,r=>((0,e.openBlock)(),(0,e.createElementBlock)(`label`,{key:r._id,class:(0,e.normalizeClass)([`child-row`,{"is-selected":M.isChildSelected(r)}])},[(0,e.createElementVNode)(`input`,{type:`checkbox`,checked:M.isChildSelected(r),onChange:e=>M.toggleChild(r)},null,40,b),n[14]||=(0,e.createElementVNode)(`span`,{class:`native-check`},null,-1),(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(M.formatChildTitle(t.title,r.title)),1)],2))),128))])):(0,e.createCommentVNode)(``,!0)]),_:2},1024)]))),128)),M.filteredOptions.length?(0,e.createCommentVNode)(``,!0):((0,e.openBlock)(),(0,e.createElementBlock)(`div`,x,[...n[15]||=[(0,e.createElementVNode)(`strong`,null,`نتیجه‌ای پیدا نشد`,-1),(0,e.createElementVNode)(`span`,null,`عبارت جست‌وجو را تغییر دهید.`,-1)]]))])])):(0,e.createCommentVNode)(``,!0)]),_:1}),M.groupedSelectedItems.length?((0,e.openBlock)(),(0,e.createElementBlock)(`section`,S,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(M.groupedSelectedItems,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t.parentId,class:`selected-group`},[(0,e.createElementVNode)(`div`,C,[(0,e.createElementVNode)(`button`,{type:`button`,class:`selected-group__toggle`,"aria-expanded":String(j.expandedGroups[t.parentId]),onClick:e=>M.toggleAccordion(t.parentId)},[(0,e.createElementVNode)(`span`,null,(0,e.toDisplayString)(t.parentTitle),1),(0,e.createElementVNode)(`span`,T,(0,e.toDisplayString)(t.children.length),1)],8,w),(0,e.createElementVNode)(`button`,{type:`button`,class:`remove-group`,"aria-label":`حذف تمام موارد ${t.parentTitle}`,onClick:e=>M.removeGroup(t)},` حذف همه `,8,E)]),(0,e.withDirectives)((0,e.createElementVNode)(`div`,D,[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(t.children,n=>((0,e.openBlock)(),(0,e.createElementBlock)(`span`,{key:n._id,class:`chip`},[(0,e.createTextVNode)((0,e.toDisplayString)(M.formatChildTitle(t.parentTitle,n.title))+` `,1),(0,e.createElementVNode)(`button`,{type:`button`,"aria-label":`حذف ${M.formatChildTitle(t.parentTitle,n.title)}`,onClick:e=>M.removeChild(n)},` × `,8,O)]))),128))],512),[[e.vShow,j.expandedGroups[t.parentId]]])]))),128))])):(0,e.createCommentVNode)(``,!0)],544)}return t(n,[[`render`,k],[`__scopeId`,`data-v-31e70ee7`]])});
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@monashakeri/vue-smart-tree-select",
3
+ "version": "1.0.0",
4
+ "description": "A customizable RTL-friendly tree select component for Vue 2.",
5
+ "main": "./dist/vue-smart-tree-select.umd.js",
6
+ "module": "./dist/vue-smart-tree-select.es.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/vue-smart-tree-select.es.js",
10
+ "require": "./dist/vue-smart-tree-select.umd.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "keywords": [
17
+ "vue",
18
+ "vue3",
19
+ "tree-select",
20
+ "multiselect",
21
+ "rtl",
22
+ "persian",
23
+ "farsi",
24
+ "vazirmatn"
25
+ ],
26
+ "author": "Mona Shakeri",
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/monashakerii/vue-smart-tree-select.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/monashakerii/vue-smart-tree-select/issues"
34
+ },
35
+ "homepage": "https://github.com/monashakerii/vue-smart-tree-select#readme",
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "registry": "https://registry.npmjs.org/"
39
+ },
40
+ "scripts": {
41
+ "dev": "vite",
42
+ "build": "vite build",
43
+ "build:lib": "vite build --config vite.lib.config.mjs",
44
+ "prepublishOnly": "npm run build:lib"
45
+ },
46
+ "dependencies": {
47
+ "@fontsource/vazirmatn": "^5.3.0",
48
+ "vue": "^3.5.42"
49
+ },
50
+ "devDependencies": {
51
+ "@vitejs/plugin-vue": "^6.0.8"
52
+ }
53
+ }