@openmfp/webcomponents 0.6.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/.github/workflows/pipeline.yaml +41 -0
- package/.storybook/main.ts +34 -0
- package/.storybook/preview.ts +29 -0
- package/.storybook/tsconfig.json +11 -0
- package/AGENTS.md +153 -0
- package/CODEOWNERS +6 -0
- package/CONTRIBUTING.md +95 -0
- package/LICENSE +201 -0
- package/LICENSES/Apache-2.0.txt +73 -0
- package/README.md +91 -0
- package/REUSE.toml +9 -0
- package/angular.json +157 -0
- package/docs/dashboard.md +358 -0
- package/docs/declarative-form.md +178 -0
- package/docs/declarative-table-card.md +235 -0
- package/docs/declarative-table.md +315 -0
- package/eslint.config.js +41 -0
- package/package.json +73 -0
- package/projects/ngx/cards/favorites/favorites.component.html +12 -0
- package/projects/ngx/cards/favorites/favorites.component.scss +50 -0
- package/projects/ngx/cards/favorites/favorites.component.ts +19 -0
- package/projects/ngx/cards/public-api.ts +4 -0
- package/projects/ngx/cards/service-status/service-status-card.component.html +15 -0
- package/projects/ngx/cards/service-status/service-status-card.component.scss +87 -0
- package/projects/ngx/cards/service-status/service-status-card.component.ts +36 -0
- package/projects/ngx/cards/stories/visited-service-card.stories.ts +149 -0
- package/projects/ngx/cards/visited-service-card/visited-service-card.component.html +17 -0
- package/projects/ngx/cards/visited-service-card/visited-service-card.component.scss +34 -0
- package/projects/ngx/cards/visited-service-card/visited-service-card.component.ts +22 -0
- package/projects/ngx/cards/whats-new/whats-new.component.html +10 -0
- package/projects/ngx/cards/whats-new/whats-new.component.scss +25 -0
- package/projects/ngx/cards/whats-new/whats-new.component.ts +46 -0
- package/projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.html +28 -0
- package/projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.scss +44 -0
- package/projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.spec.ts +85 -0
- package/projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.ts +58 -0
- package/projects/ngx/declarative-ui/dashboard/card/dashboard-card.component.html +29 -0
- package/projects/ngx/declarative-ui/dashboard/card/dashboard-card.component.scss +63 -0
- package/projects/ngx/declarative-ui/dashboard/card/dashboard-card.component.spec.ts +255 -0
- package/projects/ngx/declarative-ui/dashboard/card/dashboard-card.component.ts +75 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/dashboard-card-registry.spec.ts +76 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/dashboard-card-registry.ts +109 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/index.ts +4 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-angular-card.spec.ts +141 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-angular-card.ts +44 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-sap-card.spec.ts +142 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-sap-card.ts +52 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-wc-card.spec.ts +107 -0
- package/projects/ngx/declarative-ui/dashboard/card/utils/mount-wc-card.ts +22 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.html +134 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.scss +88 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.spec.ts +354 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.ts +238 -0
- package/projects/ngx/declarative-ui/dashboard/dashboard/index.ts +1 -0
- package/projects/ngx/declarative-ui/dashboard/index.ts +5 -0
- package/projects/ngx/declarative-ui/dashboard/models/constants.ts +2 -0
- package/projects/ngx/declarative-ui/dashboard/models/dashboard.model.ts +50 -0
- package/projects/ngx/declarative-ui/dashboard/models/index.ts +1 -0
- package/projects/ngx/declarative-ui/dashboard/section/dashboard-section.component.html +28 -0
- package/projects/ngx/declarative-ui/dashboard/section/dashboard-section.component.scss +85 -0
- package/projects/ngx/declarative-ui/dashboard/section/dashboard-section.component.spec.ts +104 -0
- package/projects/ngx/declarative-ui/dashboard/section/dashboard-section.component.ts +23 -0
- package/projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.html +62 -0
- package/projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.scss +12 -0
- package/projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.spec.ts +301 -0
- package/projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.ts +166 -0
- package/projects/ngx/declarative-ui/form/declarative-form/index.ts +1 -0
- package/projects/ngx/declarative-ui/form/index.ts +2 -0
- package/projects/ngx/declarative-ui/form/models/form-field-definition.ts +15 -0
- package/projects/ngx/declarative-ui/form/models/index.ts +1 -0
- package/projects/ngx/declarative-ui/form/utils/set-property-by-path.ts +30 -0
- package/projects/ngx/declarative-ui/models/index.ts +2 -0
- package/projects/ngx/declarative-ui/models/resource.ts +5 -0
- package/projects/ngx/declarative-ui/models/ui-definition.ts +95 -0
- package/projects/ngx/declarative-ui/public-api.ts +4 -0
- package/projects/ngx/declarative-ui/stories/add-card-dialog.stories.ts +91 -0
- package/projects/ngx/declarative-ui/stories/background-lightblue.png +0 -0
- package/projects/ngx/declarative-ui/stories/dashboard.cards.ts +107 -0
- package/projects/ngx/declarative-ui/stories/dashboard.stories.ts +296 -0
- package/projects/ngx/declarative-ui/stories/declarative-form.stories.ts +149 -0
- package/projects/ngx/declarative-ui/stories/declarative-table-card.stories.ts +358 -0
- package/projects/ngx/declarative-ui/stories/declarative-table.stories.ts +363 -0
- package/projects/ngx/declarative-ui/stories/pods-table.config.ts +188 -0
- package/projects/ngx/declarative-ui/table/declarative-table/declarative-table.component.html +138 -0
- package/projects/ngx/declarative-ui/table/declarative-table/declarative-table.component.scss +21 -0
- package/projects/ngx/declarative-ui/table/declarative-table/declarative-table.component.spec.ts +345 -0
- package/projects/ngx/declarative-ui/table/declarative-table/declarative-table.component.ts +61 -0
- package/projects/ngx/declarative-ui/table/declarative-table/index.ts +1 -0
- package/projects/ngx/declarative-ui/table/index.ts +2 -0
- package/projects/ngx/declarative-ui/table/models/index.ts +14 -0
- package/projects/ngx/declarative-ui/table/models/table.model.ts +17 -0
- package/projects/ngx/declarative-ui/table/utils/cssRules.engine.spec.ts +146 -0
- package/projects/ngx/declarative-ui/table/utils/cssRules.engine.ts +69 -0
- package/projects/ngx/declarative-ui/table/utils/field-definition.utils.spec.ts +70 -0
- package/projects/ngx/declarative-ui/table/utils/field-definition.utils.ts +13 -0
- package/projects/ngx/declarative-ui/table/utils/proccess-fields.spec.ts +511 -0
- package/projects/ngx/declarative-ui/table/utils/proccess-fields.ts +71 -0
- package/projects/ngx/declarative-ui/table/utils/resource-field-by-path.spec.ts +372 -0
- package/projects/ngx/declarative-ui/table/utils/resource-field-by-path.ts +98 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-cell.constants.ts +5 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-value.component.html +1 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-value.component.scss +0 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-value.component.spec.ts +119 -0
- package/projects/ngx/declarative-ui/table/value-cell/boolean-value/boolean-value.component.ts +35 -0
- package/projects/ngx/declarative-ui/table/value-cell/link-value/link-value.component.html +7 -0
- package/projects/ngx/declarative-ui/table/value-cell/link-value/link-value.component.scss +0 -0
- package/projects/ngx/declarative-ui/table/value-cell/link-value/link-value.component.spec.ts +114 -0
- package/projects/ngx/declarative-ui/table/value-cell/link-value/link-value.component.ts +19 -0
- package/projects/ngx/declarative-ui/table/value-cell/secret-value/secret-value.component.html +7 -0
- package/projects/ngx/declarative-ui/table/value-cell/secret-value/secret-value.component.scss +10 -0
- package/projects/ngx/declarative-ui/table/value-cell/secret-value/secret-value.component.spec.ts +188 -0
- package/projects/ngx/declarative-ui/table/value-cell/secret-value/secret-value.component.ts +16 -0
- package/projects/ngx/declarative-ui/table/value-cell/value-cell.component.html +59 -0
- package/projects/ngx/declarative-ui/table/value-cell/value-cell.component.scss +33 -0
- package/projects/ngx/declarative-ui/table/value-cell/value-cell.component.spec.ts +316 -0
- package/projects/ngx/declarative-ui/table/value-cell/value-cell.component.ts +115 -0
- package/projects/ngx/declarative-ui/table-card/declarative-table-card.component.html +156 -0
- package/projects/ngx/declarative-ui/table-card/declarative-table-card.component.scss +123 -0
- package/projects/ngx/declarative-ui/table-card/declarative-table-card.component.spec.ts +786 -0
- package/projects/ngx/declarative-ui/table-card/declarative-table-card.component.ts +286 -0
- package/projects/ngx/declarative-ui/table-card/index.ts +2 -0
- package/projects/ngx/declarative-ui/table-card/models/configs.ts +46 -0
- package/projects/ngx/declarative-ui/tsconfig.lib.json +11 -0
- package/projects/ngx/declarative-ui/tsconfig.lib.prod.json +9 -0
- package/projects/ngx/declarative-ui/tsconfig.spec.json +9 -0
- package/projects/ngx/ng-package.json +8 -0
- package/projects/ngx/package.json +22 -0
- package/projects/ngx/public-api.ts +2 -0
- package/projects/ngx/tsconfig.lib.json +11 -0
- package/projects/ngx/tsconfig.lib.prod.json +9 -0
- package/projects/webcomponents/main.ts +92 -0
- package/projects/webcomponents/tsconfig.app.json +9 -0
- package/projects/webcomponents-dashboard/main.ts +15 -0
- package/projects/webcomponents-dashboard/tsconfig.app.json +9 -0
- package/renovate.json +6 -0
- package/scripts/bundle-wc.mjs +79 -0
- package/tsconfig.json +37 -0
- package/tsconfig.spec.json +8 -0
- package/tsconfig.storybook.json +16 -0
- package/vitest.config.ts +26 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { Favorites } from '../../cards/favorites/favorites.component';
|
|
2
|
+
import { ServiceStatusCard } from '../../cards/service-status/service-status-card.component';
|
|
3
|
+
import { VisitedServiceCard } from '../../cards/visited-service-card/visited-service-card.component';
|
|
4
|
+
import { Dashboard } from '../dashboard/dashboard/dashboard.component';
|
|
5
|
+
import type { CardConfig, DashboardConfig } from '../dashboard/models';
|
|
6
|
+
import { ButtonSettings } from '../models/ui-definition';
|
|
7
|
+
import { CARDS, SECTIONS } from './dashboard.cards';
|
|
8
|
+
import { TABLE_CARD_CONFIG, TABLE_RESOURCES } from './pods-table.config';
|
|
9
|
+
import type { Meta, StoryObj } from '@storybook/angular';
|
|
10
|
+
|
|
11
|
+
Dashboard.registerAngularComponents([
|
|
12
|
+
Favorites,
|
|
13
|
+
ServiceStatusCard,
|
|
14
|
+
VisitedServiceCard,
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Shared config
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
const CUSTOM_ACTIONS: ButtonSettings[] = [
|
|
22
|
+
{
|
|
23
|
+
action: 'download-config',
|
|
24
|
+
text: 'Download config',
|
|
25
|
+
icon: 'download',
|
|
26
|
+
design: 'Default',
|
|
27
|
+
tooltip: 'Download the current dashboard configuration',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
action: 'switch-account',
|
|
31
|
+
text: 'Switch account',
|
|
32
|
+
icon: 'customer',
|
|
33
|
+
design: 'Default',
|
|
34
|
+
tooltip: 'Switch to a different account',
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const SAMPLE_CONFIG: DashboardConfig = {
|
|
39
|
+
title: 'System Overview',
|
|
40
|
+
description:
|
|
41
|
+
'Monitor your platform metrics, traffic and service health in real time.',
|
|
42
|
+
backgroundImageUrl: '/background-lightblue.png',
|
|
43
|
+
customActions: CUSTOM_ACTIONS,
|
|
44
|
+
editable: true,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const AVAILABLE_CARDS: CardConfig[] = [
|
|
48
|
+
{
|
|
49
|
+
id: 'table-pods',
|
|
50
|
+
label: 'Pods Table',
|
|
51
|
+
w: 12,
|
|
52
|
+
h: 100,
|
|
53
|
+
component: 'mfp-wc-declarative-table-card',
|
|
54
|
+
componentInputs: {
|
|
55
|
+
config: TABLE_CARD_CONFIG,
|
|
56
|
+
resources: TABLE_RESOURCES,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'whats-new',
|
|
61
|
+
label: "What's New",
|
|
62
|
+
w: 5,
|
|
63
|
+
h: 57,
|
|
64
|
+
component: 'mfp-whats-new',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'favorites',
|
|
68
|
+
label: 'Favorites',
|
|
69
|
+
w: 4,
|
|
70
|
+
h: 21,
|
|
71
|
+
component: 'mfp-favorites',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'service-status',
|
|
75
|
+
label: 'Service Status',
|
|
76
|
+
w: 4,
|
|
77
|
+
h: 30,
|
|
78
|
+
component: 'mfp-service-status-card',
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
const REGISTRY_SECTIONS = [
|
|
83
|
+
{
|
|
84
|
+
id: 'angular-cards',
|
|
85
|
+
title: 'Angular cards',
|
|
86
|
+
editable: true,
|
|
87
|
+
w: 12,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'wc-cards',
|
|
91
|
+
title: 'Webcomponent cards',
|
|
92
|
+
editable: true,
|
|
93
|
+
w: 12,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const REGISTRY_CARDS: CardConfig[] = [
|
|
98
|
+
{
|
|
99
|
+
id: 'angular-visited-service',
|
|
100
|
+
w: 4,
|
|
101
|
+
h: 10,
|
|
102
|
+
sectionId: 'angular-cards',
|
|
103
|
+
component: 'mfp-visited-service-card',
|
|
104
|
+
componentInputs: {
|
|
105
|
+
serviceType: 'SAP HANA Cloud',
|
|
106
|
+
serviceName: 'orders-db',
|
|
107
|
+
serviceIcon: 'database',
|
|
108
|
+
serviceDescription: 'Registered Angular component',
|
|
109
|
+
path: '/hana/orders-db',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: 'angular-favorites',
|
|
114
|
+
sectionId: 'angular-cards',
|
|
115
|
+
x: 0,
|
|
116
|
+
y: 0,
|
|
117
|
+
w: 5,
|
|
118
|
+
h: 20,
|
|
119
|
+
component: 'mfp-favorites',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: 'webcomponent-table',
|
|
123
|
+
sectionId: 'wc-cards',
|
|
124
|
+
w: 12,
|
|
125
|
+
h: 50,
|
|
126
|
+
component: 'mfp-wc-declarative-table-card',
|
|
127
|
+
componentInputs: {
|
|
128
|
+
config: TABLE_CARD_CONFIG,
|
|
129
|
+
header: 'Pods rendered by web component',
|
|
130
|
+
headerTooltip:
|
|
131
|
+
'This card intentionally uses the existing custom-element render path.',
|
|
132
|
+
resources: TABLE_RESOURCES,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
const ANGULAR_REGISTRY_AVAILABLE_CARDS: CardConfig[] = [
|
|
138
|
+
{
|
|
139
|
+
id: 'angular-service-status-template',
|
|
140
|
+
label: 'Angular Service Status',
|
|
141
|
+
w: 4,
|
|
142
|
+
h: 29,
|
|
143
|
+
component: 'mfp-service-status-card',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: 'webcomponent-whats-new-template',
|
|
147
|
+
label: "Web Component What's New",
|
|
148
|
+
w: 5,
|
|
149
|
+
h: 56,
|
|
150
|
+
component: 'mfp-whats-new',
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
// Meta
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
|
|
158
|
+
const meta: Meta<Dashboard> = {
|
|
159
|
+
title: 'Declarative UI / Dashboard',
|
|
160
|
+
component: Dashboard,
|
|
161
|
+
tags: ['autodocs'],
|
|
162
|
+
parameters: {
|
|
163
|
+
layout: 'fullscreen',
|
|
164
|
+
},
|
|
165
|
+
argTypes: {
|
|
166
|
+
config: { control: 'object' },
|
|
167
|
+
sections: { control: 'object' },
|
|
168
|
+
cards: { control: 'object' },
|
|
169
|
+
availableCards: { control: 'object' },
|
|
170
|
+
actionButtonClick: { action: 'actionButtonClick' },
|
|
171
|
+
},
|
|
172
|
+
args: {
|
|
173
|
+
config: SAMPLE_CONFIG,
|
|
174
|
+
sections: SECTIONS,
|
|
175
|
+
cards: CARDS,
|
|
176
|
+
availableCards: AVAILABLE_CARDS,
|
|
177
|
+
},
|
|
178
|
+
render: (args) => ({
|
|
179
|
+
props: args,
|
|
180
|
+
template: `<mfp-dashboard [config]="config" [sections]="sections" [cards]="cards" [availableCards]="availableCards" (actionButtonClick)="actionButtonClick($event)" />`,
|
|
181
|
+
}),
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export default meta;
|
|
185
|
+
type Story = StoryObj<Dashboard>;
|
|
186
|
+
|
|
187
|
+
// ---------------------------------------------------------------------------
|
|
188
|
+
// Stories
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
190
|
+
|
|
191
|
+
export const Default: Story = {};
|
|
192
|
+
|
|
193
|
+
export const WithSubheader: Story = {
|
|
194
|
+
render: (args) => ({
|
|
195
|
+
props: args,
|
|
196
|
+
template: `
|
|
197
|
+
<mfp-dashboard [config]="config" [sections]="sections" [cards]="cards" [availableCards]="availableCards">
|
|
198
|
+
<div slot="dashboard-subheader" style="display:flex;align-items:center;gap:1.5rem;width:100%">
|
|
199
|
+
<img src="https://platform-mesh.io/main/pm_logo.svg" alt="Platform Mesh logo" style="width:48px;height:48px;object-fit:contain;flex-shrink:0" />
|
|
200
|
+
<div style="display:flex;gap:2rem;flex-wrap:wrap">
|
|
201
|
+
<div style="display:flex;flex-direction:column;gap:0.25rem">
|
|
202
|
+
<span style="font-size:0.75rem;color:var(--sapContent_LabelColor,#6a6d70)">Workspace Path</span>
|
|
203
|
+
<span style="font-size:0.875rem">root:orgs:sub:a1</span>
|
|
204
|
+
</div>
|
|
205
|
+
<div style="display:flex;flex-direction:column;gap:0.25rem">
|
|
206
|
+
<span style="font-size:0.75rem;color:var(--sapContent_LabelColor,#6a6d70)">Description</span>
|
|
207
|
+
<span style="font-size:0.875rem">Platform Mesh sub-organization</span>
|
|
208
|
+
</div>
|
|
209
|
+
<div style="display:flex;flex-direction:column;gap:0.25rem">
|
|
210
|
+
<span style="font-size:0.75rem;color:var(--sapContent_LabelColor,#6a6d70)">Display Name</span>
|
|
211
|
+
<span style="font-size:0.875rem">a1</span>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
</mfp-dashboard>
|
|
216
|
+
`,
|
|
217
|
+
}),
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export const CompactToolbar: Story = {
|
|
221
|
+
parameters: {
|
|
222
|
+
viewport: { defaultViewport: 'mobile1' },
|
|
223
|
+
chromatic: { viewports: [725] },
|
|
224
|
+
docs: {
|
|
225
|
+
description: {
|
|
226
|
+
story:
|
|
227
|
+
'Below 726 px the individual toolbar buttons collapse into a single menu2 burger button. Click it to see the custom actions and Edit View item separated by a MenuSeparator.',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
render: (args) => ({
|
|
232
|
+
props: args,
|
|
233
|
+
template: `
|
|
234
|
+
<div style="width:725px;overflow:hidden">
|
|
235
|
+
<mfp-dashboard [config]="config" [sections]="sections" [cards]="cards" [availableCards]="availableCards">
|
|
236
|
+
<div slot="dashboard-subheader" style="display:flex;align-items:center;gap:1.5rem;width:100%">
|
|
237
|
+
<img src="https://platform-mesh.io/main/pm_logo.svg" alt="Platform Mesh logo" style="width:48px;height:48px;object-fit:contain;flex-shrink:0" />
|
|
238
|
+
<div style="display:flex;gap:2rem;flex-wrap:wrap">
|
|
239
|
+
<div style="display:flex;flex-direction:column;gap:0.25rem">
|
|
240
|
+
<span style="font-size:0.75rem;color:var(--sapContent_LabelColor,#6a6d70)">Workspace Path</span>
|
|
241
|
+
<span style="font-size:0.875rem">root:orgs:sub:a1</span>
|
|
242
|
+
</div>
|
|
243
|
+
<div style="display:flex;flex-direction:column;gap:0.25rem">
|
|
244
|
+
<span style="font-size:0.75rem;color:var(--sapContent_LabelColor,#6a6d70)">Description</span>
|
|
245
|
+
<span style="font-size:0.875rem">Platform Mesh sub-organization</span>
|
|
246
|
+
</div>
|
|
247
|
+
<div style="display:flex;flex-direction:column;gap:0.25rem">
|
|
248
|
+
<span style="font-size:0.75rem;color:var(--sapContent_LabelColor,#6a6d70)">Display Name</span>
|
|
249
|
+
<span style="font-size:0.875rem">a1</span>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</mfp-dashboard>
|
|
254
|
+
</div>
|
|
255
|
+
`,
|
|
256
|
+
}),
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export const AngularComponentRegistry: Story = {
|
|
260
|
+
args: {
|
|
261
|
+
config: {
|
|
262
|
+
...SAMPLE_CONFIG,
|
|
263
|
+
title: 'Angular Component Registry',
|
|
264
|
+
description:
|
|
265
|
+
'This story mixes registered Angular card components with existing web components.',
|
|
266
|
+
},
|
|
267
|
+
sections: REGISTRY_SECTIONS,
|
|
268
|
+
cards: REGISTRY_CARDS,
|
|
269
|
+
availableCards: ANGULAR_REGISTRY_AVAILABLE_CARDS,
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export const CustomButtonSettings: Story = {
|
|
274
|
+
args: {
|
|
275
|
+
config: {
|
|
276
|
+
...SAMPLE_CONFIG,
|
|
277
|
+
title: 'Custom Button Settings',
|
|
278
|
+
description:
|
|
279
|
+
'Edit View and Add Card buttons configured via buttonSettings — text labels, no icons.',
|
|
280
|
+
buttonsSettings: {
|
|
281
|
+
editViewButton: {
|
|
282
|
+
text: 'Edit View',
|
|
283
|
+
icon: '',
|
|
284
|
+
design: 'Default',
|
|
285
|
+
tooltip: '',
|
|
286
|
+
},
|
|
287
|
+
addCardButton: {
|
|
288
|
+
text: 'Add Card',
|
|
289
|
+
icon: '',
|
|
290
|
+
design: 'Emphasized',
|
|
291
|
+
tooltip: '',
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FormFieldChangeEvent,
|
|
3
|
+
FormFieldDefinition,
|
|
4
|
+
FormFieldErrors,
|
|
5
|
+
} from '../form/models';
|
|
6
|
+
import { CUSTOM_ELEMENTS_SCHEMA, Component, Input } from '@angular/core';
|
|
7
|
+
import type { Meta, StoryObj } from '@storybook/angular';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'mfp-declarative-form-story',
|
|
11
|
+
template: `
|
|
12
|
+
<mfp-wc-declarative-form
|
|
13
|
+
[editMode]="editMode"
|
|
14
|
+
[fieldErrors]="fieldErrors"
|
|
15
|
+
[fields]="fields"
|
|
16
|
+
[initialValues]="initialValues"
|
|
17
|
+
(fieldChange)="handleFormChange($event)"
|
|
18
|
+
/>
|
|
19
|
+
`,
|
|
20
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
21
|
+
})
|
|
22
|
+
class DeclarativeFormStory {
|
|
23
|
+
@Input() fields: FormFieldDefinition[] = [];
|
|
24
|
+
@Input() initialValues: Record<string, unknown> = {};
|
|
25
|
+
@Input() fieldErrors: FormFieldErrors = {};
|
|
26
|
+
@Input() editMode = false;
|
|
27
|
+
|
|
28
|
+
handleFormChange(event: CustomEvent<FormFieldChangeEvent>): void {
|
|
29
|
+
const { fieldProperty, value } = event.detail;
|
|
30
|
+
const field = this.fields.find((f) => f.name === fieldProperty);
|
|
31
|
+
const nextErrors = { ...this.fieldErrors };
|
|
32
|
+
nextErrors[fieldProperty] =
|
|
33
|
+
field?.required && !value
|
|
34
|
+
? `${field.label ?? fieldProperty} is required`
|
|
35
|
+
: null;
|
|
36
|
+
this.fieldErrors = nextErrors;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Meta
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
const meta: Meta<DeclarativeFormStory> = {
|
|
45
|
+
title: 'Declarative UI / DeclarativeForm',
|
|
46
|
+
component: DeclarativeFormStory,
|
|
47
|
+
tags: ['autodocs'],
|
|
48
|
+
parameters: {
|
|
49
|
+
layout: 'centered',
|
|
50
|
+
},
|
|
51
|
+
argTypes: {
|
|
52
|
+
fields: { control: 'object' },
|
|
53
|
+
fieldErrors: { control: 'object' },
|
|
54
|
+
initialValues: { control: 'object' },
|
|
55
|
+
editMode: { control: 'boolean' },
|
|
56
|
+
},
|
|
57
|
+
args: {
|
|
58
|
+
fields: [
|
|
59
|
+
{ name: 'metadata_name', label: 'Name' },
|
|
60
|
+
{ name: 'metadata_namespace', label: 'Namespace' },
|
|
61
|
+
],
|
|
62
|
+
fieldErrors: {},
|
|
63
|
+
initialValues: {},
|
|
64
|
+
editMode: false,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default meta;
|
|
69
|
+
type Story = StoryObj<DeclarativeFormStory>;
|
|
70
|
+
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// Stories
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
/** Minimal setup: two plain text fields. */
|
|
76
|
+
export const Basic: Story = {
|
|
77
|
+
args: {
|
|
78
|
+
fields: [
|
|
79
|
+
{ name: 'metadata_name', label: 'Name' },
|
|
80
|
+
{ name: 'metadata_namespace', label: 'Namespace' },
|
|
81
|
+
] satisfies FormFieldDefinition[],
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Required markers are visual. This story validates in the host wrapper and
|
|
87
|
+
* passes a string error back after the field is dirty.
|
|
88
|
+
*/
|
|
89
|
+
export const WithHostValidation: Story = {
|
|
90
|
+
args: {
|
|
91
|
+
fields: [
|
|
92
|
+
{
|
|
93
|
+
name: 'metadata_name',
|
|
94
|
+
label: 'Name',
|
|
95
|
+
required: true,
|
|
96
|
+
validation: 'onChange',
|
|
97
|
+
},
|
|
98
|
+
{ name: 'metadata_namespace', label: 'Namespace' },
|
|
99
|
+
] satisfies FormFieldDefinition[],
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** Static select — options provided as a plain string array via `values`. */
|
|
104
|
+
export const WithSelect: Story = {
|
|
105
|
+
args: {
|
|
106
|
+
fields: [
|
|
107
|
+
{ name: 'metadata_name', label: 'Name', required: true },
|
|
108
|
+
{
|
|
109
|
+
name: 'spec_scope',
|
|
110
|
+
label: 'Scope',
|
|
111
|
+
required: true,
|
|
112
|
+
values: ['ClusterScoped', 'Namespaced'],
|
|
113
|
+
},
|
|
114
|
+
] satisfies FormFieldDefinition[],
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Edit mode — form pre-populated with `initialValues`.
|
|
120
|
+
* The `editMode` flag is available for consumers to conditionally
|
|
121
|
+
* disable fields or adjust layout.
|
|
122
|
+
*/
|
|
123
|
+
export const EditMode: Story = {
|
|
124
|
+
args: {
|
|
125
|
+
editMode: true,
|
|
126
|
+
initialValues: {
|
|
127
|
+
metadata_name: 'my-resource',
|
|
128
|
+
metadata_namespace: 'default',
|
|
129
|
+
},
|
|
130
|
+
fields: [
|
|
131
|
+
{ name: 'metadata_name', label: 'Name', required: true },
|
|
132
|
+
{ name: 'metadata_namespace', label: 'Namespace' },
|
|
133
|
+
] satisfies FormFieldDefinition[],
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/** All field types combined: text input and select. */
|
|
138
|
+
export const AllFieldTypes: Story = {
|
|
139
|
+
args: {
|
|
140
|
+
fields: [
|
|
141
|
+
{ name: 'metadata_name', label: 'Name', required: true },
|
|
142
|
+
{
|
|
143
|
+
name: 'spec_scope',
|
|
144
|
+
label: 'Scope',
|
|
145
|
+
values: ['ClusterScoped', 'Namespaced'],
|
|
146
|
+
},
|
|
147
|
+
] satisfies FormFieldDefinition[],
|
|
148
|
+
},
|
|
149
|
+
};
|