@vc-shell/framework 1.1.0 → 1.1.2
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/CHANGELOG.md +8 -0
- package/dist/assets/apl-NdZ6-T1z.js +142 -0
- package/dist/assets/asciiarmor-CmJEbAuq.js +56 -0
- package/dist/assets/asn1-Ctc8K72v.js +192 -0
- package/dist/assets/asterisk-D6r__RMF.js +187 -0
- package/dist/assets/brainfuck-COwWCBpq.js +70 -0
- package/dist/assets/clike-C-PtfL50.js +1019 -0
- package/dist/assets/clojure-C2XPrGCa.js +274 -0
- package/dist/assets/cmake-BGrEgXCL.js +81 -0
- package/dist/assets/cobol-DShPmpZe.js +234 -0
- package/dist/assets/coffeescript-BG8vTfSz.js +329 -0
- package/dist/assets/commonlisp-8oE2EpEe.js +108 -0
- package/dist/assets/core-api-BMLS9FrT.js +8288 -0
- package/dist/assets/core-composables-DYxpIWyY.js +1799 -0
- package/dist/assets/core-constants-DiKDBbnD.js +83 -0
- package/dist/assets/core-directives-QhJx9kWh.js +41 -0
- package/dist/assets/core-interceptors-CSjUvxQ0.js +78 -0
- package/dist/assets/core-plugins-wv2bDZ0l.js +4919 -0
- package/dist/assets/core-services-CAfJRsjs.js +4 -0
- package/dist/assets/core-utilities-BTktq_a-.js +33 -0
- package/dist/assets/crystal--rIRMl16.js +419 -0
- package/dist/assets/css/core-directives-FL4vIIkN.css +73 -0
- package/dist/assets/css/fonts-M1mtyV8L.css +305 -0
- package/dist/assets/css/icons-css-DbCVsovz.css +41 -0
- package/dist/assets/css/shared-components-bnLHdCtf.css +429 -0
- package/dist/assets/css/shared-modules-CNOICmYQ.css +45 -0
- package/dist/assets/css/styles-C62nDZwV.css +4096 -0
- package/dist/assets/css/ui-app-Bh9hmlIB.css +1287 -0
- package/dist/assets/css/ui-content-B29jsmK7.css +1187 -0
- package/dist/assets/css/ui-controls-CRtfFczw.css +387 -0
- package/dist/assets/css/ui-data-CYLxfdUa.css +1555 -0
- package/dist/assets/css/ui-form-C3WrWfVl.css +71 -0
- package/dist/assets/css/ui-form-fields-DOtHhDeM.css +1360 -0
- package/dist/assets/css/ui-helpers-bOoNv5dS.css +37 -0
- package/dist/assets/css/ui-indicators-CybQnCoU.css +628 -0
- package/dist/assets/css/ui-layout-DyGKgizy.css +251 -0
- package/dist/assets/css/ui-media-TWYep8js.css +298 -0
- package/dist/assets/css/ui-media-advanced-BGxy3VSB.css +183 -0
- package/dist/assets/css/ui-navigation-DcPRn8SB.css +1693 -0
- package/dist/assets/css-C_ZeEwz2.js +847 -0
- package/dist/assets/cypher-Bayei42D.js +122 -0
- package/dist/assets/d-B0hhz6be.js +205 -0
- package/dist/assets/diff-DQutOIXs.js +30 -0
- package/dist/assets/dockerfile-D0MivFIF.js +199 -0
- package/dist/assets/dtd-C1CeYVnM.js +121 -0
- package/dist/assets/dylan-Dm9-uD-A.js +337 -0
- package/dist/assets/ebnf-jWG_1Yly.js +151 -0
- package/dist/assets/ecl-CgJPA6z9.js +190 -0
- package/dist/assets/eiffel-lj7uLahq.js +146 -0
- package/dist/assets/elm-Cz7o1ijk.js +230 -0
- package/dist/assets/erlang-CyL5QOyR.js +581 -0
- package/dist/assets/factor-BVWHwYpu.js +65 -0
- package/dist/assets/fcl-DiozYjc8.js +154 -0
- package/dist/assets/forth-B7vn5ze0.js +164 -0
- package/dist/assets/fortran-D2XNEnBT.js +172 -0
- package/dist/assets/gas-B_Tj57Ve.js +343 -0
- package/dist/assets/gherkin-CJ6Qk4EZ.js +147 -0
- package/dist/assets/groovy-ioGz2WSV.js +228 -0
- package/dist/assets/haskell-BHnm1B83.js +239 -0
- package/dist/assets/haxe-Bn6Yo6N3.js +490 -0
- package/dist/assets/http-BOd5SYCT.js +89 -0
- package/dist/assets/idl-FSFk8_xX.js +274 -0
- package/dist/assets/index--5fKpGeN.js +792 -0
- package/dist/assets/index-0lME64YH.js +342 -0
- package/dist/assets/index-B1srGfDb.js +183 -0
- package/dist/assets/index-B6Ip0FgO.js +437 -0
- package/dist/assets/index-BKF-A58l.js +106 -0
- package/dist/assets/index-BT8o9-M5.js +418 -0
- package/dist/assets/index-BmV05E5M.js +479 -0
- package/dist/assets/index-Bv_z_qRq.js +137 -0
- package/dist/assets/index-C6MavZDA.js +131 -0
- package/dist/assets/index-C7zlEJy8.js +338 -0
- package/dist/assets/index-CeeaNa4F.js +187 -0
- package/dist/assets/index-CtmpJVwa.js +330 -0
- package/dist/assets/index-CwKpgcYl.js +85 -0
- package/dist/assets/index-DMTL7O1s.js +627 -0
- package/dist/assets/index-DRUmDL0J.js +59 -0
- package/dist/assets/index-DgFC-M9G.js +96 -0
- package/dist/assets/javascript-DGrAs70C.js +922 -0
- package/dist/assets/jinja2-D9k5QrXv.js +171 -0
- package/dist/assets/julia-DM42tOPB.js +369 -0
- package/dist/assets/livescript-Dci8HnOi.js +259 -0
- package/dist/assets/lua-CByQu4v6.js +137 -0
- package/dist/assets/lucide-icons-af0BY3bi.js +34555 -0
- package/dist/assets/mathematica-Dkv0uCYF.js +153 -0
- package/dist/assets/mbox-CYTvs5kC.js +114 -0
- package/dist/assets/mirc-DpgP3GCo.js +176 -0
- package/dist/assets/mllike-C6tNn2Yt.js +343 -0
- package/dist/assets/modelica-CR6hTSce.js +192 -0
- package/dist/assets/mscgen-D0GXtzMS.js +149 -0
- package/dist/assets/mumps-Bf1EyDa6.js +129 -0
- package/dist/assets/nginx-By9Phklj.js +163 -0
- package/dist/assets/nsis-B5ggMLQ9.js +80 -0
- package/dist/assets/ntriples-C7VJ7pnm.js +141 -0
- package/dist/assets/octave-6yR_ix15.js +112 -0
- package/dist/assets/oz-CEUnktiQ.js +235 -0
- package/dist/assets/pascal-Dksf1EyF.js +124 -0
- package/dist/assets/perl-B99DUQQt.js +819 -0
- package/dist/assets/pig-DFeDRta6.js +149 -0
- package/dist/assets/powershell-DhwsNWMx.js +381 -0
- package/dist/assets/properties-o21uErwC.js +62 -0
- package/dist/assets/protobuf-YxlANsmD.js +54 -0
- package/dist/assets/pug-bUgjeODZ.js +504 -0
- package/dist/assets/puppet-B8WICGYE.js +205 -0
- package/dist/assets/python-D3FFx1Id.js +389 -0
- package/dist/assets/q-D2Hjhl2C.js +123 -0
- package/dist/assets/r-D73k5lac.js +174 -0
- package/dist/assets/rpm-Duv_WH0z.js +89 -0
- package/dist/assets/ruby-DGCVqZDt.js +287 -0
- package/dist/assets/sas-XjPv1Vy5.js +268 -0
- package/dist/assets/scheme-DeaA28vt.js +263 -0
- package/dist/assets/shared-components-CfAt2hC6.js +1501 -0
- package/dist/assets/shared-composables-v9NkNuAe.js +35 -0
- package/dist/assets/shared-modules-CDP-H5ZB.js +3588 -0
- package/dist/assets/shared-pages-BGRRA5WB.js +20 -0
- package/dist/assets/shell-Bx6QZTgx.js +145 -0
- package/dist/assets/sieve-CWCD62sW.js +178 -0
- package/dist/assets/simple-mode-BAO9cD7H.js +136 -0
- package/dist/assets/smalltalk-DSQbF4MF.js +153 -0
- package/dist/assets/solr-v_XRf31C.js +80 -0
- package/dist/assets/sparql-BrfDqf0-.js +170 -0
- package/dist/assets/spreadsheet-Csn84Pef.js +98 -0
- package/dist/assets/sql-D4utlq1l.js +480 -0
- package/dist/assets/stex-DBkktma-.js +246 -0
- package/dist/assets/stylus-ByG-Fd6f.js +750 -0
- package/dist/assets/swift-CHbTprt3.js +202 -0
- package/dist/assets/tcl-BRlMUELr.js +125 -0
- package/dist/assets/textile-CqfTUjd4.js +441 -0
- package/dist/assets/tiddlywiki-BrsoM8KB.js +278 -0
- package/dist/assets/tiki-D-ivWPkc.js +289 -0
- package/dist/assets/toml-t_IhJu83.js +75 -0
- package/dist/assets/troff-DckGF2AE.js +64 -0
- package/dist/assets/ttcn-B8TAFbRR.js +253 -0
- package/dist/assets/ttcn-cfg-NHh25oCM.js +197 -0
- package/dist/assets/turtle-D9Js0BlL.js +141 -0
- package/dist/assets/ui-app-D31Pr1WY.js +1993 -0
- package/dist/assets/ui-content-B7SxH8y9.js +52887 -0
- package/dist/assets/ui-controls-nmDJYLmC.js +348 -0
- package/dist/assets/ui-data-Ci3b1ye0.js +22901 -0
- package/dist/assets/ui-form-Cs5ooOo7.js +159 -0
- package/dist/assets/ui-form-fields-DFQi31jT.js +40575 -0
- package/dist/assets/ui-helpers-CF-EUlOg.js +1736 -0
- package/dist/assets/ui-indicators-mIQeEqha.js +199 -0
- package/dist/assets/ui-layout-v2XBQky3.js +320 -0
- package/dist/assets/ui-media-WWYrwmZw.js +1259 -0
- package/dist/assets/ui-media-advanced-T8ibi153.js +492 -0
- package/dist/assets/ui-modals-BdZXzI85.js +2 -0
- package/dist/assets/ui-navigation-BtHa6ovW.js +24269 -0
- package/dist/assets/utils-DZK5fu48.js +17216 -0
- package/dist/assets/vb-CbIGLrpY.js +249 -0
- package/dist/assets/vbscript-8ANWle9n.js +320 -0
- package/dist/assets/velocity-D6hz3Hzw.js +186 -0
- package/dist/assets/verilog-DIV442at.js +565 -0
- package/dist/assets/vhdl-BlTiZo_v.js +174 -0
- package/dist/assets/vueuse-CTQm4Zh0.js +9308 -0
- package/dist/assets/webidl-Cp3tcqdk.js +179 -0
- package/dist/assets/xquery-Dd4TBzXv.js +411 -0
- package/dist/assets/yacas-DQ1WucF0.js +182 -0
- package/dist/assets/z80-P1j44jDI.js +102 -0
- package/dist/framework.js +29 -0
- package/dist/index.css +18 -0
- package/dist/shared/components/draggable-dashboard/composables/useDashboardDragAndDrop.d.ts +4 -4
- package/dist/shared/components/notifications/components/notification-container/index.d.ts +6 -6
- package/dist/shared/components/notifications/components/notification-container/index.d.ts.map +1 -1
- package/dist/shared/modules/assets-manager/components/assets-manager/assets-manager.vue.d.ts +2 -2
- package/dist/shared/modules/dynamic/pages/dynamic-blade-form.vue.d.ts +2 -2
- package/dist/shared/modules/dynamic/pages/dynamic-blade-list.vue.d.ts +2 -2
- package/dist/shared/pages/InvitePage/components/invite/Invite.vue.d.ts +1 -1
- package/dist/shared/pages/InvitePage/components/invite/Invite.vue.d.ts.map +1 -1
- package/dist/shared/pages/ResetPasswordPage/components/reset-password/ResetPassword.vue.d.ts +1 -1
- package/dist/shared/pages/ResetPasswordPage/components/reset-password/ResetPassword.vue.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/atoms/vc-badge/vc-badge.vue.d.ts +1 -1
- package/dist/ui/components/atoms/vc-badge/vc-badge.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-container/vc-container.vue.d.ts +2 -2
- package/dist/ui/components/atoms/vc-icon/vc-material-icon.vue.d.ts +1 -1
- package/dist/ui/components/atoms/vc-icon/vc-material-icon.vue.d.ts.map +1 -1
- package/dist/ui/components/atoms/vc-progress/vc-progress.vue.d.ts +1 -1
- package/dist/ui/components/atoms/vc-progress/vc-progress.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts +2 -2
- package/dist/ui/components/molecules/vc-file-upload/vc-file-upload.vue.d.ts +2 -2
- package/dist/ui/components/molecules/vc-file-upload/vc-file-upload.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-input/vc-input.vue.d.ts +4 -4
- package/dist/ui/components/molecules/vc-input/vc-input.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-pagination/vc-pagination.vue.d.ts +1 -1
- package/dist/ui/components/molecules/vc-pagination/vc-pagination.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-rating/vc-rating.vue.d.ts +1 -1
- package/dist/ui/components/molecules/vc-rating/vc-rating.vue.d.ts.map +1 -1
- package/dist/ui/components/molecules/vc-select/vc-select.vue.d.ts +3 -3
- package/dist/ui/components/molecules/vc-select/vc-select.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/vc-app-menu-item.vue.d.ts +1 -1
- package/dist/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/vc-app-menu-item.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/_internal/vc-blade-toolbar-button/vc-blade-toolbar-base-button.vue.d.ts +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/_internal/vc-blade-toolbar-button/vc-blade-toolbar-base-button.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue.d.ts +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/_internal/vc-blade-toolbar-button/vc-blade-toolbar-circle-button.vue.d.ts +1 -1
- package/dist/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-buttons/_internal/vc-blade-toolbar-button/vc-blade-toolbar-circle-button.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-blade/vc-blade.vue.d.ts +1 -1
- package/dist/ui/components/organisms/vc-blade/vc-blade.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-gallery/_internal/vc-gallery-item/vc-gallery-item.vue.d.ts +2 -2
- package/dist/ui/components/organisms/vc-gallery/_internal/vc-gallery-preview/vc-gallery-preview.vue.d.ts +1 -1
- package/dist/ui/components/organisms/vc-gallery/_internal/vc-gallery-preview/vc-gallery-preview.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-gallery/vc-gallery.vue.d.ts +3 -3
- package/dist/ui/components/organisms/vc-gallery/vc-gallery.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-popup/vc-popup.vue.d.ts +1 -1
- package/dist/ui/components/organisms/vc-popup/vc-popup.vue.d.ts.map +1 -1
- package/dist/ui/components/organisms/vc-table/_internal/vc-table-counter/vc-table-counter.vue.d.ts +1 -1
- package/dist/ui/components/organisms/vc-table/_internal/vc-table-counter/vc-table-counter.vue.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -0,0 +1,3588 @@
|
|
|
1
|
+
import { markRaw, ref, computed, watchPostEffect, unref, toValue, readonly, h, reactive, resolveComponent, shallowRef, getCurrentInstance, watch, onMounted, onUnmounted, defineComponent, inject, onBeforeMount, provide, toRefs, createBlock, createCommentVNode, openBlock, withCtx, createElementBlock, createVNode, mergeProps, createSlots, resolveDynamicComponent, createElementVNode, toDisplayString, createTextVNode, renderList, isRef, useSlots, onUpdated, onBeforeUnmount, resolveDirective, withDirectives, Fragment, nextTick } from 'vue';
|
|
2
|
+
import { b as _sfc_main$b } from './ui-indicators-mIQeEqha.js';
|
|
3
|
+
import { A as _sfc_main$8, B as _sfc_main$9, _ as _sfc_main$n } from './ui-media-WWYrwmZw.js';
|
|
4
|
+
import { a as _sfc_main$5, b as _sfc_main$c, _ as _sfc_main$l } from './ui-controls-nmDJYLmC.js';
|
|
5
|
+
import { V as VcCard, a as VcContainer, b as _sfc_main$j, _ as _sfc_main$k } from './ui-layout-v2XBQky3.js';
|
|
6
|
+
import { V as VcHint } from './ui-helpers-CF-EUlOg.js';
|
|
7
|
+
import { b as usePopup, u as useWidgets, d as useBladeNavigation, t as _sfc_main$m, c as usePermissions, i as i18n, n as notification, k as createAppModule } from './ui-navigation-BtHa6ovW.js';
|
|
8
|
+
import { i as useFunctions, f as useLanguages, u as useNotifications, n as useBeforeUnload, j as useAsync, l as useLoading } from './core-composables-DYxpIWyY.js';
|
|
9
|
+
import './ui-app-D31Pr1WY.js';
|
|
10
|
+
import { Field, useForm, useIsFormValid } from 'vee-validate';
|
|
11
|
+
import { a as _sfc_main$e, i as _sfc_main$o } from './ui-content-B7SxH8y9.js';
|
|
12
|
+
import './ui-form-Cs5ooOo7.js';
|
|
13
|
+
import { d as _sfc_main$2, e as _sfc_main$3, c as _sfc_main$6, h as _sfc_main$7, _ as _sfc_main$a, V as VcCheckbox, b as _sfc_main$f, a as _sfc_main$g, f as _sfc_main$h, u as useI18n, J as isEmpty, C as omit, n as merge, K as chunk, l as get, L as has, M as set, j as isEqual, i as cloneDeep, N as findIndex, P as unset, Q as update, R as compact, r as uniqueId, S as findKey, T as every } from './ui-form-fields-DFQi31jT.js';
|
|
14
|
+
import './shared-composables-v9NkNuAe.js';
|
|
15
|
+
import './core-plugins-wv2bDZ0l.js';
|
|
16
|
+
import 'vue-router';
|
|
17
|
+
import './shared-components-CfAt2hC6.js';
|
|
18
|
+
import { a as _sfc_main$4, _ as _sfc_main$i, b as BladeInstance } from './ui-data-Ci3b1ye0.js';
|
|
19
|
+
import { _ as _sfc_main$d } from './ui-media-advanced-T8ibi153.js';
|
|
20
|
+
import { C as toReactive, y as createUnrefFn, t as toValue$1, D as useMounted, r as reactiveComputed, E as reactify, F as toRefs$1 } from './vueuse-CTQm4Zh0.js';
|
|
21
|
+
import { k as kebabToPascal } from './core-utilities-BTktq_a-.js';
|
|
22
|
+
|
|
23
|
+
const ControlBaseProps = ({
|
|
24
|
+
rules = void 0,
|
|
25
|
+
label = void 0,
|
|
26
|
+
placeholder = void 0,
|
|
27
|
+
disabled = false,
|
|
28
|
+
required = false,
|
|
29
|
+
name = void 0,
|
|
30
|
+
tooltip = void 0,
|
|
31
|
+
key = void 0,
|
|
32
|
+
classNames = void 0,
|
|
33
|
+
...rest
|
|
34
|
+
}) => ({
|
|
35
|
+
key,
|
|
36
|
+
rules,
|
|
37
|
+
label,
|
|
38
|
+
placeholder,
|
|
39
|
+
disabled,
|
|
40
|
+
required,
|
|
41
|
+
name,
|
|
42
|
+
tooltip,
|
|
43
|
+
classNames,
|
|
44
|
+
...rest
|
|
45
|
+
});
|
|
46
|
+
const MultivalueField$1 = ({ props, slots }) => ({
|
|
47
|
+
component: markRaw(_sfc_main$6),
|
|
48
|
+
props: {
|
|
49
|
+
...ControlBaseProps(props),
|
|
50
|
+
...props
|
|
51
|
+
},
|
|
52
|
+
slots
|
|
53
|
+
});
|
|
54
|
+
const SelectField$1 = ({ props, slots }) => ({
|
|
55
|
+
component: markRaw(_sfc_main$h),
|
|
56
|
+
props: {
|
|
57
|
+
...ControlBaseProps(props),
|
|
58
|
+
...props
|
|
59
|
+
},
|
|
60
|
+
slots
|
|
61
|
+
});
|
|
62
|
+
const StatusField$1 = ({ props, slots }) => ({
|
|
63
|
+
component: markRaw(_sfc_main$b),
|
|
64
|
+
props: {
|
|
65
|
+
...ControlBaseProps(props),
|
|
66
|
+
...props
|
|
67
|
+
},
|
|
68
|
+
slots
|
|
69
|
+
});
|
|
70
|
+
const InputField$1 = ({ props, slots }) => ({
|
|
71
|
+
component: markRaw(_sfc_main$g),
|
|
72
|
+
props: {
|
|
73
|
+
...ControlBaseProps(props),
|
|
74
|
+
...props
|
|
75
|
+
},
|
|
76
|
+
slots
|
|
77
|
+
});
|
|
78
|
+
const TextareaField$1 = ({ props }) => ({
|
|
79
|
+
component: markRaw(_sfc_main$7),
|
|
80
|
+
props: {
|
|
81
|
+
...ControlBaseProps(props),
|
|
82
|
+
...props
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
const ContentField$1 = ({ props }) => ({
|
|
86
|
+
component: markRaw(_sfc_main$a),
|
|
87
|
+
props: {
|
|
88
|
+
...ControlBaseProps(props),
|
|
89
|
+
...props
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const ImageField$1 = ({ props }) => ({
|
|
93
|
+
component: markRaw(_sfc_main$8),
|
|
94
|
+
props: {
|
|
95
|
+
...ControlBaseProps(props),
|
|
96
|
+
...props
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const VideoField$1 = ({ props }) => ({
|
|
100
|
+
component: markRaw(_sfc_main$9),
|
|
101
|
+
props: {
|
|
102
|
+
...ControlBaseProps(props),
|
|
103
|
+
...props
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
const InputCurrency$1 = ({ props }) => ({
|
|
107
|
+
component: markRaw(_sfc_main$f),
|
|
108
|
+
props: {
|
|
109
|
+
...ControlBaseProps(props),
|
|
110
|
+
...props
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const CardCollection = ({ props, slots }) => ({
|
|
114
|
+
component: markRaw(VcCard),
|
|
115
|
+
props: {
|
|
116
|
+
...props,
|
|
117
|
+
...ControlBaseProps(props)
|
|
118
|
+
},
|
|
119
|
+
slots
|
|
120
|
+
});
|
|
121
|
+
const DynamicProperties = ({ props }) => ({
|
|
122
|
+
component: markRaw(_sfc_main$i),
|
|
123
|
+
props: {
|
|
124
|
+
...props,
|
|
125
|
+
...ControlBaseProps(props)
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const EditorField$1 = ({ props }) => ({
|
|
129
|
+
component: markRaw(_sfc_main$e),
|
|
130
|
+
props: {
|
|
131
|
+
...ControlBaseProps(props),
|
|
132
|
+
...props
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
const Gallery = ({ props }) => ({
|
|
136
|
+
component: markRaw(_sfc_main$d),
|
|
137
|
+
props: {
|
|
138
|
+
...ControlBaseProps(props),
|
|
139
|
+
...props
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
const Checkbox$1 = ({ props, slots }) => ({
|
|
143
|
+
component: markRaw(VcCheckbox),
|
|
144
|
+
props: {
|
|
145
|
+
...ControlBaseProps(props),
|
|
146
|
+
...props
|
|
147
|
+
},
|
|
148
|
+
slots
|
|
149
|
+
});
|
|
150
|
+
const RadioButton = ({ props }) => ({
|
|
151
|
+
component: markRaw(_sfc_main$2),
|
|
152
|
+
props: {
|
|
153
|
+
...ControlBaseProps(props),
|
|
154
|
+
...props
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
const Button$1 = ({ props, slots }) => ({
|
|
158
|
+
component: markRaw(_sfc_main$c),
|
|
159
|
+
props: {
|
|
160
|
+
...ControlBaseProps(props),
|
|
161
|
+
...props
|
|
162
|
+
},
|
|
163
|
+
slots
|
|
164
|
+
});
|
|
165
|
+
const Switch = ({ props }) => ({
|
|
166
|
+
component: markRaw(_sfc_main$5),
|
|
167
|
+
props: {
|
|
168
|
+
...ControlBaseProps(props),
|
|
169
|
+
...props
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const Table$1 = ({ props, slots }) => ({
|
|
173
|
+
component: markRaw(_sfc_main$4),
|
|
174
|
+
props: {
|
|
175
|
+
...ControlBaseProps(props),
|
|
176
|
+
...props
|
|
177
|
+
},
|
|
178
|
+
slots
|
|
179
|
+
});
|
|
180
|
+
const Rating = ({ props }) => ({
|
|
181
|
+
component: markRaw(_sfc_main$3),
|
|
182
|
+
props: {
|
|
183
|
+
...ControlBaseProps(props),
|
|
184
|
+
...props
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const useFilterBuilder = (args) => {
|
|
189
|
+
const _search = args.load;
|
|
190
|
+
const _data = args.data;
|
|
191
|
+
const isFilterVisible = ref(true);
|
|
192
|
+
const filter = ref({});
|
|
193
|
+
const { t } = useI18n({ useScope: "global" });
|
|
194
|
+
const controls = ref([]);
|
|
195
|
+
const appliedFilter = ref({});
|
|
196
|
+
const activeFilterCount = computed(() => Object.values(appliedFilter.value).filter((item) => !!item).length);
|
|
197
|
+
const isDisabled = createUnrefFn((filterObj) => {
|
|
198
|
+
const filterKeys = Object.keys(filterObj);
|
|
199
|
+
return filterKeys.length === 0 || filterKeys.every((key) => !filterObj[key]);
|
|
200
|
+
});
|
|
201
|
+
watchPostEffect(() => {
|
|
202
|
+
createFilterControls();
|
|
203
|
+
});
|
|
204
|
+
function isItemSelected(value, field) {
|
|
205
|
+
const item = filter.value[field];
|
|
206
|
+
if (Array.isArray(item) && typeof item !== "string") {
|
|
207
|
+
return item.some((x) => x === value);
|
|
208
|
+
} else {
|
|
209
|
+
return item === value;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function selectFilterItem(e, value, field, multiple = true) {
|
|
213
|
+
if (multiple) {
|
|
214
|
+
filter.value[field] = e ? [...filter.value[field] || [], value] : (filter.value[field] || []).filter((x) => x !== value);
|
|
215
|
+
if (!filter.value[field].length) filter.value[field] = void 0;
|
|
216
|
+
} else {
|
|
217
|
+
filter.value[field] = e ? value : void 0;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function createFilterControls() {
|
|
221
|
+
if (!_data?.columns) {
|
|
222
|
+
isFilterVisible.value = false;
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
controls.value = _data.columns.map((item) => {
|
|
226
|
+
const ctr = item.controls.reduce(
|
|
227
|
+
(obj, control) => {
|
|
228
|
+
if (control.component === "vc-checkbox") {
|
|
229
|
+
const filterData = control.data;
|
|
230
|
+
const filterDataFromScope = unref(args.scope)?.[filterData] ?? [];
|
|
231
|
+
const fields = createCheckboxFromData(filterDataFromScope, control);
|
|
232
|
+
if (fields) {
|
|
233
|
+
obj[control.field] = {
|
|
234
|
+
fields,
|
|
235
|
+
label: computed(() => t(control.label ?? "")),
|
|
236
|
+
tooltip: computed(() => t(control.tooltip ?? ""))
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (control.component === "vc-input") {
|
|
241
|
+
obj[control.field] = {
|
|
242
|
+
fields: {
|
|
243
|
+
[control.field]: createInput(control)
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
if (control.component === "vc-switch") {
|
|
248
|
+
const filterData = control.data;
|
|
249
|
+
const filterDataFromScope = unref(args.scope)?.[filterData] ?? [];
|
|
250
|
+
const fields = createSwitchFromData(filterDataFromScope, control);
|
|
251
|
+
if (fields) {
|
|
252
|
+
obj[control.field] = {
|
|
253
|
+
fields
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (control.component === "vc-select") {
|
|
258
|
+
const filterData = control.data;
|
|
259
|
+
const filterDataFromScope = unref(args.scope)?.[filterData] ?? [];
|
|
260
|
+
const fields = createSelectFromData(filterDataFromScope, control);
|
|
261
|
+
if (fields) {
|
|
262
|
+
obj[control.field] = {
|
|
263
|
+
fields
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (control.component === "vc-radio-button-group") {
|
|
268
|
+
const filterData = control.data;
|
|
269
|
+
const filterDataFromScope = unref(args.scope)?.[filterData] ?? [];
|
|
270
|
+
const fields = createRadioButtonGroupFromData(filterDataFromScope, control);
|
|
271
|
+
if (fields) {
|
|
272
|
+
obj[control.field] = {
|
|
273
|
+
fields,
|
|
274
|
+
label: computed(() => t(control.label ?? "")),
|
|
275
|
+
tooltip: computed(() => t(control.tooltip ?? ""))
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return obj;
|
|
280
|
+
},
|
|
281
|
+
{}
|
|
282
|
+
);
|
|
283
|
+
return {
|
|
284
|
+
title: item.title ?? "",
|
|
285
|
+
fields: ctr
|
|
286
|
+
};
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function createRadioButtonGroupFromData(data, control) {
|
|
290
|
+
if (!(toValue(data) && toValue(data).length)) return;
|
|
291
|
+
return toValue(data).reduce(
|
|
292
|
+
(obj, currC) => {
|
|
293
|
+
obj[currC[control.optionValue]] = {
|
|
294
|
+
...RadioButton({
|
|
295
|
+
props: {
|
|
296
|
+
class: "tw-mb-2",
|
|
297
|
+
value: currC[control.optionValue],
|
|
298
|
+
label: currC[control.optionLabel],
|
|
299
|
+
modelValue: computed(() => filter.value[control.field]),
|
|
300
|
+
"onUpdate:modelValue": (e) => {
|
|
301
|
+
filter.value[control.field] = e;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
};
|
|
306
|
+
return obj;
|
|
307
|
+
},
|
|
308
|
+
{}
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
function createSelectFromData(data, control) {
|
|
312
|
+
if (!(toValue(data) && toValue(data).length)) return;
|
|
313
|
+
return {
|
|
314
|
+
[control.field]: SelectField$1({
|
|
315
|
+
props: {
|
|
316
|
+
class: "tw-mb-2",
|
|
317
|
+
label: computed(() => t(control.label ?? "")),
|
|
318
|
+
tooltip: computed(() => t(control.tooltip ?? "")),
|
|
319
|
+
options: toValue(data),
|
|
320
|
+
multiple: control.multiple,
|
|
321
|
+
optionLabel: control.optionLabel,
|
|
322
|
+
optionValue: control.optionValue,
|
|
323
|
+
clearable: false,
|
|
324
|
+
modelValue: computed(() => filter.value[control.field]),
|
|
325
|
+
"onUpdate:modelValue": (e) => {
|
|
326
|
+
if (Array.isArray(e) && e.length === 0) {
|
|
327
|
+
filter.value[control.field] = void 0;
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
filter.value[control.field] = e;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function createSwitchFromData(data, control) {
|
|
337
|
+
if (!(toValue(data) && toValue(data).length)) return;
|
|
338
|
+
return toValue(data).reduce(
|
|
339
|
+
(obj, currC) => {
|
|
340
|
+
obj[currC[control.optionValue]] = Switch({
|
|
341
|
+
props: {
|
|
342
|
+
class: "tw-mb-2",
|
|
343
|
+
label: toValue(currC[control.optionLabel]),
|
|
344
|
+
tooltip: computed(() => t(control.tooltip ?? "")),
|
|
345
|
+
modelValue: computed(() => isItemSelected(currC[control.optionValue], control.field)),
|
|
346
|
+
"onUpdate:modelValue": (e) => selectFilterItem(e, currC[control.optionValue], control.field, control.multiple)
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
return obj;
|
|
350
|
+
},
|
|
351
|
+
{}
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
function createCheckboxFromData(data, control) {
|
|
355
|
+
if (!(toValue(data) && toValue(data).length)) return;
|
|
356
|
+
return toValue(data).reduce(
|
|
357
|
+
(obj, currC) => {
|
|
358
|
+
obj[currC[control.optionValue]] = {
|
|
359
|
+
...Checkbox$1({
|
|
360
|
+
props: {
|
|
361
|
+
class: "tw-mb-2",
|
|
362
|
+
modelValue: computed(() => isItemSelected(currC[control.optionValue], control.field)),
|
|
363
|
+
"onUpdate:modelValue": (e) => selectFilterItem(e, currC[control.optionValue], control.field, control.multiple)
|
|
364
|
+
},
|
|
365
|
+
slots: {
|
|
366
|
+
default: () => toValue(currC[control.optionLabel])
|
|
367
|
+
}
|
|
368
|
+
})
|
|
369
|
+
};
|
|
370
|
+
return obj;
|
|
371
|
+
},
|
|
372
|
+
{}
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
function createInput(control) {
|
|
376
|
+
return InputField$1({
|
|
377
|
+
props: {
|
|
378
|
+
type: "date",
|
|
379
|
+
class: "tw-mb-3",
|
|
380
|
+
label: toValue(computed(() => t(control.label ?? ""))),
|
|
381
|
+
tooltip: toValue(computed(() => t(control.tooltip ?? ""))),
|
|
382
|
+
modelValue: computed(() => filter.value[control.field]),
|
|
383
|
+
"onUpdate:modelValue": (e) => filter.value[control.field] = e
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
async function applyFilters(filterHandlerFn) {
|
|
388
|
+
appliedFilter.value = {
|
|
389
|
+
...filter.value
|
|
390
|
+
};
|
|
391
|
+
filterHandlerFn();
|
|
392
|
+
await _search({
|
|
393
|
+
...omit(unref(args.query), "skip"),
|
|
394
|
+
...filter.value
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
async function resetFilters(filterHandlerFn) {
|
|
398
|
+
filterHandlerFn();
|
|
399
|
+
await reset();
|
|
400
|
+
await _search({
|
|
401
|
+
...unref(args.query),
|
|
402
|
+
...filter.value
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
function render(slotMethods) {
|
|
406
|
+
if (isEmpty(controls.value)) return;
|
|
407
|
+
return h(
|
|
408
|
+
VcContainer,
|
|
409
|
+
{
|
|
410
|
+
noPadding: true,
|
|
411
|
+
onVnodeBeforeMount: () => {
|
|
412
|
+
filter.value = { ...appliedFilter.value };
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
() => [
|
|
416
|
+
h(
|
|
417
|
+
_sfc_main$j,
|
|
418
|
+
() => Object.values(controls.value).map(({ title, fields }) => {
|
|
419
|
+
return h(_sfc_main$k, { class: "tw-px-5 tw-py-[10px]" }, () => [
|
|
420
|
+
title ? h(
|
|
421
|
+
"div",
|
|
422
|
+
{ class: "tw-mb-4 tw-text-[color:var(--secondary-500)] tw-font-bold tw-text-[17px]" },
|
|
423
|
+
unref(computed(() => t(title)))
|
|
424
|
+
) : void 0,
|
|
425
|
+
Object.values(fields)?.map((items) => {
|
|
426
|
+
return items.label ? h(
|
|
427
|
+
_sfc_main$l,
|
|
428
|
+
{
|
|
429
|
+
class: "tw-mb-2"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
default: () => items.label,
|
|
433
|
+
tooltip: items.tooltip ? () => items.tooltip : void 0
|
|
434
|
+
}
|
|
435
|
+
) : void 0;
|
|
436
|
+
}),
|
|
437
|
+
Object.values(fields)?.map((items) => {
|
|
438
|
+
return Object.values(items.fields).map((item) => {
|
|
439
|
+
if ("component" in item && item.component) {
|
|
440
|
+
return [
|
|
441
|
+
h(
|
|
442
|
+
item.component,
|
|
443
|
+
{ ...item.props, class: item.props.class },
|
|
444
|
+
"slots" in item && item.slots ? { ...item.slots } : {}
|
|
445
|
+
)
|
|
446
|
+
];
|
|
447
|
+
} else {
|
|
448
|
+
return item;
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
})
|
|
452
|
+
]);
|
|
453
|
+
})
|
|
454
|
+
),
|
|
455
|
+
h(
|
|
456
|
+
_sfc_main$j,
|
|
457
|
+
() => h(
|
|
458
|
+
_sfc_main$k,
|
|
459
|
+
{
|
|
460
|
+
class: "tw-px-5 tw-py-[10px] !tw-flex-auto tw-border-t tw-border-solid tw-border-[var(--neutrals-200)]"
|
|
461
|
+
},
|
|
462
|
+
() => h("div", { class: "tw-flex tw-justify-start" }, [
|
|
463
|
+
h(
|
|
464
|
+
_sfc_main$c,
|
|
465
|
+
{
|
|
466
|
+
class: "tw-mr-4",
|
|
467
|
+
small: true,
|
|
468
|
+
disabled: isDisabled(filter),
|
|
469
|
+
onClick: () => applyFilters(slotMethods.close)
|
|
470
|
+
},
|
|
471
|
+
() => t("COMPONENTS.FILTERS.APPLY")
|
|
472
|
+
),
|
|
473
|
+
h(
|
|
474
|
+
_sfc_main$c,
|
|
475
|
+
{
|
|
476
|
+
outline: true,
|
|
477
|
+
small: true,
|
|
478
|
+
disabled: isDisabled(appliedFilter),
|
|
479
|
+
onClick: () => resetFilters(slotMethods.close)
|
|
480
|
+
},
|
|
481
|
+
() => t("COMPONENTS.FILTERS.RESET")
|
|
482
|
+
)
|
|
483
|
+
])
|
|
484
|
+
)
|
|
485
|
+
)
|
|
486
|
+
]
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
async function reset() {
|
|
490
|
+
Object.keys(filter.value).forEach((key) => filter.value[key] = void 0);
|
|
491
|
+
appliedFilter.value = {};
|
|
492
|
+
}
|
|
493
|
+
return {
|
|
494
|
+
filterComponent: render,
|
|
495
|
+
activeFilterCount,
|
|
496
|
+
filter: readonly(toReactive(filter)),
|
|
497
|
+
isFilterVisible: computed(() => isFilterVisible.value),
|
|
498
|
+
reset
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
const useTableTemplates = (tableSchema) => {
|
|
503
|
+
const tableTemplates = reactive({
|
|
504
|
+
templateOverrideComponents: templateOverrideComponents(),
|
|
505
|
+
mobileView: resolveTemplateComponent("mobileTemplate"),
|
|
506
|
+
notFound: resolveTemplateComponent("notFoundTemplate"),
|
|
507
|
+
empty: resolveTemplateComponent("emptyTemplate"),
|
|
508
|
+
footer: resolveTemplateComponent("footerTemplate"),
|
|
509
|
+
header: resolveTemplateComponent("headerTemplate")
|
|
510
|
+
});
|
|
511
|
+
function resolveTemplateComponent(name) {
|
|
512
|
+
if (!toValue(tableSchema)) return;
|
|
513
|
+
const value = toValue(tableSchema)?.[name];
|
|
514
|
+
if (value && typeof value === "object" && "component" in value) {
|
|
515
|
+
const componentName = value.component;
|
|
516
|
+
if (componentName) {
|
|
517
|
+
const component = resolveComponent(componentName);
|
|
518
|
+
if (component && typeof component !== "string") return shallowRef(component);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function templateOverrideComponents() {
|
|
523
|
+
return {
|
|
524
|
+
...toValue(tableSchema)?.columns?.reduce(
|
|
525
|
+
(acc, curr) => {
|
|
526
|
+
if ("customTemplate" in curr && curr.customTemplate) {
|
|
527
|
+
if (!("component" in curr.customTemplate)) {
|
|
528
|
+
throw new Error(
|
|
529
|
+
`Component name must be provided in 'customTemplate' property, column: ${JSON.stringify(curr)}`
|
|
530
|
+
);
|
|
531
|
+
} else if ("component" in curr.customTemplate && curr.customTemplate.component) {
|
|
532
|
+
const component = resolveComponent(curr.customTemplate.component);
|
|
533
|
+
if (typeof component !== "string") {
|
|
534
|
+
acc[curr.id] = shallowRef(component);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return acc;
|
|
539
|
+
},
|
|
540
|
+
{}
|
|
541
|
+
)
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
return {
|
|
545
|
+
tableTemplates
|
|
546
|
+
};
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
const useToolbarReducer = (args) => {
|
|
550
|
+
if (!args) return;
|
|
551
|
+
const { t } = useI18n({ useScope: "global" });
|
|
552
|
+
const toolbarMethodsMerge = merge(
|
|
553
|
+
ref({}),
|
|
554
|
+
ref(args.defaultToolbarBindings),
|
|
555
|
+
ref(toValue$1(args.customToolbarConfig))
|
|
556
|
+
);
|
|
557
|
+
return computed(() => {
|
|
558
|
+
if (args.defaultToolbarSchema?.length !== 0) {
|
|
559
|
+
return args.defaultToolbarSchema?.reduce((acc, curr) => {
|
|
560
|
+
const toolbarItemCtx = toolbarMethodsMerge.value[curr.method];
|
|
561
|
+
if (toolbarItemCtx && Array.isArray(toolbarItemCtx)) {
|
|
562
|
+
return acc.concat(
|
|
563
|
+
toolbarItemCtx.map((item) => {
|
|
564
|
+
return {
|
|
565
|
+
...curr,
|
|
566
|
+
...item,
|
|
567
|
+
title: t(curr.title || unref(item.title ?? ""))
|
|
568
|
+
};
|
|
569
|
+
})
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
if (toolbarItemCtx && typeof toolbarItemCtx === "object") {
|
|
573
|
+
const context = typeof toolbarItemCtx === "function" ? {
|
|
574
|
+
clickHandler: async () => await toolbarItemCtx(args.context)
|
|
575
|
+
} : {
|
|
576
|
+
...toolbarItemCtx,
|
|
577
|
+
clickHandler() {
|
|
578
|
+
return toolbarItemCtx.clickHandler?.call(null, args.context);
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
acc.push({
|
|
582
|
+
...curr,
|
|
583
|
+
...context,
|
|
584
|
+
icon: curr.icon || toolbarItemCtx.icon,
|
|
585
|
+
title: t(curr.title || unref(toolbarItemCtx.title ?? ""))
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
return acc;
|
|
589
|
+
}, []);
|
|
590
|
+
}
|
|
591
|
+
return [];
|
|
592
|
+
});
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
const index = () => {
|
|
596
|
+
const instance = getCurrentInstance();
|
|
597
|
+
function getBladeExposedData() {
|
|
598
|
+
const reactiveBlade = ref(null);
|
|
599
|
+
const blade = ref(instance?.vnode);
|
|
600
|
+
let unwatch = null;
|
|
601
|
+
const updateReactiveBlade = () => {
|
|
602
|
+
if (blade.value && blade.value.props?.navigation?.instance) {
|
|
603
|
+
reactiveBlade.value = blade.value.props.navigation.instance;
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
unwatch = watch(blade, updateReactiveBlade, { immediate: true, deep: true });
|
|
607
|
+
onMounted(() => {
|
|
608
|
+
updateReactiveBlade();
|
|
609
|
+
});
|
|
610
|
+
onUnmounted(() => {
|
|
611
|
+
if (unwatch) {
|
|
612
|
+
unwatch();
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
return reactiveBlade;
|
|
616
|
+
}
|
|
617
|
+
return {
|
|
618
|
+
getBladeExposedData
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
function safeIn(key, obj) {
|
|
623
|
+
return key in obj;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
const _hoisted_1$1 = {
|
|
627
|
+
key: 0,
|
|
628
|
+
class: "tw-p-4"
|
|
629
|
+
};
|
|
630
|
+
const _hoisted_2$1 = {
|
|
631
|
+
key: 1,
|
|
632
|
+
class: "tw-w-full tw-h-full tw-box-border tw-flex tw-flex-col tw-items-center tw-justify-center"
|
|
633
|
+
};
|
|
634
|
+
const _hoisted_3$1 = { class: "tw-m-4 tw-text-xl tw-font-medium" };
|
|
635
|
+
const _hoisted_4$1 = {
|
|
636
|
+
key: 1,
|
|
637
|
+
class: "tw-w-full tw-h-full tw-box-border tw-flex tw-flex-col tw-items-center tw-justify-center"
|
|
638
|
+
};
|
|
639
|
+
const _hoisted_5 = { class: "tw-m-4 tw-text-xl tw-font-medium" };
|
|
640
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
641
|
+
__name: "dynamic-blade-list",
|
|
642
|
+
props: {
|
|
643
|
+
expanded: { type: Boolean, default: true },
|
|
644
|
+
closable: { type: Boolean, default: true },
|
|
645
|
+
param: { default: void 0 },
|
|
646
|
+
options: {},
|
|
647
|
+
model: {},
|
|
648
|
+
composables: {},
|
|
649
|
+
mixinFn: {}
|
|
650
|
+
},
|
|
651
|
+
emits: ["parent:call", "close:blade", "collapse:blade", "expand:blade", "close:children"],
|
|
652
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
653
|
+
const props = __props;
|
|
654
|
+
const { t } = useI18n({ useScope: "global" });
|
|
655
|
+
const { showConfirmation } = usePopup();
|
|
656
|
+
const { debounce } = useFunctions();
|
|
657
|
+
const widgetService = useWidgets();
|
|
658
|
+
const emit = __emit;
|
|
659
|
+
const settings = computed(() => props.model?.settings);
|
|
660
|
+
const localizationPrefix = computed(() => settings.value?.localizationPrefix.trim().toUpperCase());
|
|
661
|
+
const title = computed(() => t(settings.value?.titleTemplate));
|
|
662
|
+
const allSelected = ref(false);
|
|
663
|
+
const searchValue = ref();
|
|
664
|
+
const selectedItemId = shallowRef();
|
|
665
|
+
const sort = shallowRef();
|
|
666
|
+
const selectedIds = shallowRef([]);
|
|
667
|
+
const itemsProxy = ref();
|
|
668
|
+
const isMixinReady = ref(false);
|
|
669
|
+
inject(BladeInstance);
|
|
670
|
+
const { setNavigationQuery, getNavigationQuery } = useBladeNavigation();
|
|
671
|
+
const tableData = props.composables && computed(() => props.model?.content.find((type) => type.component === "vc-table"));
|
|
672
|
+
const tableColsWithLocales = tableData?.value?.columns?.map((col) => ({
|
|
673
|
+
...col,
|
|
674
|
+
title: computed(() => t(col.title))
|
|
675
|
+
}));
|
|
676
|
+
const stateKey = props.composables && computed(() => {
|
|
677
|
+
if (tableData?.value?.id) {
|
|
678
|
+
return tableData.value?.id;
|
|
679
|
+
}
|
|
680
|
+
throw new Error('Table id is not defined. Please provide "id" property in table schema');
|
|
681
|
+
});
|
|
682
|
+
if (typeof props.composables?.[props.model?.settings?.composable ?? ""] === "undefined") {
|
|
683
|
+
throw new Error(`Composable ( ${props.model?.settings?.composable} ) is not defined`);
|
|
684
|
+
}
|
|
685
|
+
let { load, remove, items, loading, pagination, query, scope } = props.composables ? props.composables?.[props.model?.settings?.composable ?? ""]({
|
|
686
|
+
emit,
|
|
687
|
+
props,
|
|
688
|
+
mounted: useMounted()
|
|
689
|
+
}) : {
|
|
690
|
+
load: ref(true),
|
|
691
|
+
remove: void 0,
|
|
692
|
+
items: void 0,
|
|
693
|
+
loading: void 0,
|
|
694
|
+
pagination: void 0,
|
|
695
|
+
query: void 0,
|
|
696
|
+
scope: void 0
|
|
697
|
+
};
|
|
698
|
+
if (props.mixinFn?.length) {
|
|
699
|
+
const mixinResults = props.mixinFn?.map((mixin) => mixin({ loading, items, scope, load, remove, query }));
|
|
700
|
+
const mergedResults = mixinResults.reduce((acc, result) => {
|
|
701
|
+
return {
|
|
702
|
+
...acc,
|
|
703
|
+
...result
|
|
704
|
+
};
|
|
705
|
+
}, {});
|
|
706
|
+
loading = mergedResults.loading ?? loading;
|
|
707
|
+
items = mergedResults.items ?? items;
|
|
708
|
+
scope = mergedResults.scope ?? scope;
|
|
709
|
+
load = mergedResults.load ?? load;
|
|
710
|
+
remove = mergedResults.remove ?? remove;
|
|
711
|
+
query = mergedResults.query ?? query;
|
|
712
|
+
isMixinReady.value = true;
|
|
713
|
+
} else {
|
|
714
|
+
isMixinReady.value = true;
|
|
715
|
+
}
|
|
716
|
+
const isBladeEditable = computed(
|
|
717
|
+
() => "disabled" in toValue(scope || {}) ? !toValue(toValue(scope || {})?.disabled) : false
|
|
718
|
+
);
|
|
719
|
+
const selection = computed(() => {
|
|
720
|
+
const tableConfig2 = toValue(scope)?.tableConfigComputed;
|
|
721
|
+
if (tableConfig2 && "selectedIds" in tableConfig2) {
|
|
722
|
+
return items.value?.filter((item) => tableConfig2.selectedIds?.includes(item.id)) || [];
|
|
723
|
+
}
|
|
724
|
+
return [];
|
|
725
|
+
});
|
|
726
|
+
sort.value = query.value.sort ?? "createdDate:DESC";
|
|
727
|
+
const unreffedScope = reactiveComputed(() => toValue(scope) ?? {});
|
|
728
|
+
const filterDisable = computed(() => {
|
|
729
|
+
if (tableData?.value?.filter?.disabled?.method) {
|
|
730
|
+
const disableFilterMethod = toValue(unreffedScope)?.[tableData?.value?.filter?.disabled.method];
|
|
731
|
+
if (disableFilterMethod && typeof disableFilterMethod === "function") {
|
|
732
|
+
return disableFilterMethod();
|
|
733
|
+
} else {
|
|
734
|
+
return toValue(disableFilterMethod);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
return false;
|
|
738
|
+
});
|
|
739
|
+
const { tableTemplates } = useTableTemplates(tableData);
|
|
740
|
+
const calculateColumns = (columns) => {
|
|
741
|
+
const result = columns?.map((column) => {
|
|
742
|
+
if (typeof column.visible !== "boolean" && column.visible?.method) {
|
|
743
|
+
const result2 = typeof scope?.value[column.visible?.method] === "function" ? scope?.value[column.visible?.method]() : scope?.value[column.visible?.method];
|
|
744
|
+
column.visible = result2;
|
|
745
|
+
}
|
|
746
|
+
return column;
|
|
747
|
+
});
|
|
748
|
+
return result;
|
|
749
|
+
};
|
|
750
|
+
const table = props.composables && computed(() => {
|
|
751
|
+
const tableScope = {
|
|
752
|
+
columns: calculateColumns(tableData?.value?.columns)
|
|
753
|
+
};
|
|
754
|
+
return tableScope;
|
|
755
|
+
});
|
|
756
|
+
const bladeOptions = reactive({
|
|
757
|
+
tableData,
|
|
758
|
+
table
|
|
759
|
+
});
|
|
760
|
+
const {
|
|
761
|
+
filterComponent,
|
|
762
|
+
activeFilterCount,
|
|
763
|
+
isFilterVisible,
|
|
764
|
+
reset: resetFilters,
|
|
765
|
+
filter
|
|
766
|
+
} = useFilterBuilder({
|
|
767
|
+
data: bladeOptions.tableData?.filter,
|
|
768
|
+
query,
|
|
769
|
+
load,
|
|
770
|
+
scope
|
|
771
|
+
});
|
|
772
|
+
const bladeContext = ref({
|
|
773
|
+
load,
|
|
774
|
+
remove,
|
|
775
|
+
items: computed(() => itemsProxy.value ?? []),
|
|
776
|
+
loading,
|
|
777
|
+
pagination,
|
|
778
|
+
query,
|
|
779
|
+
scope,
|
|
780
|
+
selectedIds: computed(() => selectedIds.value),
|
|
781
|
+
settings
|
|
782
|
+
});
|
|
783
|
+
const toolbarComputed = (props.composables && useToolbarReducer({
|
|
784
|
+
defaultToolbarSchema: settings.value?.toolbar ?? [],
|
|
785
|
+
defaultToolbarBindings: {
|
|
786
|
+
openAddBlade: {
|
|
787
|
+
async clickHandler() {
|
|
788
|
+
if (scope && "openDetailsBlade" in toValue(unreffedScope) && toValue(unreffedScope).openDetailsBlade && typeof toValue(unreffedScope).openDetailsBlade === "function") {
|
|
789
|
+
toValue(unreffedScope).openDetailsBlade?.();
|
|
790
|
+
} else throw new Error("openDetailsBlade method is not defined in scope");
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
refresh: {
|
|
794
|
+
async clickHandler() {
|
|
795
|
+
await reload();
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
removeItems: {
|
|
799
|
+
async clickHandler() {
|
|
800
|
+
await removeItems();
|
|
801
|
+
},
|
|
802
|
+
disabled: computed(() => !selectedIds.value?.length)
|
|
803
|
+
// isVisible: computed(() => isDesktop.value),
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
customToolbarConfig: toValue(unreffedScope)?.toolbarOverrides,
|
|
807
|
+
context: bladeContext.value
|
|
808
|
+
})) ?? [];
|
|
809
|
+
onBeforeMount(async () => {
|
|
810
|
+
if (props.composables && isMixinReady.value)
|
|
811
|
+
await load({
|
|
812
|
+
sort: sort.value,
|
|
813
|
+
...query.value,
|
|
814
|
+
...getNavigationQuery()
|
|
815
|
+
});
|
|
816
|
+
});
|
|
817
|
+
watch(
|
|
818
|
+
() => toValue(toValue(scope)?.tableConfigComputed)?.searchValue,
|
|
819
|
+
(newVal) => {
|
|
820
|
+
searchValue.value = newVal;
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
immediate: true
|
|
824
|
+
}
|
|
825
|
+
);
|
|
826
|
+
watch(
|
|
827
|
+
() => props.param,
|
|
828
|
+
async (newVal) => {
|
|
829
|
+
selectedItemId.value = unref(newVal);
|
|
830
|
+
},
|
|
831
|
+
{ immediate: true }
|
|
832
|
+
);
|
|
833
|
+
watch(sort, async (value) => {
|
|
834
|
+
await load({ ...query.value, sort: value });
|
|
835
|
+
});
|
|
836
|
+
watch(items, (newVal) => {
|
|
837
|
+
itemsProxy.value = newVal;
|
|
838
|
+
});
|
|
839
|
+
const onEditComplete = (data) => {
|
|
840
|
+
const item = itemsProxy.value?.[data.index];
|
|
841
|
+
if (item) {
|
|
842
|
+
item[data.event.field] = data.event.value;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
const onCellBlur = async (data) => {
|
|
846
|
+
const column = tableData?.value?.columns?.find((col) => col.id === data.field);
|
|
847
|
+
if (column && column.onCellBlur && column.onCellBlur.method) {
|
|
848
|
+
if (scope && toValue(unreffedScope)?.[column.onCellBlur.method] && typeof toValue(unreffedScope)[column.onCellBlur.method] === "function") {
|
|
849
|
+
await toValue(unreffedScope)[column.onCellBlur.method](data);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
const openDetailsBlade = async () => {
|
|
854
|
+
if (scope && "openDetailsBlade" in toValue(unreffedScope) && toValue(unreffedScope).openDetailsBlade && typeof toValue(unreffedScope).openDetailsBlade === "function") {
|
|
855
|
+
await toValue(unreffedScope).openDetailsBlade?.();
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
const onItemClick = (item) => {
|
|
859
|
+
if (scope && safeIn("onListItemClick", toValue(unreffedScope)) && typeof toValue(unreffedScope).onListItemClick === "function") {
|
|
860
|
+
toValue(unreffedScope).onListItemClick?.({
|
|
861
|
+
item,
|
|
862
|
+
onOpen() {
|
|
863
|
+
selectedItemId.value = item.id;
|
|
864
|
+
},
|
|
865
|
+
onClose() {
|
|
866
|
+
selectedItemId.value = void 0;
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
} else if (scope && safeIn("openDetailsBlade", toValue(unreffedScope)) && typeof toValue(unreffedScope).openDetailsBlade === "function") {
|
|
870
|
+
toValue(unreffedScope).openDetailsBlade?.({
|
|
871
|
+
param: item.id,
|
|
872
|
+
onOpen() {
|
|
873
|
+
selectedItemId.value = item.id;
|
|
874
|
+
},
|
|
875
|
+
onClose() {
|
|
876
|
+
selectedItemId.value = void 0;
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
const onSelectionChanged = (i) => {
|
|
882
|
+
const item = unref(i).map((item2) => item2.id).filter((x) => x !== null);
|
|
883
|
+
selectedIds.value = item;
|
|
884
|
+
};
|
|
885
|
+
async function removeItems() {
|
|
886
|
+
if (await showConfirmation(
|
|
887
|
+
t(
|
|
888
|
+
`${settings.value?.localizationPrefix.trim().toUpperCase()}.PAGES.ALERTS.DELETE_SELECTED_CONFIRMATION.MESSAGE`,
|
|
889
|
+
{
|
|
890
|
+
count: allSelected.value ? t(
|
|
891
|
+
`${settings.value?.localizationPrefix.trim().toUpperCase()}.PAGES.ALERTS.DELETE_SELECTED_CONFIRMATION.ALL`,
|
|
892
|
+
{
|
|
893
|
+
totalCount: pagination.value.totalCount
|
|
894
|
+
}
|
|
895
|
+
) : selectedIds.value.length
|
|
896
|
+
}
|
|
897
|
+
)
|
|
898
|
+
)) {
|
|
899
|
+
emit("close:children");
|
|
900
|
+
if (remove) await remove({ allSelected: allSelected.value, ids: selectedIds.value });
|
|
901
|
+
if (query.value.skip && query.value.take) {
|
|
902
|
+
if (query.value.skip >= query.value.take) {
|
|
903
|
+
if (allSelected.value) {
|
|
904
|
+
query.value.skip = 0;
|
|
905
|
+
} else {
|
|
906
|
+
query.value.skip -= query.value.take;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
widgetService.updateActiveWidget();
|
|
911
|
+
await reload();
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
const reload = async () => {
|
|
915
|
+
selectedIds.value = [];
|
|
916
|
+
if (query.value.take) {
|
|
917
|
+
await load({
|
|
918
|
+
...query.value,
|
|
919
|
+
skip: (pagination.value.currentPage - 1) * query.value.take,
|
|
920
|
+
sort: sort.value
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
const onPaginationClick = async (page) => {
|
|
925
|
+
if (query.value.take) {
|
|
926
|
+
if (scope && safeIn("onPaginationClick", toValue(unreffedScope)) && typeof toValue(unreffedScope).onPaginationClick === "function") {
|
|
927
|
+
toValue(unreffedScope).onPaginationClick?.({
|
|
928
|
+
...query.value,
|
|
929
|
+
skip: (page - 1) * query.value.take
|
|
930
|
+
});
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
const queryObj = {
|
|
934
|
+
...query.value,
|
|
935
|
+
skip: (page - 1) * query.value.take
|
|
936
|
+
};
|
|
937
|
+
setNavigationQuery(queryObj);
|
|
938
|
+
await load(queryObj);
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
const onHeaderClick = (item) => {
|
|
942
|
+
const sortOptions = ["DESC", "ASC", ""];
|
|
943
|
+
if (item.sortable) {
|
|
944
|
+
if (sort.value.split(":")[0] === item.id) {
|
|
945
|
+
const index = sortOptions.findIndex((x) => {
|
|
946
|
+
const sorting = sort.value.split(":")[1];
|
|
947
|
+
if (sorting) {
|
|
948
|
+
return x === sorting;
|
|
949
|
+
} else {
|
|
950
|
+
return x === "";
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
if (index !== -1) {
|
|
954
|
+
const newSort = sortOptions[(index + 1) % sortOptions.length];
|
|
955
|
+
if (newSort === "") {
|
|
956
|
+
sort.value = `${item.id}`;
|
|
957
|
+
} else {
|
|
958
|
+
sort.value = `${item.id}:${newSort}`;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
} else {
|
|
962
|
+
sort.value = `${item.id}:${sortOptions[0]}`;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
const onSearchList = debounce(async (keyword) => {
|
|
967
|
+
searchValue.value = keyword;
|
|
968
|
+
await load({
|
|
969
|
+
...query.value,
|
|
970
|
+
keyword
|
|
971
|
+
});
|
|
972
|
+
}, 1e3);
|
|
973
|
+
async function resetSearch() {
|
|
974
|
+
searchValue.value = "";
|
|
975
|
+
await resetFilters();
|
|
976
|
+
await load({
|
|
977
|
+
...query.value,
|
|
978
|
+
...filter,
|
|
979
|
+
keyword: ""
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
function sortRows(event) {
|
|
983
|
+
if (event.dragIndex !== event.dropIndex) {
|
|
984
|
+
const sorted = event.value.map((item, index) => {
|
|
985
|
+
item.sortOrder = index;
|
|
986
|
+
return item;
|
|
987
|
+
});
|
|
988
|
+
itemsProxy.value = sorted;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
async function handleSelectAllItems(all) {
|
|
992
|
+
allSelected.value = all;
|
|
993
|
+
}
|
|
994
|
+
function disabledActionHandler(disabled, item) {
|
|
995
|
+
if (!disabled) return false;
|
|
996
|
+
if (typeof disabled === "boolean") return disabled;
|
|
997
|
+
else if (disabled.method && typeof toValue(unreffedScope)?.[disabled.method] === "function")
|
|
998
|
+
return toValue(unreffedScope)?.[disabled.method]({ item });
|
|
999
|
+
else if (disabled.method && toValue(unreffedScope)?.[disabled.method])
|
|
1000
|
+
return toValue(unreffedScope)?.[disabled.method];
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
function actionBuilder(item) {
|
|
1004
|
+
const result = tableData?.value?.actions?.reduce((arr, action) => {
|
|
1005
|
+
const isDisabled = disabledActionHandler(action?.disabled ?? false, item);
|
|
1006
|
+
if (!toValue(isDisabled)) {
|
|
1007
|
+
arr.push({
|
|
1008
|
+
icon: action.icon,
|
|
1009
|
+
title: computed(() => t(action.title)),
|
|
1010
|
+
type: action.type,
|
|
1011
|
+
clickHandler: async (itemVal) => {
|
|
1012
|
+
try {
|
|
1013
|
+
if (isRef(toolbarComputed) && toolbarComputed.value && toolbarComputed.value.length > 0) {
|
|
1014
|
+
const toolbarItem = toolbarComputed.value.find(
|
|
1015
|
+
(x) => ("method" in x && x.method === action.method) ?? false
|
|
1016
|
+
);
|
|
1017
|
+
selectedIds.value = [itemVal.id];
|
|
1018
|
+
if (toolbarItem) {
|
|
1019
|
+
await toolbarItem.clickHandler?.();
|
|
1020
|
+
} else {
|
|
1021
|
+
await toValue(unreffedScope)?.[action.method]?.(itemVal);
|
|
1022
|
+
selectedIds.value = [];
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
} catch (error) {
|
|
1026
|
+
throw new Error(`Method ${action.method} is not defined in scope or toolbarOverrides`);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
return arr;
|
|
1032
|
+
}, []);
|
|
1033
|
+
return result;
|
|
1034
|
+
}
|
|
1035
|
+
const tableConfig = computed(() => {
|
|
1036
|
+
return {
|
|
1037
|
+
loading: loading.value,
|
|
1038
|
+
columns: tableColsWithLocales ?? [],
|
|
1039
|
+
stateKey: stateKey?.value ?? "",
|
|
1040
|
+
items: itemsProxy.value ?? [],
|
|
1041
|
+
multiselect: tableData?.value?.multiselect,
|
|
1042
|
+
header: tableData?.value?.header,
|
|
1043
|
+
itemActionBuilder: actionBuilder,
|
|
1044
|
+
editing: isBladeEditable.value,
|
|
1045
|
+
enableItemActions: !!tableData?.value?.actions,
|
|
1046
|
+
footer: tableData?.value?.footer,
|
|
1047
|
+
sort: sort.value,
|
|
1048
|
+
pages: pagination.value?.pages,
|
|
1049
|
+
currentPage: pagination.value?.currentPage,
|
|
1050
|
+
searchValue: searchValue.value,
|
|
1051
|
+
selectedItemId: selectedItemId.value,
|
|
1052
|
+
totalCount: pagination.value?.totalCount,
|
|
1053
|
+
reorderableRows: tableData?.value?.reorderableRows,
|
|
1054
|
+
pullToReload: true,
|
|
1055
|
+
selectAll: tableData?.value?.selectAll,
|
|
1056
|
+
paginationVariant: tableData?.value?.paginationVariant,
|
|
1057
|
+
selectionItems: selection.value,
|
|
1058
|
+
onItemClick,
|
|
1059
|
+
onPaginationClick,
|
|
1060
|
+
onSelectionChanged,
|
|
1061
|
+
onHeaderClick,
|
|
1062
|
+
"onScroll:ptr": reload,
|
|
1063
|
+
"onSearch:change": onSearchList,
|
|
1064
|
+
"onRow:reorder": sortRows,
|
|
1065
|
+
"onSelect:all": handleSelectAllItems,
|
|
1066
|
+
onEditComplete,
|
|
1067
|
+
onCellBlur,
|
|
1068
|
+
noHeaderCheckbox: tableData?.value?.noHeaderCheckbox
|
|
1069
|
+
};
|
|
1070
|
+
});
|
|
1071
|
+
const tableConfigComputed = computed(() => {
|
|
1072
|
+
if (scope && "tableConfig" in toValue(scope) && typeof toValue(scope)?.tableConfig === "function") {
|
|
1073
|
+
const initialTableConfig = toReactive(tableConfig.value);
|
|
1074
|
+
const scopeTableConfig = toValue(scope)?.tableConfig?.(initialTableConfig);
|
|
1075
|
+
const res = {
|
|
1076
|
+
...initialTableConfig,
|
|
1077
|
+
...scopeTableConfig
|
|
1078
|
+
};
|
|
1079
|
+
if (scopeTableConfig?.columns?.length) {
|
|
1080
|
+
res.columns = scopeTableConfig.columns;
|
|
1081
|
+
}
|
|
1082
|
+
return res;
|
|
1083
|
+
}
|
|
1084
|
+
return tableConfig.value;
|
|
1085
|
+
});
|
|
1086
|
+
provide("bladeContext", toReactive(bladeContext));
|
|
1087
|
+
provide("isBladeEditable", isBladeEditable);
|
|
1088
|
+
__expose({
|
|
1089
|
+
reload,
|
|
1090
|
+
title,
|
|
1091
|
+
// updateActiveWidgetCount,
|
|
1092
|
+
...toRefs(toValue(unreffedScope) ?? {}),
|
|
1093
|
+
selectedIds,
|
|
1094
|
+
settings: toValue(settings)
|
|
1095
|
+
});
|
|
1096
|
+
return (_ctx, _cache) => {
|
|
1097
|
+
const _component_VcBreadcrumbs = resolveComponent("VcBreadcrumbs");
|
|
1098
|
+
const _component_VcButton = resolveComponent("VcButton");
|
|
1099
|
+
const _component_VcTable = resolveComponent("VcTable");
|
|
1100
|
+
const _component_VcBlade = resolveComponent("VcBlade");
|
|
1101
|
+
return !_ctx.composables ? (openBlock(), createBlock(_component_VcBlade, {
|
|
1102
|
+
key: 0,
|
|
1103
|
+
expanded: _ctx.expanded,
|
|
1104
|
+
closable: _ctx.closable,
|
|
1105
|
+
width: settings.value?.width || "50%",
|
|
1106
|
+
"toolbar-items": unref(toolbarComputed),
|
|
1107
|
+
title: title.value,
|
|
1108
|
+
modified: unref(unreffedScope)?.modified,
|
|
1109
|
+
onClose: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close:blade")),
|
|
1110
|
+
onExpand: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("expand:blade")),
|
|
1111
|
+
onCollapse: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("collapse:blade"))
|
|
1112
|
+
}, {
|
|
1113
|
+
default: withCtx(() => [
|
|
1114
|
+
toValue(unref(scope)?.breadcrumbs)?.length ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
1115
|
+
createVNode(_component_VcBreadcrumbs, {
|
|
1116
|
+
items: toValue(unref(scope)?.breadcrumbs),
|
|
1117
|
+
variant: "light",
|
|
1118
|
+
separated: ""
|
|
1119
|
+
}, null, 8, ["items"])
|
|
1120
|
+
])) : createCommentVNode("", true),
|
|
1121
|
+
createVNode(_component_VcTable, mergeProps({ class: "tw-grow tw-basis-0" }, tableConfigComputed.value, {
|
|
1122
|
+
expanded: _ctx.expanded,
|
|
1123
|
+
"total-label": _ctx.$t(`${localizationPrefix.value}.PAGES.LIST.TABLE.TOTALS`),
|
|
1124
|
+
"active-filter-count": unref(activeFilterCount),
|
|
1125
|
+
"disable-filter": filterDisable.value
|
|
1126
|
+
}), createSlots({
|
|
1127
|
+
notfound: withCtx(() => [
|
|
1128
|
+
unref(tableTemplates)?.notFound ? (openBlock(), createBlock(resolveDynamicComponent(unref(tableTemplates).notFound), {
|
|
1129
|
+
key: 0,
|
|
1130
|
+
context: bladeContext.value,
|
|
1131
|
+
onReset: resetSearch
|
|
1132
|
+
}, null, 40, ["context"])) : (openBlock(), createElementBlock("div", _hoisted_2$1, [
|
|
1133
|
+
createElementVNode("div", _hoisted_3$1, toDisplayString(_ctx.$t(`${localizationPrefix.value}.PAGES.LIST.NOT_FOUND.EMPTY`)), 1),
|
|
1134
|
+
unref(isFilterVisible) ? (openBlock(), createBlock(_component_VcButton, {
|
|
1135
|
+
key: 0,
|
|
1136
|
+
onClick: resetSearch
|
|
1137
|
+
}, {
|
|
1138
|
+
default: withCtx(() => [
|
|
1139
|
+
createTextVNode(toDisplayString(_ctx.$t(`${localizationPrefix.value}.PAGES.LIST.NOT_FOUND.RESET`)), 1)
|
|
1140
|
+
]),
|
|
1141
|
+
_: 1
|
|
1142
|
+
})) : createCommentVNode("", true)
|
|
1143
|
+
]))
|
|
1144
|
+
]),
|
|
1145
|
+
empty: withCtx(() => [
|
|
1146
|
+
unref(tableTemplates)?.empty ? (openBlock(), createBlock(resolveDynamicComponent(unref(tableTemplates).empty), {
|
|
1147
|
+
key: 0,
|
|
1148
|
+
context: bladeContext.value,
|
|
1149
|
+
onAdd: openDetailsBlade
|
|
1150
|
+
}, null, 40, ["context"])) : (openBlock(), createElementBlock("div", _hoisted_4$1, [
|
|
1151
|
+
createElementVNode("div", _hoisted_5, toDisplayString(_ctx.$t(`${localizationPrefix.value}.PAGES.LIST.EMPTY.NO_ITEMS`)), 1)
|
|
1152
|
+
]))
|
|
1153
|
+
]),
|
|
1154
|
+
_: 2
|
|
1155
|
+
}, [
|
|
1156
|
+
unref(isFilterVisible) && bladeOptions.tableData?.filter ? {
|
|
1157
|
+
name: "filters",
|
|
1158
|
+
fn: withCtx(({ closePanel }) => [
|
|
1159
|
+
createVNode(unref(filterComponent), { close: closePanel }, null, 8, ["close"])
|
|
1160
|
+
]),
|
|
1161
|
+
key: "0"
|
|
1162
|
+
} : void 0,
|
|
1163
|
+
renderList(unref(tableTemplates)?.templateOverrideComponents, (component, key, index) => {
|
|
1164
|
+
return {
|
|
1165
|
+
name: `item_${key}`,
|
|
1166
|
+
fn: withCtx((itemData) => [
|
|
1167
|
+
(openBlock(), createBlock(resolveDynamicComponent(component), {
|
|
1168
|
+
context: itemData,
|
|
1169
|
+
"blade-context": bladeContext.value
|
|
1170
|
+
}, null, 8, ["context", "blade-context"]))
|
|
1171
|
+
])
|
|
1172
|
+
};
|
|
1173
|
+
}),
|
|
1174
|
+
unref(tableTemplates)?.header ? {
|
|
1175
|
+
name: "header",
|
|
1176
|
+
fn: withCtx((headerData) => [
|
|
1177
|
+
(openBlock(), createBlock(resolveDynamicComponent(unref(tableTemplates).header), {
|
|
1178
|
+
context: headerData,
|
|
1179
|
+
"blade-context": bladeContext.value
|
|
1180
|
+
}, null, 8, ["context", "blade-context"]))
|
|
1181
|
+
]),
|
|
1182
|
+
key: "1"
|
|
1183
|
+
} : void 0,
|
|
1184
|
+
unref(tableTemplates)?.footer ? {
|
|
1185
|
+
name: "footer",
|
|
1186
|
+
fn: withCtx((footerData) => [
|
|
1187
|
+
(openBlock(), createBlock(resolveDynamicComponent(unref(tableTemplates).footer), {
|
|
1188
|
+
context: footerData,
|
|
1189
|
+
"blade-context": bladeContext.value
|
|
1190
|
+
}, null, 8, ["context", "blade-context"]))
|
|
1191
|
+
]),
|
|
1192
|
+
key: "2"
|
|
1193
|
+
} : void 0,
|
|
1194
|
+
unref(tableTemplates)?.mobileView ? {
|
|
1195
|
+
name: "mobile-item",
|
|
1196
|
+
fn: withCtx((itemData) => [
|
|
1197
|
+
(openBlock(), createBlock(resolveDynamicComponent(unref(tableTemplates).mobileView), {
|
|
1198
|
+
context: itemData,
|
|
1199
|
+
"blade-context": bladeContext.value
|
|
1200
|
+
}, null, 8, ["context", "blade-context"]))
|
|
1201
|
+
]),
|
|
1202
|
+
key: "3"
|
|
1203
|
+
} : void 0
|
|
1204
|
+
]), 1040, ["expanded", "total-label", "active-filter-count", "disable-filter"])
|
|
1205
|
+
]),
|
|
1206
|
+
_: 1
|
|
1207
|
+
}, 8, ["expanded", "closable", "width", "toolbar-items", "title", "modified"])) : createCommentVNode("", true);
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
|
|
1212
|
+
const componentProps = {
|
|
1213
|
+
baseProps: {
|
|
1214
|
+
type: Object,
|
|
1215
|
+
default: () => ({})
|
|
1216
|
+
},
|
|
1217
|
+
element: {
|
|
1218
|
+
type: Object,
|
|
1219
|
+
default: () => ({})
|
|
1220
|
+
},
|
|
1221
|
+
bladeContext: {
|
|
1222
|
+
type: Object,
|
|
1223
|
+
default: () => ({})
|
|
1224
|
+
},
|
|
1225
|
+
fields: {
|
|
1226
|
+
type: Object,
|
|
1227
|
+
default: () => ({})
|
|
1228
|
+
},
|
|
1229
|
+
formData: {
|
|
1230
|
+
type: Object,
|
|
1231
|
+
default: () => ({})
|
|
1232
|
+
},
|
|
1233
|
+
fieldContext: {
|
|
1234
|
+
type: Object
|
|
1235
|
+
},
|
|
1236
|
+
currentLocale: {
|
|
1237
|
+
type: String
|
|
1238
|
+
},
|
|
1239
|
+
elIndex: {
|
|
1240
|
+
type: Number
|
|
1241
|
+
},
|
|
1242
|
+
rows: {
|
|
1243
|
+
type: Number
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
|
|
1247
|
+
const validationFieldProps = {
|
|
1248
|
+
props: Object,
|
|
1249
|
+
index: Number,
|
|
1250
|
+
rows: Number
|
|
1251
|
+
};
|
|
1252
|
+
const ValidationField = defineComponent({
|
|
1253
|
+
name: "ValidationField",
|
|
1254
|
+
props: validationFieldProps,
|
|
1255
|
+
setup(props) {
|
|
1256
|
+
const slots = useSlots();
|
|
1257
|
+
const fieldKey = computed(
|
|
1258
|
+
() => unref(props.props)?.multilanguage ? `${String(props.props?.key)}_${unref(props.props?.currentLanguage)}` : String(props.props?.key)
|
|
1259
|
+
);
|
|
1260
|
+
const fieldNameLang = reactify((name) => {
|
|
1261
|
+
return props.props?.multilanguage ? name + "_" + props.props.currentLanguage : name;
|
|
1262
|
+
});
|
|
1263
|
+
return () => h(
|
|
1264
|
+
Field,
|
|
1265
|
+
{
|
|
1266
|
+
rules: props.props?.rules,
|
|
1267
|
+
modelValue: props.props?.modelValue,
|
|
1268
|
+
label: props.props?.label,
|
|
1269
|
+
key: fieldKey.value,
|
|
1270
|
+
name: fieldNameLang(
|
|
1271
|
+
(props.rows ?? 1) > 1 && (props.index ?? 0) >= 0 ? props.props?.name + "_" + props.index : props.props?.name
|
|
1272
|
+
).value
|
|
1273
|
+
},
|
|
1274
|
+
{
|
|
1275
|
+
default: ({ errorMessage, errors }) => {
|
|
1276
|
+
return slots.default?.().map(
|
|
1277
|
+
(slot) => h(slot, {
|
|
1278
|
+
...props.props,
|
|
1279
|
+
error: !!errors.length,
|
|
1280
|
+
errorMessage,
|
|
1281
|
+
key: fieldKey.value + "_control"
|
|
1282
|
+
})
|
|
1283
|
+
);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
);
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
|
|
1290
|
+
function unrefNested(field) {
|
|
1291
|
+
const unreffedProps = {};
|
|
1292
|
+
if (field) {
|
|
1293
|
+
Object.keys(field).forEach((key) => {
|
|
1294
|
+
unreffedProps[key] = unref(field[key]);
|
|
1295
|
+
});
|
|
1296
|
+
return unreffedProps;
|
|
1297
|
+
}
|
|
1298
|
+
return field;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
const SelectField = {
|
|
1302
|
+
name: "SelectField",
|
|
1303
|
+
props: componentProps,
|
|
1304
|
+
setup(props) {
|
|
1305
|
+
return () => {
|
|
1306
|
+
const field = SelectField$1({
|
|
1307
|
+
props: Object.assign(
|
|
1308
|
+
{},
|
|
1309
|
+
{
|
|
1310
|
+
optionValue: props.element.optionValue,
|
|
1311
|
+
optionLabel: props.element.optionLabel,
|
|
1312
|
+
emitValue: props.element.emitValue,
|
|
1313
|
+
mapOptions: props.element.mapOptions,
|
|
1314
|
+
options: props.bladeContext.scope?.[props.element.optionsMethod],
|
|
1315
|
+
currentLanguage: props.currentLocale,
|
|
1316
|
+
clearable: props.element.clearable || false,
|
|
1317
|
+
searchable: props.element.searchable || false,
|
|
1318
|
+
multiple: props.element.multiple || false
|
|
1319
|
+
},
|
|
1320
|
+
unrefNested(props.baseProps),
|
|
1321
|
+
{
|
|
1322
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
1323
|
+
}
|
|
1324
|
+
),
|
|
1325
|
+
slots: props.element.customTemplate && ["selected-item", "option"].reduce(
|
|
1326
|
+
(obj, slot) => {
|
|
1327
|
+
obj[slot] = (scope) => h(resolveComponent(props.element.customTemplate?.component), {
|
|
1328
|
+
context: scope,
|
|
1329
|
+
slotName: slot
|
|
1330
|
+
});
|
|
1331
|
+
return obj;
|
|
1332
|
+
},
|
|
1333
|
+
{}
|
|
1334
|
+
)
|
|
1335
|
+
});
|
|
1336
|
+
const render = h(field.component, field.props, field.slots);
|
|
1337
|
+
if (field.props.rules) {
|
|
1338
|
+
return h(
|
|
1339
|
+
ValidationField,
|
|
1340
|
+
{
|
|
1341
|
+
props: field.props,
|
|
1342
|
+
index: props.elIndex,
|
|
1343
|
+
rows: props.rows,
|
|
1344
|
+
key: `${String(field.props.key)}_validation`
|
|
1345
|
+
},
|
|
1346
|
+
() => render
|
|
1347
|
+
);
|
|
1348
|
+
} else {
|
|
1349
|
+
return render;
|
|
1350
|
+
}
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
const Card = {
|
|
1356
|
+
name: "CardEl",
|
|
1357
|
+
props: componentProps,
|
|
1358
|
+
setup(props) {
|
|
1359
|
+
const hasNoComment = ref(true);
|
|
1360
|
+
onMounted(() => {
|
|
1361
|
+
hasNoComment.value = hasNoCommentNodes(toValue(props.fields));
|
|
1362
|
+
});
|
|
1363
|
+
onUpdated(() => {
|
|
1364
|
+
hasNoComment.value = hasNoCommentNodes(toValue(props.fields));
|
|
1365
|
+
});
|
|
1366
|
+
const hasNoCommentNodes = (components) => {
|
|
1367
|
+
const vnodeIterable = Array.isArray(components) ? components : [components];
|
|
1368
|
+
const commentCounter = ref(0);
|
|
1369
|
+
for (const component of vnodeIterable) {
|
|
1370
|
+
if (Array.isArray(component) && component.length > 0) {
|
|
1371
|
+
if (!hasNoCommentNodes(component)) {
|
|
1372
|
+
commentCounter.value++;
|
|
1373
|
+
break;
|
|
1374
|
+
}
|
|
1375
|
+
} else if (component && typeof component === "object" && !Array.isArray(component)) {
|
|
1376
|
+
if (Array.isArray(component.children) && component.children.length > 0) {
|
|
1377
|
+
if (!hasNoCommentNodes(component.children)) {
|
|
1378
|
+
commentCounter.value++;
|
|
1379
|
+
break;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
if (component.el && component.el.nodeType === Node.COMMENT_NODE) {
|
|
1383
|
+
commentCounter.value++;
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
return commentCounter.value !== vnodeIterable.length;
|
|
1389
|
+
};
|
|
1390
|
+
return () => {
|
|
1391
|
+
const field = CardCollection({
|
|
1392
|
+
props: Object.assign(
|
|
1393
|
+
{},
|
|
1394
|
+
{
|
|
1395
|
+
variant: props.element.variant,
|
|
1396
|
+
header: toValue(props.baseProps.label),
|
|
1397
|
+
isCollapsable: props.element.collapsible,
|
|
1398
|
+
isCollapsed: restoreCollapsed(props.element.id) || props.element.collapsed,
|
|
1399
|
+
"onState:collapsed": (e) => handleCollapsed(props.element.id, e)
|
|
1400
|
+
},
|
|
1401
|
+
unrefNested(props.baseProps),
|
|
1402
|
+
{
|
|
1403
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
1404
|
+
}
|
|
1405
|
+
),
|
|
1406
|
+
slots: {
|
|
1407
|
+
default: () => h(
|
|
1408
|
+
"div",
|
|
1409
|
+
{
|
|
1410
|
+
class: {
|
|
1411
|
+
"tw-flex": true,
|
|
1412
|
+
"tw-flex-col": true,
|
|
1413
|
+
"tw-p-4": !props.element.removePadding,
|
|
1414
|
+
"tw-gap-4": true
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
toValue(props.fields)
|
|
1418
|
+
),
|
|
1419
|
+
actions: () => {
|
|
1420
|
+
if (props.element.action) {
|
|
1421
|
+
const elem = nodeBuilder({
|
|
1422
|
+
controlSchema: props.element.action,
|
|
1423
|
+
parentId: `${props.element.id}`,
|
|
1424
|
+
internalContext: props.fieldContext ?? {},
|
|
1425
|
+
bladeContext: props.bladeContext,
|
|
1426
|
+
currentLocale: props.currentLocale ?? "en",
|
|
1427
|
+
formData: props.formData
|
|
1428
|
+
});
|
|
1429
|
+
return elem;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
function handleCollapsed(key, value) {
|
|
1435
|
+
localStorage?.setItem(key, `${value}`);
|
|
1436
|
+
}
|
|
1437
|
+
function restoreCollapsed(key) {
|
|
1438
|
+
return localStorage?.getItem(key) === "true";
|
|
1439
|
+
}
|
|
1440
|
+
return hasNoComment.value ? h(field.component, field.props, field.slots) : null;
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1445
|
+
const methodHandler = (visibility, fieldContext, schema) => {
|
|
1446
|
+
if (visibility === void 0) {
|
|
1447
|
+
return true;
|
|
1448
|
+
}
|
|
1449
|
+
if (typeof visibility === "function") {
|
|
1450
|
+
return visibility(schema, fieldContext);
|
|
1451
|
+
}
|
|
1452
|
+
return toValue(visibility);
|
|
1453
|
+
};
|
|
1454
|
+
|
|
1455
|
+
const slotsMap = {
|
|
1456
|
+
append: "append",
|
|
1457
|
+
prepend: "prepend",
|
|
1458
|
+
appendInner: "append-inner",
|
|
1459
|
+
prependInner: "prepend-inner"
|
|
1460
|
+
};
|
|
1461
|
+
const InputField = {
|
|
1462
|
+
name: "InputField",
|
|
1463
|
+
props: componentProps,
|
|
1464
|
+
setup(props) {
|
|
1465
|
+
return () => {
|
|
1466
|
+
const field = InputField$1({
|
|
1467
|
+
props: Object.assign(
|
|
1468
|
+
{},
|
|
1469
|
+
{
|
|
1470
|
+
type: props.element.variant,
|
|
1471
|
+
currentLanguage: props.currentLocale,
|
|
1472
|
+
clearable: props.element.clearable || false,
|
|
1473
|
+
maxlength: props.element.maxlength,
|
|
1474
|
+
datePickerOptions: props.element.datePickerOptions,
|
|
1475
|
+
loading: props.element.loading?.method ? methodHandler(
|
|
1476
|
+
toValue(props.bladeContext?.scope)?.[props.element.loading?.method],
|
|
1477
|
+
props.fieldContext,
|
|
1478
|
+
props.element
|
|
1479
|
+
) : false
|
|
1480
|
+
},
|
|
1481
|
+
unrefNested(props.baseProps),
|
|
1482
|
+
{
|
|
1483
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
1484
|
+
}
|
|
1485
|
+
),
|
|
1486
|
+
slots: Object.entries(slotsMap).reduce(
|
|
1487
|
+
(acc, [key, value]) => {
|
|
1488
|
+
if (props.element[key]) {
|
|
1489
|
+
acc[value] = () => nodeBuilder({
|
|
1490
|
+
controlSchema: props.element[key],
|
|
1491
|
+
parentId: `${props.element[key].id}`,
|
|
1492
|
+
internalContext: props.fieldContext ?? {},
|
|
1493
|
+
bladeContext: props.bladeContext,
|
|
1494
|
+
currentLocale: props.currentLocale ?? "en-US",
|
|
1495
|
+
formData: props.formData
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
return acc;
|
|
1499
|
+
},
|
|
1500
|
+
{}
|
|
1501
|
+
)
|
|
1502
|
+
});
|
|
1503
|
+
const render = h(field.component, field.props, field.slots);
|
|
1504
|
+
if (field.props.rules) {
|
|
1505
|
+
return h(
|
|
1506
|
+
ValidationField,
|
|
1507
|
+
{
|
|
1508
|
+
props: field.props,
|
|
1509
|
+
index: props.elIndex,
|
|
1510
|
+
rows: props.rows,
|
|
1511
|
+
key: `${String(field.props.key)}_validation`
|
|
1512
|
+
},
|
|
1513
|
+
() => render
|
|
1514
|
+
);
|
|
1515
|
+
} else {
|
|
1516
|
+
return render;
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
};
|
|
1521
|
+
|
|
1522
|
+
const Fieldset = {
|
|
1523
|
+
name: "Fieldset",
|
|
1524
|
+
props: componentProps,
|
|
1525
|
+
setup(props) {
|
|
1526
|
+
const { fields: fieldsetFields } = toRefs(props);
|
|
1527
|
+
return () => toValue(fieldsetFields.value)?.map((fields, index, arr) => {
|
|
1528
|
+
const divideByCols = chunk(fields, props.element.columns || 1) ?? [];
|
|
1529
|
+
return h(
|
|
1530
|
+
"div",
|
|
1531
|
+
{
|
|
1532
|
+
class: `tw-flex tw-row tw-relative ${unrefNested(props.baseProps).classNames ?? ""}`,
|
|
1533
|
+
key: `fieldset-${index}`
|
|
1534
|
+
},
|
|
1535
|
+
[
|
|
1536
|
+
h("div", { class: "tw-flex-1 tw-gap-4 tw-flex tw-flex-col tw-min-w-0" }, [
|
|
1537
|
+
divideByCols.map((itemsArr, colIndex) => {
|
|
1538
|
+
return h(
|
|
1539
|
+
_sfc_main$j,
|
|
1540
|
+
{
|
|
1541
|
+
key: `col-${colIndex}-${index}`,
|
|
1542
|
+
class: {
|
|
1543
|
+
"tw-relative": true,
|
|
1544
|
+
"tw-gap-4": true,
|
|
1545
|
+
"!tw-flex-wrap": true,
|
|
1546
|
+
"!tw-flex !tw-flex-row": !!props.element.aspectRatio
|
|
1547
|
+
}
|
|
1548
|
+
},
|
|
1549
|
+
() => [
|
|
1550
|
+
...itemsArr.map((item, itemIndex) => {
|
|
1551
|
+
return h(
|
|
1552
|
+
_sfc_main$k,
|
|
1553
|
+
{
|
|
1554
|
+
key: `col-${itemIndex}-${colIndex}-${index}`,
|
|
1555
|
+
size: "aspectRatio" in props.element ? props.element.aspectRatio?.[itemIndex] : 1
|
|
1556
|
+
},
|
|
1557
|
+
() => {
|
|
1558
|
+
if (typeof item === "object") {
|
|
1559
|
+
return h(item, {
|
|
1560
|
+
elIndex: index,
|
|
1561
|
+
rows: arr.length,
|
|
1562
|
+
key: `item-${itemIndex}-${colIndex}-${index}`
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
);
|
|
1567
|
+
})
|
|
1568
|
+
]
|
|
1569
|
+
);
|
|
1570
|
+
})
|
|
1571
|
+
])
|
|
1572
|
+
]
|
|
1573
|
+
);
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
const getModel = (property, context) => {
|
|
1579
|
+
if (property && context) {
|
|
1580
|
+
if (typeof context[property] === "function") {
|
|
1581
|
+
return context[property]();
|
|
1582
|
+
}
|
|
1583
|
+
return get(context, property);
|
|
1584
|
+
}
|
|
1585
|
+
return null;
|
|
1586
|
+
};
|
|
1587
|
+
|
|
1588
|
+
function setModel(args) {
|
|
1589
|
+
const { property, value, option, context, scope } = args;
|
|
1590
|
+
if (scope && has(scope, property)) {
|
|
1591
|
+
if (typeof scope[property] === "function") {
|
|
1592
|
+
scope[property](value);
|
|
1593
|
+
} else {
|
|
1594
|
+
set(scope, property, value);
|
|
1595
|
+
}
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
set(context, property, option ? value[option] : value);
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
const InputCurrency = {
|
|
1602
|
+
name: "InputCurrency",
|
|
1603
|
+
props: componentProps,
|
|
1604
|
+
setup(props) {
|
|
1605
|
+
return () => {
|
|
1606
|
+
const options = (safeIn("options", props.element) && props.element.options && (toValue$1(getModel(props.element.options, props.fieldContext ?? {})) || toValue$1(unref(props.bladeContext.scope)?.[props.element.options]))) ?? void 0;
|
|
1607
|
+
const contextProperty = safeIn("optionProperty", props.element) && props.element.optionProperty && getModel(props.element.optionProperty, props.fieldContext ?? {});
|
|
1608
|
+
const scopedProperty = safeIn("optionProperty", props.element) && props.element.optionProperty && props.bladeContext.scope && getModel(props.element.optionProperty, props.bladeContext.scope);
|
|
1609
|
+
const field = InputCurrency$1({
|
|
1610
|
+
props: Object.assign(
|
|
1611
|
+
{},
|
|
1612
|
+
{
|
|
1613
|
+
precision: props.element.precision,
|
|
1614
|
+
option: toValue$1(scopedProperty ?? contextProperty),
|
|
1615
|
+
currencyDisplay: props.element.currencyDisplay,
|
|
1616
|
+
optionLabel: props.element.optionLabel,
|
|
1617
|
+
optionValue: props.element.optionValue,
|
|
1618
|
+
options,
|
|
1619
|
+
"onUpdate:option": (e) => {
|
|
1620
|
+
setModel({
|
|
1621
|
+
value: e,
|
|
1622
|
+
property: props.element.optionProperty,
|
|
1623
|
+
context: props.fieldContext ?? {},
|
|
1624
|
+
scope: props.bladeContext.scope
|
|
1625
|
+
});
|
|
1626
|
+
},
|
|
1627
|
+
clearable: props.element.clearable || false
|
|
1628
|
+
},
|
|
1629
|
+
unrefNested(props.baseProps),
|
|
1630
|
+
{
|
|
1631
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
1632
|
+
}
|
|
1633
|
+
)
|
|
1634
|
+
});
|
|
1635
|
+
const render = h(field.component, field.props);
|
|
1636
|
+
if (field.props.rules) {
|
|
1637
|
+
return h(
|
|
1638
|
+
ValidationField,
|
|
1639
|
+
{
|
|
1640
|
+
props: field.props,
|
|
1641
|
+
index: props.elIndex,
|
|
1642
|
+
rows: props.rows,
|
|
1643
|
+
key: `${String(field.props.key)}_validation`
|
|
1644
|
+
},
|
|
1645
|
+
() => render
|
|
1646
|
+
);
|
|
1647
|
+
} else {
|
|
1648
|
+
return render;
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
|
|
1654
|
+
function unwrapInterpolation(property, context) {
|
|
1655
|
+
const pattern = /{(.*)}/g;
|
|
1656
|
+
const match = property.match(pattern);
|
|
1657
|
+
if (match !== null) {
|
|
1658
|
+
return getModel(property.replace(/{|}/g, ""), context);
|
|
1659
|
+
}
|
|
1660
|
+
return property;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
const Checkbox = {
|
|
1664
|
+
name: "Checkbox",
|
|
1665
|
+
props: componentProps,
|
|
1666
|
+
setup(props) {
|
|
1667
|
+
const { t } = useI18n({ useScope: "global" });
|
|
1668
|
+
return () => {
|
|
1669
|
+
const field = Checkbox$1({
|
|
1670
|
+
props: Object.assign(
|
|
1671
|
+
{},
|
|
1672
|
+
{
|
|
1673
|
+
trueValue: props.element.trueValue,
|
|
1674
|
+
falseValue: props.element.falseValue
|
|
1675
|
+
},
|
|
1676
|
+
unrefNested(props.baseProps),
|
|
1677
|
+
{
|
|
1678
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
1679
|
+
}
|
|
1680
|
+
),
|
|
1681
|
+
slots: {
|
|
1682
|
+
default: () => unref(computed(() => t(unwrapInterpolation(props.element.content, toValue$1(props.fieldContext)))))
|
|
1683
|
+
}
|
|
1684
|
+
});
|
|
1685
|
+
const render = h(field.component, field.props, field.slots);
|
|
1686
|
+
if (field.props.rules) {
|
|
1687
|
+
return h(
|
|
1688
|
+
ValidationField,
|
|
1689
|
+
{
|
|
1690
|
+
props: field.props,
|
|
1691
|
+
slots: field.slots,
|
|
1692
|
+
index: props.elIndex,
|
|
1693
|
+
rows: props.rows
|
|
1694
|
+
},
|
|
1695
|
+
() => render
|
|
1696
|
+
);
|
|
1697
|
+
} else {
|
|
1698
|
+
return render;
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
|
|
1704
|
+
const DynamicProperty = {
|
|
1705
|
+
name: "DynamicProperty",
|
|
1706
|
+
props: componentProps,
|
|
1707
|
+
emits: ["setModelData"],
|
|
1708
|
+
setup(props) {
|
|
1709
|
+
if (!props.bladeContext.scope?.dynamicProperties) {
|
|
1710
|
+
throw new Error(
|
|
1711
|
+
`There is no DynamicProperties config provided in blade scope: ${JSON.stringify(
|
|
1712
|
+
props.bladeContext.scope,
|
|
1713
|
+
null,
|
|
1714
|
+
2
|
|
1715
|
+
)}`
|
|
1716
|
+
);
|
|
1717
|
+
}
|
|
1718
|
+
const internalModel = ref();
|
|
1719
|
+
watch(
|
|
1720
|
+
() => props.baseProps?.modelValue,
|
|
1721
|
+
(newVal) => {
|
|
1722
|
+
if (!isEqual(toValue(newVal), internalModel.value)) {
|
|
1723
|
+
internalModel.value = cloneDeep(toValue(newVal));
|
|
1724
|
+
}
|
|
1725
|
+
},
|
|
1726
|
+
{ deep: true, immediate: true }
|
|
1727
|
+
);
|
|
1728
|
+
const filteredProps = reactify(
|
|
1729
|
+
(prop, { include, exclude }) => {
|
|
1730
|
+
if (prop) {
|
|
1731
|
+
return prop.filter((x) => {
|
|
1732
|
+
if (include) return include?.includes(x.type);
|
|
1733
|
+
if (exclude) return !exclude?.includes(x.type);
|
|
1734
|
+
else return true;
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
return null;
|
|
1738
|
+
}
|
|
1739
|
+
);
|
|
1740
|
+
const dynamicProps = filteredProps(internalModel, {
|
|
1741
|
+
include: props.element?.include,
|
|
1742
|
+
exclude: props.element?.exclude
|
|
1743
|
+
});
|
|
1744
|
+
const initialProps = cloneDeep(dynamicProps.value);
|
|
1745
|
+
const properties = reactiveComputed(() => {
|
|
1746
|
+
return (dynamicProps.value || [])?.map(
|
|
1747
|
+
(prop) => DynamicProperties({
|
|
1748
|
+
props: {
|
|
1749
|
+
disabled: props.bladeContext.scope && "disabled" in props.bladeContext.scope && props.bladeContext.scope.disabled,
|
|
1750
|
+
property: prop,
|
|
1751
|
+
modelValue: computed(
|
|
1752
|
+
() => props.bladeContext.scope?.dynamicProperties?.getPropertyValue(
|
|
1753
|
+
prop,
|
|
1754
|
+
toValue(props.currentLocale ?? "en-US")
|
|
1755
|
+
)
|
|
1756
|
+
),
|
|
1757
|
+
optionsGetter: props.bladeContext.scope?.dynamicProperties?.loadDictionaries,
|
|
1758
|
+
"onUpdate:model-value": (args) => {
|
|
1759
|
+
props.bladeContext.scope?.dynamicProperties?.setPropertyValue({
|
|
1760
|
+
property: prop,
|
|
1761
|
+
value: args.value,
|
|
1762
|
+
dictionary: args.dictionary,
|
|
1763
|
+
locale: args.locale,
|
|
1764
|
+
initialProp: cloneDeep(initialProps?.find((x) => x.id === prop.id))
|
|
1765
|
+
});
|
|
1766
|
+
if (props.fieldContext) {
|
|
1767
|
+
setModel({ context: props.fieldContext, property: props.element.property, value: internalModel.value });
|
|
1768
|
+
}
|
|
1769
|
+
},
|
|
1770
|
+
required: prop.required,
|
|
1771
|
+
multivalue: prop.multivalue,
|
|
1772
|
+
multilanguage: prop.multilanguage,
|
|
1773
|
+
valueType: prop.valueType,
|
|
1774
|
+
dictionary: prop.dictionary,
|
|
1775
|
+
name: prop.name,
|
|
1776
|
+
rules: {
|
|
1777
|
+
min: prop.validationRule?.charCountMin,
|
|
1778
|
+
max: prop.validationRule?.charCountMax,
|
|
1779
|
+
regex: prop.validationRule?.regExp
|
|
1780
|
+
},
|
|
1781
|
+
displayNames: prop.displayNames,
|
|
1782
|
+
key: prop.multilanguage ? prop.name + "_" + prop.id + "_" + props.currentLocale : prop.name + "_" + prop.id,
|
|
1783
|
+
currentLanguage: props.currentLocale
|
|
1784
|
+
}
|
|
1785
|
+
})
|
|
1786
|
+
);
|
|
1787
|
+
});
|
|
1788
|
+
return () => {
|
|
1789
|
+
return properties && properties.length ? properties.map(
|
|
1790
|
+
(field) => h(field.component, {
|
|
1791
|
+
...unrefNested(field.props),
|
|
1792
|
+
class: unrefNested(props.baseProps).classNames ?? "",
|
|
1793
|
+
key: field.props.key
|
|
1794
|
+
})
|
|
1795
|
+
) : null;
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
const EditorField = {
|
|
1801
|
+
name: "EditorField",
|
|
1802
|
+
props: componentProps,
|
|
1803
|
+
setup(props) {
|
|
1804
|
+
return () => {
|
|
1805
|
+
const field = EditorField$1({
|
|
1806
|
+
props: Object.assign(
|
|
1807
|
+
{},
|
|
1808
|
+
{
|
|
1809
|
+
currentLanguage: props.currentLocale,
|
|
1810
|
+
assetsFolder: props.element.assetsFolder,
|
|
1811
|
+
maxlength: props.element.maxlength
|
|
1812
|
+
},
|
|
1813
|
+
unrefNested(props.baseProps),
|
|
1814
|
+
{
|
|
1815
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
1816
|
+
}
|
|
1817
|
+
)
|
|
1818
|
+
});
|
|
1819
|
+
const render = h(field.component, field.props);
|
|
1820
|
+
if (field.props.rules) {
|
|
1821
|
+
return h(
|
|
1822
|
+
ValidationField,
|
|
1823
|
+
{
|
|
1824
|
+
props: field.props,
|
|
1825
|
+
index: props.elIndex,
|
|
1826
|
+
rows: props.rows,
|
|
1827
|
+
key: `${String(field.props.key)}_validation`
|
|
1828
|
+
},
|
|
1829
|
+
() => render
|
|
1830
|
+
);
|
|
1831
|
+
} else {
|
|
1832
|
+
return render;
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
|
|
1838
|
+
const GalleryField = {
|
|
1839
|
+
name: "GalleryField",
|
|
1840
|
+
props: componentProps,
|
|
1841
|
+
setup(props) {
|
|
1842
|
+
if (!(safeIn("bladeContext", props) && props.bladeContext && safeIn("scope", props.bladeContext) && props.bladeContext.scope && props.bladeContext.scope.assetsHandler?.images)) {
|
|
1843
|
+
throw new Error(
|
|
1844
|
+
`There is no assetsHandler.images config provided in blade scope: ${JSON.stringify(
|
|
1845
|
+
props.bladeContext.scope,
|
|
1846
|
+
null,
|
|
1847
|
+
2
|
|
1848
|
+
)}`
|
|
1849
|
+
);
|
|
1850
|
+
}
|
|
1851
|
+
const { showConfirmation } = usePopup();
|
|
1852
|
+
const { t } = useI18n({ useScope: "global" });
|
|
1853
|
+
const { openBlade } = useBladeNavigation();
|
|
1854
|
+
const imagesHandler = toRefs(props.bladeContext.scope?.assetsHandler?.images);
|
|
1855
|
+
const internalModel = ref();
|
|
1856
|
+
watch(
|
|
1857
|
+
() => props.fieldContext,
|
|
1858
|
+
(newVal) => {
|
|
1859
|
+
if (!isEqual(internalModel.value, newVal)) {
|
|
1860
|
+
internalModel.value = cloneDeep(newVal);
|
|
1861
|
+
}
|
|
1862
|
+
},
|
|
1863
|
+
{ deep: true, immediate: true }
|
|
1864
|
+
);
|
|
1865
|
+
return () => {
|
|
1866
|
+
const imageHandlers = {
|
|
1867
|
+
loading: imagesHandler.loading ?? false,
|
|
1868
|
+
async edit(image) {
|
|
1869
|
+
if (!imagesHandler.edit?.value) throw new Error("Edit handler is not provided");
|
|
1870
|
+
const edited = await imagesHandler.edit?.value?.([image]);
|
|
1871
|
+
await editImages(edited);
|
|
1872
|
+
},
|
|
1873
|
+
async upload(files, lastSortOrder) {
|
|
1874
|
+
if (!imagesHandler.upload?.value) throw new Error("Upload handler is not provided");
|
|
1875
|
+
if (files) {
|
|
1876
|
+
const uploaded = await imagesHandler.upload?.value?.(files, lastSortOrder);
|
|
1877
|
+
let addToExisting;
|
|
1878
|
+
if (Array.isArray(uploaded) && Array.isArray(internalModel.value[props.element.property])) {
|
|
1879
|
+
addToExisting = internalModel.value[props.element.property].concat(uploaded);
|
|
1880
|
+
} else {
|
|
1881
|
+
addToExisting = uploaded;
|
|
1882
|
+
}
|
|
1883
|
+
files = null;
|
|
1884
|
+
await editImages(addToExisting);
|
|
1885
|
+
}
|
|
1886
|
+
},
|
|
1887
|
+
async remove(image) {
|
|
1888
|
+
if (!imagesHandler.remove?.value) throw new Error("Remove handler is not provided");
|
|
1889
|
+
if (imagesHandler.noRemoveConfirmation || await showConfirmation(
|
|
1890
|
+
computed(
|
|
1891
|
+
() => t(
|
|
1892
|
+
`${props.bladeContext?.settings?.localizationPrefix.trim().toUpperCase()}.PAGES.ALERTS.IMAGE_DELETE_CONFIRMATION`
|
|
1893
|
+
)
|
|
1894
|
+
)
|
|
1895
|
+
)) {
|
|
1896
|
+
const edited = await imagesHandler.remove?.value?.([image]);
|
|
1897
|
+
await editImages(edited);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
};
|
|
1901
|
+
function onGalleryItemEdit(item) {
|
|
1902
|
+
openBlade({
|
|
1903
|
+
blade: markRaw(_sfc_main$m),
|
|
1904
|
+
options: {
|
|
1905
|
+
asset: item,
|
|
1906
|
+
assetEditHandler: imageHandlers.edit,
|
|
1907
|
+
assetRemoveHandler: imageHandlers.remove
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
async function editImages(args) {
|
|
1912
|
+
if (props.fieldContext) {
|
|
1913
|
+
internalModel.value[props.element.property] = args;
|
|
1914
|
+
setModel({
|
|
1915
|
+
property: props.element.property,
|
|
1916
|
+
value: args,
|
|
1917
|
+
context: props.fieldContext,
|
|
1918
|
+
scope: props.bladeContext.scope
|
|
1919
|
+
});
|
|
1920
|
+
if (props.bladeContext.validationState) {
|
|
1921
|
+
await props.bladeContext.validationState.setFieldValue(props.element.id, args);
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
const field = Gallery({
|
|
1926
|
+
props: Object.assign(
|
|
1927
|
+
{},
|
|
1928
|
+
{
|
|
1929
|
+
customText: {
|
|
1930
|
+
dragHere: typeof props.element.customText?.dragHere !== "undefined" ? unref(computed(() => t(props.element.customText.dragHere))) : void 0,
|
|
1931
|
+
browse: typeof props.element.customText?.browse !== "undefined" ? unref(computed(() => t(props.element.customText.browse))) : void 0
|
|
1932
|
+
},
|
|
1933
|
+
uploadIcon: props.element.uploadIcon,
|
|
1934
|
+
loading: imageHandlers.loading,
|
|
1935
|
+
images: toValue(props.baseProps.modelValue),
|
|
1936
|
+
multiple: props.element.multiple,
|
|
1937
|
+
variant: props.element.variant,
|
|
1938
|
+
itemActions: props.element.actions,
|
|
1939
|
+
onUpload: imageHandlers.upload,
|
|
1940
|
+
onRemove: imageHandlers.remove,
|
|
1941
|
+
onEdit: onGalleryItemEdit,
|
|
1942
|
+
onSort: editImages,
|
|
1943
|
+
hideAfterUpload: props.element.hideAfterUpload
|
|
1944
|
+
},
|
|
1945
|
+
unrefNested(props.baseProps),
|
|
1946
|
+
{
|
|
1947
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
1948
|
+
}
|
|
1949
|
+
)
|
|
1950
|
+
});
|
|
1951
|
+
return h(field.component, Object.assign(unrefNested(field.props), { class: "tw-flex-auto" }));
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
|
|
1956
|
+
const Button = {
|
|
1957
|
+
name: "ButtonEl",
|
|
1958
|
+
props: componentProps,
|
|
1959
|
+
setup(props) {
|
|
1960
|
+
const { t } = useI18n({ useScope: "global" });
|
|
1961
|
+
return () => {
|
|
1962
|
+
const field = Button$1({
|
|
1963
|
+
props: Object.assign(
|
|
1964
|
+
{},
|
|
1965
|
+
{
|
|
1966
|
+
small: props.element.small,
|
|
1967
|
+
icon: props.element?.icon,
|
|
1968
|
+
iconSize: props.element?.iconSize,
|
|
1969
|
+
text: props.element?.text,
|
|
1970
|
+
variant: props.element?.variant,
|
|
1971
|
+
raised: props.element?.raised,
|
|
1972
|
+
outline: props.element?.outline,
|
|
1973
|
+
onClick: () => {
|
|
1974
|
+
unref(props.bladeContext.scope)?.[props.element.method]();
|
|
1975
|
+
}
|
|
1976
|
+
},
|
|
1977
|
+
unrefNested(props.baseProps),
|
|
1978
|
+
{
|
|
1979
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
1980
|
+
}
|
|
1981
|
+
),
|
|
1982
|
+
slots: props.element.content ? {
|
|
1983
|
+
default: () => unref(computed(() => (props.element.content && t(props.element.content)) ?? void 0))
|
|
1984
|
+
} : void 0
|
|
1985
|
+
});
|
|
1986
|
+
return h(field.component, mergeProps(field.props, { class: "tw-self-start" }), field.slots);
|
|
1987
|
+
};
|
|
1988
|
+
}
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1991
|
+
const StatusField = {
|
|
1992
|
+
name: "StatusField",
|
|
1993
|
+
props: componentProps,
|
|
1994
|
+
setup(props) {
|
|
1995
|
+
const { t } = useI18n({ useScope: "global" });
|
|
1996
|
+
const hasOverflow = ref(false);
|
|
1997
|
+
const isExpanded = ref(false);
|
|
1998
|
+
const contentRef = ref(null);
|
|
1999
|
+
const toggle = () => {
|
|
2000
|
+
isExpanded.value = !isExpanded.value;
|
|
2001
|
+
};
|
|
2002
|
+
const checkOverflow = () => {
|
|
2003
|
+
if (contentRef.value) {
|
|
2004
|
+
hasOverflow.value = contentRef.value.scrollHeight > 100;
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
onMounted(() => {
|
|
2008
|
+
checkOverflow();
|
|
2009
|
+
});
|
|
2010
|
+
return () => {
|
|
2011
|
+
const slotContent = computed(() => {
|
|
2012
|
+
if (props.element.content && typeof props.element.content === "string") {
|
|
2013
|
+
return t(props.element.content);
|
|
2014
|
+
} else if (typeof props.element.content === "object" && "method" in props.element.content && props.element.content?.method) {
|
|
2015
|
+
const method = unref(props.bladeContext.scope)?.[props.element.content?.method];
|
|
2016
|
+
if (typeof method === "function") {
|
|
2017
|
+
return method();
|
|
2018
|
+
} else {
|
|
2019
|
+
return method;
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
return null;
|
|
2023
|
+
});
|
|
2024
|
+
const field = StatusField$1({
|
|
2025
|
+
props: Object.assign(
|
|
2026
|
+
{
|
|
2027
|
+
variant: props.element.variant,
|
|
2028
|
+
outline: props.element.outline,
|
|
2029
|
+
extend: props.element.extend
|
|
2030
|
+
},
|
|
2031
|
+
unrefNested(props.baseProps),
|
|
2032
|
+
{
|
|
2033
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2034
|
+
}
|
|
2035
|
+
),
|
|
2036
|
+
slots: {
|
|
2037
|
+
default: () => {
|
|
2038
|
+
return h("div", { class: "tw-flex tw-flex-row tw-items-center" }, [
|
|
2039
|
+
props.element.icon ? h(_sfc_main$n, {
|
|
2040
|
+
icon: props.element.icon,
|
|
2041
|
+
size: props.element.iconSize,
|
|
2042
|
+
variant: props.element.iconVariant,
|
|
2043
|
+
class: "tw-mr-3"
|
|
2044
|
+
}) : void 0,
|
|
2045
|
+
h("div", { class: "tw-flex tw-flex-col", style: "text-align: start;" }, [
|
|
2046
|
+
h("div", { class: "tw-font-bold" }, computed(() => t(props.element.title ?? "")).value),
|
|
2047
|
+
h(
|
|
2048
|
+
"div",
|
|
2049
|
+
{
|
|
2050
|
+
class: {
|
|
2051
|
+
"tw-overflow-hidden": true,
|
|
2052
|
+
"tw-max-h-[100px] tw-line-clamp-4": !isExpanded.value,
|
|
2053
|
+
"tw-max-h-[100%]": isExpanded.value
|
|
2054
|
+
},
|
|
2055
|
+
ref: contentRef
|
|
2056
|
+
},
|
|
2057
|
+
slotContent.value
|
|
2058
|
+
),
|
|
2059
|
+
hasOverflow.value ? h(
|
|
2060
|
+
_sfc_main$c,
|
|
2061
|
+
{ text: true, class: "tw-self-end", onClick: toggle },
|
|
2062
|
+
() => isExpanded.value ? t("COMPONENTS.ATOMS.VC_STATUS.SHOW_LESS") : t("COMPONENTS.ATOMS.VC_STATUS.SHOW_MORE")
|
|
2063
|
+
) : void 0
|
|
2064
|
+
])
|
|
2065
|
+
]);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
});
|
|
2069
|
+
return h(
|
|
2070
|
+
field.component,
|
|
2071
|
+
{ ...field.props, class: props.element.extend ? "tw-w-full tw-box-border" : "tw-flex tw-self-start" },
|
|
2072
|
+
field.slots
|
|
2073
|
+
);
|
|
2074
|
+
};
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
|
|
2078
|
+
const ContentField = {
|
|
2079
|
+
name: "ContentField",
|
|
2080
|
+
props: componentProps,
|
|
2081
|
+
setup(props) {
|
|
2082
|
+
return () => {
|
|
2083
|
+
const field = ContentField$1({
|
|
2084
|
+
props: Object.assign(
|
|
2085
|
+
{},
|
|
2086
|
+
{
|
|
2087
|
+
type: props.element.variant,
|
|
2088
|
+
copyable: props.element.copyable || false,
|
|
2089
|
+
orientation: props.element.orientation,
|
|
2090
|
+
aspectRatio: props.element.aspectRatio
|
|
2091
|
+
},
|
|
2092
|
+
unrefNested(props.baseProps),
|
|
2093
|
+
{
|
|
2094
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2095
|
+
}
|
|
2096
|
+
)
|
|
2097
|
+
});
|
|
2098
|
+
const render = h(field.component, field.props);
|
|
2099
|
+
return render;
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
};
|
|
2103
|
+
|
|
2104
|
+
const VideoField = {
|
|
2105
|
+
name: "VideoField",
|
|
2106
|
+
props: componentProps,
|
|
2107
|
+
setup(props) {
|
|
2108
|
+
return () => {
|
|
2109
|
+
const field = VideoField$1({
|
|
2110
|
+
props: Object.assign(
|
|
2111
|
+
{},
|
|
2112
|
+
{
|
|
2113
|
+
source: toValue(props.baseProps.modelValue)
|
|
2114
|
+
},
|
|
2115
|
+
unrefNested(props.baseProps),
|
|
2116
|
+
{
|
|
2117
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2118
|
+
}
|
|
2119
|
+
)
|
|
2120
|
+
});
|
|
2121
|
+
const render = h(field.component, field.props);
|
|
2122
|
+
return render;
|
|
2123
|
+
};
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
|
|
2127
|
+
const ImageField = {
|
|
2128
|
+
name: "ImageField",
|
|
2129
|
+
props: componentProps,
|
|
2130
|
+
setup(props) {
|
|
2131
|
+
return () => {
|
|
2132
|
+
const field = ImageField$1({
|
|
2133
|
+
props: Object.assign(
|
|
2134
|
+
{},
|
|
2135
|
+
{
|
|
2136
|
+
src: toValue(props.baseProps.modelValue),
|
|
2137
|
+
aspect: props.element.aspect,
|
|
2138
|
+
rounded: props.element.rounded,
|
|
2139
|
+
bordered: props.element.bordered,
|
|
2140
|
+
size: props.element.size,
|
|
2141
|
+
background: props.element.background
|
|
2142
|
+
},
|
|
2143
|
+
unrefNested(props.baseProps),
|
|
2144
|
+
{
|
|
2145
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2146
|
+
}
|
|
2147
|
+
)
|
|
2148
|
+
});
|
|
2149
|
+
const render = h(field.component, field.props);
|
|
2150
|
+
return render;
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
|
|
2155
|
+
const TextareaField = {
|
|
2156
|
+
name: "TextareaField",
|
|
2157
|
+
props: componentProps,
|
|
2158
|
+
setup(props) {
|
|
2159
|
+
return () => {
|
|
2160
|
+
const field = TextareaField$1({
|
|
2161
|
+
props: Object.assign(
|
|
2162
|
+
{},
|
|
2163
|
+
{
|
|
2164
|
+
currentLanguage: props.currentLocale,
|
|
2165
|
+
clearable: props.element.clearable || false,
|
|
2166
|
+
maxlength: props.element.maxlength
|
|
2167
|
+
},
|
|
2168
|
+
unrefNested(props.baseProps),
|
|
2169
|
+
{
|
|
2170
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2171
|
+
}
|
|
2172
|
+
)
|
|
2173
|
+
});
|
|
2174
|
+
const render = h(field.component, field.props);
|
|
2175
|
+
if (field.props.rules) {
|
|
2176
|
+
return h(
|
|
2177
|
+
ValidationField,
|
|
2178
|
+
{
|
|
2179
|
+
props: field.props,
|
|
2180
|
+
index: props.elIndex,
|
|
2181
|
+
rows: props.rows,
|
|
2182
|
+
key: `${String(field.props.key)}_validation`
|
|
2183
|
+
},
|
|
2184
|
+
() => render
|
|
2185
|
+
);
|
|
2186
|
+
} else {
|
|
2187
|
+
return render;
|
|
2188
|
+
}
|
|
2189
|
+
};
|
|
2190
|
+
}
|
|
2191
|
+
};
|
|
2192
|
+
|
|
2193
|
+
const MultivalueField = {
|
|
2194
|
+
name: "MultivalueField",
|
|
2195
|
+
props: componentProps,
|
|
2196
|
+
setup(props) {
|
|
2197
|
+
return () => {
|
|
2198
|
+
const field = MultivalueField$1({
|
|
2199
|
+
props: Object.assign(
|
|
2200
|
+
{},
|
|
2201
|
+
{
|
|
2202
|
+
multivalue: props.element.multivalue,
|
|
2203
|
+
type: props.element.variant,
|
|
2204
|
+
optionValue: props.element.optionValue,
|
|
2205
|
+
optionLabel: props.element.optionLabel,
|
|
2206
|
+
options: props.element.options ? props.bladeContext.scope?.[props.element.options] : void 0,
|
|
2207
|
+
currentLanguage: props.currentLocale
|
|
2208
|
+
},
|
|
2209
|
+
unrefNested(props.baseProps),
|
|
2210
|
+
{
|
|
2211
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2212
|
+
}
|
|
2213
|
+
),
|
|
2214
|
+
slots: props.element.customTemplate && ["option", "selected-item"].reduce(
|
|
2215
|
+
(obj, slot) => {
|
|
2216
|
+
obj[slot] = (scope) => h(resolveComponent(props.element.customTemplate?.component), {
|
|
2217
|
+
context: scope,
|
|
2218
|
+
slotName: slot
|
|
2219
|
+
});
|
|
2220
|
+
return obj;
|
|
2221
|
+
},
|
|
2222
|
+
{}
|
|
2223
|
+
)
|
|
2224
|
+
});
|
|
2225
|
+
const render = h(field.component, field.props, field.slots);
|
|
2226
|
+
if (field.props.rules) {
|
|
2227
|
+
return h(
|
|
2228
|
+
ValidationField,
|
|
2229
|
+
{
|
|
2230
|
+
props: field.props,
|
|
2231
|
+
index: props.elIndex,
|
|
2232
|
+
rows: props.rows,
|
|
2233
|
+
key: `${String(field.props.key)}_validation`
|
|
2234
|
+
},
|
|
2235
|
+
() => render
|
|
2236
|
+
);
|
|
2237
|
+
} else {
|
|
2238
|
+
return render;
|
|
2239
|
+
}
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
};
|
|
2243
|
+
|
|
2244
|
+
const SwitchField = {
|
|
2245
|
+
name: "SwitchEl",
|
|
2246
|
+
props: componentProps,
|
|
2247
|
+
setup(props) {
|
|
2248
|
+
return () => {
|
|
2249
|
+
const field = Switch({
|
|
2250
|
+
props: Object.assign(
|
|
2251
|
+
{},
|
|
2252
|
+
{
|
|
2253
|
+
trueValue: props.element.trueValue,
|
|
2254
|
+
falseValue: props.element.falseValue
|
|
2255
|
+
},
|
|
2256
|
+
unrefNested(props.baseProps),
|
|
2257
|
+
{
|
|
2258
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2259
|
+
}
|
|
2260
|
+
)
|
|
2261
|
+
});
|
|
2262
|
+
return h(field.component, field.props);
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
};
|
|
2266
|
+
|
|
2267
|
+
const Table = {
|
|
2268
|
+
name: "TableEl",
|
|
2269
|
+
props: componentProps,
|
|
2270
|
+
setup(props) {
|
|
2271
|
+
const { tableTemplates } = useTableTemplates(props.element);
|
|
2272
|
+
const { t } = useI18n({ useScope: "global" });
|
|
2273
|
+
const enableEdit = inject("isBladeEditable", false);
|
|
2274
|
+
const enableEditComputed = computed(() => unref(enableEdit));
|
|
2275
|
+
unrefNested(props.baseProps).modelValue ?? [];
|
|
2276
|
+
function disabledActionHandler(disabled, item) {
|
|
2277
|
+
if (!disabled) return false;
|
|
2278
|
+
if (typeof disabled === "boolean") return disabled;
|
|
2279
|
+
else if (disabled.method && typeof toValue(props.bladeContext.scope)?.[disabled.method] === "function")
|
|
2280
|
+
return toValue(props.bladeContext.scope)?.[disabled.method]({ item });
|
|
2281
|
+
else if (disabled.method && toValue(props.bladeContext.scope)?.[disabled.method])
|
|
2282
|
+
return toValue(props.bladeContext.scope)?.[disabled.method];
|
|
2283
|
+
return false;
|
|
2284
|
+
}
|
|
2285
|
+
function actionBuilder(item) {
|
|
2286
|
+
const result = props.element?.actions?.reduce((arr, action) => {
|
|
2287
|
+
const isDisabled = disabledActionHandler(action?.disabled ?? false, item);
|
|
2288
|
+
if (!toValue(isDisabled)) {
|
|
2289
|
+
arr.push({
|
|
2290
|
+
icon: action.icon,
|
|
2291
|
+
title: computed(() => t(action.title)),
|
|
2292
|
+
type: action.type,
|
|
2293
|
+
clickHandler: async (itemVal, index) => {
|
|
2294
|
+
try {
|
|
2295
|
+
await toValue(props.bladeContext.scope)?.[action.method]?.(itemVal, index);
|
|
2296
|
+
} catch (error) {
|
|
2297
|
+
throw new Error(`Method ${action.method} is not defined in scope or toolbarOverrides`);
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
});
|
|
2301
|
+
}
|
|
2302
|
+
return arr;
|
|
2303
|
+
}, []);
|
|
2304
|
+
return result;
|
|
2305
|
+
}
|
|
2306
|
+
return () => {
|
|
2307
|
+
const field = Table$1({
|
|
2308
|
+
props: Object.assign(
|
|
2309
|
+
{},
|
|
2310
|
+
{
|
|
2311
|
+
addNewRowButton: props.element.addNewRowButton ? {
|
|
2312
|
+
title: computed(() => t(props.element.addNewRowButton?.title ?? "")),
|
|
2313
|
+
show: props.element.addNewRowButton.show
|
|
2314
|
+
} : void 0,
|
|
2315
|
+
header: !!props.element.header,
|
|
2316
|
+
footer: !!props.element.footer,
|
|
2317
|
+
multiselect: !!props.element.multiselect,
|
|
2318
|
+
columns: props.element.columns?.map((col) => ({ ...col, title: computed(() => t(col.title)) })),
|
|
2319
|
+
items: unrefNested(props.baseProps).modelValue ?? [],
|
|
2320
|
+
stateKey: props.element.id,
|
|
2321
|
+
class: `!tw-flex-auto ${unrefNested(props.baseProps).classNames ?? ""}`,
|
|
2322
|
+
editing: enableEditComputed.value,
|
|
2323
|
+
enableItemActions: !!props.element.actions,
|
|
2324
|
+
itemActionBuilder: actionBuilder,
|
|
2325
|
+
get selectedItemId() {
|
|
2326
|
+
if (props.element.selectedItemId?.method && props.bladeContext.scope?.[props.element.selectedItemId?.method]) {
|
|
2327
|
+
if (typeof props.bladeContext.scope?.[props.element.selectedItemId?.method] === "function") {
|
|
2328
|
+
return props.bladeContext.scope?.[props.element.selectedItemId?.method]?.();
|
|
2329
|
+
} else {
|
|
2330
|
+
return props.bladeContext.scope?.[props.element.selectedItemId?.method];
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
},
|
|
2334
|
+
get selectedItems() {
|
|
2335
|
+
if (props.element.selectedIds?.method && props.bladeContext.scope?.[props.element.selectedIds?.method] && typeof props.bladeContext.scope?.[props.element.selectedIds?.method] === "function") {
|
|
2336
|
+
return props.bladeContext.scope?.[props.element.selectedIds?.method]?.();
|
|
2337
|
+
}
|
|
2338
|
+
return [];
|
|
2339
|
+
},
|
|
2340
|
+
onItemClick: (item) => {
|
|
2341
|
+
if (props.element.onItemClick?.method && props.bladeContext.scope?.[props.element.onItemClick?.method] && typeof props.bladeContext.scope?.[props.element.onItemClick?.method] === "function") {
|
|
2342
|
+
props.bladeContext.scope?.[props.element.onItemClick?.method](item);
|
|
2343
|
+
}
|
|
2344
|
+
},
|
|
2345
|
+
onOnEditComplete: (data) => {
|
|
2346
|
+
if (props.fieldContext) {
|
|
2347
|
+
setModel({
|
|
2348
|
+
context: props.fieldContext,
|
|
2349
|
+
property: `${props.element.property}.${data.index}.${data.event.field}`,
|
|
2350
|
+
value: data.event.value
|
|
2351
|
+
});
|
|
2352
|
+
}
|
|
2353
|
+
},
|
|
2354
|
+
onOnAddNewRow: () => {
|
|
2355
|
+
if (props.element.addNewRowButton?.method && props.bladeContext.scope?.[props.element.addNewRowButton?.method] && typeof props.bladeContext.scope?.[props.element.addNewRowButton?.method] === "function") {
|
|
2356
|
+
props.bladeContext.scope?.[props.element.addNewRowButton?.method]?.();
|
|
2357
|
+
}
|
|
2358
|
+
},
|
|
2359
|
+
onOnCellBlur: async (data) => {
|
|
2360
|
+
if (props.element.columns) {
|
|
2361
|
+
const column = props.element.columns.find((col) => col.id === data.field);
|
|
2362
|
+
if (column && column.onCellBlur && column.onCellBlur.method) {
|
|
2363
|
+
if (props.bladeContext.scope?.[column.onCellBlur.method] && typeof props.bladeContext.scope[column.onCellBlur.method] === "function") {
|
|
2364
|
+
await props.bladeContext.scope[column.onCellBlur.method](data);
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
},
|
|
2370
|
+
unrefNested(props.baseProps)
|
|
2371
|
+
),
|
|
2372
|
+
slots: {
|
|
2373
|
+
...Object.entries(tableTemplates.templateOverrideComponents).reduce(
|
|
2374
|
+
(obj, [key, value], index) => {
|
|
2375
|
+
obj[`item_${key}`] = (itemData) => {
|
|
2376
|
+
return h(unref(value), {
|
|
2377
|
+
index: itemData.index,
|
|
2378
|
+
context: itemData,
|
|
2379
|
+
key: `template_override_${props.element.id}_${index}`,
|
|
2380
|
+
bladeContext: props.bladeContext,
|
|
2381
|
+
onEditComplete: (data) => {
|
|
2382
|
+
if (props.fieldContext) {
|
|
2383
|
+
setModel({
|
|
2384
|
+
context: props.fieldContext,
|
|
2385
|
+
property: `${props.element.property}.${itemData.index}.${key}`,
|
|
2386
|
+
value: data
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
});
|
|
2391
|
+
};
|
|
2392
|
+
return obj;
|
|
2393
|
+
},
|
|
2394
|
+
{}
|
|
2395
|
+
),
|
|
2396
|
+
notfound: tableTemplates?.notFound ? () => h(tableTemplates.notFound, { context: props.bladeContext }) : void 0,
|
|
2397
|
+
"mobile-item": tableTemplates?.mobileView ? (itemData) => h(tableTemplates.mobileView, { context: itemData, bladeContext: props.bladeContext }) : void 0,
|
|
2398
|
+
empty: tableTemplates?.empty ? () => h(tableTemplates.empty, { context: props.bladeContext }) : void 0,
|
|
2399
|
+
footer: tableTemplates?.footer ? () => h(tableTemplates.footer, { context: props.bladeContext }) : void 0
|
|
2400
|
+
}
|
|
2401
|
+
});
|
|
2402
|
+
return h(field.component, field.props, field.slots);
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
2405
|
+
};
|
|
2406
|
+
|
|
2407
|
+
const CustomComponent = {
|
|
2408
|
+
name: "CustomComponentRenderer",
|
|
2409
|
+
props: componentProps,
|
|
2410
|
+
setup(props) {
|
|
2411
|
+
return () => {
|
|
2412
|
+
const component = resolveComponent(props.element?.name);
|
|
2413
|
+
return typeof component === "object" ? h(
|
|
2414
|
+
component,
|
|
2415
|
+
Object.assign(
|
|
2416
|
+
{},
|
|
2417
|
+
{
|
|
2418
|
+
context: props.bladeContext
|
|
2419
|
+
},
|
|
2420
|
+
{
|
|
2421
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2422
|
+
}
|
|
2423
|
+
)
|
|
2424
|
+
) : null;
|
|
2425
|
+
};
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2428
|
+
|
|
2429
|
+
const RatingField = {
|
|
2430
|
+
name: "RatingEl",
|
|
2431
|
+
props: componentProps,
|
|
2432
|
+
setup(props) {
|
|
2433
|
+
return () => {
|
|
2434
|
+
const field = Rating({
|
|
2435
|
+
props: Object.assign(
|
|
2436
|
+
{},
|
|
2437
|
+
{
|
|
2438
|
+
variant: props.element.type
|
|
2439
|
+
},
|
|
2440
|
+
unrefNested(props.baseProps),
|
|
2441
|
+
{
|
|
2442
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2443
|
+
}
|
|
2444
|
+
)
|
|
2445
|
+
});
|
|
2446
|
+
return h(field.component, field.props);
|
|
2447
|
+
};
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
|
|
2451
|
+
const RadioButtonGroup = {
|
|
2452
|
+
name: "RadioButtonGroup",
|
|
2453
|
+
props: componentProps,
|
|
2454
|
+
setup(props) {
|
|
2455
|
+
return () => {
|
|
2456
|
+
const label = unrefNested(props.baseProps).label;
|
|
2457
|
+
const options = toValue(getModel(props.element.options, props.fieldContext ?? {})) || toValue(unref(props.bladeContext.scope)?.[props.element.options]);
|
|
2458
|
+
const fields = options.map(
|
|
2459
|
+
(opt) => RadioButton({
|
|
2460
|
+
props: Object.assign(
|
|
2461
|
+
{},
|
|
2462
|
+
{
|
|
2463
|
+
value: props.element.optionValue ? toValue(getModel(props.element.optionValue, opt ?? {})) : opt,
|
|
2464
|
+
binary: props.element.binary,
|
|
2465
|
+
label: props.element.optionLabel ? toValue(getModel(props.element.optionLabel, opt ?? {})) : opt
|
|
2466
|
+
},
|
|
2467
|
+
omit(unrefNested(props.baseProps), "label"),
|
|
2468
|
+
{
|
|
2469
|
+
class: unrefNested(props.baseProps).classNames ?? ""
|
|
2470
|
+
}
|
|
2471
|
+
)
|
|
2472
|
+
})
|
|
2473
|
+
);
|
|
2474
|
+
const render = [
|
|
2475
|
+
label ? h(
|
|
2476
|
+
_sfc_main$l,
|
|
2477
|
+
{ required: props.element.rules?.required },
|
|
2478
|
+
{
|
|
2479
|
+
default: () => label,
|
|
2480
|
+
tooltip: unrefNested(props.baseProps).tooltip ? () => unrefNested(props.baseProps).tooltip : void 0
|
|
2481
|
+
}
|
|
2482
|
+
) : void 0,
|
|
2483
|
+
fields.map((field) => h(field.component, field.props)),
|
|
2484
|
+
h({
|
|
2485
|
+
props: ["error", "errorMessage"],
|
|
2486
|
+
components: { VcHint },
|
|
2487
|
+
template: `
|
|
2488
|
+
<VcHint v-if="error" class="vc-textarea__error">
|
|
2489
|
+
{{ errorMessage }}
|
|
2490
|
+
</VcHint>
|
|
2491
|
+
`
|
|
2492
|
+
})
|
|
2493
|
+
];
|
|
2494
|
+
if (props.element.rules) {
|
|
2495
|
+
return h(
|
|
2496
|
+
ValidationField,
|
|
2497
|
+
{
|
|
2498
|
+
props: {
|
|
2499
|
+
rules: props.element.rules,
|
|
2500
|
+
modelValue: unrefNested(props.baseProps).modelValue,
|
|
2501
|
+
label: unrefNested(props.baseProps).label,
|
|
2502
|
+
name: unrefNested(props.baseProps).name
|
|
2503
|
+
},
|
|
2504
|
+
index: props.elIndex,
|
|
2505
|
+
rows: props.rows
|
|
2506
|
+
},
|
|
2507
|
+
() => render
|
|
2508
|
+
);
|
|
2509
|
+
} else {
|
|
2510
|
+
return render;
|
|
2511
|
+
}
|
|
2512
|
+
};
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
|
|
2516
|
+
const FIELD_MAP = {
|
|
2517
|
+
"vc-select": SelectField,
|
|
2518
|
+
"vc-card": Card,
|
|
2519
|
+
"vc-input": InputField,
|
|
2520
|
+
"vc-fieldset": Fieldset,
|
|
2521
|
+
"vc-input-currency": InputCurrency,
|
|
2522
|
+
"vc-checkbox": Checkbox,
|
|
2523
|
+
"vc-dynamic-properties": DynamicProperty,
|
|
2524
|
+
"vc-editor": EditorField,
|
|
2525
|
+
"vc-gallery": GalleryField,
|
|
2526
|
+
"vc-button": Button,
|
|
2527
|
+
"vc-status": StatusField,
|
|
2528
|
+
"vc-field": ContentField,
|
|
2529
|
+
"vc-video": VideoField,
|
|
2530
|
+
"vc-image": ImageField,
|
|
2531
|
+
"vc-textarea": TextareaField,
|
|
2532
|
+
"vc-multivalue": MultivalueField,
|
|
2533
|
+
"vc-switch": SwitchField,
|
|
2534
|
+
"vc-table": Table,
|
|
2535
|
+
"vc-custom": CustomComponent,
|
|
2536
|
+
"vc-rating": RatingField,
|
|
2537
|
+
"vc-radio-button-group": RadioButtonGroup
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2540
|
+
const { hasAccess } = usePermissions();
|
|
2541
|
+
function disabledHandler(disabled, context) {
|
|
2542
|
+
if (!disabled) return false;
|
|
2543
|
+
if (typeof disabled === "boolean") return disabled;
|
|
2544
|
+
else if (disabled.method && typeof context.scope?.[disabled.method] === "function")
|
|
2545
|
+
return context.scope[disabled.method]();
|
|
2546
|
+
else if (disabled.method && context.scope?.[disabled.method]) return context.scope[disabled.method];
|
|
2547
|
+
return false;
|
|
2548
|
+
}
|
|
2549
|
+
function nodeBuilder({
|
|
2550
|
+
controlSchema,
|
|
2551
|
+
parentId,
|
|
2552
|
+
internalContext,
|
|
2553
|
+
bladeContext,
|
|
2554
|
+
currentLocale,
|
|
2555
|
+
formData,
|
|
2556
|
+
updateFormData
|
|
2557
|
+
}) {
|
|
2558
|
+
if (!controlSchema) throw new Error("There is no controlSchema provided");
|
|
2559
|
+
const { t } = i18n.global;
|
|
2560
|
+
const name = controlSchema.id;
|
|
2561
|
+
const rules = safeIn("rules", controlSchema) && controlSchema.rules || void 0;
|
|
2562
|
+
const placeholder = safeIn("placeholder", controlSchema) && controlSchema.placeholder || void 0;
|
|
2563
|
+
const required = safeIn("rules", controlSchema) && controlSchema.rules?.required;
|
|
2564
|
+
const contextProperty = safeIn("property", controlSchema) && controlSchema.property && getModel(controlSchema.property, internalContext);
|
|
2565
|
+
const scopedProperty = safeIn("property", controlSchema) && controlSchema.property && bladeContext.scope && getModel(controlSchema.property, bladeContext.scope);
|
|
2566
|
+
const modelValue = scopedProperty ?? contextProperty ?? void 0;
|
|
2567
|
+
const tooltip = safeIn("tooltip", controlSchema) && controlSchema.tooltip || void 0;
|
|
2568
|
+
const multilanguage = safeIn("multilanguage", controlSchema) && controlSchema.multilanguage;
|
|
2569
|
+
const label = safeIn("label", controlSchema) && controlSchema.label ? unref(unwrapInterpolation(controlSchema.label, internalContext)) : void 0;
|
|
2570
|
+
const hint = safeIn("hint", controlSchema) && controlSchema.hint ? (bladeContext.scope && unref(unwrapInterpolation(controlSchema.hint, bladeContext.scope))) ?? unref(unwrapInterpolation(controlSchema.hint, internalContext)) ?? void 0 : void 0;
|
|
2571
|
+
const disabled = bladeContext.scope && safeIn("disabled", bladeContext.scope) && bladeContext.scope.disabled || safeIn("disabled", controlSchema) && controlSchema.disabled && disabledHandler(controlSchema.disabled, bladeContext);
|
|
2572
|
+
const onBlur = (event) => {
|
|
2573
|
+
if (safeIn("onBlur", controlSchema) && controlSchema.onBlur) {
|
|
2574
|
+
const method = controlSchema.onBlur.method;
|
|
2575
|
+
if (method && bladeContext.scope?.[method] && typeof bladeContext.scope[method] === "function") {
|
|
2576
|
+
bladeContext.scope[method]({
|
|
2577
|
+
event,
|
|
2578
|
+
property: controlSchema.property,
|
|
2579
|
+
context: unrefNested(internalContext)
|
|
2580
|
+
});
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
};
|
|
2584
|
+
const onUpdateModelValue = async (e) => {
|
|
2585
|
+
if (safeIn("property", controlSchema) && controlSchema.property) {
|
|
2586
|
+
setModel({
|
|
2587
|
+
property: controlSchema.property,
|
|
2588
|
+
value: e,
|
|
2589
|
+
context: internalContext,
|
|
2590
|
+
scope: bladeContext.scope
|
|
2591
|
+
});
|
|
2592
|
+
updateFormData?.(formData);
|
|
2593
|
+
if (safeIn("update", controlSchema) && controlSchema.update && safeIn("method", controlSchema.update) && bladeContext.scope) {
|
|
2594
|
+
const updateMethod = controlSchema.update.method;
|
|
2595
|
+
if (safeIn(updateMethod, bladeContext.scope) && typeof bladeContext.scope[updateMethod] === "function") {
|
|
2596
|
+
await bladeContext.scope[updateMethod](e, controlSchema.property, unrefNested(internalContext));
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2601
|
+
const baseProps = reactive({
|
|
2602
|
+
key: `${parentId}`,
|
|
2603
|
+
label: computed(() => typeof label !== "undefined" ? t(label) : void 0),
|
|
2604
|
+
hint: computed(() => typeof hint !== "undefined" ? t(hint) : void 0),
|
|
2605
|
+
disabled,
|
|
2606
|
+
onBlur,
|
|
2607
|
+
name,
|
|
2608
|
+
rules,
|
|
2609
|
+
placeholder: computed(() => typeof placeholder !== "undefined" ? t(placeholder) : void 0),
|
|
2610
|
+
required,
|
|
2611
|
+
modelValue,
|
|
2612
|
+
"onUpdate:modelValue": onUpdateModelValue,
|
|
2613
|
+
tooltip: computed(() => typeof tooltip !== "undefined" ? t(tooltip) : void 0),
|
|
2614
|
+
multilanguage,
|
|
2615
|
+
"data-test-id": controlSchema.id,
|
|
2616
|
+
classNames: "horizontalSeparator" in controlSchema && controlSchema.horizontalSeparator ? "tw-border-b tw-border-solid tw-border-b-[var(--neutrals-200)] tw-mb-[5px] tw-pb-[21px]" : ""
|
|
2617
|
+
});
|
|
2618
|
+
const component = FIELD_MAP[controlSchema.component];
|
|
2619
|
+
const fieldsHandler = computed(() => {
|
|
2620
|
+
if (!("fields" in controlSchema)) return null;
|
|
2621
|
+
const contextFieldModel = safeIn("property", controlSchema) && controlSchema.property && getModel(controlSchema.property, internalContext);
|
|
2622
|
+
const scopedFieldModel = safeIn("property", controlSchema) && controlSchema.property && getModel(controlSchema.property, toValue(bladeContext.scope ?? {}));
|
|
2623
|
+
const model = scopedFieldModel || contextFieldModel;
|
|
2624
|
+
if (toValue(model) && Array.isArray(toValue(model))) {
|
|
2625
|
+
return toValue(model).map((modelItem) => {
|
|
2626
|
+
return controlSchema.fields.reduce((arr, fieldItem) => {
|
|
2627
|
+
if (safeIn("permissions", fieldItem) && !hasAccess(fieldItem.permissions)) {
|
|
2628
|
+
return arr;
|
|
2629
|
+
}
|
|
2630
|
+
if (safeIn("visibility", fieldItem) && fieldItem.visibility?.method && !methodHandler(bladeContext.scope?.[fieldItem.visibility?.method], modelItem, fieldItem)) {
|
|
2631
|
+
return arr;
|
|
2632
|
+
}
|
|
2633
|
+
return [
|
|
2634
|
+
...arr,
|
|
2635
|
+
nodeBuilder({
|
|
2636
|
+
controlSchema: fieldItem,
|
|
2637
|
+
parentId: `fieldset-${fieldItem.id}-${modelItem.id}`,
|
|
2638
|
+
internalContext: modelItem,
|
|
2639
|
+
bladeContext,
|
|
2640
|
+
currentLocale,
|
|
2641
|
+
formData,
|
|
2642
|
+
updateFormData
|
|
2643
|
+
})
|
|
2644
|
+
];
|
|
2645
|
+
}, []);
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
return [
|
|
2649
|
+
controlSchema.fields.reduce((arr, field) => {
|
|
2650
|
+
if (safeIn("permissions", field) && !hasAccess(field.permissions)) {
|
|
2651
|
+
return arr;
|
|
2652
|
+
}
|
|
2653
|
+
if (safeIn("visibility", field) && field.visibility?.method && !methodHandler(bladeContext.scope?.[field.visibility?.method], internalContext, field)) {
|
|
2654
|
+
return arr;
|
|
2655
|
+
}
|
|
2656
|
+
return [
|
|
2657
|
+
...arr,
|
|
2658
|
+
nodeBuilder({
|
|
2659
|
+
controlSchema: field,
|
|
2660
|
+
parentId: `fieldset-${parentId}-${field.id}`,
|
|
2661
|
+
internalContext,
|
|
2662
|
+
bladeContext,
|
|
2663
|
+
currentLocale,
|
|
2664
|
+
formData,
|
|
2665
|
+
updateFormData
|
|
2666
|
+
})
|
|
2667
|
+
];
|
|
2668
|
+
}, [])
|
|
2669
|
+
];
|
|
2670
|
+
});
|
|
2671
|
+
const elProps = {
|
|
2672
|
+
baseProps: toRefs$1(baseProps),
|
|
2673
|
+
bladeContext,
|
|
2674
|
+
element: controlSchema,
|
|
2675
|
+
currentLocale: unref(currentLocale),
|
|
2676
|
+
fields: fieldsHandler,
|
|
2677
|
+
formData,
|
|
2678
|
+
fieldContext: internalContext
|
|
2679
|
+
};
|
|
2680
|
+
return h(component, elProps);
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
const schemeRenderProps = {
|
|
2684
|
+
context: {
|
|
2685
|
+
type: Object,
|
|
2686
|
+
default: () => ({})
|
|
2687
|
+
},
|
|
2688
|
+
modelValue: {
|
|
2689
|
+
type: Object,
|
|
2690
|
+
required: true,
|
|
2691
|
+
default: () => ({})
|
|
2692
|
+
},
|
|
2693
|
+
uiSchema: {
|
|
2694
|
+
type: Array,
|
|
2695
|
+
required: true,
|
|
2696
|
+
default: () => []
|
|
2697
|
+
},
|
|
2698
|
+
currentLocale: {
|
|
2699
|
+
type: String,
|
|
2700
|
+
default: ""
|
|
2701
|
+
}
|
|
2702
|
+
};
|
|
2703
|
+
const SchemaRender = defineComponent({
|
|
2704
|
+
name: "SchemaRender",
|
|
2705
|
+
props: schemeRenderProps,
|
|
2706
|
+
emits: ["update:modelValue"],
|
|
2707
|
+
setup(props, ctx) {
|
|
2708
|
+
const { currentLocale } = toRefs(props);
|
|
2709
|
+
const internalFormData = reactive({});
|
|
2710
|
+
const { hasAccess } = usePermissions();
|
|
2711
|
+
watch(
|
|
2712
|
+
() => props.modelValue,
|
|
2713
|
+
(newVal) => {
|
|
2714
|
+
if (!isEqual(internalFormData, toRefs(newVal))) {
|
|
2715
|
+
Object.assign(internalFormData, toRefs(newVal));
|
|
2716
|
+
}
|
|
2717
|
+
},
|
|
2718
|
+
{ deep: true, immediate: true }
|
|
2719
|
+
);
|
|
2720
|
+
function updateFormData(newVal) {
|
|
2721
|
+
if (!isEqual(toRefs(newVal), internalFormData)) {
|
|
2722
|
+
ctx.emit("update:modelValue", unrefNested(newVal));
|
|
2723
|
+
}
|
|
2724
|
+
}
|
|
2725
|
+
return () => h(
|
|
2726
|
+
"div",
|
|
2727
|
+
{ class: "tw-flex tw-flex-col tw-gap-4" },
|
|
2728
|
+
props.uiSchema.reduce((arr, field) => {
|
|
2729
|
+
if (safeIn("permissions", field) && !hasAccess(field.permissions)) {
|
|
2730
|
+
return arr;
|
|
2731
|
+
}
|
|
2732
|
+
if (safeIn("visibility", field) && field.visibility?.method && !methodHandler(toValue$1(props.context?.scope)?.[field.visibility.method], props.context, field)) {
|
|
2733
|
+
return arr;
|
|
2734
|
+
}
|
|
2735
|
+
return [
|
|
2736
|
+
...arr,
|
|
2737
|
+
nodeBuilder({
|
|
2738
|
+
controlSchema: field,
|
|
2739
|
+
parentId: field.id,
|
|
2740
|
+
internalContext: internalFormData,
|
|
2741
|
+
bladeContext: props.context,
|
|
2742
|
+
currentLocale,
|
|
2743
|
+
formData: internalFormData,
|
|
2744
|
+
updateFormData
|
|
2745
|
+
})
|
|
2746
|
+
];
|
|
2747
|
+
}, [])
|
|
2748
|
+
);
|
|
2749
|
+
}
|
|
2750
|
+
});
|
|
2751
|
+
|
|
2752
|
+
const _hoisted_1 = { class: "blade-content-wrapper" };
|
|
2753
|
+
const _hoisted_2 = {
|
|
2754
|
+
key: 0,
|
|
2755
|
+
class: "language-selector-container"
|
|
2756
|
+
};
|
|
2757
|
+
const _hoisted_3 = {
|
|
2758
|
+
key: 0,
|
|
2759
|
+
class: "item-details__inner"
|
|
2760
|
+
};
|
|
2761
|
+
const _hoisted_4 = { class: "item-details__content" };
|
|
2762
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
2763
|
+
__name: "dynamic-blade-form",
|
|
2764
|
+
props: {
|
|
2765
|
+
expanded: { type: Boolean, default: true },
|
|
2766
|
+
closable: { type: Boolean, default: true },
|
|
2767
|
+
param: {},
|
|
2768
|
+
model: {},
|
|
2769
|
+
options: {},
|
|
2770
|
+
composables: {},
|
|
2771
|
+
mixinFn: {}
|
|
2772
|
+
},
|
|
2773
|
+
emits: ["parent:call", "close:blade", "collapse:blade", "expand:blade"],
|
|
2774
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2775
|
+
const props = __props;
|
|
2776
|
+
const emit = __emit;
|
|
2777
|
+
const { t } = useI18n({ useScope: "global" });
|
|
2778
|
+
const { showConfirmation } = usePopup();
|
|
2779
|
+
const { getFlag } = useLanguages();
|
|
2780
|
+
const isMixinReady = ref(false);
|
|
2781
|
+
const blade = inject(BladeInstance);
|
|
2782
|
+
if (typeof props.composables?.[props.model?.settings?.composable ?? ""] === "undefined") {
|
|
2783
|
+
throw new Error(`Composable ( ${props.model?.settings?.composable} ) is not defined`);
|
|
2784
|
+
}
|
|
2785
|
+
const settings = computed(() => props.model?.settings);
|
|
2786
|
+
let { loading, item, validationState, scope, load, remove, saveChanges, bladeTitle } = props.composables ? props.composables?.[props.model?.settings?.composable ?? ""]({ emit, props, mounted: useMounted() }) : {
|
|
2787
|
+
loading: true,
|
|
2788
|
+
item: void 0,
|
|
2789
|
+
validationState: void 0,
|
|
2790
|
+
scope: void 0,
|
|
2791
|
+
load: void 0,
|
|
2792
|
+
remove: void 0,
|
|
2793
|
+
saveChanges: void 0,
|
|
2794
|
+
bladeTitle: void 0
|
|
2795
|
+
};
|
|
2796
|
+
if (props.mixinFn?.length) {
|
|
2797
|
+
const mixinResults = props.mixinFn?.map(
|
|
2798
|
+
(mixin) => mixin({ loading, item, validationState, scope, load, remove, saveChanges, bladeTitle })
|
|
2799
|
+
);
|
|
2800
|
+
const mergedResults = mixinResults.reduce((acc, result) => {
|
|
2801
|
+
return {
|
|
2802
|
+
...acc,
|
|
2803
|
+
...result
|
|
2804
|
+
};
|
|
2805
|
+
}, {});
|
|
2806
|
+
loading = mergedResults.loading ?? loading;
|
|
2807
|
+
item = mergedResults.item ?? item;
|
|
2808
|
+
validationState = mergedResults.validationState ?? validationState;
|
|
2809
|
+
scope = mergedResults.scope ?? scope;
|
|
2810
|
+
load = mergedResults.load ?? load;
|
|
2811
|
+
remove = mergedResults.remove ?? remove;
|
|
2812
|
+
saveChanges = mergedResults.saveChanges ?? saveChanges;
|
|
2813
|
+
bladeTitle = mergedResults.bladeTitle ?? bladeTitle;
|
|
2814
|
+
isMixinReady.value = true;
|
|
2815
|
+
} else {
|
|
2816
|
+
isMixinReady.value = true;
|
|
2817
|
+
}
|
|
2818
|
+
const widgetService = useWidgets();
|
|
2819
|
+
const { onBeforeClose } = useBladeNavigation();
|
|
2820
|
+
const title = ref();
|
|
2821
|
+
const isReady = ref(false);
|
|
2822
|
+
const activeWidgetExposed = ref();
|
|
2823
|
+
const isBladeEditable = computed(() => !toValue("disabled" in toValue(scope || {}) && toValue(scope || {}).disabled));
|
|
2824
|
+
const unreffedScope = reactiveComputed(() => toValue(scope) ?? {});
|
|
2825
|
+
const { moduleNotifications, markAsRead } = useNotifications(settings.value?.pushNotificationType);
|
|
2826
|
+
watch(
|
|
2827
|
+
moduleNotifications,
|
|
2828
|
+
(newVal) => {
|
|
2829
|
+
newVal.forEach((message) => {
|
|
2830
|
+
if (message.title && props.composables) {
|
|
2831
|
+
notification.success(message.title, {
|
|
2832
|
+
onClose() {
|
|
2833
|
+
markAsRead(message);
|
|
2834
|
+
}
|
|
2835
|
+
});
|
|
2836
|
+
}
|
|
2837
|
+
});
|
|
2838
|
+
},
|
|
2839
|
+
{ deep: true }
|
|
2840
|
+
);
|
|
2841
|
+
watch(
|
|
2842
|
+
() => unref(bladeTitle),
|
|
2843
|
+
(newVal) => {
|
|
2844
|
+
if (newVal && props.composables) {
|
|
2845
|
+
title.value = newVal;
|
|
2846
|
+
}
|
|
2847
|
+
},
|
|
2848
|
+
{ immediate: true }
|
|
2849
|
+
);
|
|
2850
|
+
const isFormModified = computed(() => validationState.value.modified);
|
|
2851
|
+
useBeforeUnload(isFormModified);
|
|
2852
|
+
const form = computed(
|
|
2853
|
+
() => props.model?.content.find((x) => x?.component === "vc-form")
|
|
2854
|
+
);
|
|
2855
|
+
const widgets = computed(() => props.model?.content.find((x) => x?.component === "vc-widgets"));
|
|
2856
|
+
const bladeContext = ref({
|
|
2857
|
+
loading,
|
|
2858
|
+
item,
|
|
2859
|
+
validationState,
|
|
2860
|
+
scope,
|
|
2861
|
+
load,
|
|
2862
|
+
remove,
|
|
2863
|
+
saveChanges,
|
|
2864
|
+
bladeTitle,
|
|
2865
|
+
settings
|
|
2866
|
+
});
|
|
2867
|
+
const bladeStatus = computed(() => {
|
|
2868
|
+
if (props.model && "status" in props.model.settings && props.model.settings.status) {
|
|
2869
|
+
if (!("component" in props.model.settings.status))
|
|
2870
|
+
throw new Error(`Component is required in status: ${props.model.settings.status}`);
|
|
2871
|
+
return reactive(h(resolveComponent(props.model.settings.status.component), { context: bladeContext.value }));
|
|
2872
|
+
}
|
|
2873
|
+
return null;
|
|
2874
|
+
});
|
|
2875
|
+
const localeOptions = ref();
|
|
2876
|
+
watch(
|
|
2877
|
+
() => toValue(unreffedScope).multilanguage?.localesOptions,
|
|
2878
|
+
(newVal) => {
|
|
2879
|
+
localeOptions.value = newVal;
|
|
2880
|
+
},
|
|
2881
|
+
{ immediate: true, deep: true }
|
|
2882
|
+
);
|
|
2883
|
+
watch(
|
|
2884
|
+
() => localeOptions.value,
|
|
2885
|
+
async (newVal) => {
|
|
2886
|
+
for (const lang of newVal) {
|
|
2887
|
+
lang.flag = await getFlag(lang.value);
|
|
2888
|
+
}
|
|
2889
|
+
},
|
|
2890
|
+
{ deep: true }
|
|
2891
|
+
);
|
|
2892
|
+
const bladeMultilanguage = reactiveComputed(() => {
|
|
2893
|
+
if (scope && toValue(unreffedScope) && "multilanguage" in toValue(unreffedScope) && toValue(unreffedScope).multilanguage) {
|
|
2894
|
+
const isOpened = ref(false);
|
|
2895
|
+
return {
|
|
2896
|
+
component: () => {
|
|
2897
|
+
return h(
|
|
2898
|
+
_sfc_main$o,
|
|
2899
|
+
{
|
|
2900
|
+
opened: isOpened.value,
|
|
2901
|
+
items: localeOptions.value || [],
|
|
2902
|
+
floating: true,
|
|
2903
|
+
placement: "bottom-end",
|
|
2904
|
+
offset: {
|
|
2905
|
+
mainAxis: 10,
|
|
2906
|
+
crossAxis: -15
|
|
2907
|
+
},
|
|
2908
|
+
variant: "secondary",
|
|
2909
|
+
emptyText: t("COMMON.NO_OPTIONS"),
|
|
2910
|
+
itemText: (item2) => item2.label,
|
|
2911
|
+
isItemActive: (item2) => item2.value === toValue(unreffedScope).multilanguage?.currentLocale,
|
|
2912
|
+
onItemClick: (item2) => {
|
|
2913
|
+
isOpened.value = false;
|
|
2914
|
+
toValue(unreffedScope).multilanguage?.setLocale(item2.value);
|
|
2915
|
+
},
|
|
2916
|
+
"onUpdate:opened": (state) => {
|
|
2917
|
+
isOpened.value = state;
|
|
2918
|
+
}
|
|
2919
|
+
},
|
|
2920
|
+
{
|
|
2921
|
+
trigger: () => {
|
|
2922
|
+
const currentLocale = localeOptions.value?.find(
|
|
2923
|
+
(locale) => locale.value === toValue(unreffedScope).multilanguage?.currentLocale
|
|
2924
|
+
);
|
|
2925
|
+
return h(
|
|
2926
|
+
"div",
|
|
2927
|
+
{
|
|
2928
|
+
onClick: () => {
|
|
2929
|
+
if ("disabled" in toValue(unreffedScope) && toValue(unreffedScope).disabled) return;
|
|
2930
|
+
isOpened.value = !isOpened.value;
|
|
2931
|
+
},
|
|
2932
|
+
class: "tw-flex tw-items-center tw-justify-center tw-bg-[--primary-100] tw-w-8 tw-h-8 tw-rounded-full tw-mr-1 hover:tw-bg-[--primary-200]"
|
|
2933
|
+
},
|
|
2934
|
+
[h(_sfc_main$8, { src: currentLocale?.flag, class: "tw-w-6 tw-h-6", emptyIcon: "" })]
|
|
2935
|
+
);
|
|
2936
|
+
},
|
|
2937
|
+
item: (props2) => {
|
|
2938
|
+
return h("div", { class: "tw-flex tw-items-center tw-gap-2 tw-p-2" }, [
|
|
2939
|
+
h(_sfc_main$8, { src: props2.item.flag, class: "tw-w-6 tw-h-6", emptyIcon: "" }),
|
|
2940
|
+
h("span", { class: "tw-text-sm" }, props2.item.label)
|
|
2941
|
+
]);
|
|
2942
|
+
},
|
|
2943
|
+
empty: () => h("div", {}, t("COMMON.NO_OPTIONS"))
|
|
2944
|
+
}
|
|
2945
|
+
);
|
|
2946
|
+
},
|
|
2947
|
+
currentLocale: toValue(unreffedScope).multilanguage?.currentLocale
|
|
2948
|
+
};
|
|
2949
|
+
}
|
|
2950
|
+
return {};
|
|
2951
|
+
});
|
|
2952
|
+
const bladeOptions = reactive({
|
|
2953
|
+
status: bladeStatus,
|
|
2954
|
+
backButton: computed(() => {
|
|
2955
|
+
if (toValue(unreffedScope)?.backButton) {
|
|
2956
|
+
return toValue(unreffedScope).backButton;
|
|
2957
|
+
}
|
|
2958
|
+
return void 0;
|
|
2959
|
+
})
|
|
2960
|
+
});
|
|
2961
|
+
const multilanguage = reactive({
|
|
2962
|
+
multilanguage: bladeMultilanguage.component
|
|
2963
|
+
});
|
|
2964
|
+
const toolbarComputed = (props.composables && useToolbarReducer({
|
|
2965
|
+
defaultToolbarSchema: settings.value?.toolbar ?? [],
|
|
2966
|
+
defaultToolbarBindings: {
|
|
2967
|
+
saveChanges: {
|
|
2968
|
+
async clickHandler() {
|
|
2969
|
+
if (item.value) {
|
|
2970
|
+
await saveChanges(item.value);
|
|
2971
|
+
validationState.value.resetValidationState();
|
|
2972
|
+
emit("parent:call", {
|
|
2973
|
+
method: "reload"
|
|
2974
|
+
});
|
|
2975
|
+
emit("parent:call", {
|
|
2976
|
+
method: "updateActiveWidgetCount"
|
|
2977
|
+
});
|
|
2978
|
+
widgetService.updateActiveWidget();
|
|
2979
|
+
if (!unref(props.param)) {
|
|
2980
|
+
emit("close:blade");
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
},
|
|
2984
|
+
disabled: computed(() => !validationState.value.modified)
|
|
2985
|
+
},
|
|
2986
|
+
remove: {
|
|
2987
|
+
async clickHandler() {
|
|
2988
|
+
if (await showConfirmation(
|
|
2989
|
+
computed(() => t(`${settings.value?.localizationPrefix.trim().toUpperCase()}.PAGES.ALERTS.DELETE`))
|
|
2990
|
+
)) {
|
|
2991
|
+
if (props.param) {
|
|
2992
|
+
await remove?.({ id: unref(props.param) });
|
|
2993
|
+
} else {
|
|
2994
|
+
await remove?.({ item: item.value });
|
|
2995
|
+
}
|
|
2996
|
+
emit("parent:call", {
|
|
2997
|
+
method: "reload"
|
|
2998
|
+
});
|
|
2999
|
+
emit("parent:call", {
|
|
3000
|
+
method: "updateActiveWidgetCount"
|
|
3001
|
+
});
|
|
3002
|
+
widgetService.updateActiveWidget();
|
|
3003
|
+
emit("close:blade");
|
|
3004
|
+
}
|
|
3005
|
+
},
|
|
3006
|
+
disabled: computed(() => toValue(toValue(unreffedScope)?.disabled))
|
|
3007
|
+
}
|
|
3008
|
+
},
|
|
3009
|
+
customToolbarConfig: toValue(unreffedScope)?.toolbarOverrides,
|
|
3010
|
+
context: bladeContext.value
|
|
3011
|
+
})) ?? [];
|
|
3012
|
+
onMounted(() => {
|
|
3013
|
+
if (blade?.value.id && widgets.value?.children) {
|
|
3014
|
+
widgets.value.children.forEach((widgetComponent) => {
|
|
3015
|
+
const isObjectWidget = typeof widgetComponent === "object" && "id" in widgetComponent;
|
|
3016
|
+
const widgetId = isObjectWidget ? widgetComponent.id : "";
|
|
3017
|
+
const visibilityMethod = isObjectWidget && "visibility" in widgetComponent && widgetComponent.visibility?.method;
|
|
3018
|
+
const component = isObjectWidget ? resolveComponent(widgetId) : typeof widgetComponent === "string" ? resolveComponent(widgetComponent) : widgetComponent;
|
|
3019
|
+
if (!component) {
|
|
3020
|
+
console.error(`Failed to resolve widget component: ${isObjectWidget ? widgetId : widgetComponent}`);
|
|
3021
|
+
return;
|
|
3022
|
+
}
|
|
3023
|
+
const finalWidgetId = isObjectWidget ? widgetId : typeof component === "object" && "__name" in component ? component.__name : `widget-${Date.now()}`;
|
|
3024
|
+
if (finalWidgetId) {
|
|
3025
|
+
widgetService.registerWidget(
|
|
3026
|
+
{
|
|
3027
|
+
id: finalWidgetId,
|
|
3028
|
+
component: markRaw(component),
|
|
3029
|
+
props: {
|
|
3030
|
+
modelValue: bladeContext
|
|
3031
|
+
},
|
|
3032
|
+
events: {
|
|
3033
|
+
"update:modelValue": (val) => {
|
|
3034
|
+
bladeContext.value = val;
|
|
3035
|
+
}
|
|
3036
|
+
},
|
|
3037
|
+
isVisible: visibilityMethod ? computed(() => bladeContext.value.scope?.[visibilityMethod]) : true
|
|
3038
|
+
},
|
|
3039
|
+
blade.value.id
|
|
3040
|
+
);
|
|
3041
|
+
}
|
|
3042
|
+
});
|
|
3043
|
+
}
|
|
3044
|
+
});
|
|
3045
|
+
onBeforeUnmount(() => {
|
|
3046
|
+
if (blade?.value.id) {
|
|
3047
|
+
widgetService.clearBladeWidgets(blade.value.id);
|
|
3048
|
+
}
|
|
3049
|
+
});
|
|
3050
|
+
async function updateActiveWidgetCount() {
|
|
3051
|
+
if (activeWidgetExposed.value?.updateActiveWidgetCount && typeof activeWidgetExposed.value?.updateActiveWidgetCount === "function") {
|
|
3052
|
+
await activeWidgetExposed.value.updateActiveWidgetCount();
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
async function init() {
|
|
3056
|
+
await load({ id: unref(props.param) });
|
|
3057
|
+
await nextTick(() => {
|
|
3058
|
+
isReady.value = true;
|
|
3059
|
+
});
|
|
3060
|
+
}
|
|
3061
|
+
onBeforeMount(async () => {
|
|
3062
|
+
if (props.composables && isMixinReady.value) await init();
|
|
3063
|
+
});
|
|
3064
|
+
onBeforeClose(async () => {
|
|
3065
|
+
if (unref(isFormModified)) {
|
|
3066
|
+
return await showConfirmation(
|
|
3067
|
+
unref(
|
|
3068
|
+
computed(() => t(`${settings.value?.localizationPrefix.trim().toUpperCase()}.PAGES.ALERTS.CLOSE_CONFIRMATION`))
|
|
3069
|
+
)
|
|
3070
|
+
);
|
|
3071
|
+
}
|
|
3072
|
+
});
|
|
3073
|
+
provide("bladeContext", toReactive(bladeContext));
|
|
3074
|
+
provide("isBladeEditable", isBladeEditable);
|
|
3075
|
+
computed(() => {
|
|
3076
|
+
return widgets.value?.children?.map((x) => {
|
|
3077
|
+
if (typeof x === "string") return resolveComponent(x);
|
|
3078
|
+
else throw new Error(`Component is required in widget: ${x}`);
|
|
3079
|
+
});
|
|
3080
|
+
});
|
|
3081
|
+
__expose({
|
|
3082
|
+
title: bladeTitle ?? "",
|
|
3083
|
+
updateActiveWidgetCount,
|
|
3084
|
+
...toRefs(toValue(unreffedScope) ?? {}),
|
|
3085
|
+
settings: toValue(settings),
|
|
3086
|
+
item,
|
|
3087
|
+
validationState
|
|
3088
|
+
});
|
|
3089
|
+
return (_ctx, _cache) => {
|
|
3090
|
+
const _component_VcForm = resolveComponent("VcForm");
|
|
3091
|
+
const _component_VcContainer = resolveComponent("VcContainer");
|
|
3092
|
+
const _component_VcBlade = resolveComponent("VcBlade");
|
|
3093
|
+
const _directive_loading = resolveDirective("loading");
|
|
3094
|
+
return !_ctx.composables ? withDirectives((openBlock(), createBlock(_component_VcBlade, {
|
|
3095
|
+
key: 0,
|
|
3096
|
+
expanded: _ctx.expanded,
|
|
3097
|
+
closable: _ctx.closable,
|
|
3098
|
+
width: settings.value?.width || "50%",
|
|
3099
|
+
"toolbar-items": unref(toolbarComputed),
|
|
3100
|
+
title: title.value,
|
|
3101
|
+
modified: isBladeEditable.value ? isFormModified.value : void 0,
|
|
3102
|
+
onClose: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("close:blade")),
|
|
3103
|
+
onExpand: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("expand:blade")),
|
|
3104
|
+
onCollapse: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("collapse:blade"))
|
|
3105
|
+
}, createSlots({
|
|
3106
|
+
default: withCtx(() => [
|
|
3107
|
+
createElementVNode("div", _hoisted_1, [
|
|
3108
|
+
multilanguage.multilanguage ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
3109
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(multilanguage, (value, key, index) => {
|
|
3110
|
+
return openBlock(), createBlock(resolveDynamicComponent(value), {
|
|
3111
|
+
key: `blade-multilanguage-slot-${key}-${index}`
|
|
3112
|
+
});
|
|
3113
|
+
}), 128))
|
|
3114
|
+
])) : createCommentVNode("", true),
|
|
3115
|
+
createVNode(_component_VcContainer, { "no-padding": true }, {
|
|
3116
|
+
default: withCtx(() => [
|
|
3117
|
+
isReady.value && unref(item) && Object.keys(unref(item)) ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
3118
|
+
createElementVNode("div", _hoisted_4, [
|
|
3119
|
+
createVNode(_component_VcForm, {
|
|
3120
|
+
ref: "formItem",
|
|
3121
|
+
class: "tw-grow tw-p-4"
|
|
3122
|
+
}, {
|
|
3123
|
+
default: withCtx(() => [
|
|
3124
|
+
createVNode(unref(SchemaRender), {
|
|
3125
|
+
modelValue: unref(item),
|
|
3126
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(item) ? item.value = $event : item = $event),
|
|
3127
|
+
"ui-schema": form.value.children,
|
|
3128
|
+
context: bladeContext.value,
|
|
3129
|
+
"current-locale": toValue(unref(unreffedScope))?.multilanguage?.currentLocale
|
|
3130
|
+
}, null, 8, ["modelValue", "ui-schema", "context", "current-locale"])
|
|
3131
|
+
]),
|
|
3132
|
+
_: 1
|
|
3133
|
+
}, 512)
|
|
3134
|
+
])
|
|
3135
|
+
])) : createCommentVNode("", true)
|
|
3136
|
+
]),
|
|
3137
|
+
_: 1
|
|
3138
|
+
})
|
|
3139
|
+
])
|
|
3140
|
+
]),
|
|
3141
|
+
_: 2
|
|
3142
|
+
}, [
|
|
3143
|
+
bladeOptions ? {
|
|
3144
|
+
name: "actions",
|
|
3145
|
+
fn: withCtx(() => [
|
|
3146
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(bladeOptions, (value, key, index) => {
|
|
3147
|
+
return openBlock(), createBlock(resolveDynamicComponent(value), {
|
|
3148
|
+
key: `blade-actions-slot-${key}-${index}`
|
|
3149
|
+
});
|
|
3150
|
+
}), 128))
|
|
3151
|
+
]),
|
|
3152
|
+
key: "0"
|
|
3153
|
+
} : void 0
|
|
3154
|
+
]), 1032, ["expanded", "closable", "width", "toolbar-items", "title", "modified"])), [
|
|
3155
|
+
[_directive_loading, unref(loading), "1000"]
|
|
3156
|
+
]) : createCommentVNode("", true);
|
|
3157
|
+
};
|
|
3158
|
+
}
|
|
3159
|
+
});
|
|
3160
|
+
|
|
3161
|
+
const pages = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
3162
|
+
__proto__: null,
|
|
3163
|
+
DynamicBladeForm: _sfc_main,
|
|
3164
|
+
DynamicBladeList: _sfc_main$1
|
|
3165
|
+
}, Symbol.toStringTag, { value: 'Module' }));
|
|
3166
|
+
|
|
3167
|
+
const handleOverrides = (overrides, schemaCopy) => {
|
|
3168
|
+
let schema = cloneDeep(schemaCopy);
|
|
3169
|
+
if (overrides.remove && overrides.remove.length > 0) {
|
|
3170
|
+
schema = removeHelper(overrides, schema);
|
|
3171
|
+
}
|
|
3172
|
+
if (overrides.upsert && overrides.upsert.length > 0) {
|
|
3173
|
+
schema = upsertHelper(overrides, schema);
|
|
3174
|
+
}
|
|
3175
|
+
return schema;
|
|
3176
|
+
};
|
|
3177
|
+
const upsertHelper = (overrides, schemaCopy) => {
|
|
3178
|
+
return Object.entries(schemaCopy).reduce(
|
|
3179
|
+
(obj, [, schema]) => {
|
|
3180
|
+
const clonedSchema = cloneDeep(schema);
|
|
3181
|
+
overrides.upsert?.filter((x) => clonedSchema.settings.id === x.id).forEach((args) => {
|
|
3182
|
+
let valueByPath = get(clonedSchema, args.path);
|
|
3183
|
+
let currentPath = args.path;
|
|
3184
|
+
if (!valueByPath) {
|
|
3185
|
+
const pathParts = args.path.split(".");
|
|
3186
|
+
let current = clonedSchema;
|
|
3187
|
+
const generatedPath = [];
|
|
3188
|
+
for (const part of pathParts) {
|
|
3189
|
+
if (Array.isArray(current)) {
|
|
3190
|
+
const currentCopy = [...current];
|
|
3191
|
+
current = current.find((x) => Object.entries(x).some(([key, value]) => key === part || value === part));
|
|
3192
|
+
const fountElIndex = currentCopy.findIndex((x) => x === current);
|
|
3193
|
+
generatedPath.push(fountElIndex);
|
|
3194
|
+
} else {
|
|
3195
|
+
if (current) {
|
|
3196
|
+
current = current[part];
|
|
3197
|
+
generatedPath.push(part);
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
currentPath = generatedPath;
|
|
3202
|
+
valueByPath = current;
|
|
3203
|
+
}
|
|
3204
|
+
if (Array.isArray(valueByPath) && valueByPath.length && typeof args.value === "object" && !Array.isArray(args.value)) {
|
|
3205
|
+
const findIndex$1 = findIndex(valueByPath, { id: args.value.id });
|
|
3206
|
+
const spliced = valueByPath.toSpliced(findIndex$1 >= 0 ? findIndex$1 : args.index ?? 0, findIndex$1 >= 0 ? 1 : 0, args.value);
|
|
3207
|
+
set(clonedSchema, currentPath, spliced);
|
|
3208
|
+
} else if (Array.isArray(valueByPath) && valueByPath.length) {
|
|
3209
|
+
set(clonedSchema, currentPath, [...valueByPath, args.value]);
|
|
3210
|
+
} else {
|
|
3211
|
+
set(clonedSchema, currentPath, args.value);
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
const newId = clonedSchema.settings.id;
|
|
3215
|
+
if (newId !== schema.settings.id) {
|
|
3216
|
+
obj[newId] = clonedSchema;
|
|
3217
|
+
} else {
|
|
3218
|
+
obj[schema.settings.id] = clonedSchema;
|
|
3219
|
+
}
|
|
3220
|
+
return obj;
|
|
3221
|
+
},
|
|
3222
|
+
{}
|
|
3223
|
+
);
|
|
3224
|
+
};
|
|
3225
|
+
const removeHelper = (overrides, schemaCopy) => {
|
|
3226
|
+
return Object.entries(schemaCopy).reduce(
|
|
3227
|
+
(obj, [name, schema]) => {
|
|
3228
|
+
const clonedSchema = cloneDeep(schema);
|
|
3229
|
+
sortByMaxIndexPath(overrides.remove?.filter((x) => schema.settings.id === x.id)).forEach(({ path }) => {
|
|
3230
|
+
if (path) {
|
|
3231
|
+
removePath(clonedSchema, path);
|
|
3232
|
+
}
|
|
3233
|
+
});
|
|
3234
|
+
obj[name] = clonedSchema;
|
|
3235
|
+
return obj;
|
|
3236
|
+
},
|
|
3237
|
+
{}
|
|
3238
|
+
);
|
|
3239
|
+
};
|
|
3240
|
+
function removePath(obj, path) {
|
|
3241
|
+
const removeItem = get(obj, path);
|
|
3242
|
+
if (removeItem) {
|
|
3243
|
+
const parentPath = path.slice(0, path.lastIndexOf("["));
|
|
3244
|
+
unset(obj, path);
|
|
3245
|
+
update(obj, parentPath, compact);
|
|
3246
|
+
} else {
|
|
3247
|
+
const pathParts = path.split(".");
|
|
3248
|
+
let current = obj;
|
|
3249
|
+
const generatedPath = [];
|
|
3250
|
+
for (const part of pathParts) {
|
|
3251
|
+
if (Array.isArray(current)) {
|
|
3252
|
+
const currentCopy = [...current];
|
|
3253
|
+
current = current.find((x) => Object.entries(x).some(([key, value]) => key === part || value === part));
|
|
3254
|
+
const foundElIndex = currentCopy.findIndex((x) => x === current);
|
|
3255
|
+
generatedPath.push(foundElIndex);
|
|
3256
|
+
} else {
|
|
3257
|
+
if (current) {
|
|
3258
|
+
current = current[part];
|
|
3259
|
+
generatedPath.push(part);
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
unset(obj, generatedPath);
|
|
3264
|
+
update(obj, generatedPath, compact);
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
function sortByMaxIndexPath(items) {
|
|
3268
|
+
return (items || []).sort((a, b) => getMaxIndexFromPath(b.path) - getMaxIndexFromPath(a.path));
|
|
3269
|
+
}
|
|
3270
|
+
function getMaxIndexFromPath(path) {
|
|
3271
|
+
const matches = path.match(/\[(\d+)\]/g);
|
|
3272
|
+
if (matches) {
|
|
3273
|
+
const indexes = matches.map((match) => parseInt(match.slice(1, -1), 10));
|
|
3274
|
+
return Math.max(...indexes);
|
|
3275
|
+
}
|
|
3276
|
+
return Infinity;
|
|
3277
|
+
}
|
|
3278
|
+
|
|
3279
|
+
const useDetailsFactory = (factoryParams) => {
|
|
3280
|
+
return function useDetails() {
|
|
3281
|
+
const { setFieldError, setErrors, validate, setFieldValue, setValues, errorBag } = useForm({
|
|
3282
|
+
validateOnMount: false
|
|
3283
|
+
});
|
|
3284
|
+
const item = ref();
|
|
3285
|
+
const itemTemp = ref();
|
|
3286
|
+
const isModified = ref(false);
|
|
3287
|
+
const isFormValid = useIsFormValid();
|
|
3288
|
+
const isDisabled = computed(() => !isModified.value || !isFormValid.value);
|
|
3289
|
+
const { loading: itemLoading, action: load } = useAsync(async (args) => {
|
|
3290
|
+
const res = await factoryParams.load(args);
|
|
3291
|
+
if (res) {
|
|
3292
|
+
item.value = res;
|
|
3293
|
+
item.value && resetModified(item.value);
|
|
3294
|
+
}
|
|
3295
|
+
});
|
|
3296
|
+
const { loading: manageLoading, action: saveChanges } = useAsync(async (itemToSave) => {
|
|
3297
|
+
if (validationState.value.valid) {
|
|
3298
|
+
const res = await factoryParams.saveChanges?.(itemToSave);
|
|
3299
|
+
isModified.value = false;
|
|
3300
|
+
const id = itemToSave?.id ?? res?.id;
|
|
3301
|
+
if (id) {
|
|
3302
|
+
await load({ id });
|
|
3303
|
+
}
|
|
3304
|
+
if (res) return res;
|
|
3305
|
+
} else throw new Error("Form is not valid");
|
|
3306
|
+
});
|
|
3307
|
+
const { loading: removeLoading, action: remove } = useAsync(async (args) => {
|
|
3308
|
+
await factoryParams.remove?.(args);
|
|
3309
|
+
});
|
|
3310
|
+
const loading = useLoading(itemLoading, manageLoading, removeLoading);
|
|
3311
|
+
const validationState = computed(
|
|
3312
|
+
() => ({
|
|
3313
|
+
/**
|
|
3314
|
+
* @deprecated `dirty` - use `modified` instead
|
|
3315
|
+
*/
|
|
3316
|
+
dirty: isModified.value,
|
|
3317
|
+
valid: isFormValid.value,
|
|
3318
|
+
modified: isModified.value,
|
|
3319
|
+
disabled: isDisabled.value,
|
|
3320
|
+
validated: !isDisabled.value && isModified.value,
|
|
3321
|
+
cachedValue: itemTemp.value,
|
|
3322
|
+
errorBag: errorBag.value,
|
|
3323
|
+
setFieldError,
|
|
3324
|
+
setErrors,
|
|
3325
|
+
setFieldValue,
|
|
3326
|
+
setValues,
|
|
3327
|
+
resetModified,
|
|
3328
|
+
resetValidationState,
|
|
3329
|
+
validate,
|
|
3330
|
+
setModifiedState
|
|
3331
|
+
})
|
|
3332
|
+
);
|
|
3333
|
+
function setModifiedState(value) {
|
|
3334
|
+
isModified.value = value;
|
|
3335
|
+
}
|
|
3336
|
+
function normalizeData(data) {
|
|
3337
|
+
if (data === null || data === void 0 || data === "" || Array.isArray(data) && data.length === 0 || typeof data === "object" && data !== null && Object.keys(data).length === 0) {
|
|
3338
|
+
return void 0;
|
|
3339
|
+
}
|
|
3340
|
+
if (Array.isArray(data)) {
|
|
3341
|
+
return data.map((item2) => normalizeData(item2));
|
|
3342
|
+
}
|
|
3343
|
+
if (typeof data === "object") {
|
|
3344
|
+
const normalizedObj = {};
|
|
3345
|
+
for (const key in data) {
|
|
3346
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
3347
|
+
normalizedObj[key] = normalizeData(data[key]);
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
return normalizedObj;
|
|
3351
|
+
}
|
|
3352
|
+
return data;
|
|
3353
|
+
}
|
|
3354
|
+
watch(
|
|
3355
|
+
[() => item.value, () => itemTemp.value],
|
|
3356
|
+
([state, stateCopy]) => {
|
|
3357
|
+
const normalizedState = normalizeData(state);
|
|
3358
|
+
const normalizedStateCopy = normalizeData(stateCopy);
|
|
3359
|
+
isModified.value = !isEqual(normalizedState, normalizedStateCopy);
|
|
3360
|
+
},
|
|
3361
|
+
{ deep: true }
|
|
3362
|
+
);
|
|
3363
|
+
const resetModified = createUnrefFn((data, updateInitial = false) => {
|
|
3364
|
+
if (updateInitial) {
|
|
3365
|
+
item.value = data;
|
|
3366
|
+
resetValidationState();
|
|
3367
|
+
}
|
|
3368
|
+
itemTemp.value = cloneDeep(data);
|
|
3369
|
+
});
|
|
3370
|
+
const resetValidationState = () => {
|
|
3371
|
+
isModified.value = false;
|
|
3372
|
+
};
|
|
3373
|
+
return {
|
|
3374
|
+
load,
|
|
3375
|
+
saveChanges,
|
|
3376
|
+
remove,
|
|
3377
|
+
loading,
|
|
3378
|
+
item,
|
|
3379
|
+
validationState
|
|
3380
|
+
};
|
|
3381
|
+
};
|
|
3382
|
+
};
|
|
3383
|
+
|
|
3384
|
+
const useListFactory = (factoryParams) => {
|
|
3385
|
+
return function useList(options) {
|
|
3386
|
+
const pageSize = options?.pageSize || 20;
|
|
3387
|
+
const searchResult = ref();
|
|
3388
|
+
const searchQuery = ref({
|
|
3389
|
+
take: pageSize,
|
|
3390
|
+
sort: options?.sort
|
|
3391
|
+
});
|
|
3392
|
+
const { loading: itemsLoading, action: load } = useAsync(async (query, ...rest) => {
|
|
3393
|
+
searchQuery.value = { ...searchQuery.value, ...query };
|
|
3394
|
+
searchResult.value = await factoryParams.load?.(query, ...rest);
|
|
3395
|
+
});
|
|
3396
|
+
const { loading: itemsDelete, action: remove } = useAsync(async (customQuery, ...rest) => {
|
|
3397
|
+
await factoryParams.remove?.(searchQuery.value, customQuery, ...rest);
|
|
3398
|
+
});
|
|
3399
|
+
const loading = useLoading(itemsLoading, itemsDelete);
|
|
3400
|
+
const pagination = computed(() => ({
|
|
3401
|
+
currentPage: (searchQuery.value?.skip || 0) / Math.max(1, searchQuery?.value.take || 20) + 1,
|
|
3402
|
+
totalCount: searchResult.value?.totalCount || 0,
|
|
3403
|
+
pageSize,
|
|
3404
|
+
get pages() {
|
|
3405
|
+
return Math.ceil(this.totalCount / this.pageSize);
|
|
3406
|
+
}
|
|
3407
|
+
}));
|
|
3408
|
+
return {
|
|
3409
|
+
items: computed(() => searchResult.value?.results),
|
|
3410
|
+
query: searchQuery,
|
|
3411
|
+
loading,
|
|
3412
|
+
pagination,
|
|
3413
|
+
load,
|
|
3414
|
+
remove
|
|
3415
|
+
};
|
|
3416
|
+
};
|
|
3417
|
+
};
|
|
3418
|
+
|
|
3419
|
+
const registeredModules = {};
|
|
3420
|
+
const installedBladeIds = /* @__PURE__ */ new Set();
|
|
3421
|
+
const registeredSchemas = {};
|
|
3422
|
+
const createAppModuleWrapper = (args) => {
|
|
3423
|
+
const { bladeName, bladeComponent, appModuleContent } = args;
|
|
3424
|
+
return createAppModule(
|
|
3425
|
+
{ [bladeName]: bladeComponent },
|
|
3426
|
+
appModuleContent?.locales,
|
|
3427
|
+
appModuleContent?.notificationTemplates,
|
|
3428
|
+
appModuleContent?.moduleComponents
|
|
3429
|
+
);
|
|
3430
|
+
};
|
|
3431
|
+
const createBladeInstanceConstructor = (bladeComponent, bladeName, json, args, existingComposables, existingMixins) => {
|
|
3432
|
+
if (json.settings.url) {
|
|
3433
|
+
const rawUrl = json.settings.url;
|
|
3434
|
+
bladeComponent.url = rawUrl;
|
|
3435
|
+
}
|
|
3436
|
+
if (json.settings.permissions) {
|
|
3437
|
+
bladeComponent.permissions = json.settings.permissions;
|
|
3438
|
+
}
|
|
3439
|
+
return defineComponent({
|
|
3440
|
+
...bladeComponent,
|
|
3441
|
+
name: bladeName,
|
|
3442
|
+
isWorkspace: "isWorkspace" in json.settings && json.settings.isWorkspace,
|
|
3443
|
+
menuItem: ("menuItem" in json.settings && json.settings.menuItem) ?? void 0,
|
|
3444
|
+
moduleUid: args.moduleUid,
|
|
3445
|
+
routable: json.settings.routable ?? true,
|
|
3446
|
+
notifyType: json.settings.pushNotificationType,
|
|
3447
|
+
composables: existingComposables ? { ...existingComposables, ...args.composables } : args.composables,
|
|
3448
|
+
setup: (props, ctx) => (bladeComponent?.setup && bladeComponent.setup(
|
|
3449
|
+
reactiveComputed(
|
|
3450
|
+
() => Object.assign({}, props, {
|
|
3451
|
+
model: json,
|
|
3452
|
+
composables: existingComposables ? { ...existingComposables, ...args.composables } : args.composables,
|
|
3453
|
+
mixinFn: existingMixins ? [...existingMixins, ...args.mixin || []] : args.mixin?.length ? args.mixin : void 0
|
|
3454
|
+
})
|
|
3455
|
+
),
|
|
3456
|
+
ctx
|
|
3457
|
+
)) ?? {}
|
|
3458
|
+
});
|
|
3459
|
+
};
|
|
3460
|
+
const register = (args, appModuleContent) => {
|
|
3461
|
+
const { app, component, json, options } = args;
|
|
3462
|
+
const bladeId = json.settings.id;
|
|
3463
|
+
const bladeName = kebabToPascal(bladeId);
|
|
3464
|
+
if (registeredModules[bladeName]) {
|
|
3465
|
+
updateBlade(bladeName, json, args, appModuleContent);
|
|
3466
|
+
return registeredModules[bladeName];
|
|
3467
|
+
}
|
|
3468
|
+
const bladeComponent = cloneDeep(component);
|
|
3469
|
+
const BladeInstanceConstructor2 = createBladeInstanceConstructor(bladeComponent, bladeName, json, args);
|
|
3470
|
+
const module = createAppModuleWrapper({
|
|
3471
|
+
bladeName,
|
|
3472
|
+
bladeComponent: BladeInstanceConstructor2,
|
|
3473
|
+
appModuleContent
|
|
3474
|
+
});
|
|
3475
|
+
module.install(app, options);
|
|
3476
|
+
const newModule = {
|
|
3477
|
+
component: BladeInstanceConstructor2,
|
|
3478
|
+
name: bladeName,
|
|
3479
|
+
model: json,
|
|
3480
|
+
composables: { ...args.composables },
|
|
3481
|
+
mixin: args.mixin
|
|
3482
|
+
// Set mixin directly
|
|
3483
|
+
};
|
|
3484
|
+
registeredModules[bladeName] = newModule;
|
|
3485
|
+
return newModule;
|
|
3486
|
+
};
|
|
3487
|
+
const handleError = (errorKey, schemas, text) => {
|
|
3488
|
+
return console.error(
|
|
3489
|
+
`Module initialization aborted. Key '${errorKey}' not found in schemas: ${Object.keys(schemas).join(
|
|
3490
|
+
", "
|
|
3491
|
+
)}. Key '${errorKey}' ${text}`
|
|
3492
|
+
);
|
|
3493
|
+
};
|
|
3494
|
+
const updateBlade = (moduleName, newSchema, args, appModuleContent) => {
|
|
3495
|
+
const existingModule = registeredModules[moduleName];
|
|
3496
|
+
if (existingModule) {
|
|
3497
|
+
existingModule.model = newSchema;
|
|
3498
|
+
const bladeComponent = cloneDeep(args.component);
|
|
3499
|
+
const BladeInstanceConstructor2 = createBladeInstanceConstructor(
|
|
3500
|
+
bladeComponent,
|
|
3501
|
+
moduleName,
|
|
3502
|
+
newSchema,
|
|
3503
|
+
args,
|
|
3504
|
+
existingModule.composables,
|
|
3505
|
+
existingModule.mixin
|
|
3506
|
+
);
|
|
3507
|
+
const module = createAppModuleWrapper({
|
|
3508
|
+
bladeName: moduleName,
|
|
3509
|
+
bladeComponent: BladeInstanceConstructor2,
|
|
3510
|
+
appModuleContent
|
|
3511
|
+
});
|
|
3512
|
+
module.install(args.app, args.options);
|
|
3513
|
+
existingModule.component = BladeInstanceConstructor2;
|
|
3514
|
+
existingModule.mixin = existingModule.mixin ? [...existingModule.mixin, ...args.mixin || []] : args.mixin;
|
|
3515
|
+
}
|
|
3516
|
+
};
|
|
3517
|
+
function createDynamicAppModule(args) {
|
|
3518
|
+
let schemaCopy = {};
|
|
3519
|
+
if (args.schema && Object.keys(args.schema).length > 0) {
|
|
3520
|
+
const moduleUid = uniqueId("module_");
|
|
3521
|
+
Object.entries(args.schema).forEach(([, schema]) => {
|
|
3522
|
+
if (schema.settings && schema.settings.id) {
|
|
3523
|
+
schemaCopy[schema.settings.id] = { ...cloneDeep(schema), moduleUid };
|
|
3524
|
+
registeredSchemas[schema.settings.id] = schemaCopy[schema.settings.id];
|
|
3525
|
+
}
|
|
3526
|
+
});
|
|
3527
|
+
} else {
|
|
3528
|
+
schemaCopy = cloneDeep({ ...registeredSchemas });
|
|
3529
|
+
}
|
|
3530
|
+
if (args.overrides) {
|
|
3531
|
+
schemaCopy = handleOverrides(args.overrides, schemaCopy);
|
|
3532
|
+
const newUid = uniqueId("module_");
|
|
3533
|
+
const newSchemas = Object.entries(schemaCopy).reduce(
|
|
3534
|
+
(acc, [key, schema]) => {
|
|
3535
|
+
acc[key] = { ...schema, moduleUid: newUid };
|
|
3536
|
+
return acc;
|
|
3537
|
+
},
|
|
3538
|
+
{}
|
|
3539
|
+
);
|
|
3540
|
+
Object.assign(registeredSchemas, newSchemas);
|
|
3541
|
+
}
|
|
3542
|
+
const moduleInitializer = findKey(schemaCopy, (o) => o.settings.isWorkspace);
|
|
3543
|
+
const everyHasTemplate = every(Object.values(schemaCopy), (o) => o?.settings?.component);
|
|
3544
|
+
if (!everyHasTemplate) handleError("component", schemaCopy, "must be included in 'settings' of each file");
|
|
3545
|
+
if (!moduleInitializer)
|
|
3546
|
+
handleError("isWorkspace", schemaCopy, "must be included in one of the files to initialize the module workspace");
|
|
3547
|
+
return {
|
|
3548
|
+
install(app, options) {
|
|
3549
|
+
const bladePages = { ...pages };
|
|
3550
|
+
const appModuleContent = {
|
|
3551
|
+
locales: args?.locales,
|
|
3552
|
+
notificationTemplates: args?.notificationTemplates,
|
|
3553
|
+
moduleComponents: args?.moduleComponents
|
|
3554
|
+
};
|
|
3555
|
+
const getComposables = (bladeId) => {
|
|
3556
|
+
const composable = schemaCopy[bladeId]?.settings.composable;
|
|
3557
|
+
const composableFn = Object.values(registeredModules).find((module) => {
|
|
3558
|
+
return module.composables?.[composable];
|
|
3559
|
+
});
|
|
3560
|
+
if (!composableFn) {
|
|
3561
|
+
return args.composables;
|
|
3562
|
+
}
|
|
3563
|
+
return composableFn?.composables;
|
|
3564
|
+
};
|
|
3565
|
+
Object.entries(schemaCopy).forEach(([, JsonSchema], index) => {
|
|
3566
|
+
const bladeId = JsonSchema.settings.id;
|
|
3567
|
+
const mixin = args.mixin?.[bladeId];
|
|
3568
|
+
const registerArgs = {
|
|
3569
|
+
app,
|
|
3570
|
+
component: bladePages[JsonSchema.settings.component],
|
|
3571
|
+
composables: getComposables(JsonSchema.settings.id),
|
|
3572
|
+
mixin,
|
|
3573
|
+
json: JsonSchema,
|
|
3574
|
+
options,
|
|
3575
|
+
moduleUid: JsonSchema.moduleUid
|
|
3576
|
+
};
|
|
3577
|
+
if (installedBladeIds.has(bladeId)) {
|
|
3578
|
+
updateBlade(kebabToPascal(bladeId), JsonSchema, registerArgs, index === 0 ? appModuleContent : void 0);
|
|
3579
|
+
return;
|
|
3580
|
+
}
|
|
3581
|
+
installedBladeIds.add(bladeId);
|
|
3582
|
+
register(registerArgs, index === 0 ? appModuleContent : void 0);
|
|
3583
|
+
});
|
|
3584
|
+
}
|
|
3585
|
+
};
|
|
3586
|
+
}
|
|
3587
|
+
|
|
3588
|
+
export { _sfc_main as _, _sfc_main$1 as a, useListFactory as b, createDynamicAppModule as c, index as i, useDetailsFactory as u };
|