@usemote/vue 0.0.0-stage → 0.1.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 +21 -0
- 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 +57 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 George Heavenson
|
|
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
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,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usemote/vue",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Vue 3 component for Mote — deterministic floating-shape background fields.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "George Heavenson",
|
|
8
|
+
"url": "https://hearvie.dev"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/oti-adjei/mote.git",
|
|
13
|
+
"directory": "packages/vue"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://mote.hearvie.dev",
|
|
16
|
+
"bugs": "https://github.com/oti-adjei/mote/issues",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./dist/index.cjs",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"require": "./dist/index.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"size-limit": [
|
|
35
|
+
{
|
|
36
|
+
"path": "dist/index.js",
|
|
37
|
+
"limit": "3 kB"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@usemote/core": "^0.1.1",
|
|
42
|
+
"vue": ">=3.4"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@usemote/core": "0.1.1",
|
|
46
|
+
"vue": "^3.5.0",
|
|
47
|
+
"@vue/test-utils": "^2.4.6",
|
|
48
|
+
"@vue/server-renderer": "^3.5.0",
|
|
49
|
+
"happy-dom": "^20.0.0"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsup",
|
|
56
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"size": "size-limit"
|
|
59
|
+
}
|
|
6
60
|
}
|