@unofficialbox/box-open-elements-svelte 0.7.0
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 +21 -0
- package/README.md +24 -0
- package/dist/Button.svelte +41 -0
- package/dist/Button.svelte.d.ts +15 -0
- package/dist/Dialog.svelte +64 -0
- package/dist/Dialog.svelte.d.ts +21 -0
- package/dist/Select.svelte +57 -0
- package/dist/Select.svelte.d.ts +25 -0
- package/dist/TextField.svelte +56 -0
- package/dist/TextField.svelte.d.ts +21 -0
- package/dist/explorer-selection.d.ts +6 -0
- package/dist/explorer-selection.js +10 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 box-open-elements contributors
|
|
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
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @unofficialbox/box-open-elements-svelte
|
|
2
|
+
|
|
3
|
+
Typed Svelte 5 wrappers for `box-open-elements`, including explicit structured
|
|
4
|
+
property sync, callback props for custom events, bindable element refs, and a
|
|
5
|
+
selection-controller readable store.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @unofficialbox/box-open-elements @unofficialbox/box-open-elements-svelte svelte
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Select, TextField } from "@unofficialbox/box-open-elements-svelte";
|
|
14
|
+
const options = [{ label: "Draft", value: "draft" }];
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<TextField value="Apollo" onValueChanged={(event) => console.log(event.detail.value)} />
|
|
18
|
+
<Select {options} />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`createExplorerSelectionStore(controller)` exposes the shared selection
|
|
22
|
+
controller as a standard readable store. Version `0.1.0` is a release candidate;
|
|
23
|
+
Supported status follows the first public lockstep adapter release and clean
|
|
24
|
+
registry-install verification.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { Button as ButtonElement } from "@unofficialbox/box-open-elements/button";
|
|
4
|
+
|
|
5
|
+
ButtonElement.register();
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
element?: ButtonElement;
|
|
9
|
+
label?: string;
|
|
10
|
+
tone?: string;
|
|
11
|
+
size?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onClick?: (event: MouseEvent) => void;
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
element = $bindable(),
|
|
20
|
+
label,
|
|
21
|
+
tone,
|
|
22
|
+
size,
|
|
23
|
+
disabled = false,
|
|
24
|
+
onClick,
|
|
25
|
+
children,
|
|
26
|
+
...rest
|
|
27
|
+
}: Props = $props();
|
|
28
|
+
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<box-button
|
|
32
|
+
bind:this={element}
|
|
33
|
+
{...rest}
|
|
34
|
+
{label}
|
|
35
|
+
{tone}
|
|
36
|
+
{size}
|
|
37
|
+
{disabled}
|
|
38
|
+
onclick={onClick}
|
|
39
|
+
>
|
|
40
|
+
{@render children?.()}
|
|
41
|
+
</box-button>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import { Button as ButtonElement } from "@unofficialbox/box-open-elements/button";
|
|
3
|
+
type Props = {
|
|
4
|
+
element?: ButtonElement;
|
|
5
|
+
label?: string;
|
|
6
|
+
tone?: string;
|
|
7
|
+
size?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onClick?: (event: MouseEvent) => void;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
declare const Button: import("svelte").Component<Props, {}, "element">;
|
|
14
|
+
type Button = ReturnType<typeof Button>;
|
|
15
|
+
export default Button;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { Dialog as DialogElement } from "@unofficialbox/box-open-elements/dialog";
|
|
4
|
+
|
|
5
|
+
DialogElement.register();
|
|
6
|
+
|
|
7
|
+
type DialogSize = "small" | "medium" | "large" | "fullscreen";
|
|
8
|
+
type Props = {
|
|
9
|
+
element?: DialogElement;
|
|
10
|
+
open?: boolean;
|
|
11
|
+
heading?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
confirmLabel?: string;
|
|
14
|
+
size?: DialogSize;
|
|
15
|
+
onOpenChanged?: (event: CustomEvent<{ open: boolean }>) => void;
|
|
16
|
+
onConfirm?: (event: CustomEvent<null>) => void;
|
|
17
|
+
onCancel?: (event: CustomEvent<null>) => void;
|
|
18
|
+
children?: Snippet;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
element = $bindable(),
|
|
24
|
+
open = false,
|
|
25
|
+
heading,
|
|
26
|
+
description,
|
|
27
|
+
confirmLabel,
|
|
28
|
+
size,
|
|
29
|
+
onOpenChanged,
|
|
30
|
+
onConfirm,
|
|
31
|
+
onCancel,
|
|
32
|
+
children,
|
|
33
|
+
...rest
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
$effect(() => {
|
|
37
|
+
if (!element) return;
|
|
38
|
+
const bindings: Array<[string, EventListener | undefined]> = [
|
|
39
|
+
["open-changed", onOpenChanged as EventListener | undefined],
|
|
40
|
+
["confirm", onConfirm as EventListener | undefined],
|
|
41
|
+
["cancel", onCancel as EventListener | undefined],
|
|
42
|
+
];
|
|
43
|
+
for (const [eventName, listener] of bindings) {
|
|
44
|
+
if (listener) element.addEventListener(eventName, listener);
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
for (const [eventName, listener] of bindings) {
|
|
48
|
+
if (listener) element?.removeEventListener(eventName, listener);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<box-dialog
|
|
55
|
+
bind:this={element}
|
|
56
|
+
{...rest}
|
|
57
|
+
{open}
|
|
58
|
+
{heading}
|
|
59
|
+
{description}
|
|
60
|
+
{confirmLabel}
|
|
61
|
+
{size}
|
|
62
|
+
>
|
|
63
|
+
{@render children?.()}
|
|
64
|
+
</box-dialog>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import { Dialog as DialogElement } from "@unofficialbox/box-open-elements/dialog";
|
|
3
|
+
type DialogSize = "small" | "medium" | "large" | "fullscreen";
|
|
4
|
+
type Props = {
|
|
5
|
+
element?: DialogElement;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
heading?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
confirmLabel?: string;
|
|
10
|
+
size?: DialogSize;
|
|
11
|
+
onOpenChanged?: (event: CustomEvent<{
|
|
12
|
+
open: boolean;
|
|
13
|
+
}>) => void;
|
|
14
|
+
onConfirm?: (event: CustomEvent<null>) => void;
|
|
15
|
+
onCancel?: (event: CustomEvent<null>) => void;
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
declare const Dialog: import("svelte").Component<Props, {}, "element">;
|
|
20
|
+
type Dialog = ReturnType<typeof Dialog>;
|
|
21
|
+
export default Dialog;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { Select as SelectElement } from "@unofficialbox/box-open-elements/select";
|
|
4
|
+
|
|
5
|
+
SelectElement.register();
|
|
6
|
+
|
|
7
|
+
type SelectOption = { label: string; value: string };
|
|
8
|
+
type ValueChangedEvent = CustomEvent<{ value: string }>;
|
|
9
|
+
type Props = {
|
|
10
|
+
element?: SelectElement;
|
|
11
|
+
label?: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
options?: SelectOption[];
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
name?: string;
|
|
16
|
+
invalid?: boolean;
|
|
17
|
+
errorMessage?: string;
|
|
18
|
+
onValueChanged?: (event: ValueChangedEvent) => void;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
element = $bindable(),
|
|
25
|
+
label,
|
|
26
|
+
value,
|
|
27
|
+
options,
|
|
28
|
+
disabled = false,
|
|
29
|
+
name,
|
|
30
|
+
invalid = false,
|
|
31
|
+
errorMessage,
|
|
32
|
+
onValueChanged,
|
|
33
|
+
children,
|
|
34
|
+
...rest
|
|
35
|
+
}: Props = $props();
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
if (!element || !onValueChanged) return;
|
|
39
|
+
const listener = onValueChanged as EventListener;
|
|
40
|
+
element.addEventListener("value-changed", listener);
|
|
41
|
+
return () => element?.removeEventListener("value-changed", listener);
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<box-select
|
|
46
|
+
bind:this={element}
|
|
47
|
+
{...rest}
|
|
48
|
+
{label}
|
|
49
|
+
{value}
|
|
50
|
+
{options}
|
|
51
|
+
{disabled}
|
|
52
|
+
{name}
|
|
53
|
+
{invalid}
|
|
54
|
+
{errorMessage}
|
|
55
|
+
>
|
|
56
|
+
{@render children?.()}
|
|
57
|
+
</box-select>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import { Select as SelectElement } from "@unofficialbox/box-open-elements/select";
|
|
3
|
+
type SelectOption = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
type ValueChangedEvent = CustomEvent<{
|
|
8
|
+
value: string;
|
|
9
|
+
}>;
|
|
10
|
+
type Props = {
|
|
11
|
+
element?: SelectElement;
|
|
12
|
+
label?: string;
|
|
13
|
+
value?: string;
|
|
14
|
+
options?: SelectOption[];
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
name?: string;
|
|
17
|
+
invalid?: boolean;
|
|
18
|
+
errorMessage?: string;
|
|
19
|
+
onValueChanged?: (event: ValueChangedEvent) => void;
|
|
20
|
+
children?: Snippet;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
declare const Select: import("svelte").Component<Props, {}, "element">;
|
|
24
|
+
type Select = ReturnType<typeof Select>;
|
|
25
|
+
export default Select;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { TextField as TextFieldElement } from "@unofficialbox/box-open-elements/text-field";
|
|
4
|
+
|
|
5
|
+
TextFieldElement.register();
|
|
6
|
+
|
|
7
|
+
type ValueChangedEvent = CustomEvent<{ value: string }>;
|
|
8
|
+
type Props = {
|
|
9
|
+
element?: TextFieldElement;
|
|
10
|
+
label?: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
name?: string;
|
|
15
|
+
invalid?: boolean;
|
|
16
|
+
errorMessage?: string;
|
|
17
|
+
onValueChanged?: (event: ValueChangedEvent) => void;
|
|
18
|
+
children?: Snippet;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
element = $bindable(),
|
|
24
|
+
label,
|
|
25
|
+
value,
|
|
26
|
+
placeholder,
|
|
27
|
+
disabled = false,
|
|
28
|
+
name,
|
|
29
|
+
invalid = false,
|
|
30
|
+
errorMessage,
|
|
31
|
+
onValueChanged,
|
|
32
|
+
children,
|
|
33
|
+
...rest
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
$effect(() => {
|
|
37
|
+
if (!element || !onValueChanged) return;
|
|
38
|
+
const listener = onValueChanged as EventListener;
|
|
39
|
+
element.addEventListener("value-changed", listener);
|
|
40
|
+
return () => element?.removeEventListener("value-changed", listener);
|
|
41
|
+
});
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<box-text-field
|
|
45
|
+
bind:this={element}
|
|
46
|
+
{...rest}
|
|
47
|
+
{label}
|
|
48
|
+
{value}
|
|
49
|
+
{placeholder}
|
|
50
|
+
{disabled}
|
|
51
|
+
{name}
|
|
52
|
+
{invalid}
|
|
53
|
+
{errorMessage}
|
|
54
|
+
>
|
|
55
|
+
{@render children?.()}
|
|
56
|
+
</box-text-field>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import { TextField as TextFieldElement } from "@unofficialbox/box-open-elements/text-field";
|
|
3
|
+
type ValueChangedEvent = CustomEvent<{
|
|
4
|
+
value: string;
|
|
5
|
+
}>;
|
|
6
|
+
type Props = {
|
|
7
|
+
element?: TextFieldElement;
|
|
8
|
+
label?: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
name?: string;
|
|
13
|
+
invalid?: boolean;
|
|
14
|
+
errorMessage?: string;
|
|
15
|
+
onValueChanged?: (event: ValueChangedEvent) => void;
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
declare const TextField: import("svelte").Component<Props, {}, "element">;
|
|
20
|
+
type TextField = ReturnType<typeof TextField>;
|
|
21
|
+
export default TextField;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Readable } from "svelte/store";
|
|
2
|
+
import { ExplorerSelectionController, type ExplorerSelectionState } from "@unofficialbox/box-open-elements/patterns/content-explorer/selection";
|
|
3
|
+
export { ExplorerSelectionController };
|
|
4
|
+
export type { ExplorerSelectionState };
|
|
5
|
+
/** Svelte readable store backed by the framework-neutral selection controller. */
|
|
6
|
+
export declare const createExplorerSelectionStore: (controller: ExplorerSelectionController) => Readable<Readonly<ExplorerSelectionState>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { readable } from "svelte/store";
|
|
2
|
+
import { ExplorerSelectionController, } from "@unofficialbox/box-open-elements/patterns/content-explorer/selection";
|
|
3
|
+
// Re-exported so a host can construct the controller through this package and
|
|
4
|
+
// hand it straight to the adapter API. Classes with private fields are
|
|
5
|
+
// nominally typed, so a host that imports the class from a differently
|
|
6
|
+
// resolved copy of the core package gets an incompatible identity — one
|
|
7
|
+
// import path sidesteps that whole class of version-skew errors.
|
|
8
|
+
export { ExplorerSelectionController };
|
|
9
|
+
/** Svelte readable store backed by the framework-neutral selection controller. */
|
|
10
|
+
export const createExplorerSelectionStore = (controller) => readable(controller.getState(), set => controller.subscribe("selectionChanged", () => set(controller.getState())));
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Button } from "./Button.svelte";
|
|
2
|
+
export { default as Dialog } from "./Dialog.svelte";
|
|
3
|
+
export { createExplorerSelectionStore } from "./explorer-selection.js";
|
|
4
|
+
export { default as Select } from "./Select.svelte";
|
|
5
|
+
export { default as TextField } from "./TextField.svelte";
|
|
6
|
+
export { ExplorerSelectionController, type ExplorerSelectionState } from "./explorer-selection.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Button } from "./Button.svelte";
|
|
2
|
+
export { default as Dialog } from "./Dialog.svelte";
|
|
3
|
+
export { createExplorerSelectionStore } from "./explorer-selection.js";
|
|
4
|
+
export { default as Select } from "./Select.svelte";
|
|
5
|
+
export { default as TextField } from "./TextField.svelte";
|
|
6
|
+
export { ExplorerSelectionController } from "./explorer-selection.js";
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unofficialbox/box-open-elements-svelte",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Typed Svelte adapters for box-open-elements Web Components.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://unofficialbox.github.io/box-open-elements",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/unofficialbox/box-open-elements.git",
|
|
10
|
+
"directory": "packages/svelte"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/unofficialbox/box-open-elements/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": ["svelte", "web-components", "design-system", "box"],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"svelte": "./dist/index.js",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"svelte": "./dist/index.js",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": ["dist"],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20.9.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@unofficialbox/box-open-elements": "^0.7.0",
|
|
36
|
+
"svelte": ">=5.0.0 <6.0.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "svelte-package --input src --output dist",
|
|
40
|
+
"prepublishOnly": "bun run build",
|
|
41
|
+
"typecheck": "svelte-check --tsconfig tsconfig.json"
|
|
42
|
+
}
|
|
43
|
+
}
|