ex4nicegui 0.6.4__tar.gz → 0.6.6__tar.gz
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.
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/PKG-INFO +26 -1
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/README.md +25 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/__init__.py +3 -2
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/dataSource.py +5 -5
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/ui_echarts.py +2 -5
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/gsap/gsap.py +4 -4
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/gsap/timeline.py +3 -3
- ex4nicegui-0.6.6/ex4nicegui/reactive/EChartsComponent/ECharts.js +112 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/EChartsComponent/ECharts.py +20 -103
- ex4nicegui-0.6.6/ex4nicegui/reactive/EChartsComponent/events.py +26 -0
- ex4nicegui-0.6.6/ex4nicegui/reactive/EChartsComponent/types.py +51 -0
- ex4nicegui-0.6.6/ex4nicegui/reactive/EChartsComponent/utils.py +44 -0
- ex4nicegui-0.6.6/ex4nicegui/reactive/deferredTask.py +29 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/echarts.py +14 -27
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/number.py +2 -1
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/vfor.py +2 -2
- ex4nicegui-0.6.6/ex4nicegui/utils/clientScope.py +52 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui.egg-info/PKG-INFO +26 -1
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui.egg-info/SOURCES.txt +4 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui.egg-info/requires.txt +1 -1
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/setup.py +1 -1
- ex4nicegui-0.6.4/ex4nicegui/reactive/EChartsComponent/ECharts.js +0 -139
- ex4nicegui-0.6.4/ex4nicegui/utils/clientScope.py +0 -43
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/LICENSE +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/dataSourceFacade.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/containers.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/layouts.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/models.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/text.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/ui_aggrid.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/ui_date_picker.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/ui_date_picker.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/ui_radio.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/ui_range.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/ui_select.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/ui_slider.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/elements/ui_table.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/index.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/protocols.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/bi/types.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/experimental_/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/experimental_/gridLayout/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/experimental_/gridLayout/index.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/gsap/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/gsap/timeline.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/gsap/wrapGsap.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/layout/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/layout/gridFlex/GridFlex.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/layout/gridFlex/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/layout/gridFlex/gridFlex.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/layout/gridFlex/utils.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/layout/rxFlex/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/layout/rxFlex/index.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/layout/rxFlex/types.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/d3-color.ems.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/d3-dispatch.ems.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/d3-drag.ems.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/d3-ease.ems.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/d3-interpolate.ems.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/d3-selection.ems.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/d3-timer.ems.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/d3-transition.ems.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/d3/d3-zoom.ems.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/CSSPlugin.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/CSSRulePlugin.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/CustomEase.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/Draggable.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/EasePack.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/EaselPlugin.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/Flip.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/MotionPathPlugin.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/Observer.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/PixiPlugin.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/ScrollToPlugin.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/ScrollTrigger.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/TextPlugin.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/all.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/gsap-core.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/utils/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/utils/matrix.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/utils/paths.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/libs/gsap/utils/strings.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/EChartsComponent/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/UseDraggable/UseDraggable.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/UseDraggable/UseDraggable.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/UseDraggable/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/dropZone/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/dropZone/dropZone.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/dropZone/dropZone.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/empty.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/empty.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/fileWatcher.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/local_file_picker.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/mermaid/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/mermaid/mermaid.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/mermaid/mermaid.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/aggrid.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/base.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/button.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/card.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/checkbox.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/circular_progress.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/color_picker.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/column.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/date.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/drawer.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/element.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/expansion.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/grid.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/html.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/html.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/icon.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/image.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/input.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/knob.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/label.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/linear_progress.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/radio.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/row.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/select.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/slider.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/switch.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/tab.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/tab_panel.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/tab_panels.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/table.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/tabs.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/textarea.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/upload.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/officials/utils.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/q_pagination.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/rxui.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/transitionGroup.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/transitionGroup.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/useMouse/UseMouse.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/useMouse/UseMouse.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/useMouse/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/usePagination.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/utils.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/vfor.js +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/reactive/vmodel.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/tools/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/tools/debug.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/utils/__init__.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/utils/apiEffect.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/utils/asyncComputed.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/utils/common.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/utils/effect.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/utils/scheduler.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui/utils/signals.py +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui.egg-info/dependency_links.txt +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui.egg-info/not-zip-safe +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/ex4nicegui.egg-info/top_level.txt +0 -0
- {ex4nicegui-0.6.4 → ex4nicegui-0.6.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ex4nicegui
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.6
|
|
4
4
|
Summary: Extension library based on nicegui, providing data responsive,BI functionality modules
|
|
5
5
|
Home-page:
|
|
6
6
|
Author: carson_jia
|
|
@@ -420,6 +420,31 @@ ui.button("change b", on_click=change_b)
|
|
|
420
420
|
|
|
421
421
|
---
|
|
422
422
|
|
|
423
|
+
### `new_scope`
|
|
424
|
+
|
|
425
|
+
By default, all watch functions are automatically destroyed when the client connection is disconnected. For finer-grained control, the `new_scope` function can be utilized.
|
|
426
|
+
|
|
427
|
+
```python
|
|
428
|
+
from nicegui import ui
|
|
429
|
+
from ex4nicegui import rxui, to_ref, effect, new_scope
|
|
430
|
+
|
|
431
|
+
a = to_ref(0.0)
|
|
432
|
+
|
|
433
|
+
scope1 = new_scope()
|
|
434
|
+
|
|
435
|
+
@scope1.run
|
|
436
|
+
def _():
|
|
437
|
+
@effect
|
|
438
|
+
def _():
|
|
439
|
+
print(f"scope 1:{a.value}")
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
rxui.number(value=a)
|
|
443
|
+
rxui.button("dispose scope 1", on_click=scope1.dispose)
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
423
448
|
## functionality
|
|
424
449
|
|
|
425
450
|
### vmodel
|
|
@@ -414,6 +414,31 @@ ui.button("change b", on_click=change_b)
|
|
|
414
414
|
|
|
415
415
|
---
|
|
416
416
|
|
|
417
|
+
### `new_scope`
|
|
418
|
+
|
|
419
|
+
默认情况下,所有检测函数在客户端连接断开时自动销毁。如果需要更细粒度的控制,可以使用 `new_scope`
|
|
420
|
+
|
|
421
|
+
```python
|
|
422
|
+
from nicegui import ui
|
|
423
|
+
from ex4nicegui import rxui, to_ref, effect, new_scope
|
|
424
|
+
|
|
425
|
+
a = to_ref(0.0)
|
|
426
|
+
|
|
427
|
+
scope1 = new_scope()
|
|
428
|
+
|
|
429
|
+
@scope1.run
|
|
430
|
+
def _():
|
|
431
|
+
@effect
|
|
432
|
+
def _():
|
|
433
|
+
print(f"scope 1:{a.value}")
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
rxui.number(value=a)
|
|
437
|
+
rxui.button("dispose scope 1", on_click=scope1.dispose)
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
417
442
|
|
|
418
443
|
## 组件功能
|
|
419
444
|
|
|
@@ -20,7 +20,7 @@ from ex4nicegui.utils.signals import (
|
|
|
20
20
|
is_reactive,
|
|
21
21
|
)
|
|
22
22
|
from ex4nicegui.utils.asyncComputed import async_computed
|
|
23
|
-
|
|
23
|
+
from ex4nicegui.utils.clientScope import new_scope
|
|
24
24
|
|
|
25
25
|
__all__ = [
|
|
26
26
|
"async_computed",
|
|
@@ -43,6 +43,7 @@ __all__ = [
|
|
|
43
43
|
"batch",
|
|
44
44
|
"to_raw",
|
|
45
45
|
"is_setter_ref",
|
|
46
|
+
"new_scope",
|
|
46
47
|
]
|
|
47
48
|
|
|
48
|
-
__version__ = "0.6.
|
|
49
|
+
__version__ = "0.6.6"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from typing import Callable, Dict, List, Optional, Set, cast, TYPE_CHECKING
|
|
3
3
|
from ex4nicegui import to_ref, ref_computed, on, batch, effect
|
|
4
|
-
from nicegui import
|
|
4
|
+
from nicegui import Client, ui
|
|
5
5
|
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
7
|
from . import types
|
|
@@ -149,7 +149,7 @@ class DataSource:
|
|
|
149
149
|
self.__notify_update()
|
|
150
150
|
|
|
151
151
|
def get_component_info_key(self, element_id: types._TElementID):
|
|
152
|
-
client_id =
|
|
152
|
+
client_id = ui.context.client.id
|
|
153
153
|
return ComponentInfoKey(client_id, element_id)
|
|
154
154
|
|
|
155
155
|
def get_filtered_data(self, element: ui.element):
|
|
@@ -175,7 +175,7 @@ class DataSource:
|
|
|
175
175
|
update_callback: Optional[_TComponentUpdateCallback] = None,
|
|
176
176
|
ui_result: Optional[UiResult] = None,
|
|
177
177
|
):
|
|
178
|
-
ng_client =
|
|
178
|
+
ng_client = ui.context.client
|
|
179
179
|
client_id = ng_client.id
|
|
180
180
|
|
|
181
181
|
if not self._component_map.has_client_record(client_id):
|
|
@@ -198,7 +198,7 @@ class DataSource:
|
|
|
198
198
|
filter: Optional[Filter],
|
|
199
199
|
notify_update=True,
|
|
200
200
|
):
|
|
201
|
-
client_id =
|
|
201
|
+
client_id = ui.context.client.id
|
|
202
202
|
key = ComponentInfoKey(client_id, element_id)
|
|
203
203
|
|
|
204
204
|
if not self._component_map.has_record(key):
|
|
@@ -216,7 +216,7 @@ class DataSource:
|
|
|
216
216
|
return self
|
|
217
217
|
|
|
218
218
|
def notify_update(self, exclude: Optional[List[UiResult]] = None):
|
|
219
|
-
client_id =
|
|
219
|
+
client_id = ui.context.client.id
|
|
220
220
|
exclude_infos = [
|
|
221
221
|
self._component_map.get_info(ComponentInfoKey(client_id, ur.id))
|
|
222
222
|
for ur in (exclude or [])
|
|
@@ -2,10 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
from typing import TYPE_CHECKING, Any, Callable, Dict, Union, cast
|
|
3
3
|
from nicegui.events import UiEventArguments
|
|
4
4
|
from ex4nicegui.reactive import rxui
|
|
5
|
-
from ex4nicegui.reactive.EChartsComponent.ECharts import
|
|
6
|
-
EChartsMouseEventArguments,
|
|
7
|
-
echarts,
|
|
8
|
-
)
|
|
5
|
+
from ex4nicegui.reactive.EChartsComponent.ECharts import echarts
|
|
9
6
|
from nicegui import ui
|
|
10
7
|
from ex4nicegui.bi.dataSource import DataSource
|
|
11
8
|
from .models import UiResult
|
|
@@ -21,7 +18,7 @@ class EChartsResult(UiResult[echarts]):
|
|
|
21
18
|
super().__init__(element, dataSource)
|
|
22
19
|
self.chart_update = chart_update
|
|
23
20
|
|
|
24
|
-
def on_chart_click(self, handler: Callable[[
|
|
21
|
+
def on_chart_click(self, handler: Callable[[UiEventArguments], Any]):
|
|
25
22
|
return self.element.echarts_on("click", handler)
|
|
26
23
|
|
|
27
24
|
def on_chart_click_blank(self, handler: Callable[[UiEventArguments], Any]):
|
|
@@ -2,7 +2,7 @@ import os
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from typing import Dict, Optional, Union
|
|
4
4
|
from nicegui.element import Element
|
|
5
|
-
from nicegui import
|
|
5
|
+
from nicegui import ui
|
|
6
6
|
from weakref import WeakKeyDictionary
|
|
7
7
|
|
|
8
8
|
|
|
@@ -45,7 +45,7 @@ class Gsap(
|
|
|
45
45
|
def fn():
|
|
46
46
|
self.run_method("runScript", script)
|
|
47
47
|
|
|
48
|
-
if
|
|
48
|
+
if ui.context.client.has_socket_connection:
|
|
49
49
|
fn()
|
|
50
50
|
else:
|
|
51
51
|
tasks = self._props["scriptTasks"]
|
|
@@ -55,7 +55,7 @@ class Gsap(
|
|
|
55
55
|
def fn():
|
|
56
56
|
self.run_method(name, targets, vars)
|
|
57
57
|
|
|
58
|
-
if
|
|
58
|
+
if ui.context.client.has_socket_connection:
|
|
59
59
|
fn()
|
|
60
60
|
else:
|
|
61
61
|
tasks = self._props["tasks"]
|
|
@@ -66,7 +66,7 @@ __instance_map = WeakKeyDictionary()
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
def _get_instance():
|
|
69
|
-
current_client =
|
|
69
|
+
current_client = ui.context.client
|
|
70
70
|
ins = __instance_map.get(current_client)
|
|
71
71
|
|
|
72
72
|
if not ins:
|
|
@@ -2,7 +2,7 @@ import os
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from typing import Dict, Optional, Union
|
|
4
4
|
from nicegui.element import Element
|
|
5
|
-
from nicegui import
|
|
5
|
+
from nicegui import ui
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class Timeline(
|
|
@@ -40,7 +40,7 @@ class Timeline(
|
|
|
40
40
|
def fn():
|
|
41
41
|
self.run_method("runScript", script)
|
|
42
42
|
|
|
43
|
-
if
|
|
43
|
+
if ui.context.client.has_socket_connection:
|
|
44
44
|
fn()
|
|
45
45
|
else:
|
|
46
46
|
tasks = self._props["scriptTasks"]
|
|
@@ -52,7 +52,7 @@ class Timeline(
|
|
|
52
52
|
def fn():
|
|
53
53
|
self.run_method(name, targets, vars)
|
|
54
54
|
|
|
55
|
-
if
|
|
55
|
+
if ui.context.client.has_socket_connection:
|
|
56
56
|
fn()
|
|
57
57
|
else:
|
|
58
58
|
tasks = self._props["tasks"]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { convertDynamicProperties } from "../../static/utils/dynamic_properties.js";
|
|
2
|
+
|
|
3
|
+
function collectMapRegisterTask() {
|
|
4
|
+
const tasks = new Map();
|
|
5
|
+
|
|
6
|
+
if (typeof window.ex4ngEchartsMapTasks !== "undefined") {
|
|
7
|
+
|
|
8
|
+
for (const [mapName, src] of window.ex4ngEchartsMapTasks.entries()) {
|
|
9
|
+
|
|
10
|
+
const registerPromise = new Promise((resolve, reject) => {
|
|
11
|
+
fetch(src)
|
|
12
|
+
.then((response) => response.json())
|
|
13
|
+
.then((data) => {
|
|
14
|
+
echarts.registerMap(mapName, data);
|
|
15
|
+
resolve();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
tasks.set(mapName, registerPromise);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return tasks;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function hasMapOrGeo(options) {
|
|
28
|
+
if (options) {
|
|
29
|
+
const hasMapSeries = options.series && Array.isArray(options.series) &&
|
|
30
|
+
options.series.some(seriesItem =>
|
|
31
|
+
seriesItem.type === 'map' ||
|
|
32
|
+
seriesItem.type === 'lines'
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const hasGeoConfig = options.geo && (typeof options.geo === 'object' || Array.isArray(options.geo));
|
|
36
|
+
|
|
37
|
+
return hasMapSeries || hasGeoConfig;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const mapRegisterTasks = collectMapRegisterTask();
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
template: "<div></div>",
|
|
46
|
+
async mounted() {
|
|
47
|
+
await this.$nextTick(); // wait for Tailwind classes to be applied
|
|
48
|
+
|
|
49
|
+
if (hasMapOrGeo(this.options)) {
|
|
50
|
+
await Promise.all(Array.from(mapRegisterTasks.values()));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.chart = echarts.init(this.$el, this.theme);
|
|
54
|
+
|
|
55
|
+
this.resizeObs = new ResizeObserver(this.chart.resize)
|
|
56
|
+
|
|
57
|
+
// Prevent interruption of chart animations due to resize operations.
|
|
58
|
+
// It is recommended to register the callbacks for such an event before setOption.
|
|
59
|
+
const createResizeObserver = () => {
|
|
60
|
+
this.resizeObs.observe(this.$el);
|
|
61
|
+
this.chart.off("finished", createResizeObserver);
|
|
62
|
+
};
|
|
63
|
+
this.chart.on("finished", createResizeObserver);
|
|
64
|
+
|
|
65
|
+
if (this.options) {
|
|
66
|
+
this.update_chart();
|
|
67
|
+
} else {
|
|
68
|
+
const fn = new Function('return ' + this.code)()
|
|
69
|
+
fn(this.chart)
|
|
70
|
+
this.$emit("__update_options_from_client", this.chart.getOption())
|
|
71
|
+
}
|
|
72
|
+
this.chart.getZr().on("click", (e) => {
|
|
73
|
+
if (!e.target) {
|
|
74
|
+
this.$emit("clickBlank")
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
},
|
|
79
|
+
beforeDestroy() {
|
|
80
|
+
this.chart.dispose();
|
|
81
|
+
this.resizeObs.unobserve();
|
|
82
|
+
},
|
|
83
|
+
beforeUnmount() {
|
|
84
|
+
this.chart.dispose();
|
|
85
|
+
this.resizeObs.unobserve();
|
|
86
|
+
},
|
|
87
|
+
methods: {
|
|
88
|
+
update_chart(opts) {
|
|
89
|
+
convertDynamicProperties(this.options, true);
|
|
90
|
+
this.chart.setOption(this.options, opts ?? { notMerge: this.chart.options?.series.length != this.options.series.length });
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
echarts_on(eventName, query) {
|
|
94
|
+
this.chart.on(eventName.replace(/^chart:/, ''), query, (e) => {
|
|
95
|
+
this.$emit(eventName, e);
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
run_chart_method(name, ...args) {
|
|
100
|
+
if (name.startsWith(":")) {
|
|
101
|
+
name = name.slice(1);
|
|
102
|
+
args = args.map((arg) => new Function("return " + arg)());
|
|
103
|
+
}
|
|
104
|
+
return runMethod(this.chart, name, args);
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
props: {
|
|
108
|
+
options: Object | undefined,
|
|
109
|
+
theme: String | Object | undefined,
|
|
110
|
+
code: String | undefined,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
@@ -3,70 +3,26 @@ from typing import (
|
|
|
3
3
|
Any,
|
|
4
4
|
Callable,
|
|
5
5
|
Dict,
|
|
6
|
-
List,
|
|
7
6
|
Optional,
|
|
8
7
|
Union,
|
|
9
8
|
)
|
|
10
|
-
|
|
11
|
-
from
|
|
12
|
-
from nicegui.dataclasses import KWONLY_SLOTS
|
|
13
|
-
from nicegui.events import (
|
|
14
|
-
handle_event,
|
|
15
|
-
UiEventArguments,
|
|
16
|
-
)
|
|
9
|
+
|
|
10
|
+
from nicegui.events import handle_event, UiEventArguments, GenericEventArguments
|
|
17
11
|
from nicegui.element import Element
|
|
18
12
|
from nicegui.awaitable_response import AwaitableResponse
|
|
19
|
-
from nicegui import context as ng_context
|
|
20
13
|
from pathlib import Path
|
|
21
14
|
import nicegui
|
|
22
|
-
|
|
15
|
+
|
|
16
|
+
from .types import (
|
|
17
|
+
_T_event_name,
|
|
18
|
+
)
|
|
19
|
+
from ex4nicegui.reactive.deferredTask import DeferredTask
|
|
20
|
+
from .utils import get_bound_event_args, create_event_handler_args
|
|
23
21
|
|
|
24
22
|
NG_ROOT = Path(nicegui.__file__).parent / "elements"
|
|
25
23
|
libraries = [NG_ROOT / "lib/echarts/echarts.min.js"]
|
|
26
24
|
|
|
27
25
|
|
|
28
|
-
_Chart_Click_Args = [
|
|
29
|
-
"componentType",
|
|
30
|
-
"seriesType",
|
|
31
|
-
"seriesIndex",
|
|
32
|
-
"seriesName",
|
|
33
|
-
"name",
|
|
34
|
-
"dataIndex",
|
|
35
|
-
"data",
|
|
36
|
-
"dataType",
|
|
37
|
-
"value",
|
|
38
|
-
"color",
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@dataclass(**KWONLY_SLOTS)
|
|
43
|
-
class EChartsMouseEventArguments(UiEventArguments):
|
|
44
|
-
componentType: str
|
|
45
|
-
seriesType: str
|
|
46
|
-
seriesIndex: int
|
|
47
|
-
seriesName: str
|
|
48
|
-
name: str
|
|
49
|
-
dataIndex: int
|
|
50
|
-
data: dict
|
|
51
|
-
dataType: Optional[str]
|
|
52
|
-
value: Any
|
|
53
|
-
color: str
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
_T_echats_on_callback = Callable[[EChartsMouseEventArguments], Any]
|
|
57
|
-
_T_mouse_event_name = Literal[
|
|
58
|
-
"click",
|
|
59
|
-
"dblclick",
|
|
60
|
-
"mousedown",
|
|
61
|
-
"mousemove",
|
|
62
|
-
"mouseup",
|
|
63
|
-
"mouseover",
|
|
64
|
-
"mouseout",
|
|
65
|
-
"globalout",
|
|
66
|
-
"contextmenu",
|
|
67
|
-
]
|
|
68
|
-
|
|
69
|
-
|
|
70
26
|
class echarts(Element, component="ECharts.js", libraries=libraries): # type: ignore
|
|
71
27
|
def __init__(
|
|
72
28
|
self,
|
|
@@ -74,6 +30,7 @@ class echarts(Element, component="ECharts.js", libraries=libraries): # type: ig
|
|
|
74
30
|
code: Optional[str] = None,
|
|
75
31
|
) -> None:
|
|
76
32
|
super().__init__()
|
|
33
|
+
self.__deferred_task = DeferredTask()
|
|
77
34
|
|
|
78
35
|
if (options is None) and (bool(code) is False):
|
|
79
36
|
raise ValueError("At least one of options and code must be valid.")
|
|
@@ -89,36 +46,6 @@ class echarts(Element, component="ECharts.js", libraries=libraries): # type: ig
|
|
|
89
46
|
self._props["options"] = options
|
|
90
47
|
self._props["code"] = code
|
|
91
48
|
|
|
92
|
-
self._echarts_on_tasks: List[Callable] = []
|
|
93
|
-
self._echarts_on_callback_map: Dict[str, _T_echats_on_callback] = {}
|
|
94
|
-
|
|
95
|
-
async def on_client_connect(
|
|
96
|
-
client: nicegui.Client,
|
|
97
|
-
) -> Any:
|
|
98
|
-
await client.connected()
|
|
99
|
-
|
|
100
|
-
for func in self._echarts_on_tasks:
|
|
101
|
-
func()
|
|
102
|
-
|
|
103
|
-
client.connect_handlers.remove(on_client_connect) # type: ignore
|
|
104
|
-
|
|
105
|
-
ng_context.get_client().on_connect(on_client_connect)
|
|
106
|
-
|
|
107
|
-
def echartsOn_handler(e):
|
|
108
|
-
callbackId = e.args["callbackId"]
|
|
109
|
-
params: Dict = e.args["params"]
|
|
110
|
-
params["dataType"] = params.get("dataType")
|
|
111
|
-
|
|
112
|
-
if callbackId in self._echarts_on_callback_map:
|
|
113
|
-
event_args = EChartsMouseEventArguments(
|
|
114
|
-
sender=e.sender, client=e.client, **params
|
|
115
|
-
)
|
|
116
|
-
handler = self._echarts_on_callback_map[callbackId]
|
|
117
|
-
|
|
118
|
-
handle_event(handler, event_args)
|
|
119
|
-
|
|
120
|
-
self.on("event_on", echartsOn_handler)
|
|
121
|
-
|
|
122
49
|
def update_chart(
|
|
123
50
|
self,
|
|
124
51
|
merge_opts: Optional[dict] = None,
|
|
@@ -164,34 +91,24 @@ class echarts(Element, component="ECharts.js", libraries=libraries): # type: ig
|
|
|
164
91
|
),
|
|
165
92
|
)
|
|
166
93
|
|
|
167
|
-
self.on(
|
|
168
|
-
"clickBlank",
|
|
169
|
-
inner_handler,
|
|
170
|
-
_Chart_Click_Args,
|
|
171
|
-
)
|
|
94
|
+
self.on("clickBlank", inner_handler)
|
|
172
95
|
|
|
173
96
|
def echarts_on(
|
|
174
97
|
self,
|
|
175
|
-
event_name:
|
|
176
|
-
handler:
|
|
98
|
+
event_name: _T_event_name,
|
|
99
|
+
handler: Callable[[UiEventArguments], None],
|
|
177
100
|
query: Optional[Union[str, Dict]] = None,
|
|
178
101
|
):
|
|
179
|
-
|
|
102
|
+
def org_handler(e: GenericEventArguments) -> None:
|
|
103
|
+
event_args = create_event_handler_args(event_name, e)
|
|
104
|
+
handle_event(handler, event_args)
|
|
180
105
|
|
|
181
|
-
|
|
182
|
-
|
|
106
|
+
ui_event_name = f"chart:{event_name}"
|
|
107
|
+
super().on(ui_event_name, org_handler, args=get_bound_event_args(event_name))
|
|
183
108
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
callback_id = uuid.uuid4().hex
|
|
188
|
-
self.run_method(
|
|
189
|
-
"echarts_on",
|
|
190
|
-
event_name,
|
|
191
|
-
query,
|
|
192
|
-
callback_id,
|
|
193
|
-
)
|
|
194
|
-
self._echarts_on_callback_map[callback_id] = handler
|
|
109
|
+
@self.__deferred_task.register
|
|
110
|
+
def _():
|
|
111
|
+
self.run_method("echarts_on", ui_event_name, query)
|
|
195
112
|
|
|
196
113
|
def run_chart_method(
|
|
197
114
|
self, name: str, *args, timeout: float = 1, check_interval: float = 0.01
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Any,
|
|
3
|
+
Optional,
|
|
4
|
+
)
|
|
5
|
+
from dataclasses import dataclass, fields
|
|
6
|
+
from nicegui.dataclasses import KWONLY_SLOTS
|
|
7
|
+
from nicegui.events import (
|
|
8
|
+
UiEventArguments,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(**KWONLY_SLOTS)
|
|
13
|
+
class EChartsMouseEventArguments(UiEventArguments):
|
|
14
|
+
componentType: str
|
|
15
|
+
seriesType: str
|
|
16
|
+
seriesIndex: int
|
|
17
|
+
seriesName: str
|
|
18
|
+
name: str
|
|
19
|
+
dataIndex: int
|
|
20
|
+
data: dict
|
|
21
|
+
dataType: Optional[str]
|
|
22
|
+
value: Any
|
|
23
|
+
color: str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
_Mouse_Event_Arguments_Fields = [f.name for f in fields(EChartsMouseEventArguments)]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Union,
|
|
3
|
+
)
|
|
4
|
+
from typing_extensions import Literal
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
_T_mouse_event_name = Literal[
|
|
8
|
+
"click",
|
|
9
|
+
"dblclick",
|
|
10
|
+
"mousedown",
|
|
11
|
+
"mousemove",
|
|
12
|
+
"mouseup",
|
|
13
|
+
"mouseover",
|
|
14
|
+
"mouseout",
|
|
15
|
+
"globalout",
|
|
16
|
+
"contextmenu",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
_T_generic_event_name = Literal[
|
|
20
|
+
"highlight",
|
|
21
|
+
"downplay",
|
|
22
|
+
"selectchanged",
|
|
23
|
+
"legendselectchanged",
|
|
24
|
+
"legendselected",
|
|
25
|
+
"legendunselected",
|
|
26
|
+
"legendselectall",
|
|
27
|
+
"legendinverseselect",
|
|
28
|
+
"legendscroll",
|
|
29
|
+
"datazoom",
|
|
30
|
+
"datarangeselected",
|
|
31
|
+
"graphroam",
|
|
32
|
+
"georoam",
|
|
33
|
+
"treeroam",
|
|
34
|
+
"timelinechanged",
|
|
35
|
+
"timelineplaychanged",
|
|
36
|
+
"restore",
|
|
37
|
+
"dataviewchanged",
|
|
38
|
+
"magictypechanged",
|
|
39
|
+
"geoselectchanged",
|
|
40
|
+
"geoselected",
|
|
41
|
+
"geounselected",
|
|
42
|
+
"axisareaselected",
|
|
43
|
+
"brush",
|
|
44
|
+
"brushEnd",
|
|
45
|
+
"brushselected",
|
|
46
|
+
"globalcursortaken",
|
|
47
|
+
"rendered",
|
|
48
|
+
"finished",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
_T_event_name = Union[_T_mouse_event_name, _T_generic_event_name]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
import typing
|
|
3
|
+
from .types import _T_event_name, _T_mouse_event_name
|
|
4
|
+
from .events import EChartsMouseEventArguments, _Mouse_Event_Arguments_Fields
|
|
5
|
+
from nicegui.events import UiEventArguments, GenericEventArguments
|
|
6
|
+
from functools import lru_cache
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@lru_cache(maxsize=1)
|
|
10
|
+
def _get_mouse_event_names():
|
|
11
|
+
return set(typing.get_args(_T_mouse_event_name))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def is_mouse_event(event_name: _T_event_name) -> bool:
|
|
15
|
+
return event_name in _get_mouse_event_names()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_bound_event_args(event_name: _T_event_name) -> Optional[List[str]]:
|
|
19
|
+
if is_mouse_event(event_name):
|
|
20
|
+
return _Mouse_Event_Arguments_Fields
|
|
21
|
+
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def create_event_handler_args(
|
|
26
|
+
event_name: _T_event_name, e: GenericEventArguments
|
|
27
|
+
) -> UiEventArguments:
|
|
28
|
+
if is_mouse_event(event_name):
|
|
29
|
+
return EChartsMouseEventArguments(
|
|
30
|
+
sender=e.sender,
|
|
31
|
+
client=e.client,
|
|
32
|
+
componentType=e.args["componentType"],
|
|
33
|
+
seriesType=e.args["seriesType"],
|
|
34
|
+
seriesIndex=e.args["seriesIndex"],
|
|
35
|
+
seriesName=e.args["seriesName"],
|
|
36
|
+
name=e.args["name"],
|
|
37
|
+
dataIndex=e.args["dataIndex"],
|
|
38
|
+
data=e.args["data"],
|
|
39
|
+
dataType=e.args.get("dataType"),
|
|
40
|
+
value=e.args["value"],
|
|
41
|
+
color=e.args["color"],
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return GenericEventArguments(sender=e.sender, client=e.client, args=e.args)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
from nicegui import ui, Client as ng_client
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class DeferredTask:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
self._tasks = []
|
|
8
|
+
|
|
9
|
+
async def on_client_connect(
|
|
10
|
+
client: ng_client,
|
|
11
|
+
):
|
|
12
|
+
await client.connected()
|
|
13
|
+
|
|
14
|
+
for task in self._tasks:
|
|
15
|
+
task()
|
|
16
|
+
|
|
17
|
+
self._tasks.clear()
|
|
18
|
+
|
|
19
|
+
# Avoid events becoming ineffective due to page refresh when sharing the client.
|
|
20
|
+
if not client.shared:
|
|
21
|
+
client.connect_handlers.remove(on_client_connect) # type: ignore
|
|
22
|
+
|
|
23
|
+
ui.context.client.on_connect(on_client_connect)
|
|
24
|
+
|
|
25
|
+
def register(self, task: Callable[..., None]):
|
|
26
|
+
if ui.context.client.has_socket_connection:
|
|
27
|
+
task()
|
|
28
|
+
else:
|
|
29
|
+
self._tasks.append(task)
|