@gtkx/components 1.0.0-rc.3 → 1.0.0
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 +8 -9
- package/dist/adw/combo-row.d.ts +1 -0
- package/dist/adw/combo-row.d.ts.map +1 -1
- package/dist/adw/combo-row.js.map +1 -1
- package/dist/adw/types.d.ts +2 -1
- package/dist/adw/types.d.ts.map +1 -1
- package/dist/adw/types.js.map +1 -1
- package/dist/column-view.d.ts +2 -2
- package/dist/column-view.d.ts.map +1 -1
- package/dist/column-view.js +15 -13
- package/dist/column-view.js.map +1 -1
- package/dist/drop-down.d.ts +1 -0
- package/dist/drop-down.d.ts.map +1 -1
- package/dist/drop-down.js.map +1 -1
- package/dist/grid-view.js +2 -2
- package/dist/grid-view.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/cells.d.ts +32 -24
- package/dist/internal/cells.d.ts.map +1 -1
- package/dist/internal/cells.js +168 -77
- package/dist/internal/cells.js.map +1 -1
- package/dist/internal/collection-index.d.ts +9 -13
- package/dist/internal/collection-index.d.ts.map +1 -1
- package/dist/internal/collection-index.js +33 -70
- package/dist/internal/collection-index.js.map +1 -1
- package/dist/internal/collection-model.d.ts +23 -2
- package/dist/internal/collection-model.d.ts.map +1 -1
- package/dist/internal/collection-model.js +210 -98
- package/dist/internal/collection-model.js.map +1 -1
- package/dist/internal/collection.d.ts +9 -12
- package/dist/internal/collection.d.ts.map +1 -1
- package/dist/internal/collection.js +38 -49
- package/dist/internal/collection.js.map +1 -1
- package/dist/internal/controlled-sync.d.ts +11 -0
- package/dist/internal/controlled-sync.d.ts.map +1 -0
- package/dist/internal/controlled-sync.js +19 -0
- package/dist/internal/controlled-sync.js.map +1 -0
- package/dist/internal/drop-down.d.ts.map +1 -1
- package/dist/internal/drop-down.js +27 -15
- package/dist/internal/drop-down.js.map +1 -1
- package/dist/internal/expansion.d.ts +3 -2
- package/dist/internal/expansion.d.ts.map +1 -1
- package/dist/internal/expansion.js +80 -47
- package/dist/internal/expansion.js.map +1 -1
- package/dist/internal/keys.d.ts +5 -0
- package/dist/internal/keys.d.ts.map +1 -0
- package/dist/internal/keys.js +13 -0
- package/dist/internal/keys.js.map +1 -0
- package/dist/internal/selection.d.ts +3 -2
- package/dist/internal/selection.d.ts.map +1 -1
- package/dist/internal/selection.js +68 -35
- package/dist/internal/selection.js.map +1 -1
- package/dist/internal/slots.d.ts +10 -0
- package/dist/internal/slots.d.ts.map +1 -0
- package/dist/internal/slots.js +43 -0
- package/dist/internal/slots.js.map +1 -0
- package/dist/internal/tree-expansion.d.ts +20 -0
- package/dist/internal/tree-expansion.d.ts.map +1 -0
- package/dist/internal/tree-expansion.js +68 -0
- package/dist/internal/tree-expansion.js.map +1 -0
- package/dist/internal/tree-order.d.ts +27 -0
- package/dist/internal/tree-order.d.ts.map +1 -0
- package/dist/internal/tree-order.js +71 -0
- package/dist/internal/tree-order.js.map +1 -0
- package/dist/internal/use-collection.d.ts +5 -5
- package/dist/internal/use-collection.d.ts.map +1 -1
- package/dist/internal/use-collection.js +6 -6
- package/dist/internal/use-collection.js.map +1 -1
- package/dist/list-view.d.ts.map +1 -1
- package/dist/list-view.js +6 -6
- package/dist/list-view.js.map +1 -1
- package/dist/types.d.ts +127 -54
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +7 -7
- package/src/adw/combo-row.tsx +1 -0
- package/src/adw/types.ts +2 -1
- package/src/column-view.tsx +38 -35
- package/src/drop-down.tsx +1 -0
- package/src/grid-view.tsx +2 -2
- package/src/index.ts +10 -11
- package/src/internal/cells.tsx +345 -123
- package/src/internal/collection-index.ts +51 -99
- package/src/internal/collection-model.ts +259 -110
- package/src/internal/collection.ts +46 -68
- package/src/internal/controlled-sync.ts +34 -0
- package/src/internal/drop-down.tsx +44 -23
- package/src/internal/expansion.ts +104 -67
- package/src/internal/keys.ts +18 -0
- package/src/internal/selection.tsx +100 -51
- package/src/internal/slots.ts +67 -0
- package/src/internal/tree-expansion.ts +110 -0
- package/src/internal/tree-order.ts +138 -0
- package/src/internal/use-collection.tsx +11 -11
- package/src/list-view.tsx +14 -10
- package/src/types.ts +140 -65
- package/dist/size-group.d.ts +0 -12
- package/dist/size-group.d.ts.map +0 -1
- package/dist/size-group.js +0 -41
- package/dist/size-group.js.map +0 -1
- package/src/size-group.tsx +0 -77
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
The React framework for Linux.<br />
|
|
9
|
-
|
|
9
|
+
Write native Linux applications with React and TypeScript.
|
|
10
|
+
Built on the GNOME stack and standard web tooling.
|
|
10
11
|
</p>
|
|
11
12
|
|
|
12
13
|
<p align="center">
|
|
@@ -20,15 +21,13 @@
|
|
|
20
21
|
|
|
21
22
|
<p align="center">
|
|
22
23
|
<a href="https://gtkx.dev">Homepage</a> ·
|
|
23
|
-
<a href="https://gtkx.dev/guide/
|
|
24
|
+
<a href="https://gtkx.dev/guide/getting-started">Documentation</a> ·
|
|
24
25
|
<a href="https://github.com/gtkx-org/gtkx/tree/main/examples">Examples</a> ·
|
|
25
26
|
<a href="https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md">Contributing</a>
|
|
26
27
|
</p>
|
|
27
28
|
|
|
28
29
|
---
|
|
29
30
|
|
|
30
|
-
GTKX generates fully typed bindings for the entire GTK4 and Adwaita surface directly from GObject-Introspection. On top of those bindings you get the React programming model: components and hooks driving GObject instances, with Fast Refresh while you develop.
|
|
31
|
-
|
|
32
31
|
<p align="center">
|
|
33
32
|
<img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/examples/tutorial/assets/screenshot.png" alt="The Tasks app: an Adwaita window with a sidebar of smart views and colored lists on the left, and a boxed task list on the right." />
|
|
34
33
|
</p>
|
|
@@ -109,7 +108,7 @@ React Native and similar frameworks hide the native toolkit so one API can run e
|
|
|
109
108
|
|
|
110
109
|
### Why Node.js, and why generated bindings
|
|
111
110
|
|
|
112
|
-
GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [
|
|
111
|
+
GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [Why GTKX guide](https://gtkx.dev/guide/why-gtkx) covers what running on Node.js means day to day.
|
|
113
112
|
|
|
114
113
|
GTKX generates the TypeScript types and the native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. Codegen covers the whole GTK4 and Adwaita surface.
|
|
115
114
|
|
|
@@ -122,10 +121,10 @@ GTKX is Linux-only and needs Node.js 24 or later. See [Requirements](#requiremen
|
|
|
122
121
|
Scaffold a new app with the `create-gtkx` initializer:
|
|
123
122
|
|
|
124
123
|
```sh
|
|
125
|
-
npm create gtkx
|
|
124
|
+
npm create gtkx
|
|
126
125
|
```
|
|
127
126
|
|
|
128
|
-
The same command works with other package managers: `pnpm create gtkx
|
|
127
|
+
The same command works with other package managers: `pnpm create gtkx` or `yarn create gtkx`.
|
|
129
128
|
|
|
130
129
|
Then run your new app:
|
|
131
130
|
|
|
@@ -146,7 +145,7 @@ The documentation at **[gtkx.dev](https://gtkx.dev)** includes a step-by-step tu
|
|
|
146
145
|
|
|
147
146
|
GTKX is Linux-only. You need:
|
|
148
147
|
|
|
149
|
-
- Linux with the GTK4 (4.20 or later), Adwaita (1.8 or later)
|
|
148
|
+
- Linux with the GTK4 (4.20 or later) and GLib development libraries, plus Adwaita (1.8 or later) once your project binds `Adw-1`
|
|
150
149
|
- Node.js 24 or later
|
|
151
150
|
|
|
152
151
|
The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other targets need to build it from the GTKX repository, which requires a Rust toolchain.
|
|
@@ -162,7 +161,7 @@ Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
|
|
|
162
161
|
|
|
163
162
|
## Status
|
|
164
163
|
|
|
165
|
-
GTKX 1.0 is
|
|
164
|
+
GTKX 1.0 is released.
|
|
166
165
|
|
|
167
166
|
## Contributing
|
|
168
167
|
|
package/dist/adw/combo-row.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { ComboRowProps } from "./types.js";
|
|
3
|
+
/** Call signature of {@link ComboRow}, generic in the item and section value types. */
|
|
3
4
|
type ComboRowComponent = <T = unknown, S = unknown>(props: ComboRowProps<T, S>) => ReactNode;
|
|
4
5
|
/**
|
|
5
6
|
* Renders an `Adw.ComboRow` backed by a collection model, presenting the same choice as a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-row.d.ts","sourceRoot":"","sources":["../../src/adw/combo-row.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,KAAK,iBAAiB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;AAE7F;;;;GAIG;AACH,QAAA,MAAM,QAAQ,EAAE,iBAAqD,CAAC;AAMtE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"combo-row.d.ts","sourceRoot":"","sources":["../../src/adw/combo-row.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,uFAAuF;AACvF,KAAK,iBAAiB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;AAE7F;;;;GAIG;AACH,QAAA,MAAM,QAAQ,EAAE,iBAAqD,CAAC;AAMtE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-row.js","sourceRoot":"","sources":["../../src/adw/combo-row.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"combo-row.js","sourceRoot":"","sources":["../../src/adw/combo-row.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKxD;;;;GAIG;AACH,MAAM,QAAQ,GAAsB,YAAiC,CAAC;AAEtE,SAAS,YAAY,CAAC,KAAwB;IAC1C,OAAO,KAAC,YAAY,OAAK,KAAK,EAAE,SAAS,EAAE,WAAW,GAAI,CAAC;AAC/D,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { AdwComboRow } from \"@gtkx/jsx/adw\";\nimport type { DropDownBaseProps } from \"../internal/drop-down.js\";\nimport type { ComboRowProps } from \"./types.js\";\nimport { DropDownBase } from \"../internal/drop-down.js\";\n\n/** Call signature of {@link ComboRow}, generic in the item and section value types. */\ntype ComboRowComponent = <T = unknown, S = unknown>(props: ComboRowProps<T, S>) => ReactNode;\n\n/**\n * Renders an `Adw.ComboRow` backed by a collection model, presenting the same choice as a\n * `DropDown` in the shape of a preferences row, with customizable renderers for the row\n * display, popup rows, and popup section headers, and controlled selection.\n */\nconst ComboRow: ComboRowComponent = ComboRowImpl as ComboRowComponent;\n\nfunction ComboRowImpl(props: DropDownBaseProps): ReactNode {\n return <DropDownBase {...props} component={AdwComboRow} />;\n}\n\nexport { ComboRow };\n"]}
|
package/dist/adw/types.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ type ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, "onButtonCli
|
|
|
17
17
|
type ToastController = {
|
|
18
18
|
/** Builds a toast, shows it through the overlay, and returns it. */
|
|
19
19
|
show: (options?: ToastOptions) => Adw.Toast;
|
|
20
|
-
/** Dismisses a single toast, typically one returned by
|
|
20
|
+
/** Dismisses a single toast, typically one returned by `ToastController.show`. */
|
|
21
21
|
dismiss: (toast: Adw.Toast) => void;
|
|
22
22
|
};
|
|
23
23
|
/** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */
|
|
@@ -29,6 +29,7 @@ type ToastOverlayController = {
|
|
|
29
29
|
type ToastProviderProps = {
|
|
30
30
|
/** Ref also given to the `AdwToastOverlay` the toasts appear over. */
|
|
31
31
|
overlayRef: RefObject<Adw.ToastOverlay | null>;
|
|
32
|
+
/** Subtree whose `useToast` and `useToastOverlay` calls target that overlay. */
|
|
32
33
|
children?: ReactNode | undefined;
|
|
33
34
|
};
|
|
34
35
|
export { type ComboRowProps, type ToastOptions, type ToastController, type ToastOverlayController, type ToastProviderProps, };
|
package/dist/adw/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adw/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAA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ACvC,CAAC;AAEF,2FAA2F;AAC3F,KAAK,sBAAsB,GAAG;IAC1B,sDAAsD;IACtD,UAAU,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAEF,uCAAuC;AACvC,KAAK,kBAAkB,GAAG;IACtB,sEAAsE;IACtE,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC/C,gFAAgF;IAChF,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACpC,CAAC;AAEF,OAAO,EACH,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,GAC1B,CAAC"}
|
package/dist/adw/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adw/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adw/types.ts"],"names":[],"mappings":"AAuCA,OAAO,EAMN,CAAC","sourcesContent":["import type * as Adw from \"@gtkx/gi/adw\";\nimport type { AdwComboRowProps, AdwToastProps } from \"@gtkx/jsx/adw\";\nimport type { ReactNode, RefObject } from \"react\";\nimport type { DropDownWidgetProps } from \"../types.js\";\n\n/**\n * Props for {@link ComboRow}. Combines the underlying Adw.ComboRow props with the declarative\n * collection props: flat items or grouped sections, controlled single selection, and renderers\n * for the row display, popup rows, and popup section headers.\n */\ntype ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowProps, T, S>;\n/**\n * Describes a toast raised through {@link useToast}: the construct-time properties of an\n * `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.\n */\ntype ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, \"onButtonClicked\" | \"onDismissed\">;\n\n/** Imperative controls for individual toasts, returned by {@link useToast}. */\ntype ToastController = {\n /** Builds a toast, shows it through the overlay, and returns it. */\n show: (options?: ToastOptions) => Adw.Toast;\n /** Dismisses a single toast, typically one returned by `ToastController.show`. */\n dismiss: (toast: Adw.Toast) => void;\n};\n\n/** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */\ntype ToastOverlayController = {\n /** Dismisses the shown toast and every queued one. */\n dismissAll: () => void;\n};\n\n/** Props for {@link ToastProvider}. */\ntype ToastProviderProps = {\n /** Ref also given to the `AdwToastOverlay` the toasts appear over. */\n overlayRef: RefObject<Adw.ToastOverlay | null>;\n /** Subtree whose `useToast` and `useToastOverlay` calls target that overlay. */\n children?: ReactNode | undefined;\n};\n\nexport {\n type ComboRowProps,\n type ToastOptions,\n type ToastController,\n type ToastOverlayController,\n type ToastProviderProps,\n};\n"]}
|
package/dist/column-view.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import type { ColumnViewProps } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Renders a Gtk.ColumnView from declarative items or sections and a columns array,
|
|
5
|
-
* with controlled selection, expansion, and sorting, per-column header menus,
|
|
6
|
-
* section header rendering.
|
|
5
|
+
* with controlled selection, expansion, and sorting, per-column header menus,
|
|
6
|
+
* section header rendering, and per-row props such as a screen-reader label.
|
|
7
7
|
*/
|
|
8
8
|
declare function ColumnView<T = unknown, S = unknown>(props: ColumnViewProps<T, S>): ReactNode;
|
|
9
9
|
export { ColumnView };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-view.d.ts","sourceRoot":"","sources":["../src/column-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"column-view.d.ts","sourceRoot":"","sources":["../src/column-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAQlD,OAAO,KAAK,EAAoB,eAAe,EAAmC,MAAM,YAAY,CAAC;AAgKrG;;;;GAIG;AACH,iBAAS,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAiCrF;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/column-view.js
CHANGED
|
@@ -4,19 +4,21 @@ import { GtkColumnView, GtkColumnViewColumn, GtkCustomSorter, GtkSignalListItemF
|
|
|
4
4
|
import { useSignal } from "@gtkx/react";
|
|
5
5
|
import { omit } from "@gtkx/utils";
|
|
6
6
|
import { useLayoutEffect, useRef } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { ItemPortals, useItemCells, useRowProps, useSectionHeader } from "./internal/cells.js";
|
|
8
8
|
import { useCollection } from "./internal/use-collection.js";
|
|
9
9
|
import { useWidgetRef } from "./internal/use-widget-ref.js";
|
|
10
10
|
const COLUMN_VIEW_PROPS = [
|
|
11
11
|
"items",
|
|
12
12
|
"sections",
|
|
13
13
|
"renderHeader",
|
|
14
|
+
"rowProps",
|
|
14
15
|
"columns",
|
|
15
16
|
"selectedIds",
|
|
16
17
|
"onSelectionChanged",
|
|
17
18
|
"selectionMode",
|
|
18
19
|
"expandedIds",
|
|
19
20
|
"onExpandedChange",
|
|
21
|
+
"expanderDescriptions",
|
|
20
22
|
"sortColumn",
|
|
21
23
|
"sortOrder",
|
|
22
24
|
"onSortChanged",
|
|
@@ -78,29 +80,29 @@ const useColumnSorting = (view, sort, columns) => {
|
|
|
78
80
|
syncSort(sorting, view, sortColumn, sortOrder);
|
|
79
81
|
}, [view, sortColumn, sortOrder, columns]);
|
|
80
82
|
};
|
|
81
|
-
const ColumnCells = ({ column, collection, expandedIds, size }) => {
|
|
83
|
+
const ColumnCells = ({ column, collection, expandedIds, expanderDescriptions, size }) => {
|
|
82
84
|
const cells = useItemCells(size);
|
|
83
|
-
const rest = omit(column, ["id", "renderCell", "
|
|
84
|
-
return (_jsxs(_Fragment, { children: [_jsx(GtkColumnViewColumn, { id: column.id, factory: _jsx(GtkSignalListItemFactory, { ...cells.handlers }), sorter: column.
|
|
85
|
+
const rest = omit(column, ["id", "renderCell", "isSortable"]);
|
|
86
|
+
return (_jsxs(_Fragment, { children: [_jsx(GtkColumnViewColumn, { id: column.id, factory: _jsx(GtkSignalListItemFactory, { ...cells.handlers }), sorter: column.isSortable === true ? _jsx(GtkCustomSorter, {}) : null, ...rest }), _jsx(ItemPortals, { registry: cells, render: column.renderCell, collection: collection, expandedIds: expandedIds, expanderDescriptions: expanderDescriptions })] }));
|
|
85
87
|
};
|
|
86
|
-
const ColumnList = ({ columns, collection, expandedIds, size }) => columns.map((column) => (_jsx(ColumnCells, { column: column, collection: collection, expandedIds: expandedIds, size: size }, column.id)));
|
|
88
|
+
const ColumnList = ({ columns, collection, expandedIds, expanderDescriptions, size }) => columns.map((column) => (_jsx(ColumnCells, { column: column, collection: collection, expandedIds: expandedIds, expanderDescriptions: expanderDescriptions, size: size }, column.id)));
|
|
87
89
|
/**
|
|
88
90
|
* Renders a Gtk.ColumnView from declarative items or sections and a columns array,
|
|
89
|
-
* with controlled selection, expansion, and sorting, per-column header menus,
|
|
90
|
-
* section header rendering.
|
|
91
|
+
* with controlled selection, expansion, and sorting, per-column header menus,
|
|
92
|
+
* section header rendering, and per-row props such as a screen-reader label.
|
|
91
93
|
*/
|
|
92
94
|
function ColumnView(props) {
|
|
93
|
-
const { renderHeader, columns, expandedIds,
|
|
95
|
+
const { renderHeader, rowProps, columns, expandedIds, expanderDescriptions } = props;
|
|
96
|
+
const { sortColumn, sortOrder, onSortChanged, ref } = props;
|
|
94
97
|
const rest = omit(props, COLUMN_VIEW_PROPS);
|
|
98
|
+
const size = { width: -1, height: props.estimatedItemHeight ?? -1 };
|
|
95
99
|
const [view, refCallback] = useWidgetRef(ref);
|
|
96
|
-
const size = { width: -1, height: estimatedItemHeight ?? -1 };
|
|
97
100
|
const { collection, selection } = useCollection(props);
|
|
98
|
-
const
|
|
101
|
+
const header = useSectionHeader(renderHeader, collection, size);
|
|
102
|
+
const rows = useRowProps(rowProps, collection, expandedIds);
|
|
99
103
|
const columnList = columns;
|
|
100
104
|
useColumnSorting(view, { sortColumn, sortOrder, onSortChanged }, columnList);
|
|
101
|
-
return (_jsxs(_Fragment, { children: [_jsx(GtkColumnView, { ref: refCallback, model: selection, ...(
|
|
102
|
-
headerFactory: _jsx(GtkSignalListItemFactory, { ...headerCells.handlers }),
|
|
103
|
-
}), ...rest, children: _jsx(ColumnList, { columns: columnList, collection: collection, expandedIds: expandedIds, size: size }) }), renderHeader != null && (_jsx(HeaderPortals, { store: headerCells, render: renderHeader, collection: collection }))] }));
|
|
105
|
+
return (_jsxs(_Fragment, { children: [_jsx(GtkColumnView, { ref: refCallback, model: selection, ...header.factoryProps, ...rows.factoryProps, ...rest, children: _jsx(ColumnList, { columns: columnList, collection: collection, expandedIds: expandedIds, expanderDescriptions: expanderDescriptions, size: size }) }), header.portals, rows.portals] }));
|
|
104
106
|
}
|
|
105
107
|
export { ColumnView };
|
|
106
108
|
//# sourceMappingURL=column-view.js.map
|
package/dist/column-view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-view.js","sourceRoot":"","sources":["../src/column-view.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIhD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B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GAAI,GACrF,EACf,YAAY,IAAI,IAAI,IAAI,CACrB,KAAC,aAAa,IAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,GAAI,CACtF,IACF,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkColumnView, GtkColumnViewColumn, GtkCustomSorter, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { useSignal } from \"@gtkx/react\";\nimport { omit } from \"@gtkx/utils\";\nimport { useLayoutEffect, useRef } from \"react\";\nimport type { CellSize } from \"./internal/cells.js\";\nimport type { Collection } from \"./internal/collection.js\";\nimport type { Column, ColumnViewProps } from \"./types.js\";\nimport { HeaderPortals, ItemPortals, useHeaderCells, useItemCells } from \"./internal/cells.js\";\nimport { useCollection } from \"./internal/use-collection.js\";\nimport { useWidgetRef } from \"./internal/use-widget-ref.js\";\n\ntype SortProps = {\n sortColumn?: string | null | undefined;\n sortOrder?: Gtk.SortType | null | undefined;\n onSortChanged?: ((column: string | null, order: Gtk.SortType) => void) | null | undefined;\n};\n\ntype SortTarget = { view: Gtk.ColumnView; column: Gtk.ColumnViewColumn | null };\n\ntype ColumnCellsProps = {\n column: Column<never>;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n size: CellSize;\n};\n\ntype ColumnListProps = Omit<ColumnCellsProps, \"column\"> & {\n columns: Column<never>[];\n};\n\nconst COLUMN_VIEW_PROPS = [\n \"items\",\n \"sections\",\n \"renderHeader\",\n \"columns\",\n \"selectedIds\",\n \"onSelectionChanged\",\n \"selectionMode\",\n \"expandedIds\",\n \"onExpandedChange\",\n \"sortColumn\",\n \"sortOrder\",\n \"onSortChanged\",\n \"estimatedItemHeight\",\n \"children\",\n \"ref\",\n] as const satisfies (keyof ColumnViewProps)[];\n\nconst columnById = (view: Gtk.ColumnView, id: string): Gtk.ColumnViewColumn | null => {\n const columns = view.getColumns();\n\n for (let index = 0; index < columns.getNItems(); index++) {\n const column = columns.getItem(index);\n\n if (column instanceof Gtk.ColumnViewColumn && column.getId() === id) {\n return column;\n }\n }\n\n return null;\n};\n\nconst getSortTarget = (view: Gtk.ColumnView | null, sortColumn: string | null | undefined): SortTarget | null => {\n if (view === null || sortColumn === undefined) {\n return null;\n }\n\n if (sortColumn === null) {\n return { view, column: null };\n }\n\n const column = columnById(view, sortColumn);\n\n return column === null ? null : { view, column };\n};\n\nconst applySort = (\n sorting: { current: boolean },\n view: Gtk.ColumnView,\n column: Gtk.ColumnViewColumn | null,\n order: Gtk.SortType | null | undefined,\n): void => {\n sorting.current = true;\n\n try {\n view.sortByColumn(column, order ?? Gtk.SortType.ASCENDING);\n } finally {\n sorting.current = false;\n }\n};\n\nconst emitSortChanged = (\n sorter: Gtk.ColumnViewSorter | null,\n sorting: { current: boolean },\n sort: SortProps,\n): void => {\n if (sorter === null || sorting.current) {\n return;\n }\n\n sort.onSortChanged?.(sorter.getPrimarySortColumn()?.getId() ?? null, sorter.getPrimarySortOrder());\n};\n\nconst syncSort = (\n sorting: { current: boolean },\n view: Gtk.ColumnView | null,\n sortColumn: string | null | undefined,\n sortOrder: Gtk.SortType | null | undefined,\n): void => {\n const target = getSortTarget(view, sortColumn);\n\n if (target === null) {\n return;\n }\n\n applySort(sorting, target.view, target.column, sortOrder);\n};\n\nconst useColumnSorting = (view: Gtk.ColumnView | null, sort: SortProps, columns: Column<never>[]): void => {\n const sorting = useRef(false);\n const sorter = view?.getSorter() ?? null;\n const columnSorter = sorter instanceof Gtk.ColumnViewSorter ? sorter : null;\n\n useSignal(columnSorter, \"changed\", (): void => {\n emitSortChanged(columnSorter, sorting, sort);\n });\n\n const { sortColumn, sortOrder } = sort;\n\n useLayoutEffect(() => {\n syncSort(sorting, view, sortColumn, sortOrder);\n }, [view, sortColumn, sortOrder, columns]);\n};\n\nconst ColumnCells = ({ column, collection, expandedIds, size }: ColumnCellsProps): ReactNode => {\n const cells = useItemCells(size);\n const rest = omit(column, [\"id\", \"renderCell\", \"sortable\"]);\n\n return (\n <>\n <GtkColumnViewColumn\n id={column.id}\n factory={<GtkSignalListItemFactory {...cells.handlers} />}\n sorter={column.sortable === true ? <GtkCustomSorter /> : null}\n {...rest}\n />\n <ItemPortals\n store={cells}\n render={column.renderCell}\n collection={collection}\n expandedIds={expandedIds}\n />\n </>\n );\n};\n\nconst ColumnList = ({ columns, collection, expandedIds, size }: ColumnListProps): ReactNode =>\n columns.map((column) => (\n <ColumnCells\n key={column.id}\n column={column}\n collection={collection}\n expandedIds={expandedIds}\n size={size}\n />\n ));\n\n/**\n * Renders a Gtk.ColumnView from declarative items or sections and a columns array,\n * with controlled selection, expansion, and sorting, per-column header menus, and\n * section header rendering.\n */\nfunction ColumnView<T = unknown, S = unknown>(props: ColumnViewProps<T, S>): ReactNode {\n const { renderHeader, columns, expandedIds, sortColumn, sortOrder, onSortChanged, estimatedItemHeight, ref } =\n props;\n\n const rest = omit(props, COLUMN_VIEW_PROPS);\n const [view, refCallback] = useWidgetRef<Gtk.ColumnView>(ref);\n const size = { width: -1, height: estimatedItemHeight ?? -1 };\n const { collection, selection } = useCollection(props);\n const headerCells = useHeaderCells(size);\n const columnList = columns as Column<never>[];\n useColumnSorting(view, { sortColumn, sortOrder, onSortChanged }, columnList);\n\n return (\n <>\n <GtkColumnView\n ref={refCallback}\n model={selection}\n {...(renderHeader != null && {\n headerFactory: <GtkSignalListItemFactory {...headerCells.handlers} />,\n })}\n {...rest}\n >\n <ColumnList columns={columnList} collection={collection} expandedIds={expandedIds} size={size} />\n </GtkColumnView>\n {renderHeader != null && (\n <HeaderPortals store={headerCells} render={renderHeader} collection={collection} />\n )}\n </>\n );\n}\n\nexport { ColumnView };\n"]}
|
|
1
|
+
{"version":3,"file":"column-view.js","sourceRoot":"","sources":["../src/column-view.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;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CAAC,CAAC;IAC9D,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,gBAAgB,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChE,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,OAAoC,CAAC;IACxD,gBAAgB,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,EAAE,UAAU,CAAC,CAAC;IAE7E,OAAO,CACH,8BACI,KAAC,aAAa,IACV,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,SAAS,KACZ,MAAM,CAAC,YAAY,KACnB,IAAI,CAAC,YAAY,KACjB,IAAI,YAER,KAAC,UAAU,IACP,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,IAAI,EAAE,IAAI,GACZ,GACU,EACf,MAAM,CAAC,OAAO,EACd,IAAI,CAAC,OAAO,IACd,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { GtkColumnView, GtkColumnViewColumn, GtkCustomSorter, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { useSignal } from \"@gtkx/react\";\nimport { omit } from \"@gtkx/utils\";\nimport { useLayoutEffect, useRef } from \"react\";\nimport type { CellSize } from \"./internal/cells.js\";\nimport type { Collection } from \"./internal/collection.js\";\nimport type { ColumnViewColumn, ColumnViewProps, ExpanderDescriptions, SortProps } from \"./types.js\";\nimport { ItemPortals, useItemCells, useRowProps, useSectionHeader } from \"./internal/cells.js\";\nimport { useCollection } from \"./internal/use-collection.js\";\nimport { useWidgetRef } from \"./internal/use-widget-ref.js\";\n\ntype SortTarget = { view: Gtk.ColumnView; column: Gtk.ColumnViewColumn | null };\n\ntype ColumnCellsProps = {\n column: ColumnViewColumn<never>;\n collection: Collection;\n expandedIds: string[] | null | undefined;\n expanderDescriptions: ExpanderDescriptions | null | undefined;\n size: CellSize;\n};\n\ntype ColumnListProps = Omit<ColumnCellsProps, \"column\"> & {\n columns: ColumnViewColumn<never>[];\n};\n\nconst COLUMN_VIEW_PROPS = [\n \"items\",\n \"sections\",\n \"renderHeader\",\n \"rowProps\",\n \"columns\",\n \"selectedIds\",\n \"onSelectionChanged\",\n \"selectionMode\",\n \"expandedIds\",\n \"onExpandedChange\",\n \"expanderDescriptions\",\n \"sortColumn\",\n \"sortOrder\",\n \"onSortChanged\",\n \"estimatedItemHeight\",\n \"children\",\n \"ref\",\n] as const satisfies (keyof ColumnViewProps)[];\n\nconst columnById = (view: Gtk.ColumnView, id: string): Gtk.ColumnViewColumn | null => {\n const columns = view.getColumns();\n\n for (let index = 0; index < columns.getNItems(); index++) {\n const column = columns.getItem(index);\n\n if (column instanceof Gtk.ColumnViewColumn && column.getId() === id) {\n return column;\n }\n }\n\n return null;\n};\n\nconst getSortTarget = (view: Gtk.ColumnView | null, sortColumn: string | null | undefined): SortTarget | null => {\n if (view === null || sortColumn === undefined) {\n return null;\n }\n\n if (sortColumn === null) {\n return { view, column: null };\n }\n\n const column = columnById(view, sortColumn);\n\n return column === null ? null : { view, column };\n};\n\nconst applySort = (\n sorting: RefObject<boolean>,\n view: Gtk.ColumnView,\n column: Gtk.ColumnViewColumn | null,\n order: Gtk.SortType | null | undefined,\n): void => {\n sorting.current = true;\n\n try {\n view.sortByColumn(column, order ?? Gtk.SortType.ASCENDING);\n } finally {\n sorting.current = false;\n }\n};\n\nconst emitSortChanged = (\n sorter: Gtk.ColumnViewSorter | null,\n sorting: RefObject<boolean>,\n sort: SortProps,\n): void => {\n if (sorter === null || sorting.current) {\n return;\n }\n\n sort.onSortChanged?.(sorter.getPrimarySortColumn()?.getId() ?? null, sorter.getPrimarySortOrder());\n};\n\nconst syncSort = (\n sorting: RefObject<boolean>,\n view: Gtk.ColumnView | null,\n sortColumn: string | null | undefined,\n sortOrder: Gtk.SortType | null | undefined,\n): void => {\n const target = getSortTarget(view, sortColumn);\n\n if (target === null) {\n return;\n }\n\n applySort(sorting, target.view, target.column, sortOrder);\n};\n\nconst useColumnSorting = (view: Gtk.ColumnView | null, sort: SortProps, columns: ColumnViewColumn<never>[]): void => {\n const sorting = useRef(false);\n const sorter = view?.getSorter() ?? null;\n const columnSorter = sorter instanceof Gtk.ColumnViewSorter ? sorter : null;\n\n useSignal(columnSorter, \"changed\", (): void => {\n emitSortChanged(columnSorter, sorting, sort);\n });\n\n const { sortColumn, sortOrder } = sort;\n\n useLayoutEffect(() => {\n syncSort(sorting, view, sortColumn, sortOrder);\n }, [view, sortColumn, sortOrder, columns]);\n};\n\nconst ColumnCells = ({ column, collection, expandedIds, expanderDescriptions, size }: ColumnCellsProps): ReactNode => {\n const cells = useItemCells(size);\n const rest = omit(column, [\"id\", \"renderCell\", \"isSortable\"]);\n\n return (\n <>\n <GtkColumnViewColumn\n id={column.id}\n factory={<GtkSignalListItemFactory {...cells.handlers} />}\n sorter={column.isSortable === true ? <GtkCustomSorter /> : null}\n {...rest}\n />\n <ItemPortals\n registry={cells}\n render={column.renderCell}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n />\n </>\n );\n};\n\nconst ColumnList = ({ columns, collection, expandedIds, expanderDescriptions, size }: ColumnListProps): ReactNode =>\n columns.map((column) => (\n <ColumnCells\n key={column.id}\n column={column}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n size={size}\n />\n ));\n\n/**\n * Renders a Gtk.ColumnView from declarative items or sections and a columns array,\n * with controlled selection, expansion, and sorting, per-column header menus,\n * section header rendering, and per-row props such as a screen-reader label.\n */\nfunction ColumnView<T = unknown, S = unknown>(props: ColumnViewProps<T, S>): ReactNode {\n const { renderHeader, rowProps, columns, expandedIds, expanderDescriptions } = props;\n const { sortColumn, sortOrder, onSortChanged, ref } = props;\n const rest = omit(props, COLUMN_VIEW_PROPS);\n const size = { width: -1, height: props.estimatedItemHeight ?? -1 };\n const [view, refCallback] = useWidgetRef<Gtk.ColumnView>(ref);\n const { collection, selection } = useCollection(props);\n const header = useSectionHeader(renderHeader, collection, size);\n const rows = useRowProps(rowProps, collection, expandedIds);\n const columnList = columns as ColumnViewColumn<never>[];\n useColumnSorting(view, { sortColumn, sortOrder, onSortChanged }, columnList);\n\n return (\n <>\n <GtkColumnView\n ref={refCallback}\n model={selection}\n {...header.factoryProps}\n {...rows.factoryProps}\n {...rest}\n >\n <ColumnList\n columns={columnList}\n collection={collection}\n expandedIds={expandedIds}\n expanderDescriptions={expanderDescriptions}\n size={size}\n />\n </GtkColumnView>\n {header.portals}\n {rows.portals}\n </>\n );\n}\n\nexport { ColumnView };\n"]}
|
package/dist/drop-down.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { DropDownProps } from "./types.js";
|
|
3
|
+
/** Call signature of {@link DropDown}, generic in the item and section value types. */
|
|
3
4
|
type DropDownComponent = <T = unknown, S = unknown>(props: DropDownProps<T, S>) => ReactNode;
|
|
4
5
|
/**
|
|
5
6
|
* Renders a `Gtk.DropDown` backed by a collection model, with customizable renderers for the
|
package/dist/drop-down.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-down.d.ts","sourceRoot":"","sources":["../src/drop-down.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,KAAK,iBAAiB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;AAE7F;;;GAGG;AACH,QAAA,MAAM,QAAQ,EAAE,iBAAqD,CAAC;AAMtE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"drop-down.d.ts","sourceRoot":"","sources":["../src/drop-down.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,uFAAuF;AACvF,KAAK,iBAAiB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;AAE7F;;;GAGG;AACH,QAAA,MAAM,QAAQ,EAAE,iBAAqD,CAAC;AAMtE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/drop-down.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-down.js","sourceRoot":"","sources":["../src/drop-down.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"drop-down.js","sourceRoot":"","sources":["../src/drop-down.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD;;;GAGG;AACH,MAAM,QAAQ,GAAsB,YAAiC,CAAC;AAEtE,SAAS,YAAY,CAAC,KAAwB;IAC1C,OAAO,KAAC,YAAY,OAAK,KAAK,EAAE,SAAS,EAAE,WAAW,GAAI,CAAC;AAC/D,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { GtkDropDown } from \"@gtkx/jsx/gtk\";\nimport type { DropDownBaseProps } from \"./internal/drop-down.js\";\nimport type { DropDownProps } from \"./types.js\";\nimport { DropDownBase } from \"./internal/drop-down.js\";\n\n/** Call signature of {@link DropDown}, generic in the item and section value types. */\ntype DropDownComponent = <T = unknown, S = unknown>(props: DropDownProps<T, S>) => ReactNode;\n\n/**\n * Renders a `Gtk.DropDown` backed by a collection model, with customizable renderers for the\n * collapsed display, popup rows, and popup section headers, and controlled selection.\n */\nconst DropDown: DropDownComponent = DropDownImpl as DropDownComponent;\n\nfunction DropDownImpl(props: DropDownBaseProps): ReactNode {\n return <DropDownBase {...props} component={GtkDropDown} />;\n}\n\nexport { DropDown };\n"]}
|
package/dist/grid-view.js
CHANGED
|
@@ -20,9 +20,9 @@ function GridView(props) {
|
|
|
20
20
|
const { renderItem, estimatedItemHeight, estimatedItemWidth } = props;
|
|
21
21
|
const rest = omit(props, GRID_VIEW_PROPS);
|
|
22
22
|
const size = { width: estimatedItemWidth ?? -1, height: estimatedItemHeight ?? -1 };
|
|
23
|
-
const { collection, selection } = useCollection({ ...props,
|
|
23
|
+
const { collection, selection } = useCollection({ ...props, isFlat: true });
|
|
24
24
|
const itemCells = useItemCells(size);
|
|
25
|
-
return (_jsxs(_Fragment, { children: [_jsx(GtkGridView, { model: selection, factory: _jsx(GtkSignalListItemFactory, { ...itemCells.handlers }), ...rest }), _jsx(ItemPortals, {
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsx(GtkGridView, { model: selection, factory: _jsx(GtkSignalListItemFactory, { ...itemCells.handlers }), ...rest }), _jsx(ItemPortals, { registry: itemCells, render: renderItem, collection: collection })] }));
|
|
26
26
|
}
|
|
27
27
|
export { GridView };
|
|
28
28
|
//# sourceMappingURL=grid-view.js.map
|
package/dist/grid-view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-view.js","sourceRoot":"","sources":["../src/grid-view.tsx"],"names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B;IAClD,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,GAAG,KAAK,CAAC;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,kBAAkB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,IAAI,CAAC,CAAC,EAAE,CAAC;IACpF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAErC,OAAO,CACH,8BACI,KAAC,WAAW,IAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,KAAC,wBAAwB,OAAK,SAAS,CAAC,QAAQ,GAAI,KAAM,IAAI,GAAI,EAC1G,KAAC,WAAW,IAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAI,IACjF,CACN,CAAC;AACN,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["import type { ReactNode } from \"react\";\nimport { GtkGridView, GtkSignalListItemFactory } from \"@gtkx/jsx/gtk\";\nimport { omit } from \"@gtkx/utils\";\nimport type { GridViewProps } from \"./types.js\";\nimport { ItemPortals, useItemCells } from \"./internal/cells.js\";\nimport { useCollection } from \"./internal/use-collection.js\";\n\nconst GRID_VIEW_PROPS = [\n \"items\",\n \"renderItem\",\n \"selectedIds\",\n \"onSelectionChanged\",\n \"selectionMode\",\n \"estimatedItemHeight\",\n \"estimatedItemWidth\",\n] as const satisfies (keyof GridViewProps)[];\n\n/**\n * Renders a Gtk.GridView of uniform cells from declarative items, with per-cell\n * rendering, controlled selection, and estimated item sizing.\n */\nfunction GridView<T = unknown>(props: GridViewProps<T>): ReactNode {\n const { renderItem, estimatedItemHeight, estimatedItemWidth } = props;\n const rest = omit(props, GRID_VIEW_PROPS);\n const size = { width: estimatedItemWidth ?? -1, height: estimatedItemHeight ?? -1 };\n const { collection, selection } = useCollection({ ...props, isFlat: true });\n const itemCells = useItemCells(size);\n\n return (\n <>\n <GtkGridView model={selection} factory={<GtkSignalListItemFactory {...itemCells.handlers} />} {...rest} />\n <ItemPortals registry={itemCells} render={renderItem} collection={collection} />\n </>\n );\n}\n\nexport { GridView };\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,5 @@ export { ColumnView } from "./column-view.js";
|
|
|
2
2
|
export { DropDown } from "./drop-down.js";
|
|
3
3
|
export { GridView } from "./grid-view.js";
|
|
4
4
|
export { ListView } from "./list-view.js";
|
|
5
|
-
export {
|
|
6
|
-
export type { ChildProps, Column, ColumnViewProps, DropDownProps, GridViewProps, HeaderRenderer, Item, ItemRenderer, ListViewProps, RenderHeaderArgs, RenderItemArgs, Section, SizeGroupChildProps, SizeGroupProps, } from "./types.js";
|
|
5
|
+
export type { ColumnViewColumn, ColumnViewProps, DropDownProps, ExpanderDescriptions, GridViewProps, ListItem, ListItemRenderArgs, ListItemRenderer, ListRowProps, ListRowPropsResolver, ListSection, ListSectionRenderArgs, ListSectionRenderer, ListViewProps, } from "./types.js";
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EACR,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,GAChB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { ColumnView } from \"./column-view.js\";\nexport { DropDown } from \"./drop-down.js\";\nexport { GridView } from \"./grid-view.js\";\nexport { ListView } from \"./list-view.js\";\nexport type {\n ColumnViewColumn,\n ColumnViewProps,\n DropDownProps,\n ExpanderDescriptions,\n GridViewProps,\n ListItem,\n ListItemRenderArgs,\n ListItemRenderer,\n ListRowProps,\n ListRowPropsResolver,\n ListSection,\n ListSectionRenderArgs,\n ListSectionRenderer,\n ListViewProps,\n} from \"./types.js\";\n"]}
|
package/dist/internal/cells.d.ts
CHANGED
|
@@ -1,50 +1,58 @@
|
|
|
1
1
|
import type * as GObject from "@gtkx/gi/gobject";
|
|
2
|
-
import type { ReactNode } from "react";
|
|
2
|
+
import type { ReactElement, ReactNode } from "react";
|
|
3
3
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ExpanderDescriptions, ListItemRenderer, ListRowPropsResolver, ListSectionRenderer } from "../types.js";
|
|
5
5
|
import type { Collection } from "./collection.js";
|
|
6
6
|
type CellSize = {
|
|
7
7
|
width: number;
|
|
8
8
|
height: number;
|
|
9
9
|
};
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
setChild: (child: Gtk.Widget | null) => void;
|
|
10
|
+
type FactoryHost = GObject.Object & {
|
|
11
|
+
getItem: () => GObject.Object | null;
|
|
13
12
|
};
|
|
14
|
-
type CellEntry<
|
|
13
|
+
type CellEntry<H extends FactoryHost> = {
|
|
15
14
|
key: string;
|
|
16
|
-
|
|
15
|
+
host: H;
|
|
17
16
|
item: GObject.Object | null;
|
|
18
17
|
listeners: Set<() => void>;
|
|
19
18
|
subscribe: (onChange: () => void) => () => void;
|
|
20
19
|
getItem: () => GObject.Object | null;
|
|
21
20
|
};
|
|
22
21
|
type FactoryHandlers = {
|
|
23
|
-
onSetup: (
|
|
24
|
-
onBind: (
|
|
25
|
-
onUnbind: (
|
|
26
|
-
onTeardown: (
|
|
22
|
+
onSetup: (host: GObject.Object) => void;
|
|
23
|
+
onBind: (host: GObject.Object) => void;
|
|
24
|
+
onUnbind: (host: GObject.Object) => void;
|
|
25
|
+
onTeardown: (host: GObject.Object) => void;
|
|
27
26
|
};
|
|
28
|
-
type
|
|
27
|
+
type CellRegistry<H extends FactoryHost> = {
|
|
29
28
|
handlers: FactoryHandlers;
|
|
30
29
|
setSize: (size: CellSize) => void;
|
|
31
30
|
subscribe: (onChange: () => void) => () => void;
|
|
32
|
-
|
|
31
|
+
getVersion: () => number;
|
|
32
|
+
getEntries: () => CellEntry<H>[];
|
|
33
33
|
};
|
|
34
34
|
type ItemPortalsProps = {
|
|
35
|
-
|
|
36
|
-
render:
|
|
35
|
+
registry: CellRegistry<Gtk.ListItem>;
|
|
36
|
+
render: ListItemRenderer<never>;
|
|
37
37
|
collection: Collection;
|
|
38
38
|
expandedIds?: string[] | null | undefined;
|
|
39
|
+
expanderDescriptions?: ExpanderDescriptions | null | undefined;
|
|
39
40
|
};
|
|
40
|
-
type
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
type SectionHeaderSlot = {
|
|
42
|
+
factoryProps: {
|
|
43
|
+
headerFactory?: ReactElement;
|
|
44
|
+
};
|
|
45
|
+
portals: ReactNode;
|
|
46
|
+
};
|
|
47
|
+
type RowSlot = {
|
|
48
|
+
factoryProps: {
|
|
49
|
+
rowFactory?: ReactElement;
|
|
50
|
+
};
|
|
51
|
+
portals: ReactNode;
|
|
44
52
|
};
|
|
45
|
-
declare function useItemCells(size: CellSize):
|
|
46
|
-
declare
|
|
47
|
-
declare const
|
|
48
|
-
declare const
|
|
49
|
-
export { useItemCells,
|
|
53
|
+
declare function useItemCells(size: CellSize): CellRegistry<Gtk.ListItem>;
|
|
54
|
+
declare const ItemPortals: ({ registry, render, collection, expandedIds, expanderDescriptions, }: ItemPortalsProps) => ReactNode;
|
|
55
|
+
declare const useSectionHeader: (render: ListSectionRenderer<never> | null | undefined, collection: Collection, size: CellSize) => SectionHeaderSlot;
|
|
56
|
+
declare const useRowProps: (rowProps: ListRowPropsResolver<never> | null | undefined, collection: Collection, expandedIds: string[] | null | undefined) => RowSlot;
|
|
57
|
+
export { useItemCells, useRowProps, useSectionHeader, ItemPortals, type CellSize, };
|
|
50
58
|
//# sourceMappingURL=cells.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cells.d.ts","sourceRoot":"","sources":["../../src/internal/cells.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"cells.d.ts","sourceRoot":"","sources":["../../src/internal/cells.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAKpC,OAAO,KAAK,EACR,oBAAoB,EAGpB,gBAAgB,EAEhB,oBAAoB,EACpB,mBAAmB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,KAAK,QAAQ,GAAG;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG;IAChC,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CACxC,CAAC;AAOF,KAAK,SAAS,CAAC,CAAC,SAAS,WAAW,IAAI;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAC3B,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAChD,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF,KAAK,eAAe,GAAG;IACnB,OAAO,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