@pablo2410/shared-ui 0.18.2 → 0.19.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.
@@ -13,7 +13,7 @@ import {
13
13
  Tooltip,
14
14
  TooltipContent,
15
15
  TooltipTrigger
16
- } from "./chunk-NXE653CX.js";
16
+ } from "./chunk-K6FHU4HN.js";
17
17
  import {
18
18
  cn
19
19
  } from "./chunk-JT3XLKKD.js";
@@ -725,4 +725,4 @@ export {
725
725
  hierarchyCodeFor,
726
726
  HierarchyNavigator
727
727
  };
728
- //# sourceMappingURL=chunk-CPRJSW7F.js.map
728
+ //# sourceMappingURL=chunk-VJEXXX2P.js.map
@@ -6,7 +6,7 @@ import {
6
6
  hierarchyCodeFor,
7
7
  idReference,
8
8
  readActiveEnterpriseCookie
9
- } from "../chunk-CPRJSW7F.js";
9
+ } from "../chunk-VJEXXX2P.js";
10
10
  import {
11
11
  ORG_HIERARCHY_PARAM,
12
12
  appendSelectionParam,
@@ -27,7 +27,7 @@ import {
27
27
  ORG_HIERARCHY_LABELS,
28
28
  ORG_HIERARCHY_LEVELS
29
29
  } from "../chunk-HLMIR5UV.js";
30
- import "../chunk-NXE653CX.js";
30
+ import "../chunk-K6FHU4HN.js";
31
31
  import "../chunk-JT3XLKKD.js";
32
32
  import "../chunk-BKGUIIN2.js";
33
33
  export {
@@ -19,13 +19,13 @@ import {
19
19
  policyDeploymentConfig,
20
20
  sqdcpConfig,
21
21
  useSidebarResize
22
- } from "../chunk-TTDKZK6L.js";
22
+ } from "../chunk-LR5TUYFD.js";
23
23
  import "../chunk-4QJMLQSH.js";
24
- import "../chunk-CPRJSW7F.js";
24
+ import "../chunk-VJEXXX2P.js";
25
25
  import "../chunk-DMUQ5WNO.js";
26
26
  import "../chunk-A6UTXAPS.js";
27
27
  import "../chunk-HLMIR5UV.js";
28
- import "../chunk-NXE653CX.js";
28
+ import "../chunk-K6FHU4HN.js";
29
29
  import "../chunk-JT3XLKKD.js";
30
30
  import "../chunk-BKGUIIN2.js";
31
31
  export {
@@ -27,7 +27,7 @@ import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu';
27
27
  import * as PopoverPrimitive from '@radix-ui/react-popover';
28
28
  import * as ProgressPrimitive from '@radix-ui/react-progress';
29
29
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
30
- import { PanelResizeHandle, Panel, PanelGroup } from 'react-resizable-panels';
30
+ import { Separator as Separator$1, Panel, Group } from 'react-resizable-panels';
31
31
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
32
32
  import * as SelectPrimitive from '@radix-ui/react-select';
33
33
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
@@ -425,9 +425,9 @@ declare function Progress({ className, value, ...props }: React$1.ComponentProps
425
425
  declare function RadioGroup({ className, ...props }: React$1.ComponentProps<typeof RadioGroupPrimitive.Root>): React$1.JSX.Element;
426
426
  declare function RadioGroupItem({ className, ...props }: React$1.ComponentProps<typeof RadioGroupPrimitive.Item>): React$1.JSX.Element;
427
427
 
428
- declare function ResizablePanelGroup({ className, ...props }: React$1.ComponentProps<typeof PanelGroup>): React$1.JSX.Element;
428
+ declare function ResizablePanelGroup({ className, ...props }: React$1.ComponentProps<typeof Group>): React$1.JSX.Element;
429
429
  declare function ResizablePanel({ ...props }: React$1.ComponentProps<typeof Panel>): React$1.JSX.Element;
430
- declare function ResizableHandle({ withHandle, className, ...props }: React$1.ComponentProps<typeof PanelResizeHandle> & {
430
+ declare function ResizableHandle({ withHandle, className, ...props }: React$1.ComponentProps<typeof Separator$1> & {
431
431
  withHandle?: boolean;
432
432
  }): React$1.JSX.Element;
433
433
 
@@ -269,7 +269,7 @@ import {
269
269
  useFormField,
270
270
  useIsMobile,
271
271
  useSidebar
272
- } from "../chunk-NXE653CX.js";
272
+ } from "../chunk-K6FHU4HN.js";
273
273
  import {
274
274
  Button,
275
275
  Dialog,
@@ -1,36 +1,72 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  interface ReportingToolbarProps extends Omit<ReportingToolbarConfig, "moduleName"> {
4
- /** Service/module name (e.g. "Connect", "Policy Deployment"). Defaults to "Oplytics". */
4
+ /** Service/module name (e.g. "Connect"). Defaults to "Oplytics". */
5
5
  moduleName?: string;
6
- /** Optional pre-fill for the report dialog's Location/Area field. */
7
- defaultLocation?: string;
6
+ /** The current org-hierarchy selection, forwarded on every submission. */
7
+ hierarchyContext?: ReportHierarchyContext;
8
+ /** The authenticated user — openId is authoritative, name/email are hints. */
9
+ currentUser?: ReportSubmitter;
10
+ /** Service list for the feedback picker. Defaults to OPLYTICS_SERVICES. */
11
+ services?: OplyticsService[];
12
+ /** Pre-selected service slug in the feedback picker. */
13
+ defaultServiceSlug?: string;
14
+ /** Show the "attach screenshot" control (default: true). */
15
+ enableScreenshot?: boolean;
8
16
  /**
9
- * Compact mode — currently a no-op (the new design always responsive-collapses
10
- * the labels at small breakpoints). Kept on the prop type so callers that
11
- * still pass it continue to type-check.
12
- * @deprecated The toolbar handles responsive collapse on its own.
17
+ * While true (the DEFAULT), the Report items are disabled with a "Coming
18
+ * soon" badge and `onReportSubmit` is never called. A later release wires the
19
+ * per-type forms and passes `false`.
20
+ */
21
+ reportsComingSoon?: boolean;
22
+ /**
23
+ * @deprecated the toolbar handles responsive collapse itself.
13
24
  */
14
25
  compact?: boolean;
15
26
  /** CSS class for the container. */
16
27
  className?: string;
17
28
  }
18
- declare function ReportingToolbar({ moduleName, showIncidentReporting, showFeedback, reportCategories, feedbackCategories, onReportSubmit, onFeedbackSubmit, defaultLocation, className, }: ReportingToolbarProps): React.JSX.Element;
29
+ declare function ReportingToolbar({ moduleName, showIncidentReporting, showFeedback, reportCategories, feedbackCategories, onReportSubmit, onFeedbackSubmit, hierarchyContext, currentUser, services, defaultServiceSlug, enableScreenshot, reportsComingSoon, className, }: ReportingToolbarProps): React.JSX.Element | null;
19
30
 
20
31
  /**
21
32
  * @oplytics/shared-ui/reporting
22
33
  *
23
- * Reporting and feedback toolbar types and configuration for all Oplytics subdomains.
24
- * Provides the standard Safety/Environmental/Stop Work incident reporting buttons
25
- * and Problem/Suggestion feedback buttons.
34
+ * Reporting and feedback toolbar types + configuration for all Oplytics
35
+ * subdomains — the header "User Actions" dropdown (ReportingToolbar).
26
36
  *
27
- * The actual ReportingToolbar React component depends on shadcn/ui primitives
28
- * (Dialog, Button, Textarea, Select) which vary across subdomains until
29
- * consolidation. This module provides the types, configuration, and submission
30
- * logic that are shared.
37
+ * Feedback (Report Problem / Suggestion) is fully wired: the dialog collects a
38
+ * service, an "is this blocking you?" signal, a short summary, the detail, and
39
+ * an optional screenshot, then calls `onFeedbackSubmit` with the canonical
40
+ * `FeedbackReport` shape. The host owns the transport (it POSTs to Portal's
41
+ * `/api/service/feedback`).
42
+ *
43
+ * Report (Safety / Environmental / Stop Work) is not wired yet — while
44
+ * `reportsComingSoon` is true (the default), those items render disabled with a
45
+ * "Coming soon" badge. A later release adds the per-type forms and flips the
46
+ * default.
31
47
  */
32
48
  type ReportCategory = "safety" | "environmental" | "stop-work";
33
49
  type FeedbackCategory = "problem" | "suggestion";
50
+ /** Where in the org hierarchy the submission was made. */
51
+ interface ReportHierarchyContext {
52
+ enterpriseId?: number;
53
+ businessUnitId?: number;
54
+ siteId?: number;
55
+ areaId?: number;
56
+ assetId?: number;
57
+ }
58
+ /** The authenticated user, as much as the host can supply. */
59
+ interface ReportSubmitter {
60
+ /** JWT `openId` claim — the host must NOT trust name/email over this. */
61
+ openId?: string;
62
+ name?: string;
63
+ email?: string;
64
+ }
65
+ /** An attached screenshot: base64 WITHOUT the `data:...;base64,` prefix. */
66
+ interface ReportScreenshot {
67
+ dataBase64: string;
68
+ mime: string;
69
+ }
34
70
  interface IncidentReport {
35
71
  category: ReportCategory;
36
72
  description: string;
@@ -41,44 +77,52 @@ interface IncidentReport {
41
77
  moduleName: string;
42
78
  /** ISO timestamp */
43
79
  timestamp: string;
44
- /** User who submitted */
45
- submittedBy?: string;
46
- /** Hierarchy context at time of submission */
47
- hierarchyContext?: {
48
- enterpriseId?: number;
49
- businessUnitId?: number;
50
- siteId?: number;
51
- areaId?: number;
52
- assetId?: number;
53
- };
80
+ submittedBy?: ReportSubmitter;
81
+ hierarchyContext?: ReportHierarchyContext;
54
82
  }
55
83
  interface FeedbackReport {
56
84
  category: FeedbackCategory;
57
- /** Optional — short summary entered in the dialog before the description. */
58
- subject?: string;
59
- description: string;
85
+ /** Canonical service slug the feedback is about (from the picker). */
86
+ serviceSlug: string;
87
+ /** Optional short one-liner shown above the detail. */
88
+ summary?: string;
89
+ /** Required detail body. */
90
+ details: string;
91
+ /** "Is this blocking you?" — drives priority server-side. */
92
+ isBlocking: boolean;
93
+ /** Human-readable originating module ("OEE Manager", "SQDCP", …). */
60
94
  moduleName: string;
61
95
  /** ISO timestamp */
62
96
  timestamp: string;
63
- /** User who submitted */
64
- submittedBy?: string;
65
- /** Page/route where feedback was submitted */
97
+ /** Route the submitter was on. */
66
98
  pageContext?: string;
99
+ submittedBy?: ReportSubmitter;
100
+ screenshot?: ReportScreenshot;
67
101
  }
102
+ interface OplyticsService {
103
+ slug: string;
104
+ label: string;
105
+ }
106
+ /**
107
+ * The services a user can attribute feedback to. Kept here so every subdomain's
108
+ * picker shows the same list; a host can narrow or override it via the
109
+ * `services` prop. Slugs match Portal's `platform_feedback.serviceSlug`.
110
+ */
111
+ declare const OPLYTICS_SERVICES: OplyticsService[];
68
112
  interface ReportingToolbarConfig {
69
- /** Service/module name (e.g., "SQDCP", "OEE Manager") */
113
+ /** Service/module name (e.g. "SQDCP", "OEE Manager"). */
70
114
  moduleName: string;
71
- /** Whether to show incident reporting buttons (default: true) */
115
+ /** Whether to show the Report group at all (default: true). */
72
116
  showIncidentReporting?: boolean;
73
- /** Whether to show feedback buttons (default: true) */
117
+ /** Whether to show the Feedback group at all (default: true). */
74
118
  showFeedback?: boolean;
75
- /** Custom report categories to show (default: all three) */
119
+ /** Report categories to show (default: all three). */
76
120
  reportCategories?: ReportCategory[];
77
- /** Custom feedback categories to show (default: both) */
121
+ /** Feedback categories to show (default: both). */
78
122
  feedbackCategories?: FeedbackCategory[];
79
- /** Handler called when an incident report is submitted */
123
+ /** Called when an incident report is submitted (not wired yet). */
80
124
  onReportSubmit: (report: IncidentReport) => Promise<void> | void;
81
- /** Handler called when feedback is submitted */
125
+ /** Called when feedback is submitted — the host POSTs it to Portal. */
82
126
  onFeedbackSubmit: (feedback: FeedbackReport) => Promise<void> | void;
83
127
  }
84
128
  interface ReportButtonDef {
@@ -95,14 +139,28 @@ interface FeedbackButtonDef {
95
139
  color: string;
96
140
  description: string;
97
141
  }
98
- /** Standard incident report buttons — consistent across all subdomains */
99
142
  declare const REPORT_BUTTONS: ReportButtonDef[];
100
- /** Standard feedback buttons — consistent across all subdomains */
101
143
  declare const FEEDBACK_BUTTONS: FeedbackButtonDef[];
102
- /** Create a default ReportingToolbarConfig with sensible defaults */
144
+ /** Create a default ReportingToolbarConfig with sensible defaults. */
103
145
  declare function createReportingConfig(moduleName: string, handlers: {
104
146
  onReportSubmit: (report: IncidentReport) => Promise<void> | void;
105
147
  onFeedbackSubmit: (feedback: FeedbackReport) => Promise<void> | void;
106
148
  }): ReportingToolbarConfig;
149
+ /**
150
+ * Read a picked File into `{ dataBase64, mime }` (no data: prefix), rejecting
151
+ * non-images and anything over `maxBytes` decoded. Pure-ish (needs FileReader);
152
+ * exported so the size rule can be unit-tested and reused.
153
+ */
154
+ declare const FEEDBACK_SCREENSHOT_MAX_BYTES: number;
155
+ declare function isAcceptableScreenshot(file: {
156
+ type: string;
157
+ size: number;
158
+ }, maxBytes?: number): {
159
+ ok: true;
160
+ } | {
161
+ ok: false;
162
+ reason: string;
163
+ };
164
+ declare function readFileAsScreenshot(file: File): Promise<ReportScreenshot>;
107
165
 
108
- export { FEEDBACK_BUTTONS, type FeedbackButtonDef, type FeedbackCategory, type FeedbackReport, type IncidentReport, REPORT_BUTTONS, type ReportButtonDef, type ReportCategory, ReportingToolbar, type ReportingToolbarConfig, type ReportingToolbarProps, createReportingConfig };
166
+ export { FEEDBACK_BUTTONS, FEEDBACK_SCREENSHOT_MAX_BYTES, type FeedbackButtonDef, type FeedbackCategory, type FeedbackReport, type IncidentReport, OPLYTICS_SERVICES, type OplyticsService, REPORT_BUTTONS, type ReportButtonDef, type ReportCategory, type ReportHierarchyContext, type ReportScreenshot, type ReportSubmitter, ReportingToolbar, type ReportingToolbarConfig, type ReportingToolbarProps, createReportingConfig, isAcceptableScreenshot, readFileAsScreenshot };