@canvas-components/react-drag-any 0.0.0-stage → 1.0.1

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/index.css ADDED
@@ -0,0 +1,160 @@
1
+ /* src/styles/theme.css */
2
+ .drag-any-overlay {
3
+ color: var(--drag-overlay-text);
4
+ line-height: 1.45;
5
+ }
6
+ .drag-any-overlay :focus-visible {
7
+ outline: 2px solid var(--drag-overlay-focus);
8
+ outline-offset: -2px;
9
+ }
10
+
11
+ /* src/styles/menu.css */
12
+ .drag-any-menu,
13
+ .drag-any-tooltip,
14
+ .drag-any-editor-host {
15
+ position: fixed;
16
+ z-index: 1200;
17
+ box-sizing: border-box;
18
+ border: 1px solid var(--drag-overlay-border);
19
+ border-radius: 6px;
20
+ color: var(--drag-overlay-text);
21
+ background: var(--drag-overlay-bg);
22
+ box-shadow: 0 6px 20px var(--drag-overlay-shadow);
23
+ }
24
+ .drag-any-menu {
25
+ width: max-content;
26
+ min-width: min(172px, var(--drag-overlay-max-width, 100vw));
27
+ padding: 4px;
28
+ overflow: auto;
29
+ overscroll-behavior: contain;
30
+ }
31
+ .drag-any-menu [role=menuitem] {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: space-between;
35
+ gap: 16px;
36
+ width: 100%;
37
+ min-height: 30px;
38
+ padding: 5px 9px;
39
+ border: 0;
40
+ border-radius: 4px;
41
+ background: transparent;
42
+ color: inherit;
43
+ font: inherit;
44
+ text-align: start;
45
+ overflow-wrap: anywhere;
46
+ cursor: pointer;
47
+ }
48
+ .drag-any-menu [role=menuitem]:not(:disabled):is(:hover, :focus-visible, [aria-expanded=true]) {
49
+ background: var(--drag-overlay-hover);
50
+ }
51
+ .drag-any-menu [role=menuitem][data-danger=true] {
52
+ color: var(--drag-overlay-danger);
53
+ }
54
+ .drag-any-menu [role=menuitem]:disabled {
55
+ color: var(--drag-overlay-muted);
56
+ cursor: default;
57
+ }
58
+ .drag-any-menu [role=separator] {
59
+ margin: 4px;
60
+ border-top: 1px solid var(--drag-overlay-border);
61
+ }
62
+ .drag-any-tooltip {
63
+ width: max-content;
64
+ padding: 5px 9px;
65
+ overflow: hidden;
66
+ overflow-wrap: anywhere;
67
+ white-space: pre-wrap;
68
+ pointer-events: none;
69
+ }
70
+ .drag-any-editor-host {
71
+ padding: 8px;
72
+ overflow: auto;
73
+ }
74
+
75
+ /* src/styles/dialogs.css */
76
+ .drag-any-dialog-backdrop {
77
+ position: fixed;
78
+ z-index: 1210;
79
+ inset: 0;
80
+ display: grid;
81
+ place-items: center;
82
+ background: rgba(15, 23, 42, 0.22);
83
+ }
84
+ .drag-any-dialog {
85
+ position: static;
86
+ box-sizing: border-box;
87
+ width: min(390px, calc(100% - 24px));
88
+ max-height: calc(100% - 24px);
89
+ margin: auto;
90
+ padding: 0;
91
+ overflow: auto;
92
+ color: var(--drag-overlay-text);
93
+ font: inherit;
94
+ border: 1px solid var(--drag-overlay-border);
95
+ border-radius: 8px;
96
+ background: var(--drag-overlay-bg);
97
+ box-shadow: 0 8px 24px var(--drag-overlay-shadow);
98
+ }
99
+ .drag-any-dialog-backdrop:has(.drag-any-dialog:modal) {
100
+ background: transparent;
101
+ }
102
+ .drag-any-dialog:modal {
103
+ position: fixed;
104
+ }
105
+ .drag-any-dialog::backdrop {
106
+ background: rgba(15, 23, 42, 0.22);
107
+ }
108
+ .drag-any-dialog h2 {
109
+ position: sticky;
110
+ top: 0;
111
+ margin: 0;
112
+ padding: 12px 16px;
113
+ border-bottom: 1px solid var(--drag-overlay-border);
114
+ background: var(--drag-overlay-bg);
115
+ font-size: 1.1em;
116
+ }
117
+ .drag-any-dialog-fields {
118
+ display: grid;
119
+ gap: 8px;
120
+ padding: 12px 16px;
121
+ }
122
+ .drag-any-dialog-fields label {
123
+ display: grid;
124
+ grid-template-columns: 1fr minmax(0, 1fr);
125
+ align-items: center;
126
+ gap: 12px;
127
+ }
128
+ .drag-any-dialog-fields input[type=checkbox] {
129
+ justify-self: start;
130
+ }
131
+ .drag-any-dialog footer {
132
+ position: sticky;
133
+ bottom: 0;
134
+ display: flex;
135
+ justify-content: end;
136
+ gap: 8px;
137
+ padding: 10px 16px;
138
+ border-top: 1px solid var(--drag-overlay-border);
139
+ background: var(--drag-overlay-bg);
140
+ }
141
+ .drag-any-dialog :is(input:not([type=checkbox]), select, button) {
142
+ box-sizing: border-box;
143
+ min-height: 30px;
144
+ min-width: 0;
145
+ padding: 3px 8px;
146
+ border: 1px solid var(--drag-overlay-border);
147
+ border-radius: 4px;
148
+ background: var(--drag-overlay-bg);
149
+ color: inherit;
150
+ font: inherit;
151
+ }
152
+ .drag-any-dialog button {
153
+ cursor: pointer;
154
+ }
155
+ .drag-any-dialog button:is(:hover, [data-primary]) {
156
+ background: var(--drag-overlay-hover);
157
+ }
158
+ .drag-any-dialog button[data-primary] {
159
+ border-color: var(--drag-overlay-focus);
160
+ }
@@ -0,0 +1,180 @@
1
+ import { ReactNode, CSSProperties, Ref, RefAttributes, ReactElement } from 'react';
2
+ import { DragPoint, DragTheme, DragContentInput, DragRegionContentAction, DragRegionRenderContext, DragId, DragRenderTarget, dragAnyProjection, DragRenderContext, DragScrollbarOptions, DragDocument, DragStore, DragAny, DragMoveProposal, DragContentError, DragContentErrorCode, DragContentAction, DragDocumentCard, DragDocumentSlot, DragDocumentLane } from '@canvas-components/drag-any';
3
+ import { CompiledUILayout } from '@canvas-components/react-canvas-ui';
4
+
5
+ /** 热点或省略文本由宿主提供的提示内容。 */
6
+ interface TooltipProps {
7
+ readonly request: {
8
+ readonly text: string;
9
+ readonly clientAnchor: DragPoint;
10
+ };
11
+ readonly owner?: HTMLElement | null;
12
+ readonly theme?: Partial<DragTheme>;
13
+ }
14
+
15
+ /** 宿主提供的编辑视图和锚点。 */
16
+ interface EditorHostProps {
17
+ readonly request: {
18
+ readonly view: ReactNode;
19
+ readonly clientAnchor: DragPoint;
20
+ };
21
+ readonly onClose: () => void;
22
+ readonly owner?: HTMLElement | null;
23
+ readonly theme?: Partial<DragTheme>;
24
+ }
25
+
26
+ type DragOptions<T> = Parameters<typeof dragAnyProjection.create<T>>[0];
27
+ /** React 画布支持的原生内容文档或声明式 JSX。 */
28
+ type ReactDragContentInput = DragContentInput | ReactNode;
29
+ /** 通用 Canvas UI JSX 可投影的拖拽布局。 */
30
+ type DragJSXMode = "queue" | "lanes";
31
+ /** 依据结构 JSX 的原始 key 绑定拖拽业务数据。 */
32
+ type DragJSXRole<T> = {
33
+ kind: "region";
34
+ id: string;
35
+ dropDisabled?: boolean;
36
+ } | {
37
+ kind: "header";
38
+ } | {
39
+ kind: "items";
40
+ } | {
41
+ kind: "card";
42
+ id: string;
43
+ data?: T;
44
+ disabled?: boolean;
45
+ };
46
+ /** 通用 JSX 入口的布局和角色查找方式。 */
47
+ interface DragJSXOptions<T> {
48
+ readonly dragLayout: DragJSXMode;
49
+ readonly getDragRole: (key: string) => DragJSXRole<T> | undefined;
50
+ }
51
+ type WithoutDragJSX = {
52
+ [Key in keyof DragJSXOptions<unknown>]?: never;
53
+ };
54
+ interface ReactDragAnyBoardProps<T> extends Omit<DragOptions<T>, "model" | "contentRuntime" | "renderCard" | "render" | "onMoveRequest"> {
55
+ readonly height?: number | string;
56
+ readonly active?: boolean;
57
+ readonly className?: string;
58
+ readonly style?: CSSProperties;
59
+ readonly rootRef?: Ref<HTMLDivElement>;
60
+ readonly render?: (context: DragRegionRenderContext<T>) => ReactDragContentInput | undefined;
61
+ readonly renderCard?: (context: DragRenderContext<T>) => ReactDragContentInput;
62
+ readonly storageKey?: string;
63
+ readonly onScrollbarChange?: (options: DragScrollbarOptions | undefined) => void;
64
+ readonly tooltip?: TooltipProps["request"];
65
+ readonly editor?: Pick<EditorHostProps, "request" | "onClose">;
66
+ }
67
+ type ControlledBoard<T> = Pick<DragOptions<T>, "model" | "onMoveRequest"> & {
68
+ readonly acknowledgedTransactionId?: string;
69
+ };
70
+ /** 声明式独立画布,可传原生文档或 JSX 布局根。 */
71
+ type ReactDragAnyDeclarativeProps<T> = Omit<ReactDragAnyBoardProps<T | undefined>, "layout" | "render" | "renderCard" | "renderVersion"> & Pick<ControlledBoard<T | undefined>, "onMoveRequest" | "acknowledgedTransactionId"> & {
72
+ readonly layout?: never;
73
+ readonly model?: never;
74
+ readonly render?: never;
75
+ readonly renderCard?: never;
76
+ readonly renderVersion?: never;
77
+ } & ((WithoutDragJSX & {
78
+ readonly document: DragDocument<T, ReactDragContentInput>;
79
+ readonly children?: never;
80
+ readonly store?: never;
81
+ }) | ((WithoutDragJSX | DragJSXOptions<T>) & {
82
+ readonly children: ReactNode;
83
+ readonly document?: never;
84
+ readonly store?: never;
85
+ }) | (WithoutDragJSX & {
86
+ readonly store: DragStore<T>;
87
+ readonly children?: never;
88
+ readonly document?: never;
89
+ }));
90
+ /** 声明式组由成员提交文档,组接收一个确认事务。 */
91
+ interface ReactDragAnyGroupProps<T> {
92
+ readonly onMoveRequest?: (proposal: DragMoveProposal<T | undefined>) => void;
93
+ readonly onError?: (error: unknown) => void;
94
+ readonly children?: ReactNode;
95
+ readonly state?: never;
96
+ readonly acknowledgedTransactionId?: string;
97
+ }
98
+ /** 画布组的命令接口。 */
99
+ interface ReactDragAnyGroupHandle {
100
+ cancelDrag(reason?: string): void;
101
+ rejectMove(transactionId: string, reason?: string): boolean;
102
+ }
103
+ /** 画布实例的命令接口;卸载或未挂载时没有快照。 */
104
+ interface ReactDragAnyHandle<T> extends ReactDragAnyGroupHandle {
105
+ scrollTo: DragAny<T>["scrollTo"];
106
+ focusCard: DragAny<T>["focusCard"];
107
+ getSnapshot(): ReturnType<DragAny<T>["getSnapshot"]> | undefined;
108
+ }
109
+ /** 动作标识的画布、展示实例和内容版本。 */
110
+ interface ContentCompileContext {
111
+ readonly boardId: DragId;
112
+ readonly cardId?: DragId;
113
+ readonly ownerKey?: string;
114
+ readonly target?: DragRenderTarget;
115
+ readonly renderContext?: DragRegionRenderContext<unknown>;
116
+ readonly contentVersion?: string | number;
117
+ readonly onDiagnostic?: (message: string, path: string) => void;
118
+ }
119
+ /** 可交给原生引擎的文档及其独立动作回调。 */
120
+ interface CompiledContent {
121
+ readonly document: CompiledUILayout["document"];
122
+ readonly handlers: ReadonlyMap<string, (action: DragRegionContentAction, context: DragRegionRenderContext<unknown>) => void>;
123
+ dispose(): void;
124
+ }
125
+
126
+ /** 以文档、结构 JSX 或 store 挂载声明式画布。 */
127
+ declare const ReactDragAny: <T>(props: ReactDragAnyDeclarativeProps<T> & RefAttributes<ReactDragAnyHandle<T | undefined>>) => ReactElement | null;
128
+
129
+ /** 声明式画布组在同一次发布中更新所有成员。 */
130
+ declare const ReactDragAnyGroup: <T>(props: ReactDragAnyGroupProps<T> & RefAttributes<ReactDragAnyGroupHandle>) => ReactElement | null;
131
+
132
+ /** 带展示实例 ID 的 JSX 或原生内容诊断。 */
133
+ declare class ContentCompileError extends DragContentError {
134
+ readonly cardId: string;
135
+ constructor(cardId: string, code: DragContentErrorCode, nodePath: string);
136
+ }
137
+ /** 将 UI 声明或兼容的内置标签转换为 Canvas UI 文档和动作绑定。 */
138
+ declare function compileJSX(input: unknown, context: ContentCompileContext): CompiledContent;
139
+
140
+ type PreparedContent = CompiledContent & {
141
+ readonly layoutKey?: object;
142
+ };
143
+ /** 单个 React 画布的内容回调生命周期。 */
144
+ interface ContentBindings {
145
+ prepare(input: ReactDragContentInput, context: ContentCompileContext): PreparedContent;
146
+ commit(prepared: CompiledContent): void;
147
+ dispatch(action: DragRegionContentAction | Pick<DragContentAction, "cardId" | "actionId">): boolean;
148
+ release(prepared: CompiledContent): void;
149
+ destroy(): void;
150
+ }
151
+ /** 创建实例级侧表,prepare 计算内容,commit 发布该次准备的回调。 */
152
+ declare function createContentBindings(): ContentBindings;
153
+
154
+ type Content = ReactDragContentInput;
155
+ type ChildrenOr<K extends string, Value> = ({
156
+ children?: ReactNode;
157
+ } & {
158
+ [P in K]?: never;
159
+ }) | ({
160
+ children?: never;
161
+ } & {
162
+ [P in K]?: Value;
163
+ });
164
+ type Cards<T> = ChildrenOr<"cards", readonly DragDocumentCard<T, Content>[]>;
165
+ type Root<T, K extends DragDocument["type"]> = Extract<DragDocument<T, Content>, {
166
+ type: K;
167
+ }>;
168
+ type LanesProps<T> = Omit<Root<T, "lanes">, "type" | "lanes"> & ChildrenOr<"lanes", readonly DragDocumentLane<T, Content>[]>;
169
+ type GridProps<T> = Omit<Root<T, "sparse-grid">, "type" | "slots"> & ChildrenOr<"slots", readonly DragDocumentSlot<T, Content>[]>;
170
+ type SequenceProps<T, K extends "queue" | "flow"> = Omit<Root<T, K>, "type" | "cards"> & Cards<T>;
171
+ /** 声明一组自上向下排列的横向泳道。 */
172
+ declare function Lanes<T>(_props: LanesProps<T>): never;
173
+ declare function Lane<T>(_props: Omit<DragDocumentLane<T, Content>, "cards"> & Cards<T>): never;
174
+ declare function SparseGrid<T>(_props: GridProps<T>): never;
175
+ declare function GridSlot<T>(_props: Omit<DragDocumentSlot<T, Content>, "cards"> & Cards<T>): never;
176
+ declare function Queue<T>(_props: SequenceProps<T, "queue">): never;
177
+ declare function Flow<T>(_props: SequenceProps<T, "flow">): never;
178
+ declare function Card<T>(_props: Omit<DragDocumentCard<T, Content>, "content"> & ChildrenOr<"content", Content>): never;
179
+
180
+ export { Card, type CompiledContent, type ContentBindings, type ContentCompileContext, ContentCompileError, type DragJSXMode, type DragJSXOptions, type DragJSXRole, Flow, GridSlot, Lane, Lanes, Queue, ReactDragAny, type ReactDragAnyDeclarativeProps, ReactDragAnyGroup, type ReactDragAnyGroupHandle, type ReactDragAnyGroupProps, type ReactDragAnyHandle, type ReactDragAnyDeclarativeProps as ReactDragAnyProps, type ReactDragContentInput, SparseGrid, compileJSX, createContentBindings };
@@ -0,0 +1,180 @@
1
+ import { ReactNode, CSSProperties, Ref, RefAttributes, ReactElement } from 'react';
2
+ import { DragPoint, DragTheme, DragContentInput, DragRegionContentAction, DragRegionRenderContext, DragId, DragRenderTarget, dragAnyProjection, DragRenderContext, DragScrollbarOptions, DragDocument, DragStore, DragAny, DragMoveProposal, DragContentError, DragContentErrorCode, DragContentAction, DragDocumentCard, DragDocumentSlot, DragDocumentLane } from '@canvas-components/drag-any';
3
+ import { CompiledUILayout } from '@canvas-components/react-canvas-ui';
4
+
5
+ /** 热点或省略文本由宿主提供的提示内容。 */
6
+ interface TooltipProps {
7
+ readonly request: {
8
+ readonly text: string;
9
+ readonly clientAnchor: DragPoint;
10
+ };
11
+ readonly owner?: HTMLElement | null;
12
+ readonly theme?: Partial<DragTheme>;
13
+ }
14
+
15
+ /** 宿主提供的编辑视图和锚点。 */
16
+ interface EditorHostProps {
17
+ readonly request: {
18
+ readonly view: ReactNode;
19
+ readonly clientAnchor: DragPoint;
20
+ };
21
+ readonly onClose: () => void;
22
+ readonly owner?: HTMLElement | null;
23
+ readonly theme?: Partial<DragTheme>;
24
+ }
25
+
26
+ type DragOptions<T> = Parameters<typeof dragAnyProjection.create<T>>[0];
27
+ /** React 画布支持的原生内容文档或声明式 JSX。 */
28
+ type ReactDragContentInput = DragContentInput | ReactNode;
29
+ /** 通用 Canvas UI JSX 可投影的拖拽布局。 */
30
+ type DragJSXMode = "queue" | "lanes";
31
+ /** 依据结构 JSX 的原始 key 绑定拖拽业务数据。 */
32
+ type DragJSXRole<T> = {
33
+ kind: "region";
34
+ id: string;
35
+ dropDisabled?: boolean;
36
+ } | {
37
+ kind: "header";
38
+ } | {
39
+ kind: "items";
40
+ } | {
41
+ kind: "card";
42
+ id: string;
43
+ data?: T;
44
+ disabled?: boolean;
45
+ };
46
+ /** 通用 JSX 入口的布局和角色查找方式。 */
47
+ interface DragJSXOptions<T> {
48
+ readonly dragLayout: DragJSXMode;
49
+ readonly getDragRole: (key: string) => DragJSXRole<T> | undefined;
50
+ }
51
+ type WithoutDragJSX = {
52
+ [Key in keyof DragJSXOptions<unknown>]?: never;
53
+ };
54
+ interface ReactDragAnyBoardProps<T> extends Omit<DragOptions<T>, "model" | "contentRuntime" | "renderCard" | "render" | "onMoveRequest"> {
55
+ readonly height?: number | string;
56
+ readonly active?: boolean;
57
+ readonly className?: string;
58
+ readonly style?: CSSProperties;
59
+ readonly rootRef?: Ref<HTMLDivElement>;
60
+ readonly render?: (context: DragRegionRenderContext<T>) => ReactDragContentInput | undefined;
61
+ readonly renderCard?: (context: DragRenderContext<T>) => ReactDragContentInput;
62
+ readonly storageKey?: string;
63
+ readonly onScrollbarChange?: (options: DragScrollbarOptions | undefined) => void;
64
+ readonly tooltip?: TooltipProps["request"];
65
+ readonly editor?: Pick<EditorHostProps, "request" | "onClose">;
66
+ }
67
+ type ControlledBoard<T> = Pick<DragOptions<T>, "model" | "onMoveRequest"> & {
68
+ readonly acknowledgedTransactionId?: string;
69
+ };
70
+ /** 声明式独立画布,可传原生文档或 JSX 布局根。 */
71
+ type ReactDragAnyDeclarativeProps<T> = Omit<ReactDragAnyBoardProps<T | undefined>, "layout" | "render" | "renderCard" | "renderVersion"> & Pick<ControlledBoard<T | undefined>, "onMoveRequest" | "acknowledgedTransactionId"> & {
72
+ readonly layout?: never;
73
+ readonly model?: never;
74
+ readonly render?: never;
75
+ readonly renderCard?: never;
76
+ readonly renderVersion?: never;
77
+ } & ((WithoutDragJSX & {
78
+ readonly document: DragDocument<T, ReactDragContentInput>;
79
+ readonly children?: never;
80
+ readonly store?: never;
81
+ }) | ((WithoutDragJSX | DragJSXOptions<T>) & {
82
+ readonly children: ReactNode;
83
+ readonly document?: never;
84
+ readonly store?: never;
85
+ }) | (WithoutDragJSX & {
86
+ readonly store: DragStore<T>;
87
+ readonly children?: never;
88
+ readonly document?: never;
89
+ }));
90
+ /** 声明式组由成员提交文档,组接收一个确认事务。 */
91
+ interface ReactDragAnyGroupProps<T> {
92
+ readonly onMoveRequest?: (proposal: DragMoveProposal<T | undefined>) => void;
93
+ readonly onError?: (error: unknown) => void;
94
+ readonly children?: ReactNode;
95
+ readonly state?: never;
96
+ readonly acknowledgedTransactionId?: string;
97
+ }
98
+ /** 画布组的命令接口。 */
99
+ interface ReactDragAnyGroupHandle {
100
+ cancelDrag(reason?: string): void;
101
+ rejectMove(transactionId: string, reason?: string): boolean;
102
+ }
103
+ /** 画布实例的命令接口;卸载或未挂载时没有快照。 */
104
+ interface ReactDragAnyHandle<T> extends ReactDragAnyGroupHandle {
105
+ scrollTo: DragAny<T>["scrollTo"];
106
+ focusCard: DragAny<T>["focusCard"];
107
+ getSnapshot(): ReturnType<DragAny<T>["getSnapshot"]> | undefined;
108
+ }
109
+ /** 动作标识的画布、展示实例和内容版本。 */
110
+ interface ContentCompileContext {
111
+ readonly boardId: DragId;
112
+ readonly cardId?: DragId;
113
+ readonly ownerKey?: string;
114
+ readonly target?: DragRenderTarget;
115
+ readonly renderContext?: DragRegionRenderContext<unknown>;
116
+ readonly contentVersion?: string | number;
117
+ readonly onDiagnostic?: (message: string, path: string) => void;
118
+ }
119
+ /** 可交给原生引擎的文档及其独立动作回调。 */
120
+ interface CompiledContent {
121
+ readonly document: CompiledUILayout["document"];
122
+ readonly handlers: ReadonlyMap<string, (action: DragRegionContentAction, context: DragRegionRenderContext<unknown>) => void>;
123
+ dispose(): void;
124
+ }
125
+
126
+ /** 以文档、结构 JSX 或 store 挂载声明式画布。 */
127
+ declare const ReactDragAny: <T>(props: ReactDragAnyDeclarativeProps<T> & RefAttributes<ReactDragAnyHandle<T | undefined>>) => ReactElement | null;
128
+
129
+ /** 声明式画布组在同一次发布中更新所有成员。 */
130
+ declare const ReactDragAnyGroup: <T>(props: ReactDragAnyGroupProps<T> & RefAttributes<ReactDragAnyGroupHandle>) => ReactElement | null;
131
+
132
+ /** 带展示实例 ID 的 JSX 或原生内容诊断。 */
133
+ declare class ContentCompileError extends DragContentError {
134
+ readonly cardId: string;
135
+ constructor(cardId: string, code: DragContentErrorCode, nodePath: string);
136
+ }
137
+ /** 将 UI 声明或兼容的内置标签转换为 Canvas UI 文档和动作绑定。 */
138
+ declare function compileJSX(input: unknown, context: ContentCompileContext): CompiledContent;
139
+
140
+ type PreparedContent = CompiledContent & {
141
+ readonly layoutKey?: object;
142
+ };
143
+ /** 单个 React 画布的内容回调生命周期。 */
144
+ interface ContentBindings {
145
+ prepare(input: ReactDragContentInput, context: ContentCompileContext): PreparedContent;
146
+ commit(prepared: CompiledContent): void;
147
+ dispatch(action: DragRegionContentAction | Pick<DragContentAction, "cardId" | "actionId">): boolean;
148
+ release(prepared: CompiledContent): void;
149
+ destroy(): void;
150
+ }
151
+ /** 创建实例级侧表,prepare 计算内容,commit 发布该次准备的回调。 */
152
+ declare function createContentBindings(): ContentBindings;
153
+
154
+ type Content = ReactDragContentInput;
155
+ type ChildrenOr<K extends string, Value> = ({
156
+ children?: ReactNode;
157
+ } & {
158
+ [P in K]?: never;
159
+ }) | ({
160
+ children?: never;
161
+ } & {
162
+ [P in K]?: Value;
163
+ });
164
+ type Cards<T> = ChildrenOr<"cards", readonly DragDocumentCard<T, Content>[]>;
165
+ type Root<T, K extends DragDocument["type"]> = Extract<DragDocument<T, Content>, {
166
+ type: K;
167
+ }>;
168
+ type LanesProps<T> = Omit<Root<T, "lanes">, "type" | "lanes"> & ChildrenOr<"lanes", readonly DragDocumentLane<T, Content>[]>;
169
+ type GridProps<T> = Omit<Root<T, "sparse-grid">, "type" | "slots"> & ChildrenOr<"slots", readonly DragDocumentSlot<T, Content>[]>;
170
+ type SequenceProps<T, K extends "queue" | "flow"> = Omit<Root<T, K>, "type" | "cards"> & Cards<T>;
171
+ /** 声明一组自上向下排列的横向泳道。 */
172
+ declare function Lanes<T>(_props: LanesProps<T>): never;
173
+ declare function Lane<T>(_props: Omit<DragDocumentLane<T, Content>, "cards"> & Cards<T>): never;
174
+ declare function SparseGrid<T>(_props: GridProps<T>): never;
175
+ declare function GridSlot<T>(_props: Omit<DragDocumentSlot<T, Content>, "cards"> & Cards<T>): never;
176
+ declare function Queue<T>(_props: SequenceProps<T, "queue">): never;
177
+ declare function Flow<T>(_props: SequenceProps<T, "flow">): never;
178
+ declare function Card<T>(_props: Omit<DragDocumentCard<T, Content>, "content"> & ChildrenOr<"content", Content>): never;
179
+
180
+ export { Card, type CompiledContent, type ContentBindings, type ContentCompileContext, ContentCompileError, type DragJSXMode, type DragJSXOptions, type DragJSXRole, Flow, GridSlot, Lane, Lanes, Queue, ReactDragAny, type ReactDragAnyDeclarativeProps, ReactDragAnyGroup, type ReactDragAnyGroupHandle, type ReactDragAnyGroupProps, type ReactDragAnyHandle, type ReactDragAnyDeclarativeProps as ReactDragAnyProps, type ReactDragContentInput, SparseGrid, compileJSX, createContentBindings };