svelte-flexiboards 0.3.2-alpha.4 → 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.
- package/README.md +15 -15
- package/dist/components/flexi-add.svelte +87 -87
- package/dist/components/flexi-announcer.svelte +24 -24
- package/dist/components/flexi-board.svelte +58 -58
- package/dist/components/flexi-delete.svelte +67 -67
- package/dist/components/flexi-grab.svelte +28 -28
- package/dist/components/flexi-grid.svelte +27 -27
- package/dist/components/flexi-layout-loader.svelte +10 -10
- package/dist/components/flexi-portal.svelte +14 -14
- package/dist/components/flexi-resize.svelte +30 -30
- package/dist/components/flexi-target-loader.svelte +14 -10
- package/dist/components/flexi-target.svelte +115 -115
- package/dist/components/flexi-widget.svelte +81 -78
- package/dist/components/rendered-flexi-widget.svelte +64 -64
- package/dist/components/rendered-flexi-widget.svelte.d.ts +2 -2
- package/dist/components/widget-transition-placeholder.svelte +12 -12
- package/dist/system/grid/base.svelte.d.ts +3 -2
- package/dist/system/grid/free-grid.svelte.d.ts +5 -5
- package/dist/system/misc/adder.svelte.d.ts +5 -5
- package/dist/system/misc/adder.svelte.js +2 -2
- package/dist/system/shared/utils.svelte.js +10 -10
- package/dist/system/target/controller.svelte.d.ts +9 -7
- package/dist/system/target/controller.svelte.js +30 -24
- package/dist/system/target/types.d.ts +2 -2
- package/dist/system/types.d.ts +10 -9
- package/dist/system/widget/base.svelte.d.ts +55 -76
- package/dist/system/widget/base.svelte.js +77 -321
- package/dist/system/widget/controller.svelte.d.ts +60 -0
- package/dist/system/widget/controller.svelte.js +315 -0
- package/dist/system/widget/events.d.ts +4 -4
- package/dist/system/widget/index.d.ts +7 -8
- package/dist/system/widget/index.js +12 -10
- package/dist/system/widget/triggers.svelte.d.ts +2 -2
- package/dist/system/widget/types.d.ts +0 -4
- package/package.json +62 -62
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# Flexiboards
|
|
2
|
-
|
|
3
|
-
Headless, reactive drag-and-drop components for Svelte. [https://svelte-flexiboards.vercel.app](https://svelte-flexiboards.vercel.app/)
|
|
4
|
-
|
|
5
|
-
This version of Flexiboards is currently in an early preview stage, with development ongoing. If you encounter any issues, please report them on the [GitHub issues page](https://github.com/Blakintosh/svelte-flexiboards/issues).
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
npm i svelte-flexiboards
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Licence
|
|
14
|
-
|
|
15
|
-
Flexiboards is open-source software licenced under the MIT licence. Please see [LICENSE.md](https://github.com/Blakintosh/svelte-flexiboards/blob/main/LICENSE.md) for more information.
|
|
1
|
+
# Flexiboards
|
|
2
|
+
|
|
3
|
+
Headless, reactive drag-and-drop components for Svelte. [https://svelte-flexiboards.vercel.app](https://svelte-flexiboards.vercel.app/)
|
|
4
|
+
|
|
5
|
+
This version of Flexiboards is currently in an early preview stage, with development ongoing. If you encounter any issues, please report them on the [GitHub issues page](https://github.com/Blakintosh/svelte-flexiboards/issues).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm i svelte-flexiboards
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Licence
|
|
14
|
+
|
|
15
|
+
Flexiboards is open-source software licenced under the MIT licence. Please see [LICENSE.md](https://github.com/Blakintosh/svelte-flexiboards/blob/main/LICENSE.md) for more information.
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
type FlexiAddController,
|
|
4
|
-
flexiadd,
|
|
5
|
-
type FlexiAddClasses,
|
|
6
|
-
type FlexiAddWidgetFn
|
|
7
|
-
} from '../system/misc/adder.svelte.js';
|
|
8
|
-
import { onDestroy, type Snippet } from 'svelte';
|
|
9
|
-
import type { FlexiCommonProps } from '../system/types.js';
|
|
10
|
-
import RenderedFlexiWidget from './rendered-flexi-widget.svelte';
|
|
11
|
-
import { assistiveTextStyle, generateUniqueId } from '../system/shared/utils.svelte.js';
|
|
12
|
-
|
|
13
|
-
/** @deprecated FlexiAdd's children props are now redundant and will be removed in v0.4. */
|
|
14
|
-
type FlexiAddChildrenProps = {
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated This has been replaced with internal pointer management and is redundant. This event will be removed in v0.4.
|
|
17
|
-
*/
|
|
18
|
-
onpointerdown: (event: PointerEvent) => void;
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated This has been moved to the internal button so is now redundant. It will be removed in v0.4.
|
|
21
|
-
*/
|
|
22
|
-
style: string;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type FlexiAddProps = FlexiCommonProps<FlexiAddController> & {
|
|
26
|
-
class?: FlexiAddClasses;
|
|
27
|
-
children?: Snippet<[{ adder: FlexiAddController; props: FlexiAddChildrenProps }]>;
|
|
28
|
-
addWidget: FlexiAddWidgetFn;
|
|
29
|
-
};
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<script lang="ts">
|
|
33
|
-
let {
|
|
34
|
-
children,
|
|
35
|
-
addWidget,
|
|
36
|
-
controller = $bindable(),
|
|
37
|
-
onfirstcreate,
|
|
38
|
-
class: className
|
|
39
|
-
}: FlexiAddProps = $props();
|
|
40
|
-
|
|
41
|
-
const { adder, onpointerdown, onkeydown } = flexiadd(addWidget);
|
|
42
|
-
controller = adder;
|
|
43
|
-
onfirstcreate?.(adder);
|
|
44
|
-
|
|
45
|
-
const dummyOnpointerdown = (event: PointerEvent) => {};
|
|
46
|
-
|
|
47
|
-
let derivedClassName = $derived.by(() => {
|
|
48
|
-
if (!adder) {
|
|
49
|
-
return '';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (typeof className === 'function') {
|
|
53
|
-
return className(adder);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return className;
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
let assistiveTextId = generateUniqueId();
|
|
60
|
-
|
|
61
|
-
// Cleanup adder subscriptions when component is destroyed
|
|
62
|
-
onDestroy(() => {
|
|
63
|
-
adder.destroy();
|
|
64
|
-
});
|
|
65
|
-
</script>
|
|
66
|
-
|
|
67
|
-
<!-- TODO: will probably need a breaking change, because we need a ref to get the start widget position -->
|
|
68
|
-
<button
|
|
69
|
-
class={derivedClassName}
|
|
70
|
-
bind:this={adder.ref}
|
|
71
|
-
aria-describedby={assistiveTextId}
|
|
72
|
-
style={'touch-action: none;'}
|
|
73
|
-
{onpointerdown}
|
|
74
|
-
{onkeydown}
|
|
75
|
-
>
|
|
76
|
-
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
77
|
-
Press Enter to drag a new widget into this board.
|
|
78
|
-
</span>
|
|
79
|
-
{@render children?.({ adder, props: { style: '', onpointerdown: dummyOnpointerdown } })}
|
|
80
|
-
</button>
|
|
81
|
-
|
|
82
|
-
<div style="display: none;">
|
|
83
|
-
<!-- Mimics the behaviour of a FlexiTarget, as we need to render the widget so that we can "drag it in" from -->
|
|
84
|
-
{#if adder.newWidget}
|
|
85
|
-
<RenderedFlexiWidget widget={adder.newWidget} />
|
|
86
|
-
{/if}
|
|
87
|
-
</div>
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
type FlexiAddController,
|
|
4
|
+
flexiadd,
|
|
5
|
+
type FlexiAddClasses,
|
|
6
|
+
type FlexiAddWidgetFn
|
|
7
|
+
} from '../system/misc/adder.svelte.js';
|
|
8
|
+
import { onDestroy, type Snippet } from 'svelte';
|
|
9
|
+
import type { FlexiCommonProps } from '../system/types.js';
|
|
10
|
+
import RenderedFlexiWidget from './rendered-flexi-widget.svelte';
|
|
11
|
+
import { assistiveTextStyle, generateUniqueId } from '../system/shared/utils.svelte.js';
|
|
12
|
+
|
|
13
|
+
/** @deprecated FlexiAdd's children props are now redundant and will be removed in v0.4. */
|
|
14
|
+
type FlexiAddChildrenProps = {
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated This has been replaced with internal pointer management and is redundant. This event will be removed in v0.4.
|
|
17
|
+
*/
|
|
18
|
+
onpointerdown: (event: PointerEvent) => void;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated This has been moved to the internal button so is now redundant. It will be removed in v0.4.
|
|
21
|
+
*/
|
|
22
|
+
style: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type FlexiAddProps = FlexiCommonProps<FlexiAddController> & {
|
|
26
|
+
class?: FlexiAddClasses;
|
|
27
|
+
children?: Snippet<[{ adder: FlexiAddController; props: FlexiAddChildrenProps }]>;
|
|
28
|
+
addWidget: FlexiAddWidgetFn;
|
|
29
|
+
};
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
let {
|
|
34
|
+
children,
|
|
35
|
+
addWidget,
|
|
36
|
+
controller = $bindable(),
|
|
37
|
+
onfirstcreate,
|
|
38
|
+
class: className
|
|
39
|
+
}: FlexiAddProps = $props();
|
|
40
|
+
|
|
41
|
+
const { adder, onpointerdown, onkeydown } = flexiadd(addWidget);
|
|
42
|
+
controller = adder;
|
|
43
|
+
onfirstcreate?.(adder);
|
|
44
|
+
|
|
45
|
+
const dummyOnpointerdown = (event: PointerEvent) => {};
|
|
46
|
+
|
|
47
|
+
let derivedClassName = $derived.by(() => {
|
|
48
|
+
if (!adder) {
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (typeof className === 'function') {
|
|
53
|
+
return className(adder);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return className;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
let assistiveTextId = generateUniqueId();
|
|
60
|
+
|
|
61
|
+
// Cleanup adder subscriptions when component is destroyed
|
|
62
|
+
onDestroy(() => {
|
|
63
|
+
adder.destroy();
|
|
64
|
+
});
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<!-- TODO: will probably need a breaking change, because we need a ref to get the start widget position -->
|
|
68
|
+
<button
|
|
69
|
+
class={derivedClassName}
|
|
70
|
+
bind:this={adder.ref}
|
|
71
|
+
aria-describedby={assistiveTextId}
|
|
72
|
+
style={'touch-action: none;'}
|
|
73
|
+
{onpointerdown}
|
|
74
|
+
{onkeydown}
|
|
75
|
+
>
|
|
76
|
+
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
77
|
+
Press Enter to drag a new widget into this board.
|
|
78
|
+
</span>
|
|
79
|
+
{@render children?.({ adder, props: { style: '', onpointerdown: dummyOnpointerdown } })}
|
|
80
|
+
</button>
|
|
81
|
+
|
|
82
|
+
<div style="display: none;">
|
|
83
|
+
<!-- Mimics the behaviour of a FlexiTarget, as we need to render the widget so that we can "drag it in" from -->
|
|
84
|
+
{#if adder.newWidget}
|
|
85
|
+
<RenderedFlexiWidget widget={adder.newWidget} />
|
|
86
|
+
{/if}
|
|
87
|
+
</div>
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { flexiannouncer } from '../system/announcer.svelte.js';
|
|
3
|
-
import type { InternalFlexiBoardController } from '../system/board/controller.svelte.js';
|
|
4
|
-
import { assistiveTextStyle } from '../system/shared/utils.svelte.js';
|
|
5
|
-
|
|
6
|
-
type FlexiAnnouncerProps = {
|
|
7
|
-
provider: InternalFlexiBoardController;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
let { provider }: FlexiAnnouncerProps = $props();
|
|
11
|
-
|
|
12
|
-
const controller = flexiannouncer(provider);
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<div
|
|
16
|
-
role="region"
|
|
17
|
-
aria-live={controller.politeness}
|
|
18
|
-
aria-label="Drag-and-drop announcer"
|
|
19
|
-
aria-atomic="true"
|
|
20
|
-
style={assistiveTextStyle}
|
|
21
|
-
id={controller.id}
|
|
22
|
-
>
|
|
23
|
-
{controller.message}
|
|
24
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { flexiannouncer } from '../system/announcer.svelte.js';
|
|
3
|
+
import type { InternalFlexiBoardController } from '../system/board/controller.svelte.js';
|
|
4
|
+
import { assistiveTextStyle } from '../system/shared/utils.svelte.js';
|
|
5
|
+
|
|
6
|
+
type FlexiAnnouncerProps = {
|
|
7
|
+
provider: InternalFlexiBoardController;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
let { provider }: FlexiAnnouncerProps = $props();
|
|
11
|
+
|
|
12
|
+
const controller = flexiannouncer(provider);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
role="region"
|
|
17
|
+
aria-live={controller.politeness}
|
|
18
|
+
aria-label="Drag-and-drop announcer"
|
|
19
|
+
aria-atomic="true"
|
|
20
|
+
style={assistiveTextStyle}
|
|
21
|
+
id={controller.id}
|
|
22
|
+
>
|
|
23
|
+
{controller.message}
|
|
24
|
+
</div>
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { flexiboard } from '../system/board/index.js';
|
|
3
|
-
import type { FlexiBoardController } from '../system/board/base.svelte.js';
|
|
4
|
-
import type { FlexiBoardConfiguration } from '../system/board/types.js';
|
|
5
|
-
import { onDestroy, type Snippet } from 'svelte';
|
|
6
|
-
import type { FlexiCommonProps } from '../system/types.js';
|
|
7
|
-
import FlexiLayoutLoader from './flexi-layout-loader.svelte';
|
|
8
|
-
|
|
9
|
-
export type FlexiBoardProps = FlexiCommonProps<FlexiBoardController> & {
|
|
10
|
-
children: Snippet;
|
|
11
|
-
config?: FlexiBoardConfiguration;
|
|
12
|
-
class?: ClassValue;
|
|
13
|
-
};
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<script lang="ts">
|
|
17
|
-
import FlexiPortal from './flexi-portal.svelte';
|
|
18
|
-
import type { ClassValue } from 'svelte/elements';
|
|
19
|
-
import { generateUniqueId, assistiveTextStyle } from '../system/shared/utils.svelte.js';
|
|
20
|
-
import FlexiAnnouncer from './flexi-announcer.svelte';
|
|
21
|
-
|
|
22
|
-
let { controller = $bindable(), onfirstcreate, ...props }: FlexiBoardProps = $props();
|
|
23
|
-
|
|
24
|
-
const board = flexiboard(props);
|
|
25
|
-
controller = board;
|
|
26
|
-
|
|
27
|
-
onfirstcreate?.(board);
|
|
28
|
-
|
|
29
|
-
let assistiveTextId = generateUniqueId();
|
|
30
|
-
|
|
31
|
-
// Cleanup board subscriptions when component is destroyed
|
|
32
|
-
onDestroy(() => {
|
|
33
|
-
board.destroy();
|
|
34
|
-
});
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<div
|
|
38
|
-
class={props.class}
|
|
39
|
-
bind:this={board.ref}
|
|
40
|
-
style={board.style}
|
|
41
|
-
role="application"
|
|
42
|
-
aria-label="Interactive drag-and-drop interface"
|
|
43
|
-
aria-describedby={assistiveTextId}
|
|
44
|
-
>
|
|
45
|
-
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
46
|
-
Press Enter to grab or resize widgets. Once grabbed, use Arrow keys to move/resize the widget,
|
|
47
|
-
Enter to confirm the action, or Esc to cancel it.
|
|
48
|
-
</span>
|
|
49
|
-
{@render props.children()}
|
|
50
|
-
|
|
51
|
-
<FlexiAnnouncer provider={board} />
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
<!-- Component that tells the board it can start importing stuff, if needed. -->
|
|
55
|
-
<FlexiLayoutLoader />
|
|
56
|
-
|
|
57
|
-
<!-- Component that uses a shared portal for rendering grabbed widgets over the pointer. -->
|
|
58
|
-
<FlexiPortal />
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { flexiboard } from '../system/board/index.js';
|
|
3
|
+
import type { FlexiBoardController } from '../system/board/base.svelte.js';
|
|
4
|
+
import type { FlexiBoardConfiguration } from '../system/board/types.js';
|
|
5
|
+
import { onDestroy, type Snippet } from 'svelte';
|
|
6
|
+
import type { FlexiCommonProps } from '../system/types.js';
|
|
7
|
+
import FlexiLayoutLoader from './flexi-layout-loader.svelte';
|
|
8
|
+
|
|
9
|
+
export type FlexiBoardProps = FlexiCommonProps<FlexiBoardController> & {
|
|
10
|
+
children: Snippet;
|
|
11
|
+
config?: FlexiBoardConfiguration;
|
|
12
|
+
class?: ClassValue;
|
|
13
|
+
};
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import FlexiPortal from './flexi-portal.svelte';
|
|
18
|
+
import type { ClassValue } from 'svelte/elements';
|
|
19
|
+
import { generateUniqueId, assistiveTextStyle } from '../system/shared/utils.svelte.js';
|
|
20
|
+
import FlexiAnnouncer from './flexi-announcer.svelte';
|
|
21
|
+
|
|
22
|
+
let { controller = $bindable(), onfirstcreate, ...props }: FlexiBoardProps = $props();
|
|
23
|
+
|
|
24
|
+
const board = flexiboard(props);
|
|
25
|
+
controller = board;
|
|
26
|
+
|
|
27
|
+
onfirstcreate?.(board);
|
|
28
|
+
|
|
29
|
+
let assistiveTextId = generateUniqueId();
|
|
30
|
+
|
|
31
|
+
// Cleanup board subscriptions when component is destroyed
|
|
32
|
+
onDestroy(() => {
|
|
33
|
+
board.destroy();
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<div
|
|
38
|
+
class={props.class}
|
|
39
|
+
bind:this={board.ref}
|
|
40
|
+
style={board.style}
|
|
41
|
+
role="application"
|
|
42
|
+
aria-label="Interactive drag-and-drop interface"
|
|
43
|
+
aria-describedby={assistiveTextId}
|
|
44
|
+
>
|
|
45
|
+
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
46
|
+
Press Enter to grab or resize widgets. Once grabbed, use Arrow keys to move/resize the widget,
|
|
47
|
+
Enter to confirm the action, or Esc to cancel it.
|
|
48
|
+
</span>
|
|
49
|
+
{@render props.children()}
|
|
50
|
+
|
|
51
|
+
<FlexiAnnouncer provider={board} />
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<!-- Component that tells the board it can start importing stuff, if needed. -->
|
|
55
|
+
<FlexiLayoutLoader />
|
|
56
|
+
|
|
57
|
+
<!-- Component that uses a shared portal for rendering grabbed widgets over the pointer. -->
|
|
58
|
+
<FlexiPortal />
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { FlexiCommonProps } from '../system/types.js';
|
|
4
|
-
import {
|
|
5
|
-
flexidelete,
|
|
6
|
-
FlexiDeleteController,
|
|
7
|
-
type FlexiDeleteClasses
|
|
8
|
-
} from '../system/misc/deleter.svelte.js';
|
|
9
|
-
import { assistiveTextStyle, generateUniqueId } from '../system/shared/utils.svelte.js';
|
|
10
|
-
|
|
11
|
-
/** @deprecated FlexiDelete's children props are now redundant and will be removed in v0.4. */
|
|
12
|
-
type FlexiDeleteChildrenProps = {
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated This has been replaced with internal pointer management and is redundant. These events will be removed in v0.4.
|
|
15
|
-
*/
|
|
16
|
-
onpointerenter: (event: PointerEvent) => void;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated This has been replaced with internal pointer management and is redundant. These events will be removed in v0.4.
|
|
19
|
-
*/
|
|
20
|
-
onpointerleave: (event: PointerEvent) => void;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type FlexiDeleteProps = FlexiCommonProps<FlexiDeleteController> & {
|
|
24
|
-
class?: FlexiDeleteClasses;
|
|
25
|
-
children?: Snippet<[{ deleter: FlexiDeleteController; props: FlexiDeleteChildrenProps }]>;
|
|
26
|
-
};
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<script lang="ts">
|
|
30
|
-
let {
|
|
31
|
-
class: className,
|
|
32
|
-
children,
|
|
33
|
-
controller = $bindable(),
|
|
34
|
-
onfirstcreate
|
|
35
|
-
}: FlexiDeleteProps = $props();
|
|
36
|
-
|
|
37
|
-
// TODO: remove pointer events in v0.4
|
|
38
|
-
const { deleter, onpointerenter, onpointerleave } = flexidelete();
|
|
39
|
-
controller = deleter;
|
|
40
|
-
onfirstcreate?.(deleter);
|
|
41
|
-
|
|
42
|
-
let derivedClassName = $derived.by(() => {
|
|
43
|
-
if (!deleter) {
|
|
44
|
-
return '';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (typeof className === 'function') {
|
|
48
|
-
return className(deleter);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return className;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
let assistiveTextId = generateUniqueId();
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<div
|
|
58
|
-
role="region"
|
|
59
|
-
bind:this={deleter.ref}
|
|
60
|
-
class={derivedClassName}
|
|
61
|
-
aria-describedby={assistiveTextId}
|
|
62
|
-
>
|
|
63
|
-
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
64
|
-
Drag a widget here and press Enter to delete it.
|
|
65
|
-
</span>
|
|
66
|
-
{@render children?.({ deleter, props: { onpointerenter, onpointerleave } })}
|
|
67
|
-
</div>
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { FlexiCommonProps } from '../system/types.js';
|
|
4
|
+
import {
|
|
5
|
+
flexidelete,
|
|
6
|
+
FlexiDeleteController,
|
|
7
|
+
type FlexiDeleteClasses
|
|
8
|
+
} from '../system/misc/deleter.svelte.js';
|
|
9
|
+
import { assistiveTextStyle, generateUniqueId } from '../system/shared/utils.svelte.js';
|
|
10
|
+
|
|
11
|
+
/** @deprecated FlexiDelete's children props are now redundant and will be removed in v0.4. */
|
|
12
|
+
type FlexiDeleteChildrenProps = {
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated This has been replaced with internal pointer management and is redundant. These events will be removed in v0.4.
|
|
15
|
+
*/
|
|
16
|
+
onpointerenter: (event: PointerEvent) => void;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated This has been replaced with internal pointer management and is redundant. These events will be removed in v0.4.
|
|
19
|
+
*/
|
|
20
|
+
onpointerleave: (event: PointerEvent) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type FlexiDeleteProps = FlexiCommonProps<FlexiDeleteController> & {
|
|
24
|
+
class?: FlexiDeleteClasses;
|
|
25
|
+
children?: Snippet<[{ deleter: FlexiDeleteController; props: FlexiDeleteChildrenProps }]>;
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
let {
|
|
31
|
+
class: className,
|
|
32
|
+
children,
|
|
33
|
+
controller = $bindable(),
|
|
34
|
+
onfirstcreate
|
|
35
|
+
}: FlexiDeleteProps = $props();
|
|
36
|
+
|
|
37
|
+
// TODO: remove pointer events in v0.4
|
|
38
|
+
const { deleter, onpointerenter, onpointerleave } = flexidelete();
|
|
39
|
+
controller = deleter;
|
|
40
|
+
onfirstcreate?.(deleter);
|
|
41
|
+
|
|
42
|
+
let derivedClassName = $derived.by(() => {
|
|
43
|
+
if (!deleter) {
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (typeof className === 'function') {
|
|
48
|
+
return className(deleter);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return className;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
let assistiveTextId = generateUniqueId();
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<div
|
|
58
|
+
role="region"
|
|
59
|
+
bind:this={deleter.ref}
|
|
60
|
+
class={derivedClassName}
|
|
61
|
+
aria-describedby={assistiveTextId}
|
|
62
|
+
>
|
|
63
|
+
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
64
|
+
Drag a widget here and press Enter to delete it.
|
|
65
|
+
</span>
|
|
66
|
+
{@render children?.({ deleter, props: { onpointerenter, onpointerleave } })}
|
|
67
|
+
</div>
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { flexigrab } from '../system/widget/index.js';
|
|
3
|
-
import type { FlexiWidgetController } from '../system/widget/base.svelte.js';
|
|
4
|
-
import type { Snippet } from 'svelte';
|
|
5
|
-
import type { ClassValue } from 'svelte/elements';
|
|
6
|
-
|
|
7
|
-
type FlexiGrabProps = {
|
|
8
|
-
children?: Snippet<[{ widget: FlexiWidgetController }]>;
|
|
9
|
-
class?: ClassValue;
|
|
10
|
-
};
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<script lang="ts">
|
|
14
|
-
let { class: className, children }: FlexiGrabProps = $props();
|
|
15
|
-
|
|
16
|
-
const { widget, onpointerdown, onkeydown } = flexigrab();
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<button
|
|
20
|
-
style={'user-select: none; touch-action: none;' +
|
|
21
|
-
(widget.draggable && widget.mounted ? 'cursor: grab;' : 'cursor: not-allowed;')}
|
|
22
|
-
disabled={!widget.draggable || !widget.mounted}
|
|
23
|
-
class={className}
|
|
24
|
-
{onpointerdown}
|
|
25
|
-
{onkeydown}
|
|
26
|
-
>
|
|
27
|
-
{@render children?.({ widget })}
|
|
28
|
-
</button>
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { flexigrab } from '../system/widget/index.js';
|
|
3
|
+
import type { FlexiWidgetController } from '../system/widget/base.svelte.js';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import type { ClassValue } from 'svelte/elements';
|
|
6
|
+
|
|
7
|
+
type FlexiGrabProps = {
|
|
8
|
+
children?: Snippet<[{ widget: FlexiWidgetController }]>;
|
|
9
|
+
class?: ClassValue;
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
let { class: className, children }: FlexiGrabProps = $props();
|
|
15
|
+
|
|
16
|
+
const { widget, onpointerdown, onkeydown } = flexigrab();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<button
|
|
20
|
+
style={'user-select: none; touch-action: none;' +
|
|
21
|
+
(widget.draggable && widget.mounted ? 'cursor: grab;' : 'cursor: not-allowed;')}
|
|
22
|
+
disabled={!widget.draggable || !widget.mounted}
|
|
23
|
+
class={className}
|
|
24
|
+
{onpointerdown}
|
|
25
|
+
{onkeydown}
|
|
26
|
+
>
|
|
27
|
+
{@render children?.({ widget })}
|
|
28
|
+
</button>
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { flexigrid } from '../system/grid/index.js';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
|
-
|
|
5
|
-
export type FlexiGridProps = {
|
|
6
|
-
children?: Snippet;
|
|
7
|
-
class?: string;
|
|
8
|
-
};
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<script lang="ts">
|
|
12
|
-
let { children, class: className }: FlexiGridProps = $props();
|
|
13
|
-
|
|
14
|
-
const { grid } = flexigrid();
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<div
|
|
18
|
-
class={className}
|
|
19
|
-
role="grid"
|
|
20
|
-
aria-label="Drag-and-drop grid"
|
|
21
|
-
aria-colcount={grid.columns}
|
|
22
|
-
aria-rowcount={grid.rows}
|
|
23
|
-
bind:this={grid.ref}
|
|
24
|
-
style={grid?.style}
|
|
25
|
-
>
|
|
26
|
-
{@render children?.()}
|
|
27
|
-
</div>
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { flexigrid } from '../system/grid/index.js';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
export type FlexiGridProps = {
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
class?: string;
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
let { children, class: className }: FlexiGridProps = $props();
|
|
13
|
+
|
|
14
|
+
const { grid } = flexigrid();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div
|
|
18
|
+
class={className}
|
|
19
|
+
role="grid"
|
|
20
|
+
aria-label="Drag-and-drop grid"
|
|
21
|
+
aria-colcount={grid.columns}
|
|
22
|
+
aria-rowcount={grid.rows}
|
|
23
|
+
bind:this={grid.ref}
|
|
24
|
+
style={grid?.style}
|
|
25
|
+
>
|
|
26
|
+
{@render children?.()}
|
|
27
|
+
</div>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { getInternalFlexiboardCtx } from '../system/board/index.js';
|
|
3
|
-
|
|
4
|
-
// This is a simple component that triggers the initial layout load.
|
|
5
|
-
// We must do this after instantiating all other components, otherwise we won't have established
|
|
6
|
-
// the target layout of our Flexiboard.
|
|
7
|
-
|
|
8
|
-
const board = getInternalFlexiboardCtx();
|
|
9
|
-
board.oninitialloadcomplete();
|
|
10
|
-
</script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getInternalFlexiboardCtx } from '../system/board/index.js';
|
|
3
|
+
|
|
4
|
+
// This is a simple component that triggers the initial layout load.
|
|
5
|
+
// We must do this after instantiating all other components, otherwise we won't have established
|
|
6
|
+
// the target layout of our Flexiboard.
|
|
7
|
+
|
|
8
|
+
const board = getInternalFlexiboardCtx();
|
|
9
|
+
board.oninitialloadcomplete();
|
|
10
|
+
</script>
|