svelte-flexiboards 0.4.0 → 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 -86
- package/dist/components/flexi-add.svelte.d.ts +0 -12
- package/dist/components/flexi-announcer.svelte +24 -24
- package/dist/components/flexi-board.svelte +58 -58
- package/dist/components/flexi-delete.svelte +54 -66
- 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/board/controller.svelte.js +4 -0
- 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 +6 -3
- package/dist/system/shared/utils.svelte.js +49 -32
- package/dist/system/target/controller.svelte.d.ts +12 -11
- package/dist/system/target/controller.svelte.js +25 -22
- 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
|
@@ -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>
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { flexiresize } 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 FlexiResizeProps = {
|
|
8
|
-
children?: Snippet<[{ widget: FlexiWidgetController }]>;
|
|
9
|
-
class?: ClassValue;
|
|
10
|
-
};
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<script lang="ts">
|
|
14
|
-
let { class: className, children }: FlexiResizeProps = $props();
|
|
15
|
-
|
|
16
|
-
const { widget, onpointerdown, onkeydown } = flexiresize();
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<button
|
|
20
|
-
style={'user-select: none; touch-action: none;' +
|
|
21
|
-
(widget.resizability != 'none' && widget.mounted
|
|
22
|
-
? 'cursor: nwse-resize'
|
|
23
|
-
: 'cursor: not-allowed')}
|
|
24
|
-
class={className}
|
|
25
|
-
disabled={widget.resizability == 'none' || !widget.mounted}
|
|
26
|
-
{onpointerdown}
|
|
27
|
-
{onkeydown}
|
|
28
|
-
>
|
|
29
|
-
{@render children?.({ widget })}
|
|
30
|
-
</button>
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { flexiresize } 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 FlexiResizeProps = {
|
|
8
|
+
children?: Snippet<[{ widget: FlexiWidgetController }]>;
|
|
9
|
+
class?: ClassValue;
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
let { class: className, children }: FlexiResizeProps = $props();
|
|
15
|
+
|
|
16
|
+
const { widget, onpointerdown, onkeydown } = flexiresize();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<button
|
|
20
|
+
style={'user-select: none; touch-action: none;' +
|
|
21
|
+
(widget.resizability != 'none' && widget.mounted
|
|
22
|
+
? 'cursor: nwse-resize'
|
|
23
|
+
: 'cursor: not-allowed')}
|
|
24
|
+
class={className}
|
|
25
|
+
disabled={widget.resizability == 'none' || !widget.mounted}
|
|
26
|
+
{onpointerdown}
|
|
27
|
+
{onkeydown}
|
|
28
|
+
>
|
|
29
|
+
{@render children?.({ widget })}
|
|
30
|
+
</button>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { getInternalFlexitargetCtx } from '../system/target/index.js';
|
|
3
|
-
import { onMount } from 'svelte';
|
|
4
|
-
|
|
5
|
-
// This is a simple component that triggers the initial layout load.
|
|
6
|
-
// We must do this after instantiating all other components, otherwise we won't have established
|
|
7
|
-
// the target layout of our Flexiboard.
|
|
8
|
-
|
|
9
|
-
const target = getInternalFlexitargetCtx();
|
|
10
|
-
|
|
11
|
-
onMount(() => {
|
|
12
|
-
target.oninitialloadcomplete();
|
|
13
|
-
});
|
|
14
|
-
</script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getInternalFlexitargetCtx } from '../system/target/index.js';
|
|
3
|
+
import { onMount } from 'svelte';
|
|
4
|
+
|
|
5
|
+
// This is a simple component that triggers the initial layout load.
|
|
6
|
+
// We must do this after instantiating all other components, otherwise we won't have established
|
|
7
|
+
// the target layout of our Flexiboard.
|
|
8
|
+
|
|
9
|
+
const target = getInternalFlexitargetCtx();
|
|
10
|
+
|
|
11
|
+
onMount(() => {
|
|
12
|
+
target.oninitialloadcomplete();
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { onDestroy, tick, untrack, type Snippet } from 'svelte';
|
|
3
|
-
import { flexitarget } from '../system/target/index.js';
|
|
4
|
-
import type { FlexiTargetController } from '../system/target/base.svelte.js';
|
|
5
|
-
import type { FlexiTargetPartialConfiguration } from '../system/target/types.js';
|
|
6
|
-
|
|
7
|
-
import type { FlexiCommonProps } from '../system/types.js';
|
|
8
|
-
|
|
9
|
-
export type FlexiTargetProps = FlexiCommonProps<FlexiTargetController> & {
|
|
10
|
-
/**
|
|
11
|
-
* The header content of the target, above the grid.
|
|
12
|
-
*/
|
|
13
|
-
header?: Snippet<[{ target: FlexiTargetController }]>;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The child content of the target, which should contain inner FlexiWidget
|
|
17
|
-
* definitions.
|
|
18
|
-
*/
|
|
19
|
-
children?: Snippet;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The footer content of the target, below the grid.
|
|
23
|
-
*/
|
|
24
|
-
footer?: Snippet<[{ target: FlexiTargetController }]>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The class names to apply to the target's container element.
|
|
28
|
-
*/
|
|
29
|
-
containerClass?: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The class names to apply to the target's grid element.
|
|
33
|
-
*/
|
|
34
|
-
class?: string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The configuration object for the target.
|
|
38
|
-
*/
|
|
39
|
-
config?: FlexiTargetPartialConfiguration;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The unique identifier for the target.
|
|
43
|
-
* Used to identify the target when layouts are imported or exported.
|
|
44
|
-
*/
|
|
45
|
-
key?: string;
|
|
46
|
-
};
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<script lang="ts">
|
|
50
|
-
import FlexiGrid from './flexi-grid.svelte';
|
|
51
|
-
import FlexiTargetLoader from './flexi-target-loader.svelte';
|
|
52
|
-
import RenderedFlexiWidget from './rendered-flexi-widget.svelte';
|
|
53
|
-
import type { InternalFlexiWidgetController } from '../system/widget/controller.svelte.js';
|
|
54
|
-
|
|
55
|
-
let {
|
|
56
|
-
children,
|
|
57
|
-
class: className,
|
|
58
|
-
header,
|
|
59
|
-
footer,
|
|
60
|
-
config,
|
|
61
|
-
containerClass,
|
|
62
|
-
controller = $bindable(),
|
|
63
|
-
key,
|
|
64
|
-
onfirstcreate
|
|
65
|
-
}: FlexiTargetProps = $props();
|
|
66
|
-
|
|
67
|
-
const { target } = flexitarget(config, key);
|
|
68
|
-
|
|
69
|
-
// Target created, allow the caller to access it.
|
|
70
|
-
controller = target;
|
|
71
|
-
onfirstcreate?.(target);
|
|
72
|
-
|
|
73
|
-
// Cleanup target subscriptions when component is destroyed
|
|
74
|
-
onDestroy(() => {
|
|
75
|
-
target.destroy();
|
|
76
|
-
});
|
|
77
|
-
</script>
|
|
78
|
-
|
|
79
|
-
<div class={containerClass}>
|
|
80
|
-
{@render header?.({ target: target as FlexiTargetController })}
|
|
81
|
-
|
|
82
|
-
<!-- Allow user to specify components directly via a registration component. Once that's done, mount them to the actual target list dynamically -->
|
|
83
|
-
<FlexiGrid class={className}>
|
|
84
|
-
{#if children}
|
|
85
|
-
<!-- Keep the initial widgets 'rendered' so that state inside children snippet doesn't get lost -->
|
|
86
|
-
<div style={target.prepared ? 'visibility: hidden;' : ''}>
|
|
87
|
-
{@render children()}
|
|
88
|
-
</div>
|
|
89
|
-
{/if}
|
|
90
|
-
{#if target.prepared}
|
|
91
|
-
<!-- Render widgets in deterministic order for tabbing and consistent DOM ordering -->
|
|
92
|
-
{#each target.orderedWidgets as widget (widget.id)}
|
|
93
|
-
<RenderedFlexiWidget {widget} />
|
|
94
|
-
{/each}
|
|
95
|
-
|
|
96
|
-
{#if target.dropzoneWidget && target.shouldRenderDropzoneWidget}
|
|
97
|
-
<RenderedFlexiWidget widget={target.dropzoneWidget} />
|
|
98
|
-
{/if}
|
|
99
|
-
{/if}
|
|
100
|
-
</FlexiGrid>
|
|
101
|
-
{@render footer?.({ target })}
|
|
102
|
-
</div>
|
|
103
|
-
|
|
104
|
-
<FlexiTargetLoader />
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { onDestroy, tick, untrack, type Snippet } from 'svelte';
|
|
3
|
+
import { flexitarget } from '../system/target/index.js';
|
|
4
|
+
import type { FlexiTargetController } from '../system/target/base.svelte.js';
|
|
5
|
+
import type { FlexiTargetPartialConfiguration } from '../system/target/types.js';
|
|
6
|
+
|
|
7
|
+
import type { FlexiCommonProps } from '../system/types.js';
|
|
8
|
+
|
|
9
|
+
export type FlexiTargetProps = FlexiCommonProps<FlexiTargetController> & {
|
|
10
|
+
/**
|
|
11
|
+
* The header content of the target, above the grid.
|
|
12
|
+
*/
|
|
13
|
+
header?: Snippet<[{ target: FlexiTargetController }]>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The child content of the target, which should contain inner FlexiWidget
|
|
17
|
+
* definitions.
|
|
18
|
+
*/
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The footer content of the target, below the grid.
|
|
23
|
+
*/
|
|
24
|
+
footer?: Snippet<[{ target: FlexiTargetController }]>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The class names to apply to the target's container element.
|
|
28
|
+
*/
|
|
29
|
+
containerClass?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The class names to apply to the target's grid element.
|
|
33
|
+
*/
|
|
34
|
+
class?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The configuration object for the target.
|
|
38
|
+
*/
|
|
39
|
+
config?: FlexiTargetPartialConfiguration;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The unique identifier for the target.
|
|
43
|
+
* Used to identify the target when layouts are imported or exported.
|
|
44
|
+
*/
|
|
45
|
+
key?: string;
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<script lang="ts">
|
|
50
|
+
import FlexiGrid from './flexi-grid.svelte';
|
|
51
|
+
import FlexiTargetLoader from './flexi-target-loader.svelte';
|
|
52
|
+
import RenderedFlexiWidget from './rendered-flexi-widget.svelte';
|
|
53
|
+
import type { InternalFlexiWidgetController } from '../system/widget/controller.svelte.js';
|
|
54
|
+
|
|
55
|
+
let {
|
|
56
|
+
children,
|
|
57
|
+
class: className,
|
|
58
|
+
header,
|
|
59
|
+
footer,
|
|
60
|
+
config,
|
|
61
|
+
containerClass,
|
|
62
|
+
controller = $bindable(),
|
|
63
|
+
key,
|
|
64
|
+
onfirstcreate
|
|
65
|
+
}: FlexiTargetProps = $props();
|
|
66
|
+
|
|
67
|
+
const { target } = flexitarget(config, key);
|
|
68
|
+
|
|
69
|
+
// Target created, allow the caller to access it.
|
|
70
|
+
controller = target;
|
|
71
|
+
onfirstcreate?.(target);
|
|
72
|
+
|
|
73
|
+
// Cleanup target subscriptions when component is destroyed
|
|
74
|
+
onDestroy(() => {
|
|
75
|
+
target.destroy();
|
|
76
|
+
});
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<div class={containerClass}>
|
|
80
|
+
{@render header?.({ target: target as FlexiTargetController })}
|
|
81
|
+
|
|
82
|
+
<!-- Allow user to specify components directly via a registration component. Once that's done, mount them to the actual target list dynamically -->
|
|
83
|
+
<FlexiGrid class={className}>
|
|
84
|
+
{#if children}
|
|
85
|
+
<!-- Keep the initial widgets 'rendered' so that state inside children snippet doesn't get lost -->
|
|
86
|
+
<div style={target.prepared ? 'visibility: hidden;' : ''}>
|
|
87
|
+
{@render children()}
|
|
88
|
+
</div>
|
|
89
|
+
{/if}
|
|
90
|
+
{#if target.prepared}
|
|
91
|
+
<!-- Render widgets in deterministic order for tabbing and consistent DOM ordering -->
|
|
92
|
+
{#each target.orderedWidgets as widget (widget.id)}
|
|
93
|
+
<RenderedFlexiWidget {widget} />
|
|
94
|
+
{/each}
|
|
95
|
+
|
|
96
|
+
{#if target.dropzoneWidget && target.shouldRenderDropzoneWidget}
|
|
97
|
+
<RenderedFlexiWidget widget={target.dropzoneWidget} />
|
|
98
|
+
{/if}
|
|
99
|
+
{/if}
|
|
100
|
+
</FlexiGrid>
|
|
101
|
+
{@render footer?.({ target })}
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<FlexiTargetLoader />
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import type { FlexiCommonProps } from '../system/types.js';
|
|
3
|
-
import { assistiveTextStyle, generateUniqueId } from '../system/shared/utils.svelte.js';
|
|
4
|
-
import { onDestroy, onMount } from 'svelte';
|
|
5
|
-
import type {
|
|
6
|
-
FlexiWidgetChildrenSnippet,
|
|
7
|
-
FlexiWidgetClasses,
|
|
8
|
-
FlexiWidgetConfiguration
|
|
9
|
-
} from '../system/widget/types.js';
|
|
10
|
-
import type { FlexiWidgetController } from '../system/widget/base.svelte.js';
|
|
11
|
-
import { flexiwidget } from '../system/widget/index.js';
|
|
12
|
-
|
|
13
|
-
export type FlexiWidgetProps = FlexiCommonProps<FlexiWidgetController> &
|
|
14
|
-
Exclude<FlexiWidgetConfiguration, 'className' | 'snippet'> & {
|
|
15
|
-
class?: FlexiWidgetClasses;
|
|
16
|
-
children?: FlexiWidgetChildrenSnippet;
|
|
17
|
-
};
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<script lang="ts">
|
|
21
|
-
let {
|
|
22
|
-
class: className = $bindable(),
|
|
23
|
-
children = $bindable(),
|
|
24
|
-
controller = $bindable(),
|
|
25
|
-
onfirstcreate,
|
|
26
|
-
...propsConfig
|
|
27
|
-
}: FlexiWidgetProps = $props();
|
|
28
|
-
|
|
29
|
-
let config: FlexiWidgetConfiguration = $state({
|
|
30
|
-
...propsConfig,
|
|
31
|
-
...(className !== undefined && { className }),
|
|
32
|
-
...(children !== undefined && { snippet: children })
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Callback so that we still fulfil these props.
|
|
36
|
-
function onWidgetCreated(widget: FlexiWidgetController) {
|
|
37
|
-
controller = widget;
|
|
38
|
-
onfirstcreate?.(widget);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
flexiwidget(config, onWidgetCreated);
|
|
42
|
-
|
|
43
|
-
// let derivedClassName = $derived.by(() => {
|
|
44
|
-
// if (typeof widget.className === 'function') {
|
|
45
|
-
// return widget.className(widget);
|
|
46
|
-
// }
|
|
47
|
-
|
|
48
|
-
// return widget.className;
|
|
49
|
-
// });
|
|
50
|
-
|
|
51
|
-
// let assistiveTextId = generateUniqueId();
|
|
52
|
-
</script>
|
|
53
|
-
|
|
54
|
-
<!-- Only use noscript as an SSR fallback, because it won't look the same as the hydrated version. -->
|
|
55
|
-
<!-- <noscript style="display: contents;">
|
|
56
|
-
<div
|
|
57
|
-
class={derivedClassName}
|
|
58
|
-
aria-grabbed={widget.isGrabbed}
|
|
59
|
-
style={widget.style}
|
|
60
|
-
role="cell"
|
|
61
|
-
aria-label="Idle widget"
|
|
62
|
-
aria-colindex={widget.x}
|
|
63
|
-
aria-rowindex={widget.y}
|
|
64
|
-
aria-colspan={widget.width}
|
|
65
|
-
aria-rowspan={widget.height}
|
|
66
|
-
aria-describedby={assistiveTextId}
|
|
67
|
-
tabindex={0}
|
|
68
|
-
bind:this={widget.ref}
|
|
69
|
-
>
|
|
70
|
-
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
71
|
-
JavaScript is required to manipulate this widget.
|
|
72
|
-
</span>
|
|
73
|
-
{#if widget.snippet}
|
|
74
|
-
{@render widget.snippet({
|
|
75
|
-
widget
|
|
76
|
-
})}
|
|
77
|
-
{:else if widget.component}
|
|
78
|
-
<widget.component {...widget.componentProps ?? {}} />
|
|
79
|
-
{/if}
|
|
80
|
-
</div>
|
|
81
|
-
</noscript> -->
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { FlexiCommonProps } from '../system/types.js';
|
|
3
|
+
import { assistiveTextStyle, generateUniqueId } from '../system/shared/utils.svelte.js';
|
|
4
|
+
import { onDestroy, onMount } from 'svelte';
|
|
5
|
+
import type {
|
|
6
|
+
FlexiWidgetChildrenSnippet,
|
|
7
|
+
FlexiWidgetClasses,
|
|
8
|
+
FlexiWidgetConfiguration
|
|
9
|
+
} from '../system/widget/types.js';
|
|
10
|
+
import type { FlexiWidgetController } from '../system/widget/base.svelte.js';
|
|
11
|
+
import { flexiwidget } from '../system/widget/index.js';
|
|
12
|
+
|
|
13
|
+
export type FlexiWidgetProps = FlexiCommonProps<FlexiWidgetController> &
|
|
14
|
+
Exclude<FlexiWidgetConfiguration, 'className' | 'snippet'> & {
|
|
15
|
+
class?: FlexiWidgetClasses;
|
|
16
|
+
children?: FlexiWidgetChildrenSnippet;
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
let {
|
|
22
|
+
class: className = $bindable(),
|
|
23
|
+
children = $bindable(),
|
|
24
|
+
controller = $bindable(),
|
|
25
|
+
onfirstcreate,
|
|
26
|
+
...propsConfig
|
|
27
|
+
}: FlexiWidgetProps = $props();
|
|
28
|
+
|
|
29
|
+
let config: FlexiWidgetConfiguration = $state({
|
|
30
|
+
...propsConfig,
|
|
31
|
+
...(className !== undefined && { className }),
|
|
32
|
+
...(children !== undefined && { snippet: children })
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Callback so that we still fulfil these props.
|
|
36
|
+
function onWidgetCreated(widget: FlexiWidgetController) {
|
|
37
|
+
controller = widget;
|
|
38
|
+
onfirstcreate?.(widget);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
flexiwidget(config, onWidgetCreated);
|
|
42
|
+
|
|
43
|
+
// let derivedClassName = $derived.by(() => {
|
|
44
|
+
// if (typeof widget.className === 'function') {
|
|
45
|
+
// return widget.className(widget);
|
|
46
|
+
// }
|
|
47
|
+
|
|
48
|
+
// return widget.className;
|
|
49
|
+
// });
|
|
50
|
+
|
|
51
|
+
// let assistiveTextId = generateUniqueId();
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<!-- Only use noscript as an SSR fallback, because it won't look the same as the hydrated version. -->
|
|
55
|
+
<!-- <noscript style="display: contents;">
|
|
56
|
+
<div
|
|
57
|
+
class={derivedClassName}
|
|
58
|
+
aria-grabbed={widget.isGrabbed}
|
|
59
|
+
style={widget.style}
|
|
60
|
+
role="cell"
|
|
61
|
+
aria-label="Idle widget"
|
|
62
|
+
aria-colindex={widget.x}
|
|
63
|
+
aria-rowindex={widget.y}
|
|
64
|
+
aria-colspan={widget.width}
|
|
65
|
+
aria-rowspan={widget.height}
|
|
66
|
+
aria-describedby={assistiveTextId}
|
|
67
|
+
tabindex={0}
|
|
68
|
+
bind:this={widget.ref}
|
|
69
|
+
>
|
|
70
|
+
<span style={assistiveTextStyle} id={assistiveTextId}>
|
|
71
|
+
JavaScript is required to manipulate this widget.
|
|
72
|
+
</span>
|
|
73
|
+
{#if widget.snippet}
|
|
74
|
+
{@render widget.snippet({
|
|
75
|
+
widget
|
|
76
|
+
})}
|
|
77
|
+
{:else if widget.component}
|
|
78
|
+
<widget.component {...widget.componentProps ?? {}} />
|
|
79
|
+
{/if}
|
|
80
|
+
</div>
|
|
81
|
+
</noscript> -->
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { InternalFlexiWidgetController } from '../system/widget/controller.svelte.js';
|
|
3
|
-
import { renderedflexiwidget } from '../system/widget/index.js';
|
|
4
|
-
import WidgetTransitionPlaceholder from './widget-transition-placeholder.svelte';
|
|
5
|
-
|
|
6
|
-
export type RenderedFlexiWidgetProps = {
|
|
7
|
-
widget: InternalFlexiWidgetController;
|
|
8
|
-
};
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<script lang="ts">
|
|
12
|
-
let { widget }: RenderedFlexiWidgetProps = $props();
|
|
13
|
-
|
|
14
|
-
const { onpointerdown, onkeydown } = renderedflexiwidget(widget);
|
|
15
|
-
|
|
16
|
-
let derivedClassName = $derived.by(() => {
|
|
17
|
-
if (typeof widget.className === 'function') {
|
|
18
|
-
return widget.className(widget);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return widget.className;
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
let ariaLabel = $derived.by(() => {
|
|
25
|
-
if (widget.isShadow) {
|
|
26
|
-
return 'Widget action preview';
|
|
27
|
-
}
|
|
28
|
-
if (widget.draggable && widget.resizable) {
|
|
29
|
-
return 'Interactive widget';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return 'Static widget';
|
|
33
|
-
});
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<div
|
|
37
|
-
class={derivedClassName}
|
|
38
|
-
style={widget.style}
|
|
39
|
-
{onpointerdown}
|
|
40
|
-
{onkeydown}
|
|
41
|
-
aria-grabbed={widget.draggable && !widget.isShadow ? widget.isGrabbed : undefined}
|
|
42
|
-
aria-label={ariaLabel}
|
|
43
|
-
aria-dropeffect={widget.draggable ? 'move' : undefined}
|
|
44
|
-
role="cell"
|
|
45
|
-
aria-colindex={widget.x}
|
|
46
|
-
aria-rowindex={widget.y}
|
|
47
|
-
aria-colspan={widget.width}
|
|
48
|
-
aria-rowspan={widget.height}
|
|
49
|
-
tabindex={widget.draggable && !widget.hasGrabbers ? 0 : undefined}
|
|
50
|
-
bind:this={widget.ref}
|
|
51
|
-
>
|
|
52
|
-
{#if widget.snippet}
|
|
53
|
-
{@render widget.snippet({
|
|
54
|
-
widget
|
|
55
|
-
})}
|
|
56
|
-
{:else if widget.component}
|
|
57
|
-
<widget.component {...widget.componentProps ?? {}} />
|
|
58
|
-
{/if}
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<!-- When it exists, this temporarily occupies the widget's destination space, allowing the widget to be absolutely positioned to interpolate to its final destination. -->
|
|
62
|
-
{#if widget.shouldDrawPlaceholder}
|
|
63
|
-
<WidgetTransitionPlaceholder />
|
|
64
|
-
{/if}
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { InternalFlexiWidgetController } from '../system/widget/controller.svelte.js';
|
|
3
|
+
import { renderedflexiwidget } from '../system/widget/index.js';
|
|
4
|
+
import WidgetTransitionPlaceholder from './widget-transition-placeholder.svelte';
|
|
5
|
+
|
|
6
|
+
export type RenderedFlexiWidgetProps = {
|
|
7
|
+
widget: InternalFlexiWidgetController;
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
let { widget }: RenderedFlexiWidgetProps = $props();
|
|
13
|
+
|
|
14
|
+
const { onpointerdown, onkeydown } = renderedflexiwidget(widget);
|
|
15
|
+
|
|
16
|
+
let derivedClassName = $derived.by(() => {
|
|
17
|
+
if (typeof widget.className === 'function') {
|
|
18
|
+
return widget.className(widget);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return widget.className;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
let ariaLabel = $derived.by(() => {
|
|
25
|
+
if (widget.isShadow) {
|
|
26
|
+
return 'Widget action preview';
|
|
27
|
+
}
|
|
28
|
+
if (widget.draggable && widget.resizable) {
|
|
29
|
+
return 'Interactive widget';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return 'Static widget';
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div
|
|
37
|
+
class={derivedClassName}
|
|
38
|
+
style={widget.style}
|
|
39
|
+
{onpointerdown}
|
|
40
|
+
{onkeydown}
|
|
41
|
+
aria-grabbed={widget.draggable && !widget.isShadow ? widget.isGrabbed : undefined}
|
|
42
|
+
aria-label={ariaLabel}
|
|
43
|
+
aria-dropeffect={widget.draggable ? 'move' : undefined}
|
|
44
|
+
role="cell"
|
|
45
|
+
aria-colindex={widget.x}
|
|
46
|
+
aria-rowindex={widget.y}
|
|
47
|
+
aria-colspan={widget.width}
|
|
48
|
+
aria-rowspan={widget.height}
|
|
49
|
+
tabindex={widget.draggable && !widget.hasGrabbers ? 0 : undefined}
|
|
50
|
+
bind:this={widget.ref}
|
|
51
|
+
>
|
|
52
|
+
{#if widget.snippet}
|
|
53
|
+
{@render widget.snippet({
|
|
54
|
+
widget
|
|
55
|
+
})}
|
|
56
|
+
{:else if widget.component}
|
|
57
|
+
<widget.component {...widget.componentProps ?? {}} />
|
|
58
|
+
{/if}
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<!-- When it exists, this temporarily occupies the widget's destination space, allowing the widget to be absolutely positioned to interpolate to its final destination. -->
|
|
62
|
+
{#if widget.shouldDrawPlaceholder}
|
|
63
|
+
<WidgetTransitionPlaceholder />
|
|
64
|
+
{/if}
|