@fivepixels-js/react 0.1.6 → 0.1.7

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.
Files changed (38) hide show
  1. package/dist/components/panel/ReportFeedbackList.d.ts.map +1 -1
  2. package/dist/components/panel/ReportFeedbackList.js +9 -2
  3. package/dist/components/panel/ReportFeedbackList.js.map +1 -1
  4. package/dist/components/panel/feedback/FeedbackHoverCard.d.ts +4 -1
  5. package/dist/components/panel/feedback/FeedbackHoverCard.d.ts.map +1 -1
  6. package/dist/components/panel/feedback/FeedbackHoverCard.js +6 -2
  7. package/dist/components/panel/feedback/FeedbackHoverCard.js.map +1 -1
  8. package/dist/components/point/ReportMarkersLayer.d.ts.map +1 -1
  9. package/dist/components/point/ReportMarkersLayer.js +49 -8
  10. package/dist/components/point/ReportMarkersLayer.js.map +1 -1
  11. package/dist/hooks/useReportState.d.ts.map +1 -1
  12. package/dist/hooks/useReportState.js +2 -1
  13. package/dist/hooks/useReportState.js.map +1 -1
  14. package/dist/i18n/en.d.ts.map +1 -1
  15. package/dist/i18n/en.js +3 -0
  16. package/dist/i18n/en.js.map +1 -1
  17. package/dist/i18n/ko.d.ts.map +1 -1
  18. package/dist/i18n/ko.js +3 -0
  19. package/dist/i18n/ko.js.map +1 -1
  20. package/dist/i18n/types.d.ts +3 -0
  21. package/dist/i18n/types.d.ts.map +1 -1
  22. package/dist/styles/reportStylesheet.d.ts +1 -1
  23. package/dist/styles/reportStylesheet.d.ts.map +1 -1
  24. package/dist/styles/reportStylesheet.js +1 -1
  25. package/dist/styles/reportStylesheet.js.map +1 -1
  26. package/dist/types/report-ui.d.ts +2 -0
  27. package/dist/types/report-ui.d.ts.map +1 -1
  28. package/dist/utils/coordinates.d.ts.map +1 -1
  29. package/dist/utils/coordinates.js +3 -0
  30. package/dist/utils/coordinates.js.map +1 -1
  31. package/dist/utils/dom.d.ts.map +1 -1
  32. package/dist/utils/dom.js +60 -2
  33. package/dist/utils/dom.js.map +1 -1
  34. package/dist/utils/markerContext.d.ts +30 -0
  35. package/dist/utils/markerContext.d.ts.map +1 -0
  36. package/dist/utils/markerContext.js +77 -0
  37. package/dist/utils/markerContext.js.map +1 -0
  38. package/package.json +1 -1
@@ -0,0 +1,77 @@
1
+ import { hasFixedPositionAncestor } from "./dom.js";
2
+ const MODAL_REPORT_ID_PATTERN = /(?:^|-)(modal|overlay|dialog)(?:-|$)/i;
3
+ const MODAL_GHOST_DIALOG_WIDTH = 480;
4
+ const MODAL_GHOST_DIALOG_HEIGHT = 280;
5
+ const MODAL_GHOST_DIALOG_MAX_WIDTH_RATIO = 0.92;
6
+ export function isModalReportId(reportId) {
7
+ return MODAL_REPORT_ID_PATTERN.test(reportId);
8
+ }
9
+ export function usesViewportDetachedCoords(report) {
10
+ return !report.anchor_report_id && report.viewport_width > 0;
11
+ }
12
+ export function resolveDetachedKind(report, targetElement, detached) {
13
+ if (!detached) {
14
+ return null;
15
+ }
16
+ if (isModalReportId(report.report_id)) {
17
+ return "modal";
18
+ }
19
+ if (usesViewportDetachedCoords(report)) {
20
+ return "modal";
21
+ }
22
+ if (targetElement && hasFixedPositionAncestor(targetElement)) {
23
+ return "modal";
24
+ }
25
+ return "hidden";
26
+ }
27
+ export function formatModalReportLabel(reportId) {
28
+ const withoutPrefix = reportId.replace(/^modal-/, "");
29
+ const name = withoutPrefix
30
+ .replace(/-(overlay|target|open|demo)$/, "")
31
+ .split("-")
32
+ .filter(Boolean)
33
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
34
+ .join(" ");
35
+ return name ? `${name} modal` : "Modal";
36
+ }
37
+ export function getModalGhostFrame(report) {
38
+ const widthScale = report.viewport_width > 0 ? window.innerWidth / report.viewport_width : 1;
39
+ const heightScale = report.viewport_height > 0 ? window.innerHeight / report.viewport_height : 1;
40
+ const centerX = report.viewport_width * report.x_ratio * widthScale;
41
+ const centerY = report.viewport_height * report.y_ratio * heightScale;
42
+ const dialogWidth = Math.min(MODAL_GHOST_DIALOG_WIDTH * widthScale, window.innerWidth * MODAL_GHOST_DIALOG_MAX_WIDTH_RATIO);
43
+ const dialogHeight = MODAL_GHOST_DIALOG_HEIGHT * heightScale;
44
+ return {
45
+ backdrop: {
46
+ left: 0,
47
+ top: 0,
48
+ width: window.innerWidth,
49
+ height: window.innerHeight,
50
+ },
51
+ dialog: {
52
+ left: centerX - dialogWidth / 2,
53
+ top: centerY - dialogHeight / 2,
54
+ width: dialogWidth,
55
+ height: dialogHeight,
56
+ },
57
+ };
58
+ }
59
+ export function getDetachedMarkerHint(detachedKind, messages) {
60
+ if (detachedKind === "modal") {
61
+ return messages.detachedModalHint;
62
+ }
63
+ if (detachedKind === "hidden") {
64
+ return messages.detachedHint;
65
+ }
66
+ return null;
67
+ }
68
+ export function getDetachedMarkerAriaLabel(detachedKind, messages) {
69
+ if (detachedKind === "modal") {
70
+ return messages.detachedModalAriaLabel;
71
+ }
72
+ if (detachedKind === "hidden") {
73
+ return messages.detachedAriaLabel;
74
+ }
75
+ return messages.detachedAriaLabel;
76
+ }
77
+ //# sourceMappingURL=markerContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markerContext.js","sourceRoot":"","sources":["../../src/utils/markerContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,uBAAuB,GAAG,uCAAuC,CAAC;AAiBxE,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,kCAAkC,GAAG,IAAI,CAAC;AAEhD,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC5C,OAAO,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,MAAmE;IAC1G,OAAO,CAAC,MAAM,CAAC,gBAAgB,IAAI,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC;AACjE,CAAC;AAED,MA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C5B,OAAO,QAAQ,CAAC,iBAAiB,CAAC;IACtC,CAAC;IAED,OAAO,QAAQ,CAAC,iBAAiB,CAAC;AACtC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fivepixels-js/react",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "React library for DOM element feedback markers on staging, QA, and internal tool UIs",
5
5
  "license": "MIT",
6
6
  "keywords": [