@uipath/du-utils 1.0.0-rc.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/CHANGELOG.md +26 -0
- package/LICENSE +9 -0
- package/README.md +191 -0
- package/package.json +30 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +7 -0
- package/src/index.js.map +1 -0
- package/src/lib/load-web-component.d.ts +37 -0
- package/src/lib/load-web-component.js +145 -0
- package/src/lib/load-web-component.js.map +1 -0
- package/src/lib/shared/classification-station-wc.d.ts +181 -0
- package/src/lib/shared/classification-station-wc.js +3 -0
- package/src/lib/shared/classification-station-wc.js.map +1 -0
- package/src/lib/shared/index.d.ts +4 -0
- package/src/lib/shared/index.js +8 -0
- package/src/lib/shared/index.js.map +1 -0
- package/src/lib/shared/types.d.ts +11 -0
- package/src/lib/shared/types.js +10 -0
- package/src/lib/shared/types.js.map +1 -0
- package/src/lib/shared/validation-station-wc.d.ts +487 -0
- package/src/lib/shared/validation-station-wc.js +11 -0
- package/src/lib/shared/validation-station-wc.js.map +1 -0
- package/src/lib/shared/wc-lifecycle.d.ts +84 -0
- package/src/lib/shared/wc-lifecycle.js +81 -0
- package/src/lib/shared/wc-lifecycle.js.map +1 -0
- package/src/lib/url.util.d.ts +7 -0
- package/src/lib/url.util.js +18 -0
- package/src/lib/url.util.js.map +1 -0
- package/src/lib/wc-shared-styles.d.ts +31 -0
- package/src/lib/wc-shared-styles.js +204 -0
- package/src/lib/wc-shared-styles.js.map +1 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./wc-lifecycle"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./validation-station-wc"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./classification-station-wc"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../libs/du/shared/util/du-utils/src/lib/shared/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,yDAA+B;AAC/B,kEAAwC;AACxC,sEAA4C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WcHost = void 0;
|
|
4
|
+
var WcHost;
|
|
5
|
+
(function (WcHost) {
|
|
6
|
+
WcHost["Apps"] = "apps";
|
|
7
|
+
WcHost["ActionCenter"] = "action-center";
|
|
8
|
+
WcHost["Standalone"] = "standalone";
|
|
9
|
+
})(WcHost || (exports.WcHost = WcHost = {}));
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../../libs/du/shared/util/du-utils/src/lib/shared/types.ts"],"names":[],"mappings":";;;AAOA,IAAY,MAIX;AAJD,WAAY,MAAM;IACd,uBAAa,CAAA;IACb,wCAA8B,CAAA;IAC9B,mCAAyB,CAAA;AAC7B,CAAC,EAJW,MAAM,sBAAN,MAAM,QAIjB"}
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import type { ContentValidationData, Criticality, DocumentTaxonomy, ExtractionResult, LogicalOperator, ResultsDataPoint, ResultsValue } from '@uipath/uipath-typescript/document-understanding';
|
|
2
|
+
export type { ContentValidationData };
|
|
3
|
+
/**
|
|
4
|
+
* The details of the selected field and value.
|
|
5
|
+
* Emitted whenever a field value is selected or changed in the UI.
|
|
6
|
+
*
|
|
7
|
+
* Property names are PascalCase because they are part of the wire contract.
|
|
8
|
+
*/
|
|
9
|
+
export interface IFieldValueDetailsDto {
|
|
10
|
+
Field: ResultsDataPoint;
|
|
11
|
+
FieldValueIndex: number;
|
|
12
|
+
FieldValue?: ResultsValue;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The evaluated result of a rule set for the value at `Index` in the field.
|
|
16
|
+
* `Index` is -1 when the field has no extracted value.
|
|
17
|
+
*
|
|
18
|
+
* Property names are PascalCase because they are part of the wire contract.
|
|
19
|
+
*/
|
|
20
|
+
export interface EvaluatedBusinessRulesForFieldValueDto {
|
|
21
|
+
FieldId: string;
|
|
22
|
+
ParentFieldId?: string;
|
|
23
|
+
FieldName: string;
|
|
24
|
+
/**
|
|
25
|
+
* This can be the index of the value when a field is multi value
|
|
26
|
+
* or the row index when the field is a table
|
|
27
|
+
* or -1 for rules defined on fields without value
|
|
28
|
+
*/
|
|
29
|
+
Index: number;
|
|
30
|
+
IsValid: boolean;
|
|
31
|
+
Criticality: Criticality;
|
|
32
|
+
LogicalOperator: LogicalOperator;
|
|
33
|
+
Rules: EvaluatedBusinessRuleDetailsDto[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A single evaluated business rule within an {@link EvaluatedBusinessRulesForFieldValueDto}.
|
|
37
|
+
*
|
|
38
|
+
* Property names are PascalCase because they are part of the wire contract.
|
|
39
|
+
*/
|
|
40
|
+
export interface EvaluatedBusinessRuleDetailsDto {
|
|
41
|
+
RuleName: string;
|
|
42
|
+
RuleMessage: string;
|
|
43
|
+
IsValid: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface IValidationStationOptions {
|
|
46
|
+
hideSubmitButton?: boolean;
|
|
47
|
+
hideReportAsExceptionButton?: boolean;
|
|
48
|
+
hideDocumentTypeField?: boolean;
|
|
49
|
+
hideFields?: boolean;
|
|
50
|
+
hideBusinessRules?: boolean;
|
|
51
|
+
fieldsSectionPosition?: 'left' | 'right';
|
|
52
|
+
enableUserPreferences?: boolean;
|
|
53
|
+
userPreferencesKeySuffix?: string;
|
|
54
|
+
/**
|
|
55
|
+
* If true, extractionResultChanged output will emit the internal state mapped to ExtractionResult on each internal state change
|
|
56
|
+
*/
|
|
57
|
+
emitDtoStateChanges?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface DocumentViewerOptions {
|
|
60
|
+
floatingButtonsOptions?: DocumentViewerFloatingButtonsOptions;
|
|
61
|
+
/**
|
|
62
|
+
* Auto-rotate a page when a rotation type is detected across a proportion
|
|
63
|
+
* of the page's sections (as defined in the document DOM) greater than this
|
|
64
|
+
* threshold.
|
|
65
|
+
*
|
|
66
|
+
* Accepted values: (0,1]
|
|
67
|
+
* default value: 0.7
|
|
68
|
+
*/
|
|
69
|
+
autoRotationThreshold?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Set to true to turn off selection in the document viewer, for
|
|
72
|
+
* applications that don't need the selection feature. This also hides the
|
|
73
|
+
* interaction-type button, since it only switches between selection modes.
|
|
74
|
+
*/
|
|
75
|
+
disableSelection?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface DocumentViewerFloatingButtonsOptions {
|
|
78
|
+
hideTextView?: boolean;
|
|
79
|
+
hideInteractionTypeButton?: boolean;
|
|
80
|
+
defaultInteractionType?: InteractionType;
|
|
81
|
+
hideSwitchPanelSidesButton?: boolean;
|
|
82
|
+
hideKeyboardShortcutsButton?: boolean;
|
|
83
|
+
hideSearch?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export declare enum InteractionType {
|
|
86
|
+
Tokens = "Tokens",
|
|
87
|
+
Area = "Area",
|
|
88
|
+
UserChoice = "UserChoice",
|
|
89
|
+
Text = "Text"
|
|
90
|
+
}
|
|
91
|
+
export interface ISelectAndFocusFieldValueParams {
|
|
92
|
+
fieldId: string;
|
|
93
|
+
valueIndex?: number;
|
|
94
|
+
emitFieldValueSelected?: boolean;
|
|
95
|
+
parentId?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface ISetFieldValueParameters {
|
|
98
|
+
fieldId: string;
|
|
99
|
+
value?: string;
|
|
100
|
+
options?: {
|
|
101
|
+
/**
|
|
102
|
+
* Accepted values: between 0 and 1
|
|
103
|
+
* default: 1
|
|
104
|
+
*/
|
|
105
|
+
confidence?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Whether to set the new value as confirmed
|
|
108
|
+
* default: true
|
|
109
|
+
*/
|
|
110
|
+
confirm?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* It is only relevant for multi-value fields
|
|
113
|
+
* index is provided:
|
|
114
|
+
* if there is a value at the given index, value is overwritten
|
|
115
|
+
* if index > number of existing values, new value is appended
|
|
116
|
+
* else: new value is appended
|
|
117
|
+
*/
|
|
118
|
+
index?: number;
|
|
119
|
+
/**
|
|
120
|
+
* When false, it will remove the document reference from the extracted value
|
|
121
|
+
* If field has requires reference in taxonomy and flag is false, set will return an error
|
|
122
|
+
* default: true
|
|
123
|
+
*/
|
|
124
|
+
keepReference?: boolean;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export interface ISetTableCellValueParameters {
|
|
128
|
+
tableId: string;
|
|
129
|
+
columnId: string;
|
|
130
|
+
rowIndex?: number;
|
|
131
|
+
value?: string;
|
|
132
|
+
options?: {
|
|
133
|
+
/**
|
|
134
|
+
* Accepted values: between 0 and 1
|
|
135
|
+
* default: 1
|
|
136
|
+
*/
|
|
137
|
+
confidence?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Whether to set the new value as confirmed
|
|
140
|
+
* default: true
|
|
141
|
+
*/
|
|
142
|
+
confirm?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* When false, it will remove the document reference from the extracted value
|
|
145
|
+
* default: true
|
|
146
|
+
*/
|
|
147
|
+
keepReference?: boolean;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
export interface IDeleteFieldValueParameters {
|
|
151
|
+
fieldId: string;
|
|
152
|
+
index?: number;
|
|
153
|
+
/**
|
|
154
|
+
* When true, it confirms that the value is missing
|
|
155
|
+
* default: true
|
|
156
|
+
*/
|
|
157
|
+
operatorConfirmed?: boolean;
|
|
158
|
+
}
|
|
159
|
+
export interface IDeleteTableCellValueParameters {
|
|
160
|
+
tableId: string;
|
|
161
|
+
columnId: string;
|
|
162
|
+
rowIndex?: number;
|
|
163
|
+
/**
|
|
164
|
+
* When true, it confirms that the value is missing
|
|
165
|
+
* default: true
|
|
166
|
+
*/
|
|
167
|
+
operatorConfirmed?: boolean;
|
|
168
|
+
}
|
|
169
|
+
export interface IVsWcActionResultOutput {
|
|
170
|
+
success: boolean;
|
|
171
|
+
error?: string;
|
|
172
|
+
}
|
|
173
|
+
export type ISaveResult = IVsWcActionResultOutput;
|
|
174
|
+
export interface ISetFieldValueResult extends IVsWcActionResultOutput {
|
|
175
|
+
fieldId: string;
|
|
176
|
+
}
|
|
177
|
+
export interface ISetTableCellValueResult extends IVsWcActionResultOutput {
|
|
178
|
+
tableId: string;
|
|
179
|
+
columnId: string;
|
|
180
|
+
}
|
|
181
|
+
export interface IDeleteFieldValueResult extends IVsWcActionResultOutput {
|
|
182
|
+
fieldId: string;
|
|
183
|
+
}
|
|
184
|
+
export interface IDeleteTableCellValueResult extends IVsWcActionResultOutput {
|
|
185
|
+
tableId: string;
|
|
186
|
+
columnId: string;
|
|
187
|
+
}
|
|
188
|
+
export interface SetFieldValueByPath {
|
|
189
|
+
path: ExtractedPathSegment[];
|
|
190
|
+
update: Partial<FieldValueUpdate>;
|
|
191
|
+
}
|
|
192
|
+
export interface SelectAndFocusFieldValueByPath {
|
|
193
|
+
path: ExtractedPathSegment[];
|
|
194
|
+
}
|
|
195
|
+
export interface DeleteFieldValueByPath {
|
|
196
|
+
path: ExtractedPathSegment[];
|
|
197
|
+
}
|
|
198
|
+
export interface ExtractedPathSegment {
|
|
199
|
+
fieldName: string;
|
|
200
|
+
valueIndex: number;
|
|
201
|
+
}
|
|
202
|
+
export interface FieldValueUpdate {
|
|
203
|
+
Value: string;
|
|
204
|
+
DeleteReference: boolean;
|
|
205
|
+
Confidence: number;
|
|
206
|
+
OperatorConfirmed: boolean;
|
|
207
|
+
}
|
|
208
|
+
export type SetFieldValueByPathResult = IVsWcActionResultOutput;
|
|
209
|
+
export type SelectAndFocusFieldValueByPathResult = IVsWcActionResultOutput;
|
|
210
|
+
export type DeleteFieldValueByPathResult = IVsWcActionResultOutput;
|
|
211
|
+
export type GoToPageTarget = number | 'next' | 'previous' | 'first' | 'last';
|
|
212
|
+
export interface GoToPage {
|
|
213
|
+
/**
|
|
214
|
+
* Page to navigate to. A number is a 1-based page number; the keywords move
|
|
215
|
+
* relative to the current page (`next`/`previous`) or to the document bounds
|
|
216
|
+
* (`first`/`last`). Out-of-range numbers are clamped to the first/last page.
|
|
217
|
+
*/
|
|
218
|
+
target: GoToPageTarget;
|
|
219
|
+
/**
|
|
220
|
+
* Scroll behavior used to bring the page into view.
|
|
221
|
+
* @default 'instant'
|
|
222
|
+
*/
|
|
223
|
+
behavior?: ScrollBehavior;
|
|
224
|
+
}
|
|
225
|
+
export interface GoToPageResult extends IVsWcActionResultOutput {
|
|
226
|
+
/** The resolved 1-based page number after clamping, or -1 when the command failed. */
|
|
227
|
+
pageNumber: number;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Events emitted by the validation-station web component.
|
|
231
|
+
*/
|
|
232
|
+
export interface IVsWcSharedEventMap {
|
|
233
|
+
/** Fires once when the component has finished loading. */
|
|
234
|
+
loaded: boolean;
|
|
235
|
+
/** Fires when the user has unsaved changes (true) or the state is clean (false). */
|
|
236
|
+
dirty: boolean;
|
|
237
|
+
/** Fires when the user changes the document type. Detail is the new document type ID. */
|
|
238
|
+
documentTypeChanged: string;
|
|
239
|
+
/** Fires on every extraction result change when IValidationStationOptions.emitDtoStateChanges is true. */
|
|
240
|
+
extractionResultChanged: ExtractionResult;
|
|
241
|
+
/** Fires when the user selects a field value. */
|
|
242
|
+
fieldValueSelected: IFieldValueDetailsDto;
|
|
243
|
+
/** Fires when the user edits a field value. */
|
|
244
|
+
fieldValueChanged: IFieldValueDetailsDto;
|
|
245
|
+
/** Fires after business rules are evaluated. */
|
|
246
|
+
businessRulesEvaluated: EvaluatedBusinessRulesForFieldValueDto[];
|
|
247
|
+
/** Fires when the component's validity changes. Detail is true when there are no critical (Must) invalid business rules. */
|
|
248
|
+
isValid: boolean;
|
|
249
|
+
/** Fires when the fields panel width changes. Detail is the width in pixels. */
|
|
250
|
+
fieldsPanelWidthChanged: number;
|
|
251
|
+
/** Fires when the fields panel moves to the other side of the document viewer. */
|
|
252
|
+
fieldsPanelSideChanged: 'left' | 'right';
|
|
253
|
+
/** Results of the setFieldValue command input, one entry per field. */
|
|
254
|
+
setFieldValueResult: ISetFieldValueResult[];
|
|
255
|
+
/** Results of the setTableCellValue command input, one entry per cell. */
|
|
256
|
+
setTableCellValueResult: ISetTableCellValueResult[];
|
|
257
|
+
/** Results of the deleteFieldValue command input, one entry per field. */
|
|
258
|
+
deleteFieldValueResult: IDeleteFieldValueResult[];
|
|
259
|
+
/** Results of the deleteTableCellValue command input, one entry per cell. */
|
|
260
|
+
deleteTableCellValueResult: IDeleteTableCellValueResult[];
|
|
261
|
+
/** Result of the selectAndFocusFieldValue command input. */
|
|
262
|
+
selectAndFocusFieldValueResult: IVsWcActionResultOutput;
|
|
263
|
+
/** Result of the setFieldValueByPath command input. */
|
|
264
|
+
setFieldValueByPathResult: SetFieldValueByPathResult;
|
|
265
|
+
/** Result of the selectAndFocusFieldValueByPath command input. */
|
|
266
|
+
selectAndFocusFieldValueByPathResult: SelectAndFocusFieldValueByPathResult;
|
|
267
|
+
/** Result of the deleteFieldValueByPath command input. */
|
|
268
|
+
deleteFieldValueByPathResult: DeleteFieldValueByPathResult;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Maps every custom-event name emitted by the standard validation-station web component
|
|
272
|
+
* to the type carried in CustomEvent.detail.
|
|
273
|
+
*/
|
|
274
|
+
export interface IValidationStationWcEventMap extends IVsWcSharedEventMap {
|
|
275
|
+
/** Result of the save command input. */
|
|
276
|
+
saveResult: ISaveResult;
|
|
277
|
+
/** Fires once when the taxonomy has been loaded from the backend. */
|
|
278
|
+
taxonomyLoaded: DocumentTaxonomy;
|
|
279
|
+
/** Fires once when the extraction result has been loaded from the backend. */
|
|
280
|
+
extractionResultLoaded: ExtractionResult;
|
|
281
|
+
/** Fires when the Action Center task has been submitted successfully. Detail is the task ID. */
|
|
282
|
+
actionCenterTaskComplete: number;
|
|
283
|
+
/** Fires when the Action Center task has been reported as exception. Detail is the task ID. */
|
|
284
|
+
actionCenterTaskReportAsException: number;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Internal base for the VS element interface.
|
|
288
|
+
* @internal Consumers should use IValidationStationWcElement directly.
|
|
289
|
+
*/
|
|
290
|
+
export interface IVsWcBaseElement<TEventMap> extends HTMLElement {
|
|
291
|
+
/** Visual theme applied to the component. @default 'light' */
|
|
292
|
+
theme: 'light' | 'dark' | 'light-hc' | 'dark-hc';
|
|
293
|
+
/** BCP-47 language code for the UI. @default 'en' */
|
|
294
|
+
language: string;
|
|
295
|
+
/** When true, the component renders in read-only mode. @default false */
|
|
296
|
+
isReadonly: boolean;
|
|
297
|
+
/** When true, a "Save as draft" action is available. @default false */
|
|
298
|
+
enableSaveAsDraft: boolean;
|
|
299
|
+
/** Fine-grained UI feature flags. */
|
|
300
|
+
options: IValidationStationOptions;
|
|
301
|
+
/** Trigger a save operation. Set { validate: true } to validate before saving. */
|
|
302
|
+
save: {
|
|
303
|
+
validate: boolean;
|
|
304
|
+
} | undefined;
|
|
305
|
+
/** Trigger a discard-changes operation. Assign { value: true } to confirm. */
|
|
306
|
+
discardChanges: {
|
|
307
|
+
value: boolean;
|
|
308
|
+
} | undefined;
|
|
309
|
+
/** Set one or more field values programmatically. Listen to setFieldValueResult for outcomes. */
|
|
310
|
+
setFieldValue: ISetFieldValueParameters[] | undefined;
|
|
311
|
+
/** Set one or more table cell values programmatically. Listen to setTableCellValueResult for outcomes. */
|
|
312
|
+
setTableCellValue: ISetTableCellValueParameters[] | undefined;
|
|
313
|
+
/** Delete one or more field values programmatically. Listen to deleteFieldValueResult for outcomes. */
|
|
314
|
+
deleteFieldValue: IDeleteFieldValueParameters[] | undefined;
|
|
315
|
+
/** Delete one or more table cell values programmatically. Listen to deleteTableCellValueResult for outcomes. */
|
|
316
|
+
deleteTableCellValue: IDeleteTableCellValueParameters[] | undefined;
|
|
317
|
+
/** Scroll to and focus a specific field value. Listen to selectAndFocusFieldValueResult for the outcome. */
|
|
318
|
+
selectAndFocusFieldValue: ISelectAndFocusFieldValueParams | undefined;
|
|
319
|
+
/** Set field values by path. Listen to setFieldValueByPathResult for outcomes. */
|
|
320
|
+
setFieldValueByPath: SetFieldValueByPath | undefined;
|
|
321
|
+
/** Select the field in the extraction panel by path; if the value has a document reference, focus it in the PDF viewer.
|
|
322
|
+
* Listen to selectAndFocusFieldValueByPathResult for the outcome. */
|
|
323
|
+
selectAndFocusFieldValueByPath: SelectAndFocusFieldValueByPath | undefined;
|
|
324
|
+
/** Delete a field value by path. Listen to deleteFieldValueByPathResult for outcomes. */
|
|
325
|
+
deleteFieldValueByPath: DeleteFieldValueByPath | undefined;
|
|
326
|
+
addEventListener<K extends keyof TEventMap>(type: K, listener: (event: CustomEvent<TEventMap[K]>) => void, options?: boolean | AddEventListenerOptions): void;
|
|
327
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
328
|
+
removeEventListener<K extends keyof TEventMap>(type: K, listener: (event: CustomEvent<TEventMap[K]>) => void, options?: boolean | EventListenerOptions): void;
|
|
329
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Strongly-typed interface for <ui-du-validation-station-wc-element>.
|
|
333
|
+
*
|
|
334
|
+
* Obtain a reference via document.querySelector or a React/Angular ref, then
|
|
335
|
+
* set properties and attach event listeners through this interface.
|
|
336
|
+
*
|
|
337
|
+
* @example React 18 usage
|
|
338
|
+
* ```tsx
|
|
339
|
+
* const ref = useRef<IValidationStationWcElement | null>(null);
|
|
340
|
+
*
|
|
341
|
+
* useEffect(() => {
|
|
342
|
+
* const el = ref.current;
|
|
343
|
+
* if (!el) return;
|
|
344
|
+
* el.platform = { organizationName: 'acme', tenantId: 't1' };
|
|
345
|
+
* const onLoaded = (e: CustomEvent<boolean>) => setReady(e.detail);
|
|
346
|
+
* el.addEventListener('loaded', onLoaded);
|
|
347
|
+
* return () => el.removeEventListener('loaded', onLoaded);
|
|
348
|
+
* }, []);
|
|
349
|
+
*
|
|
350
|
+
* return <ui-du-validation-station-wc-element ref={ref} theme="light" />;
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
export interface IValidationStationWcElement extends IVsWcBaseElement<IValidationStationWcEventMap> {
|
|
354
|
+
/** Bearer token for delegated authentication. */
|
|
355
|
+
authToken: string | undefined;
|
|
356
|
+
/**
|
|
357
|
+
* Platform context — must be set before the component can make API calls.
|
|
358
|
+
* Set as a JS property (not an HTML attribute) for complex object values.
|
|
359
|
+
*/
|
|
360
|
+
platform: {
|
|
361
|
+
organizationName: string;
|
|
362
|
+
tenantId: string;
|
|
363
|
+
} | undefined;
|
|
364
|
+
/**
|
|
365
|
+
* Document data contract provided by the UiPath Create Task activity.
|
|
366
|
+
* Set as a JS property (not an HTML attribute) for complex object values.
|
|
367
|
+
*/
|
|
368
|
+
contentValidationData: ContentValidationData | undefined;
|
|
369
|
+
/** Action Center task ID associated with the document. */
|
|
370
|
+
actionCenterTaskId: number | null;
|
|
371
|
+
/** Organization unit ID for scoped API calls. */
|
|
372
|
+
organizationUnitId: number | null;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Extends IValidationStationWcElement with an explicit teardown method.
|
|
376
|
+
*
|
|
377
|
+
* The persistent element suppresses disconnectedCallback() to survive portal
|
|
378
|
+
* detachments (e.g. tab switches). Call forceDestroy() when the element is
|
|
379
|
+
* being permanently removed (ngOnDestroy / useEffect cleanup / componentWillUnmount).
|
|
380
|
+
*/
|
|
381
|
+
export interface IPersistentValidationStationWcElement extends IValidationStationWcElement {
|
|
382
|
+
/**
|
|
383
|
+
* Explicitly tears down the inner Angular component.
|
|
384
|
+
* Must be called when the element is being permanently removed.
|
|
385
|
+
*/
|
|
386
|
+
forceDestroy(): void;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* JSX props shared by the VS element variants.
|
|
390
|
+
* Covers configuration inputs, command inputs, and common HTML attributes.
|
|
391
|
+
*/
|
|
392
|
+
export interface IVsWcSharedJsxProps {
|
|
393
|
+
theme?: 'light' | 'dark' | 'light-hc' | 'dark-hc';
|
|
394
|
+
language?: string;
|
|
395
|
+
/** JS property form. */
|
|
396
|
+
isReadonly?: boolean;
|
|
397
|
+
/** Attribute form (kebab-case). Coerced via `booleanAttribute` transform. */
|
|
398
|
+
'is-readonly'?: boolean;
|
|
399
|
+
/** JS property form. */
|
|
400
|
+
enableSaveAsDraft?: boolean;
|
|
401
|
+
/** Attribute form (kebab-case). Coerced via `booleanAttribute` transform. */
|
|
402
|
+
'enable-save-as-draft'?: boolean;
|
|
403
|
+
options?: IValidationStationOptions;
|
|
404
|
+
save?: {
|
|
405
|
+
validate: boolean;
|
|
406
|
+
};
|
|
407
|
+
discardChanges?: {
|
|
408
|
+
value: boolean;
|
|
409
|
+
};
|
|
410
|
+
setFieldValue?: ISetFieldValueParameters[];
|
|
411
|
+
setTableCellValue?: ISetTableCellValueParameters[];
|
|
412
|
+
deleteFieldValue?: IDeleteFieldValueParameters[];
|
|
413
|
+
deleteTableCellValue?: IDeleteTableCellValueParameters[];
|
|
414
|
+
selectAndFocusFieldValue?: ISelectAndFocusFieldValueParams;
|
|
415
|
+
setFieldValueByPath?: SetFieldValueByPath;
|
|
416
|
+
selectAndFocusFieldValueByPath?: SelectAndFocusFieldValueByPath;
|
|
417
|
+
deleteFieldValueByPath?: DeleteFieldValueByPath;
|
|
418
|
+
id?: string;
|
|
419
|
+
className?: string;
|
|
420
|
+
class?: string;
|
|
421
|
+
style?: string | Record<string, string | number>;
|
|
422
|
+
title?: string;
|
|
423
|
+
role?: string;
|
|
424
|
+
tabIndex?: number;
|
|
425
|
+
part?: string;
|
|
426
|
+
slot?: string;
|
|
427
|
+
draggable?: boolean;
|
|
428
|
+
hidden?: boolean;
|
|
429
|
+
[dataAttr: `data-${string}`]: string | number | boolean | null | undefined;
|
|
430
|
+
[ariaAttr: `aria-${string}`]: string | number | boolean | null | undefined;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Props for <ui-du-validation-station-wc-element> in React JSX.
|
|
434
|
+
*
|
|
435
|
+
* React 18:
|
|
436
|
+
* - String scalar inputs (`theme`, `language`, `authToken`/`auth-token`) can be
|
|
437
|
+
* passed as JSX attributes directly.
|
|
438
|
+
* - Boolean inputs (`isReadonly`/`is-readonly`, `enableSaveAsDraft`/`enable-save-as-draft`)
|
|
439
|
+
* use `booleanAttribute` transform, so both camelCase JS property and kebab-case
|
|
440
|
+
* attribute forms work correctly.
|
|
441
|
+
* - Numeric inputs (`actionCenterTaskId`/`action-center-task-id`,
|
|
442
|
+
* `organizationUnitId`/`organization-unit-id`) use a number coercion transform,
|
|
443
|
+
* so both camelCase JS property and kebab-case attribute forms work correctly.
|
|
444
|
+
* - Complex object props (`platform`, `contentValidationData`, `options`, and all
|
|
445
|
+
* command payloads) must be set via a ref as JS properties, because React 18
|
|
446
|
+
* serialises JSX props as HTML attributes and Angular Elements cannot deserialise
|
|
447
|
+
* JSON strings back into objects.
|
|
448
|
+
*
|
|
449
|
+
* React 19:
|
|
450
|
+
* - Supports passing props as JS properties from JSX. Complex objects can be
|
|
451
|
+
* passed directly without a ref.
|
|
452
|
+
*/
|
|
453
|
+
export interface IValidationStationWcJsxProps extends IVsWcSharedJsxProps {
|
|
454
|
+
/** JS property form. */
|
|
455
|
+
authToken?: string;
|
|
456
|
+
/** Attribute form (kebab-case string). */
|
|
457
|
+
'auth-token'?: string;
|
|
458
|
+
/** JS property form. */
|
|
459
|
+
actionCenterTaskId?: number | null;
|
|
460
|
+
/** Attribute form (kebab-case). Coerced via `numberAttribute` transform. */
|
|
461
|
+
'action-center-task-id'?: number | null;
|
|
462
|
+
/** JS property form. */
|
|
463
|
+
organizationUnitId?: number | null;
|
|
464
|
+
/** Attribute form (kebab-case). Coerced via `numberAttribute` transform. */
|
|
465
|
+
'organization-unit-id'?: number | null;
|
|
466
|
+
platform?: {
|
|
467
|
+
organizationName: string;
|
|
468
|
+
tenantId: string;
|
|
469
|
+
};
|
|
470
|
+
contentValidationData?: ContentValidationData;
|
|
471
|
+
}
|
|
472
|
+
/** Props for <ui-du-validation-station-wc-persistent-element> in React JSX. */
|
|
473
|
+
export type IPersistentValidationStationWcJsxProps = IValidationStationWcJsxProps;
|
|
474
|
+
declare global {
|
|
475
|
+
interface HTMLElementTagNameMap {
|
|
476
|
+
'ui-du-validation-station-wc-element': IValidationStationWcElement;
|
|
477
|
+
'ui-du-validation-station-wc-persistent-element': IPersistentValidationStationWcElement;
|
|
478
|
+
}
|
|
479
|
+
namespace React {
|
|
480
|
+
namespace JSX {
|
|
481
|
+
interface IntrinsicElements {
|
|
482
|
+
'ui-du-validation-station-wc-element': IValidationStationWcJsxProps;
|
|
483
|
+
'ui-du-validation-station-wc-persistent-element': IPersistentValidationStationWcJsxProps;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InteractionType = void 0;
|
|
4
|
+
var InteractionType;
|
|
5
|
+
(function (InteractionType) {
|
|
6
|
+
InteractionType["Tokens"] = "Tokens";
|
|
7
|
+
InteractionType["Area"] = "Area";
|
|
8
|
+
InteractionType["UserChoice"] = "UserChoice";
|
|
9
|
+
InteractionType["Text"] = "Text";
|
|
10
|
+
})(InteractionType || (exports.InteractionType = InteractionType = {}));
|
|
11
|
+
//# sourceMappingURL=validation-station-wc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-station-wc.js","sourceRoot":"","sources":["../../../../../../../../../libs/du/shared/util/du-utils/src/lib/shared/validation-station-wc.ts"],"names":[],"mappings":";;;AA2HA,IAAY,eAKX;AALD,WAAY,eAAe;IACvB,oCAAiB,CAAA;IACjB,gCAAa,CAAA;IACb,4CAAyB,CAAA;IACzB,gCAAa,CAAA;AACjB,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructor type for an Angular Elements custom-element class with the
|
|
3
|
+
* connect/disconnect lifecycle methods exposed.
|
|
4
|
+
*
|
|
5
|
+
* Background — why this exists:
|
|
6
|
+
*
|
|
7
|
+
* - `customElements.get(tagName)` returns the generic
|
|
8
|
+
* `CustomElementConstructor | undefined`, whose instance is just `HTMLElement`.
|
|
9
|
+
* `connectedCallback` / `disconnectedCallback` are NOT visible on it, so a
|
|
10
|
+
* subclass cannot `super.disconnectedCallback()` without a structural cast.
|
|
11
|
+
* - `createCustomElement(...)` from `@angular/elements` returns a constructor
|
|
12
|
+
* whose instance type DOES expose the lifecycle methods (via `NgElement`).
|
|
13
|
+
*
|
|
14
|
+
* The union of the two sources collapses to the lower-information
|
|
15
|
+
* `CustomElementConstructor`. Use this alias to express the lifecycle-aware
|
|
16
|
+
* constructor shape we actually want to extend.
|
|
17
|
+
*/
|
|
18
|
+
export type IWcLifecycleConstructor = new () => HTMLElement & {
|
|
19
|
+
connectedCallback(): void;
|
|
20
|
+
disconnectedCallback(): void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Returns the constructor for a previously-registered custom element, falling
|
|
24
|
+
* back to the provided constructor if the element isn't yet registered.
|
|
25
|
+
*
|
|
26
|
+
* Centralises the structural cast required to expose the connect/disconnect
|
|
27
|
+
* lifecycle methods (see {@link IWcLifecycleConstructor}). Use this when
|
|
28
|
+
* defining a "persistent" subclass that overrides those methods.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const Base = getCustomElementConstructorWithLifecycle(
|
|
33
|
+
* 'ui-foo-element',
|
|
34
|
+
* FooElement,
|
|
35
|
+
* );
|
|
36
|
+
*
|
|
37
|
+
* class PersistentFooElement extends Base {
|
|
38
|
+
* override disconnectedCallback(): void {}
|
|
39
|
+
* override connectedCallback(): void { super.connectedCallback(); }
|
|
40
|
+
* forceDestroy(): void {
|
|
41
|
+
* this.remove();
|
|
42
|
+
* super.disconnectedCallback();
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare const getCustomElementConstructorWithLifecycle: (tagName: string, fallback: CustomElementConstructor) => IWcLifecycleConstructor;
|
|
48
|
+
/**
|
|
49
|
+
* Constructor type for a "persistent" custom element: the lifecycle-aware shape
|
|
50
|
+
* plus the {@link IPersistentWcConstructor.prototype.forceDestroy} escape hatch.
|
|
51
|
+
*/
|
|
52
|
+
export type IPersistentWcConstructor = new () => HTMLElement & {
|
|
53
|
+
connectedCallback(): void;
|
|
54
|
+
disconnectedCallback(): void;
|
|
55
|
+
forceDestroy(): void;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Builds a "persistent" subclass of an Angular Elements custom element — one that
|
|
59
|
+
* survives DOM detachment (e.g. mat-tab portal swaps) instead of tearing down its
|
|
60
|
+
* inner Angular component on every disconnect.
|
|
61
|
+
*
|
|
62
|
+
* - `disconnectedCallback` is a no-op, so detaching the element does NOT destroy
|
|
63
|
+
* the inner component.
|
|
64
|
+
* - `connectedCallback` runs Angular's bootstrap only once. Angular Elements'
|
|
65
|
+
* `subscribeToEvents` re-subscribes to `strategy.events` on every
|
|
66
|
+
* `connectedCallback`; because `disconnectedCallback` is suppressed those
|
|
67
|
+
* subscriptions would never be cleaned up, so N re-attaches would fire each
|
|
68
|
+
* output N times. The original subscription stays live across detach/reattach.
|
|
69
|
+
* - `forceDestroy()` is the explicit teardown the consumer must call (e.g. in
|
|
70
|
+
* `ngOnDestroy`) when permanently removing the element. It removes the element
|
|
71
|
+
* first so `super.disconnectedCallback()` runs while `isConnected === false`,
|
|
72
|
+
* matching the browser's normal contract.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const element = createCustomElement(FooComponent, { injector });
|
|
77
|
+
* customElements.define('ui-foo-element', element);
|
|
78
|
+
* customElements.define(
|
|
79
|
+
* 'ui-foo-persistent-element',
|
|
80
|
+
* createPersistentCustomElement('ui-foo-element', element),
|
|
81
|
+
* );
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare const createPersistentCustomElement: (tagName: string, element: CustomElementConstructor) => IPersistentWcConstructor;
|