@threlte/flex 2.0.0-next.9 → 2.0.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/README.md +1 -7
- package/dist/Box/Box.svelte.d.ts +3 -21
- package/dist/Box/types.d.ts +17 -0
- package/dist/Box/types.js +1 -0
- package/dist/Flex/Flex.svelte +2 -1
- package/dist/Flex/Flex.svelte.d.ts +3 -7
- package/dist/Flex/InnerFlex.svelte +0 -1
- package/dist/Flex/InnerFlex.svelte.d.ts +3 -32
- package/dist/Flex/context.d.ts +3 -2
- package/dist/Flex/context.js +1 -1
- package/dist/Flex/types.d.ts +30 -0
- package/dist/Flex/types.js +1 -0
- package/dist/lib/props.d.ts +28 -28
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -33,13 +33,7 @@ Check out our **[documentation](https://threlte.xyz)** and our **[Discord commun
|
|
|
33
33
|
|
|
34
34
|
### Installation
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
```sh
|
|
39
|
-
npm create threlte my-project
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Alternatively you can check out the full [installation instructions](https://threlte.xyz/docs/learn/getting-started/installation).
|
|
36
|
+
Check out the [installation instructions](https://threlte.xyz/docs/learn/getting-started/installation).
|
|
43
37
|
|
|
44
38
|
### Tutorial
|
|
45
39
|
|
package/dist/Box/Box.svelte.d.ts
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type BoxProps = NodeProps & {
|
|
5
|
-
order?: number | undefined
|
|
6
|
-
class?: string
|
|
7
|
-
|
|
8
|
-
children?: Snippet<
|
|
9
|
-
[
|
|
10
|
-
{
|
|
11
|
-
reflow: () => void
|
|
12
|
-
width: number
|
|
13
|
-
height: number
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
>
|
|
17
|
-
|
|
18
|
-
onreflow?: (event: { width: number; height: number }) => void
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default class Box extends SvelteComponent<BoxProps> {}
|
|
1
|
+
import type { BoxProps } from './types';
|
|
2
|
+
declare const Box: import("svelte").Component<BoxProps, {}, "">;
|
|
3
|
+
export default Box;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import type { NodeProps } from '../lib/props';
|
|
3
|
+
export type BoxProps = NodeProps & {
|
|
4
|
+
order?: number | undefined;
|
|
5
|
+
class?: string;
|
|
6
|
+
children?: Snippet<[
|
|
7
|
+
{
|
|
8
|
+
reflow: () => void;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
]>;
|
|
13
|
+
onreflow?: (event: {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}) => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {} from 'svelte';
|
package/dist/Flex/Flex.svelte
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">import { loadYoga } from 'yoga-layout/load';
|
|
2
2
|
import InnerFlex from './InnerFlex.svelte';
|
|
3
|
-
let { children: innerChildren, ...props } = $props();
|
|
3
|
+
let { children: innerChildren, ref = $bindable(), ...props } = $props();
|
|
4
4
|
let yoga = $state(undefined);
|
|
5
5
|
const initialize = async () => {
|
|
6
6
|
yoga = await loadYoga();
|
|
@@ -11,6 +11,7 @@ initialize();
|
|
|
11
11
|
{#if yoga}
|
|
12
12
|
<InnerFlex
|
|
13
13
|
{yoga}
|
|
14
|
+
bind:ref
|
|
14
15
|
{...props}
|
|
15
16
|
>
|
|
16
17
|
{#snippet children({ reflow, width, height })}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type FlexProps = Omit<ComponentProps<InnerFlex>, 'yoga'>
|
|
6
|
-
|
|
7
|
-
export default class Flex extends SvelteComponent<FlexProps> {}
|
|
1
|
+
import type { FlexProps } from './types';
|
|
2
|
+
declare const Flex: import("svelte").Component<FlexProps, {}, "ref">;
|
|
3
|
+
export default Flex;
|
|
@@ -11,7 +11,6 @@ import { propsChanged } from '../lib/propsChanged';
|
|
|
11
11
|
import { createNodeContext } from '../nodes/context';
|
|
12
12
|
import { createFlexContext } from './context';
|
|
13
13
|
let { yoga, width = 1, height = 1, plane = 'xy', direction = 'LTR', scaleFactor = 1000, classParser, class: _class = '', reflowStage, ref = $bindable(), onreflow, children, ...props } = $props();
|
|
14
|
-
$inspect(yoga);
|
|
15
14
|
ref = new Group();
|
|
16
15
|
ref.userData.isNode = true;
|
|
17
16
|
const boundingBox = new Box3();
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { ClassParser, FlexPlane, NodeProps } from '../lib/props'
|
|
5
|
-
import type { Group } from 'three'
|
|
6
|
-
|
|
7
|
-
type InnerFlexProps = NodeProps & {
|
|
8
|
-
yoga: Yoga
|
|
9
|
-
width?: number
|
|
10
|
-
height?: number
|
|
11
|
-
plane?: FlexPlane
|
|
12
|
-
direction?: keyof typeof Direction
|
|
13
|
-
scaleFactor?: number
|
|
14
|
-
class?: string
|
|
15
|
-
classParser?: ClassParser
|
|
16
|
-
reflowStage?: Stage
|
|
17
|
-
ref?: Group
|
|
18
|
-
|
|
19
|
-
children?: Snippet<
|
|
20
|
-
[
|
|
21
|
-
{
|
|
22
|
-
reflow: () => void
|
|
23
|
-
width: number
|
|
24
|
-
height: number
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
>
|
|
28
|
-
|
|
29
|
-
onreflow?: (event: { width: number; height: number }) => void
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default class InnerFlex extends SvelteComponent<InnerFlexProps> {}
|
|
1
|
+
import type { InnerFlexProps } from './types';
|
|
2
|
+
declare const InnerFlex: import("svelte").Component<InnerFlexProps, {}, "ref">;
|
|
3
|
+
export default InnerFlex;
|
package/dist/Flex/context.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { CurrentWritable } from '@threlte/core';
|
|
2
2
|
import { type Emitter } from 'mitt';
|
|
3
3
|
import type { Group } from 'three';
|
|
4
|
-
import type { Node
|
|
4
|
+
import type { Node } from 'yoga-layout';
|
|
5
|
+
import type Yoga from 'yoga-layout';
|
|
5
6
|
import type { Axis, ClassParser, NodeProps } from '../lib/props';
|
|
6
7
|
type FlexContextEvents = {
|
|
7
8
|
'reflow:before': void;
|
|
@@ -13,7 +14,7 @@ type FlexContextNode = {
|
|
|
13
14
|
props: NodeProps;
|
|
14
15
|
};
|
|
15
16
|
export type FlexContextData = {
|
|
16
|
-
yoga: Yoga;
|
|
17
|
+
yoga: typeof Yoga;
|
|
17
18
|
nodes: Map<Node, FlexContextNode>;
|
|
18
19
|
addNode: (node: Node, group: Group, props: NodeProps) => void;
|
|
19
20
|
updateNodeProps: (node: Node, props: NodeProps, force?: boolean) => void;
|
package/dist/Flex/context.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Stage } from '@threlte/core';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { Group } from 'three';
|
|
4
|
+
import type Yoga from 'yoga-layout';
|
|
5
|
+
import type { Direction } from 'yoga-layout';
|
|
6
|
+
import type { ClassParser, FlexPlane, NodeProps } from '../lib/props';
|
|
7
|
+
export type InnerFlexProps = NodeProps & {
|
|
8
|
+
yoga: typeof Yoga;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
plane?: FlexPlane;
|
|
12
|
+
direction?: keyof typeof Direction;
|
|
13
|
+
scaleFactor?: number;
|
|
14
|
+
class?: string;
|
|
15
|
+
classParser?: ClassParser;
|
|
16
|
+
reflowStage?: Stage;
|
|
17
|
+
ref?: Group;
|
|
18
|
+
children?: Snippet<[
|
|
19
|
+
{
|
|
20
|
+
reflow: () => void;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}
|
|
24
|
+
]>;
|
|
25
|
+
onreflow?: (event: {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}) => void;
|
|
29
|
+
};
|
|
30
|
+
export type FlexProps = Omit<InnerFlexProps, 'yoga'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/lib/props.d.ts
CHANGED
|
@@ -17,44 +17,44 @@ export declare const propSetter: {
|
|
|
17
17
|
justifyContent: (justify: keyof typeof Justify, node: Node) => void;
|
|
18
18
|
flexDirection: (dir: keyof typeof FlexDirection, node: Node) => void;
|
|
19
19
|
flexWrap: (wrap: keyof typeof Wrap, node: Node) => void;
|
|
20
|
-
flex: (flex: Parameters<Node[
|
|
21
|
-
flexBasis: (basis: Parameters<Node[
|
|
22
|
-
flexGrow: (grow: Parameters<Node[
|
|
23
|
-
flexShrink: (shrink: Parameters<Node[
|
|
24
|
-
height: (height: Parameters<Node[
|
|
25
|
-
width: (width: Parameters<Node[
|
|
26
|
-
maxHeight: (maxHeight: Parameters<Node[
|
|
27
|
-
maxWidth: (maxWidth: Parameters<Node[
|
|
28
|
-
minHeight: (minHeight: Parameters<Node[
|
|
29
|
-
minWidth: (minWidth: Parameters<Node[
|
|
20
|
+
flex: (flex: Parameters<Node["setFlex"]>[0], node: Node) => void;
|
|
21
|
+
flexBasis: (basis: Parameters<Node["setFlexBasis"]>[0], node: Node) => void;
|
|
22
|
+
flexGrow: (grow: Parameters<Node["setFlexGrow"]>[0], node: Node) => void;
|
|
23
|
+
flexShrink: (shrink: Parameters<Node["setFlexShrink"]>[0], node: Node) => void;
|
|
24
|
+
height: (height: Parameters<Node["setHeight"]>[0], node: Node) => void;
|
|
25
|
+
width: (width: Parameters<Node["setWidth"]>[0], node: Node) => void;
|
|
26
|
+
maxHeight: (maxHeight: Parameters<Node["setMaxHeight"]>[0], node: Node) => void;
|
|
27
|
+
maxWidth: (maxWidth: Parameters<Node["setMaxWidth"]>[0], node: Node) => void;
|
|
28
|
+
minHeight: (minHeight: Parameters<Node["setMinHeight"]>[0], node: Node) => void;
|
|
29
|
+
minWidth: (minWidth: Parameters<Node["setMinWidth"]>[0], node: Node) => void;
|
|
30
30
|
/** As of now, this won't work since the bounding box is still computed by nodes marked as absolutely positioned */
|
|
31
|
-
top: (top: Parameters<Node[
|
|
32
|
-
right: (right: Parameters<Node[
|
|
33
|
-
bottom: (bottom: Parameters<Node[
|
|
34
|
-
left: (left: Parameters<Node[
|
|
35
|
-
padding: (padding: Parameters<Node[
|
|
36
|
-
paddingTop: (paddingTop: Parameters<Node[
|
|
37
|
-
paddingRight: (paddingRight: Parameters<Node[
|
|
38
|
-
paddingBottom: (paddingBottom: Parameters<Node[
|
|
39
|
-
paddingLeft: (paddingLeft: Parameters<Node[
|
|
40
|
-
margin: (margin: Parameters<Node[
|
|
41
|
-
marginTop: (marginTop: Parameters<Node[
|
|
42
|
-
marginRight: (marginRight: Parameters<Node[
|
|
43
|
-
marginBottom: (marginBottom: Parameters<Node[
|
|
44
|
-
marginLeft: (marginLeft: Parameters<Node[
|
|
45
|
-
gap: (gap: Parameters<Node[
|
|
31
|
+
top: (top: Parameters<Node["setPosition"]>[1], node: Node) => void;
|
|
32
|
+
right: (right: Parameters<Node["setPosition"]>[1], node: Node) => void;
|
|
33
|
+
bottom: (bottom: Parameters<Node["setPosition"]>[1], node: Node) => void;
|
|
34
|
+
left: (left: Parameters<Node["setPosition"]>[1], node: Node) => void;
|
|
35
|
+
padding: (padding: Parameters<Node["setPadding"]>[1], node: Node) => void;
|
|
36
|
+
paddingTop: (paddingTop: Parameters<Node["setPadding"]>[1], node: Node) => void;
|
|
37
|
+
paddingRight: (paddingRight: Parameters<Node["setPadding"]>[1], node: Node) => void;
|
|
38
|
+
paddingBottom: (paddingBottom: Parameters<Node["setPadding"]>[1], node: Node) => void;
|
|
39
|
+
paddingLeft: (paddingLeft: Parameters<Node["setPadding"]>[1], node: Node) => void;
|
|
40
|
+
margin: (margin: Parameters<Node["setMargin"]>[1], node: Node) => void;
|
|
41
|
+
marginTop: (marginTop: Parameters<Node["setMargin"]>[1], node: Node) => void;
|
|
42
|
+
marginRight: (marginRight: Parameters<Node["setMargin"]>[1], node: Node) => void;
|
|
43
|
+
marginBottom: (marginBottom: Parameters<Node["setMargin"]>[1], node: Node) => void;
|
|
44
|
+
marginLeft: (marginLeft: Parameters<Node["setMargin"]>[1], node: Node) => void;
|
|
45
|
+
gap: (gap: Parameters<Node["setGap"]>[1], node: Node) => {
|
|
46
46
|
unit: Yoga.Unit;
|
|
47
47
|
value: number;
|
|
48
48
|
};
|
|
49
|
-
gapColumn: (gapColumn: Parameters<Node[
|
|
49
|
+
gapColumn: (gapColumn: Parameters<Node["setGap"]>[1], node: Node) => {
|
|
50
50
|
unit: Yoga.Unit;
|
|
51
51
|
value: number;
|
|
52
52
|
};
|
|
53
|
-
gapRow: (gapRow: Parameters<Node[
|
|
53
|
+
gapRow: (gapRow: Parameters<Node["setGap"]>[1], node: Node) => {
|
|
54
54
|
unit: Yoga.Unit;
|
|
55
55
|
value: number;
|
|
56
56
|
};
|
|
57
|
-
aspectRatio: (aspectRatio: Parameters<Node[
|
|
57
|
+
aspectRatio: (aspectRatio: Parameters<Node["setAspectRatio"]>[0], node: Node) => void;
|
|
58
58
|
};
|
|
59
59
|
export type NodeProps = {
|
|
60
60
|
[Key in keyof typeof propSetter]?: Parameters<(typeof propSetter)[Key]>[0];
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threlte/flex",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Components to easily use the flexbox spec with Threlte",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"@sveltejs/adapter-auto": "^3.
|
|
9
|
-
"@sveltejs/kit": "^2.7.
|
|
10
|
-
"@sveltejs/package": "^2.3.
|
|
11
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
8
|
+
"@sveltejs/adapter-auto": "^3.3.1",
|
|
9
|
+
"@sveltejs/kit": "^2.7.7",
|
|
10
|
+
"@sveltejs/package": "^2.3.7",
|
|
11
|
+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
12
12
|
"@types/node": "^20.12.7",
|
|
13
|
-
"@types/three": "^0.
|
|
13
|
+
"@types/three": "^0.175.0",
|
|
14
14
|
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
15
15
|
"@typescript-eslint/parser": "^7.6.0",
|
|
16
16
|
"@yushijinhun/three-minifier-rollup": "^0.4.0",
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
"prettier-plugin-svelte": "^3.2.2",
|
|
22
22
|
"publint": "^0.2.7",
|
|
23
23
|
"rimraf": "^5.0.5",
|
|
24
|
-
"svelte": "^5.
|
|
24
|
+
"svelte": "^5.26.2",
|
|
25
25
|
"svelte-check": "^3.6.9",
|
|
26
26
|
"svelte-preprocess": "^5.1.3",
|
|
27
27
|
"svelte2tsx": "^0.7.6",
|
|
28
|
-
"three": "^0.
|
|
28
|
+
"three": "^0.175.0",
|
|
29
29
|
"tslib": "^2.6.2",
|
|
30
|
-
"typescript": "^5.
|
|
30
|
+
"typescript": "^5.6.3",
|
|
31
31
|
"vite": "^5.2.8",
|
|
32
|
-
"@threlte/core": "8.0.
|
|
33
|
-
"@threlte/extras": "9.
|
|
32
|
+
"@threlte/core": "8.0.2",
|
|
33
|
+
"@threlte/extras": "9.1.2"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"mitt": "^3.0.1",
|
|
37
|
-
"yoga-layout": "^3.1
|
|
37
|
+
"yoga-layout": "^3.2.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"svelte": ">=5",
|