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) => { ...@@ -21,6 +21,7 @@ export const NeosModal: FC<Props> = (props) => {
closeIcon={mini ? <UpOutlined /> : <MinusOutlined />} closeIcon={mini ? <UpOutlined /> : <MinusOutlined />}
bodyStyle={{ padding: "10px 0" }} bodyStyle={{ padding: "10px 0" }}
mask={!mini} mask={!mini}
closable={canBeMinimized}
{...props} {...props}
/> />
); );
......
...@@ -106,12 +106,16 @@ export const SelectCardsModal: FC<{ ...@@ -106,12 +106,16 @@ export const SelectCardsModal: FC<{
open={isOpen} open={isOpen}
footer={ footer={
<> <>
<Button danger disabled={!cancelable} onClick={onCancel}> {cancelable && (
<Button danger onClick={onCancel}>
{cancelText} {cancelText}
</Button> </Button>
<Button type="dashed" disabled={!finishable} onClick={onFinish}> )}
{finishable && (
<Button type="dashed" onClick={onFinish}>
{finishText} {finishText}
</Button> </Button>
)}
<Button <Button
type="primary" type="primary"
disabled={!submitable} disabled={!submitable}
...@@ -139,7 +143,7 @@ export const SelectCardsModal: FC<{ ...@@ -139,7 +143,7 @@ export const SelectCardsModal: FC<{
<CheckCard.Group <CheckCard.Group
onChange={setResult as any} onChange={setResult as any}
// TODO 考虑如何设置默认值,比如只有一个的,就直接选中 // TODO 考虑如何设置默认值,比如只有一个的,就直接选中
multiple multiple={!single}
style={{ style={{
display: "grid", display: "grid",
gridTemplateColumns: "repeat(6, 1fr)", 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