snail.vue 2.0.32 → 2.0.33
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/dist/snail.vue.d.ts +5 -3
- package/dist/snail.vue.js +278 -256
- package/dist/snail.vue.umd.js +277 -255
- package/dist/styles/snail.vue.vue.css +4 -4
- package/package.json +3 -3
package/dist/snail.vue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//@ sourceURL=/snail.vue.js
|
|
2
2
|
import { defineComponent, createElementBlock, openBlock, normalizeClass, renderSlot, createTextVNode, computed, mergeProps, unref, createElementVNode, toDisplayString, Fragment, renderList, mergeModels, useModel, normalizeStyle, createCommentVNode, createBlock, nextTick, useTemplateRef, shallowRef, createVNode, watch, withDirectives, isRef, vModelText, withCtx, createApp, resolveDynamicComponent, TransitionGroup, Transition, normalizeProps, guardReactiveProps, ref, onErrorCaptured, createSlots, onMounted, withModifiers, getCurrentInstance, resolveComponent, vShow, onBeforeUnmount, onActivated, getCurrentScope, onScopeDispose } from 'vue';
|
|
3
|
-
import { throwError, isObject, correctNumber, correctString, useKey, isArray,
|
|
3
|
+
import { throwError, isObject, correctNumber, correctString, useKey, isArray, useScopes, mountScope, throwIfFalse, isPromise, wait, isNumberNotNaN, isStringNotEmpty, hasAny, mustFunction, useScope, removeFromArray, mustObject, isArrayNotEmpty, hasOwnProperty, isString, script, delay, useTimer, runAsync, defer, useAsyncScope, useHook, newId, throwIfTrue, isFunction, getDateValue, parseDate, formatDateValue, getDateByValue, getTimeNumber, parseDateValue, correctDateFormat, parseTimeValue, isValidTime, getFromArray, formatTimeValue, getTimeValue, padStart, isNullish, onMountScope } from 'snail.core';
|
|
4
4
|
import { css, link, useObserver, useScroll, useAnimation, useElastic } from 'snail.view';
|
|
5
5
|
|
|
6
6
|
const _hoisted_1$p = ["title"];
|
|
@@ -451,6 +451,7 @@ var _sfc_main$B = defineComponent({
|
|
|
451
451
|
});
|
|
452
452
|
|
|
453
453
|
function useReactive() {
|
|
454
|
+
const scopes = useScopes();
|
|
454
455
|
function transition(rv, effect, time) {
|
|
455
456
|
throwIfFalse(isObject(effect), "transition: effect must be an object.");
|
|
456
457
|
const scope = scopes.get();
|
|
@@ -477,14 +478,17 @@ function useReactive() {
|
|
|
477
478
|
});
|
|
478
479
|
return scopes.get().onDestroy(stop);
|
|
479
480
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
481
|
+
{
|
|
482
|
+
const manager = mountScope({
|
|
483
|
+
transition,
|
|
484
|
+
load,
|
|
485
|
+
watcher
|
|
486
|
+
}, {
|
|
487
|
+
type: "IReactiveManager"
|
|
488
|
+
});
|
|
489
|
+
manager.onDestroy(scopes.destroy);
|
|
490
|
+
return Object.freeze(manager);
|
|
491
|
+
}
|
|
488
492
|
}
|
|
489
493
|
|
|
490
494
|
function useFormatter(options) {
|
|
@@ -646,7 +650,9 @@ function useFormatter(options) {
|
|
|
646
650
|
buildUpper,
|
|
647
651
|
buildThousands,
|
|
648
652
|
calcByStep
|
|
649
|
-
},
|
|
653
|
+
}, {
|
|
654
|
+
type: "INumberFormatter"
|
|
655
|
+
}));
|
|
650
656
|
return formatter;
|
|
651
657
|
}
|
|
652
658
|
|
|
@@ -1916,13 +1922,17 @@ var _sfc_main$p = defineComponent({
|
|
|
1916
1922
|
}
|
|
1917
1923
|
});
|
|
1918
1924
|
|
|
1919
|
-
function usePopup() {
|
|
1920
|
-
|
|
1921
|
-
|
|
1925
|
+
function usePopup(options) {
|
|
1926
|
+
const global = options ? options.global : false;
|
|
1927
|
+
const scopes = useScopes({
|
|
1928
|
+
global
|
|
1929
|
+
});
|
|
1930
|
+
function popup(options2) {
|
|
1931
|
+
const scope = checkOptions(options2, checkPopup) || popupInCustomContainer(_sfc_main$q, options2);
|
|
1922
1932
|
return addScope2Scopes(scope);
|
|
1923
1933
|
}
|
|
1924
|
-
function dialog(
|
|
1925
|
-
var scope = checkOptions(
|
|
1934
|
+
function dialog(options2) {
|
|
1935
|
+
var scope = checkOptions(options2, checkDialog);
|
|
1926
1936
|
if (scope == void 0) {
|
|
1927
1937
|
const deferred = defer();
|
|
1928
1938
|
const hook = useHook();
|
|
@@ -1951,13 +1961,13 @@ function usePopup() {
|
|
|
1951
1961
|
},
|
|
1952
1962
|
onBeforeClose: fn => hook.register("onBeforeClose", fn)
|
|
1953
1963
|
});
|
|
1954
|
-
const descriptor = openPopup(_sfc_main$s,
|
|
1964
|
+
const descriptor = openPopup(_sfc_main$s, options2, extOptions);
|
|
1955
1965
|
scope = useAsyncScope(deferred.promise);
|
|
1956
1966
|
monitorDialog(descriptor, scope, deferred);
|
|
1957
1967
|
}
|
|
1958
1968
|
return addScope2Scopes(scope);
|
|
1959
1969
|
}
|
|
1960
|
-
function follow(target,
|
|
1970
|
+
function follow(target, options2) {
|
|
1961
1971
|
var scope = void 0;
|
|
1962
1972
|
if (target instanceof Element == false) {
|
|
1963
1973
|
const deferred = defer();
|
|
@@ -1969,34 +1979,34 @@ function usePopup() {
|
|
|
1969
1979
|
inPopup: "follow",
|
|
1970
1980
|
target
|
|
1971
1981
|
};
|
|
1972
|
-
scope = checkOptions(
|
|
1982
|
+
scope = checkOptions(options2, checkFollow) || popupInCustomContainer(_sfc_main$r, options2, extOptions);
|
|
1973
1983
|
}
|
|
1974
1984
|
return addScope2Scopes(scope);
|
|
1975
1985
|
}
|
|
1976
|
-
function confirm(title, message,
|
|
1977
|
-
|
|
1986
|
+
function confirm(title, message, options2) {
|
|
1987
|
+
options2 = options2 || Object.create(null);
|
|
1978
1988
|
return dialog({
|
|
1979
1989
|
component: _sfc_main$y,
|
|
1980
1990
|
closeOnEscape: true,
|
|
1981
1991
|
props: {
|
|
1982
|
-
...
|
|
1992
|
+
...options2,
|
|
1983
1993
|
title,
|
|
1984
1994
|
message
|
|
1985
1995
|
}
|
|
1986
1996
|
});
|
|
1987
1997
|
}
|
|
1988
|
-
function toast(type, message,
|
|
1998
|
+
function toast(type, message, options2) {
|
|
1989
1999
|
return popupInCustomContainer(_sfc_main$p, {
|
|
1990
2000
|
url: "#ToastContainer",
|
|
1991
2001
|
props: {
|
|
1992
|
-
...(
|
|
2002
|
+
...(options2 || Object.create(null)),
|
|
1993
2003
|
type,
|
|
1994
2004
|
message
|
|
1995
2005
|
}
|
|
1996
2006
|
});
|
|
1997
2007
|
}
|
|
1998
|
-
function checkOptions(
|
|
1999
|
-
const message = manager.destroyed == true ? "checkOptions: manager destroyed." : checkFunc(
|
|
2008
|
+
function checkOptions(options2, checkFunc) {
|
|
2009
|
+
const message = manager.destroyed == true ? "checkOptions: manager destroyed." : checkFunc(options2);
|
|
2000
2010
|
if (isStringNotEmpty(message) == true) {
|
|
2001
2011
|
const deferred = defer();
|
|
2002
2012
|
deferred.reject(message);
|
|
@@ -2007,7 +2017,7 @@ function usePopup() {
|
|
|
2007
2017
|
function addScope2Scopes(scope) {
|
|
2008
2018
|
return scope.destroyed || manager.destroyed ? scope : scopes.add(scope);
|
|
2009
2019
|
}
|
|
2010
|
-
function popupInCustomContainer(container,
|
|
2020
|
+
function popupInCustomContainer(container, options2, extOptions) {
|
|
2011
2021
|
const deferred = defer();
|
|
2012
2022
|
extOptions = Object.freeze({
|
|
2013
2023
|
inPopup: "popup",
|
|
@@ -2019,7 +2029,7 @@ function usePopup() {
|
|
|
2019
2029
|
},
|
|
2020
2030
|
...extOptions
|
|
2021
2031
|
});
|
|
2022
|
-
const descriptor = openPopup(container || _sfc_main$q,
|
|
2032
|
+
const descriptor = openPopup(container || _sfc_main$q, options2, extOptions);
|
|
2023
2033
|
const scope = useAsyncScope(deferred.promise);
|
|
2024
2034
|
scope.onDestroy(() => destroyPopup(descriptor, deferred));
|
|
2025
2035
|
return scope;
|
|
@@ -2030,8 +2040,10 @@ function usePopup() {
|
|
|
2030
2040
|
follow,
|
|
2031
2041
|
confirm,
|
|
2032
2042
|
toast
|
|
2033
|
-
},
|
|
2034
|
-
|
|
2043
|
+
}, {
|
|
2044
|
+
global: options ? options.global : false,
|
|
2045
|
+
type: "IPopupManager"
|
|
2046
|
+
});
|
|
2035
2047
|
manager.onDestroy(scopes.destroy);
|
|
2036
2048
|
return Object.freeze(manager);
|
|
2037
2049
|
}
|
|
@@ -2079,7 +2091,9 @@ function useTreeContext(nodes, activeNodeRef) {
|
|
|
2079
2091
|
isShowChildren,
|
|
2080
2092
|
getPath,
|
|
2081
2093
|
getKey
|
|
2082
|
-
},
|
|
2094
|
+
}, {
|
|
2095
|
+
type: "ITreeBaseContext"
|
|
2096
|
+
});
|
|
2083
2097
|
context.onDestroy(() => {
|
|
2084
2098
|
failed.value = void 0;
|
|
2085
2099
|
patched.value = void 0;
|
|
@@ -2143,7 +2157,9 @@ function useSelectContext(items, selectsRef, separator) {
|
|
|
2143
2157
|
selected,
|
|
2144
2158
|
selectedText
|
|
2145
2159
|
});
|
|
2146
|
-
mountScope(context,
|
|
2160
|
+
mountScope(context, {
|
|
2161
|
+
type: "ISelectContext"
|
|
2162
|
+
});
|
|
2147
2163
|
treeContxt.onDestroy(() => context.destroyed || context.destroy());
|
|
2148
2164
|
context.onDestroy(() => treeContxt.destroyed || treeContxt.destroy());
|
|
2149
2165
|
}
|
|
@@ -3874,210 +3890,16 @@ function buildSecondItems(minuteItem, min, max) {
|
|
|
3874
3890
|
return items;
|
|
3875
3891
|
}
|
|
3876
3892
|
|
|
3877
|
-
const _hoisted_1$7 =
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
};
|
|
3881
|
-
const _hoisted_2$6 = ["textContent", "onClick", "onDblclick"];
|
|
3882
|
-
const _hoisted_3$2 = {
|
|
3883
|
-
class: "tz-item",
|
|
3884
|
-
ref: "minute-items"
|
|
3885
|
-
};
|
|
3893
|
+
const _hoisted_1$7 = ["textContent"];
|
|
3894
|
+
const _hoisted_2$6 = ["textContent"];
|
|
3895
|
+
const _hoisted_3$2 = ["textContent"];
|
|
3886
3896
|
const _hoisted_4$2 = ["textContent", "onClick", "onDblclick"];
|
|
3887
|
-
const _hoisted_5$2 =
|
|
3888
|
-
|
|
3889
|
-
class: "tz-item",
|
|
3890
|
-
ref: "second-items"
|
|
3891
|
-
};
|
|
3892
|
-
const _hoisted_6$2 = ["textContent", "onClick", "onDblclick"];
|
|
3893
|
-
var _sfc_main$7 = defineComponent({
|
|
3894
|
-
__name: "time-pc",
|
|
3895
|
-
props: {
|
|
3896
|
-
value: {},
|
|
3897
|
-
format: {},
|
|
3898
|
-
mode: {},
|
|
3899
|
-
min: {},
|
|
3900
|
-
max: {},
|
|
3901
|
-
toolbarDisabled: {
|
|
3902
|
-
type: Boolean
|
|
3903
|
-
},
|
|
3904
|
-
nowDisabled: {
|
|
3905
|
-
type: Boolean
|
|
3906
|
-
},
|
|
3907
|
-
clearDisabled: {
|
|
3908
|
-
type: Boolean
|
|
3909
|
-
},
|
|
3910
|
-
popup: {},
|
|
3911
|
-
picker: {},
|
|
3912
|
-
inPopup: {},
|
|
3913
|
-
closePopup: {
|
|
3914
|
-
type: Function
|
|
3915
|
-
},
|
|
3916
|
-
popupStatus: {},
|
|
3917
|
-
target: {},
|
|
3918
|
-
followX: {},
|
|
3919
|
-
followY: {},
|
|
3920
|
-
pinned: {}
|
|
3921
|
-
},
|
|
3922
|
-
emits: ["clear", "confirm"],
|
|
3923
|
-
setup(__props, _ref) {
|
|
3924
|
-
let {
|
|
3925
|
-
emit: __emit
|
|
3926
|
-
} = _ref;
|
|
3927
|
-
const props = __props;
|
|
3928
|
-
const emits = __emit;
|
|
3929
|
-
const format = props.format == "HH:mm" ? "HH:mm" : "HH:mm:ss";
|
|
3930
|
-
const min = parseTimeValue(props.min, "min");
|
|
3931
|
-
const max = parseTimeValue(props.max, "max");
|
|
3932
|
-
const timeRef = ref(parseTimeValue(props.value, "min") || getTimeValue(new Date()));
|
|
3933
|
-
const isValidTimeRef = computed(() => format == "HH:mm" ? minuteItems.value && minuteItems.value[timeRef.value.minute].disabled != true : secondItems.value && secondItems.value[timeRef.value.second].disabled != true);
|
|
3934
|
-
const hourItems = shallowRef(buildHourItems(min, max));
|
|
3935
|
-
const minuteItems = shallowRef();
|
|
3936
|
-
const secondItems = shallowRef();
|
|
3937
|
-
const hItemsDom = useTemplateRef("hour-items");
|
|
3938
|
-
const mItemsDom = useTemplateRef("minute-items");
|
|
3939
|
-
const sItemsDom = useTemplateRef("second-items");
|
|
3940
|
-
async function rebuildItems(time) {
|
|
3941
|
-
time != void 0 && (timeRef.value = time);
|
|
3942
|
-
minuteItems.value = buildMinuteItems(hourItems.value[timeRef.value.hour], min, max);
|
|
3943
|
-
secondItems.value = buildSecondItems(minuteItems.value[timeRef.value.minute], min, max);
|
|
3944
|
-
await nextTick();
|
|
3945
|
-
scrollIntoView(hItemsDom.value);
|
|
3946
|
-
scrollIntoView(mItemsDom.value);
|
|
3947
|
-
scrollIntoView(sItemsDom.value);
|
|
3948
|
-
}
|
|
3949
|
-
function scrollIntoView(items) {
|
|
3950
|
-
let activeIndex = void 0;
|
|
3951
|
-
for (var index = 0; index < (items ? items.children.length : 0); index++) {
|
|
3952
|
-
const ele = items.children[index];
|
|
3953
|
-
if (ele.classList.contains("active") == true) {
|
|
3954
|
-
activeIndex = index;
|
|
3955
|
-
break;
|
|
3956
|
-
}
|
|
3957
|
-
}
|
|
3958
|
-
activeIndex != void 0 && items.children[activeIndex].scrollIntoView({
|
|
3959
|
-
behavior: "smooth",
|
|
3960
|
-
block: "center"
|
|
3961
|
-
});
|
|
3962
|
-
}
|
|
3963
|
-
function onHourClick(item, dbClick) {
|
|
3964
|
-
if (item.disabled != true && timeRef.value.hour != item.hour) {
|
|
3965
|
-
timeRef.value.hour = item.hour;
|
|
3966
|
-
minuteItems.value = buildMinuteItems(item, min, max);
|
|
3967
|
-
secondItems.value = buildSecondItems(minuteItems.value[timeRef.value.minute], min, max);
|
|
3968
|
-
}
|
|
3969
|
-
}
|
|
3970
|
-
function onMinuteClick(item, dbClick) {
|
|
3971
|
-
if (item.disabled != true) {
|
|
3972
|
-
timeRef.value.minute = item.minute;
|
|
3973
|
-
if (format == "HH:mm") {
|
|
3974
|
-
dbClick && onConfirm();
|
|
3975
|
-
} else if (timeRef.value.minute != item.minute) {
|
|
3976
|
-
secondItems.value = buildSecondItems(item, min, max);
|
|
3977
|
-
}
|
|
3978
|
-
}
|
|
3979
|
-
}
|
|
3980
|
-
function onSecondClick(item, dbClick) {
|
|
3981
|
-
if (item.disabled != true) {
|
|
3982
|
-
timeRef.value.second = item.second;
|
|
3983
|
-
dbClick && onConfirm();
|
|
3984
|
-
}
|
|
3985
|
-
}
|
|
3986
|
-
function onConfirm() {
|
|
3987
|
-
if (isValidTimeRef.value == true) {
|
|
3988
|
-
const value = formatTimeValue(timeRef.value, format);
|
|
3989
|
-
emits("confirm", value);
|
|
3990
|
-
props.inPopup && props.closePopup(value);
|
|
3991
|
-
}
|
|
3992
|
-
}
|
|
3993
|
-
onMounted(rebuildItems);
|
|
3994
|
-
return (_ctx, _cache) => {
|
|
3995
|
-
return openBlock(), createBlock(_sfc_main$f, {
|
|
3996
|
-
class: normalizeClass(["time-picker pc", {
|
|
3997
|
-
"second-disabled": unref(format) != "HH:mm:ss"
|
|
3998
|
-
}]),
|
|
3999
|
-
direction: "vertical"
|
|
4000
|
-
}, createSlots({
|
|
4001
|
-
main: withCtx(() => [createVNode(_sfc_main$x, {
|
|
4002
|
-
multiple: "",
|
|
4003
|
-
effect: unref(MOTION).top
|
|
4004
|
-
}, {
|
|
4005
|
-
default: withCtx(() => [createElementVNode("div", _hoisted_1$7, [(openBlock(true), createElementBlock(Fragment, null, renderList(hourItems.value, item => {
|
|
4006
|
-
return openBlock(), createElementBlock("div", {
|
|
4007
|
-
class: normalizeClass(["tzi-number", {
|
|
4008
|
-
active: item.hour == timeRef.value.hour,
|
|
4009
|
-
disabled: item.disabled
|
|
4010
|
-
}]),
|
|
4011
|
-
key: item.hour,
|
|
4012
|
-
textContent: toDisplayString(unref(padStart)(item.hour, 2, "0")),
|
|
4013
|
-
onClick: $event => onHourClick(item),
|
|
4014
|
-
onDblclick: $event => onHourClick(item)
|
|
4015
|
-
}, null, 42, _hoisted_2$6);
|
|
4016
|
-
}), 128))], 512), createElementVNode("div", _hoisted_3$2, [(openBlock(true), createElementBlock(Fragment, null, renderList(minuteItems.value, item => {
|
|
4017
|
-
return openBlock(), createElementBlock("div", {
|
|
4018
|
-
class: normalizeClass(["tzi-number", {
|
|
4019
|
-
active: item.minute == timeRef.value.minute,
|
|
4020
|
-
disabled: item.disabled
|
|
4021
|
-
}]),
|
|
4022
|
-
key: `${item.hour}:${item.minute}`,
|
|
4023
|
-
textContent: toDisplayString(unref(padStart)(item.minute, 2, "0")),
|
|
4024
|
-
onClick: $event => onMinuteClick(item),
|
|
4025
|
-
onDblclick: $event => onMinuteClick(item, true)
|
|
4026
|
-
}, null, 42, _hoisted_4$2);
|
|
4027
|
-
}), 128))], 512), unref(format) == "HH:mm:ss" ? (openBlock(), createElementBlock("div", _hoisted_5$2, [(openBlock(true), createElementBlock(Fragment, null, renderList(secondItems.value, item => {
|
|
4028
|
-
return openBlock(), createElementBlock("div", {
|
|
4029
|
-
class: normalizeClass(["tzi-number", {
|
|
4030
|
-
active: item.second == timeRef.value.second,
|
|
4031
|
-
disabled: item.disabled
|
|
4032
|
-
}]),
|
|
4033
|
-
key: `${item.hour}:${item.minute}:${item.second}`,
|
|
4034
|
-
textContent: toDisplayString(unref(padStart)(item.second, 2, "0")),
|
|
4035
|
-
onClick: $event => onSecondClick(item),
|
|
4036
|
-
onDblclick: $event => onSecondClick(item, true)
|
|
4037
|
-
}, null, 42, _hoisted_6$2);
|
|
4038
|
-
}), 128))], 512)) : createCommentVNode("", true)]),
|
|
4039
|
-
_: 1
|
|
4040
|
-
}, 8, ["effect"])]),
|
|
4041
|
-
_: 2
|
|
4042
|
-
}, [__props.toolbarDisabled != true ? {
|
|
4043
|
-
name: "bottom",
|
|
4044
|
-
fn: withCtx(() => [__props.clearDisabled != true ? (openBlock(), createBlock(_sfc_main$G, {
|
|
4045
|
-
key: 0,
|
|
4046
|
-
type: "link",
|
|
4047
|
-
size: "small",
|
|
4048
|
-
textContent: "清空",
|
|
4049
|
-
onClick: _cache[0] || (_cache[0] = $event => (emits("clear"), __props.inPopup && __props.closePopup("")))
|
|
4050
|
-
})) : createCommentVNode("", true), __props.nowDisabled != true ? (openBlock(), createBlock(_sfc_main$G, {
|
|
4051
|
-
key: 1,
|
|
4052
|
-
type: "link",
|
|
4053
|
-
size: "small",
|
|
4054
|
-
textContent: "现在",
|
|
4055
|
-
onClick: _cache[1] || (_cache[1] = $event => rebuildItems(unref(getTimeValue)(new Date())))
|
|
4056
|
-
})) : createCommentVNode("", true), createVNode(_sfc_main$G, {
|
|
4057
|
-
type: "link",
|
|
4058
|
-
size: "small",
|
|
4059
|
-
textContent: "确定",
|
|
4060
|
-
class: normalizeClass({
|
|
4061
|
-
disabled: isValidTimeRef.value != true
|
|
4062
|
-
}),
|
|
4063
|
-
onClick: onConfirm
|
|
4064
|
-
}, null, 8, ["class"])]),
|
|
4065
|
-
key: "0"
|
|
4066
|
-
} : void 0]), 1032, ["class"]);
|
|
4067
|
-
};
|
|
4068
|
-
}
|
|
4069
|
-
});
|
|
4070
|
-
|
|
4071
|
-
const _hoisted_1$6 = ["textContent"];
|
|
4072
|
-
const _hoisted_2$5 = ["textContent"];
|
|
4073
|
-
const _hoisted_3$1 = ["textContent"];
|
|
4074
|
-
const _hoisted_4$1 = ["textContent", "onClick", "onDblclick"];
|
|
4075
|
-
const _hoisted_5$1 = ["textContent", "onClick", "onDblclick"];
|
|
4076
|
-
const _hoisted_6$1 = ["textContent"];
|
|
3897
|
+
const _hoisted_5$2 = ["textContent", "onClick", "onDblclick"];
|
|
3898
|
+
const _hoisted_6$2 = ["textContent"];
|
|
4077
3899
|
const _hoisted_7 = ["textContent", "onClick", "onDblclick"];
|
|
4078
3900
|
const _hoisted_8 = ["textContent"];
|
|
4079
|
-
var _sfc_main$
|
|
4080
|
-
__name: "date-
|
|
3901
|
+
var _sfc_main$7 = defineComponent({
|
|
3902
|
+
__name: "date-popup",
|
|
4081
3903
|
props: {
|
|
4082
3904
|
value: {},
|
|
4083
3905
|
format: {},
|
|
@@ -4294,7 +4116,7 @@ var _sfc_main$6 = defineComponent({
|
|
|
4294
4116
|
buildPickerItems(stepRef.value, 0);
|
|
4295
4117
|
return (_ctx, _cache) => {
|
|
4296
4118
|
return openBlock(), createBlock(_sfc_main$f, {
|
|
4297
|
-
class: normalizeClass(["date-picker
|
|
4119
|
+
class: normalizeClass(["snail-date-picker-popup", {
|
|
4298
4120
|
"time-now": __props.pinned && __props.pinned.value == true
|
|
4299
4121
|
}]),
|
|
4300
4122
|
direction: "vertical",
|
|
@@ -4318,16 +4140,16 @@ var _sfc_main$6 = defineComponent({
|
|
|
4318
4140
|
}, [stepRef.value == "year" ? (openBlock(), createElementBlock("div", {
|
|
4319
4141
|
key: 0,
|
|
4320
4142
|
textContent: toDisplayString(`${yearItems.value[0].year}年 - ${unref(getFromArray)(yearItems.value, -1).year}年`)
|
|
4321
|
-
}, null, 8, _hoisted_1$
|
|
4143
|
+
}, null, 8, _hoisted_1$7)) : (openBlock(), createElementBlock(Fragment, {
|
|
4322
4144
|
key: 1
|
|
4323
4145
|
}, [createElementVNode("div", {
|
|
4324
4146
|
textContent: toDisplayString(`${dateRef.value.year}年`),
|
|
4325
4147
|
onClick: _cache[1] || (_cache[1] = $event => onSwitchStepClick("year"))
|
|
4326
|
-
}, null, 8, _hoisted_2$
|
|
4148
|
+
}, null, 8, _hoisted_2$6), stepRef.value == "day" ? (openBlock(), createElementBlock("div", {
|
|
4327
4149
|
key: 0,
|
|
4328
4150
|
textContent: toDisplayString(`${dateRef.value.month}月`),
|
|
4329
4151
|
onClick: _cache[2] || (_cache[2] = $event => onSwitchStepClick("month"))
|
|
4330
|
-
}, null, 8, _hoisted_3$
|
|
4152
|
+
}, null, 8, _hoisted_3$2)) : createCommentVNode("", true)], 64))], 2), createVNode(_sfc_main$F, {
|
|
4331
4153
|
class: "flex-0",
|
|
4332
4154
|
type: "arrow",
|
|
4333
4155
|
button: "",
|
|
@@ -4349,7 +4171,7 @@ var _sfc_main$6 = defineComponent({
|
|
|
4349
4171
|
textContent: toDisplayString(item.year),
|
|
4350
4172
|
onClick: $event => onYearItemClick(item),
|
|
4351
4173
|
onDblclick: $event => onYearItemClick(item, true)
|
|
4352
|
-
}, null, 40, _hoisted_4$
|
|
4174
|
+
}, null, 40, _hoisted_4$2)], 2);
|
|
4353
4175
|
}), 128)) : stepRef.value == "month" ? (openBlock(true), createElementBlock(Fragment, {
|
|
4354
4176
|
key: 1
|
|
4355
4177
|
}, renderList(monthItems.value, item => {
|
|
@@ -4363,7 +4185,7 @@ var _sfc_main$6 = defineComponent({
|
|
|
4363
4185
|
textContent: toDisplayString(item.text),
|
|
4364
4186
|
onClick: $event => onMonthItemClick(item),
|
|
4365
4187
|
onDblclick: $event => onMonthItemClick(item, true)
|
|
4366
|
-
}, null, 40, _hoisted_5$
|
|
4188
|
+
}, null, 40, _hoisted_5$2)], 2);
|
|
4367
4189
|
}), 128)) : (openBlock(), createElementBlock(Fragment, {
|
|
4368
4190
|
key: 2
|
|
4369
4191
|
}, [(openBlock(), createElementBlock(Fragment, null, renderList(["日", "一", "二", "三", "四", "五", "六"], item => {
|
|
@@ -4371,7 +4193,7 @@ var _sfc_main$6 = defineComponent({
|
|
|
4371
4193
|
class: "day-item week",
|
|
4372
4194
|
key: item,
|
|
4373
4195
|
textContent: toDisplayString(item)
|
|
4374
|
-
}, null, 8, _hoisted_6$
|
|
4196
|
+
}, null, 8, _hoisted_6$2);
|
|
4375
4197
|
}), 64)), (openBlock(true), createElementBlock(Fragment, null, renderList(dayItemsRef.value, item => {
|
|
4376
4198
|
return openBlock(), createElementBlock("div", {
|
|
4377
4199
|
class: normalizeClass(["day-item", {
|
|
@@ -4426,6 +4248,200 @@ var _sfc_main$6 = defineComponent({
|
|
|
4426
4248
|
}
|
|
4427
4249
|
});
|
|
4428
4250
|
|
|
4251
|
+
const _hoisted_1$6 = {
|
|
4252
|
+
class: "tz-item",
|
|
4253
|
+
ref: "hour-items"
|
|
4254
|
+
};
|
|
4255
|
+
const _hoisted_2$5 = ["textContent", "onClick", "onDblclick"];
|
|
4256
|
+
const _hoisted_3$1 = {
|
|
4257
|
+
class: "tz-item",
|
|
4258
|
+
ref: "minute-items"
|
|
4259
|
+
};
|
|
4260
|
+
const _hoisted_4$1 = ["textContent", "onClick", "onDblclick"];
|
|
4261
|
+
const _hoisted_5$1 = {
|
|
4262
|
+
key: 0,
|
|
4263
|
+
class: "tz-item",
|
|
4264
|
+
ref: "second-items"
|
|
4265
|
+
};
|
|
4266
|
+
const _hoisted_6$1 = ["textContent", "onClick", "onDblclick"];
|
|
4267
|
+
var _sfc_main$6 = defineComponent({
|
|
4268
|
+
__name: "time-popup",
|
|
4269
|
+
props: {
|
|
4270
|
+
value: {},
|
|
4271
|
+
format: {},
|
|
4272
|
+
mode: {},
|
|
4273
|
+
min: {},
|
|
4274
|
+
max: {},
|
|
4275
|
+
toolbarDisabled: {
|
|
4276
|
+
type: Boolean
|
|
4277
|
+
},
|
|
4278
|
+
nowDisabled: {
|
|
4279
|
+
type: Boolean
|
|
4280
|
+
},
|
|
4281
|
+
clearDisabled: {
|
|
4282
|
+
type: Boolean
|
|
4283
|
+
},
|
|
4284
|
+
popup: {},
|
|
4285
|
+
picker: {},
|
|
4286
|
+
inPopup: {},
|
|
4287
|
+
closePopup: {
|
|
4288
|
+
type: Function
|
|
4289
|
+
},
|
|
4290
|
+
popupStatus: {},
|
|
4291
|
+
target: {},
|
|
4292
|
+
followX: {},
|
|
4293
|
+
followY: {},
|
|
4294
|
+
pinned: {}
|
|
4295
|
+
},
|
|
4296
|
+
emits: ["clear", "confirm"],
|
|
4297
|
+
setup(__props, _ref) {
|
|
4298
|
+
let {
|
|
4299
|
+
emit: __emit
|
|
4300
|
+
} = _ref;
|
|
4301
|
+
const props = __props;
|
|
4302
|
+
const emits = __emit;
|
|
4303
|
+
const format = props.format == "HH:mm" ? "HH:mm" : "HH:mm:ss";
|
|
4304
|
+
const min = parseTimeValue(props.min, "min");
|
|
4305
|
+
const max = parseTimeValue(props.max, "max");
|
|
4306
|
+
const timeRef = ref(parseTimeValue(props.value, "min") || getTimeValue(new Date()));
|
|
4307
|
+
const isValidTimeRef = computed(() => format == "HH:mm" ? minuteItems.value && minuteItems.value[timeRef.value.minute].disabled != true : secondItems.value && secondItems.value[timeRef.value.second].disabled != true);
|
|
4308
|
+
const hourItems = shallowRef(buildHourItems(min, max));
|
|
4309
|
+
const minuteItems = shallowRef();
|
|
4310
|
+
const secondItems = shallowRef();
|
|
4311
|
+
const hItemsDom = useTemplateRef("hour-items");
|
|
4312
|
+
const mItemsDom = useTemplateRef("minute-items");
|
|
4313
|
+
const sItemsDom = useTemplateRef("second-items");
|
|
4314
|
+
async function rebuildItems(time) {
|
|
4315
|
+
time != void 0 && (timeRef.value = time);
|
|
4316
|
+
minuteItems.value = buildMinuteItems(hourItems.value[timeRef.value.hour], min, max);
|
|
4317
|
+
secondItems.value = buildSecondItems(minuteItems.value[timeRef.value.minute], min, max);
|
|
4318
|
+
await nextTick();
|
|
4319
|
+
scrollIntoView(hItemsDom.value);
|
|
4320
|
+
scrollIntoView(mItemsDom.value);
|
|
4321
|
+
scrollIntoView(sItemsDom.value);
|
|
4322
|
+
}
|
|
4323
|
+
function scrollIntoView(items) {
|
|
4324
|
+
let activeIndex = void 0;
|
|
4325
|
+
for (var index = 0; index < (items ? items.children.length : 0); index++) {
|
|
4326
|
+
const ele = items.children[index];
|
|
4327
|
+
if (ele.classList.contains("active") == true) {
|
|
4328
|
+
activeIndex = index;
|
|
4329
|
+
break;
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
activeIndex != void 0 && items.children[activeIndex].scrollIntoView({
|
|
4333
|
+
behavior: "smooth",
|
|
4334
|
+
block: "center"
|
|
4335
|
+
});
|
|
4336
|
+
}
|
|
4337
|
+
function onHourClick(item, dbClick) {
|
|
4338
|
+
if (item.disabled != true && timeRef.value.hour != item.hour) {
|
|
4339
|
+
timeRef.value.hour = item.hour;
|
|
4340
|
+
minuteItems.value = buildMinuteItems(item, min, max);
|
|
4341
|
+
secondItems.value = buildSecondItems(minuteItems.value[timeRef.value.minute], min, max);
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4344
|
+
function onMinuteClick(item, dbClick) {
|
|
4345
|
+
if (item.disabled != true) {
|
|
4346
|
+
timeRef.value.minute = item.minute;
|
|
4347
|
+
if (format == "HH:mm") {
|
|
4348
|
+
dbClick && onConfirm();
|
|
4349
|
+
} else if (timeRef.value.minute != item.minute) {
|
|
4350
|
+
secondItems.value = buildSecondItems(item, min, max);
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
function onSecondClick(item, dbClick) {
|
|
4355
|
+
if (item.disabled != true) {
|
|
4356
|
+
timeRef.value.second = item.second;
|
|
4357
|
+
dbClick && onConfirm();
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
function onConfirm() {
|
|
4361
|
+
if (isValidTimeRef.value == true) {
|
|
4362
|
+
const value = formatTimeValue(timeRef.value, format);
|
|
4363
|
+
emits("confirm", value);
|
|
4364
|
+
props.inPopup && props.closePopup(value);
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
onMounted(rebuildItems);
|
|
4368
|
+
return (_ctx, _cache) => {
|
|
4369
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
4370
|
+
class: normalizeClass(["snail-time-picker-popup", {
|
|
4371
|
+
"second-disabled": unref(format) != "HH:mm:ss"
|
|
4372
|
+
}]),
|
|
4373
|
+
direction: "vertical"
|
|
4374
|
+
}, createSlots({
|
|
4375
|
+
main: withCtx(() => [createVNode(_sfc_main$x, {
|
|
4376
|
+
multiple: "",
|
|
4377
|
+
effect: unref(MOTION).top
|
|
4378
|
+
}, {
|
|
4379
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_1$6, [(openBlock(true), createElementBlock(Fragment, null, renderList(hourItems.value, item => {
|
|
4380
|
+
return openBlock(), createElementBlock("div", {
|
|
4381
|
+
class: normalizeClass(["tzi-number", {
|
|
4382
|
+
active: item.hour == timeRef.value.hour,
|
|
4383
|
+
disabled: item.disabled
|
|
4384
|
+
}]),
|
|
4385
|
+
key: item.hour,
|
|
4386
|
+
textContent: toDisplayString(unref(padStart)(item.hour, 2, "0")),
|
|
4387
|
+
onClick: $event => onHourClick(item),
|
|
4388
|
+
onDblclick: $event => onHourClick(item)
|
|
4389
|
+
}, null, 42, _hoisted_2$5);
|
|
4390
|
+
}), 128))], 512), createElementVNode("div", _hoisted_3$1, [(openBlock(true), createElementBlock(Fragment, null, renderList(minuteItems.value, item => {
|
|
4391
|
+
return openBlock(), createElementBlock("div", {
|
|
4392
|
+
class: normalizeClass(["tzi-number", {
|
|
4393
|
+
active: item.minute == timeRef.value.minute,
|
|
4394
|
+
disabled: item.disabled
|
|
4395
|
+
}]),
|
|
4396
|
+
key: `${item.hour}:${item.minute}`,
|
|
4397
|
+
textContent: toDisplayString(unref(padStart)(item.minute, 2, "0")),
|
|
4398
|
+
onClick: $event => onMinuteClick(item),
|
|
4399
|
+
onDblclick: $event => onMinuteClick(item, true)
|
|
4400
|
+
}, null, 42, _hoisted_4$1);
|
|
4401
|
+
}), 128))], 512), unref(format) == "HH:mm:ss" ? (openBlock(), createElementBlock("div", _hoisted_5$1, [(openBlock(true), createElementBlock(Fragment, null, renderList(secondItems.value, item => {
|
|
4402
|
+
return openBlock(), createElementBlock("div", {
|
|
4403
|
+
class: normalizeClass(["tzi-number", {
|
|
4404
|
+
active: item.second == timeRef.value.second,
|
|
4405
|
+
disabled: item.disabled
|
|
4406
|
+
}]),
|
|
4407
|
+
key: `${item.hour}:${item.minute}:${item.second}`,
|
|
4408
|
+
textContent: toDisplayString(unref(padStart)(item.second, 2, "0")),
|
|
4409
|
+
onClick: $event => onSecondClick(item),
|
|
4410
|
+
onDblclick: $event => onSecondClick(item, true)
|
|
4411
|
+
}, null, 42, _hoisted_6$1);
|
|
4412
|
+
}), 128))], 512)) : createCommentVNode("", true)]),
|
|
4413
|
+
_: 1
|
|
4414
|
+
}, 8, ["effect"])]),
|
|
4415
|
+
_: 2
|
|
4416
|
+
}, [__props.toolbarDisabled != true ? {
|
|
4417
|
+
name: "bottom",
|
|
4418
|
+
fn: withCtx(() => [__props.clearDisabled != true ? (openBlock(), createBlock(_sfc_main$G, {
|
|
4419
|
+
key: 0,
|
|
4420
|
+
type: "link",
|
|
4421
|
+
size: "small",
|
|
4422
|
+
textContent: "清空",
|
|
4423
|
+
onClick: _cache[0] || (_cache[0] = $event => (emits("clear"), __props.inPopup && __props.closePopup("")))
|
|
4424
|
+
})) : createCommentVNode("", true), __props.nowDisabled != true ? (openBlock(), createBlock(_sfc_main$G, {
|
|
4425
|
+
key: 1,
|
|
4426
|
+
type: "link",
|
|
4427
|
+
size: "small",
|
|
4428
|
+
textContent: "现在",
|
|
4429
|
+
onClick: _cache[1] || (_cache[1] = $event => rebuildItems(unref(getTimeValue)(new Date())))
|
|
4430
|
+
})) : createCommentVNode("", true), createVNode(_sfc_main$G, {
|
|
4431
|
+
type: "link",
|
|
4432
|
+
size: "small",
|
|
4433
|
+
textContent: "确定",
|
|
4434
|
+
class: normalizeClass({
|
|
4435
|
+
disabled: isValidTimeRef.value != true
|
|
4436
|
+
}),
|
|
4437
|
+
onClick: onConfirm
|
|
4438
|
+
}, null, 8, ["class"])]),
|
|
4439
|
+
key: "0"
|
|
4440
|
+
} : void 0]), 1032, ["class"]);
|
|
4441
|
+
};
|
|
4442
|
+
}
|
|
4443
|
+
});
|
|
4444
|
+
|
|
4429
4445
|
const _hoisted_1$5 = {
|
|
4430
4446
|
class: "snail-scroll-picker"
|
|
4431
4447
|
};
|
|
@@ -4545,21 +4561,24 @@ var _sfc_main$5 = defineComponent({
|
|
|
4545
4561
|
}
|
|
4546
4562
|
});
|
|
4547
4563
|
|
|
4548
|
-
function usePicker() {
|
|
4549
|
-
const
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4564
|
+
function usePicker(options) {
|
|
4565
|
+
const global = options ? options.global : false;
|
|
4566
|
+
const popup = usePopup({
|
|
4567
|
+
global
|
|
4568
|
+
});
|
|
4569
|
+
function showDate(target, options2, popupOptions) {
|
|
4570
|
+
options2 = {
|
|
4571
|
+
...options2
|
|
4553
4572
|
};
|
|
4554
|
-
return showPicker(target, _sfc_main$
|
|
4573
|
+
return showPicker(target, _sfc_main$7, options2, popupOptions);
|
|
4555
4574
|
}
|
|
4556
|
-
function showTime(target,
|
|
4557
|
-
|
|
4558
|
-
...
|
|
4575
|
+
function showTime(target, options2, popupOptions) {
|
|
4576
|
+
options2 = {
|
|
4577
|
+
...options2
|
|
4559
4578
|
};
|
|
4560
|
-
return showPicker(target, _sfc_main$
|
|
4579
|
+
return showPicker(target, _sfc_main$6, options2, popupOptions);
|
|
4561
4580
|
}
|
|
4562
|
-
function showScroll(
|
|
4581
|
+
function showScroll(options2) {
|
|
4563
4582
|
const popupOptions = {
|
|
4564
4583
|
mode: "dialog",
|
|
4565
4584
|
dialog: {
|
|
@@ -4567,9 +4586,9 @@ function usePicker() {
|
|
|
4567
4586
|
closeOnMask: true
|
|
4568
4587
|
}
|
|
4569
4588
|
};
|
|
4570
|
-
return showPicker(void 0, _sfc_main$5,
|
|
4589
|
+
return showPicker(void 0, _sfc_main$5, options2, popupOptions);
|
|
4571
4590
|
}
|
|
4572
|
-
function showPicker(target, component,
|
|
4591
|
+
function showPicker(target, component, options2, popupOptions) {
|
|
4573
4592
|
if (popupOptions && popupOptions.mode == "dialog") {
|
|
4574
4593
|
return popup.dialog({
|
|
4575
4594
|
component,
|
|
@@ -4578,7 +4597,7 @@ function usePicker() {
|
|
|
4578
4597
|
closeOnMask: true
|
|
4579
4598
|
}),
|
|
4580
4599
|
props: {
|
|
4581
|
-
...
|
|
4600
|
+
...options2,
|
|
4582
4601
|
picker: manager,
|
|
4583
4602
|
popup
|
|
4584
4603
|
}
|
|
@@ -4596,7 +4615,7 @@ function usePicker() {
|
|
|
4596
4615
|
...follow,
|
|
4597
4616
|
component,
|
|
4598
4617
|
props: {
|
|
4599
|
-
...
|
|
4618
|
+
...options2,
|
|
4600
4619
|
picker: manager,
|
|
4601
4620
|
popup
|
|
4602
4621
|
}
|
|
@@ -4607,7 +4626,10 @@ function usePicker() {
|
|
|
4607
4626
|
showDate,
|
|
4608
4627
|
showTime,
|
|
4609
4628
|
showScroll
|
|
4610
|
-
},
|
|
4629
|
+
}, {
|
|
4630
|
+
global,
|
|
4631
|
+
type: "IPickerManager"
|
|
4632
|
+
}));
|
|
4611
4633
|
manager.onDestroy(popup.destroy);
|
|
4612
4634
|
return manager;
|
|
4613
4635
|
}
|
|
@@ -5108,7 +5130,7 @@ const components = {
|
|
|
5108
5130
|
};
|
|
5109
5131
|
|
|
5110
5132
|
onMountScope(scope => {
|
|
5111
|
-
getCurrentScope() && onScopeDispose(scope.destroy);
|
|
5133
|
+
scope.global != true && getCurrentScope() && onScopeDispose(scope.destroy);
|
|
5112
5134
|
});
|
|
5113
5135
|
|
|
5114
5136
|
export { MOTION, components, getBuiltinIcon, mount, onAppCreated, triggerAppCreated, usePicker, usePopup, useReactive, useTreeContext };
|