svelte-flexiboards 0.3.2-alpha.5 → 0.3.2

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.
@@ -32,10 +32,13 @@
32
32
  snippet: children
33
33
  });
34
34
 
35
- flexiwidget(config);
35
+ // Callback so that we still fulfil these props.
36
+ function onWidgetCreated(widget: FlexiWidgetController) {
37
+ controller = widget;
38
+ onfirstcreate?.(widget);
39
+ }
36
40
 
37
- // controller = widget;
38
- // onfirstcreate?.(widget);
41
+ flexiwidget(config, onWidgetCreated);
39
42
 
40
43
  // let derivedClassName = $derived.by(() => {
41
44
  // if (typeof widget.className === 'function') {
@@ -16,7 +16,7 @@ export declare class InternalFlexiTargetController implements FlexiTargetControl
16
16
  constructor(provider: InternalFlexiBoardController, key: string, config?: FlexiTargetPartialConfiguration);
17
17
  createGrid(): FlexiGrid;
18
18
  createWidget(config: FlexiWidgetConfiguration): InternalFlexiWidgetController | undefined;
19
- registerWidget(config: FlexiWidgetConfiguration): void;
19
+ registerWidget(config: FlexiWidgetConfiguration, onCreated?: (widget: FlexiWidgetController) => void): void;
20
20
  onWidgetDelete(event: WidgetEvent): void;
21
21
  /**
22
22
  * Deletes the given widget from this target, if it exists.
@@ -134,8 +134,8 @@ export class InternalFlexiTargetController {
134
134
  }
135
135
  return widget;
136
136
  }
137
- registerWidget(config) {
138
- this.#initialWidgetRegistrations.push(config);
137
+ registerWidget(config, onCreated) {
138
+ this.#initialWidgetRegistrations.push({ config, onCreated });
139
139
  }
140
140
  onWidgetDelete(event) {
141
141
  if (event.target != this) {
@@ -367,8 +367,11 @@ export class InternalFlexiTargetController {
367
367
  this.#removeDropzoneWidget();
368
368
  }
369
369
  oninitialloadcomplete() {
370
- for (const config of this.#initialWidgetRegistrations) {
371
- this.createWidget(config);
370
+ for (const registration of this.#initialWidgetRegistrations) {
371
+ const widget = this.createWidget(registration.config);
372
+ if (widget && registration.onCreated) {
373
+ registration.onCreated(widget);
374
+ }
372
375
  }
373
376
  this.#state.prepared = true;
374
377
  }
@@ -1,7 +1,7 @@
1
1
  import type { FlexiWidgetChildrenSnippet, FlexiWidgetChildrenSnippetParameters, FlexiWidgetConfiguration, FlexiWidgetTransitionConfiguration, FlexiWidgetTransitionTypeConfiguration, FlexiWidgetTriggerConfiguration } from './types.js';
2
2
  import type { FlexiWidgetController } from './base.svelte.js';
3
3
  import type { InternalFlexiWidgetController } from './controller.svelte.js';
4
- export declare function flexiwidget(config: FlexiWidgetConfiguration): void;
4
+ export declare function flexiwidget(config: FlexiWidgetConfiguration, onWidgetCreated?: (widget: FlexiWidgetController) => void): void;
5
5
  export declare function renderedflexiwidget(widget: InternalFlexiWidgetController): {
6
6
  onpointerdown: (event: PointerEvent) => void;
7
7
  onkeydown: (event: KeyboardEvent) => void;
@@ -3,12 +3,12 @@ import { getInternalFlexitargetCtx } from '../target/index.js';
3
3
  import { widgetEvents, widgetGrabberEvents, widgetResizerEvents } from './events.js';
4
4
  import { dragInOnceMounted, hasInternalFlexiaddCtx } from '../misc/adder.svelte.js';
5
5
  const contextKey = Symbol('flexiwidget');
6
- export function flexiwidget(config) {
6
+ export function flexiwidget(config, onWidgetCreated) {
7
7
  const target = getInternalFlexitargetCtx();
8
8
  if (!target) {
9
9
  throw new Error('A FlexiWidget was instantiated outside of a FlexiTarget context. Ensure that flexiwidget() (or <FlexiWidget>) is called within a <FlexiTarget> component.');
10
10
  }
11
- target.registerWidget(config);
11
+ target.registerWidget(config, onWidgetCreated);
12
12
  // const widget = target.registerWidget(config);
13
13
  // if (!widget) {
14
14
  // throw new Error(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "svelte-flexiboards",
3
3
  "licence": "MIT",
4
- "version": "0.3.2-alpha.5",
4
+ "version": "0.3.2",
5
5
  "description": "The headless drag-and-drop toolkit for Svelte.",
6
6
  "scripts": {
7
7
  "dev": "pnpm watch",
@@ -35,7 +35,7 @@
35
35
  }
36
36
  },
37
37
  "peerDependencies": {
38
- "svelte": "^5.16.0"
38
+ "svelte": "^5.0.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@sveltejs/adapter-auto": "^3.0.0",