clbs-libs-ui 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,165 @@
1
+ import { createBlock as e, createCommentVNode as t, createElementBlock as n, createElementVNode as r, createTextVNode as i, createVNode as a, normalizeStyle as o, openBlock as s, ref as c, resolveComponent as l, toDisplayString as u, unref as d, withCtx as f } from "vue";
2
+ //#region src/pages/FavoriteModal.vue
3
+ var p = { style: { "max-width": "800px" } }, m = { key: 0 }, h = { key: 1 }, g = 75, _ = {
4
+ __name: "FavoriteModal",
5
+ props: {
6
+ type: {
7
+ type: String,
8
+ required: !0
9
+ },
10
+ miniState: {
11
+ type: Boolean,
12
+ required: !0
13
+ },
14
+ api: {
15
+ type: Object,
16
+ required: !0
17
+ },
18
+ stores: {
19
+ type: Object,
20
+ required: !0
21
+ },
22
+ constants: {
23
+ type: Object,
24
+ required: !0
25
+ },
26
+ ui: {
27
+ type: Object,
28
+ required: !0
29
+ }
30
+ },
31
+ setup(_) {
32
+ let v = _, { ModalViewSmall: y, CloseButton: b, LoadingComponent: x, EmptyData: S, ContentBtn: C, SearchInput: w, FavoriteOutlineIcon: T, FavoriteIcon: E, Dots: D, HomeIcon: O, EmailIcon: k } = v.ui, A = c("SUPPORT"), j = c(""), M = c(!1), N = c({
33
+ WIKI: [],
34
+ LMS: [],
35
+ SUPPORT: []
36
+ });
37
+ c({
38
+ WIKI: {
39
+ page: 1,
40
+ rowsPerPage: 18,
41
+ rowsNumber: 0
42
+ },
43
+ LMS: {
44
+ page: 1,
45
+ rowsPerPage: 18,
46
+ rowsNumber: 0
47
+ },
48
+ SUPPORT: {
49
+ page: 1,
50
+ rowsPerPage: 18,
51
+ rowsNumber: 0
52
+ }
53
+ });
54
+ let P = async (e) => {
55
+ A.value = e, await F();
56
+ }, F = async () => {
57
+ M.value = !0;
58
+ try {
59
+ let e;
60
+ e = v.type === "history" ? await v.api.fetchHistory() : A.value === "SUPPORT" ? await v.api.fetchFavoritesTasksRows() : await v.api.fetchFavorites({
61
+ query: j.value,
62
+ type: A.value.toLowerCase()
63
+ }), N.value[A.value] = e?.data || [];
64
+ } catch (e) {
65
+ console.error(e), v.stores?.notifications?.cancel?.(e.message);
66
+ }
67
+ M.value = !1;
68
+ }, I = async (e) => {
69
+ try {
70
+ e.favorite === 0 ? await v.api.fetchAddFavorite(e.idPage, A.value) && (e.favorite = 1) : await v.api.fetchDeleteFavorite(e.idPage, A.value) && (e.favorite = 0);
71
+ } catch (e) {
72
+ console.error(e), v.stores?.notifications?.cancel?.(e.message);
73
+ }
74
+ }, L = (e) => {
75
+ let { WIKI_URL: t, LMS_URL: n } = v.constants;
76
+ A.value === "SUPPORT" && window.open(e.url, "_blank"), A.value === "WIKI" && window.open(`${t}/${e.idPage}`, "_blank"), A.value === "LMS" && window.open(`${n}/#/course/${e.idPage}`, "_blank");
77
+ };
78
+ return (c, v) => {
79
+ let O = l("q-tab"), k = l("q-tabs"), F = l("q-btn"), R = l("q-td"), z = l("q-tr"), B = l("q-table"), V = l("q-tab-panel"), H = l("q-tab-panels"), U = l("q-card");
80
+ return s(), e(d(y), {
81
+ "modal-open": !0,
82
+ "mini-state": _.miniState
83
+ }, {
84
+ default: f(() => [a(U, {
85
+ style: o({ left: _.miniState ? "57px" : "240px" }),
86
+ class: "modal"
87
+ }, {
88
+ default: f(() => [a(d(b)), r("div", p, [
89
+ a(d(w), {
90
+ modelValue: j.value,
91
+ "onUpdate:modelValue": v[0] ||= (e) => j.value = e
92
+ }, null, 8, ["modelValue"]),
93
+ a(k, {
94
+ modelValue: A.value,
95
+ "onUpdate:modelValue": v[4] ||= (e) => A.value = e,
96
+ dense: "",
97
+ "active-color": "primary",
98
+ "indicator-color": "primary",
99
+ align: "justify"
100
+ }, {
101
+ default: f(() => [
102
+ _.type === "favorites" ? (s(), e(O, {
103
+ key: 0,
104
+ name: "SUPPORT",
105
+ label: "Support",
106
+ onClick: v[1] ||= (e) => P("SUPPORT")
107
+ })) : t("", !0),
108
+ a(O, {
109
+ name: "WIKI",
110
+ label: "Wiki",
111
+ onClick: v[2] ||= (e) => P("WIKI")
112
+ }),
113
+ a(O, {
114
+ name: "LMS",
115
+ label: "Learning",
116
+ onClick: v[3] ||= (e) => P("LMS")
117
+ })
118
+ ]),
119
+ _: 1
120
+ }, 8, ["modelValue"]),
121
+ a(H, {
122
+ modelValue: A.value,
123
+ "onUpdate:modelValue": v[5] ||= (e) => A.value = e
124
+ }, {
125
+ default: f(() => [a(V, { name: "WIKI" }, {
126
+ default: f(() => [M.value ? (s(), e(d(x), { key: 0 })) : N.value.WIKI.length === 0 ? (s(), e(d(S), { key: 1 })) : (s(), e(B, {
127
+ key: 2,
128
+ rows: N.value.WIKI
129
+ }, {
130
+ body: f((t) => [a(z, { props: t }, {
131
+ default: f(() => [a(R, null, {
132
+ default: f(() => [a(F, {
133
+ flat: "",
134
+ "no-caps": "",
135
+ onClick: (e) => L(t.row)
136
+ }, {
137
+ default: f(() => [t.row.name.length < g ? (s(), n("span", m, u(t.row.name), 1)) : (s(), n("span", h, [i(u(t.row.name.slice(0, g)) + " ", 1), a(d(D), { size: "18" })]))]),
138
+ _: 2
139
+ }, 1032, ["onClick"])]),
140
+ _: 2
141
+ }, 1024), a(R, null, {
142
+ default: f(() => [a(d(C), { onClick: (e) => I(t.row) }, {
143
+ default: f(() => [t.row.favorite === 0 ? (s(), e(d(T), { key: 0 })) : (s(), e(d(E), { key: 1 }))]),
144
+ _: 2
145
+ }, 1032, ["onClick"])]),
146
+ _: 2
147
+ }, 1024)]),
148
+ _: 2
149
+ }, 1032, ["props"])]),
150
+ _: 1
151
+ }, 8, ["rows"]))]),
152
+ _: 1
153
+ })]),
154
+ _: 1
155
+ }, 8, ["modelValue"])
156
+ ])]),
157
+ _: 1
158
+ }, 8, ["style"])]),
159
+ _: 1
160
+ }, 8, ["mini-state"]);
161
+ };
162
+ }
163
+ };
164
+ //#endregion
165
+ export { _ as FavoritePage };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ClbsUI={},e.vue))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n={style:{"max-width":`800px`}},r={key:0},i={key:1},a=75;e.FavoritePage={__name:`FavoriteModal`,props:{type:{type:String,required:!0},miniState:{type:Boolean,required:!0},api:{type:Object,required:!0},stores:{type:Object,required:!0},constants:{type:Object,required:!0},ui:{type:Object,required:!0}},setup(e){let o=e,{ModalViewSmall:s,CloseButton:c,LoadingComponent:l,EmptyData:u,ContentBtn:d,SearchInput:f,FavoriteOutlineIcon:p,FavoriteIcon:m,Dots:h,HomeIcon:g,EmailIcon:_}=o.ui,v=(0,t.ref)(`SUPPORT`),y=(0,t.ref)(``),b=(0,t.ref)(!1),x=(0,t.ref)({WIKI:[],LMS:[],SUPPORT:[]});(0,t.ref)({WIKI:{page:1,rowsPerPage:18,rowsNumber:0},LMS:{page:1,rowsPerPage:18,rowsNumber:0},SUPPORT:{page:1,rowsPerPage:18,rowsNumber:0}});let S=async e=>{v.value=e,await C()},C=async()=>{b.value=!0;try{let e;e=o.type===`history`?await o.api.fetchHistory():v.value===`SUPPORT`?await o.api.fetchFavoritesTasksRows():await o.api.fetchFavorites({query:y.value,type:v.value.toLowerCase()}),x.value[v.value]=e?.data||[]}catch(e){console.error(e),o.stores?.notifications?.cancel?.(e.message)}b.value=!1},w=async e=>{try{e.favorite===0?await o.api.fetchAddFavorite(e.idPage,v.value)&&(e.favorite=1):await o.api.fetchDeleteFavorite(e.idPage,v.value)&&(e.favorite=0)}catch(e){console.error(e),o.stores?.notifications?.cancel?.(e.message)}},T=e=>{let{WIKI_URL:t,LMS_URL:n}=o.constants;v.value===`SUPPORT`&&window.open(e.url,`_blank`),v.value===`WIKI`&&window.open(`${t}/${e.idPage}`,`_blank`),v.value===`LMS`&&window.open(`${n}/#/course/${e.idPage}`,`_blank`)};return(o,g)=>{let _=(0,t.resolveComponent)(`q-tab`),C=(0,t.resolveComponent)(`q-tabs`),E=(0,t.resolveComponent)(`q-btn`),D=(0,t.resolveComponent)(`q-td`),O=(0,t.resolveComponent)(`q-tr`),k=(0,t.resolveComponent)(`q-table`),A=(0,t.resolveComponent)(`q-tab-panel`),j=(0,t.resolveComponent)(`q-tab-panels`),M=(0,t.resolveComponent)(`q-card`);return(0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(s),{"modal-open":!0,"mini-state":e.miniState},{default:(0,t.withCtx)(()=>[(0,t.createVNode)(M,{style:(0,t.normalizeStyle)({left:e.miniState?`57px`:`240px`}),class:`modal`},{default:(0,t.withCtx)(()=>[(0,t.createVNode)((0,t.unref)(c)),(0,t.createElementVNode)(`div`,n,[(0,t.createVNode)((0,t.unref)(f),{modelValue:y.value,"onUpdate:modelValue":g[0]||=e=>y.value=e},null,8,[`modelValue`]),(0,t.createVNode)(C,{modelValue:v.value,"onUpdate:modelValue":g[4]||=e=>v.value=e,dense:``,"active-color":`primary`,"indicator-color":`primary`,align:`justify`},{default:(0,t.withCtx)(()=>[e.type===`favorites`?((0,t.openBlock)(),(0,t.createBlock)(_,{key:0,name:`SUPPORT`,label:`Support`,onClick:g[1]||=e=>S(`SUPPORT`)})):(0,t.createCommentVNode)(``,!0),(0,t.createVNode)(_,{name:`WIKI`,label:`Wiki`,onClick:g[2]||=e=>S(`WIKI`)}),(0,t.createVNode)(_,{name:`LMS`,label:`Learning`,onClick:g[3]||=e=>S(`LMS`)})]),_:1},8,[`modelValue`]),(0,t.createVNode)(j,{modelValue:v.value,"onUpdate:modelValue":g[5]||=e=>v.value=e},{default:(0,t.withCtx)(()=>[(0,t.createVNode)(A,{name:`WIKI`},{default:(0,t.withCtx)(()=>[b.value?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(l),{key:0})):x.value.WIKI.length===0?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(u),{key:1})):((0,t.openBlock)(),(0,t.createBlock)(k,{key:2,rows:x.value.WIKI},{body:(0,t.withCtx)(e=>[(0,t.createVNode)(O,{props:e},{default:(0,t.withCtx)(()=>[(0,t.createVNode)(D,null,{default:(0,t.withCtx)(()=>[(0,t.createVNode)(E,{flat:``,"no-caps":``,onClick:t=>T(e.row)},{default:(0,t.withCtx)(()=>[e.row.name.length<a?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,r,(0,t.toDisplayString)(e.row.name),1)):((0,t.openBlock)(),(0,t.createElementBlock)(`span`,i,[(0,t.createTextVNode)((0,t.toDisplayString)(e.row.name.slice(0,a))+` `,1),(0,t.createVNode)((0,t.unref)(h),{size:`18`})]))]),_:2},1032,[`onClick`])]),_:2},1024),(0,t.createVNode)(D,null,{default:(0,t.withCtx)(()=>[(0,t.createVNode)((0,t.unref)(d),{onClick:t=>w(e.row)},{default:(0,t.withCtx)(()=>[e.row.favorite===0?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(p),{key:0})):((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(m),{key:1}))]),_:2},1032,[`onClick`])]),_:2},1024)]),_:2},1032,[`props`])]),_:1},8,[`rows`]))]),_:1})]),_:1},8,[`modelValue`])])]),_:1},8,[`style`])]),_:1},8,[`mini-state`])}}}});
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "clbs-libs-ui",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "build": "vite build"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "description": "",
13
+ "dependencies": {
14
+ "vue": "^3.5.31"
15
+ },
16
+ "devDependencies": {
17
+ "@vitejs/plugin-vue": "^6.0.5",
18
+ "vite": "^8.0.3"
19
+ }
20
+ }
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default as FavoritePage } from './pages/FavoriteModal.vue'
@@ -0,0 +1,207 @@
1
+ <script setup>
2
+ import { ref } from "vue"
3
+
4
+ const props = defineProps({
5
+ type: {
6
+ type: String,
7
+ required: true
8
+ },
9
+ miniState: {
10
+ type: Boolean,
11
+ required: true
12
+ },
13
+ api: {
14
+ type: Object,
15
+ required: true
16
+ },
17
+ stores: {
18
+ type: Object,
19
+ required: true
20
+ },
21
+ constants: {
22
+ type: Object,
23
+ required: true
24
+ },
25
+ ui: {
26
+ type: Object,
27
+ required: true
28
+ }
29
+ })
30
+
31
+ const {
32
+ ModalViewSmall,
33
+ CloseButton,
34
+ LoadingComponent,
35
+ EmptyData,
36
+ ContentBtn,
37
+ SearchInput,
38
+ FavoriteOutlineIcon,
39
+ FavoriteIcon,
40
+ Dots,
41
+ HomeIcon,
42
+ EmailIcon
43
+ } = props.ui
44
+
45
+ const tab = ref("SUPPORT")
46
+ const filter = ref("")
47
+ const isLoading = ref(false)
48
+
49
+ const rows = ref({
50
+ WIKI: [],
51
+ LMS: [],
52
+ SUPPORT: []
53
+ })
54
+
55
+ const pagination = ref({
56
+ WIKI: { page: 1, rowsPerPage: 18, rowsNumber: 0 },
57
+ LMS: { page: 1, rowsPerPage: 18, rowsNumber: 0 },
58
+ SUPPORT: { page: 1, rowsPerPage: 18, rowsNumber: 0 }
59
+ })
60
+
61
+ const maxTitleLength = 75
62
+
63
+ const changeTab = async (value) => {
64
+ tab.value = value
65
+ await getData()
66
+ }
67
+
68
+ const getData = async () => {
69
+ isLoading.value = true
70
+
71
+ try {
72
+ let result
73
+ if (props.type === "history") {
74
+ result = await props.api.fetchHistory()
75
+ }
76
+ else if (tab.value === "SUPPORT") {
77
+ result = await props.api.fetchFavoritesTasksRows()
78
+ }
79
+ else {
80
+ result = await props.api.fetchFavorites({
81
+ query: filter.value,
82
+ type: tab.value.toLowerCase()
83
+ })
84
+ }
85
+ rows.value[tab.value] = result?.data || []
86
+ } catch (e) {
87
+ console.error(e)
88
+ props.stores?.notifications?.cancel?.(e.message)
89
+ }
90
+ isLoading.value = false
91
+ }
92
+
93
+ const toggleFavorite = async (row) => {
94
+ try {
95
+ if (row.favorite === 0) {
96
+ const res = await props.api.fetchAddFavorite(
97
+ row.idPage,
98
+ tab.value
99
+ )
100
+ if (res) row.favorite = 1
101
+ } else {
102
+ const res = await props.api.fetchDeleteFavorite(
103
+ row.idPage,
104
+ tab.value
105
+ )
106
+ if (res) row.favorite = 0
107
+ }
108
+ } catch (e) {
109
+ console.error(e)
110
+ props.stores?.notifications?.cancel?.(e.message)
111
+ }
112
+ }
113
+
114
+ const goToPage = (row) => {
115
+ const { WIKI_URL, LMS_URL } = props.constants
116
+ if (tab.value === "SUPPORT") {
117
+ window.open(row.url, "_blank")
118
+ }
119
+ if (tab.value === "WIKI") {
120
+ window.open(`${WIKI_URL}/${row.idPage}`, "_blank")
121
+ }
122
+ if (tab.value === "LMS") {
123
+ window.open(`${LMS_URL}/#/course/${row.idPage}`, "_blank")
124
+ }
125
+ }
126
+ </script>
127
+
128
+ <template>
129
+ <ModalViewSmall
130
+ :modal-open="true"
131
+ :mini-state="miniState"
132
+ >
133
+ <q-card
134
+ :style="{ left: miniState ? '57px' : '240px' }"
135
+ class="modal"
136
+ >
137
+ <CloseButton />
138
+ <div style="max-width:800px">
139
+ <SearchInput v-model="filter"/>
140
+ <q-tabs
141
+ v-model="tab"
142
+ dense
143
+ active-color="primary"
144
+ indicator-color="primary"
145
+ align="justify"
146
+ >
147
+ <q-tab
148
+ v-if="type === 'favorites'"
149
+ name="SUPPORT"
150
+ label="Support"
151
+ @click="changeTab('SUPPORT')"
152
+ />
153
+ <q-tab
154
+ name="WIKI"
155
+ label="Wiki"
156
+ @click="changeTab('WIKI')"
157
+ />
158
+ <q-tab
159
+ name="LMS"
160
+ label="Learning"
161
+ @click="changeTab('LMS')"
162
+ />
163
+ </q-tabs>
164
+ <q-tab-panels v-model="tab">
165
+ <q-tab-panel name="WIKI">
166
+ <LoadingComponent v-if="isLoading"/>
167
+ <EmptyData v-else-if="rows.WIKI.length === 0"/>
168
+ <q-table
169
+ v-else
170
+ :rows="rows.WIKI"
171
+ >
172
+ <template #body="props">
173
+ <q-tr :props="props">
174
+ <q-td>
175
+ <q-btn
176
+ flat
177
+ no-caps
178
+ @click="goToPage(props.row)"
179
+ >
180
+ <span v-if="props.row.name.length < maxTitleLength">
181
+ {{ props.row.name }}
182
+ </span>
183
+ <span v-else>
184
+ {{ props.row.name.slice(0, maxTitleLength) }}
185
+ <Dots size="18"/>
186
+ </span>
187
+ </q-btn>
188
+ </q-td>
189
+ <q-td>
190
+ <ContentBtn
191
+ @click="toggleFavorite(props.row)"
192
+ >
193
+ <FavoriteOutlineIcon
194
+ v-if="props.row.favorite === 0"
195
+ />
196
+ <FavoriteIcon v-else/>
197
+ </ContentBtn>
198
+ </q-td>
199
+ </q-tr>
200
+ </template>
201
+ </q-table>
202
+ </q-tab-panel>
203
+ </q-tab-panels>
204
+ </div>
205
+ </q-card>
206
+ </ModalViewSmall>
207
+ </template>
package/vite.config.js ADDED
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from "vite"
2
+ import vue from "@vitejs/plugin-vue"
3
+
4
+ export default defineConfig({
5
+ plugins: [vue()],
6
+
7
+ build: {
8
+ lib: {
9
+ entry: "src/index.js",
10
+ name: "ClbsUI",
11
+ fileName: "clbs-ui"
12
+ },
13
+
14
+ rollupOptions: {
15
+ external: ["vue"]
16
+ }
17
+ }
18
+ })