silentium-components 0.0.1
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/.husky/pre-commit +1 -0
- package/.vscode/settings.json +4 -0
- package/CHANGELOG.md +165 -0
- package/LICENSE.md +7 -0
- package/README.md +4 -0
- package/beforeRelease.sh +11 -0
- package/commitizen.cjs +50 -0
- package/dist/patron-components.cjs +372 -0
- package/dist/patron-components.cjs.map +1 -0
- package/dist/patron-components.d.ts +158 -0
- package/dist/patron-components.js +358 -0
- package/dist/patron-components.js.map +1 -0
- package/dist/patron-components.min.js +1 -0
- package/dist/patron-components.min.mjs +2 -0
- package/dist/patron-components.min.mjs.map +1 -0
- package/dist/patron-components.mjs +358 -0
- package/dist/patron-components.mjs.map +1 -0
- package/dist/silentium-components.cjs +372 -0
- package/dist/silentium-components.cjs.map +1 -0
- package/dist/silentium-components.d.ts +169 -0
- package/dist/silentium-components.js +358 -0
- package/dist/silentium-components.js.map +1 -0
- package/dist/silentium-components.min.js +1 -0
- package/dist/silentium-components.min.mjs +2 -0
- package/dist/silentium-components.min.mjs.map +1 -0
- package/dist/silentium-components.mjs +358 -0
- package/dist/silentium-components.mjs.map +1 -0
- package/docs/assets/css/base.css +3 -0
- package/docs/assets/img/github_16.jpg +0 -0
- package/docs/assets/js/index.mjs +70 -0
- package/docs/assets/lib/StyleFetched.mjs +16 -0
- package/docs/build.sh +25 -0
- package/docs/buildRoutes.sh +15 -0
- package/docs/favicon.ico +0 -0
- package/docs/index-dev.html +233 -0
- package/docs/index.html +233 -0
- package/docs/pages/404.html +1 -0
- package/docs/pages/index.html +7 -0
- package/docs/pages/navigation/navigation.html +1 -0
- package/docs/pages/navigation/router.html +1 -0
- package/docs/pages/navigation.html +12 -0
- package/docs/routes.json +1 -0
- package/docs/template.html +233 -0
- package/eslint.config.mjs +42 -0
- package/package.json +63 -0
- package/rollup.config.js +52 -0
- package/src/behaviors/Dirty.test.ts +20 -0
- package/src/behaviors/Dirty.ts +62 -0
- package/src/behaviors/Touched.ts +0 -0
- package/src/controls/ComputedElement.ts +51 -0
- package/src/controls/GroupActiveClass.test.ts +26 -0
- package/src/controls/GroupActiveClass.ts +29 -0
- package/src/controls/Input.ts +40 -0
- package/src/controls/Link.ts +53 -0
- package/src/controls/Text.ts +16 -0
- package/src/controls/Visible.ts +16 -0
- package/src/controls/index.ts +6 -0
- package/src/index.ts +3 -0
- package/src/jsdom/JSDomDocument.ts +15 -0
- package/src/jsdom/JSDomElement.ts +28 -0
- package/src/jsdom/JSDomQuerySelector.ts +28 -0
- package/src/navigation/CurrentPage.ts +27 -0
- package/src/navigation/Navigation.default.test.ts +53 -0
- package/src/navigation/Navigation.main.test.ts +46 -0
- package/src/navigation/Navigation.ts +92 -0
- package/src/navigation/Navigation.wildcard.test.ts +52 -0
- package/src/navigation/PageFetchTransport.ts +26 -0
- package/src/navigation/RouteDisplay.ts +18 -0
- package/src/navigation/RoutePageType.ts +3 -0
- package/src/navigation/Router.ts +118 -0
- package/src/navigation/index.ts +7 -0
- package/src/page/EntryPointPage.ts +20 -0
- package/src/page/Page.ts +12 -0
- package/src/page/PageFake.ts +8 -0
- package/src/page/index.ts +2 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm run build-doc;
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
+
|
|
5
|
+
### 0.0.1 (2025-04-12)
|
|
6
|
+
|
|
7
|
+
## [1.20.0](https://github.com/kosukhin/patron-web-api/compare/v1.19.0...v1.20.0) (2025-04-05)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **3-issue:** docs init ([13caf63](https://github.com/kosukhin/patron-web-api/commit/13caf638789914c5099e50897fb9e0c9e0b239db))
|
|
13
|
+
* **3-issue:** initial docs template done ([fca3397](https://github.com/kosukhin/patron-web-api/commit/fca33976331ca25be7bbc2c43beb2e1998b5749e))
|
|
14
|
+
* **main:** initial docs files ([1299608](https://github.com/kosukhin/patron-web-api/commit/12996082d98188256fefc0673a5f1e35df934421))
|
|
15
|
+
|
|
16
|
+
## [1.19.0](https://github.com/kosukhin/patron-web-api/compare/v1.18.0...v1.19.0) (2025-03-30)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* **1-issue:** rename source ([6baa09f](https://github.com/kosukhin/patron-web-api/commit/6baa09f8404a571149e82ef42e9e286f5e5db01b))
|
|
22
|
+
* **1-issue:** rework source classes ([981693d](https://github.com/kosukhin/patron-web-api/commit/981693d1dc401f68f14d32a100174610d1392aba))
|
|
23
|
+
* **1-issue:** tests on js dom ([1e5f732](https://github.com/kosukhin/patron-web-api/commit/1e5f732ef995ade67c9ecec1d0a262d342c77d62))
|
|
24
|
+
* **1-issue:** work on source renaming ([961aba4](https://github.com/kosukhin/patron-web-api/commit/961aba4f0698481c297f6011c02acb29a4dbf918))
|
|
25
|
+
|
|
26
|
+
## [1.18.0](https://github.com/kosukhin/patron-web-api/compare/v1.17.0...v1.18.0) (2025-02-15)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* **main:** fix navigation ([3c344ac](https://github.com/kosukhin/patron-web-api/commit/3c344acdb231f21ae1f6a8d957324308daadcff1))
|
|
32
|
+
|
|
33
|
+
## [1.17.0](https://github.com/kosukhin/patron-web-api/compare/v1.16.0...v1.17.0) (2025-01-22)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* **main:** add pull to current page ([8bb248e](https://github.com/kosukhin/patron-web-api/commit/8bb248e71a5412d39ce0f218c5b63420d9d11b77))
|
|
39
|
+
* **main:** input source pool ([6516b9e](https://github.com/kosukhin/patron-web-api/commit/6516b9e8125c75450957b7307c33d837cced4db6))
|
|
40
|
+
* **main:** update guest chain ([34324e6](https://github.com/kosukhin/patron-web-api/commit/34324e6756ed4ff249df7192ba2ea96d8d0fc293))
|
|
41
|
+
|
|
42
|
+
## [1.16.0](https://github.com/kosukhin/patron-web-api/compare/v1.15.0...v1.16.0) (2024-11-14)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Features
|
|
46
|
+
|
|
47
|
+
* **main:** решил ошибку динамических ссылок preventDefault не работал ([7fd2ced](https://github.com/kosukhin/patron-web-api/commit/7fd2ced7597146baff4ff7d1ef97f5e3f4a2d88e))
|
|
48
|
+
|
|
49
|
+
## [1.15.0](https://github.com/kosukhin/patron-web-api/compare/v1.14.0...v1.15.0) (2024-11-12)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
* **main:** link может ходить по абсолютным ссылкам ([fa40c81](https://github.com/kosukhin/patron-web-api/commit/fa40c8109bd3bba61ad624dfddd34abfbcec17fe))
|
|
55
|
+
|
|
56
|
+
## [1.14.0](https://github.com/kosukhin/patron-web-api/compare/v1.13.0...v1.14.0) (2024-11-09)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Features
|
|
60
|
+
|
|
61
|
+
* **main:** link может управлять элементами которых еще нет ([ada3556](https://github.com/kosukhin/patron-web-api/commit/ada3556b7a753b1eebdcb9821707187947eb3a86))
|
|
62
|
+
|
|
63
|
+
## [1.13.0](https://github.com/kosukhin/patron-web-api/compare/v1.12.1...v1.13.0) (2024-11-08)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
* **main:** убрать гость мидл ([d31fc90](https://github.com/kosukhin/patron-web-api/commit/d31fc90e8ea14bf4c8bc0ba04a4bfca3aed01d3f))
|
|
69
|
+
|
|
70
|
+
### [1.12.1](https://github.com/kosukhin/patron-web-api/compare/v1.12.0...v1.12.1) (2024-11-08)
|
|
71
|
+
|
|
72
|
+
## [1.12.0](https://github.com/kosukhin/patron-web-api/compare/v1.11.0...v1.12.0) (2024-11-04)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Features
|
|
76
|
+
|
|
77
|
+
* **main:** в navigation добавлена обработка wildcard ([71d1708](https://github.com/kosukhin/patron-web-api/commit/71d17085450ae89dc4027024f3b13bee1f8ac92d))
|
|
78
|
+
|
|
79
|
+
## [1.11.0](https://github.com/kosukhin/patron-web-api/compare/v1.10.0...v1.11.0) (2024-11-03)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
### Features
|
|
83
|
+
|
|
84
|
+
* **main:** link может работать с несколькими элементами ([5a7d2f0](https://github.com/kosukhin/patron-web-api/commit/5a7d2f060cae29534a8bd78c6daedf0d82f96cb3))
|
|
85
|
+
|
|
86
|
+
## [1.10.0](https://github.com/kosukhin/patron-web-api/compare/v1.9.0...v1.10.0) (2024-11-02)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
### Features
|
|
90
|
+
|
|
91
|
+
* **main:** наработка по алиасам навигации ([57b4ac2](https://github.com/kosukhin/patron-web-api/commit/57b4ac22d02d1c1e66791c8c108be6138f51cf13))
|
|
92
|
+
* **main:** сделать удобную команду релиза ([567fd60](https://github.com/kosukhin/patron-web-api/commit/567fd60f9bfaf2cad1bd3384af04c03e4a64e30b))
|
|
93
|
+
|
|
94
|
+
## [1.9.0](https://github.com/kosukhin/patron-web-api/compare/v1.8.0...v1.9.0) (2024-11-02)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
### Features
|
|
98
|
+
|
|
99
|
+
* **main:** доделал логику алиасов для navigation ([4852bea](https://github.com/kosukhin/patron-web-api/commit/4852bea60f728518cc74424225611ffd741a6837))
|
|
100
|
+
* **main:** работа по поддержке алиасов в navigation ([f2d72eb](https://github.com/kosukhin/patron-web-api/commit/f2d72ebeabbd0f5420e8a12e77b399953edf9ca8))
|
|
101
|
+
|
|
102
|
+
## [1.8.0](https://github.com/kosukhin/patron-web-api/compare/v1.7.0...v1.8.0) (2024-11-02)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### Features
|
|
106
|
+
|
|
107
|
+
* **main:** адаптировать код к версии paron с value-give ([81c06ef](https://github.com/kosukhin/patron-web-api/commit/81c06ef3e837a6c205c36863c88d56437a9357d7))
|
|
108
|
+
|
|
109
|
+
## [1.7.0](https://github.com/kosukhin/patron-web-api/compare/v1.6.0...v1.7.0) (2024-11-01)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
### Features
|
|
113
|
+
|
|
114
|
+
* **main:** страницы с энтри поинтами ([b31a130](https://github.com/kosukhin/patron-web-api/commit/b31a130eaa73e9a4bef28e5b32f2ebbcde729864))
|
|
115
|
+
|
|
116
|
+
## [1.6.0](https://github.com/kosukhin/patron-web-api/compare/v1.5.0...v1.6.0) (2024-11-01)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
### Features
|
|
120
|
+
|
|
121
|
+
* **main:** исправление явных ошибок в Navigation классе ([5d21632](https://github.com/kosukhin/patron-web-api/commit/5d21632956df0bed0a19795326b60d0449c51913))
|
|
122
|
+
* **main:** улучшения логики и форматирования ([e000995](https://github.com/kosukhin/patron-web-api/commit/e000995185132a225903034e20800bdbc0bc9ff1))
|
|
123
|
+
|
|
124
|
+
## [1.5.0](https://github.com/kosukhin/patron-web-api/compare/v1.4.0...v1.5.0) (2024-10-31)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
### Features
|
|
128
|
+
|
|
129
|
+
* **main:** добавить publish скрипт ([0408b81](https://github.com/kosukhin/patron-web-api/commit/0408b81e8ef94a6bfbe99d27f4decf938f1494b2))
|
|
130
|
+
* **main:** доделал роутинг и базовые компоненты ([7135b1b](https://github.com/kosukhin/patron-web-api/commit/7135b1b0211d0026a5865092ed590cedd4250d30))
|
|
131
|
+
* **main:** нарабокти по навигации ([335c1b4](https://github.com/kosukhin/patron-web-api/commit/335c1b48e3f336dbce7496d6e5ca74c5c9115055))
|
|
132
|
+
|
|
133
|
+
## 1.4.0 (2024-10-30)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
### Features
|
|
137
|
+
|
|
138
|
+
* **main:** доделал основные компоненты ([043ff6a](https://github.com/kosukhin/patron-web-api/commit/043ff6a4c75d085cdaadf7232349cd0c7314cc71))
|
|
139
|
+
* **main:** изменить название библиотеки ([6e13618](https://github.com/kosukhin/patron-web-api/commit/6e136187e207a8366891f4582a80de2284e0aa9b))
|
|
140
|
+
* **main:** наработка с примером роутера ([99057f4](https://github.com/kosukhin/patron-web-api/commit/99057f40947113d2e262e7f3065fe124af3ec41f))
|
|
141
|
+
* **main:** наработки для исключения зависимостей и Route ([cb350fe](https://github.com/kosukhin/patron-web-api/commit/cb350fe34c953f170fb28eafd2dba8a6e01ed487))
|
|
142
|
+
* **main:** наработки по комопнентам и оптимизация Navigation ([af7bf44](https://github.com/kosukhin/patron-web-api/commit/af7bf446261c3961352e9b689c139a0ee8b8def5))
|
|
143
|
+
* **main:** настроить общий index.ts ([6bd70be](https://github.com/kosukhin/patron-web-api/commit/6bd70be70e7ba5223f3ef3421b119cf27624987c))
|
|
144
|
+
* **main:** роут сделал ([20ca58b](https://github.com/kosukhin/patron-web-api/commit/20ca58b5d00b3f9296d203dd4fcfd273655fd91f))
|
|
145
|
+
|
|
146
|
+
## [1.3.0](https://github.com/kosukhin/patron-web-api/compare/v1.2.0...v1.3.0) (2024-10-27)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### Features
|
|
150
|
+
|
|
151
|
+
* **main:** настроить общий index.ts ([6bd70be](https://github.com/kosukhin/patron-web-api/commit/6bd70be70e7ba5223f3ef3421b119cf27624987c))
|
|
152
|
+
|
|
153
|
+
## [1.2.0](https://github.com/kosukhin/patron-web-api/compare/v1.1.0...v1.2.0) (2024-10-27)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
### Features
|
|
157
|
+
|
|
158
|
+
* **main:** изменить название библиотеки ([6e13618](https://github.com/kosukhin/patron-web-api/commit/6e136187e207a8366891f4582a80de2284e0aa9b))
|
|
159
|
+
|
|
160
|
+
## 1.1.0 (2024-10-27)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
### Features
|
|
164
|
+
|
|
165
|
+
* **main:** роут сделал ([20ca58b](https://github.com/kosukhin/patron-web-api/commit/20ca58b5d00b3f9296d203dd4fcfd273655fd91f))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2025 Silentium Lab
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
package/beforeRelease.sh
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
4
|
+
|
|
5
|
+
if [ "$current_branch" != "main" ]; then
|
|
6
|
+
echo "Error: Current branch not 'main'. Release impossible you are on '$current_branch'."
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
echo "Current branch — 'main'."
|
|
11
|
+
exit 0
|
package/commitizen.cjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
|
|
3
|
+
function getGitBranch() {
|
|
4
|
+
const res = execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf8" });
|
|
5
|
+
return res.trim();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
types: [
|
|
10
|
+
{
|
|
11
|
+
value: "feat",
|
|
12
|
+
name: "feat: Добавление нового функционала",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
value: "refactor",
|
|
16
|
+
name: "refactor: Правки кода без исправления ошибок или добавления новых функций",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: "fix",
|
|
20
|
+
name: "fix: Исправление ошибок",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
value: "build",
|
|
24
|
+
name: "build: Сборка проекта или изменения внешних зависимостей",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
value: "docs",
|
|
28
|
+
name: "docs: Обновление документации",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
value: "docs",
|
|
32
|
+
name: "docs: Правки по документации проекта или отдельных частей проекта",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
value: "test",
|
|
36
|
+
name: "test: Добавление тестов",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
scopes: [
|
|
40
|
+
{
|
|
41
|
+
name: getGitBranch(),
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
|
|
45
|
+
allowCustomScopes: true,
|
|
46
|
+
|
|
47
|
+
allowBreakingChanges: false,
|
|
48
|
+
|
|
49
|
+
subjectLimit: 72,
|
|
50
|
+
};
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var patronOop = require('patron-oop');
|
|
4
|
+
var patronWebApi = require('patron-web-api');
|
|
5
|
+
|
|
6
|
+
class PageFetchTransport {
|
|
7
|
+
constructor(basePath, template) {
|
|
8
|
+
this.basePath = basePath;
|
|
9
|
+
this.template = template;
|
|
10
|
+
}
|
|
11
|
+
content(guest) {
|
|
12
|
+
fetch(this.basePath + "/" + this.template).then((result) => {
|
|
13
|
+
return result.text();
|
|
14
|
+
}).then((result) => {
|
|
15
|
+
patronOop.give(result, guest);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class Navigation {
|
|
21
|
+
constructor(loading, basePath, currentPage, display, pageTransport) {
|
|
22
|
+
this.loading = loading;
|
|
23
|
+
this.basePath = basePath;
|
|
24
|
+
this.currentPage = currentPage;
|
|
25
|
+
this.display = display;
|
|
26
|
+
this.pageTransport = pageTransport;
|
|
27
|
+
}
|
|
28
|
+
routes(routes) {
|
|
29
|
+
const defaultRoute = routes.find((route) => route.default);
|
|
30
|
+
const all = new patronOop.SourceAll();
|
|
31
|
+
patronOop.value(this.basePath, new patronOop.Patron(all.guestKey("basePath")));
|
|
32
|
+
patronOop.value(this.currentPage, new patronOop.Patron(all.guestKey("currentPage")));
|
|
33
|
+
all.value(
|
|
34
|
+
new patronOop.Patron(({ basePath, currentPage }) => {
|
|
35
|
+
const urlWithoutBasePath = currentPage.replace(basePath, "");
|
|
36
|
+
const routeMatchedToAlias = routes.find(
|
|
37
|
+
(route2) => route2.aliases && (route2.aliases.includes(currentPage) || route2.aliases.includes(urlWithoutBasePath))
|
|
38
|
+
);
|
|
39
|
+
if (routeMatchedToAlias) {
|
|
40
|
+
const correctUrl = basePath + routeMatchedToAlias.url;
|
|
41
|
+
if (correctUrl !== currentPage) {
|
|
42
|
+
patronOop.give(correctUrl, this.currentPage);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
let route = routes.find((route2) => {
|
|
47
|
+
if (route2.url.indexOf("*") >= 0) {
|
|
48
|
+
const regexp = new RegExp(
|
|
49
|
+
route2.url.replaceAll("*", ".*").replaceAll("/", "/")
|
|
50
|
+
);
|
|
51
|
+
return regexp.test(urlWithoutBasePath);
|
|
52
|
+
}
|
|
53
|
+
return route2.url.replaceAll("*", "") === urlWithoutBasePath;
|
|
54
|
+
});
|
|
55
|
+
if (!route && defaultRoute) {
|
|
56
|
+
route = defaultRoute;
|
|
57
|
+
}
|
|
58
|
+
if (route) {
|
|
59
|
+
const basePathWithoutHash = basePath.replace("/#", "").replace("#", "").replace(/[^/]+\.html$/, "");
|
|
60
|
+
patronOop.give(true, this.loading);
|
|
61
|
+
this.pageTransport.get(basePathWithoutHash, route.template).content((templateContent) => {
|
|
62
|
+
this.display.display(templateContent);
|
|
63
|
+
route.page.mounted();
|
|
64
|
+
patronOop.give(false, this.loading);
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error("No matching route in Navigation");
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
class RouteDisplay {
|
|
75
|
+
constructor(selector) {
|
|
76
|
+
this.selector = selector;
|
|
77
|
+
}
|
|
78
|
+
display(content) {
|
|
79
|
+
const contentEl = document.querySelector(this.selector);
|
|
80
|
+
if (contentEl) {
|
|
81
|
+
contentEl.innerHTML = content;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var __defProp = Object.defineProperty;
|
|
87
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
88
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
|
|
89
|
+
class CurrentPage {
|
|
90
|
+
constructor() {
|
|
91
|
+
__publicField(this, "source");
|
|
92
|
+
const correctUrl = location.href.replace(location.origin, "");
|
|
93
|
+
this.source = new patronOop.SourceWithPool(correctUrl);
|
|
94
|
+
}
|
|
95
|
+
give(value) {
|
|
96
|
+
this.source.give(value);
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
value(guest) {
|
|
100
|
+
this.source.value(guest);
|
|
101
|
+
return guest;
|
|
102
|
+
}
|
|
103
|
+
pool() {
|
|
104
|
+
return this.source.pool();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
class Input {
|
|
109
|
+
constructor(source, selector) {
|
|
110
|
+
this.source = source;
|
|
111
|
+
const el = document.querySelector(selector);
|
|
112
|
+
this.source.value(
|
|
113
|
+
new patronOop.Patron((value) => {
|
|
114
|
+
el.value = String(value);
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
el.addEventListener("keyup", () => {
|
|
118
|
+
this.give(el.value);
|
|
119
|
+
});
|
|
120
|
+
el.addEventListener("change", () => {
|
|
121
|
+
this.give(el.value);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
value(guest) {
|
|
125
|
+
this.source.value(guest);
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
give(value) {
|
|
129
|
+
this.source.give(value);
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
pool() {
|
|
133
|
+
return this.source.pool();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
class Visible {
|
|
138
|
+
constructor(selector) {
|
|
139
|
+
this.selector = selector;
|
|
140
|
+
}
|
|
141
|
+
give(isVisible) {
|
|
142
|
+
const el = document.querySelector(this.selector);
|
|
143
|
+
if (el) {
|
|
144
|
+
el.style.display = isVisible ? "block" : "none";
|
|
145
|
+
}
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
class Text {
|
|
151
|
+
constructor(selector) {
|
|
152
|
+
this.selector = selector;
|
|
153
|
+
}
|
|
154
|
+
give(value) {
|
|
155
|
+
const element = document.querySelector(this.selector);
|
|
156
|
+
if (element) {
|
|
157
|
+
element.innerText = String(value);
|
|
158
|
+
}
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
class Link {
|
|
164
|
+
constructor(linkSource, basePath) {
|
|
165
|
+
this.linkSource = linkSource;
|
|
166
|
+
this.basePath = basePath;
|
|
167
|
+
}
|
|
168
|
+
watchClick(selector, subselector) {
|
|
169
|
+
const wrapperEl = document.querySelectorAll(selector);
|
|
170
|
+
if (wrapperEl.length) {
|
|
171
|
+
wrapperEl.forEach((theElement) => {
|
|
172
|
+
theElement.addEventListener("click", (e) => {
|
|
173
|
+
if (subselector) {
|
|
174
|
+
theElement.querySelectorAll(subselector).forEach((theSubElement) => {
|
|
175
|
+
if (e?.target === theSubElement || e?.currentTarget === theSubElement) {
|
|
176
|
+
this.handleClick({
|
|
177
|
+
preventDefault: e.preventDefault.bind(e),
|
|
178
|
+
target: theSubElement
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
} else {
|
|
183
|
+
this.handleClick(e);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
} else {
|
|
188
|
+
throw new Error(`Link wrapper not found for selector ${selector}`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
handleClick(e) {
|
|
192
|
+
let href = e?.target?.getAttribute("href");
|
|
193
|
+
if (!href) {
|
|
194
|
+
href = e?.currentTarget?.getAttribute("href");
|
|
195
|
+
}
|
|
196
|
+
if (href && href.indexOf("http") !== 0) {
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
patronOop.value(this.basePath, (basePath) => {
|
|
199
|
+
this.linkSource.give(basePath + href);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
class ComputedElement {
|
|
206
|
+
constructor(sources, selectorTemplate) {
|
|
207
|
+
this.sources = sources;
|
|
208
|
+
this.selectorTemplate = selectorTemplate;
|
|
209
|
+
}
|
|
210
|
+
element(guest) {
|
|
211
|
+
const chain = new patronOop.SourceAll();
|
|
212
|
+
this.sources.forEach((source) => {
|
|
213
|
+
source.source.value(
|
|
214
|
+
new patronOop.GuestCast(guest, chain.guestKey(source.placeholder))
|
|
215
|
+
);
|
|
216
|
+
});
|
|
217
|
+
chain.value(
|
|
218
|
+
new patronOop.GuestCast(
|
|
219
|
+
guest,
|
|
220
|
+
(placeholders) => {
|
|
221
|
+
let selectorTemplate = this.selectorTemplate;
|
|
222
|
+
Object.entries(placeholders).map((entry) => {
|
|
223
|
+
selectorTemplate = selectorTemplate.replaceAll(entry[0], entry[1]);
|
|
224
|
+
});
|
|
225
|
+
const element = document.querySelector(
|
|
226
|
+
selectorTemplate
|
|
227
|
+
);
|
|
228
|
+
if (element) {
|
|
229
|
+
patronOop.give(element, guest);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
class GroupActiveClass {
|
|
238
|
+
constructor(activeClass, groupSelector, document) {
|
|
239
|
+
this.activeClass = activeClass;
|
|
240
|
+
this.groupSelector = groupSelector;
|
|
241
|
+
this.document = document;
|
|
242
|
+
}
|
|
243
|
+
give(element) {
|
|
244
|
+
patronOop.value(
|
|
245
|
+
this.document,
|
|
246
|
+
new patronOop.PatronOnce((document) => {
|
|
247
|
+
document.querySelectorAll(this.groupSelector).forEach((el) => {
|
|
248
|
+
el.classList.remove(this.activeClass);
|
|
249
|
+
});
|
|
250
|
+
element.classList.add(this.activeClass);
|
|
251
|
+
})
|
|
252
|
+
);
|
|
253
|
+
return this;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
class Router {
|
|
258
|
+
constructor(loaderSelector, navigationResultSelector, menuSelector) {
|
|
259
|
+
this.loaderSelector = loaderSelector;
|
|
260
|
+
this.navigationResultSelector = navigationResultSelector;
|
|
261
|
+
this.menuSelector = menuSelector;
|
|
262
|
+
}
|
|
263
|
+
routes(routes, currentPage, basePathSource, afterPageLoaded) {
|
|
264
|
+
if (!currentPage) {
|
|
265
|
+
currentPage = new CurrentPage();
|
|
266
|
+
}
|
|
267
|
+
currentPage.value(new patronOop.Patron(new patronWebApi.HistoryNewPage()));
|
|
268
|
+
const [basePath] = location.href.replace(location.origin, "").split("#");
|
|
269
|
+
if (!basePathSource) {
|
|
270
|
+
basePathSource = new patronOop.SourceWithPool(
|
|
271
|
+
`${basePath}#`.replace("index.html", "").replace("//", "/")
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
const pageLoading = new patronOop.SourceWithPool(false);
|
|
275
|
+
pageLoading.value(new patronOop.Patron(new Visible(this.loaderSelector)));
|
|
276
|
+
const historyPoppedPage = new patronWebApi.HistoryPoppedPage(currentPage);
|
|
277
|
+
historyPoppedPage.watchPop();
|
|
278
|
+
const navigation = new Navigation(
|
|
279
|
+
pageLoading,
|
|
280
|
+
basePathSource,
|
|
281
|
+
currentPage,
|
|
282
|
+
new RouteDisplay(this.navigationResultSelector),
|
|
283
|
+
new patronOop.PrivateClass(PageFetchTransport)
|
|
284
|
+
);
|
|
285
|
+
navigation.routes(routes);
|
|
286
|
+
const link = new Link(currentPage, basePathSource);
|
|
287
|
+
link.watchClick(this.menuSelector);
|
|
288
|
+
const urlChain = new patronOop.SourceAll();
|
|
289
|
+
basePathSource.value(new patronOop.Patron(urlChain.guestKey("basePath")));
|
|
290
|
+
currentPage.value(new patronOop.Patron(urlChain.guestKey("page")));
|
|
291
|
+
const url = new patronOop.Source((guest) => {
|
|
292
|
+
urlChain.value(
|
|
293
|
+
new patronOop.GuestCast(guest, ({ basePath: basePath2, page }) => {
|
|
294
|
+
patronOop.give(page.replace(basePath2, ""), guest);
|
|
295
|
+
})
|
|
296
|
+
);
|
|
297
|
+
});
|
|
298
|
+
const activeLink = new ComputedElement(
|
|
299
|
+
[{ source: url, placeholder: "{url}" }],
|
|
300
|
+
`${this.menuSelector} a[href="{url}"]`
|
|
301
|
+
);
|
|
302
|
+
activeLink.element(
|
|
303
|
+
new patronOop.Patron(
|
|
304
|
+
new GroupActiveClass(
|
|
305
|
+
"active",
|
|
306
|
+
`${this.menuSelector} a`,
|
|
307
|
+
patronOop.sourceOf(document)
|
|
308
|
+
)
|
|
309
|
+
)
|
|
310
|
+
);
|
|
311
|
+
pageLoading.value(
|
|
312
|
+
new patronOop.Patron((isInLoading) => {
|
|
313
|
+
if (isInLoading) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (afterPageLoaded) {
|
|
317
|
+
afterPageLoaded();
|
|
318
|
+
}
|
|
319
|
+
const divDestination = document.querySelector(
|
|
320
|
+
this.navigationResultSelector
|
|
321
|
+
);
|
|
322
|
+
if (divDestination) {
|
|
323
|
+
divDestination.querySelectorAll("script").forEach((x) => {
|
|
324
|
+
const sc = document.createElement("script");
|
|
325
|
+
sc.setAttribute("type", "module");
|
|
326
|
+
sc.appendChild(document.createTextNode(x.innerText));
|
|
327
|
+
divDestination.appendChild(sc);
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
})
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
class Page {
|
|
336
|
+
constructor(title) {
|
|
337
|
+
this.title = title;
|
|
338
|
+
}
|
|
339
|
+
mounted() {
|
|
340
|
+
document.title = this.title;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
class EntryPointPage {
|
|
345
|
+
constructor(title, entryPointUrl) {
|
|
346
|
+
this.title = title;
|
|
347
|
+
this.entryPointUrl = entryPointUrl;
|
|
348
|
+
}
|
|
349
|
+
mounted() {
|
|
350
|
+
document.title = this.title;
|
|
351
|
+
import(this.entryPointUrl).then((module) => {
|
|
352
|
+
if (module.main) {
|
|
353
|
+
module.main();
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
exports.ComputedElement = ComputedElement;
|
|
360
|
+
exports.CurrentPage = CurrentPage;
|
|
361
|
+
exports.EntryPointPage = EntryPointPage;
|
|
362
|
+
exports.GroupActiveClass = GroupActiveClass;
|
|
363
|
+
exports.Input = Input;
|
|
364
|
+
exports.Link = Link;
|
|
365
|
+
exports.Navigation = Navigation;
|
|
366
|
+
exports.Page = Page;
|
|
367
|
+
exports.PageFetchTransport = PageFetchTransport;
|
|
368
|
+
exports.RouteDisplay = RouteDisplay;
|
|
369
|
+
exports.Router = Router;
|
|
370
|
+
exports.Text = Text;
|
|
371
|
+
exports.Visible = Visible;
|
|
372
|
+
//# sourceMappingURL=patron-components.cjs.map
|