@threlte/flex 2.0.0-next.10 → 2.0.0-next.12

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.
@@ -1,21 +1,3 @@
1
- import { SvelteComponent, type Snippet } from 'svelte'
2
- import type { NodeProps } from '../lib/props'
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
+ export {};
@@ -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 { SvelteComponent } from 'svelte'
2
- import type { ComponentProps } from 'svelte'
3
- import type InnerFlex from './InnerFlex.svelte'
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;
@@ -1,32 +1,3 @@
1
- import type { Stage } from '@threlte/core'
2
- import { SvelteComponent, type Snippet } from 'svelte'
3
- import type { Direction, Yoga } from 'yoga-layout'
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;
@@ -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, Yoga } from 'yoga-layout';
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;
@@ -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 {};
@@ -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['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;
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['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) => {
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['setGap']>[1], node: 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['setGap']>[1], node: 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['setAspectRatio']>[0], node: Node) => void;
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,14 +1,14 @@
1
1
  {
2
2
  "name": "@threlte/flex",
3
- "version": "2.0.0-next.10",
3
+ "version": "2.0.0-next.12",
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.2.0",
9
- "@sveltejs/kit": "^2.7.2",
8
+ "@sveltejs/adapter-auto": "^3.3.1",
9
+ "@sveltejs/kit": "^2.7.7",
10
10
  "@sveltejs/package": "^2.3.7",
11
- "@sveltejs/vite-plugin-svelte": "^3.1.0",
11
+ "@sveltejs/vite-plugin-svelte": "^4.0.0",
12
12
  "@types/node": "^20.12.7",
13
13
  "@types/three": "^0.169.0",
14
14
  "@typescript-eslint/eslint-plugin": "^7.6.0",
@@ -21,16 +21,16 @@
21
21
  "prettier-plugin-svelte": "^3.2.2",
22
22
  "publint": "^0.2.7",
23
23
  "rimraf": "^5.0.5",
24
- "svelte": "^5.1.6",
24
+ "svelte": "^5.1.10",
25
25
  "svelte-check": "^3.6.9",
26
26
  "svelte-preprocess": "^5.1.3",
27
27
  "svelte2tsx": "^0.7.6",
28
- "three": "^0.169.0",
28
+ "three": "^0.170.0",
29
29
  "tslib": "^2.6.2",
30
- "typescript": "^5.4.5",
30
+ "typescript": "^5.6.3",
31
31
  "vite": "^5.2.8",
32
- "@threlte/core": "8.0.0-next.23",
33
- "@threlte/extras": "9.0.0-next.32"
32
+ "@threlte/core": "8.0.0-next.28",
33
+ "@threlte/extras": "9.0.0-next.37"
34
34
  },
35
35
  "dependencies": {
36
36
  "mitt": "^3.0.1",