@vickbk/tests 0.0.0-stage → 0.2.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/CHANGELOG.md +39 -0
- package/LICENSE +21 -0
- package/README.md +225 -2
- package/dist/console-Cf1taTRK.mjs +39 -0
- package/dist/console-Cf1taTRK.mjs.map +1 -0
- package/dist/dom-DeHbD1ni.mjs +459 -0
- package/dist/dom-DeHbD1ni.mjs.map +1 -0
- package/dist/index-CKsosUpb.d.mts +249 -0
- package/dist/index-CKsosUpb.d.mts.map +1 -0
- package/dist/index-DtGBqDev.d.mts +25 -0
- package/dist/index-DtGBqDev.d.mts.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/pattern-to-regex-BrMJtzu8.cjs +19 -0
- package/dist/pattern-to-regex-BrMJtzu8.cjs.map +1 -0
- package/dist/pattern-to-regex-CO5Y0oDU.mjs +14 -0
- package/dist/pattern-to-regex-CO5Y0oDU.mjs.map +1 -0
- package/dist/playwright.cjs +327 -0
- package/dist/playwright.cjs.map +1 -0
- package/dist/playwright.d.cts +254 -0
- package/dist/playwright.d.cts.map +1 -0
- package/dist/playwright.d.mts +254 -0
- package/dist/playwright.d.mts.map +1 -0
- package/dist/playwright.mjs +308 -0
- package/dist/playwright.mjs.map +1 -0
- package/dist/promises.cjs +45 -0
- package/dist/promises.cjs.map +1 -0
- package/dist/promises.d.cts +34 -0
- package/dist/promises.d.cts.map +1 -0
- package/dist/promises.d.mts +34 -0
- package/dist/promises.d.mts.map +1 -0
- package/dist/promises.mjs +43 -0
- package/dist/promises.mjs.map +1 -0
- package/dist/react.cjs +173 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +17 -0
- package/dist/react.d.cts.map +1 -0
- package/dist/react.d.mts +17 -0
- package/dist/react.d.mts.map +1 -0
- package/dist/react.mjs +170 -0
- package/dist/react.mjs.map +1 -0
- package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
- package/dist/types-BlSFP07Z.d.cts +8 -0
- package/dist/types-BlSFP07Z.d.cts.map +1 -0
- package/dist/types-BlSFP07Z.d.mts +8 -0
- package/dist/types-BlSFP07Z.d.mts.map +1 -0
- package/dist/vitest/console.d.mts +2 -0
- package/dist/vitest/console.mjs +1 -0
- package/dist/vitest/dom.d.mts +2 -0
- package/dist/vitest/dom.mjs +1 -0
- package/dist/vitest.d.mts +49 -0
- package/dist/vitest.d.mts.map +1 -0
- package/dist/vitest.mjs +57 -0
- package/dist/vitest.mjs.map +1 -0
- package/package.json +165 -3
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { fireEvent } 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
|
+
declare const fireEvent$1: typeof fireEvent & 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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
declare function userTypesMultiple(inputs: Record<string, string>, container?: HTMLElement): Promise<Record<string, HTMLElement>>;
|
|
247
|
+
//#endregion
|
|
248
|
+
export { shouldSee as a, shouldHaveTestId as c, isChecked as d, clickLabelInput as f, ToggleState as h, togglePopover as i, shouldHaveAttributes as l, ToggleConfig as m, userTypes as n, shouldNotSee as o, fireEvent$1 as p, userClicks as r, shouldNotHaveTestId as s, userTypesMultiple as t, isNotChecked as u };
|
|
249
|
+
//# sourceMappingURL=index-CKsosUpb.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CKsosUpb.d.mts","names":["fireEvent","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"],"mappings":";;;;;;;;;;KAQY;;;;;;;;;KAUA,eAAe,gCAAgC;;;;;;;;;;KAW/C;EACV,SACE,SAAS,WAAW,UAAU,SAAS,MACvC,WAAW,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCQVA,oBAyBAC,YAAe;;;KCjEhB,eAAe;KAEf,iBAAiB;KACjB,eAAe,eAAe;;;;;;;;;;;;;;iBCapB,gBACpB,OAAO,cACP,YAAY,cAAW;;;;;;;;;;;;;;iBCHT,UAAU,UAAU,cAAc,YAAY;;;;;;;;;;;;;;iBCA9C,aAAa,UAAU,cAAc,YAAY;;;;;;;;;;;;;;;;;iBCCjD,qBACd,SAAS,aACT,YAAY;;;;;;;;;;;;;iBCLE,oBAAoB,gBAAa;;;;;;;;;;;;;iBCAjC,uBAAuB,iBAAa;;;;;;;;;;;;;cCDvC,kBAAmB,iBAAiB;;;;;;;;;;;;;cCCpC,eAAgB,OAAO,mBAAc;;;;;;;;;;;;;iBCDlC,gBACd,WACA,UACA;EAEA,YAAY;EACZ;EACA,WAAW;IACZ;;;;;;;;;;;;;;cCLY,aACX,iBAAiB,QACjB,YAAY,gBAAW;;;;;;;;;;;;;;;;cCAZ,YACX,QAAQ,cACR,cACA,YAAY,aACZ,6CAAA,cAAwB,QAAA;;;;;;;;;;;;;;iBCRJ,kBACpB,QAAQ,wBACR,YAAY,cAAW,QAAA,eAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/features/vitest/modules/console/utils/console.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Suppresses console.log, console.warn, and console.error until resetConsole runs.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* beforeEach(shutConsole);
|
|
8
|
+
* afterEach(resetConsole);
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
declare function shutConsole(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Restores the console methods most recently suppressed by shutConsole.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* shutConsole();
|
|
18
|
+
* // Run code whose console output should be ignored.
|
|
19
|
+
* resetConsole();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function resetConsole(): void;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { shutConsole as n, resetConsole as t };
|
|
25
|
+
//# sourceMappingURL=index-DtGBqDev.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DtGBqDev.d.mts","names":[],"sources":["../src/features/vitest/modules/console/utils/console.ts"],"mappings":";;;;;;;;;;iBAegB;;;;;;;;;;;iBAkBA"}
|
package/dist/index.cjs
ADDED
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { i as TEXT_WITH_NTH, n as TEXT_MATCHER, r as TEXT_PATTERN, t as LABEL_LOCATOR } from "./types-BlSFP07Z.cjs";
|
|
2
|
+
//#region src/shared/regex/utils/pattern-to-regex.d.ts
|
|
3
|
+
export declare function patternToRegex(target: TEXT_PATTERN, flags?: string): RegExp;
|
|
4
|
+
//#endregion
|
|
5
|
+
export type { LABEL_LOCATOR, TEXT_MATCHER, TEXT_PATTERN, TEXT_WITH_NTH };
|
|
6
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/shared/regex/utils/pattern-to-regex.ts"],"mappings":";;wBAGgB,eACd,QAAQ,cACR,iBACC"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { i as TEXT_WITH_NTH, n as TEXT_MATCHER, r as TEXT_PATTERN, t as LABEL_LOCATOR } from "./types-BlSFP07Z.mjs";
|
|
2
|
+
//#region src/shared/regex/utils/pattern-to-regex.d.ts
|
|
3
|
+
export declare function patternToRegex(target: TEXT_PATTERN, flags?: string): RegExp;
|
|
4
|
+
//#endregion
|
|
5
|
+
export type { LABEL_LOCATOR, TEXT_MATCHER, TEXT_PATTERN, TEXT_WITH_NTH };
|
|
6
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/shared/regex/utils/pattern-to-regex.ts"],"mappings":";;wBAGgB,eACd,QAAQ,cACR,iBACC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as patternToRegex } from "./pattern-to-regex-CO5Y0oDU.mjs";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/shared/regex/utils/escape-regex.ts
|
|
2
|
+
function escapeRegExp(str) {
|
|
3
|
+
if (typeof RegExp.escape === "function") return RegExp.escape(str);
|
|
4
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/shared/regex/utils/pattern-to-regex.ts
|
|
8
|
+
function patternToRegex(target, flags = "i") {
|
|
9
|
+
return typeof target === "string" ? new RegExp(escapeRegExp(target), flags) : target;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
Object.defineProperty(exports, "patternToRegex", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function() {
|
|
15
|
+
return patternToRegex;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=pattern-to-regex-BrMJtzu8.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-to-regex-BrMJtzu8.cjs","names":[],"sources":["../src/shared/regex/utils/escape-regex.ts","../src/shared/regex/utils/pattern-to-regex.ts"],"sourcesContent":["export function escapeRegExp(str: string): string {\n if (typeof RegExp.escape === \"function\") {\n return RegExp.escape(str);\n }\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n","import { TEXT_PATTERN } from \"../types\";\nimport { escapeRegExp } from \"./escape-regex\";\n\nexport function patternToRegex(\n target: TEXT_PATTERN,\n flags: string = \"i\",\n): RegExp {\n return typeof target === \"string\"\n ? new RegExp(escapeRegExp(target), flags)\n : target;\n}\n"],"mappings":";AAAA,SAAgB,aAAa,KAAqB;CAChD,IAAI,OAAO,OAAO,WAAW,YAC3B,OAAO,OAAO,OAAO,GAAG;CAE1B,OAAO,IAAI,QAAQ,uBAAuB,MAAM;AAClD;;;ACFA,SAAgB,eACd,QACA,QAAgB,KACR;CACR,OAAO,OAAO,WAAW,WACrB,IAAI,OAAO,aAAa,MAAM,GAAG,KAAK,IACtC;AACN"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/shared/regex/utils/escape-regex.ts
|
|
2
|
+
function escapeRegExp(str) {
|
|
3
|
+
if (typeof RegExp.escape === "function") return RegExp.escape(str);
|
|
4
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/shared/regex/utils/pattern-to-regex.ts
|
|
8
|
+
function patternToRegex(target, flags = "i") {
|
|
9
|
+
return typeof target === "string" ? new RegExp(escapeRegExp(target), flags) : target;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { patternToRegex as t };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=pattern-to-regex-CO5Y0oDU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-to-regex-CO5Y0oDU.mjs","names":[],"sources":["../src/shared/regex/utils/escape-regex.ts","../src/shared/regex/utils/pattern-to-regex.ts"],"sourcesContent":["export function escapeRegExp(str: string): string {\n if (typeof RegExp.escape === \"function\") {\n return RegExp.escape(str);\n }\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n","import { TEXT_PATTERN } from \"../types\";\nimport { escapeRegExp } from \"./escape-regex\";\n\nexport function patternToRegex(\n target: TEXT_PATTERN,\n flags: string = \"i\",\n): RegExp {\n return typeof target === \"string\"\n ? new RegExp(escapeRegExp(target), flags)\n : target;\n}\n"],"mappings":";AAAA,SAAgB,aAAa,KAAqB;CAChD,IAAI,OAAO,OAAO,WAAW,YAC3B,OAAO,OAAO,OAAO,GAAG;CAE1B,OAAO,IAAI,QAAQ,uBAAuB,MAAM;AAClD;;;ACFA,SAAgB,eACd,QACA,QAAgB,KACR;CACR,OAAO,OAAO,WAAW,WACrB,IAAI,OAAO,aAAa,MAAM,GAAG,KAAK,IACtC;AACN"}
|