@weapp-vite/web 1.3.37 → 1.4.1
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 +16 -12
- package/dist/compiler/wxml/renderer.mjs.map +1 -1
- package/dist/compiler/wxml/specialNodes.mjs +8 -2
- 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 +24 -6
- package/dist/index.mjs +21 -4
- 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 +55 -6
- 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 +244 -73
- 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 +6 -2
- package/dist/plugin/path.mjs.map +1 -1
- package/dist/plugin/register.mjs +45 -33
- package/dist/plugin/register.mjs.map +1 -1
- package/dist/plugin/scan.mjs +211 -92
- 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 +37 -1
- package/dist/plugin/vueSfc.mjs +150 -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 +36 -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/deviceApi.mjs +6 -3
- package/dist/runtime/polyfill/deviceApi.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 +33 -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 +9 -5
- 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 +11 -6
- 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 +3 -2
- package/dist/runtime/polyfill/mediaApi/file.mjs.map +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/mediaApi/picker.mjs +16 -8
- package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/preview.mjs +4 -2
- package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/process.mjs +4 -2
- package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -1
- package/dist/runtime/polyfill/menuApi.mjs +39 -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 +3 -2
- package/dist/runtime/polyfill/platformApi.mjs.map +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/storageAsync.mjs +4 -2
- package/dist/runtime/polyfill/storageAsync.mjs.map +1 -1
- package/dist/runtime/polyfill/system.mjs +31 -4
- package/dist/runtime/polyfill/system.mjs.map +1 -1
- package/dist/runtime/polyfill/systemApi.mjs +2 -1
- package/dist/runtime/polyfill/systemApi.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 +14 -6
|
@@ -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;CACA,wBAAwB;CACxB;CACA;CACA;CACA;CACA,QAAQ;CAER,IAAI,QAAQ;EACV,OAAO,KAAKA,oBACR,KAAKC,cACL,qBAAqB,KAAK,aAAa,OAAO,CAAC,KAAK,CAAC;CAC3D;CAEA,IAAI,MAAM,OAAgB;EACxB,KAAKD,oBAAoB;EACzB,KAAKC,cAAc;EACnB,KAAKC,mBAAmB;CAC1B;CAEA,IAAI,QAAQ;EACV,OAAO,KAAKC,oBACR,KAAKC,cACL,qBAAqB,KAAK,aAAa,OAAO,CAAC;CACrD;CAEA,IAAI,MAAM,OAAgB;EACxB,KAAKD,oBAAoB;EACzB,KAAKC,cAAc;EACnB,KAAKF,mBAAmB;CAC1B;CAEA,IAAI,WAAW;EACb,OAAO,qBAAqB,MAAM,UAAU;CAC9C;CAEA,IAAI,kBAAkB;EACpB,OAAO,KAAK,aAAa,MAAM,KAAK;CACtC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EACjB,yBAAyB,MAAM,UAAU,yBAAyB,MAAM,iBAAiB,KAAKN,eAAe,CAAC,CAAC;CACjH;CAEA,OAAO,WAAoB;EACzB,IAAI,CAAC,KAAKO,SAAS,CAAC,KAAKC,WACvB;EAEF,KAAKA,UAAU,SAAS;EACxB,KAAKD,QAAQ;EACb,IAAI,WACF,yBAAyB,MAAM,UAAU,CAAC,CAAC;CAE/C;CAEA,oBAAoB,UAAsB;EACxC,IAAI,KAAKK,UAAU,MAAM,aAAa,CAAC,CAAC,SAAS,KAAKA,MAAM,GAC1D;EAEF,KAAK,KAAK;CACZ;CAEA,sBAAsB,UAAyB;EAC7C,IAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KACzC;EAEF,MAAM,eAAe;EACrB,KAAK,KAAK;CACZ;AACF"}
|
|
@@ -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,I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B,KAAK;GAC3B,KAAK,iBAAiB,KAAKA,cAAc;GACzC,KAAKY,kBAAkB,iCAAiC;IACtD,OAAO,KAAKZ;IACZ,OAAO;GACT,CAAC;GACD,IAAI,KAAKa,UAAU;IACjB,KAAKA,WAAW;IAChB,KAAKD,kBAAkB,0BAA0B;GACnD;EACF,GAAG,GAAG;CACR;AACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/runtime/nativeComponents/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,KA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