@fox-js/foxui 4.0.1-4 → 4.0.1-5

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/foxui.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*!
3
- * @fox-js/foxui v4.0.0 Thu Sep 08 2022 20:09:31 GMT+0800 (中国标准时间)
3
+ * @fox-js/foxui v4.0.0 Wed Sep 14 2022 20:37:50 GMT+0800 (中国标准时间)
4
4
  */
5
5
  import { getCurrentInstance, inject, effectScope, watchEffect, nextTick, reactive, isReactive, provide, onUnmounted, watch, computed, toRef, ref, unref, defineComponent, onMounted, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot, resolveComponent, createBlock, createCommentVNode, toDisplayString, Fragment, renderList, createTextVNode, createVNode, shallowRef, markRaw, triggerRef, h, createElementVNode, Transition, withCtx, withDirectives, vShow, render as render$5, onDeactivated, onBeforeUnmount, onActivated, withModifiers, onBeforeMount, toRefs, Teleport, toRaw, createSlots, readonly, useSlots, shallowReactive, isVNode, mergeProps, vModelText, resolveDynamicComponent } from 'vue';
6
6
  import { isEqual, toBoolean, extend, toNumber, isObject, isDate, isPromise } from '@fox-js/fox';
@@ -2233,7 +2233,7 @@ const component$c = (componentName, scope) => {
2233
2233
  };
2234
2234
  };
2235
2235
 
2236
- const _hoisted_1$1i = {
2236
+ const _hoisted_1$1j = {
2237
2237
  key: 1,
2238
2238
  class: "fox-header__title"
2239
2239
  };
@@ -2241,7 +2241,7 @@ const _hoisted_2$10 = {
2241
2241
  key: 0,
2242
2242
  class: "tab-title"
2243
2243
  };
2244
- const _hoisted_3$N = ["onClick"];
2244
+ const _hoisted_3$O = ["onClick"];
2245
2245
  const _hoisted_4$C = {
2246
2246
  key: 0,
2247
2247
  class: "fox-tab-active__line"
@@ -2279,7 +2279,7 @@ function render$3(_ctx, _cache, $props, $setup, $data, $options) {
2279
2279
  ], 4))
2280
2280
  : createCommentVNode("", true),
2281
2281
  (_ctx.mTitleShow)
2282
- ? (openBlock(), createElementBlock("view", _hoisted_1$1i, [
2282
+ ? (openBlock(), createElementBlock("view", _hoisted_1$1j, [
2283
2283
  renderSlot(_ctx.$slots, "default", {}, () => [
2284
2284
  (_ctx.mTabsShow)
2285
2285
  ? (openBlock(), createElementBlock("view", _hoisted_2$10, [
@@ -2296,7 +2296,7 @@ function render$3(_ctx, _cache, $props, $setup, $data, $options) {
2296
2296
  createVNode(_component_fox_icon, { name: "joy-smile" })
2297
2297
  ]))
2298
2298
  : createCommentVNode("", true)
2299
- ], 14, _hoisted_3$N))
2299
+ ], 14, _hoisted_3$O))
2300
2300
  }), 128))
2301
2301
  ]))
2302
2302
  : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
@@ -2898,7 +2898,7 @@ const _sfc_main$1T = create$1T({
2898
2898
  };
2899
2899
  }
2900
2900
  });
2901
- const _hoisted_1$1h = ["innerHTML"];
2901
+ const _hoisted_1$1i = ["innerHTML"];
2902
2902
  const _hoisted_2$$ = ["innerHTML"];
2903
2903
  function _sfc_render$1A(_ctx, _cache, $props, $setup, $data, $options) {
2904
2904
  return openBlock(), createElementBlock("view", {
@@ -2908,7 +2908,7 @@ function _sfc_render$1A(_ctx, _cache, $props, $setup, $data, $options) {
2908
2908
  key: 0,
2909
2909
  class: normalizeClass(["fox-price--symbol", `fox-price--symbol-${_ctx.size}`]),
2910
2910
  innerHTML: _ctx.showSymbol
2911
- }, null, 10, _hoisted_1$1h)) : createCommentVNode("", true),
2911
+ }, null, 10, _hoisted_1$1i)) : createCommentVNode("", true),
2912
2912
  createElementVNode("view", {
2913
2913
  class: normalizeClass(`fox-price--${_ctx.size}`)
2914
2914
  }, toDisplayString(_ctx.intText), 3),
@@ -3008,7 +3008,7 @@ const _sfc_main$1S = create$1S({
3008
3008
  };
3009
3009
  }
3010
3010
  });
3011
- const _hoisted_1$1g = {
3011
+ const _hoisted_1$1h = {
3012
3012
  key: 1,
3013
3013
  class: "text"
3014
3014
  };
@@ -3028,7 +3028,7 @@ function _sfc_render$1z(_ctx, _cache, $props, $setup, $data, $options) {
3028
3028
  key: 0,
3029
3029
  price: _ctx.message,
3030
3030
  position: "before"
3031
- }, null, 8, ["price"])) : (openBlock(), createElementBlock("span", _hoisted_1$1g, toDisplayString(_ctx.message), 1))
3031
+ }, null, 8, ["price"])) : (openBlock(), createElementBlock("span", _hoisted_1$1h, toDisplayString(_ctx.message), 1))
3032
3032
  ], 6),
3033
3033
  createElementVNode("view", {
3034
3034
  class: normalizeClass(_ctx.arrowClasses),
@@ -3395,7 +3395,7 @@ const _sfc_main$1R = create$1R({
3395
3395
  };
3396
3396
  }
3397
3397
  });
3398
- const _hoisted_1$1f = { class: "text" };
3398
+ const _hoisted_1$1g = { class: "text" };
3399
3399
  function _sfc_render$1y(_ctx, _cache, $props, $setup, $data, $options) {
3400
3400
  const _component_fox_icon = resolveComponent("fox-icon");
3401
3401
  return openBlock(), createElementBlock("view", {
@@ -3438,7 +3438,7 @@ function _sfc_render$1y(_ctx, _cache, $props, $setup, $data, $options) {
3438
3438
  class: "icon",
3439
3439
  name: _ctx.mIcon
3440
3440
  }, null, 8, ["name"])) : createCommentVNode("", true),
3441
- createElementVNode("view", _hoisted_1$1f, toDisplayString(_ctx.mTip), 1)
3441
+ createElementVNode("view", _hoisted_1$1g, toDisplayString(_ctx.mTip), 1)
3442
3442
  ], 6)) : createCommentVNode("", true),
3443
3443
  renderSlot(_ctx.$slots, "hide")
3444
3444
  ], 6);
@@ -4290,7 +4290,7 @@ const _sfc_main$1N = create$1N({
4290
4290
  };
4291
4291
  }
4292
4292
  });
4293
- const _hoisted_1$1e = ["rows", "disabled", "readonly", "value", "maxlength", "placeholder", "autofocus"];
4293
+ const _hoisted_1$1f = ["rows", "disabled", "readonly", "value", "maxlength", "placeholder", "autofocus"];
4294
4294
  const _hoisted_2$_ = {
4295
4295
  key: 0,
4296
4296
  class: "fox-textarea__limit"
@@ -4313,7 +4313,7 @@ function _sfc_render$1x(_ctx, _cache, $props, $setup, $data, $options) {
4313
4313
  maxlength: _ctx.maxLength,
4314
4314
  placeholder: _ctx.placeholder,
4315
4315
  autofocus: _ctx.autofocus
4316
- }, null, 44, _hoisted_1$1e),
4316
+ }, null, 44, _hoisted_1$1f),
4317
4317
  _ctx.limitShow ? (openBlock(), createElementBlock("view", _hoisted_2$_, toDisplayString(_ctx.modelValue ? _ctx.modelValue.length : 0) + "/" + toDisplayString(_ctx.maxLength), 1)) : createCommentVNode("", true)
4318
4318
  ], 2);
4319
4319
  }
@@ -4470,7 +4470,7 @@ const popupProps = {
4470
4470
  }
4471
4471
  };
4472
4472
 
4473
- const commonProps = {
4473
+ const commonColumnProps = {
4474
4474
  readonly: {
4475
4475
  type: Boolean,
4476
4476
  default: false
@@ -4489,15 +4489,18 @@ const commonProps = {
4489
4489
  required: false,
4490
4490
  default: "value"
4491
4491
  },
4492
- itemOptions: {
4493
- type: [Object, Function],
4494
- required: false
4492
+ threeDimensional: {
4493
+ type: Boolean,
4494
+ default: true
4495
+ },
4496
+ swipeDuration: {
4497
+ type: [Number, String],
4498
+ default: 1e3
4495
4499
  }
4496
4500
  };
4497
-
4498
4501
  const pickerProps = {
4499
4502
  ...popupProps,
4500
- ...commonProps,
4503
+ ...commonColumnProps,
4501
4504
  modelValue: {
4502
4505
  type: [String, Number, Boolean, Object, Array],
4503
4506
  default: ""
@@ -4636,7 +4639,7 @@ const _sfc_main$1K = create$1K({
4636
4639
  props: {
4637
4640
  ...popupProps
4638
4641
  },
4639
- emits: ["click", "click-close-icon", "open", "close", "opend", "closed", "update:visible", "click-overlay"],
4642
+ emits: ["click", "click-close-icon", "open", "close", "opened", "closed", "update:visible", "click-overlay"],
4640
4643
  setup(props, { emit }) {
4641
4644
  const popupRef = ref();
4642
4645
  const state = reactive({
@@ -4701,7 +4704,7 @@ const _sfc_main$1K = create$1K({
4701
4704
  }
4702
4705
  };
4703
4706
  const onOpened = (e) => {
4704
- emit("opend", e);
4707
+ emit("opened", e);
4705
4708
  };
4706
4709
  const onClosed = (e) => {
4707
4710
  emit("closed", e);
@@ -4765,7 +4768,7 @@ const _sfc_main$1K = create$1K({
4765
4768
  };
4766
4769
  }
4767
4770
  });
4768
- const _hoisted_1$1d = { key: 1 };
4771
+ const _hoisted_1$1e = { key: 1 };
4769
4772
  function _sfc_render$1v(_ctx, _cache, $props, $setup, $data, $options) {
4770
4773
  const _component_fox_overlay = resolveComponent("fox-overlay");
4771
4774
  const _component_fox_icon = resolveComponent("fox-icon");
@@ -4813,7 +4816,7 @@ function _sfc_render$1v(_ctx, _cache, $props, $setup, $data, $options) {
4813
4816
  ]),
4814
4817
  _: 3
4815
4818
  }, 8, ["name", "onAfterEnter", "onAfterLeave"])
4816
- ], 8, ["to"])) : (openBlock(), createElementBlock("view", _hoisted_1$1d, [
4819
+ ], 8, ["to"])) : (openBlock(), createElementBlock("view", _hoisted_1$1e, [
4817
4820
  _ctx.overlay ? (openBlock(), createBlock(_component_fox_overlay, {
4818
4821
  key: 0,
4819
4822
  visible: _ctx.visible,
@@ -4870,6 +4873,8 @@ function getDirection(x, y) {
4870
4873
  function useTouch$1() {
4871
4874
  const startX = ref(0);
4872
4875
  const startY = ref(0);
4876
+ const startTime = ref(0);
4877
+ const duration = ref(0);
4873
4878
  const moveX = ref(0);
4874
4879
  const moveY = ref(0);
4875
4880
  const deltaX = ref(0);
@@ -4885,11 +4890,13 @@ function useTouch$1() {
4885
4890
  offsetX.value = 0;
4886
4891
  offsetY.value = 0;
4887
4892
  direction.value = "";
4893
+ startTime.value = 0;
4888
4894
  };
4889
4895
  const start = (event) => {
4890
4896
  reset();
4891
4897
  startX.value = event.touches[0].clientX;
4892
4898
  startY.value = event.touches[0].clientY;
4899
+ startTime.value = Date.now();
4893
4900
  };
4894
4901
  const move = (event) => {
4895
4902
  const touch = event.touches[0];
@@ -4899,6 +4906,7 @@ function useTouch$1() {
4899
4906
  moveY.value = touch.clientY;
4900
4907
  offsetX.value = Math.abs(deltaX.value);
4901
4908
  offsetY.value = Math.abs(deltaY.value);
4909
+ duration.value = Date.now() - startTime.value;
4902
4910
  if (!direction.value) {
4903
4911
  direction.value = getDirection(offsetX.value, offsetY.value);
4904
4912
  }
@@ -4909,6 +4917,8 @@ function useTouch$1() {
4909
4917
  reset,
4910
4918
  startX,
4911
4919
  startY,
4920
+ startTime,
4921
+ duration,
4912
4922
  moveX,
4913
4923
  moveY,
4914
4924
  deltaX,
@@ -4921,12 +4931,12 @@ function useTouch$1() {
4921
4931
  };
4922
4932
  }
4923
4933
 
4924
- let gloabalItemHeight = 0;
4934
+ let globalItemHeight = 36;
4925
4935
  function getGlobalItemHeight() {
4926
- return gloabalItemHeight;
4936
+ return globalItemHeight;
4927
4937
  }
4928
4938
  function setGlobalItemHeight(h) {
4929
- gloabalItemHeight = h;
4939
+ globalItemHeight = h;
4930
4940
  }
4931
4941
  function getItemText$2(props, item) {
4932
4942
  if (typeof props.textName === "string" && props.textName.length > 0) {
@@ -4940,15 +4950,7 @@ function getItemValue$2(props, item) {
4940
4950
  }
4941
4951
  return item.value;
4942
4952
  }
4943
- function getItemOptions$2(props, item, column, index) {
4944
- if (typeof props.itemOptions === "function") {
4945
- return props.itemOptions(item, column, index);
4946
- } else if (isObject(props.itemProps)) {
4947
- return props.itemOptions;
4948
- }
4949
- return null;
4950
- }
4951
- function getCoumnOptions(props, index) {
4953
+ function getColumnOptions(props, index) {
4952
4954
  if (typeof props.itemOptions === "function") {
4953
4955
  return props.columnOptions(index);
4954
4956
  } else {
@@ -5129,9 +5131,6 @@ const MOMENTUM_LIMIT_DISTANCE = 15;
5129
5131
  const MOMENTUM_LIMIT_TIME = 300;
5130
5132
  const DEFAULT_DURATION = 200;
5131
5133
  const { create: create$1J } = createComponent("picker-column");
5132
- function range(num, min, max) {
5133
- return Math.min(Math.max(num, min), max);
5134
- }
5135
5134
  function stopPropagation(event) {
5136
5135
  event.stopPropagation();
5137
5136
  }
@@ -5149,7 +5148,7 @@ const _sfc_main$1J = create$1J({
5149
5148
  type: Array,
5150
5149
  default: []
5151
5150
  },
5152
- column: {
5151
+ columnIndex: {
5153
5152
  type: Number,
5154
5153
  required: true,
5155
5154
  default: 0
@@ -5164,39 +5163,66 @@ const _sfc_main$1J = create$1J({
5164
5163
  required: true,
5165
5164
  default: 35
5166
5165
  },
5167
- ...commonProps
5166
+ ...commonColumnProps
5168
5167
  },
5169
5168
  emits: ["click", "change", "update:modelValue"],
5170
5169
  setup(props, { emit }) {
5171
5170
  const classes = computed(() => {
5172
5171
  return {
5173
- "fox-picker__content": true
5172
+ "fox-picker__list": true
5174
5173
  };
5175
5174
  });
5176
5175
  const styles = computed(() => {
5177
- let height = toNumber(props.visibleItemCount) * +props.itemHeight;
5176
+ const height = toNumber(props.visibleItemCount) * +props.itemHeight;
5178
5177
  return {
5179
5178
  height: `${height}px`
5180
5179
  };
5181
5180
  });
5182
- const wrapper = ref();
5181
+ const contentClasses = computed(() => {
5182
+ return {
5183
+ "fox-picker__content": true,
5184
+ "fox-picker__content-tile": !props.threeDimensional,
5185
+ "fox-picker__content-roller": props.threeDimensional
5186
+ };
5187
+ });
5188
+ const baseOffset = computed(() => {
5189
+ return props.itemHeight * Math.floor(+props.visibleItemCount / 2);
5190
+ });
5191
+ const isHidden = (index) => {
5192
+ if (index >= state.currIndex + 8 || index <= state.currIndex - 8) {
5193
+ return true;
5194
+ } else {
5195
+ return false;
5196
+ }
5197
+ };
5198
+ const touchRollerStyle = computed(() => {
5199
+ return {
5200
+ transition: `transform ${state.scrollTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
5201
+ transform: `rotate3d(1, 0, 0, ${state.deg})`,
5202
+ top: `${baseOffset.value}px`
5203
+ };
5204
+ });
5205
+ const setRollerStyle = (index) => {
5206
+ return `transform: rotate3d(1, 0, 0, ${-state.rotation * index}deg) translate3d(0px, 0px, 104px)`;
5207
+ };
5208
+ const touchTileStyle = computed(() => {
5209
+ return {
5210
+ transition: `transform ${state.scrollTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
5211
+ transform: `translate3d(0, ${state.scrollDistance + baseOffset.value}px, 0)`
5212
+ };
5213
+ });
5214
+ const roller = ref(null);
5183
5215
  const state = reactive({
5184
- offset: 0,
5185
- duration: 0,
5216
+ currIndex: props.modelValue,
5217
+ startDistance: 0,
5218
+ scrollDistance: 0,
5219
+ scrollTime: 0,
5186
5220
  moving: false,
5187
- startOffset: 0,
5188
- touchStartTime: 0,
5189
- momentumOffset: 0,
5221
+ rotation: 20,
5222
+ deg: 0,
5190
5223
  transitionEndTrigger: null
5191
5224
  });
5192
- watch([() => props.modelValue, () => props.itemHeight], ([val]) => {
5193
- setIndex(val);
5194
- });
5195
5225
  const source = toRef(props, "source");
5196
- const itemDisabled = (item, index) => {
5197
- let options = getItemOptions$2(props, item, props.column, index);
5198
- return options != null && options.disabled === true;
5199
- };
5200
5226
  const itemText = (item) => {
5201
5227
  return getItemText$2(props, item);
5202
5228
  };
@@ -5204,69 +5230,80 @@ const _sfc_main$1J = create$1J({
5204
5230
  return getItemValue$2(props, item);
5205
5231
  };
5206
5232
  const touch = useTouch$1();
5207
- const wrapperStyle = computed(() => ({
5208
- transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
5209
- transitionDuration: `${state.duration}ms`,
5210
- transitionProperty: state.duration ? "all" : "none"
5211
- }));
5212
- const getIndexByOffset = (offset) => {
5213
- return range(Math.round(-offset / +props.itemHeight), 0, props.source.length - 1);
5214
- };
5215
- const baseOffset = () => {
5216
- return +props.itemHeight * (+props.visibleItemCount - 1) / 2;
5217
- };
5218
5233
  const stopMomentum = () => {
5219
- state.moving = false;
5220
- state.duration = 0;
5221
5234
  if (state.transitionEndTrigger) {
5222
5235
  state.transitionEndTrigger();
5223
5236
  state.transitionEndTrigger = null;
5224
5237
  }
5225
5238
  };
5226
- const adjustIndex = (index) => {
5227
- index = range(index, 0, source.value.length);
5228
- for (let i = index; i < source.value.length; i++) {
5229
- if (!itemDisabled(source.value[i], i)) {
5230
- return i;
5239
+ const setIndex = (index, emitChange = false, transition = false) => {
5240
+ state.currIndex = index;
5241
+ if (emitChange) {
5242
+ const trigger = () => {
5243
+ state.moving = false;
5244
+ emit("update:modelValue", index);
5245
+ emit("change", index);
5246
+ };
5247
+ if (transition) {
5248
+ state.transitionEndTrigger = trigger;
5249
+ } else {
5250
+ trigger();
5231
5251
  }
5232
5252
  }
5233
- for (let i = index - 1; i >= 0; i--) {
5234
- if (!itemDisabled(source.value[i], i)) {
5235
- return i;
5253
+ };
5254
+ const setMove = (move, type, time) => {
5255
+ let updateMove = move + state.startDistance;
5256
+ if (type === "end") {
5257
+ const min = -(source.value.length - 1) * props.itemHeight;
5258
+ if (updateMove < min) {
5259
+ updateMove = min;
5260
+ if (!time || time <= 0) {
5261
+ time = props.swipeDuration;
5262
+ }
5263
+ }
5264
+ if (updateMove > 0) {
5265
+ updateMove = 0;
5266
+ if (!time || time <= 0) {
5267
+ time = props.swipeDuration;
5268
+ }
5269
+ }
5270
+ let updateIndex = Math.abs(Math.round(-updateMove / props.itemHeight));
5271
+ const endMove = -updateIndex * props.itemHeight;
5272
+ const deg = `${(updateIndex + 1) * state.rotation}deg`;
5273
+ const transition = time ? time > 0 : false;
5274
+ setIndex(updateIndex, true, transition);
5275
+ setTransform(endMove, type, time, deg);
5276
+ } else {
5277
+ let deg = (-updateMove / props.itemHeight + 1) * state.rotation;
5278
+ const maxDeg = (source.value.length + 1) * state.rotation;
5279
+ const minDeg = 0;
5280
+ deg = Math.min(Math.max(deg, minDeg), maxDeg);
5281
+ if (props.threeDimensional && (deg < minDeg || deg > maxDeg)) {
5282
+ return;
5236
5283
  }
5284
+ setTransform(updateMove, null, void 0, `${deg}deg`);
5237
5285
  }
5238
5286
  };
5239
- const setIndex = (index, emitChange = false) => {
5240
- index = adjustIndex(index) ?? 0;
5241
- const offset = -index * +props.itemHeight;
5242
- const trigger = () => {
5243
- if (emitChange) {
5244
- emit("update:modelValue", index);
5245
- emit("change", index);
5246
- }
5247
- };
5248
- if (state.moving && offset !== state.offset) {
5249
- state.transitionEndTrigger = trigger;
5287
+ const setTransform = (translateY = 0, type, time = DEFAULT_DURATION, deg) => {
5288
+ if (type === "end") {
5289
+ state.scrollTime = time;
5250
5290
  } else {
5251
- trigger();
5291
+ state.scrollTime = 0;
5252
5292
  }
5253
- state.offset = offset;
5293
+ state.deg = deg;
5294
+ state.scrollDistance = translateY;
5254
5295
  };
5255
5296
  const momentum = (distance, duration) => {
5256
5297
  const speed = Math.abs(distance / duration);
5257
- distance = state.offset + speed / 0.03 * (distance < 0 ? -1 : 1);
5258
- const index = getIndexByOffset(distance);
5259
- setIndex(index, true);
5298
+ distance = speed / 3e-3 * (distance < 0 ? -1 : 1);
5299
+ return distance;
5260
5300
  };
5261
5301
  const onTouchStart = (event) => {
5262
- if (props.readonly) {
5302
+ if (props.readonly || state.moving) {
5263
5303
  return;
5264
5304
  }
5305
+ state.startDistance = state.scrollDistance;
5265
5306
  touch.start(event);
5266
- state.startOffset = state.offset;
5267
- state.duration = 0;
5268
- state.touchStartTime = Date.now();
5269
- state.momentumOffset = state.startOffset;
5270
5307
  state.transitionEndTrigger = null;
5271
5308
  };
5272
5309
  const onTouchMove = (event) => {
@@ -5279,55 +5316,61 @@ const _sfc_main$1J = create$1J({
5279
5316
  state.moving = true;
5280
5317
  preventDefault(event, true);
5281
5318
  }
5282
- const moveOffset = state.startOffset + touch.deltaY.value;
5283
- if (moveOffset > props.itemHeight) {
5284
- state.offset = props.itemHeight;
5285
- } else {
5286
- state.offset = state.startOffset + touch.deltaY.value;
5287
- }
5288
- const now = Date.now();
5289
- if (now - state.touchStartTime > MOMENTUM_LIMIT_TIME) {
5290
- state.touchStartTime = now;
5291
- state.momentumOffset = state.offset;
5292
- }
5319
+ setMove(touch.deltaY.value, "", 0);
5293
5320
  };
5294
5321
  const onTouchEnd = () => {
5295
- const index = getIndexByOffset(state.offset);
5296
- state.duration = DEFAULT_DURATION;
5297
- setIndex(index, true);
5298
- const distance = state.offset - state.momentumOffset;
5299
- const duration = Date.now() - state.touchStartTime;
5322
+ if (props.readonly) {
5323
+ return;
5324
+ }
5325
+ const distance = touch.deltaY.value;
5326
+ const duration = touch.duration.value;
5300
5327
  const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
5301
5328
  if (allowMomentum) {
5302
- momentum(distance, duration);
5303
- return;
5329
+ const moveDistance = momentum(distance, duration);
5330
+ setMove(moveDistance, "end", props.swipeDuration);
5331
+ } else {
5332
+ setMove(distance, "end", 0);
5304
5333
  }
5305
5334
  };
5306
- onMounted(() => {
5307
- let h = +props.itemHeight;
5308
- if (h <= 0) {
5309
- return;
5335
+ watch(
5336
+ () => props.modelValue,
5337
+ (val) => {
5338
+ if (state.currIndex !== val) {
5339
+ state.currIndex = val;
5340
+ const moveDistance = -val * props.itemHeight;
5341
+ setMove(moveDistance);
5342
+ }
5310
5343
  }
5311
- setIndex(props.modelValue ?? 0);
5344
+ );
5345
+ onMounted(() => {
5346
+ const moveDistance = -props.modelValue * props.itemHeight;
5347
+ setMove(moveDistance);
5312
5348
  });
5313
5349
  return {
5314
5350
  classes,
5315
5351
  styles,
5352
+ contentClasses,
5316
5353
  source,
5317
- itemDisabled,
5318
5354
  itemText,
5319
5355
  itemValue,
5320
5356
  ...toRefs(state),
5321
- wrapper,
5357
+ roller,
5322
5358
  getItemText: getItemText$2,
5323
5359
  onTouchStart,
5324
5360
  onTouchMove,
5325
5361
  onTouchEnd,
5326
- wrapperStyle,
5362
+ isHidden,
5363
+ setRollerStyle,
5364
+ touchRollerStyle,
5365
+ touchTileStyle,
5327
5366
  stopMomentum
5328
5367
  };
5329
5368
  }
5330
5369
  });
5370
+ const _hoisted_1$1d = {
5371
+ key: 1,
5372
+ class: "fox-picker__item-tile"
5373
+ };
5331
5374
  function _sfc_render$1u(_ctx, _cache, $props, $setup, $data, $options) {
5332
5375
  return openBlock(), createElementBlock("view", {
5333
5376
  class: normalizeClass(_ctx.classes),
@@ -5339,19 +5382,22 @@ function _sfc_render$1u(_ctx, _cache, $props, $setup, $data, $options) {
5339
5382
  onTransitionend: _cache[4] || (_cache[4] = (...args) => _ctx.stopMomentum && _ctx.stopMomentum(...args))
5340
5383
  }, [
5341
5384
  createElementVNode("view", {
5342
- ref: "wrapper",
5343
- class: "fox-picker__wrapper",
5344
- style: normalizeStyle(_ctx.wrapperStyle)
5385
+ ref: "roller",
5386
+ class: normalizeClass(_ctx.contentClasses),
5387
+ style: normalizeStyle(_ctx.threeDimensional ? _ctx.touchRollerStyle : _ctx.touchTileStyle)
5345
5388
  }, [
5346
5389
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.source, (item, i) => {
5347
- return openBlock(), createElementBlock(Fragment, null, [
5348
- !_ctx.itemDisabled(item, i) ? (openBlock(), createElementBlock("view", {
5349
- key: i,
5350
- class: "fox-picker__item fox-picker__item-ref"
5351
- }, toDisplayString(_ctx.itemText(item, i)), 1)) : createCommentVNode("", true)
5390
+ return openBlock(), createElementBlock(Fragment, {
5391
+ key: `${_ctx.columnIndex}_${i}`
5392
+ }, [
5393
+ _ctx.threeDimensional ? (openBlock(), createElementBlock("view", {
5394
+ key: 0,
5395
+ class: normalizeClass(["fox-picker__item", { "fox-picker__item-hidden": _ctx.isHidden(i + 1) }]),
5396
+ style: normalizeStyle(_ctx.setRollerStyle(i + 1))
5397
+ }, toDisplayString(_ctx.itemText(item)), 7)) : (openBlock(), createElementBlock("view", _hoisted_1$1d, toDisplayString(_ctx.itemText(item)), 1))
5352
5398
  ], 64);
5353
- }), 256))
5354
- ], 4)
5399
+ }), 128))
5400
+ ], 6)
5355
5401
  ], 38);
5356
5402
  }
5357
5403
  var column = /* @__PURE__ */ _export_sfc(_sfc_main$1J, [["render", _sfc_render$1u]]);
@@ -5369,19 +5415,17 @@ const _sfc_main$1I = create$1I({
5369
5415
  setup(props, { emit }) {
5370
5416
  const { toLocaleRefs, t } = useFoxI18n(scope$s);
5371
5417
  const localeProps = toLocaleRefs(props, ["title", "cancelText", "clearText", "confirmText"]);
5372
- const cloumnsRef = ref();
5418
+ const pickerLineRef = ref(null);
5373
5419
  const itemHeight = ref(getGlobalItemHeight());
5374
5420
  watch(
5375
5421
  () => props.visible,
5376
5422
  (visible) => {
5377
5423
  if (visible && itemHeight.value <= 0) {
5378
5424
  setTimeout(() => {
5379
- if (cloumnsRef.value) {
5380
- const node = cloumnsRef.value.querySelector(".fox-picker__item-ref");
5381
- if (node) {
5382
- itemHeight.value = node.getBoundingClientRect().height;
5383
- setGlobalItemHeight(itemHeight.value);
5384
- }
5425
+ if (pickerLineRef.value) {
5426
+ const rect = useRect(pickerLineRef.value);
5427
+ itemHeight.value = rect.height;
5428
+ setGlobalItemHeight(itemHeight.value);
5385
5429
  }
5386
5430
  }, 50);
5387
5431
  }
@@ -5461,7 +5505,7 @@ const _sfc_main$1I = create$1I({
5461
5505
  }
5462
5506
  );
5463
5507
  const getDefaultIndex = (column2) => {
5464
- let options = getCoumnOptions(props, column2);
5508
+ let options = getColumnOptions(props, column2);
5465
5509
  if (isObject(options)) {
5466
5510
  return options.getDefautIndex ?? 0;
5467
5511
  }
@@ -5471,7 +5515,7 @@ const _sfc_main$1I = create$1I({
5471
5515
  if (props.readonly === true) {
5472
5516
  return true;
5473
5517
  }
5474
- let options = getCoumnOptions(props, column2);
5518
+ let options = getColumnOptions(props, column2);
5475
5519
  if (isObject(options)) {
5476
5520
  return options.readonly ?? false;
5477
5521
  }
@@ -5613,7 +5657,7 @@ const _sfc_main$1I = create$1I({
5613
5657
  };
5614
5658
  return {
5615
5659
  ...localeProps,
5616
- cloumnsRef,
5660
+ pickerLineRef,
5617
5661
  classes,
5618
5662
  popupStyles,
5619
5663
  columns,
@@ -5632,10 +5676,8 @@ const _sfc_main$1I = create$1I({
5632
5676
  }
5633
5677
  });
5634
5678
  const _hoisted_1$1c = { class: "fox-picker__bar" };
5635
- const _hoisted_2$Z = {
5636
- class: "fox-picker__column",
5637
- ref: "cloumnsRef"
5638
- };
5679
+ const _hoisted_2$Z = { class: "fox-picker__title" };
5680
+ const _hoisted_3$N = { class: "fox-picker__column" };
5639
5681
  function _sfc_render$1t(_ctx, _cache, $props, $setup, $data, $options) {
5640
5682
  const _component_fox_picker_column = resolveComponent("fox-picker-column");
5641
5683
  const _component_fox_popup = resolveComponent("fox-popup");
@@ -5656,22 +5698,23 @@ function _sfc_render$1t(_ctx, _cache, $props, $setup, $data, $options) {
5656
5698
  default: withCtx(() => [
5657
5699
  createElementVNode("view", _hoisted_1$1c, [
5658
5700
  createElementVNode("view", {
5659
- class: "fox-picker__left fox-picker__button",
5701
+ class: "fox-picker__cancel fox-picker__left fox-picker__button",
5660
5702
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.close && _ctx.close(...args))
5661
5703
  }, toDisplayString(_ctx.cancelText), 1),
5662
- createElementVNode("view", null, toDisplayString(_ctx.title), 1),
5704
+ createElementVNode("view", _hoisted_2$Z, toDisplayString(_ctx.title), 1),
5663
5705
  createElementVNode("view", {
5664
- class: "fox-picker__button",
5706
+ class: "fox-picker__confirm fox-picker__right fox-picker__button",
5665
5707
  onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirm())
5666
5708
  }, toDisplayString(_ctx.confirmText), 1)
5667
5709
  ]),
5668
5710
  renderSlot(_ctx.$slots, "top"),
5669
- createElementVNode("view", _hoisted_2$Z, [
5711
+ createElementVNode("view", _hoisted_3$N, [
5670
5712
  createElementVNode("view", {
5671
5713
  class: "fox-picker__mask",
5672
5714
  style: normalizeStyle({ backgroundSize: `100% ${_ctx.top}px` })
5673
5715
  }, null, 4),
5674
5716
  createElementVNode("view", {
5717
+ ref: "pickerLineRef",
5675
5718
  class: "fox-picker__hairline",
5676
5719
  style: normalizeStyle({ top: ` ${_ctx.top}px` })
5677
5720
  }, null, 4),
@@ -5683,18 +5726,19 @@ function _sfc_render$1t(_ctx, _cache, $props, $setup, $data, $options) {
5683
5726
  createVNode(_component_fox_picker_column, {
5684
5727
  source: item,
5685
5728
  readonly: _ctx.isReadonly(columnIndex),
5686
- column: columnIndex,
5729
+ "column-index": columnIndex,
5687
5730
  modelValue: _ctx.getIndex(columnIndex),
5688
5731
  "onUpdate:modelValue": ($event) => _ctx.change(columnIndex, $event),
5689
5732
  "visible-item-count": _ctx.visibleItemCount,
5733
+ "three-dimensional": _ctx.threeDimensional,
5734
+ "swipe-duration": _ctx.swipeDuration,
5690
5735
  "item-height": _ctx.itemHeight,
5691
- "item-options": _ctx.itemOptions,
5692
5736
  textName: _ctx.textName,
5693
5737
  valueName: _ctx.valueName
5694
- }, null, 8, ["source", "readonly", "column", "modelValue", "onUpdate:modelValue", "visible-item-count", "item-height", "item-options", "textName", "valueName"])
5738
+ }, null, 8, ["source", "readonly", "column-index", "modelValue", "onUpdate:modelValue", "visible-item-count", "three-dimensional", "swipe-duration", "item-height", "textName", "valueName"])
5695
5739
  ]);
5696
5740
  }), 128))
5697
- ], 512),
5741
+ ]),
5698
5742
  renderSlot(_ctx.$slots, "default")
5699
5743
  ]),
5700
5744
  _: 3
@@ -7162,6 +7206,18 @@ let datepickerProps = {
7162
7206
  default: () => new Date(currentYear + 10, 11, 31),
7163
7207
  validator: isDate
7164
7208
  },
7209
+ visibleItemCount: {
7210
+ type: [Number, String],
7211
+ default: 7
7212
+ },
7213
+ threeDimensional: {
7214
+ type: Boolean,
7215
+ default: true
7216
+ },
7217
+ swipeDuration: {
7218
+ type: [Number, String],
7219
+ default: 1e3
7220
+ },
7165
7221
  isWrapTeleport: {
7166
7222
  type: Boolean,
7167
7223
  default: true
@@ -7440,6 +7496,9 @@ function _sfc_render$1q(_ctx, _cache, $props, $setup, $data, $options) {
7440
7496
  title: _ctx.title,
7441
7497
  onConfirm: _ctx.onConfirm,
7442
7498
  onClose: _ctx.onClose,
7499
+ "visible-item-count": _ctx.visibleItemCount,
7500
+ "three-dimensional": _ctx.threeDimensional,
7501
+ "swipe-duration": _ctx.swipeDuration,
7443
7502
  isWrapTeleport: _ctx.isWrapTeleport
7444
7503
  }, {
7445
7504
  top: withCtx(() => [
@@ -7449,7 +7508,7 @@ function _sfc_render$1q(_ctx, _cache, $props, $setup, $data, $options) {
7449
7508
  renderSlot(_ctx.$slots, "default")
7450
7509
  ]),
7451
7510
  _: 3
7452
- }, 8, ["visible", "model-value", "source", "confirm-text", "cancel-text", "title", "onConfirm", "onClose", "isWrapTeleport"]);
7511
+ }, 8, ["visible", "model-value", "source", "confirm-text", "cancel-text", "title", "onConfirm", "onClose", "visible-item-count", "three-dimensional", "swipe-duration", "isWrapTeleport"]);
7453
7512
  }
7454
7513
  var DatePicker = /* @__PURE__ */ _export_sfc(_sfc_main$1D, [["render", _sfc_render$1q]]);
7455
7514
 
@@ -7556,9 +7615,9 @@ const _sfc_main$1C = create$1C({
7556
7615
  const onChange = (val) => {
7557
7616
  modelValue.value = val;
7558
7617
  if (props.valueFormat) {
7559
- let foramtVal = formatValue$2(props, val, props.valueFormat);
7560
- emitEvent("update:modelValue", foramtVal, {});
7561
- emitEvent("change", foramtVal, {});
7618
+ let formatVal = formatValue$2(props, val, props.valueFormat);
7619
+ emitEvent("update:modelValue", formatVal, {});
7620
+ emitEvent("change", formatVal, {});
7562
7621
  } else {
7563
7622
  emitEvent("update:modelValue", val, {});
7564
7623
  emitEvent("change", val, {});
@@ -11984,7 +12043,7 @@ const _sfc_main$1d = create$1d({
11984
12043
  };
11985
12044
  }
11986
12045
  });
11987
- const _hoisted_1$$ = { class: "fox-menu-item__content" };
12046
+ const _hoisted_1$$ = { class: "fox-menu-item__content fox-menu-item__overflow" };
11988
12047
  const _hoisted_2$Q = ["onClick"];
11989
12048
  function _sfc_render$1c(_ctx, _cache, $props, $setup, $data, $options) {
11990
12049
  const _component_fox_icon = resolveComponent("fox-icon");
@@ -13583,6 +13642,10 @@ const _sfc_main$11 = create$11({
13583
13642
  type: Boolean,
13584
13643
  default: true
13585
13644
  },
13645
+ clearIcon: {
13646
+ type: String,
13647
+ default: "circle-close"
13648
+ },
13586
13649
  background: {
13587
13650
  type: String,
13588
13651
  default: ""
@@ -13591,6 +13654,11 @@ const _sfc_main$11 = create$11({
13591
13654
  type: String,
13592
13655
  default: ""
13593
13656
  },
13657
+ focusStyle: {
13658
+ type: Object,
13659
+ default: () => {
13660
+ }
13661
+ },
13594
13662
  autofocus: {
13595
13663
  type: Boolean,
13596
13664
  default: false
@@ -13644,10 +13712,12 @@ const _sfc_main$11 = create$11({
13644
13712
  emit("update:modelValue", val, event);
13645
13713
  emit("change", val, event);
13646
13714
  };
13715
+ const focusCss = ref({});
13647
13716
  const valueFocus = (event) => {
13648
13717
  const input = event.target;
13649
13718
  let value = input.value;
13650
13719
  state.active = true;
13720
+ focusCss.value = props.focusStyle;
13651
13721
  emit("focus", value, event);
13652
13722
  };
13653
13723
  const valueBlur = (event) => {
@@ -13659,6 +13729,7 @@ const _sfc_main$11 = create$11({
13659
13729
  if (props.maxLength && value.length > Number(props.maxLength)) {
13660
13730
  value = value.slice(0, Number(props.maxLength));
13661
13731
  }
13732
+ focusCss.value = {};
13662
13733
  emit("blur", value, event);
13663
13734
  };
13664
13735
  const handleClear = (event) => {
@@ -13700,6 +13771,7 @@ const _sfc_main$11 = create$11({
13700
13771
  handleSubmit,
13701
13772
  searchbarStyle,
13702
13773
  inputSearchbarStyle,
13774
+ focusCss,
13703
13775
  clickInput,
13704
13776
  leftIconClick,
13705
13777
  rightIconClick,
@@ -13733,7 +13805,7 @@ function _sfc_render$10(_ctx, _cache, $props, $setup, $data, $options) {
13733
13805
  ])) : createCommentVNode("", true),
13734
13806
  createElementVNode("view", {
13735
13807
  class: "fox-searchbar__search-input",
13736
- style: normalizeStyle(_ctx.inputSearchbarStyle)
13808
+ style: normalizeStyle({ ..._ctx.inputSearchbarStyle, ..._ctx.focusCss })
13737
13809
  }, [
13738
13810
  _ctx.$slots.leftin ? (openBlock(), createElementBlock("view", {
13739
13811
  key: 0,
@@ -13769,10 +13841,10 @@ function _sfc_render$10(_ctx, _cache, $props, $setup, $data, $options) {
13769
13841
  class: "fox-searchbar__input-clear"
13770
13842
  }, [
13771
13843
  createVNode(_component_fox_icon, {
13772
- name: "circle-close",
13844
+ name: _ctx.clearIcon,
13773
13845
  size: "12",
13774
13846
  color: "#555"
13775
- })
13847
+ }, null, 8, ["name"])
13776
13848
  ], 512)), [
13777
13849
  [vShow, _ctx.modelValue.length > 0]
13778
13850
  ]) : createCommentVNode("", true)
@@ -15782,9 +15854,10 @@ const _sfc_main$U = create$U({
15782
15854
  });
15783
15855
  onDeactivated(() => {
15784
15856
  state.keepAlive = true;
15785
- myDrag.removeEventListener("touchstart", touchStart);
15786
- myDrag.removeEventListener("touchmove", touchMove);
15787
- myDrag.removeEventListener("touchend", touchEnd);
15857
+ const anyDrag = myDrag;
15858
+ anyDrag.value.removeEventListener("touchstart", touchStart);
15859
+ anyDrag.value.removeEventListener("touchmove", touchMove);
15860
+ anyDrag.value.removeEventListener("touchend", touchEnd);
15788
15861
  });
15789
15862
  return {
15790
15863
  classes,