svelte-flexiboards 0.1.0

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.
Files changed (44) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/components/flexi-add.svelte +35 -0
  3. package/dist/components/flexi-add.svelte.d.ts +16 -0
  4. package/dist/components/flexi-board.svelte +30 -0
  5. package/dist/components/flexi-board.svelte.d.ts +11 -0
  6. package/dist/components/flexi-delete.svelte +22 -0
  7. package/dist/components/flexi-delete.svelte.d.ts +13 -0
  8. package/dist/components/flexi-grab.svelte +20 -0
  9. package/dist/components/flexi-grab.svelte.d.ts +12 -0
  10. package/dist/components/flexi-grid.svelte +19 -0
  11. package/dist/components/flexi-grid.svelte.d.ts +8 -0
  12. package/dist/components/flexi-layout-loader.svelte +10 -0
  13. package/dist/components/flexi-layout-loader.svelte.d.ts +18 -0
  14. package/dist/components/flexi-resize.svelte +20 -0
  15. package/dist/components/flexi-resize.svelte.d.ts +12 -0
  16. package/dist/components/flexi-target-loader.svelte +10 -0
  17. package/dist/components/flexi-target-loader.svelte.d.ts +18 -0
  18. package/dist/components/flexi-target.svelte +93 -0
  19. package/dist/components/flexi-target.svelte.d.ts +42 -0
  20. package/dist/components/flexi-widget.svelte +37 -0
  21. package/dist/components/flexi-widget.svelte.d.ts +9 -0
  22. package/dist/components/index.d.ts +1 -0
  23. package/dist/components/index.js +1 -0
  24. package/dist/components/rendered-flexi-widget.svelte +44 -0
  25. package/dist/components/rendered-flexi-widget.svelte.d.ts +7 -0
  26. package/dist/index.d.ts +16 -0
  27. package/dist/index.js +10 -0
  28. package/dist/system/grid.svelte.d.ts +146 -0
  29. package/dist/system/grid.svelte.js +815 -0
  30. package/dist/system/index.d.ts +1 -0
  31. package/dist/system/index.js +1 -0
  32. package/dist/system/manage.svelte.d.ts +25 -0
  33. package/dist/system/manage.svelte.js +54 -0
  34. package/dist/system/provider.svelte.d.ts +51 -0
  35. package/dist/system/provider.svelte.js +290 -0
  36. package/dist/system/target.svelte.d.ts +179 -0
  37. package/dist/system/target.svelte.js +397 -0
  38. package/dist/system/types.d.ts +91 -0
  39. package/dist/system/types.js +1 -0
  40. package/dist/system/utils.svelte.d.ts +21 -0
  41. package/dist/system/utils.svelte.js +156 -0
  42. package/dist/system/widget.svelte.d.ts +225 -0
  43. package/dist/system/widget.svelte.js +447 -0
  44. package/package.json +57 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,25 @@
1
+ import { type InternalFlexiBoardController } from "./provider.svelte.js";
2
+ import type { WidgetGrabbedParams } from "./types.js";
3
+ import { FlexiWidgetController, type FlexiWidgetConfiguration } from "./widget.svelte.js";
4
+ export type FlexiAddWidgetFn = () => AdderWidgetConfiguration | null;
5
+ export type AdderWidgetConfiguration = {
6
+ widget: FlexiWidgetConfiguration;
7
+ widthPx?: number;
8
+ heightPx?: number;
9
+ };
10
+ export declare class FlexiAddController {
11
+ #private;
12
+ newWidget?: FlexiWidgetController;
13
+ constructor(provider: InternalFlexiBoardController, addWidgetFn: FlexiAddWidgetFn);
14
+ onpointerdown(event: PointerEvent): void;
15
+ onstartwidgetdragin(event: WidgetGrabbedParams): import("./types.js").WidgetGrabAction | null;
16
+ onstopwidgetdragin(): void;
17
+ }
18
+ export declare function flexiadd(addWidgetFn: FlexiAddWidgetFn): {
19
+ adder: FlexiAddController;
20
+ onpointerdown: (event: PointerEvent) => void;
21
+ };
22
+ export declare function flexidelete(): {
23
+ onpointerenter: () => void;
24
+ onpointerleave: () => void;
25
+ };
@@ -0,0 +1,54 @@
1
+ import { getFlexiboardCtx, getInternalFlexiboardCtx } from "./provider.svelte.js";
2
+ import { FlexiWidgetController } from "./widget.svelte.js";
3
+ export class FlexiAddController {
4
+ #provider;
5
+ #addWidget;
6
+ newWidget = $state(undefined);
7
+ constructor(provider, addWidgetFn) {
8
+ this.#provider = provider;
9
+ this.#addWidget = addWidgetFn;
10
+ this.onpointerdown = this.onpointerdown.bind(this);
11
+ }
12
+ onpointerdown(event) {
13
+ const config = this.#addWidget();
14
+ if (!config || !config.widget) {
15
+ return;
16
+ }
17
+ // Create a widget under this FlexiAdd, which will automatically place it into a grabbed state.
18
+ this.newWidget = new FlexiWidgetController({
19
+ type: "adder",
20
+ adder: this,
21
+ config: config.widget,
22
+ widthPx: config.widthPx ?? 100,
23
+ heightPx: config.heightPx ?? 100
24
+ });
25
+ // Don't implicitly keep the pointer capture, as then mobile can't move the widget in and out of targets.
26
+ event.target.releasePointerCapture(event.pointerId);
27
+ event.preventDefault();
28
+ }
29
+ onstartwidgetdragin(event) {
30
+ return this.#provider.onwidgetgrabbed({
31
+ ...event,
32
+ adder: this
33
+ });
34
+ }
35
+ onstopwidgetdragin() {
36
+ // Whether it got placed into a target or not, the FlexiAdd's work is done.
37
+ this.newWidget = undefined;
38
+ }
39
+ }
40
+ export function flexiadd(addWidgetFn) {
41
+ const provider = getInternalFlexiboardCtx();
42
+ const adder = new FlexiAddController(provider, addWidgetFn);
43
+ return {
44
+ adder,
45
+ onpointerdown: (event) => adder.onpointerdown(event)
46
+ };
47
+ }
48
+ export function flexidelete() {
49
+ const provider = getInternalFlexiboardCtx();
50
+ return {
51
+ onpointerenter: () => provider.onenterdeleter(),
52
+ onpointerleave: () => provider.onleavedeleter()
53
+ };
54
+ }
@@ -0,0 +1,51 @@
1
+ import type { HoveredTargetEvent, WidgetGrabAction, WidgetResizeAction, WidgetGrabbedEvent, WidgetStartResizeEvent } from "./types.js";
2
+ import type { InternalFlexiTargetController, FlexiTargetDefaults, FlexiTargetController } from "./target.svelte.js";
3
+ import type { FlexiWidgetController, FlexiWidgetDefaults } from "./widget.svelte.js";
4
+ import type { FlexiBoardProps } from "../components/flexi-board.svelte";
5
+ export type FlexiBoardConfiguration = {
6
+ widgetDefaults?: FlexiWidgetDefaults;
7
+ targetDefaults?: FlexiTargetDefaults;
8
+ };
9
+ export interface FlexiBoardController {
10
+ /**
11
+ * The reactive styling to apply to the board's root element.
12
+ */
13
+ style: string;
14
+ /**
15
+ * The reactive DOM reference to the board's root element.
16
+ */
17
+ ref: HTMLElement | null;
18
+ /**
19
+ * Moves an existing widget from one target to another.
20
+ * @param widget The widget to move.
21
+ * @param from The target to move the widget from.
22
+ * @param to The target to move the widget to.
23
+ */
24
+ moveWidget(widget: FlexiWidgetController, from: FlexiTargetController | undefined, to: FlexiTargetController): void;
25
+ }
26
+ export declare class InternalFlexiBoardController implements FlexiBoardController {
27
+ #private;
28
+ config?: FlexiBoardConfiguration;
29
+ constructor(props: FlexiBoardProps);
30
+ style: string;
31
+ get ref(): HTMLElement | null;
32
+ set ref(ref: HTMLElement | null);
33
+ addTarget(target: InternalFlexiTargetController, key?: string): string;
34
+ onpointerentertarget(event: HoveredTargetEvent): void;
35
+ onpointerleavetarget(event: HoveredTargetEvent): void;
36
+ onenterdeleter(): void;
37
+ onleavedeleter(): void;
38
+ onwidgetgrabbed(event: WidgetGrabbedEvent): WidgetGrabAction | null;
39
+ onwidgetstartresize(event: WidgetStartResizeEvent): WidgetResizeAction | null;
40
+ stopScroll(event: TouchEvent): void;
41
+ handleWidgetRelease(): void;
42
+ oninitialloadcomplete(): void;
43
+ /**
44
+ * Moves a widget from one target to another.
45
+ * @param widget The widget to move.
46
+ * @param from The target to move the widget from.
47
+ * @param to The target to move the widget to.
48
+ */
49
+ moveWidget(widget: FlexiWidgetController, from: FlexiTargetController | undefined, to: FlexiTargetController): boolean;
50
+ }
51
+ export declare function flexiboard(props: FlexiBoardProps): FlexiBoardController;
@@ -0,0 +1,290 @@
1
+ import { getContext, setContext } from "svelte";
2
+ import { PointerPositionWatcher } from "./utils.svelte.js";
3
+ export class InternalFlexiBoardController {
4
+ #currentWidgetAction = $state(null);
5
+ #targets = new Map();
6
+ #hoveredTarget = $state(null);
7
+ #hoveredOverDeleter = $state(false);
8
+ #ref = $state({ value: null });
9
+ #positionWatcher = new PointerPositionWatcher(this.#ref);
10
+ #rawProps = $state(undefined);
11
+ config = $derived(this.#rawProps?.config);
12
+ #nextTargetIndex = 0;
13
+ #storedLoadLayout = null;
14
+ #ready = false;
15
+ constructor(props) {
16
+ // Track the props proxy so our config reactively updates.
17
+ this.#rawProps = props;
18
+ const onpointerup = this.#onpointerup.bind(this);
19
+ $effect(() => {
20
+ window.addEventListener('pointerup', onpointerup);
21
+ return () => {
22
+ window.removeEventListener('pointerup', onpointerup);
23
+ };
24
+ });
25
+ }
26
+ style = $derived.by(() => {
27
+ if (!this.#currentWidgetAction) {
28
+ return 'position: relative;';
29
+ }
30
+ return `position: relative; overflow: hidden;`;
31
+ });
32
+ get ref() {
33
+ return this.#ref.value;
34
+ }
35
+ set ref(ref) {
36
+ this.#ref.value = ref;
37
+ }
38
+ addTarget(target, key) {
39
+ // If they didn't bring their own key, assign one.
40
+ key ??= this.#nextTargetKey();
41
+ if (this.#targets.has(key)) {
42
+ throw new Error(`A duplicate key, '${target.key}' was used during the instantiation of a FlexiTarget. Ensure that all FlexiTarget keys are unique.`);
43
+ }
44
+ this.#targets.set(key, target);
45
+ return key;
46
+ }
47
+ onpointerentertarget(event) {
48
+ this.#hoveredTarget = event.target;
49
+ // If a widget is currently being grabbed, propagate a grabbed widget over event to this target.
50
+ const currentAction = this.#currentWidgetAction;
51
+ if (currentAction?.action === 'grab') {
52
+ event.target.ongrabbedwidgetover({
53
+ widget: currentAction.widget
54
+ });
55
+ }
56
+ }
57
+ onpointerleavetarget(event) {
58
+ // Failsafe in case another target is already registered as hovered.
59
+ if (this.#hoveredTarget === event.target) {
60
+ this.#hoveredTarget = null;
61
+ }
62
+ // If a widget is currently being grabbed, propagate a grabbed widget over event to this target.
63
+ const currentAction = this.#currentWidgetAction;
64
+ if (currentAction?.action === 'grab') {
65
+ event.target.ongrabbedwidgetleave();
66
+ }
67
+ // If it's resize, then we don't care that the pointer has left the target.
68
+ }
69
+ onenterdeleter() {
70
+ this.#hoveredOverDeleter = true;
71
+ }
72
+ onleavedeleter() {
73
+ this.#hoveredOverDeleter = false;
74
+ }
75
+ onwidgetgrabbed(event) {
76
+ if (this.#currentWidgetAction) {
77
+ return null;
78
+ }
79
+ const action = {
80
+ action: 'grab',
81
+ target: event.target,
82
+ widget: event.widget,
83
+ adder: event.adder,
84
+ offsetX: event.xOffset,
85
+ offsetY: event.yOffset,
86
+ capturedHeightPx: event.capturedHeight,
87
+ capturedWidthPx: event.capturedWidth,
88
+ positionWatcher: this.#positionWatcher
89
+ };
90
+ this.#currentWidgetAction = action;
91
+ this.#lockViewport();
92
+ // Only matters if the event source is a target, which isn't the case when the widget is being dragged into the board.
93
+ if (event.target) {
94
+ event.target.ongrabbedwidgetover({
95
+ widget: event.widget
96
+ });
97
+ }
98
+ return action;
99
+ }
100
+ onwidgetstartresize(event) {
101
+ if (this.#currentWidgetAction) {
102
+ return null;
103
+ }
104
+ const providerRef = this.ref;
105
+ if (!providerRef) {
106
+ throw new Error("Provider ref is not set");
107
+ }
108
+ const providerRect = providerRef.getBoundingClientRect();
109
+ const action = {
110
+ action: 'resize',
111
+ target: event.target,
112
+ widget: event.widget,
113
+ offsetX: event.xOffset - providerRect.left,
114
+ offsetY: event.yOffset - providerRect.top,
115
+ left: event.left - providerRect.left,
116
+ top: event.top - providerRect.top,
117
+ heightPx: event.heightPx,
118
+ widthPx: event.widthPx,
119
+ initialHeightUnits: event.widget.height,
120
+ initialWidthUnits: event.widget.width,
121
+ positionWatcher: this.#positionWatcher
122
+ };
123
+ this.#currentWidgetAction = action;
124
+ this.#lockViewport();
125
+ return action;
126
+ }
127
+ #lockViewport() {
128
+ document.documentElement.style.overscrollBehaviorY = 'contain';
129
+ document.documentElement.style.overflow = 'hidden';
130
+ document.documentElement.style.touchAction = 'none';
131
+ this.stopScroll = this.stopScroll.bind(this);
132
+ document.addEventListener('touchmove', this.stopScroll, { passive: false });
133
+ }
134
+ #unlockViewport() {
135
+ document.documentElement.style.overscrollBehaviorY = 'auto';
136
+ document.documentElement.style.overflow = 'auto';
137
+ document.documentElement.style.touchAction = 'auto';
138
+ document.removeEventListener('touchmove', this.stopScroll);
139
+ }
140
+ stopScroll(event) {
141
+ // If a scroll is in progress, there's nothing we can do to stop it and so we'll just release the widget.
142
+ if (!event.cancelable) {
143
+ this.handleWidgetRelease();
144
+ return;
145
+ }
146
+ event.preventDefault();
147
+ }
148
+ #onpointerup(event) {
149
+ if (!this.#currentWidgetAction) {
150
+ return;
151
+ }
152
+ this.handleWidgetRelease();
153
+ }
154
+ handleWidgetRelease() {
155
+ this.#unlockViewport();
156
+ const currentAction = this.#currentWidgetAction;
157
+ switch (currentAction.action) {
158
+ case 'grab':
159
+ this.#handleGrabbedWidgetRelease(currentAction);
160
+ break;
161
+ case 'resize':
162
+ this.#handleResizingWidgetRelease(currentAction);
163
+ break;
164
+ }
165
+ }
166
+ oninitialloadcomplete() {
167
+ this.#ready = true;
168
+ // if(this.#storedLoadLayout) {
169
+ // this.importLayout(this.#storedLoadLayout);
170
+ // }
171
+ }
172
+ // NEXT: Add import/export layout.
173
+ // importLayout(layout: FlexiSavedLayout) {
174
+ // // The board isn't ready to import widgets yet, so we'll store the layout and import it later.
175
+ // if(!this.#ready) {
176
+ // this.#storedLoadLayout = layout;
177
+ // return;
178
+ // }
179
+ // // Good to go - import the widgets into their respective targets.
180
+ // this.#targets.forEach(target => {
181
+ // target.importLayout(layout[target.key]);
182
+ // });
183
+ // }
184
+ // exportLayout(): FlexiSavedLayout {
185
+ // const result: FlexiSavedLayout = {};
186
+ // // Grab the current layout of each target.
187
+ // this.#targets.forEach(target => {
188
+ // result[target.key] = target.exportLayout();
189
+ // });
190
+ // return result;
191
+ // }
192
+ #handleGrabbedWidgetRelease(action) {
193
+ // If a deleter is hovered, then we'll delete the widget.
194
+ if (this.#hoveredOverDeleter) {
195
+ action.widget.delete();
196
+ this.#currentWidgetAction = null;
197
+ return;
198
+ }
199
+ // If no target is hovered, then just release the widget.
200
+ if (!this.#hoveredTarget) {
201
+ this.#releaseCurrentWidgetAction();
202
+ return;
203
+ }
204
+ if (action.adder) {
205
+ action.adder.onstopwidgetdragin();
206
+ }
207
+ const shouldDrop = this.moveWidget(action.widget, action.target, this.#hoveredTarget);
208
+ if (!shouldDrop) {
209
+ this.#releaseCurrentWidgetAction();
210
+ return;
211
+ }
212
+ this.#releaseCurrentWidgetAction(true);
213
+ }
214
+ #handleResizingWidgetRelease(action) {
215
+ action.target.tryDropWidget(action.widget);
216
+ this.#releaseCurrentWidgetAction();
217
+ }
218
+ #releaseCurrentWidgetAction(actionSucceeded = false) {
219
+ const currentWidgetAction = this.#currentWidgetAction;
220
+ if (!currentWidgetAction) {
221
+ return;
222
+ }
223
+ const widget = currentWidgetAction.widget;
224
+ // If the widget is still being grabbed, we'll need to release it.
225
+ if (widget.currentAction) {
226
+ widget.currentAction = null;
227
+ }
228
+ // If this widget is new from an adder, then it needs to remove it regardless of the outcome.
229
+ if (currentWidgetAction.action == "grab" && currentWidgetAction.adder) {
230
+ currentWidgetAction.widget.adder = undefined;
231
+ currentWidgetAction.adder.onstopwidgetdragin();
232
+ }
233
+ // The widget wasn't placed successfully, so go back to the pre-grab state on the target.
234
+ if (!actionSucceeded && currentWidgetAction.target) {
235
+ currentWidgetAction.target.restorePreGrabSnapshot();
236
+ }
237
+ this.#currentWidgetAction = null;
238
+ }
239
+ /**
240
+ * Moves a widget from one target to another.
241
+ * @param widget The widget to move.
242
+ * @param from The target to move the widget from.
243
+ * @param to The target to move the widget to.
244
+ */
245
+ moveWidget(widget, from, to) {
246
+ let defaultPrevented = false;
247
+ const dropSuccessful = to.tryDropWidget(widget);
248
+ if (defaultPrevented) {
249
+ return false;
250
+ }
251
+ // If the widget is new, it has no from target.
252
+ if (from) {
253
+ from.widgets.delete(widget);
254
+ from.forgetPreGrabSnapshot();
255
+ }
256
+ widget.target = to;
257
+ to.widgets.add(widget);
258
+ return true;
259
+ }
260
+ #nextTargetKey() {
261
+ return `target-${this.#nextTargetIndex++}`;
262
+ }
263
+ }
264
+ const contextKey = Symbol('flexiboard');
265
+ export function flexiboard(props) {
266
+ const board = new InternalFlexiBoardController(props);
267
+ setContext(contextKey, board);
268
+ return board;
269
+ }
270
+ /**
271
+ * Gets the current {@link InternalFlexiBoardController} instance, if any. Throws an error if no board is found.
272
+ * @internal
273
+ * @returns An {@link InternalFlexiBoardController} instance.
274
+ */
275
+ export function getInternalFlexiboardCtx() {
276
+ const board = getContext(contextKey);
277
+ // No provider to attach to.
278
+ if (!board) {
279
+ throw new Error("Cannot get FlexiBoard context outside of a registered board. Ensure that flexiboard() (or <FlexiProvider>) is called.");
280
+ }
281
+ return board;
282
+ }
283
+ /**
284
+ * Gets the current {@link FlexiBoard} instance, if any. Throws an error if no board is found.
285
+ * @internal
286
+ * @returns A {@link FlexiBoard} instance.
287
+ */
288
+ export function getFlexiboardCtx() {
289
+ return getInternalFlexiboardCtx();
290
+ }
@@ -0,0 +1,179 @@
1
+ import { InternalFlexiBoardController } from "./provider.svelte.js";
2
+ import { type FlexiWidgetConfiguration, type FlexiWidgetDefaults, FlexiWidgetController } from "./widget.svelte.js";
3
+ import type { GrabbedWidgetMouseEvent, MouseGridCellMoveEvent, WidgetAction, WidgetGrabAction, WidgetGrabbedParams, WidgetStartResizeParams } from "./types.js";
4
+ import { SvelteSet } from "svelte/reactivity";
5
+ import { FlexiGrid, type FlowTargetLayout, type FreeFormTargetLayout } from "./grid.svelte.js";
6
+ type TargetSizingFn = ({ target, grid }: {
7
+ target: FlexiTargetController;
8
+ grid: FlexiGrid;
9
+ }) => string;
10
+ export type TargetSizing = TargetSizingFn | string;
11
+ export type FlexiTargetDefaults = {
12
+ /**
13
+ * The base number of columns for the target's grid. Defaults to 1.
14
+ */
15
+ baseColumns?: number | null;
16
+ /**
17
+ * The base number of rows for the target's grid. Defaults to 1.
18
+ */
19
+ baseRows?: number | null;
20
+ /**
21
+ * Allows the specifying of the value inside the `repeat()` function of the `grid-template-rows` CSS property for the target.
22
+ */
23
+ rowSizing?: TargetSizing;
24
+ /**
25
+ * Allows the specifying of the value inside the `repeat()` function of the `grid-template-columns` CSS property for the target.
26
+ */
27
+ columnSizing?: TargetSizing;
28
+ /**
29
+ * The layout algorithm and parameters to use for the target grid.
30
+ */
31
+ layout?: TargetLayout;
32
+ };
33
+ export type FlexiTargetPartialConfiguration = FlexiTargetDefaults & {
34
+ widgetDefaults?: FlexiWidgetDefaults;
35
+ };
36
+ export type FlexiTargetConfiguration = Required<FlexiTargetDefaults> & {
37
+ widgetDefaults?: FlexiWidgetDefaults;
38
+ };
39
+ export type TargetLayout = FlowTargetLayout | FreeFormTargetLayout;
40
+ export interface FlexiTargetController {
41
+ /**
42
+ * The widgets currently in this target.
43
+ */
44
+ widgets: SvelteSet<FlexiWidgetController>;
45
+ /**
46
+ * The reactive configuration of the target.
47
+ */
48
+ config: FlexiTargetConfiguration;
49
+ /**
50
+ * The reactive default widget configuration passed through from the provider, if it exists.
51
+ */
52
+ providerWidgetDefaults?: FlexiWidgetDefaults;
53
+ /**
54
+ * Whether the target is prepared and ready to render widgets.
55
+ */
56
+ get prepared(): boolean;
57
+ /**
58
+ * Creates a new widget under this target.
59
+ * @param config The configuration of the widget to create.
60
+ * @returns The newly created widget if it could be placed, or undefined if not.
61
+ */
62
+ createWidget(config: FlexiWidgetConfiguration): FlexiWidgetController | undefined;
63
+ /**
64
+ * Deletes the given widget from this target, if it exists.
65
+ * @returns Whether the widget was deleted.
66
+ */
67
+ deleteWidget(widget: FlexiWidgetController): boolean;
68
+ /**
69
+ * Restores the target to its pre-grab state.
70
+ * @remarks This is not intended for external use.
71
+ */
72
+ restorePreGrabSnapshot(): void;
73
+ /**
74
+ * Forgets the pre-grab state of the target.
75
+ * @remarks This is not intended for external use.
76
+ */
77
+ forgetPreGrabSnapshot(): void;
78
+ /**
79
+ * Attempts to drop a widget into this target.
80
+ * @param widget The widget to drop.
81
+ * @returns Whether the widget was dropped.
82
+ */
83
+ tryDropWidget(widget: FlexiWidgetController): boolean;
84
+ /**
85
+ * Grabs a widget.
86
+ * @param params The parameters for the grab action.
87
+ * @returns The action that was started, or null if the action couldn't be started.
88
+ */
89
+ grabWidget(params: WidgetGrabbedParams): WidgetAction | null;
90
+ /**
91
+ * Starts resizing a widget.
92
+ * @param params The parameters for the resize action.
93
+ * @returns The action that was started, or null if the action couldn't be started.
94
+ */
95
+ startResizeWidget(params: WidgetStartResizeParams): WidgetAction | null;
96
+ }
97
+ export declare class InternalFlexiTargetController implements FlexiTargetController {
98
+ #private;
99
+ widgets: SvelteSet<FlexiWidgetController>;
100
+ provider: InternalFlexiBoardController;
101
+ providerWidgetDefaults?: FlexiWidgetDefaults;
102
+ key: string;
103
+ config: FlexiTargetConfiguration;
104
+ constructor(provider: InternalFlexiBoardController, config?: FlexiTargetPartialConfiguration, key?: string);
105
+ createGrid(): FlexiGrid;
106
+ createWidget(config: FlexiWidgetConfiguration): FlexiWidgetController | undefined;
107
+ /**
108
+ * Deletes the given widget from this target, if it exists.
109
+ * @returns Whether the widget was deleted.
110
+ */
111
+ deleteWidget(widget: FlexiWidgetController): boolean;
112
+ /**
113
+ * Imports a layout of widgets into this target, replacing any existing widgets.
114
+ * @param layout The layout to import.
115
+ */
116
+ importLayout(layout: FlexiWidgetConfiguration[]): void;
117
+ /**
118
+ * Exports the current layout of widgets from this target.
119
+ * @returns The layout of widgets.
120
+ */
121
+ exportLayout(): FlexiWidgetConfiguration[];
122
+ onpointerenter(): void;
123
+ onpointerleave(): void;
124
+ grabWidget(params: WidgetGrabbedParams): WidgetGrabAction | null;
125
+ restorePreGrabSnapshot(): void;
126
+ forgetPreGrabSnapshot(): void;
127
+ startResizeWidget(params: WidgetStartResizeParams): import("./types.js").WidgetResizeAction | null;
128
+ tryDropWidget(widget: FlexiWidgetController): boolean;
129
+ onmousegridcellmove(event: MouseGridCellMoveEvent): void;
130
+ ongrabbedwidgetover(event: GrabbedWidgetMouseEvent): void;
131
+ ongrabbedwidgetleave(): void;
132
+ oninitialloadcomplete(): void;
133
+ /**
134
+ * Whether the target is currently being hovered over by the mouse.
135
+ */
136
+ get hovered(): boolean;
137
+ set hovered(value: boolean);
138
+ /**
139
+ * When set, this indicates that a widget is currently being hovered over this target.
140
+ */
141
+ get actionWidget(): FlexiTargetActionWidget | null;
142
+ set actionWidget(value: FlexiTargetActionWidget | null);
143
+ /**
144
+ * Whether the target is prepared and ready to render widgets.
145
+ */
146
+ get prepared(): boolean;
147
+ /**
148
+ * The number of columns currently being used in the target grid.
149
+ * This value is readonly.
150
+ */
151
+ get columns(): number | undefined;
152
+ /**
153
+ * The number of rows currently being used in the target grid.
154
+ * This value is readonly.
155
+ */
156
+ get rows(): number | undefined;
157
+ get grid(): FlexiGrid;
158
+ get dropzoneWidget(): FlexiWidgetController | null;
159
+ set dropzoneWidget(value: FlexiWidgetController | null);
160
+ }
161
+ type FlexiTargetActionWidget = {
162
+ action: WidgetAction["action"];
163
+ widget: FlexiWidgetController;
164
+ };
165
+ /**
166
+ * Creates a new {@link FlexiTargetController} instance in the context of the current FlexiBoard.
167
+ * @returns A {@link FlexiTargetController} instance.
168
+ */
169
+ export declare function flexitarget(config?: FlexiTargetPartialConfiguration, key?: string): {
170
+ onpointerenter: () => void;
171
+ onpointerleave: () => void;
172
+ target: FlexiTargetController;
173
+ };
174
+ /**
175
+ * Gets the current {@link FlexiTargetController} instance, if any. Throws an error if no target is found.
176
+ * @returns A {@link FlexiTargetController} instance.
177
+ */
178
+ export declare function getFlexitargetCtx(): FlexiTargetController;
179
+ export {};