@usemote/vue 0.0.0-stage → 0.1.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/README.md +45 -2
- package/dist/index.cjs +110 -0
- package/dist/index.d.cts +157 -0
- package/dist/index.d.ts +157 -0
- package/dist/index.js +105 -0
- package/package.json +54 -4
package/README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @usemote/vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vue 3 binding for [Mote](https://mote.hearvie.dev). **799 B** brotlied.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm add @usemote/core @usemote/vue
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<script setup>
|
|
11
|
+
import { FloatingField } from '@usemote/vue';
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<section style="position: relative; overflow: hidden">
|
|
16
|
+
<FloatingField mode="bob" set="geo" :count="12" avoid="center" depth />
|
|
17
|
+
<h1 style="position: relative">Your headline</h1>
|
|
18
|
+
</section>
|
|
19
|
+
</template>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**The field is a layer.** It fills its nearest positioned ancestor, so that
|
|
23
|
+
parent needs `position: relative`, and content above it needs
|
|
24
|
+
`position: relative` too — otherwise the shapes cover it.
|
|
25
|
+
|
|
26
|
+
Props match `FieldOptions` exactly, and match `@usemote/react` name for name.
|
|
27
|
+
Unset props fall through to core's defaults.
|
|
28
|
+
|
|
29
|
+
Written as a render function, not an SFC, so the package needs no Vue compiler
|
|
30
|
+
and stays a plain dependency.
|
|
31
|
+
|
|
32
|
+
## SSR
|
|
33
|
+
|
|
34
|
+
Nuxt and `@vue/server-renderer` both work. The server renders frame 0 and the
|
|
35
|
+
client renders identical markup, so there is no hydration mismatch.
|
|
36
|
+
|
|
37
|
+
## Inspiration
|
|
38
|
+
|
|
39
|
+
Architecturally modelled on **[Navii](https://github.com/uxderrick/navii)** by
|
|
40
|
+
**[Derrick Tsorme](https://github.com/uxderrick)** — a deterministic avatar
|
|
41
|
+
engine, and the reason this project exists. No code is shared; the debt is
|
|
42
|
+
architectural. If you need avatars, use Navii.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@usemote/core');
|
|
6
|
+
var vue = require('vue');
|
|
7
|
+
|
|
8
|
+
// src/FloatingField.ts
|
|
9
|
+
var FloatingField = vue.defineComponent({
|
|
10
|
+
name: "FloatingField",
|
|
11
|
+
props: {
|
|
12
|
+
mode: { type: [String, Object], default: void 0 },
|
|
13
|
+
set: { type: String, default: void 0 },
|
|
14
|
+
shapes: { type: [String, Array], default: void 0 },
|
|
15
|
+
packs: { type: Array, default: void 0 },
|
|
16
|
+
count: { type: Number, default: void 0 },
|
|
17
|
+
size: { type: Number, default: void 0 },
|
|
18
|
+
seed: { type: [Number, String], default: void 0 },
|
|
19
|
+
theme: { type: [String, Array], default: void 0 },
|
|
20
|
+
depth: { type: Boolean, default: void 0 },
|
|
21
|
+
avoid: { type: [String, Object], default: void 0 },
|
|
22
|
+
speed: { type: Number, default: void 0 },
|
|
23
|
+
interactive: { type: Boolean, default: void 0 },
|
|
24
|
+
direction: { type: String, default: void 0 },
|
|
25
|
+
paused: { type: Boolean, default: void 0 },
|
|
26
|
+
ssrWidth: { type: Number, default: 1200 },
|
|
27
|
+
ssrHeight: { type: Number, default: 600 }
|
|
28
|
+
},
|
|
29
|
+
setup(props) {
|
|
30
|
+
const el = vue.ref(null);
|
|
31
|
+
let handle = null;
|
|
32
|
+
const options = () => {
|
|
33
|
+
const o = {};
|
|
34
|
+
if (props.mode !== void 0) o.mode = props.mode;
|
|
35
|
+
if (props.set !== void 0) o.set = props.set;
|
|
36
|
+
if (props.shapes !== void 0) o.shapes = props.shapes;
|
|
37
|
+
if (props.packs !== void 0) o.packs = props.packs;
|
|
38
|
+
if (props.count !== void 0) o.count = props.count;
|
|
39
|
+
if (props.size !== void 0) o.size = props.size;
|
|
40
|
+
if (props.seed !== void 0) o.seed = props.seed;
|
|
41
|
+
if (props.theme !== void 0) o.theme = props.theme;
|
|
42
|
+
if (props.depth !== void 0) o.depth = props.depth;
|
|
43
|
+
if (props.avoid !== void 0) o.avoid = props.avoid;
|
|
44
|
+
if (props.speed !== void 0) o.speed = props.speed;
|
|
45
|
+
if (props.interactive !== void 0) o.interactive = props.interactive;
|
|
46
|
+
if (props.direction !== void 0) o.direction = props.direction;
|
|
47
|
+
if (props.paused !== void 0) o.paused = props.paused;
|
|
48
|
+
return o;
|
|
49
|
+
};
|
|
50
|
+
const poolKey = vue.computed(
|
|
51
|
+
() => JSON.stringify([
|
|
52
|
+
props.packs?.map((p) => `${p.id}@${p.version}`) ?? null,
|
|
53
|
+
props.shapes ?? null,
|
|
54
|
+
props.theme ?? null
|
|
55
|
+
])
|
|
56
|
+
);
|
|
57
|
+
const ssrHTML = vue.computed(
|
|
58
|
+
() => core.renderFieldHTML({ ...options(), width: props.ssrWidth, height: props.ssrHeight })
|
|
59
|
+
);
|
|
60
|
+
const rebuild = () => {
|
|
61
|
+
if (!el.value) return;
|
|
62
|
+
handle?.destroy();
|
|
63
|
+
handle = core.createField(el.value, options());
|
|
64
|
+
};
|
|
65
|
+
vue.onMounted(rebuild);
|
|
66
|
+
vue.onBeforeUnmount(() => {
|
|
67
|
+
handle?.destroy();
|
|
68
|
+
handle = null;
|
|
69
|
+
});
|
|
70
|
+
vue.watch(
|
|
71
|
+
() => [
|
|
72
|
+
poolKey.value,
|
|
73
|
+
props.seed,
|
|
74
|
+
props.count,
|
|
75
|
+
props.size,
|
|
76
|
+
props.set,
|
|
77
|
+
props.depth,
|
|
78
|
+
props.direction,
|
|
79
|
+
typeof props.mode === "object" ? "custom" : props.mode
|
|
80
|
+
],
|
|
81
|
+
rebuild
|
|
82
|
+
);
|
|
83
|
+
vue.watch(
|
|
84
|
+
() => [props.speed, props.interactive, props.avoid, props.paused],
|
|
85
|
+
() => {
|
|
86
|
+
const live = {};
|
|
87
|
+
if (props.speed !== void 0) live.speed = props.speed;
|
|
88
|
+
if (props.interactive !== void 0) live.interactive = props.interactive;
|
|
89
|
+
if (props.avoid !== void 0) live.avoid = props.avoid;
|
|
90
|
+
if (props.paused !== void 0) live.paused = props.paused;
|
|
91
|
+
handle?.update(live);
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
return () => vue.h("div", {
|
|
95
|
+
ref: el,
|
|
96
|
+
"aria-hidden": "true",
|
|
97
|
+
style: {
|
|
98
|
+
position: "absolute",
|
|
99
|
+
inset: 0,
|
|
100
|
+
overflow: "hidden",
|
|
101
|
+
pointerEvents: "none"
|
|
102
|
+
},
|
|
103
|
+
innerHTML: ssrHTML.value
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
var FloatingField_default = FloatingField;
|
|
108
|
+
|
|
109
|
+
exports.FloatingField = FloatingField;
|
|
110
|
+
exports.default = FloatingField_default;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as _usemote_core from '@usemote/core';
|
|
2
|
+
import { FieldOptions } from '@usemote/core';
|
|
3
|
+
import * as vue from 'vue';
|
|
4
|
+
import { PropType } from 'vue';
|
|
5
|
+
|
|
6
|
+
declare const FloatingField: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
7
|
+
mode: {
|
|
8
|
+
type: PropType<FieldOptions["mode"]>;
|
|
9
|
+
default: undefined;
|
|
10
|
+
};
|
|
11
|
+
set: {
|
|
12
|
+
type: PropType<FieldOptions["set"]>;
|
|
13
|
+
default: undefined;
|
|
14
|
+
};
|
|
15
|
+
shapes: {
|
|
16
|
+
type: PropType<FieldOptions["shapes"]>;
|
|
17
|
+
default: undefined;
|
|
18
|
+
};
|
|
19
|
+
packs: {
|
|
20
|
+
type: PropType<FieldOptions["packs"]>;
|
|
21
|
+
default: undefined;
|
|
22
|
+
};
|
|
23
|
+
count: {
|
|
24
|
+
type: NumberConstructor;
|
|
25
|
+
default: undefined;
|
|
26
|
+
};
|
|
27
|
+
size: {
|
|
28
|
+
type: NumberConstructor;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
seed: {
|
|
32
|
+
type: PropType<FieldOptions["seed"]>;
|
|
33
|
+
default: undefined;
|
|
34
|
+
};
|
|
35
|
+
theme: {
|
|
36
|
+
type: PropType<FieldOptions["theme"]>;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
39
|
+
depth: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: undefined;
|
|
42
|
+
};
|
|
43
|
+
avoid: {
|
|
44
|
+
type: PropType<FieldOptions["avoid"]>;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
47
|
+
speed: {
|
|
48
|
+
type: NumberConstructor;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
interactive: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: undefined;
|
|
54
|
+
};
|
|
55
|
+
direction: {
|
|
56
|
+
type: PropType<FieldOptions["direction"]>;
|
|
57
|
+
default: undefined;
|
|
58
|
+
};
|
|
59
|
+
paused: {
|
|
60
|
+
type: BooleanConstructor;
|
|
61
|
+
default: undefined;
|
|
62
|
+
};
|
|
63
|
+
ssrWidth: {
|
|
64
|
+
type: NumberConstructor;
|
|
65
|
+
default: number;
|
|
66
|
+
};
|
|
67
|
+
ssrHeight: {
|
|
68
|
+
type: NumberConstructor;
|
|
69
|
+
default: number;
|
|
70
|
+
};
|
|
71
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
72
|
+
[key: string]: any;
|
|
73
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
74
|
+
mode: {
|
|
75
|
+
type: PropType<FieldOptions["mode"]>;
|
|
76
|
+
default: undefined;
|
|
77
|
+
};
|
|
78
|
+
set: {
|
|
79
|
+
type: PropType<FieldOptions["set"]>;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
82
|
+
shapes: {
|
|
83
|
+
type: PropType<FieldOptions["shapes"]>;
|
|
84
|
+
default: undefined;
|
|
85
|
+
};
|
|
86
|
+
packs: {
|
|
87
|
+
type: PropType<FieldOptions["packs"]>;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
count: {
|
|
91
|
+
type: NumberConstructor;
|
|
92
|
+
default: undefined;
|
|
93
|
+
};
|
|
94
|
+
size: {
|
|
95
|
+
type: NumberConstructor;
|
|
96
|
+
default: undefined;
|
|
97
|
+
};
|
|
98
|
+
seed: {
|
|
99
|
+
type: PropType<FieldOptions["seed"]>;
|
|
100
|
+
default: undefined;
|
|
101
|
+
};
|
|
102
|
+
theme: {
|
|
103
|
+
type: PropType<FieldOptions["theme"]>;
|
|
104
|
+
default: undefined;
|
|
105
|
+
};
|
|
106
|
+
depth: {
|
|
107
|
+
type: BooleanConstructor;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
avoid: {
|
|
111
|
+
type: PropType<FieldOptions["avoid"]>;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
speed: {
|
|
115
|
+
type: NumberConstructor;
|
|
116
|
+
default: undefined;
|
|
117
|
+
};
|
|
118
|
+
interactive: {
|
|
119
|
+
type: BooleanConstructor;
|
|
120
|
+
default: undefined;
|
|
121
|
+
};
|
|
122
|
+
direction: {
|
|
123
|
+
type: PropType<FieldOptions["direction"]>;
|
|
124
|
+
default: undefined;
|
|
125
|
+
};
|
|
126
|
+
paused: {
|
|
127
|
+
type: BooleanConstructor;
|
|
128
|
+
default: undefined;
|
|
129
|
+
};
|
|
130
|
+
ssrWidth: {
|
|
131
|
+
type: NumberConstructor;
|
|
132
|
+
default: number;
|
|
133
|
+
};
|
|
134
|
+
ssrHeight: {
|
|
135
|
+
type: NumberConstructor;
|
|
136
|
+
default: number;
|
|
137
|
+
};
|
|
138
|
+
}>> & Readonly<{}>, {
|
|
139
|
+
mode: _usemote_core.MotionId | _usemote_core.MotionPreset | undefined;
|
|
140
|
+
set: _usemote_core.SetId | undefined;
|
|
141
|
+
shapes: string | string[] | undefined;
|
|
142
|
+
packs: _usemote_core.ShapePack[] | undefined;
|
|
143
|
+
seed: string | number | undefined;
|
|
144
|
+
theme: string | _usemote_core.ThemeStop[] | undefined;
|
|
145
|
+
avoid: _usemote_core.AvoidId | _usemote_core.Rect | undefined;
|
|
146
|
+
direction: _usemote_core.Direction | undefined;
|
|
147
|
+
count: number;
|
|
148
|
+
size: number;
|
|
149
|
+
depth: boolean;
|
|
150
|
+
speed: number;
|
|
151
|
+
interactive: boolean;
|
|
152
|
+
paused: boolean;
|
|
153
|
+
ssrWidth: number;
|
|
154
|
+
ssrHeight: number;
|
|
155
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
156
|
+
|
|
157
|
+
export { FloatingField, FloatingField as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as _usemote_core from '@usemote/core';
|
|
2
|
+
import { FieldOptions } from '@usemote/core';
|
|
3
|
+
import * as vue from 'vue';
|
|
4
|
+
import { PropType } from 'vue';
|
|
5
|
+
|
|
6
|
+
declare const FloatingField: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
7
|
+
mode: {
|
|
8
|
+
type: PropType<FieldOptions["mode"]>;
|
|
9
|
+
default: undefined;
|
|
10
|
+
};
|
|
11
|
+
set: {
|
|
12
|
+
type: PropType<FieldOptions["set"]>;
|
|
13
|
+
default: undefined;
|
|
14
|
+
};
|
|
15
|
+
shapes: {
|
|
16
|
+
type: PropType<FieldOptions["shapes"]>;
|
|
17
|
+
default: undefined;
|
|
18
|
+
};
|
|
19
|
+
packs: {
|
|
20
|
+
type: PropType<FieldOptions["packs"]>;
|
|
21
|
+
default: undefined;
|
|
22
|
+
};
|
|
23
|
+
count: {
|
|
24
|
+
type: NumberConstructor;
|
|
25
|
+
default: undefined;
|
|
26
|
+
};
|
|
27
|
+
size: {
|
|
28
|
+
type: NumberConstructor;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
seed: {
|
|
32
|
+
type: PropType<FieldOptions["seed"]>;
|
|
33
|
+
default: undefined;
|
|
34
|
+
};
|
|
35
|
+
theme: {
|
|
36
|
+
type: PropType<FieldOptions["theme"]>;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
39
|
+
depth: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: undefined;
|
|
42
|
+
};
|
|
43
|
+
avoid: {
|
|
44
|
+
type: PropType<FieldOptions["avoid"]>;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
47
|
+
speed: {
|
|
48
|
+
type: NumberConstructor;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
interactive: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: undefined;
|
|
54
|
+
};
|
|
55
|
+
direction: {
|
|
56
|
+
type: PropType<FieldOptions["direction"]>;
|
|
57
|
+
default: undefined;
|
|
58
|
+
};
|
|
59
|
+
paused: {
|
|
60
|
+
type: BooleanConstructor;
|
|
61
|
+
default: undefined;
|
|
62
|
+
};
|
|
63
|
+
ssrWidth: {
|
|
64
|
+
type: NumberConstructor;
|
|
65
|
+
default: number;
|
|
66
|
+
};
|
|
67
|
+
ssrHeight: {
|
|
68
|
+
type: NumberConstructor;
|
|
69
|
+
default: number;
|
|
70
|
+
};
|
|
71
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
72
|
+
[key: string]: any;
|
|
73
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
74
|
+
mode: {
|
|
75
|
+
type: PropType<FieldOptions["mode"]>;
|
|
76
|
+
default: undefined;
|
|
77
|
+
};
|
|
78
|
+
set: {
|
|
79
|
+
type: PropType<FieldOptions["set"]>;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
82
|
+
shapes: {
|
|
83
|
+
type: PropType<FieldOptions["shapes"]>;
|
|
84
|
+
default: undefined;
|
|
85
|
+
};
|
|
86
|
+
packs: {
|
|
87
|
+
type: PropType<FieldOptions["packs"]>;
|
|
88
|
+
default: undefined;
|
|
89
|
+
};
|
|
90
|
+
count: {
|
|
91
|
+
type: NumberConstructor;
|
|
92
|
+
default: undefined;
|
|
93
|
+
};
|
|
94
|
+
size: {
|
|
95
|
+
type: NumberConstructor;
|
|
96
|
+
default: undefined;
|
|
97
|
+
};
|
|
98
|
+
seed: {
|
|
99
|
+
type: PropType<FieldOptions["seed"]>;
|
|
100
|
+
default: undefined;
|
|
101
|
+
};
|
|
102
|
+
theme: {
|
|
103
|
+
type: PropType<FieldOptions["theme"]>;
|
|
104
|
+
default: undefined;
|
|
105
|
+
};
|
|
106
|
+
depth: {
|
|
107
|
+
type: BooleanConstructor;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
avoid: {
|
|
111
|
+
type: PropType<FieldOptions["avoid"]>;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
speed: {
|
|
115
|
+
type: NumberConstructor;
|
|
116
|
+
default: undefined;
|
|
117
|
+
};
|
|
118
|
+
interactive: {
|
|
119
|
+
type: BooleanConstructor;
|
|
120
|
+
default: undefined;
|
|
121
|
+
};
|
|
122
|
+
direction: {
|
|
123
|
+
type: PropType<FieldOptions["direction"]>;
|
|
124
|
+
default: undefined;
|
|
125
|
+
};
|
|
126
|
+
paused: {
|
|
127
|
+
type: BooleanConstructor;
|
|
128
|
+
default: undefined;
|
|
129
|
+
};
|
|
130
|
+
ssrWidth: {
|
|
131
|
+
type: NumberConstructor;
|
|
132
|
+
default: number;
|
|
133
|
+
};
|
|
134
|
+
ssrHeight: {
|
|
135
|
+
type: NumberConstructor;
|
|
136
|
+
default: number;
|
|
137
|
+
};
|
|
138
|
+
}>> & Readonly<{}>, {
|
|
139
|
+
mode: _usemote_core.MotionId | _usemote_core.MotionPreset | undefined;
|
|
140
|
+
set: _usemote_core.SetId | undefined;
|
|
141
|
+
shapes: string | string[] | undefined;
|
|
142
|
+
packs: _usemote_core.ShapePack[] | undefined;
|
|
143
|
+
seed: string | number | undefined;
|
|
144
|
+
theme: string | _usemote_core.ThemeStop[] | undefined;
|
|
145
|
+
avoid: _usemote_core.AvoidId | _usemote_core.Rect | undefined;
|
|
146
|
+
direction: _usemote_core.Direction | undefined;
|
|
147
|
+
count: number;
|
|
148
|
+
size: number;
|
|
149
|
+
depth: boolean;
|
|
150
|
+
speed: number;
|
|
151
|
+
interactive: boolean;
|
|
152
|
+
paused: boolean;
|
|
153
|
+
ssrWidth: number;
|
|
154
|
+
ssrHeight: number;
|
|
155
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
156
|
+
|
|
157
|
+
export { FloatingField, FloatingField as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { renderFieldHTML, createField } from '@usemote/core';
|
|
2
|
+
import { defineComponent, ref, computed, onMounted, onBeforeUnmount, watch, h } from 'vue';
|
|
3
|
+
|
|
4
|
+
// src/FloatingField.ts
|
|
5
|
+
var FloatingField = defineComponent({
|
|
6
|
+
name: "FloatingField",
|
|
7
|
+
props: {
|
|
8
|
+
mode: { type: [String, Object], default: void 0 },
|
|
9
|
+
set: { type: String, default: void 0 },
|
|
10
|
+
shapes: { type: [String, Array], default: void 0 },
|
|
11
|
+
packs: { type: Array, default: void 0 },
|
|
12
|
+
count: { type: Number, default: void 0 },
|
|
13
|
+
size: { type: Number, default: void 0 },
|
|
14
|
+
seed: { type: [Number, String], default: void 0 },
|
|
15
|
+
theme: { type: [String, Array], default: void 0 },
|
|
16
|
+
depth: { type: Boolean, default: void 0 },
|
|
17
|
+
avoid: { type: [String, Object], default: void 0 },
|
|
18
|
+
speed: { type: Number, default: void 0 },
|
|
19
|
+
interactive: { type: Boolean, default: void 0 },
|
|
20
|
+
direction: { type: String, default: void 0 },
|
|
21
|
+
paused: { type: Boolean, default: void 0 },
|
|
22
|
+
ssrWidth: { type: Number, default: 1200 },
|
|
23
|
+
ssrHeight: { type: Number, default: 600 }
|
|
24
|
+
},
|
|
25
|
+
setup(props) {
|
|
26
|
+
const el = ref(null);
|
|
27
|
+
let handle = null;
|
|
28
|
+
const options = () => {
|
|
29
|
+
const o = {};
|
|
30
|
+
if (props.mode !== void 0) o.mode = props.mode;
|
|
31
|
+
if (props.set !== void 0) o.set = props.set;
|
|
32
|
+
if (props.shapes !== void 0) o.shapes = props.shapes;
|
|
33
|
+
if (props.packs !== void 0) o.packs = props.packs;
|
|
34
|
+
if (props.count !== void 0) o.count = props.count;
|
|
35
|
+
if (props.size !== void 0) o.size = props.size;
|
|
36
|
+
if (props.seed !== void 0) o.seed = props.seed;
|
|
37
|
+
if (props.theme !== void 0) o.theme = props.theme;
|
|
38
|
+
if (props.depth !== void 0) o.depth = props.depth;
|
|
39
|
+
if (props.avoid !== void 0) o.avoid = props.avoid;
|
|
40
|
+
if (props.speed !== void 0) o.speed = props.speed;
|
|
41
|
+
if (props.interactive !== void 0) o.interactive = props.interactive;
|
|
42
|
+
if (props.direction !== void 0) o.direction = props.direction;
|
|
43
|
+
if (props.paused !== void 0) o.paused = props.paused;
|
|
44
|
+
return o;
|
|
45
|
+
};
|
|
46
|
+
const poolKey = computed(
|
|
47
|
+
() => JSON.stringify([
|
|
48
|
+
props.packs?.map((p) => `${p.id}@${p.version}`) ?? null,
|
|
49
|
+
props.shapes ?? null,
|
|
50
|
+
props.theme ?? null
|
|
51
|
+
])
|
|
52
|
+
);
|
|
53
|
+
const ssrHTML = computed(
|
|
54
|
+
() => renderFieldHTML({ ...options(), width: props.ssrWidth, height: props.ssrHeight })
|
|
55
|
+
);
|
|
56
|
+
const rebuild = () => {
|
|
57
|
+
if (!el.value) return;
|
|
58
|
+
handle?.destroy();
|
|
59
|
+
handle = createField(el.value, options());
|
|
60
|
+
};
|
|
61
|
+
onMounted(rebuild);
|
|
62
|
+
onBeforeUnmount(() => {
|
|
63
|
+
handle?.destroy();
|
|
64
|
+
handle = null;
|
|
65
|
+
});
|
|
66
|
+
watch(
|
|
67
|
+
() => [
|
|
68
|
+
poolKey.value,
|
|
69
|
+
props.seed,
|
|
70
|
+
props.count,
|
|
71
|
+
props.size,
|
|
72
|
+
props.set,
|
|
73
|
+
props.depth,
|
|
74
|
+
props.direction,
|
|
75
|
+
typeof props.mode === "object" ? "custom" : props.mode
|
|
76
|
+
],
|
|
77
|
+
rebuild
|
|
78
|
+
);
|
|
79
|
+
watch(
|
|
80
|
+
() => [props.speed, props.interactive, props.avoid, props.paused],
|
|
81
|
+
() => {
|
|
82
|
+
const live = {};
|
|
83
|
+
if (props.speed !== void 0) live.speed = props.speed;
|
|
84
|
+
if (props.interactive !== void 0) live.interactive = props.interactive;
|
|
85
|
+
if (props.avoid !== void 0) live.avoid = props.avoid;
|
|
86
|
+
if (props.paused !== void 0) live.paused = props.paused;
|
|
87
|
+
handle?.update(live);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
return () => h("div", {
|
|
91
|
+
ref: el,
|
|
92
|
+
"aria-hidden": "true",
|
|
93
|
+
style: {
|
|
94
|
+
position: "absolute",
|
|
95
|
+
inset: 0,
|
|
96
|
+
overflow: "hidden",
|
|
97
|
+
pointerEvents: "none"
|
|
98
|
+
},
|
|
99
|
+
innerHTML: ssrHTML.value
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
var FloatingField_default = FloatingField;
|
|
104
|
+
|
|
105
|
+
export { FloatingField, FloatingField_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usemote/vue",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vue 3 component for Mote — deterministic floating-shape background fields.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/oti-adjei/mote.git",
|
|
9
|
+
"directory": "packages/vue"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://mote.hearvie.dev",
|
|
12
|
+
"bugs": "https://github.com/oti-adjei/mote/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"require": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup",
|
|
32
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"size": "size-limit"
|
|
35
|
+
},
|
|
36
|
+
"size-limit": [
|
|
37
|
+
{
|
|
38
|
+
"path": "dist/index.js",
|
|
39
|
+
"limit": "3 kB"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@usemote/core": "workspace:^0.1.0",
|
|
44
|
+
"vue": ">=3.4"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@usemote/core": "workspace:*",
|
|
48
|
+
"vue": "^3.5.0",
|
|
49
|
+
"@vue/test-utils": "^2.4.6",
|
|
50
|
+
"@vue/server-renderer": "^3.5.0",
|
|
51
|
+
"happy-dom": "^20.0.0"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
}
|
|
56
|
+
}
|