@ewjdev/anyclick-react 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +199 -63
- package/dist/index.d.mts +799 -222
- package/dist/index.d.ts +799 -222
- package/dist/index.js +2520 -2608
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2410 -2499
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { AnyclickAdapter, AnyclickTriggerEvent, AnyclickType, AnyclickPayload, ScreenshotConfig, ScreenshotData, AnyclickMenuEvent } from '@ewjdev/anyclick-core';
|
|
3
|
-
export { ALL_CURATED_PROPERTIES, AccessibilityInfo, AnyclickAdapter, AnyclickPayload, AnyclickType, BoxModelInfo, CURATED_STYLE_PROPERTIES, ComputedStylesInfo, DEFAULT_SCREENSHOT_CONFIG, DEFAULT_SENSITIVE_SELECTORS, ElementContext, ElementInspectInfo, PageContext, ScreenshotCapture, ScreenshotCaptureMode, ScreenshotConfig, ScreenshotData, captureAllScreenshots, captureScreenshot, estimateTotalSize, formatBoxModel, formatBytes, formatStylesAsCSS, getAccessibilityInfo, getAttributes, getBoxModelInfo, getComputedStyles, getElementInspectInfo, isScreenshotSupported } from '@ewjdev/anyclick-core';
|
|
4
2
|
import * as React$1 from 'react';
|
|
5
3
|
import React__default, { ReactNode, CSSProperties } from 'react';
|
|
4
|
+
import { AnyclickAdapter, AnyclickType, AnyclickPayload, ScreenshotConfig, AnyclickTriggerEvent, ScreenshotData, AnyclickMenuEvent } from '@ewjdev/anyclick-core';
|
|
5
|
+
export { ALL_CURATED_PROPERTIES, AccessibilityInfo, AnyclickAdapter, AnyclickPayload, AnyclickType, BoxModelInfo, CURATED_STYLE_PROPERTIES, ComputedStylesInfo, DEFAULT_SCREENSHOT_CONFIG, DEFAULT_SENSITIVE_SELECTORS, ElementContext, ElementInspectInfo, PageContext, ScreenshotCapture, ScreenshotCaptureMode, ScreenshotConfig, ScreenshotData, captureAllScreenshots, captureScreenshot, estimateTotalSize, formatBoxModel, formatBytes, formatStylesAsCSS, getAccessibilityInfo, getAttributes, getBoxModelInfo, getComputedStyles, getElementInspectInfo, isScreenshotSupported } from '@ewjdev/anyclick-core';
|
|
6
6
|
import * as zustand from 'zustand';
|
|
7
7
|
import * as zustand_middleware from 'zustand/middleware';
|
|
8
8
|
|
|
@@ -172,18 +172,38 @@ interface InspectDialogProps {
|
|
|
172
172
|
declare function InspectDialog({ visible, targetElement, onClose, onSelectElement, ideConfig, style, className, highlightColors, showBoxModelOverlay, initialPinnedPosition, compactConfig, }: InspectDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
175
|
+
* Type definitions for @ewjdev/anyclick-react.
|
|
176
|
+
*
|
|
177
|
+
* Contains all public interfaces, types, and utility functions
|
|
178
|
+
* for configuring anyclick providers, menus, and themes.
|
|
179
|
+
*
|
|
180
|
+
* @module types
|
|
181
|
+
* @since 1.0.0
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Theme configuration for AnyclickProvider.
|
|
186
|
+
*
|
|
187
|
+
* Supports nested theming with inheritance - child providers automatically
|
|
188
|
+
* inherit and can override parent theme settings.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```tsx
|
|
192
|
+
* const theme: AnyclickTheme = {
|
|
193
|
+
* menuStyle: { backgroundColor: "#1a1a1a" },
|
|
194
|
+
* highlightConfig: {
|
|
195
|
+
* colors: { targetColor: "#ef4444" },
|
|
196
|
+
* },
|
|
197
|
+
* };
|
|
198
|
+
*
|
|
199
|
+
* <AnyclickProvider adapter={adapter} theme={theme}>
|
|
200
|
+
* <App />
|
|
201
|
+
* </AnyclickProvider>
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @since 1.0.0
|
|
177
205
|
*/
|
|
178
206
|
interface AnyclickTheme {
|
|
179
|
-
/** Custom styles for the context menu */
|
|
180
|
-
menuStyle?: CSSProperties;
|
|
181
|
-
/** Custom class name for the context menu */
|
|
182
|
-
menuClassName?: string;
|
|
183
|
-
/** Configuration for element highlighting */
|
|
184
|
-
highlightConfig?: HighlightConfig;
|
|
185
|
-
/** Configuration for screenshot capture */
|
|
186
|
-
screenshotConfig?: ScreenshotConfig;
|
|
187
207
|
/** Whether anyclick functionality is disabled in this theme */
|
|
188
208
|
disabled?: boolean;
|
|
189
209
|
/**
|
|
@@ -191,159 +211,282 @@ interface AnyclickTheme {
|
|
|
191
211
|
* When true/configured, a FunModeBridge can hand off the track to the pointer.
|
|
192
212
|
*/
|
|
193
213
|
funMode?: boolean | FunModeThemeConfig;
|
|
214
|
+
/** Configuration for element highlighting */
|
|
215
|
+
highlightConfig?: HighlightConfig;
|
|
216
|
+
/** Custom class name for the context menu */
|
|
217
|
+
menuClassName?: string;
|
|
218
|
+
/** Custom styles for the context menu */
|
|
219
|
+
menuStyle?: CSSProperties;
|
|
220
|
+
/** Configuration for screenshot capture */
|
|
221
|
+
screenshotConfig?: ScreenshotConfig;
|
|
194
222
|
}
|
|
195
223
|
/**
|
|
196
|
-
* Optional fun mode configuration (forwarded to pointer fun mode)
|
|
224
|
+
* Optional fun mode configuration (forwarded to pointer fun mode).
|
|
225
|
+
*
|
|
226
|
+
* @since 1.3.0
|
|
197
227
|
*/
|
|
198
228
|
interface FunModeThemeConfig {
|
|
229
|
+
/** Optional acceleration override */
|
|
230
|
+
acceleration?: number;
|
|
199
231
|
/** Whether fun mode is enabled (default: true) */
|
|
200
232
|
enabled?: boolean;
|
|
201
233
|
/** Optional max speed override for this provider */
|
|
202
234
|
maxSpeed?: number;
|
|
203
|
-
/** Optional acceleration override */
|
|
204
|
-
acceleration?: number;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Menu positioning modes
|
|
208
|
-
* - static: Menu stays at exact click position (may go off-screen)
|
|
209
|
-
* - inView: Menu adjusts position to stay fully visible in viewport
|
|
210
|
-
* - dynamic: User can drag the menu to reposition it
|
|
211
|
-
*/
|
|
212
|
-
type MenuPositionMode = "static" | "inView" | "dynamic";
|
|
213
|
-
/**
|
|
214
|
-
* Configuration for highlight colors
|
|
215
|
-
*/
|
|
216
|
-
interface HighlightColors {
|
|
217
|
-
/** Color for the target element highlight (default: #3b82f6 - blue) */
|
|
218
|
-
targetColor?: string;
|
|
219
|
-
/** Color for the container element highlight (default: #8b5cf6 - purple) */
|
|
220
|
-
containerColor?: string;
|
|
221
|
-
/** Opacity for the target shadow (default: 0.25) */
|
|
222
|
-
targetShadowOpacity?: number;
|
|
223
|
-
/** Opacity for the container shadow (default: 0.1) */
|
|
224
|
-
containerShadowOpacity?: number;
|
|
225
235
|
}
|
|
226
236
|
/**
|
|
227
|
-
*
|
|
237
|
+
* Menu positioning modes for the context menu.
|
|
238
|
+
*
|
|
239
|
+
* - `static` - Menu stays at exact click position (may go off-screen)
|
|
240
|
+
* - `inView` - Menu adjusts position to stay fully visible in viewport
|
|
241
|
+
* - `dynamic` - User can drag the menu to reposition it
|
|
242
|
+
*
|
|
243
|
+
* @since 1.1.0
|
|
228
244
|
*/
|
|
229
|
-
|
|
230
|
-
/** Whether to show highlights (default: true) */
|
|
231
|
-
enabled?: boolean;
|
|
232
|
-
/** Custom colors for highlights */
|
|
233
|
-
colors?: HighlightColors;
|
|
234
|
-
/** CSS selectors to identify container elements */
|
|
235
|
-
containerSelectors?: string[];
|
|
236
|
-
/** Minimum number of children for an element to be considered a container (default: 2) */
|
|
237
|
-
minChildrenForContainer?: number;
|
|
238
|
-
}
|
|
245
|
+
type MenuPositionMode = "dynamic" | "inView" | "static";
|
|
239
246
|
/**
|
|
240
|
-
* Menu item displayed in the Anyclick context menu
|
|
247
|
+
* Menu item displayed in the Anyclick context menu.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```tsx
|
|
251
|
+
* const menuItems: ContextMenuItem[] = [
|
|
252
|
+
* {
|
|
253
|
+
* type: "bug",
|
|
254
|
+
* label: "Report Bug",
|
|
255
|
+
* icon: <BugIcon />,
|
|
256
|
+
* showComment: true,
|
|
257
|
+
* },
|
|
258
|
+
* {
|
|
259
|
+
* type: "feature",
|
|
260
|
+
* label: "Request Feature",
|
|
261
|
+
* showComment: true,
|
|
262
|
+
* requiredRoles: ["admin", "developer"],
|
|
263
|
+
* },
|
|
264
|
+
* ];
|
|
265
|
+
* ```
|
|
266
|
+
*
|
|
267
|
+
* @since 1.0.0
|
|
241
268
|
*/
|
|
242
269
|
interface ContextMenuItem {
|
|
243
|
-
/** Feedback type for this option (use unique identifier for parent items with children) */
|
|
244
|
-
type: AnyclickType;
|
|
245
|
-
/** Display label */
|
|
246
|
-
label: string;
|
|
247
|
-
/** Optional icon */
|
|
248
|
-
icon?: ReactNode;
|
|
249
|
-
/** Whether to show a comment input for this type */
|
|
250
|
-
showComment?: boolean;
|
|
251
|
-
/** Optional status to signal availability (e.g., coming soon) */
|
|
252
|
-
status?: FeedbackMenuStatus;
|
|
253
270
|
/** Optional badge to render next to the label */
|
|
254
271
|
badge?: FeedbackMenuBadge;
|
|
255
|
-
/** Optional role(s) required to see this menu item */
|
|
256
|
-
requiredRoles?: string[];
|
|
257
272
|
/** Child menu items (creates a submenu) */
|
|
258
273
|
children?: ContextMenuItem[];
|
|
274
|
+
/** Optional icon */
|
|
275
|
+
icon?: ReactNode;
|
|
276
|
+
/** Display label */
|
|
277
|
+
label: string;
|
|
259
278
|
/**
|
|
260
279
|
* Optional click handler for custom behavior.
|
|
261
280
|
* Return `false` (or a Promise resolving to false) to skip the default submission flow.
|
|
262
281
|
*/
|
|
263
282
|
onClick?: (context: {
|
|
264
|
-
targetElement: Element | null;
|
|
265
|
-
containerElement: Element | null;
|
|
266
283
|
closeMenu: () => void;
|
|
267
|
-
|
|
284
|
+
containerElement: Element | null;
|
|
285
|
+
targetElement: Element | null;
|
|
286
|
+
}) => boolean | Promise<boolean | void> | void;
|
|
287
|
+
/** Optional role(s) required to see this menu item */
|
|
288
|
+
requiredRoles?: string[];
|
|
289
|
+
/** Whether to show a comment input for this type */
|
|
290
|
+
showComment?: boolean;
|
|
291
|
+
/** Optional status to signal availability (e.g., coming soon) */
|
|
292
|
+
status?: FeedbackMenuStatus;
|
|
293
|
+
/** Feedback type for this option (use unique identifier for parent items with children) */
|
|
294
|
+
type: AnyclickType;
|
|
268
295
|
}
|
|
269
296
|
/**
|
|
270
|
-
* Visual badge for menu items
|
|
297
|
+
* Visual badge for menu items.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```tsx
|
|
301
|
+
* const badge: FeedbackMenuBadge = {
|
|
302
|
+
* label: "New",
|
|
303
|
+
* tone: "success",
|
|
304
|
+
* };
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @since 1.2.0
|
|
271
308
|
*/
|
|
272
309
|
interface FeedbackMenuBadge {
|
|
273
310
|
/** Text shown inside the badge */
|
|
274
311
|
label: string;
|
|
275
312
|
/** Optional tone to drive styling */
|
|
276
|
-
tone?: "
|
|
313
|
+
tone?: "info" | "neutral" | "success" | "warning";
|
|
277
314
|
}
|
|
278
315
|
/**
|
|
279
|
-
* Status of a menu item used for presets
|
|
316
|
+
* Status of a menu item used for presets.
|
|
317
|
+
*
|
|
318
|
+
* - `available` - Item is fully functional
|
|
319
|
+
* - `comingSoon` - Item is visible but disabled
|
|
320
|
+
*
|
|
321
|
+
* @since 1.2.0
|
|
280
322
|
*/
|
|
281
323
|
type FeedbackMenuStatus = "available" | "comingSoon";
|
|
282
324
|
/**
|
|
283
|
-
*
|
|
325
|
+
* Configuration for highlight colors.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```tsx
|
|
329
|
+
* const colors: HighlightColors = {
|
|
330
|
+
* targetColor: "#ef4444", // Red for target
|
|
331
|
+
* containerColor: "#3b82f6", // Blue for container
|
|
332
|
+
* targetShadowOpacity: 0.3,
|
|
333
|
+
* containerShadowOpacity: 0.15,
|
|
334
|
+
* };
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* @since 1.0.0
|
|
338
|
+
*/
|
|
339
|
+
interface HighlightColors {
|
|
340
|
+
/** Color for the container element highlight (default: #8b5cf6 - purple) */
|
|
341
|
+
containerColor?: string;
|
|
342
|
+
/** Opacity for the container shadow (default: 0.1) */
|
|
343
|
+
containerShadowOpacity?: number;
|
|
344
|
+
/** Color for the target element highlight (default: #3b82f6 - blue) */
|
|
345
|
+
targetColor?: string;
|
|
346
|
+
/** Opacity for the target shadow (default: 0.25) */
|
|
347
|
+
targetShadowOpacity?: number;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Configuration for highlight behavior.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```tsx
|
|
354
|
+
* const highlightConfig: HighlightConfig = {
|
|
355
|
+
* enabled: true,
|
|
356
|
+
* colors: { targetColor: "#ef4444" },
|
|
357
|
+
* containerSelectors: [".card", ".modal", "[data-container]"],
|
|
358
|
+
* minChildrenForContainer: 3,
|
|
359
|
+
* };
|
|
360
|
+
* ```
|
|
361
|
+
*
|
|
362
|
+
* @since 1.0.0
|
|
363
|
+
*/
|
|
364
|
+
interface HighlightConfig {
|
|
365
|
+
/** Custom colors for highlights */
|
|
366
|
+
colors?: HighlightColors;
|
|
367
|
+
/** CSS selectors to identify container elements */
|
|
368
|
+
containerSelectors?: string[];
|
|
369
|
+
/** Whether to show highlights (default: true) */
|
|
370
|
+
enabled?: boolean;
|
|
371
|
+
/** Minimum number of children for an element to be considered a container (default: 2) */
|
|
372
|
+
minChildrenForContainer?: number;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* User context for role-based menu filtering.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* ```tsx
|
|
379
|
+
* const userContext: AnyclickUserContext = {
|
|
380
|
+
* id: "user-123",
|
|
381
|
+
* email: "user@example.com",
|
|
382
|
+
* roles: ["admin", "developer"],
|
|
383
|
+
* };
|
|
384
|
+
*
|
|
385
|
+
* const visibleItems = filterMenuItemsByRole(allMenuItems, userContext);
|
|
386
|
+
* ```
|
|
387
|
+
*
|
|
388
|
+
* @since 1.2.0
|
|
284
389
|
*/
|
|
285
390
|
interface AnyclickUserContext {
|
|
286
|
-
/** User's role(s) */
|
|
287
|
-
roles?: string[];
|
|
288
|
-
/** User ID */
|
|
289
|
-
id?: string;
|
|
290
391
|
/** User email */
|
|
291
392
|
email?: string;
|
|
393
|
+
/** User ID */
|
|
394
|
+
id?: string;
|
|
395
|
+
/** User's role(s) */
|
|
396
|
+
roles?: string[];
|
|
292
397
|
}
|
|
293
398
|
/**
|
|
294
|
-
*
|
|
399
|
+
* Filters menu items based on user context and required roles.
|
|
400
|
+
*
|
|
401
|
+
* Items without required roles are shown to everyone.
|
|
402
|
+
* Items with required roles are only shown to users who have at least one matching role.
|
|
403
|
+
*
|
|
404
|
+
* @param items - Menu items to filter
|
|
405
|
+
* @param userContext - Optional user context with roles
|
|
406
|
+
* @returns Filtered menu items visible to the user
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```tsx
|
|
410
|
+
* const allItems: ContextMenuItem[] = [
|
|
411
|
+
* { type: "bug", label: "Report Bug" },
|
|
412
|
+
* { type: "admin", label: "Admin Panel", requiredRoles: ["admin"] },
|
|
413
|
+
* ];
|
|
414
|
+
*
|
|
415
|
+
* const userContext = { roles: ["user"] };
|
|
416
|
+
* const visibleItems = filterMenuItemsByRole(allItems, userContext);
|
|
417
|
+
* // => [{ type: "bug", label: "Report Bug" }]
|
|
418
|
+
* ```
|
|
419
|
+
*
|
|
420
|
+
* @since 1.2.0
|
|
295
421
|
*/
|
|
296
422
|
declare function filterMenuItemsByRole(items: ContextMenuItem[], userContext?: AnyclickUserContext): ContextMenuItem[];
|
|
297
423
|
/**
|
|
298
|
-
* Props for the AnyclickProvider component
|
|
424
|
+
* Props for the AnyclickProvider component.
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```tsx
|
|
428
|
+
* <AnyclickProvider
|
|
429
|
+
* adapter={myAdapter}
|
|
430
|
+
* menuItems={customMenuItems}
|
|
431
|
+
* highlightConfig={{ colors: { targetColor: "#ef4444" } }}
|
|
432
|
+
* screenshotConfig={{ enabled: true, showPreview: true }}
|
|
433
|
+
* onSubmitSuccess={(payload) => console.log("Submitted:", payload)}
|
|
434
|
+
* >
|
|
435
|
+
* <App />
|
|
436
|
+
* </AnyclickProvider>
|
|
437
|
+
* ```
|
|
438
|
+
*
|
|
439
|
+
* @since 1.0.0
|
|
299
440
|
*/
|
|
300
441
|
interface AnyclickProviderProps {
|
|
301
|
-
/** Header content */
|
|
302
|
-
header?: ReactNode | null;
|
|
303
442
|
/** The adapter to use for submitting anyclick */
|
|
304
443
|
adapter: AnyclickAdapter;
|
|
305
444
|
/** Child components */
|
|
306
445
|
children: ReactNode;
|
|
307
|
-
/**
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
|
|
446
|
+
/** Cooldown in milliseconds between submissions (rate limiting) */
|
|
447
|
+
cooldownMs?: number;
|
|
448
|
+
/** Whether the provider is disabled */
|
|
449
|
+
disabled?: boolean;
|
|
450
|
+
/** Header content */
|
|
451
|
+
header?: ReactNode | null;
|
|
452
|
+
/** Configuration for element highlighting */
|
|
453
|
+
highlightConfig?: HighlightConfig;
|
|
454
|
+
/** Maximum number of ancestors to capture */
|
|
455
|
+
maxAncestors?: number;
|
|
315
456
|
/** Maximum length for innerText capture */
|
|
316
457
|
maxInnerTextLength?: number;
|
|
317
458
|
/** Maximum length for outerHTML capture */
|
|
318
459
|
maxOuterHTMLLength?: number;
|
|
319
|
-
/**
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
|
|
460
|
+
/** Custom class name for the context menu */
|
|
461
|
+
menuClassName?: string;
|
|
462
|
+
/** Custom menu items (defaults to Issue, Feature, Like) */
|
|
463
|
+
menuItems?: ContextMenuItem[];
|
|
464
|
+
/** Menu positioning mode (default: 'inView') */
|
|
465
|
+
menuPositionMode?: MenuPositionMode;
|
|
466
|
+
/** Custom styles for the context menu */
|
|
467
|
+
menuStyle?: CSSProperties;
|
|
325
468
|
/** Additional metadata to include with every submission */
|
|
326
469
|
metadata?: Record<string, unknown>;
|
|
327
|
-
/** Callback after successful submission */
|
|
328
|
-
onSubmitSuccess?: (payload: AnyclickPayload) => void;
|
|
329
470
|
/** Callback after failed submission */
|
|
330
471
|
onSubmitError?: (error: Error, payload: AnyclickPayload) => void;
|
|
331
|
-
/**
|
|
332
|
-
|
|
333
|
-
/** Custom class name for the context menu */
|
|
334
|
-
menuClassName?: string;
|
|
335
|
-
/** Whether the provider is disabled */
|
|
336
|
-
disabled?: boolean;
|
|
337
|
-
/** Configuration for element highlighting */
|
|
338
|
-
highlightConfig?: HighlightConfig;
|
|
339
|
-
/** Configuration for screenshot capture */
|
|
340
|
-
screenshotConfig?: ScreenshotConfig;
|
|
472
|
+
/** Callback after successful submission */
|
|
473
|
+
onSubmitSuccess?: (payload: AnyclickPayload) => void;
|
|
341
474
|
/**
|
|
342
475
|
* Whether to scope this provider to its children only.
|
|
343
476
|
* When true, events will only be captured for elements within this provider's subtree.
|
|
344
477
|
* When false (default), events are captured for the entire document.
|
|
345
478
|
*/
|
|
346
479
|
scoped?: boolean;
|
|
480
|
+
/** Configuration for screenshot capture */
|
|
481
|
+
screenshotConfig?: ScreenshotConfig;
|
|
482
|
+
/** Attributes to strip from outerHTML for privacy */
|
|
483
|
+
stripAttributes?: string[];
|
|
484
|
+
/**
|
|
485
|
+
* Filter function to determine if anyclick should be captured for a target element.
|
|
486
|
+
* Return true to allow anyclick, false to ignore.
|
|
487
|
+
* Accepts both MouseEvent (right-click) and TouchEvent (press-and-hold).
|
|
488
|
+
*/
|
|
489
|
+
targetFilter?: (event: AnyclickTriggerEvent, target: Element) => boolean;
|
|
347
490
|
/**
|
|
348
491
|
* Theme configuration for this provider.
|
|
349
492
|
* Themes are inherited from parent providers and merged (child overrides parent).
|
|
@@ -354,96 +497,135 @@ interface AnyclickProviderProps {
|
|
|
354
497
|
touchHoldDurationMs?: number;
|
|
355
498
|
/** Maximum movement in px before touch hold is cancelled (default: 10) */
|
|
356
499
|
touchMoveThreshold?: number;
|
|
357
|
-
/** Menu positioning mode (default: 'inView') */
|
|
358
|
-
menuPositionMode?: MenuPositionMode;
|
|
359
500
|
}
|
|
360
501
|
/**
|
|
361
|
-
* Context value exposed by AnyclickProvider
|
|
502
|
+
* Context value exposed by AnyclickProvider.
|
|
503
|
+
*
|
|
504
|
+
* Access via the {@link useAnyclick} hook.
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```tsx
|
|
508
|
+
* function MyComponent() {
|
|
509
|
+
* const {
|
|
510
|
+
* isEnabled,
|
|
511
|
+
* isSubmitting,
|
|
512
|
+
* openMenu,
|
|
513
|
+
* closeMenu,
|
|
514
|
+
* submitAnyclick,
|
|
515
|
+
* theme,
|
|
516
|
+
* } = useAnyclick();
|
|
517
|
+
*
|
|
518
|
+
* // ...
|
|
519
|
+
* }
|
|
520
|
+
* ```
|
|
521
|
+
*
|
|
522
|
+
* @since 1.0.0
|
|
362
523
|
*/
|
|
363
524
|
interface AnyclickContextValue {
|
|
525
|
+
/** Close the anyclick menu */
|
|
526
|
+
closeMenu: () => void;
|
|
364
527
|
/** Whether anyclick is currently enabled */
|
|
365
528
|
isEnabled: boolean;
|
|
366
529
|
/** Whether a submission is in progress */
|
|
367
530
|
isSubmitting: boolean;
|
|
368
|
-
/** Submit anyclick for a specific element */
|
|
369
|
-
submitAnyclick: (element: Element, type: AnyclickType, comment?: string) => Promise<void>;
|
|
370
531
|
/** Open the anyclick menu programmatically */
|
|
371
532
|
openMenu: (element: Element, position: {
|
|
372
533
|
x: number;
|
|
373
534
|
y: number;
|
|
374
535
|
}) => void;
|
|
375
|
-
/** Close the anyclick menu */
|
|
376
|
-
closeMenu: () => void;
|
|
377
|
-
/** The current merged theme (inherited from ancestors) */
|
|
378
|
-
theme: AnyclickTheme;
|
|
379
|
-
/** Whether this provider is scoped */
|
|
380
|
-
scoped: boolean;
|
|
381
536
|
/** The provider's unique ID */
|
|
382
537
|
providerId: string;
|
|
538
|
+
/** Whether this provider is scoped */
|
|
539
|
+
scoped: boolean;
|
|
540
|
+
/** Submit anyclick for a specific element */
|
|
541
|
+
submitAnyclick: (element: Element, type: AnyclickType, comment?: string) => Promise<void>;
|
|
542
|
+
/** The current merged theme (inherited from ancestors) */
|
|
543
|
+
theme: AnyclickTheme;
|
|
383
544
|
}
|
|
384
545
|
/**
|
|
385
|
-
* Props for the
|
|
546
|
+
* Props for the ContextMenu component.
|
|
547
|
+
*
|
|
548
|
+
* @since 1.0.0
|
|
386
549
|
*/
|
|
387
550
|
interface ContextMenuProps {
|
|
388
|
-
/**
|
|
389
|
-
|
|
390
|
-
/** Position of the menu */
|
|
391
|
-
position: {
|
|
392
|
-
x: number;
|
|
393
|
-
y: number;
|
|
394
|
-
};
|
|
395
|
-
/** Target element for anyclick */
|
|
396
|
-
targetElement: Element | null;
|
|
551
|
+
/** Custom class name */
|
|
552
|
+
className?: string;
|
|
397
553
|
/** Container element found by highlight logic */
|
|
398
554
|
containerElement: Element | null;
|
|
399
|
-
/**
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
|
|
403
|
-
/** Callback when menu is closed */
|
|
404
|
-
onClose: () => void;
|
|
405
|
-
/** Whether submission is in progress */
|
|
406
|
-
isSubmitting: boolean;
|
|
407
|
-
/** Custom styles */
|
|
408
|
-
style?: CSSProperties;
|
|
409
|
-
/** Custom class name */
|
|
410
|
-
className?: string;
|
|
555
|
+
/** Footer content */
|
|
556
|
+
footer?: ReactNode;
|
|
557
|
+
/** Header content */
|
|
558
|
+
header?: ReactNode;
|
|
411
559
|
/** Configuration for element highlighting */
|
|
412
560
|
highlightConfig?: HighlightConfig;
|
|
413
|
-
/**
|
|
414
|
-
|
|
561
|
+
/** Whether submission is in progress */
|
|
562
|
+
isSubmitting: boolean;
|
|
563
|
+
/** Menu items to display */
|
|
564
|
+
items: ContextMenuItem[];
|
|
565
|
+
/** Callback when menu is closed */
|
|
566
|
+
onClose: () => void;
|
|
567
|
+
/** Callback when an item is selected */
|
|
568
|
+
onSelect: (type: AnyclickType, comment?: string, screenshots?: ScreenshotData) => void;
|
|
569
|
+
/** Position of the menu */
|
|
570
|
+
position: {
|
|
571
|
+
x: number;
|
|
572
|
+
y: number;
|
|
573
|
+
};
|
|
415
574
|
/** Menu positioning mode (default: 'inView') */
|
|
416
575
|
positionMode?: MenuPositionMode;
|
|
417
|
-
/**
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
|
|
576
|
+
/** Configuration for screenshot capture */
|
|
577
|
+
screenshotConfig?: ScreenshotConfig;
|
|
578
|
+
/** Custom styles */
|
|
579
|
+
style?: CSSProperties;
|
|
580
|
+
/** Target element for anyclick */
|
|
581
|
+
targetElement: Element | null;
|
|
582
|
+
/** Whether the menu is visible */
|
|
583
|
+
visible: boolean;
|
|
421
584
|
}
|
|
422
585
|
/**
|
|
423
|
-
* Props for the
|
|
586
|
+
* Props for the ScreenshotPreview component.
|
|
587
|
+
*
|
|
588
|
+
* @since 1.0.0
|
|
424
589
|
*/
|
|
425
590
|
interface ScreenshotPreviewProps {
|
|
426
|
-
/** Captured screenshot data */
|
|
427
|
-
screenshots: ScreenshotData | null;
|
|
428
591
|
/** Whether screenshots are loading */
|
|
429
592
|
isLoading: boolean;
|
|
430
|
-
/**
|
|
431
|
-
|
|
593
|
+
/** Whether submission is in progress */
|
|
594
|
+
isSubmitting: boolean;
|
|
432
595
|
/** Callback when user cancels */
|
|
433
596
|
onCancel: () => void;
|
|
597
|
+
/** Callback when user confirms screenshots */
|
|
598
|
+
onConfirm: (screenshots: ScreenshotData) => void;
|
|
434
599
|
/** Callback when user wants to retake screenshots */
|
|
435
600
|
onRetake: () => void;
|
|
436
|
-
/**
|
|
437
|
-
|
|
601
|
+
/** Captured screenshot data */
|
|
602
|
+
screenshots: ScreenshotData | null;
|
|
438
603
|
}
|
|
439
604
|
|
|
440
605
|
/**
|
|
441
|
-
* AnyclickProvider component - wraps your app to enable feedback capture
|
|
442
|
-
*
|
|
606
|
+
* AnyclickProvider component - wraps your app to enable feedback capture.
|
|
607
|
+
*
|
|
608
|
+
* Supports scoped providers and nested theming with inheritance.
|
|
609
|
+
* Child providers automatically inherit and can override parent themes.
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```tsx
|
|
613
|
+
* <AnyclickProvider
|
|
614
|
+
* adapter={myAdapter}
|
|
615
|
+
* menuItems={[
|
|
616
|
+
* { type: "bug", label: "Report Bug", showComment: true },
|
|
617
|
+
* ]}
|
|
618
|
+
* onSubmitSuccess={(payload) => console.log("Submitted:", payload)}
|
|
619
|
+
* >
|
|
620
|
+
* <App />
|
|
621
|
+
* </AnyclickProvider>
|
|
622
|
+
* ```
|
|
623
|
+
*
|
|
624
|
+
* @since 1.0.0
|
|
443
625
|
*/
|
|
444
|
-
declare function AnyclickProvider({ adapter, children,
|
|
626
|
+
declare function AnyclickProvider({ adapter, children, cooldownMs, disabled, header, highlightConfig, maxAncestors, maxInnerTextLength, maxOuterHTMLLength, menuClassName, menuItems, menuStyle, metadata, onSubmitError, onSubmitSuccess, scoped, screenshotConfig, stripAttributes, targetFilter, theme, touchHoldDurationMs, touchMoveThreshold, }: AnyclickProviderProps): react_jsx_runtime.JSX.Element;
|
|
445
627
|
/**
|
|
446
|
-
* @deprecated Use AnyclickProvider instead
|
|
628
|
+
* @deprecated Use {@link AnyclickProvider} instead. Will be removed in v2.0.0.
|
|
447
629
|
*/
|
|
448
630
|
declare const FeedbackProvider: typeof AnyclickProvider;
|
|
449
631
|
|
|
@@ -455,146 +637,404 @@ declare const FeedbackProvider: typeof AnyclickProvider;
|
|
|
455
637
|
declare function FunModeBridge(): null;
|
|
456
638
|
|
|
457
639
|
/**
|
|
458
|
-
* Context menu component for selecting feedback type
|
|
640
|
+
* Context menu component for selecting feedback type.
|
|
641
|
+
*
|
|
642
|
+
* Displays a customizable context menu with support for:
|
|
643
|
+
* - Custom menu items with icons and badges
|
|
644
|
+
* - Submenus for organizing options
|
|
645
|
+
* - Comment input for detailed feedback
|
|
646
|
+
* - Screenshot preview before sending
|
|
647
|
+
* - Touch-friendly interactions
|
|
648
|
+
* - Dynamic positioning modes
|
|
649
|
+
*
|
|
650
|
+
* @since 1.0.0
|
|
459
651
|
*/
|
|
460
|
-
declare function ContextMenu({
|
|
652
|
+
declare function ContextMenu({ className, containerElement, footer, header, highlightConfig, isSubmitting, items, onClose, onSelect, position, positionMode, screenshotConfig, style, targetElement, visible, }: ContextMenuProps): react_jsx_runtime.JSX.Element | null;
|
|
461
653
|
|
|
462
654
|
/**
|
|
463
|
-
* Screenshot preview component - shows captured screenshots before sending
|
|
655
|
+
* Screenshot preview component - shows captured screenshots before sending.
|
|
656
|
+
*
|
|
657
|
+
* Displays a preview of captured screenshots with tabs for element, container,
|
|
658
|
+
* and viewport captures. Allows users to review, retake, or proceed without
|
|
659
|
+
* screenshots.
|
|
660
|
+
*
|
|
661
|
+
* @since 1.0.0
|
|
464
662
|
*/
|
|
465
|
-
declare
|
|
663
|
+
declare const ScreenshotPreview: React__default.NamedExoticComponent<ScreenshotPreviewProps>;
|
|
466
664
|
|
|
467
665
|
/**
|
|
468
|
-
* React context for anyclick functionality
|
|
666
|
+
* React context for anyclick functionality.
|
|
667
|
+
*
|
|
668
|
+
* Provides access to anyclick state and methods throughout the component tree.
|
|
669
|
+
* Use the {@link useAnyclick} hook for type-safe access.
|
|
670
|
+
*
|
|
671
|
+
* @example
|
|
672
|
+
* ```tsx
|
|
673
|
+
* // Using the context directly (advanced)
|
|
674
|
+
* const context = useContext(AnyclickContext);
|
|
675
|
+
* if (context) {
|
|
676
|
+
* context.openMenu(element, { x: 100, y: 100 });
|
|
677
|
+
* }
|
|
678
|
+
* ```
|
|
679
|
+
*
|
|
680
|
+
* @see {@link useAnyclick} for the recommended way to access this context
|
|
681
|
+
* @since 1.0.0
|
|
469
682
|
*/
|
|
470
683
|
declare const AnyclickContext: React$1.Context<AnyclickContextValue | null>;
|
|
471
684
|
/**
|
|
472
|
-
* @deprecated Use AnyclickContext instead
|
|
685
|
+
* @deprecated Use {@link AnyclickContext} instead. Will be removed in v2.0.0.
|
|
686
|
+
* @see {@link AnyclickContext}
|
|
473
687
|
*/
|
|
474
688
|
declare const FeedbackContext: React$1.Context<AnyclickContextValue | null>;
|
|
475
689
|
/**
|
|
476
|
-
* Hook to access anyclick context
|
|
477
|
-
*
|
|
690
|
+
* Hook to access anyclick context values and methods.
|
|
691
|
+
*
|
|
692
|
+
* Provides access to:
|
|
693
|
+
* - `isEnabled` - Whether anyclick is currently enabled
|
|
694
|
+
* - `isSubmitting` - Whether a submission is in progress
|
|
695
|
+
* - `submitAnyclick` - Function to submit feedback programmatically
|
|
696
|
+
* - `openMenu` - Function to open the context menu programmatically
|
|
697
|
+
* - `closeMenu` - Function to close the context menu
|
|
698
|
+
* - `theme` - The current merged theme configuration
|
|
699
|
+
* - `scoped` - Whether the current provider is scoped
|
|
700
|
+
* - `providerId` - The unique ID of the current provider
|
|
701
|
+
*
|
|
702
|
+
* @returns {AnyclickContextValue} The anyclick context value
|
|
703
|
+
* @throws {Error} When used outside of an AnyclickProvider
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```tsx
|
|
707
|
+
* function FeedbackButton() {
|
|
708
|
+
* const { openMenu, isSubmitting, isEnabled } = useAnyclick();
|
|
709
|
+
*
|
|
710
|
+
* const handleClick = (event: React.MouseEvent) => {
|
|
711
|
+
* if (isEnabled && !isSubmitting) {
|
|
712
|
+
* openMenu(event.currentTarget, {
|
|
713
|
+
* x: event.clientX,
|
|
714
|
+
* y: event.clientY,
|
|
715
|
+
* });
|
|
716
|
+
* }
|
|
717
|
+
* };
|
|
718
|
+
*
|
|
719
|
+
* return (
|
|
720
|
+
* <button onClick={handleClick} disabled={!isEnabled || isSubmitting}>
|
|
721
|
+
* Send Feedback
|
|
722
|
+
* </button>
|
|
723
|
+
* );
|
|
724
|
+
* }
|
|
725
|
+
* ```
|
|
726
|
+
*
|
|
727
|
+
* @since 1.0.0
|
|
478
728
|
*/
|
|
479
729
|
declare function useAnyclick(): AnyclickContextValue;
|
|
480
730
|
/**
|
|
481
|
-
* @deprecated Use useAnyclick instead
|
|
731
|
+
* @deprecated Use {@link useAnyclick} instead. Will be removed in v2.0.0.
|
|
732
|
+
* @see {@link useAnyclick}
|
|
482
733
|
*/
|
|
483
734
|
declare function useFeedback(): AnyclickContextValue;
|
|
484
735
|
|
|
485
736
|
/**
|
|
486
|
-
* Registered provider instance
|
|
737
|
+
* Registered provider instance in the provider registry.
|
|
738
|
+
*
|
|
739
|
+
* Each AnyclickProvider creates an instance of this type when mounted,
|
|
740
|
+
* enabling the store to track and manage provider hierarchies.
|
|
741
|
+
*
|
|
742
|
+
* @since 1.0.0
|
|
487
743
|
*/
|
|
488
744
|
interface ProviderInstance {
|
|
489
|
-
/** Unique identifier for this provider instance */
|
|
490
|
-
id: string;
|
|
491
745
|
/** Reference to the provider's container element (null if not scoped) */
|
|
492
746
|
containerRef: React.RefObject<Element | null>;
|
|
493
|
-
/** Whether this provider is scoped to its container */
|
|
494
|
-
scoped: boolean;
|
|
495
|
-
/** The provider's theme configuration */
|
|
496
|
-
theme: AnyclickTheme | null;
|
|
497
|
-
/** Whether this provider is disabled */
|
|
498
|
-
disabled: boolean;
|
|
499
|
-
/** Parent provider ID (if nested) */
|
|
500
|
-
parentId: string | null;
|
|
501
747
|
/** Depth in the provider hierarchy (0 = root) */
|
|
502
748
|
depth: number;
|
|
749
|
+
/** Whether this provider is disabled */
|
|
750
|
+
disabled: boolean;
|
|
751
|
+
/** Unique identifier for this provider instance */
|
|
752
|
+
id: string;
|
|
503
753
|
/** Handler to call when an event occurs in this provider's scope */
|
|
504
754
|
onContextMenu?: (event: AnyclickMenuEvent, element: Element) => boolean | void;
|
|
755
|
+
/** Parent provider ID (if nested) */
|
|
756
|
+
parentId: string | null;
|
|
757
|
+
/** Whether this provider is scoped to its container */
|
|
758
|
+
scoped: boolean;
|
|
759
|
+
/** The provider's theme configuration */
|
|
760
|
+
theme: AnyclickTheme | null;
|
|
505
761
|
}
|
|
506
762
|
/**
|
|
507
|
-
* Provider registry store state
|
|
763
|
+
* Provider registry store state and actions.
|
|
764
|
+
* @internal
|
|
508
765
|
*/
|
|
509
766
|
interface ProviderStore {
|
|
510
767
|
/** Map of provider ID to provider instance */
|
|
511
768
|
providers: Map<string, ProviderInstance>;
|
|
512
769
|
/**
|
|
513
|
-
*
|
|
770
|
+
* Finds all providers that contain a given element, sorted by depth (nearest first).
|
|
771
|
+
* @param element - The DOM element to find providers for
|
|
772
|
+
* @returns Array of matching providers, sorted by depth (deepest first)
|
|
514
773
|
*/
|
|
515
|
-
|
|
774
|
+
findProvidersForElement: (element: Element) => ProviderInstance[];
|
|
516
775
|
/**
|
|
517
|
-
*
|
|
776
|
+
* Finds the nearest parent provider for a given container.
|
|
777
|
+
* @param container - The container element to find a parent for
|
|
778
|
+
* @param excludeId - Optional provider ID to exclude from search
|
|
779
|
+
* @returns The nearest parent provider, or null if none found
|
|
518
780
|
*/
|
|
519
|
-
|
|
781
|
+
findParentProvider: (container: Element | null, excludeId?: string) => ProviderInstance | null;
|
|
520
782
|
/**
|
|
521
|
-
*
|
|
783
|
+
* Gets the merged theme for a provider (includes inherited parent themes).
|
|
784
|
+
* @param providerId - The ID of the provider to get the merged theme for
|
|
785
|
+
* @returns The merged theme configuration
|
|
522
786
|
*/
|
|
523
|
-
|
|
787
|
+
getMergedTheme: (providerId: string) => AnyclickTheme;
|
|
524
788
|
/**
|
|
525
|
-
*
|
|
789
|
+
* Checks if any ancestor provider has disabled anyclick.
|
|
790
|
+
* @param providerId - The ID of the provider to check
|
|
791
|
+
* @returns True if any ancestor is disabled
|
|
526
792
|
*/
|
|
527
|
-
|
|
793
|
+
isDisabledByAncestor: (providerId: string) => boolean;
|
|
528
794
|
/**
|
|
529
|
-
*
|
|
795
|
+
* Checks if an element is inside any scoped provider's container.
|
|
796
|
+
* Used to prevent the global provider from handling touch events.
|
|
797
|
+
* @param element - The element to check
|
|
798
|
+
* @returns True if element is inside any scoped provider
|
|
530
799
|
*/
|
|
531
|
-
|
|
800
|
+
isElementInAnyScopedProvider: (element: Element) => boolean;
|
|
532
801
|
/**
|
|
533
|
-
*
|
|
802
|
+
* Checks if an element is inside a disabled scoped provider's container.
|
|
803
|
+
* @param element - The element to check
|
|
804
|
+
* @returns True if element is inside a disabled scope
|
|
534
805
|
*/
|
|
535
|
-
|
|
806
|
+
isElementInDisabledScope: (element: Element) => boolean;
|
|
536
807
|
/**
|
|
537
|
-
*
|
|
808
|
+
* Registers a new provider in the store.
|
|
809
|
+
* @param provider - The provider instance to register
|
|
538
810
|
*/
|
|
539
|
-
|
|
811
|
+
registerProvider: (provider: ProviderInstance) => void;
|
|
540
812
|
/**
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
* in areas where a disabled scoped provider should block them
|
|
813
|
+
* Unregisters a provider from the store.
|
|
814
|
+
* @param id - The ID of the provider to unregister
|
|
544
815
|
*/
|
|
545
|
-
|
|
816
|
+
unregisterProvider: (id: string) => void;
|
|
546
817
|
/**
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
818
|
+
* Updates a provider's configuration.
|
|
819
|
+
* @param id - The ID of the provider to update
|
|
820
|
+
* @param updates - Partial updates to apply
|
|
550
821
|
*/
|
|
551
|
-
|
|
822
|
+
updateProvider: (id: string, updates: Partial<ProviderInstance>) => void;
|
|
552
823
|
}
|
|
824
|
+
/**
|
|
825
|
+
* Generates a unique ID for a provider instance.
|
|
826
|
+
*
|
|
827
|
+
* @returns A unique provider ID string
|
|
828
|
+
*
|
|
829
|
+
* @example
|
|
830
|
+
* ```ts
|
|
831
|
+
* const id = generateProviderId();
|
|
832
|
+
* // => "anyclick-provider-1"
|
|
833
|
+
* ```
|
|
834
|
+
*
|
|
835
|
+
* @since 1.0.0
|
|
836
|
+
*/
|
|
553
837
|
declare function generateProviderId(): string;
|
|
554
838
|
/**
|
|
555
|
-
* Zustand store for managing provider instances
|
|
839
|
+
* Zustand store hook for managing provider instances.
|
|
840
|
+
*
|
|
841
|
+
* This store maintains a global registry of all AnyclickProvider instances,
|
|
842
|
+
* enabling features like:
|
|
843
|
+
* - Nested provider hierarchies
|
|
844
|
+
* - Theme inheritance
|
|
845
|
+
* - Scoped contexts
|
|
846
|
+
* - Event routing
|
|
847
|
+
*
|
|
848
|
+
* @example
|
|
849
|
+
* ```ts
|
|
850
|
+
* // Get providers for an element
|
|
851
|
+
* const providers = useProviderStore.getState().findProvidersForElement(element);
|
|
852
|
+
*
|
|
853
|
+
* // Get merged theme for a provider
|
|
854
|
+
* const { getMergedTheme } = useProviderStore();
|
|
855
|
+
* const theme = getMergedTheme(providerId);
|
|
856
|
+
* ```
|
|
857
|
+
*
|
|
858
|
+
* @since 1.0.0
|
|
556
859
|
*/
|
|
557
860
|
declare const useProviderStore: zustand.UseBoundStore<zustand.StoreApi<ProviderStore>>;
|
|
558
861
|
/**
|
|
559
|
-
*
|
|
862
|
+
* Dispatches a context menu event to all matching providers.
|
|
863
|
+
*
|
|
864
|
+
* Routes the event through the provider hierarchy, calling handlers
|
|
865
|
+
* from the nearest (deepest) provider first.
|
|
866
|
+
*
|
|
867
|
+
* @param event - The original mouse event
|
|
868
|
+
* @param element - The target element
|
|
869
|
+
*
|
|
870
|
+
* @example
|
|
871
|
+
* ```ts
|
|
872
|
+
* document.addEventListener("contextmenu", (event) => {
|
|
873
|
+
* dispatchContextMenuEvent(event, event.target as Element);
|
|
874
|
+
* });
|
|
875
|
+
* ```
|
|
876
|
+
*
|
|
877
|
+
* @since 1.0.0
|
|
560
878
|
*/
|
|
561
879
|
declare function dispatchContextMenuEvent(event: MouseEvent, element: Element): void;
|
|
562
880
|
|
|
563
|
-
|
|
881
|
+
/**
|
|
882
|
+
* Available preset role identifiers.
|
|
883
|
+
*
|
|
884
|
+
* - `qa` - QA/Testing focused menu with bug reporting and repro steps
|
|
885
|
+
* - `pm` - Product Manager focused menu with feature ideas and impact sizing
|
|
886
|
+
* - `designer` - Designer focused menu with visual QA and accessibility
|
|
887
|
+
* - `developer` - Developer focused menu with diagnostics and debugging
|
|
888
|
+
* - `chrome` - Chrome-like context menu with browser actions
|
|
889
|
+
*
|
|
890
|
+
* @since 1.2.0
|
|
891
|
+
*/
|
|
892
|
+
type PresetRole = "chrome" | "designer" | "developer" | "pm" | "qa";
|
|
893
|
+
/**
|
|
894
|
+
* Complete preset configuration for a role.
|
|
895
|
+
*
|
|
896
|
+
* Contains all the settings needed to configure an AnyclickProvider
|
|
897
|
+
* for a specific user role.
|
|
898
|
+
*
|
|
899
|
+
* @since 1.2.0
|
|
900
|
+
*/
|
|
564
901
|
interface PresetConfig {
|
|
565
|
-
|
|
566
|
-
label: string;
|
|
902
|
+
/** Human-readable description of the preset */
|
|
567
903
|
description: string;
|
|
904
|
+
/** Optional highlight configuration */
|
|
905
|
+
highlightConfig?: HighlightConfig;
|
|
906
|
+
/** Human-readable label for the preset */
|
|
907
|
+
label: string;
|
|
908
|
+
/** Context menu items for this preset */
|
|
568
909
|
menuItems: ContextMenuItem[];
|
|
569
|
-
|
|
910
|
+
/** Additional metadata to include with submissions */
|
|
570
911
|
metadata?: Record<string, unknown>;
|
|
912
|
+
/** The preset role identifier */
|
|
913
|
+
role: PresetRole;
|
|
914
|
+
/** Screenshot capture configuration */
|
|
915
|
+
screenshotConfig?: Partial<ScreenshotConfig>;
|
|
916
|
+
/** Theme configuration including styles and highlighting */
|
|
571
917
|
theme?: AnyclickTheme;
|
|
572
|
-
highlightConfig?: HighlightConfig;
|
|
573
918
|
}
|
|
919
|
+
/**
|
|
920
|
+
* Options for customizing preset menu creation.
|
|
921
|
+
*
|
|
922
|
+
* @since 1.2.0
|
|
923
|
+
*/
|
|
574
924
|
interface CreatePresetMenuOptions {
|
|
575
|
-
/**
|
|
925
|
+
/**
|
|
926
|
+
* Whether to include coming-soon items in the menu.
|
|
927
|
+
* Coming-soon items are shown but disabled.
|
|
928
|
+
* @default true
|
|
929
|
+
*/
|
|
576
930
|
includeComingSoon?: boolean;
|
|
577
931
|
/**
|
|
578
932
|
* Optional overrides for menu items, screenshot config, metadata, or theme.
|
|
579
933
|
* Useful when you want to tweak a preset without rebuilding it manually.
|
|
934
|
+
*
|
|
935
|
+
* @example
|
|
936
|
+
* ```ts
|
|
937
|
+
* const qaPreset = createPresetMenu("qa", {
|
|
938
|
+
* overrides: {
|
|
939
|
+
* screenshotConfig: { quality: 0.9 },
|
|
940
|
+
* theme: { highlightConfig: { colors: { targetColor: "#ef4444" } } },
|
|
941
|
+
* },
|
|
942
|
+
* });
|
|
943
|
+
* ```
|
|
580
944
|
*/
|
|
581
|
-
overrides?: Partial<Omit<PresetConfig, "
|
|
945
|
+
overrides?: Partial<Omit<PresetConfig, "description" | "label" | "role">>;
|
|
582
946
|
}
|
|
947
|
+
/**
|
|
948
|
+
* Default preset configurations for each role.
|
|
949
|
+
*
|
|
950
|
+
* These are the base configurations that {@link createPresetMenu} uses.
|
|
951
|
+
* You can use them directly if you don't need any customization.
|
|
952
|
+
*
|
|
953
|
+
* @since 1.2.0
|
|
954
|
+
*/
|
|
583
955
|
declare const presetDefaults: Record<PresetRole, PresetConfig>;
|
|
584
956
|
/**
|
|
585
|
-
*
|
|
957
|
+
* Creates a preset menu configuration for a specific role.
|
|
958
|
+
*
|
|
959
|
+
* Returns a complete configuration that can be spread into AnyclickProvider props.
|
|
960
|
+
* Coming-soon items are included by default but shown as disabled.
|
|
961
|
+
*
|
|
962
|
+
* @param role - The preset role to create a menu for
|
|
963
|
+
* @param options - Optional customization options
|
|
964
|
+
* @returns A complete preset configuration
|
|
965
|
+
* @throws {Error} If an unknown role is specified
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```tsx
|
|
969
|
+
* // Basic usage
|
|
970
|
+
* const qaPreset = createPresetMenu("qa");
|
|
971
|
+
*
|
|
972
|
+
* // With customization
|
|
973
|
+
* const devPreset = createPresetMenu("developer", {
|
|
974
|
+
* includeComingSoon: false,
|
|
975
|
+
* overrides: {
|
|
976
|
+
* screenshotConfig: { quality: 0.9 },
|
|
977
|
+
* },
|
|
978
|
+
* });
|
|
979
|
+
*
|
|
980
|
+
* <AnyclickProvider
|
|
981
|
+
* adapter={adapter}
|
|
982
|
+
* menuItems={qaPreset.menuItems}
|
|
983
|
+
* screenshotConfig={qaPreset.screenshotConfig}
|
|
984
|
+
* theme={qaPreset.theme}
|
|
985
|
+
* >
|
|
986
|
+
* <App />
|
|
987
|
+
* </AnyclickProvider>
|
|
988
|
+
* ```
|
|
989
|
+
*
|
|
990
|
+
* @since 1.2.0
|
|
586
991
|
*/
|
|
587
992
|
declare function createPresetMenu(role: PresetRole, options?: CreatePresetMenuOptions): PresetConfig;
|
|
588
993
|
/**
|
|
589
|
-
*
|
|
994
|
+
* Lists all available preset configurations.
|
|
995
|
+
*
|
|
996
|
+
* Returns cloned copies of all presets so they can be safely modified.
|
|
997
|
+
* Useful for displaying available options or building custom preset selectors.
|
|
998
|
+
*
|
|
999
|
+
* @returns Array of all preset configurations
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```tsx
|
|
1003
|
+
* const presets = listPresets();
|
|
1004
|
+
*
|
|
1005
|
+
* function PresetSelector({ onSelect }) {
|
|
1006
|
+
* return (
|
|
1007
|
+
* <select onChange={(e) => onSelect(e.target.value)}>
|
|
1008
|
+
* {presets.map((preset) => (
|
|
1009
|
+
* <option key={preset.role} value={preset.role}>
|
|
1010
|
+
* {preset.label} - {preset.description}
|
|
1011
|
+
* </option>
|
|
1012
|
+
* ))}
|
|
1013
|
+
* </select>
|
|
1014
|
+
* );
|
|
1015
|
+
* }
|
|
1016
|
+
* ```
|
|
1017
|
+
*
|
|
1018
|
+
* @since 1.2.0
|
|
590
1019
|
*/
|
|
591
1020
|
declare function listPresets(): PresetConfig[];
|
|
592
1021
|
|
|
1022
|
+
/**
|
|
1023
|
+
* Style definitions for anyclick-react components.
|
|
1024
|
+
*
|
|
1025
|
+
* This module provides consolidated styling for all UI components,
|
|
1026
|
+
* including CSS custom properties for theming and dark mode support.
|
|
1027
|
+
*
|
|
1028
|
+
* @module styles
|
|
1029
|
+
* @since 1.0.0
|
|
1030
|
+
*/
|
|
1031
|
+
|
|
593
1032
|
/**
|
|
594
1033
|
* CSS custom properties for menu theming.
|
|
1034
|
+
*
|
|
595
1035
|
* These can be overridden via the `style` prop on AnyclickProvider.
|
|
596
1036
|
*
|
|
597
|
-
*
|
|
1037
|
+
* @example
|
|
598
1038
|
* ```tsx
|
|
599
1039
|
* <AnyclickProvider
|
|
600
1040
|
* theme={{
|
|
@@ -608,57 +1048,194 @@ declare function listPresets(): PresetConfig[];
|
|
|
608
1048
|
* }}
|
|
609
1049
|
* />
|
|
610
1050
|
* ```
|
|
1051
|
+
*
|
|
1052
|
+
* @since 1.0.0
|
|
611
1053
|
*/
|
|
612
1054
|
declare const menuCSSVariables: {
|
|
613
|
-
readonly "--anyclick-menu-bg": "#ffffff";
|
|
614
|
-
readonly "--anyclick-menu-hover": "#f5f5f5";
|
|
615
|
-
readonly "--anyclick-menu-text": "#333333";
|
|
616
|
-
readonly "--anyclick-menu-text-muted": "#666666";
|
|
617
|
-
readonly "--anyclick-menu-border": "#e5e5e5";
|
|
618
1055
|
readonly "--anyclick-menu-accent": "#0066cc";
|
|
619
1056
|
readonly "--anyclick-menu-accent-text": "#ffffff";
|
|
620
|
-
readonly "--anyclick-menu-
|
|
621
|
-
readonly "--anyclick-menu-
|
|
1057
|
+
readonly "--anyclick-menu-bg": "#ffffff";
|
|
1058
|
+
readonly "--anyclick-menu-border": "#e5e5e5";
|
|
622
1059
|
readonly "--anyclick-menu-cancel-bg": "#f0f0f0";
|
|
623
1060
|
readonly "--anyclick-menu-cancel-text": "#666666";
|
|
1061
|
+
readonly "--anyclick-menu-hover": "#f5f5f5";
|
|
1062
|
+
readonly "--anyclick-menu-input-bg": "#ffffff";
|
|
1063
|
+
readonly "--anyclick-menu-input-border": "#dddddd";
|
|
1064
|
+
readonly "--anyclick-menu-text": "#333333";
|
|
1065
|
+
readonly "--anyclick-menu-text-muted": "#666666";
|
|
624
1066
|
};
|
|
1067
|
+
/**
|
|
1068
|
+
* Gets badge styles for a specific tone.
|
|
1069
|
+
*
|
|
1070
|
+
* @param tone - The badge tone (info, neutral, success, warning)
|
|
1071
|
+
* @returns CSSProperties for the badge
|
|
1072
|
+
*
|
|
1073
|
+
* @example
|
|
1074
|
+
* ```tsx
|
|
1075
|
+
* const style = getBadgeStyle("success");
|
|
1076
|
+
* // => { backgroundColor: "rgba(34, 197, 94, 0.15)", ... }
|
|
1077
|
+
* ```
|
|
1078
|
+
*
|
|
1079
|
+
* @since 1.2.0
|
|
1080
|
+
*/
|
|
1081
|
+
declare function getBadgeStyle(tone?: "info" | "neutral" | "success" | "warning"): CSSProperties;
|
|
1082
|
+
/**
|
|
1083
|
+
* Core menu component styles.
|
|
1084
|
+
*
|
|
1085
|
+
* @since 1.0.0
|
|
1086
|
+
*/
|
|
625
1087
|
declare const menuStyles: Record<string, CSSProperties>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Dark mode menu styles.
|
|
1090
|
+
*
|
|
1091
|
+
* Apply these styles for dark theme support.
|
|
1092
|
+
*
|
|
1093
|
+
* @since 1.0.0
|
|
1094
|
+
*/
|
|
626
1095
|
declare const darkMenuStyles: Record<string, CSSProperties>;
|
|
627
1096
|
|
|
628
1097
|
/**
|
|
629
|
-
* Highlight utilities for feedback target elements
|
|
1098
|
+
* Highlight utilities for feedback target elements.
|
|
1099
|
+
*
|
|
1100
|
+
* Provides functions to visually highlight DOM elements during feedback selection.
|
|
1101
|
+
* Highlights are applied using CSS classes and dynamically generated styles.
|
|
1102
|
+
*
|
|
1103
|
+
* @module highlight
|
|
1104
|
+
* @since 1.0.0
|
|
630
1105
|
*/
|
|
631
1106
|
|
|
632
1107
|
/**
|
|
633
|
-
* Default highlight colors
|
|
1108
|
+
* Default highlight colors used when no custom colors are specified.
|
|
1109
|
+
*
|
|
1110
|
+
* @example
|
|
1111
|
+
* ```ts
|
|
1112
|
+
* // Override specific colors
|
|
1113
|
+
* const customColors = {
|
|
1114
|
+
* ...defaultHighlightColors,
|
|
1115
|
+
* targetColor: "#ef4444", // Red instead of blue
|
|
1116
|
+
* };
|
|
1117
|
+
* ```
|
|
1118
|
+
*
|
|
1119
|
+
* @since 1.0.0
|
|
634
1120
|
*/
|
|
635
1121
|
declare const defaultHighlightColors: Required<HighlightColors>;
|
|
636
1122
|
/**
|
|
637
|
-
* Default container
|
|
1123
|
+
* Default CSS selectors used to identify container elements.
|
|
1124
|
+
*
|
|
1125
|
+
* These selectors are checked when traversing up the DOM tree to find
|
|
1126
|
+
* a suitable container element to highlight alongside the target.
|
|
1127
|
+
*
|
|
1128
|
+
* @example
|
|
1129
|
+
* ```ts
|
|
1130
|
+
* // Add custom selectors
|
|
1131
|
+
* const customSelectors = [
|
|
1132
|
+
* ...defaultContainerSelectors,
|
|
1133
|
+
* "[data-component]",
|
|
1134
|
+
* ".my-custom-container",
|
|
1135
|
+
* ];
|
|
1136
|
+
* ```
|
|
1137
|
+
*
|
|
1138
|
+
* @since 1.0.0
|
|
638
1139
|
*/
|
|
639
1140
|
declare const defaultContainerSelectors: string[];
|
|
640
1141
|
/**
|
|
641
|
-
*
|
|
1142
|
+
* Finds the closest container parent element for a given target element.
|
|
1143
|
+
*
|
|
1144
|
+
* Traverses up the DOM tree looking for elements that match container selectors
|
|
1145
|
+
* or have multiple meaningful child elements.
|
|
1146
|
+
*
|
|
1147
|
+
* @param element - The target element to find a container for
|
|
1148
|
+
* @param config - Optional highlight configuration with custom selectors
|
|
1149
|
+
* @returns The found container element, or null if none found
|
|
1150
|
+
*
|
|
1151
|
+
* @example
|
|
1152
|
+
* ```ts
|
|
1153
|
+
* const target = document.querySelector(".my-button");
|
|
1154
|
+
* const container = findContainerParent(target, {
|
|
1155
|
+
* containerSelectors: [".card", ".panel"],
|
|
1156
|
+
* minChildrenForContainer: 3,
|
|
1157
|
+
* });
|
|
1158
|
+
* ```
|
|
1159
|
+
*
|
|
1160
|
+
* @since 1.0.0
|
|
642
1161
|
*/
|
|
643
1162
|
declare function findContainerParent(element: Element, config?: HighlightConfig): Element | null;
|
|
644
1163
|
/**
|
|
645
|
-
*
|
|
1164
|
+
* Applies highlight styling to a target element.
|
|
1165
|
+
*
|
|
1166
|
+
* Injects the necessary CSS styles and adds the highlight class to the element.
|
|
1167
|
+
*
|
|
1168
|
+
* @param element - The element to highlight
|
|
1169
|
+
* @param colors - Optional custom highlight colors
|
|
1170
|
+
*
|
|
1171
|
+
* @example
|
|
1172
|
+
* ```ts
|
|
1173
|
+
* const target = document.querySelector(".my-button");
|
|
1174
|
+
* highlightTarget(target, { targetColor: "#ef4444" });
|
|
1175
|
+
* ```
|
|
1176
|
+
*
|
|
1177
|
+
* @since 1.0.0
|
|
646
1178
|
*/
|
|
647
1179
|
declare function highlightTarget(element: Element, colors?: HighlightColors): void;
|
|
648
1180
|
/**
|
|
649
|
-
*
|
|
1181
|
+
* Applies highlight styling to a container element.
|
|
1182
|
+
*
|
|
1183
|
+
* Container highlights are visually distinct from target highlights,
|
|
1184
|
+
* typically with a larger outline offset and different color.
|
|
1185
|
+
*
|
|
1186
|
+
* @param element - The container element to highlight
|
|
1187
|
+
* @param colors - Optional custom highlight colors
|
|
1188
|
+
*
|
|
1189
|
+
* @example
|
|
1190
|
+
* ```ts
|
|
1191
|
+
* const container = document.querySelector(".card");
|
|
1192
|
+
* highlightContainer(container, { containerColor: "#22c55e" });
|
|
1193
|
+
* ```
|
|
1194
|
+
*
|
|
1195
|
+
* @since 1.0.0
|
|
650
1196
|
*/
|
|
651
1197
|
declare function highlightContainer(element: Element, colors?: HighlightColors): void;
|
|
652
1198
|
/**
|
|
653
|
-
*
|
|
1199
|
+
* Removes all highlight styling from the document.
|
|
1200
|
+
*
|
|
1201
|
+
* Clears both target and container highlights from all elements.
|
|
1202
|
+
*
|
|
1203
|
+
* @example
|
|
1204
|
+
* ```ts
|
|
1205
|
+
* // Remove highlights when closing the context menu
|
|
1206
|
+
* clearHighlights();
|
|
1207
|
+
* ```
|
|
1208
|
+
*
|
|
1209
|
+
* @since 1.0.0
|
|
654
1210
|
*/
|
|
655
1211
|
declare function clearHighlights(): void;
|
|
656
1212
|
/**
|
|
657
|
-
*
|
|
1213
|
+
* Applies highlights to both a target element and its container parent.
|
|
1214
|
+
*
|
|
1215
|
+
* This is the main function for applying highlights during feedback selection.
|
|
1216
|
+
* It automatically finds the container parent and applies appropriate styling.
|
|
1217
|
+
*
|
|
1218
|
+
* @param targetElement - The element to highlight as the target
|
|
1219
|
+
* @param config - Optional highlight configuration
|
|
1220
|
+
* @returns Object containing the target and container elements
|
|
1221
|
+
*
|
|
1222
|
+
* @example
|
|
1223
|
+
* ```ts
|
|
1224
|
+
* const result = applyHighlights(clickedElement, {
|
|
1225
|
+
* enabled: true,
|
|
1226
|
+
* colors: { targetColor: "#3b82f6", containerColor: "#8b5cf6" },
|
|
1227
|
+
* containerSelectors: [".card", ".modal"],
|
|
1228
|
+
* });
|
|
1229
|
+
*
|
|
1230
|
+
* console.log(result.target); // The highlighted target
|
|
1231
|
+
* console.log(result.container); // The highlighted container (or null)
|
|
1232
|
+
* ```
|
|
1233
|
+
*
|
|
1234
|
+
* @since 1.0.0
|
|
658
1235
|
*/
|
|
659
1236
|
declare function applyHighlights(targetElement: Element, config?: HighlightConfig): {
|
|
660
|
-
target: Element;
|
|
661
1237
|
container: Element | null;
|
|
1238
|
+
target: Element;
|
|
662
1239
|
};
|
|
663
1240
|
|
|
664
1241
|
/**
|
|
@@ -869,4 +1446,4 @@ interface ModificationIndicatorProps {
|
|
|
869
1446
|
*/
|
|
870
1447
|
declare function ModificationIndicator({ position, size, autoApply, offset, primaryColor, backgroundColor, }: ModificationIndicatorProps): react_jsx_runtime.JSX.Element | null;
|
|
871
1448
|
|
|
872
|
-
export { AnyclickContext, type AnyclickContextValue, AnyclickLogo, type AnyclickLogoProps, AnyclickProvider, type AnyclickProviderProps, type AnyclickTheme, type AnyclickUserContext, type CompactModeConfig, ContextMenu, type ContextMenuItem, type ContextMenuProps, type CreatePresetMenuOptions, DEFAULT_COMPACT_CONFIG, type DeletedElement, type ElementModification, FeedbackContext, type FeedbackMenuBadge, type FeedbackMenuStatus, FeedbackProvider, FunModeBridge, type FunModeThemeConfig, type HighlightColors, type HighlightConfig, type IDEConfig, type IDEProtocol, INSPECT_DIALOG_EVENT, InspectDialog, type InspectDialogEventDetail, InspectDialogManager, type InspectDialogManagerProps, type InspectDialogProps, type MenuPositionMode, ModificationIndicator, type ModificationIndicatorProps, type PinnedPosition, type PresetConfig, type PresetRole, type ProviderInstance, ScreenshotPreview, type ScreenshotPreviewProps, type SourceLocation, applyHighlights, buildIDEUrl, clearHighlights, createIDEOpener, createPresetMenu, darkMenuStyles, defaultContainerSelectors, defaultHighlightColors, detectPreferredIDE, dispatchContextMenuEvent, filterMenuItemsByRole, findContainerParent, findSourceLocationInAncestors, formatSourceLocation, generateElementId, generateProviderId, getElementDescription, getSourceLocationFromElement, highlightContainer, highlightTarget, isIDEProtocolSupported, listPresets, menuCSSVariables, menuStyles, openInIDE, openInspectDialog, presetDefaults, useAnyclick, useFeedback, useHasHydrated, useInspectStore, useProviderStore, waitForHydration };
|
|
1449
|
+
export { AnyclickContext, type AnyclickContextValue, AnyclickLogo, type AnyclickLogoProps, AnyclickProvider, type AnyclickProviderProps, type AnyclickTheme, type AnyclickUserContext, type CompactModeConfig, ContextMenu, type ContextMenuItem, type ContextMenuProps, type CreatePresetMenuOptions, DEFAULT_COMPACT_CONFIG, type DeletedElement, type ElementModification, FeedbackContext, type FeedbackMenuBadge, type FeedbackMenuStatus, FeedbackProvider, FunModeBridge, type FunModeThemeConfig, type HighlightColors, type HighlightConfig, type IDEConfig, type IDEProtocol, INSPECT_DIALOG_EVENT, InspectDialog, type InspectDialogEventDetail, InspectDialogManager, type InspectDialogManagerProps, type InspectDialogProps, type MenuPositionMode, ModificationIndicator, type ModificationIndicatorProps, type PinnedPosition, type PresetConfig, type PresetRole, type ProviderInstance, ScreenshotPreview, type ScreenshotPreviewProps, type SourceLocation, applyHighlights, buildIDEUrl, clearHighlights, createIDEOpener, createPresetMenu, darkMenuStyles, defaultContainerSelectors, defaultHighlightColors, detectPreferredIDE, dispatchContextMenuEvent, filterMenuItemsByRole, findContainerParent, findSourceLocationInAncestors, formatSourceLocation, generateElementId, generateProviderId, getBadgeStyle, getElementDescription, getSourceLocationFromElement, highlightContainer, highlightTarget, isIDEProtocolSupported, listPresets, menuCSSVariables, menuStyles, openInIDE, openInspectDialog, presetDefaults, useAnyclick, useFeedback, useHasHydrated, useInspectStore, useProviderStore, waitForHydration };
|