@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,71 @@
|
|
|
1
|
+
//#region src/runtime/nativeComponents/picker/style.ts
|
|
2
|
+
const PICKER_SHADOW_STYLE = `
|
|
3
|
+
:host { position: relative; cursor: pointer; }
|
|
4
|
+
:host([disabled]) { cursor: not-allowed; opacity: 0.6; }
|
|
5
|
+
.backdrop {
|
|
6
|
+
position: fixed;
|
|
7
|
+
z-index: 1200;
|
|
8
|
+
inset: 0;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: flex-end;
|
|
11
|
+
background: rgba(0, 0, 0, 0.5);
|
|
12
|
+
}
|
|
13
|
+
.backdrop[hidden] { display: none; }
|
|
14
|
+
.panel {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
width: 100%;
|
|
17
|
+
max-height: min(72vh, 520px);
|
|
18
|
+
padding-bottom: var(--weapp-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
|
|
19
|
+
color: #000000;
|
|
20
|
+
background: #ffffff;
|
|
21
|
+
}
|
|
22
|
+
.toolbar {
|
|
23
|
+
display: grid;
|
|
24
|
+
grid-template-columns: 72px minmax(0, 1fr) 72px;
|
|
25
|
+
align-items: center;
|
|
26
|
+
min-height: 52px;
|
|
27
|
+
border-bottom: 1px solid #e5e5e5;
|
|
28
|
+
}
|
|
29
|
+
.toolbar button {
|
|
30
|
+
min-width: 0;
|
|
31
|
+
height: 52px;
|
|
32
|
+
padding: 0 16px;
|
|
33
|
+
border: 0;
|
|
34
|
+
color: #576b95;
|
|
35
|
+
background: transparent;
|
|
36
|
+
font: inherit;
|
|
37
|
+
}
|
|
38
|
+
.toolbar button:last-child { color: #07c160; }
|
|
39
|
+
.title {
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
font-size: 15px;
|
|
42
|
+
font-weight: 500;
|
|
43
|
+
text-align: center;
|
|
44
|
+
text-overflow: ellipsis;
|
|
45
|
+
white-space: nowrap;
|
|
46
|
+
}
|
|
47
|
+
.editors {
|
|
48
|
+
display: flex;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
gap: 8px;
|
|
51
|
+
min-height: 216px;
|
|
52
|
+
padding: 16px;
|
|
53
|
+
}
|
|
54
|
+
.editors select,
|
|
55
|
+
.editors input {
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
min-width: 0;
|
|
58
|
+
flex: 1;
|
|
59
|
+
border: 1px solid #d8d8d8;
|
|
60
|
+
border-radius: 4px;
|
|
61
|
+
color: inherit;
|
|
62
|
+
background: #ffffff;
|
|
63
|
+
font: inherit;
|
|
64
|
+
}
|
|
65
|
+
.editors select { padding: 6px; }
|
|
66
|
+
.editors input { align-self: center; height: 44px; padding: 0 12px; }
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
export { PICKER_SHADOW_STYLE };
|
|
71
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/picker/style.ts"],"sourcesContent":["export const PICKER_SHADOW_STYLE = `\n :host { position: relative; cursor: pointer; }\n :host([disabled]) { cursor: not-allowed; opacity: 0.6; }\n .backdrop {\n position: fixed;\n z-index: 1200;\n inset: 0;\n display: flex;\n align-items: flex-end;\n background: rgba(0, 0, 0, 0.5);\n }\n .backdrop[hidden] { display: none; }\n .panel {\n box-sizing: border-box;\n width: 100%;\n max-height: min(72vh, 520px);\n padding-bottom: var(--weapp-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));\n color: #000000;\n background: #ffffff;\n }\n .toolbar {\n display: grid;\n grid-template-columns: 72px minmax(0, 1fr) 72px;\n align-items: center;\n min-height: 52px;\n border-bottom: 1px solid #e5e5e5;\n }\n .toolbar button {\n min-width: 0;\n height: 52px;\n padding: 0 16px;\n border: 0;\n color: #576b95;\n background: transparent;\n font: inherit;\n }\n .toolbar button:last-child { color: #07c160; }\n .title {\n overflow: hidden;\n font-size: 15px;\n font-weight: 500;\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .editors {\n display: flex;\n box-sizing: border-box;\n gap: 8px;\n min-height: 216px;\n padding: 16px;\n }\n .editors select,\n .editors input {\n box-sizing: border-box;\n min-width: 0;\n flex: 1;\n border: 1px solid #d8d8d8;\n border-radius: 4px;\n color: inherit;\n background: #ffffff;\n font: inherit;\n }\n .editors select { padding: 6px; }\n .editors input { align-self: center; height: 44px; padding: 0 12px; }\n`\n"],"mappings":";AAAA,MAAa,sBAAsB"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { getNativeComponentDescriptor } from "../../../shared/nativeComponents.mjs";
|
|
2
|
+
import { resolveContainingShadowRoot } from "../helpers.mjs";
|
|
3
|
+
import { ensureNativeComponentStyle } from "../style.mjs";
|
|
4
|
+
import { PICKER_VIEW_COLUMN_CHANGE_EVENT, PICKER_VIEW_COLUMN_READY_EVENT, PICKER_VIEW_PICK_END_EVENT, PICKER_VIEW_PICK_START_EVENT } from "./helpers.mjs";
|
|
5
|
+
import { PICKER_VIEW_COLUMN_SHADOW_STYLE } from "./style.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/runtime/nativeComponents/pickerView/column.ts
|
|
8
|
+
const BaseElement = globalThis.HTMLElement ?? class {};
|
|
9
|
+
var WeappPickerViewColumn = class extends BaseElement {
|
|
10
|
+
static observedAttributes = [...getNativeComponentDescriptor("picker-view-column").attributes];
|
|
11
|
+
#scroller;
|
|
12
|
+
#slot;
|
|
13
|
+
#itemHeight = 34;
|
|
14
|
+
#selectedIndex = 0;
|
|
15
|
+
#scrollTimer;
|
|
16
|
+
#resizeObserver;
|
|
17
|
+
#picking = false;
|
|
18
|
+
#suppressScroll = false;
|
|
19
|
+
get itemCount() {
|
|
20
|
+
return this.#items.length;
|
|
21
|
+
}
|
|
22
|
+
get itemHeight() {
|
|
23
|
+
return this.#itemHeight;
|
|
24
|
+
}
|
|
25
|
+
get selectedIndex() {
|
|
26
|
+
if (!this.#scroller) return this.#selectedIndex;
|
|
27
|
+
return this.#clampIndex(Math.round(this.#scroller.scrollTop / this.#itemHeight));
|
|
28
|
+
}
|
|
29
|
+
connectedCallback() {
|
|
30
|
+
ensureNativeComponentStyle(resolveContainingShadowRoot(this));
|
|
31
|
+
this.#ensureStructure();
|
|
32
|
+
this.#syncMetrics();
|
|
33
|
+
this.#observeSize();
|
|
34
|
+
}
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
if (this.#scrollTimer) {
|
|
37
|
+
clearTimeout(this.#scrollTimer);
|
|
38
|
+
this.#scrollTimer = void 0;
|
|
39
|
+
}
|
|
40
|
+
this.#resizeObserver?.disconnect();
|
|
41
|
+
this.#resizeObserver = void 0;
|
|
42
|
+
}
|
|
43
|
+
setSelectedIndex(value) {
|
|
44
|
+
this.#selectedIndex = this.#clampIndex(value);
|
|
45
|
+
if (!this.#scroller) return;
|
|
46
|
+
this.#suppressScroll = true;
|
|
47
|
+
this.#scroller.scrollTop = this.#selectedIndex * this.#itemHeight;
|
|
48
|
+
requestAnimationFrame(() => {
|
|
49
|
+
this.#suppressScroll = false;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
get #items() {
|
|
53
|
+
return this.#slot?.assignedElements({ flatten: true }) ?? [];
|
|
54
|
+
}
|
|
55
|
+
#ensureStructure() {
|
|
56
|
+
if (this.#scroller || typeof document === "undefined") return;
|
|
57
|
+
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
58
|
+
const style = document.createElement("style");
|
|
59
|
+
style.textContent = PICKER_VIEW_COLUMN_SHADOW_STYLE;
|
|
60
|
+
const scroller = document.createElement("div");
|
|
61
|
+
scroller.className = "scroller";
|
|
62
|
+
const leading = document.createElement("div");
|
|
63
|
+
leading.className = "spacer";
|
|
64
|
+
const slot = document.createElement("slot");
|
|
65
|
+
const trailing = document.createElement("div");
|
|
66
|
+
trailing.className = "spacer";
|
|
67
|
+
scroller.append(leading, slot, trailing);
|
|
68
|
+
root.append(style, scroller);
|
|
69
|
+
slot.addEventListener("slotchange", () => this.#syncMetrics());
|
|
70
|
+
scroller.addEventListener("pointerdown", this.#handlePickStart);
|
|
71
|
+
scroller.addEventListener("pointerup", this.#schedulePickEnd);
|
|
72
|
+
scroller.addEventListener("pointercancel", this.#schedulePickEnd);
|
|
73
|
+
scroller.addEventListener("scroll", this.#handleScroll, { passive: true });
|
|
74
|
+
this.#scroller = scroller;
|
|
75
|
+
this.#slot = slot;
|
|
76
|
+
}
|
|
77
|
+
#syncMetrics() {
|
|
78
|
+
const height = this.#items[0]?.getBoundingClientRect().height;
|
|
79
|
+
this.#itemHeight = height && Number.isFinite(height) && height > 0 ? height : 34;
|
|
80
|
+
this.style.setProperty("--weapp-picker-view-item-height", `${this.#itemHeight}px`);
|
|
81
|
+
this.setSelectedIndex(this.#selectedIndex);
|
|
82
|
+
this.#dispatchInternal(PICKER_VIEW_COLUMN_READY_EVENT);
|
|
83
|
+
}
|
|
84
|
+
#observeSize() {
|
|
85
|
+
if (typeof ResizeObserver === "undefined" || !this.#scroller || this.#resizeObserver) return;
|
|
86
|
+
this.#resizeObserver = new ResizeObserver(() => this.#syncMetrics());
|
|
87
|
+
this.#resizeObserver.observe(this.#scroller);
|
|
88
|
+
}
|
|
89
|
+
#clampIndex(value) {
|
|
90
|
+
return Math.min(Math.max(0, Number.isFinite(value) ? Math.trunc(value) : 0), Math.max(0, this.itemCount - 1));
|
|
91
|
+
}
|
|
92
|
+
#dispatchInternal(name, detail = {}) {
|
|
93
|
+
this.dispatchEvent(new CustomEvent(name, {
|
|
94
|
+
bubbles: true,
|
|
95
|
+
composed: true,
|
|
96
|
+
detail
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
#handlePickStart = () => {
|
|
100
|
+
if (this.#picking || this.#suppressScroll) return;
|
|
101
|
+
this.#picking = true;
|
|
102
|
+
this.#dispatchInternal(PICKER_VIEW_PICK_START_EVENT);
|
|
103
|
+
};
|
|
104
|
+
#handleScroll = () => {
|
|
105
|
+
if (this.#suppressScroll) return;
|
|
106
|
+
this.#handlePickStart();
|
|
107
|
+
this.#selectedIndex = this.selectedIndex;
|
|
108
|
+
this.#dispatchInternal(PICKER_VIEW_COLUMN_CHANGE_EVENT, {
|
|
109
|
+
value: this.#selectedIndex,
|
|
110
|
+
phase: "changing"
|
|
111
|
+
});
|
|
112
|
+
this.#schedulePickEnd();
|
|
113
|
+
};
|
|
114
|
+
#schedulePickEnd = () => {
|
|
115
|
+
if (this.#scrollTimer) clearTimeout(this.#scrollTimer);
|
|
116
|
+
this.#scrollTimer = globalThis.setTimeout(() => {
|
|
117
|
+
this.#scrollTimer = void 0;
|
|
118
|
+
this.#selectedIndex = this.selectedIndex;
|
|
119
|
+
this.setSelectedIndex(this.#selectedIndex);
|
|
120
|
+
this.#dispatchInternal(PICKER_VIEW_COLUMN_CHANGE_EVENT, {
|
|
121
|
+
value: this.#selectedIndex,
|
|
122
|
+
phase: "end"
|
|
123
|
+
});
|
|
124
|
+
if (this.#picking) {
|
|
125
|
+
this.#picking = false;
|
|
126
|
+
this.#dispatchInternal(PICKER_VIEW_PICK_END_EVENT);
|
|
127
|
+
}
|
|
128
|
+
}, 100);
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
export { WeappPickerViewColumn };
|
|
134
|
+
//# sourceMappingURL=column.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column.mjs","names":["#items","#itemHeight","#scroller","#selectedIndex","#clampIndex","#ensureStructure","#syncMetrics","#observeSize","#scrollTimer","#resizeObserver","#suppressScroll","#slot","#handlePickStart","#schedulePickEnd","#handleScroll","#dispatchInternal","#picking"],"sources":["../../../../src/runtime/nativeComponents/pickerView/column.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { resolveContainingShadowRoot } from '../helpers'\nimport { ensureNativeComponentStyle } from '../style'\nimport {\n PICKER_VIEW_COLUMN_CHANGE_EVENT,\n PICKER_VIEW_COLUMN_READY_EVENT,\n PICKER_VIEW_PICK_END_EVENT,\n PICKER_VIEW_PICK_START_EVENT,\n} from './helpers'\nimport { PICKER_VIEW_COLUMN_SHADOW_STYLE } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nexport class WeappPickerViewColumn extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('picker-view-column')!.attributes]\n\n #scroller?: HTMLDivElement\n #slot?: HTMLSlotElement\n #itemHeight = 34\n #selectedIndex = 0\n #scrollTimer?: ReturnType<typeof globalThis.setTimeout>\n #resizeObserver?: ResizeObserver\n #picking = false\n #suppressScroll = false\n\n get itemCount() {\n return this.#items.length\n }\n\n get itemHeight() {\n return this.#itemHeight\n }\n\n get selectedIndex() {\n if (!this.#scroller) {\n return this.#selectedIndex\n }\n return this.#clampIndex(Math.round(this.#scroller.scrollTop / this.#itemHeight))\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncMetrics()\n this.#observeSize()\n }\n\n disconnectedCallback() {\n if (this.#scrollTimer) {\n clearTimeout(this.#scrollTimer)\n this.#scrollTimer = undefined\n }\n this.#resizeObserver?.disconnect()\n this.#resizeObserver = undefined\n }\n\n setSelectedIndex(value: number) {\n this.#selectedIndex = this.#clampIndex(value)\n if (!this.#scroller) {\n return\n }\n this.#suppressScroll = true\n this.#scroller.scrollTop = this.#selectedIndex * this.#itemHeight\n requestAnimationFrame(() => {\n this.#suppressScroll = false\n })\n }\n\n get #items() {\n return this.#slot?.assignedElements({ flatten: true }) ?? []\n }\n\n #ensureStructure() {\n if (this.#scroller || 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_VIEW_COLUMN_SHADOW_STYLE\n const scroller = document.createElement('div')\n scroller.className = 'scroller'\n const leading = document.createElement('div')\n leading.className = 'spacer'\n const slot = document.createElement('slot')\n const trailing = document.createElement('div')\n trailing.className = 'spacer'\n scroller.append(leading, slot, trailing)\n root.append(style, scroller)\n slot.addEventListener('slotchange', () => this.#syncMetrics())\n scroller.addEventListener('pointerdown', this.#handlePickStart)\n scroller.addEventListener('pointerup', this.#schedulePickEnd)\n scroller.addEventListener('pointercancel', this.#schedulePickEnd)\n scroller.addEventListener('scroll', this.#handleScroll, { passive: true })\n this.#scroller = scroller\n this.#slot = slot\n }\n\n #syncMetrics() {\n const first = this.#items[0] as HTMLElement | undefined\n const height = first?.getBoundingClientRect().height\n this.#itemHeight = height && Number.isFinite(height) && height > 0 ? height : 34\n this.style.setProperty('--weapp-picker-view-item-height', `${this.#itemHeight}px`)\n this.setSelectedIndex(this.#selectedIndex)\n this.#dispatchInternal(PICKER_VIEW_COLUMN_READY_EVENT)\n }\n\n #observeSize() {\n if (typeof ResizeObserver === 'undefined' || !this.#scroller || this.#resizeObserver) {\n return\n }\n this.#resizeObserver = new ResizeObserver(() => this.#syncMetrics())\n this.#resizeObserver.observe(this.#scroller)\n }\n\n #clampIndex(value: number) {\n const index = Number.isFinite(value) ? Math.trunc(value) : 0\n return Math.min(Math.max(0, index), Math.max(0, this.itemCount - 1))\n }\n\n #dispatchInternal(name: string, detail: unknown = {}) {\n this.dispatchEvent(new CustomEvent(name, {\n bubbles: true,\n composed: true,\n detail,\n }))\n }\n\n #handlePickStart = () => {\n if (this.#picking || this.#suppressScroll) {\n return\n }\n this.#picking = true\n this.#dispatchInternal(PICKER_VIEW_PICK_START_EVENT)\n }\n\n #handleScroll = () => {\n if (this.#suppressScroll) {\n return\n }\n this.#handlePickStart()\n this.#selectedIndex = this.selectedIndex\n this.#dispatchInternal(PICKER_VIEW_COLUMN_CHANGE_EVENT, {\n value: this.#selectedIndex,\n phase: 'changing',\n })\n this.#schedulePickEnd()\n }\n\n #schedulePickEnd = () => {\n if (this.#scrollTimer) {\n clearTimeout(this.#scrollTimer)\n }\n this.#scrollTimer = globalThis.setTimeout(() => {\n this.#scrollTimer = undefined\n this.#selectedIndex = this.selectedIndex\n this.setSelectedIndex(this.#selectedIndex)\n this.#dispatchInternal(PICKER_VIEW_COLUMN_CHANGE_EVENT, {\n value: this.#selectedIndex,\n phase: 'end',\n })\n if (this.#picking) {\n this.#picking = false\n this.#dispatchInternal(PICKER_VIEW_PICK_END_EVENT)\n }\n }, 100)\n }\n}\n"],"mappings":";;;;;;;AAWA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAa,wBAAb,cAA2C,YAAY;CACrD,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,oBAAoB,CAAC,CAAE,UAAU;CAE9F;CACA;CACA,cAAc;CACd,iBAAiB;CACjB;CACA;CACA,WAAW;CACX,kBAAkB;CAElB,IAAI,YAAY;EACd,OAAO,KAAKA,OAAO;CACrB;CAEA,IAAI,aAAa;EACf,OAAO,KAAKC;CACd;CAEA,IAAI,gBAAgB;EAClB,IAAI,CAAC,KAAKC,WACR,OAAO,KAAKC;EAEd,OAAO,KAAKC,YAAY,KAAK,MAAM,KAAKF,UAAU,YAAY,KAAKD,WAAW,CAAC;CACjF;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAKI,iBAAiB;EACtB,KAAKC,aAAa;EAClB,KAAKC,aAAa;CACpB;CAEA,uBAAuB;EACrB,IAAI,KAAKC,cAAc;GACrB,aAAa,KAAKA,YAAY;GAC9B,KAAKA,eAAe;EACtB;EACA,KAAKC,iBAAiB,WAAW;EACjC,KAAKA,kBAAkB;CACzB;CAEA,iBAAiB,OAAe;EAC9B,KAAKN,iBAAiB,KAAKC,YAAY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ponents/pickerView/helpers.ts
|
|
2
|
+
const PICKER_VIEW_COLUMN_CHANGE_EVENT = "weapp-picker-view-column-change";
|
|
3
|
+
const PICKER_VIEW_COLUMN_READY_EVENT = "weapp-picker-view-column-ready";
|
|
4
|
+
const PICKER_VIEW_PICK_START_EVENT = "weapp-picker-view-pick-start";
|
|
5
|
+
const PICKER_VIEW_PICK_END_EVENT = "weapp-picker-view-pick-end";
|
|
6
|
+
function normalizeColumnIndex(value, itemCount) {
|
|
7
|
+
const numeric = Number(value);
|
|
8
|
+
return Math.min(Math.max(0, Number.isFinite(numeric) ? Math.trunc(numeric) : 0), Math.max(0, itemCount - 1));
|
|
9
|
+
}
|
|
10
|
+
function normalizePickerViewValue(value, columnLengths) {
|
|
11
|
+
const indexes = Array.isArray(value) ? value : [];
|
|
12
|
+
return columnLengths.map((length, column) => normalizeColumnIndex(indexes[column], length));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { PICKER_VIEW_COLUMN_CHANGE_EVENT, PICKER_VIEW_COLUMN_READY_EVENT, PICKER_VIEW_PICK_END_EVENT, PICKER_VIEW_PICK_START_EVENT, normalizePickerViewValue };
|
|
17
|
+
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/pickerView/helpers.ts"],"sourcesContent":["export const PICKER_VIEW_COLUMN_CHANGE_EVENT = 'weapp-picker-view-column-change'\nexport const PICKER_VIEW_COLUMN_READY_EVENT = 'weapp-picker-view-column-ready'\nexport const PICKER_VIEW_PICK_START_EVENT = 'weapp-picker-view-pick-start'\nexport const PICKER_VIEW_PICK_END_EVENT = 'weapp-picker-view-pick-end'\n\nexport interface PickerViewColumnChangeDetail {\n value: number\n phase: 'changing' | 'end'\n}\n\nfunction normalizeColumnIndex(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 normalizePickerViewValue(value: unknown, columnLengths: number[]) {\n const indexes = Array.isArray(value) ? value : []\n return columnLengths.map((length, column) => normalizeColumnIndex(indexes[column], length))\n}\n"],"mappings":";AAAA,MAAa,kCAAkC;AAC/C,MAAa,iCAAiC;AAC9C,MAAa,+BAA+B;AAC5C,MAAa,6BAA6B;AAO1C,SAAS,qBAAqB,OAAgB,WAAmB;CAC/D,MAAM,UAAU,OAAO,KAAK;CAE5B,OAAO,KAAK,IAAI,KAAK,IAAI,GADX,OAAO,SAAS,OAAO,IAAI,KAAK,MAAM,OAAO,IAAI,CAC9B,GAAG,KAAK,IAAI,GAAG,YAAY,CAAC,CAAC;AAChE;AAEA,SAAgB,yBAAyB,OAAgB,eAAyB;CAChF,MAAM,UAAU,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC;CAChD,OAAO,cAAc,KAAK,QAAQ,WAAW,qBAAqB,QAAQ,SAAS,MAAM,CAAC;AAC5F"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { getNativeComponentDescriptor } from "../../../shared/nativeComponents.mjs";
|
|
2
|
+
import { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from "../helpers.mjs";
|
|
3
|
+
import { ensureNativeComponentStyle } from "../style.mjs";
|
|
4
|
+
import { PICKER_VIEW_COLUMN_CHANGE_EVENT, PICKER_VIEW_COLUMN_READY_EVENT, PICKER_VIEW_PICK_END_EVENT, PICKER_VIEW_PICK_START_EVENT, normalizePickerViewValue } from "./helpers.mjs";
|
|
5
|
+
import { PICKER_VIEW_SHADOW_STYLE } from "./style.mjs";
|
|
6
|
+
import { WeappPickerViewColumn } from "./column.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/runtime/nativeComponents/pickerView/index.ts
|
|
9
|
+
const BaseElement = globalThis.HTMLElement ?? class {};
|
|
10
|
+
function parsePickerViewValue(value) {
|
|
11
|
+
if (!value) return [];
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(value);
|
|
14
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
15
|
+
} catch {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
var WeappPickerView = class extends BaseElement {
|
|
20
|
+
static observedAttributes = [...getNativeComponentDescriptor("picker-view").attributes];
|
|
21
|
+
#value = [];
|
|
22
|
+
#valuePropertySet = false;
|
|
23
|
+
#columns = [];
|
|
24
|
+
#slot;
|
|
25
|
+
#indicator;
|
|
26
|
+
#masks = [];
|
|
27
|
+
#lastEmittedValue = [];
|
|
28
|
+
get value() {
|
|
29
|
+
return this.#valuePropertySet ? this.#value : parsePickerViewValue(this.getAttribute("value"));
|
|
30
|
+
}
|
|
31
|
+
set value(value) {
|
|
32
|
+
this.#valuePropertySet = true;
|
|
33
|
+
this.#value = value;
|
|
34
|
+
this.#syncColumns();
|
|
35
|
+
}
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
ensureNativeComponentStyle(resolveContainingShadowRoot(this));
|
|
38
|
+
this.#ensureStructure();
|
|
39
|
+
this.addEventListener(PICKER_VIEW_COLUMN_CHANGE_EVENT, this.#handleColumnChange);
|
|
40
|
+
this.addEventListener(PICKER_VIEW_COLUMN_READY_EVENT, this.#handleColumnReady);
|
|
41
|
+
this.addEventListener(PICKER_VIEW_PICK_START_EVENT, this.#handlePickStart);
|
|
42
|
+
this.addEventListener(PICKER_VIEW_PICK_END_EVENT, this.#handlePickEnd);
|
|
43
|
+
this.#syncColumns();
|
|
44
|
+
this.#syncStyles();
|
|
45
|
+
}
|
|
46
|
+
disconnectedCallback() {
|
|
47
|
+
this.removeEventListener(PICKER_VIEW_COLUMN_CHANGE_EVENT, this.#handleColumnChange);
|
|
48
|
+
this.removeEventListener(PICKER_VIEW_COLUMN_READY_EVENT, this.#handleColumnReady);
|
|
49
|
+
this.removeEventListener(PICKER_VIEW_PICK_START_EVENT, this.#handlePickStart);
|
|
50
|
+
this.removeEventListener(PICKER_VIEW_PICK_END_EVENT, this.#handlePickEnd);
|
|
51
|
+
}
|
|
52
|
+
attributeChangedCallback(name) {
|
|
53
|
+
if (name === "value") this.#syncColumns();
|
|
54
|
+
else this.#syncStyles();
|
|
55
|
+
}
|
|
56
|
+
#ensureStructure() {
|
|
57
|
+
if (this.#slot || typeof document === "undefined") return;
|
|
58
|
+
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
59
|
+
const style = document.createElement("style");
|
|
60
|
+
style.textContent = PICKER_VIEW_SHADOW_STYLE;
|
|
61
|
+
const viewport = document.createElement("div");
|
|
62
|
+
viewport.className = "viewport";
|
|
63
|
+
const slot = document.createElement("slot");
|
|
64
|
+
const topMask = document.createElement("div");
|
|
65
|
+
topMask.className = "mask mask--top";
|
|
66
|
+
const bottomMask = document.createElement("div");
|
|
67
|
+
bottomMask.className = "mask mask--bottom";
|
|
68
|
+
const indicator = document.createElement("div");
|
|
69
|
+
indicator.className = "indicator";
|
|
70
|
+
viewport.append(slot, topMask, bottomMask, indicator);
|
|
71
|
+
root.append(style, viewport);
|
|
72
|
+
slot.addEventListener("slotchange", () => this.#syncColumns());
|
|
73
|
+
this.#slot = slot;
|
|
74
|
+
this.#indicator = indicator;
|
|
75
|
+
this.#masks = [topMask, bottomMask];
|
|
76
|
+
}
|
|
77
|
+
#syncColumns() {
|
|
78
|
+
if (!this.#slot) return;
|
|
79
|
+
this.#columns = this.#slot.assignedElements({ flatten: true }).filter((element) => element.tagName.toLowerCase() === "weapp-picker-view-column");
|
|
80
|
+
const next = normalizePickerViewValue(this.value, this.#columns.map((column) => column.itemCount));
|
|
81
|
+
this.#columns.forEach((column, index) => column.setSelectedIndex(next[index]));
|
|
82
|
+
const itemHeight = this.#columns[0]?.itemHeight;
|
|
83
|
+
if (itemHeight) this.style.setProperty("--weapp-picker-view-item-height", `${itemHeight}px`);
|
|
84
|
+
this.#lastEmittedValue = [...next];
|
|
85
|
+
}
|
|
86
|
+
#syncStyles() {
|
|
87
|
+
if (!this.#indicator) return;
|
|
88
|
+
this.#indicator.style.cssText = this.getAttribute("indicator-style") ?? "";
|
|
89
|
+
this.#indicator.className = `indicator ${this.getAttribute("indicator-class") ?? ""}`.trim();
|
|
90
|
+
const maskStyle = this.getAttribute("mask-style") ?? "";
|
|
91
|
+
const maskClass = this.getAttribute("mask-class") ?? "";
|
|
92
|
+
this.#masks.forEach((mask, index) => {
|
|
93
|
+
mask.style.cssText = maskStyle;
|
|
94
|
+
mask.className = `mask mask--${index === 0 ? "top" : "bottom"} ${maskClass}`.trim();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
#handleColumnChange = (event) => {
|
|
98
|
+
event.stopPropagation();
|
|
99
|
+
const column = event.target;
|
|
100
|
+
const columnIndex = this.#columns.indexOf(column);
|
|
101
|
+
if (columnIndex < 0) return;
|
|
102
|
+
const next = normalizePickerViewValue(this.#columns.map((item) => item.selectedIndex), this.#columns.map((item) => item.itemCount));
|
|
103
|
+
next[columnIndex] = event.detail.value;
|
|
104
|
+
const immediate = readBooleanAttribute(this, "immediate-change");
|
|
105
|
+
if (immediate && event.detail.phase === "changing" || !immediate && event.detail.phase === "end") this.#emitChange(next);
|
|
106
|
+
};
|
|
107
|
+
#handleColumnReady = (event) => {
|
|
108
|
+
event.stopPropagation();
|
|
109
|
+
this.#syncColumns();
|
|
110
|
+
};
|
|
111
|
+
#emitChange(value) {
|
|
112
|
+
if (value.length === this.#lastEmittedValue.length && value.every((item, index) => item === this.#lastEmittedValue[index])) return;
|
|
113
|
+
this.#lastEmittedValue = [...value];
|
|
114
|
+
dispatchMiniProgramEvent(this, "change", { value });
|
|
115
|
+
}
|
|
116
|
+
#handlePickStart = (event) => {
|
|
117
|
+
event.stopPropagation();
|
|
118
|
+
dispatchMiniProgramEvent(this, "pickstart", {});
|
|
119
|
+
};
|
|
120
|
+
#handlePickEnd = (event) => {
|
|
121
|
+
event.stopPropagation();
|
|
122
|
+
dispatchMiniProgramEvent(this, "pickend", {});
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
export { PICKER_VIEW_COLUMN_CHANGE_EVENT, PICKER_VIEW_COLUMN_READY_EVENT, PICKER_VIEW_PICK_END_EVENT, PICKER_VIEW_PICK_START_EVENT, WeappPickerView, WeappPickerViewColumn, normalizePickerViewValue };
|
|
128
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#valuePropertySet","#value","#syncColumns","#ensureStructure","#handleColumnChange","#handleColumnReady","#handlePickStart","#handlePickEnd","#syncStyles","#slot","#indicator","#masks","#columns","#lastEmittedValue","#emitChange"],"sources":["../../../../src/runtime/nativeComponents/pickerView/index.ts"],"sourcesContent":["import type { PickerViewColumnChangeDetail } from './helpers'\nimport { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from '../helpers'\nimport { ensureNativeComponentStyle } from '../style'\nimport { WeappPickerViewColumn } from './column'\nimport {\n normalizePickerViewValue,\n PICKER_VIEW_COLUMN_CHANGE_EVENT,\n PICKER_VIEW_COLUMN_READY_EVENT,\n PICKER_VIEW_PICK_END_EVENT,\n PICKER_VIEW_PICK_START_EVENT,\n} from './helpers'\nimport { PICKER_VIEW_SHADOW_STYLE } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nfunction parsePickerViewValue(value: string | null) {\n if (!value) {\n return []\n }\n try {\n const parsed = JSON.parse(value) as unknown\n return Array.isArray(parsed) ? parsed : []\n }\n catch {\n return []\n }\n}\n\nexport class WeappPickerView extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('picker-view')!.attributes]\n\n #value: unknown = []\n #valuePropertySet = false\n #columns: WeappPickerViewColumn[] = []\n #slot?: HTMLSlotElement\n #indicator?: HTMLDivElement\n #masks: HTMLDivElement[] = []\n #lastEmittedValue: number[] = []\n\n get value() {\n return this.#valuePropertySet ? this.#value : parsePickerViewValue(this.getAttribute('value'))\n }\n\n set value(value: unknown) {\n this.#valuePropertySet = true\n this.#value = value\n this.#syncColumns()\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.addEventListener(PICKER_VIEW_COLUMN_CHANGE_EVENT, this.#handleColumnChange as EventListener)\n this.addEventListener(PICKER_VIEW_COLUMN_READY_EVENT, this.#handleColumnReady)\n this.addEventListener(PICKER_VIEW_PICK_START_EVENT, this.#handlePickStart)\n this.addEventListener(PICKER_VIEW_PICK_END_EVENT, this.#handlePickEnd)\n this.#syncColumns()\n this.#syncStyles()\n }\n\n disconnectedCallback() {\n this.removeEventListener(PICKER_VIEW_COLUMN_CHANGE_EVENT, this.#handleColumnChange as EventListener)\n this.removeEventListener(PICKER_VIEW_COLUMN_READY_EVENT, this.#handleColumnReady)\n this.removeEventListener(PICKER_VIEW_PICK_START_EVENT, this.#handlePickStart)\n this.removeEventListener(PICKER_VIEW_PICK_END_EVENT, this.#handlePickEnd)\n }\n\n attributeChangedCallback(name: string) {\n if (name === 'value') {\n this.#syncColumns()\n }\n else {\n this.#syncStyles()\n }\n }\n\n #ensureStructure() {\n if (this.#slot || 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_VIEW_SHADOW_STYLE\n const viewport = document.createElement('div')\n viewport.className = 'viewport'\n const slot = document.createElement('slot')\n const topMask = document.createElement('div')\n topMask.className = 'mask mask--top'\n const bottomMask = document.createElement('div')\n bottomMask.className = 'mask mask--bottom'\n const indicator = document.createElement('div')\n indicator.className = 'indicator'\n viewport.append(slot, topMask, bottomMask, indicator)\n root.append(style, viewport)\n slot.addEventListener('slotchange', () => this.#syncColumns())\n this.#slot = slot\n this.#indicator = indicator\n this.#masks = [topMask, bottomMask]\n }\n\n #syncColumns() {\n if (!this.#slot) {\n return\n }\n this.#columns = this.#slot.assignedElements({ flatten: true })\n .filter((element): element is WeappPickerViewColumn => element.tagName.toLowerCase() === 'weapp-picker-view-column')\n const next = normalizePickerViewValue(this.value, this.#columns.map(column => column.itemCount))\n this.#columns.forEach((column, index) => column.setSelectedIndex(next[index]!))\n const itemHeight = this.#columns[0]?.itemHeight\n if (itemHeight) {\n this.style.setProperty('--weapp-picker-view-item-height', `${itemHeight}px`)\n }\n this.#lastEmittedValue = [...next]\n }\n\n #syncStyles() {\n if (!this.#indicator) {\n return\n }\n this.#indicator.style.cssText = this.getAttribute('indicator-style') ?? ''\n this.#indicator.className = `indicator ${this.getAttribute('indicator-class') ?? ''}`.trim()\n const maskStyle = this.getAttribute('mask-style') ?? ''\n const maskClass = this.getAttribute('mask-class') ?? ''\n this.#masks.forEach((mask, index) => {\n mask.style.cssText = maskStyle\n mask.className = `mask mask--${index === 0 ? 'top' : 'bottom'} ${maskClass}`.trim()\n })\n }\n\n #handleColumnChange = (event: CustomEvent<PickerViewColumnChangeDetail>) => {\n event.stopPropagation()\n const column = event.target as WeappPickerViewColumn\n const columnIndex = this.#columns.indexOf(column)\n if (columnIndex < 0) {\n return\n }\n const next = normalizePickerViewValue(\n this.#columns.map(item => item.selectedIndex),\n this.#columns.map(item => item.itemCount),\n )\n next[columnIndex] = event.detail.value\n const immediate = readBooleanAttribute(this, 'immediate-change')\n if ((immediate && event.detail.phase === 'changing') || (!immediate && event.detail.phase === 'end')) {\n this.#emitChange(next)\n }\n }\n\n #handleColumnReady = (event: Event) => {\n event.stopPropagation()\n this.#syncColumns()\n }\n\n #emitChange(value: number[]) {\n if (value.length === this.#lastEmittedValue.length && value.every((item, index) => item === this.#lastEmittedValue[index])) {\n return\n }\n this.#lastEmittedValue = [...value]\n dispatchMiniProgramEvent(this, 'change', { value })\n }\n\n #handlePickStart = (event: Event) => {\n event.stopPropagation()\n dispatchMiniProgramEvent(this, 'pickstart', {})\n }\n\n #handlePickEnd = (event: Event) => {\n event.stopPropagation()\n dispatchMiniProgramEvent(this, 'pickend', {})\n }\n}\n\nexport { WeappPickerViewColumn }\nexport * from './helpers'\n"],"mappings":";;;;;;;;AAcA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,SAAS,qBAAqB,OAAsB;CAClD,IAAI,CAAC,OACH,OAAO,CAAC;CAEV,IAAI;EACF,MAAM,SAAS,KAAK,MAAM,KAAK;EAC/B,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC;CAC3C,QACM;EACJ,OAAO,CAAC;CACV;AACF;AAEA,IAAa,kBAAb,cAAqC,YAAY;CAC/C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,aAAa,CAAC,CAAE,UAAU;CAEvF,SAAkB,CAAC;CACnB,oBAAoB;CACpB,WAAoC,CAAC;CACrC;CACA;CACA,SAA2B,CAAC;CAC5B,oBAA8B,CAAC;CAE/B,IAAI,QAAQ;EACV,OAAO,KAAKA,oBAAoB,KAAKC,SAAS,qBAAqB,KAAK,aAAa,OAAO,CAAC;CAC/F;CAEA,IAAI,MAAM,OAAgB;EACxB,KAAKD,oBAAoB;EACzB,KAAKC,SAAS;EACd,KAAKC,aAAa;CACpB;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAKC,iBAAiB;EACtB,KAAK,iBAAiB,iCAAiC,KAAKC,mBAAoC;EAChG,KAAK,iBAAiB,gCAAgC,KAAKC,kBAAkB;EAC7E,KAAK,iBAAiB,8BAA8B,KAAKC,gBAAgB;EACzE,KAAK,iBAAiB,4BAA4B,KAAKC,cAAc;EACrE,KAAKL,aAAa;EAClB,KAAKM,YAAY;CACnB;CAEA,uBAAuB;EACrB,KAAK,oBAAoB,iCAAiC,KAAKJ,mBAAoC;EACnG,KAAK,oBAAoB,gCAAgC,KAAKC,kBAAkB;EAChF,KAAK,oBAAoB,8BAA8B,KAAKC,gBAAgB;EAC5E,KAAK,oBAAoB,4BAA4B,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B;EACtB,yBAAyB,MAAM,WAAW,CAAC,CAAC;CAC9C;AACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/runtime/nativeComponents/pickerView/style.ts
|
|
2
|
+
const PICKER_VIEW_SHADOW_STYLE = `
|
|
3
|
+
:host { position: relative; min-width: 0; }
|
|
4
|
+
.viewport { position: relative; display: flex; width: 100%; height: 100%; overflow: hidden; }
|
|
5
|
+
slot { display: flex; width: 100%; height: 100%; }
|
|
6
|
+
::slotted(weapp-picker-view-column) { min-width: 0; flex: 1; }
|
|
7
|
+
.mask,
|
|
8
|
+
.indicator { position: absolute; right: 0; left: 0; pointer-events: none; }
|
|
9
|
+
.mask--top {
|
|
10
|
+
top: 0;
|
|
11
|
+
bottom: 50%;
|
|
12
|
+
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.35));
|
|
13
|
+
}
|
|
14
|
+
.mask--bottom {
|
|
15
|
+
top: 50%;
|
|
16
|
+
bottom: 0;
|
|
17
|
+
background: linear-gradient(to top, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.35));
|
|
18
|
+
}
|
|
19
|
+
.indicator {
|
|
20
|
+
top: 50%;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
height: var(--weapp-picker-view-item-height, 34px);
|
|
23
|
+
border-top: 1px solid #e5e5e5;
|
|
24
|
+
border-bottom: 1px solid #e5e5e5;
|
|
25
|
+
transform: translateY(-50%);
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const PICKER_VIEW_COLUMN_SHADOW_STYLE = `
|
|
29
|
+
:host { min-width: 0; overflow: hidden; }
|
|
30
|
+
.scroller {
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
overflow-x: hidden;
|
|
35
|
+
overflow-y: auto;
|
|
36
|
+
overscroll-behavior: contain;
|
|
37
|
+
scrollbar-width: none;
|
|
38
|
+
scroll-snap-type: y mandatory;
|
|
39
|
+
touch-action: pan-y;
|
|
40
|
+
}
|
|
41
|
+
.scroller::-webkit-scrollbar { display: none; }
|
|
42
|
+
.spacer { width: 1px; height: calc((100% - var(--weapp-picker-view-item-height, 34px)) / 2); }
|
|
43
|
+
slot { display: block; }
|
|
44
|
+
::slotted(*) {
|
|
45
|
+
box-sizing: border-box;
|
|
46
|
+
height: var(--weapp-picker-view-item-height, 34px);
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
line-height: var(--weapp-picker-view-item-height, 34px);
|
|
49
|
+
text-align: center;
|
|
50
|
+
text-overflow: ellipsis;
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
scroll-snap-align: center;
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { PICKER_VIEW_COLUMN_SHADOW_STYLE, PICKER_VIEW_SHADOW_STYLE };
|
|
58
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/pickerView/style.ts"],"sourcesContent":["export const PICKER_VIEW_SHADOW_STYLE = `\n :host { position: relative; min-width: 0; }\n .viewport { position: relative; display: flex; width: 100%; height: 100%; overflow: hidden; }\n slot { display: flex; width: 100%; height: 100%; }\n ::slotted(weapp-picker-view-column) { min-width: 0; flex: 1; }\n .mask,\n .indicator { position: absolute; right: 0; left: 0; pointer-events: none; }\n .mask--top {\n top: 0;\n bottom: 50%;\n background: linear-gradient(to bottom, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.35));\n }\n .mask--bottom {\n top: 50%;\n bottom: 0;\n background: linear-gradient(to top, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.35));\n }\n .indicator {\n top: 50%;\n box-sizing: border-box;\n height: var(--weapp-picker-view-item-height, 34px);\n border-top: 1px solid #e5e5e5;\n border-bottom: 1px solid #e5e5e5;\n transform: translateY(-50%);\n }\n`\n\nexport const PICKER_VIEW_COLUMN_SHADOW_STYLE = `\n :host { min-width: 0; overflow: hidden; }\n .scroller {\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n overflow-x: hidden;\n overflow-y: auto;\n overscroll-behavior: contain;\n scrollbar-width: none;\n scroll-snap-type: y mandatory;\n touch-action: pan-y;\n }\n .scroller::-webkit-scrollbar { display: none; }\n .spacer { width: 1px; height: calc((100% - var(--weapp-picker-view-item-height, 34px)) / 2); }\n slot { display: block; }\n ::slotted(*) {\n box-sizing: border-box;\n height: var(--weapp-picker-view-item-height, 34px);\n overflow: hidden;\n line-height: var(--weapp-picker-view-item-height, 34px);\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap;\n scroll-snap-align: center;\n }\n`\n"],"mappings":";AAAA,MAAa,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BxC,MAAa,kCAAkC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolveContainingShadowRoot } from "./helpers.mjs";
|
|
2
|
+
import { ensureNativeComponentStyle } from "./style.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/nativeComponents/primitives.ts
|
|
5
|
+
const BaseElement = globalThis.HTMLElement ?? class {};
|
|
6
|
+
var StyledNativeElement = class extends BaseElement {
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
ensureNativeComponentStyle(resolveContainingShadowRoot(this));
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var WeappView = class extends StyledNativeElement {};
|
|
12
|
+
var WeappText = class extends StyledNativeElement {};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { WeappText, WeappView };
|
|
16
|
+
//# sourceMappingURL=primitives.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.mjs","names":[],"sources":["../../../src/runtime/nativeComponents/primitives.ts"],"sourcesContent":["import { resolveContainingShadowRoot } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nclass StyledNativeElement extends BaseElement {\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n }\n}\n\nexport class WeappView extends StyledNativeElement {}\nexport class WeappText extends StyledNativeElement {}\n"],"mappings":";;;;AAGA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAM,sBAAN,cAAkC,YAAY;CAC5C,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;CAC9D;AACF;AAEA,IAAa,YAAb,cAA+B,oBAAoB,CAAC;AACpD,IAAa,YAAb,cAA+B,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/runtime/nativeComponents/progress/helpers.ts
|
|
2
|
+
function finiteNumber(value, fallback) {
|
|
3
|
+
const numeric = Number(value);
|
|
4
|
+
return Number.isFinite(numeric) ? numeric : fallback;
|
|
5
|
+
}
|
|
6
|
+
function nonNegativeNumber(value, fallback) {
|
|
7
|
+
return Math.max(0, finiteNumber(value, fallback));
|
|
8
|
+
}
|
|
9
|
+
function resolveProgressConfig(input = {}) {
|
|
10
|
+
const activeMode = input.activeMode === "forwards" ? "forwards" : "backwards";
|
|
11
|
+
return {
|
|
12
|
+
percent: Math.min(100, Math.max(0, finiteNumber(input.percent, 0))),
|
|
13
|
+
strokeWidth: nonNegativeNumber(input.strokeWidth, 6),
|
|
14
|
+
duration: nonNegativeNumber(input.duration, 30),
|
|
15
|
+
borderRadius: nonNegativeNumber(input.borderRadius, 0),
|
|
16
|
+
fontSize: nonNegativeNumber(input.fontSize, 16),
|
|
17
|
+
activeMode
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function resolveProgressAnimationDuration(start, end, durationPerPercent) {
|
|
21
|
+
return Math.abs(end - start) * durationPerPercent;
|
|
22
|
+
}
|
|
23
|
+
function createProgressActiveEndDetail() {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { createProgressActiveEndDetail, resolveProgressAnimationDuration, resolveProgressConfig };
|
|
29
|
+
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/progress/helpers.ts"],"sourcesContent":["export type ProgressActiveMode = 'backwards' | 'forwards'\n\nexport interface ProgressConfigInput {\n percent?: unknown\n strokeWidth?: unknown\n duration?: unknown\n borderRadius?: unknown\n fontSize?: unknown\n activeMode?: unknown\n}\n\nexport interface ProgressConfig {\n percent: number\n strokeWidth: number\n duration: number\n borderRadius: number\n fontSize: number\n activeMode: ProgressActiveMode\n}\n\nfunction finiteNumber(value: unknown, fallback: number) {\n const numeric = Number(value)\n return Number.isFinite(numeric) ? numeric : fallback\n}\n\nfunction nonNegativeNumber(value: unknown, fallback: number) {\n return Math.max(0, finiteNumber(value, fallback))\n}\n\nexport function resolveProgressConfig(input: ProgressConfigInput = {}): ProgressConfig {\n const activeMode = input.activeMode === 'forwards' ? 'forwards' : 'backwards'\n return {\n percent: Math.min(100, Math.max(0, finiteNumber(input.percent, 0))),\n strokeWidth: nonNegativeNumber(input.strokeWidth, 6),\n duration: nonNegativeNumber(input.duration, 30),\n borderRadius: nonNegativeNumber(input.borderRadius, 0),\n fontSize: nonNegativeNumber(input.fontSize, 16),\n activeMode,\n }\n}\n\nexport function resolveProgressAnimationDuration(start: number, end: number, durationPerPercent: number) {\n return Math.abs(end - start) * durationPerPercent\n}\n\nexport function createProgressActiveEndDetail() {\n return {}\n}\n"],"mappings":";AAoBA,SAAS,aAAa,OAAgB,UAAkB;CACtD,MAAM,UAAU,OAAO,KAAK;CAC5B,OAAO,OAAO,SAAS,OAAO,IAAI,UAAU;AAC9C;AAEA,SAAS,kBAAkB,OAAgB,UAAkB;CAC3D,OAAO,KAAK,IAAI,GAAG,aAAa,OAAO,QAAQ,CAAC;AAClD;AAEA,SAAgB,sBAAsB,QAA6B,CAAC,GAAmB;CACrF,MAAM,aAAa,MAAM,eAAe,aAAa,aAAa;CAClE,OAAO;EACL,SAAS,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,aAAa,MAAM,SAAS,CAAC,CAAC,CAAC;EAClE,aAAa,kBAAkB,MAAM,aAAa,CAAC;EACnD,UAAU,kBAAkB,MAAM,UAAU,EAAE;EAC9C,cAAc,kBAAkB,MAAM,cAAc,CAAC;EACrD,UAAU,kBAAkB,MAAM,UAAU,EAAE;EAC9C;CACF;AACF;AAEA,SAAgB,iCAAiC,OAAe,KAAa,oBAA4B;CACvG,OAAO,KAAK,IAAI,MAAM,KAAK,IAAI;AACjC;AAEA,SAAgB,gCAAgC;CAC9C,OAAO,CAAC;AACV"}
|