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

@@ -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", {