@gtkx/react 0.16.0 → 0.17.2

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 (75) 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 +354 -351
  7. package/dist/generated/jsx.js +2 -0
  8. package/dist/host-config.js +6 -11
  9. package/dist/jsx.d.ts +39 -10
  10. package/dist/jsx.js +7 -7
  11. package/dist/node.d.ts +1 -0
  12. package/dist/node.js +9 -0
  13. package/dist/nodes/abstract/virtual-container.d.ts +5 -1
  14. package/dist/nodes/abstract/virtual-container.js +9 -0
  15. package/dist/nodes/abstract/virtual-single-child.js +2 -1
  16. package/dist/nodes/action-row-child.js +8 -0
  17. package/dist/nodes/animation.d.ts +1 -0
  18. package/dist/nodes/animation.js +252 -0
  19. package/dist/nodes/event-controller.d.ts +22 -1
  20. package/dist/nodes/event-controller.js +2 -2
  21. package/dist/nodes/expander-row-child.js +8 -0
  22. package/dist/nodes/fixed-child.js +4 -0
  23. package/dist/nodes/grid-child.js +4 -0
  24. package/dist/nodes/index.d.ts +2 -4
  25. package/dist/nodes/index.js +2 -4
  26. package/dist/nodes/internal/deferred-action.d.ts +1 -0
  27. package/dist/nodes/internal/deferred-action.js +3 -0
  28. package/dist/nodes/internal/list-store.d.ts +4 -6
  29. package/dist/nodes/internal/list-store.js +26 -31
  30. package/dist/nodes/internal/selection-model.js +0 -4
  31. package/dist/nodes/internal/signal-store.d.ts +4 -1
  32. package/dist/nodes/internal/signal-store.js +6 -8
  33. package/dist/nodes/internal/text-buffer-controller.js +1 -1
  34. package/dist/nodes/internal/tree-store.d.ts +2 -6
  35. package/dist/nodes/internal/tree-store.js +58 -56
  36. package/dist/nodes/list-view.js +2 -1
  37. package/dist/nodes/models/tree-list.js +1 -1
  38. package/dist/nodes/overlay-child.js +7 -7
  39. package/dist/nodes/pack-child.js +8 -0
  40. package/dist/nodes/shortcut-controller.js +6 -61
  41. package/dist/nodes/slot.js +1 -1
  42. package/dist/nodes/text-paintable.d.ts +6 -0
  43. package/dist/nodes/toggle-group.js +1 -1
  44. package/dist/nodes/toolbar-child.js +22 -29
  45. package/dist/nodes/tree-list-view.js +2 -1
  46. package/dist/nodes/web-view.d.ts +1 -0
  47. package/dist/nodes/web-view.js +29 -0
  48. package/dist/render.js +1 -1
  49. package/package.json +4 -4
  50. package/dist/nodes/abstract/positional-parent.d.ts +0 -18
  51. package/dist/nodes/abstract/positional-parent.js +0 -48
  52. package/dist/nodes/action-row.d.ts +0 -6
  53. package/dist/nodes/action-row.js +0 -13
  54. package/dist/nodes/animation/animation-controller.d.ts +0 -17
  55. package/dist/nodes/animation/animation-controller.js +0 -107
  56. package/dist/nodes/animation/animation-factory.d.ts +0 -15
  57. package/dist/nodes/animation/animation-factory.js +0 -25
  58. package/dist/nodes/animation/animation-node.d.ts +0 -9
  59. package/dist/nodes/animation/animation-node.js +0 -126
  60. package/dist/nodes/animation/animation-style-sheet.d.ts +0 -16
  61. package/dist/nodes/animation/animation-style-sheet.js +0 -74
  62. package/dist/nodes/animation/index.d.ts +0 -4
  63. package/dist/nodes/animation/index.js +0 -1
  64. package/dist/nodes/animation/property-mapper.d.ts +0 -11
  65. package/dist/nodes/animation/property-mapper.js +0 -36
  66. package/dist/nodes/animation/transform-state.d.ts +0 -11
  67. package/dist/nodes/animation/transform-state.js +0 -57
  68. package/dist/nodes/animation/widget-registry.d.ts +0 -5
  69. package/dist/nodes/animation/widget-registry.js +0 -42
  70. package/dist/nodes/expander-row.d.ts +0 -6
  71. package/dist/nodes/expander-row.js +0 -18
  72. package/dist/nodes/internal/base-store.d.ts +0 -9
  73. package/dist/nodes/internal/base-store.js +0 -20
  74. package/dist/nodes/pack.d.ts +0 -6
  75. package/dist/nodes/pack.js +0 -13
@@ -1,16 +0,0 @@
1
- export declare function getAnimationStyleSheet(): AnimationStyleSheet;
2
- declare class AnimationStyleSheet {
3
- private provider;
4
- private display;
5
- private rules;
6
- private dirty;
7
- private flushScheduled;
8
- setRule(widgetId: string, transformCss: string): void;
9
- removeRule(widgetId: string): void;
10
- private markDirty;
11
- private scheduleFlush;
12
- private flush;
13
- private ensureProvider;
14
- dispose(): void;
15
- }
16
- export {};
@@ -1,74 +0,0 @@
1
- import { isStarted } from "@gtkx/ffi";
2
- import * as Gdk from "@gtkx/ffi/gdk";
3
- import * as Gtk from "@gtkx/ffi/gtk";
4
- const STYLE_PROVIDER_PRIORITY_ANIMATIONS = 700;
5
- let instance = null;
6
- export function getAnimationStyleSheet() {
7
- if (!instance) {
8
- instance = new AnimationStyleSheet();
9
- }
10
- return instance;
11
- }
12
- class AnimationStyleSheet {
13
- provider = null;
14
- display = null;
15
- rules = new Map();
16
- dirty = false;
17
- flushScheduled = false;
18
- setRule(widgetId, transformCss) {
19
- const rule = `#${widgetId} { transform-origin: center center; transform: ${transformCss}; }`;
20
- this.rules.set(widgetId, rule);
21
- this.markDirty();
22
- }
23
- removeRule(widgetId) {
24
- if (this.rules.delete(widgetId)) {
25
- this.markDirty();
26
- }
27
- }
28
- markDirty() {
29
- this.dirty = true;
30
- this.scheduleFlush();
31
- }
32
- scheduleFlush() {
33
- if (this.flushScheduled)
34
- return;
35
- this.flushScheduled = true;
36
- if (isStarted) {
37
- queueMicrotask(() => this.flush());
38
- }
39
- }
40
- flush() {
41
- this.flushScheduled = false;
42
- if (!this.dirty)
43
- return;
44
- this.dirty = false;
45
- if (!isStarted)
46
- return;
47
- this.ensureProvider();
48
- if (this.rules.size === 0) {
49
- this.provider?.loadFromString("");
50
- return;
51
- }
52
- const css = [...this.rules.values()].join("\n");
53
- this.provider?.loadFromString(css);
54
- }
55
- ensureProvider() {
56
- if (this.provider)
57
- return;
58
- this.provider = new Gtk.CssProvider();
59
- this.display = Gdk.DisplayManager.get().getDefaultDisplay();
60
- if (this.display) {
61
- Gtk.StyleContext.addProviderForDisplay(this.display, this.provider, STYLE_PROVIDER_PRIORITY_ANIMATIONS);
62
- }
63
- }
64
- dispose() {
65
- if (this.provider && this.display) {
66
- Gtk.StyleContext.removeProviderForDisplay(this.display, this.provider);
67
- }
68
- this.provider = null;
69
- this.display = null;
70
- this.rules.clear();
71
- this.dirty = false;
72
- this.flushScheduled = false;
73
- }
74
- }
@@ -1,4 +0,0 @@
1
- import "./animation-node.js";
2
- export type { AnimatableProperties } from "./animation-controller.js";
3
- export type { SpringTransition, TimedTransition, Transition } from "./animation-factory.js";
4
- export type { AnimationProps } from "./animation-node.js";
@@ -1 +0,0 @@
1
- import "./animation-node.js";
@@ -1,11 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import type { TransformProperty } from "./transform-state.js";
3
- export type AnimatableProperty = TransformProperty | "opacity";
4
- type PropertyAccessor = {
5
- get: (widget: Gtk.Widget) => number;
6
- set: (widget: Gtk.Widget, value: number) => void;
7
- };
8
- export declare function getPropertyAccessor(property: AnimatableProperty): PropertyAccessor;
9
- export declare function isAnimatableProperty(property: string): property is AnimatableProperty;
10
- export declare function isTransformProperty(property: string): property is TransformProperty;
11
- export {};
@@ -1,36 +0,0 @@
1
- import { getTransformState } from "./widget-registry.js";
2
- const TRANSFORM_DEFAULTS = {
3
- x: 0,
4
- y: 0,
5
- scale: 1,
6
- scaleX: 1,
7
- scaleY: 1,
8
- rotate: 0,
9
- };
10
- function createTransformAccessor(property) {
11
- return {
12
- get: (widget) => getTransformState(widget)?.get(property) ?? TRANSFORM_DEFAULTS[property],
13
- set: (widget, value) => getTransformState(widget)?.set(property, value),
14
- };
15
- }
16
- const propertyAccessors = {
17
- opacity: {
18
- get: (widget) => widget.getOpacity(),
19
- set: (widget, value) => widget.setOpacity(value),
20
- },
21
- x: createTransformAccessor("x"),
22
- y: createTransformAccessor("y"),
23
- scale: createTransformAccessor("scale"),
24
- scaleX: createTransformAccessor("scaleX"),
25
- scaleY: createTransformAccessor("scaleY"),
26
- rotate: createTransformAccessor("rotate"),
27
- };
28
- export function getPropertyAccessor(property) {
29
- return propertyAccessors[property];
30
- }
31
- export function isAnimatableProperty(property) {
32
- return property in propertyAccessors;
33
- }
34
- export function isTransformProperty(property) {
35
- return property in TRANSFORM_DEFAULTS;
36
- }
@@ -1,11 +0,0 @@
1
- export type TransformProperty = "x" | "y" | "scale" | "scaleX" | "scaleY" | "rotate";
2
- export declare class TransformState {
3
- private values;
4
- private onChangeCallback;
5
- constructor(onChange?: () => void);
6
- get(property: TransformProperty): number;
7
- set(property: TransformProperty, value: number): void;
8
- isDefault(): boolean;
9
- toCss(): string;
10
- reset(): void;
11
- }
@@ -1,57 +0,0 @@
1
- const DEFAULT_VALUES = {
2
- x: 0,
3
- y: 0,
4
- scale: 1,
5
- scaleX: 1,
6
- scaleY: 1,
7
- rotate: 0,
8
- };
9
- export class TransformState {
10
- values = { ...DEFAULT_VALUES };
11
- onChangeCallback = null;
12
- constructor(onChange) {
13
- this.onChangeCallback = onChange ?? null;
14
- }
15
- get(property) {
16
- return this.values[property];
17
- }
18
- set(property, value) {
19
- if (this.values[property] !== value) {
20
- this.values[property] = value;
21
- this.onChangeCallback?.();
22
- }
23
- }
24
- isDefault() {
25
- return (this.values.x === 0 &&
26
- this.values.y === 0 &&
27
- this.values.scale === 1 &&
28
- this.values.scaleX === 1 &&
29
- this.values.scaleY === 1 &&
30
- this.values.rotate === 0);
31
- }
32
- toCss() {
33
- const transforms = [];
34
- if (this.values.x !== 0 || this.values.y !== 0) {
35
- transforms.push(`translate(${this.values.x}px, ${this.values.y}px)`);
36
- }
37
- const hasUniformScale = this.values.scale !== 1;
38
- const hasAxisScale = this.values.scaleX !== 1 || this.values.scaleY !== 1;
39
- if (hasUniformScale) {
40
- transforms.push(`scale(${this.values.scale})`);
41
- }
42
- else if (hasAxisScale) {
43
- transforms.push(`scale(${this.values.scaleX}, ${this.values.scaleY})`);
44
- }
45
- if (this.values.rotate !== 0) {
46
- transforms.push(`rotate(${this.values.rotate}deg)`);
47
- }
48
- return transforms.length > 0 ? transforms.join(" ") : "none";
49
- }
50
- reset() {
51
- const wasDefault = this.isDefault();
52
- this.values = { ...DEFAULT_VALUES };
53
- if (!wasDefault) {
54
- this.onChangeCallback?.();
55
- }
56
- }
57
- }
@@ -1,5 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- import { TransformState } from "./transform-state.js";
3
- export declare function registerWidget(widget: Gtk.Widget): TransformState;
4
- export declare function unregisterWidget(widget: Gtk.Widget): void;
5
- export declare function getTransformState(widget: Gtk.Widget): TransformState | null;
@@ -1,42 +0,0 @@
1
- import { getNativeId } from "@gtkx/ffi";
2
- import { getAnimationStyleSheet } from "./animation-style-sheet.js";
3
- import { TransformState } from "./transform-state.js";
4
- const widgets = new WeakMap();
5
- const styleSheet = getAnimationStyleSheet();
6
- export function registerWidget(widget) {
7
- const existing = widgets.get(widget);
8
- if (existing) {
9
- return existing.transformState;
10
- }
11
- const nativeId = getNativeId(widget.handle);
12
- const cssId = `gtkx-anim-${nativeId}`;
13
- const originalName = widget.getName();
14
- widget.setName(cssId);
15
- const transformState = new TransformState(() => {
16
- if (transformState.isDefault()) {
17
- styleSheet.removeRule(cssId);
18
- }
19
- else {
20
- styleSheet.setRule(cssId, transformState.toCss());
21
- }
22
- });
23
- widgets.set(widget, {
24
- cssId,
25
- originalName,
26
- transformState,
27
- });
28
- return transformState;
29
- }
30
- export function unregisterWidget(widget) {
31
- const entry = widgets.get(widget);
32
- if (!entry)
33
- return;
34
- styleSheet.removeRule(entry.cssId);
35
- if (entry.originalName !== null) {
36
- widget.setName(entry.originalName);
37
- }
38
- widgets.delete(widget);
39
- }
40
- export function getTransformState(widget) {
41
- return widgets.get(widget)?.transformState ?? null;
42
- }
@@ -1,6 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- export type ExpanderRowWidget = Gtk.Widget & {
3
- addRow(child: Gtk.Widget): void;
4
- addAction(child: Gtk.Widget): void;
5
- remove(child: Gtk.Widget): void;
6
- };
@@ -1,18 +0,0 @@
1
- import * as Adw from "@gtkx/ffi/adw";
2
- import { registerNodeClass } from "../registry.js";
3
- import { PositionalParentNode } from "./abstract/positional-parent.js";
4
- import { matchesAnyClass } from "./internal/utils.js";
5
- class ExpanderRowNode extends PositionalParentNode {
6
- static priority = -1;
7
- acceptedPositionalChildTypes = new Set([
8
- "ExpanderRowRow",
9
- "ExpanderRowAction",
10
- "ActionRowPrefix",
11
- "ActionRowSuffix",
12
- ]);
13
- containerTypeName = "ExpanderRow";
14
- static matches(_type, containerOrClass) {
15
- return matchesAnyClass([Adw.ExpanderRow], containerOrClass);
16
- }
17
- }
18
- registerNodeClass(ExpanderRowNode);
@@ -1,9 +0,0 @@
1
- export declare abstract class BaseStore<TItem = unknown> {
2
- protected items: Map<string, TItem>;
3
- private syncAction;
4
- constructor();
5
- getItem(id: string): TItem | undefined;
6
- updateItem(id: string, item: TItem): void;
7
- protected scheduleSync(): void;
8
- protected abstract sync(): void;
9
- }
@@ -1,20 +0,0 @@
1
- import { CommitPriority } from "../../scheduler.js";
2
- import { DeferredAction } from "./deferred-action.js";
3
- export class BaseStore {
4
- items = new Map();
5
- syncAction;
6
- constructor() {
7
- this.syncAction = new DeferredAction(() => this.sync(), CommitPriority.LOW);
8
- }
9
- getItem(id) {
10
- return this.items.get(id);
11
- }
12
- updateItem(id, item) {
13
- if (this.items.has(id)) {
14
- this.items.set(id, item);
15
- }
16
- }
17
- scheduleSync() {
18
- this.syncAction.schedule();
19
- }
20
- }
@@ -1,6 +0,0 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
- export type PackableWidget = Gtk.Widget & {
3
- packStart(child: Gtk.Widget): void;
4
- packEnd(child: Gtk.Widget): void;
5
- remove(child: Gtk.Widget): void;
6
- };
@@ -1,13 +0,0 @@
1
- import { PACK_INTERFACE_METHODS } from "../generated/internal.js";
2
- import { registerNodeClass } from "../registry.js";
3
- import { PositionalParentNode } from "./abstract/positional-parent.js";
4
- import { matchesInterface } from "./internal/utils.js";
5
- class PackNode extends PositionalParentNode {
6
- static priority = 0;
7
- acceptedPositionalChildTypes = new Set(["PackStart", "PackEnd"]);
8
- containerTypeName = "Pack";
9
- static matches(_type, containerOrClass) {
10
- return matchesInterface(PACK_INTERFACE_METHODS, containerOrClass);
11
- }
12
- }
13
- registerNodeClass(PackNode);