@gtkx/testing 1.0.0-rc.4 → 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 +5 -5
- package/dist/accessible-native.d.ts +16 -0
- package/dist/accessible-native.d.ts.map +1 -0
- package/dist/accessible-native.js +206 -0
- package/dist/accessible-native.js.map +1 -0
- package/dist/build-queries.d.ts +27 -10
- package/dist/build-queries.d.ts.map +1 -1
- package/dist/build-queries.js +22 -24
- package/dist/build-queries.js.map +1 -1
- package/dist/cleanup-registry.d.ts +1 -1
- package/dist/cleanup-registry.d.ts.map +1 -1
- package/dist/cleanup-registry.js.map +1 -1
- package/dist/errors.d.ts +10 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -1
- package/dist/errors.js.map +1 -1
- package/dist/fire-event.d.ts +35 -6
- package/dist/fire-event.d.ts.map +1 -1
- package/dist/fire-event.js +23 -7
- package/dist/fire-event.js.map +1 -1
- package/dist/frame-sync.d.ts +2 -1
- package/dist/frame-sync.d.ts.map +1 -1
- package/dist/frame-sync.js +15 -5
- package/dist/frame-sync.js.map +1 -1
- package/dist/harness-window.d.ts +4 -0
- package/dist/harness-window.d.ts.map +1 -0
- package/dist/harness-window.js +6 -0
- package/dist/harness-window.js.map +1 -0
- package/dist/index.d.ts +14 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +4 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +1 -0
- package/dist/matchers.d.ts +88 -46
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +156 -18
- package/dist/matchers.js.map +1 -1
- package/dist/pretty-format.d.ts +2 -0
- package/dist/pretty-format.d.ts.map +1 -0
- package/dist/pretty-format.js +2 -0
- package/dist/pretty-format.js.map +1 -0
- package/dist/pretty-widget.d.ts +5 -2
- package/dist/pretty-widget.d.ts.map +1 -1
- package/dist/pretty-widget.js +73 -56
- package/dist/pretty-widget.js.map +1 -1
- package/dist/production.d.ts +8 -0
- package/dist/production.d.ts.map +1 -0
- package/dist/production.js +34 -0
- package/dist/production.js.map +1 -0
- package/dist/queries.d.ts +98 -56
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +123 -83
- package/dist/queries.js.map +1 -1
- package/dist/query-helpers.d.ts +44 -0
- package/dist/query-helpers.d.ts.map +1 -0
- package/dist/query-helpers.js +57 -0
- package/dist/query-helpers.js.map +1 -0
- package/dist/render-children.d.ts +9 -0
- package/dist/render-children.d.ts.map +1 -0
- package/dist/render-children.js +11 -0
- package/dist/render-children.js.map +1 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +11 -9
- package/dist/render.js.map +1 -1
- package/dist/role-helpers.d.ts +12 -3
- package/dist/role-helpers.d.ts.map +1 -1
- package/dist/role-helpers.js +13 -4
- package/dist/role-helpers.js.map +1 -1
- package/dist/role-naming.d.ts +5 -0
- package/dist/role-naming.d.ts.map +1 -0
- package/dist/role-naming.js +96 -0
- package/dist/role-naming.js.map +1 -0
- package/dist/screenshot.d.ts +12 -20
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +183 -91
- package/dist/screenshot.js.map +1 -1
- package/dist/traversal.d.ts +4 -1
- package/dist/traversal.d.ts.map +1 -1
- package/dist/traversal.js +25 -6
- package/dist/traversal.js.map +1 -1
- package/dist/types.d.ts +26 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/user-event/adjustment.d.ts +3 -0
- package/dist/user-event/adjustment.d.ts.map +1 -1
- package/dist/user-event/adjustment.js +23 -2
- package/dist/user-event/adjustment.js.map +1 -1
- package/dist/user-event/click.d.ts +43 -8
- package/dist/user-event/click.d.ts.map +1 -1
- package/dist/user-event/click.js +175 -44
- package/dist/user-event/click.js.map +1 -1
- package/dist/user-event/column-header-click.d.ts +4 -0
- package/dist/user-event/column-header-click.d.ts.map +1 -0
- package/dist/user-event/column-header-click.js +65 -0
- package/dist/user-event/column-header-click.js.map +1 -0
- package/dist/user-event/event-wrapper.d.ts.map +1 -1
- package/dist/user-event/event-wrapper.js +2 -1
- package/dist/user-event/event-wrapper.js.map +1 -1
- package/dist/user-event/index.d.ts +51 -10
- package/dist/user-event/index.d.ts.map +1 -1
- package/dist/user-event/index.js +43 -26
- package/dist/user-event/index.js.map +1 -1
- package/dist/user-event/indexed-children.d.ts +10 -0
- package/dist/user-event/indexed-children.d.ts.map +1 -0
- package/dist/user-event/indexed-children.js +50 -0
- package/dist/user-event/indexed-children.js.map +1 -0
- package/dist/user-event/keyboard.d.ts.map +1 -1
- package/dist/user-event/keyboard.js +33 -4
- package/dist/user-event/keyboard.js.map +1 -1
- package/dist/user-event/list-row-click.d.ts +4 -0
- package/dist/user-event/list-row-click.d.ts.map +1 -0
- package/dist/user-event/list-row-click.js +39 -0
- package/dist/user-event/list-row-click.js.map +1 -0
- package/dist/user-event/native-click.d.ts +6 -0
- package/dist/user-event/native-click.d.ts.map +1 -0
- package/dist/user-event/native-click.js +32 -0
- package/dist/user-event/native-click.js.map +1 -0
- package/dist/user-event/pointer.d.ts +1 -1
- package/dist/user-event/pointer.d.ts.map +1 -1
- package/dist/user-event/pointer.js +33 -9
- package/dist/user-event/pointer.js.map +1 -1
- package/dist/user-event/selection.d.ts +11 -8
- package/dist/user-event/selection.d.ts.map +1 -1
- package/dist/user-event/selection.js +49 -38
- package/dist/user-event/selection.js.map +1 -1
- package/dist/user-event/text.d.ts +6 -2
- package/dist/user-event/text.d.ts.map +1 -1
- package/dist/user-event/text.js +68 -18
- package/dist/user-event/text.js.map +1 -1
- package/dist/widget-accessible-properties.d.ts +14 -26
- package/dist/widget-accessible-properties.d.ts.map +1 -1
- package/dist/widget-accessible-properties.js +135 -190
- package/dist/widget-accessible-properties.js.map +1 -1
- package/dist/widget-getters.d.ts +8 -0
- package/dist/widget-getters.d.ts.map +1 -0
- package/dist/widget-getters.js +19 -0
- package/dist/widget-getters.js.map +1 -0
- package/dist/within.d.ts +3 -2
- package/dist/within.d.ts.map +1 -1
- package/dist/within.js +3 -2
- package/dist/within.js.map +1 -1
- package/package.json +12 -7
- package/src/accessible-native.ts +333 -0
- package/src/build-queries.ts +47 -41
- package/src/cleanup-registry.ts +1 -1
- package/src/errors.ts +12 -1
- package/src/fire-event.ts +61 -8
- package/src/frame-sync.ts +21 -5
- package/src/harness-window.ts +9 -0
- package/src/index.ts +18 -11
- package/src/internal.ts +11 -0
- package/src/matchers.ts +428 -70
- package/src/pretty-format.ts +1 -0
- package/src/pretty-widget.ts +97 -70
- package/src/production.ts +52 -0
- package/src/queries.ts +127 -89
- package/src/query-helpers.ts +97 -0
- package/src/render-children.ts +25 -0
- package/src/render.tsx +16 -11
- package/src/role-helpers.ts +14 -4
- package/src/role-naming.ts +99 -0
- package/src/screenshot.ts +272 -103
- package/src/traversal.ts +44 -6
- package/src/types.ts +28 -16
- package/src/user-event/adjustment.ts +29 -2
- package/src/user-event/click.ts +247 -52
- package/src/user-event/column-header-click.ts +90 -0
- package/src/user-event/event-wrapper.ts +3 -1
- package/src/user-event/index.ts +100 -37
- package/src/user-event/indexed-children.ts +75 -0
- package/src/user-event/keyboard.ts +52 -4
- package/src/user-event/list-row-click.ts +57 -0
- package/src/user-event/native-click.ts +46 -0
- package/src/user-event/pointer.ts +48 -9
- package/src/user-event/selection.ts +67 -41
- package/src/user-event/text.ts +92 -21
- package/src/widget-accessible-properties.ts +183 -230
- package/src/widget-getters.ts +32 -0
- package/src/within.ts +3 -2
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAA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"],"names":[],"mappings":"AAoPA,OAAO,EAqBN,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { RootElement } from \"@gtkx/react\";\nimport type { ComponentType, ErrorInfo, ReactNode } from \"react\";\nimport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport type { Container } from \"./traversal.js\";\n\n/**\n * A custom matcher predicate: given a candidate widget's normalized text content and the widget\n * itself, returns whether it matches.\n */\ntype MatcherFunction = (content: string, widget: Gtk.Widget) => boolean;\n/** A value used to match widget text: a string or number, a regular expression, or a custom {@link MatcherFunction}. */\ntype Matcher = string | number | RegExp | MatcherFunction;\n/** Normalizes a widget's text before it is compared against a matcher. */\ntype NormalizerFn = (text: string) => string;\n/**\n * A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and\n * generated GInterface pseudo-classes are accepted.\n */\ntype WidgetType<T extends Gtk.Widget = Gtk.Widget> = abstract new (...args: never[]) => T;\n\n/** Options controlling the default text normalizer. */\ntype NormalizerOptions = {\n /** Trim leading and trailing whitespace. */\n trim?: boolean | undefined;\n /** Collapse runs of whitespace into a single space. */\n collapseWhitespace?: boolean | undefined;\n};\n\n/** Options controlling how asynchronous queries and waits poll for a condition. */\ntype WaitForOptions = {\n /** Maximum time in milliseconds to keep retrying before failing. */\n timeout?: number | undefined;\n /** Delay in milliseconds between retries. */\n interval?: number | undefined;\n /** Transforms the error thrown when the timeout elapses. */\n onTimeout?: ((error: Error) => Error) | undefined;\n /** Error whose stack trace attributes the timeout failure to the calling code. */\n stackTraceError?: Error | undefined;\n};\n\n/** Options controlling text matching and, for asynchronous queries, polling behavior. */\ntype MatcherOptions<T extends Gtk.Widget = Gtk.Widget> = {\n /** When true (the default), require an exact match; when false, match case-insensitively as a substring. */\n exact?: boolean | undefined;\n /** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */\n normalizer?: NormalizerFn | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n trim?: boolean | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n collapseWhitespace?: boolean | undefined;\n /** Whether to include a suggested better query in error messages. */\n suggest?: boolean | undefined;\n /** Restricts matches to instances of this widget class, and narrows the query's return type to it. */\n as?: WidgetType<T> | undefined;\n} & WaitForOptions;\n\n/** Constraints on a widget's numeric range value used by role queries. */\ntype ByRoleValue = {\n /** The current value. */\n now?: number | undefined;\n /** The lower bound of the value's range. */\n min?: number | undefined;\n /** The upper bound of the value's range. */\n max?: number | undefined;\n /** Matcher for the value's textual representation. */\n text?: Matcher | undefined;\n};\n\n/** Options for role queries: an accessible name matcher plus accessible state and value constraints. */\ntype ByRoleOptions<T extends Gtk.Widget = Gtk.Widget> = MatcherOptions<T> & {\n /** Matcher for the widget's accessible name. */\n name?: Matcher | undefined;\n /** Required checked state; a mixed check button reads as neither, so it matches neither value. */\n checked?: boolean | undefined;\n /** Required active state of a toggle button; any other widget matches neither value. */\n pressed?: boolean | undefined;\n /** Required selected state of a row, list item, grid cell, option or tree item. */\n selected?: boolean | undefined;\n /** Required expanded state of an expander or tree expander. */\n expanded?: boolean | undefined;\n /** Heading or hierarchy level. */\n level?: number | undefined;\n /** Required busy state, which an unset state satisfies as false. */\n busy?: boolean | undefined;\n /** Matcher for the widget's own accessible description, ignoring its `described-by` targets. */\n description?: Matcher | undefined;\n /** Constraints on the widget's range value, each checked only when given. */\n value?: ByRoleValue | undefined;\n /** When true, include widgets excluded from the accessibility tree. */\n hidden?: boolean | undefined;\n};\n\n/** A React component that wraps rendered content, receiving it as its children. */\ntype WrapperComponent = ComponentType<{\n children: ReactNode;\n}>;\n\n/** A custom query, taking the scope to search as its first argument and its matcher arguments after it. */\ntype Query = (container: Container, ...args: never[]) => unknown;\n/** Custom queries keyed by the name each is bound under. */\ntype QueryMap = Record<string, Query>;\n\n/** A query with its container argument already applied. */\ntype BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R\n ? (...args: A) => R\n : never;\n\n/** Custom queries with their container argument already applied, keyed as they were passed in. */\ntype BoundCustomQueries<Q extends QueryMap> = { [K in keyof Q]: BoundQuery<Q[K]> };\n\n/** What each variant of a query family yields for the widget type it matched. */\ntype QueryFamilyReturns<T extends Gtk.Widget> = {\n /** The single match, or null when nothing matched; throws when more than one matched. */\n queryBy: T | null;\n /** Every match, empty when nothing matched. */\n queryAllBy: T[];\n /** The single match; throws when nothing or more than one matched. */\n getBy: T;\n /** Every match; throws when nothing matched. */\n getAllBy: T[];\n /** The single match, retried until it appears or the timeout elapses. */\n findBy: Promise<T>;\n /** Every match, retried until at least one appears or the timeout elapses. */\n findAllBy: Promise<T[]>;\n};\n\n/** What a query family matches against, which fixes the arguments it takes. */\ntype QueryKind = \"role\" | \"text\" | \"name\" | \"value\";\n\n/** The arguments a query of the given kind takes after the family's leading ones. */\ntype QueryArgs<Kind extends QueryKind, T extends Gtk.Widget> = Kind extends \"role\"\n ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>]\n : Kind extends \"name\"\n ? [name: Matcher, options?: MatcherOptions<T>]\n : Kind extends \"value\"\n ? [value: Matcher, options?: MatcherOptions<T>]\n : [text: Matcher, options?: MatcherOptions<T>];\n\n/**\n * One family's query variants, each named for its variant followed by `Suffix` and taking `Head`\n * ahead of the family's own arguments.\n */\ntype QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {\n [K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.Widget = Gtk.Widget>(\n ...args: [...Head, ...QueryArgs<Kind, T>]\n ) => QueryFamilyReturns<T>[K];\n};\n\n/**\n * Every built-in query, spanning the Role, LabelText, Text, Name, PlaceholderText, and DisplayValue\n * families, with `Head` prepended to each signature.\n */\ntype QueryFamilies<Head extends unknown[]> = QueryFamily<\"Role\", \"role\", Head> &\n QueryFamily<\"LabelText\", \"text\", Head> &\n QueryFamily<\"Text\", \"text\", Head> &\n QueryFamily<\"Name\", \"name\", Head> &\n QueryFamily<\"PlaceholderText\", \"text\", Head> &\n QueryFamily<\"DisplayValue\", \"value\", Head>;\n\n/**\n * Options for {@link render}: the container and base element to mount into, an optional wrapper,\n * React behavior toggles, error callbacks, and custom queries to bind.\n */\ntype RenderOptions<Q extends QueryMap = Record<never, never>> = {\n /** Widget or root element to mount into; an undecorated harness window is created when omitted. */\n container?: Gtk.Widget | RootElement | undefined;\n /** Root of the subtree that bound queries search. */\n baseElement?: Container | undefined;\n /** Component wrapped around the rendered element, such as a context provider. */\n wrapper?: WrapperComponent | undefined;\n /** Render inside React StrictMode. */\n isReactStrictMode?: boolean | undefined;\n /** Enable widget animations during the test. */\n areAnimationsEnabled?: boolean | undefined;\n /** Called for errors caught by React error boundaries. */\n onCaughtError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Called for errors React recovered from automatically. */\n onRecoverableError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Custom queries to bind to the rendered result. */\n queries?: Q | undefined;\n};\n\n/** Console helpers bundled with the bound queries on {@link screen} and on a render result. */\ntype DebugUtilities = {\n /** Prints the widget tree of the given containers, or of the whole scope, to the console. */\n debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;\n /** Prints the accessible roles found in the scope, with the widgets carrying each one. */\n logRoles: () => void;\n /** Captures a window, writes the image to a temporary file, and logs its path. */\n screenshot: (selector?: WindowSelector, options?: ScreenshotOptions) => Promise<ScreenshotResult>;\n};\n\n/** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */\ntype ScreenshotResult = {\n /** Base64-encoded image bytes. */\n data: string;\n /** MIME type of the encoded image, always `image/png`. */\n mimeType: string;\n /** Image width in pixels, after the scale factor is applied. */\n width: number;\n /** Image height in pixels, after the scale factor is applied. */\n height: number;\n};\n\n/** Options for capturing a screenshot: the poll timeout and interval, plus a rendering scale factor. */\ntype ScreenshotOptions = Pick<WaitForOptions, \"timeout\" | \"interval\"> & {\n /** Device scale factor applied when rendering. */\n scale?: number;\n};\n\n/**\n * Selects the window to screenshot by index, or by title (exact string or regular expression);\n * undefined targets the default window.\n */\ntype WindowSelector = number | string | RegExp | undefined;\n\n/**\n * Options for {@link renderHook}: an optional wrapper and the initial props (required unless the\n * props type permits undefined).\n */\ntype RenderHookOptions<Props> = {\n wrapper?: WrapperComponent;\n} & (undefined extends Props\n ? {\n initialProps?: Props;\n }\n : {\n initialProps: Props;\n });\n\n/**\n * The result of {@link renderHook}: the latest hook return value plus functions to rerender with new\n * props and to unmount.\n */\ntype RenderHookResult<Result, Props> = {\n /** Holds the most recent value returned by the hook under `current`. */\n result: { current: Result };\n /** Re-invokes the hook, keeping the previous props when none are given. */\n rerender: (newProps?: Props) => Promise<void>;\n /** Unmounts the component that calls the hook. */\n unmount: () => Promise<void>;\n};\n\nexport {\n type MatcherFunction,\n type Matcher,\n type NormalizerFn,\n type NormalizerOptions,\n type WaitForOptions,\n type MatcherOptions,\n type ByRoleValue,\n type ByRoleOptions,\n type WidgetType,\n type WrapperComponent,\n type QueryMap,\n type BoundCustomQueries,\n type QueryFamilies,\n type RenderOptions,\n type DebugUtilities,\n type ScreenshotResult,\n type ScreenshotOptions,\n type WindowSelector,\n type RenderHookOptions,\n type RenderHookResult,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAiQA,OAAO,EAoBN,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { RootElement } from \"@gtkx/react\";\nimport type { ComponentType, ErrorInfo, ReactNode } from \"react\";\nimport type { PrettyWidgetOptions } from \"./pretty-widget.js\";\nimport type { Container } from \"./traversal.js\";\n\n/**\n * A custom matcher predicate: given a candidate widget's normalized text content and the widget\n * itself, returns whether it matches.\n */\ntype MatcherFunction = (content: string, widget: Gtk.Widget) => boolean;\n/** A value used to match widget text: a string or number, a regular expression, or a custom {@link MatcherFunction}. */\ntype Matcher = string | number | RegExp | MatcherFunction;\n/** Normalizes a widget's text before it is compared against a matcher. */\ntype NormalizerFn = (text: string) => string;\n/**\n * A widget class usable as a query's `as` constraint, such as `Gtk.Button`. Abstract classes and\n * generated GInterface pseudo-classes are accepted.\n */\ntype WidgetType<T extends Gtk.Widget = Gtk.Widget> = abstract new (...args: never[]) => T;\n\n/** Options controlling the default text normalizer. */\ntype NormalizerOptions = {\n /** Trim leading and trailing whitespace. */\n trim?: boolean | undefined;\n /** Collapse runs of whitespace into a single space. */\n collapseWhitespace?: boolean | undefined;\n};\n\n/** Options controlling how asynchronous queries and waits poll for a condition. */\ntype WaitForOptions = {\n /** Maximum time in milliseconds to keep retrying before failing. */\n timeout?: number | undefined;\n /** Delay in milliseconds between retries. */\n interval?: number | undefined;\n /** Transforms the error thrown when the timeout elapses. */\n onTimeout?: ((error: Error) => Error) | undefined;\n /** Error whose stack trace attributes the timeout failure to the calling code. */\n stackTraceError?: Error | undefined;\n};\n\n/** Options controlling text matching and, for asynchronous queries, polling behavior. */\ntype MatcherOptions<T extends Gtk.Widget = Gtk.Widget> = {\n /** When true (the default), require an exact match; when false, match case-insensitively as a substring. */\n exact?: boolean | undefined;\n /** Custom normalizer replacing the default; cannot be combined with `trim` or `collapseWhitespace`. */\n normalizer?: NormalizerFn | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n trim?: boolean | undefined;\n /** Forwarded to the default normalizer when no custom `normalizer` is given. */\n collapseWhitespace?: boolean | undefined;\n /** Whether to include a suggested better query in error messages. */\n suggest?: boolean | undefined;\n /** Restricts matches to instances of this widget class, and narrows the query's return type to it. */\n as?: WidgetType<T> | undefined;\n} & WaitForOptions;\n\n/**\n * Constraints on a widget's numeric range value used by role queries. The numbers come from the\n * accessibility tree and match within 0.001, the resolution GTK keeps them to.\n */\ntype ByRoleValue = {\n /** The current value. */\n now?: number | undefined;\n /** The lower bound of the value's range. */\n min?: number | undefined;\n /**\n * The highest value the widget can reach, which on a paged widget such as a scrollbar is its\n * adjustment's upper bound less one page.\n */\n max?: number | undefined;\n /** Matcher for the value's textual representation. */\n text?: Matcher | undefined;\n};\n\n/** Options for role queries: an accessible name matcher plus accessible state and value constraints. */\ntype ByRoleOptions<T extends Gtk.Widget = Gtk.Widget> = MatcherOptions<T> & {\n /** Matcher for the widget's accessible name. */\n name?: Matcher | undefined;\n /** Required checked state; a mixed check button reads as neither, so it matches neither value. */\n checked?: boolean | undefined;\n /** Required active state of a toggle button; any other widget matches neither value. */\n pressed?: boolean | undefined;\n /** Required selected state of a row, list item, grid cell, option or tree item. */\n selected?: boolean | undefined;\n /** Required expanded state of an expander or tree expander. */\n expanded?: boolean | undefined;\n /** Heading or hierarchy level. */\n level?: number | undefined;\n /** Required busy state, which an unset state satisfies as false. */\n busy?: boolean | undefined;\n /** Matcher for the widget's own accessible description, ignoring its `described-by` targets. */\n description?: Matcher | undefined;\n /** Constraints on the widget's range value, each checked only when given. */\n value?: ByRoleValue | undefined;\n /** When true, include widgets excluded from the accessibility tree. Widgets that are not mapped stay excluded. */\n hidden?: boolean | undefined;\n};\n\n/** A React component that wraps rendered content, receiving it as its children. */\ntype WrapperComponent = ComponentType<{\n children: ReactNode;\n}>;\n\n/** A custom query, taking the scope to search as its first argument and its matcher arguments after it. */\ntype Query = (container: Container, ...args: never[]) => unknown;\n/** Custom queries keyed by the name each is bound under. */\ntype QueryMap = Record<string, Query>;\n\n/** A query with its container argument already applied. */\ntype BoundQuery<Q extends Query> = Q extends (container: Container, ...args: infer A) => infer R\n ? (...args: A) => R\n : never;\n\n/** Custom queries with their container argument already applied, keyed as they were passed in. */\ntype BoundCustomQueries<Q extends QueryMap> = { [K in keyof Q]: BoundQuery<Q[K]> };\n\n/** What each variant of a query family yields for the widget type it matched. */\ntype QueryFamilyReturns<T extends Gtk.Widget> = {\n /** The single match, or null when nothing matched; throws when more than one matched. */\n queryBy: T | null;\n /** Every match, empty when nothing matched. */\n queryAllBy: T[];\n /** The single match; throws when nothing or more than one matched. */\n getBy: T;\n /** Every match; throws when nothing matched. */\n getAllBy: T[];\n /** The single match, retried until it appears or the timeout elapses. */\n findBy: Promise<T>;\n /** Every match, retried until at least one appears or the timeout elapses. */\n findAllBy: Promise<T[]>;\n};\n\n/** What a query family matches against, which fixes the arguments it takes. */\ntype QueryKind = \"role\" | \"text\" | \"name\" | \"value\";\n\n/** The arguments a query of the given kind takes after the family's leading ones. */\ntype QueryArgs<Kind extends QueryKind, T extends Gtk.Widget> = Kind extends \"role\"\n ? [role: Gtk.AccessibleRole, options?: ByRoleOptions<T>]\n : Kind extends \"name\"\n ? [name: Matcher, options?: MatcherOptions<T>]\n : Kind extends \"value\"\n ? [value: Matcher, options?: MatcherOptions<T>]\n : [text: Matcher, options?: MatcherOptions<T>];\n\n/**\n * One family's query variants, each named for its variant followed by `Suffix` and taking `Head`\n * ahead of the family's own arguments.\n */\ntype QueryFamily<Suffix extends string, Kind extends QueryKind, Head extends unknown[]> = {\n [K in keyof QueryFamilyReturns<Gtk.Widget> as `${K & string}${Suffix}`]: <T extends Gtk.Widget = Gtk.Widget>(\n ...args: [...Head, ...QueryArgs<Kind, T>]\n ) => QueryFamilyReturns<T>[K];\n};\n\n/**\n * Every built-in query, spanning the Role, LabelText, Text, Name, PlaceholderText, and DisplayValue\n * families, with `Head` prepended to each signature.\n */\ntype QueryFamilies<Head extends unknown[]> = QueryFamily<\"Role\", \"role\", Head> &\n QueryFamily<\"LabelText\", \"text\", Head> &\n QueryFamily<\"Text\", \"text\", Head> &\n QueryFamily<\"Name\", \"name\", Head> &\n QueryFamily<\"PlaceholderText\", \"text\", Head> &\n QueryFamily<\"DisplayValue\", \"value\", Head>;\n\n/**\n * Options for {@link render}: the container and base element to mount into, an optional wrapper,\n * React behavior toggles, error callbacks, and custom queries to bind.\n */\ntype RenderOptions<Q extends QueryMap = Record<never, never>> = {\n /** Widget or root element to mount into; an undecorated harness window is created when omitted. */\n container?: Gtk.Widget | RootElement | undefined;\n /** Root of the subtree that bound queries search. */\n baseElement?: Container | undefined;\n /** Component wrapped around the rendered element, such as a context provider. */\n wrapper?: WrapperComponent | undefined;\n /** Render inside React StrictMode. */\n isReactStrictMode?: boolean | undefined;\n /** Enable widget animations during the test. */\n areAnimationsEnabled?: boolean | undefined;\n /** Called for errors caught by React error boundaries. */\n onCaughtError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Called for errors React recovered from automatically. */\n onRecoverableError?: ((error: unknown, errorInfo: ErrorInfo) => void) | undefined;\n /** Custom queries to bind to the rendered result. */\n queries?: Q | undefined;\n};\n\n/** Console helpers bundled with the bound queries on {@link screen} and on a render result. */\ntype DebugUtilities = {\n /** Prints the widget tree of the given containers, or of the whole scope, to the console. */\n debug: (element?: Container | Container[], options?: PrettyWidgetOptions) => void;\n /** Prints the accessible roles found in the scope, with the widgets carrying each one. */\n logRoles: () => void;\n /**\n * Captures what is on screen, which is the active toplevel window: GTK4 exposes no position for\n * a toplevel, so windows cannot be composited into a single image.\n */\n screenshot: (options?: ScreenshotOptions) => Promise<ScreenshotResult>;\n};\n\n/** A captured screenshot: base64-encoded image data, its MIME type, and pixel dimensions. */\ntype ScreenshotResult = {\n /** Base64-encoded image bytes. */\n data: string;\n /** MIME type of the encoded image, always `image/png`. */\n mimeType: string;\n /** Image width in pixels, after the scale factor is applied. */\n width: number;\n /** Image height in pixels, after the scale factor is applied. */\n height: number;\n};\n\n/**\n * Options for capturing a screenshot: the poll timeout and interval, a rendering scale factor, and\n * a file to write the PNG to.\n */\ntype ScreenshotOptions = Pick<WaitForOptions, \"timeout\" | \"interval\"> & {\n /** Device scale factor applied when rendering. */\n scale?: number | undefined;\n /** File the PNG is written to, with its parent directories created as needed. */\n path?: string | undefined;\n};\n\n/**\n * Options for {@link renderHook}: an optional wrapper and the initial props (required unless the\n * props type permits undefined).\n */\ntype RenderHookOptions<Props> = {\n /** Component wrapped around the one calling the hook, such as a context provider. */\n wrapper?: WrapperComponent;\n} & (undefined extends Props\n ? {\n /** Props the hook is invoked with until `rerender` is given new ones. */\n initialProps?: Props;\n }\n : {\n initialProps: Props;\n });\n\n/**\n * The result of {@link renderHook}: the latest hook return value plus functions to rerender with new\n * props and to unmount.\n */\ntype RenderHookResult<Result, Props> = {\n /** Stable object the hook's return value is written to on every render. */\n result: {\n /** The hook's latest return value. */\n current: Result;\n };\n /** Re-invokes the hook, keeping the previous props when none are given. */\n rerender: (newProps?: Props) => Promise<void>;\n /** Unmounts the component that calls the hook. */\n unmount: () => Promise<void>;\n};\n\nexport {\n type MatcherFunction,\n type Matcher,\n type NormalizerFn,\n type NormalizerOptions,\n type WaitForOptions,\n type MatcherOptions,\n type ByRoleValue,\n type ByRoleOptions,\n type WidgetType,\n type WrapperComponent,\n type QueryMap,\n type BoundCustomQueries,\n type QueryFamilies,\n type RenderOptions,\n type DebugUtilities,\n type ScreenshotResult,\n type ScreenshotOptions,\n type RenderHookOptions,\n type RenderHookResult,\n};\n"]}
|
|
@@ -16,6 +16,9 @@ declare const slide: (widget: Gtk.Widget, value: number) => Promise<void>;
|
|
|
16
16
|
* Adds the delta to the adjustments of the widget itself, or of its nearest Gtk.ScrolledWindow or
|
|
17
17
|
* Gtk.Scrollable ancestor.
|
|
18
18
|
*
|
|
19
|
+
* Each adjustment advances in viewport-sized steps rather than one jump, so virtualized views such
|
|
20
|
+
* as Gtk.ListView, Gtk.GridView and Gtk.ColumnView re-anchor onto the rows the new offset shows.
|
|
21
|
+
*
|
|
19
22
|
* @throws When neither the widget nor any of its ancestors is scrollable.
|
|
20
23
|
*/
|
|
21
24
|
declare const scroll: (widget: Gtk.Widget, delta: ScrollDelta) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adjustment.d.ts","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"adjustment.d.ts","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAIpC,mDAAmD;AACnD,KAAK,WAAW,GAAG;IACf,mDAAmD;IACnD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,CAAC,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAOF;;;;GAIG;AACH,QAAA,MAAM,KAAK,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CASzD,CAAC;AA8CP;;;;;;;;GAQG;AACH,QAAA,MAAM,MAAM,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,WAAW,KAAG,OAAO,CAAC,IAAI,CAa/D,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
+
import { scheduleNextFrame } from "../frame-sync.js";
|
|
2
3
|
import { wrapEvent } from "./event-wrapper.js";
|
|
3
4
|
/**
|
|
4
5
|
* Emits a jump `change-value` so a Gtk.Range moves to the given value.
|
|
@@ -22,25 +23,45 @@ const resolveScrollAdjustments = (widget) => {
|
|
|
22
23
|
}
|
|
23
24
|
return null;
|
|
24
25
|
};
|
|
26
|
+
const stepToward = (adjustment, target, step) => {
|
|
27
|
+
const value = adjustment.getValue();
|
|
28
|
+
adjustment.setValue(value < target ? Math.min(value + step, target) : Math.max(value - step, target));
|
|
29
|
+
return adjustment.getValue();
|
|
30
|
+
};
|
|
31
|
+
const rampTo = (adjustment, target, step) => {
|
|
32
|
+
let value = adjustment.getValue();
|
|
33
|
+
while (value !== target) {
|
|
34
|
+
const moved = stepToward(adjustment, target, step);
|
|
35
|
+
if (moved === value) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
value = moved;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
25
41
|
const applyScrollDelta = (adjustment, delta) => {
|
|
26
42
|
if (!adjustment || delta === 0) {
|
|
27
43
|
return;
|
|
28
44
|
}
|
|
29
|
-
adjustment.
|
|
45
|
+
const pageSize = adjustment.getPageSize();
|
|
46
|
+
rampTo(adjustment, adjustment.getValue() + delta, pageSize > 0 ? pageSize : Math.abs(delta));
|
|
30
47
|
};
|
|
31
48
|
/**
|
|
32
49
|
* Adds the delta to the adjustments of the widget itself, or of its nearest Gtk.ScrolledWindow or
|
|
33
50
|
* Gtk.Scrollable ancestor.
|
|
34
51
|
*
|
|
52
|
+
* Each adjustment advances in viewport-sized steps rather than one jump, so virtualized views such
|
|
53
|
+
* as Gtk.ListView, Gtk.GridView and Gtk.ColumnView re-anchor onto the rows the new offset shows.
|
|
54
|
+
*
|
|
35
55
|
* @throws When neither the widget nor any of its ancestors is scrollable.
|
|
36
56
|
*/
|
|
37
|
-
const scroll = (widget, delta) => wrapEvent(widget, () => {
|
|
57
|
+
const scroll = (widget, delta) => wrapEvent(widget, async () => {
|
|
38
58
|
const adjustments = resolveScrollAdjustments(widget);
|
|
39
59
|
if (!adjustments) {
|
|
40
60
|
throw new Error("userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors");
|
|
41
61
|
}
|
|
42
62
|
applyScrollDelta(adjustments.horizontal, delta.x ?? 0);
|
|
43
63
|
applyScrollDelta(adjustments.vertical, delta.y ?? 0);
|
|
64
|
+
await scheduleNextFrame(widget);
|
|
44
65
|
});
|
|
45
66
|
export { slide, scroll };
|
|
46
67
|
//# sourceMappingURL=adjustment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adjustment.js","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAe/C;;;;GAIG;AACH,MAAM,KAAK,GAAG,CAAC,MAAkB,EAAE,KAAa,EAAiB,EAAE,CAC/D,SAAS,CAAC,MAAM,EAAE,GAAG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IAED,gBAAgB,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,gBAAgB,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAoB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { scheduleNextFrame } from \"../frame-sync.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\n/** A scroll distance in pixels along each axis. */\ntype ScrollDelta = {\n /** Distance added to the horizontal adjustment. */\n x?: number;\n /** Distance added to the vertical adjustment. */\n y?: number;\n};\n\ntype ScrollAdjustments = {\n horizontal: Gtk.Adjustment | null;\n vertical: Gtk.Adjustment | null;\n};\n\n/**\n * Emits a jump `change-value` so a Gtk.Range moves to the given value.\n *\n * @throws When the widget is not a Gtk.Range.\n */\nconst slide = (widget: Gtk.Widget, value: number): Promise<void> =>\n wrapEvent(widget, () => {\n if (!(widget instanceof Gtk.Range)) {\n throw new TypeError(\n `userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${widget.constructor.name}`,\n );\n }\n\n widget.emit(\"change-value\", Gtk.ScrollType.JUMP, value);\n });\n\nconst resolveScrollAdjustments = (widget: Gtk.Widget): ScrollAdjustments | null => {\n for (let current: Gtk.Widget | null = widget; current; current = current.getParent()) {\n if (current instanceof Gtk.ScrolledWindow) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n\n if (current instanceof Gtk.Scrollable) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n }\n\n return null;\n};\n\nconst stepToward = (adjustment: Gtk.Adjustment, target: number, step: number): number => {\n const value = adjustment.getValue();\n adjustment.setValue(value < target ? Math.min(value + step, target) : Math.max(value - step, target));\n\n return adjustment.getValue();\n};\n\nconst rampTo = (adjustment: Gtk.Adjustment, target: number, step: number): void => {\n let value = adjustment.getValue();\n\n while (value !== target) {\n const moved = stepToward(adjustment, target, step);\n\n if (moved === value) {\n return;\n }\n\n value = moved;\n }\n};\n\nconst applyScrollDelta = (adjustment: Gtk.Adjustment | null, delta: number): void => {\n if (!adjustment || delta === 0) {\n return;\n }\n\n const pageSize = adjustment.getPageSize();\n rampTo(adjustment, adjustment.getValue() + delta, pageSize > 0 ? pageSize : Math.abs(delta));\n};\n\n/**\n * Adds the delta to the adjustments of the widget itself, or of its nearest Gtk.ScrolledWindow or\n * Gtk.Scrollable ancestor.\n *\n * Each adjustment advances in viewport-sized steps rather than one jump, so virtualized views such\n * as Gtk.ListView, Gtk.GridView and Gtk.ColumnView re-anchor onto the rows the new offset shows.\n *\n * @throws When neither the widget nor any of its ancestors is scrollable.\n */\nconst scroll = (widget: Gtk.Widget, delta: ScrollDelta): Promise<void> =>\n wrapEvent(widget, async () => {\n const adjustments = resolveScrollAdjustments(widget);\n\n if (!adjustments) {\n throw new Error(\n \"userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors\",\n );\n }\n\n applyScrollDelta(adjustments.horizontal, delta.x ?? 0);\n applyScrollDelta(adjustments.vertical, delta.y ?? 0);\n await scheduleNextFrame(widget);\n });\n\nexport { slide, scroll, type ScrollDelta };\n"]}
|
|
@@ -1,15 +1,50 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
|
|
3
|
-
declare const
|
|
2
|
+
type ClickPhase = "pressed" | "released";
|
|
3
|
+
declare const emitClickPhase: (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number, phase: ClickPhase) => void;
|
|
4
|
+
declare const clickGestures: (widget: Gtk.Widget) => Gtk.GestureClick[];
|
|
5
|
+
declare const getAuthoredClickGestures: (widget: Gtk.Widget) => Gtk.GestureClick[];
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Activates a widget that neither claims the click nor carries a click gesture of its own, and
|
|
8
|
+
* otherwise delivers a press and release. The press travels outwards from the clicked widget
|
|
9
|
+
* through every widget carrying a click gesture with a pressed or released handler, the way GTK
|
|
10
|
+
* hands the same press to each of them, and stops at the first Gtk.Button or indexed child of a
|
|
11
|
+
* list box or flow box, which claims it. A gesture GTK attached itself takes the press only when no
|
|
12
|
+
* widget below it handles one, and stops it there, so an expander or a notebook tab nested in a row
|
|
13
|
+
* opens instead of activating the row. Coordinates are the clicked widget's position in each
|
|
14
|
+
* carrier, so a gesture the container of an indexed child carries reads the child's position rather
|
|
15
|
+
* than the container's center. An indexed child that the press reaches is then activated, or
|
|
16
|
+
* exclusively selected when its container does not activate on a single click. A widget with the
|
|
17
|
+
* label role is never activated, but does consume the click when it carries a gesture of its own.
|
|
18
|
+
*
|
|
19
|
+
* The press also stops at a widget whose click GTK4 implements in C on a gesture it attached
|
|
20
|
+
* itself, reading a GdkEvent that off-screen synthesis cannot produce. Gestures that widget carries
|
|
21
|
+
* of its own still take the press and release, the way GTK hands them the press before its own
|
|
22
|
+
* gesture claims it, and the same outcome is then applied through the public action GTK's own
|
|
23
|
+
* handler invokes: a list, grid, or column-view row is focused and selected, and activated as well
|
|
24
|
+
* on a second press or when its view activates on a single click; an expandable tree expander
|
|
25
|
+
* toggles its expansion, once per press, and only when it is the widget clicked, so a click on its
|
|
26
|
+
* child falls through to the enclosing row; a column header sorts by its column. Sorting goes
|
|
27
|
+
* through Gtk.ColumnView.sortByColumn, so the primary sort column and order match what a pointer
|
|
28
|
+
* produces while previously sorted columns are dropped rather than kept as secondary keys. A
|
|
29
|
+
* column-view cell and the row that carries the column headers stand in the way of the click rather
|
|
30
|
+
* than taking it, so a click on either reaches the row or the view behind it.
|
|
8
31
|
*/
|
|
9
32
|
declare const click: (widget: Gtk.Widget) => Promise<void>;
|
|
10
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Delivers a two-press click gesture the way {@link click} delivers a single press, without trying
|
|
35
|
+
* activation first. A list box row or flow box child the presses reach, clicked directly or through
|
|
36
|
+
* a descendant, is activated and exclusively selected, as GTK's double-click path does whether or
|
|
37
|
+
* not the container activates on a single click. A widget whose click GTK4 implements itself
|
|
38
|
+
* receives that outcome once per press, so a list, grid, or column-view row is selected and then
|
|
39
|
+
* activated by the second press, a tree expander ends back where it started, and a column header
|
|
40
|
+
* sorts and then inverts its order.
|
|
41
|
+
*/
|
|
11
42
|
declare const dblClick: (widget: Gtk.Widget) => Promise<void>;
|
|
12
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Delivers a three-press click gesture the same way a double click is delivered, applying the same
|
|
45
|
+
* outcome to a list box row or flow box child the presses reach, and applying the outcome GTK4
|
|
46
|
+
* implements itself once per press to a row, tree expander, or column header.
|
|
47
|
+
*/
|
|
13
48
|
declare const tripleClick: (widget: Gtk.Widget) => Promise<void>;
|
|
14
|
-
export {
|
|
49
|
+
export { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };
|
|
15
50
|
//# sourceMappingURL=click.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AASpC,KAAK,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AA8CzC,QAAA,MAAM,cAAc,GAChB,QAAQ,GAAG,CAAC,MAAM,EAClB,aAAa,GAAG,CAAC,YAAY,EAAE,EAC/B,QAAQ,MAAM,EACd,OAAO,UAAU,KAClB,IAEF,CAAC;AAyBF,QAAA,MAAM,aAAa,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACoC,CAAC;AAEjG,QAAA,MAAM,wBAAwB,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACC,CAAC;AA6JzE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,KAAK,GAAU,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAMrD,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,QAAQ,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAA4B,CAAC;AAChF;;;;GAIG;AACH,QAAA,MAAM,WAAW,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAA4B,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/user-event/click.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import * as Gdk from "@gtkx/gi/gdk";
|
|
1
2
|
import * as Gtk from "@gtkx/gi/gtk";
|
|
2
|
-
import {
|
|
3
|
+
import { hasSignalListener } from "@gtkx/runtime/internal";
|
|
4
|
+
import { callBooleanGetter, getCallableMethod, hasWidgetMethod } from "../widget-getters.js";
|
|
5
|
+
import { queryAllControllers } from "./controller.js";
|
|
3
6
|
import { wrapEvent } from "./event-wrapper.js";
|
|
4
|
-
|
|
7
|
+
import { hasIndexedChildren, selectContainerChild, SELECTED_PROBE, unselectOtherChildren } from "./indexed-children.js";
|
|
8
|
+
import { isClickTransparent, nativeClickFor } from "./native-click.js";
|
|
9
|
+
const CLICK_SIGNALS = ["pressed", "released"];
|
|
10
|
+
const PRIMARY_BUTTONS = new Set([0, Gdk.BUTTON_PRIMARY]);
|
|
11
|
+
const getCenterPoint = (widget) => {
|
|
5
12
|
const width = widget.getWidth();
|
|
6
13
|
const height = widget.getHeight();
|
|
7
14
|
if (width > 0 && height > 0) {
|
|
@@ -9,35 +16,139 @@ const getPressPoint = (widget) => {
|
|
|
9
16
|
}
|
|
10
17
|
return { x: 0, y: 0 };
|
|
11
18
|
};
|
|
12
|
-
const
|
|
13
|
-
|
|
19
|
+
const getClickPoint = (clicked, carrier) => {
|
|
20
|
+
if (clicked === carrier) {
|
|
21
|
+
return getCenterPoint(clicked);
|
|
22
|
+
}
|
|
23
|
+
const [isComputed, bounds] = clicked.computeBounds(carrier);
|
|
24
|
+
if (!isComputed) {
|
|
25
|
+
return getCenterPoint(carrier);
|
|
26
|
+
}
|
|
27
|
+
return { x: bounds.getX() + bounds.getWidth() / 2, y: bounds.getY() + bounds.getHeight() / 2 };
|
|
28
|
+
};
|
|
29
|
+
const emitGesture = (point, controllers, nPress, signal) => {
|
|
14
30
|
for (const controller of controllers) {
|
|
15
|
-
controller.emit(signal, nPress, x, y);
|
|
31
|
+
controller.emit(signal, nPress, point.x, point.y);
|
|
16
32
|
}
|
|
17
33
|
};
|
|
18
|
-
const
|
|
19
|
-
emitGesture(widget, controllers, nPress,
|
|
34
|
+
const emitClickPhase = (widget, controllers, nPress, phase) => {
|
|
35
|
+
emitGesture(getCenterPoint(widget), controllers, nPress, phase);
|
|
20
36
|
};
|
|
21
|
-
const
|
|
22
|
-
|
|
37
|
+
const emitSitePhase = (sites, nPress, phase) => {
|
|
38
|
+
for (const site of sites) {
|
|
39
|
+
emitGesture(site.point, site.gestures, nPress, phase);
|
|
40
|
+
}
|
|
23
41
|
};
|
|
24
|
-
const emitClickSequence = (
|
|
25
|
-
const controllers = getOrCreateControllers(target, Gtk.GestureClick);
|
|
42
|
+
const emitClickSequence = (sites, nPress) => {
|
|
26
43
|
for (let i = 1; i <= nPress; i++) {
|
|
27
|
-
|
|
28
|
-
|
|
44
|
+
emitSitePhase(sites, i, "pressed");
|
|
45
|
+
emitSitePhase(sites, i, "released");
|
|
29
46
|
}
|
|
30
|
-
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
};
|
|
48
|
+
const containerFor = (widget) => {
|
|
49
|
+
const parent = widget.getParent();
|
|
50
|
+
return parent !== null && hasWidgetMethod(widget, SELECTED_PROBE) && hasIndexedChildren(parent) ? parent : null;
|
|
51
|
+
};
|
|
52
|
+
const hasClickHandlers = (gesture) => hasSignalListener(gesture, CLICK_SIGNALS);
|
|
53
|
+
const isInternalGesture = (gesture) => !hasSignalListener(gesture);
|
|
54
|
+
const isPrimaryGesture = (gesture) => PRIMARY_BUTTONS.has(gesture.getButton());
|
|
55
|
+
const clickGestures = (widget) => queryAllControllers(widget, Gtk.GestureClick).filter((gesture) => isPrimaryGesture(gesture));
|
|
56
|
+
const getAuthoredClickGestures = (widget) => clickGestures(widget).filter((gesture) => hasClickHandlers(gesture));
|
|
57
|
+
const isClaimingTarget = (widget) => widget instanceof Gtk.Button || containerFor(widget) !== null;
|
|
58
|
+
const gestureTargetFor = (widget, isInternalAllowed) => {
|
|
59
|
+
const gestures = clickGestures(widget);
|
|
60
|
+
if (isClaimingTarget(widget)) {
|
|
61
|
+
return { widget, container: containerFor(widget), gestures, isClaiming: true, native: null };
|
|
62
|
+
}
|
|
63
|
+
const authored = gestures.filter((gesture) => hasClickHandlers(gesture));
|
|
64
|
+
if (authored.length > 0) {
|
|
65
|
+
return { widget, container: null, gestures: authored, isClaiming: false, native: null };
|
|
66
|
+
}
|
|
67
|
+
if (isInternalAllowed && gestures.some((gesture) => isInternalGesture(gesture))) {
|
|
68
|
+
return { widget, container: null, gestures, isClaiming: true, native: null };
|
|
38
69
|
}
|
|
39
70
|
return null;
|
|
40
71
|
};
|
|
72
|
+
const clickTargetFor = (widget, scope) => {
|
|
73
|
+
if (isClickTransparent(widget)) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const native = nativeClickFor(widget, scope.isClicked);
|
|
77
|
+
if (native !== null) {
|
|
78
|
+
return { widget, container: null, gestures: getAuthoredClickGestures(widget), isClaiming: true, native };
|
|
79
|
+
}
|
|
80
|
+
return gestureTargetFor(widget, scope.isInternalAllowed);
|
|
81
|
+
};
|
|
82
|
+
const isSelfClickTarget = (widget) => isClickTransparent(widget) || clickTargetFor(widget, { isClicked: true, isInternalAllowed: false }) !== null;
|
|
83
|
+
const nextClickWidget = (current, target) => target?.isClaiming === true ? null : current.getParent();
|
|
84
|
+
const collectClickTargets = (widget) => {
|
|
85
|
+
const targets = [];
|
|
86
|
+
let current = widget;
|
|
87
|
+
while (current !== null) {
|
|
88
|
+
const isClicked = current === widget;
|
|
89
|
+
const scope = { isClicked, isInternalAllowed: !isClicked && targets.length === 0 };
|
|
90
|
+
const target = clickTargetFor(current, scope);
|
|
91
|
+
const next = nextClickWidget(current, target);
|
|
92
|
+
if (target !== null) {
|
|
93
|
+
targets.push(target);
|
|
94
|
+
}
|
|
95
|
+
current = next;
|
|
96
|
+
}
|
|
97
|
+
return targets;
|
|
98
|
+
};
|
|
99
|
+
const targetSites = (clicked, target) => {
|
|
100
|
+
const { container } = target;
|
|
101
|
+
const site = { gestures: target.gestures, point: getClickPoint(clicked, target.widget) };
|
|
102
|
+
if (container === null) {
|
|
103
|
+
return [site];
|
|
104
|
+
}
|
|
105
|
+
return [site, { gestures: getAuthoredClickGestures(container), point: getClickPoint(clicked, container) }];
|
|
106
|
+
};
|
|
107
|
+
const isSingleClickActivating = (container) => callBooleanGetter(container, "getActivateOnSingleClick") ?? true;
|
|
108
|
+
const isMultipleSelection = (container) => getCallableMethod(container, "getSelectionMode")?.() === Gtk.SelectionMode.MULTIPLE;
|
|
109
|
+
const isChildSelectable = (child) => callBooleanGetter(child, "getSelectable") ?? true;
|
|
110
|
+
const replaceContainerSelection = (container, child) => {
|
|
111
|
+
if (!isChildSelectable(child)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
selectContainerChild(container, child);
|
|
115
|
+
if (isMultipleSelection(container)) {
|
|
116
|
+
unselectOtherChildren(container, child);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const isActivatedByClick = (container, nPress) => isSingleClickActivating(container) || nPress > 1;
|
|
120
|
+
const isSelectionReplacedByClick = (container, nPress) => nPress > 1 || !isSingleClickActivating(container);
|
|
121
|
+
const applyContainerOutcome = (target, nPress) => {
|
|
122
|
+
const { container, widget } = target;
|
|
123
|
+
if (container === null || widget.getParent() !== container) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (isActivatedByClick(container, nPress)) {
|
|
127
|
+
widget.activate();
|
|
128
|
+
}
|
|
129
|
+
if (isSelectionReplacedByClick(container, nPress)) {
|
|
130
|
+
replaceContainerSelection(container, widget);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const applyClickOutcome = (target, nPress) => {
|
|
134
|
+
if (target.native === null) {
|
|
135
|
+
applyContainerOutcome(target, nPress);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
target.native(target.widget, nPress);
|
|
139
|
+
};
|
|
140
|
+
const applyClickOutcomes = (targets, nPress) => {
|
|
141
|
+
for (const target of targets) {
|
|
142
|
+
applyClickOutcome(target, nPress);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const deliverClick = (widget, nPress) => wrapEvent(widget, () => {
|
|
146
|
+
const targets = collectClickTargets(widget);
|
|
147
|
+
const sites = targets.flatMap((target) => targetSites(widget, target));
|
|
148
|
+
emitClickSequence(sites, nPress);
|
|
149
|
+
applyClickOutcomes(targets, nPress);
|
|
150
|
+
});
|
|
151
|
+
/* eslint-disable-next-line unicorn/consistent-boolean-name -- the boolean reports whether activation succeeded */
|
|
41
152
|
const tryActivate = async (widget) => {
|
|
42
153
|
if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {
|
|
43
154
|
return false;
|
|
@@ -49,32 +160,52 @@ const tryActivate = async (widget) => {
|
|
|
49
160
|
return isActivated;
|
|
50
161
|
};
|
|
51
162
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
163
|
+
* Activates a widget that neither claims the click nor carries a click gesture of its own, and
|
|
164
|
+
* otherwise delivers a press and release. The press travels outwards from the clicked widget
|
|
165
|
+
* through every widget carrying a click gesture with a pressed or released handler, the way GTK
|
|
166
|
+
* hands the same press to each of them, and stops at the first Gtk.Button or indexed child of a
|
|
167
|
+
* list box or flow box, which claims it. A gesture GTK attached itself takes the press only when no
|
|
168
|
+
* widget below it handles one, and stops it there, so an expander or a notebook tab nested in a row
|
|
169
|
+
* opens instead of activating the row. Coordinates are the clicked widget's position in each
|
|
170
|
+
* carrier, so a gesture the container of an indexed child carries reads the child's position rather
|
|
171
|
+
* than the container's center. An indexed child that the press reaches is then activated, or
|
|
172
|
+
* exclusively selected when its container does not activate on a single click. A widget with the
|
|
173
|
+
* label role is never activated, but does consume the click when it carries a gesture of its own.
|
|
174
|
+
*
|
|
175
|
+
* The press also stops at a widget whose click GTK4 implements in C on a gesture it attached
|
|
176
|
+
* itself, reading a GdkEvent that off-screen synthesis cannot produce. Gestures that widget carries
|
|
177
|
+
* of its own still take the press and release, the way GTK hands them the press before its own
|
|
178
|
+
* gesture claims it, and the same outcome is then applied through the public action GTK's own
|
|
179
|
+
* handler invokes: a list, grid, or column-view row is focused and selected, and activated as well
|
|
180
|
+
* on a second press or when its view activates on a single click; an expandable tree expander
|
|
181
|
+
* toggles its expansion, once per press, and only when it is the widget clicked, so a click on its
|
|
182
|
+
* child falls through to the enclosing row; a column header sorts by its column. Sorting goes
|
|
183
|
+
* through Gtk.ColumnView.sortByColumn, so the primary sort column and order match what a pointer
|
|
184
|
+
* produces while previously sorted columns are dropped rather than kept as secondary keys. A
|
|
185
|
+
* column-view cell and the row that carries the column headers stand in the way of the click rather
|
|
186
|
+
* than taking it, so a click on either reaches the row or the view behind it.
|
|
55
187
|
*/
|
|
56
188
|
const click = async (widget) => {
|
|
57
|
-
if (widget
|
|
58
|
-
await emitClickSequence(widget, widget, 1);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (widget instanceof Gtk.Switch) {
|
|
62
|
-
await wrapEvent(widget, () => {
|
|
63
|
-
widget.setActive(!widget.getActive());
|
|
64
|
-
});
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (await tryActivate(widget)) {
|
|
189
|
+
if (!isSelfClickTarget(widget) && (await tryActivate(widget))) {
|
|
68
190
|
return;
|
|
69
191
|
}
|
|
70
|
-
|
|
71
|
-
if (target) {
|
|
72
|
-
await emitClickSequence(widget, target, 1);
|
|
73
|
-
}
|
|
192
|
+
await deliverClick(widget, 1);
|
|
74
193
|
};
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Delivers a two-press click gesture the way {@link click} delivers a single press, without trying
|
|
196
|
+
* activation first. A list box row or flow box child the presses reach, clicked directly or through
|
|
197
|
+
* a descendant, is activated and exclusively selected, as GTK's double-click path does whether or
|
|
198
|
+
* not the container activates on a single click. A widget whose click GTK4 implements itself
|
|
199
|
+
* receives that outcome once per press, so a list, grid, or column-view row is selected and then
|
|
200
|
+
* activated by the second press, a tree expander ends back where it started, and a column header
|
|
201
|
+
* sorts and then inverts its order.
|
|
202
|
+
*/
|
|
203
|
+
const dblClick = (widget) => deliverClick(widget, 2);
|
|
204
|
+
/**
|
|
205
|
+
* Delivers a three-press click gesture the same way a double click is delivered, applying the same
|
|
206
|
+
* outcome to a list box row or flow box child the presses reach, and applying the outcome GTK4
|
|
207
|
+
* implements itself once per press to a row, tree expander, or column header.
|
|
208
|
+
*/
|
|
209
|
+
const tripleClick = (widget) => deliverClick(widget, 3);
|
|
210
|
+
export { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };
|
|
80
211
|
//# sourceMappingURL=click.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.js","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO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,EAAE,MAAkB,EAAiB,EAAE;IACtD,IAAI,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,CAAC;QAC/B,MAAM,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAE3C,OAAO;IACX,CAAC;IAED,IAAI,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,CAAC;QAC/B,MAAM,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;YACzB,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH,OAAO;IACX,CAAC;IAED,IAAI,MAAM,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO;IACX,CAAC;IAED,MAAM,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAE7C,IAAI,MAAM,EAAE,CAAC;QACT,MAAM,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;AACL,CAAC,CAAC;AAEF,0GAA0G;AAC1G,MAAM,QAAQ,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC7F,4GAA4G;AAC5G,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { getOrCreateControllers, queryController } from \"./controller.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\nconst getPressPoint = (widget: Gtk.Widget): { x: number; y: number } => {\n const width = widget.getWidth();\n const height = widget.getHeight();\n\n if (width > 0 && height > 0) {\n return { x: width / 2, y: height / 2 };\n }\n\n return { x: 0, y: 0 };\n};\n\nconst emitGesture = (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number, signal: string): void => {\n const { x, y } = getPressPoint(widget);\n\n for (const controller of controllers) {\n controller.emit(signal, nPress, x, y);\n }\n};\n\nconst emitPress = (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number): void => {\n emitGesture(widget, controllers, nPress, \"pressed\");\n};\n\nconst emitRelease = (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number): void => {\n emitGesture(widget, controllers, nPress, \"released\");\n};\n\nconst emitClickSequence = (widget: Gtk.Widget, target: Gtk.Widget, nPress: number): Promise<void> =>\n wrapEvent(widget, () => {\n const controllers = getOrCreateControllers(target, Gtk.GestureClick);\n\n for (let i = 1; i <= nPress; i++) {\n emitPress(target, controllers, i);\n emitRelease(target, controllers, i);\n }\n });\n\nconst findClickableAncestor = (widget: Gtk.Widget): Gtk.Widget | null => {\n let current = widget.getParent();\n\n while (current) {\n if (current instanceof Gtk.Button || queryController(current, Gtk.GestureClick) !== null) {\n return current;\n }\n\n current = current.getParent();\n }\n\n return null;\n};\n\nconst tryActivate = async (widget: Gtk.Widget): Promise<boolean> => {\n if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {\n return false;\n }\n\n let isActivated = false;\n\n await wrapEvent(widget, () => {\n isActivated = widget.activate();\n });\n\n return isActivated;\n};\n\n/**\n * Presses and releases a Gtk.Button, flips a Gtk.Switch, and otherwise activates the widget,\n * falling back to a click gesture on the nearest Gtk.Button or click-gesture ancestor when\n * activation does nothing. A widget with the label role is never activated.\n */\nconst click = async (widget: Gtk.Widget): Promise<void> => {\n if (widget instanceof Gtk.Button) {\n await emitClickSequence(widget, widget, 1);\n\n return;\n }\n\n if (widget instanceof Gtk.Switch) {\n await wrapEvent(widget, () => {\n widget.setActive(!widget.getActive());\n });\n\n return;\n }\n\n if (await tryActivate(widget)) {\n return;\n }\n\n const target = findClickableAncestor(widget);\n\n if (target) {\n await emitClickSequence(widget, target, 1);\n }\n};\n\n/** Emits a two-press click gesture at the widget's center, adding a Gtk.GestureClick when it has none. */\nconst dblClick = (widget: Gtk.Widget): Promise<void> => emitClickSequence(widget, widget, 2);\n/** Emits a three-press click gesture at the widget's center, adding a Gtk.GestureClick when it has none. */\nconst tripleClick = (widget: Gtk.Widget): Promise<void> => emitClickSequence(widget, widget, 3);\n\nexport { emitPress, emitRelease, click, dblClick, tripleClick };\n"]}
|
|
1
|
+
{"version":3,"file":"click.js","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACxH,OAAO,EAAE,kBAAkB,EAAoB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAezF,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC9C,MAAM,eAAe,GAAgB,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;AAEtE,MAAM,cAAc,GAAG,CAAC,MAAkB,EAAc,EAAE;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAElC,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QA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C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,KAAK,GAAG,KAAK,EAAE,MAAkB,EAAiB,EAAE;IACtD,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QAC5D,OAAO;IACX,CAAC;IAED,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAChF;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { hasSignalListener } from \"@gtkx/runtime/internal\";\nimport { callBooleanGetter, getCallableMethod, hasWidgetMethod } from \"../widget-getters.js\";\nimport { queryAllControllers } from \"./controller.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\nimport { hasIndexedChildren, selectContainerChild, SELECTED_PROBE, unselectOtherChildren } from \"./indexed-children.js\";\nimport { isClickTransparent, type NativeClick, nativeClickFor } from \"./native-click.js\";\n\ntype PressPoint = { x: number; y: number };\ntype ClickPhase = \"pressed\" | \"released\";\ntype ClickSite = { gestures: Gtk.GestureClick[]; point: PressPoint };\ntype ClickScope = { isClicked: boolean; isInternalAllowed: boolean };\n\ntype ClickTarget = {\n widget: Gtk.Widget;\n container: Gtk.Widget | null;\n gestures: Gtk.GestureClick[];\n isClaiming: boolean;\n native: NativeClick | null;\n};\n\nconst CLICK_SIGNALS = [\"pressed\", \"released\"];\nconst PRIMARY_BUTTONS: Set<number> = new Set([0, Gdk.BUTTON_PRIMARY]);\n\nconst getCenterPoint = (widget: Gtk.Widget): PressPoint => {\n const width = widget.getWidth();\n const height = widget.getHeight();\n\n if (width > 0 && height > 0) {\n return { x: width / 2, y: height / 2 };\n }\n\n return { x: 0, y: 0 };\n};\n\nconst getClickPoint = (clicked: Gtk.Widget, carrier: Gtk.Widget): PressPoint => {\n if (clicked === carrier) {\n return getCenterPoint(clicked);\n }\n\n const [isComputed, bounds] = clicked.computeBounds(carrier);\n\n if (!isComputed) {\n return getCenterPoint(carrier);\n }\n\n return { x: bounds.getX() + bounds.getWidth() / 2, y: bounds.getY() + bounds.getHeight() / 2 };\n};\n\nconst emitGesture = (point: PressPoint, controllers: Gtk.GestureClick[], nPress: number, signal: string): void => {\n for (const controller of controllers) {\n controller.emit(signal, nPress, point.x, point.y);\n }\n};\n\nconst emitClickPhase = (\n widget: Gtk.Widget,\n controllers: Gtk.GestureClick[],\n nPress: number,\n phase: ClickPhase,\n): void => {\n emitGesture(getCenterPoint(widget), controllers, nPress, phase);\n};\n\nconst emitSitePhase = (sites: ClickSite[], nPress: number, phase: ClickPhase): void => {\n for (const site of sites) {\n emitGesture(site.point, site.gestures, nPress, phase);\n }\n};\n\nconst emitClickSequence = (sites: ClickSite[], nPress: number): void => {\n for (let i = 1; i <= nPress; i++) {\n emitSitePhase(sites, i, \"pressed\");\n emitSitePhase(sites, i, \"released\");\n }\n};\n\nconst containerFor = (widget: Gtk.Widget): Gtk.Widget | null => {\n const parent = widget.getParent();\n\n return parent !== null && hasWidgetMethod(widget, SELECTED_PROBE) && hasIndexedChildren(parent) ? parent : null;\n};\n\nconst hasClickHandlers = (gesture: Gtk.GestureClick): boolean => hasSignalListener(gesture, CLICK_SIGNALS);\nconst isInternalGesture = (gesture: Gtk.GestureClick): boolean => !hasSignalListener(gesture);\nconst isPrimaryGesture = (gesture: Gtk.GestureClick): boolean => PRIMARY_BUTTONS.has(gesture.getButton());\n\nconst clickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n queryAllControllers(widget, Gtk.GestureClick).filter((gesture) => isPrimaryGesture(gesture));\n\nconst getAuthoredClickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n clickGestures(widget).filter((gesture) => hasClickHandlers(gesture));\n\nconst isClaimingTarget = (widget: Gtk.Widget): boolean =>\n widget instanceof Gtk.Button || containerFor(widget) !== null;\n\nconst gestureTargetFor = (widget: Gtk.Widget, isInternalAllowed: boolean): ClickTarget | null => {\n const gestures = clickGestures(widget);\n\n if (isClaimingTarget(widget)) {\n return { widget, container: containerFor(widget), gestures, isClaiming: true, native: null };\n }\n\n const authored = gestures.filter((gesture) => hasClickHandlers(gesture));\n\n if (authored.length > 0) {\n return { widget, container: null, gestures: authored, isClaiming: false, native: null };\n }\n\n if (isInternalAllowed && gestures.some((gesture) => isInternalGesture(gesture))) {\n return { widget, container: null, gestures, isClaiming: true, native: null };\n }\n\n return null;\n};\n\nconst clickTargetFor = (widget: Gtk.Widget, scope: ClickScope): ClickTarget | null => {\n if (isClickTransparent(widget)) {\n return null;\n }\n\n const native = nativeClickFor(widget, scope.isClicked);\n\n if (native !== null) {\n return { widget, container: null, gestures: getAuthoredClickGestures(widget), isClaiming: true, native };\n }\n\n return gestureTargetFor(widget, scope.isInternalAllowed);\n};\n\nconst isSelfClickTarget = (widget: Gtk.Widget): boolean =>\n isClickTransparent(widget) || clickTargetFor(widget, { isClicked: true, isInternalAllowed: false }) !== null;\n\nconst nextClickWidget = (current: Gtk.Widget, target: ClickTarget | null): Gtk.Widget | null =>\n target?.isClaiming === true ? null : current.getParent();\n\nconst collectClickTargets = (widget: Gtk.Widget): ClickTarget[] => {\n const targets: ClickTarget[] = [];\n let current: Gtk.Widget | null = widget;\n\n while (current !== null) {\n const isClicked = current === widget;\n const scope = { isClicked, isInternalAllowed: !isClicked && targets.length === 0 };\n const target = clickTargetFor(current, scope);\n const next = nextClickWidget(current, target);\n\n if (target !== null) {\n targets.push(target);\n }\n\n current = next;\n }\n\n return targets;\n};\n\nconst targetSites = (clicked: Gtk.Widget, target: ClickTarget): ClickSite[] => {\n const { container } = target;\n const site = { gestures: target.gestures, point: getClickPoint(clicked, target.widget) };\n\n if (container === null) {\n return [site];\n }\n\n return [site, { gestures: getAuthoredClickGestures(container), point: getClickPoint(clicked, container) }];\n};\n\nconst isSingleClickActivating = (container: Gtk.Widget): boolean =>\n callBooleanGetter(container, \"getActivateOnSingleClick\") ?? true;\n\nconst isMultipleSelection = (container: Gtk.Widget): boolean =>\n getCallableMethod<[], Gtk.SelectionMode>(container, \"getSelectionMode\")?.() === Gtk.SelectionMode.MULTIPLE;\n\nconst isChildSelectable = (child: Gtk.Widget): boolean => callBooleanGetter(child, \"getSelectable\") ?? true;\n\nconst replaceContainerSelection = (container: Gtk.Widget, child: Gtk.Widget): void => {\n if (!isChildSelectable(child)) {\n return;\n }\n\n selectContainerChild(container, child);\n\n if (isMultipleSelection(container)) {\n unselectOtherChildren(container, child);\n }\n};\n\nconst isActivatedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n isSingleClickActivating(container) || nPress > 1;\n\nconst isSelectionReplacedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n nPress > 1 || !isSingleClickActivating(container);\n\nconst applyContainerOutcome = (target: ClickTarget, nPress: number): void => {\n const { container, widget } = target;\n\n if (container === null || widget.getParent() !== container) {\n return;\n }\n\n if (isActivatedByClick(container, nPress)) {\n widget.activate();\n }\n\n if (isSelectionReplacedByClick(container, nPress)) {\n replaceContainerSelection(container, widget);\n }\n};\n\nconst applyClickOutcome = (target: ClickTarget, nPress: number): void => {\n if (target.native === null) {\n applyContainerOutcome(target, nPress);\n\n return;\n }\n\n target.native(target.widget, nPress);\n};\n\nconst applyClickOutcomes = (targets: ClickTarget[], nPress: number): void => {\n for (const target of targets) {\n applyClickOutcome(target, nPress);\n }\n};\n\nconst deliverClick = (widget: Gtk.Widget, nPress: number): Promise<void> =>\n wrapEvent(widget, () => {\n const targets = collectClickTargets(widget);\n const sites = targets.flatMap((target) => targetSites(widget, target));\n emitClickSequence(sites, nPress);\n applyClickOutcomes(targets, nPress);\n });\n\n/* eslint-disable-next-line unicorn/consistent-boolean-name -- the boolean reports whether activation succeeded */\nconst tryActivate = async (widget: Gtk.Widget): Promise<boolean> => {\n if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {\n return false;\n }\n\n let isActivated = false;\n\n await wrapEvent(widget, () => {\n isActivated = widget.activate();\n });\n\n return isActivated;\n};\n\n/**\n * Activates a widget that neither claims the click nor carries a click gesture of its own, and\n * otherwise delivers a press and release. The press travels outwards from the clicked widget\n * through every widget carrying a click gesture with a pressed or released handler, the way GTK\n * hands the same press to each of them, and stops at the first Gtk.Button or indexed child of a\n * list box or flow box, which claims it. A gesture GTK attached itself takes the press only when no\n * widget below it handles one, and stops it there, so an expander or a notebook tab nested in a row\n * opens instead of activating the row. Coordinates are the clicked widget's position in each\n * carrier, so a gesture the container of an indexed child carries reads the child's position rather\n * than the container's center. An indexed child that the press reaches is then activated, or\n * exclusively selected when its container does not activate on a single click. A widget with the\n * label role is never activated, but does consume the click when it carries a gesture of its own.\n *\n * The press also stops at a widget whose click GTK4 implements in C on a gesture it attached\n * itself, reading a GdkEvent that off-screen synthesis cannot produce. Gestures that widget carries\n * of its own still take the press and release, the way GTK hands them the press before its own\n * gesture claims it, and the same outcome is then applied through the public action GTK's own\n * handler invokes: a list, grid, or column-view row is focused and selected, and activated as well\n * on a second press or when its view activates on a single click; an expandable tree expander\n * toggles its expansion, once per press, and only when it is the widget clicked, so a click on its\n * child falls through to the enclosing row; a column header sorts by its column. Sorting goes\n * through Gtk.ColumnView.sortByColumn, so the primary sort column and order match what a pointer\n * produces while previously sorted columns are dropped rather than kept as secondary keys. A\n * column-view cell and the row that carries the column headers stand in the way of the click rather\n * than taking it, so a click on either reaches the row or the view behind it.\n */\nconst click = async (widget: Gtk.Widget): Promise<void> => {\n if (!isSelfClickTarget(widget) && (await tryActivate(widget))) {\n return;\n }\n\n await deliverClick(widget, 1);\n};\n\n/**\n * Delivers a two-press click gesture the way {@link click} delivers a single press, without trying\n * activation first. A list box row or flow box child the presses reach, clicked directly or through\n * a descendant, is activated and exclusively selected, as GTK's double-click path does whether or\n * not the container activates on a single click. A widget whose click GTK4 implements itself\n * receives that outcome once per press, so a list, grid, or column-view row is selected and then\n * activated by the second press, a tree expander ends back where it started, and a column header\n * sorts and then inverts its order.\n */\nconst dblClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 2);\n/**\n * Delivers a three-press click gesture the same way a double click is delivered, applying the same\n * outcome to a list box row or flow box child the presses reach, and applying the outcome GTK4\n * implements itself once per press to a row, tree expander, or column header.\n */\nconst tripleClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 3);\n\nexport { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-header-click.d.ts","sourceRoot":"","sources":["../../src/user-event/column-header-click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AA4EpC,QAAA,MAAM,gBAAgB,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,MAAM,KAAG,IAW9D,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|