typecomposer 0.1.26 → 0.1.28
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/assets/index.d.ts +12 -0
- package/assets/index.js +13 -0
- package/assets/index.js.map +1 -0
- 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 +34 -0
- package/core/components/TextField.js +148 -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 +923 -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 +2 -18
- package/typings/index.d.ts +4 -3
- package/README.md +0 -62
- package/public/Ic_my_location_48px.svg.png +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Ref } from ".";
|
|
2
|
+
const refSubscriber = Symbol("refSubscriber");
|
|
3
|
+
export class RefContainer {
|
|
4
|
+
value;
|
|
5
|
+
root;
|
|
6
|
+
#subscribers = [];
|
|
7
|
+
constructor(value, root) {
|
|
8
|
+
this.value = value;
|
|
9
|
+
this.root = root;
|
|
10
|
+
}
|
|
11
|
+
emit(subscriber, value) {
|
|
12
|
+
if (subscriber.target instanceof Function) {
|
|
13
|
+
subscriber.target(value);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const target = subscriber.target.deref();
|
|
17
|
+
if (target === undefined) {
|
|
18
|
+
this.#subscribers = this.#subscribers.filter((s) => s !== subscriber);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (typeof target[subscriber.propertyName] === "function")
|
|
22
|
+
target[subscriber.propertyName](value);
|
|
23
|
+
else if (target[subscriber.propertyName] !== value) {
|
|
24
|
+
target[subscriber.propertyName] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
emitAll(propertyName, value) {
|
|
31
|
+
this.#subscribers.forEach((s) => this.emit(s, value));
|
|
32
|
+
if (this.root && this.root.emitAll)
|
|
33
|
+
this.root.emitAll("value", this.root["instance"] ? this.root["instance"]["value"] : this.root.value);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
getSubscriber(target, propertyName) {
|
|
37
|
+
const resutl = { subscriber: undefined, index: -1 };
|
|
38
|
+
if (typeof target === "function") {
|
|
39
|
+
const index = this.#subscribers.findIndex((s) => s.target === target);
|
|
40
|
+
resutl.index = index;
|
|
41
|
+
if (index !== -1)
|
|
42
|
+
resutl.subscriber = this.#subscribers[index];
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
const index = this.#subscribers.findIndex((s) => typeof s.target !== "function" && s.target.deref() === target && s.propertyName === propertyName);
|
|
47
|
+
resutl.index = index;
|
|
48
|
+
if (index !== -1)
|
|
49
|
+
resutl.subscriber = this.#subscribers[index];
|
|
50
|
+
}
|
|
51
|
+
return resutl;
|
|
52
|
+
}
|
|
53
|
+
subscribe(target, propertyName, onUnsubscribe) {
|
|
54
|
+
const resutl = this.getSubscriber(target, propertyName);
|
|
55
|
+
if (propertyName instanceof Function)
|
|
56
|
+
onUnsubscribe = propertyName;
|
|
57
|
+
if (resutl.subscriber)
|
|
58
|
+
return resutl.subscriber;
|
|
59
|
+
const subscriber = {
|
|
60
|
+
target: target instanceof Function ? target : new WeakRef(target),
|
|
61
|
+
propertyName: typeof propertyName === "string" ? propertyName : "",
|
|
62
|
+
onUnsubscribe,
|
|
63
|
+
refSubscriber
|
|
64
|
+
};
|
|
65
|
+
this.#subscribers.push(subscriber);
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
if (typeof target !== "function")
|
|
68
|
+
Ref.subscribe(target, typeof propertyName === "string" ? propertyName : "", this);
|
|
69
|
+
return subscriber;
|
|
70
|
+
}
|
|
71
|
+
unsubscribe(target, propertyName) {
|
|
72
|
+
const resutl = this.getSubscriber(target, propertyName);
|
|
73
|
+
if (resutl.subscriber === undefined)
|
|
74
|
+
return false;
|
|
75
|
+
resutl.subscriber.onUnsubscribe?.();
|
|
76
|
+
this.#subscribers = this.#subscribers.filter((_, i) => i !== resutl.index);
|
|
77
|
+
if (typeof target !== "function")
|
|
78
|
+
Ref.unsubscribe(target, propertyName);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
[Symbol.toPrimitive](hint) {
|
|
82
|
+
if (hint === "string" || hint === "default") {
|
|
83
|
+
return this.value;
|
|
84
|
+
}
|
|
85
|
+
return this.value.valueOf();
|
|
86
|
+
}
|
|
87
|
+
toString() {
|
|
88
|
+
if (typeof this.value === "object") {
|
|
89
|
+
return this.value.toString();
|
|
90
|
+
}
|
|
91
|
+
else if (this.value instanceof Object) {
|
|
92
|
+
return "[object Object]";
|
|
93
|
+
}
|
|
94
|
+
return this.value.toString();
|
|
95
|
+
}
|
|
96
|
+
toJSON() {
|
|
97
|
+
try {
|
|
98
|
+
return JSON.parse(JSON.stringify(this.value));
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=RefContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefContainer.js","sourceRoot":"","sources":["../../../src/core/ref/RefContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;AAExB,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAS9C,MAAM,OAAO,YAAY;IAId;IACS;IAJlB,YAAY,GAAqB,EAAE,CAAC;IAEpC,YACS,KAAW,EACF,IAAmB;QAD5B,UAAK,GAAL,KAAK,CAAM;QACF,SAAI,GAAJ,IAAI,CAAe;IACjC,CAAC;IAEL,IAAI,CAAC,UAA0B,EAAE,KAAU;QACzC,IAAI,UAAU,CAAC,MAAM,YAAY,QAAQ,EAAE,CAAC;YAC1C,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;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K,CAAC,QAAQ,EAAE,CAAC;QAC/B,CAAC;aAAM,IAAI,IAAI,CAAC,KAAK,YAAY,MAAM,EAAE,CAAC;YACxC,OAAO,iBAAiB,CAAC;QAC3B,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ref } from ".";
|
|
2
|
+
import { RefContainer } from "./RefContainer";
|
|
3
|
+
export declare function refList<T>(items: T[]): RefList<T>;
|
|
4
|
+
export type refList<T> = T[] | RefList<T>;
|
|
5
|
+
export declare class RefList<T = any> extends Array<T> implements ref<T[]> {
|
|
6
|
+
readonly container: RefContainer;
|
|
7
|
+
readonly refKey: string;
|
|
8
|
+
constructor(items: T[], refKey?: string);
|
|
9
|
+
private emit;
|
|
10
|
+
subscribe(target: (arg: T) => void): boolean;
|
|
11
|
+
subscribe(target: (arg: T) => void, onUnsubscribe: Function): boolean;
|
|
12
|
+
subscribe(target: object, propertyName: string | symbol): boolean;
|
|
13
|
+
subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
|
|
14
|
+
subscribe(target: object | ((arg: T) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
|
|
15
|
+
unsubscribe(target: (arg: T) => void): boolean;
|
|
16
|
+
unsubscribe(target: object, propertyName: string | symbol): boolean;
|
|
17
|
+
push(...items: T[]): number;
|
|
18
|
+
pop(): T | undefined;
|
|
19
|
+
shift(): T | undefined;
|
|
20
|
+
unshift(...items: T[]): number;
|
|
21
|
+
splice(start: number, deleteCount?: number): T[];
|
|
22
|
+
splice(start: number, deleteCount: number, ...items: T[]): T[];
|
|
23
|
+
sort(compareFn?: (a: T, b: T) => number): this;
|
|
24
|
+
reverse(): T[];
|
|
25
|
+
fill(value: T, start?: number, end?: number): this;
|
|
26
|
+
copyWithin(target: number, start: number, end?: number): this;
|
|
27
|
+
set length(value: number);
|
|
28
|
+
clear(): void;
|
|
29
|
+
insert(index: number, ...items: T[]): number;
|
|
30
|
+
remove(index: number, count?: number): number;
|
|
31
|
+
valueOf(): T[];
|
|
32
|
+
get length(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Synchronizes the children of an HTML element (`element`) with the provided list of `HTMLElement`s (`list`).
|
|
35
|
+
* Ensures that the `element` contains the same elements as in the `list`, in the same order.
|
|
36
|
+
*
|
|
37
|
+
* Behavior:
|
|
38
|
+
* 1. Removes children from `element` that are not in `list`.
|
|
39
|
+
* 2. Appends elements from `list` to `element` that are not already present.
|
|
40
|
+
* 3. Reorders children of `element` to match the order in `list`.
|
|
41
|
+
*
|
|
42
|
+
* @param list - An array of `HTMLElement`s that should be reflected as the children of `element`.
|
|
43
|
+
* @param element - The parent `HTMLElement` whose children will be synchronized with `list`.
|
|
44
|
+
*/
|
|
45
|
+
static syncComponentWithList(list: Element[], element: HTMLElement): void;
|
|
46
|
+
get [Symbol.toStringTag](): string;
|
|
47
|
+
static get [Symbol.species](): ArrayConstructor;
|
|
48
|
+
get value(): T[];
|
|
49
|
+
set value(value: T[]);
|
|
50
|
+
toJSON(): T[];
|
|
51
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Ref } from ".";
|
|
2
|
+
import { RefContainer } from "./RefContainer";
|
|
3
|
+
export function refList(items) {
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
return new RefList(items);
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(refList, Symbol.hasInstance, {
|
|
8
|
+
value: function (instance) {
|
|
9
|
+
return !!instance && instance instanceof RefList;
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
export class RefList extends Array {
|
|
13
|
+
container;
|
|
14
|
+
refKey;
|
|
15
|
+
constructor(items, refKey) {
|
|
16
|
+
super(...items);
|
|
17
|
+
this.refKey = refKey;
|
|
18
|
+
refKey && Ref.set(refKey, this);
|
|
19
|
+
this.container = new RefContainer(this);
|
|
20
|
+
}
|
|
21
|
+
emit(propertyName, value) {
|
|
22
|
+
this.container.emitAll(propertyName, value);
|
|
23
|
+
}
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
subscribe(target, propertyName, onUnsubscribe) {
|
|
26
|
+
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this);
|
|
27
|
+
}
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
unsubscribe(targe, propertyName = "") {
|
|
30
|
+
return this.container.unsubscribe(targe, propertyName);
|
|
31
|
+
}
|
|
32
|
+
push(...items) {
|
|
33
|
+
const n = super.push(...items);
|
|
34
|
+
this.container.emitAll("push", this);
|
|
35
|
+
return n;
|
|
36
|
+
}
|
|
37
|
+
pop() {
|
|
38
|
+
const item = super.pop();
|
|
39
|
+
this.container.emitAll("pop", this);
|
|
40
|
+
return item;
|
|
41
|
+
}
|
|
42
|
+
shift() {
|
|
43
|
+
const item = super.shift();
|
|
44
|
+
this.container.emitAll("shift", this);
|
|
45
|
+
return item;
|
|
46
|
+
}
|
|
47
|
+
unshift(...items) {
|
|
48
|
+
const n = super.unshift(...items);
|
|
49
|
+
this.container.emitAll("unshift", this);
|
|
50
|
+
return n;
|
|
51
|
+
}
|
|
52
|
+
splice(start, deleteCount = 0, ...items) {
|
|
53
|
+
const deleted = super.splice(start, deleteCount, ...items);
|
|
54
|
+
this.container.emitAll("splice", this);
|
|
55
|
+
return deleted;
|
|
56
|
+
}
|
|
57
|
+
sort(compareFn) {
|
|
58
|
+
super.sort(compareFn);
|
|
59
|
+
this.container.emitAll("sort", this);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
reverse() {
|
|
63
|
+
const reversed = super.reverse();
|
|
64
|
+
this.container.emitAll("reverse", this);
|
|
65
|
+
return reversed;
|
|
66
|
+
}
|
|
67
|
+
fill(value, start, end) {
|
|
68
|
+
super.fill(value, start, end);
|
|
69
|
+
this.container.emitAll("fill", this);
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
copyWithin(target, start, end) {
|
|
73
|
+
super.copyWithin(target, start, end);
|
|
74
|
+
this.container.emitAll("copyWithin", this);
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
set length(value) {
|
|
78
|
+
super.length = value;
|
|
79
|
+
this.container.emitAll("length", this);
|
|
80
|
+
}
|
|
81
|
+
clear() {
|
|
82
|
+
super.length = 0;
|
|
83
|
+
this.container.emitAll("clear", this);
|
|
84
|
+
}
|
|
85
|
+
insert(index, ...items) {
|
|
86
|
+
super.splice(index, 0, ...items);
|
|
87
|
+
this.container.emitAll("insert", this);
|
|
88
|
+
return this.length;
|
|
89
|
+
}
|
|
90
|
+
remove(index, count = 1) {
|
|
91
|
+
super.splice(index, count);
|
|
92
|
+
this.container.emitAll("remove", this);
|
|
93
|
+
return this.length;
|
|
94
|
+
}
|
|
95
|
+
valueOf() {
|
|
96
|
+
return Array.from(this);
|
|
97
|
+
}
|
|
98
|
+
get length() {
|
|
99
|
+
return super.length;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Synchronizes the children of an HTML element (`element`) with the provided list of `HTMLElement`s (`list`).
|
|
103
|
+
* Ensures that the `element` contains the same elements as in the `list`, in the same order.
|
|
104
|
+
*
|
|
105
|
+
* Behavior:
|
|
106
|
+
* 1. Removes children from `element` that are not in `list`.
|
|
107
|
+
* 2. Appends elements from `list` to `element` that are not already present.
|
|
108
|
+
* 3. Reorders children of `element` to match the order in `list`.
|
|
109
|
+
*
|
|
110
|
+
* @param list - An array of `HTMLElement`s that should be reflected as the children of `element`.
|
|
111
|
+
* @param element - The parent `HTMLElement` whose children will be synchronized with `list`.
|
|
112
|
+
*/
|
|
113
|
+
static syncComponentWithList(list, element) {
|
|
114
|
+
const currentChildren = Array.from(element.children);
|
|
115
|
+
currentChildren.forEach((child) => {
|
|
116
|
+
if (!list.includes(child)) {
|
|
117
|
+
element.removeChild(child);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
list.forEach((el) => {
|
|
121
|
+
// @ts-ignore
|
|
122
|
+
if (el instanceof Node && !currentChildren.includes(el)) {
|
|
123
|
+
element.appendChild(el);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
list.forEach((el, index) => {
|
|
127
|
+
if (el instanceof Node && element.children[index] !== el) {
|
|
128
|
+
element.insertBefore(el, element.children[index] || null);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
get [Symbol.toStringTag]() {
|
|
133
|
+
return "refList";
|
|
134
|
+
}
|
|
135
|
+
static get [Symbol.species]() {
|
|
136
|
+
return Array;
|
|
137
|
+
}
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
get value() {
|
|
140
|
+
return this.container.value.valueOf();
|
|
141
|
+
}
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
set value(value) {
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
if (this === value)
|
|
146
|
+
return;
|
|
147
|
+
super.splice(0, this.length, ...value);
|
|
148
|
+
this.emit("value", value);
|
|
149
|
+
}
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
toJSON() {
|
|
152
|
+
return this.value;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=RefList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefList.js","sourceRoot":"","sources":["../../../src/core/ref/RefList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,OAAO,CAAI,KAAU;IACnC,aAAa;IACb,OAAO,IAAI,OAAO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,KAAK,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IACD,aAAa;IACb,IAAI,KAAK,CAAC,KAAU;QAClB,aAAa;QACb,IAAI,IAAI,KAAK,KAAK;YAAE,OAAO;QAC3B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,aAAa;IACb,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ref } from ".";
|
|
2
|
+
import { RefContainer } from "./RefContainer";
|
|
3
|
+
export declare function refMap<K, V>(entries?: readonly (readonly [K, V])[] | null): RefMap<K, V>;
|
|
4
|
+
export type refMap<K, V> = Map<K, V> | RefMap<K, V>;
|
|
5
|
+
export declare class RefMap<K, V> extends Map<K, V> implements ref<Map<K, V>> {
|
|
6
|
+
readonly container: RefContainer;
|
|
7
|
+
readonly refKey: string;
|
|
8
|
+
constructor(entries?: readonly (readonly [K, V])[] | null, refKey?: string);
|
|
9
|
+
private emit;
|
|
10
|
+
subscribe(target: (arg: Map<K, V>) => void): boolean;
|
|
11
|
+
subscribe(target: (arg: Map<K, V>) => void, onUnsubscribe: Function): boolean;
|
|
12
|
+
subscribe(target: object, propertyName: string | symbol): boolean;
|
|
13
|
+
subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
|
|
14
|
+
subscribe(target: object | ((arg: Map<K, V>) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
|
|
15
|
+
unsubscribe(target: (arg: Map<K, V>) => void): boolean;
|
|
16
|
+
unsubscribe(targe: object, propertyName: string | symbol): boolean;
|
|
17
|
+
set(key: K, value: V): this;
|
|
18
|
+
delete(key: K): boolean;
|
|
19
|
+
clear(): void;
|
|
20
|
+
valueOf(): Map<K, V>;
|
|
21
|
+
static get [Symbol.species](): MapConstructor;
|
|
22
|
+
get value(): Map<K, V>;
|
|
23
|
+
set value(value: Map<K, V>);
|
|
24
|
+
toJSON(): any;
|
|
25
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Ref } from ".";
|
|
2
|
+
import { RefContainer } from "./RefContainer";
|
|
3
|
+
export function refMap(entries) {
|
|
4
|
+
return new RefMap(entries);
|
|
5
|
+
}
|
|
6
|
+
Object.defineProperty(refMap, Symbol.hasInstance, {
|
|
7
|
+
value: function (instance) {
|
|
8
|
+
return !!instance && instance instanceof RefMap;
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
export class RefMap extends Map {
|
|
13
|
+
container = new RefContainer(this);
|
|
14
|
+
refKey;
|
|
15
|
+
constructor(entries, refKey) {
|
|
16
|
+
super();
|
|
17
|
+
this.refKey = refKey;
|
|
18
|
+
refKey && Ref.set(refKey, this);
|
|
19
|
+
this.value = new Map(entries);
|
|
20
|
+
}
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
emit(propertyName, value) {
|
|
23
|
+
this.container.emitAll(propertyName, value);
|
|
24
|
+
}
|
|
25
|
+
subscribe(target, propertyName, onUnsubscribe) {
|
|
26
|
+
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this);
|
|
27
|
+
}
|
|
28
|
+
unsubscribe(targe, propertyName = "") {
|
|
29
|
+
return this.container.unsubscribe(targe, propertyName);
|
|
30
|
+
}
|
|
31
|
+
set(key, value) {
|
|
32
|
+
const result = super.set(key, value);
|
|
33
|
+
this.container.emitAll("set", this);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
delete(key) {
|
|
37
|
+
const result = super.delete(key);
|
|
38
|
+
this.container.emitAll("delete", this);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
clear() {
|
|
42
|
+
super.clear();
|
|
43
|
+
this.container.emitAll("clear", this);
|
|
44
|
+
}
|
|
45
|
+
valueOf() {
|
|
46
|
+
return new Map(Array.from(this));
|
|
47
|
+
}
|
|
48
|
+
static get [Symbol.species]() {
|
|
49
|
+
return Map;
|
|
50
|
+
}
|
|
51
|
+
get value() {
|
|
52
|
+
return this.container.value.valueOf();
|
|
53
|
+
}
|
|
54
|
+
set value(value) {
|
|
55
|
+
if (this === value)
|
|
56
|
+
return;
|
|
57
|
+
super.clear();
|
|
58
|
+
for (const [key, val] of value) {
|
|
59
|
+
super.set(key, val);
|
|
60
|
+
}
|
|
61
|
+
this.emit("value", value);
|
|
62
|
+
}
|
|
63
|
+
toJSON() {
|
|
64
|
+
const obj = {};
|
|
65
|
+
for (const [k, v] of this.value) {
|
|
66
|
+
obj[k] = v;
|
|
67
|
+
}
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=RefMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefMap.js","sourceRoot":"","sources":["../../../src/core/ref/RefMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,MAAM,CAAO,OAA6C;IACxE,OAAO,IAAI,MAAM,CAAO,OAAO,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE;IAChD,KAAK,EAAE,UAAU,QAAa;QAC5B,OAAO,CAAC,CAAC,QAAQ,IAAI,QAAQ,YAAY,MAAM,CAAC;IAClD,CAAC;CACF,CAAC,CAAC;AAGH,aAAa;AACb,MAAM,OAAO,MAAa,SAAQ,GAAS;IAChC,SAAS,GAAiB,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAS;IAExB,YAAY,OAA6C,EAAE,MAAe;QACxE,KAAK,EAAE,CAAC;QACR,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AI,GAAG,CAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;QACzB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,KAAK,CAAC,KAAgB;QACxB,IAAI,IAAI,KAAK,KAAK;YAAE,OAAO;QAC3B,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC;YAC/B,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAChC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACb,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ref } from ".";
|
|
2
|
+
import { RefContainer } from "./RefContainer";
|
|
3
|
+
export declare function refNumber(value: number): RefNumber;
|
|
4
|
+
export type refNumber = number | RefNumber;
|
|
5
|
+
export declare class RefNumber implements Number, ref<number> {
|
|
6
|
+
readonly container: RefContainer;
|
|
7
|
+
readonly refKey: string;
|
|
8
|
+
constructor(value: number, refKey?: string);
|
|
9
|
+
toFixed(fractionDigits?: number): string;
|
|
10
|
+
toExponential(fractionDigits?: number): string;
|
|
11
|
+
toPrecision(precision?: number): string;
|
|
12
|
+
valueOf(): number;
|
|
13
|
+
toLocaleString(locales?: string, options?: Intl.NumberFormatOptions): string;
|
|
14
|
+
private emit;
|
|
15
|
+
subscribe(target: (arg: number) => void): boolean;
|
|
16
|
+
subscribe(target: (arg: number) => void, onUnsubscribe: Function): boolean;
|
|
17
|
+
subscribe(target: object, propertyName: string | symbol): boolean;
|
|
18
|
+
subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
|
|
19
|
+
subscribe(target: object | ((arg: number) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
|
|
20
|
+
unsubscribe(target: (arg: number) => void): boolean;
|
|
21
|
+
unsubscribe(targe: object, propertyName: string | symbol): boolean;
|
|
22
|
+
[Symbol.toPrimitive](hint: string): number;
|
|
23
|
+
static get [Symbol.species](): NumberConstructor;
|
|
24
|
+
get value(): number;
|
|
25
|
+
set value(value: number);
|
|
26
|
+
toJSON(): number | {
|
|
27
|
+
value: number;
|
|
28
|
+
};
|
|
29
|
+
toString(radix?: number): string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Ref } from ".";
|
|
2
|
+
import { RefContainer } from "./RefContainer";
|
|
3
|
+
export function refNumber(value) {
|
|
4
|
+
return new RefNumber(value);
|
|
5
|
+
}
|
|
6
|
+
Object.defineProperty(refNumber, Symbol.hasInstance, {
|
|
7
|
+
value: function (instance) {
|
|
8
|
+
return !!instance && instance instanceof RefNumber;
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
export class RefNumber {
|
|
13
|
+
container;
|
|
14
|
+
refKey;
|
|
15
|
+
constructor(value, refKey) {
|
|
16
|
+
this.refKey = refKey;
|
|
17
|
+
refKey && Ref.set(refKey, this);
|
|
18
|
+
this.container = new RefContainer(value);
|
|
19
|
+
}
|
|
20
|
+
toFixed(fractionDigits) {
|
|
21
|
+
return this.value.toFixed(fractionDigits);
|
|
22
|
+
}
|
|
23
|
+
toExponential(fractionDigits) {
|
|
24
|
+
return this.value.toExponential(fractionDigits);
|
|
25
|
+
}
|
|
26
|
+
toPrecision(precision) {
|
|
27
|
+
return this.value.toPrecision(precision);
|
|
28
|
+
}
|
|
29
|
+
valueOf() {
|
|
30
|
+
return this.value.valueOf();
|
|
31
|
+
}
|
|
32
|
+
toLocaleString(locales, options) {
|
|
33
|
+
return this.value.toLocaleString(locales, options);
|
|
34
|
+
}
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
emit(propertyName, value) {
|
|
37
|
+
if (this.value === value.valueOf())
|
|
38
|
+
return;
|
|
39
|
+
this.container.emitAll(propertyName, (this.container.value = value.valueOf()));
|
|
40
|
+
}
|
|
41
|
+
subscribe(target, propertyName, onUnsubscribe) {
|
|
42
|
+
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this.value);
|
|
43
|
+
}
|
|
44
|
+
unsubscribe(targe, propertyName = "") {
|
|
45
|
+
return this.container.unsubscribe(targe, propertyName);
|
|
46
|
+
}
|
|
47
|
+
[Symbol.toPrimitive](hint) {
|
|
48
|
+
if (hint === "number" || hint === "default") {
|
|
49
|
+
return this.value;
|
|
50
|
+
}
|
|
51
|
+
return this.valueOf();
|
|
52
|
+
}
|
|
53
|
+
static get [Symbol.species]() {
|
|
54
|
+
return Number;
|
|
55
|
+
}
|
|
56
|
+
get value() {
|
|
57
|
+
return this.container.value;
|
|
58
|
+
}
|
|
59
|
+
set value(value) {
|
|
60
|
+
this.emit("value", value);
|
|
61
|
+
}
|
|
62
|
+
toJSON() {
|
|
63
|
+
return this.container.root ? this.value : { value: this.value };
|
|
64
|
+
}
|
|
65
|
+
toString(radix) {
|
|
66
|
+
return this.value.toString(radix);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=RefNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefNumber.js","sourceRoot":"","sources":["../../../src/core/ref/RefNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAC7B,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,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { refBoolean, RefNumber, refNumber, refString, RefString, RefBoolean, RefMap, RefList, refMap, refList, RefState } from ".";
|
|
2
|
+
import { RefSet, refSet } from "./RefSet";
|
|
3
|
+
type refObject<T> = {
|
|
4
|
+
[K in keyof T]: T[K] extends string | String ? refString : T[K] extends number | Number ? refNumber : T[K] extends boolean | Boolean ? refBoolean : T[K] extends Array<K> ? refList<K> : T[K] extends Map<infer K, infer V> ? refMap<K, V> : T[K] extends Set<infer U> ? refSet<U> : T[K] extends object ? refObject<T[K]> : T[K];
|
|
5
|
+
};
|
|
6
|
+
interface RefObject<T> {
|
|
7
|
+
value: refObject<T>;
|
|
8
|
+
subscribe(target: (arg: T) => void): boolean;
|
|
9
|
+
subscribe(target: (arg: T) => void, onUnsubscribe: Function): boolean;
|
|
10
|
+
subscribe(target: object, propertyName: string | symbol): boolean;
|
|
11
|
+
subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
|
|
12
|
+
subscribe(target: object | ((args: T) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
|
|
13
|
+
unsubscribe(target: (args: T) => void): boolean;
|
|
14
|
+
unsubscribe(target: object, propertyName: string | symbol): boolean;
|
|
15
|
+
unsubscribe(target: object | ((args: T) => void), propertyName: string | symbol): boolean;
|
|
16
|
+
toString(): string;
|
|
17
|
+
toJSON(): DynamicJSON<T>;
|
|
18
|
+
valueOf(): T;
|
|
19
|
+
readonly refKey: string;
|
|
20
|
+
[Symbol.iterator](): Iterator<T>;
|
|
21
|
+
}
|
|
22
|
+
type DynamicJSON<T> = T extends object ? T : {
|
|
23
|
+
value: T;
|
|
24
|
+
};
|
|
25
|
+
export type DynamicRef<T> = T extends string | String ? RefString : T extends number | Number ? RefNumber : T extends boolean | Boolean ? RefBoolean : T extends Array<infer U> ? RefList<U> : T extends Set<infer U> ? RefSet<U> : T extends Map<infer K, infer V> ? RefMap<K, V> : T extends object ? RefObject<T> : never;
|
|
26
|
+
export declare function ref<T = any>(value?: T, refKey?: string): DynamicRef<T>;
|
|
27
|
+
export type ref<T = any> = RefObject<T>;
|
|
28
|
+
export type refType = RefString | RefNumber | RefBoolean | RefList<any> | RefSet<any> | RefMap<any, any> | RefObject<any> | RefState<any>;
|
|
29
|
+
export declare function computed<T>(fn: () => Exclude<T, void>, observers?: refType[]): DynamicRef<T>;
|
|
30
|
+
export {};
|