@pega/sdk 0.0.13 → 0.0.15
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 +46 -6
- package/dist/index.js +50 -24
- package/package.json +42 -3
- package/templates/angular-sdk-reference/extra-webpack.config.cjs +23 -0
- package/templates/angular-sdk-reference/index.html +12 -0
- package/templates/angular-sdk-reference/src/app/pconnect-renderer.component.ts +153 -0
- package/templates/angular-sdk-reference/src/components/component-map.ts +90 -0
- package/templates/angular-sdk-reference/src/components/fields/auto-complete/auto-complete.component.ts +304 -0
- package/templates/angular-sdk-reference/src/components/fields/checkbox/checkbox.component.ts +89 -0
- package/templates/angular-sdk-reference/src/components/fields/currency/currency.component.ts +112 -0
- package/templates/angular-sdk-reference/src/components/fields/date-input/date-input.component.ts +101 -0
- package/templates/angular-sdk-reference/src/components/fields/dropdown/dropdown.component.ts +118 -0
- package/templates/angular-sdk-reference/src/components/fields/email/email.component.ts +104 -0
- package/templates/angular-sdk-reference/src/components/fields/integer/integer.component.ts +106 -0
- package/templates/angular-sdk-reference/src/components/fields/phone/phone.component.ts +104 -0
- package/templates/angular-sdk-reference/src/components/fields/radio-buttons/radio-buttons.component.ts +113 -0
- package/templates/angular-sdk-reference/src/components/fields/text-area/text-area.component.ts +111 -0
- package/templates/angular-sdk-reference/src/components/fields/text-input/text-input.component.ts +110 -0
- package/templates/angular-sdk-reference/src/components/fields/url-input/url-input.component.ts +113 -0
- package/templates/angular-sdk-reference/src/components/helpers/sdk-helpers.ts +93 -0
- package/templates/angular-sdk-reference/src/components/infra/assignment/assignment.component.ts +206 -0
- package/templates/angular-sdk-reference/src/components/infra/case-summary/case-summary.component.ts +75 -0
- package/templates/angular-sdk-reference/src/components/infra/case-view/case-view.component.ts +126 -0
- package/templates/angular-sdk-reference/src/components/infra/flow-container/flow-container.component.ts +411 -0
- package/templates/angular-sdk-reference/src/components/infra/reference/reference.component.ts +158 -0
- package/templates/angular-sdk-reference/src/components/infra/region/region.component.ts +39 -0
- package/templates/angular-sdk-reference/src/components/infra/root-container/root-container.component.ts +199 -0
- package/templates/angular-sdk-reference/src/components/infra/stages/stages.component.ts +89 -0
- package/templates/angular-sdk-reference/src/components/infra/view/view.component.ts +144 -0
- package/templates/angular-sdk-reference/src/components/infra/view-container/view-container.component.ts +191 -0
- package/templates/angular-sdk-reference/src/components/templates/default-form/default-form.component.ts +105 -0
- package/templates/angular-sdk-reference/src/components/templates/narrow-wide/narrow-wide.component.ts +37 -0
- package/templates/angular-sdk-reference/src/components/templates/one-column/one-column.component.ts +37 -0
- package/templates/angular-sdk-reference/src/components/templates/two-column/two-column.component.ts +37 -0
- package/templates/angular-sdk-reference/src/components/templates/wide-narrow/wide-narrow.component.ts +37 -0
- package/templates/angular-sdk-reference/tsconfig.app.json +13 -0
- package/templates/react-sdk-reference/.ai-common/agents/embedded-flow-expert.md +75 -34
- package/templates/react-sdk-reference/.ai-common/agents/implementation-expert.md +74 -38
- package/templates/react-sdk-reference/.ai-common/global/ai-agent-instructions-embedded.md +33 -1
- package/templates/react-sdk-reference/.ai-common/global/ai-agent-instructions.md +57 -22
- package/templates/react-sdk-reference/.ai-common/instructions/embedded-component.md +25 -10
- package/templates/react-sdk-reference/.ai-common/prompts/add-component.md +40 -19
- package/templates/react-sdk-reference/.ai-common/prompts/component-manifest.json +62 -1
- package/templates/react-sdk-reference/.ai-common/prompts/embedded-component-manifest.md +26 -4
- package/templates/react-sdk-reference/.ai-common/prompts/generate-all-components.md +84 -33
- package/templates/react-sdk-reference/.ai-common/prompts/generate-dse-components.md +46 -26
- package/templates/react-sdk-reference/.ai-common/prompts/generate-embedded-components.md +28 -15
- package/templates/react-sdk-reference/.ai-common/prompts/generate-field-components.md +24 -6
- package/templates/react-sdk-reference/.ai-common/prompts/generate-infra-components.md +24 -6
- package/templates/react-sdk-reference/.ai-common/prompts/generate-template-components.md +24 -6
- package/templates/react-sdk-reference/.ai-common/prompts/generate-widget-components.md +24 -6
- package/templates/react-sdk-reference/.ai-common/prompts/identify-components.md +2 -0
- package/templates/react-sdk-reference/.ai-common/prompts/replace-design-system.md +44 -17
- package/templates/react-sdk-reference/.ai-common/skills/connect-pega-server.md +14 -1
- package/templates/react-sdk-reference/.ai-common/skills/design-system-extension-skills/AssignmentHeader.md +79 -0
- package/templates/react-sdk-reference/.ai-common/skills/design-system-extension-skills/Toast.md +96 -0
- package/templates/react-sdk-reference/.ai-common/skills/design-system-extension.md +56 -35
- package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/analyze-customer-repo.md +29 -3
- package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/run-and-verify-integration.md +97 -37
- package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/wire-integration.md +91 -60
- package/templates/react-sdk-reference/.ai-common/skills/field-components.md +88 -30
- package/templates/react-sdk-reference/.ai-common/skills/field-skills/AutoComplete.md +133 -101
- package/templates/react-sdk-reference/.ai-common/skills/field-skills/EmbeddedData.md +385 -0
- package/templates/react-sdk-reference/.ai-common/skills/field-skills/EmbeddedDataMulti.md +506 -0
- package/templates/react-sdk-reference/.ai-common/skills/field-skills/ObjectReference.md +549 -86
- package/templates/react-sdk-reference/.ai-common/skills/field-skills/UserReference.md +181 -83
- package/templates/react-sdk-reference/.ai-common/skills/infra-components.md +13 -1
- package/templates/react-sdk-reference/.ai-common/skills/portal-flow/run-and-verify-portal.md +290 -0
- package/templates/react-sdk-reference/.ai-common/skills/template-components.md +13 -1
- package/templates/react-sdk-reference/.ai-common/skills/template-skills/ListView.md +125 -153
- package/templates/react-sdk-reference/.ai-common/skills/template-skills/SimpleTable.md +90 -81
- package/templates/react-sdk-reference/.ai-common/skills/widget-components.md +13 -1
- package/templates/react-sdk-reference/assets/icons/trash.svg +3 -0
- package/templates/react-sdk-reference/index.html +0 -1
- package/templates/react-sdk-reference/package.json +2 -2
- package/templates/react-sdk-reference/package.minimal.json +2 -2
- package/templates/react-sdk-reference/sdk-config.json +3 -3
- package/templates/react-sdk-reference/src/FallbackComponent.tsx +1 -1
- package/templates/react-sdk-reference/src/MashupApp.tsx +33 -78
- package/templates/react-sdk-reference/src/PortalApp.tsx +23 -100
- package/templates/react-sdk-reference/src/components/component-map.ts +15 -1
- package/templates/react-sdk-reference/src/components/designSystemExtension/AssignmentHeader/AssignmentHeader.tsx +15 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/AssignmentHeader/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/FieldGroup/FieldGroup.tsx +1 -1
- package/templates/react-sdk-reference/src/components/designSystemExtension/FieldGroupList/FieldGroupList.tsx +1 -1
- package/templates/react-sdk-reference/src/components/designSystemExtension/FieldValueList/FieldValueList.tsx +16 -4
- package/templates/react-sdk-reference/src/components/designSystemExtension/ModalDialog/ModalDialog.tsx +26 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/ModalDialog/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/Toast/Toast.tsx +35 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/Toast/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/field/AutoComplete/AutoComplete.tsx +362 -24
- package/templates/react-sdk-reference/src/components/field/CancelAlert/CancelAlert.tsx +1 -1
- package/templates/react-sdk-reference/src/components/field/Checkbox/Checkbox.tsx +3 -1
- package/templates/react-sdk-reference/src/components/field/Currency/Currency.tsx +6 -3
- package/templates/react-sdk-reference/src/components/field/Date/Date.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/DateTime/DateTime.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/Decimal/Decimal.tsx +4 -3
- package/templates/react-sdk-reference/src/components/field/Dropdown/Dropdown.tsx +2 -0
- package/templates/react-sdk-reference/src/components/field/Email/Email.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/EmbeddedDataMulti/EmbeddedDataMulti.tsx +121 -0
- package/templates/react-sdk-reference/src/components/field/EmbeddedDataMulti/config-ext.json +7 -0
- package/templates/react-sdk-reference/src/components/field/EmbeddedDataMulti/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/field/Integer/Integer.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/Location/Location.tsx +1 -1
- package/templates/react-sdk-reference/src/components/field/Multiselect/Multiselect.tsx +40 -20
- package/templates/react-sdk-reference/src/components/field/ObjectReference/ObjectReference.tsx +554 -49
- package/templates/react-sdk-reference/src/components/field/ObjectReference/utils.ts +111 -20
- package/templates/react-sdk-reference/src/components/field/Percentage/Percentage.tsx +4 -3
- package/templates/react-sdk-reference/src/components/field/Phone/Phone.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/SelectableCard/SelectableCard.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/TextArea/TextArea.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/TextInput/TextInput.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/Time/Time.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/URL/URL.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/UserReference/UserReference.tsx +1 -1
- package/templates/react-sdk-reference/src/components/helpers/field-utils.ts +44 -0
- package/templates/react-sdk-reference/src/components/helpers/simpleTableHelpers.ts +19 -7
- package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/DataViewActionButtons/DataViewActionButtons.tsx +97 -0
- package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/DataViewActionButtons/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +53 -0
- package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/ListViewActionButtons/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/template/AdvancedSearch/SearchGroups/SearchGroups.tsx +2 -2
- package/templates/react-sdk-reference/src/components/template/CaseSummary/CaseSummary.tsx +3 -1
- package/templates/react-sdk-reference/src/components/template/DataReference/SearchForm.tsx +4 -4
- package/templates/react-sdk-reference/src/components/template/HierarchicalForm/HierarchicalForm.tsx +2 -2
- package/templates/react-sdk-reference/src/components/template/InlineDashboard/InlineDashboard.tsx +1 -1
- package/templates/react-sdk-reference/src/components/template/ListView/ListView.tsx +7 -3
- package/templates/react-sdk-reference/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +173 -99
- package/templates/react-sdk-reference/src/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +63 -56
- package/templates/react-sdk-reference/src/components/widget/ToDo/ToDo.tsx +1 -1
- package/templates/react-sdk-reference/vite.config.ts +26 -4
- package/templates/react-sdk-reference/.ai-common/instructions/dse-component.md +0 -47
- package/templates/react-sdk-reference/.ai-common/instructions/field-component.md +0 -50
- package/templates/react-sdk-reference/.ai-common/instructions/infra-component.md +0 -76
- package/templates/react-sdk-reference/.ai-common/instructions/template-component.md +0 -43
- package/templates/react-sdk-reference/.ai-common/instructions/widget-component.md +0 -45
- package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/authenticate.md +0 -311
- package/templates/react-sdk-reference/pega-constellationjs-0.26.3-local.tgz +0 -0
- package/templates/react-sdk-reference/pega-sdk-react-0.1.0.tgz +0 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoComplete — typeahead/autocomplete field.
|
|
3
|
+
*
|
|
4
|
+
* Supports associated lists (options from datasource prop) and data page lists
|
|
5
|
+
* (options fetched via PCore.getDataPageUtils). Also handles deferDatasource mode
|
|
6
|
+
* where datasourceMetadata transforms into a data page call.
|
|
7
|
+
*
|
|
8
|
+
* Pattern reference: angular-sdk-components AutoCompleteComponent + sdk-react AutoComplete
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
|
+
import { Component, Input } from '@angular/core';
|
|
13
|
+
import type { OnInit, OnChanges, SimpleChanges } from '@angular/core';
|
|
14
|
+
import { CommonModule } from '@angular/common';
|
|
15
|
+
import { FormsModule } from '@angular/forms';
|
|
16
|
+
import { getOptionList, handleEvent } from '../../helpers/sdk-helpers';
|
|
17
|
+
|
|
18
|
+
interface IOption {
|
|
19
|
+
key: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Component({
|
|
24
|
+
selector: 'pega-auto-complete',
|
|
25
|
+
standalone: true,
|
|
26
|
+
imports: [CommonModule, FormsModule],
|
|
27
|
+
template: `
|
|
28
|
+
<!-- Read-only / display mode -->
|
|
29
|
+
<div *ngIf="readOnly || isDisplayMode" style="margin-bottom: 1rem;">
|
|
30
|
+
<span style="font-size: 0.75rem; color: #6b7280;">{{ label }}</span>
|
|
31
|
+
<div style="font-size: 0.875rem;">{{ displayValue }}</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<!-- Editable mode -->
|
|
35
|
+
<div
|
|
36
|
+
*ngIf="!readOnly && !isDisplayMode"
|
|
37
|
+
style="margin-bottom: 1rem; position: relative;"
|
|
38
|
+
>
|
|
39
|
+
<label
|
|
40
|
+
*ngIf="label"
|
|
41
|
+
style="display: block; margin-bottom: 0.25rem; font-weight: 500; font-size: 0.875rem;"
|
|
42
|
+
>
|
|
43
|
+
{{ label
|
|
44
|
+
}}<span *ngIf="required" style="color: #dc2626; margin-left: 0.25rem;"
|
|
45
|
+
>*</span
|
|
46
|
+
>
|
|
47
|
+
</label>
|
|
48
|
+
<input
|
|
49
|
+
type="text"
|
|
50
|
+
[attr.data-testid]="testId"
|
|
51
|
+
[value]="inputValue"
|
|
52
|
+
[placeholder]="placeholder"
|
|
53
|
+
[disabled]="disabled"
|
|
54
|
+
[required]="required"
|
|
55
|
+
(input)="onInput($event)"
|
|
56
|
+
(focus)="showDropdown = true"
|
|
57
|
+
(blur)="onBlur()"
|
|
58
|
+
autocomplete="off"
|
|
59
|
+
style="width: 100%; padding: 0.5rem 0.75rem; border-radius: 0.375rem; font-size: 0.875rem; box-sizing: border-box;"
|
|
60
|
+
[style.border]="
|
|
61
|
+
validatemessage ? '1px solid #dc2626' : '1px solid #d1d5db'
|
|
62
|
+
"
|
|
63
|
+
/>
|
|
64
|
+
<!-- Dropdown list -->
|
|
65
|
+
<ul
|
|
66
|
+
*ngIf="showDropdown && filteredOptions.length > 0"
|
|
67
|
+
style="position: absolute; z-index: 10; width: 100%; max-height: 12rem; overflow-y: auto; background: #fff; border: 1px solid #d1d5db; border-radius: 0.375rem; margin-top: 0.125rem; padding: 0; list-style: none; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);"
|
|
68
|
+
>
|
|
69
|
+
<li
|
|
70
|
+
*ngFor="let opt of filteredOptions"
|
|
71
|
+
(mousedown)="selectOption(opt)"
|
|
72
|
+
style="padding: 0.5rem 0.75rem; cursor: pointer; font-size: 0.875rem;"
|
|
73
|
+
>
|
|
74
|
+
{{ opt.value }}
|
|
75
|
+
</li>
|
|
76
|
+
</ul>
|
|
77
|
+
<div
|
|
78
|
+
*ngIf="helperTextToDisplay"
|
|
79
|
+
style="font-size: 0.75rem; margin-top: 0.25rem;"
|
|
80
|
+
[style.color]="validatemessage ? '#dc2626' : '#6b7280'"
|
|
81
|
+
>
|
|
82
|
+
{{ helperTextToDisplay }}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
`,
|
|
86
|
+
})
|
|
87
|
+
export class AutoCompleteComponent implements OnInit, OnChanges {
|
|
88
|
+
@Input() props: any;
|
|
89
|
+
|
|
90
|
+
label = '';
|
|
91
|
+
value = '';
|
|
92
|
+
placeholder = '';
|
|
93
|
+
testId = '';
|
|
94
|
+
required = false;
|
|
95
|
+
disabled = false;
|
|
96
|
+
readOnly = false;
|
|
97
|
+
validatemessage = '';
|
|
98
|
+
helperText = '';
|
|
99
|
+
isDisplayMode = false;
|
|
100
|
+
displayValue = '';
|
|
101
|
+
inputValue = '';
|
|
102
|
+
showDropdown = false;
|
|
103
|
+
options: IOption[] = [];
|
|
104
|
+
filteredOptions: IOption[] = [];
|
|
105
|
+
helperTextToDisplay = '';
|
|
106
|
+
|
|
107
|
+
private actions: any;
|
|
108
|
+
private propName = '';
|
|
109
|
+
private pConn: any;
|
|
110
|
+
private listType = '';
|
|
111
|
+
|
|
112
|
+
ngOnInit(): void {
|
|
113
|
+
this.updateFromProps();
|
|
114
|
+
this.loadOptions();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
118
|
+
if (changes['props']) {
|
|
119
|
+
this.updateFromProps();
|
|
120
|
+
this.loadOptions();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private updateFromProps(): void {
|
|
125
|
+
const p = this.props;
|
|
126
|
+
this.label = p.label ?? '';
|
|
127
|
+
this.value = p.value ?? '';
|
|
128
|
+
this.placeholder = p.placeholder ?? '';
|
|
129
|
+
this.testId = p.testId ?? '';
|
|
130
|
+
this.required = p.required ?? false;
|
|
131
|
+
this.disabled = p.disabled ?? false;
|
|
132
|
+
this.readOnly = p.readOnly ?? false;
|
|
133
|
+
this.validatemessage = p.validatemessage ?? '';
|
|
134
|
+
this.helperText = p.helperText ?? '';
|
|
135
|
+
this.helperTextToDisplay = this.validatemessage || this.helperText;
|
|
136
|
+
this.isDisplayMode =
|
|
137
|
+
p.displayMode === 'DISPLAY_ONLY' || p.displayMode === 'STACKED_LARGE_VAL';
|
|
138
|
+
|
|
139
|
+
this.pConn = p.getPConnect?.();
|
|
140
|
+
this.actions = this.pConn?.getActionsApi?.();
|
|
141
|
+
this.propName =
|
|
142
|
+
((this.pConn?.getStateProps?.() as Record<string, unknown>)
|
|
143
|
+
?.value as string) ?? '';
|
|
144
|
+
|
|
145
|
+
// Resolve display value from current options
|
|
146
|
+
this.updateDisplayValue();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private updateDisplayValue(): void {
|
|
150
|
+
const match = this.options.find((o) => o.key === this.value);
|
|
151
|
+
this.displayValue = match?.value ?? this.value ?? '';
|
|
152
|
+
if (!this.inputValue || this.inputValue !== this.displayValue) {
|
|
153
|
+
this.inputValue = this.displayValue;
|
|
154
|
+
}
|
|
155
|
+
this.filterOptions();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private filterOptions(): void {
|
|
159
|
+
const text = (this.inputValue ?? '').toLowerCase();
|
|
160
|
+
this.filteredOptions = text
|
|
161
|
+
? this.options.filter((o) => o.value?.toLowerCase().includes(text))
|
|
162
|
+
: [...this.options];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private loadOptions(): void {
|
|
166
|
+
const p = this.props;
|
|
167
|
+
let { listType, parameters, datasource, columns = [] } = p;
|
|
168
|
+
|
|
169
|
+
// Handle deferDatasource
|
|
170
|
+
if (p.deferDatasource && p.datasourceMetadata?.datasource?.name) {
|
|
171
|
+
listType = 'datapage';
|
|
172
|
+
datasource = p.datasourceMetadata.datasource.name;
|
|
173
|
+
const meta = p.datasourceMetadata.datasource;
|
|
174
|
+
parameters = this.flattenParameters(meta.parameters);
|
|
175
|
+
const displayProp = meta.propertyForDisplayText?.startsWith('@P')
|
|
176
|
+
? meta.propertyForDisplayText.substring(3)
|
|
177
|
+
: meta.propertyForDisplayText;
|
|
178
|
+
const valueProp = meta.propertyForValue?.startsWith('@P')
|
|
179
|
+
? meta.propertyForValue.substring(3)
|
|
180
|
+
: meta.propertyForValue;
|
|
181
|
+
columns = [
|
|
182
|
+
{ key: 'true', setProperty: 'Associated property', value: valueProp },
|
|
183
|
+
{
|
|
184
|
+
display: 'true',
|
|
185
|
+
primary: 'true',
|
|
186
|
+
useForSearch: 'true',
|
|
187
|
+
value: displayProp,
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
this.listType = listType ?? '';
|
|
193
|
+
const processedColumns = this.preProcessColumns(columns ?? []);
|
|
194
|
+
|
|
195
|
+
if (this.listType === 'associated') {
|
|
196
|
+
const dataObject = this.pConn?.getDataObject?.('') ?? {};
|
|
197
|
+
const optList = getOptionList(
|
|
198
|
+
p as Record<string, unknown>,
|
|
199
|
+
dataObject as Record<string, unknown>,
|
|
200
|
+
);
|
|
201
|
+
this.setOptions(
|
|
202
|
+
optList.map((o) => ({ key: o.value, value: o.text ?? o.value })),
|
|
203
|
+
);
|
|
204
|
+
} else if (this.listType === 'datapage' && datasource) {
|
|
205
|
+
const context = this.pConn?.getContextName?.() ?? '';
|
|
206
|
+
const flatParams =
|
|
207
|
+
typeof parameters === 'object' && !Array.isArray(parameters)
|
|
208
|
+
? this.flattenParameters(parameters)
|
|
209
|
+
: {};
|
|
210
|
+
(PCore.getDataPageUtils() as any)
|
|
211
|
+
.getDataAsync(datasource, context, flatParams)
|
|
212
|
+
.then((response: any) => {
|
|
213
|
+
const results = Array.isArray(response)
|
|
214
|
+
? response
|
|
215
|
+
: (response?.data ?? []);
|
|
216
|
+
const displayColumn = this.getDisplayFieldsMetaData(processedColumns);
|
|
217
|
+
const optionsData: IOption[] = results.map(
|
|
218
|
+
(element: Record<string, unknown>) => ({
|
|
219
|
+
key: String(
|
|
220
|
+
element[displayColumn.key] ?? element['pyGUID'] ?? '',
|
|
221
|
+
),
|
|
222
|
+
value: String(element[displayColumn.primary] ?? ''),
|
|
223
|
+
}),
|
|
224
|
+
);
|
|
225
|
+
this.setOptions(optionsData);
|
|
226
|
+
})
|
|
227
|
+
.catch(() => {
|
|
228
|
+
// Data page fetch failed
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private setOptions(opts: IOption[]): void {
|
|
234
|
+
this.options = opts;
|
|
235
|
+
this.updateDisplayValue();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private flattenParameters(
|
|
239
|
+
params: Record<string, any> = {},
|
|
240
|
+
): Record<string, unknown> {
|
|
241
|
+
const flat: Record<string, unknown> = {};
|
|
242
|
+
for (const key of Object.keys(params)) {
|
|
243
|
+
const { name, value: val } = params[key];
|
|
244
|
+
flat[name] = val;
|
|
245
|
+
}
|
|
246
|
+
return flat;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private preProcessColumns(
|
|
250
|
+
columnList: Array<Record<string, string>>,
|
|
251
|
+
): Array<Record<string, string>> {
|
|
252
|
+
return columnList.map((col) => {
|
|
253
|
+
const temp = { ...col };
|
|
254
|
+
temp.value =
|
|
255
|
+
col.value && col.value.startsWith('.')
|
|
256
|
+
? col.value.substring(1)
|
|
257
|
+
: col.value;
|
|
258
|
+
return temp;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private getDisplayFieldsMetaData(columnList: Array<Record<string, string>>): {
|
|
263
|
+
key: string;
|
|
264
|
+
primary: string;
|
|
265
|
+
secondary: string[];
|
|
266
|
+
} {
|
|
267
|
+
const displayColumns = columnList.filter(
|
|
268
|
+
(col) => col['display'] === 'true',
|
|
269
|
+
);
|
|
270
|
+
const metaData = { key: '', primary: '', secondary: [] as string[] };
|
|
271
|
+
const keyCol = columnList.filter((col) => col['key'] === 'true');
|
|
272
|
+
metaData.key = keyCol.length > 0 ? keyCol[0].value : 'auto';
|
|
273
|
+
for (const col of displayColumns) {
|
|
274
|
+
if (col['primary'] === 'true') {
|
|
275
|
+
metaData.primary = col.value;
|
|
276
|
+
} else {
|
|
277
|
+
metaData.secondary.push(col.value);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return metaData;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
onInput(event: Event): void {
|
|
284
|
+
const target = event.target as HTMLInputElement;
|
|
285
|
+
this.inputValue = target.value;
|
|
286
|
+
this.showDropdown = true;
|
|
287
|
+
this.filterOptions();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
onBlur(): void {
|
|
291
|
+
// Delay to allow click on an option
|
|
292
|
+
setTimeout(() => {
|
|
293
|
+
this.showDropdown = false;
|
|
294
|
+
}, 200);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
selectOption(opt: IOption): void {
|
|
298
|
+
this.inputValue = opt.value;
|
|
299
|
+
this.showDropdown = false;
|
|
300
|
+
if (this.actions && this.propName) {
|
|
301
|
+
handleEvent(this.actions, 'changeNblur', this.propName, opt.key);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox — boolean checkbox field.
|
|
3
|
+
*
|
|
4
|
+
* Pattern reference: sdk-react Checkbox
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
import { Component, Input } from '@angular/core';
|
|
9
|
+
import type { OnInit, OnChanges, SimpleChanges } from '@angular/core';
|
|
10
|
+
import { CommonModule } from '@angular/common';
|
|
11
|
+
import { handleEvent } from '../../helpers/sdk-helpers';
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'pega-checkbox',
|
|
15
|
+
standalone: true,
|
|
16
|
+
imports: [CommonModule],
|
|
17
|
+
template: `
|
|
18
|
+
<div style="margin-bottom: 1rem;">
|
|
19
|
+
<label
|
|
20
|
+
style="display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem;"
|
|
21
|
+
[style.cursor]="disabled || readOnly ? 'default' : 'pointer'"
|
|
22
|
+
>
|
|
23
|
+
<input
|
|
24
|
+
type="checkbox"
|
|
25
|
+
[attr.data-testid]="testId"
|
|
26
|
+
[checked]="checked"
|
|
27
|
+
[disabled]="disabled || readOnly"
|
|
28
|
+
(change)="onCheckChange($event)"
|
|
29
|
+
/>
|
|
30
|
+
{{ label }}
|
|
31
|
+
<span *ngIf="required" style="color: #dc2626;">*</span>
|
|
32
|
+
</label>
|
|
33
|
+
<div
|
|
34
|
+
*ngIf="validatemessage"
|
|
35
|
+
style="color: #dc2626; font-size: 0.75rem; margin-top: 0.25rem;"
|
|
36
|
+
>
|
|
37
|
+
{{ validatemessage }}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
`,
|
|
41
|
+
})
|
|
42
|
+
export class CheckboxComponent implements OnInit, OnChanges {
|
|
43
|
+
@Input() props: any;
|
|
44
|
+
|
|
45
|
+
label = '';
|
|
46
|
+
checked = false;
|
|
47
|
+
testId = '';
|
|
48
|
+
required = false;
|
|
49
|
+
disabled = false;
|
|
50
|
+
readOnly = false;
|
|
51
|
+
validatemessage = '';
|
|
52
|
+
|
|
53
|
+
private actions: any;
|
|
54
|
+
private propName = '';
|
|
55
|
+
|
|
56
|
+
ngOnInit(): void {
|
|
57
|
+
this.updateFromProps();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
61
|
+
if (changes['props']) {
|
|
62
|
+
this.updateFromProps();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private updateFromProps(): void {
|
|
67
|
+
const p = this.props;
|
|
68
|
+
this.label = p.label ?? '';
|
|
69
|
+
this.checked = p.value === true || p.value === 'true';
|
|
70
|
+
this.testId = p.testId ?? '';
|
|
71
|
+
this.required = p.required ?? false;
|
|
72
|
+
this.disabled = p.disabled ?? false;
|
|
73
|
+
this.readOnly = p.readOnly ?? false;
|
|
74
|
+
this.validatemessage = p.validatemessage ?? '';
|
|
75
|
+
|
|
76
|
+
const pConn = p.getPConnect?.();
|
|
77
|
+
this.actions = pConn?.getActionsApi?.();
|
|
78
|
+
this.propName =
|
|
79
|
+
((pConn?.getStateProps?.() as Record<string, unknown>)
|
|
80
|
+
?.value as string) ?? '';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onCheckChange(event: Event): void {
|
|
84
|
+
const target = event.target as HTMLInputElement;
|
|
85
|
+
if (this.actions && this.propName) {
|
|
86
|
+
handleEvent(this.actions, 'changeNblur', this.propName, target.checked);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency — currency input field with formatting.
|
|
3
|
+
*
|
|
4
|
+
* Pattern reference: sdk-react Currency
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
import { Component, Input } from '@angular/core';
|
|
9
|
+
import type { OnInit, OnChanges, SimpleChanges } from '@angular/core';
|
|
10
|
+
import { CommonModule } from '@angular/common';
|
|
11
|
+
import { FormsModule } from '@angular/forms';
|
|
12
|
+
import { handleEvent } from '../../helpers/sdk-helpers';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'pega-currency',
|
|
16
|
+
standalone: true,
|
|
17
|
+
imports: [CommonModule, FormsModule],
|
|
18
|
+
template: `
|
|
19
|
+
<div *ngIf="!readOnly" style="margin-bottom: 1rem;">
|
|
20
|
+
<label
|
|
21
|
+
*ngIf="label"
|
|
22
|
+
style="display: block; margin-bottom: 0.25rem; font-weight: 500; font-size: 0.875rem;"
|
|
23
|
+
>
|
|
24
|
+
{{ label
|
|
25
|
+
}}<span *ngIf="required" style="color: #dc2626; margin-left: 0.25rem;"
|
|
26
|
+
>*</span
|
|
27
|
+
>
|
|
28
|
+
</label>
|
|
29
|
+
<div style="display: flex; align-items: center;">
|
|
30
|
+
<span style="margin-right: 0.25rem; font-size: 0.875rem;">{{
|
|
31
|
+
currencySymbol
|
|
32
|
+
}}</span>
|
|
33
|
+
<input
|
|
34
|
+
type="number"
|
|
35
|
+
step="0.01"
|
|
36
|
+
[attr.data-testid]="testId"
|
|
37
|
+
[value]="value"
|
|
38
|
+
[placeholder]="placeholder"
|
|
39
|
+
[disabled]="disabled"
|
|
40
|
+
[required]="required"
|
|
41
|
+
(blur)="onBlur($event)"
|
|
42
|
+
style="flex: 1; padding: 0.5rem 0.75rem; border-radius: 0.375rem; font-size: 0.875rem;"
|
|
43
|
+
[style.border]="
|
|
44
|
+
validatemessage ? '1px solid #dc2626' : '1px solid #d1d5db'
|
|
45
|
+
"
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
<div
|
|
49
|
+
*ngIf="validatemessage"
|
|
50
|
+
style="color: #dc2626; font-size: 0.75rem; margin-top: 0.25rem;"
|
|
51
|
+
>
|
|
52
|
+
{{ validatemessage }}
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<div *ngIf="readOnly" style="margin-bottom: 1rem;">
|
|
56
|
+
<span style="font-size: 0.75rem; color: #6b7280;">{{ label }}</span>
|
|
57
|
+
<div style="font-size: 0.875rem;">{{ currencySymbol }}{{ value }}</div>
|
|
58
|
+
</div>
|
|
59
|
+
`,
|
|
60
|
+
})
|
|
61
|
+
export class CurrencyComponent implements OnInit, OnChanges {
|
|
62
|
+
@Input() props: any;
|
|
63
|
+
|
|
64
|
+
label = '';
|
|
65
|
+
value: any = '';
|
|
66
|
+
placeholder = '';
|
|
67
|
+
testId = '';
|
|
68
|
+
required = false;
|
|
69
|
+
disabled = false;
|
|
70
|
+
readOnly = false;
|
|
71
|
+
validatemessage = '';
|
|
72
|
+
currencySymbol = '$';
|
|
73
|
+
|
|
74
|
+
private actions: any;
|
|
75
|
+
private propName = '';
|
|
76
|
+
|
|
77
|
+
ngOnInit(): void {
|
|
78
|
+
this.updateFromProps();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
82
|
+
if (changes['props']) {
|
|
83
|
+
this.updateFromProps();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private updateFromProps(): void {
|
|
88
|
+
const p = this.props;
|
|
89
|
+
this.label = p.label ?? '';
|
|
90
|
+
this.value = p.value ?? '';
|
|
91
|
+
this.placeholder = p.placeholder ?? '';
|
|
92
|
+
this.testId = p.testId ?? '';
|
|
93
|
+
this.required = p.required ?? false;
|
|
94
|
+
this.disabled = p.disabled ?? false;
|
|
95
|
+
this.readOnly = p.readOnly ?? false;
|
|
96
|
+
this.validatemessage = p.validatemessage ?? '';
|
|
97
|
+
this.currencySymbol = p.currencyISOCode ?? p.currencySymbol ?? '$';
|
|
98
|
+
|
|
99
|
+
const pConn = p.getPConnect?.();
|
|
100
|
+
this.actions = pConn?.getActionsApi?.();
|
|
101
|
+
this.propName =
|
|
102
|
+
((pConn?.getStateProps?.() as Record<string, unknown>)
|
|
103
|
+
?.value as string) ?? '';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
onBlur(event: Event): void {
|
|
107
|
+
const target = event.target as HTMLInputElement;
|
|
108
|
+
if (this.actions && this.propName) {
|
|
109
|
+
handleEvent(this.actions, 'changeNblur', this.propName, target.value);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
package/templates/angular-sdk-reference/src/components/fields/date-input/date-input.component.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DateInput — date picker field.
|
|
3
|
+
*
|
|
4
|
+
* Pattern reference: sdk-react DateInput
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
import { Component, Input } from '@angular/core';
|
|
9
|
+
import type { OnInit, OnChanges, SimpleChanges } from '@angular/core';
|
|
10
|
+
import { CommonModule } from '@angular/common';
|
|
11
|
+
import { FormsModule } from '@angular/forms';
|
|
12
|
+
import { handleEvent } from '../../helpers/sdk-helpers';
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
selector: 'pega-date-input',
|
|
16
|
+
standalone: true,
|
|
17
|
+
imports: [CommonModule, FormsModule],
|
|
18
|
+
template: `
|
|
19
|
+
<div *ngIf="!readOnly" style="margin-bottom: 1rem;">
|
|
20
|
+
<label
|
|
21
|
+
*ngIf="label"
|
|
22
|
+
style="display: block; margin-bottom: 0.25rem; font-weight: 500; font-size: 0.875rem;"
|
|
23
|
+
>
|
|
24
|
+
{{ label
|
|
25
|
+
}}<span *ngIf="required" style="color: #dc2626; margin-left: 0.25rem;"
|
|
26
|
+
>*</span
|
|
27
|
+
>
|
|
28
|
+
</label>
|
|
29
|
+
<input
|
|
30
|
+
type="date"
|
|
31
|
+
[attr.data-testid]="testId"
|
|
32
|
+
[value]="value"
|
|
33
|
+
[disabled]="disabled"
|
|
34
|
+
[required]="required"
|
|
35
|
+
(change)="onDateChange($event)"
|
|
36
|
+
style="width: 100%; padding: 0.5rem 0.75rem; border-radius: 0.375rem; font-size: 0.875rem;"
|
|
37
|
+
[style.border]="
|
|
38
|
+
validatemessage ? '1px solid #dc2626' : '1px solid #d1d5db'
|
|
39
|
+
"
|
|
40
|
+
/>
|
|
41
|
+
<div
|
|
42
|
+
*ngIf="validatemessage"
|
|
43
|
+
style="color: #dc2626; font-size: 0.75rem; margin-top: 0.25rem;"
|
|
44
|
+
>
|
|
45
|
+
{{ validatemessage }}
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
<div *ngIf="readOnly" style="margin-bottom: 1rem;">
|
|
49
|
+
<span style="font-size: 0.75rem; color: #6b7280;">{{ label }}</span>
|
|
50
|
+
<div style="font-size: 0.875rem;">{{ value }}</div>
|
|
51
|
+
</div>
|
|
52
|
+
`,
|
|
53
|
+
})
|
|
54
|
+
export class DateInputComponent implements OnInit, OnChanges {
|
|
55
|
+
@Input() props: any;
|
|
56
|
+
|
|
57
|
+
label = '';
|
|
58
|
+
value = '';
|
|
59
|
+
testId = '';
|
|
60
|
+
required = false;
|
|
61
|
+
disabled = false;
|
|
62
|
+
readOnly = false;
|
|
63
|
+
validatemessage = '';
|
|
64
|
+
|
|
65
|
+
private actions: any;
|
|
66
|
+
private propName = '';
|
|
67
|
+
|
|
68
|
+
ngOnInit(): void {
|
|
69
|
+
this.updateFromProps();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
73
|
+
if (changes['props']) {
|
|
74
|
+
this.updateFromProps();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private updateFromProps(): void {
|
|
79
|
+
const p = this.props;
|
|
80
|
+
this.label = p.label ?? '';
|
|
81
|
+
this.value = p.value ?? '';
|
|
82
|
+
this.testId = p.testId ?? '';
|
|
83
|
+
this.required = p.required ?? false;
|
|
84
|
+
this.disabled = p.disabled ?? false;
|
|
85
|
+
this.readOnly = p.readOnly ?? false;
|
|
86
|
+
this.validatemessage = p.validatemessage ?? '';
|
|
87
|
+
|
|
88
|
+
const pConn = p.getPConnect?.();
|
|
89
|
+
this.actions = pConn?.getActionsApi?.();
|
|
90
|
+
this.propName =
|
|
91
|
+
((pConn?.getStateProps?.() as Record<string, unknown>)
|
|
92
|
+
?.value as string) ?? '';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
onDateChange(event: Event): void {
|
|
96
|
+
const target = event.target as HTMLInputElement;
|
|
97
|
+
if (this.actions && this.propName) {
|
|
98
|
+
handleEvent(this.actions, 'changeNblur', this.propName, target.value);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|