dune-react 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/puck-base/action-field.js +1 -0
- package/dist/components/puck-base/button.d.ts +1 -0
- package/dist/components/puck-base/button.js +2 -0
- package/dist/components/puck-base/core/with-editable.js +1 -0
- package/dist/components/puck-base/editor-context.d.ts +4 -0
- package/dist/components/puck-base/editor-context.js +1 -0
- package/dist/components/puck-base/error-boundary.js +1 -0
- package/dist/components/puck-base/image-upload-field.js +1 -0
- package/dist/components/puck-base/image.js +1 -0
- package/dist/components/puck-base/inline-editable.js +1 -0
- package/dist/components/puck-block/contact-sections/contact-us-1/contact-us.js +36 -11
- package/dist/components/puck-block/faq-sections/accordion-1/accordion.js +1 -0
- package/dist/components/puck-block/header-sections/header-1/header.js +1 -0
- package/dist/components/puck-block/hero-sections/hero-1/hero.js +1 -0
- package/dist/components/puck-block/testimonial-sections/customers-1/customers.js +1 -0
- package/dist/components/puck-block/testimonial-sections/testimonials-1/testimonials.js +1 -0
- package/dist/components/puck-block/text-sections/tab-section-1/tab-section.js +1 -0
- package/dist/components/shadcn/accordion.js +1 -0
- package/dist/components/shadcn/alert-dialog.js +1 -0
- package/dist/components/shadcn/animated-theme-toggler.js +1 -0
- package/dist/components/shadcn/avatar.js +1 -0
- package/dist/components/shadcn/button.js +1 -0
- package/dist/components/shadcn/calendar.js +1 -0
- package/dist/components/shadcn/carousel.js +1 -0
- package/dist/components/shadcn/chart.js +1 -0
- package/dist/components/shadcn/checkbox.js +1 -0
- package/dist/components/shadcn/collapsible.js +1 -0
- package/dist/components/shadcn/combobox.js +1 -0
- package/dist/components/shadcn/command.js +1 -0
- package/dist/components/shadcn/context-menu.js +1 -0
- package/dist/components/shadcn/dialog.js +1 -0
- package/dist/components/shadcn/drawer.js +1 -0
- package/dist/components/shadcn/dropdown-menu.js +1 -0
- package/dist/components/shadcn/field.js +1 -0
- package/dist/components/shadcn/form.js +1 -0
- package/dist/components/shadcn/hover-card.js +1 -0
- package/dist/components/shadcn/input-group.js +1 -0
- package/dist/components/shadcn/input-otp.js +1 -0
- package/dist/components/shadcn/label.js +1 -0
- package/dist/components/shadcn/layout-text-flip.js +1 -0
- package/dist/components/shadcn/menubar.js +1 -0
- package/dist/components/shadcn/popover.js +1 -0
- package/dist/components/shadcn/progress.js +1 -0
- package/dist/components/shadcn/radio-group.js +1 -0
- package/dist/components/shadcn/resizable-navbar.js +1 -0
- package/dist/components/shadcn/resizable.js +1 -0
- package/dist/components/shadcn/scroll-area.js +1 -0
- package/dist/components/shadcn/select.js +1 -0
- package/dist/components/shadcn/separator.js +1 -0
- package/dist/components/shadcn/sheet.js +1 -0
- package/dist/components/shadcn/sidebar.js +1 -0
- package/dist/components/shadcn/slider.js +1 -0
- package/dist/components/shadcn/sonner.js +1 -0
- package/dist/components/shadcn/switch.js +1 -0
- package/dist/components/shadcn/table.js +1 -0
- package/dist/components/shadcn/tabs.js +1 -0
- package/dist/components/shadcn/toggle-group.js +1 -0
- package/dist/components/shadcn/toggle.js +1 -0
- package/dist/components/shadcn/tooltip.js +1 -0
- package/dist/components/shadcn/tweet-card-client.js +1 -0
- package/dist/components/ui-block/cover/index.js +1 -0
- package/dist/components/ui-block/sparkles/index.js +1 -0
- package/dist/node_modules/.pnpm/lucide-react@0.540.0_react@19.2.4/node_modules/lucide-react/dist/esm/DynamicIcon.js +2 -0
- package/dist/node_modules/.pnpm/react-error-boundary@6.1.1_react@19.2.4/node_modules/react-error-boundary/dist/react-error-boundary.js +1 -0
- package/package.json +2 -1
|
@@ -8,6 +8,7 @@ export interface CompoundButtonProps {
|
|
|
8
8
|
size?: ButtonProps["size"];
|
|
9
9
|
icon?: IconName;
|
|
10
10
|
type?: "button" | "submit" | "reset";
|
|
11
|
+
disabled?: boolean;
|
|
11
12
|
className?: string;
|
|
12
13
|
}
|
|
13
14
|
export declare const CompoundButton: (props: CompoundButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
3
|
import { useState, useCallback } from "react";
|
|
3
4
|
import { Button, buttonVariants } from "../shadcn/button.js";
|
|
@@ -71,6 +72,7 @@ function CompoundButtonBase(props) {
|
|
|
71
72
|
size: props.size,
|
|
72
73
|
className: cn("gap-4", props.className),
|
|
73
74
|
type: props.type ?? "button",
|
|
75
|
+
disabled: props.disabled,
|
|
74
76
|
children: content
|
|
75
77
|
}
|
|
76
78
|
);
|
|
@@ -5,6 +5,10 @@ type EditorContextValue = {
|
|
|
5
5
|
isEditor: boolean;
|
|
6
6
|
toolbarPortalRef: RefObject<HTMLDivElement | null> | null;
|
|
7
7
|
fetchLibraryImages?: () => Promise<string[]>;
|
|
8
|
+
/** 站点 ID,用于表单提交等业务接口 */
|
|
9
|
+
siteId?: string;
|
|
10
|
+
/** 后台 API 域名,如 https://api.example.com */
|
|
11
|
+
domain?: string;
|
|
8
12
|
};
|
|
9
13
|
export declare const EditorContextProvider: import("react").Provider<EditorContextValue>;
|
|
10
14
|
export declare const useEditorContext: () => EditorContextValue;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { ErrorBoundary as m } from "../../node_modules/.pnpm/react-error-boundary@6.1.1_react@19.2.4/node_modules/react-error-boundary/dist/react-error-boundary.js";
|
|
3
4
|
import { Button } from "../shadcn/button.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useState } from "react";
|
|
3
4
|
import { toast } from "sonner";
|
|
@@ -16,17 +17,42 @@ const DEFAULT_FIELDS = [
|
|
|
16
17
|
{ label: "Message", name: "message", type: "textarea", required: true }
|
|
17
18
|
];
|
|
18
19
|
const ContactUs = (props) => {
|
|
19
|
-
var _a, _b, _c, _d, _e, _f
|
|
20
|
-
const { isEditor: isEditorMode } = useEditorContext();
|
|
20
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21
|
+
const { isEditor: isEditorMode, siteId, domain } = useEditorContext();
|
|
21
22
|
const formFields = ((_b = (_a = props.form) == null ? void 0 : _a.fields) == null ? void 0 : _b.length) ? props.form.fields : DEFAULT_FIELDS;
|
|
22
23
|
const [values, setValues] = useState({});
|
|
24
|
+
const [submitting, setSubmitting] = useState(false);
|
|
23
25
|
const setValue = (name, value) => setValues((prev) => ({ ...prev, [name]: value }));
|
|
24
|
-
const handleSubmit = (e) => {
|
|
26
|
+
const handleSubmit = async (e) => {
|
|
25
27
|
e.preventDefault();
|
|
26
28
|
if (isEditorMode) return;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
setSubmitting(true);
|
|
30
|
+
try {
|
|
31
|
+
const baseUrl = (domain || "").replace(/\/$/, "");
|
|
32
|
+
const res = await fetch(`${baseUrl}/api/form-leads`, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: { "Content-Type": "application/json" },
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
site_id: siteId,
|
|
37
|
+
name: values.name || "",
|
|
38
|
+
email: values.email || "",
|
|
39
|
+
phone: values.phone || "",
|
|
40
|
+
message: values.message || "",
|
|
41
|
+
source_page: typeof window !== "undefined" ? window.location.pathname : ""
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
const data = await res.json().catch(() => null);
|
|
45
|
+
if (!res.ok || !(data == null ? void 0 : data.success)) {
|
|
46
|
+
throw new Error((data == null ? void 0 : data.errMsg) || `HTTP ${res.status}`);
|
|
47
|
+
}
|
|
48
|
+
toast.success("Message sent successfully!");
|
|
49
|
+
setValues({});
|
|
50
|
+
} catch (err) {
|
|
51
|
+
const msg = err instanceof Error ? err.message : "Failed to send message";
|
|
52
|
+
toast.error(msg);
|
|
53
|
+
} finally {
|
|
54
|
+
setSubmitting(false);
|
|
55
|
+
}
|
|
30
56
|
};
|
|
31
57
|
const submitLabel = ((_d = (_c = props.form) == null ? void 0 : _c.button) == null ? void 0 : _d.label) ?? "Send Message";
|
|
32
58
|
const submitIcon = ((_f = (_e = props.form) == null ? void 0 : _e.button) == null ? void 0 : _f.icon) ?? "send";
|
|
@@ -48,8 +74,6 @@ const ContactUs = (props) => {
|
|
|
48
74
|
{
|
|
49
75
|
className: "rounded-md max-w-md w-full flex flex-col border p-8 gap-4",
|
|
50
76
|
onSubmit: handleSubmit,
|
|
51
|
-
action: (_g = props.form) == null ? void 0 : _g.action,
|
|
52
|
-
method: (_h = props.form) == null ? void 0 : _h.method,
|
|
53
77
|
children: [
|
|
54
78
|
formFields.reduce((rows, field, i) => {
|
|
55
79
|
var _a2, _b2, _c2;
|
|
@@ -126,11 +150,12 @@ const ContactUs = (props) => {
|
|
|
126
150
|
/* @__PURE__ */ jsx(
|
|
127
151
|
CompoundButton,
|
|
128
152
|
{
|
|
129
|
-
label: submitLabel,
|
|
153
|
+
label: submitting ? "Sending..." : submitLabel,
|
|
130
154
|
variant: "default",
|
|
131
155
|
size: "default",
|
|
132
|
-
icon: submitIcon,
|
|
133
|
-
type: "submit"
|
|
156
|
+
icon: submitting ? "loader" : submitIcon,
|
|
157
|
+
type: "submit",
|
|
158
|
+
disabled: submitting
|
|
134
159
|
}
|
|
135
160
|
)
|
|
136
161
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dune-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"eslint-plugin-storybook": "^10.2.19",
|
|
71
71
|
"motion": "12.23.12",
|
|
72
72
|
"react-easy-crop": "5.5.6",
|
|
73
|
+
"rollup-plugin-preserve-directives": "0.4.0",
|
|
73
74
|
"sass": "^1.90.0",
|
|
74
75
|
"sass-loader": "^16.0.5",
|
|
75
76
|
"storybook": "^10.2.19",
|