@kurot/ui 1.1.7
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/README.md +258 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/kurot/binding/Binding.d.ts +38 -0
- package/dist/kurot/binding/Binding.d.ts.map +1 -0
- package/dist/kurot/binding/Binding.js +88 -0
- package/dist/kurot/binding/Binding.js.map +1 -0
- package/dist/kurot/binding/Watcher.d.ts +57 -0
- package/dist/kurot/binding/Watcher.d.ts.map +1 -0
- package/dist/kurot/binding/Watcher.js +119 -0
- package/dist/kurot/binding/Watcher.js.map +1 -0
- package/dist/kurot/binding/index.d.ts +3 -0
- package/dist/kurot/binding/index.d.ts.map +1 -0
- package/dist/kurot/binding/index.js +3 -0
- package/dist/kurot/binding/index.js.map +1 -0
- package/dist/kurot/collections/ArrayCollection.d.ts +56 -0
- package/dist/kurot/collections/ArrayCollection.d.ts.map +1 -0
- package/dist/kurot/collections/ArrayCollection.js +143 -0
- package/dist/kurot/collections/ArrayCollection.js.map +1 -0
- package/dist/kurot/collections/ICollection.d.ts +24 -0
- package/dist/kurot/collections/ICollection.d.ts.map +1 -0
- package/dist/kurot/collections/ICollection.js +2 -0
- package/dist/kurot/collections/ICollection.js.map +1 -0
- package/dist/kurot/collections/index.d.ts +3 -0
- package/dist/kurot/collections/index.d.ts.map +1 -0
- package/dist/kurot/collections/index.js +2 -0
- package/dist/kurot/collections/index.js.map +1 -0
- package/dist/kurot/components/Animation.d.ts +34 -0
- package/dist/kurot/components/Animation.d.ts.map +1 -0
- package/dist/kurot/components/Animation.js +100 -0
- package/dist/kurot/components/Animation.js.map +1 -0
- package/dist/kurot/components/Button.d.ts +61 -0
- package/dist/kurot/components/Button.d.ts.map +1 -0
- package/dist/kurot/components/Button.js +176 -0
- package/dist/kurot/components/Button.js.map +1 -0
- package/dist/kurot/components/CheckBox.d.ts +11 -0
- package/dist/kurot/components/CheckBox.d.ts.map +1 -0
- package/dist/kurot/components/CheckBox.js +13 -0
- package/dist/kurot/components/CheckBox.js.map +1 -0
- package/dist/kurot/components/ComboBox.d.ts +93 -0
- package/dist/kurot/components/ComboBox.d.ts.map +1 -0
- package/dist/kurot/components/ComboBox.js +307 -0
- package/dist/kurot/components/ComboBox.js.map +1 -0
- package/dist/kurot/components/Component.d.ts +203 -0
- package/dist/kurot/components/Component.d.ts.map +1 -0
- package/dist/kurot/components/Component.js +522 -0
- package/dist/kurot/components/Component.js.map +1 -0
- package/dist/kurot/components/DataGroup.d.ts +90 -0
- package/dist/kurot/components/DataGroup.d.ts.map +1 -0
- package/dist/kurot/components/DataGroup.js +483 -0
- package/dist/kurot/components/DataGroup.js.map +1 -0
- package/dist/kurot/components/EditableText.d.ts +44 -0
- package/dist/kurot/components/EditableText.d.ts.map +1 -0
- package/dist/kurot/components/EditableText.js +126 -0
- package/dist/kurot/components/EditableText.js.map +1 -0
- package/dist/kurot/components/Group.d.ts +133 -0
- package/dist/kurot/components/Group.d.ts.map +1 -0
- package/dist/kurot/components/Group.js +454 -0
- package/dist/kurot/components/Group.js.map +1 -0
- package/dist/kurot/components/HScrollBar.d.ts +13 -0
- package/dist/kurot/components/HScrollBar.d.ts.map +1 -0
- package/dist/kurot/components/HScrollBar.js +55 -0
- package/dist/kurot/components/HScrollBar.js.map +1 -0
- package/dist/kurot/components/HSlider.d.ts +17 -0
- package/dist/kurot/components/HSlider.d.ts.map +1 -0
- package/dist/kurot/components/HSlider.js +48 -0
- package/dist/kurot/components/HSlider.js.map +1 -0
- package/dist/kurot/components/Image.d.ts +35 -0
- package/dist/kurot/components/Image.d.ts.map +1 -0
- package/dist/kurot/components/Image.js +141 -0
- package/dist/kurot/components/Image.js.map +1 -0
- package/dist/kurot/components/ItemRenderer.d.ts +42 -0
- package/dist/kurot/components/ItemRenderer.d.ts.map +1 -0
- package/dist/kurot/components/ItemRenderer.js +117 -0
- package/dist/kurot/components/ItemRenderer.js.map +1 -0
- package/dist/kurot/components/Label.d.ts +49 -0
- package/dist/kurot/components/Label.d.ts.map +1 -0
- package/dist/kurot/components/Label.js +193 -0
- package/dist/kurot/components/Label.js.map +1 -0
- package/dist/kurot/components/List.d.ts +16 -0
- package/dist/kurot/components/List.d.ts.map +1 -0
- package/dist/kurot/components/List.js +34 -0
- package/dist/kurot/components/List.js.map +1 -0
- package/dist/kurot/components/ListBase.d.ts +61 -0
- package/dist/kurot/components/ListBase.d.ts.map +1 -0
- package/dist/kurot/components/ListBase.js +202 -0
- package/dist/kurot/components/ListBase.js.map +1 -0
- package/dist/kurot/components/Panel.d.ts +53 -0
- package/dist/kurot/components/Panel.d.ts.map +1 -0
- package/dist/kurot/components/Panel.js +145 -0
- package/dist/kurot/components/Panel.js.map +1 -0
- package/dist/kurot/components/ProgressBar.d.ts +48 -0
- package/dist/kurot/components/ProgressBar.d.ts.map +1 -0
- package/dist/kurot/components/ProgressBar.js +180 -0
- package/dist/kurot/components/ProgressBar.js.map +1 -0
- package/dist/kurot/components/RadioButton.d.ts +86 -0
- package/dist/kurot/components/RadioButton.d.ts.map +1 -0
- package/dist/kurot/components/RadioButton.js +246 -0
- package/dist/kurot/components/RadioButton.js.map +1 -0
- package/dist/kurot/components/Range.d.ts +41 -0
- package/dist/kurot/components/Range.d.ts.map +1 -0
- package/dist/kurot/components/Range.js +144 -0
- package/dist/kurot/components/Range.js.map +1 -0
- package/dist/kurot/components/Rect.d.ts +33 -0
- package/dist/kurot/components/Rect.d.ts.map +1 -0
- package/dist/kurot/components/Rect.js +125 -0
- package/dist/kurot/components/Rect.js.map +1 -0
- package/dist/kurot/components/ScrollBarBase.d.ts +27 -0
- package/dist/kurot/components/ScrollBarBase.d.ts.map +1 -0
- package/dist/kurot/components/ScrollBarBase.js +50 -0
- package/dist/kurot/components/ScrollBarBase.js.map +1 -0
- package/dist/kurot/components/Scroller.d.ts +82 -0
- package/dist/kurot/components/Scroller.d.ts.map +1 -0
- package/dist/kurot/components/Scroller.js +416 -0
- package/dist/kurot/components/Scroller.js.map +1 -0
- package/dist/kurot/components/Skin.d.ts +64 -0
- package/dist/kurot/components/Skin.d.ts.map +1 -0
- package/dist/kurot/components/Skin.js +136 -0
- package/dist/kurot/components/Skin.js.map +1 -0
- package/dist/kurot/components/SliderBase.d.ts +60 -0
- package/dist/kurot/components/SliderBase.d.ts.map +1 -0
- package/dist/kurot/components/SliderBase.js +197 -0
- package/dist/kurot/components/SliderBase.js.map +1 -0
- package/dist/kurot/components/TabBar.d.ts +29 -0
- package/dist/kurot/components/TabBar.d.ts.map +1 -0
- package/dist/kurot/components/TabBar.js +92 -0
- package/dist/kurot/components/TabBar.js.map +1 -0
- package/dist/kurot/components/TextInput.d.ts +49 -0
- package/dist/kurot/components/TextInput.d.ts.map +1 -0
- package/dist/kurot/components/TextInput.js +157 -0
- package/dist/kurot/components/TextInput.js.map +1 -0
- package/dist/kurot/components/ToggleButton.d.ts +11 -0
- package/dist/kurot/components/ToggleButton.d.ts.map +1 -0
- package/dist/kurot/components/ToggleButton.js +14 -0
- package/dist/kurot/components/ToggleButton.js.map +1 -0
- package/dist/kurot/components/ToggleSwitch.d.ts +10 -0
- package/dist/kurot/components/ToggleSwitch.d.ts.map +1 -0
- package/dist/kurot/components/ToggleSwitch.js +10 -0
- package/dist/kurot/components/ToggleSwitch.js.map +1 -0
- package/dist/kurot/components/TouchScroll.d.ts +38 -0
- package/dist/kurot/components/TouchScroll.d.ts.map +1 -0
- package/dist/kurot/components/TouchScroll.js +133 -0
- package/dist/kurot/components/TouchScroll.js.map +1 -0
- package/dist/kurot/components/UILayer.d.ts +14 -0
- package/dist/kurot/components/UILayer.d.ts.map +1 -0
- package/dist/kurot/components/UILayer.js +38 -0
- package/dist/kurot/components/UILayer.js.map +1 -0
- package/dist/kurot/components/VScrollBar.d.ts +13 -0
- package/dist/kurot/components/VScrollBar.d.ts.map +1 -0
- package/dist/kurot/components/VScrollBar.js +55 -0
- package/dist/kurot/components/VScrollBar.js.map +1 -0
- package/dist/kurot/components/VSlider.d.ts +17 -0
- package/dist/kurot/components/VSlider.d.ts.map +1 -0
- package/dist/kurot/components/VSlider.js +49 -0
- package/dist/kurot/components/VSlider.js.map +1 -0
- package/dist/kurot/components/ViewStack.d.ts +42 -0
- package/dist/kurot/components/ViewStack.d.ts.map +1 -0
- package/dist/kurot/components/ViewStack.js +160 -0
- package/dist/kurot/components/ViewStack.js.map +1 -0
- package/dist/kurot/components/index.d.ts +34 -0
- package/dist/kurot/components/index.d.ts.map +1 -0
- package/dist/kurot/components/index.js +34 -0
- package/dist/kurot/components/index.js.map +1 -0
- package/dist/kurot/core/AssetAdapterRegistry.d.ts +4 -0
- package/dist/kurot/core/AssetAdapterRegistry.d.ts.map +1 -0
- package/dist/kurot/core/AssetAdapterRegistry.js +9 -0
- package/dist/kurot/core/AssetAdapterRegistry.js.map +1 -0
- package/dist/kurot/core/DefaultAssetAdapter.d.ts +10 -0
- package/dist/kurot/core/DefaultAssetAdapter.d.ts.map +1 -0
- package/dist/kurot/core/DefaultAssetAdapter.js +22 -0
- package/dist/kurot/core/DefaultAssetAdapter.js.map +1 -0
- package/dist/kurot/core/DefaultThemeAdapter.d.ts +8 -0
- package/dist/kurot/core/DefaultThemeAdapter.d.ts.map +1 -0
- package/dist/kurot/core/DefaultThemeAdapter.js +27 -0
- package/dist/kurot/core/DefaultThemeAdapter.js.map +1 -0
- package/dist/kurot/core/Direction.d.ts +10 -0
- package/dist/kurot/core/Direction.d.ts.map +1 -0
- package/dist/kurot/core/Direction.js +10 -0
- package/dist/kurot/core/Direction.js.map +1 -0
- package/dist/kurot/core/IAssetAdapter.d.ts +15 -0
- package/dist/kurot/core/IAssetAdapter.d.ts.map +1 -0
- package/dist/kurot/core/IAssetAdapter.js +2 -0
- package/dist/kurot/core/IAssetAdapter.js.map +1 -0
- package/dist/kurot/core/IDisplayText.d.ts +12 -0
- package/dist/kurot/core/IDisplayText.d.ts.map +1 -0
- package/dist/kurot/core/IDisplayText.js +2 -0
- package/dist/kurot/core/IDisplayText.js.map +1 -0
- package/dist/kurot/core/IItemRenderer.d.ts +19 -0
- package/dist/kurot/core/IItemRenderer.d.ts.map +1 -0
- package/dist/kurot/core/IItemRenderer.js +2 -0
- package/dist/kurot/core/IItemRenderer.js.map +1 -0
- package/dist/kurot/core/IThemeAdapter.d.ts +14 -0
- package/dist/kurot/core/IThemeAdapter.d.ts.map +1 -0
- package/dist/kurot/core/IThemeAdapter.js +2 -0
- package/dist/kurot/core/IThemeAdapter.js.map +1 -0
- package/dist/kurot/core/IUIComponent.d.ts +63 -0
- package/dist/kurot/core/IUIComponent.d.ts.map +1 -0
- package/dist/kurot/core/IUIComponent.js +2 -0
- package/dist/kurot/core/IUIComponent.js.map +1 -0
- package/dist/kurot/core/IViewport.d.ts +12 -0
- package/dist/kurot/core/IViewport.d.ts.map +1 -0
- package/dist/kurot/core/IViewport.js +2 -0
- package/dist/kurot/core/IViewport.js.map +1 -0
- package/dist/kurot/core/ScrollPolicy.d.ts +9 -0
- package/dist/kurot/core/ScrollPolicy.d.ts.map +1 -0
- package/dist/kurot/core/ScrollPolicy.js +9 -0
- package/dist/kurot/core/ScrollPolicy.js.map +1 -0
- package/dist/kurot/core/Theme.d.ts +53 -0
- package/dist/kurot/core/Theme.d.ts.map +1 -0
- package/dist/kurot/core/Theme.js +169 -0
- package/dist/kurot/core/Theme.js.map +1 -0
- package/dist/kurot/core/UIComponent.d.ts +2 -0
- package/dist/kurot/core/UIComponent.d.ts.map +1 -0
- package/dist/kurot/core/UIComponent.js +4 -0
- package/dist/kurot/core/UIComponent.js.map +1 -0
- package/dist/kurot/core/UIState.d.ts +84 -0
- package/dist/kurot/core/UIState.d.ts.map +1 -0
- package/dist/kurot/core/UIState.js +512 -0
- package/dist/kurot/core/UIState.js.map +1 -0
- package/dist/kurot/core/Validator.d.ts +46 -0
- package/dist/kurot/core/Validator.d.ts.map +1 -0
- package/dist/kurot/core/Validator.js +368 -0
- package/dist/kurot/core/Validator.js.map +1 -0
- package/dist/kurot/core/index.d.ts +17 -0
- package/dist/kurot/core/index.d.ts.map +1 -0
- package/dist/kurot/core/index.js +10 -0
- package/dist/kurot/core/index.js.map +1 -0
- package/dist/kurot/events/CollectionEvent.d.ts +22 -0
- package/dist/kurot/events/CollectionEvent.d.ts.map +1 -0
- package/dist/kurot/events/CollectionEvent.js +37 -0
- package/dist/kurot/events/CollectionEvent.js.map +1 -0
- package/dist/kurot/events/ItemTapEvent.d.ts +11 -0
- package/dist/kurot/events/ItemTapEvent.d.ts.map +1 -0
- package/dist/kurot/events/ItemTapEvent.js +24 -0
- package/dist/kurot/events/ItemTapEvent.js.map +1 -0
- package/dist/kurot/events/PropertyEvent.d.ts +8 -0
- package/dist/kurot/events/PropertyEvent.d.ts.map +1 -0
- package/dist/kurot/events/PropertyEvent.js +20 -0
- package/dist/kurot/events/PropertyEvent.js.map +1 -0
- package/dist/kurot/events/ScrollerThrowEvent.d.ts +17 -0
- package/dist/kurot/events/ScrollerThrowEvent.d.ts.map +1 -0
- package/dist/kurot/events/ScrollerThrowEvent.js +22 -0
- package/dist/kurot/events/ScrollerThrowEvent.js.map +1 -0
- package/dist/kurot/events/UIEvent.d.ts +29 -0
- package/dist/kurot/events/UIEvent.d.ts.map +1 -0
- package/dist/kurot/events/UIEvent.js +39 -0
- package/dist/kurot/events/UIEvent.js.map +1 -0
- package/dist/kurot/events/index.d.ts +6 -0
- package/dist/kurot/events/index.d.ts.map +1 -0
- package/dist/kurot/events/index.js +6 -0
- package/dist/kurot/events/index.js.map +1 -0
- package/dist/kurot/layouts/BasicLayout.d.ts +13 -0
- package/dist/kurot/layouts/BasicLayout.d.ts.map +1 -0
- package/dist/kurot/layouts/BasicLayout.js +146 -0
- package/dist/kurot/layouts/BasicLayout.js.map +1 -0
- package/dist/kurot/layouts/ColumnAlign.d.ts +9 -0
- package/dist/kurot/layouts/ColumnAlign.d.ts.map +1 -0
- package/dist/kurot/layouts/ColumnAlign.js +9 -0
- package/dist/kurot/layouts/ColumnAlign.js.map +1 -0
- package/dist/kurot/layouts/HorizontalLayout.d.ts +23 -0
- package/dist/kurot/layouts/HorizontalLayout.d.ts.map +1 -0
- package/dist/kurot/layouts/HorizontalLayout.js +405 -0
- package/dist/kurot/layouts/HorizontalLayout.js.map +1 -0
- package/dist/kurot/layouts/ILayoutTarget.d.ts +25 -0
- package/dist/kurot/layouts/ILayoutTarget.d.ts.map +1 -0
- package/dist/kurot/layouts/ILayoutTarget.js +2 -0
- package/dist/kurot/layouts/ILayoutTarget.js.map +1 -0
- package/dist/kurot/layouts/JustifyAlign.d.ts +8 -0
- package/dist/kurot/layouts/JustifyAlign.d.ts.map +1 -0
- package/dist/kurot/layouts/JustifyAlign.js +8 -0
- package/dist/kurot/layouts/JustifyAlign.js.map +1 -0
- package/dist/kurot/layouts/LayoutBase.d.ts +23 -0
- package/dist/kurot/layouts/LayoutBase.d.ts.map +1 -0
- package/dist/kurot/layouts/LayoutBase.js +45 -0
- package/dist/kurot/layouts/LayoutBase.js.map +1 -0
- package/dist/kurot/layouts/LinearLayoutBase.d.ts +70 -0
- package/dist/kurot/layouts/LinearLayoutBase.d.ts.map +1 -0
- package/dist/kurot/layouts/LinearLayoutBase.js +246 -0
- package/dist/kurot/layouts/LinearLayoutBase.js.map +1 -0
- package/dist/kurot/layouts/RowAlign.d.ts +9 -0
- package/dist/kurot/layouts/RowAlign.d.ts.map +1 -0
- package/dist/kurot/layouts/RowAlign.js +9 -0
- package/dist/kurot/layouts/RowAlign.js.map +1 -0
- package/dist/kurot/layouts/TileLayout.d.ts +79 -0
- package/dist/kurot/layouts/TileLayout.d.ts.map +1 -0
- package/dist/kurot/layouts/TileLayout.js +577 -0
- package/dist/kurot/layouts/TileLayout.js.map +1 -0
- package/dist/kurot/layouts/TileOrientation.d.ts +8 -0
- package/dist/kurot/layouts/TileOrientation.d.ts.map +1 -0
- package/dist/kurot/layouts/TileOrientation.js +8 -0
- package/dist/kurot/layouts/TileOrientation.js.map +1 -0
- package/dist/kurot/layouts/VerticalLayout.d.ts +23 -0
- package/dist/kurot/layouts/VerticalLayout.d.ts.map +1 -0
- package/dist/kurot/layouts/VerticalLayout.js +406 -0
- package/dist/kurot/layouts/VerticalLayout.js.map +1 -0
- package/dist/kurot/layouts/index.d.ts +12 -0
- package/dist/kurot/layouts/index.d.ts.map +1 -0
- package/dist/kurot/layouts/index.js +11 -0
- package/dist/kurot/layouts/index.js.map +1 -0
- package/dist/kurot/states/AddItems.d.ts +17 -0
- package/dist/kurot/states/AddItems.d.ts.map +1 -0
- package/dist/kurot/states/AddItems.js +42 -0
- package/dist/kurot/states/AddItems.js.map +1 -0
- package/dist/kurot/states/IOverride.d.ts +12 -0
- package/dist/kurot/states/IOverride.d.ts.map +1 -0
- package/dist/kurot/states/IOverride.js +2 -0
- package/dist/kurot/states/IOverride.js.map +1 -0
- package/dist/kurot/states/SetProperty.d.ts +19 -0
- package/dist/kurot/states/SetProperty.d.ts.map +1 -0
- package/dist/kurot/states/SetProperty.js +50 -0
- package/dist/kurot/states/SetProperty.js.map +1 -0
- package/dist/kurot/states/SetStateProperty.d.ts +17 -0
- package/dist/kurot/states/SetStateProperty.d.ts.map +1 -0
- package/dist/kurot/states/SetStateProperty.js +35 -0
- package/dist/kurot/states/SetStateProperty.js.map +1 -0
- package/dist/kurot/states/State.d.ts +14 -0
- package/dist/kurot/states/State.d.ts.map +1 -0
- package/dist/kurot/states/State.js +18 -0
- package/dist/kurot/states/State.js.map +1 -0
- package/dist/kurot/states/index.d.ts +6 -0
- package/dist/kurot/states/index.d.ts.map +1 -0
- package/dist/kurot/states/index.js +5 -0
- package/dist/kurot/states/index.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# @kurot/ui
|
|
2
|
+
|
|
3
|
+
UI component framework for [@kurot/core](https://github.com/kurot-engine/kurot/tree/main/packages/core). Migrated from Egret EUI, rewritten in modern TypeScript with clean class inheritance — no namespace hacks, no prototype manipulation.
|
|
4
|
+
|
|
5
|
+
> **Stable (1.1.7).** Requires `@kurot/core@^1.0.12`. Targets ES2022 + evergreen browsers, same as core.
|
|
6
|
+
|
|
7
|
+
For the full list of changes in this release, see [CHANGELOG.md](./CHANGELOG.md).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @kurot/ui @kurot/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`@kurot/ui` declares `@kurot/core` as a peer dependency. Install both packages explicitly so the application controls the resolved core version.
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { Group, Label, Button, Rect, BasicLayout } from '@kurot/ui';
|
|
21
|
+
|
|
22
|
+
const group = new Group();
|
|
23
|
+
group.layout = new BasicLayout();
|
|
24
|
+
group.width = 400;
|
|
25
|
+
group.height = 300;
|
|
26
|
+
|
|
27
|
+
const btn = new Button();
|
|
28
|
+
btn.label = 'Click Me';
|
|
29
|
+
btn.width = 120;
|
|
30
|
+
btn.height = 36;
|
|
31
|
+
btn.left = 20;
|
|
32
|
+
btn.top = 20;
|
|
33
|
+
|
|
34
|
+
// Manual skin: transparent hit area + visual children
|
|
35
|
+
btn.graphics.beginFill(0x000000, 0.01);
|
|
36
|
+
btn.graphics.drawRect(0, 0, 120, 36);
|
|
37
|
+
btn.graphics.endFill();
|
|
38
|
+
|
|
39
|
+
const bg = new Rect(120, 36, 0x6c5ce7);
|
|
40
|
+
btn.addChild(bg);
|
|
41
|
+
|
|
42
|
+
const lbl = new Label('Click Me');
|
|
43
|
+
lbl.width = 120;
|
|
44
|
+
lbl.height = 36;
|
|
45
|
+
lbl.textAlign = 'center';
|
|
46
|
+
lbl.verticalAlign = 'middle';
|
|
47
|
+
lbl.textColor = 0xffffff;
|
|
48
|
+
btn.labelDisplay = lbl;
|
|
49
|
+
btn.addChild(lbl);
|
|
50
|
+
|
|
51
|
+
group.addChild(btn);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Architecture
|
|
55
|
+
|
|
56
|
+
Every UI component holds a `UIState` instance that manages the layout lifecycle. `Group` and `Component` delegate all layout calls to it — no mixin, no prototype copying.
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
Group / Component
|
|
60
|
+
└── ui: UIState ← layout state + invalidation logic
|
|
61
|
+
└── owner: IUIOwner ← back-reference to the DisplayObject
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Layout cycle
|
|
65
|
+
|
|
66
|
+
Property changes are batched and applied on the next animation frame:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
invalidateProperties / invalidateSize / invalidateDisplayList
|
|
70
|
+
→ Validator queues the component
|
|
71
|
+
→ requestAnimationFrame tick
|
|
72
|
+
→ validateProperties (shallow → deep, commitProperties)
|
|
73
|
+
→ validateSize (deep → shallow, measure)
|
|
74
|
+
→ validateDisplayList (shallow → deep, updateDisplayList)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Skin system
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { Skin, State, SetProperty } from '@kurot/ui';
|
|
81
|
+
|
|
82
|
+
class MyButtonSkin extends Skin {
|
|
83
|
+
constructor() {
|
|
84
|
+
super();
|
|
85
|
+
this.skinParts = ['labelDisplay'];
|
|
86
|
+
this.states = [
|
|
87
|
+
new State('up'),
|
|
88
|
+
new State('down', [new SetProperty('bg', 'fillColor', 0x5a4bd1)]),
|
|
89
|
+
new State('disabled', [new SetProperty('bg', 'fillColor', 0x636e72)]),
|
|
90
|
+
];
|
|
91
|
+
// build visual children...
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
btn.skinName = MyButtonSkin;
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Components
|
|
99
|
+
|
|
100
|
+
### Basic Controls
|
|
101
|
+
|
|
102
|
+
| Component | Description |
|
|
103
|
+
| -------------- | --------------------------------------------------------------------------- |
|
|
104
|
+
| `Label` | Text display. Wraps `TextField` in the UI lifecycle. |
|
|
105
|
+
| `Button` | Tappable button with `up`/`down`/`disabled` states and `labelDisplay` part. |
|
|
106
|
+
| `CheckBox` | Toggle button. Dispatches `Event.CHANGE` on selection change. |
|
|
107
|
+
| `RadioButton` | Mutually exclusive toggle. Use `groupName` to link buttons. |
|
|
108
|
+
| `ToggleButton` | Base for toggle-style buttons. |
|
|
109
|
+
| `ToggleSwitch` | Binary on/off switch (visual variant of `ToggleButton`). |
|
|
110
|
+
| `ProgressBar` | Value indicator. Inject `thumb` (a `Component`) as the fill part. |
|
|
111
|
+
| `HSlider` | Horizontal slider. Inject `thumb` and `track` skin parts. |
|
|
112
|
+
| `VSlider` | Vertical slider. Inject `thumb` and `track` skin parts. |
|
|
113
|
+
| `Rect` | Filled/stroked rectangle. Supports `fillColor`, `strokeColor`, `fillAlpha`. |
|
|
114
|
+
| `Image` | Bitmap display. Supports URL string or `Texture`, `scale9Grid`, `fillMode`. |
|
|
115
|
+
|
|
116
|
+
### Text Input
|
|
117
|
+
|
|
118
|
+
| Component | Description |
|
|
119
|
+
| -------------- | -------------------------------------------------------------------------- |
|
|
120
|
+
| `EditableText` | Editable text field with `prompt` (placeholder) and `promptColor` support. |
|
|
121
|
+
| `TextInput` | Skinnable input component. Skin parts: `textDisplay`, `promptDisplay`. |
|
|
122
|
+
|
|
123
|
+
### Containers
|
|
124
|
+
|
|
125
|
+
| Component | Description |
|
|
126
|
+
| ----------- | -------------------------------------------------------------------------------------------- |
|
|
127
|
+
| `Group` | Base container. Holds a `LayoutBase` for child positioning. Implements `IViewport`. |
|
|
128
|
+
| `Panel` | Container with title bar. Skin parts: `titleDisplay`, `closeButton`, `moveArea` (draggable). |
|
|
129
|
+
| `ViewStack` | Shows one child at a time. Set `selectedIndex` or `selectedChild` to switch. |
|
|
130
|
+
| `Scroller` | Touch-scrolling wrapper for any `IViewport`. Supports bounce, scroll bars, scroll policies. |
|
|
131
|
+
| `UILayer` | Full-screen overlay container. |
|
|
132
|
+
|
|
133
|
+
### Data-Driven
|
|
134
|
+
|
|
135
|
+
| Component | Description |
|
|
136
|
+
| -------------- | ------------------------------------------------------------------------------------------- |
|
|
137
|
+
| `DataGroup` | Renders a data collection using item renderers. Supports virtual layout for large datasets. |
|
|
138
|
+
| `List` | `DataGroup` with tap-to-select. Dispatches `ItemTapEvent.ITEM_TAP`. |
|
|
139
|
+
| `TabBar` | Horizontal tab strip driven by `dataProvider`. Dispatches `ItemTapEvent.ITEM_TAP`. |
|
|
140
|
+
| `ComboBox` | Drop-down selector. Tapping toggles a `list` skin part; dispatches `Event.CHANGE` on selection. |
|
|
141
|
+
| `ItemRenderer` | Base class for custom item renderers. Override `dataChanged()` to update visuals. |
|
|
142
|
+
|
|
143
|
+
### Scroll Bars
|
|
144
|
+
|
|
145
|
+
| Component | Description |
|
|
146
|
+
| ------------ | --------------------------------------------------------- |
|
|
147
|
+
| `HScrollBar` | Horizontal scroll bar. Bind to a viewport via `viewport`. |
|
|
148
|
+
| `VScrollBar` | Vertical scroll bar. Bind to a viewport via `viewport`. |
|
|
149
|
+
|
|
150
|
+
## Layouts
|
|
151
|
+
|
|
152
|
+
| Layout | Description |
|
|
153
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
154
|
+
| `BasicLayout` | Positions children using `left`/`right`/`top`/`bottom`/`horizontalCenter`/`verticalCenter` and `percentWidth`/`percentHeight`. |
|
|
155
|
+
| `VerticalLayout` | Linear vertical arrangement with gap, padding, alignment, percent sizes, and virtual layout support. |
|
|
156
|
+
| `HorizontalLayout` | Linear horizontal arrangement with gap, padding, alignment, percent sizes, and virtual layout support. |
|
|
157
|
+
| `TileLayout` | Grid arrangement with configurable orientation, column/row counts, justification, and virtual layout support. |
|
|
158
|
+
|
|
159
|
+
## Data Collections
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import { ArrayCollection } from '@kurot/ui';
|
|
163
|
+
|
|
164
|
+
const data = new ArrayCollection(['Apple', 'Banana', 'Cherry']);
|
|
165
|
+
|
|
166
|
+
data.addItem('Durian');
|
|
167
|
+
data.addItemAt('Elderberry', 1);
|
|
168
|
+
data.removeItemAt(0);
|
|
169
|
+
data.replaceItemAt('Fig', 0);
|
|
170
|
+
data.sortOn('name'); // sort by field
|
|
171
|
+
data.sort((a, b) => (a > b ? 1 : -1)); // custom sort
|
|
172
|
+
data.filterFunction(item => item !== 'Fig');
|
|
173
|
+
data.refresh(); // notify view after manual source changes
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Virtual Layout
|
|
177
|
+
|
|
178
|
+
For large datasets, enable virtual layout so only visible renderers are created:
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
import { List, ItemRenderer, ArrayCollection, Label } from '@kurot/ui';
|
|
182
|
+
|
|
183
|
+
class MyRenderer extends ItemRenderer {
|
|
184
|
+
private _label: Label;
|
|
185
|
+
constructor() {
|
|
186
|
+
super();
|
|
187
|
+
this._label = new Label('');
|
|
188
|
+
this._label.width = 200;
|
|
189
|
+
this._label.height = 36;
|
|
190
|
+
this.addChild(this._label);
|
|
191
|
+
}
|
|
192
|
+
protected override dataChanged(): void {
|
|
193
|
+
this._label.text = String(this.data ?? '');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const list = new List();
|
|
198
|
+
list.dataProvider = new ArrayCollection(largeArray);
|
|
199
|
+
list.itemRenderer = MyRenderer;
|
|
200
|
+
list.useVirtualLayout = true; // only visible renderers are instantiated
|
|
201
|
+
list.width = 200;
|
|
202
|
+
list.height = 300; // visible window height
|
|
203
|
+
list.scrollEnabled = true;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Constraint Properties
|
|
207
|
+
|
|
208
|
+
All UI components support these layout constraint properties:
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
component.left = 20;
|
|
212
|
+
component.right = 20;
|
|
213
|
+
component.top = 10;
|
|
214
|
+
component.bottom = 10;
|
|
215
|
+
component.horizontalCenter = 0;
|
|
216
|
+
component.verticalCenter = 0;
|
|
217
|
+
component.percentWidth = 50;
|
|
218
|
+
component.percentHeight = 100;
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## View States
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { State, SetProperty, AddItems } from '@kurot/ui';
|
|
225
|
+
|
|
226
|
+
class MyButtonSkin extends Skin {
|
|
227
|
+
states = [
|
|
228
|
+
new State('up'),
|
|
229
|
+
new State('down', [new SetProperty('bg', 'fillColor', 0x5a4bd1)]),
|
|
230
|
+
new State('disabled', [
|
|
231
|
+
new SetProperty('bg', 'fillColor', 0x636e72),
|
|
232
|
+
new SetProperty('lbl', 'textColor', 0xb2bec3),
|
|
233
|
+
]),
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Events
|
|
239
|
+
|
|
240
|
+
| Event | Dispatched by | Description |
|
|
241
|
+
| ----------------------------------- | ------------------------------- | ---------------------------------------------------- |
|
|
242
|
+
| `Event.CHANGE` | `List`, `TabBar`, `ComboBox`, `CheckBox`, `RadioButton`, `Range` | Selection or value changed (user interaction only for List/TabBar) |
|
|
243
|
+
| `ItemTapEvent.ITEM_TAP` | `List`, `TabBar` | Item tapped. Has `item`, `itemIndex`, `itemRenderer` |
|
|
244
|
+
| `CollectionEvent.COLLECTION_CHANGE` | `ArrayCollection` | Data added, removed, replaced, reset |
|
|
245
|
+
| `UIEvent.CLOSING` | `Panel` | Close button tapped (cancelable) |
|
|
246
|
+
| `UIEvent.CREATION_COMPLETE` | Any `Component` | First `createChildren` completed |
|
|
247
|
+
|
|
248
|
+
## Differences from Egret EUI
|
|
249
|
+
|
|
250
|
+
| | Egret EUI | @kurot/ui |
|
|
251
|
+
| -------------- | --------------------------- | ------------------------------------ |
|
|
252
|
+
| Namespace | `eui.*` global | ES Module named exports |
|
|
253
|
+
| Component base | `namespace` + `mixin` | Standard class inheritance |
|
|
254
|
+
| Layout state | Prototype-injected | `UIState` delegation |
|
|
255
|
+
| EXML runtime | Built-in parser | Compile-time only (`@kurot/cli`) |
|
|
256
|
+
| `thisObject` | Required in event listeners | Not needed — use arrow functions |
|
|
257
|
+
| Virtual layout | Default on | Opt-in via `useVirtualLayout = true` |
|
|
258
|
+
| i18n | Built-in | Not supported |
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './kurot/core/index.js';
|
|
2
|
+
export * from './kurot/layouts/index.js';
|
|
3
|
+
export * from './kurot/components/index.js';
|
|
4
|
+
export * from './kurot/events/index.js';
|
|
5
|
+
export * from './kurot/states/index.js';
|
|
6
|
+
export * from './kurot/collections/index.js';
|
|
7
|
+
export * from './kurot/binding/index.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './kurot/core/index.js';
|
|
2
|
+
export * from './kurot/layouts/index.js';
|
|
3
|
+
export * from './kurot/components/index.js';
|
|
4
|
+
export * from './kurot/events/index.js';
|
|
5
|
+
export * from './kurot/states/index.js';
|
|
6
|
+
export * from './kurot/collections/index.js';
|
|
7
|
+
export * from './kurot/binding/index.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Watcher } from './Watcher.js';
|
|
2
|
+
/**
|
|
3
|
+
* Binding — static utility class for data binding.
|
|
4
|
+
*
|
|
5
|
+
* - `bindProperty(host, chain, target, prop)` — binds `host.chain` → `target.prop`
|
|
6
|
+
* - `bindHandler(host, chain, handler, thisObject)` — calls `handler(value)` on change
|
|
7
|
+
* - `bindProperties(host, templates, chainIndex, target, prop)` — template-string binding
|
|
8
|
+
*/
|
|
9
|
+
export declare class Binding {
|
|
10
|
+
/**
|
|
11
|
+
* Binds a property chain on `host` to a target property.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* Binding.bindProperty(user, ['name'], label, 'text');
|
|
15
|
+
* // label.text === user.name; auto-updates when user dispatches PropertyChange
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
static bindProperty(host: unknown, chain: string[], target: unknown, prop: string): Watcher | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Binds a property chain on `host` to a handler function.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* Binding.bindHandler(user, ['name'], (v) => console.log(v), null);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
static bindHandler(host: unknown, chain: string[], handler: (value: unknown) => void, thisObject: unknown): Watcher | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Template-string binding used by EXML compiler.
|
|
29
|
+
*
|
|
30
|
+
* `templates` is a mixed array of literal strings and `Watcher` instances.
|
|
31
|
+
* `chainIndex` marks which entries are dynamic (property chains).
|
|
32
|
+
*
|
|
33
|
+
* The result is the string concatenation of all template values, written
|
|
34
|
+
* to `target[prop]`.
|
|
35
|
+
*/
|
|
36
|
+
static bindProperties(host: unknown, templates: unknown[], chainIndex: number[], target: unknown, prop: string): Watcher | undefined;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=Binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Binding.d.ts","sourceRoot":"","sources":["../../../src/kurot/binding/Binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;;;;;GAMG;AACH,qBAAa,OAAO;IACnB;;;;;;;OAOG;WACW,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAY9G;;;;;;OAMG;WACW,WAAW,CACxB,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,EACjC,UAAU,EAAE,OAAO,GACjB,OAAO,GAAG,SAAS;IAQtB;;;;;;;;OAQG;WACW,cAAc,CAC3B,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,OAAO,EAAE,EACpB,UAAU,EAAE,MAAM,EAAE,EACpB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,GACV,OAAO,GAAG,SAAS;CAgCtB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Watcher } from './Watcher.js';
|
|
2
|
+
/**
|
|
3
|
+
* Binding — static utility class for data binding.
|
|
4
|
+
*
|
|
5
|
+
* - `bindProperty(host, chain, target, prop)` — binds `host.chain` → `target.prop`
|
|
6
|
+
* - `bindHandler(host, chain, handler, thisObject)` — calls `handler(value)` on change
|
|
7
|
+
* - `bindProperties(host, templates, chainIndex, target, prop)` — template-string binding
|
|
8
|
+
*/
|
|
9
|
+
export class Binding {
|
|
10
|
+
/**
|
|
11
|
+
* Binds a property chain on `host` to a target property.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* Binding.bindProperty(user, ['name'], label, 'text');
|
|
15
|
+
* // label.text === user.name; auto-updates when user dispatches PropertyChange
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
static bindProperty(host, chain, target, prop) {
|
|
19
|
+
const watcher = Watcher.watch(host, chain, undefined, undefined);
|
|
20
|
+
if (watcher) {
|
|
21
|
+
const assign = (value) => {
|
|
22
|
+
target[prop] = value;
|
|
23
|
+
};
|
|
24
|
+
watcher.setHandler(assign, undefined);
|
|
25
|
+
assign(watcher.getValue());
|
|
26
|
+
}
|
|
27
|
+
return watcher;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Binds a property chain on `host` to a handler function.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* Binding.bindHandler(user, ['name'], (v) => console.log(v), null);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
static bindHandler(host, chain, handler, thisObject) {
|
|
37
|
+
const watcher = Watcher.watch(host, chain, handler, thisObject);
|
|
38
|
+
if (watcher) {
|
|
39
|
+
handler.call(thisObject, watcher.getValue());
|
|
40
|
+
}
|
|
41
|
+
return watcher;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Template-string binding used by EXML compiler.
|
|
45
|
+
*
|
|
46
|
+
* `templates` is a mixed array of literal strings and `Watcher` instances.
|
|
47
|
+
* `chainIndex` marks which entries are dynamic (property chains).
|
|
48
|
+
*
|
|
49
|
+
* The result is the string concatenation of all template values, written
|
|
50
|
+
* to `target[prop]`.
|
|
51
|
+
*/
|
|
52
|
+
static bindProperties(host, templates, chainIndex, target, prop) {
|
|
53
|
+
if (templates.length === 1 && chainIndex.length === 1) {
|
|
54
|
+
return Binding.bindProperty(host, templates[0].split('.'), target, prop);
|
|
55
|
+
}
|
|
56
|
+
const assign = () => {
|
|
57
|
+
target[prop] = _joinValues(templates);
|
|
58
|
+
};
|
|
59
|
+
let lastWatcher;
|
|
60
|
+
for (const index of chainIndex) {
|
|
61
|
+
const element = templates[index];
|
|
62
|
+
let watcher;
|
|
63
|
+
if (typeof element === 'string') {
|
|
64
|
+
watcher = Watcher.watch(host, element.split('.'), undefined, undefined);
|
|
65
|
+
}
|
|
66
|
+
else if (element instanceof Watcher) {
|
|
67
|
+
watcher = element;
|
|
68
|
+
watcher.reset(host);
|
|
69
|
+
}
|
|
70
|
+
if (watcher) {
|
|
71
|
+
templates[index] = watcher;
|
|
72
|
+
watcher.setHandler(assign, undefined);
|
|
73
|
+
lastWatcher = watcher;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
assign();
|
|
77
|
+
return lastWatcher;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// ── Helpers ─────────────────────────────────────────────────────────
|
|
81
|
+
function _joinValues(templates) {
|
|
82
|
+
let value = '';
|
|
83
|
+
for (const item of templates) {
|
|
84
|
+
value += item instanceof Watcher ? String(item.getValue() ?? '') : String(item);
|
|
85
|
+
}
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=Binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Binding.js","sourceRoot":"","sources":["../../../src/kurot/binding/Binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;;;;;GAMG;AACH,MAAM,OAAO,OAAO;IACnB;;;;;;;OAOG;IACI,MAAM,CAAC,YAAY,CAAC,IAAa,EAAE,KAAe,EAAE,MAAe,EAAE,IAAY;QACvF,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,IAAoC,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QACjG,IAAI,OAAO,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;gBACtC,MAAkC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YAC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,CAAC,IAAoC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;YACzG,CAAC;iBAAM,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;gBACvC,OAAO,GAAG,OAAO,CAAC;gBAClB,OAAO,CAAC,KAAK,CAAC,IAAoC,CAAC,CAAC;YACrD,CAAC;YAED,IAAI,OAAO,EAAE,CAAC;gBACb,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;gBAC3B,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;gBAEtC,WAAW,GAAG,OAAO,CAAC;YACvB,CAAC;QACF,CAAC;QAED,MAAM,EAAE,CAAC;QACT,OAAO,WAAW,CAAC;IACpB,CAAC;CACD;AAED,uEAAuE;AAEvE,SAAS,WAAW,CAAC,SAAoB;IACxC,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC9B,KAAK,IAAI,IAAI,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { IEventDispatcher } from '@kurot/core';
|
|
2
|
+
/**
|
|
3
|
+
* An object that can both dispatch {@link PropertyEvent.PROPERTY_CHANGE} and be
|
|
4
|
+
* read by arbitrary property name (i.e. it is a record of named bindable values).
|
|
5
|
+
*
|
|
6
|
+
* This is the minimal contract a binding host must satisfy. In practice every
|
|
7
|
+
* host is an {@link EventDispatcher} subclass (Skin, Component, Group, …) whose
|
|
8
|
+
* own properties are mutated and then announced via
|
|
9
|
+
* {@link PropertyEvent.dispatchPropertyEvent}. The index signature models that
|
|
10
|
+
* dynamic access without forcing every host through `as unknown as Record<…>`.
|
|
11
|
+
*/
|
|
12
|
+
export type Bindable = IEventDispatcher & Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* Watcher monitors a property (or property chain) on a host object.
|
|
15
|
+
* When the property changes (via {@link PropertyEvent}), the registered
|
|
16
|
+
* handler is invoked with the new value.
|
|
17
|
+
*
|
|
18
|
+
* Create instances via the static {@link Watcher.watch} method — do not use the
|
|
19
|
+
* constructor directly.
|
|
20
|
+
*/
|
|
21
|
+
export declare class Watcher {
|
|
22
|
+
private _host?;
|
|
23
|
+
private readonly _property;
|
|
24
|
+
private _handler?;
|
|
25
|
+
private _thisObject;
|
|
26
|
+
private readonly _next?;
|
|
27
|
+
private _isExecuting;
|
|
28
|
+
constructor(property: string, handler: ((value: unknown) => void) | undefined, thisObject: unknown, next: Watcher | undefined);
|
|
29
|
+
/**
|
|
30
|
+
* Creates and starts a Watcher for a property chain.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* // watches host.a.b.c
|
|
34
|
+
* Watcher.watch(host, ['a', 'b', 'c'], (value) => { ... }, this);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param host Root object hosting the chain. Must dispatch
|
|
38
|
+
* `PropertyEvent.PROPERTY_CHANGE` when its bindable
|
|
39
|
+
* properties change (i.e. implement `IEventDispatcher`).
|
|
40
|
+
* @param chain Property names forming the chain, e.g. `['a','b','c']`.
|
|
41
|
+
* @param handler Called with the new leaf value whenever the chain changes.
|
|
42
|
+
* @param thisObject `this` context for the handler.
|
|
43
|
+
* @returns The head Watcher, or `undefined` if `chain` is empty.
|
|
44
|
+
*/
|
|
45
|
+
static watch(host: IEventDispatcher | undefined, chain: string[], handler: ((value: unknown) => void) | undefined, thisObject: unknown): Watcher | undefined;
|
|
46
|
+
getValue(): unknown;
|
|
47
|
+
setHandler(handler: (value: unknown) => void, thisObject: unknown): void;
|
|
48
|
+
/**
|
|
49
|
+
* Re-points this watcher at a new host.
|
|
50
|
+
* Pass `undefined` to detach from the current host.
|
|
51
|
+
*/
|
|
52
|
+
reset(newHost: IEventDispatcher | undefined): void;
|
|
53
|
+
unwatch(): void;
|
|
54
|
+
private _getHostPropertyValue;
|
|
55
|
+
private _onPropertyChange;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=Watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Watcher.d.ts","sourceRoot":"","sources":["../../../src/kurot/binding/Watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG3D;;;;;;;;;GASG;AACH,MAAM,MAAM,QAAQ,GAAG,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElE;;;;;;;GAOG;AACH,qBAAa,OAAO;IAGnB,OAAO,CAAC,KAAK,CAAC,CAAW;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,CAA2B;IAC5C,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAU;IACjC,OAAO,CAAC,YAAY,CAAS;gBAK5B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,EAC/C,UAAU,EAAE,OAAO,EACnB,IAAI,EAAE,OAAO,GAAG,SAAS;IAU1B;;;;;;;;;;;;;;;OAeG;WACW,KAAK,CAClB,IAAI,EAAE,gBAAgB,GAAG,SAAS,EAClC,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,EAC/C,UAAU,EAAE,OAAO,GACjB,OAAO,GAAG,SAAS;IAUf,QAAQ,IAAI,OAAO;IAKnB,UAAU,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI;IAM/E;;;OAGG;IACI,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI;IAsBlD,OAAO,IAAI,IAAI;IAQtB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,iBAAiB,CAmBvB;CACF"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { PropertyEvent } from '../events/PropertyEvent.js';
|
|
2
|
+
/**
|
|
3
|
+
* Watcher monitors a property (or property chain) on a host object.
|
|
4
|
+
* When the property changes (via {@link PropertyEvent}), the registered
|
|
5
|
+
* handler is invoked with the new value.
|
|
6
|
+
*
|
|
7
|
+
* Create instances via the static {@link Watcher.watch} method — do not use the
|
|
8
|
+
* constructor directly.
|
|
9
|
+
*/
|
|
10
|
+
export class Watcher {
|
|
11
|
+
// ── Instance fields ───────────────────────────────────────────────────
|
|
12
|
+
_host;
|
|
13
|
+
_property;
|
|
14
|
+
_handler;
|
|
15
|
+
_thisObject;
|
|
16
|
+
_next;
|
|
17
|
+
_isExecuting = false;
|
|
18
|
+
// ── Constructor ───────────────────────────────────────────────────────
|
|
19
|
+
constructor(property, handler, thisObject, next) {
|
|
20
|
+
this._property = property;
|
|
21
|
+
this._handler = handler;
|
|
22
|
+
this._thisObject = thisObject;
|
|
23
|
+
this._next = next;
|
|
24
|
+
}
|
|
25
|
+
// ── Public methods ────────────────────────────────────────────────────
|
|
26
|
+
/**
|
|
27
|
+
* Creates and starts a Watcher for a property chain.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* // watches host.a.b.c
|
|
31
|
+
* Watcher.watch(host, ['a', 'b', 'c'], (value) => { ... }, this);
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param host Root object hosting the chain. Must dispatch
|
|
35
|
+
* `PropertyEvent.PROPERTY_CHANGE` when its bindable
|
|
36
|
+
* properties change (i.e. implement `IEventDispatcher`).
|
|
37
|
+
* @param chain Property names forming the chain, e.g. `['a','b','c']`.
|
|
38
|
+
* @param handler Called with the new leaf value whenever the chain changes.
|
|
39
|
+
* @param thisObject `this` context for the handler.
|
|
40
|
+
* @returns The head Watcher, or `undefined` if `chain` is empty.
|
|
41
|
+
*/
|
|
42
|
+
static watch(host, chain, handler, thisObject) {
|
|
43
|
+
if (chain.length === 0)
|
|
44
|
+
return undefined;
|
|
45
|
+
const property = chain[0];
|
|
46
|
+
const remaining = chain.slice(1);
|
|
47
|
+
const next = remaining.length > 0 ? Watcher.watch(undefined, remaining, handler, thisObject) : undefined;
|
|
48
|
+
const watcher = new Watcher(property, handler, thisObject, next);
|
|
49
|
+
watcher.reset(host);
|
|
50
|
+
return watcher;
|
|
51
|
+
}
|
|
52
|
+
getValue() {
|
|
53
|
+
if (this._next)
|
|
54
|
+
return this._next.getValue();
|
|
55
|
+
return this._getHostPropertyValue();
|
|
56
|
+
}
|
|
57
|
+
setHandler(handler, thisObject) {
|
|
58
|
+
this._handler = handler;
|
|
59
|
+
this._thisObject = thisObject;
|
|
60
|
+
if (this._next)
|
|
61
|
+
this._next.setHandler(handler, thisObject);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Re-points this watcher at a new host.
|
|
65
|
+
* Pass `undefined` to detach from the current host.
|
|
66
|
+
*/
|
|
67
|
+
reset(newHost) {
|
|
68
|
+
if (this._host) {
|
|
69
|
+
this._host.removeEventListener(PropertyEvent.PROPERTY_CHANGE, this._onPropertyChange);
|
|
70
|
+
}
|
|
71
|
+
// The cast is unavoidable: `IEventDispatcher` (core) is not generic over
|
|
72
|
+
// a property map, so TS cannot know the host also exposes bindable own
|
|
73
|
+
// properties by name. `Bindable` only adds an index signature on top of
|
|
74
|
+
// `IEventDispatcher` — it models what every real host (Skin, Component,
|
|
75
|
+
// Group) already does at runtime. This is the single place the engine
|
|
76
|
+
// bridges the event-dispatcher contract and dynamic property access.
|
|
77
|
+
this._host = newHost;
|
|
78
|
+
if (this._host) {
|
|
79
|
+
this._host.addEventListener(PropertyEvent.PROPERTY_CHANGE, this._onPropertyChange);
|
|
80
|
+
}
|
|
81
|
+
if (this._next) {
|
|
82
|
+
this._next.reset(this._getHostPropertyValue());
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
unwatch() {
|
|
86
|
+
this.reset(undefined);
|
|
87
|
+
this._handler = undefined;
|
|
88
|
+
if (this._next)
|
|
89
|
+
this._next._handler = undefined;
|
|
90
|
+
}
|
|
91
|
+
// ── Private methods ───────────────────────────────────────────────────
|
|
92
|
+
_getHostPropertyValue() {
|
|
93
|
+
return this._host ? this._host[this._property] : undefined;
|
|
94
|
+
}
|
|
95
|
+
_onPropertyChange = (e) => {
|
|
96
|
+
// `e` arrives as `Event` because the listener is registered through the
|
|
97
|
+
// `IEventDispatcher` interface, whose signature is not generic over an
|
|
98
|
+
// EventMap (core 1.0 limitation). The dispatcher always uses
|
|
99
|
+
// `PropertyEvent.dispatchPropertyEvent`, which constructs a
|
|
100
|
+
// `PropertyEvent`, so the runtime type is guaranteed.
|
|
101
|
+
if (!(e instanceof PropertyEvent))
|
|
102
|
+
return;
|
|
103
|
+
if (e.property !== this._property || this._isExecuting)
|
|
104
|
+
return;
|
|
105
|
+
try {
|
|
106
|
+
this._isExecuting = true;
|
|
107
|
+
if (this._next) {
|
|
108
|
+
this._next.reset(this._getHostPropertyValue());
|
|
109
|
+
}
|
|
110
|
+
if (this._handler) {
|
|
111
|
+
this._handler.call(this._thisObject, this.getValue());
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
this._isExecuting = false;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=Watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Watcher.js","sourceRoot":"","sources":["../../../src/kurot/binding/Watcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MA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S,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;IAEO,iBAAiB,GAAG,CAAC,CAAQ,EAAQ,EAAE;QAC9C,wEAAwE;QACxE,uEAAuE;QACvE,6DAA6D;QAC7D,4DAA4D;QAC5D,sDAAsD;QACtD,IAAI,CAAC,CAAC,CAAC,YAAY,aAAa,CAAC;YAAE,OAAO;QAC1C,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO;QAC/D,IAAI,CAAC;YACJ,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;YACzB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAqB,EAAkC,CAAC,CAAC;YAChF,CAAC;YACD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YACvD,CAAC;QACF,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC3B,CAAC;IACF,CAAC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/kurot/binding/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/kurot/binding/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|