@unofficialbox/box-open-elements-vue 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 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,26 @@
1
+ # @unofficialbox/box-open-elements-vue
2
+
3
+ Typed Vue 3 wrappers for `box-open-elements`, including structured property
4
+ sync, custom-event emits, exposed element refs, and a selection-controller
5
+ composable.
6
+
7
+ ```bash
8
+ npm install @unofficialbox/box-open-elements @unofficialbox/box-open-elements-vue vue
9
+ ```
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ import { Select, TextField } from "@unofficialbox/box-open-elements-vue";
14
+ const options = [{ label: "Draft", value: "draft" }];
15
+ </script>
16
+
17
+ <template>
18
+ <TextField value="Apollo" @value-changed="event => console.log(event.detail.value)" />
19
+ <Select :options="options" />
20
+ </template>
21
+ ```
22
+
23
+ `useExplorerSelectionController(controller)` exposes the shared selection
24
+ controller as a scoped readonly ref. Version `0.1.0` is a release candidate;
25
+ Supported status follows the first public lockstep adapter release and clean
26
+ registry-install verification.
@@ -0,0 +1,7 @@
1
+ import { type ShallowRef } from "vue";
2
+ export type EventBinding = {
3
+ eventName: string;
4
+ listener: (event: Event) => void;
5
+ };
6
+ /** Shared lifecycle bridge for Vue wrappers around custom-element hosts. */
7
+ export declare const useWebComponent: <E extends HTMLElement>(sync: (element: E) => void, events?: readonly EventBinding[]) => ShallowRef<E | undefined>;
@@ -0,0 +1,24 @@
1
+ import { onBeforeUnmount, onMounted, shallowRef, watchEffect, } from "vue";
2
+ /** Shared lifecycle bridge for Vue wrappers around custom-element hosts. */
3
+ export const useWebComponent = (sync, events = []) => {
4
+ const element = shallowRef();
5
+ watchEffect(() => {
6
+ if (element.value)
7
+ sync(element.value);
8
+ });
9
+ onMounted(() => {
10
+ if (!element.value)
11
+ return;
12
+ for (const binding of events) {
13
+ element.value.addEventListener(binding.eventName, binding.listener);
14
+ }
15
+ });
16
+ onBeforeUnmount(() => {
17
+ if (!element.value)
18
+ return;
19
+ for (const binding of events) {
20
+ element.value.removeEventListener(binding.eventName, binding.listener);
21
+ }
22
+ });
23
+ return element;
24
+ };
@@ -0,0 +1,16 @@
1
+ /** Typed Vue wrapper for `<box-button>`. */
2
+ export declare const Button: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
+ label: StringConstructor;
4
+ tone: StringConstructor;
5
+ size: StringConstructor;
6
+ disabled: BooleanConstructor;
7
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
8
+ [key: string]: any;
9
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
10
+ label: StringConstructor;
11
+ tone: StringConstructor;
12
+ size: StringConstructor;
13
+ disabled: BooleanConstructor;
14
+ }>> & Readonly<{}>, {
15
+ disabled: boolean;
16
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
package/dist/button.js ADDED
@@ -0,0 +1,28 @@
1
+ import { defineComponent, h } from "vue";
2
+ import { Button as ButtonElement } from "@unofficialbox/box-open-elements/button";
3
+ import { useWebComponent } from "./adapter.js";
4
+ ButtonElement.register();
5
+ /** Typed Vue wrapper for `<box-button>`. */
6
+ export const Button = defineComponent({
7
+ name: "Button",
8
+ inheritAttrs: false,
9
+ props: {
10
+ label: String,
11
+ tone: String,
12
+ size: String,
13
+ disabled: Boolean,
14
+ },
15
+ setup(props, { attrs, slots, expose }) {
16
+ const element = useWebComponent(host => {
17
+ if (props.label !== undefined)
18
+ host.label = props.label;
19
+ if (props.tone !== undefined)
20
+ host.tone = props.tone;
21
+ if (props.size !== undefined)
22
+ host.size = props.size;
23
+ host.disabled = props.disabled;
24
+ });
25
+ expose({ get element() { return element.value; } });
26
+ return () => h("box-button", { ...attrs, ref: element }, slots.default?.());
27
+ },
28
+ });
@@ -0,0 +1,31 @@
1
+ import { type PropType } from "vue";
2
+ export type DialogSize = "small" | "medium" | "large" | "fullscreen";
3
+ export type OpenChangedEvent = CustomEvent<{
4
+ open: boolean;
5
+ }>;
6
+ /** Typed Vue wrapper for the controlled `<box-dialog>`. */
7
+ export declare const Dialog: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ open: BooleanConstructor;
9
+ heading: StringConstructor;
10
+ description: StringConstructor;
11
+ confirmLabel: StringConstructor;
12
+ size: PropType<DialogSize>;
13
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
14
+ [key: string]: any;
15
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
+ "open-changed": (_event: OpenChangedEvent) => true;
17
+ confirm: (_event: CustomEvent<null>) => true;
18
+ cancel: (_event: CustomEvent<null>) => true;
19
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
+ open: BooleanConstructor;
21
+ heading: StringConstructor;
22
+ description: StringConstructor;
23
+ confirmLabel: StringConstructor;
24
+ size: PropType<DialogSize>;
25
+ }>> & Readonly<{
26
+ onCancel?: ((_event: CustomEvent<null>) => any) | undefined;
27
+ "onOpen-changed"?: ((_event: OpenChangedEvent) => any) | undefined;
28
+ onConfirm?: ((_event: CustomEvent<null>) => any) | undefined;
29
+ }>, {
30
+ open: boolean;
31
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
package/dist/dialog.js ADDED
@@ -0,0 +1,49 @@
1
+ import { defineComponent, h } from "vue";
2
+ import { Dialog as DialogElement } from "@unofficialbox/box-open-elements/dialog";
3
+ import { useWebComponent } from "./adapter.js";
4
+ DialogElement.register();
5
+ /** Typed Vue wrapper for the controlled `<box-dialog>`. */
6
+ export const Dialog = defineComponent({
7
+ name: "Dialog",
8
+ inheritAttrs: false,
9
+ props: {
10
+ open: Boolean,
11
+ heading: String,
12
+ description: String,
13
+ confirmLabel: String,
14
+ size: String,
15
+ },
16
+ emits: {
17
+ "open-changed": (_event) => true,
18
+ confirm: (_event) => true,
19
+ cancel: (_event) => true,
20
+ },
21
+ setup(props, { attrs, slots, emit, expose }) {
22
+ const element = useWebComponent(host => {
23
+ host.open = props.open;
24
+ if (props.heading !== undefined)
25
+ host.heading = props.heading;
26
+ if (props.description !== undefined)
27
+ host.description = props.description;
28
+ if (props.confirmLabel !== undefined)
29
+ host.confirmLabel = props.confirmLabel;
30
+ if (props.size !== undefined)
31
+ host.size = props.size;
32
+ }, [
33
+ {
34
+ eventName: "open-changed",
35
+ listener: event => emit("open-changed", event),
36
+ },
37
+ {
38
+ eventName: "confirm",
39
+ listener: event => emit("confirm", event),
40
+ },
41
+ {
42
+ eventName: "cancel",
43
+ listener: event => emit("cancel", event),
44
+ },
45
+ ]);
46
+ expose({ get element() { return element.value; } });
47
+ return () => h("box-dialog", { ...attrs, ref: element }, slots.default?.());
48
+ },
49
+ });
@@ -0,0 +1,6 @@
1
+ import { type DeepReadonly, type ShallowRef } from "vue";
2
+ import { ExplorerSelectionController, type ExplorerSelectionState } from "@unofficialbox/box-open-elements/patterns/content-explorer/selection";
3
+ export { ExplorerSelectionController };
4
+ export type { ExplorerSelectionState };
5
+ /** Vue composable for the framework-neutral explorer selection controller. */
6
+ export declare const useExplorerSelectionController: (controller: ExplorerSelectionController) => DeepReadonly<ShallowRef<Readonly<ExplorerSelectionState>>>;
@@ -0,0 +1,18 @@
1
+ import { getCurrentScope, onScopeDispose, readonly, shallowRef, } from "vue";
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
+ /** Vue composable for the framework-neutral explorer selection controller. */
10
+ export const useExplorerSelectionController = (controller) => {
11
+ const state = shallowRef(controller.getState());
12
+ const unsubscribe = controller.subscribe("selectionChanged", () => {
13
+ state.value = controller.getState();
14
+ });
15
+ if (getCurrentScope())
16
+ onScopeDispose(unsubscribe);
17
+ return readonly(state);
18
+ };
@@ -0,0 +1,7 @@
1
+ export { useWebComponent, type EventBinding } from "./adapter.js";
2
+ export { Button } from "./button.js";
3
+ export { Dialog, type DialogSize, type OpenChangedEvent } from "./dialog.js";
4
+ export { useExplorerSelectionController } from "./explorer-selection.js";
5
+ export { Select, type SelectOption } from "./select.js";
6
+ export { TextField, type ValueChangedDetail, type ValueChangedEvent } from "./text-field.js";
7
+ export { ExplorerSelectionController, type ExplorerSelectionState } from "./explorer-selection.js";
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { useWebComponent } from "./adapter.js";
2
+ export { Button } from "./button.js";
3
+ export { Dialog } from "./dialog.js";
4
+ export { useExplorerSelectionController } from "./explorer-selection.js";
5
+ export { Select } from "./select.js";
6
+ export { TextField } from "./text-field.js";
7
+ export { ExplorerSelectionController } from "./explorer-selection.js";
@@ -0,0 +1,33 @@
1
+ import { type PropType } from "vue";
2
+ import type { ValueChangedEvent } from "./text-field.js";
3
+ export type SelectOption = {
4
+ label: string;
5
+ value: string;
6
+ };
7
+ /** Typed Vue wrapper for `<box-select>`, including structured options. */
8
+ export declare const Select: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
9
+ label: StringConstructor;
10
+ value: StringConstructor;
11
+ options: PropType<SelectOption[]>;
12
+ disabled: BooleanConstructor;
13
+ name: StringConstructor;
14
+ invalid: BooleanConstructor;
15
+ errorMessage: StringConstructor;
16
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
17
+ [key: string]: any;
18
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ "value-changed": (_event: ValueChangedEvent) => true;
20
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
+ label: StringConstructor;
22
+ value: StringConstructor;
23
+ options: PropType<SelectOption[]>;
24
+ disabled: BooleanConstructor;
25
+ name: StringConstructor;
26
+ invalid: BooleanConstructor;
27
+ errorMessage: StringConstructor;
28
+ }>> & Readonly<{
29
+ "onValue-changed"?: ((_event: ValueChangedEvent) => any) | undefined;
30
+ }>, {
31
+ invalid: boolean;
32
+ disabled: boolean;
33
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
package/dist/select.js ADDED
@@ -0,0 +1,42 @@
1
+ import { defineComponent, h } from "vue";
2
+ import { Select as SelectElement } from "@unofficialbox/box-open-elements/select";
3
+ import { useWebComponent } from "./adapter.js";
4
+ SelectElement.register();
5
+ /** Typed Vue wrapper for `<box-select>`, including structured options. */
6
+ export const Select = defineComponent({
7
+ name: "Select",
8
+ inheritAttrs: false,
9
+ props: {
10
+ label: String,
11
+ value: String,
12
+ options: Array,
13
+ disabled: Boolean,
14
+ name: String,
15
+ invalid: Boolean,
16
+ errorMessage: String,
17
+ },
18
+ emits: {
19
+ "value-changed": (_event) => true,
20
+ },
21
+ setup(props, { attrs, slots, emit, expose }) {
22
+ const element = useWebComponent(host => {
23
+ if (props.label !== undefined)
24
+ host.label = props.label;
25
+ if (props.value !== undefined)
26
+ host.value = props.value;
27
+ if (props.options !== undefined)
28
+ host.options = props.options;
29
+ if (props.name !== undefined)
30
+ host.name = props.name;
31
+ if (props.errorMessage !== undefined)
32
+ host.errorMessage = props.errorMessage;
33
+ host.disabled = props.disabled;
34
+ host.invalid = props.invalid;
35
+ }, [{
36
+ eventName: "value-changed",
37
+ listener: event => emit("value-changed", event),
38
+ }]);
39
+ expose({ get element() { return element.value; } });
40
+ return () => h("box-select", { ...attrs, ref: element }, slots.default?.());
41
+ },
42
+ });
@@ -0,0 +1,31 @@
1
+ export type ValueChangedDetail = {
2
+ value: string;
3
+ };
4
+ export type ValueChangedEvent = CustomEvent<ValueChangedDetail>;
5
+ /** Typed Vue wrapper for `<box-text-field>`. */
6
+ export declare const TextField: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
7
+ label: StringConstructor;
8
+ value: StringConstructor;
9
+ placeholder: StringConstructor;
10
+ disabled: BooleanConstructor;
11
+ name: StringConstructor;
12
+ invalid: BooleanConstructor;
13
+ errorMessage: StringConstructor;
14
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
15
+ [key: string]: any;
16
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
17
+ "value-changed": (_event: ValueChangedEvent) => true;
18
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
+ label: StringConstructor;
20
+ value: StringConstructor;
21
+ placeholder: StringConstructor;
22
+ disabled: BooleanConstructor;
23
+ name: StringConstructor;
24
+ invalid: BooleanConstructor;
25
+ errorMessage: StringConstructor;
26
+ }>> & Readonly<{
27
+ "onValue-changed"?: ((_event: ValueChangedEvent) => any) | undefined;
28
+ }>, {
29
+ invalid: boolean;
30
+ disabled: boolean;
31
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,42 @@
1
+ import { defineComponent, h } from "vue";
2
+ import { TextField as TextFieldElement } from "@unofficialbox/box-open-elements/text-field";
3
+ import { useWebComponent } from "./adapter.js";
4
+ TextFieldElement.register();
5
+ /** Typed Vue wrapper for `<box-text-field>`. */
6
+ export const TextField = defineComponent({
7
+ name: "TextField",
8
+ inheritAttrs: false,
9
+ props: {
10
+ label: String,
11
+ value: String,
12
+ placeholder: String,
13
+ disabled: Boolean,
14
+ name: String,
15
+ invalid: Boolean,
16
+ errorMessage: String,
17
+ },
18
+ emits: {
19
+ "value-changed": (_event) => true,
20
+ },
21
+ setup(props, { attrs, slots, emit, expose }) {
22
+ const element = useWebComponent(host => {
23
+ if (props.label !== undefined)
24
+ host.label = props.label;
25
+ if (props.value !== undefined)
26
+ host.value = props.value;
27
+ if (props.placeholder !== undefined)
28
+ host.placeholder = props.placeholder;
29
+ if (props.name !== undefined)
30
+ host.name = props.name;
31
+ if (props.errorMessage !== undefined)
32
+ host.errorMessage = props.errorMessage;
33
+ host.disabled = props.disabled;
34
+ host.invalid = props.invalid;
35
+ }, [{
36
+ eventName: "value-changed",
37
+ listener: event => emit("value-changed", event),
38
+ }]);
39
+ expose({ get element() { return element.value; } });
40
+ return () => h("box-text-field", { ...attrs, ref: element }, slots.default?.());
41
+ },
42
+ });
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@unofficialbox/box-open-elements-vue",
3
+ "version": "0.7.0",
4
+ "description": "Typed Vue 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/vue"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/unofficialbox/box-open-elements/issues"
14
+ },
15
+ "keywords": ["vue", "web-components", "design-system", "box"],
16
+ "type": "module",
17
+ "main": "dist/index.js",
18
+ "types": "dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js"
23
+ }
24
+ },
25
+ "files": ["dist"],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "engines": {
30
+ "node": ">=20.9.0"
31
+ },
32
+ "peerDependencies": {
33
+ "@unofficialbox/box-open-elements": "^0.7.0",
34
+ "vue": ">=3.5.0 <4.0.0"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc -p tsconfig.build.json",
38
+ "prepublishOnly": "bun run build",
39
+ "typecheck": "tsc -p tsconfig.json --noEmit"
40
+ }
41
+ }