@gtkx/components 1.6.0 → 2.0.0-beta.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 +5 -5
- package/dist/combo-row.d.ts.map +1 -0
- package/dist/{adw/combo-row.js → combo-row.js} +1 -1
- package/dist/combo-row.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/collection-index.d.ts +1 -2
- package/dist/internal/collection-index.d.ts.map +1 -1
- package/dist/internal/collection-index.js +1 -2
- package/dist/internal/collection-index.js.map +1 -1
- package/dist/internal/collection-model.d.ts.map +1 -1
- package/dist/internal/collection-model.js +3 -8
- package/dist/internal/collection-model.js.map +1 -1
- package/dist/internal/expansion.d.ts.map +1 -1
- package/dist/internal/expansion.js +2 -8
- package/dist/internal/expansion.js.map +1 -1
- package/dist/internal/slots.d.ts.map +1 -1
- package/dist/internal/slots.js +1 -6
- package/dist/internal/slots.js.map +1 -1
- package/dist/internal/tree-expansion.js +2 -2
- package/dist/internal/tree-expansion.js.map +1 -1
- package/dist/internal/tree-order.d.ts +1 -2
- package/dist/internal/tree-order.d.ts.map +1 -1
- package/dist/internal/tree-order.js +1 -4
- package/dist/internal/tree-order.js.map +1 -1
- package/dist/internal/use-widget-ref.d.ts +2 -2
- package/dist/internal/use-widget-ref.d.ts.map +1 -1
- package/dist/internal/use-widget-ref.js.map +1 -1
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js.map +1 -0
- package/dist/types.d.ts +34 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +11 -13
- package/src/{adw/combo-row.tsx → combo-row.tsx} +2 -2
- package/src/index.ts +7 -0
- package/src/internal/collection-index.ts +1 -2
- package/src/internal/collection-model.ts +3 -9
- package/src/internal/expansion.ts +2 -10
- package/src/internal/slots.ts +1 -9
- package/src/internal/tree-expansion.ts +2 -2
- package/src/internal/tree-order.ts +0 -5
- package/src/internal/use-widget-ref.ts +2 -2
- package/src/types.ts +42 -2
- package/dist/adw/combo-row.d.ts.map +0 -1
- package/dist/adw/combo-row.js.map +0 -1
- package/dist/adw/index.d.ts +0 -4
- package/dist/adw/index.d.ts.map +0 -1
- package/dist/adw/index.js +0 -3
- package/dist/adw/index.js.map +0 -1
- package/dist/adw/toast.d.ts.map +0 -1
- package/dist/adw/toast.js.map +0 -1
- package/dist/adw/types.d.ts +0 -36
- package/dist/adw/types.d.ts.map +0 -1
- package/dist/adw/types.js +0 -2
- package/dist/adw/types.js.map +0 -1
- package/src/adw/index.ts +0 -9
- package/src/adw/types.ts +0 -46
- /package/dist/{adw/combo-row.d.ts → combo-row.d.ts} +0 -0
- /package/dist/{adw/toast.d.ts → toast.d.ts} +0 -0
- /package/dist/{adw/toast.js → toast.js} +0 -0
- /package/src/{adw/toast.tsx → toast.tsx} +0 -0
package/dist/adw/toast.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","sourceRoot":"","sources":["../../src/adw/toast.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAK3D,MAAM,YAAY,GAAG,aAAa,CAAoB,IAAI,CAAC,CAAC;AAE5D,MAAM,aAAa,GAAG,GAAe,EAAE;IACnC,MAAM,UAAU,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAE5C,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,OAAqB,EAAa,EAAE;IACpD,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,GAAG,OA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AAC;QACH,UAAU,EAAE,GAAG,EAAE;YACb,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;QACrC,CAAC;KACJ,CAAC,EACF,CAAC,UAAU,CAAC,CACf,CAAC;AACN,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { ReactNode, RefObject } from \"react\";\nimport * as Adw from \"@gtkx/gi/adw\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport type { ToastController, ToastOptions, ToastOverlayController, ToastProviderProps } from \"./types.js\";\n\ntype OverlayRef = RefObject<Adw.ToastOverlay | null>;\n\nconst ToastContext = createContext<OverlayRef | null>(null);\n\nconst useOverlayRef = (): OverlayRef => {\n const overlayRef = useContext(ToastContext);\n\n if (overlayRef === null) {\n throw new Error(\"useToast and useToastOverlay must be used within a ToastProvider\");\n }\n\n return overlayRef;\n};\n\nconst buildToast = (options: ToastOptions): Adw.Toast => {\n const { onButtonClicked, onDismissed, ...props } = options;\n const toast = new Adw.Toast(props);\n\n if (onButtonClicked != null) {\n toast.on(\"button-clicked\", () => {\n onButtonClicked(toast);\n });\n }\n\n if (onDismissed != null) {\n toast.on(\"dismissed\", () => {\n onDismissed(toast);\n });\n }\n\n return toast;\n};\n\n/** Shares an Adw.ToastOverlay reference with the toast hooks in every descendant. */\nfunction ToastProvider(props: ToastProviderProps): ReactNode {\n return <ToastContext.Provider value={props.overlayRef}>{props.children}</ToastContext.Provider>;\n}\n\n/** Returns a {@link ToastController} that shows and dismisses toasts on the nearest provider's overlay. */\nfunction useToast(): ToastController {\n const overlayRef = useOverlayRef();\n\n return useMemo<ToastController>(\n () => ({\n show: (options?: ToastOptions) => {\n const toast = buildToast(options ?? {});\n overlayRef.current?.addToast(toast);\n\n return toast;\n },\n dismiss: (toast: Adw.Toast) => {\n toast.dismiss();\n },\n }),\n [overlayRef],\n );\n}\n\n/** Returns a {@link ToastOverlayController} for the nearest provider's overlay as a whole. */\nfunction useToastOverlay(): ToastOverlayController {\n const overlayRef = useOverlayRef();\n\n return useMemo<ToastOverlayController>(\n () => ({\n dismissAll: () => {\n overlayRef.current?.dismissAll();\n },\n }),\n [overlayRef],\n );\n}\n\nexport { ToastProvider, useToast, useToastOverlay };\n"]}
|
package/dist/adw/types.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type * as Adw from "@gtkx/gi/adw";
|
|
2
|
-
import type { AdwComboRowProps, AdwToastProps } from "@gtkx/jsx/adw";
|
|
3
|
-
import type { ReactNode, RefObject } from "react";
|
|
4
|
-
import type { DropDownWidgetProps } from "../types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Props for {@link ComboRow}. Combines the underlying Adw.ComboRow props with the declarative
|
|
7
|
-
* collection props: flat items or grouped sections, controlled single selection, and renderers
|
|
8
|
-
* for the row display, popup rows, and popup section headers.
|
|
9
|
-
*/
|
|
10
|
-
type ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowProps, T, S>;
|
|
11
|
-
/**
|
|
12
|
-
* Describes a toast raised through {@link useToast}: the construct-time properties of an
|
|
13
|
-
* `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.
|
|
14
|
-
*/
|
|
15
|
-
type ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, "onButtonClicked" | "onDismissed">;
|
|
16
|
-
/** Imperative controls for individual toasts, returned by {@link useToast}. */
|
|
17
|
-
type ToastController = {
|
|
18
|
-
/** Builds a toast, shows it through the overlay, and returns it. */
|
|
19
|
-
show: (options?: ToastOptions) => Adw.Toast;
|
|
20
|
-
/** Dismisses a single toast, typically one returned by `ToastController.show`. */
|
|
21
|
-
dismiss: (toast: Adw.Toast) => void;
|
|
22
|
-
};
|
|
23
|
-
/** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */
|
|
24
|
-
type ToastOverlayController = {
|
|
25
|
-
/** Dismisses the shown toast and every queued one. */
|
|
26
|
-
dismissAll: () => void;
|
|
27
|
-
};
|
|
28
|
-
/** Props for {@link ToastProvider}. */
|
|
29
|
-
type ToastProviderProps = {
|
|
30
|
-
/** Ref also given to the `AdwToastOverlay` the toasts appear over. */
|
|
31
|
-
overlayRef: RefObject<Adw.ToastOverlay | null>;
|
|
32
|
-
/** Subtree whose `useToast` and `useToastOverlay` calls target that overlay. */
|
|
33
|
-
children?: ReactNode | undefined;
|
|
34
|
-
};
|
|
35
|
-
export { type ComboRowProps, type ToastOptions, type ToastController, type ToastOverlayController, type ToastProviderProps, };
|
|
36
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/adw/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,MAAM,aAAa,CAAC;AAEvD;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3F;;;GAGG;AACH,KAAK,YAAY,GAAG,GAAG,CAAC,qBAAqB,GAAG,IAAI,CAAC,aAAa,EAAE,iBAAiB,GAAG,aAAa,CAAC,CAAC;AAEvG,+EAA+E;AAC/E,KAAK,eAAe,GAAG;IACnB,oEAAoE;IACpE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,GAAG,CAAC,KAAK,CAAC;IAC5C,kFAAkF;IAClF,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC;CACvC,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
DELETED
package/dist/adw/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/src/adw/index.ts
DELETED
package/src/adw/types.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type * as Adw from "@gtkx/gi/adw";
|
|
2
|
-
import type { AdwComboRowProps, AdwToastProps } from "@gtkx/jsx/adw";
|
|
3
|
-
import type { ReactNode, RefObject } from "react";
|
|
4
|
-
import type { DropDownWidgetProps } from "../types.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Props for {@link ComboRow}. Combines the underlying Adw.ComboRow props with the declarative
|
|
8
|
-
* collection props: flat items or grouped sections, controlled single selection, and renderers
|
|
9
|
-
* for the row display, popup rows, and popup section headers.
|
|
10
|
-
*/
|
|
11
|
-
type ComboRowProps<T = unknown, S = unknown> = DropDownWidgetProps<AdwComboRowProps, T, S>;
|
|
12
|
-
/**
|
|
13
|
-
* Describes a toast raised through {@link useToast}: the construct-time properties of an
|
|
14
|
-
* `Adw.Toast` plus its `button-clicked` and `dismissed` handlers.
|
|
15
|
-
*/
|
|
16
|
-
type ToastOptions = Adw.ToastConstructorProps & Pick<AdwToastProps, "onButtonClicked" | "onDismissed">;
|
|
17
|
-
|
|
18
|
-
/** Imperative controls for individual toasts, returned by {@link useToast}. */
|
|
19
|
-
type ToastController = {
|
|
20
|
-
/** Builds a toast, shows it through the overlay, and returns it. */
|
|
21
|
-
show: (options?: ToastOptions) => Adw.Toast;
|
|
22
|
-
/** Dismisses a single toast, typically one returned by `ToastController.show`. */
|
|
23
|
-
dismiss: (toast: Adw.Toast) => void;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/** Imperative controls for the overlay as a whole, returned by {@link useToastOverlay}. */
|
|
27
|
-
type ToastOverlayController = {
|
|
28
|
-
/** Dismisses the shown toast and every queued one. */
|
|
29
|
-
dismissAll: () => void;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/** Props for {@link ToastProvider}. */
|
|
33
|
-
type ToastProviderProps = {
|
|
34
|
-
/** Ref also given to the `AdwToastOverlay` the toasts appear over. */
|
|
35
|
-
overlayRef: RefObject<Adw.ToastOverlay | null>;
|
|
36
|
-
/** Subtree whose `useToast` and `useToastOverlay` calls target that overlay. */
|
|
37
|
-
children?: ReactNode | undefined;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
type ComboRowProps,
|
|
42
|
-
type ToastOptions,
|
|
43
|
-
type ToastController,
|
|
44
|
-
type ToastOverlayController,
|
|
45
|
-
type ToastProviderProps,
|
|
46
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|