doph-js 0.0.26 → 0.0.28
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/dophJs.js +130 -10
- package/dist/dophJs.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -1
package/dist/dophJs.js
CHANGED
|
@@ -1,18 +1,138 @@
|
|
|
1
|
-
import { openBlock as
|
|
2
|
-
const
|
|
1
|
+
import { useSlots as y, computed as d, h as m, openBlock as r, createBlock as S, unref as u, createElementBlock as c, Fragment as h, normalizeClass as p, renderSlot as g, createCommentVNode as _, createVNode as D, createElementVNode as f, resolveComponent as k, toDisplayString as B, renderList as v, getCurrentInstance as $, reactive as x } from "vue";
|
|
2
|
+
const z = {
|
|
3
|
+
__name: "BIcon",
|
|
4
|
+
props: {
|
|
5
|
+
component: Object,
|
|
6
|
+
size: [Number, String],
|
|
7
|
+
color: String
|
|
8
|
+
},
|
|
9
|
+
setup(t) {
|
|
10
|
+
const e = t, n = y(), l = d(() => {
|
|
11
|
+
const { color: o } = e;
|
|
12
|
+
return o === void 0 ? null : o;
|
|
13
|
+
}), a = d(() => {
|
|
14
|
+
const o = e.size ?? null;
|
|
15
|
+
if (o !== void 0)
|
|
16
|
+
return typeof o == "number" || /^\d+$/.test(o) ? `${o}px` : o;
|
|
17
|
+
}), i = m(
|
|
18
|
+
"i",
|
|
19
|
+
{
|
|
20
|
+
class: "icon",
|
|
21
|
+
style: {
|
|
22
|
+
color: l.value,
|
|
23
|
+
fontSize: a.value
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
e.component ? m(e.component) : n
|
|
27
|
+
);
|
|
28
|
+
return (o, b) => (r(), S(u(i)));
|
|
29
|
+
}
|
|
30
|
+
}, w = {
|
|
3
31
|
__name: "DButton",
|
|
4
32
|
props: {
|
|
5
|
-
class: String
|
|
33
|
+
class: String,
|
|
34
|
+
icon: Object
|
|
35
|
+
},
|
|
36
|
+
setup(t) {
|
|
37
|
+
const e = t;
|
|
38
|
+
let n = null;
|
|
39
|
+
return e.icon && (n = m(z, {
|
|
40
|
+
component: e.icon,
|
|
41
|
+
color: "inherit"
|
|
42
|
+
})), (l, a) => (r(), c(h, null, [
|
|
43
|
+
u(n) ? _("", !0) : (r(), c("div", {
|
|
44
|
+
key: 0,
|
|
45
|
+
class: p(["button", e.class])
|
|
46
|
+
}, [
|
|
47
|
+
g(l.$slots, "default")
|
|
48
|
+
], 2)),
|
|
49
|
+
u(n) ? (r(), c("div", {
|
|
50
|
+
key: 1,
|
|
51
|
+
class: p(["button button-ext", e.class])
|
|
52
|
+
}, [
|
|
53
|
+
D(u(n)),
|
|
54
|
+
f("div", null, [
|
|
55
|
+
g(l.$slots, "default")
|
|
56
|
+
])
|
|
57
|
+
], 2)) : _("", !0)
|
|
58
|
+
], 64));
|
|
59
|
+
}
|
|
60
|
+
}, C = { class: "tree-item" }, N = { key: 0 }, j = {
|
|
61
|
+
__name: "DTreeItem",
|
|
62
|
+
props: {
|
|
63
|
+
model: Object,
|
|
64
|
+
treeId: [String, Number]
|
|
6
65
|
},
|
|
7
66
|
setup(t) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
67
|
+
const e = t, n = d(() => e.model.children && e.model.children.length), l = (i) => {
|
|
68
|
+
s.mutations.setTreeSelect(e.treeId, e.model.id);
|
|
69
|
+
}, a = d(() => s.actions.isTreeSelected(e.treeId, e.model.id) ? "selected" : "");
|
|
70
|
+
return (i, o) => {
|
|
71
|
+
const b = k("d-tree-item", !0);
|
|
72
|
+
return r(), c("li", C, [
|
|
73
|
+
f("div", {
|
|
74
|
+
class: p(a.value),
|
|
75
|
+
onClick: l,
|
|
76
|
+
style: { display: "flex", "flex-direction": "row", "justify-content": "space-between", "align-items": "center" }
|
|
77
|
+
}, [
|
|
78
|
+
f("div", null, B(e.model.title), 1)
|
|
79
|
+
], 2),
|
|
80
|
+
n.value ? (r(), c("ul", N, [
|
|
81
|
+
(r(!0), c(h, null, v(t.model.children, (T) => (r(), S(b, {
|
|
82
|
+
class: "tree-item",
|
|
83
|
+
model: T,
|
|
84
|
+
treeId: e.treeId
|
|
85
|
+
}, null, 8, ["model", "treeId"]))), 256))
|
|
86
|
+
])) : _("", !0)
|
|
87
|
+
]);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}, O = { class: "tree" }, E = {
|
|
91
|
+
__name: "DTree",
|
|
92
|
+
props: {
|
|
93
|
+
items: Array,
|
|
94
|
+
noSelect: Boolean,
|
|
95
|
+
multiSelect: Boolean
|
|
96
|
+
},
|
|
97
|
+
setup(t) {
|
|
98
|
+
const e = t, n = $().uid;
|
|
99
|
+
return s.actions.initTreeStore(n, e.noSelect, e.multiSelect), (l, a) => (r(), c("ul", O, [
|
|
100
|
+
(r(!0), c(h, null, v(t.items, (i) => (r(), S(j, {
|
|
101
|
+
key: i.id,
|
|
102
|
+
model: i,
|
|
103
|
+
treeId: u(n)
|
|
104
|
+
}, null, 8, ["model", "treeId"]))), 128))
|
|
105
|
+
]));
|
|
106
|
+
}
|
|
107
|
+
}, s = {
|
|
108
|
+
state: x({
|
|
109
|
+
trees: {}
|
|
110
|
+
}),
|
|
111
|
+
getters: {
|
|
112
|
+
getTreeSelect(t) {
|
|
113
|
+
return s.state.trees[t].selected;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
mutations: {
|
|
117
|
+
setTreeSelect(t, e) {
|
|
118
|
+
s.state.trees[t].noSelect || (s.state.trees[t].multiSelect ? s.state.trees[t].selected.includes(e) ? s.state.trees[t].selected = s.state.trees[t].selected.filter(function(n) {
|
|
119
|
+
return n !== e;
|
|
120
|
+
}) : s.state.trees[t].selected = [...s.state.trees[t].selected, e] : s.state.trees[t].selected = [e]);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
actions: {
|
|
124
|
+
initTreeStore(t, e, n) {
|
|
125
|
+
s.state.trees[t] = [], s.state.trees[t].selected = [], s.state.trees[t].noSelect = e, s.state.trees[t].multiSelect = n;
|
|
126
|
+
},
|
|
127
|
+
isTreeSelected(t, e) {
|
|
128
|
+
return s.state.trees[t].selected.includes(e);
|
|
129
|
+
}
|
|
14
130
|
}
|
|
15
131
|
};
|
|
16
132
|
export {
|
|
17
|
-
|
|
133
|
+
w as DButton,
|
|
134
|
+
z as DIcon,
|
|
135
|
+
E as DTree,
|
|
136
|
+
j as DTreeItem,
|
|
137
|
+
s as DTreeStore
|
|
18
138
|
};
|
package/dist/dophJs.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.DophJs={},s.Vue))})(this,function(s,e){"use strict";const h="",T="",g="",y="",m={__name:"BIcon",props:{component:Object,size:[Number,String],color:String},setup(n){const t=n,c=e.useSlots(),r=e.computed(()=>{const{color:l}=t;return l===void 0?null:l}),a=e.computed(()=>{const l=t.size??null;if(l!==void 0)return typeof l=="number"||/^\d+$/.test(l)?`${l}px`:l}),i=e.h("i",{class:"icon",style:{color:r.value,fontSize:a.value}},t.component?e.h(t.component):c);return(l,p)=>(e.openBlock(),e.createBlock(e.unref(i)))}},f={__name:"DButton",props:{class:String,icon:Object},setup(n){const t=n;let c=null;return t.icon&&(c=e.h(m,{component:t.icon,color:"inherit"})),(r,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.unref(c)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["button",t.class])},[e.renderSlot(r.$slots,"default")],2)),e.unref(c)?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["button button-ext",t.class])},[e.createVNode(e.unref(c)),e.createElementVNode("div",null,[e.renderSlot(r.$slots,"default")])],2)):e.createCommentVNode("",!0)],64))}},u={class:"tree-item"},S={key:0},d={__name:"DTreeItem",props:{model:Object,treeId:[String,Number]},setup(n){const t=n,c=e.computed(()=>t.model.children&&t.model.children.length),r=i=>{o.mutations.setTreeSelect(t.treeId,t.model.id)},a=e.computed(()=>o.actions.isTreeSelected(t.treeId,t.model.id)?"selected":"");return(i,l)=>{const p=e.resolveComponent("d-tree-item",!0);return e.openBlock(),e.createElementBlock("li",u,[e.createElementVNode("div",{class:e.normalizeClass(a.value),onClick:r,style:{display:"flex","flex-direction":"row","justify-content":"space-between","align-items":"center"}},[e.createElementVNode("div",null,e.toDisplayString(t.model.title),1)],2),c.value?(e.openBlock(),e.createElementBlock("ul",S,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.model.children,B=>(e.openBlock(),e.createBlock(p,{class:"tree-item",model:B,treeId:t.treeId},null,8,["model","treeId"]))),256))])):e.createCommentVNode("",!0)])}}},_={class:"tree"},k={__name:"DTree",props:{items:Array,noSelect:Boolean,multiSelect:Boolean},setup(n){const t=n,c=e.getCurrentInstance().uid;return o.actions.initTreeStore(c,t.noSelect,t.multiSelect),(r,a)=>(e.openBlock(),e.createElementBlock("ul",_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.items,i=>(e.openBlock(),e.createBlock(d,{key:i.id,model:i,treeId:e.unref(c)},null,8,["model","treeId"]))),128))]))}},o={state:e.reactive({trees:{}}),getters:{getTreeSelect(n){return o.state.trees[n].selected}},mutations:{setTreeSelect(n,t){o.state.trees[n].noSelect||(o.state.trees[n].multiSelect?o.state.trees[n].selected.includes(t)?o.state.trees[n].selected=o.state.trees[n].selected.filter(function(c){return c!==t}):o.state.trees[n].selected=[...o.state.trees[n].selected,t]:o.state.trees[n].selected=[t])}},actions:{initTreeStore(n,t,c){o.state.trees[n]=[],o.state.trees[n].selected=[],o.state.trees[n].noSelect=t,o.state.trees[n].multiSelect=c},isTreeSelected(n,t){return o.state.trees[n].selected.includes(t)}}};s.DButton=f,s.DIcon=m,s.DTree=k,s.DTreeItem=d,s.DTreeStore=o,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|