Commit 7d3d3960 authored by timel's avatar timel

feat: simple select cards modal

parent 37fdc115
Pipeline #22386 failed with stages
in 23 minutes and 20 seconds
......@@ -21,6 +21,7 @@ export const NeosModal: FC<Props> = (props) => {
closeIcon={mini ? <UpOutlined /> : <MinusOutlined />}
bodyStyle={{ padding: "10px 0" }}
mask={!mini}
closable={canBeMinimized}
{...props}
/>
);
......
......@@ -106,12 +106,16 @@ export const SelectCardsModal: FC<{
open={isOpen}
footer={
<>
<Button danger disabled={!cancelable} onClick={onCancel}>
{cancelText}
</Button>
<Button type="dashed" disabled={!finishable} onClick={onFinish}>
{finishText}
</Button>
{cancelable && (
<Button danger onClick={onCancel}>
{cancelText}
</Button>
)}
{finishable && (
<Button type="dashed" onClick={onFinish}>
{finishText}
</Button>
)}
<Button
type="primary"
disabled={!submitable}
......@@ -139,7 +143,7 @@ export const SelectCardsModal: FC<{
<CheckCard.Group
onChange={setResult as any}
// TODO 考虑如何设置默认值,比如只有一个的,就直接选中
multiple
multiple={!single}
style={{
display: "grid",
gridTemplateColumns: "repeat(6, 1fr)",
......
// import "./index.scss";
import { type FC } from "react";
import { proxy, useSnapshot, INTERNAL_Snapshot as Snapshot } from "valtio";
import { SelectCardsModal, type Option } from "../SelectCardsModal";
const defaultProps = {
isOpen: false,
selectables: [] as Option[],
};
const localStore = proxy(defaultProps);
export const SimpleSelectCardsModal: FC = () => {
const { isOpen, selectables } = useSnapshot(localStore);
return (
<SelectCardsModal
isOpen={isOpen}
isChain={false}
min={1}
max={1}
single
selecteds={[]}
mustSelects={[]}
selectables={selectables}
cancelable
finishable={false}
totalLevels={1}
overflow
onSubmit={(options) => rs(options)}
onFinish={() => rs([])}
onCancel={() => rs([])}
/>
);
};
let rs: (options: Snapshot<Option[]>) => void = () => {};
export const displaySimpleSelectActionsModal = async (
args: Omit<typeof defaultProps, "isOpen">
) => {
localStore.isOpen = true;
localStore.selectables = args.selectables;
await new Promise<Snapshot<Option[]>>((resolve) => (rs = resolve)); // 等待在组件内resolve
localStore.isOpen = false;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment