unika-components 1.1.21 → 1.1.22

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.
@@ -28596,6 +28596,14 @@ var script$d = defineComponent({
28596
28596
  const inputValue = ref('');
28597
28597
  const hasError = ref(false);
28598
28598
  const isTouched = ref(false);
28599
+ const inputRef = ref(null);
28600
+ const instanceId = ref(`input-${Math.random().toString(36).substr(2, 9)}`);
28601
+ const inputId = computed(() => `form-input-${props.element.id || instanceId.value}`);
28602
+ // 检测移动设备
28603
+ const isMobile = ref(false);
28604
+ const checkIfMobile = () => {
28605
+ isMobile.value = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
28606
+ };
28599
28607
  // 根据inputType确定验证类型
28600
28608
  const validatorType = computed(() => {
28601
28609
  switch (props.element.inputType) {
@@ -28633,12 +28641,68 @@ var script$d = defineComponent({
28633
28641
  isTouched.value = true;
28634
28642
  validate();
28635
28643
  };
28644
+ // 处理输入框聚焦时的滚动问题
28645
+ const handleFocus = () => {
28646
+ if (props.isPlatform || !isMobile.value || !inputRef.value)
28647
+ return;
28648
+ setTimeout(() => {
28649
+ const inputEl = inputRef.value;
28650
+ if (!inputEl)
28651
+ return;
28652
+ // 对于Android设备,需要额外处理
28653
+ if (/Android/i.test(navigator.userAgent)) {
28654
+ const scrollContainer = inputEl.closest('.scroll-long');
28655
+ if (scrollContainer) {
28656
+ const inputRect = inputEl.getBoundingClientRect();
28657
+ const scrollTop = window.scrollY || document.documentElement.scrollTop;
28658
+ const targetPosition = inputRect.top + scrollTop - (window.innerHeight / 3);
28659
+ window.scrollTo({
28660
+ top: targetPosition,
28661
+ behavior: 'smooth'
28662
+ });
28663
+ }
28664
+ }
28665
+ else {
28666
+ // iOS和其他设备
28667
+ const wrapper = inputEl.closest('.input-wrapper');
28668
+ if (wrapper) {
28669
+ wrapper.scrollIntoView({
28670
+ block: 'center',
28671
+ behavior: 'smooth'
28672
+ });
28673
+ }
28674
+ }
28675
+ }, 300);
28676
+ };
28677
+ // 处理Android键盘收起
28678
+ const handleAndroidBlur = () => {
28679
+ if (/Android/i.test(navigator.userAgent)) {
28680
+ setTimeout(() => {
28681
+ window.scrollTo(0, 0);
28682
+ }, 200);
28683
+ }
28684
+ };
28636
28685
  // 值变化时验证(如果已经触摸过)
28637
28686
  watch(inputValue, () => {
28638
28687
  if (isTouched.value) {
28639
28688
  validate();
28640
28689
  }
28641
28690
  });
28691
+ // 初始化
28692
+ onMounted(() => {
28693
+ checkIfMobile();
28694
+ if (inputRef.value) {
28695
+ inputRef.value.addEventListener('focus', handleFocus);
28696
+ inputRef.value.addEventListener('blur', handleAndroidBlur);
28697
+ }
28698
+ });
28699
+ // 清理
28700
+ onBeforeUnmount(() => {
28701
+ if (inputRef.value) {
28702
+ inputRef.value.removeEventListener('focus', handleFocus);
28703
+ inputRef.value.removeEventListener('blur', handleAndroidBlur);
28704
+ }
28705
+ });
28642
28706
  // 样式计算
28643
28707
  const required = computed(() => props.element.properties.required || false);
28644
28708
  const title = computed(() => props.element.title || '');
@@ -28651,6 +28715,13 @@ var script$d = defineComponent({
28651
28715
  transform: `rotate(${props.element.css.transform || 0}deg)`,
28652
28716
  opacity: props.element.css.opacity || 1
28653
28717
  }));
28718
+ const shadowStyle = computed(() => {
28719
+ const shadow = props.element.properties;
28720
+ if (shadow.shadowSize <= 0)
28721
+ return 'none';
28722
+ // Use px2rem for shadow values and remove props.unit (which does not exist)
28723
+ return `${px2rem(shadow.shadowX, props.isPlatform)} ${px2rem(shadow.shadowY, props.isPlatform)} ${px2rem(shadow.shadowBlur, props.isPlatform)} ${shadow.shadowColor}`;
28724
+ });
28654
28725
  const wrapperStyles = computed(() => ({
28655
28726
  backgroundColor: props.element.css.backgroundColor || '#fff',
28656
28727
  borderRadius: px2rem(props.element.css.borderRadius || 2, props.isPlatform),
@@ -28673,7 +28744,11 @@ var script$d = defineComponent({
28673
28744
  containerStyles,
28674
28745
  wrapperStyles,
28675
28746
  inputStyles,
28676
- handleBlur
28747
+ shadowStyle,
28748
+ handleBlur,
28749
+ inputRef,
28750
+ instanceId,
28751
+ inputId
28677
28752
  };
28678
28753
  }
28679
28754
  });
@@ -28682,12 +28757,12 @@ const _hoisted_1$7 = {
28682
28757
  key: 0,
28683
28758
  class: "required-marker"
28684
28759
  };
28685
- const _hoisted_2$7 = ["type", "placeholder"];
28760
+ const _hoisted_2$7 = ["id", "type", "placeholder", "data-instance-id"];
28686
28761
 
28687
28762
  function render$9(_ctx, _cache, $props, $setup, $data, $options) {
28688
28763
  return (openBlock(), createElementBlock("div", {
28689
28764
  class: "ele-form form-input eles",
28690
- style: normalizeStyle(_ctx.containerStyles)
28765
+ style: normalizeStyle({..._ctx.containerStyles, boxShadow: _ctx.shadowStyle})
28691
28766
  }, [
28692
28767
  createElementVNode("div", {
28693
28768
  class: "input-wrapper",
@@ -28700,12 +28775,15 @@ function render$9(_ctx, _cache, $props, $setup, $data, $options) {
28700
28775
  ? (openBlock(), createElementBlock("span", _hoisted_1$7, "*"))
28701
28776
  : createCommentVNode("v-if", true),
28702
28777
  withDirectives(createElementVNode("input", {
28778
+ id: _ctx.inputId,
28703
28779
  type: _ctx.inputType,
28704
28780
  placeholder: _ctx.title,
28705
28781
  "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((_ctx.inputValue) = $event)),
28706
28782
  style: normalizeStyle(_ctx.inputStyles),
28707
28783
  onBlur: _cache[1] || (_cache[1] = (...args) => (_ctx.handleBlur && _ctx.handleBlur(...args))),
28708
- class: "dynamic-placeholder-input"
28784
+ class: "dynamic-placeholder-input",
28785
+ ref: "inputRef",
28786
+ "data-instance-id": _ctx.instanceId
28709
28787
  }, null, 44 /* STYLE, PROPS, NEED_HYDRATION */, _hoisted_2$7), [
28710
28788
  [vModelDynamic, _ctx.inputValue]
28711
28789
  ])
@@ -28714,6 +28792,7 @@ function render$9(_ctx, _cache, $props, $setup, $data, $options) {
28714
28792
  }
28715
28793
 
28716
28794
  script$d.render = render$9;
28795
+ script$d.__scopeId = "data-v-af046be2";
28717
28796
  script$d.__file = "src/components/UniFormInput/UniFormInput.vue";
28718
28797
 
28719
28798
  var script$c = defineComponent({
@@ -29376,7 +29455,6 @@ function render$4(_ctx, _cache, $props, $setup, $data, $options) {
29376
29455
  }
29377
29456
 
29378
29457
  script$8.render = render$4;
29379
- script$8.__scopeId = "data-v-2d16d26f";
29380
29458
  script$8.__file = "src/components/UniFormContainer/UniFormContainer.vue";
29381
29459
 
29382
29460
  var script$7 = /*#__PURE__*/ defineComponent({
@@ -29992,6 +30070,8 @@ var script$2 = defineComponent({
29992
30070
  const direction = ref('up');
29993
30071
  const autoPlayTimer = ref(null);
29994
30072
  const isAutoPlaying = ref(false);
30073
+ const isMobile = ref(false);
30074
+ const isKeyboardActive = ref(false);
29995
30075
  const workData = computed(() => props.workData || { pages: [], global: {} });
29996
30076
  const personalData = computed(() => workData.value.personalData || {});
29997
30077
  const global = computed(() => workData.value.global || {});
@@ -29999,6 +30079,10 @@ var script$2 = defineComponent({
29999
30079
  const musicStatus = ref(false);
30000
30080
  const musicPlayer = ref();
30001
30081
  const { attemptAutoplay, playOnInteraction, pauseNonGlobalMusic, getCurrentMusicState } = useMusicManager();
30082
+ // 检测移动设备
30083
+ const checkIfMobile = () => {
30084
+ isMobile.value = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
30085
+ };
30002
30086
  // 处理首次交互
30003
30087
  const handleFirstInteraction = () => {
30004
30088
  const currentState = getCurrentMusicState();
@@ -30061,7 +30145,40 @@ var script$2 = defineComponent({
30061
30145
  watch(currentPageId, () => {
30062
30146
  startAutoPlay();
30063
30147
  });
30148
+ // 处理移动端键盘事件
30149
+ const handleMobileResize = () => {
30150
+ const activeElement = document.activeElement;
30151
+ if (activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA')) {
30152
+ setTimeout(() => {
30153
+ activeElement.scrollIntoView({
30154
+ block: 'center',
30155
+ behavior: 'smooth'
30156
+ });
30157
+ }, 100);
30158
+ }
30159
+ };
30160
+ const handleFocusIn = (e) => {
30161
+ const target = e.target;
30162
+ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
30163
+ isKeyboardActive.value = true;
30164
+ if (isAutoPlaying.value) {
30165
+ clearAutoPlayTimer();
30166
+ }
30167
+ }
30168
+ };
30169
+ const handleFocusOut = (e) => {
30170
+ const target = e.target;
30171
+ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
30172
+ isKeyboardActive.value = false;
30173
+ if (/Android/i.test(navigator.userAgent)) {
30174
+ setTimeout(() => {
30175
+ window.scrollTo(0, 0);
30176
+ }, 200);
30177
+ }
30178
+ }
30179
+ };
30064
30180
  onMounted(() => {
30181
+ checkIfMobile();
30065
30182
  startAutoPlay();
30066
30183
  if (global.value.music.url) {
30067
30184
  setTimeout(() => {
@@ -30073,9 +30190,19 @@ var script$2 = defineComponent({
30073
30190
  handleFirstInteraction();
30074
30191
  }, 1000);
30075
30192
  }
30193
+ if (isMobile.value) {
30194
+ window.addEventListener('resize', handleMobileResize);
30195
+ document.body.addEventListener('focusin', handleFocusIn);
30196
+ document.body.addEventListener('focusout', handleFocusOut);
30197
+ }
30076
30198
  });
30077
30199
  onBeforeUnmount(() => {
30078
30200
  clearAutoPlayTimer();
30201
+ if (isMobile.value) {
30202
+ window.removeEventListener('resize', handleMobileResize);
30203
+ document.body.removeEventListener('focusin', handleFocusIn);
30204
+ document.body.removeEventListener('focusout', handleFocusOut);
30205
+ }
30079
30206
  });
30080
30207
  const { handleTouchStart, handleTouchMove, handleTouchEnd, handleMouseDown, handleMouseMove, handleMouseUp } = useTouchHandler(pages, currentPageId, direction, isLoopEnabled, () => {
30081
30208
  handleFirstInteraction();
@@ -30180,6 +30307,7 @@ var script$2 = defineComponent({
30180
30307
  showPopup,
30181
30308
  direction,
30182
30309
  musicPlayer,
30310
+ isKeyboardActive,
30183
30311
  handleFirstInteraction,
30184
30312
  playMusic,
30185
30313
  px2rem,
@@ -30223,7 +30351,8 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
30223
30351
  onMousemove: _cache[4] || (_cache[4] = (...args) => (_ctx.handleMouseMove && _ctx.handleMouseMove(...args))),
30224
30352
  onMouseup: _cache[5] || (_cache[5] = (...args) => (_ctx.handleMouseUp && _ctx.handleMouseUp(...args))),
30225
30353
  onMouseleave: _cache[6] || (_cache[6] = (...args) => (_ctx.handleMouseUp && _ctx.handleMouseUp(...args))),
30226
- style: normalizeStyle(_ctx.containerStyle)
30354
+ style: normalizeStyle(_ctx.containerStyle),
30355
+ class: normalizeClass({ 'keyboard-active': _ctx.isKeyboardActive })
30227
30356
  }, [
30228
30357
  createCommentVNode(" 背景音乐 "),
30229
30358
  (_ctx.global && _ctx.global.music && _ctx.global.music.url)
@@ -30277,29 +30406,41 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
30277
30406
  }, {
30278
30407
  default: withCtx(() => [
30279
30408
  (openBlock(true), createElementBlock(Fragment, null, renderList(page.elements, (element) => {
30280
- return (openBlock(), createBlock(resolveDynamicComponent(_ctx.getComponentName(element.type)), {
30281
- key: element.id,
30282
- element: element,
30283
- isPlatform: _ctx.isPlatform,
30284
- global: _ctx.global,
30285
- env: _ctx.env,
30286
- personalData: _ctx.personalData,
30287
- onTrigger: _ctx.handleElementTrigger
30288
- }, null, 40 /* PROPS, NEED_HYDRATION */, ["element", "isPlatform", "global", "env", "personalData", "onTrigger"]))
30409
+ return (openBlock(), createElementBlock(Fragment, {
30410
+ key: element.id
30411
+ }, [
30412
+ (element.type !== 'group')
30413
+ ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.getComponentName(element.type)), {
30414
+ key: 0,
30415
+ element: element,
30416
+ isPlatform: _ctx.isPlatform,
30417
+ global: _ctx.global,
30418
+ env: _ctx.env,
30419
+ personalData: _ctx.personalData,
30420
+ onTrigger: _ctx.handleElementTrigger
30421
+ }, null, 40 /* PROPS, NEED_HYDRATION */, ["element", "isPlatform", "global", "env", "personalData", "onTrigger"]))
30422
+ : createCommentVNode("v-if", true)
30423
+ ], 64 /* STABLE_FRAGMENT */))
30289
30424
  }), 128 /* KEYED_FRAGMENT */))
30290
30425
  ]),
30291
30426
  _: 2 /* DYNAMIC */
30292
30427
  }, 1032 /* PROPS, DYNAMIC_SLOTS */, ["onSubmit"]))
30293
30428
  : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(page.elements, (element) => {
30294
- return (openBlock(), createBlock(resolveDynamicComponent(_ctx.getComponentName(element.type)), {
30295
- key: element.id,
30296
- element: element,
30297
- global: _ctx.global,
30298
- env: _ctx.env,
30299
- isPlatform: _ctx.isPlatform,
30300
- personalData: _ctx.personalData,
30301
- onTrigger: _ctx.handleElementTrigger
30302
- }, null, 40 /* PROPS, NEED_HYDRATION */, ["element", "global", "env", "isPlatform", "personalData", "onTrigger"]))
30429
+ return (openBlock(), createElementBlock(Fragment, {
30430
+ key: element.id
30431
+ }, [
30432
+ (element.type !== 'group')
30433
+ ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.getComponentName(element.type)), {
30434
+ key: 0,
30435
+ element: element,
30436
+ global: _ctx.global,
30437
+ env: _ctx.env,
30438
+ isPlatform: _ctx.isPlatform,
30439
+ personalData: _ctx.personalData,
30440
+ onTrigger: _ctx.handleElementTrigger
30441
+ }, null, 40 /* PROPS, NEED_HYDRATION */, ["element", "global", "env", "isPlatform", "personalData", "onTrigger"]))
30442
+ : createCommentVNode("v-if", true)
30443
+ ], 64 /* STABLE_FRAGMENT */))
30303
30444
  }), 128 /* KEYED_FRAGMENT */))
30304
30445
  ])
30305
30446
  ])
@@ -30314,7 +30455,7 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
30314
30455
  ], 2 /* CLASS */),
30315
30456
  createVNode(_component_UniBarrage, { global: _ctx.global }, null, 8 /* PROPS */, ["global"]),
30316
30457
  createVNode(_component_UniMenu, { global: _ctx.global }, null, 8 /* PROPS */, ["global"])
30317
- ], 36 /* STYLE, NEED_HYDRATION */))
30458
+ ], 38 /* CLASS, STYLE, NEED_HYDRATION */))
30318
30459
  }
30319
30460
 
30320
30461
  script$2.render = render$2;
@@ -30775,29 +30916,41 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
30775
30916
  }, {
30776
30917
  default: withCtx(() => [
30777
30918
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.page.elements, (element) => {
30778
- return (openBlock(), createBlock(resolveDynamicComponent(_ctx.getComponentName(element.type)), {
30779
- key: element.id,
30780
- element: element,
30781
- isPlatform: _ctx.isPlatform,
30782
- global: _ctx.global,
30783
- env: _ctx.env,
30784
- personalData: _ctx.personalData,
30785
- onTrigger: _ctx.handleElementTrigger
30786
- }, null, 40 /* PROPS, NEED_HYDRATION */, ["element", "isPlatform", "global", "env", "personalData", "onTrigger"]))
30919
+ return (openBlock(), createElementBlock(Fragment, {
30920
+ key: element.id
30921
+ }, [
30922
+ (element.type !== 'group')
30923
+ ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.getComponentName(element.type)), {
30924
+ key: 0,
30925
+ element: element,
30926
+ isPlatform: _ctx.isPlatform,
30927
+ global: _ctx.global,
30928
+ env: _ctx.env,
30929
+ personalData: _ctx.personalData,
30930
+ onTrigger: _ctx.handleElementTrigger
30931
+ }, null, 40 /* PROPS, NEED_HYDRATION */, ["element", "isPlatform", "global", "env", "personalData", "onTrigger"]))
30932
+ : createCommentVNode("v-if", true)
30933
+ ], 64 /* STABLE_FRAGMENT */))
30787
30934
  }), 128 /* KEYED_FRAGMENT */))
30788
30935
  ]),
30789
30936
  _: 1 /* STABLE */
30790
30937
  }, 8 /* PROPS */, ["onSubmit"]))
30791
30938
  : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.page.elements, (element) => {
30792
- return (openBlock(), createBlock(resolveDynamicComponent(_ctx.getComponentName(element.type)), {
30793
- key: element.id,
30794
- element: element,
30795
- global: _ctx.global,
30796
- env: _ctx.env,
30797
- isPlatform: _ctx.isPlatform,
30798
- personalData: _ctx.personalData,
30799
- onTrigger: _ctx.handleElementTrigger
30800
- }, null, 40 /* PROPS, NEED_HYDRATION */, ["element", "global", "env", "isPlatform", "personalData", "onTrigger"]))
30939
+ return (openBlock(), createElementBlock(Fragment, {
30940
+ key: element.id
30941
+ }, [
30942
+ (element.type !== 'group')
30943
+ ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.getComponentName(element.type)), {
30944
+ key: 0,
30945
+ element: element,
30946
+ global: _ctx.global,
30947
+ env: _ctx.env,
30948
+ isPlatform: _ctx.isPlatform,
30949
+ personalData: _ctx.personalData,
30950
+ onTrigger: _ctx.handleElementTrigger
30951
+ }, null, 40 /* PROPS, NEED_HYDRATION */, ["element", "global", "env", "isPlatform", "personalData", "onTrigger"]))
30952
+ : createCommentVNode("v-if", true)
30953
+ ], 64 /* STABLE_FRAGMENT */))
30801
30954
  }), 128 /* KEYED_FRAGMENT */))
30802
30955
  ])
30803
30956
  ], 36 /* STYLE, NEED_HYDRATION */)