@puresnake/snake-ui 0.0.0-stage → 0.0.1

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.
Files changed (279) hide show
  1. package/LICENSE +21 -0
  2. package/changelog.md +1 -0
  3. package/components/snake-activity-list/snake-activity-list.vue +365 -0
  4. package/components/snake-activity-list/types.ts +29 -0
  5. package/components/snake-auxiliary-segmentation/snake-auxiliary-segmentation.vue +44 -0
  6. package/components/snake-auxiliary-segmentation/types.ts +5 -0
  7. package/components/snake-button/snake-button.vue +357 -0
  8. package/components/snake-button/types.ts +103 -0
  9. package/components/snake-button-sort/snake-button-sort.vue +72 -0
  10. package/components/snake-button-sort/types.ts +22 -0
  11. package/components/snake-calendar/snake-calendar.vue +998 -0
  12. package/components/snake-calendar/types.ts +189 -0
  13. package/components/snake-cell-group/snake-cell-group.vue +55 -0
  14. package/components/snake-cell-group/types.ts +19 -0
  15. package/components/snake-cell-item/snake-cell-item.vue +159 -0
  16. package/components/snake-cell-item/types.ts +66 -0
  17. package/components/snake-checkbox/snake-checkbox.vue +264 -0
  18. package/components/snake-checkbox/types.ts +70 -0
  19. package/components/snake-checkbox-group/snake-checkbox-group.vue +154 -0
  20. package/components/snake-checkbox-group/types.ts +52 -0
  21. package/components/snake-cms/blocks/v2/cms-v2-carousel.vue +87 -0
  22. package/components/snake-cms/blocks/v2/cms-v2-coupon.vue +25 -0
  23. package/components/snake-cms/blocks/v2/cms-v2-custom.vue +12 -0
  24. package/components/snake-cms/blocks/v2/cms-v2-divider.vue +33 -0
  25. package/components/snake-cms/blocks/v2/cms-v2-floatbutton.vue +28 -0
  26. package/components/snake-cms/blocks/v2/cms-v2-goods-list.vue +150 -0
  27. package/components/snake-cms/blocks/v2/cms-v2-hotzone.vue +41 -0
  28. package/components/snake-cms/blocks/v2/cms-v2-images.vue +41 -0
  29. package/components/snake-cms/blocks/v2/cms-v2-magiccube.vue +93 -0
  30. package/components/snake-cms/blocks/v2/cms-v2-notice.vue +80 -0
  31. package/components/snake-cms/blocks/v2/cms-v2-popup.vue +46 -0
  32. package/components/snake-cms/blocks/v2/cms-v2-richtext.vue +18 -0
  33. package/components/snake-cms/blocks/v2/cms-v2-search.vue +115 -0
  34. package/components/snake-cms/blocks/v2/cms-v2-video.vue +25 -0
  35. package/components/snake-cms/blocks/v2/shared.ts +84 -0
  36. package/components/snake-cms/snake-cms.vue +409 -0
  37. package/components/snake-cms/types.ts +50 -0
  38. package/components/snake-commodity-search/snake-commodity-search.vue +234 -0
  39. package/components/snake-commodity-search/types.ts +11 -0
  40. package/components/snake-config-provider/snake-config-provider.vue +61 -0
  41. package/components/snake-config-provider/types.ts +22 -0
  42. package/components/snake-count-down/snake-count-down.vue +231 -0
  43. package/components/snake-count-down/types.ts +103 -0
  44. package/components/snake-coupon/snake-coupon.vue +209 -0
  45. package/components/snake-coupon/types.ts +21 -0
  46. package/components/snake-custom-module/snake-custom-module.vue +25 -0
  47. package/components/snake-custom-module/types.ts +11 -0
  48. package/components/snake-drop-menu/snake-drop-menu.vue +123 -0
  49. package/components/snake-drop-menu/types.ts +95 -0
  50. package/components/snake-drop-menu-item/snake-drop-menu-item.vue +181 -0
  51. package/components/snake-drop-menu-item/types.ts +48 -0
  52. package/components/snake-empty/snake-empty.vue +100 -0
  53. package/components/snake-empty/types.ts +48 -0
  54. package/components/snake-filter-sorts/filter-page.vue +695 -0
  55. package/components/snake-filter-sorts/snake-filter-sorts.vue +185 -0
  56. package/components/snake-filter-sorts/types.ts +57 -0
  57. package/components/snake-floating-bubble/snake-floating-bubble.vue +157 -0
  58. package/components/snake-floating-bubble/types.ts +43 -0
  59. package/components/snake-follow/snake-follow.vue +18 -0
  60. package/components/snake-follow/types.ts +2 -0
  61. package/components/snake-form/snake-form.vue +124 -0
  62. package/components/snake-form/types.ts +96 -0
  63. package/components/snake-form-item/snake-form-item.vue +331 -0
  64. package/components/snake-form-item/types.ts +70 -0
  65. package/components/snake-goods-list/snake-goods-list.vue +792 -0
  66. package/components/snake-goods-list/types.ts +55 -0
  67. package/components/snake-graphic-navigation/snake-graphic-navigation.vue +198 -0
  68. package/components/snake-graphic-navigation/types.ts +43 -0
  69. package/components/snake-icon/icon-names.ts +222 -0
  70. package/components/snake-icon/snake-icon.vue +220 -0
  71. package/components/snake-icon/types.ts +45 -0
  72. package/components/snake-image/snake-image.vue +230 -0
  73. package/components/snake-image/types.ts +70 -0
  74. package/components/snake-images/snake-images.vue +80 -0
  75. package/components/snake-images/types.ts +5 -0
  76. package/components/snake-index-anchor/snake-index-anchor.vue +83 -0
  77. package/components/snake-index-anchor/types.ts +14 -0
  78. package/components/snake-index-list/anchor-registry.ts +80 -0
  79. package/components/snake-index-list/snake-index-list.vue +259 -0
  80. package/components/snake-index-list/types.ts +115 -0
  81. package/components/snake-index-list-panel/snake-index-list-panel.vue +277 -0
  82. package/components/snake-index-list-panel/types.ts +10 -0
  83. package/components/snake-input/snake-input.vue +225 -0
  84. package/components/snake-input/types.ts +99 -0
  85. package/components/snake-jump-applet/snake-jump-applet.vue +99 -0
  86. package/components/snake-jump-applet/types.ts +17 -0
  87. package/components/snake-line/snake-line.vue +42 -0
  88. package/components/snake-line/types.ts +30 -0
  89. package/components/snake-line-progress/snake-line-progress.vue +105 -0
  90. package/components/snake-line-progress/types.ts +26 -0
  91. package/components/snake-link/snake-link.vue +74 -0
  92. package/components/snake-link/types.ts +30 -0
  93. package/components/snake-list-switching/components/tree-select/index.vue +156 -0
  94. package/components/snake-list-switching/snake-list-switching.vue +1285 -0
  95. package/components/snake-list-switching/types.ts +11 -0
  96. package/components/snake-loading/snake-loading.vue +241 -0
  97. package/components/snake-loading/types.ts +34 -0
  98. package/components/snake-loadmore/snake-loadmore.vue +103 -0
  99. package/components/snake-loadmore/types.ts +56 -0
  100. package/components/snake-magic-cube/snake-magic-cube.vue +622 -0
  101. package/components/snake-magic-cube/types.ts +5 -0
  102. package/components/snake-modal/snake-modal.vue +434 -0
  103. package/components/snake-modal/types.ts +71 -0
  104. package/components/snake-navbar/snake-navbar.vue +194 -0
  105. package/components/snake-navbar/types.ts +54 -0
  106. package/components/snake-no-network/snake-no-network.vue +125 -0
  107. package/components/snake-no-network/types.ts +27 -0
  108. package/components/snake-notice/snake-notice.vue +44 -0
  109. package/components/snake-notice/types.ts +5 -0
  110. package/components/snake-notice-bar/snake-notice-bar.vue +336 -0
  111. package/components/snake-notice-bar/types.ts +82 -0
  112. package/components/snake-overlay/snake-overlay.vue +73 -0
  113. package/components/snake-overlay/types.ts +35 -0
  114. package/components/snake-page-popup/snake-page-popup.vue +146 -0
  115. package/components/snake-page-popup/types.ts +28 -0
  116. package/components/snake-parse/audio/audio.vue +286 -0
  117. package/components/snake-parse/audio/context.js +11 -0
  118. package/components/snake-parse/audio/index.js +34 -0
  119. package/components/snake-parse/node/node.vue +830 -0
  120. package/components/snake-parse/parser.js +1480 -0
  121. package/components/snake-parse/snake-parse.vue +548 -0
  122. package/components/snake-parse/static/app-plus/snake-parse/js/handler.js +109 -0
  123. package/components/snake-parse/static/app-plus/snake-parse/js/uni.webview.js +0 -0
  124. package/components/snake-parse/static/app-plus/snake-parse/js/uni.webview.min.js +1 -0
  125. package/components/snake-parse/static/app-plus/snake-parse/local.html +3 -0
  126. package/components/snake-parse/style/index.js +132 -0
  127. package/components/snake-parse/style/parser.js +175 -0
  128. package/components/snake-parse/types.ts +49 -0
  129. package/components/snake-picture-ads/snake-picture-ads.vue +292 -0
  130. package/components/snake-picture-ads/types.ts +5 -0
  131. package/components/snake-popup/snake-popup.vue +348 -0
  132. package/components/snake-popup/types.ts +88 -0
  133. package/components/snake-qr-code/qrcode.ts +1214 -0
  134. package/components/snake-qr-code/snake-qr-code.vue +408 -0
  135. package/components/snake-qr-code/types.ts +78 -0
  136. package/components/snake-radio/snake-radio.vue +271 -0
  137. package/components/snake-radio/types.ts +64 -0
  138. package/components/snake-radio-group/snake-radio-group.vue +98 -0
  139. package/components/snake-radio-group/types.ts +48 -0
  140. package/components/snake-read-more/snake-read-more.vue +140 -0
  141. package/components/snake-read-more/types.ts +53 -0
  142. package/components/snake-rich-text/snake-rich-text.vue +24 -0
  143. package/components/snake-rich-text/types.ts +5 -0
  144. package/components/snake-root-portal/snake-root-portal.vue +92 -0
  145. package/components/snake-root-portal/types.ts +9 -0
  146. package/components/snake-search/snake-search.vue +202 -0
  147. package/components/snake-search/types.ts +84 -0
  148. package/components/snake-select/snake-select.vue +371 -0
  149. package/components/snake-select/types.ts +75 -0
  150. package/components/snake-skeleton/snake-skeleton.vue +104 -0
  151. package/components/snake-skeleton/types.ts +32 -0
  152. package/components/snake-skeleton-item/snake-skeleton-item.vue +90 -0
  153. package/components/snake-skeleton-item/types.ts +30 -0
  154. package/components/snake-slider/snake-slider.vue +249 -0
  155. package/components/snake-slider/types.ts +59 -0
  156. package/components/snake-sticky/snake-sticky.vue +178 -0
  157. package/components/snake-sticky/types.ts +48 -0
  158. package/components/snake-subsection/snake-subsection.vue +188 -0
  159. package/components/snake-subsection/types.ts +54 -0
  160. package/components/snake-swiper/snake-swiper.vue +229 -0
  161. package/components/snake-swiper/types.ts +79 -0
  162. package/components/snake-switch/snake-switch.vue +100 -0
  163. package/components/snake-switch/types.ts +41 -0
  164. package/components/snake-tabbar/snake-tabbar.vue +306 -0
  165. package/components/snake-tabbar/types.ts +93 -0
  166. package/components/snake-tabs/snake-tabs.vue +305 -0
  167. package/components/snake-tabs/types.ts +79 -0
  168. package/components/snake-text/snake-text.vue +292 -0
  169. package/components/snake-text/types.ts +100 -0
  170. package/components/snake-textarea/snake-textarea.vue +171 -0
  171. package/components/snake-textarea/types.ts +79 -0
  172. package/components/snake-toast/snake-toast.vue +330 -0
  173. package/components/snake-toast/types.ts +55 -0
  174. package/components/snake-tooltip/position.ts +33 -0
  175. package/components/snake-tooltip/snake-tooltip.vue +339 -0
  176. package/components/snake-tooltip/types.ts +80 -0
  177. package/components/snake-transition/snake-transition.vue +315 -0
  178. package/components/snake-transition/types.ts +65 -0
  179. package/components/snake-upload/snake-upload.vue +1801 -0
  180. package/components/snake-upload/types.ts +256 -0
  181. package/components/snake-videos/snake-videos.vue +122 -0
  182. package/components/snake-videos/types.ts +7 -0
  183. package/iconfont.css +881 -0
  184. package/index.d.ts +7 -0
  185. package/index.scss +26 -0
  186. package/index.ts +94 -0
  187. package/libs/cms/blocks.ts +103 -0
  188. package/libs/cms/config.ts +25 -0
  189. package/libs/cms/index.ts +7 -0
  190. package/libs/cms/normalize.ts +135 -0
  191. package/libs/cms/resolve.ts +12 -0
  192. package/libs/cms/types.ts +164 -0
  193. package/libs/cms/use-commerce.ts +385 -0
  194. package/libs/cms/v2.ts +193 -0
  195. package/libs/config/index.ts +4 -0
  196. package/libs/config/modal.ts +93 -0
  197. package/libs/config/state.ts +33 -0
  198. package/libs/config/theme.ts +351 -0
  199. package/libs/config/toast.ts +71 -0
  200. package/libs/config/types.ts +135 -0
  201. package/libs/config/zIndex.ts +44 -0
  202. package/libs/css/color.scss +105 -0
  203. package/libs/css/common.scss +171 -0
  204. package/libs/css/style.h5.scss +7 -0
  205. package/libs/css/style.mp.scss +7 -0
  206. package/libs/css/style.theme.scss +70 -0
  207. package/libs/css/style.vue.scss +140 -0
  208. package/libs/form/async-validator.min.d.ts +75 -0
  209. package/libs/form/async-validator.min.js +3 -0
  210. package/libs/form/index.ts +3 -0
  211. package/libs/form/path.ts +40 -0
  212. package/libs/form/types.ts +51 -0
  213. package/libs/form/validate.ts +149 -0
  214. package/libs/foundation.ts +96 -0
  215. package/libs/function/$parent.ts +33 -0
  216. package/libs/function/clipboard.ts +13 -0
  217. package/libs/function/color.ts +55 -0
  218. package/libs/function/debounce.ts +34 -0
  219. package/libs/function/deepClone.ts +30 -0
  220. package/libs/function/deepMerge.ts +25 -0
  221. package/libs/function/emitter.ts +30 -0
  222. package/libs/function/format.ts +27 -0
  223. package/libs/function/getParent.ts +53 -0
  224. package/libs/function/getRect.ts +29 -0
  225. package/libs/function/guid.ts +11 -0
  226. package/libs/function/index.ts +31 -0
  227. package/libs/function/queryParams.ts +73 -0
  228. package/libs/function/random.ts +6 -0
  229. package/libs/function/randomArray.ts +14 -0
  230. package/libs/function/route.ts +155 -0
  231. package/libs/function/sleep.ts +7 -0
  232. package/libs/function/style.ts +58 -0
  233. package/libs/function/styleUtils.ts +83 -0
  234. package/libs/function/system.ts +14 -0
  235. package/libs/function/test.ts +202 -0
  236. package/libs/function/throttle.ts +36 -0
  237. package/libs/function/timeFormat.ts +27 -0
  238. package/libs/function/timeFrom.ts +27 -0
  239. package/libs/function/toast.ts +10 -0
  240. package/libs/function/trim.ts +11 -0
  241. package/libs/function/type2icon.ts +11 -0
  242. package/libs/function/unit.ts +45 -0
  243. package/libs/hooks/index.ts +11 -0
  244. package/libs/hooks/useChildren.ts +125 -0
  245. package/libs/hooks/useColor.ts +5 -0
  246. package/libs/hooks/useDebounce.ts +5 -0
  247. package/libs/hooks/useLocale.ts +13 -0
  248. package/libs/hooks/useModal.ts +131 -0
  249. package/libs/hooks/useParent.ts +62 -0
  250. package/libs/hooks/useRect.ts +44 -0
  251. package/libs/hooks/useRouter.ts +5 -0
  252. package/libs/hooks/useTheme.ts +31 -0
  253. package/libs/hooks/useThrottle.ts +5 -0
  254. package/libs/hooks/useToast.ts +116 -0
  255. package/libs/index.ts +18 -0
  256. package/libs/request/auto-http.ts +1 -0
  257. package/libs/request/index.ts +343 -0
  258. package/libs/runtime/accessors.ts +55 -0
  259. package/libs/runtime/context.ts +40 -0
  260. package/libs/runtime/index.ts +18 -0
  261. package/libs/runtime/types.ts +49 -0
  262. package/libs/util/calendar.ts +6 -0
  263. package/locale/index.ts +130 -0
  264. package/locale/lang/en-US.ts +67 -0
  265. package/locale/lang/zh-CN.ts +67 -0
  266. package/package.json +130 -5
  267. package/plugins/index.ts +1 -0
  268. package/plugins/root/README.md +86 -0
  269. package/plugins/root/index.ts +123 -0
  270. package/plugins/root/page.ts +77 -0
  271. package/plugins/root/root.ts +53 -0
  272. package/plugins/root/utils.ts +137 -0
  273. package/readme.md +79 -0
  274. package/theme.scss +118 -0
  275. package/types/components.d.ts +236 -0
  276. package/types/global.d.ts +21 -0
  277. package/types/index.d.ts +6 -0
  278. package/types/uni-app.d.ts +16 -0
  279. package/README.md +0 -3
@@ -0,0 +1,348 @@
1
+ <template>
2
+ <view class="snake-popup" :style="rootStyle">
3
+ <!-- 三层结构:根 / 遮罩 / 面板,全部收在根的层叠上下文内 -->
4
+ <snake-overlay
5
+ v-if="overlay"
6
+ :show="localShow"
7
+ :z-index="uZIndex - 2"
8
+ :duration="duration"
9
+ :opacity="overlayOpacity"
10
+ :lock-scroll="lockScroll"
11
+ :custom-style="overlayStyle"
12
+ @click="overlayClick"
13
+ />
14
+ <snake-transition
15
+ :show="localShow"
16
+ :name="transitionName"
17
+ :duration="duration"
18
+ :custom-class="['snake-popup__panel', `snake-popup__panel--${mode}`, customClass].filter(Boolean).join(' ')"
19
+ :custom-style="panelStyle"
20
+ @after-enter="emit('opened')"
21
+ @after-leave="emit('closed')"
22
+ >
23
+ <slot />
24
+ <view
25
+ v-if="closeable"
26
+ class="snake-popup__close"
27
+ :class="`snake-popup__close--${closeIconPos}`"
28
+ @click.stop="close"
29
+ >
30
+ <snake-icon :name="closeIcon" :color="closeIconColor" :size="closeIconSize" />
31
+ </view>
32
+ </snake-transition>
33
+ </view>
34
+ </template>
35
+
36
+ <script setup lang="ts">
37
+ /**
38
+ * @component Popup
39
+ * @description 基于 Overlay 与 Transition 的正式弹层,支持中心和四边弹出、圆角、关闭图标、安全区以及完整生命周期。
40
+ * @see /components/popup
41
+ */
42
+
43
+ import { computed, getCurrentInstance, ref, watch } from 'vue';
44
+ import type { CSSProperties } from 'vue';
45
+ import zIndex from '../../libs/config/zIndex';
46
+ import { addUnit } from '../../libs/function/unit';
47
+ import Icon from '../snake-icon/snake-icon.vue';
48
+ import Overlay from '../snake-overlay/snake-overlay.vue';
49
+ import Transition from '../snake-transition/snake-transition.vue';
50
+ import type { PopupEmits, PopupProps } from './types';
51
+
52
+ defineOptions({ name: 'Popup', options: { virtualHost: true, styleIsolation: 'shared' } });
53
+
54
+ const props = withDefaults(defineProps<PopupProps>(), {
55
+ modelValue: false,
56
+ mode: 'center',
57
+ bgColor: 'var(--snake-color-surface, #fff)',
58
+ zIndex: zIndex.popup,
59
+ duration: 300,
60
+ round: false,
61
+ zoom: true,
62
+ closeable: false,
63
+ closeIcon: 'close',
64
+ closeIconColor: 'var(--snake-color-text-muted, #909399)',
65
+ closeIconSize: 20,
66
+ closeIconPos: 'top-right',
67
+ closeOnClickOverlay: true,
68
+ overlay: true,
69
+ overlayOpacity: 0.5,
70
+ lockScroll: true,
71
+ overlayStyle: '',
72
+ safeAreaInsetBottom: false,
73
+ safeAreaInsetTop: false,
74
+ customClass: '',
75
+ customStyle: ''
76
+ });
77
+ const emit = defineEmits<PopupEmits>();
78
+ // Vue 3 对未传递的 Boolean prop 做 boolean casting(值为 false 而非 undefined),
79
+ // 不能用空值合并把 show 兜底到 modelValue:未绑定 show 时 v-model 通道会被 false 短路。
80
+ // 这里在 setup 时检测父组件是否真的绑定了 show,绑定则 show 优先,否则走 v-model(modelValue)。
81
+ const showBound = 'show' in (getCurrentInstance()?.vnode?.props ?? {});
82
+ const externalShow = computed(() => (showBound ? props.show : props.modelValue));
83
+ const localShow = ref(externalShow.value);
84
+ watch(externalShow, value => {
85
+ if (localShow.value === value) return;
86
+ localShow.value = value;
87
+ if (value) emit('open');
88
+ else emit('close');
89
+ emit('change', { show: value });
90
+ });
91
+
92
+ const transitionName = computed(() => {
93
+ if (props.mode === 'center') return props.zoom ? 'zoom-in' : 'fade';
94
+ return {
95
+ top: 'slide-down',
96
+ right: 'slide-left',
97
+ bottom: 'slide-up',
98
+ left: 'slide-right'
99
+ }[props.mode] as 'slide-down' | 'slide-left' | 'slide-up' | 'slide-right';
100
+ });
101
+ const radius = computed(() => {
102
+ if (props.round === false) return '0';
103
+ const value = props.round === true ? 'var(--snake-radius-large, 20rpx)' : addUnit(props.round, 'rpx');
104
+ // 四边弹层只圆远离屏幕边缘的一侧,否则贴着屏幕边的角会被圆掉露出页面背景
105
+ switch (props.mode) {
106
+ case 'top':
107
+ return `0 0 ${value} ${value}`;
108
+ case 'bottom':
109
+ return `${value} ${value} 0 0`;
110
+ case 'left':
111
+ return `0 ${value} ${value} 0`;
112
+ case 'right':
113
+ return `${value} 0 0 ${value}`;
114
+ default:
115
+ return value;
116
+ }
117
+ });
118
+ // 计算整理后的 z-index 值:缺失/非法时退回 popup 档
119
+ const uZIndex = computed(() => Number(props.zIndex) || zIndex.popup);
120
+ // 根节点持有整棵弹层的页面层级:遮罩与面板被锁进同一个专属
121
+ // 层叠上下文,页面元素无法插进遮罩与面板之间,任何一级行内层级在运行时丢失,
122
+ // 面板也不会被自家遮罩盖住(根为 fixed,即使行内 z 丢失也仍是独立层叠上下文)
123
+ const rootStyle = computed<CSSProperties>(() => ({
124
+ zIndex: uZIndex.value - 1,
125
+ // 采用 v-if 语义:弹层隐藏时整棵弹层不渲染,空壳不存在;
126
+ // 我们的根常驻(离场动画需要),隐藏时置 none 不拦截页面点击,显示时恢复 auto——
127
+ // 遮罩/面板自身零 pointer-events 声明,交互完全由根决定
128
+ pointerEvents: localShow.value ? 'auto' : 'none'
129
+ }));
130
+ const panelStyle = computed(() => [
131
+ {
132
+ backgroundColor: props.bgColor,
133
+ // 面板行内层级(uZ):排序范围是根节点的专属上下文,只需压过遮罩(uZ-2)
134
+ zIndex: uZIndex.value,
135
+ borderRadius: radius.value,
136
+ paddingBottom: props.safeAreaInsetBottom ? 'env(safe-area-inset-bottom)' : undefined,
137
+ paddingTop: props.safeAreaInsetTop ? 'env(safe-area-inset-top)' : undefined
138
+ },
139
+ props.customStyle
140
+ ]);
141
+
142
+ function setVisible(value: boolean) {
143
+ if (localShow.value === value) return;
144
+ localShow.value = value;
145
+ emit('update:modelValue', value);
146
+ emit('update:show', value);
147
+ if (value) emit('open');
148
+ else emit('close');
149
+ emit('change', { show: value });
150
+ }
151
+
152
+ function open() {
153
+ setVisible(true);
154
+ }
155
+ function close() {
156
+ setVisible(false);
157
+ }
158
+ function overlayClick(event: unknown) {
159
+ emit('click-overlay', event);
160
+ if (props.closeOnClickOverlay) close();
161
+ }
162
+
163
+ defineExpose({ open, close });
164
+ </script>
165
+
166
+ <style>
167
+ /* 全屏定位根:为遮罩与面板提供专属层叠上下文;隐藏时空根不拦截
168
+ 页面点击(pointer-events 由 rootStyle 动态切换),无遮罩弹层仍可点击面板以外的页面区域 */
169
+ .snake-popup {
170
+ position: fixed;
171
+ top: 0;
172
+ right: 0;
173
+ bottom: 0;
174
+ left: 0;
175
+ }
176
+ .snake-popup__panel {
177
+ /* 挂在 fixed 根内,定位基准仍是视口;行内 z-index 丢失时的基线层级(popup 档) */
178
+ position: absolute;
179
+ pointer-events: auto;
180
+ z-index: var(--snake-z-index-popup, 10075);
181
+ box-sizing: border-box;
182
+ max-width: 100%;
183
+ max-height: 100%;
184
+ overflow: auto;
185
+ }
186
+ .snake-popup__panel--center {
187
+ top: 50%;
188
+ left: 50%;
189
+ transform: translate(-50%, -50%);
190
+ }
191
+ .snake-popup__panel--center.snake-transition--zoom-in-enter {
192
+ animation-name: snake-popup-center-zoom-in;
193
+ }
194
+ .snake-popup__panel--center.snake-transition--zoom-in-leave {
195
+ animation-name: snake-popup-center-zoom-out;
196
+ }
197
+ /* 四边弹层整块滑入滑出:transition 通用滑入只有 40rpx 位移 + 淡入,这里覆盖为 100% 平移 */
198
+ .snake-popup__panel--bottom.snake-transition--slide-up-enter {
199
+ animation-name: snake-popup-slide-up-in;
200
+ }
201
+ .snake-popup__panel--bottom.snake-transition--slide-up-leave {
202
+ animation-name: snake-popup-slide-up-out;
203
+ }
204
+ .snake-popup__panel--top.snake-transition--slide-down-enter {
205
+ animation-name: snake-popup-slide-down-in;
206
+ }
207
+ .snake-popup__panel--top.snake-transition--slide-down-leave {
208
+ animation-name: snake-popup-slide-down-out;
209
+ }
210
+ .snake-popup__panel--left.snake-transition--slide-right-enter {
211
+ animation-name: snake-popup-slide-right-in;
212
+ }
213
+ .snake-popup__panel--left.snake-transition--slide-right-leave {
214
+ animation-name: snake-popup-slide-right-out;
215
+ }
216
+ .snake-popup__panel--right.snake-transition--slide-left-enter {
217
+ animation-name: snake-popup-slide-left-in;
218
+ }
219
+ .snake-popup__panel--right.snake-transition--slide-left-leave {
220
+ animation-name: snake-popup-slide-left-out;
221
+ }
222
+ .snake-popup__panel--top {
223
+ top: 0;
224
+ left: 0;
225
+ width: 100%;
226
+ }
227
+ .snake-popup__panel--bottom {
228
+ bottom: 0;
229
+ left: 0;
230
+ width: 100%;
231
+ }
232
+ .snake-popup__panel--left {
233
+ top: 0;
234
+ bottom: 0;
235
+ left: 0;
236
+ }
237
+ .snake-popup__panel--right {
238
+ top: 0;
239
+ right: 0;
240
+ bottom: 0;
241
+ }
242
+ .snake-popup__close {
243
+ position: absolute;
244
+ z-index: 1;
245
+ display: flex;
246
+ padding: 20rpx;
247
+ }
248
+ .snake-popup__close--top-left {
249
+ top: 0;
250
+ left: 0;
251
+ }
252
+ .snake-popup__close--top-right {
253
+ top: 0;
254
+ right: 0;
255
+ }
256
+ .snake-popup__close--bottom-left {
257
+ bottom: 0;
258
+ left: 0;
259
+ }
260
+ .snake-popup__close--bottom-right {
261
+ right: 0;
262
+ bottom: 0;
263
+ }
264
+ @keyframes snake-popup-center-zoom-in {
265
+ from {
266
+ opacity: 0;
267
+ transform: translate(-50%, -50%) scale(0.85);
268
+ }
269
+ to {
270
+ opacity: 1;
271
+ transform: translate(-50%, -50%) scale(1);
272
+ }
273
+ }
274
+ @keyframes snake-popup-center-zoom-out {
275
+ from {
276
+ opacity: 1;
277
+ transform: translate(-50%, -50%) scale(1);
278
+ }
279
+ to {
280
+ opacity: 0;
281
+ transform: translate(-50%, -50%) scale(0.85);
282
+ }
283
+ }
284
+ @keyframes snake-popup-slide-up-in {
285
+ from {
286
+ transform: translate3d(0, 100%, 0);
287
+ }
288
+ to {
289
+ transform: translate3d(0, 0, 0);
290
+ }
291
+ }
292
+ @keyframes snake-popup-slide-up-out {
293
+ from {
294
+ transform: translate3d(0, 0, 0);
295
+ }
296
+ to {
297
+ transform: translate3d(0, 100%, 0);
298
+ }
299
+ }
300
+ @keyframes snake-popup-slide-down-in {
301
+ from {
302
+ transform: translate3d(0, -100%, 0);
303
+ }
304
+ to {
305
+ transform: translate3d(0, 0, 0);
306
+ }
307
+ }
308
+ @keyframes snake-popup-slide-down-out {
309
+ from {
310
+ transform: translate3d(0, 0, 0);
311
+ }
312
+ to {
313
+ transform: translate3d(0, -100%, 0);
314
+ }
315
+ }
316
+ @keyframes snake-popup-slide-right-in {
317
+ from {
318
+ transform: translate3d(-100%, 0, 0);
319
+ }
320
+ to {
321
+ transform: translate3d(0, 0, 0);
322
+ }
323
+ }
324
+ @keyframes snake-popup-slide-right-out {
325
+ from {
326
+ transform: translate3d(0, 0, 0);
327
+ }
328
+ to {
329
+ transform: translate3d(-100%, 0, 0);
330
+ }
331
+ }
332
+ @keyframes snake-popup-slide-left-in {
333
+ from {
334
+ transform: translate3d(100%, 0, 0);
335
+ }
336
+ to {
337
+ transform: translate3d(0, 0, 0);
338
+ }
339
+ }
340
+ @keyframes snake-popup-slide-left-out {
341
+ from {
342
+ transform: translate3d(0, 0, 0);
343
+ }
344
+ to {
345
+ transform: translate3d(100%, 0, 0);
346
+ }
347
+ }
348
+ </style>
@@ -0,0 +1,88 @@
1
+ import type { StyleValue } from '../../types/global';
2
+
3
+ /** PopupMode 类型定义。 */
4
+ export type PopupMode = 'center' | 'top' | 'right' | 'bottom' | 'left';
5
+ /** PopupCloseIconPosition 类型定义。 */
6
+ export type PopupCloseIconPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
7
+
8
+ /** Popup 组件的公开属性。 */
9
+ export interface PopupProps {
10
+ /** 双向绑定的当前值。 */
11
+ modelValue?: boolean;
12
+ /** 是否显示组件。 */
13
+ show?: boolean;
14
+ /** 组件展示模式。 */
15
+ mode?: PopupMode;
16
+ /** 背景颜色。 */
17
+ bgColor?: string;
18
+ /** 组件层级。 */
19
+ zIndex?: number;
20
+ /** 动画持续时间。 */
21
+ duration?: number;
22
+ /** 是否显示为圆角样式。 */
23
+ round?: number | string | boolean;
24
+ /** zoom 配置。 */
25
+ zoom?: boolean;
26
+ /** 是否显示关闭按钮。 */
27
+ closeable?: boolean;
28
+ /** 关闭按钮图标名称。 */
29
+ closeIcon?: string;
30
+ /** 关闭按钮图标颜色。 */
31
+ closeIconColor?: string;
32
+ /** 关闭按钮图标尺寸。 */
33
+ closeIconSize?: number | string;
34
+ /** 关闭按钮所在位置。 */
35
+ closeIconPos?: PopupCloseIconPosition;
36
+ /** 点击遮罩时是否关闭组件。 */
37
+ closeOnClickOverlay?: boolean;
38
+ /** 是否显示遮罩层。 */
39
+ overlay?: boolean;
40
+ /** 遮罩层透明度。 */
41
+ overlayOpacity?: number;
42
+ /** 是否阻止遮罩区域的触摸滚动。 */
43
+ lockScroll?: boolean;
44
+ /** 遮罩层自定义样式。 */
45
+ overlayStyle?: StyleValue;
46
+ /** 是否适配底部安全区域。 */
47
+ safeAreaInsetBottom?: boolean;
48
+ /** 是否适配顶部安全区域。 */
49
+ safeAreaInsetTop?: boolean;
50
+ /** 根节点自定义类名。 */
51
+ customClass?: string;
52
+ /** 根节点自定义样式。 */
53
+ customStyle?: StyleValue;
54
+ }
55
+
56
+ /** PopupChange 事件详情。 */
57
+ export interface PopupChangeDetail {
58
+ /** 是否显示组件。 */
59
+ show: boolean;
60
+ }
61
+
62
+ /** Popup 组件的事件契约。 */
63
+ export type PopupEmits = {
64
+ /** update:modelValue 事件携带的参数。 */
65
+ 'update:modelValue': [value: boolean];
66
+ /** update:show 事件携带的参数。 */
67
+ 'update:show': [value: boolean];
68
+ /** open 事件携带的参数。 */
69
+ open: [];
70
+ /** opened 事件携带的参数。 */
71
+ opened: [];
72
+ /** close 事件携带的参数。 */
73
+ close: [];
74
+ /** closed 事件携带的参数。 */
75
+ closed: [];
76
+ /** change 事件携带的参数。 */
77
+ change: [detail: PopupChangeDetail];
78
+ /** click-overlay 事件携带的参数。 */
79
+ 'click-overlay': [event: unknown];
80
+ };
81
+
82
+ /** Popup 组件实例公开的方法和状态。 */
83
+ export interface PopupExpose {
84
+ /** open 方法。 */
85
+ open(): void;
86
+ /** close 方法。 */
87
+ close(): void;
88
+ }