@vickbk/tests 0.0.0-stage → 0.1.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/dist/react.mjs ADDED
@@ -0,0 +1,170 @@
1
+ import * as React from "react";
2
+ //#region src/features/react/utils/resolveArrayChild.ts
3
+ /**
4
+ * Resolves one array child and supplies a stable key when the result is an
5
+ * element without one.
6
+ *
7
+ * @param child - The child value to resolve.
8
+ * @param index - The child's position in its containing array.
9
+ * @param resolveTree - The recursive tree resolver.
10
+ * @returns The resolved child.
11
+ * @example
12
+ * ```ts
13
+ * await resolveArrayChild(<Page />, 0, resolveRscTree);
14
+ * ```
15
+ */
16
+ async function resolveArrayChild(child, index, resolveTree) {
17
+ const resolvedChild = await resolveTree(child);
18
+ if (React.isValidElement(resolvedChild)) {
19
+ const keyToUse = resolvedChild.key ?? child?.key ?? `rsc-key-${index}`;
20
+ return React.cloneElement(resolvedChild, { key: keyToUse });
21
+ }
22
+ return resolvedChild;
23
+ }
24
+ //#endregion
25
+ //#region src/features/react/utils/isClassComponent.ts
26
+ /**
27
+ * Determines whether a component type is a React class component.
28
+ *
29
+ * @param type - The value to inspect.
30
+ * @returns `true` when the value is a React class component.
31
+ * @example
32
+ * ```ts
33
+ * isClassComponent(MyClassComponent); // true
34
+ * ```
35
+ */
36
+ function isClassComponent(type) {
37
+ return typeof type === "function" && Boolean(type.prototype?.isReactComponent);
38
+ }
39
+ //#endregion
40
+ //#region src/features/react/utils/executeServerComponent.ts
41
+ /**
42
+ * Executes a server component and awaits an asynchronous result when present.
43
+ * Component errors intentionally propagate to the caller.
44
+ *
45
+ * @param type - The server component to execute.
46
+ * @param props - Props passed to the component.
47
+ * @returns The component's resolved render result.
48
+ * @example
49
+ * ```ts
50
+ * await executeServerComponent(Page, { title: "Hello" });
51
+ * ```
52
+ */
53
+ async function executeServerComponent(type, props) {
54
+ if (isClassComponent(type)) return new type(props).render();
55
+ return await type(props);
56
+ }
57
+ //#endregion
58
+ //#region src/features/react/utils/isClientComponent.ts
59
+ /**
60
+ * Determines whether a component should be kept behind a client boundary.
61
+ * React client/module references and functions containing hook calls are not
62
+ * invoked directly by the resolver.
63
+ *
64
+ * @param type - The React element type to inspect.
65
+ * @returns `true` when the type represents a client boundary.
66
+ * @example
67
+ * ```ts
68
+ * isClientComponent({ $$typeof: Symbol.for("react.client.reference") }); // true
69
+ * ```
70
+ */
71
+ function isClientComponent(type) {
72
+ if (type === null || typeof type !== "function" && typeof type !== "object") return false;
73
+ const reference = type;
74
+ if (reference.$$typeof === Symbol.for("react.client.reference") || reference.$$typeof === Symbol.for("react.module.reference") || typeof reference.$$id === "string") return true;
75
+ return typeof type === "function" && /\buse[A-Z0-9_]\w*\s*\(/.test(Function.prototype.toString.call(type));
76
+ }
77
+ //#endregion
78
+ //#region src/features/react/utils/resolveProps.ts
79
+ /**
80
+ * Resolves React elements and arrays nested in a component's props.
81
+ *
82
+ * @param props - The component props to inspect.
83
+ * @param resolveTree - The recursive tree resolver.
84
+ * @returns Updated props and whether any prop value changed.
85
+ * @example
86
+ * ```ts
87
+ * const result = await resolveProps({ children: <Page /> }, resolveRscTree);
88
+ * ```
89
+ */
90
+ async function resolveProps(props, resolveTree) {
91
+ const newProps = { ...props };
92
+ let hasChanged = false;
93
+ for (const key of Object.keys(newProps)) {
94
+ const value = newProps[key];
95
+ if (React.isValidElement(value) || Array.isArray(value)) {
96
+ const resolved = await resolveTree(value);
97
+ if (resolved !== value) {
98
+ newProps[key] = resolved;
99
+ hasChanged = true;
100
+ }
101
+ }
102
+ }
103
+ return {
104
+ newProps,
105
+ hasChanged
106
+ };
107
+ }
108
+ //#endregion
109
+ //#region src/features/react/utils/resolveElement.ts
110
+ /**
111
+ * Resolves a server component element or recursively updates its element props.
112
+ * Client component boundaries remain untouched and component errors propagate.
113
+ *
114
+ * @param node - The React element to resolve.
115
+ * @param resolveTree - The recursive tree resolver.
116
+ * @returns The resolved render result or the updated original element.
117
+ * @example
118
+ * ```ts
119
+ * await resolveElement(<ServerPage />, resolveRscTree);
120
+ * ```
121
+ */
122
+ async function resolveElement(node, resolveTree) {
123
+ const { type, props } = node;
124
+ if (typeof type === "function" && !isClientComponent(type)) return resolveTree(await executeServerComponent(type, props));
125
+ if (props && typeof props === "object") {
126
+ const { newProps, hasChanged } = await resolveProps(props, resolveTree);
127
+ if (hasChanged) return React.cloneElement(node, newProps);
128
+ }
129
+ return node;
130
+ }
131
+ //#endregion
132
+ //#region src/features/react/utils/traverseTree.ts
133
+ /**
134
+ * Traverses arrays and React elements, delegating component resolution.
135
+ *
136
+ * @param node - The tree value to visit.
137
+ * @param resolveTree - The recursive tree resolver.
138
+ * @returns The traversed value with server components resolved.
139
+ * @example
140
+ * ```ts
141
+ * await traverseTree(tree, resolveRscTree);
142
+ * ```
143
+ */
144
+ async function traverseTree(node, resolveTree) {
145
+ if (!node || typeof node !== "object") return node;
146
+ if (Array.isArray(node)) return Promise.all(node.map((child, index) => resolveArrayChild(child, index, resolveTree)));
147
+ if (React.isValidElement(node)) return resolveElement(node, resolveTree);
148
+ return node;
149
+ }
150
+ //#endregion
151
+ //#region src/features/react/utils/resolveRscTree.ts
152
+ /**
153
+ * Recursively resolves synchronous and asynchronous React Server Components.
154
+ * Client component boundaries are preserved, and component errors are allowed
155
+ * to reject the returned promise.
156
+ *
157
+ * @param node - The React node or tree to resolve.
158
+ * @returns A promise for the resolved React tree.
159
+ * @example
160
+ * ```ts
161
+ * const resolved = await resolveRscTree(<ServerPage />);
162
+ * ```
163
+ */
164
+ async function resolveRscTree(node) {
165
+ return traverseTree(node, resolveRscTree);
166
+ }
167
+ //#endregion
168
+ export { resolveRscTree };
169
+
170
+ //# sourceMappingURL=react.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.mjs","names":["ClassComponent","FunctionComponent"],"sources":["../src/features/react/utils/resolveArrayChild.ts","../src/features/react/utils/isClassComponent.ts","../src/features/react/utils/executeServerComponent.ts","../src/features/react/utils/isClientComponent.ts","../src/features/react/utils/resolveProps.ts","../src/features/react/utils/resolveElement.ts","../src/features/react/utils/traverseTree.ts","../src/features/react/utils/resolveRscTree.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\r\nimport * as React from \"react\";\r\nimport type { ResolveTree } from \"./types\";\r\n\r\n/**\r\n * Resolves one array child and supplies a stable key when the result is an\r\n * element without one.\r\n *\r\n * @param child - The child value to resolve.\r\n * @param index - The child's position in its containing array.\r\n * @param resolveTree - The recursive tree resolver.\r\n * @returns The resolved child.\r\n * @example\r\n * ```ts\r\n * await resolveArrayChild(<Page />, 0, resolveRscTree);\r\n * ```\r\n */\r\nexport async function resolveArrayChild(\r\n child: ReactNode,\r\n index: number,\r\n resolveTree: ResolveTree,\r\n): Promise<ReactNode> {\r\n const resolvedChild = await resolveTree(child);\r\n if (React.isValidElement(resolvedChild)) {\r\n const keyToUse =\r\n resolvedChild.key ??\r\n (child as { key?: string })?.key ??\r\n `rsc-key-${index}`;\r\n return React.cloneElement(resolvedChild, { key: keyToUse });\r\n }\r\n return resolvedChild;\r\n}\r\n","/**\r\n * Determines whether a component type is a React class component.\r\n *\r\n * @param type - The value to inspect.\r\n * @returns `true` when the value is a React class component.\r\n * @example\r\n * ```ts\r\n * isClassComponent(MyClassComponent); // true\r\n * ```\r\n */\r\nexport function isClassComponent(type: unknown): boolean {\r\n return (\r\n typeof type === \"function\" &&\r\n Boolean(\r\n (type as { prototype?: { isReactComponent?: unknown } }).prototype\r\n ?.isReactComponent,\r\n )\r\n );\r\n}\r\n","import type * as React from \"react\";\r\nimport type { ReactNode } from \"react\";\r\nimport { isClassComponent } from \"./isClassComponent\";\r\n\r\n/**\r\n * Executes a server component and awaits an asynchronous result when present.\r\n * Component errors intentionally propagate to the caller.\r\n *\r\n * @param type - The server component to execute.\r\n * @param props - Props passed to the component.\r\n * @returns The component's resolved render result.\r\n * @example\r\n * ```ts\r\n * await executeServerComponent(Page, { title: \"Hello\" });\r\n * ```\r\n */\r\nexport async function executeServerComponent(\r\n type: React.ComponentType<Record<string, unknown>>,\r\n props: Record<string, unknown>,\r\n): Promise<ReactNode> {\r\n if (isClassComponent(type)) {\r\n const ClassComponent = type as React.ComponentClass<\r\n Record<string, unknown>\r\n >;\r\n return new ClassComponent(props).render();\r\n }\r\n\r\n const FunctionComponent = type as React.FunctionComponent<\r\n Record<string, unknown>\r\n >;\r\n return await FunctionComponent(props);\r\n}\r\n","/**\r\n * Determines whether a component should be kept behind a client boundary.\r\n * React client/module references and functions containing hook calls are not\r\n * invoked directly by the resolver.\r\n *\r\n * @param type - The React element type to inspect.\r\n * @returns `true` when the type represents a client boundary.\r\n * @example\r\n * ```ts\r\n * isClientComponent({ $$typeof: Symbol.for(\"react.client.reference\") }); // true\r\n * ```\r\n */\r\nexport function isClientComponent(type: unknown): boolean {\r\n if (type === null || (typeof type !== \"function\" && typeof type !== \"object\")) {\r\n return false;\r\n }\r\n\r\n const reference = type as { $$typeof?: symbol; $$id?: unknown };\r\n if (\r\n reference.$$typeof === Symbol.for(\"react.client.reference\") ||\r\n reference.$$typeof === Symbol.for(\"react.module.reference\") ||\r\n typeof reference.$$id === \"string\"\r\n ) {\r\n return true;\r\n }\r\n\r\n return (\r\n typeof type === \"function\" &&\r\n /\\buse[A-Z0-9_]\\w*\\s*\\(/.test(Function.prototype.toString.call(type))\r\n );\r\n}\r\n","import * as React from \"react\";\r\nimport type { ResolveTree } from \"./types\";\r\n\r\n/**\r\n * Resolves React elements and arrays nested in a component's props.\r\n *\r\n * @param props - The component props to inspect.\r\n * @param resolveTree - The recursive tree resolver.\r\n * @returns Updated props and whether any prop value changed.\r\n * @example\r\n * ```ts\r\n * const result = await resolveProps({ children: <Page /> }, resolveRscTree);\r\n * ```\r\n */\r\nexport async function resolveProps(\r\n props: Record<string, unknown>,\r\n resolveTree: ResolveTree,\r\n): Promise<{ newProps: Record<string, unknown>; hasChanged: boolean }> {\r\n const newProps: Record<string, unknown> = { ...props };\r\n let hasChanged = false;\r\n\r\n for (const key of Object.keys(newProps)) {\r\n const value = newProps[key];\r\n if (React.isValidElement(value) || Array.isArray(value)) {\r\n const resolved = await resolveTree(value as React.ReactNode);\r\n if (resolved !== value) {\r\n newProps[key] = resolved;\r\n hasChanged = true;\r\n }\r\n }\r\n }\r\n\r\n return { newProps, hasChanged };\r\n}\r\n","import type { ReactNode } from \"react\";\r\nimport * as React from \"react\";\r\nimport { executeServerComponent } from \"./executeServerComponent\";\r\nimport { isClientComponent } from \"./isClientComponent\";\r\nimport { resolveProps } from \"./resolveProps\";\r\nimport type { ResolveTree } from \"./types\";\r\n\r\n/**\r\n * Resolves a server component element or recursively updates its element props.\r\n * Client component boundaries remain untouched and component errors propagate.\r\n *\r\n * @param node - The React element to resolve.\r\n * @param resolveTree - The recursive tree resolver.\r\n * @returns The resolved render result or the updated original element.\r\n * @example\r\n * ```ts\r\n * await resolveElement(<ServerPage />, resolveRscTree);\r\n * ```\r\n */\r\nexport async function resolveElement(\r\n node: React.ReactElement,\r\n resolveTree: ResolveTree,\r\n): Promise<ReactNode> {\r\n const { type, props } = node;\r\n\r\n if (typeof type === \"function\" && !isClientComponent(type)) {\r\n const serverResult = await executeServerComponent(\r\n type as React.ComponentType<Record<string, unknown>>,\r\n props as Record<string, unknown>,\r\n );\r\n return resolveTree(serverResult);\r\n }\r\n\r\n if (props && typeof props === \"object\") {\r\n const { newProps, hasChanged } = await resolveProps(\r\n props as Record<string, unknown>,\r\n resolveTree,\r\n );\r\n if (hasChanged) {\r\n return React.cloneElement(node, newProps);\r\n }\r\n }\r\n\r\n return node;\r\n}\r\n","import * as React from \"react\";\r\nimport type { ReactNode } from \"react\";\r\nimport { resolveArrayChild } from \"./resolveArrayChild\";\r\nimport { resolveElement } from \"./resolveElement\";\r\nimport type { ResolveTree } from \"./types\";\r\n\r\n/**\r\n * Traverses arrays and React elements, delegating component resolution.\r\n *\r\n * @param node - The tree value to visit.\r\n * @param resolveTree - The recursive tree resolver.\r\n * @returns The traversed value with server components resolved.\r\n * @example\r\n * ```ts\r\n * await traverseTree(tree, resolveRscTree);\r\n * ```\r\n */\r\nexport async function traverseTree(\r\n node: ReactNode,\r\n resolveTree: ResolveTree,\r\n): Promise<ReactNode> {\r\n if (!node || typeof node !== \"object\") return node;\r\n\r\n if (Array.isArray(node)) {\r\n return Promise.all(\r\n node.map((child, index) => resolveArrayChild(child, index, resolveTree)),\r\n );\r\n }\r\n\r\n if (React.isValidElement(node)) {\r\n return resolveElement(node, resolveTree);\r\n }\r\n\r\n return node;\r\n}\r\n","import type { ReactNode } from \"react\";\r\nimport { traverseTree } from \"./traverseTree\";\r\n\r\n/**\r\n * Recursively resolves synchronous and asynchronous React Server Components.\r\n * Client component boundaries are preserved, and component errors are allowed\r\n * to reject the returned promise.\r\n *\r\n * @param node - The React node or tree to resolve.\r\n * @returns A promise for the resolved React tree.\r\n * @example\r\n * ```ts\r\n * const resolved = await resolveRscTree(<ServerPage />);\r\n * ```\r\n */\r\nexport async function resolveRscTree(node: ReactNode): Promise<ReactNode> {\r\n return traverseTree(node, resolveRscTree);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,eAAsB,kBACpB,OACA,OACA,aACoB;CACpB,MAAM,gBAAgB,MAAM,YAAY,KAAK;CAC7C,IAAI,MAAM,eAAe,aAAa,GAAG;EACvC,MAAM,WACJ,cAAc,OACb,OAA4B,OAC7B,WAAW;EACb,OAAO,MAAM,aAAa,eAAe,EAAE,KAAK,SAAS,CAAC;CAC5D;CACA,OAAO;AACT;;;;;;;;;;;;;ACrBA,SAAgB,iBAAiB,MAAwB;CACvD,OACE,OAAO,SAAS,cAChB,QACG,KAAwD,WACrD,gBACN;AAEJ;;;;;;;;;;;;;;;ACFA,eAAsB,uBACpB,MACA,OACoB;CACpB,IAAI,iBAAiB,IAAI,GAIvB,OAAO,IAAIA,KAAe,KAAK,CAAC,CAAC,OAAO;CAM1C,OAAO,MAAMC,KAAkB,KAAK;AACtC;;;;;;;;;;;;;;;ACnBA,SAAgB,kBAAkB,MAAwB;CACxD,IAAI,SAAS,QAAS,OAAO,SAAS,cAAc,OAAO,SAAS,UAClE,OAAO;CAGT,MAAM,YAAY;CAClB,IACE,UAAU,aAAa,OAAO,IAAI,wBAAwB,KAC1D,UAAU,aAAa,OAAO,IAAI,wBAAwB,KAC1D,OAAO,UAAU,SAAS,UAE1B,OAAO;CAGT,OACE,OAAO,SAAS,cAChB,yBAAyB,KAAK,SAAS,UAAU,SAAS,KAAK,IAAI,CAAC;AAExE;;;;;;;;;;;;;;AChBA,eAAsB,aACpB,OACA,aACqE;CACrE,MAAM,WAAoC,EAAE,GAAG,MAAM;CACrD,IAAI,aAAa;CAEjB,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,GAAG;EACvC,MAAM,QAAQ,SAAS;EACvB,IAAI,MAAM,eAAe,KAAK,KAAK,MAAM,QAAQ,KAAK,GAAG;GACvD,MAAM,WAAW,MAAM,YAAY,KAAwB;GAC3D,IAAI,aAAa,OAAO;IACtB,SAAS,OAAO;IAChB,aAAa;GACf;EACF;CACF;CAEA,OAAO;EAAE;EAAU;CAAW;AAChC;;;;;;;;;;;;;;;ACdA,eAAsB,eACpB,MACA,aACoB;CACpB,MAAM,EAAE,MAAM,UAAU;CAExB,IAAI,OAAO,SAAS,cAAc,CAAC,kBAAkB,IAAI,GAKvD,OAAO,YAAY,MAJQ,uBACzB,MACA,KACF,CAC+B;CAGjC,IAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,EAAE,UAAU,eAAe,MAAM,aACrC,OACA,WACF;EACA,IAAI,YACF,OAAO,MAAM,aAAa,MAAM,QAAQ;CAE5C;CAEA,OAAO;AACT;;;;;;;;;;;;;;AC3BA,eAAsB,aACpB,MACA,aACoB;CACpB,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO;CAE9C,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO,QAAQ,IACb,KAAK,KAAK,OAAO,UAAU,kBAAkB,OAAO,OAAO,WAAW,CAAC,CACzE;CAGF,IAAI,MAAM,eAAe,IAAI,GAC3B,OAAO,eAAe,MAAM,WAAW;CAGzC,OAAO;AACT;;;;;;;;;;;;;;;ACnBA,eAAsB,eAAe,MAAqC;CACxE,OAAO,aAAa,MAAM,cAAc;AAC1C"}
@@ -0,0 +1,28 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ Object.defineProperty(exports, "__toESM", {
24
+ enumerable: true,
25
+ get: function() {
26
+ return __toESM;
27
+ }
28
+ });
@@ -0,0 +1,8 @@
1
+ //#region src/shared/regex/types.d.ts
2
+ type TEXT_PATTERN = RegExp | string;
3
+ type LABEL_LOCATOR = [TEXT_PATTERN, string];
4
+ type TEXT_WITH_NTH = [TEXT_PATTERN, number];
5
+ type TEXT_MATCHER = TEXT_PATTERN | TEXT_WITH_NTH;
6
+ //#endregion
7
+ export { TEXT_WITH_NTH as i, TEXT_MATCHER as n, TEXT_PATTERN as r, LABEL_LOCATOR as t };
8
+ //# sourceMappingURL=types-BlSFP07Z.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BlSFP07Z.d.cts","names":[],"sources":["../src/shared/regex/types.ts"],"mappings":";KAAY,eAAe;KACf,iBAAiB;KACjB,iBAAiB;KACjB,eAAe,eAAe"}
@@ -0,0 +1,8 @@
1
+ //#region src/shared/regex/types.d.ts
2
+ type TEXT_PATTERN = RegExp | string;
3
+ type LABEL_LOCATOR = [TEXT_PATTERN, string];
4
+ type TEXT_WITH_NTH = [TEXT_PATTERN, number];
5
+ type TEXT_MATCHER = TEXT_PATTERN | TEXT_WITH_NTH;
6
+ //#endregion
7
+ export { TEXT_WITH_NTH as i, TEXT_MATCHER as n, TEXT_PATTERN as r, LABEL_LOCATOR as t };
8
+ //# sourceMappingURL=types-BlSFP07Z.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BlSFP07Z.d.mts","names":[],"sources":["../src/shared/regex/types.ts"],"mappings":";KAAY,eAAe;KACf,iBAAiB;KACjB,iBAAiB;KACjB,eAAe,eAAe"}
@@ -0,0 +1,305 @@
1
+ import { fireEvent as fireEvent$1 } from "@testing-library/react";
2
+ //#region src/features/vitest/modules/dom/modules/toggle-event/utils/types.d.ts
3
+ /**
4
+ * Possible states for a disclosure or popover toggle transition.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const nextState: ToggleState = "open";
9
+ * ```
10
+ */
11
+ type ToggleState = "open" | "closed";
12
+ /**
13
+ * The previous and next states dispatched by the toggle-event polyfill.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const transition: ToggleConfig = { oldState: "closed", newState: "open" };
18
+ * ```
19
+ */
20
+ type ToggleConfig = Record<"oldState" | "newState", ToggleState>;
21
+ /**
22
+ * Internal shape added to Testing Library's `fireEvent` by its type augmentation.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * installToggleEvent();
27
+ * fireEvent.toggle(document.body, { newState: "open" });
28
+ * ```
29
+ */
30
+ type ToggleFireEventExtensions = {
31
+ toggle: (element: Document | Element | Window | Node, initDict?: Partial<ToggleConfig>) => boolean;
32
+ };
33
+ //#endregion
34
+ //#region src/features/vitest/modules/dom/modules/toggle-event/utils/fireEvent.d.ts
35
+ /**
36
+ * Testing Library's fireEvent API with an additional `toggle` event helper.
37
+ *
38
+ * The exported object copies the standard `fireEvent` properties and adds
39
+ * `toggle`, which dispatches the toggle event through `togglePolyfill`.
40
+ * It does not install the extension onto Testing Library's original export.
41
+ *
42
+ * Standard Testing Library event helpers remain available, including
43
+ * `click`, `change`, `input`, `submit`, `focus`, and keyboard/mouse events.
44
+ *
45
+ * @remarks
46
+ * The `toggle` helper defaults to a transition from `closed` to `open`.
47
+ * Call-specific configuration overrides those defaults. This helper does
48
+ * not maintain state between calls.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * import { fireEvent } from "@vickbk/tests/vitest";
53
+ *
54
+ * const disclosure = document.querySelector("details")!;
55
+ *
56
+ * fireEvent.toggle(disclosure);
57
+ * fireEvent.toggle(disclosure, { newState: "closed" });
58
+ * ```
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { fireEvent } from "@vickbk/tests/vitest";
63
+ *
64
+ * const button = document.querySelector("button")!;
65
+ *
66
+ * fireEvent.click(button);
67
+ * ```
68
+ */
69
+ export declare const fireEvent: typeof fireEvent$1 & ToggleFireEventExtensions;
70
+ //#endregion
71
+ //#region src/shared/regex/types.d.ts
72
+ type TEXT_PATTERN = RegExp | string;
73
+ type TEXT_WITH_NTH = [TEXT_PATTERN, number];
74
+ type TEXT_MATCHER = TEXT_PATTERN | TEXT_WITH_NTH;
75
+ //#endregion
76
+ //#region src/features/vitest/modules/dom/utils/clickLabelInput.d.ts
77
+ /**
78
+ * Simulates clicking an input found by its label or placeholder.
79
+ *
80
+ * @param label Label or placeholder text/regular expression identifying the input.
81
+ * @param container Optional element that limits the input search.
82
+ * @returns A promise that resolves after the click interaction completes.
83
+ * @example
84
+ * ```ts
85
+ * await clickLabelInput("Email address");
86
+ * ```
87
+ */
88
+ export declare function clickLabelInput(label: TEXT_PATTERN, container?: HTMLElement): Promise<void>;
89
+ //#endregion
90
+ //#region src/features/vitest/modules/dom/utils/isChecked.d.ts
91
+ /**
92
+ * Asserts that the radio button or checkbox matching the accessible name is checked.
93
+ *
94
+ * @param selector Accessible label text or regular expression for the control.
95
+ * @param container Optional element that limits the control search.
96
+ * @returns Nothing; throws an assertion error if the control is absent or unchecked.
97
+ * @example
98
+ * ```ts
99
+ * isChecked("Accept terms");
100
+ * ```
101
+ */
102
+ export declare function isChecked(selector: TEXT_PATTERN, container?: HTMLElement): void;
103
+ //#endregion
104
+ //#region src/features/vitest/modules/dom/utils/isNotChecked.d.ts
105
+ /**
106
+ * Asserts that the radio button or checkbox matching the accessible name is unchecked.
107
+ *
108
+ * @param selector Accessible label text or regular expression for the control.
109
+ * @param container Optional element that limits the control search.
110
+ * @returns Nothing; throws an assertion error if the control is absent or checked.
111
+ * @example
112
+ * ```ts
113
+ * isNotChecked("Subscribe to updates");
114
+ * ```
115
+ */
116
+ export declare function isNotChecked(selector: TEXT_PATTERN, container?: HTMLElement): void;
117
+ //#endregion
118
+ //#region src/features/vitest/modules/dom/utils/shouldHaveAttributes.d.ts
119
+ /**
120
+ * Asserts that an HTMLElement possesses the expected set of DOM attributes and values.
121
+ *
122
+ * Handles string/numeric values, boolean attributes (true = present, false = absent),
123
+ * and null/undefined values (absent).
124
+ *
125
+ * @param element The DOM element whose attributes will be checked.
126
+ * @param attributes Attribute names mapped to their expected values.
127
+ * @returns Nothing; throws an assertion error when any attribute does not match.
128
+ * @example
129
+ * ```ts
130
+ * shouldHaveAttributes(input, { required: true, "aria-label": "Email" });
131
+ * ```
132
+ */
133
+ export declare function shouldHaveAttributes(element: HTMLElement, attributes: Record<string, unknown>): void;
134
+ //#endregion
135
+ //#region src/features/vitest/modules/dom/utils/shouldHaveTestId.d.ts
136
+ /**
137
+ * Asserts that elements with all supplied test IDs are present in the document.
138
+ *
139
+ * @param ids One or more `data-testid` values to locate.
140
+ * @returns The elements found, in the same order as the supplied IDs.
141
+ * @example
142
+ * ```ts
143
+ * const [submitButton] = shouldHaveTestId("submit-button");
144
+ * ```
145
+ */
146
+ export declare function shouldHaveTestId(...ids: string[]): HTMLElement[];
147
+ //#endregion
148
+ //#region src/features/vitest/modules/dom/utils/shouldNotHaveTestId.d.ts
149
+ /**
150
+ * Asserts that elements with all supplied test IDs are absent from the document.
151
+ *
152
+ * @param ids One or more `data-testid` values to verify are absent.
153
+ * @returns The query results (`null` for each absent element), in ID order.
154
+ * @example
155
+ * ```ts
156
+ * shouldNotHaveTestId("loading-spinner");
157
+ * ```
158
+ */
159
+ export declare function shouldNotHaveTestId(...ids: string[]): (HTMLElement | null)[];
160
+ //#endregion
161
+ //#region src/features/vitest/modules/dom/utils/shouldNotSee.d.ts
162
+ /**
163
+ * Asserts that none of the supplied text matchers appear in the document.
164
+ *
165
+ * @param texts Text strings or regular expressions that must be absent.
166
+ * @returns Nothing; throws an assertion error if any text is found.
167
+ * @example
168
+ * ```ts
169
+ * shouldNotSee("Error", /failed/i);
170
+ * ```
171
+ */
172
+ export declare const shouldNotSee: (...texts: (string | RegExp)[]) => void;
173
+ //#endregion
174
+ //#region src/features/vitest/modules/dom/utils/shouldSee.d.ts
175
+ /**
176
+ * Asserts that each requested text matcher is present in the document.
177
+ *
178
+ * @param texts Text strings, regular expressions, or `[matcher, occurrenceIndex]` pairs.
179
+ * @returns The matching elements in the same order as the supplied matchers.
180
+ * @example
181
+ * ```ts
182
+ * const [heading] = shouldSee("Welcome");
183
+ * ```
184
+ */
185
+ export declare const shouldSee: (...texts: TEXT_MATCHER[]) => HTMLElement[];
186
+ //#endregion
187
+ //#region src/features/vitest/modules/dom/utils/togglePopover.d.ts
188
+ /**
189
+ * Dispatches a toggle event on the first element matching a selector.
190
+ *
191
+ * @param options Selector, optional search container, and target open/closed state.
192
+ * @returns The matched element, or `undefined` when no matching element exists.
193
+ * @example
194
+ * ```ts
195
+ * const popover = togglePopover({ selector: "#help", newState: "open" });
196
+ * ```
197
+ */
198
+ export declare function togglePopover({ container, selector, newState }: {
199
+ container?: HTMLElement;
200
+ selector: string;
201
+ newState?: ToggleState;
202
+ }): Element | undefined;
203
+ //#endregion
204
+ //#region src/features/vitest/modules/dom/utils/userClicks.d.ts
205
+ /**
206
+ * Simulates a user click on a button with the requested name, or matching text.
207
+ *
208
+ * @param target Button accessible name or text string/regular expression.
209
+ * @param container Optional element that limits the target search.
210
+ * @returns A promise that resolves after the click interaction completes.
211
+ * @example
212
+ * ```ts
213
+ * await userClicks("Save");
214
+ * ```
215
+ */
216
+ export declare const userClicks: (target: string | RegExp, container?: HTMLElement) => Promise<void>;
217
+ //#endregion
218
+ //#region src/features/vitest/modules/dom/utils/userTypes.d.ts
219
+ /**
220
+ * Replaces the value of a textbox found by its label, placeholder, or textbox name.
221
+ *
222
+ * @param target Accessible label, placeholder, or textbox name as text or a regex.
223
+ * @param text Text to type after clearing the existing value.
224
+ * @param container Optional element that limits the textbox search.
225
+ * @param user User-event instance used for the interaction; defaults to a new instance.
226
+ * @returns A promise resolving to the textbox that was updated.
227
+ * @example
228
+ * ```ts
229
+ * const emailInput = await userTypes("Email", "person@example.com");
230
+ * ```
231
+ */
232
+ export declare const userTypes: (target: TEXT_PATTERN, text: string, container?: HTMLElement, user?: import("@testing-library/user-event").UserEvent) => Promise<HTMLElement>;
233
+ //#endregion
234
+ //#region src/features/vitest/modules/dom/utils/userTypesMultiple.d.ts
235
+ /**
236
+ * Replaces the values of multiple textboxes, located by their respective selectors.
237
+ *
238
+ * @param inputs Object mapping each textbox label/placeholder to the text to enter.
239
+ * @param container Optional element that limits all textbox searches.
240
+ * @returns A promise resolving to an object mapping each selector to its updated textbox.
241
+ * @example
242
+ * ```ts
243
+ * const fields = await userTypesMultiple({ Email: "person@example.com", Name: "Pat" });
244
+ * ```
245
+ */
246
+ export declare function userTypesMultiple(inputs: Record<string, string>, container?: HTMLElement): Promise<Record<string, HTMLElement>>;
247
+ //#endregion
248
+ //#region src/features/vitest/modules/promises/utils/resolvedPromise.d.ts
249
+ /**
250
+ * Creates a fulfilled promise augmented with Vitest's fulfilled-promise metadata.
251
+ *
252
+ * @param value The value with which the promise is fulfilled.
253
+ * @returns A fulfilled Promise<T> with `status: "fulfilled"` and its `value`.
254
+ * @example
255
+ * ```ts
256
+ * const payload = await resolvedPromise({ id: 1 });
257
+ * expect(payload).toEqual({ id: 1 });
258
+ * ```
259
+ */
260
+ export declare function resolvedPromise<T>(value: T): Promise<T> & {
261
+ status: "fulfilled";
262
+ value: T;
263
+ };
264
+ //#endregion
265
+ //#region src/features/vitest/modules/promises/utils/rejectedPromise.d.ts
266
+ /**
267
+ * Creates a rejected promise augmented with Vitest's rejected-promise metadata.
268
+ *
269
+ * @param reason The rejection reason, preserved as an unknown value; defaults to `undefined`.
270
+ * @returns A rejected Promise<never> with `status: "rejected"` and its `reason`.
271
+ * @example
272
+ * ```ts
273
+ * await expect(rejectedPromise(new Error("Request failed"))).rejects.toThrow("Request failed");
274
+ * ```
275
+ */
276
+ export declare function rejectedPromise(reason?: unknown): Promise<never> & {
277
+ status: "rejected";
278
+ reason: unknown;
279
+ };
280
+ //#endregion
281
+ //#region src/features/vitest/utils/console.d.ts
282
+ /**
283
+ * Suppresses console.log, console.warn, and console.error until resetConsole runs.
284
+ *
285
+ * @example
286
+ * ```ts
287
+ * beforeEach(shutConsole);
288
+ * afterEach(resetConsole);
289
+ * ```
290
+ */
291
+ export declare function shutConsole(): void;
292
+ /**
293
+ * Restores the console methods most recently suppressed by shutConsole.
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * shutConsole();
298
+ * // Run code whose console output should be ignored.
299
+ * resetConsole();
300
+ * ```
301
+ */
302
+ export declare function resetConsole(): void;
303
+ //#endregion
304
+ export type { ToggleConfig, ToggleState };
305
+ //# sourceMappingURL=vitest.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest.d.mts","names":["rtlFireEvent"],"sources":["../src/features/vitest/modules/dom/modules/toggle-event/utils/types.ts","../src/features/vitest/modules/dom/modules/toggle-event/utils/fireEvent.ts","../src/shared/regex/types.ts","../src/features/vitest/modules/dom/utils/clickLabelInput.ts","../src/features/vitest/modules/dom/utils/isChecked.ts","../src/features/vitest/modules/dom/utils/isNotChecked.ts","../src/features/vitest/modules/dom/utils/shouldHaveAttributes.ts","../src/features/vitest/modules/dom/utils/shouldHaveTestId.ts","../src/features/vitest/modules/dom/utils/shouldNotHaveTestId.ts","../src/features/vitest/modules/dom/utils/shouldNotSee.ts","../src/features/vitest/modules/dom/utils/shouldSee.ts","../src/features/vitest/modules/dom/utils/togglePopover.ts","../src/features/vitest/modules/dom/utils/userClicks.ts","../src/features/vitest/modules/dom/utils/userTypes.ts","../src/features/vitest/modules/dom/utils/userTypesMultiple.ts","../src/features/vitest/modules/promises/utils/resolvedPromise.ts","../src/features/vitest/modules/promises/utils/rejectedPromise.ts","../src/features/vitest/utils/console.ts"],"mappings":";;;;;;;;;;KAQY;;;;;;;;;KAUA,eAAe,gCAAgC;;;;;;;;;;KAW/C;EACV,SACE,SAAS,WAAW,UAAU,SAAS,MACvC,WAAW,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBCQV,kBAyBAA,cAAe;;;KCjEhB,eAAe;KAEf,iBAAiB;KACjB,eAAe,eAAe;;;;;;;;;;;;;;wBCapB,gBACpB,OAAO,cACP,YAAY,cAAW;;;;;;;;;;;;;;wBCHT,UAAU,UAAU,cAAc,YAAY;;;;;;;;;;;;;;wBCA9C,aAAa,UAAU,cAAc,YAAY;;;;;;;;;;;;;;;;;wBCCjD,qBACd,SAAS,aACT,YAAY;;;;;;;;;;;;;wBCLE,oBAAoB,gBAAa;;;;;;;;;;;;;wBCAjC,uBAAuB,iBAAa;;;;;;;;;;;;;qBCDvC,kBAAmB,iBAAiB;;;;;;;;;;;;;qBCCpC,eAAgB,OAAO,mBAAc;;;;;;;;;;;;;wBCDlC,gBACd,WACA,UACA;EAEA,YAAY;EACZ;EACA,WAAW;IACZ;;;;;;;;;;;;;;qBCLY,aACX,iBAAiB,QACjB,YAAY,gBAAW;;;;;;;;;;;;;;;;qBCAZ,YACX,QAAQ,cACR,cACA,YAAY,aACZ,6CAAA,cAAwB,QAAA;;;;;;;;;;;;;;wBCRJ,kBACpB,QAAQ,wBACR,YAAY,cAAW,QAAA,eAAA;;;;;;;;;;;;;;wBCJT,gBAAgB,GAC9B,OAAO,IACN,QAAQ;EAAO;EAAqB,OAAO;;;;;;;;;;;;;;wBCH9B,gBACd,mBACC;EAAmB;EAAoB;;;;;;;;;;;;;wBCG1B;;;;;;;;;;;wBAkBA"}