@rxdrag/website-lib-core 0.0.4 → 0.0.7

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 (168) hide show
  1. package/index.ts +1 -0
  2. package/package.json +12 -13
  3. package/src/entify/Entify.ts +365 -0
  4. package/{dist/entify/index.d.ts → src/entify/index.ts} +4 -4
  5. package/src/entify/lib/createEntifyClient.ts +23 -0
  6. package/{dist/entify/lib/index.d.ts → src/entify/lib/index.ts} +29 -29
  7. package/src/entify/lib/langFields.ts +12 -0
  8. package/src/entify/lib/newAvatarQueryOptions.ts +5 -0
  9. package/src/entify/lib/newOgImageQueryOptions.ts +6 -0
  10. package/src/entify/lib/newPageMetaOptions.ts +20 -0
  11. package/src/entify/lib/newQueryPostOptions.ts +41 -0
  12. package/src/entify/lib/newQueryProductOptions.ts +90 -0
  13. package/src/entify/lib/newQueryProductsMediaOptions.ts +26 -0
  14. package/src/entify/lib/queryAllProducts.ts +27 -0
  15. package/src/entify/lib/queryEntityList.ts +44 -0
  16. package/src/entify/lib/queryFeaturedProducts.ts +47 -0
  17. package/src/entify/lib/queryLangs.ts +47 -0
  18. package/src/entify/lib/queryLatestPosts.ts +65 -0
  19. package/src/entify/lib/queryOneEntity.ts +67 -0
  20. package/src/entify/lib/queryOnePostById.ts +21 -0
  21. package/src/entify/lib/queryOnePostBySlug.ts +21 -0
  22. package/src/entify/lib/queryOnePostCategoryBySlug.ts +30 -0
  23. package/src/entify/lib/queryOneProductById.ts +20 -0
  24. package/src/entify/lib/queryOneProductBySlug.ts +21 -0
  25. package/src/entify/lib/queryOneProductCategoryBySlug.ts +30 -0
  26. package/src/entify/lib/queryOneTheme.ts +76 -0
  27. package/src/entify/lib/queryOneUser.ts +38 -0
  28. package/src/entify/lib/queryPostCategories.ts +48 -0
  29. package/src/entify/lib/queryPostSlugs.ts +32 -0
  30. package/src/entify/lib/queryPosts.ts +92 -0
  31. package/src/entify/lib/queryProductCategories.ts +44 -0
  32. package/src/entify/lib/queryProducts.ts +69 -0
  33. package/src/entify/lib/queryProductsInMenu.ts +31 -0
  34. package/src/entify/lib/queryUserIds.ts +24 -0
  35. package/src/entify/lib/queryUserPosts.ts +74 -0
  36. package/src/entify/lib/queryWebSiteSettings.ts +29 -0
  37. package/src/entify/lib/searchProducts.ts +70 -0
  38. package/src/entify/lib/sendEmail.ts +8 -0
  39. package/src/entify/lib/toQueryOptions.ts +20 -0
  40. package/src/entify/lib/upsertEntity.ts +9 -0
  41. package/src/entify/types/index.ts +2 -0
  42. package/src/entify/types/utils.ts +4 -0
  43. package/src/entify/types/variables.ts +7 -0
  44. package/src/entify/view-model/funcs.ts +271 -0
  45. package/src/entify/view-model/index.ts +2 -0
  46. package/src/entify/view-model/models.ts +143 -0
  47. package/{dist/index.d.ts → src/index.ts} +5 -5
  48. package/src/motion/consts.ts +598 -0
  49. package/{dist/motion/index.d.ts → src/motion/index.ts} +2 -2
  50. package/src/motion/types.ts +46 -0
  51. package/src/react/components/EnquiryForm/Input.tsx +52 -0
  52. package/src/react/components/EnquiryForm/Submit.tsx +30 -0
  53. package/src/react/components/EnquiryForm/Textarea.tsx +51 -0
  54. package/src/react/components/EnquiryForm/index.tsx +334 -0
  55. package/src/react/components/GoogleConsent/CookieItemPanel.tsx +81 -0
  56. package/src/react/components/GoogleConsent/CumtomizedModal.tsx +149 -0
  57. package/src/react/components/GoogleConsent/GoogleConsent.tsx +101 -0
  58. package/src/react/components/GoogleConsent/README.md +1 -0
  59. package/src/react/components/GoogleConsent/gtags.ts +68 -0
  60. package/src/react/components/GoogleConsent/index.ts +3 -0
  61. package/src/react/components/GoogleConsent/types.ts +18 -0
  62. package/src/react/components/GoogleConsent//345/217/202/350/200/203.md +4 -0
  63. package/src/react/components/Medias/index.tsx +347 -0
  64. package/src/react/components/ProductCard/ProductCard.tsx +23 -0
  65. package/src/react/components/ProductCard/ProductCardPreview.tsx +12 -0
  66. package/src/react/components/ProductCard/ProductCta/index.tsx +41 -0
  67. package/src/react/components/ProductCard/ProductCta/style.css +4 -0
  68. package/src/react/components/ProductCard/ProductDescription/index.tsx +13 -0
  69. package/src/react/components/ProductCard/ProductDescription/style.css +6 -0
  70. package/src/react/components/ProductCard/ProductMedia/index.tsx +34 -0
  71. package/src/react/components/ProductCard/ProductMedia/style.css +6 -0
  72. package/src/react/components/ProductCard/ProductTitle/index.tsx +7 -0
  73. package/src/react/components/ProductCard/ProductTitle/style.css +4 -0
  74. package/src/react/components/ProductCard/ProductView.tsx +35 -0
  75. package/{dist/react/components/ProductCard/index.d.ts → src/react/components/ProductCard/index.ts} +6 -6
  76. package/src/react/components/ProductCard/useQueryProduct.ts +32 -0
  77. package/src/react/components/RichTextOutline/index.tsx +76 -0
  78. package/src/react/components/RichTextOutline/useAcitviedHeading.ts +54 -0
  79. package/src/react/components/RichTextOutline/useAnchorScroll.ts +24 -0
  80. package/src/react/components/Scroller.tsx +7 -0
  81. package/src/react/components/SearchInput.tsx +34 -0
  82. package/src/react/components/Share/index.tsx +69 -0
  83. package/src/react/components/Share/socials.tsx +79 -0
  84. package/src/react/components/Share//350/265/204/346/226/231.md +7 -0
  85. package/src/react/components/ToTop/index.tsx +33 -0
  86. package/src/react/components/ToTop.tsx +33 -0
  87. package/{dist/react/components/index.d.ts → src/react/components/index.ts} +8 -8
  88. package/src/react/hooks/index.ts +1 -0
  89. package/src/react/hooks/useScroll.ts +23 -0
  90. package/{dist/react/index.d.ts → src/react/index.ts} +2 -2
  91. package/src/robots.ts +4 -0
  92. package/src/scripts/actions.ts +304 -0
  93. package/src/scripts/consts.ts +32 -0
  94. package/src/scripts/events.ts +33 -0
  95. package/{dist/scripts/index.d.ts → src/scripts/index.ts} +3 -3
  96. package/dist/entify/Entify.d.ts +0 -138
  97. package/dist/entify/lib/createEntifyClient.d.ts +0 -3
  98. package/dist/entify/lib/langFields.d.ts +0 -2
  99. package/dist/entify/lib/newAvatarQueryOptions.d.ts +0 -2
  100. package/dist/entify/lib/newOgImageQueryOptions.d.ts +0 -2
  101. package/dist/entify/lib/newPageMetaOptions.d.ts +0 -2
  102. package/dist/entify/lib/newQueryPostOptions.d.ts +0 -3
  103. package/dist/entify/lib/newQueryProductOptions.d.ts +0 -3
  104. package/dist/entify/lib/newQueryProductsMediaOptions.d.ts +0 -3
  105. package/dist/entify/lib/queryAllProducts.d.ts +0 -4
  106. package/dist/entify/lib/queryEntityList.d.ts +0 -3
  107. package/dist/entify/lib/queryFeaturedProducts.d.ts +0 -4
  108. package/dist/entify/lib/queryLangs.d.ts +0 -4
  109. package/dist/entify/lib/queryLatestPosts.d.ts +0 -4
  110. package/dist/entify/lib/queryOneEntity.d.ts +0 -5
  111. package/dist/entify/lib/queryOnePostById.d.ts +0 -3
  112. package/dist/entify/lib/queryOnePostBySlug.d.ts +0 -3
  113. package/dist/entify/lib/queryOnePostCategoryBySlug.d.ts +0 -3
  114. package/dist/entify/lib/queryOneProductById.d.ts +0 -3
  115. package/dist/entify/lib/queryOneProductBySlug.d.ts +0 -3
  116. package/dist/entify/lib/queryOneProductCategoryBySlug.d.ts +0 -3
  117. package/dist/entify/lib/queryOneTheme.d.ts +0 -3
  118. package/dist/entify/lib/queryOneUser.d.ts +0 -3
  119. package/dist/entify/lib/queryPostCategories.d.ts +0 -4
  120. package/dist/entify/lib/queryPostSlugs.d.ts +0 -4
  121. package/dist/entify/lib/queryPosts.d.ts +0 -10
  122. package/dist/entify/lib/queryProductCategories.d.ts +0 -4
  123. package/dist/entify/lib/queryProducts.d.ts +0 -6
  124. package/dist/entify/lib/queryProductsInMenu.d.ts +0 -2
  125. package/dist/entify/lib/queryUserIds.d.ts +0 -4
  126. package/dist/entify/lib/queryUserPosts.d.ts +0 -9
  127. package/dist/entify/lib/queryWebSiteSettings.d.ts +0 -3
  128. package/dist/entify/lib/searchProducts.d.ts +0 -4
  129. package/dist/entify/lib/sendEmail.d.ts +0 -3
  130. package/dist/entify/lib/toQueryOptions.d.ts +0 -3
  131. package/dist/entify/lib/upsertEntity.d.ts +0 -2
  132. package/dist/entify/types/index.d.ts +0 -2
  133. package/dist/entify/types/utils.d.ts +0 -4
  134. package/dist/entify/types/variables.d.ts +0 -7
  135. package/dist/entify/view-model/funcs.d.ts +0 -20
  136. package/dist/entify/view-model/index.d.ts +0 -2
  137. package/dist/entify/view-model/models.d.ts +0 -119
  138. package/dist/index.mjs +0 -40514
  139. package/dist/index.mjs.map +0 -1
  140. package/dist/motion/consts.d.ts +0 -77
  141. package/dist/motion/types.d.ts +0 -26
  142. package/dist/react/components/EnquiryForm/Input.d.ts +0 -15
  143. package/dist/react/components/EnquiryForm/Submit.d.ts +0 -8
  144. package/dist/react/components/EnquiryForm/Textarea.d.ts +0 -13
  145. package/dist/react/components/EnquiryForm/index.d.ts +0 -22
  146. package/dist/react/components/Medias/index.d.ts +0 -8
  147. package/dist/react/components/ProductCard/ProductCard.d.ts +0 -15
  148. package/dist/react/components/ProductCard/ProductCardPreview.d.ts +0 -2
  149. package/dist/react/components/ProductCard/ProductCta/index.d.ts +0 -5
  150. package/dist/react/components/ProductCard/ProductDescription/index.d.ts +0 -2
  151. package/dist/react/components/ProductCard/ProductMedia/index.d.ts +0 -7
  152. package/dist/react/components/ProductCard/ProductTitle/index.d.ts +0 -2
  153. package/dist/react/components/ProductCard/ProductView.d.ts +0 -5
  154. package/dist/react/components/ProductCard/useQueryProduct.d.ts +0 -2
  155. package/dist/react/components/RichTextOutline/index.d.ts +0 -8
  156. package/dist/react/components/RichTextOutline/useAcitviedHeading.d.ts +0 -1
  157. package/dist/react/components/Scroller.d.ts +0 -3
  158. package/dist/react/components/SearchInput.d.ts +0 -2
  159. package/dist/react/components/Share/index.d.ts +0 -6
  160. package/dist/react/components/Share/socials.d.ts +0 -10
  161. package/dist/react/components/ToTop.d.ts +0 -5
  162. package/dist/react/hooks/index.d.ts +0 -1
  163. package/dist/react/hooks/useScroll.d.ts +0 -2
  164. package/dist/robots.d.ts +0 -2
  165. package/dist/scripts/actions.d.ts +0 -85
  166. package/dist/scripts/consts.d.ts +0 -21
  167. package/dist/scripts/events.d.ts +0 -11
  168. package/dist/style.css +0 -98
@@ -0,0 +1,304 @@
1
+ import {
2
+ DATA_POPUP,
3
+ DATA_POPUP_ROLE,
4
+ EVENT_CLOSE,
5
+ EVENT_OPEN,
6
+ EVENT_SELECT,
7
+ EVENT_UNSELECT,
8
+ PopupRole,
9
+ } from "./consts";
10
+ import { $emit, $on, PopupEvent, SelectionEvent } from "./events";
11
+ import { ANIMATIONS, DUAL_ANIMATIONS } from "../motion/consts";
12
+ import { DualAnimation, SimpleAnimation } from "../motion/types";
13
+
14
+ /**
15
+ * 在每次页面切换后执行回调函数
16
+ * 注意:此函数注册的事件监听器不会自动解注册,将在每次页面切换时执行
17
+ *
18
+ * @param init - 每次页面切换时要执行的回调函数
19
+ * @returns 用于手动解注册事件的函数
20
+ */
21
+ export function onEverySwap(init: () => void) {
22
+ document.addEventListener("astro:after-swap", init);
23
+ // 返回一个函数,用于手动解注册事件
24
+ return () => document.removeEventListener("astro:after-swap", init);
25
+ }
26
+
27
+ /**
28
+ * 初始化动画,在 page-load 事件触发时执行
29
+ *
30
+ * @param init - 初始化动画的回调函数
31
+ */
32
+ export function onPageLoaded(init: () => void) {
33
+ const doInit = () => {
34
+ init();
35
+ document.removeEventListener("astro:page-load", doInit);
36
+ };
37
+ document.addEventListener("astro:page-load", doInit);
38
+ }
39
+
40
+ /**
41
+ * 用于在脚本中监听弹出层的打开/关闭事件,并处理相关动画效果
42
+ * 注意:此函数主要用于脚本中的事件处理,组件内部已有相应实现,无需使用
43
+ *
44
+ * @param targetKey - 要监听的弹出层的唯一标识
45
+ * @param callback - 弹出层打开时的回调函数,可返回关闭时的清理函数
46
+ * @returns 取消监听的函数
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // 监听产品菜单的打开/关闭事件并添加旋转动画
51
+ * onOpen("products-popup", () => {
52
+ * // 打开时顺时针旋转
53
+ * animate("#products-indicator", {
54
+ * rotate: [0, 180],
55
+ * });
56
+ *
57
+ * // 返回关闭时的动画处理函数
58
+ * return () => {
59
+ * animate("#products-indicator", {
60
+ * rotate: [180, 0],
61
+ * });
62
+ * };
63
+ * });
64
+ * ```
65
+ */
66
+ export function onOpen(
67
+ targetKey: string,
68
+ callback?: (evnet?: PopupEvent) => VoidFunction | void
69
+ ) {
70
+ return onPopupOpen((event) => {
71
+ if (event.key === targetKey) {
72
+ return callback?.(event);
73
+ }
74
+ });
75
+ }
76
+
77
+ /**
78
+ * 用于在脚本中监听弹出层的打开/关闭事件,并处理相关动画效果
79
+ * 注意:此函数主要用于脚本中的事件处理,组件内部已有相应实现,无需使用
80
+ *
81
+ * @param callback - 弹出层打开时的回调函数,可返回关闭时的清理函数
82
+ * @returns 取消监听的函数
83
+ *
84
+ */
85
+ export function onPopupOpen(
86
+ callback: (event: PopupEvent) => VoidFunction | void
87
+ ) {
88
+ let unsubscribe: ((event: PopupEvent) => void) | void;
89
+
90
+ const handleOpen = (event: PopupEvent) => {
91
+ unsubscribe = callback?.(event);
92
+ };
93
+
94
+ const unsubscribeOpen = $on(EVENT_OPEN, handleOpen);
95
+
96
+ const handelClose = (event: PopupEvent) => {
97
+ unsubscribe?.(event);
98
+ };
99
+ const unsubscribeClose = $on(EVENT_CLOSE, handelClose);
100
+
101
+ return () => {
102
+ unsubscribeOpen();
103
+ unsubscribeClose();
104
+ };
105
+ }
106
+
107
+ export function onPopupClose(
108
+ callback: (event: PopupEvent) => VoidFunction | void
109
+ ) {
110
+ return $on<PopupEvent>(EVENT_CLOSE, callback);
111
+ }
112
+
113
+ export function onSelected(
114
+ callback: (event: SelectionEvent) => VoidFunction | void
115
+ ) {
116
+ return $on<SelectionEvent>(EVENT_SELECT, callback);
117
+ }
118
+
119
+ export function onUnSelected(
120
+ callback: (event: SelectionEvent) => VoidFunction | void
121
+ ) {
122
+ return $on<SelectionEvent>(EVENT_UNSELECT, callback);
123
+ }
124
+
125
+ // 使用WeakMap存储事件处理函数引用
126
+ const popoverHandlers = new WeakMap<
127
+ HTMLElement,
128
+ {
129
+ enter: (event: Event) => void;
130
+ leave: (event: Event) => void;
131
+ }
132
+ >();
133
+
134
+ // 使用WeakMap存储Modal触发器的事件处理函数引用
135
+ const modalHandlers = new WeakMap<HTMLElement, (event: Event) => void>();
136
+
137
+ // 使用WeakMap存储Modal关闭按钮的事件处理函数引用
138
+ const modalCloserHandlers = new WeakMap<HTMLElement, (event: Event) => void>();
139
+
140
+ /**
141
+ * 初始化Popover的鼠标交互事件
142
+ * @param popupKey - 弹出层的唯一标识
143
+ * @param element - 弹出层的 DOM 元素
144
+ */
145
+ export function initPopover(popupKey: string, element: HTMLElement) {
146
+ // 先移除旧的事件监听器(如果存在)
147
+ const oldHandlers = popoverHandlers.get(element);
148
+ if (oldHandlers) {
149
+ element.removeEventListener("mouseenter", oldHandlers.enter);
150
+ element.removeEventListener("mouseleave", oldHandlers.leave);
151
+ element.removeEventListener("touchstart", oldHandlers.enter);
152
+ element.removeEventListener("touchend", oldHandlers.leave);
153
+ }
154
+
155
+ // 创建新的事件处理函数
156
+ const handleMouseEnter = (event: Event) => {
157
+ openPopup(popupKey, element);
158
+ };
159
+
160
+ const handleMouseLeave = (event: Event) => {
161
+ closePopup(popupKey);
162
+ };
163
+
164
+ // 保存新的事件处理函数引用
165
+ popoverHandlers.set(element, {
166
+ enter: handleMouseEnter,
167
+ leave: handleMouseLeave,
168
+ });
169
+
170
+ // 添加新的事件监听器
171
+ element.addEventListener("mouseenter", handleMouseEnter);
172
+ element.addEventListener("mouseleave", handleMouseLeave);
173
+ element.addEventListener("touchstart", handleMouseEnter);
174
+ element.addEventListener("touchend", handleMouseLeave);
175
+ }
176
+
177
+ export function getPopupContainer(popupKey: string) {
178
+ return document.querySelector(
179
+ `[${DATA_POPUP}="${popupKey}"][${DATA_POPUP_ROLE}="${PopupRole.ModalContainer}"], [${DATA_POPUP}="${popupKey}"][${DATA_POPUP_ROLE}="${PopupRole.PopoverContainer}"]`
180
+ ) as HTMLElement | undefined;
181
+ }
182
+
183
+ export function initModal(popupKey: string, trigger: HTMLElement) {
184
+ // 先移除旧的事件监听器(如果存在)
185
+ const oldHandler = modalHandlers.get(trigger);
186
+ if (oldHandler) {
187
+ trigger.removeEventListener("click", oldHandler);
188
+ }
189
+
190
+ // 创建新的事件处理函数
191
+ const handleTriggerClick = (event: Event) => {
192
+ // 查找 Modal 容器
193
+ openPopup(popupKey, trigger);
194
+ };
195
+
196
+ // 保存新的事件处理函数引用
197
+ modalHandlers.set(trigger, handleTriggerClick);
198
+
199
+ // 添加新的事件监听器
200
+ trigger.addEventListener("click", handleTriggerClick);
201
+ }
202
+
203
+ /**
204
+ * 初始化Modal关闭按钮
205
+ * @param popupKey - 弹出层的唯一标识
206
+ * @param closer - 关闭按钮元素
207
+ */
208
+ export function initModalCloser(popupKey: string, closer: HTMLElement) {
209
+ // 先移除旧的事件监听器(如果存在)
210
+ const oldHandler = modalCloserHandlers.get(closer);
211
+ if (oldHandler) {
212
+ closer.removeEventListener("click", oldHandler);
213
+ }
214
+
215
+ // 创建新的事件处理函数
216
+ const handleCloserClick = (event: Event) => {
217
+ closePopup(popupKey);
218
+ };
219
+
220
+ // 保存新的事件处理函数引用
221
+ modalCloserHandlers.set(closer, handleCloserClick);
222
+
223
+ // 添加新的事件监听器
224
+ closer.addEventListener("click", handleCloserClick);
225
+ }
226
+
227
+ /**
228
+ * 打开弹出层
229
+ * @param popupKey
230
+ * @param target
231
+ */
232
+ export function openPopup(popupKey: string, target: HTMLElement) {
233
+ // 查找 Modal 容器
234
+ const modalContainer = getPopupContainer(popupKey);
235
+ if (modalContainer) {
236
+ modalContainer.classList.add("open");
237
+ $emit(EVENT_OPEN, { key: popupKey, target });
238
+ } else {
239
+ console.error("未找到弹出层", popupKey);
240
+ }
241
+ }
242
+
243
+ // 选择
244
+ export function select(key: string, target: HTMLElement, selection: string) {
245
+ $emit(EVENT_SELECT, { key, target, selection });
246
+ }
247
+
248
+ // 取消选择
249
+ export function unselect(key: string, target: HTMLElement, selection: string) {
250
+ $emit(EVENT_UNSELECT, { key, target, selection });
251
+ }
252
+
253
+ /**
254
+ * 关闭弹出层
255
+ * @param popupKey - 弹出层的唯一标识
256
+ * @param target - 可选的目标元素,如果提供则使用该元素,否则查找容器
257
+ */
258
+ export function closePopup(popupKey: string, target?: HTMLElement) {
259
+ const container = target || getPopupContainer(popupKey);
260
+ container?.classList.remove("open");
261
+ $emit(EVENT_CLOSE, { key: popupKey });
262
+ }
263
+
264
+ export function normalizeSimpleAnimation(animation?: SimpleAnimation) {
265
+ if (animation?.preset) {
266
+ const preset = ANIMATIONS[animation?.preset];
267
+ return {
268
+ ...preset,
269
+ keyframes: { ...preset.keyframes, ...animation.keyframes },
270
+ transition: { ...preset.transition, ...animation.transition },
271
+ };
272
+ }
273
+
274
+ return animation;
275
+ }
276
+
277
+ //处理预置动画
278
+ export function normalizeDualAnimation(
279
+ animation?: DualAnimation
280
+ ): DualAnimation | undefined {
281
+ if (!animation) {
282
+ return undefined;
283
+ }
284
+
285
+ // 如果有预设,合并预设和自定义配置
286
+ if (animation.preset) {
287
+ const preset = DUAL_ANIMATIONS[animation.preset];
288
+ return {
289
+ ...animation,
290
+ in: animation.in
291
+ ? normalizeSimpleAnimation({ ...preset.in, ...animation.in })
292
+ : preset.in,
293
+ out: animation.out
294
+ ? normalizeSimpleAnimation({ ...preset.out, ...animation.out })
295
+ : preset.out,
296
+ };
297
+ }
298
+
299
+ // 如果没有预设,但有 in/out 配置
300
+ return {
301
+ in: animation.in ? normalizeSimpleAnimation(animation.in) : undefined,
302
+ out: animation.out ? normalizeSimpleAnimation(animation.out) : undefined,
303
+ };
304
+ }
@@ -0,0 +1,32 @@
1
+ //弹层ID
2
+ export const DATA_POPUP = "data-popup";
3
+
4
+ //弹层角色,取值:PopupRole
5
+ export const DATA_POPUP_ROLE = "data-popup-role";
6
+
7
+ //弹层CTA,用于跟踪用户点击行为
8
+ export const DATA_POPUP_CTA = "data-popup-cta";
9
+
10
+ //已经进入过视窗
11
+ export const DATA_VIEWPORT_ENTERED = "data-viewport-entered";
12
+
13
+ export enum PopupRole {
14
+ PopoverContainer = "popover-container",
15
+ PopoverPanel = "popover-panel",
16
+ ModalContainer = "modal-container",
17
+ ModalTrigger = "modal-trigger",
18
+ ModalPanel = "modal-panel",
19
+ ModalCloser = "modal-closer",
20
+ }
21
+
22
+ export const DEFAULT_ENQUIRY_POPUP = "enquiry-modal";
23
+
24
+ /** 弹出层打开事件名称 */
25
+ export const EVENT_OPEN = "popup-open";
26
+ /** 弹出层关闭事件名称 */
27
+ export const EVENT_CLOSE = "popup-close";
28
+
29
+ /** 元素选中事件名称,比如tab切换 */
30
+ export const EVENT_SELECT = "element-select";
31
+ /** 元素取消选中事件名称 */
32
+ export const EVENT_UNSELECT = "element-unselect";
@@ -0,0 +1,33 @@
1
+ export type PopupEvent = {
2
+ //控件组的唯一标识
3
+ key: string;
4
+ //发出事件的element,popover对应Container,modal对应Trigger
5
+ target?: HTMLElement;
6
+ };
7
+
8
+ export type SelectionEvent = {
9
+ //控件组的唯一标识
10
+ key: string;
11
+ //发出事件的element
12
+ target: HTMLElement;
13
+ selection: string;
14
+ };
15
+
16
+ export const $emit = (event: string, options?: PopupEvent | SelectionEvent) => {
17
+ const customEvent = new CustomEvent(event, { detail: options });
18
+ document.dispatchEvent(customEvent);
19
+ };
20
+
21
+ export const $on = <T = PopupEvent | SelectionEvent>(
22
+ event: string,
23
+ callback: (options: T) => void
24
+ ) => {
25
+ const eventListener = (e: CustomEvent) => {
26
+ callback(e.detail);
27
+ };
28
+ document.addEventListener(event, eventListener as EventListener);
29
+
30
+ return () => {
31
+ document.removeEventListener(event, eventListener as EventListener);
32
+ };
33
+ };
@@ -1,3 +1,3 @@
1
- export * from "./actions";
2
- export * from "./consts";
3
- export * from "./events";
1
+ export * from "./actions";
2
+ export * from "./consts";
3
+ export * from "./events";
@@ -1,138 +0,0 @@
1
- import { EnvVariables, TSize } from "./types";
2
- import { ListConditions } from "./lib";
3
- import { IQueryOptions } from "@rxdrag/entify-hooks";
4
- export type PostsOptions = {
5
- category?: string;
6
- coverSize?: TSize | undefined;
7
- page: number;
8
- pageSize: number;
9
- };
10
- export type PostPatinateOptions = {
11
- pageSize: number;
12
- category?: string;
13
- };
14
- export declare class Entify {
15
- protected envVariables: EnvVariables;
16
- private static instance;
17
- private constructor();
18
- static getInstance(envVariables: EnvVariables): Entify;
19
- queryEntityList<T, WhereExp = unknown, OrderBy = unknown, DistinctExp = unknown>(options: IQueryOptions<T, WhereExp, OrderBy, DistinctExp>): Promise<import("@rxdrag/entify-hooks").ListResult<import("./view-model").TProduct> | import("@rxdrag/entify-hooks").ListResult<import("./view-model").TPost> | import("@rxdrag/entify-hooks").ListResult<import("./view-model").TProductCategory> | import("@rxdrag/entify-hooks").ListResult<import("./view-model").TPostCategory> | import("@rxdrag/entify-hooks").ListResult<import("./view-model").TUser> | import("@rxdrag/entify-hooks").ListResult<import("./view-model").TMedia> | import("@rxdrag/entify-hooks").ListResult<T> | undefined>;
20
- getTheme(): Promise<import("@rxdrag/rxcms-models").Theme | undefined>;
21
- getLangs(): Promise<import("@rxdrag/rxcms-models").Lang[] | undefined>;
22
- getFeaturedProducts(count?: number): Promise<import("@rxdrag/entify-hooks").ListResult<import("./view-model").TProduct> | undefined>;
23
- getLatestPosts(count?: number): Promise<import("@rxdrag/entify-hooks").ListResult<import("./view-model").TPost> | undefined>;
24
- getPosts(options: PostsOptions): Promise<import("./view-model").TPost[] | undefined>;
25
- getPostListPaths(options: PostPatinateOptions): Promise<{
26
- params: {
27
- page: string;
28
- };
29
- props: {
30
- currentPage: number;
31
- totalPages: number;
32
- pageSize: number;
33
- totalItems: number;
34
- };
35
- }[]>;
36
- getPostPaths(): Promise<{
37
- params: {
38
- slug: string | undefined;
39
- };
40
- props: {
41
- slug: string | undefined;
42
- };
43
- }[]>;
44
- getPostBySlug(slug: string, coverSize: TSize | undefined): Promise<import("./view-model").TPost | undefined>;
45
- /**
46
- * 获取所有文章的 slug,用于生成静态页面
47
- * 对于大量文章,这个方法会进行优化,只获取 slug 字段
48
- */
49
- getPostSlugs(): Promise<(string | undefined)[]>;
50
- getPostCategories(): Promise<import("./view-model").TPostCategory[] | undefined>;
51
- getPostCategoryBySlug(slug: string): Promise<import("./view-model").TPostCategory | undefined>;
52
- getProuducts(conditions: ListConditions, imageSize: TSize | undefined): Promise<import("./view-model").TProduct[] | undefined>;
53
- getProductListPaths(options: {
54
- category?: string;
55
- pageSize: number;
56
- }): Promise<{
57
- params: {
58
- page: string;
59
- };
60
- props: {
61
- currentPage: number;
62
- totalPages: number;
63
- pageSize: number;
64
- totalItems: number;
65
- };
66
- }[]>;
67
- getCategoredProductListPaths(): Promise<{
68
- params: {
69
- slug: string;
70
- page: string;
71
- };
72
- props: {
73
- currentPage: number;
74
- totalPages: number;
75
- pageSize: number;
76
- totalItems: number;
77
- slug: string;
78
- };
79
- }[]>;
80
- /**
81
- * TODO:未调试
82
- * 获取所有文章分类的分页路径
83
- * 用于生成静态页面
84
- * @returns 所有文章分类的分页路径
85
- */
86
- getCategoredPostListPaths(): Promise<{
87
- params: {
88
- slug: string;
89
- page: string;
90
- };
91
- props: {
92
- currentPage: number;
93
- totalPages: number;
94
- pageSize: number;
95
- totalItems: number;
96
- slug: string;
97
- };
98
- }[]>;
99
- getProductBySlug(slug: string, imageSize: TSize | undefined): Promise<import("./view-model").TProduct | undefined>;
100
- getProductPaths(): Promise<{
101
- params: {
102
- slug: string | undefined;
103
- };
104
- props: {
105
- slug: string | undefined;
106
- };
107
- }[]>;
108
- /**
109
- * 获取所有产品的 slug,用于生成静态页面
110
- * 对于大量产品,这个方法会进行优化,只获取 slug 字段
111
- */
112
- getProductSlugs(): Promise<(string | undefined)[]>;
113
- getProductIds(): Promise<(string | null | undefined)[]>;
114
- getProductCategories(): Promise<import("./view-model").TProductCategory[] | undefined>;
115
- getProductCategoryBySlug(slug: string): Promise<import("./view-model").TProductCategory | undefined>;
116
- getOneUser(id: string): Promise<import("./view-model").TUser | undefined>;
117
- getUserPosts(userId: string): Promise<import("./view-model").TPost[] | undefined>;
118
- searchProducts(keyword: string): Promise<import("@rxdrag/entify-hooks").ListResult<import("./view-model").TProduct> | undefined>;
119
- getUserPaths(): Promise<{
120
- params: {
121
- id: string | null | undefined;
122
- };
123
- props: {
124
- id: string | null | undefined;
125
- };
126
- }[]>;
127
- createPagination(totalItems: number, pageSize: number): {
128
- params: {
129
- page: string;
130
- };
131
- props: {
132
- currentPage: number;
133
- totalPages: number;
134
- pageSize: number;
135
- totalItems: number;
136
- };
137
- }[];
138
- }
@@ -1,3 +0,0 @@
1
- import { EntifyClient } from "@rxdrag/entify-hooks";
2
- import { EnvVariables } from "../types";
3
- export declare function createEntifyClient(envVariables: EnvVariables): EntifyClient;
@@ -1,2 +0,0 @@
1
- import { LangFields } from "@rxdrag/rxcms-models";
2
- export declare const langFields: LangFields[];
@@ -1,2 +0,0 @@
1
- import { MediaQueryOptions } from "@rxdrag/rxcms-models";
2
- export declare function newAvatarQueryOptions(): MediaQueryOptions;
@@ -1,2 +0,0 @@
1
- import { MediaQueryOptions } from "@rxdrag/rxcms-models";
2
- export declare function newOgImageQueryOptions(): MediaQueryOptions;
@@ -1,2 +0,0 @@
1
- import { PageMetaQueryOptions } from "@rxdrag/rxcms-models";
2
- export declare function newPageMetaOptions(): PageMetaQueryOptions;
@@ -1,3 +0,0 @@
1
- import { PostQueryOptions } from "@rxdrag/rxcms-models";
2
- import { TSize } from "../types";
3
- export declare function newQueryOnePostOptions(coverSize?: TSize): PostQueryOptions;
@@ -1,3 +0,0 @@
1
- import { ProductQueryOptions } from "@rxdrag/rxcms-models";
2
- import { TSize } from "../types";
3
- export declare function newQueryProductOptions(imagSize?: TSize): ProductQueryOptions;
@@ -1,3 +0,0 @@
1
- import { MediaOnProductQueryOptions } from "@rxdrag/rxcms-models";
2
- import { TSize } from "../types";
3
- export declare function newQueryProductsMediaOptions(imageSize?: TSize | undefined): MediaOnProductQueryOptions;
@@ -1,4 +0,0 @@
1
- import { EnvVariables } from "../types";
2
- import { ListResult } from "@rxdrag/entify-hooks";
3
- import { TProduct } from "../view-model";
4
- export declare function queryAllProducts(envVariables: EnvVariables): Promise<ListResult<TProduct> | undefined>;
@@ -1,3 +0,0 @@
1
- import { IQueryOptions, ListResult } from "@rxdrag/entify-hooks";
2
- import { EnvVariables } from "../types";
3
- export declare function queryEntityList<T, WhereExp = unknown, OrderBy = unknown, DistinctExp = unknown>(options: IQueryOptions<T, WhereExp, OrderBy, DistinctExp>, envVariables: EnvVariables): Promise<ListResult<T> | ListResult<import("../view-model").TProduct> | ListResult<import("../view-model").TPost> | ListResult<import("../view-model").TProductCategory> | ListResult<import("../view-model").TPostCategory> | ListResult<import("../view-model").TUser> | ListResult<import("../view-model").TMedia> | undefined>;
@@ -1,4 +0,0 @@
1
- import { EnvVariables } from "../types";
2
- import { ListResult } from "@rxdrag/entify-hooks";
3
- import { TProduct } from "../view-model";
4
- export declare function queryFeaturedProducts(count: number | undefined, envVariables: EnvVariables): Promise<ListResult<TProduct> | undefined>;
@@ -1,4 +0,0 @@
1
- import { Lang } from "@rxdrag/rxcms-models";
2
- import { ListResult } from "@rxdrag/entify-hooks";
3
- import { EnvVariables } from "../types";
4
- export declare function queryLangs(envVariables: EnvVariables): Promise<ListResult<Lang> | undefined>;
@@ -1,4 +0,0 @@
1
- import { ListResult } from "@rxdrag/entify-hooks";
2
- import { EnvVariables } from "../types";
3
- import { TPost } from "../view-model";
4
- export declare function queryLatestPosts(count: number | undefined, envVariables: EnvVariables): Promise<ListResult<TPost> | undefined>;
@@ -1,5 +0,0 @@
1
- import { IQueryOptions } from "@rxdrag/entify-hooks";
2
- import { WebsitePart } from "@rxdrag/rxcms-models";
3
- import { WebsitePartBoolExp } from "@rxdrag/rxcms-models/";
4
- import { EnvVariables } from "../types";
5
- export declare function queryOneEntity<T extends WebsitePart = WebsitePart, WhereExp extends WebsitePartBoolExp = WebsitePartBoolExp, OrderBy = unknown, DistinctExp = unknown>(options: IQueryOptions<T, WhereExp, OrderBy, DistinctExp>, envVariables: EnvVariables): Promise<T | undefined>;
@@ -1,3 +0,0 @@
1
- import { Post } from "@rxdrag/rxcms-models";
2
- import { EnvVariables } from "../types";
3
- export declare function queryOnePostById(id: string, envVariables: EnvVariables): Promise<Post | undefined>;
@@ -1,3 +0,0 @@
1
- import { EnvVariables, TSize } from "../types";
2
- import { TPost } from "../view-model";
3
- export declare function queryOnePostBySlug(slug: string, coverSize: TSize | undefined, envVariables: EnvVariables): Promise<TPost | undefined>;
@@ -1,3 +0,0 @@
1
- import { EnvVariables } from "../types";
2
- import { TPostCategory } from "../view-model";
3
- export declare function queryOnePostCategoryBySlug(slug: string, envVariables: EnvVariables): Promise<TPostCategory | undefined>;
@@ -1,3 +0,0 @@
1
- import { Product } from "@rxdrag/rxcms-models";
2
- import { EnvVariables } from "../types";
3
- export declare function queryOneProductById(id: string, envVariables: EnvVariables): Promise<Product | undefined>;
@@ -1,3 +0,0 @@
1
- import { EnvVariables, TSize } from "../types";
2
- import { TProduct } from "../view-model";
3
- export declare function queryOneProductBySlug(slug: string, imageSize: TSize | undefined, envVariables: EnvVariables): Promise<TProduct | undefined>;
@@ -1,3 +0,0 @@
1
- import { EnvVariables } from "../types";
2
- import { TProductCategory } from "../view-model";
3
- export declare function queryOneProductCategoryBySlug(slug: string, envVariables: EnvVariables): Promise<TProductCategory | undefined>;
@@ -1,3 +0,0 @@
1
- import { Theme } from "@rxdrag/rxcms-models";
2
- import { EnvVariables } from "../types";
3
- export declare function queryOneTheme(envVariables: EnvVariables): Promise<Theme | undefined>;
@@ -1,3 +0,0 @@
1
- import { EnvVariables } from "../types";
2
- import { TUser } from "../view-model";
3
- export declare function queryOneUser(id: string, envVariables: EnvVariables): Promise<TUser | undefined>;
@@ -1,4 +0,0 @@
1
- import { ListResult } from "@rxdrag/entify-hooks";
2
- import { EnvVariables } from "../types";
3
- import { TPostCategory } from "../view-model";
4
- export declare function queryPostCategories(envVariables: EnvVariables): Promise<ListResult<TPostCategory> | undefined>;
@@ -1,4 +0,0 @@
1
- import { EnvVariables } from "../types";
2
- import { ListResult } from "@rxdrag/entify-hooks";
3
- import { TPost } from "../view-model";
4
- export declare function queryPostSlugs(envVariables: EnvVariables): Promise<ListResult<TPost> | undefined>;
@@ -1,10 +0,0 @@
1
- import { Post } from "@rxdrag/rxcms-models";
2
- import { ListResult } from "@rxdrag/entify-hooks";
3
- import { EnvVariables, TSize } from "../types";
4
- import { TPost } from "../view-model";
5
- export interface ListConditions {
6
- category?: string;
7
- page?: number;
8
- pageSize: number;
9
- }
10
- export declare function queryPosts(conditions: ListConditions, coverSize: TSize | undefined, envVariables: EnvVariables, selectFields?: (keyof Post)[]): Promise<ListResult<TPost> | undefined>;
@@ -1,4 +0,0 @@
1
- import { ListResult } from "@rxdrag/entify-hooks";
2
- import { EnvVariables } from "../types";
3
- import { TProductCategory } from "../view-model";
4
- export declare function queryProductCategories(envVariables: EnvVariables): Promise<ListResult<TProductCategory> | undefined>;