@topvisor/ui 0.9.25 → 0.9.26-dev
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/.chunks/datepicker-BMrdz1zd.es.js +277 -0
- package/.chunks/datepicker-BMrdz1zd.es.js.map +1 -0
- package/.chunks/datepicker-C0rB8tdN.amd.js +234 -0
- package/.chunks/datepicker-C0rB8tdN.amd.js.map +1 -0
- package/.chunks/{forms-gb7uf2K8.es.js → forms-C4UtO06K.es.js} +230 -230
- package/.chunks/forms-C4UtO06K.es.js.map +1 -0
- package/.chunks/forms-DujTMzoW.amd.js +3 -0
- package/.chunks/forms-DujTMzoW.amd.js.map +1 -0
- package/.chunks/{listItem.vue_vue_type_script_setup_true_lang-Caw4oFU-.es.js → listItem.vue_vue_type_script_setup_true_lang-CHYNz0kA.es.js} +2 -2
- package/.chunks/listItem.vue_vue_type_script_setup_true_lang-CHYNz0kA.es.js.map +1 -0
- package/.chunks/{listItem.vue_vue_type_script_setup_true_lang-2TAzIZZA.amd.js → listItem.vue_vue_type_script_setup_true_lang-Ob3185Bq.amd.js} +2 -2
- package/.chunks/listItem.vue_vue_type_script_setup_true_lang-Ob3185Bq.amd.js.map +1 -0
- package/.chunks/{popup-ZmdXZkvb.es.js → popup-B2BoAirk.es.js} +431 -431
- package/.chunks/popup-B2BoAirk.es.js.map +1 -0
- package/.chunks/{popup-Dfz5hkrQ.amd.js → popup-CyJ0WBUB.amd.js} +386 -386
- package/.chunks/popup-CyJ0WBUB.amd.js.map +1 -0
- package/.chunks/store-Bl79G7T_.amd.js.map +1 -1
- package/.chunks/store-PoMCiuBr.es.js.map +1 -1
- package/.chunks/{widgetInput-BxO9y9L7.amd.js → widgetInput-Ce8a61St.amd.js} +2 -2
- package/.chunks/widgetInput-Ce8a61St.amd.js.map +1 -0
- package/.chunks/{widgetInput-DPOH_qya.es.js → widgetInput-pNYn7i5g.es.js} +2 -2
- package/.chunks/widgetInput-pNYn7i5g.es.js.map +1 -0
- package/README.md +86 -86
- package/assets/forms.css +1 -1
- package/assets/formsExt.css +1 -1
- package/core/core.amd.js +1 -1
- package/core/core.js +1 -1
- package/forms/forms.amd.js +1 -1
- package/forms/forms.js +1 -1
- package/forms/helpers.amd.js.map +1 -1
- package/forms/helpers.js.map +1 -1
- package/formsExt/formsExt.amd.js +1 -1
- package/formsExt/formsExt.amd.js.map +1 -1
- package/formsExt/formsExt.js +317 -301
- package/formsExt/formsExt.js.map +1 -1
- package/icomoon/Read Me.txt +7 -7
- package/icomoon/demo-files/demo.css +161 -161
- package/icomoon/demo-files/demo.js +30 -30
- package/icomoon/demo.html +3225 -3225
- package/icomoon/fonts/Topvisor-2.svg +252 -252
- package/icomoon/style.css +707 -707
- package/package.json +20 -20
- package/popup/popup.amd.js +1 -1
- package/popup/popup.js +2 -2
- package/popup/worker.amd.js +1 -1
- package/popup/worker.amd.js.map +1 -1
- package/popup/worker.js +47 -47
- package/popup/worker.js.map +1 -1
- package/require/css.amd.js +11 -11
- package/src/components/forms/avatar/avatar.d.ts +9 -0
- package/src/components/forms/avatar/avatar.stories.d.ts +24 -0
- package/src/components/forms/avatar/avatar.vue.d.ts +12 -0
- package/src/components/formsExt/editArea/editArea.d.ts +16 -3
- package/src/components/formsExt/editArea/editArea.stories.d.ts +36 -20
- package/src/components/formsExt/editArea/editArea.vue.d.ts +12 -4
- package/src/components/popup/popup/popup.stories.d.ts +2 -2
- package/tabs/tabs.amd.js +1 -1
- package/tabs/tabs.js +1 -1
- package/tabsView/tabsView.amd.js +1 -1
- package/tabsView/tabsView.amd.js.map +1 -1
- package/tabsView/tabsView.js +2 -2
- package/tabsView/tabsView.js.map +1 -1
- package/utils/css.amd.js.map +1 -1
- package/utils/css.js.map +1 -1
- package/utils/date.amd.js +1 -1
- package/utils/date.js +1 -1
- package/utils/device.amd.js +1 -1
- package/utils/device.js +1 -1
- package/utils/dom.amd.js.map +1 -1
- package/utils/dom.js.map +1 -1
- package/utils/keyboard.amd.js.map +1 -1
- package/utils/keyboard.js.map +1 -1
- package/utils/route.amd.js.map +1 -1
- package/utils/route.js.map +1 -1
- package/utils/scroll.amd.js +1 -1
- package/utils/scroll.amd.js.map +1 -1
- package/utils/scroll.js +1 -1
- package/utils/scroll.js.map +1 -1
- package/utils/system.amd.js.map +1 -1
- package/utils/system.js.map +1 -1
- package/utils/window.amd.js +1 -1
- package/utils/window.js +1 -1
- package/.chunks/datepicker-B9eprAyk.amd.js +0 -234
- package/.chunks/datepicker-B9eprAyk.amd.js.map +0 -1
- package/.chunks/datepicker-C86O1mQq.es.js +0 -277
- package/.chunks/datepicker-C86O1mQq.es.js.map +0 -1
- package/.chunks/forms-DkNAMd-D.amd.js +0 -3
- package/.chunks/forms-DkNAMd-D.amd.js.map +0 -1
- package/.chunks/forms-gb7uf2K8.es.js.map +0 -1
- package/.chunks/listItem.vue_vue_type_script_setup_true_lang-2TAzIZZA.amd.js.map +0 -1
- package/.chunks/listItem.vue_vue_type_script_setup_true_lang-Caw4oFU-.es.js.map +0 -1
- package/.chunks/popup-Dfz5hkrQ.amd.js.map +0 -1
- package/.chunks/popup-ZmdXZkvb.es.js.map +0 -1
- package/.chunks/widgetInput-BxO9y9L7.amd.js.map +0 -1
- package/.chunks/widgetInput-DPOH_qya.es.js.map +0 -1
|
@@ -20,6 +20,10 @@ declare const meta: {
|
|
|
20
20
|
hint: {
|
|
21
21
|
type: import("vue").PropType<string>;
|
|
22
22
|
};
|
|
23
|
+
closeText: {
|
|
24
|
+
type: import("vue").PropType<string>;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
23
27
|
readonly: {
|
|
24
28
|
type: import("vue").PropType<boolean>;
|
|
25
29
|
};
|
|
@@ -36,6 +40,10 @@ declare const meta: {
|
|
|
36
40
|
type: import("vue").PropType<boolean>;
|
|
37
41
|
default: boolean;
|
|
38
42
|
};
|
|
43
|
+
defaultValue: {
|
|
44
|
+
type: import("vue").PropType<string>;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
39
47
|
cancelText: {
|
|
40
48
|
type: import("vue").PropType<string>;
|
|
41
49
|
default: string;
|
|
@@ -44,12 +52,19 @@ declare const meta: {
|
|
|
44
52
|
type: import("vue").PropType<string>;
|
|
45
53
|
default: string;
|
|
46
54
|
};
|
|
55
|
+
isFocused: {
|
|
56
|
+
type: import("vue").PropType<boolean>;
|
|
57
|
+
};
|
|
58
|
+
forceShowCloseBtn: {
|
|
59
|
+
type: import("vue").PropType<boolean>;
|
|
60
|
+
};
|
|
47
61
|
attachToKeyboard: {
|
|
48
62
|
type: import("vue").PropType<boolean>;
|
|
49
63
|
};
|
|
50
64
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
submit: (value: string) => void;
|
|
66
|
+
close: () => void;
|
|
67
|
+
clickOnTitle: () => void;
|
|
53
68
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
54
69
|
title: {
|
|
55
70
|
type: import("vue").PropType<string>;
|
|
@@ -70,6 +85,10 @@ declare const meta: {
|
|
|
70
85
|
hint: {
|
|
71
86
|
type: import("vue").PropType<string>;
|
|
72
87
|
};
|
|
88
|
+
closeText: {
|
|
89
|
+
type: import("vue").PropType<string>;
|
|
90
|
+
default: string;
|
|
91
|
+
};
|
|
73
92
|
readonly: {
|
|
74
93
|
type: import("vue").PropType<boolean>;
|
|
75
94
|
};
|
|
@@ -86,6 +105,10 @@ declare const meta: {
|
|
|
86
105
|
type: import("vue").PropType<boolean>;
|
|
87
106
|
default: boolean;
|
|
88
107
|
};
|
|
108
|
+
defaultValue: {
|
|
109
|
+
type: import("vue").PropType<string>;
|
|
110
|
+
default: string;
|
|
111
|
+
};
|
|
89
112
|
cancelText: {
|
|
90
113
|
type: import("vue").PropType<string>;
|
|
91
114
|
default: string;
|
|
@@ -94,14 +117,23 @@ declare const meta: {
|
|
|
94
117
|
type: import("vue").PropType<string>;
|
|
95
118
|
default: string;
|
|
96
119
|
};
|
|
120
|
+
isFocused: {
|
|
121
|
+
type: import("vue").PropType<boolean>;
|
|
122
|
+
};
|
|
123
|
+
forceShowCloseBtn: {
|
|
124
|
+
type: import("vue").PropType<boolean>;
|
|
125
|
+
};
|
|
97
126
|
attachToKeyboard: {
|
|
98
127
|
type: import("vue").PropType<boolean>;
|
|
99
128
|
};
|
|
100
129
|
}>> & {
|
|
101
|
-
|
|
102
|
-
|
|
130
|
+
onSubmit?: ((value: string) => any) | undefined;
|
|
131
|
+
onClose?: (() => any) | undefined;
|
|
132
|
+
onClickOnTitle?: (() => any) | undefined;
|
|
103
133
|
}, {
|
|
134
|
+
closeText: string;
|
|
104
135
|
expandable: boolean;
|
|
136
|
+
defaultValue: string;
|
|
105
137
|
cancelText: string;
|
|
106
138
|
submitText: string;
|
|
107
139
|
}, {}>;
|
|
@@ -121,20 +153,4 @@ declare const meta: {
|
|
|
121
153
|
type Story = StoryObj<typeof meta>;
|
|
122
154
|
export declare const Playground: {};
|
|
123
155
|
export declare const Overview: Story;
|
|
124
|
-
export declare const Expandable: {
|
|
125
|
-
args: {
|
|
126
|
-
title: string;
|
|
127
|
-
modelValue: string;
|
|
128
|
-
expandable: true;
|
|
129
|
-
attachToKeyboard: false;
|
|
130
|
-
isError: false;
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
export declare const MobileVersion: {
|
|
134
|
-
args: {
|
|
135
|
-
modelValue: string;
|
|
136
|
-
attachToKeyboard: true;
|
|
137
|
-
isError: false;
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
156
|
export default meta;
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import type { Props } from './editArea';
|
|
2
2
|
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
3
|
+
defaultValue: string;
|
|
3
4
|
cancelText: string;
|
|
4
5
|
submitText: string;
|
|
6
|
+
closeText: string;
|
|
5
7
|
expandable: boolean;
|
|
6
8
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
submit: (value: string) => void;
|
|
10
|
+
close: () => void;
|
|
11
|
+
clickOnTitle: () => void;
|
|
9
12
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
13
|
+
defaultValue: string;
|
|
10
14
|
cancelText: string;
|
|
11
15
|
submitText: string;
|
|
16
|
+
closeText: string;
|
|
12
17
|
expandable: boolean;
|
|
13
18
|
}>>> & {
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
onSubmit?: ((value: string) => any) | undefined;
|
|
20
|
+
onClose?: (() => any) | undefined;
|
|
21
|
+
onClickOnTitle?: (() => any) | undefined;
|
|
16
22
|
}, {
|
|
23
|
+
closeText: string;
|
|
17
24
|
expandable: boolean;
|
|
25
|
+
defaultValue: string;
|
|
18
26
|
cancelText: string;
|
|
19
27
|
submitText: string;
|
|
20
28
|
}, {}>;
|
|
@@ -233,9 +233,9 @@ export declare const Playground: {
|
|
|
233
233
|
}>) => void) | ((vnode: import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
234
234
|
[key: string]: any;
|
|
235
235
|
}>) => void)[] | undefined;
|
|
236
|
+
onClose?: (() => any) | undefined;
|
|
236
237
|
readonly openByHover?: boolean | undefined;
|
|
237
238
|
readonly transitionDuration?: number | undefined;
|
|
238
|
-
onClose?: (() => any) | undefined;
|
|
239
239
|
onOpen?: (() => any) | undefined;
|
|
240
240
|
onScrollContentList?: ((value: Event) => any) | undefined;
|
|
241
241
|
opener?: ((_: {}) => any) | import("vue").VNodeChild;
|
|
@@ -739,9 +739,9 @@ export declare const Playground: {
|
|
|
739
739
|
}>) => void) | ((vnode: import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
740
740
|
[key: string]: any;
|
|
741
741
|
}>) => void)[] | undefined;
|
|
742
|
+
onClose?: (() => any) | undefined;
|
|
742
743
|
readonly openByHover?: boolean | undefined;
|
|
743
744
|
readonly transitionDuration?: number | undefined;
|
|
744
|
-
onClose?: (() => any) | undefined;
|
|
745
745
|
onOpen?: (() => any) | undefined;
|
|
746
746
|
onScrollContentList?: ((value: Event) => any) | undefined;
|
|
747
747
|
opener?: ((_: {}) => any) | import("vue").VNodeChild;
|
package/tabs/tabs.amd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
define(["require","exports","vue","../.chunks/forms-
|
|
1
|
+
define(["require","exports","vue","../.chunks/forms-DujTMzoW.amd","../require/css.amd!../assets/tabs.css"],function(k,s,e,o){"use strict";if(typeof e>"u")var e=window.Vue;const l={class:e.normalizeClass({"top-tabs":!0})},d={key:0,class:"top-tabs_header"},c={class:"top-tabs_contents"},r=e.defineComponent({__name:"tabs",props:{id:{}},setup(a){return(t,n)=>(e.openBlock(),e.createElementBlock("div",l,[e.renderSlot(t.$slots,"buttons"),t.$slots.header?(e.openBlock(),e.createElementBlock("div",d,[e.renderSlot(t.$slots,"header")])):e.createCommentVNode("",!0),e.createElementVNode("div",c,[e.renderSlot(t.$slots,"contents")])]))}}),b={$style:{"top-tabs":"top-tabs","top-tabs_header":"top-tabs_header","top-tabs_contents":"top-tabs_contents","top-tabs_tabInput":"top-tabs_tabInput","top-tabs_content":"top-tabs_content"}},p=o._export_sfc(r,[["__cssModules",b]]),_=["id","name","value","checked","disabled"],i=["for"],u=e.defineComponent({__name:"tab",props:{tabsId:{},name:{},title:{},active:{type:Boolean},disabled:{type:Boolean}},setup(a){return(t,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("input",{type:"radio",class:"top-tabs_tabInput top-unvisible",id:t.tabsId+t.name,name:t.tabsId,value:t.name,checked:t.active,disabled:t.disabled},null,8,_),e.createElementVNode("label",{class:e.normalizeClass({"top-tabs_tabLabel":!0,"top-forms-focusable":!0,"top-disabled":t.disabled}),for:t.tabsId+t.name},[e.renderSlot(t.$slots,"default")],10,i)],64))}}),m={$style:{"top-tabs_tabLabel":"top-tabs_tabLabel","top-tabs_tabInput":"top-tabs_tabInput","top-disabled":"top-disabled"}},f=o._export_sfc(u,[["__cssModules",m]]),$=["data-tabs-name"],h=e.defineComponent({__name:"content",props:{name:{}},setup(a){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-tabs_content":!0}),"data-tabs-name":t.name},[e.renderSlot(t.$slots,"default")],8,$))}}),y={$style:{"top-tabs_content":"top-tabs_content"}},v=o._export_sfc(h,[["__cssModules",y]]);s.Tabs=p,s.TabsContent=v,s.TabsTab=f,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=tabs.amd.js.map
|
package/tabs/tabs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { insertToPage as c } from "../utils/css.js";
|
|
2
2
|
import { defineComponent as b, openBlock as a, createElementBlock as o, renderSlot as s, createCommentVNode as _, createElementVNode as n, normalizeClass as l, Fragment as i } from "vue";
|
|
3
|
-
import { a as p } from "../.chunks/forms-
|
|
3
|
+
import { a as p } from "../.chunks/forms-C4UtO06K.es.js";
|
|
4
4
|
const r = ["../assets/tabs.css"].map((e) => import.meta.resolve(e));
|
|
5
5
|
await c(r);
|
|
6
6
|
const u = {
|
package/tabsView/tabsView.amd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
define(["require","exports","vue","../utils/route.amd","../.chunks/forms-
|
|
1
|
+
define(["require","exports","vue","../utils/route.amd","../.chunks/forms-DujTMzoW.amd","../.chunks/store-Bl79G7T_.amd","../.chunks/listItem.vue_vue_type_script_setup_true_lang-Ob3185Bq.amd","../popup/worker.amd","../utils/system.amd","../require/css.amd!../assets/tabsView.css"],function(ee,_,e,b,p,v,w,te,I){"use strict";if(typeof e>"u")var e=window.Vue;const h=(o,n)=>`top:${String(o)}:${n}`,y={loadLocalStorge:(o,n)=>{if(!n.$id)return;const t=h(o,n.$id);try{const a=JSON.parse(localStorage.getItem(t));typeof a==typeof n[o]&&(n[o]=a)}catch{console.warn(new Error(`В localStorage[${t}] не корректный json`))}},addSaverLocalStorge:(o,n)=>{if(!n.$id)return;const t=h(o,n.$id);e.watch(()=>n[o],()=>{localStorage.setItem(t,JSON.stringify(n[o]))},{immediate:!0})}},S=Symbol(),B=(o,n)=>{const t=v.defineStore(S,()=>{const a=e.computed(()=>o.showMenuInPopup??p.Core.state.isMobile),l=e.computed(()=>o.pageMod),u=e.ref(!1),s=e.ref(void 0),r=e.ref(!0);return{showMenuInPopup:a,pageMod:l,isShort:u,activeItemName:n,component:s,scrollable:r}},o.idState);if(o.isShortable){const a="isShort";y.loadLocalStorge(a,t),y.addSaverLocalStorge(a,t)}return t},V=()=>v.useStore(S),N={key:1,class:"top-ellipsis"},L=e.defineComponent({__name:"menuItem",props:{name:{},href:{},icon:{},disabled:{type:Boolean},component:{default:void 0},scrollable:{type:Boolean,default:!0}},setup(o){const n=o,t=V(),a=e.computed(()=>n.name&&t.$id?b.genHash(t.$id,n.name):n.href),l=e.computed(()=>t.showMenuInPopup?w._sfc_main$2:a?"a":"button"),u=s=>{!n.href&&a.value&&s.preventDefault(),n.name&&(t.activeItemName=n.name)};return(s,r)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.value),{target:"_self",class:e.normalizeClass({"top-tabsView_menuItem":!e.unref(t).showMenuInPopup,"top-active":s.name&&e.unref(t).activeItemName===s.name,"top-disabled":s.disabled,"top-spa-disabled":!0}),href:a.value,"data-top-icon":s.icon||void 0,disabled:s.disabled||void 0,onClick:u},{default:e.withCtx(()=>[e.unref(t).showMenuInPopup?e.renderSlot(s.$slots,"default",{key:0}):s.$slots.default&&!e.unref(t).isShort?(e.openBlock(),e.createElementBlock("span",N,[e.renderSlot(s.$slots,"default")])):e.createCommentVNode("",!0)]),_:3},8,["class","href","data-top-icon","disabled"]))}}),C={$style:{"top-tabsView_menuItem":"top-tabsView_menuItem","top-active":"top-active","top-forms-option":"top-forms-option","top-formsCaption":"top-formsCaption","top-disabled":"top-disabled"}},m=p._export_sfc(L,[["__cssModules",C]]),g=o=>(o==null?void 0:o.name)==="AsyncComponentWrapper"&&!(o!=null&&o.__asyncResolved),P=async(o,n)=>{(o==null?void 0:o.name)==="AsyncComponentWrapper"&&(o!=null&&o.__asyncResolved||(o.__asyncLoader(),await I.sleepWhile(()=>n()&&g(o),200)))},T={class:"top-tabsView_menuOpener"},E=["data-top-icon"],O={class:"top-ellipsis"},D=e.createElementVNode("div",{class:"top-tabsView_menuOpenerIcon","data-top-icon":""},null,-1),z={class:"top-tabsView_menuList"},R={key:0,class:"top-tabsView_menuFooter"},A=e.defineComponent({__name:"menu",props:e.mergeModels({isShortable:{type:Boolean},isLoading:{type:Boolean}},{isLoading:{},isLoadingModifiers:{}}),emits:["update:isLoading"],setup(o){const n=e.useModel(o,"isLoading"),t=V(),a=e.useSlots(),l=new Map,u=()=>{if(!a.default)return;const c=a.default().find(i=>i.key==="_menu");c&&c.children.forEach(i=>{var M,$;if(i.type.__name!==m.__name||!i.props.name||i.props.disabled)return;const k={title:(($=(M=i.children).default)==null?void 0:$.call(M)[0].children).trim(),icon:i.props.icon,component:i.props.component?e.markRaw(i.props.component):m.props.component.default,scrollable:i.props.scrollable??m.props.scrollable.default};l.set(i.props.name,k)})},s=e.ref(null);let r=0;e.watch(()=>t.activeItemName,async()=>{const c=++r;if(l.size===0&&u(),l.size===0){t.activeItemName="";return}if(s.value=l.get(t.activeItemName)??null,!s.value&&t.$id){const i=b.getHash(t.$id);if(s.value=l.get(i)??null,s.value){t.activeItemName=i;return}}if(!s.value){t.activeItemName=l.keys().next().value;return}if(s.value.component===t.component){n.value=!1;return}t.$id&&b.setHash(t.$id,t.activeItemName,!0),n.value=!0,await P(s.value.component,()=>c===r),c===r&&(t.scrollable=s.value.scrollable,t.component=s.value.component,s.value&&!t.component&&console.warn(`Компонент вкладки ${t.activeItemName} не найден. Добавьте props.component для пункта меню ${t.activeItemName}.`))},{immediate:!0});const d=e.ref();let f;return e.onMounted(()=>{f=new ResizeObserver(()=>{d.value.parentElement.style.setProperty("--top-tabsView-contents-offset-top",d.value.offsetHeight+"px")}),f.observe(d.value)}),e.onUnmounted(()=>{f.disconnect()}),(c,i)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"elRef",ref:d,class:e.normalizeClass({"top-tabsView_menu":!0,"top-tabsView_menu-inPopup_0":!e.unref(t).showMenuInPopup,"top-tabsView_menu-inPopup_1":e.unref(t).showMenuInPopup,"top-tabsView_menu-short":e.unref(t).isShort&&!e.unref(t).showMenuInPopup})},[e.unref(t).showMenuInPopup?(e.openBlock(),e.createBlock(e.unref(w._sfc_main),{key:0},{opener:e.withCtx(()=>[e.createElementVNode("div",T,[s.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"top-tabsView_menuOpenerActiveItem","data-top-icon":s.value.icon},[e.createElementVNode("span",O,e.toDisplayString(s.value.title),1)],8,E)):e.createCommentVNode("",!0),D])]),contentList:e.withCtx(()=>[e.renderSlot(c.$slots,"default")]),_:3})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",z,[e.renderSlot(c.$slots,"default")]),c.isShortable?(e.openBlock(),e.createElementBlock("div",R,[c.isShortable?(e.openBlock(),e.createBlock(m,{key:0,icon:e.unref(t).isShort?"":"",onClick:i[0]||(i[0]=k=>e.unref(t).isShort=!e.unref(t).isShort)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(t).isShort?"":"Свернуть"),1)]),_:1},8,["icon"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],64))],2))}}),H={$style:{"top-tabsView-pageMod":"top-tabsView-pageMod","top-tabsView_menu":"top-tabsView_menu","top-tabsView_menu-inPopup_0":"top-tabsView_menu-inPopup_0","top-tabsView_menu-inPopup_1":"top-tabsView_menu-inPopup_1","top-tabsView_menu-short":"top-tabsView_menu-short","top-tabsView_menuOpener":"top-tabsView_menuOpener","top-tabsView_menuOpenerIcon":"top-tabsView_menuOpenerIcon","top-tabsView_menuOpenerActiveItem":"top-tabsView_menuOpenerActiveItem","top-tabsView_menuList":"top-tabsView_menuList","top-tabsView_menuFooter":"top-tabsView_menuFooter","top-tabsView_menuItem":"top-tabsView_menuItem"}},K=p._export_sfc(A,[["__cssModules",H]]),F=e.defineComponent({__name:"tabsView",props:e.mergeModels({modelValue:{},pageMod:{type:Boolean},showMenuInPopup:{type:Boolean,default:void 0},isShortable:{type:Boolean,default:!1},idState:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const n=o,t=e.useModel(o,"modelValue"),a=B(n,t),l=r=>{document.documentElement.classList.toggle("top-hasTabsViewPageMod",r)};n.pageMod&&l(!0),e.onUnmounted(()=>{n.pageMod&&l(!1),a.$id&&b.delHash(a.$id,a.activeItemName,!0)});const u=e.ref(),s=e.ref(!1);return e.watch([u,()=>a.component],()=>{s.value=g(a.component)},{immediate:!0}),(r,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass({"top-tabsView":!0,"top-tabsView-pageMod":n.pageMod,"top-tabsView-inPopup":e.unref(a).showMenuInPopup})},[e.createVNode(K,{isShortable:r.isShortable,isLoading:s.value,"onUpdate:isLoading":d[0]||(d[0]=f=>s.value=f)},{default:e.withCtx(()=>[e.renderSlot(r.$slots,"menu")]),_:3},8,["isShortable","isLoading"]),e.createElementVNode("div",{class:e.normalizeClass({"top-tabsView_contents":!0,"top-tabsView_contents-isLoading":s.value,"top-tabsView_contents-noScrollable":!e.unref(a).scrollable})},[s.value?(e.openBlock(),e.createBlock(e.unref(p.Loadbar),{key:0})):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.KeepAlive,null,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(a).component),{ref_key:"componentRef",ref:u},null,512))],1024))],2)],2))}}),j={$style:{"top-tabsView":"top-tabsView","top-tabsView_contents":"top-tabsView_contents","top-tabsView_contents-isLoading":"top-tabsView_contents-isLoading","top-tabsView_contents-noScrollable":"top-tabsView_contents-noScrollable","top-tabsView-inPopup":"top-tabsView-inPopup"}},q=p._export_sfc(F,[["__cssModules",j]]),U={"top-tabsView_menuDelimeter":"top-tabsView_menuDelimeter"},W={},J={class:"top-tabsView_menuDelimeter"};function x(o,n){return e.openBlock(),e.createElementBlock("div",J)}const G={$style:U},Q=p._export_sfc(W,[["render",x],["__cssModules",G]]),X=e.defineComponent({__name:"menuTitle",props:{isSubtitle:{type:Boolean}},setup(o){const n=V();return(t,a)=>e.unref(n).showMenuInPopup?(e.openBlock(),e.createBlock(e.unref(w._sfc_main$2),{key:0,type:"title"},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3})):e.unref(n).isShort?(e.openBlock(),e.createBlock(Q,{key:1})):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass({"top-tabsView_menuTitle":!0,"top-tabsView_menuTitle-subtitle":t.isSubtitle})},[e.renderSlot(t.$slots,"default")],2))}}),Y={$style:{"top-tabsView_menuTitle":"top-tabsView_menuTitle","top-tabsView_menuTitle-subtitle":"top-tabsView_menuTitle-subtitle"}},Z=p._export_sfc(X,[["__cssModules",Y]]);_.TabsView=q,_.TabsViewMenuItem=m,_.TabsViewMenuTitle=Z,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=tabsView.amd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabsView.amd.js","sources":["../../src/core/utils/store/localStorage.ts","../../src/components/tabsView/tabsView/store.ts","../../src/components/tabsView/tabsView/menuItem.vue","../../src/components/tabsView/tabsView/utils.ts","../../src/components/tabsView/tabsView/menu.vue","../../src/components/tabsView/tabsView/tabsView.vue","../../src/components/tabsView/tabsView/menuDelimeter.vue","../../src/components/tabsView/tabsView/menuTitle.vue"],"sourcesContent":["import { watch } from 'vue';\r\nimport type { Store } from './store';\r\n\r\n/**\r\n * Сгенерировать имя для сохранения данных в localStorage\r\n * @param stateName - имя свойства состояния\r\n * @param stateKey - ключ состояния, разные компоненты могут использовать одинаковый ключ\r\n */\r\nconst genStorageKey = <T extends Store>(stateName: keyof T, stateKey: string): string => {\r\n\tconst stateNameString = String(stateName);\r\n\r\n\treturn `top:${stateNameString}:${stateKey}`;\r\n};\r\n\r\n/**\r\n * Загрузить состояние\r\n * @param stateName - имя свойства состояния\r\n * @param store\r\n */\r\nconst loadLocalStorge = <T extends Store>(stateName: keyof T, store: T) => {\r\n\t// если Store.key не знадан, значит сохранение состояния в компоненте отключено\r\n\tif (!store.$id) return;\r\n\r\n\tconst localStorageKey = genStorageKey(stateName, store.$id);\r\n\r\n\ttry {\r\n\t\tconst localStorageValue: typeof store[keyof typeof store] = JSON.parse(localStorage.getItem(localStorageKey) as string);\r\n\r\n\t\tif (typeof localStorageValue === typeof store[stateName]) {\r\n\t\t\tstore[stateName] = localStorageValue;\r\n\t\t}\r\n\t} catch (e) {\r\n\t\tconsole.warn(new Error(`В localStorage[${localStorageKey}] не корректный json`));\r\n\t}\r\n};\r\n\r\n/**\r\n * Добавить автосохранение состояние при его изменении\r\n * @param stateName - имя свойства состояния\r\n * @param store\r\n */\r\nconst addSaverLocalStorge = <T extends Store>(stateName: keyof T, store: T) => {\r\n\t// если store.$id не знадан, значит сохранение состояния в компоненте отключено\r\n\tif (!store.$id) return;\r\n\r\n\tconst localStorageKey = genStorageKey(stateName, store.$id);\r\n\r\n\twatch(() => store[stateName], () => {\r\n\t\tlocalStorage.setItem(localStorageKey, JSON.stringify(store[stateName]));\r\n\t}, { immediate: true });\r\n};\r\n\r\nexport default {\r\n\tloadLocalStorge,\r\n\taddSaverLocalStorge,\r\n};","import type { ModelRef, InjectionKey } from 'vue';\r\nimport { ref, computed } from 'vue';\r\nimport Core from '@/core/core/core';\r\nimport { defineStore, useStore } from '@/core/utils/store';\r\nimport StoreLocalStorage from '@/core/utils/store/localStorage';\r\nimport type { Props, Store } from './tabsView';\r\n\r\nexport const injectionKey = Symbol() as InjectionKey<Store>;\r\n\r\n/**\r\n * Инициировать Store компонента\r\n */\r\nexport const defineTabsStore = (props: Props, model: ModelRef<string | undefined>) => {\r\n\tconst store = defineStore(injectionKey, () => {\r\n\t\tconst showMenuInPopup = computed(() => props.showMenuInPopup ?? Core.state.isMobile);\r\n\t\tconst pageMod = computed(() => props.pageMod);\r\n\t\tconst isShort = ref(false);\r\n\r\n\t\tconst component = ref(undefined);\r\n\t\tconst scrollable = ref(true);\r\n\r\n\t\treturn {\r\n\t\t\tshowMenuInPopup,\r\n\t\t\tpageMod,\r\n\t\t\tisShort,\r\n\t\t\tactiveItemName: model,\r\n\t\t\tcomponent,\r\n\t\t\tscrollable,\r\n\t\t};\r\n\t}, props.idState);\r\n\r\n\tif (props.isShortable) {\r\n\t\tconst stateName = 'isShort';\r\n\r\n\t\tStoreLocalStorage.loadLocalStorge(stateName, store);\r\n\t\tStoreLocalStorage.addSaverLocalStorge(stateName, store);\r\n\t}\r\n\r\n\treturn store;\r\n};\r\n\r\n/**\r\n * Получить Store компонента\r\n */\r\nexport const useTabsStore = () => useStore(injectionKey);","<script setup lang=\"ts\">\r\nimport { computed } from 'vue';\r\nimport { genHash } from '@/core/utils/route';\r\nimport { PopupListItem } from '@/components/popup/popup';\r\nimport { useTabsStore } from './store';\r\nimport type { PropsMenuItem } from './tabsView';\r\n\r\nconst props = withDefaults(defineProps<PropsMenuItem>(), {\r\n\tscrollable: true,\r\n\tcomponent: undefined,\r\n});\r\n\r\nconst store = useTabsStore();\r\n\r\nconst href = computed(() => {\r\n\t// это внутренняя хеш навигация, ссылка на вкладку\r\n\tif (props.name && store.$id) {\r\n\t\treturn genHash(store.$id, props.name);\r\n\t}\r\n\r\n\treturn props.href;\r\n});\r\n\r\nconst tagName = computed(() => {\r\n\tif (store.showMenuInPopup) {\r\n\t\treturn PopupListItem;\r\n\t}\r\n\r\n\treturn href ? 'a' : 'button';\r\n});\r\n\r\n/**\r\n * Клик по элементу меню\r\n */\r\nconst onClick = (e: MouseEvent) => {\r\n\t// это внутренняя хеш навигация, ссылка на вкладку\r\n\tif (!props.href && href.value) {\r\n\t\te.preventDefault();\r\n\t}\r\n\r\n\tif (props.name) {\r\n\t\tstore.activeItemName = props.name;\r\n\t}\r\n};\r\n</script>\r\n\r\n<template>\r\n\t<component\r\n\t\t:is=\"tagName\"\r\n\t\ttarget=\"_self\"\r\n\t\t:class=\"{\r\n\t\t\t['top-tabsView_menuItem']: !store.showMenuInPopup,\r\n\t\t\t['top-active']: name && store.activeItemName === name,\r\n\t\t\t['top-disabled']: disabled,\r\n\t\t\t['top-spa-disabled']: true,\r\n\t\t}\"\r\n\t\t:href=\"href\"\r\n\t\t:data-top-icon=\"icon || undefined\"\r\n\t\t:disabled=\"disabled || undefined\"\r\n\t\t@click=\"onClick\"\r\n\t>\r\n\t\t<slot v-if=\"store.showMenuInPopup\"></slot>\r\n\r\n\t\t<span\r\n\t\t\tv-else-if=\"$slots.default && !store.isShort\"\r\n\t\t\tclass=\"top-ellipsis\"\r\n\t\t>\r\n\t\t\t<slot></slot>\r\n\t\t</span>\r\n\t</component>\r\n</template>\r\n\r\n<style module>\r\n.top-tabsView_menuItem {\r\n\t--top-icon-color: var(--color-text-1);\r\n\t--top-icon-width: calc(var(--top-icon-size));\r\n\r\n\tcursor: pointer;\r\n\tbox-sizing: border-box;\r\n\r\n\tborder: none;\r\n\tborder-radius: var(--top-radius-2);\r\n\tpadding: var(--top-padding-2);\r\n\tbackground: transparent;\r\n\theight: 40px;\r\n\r\n\tcolor: var(--color-text-1);\r\n\ttext-decoration: none;\r\n\twhite-space: nowrap;\r\n\r\n\tdisplay: flex;\r\n\tgap: var(--top-gap-2);\r\n\talign-items: center;\r\n\tjustify-content: flex-start;\r\n\ttransition: background var(--transition);\r\n}\r\n\r\n.top-tabsView_menuItem:hover {\r\n\tbackground: var(--color-secondary-2-opacity);\r\n\ttext-decoration: none;\r\n}\r\n\r\n.top-tabsView_menuItem.top-active {\r\n\tcursor: unset;\r\n\tbackground: var(--color-bg-3);\r\n}\r\n\r\n.top-tabsView_menuItem:disabled:not(option):not(optgroup):not(.top-forms-option),\r\n.top-tabsView_menuItem:disabled ~ .top-formsCaption,\r\n.top-tabsView_menuItem.top-disabled[data-top-icon]:before,\r\n.top-tabsView_menuItem.top-disabled[data-top-icon2]:after {\r\n\topacity: unset;\r\n\tfilter: unset;\r\n}\r\n\r\n.top-tabsView_menuItem.top-disabled {\r\n\t--top-icon-color: var(--color-text-4);\r\n\r\n\tcolor: var(--color-text-4);\r\n}\r\n</style>","// TODO: Эту функцию можно вынести в глобальный utils\r\n\r\nimport { sleepWhile } from '@/core/utils/system';\r\n\r\n/**\r\n * Проверка нахождения компонента в состояние загрузки\r\n * @param component\r\n */\r\nexport const checkComponentIsLoading = (component: any) => {\r\n\treturn component?.name === 'AsyncComponentWrapper' && !component?.__asyncResolved;\r\n};\r\n\r\n/**\r\n * Презагрузить компонент\r\n *\r\n * Некоторое время ожидает загрузку компонента, прежде чем завершит работу\r\n */\r\nexport const preResolveComponent = async (component: any, condition: Function) => {\r\n\tif(component?.name !== 'AsyncComponentWrapper') return;\r\n\tif(component?.__asyncResolved) return;\r\n\r\n\tcomponent.__asyncLoader();\r\n\r\n\tawait sleepWhile(() => {\r\n\t\treturn condition() && checkComponentIsLoading(component);\r\n\t}, 200);\r\n};","<script setup lang=\"ts\">\r\nimport { ref, watch, markRaw, useSlots, onMounted, onUnmounted } from 'vue';\r\nimport type { Ref, Component } from 'vue';\r\nimport { Popup } from '../../popup/popup';\r\nimport { sleepWhile } from '@/core/utils/system';\r\nimport { getHash, setHash } from '@/core/utils/route';\r\n\r\nimport type { PropsMenu, PropsMenuItem, MenuItem } from './tabsView';\r\nimport { useTabsStore } from './store';\r\nimport TabsViewMenuItem from './menuItem.vue';\r\nimport { preResolveComponent } from './utils';\r\n\r\ndefineProps<PropsMenu>();\r\n\r\nconst isLoading = defineModel('isLoading');\r\n\r\nconst store = useTabsStore();\r\n\r\nconst slots = useSlots();\r\n\r\n// словарь используется для оптимизации получения нужного menuItem\r\nconst menuItemByName: Map<PropsMenuItem['name'], MenuItem> = new Map();\r\n\r\n// сгенерировать словарь с menuItem, по элементам в slot\r\nconst genMenuItemByName = () => {\r\n\tif (!slots.default) return;\r\n\r\n\tconst component: any = slots.default().find(item => item.key === '_menu');\r\n\tif (!component) return;\r\n\r\n\tcomponent.children.forEach((subComponent: any) => {\r\n\t\tif (subComponent.type.__name !== TabsViewMenuItem.__name) return;\r\n\t\tif (!subComponent.props.name || subComponent.props.disabled) return;\r\n\r\n\t\tconst menuItem: MenuItem = {\r\n\t\t\ttitle: (subComponent.children.default?.()[0].children as string).trim(),\r\n\t\t\ticon: subComponent.props.icon,\r\n\t\t\tcomponent: subComponent.props.component ? markRaw(subComponent.props.component) : TabsViewMenuItem.props.component.default,\r\n\t\t\tscrollable: subComponent.props.scrollable ?? TabsViewMenuItem.props.scrollable.default,\r\n\t\t};\r\n\r\n\t\tmenuItemByName.set(subComponent.props.name, menuItem);\r\n\t});\r\n};\r\n\r\n/**\r\n * activeMenuItem нужен:\r\n * - для вывода текста активной вкладки в меню с popup\r\n * - для вывода компонента активной вкладки (store.component)\r\n * - для установки store.scrollable\r\n */\r\nconst activeMenuItem: Ref<MenuItem | null> = ref(null);\r\n\r\n/**\r\n * Кол-во изменений активной вкладки\r\n */\r\nlet countChanged = 0;\r\n\r\n/**\r\n * Смена активной вкладки\r\n *\r\n * TODO: смена slot, например смена языка, требует повторного выполнения genMenuItemByName()\r\n */\r\nwatch(\r\n\t() => store.activeItemName,\r\n\tasync () => {\r\n\t\tconst numberChanged = ++countChanged; // порядковый номер текущего изменения\r\n\r\n\t\tif (menuItemByName.size === 0) {\r\n\t\t\tgenMenuItemByName();\r\n\t\t}\r\n\r\n\t\tif (menuItemByName.size === 0) {\r\n\t\t\tstore.activeItemName = '';\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tactiveMenuItem.value = menuItemByName.get(store.activeItemName) ?? null;\r\n\r\n\t\t// элемент не найден, установить из хеша страницы\r\n\t\tif (!activeMenuItem.value && store.$id) {\r\n\t\t\tconst activeItemName = getHash(store.$id);\r\n\r\n\t\t\tactiveMenuItem.value = menuItemByName.get(activeItemName) ?? null;\r\n\r\n\t\t\tif (activeMenuItem.value) {\r\n\t\t\t\tstore.activeItemName = activeItemName;\r\n\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// элемент не найден, установить первый доступный\r\n\t\tif (!activeMenuItem.value) {\r\n\t\t\tstore.activeItemName = menuItemByName.keys().next().value;\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// запрошена смена на уже активный элемент\r\n\t\tif (activeMenuItem.value.component === store.component) {\r\n\t\t\tisLoading.value = false;\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (store.$id) setHash(store.$id, store.activeItemName, true);\r\n\r\n\t\t// флаг загрузки будет сброшен при инициализации компонента\r\n\t\tisLoading.value = true;\r\n\r\n\t\t/**\r\n\t\t * Презагрузить компонент\r\n\t\t *\r\n\t\t * Нужно для того, чтобы минимизировать скачки интерфейса при ожидании загрузки асинхронного компонента\r\n\t\t */\r\n\t\tawait preResolveComponent(activeMenuItem.value.component, () => numberChanged === countChanged);\r\n\r\n\t\t// влкадка была сменена еще раз во время sleepWhile\r\n\t\tif (numberChanged !== countChanged) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tstore.scrollable = activeMenuItem.value.scrollable;\r\n\t\tstore.component = activeMenuItem.value.component;\r\n\r\n\t\tif (activeMenuItem.value && !store.component) {\r\n\t\t\tconsole.warn(`Компонент вкладки ${store.activeItemName} не найден. Добавьте props.component для пункта меню ${store.activeItemName}.`);\r\n\t\t}\r\n\t},\r\n\t{ immediate: true },\r\n);\r\n\r\nconst elRef = ref();\r\nlet resizeObserver: ResizeObserver;\r\n\r\nonMounted(() => {\r\n\tresizeObserver = new ResizeObserver(() => {\r\n\t\telRef.value.parentElement.style.setProperty('--top-tabsView-contents-offset-top', elRef.value.offsetHeight + 'px');\r\n\t});\r\n\r\n\tresizeObserver.observe(elRef.value);\r\n});\r\n\r\nonUnmounted(() => {\r\n\tresizeObserver.disconnect();\r\n});\r\n</script>\r\n\r\n<template>\r\n\t<div\r\n\t\tref=\"elRef\"\r\n\t\t:class=\"{\r\n\t\t\t'top-tabsView_menu': true,\r\n\t\t\t'top-tabsView_menu-inPopup_0': !store.showMenuInPopup,\r\n\t\t\t'top-tabsView_menu-inPopup_1': store.showMenuInPopup,\r\n\t\t\t'top-tabsView_menu-short': store.isShort && !store.showMenuInPopup,\r\n\t\t}\"\r\n\t>\r\n\t\t<!-- Спрятать меню под кнопку в popup -->\r\n\t\t<Popup v-if=\"store.showMenuInPopup\">\r\n\t\t\t<template #opener>\r\n\t\t\t\t<div class=\"top-tabsView_menuOpener\">\r\n\t\t\t\t\t<div\r\n\t\t\t\t\t\tv-if=\"activeMenuItem\"\r\n\t\t\t\t\t\tclass=\"top-tabsView_menuOpenerActiveItem\"\r\n\t\t\t\t\t\t:data-top-icon=\"activeMenuItem.icon\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<span class=\"top-ellipsis\">\r\n\t\t\t\t\t\t\t{{ activeMenuItem.title }}\r\n\t\t\t\t\t\t</span>\r\n\t\t\t\t\t</div>\r\n\r\n\t\t\t\t\t<div class=\"top-tabsView_menuOpenerIcon\" data-top-icon=\"\"></div>\r\n\t\t\t\t</div>\r\n\t\t\t</template>\r\n\r\n\t\t\t<template #contentList>\r\n\t\t\t\t<slot></slot>\r\n\t\t\t</template>\r\n\t\t</Popup>\r\n\r\n\t\t<!-- Отобразить меню на странице -->\r\n\t\t<template v-else>\r\n\t\t\t<div class=\"top-tabsView_menuList\">\r\n\t\t\t\t<slot></slot>\r\n\t\t\t</div>\r\n\r\n\t\t\t<div\r\n\t\t\t\tv-if=\"isShortable\"\r\n\t\t\t\tclass=\"top-tabsView_menuFooter\"\r\n\t\t\t>\r\n\t\t\t\t<TabsViewMenuItem\r\n\t\t\t\t\tv-if=\"isShortable\"\r\n\t\t\t\t\t:icon=\"store.isShort ? '' : ''\"\r\n\t\t\t\t\t@click=\"store.isShort = !store.isShort\"\r\n\t\t\t\t>\r\n\t\t\t\t\t{{ store.isShort ? '' : 'Свернуть' }} <!--TODO: translate-->\r\n\t\t\t\t</TabsViewMenuItem>\r\n\t\t\t</div>\r\n\t\t</template>\r\n\t</div>\r\n</template>\r\n\r\n<style module>\r\n/* режим отображение табов в основной области документа */\r\n.top-tabsView-pageMod .top-tabsView_menu {\r\n\tbox-sizing: border-box;\r\n\tposition: sticky;\r\n\ttop: var(--top-tabsView-top);\r\n\tz-index: 10;\r\n}\r\n\r\n/* режим отображение табов в основной области документа без popup */\r\n.top-tabsView-pageMod .top-tabsView_menu-inPopup_0 {\r\n\theight: calc(var(--100vh) - var(--top-tabsView-top));\r\n}\r\n\r\n/* стантартный режим */\r\n.top-tabsView_menu-inPopup_0 {\r\n\tbox-sizing: border-box;\r\n\twidth: var(--top-tabsView-menu-width);\r\n\tdisplay: flex;\r\n\tflex-direction: column;\r\n\tjustify-content: space-between;\r\n}\r\n\r\n/* режим вывода в popup */\r\n.top-tabsView_menu-inPopup_1 {\r\n\tborder-bottom: 1px solid var(--color-line-2-opacity);\r\n}\r\n\r\n.top-tabsView_menu-short {\r\n\twidth: auto;\r\n}\r\n\r\n.top-tabsView_menu > .top-tabsView_menuOpener {\r\n\tdisplay: flex;\r\n\tjustify-content: flex-end;\r\n}\r\n\r\n.top-tabsView_menu > .top-tabsView_menuOpener:hover {\r\n\tbackground: var(--color-secondary-opacity);\r\n}\r\n\r\n.top-tabsView_menuOpenerIcon { display: flex; }\r\n\r\n.top-tabsView_menuOpenerActiveItem {\r\n\t--top-forms-padding: 0px;\r\n\r\n\tbox-sizing: border-box;\r\n\tpadding: var(--top-padding-2);\r\n\tmax-width: calc(100% - var(--top-forms-base-height));\r\n\twhite-space: nowrap;\r\n\tflex-grow: 1;\r\n\tdisplay: flex;\r\n\talign-items: center;\r\n\tgap: var(--top-padding-2);\r\n}\r\n\r\n.top-tabsView_menuList,\r\n.top-tabsView_menuFooter {\r\n\tpadding: var(--top-padding-2);\r\n\tdisplay: flex;\r\n\tflex-direction: column;\r\n\tgap: var(--top-gap-2);\r\n}\r\n\r\n.top-tabsView_menuList {\r\n\toverflow-y: auto;\r\n}\r\n\r\n.top-tabsView_menu-short .top-tabsView_menuFooter > .top-tabsView_menuItem {\r\n\t--top-icon-width: 100%;\r\n}\r\n</style>","<script setup lang=\"ts\">\r\nimport { defineModel, onUnmounted, ref, watch } from 'vue';\r\nimport { delHash } from '@/core/utils/route';\r\nimport type { Props } from './tabsView';\r\nimport { defineTabsStore } from './store';\r\nimport TabsViewMenu from './menu.vue';\r\nimport { Loadbar } from '@/components/forms/forms';\r\nimport { checkComponentIsLoading } from './utils';\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n\tshowMenuInPopup: undefined,\r\n\tisShortable: false,\r\n});\r\n\r\nconst model = defineModel<string>();\r\n\r\nconst store = defineTabsStore(props, model);\r\n\r\n/**\r\n * Установка или снятие глобального модификатора\r\n * @see props.pageMod\r\n */\r\nconst setDocumentPageModModificator = (pageMod: boolean) => {\r\n\tdocument.documentElement.classList.toggle('top-hasTabsViewPageMod', pageMod);\r\n};\r\n\r\nif (props.pageMod) setDocumentPageModModificator(true);\r\n\r\nonUnmounted(() => {\r\n\tif (props.pageMod) setDocumentPageModModificator(false);\r\n\r\n\tif (store.$id) delHash(store.$id, store.activeItemName, true);\r\n});\r\n\r\nconst componentRef = ref();\r\nconst isLoading = ref(false);\r\n\r\nwatch([componentRef, () => store.component], () => {\r\n\tisLoading.value = checkComponentIsLoading(store.component);\r\n}, { immediate: true });\r\n</script>\r\n\r\n<template>\r\n\t<div\r\n\t\t:class=\"{\r\n\t\t\t'top-tabsView': true,\r\n\t\t\t'top-tabsView-pageMod': props.pageMod,\r\n\t\t\t'top-tabsView-inPopup': store.showMenuInPopup,\r\n\t\t}\"\r\n\t>\r\n\t\t<TabsViewMenu\r\n\t\t\t:isShortable=\"isShortable\"\r\n\t\t\tv-model:isLoading=\"isLoading\"\r\n\t\t>\r\n\t\t\t<!-- @slot Меню, ожидает передачу компонентов TabsViewMenuItem и TabsViewMenuTitle -->\r\n\t\t\t<slot name=\"menu\"></slot>\r\n\t\t</TabsViewMenu>\r\n\r\n\t\t<div\r\n\t\t\t:class=\"{\r\n\t\t\t\t'top-tabsView_contents': true,\r\n\t\t\t\t'top-tabsView_contents-isLoading': isLoading,\r\n\t\t\t\t'top-tabsView_contents-noScrollable': !store.scrollable,\r\n\t\t\t}\"\r\n\t\t>\r\n\t\t\t<Loadbar v-if=\"isLoading\"/>\r\n\t\t\t<keep-alive>\r\n\t\t\t\t<component\r\n\t\t\t\t\tref=\"componentRef\"\r\n\t\t\t\t\t:is=\"store.component\"\r\n\t\t\t\t/>\r\n\t\t\t</keep-alive>\r\n\t\t</div>\r\n\t</div>\r\n</template>\r\n\r\n<style module>\r\n:root {\r\n\t--top-tabsView-top: 0px;\r\n\t--top-tabsView-menu-width: 220px;\r\n\t--top-tabsView-contents-offset-top: 0px;\r\n}\r\n\r\n.top-tabsView {\r\n\tbackground: var(--color-bg-2);\r\n\twidth: 100%;\r\n\theight: 100%;\r\n\tdisplay: flex;\r\n\tflex-direction: row;\r\n}\r\n\r\n.top-tabsView_contents {\r\n\tborder-radius: var(--top-radius-4);\r\n\tbackground: var(--color-bg-3);\r\n\tpadding: var(--top-padding-4);\r\n\tflex-grow: 1;\r\n\toverflow: auto;\r\n\tposition: relative;\r\n}\r\n\r\n.top-tabsView_contents-isLoading {\r\n\tpointer-events: none;\r\n}\r\n\r\n.top-tabsView_contents-noScrollable {\r\n\twidth: calc(100% - var(--top-tabsView-menu-width));\r\n\tpadding: 0;\r\n\toverflow: visible;\r\n}\r\n\r\n/* top-tabsView-inPopup */\r\n.top-tabsView-inPopup {\r\n\tbackground: var(--color-bg-3);\r\n\tflex-direction: column;\r\n}\r\n\r\n.top-tabsView-inPopup > .top-tabsView_contents {\r\n\tborder-radius: 0;\r\n}\r\n\r\n.top-tabsView-inPopup > .top-tabsView_contents-noScrollable {\r\n\twidth: auto;\r\n}\r\n</style>","<script setup lang=\"ts\">\r\n\r\n</script>\r\n\r\n<template>\r\n\t<div class=\"top-tabsView_menuDelimeter\"></div>\r\n</template>\r\n\r\n<style module>\r\n.top-tabsView_menuDelimeter {\r\n\tpadding: var(--top-padding-1) 0;\r\n\tdisplay: flex;\r\n}\r\n\r\n.top-tabsView_menuDelimeter:before {\r\n\tcontent: \"\";\r\n\theight: 2px;\r\n\tbackground: var(--color-line-2-opacity);\r\n\tflex-grow: 1;\r\n}\r\n\r\n.top-tabsView_menuDelimeter:first-child,\r\n.top-tabsView_menuDelimeter + .top-tabsView_menuDelimeter {\r\n\tdisplay: none;\r\n}\r\n</style>","<script setup lang=\"ts\">\r\nimport { useTabsStore } from './store';\r\nimport type { PropsMenuTitle } from './tabsView';\r\nimport TabsViewMenuDelimeter from './menuDelimeter.vue';\r\nimport { PopupListItem } from '../../popup/popup';\r\n\r\ndefineProps<PropsMenuTitle>();\r\n\r\nconst store = useTabsStore();\r\n</script>\r\n\r\n<template>\r\n\t<PopupListItem\r\n\t\tv-if=\"store.showMenuInPopup\"\r\n\t\ttype=\"title\"\r\n\t>\r\n\t\t<slot></slot>\r\n\t</PopupListItem>\r\n\r\n\t<TabsViewMenuDelimeter v-else-if=\"store.isShort\"/>\r\n\r\n\t<div\r\n\t\tv-else\r\n\t\t:class=\"{\r\n\t\t\t'top-tabsView_menuTitle': true,\r\n\t\t\t'top-tabsView_menuTitle-subtitle': isSubtitle,\r\n\t\t}\"\r\n\t>\r\n\t\t<slot></slot>\r\n\t</div>\r\n</template>\r\n\r\n<style module>\r\n.top-tabsView_menuTitle {\r\n\tpadding: var(--top-padding-4) var(--top-padding-2) var(--top-padding-1);\r\n\tfont-weight: 600;\r\n}\r\n\r\n.top-tabsView_menuTitle-subtitle {\r\n\tpadding-top: var(--top-padding-1);\r\n\tfont-size: 12px;\r\n\tfont-weight: 400;\r\n\tcolor: var(--color-text-2);\r\n}\r\n</style>"],"names":["genStorageKey","stateName","stateKey","StoreLocalStorage","store","localStorageValue","localStorageKey","injectionKey","defineTabsStore","props","model","store$1","showMenuInPopup","vue","forms","isShort","scrollable","pageMod","component","useTabsStore","__props","href","tagName","onClick","e","checkComponentIsLoading","preResolveComponent","condition","slots","menuItemByName","item","subComponent","_b","_a","TabsViewMenuItem","menuItem","activeMenuItem","countChanged","numberChanged","activeItemName","isLoading","utils_route","elRef","resizeObserver","setDocumentPageModModificator","componentRef","_sfc_render","_ctx","_cache"],"mappings":"mWAQA,MAAAA,EAAA,CAAAC,EAAAC,WACC,OAAAD,CAAA,SA2CDE,EAAA,CAAe,gBAjCf,CAAAF,EAAAG,IAAA,CAEC,GAAA,CAAAA,EAAA,IAAgB,0BAIhB,GAAA,CACC,MAAAC,EAAA,KAAA,MAAA,aAAA,QAAAC,CAAA,CAAA,0BAGCF,EAAAH,CAAA,EAAAI,SAGD,QAAA,KAAA,IAAA,MAAA,kBAAAC,CAAA,sBAAA,CAAA,EAEF,EAmBC,oBAZD,CAAAL,EAAAG,IAAA,CAEC,GAAA,CAAAA,EAAA,IAAgB,gDAKf,aAAA,QAAAE,EAAA,KAAA,UAAAF,EAAAH,CAAA,CAAA,CAAA,CAAsE,EAAA,CAAA,UAAA,EAAA,CAAA,CAExE,GC3COM,EAAA,OAAA,EAKMC,EAAA,CAAAC,EAAAC,IAAA,CACZ,MAAAC,EAAAP,EAAA,YAAAG,EAAA,IAAA,CACC,MAAAK,EAAAC,EAAA,SAAA,IAAAJ,EAAA,iBAAAK,EAAA,KAAA,MAAA,QAAA,8BAEAC,EAAAF,EAAA,IAAA,EAAA,kBAGAG,EAAAH,EAAA,IAAA,EAAA,EAEA,MAAA,CAAO,gBAAAD,EACN,QAAAK,EACA,QAAAF,mB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AP,EAAA,IAAAU,CAAA,GAAA,KAEAH,EAAA,MAAA,CACChC,EAAA,eAAAmC,EAEA,QAKF,GAAA,CAAAH,EAAA,MAAA,CACChC,EAAA,eAAAyB,EAAA,KAAA,EAAA,KAAA,EAAA,MAEA,2CAKAW,EAAA,MAAA,GAEA,cAGcC,EAAA,QAAArC,EAAA,IAAAA,EAAA,eAAA,EAAA,EAGfoC,EAAA,MAAA,GAOA,MAAAd,EAAAU,EAAA,MAAA,UAAA,IAAAE,IAAAD,CAAA,EAGAC,IAAAD,0NAUD,CAAA,UAAA,EAAA,CACkB,EAGnB,MAAAK,EAAA7B,EAAA,IAAA,gCAIC8B,EAAA,IAAA,eAAA,IAAA,wGACkH,CAAA,oBAGhF,CAAA,qBAIlCA,EAAA,WAAA,CAA0B,CAAA,woECzI3B,MAAAlC,EAAAW,wCAaAwB,EAAA3B,GAAA,CACC,SAAA,gBAAA,UAAA,OAAA,yBAAAA,CAAA,CAA2E,aAGzD2B,EAAA,EAAA,gCAGCA,EAAA,EAAA,SAEJH,EAAA,QAAArC,EAAA,IAAAA,EAAA,eAAA,EAAA,CAA6C,CAAA,EAG7D,MAAAyC,EAAAhC,EAAA,IAAA,EACA2B,EAAA3B,EAAA,IAAA,EAAA,gEAG0D,EAAA,CAAA,UAAA,EAAA,CAAA,wvCCjCzD,SAAAiC,EAAAC,EAAAC,EAAA,+MCGD,MAAA5C,EAAAe,EAAA"}
|
|
1
|
+
{"version":3,"file":"tabsView.amd.js","sources":["../../src/core/utils/store/localStorage.ts","../../src/components/tabsView/tabsView/store.ts","../../src/components/tabsView/tabsView/menuItem.vue","../../src/components/tabsView/tabsView/utils.ts","../../src/components/tabsView/tabsView/menu.vue","../../src/components/tabsView/tabsView/tabsView.vue","../../src/components/tabsView/tabsView/menuDelimeter.vue","../../src/components/tabsView/tabsView/menuTitle.vue"],"sourcesContent":["import { watch } from 'vue';\nimport type { Store } from './store';\n\n/**\n * Сгенерировать имя для сохранения данных в localStorage\n * @param stateName - имя свойства состояния\n * @param stateKey - ключ состояния, разные компоненты могут использовать одинаковый ключ\n */\nconst genStorageKey = <T extends Store>(stateName: keyof T, stateKey: string): string => {\n\tconst stateNameString = String(stateName);\n\n\treturn `top:${stateNameString}:${stateKey}`;\n};\n\n/**\n * Загрузить состояние\n * @param stateName - имя свойства состояния\n * @param store\n */\nconst loadLocalStorge = <T extends Store>(stateName: keyof T, store: T) => {\n\t// если Store.key не знадан, значит сохранение состояния в компоненте отключено\n\tif (!store.$id) return;\n\n\tconst localStorageKey = genStorageKey(stateName, store.$id);\n\n\ttry {\n\t\tconst localStorageValue: typeof store[keyof typeof store] = JSON.parse(localStorage.getItem(localStorageKey) as string);\n\n\t\tif (typeof localStorageValue === typeof store[stateName]) {\n\t\t\tstore[stateName] = localStorageValue;\n\t\t}\n\t} catch (e) {\n\t\tconsole.warn(new Error(`В localStorage[${localStorageKey}] не корректный json`));\n\t}\n};\n\n/**\n * Добавить автосохранение состояние при его изменении\n * @param stateName - имя свойства состояния\n * @param store\n */\nconst addSaverLocalStorge = <T extends Store>(stateName: keyof T, store: T) => {\n\t// если store.$id не знадан, значит сохранение состояния в компоненте отключено\n\tif (!store.$id) return;\n\n\tconst localStorageKey = genStorageKey(stateName, store.$id);\n\n\twatch(() => store[stateName], () => {\n\t\tlocalStorage.setItem(localStorageKey, JSON.stringify(store[stateName]));\n\t}, { immediate: true });\n};\n\nexport default {\n\tloadLocalStorge,\n\taddSaverLocalStorge,\n};","import type { ModelRef, InjectionKey } from 'vue';\nimport { ref, computed } from 'vue';\nimport Core from '@/core/core/core';\nimport { defineStore, useStore } from '@/core/utils/store';\nimport StoreLocalStorage from '@/core/utils/store/localStorage';\nimport type { Props, Store } from './tabsView';\n\nexport const injectionKey = Symbol() as InjectionKey<Store>;\n\n/**\n * Инициировать Store компонента\n */\nexport const defineTabsStore = (props: Props, model: ModelRef<string | undefined>) => {\n\tconst store = defineStore(injectionKey, () => {\n\t\tconst showMenuInPopup = computed(() => props.showMenuInPopup ?? Core.state.isMobile);\n\t\tconst pageMod = computed(() => props.pageMod);\n\t\tconst isShort = ref(false);\n\n\t\tconst component = ref(undefined);\n\t\tconst scrollable = ref(true);\n\n\t\treturn {\n\t\t\tshowMenuInPopup,\n\t\t\tpageMod,\n\t\t\tisShort,\n\t\t\tactiveItemName: model,\n\t\t\tcomponent,\n\t\t\tscrollable,\n\t\t};\n\t}, props.idState);\n\n\tif (props.isShortable) {\n\t\tconst stateName = 'isShort';\n\n\t\tStoreLocalStorage.loadLocalStorge(stateName, store);\n\t\tStoreLocalStorage.addSaverLocalStorge(stateName, store);\n\t}\n\n\treturn store;\n};\n\n/**\n * Получить Store компонента\n */\nexport const useTabsStore = () => useStore(injectionKey);","<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { genHash } from '@/core/utils/route';\nimport { PopupListItem } from '@/components/popup/popup';\nimport { useTabsStore } from './store';\nimport type { PropsMenuItem } from './tabsView';\n\nconst props = withDefaults(defineProps<PropsMenuItem>(), {\n\tscrollable: true,\n\tcomponent: undefined,\n});\n\nconst store = useTabsStore();\n\nconst href = computed(() => {\n\t// это внутренняя хеш навигация, ссылка на вкладку\n\tif (props.name && store.$id) {\n\t\treturn genHash(store.$id, props.name);\n\t}\n\n\treturn props.href;\n});\n\nconst tagName = computed(() => {\n\tif (store.showMenuInPopup) {\n\t\treturn PopupListItem;\n\t}\n\n\treturn href ? 'a' : 'button';\n});\n\n/**\n * Клик по элементу меню\n */\nconst onClick = (e: MouseEvent) => {\n\t// это внутренняя хеш навигация, ссылка на вкладку\n\tif (!props.href && href.value) {\n\t\te.preventDefault();\n\t}\n\n\tif (props.name) {\n\t\tstore.activeItemName = props.name;\n\t}\n};\n</script>\n\n<template>\n\t<component\n\t\t:is=\"tagName\"\n\t\ttarget=\"_self\"\n\t\t:class=\"{\n\t\t\t['top-tabsView_menuItem']: !store.showMenuInPopup,\n\t\t\t['top-active']: name && store.activeItemName === name,\n\t\t\t['top-disabled']: disabled,\n\t\t\t['top-spa-disabled']: true,\n\t\t}\"\n\t\t:href=\"href\"\n\t\t:data-top-icon=\"icon || undefined\"\n\t\t:disabled=\"disabled || undefined\"\n\t\t@click=\"onClick\"\n\t>\n\t\t<slot v-if=\"store.showMenuInPopup\"></slot>\n\n\t\t<span\n\t\t\tv-else-if=\"$slots.default && !store.isShort\"\n\t\t\tclass=\"top-ellipsis\"\n\t\t>\n\t\t\t<slot></slot>\n\t\t</span>\n\t</component>\n</template>\n\n<style module>\n.top-tabsView_menuItem {\n\t--top-icon-color: var(--color-text-1);\n\t--top-icon-width: calc(var(--top-icon-size));\n\n\tcursor: pointer;\n\tbox-sizing: border-box;\n\n\tborder: none;\n\tborder-radius: var(--top-radius-2);\n\tpadding: var(--top-padding-2);\n\tbackground: transparent;\n\theight: 40px;\n\n\tcolor: var(--color-text-1);\n\ttext-decoration: none;\n\twhite-space: nowrap;\n\n\tdisplay: flex;\n\tgap: var(--top-gap-2);\n\talign-items: center;\n\tjustify-content: flex-start;\n\ttransition: background var(--transition);\n}\n\n.top-tabsView_menuItem:hover {\n\tbackground: var(--color-secondary-2-opacity);\n\ttext-decoration: none;\n}\n\n.top-tabsView_menuItem.top-active {\n\tcursor: unset;\n\tbackground: var(--color-bg-3);\n}\n\n.top-tabsView_menuItem:disabled:not(option):not(optgroup):not(.top-forms-option),\n.top-tabsView_menuItem:disabled ~ .top-formsCaption,\n.top-tabsView_menuItem.top-disabled[data-top-icon]:before,\n.top-tabsView_menuItem.top-disabled[data-top-icon2]:after {\n\topacity: unset;\n\tfilter: unset;\n}\n\n.top-tabsView_menuItem.top-disabled {\n\t--top-icon-color: var(--color-text-4);\n\n\tcolor: var(--color-text-4);\n}\n</style>","// TODO: Эту функцию можно вынести в глобальный utils\n\nimport { sleepWhile } from '@/core/utils/system';\n\n/**\n * Проверка нахождения компонента в состояние загрузки\n * @param component\n */\nexport const checkComponentIsLoading = (component: any) => {\n\treturn component?.name === 'AsyncComponentWrapper' && !component?.__asyncResolved;\n};\n\n/**\n * Презагрузить компонент\n *\n * Некоторое время ожидает загрузку компонента, прежде чем завершит работу\n */\nexport const preResolveComponent = async (component: any, condition: Function) => {\n\tif(component?.name !== 'AsyncComponentWrapper') return;\n\tif(component?.__asyncResolved) return;\n\n\tcomponent.__asyncLoader();\n\n\tawait sleepWhile(() => {\n\t\treturn condition() && checkComponentIsLoading(component);\n\t}, 200);\n};","<script setup lang=\"ts\">\nimport { ref, watch, markRaw, useSlots, onMounted, onUnmounted } from 'vue';\nimport type { Ref, Component } from 'vue';\nimport { Popup } from '../../popup/popup';\nimport { sleepWhile } from '@/core/utils/system';\nimport { getHash, setHash } from '@/core/utils/route';\n\nimport type { PropsMenu, PropsMenuItem, MenuItem } from './tabsView';\nimport { useTabsStore } from './store';\nimport TabsViewMenuItem from './menuItem.vue';\nimport { preResolveComponent } from './utils';\n\ndefineProps<PropsMenu>();\n\nconst isLoading = defineModel('isLoading');\n\nconst store = useTabsStore();\n\nconst slots = useSlots();\n\n// словарь используется для оптимизации получения нужного menuItem\nconst menuItemByName: Map<PropsMenuItem['name'], MenuItem> = new Map();\n\n// сгенерировать словарь с menuItem, по элементам в slot\nconst genMenuItemByName = () => {\n\tif (!slots.default) return;\n\n\tconst component: any = slots.default().find(item => item.key === '_menu');\n\tif (!component) return;\n\n\tcomponent.children.forEach((subComponent: any) => {\n\t\tif (subComponent.type.__name !== TabsViewMenuItem.__name) return;\n\t\tif (!subComponent.props.name || subComponent.props.disabled) return;\n\n\t\tconst menuItem: MenuItem = {\n\t\t\ttitle: (subComponent.children.default?.()[0].children as string).trim(),\n\t\t\ticon: subComponent.props.icon,\n\t\t\tcomponent: subComponent.props.component ? markRaw(subComponent.props.component) : TabsViewMenuItem.props.component.default,\n\t\t\tscrollable: subComponent.props.scrollable ?? TabsViewMenuItem.props.scrollable.default,\n\t\t};\n\n\t\tmenuItemByName.set(subComponent.props.name, menuItem);\n\t});\n};\n\n/**\n * activeMenuItem нужен:\n * - для вывода текста активной вкладки в меню с popup\n * - для вывода компонента активной вкладки (store.component)\n * - для установки store.scrollable\n */\nconst activeMenuItem: Ref<MenuItem | null> = ref(null);\n\n/**\n * Кол-во изменений активной вкладки\n */\nlet countChanged = 0;\n\n/**\n * Смена активной вкладки\n *\n * TODO: смена slot, например смена языка, требует повторного выполнения genMenuItemByName()\n */\nwatch(\n\t() => store.activeItemName,\n\tasync () => {\n\t\tconst numberChanged = ++countChanged; // порядковый номер текущего изменения\n\n\t\tif (menuItemByName.size === 0) {\n\t\t\tgenMenuItemByName();\n\t\t}\n\n\t\tif (menuItemByName.size === 0) {\n\t\t\tstore.activeItemName = '';\n\n\t\t\treturn;\n\t\t}\n\n\t\tactiveMenuItem.value = menuItemByName.get(store.activeItemName) ?? null;\n\n\t\t// элемент не найден, установить из хеша страницы\n\t\tif (!activeMenuItem.value && store.$id) {\n\t\t\tconst activeItemName = getHash(store.$id);\n\n\t\t\tactiveMenuItem.value = menuItemByName.get(activeItemName) ?? null;\n\n\t\t\tif (activeMenuItem.value) {\n\t\t\t\tstore.activeItemName = activeItemName;\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// элемент не найден, установить первый доступный\n\t\tif (!activeMenuItem.value) {\n\t\t\tstore.activeItemName = menuItemByName.keys().next().value;\n\n\t\t\treturn;\n\t\t}\n\n\t\t// запрошена смена на уже активный элемент\n\t\tif (activeMenuItem.value.component === store.component) {\n\t\t\tisLoading.value = false;\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (store.$id) setHash(store.$id, store.activeItemName, true);\n\n\t\t// флаг загрузки будет сброшен при инициализации компонента\n\t\tisLoading.value = true;\n\n\t\t/**\n\t\t * Презагрузить компонент\n\t\t *\n\t\t * Нужно для того, чтобы минимизировать скачки интерфейса при ожидании загрузки асинхронного компонента\n\t\t */\n\t\tawait preResolveComponent(activeMenuItem.value.component, () => numberChanged === countChanged);\n\n\t\t// влкадка была сменена еще раз во время sleepWhile\n\t\tif (numberChanged !== countChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tstore.scrollable = activeMenuItem.value.scrollable;\n\t\tstore.component = activeMenuItem.value.component;\n\n\t\tif (activeMenuItem.value && !store.component) {\n\t\t\tconsole.warn(`Компонент вкладки ${store.activeItemName} не найден. Добавьте props.component для пункта меню ${store.activeItemName}.`);\n\t\t}\n\t},\n\t{ immediate: true },\n);\n\nconst elRef = ref();\nlet resizeObserver: ResizeObserver;\n\nonMounted(() => {\n\tresizeObserver = new ResizeObserver(() => {\n\t\telRef.value.parentElement.style.setProperty('--top-tabsView-contents-offset-top', elRef.value.offsetHeight + 'px');\n\t});\n\n\tresizeObserver.observe(elRef.value);\n});\n\nonUnmounted(() => {\n\tresizeObserver.disconnect();\n});\n</script>\n\n<template>\n\t<div\n\t\tref=\"elRef\"\n\t\t:class=\"{\n\t\t\t'top-tabsView_menu': true,\n\t\t\t'top-tabsView_menu-inPopup_0': !store.showMenuInPopup,\n\t\t\t'top-tabsView_menu-inPopup_1': store.showMenuInPopup,\n\t\t\t'top-tabsView_menu-short': store.isShort && !store.showMenuInPopup,\n\t\t}\"\n\t>\n\t\t<!-- Спрятать меню под кнопку в popup -->\n\t\t<Popup v-if=\"store.showMenuInPopup\">\n\t\t\t<template #opener>\n\t\t\t\t<div class=\"top-tabsView_menuOpener\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tv-if=\"activeMenuItem\"\n\t\t\t\t\t\tclass=\"top-tabsView_menuOpenerActiveItem\"\n\t\t\t\t\t\t:data-top-icon=\"activeMenuItem.icon\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"top-ellipsis\">\n\t\t\t\t\t\t\t{{ activeMenuItem.title }}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div class=\"top-tabsView_menuOpenerIcon\" data-top-icon=\"\"></div>\n\t\t\t\t</div>\n\t\t\t</template>\n\n\t\t\t<template #contentList>\n\t\t\t\t<slot></slot>\n\t\t\t</template>\n\t\t</Popup>\n\n\t\t<!-- Отобразить меню на странице -->\n\t\t<template v-else>\n\t\t\t<div class=\"top-tabsView_menuList\">\n\t\t\t\t<slot></slot>\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tv-if=\"isShortable\"\n\t\t\t\tclass=\"top-tabsView_menuFooter\"\n\t\t\t>\n\t\t\t\t<TabsViewMenuItem\n\t\t\t\t\tv-if=\"isShortable\"\n\t\t\t\t\t:icon=\"store.isShort ? '' : ''\"\n\t\t\t\t\t@click=\"store.isShort = !store.isShort\"\n\t\t\t\t>\n\t\t\t\t\t{{ store.isShort ? '' : 'Свернуть' }} <!--TODO: translate-->\n\t\t\t\t</TabsViewMenuItem>\n\t\t\t</div>\n\t\t</template>\n\t</div>\n</template>\n\n<style module>\n/* режим отображение табов в основной области документа */\n.top-tabsView-pageMod .top-tabsView_menu {\n\tbox-sizing: border-box;\n\tposition: sticky;\n\ttop: var(--top-tabsView-top);\n\tz-index: 10;\n}\n\n/* режим отображение табов в основной области документа без popup */\n.top-tabsView-pageMod .top-tabsView_menu-inPopup_0 {\n\theight: calc(var(--100vh) - var(--top-tabsView-top));\n}\n\n/* стантартный режим */\n.top-tabsView_menu-inPopup_0 {\n\tbox-sizing: border-box;\n\twidth: var(--top-tabsView-menu-width);\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-between;\n}\n\n/* режим вывода в popup */\n.top-tabsView_menu-inPopup_1 {\n\tborder-bottom: 1px solid var(--color-line-2-opacity);\n}\n\n.top-tabsView_menu-short {\n\twidth: auto;\n}\n\n.top-tabsView_menu > .top-tabsView_menuOpener {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n}\n\n.top-tabsView_menu > .top-tabsView_menuOpener:hover {\n\tbackground: var(--color-secondary-opacity);\n}\n\n.top-tabsView_menuOpenerIcon { display: flex; }\n\n.top-tabsView_menuOpenerActiveItem {\n\t--top-forms-padding: 0px;\n\n\tbox-sizing: border-box;\n\tpadding: var(--top-padding-2);\n\tmax-width: calc(100% - var(--top-forms-base-height));\n\twhite-space: nowrap;\n\tflex-grow: 1;\n\tdisplay: flex;\n\talign-items: center;\n\tgap: var(--top-padding-2);\n}\n\n.top-tabsView_menuList,\n.top-tabsView_menuFooter {\n\tpadding: var(--top-padding-2);\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: var(--top-gap-2);\n}\n\n.top-tabsView_menuList {\n\toverflow-y: auto;\n}\n\n.top-tabsView_menu-short .top-tabsView_menuFooter > .top-tabsView_menuItem {\n\t--top-icon-width: 100%;\n}\n</style>","<script setup lang=\"ts\">\nimport { defineModel, onUnmounted, ref, watch } from 'vue';\nimport { delHash } from '@/core/utils/route';\nimport type { Props } from './tabsView';\nimport { defineTabsStore } from './store';\nimport TabsViewMenu from './menu.vue';\nimport { Loadbar } from '@/components/forms/forms';\nimport { checkComponentIsLoading } from './utils';\n\nconst props = withDefaults(defineProps<Props>(), {\n\tshowMenuInPopup: undefined,\n\tisShortable: false,\n});\n\nconst model = defineModel<string>();\n\nconst store = defineTabsStore(props, model);\n\n/**\n * Установка или снятие глобального модификатора\n * @see props.pageMod\n */\nconst setDocumentPageModModificator = (pageMod: boolean) => {\n\tdocument.documentElement.classList.toggle('top-hasTabsViewPageMod', pageMod);\n};\n\nif (props.pageMod) setDocumentPageModModificator(true);\n\nonUnmounted(() => {\n\tif (props.pageMod) setDocumentPageModModificator(false);\n\n\tif (store.$id) delHash(store.$id, store.activeItemName, true);\n});\n\nconst componentRef = ref();\nconst isLoading = ref(false);\n\nwatch([componentRef, () => store.component], () => {\n\tisLoading.value = checkComponentIsLoading(store.component);\n}, { immediate: true });\n</script>\n\n<template>\n\t<div\n\t\t:class=\"{\n\t\t\t'top-tabsView': true,\n\t\t\t'top-tabsView-pageMod': props.pageMod,\n\t\t\t'top-tabsView-inPopup': store.showMenuInPopup,\n\t\t}\"\n\t>\n\t\t<TabsViewMenu\n\t\t\t:isShortable=\"isShortable\"\n\t\t\tv-model:isLoading=\"isLoading\"\n\t\t>\n\t\t\t<!-- @slot Меню, ожидает передачу компонентов TabsViewMenuItem и TabsViewMenuTitle -->\n\t\t\t<slot name=\"menu\"></slot>\n\t\t</TabsViewMenu>\n\n\t\t<div\n\t\t\t:class=\"{\n\t\t\t\t'top-tabsView_contents': true,\n\t\t\t\t'top-tabsView_contents-isLoading': isLoading,\n\t\t\t\t'top-tabsView_contents-noScrollable': !store.scrollable,\n\t\t\t}\"\n\t\t>\n\t\t\t<Loadbar v-if=\"isLoading\"/>\n\t\t\t<keep-alive>\n\t\t\t\t<component\n\t\t\t\t\tref=\"componentRef\"\n\t\t\t\t\t:is=\"store.component\"\n\t\t\t\t/>\n\t\t\t</keep-alive>\n\t\t</div>\n\t</div>\n</template>\n\n<style module>\n:root {\n\t--top-tabsView-top: 0px;\n\t--top-tabsView-menu-width: 220px;\n\t--top-tabsView-contents-offset-top: 0px;\n}\n\n.top-tabsView {\n\tbackground: var(--color-bg-2);\n\twidth: 100%;\n\theight: 100%;\n\tdisplay: flex;\n\tflex-direction: row;\n}\n\n.top-tabsView_contents {\n\tborder-radius: var(--top-radius-4);\n\tbackground: var(--color-bg-3);\n\tpadding: var(--top-padding-4);\n\tflex-grow: 1;\n\toverflow: auto;\n\tposition: relative;\n}\n\n.top-tabsView_contents-isLoading {\n\tpointer-events: none;\n}\n\n.top-tabsView_contents-noScrollable {\n\twidth: calc(100% - var(--top-tabsView-menu-width));\n\tpadding: 0;\n\toverflow: visible;\n}\n\n/* top-tabsView-inPopup */\n.top-tabsView-inPopup {\n\tbackground: var(--color-bg-3);\n\tflex-direction: column;\n}\n\n.top-tabsView-inPopup > .top-tabsView_contents {\n\tborder-radius: 0;\n}\n\n.top-tabsView-inPopup > .top-tabsView_contents-noScrollable {\n\twidth: auto;\n}\n</style>","<script setup lang=\"ts\">\n\n</script>\n\n<template>\n\t<div class=\"top-tabsView_menuDelimeter\"></div>\n</template>\n\n<style module>\n.top-tabsView_menuDelimeter {\n\tpadding: var(--top-padding-1) 0;\n\tdisplay: flex;\n}\n\n.top-tabsView_menuDelimeter:before {\n\tcontent: \"\";\n\theight: 2px;\n\tbackground: var(--color-line-2-opacity);\n\tflex-grow: 1;\n}\n\n.top-tabsView_menuDelimeter:first-child,\n.top-tabsView_menuDelimeter + .top-tabsView_menuDelimeter {\n\tdisplay: none;\n}\n</style>","<script setup lang=\"ts\">\nimport { useTabsStore } from './store';\nimport type { PropsMenuTitle } from './tabsView';\nimport TabsViewMenuDelimeter from './menuDelimeter.vue';\nimport { PopupListItem } from '../../popup/popup';\n\ndefineProps<PropsMenuTitle>();\n\nconst store = useTabsStore();\n</script>\n\n<template>\n\t<PopupListItem\n\t\tv-if=\"store.showMenuInPopup\"\n\t\ttype=\"title\"\n\t>\n\t\t<slot></slot>\n\t</PopupListItem>\n\n\t<TabsViewMenuDelimeter v-else-if=\"store.isShort\"/>\n\n\t<div\n\t\tv-else\n\t\t:class=\"{\n\t\t\t'top-tabsView_menuTitle': true,\n\t\t\t'top-tabsView_menuTitle-subtitle': isSubtitle,\n\t\t}\"\n\t>\n\t\t<slot></slot>\n\t</div>\n</template>\n\n<style module>\n.top-tabsView_menuTitle {\n\tpadding: var(--top-padding-4) var(--top-padding-2) var(--top-padding-1);\n\tfont-weight: 600;\n}\n\n.top-tabsView_menuTitle-subtitle {\n\tpadding-top: var(--top-padding-1);\n\tfont-size: 12px;\n\tfont-weight: 400;\n\tcolor: var(--color-text-2);\n}\n</style>"],"names":["genStorageKey","stateName","stateKey","StoreLocalStorage","store","localStorageValue","localStorageKey","injectionKey","defineTabsStore","props","model","store$1","showMenuInPopup","vue","forms","isShort","scrollable","pageMod","component","useTabsStore","__props","href","tagName","onClick","e","checkComponentIsLoading","preResolveComponent","condition","slots","menuItemByName","item","subComponent","_b","_a","TabsViewMenuItem","menuItem","activeMenuItem","countChanged","numberChanged","activeItemName","isLoading","utils_route","elRef","resizeObserver","setDocumentPageModModificator","componentRef","_sfc_render","_ctx","_cache"],"mappings":"mWAQA,MAAAA,EAAA,CAAAC,EAAAC,WACC,OAAAD,CAAA,SA2CDE,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AaAwB,EAAA3B,GAAA,CACC,SAAA,gBAAA,UAAA,OAAA,yBAAAA,CAAA,CAA2E,aAGzD2B,EAAA,EAAA,gCAGCA,EAAA,EAAA,SAEJH,EAAA,QAAArC,EAAA,IAAAA,EAAA,eAAA,EAAA,CAA6C,CAAA,EAG7D,MAAAyC,EAAAhC,EAAA,IAAA,EACA2B,EAAA3B,EAAA,IAAA,EAAA,gEAG0D,EAAA,CAAA,UAAA,EAAA,CAAA,wvCCjCzD,SAAAiC,EAAAC,EAAAC,EAAA,+MCGD,MAAA5C,EAAAe,EAAA"}
|
package/tabsView/tabsView.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { insertToPage as K } from "../utils/css.js";
|
|
2
2
|
import { watch as I, computed as M, ref as b, defineComponent as $, openBlock as l, createBlock as d, resolveDynamicComponent as O, normalizeClass as g, unref as n, withCtx as w, renderSlot as f, createElementBlock as m, createCommentVNode as v, mergeModels as C, useModel as R, useSlots as U, onMounted as W, onUnmounted as D, createElementVNode as h, toDisplayString as T, Fragment as j, createTextVNode as J, markRaw as q, createVNode as G, KeepAlive as Q } from "vue";
|
|
3
3
|
import { genHash as X, getHash as Y, setHash as Z, delHash as x } from "../utils/route.js";
|
|
4
|
-
import { C as ee, a as y, L as te } from "../.chunks/forms-
|
|
4
|
+
import { C as ee, a as y, L as te } from "../.chunks/forms-C4UtO06K.es.js";
|
|
5
5
|
import { d as oe, u as se } from "../.chunks/store-PoMCiuBr.es.js";
|
|
6
|
-
import { b as A, _ as ae } from "../.chunks/listItem.vue_vue_type_script_setup_true_lang-
|
|
6
|
+
import { b as A, _ as ae } from "../.chunks/listItem.vue_vue_type_script_setup_true_lang-CHYNz0kA.es.js";
|
|
7
7
|
import "../popup/worker.js";
|
|
8
8
|
import { sleepWhile as ne } from "../utils/system.js";
|
|
9
9
|
const F = ["../assets/tabsView.css"].map((t) => import.meta.resolve(t));
|
package/tabsView/tabsView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabsView.js","sources":["../../src/core/utils/store/localStorage.ts","../../src/components/tabsView/tabsView/store.ts","../../src/components/tabsView/tabsView/menuItem.vue","../../src/components/tabsView/tabsView/utils.ts","../../src/components/tabsView/tabsView/menu.vue","../../src/components/tabsView/tabsView/tabsView.vue","../../src/components/tabsView/tabsView/menuDelimeter.vue","../../src/components/tabsView/tabsView/menuTitle.vue"],"sourcesContent":["import { watch } from 'vue';\r\nimport type { Store } from './store';\r\n\r\n/**\r\n * Сгенерировать имя для сохранения данных в localStorage\r\n * @param stateName - имя свойства состояния\r\n * @param stateKey - ключ состояния, разные компоненты могут использовать одинаковый ключ\r\n */\r\nconst genStorageKey = <T extends Store>(stateName: keyof T, stateKey: string): string => {\r\n\tconst stateNameString = String(stateName);\r\n\r\n\treturn `top:${stateNameString}:${stateKey}`;\r\n};\r\n\r\n/**\r\n * Загрузить состояние\r\n * @param stateName - имя свойства состояния\r\n * @param store\r\n */\r\nconst loadLocalStorge = <T extends Store>(stateName: keyof T, store: T) => {\r\n\t// если Store.key не знадан, значит сохранение состояния в компоненте отключено\r\n\tif (!store.$id) return;\r\n\r\n\tconst localStorageKey = genStorageKey(stateName, store.$id);\r\n\r\n\ttry {\r\n\t\tconst localStorageValue: typeof store[keyof typeof store] = JSON.parse(localStorage.getItem(localStorageKey) as string);\r\n\r\n\t\tif (typeof localStorageValue === typeof store[stateName]) {\r\n\t\t\tstore[stateName] = localStorageValue;\r\n\t\t}\r\n\t} catch (e) {\r\n\t\tconsole.warn(new Error(`В localStorage[${localStorageKey}] не корректный json`));\r\n\t}\r\n};\r\n\r\n/**\r\n * Добавить автосохранение состояние при его изменении\r\n * @param stateName - имя свойства состояния\r\n * @param store\r\n */\r\nconst addSaverLocalStorge = <T extends Store>(stateName: keyof T, store: T) => {\r\n\t// если store.$id не знадан, значит сохранение состояния в компоненте отключено\r\n\tif (!store.$id) return;\r\n\r\n\tconst localStorageKey = genStorageKey(stateName, store.$id);\r\n\r\n\twatch(() => store[stateName], () => {\r\n\t\tlocalStorage.setItem(localStorageKey, JSON.stringify(store[stateName]));\r\n\t}, { immediate: true });\r\n};\r\n\r\nexport default {\r\n\tloadLocalStorge,\r\n\taddSaverLocalStorge,\r\n};","import type { ModelRef, InjectionKey } from 'vue';\r\nimport { ref, computed } from 'vue';\r\nimport Core from '@/core/core/core';\r\nimport { defineStore, useStore } from '@/core/utils/store';\r\nimport StoreLocalStorage from '@/core/utils/store/localStorage';\r\nimport type { Props, Store } from './tabsView';\r\n\r\nexport const injectionKey = Symbol() as InjectionKey<Store>;\r\n\r\n/**\r\n * Инициировать Store компонента\r\n */\r\nexport const defineTabsStore = (props: Props, model: ModelRef<string | undefined>) => {\r\n\tconst store = defineStore(injectionKey, () => {\r\n\t\tconst showMenuInPopup = computed(() => props.showMenuInPopup ?? Core.state.isMobile);\r\n\t\tconst pageMod = computed(() => props.pageMod);\r\n\t\tconst isShort = ref(false);\r\n\r\n\t\tconst component = ref(undefined);\r\n\t\tconst scrollable = ref(true);\r\n\r\n\t\treturn {\r\n\t\t\tshowMenuInPopup,\r\n\t\t\tpageMod,\r\n\t\t\tisShort,\r\n\t\t\tactiveItemName: model,\r\n\t\t\tcomponent,\r\n\t\t\tscrollable,\r\n\t\t};\r\n\t}, props.idState);\r\n\r\n\tif (props.isShortable) {\r\n\t\tconst stateName = 'isShort';\r\n\r\n\t\tStoreLocalStorage.loadLocalStorge(stateName, store);\r\n\t\tStoreLocalStorage.addSaverLocalStorge(stateName, store);\r\n\t}\r\n\r\n\treturn store;\r\n};\r\n\r\n/**\r\n * Получить Store компонента\r\n */\r\nexport const useTabsStore = () => useStore(injectionKey);","<script setup lang=\"ts\">\r\nimport { computed } from 'vue';\r\nimport { genHash } from '@/core/utils/route';\r\nimport { PopupListItem } from '@/components/popup/popup';\r\nimport { useTabsStore } from './store';\r\nimport type { PropsMenuItem } from './tabsView';\r\n\r\nconst props = withDefaults(defineProps<PropsMenuItem>(), {\r\n\tscrollable: true,\r\n\tcomponent: undefined,\r\n});\r\n\r\nconst store = useTabsStore();\r\n\r\nconst href = computed(() => {\r\n\t// это внутренняя хеш навигация, ссылка на вкладку\r\n\tif (props.name && store.$id) {\r\n\t\treturn genHash(store.$id, props.name);\r\n\t}\r\n\r\n\treturn props.href;\r\n});\r\n\r\nconst tagName = computed(() => {\r\n\tif (store.showMenuInPopup) {\r\n\t\treturn PopupListItem;\r\n\t}\r\n\r\n\treturn href ? 'a' : 'button';\r\n});\r\n\r\n/**\r\n * Клик по элементу меню\r\n */\r\nconst onClick = (e: MouseEvent) => {\r\n\t// это внутренняя хеш навигация, ссылка на вкладку\r\n\tif (!props.href && href.value) {\r\n\t\te.preventDefault();\r\n\t}\r\n\r\n\tif (props.name) {\r\n\t\tstore.activeItemName = props.name;\r\n\t}\r\n};\r\n</script>\r\n\r\n<template>\r\n\t<component\r\n\t\t:is=\"tagName\"\r\n\t\ttarget=\"_self\"\r\n\t\t:class=\"{\r\n\t\t\t['top-tabsView_menuItem']: !store.showMenuInPopup,\r\n\t\t\t['top-active']: name && store.activeItemName === name,\r\n\t\t\t['top-disabled']: disabled,\r\n\t\t\t['top-spa-disabled']: true,\r\n\t\t}\"\r\n\t\t:href=\"href\"\r\n\t\t:data-top-icon=\"icon || undefined\"\r\n\t\t:disabled=\"disabled || undefined\"\r\n\t\t@click=\"onClick\"\r\n\t>\r\n\t\t<slot v-if=\"store.showMenuInPopup\"></slot>\r\n\r\n\t\t<span\r\n\t\t\tv-else-if=\"$slots.default && !store.isShort\"\r\n\t\t\tclass=\"top-ellipsis\"\r\n\t\t>\r\n\t\t\t<slot></slot>\r\n\t\t</span>\r\n\t</component>\r\n</template>\r\n\r\n<style module>\r\n.top-tabsView_menuItem {\r\n\t--top-icon-color: var(--color-text-1);\r\n\t--top-icon-width: calc(var(--top-icon-size));\r\n\r\n\tcursor: pointer;\r\n\tbox-sizing: border-box;\r\n\r\n\tborder: none;\r\n\tborder-radius: var(--top-radius-2);\r\n\tpadding: var(--top-padding-2);\r\n\tbackground: transparent;\r\n\theight: 40px;\r\n\r\n\tcolor: var(--color-text-1);\r\n\ttext-decoration: none;\r\n\twhite-space: nowrap;\r\n\r\n\tdisplay: flex;\r\n\tgap: var(--top-gap-2);\r\n\talign-items: center;\r\n\tjustify-content: flex-start;\r\n\ttransition: background var(--transition);\r\n}\r\n\r\n.top-tabsView_menuItem:hover {\r\n\tbackground: var(--color-secondary-2-opacity);\r\n\ttext-decoration: none;\r\n}\r\n\r\n.top-tabsView_menuItem.top-active {\r\n\tcursor: unset;\r\n\tbackground: var(--color-bg-3);\r\n}\r\n\r\n.top-tabsView_menuItem:disabled:not(option):not(optgroup):not(.top-forms-option),\r\n.top-tabsView_menuItem:disabled ~ .top-formsCaption,\r\n.top-tabsView_menuItem.top-disabled[data-top-icon]:before,\r\n.top-tabsView_menuItem.top-disabled[data-top-icon2]:after {\r\n\topacity: unset;\r\n\tfilter: unset;\r\n}\r\n\r\n.top-tabsView_menuItem.top-disabled {\r\n\t--top-icon-color: var(--color-text-4);\r\n\r\n\tcolor: var(--color-text-4);\r\n}\r\n</style>","// TODO: Эту функцию можно вынести в глобальный utils\r\n\r\nimport { sleepWhile } from '@/core/utils/system';\r\n\r\n/**\r\n * Проверка нахождения компонента в состояние загрузки\r\n * @param component\r\n */\r\nexport const checkComponentIsLoading = (component: any) => {\r\n\treturn component?.name === 'AsyncComponentWrapper' && !component?.__asyncResolved;\r\n};\r\n\r\n/**\r\n * Презагрузить компонент\r\n *\r\n * Некоторое время ожидает загрузку компонента, прежде чем завершит работу\r\n */\r\nexport const preResolveComponent = async (component: any, condition: Function) => {\r\n\tif(component?.name !== 'AsyncComponentWrapper') return;\r\n\tif(component?.__asyncResolved) return;\r\n\r\n\tcomponent.__asyncLoader();\r\n\r\n\tawait sleepWhile(() => {\r\n\t\treturn condition() && checkComponentIsLoading(component);\r\n\t}, 200);\r\n};","<script setup lang=\"ts\">\r\nimport { ref, watch, markRaw, useSlots, onMounted, onUnmounted } from 'vue';\r\nimport type { Ref, Component } from 'vue';\r\nimport { Popup } from '../../popup/popup';\r\nimport { sleepWhile } from '@/core/utils/system';\r\nimport { getHash, setHash } from '@/core/utils/route';\r\n\r\nimport type { PropsMenu, PropsMenuItem, MenuItem } from './tabsView';\r\nimport { useTabsStore } from './store';\r\nimport TabsViewMenuItem from './menuItem.vue';\r\nimport { preResolveComponent } from './utils';\r\n\r\ndefineProps<PropsMenu>();\r\n\r\nconst isLoading = defineModel('isLoading');\r\n\r\nconst store = useTabsStore();\r\n\r\nconst slots = useSlots();\r\n\r\n// словарь используется для оптимизации получения нужного menuItem\r\nconst menuItemByName: Map<PropsMenuItem['name'], MenuItem> = new Map();\r\n\r\n// сгенерировать словарь с menuItem, по элементам в slot\r\nconst genMenuItemByName = () => {\r\n\tif (!slots.default) return;\r\n\r\n\tconst component: any = slots.default().find(item => item.key === '_menu');\r\n\tif (!component) return;\r\n\r\n\tcomponent.children.forEach((subComponent: any) => {\r\n\t\tif (subComponent.type.__name !== TabsViewMenuItem.__name) return;\r\n\t\tif (!subComponent.props.name || subComponent.props.disabled) return;\r\n\r\n\t\tconst menuItem: MenuItem = {\r\n\t\t\ttitle: (subComponent.children.default?.()[0].children as string).trim(),\r\n\t\t\ticon: subComponent.props.icon,\r\n\t\t\tcomponent: subComponent.props.component ? markRaw(subComponent.props.component) : TabsViewMenuItem.props.component.default,\r\n\t\t\tscrollable: subComponent.props.scrollable ?? TabsViewMenuItem.props.scrollable.default,\r\n\t\t};\r\n\r\n\t\tmenuItemByName.set(subComponent.props.name, menuItem);\r\n\t});\r\n};\r\n\r\n/**\r\n * activeMenuItem нужен:\r\n * - для вывода текста активной вкладки в меню с popup\r\n * - для вывода компонента активной вкладки (store.component)\r\n * - для установки store.scrollable\r\n */\r\nconst activeMenuItem: Ref<MenuItem | null> = ref(null);\r\n\r\n/**\r\n * Кол-во изменений активной вкладки\r\n */\r\nlet countChanged = 0;\r\n\r\n/**\r\n * Смена активной вкладки\r\n *\r\n * TODO: смена slot, например смена языка, требует повторного выполнения genMenuItemByName()\r\n */\r\nwatch(\r\n\t() => store.activeItemName,\r\n\tasync () => {\r\n\t\tconst numberChanged = ++countChanged; // порядковый номер текущего изменения\r\n\r\n\t\tif (menuItemByName.size === 0) {\r\n\t\t\tgenMenuItemByName();\r\n\t\t}\r\n\r\n\t\tif (menuItemByName.size === 0) {\r\n\t\t\tstore.activeItemName = '';\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tactiveMenuItem.value = menuItemByName.get(store.activeItemName) ?? null;\r\n\r\n\t\t// элемент не найден, установить из хеша страницы\r\n\t\tif (!activeMenuItem.value && store.$id) {\r\n\t\t\tconst activeItemName = getHash(store.$id);\r\n\r\n\t\t\tactiveMenuItem.value = menuItemByName.get(activeItemName) ?? null;\r\n\r\n\t\t\tif (activeMenuItem.value) {\r\n\t\t\t\tstore.activeItemName = activeItemName;\r\n\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// элемент не найден, установить первый доступный\r\n\t\tif (!activeMenuItem.value) {\r\n\t\t\tstore.activeItemName = menuItemByName.keys().next().value;\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// запрошена смена на уже активный элемент\r\n\t\tif (activeMenuItem.value.component === store.component) {\r\n\t\t\tisLoading.value = false;\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif (store.$id) setHash(store.$id, store.activeItemName, true);\r\n\r\n\t\t// флаг загрузки будет сброшен при инициализации компонента\r\n\t\tisLoading.value = true;\r\n\r\n\t\t/**\r\n\t\t * Презагрузить компонент\r\n\t\t *\r\n\t\t * Нужно для того, чтобы минимизировать скачки интерфейса при ожидании загрузки асинхронного компонента\r\n\t\t */\r\n\t\tawait preResolveComponent(activeMenuItem.value.component, () => numberChanged === countChanged);\r\n\r\n\t\t// влкадка была сменена еще раз во время sleepWhile\r\n\t\tif (numberChanged !== countChanged) {\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tstore.scrollable = activeMenuItem.value.scrollable;\r\n\t\tstore.component = activeMenuItem.value.component;\r\n\r\n\t\tif (activeMenuItem.value && !store.component) {\r\n\t\t\tconsole.warn(`Компонент вкладки ${store.activeItemName} не найден. Добавьте props.component для пункта меню ${store.activeItemName}.`);\r\n\t\t}\r\n\t},\r\n\t{ immediate: true },\r\n);\r\n\r\nconst elRef = ref();\r\nlet resizeObserver: ResizeObserver;\r\n\r\nonMounted(() => {\r\n\tresizeObserver = new ResizeObserver(() => {\r\n\t\telRef.value.parentElement.style.setProperty('--top-tabsView-contents-offset-top', elRef.value.offsetHeight + 'px');\r\n\t});\r\n\r\n\tresizeObserver.observe(elRef.value);\r\n});\r\n\r\nonUnmounted(() => {\r\n\tresizeObserver.disconnect();\r\n});\r\n</script>\r\n\r\n<template>\r\n\t<div\r\n\t\tref=\"elRef\"\r\n\t\t:class=\"{\r\n\t\t\t'top-tabsView_menu': true,\r\n\t\t\t'top-tabsView_menu-inPopup_0': !store.showMenuInPopup,\r\n\t\t\t'top-tabsView_menu-inPopup_1': store.showMenuInPopup,\r\n\t\t\t'top-tabsView_menu-short': store.isShort && !store.showMenuInPopup,\r\n\t\t}\"\r\n\t>\r\n\t\t<!-- Спрятать меню под кнопку в popup -->\r\n\t\t<Popup v-if=\"store.showMenuInPopup\">\r\n\t\t\t<template #opener>\r\n\t\t\t\t<div class=\"top-tabsView_menuOpener\">\r\n\t\t\t\t\t<div\r\n\t\t\t\t\t\tv-if=\"activeMenuItem\"\r\n\t\t\t\t\t\tclass=\"top-tabsView_menuOpenerActiveItem\"\r\n\t\t\t\t\t\t:data-top-icon=\"activeMenuItem.icon\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<span class=\"top-ellipsis\">\r\n\t\t\t\t\t\t\t{{ activeMenuItem.title }}\r\n\t\t\t\t\t\t</span>\r\n\t\t\t\t\t</div>\r\n\r\n\t\t\t\t\t<div class=\"top-tabsView_menuOpenerIcon\" data-top-icon=\"\"></div>\r\n\t\t\t\t</div>\r\n\t\t\t</template>\r\n\r\n\t\t\t<template #contentList>\r\n\t\t\t\t<slot></slot>\r\n\t\t\t</template>\r\n\t\t</Popup>\r\n\r\n\t\t<!-- Отобразить меню на странице -->\r\n\t\t<template v-else>\r\n\t\t\t<div class=\"top-tabsView_menuList\">\r\n\t\t\t\t<slot></slot>\r\n\t\t\t</div>\r\n\r\n\t\t\t<div\r\n\t\t\t\tv-if=\"isShortable\"\r\n\t\t\t\tclass=\"top-tabsView_menuFooter\"\r\n\t\t\t>\r\n\t\t\t\t<TabsViewMenuItem\r\n\t\t\t\t\tv-if=\"isShortable\"\r\n\t\t\t\t\t:icon=\"store.isShort ? '' : ''\"\r\n\t\t\t\t\t@click=\"store.isShort = !store.isShort\"\r\n\t\t\t\t>\r\n\t\t\t\t\t{{ store.isShort ? '' : 'Свернуть' }} <!--TODO: translate-->\r\n\t\t\t\t</TabsViewMenuItem>\r\n\t\t\t</div>\r\n\t\t</template>\r\n\t</div>\r\n</template>\r\n\r\n<style module>\r\n/* режим отображение табов в основной области документа */\r\n.top-tabsView-pageMod .top-tabsView_menu {\r\n\tbox-sizing: border-box;\r\n\tposition: sticky;\r\n\ttop: var(--top-tabsView-top);\r\n\tz-index: 10;\r\n}\r\n\r\n/* режим отображение табов в основной области документа без popup */\r\n.top-tabsView-pageMod .top-tabsView_menu-inPopup_0 {\r\n\theight: calc(var(--100vh) - var(--top-tabsView-top));\r\n}\r\n\r\n/* стантартный режим */\r\n.top-tabsView_menu-inPopup_0 {\r\n\tbox-sizing: border-box;\r\n\twidth: var(--top-tabsView-menu-width);\r\n\tdisplay: flex;\r\n\tflex-direction: column;\r\n\tjustify-content: space-between;\r\n}\r\n\r\n/* режим вывода в popup */\r\n.top-tabsView_menu-inPopup_1 {\r\n\tborder-bottom: 1px solid var(--color-line-2-opacity);\r\n}\r\n\r\n.top-tabsView_menu-short {\r\n\twidth: auto;\r\n}\r\n\r\n.top-tabsView_menu > .top-tabsView_menuOpener {\r\n\tdisplay: flex;\r\n\tjustify-content: flex-end;\r\n}\r\n\r\n.top-tabsView_menu > .top-tabsView_menuOpener:hover {\r\n\tbackground: var(--color-secondary-opacity);\r\n}\r\n\r\n.top-tabsView_menuOpenerIcon { display: flex; }\r\n\r\n.top-tabsView_menuOpenerActiveItem {\r\n\t--top-forms-padding: 0px;\r\n\r\n\tbox-sizing: border-box;\r\n\tpadding: var(--top-padding-2);\r\n\tmax-width: calc(100% - var(--top-forms-base-height));\r\n\twhite-space: nowrap;\r\n\tflex-grow: 1;\r\n\tdisplay: flex;\r\n\talign-items: center;\r\n\tgap: var(--top-padding-2);\r\n}\r\n\r\n.top-tabsView_menuList,\r\n.top-tabsView_menuFooter {\r\n\tpadding: var(--top-padding-2);\r\n\tdisplay: flex;\r\n\tflex-direction: column;\r\n\tgap: var(--top-gap-2);\r\n}\r\n\r\n.top-tabsView_menuList {\r\n\toverflow-y: auto;\r\n}\r\n\r\n.top-tabsView_menu-short .top-tabsView_menuFooter > .top-tabsView_menuItem {\r\n\t--top-icon-width: 100%;\r\n}\r\n</style>","<script setup lang=\"ts\">\r\nimport { defineModel, onUnmounted, ref, watch } from 'vue';\r\nimport { delHash } from '@/core/utils/route';\r\nimport type { Props } from './tabsView';\r\nimport { defineTabsStore } from './store';\r\nimport TabsViewMenu from './menu.vue';\r\nimport { Loadbar } from '@/components/forms/forms';\r\nimport { checkComponentIsLoading } from './utils';\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n\tshowMenuInPopup: undefined,\r\n\tisShortable: false,\r\n});\r\n\r\nconst model = defineModel<string>();\r\n\r\nconst store = defineTabsStore(props, model);\r\n\r\n/**\r\n * Установка или снятие глобального модификатора\r\n * @see props.pageMod\r\n */\r\nconst setDocumentPageModModificator = (pageMod: boolean) => {\r\n\tdocument.documentElement.classList.toggle('top-hasTabsViewPageMod', pageMod);\r\n};\r\n\r\nif (props.pageMod) setDocumentPageModModificator(true);\r\n\r\nonUnmounted(() => {\r\n\tif (props.pageMod) setDocumentPageModModificator(false);\r\n\r\n\tif (store.$id) delHash(store.$id, store.activeItemName, true);\r\n});\r\n\r\nconst componentRef = ref();\r\nconst isLoading = ref(false);\r\n\r\nwatch([componentRef, () => store.component], () => {\r\n\tisLoading.value = checkComponentIsLoading(store.component);\r\n}, { immediate: true });\r\n</script>\r\n\r\n<template>\r\n\t<div\r\n\t\t:class=\"{\r\n\t\t\t'top-tabsView': true,\r\n\t\t\t'top-tabsView-pageMod': props.pageMod,\r\n\t\t\t'top-tabsView-inPopup': store.showMenuInPopup,\r\n\t\t}\"\r\n\t>\r\n\t\t<TabsViewMenu\r\n\t\t\t:isShortable=\"isShortable\"\r\n\t\t\tv-model:isLoading=\"isLoading\"\r\n\t\t>\r\n\t\t\t<!-- @slot Меню, ожидает передачу компонентов TabsViewMenuItem и TabsViewMenuTitle -->\r\n\t\t\t<slot name=\"menu\"></slot>\r\n\t\t</TabsViewMenu>\r\n\r\n\t\t<div\r\n\t\t\t:class=\"{\r\n\t\t\t\t'top-tabsView_contents': true,\r\n\t\t\t\t'top-tabsView_contents-isLoading': isLoading,\r\n\t\t\t\t'top-tabsView_contents-noScrollable': !store.scrollable,\r\n\t\t\t}\"\r\n\t\t>\r\n\t\t\t<Loadbar v-if=\"isLoading\"/>\r\n\t\t\t<keep-alive>\r\n\t\t\t\t<component\r\n\t\t\t\t\tref=\"componentRef\"\r\n\t\t\t\t\t:is=\"store.component\"\r\n\t\t\t\t/>\r\n\t\t\t</keep-alive>\r\n\t\t</div>\r\n\t</div>\r\n</template>\r\n\r\n<style module>\r\n:root {\r\n\t--top-tabsView-top: 0px;\r\n\t--top-tabsView-menu-width: 220px;\r\n\t--top-tabsView-contents-offset-top: 0px;\r\n}\r\n\r\n.top-tabsView {\r\n\tbackground: var(--color-bg-2);\r\n\twidth: 100%;\r\n\theight: 100%;\r\n\tdisplay: flex;\r\n\tflex-direction: row;\r\n}\r\n\r\n.top-tabsView_contents {\r\n\tborder-radius: var(--top-radius-4);\r\n\tbackground: var(--color-bg-3);\r\n\tpadding: var(--top-padding-4);\r\n\tflex-grow: 1;\r\n\toverflow: auto;\r\n\tposition: relative;\r\n}\r\n\r\n.top-tabsView_contents-isLoading {\r\n\tpointer-events: none;\r\n}\r\n\r\n.top-tabsView_contents-noScrollable {\r\n\twidth: calc(100% - var(--top-tabsView-menu-width));\r\n\tpadding: 0;\r\n\toverflow: visible;\r\n}\r\n\r\n/* top-tabsView-inPopup */\r\n.top-tabsView-inPopup {\r\n\tbackground: var(--color-bg-3);\r\n\tflex-direction: column;\r\n}\r\n\r\n.top-tabsView-inPopup > .top-tabsView_contents {\r\n\tborder-radius: 0;\r\n}\r\n\r\n.top-tabsView-inPopup > .top-tabsView_contents-noScrollable {\r\n\twidth: auto;\r\n}\r\n</style>","<script setup lang=\"ts\">\r\n\r\n</script>\r\n\r\n<template>\r\n\t<div class=\"top-tabsView_menuDelimeter\"></div>\r\n</template>\r\n\r\n<style module>\r\n.top-tabsView_menuDelimeter {\r\n\tpadding: var(--top-padding-1) 0;\r\n\tdisplay: flex;\r\n}\r\n\r\n.top-tabsView_menuDelimeter:before {\r\n\tcontent: \"\";\r\n\theight: 2px;\r\n\tbackground: var(--color-line-2-opacity);\r\n\tflex-grow: 1;\r\n}\r\n\r\n.top-tabsView_menuDelimeter:first-child,\r\n.top-tabsView_menuDelimeter + .top-tabsView_menuDelimeter {\r\n\tdisplay: none;\r\n}\r\n</style>","<script setup lang=\"ts\">\r\nimport { useTabsStore } from './store';\r\nimport type { PropsMenuTitle } from './tabsView';\r\nimport TabsViewMenuDelimeter from './menuDelimeter.vue';\r\nimport { PopupListItem } from '../../popup/popup';\r\n\r\ndefineProps<PropsMenuTitle>();\r\n\r\nconst store = useTabsStore();\r\n</script>\r\n\r\n<template>\r\n\t<PopupListItem\r\n\t\tv-if=\"store.showMenuInPopup\"\r\n\t\ttype=\"title\"\r\n\t>\r\n\t\t<slot></slot>\r\n\t</PopupListItem>\r\n\r\n\t<TabsViewMenuDelimeter v-else-if=\"store.isShort\"/>\r\n\r\n\t<div\r\n\t\tv-else\r\n\t\t:class=\"{\r\n\t\t\t'top-tabsView_menuTitle': true,\r\n\t\t\t'top-tabsView_menuTitle-subtitle': isSubtitle,\r\n\t\t}\"\r\n\t>\r\n\t\t<slot></slot>\r\n\t</div>\r\n</template>\r\n\r\n<style module>\r\n.top-tabsView_menuTitle {\r\n\tpadding: var(--top-padding-4) var(--top-padding-2) var(--top-padding-1);\r\n\tfont-weight: 600;\r\n}\r\n\r\n.top-tabsView_menuTitle-subtitle {\r\n\tpadding-top: var(--top-padding-1);\r\n\tfont-size: 12px;\r\n\tfont-weight: 400;\r\n\tcolor: var(--color-text-2);\r\n}\r\n</style>"],"names":["genStorageKey","stateName","stateKey","loadLocalStorge","store","localStorageKey","localStorageValue","addSaverLocalStorge","watch","StoreLocalStorage","injectionKey","defineTabsStore","props","model","defineStore","showMenuInPopup","computed","Core","pageMod","isShort","ref","component","scrollable","useTabsStore","useStore","__props","href","genHash","tagName","_sfc_main$5","onClick","e","checkComponentIsLoading","preResolveComponent","condition","sleepWhile","isLoading","useModel","slots","useSlots","menuItemByName","genMenuItemByName","item","subComponent","TabsViewMenuItem","menuItem","_b","_a","markRaw","activeMenuItem","countChanged","numberChanged","activeItemName","getHash","setHash","elRef","resizeObserver","onMounted","onUnmounted","setDocumentPageModModificator","delHash","componentRef","_sfc_render","_ctx","_cache"],"mappings":";;;;;;;;;;AAQA,MAAAA,IAAA,CAAAC,GAAAC,MAGC,OAFA,OAAAD,CAAA,CAEA,IAAAC,CAAA,IAQDC,KAAA,CAAAF,GAAAG,MAAA;AAEC,MAAA,CAAAA,EAAA;AAAgB;AAEhB,QAAAC,IAAAL,EAAAC,GAAAG,EAAA,GAAA;AAEA,MAAA;AACC,UAAAE,IAAA,KAAA,MAAA,aAAA,QAAAD,CAAA,CAAA;AAEA,IAAA,OAAAC,KAAA,OAAAF,EAAAH,CAAA,MACCG,EAAAH,CAAA,IAAAK;AAAA,EACD,QA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,MAAA;AACC,MAAAD,IAAA,IAAA,eAAA,MAAA;AACC,QAAAD,EAAA,MAAA,cAAA,MAAA,YAAA,sCAAAA,EAAA,MAAA,eAAA,IAAA;AAAA,MAAiH,CAAA,GAGlHC,EAAA,QAAAD,EAAA,KAAA;AAAA,IAAkC,CAAA,GAGnCG,EAAA,MAAA;AACC,MAAAF,EAAA,WAAA;AAAA,IAA0B,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACzI3B,UAAA5C,IAAAa,GAKAZ,IAAAwB,EAAAZ,GAAA,YAAA,GAEArB,IAAAO,GAAAC,GAAAC,CAAA,GAMA8C,IAAA,CAAAzC,MAAA;AACC,eAAA,gBAAA,UAAA,OAAA,0BAAAA,CAAA;AAAA,IAA2E;AAG5E,IAAAN,EAAA,WAAmB+C,EAAA,EAAA,GAEnBD,EAAA,MAAA;AACC,MAAA9C,EAAA,WAAmB+C,EAAA,EAAA,GAEnBvD,EAAA,OAAewD,EAAAxD,EAAA,KAAAA,EAAA,gBAAA,EAAA;AAAA,IAA6C,CAAA;AAG7D,UAAAyD,IAAAzC,EAAA,GACAgB,IAAAhB,EAAA,EAAA;AAEA,WAAAZ,EAAA,CAAAqD,GAAA,MAAAzD,EAAA,SAAA,GAAA,MAAA;AACC,MAAAgC,EAAA,QAAAJ,EAAA5B,EAAA,SAAA;AAAA,IAAyD,GAAA,EAAA,WAAA,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjCzD,SAAA0D,GAAAC,GAAAC,GAAA;;;;;;;;;;;ACGD,UAAA5D,IAAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"tabsView.js","sources":["../../src/core/utils/store/localStorage.ts","../../src/components/tabsView/tabsView/store.ts","../../src/components/tabsView/tabsView/menuItem.vue","../../src/components/tabsView/tabsView/utils.ts","../../src/components/tabsView/tabsView/menu.vue","../../src/components/tabsView/tabsView/tabsView.vue","../../src/components/tabsView/tabsView/menuDelimeter.vue","../../src/components/tabsView/tabsView/menuTitle.vue"],"sourcesContent":["import { watch } from 'vue';\nimport type { Store } from './store';\n\n/**\n * Сгенерировать имя для сохранения данных в localStorage\n * @param stateName - имя свойства состояния\n * @param stateKey - ключ состояния, разные компоненты могут использовать одинаковый ключ\n */\nconst genStorageKey = <T extends Store>(stateName: keyof T, stateKey: string): string => {\n\tconst stateNameString = String(stateName);\n\n\treturn `top:${stateNameString}:${stateKey}`;\n};\n\n/**\n * Загрузить состояние\n * @param stateName - имя свойства состояния\n * @param store\n */\nconst loadLocalStorge = <T extends Store>(stateName: keyof T, store: T) => {\n\t// если Store.key не знадан, значит сохранение состояния в компоненте отключено\n\tif (!store.$id) return;\n\n\tconst localStorageKey = genStorageKey(stateName, store.$id);\n\n\ttry {\n\t\tconst localStorageValue: typeof store[keyof typeof store] = JSON.parse(localStorage.getItem(localStorageKey) as string);\n\n\t\tif (typeof localStorageValue === typeof store[stateName]) {\n\t\t\tstore[stateName] = localStorageValue;\n\t\t}\n\t} catch (e) {\n\t\tconsole.warn(new Error(`В localStorage[${localStorageKey}] не корректный json`));\n\t}\n};\n\n/**\n * Добавить автосохранение состояние при его изменении\n * @param stateName - имя свойства состояния\n * @param store\n */\nconst addSaverLocalStorge = <T extends Store>(stateName: keyof T, store: T) => {\n\t// если store.$id не знадан, значит сохранение состояния в компоненте отключено\n\tif (!store.$id) return;\n\n\tconst localStorageKey = genStorageKey(stateName, store.$id);\n\n\twatch(() => store[stateName], () => {\n\t\tlocalStorage.setItem(localStorageKey, JSON.stringify(store[stateName]));\n\t}, { immediate: true });\n};\n\nexport default {\n\tloadLocalStorge,\n\taddSaverLocalStorge,\n};","import type { ModelRef, InjectionKey } from 'vue';\nimport { ref, computed } from 'vue';\nimport Core from '@/core/core/core';\nimport { defineStore, useStore } from '@/core/utils/store';\nimport StoreLocalStorage from '@/core/utils/store/localStorage';\nimport type { Props, Store } from './tabsView';\n\nexport const injectionKey = Symbol() as InjectionKey<Store>;\n\n/**\n * Инициировать Store компонента\n */\nexport const defineTabsStore = (props: Props, model: ModelRef<string | undefined>) => {\n\tconst store = defineStore(injectionKey, () => {\n\t\tconst showMenuInPopup = computed(() => props.showMenuInPopup ?? Core.state.isMobile);\n\t\tconst pageMod = computed(() => props.pageMod);\n\t\tconst isShort = ref(false);\n\n\t\tconst component = ref(undefined);\n\t\tconst scrollable = ref(true);\n\n\t\treturn {\n\t\t\tshowMenuInPopup,\n\t\t\tpageMod,\n\t\t\tisShort,\n\t\t\tactiveItemName: model,\n\t\t\tcomponent,\n\t\t\tscrollable,\n\t\t};\n\t}, props.idState);\n\n\tif (props.isShortable) {\n\t\tconst stateName = 'isShort';\n\n\t\tStoreLocalStorage.loadLocalStorge(stateName, store);\n\t\tStoreLocalStorage.addSaverLocalStorge(stateName, store);\n\t}\n\n\treturn store;\n};\n\n/**\n * Получить Store компонента\n */\nexport const useTabsStore = () => useStore(injectionKey);","<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { genHash } from '@/core/utils/route';\nimport { PopupListItem } from '@/components/popup/popup';\nimport { useTabsStore } from './store';\nimport type { PropsMenuItem } from './tabsView';\n\nconst props = withDefaults(defineProps<PropsMenuItem>(), {\n\tscrollable: true,\n\tcomponent: undefined,\n});\n\nconst store = useTabsStore();\n\nconst href = computed(() => {\n\t// это внутренняя хеш навигация, ссылка на вкладку\n\tif (props.name && store.$id) {\n\t\treturn genHash(store.$id, props.name);\n\t}\n\n\treturn props.href;\n});\n\nconst tagName = computed(() => {\n\tif (store.showMenuInPopup) {\n\t\treturn PopupListItem;\n\t}\n\n\treturn href ? 'a' : 'button';\n});\n\n/**\n * Клик по элементу меню\n */\nconst onClick = (e: MouseEvent) => {\n\t// это внутренняя хеш навигация, ссылка на вкладку\n\tif (!props.href && href.value) {\n\t\te.preventDefault();\n\t}\n\n\tif (props.name) {\n\t\tstore.activeItemName = props.name;\n\t}\n};\n</script>\n\n<template>\n\t<component\n\t\t:is=\"tagName\"\n\t\ttarget=\"_self\"\n\t\t:class=\"{\n\t\t\t['top-tabsView_menuItem']: !store.showMenuInPopup,\n\t\t\t['top-active']: name && store.activeItemName === name,\n\t\t\t['top-disabled']: disabled,\n\t\t\t['top-spa-disabled']: true,\n\t\t}\"\n\t\t:href=\"href\"\n\t\t:data-top-icon=\"icon || undefined\"\n\t\t:disabled=\"disabled || undefined\"\n\t\t@click=\"onClick\"\n\t>\n\t\t<slot v-if=\"store.showMenuInPopup\"></slot>\n\n\t\t<span\n\t\t\tv-else-if=\"$slots.default && !store.isShort\"\n\t\t\tclass=\"top-ellipsis\"\n\t\t>\n\t\t\t<slot></slot>\n\t\t</span>\n\t</component>\n</template>\n\n<style module>\n.top-tabsView_menuItem {\n\t--top-icon-color: var(--color-text-1);\n\t--top-icon-width: calc(var(--top-icon-size));\n\n\tcursor: pointer;\n\tbox-sizing: border-box;\n\n\tborder: none;\n\tborder-radius: var(--top-radius-2);\n\tpadding: var(--top-padding-2);\n\tbackground: transparent;\n\theight: 40px;\n\n\tcolor: var(--color-text-1);\n\ttext-decoration: none;\n\twhite-space: nowrap;\n\n\tdisplay: flex;\n\tgap: var(--top-gap-2);\n\talign-items: center;\n\tjustify-content: flex-start;\n\ttransition: background var(--transition);\n}\n\n.top-tabsView_menuItem:hover {\n\tbackground: var(--color-secondary-2-opacity);\n\ttext-decoration: none;\n}\n\n.top-tabsView_menuItem.top-active {\n\tcursor: unset;\n\tbackground: var(--color-bg-3);\n}\n\n.top-tabsView_menuItem:disabled:not(option):not(optgroup):not(.top-forms-option),\n.top-tabsView_menuItem:disabled ~ .top-formsCaption,\n.top-tabsView_menuItem.top-disabled[data-top-icon]:before,\n.top-tabsView_menuItem.top-disabled[data-top-icon2]:after {\n\topacity: unset;\n\tfilter: unset;\n}\n\n.top-tabsView_menuItem.top-disabled {\n\t--top-icon-color: var(--color-text-4);\n\n\tcolor: var(--color-text-4);\n}\n</style>","// TODO: Эту функцию можно вынести в глобальный utils\n\nimport { sleepWhile } from '@/core/utils/system';\n\n/**\n * Проверка нахождения компонента в состояние загрузки\n * @param component\n */\nexport const checkComponentIsLoading = (component: any) => {\n\treturn component?.name === 'AsyncComponentWrapper' && !component?.__asyncResolved;\n};\n\n/**\n * Презагрузить компонент\n *\n * Некоторое время ожидает загрузку компонента, прежде чем завершит работу\n */\nexport const preResolveComponent = async (component: any, condition: Function) => {\n\tif(component?.name !== 'AsyncComponentWrapper') return;\n\tif(component?.__asyncResolved) return;\n\n\tcomponent.__asyncLoader();\n\n\tawait sleepWhile(() => {\n\t\treturn condition() && checkComponentIsLoading(component);\n\t}, 200);\n};","<script setup lang=\"ts\">\nimport { ref, watch, markRaw, useSlots, onMounted, onUnmounted } from 'vue';\nimport type { Ref, Component } from 'vue';\nimport { Popup } from '../../popup/popup';\nimport { sleepWhile } from '@/core/utils/system';\nimport { getHash, setHash } from '@/core/utils/route';\n\nimport type { PropsMenu, PropsMenuItem, MenuItem } from './tabsView';\nimport { useTabsStore } from './store';\nimport TabsViewMenuItem from './menuItem.vue';\nimport { preResolveComponent } from './utils';\n\ndefineProps<PropsMenu>();\n\nconst isLoading = defineModel('isLoading');\n\nconst store = useTabsStore();\n\nconst slots = useSlots();\n\n// словарь используется для оптимизации получения нужного menuItem\nconst menuItemByName: Map<PropsMenuItem['name'], MenuItem> = new Map();\n\n// сгенерировать словарь с menuItem, по элементам в slot\nconst genMenuItemByName = () => {\n\tif (!slots.default) return;\n\n\tconst component: any = slots.default().find(item => item.key === '_menu');\n\tif (!component) return;\n\n\tcomponent.children.forEach((subComponent: any) => {\n\t\tif (subComponent.type.__name !== TabsViewMenuItem.__name) return;\n\t\tif (!subComponent.props.name || subComponent.props.disabled) return;\n\n\t\tconst menuItem: MenuItem = {\n\t\t\ttitle: (subComponent.children.default?.()[0].children as string).trim(),\n\t\t\ticon: subComponent.props.icon,\n\t\t\tcomponent: subComponent.props.component ? markRaw(subComponent.props.component) : TabsViewMenuItem.props.component.default,\n\t\t\tscrollable: subComponent.props.scrollable ?? TabsViewMenuItem.props.scrollable.default,\n\t\t};\n\n\t\tmenuItemByName.set(subComponent.props.name, menuItem);\n\t});\n};\n\n/**\n * activeMenuItem нужен:\n * - для вывода текста активной вкладки в меню с popup\n * - для вывода компонента активной вкладки (store.component)\n * - для установки store.scrollable\n */\nconst activeMenuItem: Ref<MenuItem | null> = ref(null);\n\n/**\n * Кол-во изменений активной вкладки\n */\nlet countChanged = 0;\n\n/**\n * Смена активной вкладки\n *\n * TODO: смена slot, например смена языка, требует повторного выполнения genMenuItemByName()\n */\nwatch(\n\t() => store.activeItemName,\n\tasync () => {\n\t\tconst numberChanged = ++countChanged; // порядковый номер текущего изменения\n\n\t\tif (menuItemByName.size === 0) {\n\t\t\tgenMenuItemByName();\n\t\t}\n\n\t\tif (menuItemByName.size === 0) {\n\t\t\tstore.activeItemName = '';\n\n\t\t\treturn;\n\t\t}\n\n\t\tactiveMenuItem.value = menuItemByName.get(store.activeItemName) ?? null;\n\n\t\t// элемент не найден, установить из хеша страницы\n\t\tif (!activeMenuItem.value && store.$id) {\n\t\t\tconst activeItemName = getHash(store.$id);\n\n\t\t\tactiveMenuItem.value = menuItemByName.get(activeItemName) ?? null;\n\n\t\t\tif (activeMenuItem.value) {\n\t\t\t\tstore.activeItemName = activeItemName;\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// элемент не найден, установить первый доступный\n\t\tif (!activeMenuItem.value) {\n\t\t\tstore.activeItemName = menuItemByName.keys().next().value;\n\n\t\t\treturn;\n\t\t}\n\n\t\t// запрошена смена на уже активный элемент\n\t\tif (activeMenuItem.value.component === store.component) {\n\t\t\tisLoading.value = false;\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (store.$id) setHash(store.$id, store.activeItemName, true);\n\n\t\t// флаг загрузки будет сброшен при инициализации компонента\n\t\tisLoading.value = true;\n\n\t\t/**\n\t\t * Презагрузить компонент\n\t\t *\n\t\t * Нужно для того, чтобы минимизировать скачки интерфейса при ожидании загрузки асинхронного компонента\n\t\t */\n\t\tawait preResolveComponent(activeMenuItem.value.component, () => numberChanged === countChanged);\n\n\t\t// влкадка была сменена еще раз во время sleepWhile\n\t\tif (numberChanged !== countChanged) {\n\t\t\treturn;\n\t\t}\n\n\t\tstore.scrollable = activeMenuItem.value.scrollable;\n\t\tstore.component = activeMenuItem.value.component;\n\n\t\tif (activeMenuItem.value && !store.component) {\n\t\t\tconsole.warn(`Компонент вкладки ${store.activeItemName} не найден. Добавьте props.component для пункта меню ${store.activeItemName}.`);\n\t\t}\n\t},\n\t{ immediate: true },\n);\n\nconst elRef = ref();\nlet resizeObserver: ResizeObserver;\n\nonMounted(() => {\n\tresizeObserver = new ResizeObserver(() => {\n\t\telRef.value.parentElement.style.setProperty('--top-tabsView-contents-offset-top', elRef.value.offsetHeight + 'px');\n\t});\n\n\tresizeObserver.observe(elRef.value);\n});\n\nonUnmounted(() => {\n\tresizeObserver.disconnect();\n});\n</script>\n\n<template>\n\t<div\n\t\tref=\"elRef\"\n\t\t:class=\"{\n\t\t\t'top-tabsView_menu': true,\n\t\t\t'top-tabsView_menu-inPopup_0': !store.showMenuInPopup,\n\t\t\t'top-tabsView_menu-inPopup_1': store.showMenuInPopup,\n\t\t\t'top-tabsView_menu-short': store.isShort && !store.showMenuInPopup,\n\t\t}\"\n\t>\n\t\t<!-- Спрятать меню под кнопку в popup -->\n\t\t<Popup v-if=\"store.showMenuInPopup\">\n\t\t\t<template #opener>\n\t\t\t\t<div class=\"top-tabsView_menuOpener\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tv-if=\"activeMenuItem\"\n\t\t\t\t\t\tclass=\"top-tabsView_menuOpenerActiveItem\"\n\t\t\t\t\t\t:data-top-icon=\"activeMenuItem.icon\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span class=\"top-ellipsis\">\n\t\t\t\t\t\t\t{{ activeMenuItem.title }}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div class=\"top-tabsView_menuOpenerIcon\" data-top-icon=\"\"></div>\n\t\t\t\t</div>\n\t\t\t</template>\n\n\t\t\t<template #contentList>\n\t\t\t\t<slot></slot>\n\t\t\t</template>\n\t\t</Popup>\n\n\t\t<!-- Отобразить меню на странице -->\n\t\t<template v-else>\n\t\t\t<div class=\"top-tabsView_menuList\">\n\t\t\t\t<slot></slot>\n\t\t\t</div>\n\n\t\t\t<div\n\t\t\t\tv-if=\"isShortable\"\n\t\t\t\tclass=\"top-tabsView_menuFooter\"\n\t\t\t>\n\t\t\t\t<TabsViewMenuItem\n\t\t\t\t\tv-if=\"isShortable\"\n\t\t\t\t\t:icon=\"store.isShort ? '' : ''\"\n\t\t\t\t\t@click=\"store.isShort = !store.isShort\"\n\t\t\t\t>\n\t\t\t\t\t{{ store.isShort ? '' : 'Свернуть' }} <!--TODO: translate-->\n\t\t\t\t</TabsViewMenuItem>\n\t\t\t</div>\n\t\t</template>\n\t</div>\n</template>\n\n<style module>\n/* режим отображение табов в основной области документа */\n.top-tabsView-pageMod .top-tabsView_menu {\n\tbox-sizing: border-box;\n\tposition: sticky;\n\ttop: var(--top-tabsView-top);\n\tz-index: 10;\n}\n\n/* режим отображение табов в основной области документа без popup */\n.top-tabsView-pageMod .top-tabsView_menu-inPopup_0 {\n\theight: calc(var(--100vh) - var(--top-tabsView-top));\n}\n\n/* стантартный режим */\n.top-tabsView_menu-inPopup_0 {\n\tbox-sizing: border-box;\n\twidth: var(--top-tabsView-menu-width);\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-between;\n}\n\n/* режим вывода в popup */\n.top-tabsView_menu-inPopup_1 {\n\tborder-bottom: 1px solid var(--color-line-2-opacity);\n}\n\n.top-tabsView_menu-short {\n\twidth: auto;\n}\n\n.top-tabsView_menu > .top-tabsView_menuOpener {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n}\n\n.top-tabsView_menu > .top-tabsView_menuOpener:hover {\n\tbackground: var(--color-secondary-opacity);\n}\n\n.top-tabsView_menuOpenerIcon { display: flex; }\n\n.top-tabsView_menuOpenerActiveItem {\n\t--top-forms-padding: 0px;\n\n\tbox-sizing: border-box;\n\tpadding: var(--top-padding-2);\n\tmax-width: calc(100% - var(--top-forms-base-height));\n\twhite-space: nowrap;\n\tflex-grow: 1;\n\tdisplay: flex;\n\talign-items: center;\n\tgap: var(--top-padding-2);\n}\n\n.top-tabsView_menuList,\n.top-tabsView_menuFooter {\n\tpadding: var(--top-padding-2);\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: var(--top-gap-2);\n}\n\n.top-tabsView_menuList {\n\toverflow-y: auto;\n}\n\n.top-tabsView_menu-short .top-tabsView_menuFooter > .top-tabsView_menuItem {\n\t--top-icon-width: 100%;\n}\n</style>","<script setup lang=\"ts\">\nimport { defineModel, onUnmounted, ref, watch } from 'vue';\nimport { delHash } from '@/core/utils/route';\nimport type { Props } from './tabsView';\nimport { defineTabsStore } from './store';\nimport TabsViewMenu from './menu.vue';\nimport { Loadbar } from '@/components/forms/forms';\nimport { checkComponentIsLoading } from './utils';\n\nconst props = withDefaults(defineProps<Props>(), {\n\tshowMenuInPopup: undefined,\n\tisShortable: false,\n});\n\nconst model = defineModel<string>();\n\nconst store = defineTabsStore(props, model);\n\n/**\n * Установка или снятие глобального модификатора\n * @see props.pageMod\n */\nconst setDocumentPageModModificator = (pageMod: boolean) => {\n\tdocument.documentElement.classList.toggle('top-hasTabsViewPageMod', pageMod);\n};\n\nif (props.pageMod) setDocumentPageModModificator(true);\n\nonUnmounted(() => {\n\tif (props.pageMod) setDocumentPageModModificator(false);\n\n\tif (store.$id) delHash(store.$id, store.activeItemName, true);\n});\n\nconst componentRef = ref();\nconst isLoading = ref(false);\n\nwatch([componentRef, () => store.component], () => {\n\tisLoading.value = checkComponentIsLoading(store.component);\n}, { immediate: true });\n</script>\n\n<template>\n\t<div\n\t\t:class=\"{\n\t\t\t'top-tabsView': true,\n\t\t\t'top-tabsView-pageMod': props.pageMod,\n\t\t\t'top-tabsView-inPopup': store.showMenuInPopup,\n\t\t}\"\n\t>\n\t\t<TabsViewMenu\n\t\t\t:isShortable=\"isShortable\"\n\t\t\tv-model:isLoading=\"isLoading\"\n\t\t>\n\t\t\t<!-- @slot Меню, ожидает передачу компонентов TabsViewMenuItem и TabsViewMenuTitle -->\n\t\t\t<slot name=\"menu\"></slot>\n\t\t</TabsViewMenu>\n\n\t\t<div\n\t\t\t:class=\"{\n\t\t\t\t'top-tabsView_contents': true,\n\t\t\t\t'top-tabsView_contents-isLoading': isLoading,\n\t\t\t\t'top-tabsView_contents-noScrollable': !store.scrollable,\n\t\t\t}\"\n\t\t>\n\t\t\t<Loadbar v-if=\"isLoading\"/>\n\t\t\t<keep-alive>\n\t\t\t\t<component\n\t\t\t\t\tref=\"componentRef\"\n\t\t\t\t\t:is=\"store.component\"\n\t\t\t\t/>\n\t\t\t</keep-alive>\n\t\t</div>\n\t</div>\n</template>\n\n<style module>\n:root {\n\t--top-tabsView-top: 0px;\n\t--top-tabsView-menu-width: 220px;\n\t--top-tabsView-contents-offset-top: 0px;\n}\n\n.top-tabsView {\n\tbackground: var(--color-bg-2);\n\twidth: 100%;\n\theight: 100%;\n\tdisplay: flex;\n\tflex-direction: row;\n}\n\n.top-tabsView_contents {\n\tborder-radius: var(--top-radius-4);\n\tbackground: var(--color-bg-3);\n\tpadding: var(--top-padding-4);\n\tflex-grow: 1;\n\toverflow: auto;\n\tposition: relative;\n}\n\n.top-tabsView_contents-isLoading {\n\tpointer-events: none;\n}\n\n.top-tabsView_contents-noScrollable {\n\twidth: calc(100% - var(--top-tabsView-menu-width));\n\tpadding: 0;\n\toverflow: visible;\n}\n\n/* top-tabsView-inPopup */\n.top-tabsView-inPopup {\n\tbackground: var(--color-bg-3);\n\tflex-direction: column;\n}\n\n.top-tabsView-inPopup > .top-tabsView_contents {\n\tborder-radius: 0;\n}\n\n.top-tabsView-inPopup > .top-tabsView_contents-noScrollable {\n\twidth: auto;\n}\n</style>","<script setup lang=\"ts\">\n\n</script>\n\n<template>\n\t<div class=\"top-tabsView_menuDelimeter\"></div>\n</template>\n\n<style module>\n.top-tabsView_menuDelimeter {\n\tpadding: var(--top-padding-1) 0;\n\tdisplay: flex;\n}\n\n.top-tabsView_menuDelimeter:before {\n\tcontent: \"\";\n\theight: 2px;\n\tbackground: var(--color-line-2-opacity);\n\tflex-grow: 1;\n}\n\n.top-tabsView_menuDelimeter:first-child,\n.top-tabsView_menuDelimeter + .top-tabsView_menuDelimeter {\n\tdisplay: none;\n}\n</style>","<script setup lang=\"ts\">\nimport { useTabsStore } from './store';\nimport type { PropsMenuTitle } from './tabsView';\nimport TabsViewMenuDelimeter from './menuDelimeter.vue';\nimport { PopupListItem } from '../../popup/popup';\n\ndefineProps<PropsMenuTitle>();\n\nconst store = useTabsStore();\n</script>\n\n<template>\n\t<PopupListItem\n\t\tv-if=\"store.showMenuInPopup\"\n\t\ttype=\"title\"\n\t>\n\t\t<slot></slot>\n\t</PopupListItem>\n\n\t<TabsViewMenuDelimeter v-else-if=\"store.isShort\"/>\n\n\t<div\n\t\tv-else\n\t\t:class=\"{\n\t\t\t'top-tabsView_menuTitle': true,\n\t\t\t'top-tabsView_menuTitle-subtitle': isSubtitle,\n\t\t}\"\n\t>\n\t\t<slot></slot>\n\t</div>\n</template>\n\n<style module>\n.top-tabsView_menuTitle {\n\tpadding: var(--top-padding-4) var(--top-padding-2) var(--top-padding-1);\n\tfont-weight: 600;\n}\n\n.top-tabsView_menuTitle-subtitle {\n\tpadding-top: var(--top-padding-1);\n\tfont-size: 12px;\n\tfont-weight: 400;\n\tcolor: var(--color-text-2);\n}\n</style>"],"names":["genStorageKey","stateName","stateKey","loadLocalStorge","store","localStorageKey","localStorageValue","addSaverLocalStorge","watch","StoreLocalStorage","injectionKey","defineTabsStore","props","model","defineStore","showMenuInPopup","computed","Core","pageMod","isShort","ref","component","scrollable","useTabsStore","useStore","__props","href","genHash","tagName","_sfc_main$5","onClick","e","checkComponentIsLoading","preResolveComponent","condition","sleepWhile","isLoading","useModel","slots","useSlots","menuItemByName","genMenuItemByName","item","subComponent","TabsViewMenuItem","menuItem","_b","_a","markRaw","activeMenuItem","countChanged","numberChanged","activeItemName","getHash","setHash","elRef","resizeObserver","onMounted","onUnmounted","setDocumentPageModModificator","delHash","componentRef","_sfc_render","_ctx","_cache"],"mappings":";;;;;;;;;;AAQA,MAAAA,IAAA,CAAAC,GAAAC,MAGC,OAFA,OAAAD,CAAA,CAEA,IAAAC,CAAA,IAQDC,KAAA,CAAAF,GAAAG,MAAA;AAEC,MAAA,CAAAA,EAAA;AAAgB;AAEhB,QAAAC,IAAAL,EAAAC,GAAAG,EAAA,GAAA;AAEA,MAAA;AACC,UAAAE,IAAA,KAAA,MAAA,aAAA,QAAAD,CAAA,CAAA;AAEA,IAAA,OAAAC,KAAA,OAAAF,EAAAH,CAAA,MACCG,EAAAH,CAAA,IAAAK;AAAA,EACD,QAAA;AAEA,YAAA,KAAA,IAAA,MAAA,kBAAAD,CAAA,sBAAA,CAAA;AAAA,EAA+E;AAEjF,GAOAE,KAAA,CAAAN,GAAAG,MAAA;AAEC,MAAA,CAAAA,EAAA;AAAgB;AAEhB,QAAAC,IAAAL,EAAAC,GAAAG,EAAA,GAAA;AAEA,EAAAI,EAAA,MAAAJ,EAAAH,CAAA,GAAA,MAAA;AACC,iBAAA,QAAAI,GAAA,KAAA,UAAAD,EAAAH,CAAA,CAAA,CAAA;AAAA,EAAsE,GAAA,EAAA,WAAA,GAAA,CAAA;AAExE,GAEAQ,IAAA;AAAA,EAAe,iBAAAN;AAAA,EACd,qBAAAI;AAED,GChDOG,IAAA,OAAA,GAKMC,KAAA,CAAAC,GAAAC,MAAA;AACZ,QAAAT,IAAAU,GAAAJ,GAAA,MAAA;AACC,UAAAK,IAAAC,EAAA,MAAAJ,EAAA,mBAAAK,GAAA,MAAA,QAAA,GACAC,IAAAF,EAAA,MAAAJ,EAAA,OAAA,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,EAAA,GAEnBvD,EAAA,OAAewD,EAAAxD,EAAA,KAAAA,EAAA,gBAAA,EAAA;AAAA,IAA6C,CAAA;AAG7D,UAAAyD,IAAAzC,EAAA,GACAgB,IAAAhB,EAAA,EAAA;AAEA,WAAAZ,EAAA,CAAAqD,GAAA,MAAAzD,EAAA,SAAA,GAAA,MAAA;AACC,MAAAgC,EAAA,QAAAJ,EAAA5B,EAAA,SAAA;AAAA,IAAyD,GAAA,EAAA,WAAA,GAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjCzD,SAAA0D,GAAAC,GAAAC,GAAA;;;;;;;;;;;ACGD,UAAA5D,IAAAmB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/utils/css.amd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.amd.js","sources":["../../src/core/utils/css.ts"],"sourcesContent":["/**\
|
|
1
|
+
{"version":3,"file":"css.amd.js","sources":["../../src/core/utils/css.ts"],"sourcesContent":["/**\n * Вставить css стили на страницу с автоматическим определением media\n * @param fileNames - список ссылок на css файлы\n */\nexport const insertToPage = async (fileNames: Array<string>) => {\n\tconst cssFilesByOptions = new Map();\n\tcssFilesByOptions.set('::', []);\n\n\tfileNames.forEach(filename => {\n\t\tlet m = false;\n\t\tlet pc = false;\n\n\t\tif (filename.match(/\\.m\\./)) {\n\t\t\tm = true;\n\t\t}\n\t\tif (filename.match(/\\.pc\\./)) {\n\t\t\tpc = true;\n\t\t}\n\n\t\tconst key = `${m}:${pc}`;\n\t\tif (!cssFilesByOptions.has(key)) {\n\t\t\tcssFilesByOptions.set(`${m}:${pc}`, []);\n\t\t}\n\t\tcssFilesByOptions.get(`${m}:${pc}`).push(filename);\n\t});\n\n\tconst promises: Array<Promise<unknown>> = [];\n\n\tcssFilesByOptions.forEach((fileNames, options: string) => {\n\t\tif (!fileNames.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [m, pc] = options.split(':').map(item => item === 'true');\n\n\t\tlet media = 'all';\n\t\tif (m) {\n\t\t\tmedia = '(max-width: 900px)';\n\t\t}\n\t\tif (pc) {\n\t\t\tmedia = '(min-width: 900px)';\n\t\t}\n\n\t\tconst promisesI = _insertToPage(fileNames, media);\n\t\tpromisesI.forEach(promise => promises.push(promise));\n\t});\n\n\treturn await Promise.all(promises);\n};\n\nconst _insertToPage = (fileNames: Array<string>, media: string): Array<Promise<unknown>> => {\n\tconst promises: Array<Promise<unknown>> = [];\n\n\tfileNames.forEach(fileName => {\n\t\tconst id = 'topCSSLink-' + fileName.replace(/\\W/g, '-');\n\n\t\t// стиль уже загружен\n\t\tif (window.hasOwnProperty(id)) return;\n\n\t\tlet resolve: Function;\n\t\tlet reject: Function;\n\t\tconst promise = new Promise((_resolve, _reject) => {\n\t\t\tresolve = _resolve;\n\t\t\treject = _reject;\n\t\t});\n\t\tpromises.push(promise);\n\n\t\tconst elLink = document.createElement('link');\n\t\telLink.id = id;\n\t\telLink.rel = 'stylesheet';\n\t\telLink.media = media;\n\t\telLink.href = fileName;\n\t\telLink.onload = () => resolve();\n\t\telLink.onerror = () => reject();\n\n\t\tdocument.head.append(elLink);\n\t});\n\n\treturn promises;\n};"],"names":["insertToPage","fileNames","cssFilesByOptions","filename","m","pc","key","promises","fileNames2","media","promise","_insertToPage","fileName","id","elLink","resolve","reject"],"mappings":"yFAIa,MAAAA,EAAA,MAAAC,GAAA,CACZ,MAAAC,EAAA,IAAA,mBAGAD,EAAA,QAAAE,GAAA,CACC,IAAAC,EAAA,GACAC,EAAA,GAEAF,EAAA,MAAA,OAAA,UAGAA,EAAA,MAAA,QAAA,UAIA,MAAAG,EAAA,GAAAF,CAAA,IAAAC,CAAA,aAECH,EAAA,IAAA,GAAAE,CAAA,IAAAC,CAAA,GAAA,CAAA,CAAA,EAEDH,EAAA,IAAA,GAAAE,CAAA,IAAAC,CAAA,EAAA,EAAA,KAAAF,CAAA,CAAiD,CAAA,EAGlD,MAAAI,EAAA,CAAA,2BAGC,GAAA,CAAAC,EAAA,OACC,kDAKD,IAAAC,EAAA,qEASA,QAAAC,GAAAH,EAAA,KAAAG,CAAA,CAAA,CAAmD,CAAA,wBAMrDC,EAAA,CAAAV,EAAAQ,IAAA,CACC,MAAAF,EAAA,CAAA,EAEA,OAAAN,EAAA,QAAAW,GAAA,CACC,MAAAC,EAAA,cAAAD,EAAA,QAAA,MAAA,GAAA,EAGA,GAAA,OAAA,eAAAC,CAAA,EAA+B,kDAMrB,CAAA,EAEVN,EAAA,KAAAG,CAAA,yCAGAI,EAAA,GAAAD,EACAC,EAAA,IAAA,aACAA,EAAA,MAAAL,EACAK,EAAA,KAAAF,EACAE,EAAA,OAAA,IAAAC,EAAA,EACAD,EAAA,QAAA,IAAAE,EAAA,yBAE2B,CAAA"}
|
package/utils/css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.js","sources":["../../src/core/utils/css.ts"],"sourcesContent":["/**\
|
|
1
|
+
{"version":3,"file":"css.js","sources":["../../src/core/utils/css.ts"],"sourcesContent":["/**\n * Вставить css стили на страницу с автоматическим определением media\n * @param fileNames - список ссылок на css файлы\n */\nexport const insertToPage = async (fileNames: Array<string>) => {\n\tconst cssFilesByOptions = new Map();\n\tcssFilesByOptions.set('::', []);\n\n\tfileNames.forEach(filename => {\n\t\tlet m = false;\n\t\tlet pc = false;\n\n\t\tif (filename.match(/\\.m\\./)) {\n\t\t\tm = true;\n\t\t}\n\t\tif (filename.match(/\\.pc\\./)) {\n\t\t\tpc = true;\n\t\t}\n\n\t\tconst key = `${m}:${pc}`;\n\t\tif (!cssFilesByOptions.has(key)) {\n\t\t\tcssFilesByOptions.set(`${m}:${pc}`, []);\n\t\t}\n\t\tcssFilesByOptions.get(`${m}:${pc}`).push(filename);\n\t});\n\n\tconst promises: Array<Promise<unknown>> = [];\n\n\tcssFilesByOptions.forEach((fileNames, options: string) => {\n\t\tif (!fileNames.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [m, pc] = options.split(':').map(item => item === 'true');\n\n\t\tlet media = 'all';\n\t\tif (m) {\n\t\t\tmedia = '(max-width: 900px)';\n\t\t}\n\t\tif (pc) {\n\t\t\tmedia = '(min-width: 900px)';\n\t\t}\n\n\t\tconst promisesI = _insertToPage(fileNames, media);\n\t\tpromisesI.forEach(promise => promises.push(promise));\n\t});\n\n\treturn await Promise.all(promises);\n};\n\nconst _insertToPage = (fileNames: Array<string>, media: string): Array<Promise<unknown>> => {\n\tconst promises: Array<Promise<unknown>> = [];\n\n\tfileNames.forEach(fileName => {\n\t\tconst id = 'topCSSLink-' + fileName.replace(/\\W/g, '-');\n\n\t\t// стиль уже загружен\n\t\tif (window.hasOwnProperty(id)) return;\n\n\t\tlet resolve: Function;\n\t\tlet reject: Function;\n\t\tconst promise = new Promise((_resolve, _reject) => {\n\t\t\tresolve = _resolve;\n\t\t\treject = _reject;\n\t\t});\n\t\tpromises.push(promise);\n\n\t\tconst elLink = document.createElement('link');\n\t\telLink.id = id;\n\t\telLink.rel = 'stylesheet';\n\t\telLink.media = media;\n\t\telLink.href = fileName;\n\t\telLink.onload = () => resolve();\n\t\telLink.onerror = () => reject();\n\n\t\tdocument.head.append(elLink);\n\t});\n\n\treturn promises;\n};"],"names":["insertToPage","fileNames","cssFilesByOptions","filename","m","pc","key","promises","options","item","media","_insertToPage","promise","fileName","id","resolve","reject","_resolve","_reject","elLink"],"mappings":"AAIa,MAAAA,IAAe,OAAOC,MAA6B;AACzD,QAAAC,wBAAwB;AACZ,EAAAA,EAAA,IAAI,MAAM,CAAA,CAAE,GAE9BD,EAAU,QAAQ,CAAYE,MAAA;AAC7B,QAAIC,IAAI,IACJC,IAAK;AAEL,IAAAF,EAAS,MAAM,OAAO,MACrBC,IAAA,KAEDD,EAAS,MAAM,QAAQ,MACrBE,IAAA;AAGN,UAAMC,IAAM,GAAGF,CAAC,IAAIC,CAAE;AACtB,IAAKH,EAAkB,IAAII,CAAG,KAC7B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|
1
|
+
define(["require","exports","../.chunks/forms-DujTMzoW.amd"],function(n,e,t){"use strict";if(typeof a>"u")var a=window.Vue;e.dateFormat=t.dateFormat,e.dateUnformat=t.dateUnformat,e.genDate=t.genDate,e.stringToDate=t.stringToDate,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=date.amd.js.map
|
package/utils/date.js
CHANGED
package/utils/device.amd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
define(["require","exports","../.chunks/forms-
|
|
1
|
+
define(["require","exports","../.chunks/forms-DujTMzoW.amd"],function(n,i,e){"use strict";if(typeof a>"u")var a=window.Vue;i.getCommandKeyLabel=e.getCommandKeyLabel,i.isApp=e.isApp,i.isMacOS=e.isMacOS,i.isMobile=e.isMobile,i.isRetina=e.isRetina,i.isSafari=e.isSafari,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=device.amd.js.map
|