first commit
This commit is contained in:
164
node_modules/vant/lib/picker/Picker.d.ts
generated
vendored
Normal file
164
node_modules/vant/lib/picker/Picker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
import { type PropType, type ExtractPropTypes } from 'vue';
|
||||
import { type Numeric } from '../utils';
|
||||
import type { PickerColumn, PickerOption, PickerFieldNames, PickerToolbarPosition } from './types';
|
||||
export declare const pickerSharedProps: {
|
||||
loading: BooleanConstructor;
|
||||
readonly: BooleanConstructor;
|
||||
allowHtml: BooleanConstructor;
|
||||
optionHeight: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
showToolbar: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeDuration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
visibleOptionNum: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
} & {
|
||||
title: StringConstructor;
|
||||
cancelButtonText: StringConstructor;
|
||||
confirmButtonText: StringConstructor;
|
||||
};
|
||||
export declare const pickerProps: {
|
||||
loading: BooleanConstructor;
|
||||
readonly: BooleanConstructor;
|
||||
allowHtml: BooleanConstructor;
|
||||
optionHeight: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
showToolbar: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeDuration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
visibleOptionNum: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
} & {
|
||||
title: StringConstructor;
|
||||
cancelButtonText: StringConstructor;
|
||||
confirmButtonText: StringConstructor;
|
||||
} & {
|
||||
columns: {
|
||||
type: PropType<(PickerColumn | PickerOption)[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
modelValue: {
|
||||
type: PropType<Numeric[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
toolbarPosition: {
|
||||
type: PropType<PickerToolbarPosition>;
|
||||
default: PickerToolbarPosition;
|
||||
};
|
||||
columnsFieldNames: PropType<PickerFieldNames>;
|
||||
};
|
||||
export type PickerProps = ExtractPropTypes<typeof pickerProps>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
loading: BooleanConstructor;
|
||||
readonly: BooleanConstructor;
|
||||
allowHtml: BooleanConstructor;
|
||||
optionHeight: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
showToolbar: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeDuration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
visibleOptionNum: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
} & {
|
||||
title: StringConstructor;
|
||||
cancelButtonText: StringConstructor;
|
||||
confirmButtonText: StringConstructor;
|
||||
} & {
|
||||
columns: {
|
||||
type: PropType<(PickerColumn | PickerOption)[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
modelValue: {
|
||||
type: PropType<Numeric[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
toolbarPosition: {
|
||||
type: PropType<PickerToolbarPosition>;
|
||||
default: PickerToolbarPosition;
|
||||
};
|
||||
columnsFieldNames: PropType<PickerFieldNames>;
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "cancel" | "change" | "confirm" | "clickOption" | "scrollInto")[], "update:modelValue" | "cancel" | "change" | "confirm" | "clickOption" | "scrollInto", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
loading: BooleanConstructor;
|
||||
readonly: BooleanConstructor;
|
||||
allowHtml: BooleanConstructor;
|
||||
optionHeight: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
showToolbar: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeDuration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
visibleOptionNum: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
} & {
|
||||
title: StringConstructor;
|
||||
cancelButtonText: StringConstructor;
|
||||
confirmButtonText: StringConstructor;
|
||||
} & {
|
||||
columns: {
|
||||
type: PropType<(PickerColumn | PickerOption)[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
modelValue: {
|
||||
type: PropType<Numeric[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
toolbarPosition: {
|
||||
type: PropType<PickerToolbarPosition>;
|
||||
default: PickerToolbarPosition;
|
||||
};
|
||||
columnsFieldNames: PropType<PickerFieldNames>;
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
||||
onCancel?: ((...args: any[]) => any) | undefined;
|
||||
onClickOption?: ((...args: any[]) => any) | undefined;
|
||||
onScrollInto?: ((...args: any[]) => any) | undefined;
|
||||
onConfirm?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
modelValue: Numeric[];
|
||||
readonly: boolean;
|
||||
loading: boolean;
|
||||
allowHtml: boolean;
|
||||
optionHeight: string | number;
|
||||
showToolbar: boolean;
|
||||
swipeDuration: string | number;
|
||||
visibleOptionNum: string | number;
|
||||
columns: (PickerColumn | PickerOption)[];
|
||||
toolbarPosition: PickerToolbarPosition;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
248
node_modules/vant/lib/picker/Picker.js
generated
vendored
Normal file
248
node_modules/vant/lib/picker/Picker.js
generated
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name2 in all)
|
||||
__defProp(target, name2, { get: all[name2], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
default: () => stdin_default,
|
||||
pickerProps: () => pickerProps,
|
||||
pickerSharedProps: () => pickerSharedProps
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_vue = require("vue");
|
||||
var import_utils = require("../utils");
|
||||
var import_utils2 = require("./utils");
|
||||
var import_use = require("@vant/use");
|
||||
var import_use_expose = require("../composables/use-expose");
|
||||
var import_loading = require("../loading");
|
||||
var import_PickerColumn = __toESM(require("./PickerColumn"));
|
||||
var import_PickerToolbar = __toESM(require("./PickerToolbar"));
|
||||
var import_PickerGroup = require("../picker-group/PickerGroup");
|
||||
const pickerSharedProps = (0, import_utils.extend)({
|
||||
loading: Boolean,
|
||||
readonly: Boolean,
|
||||
allowHtml: Boolean,
|
||||
optionHeight: (0, import_utils.makeNumericProp)(44),
|
||||
showToolbar: import_utils.truthProp,
|
||||
swipeDuration: (0, import_utils.makeNumericProp)(1e3),
|
||||
visibleOptionNum: (0, import_utils.makeNumericProp)(6)
|
||||
}, import_PickerToolbar.pickerToolbarProps);
|
||||
const pickerProps = (0, import_utils.extend)({}, pickerSharedProps, {
|
||||
columns: (0, import_utils.makeArrayProp)(),
|
||||
modelValue: (0, import_utils.makeArrayProp)(),
|
||||
toolbarPosition: (0, import_utils.makeStringProp)("top"),
|
||||
columnsFieldNames: Object
|
||||
});
|
||||
var stdin_default = (0, import_vue.defineComponent)({
|
||||
name: import_utils2.name,
|
||||
props: pickerProps,
|
||||
emits: ["confirm", "cancel", "change", "scrollInto", "clickOption", "update:modelValue"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const columnsRef = (0, import_vue.ref)();
|
||||
const selectedValues = (0, import_vue.ref)(props.modelValue.slice(0));
|
||||
const {
|
||||
parent
|
||||
} = (0, import_use.useParent)(import_PickerGroup.PICKER_GROUP_KEY);
|
||||
const {
|
||||
children,
|
||||
linkChildren
|
||||
} = (0, import_use.useChildren)(import_PickerColumn.PICKER_KEY);
|
||||
linkChildren();
|
||||
const fields = (0, import_vue.computed)(() => (0, import_utils2.assignDefaultFields)(props.columnsFieldNames));
|
||||
const optionHeight = (0, import_vue.computed)(() => (0, import_utils.unitToPx)(props.optionHeight));
|
||||
const columnsType = (0, import_vue.computed)(() => (0, import_utils2.getColumnsType)(props.columns, fields.value));
|
||||
const currentColumns = (0, import_vue.computed)(() => {
|
||||
const {
|
||||
columns
|
||||
} = props;
|
||||
switch (columnsType.value) {
|
||||
case "multiple":
|
||||
return columns;
|
||||
case "cascade":
|
||||
return (0, import_utils2.formatCascadeColumns)(columns, fields.value, selectedValues);
|
||||
default:
|
||||
return [columns];
|
||||
}
|
||||
});
|
||||
const hasOptions = (0, import_vue.computed)(() => currentColumns.value.some((options) => options.length));
|
||||
const selectedOptions = (0, import_vue.computed)(() => currentColumns.value.map((options, index) => (0, import_utils2.findOptionByValue)(options, selectedValues.value[index], fields.value)));
|
||||
const selectedIndexes = (0, import_vue.computed)(() => currentColumns.value.map((options, index) => options.findIndex((option) => option[fields.value.value] === selectedValues.value[index])));
|
||||
const setValue = (index, value) => {
|
||||
if (selectedValues.value[index] !== value) {
|
||||
const newValues = selectedValues.value.slice(0);
|
||||
newValues[index] = value;
|
||||
selectedValues.value = newValues;
|
||||
}
|
||||
};
|
||||
const getEventParams = () => ({
|
||||
selectedValues: selectedValues.value.slice(0),
|
||||
selectedOptions: selectedOptions.value,
|
||||
selectedIndexes: selectedIndexes.value
|
||||
});
|
||||
const onChange = (value, columnIndex) => {
|
||||
setValue(columnIndex, value);
|
||||
if (columnsType.value === "cascade") {
|
||||
selectedValues.value.forEach((value2, index) => {
|
||||
const options = currentColumns.value[index];
|
||||
if (!(0, import_utils2.isOptionExist)(options, value2, fields.value)) {
|
||||
setValue(index, options.length ? options[0][fields.value.value] : void 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
(0, import_vue.nextTick)(() => {
|
||||
emit("change", (0, import_utils.extend)({
|
||||
columnIndex
|
||||
}, getEventParams()));
|
||||
});
|
||||
};
|
||||
const onClickOption = (currentOption, columnIndex) => {
|
||||
const params = {
|
||||
columnIndex,
|
||||
currentOption
|
||||
};
|
||||
emit("clickOption", (0, import_utils.extend)(getEventParams(), params));
|
||||
emit("scrollInto", params);
|
||||
};
|
||||
const confirm = () => {
|
||||
children.forEach((child) => child.stopMomentum());
|
||||
const params = getEventParams();
|
||||
(0, import_vue.nextTick)(() => {
|
||||
const params2 = getEventParams();
|
||||
emit("confirm", params2);
|
||||
});
|
||||
return params;
|
||||
};
|
||||
const cancel = () => emit("cancel", getEventParams());
|
||||
const renderColumnItems = () => currentColumns.value.map((options, columnIndex) => (0, import_vue.createVNode)(import_PickerColumn.default, {
|
||||
"value": selectedValues.value[columnIndex],
|
||||
"fields": fields.value,
|
||||
"options": options,
|
||||
"readonly": props.readonly,
|
||||
"allowHtml": props.allowHtml,
|
||||
"optionHeight": optionHeight.value,
|
||||
"swipeDuration": props.swipeDuration,
|
||||
"visibleOptionNum": props.visibleOptionNum,
|
||||
"onChange": (value) => onChange(value, columnIndex),
|
||||
"onClickOption": (option) => onClickOption(option, columnIndex),
|
||||
"onScrollInto": (option) => {
|
||||
emit("scrollInto", {
|
||||
currentOption: option,
|
||||
columnIndex
|
||||
});
|
||||
}
|
||||
}, {
|
||||
option: slots.option
|
||||
}));
|
||||
const renderMask = (wrapHeight) => {
|
||||
if (hasOptions.value) {
|
||||
const frameStyle = {
|
||||
height: `${optionHeight.value}px`
|
||||
};
|
||||
const maskStyle = {
|
||||
backgroundSize: `100% ${(wrapHeight - optionHeight.value) / 2}px`
|
||||
};
|
||||
return [(0, import_vue.createVNode)("div", {
|
||||
"class": (0, import_utils2.bem)("mask"),
|
||||
"style": maskStyle
|
||||
}, null), (0, import_vue.createVNode)("div", {
|
||||
"class": [import_utils.BORDER_UNSET_TOP_BOTTOM, (0, import_utils2.bem)("frame")],
|
||||
"style": frameStyle
|
||||
}, null)];
|
||||
}
|
||||
};
|
||||
const renderColumns = () => {
|
||||
const wrapHeight = optionHeight.value * +props.visibleOptionNum;
|
||||
const columnsStyle = {
|
||||
height: `${wrapHeight}px`
|
||||
};
|
||||
if (!props.loading && !hasOptions.value && slots.empty) {
|
||||
return slots.empty();
|
||||
}
|
||||
return (0, import_vue.createVNode)("div", {
|
||||
"ref": columnsRef,
|
||||
"class": (0, import_utils2.bem)("columns"),
|
||||
"style": columnsStyle
|
||||
}, [renderColumnItems(), renderMask(wrapHeight)]);
|
||||
};
|
||||
const renderToolbar = () => {
|
||||
if (props.showToolbar && !parent) {
|
||||
return (0, import_vue.createVNode)(import_PickerToolbar.default, (0, import_vue.mergeProps)((0, import_utils.pick)(props, import_PickerToolbar.pickerToolbarPropKeys), {
|
||||
"onConfirm": confirm,
|
||||
"onCancel": cancel
|
||||
}), (0, import_utils.pick)(slots, import_PickerToolbar.pickerToolbarSlots));
|
||||
}
|
||||
};
|
||||
const resetSelectedValues = (columns) => {
|
||||
columns.forEach((options, index) => {
|
||||
if (options.length && !(0, import_utils2.isOptionExist)(options, selectedValues.value[index], fields.value)) {
|
||||
setValue(index, (0, import_utils2.getFirstEnabledOption)(options)[fields.value.value]);
|
||||
}
|
||||
});
|
||||
};
|
||||
(0, import_vue.watch)(currentColumns, (columns) => resetSelectedValues(columns), {
|
||||
immediate: true
|
||||
});
|
||||
let lastEmittedModelValue;
|
||||
(0, import_vue.watch)(() => props.modelValue, (newValues) => {
|
||||
if (!(0, import_utils.isSameValue)(newValues, selectedValues.value) && !(0, import_utils.isSameValue)(newValues, lastEmittedModelValue)) {
|
||||
selectedValues.value = newValues.slice(0);
|
||||
lastEmittedModelValue = newValues.slice(0);
|
||||
}
|
||||
if (props.modelValue.length === 0) {
|
||||
resetSelectedValues(currentColumns.value);
|
||||
}
|
||||
}, {
|
||||
deep: true
|
||||
});
|
||||
(0, import_vue.watch)(selectedValues, (newValues) => {
|
||||
if (!(0, import_utils.isSameValue)(newValues, props.modelValue)) {
|
||||
lastEmittedModelValue = newValues.slice(0);
|
||||
emit("update:modelValue", lastEmittedModelValue);
|
||||
}
|
||||
}, {
|
||||
immediate: true
|
||||
});
|
||||
(0, import_use.useEventListener)("touchmove", import_utils.preventDefault, {
|
||||
target: columnsRef
|
||||
});
|
||||
const getSelectedOptions = () => selectedOptions.value;
|
||||
(0, import_use_expose.useExpose)({
|
||||
confirm,
|
||||
getSelectedOptions
|
||||
});
|
||||
return () => {
|
||||
var _a, _b;
|
||||
return (0, import_vue.createVNode)("div", {
|
||||
"class": (0, import_utils2.bem)()
|
||||
}, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? (0, import_vue.createVNode)(import_loading.Loading, {
|
||||
"class": (0, import_utils2.bem)("loading")
|
||||
}, null) : null, (_a = slots["columns-top"]) == null ? void 0 : _a.call(slots), renderColumns(), (_b = slots["columns-bottom"]) == null ? void 0 : _b.call(slots), props.toolbarPosition === "bottom" ? renderToolbar() : null]);
|
||||
};
|
||||
}
|
||||
});
|
||||
61
node_modules/vant/lib/picker/PickerColumn.d.ts
generated
vendored
Normal file
61
node_modules/vant/lib/picker/PickerColumn.d.ts
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
import { type PropType, type InjectionKey } from 'vue';
|
||||
import type { PickerOption, PickerFieldNames, PickerColumnProvide } from './types';
|
||||
export declare const PICKER_KEY: InjectionKey<PickerColumnProvide>;
|
||||
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
value: (NumberConstructor | StringConstructor)[];
|
||||
fields: {
|
||||
type: PropType<Required<PickerFieldNames>>;
|
||||
required: true;
|
||||
};
|
||||
options: {
|
||||
type: PropType<PickerOption[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
readonly: BooleanConstructor;
|
||||
allowHtml: BooleanConstructor;
|
||||
optionHeight: {
|
||||
type: NumberConstructor;
|
||||
required: true;
|
||||
};
|
||||
swipeDuration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
required: true;
|
||||
};
|
||||
visibleOptionNum: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
required: true;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "clickOption" | "scrollInto")[], "change" | "clickOption" | "scrollInto", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
value: (NumberConstructor | StringConstructor)[];
|
||||
fields: {
|
||||
type: PropType<Required<PickerFieldNames>>;
|
||||
required: true;
|
||||
};
|
||||
options: {
|
||||
type: PropType<PickerOption[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
readonly: BooleanConstructor;
|
||||
allowHtml: BooleanConstructor;
|
||||
optionHeight: {
|
||||
type: NumberConstructor;
|
||||
required: true;
|
||||
};
|
||||
swipeDuration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
required: true;
|
||||
};
|
||||
visibleOptionNum: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
required: true;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
onClickOption?: ((...args: any[]) => any) | undefined;
|
||||
onScrollInto?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
readonly: boolean;
|
||||
allowHtml: boolean;
|
||||
options: PickerOption[];
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
222
node_modules/vant/lib/picker/PickerColumn.js
generated
vendored
Normal file
222
node_modules/vant/lib/picker/PickerColumn.js
generated
vendored
Normal file
@@ -0,0 +1,222 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name2 in all)
|
||||
__defProp(target, name2, { get: all[name2], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
PICKER_KEY: () => PICKER_KEY,
|
||||
default: () => stdin_default
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_vue = require("vue");
|
||||
var import_utils = require("../utils");
|
||||
var import_utils2 = require("./utils");
|
||||
var import_use = require("@vant/use");
|
||||
var import_use_touch = require("../composables/use-touch");
|
||||
var import_use_expose = require("../composables/use-expose");
|
||||
const DEFAULT_DURATION = 200;
|
||||
const MOMENTUM_TIME = 300;
|
||||
const MOMENTUM_DISTANCE = 15;
|
||||
const [name, bem] = (0, import_utils.createNamespace)("picker-column");
|
||||
const PICKER_KEY = Symbol(name);
|
||||
var stdin_default = (0, import_vue.defineComponent)({
|
||||
name,
|
||||
props: {
|
||||
value: import_utils.numericProp,
|
||||
fields: (0, import_utils.makeRequiredProp)(Object),
|
||||
options: (0, import_utils.makeArrayProp)(),
|
||||
readonly: Boolean,
|
||||
allowHtml: Boolean,
|
||||
optionHeight: (0, import_utils.makeRequiredProp)(Number),
|
||||
swipeDuration: (0, import_utils.makeRequiredProp)(import_utils.numericProp),
|
||||
visibleOptionNum: (0, import_utils.makeRequiredProp)(import_utils.numericProp)
|
||||
},
|
||||
emits: ["change", "clickOption", "scrollInto"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
let moving;
|
||||
let startOffset;
|
||||
let touchStartTime;
|
||||
let momentumOffset;
|
||||
let transitionEndTrigger;
|
||||
const root = (0, import_vue.ref)();
|
||||
const wrapper = (0, import_vue.ref)();
|
||||
const currentOffset = (0, import_vue.ref)(0);
|
||||
const currentDuration = (0, import_vue.ref)(0);
|
||||
const touch = (0, import_use_touch.useTouch)();
|
||||
const count = () => props.options.length;
|
||||
const baseOffset = () => props.optionHeight * (+props.visibleOptionNum - 1) / 2;
|
||||
const updateValueByIndex = (index) => {
|
||||
let enabledIndex = (0, import_utils2.findIndexOfEnabledOption)(props.options, index);
|
||||
const offset = -enabledIndex * props.optionHeight;
|
||||
const trigger = () => {
|
||||
if (enabledIndex > count() - 1) {
|
||||
enabledIndex = (0, import_utils2.findIndexOfEnabledOption)(props.options, index);
|
||||
}
|
||||
const value = props.options[enabledIndex][props.fields.value];
|
||||
if (value !== props.value) {
|
||||
emit("change", value);
|
||||
}
|
||||
};
|
||||
if (moving && offset !== currentOffset.value) {
|
||||
transitionEndTrigger = trigger;
|
||||
} else {
|
||||
trigger();
|
||||
}
|
||||
currentOffset.value = offset;
|
||||
};
|
||||
const isReadonly = () => props.readonly || !props.options.length;
|
||||
const onClickOption = (index) => {
|
||||
if (moving || isReadonly()) {
|
||||
return;
|
||||
}
|
||||
transitionEndTrigger = null;
|
||||
currentDuration.value = DEFAULT_DURATION;
|
||||
updateValueByIndex(index);
|
||||
emit("clickOption", props.options[index]);
|
||||
};
|
||||
const getIndexByOffset = (offset) => (0, import_utils.clamp)(Math.round(-offset / props.optionHeight), 0, count() - 1);
|
||||
const currentIndex = (0, import_vue.computed)(() => getIndexByOffset(currentOffset.value));
|
||||
const momentum = (distance, duration) => {
|
||||
const speed = Math.abs(distance / duration);
|
||||
distance = currentOffset.value + speed / 3e-3 * (distance < 0 ? -1 : 1);
|
||||
const index = getIndexByOffset(distance);
|
||||
currentDuration.value = +props.swipeDuration;
|
||||
updateValueByIndex(index);
|
||||
};
|
||||
const stopMomentum = () => {
|
||||
moving = false;
|
||||
currentDuration.value = 0;
|
||||
if (transitionEndTrigger) {
|
||||
transitionEndTrigger();
|
||||
transitionEndTrigger = null;
|
||||
}
|
||||
};
|
||||
const onTouchStart = (event) => {
|
||||
if (isReadonly()) {
|
||||
return;
|
||||
}
|
||||
touch.start(event);
|
||||
if (moving) {
|
||||
const translateY = (0, import_utils2.getElementTranslateY)(wrapper.value);
|
||||
currentOffset.value = Math.min(0, translateY - baseOffset());
|
||||
}
|
||||
currentDuration.value = 0;
|
||||
startOffset = currentOffset.value;
|
||||
touchStartTime = Date.now();
|
||||
momentumOffset = startOffset;
|
||||
transitionEndTrigger = null;
|
||||
};
|
||||
const onTouchMove = (event) => {
|
||||
if (isReadonly()) {
|
||||
return;
|
||||
}
|
||||
touch.move(event);
|
||||
if (touch.isVertical()) {
|
||||
moving = true;
|
||||
(0, import_utils.preventDefault)(event, true);
|
||||
}
|
||||
const newOffset = (0, import_utils.clamp)(startOffset + touch.deltaY.value, -(count() * props.optionHeight), props.optionHeight);
|
||||
const newIndex = getIndexByOffset(newOffset);
|
||||
if (newIndex !== currentIndex.value) {
|
||||
emit("scrollInto", props.options[newIndex]);
|
||||
}
|
||||
currentOffset.value = newOffset;
|
||||
const now = Date.now();
|
||||
if (now - touchStartTime > MOMENTUM_TIME) {
|
||||
touchStartTime = now;
|
||||
momentumOffset = newOffset;
|
||||
}
|
||||
};
|
||||
const onTouchEnd = () => {
|
||||
if (isReadonly()) {
|
||||
return;
|
||||
}
|
||||
const distance = currentOffset.value - momentumOffset;
|
||||
const duration = Date.now() - touchStartTime;
|
||||
const startMomentum = duration < MOMENTUM_TIME && Math.abs(distance) > MOMENTUM_DISTANCE;
|
||||
if (startMomentum) {
|
||||
momentum(distance, duration);
|
||||
return;
|
||||
}
|
||||
const index = getIndexByOffset(currentOffset.value);
|
||||
currentDuration.value = DEFAULT_DURATION;
|
||||
updateValueByIndex(index);
|
||||
setTimeout(() => {
|
||||
moving = false;
|
||||
}, 0);
|
||||
};
|
||||
const renderOptions = () => {
|
||||
const optionStyle = {
|
||||
height: `${props.optionHeight}px`
|
||||
};
|
||||
return props.options.map((option, index) => {
|
||||
const text = option[props.fields.text];
|
||||
const {
|
||||
disabled
|
||||
} = option;
|
||||
const value = option[props.fields.value];
|
||||
const data = {
|
||||
role: "button",
|
||||
style: optionStyle,
|
||||
tabindex: disabled ? -1 : 0,
|
||||
class: [bem("item", {
|
||||
disabled,
|
||||
selected: value === props.value
|
||||
}), option.className],
|
||||
onClick: () => onClickOption(index)
|
||||
};
|
||||
const childData = {
|
||||
class: "van-ellipsis",
|
||||
[props.allowHtml ? "innerHTML" : "textContent"]: text
|
||||
};
|
||||
return (0, import_vue.createVNode)("li", data, [slots.option ? slots.option(option, index) : (0, import_vue.createVNode)("div", childData, null)]);
|
||||
});
|
||||
};
|
||||
(0, import_use.useParent)(PICKER_KEY);
|
||||
(0, import_use_expose.useExpose)({
|
||||
stopMomentum
|
||||
});
|
||||
(0, import_vue.watchEffect)(() => {
|
||||
const index = moving ? Math.floor(-currentOffset.value / props.optionHeight) : props.options.findIndex((option) => option[props.fields.value] === props.value);
|
||||
const enabledIndex = (0, import_utils2.findIndexOfEnabledOption)(props.options, index);
|
||||
const offset = -enabledIndex * props.optionHeight;
|
||||
if (moving && enabledIndex < index) stopMomentum();
|
||||
currentOffset.value = offset;
|
||||
});
|
||||
(0, import_use.useEventListener)("touchmove", onTouchMove, {
|
||||
target: root
|
||||
});
|
||||
return () => (0, import_vue.createVNode)("div", {
|
||||
"ref": root,
|
||||
"class": bem(),
|
||||
"onTouchstartPassive": onTouchStart,
|
||||
"onTouchend": onTouchEnd,
|
||||
"onTouchcancel": onTouchEnd
|
||||
}, [(0, import_vue.createVNode)("ul", {
|
||||
"ref": wrapper,
|
||||
"style": {
|
||||
transform: `translate3d(0, ${currentOffset.value + baseOffset()}px, 0)`,
|
||||
transitionDuration: `${currentDuration.value}ms`,
|
||||
transitionProperty: currentDuration.value ? "all" : "none"
|
||||
},
|
||||
"class": bem("wrapper"),
|
||||
"onTransitionend": stopMomentum
|
||||
}, [renderOptions()])]);
|
||||
}
|
||||
});
|
||||
21
node_modules/vant/lib/picker/PickerToolbar.d.ts
generated
vendored
Normal file
21
node_modules/vant/lib/picker/PickerToolbar.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export declare const pickerToolbarProps: {
|
||||
title: StringConstructor;
|
||||
cancelButtonText: StringConstructor;
|
||||
confirmButtonText: StringConstructor;
|
||||
};
|
||||
export declare const pickerToolbarSlots: string[];
|
||||
export type PickerToolbarPropKeys = Array<keyof typeof pickerToolbarProps>;
|
||||
export declare const pickerToolbarPropKeys: PickerToolbarPropKeys;
|
||||
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
title: StringConstructor;
|
||||
cancelButtonText: StringConstructor;
|
||||
confirmButtonText: StringConstructor;
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("cancel" | "confirm")[], "cancel" | "confirm", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
title: StringConstructor;
|
||||
cancelButtonText: StringConstructor;
|
||||
confirmButtonText: StringConstructor;
|
||||
}>> & Readonly<{
|
||||
onCancel?: ((...args: any[]) => any) | undefined;
|
||||
onConfirm?: ((...args: any[]) => any) | undefined;
|
||||
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
85
node_modules/vant/lib/picker/PickerToolbar.js
generated
vendored
Normal file
85
node_modules/vant/lib/picker/PickerToolbar.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name2 in all)
|
||||
__defProp(target, name2, { get: all[name2], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
default: () => stdin_default,
|
||||
pickerToolbarPropKeys: () => pickerToolbarPropKeys,
|
||||
pickerToolbarProps: () => pickerToolbarProps,
|
||||
pickerToolbarSlots: () => pickerToolbarSlots
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_vue = require("vue");
|
||||
var import_utils = require("./utils");
|
||||
var import_utils2 = require("../utils");
|
||||
const [name] = (0, import_utils2.createNamespace)("picker-toolbar");
|
||||
const pickerToolbarProps = {
|
||||
title: String,
|
||||
cancelButtonText: String,
|
||||
confirmButtonText: String
|
||||
};
|
||||
const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
|
||||
const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
|
||||
var stdin_default = (0, import_vue.defineComponent)({
|
||||
name,
|
||||
props: pickerToolbarProps,
|
||||
emits: ["confirm", "cancel"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const renderTitle = () => {
|
||||
if (slots.title) {
|
||||
return slots.title();
|
||||
}
|
||||
if (props.title) {
|
||||
return (0, import_vue.createVNode)("div", {
|
||||
"class": [(0, import_utils.bem)("title"), "van-ellipsis"]
|
||||
}, [props.title]);
|
||||
}
|
||||
};
|
||||
const onCancel = () => emit("cancel");
|
||||
const onConfirm = () => emit("confirm");
|
||||
const renderCancel = () => {
|
||||
var _a;
|
||||
const text = (_a = props.cancelButtonText) != null ? _a : (0, import_utils.t)("cancel");
|
||||
if (!slots.cancel && !text) {
|
||||
return;
|
||||
}
|
||||
return (0, import_vue.createVNode)("button", {
|
||||
"type": "button",
|
||||
"class": [(0, import_utils.bem)("cancel"), import_utils2.HAPTICS_FEEDBACK],
|
||||
"onClick": onCancel
|
||||
}, [slots.cancel ? slots.cancel() : text]);
|
||||
};
|
||||
const renderConfirm = () => {
|
||||
var _a;
|
||||
const text = (_a = props.confirmButtonText) != null ? _a : (0, import_utils.t)("confirm");
|
||||
if (!slots.confirm && !text) {
|
||||
return;
|
||||
}
|
||||
return (0, import_vue.createVNode)("button", {
|
||||
"type": "button",
|
||||
"class": [(0, import_utils.bem)("confirm"), import_utils2.HAPTICS_FEEDBACK],
|
||||
"onClick": onConfirm
|
||||
}, [slots.confirm ? slots.confirm() : text]);
|
||||
};
|
||||
return () => (0, import_vue.createVNode)("div", {
|
||||
"class": (0, import_utils.bem)("toolbar")
|
||||
}, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
|
||||
}
|
||||
});
|
||||
1
node_modules/vant/lib/picker/index.css
generated
vendored
Normal file
1
node_modules/vant/lib/picker/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-picker-background: var(--van-background-2);--van-picker-toolbar-height: 44px;--van-picker-title-font-size: var(--van-font-size-lg);--van-picker-title-line-height: var(--van-line-height-md);--van-picker-action-padding: 0 var(--van-padding-md);--van-picker-action-font-size: var(--van-font-size-md);--van-picker-confirm-action-color: var(--van-primary-color);--van-picker-cancel-action-color: var(--van-text-color-2);--van-picker-option-font-size: var(--van-font-size-lg);--van-picker-option-padding: 0 var(--van-padding-base);--van-picker-option-text-color: var(--van-text-color);--van-picker-option-disabled-opacity: .3;--van-picker-loading-icon-color: var(--van-primary-color);--van-picker-loading-mask-color: rgba(255, 255, 255, .9);--van-picker-mask-color: linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .4)), linear-gradient(0deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .4))}.van-theme-dark{--van-picker-loading-mask-color: rgba(0, 0, 0, .6);--van-picker-mask-color: linear-gradient(180deg, rgba(0, 0, 0, .6), rgba(0, 0, 0, .1)), linear-gradient(0deg, rgba(0, 0, 0, .6), rgba(0, 0, 0, .1))}.van-picker{position:relative;background:var(--van-picker-background);-webkit-user-select:none;user-select:none}.van-picker__toolbar{position:relative;display:flex;align-items:center;justify-content:space-between;height:var(--van-picker-toolbar-height)}.van-picker__cancel,.van-picker__confirm{height:100%;padding:var(--van-picker-action-padding);font-size:var(--van-picker-action-font-size);background-color:transparent;border:none}.van-picker__confirm{color:var(--van-picker-confirm-action-color)}.van-picker__cancel{color:var(--van-picker-cancel-action-color)}.van-picker__title{position:absolute;left:50%;color:var(--van-text-color);max-width:50%;font-weight:var(--van-font-bold);font-size:var(--van-picker-title-font-size);line-height:var(--van-picker-title-line-height);text-align:center;transform:translate(-50%)}.van-picker__columns{position:relative;display:flex;cursor:-webkit-grab;cursor:grab}.van-picker__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:3;display:flex;align-items:center;justify-content:center;color:var(--van-picker-loading-icon-color);background:var(--van-picker-loading-mask-color)}.van-picker__frame{position:absolute;top:50%;right:var(--van-padding-md);left:var(--van-padding-md);z-index:2;transform:translateY(-50%);pointer-events:none}.van-picker__mask{position:absolute;top:0;left:0;z-index:1;width:100%;height:100%;background-image:var(--van-picker-mask-color);background-repeat:no-repeat;background-position:top,bottom;transform:translateZ(0);pointer-events:none}.van-picker-column{flex:1;overflow:hidden;font-size:var(--van-picker-option-font-size)}.van-picker-column__wrapper{transition-timing-function:cubic-bezier(.23,1,.68,1)}.van-picker-column__item{display:flex;align-items:center;justify-content:center;padding:var(--van-picker-option-padding);color:var(--van-picker-option-text-color)}.van-picker-column__item--disabled{cursor:not-allowed;opacity:var(--van-picker-option-disabled-opacity)}
|
||||
105
node_modules/vant/lib/picker/index.d.ts
generated
vendored
Normal file
105
node_modules/vant/lib/picker/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
import { PickerProps } from './Picker';
|
||||
export declare const Picker: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
loading: BooleanConstructor;
|
||||
readonly: BooleanConstructor;
|
||||
allowHtml: BooleanConstructor;
|
||||
optionHeight: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
showToolbar: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeDuration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
visibleOptionNum: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
} & {
|
||||
title: StringConstructor;
|
||||
cancelButtonText: StringConstructor;
|
||||
confirmButtonText: StringConstructor;
|
||||
} & {
|
||||
columns: {
|
||||
type: import("vue").PropType<(import("./types").PickerColumn | import("./types").PickerOption)[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
modelValue: {
|
||||
type: import("vue").PropType<import("../utils").Numeric[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
toolbarPosition: {
|
||||
type: import("vue").PropType<import("./types").PickerToolbarPosition>;
|
||||
default: import("./types").PickerToolbarPosition;
|
||||
};
|
||||
columnsFieldNames: import("vue").PropType<import("./types").PickerFieldNames>;
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "cancel" | "change" | "confirm" | "clickOption" | "scrollInto")[], "update:modelValue" | "cancel" | "change" | "confirm" | "clickOption" | "scrollInto", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
loading: BooleanConstructor;
|
||||
readonly: BooleanConstructor;
|
||||
allowHtml: BooleanConstructor;
|
||||
optionHeight: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
showToolbar: {
|
||||
type: BooleanConstructor;
|
||||
default: true;
|
||||
};
|
||||
swipeDuration: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
visibleOptionNum: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
} & {
|
||||
title: StringConstructor;
|
||||
cancelButtonText: StringConstructor;
|
||||
confirmButtonText: StringConstructor;
|
||||
} & {
|
||||
columns: {
|
||||
type: import("vue").PropType<(import("./types").PickerColumn | import("./types").PickerOption)[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
modelValue: {
|
||||
type: import("vue").PropType<import("../utils").Numeric[]>;
|
||||
default: () => never[];
|
||||
};
|
||||
toolbarPosition: {
|
||||
type: import("vue").PropType<import("./types").PickerToolbarPosition>;
|
||||
default: import("./types").PickerToolbarPosition;
|
||||
};
|
||||
columnsFieldNames: import("vue").PropType<import("./types").PickerFieldNames>;
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
||||
onCancel?: ((...args: any[]) => any) | undefined;
|
||||
onClickOption?: ((...args: any[]) => any) | undefined;
|
||||
onScrollInto?: ((...args: any[]) => any) | undefined;
|
||||
onConfirm?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
modelValue: import("../utils").Numeric[];
|
||||
readonly: boolean;
|
||||
loading: boolean;
|
||||
allowHtml: boolean;
|
||||
optionHeight: string | number;
|
||||
showToolbar: boolean;
|
||||
swipeDuration: string | number;
|
||||
visibleOptionNum: string | number;
|
||||
columns: (import("./types").PickerColumn | import("./types").PickerOption)[];
|
||||
toolbarPosition: import("./types").PickerToolbarPosition;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default Picker;
|
||||
export { pickerProps } from './Picker';
|
||||
export type { PickerProps };
|
||||
export type { PickerColumn, PickerOption, PickerInstance, PickerThemeVars, PickerFieldNames, PickerToolbarPosition, PickerCancelEventParams, PickerChangeEventParams, PickerConfirmEventParams, } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
VanPicker: typeof Picker;
|
||||
}
|
||||
}
|
||||
39
node_modules/vant/lib/picker/index.js
generated
vendored
Normal file
39
node_modules/vant/lib/picker/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
Picker: () => Picker,
|
||||
default: () => stdin_default,
|
||||
pickerProps: () => import_Picker2.pickerProps
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_utils = require("../utils");
|
||||
var import_Picker = __toESM(require("./Picker"));
|
||||
var import_Picker2 = require("./Picker");
|
||||
const Picker = (0, import_utils.withInstall)(import_Picker.default);
|
||||
var stdin_default = Picker;
|
||||
1
node_modules/vant/lib/picker/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/lib/picker/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
10
node_modules/vant/lib/picker/style/index.js
generated
vendored
Normal file
10
node_modules/vant/lib/picker/style/index.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
require("../../style/base.css");
|
||||
require("../../badge/index.css");
|
||||
require("../../loading/index.css");
|
||||
require("../../sticky/index.css");
|
||||
require("../../swipe/index.css");
|
||||
require("../../swipe-item/index.css");
|
||||
require("../../tabs/index.css");
|
||||
require("../../tab/index.css");
|
||||
require("../../picker-group/index.css");
|
||||
require("../index.css");
|
||||
62
node_modules/vant/lib/picker/types.d.ts
generated
vendored
Normal file
62
node_modules/vant/lib/picker/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
import type { ComponentPublicInstance } from 'vue';
|
||||
import type { Numeric } from '../utils';
|
||||
import type { PickerProps } from './Picker';
|
||||
export type PickerToolbarPosition = 'top' | 'bottom';
|
||||
export type PickerFieldNames = {
|
||||
text?: string;
|
||||
value?: string;
|
||||
children?: string;
|
||||
};
|
||||
export type PickerOption = {
|
||||
text?: Numeric;
|
||||
value?: Numeric;
|
||||
disabled?: boolean;
|
||||
children?: PickerColumn;
|
||||
className?: unknown;
|
||||
[key: PropertyKey]: any;
|
||||
};
|
||||
export type PickerColumn = PickerOption[];
|
||||
export type PickerExpose = {
|
||||
confirm: () => void;
|
||||
getSelectedOptions: () => Array<PickerOption | undefined>;
|
||||
};
|
||||
export type PickerColumnProvide = {
|
||||
state: {
|
||||
index: number;
|
||||
offset: number;
|
||||
duration: number;
|
||||
options: PickerOption[];
|
||||
};
|
||||
setIndex: (index: number, emitChange?: boolean | undefined) => void;
|
||||
getValue: () => PickerOption;
|
||||
setValue: (value: string) => void;
|
||||
setOptions: (options: PickerOption[]) => void;
|
||||
stopMomentum: () => void;
|
||||
};
|
||||
export type PickerInstance = ComponentPublicInstance<PickerProps, PickerExpose>;
|
||||
export type PickerConfirmEventParams = {
|
||||
selectedValues: Numeric[];
|
||||
selectedOptions: Array<PickerOption | undefined>;
|
||||
selectedIndexes: number[];
|
||||
};
|
||||
export type PickerCancelEventParams = PickerConfirmEventParams;
|
||||
export type PickerChangeEventParams = PickerConfirmEventParams & {
|
||||
columnIndex: number;
|
||||
};
|
||||
export type PickerThemeVars = {
|
||||
pickerBackground?: string;
|
||||
pickerToolbarHeight?: string;
|
||||
pickerTitleFontSize?: string;
|
||||
pickerTitleLineHeight?: number | string;
|
||||
pickerActionPadding?: string;
|
||||
pickerActionFontSize?: string;
|
||||
pickerConfirmActionColor?: string;
|
||||
pickerCancelActionColor?: string;
|
||||
pickerOptionFontSize?: string;
|
||||
pickerOptionPadding?: string;
|
||||
pickerOptionTextColor?: string;
|
||||
pickerOptionDisabledOpacity?: number | string;
|
||||
pickerLoadingIconColor?: string;
|
||||
pickerLoadingMaskColor?: string;
|
||||
pickerMaskColor?: string;
|
||||
};
|
||||
15
node_modules/vant/lib/picker/types.js
generated
vendored
Normal file
15
node_modules/vant/lib/picker/types.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
13
node_modules/vant/lib/picker/utils.d.ts
generated
vendored
Normal file
13
node_modules/vant/lib/picker/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { type Numeric } from '../utils';
|
||||
import type { Ref } from 'vue';
|
||||
import type { PickerOption, PickerColumn, PickerFieldNames } from './types';
|
||||
declare const name: string, bem: (el?: import("../utils").Mods, mods?: import("../utils").Mods) => import("../utils").Mods, t: (path: string, ...args: unknown[]) => any;
|
||||
export { name, bem, t };
|
||||
export declare const getFirstEnabledOption: (options: PickerOption[]) => PickerOption | undefined;
|
||||
export declare function getColumnsType(columns: PickerColumn | PickerColumn[], fields: Required<PickerFieldNames>): "default" | "multiple" | "cascade";
|
||||
export declare function findIndexOfEnabledOption(options: PickerOption[], index: number): number;
|
||||
export declare const isOptionExist: (options: PickerOption[], value: Numeric | undefined, fields: Required<PickerFieldNames>) => boolean;
|
||||
export declare function findOptionByValue(options: PickerOption[], value: Numeric, fields: Required<PickerFieldNames>): PickerOption | undefined;
|
||||
export declare function formatCascadeColumns(columns: PickerColumn | PickerColumn[], fields: Required<PickerFieldNames>, selectedValues: Ref<Numeric[]>): PickerColumn[];
|
||||
export declare function getElementTranslateY(element: Element): number;
|
||||
export declare function assignDefaultFields(fields: PickerFieldNames | undefined): Required<PickerFieldNames>;
|
||||
97
node_modules/vant/lib/picker/utils.js
generated
vendored
Normal file
97
node_modules/vant/lib/picker/utils.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name2 in all)
|
||||
__defProp(target, name2, { get: all[name2], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
assignDefaultFields: () => assignDefaultFields,
|
||||
bem: () => bem,
|
||||
findIndexOfEnabledOption: () => findIndexOfEnabledOption,
|
||||
findOptionByValue: () => findOptionByValue,
|
||||
formatCascadeColumns: () => formatCascadeColumns,
|
||||
getColumnsType: () => getColumnsType,
|
||||
getElementTranslateY: () => getElementTranslateY,
|
||||
getFirstEnabledOption: () => getFirstEnabledOption,
|
||||
isOptionExist: () => isOptionExist,
|
||||
name: () => name,
|
||||
t: () => t
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_utils = require("../utils");
|
||||
const [name, bem, t] = (0, import_utils.createNamespace)("picker");
|
||||
const getFirstEnabledOption = (options) => options.find((option) => !option.disabled) || options[0];
|
||||
function getColumnsType(columns, fields) {
|
||||
const firstColumn = columns[0];
|
||||
if (firstColumn) {
|
||||
if (Array.isArray(firstColumn)) {
|
||||
return "multiple";
|
||||
}
|
||||
if (fields.children in firstColumn) {
|
||||
return "cascade";
|
||||
}
|
||||
}
|
||||
return "default";
|
||||
}
|
||||
function findIndexOfEnabledOption(options, index) {
|
||||
index = (0, import_utils.clamp)(index, 0, options.length);
|
||||
for (let i = index; i < options.length; i++) {
|
||||
if (!options[i].disabled) return i;
|
||||
}
|
||||
for (let i = index - 1; i >= 0; i--) {
|
||||
if (!options[i].disabled) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
const isOptionExist = (options, value, fields) => value !== void 0 && options.some((option) => option[fields.value] === value);
|
||||
function findOptionByValue(options, value, fields) {
|
||||
const index = options.findIndex((option) => option[fields.value] === value);
|
||||
const enabledIndex = findIndexOfEnabledOption(options, index);
|
||||
return options[enabledIndex];
|
||||
}
|
||||
function formatCascadeColumns(columns, fields, selectedValues) {
|
||||
const formatted = [];
|
||||
let cursor = {
|
||||
[fields.children]: columns
|
||||
};
|
||||
let columnIndex = 0;
|
||||
while (cursor && cursor[fields.children]) {
|
||||
const options = cursor[fields.children];
|
||||
const value = selectedValues.value[columnIndex];
|
||||
cursor = (0, import_utils.isDef)(value) ? findOptionByValue(options, value, fields) : void 0;
|
||||
if (!cursor && options.length) {
|
||||
const firstValue = getFirstEnabledOption(options)[fields.value];
|
||||
cursor = findOptionByValue(options, firstValue, fields);
|
||||
}
|
||||
columnIndex++;
|
||||
formatted.push(options);
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
function getElementTranslateY(element) {
|
||||
const { transform } = window.getComputedStyle(element);
|
||||
const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
|
||||
return Number(translateY);
|
||||
}
|
||||
function assignDefaultFields(fields) {
|
||||
return (0, import_utils.extend)(
|
||||
{
|
||||
text: "text",
|
||||
value: "value",
|
||||
children: "children"
|
||||
},
|
||||
fields
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user