@weapp-vite/web 1.3.36 → 1.4.0
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 +144 -5
- package/dist/_virtual/_rolldown/runtime.mjs +19 -1
- package/dist/compiler/wxml/attributes.mjs +1 -1
- package/dist/compiler/wxml/attributes.mjs.map +1 -1
- package/dist/compiler/wxml/compile.mjs +6 -3
- package/dist/compiler/wxml/compile.mjs.map +1 -1
- package/dist/compiler/wxml/interpolation.mjs +1 -2
- package/dist/compiler/wxml/interpolation.mjs.map +1 -1
- package/dist/compiler/wxml/navigation.mjs +5 -7
- package/dist/compiler/wxml/navigation.mjs.map +1 -1
- package/dist/compiler/wxml/parser.mjs +5 -5
- package/dist/compiler/wxml/parser.mjs.map +1 -1
- package/dist/compiler/wxml/renderer.mjs +13 -12
- package/dist/compiler/wxml/renderer.mjs.map +1 -1
- package/dist/compiler/wxml/specialNodes.mjs +6 -1
- package/dist/compiler/wxml/specialNodes.mjs.map +1 -1
- package/dist/compiler/wxml/types.d.mts +12 -0
- package/dist/compiler/wxs.mjs +5 -5
- package/dist/compiler/wxs.mjs.map +1 -1
- package/dist/css/wxss.d.mts +1 -0
- package/dist/css/wxss.mjs +110 -9
- package/dist/css/wxss.mjs.map +1 -1
- package/dist/index.d.mts +29 -6
- package/dist/index.mjs +197 -4
- package/dist/index.mjs.map +1 -0
- package/dist/plugin/assets.d.mts +7 -0
- package/dist/plugin/assets.mjs +122 -0
- package/dist/plugin/assets.mjs.map +1 -0
- package/dist/plugin/constants.mjs +10 -1
- package/dist/plugin/constants.mjs.map +1 -1
- package/dist/plugin/dependencyScan.mjs +41 -0
- package/dist/plugin/dependencyScan.mjs.map +1 -0
- package/dist/plugin/entry.mjs +56 -7
- package/dist/plugin/entry.mjs.map +1 -1
- package/dist/plugin/files.mjs +1 -1
- package/dist/plugin/files.mjs.map +1 -1
- package/dist/plugin/index.d.mts +37 -3
- package/dist/plugin/index.mjs +245 -74
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/layout.mjs +24 -0
- package/dist/plugin/layout.mjs.map +1 -0
- package/dist/plugin/path.mjs +4 -1
- package/dist/plugin/path.mjs.map +1 -1
- package/dist/plugin/register.mjs +48 -36
- package/dist/plugin/register.mjs.map +1 -1
- package/dist/plugin/scan.mjs +206 -94
- package/dist/plugin/scan.mjs.map +1 -1
- package/dist/plugin/scanSfc.mjs +65 -0
- package/dist/plugin/scanSfc.mjs.map +1 -0
- package/dist/plugin/state.mjs +3 -2
- package/dist/plugin/state.mjs.map +1 -1
- package/dist/plugin/styleModule.mjs +52 -0
- package/dist/plugin/styleModule.mjs.map +1 -0
- package/dist/plugin/types.d.mts +46 -1
- package/dist/plugin/vueSfc.mjs +149 -0
- package/dist/plugin/vueSfc.mjs.map +1 -0
- package/dist/runtime/appShell/container.mjs +25 -0
- package/dist/runtime/appShell/container.mjs.map +1 -0
- package/dist/runtime/appShell/tabBar/index.mjs +192 -0
- package/dist/runtime/appShell/tabBar/index.mjs.map +1 -0
- package/dist/runtime/appShell/tabBar/style.mjs +127 -0
- package/dist/runtime/appShell/tabBar/style.mjs.map +1 -0
- package/dist/runtime/button/helpers.mjs +1 -58
- package/dist/runtime/button/helpers.mjs.map +1 -1
- package/dist/runtime/button/index.d.mts +4 -5
- package/dist/runtime/button/index.mjs +6 -28
- package/dist/runtime/button/index.mjs.map +1 -1
- package/dist/runtime/button/style.mjs +53 -28
- package/dist/runtime/button/style.mjs.map +1 -1
- package/dist/runtime/component/behavior.mjs +26 -2
- package/dist/runtime/component/behavior.mjs.map +1 -1
- package/dist/runtime/component/element.mjs +107 -31
- package/dist/runtime/component/element.mjs.map +1 -1
- package/dist/runtime/component/observers.mjs +36 -0
- package/dist/runtime/component/observers.mjs.map +1 -0
- package/dist/runtime/component/publicInstance.mjs +48 -0
- package/dist/runtime/component/publicInstance.mjs.map +1 -0
- package/dist/runtime/component/relations.mjs +35 -0
- package/dist/runtime/component/relations.mjs.map +1 -0
- package/dist/runtime/component/slots.mjs +24 -0
- package/dist/runtime/component/slots.mjs.map +1 -0
- package/dist/runtime/component/state.mjs +13 -3
- package/dist/runtime/component/state.mjs.map +1 -1
- package/dist/runtime/component/types.d.mts +29 -4
- package/dist/runtime/component/virtualHost.mjs +83 -0
- package/dist/runtime/component/virtualHost.mjs.map +1 -0
- package/dist/runtime/host/index.d.mts +13 -0
- package/dist/runtime/host/index.mjs +47 -0
- package/dist/runtime/host/index.mjs.map +1 -0
- package/dist/runtime/host/types.d.mts +28 -0
- package/dist/runtime/hostGlobals.d.mts +9 -0
- package/dist/runtime/hostGlobals.mjs +39 -0
- package/dist/runtime/hostGlobals.mjs.map +1 -0
- package/dist/runtime/index.d.mts +21 -3
- package/dist/runtime/index.mjs +26 -4
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/runtime/legacyTemplate/dom.mjs +3 -3
- package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/expression.mjs +9 -9
- package/dist/runtime/legacyTemplate/expression.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/index.mjs +6 -6
- package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/canvas/index.mjs +53 -0
- package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/checkbox.mjs +137 -0
- package/dist/runtime/nativeComponents/checkbox.mjs.map +1 -0
- package/dist/runtime/nativeComponents/cover/index.mjs +23 -0
- package/dist/runtime/nativeComponents/cover/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/form.d.mts +7 -0
- package/dist/runtime/nativeComponents/form.mjs +50 -0
- package/dist/runtime/nativeComponents/form.mjs.map +1 -0
- package/dist/runtime/nativeComponents/formControl.mjs +61 -0
- package/dist/runtime/nativeComponents/formControl.mjs.map +1 -0
- package/dist/runtime/nativeComponents/helpers.mjs +25 -0
- package/dist/runtime/nativeComponents/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/helpers.mjs +42 -0
- package/dist/runtime/nativeComponents/icon/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/index.mjs +45 -0
- package/dist/runtime/nativeComponents/icon/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/style.mjs +176 -0
- package/dist/runtime/nativeComponents/icon/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/image.d.mts +8 -0
- package/dist/runtime/nativeComponents/image.mjs +121 -0
- package/dist/runtime/nativeComponents/image.mjs.map +1 -0
- package/dist/runtime/nativeComponents/index.d.mts +11 -0
- package/dist/runtime/nativeComponents/index.mjs +83 -0
- package/dist/runtime/nativeComponents/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/input.d.mts +8 -0
- package/dist/runtime/nativeComponents/input.mjs +131 -0
- package/dist/runtime/nativeComponents/input.mjs.map +1 -0
- package/dist/runtime/nativeComponents/label.mjs +36 -0
- package/dist/runtime/nativeComponents/label.mjs.map +1 -0
- package/dist/runtime/nativeComponents/mediaRegistry.mjs +47 -0
- package/dist/runtime/nativeComponents/mediaRegistry.mjs.map +1 -0
- package/dist/runtime/nativeComponents/movable/helpers.mjs +23 -0
- package/dist/runtime/nativeComponents/movable/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/movable/index.mjs +117 -0
- package/dist/runtime/nativeComponents/movable/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/navigator.mjs +200 -0
- package/dist/runtime/nativeComponents/navigator.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/editors.mjs +74 -0
- package/dist/runtime/nativeComponents/picker/editors.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/helpers.mjs +57 -0
- package/dist/runtime/nativeComponents/picker/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/index.mjs +210 -0
- package/dist/runtime/nativeComponents/picker/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/style.mjs +71 -0
- package/dist/runtime/nativeComponents/picker/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/column.mjs +134 -0
- package/dist/runtime/nativeComponents/pickerView/column.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/helpers.mjs +17 -0
- package/dist/runtime/nativeComponents/pickerView/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/index.mjs +128 -0
- package/dist/runtime/nativeComponents/pickerView/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/style.mjs +58 -0
- package/dist/runtime/nativeComponents/pickerView/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/primitives.mjs +16 -0
- package/dist/runtime/nativeComponents/primitives.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/helpers.mjs +29 -0
- package/dist/runtime/nativeComponents/progress/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/index.mjs +130 -0
- package/dist/runtime/nativeComponents/progress/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/style.mjs +40 -0
- package/dist/runtime/nativeComponents/progress/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/radio.mjs +147 -0
- package/dist/runtime/nativeComponents/radio.mjs.map +1 -0
- package/dist/runtime/nativeComponents/richText/helpers.mjs +230 -0
- package/dist/runtime/nativeComponents/richText/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/richText/index.mjs +74 -0
- package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/scrollView.d.mts +15 -0
- package/dist/runtime/nativeComponents/scrollView.mjs +79 -0
- package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/helpers.mjs +28 -0
- package/dist/runtime/nativeComponents/slider/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/index.mjs +120 -0
- package/dist/runtime/nativeComponents/slider/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/style.mjs +60 -0
- package/dist/runtime/nativeComponents/slider/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/style.mjs +41 -0
- package/dist/runtime/nativeComponents/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/helpers.mjs +52 -0
- package/dist/runtime/nativeComponents/swiper/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/index.mjs +235 -0
- package/dist/runtime/nativeComponents/swiper/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/item.mjs +14 -0
- package/dist/runtime/nativeComponents/swiper/item.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/style.mjs +20 -0
- package/dist/runtime/nativeComponents/swiper/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/switch.d.mts +7 -0
- package/dist/runtime/nativeComponents/switch.mjs +132 -0
- package/dist/runtime/nativeComponents/switch.mjs.map +1 -0
- package/dist/runtime/nativeComponents/textarea.d.mts +9 -0
- package/dist/runtime/nativeComponents/textarea.mjs +144 -0
- package/dist/runtime/nativeComponents/textarea.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/helpers.d.mts +12 -0
- package/dist/runtime/nativeComponents/video/helpers.mjs +21 -0
- package/dist/runtime/nativeComponents/video/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/index.mjs +124 -0
- package/dist/runtime/nativeComponents/video/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/style.mjs +14 -0
- package/dist/runtime/nativeComponents/video/style.mjs.map +1 -0
- package/dist/runtime/navigationBar/index.mjs +1 -3
- package/dist/runtime/navigationBar/index.mjs.map +1 -1
- package/dist/runtime/pageLayout.d.mts +9 -0
- package/dist/runtime/pageLayout.mjs +16 -0
- package/dist/runtime/pageLayout.mjs.map +1 -0
- package/dist/runtime/polyfill/animation.mjs +120 -0
- package/dist/runtime/polyfill/animation.mjs.map +1 -0
- package/dist/runtime/polyfill/appState.mjs +1 -1
- package/dist/runtime/polyfill/appState.mjs.map +1 -1
- package/dist/runtime/polyfill/async.d.mts +7 -0
- package/dist/runtime/polyfill/async.mjs.map +1 -1
- package/dist/runtime/polyfill/canvasContext.mjs +41 -0
- package/dist/runtime/polyfill/canvasContext.mjs.map +1 -1
- package/dist/runtime/polyfill/device.mjs +1 -1
- package/dist/runtime/polyfill/device.mjs.map +1 -1
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +8 -2
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
- package/dist/runtime/polyfill/eventBus.mjs +56 -0
- package/dist/runtime/polyfill/eventBus.mjs.map +1 -0
- package/dist/runtime/polyfill/fileSystemManager.mjs +5 -2
- package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
- package/dist/runtime/polyfill/files.mjs +10 -10
- package/dist/runtime/polyfill/files.mjs.map +1 -1
- package/dist/runtime/polyfill/font.mjs +32 -0
- package/dist/runtime/polyfill/font.mjs.map +1 -0
- package/dist/runtime/polyfill/index.d.mts +2 -2
- package/dist/runtime/polyfill/index.mjs +49 -45
- package/dist/runtime/polyfill/index.mjs.map +1 -1
- package/dist/runtime/polyfill/interaction.mjs +7 -6
- package/dist/runtime/polyfill/interaction.mjs.map +1 -1
- package/dist/runtime/polyfill/interactionApi.mjs +3 -2
- package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
- package/dist/runtime/polyfill/intersectionObserver.mjs +106 -0
- package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -0
- package/dist/runtime/polyfill/locale.mjs +14 -0
- package/dist/runtime/polyfill/locale.mjs.map +1 -0
- package/dist/runtime/polyfill/locationApi.mjs +7 -4
- package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaActions.mjs +2 -2
- package/dist/runtime/polyfill/mediaActions.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/file.mjs +1 -1
- package/dist/runtime/polyfill/mediaApi/info.mjs +6 -4
- package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
- package/dist/runtime/polyfill/menuApi.mjs +38 -4
- package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs +6 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/network/request.mjs +2 -2
- package/dist/runtime/polyfill/network/request.mjs.map +1 -1
- package/dist/runtime/polyfill/platformApi.mjs +1 -1
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +88 -0
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/dom.mjs +44 -15
- package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/history.d.mts +30 -0
- package/dist/runtime/polyfill/routeRuntime/history.mjs +148 -0
- package/dist/runtime/polyfill/routeRuntime/history.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +39 -8
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/options.d.mts +11 -1
- package/dist/runtime/polyfill/routeRuntime/options.mjs +0 -1
- package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/result.mjs +12 -0
- package/dist/runtime/polyfill/routeRuntime/result.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs +39 -0
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/stack.mjs +122 -0
- package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime.d.mts +26 -17
- package/dist/runtime/polyfill/routeRuntime.mjs +121 -96
- package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeDataApi.mjs +8 -3
- package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeOps.mjs +10 -6
- package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
- package/dist/runtime/polyfill/selectorQuery.mjs +70 -14
- package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
- package/dist/runtime/polyfill/storage.mjs +5 -2
- package/dist/runtime/polyfill/storage.mjs.map +1 -1
- package/dist/runtime/polyfill/system.mjs +30 -3
- package/dist/runtime/polyfill/system.mjs.map +1 -1
- package/dist/runtime/polyfill/types/locationRuntime.d.mts +1 -4
- package/dist/runtime/polyfill/types/platformRuntime.d.mts +9 -0
- package/dist/runtime/polyfill/types/systemAuth.d.mts +20 -9
- package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +25 -0
- package/dist/runtime/polyfill/ui.mjs +2 -6
- package/dist/runtime/polyfill/ui.mjs.map +1 -1
- package/dist/runtime/polyfill/uiMediaApi.d.mts +11 -10
- package/dist/runtime/polyfill/uiMediaApi.mjs +26 -2
- package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
- package/dist/runtime/polyfill/videoContext.mjs +4 -0
- package/dist/runtime/polyfill/videoContext.mjs.map +1 -1
- package/dist/runtime/polyfill/vkSession.mjs +4 -14
- package/dist/runtime/polyfill/vkSession.mjs.map +1 -1
- package/dist/runtime/polyfill.d.mts +2 -2
- package/dist/runtime/renderContext.mjs +1 -1
- package/dist/runtime/renderContext.mjs.map +1 -1
- package/dist/runtime/rpx.mjs +17 -8
- package/dist/runtime/rpx.mjs.map +1 -1
- package/dist/runtime/seo/index.d.mts +31 -0
- package/dist/runtime/seo/index.mjs +94 -0
- package/dist/runtime/seo/index.mjs.map +1 -0
- package/dist/runtime/viewport/index.d.mts +12 -0
- package/dist/runtime/viewport/index.mjs +44 -0
- package/dist/runtime/viewport/index.mjs.map +1 -0
- package/dist/runtime/viewport/style.mjs +62 -0
- package/dist/runtime/viewport/style.mjs.map +1 -0
- package/dist/runtime/viewport/types.d.mts +14 -0
- package/dist/runtime/wevu.d.mts +20 -0
- package/dist/runtime/wevu.mjs +73 -0
- package/dist/runtime/wevu.mjs.map +1 -0
- package/dist/shared/nativeComponents.mjs +401 -0
- package/dist/shared/nativeComponents.mjs.map +1 -0
- package/dist/shared/tabBar.d.mts +19 -0
- package/dist/shared/tabBar.mjs +37 -0
- package/dist/shared/tabBar.mjs.map +1 -0
- package/dist/shared/wxml.mjs +3 -20
- package/dist/shared/wxml.mjs.map +1 -1
- package/package.json +13 -5
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { getNativeComponentDescriptor } from "../../shared/nativeComponents.mjs";
|
|
2
|
+
import { emitRuntimeWarning } from "../warning.mjs";
|
|
3
|
+
import { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from "./helpers.mjs";
|
|
4
|
+
import { ensureNativeComponentStyle } from "./style.mjs";
|
|
5
|
+
import { navigateBack, navigateTo, reLaunch, redirectTo, switchTab } from "../polyfill/routeRuntime.mjs";
|
|
6
|
+
import { exitMiniProgram, navigateToMiniProgram } from "../polyfill/runtimeDataApi.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/runtime/nativeComponents/navigator.ts
|
|
9
|
+
const BaseElement = globalThis.HTMLElement ?? class {};
|
|
10
|
+
const defaultBridge = {
|
|
11
|
+
navigateTo,
|
|
12
|
+
redirectTo,
|
|
13
|
+
switchTab,
|
|
14
|
+
reLaunch,
|
|
15
|
+
navigateBack,
|
|
16
|
+
navigateToMiniProgram,
|
|
17
|
+
exitMiniProgram
|
|
18
|
+
};
|
|
19
|
+
function normalizeOpenType(value) {
|
|
20
|
+
const normalized = value.trim().toLowerCase();
|
|
21
|
+
switch (normalized) {
|
|
22
|
+
case "redirect":
|
|
23
|
+
case "switchtab":
|
|
24
|
+
case "relaunch":
|
|
25
|
+
case "navigateback":
|
|
26
|
+
case "exit": return normalized;
|
|
27
|
+
default: return "navigate";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function withNavigatorCallbacks(options, request) {
|
|
31
|
+
if (request.success) Object.assign(options, { success: request.success });
|
|
32
|
+
if (request.fail) Object.assign(options, { fail: request.fail });
|
|
33
|
+
if (request.complete) Object.assign(options, { complete: request.complete });
|
|
34
|
+
return options;
|
|
35
|
+
}
|
|
36
|
+
function executeNavigatorRequest(request, bridge = defaultBridge) {
|
|
37
|
+
const openType = normalizeOpenType(request.openType);
|
|
38
|
+
if (request.target.trim().toLowerCase() === "miniprogram") {
|
|
39
|
+
if (openType === "exit") return bridge.exitMiniProgram({
|
|
40
|
+
success: request.success,
|
|
41
|
+
fail: request.fail,
|
|
42
|
+
complete: request.complete
|
|
43
|
+
});
|
|
44
|
+
const options = {
|
|
45
|
+
appId: request.appId,
|
|
46
|
+
path: request.path,
|
|
47
|
+
extraData: request.extraData,
|
|
48
|
+
envVersion: request.envVersion,
|
|
49
|
+
success: request.success,
|
|
50
|
+
fail: request.fail,
|
|
51
|
+
complete: request.complete
|
|
52
|
+
};
|
|
53
|
+
return bridge.navigateToMiniProgram(options);
|
|
54
|
+
}
|
|
55
|
+
switch (openType) {
|
|
56
|
+
case "redirect": return bridge.redirectTo(withNavigatorCallbacks({ url: request.url }, request));
|
|
57
|
+
case "switchtab": return bridge.switchTab(withNavigatorCallbacks({ url: request.url }, request));
|
|
58
|
+
case "relaunch": return bridge.reLaunch(withNavigatorCallbacks({ url: request.url }, request));
|
|
59
|
+
case "navigateback": return bridge.navigateBack(withNavigatorCallbacks({ delta: request.delta }, request));
|
|
60
|
+
case "exit":
|
|
61
|
+
emitRuntimeWarning("[@weapp-vite/web] navigator open-type=\"exit\" 仅在 target=\"miniProgram\" 时生效", {
|
|
62
|
+
key: "navigator:self:exit",
|
|
63
|
+
context: "native-component:navigator"
|
|
64
|
+
});
|
|
65
|
+
return Promise.resolve();
|
|
66
|
+
default: return bridge.navigateTo(withNavigatorCallbacks({ url: request.url }, request));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function resolveNavigatorExtraData(value, attributeValue) {
|
|
70
|
+
if (value && typeof value === "object") return value;
|
|
71
|
+
const serialized = typeof value === "string" ? value : attributeValue;
|
|
72
|
+
if (!serialized) return;
|
|
73
|
+
try {
|
|
74
|
+
const parsed = JSON.parse(serialized);
|
|
75
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
76
|
+
} catch {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function parseNumber(value, fallback) {
|
|
81
|
+
const number = Number(value);
|
|
82
|
+
return value !== null && Number.isFinite(number) ? number : fallback;
|
|
83
|
+
}
|
|
84
|
+
function resolveHoverClass(element) {
|
|
85
|
+
const value = element.getAttribute("hover-class") ?? element.getAttribute("data-hover-class");
|
|
86
|
+
if (value === "none") return "";
|
|
87
|
+
return value || "navigator-hover";
|
|
88
|
+
}
|
|
89
|
+
var WeappNavigator = class extends BaseElement {
|
|
90
|
+
static observedAttributes = [...getNativeComponentDescriptor("navigator").attributes];
|
|
91
|
+
extraData;
|
|
92
|
+
#anchor;
|
|
93
|
+
#hoverTimer;
|
|
94
|
+
#hoverRemoveTimer;
|
|
95
|
+
#lastTouchTime = 0;
|
|
96
|
+
#bound = false;
|
|
97
|
+
connectedCallback() {
|
|
98
|
+
ensureNativeComponentStyle(resolveContainingShadowRoot(this));
|
|
99
|
+
this.#ensureStructure();
|
|
100
|
+
this.#syncAttributes();
|
|
101
|
+
this.#bindEvents();
|
|
102
|
+
}
|
|
103
|
+
disconnectedCallback() {
|
|
104
|
+
this.#clearHoverTimers();
|
|
105
|
+
}
|
|
106
|
+
attributeChangedCallback() {
|
|
107
|
+
this.#syncAttributes();
|
|
108
|
+
}
|
|
109
|
+
#ensureStructure() {
|
|
110
|
+
if (this.#anchor || typeof document === "undefined") return;
|
|
111
|
+
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
112
|
+
const style = document.createElement("style");
|
|
113
|
+
style.textContent = `
|
|
114
|
+
:host { -webkit-tap-highlight-color: transparent; }
|
|
115
|
+
:host(.navigator-hover) { opacity: 0.7; }
|
|
116
|
+
a { display: block; width: 100%; height: 100%; color: inherit; text-decoration: none; outline: none; }
|
|
117
|
+
`;
|
|
118
|
+
const anchor = document.createElement("a");
|
|
119
|
+
anchor.append(document.createElement("slot"));
|
|
120
|
+
root.append(style, anchor);
|
|
121
|
+
this.#anchor = anchor;
|
|
122
|
+
}
|
|
123
|
+
#syncAttributes() {
|
|
124
|
+
if (!this.#anchor) return;
|
|
125
|
+
const url = this.getAttribute("url") ?? "";
|
|
126
|
+
this.#anchor.href = url || "#";
|
|
127
|
+
this.#anchor.setAttribute("aria-label", this.getAttribute("aria-label") ?? this.textContent.trim());
|
|
128
|
+
}
|
|
129
|
+
#bindEvents() {
|
|
130
|
+
if (this.#bound || !this.#anchor) return;
|
|
131
|
+
this.#bound = true;
|
|
132
|
+
this.#anchor.addEventListener("click", this.#handleClick);
|
|
133
|
+
this.addEventListener("touchstart", this.#handlePressStart, { passive: true });
|
|
134
|
+
this.addEventListener("mousedown", this.#handlePressStart);
|
|
135
|
+
this.addEventListener("touchend", this.#handlePressEnd);
|
|
136
|
+
this.addEventListener("touchcancel", this.#handlePressEnd);
|
|
137
|
+
this.addEventListener("mouseup", this.#handlePressEnd);
|
|
138
|
+
this.addEventListener("mouseleave", this.#handlePressEnd);
|
|
139
|
+
}
|
|
140
|
+
#handleClick = (event) => {
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
const target = this.getAttribute("target") ?? "self";
|
|
143
|
+
const shortLink = this.getAttribute("short-link");
|
|
144
|
+
if (target.toLowerCase() === "miniprogram" && shortLink && !this.getAttribute("app-id")) emitRuntimeWarning("[@weapp-vite/web] navigator short-link 暂无浏览器等价实现,请同时提供 app-id", {
|
|
145
|
+
key: "navigator:miniprogram:short-link",
|
|
146
|
+
context: "native-component:navigator"
|
|
147
|
+
});
|
|
148
|
+
const version = this.getAttribute("version");
|
|
149
|
+
const envVersion = version === "develop" || version === "trial" || version === "release" ? version : void 0;
|
|
150
|
+
executeNavigatorRequest({
|
|
151
|
+
url: this.getAttribute("url") ?? "",
|
|
152
|
+
openType: this.getAttribute("open-type") ?? "navigate",
|
|
153
|
+
delta: Math.max(1, parseNumber(this.getAttribute("delta"), 1)),
|
|
154
|
+
target,
|
|
155
|
+
appId: this.getAttribute("app-id") ?? void 0,
|
|
156
|
+
path: this.getAttribute("path") ?? void 0,
|
|
157
|
+
extraData: resolveNavigatorExtraData(this.extraData, this.getAttribute("extra-data")),
|
|
158
|
+
envVersion,
|
|
159
|
+
success: (result) => dispatchMiniProgramEvent(this, "success", result),
|
|
160
|
+
fail: (result) => dispatchMiniProgramEvent(this, "fail", result),
|
|
161
|
+
complete: (result) => dispatchMiniProgramEvent(this, "complete", result)
|
|
162
|
+
}).catch(() => {});
|
|
163
|
+
};
|
|
164
|
+
#handlePressStart = (event) => {
|
|
165
|
+
const hoverClass = resolveHoverClass(this);
|
|
166
|
+
if (!hoverClass) return;
|
|
167
|
+
if (readBooleanAttribute(this, "hover-stop-propagation")) event.stopPropagation();
|
|
168
|
+
if (event.type === "touchstart") this.#lastTouchTime = Date.now();
|
|
169
|
+
if (event.type === "mousedown" && Date.now() - this.#lastTouchTime < 400) return;
|
|
170
|
+
this.#clearHoverTimers();
|
|
171
|
+
const startTime = Math.max(0, parseNumber(this.getAttribute("hover-start-time"), 50));
|
|
172
|
+
this.#hoverTimer = globalThis.setTimeout(() => this.classList.add(hoverClass), startTime);
|
|
173
|
+
};
|
|
174
|
+
#handlePressEnd = (event) => {
|
|
175
|
+
const hoverClass = resolveHoverClass(this);
|
|
176
|
+
if (!hoverClass || event.type === "mouseup" && Date.now() - this.#lastTouchTime < 400) return;
|
|
177
|
+
if (this.#hoverTimer) {
|
|
178
|
+
clearTimeout(this.#hoverTimer);
|
|
179
|
+
this.#hoverTimer = void 0;
|
|
180
|
+
}
|
|
181
|
+
if (this.classList.contains(hoverClass)) {
|
|
182
|
+
const stayTime = Math.max(0, parseNumber(this.getAttribute("hover-stay-time"), 600));
|
|
183
|
+
this.#hoverRemoveTimer = globalThis.setTimeout(() => this.classList.remove(hoverClass), stayTime);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
#clearHoverTimers() {
|
|
187
|
+
if (this.#hoverTimer) {
|
|
188
|
+
clearTimeout(this.#hoverTimer);
|
|
189
|
+
this.#hoverTimer = void 0;
|
|
190
|
+
}
|
|
191
|
+
if (this.#hoverRemoveTimer) {
|
|
192
|
+
clearTimeout(this.#hoverRemoveTimer);
|
|
193
|
+
this.#hoverRemoveTimer = void 0;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
199
|
+
export { WeappNavigator, executeNavigatorRequest, resolveNavigatorExtraData };
|
|
200
|
+
//# sourceMappingURL=navigator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator.mjs","names":["#ensureStructure","#syncAttributes","#bindEvents","#clearHoverTimers","#anchor","#bound","#handleClick","#handlePressStart","#handlePressEnd","#lastTouchTime","#hoverTimer","#hoverRemoveTimer"],"sources":["../../../src/runtime/nativeComponents/navigator.ts"],"sourcesContent":["import type { MiniProgramBaseResult, NavigateToMiniProgramOptions } from '../polyfill/types'\nimport { getNativeComponentDescriptor } from '../../shared/nativeComponents'\nimport { navigateBack, navigateTo, redirectTo, reLaunch, switchTab } from '../polyfill/routeRuntime'\nimport { exitMiniProgram, navigateToMiniProgram } from '../polyfill/runtimeDataApi'\nimport { emitRuntimeWarning } from '../warning'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\ntype NavigatorOpenType = 'navigate' | 'redirect' | 'switchtab' | 'relaunch' | 'navigateback' | 'exit'\n\ninterface NavigatorRuntimeBridge {\n navigateTo: typeof navigateTo\n redirectTo: typeof redirectTo\n switchTab: typeof switchTab\n reLaunch: typeof reLaunch\n navigateBack: typeof navigateBack\n navigateToMiniProgram: typeof navigateToMiniProgram\n exitMiniProgram: typeof exitMiniProgram\n}\n\nexport interface NavigatorRequest {\n url: string\n openType: string\n delta: number\n target: string\n appId?: string\n path?: string\n extraData?: Record<string, unknown>\n envVersion?: 'develop' | 'trial' | 'release'\n success?: (result: MiniProgramBaseResult) => void\n fail?: (result: MiniProgramBaseResult) => void\n complete?: (result: MiniProgramBaseResult) => void\n}\n\nconst defaultBridge: NavigatorRuntimeBridge = {\n navigateTo,\n redirectTo,\n switchTab,\n reLaunch,\n navigateBack,\n navigateToMiniProgram,\n exitMiniProgram,\n}\n\nfunction normalizeOpenType(value: string): NavigatorOpenType {\n const normalized = value.trim().toLowerCase()\n switch (normalized) {\n case 'redirect':\n case 'switchtab':\n case 'relaunch':\n case 'navigateback':\n case 'exit':\n return normalized\n default:\n return 'navigate'\n }\n}\n\nfunction withNavigatorCallbacks<T extends Record<string, unknown>>(options: T, request: NavigatorRequest) {\n if (request.success) {\n Object.assign(options, { success: request.success })\n }\n if (request.fail) {\n Object.assign(options, { fail: request.fail })\n }\n if (request.complete) {\n Object.assign(options, { complete: request.complete })\n }\n return options\n}\n\nexport function executeNavigatorRequest(\n request: NavigatorRequest,\n bridge: NavigatorRuntimeBridge = defaultBridge,\n) {\n const openType = normalizeOpenType(request.openType)\n if (request.target.trim().toLowerCase() === 'miniprogram') {\n if (openType === 'exit') {\n return bridge.exitMiniProgram({\n success: request.success,\n fail: request.fail,\n complete: request.complete,\n })\n }\n const options: NavigateToMiniProgramOptions = {\n appId: request.appId,\n path: request.path,\n extraData: request.extraData,\n envVersion: request.envVersion,\n success: request.success,\n fail: request.fail,\n complete: request.complete,\n }\n return bridge.navigateToMiniProgram(options)\n }\n\n switch (openType) {\n case 'redirect':\n return bridge.redirectTo(withNavigatorCallbacks({ url: request.url }, request))\n case 'switchtab':\n return bridge.switchTab(withNavigatorCallbacks({ url: request.url }, request))\n case 'relaunch':\n return bridge.reLaunch(withNavigatorCallbacks({ url: request.url }, request))\n case 'navigateback':\n return bridge.navigateBack(withNavigatorCallbacks({ delta: request.delta }, request))\n case 'exit':\n emitRuntimeWarning('[@weapp-vite/web] navigator open-type=\"exit\" 仅在 target=\"miniProgram\" 时生效', {\n key: 'navigator:self:exit',\n context: 'native-component:navigator',\n })\n return Promise.resolve()\n default:\n return bridge.navigateTo(withNavigatorCallbacks({ url: request.url }, request))\n }\n}\n\nexport function resolveNavigatorExtraData(value: unknown, attributeValue?: string | null) {\n if (value && typeof value === 'object') {\n return value as Record<string, unknown>\n }\n const serialized = typeof value === 'string' ? value : attributeValue\n if (!serialized) {\n return undefined\n }\n try {\n const parsed = JSON.parse(serialized) as unknown\n return parsed && typeof parsed === 'object' ? parsed as Record<string, unknown> : undefined\n }\n catch {\n return undefined\n }\n}\n\nfunction parseNumber(value: string | null, fallback: number) {\n const number = Number(value)\n return value !== null && Number.isFinite(number) ? number : fallback\n}\n\nfunction resolveHoverClass(element: HTMLElement) {\n const value = element.getAttribute('hover-class') ?? element.getAttribute('data-hover-class')\n if (value === 'none') {\n return ''\n }\n return value || 'navigator-hover'\n}\n\nexport class WeappNavigator extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('navigator')!.attributes]\n\n extraData?: Record<string, unknown> | string\n\n #anchor?: HTMLAnchorElement\n #hoverTimer?: ReturnType<typeof globalThis.setTimeout>\n #hoverRemoveTimer?: ReturnType<typeof globalThis.setTimeout>\n #lastTouchTime = 0\n #bound = false\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncAttributes()\n this.#bindEvents()\n }\n\n disconnectedCallback() {\n this.#clearHoverTimers()\n }\n\n attributeChangedCallback() {\n this.#syncAttributes()\n }\n\n #ensureStructure() {\n if (this.#anchor || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { -webkit-tap-highlight-color: transparent; }\n :host(.navigator-hover) { opacity: 0.7; }\n a { display: block; width: 100%; height: 100%; color: inherit; text-decoration: none; outline: none; }\n `\n const anchor = document.createElement('a')\n anchor.append(document.createElement('slot'))\n root.append(style, anchor)\n this.#anchor = anchor\n }\n\n #syncAttributes() {\n if (!this.#anchor) {\n return\n }\n const url = this.getAttribute('url') ?? ''\n this.#anchor.href = url || '#'\n this.#anchor.setAttribute('aria-label', this.getAttribute('aria-label') ?? this.textContent.trim())\n }\n\n #bindEvents() {\n if (this.#bound || !this.#anchor) {\n return\n }\n this.#bound = true\n this.#anchor.addEventListener('click', this.#handleClick)\n this.addEventListener('touchstart', this.#handlePressStart, { passive: true })\n this.addEventListener('mousedown', this.#handlePressStart)\n this.addEventListener('touchend', this.#handlePressEnd)\n this.addEventListener('touchcancel', this.#handlePressEnd)\n this.addEventListener('mouseup', this.#handlePressEnd)\n this.addEventListener('mouseleave', this.#handlePressEnd)\n }\n\n #handleClick = (event: MouseEvent) => {\n event.preventDefault()\n const target = this.getAttribute('target') ?? 'self'\n const shortLink = this.getAttribute('short-link')\n if (target.toLowerCase() === 'miniprogram' && shortLink && !this.getAttribute('app-id')) {\n emitRuntimeWarning('[@weapp-vite/web] navigator short-link 暂无浏览器等价实现,请同时提供 app-id', {\n key: 'navigator:miniprogram:short-link',\n context: 'native-component:navigator',\n })\n }\n const version = this.getAttribute('version')\n const envVersion = version === 'develop' || version === 'trial' || version === 'release'\n ? version\n : undefined\n void executeNavigatorRequest({\n url: this.getAttribute('url') ?? '',\n openType: this.getAttribute('open-type') ?? 'navigate',\n delta: Math.max(1, parseNumber(this.getAttribute('delta'), 1)),\n target,\n appId: this.getAttribute('app-id') ?? undefined,\n path: this.getAttribute('path') ?? undefined,\n extraData: resolveNavigatorExtraData(this.extraData, this.getAttribute('extra-data')),\n envVersion,\n success: result => dispatchMiniProgramEvent(this, 'success', result),\n fail: result => dispatchMiniProgramEvent(this, 'fail', result),\n complete: result => dispatchMiniProgramEvent(this, 'complete', result),\n }).catch(() => {})\n }\n\n #handlePressStart = (event: Event) => {\n const hoverClass = resolveHoverClass(this)\n if (!hoverClass) {\n return\n }\n if (readBooleanAttribute(this, 'hover-stop-propagation')) {\n event.stopPropagation()\n }\n if (event.type === 'touchstart') {\n this.#lastTouchTime = Date.now()\n }\n if (event.type === 'mousedown' && Date.now() - this.#lastTouchTime < 400) {\n return\n }\n this.#clearHoverTimers()\n const startTime = Math.max(0, parseNumber(this.getAttribute('hover-start-time'), 50))\n this.#hoverTimer = globalThis.setTimeout(() => this.classList.add(hoverClass), startTime)\n }\n\n #handlePressEnd = (event: Event) => {\n const hoverClass = resolveHoverClass(this)\n if (!hoverClass || (event.type === 'mouseup' && Date.now() - this.#lastTouchTime < 400)) {\n return\n }\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.classList.contains(hoverClass)) {\n const stayTime = Math.max(0, parseNumber(this.getAttribute('hover-stay-time'), 600))\n this.#hoverRemoveTimer = globalThis.setTimeout(() => this.classList.remove(hoverClass), stayTime)\n }\n }\n\n #clearHoverTimers() {\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.#hoverRemoveTimer) {\n clearTimeout(this.#hoverRemoveTimer)\n this.#hoverRemoveTimer = undefined\n }\n }\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AA4BtD,MAAM,gBAAwC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,kBAAkB,OAAkC;CAC3D,MAAM,aAAa,MAAM,KAAK,CAAC,CAAC,YAAY;CAC5C,QAAQ,YAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,SAAS,uBAA0D,SAAY,SAA2B;CACxG,IAAI,QAAQ,SACV,OAAO,OAAO,SAAS,EAAE,SAAS,QAAQ,QAAQ,CAAC;CAErD,IAAI,QAAQ,MACV,OAAO,OAAO,SAAS,EA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3
|
+
//#region src/runtime/nativeComponents/picker/editors.ts
|
|
4
|
+
function currentDateValue(fields) {
|
|
5
|
+
const date = /* @__PURE__ */ new Date();
|
|
6
|
+
const year = String(date.getFullYear()).padStart(4, "0");
|
|
7
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
8
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
9
|
+
if (fields === "year") return year;
|
|
10
|
+
if (fields === "month") return `${year}-${month}`;
|
|
11
|
+
return `${year}-${month}-${day}`;
|
|
12
|
+
}
|
|
13
|
+
function renderRangeEditors(options) {
|
|
14
|
+
const columns = resolvePickerColumns(options.range, options.mode, options.rangeKey);
|
|
15
|
+
const current = options.mode === "multiSelector" ? normalizePickerIndexes(options.value, columns.map((column) => column.length)) : [normalizePickerIndex(options.value, columns[0].length)];
|
|
16
|
+
return columns.map((column, columnIndex) => {
|
|
17
|
+
const select = document.createElement("select");
|
|
18
|
+
select.size = Math.min(7, Math.max(3, column.length));
|
|
19
|
+
column.forEach((option, optionIndex) => {
|
|
20
|
+
const item = document.createElement("option");
|
|
21
|
+
item.value = String(optionIndex);
|
|
22
|
+
item.textContent = option.label;
|
|
23
|
+
item.selected = optionIndex === current[columnIndex];
|
|
24
|
+
select.append(item);
|
|
25
|
+
});
|
|
26
|
+
select.addEventListener("change", () => {
|
|
27
|
+
const index = normalizePickerIndex(select.value, column.length);
|
|
28
|
+
if (options.mode === "multiSelector") {
|
|
29
|
+
const next = normalizePickerIndexes(options.value, columns.map((item) => item.length));
|
|
30
|
+
next[columnIndex] = index;
|
|
31
|
+
options.value = next;
|
|
32
|
+
options.onValueChange(next);
|
|
33
|
+
options.onColumnChange(columnIndex, index);
|
|
34
|
+
} else {
|
|
35
|
+
options.value = index;
|
|
36
|
+
options.onValueChange(index);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return select;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function renderTemporalEditor(options) {
|
|
43
|
+
const input = document.createElement("input");
|
|
44
|
+
input.type = options.mode === "time" ? "time" : options.fields === "month" ? "month" : options.fields === "year" ? "number" : "date";
|
|
45
|
+
input.value = String(options.value ?? "");
|
|
46
|
+
if (options.fields === "year") input.value = input.value.slice(0, 4);
|
|
47
|
+
if (options.start) input.min = options.fields === "year" ? options.start.slice(0, 4) : options.start;
|
|
48
|
+
if (options.end) input.max = options.fields === "year" ? options.end.slice(0, 4) : options.end;
|
|
49
|
+
input.addEventListener("input", () => options.onValueChange(input.value));
|
|
50
|
+
return input;
|
|
51
|
+
}
|
|
52
|
+
function renderRegionEditors(options) {
|
|
53
|
+
const count = options.level === "province" ? 1 : options.level === "city" ? 2 : options.level === "sub-district" ? 4 : 3;
|
|
54
|
+
const values = Array.isArray(options.value) ? [...options.value] : [];
|
|
55
|
+
return Array.from({ length: count }, (_, index) => {
|
|
56
|
+
const input = document.createElement("input");
|
|
57
|
+
input.type = "text";
|
|
58
|
+
input.value = String(values[index] ?? options.customItem ?? "");
|
|
59
|
+
input.addEventListener("input", () => {
|
|
60
|
+
values[index] = input.value;
|
|
61
|
+
options.onValueChange([...values]);
|
|
62
|
+
});
|
|
63
|
+
return input;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function renderPickerEditors(options) {
|
|
67
|
+
if (options.mode === "selector" || options.mode === "multiSelector") return renderRangeEditors(options);
|
|
68
|
+
if (options.mode === "date" || options.mode === "time") return [renderTemporalEditor(options)];
|
|
69
|
+
return renderRegionEditors(options);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { currentDateValue, renderPickerEditors };
|
|
74
|
+
//# sourceMappingURL=editors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editors.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/picker/editors.ts"],"sourcesContent":["import type { PickerMode } from './helpers'\nimport {\n normalizePickerIndex,\n normalizePickerIndexes,\n resolvePickerColumns,\n} from './helpers'\n\ninterface PickerEditorOptions {\n mode: PickerMode\n range: unknown\n rangeKey?: string\n value: unknown\n fields?: string\n start?: string\n end?: string\n customItem?: string\n level?: string\n onValueChange: (value: unknown) => void\n onColumnChange: (column: number, value: number) => void\n}\n\nexport function currentDateValue(fields?: string) {\n const date = new Date()\n const year = String(date.getFullYear()).padStart(4, '0')\n const month = String(date.getMonth() + 1).padStart(2, '0')\n const day = String(date.getDate()).padStart(2, '0')\n if (fields === 'year') {\n return year\n }\n if (fields === 'month') {\n return `${year}-${month}`\n }\n return `${year}-${month}-${day}`\n}\n\nfunction renderRangeEditors(options: PickerEditorOptions) {\n const columns = resolvePickerColumns(options.range, options.mode, options.rangeKey)\n const current = options.mode === 'multiSelector'\n ? normalizePickerIndexes(options.value, columns.map(column => column.length))\n : [normalizePickerIndex(options.value, columns[0]!.length)]\n return columns.map((column, columnIndex) => {\n const select = document.createElement('select')\n select.size = Math.min(7, Math.max(3, column.length))\n column.forEach((option, optionIndex) => {\n const item = document.createElement('option')\n item.value = String(optionIndex)\n item.textContent = option.label\n item.selected = optionIndex === current[columnIndex]\n select.append(item)\n })\n select.addEventListener('change', () => {\n const index = normalizePickerIndex(select.value, column.length)\n if (options.mode === 'multiSelector') {\n const next = normalizePickerIndexes(options.value, columns.map(item => item.length))\n next[columnIndex] = index\n options.value = next\n options.onValueChange(next)\n options.onColumnChange(columnIndex, index)\n }\n else {\n options.value = index\n options.onValueChange(index)\n }\n })\n return select\n })\n}\n\nfunction renderTemporalEditor(options: PickerEditorOptions) {\n const input = document.createElement('input')\n input.type = options.mode === 'time'\n ? 'time'\n : options.fields === 'month'\n ? 'month'\n : options.fields === 'year'\n ? 'number'\n : 'date'\n input.value = String(options.value ?? '')\n if (options.fields === 'year') {\n input.value = input.value.slice(0, 4)\n }\n if (options.start) {\n input.min = options.fields === 'year' ? options.start.slice(0, 4) : options.start\n }\n if (options.end) {\n input.max = options.fields === 'year' ? options.end.slice(0, 4) : options.end\n }\n input.addEventListener('input', () => options.onValueChange(input.value))\n return input\n}\n\nfunction renderRegionEditors(options: PickerEditorOptions) {\n const count = options.level === 'province' ? 1 : options.level === 'city' ? 2 : options.level === 'sub-district' ? 4 : 3\n const values = Array.isArray(options.value) ? [...options.value] : []\n return Array.from({ length: count }, (_, index) => {\n const input = document.createElement('input')\n input.type = 'text'\n input.value = String(values[index] ?? options.customItem ?? '')\n input.addEventListener('input', () => {\n values[index] = input.value\n options.onValueChange([...values])\n })\n return input\n })\n}\n\nexport function renderPickerEditors(options: PickerEditorOptions) {\n if (options.mode === 'selector' || options.mode === 'multiSelector') {\n return renderRangeEditors(options)\n }\n if (options.mode === 'date' || options.mode === 'time') {\n return [renderTemporalEditor(options)]\n }\n return renderRegionEditors(options)\n}\n"],"mappings":";;;AAqBA,SAAgB,iBAAiB,QAAiB;CAChD,MAAM,uBAAO,IAAI,KAAK;CACtB,MAAM,OAAO,OAAO,KAAK,YAAY,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;CACvD,MAAM,QAAQ,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;CACzD,MAAM,MAAM,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;CAClD,IAAI,WAAW,QACb,OAAO;CAET,IAAI,WAAW,SACb,OAAO,GAAG,KAAK,GAAG;CAEpB,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG;AAC7B;AAEA,SAAS,mBAAmB,SAA8B;CACxD,MAAM,UAAU,qBAAqB,QAAQ,OAAO,QAAQ,MAAM,QAAQ,QAAQ;CAClF,MAAM,UAAU,QAAQ,SAAS,kBAC7B,uBAAuB,QAAQ,OAAO,QAAQ,KAAI,WAAU,OAAO,MAAM,CAAC,IAC1E,CAAC,qBAAqB,QAAQ,OAAO,QAAQ,EAAE,CAAE,MAAM,CAAC;CAC5D,OAAO,QAAQ,KAAK,QAAQ,gBAAgB;EAC1C,MAAM,SAAS,SAAS,cAAc,QAAQ;EAC9C,OAAO,OAAO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,MAAM,QAAQ,QAAQ,UAAU,aAAa,IAAI,QAAQ,UAAU,SAAS,IAAI,QAAQ,UAAU,iBAAiB,IAAI;CACvH,MAAM,SAAS,MAAM,QAAQ,QAAQ,KAAK,IAAI,CAAC,GAAG,QAAQ,KAAK,IAAI,CAAC;CACpE,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UAAU;EACjD,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,OAAO;EACb,MAAM,QAAQ,OAAO,OAAO,UAAU,QAAQ,cAAc,EAAE;EAC9D,MAAM,iBAAiB,eAAe;GACpC,OAAO,SAAS,MAAM;GACtB,QAAQ,cAAc,CAAC,GAAG,MAAM,CAAC;EACnC,CAAC;EACD,OAAO;CACT,CAAC;AACH;AAEA,SAAgB,oBAAoB,SAA8B;CAChE,IAAI,QAAQ,SAAS,cAAc,QAAQ,SAAS,iBAClD,OAAO,mBAAmB,OAAO;CAEnC,IAAI,QAAQ,SAAS,UAAU,QAAQ,SAAS,QAC9C,OAAO,CAAC,qBAAqB,OAAO,CAAC;CAEvC,OAAO,oBAAoB,OAAO;AACpC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/runtime/nativeComponents/picker/helpers.ts
|
|
2
|
+
const PICKER_MODES = [
|
|
3
|
+
"selector",
|
|
4
|
+
"multiSelector",
|
|
5
|
+
"time",
|
|
6
|
+
"date",
|
|
7
|
+
"region"
|
|
8
|
+
];
|
|
9
|
+
function resolvePickerMode(value) {
|
|
10
|
+
return PICKER_MODES.includes(value) ? value : "selector";
|
|
11
|
+
}
|
|
12
|
+
function resolvePickerLabel(value, rangeKey) {
|
|
13
|
+
if (rangeKey && value && typeof value === "object") {
|
|
14
|
+
const label = value[rangeKey];
|
|
15
|
+
return label === void 0 || label === null ? "" : String(label);
|
|
16
|
+
}
|
|
17
|
+
return value === void 0 || value === null ? "" : String(value);
|
|
18
|
+
}
|
|
19
|
+
function normalizeRange(value) {
|
|
20
|
+
return Array.isArray(value) ? value : [];
|
|
21
|
+
}
|
|
22
|
+
function resolvePickerColumns(range, mode, rangeKey) {
|
|
23
|
+
if (mode === "multiSelector") return normalizeRange(range).map((column) => {
|
|
24
|
+
return normalizeRange(column).map((value) => ({
|
|
25
|
+
label: resolvePickerLabel(value, rangeKey),
|
|
26
|
+
value
|
|
27
|
+
}));
|
|
28
|
+
});
|
|
29
|
+
if (mode !== "selector") return [];
|
|
30
|
+
return [normalizeRange(range).map((value) => ({
|
|
31
|
+
label: resolvePickerLabel(value, rangeKey),
|
|
32
|
+
value
|
|
33
|
+
}))];
|
|
34
|
+
}
|
|
35
|
+
function normalizePickerIndex(value, itemCount) {
|
|
36
|
+
const numeric = Number(value);
|
|
37
|
+
return Math.min(Math.max(0, Number.isFinite(numeric) ? Math.trunc(numeric) : 0), Math.max(0, itemCount - 1));
|
|
38
|
+
}
|
|
39
|
+
function normalizePickerIndexes(value, columnLengths) {
|
|
40
|
+
const indexes = Array.isArray(value) ? value : [];
|
|
41
|
+
return columnLengths.map((length, column) => normalizePickerIndex(indexes[column], length));
|
|
42
|
+
}
|
|
43
|
+
function createPickerChangeDetail(mode, value) {
|
|
44
|
+
if (mode === "region") {
|
|
45
|
+
const region = Array.isArray(value) ? value.map((item) => String(item ?? "")) : [];
|
|
46
|
+
return {
|
|
47
|
+
value: region,
|
|
48
|
+
code: region.map(() => ""),
|
|
49
|
+
postcode: ""
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return { value };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { PICKER_MODES, createPickerChangeDetail, normalizePickerIndex, normalizePickerIndexes, resolvePickerColumns, resolvePickerMode };
|
|
57
|
+
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/picker/helpers.ts"],"sourcesContent":["export const PICKER_MODES = ['selector', 'multiSelector', 'time', 'date', 'region'] as const\n\nexport type PickerMode = typeof PICKER_MODES[number]\n\nexport interface PickerOption {\n label: string\n value: unknown\n}\n\nexport function resolvePickerMode(value: string | null | undefined): PickerMode {\n return PICKER_MODES.includes(value as PickerMode) ? value as PickerMode : 'selector'\n}\n\nfunction resolvePickerLabel(value: unknown, rangeKey?: string) {\n if (rangeKey && value && typeof value === 'object') {\n const label = (value as Record<string, unknown>)[rangeKey]\n return label === undefined || label === null ? '' : String(label)\n }\n return value === undefined || value === null ? '' : String(value)\n}\n\nfunction normalizeRange(value: unknown) {\n return Array.isArray(value) ? value : []\n}\n\nexport function resolvePickerColumns(\n range: unknown,\n mode: PickerMode,\n rangeKey?: string,\n): PickerOption[][] {\n if (mode === 'multiSelector') {\n return normalizeRange(range).map((column) => {\n return normalizeRange(column).map(value => ({\n label: resolvePickerLabel(value, rangeKey),\n value,\n }))\n })\n }\n if (mode !== 'selector') {\n return []\n }\n return [normalizeRange(range).map(value => ({\n label: resolvePickerLabel(value, rangeKey),\n value,\n }))]\n}\n\nexport function normalizePickerIndex(value: unknown, itemCount: number) {\n const numeric = Number(value)\n const index = Number.isFinite(numeric) ? Math.trunc(numeric) : 0\n return Math.min(Math.max(0, index), Math.max(0, itemCount - 1))\n}\n\nexport function normalizePickerIndexes(value: unknown, columnLengths: number[]) {\n const indexes = Array.isArray(value) ? value : []\n return columnLengths.map((length, column) => normalizePickerIndex(indexes[column], length))\n}\n\nexport function createPickerChangeDetail(mode: PickerMode, value: unknown) {\n if (mode === 'region') {\n const region = Array.isArray(value) ? value.map(item => String(item ?? '')) : []\n return {\n value: region,\n code: region.map(() => ''),\n postcode: '',\n }\n }\n return { value }\n}\n"],"mappings":";AAAA,MAAa,eAAe;CAAC;CAAY;CAAiB;CAAQ;CAAQ;AAAQ;AASlF,SAAgB,kBAAkB,OAA8C;CAC9E,OAAO,aAAa,SAAS,KAAmB,IAAI,QAAsB;AAC5E;AAEA,SAAS,mBAAmB,OAAgB,UAA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AE;GACzB,UAAU;EACZ;CACF;CACA,OAAO,EAAE,MAAM;AACjB"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { getNativeComponentDescriptor } from "../../../shared/nativeComponents.mjs";
|
|
2
|
+
import { connectFormControl, disconnectFormControl } from "../formControl.mjs";
|
|
3
|
+
import { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from "../helpers.mjs";
|
|
4
|
+
import { ensureNativeComponentStyle } from "../style.mjs";
|
|
5
|
+
import { PICKER_MODES, createPickerChangeDetail, normalizePickerIndex, normalizePickerIndexes, resolvePickerColumns, resolvePickerMode } from "./helpers.mjs";
|
|
6
|
+
import { currentDateValue, renderPickerEditors } from "./editors.mjs";
|
|
7
|
+
import { PICKER_SHADOW_STYLE } from "./style.mjs";
|
|
8
|
+
|
|
9
|
+
//#region src/runtime/nativeComponents/picker/index.ts
|
|
10
|
+
const BaseElement = globalThis.HTMLElement ?? class {};
|
|
11
|
+
function parsePickerAttribute(value) {
|
|
12
|
+
if (value === null || value === "") return value ?? void 0;
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(value);
|
|
15
|
+
} catch {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function clonePickerValue(value) {
|
|
20
|
+
return Array.isArray(value) ? value.map((item) => clonePickerValue(item)) : value;
|
|
21
|
+
}
|
|
22
|
+
var WeappPicker = class extends BaseElement {
|
|
23
|
+
static observedAttributes = [...getNativeComponentDescriptor("picker").attributes];
|
|
24
|
+
#rangeValue = [];
|
|
25
|
+
#rangePropertySet = false;
|
|
26
|
+
#valueValue;
|
|
27
|
+
#valuePropertySet = false;
|
|
28
|
+
#committedValue;
|
|
29
|
+
#draftValue;
|
|
30
|
+
#initialValue;
|
|
31
|
+
#initialValueCaptured = false;
|
|
32
|
+
#backdrop;
|
|
33
|
+
#panel;
|
|
34
|
+
#editors;
|
|
35
|
+
#title;
|
|
36
|
+
#open = false;
|
|
37
|
+
get range() {
|
|
38
|
+
return this.#rangePropertySet ? this.#rangeValue : parsePickerAttribute(this.getAttribute("range")) ?? [];
|
|
39
|
+
}
|
|
40
|
+
set range(value) {
|
|
41
|
+
this.#rangePropertySet = true;
|
|
42
|
+
this.#rangeValue = value;
|
|
43
|
+
this.#syncExternalValue();
|
|
44
|
+
}
|
|
45
|
+
get value() {
|
|
46
|
+
return this.#valuePropertySet ? this.#valueValue : parsePickerAttribute(this.getAttribute("value"));
|
|
47
|
+
}
|
|
48
|
+
set value(value) {
|
|
49
|
+
this.#valuePropertySet = true;
|
|
50
|
+
this.#valueValue = value;
|
|
51
|
+
this.#syncExternalValue();
|
|
52
|
+
}
|
|
53
|
+
get disabled() {
|
|
54
|
+
return readBooleanAttribute(this, "disabled");
|
|
55
|
+
}
|
|
56
|
+
get formControlName() {
|
|
57
|
+
return this.getAttribute("name") ?? "";
|
|
58
|
+
}
|
|
59
|
+
get formControlValue() {
|
|
60
|
+
return clonePickerValue(this.#committedValue);
|
|
61
|
+
}
|
|
62
|
+
get formControlDisabled() {
|
|
63
|
+
return this.disabled;
|
|
64
|
+
}
|
|
65
|
+
connectedCallback() {
|
|
66
|
+
ensureNativeComponentStyle(resolveContainingShadowRoot(this));
|
|
67
|
+
this.#ensureStructure();
|
|
68
|
+
this.#syncExternalValue();
|
|
69
|
+
if (!this.#initialValueCaptured) {
|
|
70
|
+
this.#initialValue = clonePickerValue(this.#committedValue);
|
|
71
|
+
this.#initialValueCaptured = true;
|
|
72
|
+
}
|
|
73
|
+
this.addEventListener("click", this.#handleHostClick);
|
|
74
|
+
this.addEventListener("keydown", this.#handleHostKeydown);
|
|
75
|
+
if (!this.hasAttribute("tabindex")) this.tabIndex = 0;
|
|
76
|
+
connectFormControl(this);
|
|
77
|
+
}
|
|
78
|
+
disconnectedCallback() {
|
|
79
|
+
this.removeEventListener("click", this.#handleHostClick);
|
|
80
|
+
this.removeEventListener("keydown", this.#handleHostKeydown);
|
|
81
|
+
disconnectFormControl(this);
|
|
82
|
+
}
|
|
83
|
+
attributeChangedCallback() {
|
|
84
|
+
this.#syncExternalValue();
|
|
85
|
+
}
|
|
86
|
+
formActivate() {
|
|
87
|
+
this.open();
|
|
88
|
+
}
|
|
89
|
+
formReset() {
|
|
90
|
+
this.#committedValue = clonePickerValue(this.#initialValue);
|
|
91
|
+
this.#close(false);
|
|
92
|
+
}
|
|
93
|
+
open() {
|
|
94
|
+
if (this.disabled || this.#open || !this.#backdrop) return;
|
|
95
|
+
this.#draftValue = clonePickerValue(this.#committedValue);
|
|
96
|
+
this.#renderEditors();
|
|
97
|
+
this.#backdrop.hidden = false;
|
|
98
|
+
this.#open = true;
|
|
99
|
+
}
|
|
100
|
+
#ensureStructure() {
|
|
101
|
+
if (this.#backdrop || typeof document === "undefined") return;
|
|
102
|
+
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
103
|
+
const style = document.createElement("style");
|
|
104
|
+
style.textContent = PICKER_SHADOW_STYLE;
|
|
105
|
+
const slot = document.createElement("slot");
|
|
106
|
+
const backdrop = document.createElement("div");
|
|
107
|
+
backdrop.className = "backdrop";
|
|
108
|
+
backdrop.hidden = true;
|
|
109
|
+
const panel = document.createElement("div");
|
|
110
|
+
panel.className = "panel";
|
|
111
|
+
panel.setAttribute("role", "dialog");
|
|
112
|
+
panel.setAttribute("aria-modal", "true");
|
|
113
|
+
const toolbar = document.createElement("div");
|
|
114
|
+
toolbar.className = "toolbar";
|
|
115
|
+
const cancel = document.createElement("button");
|
|
116
|
+
cancel.type = "button";
|
|
117
|
+
cancel.textContent = "取消";
|
|
118
|
+
const title = document.createElement("div");
|
|
119
|
+
title.className = "title";
|
|
120
|
+
const confirm = document.createElement("button");
|
|
121
|
+
confirm.type = "button";
|
|
122
|
+
confirm.textContent = "确定";
|
|
123
|
+
const editors = document.createElement("div");
|
|
124
|
+
editors.className = "editors";
|
|
125
|
+
toolbar.append(cancel, title, confirm);
|
|
126
|
+
panel.append(toolbar, editors);
|
|
127
|
+
backdrop.append(panel);
|
|
128
|
+
root.append(style, slot, backdrop);
|
|
129
|
+
cancel.addEventListener("click", () => this.#close(true));
|
|
130
|
+
confirm.addEventListener("click", () => this.#confirm());
|
|
131
|
+
backdrop.addEventListener("click", (event) => {
|
|
132
|
+
if (event.target === backdrop) {
|
|
133
|
+
event.stopPropagation();
|
|
134
|
+
this.#close(true);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
this.#backdrop = backdrop;
|
|
138
|
+
this.#panel = panel;
|
|
139
|
+
this.#editors = editors;
|
|
140
|
+
this.#title = title;
|
|
141
|
+
}
|
|
142
|
+
#syncExternalValue() {
|
|
143
|
+
const mode = resolvePickerMode(this.getAttribute("mode"));
|
|
144
|
+
const external = this.value;
|
|
145
|
+
if (mode === "selector") {
|
|
146
|
+
const columns = resolvePickerColumns(this.range, mode, this.getAttribute("range-key") ?? void 0);
|
|
147
|
+
this.#committedValue = normalizePickerIndex(external, columns[0].length);
|
|
148
|
+
} else if (mode === "multiSelector") {
|
|
149
|
+
const columns = resolvePickerColumns(this.range, mode, this.getAttribute("range-key") ?? void 0);
|
|
150
|
+
this.#committedValue = normalizePickerIndexes(external, columns.map((column) => column.length));
|
|
151
|
+
} else if (mode === "date") this.#committedValue = typeof external === "string" && external ? external : currentDateValue(this.getAttribute("fields") ?? void 0);
|
|
152
|
+
else if (mode === "time") this.#committedValue = typeof external === "string" ? external : "";
|
|
153
|
+
else this.#committedValue = Array.isArray(external) ? external.map((item) => String(item ?? "")) : [];
|
|
154
|
+
if (this.#open) {
|
|
155
|
+
this.#draftValue = clonePickerValue(this.#committedValue);
|
|
156
|
+
this.#renderEditors();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
#renderEditors() {
|
|
160
|
+
if (!this.#editors || typeof document === "undefined") return;
|
|
161
|
+
const mode = resolvePickerMode(this.getAttribute("mode"));
|
|
162
|
+
this.#title.textContent = this.getAttribute("header-text") ?? "";
|
|
163
|
+
const controls = renderPickerEditors({
|
|
164
|
+
mode,
|
|
165
|
+
range: this.range,
|
|
166
|
+
rangeKey: this.getAttribute("range-key") ?? void 0,
|
|
167
|
+
value: this.#draftValue,
|
|
168
|
+
fields: this.getAttribute("fields") ?? void 0,
|
|
169
|
+
start: this.getAttribute("start") ?? void 0,
|
|
170
|
+
end: this.getAttribute("end") ?? void 0,
|
|
171
|
+
customItem: this.getAttribute("custom-item") ?? void 0,
|
|
172
|
+
level: this.getAttribute("level") ?? void 0,
|
|
173
|
+
onValueChange: (value) => {
|
|
174
|
+
this.#draftValue = value;
|
|
175
|
+
},
|
|
176
|
+
onColumnChange: (column, value) => {
|
|
177
|
+
dispatchMiniProgramEvent(this, "columnchange", {
|
|
178
|
+
column,
|
|
179
|
+
value
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
this.#editors.replaceChildren(...controls);
|
|
184
|
+
}
|
|
185
|
+
#confirm() {
|
|
186
|
+
const mode = resolvePickerMode(this.getAttribute("mode"));
|
|
187
|
+
this.#committedValue = clonePickerValue(this.#draftValue);
|
|
188
|
+
this.#close(false);
|
|
189
|
+
dispatchMiniProgramEvent(this, "change", createPickerChangeDetail(mode, clonePickerValue(this.#committedValue)));
|
|
190
|
+
}
|
|
191
|
+
#close(cancelled) {
|
|
192
|
+
if (!this.#open || !this.#backdrop) return;
|
|
193
|
+
this.#backdrop.hidden = true;
|
|
194
|
+
this.#open = false;
|
|
195
|
+
if (cancelled) dispatchMiniProgramEvent(this, "cancel", {});
|
|
196
|
+
}
|
|
197
|
+
#handleHostClick = (event) => {
|
|
198
|
+
if (this.#panel && event.composedPath().includes(this.#panel)) return;
|
|
199
|
+
this.open();
|
|
200
|
+
};
|
|
201
|
+
#handleHostKeydown = (event) => {
|
|
202
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
this.open();
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
//#endregion
|
|
209
|
+
export { PICKER_MODES, WeappPicker, createPickerChangeDetail, normalizePickerIndex, normalizePickerIndexes, resolvePickerColumns, resolvePickerMode };
|
|
210
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#rangePropertySet","#rangeValue","#syncExternalValue","#valuePropertySet","#valueValue","#committedValue","#ensureStructure","#initialValueCaptured","#initialValue","#handleHostClick","#handleHostKeydown","#close","#open","#backdrop","#draftValue","#renderEditors","#confirm","#panel","#editors","#title"],"sources":["../../../../src/runtime/nativeComponents/picker/index.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { connectFormControl, disconnectFormControl } from '../formControl'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from '../helpers'\nimport { ensureNativeComponentStyle } from '../style'\nimport { currentDateValue, renderPickerEditors } from './editors'\nimport {\n createPickerChangeDetail,\n normalizePickerIndex,\n normalizePickerIndexes,\n resolvePickerColumns,\n resolvePickerMode,\n} from './helpers'\nimport { PICKER_SHADOW_STYLE } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nfunction parsePickerAttribute(value: string | null): unknown {\n if (value === null || value === '') {\n return value ?? undefined\n }\n try {\n return JSON.parse(value) as unknown\n }\n catch {\n return value\n }\n}\n\nfunction clonePickerValue(value: unknown): unknown {\n return Array.isArray(value) ? value.map(item => clonePickerValue(item)) : value\n}\n\nexport class WeappPicker extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('picker')!.attributes]\n\n #rangeValue: unknown = []\n #rangePropertySet = false\n #valueValue: unknown\n #valuePropertySet = false\n #committedValue: unknown\n #draftValue: unknown\n #initialValue: unknown\n #initialValueCaptured = false\n #backdrop?: HTMLDivElement\n #panel?: HTMLDivElement\n #editors?: HTMLDivElement\n #title?: HTMLDivElement\n #open = false\n\n get range() {\n return this.#rangePropertySet\n ? this.#rangeValue\n : parsePickerAttribute(this.getAttribute('range')) ?? []\n }\n\n set range(value: unknown) {\n this.#rangePropertySet = true\n this.#rangeValue = value\n this.#syncExternalValue()\n }\n\n get value() {\n return this.#valuePropertySet\n ? this.#valueValue\n : parsePickerAttribute(this.getAttribute('value'))\n }\n\n set value(value: unknown) {\n this.#valuePropertySet = true\n this.#valueValue = value\n this.#syncExternalValue()\n }\n\n get disabled() {\n return readBooleanAttribute(this, 'disabled')\n }\n\n get formControlName() {\n return this.getAttribute('name') ?? ''\n }\n\n get formControlValue() {\n return clonePickerValue(this.#committedValue)\n }\n\n get formControlDisabled() {\n return this.disabled\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncExternalValue()\n if (!this.#initialValueCaptured) {\n this.#initialValue = clonePickerValue(this.#committedValue)\n this.#initialValueCaptured = true\n }\n this.addEventListener('click', this.#handleHostClick)\n this.addEventListener('keydown', this.#handleHostKeydown)\n if (!this.hasAttribute('tabindex')) {\n this.tabIndex = 0\n }\n connectFormControl(this)\n }\n\n disconnectedCallback() {\n this.removeEventListener('click', this.#handleHostClick)\n this.removeEventListener('keydown', this.#handleHostKeydown)\n disconnectFormControl(this)\n }\n\n attributeChangedCallback() {\n this.#syncExternalValue()\n }\n\n formActivate() {\n this.open()\n }\n\n formReset() {\n this.#committedValue = clonePickerValue(this.#initialValue)\n this.#close(false)\n }\n\n open() {\n if (this.disabled || this.#open || !this.#backdrop) {\n return\n }\n this.#draftValue = clonePickerValue(this.#committedValue)\n this.#renderEditors()\n this.#backdrop.hidden = false\n this.#open = true\n }\n\n #ensureStructure() {\n if (this.#backdrop || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = PICKER_SHADOW_STYLE\n const slot = document.createElement('slot')\n const backdrop = document.createElement('div')\n backdrop.className = 'backdrop'\n backdrop.hidden = true\n const panel = document.createElement('div')\n panel.className = 'panel'\n panel.setAttribute('role', 'dialog')\n panel.setAttribute('aria-modal', 'true')\n const toolbar = document.createElement('div')\n toolbar.className = 'toolbar'\n const cancel = document.createElement('button')\n cancel.type = 'button'\n cancel.textContent = '取消'\n const title = document.createElement('div')\n title.className = 'title'\n const confirm = document.createElement('button')\n confirm.type = 'button'\n confirm.textContent = '确定'\n const editors = document.createElement('div')\n editors.className = 'editors'\n toolbar.append(cancel, title, confirm)\n panel.append(toolbar, editors)\n backdrop.append(panel)\n root.append(style, slot, backdrop)\n cancel.addEventListener('click', () => this.#close(true))\n confirm.addEventListener('click', () => this.#confirm())\n backdrop.addEventListener('click', (event) => {\n if (event.target === backdrop) {\n event.stopPropagation()\n this.#close(true)\n }\n })\n this.#backdrop = backdrop\n this.#panel = panel\n this.#editors = editors\n this.#title = title\n }\n\n #syncExternalValue() {\n const mode = resolvePickerMode(this.getAttribute('mode'))\n const external = this.value\n if (mode === 'selector') {\n const columns = resolvePickerColumns(this.range, mode, this.getAttribute('range-key') ?? undefined)\n this.#committedValue = normalizePickerIndex(external, columns[0]!.length)\n }\n else if (mode === 'multiSelector') {\n const columns = resolvePickerColumns(this.range, mode, this.getAttribute('range-key') ?? undefined)\n this.#committedValue = normalizePickerIndexes(external, columns.map(column => column.length))\n }\n else if (mode === 'date') {\n this.#committedValue = typeof external === 'string' && external\n ? external\n : currentDateValue(this.getAttribute('fields') ?? undefined)\n }\n else if (mode === 'time') {\n this.#committedValue = typeof external === 'string' ? external : ''\n }\n else {\n this.#committedValue = Array.isArray(external) ? external.map(item => String(item ?? '')) : []\n }\n if (this.#open) {\n this.#draftValue = clonePickerValue(this.#committedValue)\n this.#renderEditors()\n }\n }\n\n #renderEditors() {\n if (!this.#editors || typeof document === 'undefined') {\n return\n }\n const mode = resolvePickerMode(this.getAttribute('mode'))\n this.#title!.textContent = this.getAttribute('header-text') ?? ''\n const controls = renderPickerEditors({\n mode,\n range: this.range,\n rangeKey: this.getAttribute('range-key') ?? undefined,\n value: this.#draftValue,\n fields: this.getAttribute('fields') ?? undefined,\n start: this.getAttribute('start') ?? undefined,\n end: this.getAttribute('end') ?? undefined,\n customItem: this.getAttribute('custom-item') ?? undefined,\n level: this.getAttribute('level') ?? undefined,\n onValueChange: (value) => {\n this.#draftValue = value\n },\n onColumnChange: (column, value) => {\n dispatchMiniProgramEvent(this, 'columnchange', { column, value })\n },\n })\n this.#editors.replaceChildren(...controls)\n }\n\n #confirm() {\n const mode = resolvePickerMode(this.getAttribute('mode'))\n this.#committedValue = clonePickerValue(this.#draftValue)\n this.#close(false)\n dispatchMiniProgramEvent(this, 'change', createPickerChangeDetail(mode, clonePickerValue(this.#committedValue)))\n }\n\n #close(cancelled: boolean) {\n if (!this.#open || !this.#backdrop) {\n return\n }\n this.#backdrop.hidden = true\n this.#open = false\n if (cancelled) {\n dispatchMiniProgramEvent(this, 'cancel', {})\n }\n }\n\n #handleHostClick = (event: MouseEvent) => {\n if (this.#panel && event.composedPath().includes(this.#panel)) {\n return\n }\n this.open()\n }\n\n #handleHostKeydown = (event: KeyboardEvent) => {\n if (event.key !== 'Enter' && event.key !== ' ') {\n return\n }\n event.preventDefault()\n this.open()\n }\n}\n\nexport * from './helpers'\n"],"mappings":";;;;;;;;;AAcA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,SAAS,qBAAqB,OAA+B;CAC3D,IAAI,UAAU,QAAQ,UAAU,IAC9B,OAAO,SAAS;CAElB,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QACM;EACJ,OAAO;CACT;AACF;AAEA,SAAS,iBAAiB,OAAyB;CACjD,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAI,SAAQ,iBAAiB,IAAI,CAAC,IAAI;AAC5E;AAEA,IAAa,cAAb,cAAiC,YAAY;CAC3C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,QAAQ,CAAC,CAAE,UAAU;CAElF,cAAuB,CAAC;CACxB,oBAAoB;CACpB;CACA,oBAAoB;CACpB;CACA;CACA;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