@gtkx/react 0.16.0 → 0.17.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.
Files changed (73) hide show
  1. package/dist/animation/css-builder.d.ts +3 -0
  2. package/dist/animation/css-builder.js +53 -0
  3. package/dist/animation/types.d.ts +120 -0
  4. package/dist/animation/types.js +1 -0
  5. package/dist/fiber-root.js +1 -1
  6. package/dist/generated/jsx.d.ts +351 -351
  7. package/dist/host-config.js +6 -11
  8. package/dist/jsx.d.ts +39 -10
  9. package/dist/jsx.js +7 -7
  10. package/dist/node.d.ts +1 -0
  11. package/dist/node.js +9 -0
  12. package/dist/nodes/abstract/virtual-container.d.ts +5 -1
  13. package/dist/nodes/abstract/virtual-container.js +9 -0
  14. package/dist/nodes/abstract/virtual-single-child.js +2 -1
  15. package/dist/nodes/action-row-child.js +8 -0
  16. package/dist/nodes/animation.d.ts +1 -0
  17. package/dist/nodes/animation.js +252 -0
  18. package/dist/nodes/event-controller.d.ts +22 -1
  19. package/dist/nodes/event-controller.js +2 -2
  20. package/dist/nodes/expander-row-child.js +8 -0
  21. package/dist/nodes/fixed-child.js +4 -0
  22. package/dist/nodes/grid-child.js +4 -0
  23. package/dist/nodes/index.d.ts +2 -4
  24. package/dist/nodes/index.js +2 -4
  25. package/dist/nodes/internal/deferred-action.d.ts +1 -0
  26. package/dist/nodes/internal/deferred-action.js +3 -0
  27. package/dist/nodes/internal/list-store.d.ts +4 -6
  28. package/dist/nodes/internal/list-store.js +26 -31
  29. package/dist/nodes/internal/selection-model.js +0 -4
  30. package/dist/nodes/internal/signal-store.d.ts +4 -1
  31. package/dist/nodes/internal/signal-store.js +6 -8
  32. package/dist/nodes/internal/text-buffer-controller.js +1 -1
  33. package/dist/nodes/internal/tree-store.d.ts +2 -6
  34. package/dist/nodes/internal/tree-store.js +58 -56
  35. package/dist/nodes/list-view.js +2 -1
  36. package/dist/nodes/models/tree-list.js +1 -1
  37. package/dist/nodes/overlay-child.js +7 -7
  38. package/dist/nodes/pack-child.js +8 -0
  39. package/dist/nodes/shortcut-controller.js +6 -61
  40. package/dist/nodes/slot.js +1 -1
  41. package/dist/nodes/toggle-group.js +1 -1
  42. package/dist/nodes/toolbar-child.js +22 -29
  43. package/dist/nodes/tree-list-view.js +2 -1
  44. package/dist/nodes/web-view.d.ts +1 -0
  45. package/dist/nodes/web-view.js +29 -0
  46. package/dist/render.js +1 -1
  47. package/package.json +4 -4
  48. package/dist/nodes/abstract/positional-parent.d.ts +0 -18
  49. package/dist/nodes/abstract/positional-parent.js +0 -48
  50. package/dist/nodes/action-row.d.ts +0 -6
  51. package/dist/nodes/action-row.js +0 -13
  52. package/dist/nodes/animation/animation-controller.d.ts +0 -17
  53. package/dist/nodes/animation/animation-controller.js +0 -107
  54. package/dist/nodes/animation/animation-factory.d.ts +0 -15
  55. package/dist/nodes/animation/animation-factory.js +0 -25
  56. package/dist/nodes/animation/animation-node.d.ts +0 -9
  57. package/dist/nodes/animation/animation-node.js +0 -126
  58. package/dist/nodes/animation/animation-style-sheet.d.ts +0 -16
  59. package/dist/nodes/animation/animation-style-sheet.js +0 -74
  60. package/dist/nodes/animation/index.d.ts +0 -4
  61. package/dist/nodes/animation/index.js +0 -1
  62. package/dist/nodes/animation/property-mapper.d.ts +0 -11
  63. package/dist/nodes/animation/property-mapper.js +0 -36
  64. package/dist/nodes/animation/transform-state.d.ts +0 -11
  65. package/dist/nodes/animation/transform-state.js +0 -57
  66. package/dist/nodes/animation/widget-registry.d.ts +0 -5
  67. package/dist/nodes/animation/widget-registry.js +0 -42
  68. package/dist/nodes/expander-row.d.ts +0 -6
  69. package/dist/nodes/expander-row.js +0 -18
  70. package/dist/nodes/internal/base-store.d.ts +0 -9
  71. package/dist/nodes/internal/base-store.js +0 -20
  72. package/dist/nodes/pack.d.ts +0 -6
  73. package/dist/nodes/pack.js +0 -13
@@ -0,0 +1,3 @@
1
+ import type { AnimatableProperties } from "./types.js";
2
+ export declare const interpolate: (from: AnimatableProperties, to: AnimatableProperties, progress: number) => AnimatableProperties;
3
+ export declare const buildCss: (className: string, props: AnimatableProperties) => string;
@@ -0,0 +1,53 @@
1
+ const getDefaultValue = (property) => {
2
+ switch (property) {
3
+ case "opacity":
4
+ case "scale":
5
+ case "scaleX":
6
+ case "scaleY":
7
+ return 1;
8
+ default:
9
+ return 0;
10
+ }
11
+ };
12
+ export const interpolate = (from, to, progress) => {
13
+ const result = {};
14
+ const allKeys = new Set([...Object.keys(from), ...Object.keys(to)]);
15
+ for (const key of allKeys) {
16
+ const fromVal = from[key] ?? getDefaultValue(key);
17
+ const toVal = to[key] ?? getDefaultValue(key);
18
+ result[key] = fromVal + (toVal - fromVal) * progress;
19
+ }
20
+ return result;
21
+ };
22
+ export const buildCss = (className, props) => {
23
+ const parts = [];
24
+ const transforms = [];
25
+ if (props.opacity !== undefined) {
26
+ parts.push(`opacity: ${props.opacity}`);
27
+ }
28
+ if (props.translateX !== undefined || props.translateY !== undefined) {
29
+ transforms.push(`translate(${props.translateX ?? 0}px, ${props.translateY ?? 0}px)`);
30
+ }
31
+ if (props.scale !== undefined) {
32
+ transforms.push(`scale(${props.scale})`);
33
+ }
34
+ else if (props.scaleX !== undefined || props.scaleY !== undefined) {
35
+ transforms.push(`scale(${props.scaleX ?? 1}, ${props.scaleY ?? 1})`);
36
+ }
37
+ if (props.rotate !== undefined) {
38
+ transforms.push(`rotate(${props.rotate}deg)`);
39
+ }
40
+ if (props.skewX !== undefined) {
41
+ transforms.push(`skewX(${props.skewX}deg)`);
42
+ }
43
+ if (props.skewY !== undefined) {
44
+ transforms.push(`skewY(${props.skewY}deg)`);
45
+ }
46
+ if (transforms.length > 0) {
47
+ parts.push(`transform: ${transforms.join(" ")}`);
48
+ }
49
+ if (parts.length === 0) {
50
+ return "";
51
+ }
52
+ return `.${className} { ${parts.join("; ")}; }`;
53
+ };
@@ -0,0 +1,120 @@
1
+ import type { Easing } from "@gtkx/ffi/adw";
2
+ import type { ReactNode } from "react";
3
+ /**
4
+ * The type of animation to use.
5
+ *
6
+ * - `"timed"`: Duration-based animation with easing curves (uses {@link Adw.TimedAnimation})
7
+ * - `"spring"`: Physics-based spring animation (uses {@link Adw.SpringAnimation})
8
+ */
9
+ export type AnimationMode = "timed" | "spring";
10
+ /**
11
+ * A numeric value that can be animated.
12
+ */
13
+ export type AnimatableValue = number;
14
+ /**
15
+ * CSS properties that can be animated on a widget.
16
+ *
17
+ * All transforms are applied via GTK CSS and rendered through the widget's style context.
18
+ */
19
+ export type AnimatableProperties = {
20
+ /** Opacity from 0 (fully transparent) to 1 (fully opaque) */
21
+ opacity?: AnimatableValue;
22
+ /** Horizontal translation in pixels (positive moves right) */
23
+ translateX?: AnimatableValue;
24
+ /** Vertical translation in pixels (positive moves down) */
25
+ translateY?: AnimatableValue;
26
+ /** Uniform scale factor (1 = original size, 2 = double size) */
27
+ scale?: AnimatableValue;
28
+ /** Horizontal scale factor */
29
+ scaleX?: AnimatableValue;
30
+ /** Vertical scale factor */
31
+ scaleY?: AnimatableValue;
32
+ /** Rotation angle in degrees (positive rotates clockwise) */
33
+ rotate?: AnimatableValue;
34
+ /** Horizontal skew angle in degrees */
35
+ skewX?: AnimatableValue;
36
+ /** Vertical skew angle in degrees */
37
+ skewY?: AnimatableValue;
38
+ };
39
+ /**
40
+ * Transition configuration for timed (duration-based) animations.
41
+ *
42
+ * @see {@link https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TimedAnimation.html Adw.TimedAnimation}
43
+ */
44
+ export type TimedTransition = {
45
+ /** Animation duration in milliseconds (default: 300) */
46
+ duration?: number;
47
+ /** Easing function for the animation curve (default: EASE_OUT_CUBIC) */
48
+ easing?: Easing;
49
+ /** Delay before starting the animation in milliseconds */
50
+ delay?: number;
51
+ /** Number of times to repeat the animation (0 = no repeat, -1 = infinite) */
52
+ repeat?: number;
53
+ /** Whether to play the animation in reverse */
54
+ reverse?: boolean;
55
+ /** Whether to alternate direction on each repeat */
56
+ alternate?: boolean;
57
+ };
58
+ /**
59
+ * Transition configuration for spring (physics-based) animations.
60
+ *
61
+ * Spring animations simulate a mass attached to a spring, providing natural-feeling motion.
62
+ * The animation settles when the spring reaches equilibrium.
63
+ *
64
+ * @see {@link https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.SpringAnimation.html Adw.SpringAnimation}
65
+ */
66
+ export type SpringTransition = {
67
+ /** Damping ratio controlling oscillation decay (default: 1, critically damped) */
68
+ damping?: number;
69
+ /** Spring stiffness in N/m affecting animation speed (default: 100) */
70
+ stiffness?: number;
71
+ /** Virtual mass in kg affecting momentum (default: 1) */
72
+ mass?: number;
73
+ /** Initial velocity to apply at animation start */
74
+ initialVelocity?: number;
75
+ /** Whether to clamp the animation value to prevent overshooting */
76
+ clamp?: boolean;
77
+ /** Delay before starting the animation in milliseconds */
78
+ delay?: number;
79
+ };
80
+ /**
81
+ * Props for the Animation component.
82
+ *
83
+ * Provides a declarative API for animating widget properties using either
84
+ * timed (duration-based) or spring (physics-based) animations.
85
+ *
86
+ * @typeParam M - The animation mode, either `"timed"` or `"spring"`
87
+ *
88
+ * @example
89
+ * ```tsx
90
+ * <x.Animation
91
+ * mode="spring"
92
+ * initial={{ opacity: 0, translateY: -20 }}
93
+ * animate={{ opacity: 1, translateY: 0 }}
94
+ * exit={{ opacity: 0, translateY: 20 }}
95
+ * animateOnMount
96
+ * >
97
+ * <GtkLabel label="Animated content" />
98
+ * </x.Animation>
99
+ * ```
100
+ */
101
+ export type AnimationProps<M extends AnimationMode = AnimationMode> = {
102
+ /** Animation type: `"timed"` for duration-based or `"spring"` for physics-based */
103
+ mode: M;
104
+ /** Initial property values before animation starts, or `false` to skip initial state */
105
+ initial?: AnimatableProperties | false;
106
+ /** Target property values to animate towards */
107
+ animate?: AnimatableProperties;
108
+ /** Property values to animate to when the component unmounts */
109
+ exit?: AnimatableProperties;
110
+ /** Transition configuration (type depends on mode) */
111
+ transition?: M extends "timed" ? TimedTransition : SpringTransition;
112
+ /** Whether to animate from `initial` to `animate` when first mounted (default: false) */
113
+ animateOnMount?: boolean;
114
+ /** Callback fired when an animation begins */
115
+ onAnimationStart?: () => void;
116
+ /** Callback fired when an animation completes */
117
+ onAnimationComplete?: () => void;
118
+ /** The child widget to animate (must be a single GTK widget) */
119
+ children?: ReactNode;
120
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { reconciler } from "./reconciler.js";
2
2
  export const createFiberRoot = (container) => {
3
3
  const instance = reconciler.getInstance();
4
- return instance.createContainer(container, 1, null, false, null, "", (error) => console.error("Fiber root render error:", error), () => { }, () => { }, () => { }, null);
4
+ return instance.createContainer(container, 1, null, false, null, "", (error) => console.error("Fiber root render error:", error), () => { }, () => { }, () => { });
5
5
  };