typecomposer 0.1.47 → 0.1.50
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.js +1 -2
- package/core/components/AlertPanel.d.ts +6 -6
- package/core/components/AlertPanel.js +1 -75
- package/core/components/AlertPanel.js.map +1 -1
- package/core/components/AvatarPanel.d.ts +2 -2
- package/core/components/AvatarPanel.js +1 -62
- package/core/components/AvatarPanel.js.map +1 -1
- package/core/components/BorderPanel.d.ts +2 -2
- package/core/components/BorderPanel.js +1 -90
- package/core/components/BorderPanel.js.map +1 -1
- package/core/components/CardPanel.d.ts +2 -2
- package/core/components/CardPanel.js +1 -11
- package/core/components/CardPanel.js.map +1 -1
- package/core/components/CheckBox.d.ts +2 -2
- package/core/components/CheckBox.js +1 -109
- package/core/components/CheckBox.js.map +1 -1
- package/core/components/ColorPicker.d.ts +2 -2
- package/core/components/ColorPicker.js +1 -36
- package/core/components/ColorPicker.js.map +1 -1
- package/core/components/ContextMenu.d.ts +3 -3
- package/core/components/ContextMenu.js +1 -64
- package/core/components/ContextMenu.js.map +1 -1
- package/core/components/DialogPanel.d.ts +2 -2
- package/core/components/DialogPanel.js +1 -62
- package/core/components/DialogPanel.js.map +1 -1
- package/core/components/DropDown.d.ts +3 -3
- package/core/components/DropDown.js +1 -231
- package/core/components/DropDown.js.map +1 -1
- package/core/components/FlowPanel.d.ts +2 -2
- package/core/components/FlowPanel.js +1 -40
- package/core/components/FlowPanel.js.map +1 -1
- package/core/components/ForEach.d.ts +2 -2
- package/core/components/ForEach.js +1 -88
- package/core/components/ForEach.js.map +1 -1
- package/core/components/GridPanel.d.ts +4 -7
- package/core/components/GridPanel.js +1 -30
- package/core/components/GridPanel.js.map +1 -1
- package/core/components/HBox.d.ts +2 -2
- package/core/components/HBox.js +1 -10
- package/core/components/HBox.js.map +1 -1
- package/core/components/LazyLoading.d.ts +2 -2
- package/core/components/LazyLoading.js +1 -36
- package/core/components/LazyLoading.js.map +1 -1
- package/core/components/ListPanel.d.ts +2 -2
- package/core/components/ListPanel.js +1 -153
- package/core/components/ListPanel.js.map +1 -1
- package/core/components/PopUpButton.d.ts +2 -2
- package/core/components/PopUpButton.js +1 -57
- package/core/components/PopUpButton.js.map +1 -1
- package/core/components/ScrollPanel.d.ts +2 -2
- package/core/components/ScrollPanel.js +1 -35
- package/core/components/ScrollPanel.js.map +1 -1
- package/core/components/SliderPanel.d.ts +2 -2
- package/core/components/SliderPanel.js +1 -135
- package/core/components/SliderPanel.js.map +1 -1
- package/core/components/StackPanel.d.ts +2 -2
- package/core/components/StackPanel.js +1 -10
- package/core/components/StackPanel.js.map +1 -1
- package/core/components/TabItem.js +1 -84
- package/core/components/TabPanel.d.ts +2 -2
- package/core/components/TabPanel.js +1 -96
- package/core/components/TabPanel.js.map +1 -1
- package/core/components/TextEdit.js +1 -174
- package/core/components/TextField.d.ts +2 -2
- package/core/components/TextField.js +1 -140
- package/core/components/TextField.js.map +1 -1
- package/core/components/ToggleButton.d.ts +2 -2
- package/core/components/ToggleButton.js +1 -20
- package/core/components/ToggleButton.js.map +1 -1
- package/core/components/Tooltip.d.ts +4 -6
- package/core/components/Tooltip.js +1 -14
- package/core/components/Tooltip.js.map +1 -1
- package/core/components/VBox.d.ts +2 -2
- package/core/components/VBox.js +1 -10
- package/core/components/VBox.js.map +1 -1
- package/core/components/VirtualScroll.d.ts +2 -2
- package/core/components/VirtualScroll.js +1 -47
- package/core/components/index.d.ts +1 -2
- package/core/components/index.js +1 -30
- package/core/components/index.js.map +1 -1
- package/core/decorators/RegisterComponent.js +1 -20
- package/core/decorators/StyleLink.js +1 -13
- package/core/decorators/index.js +1 -6
- package/core/element/AbbreviationElement.d.ts +2 -4
- package/core/element/AbbreviationElement.js +1 -10
- package/core/element/AbbreviationElement.js.map +1 -1
- package/core/element/AnchorElement.d.ts +2 -18
- package/core/element/AnchorElement.js +1 -31
- package/core/element/AnchorElement.js.map +1 -1
- package/core/element/AreaElement.d.ts +2 -15
- package/core/element/AreaElement.js +1 -11
- package/core/element/AreaElement.js.map +1 -1
- package/core/element/ArticleElement.d.ts +2 -2
- package/core/element/ArticleElement.js +1 -12
- package/core/element/ArticleElement.js.map +1 -1
- package/core/element/AudioElement.d.ts +2 -9
- package/core/element/AudioElement.js +1 -10
- package/core/element/AudioElement.js.map +1 -1
- package/core/element/BaseElement.d.ts +2 -5
- package/core/element/BaseElement.js +1 -11
- package/core/element/BaseElement.js.map +1 -1
- package/core/element/BodyElement.d.ts +2 -2
- package/core/element/BodyElement.js +1 -11
- package/core/element/BodyElement.js.map +1 -1
- package/core/element/BoldElement.d.ts +2 -2
- package/core/element/BoldElement.js +1 -10
- package/core/element/BoldElement.js.map +1 -1
- package/core/element/BreakElement.d.ts +2 -2
- package/core/element/BreakElement.js +1 -10
- package/core/element/BreakElement.js.map +1 -1
- package/core/element/ButtonElement.d.ts +4 -21
- package/core/element/ButtonElement.js +1 -47
- package/core/element/ButtonElement.js.map +1 -1
- package/core/element/CanvasElement.d.ts +2 -2
- package/core/element/CanvasElement.js +1 -14
- package/core/element/CanvasElement.js.map +1 -1
- package/core/element/CaptionElement.d.ts +2 -2
- package/core/element/CaptionElement.js +1 -13
- package/core/element/CaptionElement.js.map +1 -1
- package/core/element/CiteElement.d.ts +2 -2
- package/core/element/CiteElement.js +1 -11
- package/core/element/CiteElement.js.map +1 -1
- package/core/element/CodeElement.d.ts +2 -2
- package/core/element/CodeElement.js +1 -13
- package/core/element/CodeElement.js.map +1 -1
- package/core/element/DataListElement.d.ts +2 -2
- package/core/element/DataListElement.js +1 -13
- package/core/element/DataListElement.js.map +1 -1
- package/core/element/DefinitionDescriptionElement.d.ts +2 -2
- package/core/element/DefinitionDescriptionElement.js +1 -13
- package/core/element/DefinitionDescriptionElement.js.map +1 -1
- package/core/element/DefinitionElement.d.ts +2 -2
- package/core/element/DefinitionElement.js +1 -13
- package/core/element/DefinitionElement.js.map +1 -1
- package/core/element/DeletedTextElement.d.ts +2 -4
- package/core/element/DeletedTextElement.js +1 -15
- package/core/element/DeletedTextElement.js.map +1 -1
- package/core/element/DetailsElement.d.ts +3 -6
- package/core/element/DetailsElement.js +1 -28
- package/core/element/DetailsElement.js.map +1 -1
- package/core/element/DialogElement.d.ts +2 -4
- package/core/element/DialogElement.js +1 -14
- package/core/element/DialogElement.js.map +1 -1
- package/core/element/DivElement.d.ts +2 -2
- package/core/element/DivElement.js +1 -10
- package/core/element/DivElement.js.map +1 -1
- package/core/element/EmElement.d.ts +2 -2
- package/core/element/EmElement.js +1 -10
- package/core/element/EmElement.js.map +1 -1
- package/core/element/EmbedElement.d.ts +2 -7
- package/core/element/EmbedElement.js +1 -19
- package/core/element/EmbedElement.js.map +1 -1
- package/core/element/FieldSetElement.d.ts +3 -6
- package/core/element/FieldSetElement.js +1 -34
- package/core/element/FieldSetElement.js.map +1 -1
- package/core/element/FooterElement.d.ts +2 -2
- package/core/element/FooterElement.js +1 -13
- package/core/element/FooterElement.js.map +1 -1
- package/core/element/FormElement.d.ts +2 -17
- package/core/element/FormElement.js +1 -36
- package/core/element/FormElement.js.map +1 -1
- package/core/element/Fragment.js +1 -103
- package/core/element/H1Element.d.ts +2 -2
- package/core/element/H1Element.js +1 -10
- package/core/element/H1Element.js.map +1 -1
- package/core/element/H2Element.d.ts +2 -2
- package/core/element/H2Element.js +1 -10
- package/core/element/H2Element.js.map +1 -1
- package/core/element/H3Element.d.ts +2 -2
- package/core/element/H3Element.js +1 -10
- package/core/element/H3Element.js.map +1 -1
- package/core/element/H4Element.d.ts +2 -2
- package/core/element/H4Element.js +1 -10
- package/core/element/H4Element.js.map +1 -1
- package/core/element/H5Element.d.ts +2 -2
- package/core/element/H5Element.js +1 -10
- package/core/element/H5Element.js.map +1 -1
- package/core/element/H6Element.d.ts +2 -2
- package/core/element/H6Element.js +1 -10
- package/core/element/H6Element.js.map +1 -1
- package/core/element/HeadElement.d.ts +2 -2
- package/core/element/HeadElement.js +1 -11
- package/core/element/HeadElement.js.map +1 -1
- package/core/element/HeaderElement.d.ts +2 -2
- package/core/element/HeaderElement.js +1 -13
- package/core/element/HeaderElement.js.map +1 -1
- package/core/element/HorizontalRuleElement.d.ts +2 -2
- package/core/element/HorizontalRuleElement.js +1 -13
- package/core/element/HorizontalRuleElement.js.map +1 -1
- package/core/element/HtmlElement.d.ts +2 -4
- package/core/element/HtmlElement.js +1 -19
- package/core/element/HtmlElement.js.map +1 -1
- package/core/element/IFrameElement.d.ts +2 -15
- package/core/element/IFrameElement.js +1 -67
- package/core/element/IFrameElement.js.map +1 -1
- package/core/element/ILayout.d.ts +2 -2
- package/core/element/ILayout.js +1 -9
- package/core/element/ILayout.js.map +1 -1
- package/core/element/IconElement.d.ts +2 -2
- package/core/element/IconElement.js +1 -32
- package/core/element/IconElement.js.map +1 -1
- package/core/element/IdiomaticElement.d.ts +2 -1
- package/core/element/IdiomaticElement.js +1 -6
- package/core/element/IdiomaticElement.js.map +1 -1
- package/core/element/ImageElement.d.ts +2 -2
- package/core/element/ImageElement.js +1 -17
- package/core/element/ImageElement.js.map +1 -1
- package/core/element/InputElement.d.ts +2 -16
- package/core/element/InputElement.js +1 -81
- package/core/element/InputElement.js.map +1 -1
- package/core/element/LabelElement.d.ts +2 -5
- package/core/element/LabelElement.js +1 -10
- package/core/element/LabelElement.js.map +1 -1
- package/core/element/LegendElement.d.ts +2 -4
- package/core/element/LegendElement.js +1 -15
- package/core/element/LegendElement.js.map +1 -1
- package/core/element/ListItemElement.d.ts +2 -4
- package/core/element/ListItemElement.js +1 -28
- package/core/element/ListItemElement.js.map +1 -1
- package/core/element/MainElement.d.ts +2 -2
- package/core/element/MainElement.js +1 -10
- package/core/element/MainElement.js.map +1 -1
- package/core/element/NavElement.d.ts +2 -2
- package/core/element/NavElement.js +1 -10
- package/core/element/NavElement.js.map +1 -1
- package/core/element/OrderedListElement.d.ts +2 -2
- package/core/element/OrderedListElement.js +1 -10
- package/core/element/OrderedListElement.js.map +1 -1
- package/core/element/ParagraphElement.d.ts +2 -2
- package/core/element/ParagraphElement.js +1 -10
- package/core/element/ParagraphElement.js.map +1 -1
- package/core/element/PreElement.d.ts +2 -2
- package/core/element/PreElement.js +1 -10
- package/core/element/PreElement.js.map +1 -1
- package/core/element/SectionElement.d.ts +2 -2
- package/core/element/SectionElement.js +1 -12
- package/core/element/SectionElement.js.map +1 -1
- package/core/element/SelectElement.d.ts +2 -2
- package/core/element/SelectElement.js +1 -12
- package/core/element/SelectElement.js.map +1 -1
- package/core/element/SourceElement.d.ts +2 -5
- package/core/element/SourceElement.js +1 -14
- package/core/element/SourceElement.js.map +1 -1
- package/core/element/SpanElement.d.ts +2 -2
- package/core/element/SpanElement.js +1 -10
- package/core/element/SpanElement.js.map +1 -1
- package/core/element/StrongElement.d.ts +2 -2
- package/core/element/StrongElement.js +1 -12
- package/core/element/StrongElement.js.map +1 -1
- package/core/element/StyleElement.d.ts +2 -2
- package/core/element/StyleElement.js +1 -10
- package/core/element/StyleElement.js.map +1 -1
- package/core/element/SummaryElement.d.ts +2 -2
- package/core/element/SummaryElement.js +1 -12
- package/core/element/SummaryElement.js.map +1 -1
- package/core/element/SvgElement.d.ts +3 -3
- package/core/element/SvgElement.js +1 -151
- package/core/element/SvgElement.js.map +1 -1
- package/core/element/TableBodyElement.d.ts +2 -2
- package/core/element/TableBodyElement.js +1 -10
- package/core/element/TableBodyElement.js.map +1 -1
- package/core/element/TableCellElement.d.ts +3 -6
- package/core/element/TableCellElement.js +1 -25
- package/core/element/TableCellElement.js.map +1 -1
- package/core/element/TableColElement.d.ts +2 -4
- package/core/element/TableColElement.js +1 -13
- package/core/element/TableColElement.js.map +1 -1
- package/core/element/TableColGroupElement.d.ts +2 -4
- package/core/element/TableColGroupElement.js +1 -15
- package/core/element/TableColGroupElement.js.map +1 -1
- package/core/element/TableElement.d.ts +2 -42
- package/core/element/TableElement.js +1 -228
- package/core/element/TableElement.js.map +1 -1
- package/core/element/TableFootElement.d.ts +2 -2
- package/core/element/TableFootElement.js +1 -10
- package/core/element/TableFootElement.js.map +1 -1
- package/core/element/TableFootRowElement.d.ts +2 -2
- package/core/element/TableFootRowElement.js +1 -23
- package/core/element/TableFootRowElement.js.map +1 -1
- package/core/element/TableHeadCellElement.d.ts +2 -2
- package/core/element/TableHeadCellElement.js +1 -24
- package/core/element/TableHeadCellElement.js.map +1 -1
- package/core/element/TableHeadElement.d.ts +2 -2
- package/core/element/TableHeadElement.js +1 -10
- package/core/element/TableHeadElement.js.map +1 -1
- package/core/element/TableHeadRowElement.d.ts +2 -2
- package/core/element/TableHeadRowElement.js +1 -29
- package/core/element/TableHeadRowElement.js.map +1 -1
- package/core/element/TableRowElement.d.ts +2 -2
- package/core/element/TableRowElement.js +1 -29
- package/core/element/TableRowElement.js.map +1 -1
- package/core/element/TextAreaElement.d.ts +2 -4
- package/core/element/TextAreaElement.js +1 -10
- package/core/element/TextAreaElement.js.map +1 -1
- package/core/element/UListElement.d.ts +2 -2
- package/core/element/UListElement.js +1 -10
- package/core/element/UListElement.js.map +1 -1
- package/core/element/VideoElement.d.ts +2 -10
- package/core/element/VideoElement.js +1 -16
- package/core/element/VideoElement.js.map +1 -1
- package/core/element/index.d.ts +3 -3
- package/core/element/index.js +1 -73
- package/core/element/index.js.map +1 -1
- package/core/event/index.js +1 -75
- package/core/index.d.ts +0 -3
- package/core/index.js +1 -10
- package/core/index.js.map +1 -1
- package/core/ref/Computed.js +1 -75
- package/core/ref/Computed.js.map +1 -1
- package/core/ref/RefBoolean.js +1 -119
- package/core/ref/RefContainer.js +1 -114
- package/core/ref/RefContainer.js.map +1 -1
- package/core/ref/RefList.js +1 -240
- package/core/ref/RefMap.js +1 -149
- package/core/ref/RefNumber.js +1 -157
- package/core/ref/RefObject.js +1 -265
- package/core/ref/RefObject.js.map +1 -1
- package/core/ref/RefProperty.js +1 -46
- package/core/ref/RefSet.js +1 -148
- package/core/ref/RefState.js +1 -89
- package/core/ref/RefString.js +1 -179
- package/core/ref/RefString.js.map +1 -1
- package/core/ref/index.js +1 -71
- package/core/router/RouteView.d.ts +2 -2
- package/core/router/RouteView.js +1 -84
- package/core/router/RouteView.js.map +1 -1
- package/core/router/Router.d.ts +8 -9
- package/core/router/Router.js +1 -307
- package/core/router/Router.js.map +1 -1
- package/core/router/RouterEvent.js +1 -43
- package/core/router/RouterGuard.js +1 -3
- package/core/router/index.js +1 -5
- package/core/styles/index.d.ts +3 -3
- package/core/styles/index.js +1 -36
- package/core/styles/index.js.map +1 -1
- package/{core/app/index.d.ts → global/app.d.ts} +5 -7
- package/global/app.js +1 -0
- package/global/app.js.map +1 -0
- package/global/index.d.ts +10 -4
- package/global/index.js +1 -1286
- package/global/index.js.map +1 -1
- package/global/safari-polyfill.js +1 -234
- package/index.d.ts +1 -0
- package/index.js +1 -4
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/styles/style.scss +2 -17
- package/typings/index.d.ts +58 -66
- package/LICENSE +0 -21
- package/README.md +0 -62
- package/core/app/Validate.d.ts +0 -61
- package/core/app/Validate.js +0 -2
- package/core/app/Validate.js.map +0 -1
- package/core/app/index.js +0 -181
- package/core/app/index.js.map +0 -1
- package/core/components/TablePanel.d.ts +0 -34
- package/core/components/TablePanel.js +0 -127
- package/core/components/TablePanel.js.map +0 -1
- package/core/components/VirtualScroll copy 2.d.ts +0 -24
- package/core/components/VirtualScroll copy 2.js +0 -92
- package/core/components/VirtualScroll copy 2.js.map +0 -1
- package/core/ref/RefObject copy.d.ts +0 -124
- package/core/ref/RefObject copy.js +0 -271
- package/core/ref/RefObject copy.js.map +0 -1
package/core/ref/RefList.js
CHANGED
|
@@ -1,240 +1 @@
|
|
|
1
|
-
import { Ref } from "."
|
|
2
|
-
import { RefContainer } from "./RefContainer";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a new reactive list wrapper around a standard array.
|
|
5
|
-
*
|
|
6
|
-
* @param items - The initial array of items.
|
|
7
|
-
* @returns A new instance of RefList.
|
|
8
|
-
*/
|
|
9
|
-
export function refList(items) {
|
|
10
|
-
return new RefList(items);
|
|
11
|
-
}
|
|
12
|
-
// Enables `instanceof refList` to work correctly
|
|
13
|
-
Object.defineProperty(refList, Symbol.hasInstance, {
|
|
14
|
-
value: function (instance) {
|
|
15
|
-
return !!instance && instance instanceof RefList;
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* A reactive wrapper for arrays that notifies subscribers on mutation.
|
|
20
|
-
* Inherits from Array and intercepts mutations like push, pop, splice, etc.
|
|
21
|
-
*/
|
|
22
|
-
export class RefList extends Array {
|
|
23
|
-
/**
|
|
24
|
-
* Internal container that manages the reactive value and its subscribers.
|
|
25
|
-
*/
|
|
26
|
-
container;
|
|
27
|
-
id;
|
|
28
|
-
/**
|
|
29
|
-
* Constructs a new RefList instance with the given items.
|
|
30
|
-
*
|
|
31
|
-
* @param items - The initial items for the list.
|
|
32
|
-
* @param refKey - Optional key used for registration in a central Ref registry.
|
|
33
|
-
*/
|
|
34
|
-
constructor(items) {
|
|
35
|
-
super(...items);
|
|
36
|
-
this.container = new RefContainer(this);
|
|
37
|
-
this.id = this.container.id;
|
|
38
|
-
Ref.set(this.id, this);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Emits a change event to all subscribers for a specific mutation.
|
|
42
|
-
*
|
|
43
|
-
* @param propertyName - The type of mutation (e.g., "push", "splice", "value").
|
|
44
|
-
* @param value - The new list value.
|
|
45
|
-
*/
|
|
46
|
-
emit(propertyName, value) {
|
|
47
|
-
const oldValue = this.valueOf();
|
|
48
|
-
this.container.emitAll(propertyName, value, oldValue);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Subscribes to list changes and immediately emits the current value.
|
|
52
|
-
*/
|
|
53
|
-
subscribe(target, propertyName, onUnsubscribe) {
|
|
54
|
-
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this, this.valueOf());
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Subscribes to future changes without emitting the current value.
|
|
58
|
-
*/
|
|
59
|
-
listen(target, onUnsubscribe) {
|
|
60
|
-
return this.container.subscribe(target, onUnsubscribe) !== undefined;
|
|
61
|
-
}
|
|
62
|
-
unsubscribe(targe, propertyName = "") {
|
|
63
|
-
return this.container.unsubscribe(targe, propertyName);
|
|
64
|
-
}
|
|
65
|
-
/** Reactive mutation overrides **/
|
|
66
|
-
push(...items) {
|
|
67
|
-
const oldValue = this.valueOf();
|
|
68
|
-
const n = super.push(...items);
|
|
69
|
-
this.container.emitAll("push", this, oldValue);
|
|
70
|
-
return n;
|
|
71
|
-
}
|
|
72
|
-
pop() {
|
|
73
|
-
const oldValue = this.valueOf();
|
|
74
|
-
const item = super.pop();
|
|
75
|
-
this.container.emitAll("pop", this, oldValue);
|
|
76
|
-
return item;
|
|
77
|
-
}
|
|
78
|
-
shift() {
|
|
79
|
-
const oldValue = this.valueOf();
|
|
80
|
-
const item = super.shift();
|
|
81
|
-
this.container.emitAll("shift", this, oldValue);
|
|
82
|
-
return item;
|
|
83
|
-
}
|
|
84
|
-
unshift(...items) {
|
|
85
|
-
const oldValue = this.valueOf();
|
|
86
|
-
const n = super.unshift(...items);
|
|
87
|
-
this.container.emitAll("unshift", this, oldValue);
|
|
88
|
-
return n;
|
|
89
|
-
}
|
|
90
|
-
splice(start, deleteCount = 0, ...items) {
|
|
91
|
-
const oldValue = this.valueOf();
|
|
92
|
-
const deleted = super.splice(start, deleteCount, ...items);
|
|
93
|
-
this.container.emitAll("splice", this, oldValue);
|
|
94
|
-
return deleted;
|
|
95
|
-
}
|
|
96
|
-
sort(compareFn) {
|
|
97
|
-
const oldValue = this.valueOf();
|
|
98
|
-
super.sort(compareFn);
|
|
99
|
-
this.container.emitAll("sort", this, oldValue);
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
reverse() {
|
|
103
|
-
const oldValue = this.valueOf();
|
|
104
|
-
const reversed = super.reverse();
|
|
105
|
-
this.container.emitAll("reverse", this, oldValue);
|
|
106
|
-
return reversed;
|
|
107
|
-
}
|
|
108
|
-
fill(value, start, end) {
|
|
109
|
-
const oldValue = this.valueOf();
|
|
110
|
-
super.fill(value, start, end);
|
|
111
|
-
this.container.emitAll("fill", this, oldValue);
|
|
112
|
-
return this;
|
|
113
|
-
}
|
|
114
|
-
copyWithin(target, start, end) {
|
|
115
|
-
const oldValue = this.valueOf();
|
|
116
|
-
super.copyWithin(target, start, end);
|
|
117
|
-
this.container.emitAll("copyWithin", this, oldValue);
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Changes the length of the array and emits a change.
|
|
122
|
-
*/
|
|
123
|
-
set length(value) {
|
|
124
|
-
const oldValue = this.length;
|
|
125
|
-
super.length = value;
|
|
126
|
-
this.container.emitAll("length", this, oldValue);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Clears all elements in the list.
|
|
130
|
-
*/
|
|
131
|
-
clear() {
|
|
132
|
-
const oldValue = this.length;
|
|
133
|
-
super.length = 0;
|
|
134
|
-
this.container.emitAll("clear", this, oldValue);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Inserts items at a specific index.
|
|
138
|
-
*/
|
|
139
|
-
insert(index, ...items) {
|
|
140
|
-
const oldValue = this.valueOf();
|
|
141
|
-
super.splice(index, 0, ...items);
|
|
142
|
-
this.container.emitAll("insert", this, oldValue);
|
|
143
|
-
return this.length;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Removes a specific item from the list.
|
|
147
|
-
*/
|
|
148
|
-
removeItem(value) {
|
|
149
|
-
const index = super.indexOf(value);
|
|
150
|
-
if (index === -1)
|
|
151
|
-
return value;
|
|
152
|
-
const oldValue = this.valueOf();
|
|
153
|
-
super.splice(index, 1);
|
|
154
|
-
this.container.emitAll("removeValue", this, oldValue);
|
|
155
|
-
return value;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Removes elements starting from an index.
|
|
159
|
-
*/
|
|
160
|
-
remove(index, count = 1) {
|
|
161
|
-
const oldValue = this.valueOf();
|
|
162
|
-
super.splice(index, count);
|
|
163
|
-
this.container.emitAll("remove", this, oldValue);
|
|
164
|
-
return this.length;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Returns a shallow copy of the current list.
|
|
168
|
-
*/
|
|
169
|
-
valueOf() {
|
|
170
|
-
return Array.from(this);
|
|
171
|
-
}
|
|
172
|
-
get length() {
|
|
173
|
-
return super.length;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Synchronizes the children of an HTML element with a list of HTMLElements.
|
|
177
|
-
*
|
|
178
|
-
* @param list - The list of elements to reflect in the container.
|
|
179
|
-
* @param element - The container element whose children will be updated.
|
|
180
|
-
*/
|
|
181
|
-
static syncComponentWithList(list, element) {
|
|
182
|
-
const currentChildren = Array.from(element.children);
|
|
183
|
-
currentChildren.forEach((child) => {
|
|
184
|
-
if (!list.includes(child)) {
|
|
185
|
-
element.removeChild(child);
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
list.forEach((el) => {
|
|
189
|
-
// @ts-ignore
|
|
190
|
-
if (el instanceof Node && !currentChildren.includes(el)) {
|
|
191
|
-
element.appendChild(el);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
list.forEach((el, index) => {
|
|
195
|
-
if (el instanceof Node && element.children[index] !== el) {
|
|
196
|
-
element.insertBefore(el, element.children[index] || null);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Identifies this object as a custom reactive list in `Object.prototype.toString`.
|
|
202
|
-
*/
|
|
203
|
-
get [Symbol.toStringTag]() {
|
|
204
|
-
return "refList";
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Ensures Array is returned when using methods like `slice()` or `map()`.
|
|
208
|
-
*/
|
|
209
|
-
static get [Symbol.species]() {
|
|
210
|
-
return Array;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Gets the current value of the reactive list.
|
|
214
|
-
* Returns a shallow copy of the internal array to prevent direct mutation.
|
|
215
|
-
*/
|
|
216
|
-
get value() {
|
|
217
|
-
return this.container.value.valueOf();
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Replaces the entire contents of the list with a new array of items.
|
|
221
|
-
* If the same array reference is passed, no update or notification occurs.
|
|
222
|
-
*
|
|
223
|
-
* @param value - The new array of items to assign.
|
|
224
|
-
*/
|
|
225
|
-
set value(value) {
|
|
226
|
-
// @ts-ignore
|
|
227
|
-
if (this === value)
|
|
228
|
-
return;
|
|
229
|
-
super.splice(0, this.length, ...value);
|
|
230
|
-
this.emit("value", value);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Serializes the current list value for JSON output.
|
|
234
|
-
* This ensures only the raw array contents are emitted.
|
|
235
|
-
*/
|
|
236
|
-
toJSON() {
|
|
237
|
-
return this.value;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
//# sourceMappingURL=RefList.js.map
|
|
1
|
+
import{Ref}from".";import{RefContainer}from"./RefContainer";export function refList(t){return new RefList(t)}Object.defineProperty(refList,Symbol.hasInstance,{value:function(t){return!!t&&t instanceof RefList}});export class RefList extends Array{container;id;constructor(t){super(...t),this.container=new RefContainer(this),this.id=this.container.id,Ref.set(this.id,this)}emit(t,e){const i=this.valueOf();this.container.emitAll(t,e,i)}subscribe(t,e,i){return this.container.emit(this.container.subscribe(t,e,i),this,this.valueOf())}listen(t,e){return void 0!==this.container.subscribe(t,e)}unsubscribe(t,e=""){return this.container.unsubscribe(t,e)}push(...t){const e=this.valueOf(),i=super.push(...t);return this.container.emitAll("push",this,e),i}pop(){const t=this.valueOf(),e=super.pop();return this.container.emitAll("pop",this,t),e}shift(){const t=this.valueOf(),e=super.shift();return this.container.emitAll("shift",this,t),e}unshift(...t){const e=this.valueOf(),i=super.unshift(...t);return this.container.emitAll("unshift",this,e),i}splice(t,e=0,...i){const s=this.valueOf(),r=super.splice(t,e,...i);return this.container.emitAll("splice",this,s),r}sort(t){const e=this.valueOf();return super.sort(t),this.container.emitAll("sort",this,e),this}reverse(){const t=this.valueOf(),e=super.reverse();return this.container.emitAll("reverse",this,t),e}fill(t,e,i){const s=this.valueOf();return super.fill(t,e,i),this.container.emitAll("fill",this,s),this}copyWithin(t,e,i){const s=this.valueOf();return super.copyWithin(t,e,i),this.container.emitAll("copyWithin",this,s),this}set length(t){const e=this.length;super.length=t,this.container.emitAll("length",this,e)}clear(){const t=this.length;super.length=0,this.container.emitAll("clear",this,t)}insert(t,...e){const i=this.valueOf();return super.splice(t,0,...e),this.container.emitAll("insert",this,i),this.length}removeItem(t){const e=super.indexOf(t);if(-1===e)return t;const i=this.valueOf();return super.splice(e,1),this.container.emitAll("removeValue",this,i),t}remove(t,e=1){const i=this.valueOf();return super.splice(t,e),this.container.emitAll("remove",this,i),this.length}valueOf(){return Array.from(this)}get length(){return super.length}static syncComponentWithList(t,e){const i=Array.from(e.children);i.forEach(i=>{t.includes(i)||e.removeChild(i)}),t.forEach(t=>{t instanceof Node&&!i.includes(t)&&e.appendChild(t)}),t.forEach((t,i)=>{t instanceof Node&&e.children[i]!==t&&e.insertBefore(t,e.children[i]||null)})}get[Symbol.toStringTag](){return"refList"}static get[Symbol.species](){return Array}get value(){return this.container.value.valueOf()}set value(t){this!==t&&(super.splice(0,this.length,...t),this.emit("value",t))}toJSON(){return this.value}}
|
package/core/ref/RefMap.js
CHANGED
|
@@ -1,149 +1 @@
|
|
|
1
|
-
import { Ref }
|
|
2
|
-
import { RefContainer } from "./RefContainer";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a new reactive map from the given entries.
|
|
5
|
-
*
|
|
6
|
-
* @param entries - Optional initial key-value pairs.
|
|
7
|
-
* @returns A reactive RefMap instance.
|
|
8
|
-
*/
|
|
9
|
-
export function refMap(entries) {
|
|
10
|
-
return new RefMap(entries);
|
|
11
|
-
}
|
|
12
|
-
// Enables `instanceof refMap` to work correctly
|
|
13
|
-
Object.defineProperty(refMap, Symbol.hasInstance, {
|
|
14
|
-
value: function (instance) {
|
|
15
|
-
return !!instance && instance instanceof RefMap;
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* A reactive wrapper around the native Map object.
|
|
20
|
-
* Supports automatic reactivity and subscription to changes.
|
|
21
|
-
*/
|
|
22
|
-
export class RefMap extends Map {
|
|
23
|
-
/**
|
|
24
|
-
* Internal container managing subscribers and value propagation.
|
|
25
|
-
*/
|
|
26
|
-
container = new RefContainer(this);
|
|
27
|
-
id;
|
|
28
|
-
/**
|
|
29
|
-
* Constructs a new reactive map instance.
|
|
30
|
-
*
|
|
31
|
-
* @param entries - Optional initial entries to populate the map.
|
|
32
|
-
* @param refKey - Optional registration key for the Ref registry.
|
|
33
|
-
*/
|
|
34
|
-
constructor(entries) {
|
|
35
|
-
super();
|
|
36
|
-
this.id = this.container.id;
|
|
37
|
-
Ref.set(this.id, this);
|
|
38
|
-
this.value = new Map(entries);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Emits a change event to all subscribers for a given mutation type.
|
|
42
|
-
*
|
|
43
|
-
* @param propertyName - The kind of mutation (e.g., "set", "clear").
|
|
44
|
-
* @param value - The current state of the map.
|
|
45
|
-
*/
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
emit(propertyName, value) {
|
|
48
|
-
const oldValue = this.valueOf();
|
|
49
|
-
this.container.emitAll(propertyName, value, oldValue);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Subscribes to changes and immediately emits the current map value.
|
|
53
|
-
*/
|
|
54
|
-
subscribe(target, propertyName, onUnsubscribe) {
|
|
55
|
-
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this, this.valueOf());
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Subscribes to future changes without emitting the current value.
|
|
59
|
-
*
|
|
60
|
-
* @param target - Function to call on change.
|
|
61
|
-
* @param onUnsubscribe - Optional callback to invoke on unsubscription.
|
|
62
|
-
*/
|
|
63
|
-
listen(target, onUnsubscribe) {
|
|
64
|
-
return this.container.subscribe(target, onUnsubscribe) !== undefined;
|
|
65
|
-
}
|
|
66
|
-
unsubscribe(targe, propertyName = "") {
|
|
67
|
-
return this.container.unsubscribe(targe, propertyName);
|
|
68
|
-
}
|
|
69
|
-
/** Reactive mutation overrides **/
|
|
70
|
-
/**
|
|
71
|
-
* Sets a value for a given key and notifies subscribers.
|
|
72
|
-
*
|
|
73
|
-
* @param key - The key to insert or update.
|
|
74
|
-
* @param value - The value to associate with the key.
|
|
75
|
-
* @returns The map itself.
|
|
76
|
-
*/
|
|
77
|
-
set(key, value) {
|
|
78
|
-
const oldValue = this.valueOf();
|
|
79
|
-
const result = super.set(key, value);
|
|
80
|
-
this.container.emitAll("set", this, oldValue);
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Deletes a key-value pair and notifies subscribers.
|
|
85
|
-
*
|
|
86
|
-
* @param key - The key to delete.
|
|
87
|
-
* @returns True if the key existed and was removed.
|
|
88
|
-
*/
|
|
89
|
-
delete(key) {
|
|
90
|
-
const oldValue = this.valueOf();
|
|
91
|
-
const result = super.delete(key);
|
|
92
|
-
this.container.emitAll("delete", this, oldValue);
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Clears all entries from the map and notifies subscribers.
|
|
97
|
-
*/
|
|
98
|
-
clear() {
|
|
99
|
-
const oldValue = this.valueOf();
|
|
100
|
-
super.clear();
|
|
101
|
-
this.container.emitAll("clear", this, oldValue);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Returns a shallow copy of the current map state.
|
|
105
|
-
*/
|
|
106
|
-
valueOf() {
|
|
107
|
-
return new Map(Array.from(this));
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Ensures native `Map` is returned when using `Map` methods that create new instances.
|
|
111
|
-
*/
|
|
112
|
-
static get [Symbol.species]() {
|
|
113
|
-
return Map;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Gets the current value of the reactive map.
|
|
117
|
-
* Returns a shallow copy to prevent unintended mutation.
|
|
118
|
-
*/
|
|
119
|
-
get value() {
|
|
120
|
-
return this.container.value.valueOf();
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Sets the entire contents of the map to match the given Map instance.
|
|
124
|
-
* If the same reference is passed, no update is triggered.
|
|
125
|
-
*
|
|
126
|
-
* @param value - A new Map to replace the current contents.
|
|
127
|
-
*/
|
|
128
|
-
set value(value) {
|
|
129
|
-
if (this === value)
|
|
130
|
-
return;
|
|
131
|
-
super.clear();
|
|
132
|
-
for (const [key, val] of value) {
|
|
133
|
-
super.set(key, val);
|
|
134
|
-
}
|
|
135
|
-
this.emit("value", value);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Serializes the map to a plain JavaScript object for JSON output.
|
|
139
|
-
* Note: keys are converted to string.
|
|
140
|
-
*/
|
|
141
|
-
toJSON() {
|
|
142
|
-
const obj = {};
|
|
143
|
-
for (const [k, v] of this.value) {
|
|
144
|
-
obj[k] = v;
|
|
145
|
-
}
|
|
146
|
-
return obj;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=RefMap.js.map
|
|
1
|
+
import{Ref}from".";import{RefContainer}from"./RefContainer";export function refMap(e){return new RefMap(e)}Object.defineProperty(refMap,Symbol.hasInstance,{value:function(e){return!!e&&e instanceof RefMap}});export class RefMap extends Map{container=new RefContainer(this);id;constructor(e){super(),this.id=this.container.id,Ref.set(this.id,this),this.value=new Map(e)}emit(e,t){const i=this.valueOf();this.container.emitAll(e,t,i)}subscribe(e,t,i){return this.container.emit(this.container.subscribe(e,t,i),this,this.valueOf())}listen(e,t){return void 0!==this.container.subscribe(e,t)}unsubscribe(e,t=""){return this.container.unsubscribe(e,t)}set(e,t){const i=this.valueOf(),r=super.set(e,t);return this.container.emitAll("set",this,i),r}delete(e){const t=this.valueOf(),i=super.delete(e);return this.container.emitAll("delete",this,t),i}clear(){const e=this.valueOf();super.clear(),this.container.emitAll("clear",this,e)}valueOf(){return new Map(Array.from(this))}static get[Symbol.species](){return Map}get value(){return this.container.value.valueOf()}set value(e){if(this!==e){super.clear();for(const[t,i]of e)super.set(t,i);this.emit("value",e)}}toJSON(){const e={};for(const[t,i]of this.value)e[t]=i;return e}}
|
package/core/ref/RefNumber.js
CHANGED
|
@@ -1,157 +1 @@
|
|
|
1
|
-
import { Ref }
|
|
2
|
-
import { RefContainer } from "./RefContainer";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a reactive wrapper for a numeric value.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The initial number value.
|
|
7
|
-
* @returns A new instance of RefNumber.
|
|
8
|
-
*/
|
|
9
|
-
export function refNumber(value) {
|
|
10
|
-
return new RefNumber(value);
|
|
11
|
-
}
|
|
12
|
-
// Enables `instanceof refNumber` to return true for RefNumber instances
|
|
13
|
-
Object.defineProperty(refNumber, Symbol.hasInstance, {
|
|
14
|
-
value: function (instance) {
|
|
15
|
-
return !!instance && instance instanceof RefNumber;
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* A reactive wrapper for numbers that behaves like a Number object.
|
|
20
|
-
* Allows subscriptions to value changes and integrates with primitive operations.
|
|
21
|
-
*/
|
|
22
|
-
export class RefNumber {
|
|
23
|
-
/**
|
|
24
|
-
* The container holding the internal value and managing subscriptions.
|
|
25
|
-
*/
|
|
26
|
-
container;
|
|
27
|
-
id;
|
|
28
|
-
/**
|
|
29
|
-
* Constructs a new reactive number wrapper.
|
|
30
|
-
*
|
|
31
|
-
* @param value - The initial number value.
|
|
32
|
-
*/
|
|
33
|
-
constructor(value) {
|
|
34
|
-
this.container = new RefContainer(value);
|
|
35
|
-
this.id = this.container.id;
|
|
36
|
-
Ref.set(this.id, this);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Emits a change notification if the value has changed.
|
|
40
|
-
*
|
|
41
|
-
* @param propertyName - The name of the property being updated (usually "value").
|
|
42
|
-
* @param value - The new number value to assign.
|
|
43
|
-
*/
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
emit(propertyName, value) {
|
|
46
|
-
if (this.value === value.valueOf())
|
|
47
|
-
return;
|
|
48
|
-
const oldValue = this.valueOf();
|
|
49
|
-
this.container.emitAll(propertyName, (this.container.value = value.valueOf()), oldValue);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Subscribes to value changes and immediately emits the current number.
|
|
53
|
-
*/
|
|
54
|
-
subscribe(target, propertyName, onUnsubscribe) {
|
|
55
|
-
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this.value, this.valueOf());
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Subscribes to future value changes without emitting the current number.
|
|
59
|
-
*
|
|
60
|
-
* @param target - A function to be called on future updates.
|
|
61
|
-
* @param onUnsubscribe - Optional callback to be called upon unsubscription.
|
|
62
|
-
* @returns true if successfully subscribed.
|
|
63
|
-
*/
|
|
64
|
-
listen(target, onUnsubscribe) {
|
|
65
|
-
return this.container.subscribe(target, onUnsubscribe) !== undefined;
|
|
66
|
-
}
|
|
67
|
-
unsubscribe(targe, propertyName = "") {
|
|
68
|
-
return this.container.unsubscribe(targe, propertyName);
|
|
69
|
-
}
|
|
70
|
-
/** Value access and primitives **/
|
|
71
|
-
/**
|
|
72
|
-
* Gets the current number value.
|
|
73
|
-
*/
|
|
74
|
-
get value() {
|
|
75
|
-
return this.container.value;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Sets a new number value and notifies subscribers if it changed.
|
|
79
|
-
*
|
|
80
|
-
* @param value - The new number to set.
|
|
81
|
-
*/
|
|
82
|
-
set value(value) {
|
|
83
|
-
this.emit("value", value);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Returns the primitive number value.
|
|
87
|
-
*/
|
|
88
|
-
valueOf() {
|
|
89
|
-
return this.value.valueOf();
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Converts the value to a string using an optional radix.
|
|
93
|
-
*
|
|
94
|
-
* @param radix - An integer between 2 and 36 specifying the base.
|
|
95
|
-
*/
|
|
96
|
-
toString(radix) {
|
|
97
|
-
return this.value.toString(radix);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Converts the value to fixed-point notation.
|
|
101
|
-
*
|
|
102
|
-
* @param fractionDigits - Number of digits after the decimal point.
|
|
103
|
-
*/
|
|
104
|
-
toFixed(fractionDigits) {
|
|
105
|
-
return this.value.toFixed(fractionDigits);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Converts the value to exponential notation.
|
|
109
|
-
*
|
|
110
|
-
* @param fractionDigits - Number of digits after the decimal point.
|
|
111
|
-
*/
|
|
112
|
-
toExponential(fractionDigits) {
|
|
113
|
-
return this.value.toExponential(fractionDigits);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Formats the number to a specified precision.
|
|
117
|
-
*
|
|
118
|
-
* @param precision - Total number of significant digits.
|
|
119
|
-
*/
|
|
120
|
-
toPrecision(precision) {
|
|
121
|
-
return this.value.toPrecision(precision);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Formats the number according to locale-specific rules.
|
|
125
|
-
*
|
|
126
|
-
* @param locales - A locale string or array of locale strings.
|
|
127
|
-
* @param options - Formatting options.
|
|
128
|
-
*/
|
|
129
|
-
toLocaleString(locales, options) {
|
|
130
|
-
return this.value.toLocaleString(locales, options);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Supports automatic type coercion to a number in JS expressions.
|
|
134
|
-
*
|
|
135
|
-
* @param hint - Either "number", "string", or "default".
|
|
136
|
-
*/
|
|
137
|
-
[Symbol.toPrimitive](hint) {
|
|
138
|
-
if (hint === "number" || hint === "default") {
|
|
139
|
-
return this.value;
|
|
140
|
-
}
|
|
141
|
-
return this.valueOf();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Identifies this class as a subtype of `Number`.
|
|
145
|
-
*/
|
|
146
|
-
static get [Symbol.species]() {
|
|
147
|
-
return Number;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Serializes the current value for JSON output.
|
|
151
|
-
* If this instance is the root ref, emits the raw value, otherwise wraps it.
|
|
152
|
-
*/
|
|
153
|
-
toJSON() {
|
|
154
|
-
return this.container.root ? this.value : { value: this.value };
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
//# sourceMappingURL=RefNumber.js.map
|
|
1
|
+
import{Ref}from".";import{RefContainer}from"./RefContainer";export function refNumber(e){return new RefNumber(e)}Object.defineProperty(refNumber,Symbol.hasInstance,{value:function(e){return!!e&&e instanceof RefNumber}});export class RefNumber{container;id;constructor(e){this.container=new RefContainer(e),this.id=this.container.id,Ref.set(this.id,this)}emit(e,t){if(this.value===t.valueOf())return;const i=this.valueOf();this.container.emitAll(e,this.container.value=t.valueOf(),i)}subscribe(e,t,i){return this.container.emit(this.container.subscribe(e,t,i),this.value,this.valueOf())}listen(e,t){return void 0!==this.container.subscribe(e,t)}unsubscribe(e,t=""){return this.container.unsubscribe(e,t)}get value(){return this.container.value}set value(e){this.emit("value",e)}valueOf(){return this.value.valueOf()}toString(e){return this.value.toString(e)}toFixed(e){return this.value.toFixed(e)}toExponential(e){return this.value.toExponential(e)}toPrecision(e){return this.value.toPrecision(e)}toLocaleString(e,t){return this.value.toLocaleString(e,t)}[Symbol.toPrimitive](e){return"number"===e||"default"===e?this.value:this.valueOf()}static get[Symbol.species](){return Number}toJSON(){return this.container.root?this.value:{value:this.value}}}
|