typecomposer 0.1.26 → 0.1.27
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/core/app/Validate.d.ts +61 -0
- package/core/app/Validate.js +2 -0
- package/core/app/Validate.js.map +1 -0
- package/core/app/index.d.ts +39 -0
- package/core/app/index.js +174 -0
- package/core/app/index.js.map +1 -0
- package/core/components/AlertPanel.d.ts +31 -0
- package/core/components/AlertPanel.js +74 -0
- package/core/components/AlertPanel.js.map +1 -0
- package/core/components/AvatarPanel.d.ts +20 -0
- package/core/components/AvatarPanel.js +62 -0
- package/core/components/AvatarPanel.js.map +1 -0
- package/core/components/BorderPanel.d.ts +27 -0
- package/core/components/BorderPanel.js +89 -0
- package/core/components/BorderPanel.js.map +1 -0
- package/core/components/CardPanel.d.ts +4 -0
- package/core/components/CardPanel.js +10 -0
- package/core/components/CardPanel.js.map +1 -0
- package/core/components/CheckBox.d.ts +34 -0
- package/core/components/CheckBox.js +107 -0
- package/core/components/CheckBox.js.map +1 -0
- package/core/components/ColorPicker.d.ts +9 -0
- package/core/components/ColorPicker.js +32 -0
- package/core/components/ColorPicker.js.map +1 -0
- package/core/components/ContextMenu.d.ts +14 -0
- package/core/components/ContextMenu.js +62 -0
- package/core/components/ContextMenu.js.map +1 -0
- package/core/components/DialogPanel.d.ts +14 -0
- package/core/components/DialogPanel.js +62 -0
- package/core/components/DialogPanel.js.map +1 -0
- package/core/components/DropDown.d.ts +51 -0
- package/core/components/DropDown.js +213 -0
- package/core/components/DropDown.js.map +1 -0
- package/core/components/FlowPanel.d.ts +10 -0
- package/core/components/FlowPanel.js +39 -0
- package/core/components/FlowPanel.js.map +1 -0
- package/core/components/ForEach.d.ts +10 -0
- package/core/components/ForEach.js +86 -0
- package/core/components/ForEach.js.map +1 -0
- package/core/components/GridPanel.d.ts +9 -0
- package/core/components/GridPanel.js +29 -0
- package/core/components/GridPanel.js.map +1 -0
- package/core/components/HBox.d.ts +4 -0
- package/core/components/HBox.js +9 -0
- package/core/components/HBox.js.map +1 -0
- package/core/components/LazyLoading.d.ts +18 -0
- package/core/components/LazyLoading.js +35 -0
- package/core/components/LazyLoading.js.map +1 -0
- package/core/components/ListPanel.d.ts +26 -0
- package/core/components/ListPanel.js +152 -0
- package/core/components/ListPanel.js.map +1 -0
- package/core/components/PopUpButton.d.ts +17 -0
- package/core/components/PopUpButton.js +54 -0
- package/core/components/PopUpButton.js.map +1 -0
- package/core/components/ScrollPanel.d.ts +13 -0
- package/core/components/ScrollPanel.js +34 -0
- package/core/components/ScrollPanel.js.map +1 -0
- package/core/components/StackPanel.d.ts +4 -0
- package/core/components/StackPanel.js +9 -0
- package/core/components/StackPanel.js.map +1 -0
- package/core/components/TabItem.d.ts +18 -0
- package/core/components/TabItem.js +81 -0
- package/core/components/TabItem.js.map +1 -0
- package/core/components/TabPanel.d.ts +24 -0
- package/core/components/TabPanel.js +95 -0
- package/core/components/TabPanel.js.map +1 -0
- package/core/components/TablePanel.d.ts +32 -0
- package/core/components/TablePanel.js +125 -0
- package/core/components/TablePanel.js.map +1 -0
- package/core/components/TextEdit.d.ts +31 -0
- package/core/components/TextEdit.js +172 -0
- package/core/components/TextEdit.js.map +1 -0
- package/core/components/TextField.d.ts +32 -0
- package/core/components/TextField.js +147 -0
- package/core/components/TextField.js.map +1 -0
- package/core/components/ToggleButton.d.ts +6 -0
- package/core/components/ToggleButton.js +19 -0
- package/core/components/ToggleButton.js.map +1 -0
- package/core/components/VBox.d.ts +4 -0
- package/core/components/VBox.js +9 -0
- package/core/components/VBox.js.map +1 -0
- package/core/components/VirtualScroll copy 2.d.ts +24 -0
- package/core/components/VirtualScroll copy 2.js +98 -0
- package/core/components/VirtualScroll copy 2.js.map +1 -0
- package/core/components/VirtualScroll.d.ts +19 -0
- package/core/components/VirtualScroll.js +46 -0
- package/core/components/VirtualScroll.js.map +1 -0
- package/core/components/index.d.ts +26 -0
- package/core/components/index.js +28 -0
- package/core/components/index.js.map +1 -0
- package/core/decorators/RegisterComponent.d.ts +8 -0
- package/core/decorators/RegisterComponent.js +5 -0
- package/core/decorators/RegisterComponent.js.map +1 -0
- package/core/decorators/StyleLink.d.ts +1 -0
- package/core/decorators/StyleLink.js +13 -0
- package/core/decorators/StyleLink.js.map +1 -0
- package/core/decorators/index.d.ts +4 -0
- package/core/decorators/index.js +6 -0
- package/core/decorators/index.js.map +1 -0
- package/core/element/AbbreviationElement.d.ts +6 -0
- package/core/element/AbbreviationElement.js +11 -0
- package/core/element/AbbreviationElement.js.map +1 -0
- package/core/element/AnchorElement.d.ts +23 -0
- package/core/element/AnchorElement.js +29 -0
- package/core/element/AnchorElement.js.map +1 -0
- package/core/element/AreaElement.d.ts +17 -0
- package/core/element/AreaElement.js +10 -0
- package/core/element/AreaElement.js.map +1 -0
- package/core/element/ArticleElement.d.ts +4 -0
- package/core/element/ArticleElement.js +11 -0
- package/core/element/ArticleElement.js.map +1 -0
- package/core/element/AudioElement.d.ts +11 -0
- package/core/element/AudioElement.js +9 -0
- package/core/element/AudioElement.js.map +1 -0
- package/core/element/BaseElement.d.ts +7 -0
- package/core/element/BaseElement.js +10 -0
- package/core/element/BaseElement.js.map +1 -0
- package/core/element/BodyElement.d.ts +4 -0
- package/core/element/BodyElement.js +10 -0
- package/core/element/BodyElement.js.map +1 -0
- package/core/element/BoldElement.d.ts +4 -0
- package/core/element/BoldElement.js +9 -0
- package/core/element/BoldElement.js.map +1 -0
- package/core/element/BreakElement.d.ts +4 -0
- package/core/element/BreakElement.js +9 -0
- package/core/element/BreakElement.js.map +1 -0
- package/core/element/ButtonElement.d.ts +25 -0
- package/core/element/ButtonElement.js +46 -0
- package/core/element/ButtonElement.js.map +1 -0
- package/core/element/CanvasElement.d.ts +4 -0
- package/core/element/CanvasElement.js +13 -0
- package/core/element/CanvasElement.js.map +1 -0
- package/core/element/CaptionElement.d.ts +4 -0
- package/core/element/CaptionElement.js +12 -0
- package/core/element/CaptionElement.js.map +1 -0
- package/core/element/CiteElement.d.ts +4 -0
- package/core/element/CiteElement.js +10 -0
- package/core/element/CiteElement.js.map +1 -0
- package/core/element/CodeElement.d.ts +6 -0
- package/core/element/CodeElement.js +12 -0
- package/core/element/CodeElement.js.map +1 -0
- package/core/element/DataListElement.d.ts +4 -0
- package/core/element/DataListElement.js +12 -0
- package/core/element/DataListElement.js.map +1 -0
- package/core/element/DefinitionDescriptionElement.d.ts +4 -0
- package/core/element/DefinitionDescriptionElement.js +12 -0
- package/core/element/DefinitionDescriptionElement.js.map +1 -0
- package/core/element/DefinitionElement.d.ts +4 -0
- package/core/element/DefinitionElement.js +12 -0
- package/core/element/DefinitionElement.js.map +1 -0
- package/core/element/DeletedTextElement.d.ts +6 -0
- package/core/element/DeletedTextElement.js +14 -0
- package/core/element/DeletedTextElement.js.map +1 -0
- package/core/element/DetailsElement.d.ts +8 -0
- package/core/element/DetailsElement.js +27 -0
- package/core/element/DetailsElement.js.map +1 -0
- package/core/element/DialogElement.d.ts +6 -0
- package/core/element/DialogElement.js +13 -0
- package/core/element/DialogElement.js.map +1 -0
- package/core/element/DivElement.d.ts +4 -0
- package/core/element/DivElement.js +9 -0
- package/core/element/DivElement.js.map +1 -0
- package/core/element/EmElement.d.ts +4 -0
- package/core/element/EmElement.js +9 -0
- package/core/element/EmElement.js.map +1 -0
- package/core/element/EmbedElement.d.ts +9 -0
- package/core/element/EmbedElement.js +18 -0
- package/core/element/EmbedElement.js.map +1 -0
- package/core/element/FieldSetElement.d.ts +8 -0
- package/core/element/FieldSetElement.js +33 -0
- package/core/element/FieldSetElement.js.map +1 -0
- package/core/element/FooterElement.d.ts +4 -0
- package/core/element/FooterElement.js +12 -0
- package/core/element/FooterElement.js.map +1 -0
- package/core/element/FormElement.d.ts +13 -0
- package/core/element/FormElement.js +9 -0
- package/core/element/FormElement.js.map +1 -0
- package/core/element/Fragment.d.ts +33 -0
- package/core/element/Fragment.js +146 -0
- package/core/element/Fragment.js.map +1 -0
- package/core/element/H1Element.d.ts +4 -0
- package/core/element/H1Element.js +9 -0
- package/core/element/H1Element.js.map +1 -0
- package/core/element/H2Element.d.ts +4 -0
- package/core/element/H2Element.js +9 -0
- package/core/element/H2Element.js.map +1 -0
- package/core/element/H3Element.d.ts +4 -0
- package/core/element/H3Element.js +9 -0
- package/core/element/H3Element.js.map +1 -0
- package/core/element/H4Element.d.ts +4 -0
- package/core/element/H4Element.js +9 -0
- package/core/element/H4Element.js.map +1 -0
- package/core/element/H5Element.d.ts +4 -0
- package/core/element/H5Element.js +9 -0
- package/core/element/H5Element.js.map +1 -0
- package/core/element/H6Element.d.ts +4 -0
- package/core/element/H6Element.js +9 -0
- package/core/element/H6Element.js.map +1 -0
- package/core/element/HeadElement.d.ts +4 -0
- package/core/element/HeadElement.js +10 -0
- package/core/element/HeadElement.js.map +1 -0
- package/core/element/HeaderElement.d.ts +4 -0
- package/core/element/HeaderElement.js +12 -0
- package/core/element/HeaderElement.js.map +1 -0
- package/core/element/HorizontalRuleElement.d.ts +4 -0
- package/core/element/HorizontalRuleElement.js +12 -0
- package/core/element/HorizontalRuleElement.js.map +1 -0
- package/core/element/HtmlElement.d.ts +8 -0
- package/core/element/HtmlElement.js +18 -0
- package/core/element/HtmlElement.js.map +1 -0
- package/core/element/IFrameElement.d.ts +27 -0
- package/core/element/IFrameElement.js +66 -0
- package/core/element/IFrameElement.js.map +1 -0
- package/core/element/ILayout.d.ts +4 -0
- package/core/element/ILayout.js +8 -0
- package/core/element/ILayout.js.map +1 -0
- package/core/element/IconElement.d.ts +13 -0
- package/core/element/IconElement.js +31 -0
- package/core/element/IconElement.js.map +1 -0
- package/core/element/ImageElement.d.ts +18 -0
- package/core/element/ImageElement.js +16 -0
- package/core/element/ImageElement.js.map +1 -0
- package/core/element/InputElement.d.ts +37 -0
- package/core/element/InputElement.js +81 -0
- package/core/element/InputElement.js.map +1 -0
- package/core/element/LabelElement.d.ts +7 -0
- package/core/element/LabelElement.js +9 -0
- package/core/element/LabelElement.js.map +1 -0
- package/core/element/LegendElement.d.ts +6 -0
- package/core/element/LegendElement.js +14 -0
- package/core/element/LegendElement.js.map +1 -0
- package/core/element/ListItemElement.d.ts +11 -0
- package/core/element/ListItemElement.js +27 -0
- package/core/element/ListItemElement.js.map +1 -0
- package/core/element/MainElement.d.ts +4 -0
- package/core/element/MainElement.js +9 -0
- package/core/element/MainElement.js.map +1 -0
- package/core/element/NavElement.d.ts +4 -0
- package/core/element/NavElement.js +9 -0
- package/core/element/NavElement.js.map +1 -0
- package/core/element/OrderedListElement.d.ts +4 -0
- package/core/element/OrderedListElement.js +9 -0
- package/core/element/OrderedListElement.js.map +1 -0
- package/core/element/ParagraphElement.d.ts +4 -0
- package/core/element/ParagraphElement.js +9 -0
- package/core/element/ParagraphElement.js.map +1 -0
- package/core/element/PreElement.d.ts +4 -0
- package/core/element/PreElement.js +9 -0
- package/core/element/PreElement.js.map +1 -0
- package/core/element/SectionElement.d.ts +4 -0
- package/core/element/SectionElement.js +11 -0
- package/core/element/SectionElement.js.map +1 -0
- package/core/element/SelectElement.d.ts +4 -0
- package/core/element/SelectElement.js +11 -0
- package/core/element/SelectElement.js.map +1 -0
- package/core/element/SourceElement.d.ts +7 -0
- package/core/element/SourceElement.js +13 -0
- package/core/element/SourceElement.js.map +1 -0
- package/core/element/SpanElement.d.ts +4 -0
- package/core/element/SpanElement.js +9 -0
- package/core/element/SpanElement.js.map +1 -0
- package/core/element/StrongElement.d.ts +4 -0
- package/core/element/StrongElement.js +11 -0
- package/core/element/StrongElement.js.map +1 -0
- package/core/element/StyleElement.d.ts +4 -0
- package/core/element/StyleElement.js +9 -0
- package/core/element/StyleElement.js.map +1 -0
- package/core/element/SummaryElement.d.ts +4 -0
- package/core/element/SummaryElement.js +11 -0
- package/core/element/SummaryElement.js.map +1 -0
- package/core/element/SvgElement.d.ts +17 -0
- package/core/element/SvgElement.js +149 -0
- package/core/element/SvgElement.js.map +1 -0
- package/core/element/TableBodyElement.d.ts +4 -0
- package/core/element/TableBodyElement.js +9 -0
- package/core/element/TableBodyElement.js.map +1 -0
- package/core/element/TableCellElement.d.ts +9 -0
- package/core/element/TableCellElement.js +24 -0
- package/core/element/TableCellElement.js.map +1 -0
- package/core/element/TableColElement.d.ts +6 -0
- package/core/element/TableColElement.js +12 -0
- package/core/element/TableColElement.js.map +1 -0
- package/core/element/TableColGroupElement.d.ts +6 -0
- package/core/element/TableColGroupElement.js +14 -0
- package/core/element/TableColGroupElement.js.map +1 -0
- package/core/element/TableElement.d.ts +44 -0
- package/core/element/TableElement.js +227 -0
- package/core/element/TableElement.js.map +1 -0
- package/core/element/TableFootElement.d.ts +4 -0
- package/core/element/TableFootElement.js +9 -0
- package/core/element/TableFootElement.js.map +1 -0
- package/core/element/TableFootRowElement.d.ts +8 -0
- package/core/element/TableFootRowElement.js +22 -0
- package/core/element/TableFootRowElement.js.map +1 -0
- package/core/element/TableHeadCellElement.d.ts +9 -0
- package/core/element/TableHeadCellElement.js +23 -0
- package/core/element/TableHeadCellElement.js.map +1 -0
- package/core/element/TableHeadElement.d.ts +4 -0
- package/core/element/TableHeadElement.js +9 -0
- package/core/element/TableHeadElement.js.map +1 -0
- package/core/element/TableHeadRowElement.d.ts +10 -0
- package/core/element/TableHeadRowElement.js +28 -0
- package/core/element/TableHeadRowElement.js.map +1 -0
- package/core/element/TableRowElement.d.ts +10 -0
- package/core/element/TableRowElement.js +28 -0
- package/core/element/TableRowElement.js.map +1 -0
- package/core/element/TextAreaElement.d.ts +6 -0
- package/core/element/TextAreaElement.js +9 -0
- package/core/element/TextAreaElement.js.map +1 -0
- package/core/element/UListElement.d.ts +4 -0
- package/core/element/UListElement.js +9 -0
- package/core/element/UListElement.js.map +1 -0
- package/core/element/VideoElement.d.ts +12 -0
- package/core/element/VideoElement.js +15 -0
- package/core/element/VideoElement.js.map +1 -0
- package/core/element/index.d.ts +71 -0
- package/core/element/index.js +72 -0
- package/core/element/index.js.map +1 -0
- package/core/event/index.d.ts +16 -0
- package/core/event/index.js +75 -0
- package/core/event/index.js.map +1 -0
- package/core/index.d.ts +9 -0
- package/core/index.js +10 -0
- package/core/index.js.map +1 -0
- package/core/ref/RefBoolean.d.ts +26 -0
- package/core/ref/RefBoolean.js +58 -0
- package/core/ref/RefBoolean.js.map +1 -0
- package/core/ref/RefContainer.d.ts +25 -0
- package/core/ref/RefContainer.js +105 -0
- package/core/ref/RefContainer.js.map +1 -0
- package/core/ref/RefList.d.ts +51 -0
- package/core/ref/RefList.js +155 -0
- package/core/ref/RefList.js.map +1 -0
- package/core/ref/RefMap.d.ts +25 -0
- package/core/ref/RefMap.js +71 -0
- package/core/ref/RefMap.js.map +1 -0
- package/core/ref/RefNumber.d.ts +30 -0
- package/core/ref/RefNumber.js +69 -0
- package/core/ref/RefNumber.js.map +1 -0
- package/core/ref/RefObject.d.ts +30 -0
- package/core/ref/RefObject.js +211 -0
- package/core/ref/RefObject.js.map +1 -0
- package/core/ref/RefProperty.d.ts +3 -0
- package/core/ref/RefProperty.js +46 -0
- package/core/ref/RefProperty.js.map +1 -0
- package/core/ref/RefSet.d.ts +25 -0
- package/core/ref/RefSet.js +72 -0
- package/core/ref/RefSet.js.map +1 -0
- package/core/ref/RefState.d.ts +23 -0
- package/core/ref/RefState.js +79 -0
- package/core/ref/RefState.js.map +1 -0
- package/core/ref/RefString.d.ts +75 -0
- package/core/ref/RefString.js +202 -0
- package/core/ref/RefString.js.map +1 -0
- package/core/ref/index.d.ts +21 -0
- package/core/ref/index.js +64 -0
- package/core/ref/index.js.map +1 -0
- package/core/router/RouteView.d.ts +19 -0
- package/core/router/RouteView.js +75 -0
- package/core/router/RouteView.js.map +1 -0
- package/core/router/Router.d.ts +70 -0
- package/core/router/Router.js +287 -0
- package/core/router/Router.js.map +1 -0
- package/core/router/RouterEvent.d.ts +36 -0
- package/core/router/RouterEvent.js +43 -0
- package/core/router/RouterEvent.js.map +1 -0
- package/core/router/RouterGuard.d.ts +12 -0
- package/core/router/RouterGuard.js +3 -0
- package/core/router/RouterGuard.js.map +1 -0
- package/core/router/index.d.ts +4 -0
- package/core/router/index.js +5 -0
- package/core/router/index.js.map +1 -0
- package/core/styles/index.d.ts +97 -0
- package/core/styles/index.js +36 -0
- package/core/styles/index.js.map +1 -0
- package/global/index.d.ts +79 -0
- package/global/index.js +931 -0
- package/global/index.js.map +1 -0
- package/global/safari-polyfill.d.ts +0 -0
- package/global/safari-polyfill.js +234 -0
- package/global/safari-polyfill.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { App } from "../../";
|
|
2
|
+
function getRoutePairs(routes, basePath = '', parentRouters = []) {
|
|
3
|
+
let result = [];
|
|
4
|
+
for (const route of routes) {
|
|
5
|
+
const fullPath = `${basePath}/${route.path}`.replace(/\/+/g, '/');
|
|
6
|
+
const routers = [...parentRouters];
|
|
7
|
+
if (route.component || route.redirect) {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
routers.push({ component: route.component, path: route.path, id: route.id, guard: route.guard, redirect: route.redirect, title: route.title });
|
|
10
|
+
}
|
|
11
|
+
result.push({ path: fullPath, routers });
|
|
12
|
+
if (route.children) {
|
|
13
|
+
result = result.concat(getRoutePairs(route.children, fullPath, routers));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
function matchRoute(url, routes) {
|
|
19
|
+
let bestMatch = null;
|
|
20
|
+
for (const route of routes) {
|
|
21
|
+
const routeRegex = new RegExp(`^${route.path
|
|
22
|
+
.replace(/\*\*/g, '.*')
|
|
23
|
+
.replace(/\*/g, '[^/]+')
|
|
24
|
+
.replace(/:[^\s/]+/g, '([^/]+)')}$`);
|
|
25
|
+
const match = url.match(routeRegex);
|
|
26
|
+
if (match || route.path === `/${Router.PATH_WILDCARD}`) {
|
|
27
|
+
const params = {};
|
|
28
|
+
const paramKeys = route.path.match(/:[^\s/]+/g);
|
|
29
|
+
if (paramKeys) {
|
|
30
|
+
paramKeys.forEach((key, index) => {
|
|
31
|
+
params[key.replace(':', '')] = match[index + 1];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (!bestMatch || route.path.length > bestMatch.path.length) {
|
|
35
|
+
bestMatch = {
|
|
36
|
+
path: route.path,
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
routers: route.routers.map((route) => {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
return { component: route.component, path: route.path, id: route.id, guard: route.guard, title: route.title, redirect: route.redirect, build: undefined };
|
|
41
|
+
}),
|
|
42
|
+
params,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (bestMatch)
|
|
48
|
+
bestMatch.url = url;
|
|
49
|
+
return bestMatch;
|
|
50
|
+
}
|
|
51
|
+
function pageNotFound() {
|
|
52
|
+
const body = document.createElement("div");
|
|
53
|
+
body.style.width = "100vw";
|
|
54
|
+
body.style.height = "100vh";
|
|
55
|
+
body.style.display = "flex";
|
|
56
|
+
body.style.flexDirection = "column";
|
|
57
|
+
body.style.justifyContent = "center";
|
|
58
|
+
body.style.alignItems = "center";
|
|
59
|
+
body.style.overflow = "hidden";
|
|
60
|
+
body.style.position = "fixed";
|
|
61
|
+
body.innerHTML =
|
|
62
|
+
"<div style='text-align: center;'>" +
|
|
63
|
+
"<h1 style='text-shadow: 0 3px 0px $color-base, 0 6px 0px #333; color: #f54f59; font-size: 6em; font-weight: 700; line-height: 0.6em;'>404</h1>" +
|
|
64
|
+
"<h1 style='text-shadow: 0 3px 0px $color-base, 0 6px 0px #333; color: #f54f59; font-size: 10; font-weight: 15; line-height: 0.6em;'>Page not found</h1>" +
|
|
65
|
+
"</div>";
|
|
66
|
+
return body;
|
|
67
|
+
}
|
|
68
|
+
export class Router {
|
|
69
|
+
static #router;
|
|
70
|
+
#history;
|
|
71
|
+
#props = {};
|
|
72
|
+
routes = [];
|
|
73
|
+
url = window.location.pathname;
|
|
74
|
+
urlValid = "";
|
|
75
|
+
pageNotFound;
|
|
76
|
+
match = null;
|
|
77
|
+
/**
|
|
78
|
+
* @param data - An array of route objects.
|
|
79
|
+
* @param history - The type of history to use. Can be either "hash" or "history".
|
|
80
|
+
*/
|
|
81
|
+
static SEGMENT_WILDCARD = "*";
|
|
82
|
+
/**
|
|
83
|
+
* @param data - An array of route objects.
|
|
84
|
+
* @param history - The type of history to use. Can be either "hash" or "history".
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
static PATH_WILDCARD = "**";
|
|
88
|
+
beforeEach = () => { };
|
|
89
|
+
constructor(data, history, pageNotFound) {
|
|
90
|
+
if (Router.#router)
|
|
91
|
+
throw new Error("Router already exists");
|
|
92
|
+
Router.#router = this;
|
|
93
|
+
this.#history = history;
|
|
94
|
+
if (this.#history === "hash") {
|
|
95
|
+
if (!window.location.pathname.startsWith("/#/")) {
|
|
96
|
+
if (window.location.pathname === "/") {
|
|
97
|
+
window.history.replaceState({}, "", "/#/");
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
window.history.replaceState({}, "", "/#" + window.location.pathname);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
this.pageNotFound = pageNotFound;
|
|
105
|
+
this.createAutoId(data, 0);
|
|
106
|
+
this.routes = getRoutePairs(data);
|
|
107
|
+
window.addEventListener(history == "history" ? "popstate" : "hashchange", () => this.handleRoute());
|
|
108
|
+
this.handleRoute();
|
|
109
|
+
}
|
|
110
|
+
createAutoId(routes = [], id) {
|
|
111
|
+
for (const route of routes) {
|
|
112
|
+
route["id"] = `${route.path}_${++id}`;
|
|
113
|
+
if (route.children) {
|
|
114
|
+
id = this.createAutoId(route.children, id);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return id;
|
|
118
|
+
}
|
|
119
|
+
getQueryParams(url) {
|
|
120
|
+
const queryParams = {};
|
|
121
|
+
const queryString = url.split('?')[1];
|
|
122
|
+
if (queryString) {
|
|
123
|
+
const pairs = queryString.split('&');
|
|
124
|
+
for (const pair of pairs) {
|
|
125
|
+
const [key, value] = pair.split('=');
|
|
126
|
+
queryParams[decodeURIComponent(key)] = decodeURIComponent(value || '');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return queryParams;
|
|
130
|
+
}
|
|
131
|
+
handleRoute() {
|
|
132
|
+
const url = this.#history === "hash" ? window.location.hash : window.location.pathname || "/";
|
|
133
|
+
this.url = url;
|
|
134
|
+
if (this.#history === "hash")
|
|
135
|
+
this.url = this.url.replace(/^#\//, "/");
|
|
136
|
+
this.#props = this.getQueryParams(this.url);
|
|
137
|
+
this.buildRoutePage(matchRoute(this.url.split('?')[0], this.routes));
|
|
138
|
+
}
|
|
139
|
+
async buildRoutePage(match) {
|
|
140
|
+
let title = "";
|
|
141
|
+
if (!match || !match.routers.length) {
|
|
142
|
+
App.setPage(this.pageNotFound ? new this.pageNotFound() : pageNotFound());
|
|
143
|
+
this.match = null;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
if (!await this.checkGuard(match))
|
|
147
|
+
return;
|
|
148
|
+
if (this.match) {
|
|
149
|
+
for (let i = 0; i < match.routers.length; i++) {
|
|
150
|
+
if (!this.match?.routers[i]?.id)
|
|
151
|
+
break;
|
|
152
|
+
const route = match.routers[i];
|
|
153
|
+
if (route.id == this.match?.routers[i]?.id) {
|
|
154
|
+
route.build = this.match.routers[i].build;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (let i = 0; i < match.routers.length; i++) {
|
|
159
|
+
const route = match.routers[i];
|
|
160
|
+
if (route.redirect) {
|
|
161
|
+
this.match = null;
|
|
162
|
+
Router.go(route.redirect);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (route.title)
|
|
166
|
+
title = route.title;
|
|
167
|
+
route.parent = i == 0 ? undefined : match.routers[i - 1];
|
|
168
|
+
}
|
|
169
|
+
const buildRoot = match.routers[0];
|
|
170
|
+
this.match = match;
|
|
171
|
+
if (!buildRoot.build) {
|
|
172
|
+
buildRoot.build = App.setPage(new buildRoot.component);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (title)
|
|
176
|
+
document.title = title;
|
|
177
|
+
this.beforeEach(match);
|
|
178
|
+
document.body.emitEvent("router:watch", { url: this.url, props: this.#props });
|
|
179
|
+
}
|
|
180
|
+
async checkGuard(match) {
|
|
181
|
+
const guards = match.routers.map((route) => route.guard).filter(Boolean);
|
|
182
|
+
let result = true;
|
|
183
|
+
for await (const guard of guards) {
|
|
184
|
+
const primose = new Promise((resolve) => {
|
|
185
|
+
const response = {
|
|
186
|
+
path: match.url,
|
|
187
|
+
params: match.params,
|
|
188
|
+
query: this.#props,
|
|
189
|
+
redirect: (path) => {
|
|
190
|
+
resolve(path);
|
|
191
|
+
},
|
|
192
|
+
resolve: () => {
|
|
193
|
+
resolve(true);
|
|
194
|
+
},
|
|
195
|
+
break: () => {
|
|
196
|
+
resolve(false);
|
|
197
|
+
},
|
|
198
|
+
reject: () => {
|
|
199
|
+
resolve(false);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
guard.beforeEach(response);
|
|
203
|
+
});
|
|
204
|
+
result = await primose;
|
|
205
|
+
if (typeof result === "string") {
|
|
206
|
+
Router.go(result);
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (result)
|
|
211
|
+
this.urlValid = match.url;
|
|
212
|
+
else
|
|
213
|
+
Router.go(Router.#router?.urlValid);
|
|
214
|
+
return result === true;
|
|
215
|
+
}
|
|
216
|
+
static create(data) {
|
|
217
|
+
Router.#router = new Router(data.routes, data.history || "history", data.pageNotFound);
|
|
218
|
+
}
|
|
219
|
+
static reload() {
|
|
220
|
+
if (Router.#router) {
|
|
221
|
+
Router.#router.match = null;
|
|
222
|
+
Router.#router.handleRoute();
|
|
223
|
+
}
|
|
224
|
+
else
|
|
225
|
+
window.location.reload();
|
|
226
|
+
}
|
|
227
|
+
static get props() {
|
|
228
|
+
if (window.location.hash) {
|
|
229
|
+
const hashParts = window.location.hash.split('?');
|
|
230
|
+
if (hashParts.length > 1) {
|
|
231
|
+
const hashParams = new URLSearchParams(hashParts[1]);
|
|
232
|
+
const props = {};
|
|
233
|
+
for (const [key, value] of hashParams) {
|
|
234
|
+
props[key] = value;
|
|
235
|
+
}
|
|
236
|
+
return props;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
241
|
+
const props = {};
|
|
242
|
+
for (const [key, value] of searchParams) {
|
|
243
|
+
props[key] = value;
|
|
244
|
+
}
|
|
245
|
+
return props;
|
|
246
|
+
}
|
|
247
|
+
return {};
|
|
248
|
+
}
|
|
249
|
+
static get history() {
|
|
250
|
+
return Router.#router.#history;
|
|
251
|
+
}
|
|
252
|
+
static buildURL(baseUrl, parametros) {
|
|
253
|
+
const queryString = Object.keys(parametros)
|
|
254
|
+
.map((key) => encodeURIComponent(key) + "=" + encodeURIComponent(parametros[key]))
|
|
255
|
+
.join("&");
|
|
256
|
+
return baseUrl + (queryString ? "?" + queryString : "");
|
|
257
|
+
}
|
|
258
|
+
static async go(url, props) {
|
|
259
|
+
if (!url)
|
|
260
|
+
return;
|
|
261
|
+
if (!url.startsWith("/"))
|
|
262
|
+
url = "/" + url;
|
|
263
|
+
const newUrl = Router.buildURL(url, props || {});
|
|
264
|
+
if (Router.#router.#history === "history")
|
|
265
|
+
history.pushState(props || {}, "", newUrl);
|
|
266
|
+
else
|
|
267
|
+
window.location.hash = newUrl;
|
|
268
|
+
Router.#router?.handleRoute();
|
|
269
|
+
}
|
|
270
|
+
static back() {
|
|
271
|
+
window.history.back();
|
|
272
|
+
}
|
|
273
|
+
static forward() {
|
|
274
|
+
window.history.forward();
|
|
275
|
+
}
|
|
276
|
+
static getRouteViewFree(routeView) {
|
|
277
|
+
if (!Router.#router || !Router.#router.match)
|
|
278
|
+
return undefined;
|
|
279
|
+
const { routers } = Router.#router.match;
|
|
280
|
+
const route = routers.find((route) => (!route.routeView || route.routeView === routeView) && route.parent);
|
|
281
|
+
if (!route)
|
|
282
|
+
return undefined;
|
|
283
|
+
route.routeView = routeView;
|
|
284
|
+
return route;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=Router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/core/router/Router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAyB,MAAM,QAAQ,CAAC;AA0BpD,SAAS,aAAa,CACpB,MAAmB,EACnB,QAAQ,GAAG,EAAE,EACb,gBAAyE,EAAE;IAE3E,IAAI,MAAM,GAAkB,EAAE,CAAC;IAE/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,GAAG,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAElE,MAAM,OAAO,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACtC,aAAa;YACb,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACjJ,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAEzC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,aA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AC;QACnC,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC;IAChC,CAAC;IAEM,MAAM,CAAC,IAAI;QAChB,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,OAAO;QACnB,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,SAAoB;QAClD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC/D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QACzC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3G,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC7B,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare class RouterEvent {
|
|
2
|
+
/**
|
|
3
|
+
* This event is triggered before leaving the current route. It is useful for
|
|
4
|
+
* carrying out specific checks or actions before allowing the user to leave
|
|
5
|
+
* the current page.
|
|
6
|
+
* @param to
|
|
7
|
+
* @param from
|
|
8
|
+
* @param next
|
|
9
|
+
*/
|
|
10
|
+
beforeRouteLeave(to: any, from: any, next: any): void;
|
|
11
|
+
/**
|
|
12
|
+
* This event is triggered before entering the new route. It is useful for carrying
|
|
13
|
+
* out data uploads or other necessary tasks before fully entering the new route
|
|
14
|
+
* @param to
|
|
15
|
+
* @param from
|
|
16
|
+
* @param next
|
|
17
|
+
*/
|
|
18
|
+
beforeRouteEnter(to: any, from: any, next: any): void;
|
|
19
|
+
/**
|
|
20
|
+
* This event is triggered when the route is about to be updated, but the current
|
|
21
|
+
* route still remains active. It is useful for carrying out specific actions when
|
|
22
|
+
* the route is changing but the component is still in use.
|
|
23
|
+
* @param to
|
|
24
|
+
* @param from
|
|
25
|
+
* @param next
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
beforeRouteUpdate(to: any, from: any, next: any): void;
|
|
29
|
+
/**
|
|
30
|
+
* This event is triggered after the route has been updated. It is useful for
|
|
31
|
+
* carrying out specific actions after the route has been updated.
|
|
32
|
+
* @param to
|
|
33
|
+
* @param from
|
|
34
|
+
*/
|
|
35
|
+
afterEach(to: any, from: any): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export class RouterEvent {
|
|
2
|
+
/**
|
|
3
|
+
* This event is triggered before leaving the current route. It is useful for
|
|
4
|
+
* carrying out specific checks or actions before allowing the user to leave
|
|
5
|
+
* the current page.
|
|
6
|
+
* @param to
|
|
7
|
+
* @param from
|
|
8
|
+
* @param next
|
|
9
|
+
*/
|
|
10
|
+
beforeRouteLeave(to, from, next) {
|
|
11
|
+
next();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* This event is triggered before entering the new route. It is useful for carrying
|
|
15
|
+
* out data uploads or other necessary tasks before fully entering the new route
|
|
16
|
+
* @param to
|
|
17
|
+
* @param from
|
|
18
|
+
* @param next
|
|
19
|
+
*/
|
|
20
|
+
beforeRouteEnter(to, from, next) {
|
|
21
|
+
next();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* This event is triggered when the route is about to be updated, but the current
|
|
25
|
+
* route still remains active. It is useful for carrying out specific actions when
|
|
26
|
+
* the route is changing but the component is still in use.
|
|
27
|
+
* @param to
|
|
28
|
+
* @param from
|
|
29
|
+
* @param next
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
beforeRouteUpdate(to, from, next) {
|
|
33
|
+
next();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* This event is triggered after the route has been updated. It is useful for
|
|
37
|
+
* carrying out specific actions after the route has been updated.
|
|
38
|
+
* @param to
|
|
39
|
+
* @param from
|
|
40
|
+
*/
|
|
41
|
+
afterEach(to, from) { }
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=RouterEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterEvent.js","sourceRoot":"","sources":["../../../src/core/router/RouterEvent.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAW;IACtB;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAO,EAAE,IAAS,EAAE,IAAS;QAC5C,IAAI,EAAE,CAAC;IACT,CAAC;IAED;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAO,EAAE,IAAS,EAAE,IAAS;QAC5C,IAAI,EAAE,CAAC;IACT,CAAC;IAED;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAO,EAAE,IAAS,EAAE,IAAS;QAC7C,IAAI,EAAE,CAAC;IACT,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,EAAO,EAAE,IAAS,IAAG,CAAC;CACjC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface GuardResponse {
|
|
2
|
+
redirect(path: string): void;
|
|
3
|
+
resolve(): void;
|
|
4
|
+
break(): void;
|
|
5
|
+
reject(): void;
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly params: Record<string, string>;
|
|
8
|
+
readonly query: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class RouterGuard {
|
|
11
|
+
abstract beforeEach(response: GuardResponse): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RouterGuard.js","sourceRoot":"","sources":["../../../src/core/router/RouterGuard.ts"],"names":[],"mappings":"AAWA,MAAM,OAAgB,WAAW;CAIhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAsB,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ref, refBoolean, refNumber, refString } from "../";
|
|
2
|
+
import type * as CSS from "csstype";
|
|
3
|
+
export type Variant = "default" | "outline" | "solo" | "standard" | "underlined";
|
|
4
|
+
export type StyleProperties = {
|
|
5
|
+
[K in keyof CSS.Properties]?: CSS.Properties[K] | ref<CSS.Properties[K]> | ref<string>;
|
|
6
|
+
} & {
|
|
7
|
+
[K in keyof CSS.PropertiesHyphen]?: CSS.PropertiesHyphen[K] | ref<CSS.PropertiesHyphen[K]> | ref<string>;
|
|
8
|
+
};
|
|
9
|
+
interface ComponentPropsMethods {
|
|
10
|
+
id?: refString;
|
|
11
|
+
title?: refString;
|
|
12
|
+
className?: refString;
|
|
13
|
+
text?: refString | refNumber | refBoolean;
|
|
14
|
+
html?: refString | refNumber | refBoolean;
|
|
15
|
+
readOnly?: refBoolean;
|
|
16
|
+
hidden?: refBoolean;
|
|
17
|
+
variant?: refString;
|
|
18
|
+
itemLoading?: boolean;
|
|
19
|
+
disabled?: refBoolean;
|
|
20
|
+
children?: (IComponent | null | undefined)[];
|
|
21
|
+
innerHTML?: refString | refNumber | refBoolean | IComponent;
|
|
22
|
+
innerText?: refString | refNumber | refBoolean | IComponent;
|
|
23
|
+
onclick?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
24
|
+
onchange?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
25
|
+
oninput?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
26
|
+
onfocus?: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
27
|
+
onblur?: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null;
|
|
28
|
+
onmouseover?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
29
|
+
onmouseout?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
30
|
+
onmouseenter?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
31
|
+
onmouseleave?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
32
|
+
onmousedown?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
33
|
+
onmouseup?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
34
|
+
onkeydown?: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
35
|
+
onkeyup?: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
36
|
+
onkeypress?: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null;
|
|
37
|
+
ondblclick?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
38
|
+
oncontextmenu?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
39
|
+
oncopy?: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
40
|
+
oncut?: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
41
|
+
onpaste?: ((this: GlobalEventHandlers, ev: ClipboardEvent) => any) | null;
|
|
42
|
+
onabort?: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
|
|
43
|
+
onauxclick?: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null;
|
|
44
|
+
onbeforeinput?: ((this: GlobalEventHandlers, ev: InputEvent) => any) | null;
|
|
45
|
+
oncanplay?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
46
|
+
oncanplaythrough?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
47
|
+
oncuechange?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
48
|
+
ondurationchange?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
49
|
+
onemptied?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
50
|
+
onended?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
51
|
+
onerror?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
52
|
+
onformdata?: ((this: GlobalEventHandlers, ev: FormDataEvent) => any) | null;
|
|
53
|
+
onload?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
54
|
+
onloadeddata?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
55
|
+
onloadedmetadata?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
56
|
+
onloadstart?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
57
|
+
onpause?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
58
|
+
onplay?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
59
|
+
onplaying?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
60
|
+
onprogress?: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null;
|
|
61
|
+
onratechange?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
62
|
+
onreset?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
63
|
+
onresize?: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null;
|
|
64
|
+
onscroll?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
65
|
+
onsecuritypolicyviolation?: ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | null;
|
|
66
|
+
onstalled?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
67
|
+
onsuspend?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
68
|
+
ontimeupdate?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
69
|
+
ontoggle?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
70
|
+
onvolumechange?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
71
|
+
onwaiting?: ((this: GlobalEventHandlers, ev: Event) => any) | null;
|
|
72
|
+
onwheel?: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null;
|
|
73
|
+
ondrag?: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
74
|
+
ondragend?: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
75
|
+
ondragenter?: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
76
|
+
ondragleave?: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
77
|
+
ondragover?: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
78
|
+
ondragstart?: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
79
|
+
ondrop?: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null;
|
|
80
|
+
}
|
|
81
|
+
export type ComponentProps = StyleProperties & ComponentPropsMethods;
|
|
82
|
+
interface StylePropertiesMethods {
|
|
83
|
+
/** [MDN reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/getPropertyPriority) */
|
|
84
|
+
getPropertyPriority(property: string): refString;
|
|
85
|
+
/** [MDN reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/getPropertyValue) */
|
|
86
|
+
getPropertyValue(property: string): refString;
|
|
87
|
+
/** [MDN reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/item) */
|
|
88
|
+
item(index: number): refString;
|
|
89
|
+
/** [MDN reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/removeProperty) */
|
|
90
|
+
removeProperty(property: string): refString;
|
|
91
|
+
/** [MDN reference](https://developer.mozilla.org/docs/Web/API/CSSStyleDeclaration/setProperty) */
|
|
92
|
+
setProperty(property: string, value: refString | null, priority?: string): void;
|
|
93
|
+
[index: number]: refString;
|
|
94
|
+
hasOwnProperty(key: string): boolean;
|
|
95
|
+
}
|
|
96
|
+
export type CSSStyleDeclarationRef = StyleProperties & StylePropertiesMethods;
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Component, ref } from "../";
|
|
2
|
+
const removePropertyOriginal = CSSStyleDeclaration.prototype.removeProperty;
|
|
3
|
+
Object.defineProperty(CSSStyleDeclaration.prototype, "removeProperty", {
|
|
4
|
+
value: function (property) {
|
|
5
|
+
removePropertyOriginal.call(this, property);
|
|
6
|
+
},
|
|
7
|
+
writable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
});
|
|
10
|
+
const setPropertyOriginal = CSSStyleDeclaration.prototype.setProperty;
|
|
11
|
+
Object.defineProperty(CSSStyleDeclaration.prototype, "setProperty", {
|
|
12
|
+
value: function (property, value, priority) {
|
|
13
|
+
if (value instanceof ref)
|
|
14
|
+
value.subscribe(this, property);
|
|
15
|
+
else
|
|
16
|
+
setPropertyOriginal.call(this, property, value, priority);
|
|
17
|
+
},
|
|
18
|
+
writable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(CSSStyleDeclaration.prototype, "hasOwnProperty", {
|
|
22
|
+
value: function (key) {
|
|
23
|
+
return Object.prototype.hasOwnProperty.call(this, key);
|
|
24
|
+
},
|
|
25
|
+
writable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
});
|
|
28
|
+
const originalCreateElement = Document.prototype.createElement;
|
|
29
|
+
Object.defineProperty(Document.prototype, "createElement", {
|
|
30
|
+
value: function (tagName) {
|
|
31
|
+
const element = originalCreateElement.call(this, tagName);
|
|
32
|
+
Component.applyProps(element, {});
|
|
33
|
+
return element;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/styles/index.ts"],"names":[],"mappings":"AAAA,OAAO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AAE,UAAU,OAAe;QAC9B,MAAM,OAAO,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAgB,CAAC;QACzE,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ComponentProps, ref, StyleProperties } from "../";
|
|
2
|
+
export declare class Component extends HTMLElement implements IComponent {
|
|
3
|
+
constructor(props?: ComponentProps);
|
|
4
|
+
static applyProps<T extends HTMLElement>(element: T, props?: ComponentProps): Promise<void>;
|
|
5
|
+
static createElement(html: string): HTMLElement;
|
|
6
|
+
}
|
|
7
|
+
export interface HTMLComponent {
|
|
8
|
+
style?: StyleProperties;
|
|
9
|
+
ref?: HTMLElement;
|
|
10
|
+
children?: HTMLElement[];
|
|
11
|
+
className?: string | ref<string>;
|
|
12
|
+
onabort?: (event: UIEvent) => void;
|
|
13
|
+
onauxclick?: (event: MouseEvent) => void;
|
|
14
|
+
onbeforeinput?: (event: InputEvent) => void;
|
|
15
|
+
onblur?: (event: FocusEvent) => void;
|
|
16
|
+
oncanplay?: (event: Event) => void;
|
|
17
|
+
oncanplaythrough?: (event: Event) => void;
|
|
18
|
+
onchange?: (event: Event) => void;
|
|
19
|
+
onclick?: (event: MouseEvent) => void;
|
|
20
|
+
onclose?: (event: Event) => void;
|
|
21
|
+
oncontextmenu?: (event: MouseEvent) => void;
|
|
22
|
+
oncopy?: (event: ClipboardEvent) => void;
|
|
23
|
+
oncuechange?: (event: Event) => void;
|
|
24
|
+
oncut?: (event: ClipboardEvent) => void;
|
|
25
|
+
ondblclick?: (event: MouseEvent) => void;
|
|
26
|
+
ondrag?: (event: DragEvent) => void;
|
|
27
|
+
ondragend?: (event: DragEvent) => void;
|
|
28
|
+
ondragenter?: (event: DragEvent) => void;
|
|
29
|
+
ondragleave?: (event: DragEvent) => void;
|
|
30
|
+
ondragover?: (event: DragEvent) => void;
|
|
31
|
+
ondragstart?: (event: DragEvent) => void;
|
|
32
|
+
ondrop?: (event: DragEvent) => void;
|
|
33
|
+
ondurationchange?: (event: Event) => void;
|
|
34
|
+
onemptied?: (event: Event) => void;
|
|
35
|
+
onended?: (event: Event) => void;
|
|
36
|
+
onerror?: (event: Event) => void;
|
|
37
|
+
onfocus?: (event: FocusEvent) => void;
|
|
38
|
+
onformdata?: (event: FormDataEvent) => void;
|
|
39
|
+
oninput?: (event: InputEvent) => void;
|
|
40
|
+
oninvalid?: (event: Event) => void;
|
|
41
|
+
onkeydown?: (event: KeyboardEvent) => void;
|
|
42
|
+
onkeypress?: (event: KeyboardEvent) => void;
|
|
43
|
+
onkeyup?: (event: KeyboardEvent) => void;
|
|
44
|
+
onload?: (event: Event) => void;
|
|
45
|
+
onloadeddata?: (event: Event) => void;
|
|
46
|
+
onloadedmetadata?: (event: Event) => void;
|
|
47
|
+
onloadstart?: (event: Event) => void;
|
|
48
|
+
onmousedown?: (event: MouseEvent) => void;
|
|
49
|
+
onmouseenter?: (event: MouseEvent) => void;
|
|
50
|
+
onmouseleave?: (event: MouseEvent) => void;
|
|
51
|
+
onmousemove?: (event: MouseEvent) => void;
|
|
52
|
+
onmouseout?: (event: MouseEvent) => void;
|
|
53
|
+
onmouseover?: (event: MouseEvent) => void;
|
|
54
|
+
onmouseup?: (event: MouseEvent) => void;
|
|
55
|
+
onpaste?: (event: ClipboardEvent) => void;
|
|
56
|
+
onpause?: (event: Event) => void;
|
|
57
|
+
onplay?: (event: Event) => void;
|
|
58
|
+
onplaying?: (event: Event) => void;
|
|
59
|
+
onprogress?: (event: ProgressEvent) => void;
|
|
60
|
+
onratechange?: (event: Event) => void;
|
|
61
|
+
onreset?: (event: Event) => void;
|
|
62
|
+
onresize?: (event: UIEvent) => void;
|
|
63
|
+
onscroll?: (event: Event) => void;
|
|
64
|
+
onsecuritypolicyviolation?: (event: SecurityPolicyViolationEvent) => void;
|
|
65
|
+
onseeked?: (event: Event) => void;
|
|
66
|
+
onseeking?: (event: Event) => void;
|
|
67
|
+
onselect?: (event: Event) => void;
|
|
68
|
+
onslotchange?: (event: Event) => void;
|
|
69
|
+
onstalled?: (event: Event) => void;
|
|
70
|
+
onsubmit?: (event: SubmitEvent) => void;
|
|
71
|
+
onsuspend?: (event: Event) => void;
|
|
72
|
+
ontimeupdate?: (event: Event) => void;
|
|
73
|
+
ontoggle?: (event: Event) => void;
|
|
74
|
+
onvolumechange?: (event: Event) => void;
|
|
75
|
+
onwaiting?: (event: Event) => void;
|
|
76
|
+
onwheel?: (event: WheelEvent) => void;
|
|
77
|
+
[key: string]: any;
|
|
78
|
+
}
|
|
79
|
+
export {};
|