@topvisor/ui 1.0.26-1 → 1.0.26-11
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/dialog_selectorRegions-DZR64Wm8.es.js +181 -0
- package/.chunks/dialog_selectorRegions-DZR64Wm8.es.js.map +1 -0
- package/.chunks/dialog_selectorRegions-D_HXNjOX.amd.js +2 -0
- package/.chunks/dialog_selectorRegions-D_HXNjOX.amd.js.map +1 -0
- package/assets/extra.css +1 -0
- package/components/extra/extra.d.ts +3 -0
- package/components/extra/rive/rive.vue.d.ts +11 -0
- package/components/extra/rive/types.d.ts +7 -0
- package/components/formsExt/selector2/selector2.d.ts +4 -0
- package/components/formsExt/selector2/selector2.vue.d.ts +1 -0
- package/components/project/selectorRegion/dialog_selectorRegions/dialog_selectorRegions.vue.d.ts +3 -1
- package/components/project/selectorRegion/utils/utils.d.ts +3 -1
- package/core/app.amd.js +1 -1
- package/core/app.amd.js.map +1 -1
- package/core/app.js +24 -24
- package/core/app.js.map +1 -1
- package/core/utils/searchers.d.ts +1 -1
- package/extra/extra.amd.js +2 -0
- package/extra/extra.amd.js.map +1 -0
- package/extra/extra.d.ts +2 -0
- package/extra/extra.js +72 -0
- package/extra/extra.js.map +1 -0
- package/formsExt/formsExt.amd.js +1 -1
- package/formsExt/formsExt.amd.js.map +1 -1
- package/formsExt/formsExt.js +129 -123
- package/formsExt/formsExt.js.map +1 -1
- package/package.json +1 -1
- package/project/project.amd.js +1 -1
- package/project/project.js +1 -1
- package/utils/searchers.amd.js.map +1 -1
- package/utils/searchers.js.map +1 -1
- package/.chunks/dialog_selectorRegions-BOPta9cH.amd.js +0 -2
- package/.chunks/dialog_selectorRegions-BOPta9cH.amd.js.map +0 -1
- package/.chunks/dialog_selectorRegions-Dy0AlECS.es.js +0 -140
- package/.chunks/dialog_selectorRegions-Dy0AlECS.es.js.map +0 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Core as P } from "../core/app.js";
|
|
2
|
+
import { defineComponent as M, ref as k, reactive as O, watch as L, resolveComponent as V, createBlock as N, openBlock as u, unref as C, withCtx as m, createVNode as p, createTextVNode as B, toDisplayString as v, createElementVNode as f, createElementBlock as y, Fragment as G, renderList as X, createCommentVNode as b } from "vue";
|
|
3
|
+
import { _ as Q, a as q } from "./page.vue_vue_type_script_setup_true_lang-CCE8pKg7.es.js";
|
|
4
|
+
import { b as z } from "./utils-DIly8mml.es.js";
|
|
5
|
+
import { genFlagLinkByCountryCode as H } from "../utils/string.js";
|
|
6
|
+
import { getSearcherGIcon as J, getLangLabel as K, getDeviceGIcon as W } from "../utils/searchers.js";
|
|
7
|
+
import { C as A } from "./forms-BEMrEl5V.es.js";
|
|
8
|
+
const D = ["../assets/dialog_selectorRegions.css"].map((x) => import.meta.resolve(x));
|
|
9
|
+
P.insertCSSLinkToPage(D, !0);
|
|
10
|
+
const Y = { class: "dialog_selectorRegions_header" }, Z = ["data-top-icon"], F = ["src", "alt"], ee = { class: "dialog_selectorRegions_regionAreaName top-ellipsis" }, oe = { key: 1 }, te = ["data-top-icon"], de = /* @__PURE__ */ M({
|
|
11
|
+
id: "selectorRegions",
|
|
12
|
+
__name: "dialog_selectorRegions",
|
|
13
|
+
props: {
|
|
14
|
+
regions: {},
|
|
15
|
+
regionsIndexes: {},
|
|
16
|
+
"@update:regionsIndexes": { type: Function }
|
|
17
|
+
},
|
|
18
|
+
setup(x) {
|
|
19
|
+
const l = x, I = z(), _ = k(!1), a = k([]), i = k(null), g = O({
|
|
20
|
+
searcher_key: -1,
|
|
21
|
+
key: -1,
|
|
22
|
+
name: -1
|
|
23
|
+
}), h = (o) => {
|
|
24
|
+
g[o] = -g[o], a.value.sort((n, s) => !n[o] || !s[o] ? -1 : n[o] >= s[o] ? g[o] : -g[o]);
|
|
25
|
+
}, T = () => {
|
|
26
|
+
var n;
|
|
27
|
+
if (!a.value.some((s) => s.selected)) return;
|
|
28
|
+
const o = a.value.filter((s) => s.selected).map((s) => s.index);
|
|
29
|
+
(n = l["@update:regionsIndexes"]) == null || n.call(l, o), I.close();
|
|
30
|
+
};
|
|
31
|
+
L(_, () => {
|
|
32
|
+
a.value = a.value.map((o) => ({ ...o, selected: _.value }));
|
|
33
|
+
}), L([
|
|
34
|
+
() => l.regions,
|
|
35
|
+
() => l.regionsIndexes
|
|
36
|
+
], () => {
|
|
37
|
+
if (a.value = [], !l.regions || !l.regionsIndexes) return;
|
|
38
|
+
let o = !0, n = [...l.regions];
|
|
39
|
+
const s = new Map(l.regionsIndexes.map((t, e) => [t, e]));
|
|
40
|
+
n.sort((t, e) => {
|
|
41
|
+
const r = s.get(t.index) ?? Number.MAX_VALUE, c = s.get(e.index) ?? Number.MAX_VALUE;
|
|
42
|
+
return r - c;
|
|
43
|
+
}), n.forEach((t) => {
|
|
44
|
+
var S;
|
|
45
|
+
let e = t.name;
|
|
46
|
+
t.areaName && (e += ` (${t.areaName})`);
|
|
47
|
+
const r = ((S = l.regionsIndexes) == null ? void 0 : S.includes(t.index)) ?? !1, c = J(t.searcher_key), d = t.lang !== void 0 ? K(t.searcher_key ?? 999, t.lang) : void 0, j = t.device !== void 0 ? W(t.device) : void 0, w = t.countryCode !== void 0 ? H(t.countryCode) : void 0, R = {
|
|
48
|
+
...t,
|
|
49
|
+
selected: r,
|
|
50
|
+
title: e,
|
|
51
|
+
searcherIcon: c,
|
|
52
|
+
langLabel: d,
|
|
53
|
+
deviceIcon: j,
|
|
54
|
+
flagLink: w
|
|
55
|
+
};
|
|
56
|
+
a.value.push(R), R.selected || (o = !1);
|
|
57
|
+
}), _.value = o;
|
|
58
|
+
});
|
|
59
|
+
const U = () => {
|
|
60
|
+
var o;
|
|
61
|
+
if (!((o = A.$) != null && o.ui.sortable)) {
|
|
62
|
+
console.info("Для работы сортировки требуется глобальная загрузка jQuery UI Sortable");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
i.value && $(i.value).sortable({
|
|
66
|
+
distance: 10,
|
|
67
|
+
stop: () => {
|
|
68
|
+
const n = [...i.value.children].map((s) => Number(s.getAttribute("data-region-index")));
|
|
69
|
+
a.value.sort((s, t) => n.indexOf(s.index) - n.indexOf(t.index));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}, E = () => {
|
|
73
|
+
var o;
|
|
74
|
+
(o = A.$) != null && o.ui.sortable && i.value && $(i.value).sortable("destroy");
|
|
75
|
+
};
|
|
76
|
+
return (o, n) => {
|
|
77
|
+
const s = V("TopCheckbox"), t = V("TopButton");
|
|
78
|
+
return u(), N(C(Q), {
|
|
79
|
+
id: C(I).id,
|
|
80
|
+
pageActive: "selectorRegions",
|
|
81
|
+
class: "dialog_selectorRegions",
|
|
82
|
+
height: "600px",
|
|
83
|
+
width: "600px",
|
|
84
|
+
onOpen: U,
|
|
85
|
+
onClose: E
|
|
86
|
+
}, {
|
|
87
|
+
default: m(() => [
|
|
88
|
+
p(C(q), {
|
|
89
|
+
name: "selectorRegions",
|
|
90
|
+
order: 0
|
|
91
|
+
}, {
|
|
92
|
+
header: m(() => {
|
|
93
|
+
var e, r, c;
|
|
94
|
+
return [
|
|
95
|
+
f("div", Y, [
|
|
96
|
+
p(s, {
|
|
97
|
+
modelValue: _.value,
|
|
98
|
+
"onUpdate:modelValue": n[0] || (n[0] = (d) => _.value = d)
|
|
99
|
+
}, null, 8, ["modelValue"]),
|
|
100
|
+
p(t, {
|
|
101
|
+
class: "dialog_selectorRegions_sortButton",
|
|
102
|
+
color: "theme",
|
|
103
|
+
"data-top-icon": "",
|
|
104
|
+
onClick: n[1] || (n[1] = (d) => h("searcher_key")),
|
|
105
|
+
title: (e = o.$i18n.Projects) == null ? void 0 : e.Sort_by_search_engine
|
|
106
|
+
}, null, 8, ["title"]),
|
|
107
|
+
p(t, {
|
|
108
|
+
class: "dialog_selectorRegions_sortButton",
|
|
109
|
+
color: "theme",
|
|
110
|
+
"data-top-icon": "",
|
|
111
|
+
onClick: n[2] || (n[2] = (d) => h("key")),
|
|
112
|
+
title: (r = o.$i18n.Projects) == null ? void 0 : r.Sort_by_yande_region_code
|
|
113
|
+
}, null, 8, ["title"]),
|
|
114
|
+
p(t, {
|
|
115
|
+
class: "dialog_selectorRegions_sortButton",
|
|
116
|
+
color: "theme",
|
|
117
|
+
"data-top-icon": "",
|
|
118
|
+
onClick: n[3] || (n[3] = (d) => h("name")),
|
|
119
|
+
title: (c = o.$i18n.Projects) == null ? void 0 : c.Sort_by_lphabetically
|
|
120
|
+
}, null, 8, ["title"])
|
|
121
|
+
])
|
|
122
|
+
];
|
|
123
|
+
}),
|
|
124
|
+
body: m(() => [
|
|
125
|
+
f("div", {
|
|
126
|
+
ref_key: "elRegions",
|
|
127
|
+
ref: i
|
|
128
|
+
}, [
|
|
129
|
+
(u(!0), y(G, null, X(a.value, (e) => (u(), N(s, {
|
|
130
|
+
key: e.index,
|
|
131
|
+
modelValue: e.selected,
|
|
132
|
+
"onUpdate:modelValue": (r) => e.selected = r,
|
|
133
|
+
class: "dialog_selectorRegions_region",
|
|
134
|
+
"data-region-index": e.index
|
|
135
|
+
}, {
|
|
136
|
+
default: m(() => [
|
|
137
|
+
f("div", {
|
|
138
|
+
class: "dialog_selectorRegions_regionSearcherIcon",
|
|
139
|
+
"data-top-icon": e.searcherIcon
|
|
140
|
+
}, null, 8, Z),
|
|
141
|
+
e.flagLink ? (u(), y("img", {
|
|
142
|
+
key: 0,
|
|
143
|
+
class: "top-flag",
|
|
144
|
+
src: "//topvisor.dev" + e.flagLink,
|
|
145
|
+
alt: e.countryCode
|
|
146
|
+
}, null, 8, F)) : b("", !0),
|
|
147
|
+
B(" " + v(e.name) + " ", 1),
|
|
148
|
+
f("div", ee, v(e.areaName), 1),
|
|
149
|
+
e.langLabel ? (u(), y("div", oe, " [" + v(e.langLabel) + "] ", 1)) : b("", !0),
|
|
150
|
+
e.deviceIcon ? (u(), y("div", {
|
|
151
|
+
key: 2,
|
|
152
|
+
"data-top-icon": e.deviceIcon
|
|
153
|
+
}, null, 8, te)) : b("", !0)
|
|
154
|
+
]),
|
|
155
|
+
_: 2
|
|
156
|
+
}, 1032, ["modelValue", "onUpdate:modelValue", "data-region-index"]))), 128))
|
|
157
|
+
], 512)
|
|
158
|
+
]),
|
|
159
|
+
footer: m(() => [
|
|
160
|
+
p(t, { onClick: T }, {
|
|
161
|
+
default: m(() => {
|
|
162
|
+
var e;
|
|
163
|
+
return [
|
|
164
|
+
B(v((e = o.$i18n.Common) == null ? void 0 : e.Apply), 1)
|
|
165
|
+
];
|
|
166
|
+
}),
|
|
167
|
+
_: 1
|
|
168
|
+
})
|
|
169
|
+
]),
|
|
170
|
+
_: 1
|
|
171
|
+
})
|
|
172
|
+
]),
|
|
173
|
+
_: 1
|
|
174
|
+
}, 8, ["id"]);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
export {
|
|
179
|
+
de as default
|
|
180
|
+
};
|
|
181
|
+
//# sourceMappingURL=dialog_selectorRegions-DZR64Wm8.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog_selectorRegions-DZR64Wm8.es.js","sources":["../../src/components/project/selectorRegion/dialog_selectorRegions/dialog_selectorRegions.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { reactive, ref, watch } from 'vue';\nimport { TopDialog, TopDialogPage, useTopDialogSelf } from '@/components/dialog/dialog';\nimport { genFlagLinkByCountryCode } from '@/core/utils/string';\nimport type { Props, RegionRich } from './types';\nimport { getDeviceGIcon, getLangLabel, getSearcherGIcon } from '@/core/utils/searchers';\nimport Core from '@/core/core/core';\n\ndefineOptions({ id: 'selectorRegions' });\n\nconst props = defineProps<Partial<Props>>();\n\nconst dialog = useTopDialogSelf();\n\n/**\n * Выбраны все регионы\n */\nconst isAllSelected = ref(false);\n\n/**\n * Список расширенных регионов для использования в компоненте\n */\nconst regionsRich = ref<RegionRich[]>([]);\n\n/**\n * Ссылка на элемент с регионами\n */\nconst elRegions = ref<null | HTMLElement>(null);\n\n/**\n * Направление сортировки по полю\n */\nconst sortedVectorByField = reactive({\n\tsearcher_key: -1,\n\tkey: -1,\n\tname: -1,\n});\n\n/**\n * Сортировать регионы по выбранному полю\n * @param sortedField - Поле для сортировки\n */\nconst sort = (sortedField: keyof typeof sortedVectorByField) => {\n\tsortedVectorByField[sortedField] = -sortedVectorByField[sortedField];\n\n\tregionsRich.value.sort((regionA, regionB) => {\n\t\tif (!regionA[sortedField] || !regionB[sortedField]) return -1;\n\n\t\treturn regionA[sortedField] >= regionB[sortedField] ? sortedVectorByField[sortedField] : -sortedVectorByField[sortedField];\n\t});\n};\n\n/**\n * Применить изменения\n *\n * Вызывает callback `props['@update:regionsIndexes']`\n */\nconst onSubmit = () => {\n\tif (!regionsRich.value.some((region) => region.selected)) return;\n\n\tconst regionsIndexes = regionsRich.value\n\t\t.filter((region) => region.selected)\n\t\t.map((region) => region.index);\n\n\tprops['@update:regionsIndexes']?.(regionsIndexes);\n\n\tdialog.close();\n};\n\n// Выбрать / отменить все регионы\nwatch(isAllSelected, () => {\n\tregionsRich.value = regionsRich.value.map((region) => ({ ...region, selected: isAllSelected.value }));\n});\n\n// генерация регионов\nwatch([\n\t() => props.regions,\n\t() => props.regionsIndexes,\n], () => {\n\tregionsRich.value = [];\n\n\tif (!props.regions) return;\n\tif (!props.regionsIndexes) return;\n\n\tlet isAllSelectedLocal = true;\n\n\tlet regions = [...props.regions];\n\n\t// отсортировать регионы по входным данным\n\tconst orderByRegionIndex = new Map(props.regionsIndexes.map((index, order) => [index, order]));\n\n\tregions.sort((regionA, regionB) => {\n\t\tconst orderA = orderByRegionIndex.get(regionA.index) ?? Number.MAX_VALUE;\n\t\tconst orderB = orderByRegionIndex.get(regionB.index) ?? Number.MAX_VALUE;\n\n\t\treturn orderA - orderB;\n\t});\n\n\tregions.forEach((region) => {\n\t\tlet title = region.name;\n\t\tif (region.areaName) title += ` (${region.areaName})`;\n\n\t\tconst selected = props.regionsIndexes?.includes(region.index) ?? false;\n\t\tconst searcherIcon = getSearcherGIcon(region.searcher_key);\n\t\tconst langLabel = region.lang !== undefined ? getLangLabel(region.searcher_key ?? 999, region.lang) : undefined;\n\t\tconst deviceIcon = region.device !== undefined ? getDeviceGIcon(region.device) : undefined;\n\t\tconst flagLink = region.countryCode !== undefined ? genFlagLinkByCountryCode(region.countryCode) : undefined;\n\n\t\tconst regionRich = {\n\t\t\t...region,\n\t\t\tselected,\n\t\t\ttitle,\n\t\t\tsearcherIcon,\n\t\t\tlangLabel,\n\t\t\tdeviceIcon,\n\t\t\tflagLink,\n\t\t};\n\n\t\tregionsRich.value.push(regionRich);\n\n\t\tif (!regionRich.selected) {\n\t\t\tisAllSelectedLocal = false;\n\t\t}\n\t});\n\n\tisAllSelected.value = isAllSelectedLocal;\n});\n\n/**\n * Проверить на существование sortable\n */\nconst onOpen = () => {\n\tif (!Core.$?.ui['sortable']) {\n\t\tconsole.info('Для работы сортировки требуется глобальная загрузка jQuery UI Sortable');\n\n\t\treturn;\n\t}\n\n\tif (!elRegions.value) return;\n\n\t$(elRegions.value).sortable({\n\t\tdistance: 10,\n\n\t\tstop: () => {\n\t\t\t// Обновляем порядок регионов в массиве regionsRich после сортировки\n\t\t\tconst sortedIndexes = [...elRegions.value!.children].map(el => Number(el.getAttribute('data-region-index')));\n\t\t\tregionsRich.value.sort((a, b) => sortedIndexes.indexOf(a.index) - sortedIndexes.indexOf(b.index));\n\t\t},\n\t});\n\n};\n\n/**\n * Удаление sortable\n */\nconst onClose = () => {\n\tif (!Core.$?.ui['sortable']) return;\n\tif (!elRegions.value) return;\n\n\t$(elRegions.value).sortable('destroy');\n};\n\n</script>\n\n<template>\n\t<TopDialog\n\t\t:id=\"dialog.id\"\n\t\tpageActive=\"selectorRegions\"\n\t\tclass=\"dialog_selectorRegions\"\n\t\theight=\"600px\"\n\t\twidth=\"600px\"\n\t\t@open=\"onOpen\"\n\t\t@close=\"onClose\"\n\t>\n\t\t<TopDialogPage name=\"selectorRegions\" :order=\"0\">\n\t\t\t<template #header>\n\t\t\t\t<div class=\"dialog_selectorRegions_header\">\n\t\t\t\t\t<TopCheckbox v-model=\"isAllSelected\"></TopCheckbox>\n\n\t\t\t\t\t<TopButton\n\t\t\t\t\t\tclass=\"dialog_selectorRegions_sortButton\"\n\t\t\t\t\t\tcolor=\"theme\"\n\t\t\t\t\t\tdata-top-icon=\"\"\n\t\t\t\t\t\t@click=\"sort('searcher_key')\"\n\t\t\t\t\t\t:title=\"$i18n.Projects?.Sort_by_search_engine\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<TopButton\n\t\t\t\t\t\tclass=\"dialog_selectorRegions_sortButton\"\n\t\t\t\t\t\tcolor=\"theme\"\n\t\t\t\t\t\tdata-top-icon=\"\"\n\t\t\t\t\t\t@click=\"sort('key')\"\n\t\t\t\t\t\t:title=\"$i18n.Projects?.Sort_by_yande_region_code\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<TopButton\n\t\t\t\t\t\tclass=\"dialog_selectorRegions_sortButton\"\n\t\t\t\t\t\tcolor=\"theme\"\n\t\t\t\t\t\tdata-top-icon=\"\"\n\t\t\t\t\t\t@click=\"sort('name')\"\n\t\t\t\t\t\t:title=\"$i18n.Projects?.Sort_by_lphabetically\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</template>\n\n\t\t\t<template #body>\n\t\t\t\t<div ref=\"elRegions\">\n\t\t\t\t\t<TopCheckbox\n\t\t\t\t\t\tv-for=\"region of regionsRich\"\n\t\t\t\t\t\t:key=\"region.index\"\n\t\t\t\t\t\tv-model=\"region.selected\"\n\t\t\t\t\t\tclass=\"dialog_selectorRegions_region\"\n\t\t\t\t\t\t:data-region-index=\"region.index\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclass=\"dialog_selectorRegions_regionSearcherIcon\"\n\t\t\t\t\t\t\t:data-top-icon=\"region.searcherIcon\"\n\t\t\t\t\t\t></div>\n\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tv-if=\"region.flagLink\"\n\t\t\t\t\t\t\tclass=\"top-flag\"\n\t\t\t\t\t\t\t:src=\"'//topvisor.dev' + region.flagLink\"\n\t\t\t\t\t\t\t:alt=\"region.countryCode\"\n\t\t\t\t\t\t>\n\n\t\t\t\t\t\t{{ region.name }}\n\n\t\t\t\t\t\t<div class=\"dialog_selectorRegions_regionAreaName top-ellipsis\">\n\t\t\t\t\t\t\t{{ region.areaName }}\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div v-if=\"region.langLabel\">\n\t\t\t\t\t\t\t[{{ region.langLabel }}]\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tv-if=\"region.deviceIcon\"\n\t\t\t\t\t\t\t:data-top-icon=\"region.deviceIcon\"\n\t\t\t\t\t\t></div>\n\t\t\t\t\t</TopCheckbox>\n\t\t\t\t</div>\n\t\t\t</template>\n\n\t\t\t<template #footer>\n\t\t\t\t<TopButton @click=\"onSubmit\">\n\t\t\t\t\t{{ $i18n.Common?.Apply }}\n\t\t\t\t</TopButton>\n\t\t\t</template>\n\t\t</TopDialogPage>\n\t</TopDialog>\n</template>\n\n<style>\n@import \"./style.css\";\n</style>\n"],"names":["props","__props","dialog","useTopDialogSelf","isAllSelected","ref","regionsRich","elRegions","sortedVectorByField","reactive","sort","sortedField","regionA","regionB","onSubmit","region","regionsIndexes","_a","watch","isAllSelectedLocal","regions","orderByRegionIndex","index","order","orderA","orderB","title","selected","searcherIcon","getSearcherGIcon","langLabel","getLangLabel","deviceIcon","getDeviceGIcon","flagLink","genFlagLinkByCountryCode","regionRich","onOpen","Core","sortedIndexes","el","a","b","onClose"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,UAAAA,IAAAC,GAEAC,IAAAC,EAAA,GAKAC,IAAAC,EAAA,EAAA,GAKAC,IAAAD,EAAA,CAAA,CAAA,GAKAE,IAAAF,EAAA,IAAA,GAKAG,IAAAC,EAAA;AAAA,MAAqC,cAAA;AAAA,MAC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AA;AAAA,QAAgG;AAAA,MACjG,CAAA;AAAA,IACA,GAOFC,IAAA,MAAA;;AACC,OAAA1B,IAAAqB,EAAA,MAAA,QAAArB,EAAA,GAAA,YACAV,EAAA,SAEA,EAAAA,EAAA,KAAA,EAAA,SAAA,SAAA;AAAA,IAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
define(["require","exports","vue","./page.vue_vue_type_script_setup_true_lang-BI9HWAyQ.amd","./utils-CTjq0RlC.amd","../utils/string.amd","../utils/searchers.amd","./forms-B3bJpLOo.amd","../require/css.amd!../assets/dialog_selectorRegions.css"],function(j,_,e,f,C,V,g,y){"use strict";if(typeof e>"u")var e=window.Vue;const b={class:"dialog_selectorRegions_header"},N=["data-top-icon"],B=["src","alt"],I={class:"dialog_selectorRegions_regionAreaName top-ellipsis"},R={key:1},S=["data-top-icon"],L=e.defineComponent({id:"selectorRegions",__name:"dialog_selectorRegions",props:{regions:{},regionsIndexes:{},"@update:regionsIndexes":{type:Function}},setup(w){const s=w,k=C.useTopDialogSelf(),m=e.ref(!1),r=e.ref([]),i=e.ref(null),p=e.reactive({searcher_key:-1,key:-1,name:-1}),v=o=>{p[o]=-p[o],r.value.sort((l,a)=>!l[o]||!a[o]?-1:l[o]>=a[o]?p[o]:-p[o])},E=()=>{var l;if(!r.value.some(a=>a.selected))return;const o=r.value.filter(a=>a.selected).map(a=>a.index);(l=s["@update:regionsIndexes"])==null||l.call(s,o),k.close()};e.watch(m,()=>{r.value=r.value.map(o=>({...o,selected:m.value}))}),e.watch([()=>s.regions,()=>s.regionsIndexes],()=>{if(r.value=[],!s.regions||!s.regionsIndexes)return;let o=!0,l=[...s.regions];const a=new Map(s.regionsIndexes.map((n,t)=>[n,t]));l.sort((n,t)=>{const c=a.get(n.index)??Number.MAX_VALUE,d=a.get(t.index)??Number.MAX_VALUE;return c-d}),l.forEach(n=>{var h;let t=n.name;n.areaName&&(t+=` (${n.areaName})`);const c=((h=s.regionsIndexes)==null?void 0:h.includes(n.index))??!1,d=g.getSearcherGIcon(n.searcher_key),u=n.lang!==void 0?g.getLangLabel(n.searcher_key??999,n.lang):void 0,D=n.device!==void 0?g.getDeviceGIcon(n.device):void 0,U=n.countryCode!==void 0?V.genFlagLinkByCountryCode(n.countryCode):void 0,x={...n,selected:c,title:t,searcherIcon:d,langLabel:u,deviceIcon:D,flagLink:U};r.value.push(x),x.selected||(o=!1)}),m.value=o});const A=()=>{var o;if(!((o=y.Core.$)!=null&&o.ui.sortable)){console.info("Для работы сортировки требуется глобальная загрузка jQuery UI Sortable");return}i.value&&$(i.value).sortable({distance:10,stop:()=>{const l=[...i.value.children].map(a=>Number(a.getAttribute("data-region-index")));r.value.sort((a,n)=>l.indexOf(a.index)-l.indexOf(n.index))}})},T=()=>{var o;(o=y.Core.$)!=null&&o.ui.sortable&&i.value&&$(i.value).sortable("destroy")};return(o,l)=>{const a=e.resolveComponent("TopCheckbox"),n=e.resolveComponent("TopButton");return e.openBlock(),e.createBlock(e.unref(f._sfc_main),{id:e.unref(k).id,pageActive:"selectorRegions",class:"dialog_selectorRegions",height:"600px",width:"600px",onOpen:A,onClose:T},{default:e.withCtx(()=>[e.createVNode(e.unref(f._sfc_main$1),{name:"selectorRegions",order:0},{header:e.withCtx(()=>{var t,c,d;return[e.createElementVNode("div",b,[e.createVNode(a,{modelValue:m.value,"onUpdate:modelValue":l[0]||(l[0]=u=>m.value=u)},null,8,["modelValue"]),e.createVNode(n,{class:"dialog_selectorRegions_sortButton",color:"theme","data-top-icon":"",onClick:l[1]||(l[1]=u=>v("searcher_key")),title:(t=o.$i18n.Projects)==null?void 0:t.Sort_by_search_engine},null,8,["title"]),e.createVNode(n,{class:"dialog_selectorRegions_sortButton",color:"theme","data-top-icon":"",onClick:l[2]||(l[2]=u=>v("key")),title:(c=o.$i18n.Projects)==null?void 0:c.Sort_by_yande_region_code},null,8,["title"]),e.createVNode(n,{class:"dialog_selectorRegions_sortButton",color:"theme","data-top-icon":"",onClick:l[3]||(l[3]=u=>v("name")),title:(d=o.$i18n.Projects)==null?void 0:d.Sort_by_lphabetically},null,8,["title"])])]}),body:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"elRegions",ref:i},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,t=>(e.openBlock(),e.createBlock(a,{key:t.index,modelValue:t.selected,"onUpdate:modelValue":c=>t.selected=c,class:"dialog_selectorRegions_region","data-region-index":t.index},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"dialog_selectorRegions_regionSearcherIcon","data-top-icon":t.searcherIcon},null,8,N),t.flagLink?(e.openBlock(),e.createElementBlock("img",{key:0,class:"top-flag",src:"//topvisor.dev"+t.flagLink,alt:t.countryCode},null,8,B)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(t.name)+" ",1),e.createElementVNode("div",I,e.toDisplayString(t.areaName),1),t.langLabel?(e.openBlock(),e.createElementBlock("div",R," ["+e.toDisplayString(t.langLabel)+"] ",1)):e.createCommentVNode("",!0),t.deviceIcon?(e.openBlock(),e.createElementBlock("div",{key:2,"data-top-icon":t.deviceIcon},null,8,S)):e.createCommentVNode("",!0)]),_:2},1032,["modelValue","onUpdate:modelValue","data-region-index"]))),128))],512)]),footer:e.withCtx(()=>[e.createVNode(n,{onClick:E},{default:e.withCtx(()=>{var t;return[e.createTextVNode(e.toDisplayString((t=o.$i18n.Common)==null?void 0:t.Apply),1)]}),_:1})]),_:1})]),_:1},8,["id"])}}});_.default=L,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
2
|
+
//# sourceMappingURL=dialog_selectorRegions-D_HXNjOX.amd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog_selectorRegions-D_HXNjOX.amd.js","sources":["../../src/components/project/selectorRegion/dialog_selectorRegions/dialog_selectorRegions.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { reactive, ref, watch } from 'vue';\nimport { TopDialog, TopDialogPage, useTopDialogSelf } from '@/components/dialog/dialog';\nimport { genFlagLinkByCountryCode } from '@/core/utils/string';\nimport type { Props, RegionRich } from './types';\nimport { getDeviceGIcon, getLangLabel, getSearcherGIcon } from '@/core/utils/searchers';\nimport Core from '@/core/core/core';\n\ndefineOptions({ id: 'selectorRegions' });\n\nconst props = defineProps<Partial<Props>>();\n\nconst dialog = useTopDialogSelf();\n\n/**\n * Выбраны все регионы\n */\nconst isAllSelected = ref(false);\n\n/**\n * Список расширенных регионов для использования в компоненте\n */\nconst regionsRich = ref<RegionRich[]>([]);\n\n/**\n * Ссылка на элемент с регионами\n */\nconst elRegions = ref<null | HTMLElement>(null);\n\n/**\n * Направление сортировки по полю\n */\nconst sortedVectorByField = reactive({\n\tsearcher_key: -1,\n\tkey: -1,\n\tname: -1,\n});\n\n/**\n * Сортировать регионы по выбранному полю\n * @param sortedField - Поле для сортировки\n */\nconst sort = (sortedField: keyof typeof sortedVectorByField) => {\n\tsortedVectorByField[sortedField] = -sortedVectorByField[sortedField];\n\n\tregionsRich.value.sort((regionA, regionB) => {\n\t\tif (!regionA[sortedField] || !regionB[sortedField]) return -1;\n\n\t\treturn regionA[sortedField] >= regionB[sortedField] ? sortedVectorByField[sortedField] : -sortedVectorByField[sortedField];\n\t});\n};\n\n/**\n * Применить изменения\n *\n * Вызывает callback `props['@update:regionsIndexes']`\n */\nconst onSubmit = () => {\n\tif (!regionsRich.value.some((region) => region.selected)) return;\n\n\tconst regionsIndexes = regionsRich.value\n\t\t.filter((region) => region.selected)\n\t\t.map((region) => region.index);\n\n\tprops['@update:regionsIndexes']?.(regionsIndexes);\n\n\tdialog.close();\n};\n\n// Выбрать / отменить все регионы\nwatch(isAllSelected, () => {\n\tregionsRich.value = regionsRich.value.map((region) => ({ ...region, selected: isAllSelected.value }));\n});\n\n// генерация регионов\nwatch([\n\t() => props.regions,\n\t() => props.regionsIndexes,\n], () => {\n\tregionsRich.value = [];\n\n\tif (!props.regions) return;\n\tif (!props.regionsIndexes) return;\n\n\tlet isAllSelectedLocal = true;\n\n\tlet regions = [...props.regions];\n\n\t// отсортировать регионы по входным данным\n\tconst orderByRegionIndex = new Map(props.regionsIndexes.map((index, order) => [index, order]));\n\n\tregions.sort((regionA, regionB) => {\n\t\tconst orderA = orderByRegionIndex.get(regionA.index) ?? Number.MAX_VALUE;\n\t\tconst orderB = orderByRegionIndex.get(regionB.index) ?? Number.MAX_VALUE;\n\n\t\treturn orderA - orderB;\n\t});\n\n\tregions.forEach((region) => {\n\t\tlet title = region.name;\n\t\tif (region.areaName) title += ` (${region.areaName})`;\n\n\t\tconst selected = props.regionsIndexes?.includes(region.index) ?? false;\n\t\tconst searcherIcon = getSearcherGIcon(region.searcher_key);\n\t\tconst langLabel = region.lang !== undefined ? getLangLabel(region.searcher_key ?? 999, region.lang) : undefined;\n\t\tconst deviceIcon = region.device !== undefined ? getDeviceGIcon(region.device) : undefined;\n\t\tconst flagLink = region.countryCode !== undefined ? genFlagLinkByCountryCode(region.countryCode) : undefined;\n\n\t\tconst regionRich = {\n\t\t\t...region,\n\t\t\tselected,\n\t\t\ttitle,\n\t\t\tsearcherIcon,\n\t\t\tlangLabel,\n\t\t\tdeviceIcon,\n\t\t\tflagLink,\n\t\t};\n\n\t\tregionsRich.value.push(regionRich);\n\n\t\tif (!regionRich.selected) {\n\t\t\tisAllSelectedLocal = false;\n\t\t}\n\t});\n\n\tisAllSelected.value = isAllSelectedLocal;\n});\n\n/**\n * Проверить на существование sortable\n */\nconst onOpen = () => {\n\tif (!Core.$?.ui['sortable']) {\n\t\tconsole.info('Для работы сортировки требуется глобальная загрузка jQuery UI Sortable');\n\n\t\treturn;\n\t}\n\n\tif (!elRegions.value) return;\n\n\t$(elRegions.value).sortable({\n\t\tdistance: 10,\n\n\t\tstop: () => {\n\t\t\t// Обновляем порядок регионов в массиве regionsRich после сортировки\n\t\t\tconst sortedIndexes = [...elRegions.value!.children].map(el => Number(el.getAttribute('data-region-index')));\n\t\t\tregionsRich.value.sort((a, b) => sortedIndexes.indexOf(a.index) - sortedIndexes.indexOf(b.index));\n\t\t},\n\t});\n\n};\n\n/**\n * Удаление sortable\n */\nconst onClose = () => {\n\tif (!Core.$?.ui['sortable']) return;\n\tif (!elRegions.value) return;\n\n\t$(elRegions.value).sortable('destroy');\n};\n\n</script>\n\n<template>\n\t<TopDialog\n\t\t:id=\"dialog.id\"\n\t\tpageActive=\"selectorRegions\"\n\t\tclass=\"dialog_selectorRegions\"\n\t\theight=\"600px\"\n\t\twidth=\"600px\"\n\t\t@open=\"onOpen\"\n\t\t@close=\"onClose\"\n\t>\n\t\t<TopDialogPage name=\"selectorRegions\" :order=\"0\">\n\t\t\t<template #header>\n\t\t\t\t<div class=\"dialog_selectorRegions_header\">\n\t\t\t\t\t<TopCheckbox v-model=\"isAllSelected\"></TopCheckbox>\n\n\t\t\t\t\t<TopButton\n\t\t\t\t\t\tclass=\"dialog_selectorRegions_sortButton\"\n\t\t\t\t\t\tcolor=\"theme\"\n\t\t\t\t\t\tdata-top-icon=\"\"\n\t\t\t\t\t\t@click=\"sort('searcher_key')\"\n\t\t\t\t\t\t:title=\"$i18n.Projects?.Sort_by_search_engine\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<TopButton\n\t\t\t\t\t\tclass=\"dialog_selectorRegions_sortButton\"\n\t\t\t\t\t\tcolor=\"theme\"\n\t\t\t\t\t\tdata-top-icon=\"\"\n\t\t\t\t\t\t@click=\"sort('key')\"\n\t\t\t\t\t\t:title=\"$i18n.Projects?.Sort_by_yande_region_code\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<TopButton\n\t\t\t\t\t\tclass=\"dialog_selectorRegions_sortButton\"\n\t\t\t\t\t\tcolor=\"theme\"\n\t\t\t\t\t\tdata-top-icon=\"\"\n\t\t\t\t\t\t@click=\"sort('name')\"\n\t\t\t\t\t\t:title=\"$i18n.Projects?.Sort_by_lphabetically\"\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</template>\n\n\t\t\t<template #body>\n\t\t\t\t<div ref=\"elRegions\">\n\t\t\t\t\t<TopCheckbox\n\t\t\t\t\t\tv-for=\"region of regionsRich\"\n\t\t\t\t\t\t:key=\"region.index\"\n\t\t\t\t\t\tv-model=\"region.selected\"\n\t\t\t\t\t\tclass=\"dialog_selectorRegions_region\"\n\t\t\t\t\t\t:data-region-index=\"region.index\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclass=\"dialog_selectorRegions_regionSearcherIcon\"\n\t\t\t\t\t\t\t:data-top-icon=\"region.searcherIcon\"\n\t\t\t\t\t\t></div>\n\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tv-if=\"region.flagLink\"\n\t\t\t\t\t\t\tclass=\"top-flag\"\n\t\t\t\t\t\t\t:src=\"'//topvisor.dev' + region.flagLink\"\n\t\t\t\t\t\t\t:alt=\"region.countryCode\"\n\t\t\t\t\t\t>\n\n\t\t\t\t\t\t{{ region.name }}\n\n\t\t\t\t\t\t<div class=\"dialog_selectorRegions_regionAreaName top-ellipsis\">\n\t\t\t\t\t\t\t{{ region.areaName }}\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div v-if=\"region.langLabel\">\n\t\t\t\t\t\t\t[{{ region.langLabel }}]\n\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tv-if=\"region.deviceIcon\"\n\t\t\t\t\t\t\t:data-top-icon=\"region.deviceIcon\"\n\t\t\t\t\t\t></div>\n\t\t\t\t\t</TopCheckbox>\n\t\t\t\t</div>\n\t\t\t</template>\n\n\t\t\t<template #footer>\n\t\t\t\t<TopButton @click=\"onSubmit\">\n\t\t\t\t\t{{ $i18n.Common?.Apply }}\n\t\t\t\t</TopButton>\n\t\t\t</template>\n\t\t</TopDialogPage>\n\t</TopDialog>\n</template>\n\n<style>\n@import \"./style.css\";\n</style>\n"],"names":["dialog","utils","isAllSelected","vue","regionsRich","elRegions","sortedVectorByField","sort","sortedField","regionA","regionB","region","_a","props","regionsIndexes","orderA","orderByRegionIndex","orderB","regions","title","selected","deviceIcon","utils_searchers","flagLink","utils_string","searcherIcon","langLabel","regionRich","isAllSelectedLocal","b","sortedIndexes"],"mappings":"wpBAYAA,EAAAC,EAAA,iBAAA,EAKAC,EAAAC,EAAA,IAAA,EAAA,EAKAC,EAAAD,EAAA,IAAA,CAAA,CAAA,EAKAE,EAAAF,EAAA,IAAA,IAAA,EAKAG,EAAAH,EAAA,SAAA,wBAEM,KAAA,EACC,CAAA,EAOPI,EAAAC,GAAA,gCAIE,CAAAC,EAAAD,CAAA,GAAA,CAAAE,EAAAF,CAAA,EAAA,wBAEyH,gBAU1H,GAAA,CAAAJ,EAAA,MAAA,KAAAO,GAAAA,EAAA,QAAA,EAAA,8DAMAC,EAAAC,EAAA,4BAAA,MAAAD,EAAA,KAAAC,EAAAC,cAMDX,EAAA,MAAAD,EAAA,IAAA,kDACqG,CAAA,EAIrGC,EAAA,MAAA,mCAEa,EAAA,IAAA,CAKZ,GAHAC,EAAA,MAAA,CAAA,EAEA,CAAAS,EAAA,SACA,CAAAA,EAAA,eAAA,oGAUC,MAAAE,EAAAC,EAAA,IAAAP,EAAA,KAAA,GAAA,OAAA,UACAQ,EAAAD,EAAA,IAAAN,EAAA,KAAA,GAAA,OAAA,oBAEgB,CAAA,EAGjBQ,EAAA,QAAAP,GAAA,OACC,IAAAQ,EAAAR,EAAA,KACAA,EAAA,WAAAQ,GAAA,KAAAR,EAAA,QAAA,KAEA,MAAAS,IAAAR,EAAAC,EAAA,iBAAA,YAAAD,EAAA,SAAAD,EAAA,SAAA,4GAGAU,EAAAV,EAAA,SAAA,OAAAW,EAAA,eAAAX,EAAA,MAAA,EAAA,OACAY,EAAAZ,EAAA,cAAA,OAAAa,EAAA,yBAAAb,EAAA,WAAA,EAAA,UAEmB,GAAAA,EACf,SAAAS,EACH,MAAAD,EACA,aAAAM,EACA,UAAAC,EACA,WAAAL,cAKDjB,EAAA,MAAA,KAAAuB,CAAA,EAEAA,EAAA,gBAEA,CAAA,EAGDzB,EAAA,MAAA0B,CAAsB,CAAA,8DAQrB,QAAA,KAAA,wEAAA,QAEA,CAGDvB,EAAA,oIAQED,EAAA,MAAA,KAAA,CAAA,EAAAyB,IAAAC,EAAA,QAAA,EAAA,KAAA,EAAAA,EAAA,QAAAD,EAAA,KAAA,CAAA,CAAgG,CACjG,CAAA,mDAUDxB,EAAA"}
|
package/assets/extra.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.top-rive{width:100%;height:100%;flex-grow:1}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Rive } from '@rive-app/canvas-lite';
|
|
2
|
+
import { Props } from './types';
|
|
3
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
4
|
+
declare const _default: DefineComponent<Props, {
|
|
5
|
+
riveInstance: Rive | undefined;
|
|
6
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
7
|
+
autoplay: boolean;
|
|
8
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
9
|
+
el: HTMLCanvasElement;
|
|
10
|
+
}, HTMLCanvasElement>;
|
|
11
|
+
export default _default;
|
|
@@ -112,6 +112,7 @@ declare const __VLS_component: DefineComponent<__VLS_PublicProps, {}, {}, {}, {}
|
|
|
112
112
|
items: Item[];
|
|
113
113
|
minLength: number;
|
|
114
114
|
showSelectedInInput: boolean;
|
|
115
|
+
showSearch: boolean;
|
|
115
116
|
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
116
117
|
popupRef: ({
|
|
117
118
|
$: ComponentInternalInstance;
|
package/components/project/selectorRegion/dialog_selectorRegions/dialog_selectorRegions.vue.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Props } from './types';
|
|
2
2
|
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
|
-
declare const _default: DefineComponent<Partial<Props>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Partial<Props>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
3
|
+
declare const _default: DefineComponent<Partial<Props>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Partial<Props>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
4
|
+
elRegions: HTMLDivElement;
|
|
5
|
+
}, HTMLDivElement>;
|
|
4
6
|
export default _default;
|
|
@@ -29,4 +29,6 @@ export declare const findRegion: (forFrequency: boolean, searchRegion: Partial<R
|
|
|
29
29
|
*
|
|
30
30
|
* @see import('../dialog_selectorRegions/types').Props
|
|
31
31
|
*/
|
|
32
|
-
export declare const dialogSelectorRegions: AsyncTopDialogHandle<DefineComponent<Partial< Props>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Partial< Props>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
32
|
+
export declare const dialogSelectorRegions: AsyncTopDialogHandle<DefineComponent<Partial< Props>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Partial< Props>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
33
|
+
elRegions: HTMLDivElement;
|
|
34
|
+
}, HTMLDivElement>>;
|
package/core/app.amd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
define(["require","exports","../.chunks/forms-B3bJpLOo.amd","../.chunks/core-B9imztzR.amd","vue","../utils/clipboard.amd","../utils/string.amd","../utils/route.amd","../.chunks/utils-CTjq0RlC.amd","../.chunks/dialogs.vue_vue_type_script_setup_true_lang-vT5jI1Ll.amd"],function(y,
|
|
1
|
+
define(["require","exports","../.chunks/forms-B3bJpLOo.amd","../.chunks/core-B9imztzR.amd","vue","../utils/clipboard.amd","../utils/string.amd","../utils/route.amd","../.chunks/utils-CTjq0RlC.amd","../.chunks/dialogs.vue_vue_type_script_setup_true_lang-vT5jI1Ll.amd"],function(y,n,c,l,d,m,S,p,g,k){"use strict";if(typeof d>"u")var d=window.Vue;class E{#s;#t;#e;#i;#c;#a=[];#o=[];#n=[];#r=[];constructor(s){var t;this.#t=s.store,this.#s=this.#t.$id,this.#e=s.options.Page,this.#i=s.options.user,this.#c=s.options.Api,this.#a=s.options.tpaNamesUrlHash||[],this.#o=s.options.tpaNamesStorage||[],this.#n=s.options.tpaNamesStorageLocal||[],this.#r=s.options.tpaNamesGuestLink||[],s.store.genGuestLink=(i,a)=>this.genGuestLink(i,a),(t=this.#i.guest_data)!=null&&t.data||(this.#u(),this.#u(!0),this.#l()),this.#S(),this.#k();const e=c.debounce(()=>{this.#m(),this.#p(),this.#p(!0)});s.store.$subscribe(e)}async genGuestLink(s,e){const t=this.#g();e=Object.assign(e,Object.fromEntries(t));const i=await this.#c.gen(s,"fetchColumn").call({},e);i!=null&&i.errors||await m.guestLinkToClipboard(i.result)}#g(){const s=new Map;return this.#r.forEach(e=>{const t=S.camelToSnakeCase(e);s.set(t,this.#t[e])}),s}#h(s){s.forEach((e,t)=>{const i=this.#t[t];if(e!=null&&i!==void 0&&e!=null&&e.constructor&&e.constructor===i.constructor){if(t.indexOf("date")===0&&!Array.isArray(e)){if(typeof e=="string"&&!/\d\d\d\d-\d\d-\d\d/.test(e))return}this.#t[t]=e}})}#f(s){const e=new Map;return s.forEach((t,i)=>{t!==null&&(t=JSON.stringify(t),e.set(i,t))}),e}#d(s){const e=new Map;return s.forEach((t,i)=>{if(!(t==null||t==="false")){try{if(typeof t=="string"&&!/^\d\d\d\d-\d\d-\d\d$/.test(t)&&(t=JSON.parse(t)),t==null||t==="false")return}catch{}e.set(i,t)}}),e}#l(){let s;try{s=JSON.parse(p.getHash(this.#s))}catch{}if(!s)return;const e=new Map;this.#a.forEach(t=>{const i=s[t];i&&e.set(t,i)}),this.#h(e)}#m(){const s=new Map;this.#a.forEach(i=>{const a=this.#t[i];s.set(i,a)});const e=Object.fromEntries(s),t=JSON.stringify(e);p.setHash(this.#s,t)}#u(s=!1){const e=new Map;let t=this.#o,i="state:"+this.#s;s&&(t=this.#n,i="state:"+this.#s+":"+location.pathname),t.forEach(o=>{const r=localStorage.getItem(i+":"+o);e.set(o,r)});const a=this.#d(e);this.#h(a)}#p(s=!1){const e=new Map;let t=this.#o,i="state:"+this.#s;s&&(t=this.#n,i="state:"+this.#s+":"+location.pathname),t.forEach(o=>{const r=this.#t[o];e.set(o,r)});const a=this.#f(e);t.forEach(o=>{const r=a.get(o);localStorage.setItem(i+":"+o,r)})}#S(){var a,o,r;const s=(o=(a=this.#i)==null?void 0:a.guest_data)==null?void 0:o.data;if(!s)return;this.#i.id===-1&&(this.#i.positionsReverseDates=s.positionsReverseDates);const e=new Map;this.#r.forEach(h=>{const u=s[h];e.set(h,u)});const t=this.#d(e);this.#h(t);const i=$(".mod_guest_title");if(((r=this.#t.competitorsIds)==null?void 0:r.length)===1&&this.#e.page.data.competitors){let h=this.#e.page.data.competitors.filter(u=>u.id===s.competitorsIds[0]);h.length&&($("a",i).attr("href","http://"+h[0].url),$("a",i).text(h[0].name))}}#k(){this.#t.regionsIndexes&&d.watch(this.#t.regionsIndexes,s=>{if(!s.length)return;s.forEach((i,a)=>s[a]=i);const e=TplProjectSelectorRegion.genSearchersMap(),t=[];e.forEach(i=>{i.regions.forEach(a=>{a.index!==-1&&t.push(a.index)})}),this.#t.regionsIndexes=s.filter(i=>t.includes(i))},{immediate:!0}),this.#t.competitorsIds&&d.watch(this.#t.competitorsIds,s=>{if(!s.length)return;s.forEach((t,i)=>s[i]=t);const e=[this.#e.page.data.project.id];this.#e.page.data.project.competitors.forEach(t=>{t.on>=0&&e.push(t.id)}),this.#t.competitorsIds=s.filter(t=>e.includes(t))},{immediate:!0})}}const w=f=>{var e,t,i,a;const s=f;!((e=s.options.tpaNamesUrlHash)!=null&&e.length)&&!((t=s.options.tpaNamesStorage)!=null&&t.length)&&!((i=s.options.tpaNamesStorageLocal)!=null&&i.length)&&!((a=s.options.tpaNamesGuestLink)!=null&&a.length)||new E(s)};n.Core=c.Core,n.i18nPlugin=c.i18n,n.useI18n=c.useI18n,n.useI18nLang=c.useI18nLang,n.corePlugin=l.core,n.useAsyncTopDialog=g.useAsyncTopDialog,n.useTopDialog=g.useTopDialog,n.TopDialogWorker=k.TopDialogWorker,n.piniaTPAPlugin=w,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=app.amd.js.map
|
package/core/app.amd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.amd.js","sources":["../../src/core/plugins/piniaTPA.ts"],"sourcesContent":["import type { PiniaPluginContext, Store } from 'pinia';\nimport { watch } from 'vue';\nimport Core from '@/core/core/core';\nimport { useI18n } from '@/core/plugins/i18n';\nimport { debounce } from '@/core/utils/lodash';\nimport { guestLinkToClipboard } from '@/core/utils/clipboard';\nimport { camelToSnakeCase } from '@/core/utils/string.js';\nimport type { paths as OpenAPIPaths } from 'topvisor-openapi/src/ts/Topvisor';\nimport { getHash, setHash } from '@/core/utils/route';\n\ntype OpenAPIPath = keyof OpenAPIPaths;\n\nclass PiniaTPA {\n\n\treadonly #storeId: string;\n\treadonly #store: Store<string, any>;\n\n\t/**\n\t * @deprecated\n\t */\n\treadonly #Page: any;\n\n\treadonly #user: any;\n\treadonly #Api: any;\n\n\treadonly #namesUrlHash: string[] = [];\n\treadonly #namesStorage: string[] = [];\n\treadonly #namesStorageLocal: string[] = [];\n\treadonly #namesGuestLink: string[] = [];\n\n\tconstructor(context: Context) {\n\t\tthis.#store = context.store;\n\t\tthis.#storeId = this.#store.$id;\n\n\t\tthis.#Page = context.options.Page;\n\n\t\tthis.#user = context.options.user;\n\t\tthis.#Api = context.options.Api;\n\n\t\tthis.#namesUrlHash = context.options.tpaNamesUrlHash || [];\n\t\tthis.#namesStorage = context.options.tpaNamesStorage || [];\n\t\tthis.#namesStorageLocal = context.options.tpaNamesStorageLocal || [];\n\t\tthis.#namesGuestLink = context.options.tpaNamesGuestLink || [];\n\n\t\tcontext.store.genGuestLink = <Path extends OpenAPIPath>(url: Path, data: any) => this.genGuestLink(url, data);\n\n\t\tif (!this.#user.guest_data?.data) {\n\t\t\tthis.#loadFromStorage();\n\t\t\tthis.#loadFromStorage(true);\n\n\t\t\t// настройки URL hash имеют приоритет\n\t\t\tthis.#loadFromHash();\n\t\t}\n\n\t\t// настройки гостевой ссылки имеют приоритет\n\t\tthis.#loadFromGuestLink();\n\n\t\tthis.#prepareParams();\n\n\t\tconst save = debounce(() => {\n\t\t\tthis.#saveInHash();\n\t\t\tthis.#saveInStorage();\n\t\t});\n\n\t\tcontext.store.$subscribe(save);\n\t}\n\n\t/**\n\t * Сгенерировать гостевую ссылку\n\t *\n\t * Метод, путь к которому указан в url, должен возвращать сгенерированную ссылку\n\t */\n\tasync genGuestLink<Path extends OpenAPIPath>(url: Path, data: any) {\n\t\tconst dataGuestLink = this.#genOptionsForGuestLink();\n\t\tdata = Object.assign(data, Object.fromEntries(dataGuestLink));\n\n\t\tconst res = await this.#Api.gen(url, 'fetchColumn').call({} as any, data);\n\n\t\t// @ts-ignore - метод, который скачивает файл не возвращает json\n\t\tif (res?.errors) return;\n\n\t\t// @ts-ignore - метод, который скачивает файл не возвращает json\n\t\tawait guestLinkToClipboard(res.result);\n\t}\n\n\t/**\n\t * Сгенерировать опции для гостевой ссылки\n\t */\n\t#genOptionsForGuestLink() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesGuestLink.forEach(name => {\n\t\t\t// формат параметров API: snake_case\n\t\t\tconst nameSnakeCase = camelToSnakeCase(name);\n\t\t\tdata.set(nameSnakeCase, this.#store[name]);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из объекта без фиксации состояния\n\t */\n\t#setOptions(data: Map<string, any>) {\n\t\tdata.forEach((value, name) => {\n\t\t\tconst currentValue = this.#store[name];\n\n\t\t\tif (value === null || value === undefined) return;\n\t\t\tif (currentValue === undefined) return;\n\t\t\tif (!value?.constructor) return;\n\t\t\tif (value.constructor !== currentValue.constructor) return;\n\n\t\t\t// дополнительная проверка на формат даты\n\t\t\tif (name.indexOf('date') === 0) {\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t// value.forEach((valueI) => {\n\t\t\t\t\t// \tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(valueI)) return;\n\t\t\t\t\t// });\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof (value) === 'string') {\n\t\t\t\t\t\tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(value)) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.#store[name] = value;\n\t\t});\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в виде json строк\n\t */\n\t#genDataFormat(data: Map<string, any>) {\n\t\tconst dataFormatted = new Map();\n\n\t\tdata.forEach((value, name) => {\n\t\t\tif (value === null) return;\n\n\t\t\tvalue = JSON.stringify(value);\n\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\treturn dataFormatted;\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в оригинальном виде\n\t */\n\t#genDataUnFormat(dataFormatted: Map<string, string>) {\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tdataFormatted.forEach((value, name) => {\n\t\t\tif (value === null || value === undefined || value === 'false') return;\n\n\t\t\ttry {\n\t\t\t\tif (typeof (value) === 'string' && !/^\\d\\d\\d\\d-\\d\\d-\\d\\d$/.test(value)) value = JSON.parse(value);\n\n\t\t\t\tif (value === null || value === undefined || value === 'false') return;\n\t\t\t} catch (e) {\n\t\t\t\t// не json строка\n\t\t\t}\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из хеша адреса страницы\n\t */\n\t#loadFromHash() {\n\t\tlet dataHash: any;\n\t\ttry {\n\t\t\tdataHash = JSON.parse(getHash(this.#storeId));\n\t\t} catch (e) {\n\n\t\t}\n\t\tif (!dataHash) return;\n\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = dataHash[name];\n\t\t\tif (!value) return;\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в хеш адреса страницы\n\t */\n\t#saveInHash() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataObject = Object.fromEntries(data);\n\t\tconst dataJSON = JSON.stringify(dataObject);\n\n\t\tsetHash(this.#storeId, dataJSON);\n\t};\n\n\t/**\n\t * Установить опции из localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#loadFromStorage(isLocal = false) {\n\t\tconst dataFormatted = new Map();\n\n\t\t// let names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\t// names = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tthis.#namesStorage.forEach((name) => {\n\t\t\tconst value = localStorage.getItem(storageNamespace + ':' + name);\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#saveInStorage(isLocal = false) {\n\t\tconst data = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataFormatted = this.#genDataFormat(data);\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = dataFormatted.get(name);\n\n\t\t\tlocalStorage.setItem(storageNamespace + ':' + name, value);\n\t\t});\n\t}\n\n\t/**\n\t * Установить опции из гостевой ссылки\n\t */\n\t#loadFromGuestLink() {\n\t\tconst guestData = this.#user?.guest_data?.data;\n\t\tif (!guestData) return;\n\n\t\t// общие правила для гостевых сессий\n\t\tif (this.#user.id === -1) this.#user.positionsReverseDates = guestData.positionsReverseDates;\n\n\t\tconst dataFormatted = new Map();\n\n\t\tthis.#namesGuestLink.forEach((name) => {\n\t\t\tconst value = guestData[name];\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\n\t\tconst $guestTitle = $('.mod_guest_title');\n\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds?.length === 1 && this.#Page.page.data.competitors) {\n\t\t\tlet competitors = this.#Page.page.data.competitors.filter((competitor: any) => competitor.id === guestData.competitorsIds[0]);\n\t\t\tif (competitors.length) {\n\t\t\t\t$('a', $guestTitle).attr('href', 'http://' + competitors[0].url);\n\t\t\t\t$('a', $guestTitle).text(competitors[0].name);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Подготовить входные параметры перед инициализацией основного функционала\n\t *\n\t * Входные параметры устанавливаются при открытии страницы\n\t *\n\t * Входные параметры могут меняться пользоваталем и устаревать\n\t */\n\t#prepareParams() {\n\t\t// контролль за вводом регионов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.regionsIndexes) {\n\t\t\twatch(this.#store.regionsIndexes, (regionsIndexes) => {\n\t\t\t\tif (!regionsIndexes.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tregionsIndexes.forEach((regionIndex: number, index: number) => regionsIndexes[index] = regionIndex);\n\n\t\t\t\t// оставить только включенные регионы\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst mapSearchers = TplProjectSelectorRegion.genSearchersMap();\n\n\t\t\t\tconst availableRegionsIndexes: number[] = [];\n\t\t\t\tmapSearchers.forEach((searcher: any) => {\n\t\t\t\t\tsearcher.regions.forEach((region: any) => {\n\t\t\t\t\t\tif (region.index === -1) return;\n\n\t\t\t\t\t\tavailableRegionsIndexes.push(region.index);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tthis.#store.regionsIndexes = regionsIndexes.filter((regionIndex: number) => availableRegionsIndexes.includes(regionIndex));\n\t\t\t}, { immediate: true });\n\t\t}\n\n\t\t// контролль за вводом конкурентов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds) {\n\t\t\twatch(this.#store.competitorsIds, (competitorsIds) => {\n\t\t\t\tif (!competitorsIds.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tcompetitorsIds.forEach((competitorId: number, index: number) => competitorsIds[index] = competitorId);\n\n\t\t\t\t// оставить только включенных конкурентов\n\t\t\t\tconst availableCompetitorsIds = [this.#Page.page.data.project.id];\n\t\t\t\tthis.#Page.page.data.project.competitors.forEach((competitor: any) => {\n\t\t\t\t\tif (competitor.on >= 0) availableCompetitorsIds.push(competitor.id);\n\t\t\t\t});\n\n\t\t\t\tthis.#store.competitorsIds = competitorsIds.filter((competitorId: number) => availableCompetitorsIds.includes(competitorId));\n\t\t\t}, { immediate: true });\n\t\t}\n\t}\n\n}\n\ntype Options = {\n\t/**\n\t * TODO: Убрать из плагина\n\t */\n\tPage: any,\n\n\t/**\n\t * Объект с настройками пользователя\n\t */\n\tuser: any,\n\n\t/**\n\t * Объект для работы с API\n\t *\n\t * См. на сайте: @/component/api/core/api.ts\n\t */\n\tApi: any;\n\n\t/**\n\t * Имена свойств для сохранения в URL\n\t */\n\ttpaNamesUrlHash?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage\n\t */\n\ttpaNamesStorage?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage с учетом пути URL\n\t *\n\t * Каждый URL будет работать со своим состоянием\n\t */\n\ttpaNamesStorageLocal?: string[],\n\n\t/**\n\t * Имена свойств для работы с гостевой ссылкой\n\t *\n\t * Для генерации гостевой ссылки используйте store.genGuestLink(data, url)\n\t */\n\ttpaNamesGuestLink?: string[],\n};\n\ntype Context = PiniaPluginContext & {\n\toptions: Options\n};\n\n/**\n * Плагин tpa (Third-party access) для pinia\n *\n * Добавляет возможность сохранять и загружать данные в/из:\n * \t- URL hash в адресе страницы\n * \t- localStorage\n * \t- гостевая ссылка\n *\n * Для подключения плагина нужно указань одну или несколько опций при определении defineStore():\n * - tpaNamesUrlHash\n * - tpaNamesStorage\n * - tpaNamesStorageLocal\n * - tpaNamesGuestLink\n */\nexport default (contextPinia: PiniaPluginContext) => {\n\tconst context = contextPinia as Context;\n\n\t// плагин подключать не нужно\n\tif (\n\t\t!context.options.tpaNamesUrlHash?.length &&\n\t\t!context.options.tpaNamesStorage?.length &&\n\t\t!context.options.tpaNamesStorageLocal?.length &&\n\t\t!context.options.tpaNamesGuestLink?.length\n\t) {\n\t\treturn;\n\t}\n\n\tnew PiniaTPA(context);\n}\n"],"names":["PiniaTPA","#storeId","#store","#Page","#user","#Api","context","url","data","#loadFromStorage","save","forms","dataGuestLink","#genOptionsForGuestLink","res","utils_clipboard","nameSnakeCase","utils_string","name","currentValue","value","dataFormatted","#loadFromHash","dataHash","utils_route","#setOptions","#saveInHash","dataJSON","isLocal","storageNamespace","#saveInStorage","names","#namesStorage","#namesStorageLocal","#loadFromGuestLink","guestData","$guestTitle","competitors","competitor","#prepareParams","regionsIndexes","regionIndex","index","mapSearchers","searcher","region","availableRegionsIndexes","competitorsIds","competitorId","availableCompetitorsIds","piniaTPA","contextPinia","_a","_b","_c","_d"],"mappings":"wVAYA,MAAAA,CAAA,CAAeC,GAELC,GACAC,GAKAC,GAEAC,gDASR,KAAAH,GAAAI,EAAA,6PAaAA,EAAA,MAAA,aAAA,CAAAC,EAAAC,IAAA,KAAA,aAAAD,EAAAC,CAAA,mDAIC,KAAAC,GAAA,EAAA,iCAWD,MAAAC,EAAAC,EAAA,SAAA,IAAA,oBAEqB,CAAA,EAGrBL,EAAA,MAAA,WAAAI,CAAA,CAA6B,CAC9B,MAAA,aAAAH,EAAAC,EAAA,CAQC,MAAAI,EAAA,KAAAC,GAAA,EACAL,EAAA,OAAA,OAAAA,EAAA,OAAA,YAAAI,CAAA,CAAA,wDAKAE,GAAA,MAAAA,EAAA,QAGA,MAAAC,EAAA,qBAAAD,EAAA,MAAA,CAAqC,CACtCD,IAAA,CAMC,MAAAL,EAAA,IAAA,+BAIC,MAAAQ,EAAAC,EAAA,iBAAAC,CAAA,EACAV,EAAA,IAAAQ,EAAA,KAAAd,GAAAgB,CAAA,CAAA,CAAyC,CAAA,EAG1CV,CAAO,wDAWNW,IAAA,QACAC,GAAA,MAAAA,EAAA,yFAUE,GAAA,OAAAA,GAAA,+CAMF,KAAAlB,GAAAgB,CAAA,EAAAE,EAAoB,CAAA,CACpB,OAOD,MAAAC,EAAA,IAAA,6BAGCD,IAAA,OAEAA,EAAA,KAAA,UAAAA,CAAA,EAEAC,EAAA,IAAAH,EAAAE,CAAA,EAA6B,CAAA,EAG9BC,CAAO,OAOP,MAAAb,EAAA,IAAA,6BAGC,GAAA,EAAAY,GAAA,MAAAA,IAAA,SAEA,IAAA,CAGC,0EAAAA,GAAA,MAAAA,IAAA,QAAA,aACW,CAIZZ,EAAA,IAAAU,EAAAE,CAAA,EAAoB,CAAA,EAGrBZ,CAAO,CACRc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EAAA,SAAA,GAAAC,EAAAjD,EAAA,QAAA,oBAAA,MAAAiD,EAAA,SASA,IAAAvD,EAAAM,CAAA"}
|
|
1
|
+
{"version":3,"file":"app.amd.js","sources":["../../src/core/plugins/piniaTPA.ts"],"sourcesContent":["import type { PiniaPluginContext, Store } from 'pinia';\nimport { watch } from 'vue';\nimport Core from '@/core/core/core';\nimport { useI18n } from '@/core/plugins/i18n';\nimport { debounce } from '@/core/utils/lodash';\nimport { guestLinkToClipboard } from '@/core/utils/clipboard';\nimport { camelToSnakeCase } from '@/core/utils/string.js';\nimport type { paths as OpenAPIPaths } from 'topvisor-openapi/src/ts/Topvisor';\nimport { getHash, setHash } from '@/core/utils/route';\n\ntype OpenAPIPath = keyof OpenAPIPaths;\n\nclass PiniaTPA {\n\n\treadonly #storeId: string;\n\treadonly #store: Store<string, any>;\n\n\t/**\n\t * @deprecated\n\t */\n\treadonly #Page: any;\n\n\treadonly #user: any;\n\treadonly #Api: any;\n\n\treadonly #namesUrlHash: string[] = [];\n\treadonly #namesStorage: string[] = [];\n\treadonly #namesStorageLocal: string[] = [];\n\treadonly #namesGuestLink: string[] = [];\n\n\tconstructor(context: Context) {\n\t\tthis.#store = context.store;\n\t\tthis.#storeId = this.#store.$id;\n\n\t\tthis.#Page = context.options.Page;\n\n\t\tthis.#user = context.options.user;\n\t\tthis.#Api = context.options.Api;\n\n\t\tthis.#namesUrlHash = context.options.tpaNamesUrlHash || [];\n\t\tthis.#namesStorage = context.options.tpaNamesStorage || [];\n\t\tthis.#namesStorageLocal = context.options.tpaNamesStorageLocal || [];\n\t\tthis.#namesGuestLink = context.options.tpaNamesGuestLink || [];\n\n\t\tcontext.store.genGuestLink = <Path extends OpenAPIPath>(url: Path, data: any) => this.genGuestLink(url, data);\n\n\t\tif (!this.#user.guest_data?.data) {\n\t\t\tthis.#loadFromStorage();\n\t\t\tthis.#loadFromStorage(true);\n\n\t\t\t// настройки URL hash имеют приоритет\n\t\t\tthis.#loadFromHash();\n\t\t}\n\n\t\t// настройки гостевой ссылки имеют приоритет\n\t\tthis.#loadFromGuestLink();\n\n\t\tthis.#prepareParams();\n\n\t\tconst save = debounce(() => {\n\t\t\tthis.#saveInHash();\n\t\t\tthis.#saveInStorage();\n\t\t\tthis.#saveInStorage(true);\n\t\t});\n\n\t\tcontext.store.$subscribe(save);\n\t}\n\n\t/**\n\t * Сгенерировать гостевую ссылку\n\t *\n\t * Метод, путь к которому указан в url, должен возвращать сгенерированную ссылку\n\t */\n\tasync genGuestLink<Path extends OpenAPIPath>(url: Path, data: any) {\n\t\tconst dataGuestLink = this.#genOptionsForGuestLink();\n\t\tdata = Object.assign(data, Object.fromEntries(dataGuestLink));\n\n\t\tconst res = await this.#Api.gen(url, 'fetchColumn').call({} as any, data);\n\n\t\t// @ts-ignore - метод, который скачивает файл не возвращает json\n\t\tif (res?.errors) return;\n\n\t\t// @ts-ignore - метод, который скачивает файл не возвращает json\n\t\tawait guestLinkToClipboard(res.result);\n\t}\n\n\t/**\n\t * Сгенерировать опции для гостевой ссылки\n\t */\n\t#genOptionsForGuestLink() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesGuestLink.forEach(name => {\n\t\t\t// формат параметров API: snake_case\n\t\t\tconst nameSnakeCase = camelToSnakeCase(name);\n\t\t\tdata.set(nameSnakeCase, this.#store[name]);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из объекта без фиксации состояния\n\t */\n\t#setOptions(data: Map<string, any>) {\n\t\tdata.forEach((value, name) => {\n\t\t\tconst currentValue = this.#store[name];\n\n\t\t\tif (value === null || value === undefined) return;\n\t\t\tif (currentValue === undefined) return;\n\t\t\tif (!value?.constructor) return;\n\t\t\tif (value.constructor !== currentValue.constructor) return;\n\n\t\t\t// дополнительная проверка на формат даты\n\t\t\tif (name.indexOf('date') === 0) {\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t// value.forEach((valueI) => {\n\t\t\t\t\t// \tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(valueI)) return;\n\t\t\t\t\t// });\n\t\t\t\t} else {\n\t\t\t\t\tif (typeof (value) === 'string') {\n\t\t\t\t\t\tif (!/\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(value)) return;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.#store[name] = value;\n\t\t});\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в виде json строк\n\t */\n\t#genDataFormat(data: Map<string, any>) {\n\t\tconst dataFormatted = new Map();\n\n\t\tdata.forEach((value, name) => {\n\t\t\tif (value === null) return;\n\n\t\t\tvalue = JSON.stringify(value);\n\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\treturn dataFormatted;\n\t}\n\n\t/**\n\t * Сгенерировать Map объект с опциями со значениями в оригинальном виде\n\t */\n\t#genDataUnFormat(dataFormatted: Map<string, string>) {\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tdataFormatted.forEach((value, name) => {\n\t\t\tif (value === null || value === undefined || value === 'false') return;\n\n\t\t\ttry {\n\t\t\t\tif (typeof (value) === 'string' && !/^\\d\\d\\d\\d-\\d\\d-\\d\\d$/.test(value)) value = JSON.parse(value);\n\n\t\t\t\tif (value === null || value === undefined || value === 'false') return;\n\t\t\t} catch (e) {\n\t\t\t\t// не json строка\n\t\t\t}\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\treturn data;\n\t}\n\n\t/**\n\t * Установить опции из хеша адреса страницы\n\t */\n\t#loadFromHash() {\n\t\tlet dataHash: any;\n\t\ttry {\n\t\t\tdataHash = JSON.parse(getHash(this.#storeId));\n\t\t} catch (e) {\n\n\t\t}\n\t\tif (!dataHash) return;\n\n\t\tconst data: Map<string, any> = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = dataHash[name];\n\t\t\tif (!value) return;\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в хеш адреса страницы\n\t */\n\t#saveInHash() {\n\t\tconst data = new Map();\n\n\t\tthis.#namesUrlHash.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataObject = Object.fromEntries(data);\n\t\tconst dataJSON = JSON.stringify(dataObject);\n\n\t\tsetHash(this.#storeId, dataJSON);\n\t};\n\n\t/**\n\t * Установить опции из localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#loadFromStorage(isLocal = false) {\n\t\tconst dataFormatted = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = localStorage.getItem(storageNamespace + ':' + name);\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\t}\n\n\t/**\n\t * Сохранить опции в localStorage\n\t * @param isLocal - сохранить с учетом адреса страницы\n\t */\n\t#saveInStorage(isLocal = false) {\n\t\tconst data = new Map();\n\n\t\tlet names = this.#namesStorage;\n\t\tlet storageNamespace = 'state:' + this.#storeId;\n\n\t\tif (isLocal) {\n\t\t\tnames = this.#namesStorageLocal;\n\t\t\tstorageNamespace = 'state:' + this.#storeId + ':' + location.pathname;\n\t\t}\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = this.#store[name];\n\n\t\t\tdata.set(name, value);\n\t\t});\n\n\t\tconst dataFormatted = this.#genDataFormat(data);\n\n\t\tnames.forEach((name) => {\n\t\t\tconst value = dataFormatted.get(name);\n\n\t\t\tlocalStorage.setItem(storageNamespace + ':' + name, value);\n\t\t});\n\t}\n\n\t/**\n\t * Установить опции из гостевой ссылки\n\t */\n\t#loadFromGuestLink() {\n\t\tconst guestData = this.#user?.guest_data?.data;\n\t\tif (!guestData) return;\n\n\t\t// общие правила для гостевых сессий\n\t\tif (this.#user.id === -1) this.#user.positionsReverseDates = guestData.positionsReverseDates;\n\n\t\tconst dataFormatted = new Map();\n\n\t\tthis.#namesGuestLink.forEach((name) => {\n\t\t\tconst value = guestData[name];\n\t\t\tdataFormatted.set(name, value);\n\t\t});\n\n\t\tconst data = this.#genDataUnFormat(dataFormatted);\n\n\t\tthis.#setOptions(data);\n\n\t\tconst $guestTitle = $('.mod_guest_title');\n\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds?.length === 1 && this.#Page.page.data.competitors) {\n\t\t\tlet competitors = this.#Page.page.data.competitors.filter((competitor: any) => competitor.id === guestData.competitorsIds[0]);\n\t\t\tif (competitors.length) {\n\t\t\t\t$('a', $guestTitle).attr('href', 'http://' + competitors[0].url);\n\t\t\t\t$('a', $guestTitle).text(competitors[0].name);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Подготовить входные параметры перед инициализацией основного функционала\n\t *\n\t * Входные параметры устанавливаются при открытии страницы\n\t *\n\t * Входные параметры могут меняться пользоваталем и устаревать\n\t */\n\t#prepareParams() {\n\t\t// контролль за вводом регионов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.regionsIndexes) {\n\t\t\twatch(this.#store.regionsIndexes, (regionsIndexes) => {\n\t\t\t\tif (!regionsIndexes.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tregionsIndexes.forEach((regionIndex: number, index: number) => regionsIndexes[index] = regionIndex);\n\n\t\t\t\t// оставить только включенные регионы\n\t\t\t\t// @ts-ignore\n\t\t\t\tconst mapSearchers = TplProjectSelectorRegion.genSearchersMap();\n\n\t\t\t\tconst availableRegionsIndexes: number[] = [];\n\t\t\t\tmapSearchers.forEach((searcher: any) => {\n\t\t\t\t\tsearcher.regions.forEach((region: any) => {\n\t\t\t\t\t\tif (region.index === -1) return;\n\n\t\t\t\t\t\tavailableRegionsIndexes.push(region.index);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\tthis.#store.regionsIndexes = regionsIndexes.filter((regionIndex: number) => availableRegionsIndexes.includes(regionIndex));\n\t\t\t}, { immediate: true });\n\t\t}\n\n\t\t// контролль за вводом конкурентов\n\t\t// TODO: вынести в опции плагина\n\t\tif (this.#store.competitorsIds) {\n\t\t\twatch(this.#store.competitorsIds, (competitorsIds) => {\n\t\t\t\tif (!competitorsIds.length) return;\n\n\t\t\t\t// приведение типа\n\t\t\t\tcompetitorsIds.forEach((competitorId: number, index: number) => competitorsIds[index] = competitorId);\n\n\t\t\t\t// оставить только включенных конкурентов\n\t\t\t\tconst availableCompetitorsIds = [this.#Page.page.data.project.id];\n\t\t\t\tthis.#Page.page.data.project.competitors.forEach((competitor: any) => {\n\t\t\t\t\tif (competitor.on >= 0) availableCompetitorsIds.push(competitor.id);\n\t\t\t\t});\n\n\t\t\t\tthis.#store.competitorsIds = competitorsIds.filter((competitorId: number) => availableCompetitorsIds.includes(competitorId));\n\t\t\t}, { immediate: true });\n\t\t}\n\t}\n\n}\n\ntype Options = {\n\t/**\n\t * TODO: Убрать из плагина\n\t */\n\tPage: any,\n\n\t/**\n\t * Объект с настройками пользователя\n\t */\n\tuser: any,\n\n\t/**\n\t * Объект для работы с API\n\t *\n\t * См. на сайте: @/component/api/core/api.ts\n\t */\n\tApi: any;\n\n\t/**\n\t * Имена свойств для сохранения в URL\n\t */\n\ttpaNamesUrlHash?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage\n\t */\n\ttpaNamesStorage?: string[],\n\n\t/**\n\t * Имена свойств для сохранения в localStorage с учетом пути URL\n\t *\n\t * Каждый URL будет работать со своим состоянием\n\t */\n\ttpaNamesStorageLocal?: string[],\n\n\t/**\n\t * Имена свойств для работы с гостевой ссылкой\n\t *\n\t * Для генерации гостевой ссылки используйте store.genGuestLink(data, url)\n\t */\n\ttpaNamesGuestLink?: string[],\n};\n\ntype Context = PiniaPluginContext & {\n\toptions: Options\n};\n\n/**\n * Плагин tpa (Third-party access) для pinia\n *\n * Добавляет возможность сохранять и загружать данные в/из:\n * \t- URL hash в адресе страницы\n * \t- localStorage\n * \t- гостевая ссылка\n *\n * Для подключения плагина нужно указань одну или несколько опций при определении defineStore():\n * - tpaNamesUrlHash\n * - tpaNamesStorage\n * - tpaNamesStorageLocal\n * - tpaNamesGuestLink\n */\nexport default (contextPinia: PiniaPluginContext) => {\n\tconst context = contextPinia as Context;\n\n\t// плагин подключать не нужно\n\tif (\n\t\t!context.options.tpaNamesUrlHash?.length &&\n\t\t!context.options.tpaNamesStorage?.length &&\n\t\t!context.options.tpaNamesStorageLocal?.length &&\n\t\t!context.options.tpaNamesGuestLink?.length\n\t) {\n\t\treturn;\n\t}\n\n\tnew PiniaTPA(context);\n}\n"],"names":["PiniaTPA","#storeId","#store","#Page","#user","#Api","context","url","data","#loadFromStorage","save","forms","#saveInStorage","dataGuestLink","#genOptionsForGuestLink","res","utils_clipboard","nameSnakeCase","utils_string","name","currentValue","value","dataFormatted","#loadFromHash","dataHash","utils_route","#setOptions","#saveInHash","dataJSON","isLocal","names","#namesStorage","storageNamespace","#namesStorageLocal","#loadFromGuestLink","guestData","$guestTitle","competitors","competitor","#prepareParams","regionsIndexes","regionIndex","index","mapSearchers","searcher","region","availableRegionsIndexes","competitorsIds","competitorId","availableCompetitorsIds","piniaTPA","contextPinia","_a","_b","_c","_d"],"mappings":"wVAYA,MAAAA,CAAA,CAAeC,GAELC,GACAC,GAKAC,GAEAC,gDASR,KAAAH,GAAAI,EAAA,6PAaAA,EAAA,MAAA,aAAA,CAAAC,EAAAC,IAAA,KAAA,aAAAD,EAAAC,CAAA,mDAIC,KAAAC,GAAA,EAAA,iCAWD,MAAAC,EAAAC,EAAA,SAAA,IAAA,qBAGC,KAAAC,GAAA,EAAA,CAAwB,CAAA,EAGzBN,EAAA,MAAA,WAAAI,CAAA,CAA6B,CAC9B,MAAA,aAAAH,EAAA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.#e = s.options.Page, this.#a = s.options.user, this.#
|
|
25
|
+
this.#t = s.store, this.#s = this.#t.$id, this.#e = s.options.Page, this.#a = s.options.user, this.#c = s.options.Api, this.#i = s.options.tpaNamesUrlHash || [], this.#o = s.options.tpaNamesStorage || [], this.#r = s.options.tpaNamesStorageLocal || [], this.#n = s.options.tpaNamesGuestLink || [], s.store.genGuestLink = (a, i) => this.genGuestLink(a, i), (t = this.#a.guest_data) != null && t.data || (this.#d(), this.#d(!0), this.#l()), this.#S(), this.#E();
|
|
26
26
|
const e = d(() => {
|
|
27
|
-
this.#
|
|
27
|
+
this.#u(), this.#f(), this.#f(!0);
|
|
28
28
|
});
|
|
29
29
|
s.store.$subscribe(e);
|
|
30
30
|
}
|
|
@@ -34,17 +34,17 @@ class u {
|
|
|
34
34
|
* Метод, путь к которому указан в url, должен возвращать сгенерированную ссылку
|
|
35
35
|
*/
|
|
36
36
|
async genGuestLink(s, e) {
|
|
37
|
-
const t = this.#
|
|
37
|
+
const t = this.#g();
|
|
38
38
|
e = Object.assign(e, Object.fromEntries(t));
|
|
39
|
-
const a = await this.#
|
|
39
|
+
const a = await this.#c.gen(s, "fetchColumn").call({}, e);
|
|
40
40
|
a != null && a.errors || await f(a.result);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Сгенерировать опции для гостевой ссылки
|
|
44
44
|
*/
|
|
45
|
-
#
|
|
45
|
+
#g() {
|
|
46
46
|
const s = /* @__PURE__ */ new Map();
|
|
47
|
-
return this.#
|
|
47
|
+
return this.#n.forEach((e) => {
|
|
48
48
|
const t = g(e);
|
|
49
49
|
s.set(t, this.#t[e]);
|
|
50
50
|
}), s;
|
|
@@ -52,7 +52,7 @@ class u {
|
|
|
52
52
|
/**
|
|
53
53
|
* Установить опции из объекта без фиксации состояния
|
|
54
54
|
*/
|
|
55
|
-
#
|
|
55
|
+
#h(s) {
|
|
56
56
|
s.forEach((e, t) => {
|
|
57
57
|
const a = this.#t[t];
|
|
58
58
|
if (e != null && a !== void 0 && e != null && e.constructor && e.constructor === a.constructor) {
|
|
@@ -67,7 +67,7 @@ class u {
|
|
|
67
67
|
/**
|
|
68
68
|
* Сгенерировать Map объект с опциями со значениями в виде json строк
|
|
69
69
|
*/
|
|
70
|
-
#
|
|
70
|
+
#m(s) {
|
|
71
71
|
const e = /* @__PURE__ */ new Map();
|
|
72
72
|
return s.forEach((t, a) => {
|
|
73
73
|
t !== null && (t = JSON.stringify(t), e.set(a, t));
|
|
@@ -91,7 +91,7 @@ class u {
|
|
|
91
91
|
/**
|
|
92
92
|
* Установить опции из хеша адреса страницы
|
|
93
93
|
*/
|
|
94
|
-
#
|
|
94
|
+
#l() {
|
|
95
95
|
let s;
|
|
96
96
|
try {
|
|
97
97
|
s = JSON.parse(m(this.#s));
|
|
@@ -102,12 +102,12 @@ class u {
|
|
|
102
102
|
this.#i.forEach((t) => {
|
|
103
103
|
const a = s[t];
|
|
104
104
|
a && e.set(t, a);
|
|
105
|
-
}), this.#
|
|
105
|
+
}), this.#h(e);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Сохранить опции в хеш адреса страницы
|
|
109
109
|
*/
|
|
110
|
-
#
|
|
110
|
+
#u() {
|
|
111
111
|
const s = /* @__PURE__ */ new Map();
|
|
112
112
|
this.#i.forEach((a) => {
|
|
113
113
|
const i = this.#t[a];
|
|
@@ -122,26 +122,26 @@ class u {
|
|
|
122
122
|
*/
|
|
123
123
|
#d(s = !1) {
|
|
124
124
|
const e = /* @__PURE__ */ new Map();
|
|
125
|
-
let t = "state:" + this.#s;
|
|
126
|
-
s && (t = "state:" + this.#s + ":" + location.pathname),
|
|
127
|
-
const
|
|
128
|
-
e.set(
|
|
125
|
+
let t = this.#o, a = "state:" + this.#s;
|
|
126
|
+
s && (t = this.#r, a = "state:" + this.#s + ":" + location.pathname), t.forEach((o) => {
|
|
127
|
+
const r = localStorage.getItem(a + ":" + o);
|
|
128
|
+
e.set(o, r);
|
|
129
129
|
});
|
|
130
|
-
const
|
|
131
|
-
this.#
|
|
130
|
+
const i = this.#p(e);
|
|
131
|
+
this.#h(i);
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* Сохранить опции в localStorage
|
|
135
135
|
* @param isLocal - сохранить с учетом адреса страницы
|
|
136
136
|
*/
|
|
137
|
-
#
|
|
137
|
+
#f(s = !1) {
|
|
138
138
|
const e = /* @__PURE__ */ new Map();
|
|
139
139
|
let t = this.#o, a = "state:" + this.#s;
|
|
140
|
-
s && (t = this.#
|
|
140
|
+
s && (t = this.#r, a = "state:" + this.#s + ":" + location.pathname), t.forEach((o) => {
|
|
141
141
|
const r = this.#t[o];
|
|
142
142
|
e.set(o, r);
|
|
143
143
|
});
|
|
144
|
-
const i = this.#
|
|
144
|
+
const i = this.#m(e);
|
|
145
145
|
t.forEach((o) => {
|
|
146
146
|
const r = i.get(o);
|
|
147
147
|
localStorage.setItem(a + ":" + o, r);
|
|
@@ -156,12 +156,12 @@ class u {
|
|
|
156
156
|
if (!s) return;
|
|
157
157
|
this.#a.id === -1 && (this.#a.positionsReverseDates = s.positionsReverseDates);
|
|
158
158
|
const e = /* @__PURE__ */ new Map();
|
|
159
|
-
this.#
|
|
159
|
+
this.#n.forEach((n) => {
|
|
160
160
|
const h = s[n];
|
|
161
161
|
e.set(n, h);
|
|
162
162
|
});
|
|
163
163
|
const t = this.#p(e);
|
|
164
|
-
this.#
|
|
164
|
+
this.#h(t);
|
|
165
165
|
const a = $(".mod_guest_title");
|
|
166
166
|
if (((r = this.#t.competitorsIds) == null ? void 0 : r.length) === 1 && this.#e.page.data.competitors) {
|
|
167
167
|
let n = this.#e.page.data.competitors.filter((h) => h.id === s.competitorsIds[0]);
|