svelte-flexiboards 0.4.1 → 0.4.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/LICENSE.md +21 -0
- package/README.md +15 -15
- package/dist/components/flexi-add.svelte +74 -74
- package/dist/components/flexi-announcer.svelte +24 -24
- package/dist/components/flexi-board.svelte +58 -58
- package/dist/components/flexi-delete.svelte +54 -54
- 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 -14
- package/dist/components/flexi-target.svelte +104 -104
- package/dist/components/flexi-widget.svelte +81 -81
- package/dist/components/rendered-flexi-widget.svelte +64 -64
- package/dist/components/responsive-flexi-board.svelte +83 -83
- package/dist/components/widget-transition-placeholder.svelte +12 -12
- package/dist/system/board/controller.svelte.d.ts +8 -8
- package/dist/system/internal-types.d.ts +109 -0
- package/dist/system/internal-types.js +1 -0
- package/dist/system/misc/adder.svelte.d.ts +2 -2
- package/dist/system/portal.d.ts +3 -3
- package/dist/system/shared/event-bus.d.ts +15 -14
- package/dist/system/shared/utils.svelte.d.ts +4 -3
- package/dist/system/shared/utils.svelte.js +10 -10
- package/dist/system/target/controller.svelte.d.ts +12 -11
- package/dist/system/target/controller.svelte.js +1 -1
- package/dist/system/target/types.d.ts +2 -2
- package/dist/system/types.d.ts +26 -27
- package/dist/system/widget/controller.svelte.d.ts +6 -6
- package/dist/system/widget/controller.svelte.js +1 -2
- package/dist/system/widget/triggers.svelte.js +9 -0
- package/package.json +60 -61
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Blakintosh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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,74 +1,74 @@
|
|
|
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
|
-
export type FlexiAddProps = FlexiCommonProps<FlexiAddController> & {
|
|
14
|
-
class?: FlexiAddClasses;
|
|
15
|
-
children?: Snippet<[{ adder: FlexiAddController }]>;
|
|
16
|
-
addWidget: FlexiAddWidgetFn;
|
|
17
|
-
};
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<script lang="ts">
|
|
21
|
-
let {
|
|
22
|
-
children,
|
|
23
|
-
addWidget,
|
|
24
|
-
controller = $bindable(),
|
|
25
|
-
onfirstcreate,
|
|
26
|
-
class: className
|
|
27
|
-
}: FlexiAddProps = $props();
|
|
28
|
-
|
|
29
|
-
const { adder, onpointerdown, onkeydown } = flexiadd(addWidget);
|
|
30
|
-
controller = adder;
|
|
31
|
-
onfirstcreate?.(adder);
|
|
32
|
-
|
|
33
|
-
const dummyOnpointerdown = (event: PointerEvent) => {};
|
|
34
|
-
|
|
35
|
-
let derivedClassName = $derived.by(() => {
|
|
36
|
-
if (!adder) {
|
|
37
|
-
return '';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (typeof className === 'function') {
|
|
41
|
-
return className(adder);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return className;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
let assistiveTextId = generateUniqueId();
|
|
48
|
-
|
|
49
|
-
// Cleanup adder subscriptions when component is destroyed
|
|
50
|
-
onDestroy(() => {
|
|
51
|
-
adder.destroy();
|
|
52
|
-
});
|
|
53
|
-
</script>
|
|
54
|
-
|
|
55
|
-
<button
|
|
56
|
-
class={derivedClassName}
|
|
57
|
-
bind:this={adder.ref}
|
|
58
|
-
aria-describedby={assistiveTextId}
|
|
59
|
-
style={'touch-action: none;'}
|
|
60
|
-
{onpointerdown}
|
|
61
|
-
{onkeydown}
|
|
62
|
-
>
|
|
63
|
-
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
64
|
-
Press Enter to drag a new widget into this board.
|
|
65
|
-
</span>
|
|
66
|
-
{@render children?.({ adder })}
|
|
67
|
-
</button>
|
|
68
|
-
|
|
69
|
-
<div style="display: none;">
|
|
70
|
-
<!-- Mimics the behaviour of a FlexiTarget, as we need to render the widget so that we can "drag it in" from -->
|
|
71
|
-
{#if adder.newWidget}
|
|
72
|
-
<RenderedFlexiWidget widget={adder.newWidget} />
|
|
73
|
-
{/if}
|
|
74
|
-
</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
|
+
export type FlexiAddProps = FlexiCommonProps<FlexiAddController> & {
|
|
14
|
+
class?: FlexiAddClasses;
|
|
15
|
+
children?: Snippet<[{ adder: FlexiAddController }]>;
|
|
16
|
+
addWidget: FlexiAddWidgetFn;
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
let {
|
|
22
|
+
children,
|
|
23
|
+
addWidget,
|
|
24
|
+
controller = $bindable(),
|
|
25
|
+
onfirstcreate,
|
|
26
|
+
class: className
|
|
27
|
+
}: FlexiAddProps = $props();
|
|
28
|
+
|
|
29
|
+
const { adder, onpointerdown, onkeydown } = flexiadd(addWidget);
|
|
30
|
+
controller = adder;
|
|
31
|
+
onfirstcreate?.(adder);
|
|
32
|
+
|
|
33
|
+
const dummyOnpointerdown = (event: PointerEvent) => {};
|
|
34
|
+
|
|
35
|
+
let derivedClassName = $derived.by(() => {
|
|
36
|
+
if (!adder) {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof className === 'function') {
|
|
41
|
+
return className(adder);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return className;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
let assistiveTextId = generateUniqueId();
|
|
48
|
+
|
|
49
|
+
// Cleanup adder subscriptions when component is destroyed
|
|
50
|
+
onDestroy(() => {
|
|
51
|
+
adder.destroy();
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<button
|
|
56
|
+
class={derivedClassName}
|
|
57
|
+
bind:this={adder.ref}
|
|
58
|
+
aria-describedby={assistiveTextId}
|
|
59
|
+
style={'touch-action: none;'}
|
|
60
|
+
{onpointerdown}
|
|
61
|
+
{onkeydown}
|
|
62
|
+
>
|
|
63
|
+
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
64
|
+
Press Enter to drag a new widget into this board.
|
|
65
|
+
</span>
|
|
66
|
+
{@render children?.({ adder })}
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
<div style="display: none;">
|
|
70
|
+
<!-- Mimics the behaviour of a FlexiTarget, as we need to render the widget so that we can "drag it in" from -->
|
|
71
|
+
{#if adder.newWidget}
|
|
72
|
+
<RenderedFlexiWidget widget={adder.newWidget} />
|
|
73
|
+
{/if}
|
|
74
|
+
</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,54 +1,54 @@
|
|
|
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
|
-
export type FlexiDeleteProps = FlexiCommonProps<FlexiDeleteController> & {
|
|
12
|
-
class?: FlexiDeleteClasses;
|
|
13
|
-
children?: Snippet<[{ deleter: FlexiDeleteController }]>;
|
|
14
|
-
};
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<script lang="ts">
|
|
18
|
-
let {
|
|
19
|
-
class: className,
|
|
20
|
-
children,
|
|
21
|
-
controller = $bindable(),
|
|
22
|
-
onfirstcreate
|
|
23
|
-
}: FlexiDeleteProps = $props();
|
|
24
|
-
|
|
25
|
-
const { deleter } = flexidelete();
|
|
26
|
-
controller = deleter;
|
|
27
|
-
onfirstcreate?.(deleter);
|
|
28
|
-
|
|
29
|
-
let derivedClassName = $derived.by(() => {
|
|
30
|
-
if (!deleter) {
|
|
31
|
-
return '';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (typeof className === 'function') {
|
|
35
|
-
return className(deleter);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return className;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
let assistiveTextId = generateUniqueId();
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<div
|
|
45
|
-
role="region"
|
|
46
|
-
bind:this={deleter.ref}
|
|
47
|
-
class={derivedClassName}
|
|
48
|
-
aria-describedby={assistiveTextId}
|
|
49
|
-
>
|
|
50
|
-
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
51
|
-
Drag a widget here and press Enter to delete it.
|
|
52
|
-
</span>
|
|
53
|
-
{@render children?.({ deleter })}
|
|
54
|
-
</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
|
+
export type FlexiDeleteProps = FlexiCommonProps<FlexiDeleteController> & {
|
|
12
|
+
class?: FlexiDeleteClasses;
|
|
13
|
+
children?: Snippet<[{ deleter: FlexiDeleteController }]>;
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
let {
|
|
19
|
+
class: className,
|
|
20
|
+
children,
|
|
21
|
+
controller = $bindable(),
|
|
22
|
+
onfirstcreate
|
|
23
|
+
}: FlexiDeleteProps = $props();
|
|
24
|
+
|
|
25
|
+
const { deleter } = flexidelete();
|
|
26
|
+
controller = deleter;
|
|
27
|
+
onfirstcreate?.(deleter);
|
|
28
|
+
|
|
29
|
+
let derivedClassName = $derived.by(() => {
|
|
30
|
+
if (!deleter) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeof className === 'function') {
|
|
35
|
+
return className(deleter);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return className;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
let assistiveTextId = generateUniqueId();
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<div
|
|
45
|
+
role="region"
|
|
46
|
+
bind:this={deleter.ref}
|
|
47
|
+
class={derivedClassName}
|
|
48
|
+
aria-describedby={assistiveTextId}
|
|
49
|
+
>
|
|
50
|
+
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
51
|
+
Drag a widget here and press Enter to delete it.
|
|
52
|
+
</span>
|
|
53
|
+
{@render children?.({ deleter })}
|
|
54
|
+
</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.isGrabbable && widget.mounted ? 'cursor: grab;' : 'cursor: not-allowed;')}
|
|
22
|
-
disabled={!widget.isGrabbable || !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.isGrabbable && widget.mounted ? 'cursor: grab;' : 'cursor: not-allowed;')}
|
|
22
|
+
disabled={!widget.isGrabbable || !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>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { flexiportal, destroyFlexiportal } from '../system/portal.js';
|
|
3
|
-
import { onMount } from 'svelte';
|
|
4
|
-
|
|
5
|
-
// Simply just wait until we're mounted to the DOM before initialising the portal.
|
|
6
|
-
onMount(() => {
|
|
7
|
-
flexiportal();
|
|
8
|
-
|
|
9
|
-
// Garbage collect on destroy
|
|
10
|
-
return () => {
|
|
11
|
-
destroyFlexiportal();
|
|
12
|
-
};
|
|
13
|
-
});
|
|
14
|
-
</script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { flexiportal, destroyFlexiportal } from '../system/portal.js';
|
|
3
|
+
import { onMount } from 'svelte';
|
|
4
|
+
|
|
5
|
+
// Simply just wait until we're mounted to the DOM before initialising the portal.
|
|
6
|
+
onMount(() => {
|
|
7
|
+
flexiportal();
|
|
8
|
+
|
|
9
|
+
// Garbage collect on destroy
|
|
10
|
+
return () => {
|
|
11
|
+
destroyFlexiportal();
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
</script>
|