@shijiu/jsview-vue 0.9.502 → 0.9.631
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/dom/bin/jsview-browser-debug-dom.min.js +1 -1
- package/dom/bin/jsview-dom.min.js +1 -1
- package/dom/target_core_revision.js +4 -3
- package/index.js +10 -0
- package/package.json +8 -1
- package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +16 -5
- package/samples/AnimPicture/App.vue +89 -106
- package/samples/Basic/App.vue +65 -68
- package/samples/Basic/components/ContentBlock.vue +31 -36
- package/samples/Basic/components/anim/AnimGroup.vue +61 -75
- package/samples/Basic/components/anim/AnimKeyframeBasic.vue +54 -43
- package/samples/Basic/components/anim/AnimKeyframeComposite.vue +25 -31
- package/samples/Basic/components/anim/AnimTransition.vue +142 -105
- package/samples/Basic/components/div/DivBackground.vue +38 -16
- package/samples/Basic/components/div/DivClip.vue +143 -78
- package/samples/Basic/components/div/DivCssScoped.vue +10 -10
- package/samples/Basic/components/div/DivCssVar.vue +40 -42
- package/samples/Basic/components/div/DivGroup1.vue +45 -39
- package/samples/Basic/components/div/DivGroup2.vue +56 -45
- package/samples/Basic/components/div/DivLayout.vue +63 -5
- package/samples/Basic/components/div/DivRadius.vue +51 -42
- package/samples/Basic/components/div/DivTransform.vue +21 -16
- package/samples/Basic/components/panel/Panel1.vue +46 -44
- package/samples/Basic/components/panel/Panel2.vue +22 -26
- package/samples/Basic/components/panel/TitleBar.vue +12 -12
- package/samples/Basic/components/text/TextAlign.vue +54 -44
- package/samples/Basic/components/text/TextEmoji.vue +16 -20
- package/samples/Basic/components/text/TextFontStyle.vue +77 -53
- package/samples/Basic/components/text/TextGroup1.vue +46 -38
- package/samples/Basic/components/text/TextGroup2.vue +25 -28
- package/samples/Basic/components/text/TextOverflow.vue +78 -59
- package/samples/BasicFocusControl/App.vue +22 -43
- package/samples/BasicFocusControl/components/BaseBlock.vue +42 -43
- package/samples/BasicFocusControl/components/MainArea.vue +55 -70
- package/samples/BasicFocusControl/components/MainAreaLeftBlock.vue +11 -15
- package/samples/BasicFocusControl/components/MainAreaRightBlock.vue +21 -24
- package/samples/BasicFocusControl/components/SideBar.vue +32 -47
- package/samples/BasicFocusControl/components/SideBarBlock.vue +20 -23
- package/samples/Collision/App.vue +452 -0
- package/samples/ColorSpace/App.vue +15 -24
- package/samples/DemoHomepage/App.vue +7 -11
- package/samples/DemoHomepage/components/BodyFrame.vue +21 -9
- package/samples/DemoHomepage/components/TabFrame.vue +7 -8
- package/samples/DemoHomepage/router.js +52 -33
- package/samples/DemoHomepage/views/Homepage.vue +18 -9
- package/samples/FilterDemo/AnimatePic.vue +58 -0
- package/samples/FilterDemo/App.vue +99 -61
- package/samples/FilterDemo/VideoLayer.vue +62 -0
- package/samples/FlipCard/App.vue +32 -41
- package/samples/FlipCard/FlipCard.vue +48 -54
- package/samples/GridDemo/App.vue +109 -77
- package/samples/GridDemo/ButtonBlock.vue +50 -49
- package/samples/GridDemo/FocusItem.vue +19 -38
- package/samples/GridDemo/Item.vue +46 -54
- package/samples/HashHistory/App.vue +63 -79
- package/samples/HashHistory/components/HorizontalButtonList.vue +72 -95
- package/samples/HashHistory/components/Item.vue +42 -56
- package/samples/HashHistory/router.js +23 -12
- package/samples/HashHistory/views/MainPage.vue +35 -46
- package/samples/HashHistory/views/SubPage.vue +34 -47
- package/samples/ImpactStop/App.vue +435 -0
- package/samples/Input/App.vue +8 -18
- package/samples/Input/FullKeyboard.vue +2 -6
- package/samples/Input/InputPanel.vue +18 -12
- package/samples/Input/KeyboardItem.vue +1 -1
- package/samples/LongImage/App.vue +11 -27
- package/samples/LongImage/Button.vue +50 -145
- package/samples/LongImage/ButtonItem.vue +44 -0
- package/samples/LongImage/LongImageScroll.vue +71 -106
- package/samples/LongImage/Scroll.vue +7 -9
- package/samples/LongText/App.vue +13 -28
- package/samples/LongText/Button.vue +43 -145
- package/samples/LongText/ButtonItem.vue +44 -0
- package/samples/LongText/LongTextScroll.vue +68 -101
- package/samples/LongText/Scroll.vue +7 -9
- package/samples/Marquee/App.vue +34 -37
- package/samples/MaskClip/App.vue +17 -30
- package/samples/MetroWidgetDemos/Advanced/App.vue +47 -0
- package/samples/MetroWidgetDemos/Advanced/ButtonItem.vue +90 -0
- package/samples/MetroWidgetDemos/Advanced/Buttons.vue +70 -0
- package/samples/MetroWidgetDemos/Advanced/Mixed.vue +77 -0
- package/samples/MetroWidgetDemos/Advanced/Widgets.vue +71 -0
- package/samples/MetroWidgetDemos/Item.vue +67 -0
- package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/App.vue +80 -104
- package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/Item.vue +7 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/bg.jpg +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/coupon_content.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/coupon_left.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/coupon_mid.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/coupon_right.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/focus_border.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/holder_logo.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/jrbm.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/line_left.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/line_mid.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/line_right.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/loading.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/logo.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/mcjx.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/tao.png +0 -0
- package/samples/{ClassNameDemo → MetroWidgetDemos/PerformanceTest}/assets/tmall.png +0 -0
- package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/border.png +0 -0
- package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/components/ContentItem.vue +60 -86
- package/samples/{SimpleWidgetDemo → MetroWidgetDemos/PerformanceTest}/components/MyTab.vue +0 -0
- package/samples/MetroWidgetDemos/PerformanceTest/data.js +45 -0
- package/samples/MetroWidgetDemos/PingPong/App.vue +135 -0
- package/samples/MetroWidgetDemos/PingPong/AppPage.vue +73 -0
- package/samples/MetroWidgetDemos/PingPong/AppTab.vue +62 -0
- package/samples/MetroWidgetDemos/PingPong/TabItem.vue +84 -0
- package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +214 -0
- package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +75 -0
- package/samples/MetroWidgetDemos/Simple/App.vue +45 -0
- package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +111 -0
- package/samples/MetroWidgetDemos/WidgetItem.vue +89 -0
- package/samples/MetroWidgetDemos/data.js +204 -0
- package/samples/NinePatchDemo/App.vue +114 -115
- package/samples/NinePatchDemo/Item.vue +7 -8
- package/samples/Preload/App.vue +67 -64
- package/samples/Preload/Item.vue +21 -29
- package/samples/QrcodeDemo/App.vue +24 -29
- package/samples/SoundPool/App.vue +77 -106
- package/samples/SprayView/App.vue +10 -8
- package/samples/SpriteImage/App.vue +1 -2
- package/samples/TextBox/App.vue +86 -101
- package/samples/TextBox/RenderCenter.vue +1 -1
- package/samples/TextBox/RenderLeft.vue +1 -1
- package/samples/TextBox/RenderOneLine.vue +1 -1
- package/samples/TextBox/RenderRight.vue +1 -1
- package/samples/TextShadowDemo/App.vue +1 -2
- package/samples/TextureAnimation/App.vue +16 -13
- package/samples/TextureAnimation/App2.vue +111 -0
- package/samples/TextureAnimation/assets/blackWhiteGrid.png +0 -0
- package/samples/TextureAnimation/assets/light.png +0 -0
- package/samples/TextureAnimation/assets/light2.png +0 -0
- package/samples/TextureAnimation/assets/mask.png +0 -0
- package/samples/TextureSize/App.vue +15 -25
- package/samples/ThrowMoveDemo/AccelerateDemo.vue +2 -4
- package/samples/ThrowMoveDemo/LRParabolicDemo.vue +2 -3
- package/samples/ThrowMoveDemo/TargetDemo.vue +3 -4
- package/samples/ThrowMoveDemo/UDParabolicDemo.vue +2 -3
- package/samples/TouchSample/App.vue +2 -3
- package/samples/TouchSample/Item.vue +15 -13
- package/samples/TouchSample/MetroWidgetHorizontal.vue +2 -2
- package/samples/TouchSample/MetroWidgetVertical.vue +1 -1
- package/samples/TouchSample/TouchContainerHorizontal.vue +4 -3
- package/samples/TouchSample/TouchContainerVertical.vue +3 -2
- package/samples/TransitPage/App.vue +20 -32
- package/samples/VideoDemo/App.vue +65 -81
- package/samples/VideoDemo/components/Button.vue +41 -52
- package/samples/VideoDemo/components/Controllor.vue +171 -169
- package/samples/VideoDemo/components/VideoFrame.vue +87 -99
- package/samples/VisibleSensorDemo/App.vue +234 -0
- package/scripts/jsview-jsmap-serve.js +42 -0
- package/scripts/jsview-post-install.js +1 -1
- package/tsconfig.json +3 -0
- package/utils/JsViewEngineWidget/JsvFocusBlock.vue +204 -193
- package/utils/JsViewEngineWidget/JsvFocusManager.js +30 -17
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +1561 -1656
- package/utils/JsViewEngineWidget/MetroWidget/PageUpdater.js +136 -0
- package/utils/JsViewEngineWidget/MetroWidget/ToolFunctions.js +18 -0
- package/utils/JsViewEngineWidget/TemplateParser.js +111 -1
- package/utils/JsViewEngineWidget/WidgetCommon.js +8 -2
- package/utils/JsViewEngineWidget/index.js +4 -4
- package/utils/JsViewPlugin/JsvPlayer/GetVersion.js +1 -1
- package/utils/JsViewPlugin/JsvPlayer/JsvMedia.js +301 -58
- package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +22 -3
- package/utils/JsViewPlugin/JsvPlayer/index.js +8 -1
- package/utils/JsViewPlugin/JsvPlayer/version.js +5 -5
- package/utils/JsViewVueTools/JsvImpactTracer.js +113 -0
- package/utils/JsViewVueTools/JsvRefTaker.js +35 -0
- package/utils/JsViewVueTools/index.js +20 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserPreload.vue +11 -1
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserQrcode.vue +8 -4
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +203 -14
- package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +2 -2
- package/utils/JsViewVueWidget/JsvApic/JsvApic.vue +2 -2
- package/utils/JsViewVueWidget/JsvFilterView.vue +59 -51
- package/utils/JsViewVueWidget/JsvGrid.vue +139 -41
- package/utils/JsViewVueWidget/JsvInput/Cursor.vue +4 -2
- package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +13 -12
- package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +3 -1
- package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +8 -17
- package/utils/JsViewVueWidget/JsvNinePatch.vue +1 -1
- package/utils/JsViewVueWidget/JsvPosterDiv.vue +37 -7
- package/utils/JsViewVueWidget/JsvPosterImage.vue +34 -13
- package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +39 -53
- package/utils/JsViewVueWidget/JsvQrcode/JsvQrcode.vue +1 -1
- package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +13 -10
- package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +282 -285
- package/utils/JsViewVueWidget/JsvSpriteAnim/index.js +2 -3
- package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +6 -1
- package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +6 -1
- package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +142 -61
- package/utils/JsViewVueWidget/JsvTextureAnim/index.js +9 -5
- package/utils/JsViewVueWidget/JsvTransparentDiv.vue +7 -8
- package/utils/JsViewVueWidget/JsvVideo.vue +9 -12
- package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +141 -0
- package/utils/JsViewVueWidget/JsvVisibleSensor/index.js +9 -0
- package/utils/JsViewVueWidget/index.js +42 -0
- package/samples/AdvanceMetroWidget/App.vue +0 -123
- package/samples/AdvanceMetroWidget/Frame.vue +0 -102
- package/samples/AdvanceMetroWidget/Item.vue +0 -63
- package/samples/AdvanceMetroWidget/data.js +0 -137
- package/samples/ClassNameDemo/App.vue +0 -119
- package/samples/ClassNameDemo/components/ContentItem.vue +0 -253
- package/samples/ClassNameDemo/components/LoadingView.vue +0 -43
- package/samples/ClassNameDemo/components/TitleView.vue +0 -24
- package/samples/ClassNameDemo/data.js +0 -24
- package/samples/FlowMultiWidget/App.vue +0 -91
- package/samples/FlowMultiWidget/assets/nine_patch_focus.png +0 -0
- package/samples/FlowMultiWidget/components/Block.vue +0 -107
- package/samples/FlowMultiWidget/components/FlowPage.vue +0 -60
- package/samples/FlowMultiWidget/components/Item.vue +0 -103
- package/samples/FlowMultiWidget/components/MenuItem.vue +0 -72
- package/samples/FlowMultiWidget/components/MyMenu.vue +0 -90
- package/samples/FlowMultiWidget/data.js +0 -446
- package/samples/HashHistory/views/BasePage.vue +0 -19
- package/samples/HashHistory/views/SubPageFirst.vue +0 -10
- package/samples/HashHistory/views/SubPageSecond.vue +0 -10
- package/samples/SimpleWidgetDemo/assets/bg.jpg +0 -0
- package/samples/SimpleWidgetDemo/assets/coupon_content.png +0 -0
- package/samples/SimpleWidgetDemo/assets/coupon_left.png +0 -0
- package/samples/SimpleWidgetDemo/assets/coupon_mid.png +0 -0
- package/samples/SimpleWidgetDemo/assets/coupon_right.png +0 -0
- package/samples/SimpleWidgetDemo/assets/focus_border.png +0 -0
- package/samples/SimpleWidgetDemo/assets/holder_logo.png +0 -0
- package/samples/SimpleWidgetDemo/assets/jrbm.png +0 -0
- package/samples/SimpleWidgetDemo/assets/line_left.png +0 -0
- package/samples/SimpleWidgetDemo/assets/line_mid.png +0 -0
- package/samples/SimpleWidgetDemo/assets/line_right.png +0 -0
- package/samples/SimpleWidgetDemo/assets/loading.png +0 -0
- package/samples/SimpleWidgetDemo/assets/logo.png +0 -0
- package/samples/SimpleWidgetDemo/assets/mcjx.png +0 -0
- package/samples/SimpleWidgetDemo/assets/tao.png +0 -0
- package/samples/SimpleWidgetDemo/assets/tmall.png +0 -0
- package/samples/SimpleWidgetDemo/data.js +0 -124
- package/utils/JsViewEngineWidget/MetroWidget/ContentView.vue +0 -63
- package/utils/JsViewEngineWidget/MetroWidget/DivWrapper.vue +0 -51
- package/utils/JsViewEngineWidget/MetroWidget/ItemView.vue +0 -213
- package/utils/JsViewEngineWidget/MetroWidget/RootView.vue +0 -154
|
@@ -1,215 +1,226 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
*
|
|
2
|
+
* props:
|
|
3
|
+
* onKeyUp: 按键抬起回调
|
|
3
4
|
* @params keyEvent
|
|
4
5
|
* @return 是否消耗 true: 已消耗,不再冒泡; false: 继续冒泡
|
|
5
|
-
*
|
|
6
|
+
* onKeyDown: 按键落下回调
|
|
6
7
|
* @params keyEvent
|
|
7
8
|
* @return 是否消耗 true: 已消耗,不再冒泡; false: 继续冒泡
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* onFocus: 获得焦点回调
|
|
10
|
+
* onBlur: 失去焦点回调
|
|
11
|
+
* onDispatchKeyDown: 分发按键落下事件回调
|
|
11
12
|
* @params keyEvent
|
|
12
13
|
* @return 是否消耗 true: 已消耗,不再分发; false: 继续分发
|
|
13
|
-
*
|
|
14
|
+
* onDispatchKeyUp: 分发按键抬起事件回调
|
|
14
15
|
* @params keyEvent
|
|
15
16
|
* @return 是否消耗 true: 已消耗,不再分发; false: 继续分发
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* name: 用于设置焦点的id
|
|
18
|
+
* namespace: 焦点id的命名空间
|
|
19
|
+
* autoFocus: 当Mount后自动获得焦点, 设置为"exact",将把其子节点的焦点给抢过来
|
|
20
|
+
* methods:
|
|
21
|
+
* findBlockByName
|
|
22
|
+
@description 寻找焦点树上的节点
|
|
23
|
+
@params {string} name 节点的id名
|
|
24
|
+
* requestFocus
|
|
25
|
+
@description 赋予焦点
|
|
26
|
+
@params {boolean} passToChild 焦点由子往父时是否保持子的焦点
|
|
27
|
+
* returnFocusToParent
|
|
28
|
+
@description 把焦点给自己的父节点
|
|
19
29
|
-->
|
|
20
30
|
|
|
21
|
-
<script>
|
|
22
|
-
/* eslint-disable
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
31
|
+
<script setup>
|
|
32
|
+
/* eslint-disable */
|
|
33
|
+
import { onMounted, onBeforeUnmount, ref, toRaw } from "vue";
|
|
34
|
+
const props = defineProps({
|
|
35
|
+
name: String,
|
|
36
|
+
namespace: String,
|
|
37
|
+
autoFocus: String,
|
|
38
|
+
onAction: Object,
|
|
39
|
+
onDispatchKeyUp: Function,
|
|
40
|
+
onDispatchKeyDown: Function,
|
|
41
|
+
onKeyUp: Function,
|
|
42
|
+
onKeyDown: Function,
|
|
43
|
+
onFocus: Function,
|
|
44
|
+
onBlur: Function,
|
|
45
|
+
onCustomerEvent: Function,
|
|
46
|
+
});
|
|
47
|
+
if (props.namespace && props.name) {
|
|
48
|
+
throw new Error("JsvFocusBlock Error: Either name or namespace can be set.");
|
|
49
|
+
}
|
|
50
|
+
if (props.namespace === "") {
|
|
51
|
+
throw new Error("JsvFocusBlock Error: Invalid namespace of empty value.");
|
|
52
|
+
}
|
|
53
|
+
if (props.namespace && props.namespace.indexOf(".") >= 0) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
'JsvFocusBlock Error: Invalid namespace of "' +
|
|
56
|
+
props.namespace +
|
|
57
|
+
'". namespace must not contains "."'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (props.name && props.name.indexOf(".") >= 0) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
'JsvFocusBlock Error: Invalid name of "' +
|
|
63
|
+
props.name +
|
|
64
|
+
'". name must not contains "."'
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
let actionCallback = {};
|
|
68
|
+
let fDivRef = ref(null);
|
|
69
|
+
|
|
70
|
+
//methods
|
|
71
|
+
const getName = () => {
|
|
72
|
+
return toRaw(fDivRef.value)?.FocusNodeRef.getName();
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const getNamespace = () => {
|
|
76
|
+
let focusNode = toRaw(fDivRef.value)?.FocusNodeRef;
|
|
77
|
+
if (focusNode?.AsHub) {
|
|
78
|
+
// hub的getHub返回的是自己
|
|
79
|
+
focusNode = toRaw(fDivRef.value)?.FocusNodeRef.GetParentPage();
|
|
80
|
+
}
|
|
81
|
+
const namespace = focusNode.getName();
|
|
82
|
+
return namespace !== ".__AppRoot__" ? namespace : "";
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const findBlockByName = (name) => {
|
|
86
|
+
const focusNode = toRaw(fDivRef.value)?.FocusNodeRef.getNodeByName(name);
|
|
87
|
+
return focusNode?.jsvVueComponent;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const requestFocus = (passToChild) => {
|
|
91
|
+
toRaw(fDivRef.value)?.FocusNodeRef.requestFocus(passToChild);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const returnFocusToParent = () => {
|
|
95
|
+
toRaw(fDivRef.value)?.FocusNodeRef.ReturnFocusToParent();
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const bubbleCustomerEvent = (ev) => {
|
|
99
|
+
toRaw(fDivRef.value)?.FocusNodeRef.bubbleCustomerEvent(ev);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const debugPrintFocusChain = () => {
|
|
103
|
+
toRaw(fDivRef.value)?.FocusNodeRef.printFocusNodeList();
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const debugPrintLastFocus = () => {
|
|
107
|
+
toRaw(fDivRef.value)?.FocusNodeRef.printGlobalLastFocus();
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const exportObject = {
|
|
111
|
+
getName,
|
|
112
|
+
getNamespace,
|
|
113
|
+
findBlockByName,
|
|
114
|
+
requestFocus,
|
|
115
|
+
returnFocusToParent,
|
|
116
|
+
bubbleCustomerEvent,
|
|
117
|
+
debugPrintFocusChain,
|
|
118
|
+
debugPrintLastFocus,
|
|
119
|
+
};
|
|
120
|
+
const _mountToFocusSystem = () => {
|
|
121
|
+
const focusNode = toRaw(fDivRef.value)?.FocusNodeRef;
|
|
122
|
+
|
|
123
|
+
// 保存self,find用, 通过exportObject代表自己的instance
|
|
124
|
+
focusNode.jsvVueComponent = exportObject;
|
|
125
|
+
|
|
126
|
+
// 注册回调函数
|
|
127
|
+
actionCallback.onDispatchKeyDown =
|
|
128
|
+
props.onDispatchKeyDown || props.onAction?.onDispatchKeyDown;
|
|
129
|
+
if (actionCallback.onDispatchKeyDown) {
|
|
130
|
+
focusNode.setDispatchKeyDown(_onDispatchKeyDown);
|
|
131
|
+
}
|
|
132
|
+
actionCallback.onDispatchKeyUp =
|
|
133
|
+
props.onDispatchKeyUp || props.onAction?.onDispatchKeyUp;
|
|
134
|
+
if (actionCallback.onDispatchKeyUp) {
|
|
135
|
+
focusNode.setDispatchKeyUp(_onDispatchKeyUp);
|
|
136
|
+
}
|
|
137
|
+
actionCallback.onKeyDown = props.onKeyDown || props.onAction?.onKeyDown;
|
|
138
|
+
if (actionCallback.onKeyDown) {
|
|
139
|
+
focusNode.setOnKeyDown(_onKeyDown);
|
|
140
|
+
}
|
|
141
|
+
actionCallback.onKeyUp = props.onKeyUp || props.onAction?.onKeyUp;
|
|
142
|
+
if (actionCallback.onKeyUp) {
|
|
143
|
+
focusNode.setOnKeyUp(_onKeyUp);
|
|
144
|
+
}
|
|
145
|
+
actionCallback.onFocus = props.onFocus || props.onAction?.onFocus;
|
|
146
|
+
if (actionCallback.onFocus) {
|
|
147
|
+
focusNode.setOnFocus(_onFocus);
|
|
148
|
+
}
|
|
149
|
+
actionCallback.onBlur = props.onBlur || props.onAction?.onBlur;
|
|
150
|
+
if (actionCallback.onBlur) {
|
|
151
|
+
focusNode.setOnBlur(_onBlur);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
actionCallback.onCustomerEvent =
|
|
155
|
+
props.onCustomerEvent || props.onAction?.onCustomerEvent;
|
|
156
|
+
if (actionCallback.onCustomerEvent) {
|
|
157
|
+
focusNode.setOnCustomerEvent(_onCustomerEvent);
|
|
158
|
+
}
|
|
159
|
+
// 建立父子关系链
|
|
160
|
+
let self = toRaw(fDivRef.value);
|
|
161
|
+
let parent = self.parentElement;
|
|
162
|
+
while (parent) {
|
|
163
|
+
if (self.FocusNodeRef.GetParentPage()) {
|
|
164
|
+
break;
|
|
56
165
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'". name must not contains "."'
|
|
62
|
-
);
|
|
166
|
+
|
|
167
|
+
if (parent.tagName !== "FDIV") {
|
|
168
|
+
parent = parent.parentElement;
|
|
169
|
+
continue;
|
|
63
170
|
}
|
|
64
171
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
mounted() {
|
|
70
|
-
this.$_mountToFocusSystem();
|
|
172
|
+
self.FocusNodeRef.setParent(parent.FocusNodeRef);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
71
176
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
getNamespace() {
|
|
88
|
-
let focusNode = this.$el.FocusNodeRef;
|
|
89
|
-
if (focusNode?.AsHub) {
|
|
90
|
-
// hub的getHub返回的是自己
|
|
91
|
-
focusNode = this.$el.FocusNodeRef.GetParentPage();
|
|
92
|
-
}
|
|
93
|
-
const namespace = focusNode.getName();
|
|
94
|
-
return namespace !== ".__AppRoot__" ? namespace : "";
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
findBlockByName(name) {
|
|
98
|
-
const focusNode = this.$el.FocusNodeRef.getNodeByName(name);
|
|
99
|
-
return focusNode?.jsvVueComponent;
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
requestFocus(passToChild) {
|
|
103
|
-
this.$el.FocusNodeRef.requestFocus(passToChild);
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
bubbleCustomerEvent(ev) {
|
|
107
|
-
this.$el.FocusNodeRef.bubbleCustomerEvent(ev);
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
debugPrintFocusChain() {
|
|
111
|
-
this.$el.FocusNodeRef.printFocusNodeList();
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
debugPrintLastFocus() {
|
|
115
|
-
this.$el.FocusNodeRef.printGlobalLastFocus();
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
$_mountToFocusSystem() {
|
|
119
|
-
const focusNode = this.$el.FocusNodeRef;
|
|
120
|
-
|
|
121
|
-
// 保存self,find用
|
|
122
|
-
focusNode.jsvVueComponent = this;
|
|
123
|
-
|
|
124
|
-
// 注册回调函数
|
|
125
|
-
this.actionCallback.onDispatchKeyDown =
|
|
126
|
-
this.$props.onDispatchKeyDown ||
|
|
127
|
-
this.$props.onAction?.onDispatchKeyDown;
|
|
128
|
-
if (this.actionCallback.onDispatchKeyDown) {
|
|
129
|
-
focusNode.setDispatchKeyDown(this.$_onDispatchKeyDown);
|
|
130
|
-
}
|
|
131
|
-
this.actionCallback.onDispatchKeyUp =
|
|
132
|
-
this.$props.onDispatchKeyUp || this.$props.onAction?.onDispatchKeyUp;
|
|
133
|
-
if (this.actionCallback.onDispatchKeyUp) {
|
|
134
|
-
focusNode.setDispatchKeyUp(this.$_onDispatchKeyUp);
|
|
135
|
-
}
|
|
136
|
-
this.actionCallback.onKeyDown =
|
|
137
|
-
this.$props.onKeyDown || this.$props.onAction?.onKeyDown;
|
|
138
|
-
if (this.actionCallback.onKeyDown) {
|
|
139
|
-
focusNode.setOnKeyDown(this.$_onKeyDown);
|
|
140
|
-
}
|
|
141
|
-
this.actionCallback.onKeyUp =
|
|
142
|
-
this.$props.onKeyUp || this.$props.onAction?.onKeyUp;
|
|
143
|
-
if (this.actionCallback.onKeyUp) {
|
|
144
|
-
focusNode.setOnKeyUp(this.$_onKeyUp);
|
|
145
|
-
}
|
|
146
|
-
this.actionCallback.onFocus =
|
|
147
|
-
this.$props.onFocus || this.$props.onAction?.onFocus;
|
|
148
|
-
if (this.actionCallback.onFocus) {
|
|
149
|
-
focusNode.setOnFocus(this.$_onFocus);
|
|
150
|
-
}
|
|
151
|
-
this.actionCallback.onBlur =
|
|
152
|
-
this.$props.onBlur || this.$props.onAction?.onBlur;
|
|
153
|
-
if (this.actionCallback.onBlur) {
|
|
154
|
-
focusNode.setOnBlur(this.$_onBlur);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
this.actionCallback.onCustomerEvent =
|
|
158
|
-
this.$props.onCustomerEvent || this.$props.onAction?.onCustomerEvent;
|
|
159
|
-
if (this.actionCallback.onCustomerEvent) {
|
|
160
|
-
focusNode.setOnCustomerEvent(this.$_onCustomerEvent);
|
|
161
|
-
}
|
|
162
|
-
// 建立父子关系链
|
|
163
|
-
let self = this.$el;
|
|
164
|
-
let parent = self.parentElement;
|
|
165
|
-
while (parent) {
|
|
166
|
-
if (self.FocusNodeRef.GetParentPage()) {
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (parent.tagName !== "FDIV") {
|
|
171
|
-
parent = parent.parentElement;
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
self.FocusNodeRef.setParent(parent.FocusNodeRef);
|
|
176
|
-
|
|
177
|
-
self = parent;
|
|
178
|
-
parent = self.parentElement;
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
$_onDispatchKeyDown(ev) {
|
|
183
|
-
ev.ownerNode = this;
|
|
184
|
-
return this.actionCallback?.onDispatchKeyDown(ev) || false;
|
|
185
|
-
},
|
|
186
|
-
$_onDispatchKeyUp(ev) {
|
|
187
|
-
ev.ownerNode = this;
|
|
188
|
-
return this.actionCallback?.onDispatchKeyUp(ev) || false;
|
|
189
|
-
},
|
|
190
|
-
$_onKeyDown(ev) {
|
|
191
|
-
ev.ownerNode = this;
|
|
192
|
-
return this.actionCallback?.onKeyDown(ev) || false;
|
|
193
|
-
},
|
|
194
|
-
$_onKeyUp(ev) {
|
|
195
|
-
ev.ownerNode = this;
|
|
196
|
-
return this.actionCallback?.onKeyUp(ev) || false;
|
|
197
|
-
},
|
|
198
|
-
$_onFocus() {
|
|
199
|
-
this.actionCallback?.onFocus(this) || false;
|
|
200
|
-
},
|
|
201
|
-
$_onBlur() {
|
|
202
|
-
this.actionCallback?.onBlur(this) || false;
|
|
203
|
-
},
|
|
204
|
-
$_onCustomerEvent(ev) {
|
|
205
|
-
return this.actionCallback?.onCustomerEvent(ev) || false;
|
|
206
|
-
},
|
|
207
|
-
},
|
|
177
|
+
const _onDispatchKeyDown = (ev) => {
|
|
178
|
+
ev.ownerNode = exportObject;
|
|
179
|
+
return actionCallback?.onDispatchKeyDown(ev) || false;
|
|
180
|
+
};
|
|
181
|
+
const _onDispatchKeyUp = (ev) => {
|
|
182
|
+
ev.ownerNode = exportObject;
|
|
183
|
+
return actionCallback?.onDispatchKeyUp(ev) || false;
|
|
184
|
+
};
|
|
185
|
+
const _onKeyDown = (ev) => {
|
|
186
|
+
ev.ownerNode = exportObject;
|
|
187
|
+
return actionCallback?.onKeyDown(ev) || false;
|
|
188
|
+
};
|
|
189
|
+
const _onKeyUp = (ev) => {
|
|
190
|
+
ev.ownerNode = exportObject;
|
|
191
|
+
return actionCallback?.onKeyUp(ev) || false;
|
|
208
192
|
};
|
|
193
|
+
const _onFocus = () => {
|
|
194
|
+
actionCallback?.onFocus(exportObject);
|
|
195
|
+
};
|
|
196
|
+
const _onBlur = () => {
|
|
197
|
+
actionCallback?.onBlur(exportObject);
|
|
198
|
+
};
|
|
199
|
+
const _onCustomerEvent = (ev) => {
|
|
200
|
+
return actionCallback?.onCustomerEvent(ev) || false;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
onMounted(() => {
|
|
204
|
+
_mountToFocusSystem();
|
|
205
|
+
|
|
206
|
+
if (!!props.autoFocus || props.autoFocus === "") {
|
|
207
|
+
requestFocus(props.autoFocus !== "exact");
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
onBeforeUnmount(() => {
|
|
212
|
+
const focusNode = toRaw(fDivRef.value)?.FocusNodeRef;
|
|
213
|
+
focusNode?.onUnMount();
|
|
214
|
+
if (focusNode?.jsvVueComponent) {
|
|
215
|
+
focusNode.jsvVueComponent = undefined;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
defineExpose(exportObject);
|
|
209
220
|
</script>
|
|
210
221
|
|
|
211
222
|
<template>
|
|
212
|
-
<fdiv :fname="
|
|
223
|
+
<fdiv ref="fDivRef" :fname="name" :new-namespace="namespace">
|
|
213
224
|
<slot></slot>
|
|
214
225
|
</fdiv>
|
|
215
226
|
</template>
|
|
@@ -1,30 +1,41 @@
|
|
|
1
1
|
/* eslint-disable no-prototype-builtins */
|
|
2
2
|
|
|
3
|
-
import JsvFocusBlock from
|
|
3
|
+
import JsvFocusBlock from "./JsvFocusBlock.vue";
|
|
4
|
+
import { inject } from "vue";
|
|
5
|
+
|
|
6
|
+
const ROOT_HUB_PROVIDE_NAME = "__jsvFocusRootHub__";
|
|
7
|
+
|
|
8
|
+
const useFocusHub = () => {
|
|
9
|
+
return inject(ROOT_HUB_PROVIDE_NAME);
|
|
10
|
+
};
|
|
4
11
|
|
|
5
12
|
export class JsvFocusManager {
|
|
6
|
-
constructor() {
|
|
7
|
-
}
|
|
13
|
+
constructor() {}
|
|
8
14
|
|
|
9
15
|
install(app, ...options) {
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
console.log("JsvFocusManager install");
|
|
17
|
+
if (typeof options[0] !== "string") {
|
|
18
|
+
throw new Error(
|
|
19
|
+
"JsvFocusManager Error: 2nd argument is required. Such as: app.use(FocusManager, '#app')"
|
|
20
|
+
);
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
// hook掉app原有的mount函数
|
|
15
|
-
const doAppMount = this.$_hookMount(app, options[0])
|
|
16
|
-
app.mount = doAppMount
|
|
24
|
+
const doAppMount = this.$_hookMount(app, options[0]);
|
|
25
|
+
app.mount = doAppMount;
|
|
17
26
|
|
|
18
27
|
// 注册全局jsv-focus-block组件
|
|
19
|
-
app.component(
|
|
28
|
+
app.component("JsvFocusBlock", JsvFocusBlock);
|
|
20
29
|
|
|
21
30
|
// 注册全局$jsvFocusManager变量
|
|
22
31
|
app.config.globalProperties.$jsvFocusManager = this;
|
|
32
|
+
|
|
33
|
+
app.provide(ROOT_HUB_PROVIDE_NAME, this.$_topFDiv.getHub());
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
getCurrentFocusStack() {
|
|
26
37
|
let focus_stack = this.$_topFDiv?.getHub()?.getCurrentFocusStack();
|
|
27
|
-
return
|
|
38
|
+
return focus_stack ? focus_stack : [];
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
// declareAlias(alias, blockName) {
|
|
@@ -68,20 +79,20 @@ export class JsvFocusManager {
|
|
|
68
79
|
// }
|
|
69
80
|
|
|
70
81
|
$_hookMount(app, rootNodeId) {
|
|
71
|
-
rootNodeId = rootNodeId.replace(
|
|
72
|
-
this.$_topFDiv = document.jsvInitFDivRoot(rootNodeId)
|
|
73
|
-
this.$_appMount = app.mount.bind(app)
|
|
82
|
+
rootNodeId = rootNodeId.replace("#", "");
|
|
83
|
+
this.$_topFDiv = document.jsvInitFDivRoot(rootNodeId);
|
|
84
|
+
this.$_appMount = app.mount.bind(app);
|
|
74
85
|
|
|
75
|
-
return this.$_doAppMount.bind(this)
|
|
86
|
+
return this.$_doAppMount.bind(this);
|
|
76
87
|
}
|
|
77
88
|
|
|
78
89
|
$_doAppMount(rootContainer) {
|
|
79
90
|
// 调用app原有的mount函数
|
|
80
|
-
const rootComponent = this.$_appMount(rootContainer)
|
|
91
|
+
const rootComponent = this.$_appMount(rootContainer);
|
|
81
92
|
// console.log('FocusManager: do mount')
|
|
82
93
|
|
|
83
94
|
// 在app.mount后添加焦点控制调用
|
|
84
|
-
this.$_topFDiv.onMounted()
|
|
95
|
+
this.$_topFDiv.onMounted();
|
|
85
96
|
|
|
86
97
|
return rootComponent;
|
|
87
98
|
}
|
|
@@ -91,6 +102,8 @@ export class JsvFocusManager {
|
|
|
91
102
|
$_topFDiv = undefined;
|
|
92
103
|
}
|
|
93
104
|
|
|
94
|
-
|
|
95
|
-
return new JsvFocusManager()
|
|
105
|
+
function jsvCreateFocusManager() {
|
|
106
|
+
return new JsvFocusManager();
|
|
96
107
|
}
|
|
108
|
+
|
|
109
|
+
export { jsvCreateFocusManager, useFocusHub };
|