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