@svar-ui/svelte-toolbar 2.2.1

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.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 XB Software Sp. z o.o.
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/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@svar-ui/svelte-toolbar",
3
+ "version": "2.2.1",
4
+ "description": "Svelte toolbar component. Lightweight, customizable, easy-to-use.",
5
+ "productTag": "toolbar",
6
+ "productTrial": false,
7
+ "type": "module",
8
+ "scripts": {
9
+ "build": "vite build",
10
+ "build:dist": "vite build --mode dist",
11
+ "build:tests": "vite build --mode test",
12
+ "lint": "yarn eslint ./demos ./src",
13
+ "start": "vite --open",
14
+ "start:tests": "vite --open=/tests/ --host 0.0.0.0 --port 5100 --mode test",
15
+ "test": "true",
16
+ "test:cypress": "cypress run -P ./ --config \"baseUrl=http://localhost:5100/tests\""
17
+ },
18
+ "svelte": "src/index.js",
19
+ "exports": {
20
+ ".": {
21
+ "svelte": "./src/index.js"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/svar-widgets/toolbar.git"
29
+ },
30
+ "bugs": {
31
+ "url": "https://forum.svar.dev"
32
+ },
33
+ "homepage": "https://svar.dev/svelte/core/",
34
+ "dependencies": {
35
+ "@svar-ui/svelte-core": "2.2.1",
36
+ "@svar-ui/lib-dom": "0.9.2"
37
+ },
38
+ "files": [
39
+ "src",
40
+ "readme.md",
41
+ "whatsnew.md",
42
+ "license.txt"
43
+ ],
44
+ "keywords": [
45
+ "svelte",
46
+ "svelte toolbar",
47
+ "toolbar",
48
+ "toolbar component",
49
+ "buttons panel",
50
+ "svar widgets"
51
+ ]
52
+ }
package/readme.md ADDED
@@ -0,0 +1,67 @@
1
+ <div align="center">
2
+
3
+ # SVAR Svelte Toolbar
4
+
5
+ [![npm](https://img.shields.io/npm/v/wx-svelte-toolbar.svg)](https://www.npmjs.com/package/wx-svelte-toolbar)
6
+ [![License](https://img.shields.io/github/license/svar-widgets/toolbar)](https://github.com/svar-widgets/toolbar/blob/main/license.txt)
7
+ [![npm downloads](https://img.shields.io/npm/dm/wx-svelte-toolbar.svg)](https://www.npmjs.com/package/wx-svelte-toolbar)
8
+
9
+ </div>
10
+
11
+ <div align="center">
12
+
13
+ [Documentation](https://docs.svar.dev/svelte/core/toolbar/) • [Demos](https://docs.svar.dev/svelte/core/samples-toolbar/#/base/willow)
14
+
15
+ </div>
16
+
17
+ SVAR Toolbar is a Svelte UI component for building flexible button panels, from simple button sets to complex structures with numerous buttons and select boxes. It provides an easy way to organize and display multiple toolbar items, with support for multiline layouts and collapsible item groups that can be shown on demand.
18
+
19
+ ### How to Use
20
+
21
+ To use the widget, simply import the package and include the component in your Svelte file:
22
+
23
+ ```svelte
24
+ <script>
25
+ import { Toolbar } from "wx-svelte-toolbar";
26
+
27
+ function onClick(item) {
28
+ message = "Button '" + item.id + "' clicked";
29
+ }
30
+
31
+ let items = [
32
+ { id: "label", text: "Toolbar with icon buttons" },
33
+ {
34
+ id: "search",
35
+ comp: "button",
36
+ icon: "wxi-search",
37
+ handler: onClick,
38
+ },
39
+ ];
40
+ </script>
41
+
42
+ <Toolbar {items} />
43
+ ```
44
+
45
+ ### How to Modify
46
+
47
+ Typically, you don't need to modify the code. However, if you wish to do so, follow these steps:
48
+
49
+ 1. Run `yarn` to install dependencies. Note that this project is a monorepo using `yarn` workspaces, so npm will not work
50
+ 2. Start the project in development mode with `yarn start`
51
+
52
+ ### Run Tests
53
+
54
+ To run the test:
55
+
56
+ 1. Start the test examples with:
57
+ ```sh
58
+ yarn start:tests
59
+ ```
60
+ 2. In a separate console, run the end-to-end tests with:
61
+ ```sh
62
+ yarn test:cypress
63
+ ```
64
+
65
+ ### Need help?
66
+
67
+ Join our [community forum](https://forum.svar.dev/) to get help or post feature requests.
@@ -0,0 +1,29 @@
1
+ <script>
2
+ import { Button } from "@svar-ui/svelte-core";
3
+
4
+ let { icon, text = "", css, type, disabled, menu, onclick } = $props();
5
+ </script>
6
+
7
+ {#if menu}
8
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
9
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
10
+ <div class="wx-item" {onclick}>
11
+ <i class="{icon || 'wxi-empty'} {css || ''}"></i>
12
+ {text}
13
+ </div>
14
+ {:else}
15
+ <Button {icon} {type} {css} {text} {disabled} {onclick} />
16
+ {/if}
17
+
18
+ <style>
19
+ i {
20
+ margin-right: 8px;
21
+ font-size: var(--wx-button-icon-size);
22
+ color: var(--wx-icon-color);
23
+ }
24
+ .wx-item {
25
+ cursor: pointer;
26
+ white-space: nowrap;
27
+ line-height: 26px;
28
+ }
29
+ </style>
@@ -0,0 +1,33 @@
1
+ <script>
2
+ import { Button } from "@svar-ui/svelte-core";
3
+
4
+ let { icon, text, css, type, disabled, menu, onclick } = $props();
5
+ </script>
6
+
7
+ {#if menu}
8
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
9
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
10
+ <div class="wx-item" {onclick}>
11
+ {#if icon}<i class="{icon} {css}"></i>{/if}
12
+ {text}
13
+ </div>
14
+ {:else}
15
+ <Button {icon} {type} {css} title={text} {disabled} {onclick} />
16
+ {/if}
17
+
18
+ <style>
19
+ i {
20
+ margin-right: 8px;
21
+ font-size: var(--wx-icon-size);
22
+ color: var(--wx-color-font);
23
+ }
24
+ .wx-item {
25
+ cursor: pointer;
26
+ white-space: nowrap;
27
+ line-height: 36px;
28
+ height: 36px;
29
+ box-sizing: border-box;
30
+ display: flex;
31
+ align-items: center;
32
+ }
33
+ </style>
@@ -0,0 +1,40 @@
1
+ <script>
2
+ let { id = "", text = "", css = "", icon = "", onclick } = $props();
3
+
4
+ function handleClick() {
5
+ onclick && onclick({ id });
6
+ }
7
+ </script>
8
+
9
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
10
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
11
+ <div class="wx-label {css}" onclick={handleClick}>
12
+ {#if icon}
13
+ <i class={icon}></i>
14
+ {/if}
15
+ {text}
16
+ </div>
17
+
18
+ <style>
19
+ .wx-label {
20
+ width: 100%;
21
+ white-space: nowrap;
22
+ color: var(--wx-input-font-color);
23
+ padding: var(--wx-input-padding);
24
+ overflow: hidden;
25
+ cursor: pointer;
26
+ display: flex;
27
+ align-items: center;
28
+ }
29
+ i {
30
+ margin-right: 8px;
31
+ font-size: var(--wx-icon-size);
32
+ }
33
+
34
+ .wx-label:hover {
35
+ background-image: linear-gradient(
36
+ rgba(0, 0, 0, 0.1) 0%,
37
+ rgba(0, 0, 0, 0.1) 100%
38
+ );
39
+ }
40
+ </style>
@@ -0,0 +1,21 @@
1
+ <script>
2
+ const { text, value, children } = $props();
3
+ </script>
4
+
5
+ {#if children}
6
+ <div class="wx-label">
7
+ {@render children()}
8
+ </div>
9
+ {:else}
10
+ <div class="wx-label">{value || text}</div>
11
+ {/if}
12
+
13
+ <style>
14
+ .wx-label {
15
+ width: auto;
16
+ font-weight: var(--wx-label-font-weight);
17
+ color: var(--wx-input-font-color);
18
+ padding: var(--wx-input-padding);
19
+ overflow: hidden;
20
+ }
21
+ </style>
@@ -0,0 +1,24 @@
1
+ <script>
2
+ let { menu = false } = $props();
3
+ </script>
4
+
5
+ <div class="wx-separator{menu ? '-menu' : ''}">&nbsp;</div>
6
+
7
+ <style>
8
+ .wx-separator {
9
+ width: 1px;
10
+ min-height: 100%;
11
+ border-left: 1px solid rgba(0, 0, 0, 0.07);
12
+ border-right: var(--wx-border);
13
+
14
+ margin: 6px 4px;
15
+ box-sizing: border-box;
16
+ }
17
+ :global(.wx-column > .wx-tb-body) > .wx-separator,
18
+ .wx-separator-menu {
19
+ height: 1px;
20
+ width: 100%;
21
+ border-top: var(--wx-border-medium);
22
+ align-self: center;
23
+ }
24
+ </style>
@@ -0,0 +1,7 @@
1
+ <div class="wx-spacer"></div>
2
+
3
+ <style>
4
+ .wx-spacer {
5
+ flex-grow: 1;
6
+ }
7
+ </style>
@@ -0,0 +1,85 @@
1
+ <script>
2
+ import { getItemHandler } from "../helpers";
3
+ import Separator from "../buttons/Separator.svelte";
4
+ import Spacer from "../buttons/Spacer.svelte";
5
+
6
+ let { item = {}, menu = false, values, onclick, onchange } = $props();
7
+
8
+ let itemComponent = $derived(getItemHandler(item.comp || "label"));
9
+
10
+ function onClick() {
11
+ if (item.handler) item.handler(item);
12
+ onclick && onclick({ item });
13
+ }
14
+
15
+ let value = $derived(item.key ? values[item.key] : undefined);
16
+ function detectChange({ value }) {
17
+ if (item.handler) item.handler(item, value);
18
+ onchange && onchange({ value, item });
19
+ }
20
+
21
+ const text = $derived(menu ? item.menuText || item.text : item.text);
22
+ </script>
23
+
24
+ {#if item.comp == "spacer"}
25
+ <Spacer {menu} />
26
+ {:else if item.comp == "separator"}
27
+ <Separator {menu} />
28
+ {:else}
29
+ {@const SvelteComponent = itemComponent}
30
+ <div
31
+ class="wx-tb-element {item.css || ''}"
32
+ class:wx-spacer={item.spacer}
33
+ class:wx-menu={menu}
34
+ data-id={item.id}
35
+ >
36
+ <SvelteComponent
37
+ {value}
38
+ onchange={detectChange}
39
+ onclick={onClick}
40
+ {menu}
41
+ {...item}
42
+ {text}
43
+ />
44
+ </div>
45
+ {/if}
46
+
47
+ <style>
48
+ .wx-spacer {
49
+ flex: 1;
50
+ }
51
+ .wx-tb-element {
52
+ padding: 4px;
53
+ flex-shrink: 0;
54
+ align-self: center;
55
+ display: flex;
56
+ }
57
+ .wx-menu.wx-tb-element {
58
+ height: 36px;
59
+ line-height: 36px;
60
+ padding: 2px 8px;
61
+ background-color: var(--wx-background);
62
+ }
63
+
64
+ .wx-menu :global(button) {
65
+ width: 100%;
66
+ background: transparent;
67
+ text-align: left;
68
+ padding-left: 0;
69
+ font-weight: var(--wx-font-weight);
70
+ font-size: var(--wx-font-size);
71
+ }
72
+ .wx-menu :global(.wx-tb-element) {
73
+ align-self: stretch;
74
+ }
75
+ .wx-menu.wx-tb-element :global(button:hover) {
76
+ background: var(--wx-background-alt);
77
+ }
78
+ .wx-menu :global(button i) {
79
+ margin-right: 4px;
80
+ font-size: var(--wx-icon-size);
81
+ }
82
+ .wx-menu.wx-tb-element:hover {
83
+ background: var(--wx-background-alt);
84
+ }
85
+ </style>
@@ -0,0 +1,117 @@
1
+ <script>
2
+ import Group from "./Group.svelte";
3
+
4
+ import BarComponent from "./BarComponent.svelte";
5
+ import { Dropdown } from "@svar-ui/svelte-core";
6
+
7
+ let { item, values = null, menu = false, onchange, onclick } = $props();
8
+
9
+ let collapsedState = $state(true);
10
+
11
+ const onClick = ev => {
12
+ oncancel();
13
+ onclick && onclick(ev);
14
+ };
15
+
16
+ const show = () => (collapsedState = false);
17
+ const oncancel = () => (collapsedState = true);
18
+ </script>
19
+
20
+ <div
21
+ class="wx-tb-group {item.css || ''}"
22
+ class:wx-column={item.layout == "column"}
23
+ class:wx-group-collapsed={item.collapsed && !menu}
24
+ >
25
+ {#if item.collapsed && !menu}
26
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
27
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
28
+ <div class="wx-collapsed" onclick={show}>
29
+ {#if item.icon}<i class="icon {item.icon}"></i>{/if}
30
+ {#if item.text}
31
+ <div class="wx-label-text">{item.text}</div>
32
+ {/if}
33
+ {#if item.text && !item.icon}
34
+ <i class="wx-label-arrow wxi-angle-down"></i>
35
+ {/if}
36
+ </div>
37
+ {#if !collapsedState}
38
+ <Dropdown width="" {oncancel}>
39
+ <div class="wx-drop-group">
40
+ <Group
41
+ item={{ ...item, text: "", collapsed: false }}
42
+ {values}
43
+ {menu}
44
+ {onchange}
45
+ onclick={onClick}
46
+ />
47
+ </div>
48
+ </Dropdown>
49
+ {/if}
50
+ {:else}
51
+ <div class="wx-tb-body">
52
+ {#each item.items as sub}
53
+ {#if sub.items}
54
+ <Group item={sub} {values} onclick={onClick} {onchange} />
55
+ {:else}
56
+ <BarComponent
57
+ item={sub}
58
+ {values}
59
+ onclick={onClick}
60
+ {onchange}
61
+ />
62
+ {/if}
63
+ {/each}
64
+ </div>
65
+ {#if item.text}
66
+ <div class="wx-label">{item.text}</div>
67
+ {/if}
68
+ {/if}
69
+ </div>
70
+
71
+ <style>
72
+ .wx-tb-group {
73
+ position: relative;
74
+ display: flex;
75
+ flex-flow: column;
76
+ }
77
+ .wx-group-collapsed {
78
+ flex-flow: row;
79
+ }
80
+ .wx-collapsed {
81
+ display: flex;
82
+ padding: 10px;
83
+ flex-flow: row;
84
+ cursor: pointer;
85
+ }
86
+ .wx-group-collapsed .wx-collapsed {
87
+ align-items: center;
88
+ }
89
+
90
+ .wx-label {
91
+ font-weight: var(--wx-label-font-weight);
92
+ font-size: var(--wx-font-size-sm);
93
+ color: var(--wx-color-font);
94
+ text-align: center;
95
+ display: flex;
96
+ padding: 4px 2px 4px 12px;
97
+ align-items: center;
98
+ justify-content: center;
99
+ width: 100%;
100
+ }
101
+ .wx-tb-group :global(.wx-dropdown) {
102
+ overflow: inherit;
103
+ }
104
+ .wx-column {
105
+ align-items: stretch;
106
+ }
107
+ .wx-column :global(.wx-tb-element) {
108
+ align-self: stretch;
109
+ }
110
+ .wx-tb-body {
111
+ height: 100%;
112
+ display: flex;
113
+ }
114
+ .wx-column > .wx-tb-body {
115
+ flex-flow: column;
116
+ }
117
+ </style>
@@ -0,0 +1,66 @@
1
+ <script>
2
+ import BarComponent from "./BarComponent.svelte";
3
+ import Group from "./Group.svelte";
4
+ import { Dropdown, Button } from "@svar-ui/svelte-core";
5
+
6
+ let { items = [], css, values, width, onclick, onchange } = $props();
7
+
8
+ let popup = $state();
9
+ let div = $state();
10
+
11
+ function oncancel() {
12
+ popup = null;
13
+ }
14
+ function showMenu() {
15
+ popup = true;
16
+ }
17
+ function menuClick(ev) {
18
+ oncancel();
19
+ onclick && onclick(ev);
20
+ }
21
+ </script>
22
+
23
+ <div class="wx-menu {css || ''}" bind:this={div} data-id="$menu">
24
+ <Button icon="wxi-dots-h" onclick={showMenu} />
25
+ {#if popup}
26
+ <Dropdown width="{width}px" {oncancel}>
27
+ <div class="wx-drop-menu">
28
+ {#each items as item}
29
+ {#if item.items}
30
+ <Group
31
+ {item}
32
+ {values}
33
+ menu={true}
34
+ onclick={menuClick}
35
+ {onchange}
36
+ />
37
+ {:else}
38
+ <BarComponent
39
+ {item}
40
+ {values}
41
+ menu={true}
42
+ onclick={menuClick}
43
+ {onchange}
44
+ />
45
+ {/if}
46
+ {/each}
47
+ </div>
48
+ </Dropdown>
49
+ {/if}
50
+ </div>
51
+
52
+ <style>
53
+ .wx-menu {
54
+ position: absolute;
55
+ overflow: visible;
56
+ padding: 4px;
57
+ right: 4px;
58
+ }
59
+
60
+ .wx-menu :global(.wx-dropdown) {
61
+ overflow: visible;
62
+ }
63
+ .wx-drop-menu {
64
+ padding: 4px;
65
+ }
66
+ </style>
@@ -0,0 +1,185 @@
1
+ <script>
2
+ import Menu from "./Menu.svelte";
3
+ import Group from "./Group.svelte";
4
+ import BarComponent from "./BarComponent.svelte";
5
+
6
+ import { uid } from "@svar-ui/lib-dom";
7
+ import { onMount, tick } from "svelte";
8
+
9
+ let {
10
+ items = $bindable([]),
11
+ menuCss = "",
12
+ css,
13
+ values = $bindable(null),
14
+ overflow = "menu",
15
+ onclick,
16
+ onchange,
17
+ } = $props();
18
+
19
+ function handleChange(ev) {
20
+ if (values) {
21
+ values[ev.item.key] = ev.value;
22
+ values = values;
23
+ }
24
+ onchange && onchange(ev);
25
+ }
26
+
27
+ let div = null;
28
+ let lastToolbarState = -1;
29
+ let menuItems = $state([]);
30
+
31
+ function processOverflow() {
32
+ if (overflow === "wrap") return;
33
+
34
+ const visibleWidth = div.clientWidth;
35
+ const fullWidth = div.scrollWidth;
36
+ const needMenu = fullWidth > visibleWidth;
37
+
38
+ if (needMenu) {
39
+ if (overflow === "collapse") return collapseGroups(visibleWidth);
40
+ // we need to decide how many nodes need to be
41
+ const nodes = div.children;
42
+ let sum = 0;
43
+
44
+ for (let i = 0; i < items.length; i++) {
45
+ sum += nodes[i].clientWidth;
46
+ if (items[i].comp == "separator") sum += 8;
47
+ if (sum > visibleWidth - 40) {
48
+ // skip updates, as visibility state was not changed
49
+ if (lastToolbarState === i) return;
50
+ lastToolbarState = i;
51
+
52
+ // we need to hide nodes[i] and all next nodes
53
+ menuItems = [];
54
+ for (let j = i; j < items.length; j++) {
55
+ menuItems.push(items[j]);
56
+ nodes[j].style.visibility = "hidden";
57
+ }
58
+ // hide the ending separator
59
+ if (i > 0 && items[i - 1].comp == "separator") {
60
+ nodes[i - 1].style.visibility = "hidden";
61
+ }
62
+ break;
63
+ }
64
+ nodes[i].style.visibility = "";
65
+ }
66
+ } else {
67
+ const freeWidth = visibleWidth - getTotalWidth();
68
+ if (freeWidth <= 0) return;
69
+ if (overflow === "collapse") return expandGroups(freeWidth);
70
+
71
+ if (menuItems.length) {
72
+ lastToolbarState = null;
73
+ const nodes = div.children;
74
+ for (let i = 0; i < items.length; i++) {
75
+ nodes[i].style.visibility = "";
76
+ }
77
+ menuItems = [];
78
+ }
79
+ }
80
+ }
81
+
82
+ function getTotalWidth() {
83
+ const nodes = div.children;
84
+ let sum = 0;
85
+ for (let i = 0; i < items.length; i++) {
86
+ if (items[i].comp != "spacer") {
87
+ sum += nodes[i].clientWidth;
88
+ if (items[i].comp == "separator") sum += 8;
89
+ }
90
+ }
91
+ return sum;
92
+ }
93
+
94
+ function collapseGroups() {
95
+ for (let i = items.length - 1; i >= 0; i--) {
96
+ // close rightmost open group
97
+ if (items[i].items && !items[i].collapsed) {
98
+ items[i].collapsed = true;
99
+ items[i].$width = div.children[i].offsetWidth;
100
+ // check after dom update, maybe we need to close more
101
+ tick().then(processOverflow);
102
+
103
+ // items are not deep reactive, so we need to trigger the update
104
+ items = [...items];
105
+ return;
106
+ }
107
+ }
108
+ }
109
+
110
+ function expandGroups(freeSpace) {
111
+ for (let i = 0; i < items.length; i++) {
112
+ // close leftmost closed group, that was closed previously
113
+ if (items[i].collapsed && items[i].$width) {
114
+ // check if group can fit in free space
115
+ if (
116
+ items[i].$width - div.children[i].offsetWidth <
117
+ freeSpace + 10
118
+ ) {
119
+ items[i].collapsed = false;
120
+ // check after dom update, maybe we can open one more
121
+ tick().then(processOverflow);
122
+ }
123
+
124
+ items = [...items];
125
+ return;
126
+ }
127
+ }
128
+ }
129
+
130
+ // rebuild toolbar items, inject group nodes
131
+ function normalize(items) {
132
+ items.forEach(item => {
133
+ if (!item.id) item.id = uid();
134
+ });
135
+ return items;
136
+ }
137
+
138
+ onMount(() => {
139
+ const resizeObserver = new ResizeObserver(() => processOverflow(div));
140
+ resizeObserver.observe(div);
141
+
142
+ return () => {
143
+ if (resizeObserver) resizeObserver.unobserve(div);
144
+ };
145
+ });
146
+
147
+ const visibleItems = $derived(normalize(items));
148
+ </script>
149
+
150
+ <div
151
+ class="wx-toolbar {css}"
152
+ class:wx-wrap={overflow === "wrap"}
153
+ bind:this={div}
154
+ >
155
+ {#each visibleItems as item}
156
+ {#if item.items}
157
+ <Group {item} {values} {onclick} onchange={handleChange} />
158
+ {:else}
159
+ <BarComponent {item} {values} {onclick} onchange={handleChange} />
160
+ {/if}
161
+ {/each}
162
+ {#if menuItems.length}
163
+ <Menu
164
+ items={menuItems}
165
+ css={menuCss}
166
+ {values}
167
+ {onclick}
168
+ onchange={handleChange}
169
+ />
170
+ {/if}
171
+ </div>
172
+
173
+ <style>
174
+ .wx-toolbar {
175
+ width: 100%;
176
+ flex-wrap: nowrap;
177
+ display: flex;
178
+ align-items: stretch;
179
+ padding: 4px;
180
+ position: relative;
181
+ }
182
+ .wx-toolbar.wx-wrap {
183
+ flex-wrap: wrap;
184
+ }
185
+ </style>
package/src/helpers.js ADDED
@@ -0,0 +1,7 @@
1
+ const handlers = {};
2
+ export function getItemHandler(type) {
3
+ return handlers[type] || type;
4
+ }
5
+ export function registerToolbarItem(type, handler) {
6
+ handlers[type] = handler;
7
+ }
package/src/index.js ADDED
@@ -0,0 +1,18 @@
1
+ import Toolbar from "./components/Toolbar.svelte";
2
+ import { registerToolbarItem } from "./helpers.js";
3
+
4
+ import Separator from "./buttons/Separator.svelte";
5
+ import Spacer from "./buttons/Spacer.svelte";
6
+ import Button from "./buttons/Button.svelte";
7
+ import Label from "./buttons/Label.svelte";
8
+ import Icon from "./buttons/Icon.svelte";
9
+ import Item from "./buttons/Item.svelte";
10
+
11
+ registerToolbarItem("button", Button);
12
+ registerToolbarItem("separator", Separator);
13
+ registerToolbarItem("spacer", Spacer);
14
+ registerToolbarItem("label", Label);
15
+ registerToolbarItem("item", Item);
16
+ registerToolbarItem("icon", Icon);
17
+
18
+ export { Toolbar, registerToolbarItem };
package/whatsnew.md ADDED
@@ -0,0 +1,67 @@
1
+ ## 2.2.1
2
+
3
+ ### Fixes
4
+
5
+ - Using in Salesforce environment
6
+
7
+ ## 2.2.0
8
+
9
+ - Using core@2.2.0
10
+
11
+ ## 2.1.0
12
+
13
+ - Using core@2.1.0
14
+
15
+ ## 2.0.1
16
+
17
+ ### New features
18
+
19
+ - Svelte 5 support
20
+
21
+ ## 1.3.0
22
+
23
+ - Using core@1.3.0
24
+
25
+ ## 1.2.3
26
+
27
+ ### Fixes
28
+
29
+ - Regression in overflow menu closing
30
+ - Regression in dropdown rendering
31
+
32
+ ## 1.2.1
33
+
34
+ - Using core@1.2.0
35
+
36
+ ## 1.2.1
37
+
38
+ ### New features
39
+
40
+ - Labels can be bound to data
41
+
42
+ ## 1.2.0
43
+
44
+ ### New features
45
+
46
+ - Extra demo for the HeaderMenu scenario
47
+ - Ability to use `spacer` on toolbar items
48
+ - Ability to use `item` subtype for the drop-down menus
49
+
50
+ ### Fixes
51
+
52
+ - Separator rendering in drop-down menus
53
+ - Names of css classes corrected
54
+
55
+ ## 1.1.2
56
+
57
+ ### Updates
58
+
59
+ - Inner css classes renamed, "wx" prefix added
60
+
61
+ ## 1.1.1
62
+
63
+ - Migrated to vite based toolchain
64
+
65
+ ### 1.1.0
66
+
67
+ - Initial version