@onsvisual/svelte-components 1.0.24 → 1.0.26
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/dist/css/main.css +4 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +10 -0
- package/dist/inputs/ButtonGroup/ButtonGroup.stories.svelte +40 -0
- package/dist/inputs/ButtonGroup/ButtonGroup.stories.svelte.d.ts +23 -0
- package/dist/inputs/ButtonGroup/ButtonGroup.svelte +57 -0
- package/dist/inputs/ButtonGroup/ButtonGroup.svelte.d.ts +27 -0
- package/dist/inputs/ButtonGroup/ButtonGroupItem.svelte +101 -0
- package/dist/inputs/ButtonGroup/ButtonGroupItem.svelte.d.ts +23 -0
- package/dist/inputs/ButtonGroup/docs/component.md +21 -0
- package/dist/inputs/Toolbar/HelpModal.svelte +234 -0
- package/dist/inputs/Toolbar/HelpModal.svelte.d.ts +16 -0
- package/dist/inputs/Toolbar/Icon.svelte +106 -0
- package/dist/inputs/Toolbar/Icon.svelte.d.ts +23 -0
- package/dist/inputs/Toolbar/ToolControl.svelte +23 -0
- package/dist/inputs/Toolbar/ToolControl.svelte.d.ts +27 -0
- package/dist/inputs/Toolbar/ToolControls.svelte +9 -0
- package/dist/inputs/Toolbar/ToolControls.svelte.d.ts +27 -0
- package/dist/inputs/Toolbar/Toolbar.stories.svelte +148 -0
- package/dist/inputs/Toolbar/Toolbar.stories.svelte.d.ts +23 -0
- package/dist/inputs/Toolbar/Toolbar.svelte +70 -0
- package/dist/inputs/Toolbar/Toolbar.svelte.d.ts +29 -0
- package/dist/inputs/Toolbar/ToolbarButton.svelte +184 -0
- package/dist/inputs/Toolbar/ToolbarButton.svelte.d.ts +19 -0
- package/dist/inputs/Toolbar/ToolbarDivider.svelte +29 -0
- package/dist/inputs/Toolbar/ToolbarDivider.svelte.d.ts +14 -0
- package/dist/inputs/Toolbar/ToolbarsContainer.svelte +69 -0
- package/dist/inputs/Toolbar/ToolbarsContainer.svelte.d.ts +19 -0
- package/dist/inputs/Toolbar/docs/component.md +99 -0
- package/dist/inputs/Toolbar/img/movepan.png +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
click: CustomEvent<any>;
|
|
6
|
+
} & {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
custom: {};
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type ToolbarButtonProps = typeof __propDef.props;
|
|
15
|
+
export type ToolbarButtonEvents = typeof __propDef.events;
|
|
16
|
+
export type ToolbarButtonSlots = typeof __propDef.slots;
|
|
17
|
+
export default class ToolbarButton extends SvelteComponentTyped<ToolbarButtonProps, ToolbarButtonEvents, ToolbarButtonSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
|
|
4
|
+
let { classes = "" }: { classes?: string } = $props();
|
|
5
|
+
|
|
6
|
+
// Get the orientation store from context
|
|
7
|
+
const orientationStore = getContext("orientation");
|
|
8
|
+
|
|
9
|
+
// Subscribe to the store to get its value
|
|
10
|
+
const orientation = $derived(orientationStore);
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class={`toolbar-divider ${$orientation} ${classes}`} aria-hidden="true"></div>
|
|
14
|
+
|
|
15
|
+
<style>
|
|
16
|
+
.toolbar-divider {
|
|
17
|
+
background-color: #ccc;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.toolbar-divider.horizontal {
|
|
21
|
+
width: 1px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.toolbar-divider.vertical {
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 1px;
|
|
27
|
+
margin: 0.5rem 0;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type ToolbarDividerProps = typeof __propDef.props;
|
|
10
|
+
export type ToolbarDividerEvents = typeof __propDef.events;
|
|
11
|
+
export type ToolbarDividerSlots = typeof __propDef.slots;
|
|
12
|
+
export default class ToolbarDivider extends SvelteComponentTyped<ToolbarDividerProps, ToolbarDividerEvents, ToolbarDividerSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { setContext, onMount } from "svelte";
|
|
3
|
+
import { writable } from "svelte/store";
|
|
4
|
+
|
|
5
|
+
// Initialize a store for button IDs
|
|
6
|
+
const buttonIds = writable([]);
|
|
7
|
+
setContext("buttonIds", {
|
|
8
|
+
register: (id: string) => {
|
|
9
|
+
buttonIds.update((ids) => [...ids, id]);
|
|
10
|
+
},
|
|
11
|
+
unregister: (id: string) => {
|
|
12
|
+
buttonIds.update((ids) => ids.filter((btnId) => btnId !== id));
|
|
13
|
+
},
|
|
14
|
+
buttonIds
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
let showHelpState = $state(true);
|
|
18
|
+
|
|
19
|
+
$effect(() => {
|
|
20
|
+
const sessionValue = sessionStorage.getItem("showHelpModals");
|
|
21
|
+
const localValue = localStorage.getItem("showHelpModals");
|
|
22
|
+
showHelpState = sessionValue === "false" ? false : localValue === "false" ? false : true;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const showHelpModals = writable(showHelpState);
|
|
26
|
+
// Set context for showHelpModals
|
|
27
|
+
setContext("showHelpModals", showHelpModals);
|
|
28
|
+
|
|
29
|
+
// Reactively update the initial state
|
|
30
|
+
$effect(() => {
|
|
31
|
+
showHelpModals.set(showHelpState);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const activeModalStore = writable(null); // Tracks the ID of the active modal
|
|
35
|
+
setContext("activeModalId", activeModalStore);
|
|
36
|
+
|
|
37
|
+
onMount(() => {
|
|
38
|
+
window.addEventListener("beforeunload", () => {
|
|
39
|
+
sessionStorage.removeItem("showHelpModals");
|
|
40
|
+
});
|
|
41
|
+
let unsubscribe = buttonIds.subscribe((ids) => {
|
|
42
|
+
if (ids.length > 0) {
|
|
43
|
+
activeModalStore.set(ids[0]); // Set first button as active
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return unsubscribe;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export function resetHelp() {
|
|
51
|
+
sessionStorage.setItem("showHelpModals", "true");
|
|
52
|
+
showHelpModals.set(true);
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<div class="multi-toolbar-container">
|
|
57
|
+
<slot />
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<style>
|
|
61
|
+
.multi-toolbar-container {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: row;
|
|
64
|
+
gap: 1rem;
|
|
65
|
+
justify-content: space-between;
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
flex-wrap: wrap;
|
|
68
|
+
}
|
|
69
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
resetHelp?: () => void;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
default: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type ToolbarsContainerProps = typeof __propDef.props;
|
|
14
|
+
export type ToolbarsContainerEvents = typeof __propDef.events;
|
|
15
|
+
export type ToolbarsContainerSlots = typeof __propDef.slots;
|
|
16
|
+
export default class ToolbarsContainer extends SvelteComponentTyped<ToolbarsContainerProps, ToolbarsContainerEvents, ToolbarsContainerSlots> {
|
|
17
|
+
get resetHelp(): () => void;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
A toolbar component. Use `ToolbarsContainer` even if using one toolbar as it contains a store for all the IDs and the activeID.
|
|
2
|
+
|
|
3
|
+
There's a slot on ToolbarButton if you want to put in custom help text otherwise, there's the prop `helpText`.
|
|
4
|
+
|
|
5
|
+
Each `ToolControl` will display content underneath the row of buttons. The `id` needs to match the `id` of the button.
|
|
6
|
+
|
|
7
|
+
Use the prop `hasAriaControls` on a button to link the controls to the button.
|
|
8
|
+
|
|
9
|
+
<!-- prettier-ignore -->
|
|
10
|
+
```html
|
|
11
|
+
<script>
|
|
12
|
+
import { ToolbarsContainer,Toolbar,ToolbarButton, ToolbarDivider,ToolControls,ToolControl, HelpModal } from "@onsvisual/svelte-components";
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<ToolbarsContainer>
|
|
16
|
+
|
|
17
|
+
<Toolbar orientation="horizontal">
|
|
18
|
+
<ToolbarButton icon="polygon" label="Draw a polygon" helpText="Draw a polygon on the map" hasAriaControls>
|
|
19
|
+
<HelpModal>
|
|
20
|
+
<h3>Detailed Help</h3>
|
|
21
|
+
<p>More complex help text or even HTML content</p>
|
|
22
|
+
<ul>
|
|
23
|
+
<li>With lists</li>
|
|
24
|
+
<li>Or other elements</li>
|
|
25
|
+
</ul>
|
|
26
|
+
</HelpModal>
|
|
27
|
+
</ToolbarButton>
|
|
28
|
+
<ToolbarButton
|
|
29
|
+
icon="radius"
|
|
30
|
+
label="Draw a circle"
|
|
31
|
+
helpText="Draw a circle using this tool"
|
|
32
|
+
/>
|
|
33
|
+
<ToolbarDivider />
|
|
34
|
+
<ToolbarButton
|
|
35
|
+
icon="zoomin"
|
|
36
|
+
label="Zoom in"
|
|
37
|
+
/>
|
|
38
|
+
<ToolbarButton icon="zoomout" label="Zoom out" />
|
|
39
|
+
<ToolControls>
|
|
40
|
+
<ToolControl id="polygon">
|
|
41
|
+
<p>Text to display when polygon tool is selected, or even an input</p>
|
|
42
|
+
</ToolControl>
|
|
43
|
+
</Toolbar>
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// Second toolbar
|
|
47
|
+
<Toolbar>
|
|
48
|
+
<ToolbarButton id="upload" icon="upload"/>
|
|
49
|
+
<ToolbarButton id="download" icon="download"/>
|
|
50
|
+
</Toolbar>
|
|
51
|
+
</ToolbarsContainer>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Sticky buttons
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<ToolbarsContainer>
|
|
58
|
+
<Toolbar>
|
|
59
|
+
<ToolbarButton id="move" icon="move" label="Move and Pan" sticky />
|
|
60
|
+
<ToolbarButton id="polygon" icon="polygon" label="Draw a polygon" sticky />
|
|
61
|
+
<ToolbarButton id="circle" icon="radius" label="Draw a circle" sticky />
|
|
62
|
+
</Toolbar>
|
|
63
|
+
</ToolbarsContainer>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Transient buttons
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<ToolbarsContainer>
|
|
70
|
+
<Toolbar>
|
|
71
|
+
<ToolbarButton
|
|
72
|
+
id="zoomin"
|
|
73
|
+
icon="zoomin"
|
|
74
|
+
label="Zoom in"
|
|
75
|
+
transient="{true}"
|
|
76
|
+
selected="{false}"
|
|
77
|
+
/>
|
|
78
|
+
<ToolbarButton id="zoomout" icon="zoomout" label="zoom out" transient />
|
|
79
|
+
</Toolbar>
|
|
80
|
+
</ToolbarsContainer>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## No help modal
|
|
84
|
+
|
|
85
|
+
```html
|
|
86
|
+
<ToolbarsContainer>
|
|
87
|
+
<Toolbar>
|
|
88
|
+
<ToolbarButton
|
|
89
|
+
id="zoomin"
|
|
90
|
+
icon="zoomin"
|
|
91
|
+
label="Zoom in"
|
|
92
|
+
transient="{true}"
|
|
93
|
+
selected="{false}"
|
|
94
|
+
disableHelp="{true}"
|
|
95
|
+
/>
|
|
96
|
+
<ToolbarButton id="zoomout" icon="zoomout" label="zoom out" disableHelp="{true}" transient />
|
|
97
|
+
</Toolbar>
|
|
98
|
+
</ToolbarsContainer>
|
|
99
|
+
```
|
|
Binary file
|