@rxdrag/website-lib 0.0.151 → 0.0.153

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 (51) hide show
  1. package/README.md +2 -2
  2. package/components/AnimationNumber.astro +217 -217
  3. package/components/Background.astro +140 -114
  4. package/components/BackgroundGroup.astro +20 -26
  5. package/components/BaseFooter.astro +24 -39
  6. package/components/BaseHeader.astro +22 -25
  7. package/components/Box.astro +20 -22
  8. package/components/Button.astro +80 -0
  9. package/components/Carousel.astro +456 -315
  10. package/components/CarouselPagination.astro +97 -76
  11. package/components/CarouselSlide.astro +10 -16
  12. package/components/Collapse.astro +125 -125
  13. package/components/CollapseIndicator.astro +20 -20
  14. package/components/Container.astro +27 -32
  15. package/components/Content.astro +20 -0
  16. package/components/CookieConsent.astro +47 -47
  17. package/components/CookieConsent.css +52 -52
  18. package/components/CookieConsentConfig.ts +208 -208
  19. package/components/Dialog.astro +342 -338
  20. package/components/DialogTrigger.astro +32 -32
  21. package/components/Document.astro +240 -225
  22. package/components/Frame.astro +32 -0
  23. package/components/GlassBorder.astro +104 -0
  24. package/components/GlassRefraction.astro +85 -0
  25. package/components/GradientBorder.astro +80 -0
  26. package/components/Grid.astro +32 -34
  27. package/components/GridCell.astro +28 -32
  28. package/components/Heading.astro +24 -24
  29. package/components/Icon.astro +29 -29
  30. package/components/Image.astro +100 -100
  31. package/components/Image.md +14 -14
  32. package/components/Link.astro +89 -99
  33. package/components/Main.astro +17 -17
  34. package/components/Meta.astro +65 -65
  35. package/components/Popover.astro +189 -189
  36. package/components/RichTextView.astro +28 -28
  37. package/components/Section.astro +26 -44
  38. package/components/TabButton.astro +32 -16
  39. package/components/TabPanel.astro +20 -19
  40. package/components/Tabs.astro +220 -147
  41. package/components/Video.astro +6 -4
  42. package/components/YearsSince.astro +20 -20
  43. package/components//344/270/211/345/261/202/346/250/241/345/236/213.md +5 -5
  44. package/components//344/270/273/351/242/230Token.md +198 -198
  45. package/components//345/216/237/345/255/220/345/206/273/347/273/223/346/270/205/345/215/225.md +270 -260
  46. package/components//347/211/251/346/226/231/346/270/205/345/215/225.md +599 -567
  47. package/index.ts +5 -5
  48. package/package.json +7 -7
  49. package/components/BaseBlock.astro +0 -34
  50. package/components/Motion.astro +0 -77
  51. package/components/Stack.astro +0 -31
@@ -1,189 +1,189 @@
1
- ---
2
- interface ClassNames {
3
- root?: string | string[];
4
- trigger?: string | string[];
5
- panel?: string | string[];
6
- }
7
-
8
- interface Props {
9
- id: string;
10
- classNames?: ClassNames;
11
- }
12
-
13
- const { id, classNames } = Astro.props;
14
-
15
- const normalize = (v?: string | string[]) => {
16
- if (!v) return [];
17
- return Array.isArray(v) ? v : [v];
18
- };
19
-
20
- const rootClassList = normalize(classNames?.root);
21
- const triggerClassList = normalize(classNames?.trigger);
22
- const panelClassList = normalize(classNames?.panel);
23
- ---
24
-
25
- <div class:list={rootClassList} data-popover={id} data-open="0">
26
- <style>
27
- [data-popover-panel] {
28
- height: 0;
29
- overflow: hidden;
30
- will-change: height;
31
- }
32
-
33
- :global([data-popover-arrow]) {
34
- display: inline-flex;
35
- transform-origin: center;
36
- transition: transform 200ms ease;
37
- }
38
-
39
- [data-popover][data-open="1"] :global([data-popover-arrow]) {
40
- transform: rotate(180deg);
41
- }
42
- </style>
43
-
44
- <button
45
- type="button"
46
- class:list={triggerClassList}
47
- data-popover-trigger
48
- aria-expanded="false"
49
- aria-controls={`${id}-panel`}
50
- >
51
- <slot name="trigger" />
52
- </button>
53
-
54
- <div
55
- id={`${id}-panel`}
56
- data-popover-panel
57
- class:list={panelClassList}
58
- style="height:0px;overflow:hidden;"
59
- >
60
- <slot />
61
- </div>
62
- </div>
63
-
64
- <script is:inline>
65
- (() => {
66
- const globalKey = "__popover_doc_bound__";
67
- const w = window;
68
- if (!w[globalKey]) w[globalKey] = { docBound: false };
69
-
70
- const init = () => {
71
- const roots = document.querySelectorAll("[data-popover]");
72
- roots.forEach((root) => {
73
- if (!(root instanceof HTMLElement)) return;
74
- if (root.dataset.bound === "1") return;
75
- root.dataset.bound = "1";
76
-
77
- const panel = root.querySelector("[data-popover-panel]");
78
- const trigger = root.querySelector("[data-popover-trigger]");
79
- if (!(panel instanceof HTMLElement) || !(trigger instanceof HTMLElement)) {
80
- console.log("Popover: trigger/panel not found");
81
- return;
82
- }
83
-
84
- let open = false;
85
- let hoverTimer;
86
-
87
- const setExpanded = (v) => {
88
- trigger.setAttribute("aria-expanded", v ? "true" : "false");
89
- root.setAttribute("data-open", v ? "1" : "0");
90
- };
91
-
92
- const openPanel = () => {
93
- if (open) return;
94
- open = true;
95
- setExpanded(true);
96
- panel.style.transition = "height 600ms ease";
97
- panel.style.height = "0px";
98
- const h = panel.scrollHeight;
99
- requestAnimationFrame(() => {
100
- panel.style.height = h + "px";
101
- });
102
- const onEnd = () => {
103
- if (open) {
104
- panel.style.height = "auto";
105
- }
106
- panel.removeEventListener("transitionend", onEnd);
107
- };
108
- panel.addEventListener("transitionend", onEnd);
109
- };
110
-
111
- const closePanel = () => {
112
- if (!open) return;
113
- open = false;
114
- setExpanded(false);
115
- const h = panel.scrollHeight;
116
- panel.style.transition = "height 250ms ease";
117
- panel.style.height = h + "px";
118
- requestAnimationFrame(() => {
119
- panel.style.height = "0px";
120
- });
121
- };
122
-
123
- root.__popoverClose = closePanel;
124
-
125
- const toggle = () => {
126
- if (open) closePanel();
127
- else openPanel();
128
- };
129
-
130
- trigger.addEventListener("click", (e) => {
131
- e.preventDefault();
132
- toggle();
133
- });
134
-
135
- root.addEventListener("mouseenter", () => {
136
- clearTimeout(hoverTimer);
137
- hoverTimer = setTimeout(() => openPanel(), 60);
138
- });
139
-
140
- root.addEventListener("mouseleave", () => {
141
- clearTimeout(hoverTimer);
142
- hoverTimer = setTimeout(() => closePanel(), 120);
143
- });
144
- });
145
-
146
- if (!w[globalKey].docBound) {
147
- w[globalKey].docBound = true;
148
-
149
- const closeAll = () => {
150
- const opened = document.querySelectorAll('[data-popover][data-open="1"]');
151
- opened.forEach((r) => {
152
- if (!(r instanceof HTMLElement)) return;
153
- if (typeof r.__popoverClose === "function") {
154
- r.__popoverClose();
155
- return;
156
- }
157
- const p = r.querySelector("[data-popover-panel]");
158
- const trig = r.querySelector("[data-popover-trigger]");
159
- if (!(p instanceof HTMLElement) || !(trig instanceof HTMLElement)) return;
160
- trig.setAttribute("aria-expanded", "false");
161
- r.setAttribute("data-open", "0");
162
- const h = p.scrollHeight;
163
- p.style.transition = "height 250ms ease";
164
- p.style.height = h + "px";
165
- requestAnimationFrame(() => {
166
- p.style.height = "0px";
167
- });
168
- });
169
- };
170
-
171
- document.addEventListener("click", (e) => {
172
- const t = e.target;
173
- if (!(t instanceof Element)) return;
174
- if (t.closest('[data-popover][data-open="1"]')) return;
175
- closeAll();
176
- });
177
-
178
- document.addEventListener("keydown", (e) => {
179
- if (e.key !== "Escape") return;
180
- closeAll();
181
- });
182
- }
183
- };
184
-
185
- init();
186
- document.addEventListener("astro:page-load", init);
187
- document.addEventListener("astro:after-swap", init);
188
- })();
189
- </script>
1
+ ---
2
+ interface ClassNames {
3
+ root?: string | string[];
4
+ trigger?: string | string[];
5
+ panel?: string | string[];
6
+ }
7
+
8
+ interface Props {
9
+ id: string;
10
+ classNames?: ClassNames;
11
+ }
12
+
13
+ const { id, classNames } = Astro.props;
14
+
15
+ const normalize = (v?: string | string[]) => {
16
+ if (!v) return [];
17
+ return Array.isArray(v) ? v : [v];
18
+ };
19
+
20
+ const rootClassList = normalize(classNames?.root);
21
+ const triggerClassList = normalize(classNames?.trigger);
22
+ const panelClassList = normalize(classNames?.panel);
23
+ ---
24
+
25
+ <div class:list={rootClassList} data-popover={id} data-open="0">
26
+ <style>
27
+ [data-popover-panel] {
28
+ height: 0;
29
+ overflow: hidden;
30
+ will-change: height;
31
+ }
32
+
33
+ :global([data-popover-arrow]) {
34
+ display: inline-flex;
35
+ transform-origin: center;
36
+ transition: transform 200ms ease;
37
+ }
38
+
39
+ [data-popover][data-open="1"] :global([data-popover-arrow]) {
40
+ transform: rotate(180deg);
41
+ }
42
+ </style>
43
+
44
+ <button
45
+ type="button"
46
+ class:list={triggerClassList}
47
+ data-popover-trigger
48
+ aria-expanded="false"
49
+ aria-controls={`${id}-panel`}
50
+ >
51
+ <slot name="trigger" />
52
+ </button>
53
+
54
+ <div
55
+ id={`${id}-panel`}
56
+ data-popover-panel
57
+ class:list={panelClassList}
58
+ style="height:0px;overflow:hidden;"
59
+ >
60
+ <slot />
61
+ </div>
62
+ </div>
63
+
64
+ <script is:inline>
65
+ (() => {
66
+ const globalKey = "__popover_doc_bound__";
67
+ const w = window;
68
+ if (!w[globalKey]) w[globalKey] = { docBound: false };
69
+
70
+ const init = () => {
71
+ const roots = document.querySelectorAll("[data-popover]");
72
+ roots.forEach((root) => {
73
+ if (!(root instanceof HTMLElement)) return;
74
+ if (root.dataset.bound === "1") return;
75
+ root.dataset.bound = "1";
76
+
77
+ const panel = root.querySelector("[data-popover-panel]");
78
+ const trigger = root.querySelector("[data-popover-trigger]");
79
+ if (!(panel instanceof HTMLElement) || !(trigger instanceof HTMLElement)) {
80
+ console.log("Popover: trigger/panel not found");
81
+ return;
82
+ }
83
+
84
+ let open = false;
85
+ let hoverTimer;
86
+
87
+ const setExpanded = (v) => {
88
+ trigger.setAttribute("aria-expanded", v ? "true" : "false");
89
+ root.setAttribute("data-open", v ? "1" : "0");
90
+ };
91
+
92
+ const openPanel = () => {
93
+ if (open) return;
94
+ open = true;
95
+ setExpanded(true);
96
+ panel.style.transition = "height 600ms ease";
97
+ panel.style.height = "0px";
98
+ const h = panel.scrollHeight;
99
+ requestAnimationFrame(() => {
100
+ panel.style.height = h + "px";
101
+ });
102
+ const onEnd = () => {
103
+ if (open) {
104
+ panel.style.height = "auto";
105
+ }
106
+ panel.removeEventListener("transitionend", onEnd);
107
+ };
108
+ panel.addEventListener("transitionend", onEnd);
109
+ };
110
+
111
+ const closePanel = () => {
112
+ if (!open) return;
113
+ open = false;
114
+ setExpanded(false);
115
+ const h = panel.scrollHeight;
116
+ panel.style.transition = "height 250ms ease";
117
+ panel.style.height = h + "px";
118
+ requestAnimationFrame(() => {
119
+ panel.style.height = "0px";
120
+ });
121
+ };
122
+
123
+ root.__popoverClose = closePanel;
124
+
125
+ const toggle = () => {
126
+ if (open) closePanel();
127
+ else openPanel();
128
+ };
129
+
130
+ trigger.addEventListener("click", (e) => {
131
+ e.preventDefault();
132
+ toggle();
133
+ });
134
+
135
+ root.addEventListener("mouseenter", () => {
136
+ clearTimeout(hoverTimer);
137
+ hoverTimer = setTimeout(() => openPanel(), 60);
138
+ });
139
+
140
+ root.addEventListener("mouseleave", () => {
141
+ clearTimeout(hoverTimer);
142
+ hoverTimer = setTimeout(() => closePanel(), 120);
143
+ });
144
+ });
145
+
146
+ if (!w[globalKey].docBound) {
147
+ w[globalKey].docBound = true;
148
+
149
+ const closeAll = () => {
150
+ const opened = document.querySelectorAll('[data-popover][data-open="1"]');
151
+ opened.forEach((r) => {
152
+ if (!(r instanceof HTMLElement)) return;
153
+ if (typeof r.__popoverClose === "function") {
154
+ r.__popoverClose();
155
+ return;
156
+ }
157
+ const p = r.querySelector("[data-popover-panel]");
158
+ const trig = r.querySelector("[data-popover-trigger]");
159
+ if (!(p instanceof HTMLElement) || !(trig instanceof HTMLElement)) return;
160
+ trig.setAttribute("aria-expanded", "false");
161
+ r.setAttribute("data-open", "0");
162
+ const h = p.scrollHeight;
163
+ p.style.transition = "height 250ms ease";
164
+ p.style.height = h + "px";
165
+ requestAnimationFrame(() => {
166
+ p.style.height = "0px";
167
+ });
168
+ });
169
+ };
170
+
171
+ document.addEventListener("click", (e) => {
172
+ const t = e.target;
173
+ if (!(t instanceof Element)) return;
174
+ if (t.closest('[data-popover][data-open="1"]')) return;
175
+ closeAll();
176
+ });
177
+
178
+ document.addEventListener("keydown", (e) => {
179
+ if (e.key !== "Escape") return;
180
+ closeAll();
181
+ });
182
+ }
183
+ };
184
+
185
+ init();
186
+ document.addEventListener("astro:page-load", init);
187
+ document.addEventListener("astro:after-swap", init);
188
+ })();
189
+ </script>
@@ -1,28 +1,28 @@
1
- ---
2
- import { mdxToTiptap, TiptapPreview } from "@rxdrag/tiptap-preview";
3
- import { PRODUCT_KEY, ProductCard } from "@rxdrag/website-lib-core";
4
- import React from "react";
5
-
6
- interface Props {
7
- value?: string;
8
- class?: string;
9
- style?: string | Record<string, string | number>;
10
- }
11
-
12
- const { value = "", class: className, style } = Astro.props;
13
- const tiptapValue = mdxToTiptap(value);
14
-
15
- const ProductBlock = (props: { attrs?: Record<string, unknown> }) => {
16
- return React.createElement(ProductCard as any, {
17
- node: (props.attrs || {}) as any,
18
- });
19
- };
20
- const customBlocks = {
21
- [PRODUCT_KEY]: ProductBlock,
22
- product: ProductBlock,
23
- };
24
- ---
25
-
26
- <div class={className} style={style}>
27
- <TiptapPreview value={tiptapValue} customBlocks={customBlocks} />
28
- </div>
1
+ ---
2
+ import { mdxToTiptap, TiptapPreview } from "@rxdrag/tiptap-preview";
3
+ import { PRODUCT_KEY, ProductCard } from "@rxdrag/website-lib-core";
4
+ import React from "react";
5
+
6
+ interface Props {
7
+ value?: string;
8
+ class?: string;
9
+ style?: string | Record<string, string | number>;
10
+ }
11
+
12
+ const { value = "", class: className, style } = Astro.props;
13
+ const tiptapValue = mdxToTiptap(value);
14
+
15
+ const ProductBlock = (props: { attrs?: Record<string, unknown> }) => {
16
+ return React.createElement(ProductCard as any, {
17
+ node: (props.attrs || {}) as any,
18
+ });
19
+ };
20
+ const customBlocks = {
21
+ [PRODUCT_KEY]: ProductBlock,
22
+ product: ProductBlock,
23
+ };
24
+ ---
25
+
26
+ <div class={className} style={style}>
27
+ <TiptapPreview value={tiptapValue} customBlocks={customBlocks} />
28
+ </div>
@@ -1,44 +1,26 @@
1
- ---
2
- import type { HTMLAttributes } from "astro/types";
3
- import type { BackgroundConfig } from "@rxdrag/website-lib-core";
4
- import BackgroundGroup from "./BackgroundGroup.astro";
5
- import Container from "./Container.astro";
6
-
7
- /**
8
- * 区块
9
- *
10
- * 规范:被冻结(Frozen)的设计器原子组件
11
- * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
12
- * - 允许通过原生属性透传(...rest)注入 id/style/data-*(如 data-aos-*)等通用能力
13
- * - 默认包裹 Container 提供统一容器宽度;需要全宽内容时使用 disableContainer
14
- */
15
-
16
- interface Props extends HTMLAttributes<'section'> {
17
- className?: string;
18
- containerClassName?: string;
19
- backgrounds?: BackgroundConfig[];
20
- disableContainer?: boolean;
21
- }
22
-
23
- const {
24
- className,
25
- containerClassName,
26
- backgrounds,
27
- disableContainer,
28
- class: originalClass,
29
- ...rest
30
- } = Astro.props;
31
- ---
32
-
33
- <section class:list={["section-block", className, originalClass]} {...rest}>
34
- <BackgroundGroup backgrounds={backgrounds} />
35
- {
36
- disableContainer ? (
37
- <slot />
38
- ) : (
39
- <Container class:list={["w-full h-full", containerClassName]}>
40
- <slot />
41
- </Container>
42
- )
43
- }
44
- </section>
1
+ ---
2
+ import type { HTMLAttributes } from "astro/types";
3
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
4
+ import BackgroundGroup from "./BackgroundGroup.astro";
5
+
6
+ /**
7
+ * 区块
8
+ *
9
+ * 规范:被冻结(Frozen)的设计器原子组件
10
+ * - 对外接口与 DOM 结构应保持稳定,不随业务随意增删/调整
11
+ * - 允许通过原生属性透传(...rest)注入 id/style/data-*(如 data-aos-*)等通用能力
12
+ * - 默认包裹 Container 提供统一容器宽度;需要全宽内容时使用 disableContainer
13
+ */
14
+
15
+ interface Props extends HTMLAttributes<"section"> {
16
+ className?: string;
17
+ backgrounds?: BackgroundConfig[];
18
+ }
19
+
20
+ const { className, backgrounds, class: originalClass, ...rest } = Astro.props;
21
+ ---
22
+
23
+ <section class:list={["section-block", className, originalClass]} {...rest}>
24
+ <BackgroundGroup backgrounds={backgrounds} />
25
+ <slot />
26
+ </section>
@@ -1,16 +1,32 @@
1
- ---
2
- interface Props {
3
- class?: string;
4
- className?: string;
5
- }
6
-
7
- const { class: className, className: className2, ...props } = Astro.props;
8
- ---
9
-
10
- <button
11
- class:list={["tab-btn", className, className2]}
12
- data-tabs-btn="true"
13
- {...props}
14
- >
15
- <slot />
16
- </button>
1
+ ---
2
+ import type { BackgroundConfig } from "@rxdrag/website-lib-core";
3
+ import BackgroundGroup from "./BackgroundGroup.astro";
4
+
5
+ interface Props {
6
+ class?: string;
7
+ className?: string;
8
+ active?: boolean | string;
9
+ backgrounds?: BackgroundConfig[];
10
+ }
11
+
12
+ const {
13
+ class: className,
14
+ className: className2,
15
+ active,
16
+ backgrounds,
17
+ ...props
18
+ } = Astro.props;
19
+ const isActive =
20
+ active === true ||
21
+ (typeof active === "string" && (active === "" || active === "true"));
22
+ ---
23
+
24
+ <button
25
+ class:list={["tab-btn relative", className, className2, isActive && "active"]}
26
+ data-tabs-btn="true"
27
+ data-tabs-role="button"
28
+ {...props}
29
+ >
30
+ <BackgroundGroup backgrounds={backgrounds} />
31
+ <slot />
32
+ </button>
@@ -1,19 +1,20 @@
1
- ---
2
- interface Props {
3
- class?: string;
4
- active?: boolean | string;
5
- }
6
-
7
- const { class: className, active, ...props } = Astro.props;
8
- const isActive =
9
- active === true ||
10
- (typeof active === "string" && (active === "" || active === "true"));
11
- ---
12
-
13
- <div
14
- data-tabs-panel=""
15
- class:list={["tab-content", className, isActive ? "block" : "hidden"]}
16
- {...props}
17
- >
18
- <slot />
19
- </div>
1
+ ---
2
+ interface Props {
3
+ class?: string;
4
+ active?: boolean | string;
5
+ }
6
+
7
+ const { class: className, active, ...props } = Astro.props;
8
+ const isActive =
9
+ active === true ||
10
+ (typeof active === "string" && (active === "" || active === "true"));
11
+ ---
12
+
13
+ <div
14
+ data-tabs-panel="true"
15
+ data-tabs-role="panel"
16
+ class:list={["tab-content", className, isActive ? "block" : "hidden"]}
17
+ {...props}
18
+ >
19
+ <slot />
20
+ </div>