react-grab 0.0.53 → 0.0.54

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.
@@ -153,9 +153,30 @@ interface ReactGrabState {
153
153
  isActive: boolean;
154
154
  isDragging: boolean;
155
155
  isCopying: boolean;
156
+ isInputMode: boolean;
156
157
  targetElement: Element | null;
157
158
  dragBounds: DragRect | null;
158
159
  }
160
+ type SuccessLabelType = "copy" | "input-submit";
161
+ type ElementLabelVariant = "hover" | "processing" | "success";
162
+ interface InputModeContext {
163
+ x: number;
164
+ y: number;
165
+ targetElement: Element | null;
166
+ }
167
+ interface SuccessLabelContext {
168
+ x: number;
169
+ y: number;
170
+ }
171
+ interface CrosshairContext {
172
+ x: number;
173
+ y: number;
174
+ }
175
+ interface ElementLabelContext {
176
+ x: number;
177
+ y: number;
178
+ content: string;
179
+ }
159
180
  type RenderType = "selectionBox" | "dragBox" | "grabbedBox" | "elementLabel" | "successLabel" | "crosshair" | "inputOverlay";
160
181
  interface RenderData {
161
182
  ref: HTMLElement | undefined;
@@ -165,6 +186,8 @@ interface Options {
165
186
  enabled?: boolean;
166
187
  keyHoldDuration?: number;
167
188
  allowActivationInsideInput?: boolean;
189
+ copyFileOnly?: boolean;
190
+ log?: boolean;
168
191
  theme?: Theme;
169
192
  onActivate?: () => void;
170
193
  onDeactivate?: () => void;
@@ -178,6 +201,13 @@ interface Options {
178
201
  onCopyError?: (error: Error) => void;
179
202
  onStateChange?: (state: ReactGrabState) => void;
180
203
  onRender?: (type: RenderType, data: RenderData) => void;
204
+ onInputModeChange?: (isInputMode: boolean, context: InputModeContext) => void;
205
+ onSuccessLabel?: (text: string, type: SuccessLabelType, context: SuccessLabelContext) => void;
206
+ onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
207
+ onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
208
+ onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
209
+ onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
210
+ onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
181
211
  }
182
212
  interface ReactGrabAPI {
183
213
  activate: () => void;
@@ -263,10 +293,11 @@ interface StackFrame {
263
293
  }
264
294
  declare const getStack: (element: Element) => Promise<Array<StackFrame>>;
265
295
  declare const formatStack: (stack: Array<StackFrame>) => string;
296
+ declare const getFileName: (stack: Array<StackFrame>) => string | null;
266
297
  declare const getHTMLPreview: (element: Element) => string;
267
298
 
268
299
  declare const DEFAULT_THEME: Required<Theme>;
269
300
 
270
301
  declare const init: (rawOptions?: Options) => ReactGrabAPI;
271
302
 
272
- export { DEFAULT_THEME as D, type GrabbedBox as G, type Options as O, type Position as P, type ReactGrabAPI as R, type Theme as T, getHTMLPreview as a, getNearestComponentName as b, type ReactGrabState as c, type RenderType as d, type RenderData as e, formatStack as f, getStack as g, type OverlayBounds as h, init as i, type DragRect as j, type Rect as k, type DeepPartial as l, type ReactGrabRendererProps as m };
303
+ export { type CrosshairContext as C, DEFAULT_THEME as D, type ElementLabelVariant as E, type GrabbedBox as G, type InputModeContext as I, type Options as O, type Position as P, type ReactGrabAPI as R, type SuccessLabelType as S, type Theme as T, getHTMLPreview as a, getNearestComponentName as b, type ReactGrabState as c, type RenderType as d, type RenderData as e, formatStack as f, getStack as g, type OverlayBounds as h, init as i, type DragRect as j, type Rect as k, type DeepPartial as l, type SuccessLabelContext as m, type ElementLabelContext as n, getFileName as o, type ReactGrabRendererProps as p };
@@ -153,9 +153,30 @@ interface ReactGrabState {
153
153
  isActive: boolean;
154
154
  isDragging: boolean;
155
155
  isCopying: boolean;
156
+ isInputMode: boolean;
156
157
  targetElement: Element | null;
157
158
  dragBounds: DragRect | null;
158
159
  }
160
+ type SuccessLabelType = "copy" | "input-submit";
161
+ type ElementLabelVariant = "hover" | "processing" | "success";
162
+ interface InputModeContext {
163
+ x: number;
164
+ y: number;
165
+ targetElement: Element | null;
166
+ }
167
+ interface SuccessLabelContext {
168
+ x: number;
169
+ y: number;
170
+ }
171
+ interface CrosshairContext {
172
+ x: number;
173
+ y: number;
174
+ }
175
+ interface ElementLabelContext {
176
+ x: number;
177
+ y: number;
178
+ content: string;
179
+ }
159
180
  type RenderType = "selectionBox" | "dragBox" | "grabbedBox" | "elementLabel" | "successLabel" | "crosshair" | "inputOverlay";
160
181
  interface RenderData {
161
182
  ref: HTMLElement | undefined;
@@ -165,6 +186,8 @@ interface Options {
165
186
  enabled?: boolean;
166
187
  keyHoldDuration?: number;
167
188
  allowActivationInsideInput?: boolean;
189
+ copyFileOnly?: boolean;
190
+ log?: boolean;
168
191
  theme?: Theme;
169
192
  onActivate?: () => void;
170
193
  onDeactivate?: () => void;
@@ -178,6 +201,13 @@ interface Options {
178
201
  onCopyError?: (error: Error) => void;
179
202
  onStateChange?: (state: ReactGrabState) => void;
180
203
  onRender?: (type: RenderType, data: RenderData) => void;
204
+ onInputModeChange?: (isInputMode: boolean, context: InputModeContext) => void;
205
+ onSuccessLabel?: (text: string, type: SuccessLabelType, context: SuccessLabelContext) => void;
206
+ onSelectionBox?: (visible: boolean, bounds: OverlayBounds | null, element: Element | null) => void;
207
+ onDragBox?: (visible: boolean, bounds: OverlayBounds | null) => void;
208
+ onGrabbedBox?: (bounds: OverlayBounds, element: Element) => void;
209
+ onElementLabel?: (visible: boolean, variant: ElementLabelVariant, context: ElementLabelContext) => void;
210
+ onCrosshair?: (visible: boolean, context: CrosshairContext) => void;
181
211
  }
182
212
  interface ReactGrabAPI {
183
213
  activate: () => void;
@@ -263,10 +293,11 @@ interface StackFrame {
263
293
  }
264
294
  declare const getStack: (element: Element) => Promise<Array<StackFrame>>;
265
295
  declare const formatStack: (stack: Array<StackFrame>) => string;
296
+ declare const getFileName: (stack: Array<StackFrame>) => string | null;
266
297
  declare const getHTMLPreview: (element: Element) => string;
267
298
 
268
299
  declare const DEFAULT_THEME: Required<Theme>;
269
300
 
270
301
  declare const init: (rawOptions?: Options) => ReactGrabAPI;
271
302
 
272
- export { DEFAULT_THEME as D, type GrabbedBox as G, type Options as O, type Position as P, type ReactGrabAPI as R, type Theme as T, getHTMLPreview as a, getNearestComponentName as b, type ReactGrabState as c, type RenderType as d, type RenderData as e, formatStack as f, getStack as g, type OverlayBounds as h, init as i, type DragRect as j, type Rect as k, type DeepPartial as l, type ReactGrabRendererProps as m };
303
+ export { type CrosshairContext as C, DEFAULT_THEME as D, type ElementLabelVariant as E, type GrabbedBox as G, type InputModeContext as I, type Options as O, type Position as P, type ReactGrabAPI as R, type SuccessLabelType as S, type Theme as T, getHTMLPreview as a, getNearestComponentName as b, type ReactGrabState as c, type RenderType as d, type RenderData as e, formatStack as f, getStack as g, type OverlayBounds as h, init as i, type DragRect as j, type Rect as k, type DeepPartial as l, type SuccessLabelContext as m, type ElementLabelContext as n, getFileName as o, type ReactGrabRendererProps as p };
package/dist/core.cjs CHANGED
@@ -1,34 +1,38 @@
1
1
  'use strict';
2
2
 
3
- var chunk3OMOSCKI_cjs = require('./chunk-3OMOSCKI.cjs');
3
+ var chunkQMP2IZ3H_cjs = require('./chunk-QMP2IZ3H.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "DEFAULT_THEME", {
8
8
  enumerable: true,
9
- get: function () { return chunk3OMOSCKI_cjs.DEFAULT_THEME; }
9
+ get: function () { return chunkQMP2IZ3H_cjs.DEFAULT_THEME; }
10
10
  });
11
11
  Object.defineProperty(exports, "formatStack", {
12
12
  enumerable: true,
13
- get: function () { return chunk3OMOSCKI_cjs.formatStack; }
13
+ get: function () { return chunkQMP2IZ3H_cjs.formatStack; }
14
+ });
15
+ Object.defineProperty(exports, "getFileName", {
16
+ enumerable: true,
17
+ get: function () { return chunkQMP2IZ3H_cjs.getFileName; }
14
18
  });
15
19
  Object.defineProperty(exports, "getHTMLPreview", {
16
20
  enumerable: true,
17
- get: function () { return chunk3OMOSCKI_cjs.getHTMLPreview; }
21
+ get: function () { return chunkQMP2IZ3H_cjs.getHTMLPreview; }
18
22
  });
19
23
  Object.defineProperty(exports, "getNearestComponentName", {
20
24
  enumerable: true,
21
- get: function () { return chunk3OMOSCKI_cjs.getNearestComponentName; }
25
+ get: function () { return chunkQMP2IZ3H_cjs.getNearestComponentName; }
22
26
  });
23
27
  Object.defineProperty(exports, "getStack", {
24
28
  enumerable: true,
25
- get: function () { return chunk3OMOSCKI_cjs.getStack; }
29
+ get: function () { return chunkQMP2IZ3H_cjs.getStack; }
26
30
  });
27
31
  Object.defineProperty(exports, "init", {
28
32
  enumerable: true,
29
- get: function () { return chunk3OMOSCKI_cjs.init; }
33
+ get: function () { return chunkQMP2IZ3H_cjs.init; }
30
34
  });
31
35
  Object.defineProperty(exports, "isInstrumentationActive", {
32
36
  enumerable: true,
33
- get: function () { return chunk3OMOSCKI_cjs.Ee; }
37
+ get: function () { return chunkQMP2IZ3H_cjs.Ee; }
34
38
  });
package/dist/core.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { D as DEFAULT_THEME, O as Options, h as OverlayBounds, R as ReactGrabAPI, m as ReactGrabRendererProps, f as formatStack, a as getHTMLPreview, b as getNearestComponentName, g as getStack, i as init } from './core-CHAbsaHv.cjs';
1
+ export { D as DEFAULT_THEME, O as Options, h as OverlayBounds, R as ReactGrabAPI, p as ReactGrabRendererProps, f as formatStack, o as getFileName, a as getHTMLPreview, b as getNearestComponentName, g as getStack, i as init } from './core-HkBjqOQQ.cjs';
2
2
  export { isInstrumentationActive } from 'bippy';
3
3
  import 'bippy/source';
package/dist/core.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { D as DEFAULT_THEME, O as Options, h as OverlayBounds, R as ReactGrabAPI, m as ReactGrabRendererProps, f as formatStack, a as getHTMLPreview, b as getNearestComponentName, g as getStack, i as init } from './core-CHAbsaHv.js';
1
+ export { D as DEFAULT_THEME, O as Options, h as OverlayBounds, R as ReactGrabAPI, p as ReactGrabRendererProps, f as formatStack, o as getFileName, a as getHTMLPreview, b as getNearestComponentName, g as getStack, i as init } from './core-HkBjqOQQ.js';
2
2
  export { isInstrumentationActive } from 'bippy';
3
3
  import 'bippy/source';
package/dist/core.js CHANGED
@@ -1 +1 @@
1
- export { DEFAULT_THEME, formatStack, getHTMLPreview, getNearestComponentName, getStack, init, Ee as isInstrumentationActive } from './chunk-XLGRJBAL.js';
1
+ export { DEFAULT_THEME, formatStack, getFileName, getHTMLPreview, getNearestComponentName, getStack, init, Ee as isInstrumentationActive } from './chunk-D6EGQYIX.js';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk3OMOSCKI_cjs = require('./chunk-3OMOSCKI.cjs');
3
+ var chunkQMP2IZ3H_cjs = require('./chunk-QMP2IZ3H.cjs');
4
4
 
5
5
  /**
6
6
  * @license MIT
@@ -14,38 +14,46 @@ var chunk3OMOSCKI_cjs = require('./chunk-3OMOSCKI.cjs');
14
14
  // src/index.ts
15
15
  var globalApi = null;
16
16
  var getGlobalApi = () => {
17
- return globalApi;
17
+ return globalApi ?? window.__REACT_GRAB__ ?? null;
18
18
  };
19
19
  if (typeof window !== "undefined") {
20
- globalApi = chunk3OMOSCKI_cjs.init();
20
+ if (window.__REACT_GRAB__) {
21
+ globalApi = window.__REACT_GRAB__;
22
+ } else {
23
+ globalApi = chunkQMP2IZ3H_cjs.init();
24
+ window.__REACT_GRAB__ = globalApi;
25
+ window.dispatchEvent(
26
+ new CustomEvent("react-grab:init", { detail: globalApi })
27
+ );
28
+ }
21
29
  }
22
30
 
23
31
  Object.defineProperty(exports, "DEFAULT_THEME", {
24
32
  enumerable: true,
25
- get: function () { return chunk3OMOSCKI_cjs.DEFAULT_THEME; }
33
+ get: function () { return chunkQMP2IZ3H_cjs.DEFAULT_THEME; }
26
34
  });
27
35
  Object.defineProperty(exports, "formatStack", {
28
36
  enumerable: true,
29
- get: function () { return chunk3OMOSCKI_cjs.formatStack; }
37
+ get: function () { return chunkQMP2IZ3H_cjs.formatStack; }
30
38
  });
31
39
  Object.defineProperty(exports, "getHTMLPreview", {
32
40
  enumerable: true,
33
- get: function () { return chunk3OMOSCKI_cjs.getHTMLPreview; }
41
+ get: function () { return chunkQMP2IZ3H_cjs.getHTMLPreview; }
34
42
  });
35
43
  Object.defineProperty(exports, "getNearestComponentName", {
36
44
  enumerable: true,
37
- get: function () { return chunk3OMOSCKI_cjs.getNearestComponentName; }
45
+ get: function () { return chunkQMP2IZ3H_cjs.getNearestComponentName; }
38
46
  });
39
47
  Object.defineProperty(exports, "getStack", {
40
48
  enumerable: true,
41
- get: function () { return chunk3OMOSCKI_cjs.getStack; }
49
+ get: function () { return chunkQMP2IZ3H_cjs.getStack; }
42
50
  });
43
51
  Object.defineProperty(exports, "init", {
44
52
  enumerable: true,
45
- get: function () { return chunk3OMOSCKI_cjs.init; }
53
+ get: function () { return chunkQMP2IZ3H_cjs.init; }
46
54
  });
47
55
  Object.defineProperty(exports, "isInstrumentationActive", {
48
56
  enumerable: true,
49
- get: function () { return chunk3OMOSCKI_cjs.Ee; }
57
+ get: function () { return chunkQMP2IZ3H_cjs.Ee; }
50
58
  });
51
59
  exports.getGlobalApi = getGlobalApi;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,13 @@
1
- import { R as ReactGrabAPI } from './core-CHAbsaHv.cjs';
2
- export { D as DEFAULT_THEME, l as DeepPartial, j as DragRect, G as GrabbedBox, O as Options, h as OverlayBounds, P as Position, c as ReactGrabState, k as Rect, e as RenderData, d as RenderType, T as Theme, f as formatStack, a as getHTMLPreview, b as getNearestComponentName, g as getStack, i as init } from './core-CHAbsaHv.cjs';
1
+ import { R as ReactGrabAPI } from './core-HkBjqOQQ.cjs';
2
+ export { C as CrosshairContext, D as DEFAULT_THEME, l as DeepPartial, j as DragRect, n as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, I as InputModeContext, O as Options, h as OverlayBounds, P as Position, c as ReactGrabState, k as Rect, e as RenderData, d as RenderType, m as SuccessLabelContext, S as SuccessLabelType, T as Theme, f as formatStack, a as getHTMLPreview, b as getNearestComponentName, g as getStack, i as init } from './core-HkBjqOQQ.cjs';
3
3
  export { isInstrumentationActive } from 'bippy';
4
4
  import 'bippy/source';
5
5
 
6
+ declare global {
7
+ interface Window {
8
+ __REACT_GRAB__?: ReactGrabAPI;
9
+ }
10
+ }
6
11
  declare const getGlobalApi: () => ReactGrabAPI | null;
7
12
 
8
13
  export { ReactGrabAPI, getGlobalApi };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- import { R as ReactGrabAPI } from './core-CHAbsaHv.js';
2
- export { D as DEFAULT_THEME, l as DeepPartial, j as DragRect, G as GrabbedBox, O as Options, h as OverlayBounds, P as Position, c as ReactGrabState, k as Rect, e as RenderData, d as RenderType, T as Theme, f as formatStack, a as getHTMLPreview, b as getNearestComponentName, g as getStack, i as init } from './core-CHAbsaHv.js';
1
+ import { R as ReactGrabAPI } from './core-HkBjqOQQ.js';
2
+ export { C as CrosshairContext, D as DEFAULT_THEME, l as DeepPartial, j as DragRect, n as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, I as InputModeContext, O as Options, h as OverlayBounds, P as Position, c as ReactGrabState, k as Rect, e as RenderData, d as RenderType, m as SuccessLabelContext, S as SuccessLabelType, T as Theme, f as formatStack, a as getHTMLPreview, b as getNearestComponentName, g as getStack, i as init } from './core-HkBjqOQQ.js';
3
3
  export { isInstrumentationActive } from 'bippy';
4
4
  import 'bippy/source';
5
5
 
6
+ declare global {
7
+ interface Window {
8
+ __REACT_GRAB__?: ReactGrabAPI;
9
+ }
10
+ }
6
11
  declare const getGlobalApi: () => ReactGrabAPI | null;
7
12
 
8
13
  export { ReactGrabAPI, getGlobalApi };