fix: 修复组件预览底部按钮溢出与咨询表单缺失

This commit is contained in:
que01 committed 2026-10-09 15:12:40 +08:00
1 parent 5b85fe769f
commit fd2e970d8b
8 files changed
+151 -8

No files matched your search

@@ -35,6 +35,7 @@
}
.component-template-preview__canvas {
position: relative;
container-type: inline-size;
width: min(100%, 390px);
min-height: calc(100% - 48px);
@@ -1,19 +1,29 @@
import { TemplatePage as FoodTemplatePage } from "../../../../../packages/template-acheng-campus-food/taro/index.tsx";
import { TemplatePage as EditorialTemplatePage } from "../../../../../packages/template-linjing-editorial/taro/index.tsx";
import React from "react";
import { Inquiry } from "../../../../taro/src/components/Inquiry.tsx";
import { Records } from "../../../../taro/src/components/Records.tsx";
import { Success } from "../../../../taro/src/components/Success.tsx";
import { TemplateAssetContext } from "./taro-web-components.jsx";
function pageContent({ workspace, page }) {
if (page === "inquiry") return <Inquiry workspace={workspace} preview />;
if (page === "records") return <Records workspace={workspace} />;
if (page === "success") return <Success workspace={workspace} />;
return null;
}
function FoodPreview(props) {
return (
<TemplateAssetContext.Provider value="acheng-campus-food">
<FoodTemplatePage {...props} />
<FoodTemplatePage {...props}>{pageContent(props)}</FoodTemplatePage>
</TemplateAssetContext.Provider>
);
}
function EditorialPreview(props) {
return (
<TemplateAssetContext.Provider value="linjing-editorial">
<EditorialTemplatePage {...props} />
<EditorialTemplatePage {...props}>{pageContent(props)}</EditorialTemplatePage>
</TemplateAssetContext.Provider>
);
}
@@ -27,9 +27,76 @@ const element = (tag) =>
export const View = element("div");
export const Text = element("span");
export const Button = element("button");
export const Input = React.forwardRef((props, ref) =>
React.createElement("input", { ...props, ref }),
export const Input = React.forwardRef(({ onInput, ...props }, ref) =>
React.createElement("input", {
...props,
ref,
onInput: (event) => onInput?.({ detail: { value: event.currentTarget.value } }),
}),
);
export const Textarea = React.forwardRef(({ onInput, maxlength, ...props }, ref) =>
React.createElement("textarea", {
...props,
ref,
maxLength: maxlength,
onInput: (event) => onInput?.({ detail: { value: event.currentTarget.value } }),
}),
);
export function Picker({ children, mode, range = [], value, onChange }) {
return (
<div style={{ position: "relative" }}>
{children}
{mode === "date" ? (
<input
aria-label="选择日期"
type="date"
value={value || ""}
onChange={(event) => onChange?.({ detail: { value: event.currentTarget.value } })}
style={{ position: "absolute", inset: 0, width: "100%", opacity: 0, cursor: "pointer" }}
/>
) : (
<select
aria-label="选择选项"
value={value ?? 0}
onChange={(event) => onChange?.({ detail: { value: event.currentTarget.value } })}
style={{ position: "absolute", inset: 0, width: "100%", opacity: 0, cursor: "pointer" }}
>
{range.map((label, index) => (
<option key={index} value={index}>
{label}
</option>
))}
</select>
)}
</div>
);
}
const CheckboxContext = React.createContext(null);
export function CheckboxGroup({ children, onChange }) {
const [selected, setSelected] = React.useState([]);
const update = (value, checked) => {
const next = checked ? [...selected, value] : selected.filter((item) => item !== value);
setSelected(next);
onChange?.({ detail: { value: next } });
};
return (
<CheckboxContext.Provider value={update}>
<div>{children}</div>
</CheckboxContext.Provider>
);
}
export function Checkbox({ value, checked }) {
const update = React.useContext(CheckboxContext);
return (
<input
type="checkbox"
value={value}
checked={Boolean(checked)}
onChange={(event) => update?.(value, event.currentTarget.checked)}
/>
);
}
export const Label = element("label");
export const Image = React.forwardRef(({ mode, src, style, ...props }, ref) => {
const key = React.useContext(TemplateAssetContext);
return React.createElement("img", {
@@ -1,4 +1,7 @@
import React from "react";
const noop = () => Promise.resolve();
export const useRouter = () => ({ params: {} });
export const useDidShow = (callback) => React.useEffect(callback, []);
const Taro = {
setStorageSync() {},
getStorageSync() {