@cratis/scene.blueprint.default 4.41.0 → 4.42.0
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/ComponentName.ts +9 -0
- package/defaultBlueprintComponents.ts +4 -1
- package/dist/cjs/ComponentName.js +3 -0
- package/dist/cjs/ComponentName.js.map +1 -1
- package/dist/cjs/defaultBlueprint.js +2 -0
- package/dist/cjs/defaultBlueprint.js.map +1 -1
- package/dist/cjs/defaultBlueprintComponentMetadata.js +2 -0
- package/dist/cjs/defaultBlueprintComponentMetadata.js.map +1 -1
- package/dist/cjs/defaultBlueprintComponents.js +8 -0
- package/dist/cjs/defaultBlueprintComponents.js.map +1 -1
- package/dist/cjs/foundation/ActionButton.js.map +1 -1
- package/dist/cjs/foundation/ActionButtonControl.js +46 -0
- package/dist/cjs/foundation/ActionButtonControl.js.map +1 -0
- package/dist/cjs/foundation/DialogFrame.js +196 -0
- package/dist/cjs/foundation/DialogFrame.js.map +1 -0
- package/dist/cjs/foundation/FormScreenBody.js +13 -3
- package/dist/cjs/foundation/FormScreenBody.js.map +1 -1
- package/dist/cjs/foundation/Notice.js +51 -0
- package/dist/cjs/foundation/Notice.js.map +1 -0
- package/dist/cjs/foundation/formModel.js +1 -0
- package/dist/cjs/foundation/formModel.js.map +1 -1
- package/dist/cjs/foundation/foundationComponentMetadata.js +22 -0
- package/dist/cjs/foundation/foundationComponentMetadata.js.map +1 -1
- package/dist/cjs/foundation/foundationDescriptors.js +89 -0
- package/dist/cjs/foundation/foundationDescriptors.js.map +1 -1
- package/dist/cjs/foundation/foundationSamples.js +29 -0
- package/dist/cjs/foundation/foundationSamples.js.map +1 -1
- package/dist/cjs/foundation/foundationStrings.js +3 -1
- package/dist/cjs/foundation/foundationStrings.js.map +1 -1
- package/dist/cjs/foundation/templates/dialogTemplates.js +254 -0
- package/dist/cjs/foundation/templates/dialogTemplates.js.map +1 -0
- package/dist/cjs/foundation/templates/index.js +18 -0
- package/dist/cjs/foundation/templates/index.js.map +1 -1
- package/dist/cjs/foundation/templates/stateScreenTemplates.js +252 -0
- package/dist/cjs/foundation/templates/stateScreenTemplates.js.map +1 -0
- package/dist/cjs/gallery/GalleryDialogPreview.js +62 -0
- package/dist/cjs/gallery/GalleryDialogPreview.js.map +1 -0
- package/dist/cjs/gallery/GalleryScreenPreview.js +2 -0
- package/dist/cjs/gallery/GalleryScreenPreview.js.map +1 -1
- package/dist/cjs/gallery/dialogTemplates.js +41 -36
- package/dist/cjs/gallery/dialogTemplates.js.map +1 -1
- package/dist/cjs/gallery/screens.js +4 -1
- package/dist/cjs/gallery/screens.js.map +1 -1
- package/dist/cjs/index.js +36 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/ComponentName.d.ts +3 -0
- package/dist/esm/ComponentName.d.ts.map +1 -1
- package/dist/esm/ComponentName.js +3 -0
- package/dist/esm/ComponentName.js.map +1 -1
- package/dist/esm/defaultBlueprint.js +2 -0
- package/dist/esm/defaultBlueprint.js.map +1 -1
- package/dist/esm/defaultBlueprintComponentMetadata.js +2 -0
- package/dist/esm/defaultBlueprintComponentMetadata.js.map +1 -1
- package/dist/esm/defaultBlueprintComponents.d.ts.map +1 -1
- package/dist/esm/defaultBlueprintComponents.js +8 -0
- package/dist/esm/defaultBlueprintComponents.js.map +1 -1
- package/dist/esm/foundation/ActionButton.d.ts +1 -1
- package/dist/esm/foundation/ActionButton.d.ts.map +1 -1
- package/dist/esm/foundation/ActionButton.js.map +1 -1
- package/dist/esm/foundation/ActionButtonControl.d.ts +3 -0
- package/dist/esm/foundation/ActionButtonControl.d.ts.map +1 -0
- package/dist/esm/foundation/ActionButtonControl.js +44 -0
- package/dist/esm/foundation/ActionButtonControl.js.map +1 -0
- package/dist/esm/foundation/DialogFrame.d.ts +14 -0
- package/dist/esm/foundation/DialogFrame.d.ts.map +1 -0
- package/dist/esm/foundation/DialogFrame.js +190 -0
- package/dist/esm/foundation/DialogFrame.js.map +1 -0
- package/dist/esm/foundation/FormScreenBody.d.ts.map +1 -1
- package/dist/esm/foundation/FormScreenBody.js +13 -3
- package/dist/esm/foundation/FormScreenBody.js.map +1 -1
- package/dist/esm/foundation/Notice.d.ts +3 -0
- package/dist/esm/foundation/Notice.d.ts.map +1 -0
- package/dist/esm/foundation/Notice.js +49 -0
- package/dist/esm/foundation/Notice.js.map +1 -0
- package/dist/esm/foundation/formModel.d.ts +2 -1
- package/dist/esm/foundation/formModel.d.ts.map +1 -1
- package/dist/esm/foundation/formModel.js +1 -0
- package/dist/esm/foundation/formModel.js.map +1 -1
- package/dist/esm/foundation/foundationComponentMetadata.d.ts.map +1 -1
- package/dist/esm/foundation/foundationComponentMetadata.js +22 -0
- package/dist/esm/foundation/foundationComponentMetadata.js.map +1 -1
- package/dist/esm/foundation/foundationDescriptors.d.ts.map +1 -1
- package/dist/esm/foundation/foundationDescriptors.js +89 -0
- package/dist/esm/foundation/foundationDescriptors.js.map +1 -1
- package/dist/esm/foundation/foundationSamples.d.ts.map +1 -1
- package/dist/esm/foundation/foundationSamples.js +29 -0
- package/dist/esm/foundation/foundationSamples.js.map +1 -1
- package/dist/esm/foundation/foundationStrings.d.ts +2 -0
- package/dist/esm/foundation/foundationStrings.d.ts.map +1 -1
- package/dist/esm/foundation/foundationStrings.js +3 -1
- package/dist/esm/foundation/foundationStrings.js.map +1 -1
- package/dist/esm/foundation/index.d.ts +3 -0
- package/dist/esm/foundation/index.d.ts.map +1 -1
- package/dist/esm/foundation/index.js +3 -0
- package/dist/esm/foundation/index.js.map +1 -1
- package/dist/esm/foundation/templates/dialogTemplates.d.ts +20 -0
- package/dist/esm/foundation/templates/dialogTemplates.d.ts.map +1 -0
- package/dist/esm/foundation/templates/dialogTemplates.js +243 -0
- package/dist/esm/foundation/templates/dialogTemplates.js.map +1 -0
- package/dist/esm/foundation/templates/index.d.ts +2 -0
- package/dist/esm/foundation/templates/index.d.ts.map +1 -1
- package/dist/esm/foundation/templates/index.js +2 -0
- package/dist/esm/foundation/templates/index.js.map +1 -1
- package/dist/esm/foundation/templates/stateScreenTemplates.d.ts +8 -0
- package/dist/esm/foundation/templates/stateScreenTemplates.d.ts.map +1 -0
- package/dist/esm/foundation/templates/stateScreenTemplates.js +245 -0
- package/dist/esm/foundation/templates/stateScreenTemplates.js.map +1 -0
- package/dist/esm/gallery/FoundationDialogs.stories.d.ts +35 -0
- package/dist/esm/gallery/FoundationDialogs.stories.d.ts.map +1 -0
- package/dist/esm/gallery/FoundationDialogs.stories.js +38 -0
- package/dist/esm/gallery/FoundationDialogs.stories.js.map +1 -0
- package/dist/esm/gallery/GalleryDialogPreview.d.ts +17 -0
- package/dist/esm/gallery/GalleryDialogPreview.d.ts.map +1 -0
- package/dist/esm/gallery/GalleryDialogPreview.js +59 -0
- package/dist/esm/gallery/GalleryDialogPreview.js.map +1 -0
- package/dist/esm/gallery/GalleryScreenPreview.js +2 -0
- package/dist/esm/gallery/GalleryScreenPreview.js.map +1 -1
- package/dist/esm/gallery/dialogTemplates.d.ts.map +1 -1
- package/dist/esm/gallery/dialogTemplates.js +42 -37
- package/dist/esm/gallery/dialogTemplates.js.map +1 -1
- package/dist/esm/gallery/index.d.ts +1 -0
- package/dist/esm/gallery/index.d.ts.map +1 -1
- package/dist/esm/gallery/index.js +1 -0
- package/dist/esm/gallery/index.js.map +1 -1
- package/dist/esm/gallery/screens.d.ts.map +1 -1
- package/dist/esm/gallery/screens.js +4 -1
- package/dist/esm/gallery/screens.js.map +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/foundation/ActionButton.tsx +1 -1
- package/foundation/ActionButtonControl.tsx +37 -0
- package/foundation/DialogFrame.tsx +138 -0
- package/foundation/FormScreenBody.tsx +6 -3
- package/foundation/Notice.tsx +33 -0
- package/foundation/formModel.ts +1 -0
- package/foundation/foundationComponentMetadata.ts +3 -0
- package/foundation/foundationDescriptors.ts +41 -0
- package/foundation/foundationSamples.ts +3 -0
- package/foundation/foundationStrings.ts +2 -0
- package/foundation/index.ts +3 -0
- package/foundation/templates/dialogTemplates.ts +114 -0
- package/foundation/templates/index.ts +2 -0
- package/foundation/templates/stateScreenTemplates.ts +107 -0
- package/gallery/FoundationDialogs.stories.tsx +74 -0
- package/gallery/GalleryDialogPreview.tsx +68 -0
- package/gallery/dialogTemplates.ts +22 -17
- package/gallery/index.ts +1 -0
- package/gallery/screens.ts +3 -2
- package/package.json +8 -8
- package/sampleData/foundation-en.json +149 -0
- package/shell/layout.css +219 -0
- package/thumbnails/ConfirmDialog.svg +12 -0
- package/thumbnails/DetailDialog.svg +11 -0
- package/thumbnails/ErrorScreen.svg +11 -0
- package/thumbnails/FilterDialog.svg +16 -0
- package/thumbnails/ForbiddenScreen.svg +10 -0
- package/thumbnails/FormDialog.svg +12 -0
- package/thumbnails/LoginScreen.svg +12 -0
- package/thumbnails/LookupDialog.svg +13 -0
- package/thumbnails/NotFoundScreen.svg +9 -0
- package/thumbnails/QuickCreateDialog.svg +12 -0
- package/thumbnails/SideSheet.svg +13 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var elements = require('../../gallery/elements.js');
|
|
4
|
+
var dialogTemplates = require('./dialogTemplates.js');
|
|
5
|
+
var flowBuilders = require('../../layouts/flowBuilders.js');
|
|
6
|
+
var templateParts = require('./templateParts.js');
|
|
7
|
+
|
|
8
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
9
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
10
|
+
const metadataOf = (name, type)=>({
|
|
11
|
+
...templateParts.foundationTemplateProvenance,
|
|
12
|
+
type,
|
|
13
|
+
category: `Foundation / ${type}`,
|
|
14
|
+
thumbnail: templateParts.thumbnailOf(name)
|
|
15
|
+
});
|
|
16
|
+
/** The way back every state screen offers: home, which is always somewhere the person is allowed to be. */ const backToDashboard = (id)=>dialogTemplates.actionButton(id, {
|
|
17
|
+
label: 'Back to the dashboard',
|
|
18
|
+
emphasis: 'secondary',
|
|
19
|
+
targetScreen: 'DashboardScreen'
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* The sign-in screen: the logo, the sign-in form, a slot for the identity providers the application offers (`providers` - buttons, each starting its
|
|
23
|
+
* provider's flow, which the application fills), an error area that is a live region and says why a sign-in failed, and a link to help. The form is
|
|
24
|
+
* made of the foundation's form components, so it validates and announces like every other form.
|
|
25
|
+
*/ const loginScreenTemplate = {
|
|
26
|
+
name: 'LoginScreen',
|
|
27
|
+
fitsSlot: 'content',
|
|
28
|
+
slots: [
|
|
29
|
+
{
|
|
30
|
+
name: 'logo'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'error'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'form'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'providers'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'help'
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
arrangement: {
|
|
46
|
+
root: flowBuilders.column([
|
|
47
|
+
flowBuilders.slotLeaf('logo'),
|
|
48
|
+
flowBuilders.slotLeaf('error'),
|
|
49
|
+
flowBuilders.slotLeaf('form'),
|
|
50
|
+
flowBuilders.slotLeaf('providers'),
|
|
51
|
+
flowBuilders.slotLeaf('help')
|
|
52
|
+
], 16)
|
|
53
|
+
},
|
|
54
|
+
content: {
|
|
55
|
+
logo: [
|
|
56
|
+
elements.externalComponent('login-logo', 'logo', {
|
|
57
|
+
label: 'Contoso',
|
|
58
|
+
initials: 'C'
|
|
59
|
+
})
|
|
60
|
+
],
|
|
61
|
+
error: [
|
|
62
|
+
templateParts.component('login-error', 'notice', {
|
|
63
|
+
text: templateParts.fromQuery('SignInError', '0.message'),
|
|
64
|
+
tone: 'danger'
|
|
65
|
+
})
|
|
66
|
+
],
|
|
67
|
+
form: [
|
|
68
|
+
templateParts.component('login-form', 'formScreenBody', {
|
|
69
|
+
mode: 'create',
|
|
70
|
+
saveAndNew: false,
|
|
71
|
+
strings: {
|
|
72
|
+
formSave: 'Sign in',
|
|
73
|
+
formCancel: 'Clear'
|
|
74
|
+
},
|
|
75
|
+
sections: templateParts.fromQuery('SignInSections'),
|
|
76
|
+
values: templateParts.fromQuery('SignInValues', '0'),
|
|
77
|
+
errors: templateParts.fromQuery('FormErrors', '0')
|
|
78
|
+
})
|
|
79
|
+
],
|
|
80
|
+
providers: [
|
|
81
|
+
elements.panel('login-providers', [
|
|
82
|
+
dialogTemplates.actionButton('login-microsoft', {
|
|
83
|
+
label: 'Continue with Microsoft',
|
|
84
|
+
emphasis: 'secondary'
|
|
85
|
+
}),
|
|
86
|
+
dialogTemplates.actionButton('login-github', {
|
|
87
|
+
label: 'Continue with GitHub',
|
|
88
|
+
emphasis: 'secondary'
|
|
89
|
+
})
|
|
90
|
+
])
|
|
91
|
+
],
|
|
92
|
+
help: [
|
|
93
|
+
dialogTemplates.actionButton('login-help', {
|
|
94
|
+
label: 'Need help signing in?',
|
|
95
|
+
emphasis: 'quiet',
|
|
96
|
+
targetScreen: 'ForbiddenScreen'
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
displayName: 'Sign in',
|
|
101
|
+
description: 'A sign-in form with a slot for identity providers, an error area and a help link.',
|
|
102
|
+
metadata: metadataOf('LoginScreen', 'Auth')
|
|
103
|
+
};
|
|
104
|
+
/** The wrong address: what happened in words, a search, and the way home. */ const notFoundScreenTemplate = {
|
|
105
|
+
name: 'NotFoundScreen',
|
|
106
|
+
fitsSlot: 'content',
|
|
107
|
+
slots: [
|
|
108
|
+
{
|
|
109
|
+
name: 'message'
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'search'
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'actions'
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
arrangement: {
|
|
119
|
+
root: flowBuilders.column([
|
|
120
|
+
flowBuilders.slotLeaf('message'),
|
|
121
|
+
flowBuilders.slotLeaf('search'),
|
|
122
|
+
flowBuilders.slotLeaf('actions')
|
|
123
|
+
], 16)
|
|
124
|
+
},
|
|
125
|
+
content: {
|
|
126
|
+
message: [
|
|
127
|
+
templateParts.component('not-found-message', 'emptyState', {
|
|
128
|
+
icon: 'file',
|
|
129
|
+
headline: 'That page is not here',
|
|
130
|
+
hint: 'The link may be old, or the thing it pointed at may have been removed.'
|
|
131
|
+
})
|
|
132
|
+
],
|
|
133
|
+
search: [
|
|
134
|
+
templateParts.component('not-found-search', 'globalSearch', {
|
|
135
|
+
label: 'Search the application',
|
|
136
|
+
placeholder: 'Search instead'
|
|
137
|
+
})
|
|
138
|
+
],
|
|
139
|
+
actions: [
|
|
140
|
+
backToDashboard('not-found-home')
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
displayName: 'Not found',
|
|
144
|
+
description: 'A wrong address explained, with a search and a link home.',
|
|
145
|
+
metadata: metadataOf('NotFoundScreen', 'State')
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* The refusal: signed in, and still not allowed. It says so and offers to ask for access, and it shows nothing of what was refused - the template binds
|
|
149
|
+
* no data at all, so there is nothing to leak.
|
|
150
|
+
*/ const forbiddenScreenTemplate = {
|
|
151
|
+
name: 'ForbiddenScreen',
|
|
152
|
+
fitsSlot: 'content',
|
|
153
|
+
slots: [
|
|
154
|
+
{
|
|
155
|
+
name: 'message'
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'actions'
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
arrangement: {
|
|
162
|
+
root: flowBuilders.column([
|
|
163
|
+
flowBuilders.slotLeaf('message'),
|
|
164
|
+
flowBuilders.slotLeaf('actions')
|
|
165
|
+
], 16)
|
|
166
|
+
},
|
|
167
|
+
content: {
|
|
168
|
+
message: [
|
|
169
|
+
templateParts.component('forbidden-message', 'emptyState', {
|
|
170
|
+
icon: 'lock',
|
|
171
|
+
headline: 'You do not have access to this',
|
|
172
|
+
hint: 'Your account is signed in, but it is not allowed here. An administrator can change that.',
|
|
173
|
+
actionLabel: 'Request access'
|
|
174
|
+
})
|
|
175
|
+
],
|
|
176
|
+
actions: [
|
|
177
|
+
backToDashboard('forbidden-home')
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
displayName: 'Forbidden',
|
|
181
|
+
description: 'A refusal that offers to request access and shows none of what was refused.',
|
|
182
|
+
metadata: metadataOf('ForbiddenScreen', 'State')
|
|
183
|
+
};
|
|
184
|
+
/** The failure on our side: a plain message, a retry, and the support reference id a person can quote. */ const errorScreenTemplate = {
|
|
185
|
+
name: 'ErrorScreen',
|
|
186
|
+
fitsSlot: 'content',
|
|
187
|
+
slots: [
|
|
188
|
+
{
|
|
189
|
+
name: 'message'
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'reference'
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: 'actions'
|
|
196
|
+
}
|
|
197
|
+
],
|
|
198
|
+
arrangement: {
|
|
199
|
+
root: flowBuilders.column([
|
|
200
|
+
flowBuilders.slotLeaf('message'),
|
|
201
|
+
flowBuilders.slotLeaf('reference'),
|
|
202
|
+
flowBuilders.slotLeaf('actions')
|
|
203
|
+
], 16)
|
|
204
|
+
},
|
|
205
|
+
content: {
|
|
206
|
+
message: [
|
|
207
|
+
templateParts.component('error-message', 'emptyState', {
|
|
208
|
+
icon: 'alert',
|
|
209
|
+
headline: 'Something went wrong on our side',
|
|
210
|
+
hint: 'The team has been told. Nothing you were working on was lost.',
|
|
211
|
+
actionLabel: 'Try again'
|
|
212
|
+
})
|
|
213
|
+
],
|
|
214
|
+
reference: [
|
|
215
|
+
elements.panel('error-reference', [
|
|
216
|
+
elements.externalComponent('error-reference-label', 'text', {
|
|
217
|
+
text: 'Support reference'
|
|
218
|
+
}),
|
|
219
|
+
elements.externalComponent('error-reference-id', 'text', {
|
|
220
|
+
text: templateParts.fromQuery('SupportReference', '0.id')
|
|
221
|
+
})
|
|
222
|
+
])
|
|
223
|
+
],
|
|
224
|
+
actions: [
|
|
225
|
+
backToDashboard('error-home')
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
displayName: 'Error',
|
|
229
|
+
description: 'A generic failure with a retry and the support reference id to quote.',
|
|
230
|
+
metadata: metadataOf('ErrorScreen', 'State')
|
|
231
|
+
};
|
|
232
|
+
/** The four auth and state screens of Part B 2.11. The legacy `Login`, `NotFound`, `AccessDenied` and `Error` remain as they were. */ const stateScreenTemplates = [
|
|
233
|
+
loginScreenTemplate,
|
|
234
|
+
notFoundScreenTemplate,
|
|
235
|
+
forbiddenScreenTemplate,
|
|
236
|
+
errorScreenTemplate
|
|
237
|
+
];
|
|
238
|
+
/** The earlier template each spec-named one stands beside: the old name keeps working, and is the alias of the new. */ const foundationTemplateAliases = {
|
|
239
|
+
LoginScreen: 'Login',
|
|
240
|
+
NotFoundScreen: 'NotFound',
|
|
241
|
+
ForbiddenScreen: 'AccessDenied',
|
|
242
|
+
ErrorScreen: 'Error',
|
|
243
|
+
QuickCreateDialog: 'FormDialog'
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
exports.errorScreenTemplate = errorScreenTemplate;
|
|
247
|
+
exports.forbiddenScreenTemplate = forbiddenScreenTemplate;
|
|
248
|
+
exports.foundationTemplateAliases = foundationTemplateAliases;
|
|
249
|
+
exports.loginScreenTemplate = loginScreenTemplate;
|
|
250
|
+
exports.notFoundScreenTemplate = notFoundScreenTemplate;
|
|
251
|
+
exports.stateScreenTemplates = stateScreenTemplates;
|
|
252
|
+
//# sourceMappingURL=stateScreenTemplates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateScreenTemplates.js","sources":["../../../../foundation/templates/stateScreenTemplates.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ScreenTemplate, TemplateMetadata } from '@cratis/scene.model';\nimport { externalComponent, panel } from '../../gallery/elements';\nimport { actionButton } from './dialogTemplates';\nimport { column, slotLeaf } from '../../layouts/flowBuilders';\nimport { component, foundationTemplateProvenance, fromQuery, thumbnailOf } from './templateParts';\n\nconst metadataOf = (name: string, type: 'Auth' | 'State'): TemplateMetadata => ({ ...foundationTemplateProvenance, type, category: `Foundation / ${type}`, thumbnail: thumbnailOf(name) });\n\n/** The way back every state screen offers: home, which is always somewhere the person is allowed to be. */\nconst backToDashboard = (id: string) => actionButton(id, { label: 'Back to the dashboard', emphasis: 'secondary', targetScreen: 'DashboardScreen' });\n\n/**\n * The sign-in screen: the logo, the sign-in form, a slot for the identity providers the application offers (`providers` - buttons, each starting its\n * provider's flow, which the application fills), an error area that is a live region and says why a sign-in failed, and a link to help. The form is\n * made of the foundation's form components, so it validates and announces like every other form.\n */\nexport const loginScreenTemplate: ScreenTemplate = {\n name: 'LoginScreen',\n fitsSlot: 'content',\n slots: [{ name: 'logo' }, { name: 'error' }, { name: 'form' }, { name: 'providers' }, { name: 'help' }],\n arrangement: { root: column([slotLeaf('logo'), slotLeaf('error'), slotLeaf('form'), slotLeaf('providers'), slotLeaf('help')], 16) },\n content: {\n logo: [externalComponent('login-logo', 'logo', { label: 'Contoso', initials: 'C' })],\n error: [component('login-error', 'notice', { text: fromQuery('SignInError', '0.message'), tone: 'danger' })],\n form: [component('login-form', 'formScreenBody', {\n mode: 'create', saveAndNew: false, strings: { formSave: 'Sign in', formCancel: 'Clear' },\n sections: fromQuery('SignInSections'), values: fromQuery('SignInValues', '0'), errors: fromQuery('FormErrors', '0'),\n })],\n providers: [panel('login-providers', [actionButton('login-microsoft', { label: 'Continue with Microsoft', emphasis: 'secondary' }), actionButton('login-github', { label: 'Continue with GitHub', emphasis: 'secondary' })])],\n help: [actionButton('login-help', { label: 'Need help signing in?', emphasis: 'quiet', targetScreen: 'ForbiddenScreen' })],\n },\n displayName: 'Sign in',\n description: 'A sign-in form with a slot for identity providers, an error area and a help link.',\n metadata: metadataOf('LoginScreen', 'Auth'),\n};\n\n/** The wrong address: what happened in words, a search, and the way home. */\nexport const notFoundScreenTemplate: ScreenTemplate = {\n name: 'NotFoundScreen',\n fitsSlot: 'content',\n slots: [{ name: 'message' }, { name: 'search' }, { name: 'actions' }],\n arrangement: { root: column([slotLeaf('message'), slotLeaf('search'), slotLeaf('actions')], 16) },\n content: {\n message: [component('not-found-message', 'emptyState', { icon: 'file', headline: 'That page is not here', hint: 'The link may be old, or the thing it pointed at may have been removed.' })],\n search: [component('not-found-search', 'globalSearch', { label: 'Search the application', placeholder: 'Search instead' })],\n actions: [backToDashboard('not-found-home')],\n },\n displayName: 'Not found',\n description: 'A wrong address explained, with a search and a link home.',\n metadata: metadataOf('NotFoundScreen', 'State'),\n};\n\n/**\n * The refusal: signed in, and still not allowed. It says so and offers to ask for access, and it shows nothing of what was refused - the template binds\n * no data at all, so there is nothing to leak.\n */\nexport const forbiddenScreenTemplate: ScreenTemplate = {\n name: 'ForbiddenScreen',\n fitsSlot: 'content',\n slots: [{ name: 'message' }, { name: 'actions' }],\n arrangement: { root: column([slotLeaf('message'), slotLeaf('actions')], 16) },\n content: {\n message: [component('forbidden-message', 'emptyState', {\n icon: 'lock', headline: 'You do not have access to this', hint: 'Your account is signed in, but it is not allowed here. An administrator can change that.', actionLabel: 'Request access',\n })],\n actions: [backToDashboard('forbidden-home')],\n },\n displayName: 'Forbidden',\n description: 'A refusal that offers to request access and shows none of what was refused.',\n metadata: metadataOf('ForbiddenScreen', 'State'),\n};\n\n/** The failure on our side: a plain message, a retry, and the support reference id a person can quote. */\nexport const errorScreenTemplate: ScreenTemplate = {\n name: 'ErrorScreen',\n fitsSlot: 'content',\n slots: [{ name: 'message' }, { name: 'reference' }, { name: 'actions' }],\n arrangement: { root: column([slotLeaf('message'), slotLeaf('reference'), slotLeaf('actions')], 16) },\n content: {\n message: [component('error-message', 'emptyState', {\n icon: 'alert', headline: 'Something went wrong on our side', hint: 'The team has been told. Nothing you were working on was lost.', actionLabel: 'Try again',\n })],\n reference: [panel('error-reference', [\n externalComponent('error-reference-label', 'text', { text: 'Support reference' }),\n externalComponent('error-reference-id', 'text', { text: fromQuery('SupportReference', '0.id') }),\n ])],\n actions: [backToDashboard('error-home')],\n },\n displayName: 'Error',\n description: 'A generic failure with a retry and the support reference id to quote.',\n metadata: metadataOf('ErrorScreen', 'State'),\n};\n\n/** The four auth and state screens of Part B 2.11. The legacy `Login`, `NotFound`, `AccessDenied` and `Error` remain as they were. */\nexport const stateScreenTemplates: ScreenTemplate[] = [loginScreenTemplate, notFoundScreenTemplate, forbiddenScreenTemplate, errorScreenTemplate];\n\n/** The earlier template each spec-named one stands beside: the old name keeps working, and is the alias of the new. */\nexport const foundationTemplateAliases: Record<string, string> = {\n LoginScreen: 'Login',\n NotFoundScreen: 'NotFound',\n ForbiddenScreen: 'AccessDenied',\n ErrorScreen: 'Error',\n QuickCreateDialog: 'FormDialog',\n};\n"],"names":["metadataOf","name","type","foundationTemplateProvenance","category","thumbnail","thumbnailOf","backToDashboard","id","actionButton","label","emphasis","targetScreen","loginScreenTemplate","fitsSlot","slots","arrangement","root","column","slotLeaf","content","logo","externalComponent","initials","error","component","text","fromQuery","tone","form","mode","saveAndNew","strings","formSave","formCancel","sections","values","errors","providers","panel","help","displayName","description","metadata","notFoundScreenTemplate","message","icon","headline","hint","search","placeholder","actions","forbiddenScreenTemplate","actionLabel","errorScreenTemplate","reference","stateScreenTemplates","foundationTemplateAliases","LoginScreen","NotFoundScreen","ForbiddenScreen","ErrorScreen","QuickCreateDialog"],"mappings":";;;;;;;AAAA;AACA;AAQA,MAAMA,UAAAA,GAAa,CAACC,IAAAA,EAAcC,IAAAA,IAA8C;AAAE,QAAA,GAAGC,0CAA4B;AAAED,QAAAA,IAAAA;QAAME,QAAAA,EAAU,CAAC,aAAa,EAAEF,IAAAA,CAAAA,CAAM;AAAEG,QAAAA,SAAAA,EAAWC,yBAAAA,CAAYL,IAAAA;KA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WAAAA,EAAa,uEAAA;AACbC,IAAAA,QAAAA,EAAU3C,WAAW,aAAA,EAAe,OAAA;AACxC;AAEA,uIACO,MAAMwD,oBAAAA,GAAyC;AAAC3C,IAAAA,mBAAAA;AAAqB+B,IAAAA,sBAAAA;AAAwBQ,IAAAA,uBAAAA;AAAyBE,IAAAA;;AAE7H,wHACO,MAAMG,yBAAAA,GAAoD;IAC7DC,WAAAA,EAAa,OAAA;IACbC,cAAAA,EAAgB,UAAA;IAChBC,eAAAA,EAAiB,cAAA;IACjBC,WAAAA,EAAa,OAAA;IACbC,iBAAAA,EAAmB;AACvB;;;;;;;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var scene_react = require('@cratis/scene.react');
|
|
6
|
+
var LayoutConfigProvider = require('../configuration/LayoutConfigProvider.js');
|
|
7
|
+
var PreviewTemplate = require('../preview-host/PreviewTemplate.js');
|
|
8
|
+
var defaultBlueprintThemes = require('../themes/defaultBlueprintThemes.js');
|
|
9
|
+
var LayoutThemeProvider = require('../themes/LayoutThemeProvider.js');
|
|
10
|
+
var elements = require('./elements.js');
|
|
11
|
+
var GalleryScreenPreview = require('./GalleryScreenPreview.js');
|
|
12
|
+
var dialogTemplates = require('./dialogTemplates.js');
|
|
13
|
+
var previewProfile = require('./previewProfile.js');
|
|
14
|
+
var resolveElementNames = require('./resolveElementNames.js');
|
|
15
|
+
var TemplatePreviewState = require('./TemplatePreviewState.js');
|
|
16
|
+
|
|
17
|
+
/** One gallery dialog template by name, for a story or a host that opens a specific one. */ const galleryDialogTemplate = (name)=>dialogTemplates.galleryDialogTemplates.find((template)=>template.name === name);
|
|
18
|
+
/**
|
|
19
|
+
* Opens one gallery dialog template the way a host does: inside a `role="dialog" aria-modal="true"` element, with the template's content in the wrapper
|
|
20
|
+
* a screen's template gets. Nothing here is a preview-only path - the dialog is a real {@link DialogTemplate} rendered by the real `SceneElementView`,
|
|
21
|
+
* and the dialog's own frame gives the host element its focus handling, placement and labelling exactly as it does in an application.
|
|
22
|
+
*/ function GalleryDialogPreview({ dialogName, initialConfig, themes = defaultBlueprintThemes.defaultBlueprintThemes, registry = GalleryScreenPreview.galleryPreviewRegistry, state = TemplatePreviewState.TemplatePreviewState.Populated, pack, forceState }) {
|
|
23
|
+
const template = galleryDialogTemplate(dialogName);
|
|
24
|
+
if (!template) throw new Error(`The gallery has no dialog template named '${dialogName}'.`);
|
|
25
|
+
const element = react.useMemo(()=>{
|
|
26
|
+
const composed = elements.externalComponent(`dialog-${template.name}`, PreviewTemplate.previewTemplateComponent, {}, template.content ?? {});
|
|
27
|
+
const resolved = resolveElementNames.resolveElementComponentNames(composed, previewProfile.galleryPreviewProfile, previewProfile.galleryComponentCatalog);
|
|
28
|
+
return forceState ? GalleryScreenPreview.forceComponentState(resolved, forceState) : resolved;
|
|
29
|
+
}, [
|
|
30
|
+
template,
|
|
31
|
+
forceState
|
|
32
|
+
]);
|
|
33
|
+
const full = react.useMemo(()=>({
|
|
34
|
+
...registry,
|
|
35
|
+
...PreviewTemplate.previewComponents
|
|
36
|
+
}), [
|
|
37
|
+
registry
|
|
38
|
+
]);
|
|
39
|
+
return /*#__PURE__*/ jsxRuntime.jsx(LayoutConfigProvider.LayoutConfigProvider, {
|
|
40
|
+
initialConfig: initialConfig,
|
|
41
|
+
storage: null,
|
|
42
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(LayoutThemeProvider.LayoutThemeProvider, {
|
|
43
|
+
themes: themes,
|
|
44
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
45
|
+
role: "dialog",
|
|
46
|
+
"aria-modal": "true",
|
|
47
|
+
"aria-label": template.displayName ?? template.name,
|
|
48
|
+
"data-scene-dialog": template.name,
|
|
49
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(scene_react.SceneElementView, {
|
|
50
|
+
element: element,
|
|
51
|
+
registry: full,
|
|
52
|
+
resolveBinding: ()=>undefined,
|
|
53
|
+
queryResults: GalleryScreenPreview.queryResultsOf(pack, state)
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports.GalleryDialogPreview = GalleryDialogPreview;
|
|
61
|
+
exports.galleryDialogTemplate = galleryDialogTemplate;
|
|
62
|
+
//# sourceMappingURL=GalleryDialogPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GalleryDialogPreview.js","sources":["../../../gallery/GalleryDialogPreview.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useMemo } from 'react';\nimport { DialogTemplate, SampleDataPack, Theme } from '@cratis/scene.model';\nimport { ComponentRegistry, SceneElementView } from '@cratis/scene.react';\nimport { LayoutConfigProvider, LayoutConfigState } from '../configuration';\nimport { previewComponents, previewTemplateComponent } from '../preview-host/PreviewTemplate';\nimport { LayoutThemeProvider, defaultBlueprintThemes } from '../themes';\nimport { externalComponent } from './elements';\nimport { ForcedComponentState, forceComponentState, galleryPreviewRegistry, queryResultsOf } from './GalleryScreenPreview';\nimport { galleryDialogTemplates } from './dialogTemplates';\nimport { galleryComponentCatalog, galleryPreviewProfile } from './previewProfile';\nimport { resolveElementComponentNames } from './resolveElementNames';\nimport { TemplatePreviewState } from './TemplatePreviewState';\n\n/** One gallery dialog template by name, for a story or a host that opens a specific one. */\nexport const galleryDialogTemplate = (name: string): DialogTemplate | undefined => galleryDialogTemplates.find(template => template.name === name);\n\nexport interface GalleryDialogPreviewProps {\n /** The name of the gallery dialog template to open. */\n dialogName: string;\n\n /** Configuration to start from. */\n initialConfig?: Partial<LayoutConfigState>;\n\n /** The themes the preview may switch between. Defaults to the two this blueprint ships. */\n themes?: Theme[];\n\n /** The component registry to render against. Defaults to `core` plus this blueprint's own components. */\n registry?: ComponentRegistry;\n\n /** The data state to show. Defaults to the seeded, populated records. */\n state?: TemplatePreviewState;\n\n /** The sample-data pack that stands in for the queries the template binds to. */\n pack?: SampleDataPack;\n\n /** A standard state (spec Part B 1.4) to force on every foundation component of the dialog that owns the five states. */\n forceState?: ForcedComponentState;\n}\n\n/**\n * Opens one gallery dialog template the way a host does: inside a `role=\"dialog\" aria-modal=\"true\"` element, with the template's content in the wrapper\n * a screen's template gets. Nothing here is a preview-only path - the dialog is a real {@link DialogTemplate} rendered by the real `SceneElementView`,\n * and the dialog's own frame gives the host element its focus handling, placement and labelling exactly as it does in an application.\n */\nexport function GalleryDialogPreview({ dialogName, initialConfig, themes = defaultBlueprintThemes, registry = galleryPreviewRegistry, state = TemplatePreviewState.Populated, pack, forceState }: GalleryDialogPreviewProps) {\n const template = galleryDialogTemplate(dialogName);\n if (!template) throw new Error(`The gallery has no dialog template named '${dialogName}'.`);\n\n const element = useMemo(() => {\n const composed = externalComponent(`dialog-${template.name}`, previewTemplateComponent, {}, template.content ?? {});\n const resolved = resolveElementComponentNames(composed, galleryPreviewProfile, galleryComponentCatalog);\n return forceState ? forceComponentState(resolved, forceState) : resolved;\n }, [template, forceState]);\n const full = useMemo(() => ({ ...registry, ...previewComponents }), [registry]);\n\n return (\n <LayoutConfigProvider initialConfig={initialConfig} storage={null}>\n <LayoutThemeProvider themes={themes}>\n <div role='dialog' aria-modal='true' aria-label={template.displayName ?? template.name} data-scene-dialog={template.name}>\n <SceneElementView element={element} registry={full} resolveBinding={() => undefined} queryResults={queryResultsOf(pack, state)} />\n </div>\n </LayoutThemeProvider>\n </LayoutConfigProvider>\n );\n}\n"],"names":["galleryDialogTemplate","name","galleryDialogTemplates","find","template","GalleryDialogPreview","dialogName","initialConfig","themes","defaultBlueprintThemes","registry","galleryPreviewRegistry","state","TemplatePreviewState","Populated","pack","forceState","Error","element","useMemo","composed","externalComponent","previewTemplateComponent","content","resolved","resolveElementComponentNames","galleryPreviewProfile","galleryComponentCatalog","forceComponentState","full","previewComponents","_jsx","LayoutConfigProvider","storage","LayoutThemeProvider","div","role","aria-modal","aria-label","displayName","data-scene-dialog","SceneElementView","resolveBinding","undefined","queryResults","queryResultsOf"],"mappings":";;;;;;;;;;;;;;;;AAgBA,6FACO,MAAMA,qBAAAA,GAAwB,CAACC,IAAAA,GAA6CC,sCAAAA,CAAuBC,IAAI,CAACC,CAAAA,QAAAA,GAAYA,QAAAA,CAASH,IAAI,KAAKA,IAAAA;AAyB7I;;;;IAKO,SAASI,oBAAAA,CAAqB,EAAEC,UAAU,EAAEC,aAAa,EAAEC,MAAAA,GAASC,6CAAsB,EAAEC,QAAAA,GAAWC,2CAAsB,EAAEC,KAAAA,GAAQC,yCAAAA,CAAqBC,SAAS,EAAEC,IAAI,EAAEC,UAAU,EAA6B,EAAA;AACvN,IAAA,MAAMZ,WAAWJ,qBAAAA,CAAsBM,UAAAA,CAAAA;IACvC,IAAI,CAACF,QAAAA,EAAU,MAAM,IAAIa,KAAAA,CAAM,CAAC,0CAA0C,EAAEX,UAAAA,CAAW,EAAE,CAAC,CAAA;AAE1F,IAAA,MAAMY,UAAUC,aAAAA,CAAQ,IAAA;AACpB,QAAA,MAAMC,QAAAA,GAAWC,0BAAAA,CAAkB,CAAC,OAAO,EAAEjB,QAAAA,CAASH,IAAI,CAAA,CAAE,EAAEqB,0CAA0B,EAAC,EAAGlB,QAAAA,CAASmB,OAAO,IAAI,EAAC,CAAA;QACjH,MAAMC,QAAAA,GAAWC,gDAAAA,CAA6BL,QAAAA,EAAUM,oCAAAA,EAAuBC,sCAAAA,CAAAA;QAC/E,OAAOX,UAAAA,GAAaY,wCAAAA,CAAoBJ,QAAAA,EAAUR,UAAAA,CAAAA,GAAcQ,QAAAA;IACpE,CAAA,EAAG;AAACpB,QAAAA,QAAAA;AAAUY,QAAAA;AAAW,KAAA,CAAA;IACzB,MAAMa,IAAAA,GAAOV,aAAAA,CAAQ,KAAO;AAAE,YAAA,GAAGT,QAAQ;AAAE,YAAA,GAAGoB;AAAkB,SAAA,CAAA,EAAI;AAACpB,QAAAA;AAAS,KAAA,CAAA;AAE9E,IAAA,qBACIqB,cAAA,CAACC,yCAAAA,EAAAA;QAAqBzB,aAAAA,EAAeA,aAAAA;QAAe0B,OAAAA,EAAS,IAAA;AACzD,QAAA,QAAA,gBAAAF,cAAA,CAACG,uCAAAA,EAAAA;YAAoB1B,MAAAA,EAAQA,MAAAA;AACzB,YAAA,QAAA,gBAAAuB,cAAA,CAACI,KAAAA,EAAAA;gBAAIC,IAAAA,EAAK,QAAA;gBAASC,YAAAA,EAAW,MAAA;AAAOC,gBAAAA,YAAAA,EAAYlC,QAAAA,CAASmC,WAAW,IAAInC,QAAAA,CAASH,IAAI;AAAEuC,gBAAAA,mBAAAA,EAAmBpC,SAASH,IAAI;AACpH,gBAAA,QAAA,gBAAA8B,cAAA,CAACU,4BAAAA,EAAAA;oBAAiBvB,OAAAA,EAASA,OAAAA;oBAASR,QAAAA,EAAUmB,IAAAA;AAAMa,oBAAAA,cAAAA,EAAgB,IAAMC,SAAAA;AAAWC,oBAAAA,YAAAA,EAAcC,oCAAe9B,IAAAA,EAAMH,KAAAA;;;;;AAK5I;;;"}
|
|
@@ -24,6 +24,8 @@ require('../foundation/templates/recordPageTemplate.js');
|
|
|
24
24
|
require('../foundation/templates/wizardScreenTemplate.js');
|
|
25
25
|
require('../foundation/templates/workspaceScreenTemplate.js');
|
|
26
26
|
require('../foundation/templates/templateParts.js');
|
|
27
|
+
require('../foundation/templates/dialogTemplates.js');
|
|
28
|
+
require('../foundation/templates/stateScreenTemplates.js');
|
|
27
29
|
var composeScreen = require('./composeScreen.js');
|
|
28
30
|
var previewProfile = require('./previewProfile.js');
|
|
29
31
|
var resolveElementNames = require('./resolveElementNames.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryScreenPreview.js","sources":["../../../gallery/GalleryScreenPreview.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useMemo } from 'react';\nimport { ExternalComponent, SampleDataPack, SceneElement, Theme } from '@cratis/scene.model';\nimport { ComponentRegistry, SceneElementView, coreComponents } from '@cratis/scene.react';\nimport { LayoutConfigProvider, LayoutConfigState } from '../configuration';\nimport { ComponentName } from '../ComponentName';\nimport { defaultBlueprintComponents } from '../defaultBlueprintComponents';\nimport { ComponentState, foundationSamples } from '../foundation';\nimport { defaultBlueprintName } from '../packageName';\nimport { LayoutThemeProvider, defaultBlueprintThemes } from '../themes';\nimport { composeScreenElement } from './composeScreen';\nimport { galleryComponentCatalog, galleryPreviewProfile } from './previewProfile';\nimport { resolveElementComponentNames } from './resolveElementNames';\nimport { galleryScreen } from './screens';\nimport { TemplatePreviewState } from './TemplatePreviewState';\nimport { applyTemplatePreviewState } from './applyTemplatePreviewState';\n\n/**\n * The registry a preview resolves against when a host does not supply one: `core` plus this blueprint.\n *\n * Merged by hand rather than through `mergePackageRegistries`, because reaching for this blueprint's\n * *bundle* here would be circular - the bundle is assembled from the gallery this file belongs to. Registry\n * keys carry their package name, so merge order cannot cause a collision either way.\n */\nexport const galleryPreviewRegistry: ComponentRegistry = { ...coreComponents, ...defaultBlueprintComponents };\n\nexport interface GalleryScreenPreviewProps {\n /** The name of the gallery screen to boot. */\n screenName: string;\n\n /** Configuration to start from - a story pinning a mode, or a host restoring a session. */\n initialConfig?: Partial<LayoutConfigState>;\n\n /** The themes the configurator may switch between. Defaults to the two this blueprint ships. */\n themes?: Theme[];\n\n /** The component registry to render against. Defaults to `core` plus this blueprint's own components. */\n registry?: ComponentRegistry;\n\n /** The data state to show. Defaults to the seeded, populated records. */\n state?: TemplatePreviewState;\n\n /**\n * The sample-data pack that stands in for the queries the templates bind to: each set's `shape` is a query name and its `rows` that query's result.\n * Templates carry no rows of their own - they declare where the data comes from (spec SD1) - so a preview of a foundation template needs one.\n */\n pack?: SampleDataPack;\n\n /**\n * A standard state (spec Part B 1.4) to force on every foundation component that owns the five states: loading, error, no-permission or partial.\n * This is how a designer inspects each one on a real template - it only sets the `state` property the components already read, so there is no\n * second code path. `error`, `permissionSubject` and `failedRegions` give the state its message.\n */\n forceState?: ForcedComponentState;\n}\n\n/** The standard states a preview can force on a template's components. */\nexport interface ForcedComponentState {\n state: ComponentState;\n error?: string;\n permissionSubject?: string;\n failedRegions?: string[];\n}\n\n/** Components that are chrome or controls rather than data-showing regions, and so do not own the five states. */\nconst withoutStates = new Set<string>([\n ComponentName.EmptyState, ComponentName.TrendChip, ComponentName.StatusChip, ComponentName.BulkBar, ComponentName.GlobalSearch, ComponentName.NotificationsButton,\n]);\n\n/** Sets the forced state on every region that owns the five states, leaving chrome and controls as they are. */\nexport function forceComponentState(element: SceneElement, forced: ForcedComponentState): SceneElement {\n const external = element as Partial<ExternalComponent>;\n const children = (element as { children?: SceneElement[] }).children;\n const slots = external.slots ? Object.fromEntries(Object.entries(external.slots).map(([slot, inner]) => [slot, inner.map(child => forceComponentState(child, forced))])) : undefined;\n const bare = typeof external.componentName === 'string' ? external.componentName.substring(external.componentName.lastIndexOf(':') + 1) : undefined;\n const owns = bare !== undefined && external.componentName!.includes(defaultBlueprintName) && (bare in foundationSamples) && foundationSamples[bare].stateful && !withoutStates.has(bare);\n\n return {\n ...element,\n ...(owns ? { properties: { ...external.properties, ...forced } } : {}),\n ...(slots ? { slots } : {}),\n ...(children ? { children: children.map(child => forceComponentState(child, forced)) } : {}),\n } as SceneElement;\n}\n\n/**\n * A pack as the query results the templates bind to: one entry for each set, keyed by the set's shape name.\n *\n * The state is a property of the *data*, not of the template: Empty answers every query with no rows; Loading and Error withhold the answer, which is\n * what a query that has not come back or has failed looks like to a component, so each shows its own skeleton or error exactly as it will in an application.\n * The elements themselves are untouched, which is why the same template previews in every state with no per-template code.\n */\nexport const queryResultsOf = (pack: SampleDataPack | undefined, state: TemplatePreviewState = TemplatePreviewState.Populated): Record<string, unknown> | undefined => {\n if (pack === undefined) return undefined;\n if (state === TemplatePreviewState.Empty) return Object.fromEntries(pack.sets.map(set => [set.shape, []]));\n return Object.fromEntries(pack.sets.map(set => [set.shape, set.rows]));\n};\n\n/**\n * Boots one gallery screen through the real engine.\n *\n * Nothing here is a preview-only path: the screen is a real {@link Screen}, its element tree is resolved by\n * the real `resolveComponentName`, and it is rendered by the real `SceneElementView` against the real\n * registry. That is the point of shipping a gallery at all - a mockup proves that someone can draw a\n * dashboard, and this proves the blueprint renders one.\n *\n * Component names belonging to packages the host has not loaded resolve but find no implementation, and\n * come out as `UnresolvedComponent`'s dashed red box naming what is missing. That is the designed outcome:\n * a preview of a blueprint against half a profile should look visibly incomplete rather than quietly\n * wrong.\n */\nexport function GalleryScreenPreview({ screenName, initialConfig, themes = defaultBlueprintThemes, registry = galleryPreviewRegistry, state = TemplatePreviewState.Populated, pack, forceState }: GalleryScreenPreviewProps) {\n const element = useMemo(() => {\n const screen = galleryScreen(screenName);\n if (!screen) {\n throw new Error(`The gallery has no screen named '${screenName}'.`);\n }\n\n const resolved = applyTemplatePreviewState(resolveElementComponentNames(composeScreenElement(screen), galleryPreviewProfile, galleryComponentCatalog), state);\n return forceState ? forceComponentState(resolved, forceState) : resolved;\n }, [screenName, state, forceState]);\n\n return (\n <LayoutConfigProvider initialConfig={initialConfig} storage={null}>\n <LayoutThemeProvider themes={themes}>\n <SceneElementView element={element} registry={registry} resolveBinding={() => undefined} queryResults={queryResultsOf(pack, state)} />\n </LayoutThemeProvider>\n </LayoutConfigProvider>\n );\n}\n"],"names":["galleryPreviewRegistry","coreComponents","defaultBlueprintComponents","withoutStates","Set","ComponentName","EmptyState","TrendChip","StatusChip","BulkBar","GlobalSearch","NotificationsButton","forceComponentState","element","forced","external","children","slots","Object","fromEntries","entries","map","slot","inner","child","undefined","bare","componentName","substring","lastIndexOf","owns","includes","defaultBlueprintName","foundationSamples","stateful","has","properties","queryResultsOf","pack","state","TemplatePreviewState","Populated","Empty","sets","set","shape","rows","GalleryScreenPreview","screenName","initialConfig","themes","defaultBlueprintThemes","registry","forceState","useMemo","screen","galleryScreen","Error","resolved","applyTemplatePreviewState","resolveElementComponentNames","composeScreenElement","galleryPreviewProfile","galleryComponentCatalog","_jsx","LayoutConfigProvider","storage","LayoutThemeProvider","SceneElementView","resolveBinding","queryResults"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;;;;;UAOaA,sBAAAA,GAA4C;AAAE,IAAA,GAAGC,0BAAc;AAAE,IAAA,GAAGC;AAA2B;AAwC5G,mHACA,MAAMC,aAAAA,GAAgB,IAAIC,GAAAA,CAAY;AAClCC,IAAAA,2BAAAA,CAAcC,UAAU;AAAED,IAAAA,2BAAAA,CAAcE,SAAS;AAAEF,IAAAA,2BAAAA,CAAcG,UAAU;AAAEH,IAAAA,2BAAAA,CAAcI,OAAO;AAAEJ,IAAAA,2BAAAA,CAAcK,YAAY;AAAEL,IAAAA,2BAAAA,CAAcM;AACjJ,CAAA,CAAA;AAED,iHACO,SAASC,mBAAAA,CAAoBC,OAAqB,EAAEC,MAA4B,EAAA;AACnF,IAAA,MAAMC,QAAAA,GAAWF,OAAAA;IACjB,MAAMG,QAAAA,GAAW,OAACH,CAA0CG,QAAQ;AACpE,IAAA,MAAMC,QAAQF,QAAAA,CAASE,KAAK,GAAGC,MAAAA,CAAOC,WAAW,CAACD,MAAAA,CAAOE,OAAO,CAACL,QAAAA,CAASE,KAAK,EAAEI,GAAG,CAAC,CAAC,CAACC,IAAAA,EAAMC,MAAM,GAAK;AAACD,YAAAA,IAAAA;AAAMC,YAAAA,KAAAA,CAAMF,GAAG,CAACG,CAAAA,KAAAA,GAASZ,oBAAoBY,KAAAA,EAAOV,MAAAA,CAAAA;SAAS,CAAA,CAAA,GAAKW,SAAAA;AAC3K,IAAA,MAAMC,OAAO,OAAOX,QAAAA,CAASY,aAAa,KAAK,WAAWZ,QAAAA,CAASY,aAAa,CAACC,SAAS,CAACb,QAAAA,CAASY,aAAa,CAACE,WAAW,CAAC,OAAO,CAAA,CAAA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;;;;"}
|
|
1
|
+
{"version":3,"file":"GalleryScreenPreview.js","sources":["../../../gallery/GalleryScreenPreview.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useMemo } from 'react';\nimport { ExternalComponent, SampleDataPack, SceneElement, Theme } from '@cratis/scene.model';\nimport { ComponentRegistry, SceneElementView, coreComponents } from '@cratis/scene.react';\nimport { LayoutConfigProvider, LayoutConfigState } from '../configuration';\nimport { ComponentName } from '../ComponentName';\nimport { defaultBlueprintComponents } from '../defaultBlueprintComponents';\nimport { ComponentState, foundationSamples } from '../foundation';\nimport { defaultBlueprintName } from '../packageName';\nimport { LayoutThemeProvider, defaultBlueprintThemes } from '../themes';\nimport { composeScreenElement } from './composeScreen';\nimport { galleryComponentCatalog, galleryPreviewProfile } from './previewProfile';\nimport { resolveElementComponentNames } from './resolveElementNames';\nimport { galleryScreen } from './screens';\nimport { TemplatePreviewState } from './TemplatePreviewState';\nimport { applyTemplatePreviewState } from './applyTemplatePreviewState';\n\n/**\n * The registry a preview resolves against when a host does not supply one: `core` plus this blueprint.\n *\n * Merged by hand rather than through `mergePackageRegistries`, because reaching for this blueprint's\n * *bundle* here would be circular - the bundle is assembled from the gallery this file belongs to. Registry\n * keys carry their package name, so merge order cannot cause a collision either way.\n */\nexport const galleryPreviewRegistry: ComponentRegistry = { ...coreComponents, ...defaultBlueprintComponents };\n\nexport interface GalleryScreenPreviewProps {\n /** The name of the gallery screen to boot. */\n screenName: string;\n\n /** Configuration to start from - a story pinning a mode, or a host restoring a session. */\n initialConfig?: Partial<LayoutConfigState>;\n\n /** The themes the configurator may switch between. Defaults to the two this blueprint ships. */\n themes?: Theme[];\n\n /** The component registry to render against. Defaults to `core` plus this blueprint's own components. */\n registry?: ComponentRegistry;\n\n /** The data state to show. Defaults to the seeded, populated records. */\n state?: TemplatePreviewState;\n\n /**\n * The sample-data pack that stands in for the queries the templates bind to: each set's `shape` is a query name and its `rows` that query's result.\n * Templates carry no rows of their own - they declare where the data comes from (spec SD1) - so a preview of a foundation template needs one.\n */\n pack?: SampleDataPack;\n\n /**\n * A standard state (spec Part B 1.4) to force on every foundation component that owns the five states: loading, error, no-permission or partial.\n * This is how a designer inspects each one on a real template - it only sets the `state` property the components already read, so there is no\n * second code path. `error`, `permissionSubject` and `failedRegions` give the state its message.\n */\n forceState?: ForcedComponentState;\n}\n\n/** The standard states a preview can force on a template's components. */\nexport interface ForcedComponentState {\n state: ComponentState;\n error?: string;\n permissionSubject?: string;\n failedRegions?: string[];\n}\n\n/** Components that are chrome or controls rather than data-showing regions, and so do not own the five states. */\nconst withoutStates = new Set<string>([\n ComponentName.EmptyState, ComponentName.TrendChip, ComponentName.StatusChip, ComponentName.BulkBar, ComponentName.GlobalSearch, ComponentName.NotificationsButton,\n]);\n\n/** Sets the forced state on every region that owns the five states, leaving chrome and controls as they are. */\nexport function forceComponentState(element: SceneElement, forced: ForcedComponentState): SceneElement {\n const external = element as Partial<ExternalComponent>;\n const children = (element as { children?: SceneElement[] }).children;\n const slots = external.slots ? Object.fromEntries(Object.entries(external.slots).map(([slot, inner]) => [slot, inner.map(child => forceComponentState(child, forced))])) : undefined;\n const bare = typeof external.componentName === 'string' ? external.componentName.substring(external.componentName.lastIndexOf(':') + 1) : undefined;\n const owns = bare !== undefined && external.componentName!.includes(defaultBlueprintName) && (bare in foundationSamples) && foundationSamples[bare].stateful && !withoutStates.has(bare);\n\n return {\n ...element,\n ...(owns ? { properties: { ...external.properties, ...forced } } : {}),\n ...(slots ? { slots } : {}),\n ...(children ? { children: children.map(child => forceComponentState(child, forced)) } : {}),\n } as SceneElement;\n}\n\n/**\n * A pack as the query results the templates bind to: one entry for each set, keyed by the set's shape name.\n *\n * The state is a property of the *data*, not of the template: Empty answers every query with no rows; Loading and Error withhold the answer, which is\n * what a query that has not come back or has failed looks like to a component, so each shows its own skeleton or error exactly as it will in an application.\n * The elements themselves are untouched, which is why the same template previews in every state with no per-template code.\n */\nexport const queryResultsOf = (pack: SampleDataPack | undefined, state: TemplatePreviewState = TemplatePreviewState.Populated): Record<string, unknown> | undefined => {\n if (pack === undefined) return undefined;\n if (state === TemplatePreviewState.Empty) return Object.fromEntries(pack.sets.map(set => [set.shape, []]));\n return Object.fromEntries(pack.sets.map(set => [set.shape, set.rows]));\n};\n\n/**\n * Boots one gallery screen through the real engine.\n *\n * Nothing here is a preview-only path: the screen is a real {@link Screen}, its element tree is resolved by\n * the real `resolveComponentName`, and it is rendered by the real `SceneElementView` against the real\n * registry. That is the point of shipping a gallery at all - a mockup proves that someone can draw a\n * dashboard, and this proves the blueprint renders one.\n *\n * Component names belonging to packages the host has not loaded resolve but find no implementation, and\n * come out as `UnresolvedComponent`'s dashed red box naming what is missing. That is the designed outcome:\n * a preview of a blueprint against half a profile should look visibly incomplete rather than quietly\n * wrong.\n */\nexport function GalleryScreenPreview({ screenName, initialConfig, themes = defaultBlueprintThemes, registry = galleryPreviewRegistry, state = TemplatePreviewState.Populated, pack, forceState }: GalleryScreenPreviewProps) {\n const element = useMemo(() => {\n const screen = galleryScreen(screenName);\n if (!screen) {\n throw new Error(`The gallery has no screen named '${screenName}'.`);\n }\n\n const resolved = applyTemplatePreviewState(resolveElementComponentNames(composeScreenElement(screen), galleryPreviewProfile, galleryComponentCatalog), state);\n return forceState ? forceComponentState(resolved, forceState) : resolved;\n }, [screenName, state, forceState]);\n\n return (\n <LayoutConfigProvider initialConfig={initialConfig} storage={null}>\n <LayoutThemeProvider themes={themes}>\n <SceneElementView element={element} registry={registry} resolveBinding={() => undefined} queryResults={queryResultsOf(pack, state)} />\n </LayoutThemeProvider>\n </LayoutConfigProvider>\n );\n}\n"],"names":["galleryPreviewRegistry","coreComponents","defaultBlueprintComponents","withoutStates","Set","ComponentName","EmptyState","TrendChip","StatusChip","BulkBar","GlobalSearch","NotificationsButton","forceComponentState","element","forced","external","children","slots","Object","fromEntries","entries","map","slot","inner","child","undefined","bare","componentName","substring","lastIndexOf","owns","includes","defaultBlueprintName","foundationSamples","stateful","has","properties","queryResultsOf","pack","state","TemplatePreviewState","Populated","Empty","sets","set","shape","rows","GalleryScreenPreview","screenName","initialConfig","themes","defaultBlueprintThemes","registry","forceState","useMemo","screen","galleryScreen","Error","resolved","applyTemplatePreviewState","resolveElementComponentNames","composeScreenElement","galleryPreviewProfile","galleryComponentCatalog","_jsx","LayoutConfigProvider","storage","LayoutThemeProvider","SceneElementView","resolveBinding","queryResults"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;;;;;UAOaA,sBAAAA,GAA4C;AAAE,IAAA,GAAGC,0BAAc;AAAE,IAAA,GAAGC;AAA2B;AAwC5G,mHACA,MAAMC,aAAAA,GAAgB,IAAIC,GAAAA,CAAY;AAClCC,IAAAA,2BAAAA,CAAcC,UAAU;AAAED,IAAAA,2BAAAA,CAAcE,SAAS;AAAEF,IAAAA,2BAAAA,CAAcG,UAAU;AAAEH,IAAAA,2BAAAA,CAAcI,OAAO;AAAEJ,IAAAA,2BAAAA,CAAcK,YAAY;AAAEL,IAAAA,2BAAAA,CAAcM;AACjJ,CAAA,CAAA;AAED,iHACO,SAASC,mBAAAA,CAAoBC,OAAqB,EAAEC,MAA4B,EAAA;AACnF,IAAA,MAAMC,QAAAA,GAAWF,OAAAA;IACjB,MAAMG,QAAAA,GAAW,OAACH,CAA0CG,QAAQ;AACpE,IAAA,MAAMC,QAAQF,QAAAA,CAASE,KAAK,GAAGC,MAAAA,CAAOC,WAAW,CAACD,MAAAA,CAAOE,OAAO,CAACL,QAAAA,CAASE,KAAK,EAAEI,GAAG,CAAC,CAAC,CAACC,IAAAA,EAAMC,MAAM,GAAK;AAACD,YAAAA,IAAAA;AAAMC,YAAAA,KAAAA,CAAMF,GAAG,CAACG,CAAAA,KAAAA,GAASZ,oBAAoBY,KAAAA,EAAOV,MAAAA,CAAAA;SAAS,CAAA,CAAA,GAAKW,SAAAA;AAC3K,IAAA,MAAMC,OAAO,OAAO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,QAAAA;AAAUiB,gBAAAA,cAAAA,EAAgB,IAAM5C,SAAAA;AAAW6C,gBAAAA,YAAAA,EAAcjC,eAAeC,IAAAA,EAAMC,KAAAA;;;;AAI5I;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var dialogTemplates = require('../foundation/templates/dialogTemplates.js');
|
|
3
4
|
var TemplateSlotName = require('./TemplateSlotName.js');
|
|
4
5
|
var elements = require('./elements.js');
|
|
5
6
|
var widgets = require('./widgets.js');
|
|
6
|
-
var templateProvenance = require('../templateProvenance.js');
|
|
7
7
|
|
|
8
8
|
// Copyright (c) Cratis. All rights reserved.
|
|
9
9
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -15,7 +15,12 @@ var templateProvenance = require('../templateProvenance.js');
|
|
|
15
15
|
* *placed* - it fills a slot on whatever contains it, and the containment chain is what decides where it
|
|
16
16
|
* appears. A dialog is *summoned*: it opens over the application from wherever the code that opened it
|
|
17
17
|
* happens to be, so there is no parent slot for it to name.
|
|
18
|
-
*/ /**
|
|
18
|
+
*/ /**
|
|
19
|
+
* Confirm: one question, two answers, and enough context to answer it - the consequences listed, and the confirming button naming what it does
|
|
20
|
+
* (`Archive product`, never `OK`). A destructive confirmation takes the danger tone: the heading and border are drawn in the danger colors and the
|
|
21
|
+
* confirming button is the danger button. The components blueprint has a `ConfirmDialog` of its own for a command; a reference names the blueprint
|
|
22
|
+
* (`resolveTemplateReference`), so the two never collide.
|
|
23
|
+
*/ const confirmDialogTemplate = {
|
|
19
24
|
name: 'ConfirmDialog',
|
|
20
25
|
slots: [
|
|
21
26
|
{
|
|
@@ -30,32 +35,33 @@ var templateProvenance = require('../templateProvenance.js');
|
|
|
30
35
|
],
|
|
31
36
|
content: {
|
|
32
37
|
[TemplateSlotName.TemplateSlotName.Header]: [
|
|
33
|
-
elements.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
elements.externalComponent('confirm-frame', 'dialogFrame', {
|
|
39
|
+
title: 'Archive this product?',
|
|
40
|
+
message: 'Bamboo Watch will stop appearing in the catalog.',
|
|
41
|
+
tone: 'danger',
|
|
42
|
+
consequences: [
|
|
43
|
+
'Existing orders keep it',
|
|
44
|
+
'It can be restored from the archive'
|
|
45
|
+
]
|
|
40
46
|
})
|
|
41
47
|
],
|
|
48
|
+
[TemplateSlotName.TemplateSlotName.Body]: [],
|
|
42
49
|
[TemplateSlotName.TemplateSlotName.Actions]: [
|
|
43
50
|
elements.panel('confirm-actions', [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
dialogTemplates.closingDialog(dialogTemplates.actionButton('confirm-no', {
|
|
52
|
+
label: 'Keep it',
|
|
53
|
+
emphasis: 'secondary'
|
|
54
|
+
})),
|
|
55
|
+
dialogTemplates.actionButton('confirm-yes', {
|
|
56
|
+
label: 'Archive product',
|
|
57
|
+
emphasis: 'danger'
|
|
49
58
|
})
|
|
50
59
|
])
|
|
51
60
|
]
|
|
52
61
|
},
|
|
53
62
|
displayName: 'Confirmation dialog',
|
|
54
63
|
description: 'One question with the consequence spelled out, and a way back.',
|
|
55
|
-
metadata:
|
|
56
|
-
...templateProvenance.defaultBlueprintTemplateProvenance,
|
|
57
|
-
category: 'Foundation / Dialog'
|
|
58
|
-
}
|
|
64
|
+
metadata: dialogTemplates.dialogMetadata('ConfirmDialog')
|
|
59
65
|
};
|
|
60
66
|
/** Form: a short capture that does not deserve a page of its own. */ const formDialogTemplate = {
|
|
61
67
|
name: 'FormDialog',
|
|
@@ -72,7 +78,9 @@ var templateProvenance = require('../templateProvenance.js');
|
|
|
72
78
|
],
|
|
73
79
|
content: {
|
|
74
80
|
[TemplateSlotName.TemplateSlotName.Header]: [
|
|
75
|
-
elements.
|
|
81
|
+
elements.externalComponent('form-dialog-frame', 'dialogFrame', {
|
|
82
|
+
title: 'Invite someone'
|
|
83
|
+
})
|
|
76
84
|
],
|
|
77
85
|
[TemplateSlotName.TemplateSlotName.Body]: [
|
|
78
86
|
widgets.field('form-dialog-email', 'Email', 'inputText', {
|
|
@@ -91,21 +99,18 @@ var templateProvenance = require('../templateProvenance.js');
|
|
|
91
99
|
],
|
|
92
100
|
[TemplateSlotName.TemplateSlotName.Actions]: [
|
|
93
101
|
elements.panel('form-dialog-actions', [
|
|
102
|
+
dialogTemplates.closingDialog(elements.button('form-dialog-cancel', 'Cancel', {
|
|
103
|
+
severity: 'secondary'
|
|
104
|
+
})),
|
|
94
105
|
elements.button('form-dialog-send', 'Send invitation', {
|
|
95
106
|
severity: 'primary'
|
|
96
|
-
}),
|
|
97
|
-
elements.button('form-dialog-cancel', 'Cancel', {
|
|
98
|
-
severity: 'secondary'
|
|
99
107
|
})
|
|
100
108
|
])
|
|
101
109
|
]
|
|
102
110
|
},
|
|
103
111
|
displayName: 'Form dialog',
|
|
104
112
|
description: 'A handful of fields captured without leaving the page underneath.',
|
|
105
|
-
metadata:
|
|
106
|
-
...templateProvenance.defaultBlueprintTemplateProvenance,
|
|
107
|
-
category: 'Foundation / Dialog'
|
|
108
|
-
}
|
|
113
|
+
metadata: dialogTemplates.dialogMetadata('FormDialog', true)
|
|
109
114
|
};
|
|
110
115
|
/** Detail: a record shown over the list it came from. */ const detailDialogTemplate = {
|
|
111
116
|
name: 'DetailDialog',
|
|
@@ -125,7 +130,9 @@ var templateProvenance = require('../templateProvenance.js');
|
|
|
125
130
|
],
|
|
126
131
|
content: {
|
|
127
132
|
[TemplateSlotName.TemplateSlotName.Header]: [
|
|
128
|
-
elements.
|
|
133
|
+
elements.externalComponent('detail-dialog-frame', 'dialogFrame', {
|
|
134
|
+
title: 'ORD-4192'
|
|
135
|
+
})
|
|
129
136
|
],
|
|
130
137
|
[TemplateSlotName.TemplateSlotName.Body]: [
|
|
131
138
|
elements.card('detail-dialog-summary', [
|
|
@@ -144,27 +151,25 @@ var templateProvenance = require('../templateProvenance.js');
|
|
|
144
151
|
],
|
|
145
152
|
[TemplateSlotName.TemplateSlotName.Actions]: [
|
|
146
153
|
elements.panel('detail-dialog-actions', [
|
|
154
|
+
dialogTemplates.closingDialog(elements.button('detail-dialog-close', 'Close', {
|
|
155
|
+
severity: 'secondary'
|
|
156
|
+
})),
|
|
147
157
|
elements.button('detail-dialog-open', 'Open full record', {
|
|
148
158
|
severity: 'primary',
|
|
149
159
|
targetScreen: 'DetailView'
|
|
150
|
-
}),
|
|
151
|
-
elements.button('detail-dialog-close', 'Close', {
|
|
152
|
-
severity: 'secondary'
|
|
153
160
|
})
|
|
154
161
|
])
|
|
155
162
|
]
|
|
156
163
|
},
|
|
157
164
|
displayName: 'Detail dialog',
|
|
158
165
|
description: 'A record over the list it came from, with a route to the full page.',
|
|
159
|
-
metadata:
|
|
160
|
-
...templateProvenance.defaultBlueprintTemplateProvenance,
|
|
161
|
-
category: 'Foundation / Dialog'
|
|
162
|
-
}
|
|
166
|
+
metadata: dialogTemplates.dialogMetadata('DetailDialog', true)
|
|
163
167
|
};
|
|
164
|
-
/** The dialog templates this blueprint provides. */ const galleryDialogTemplates = [
|
|
168
|
+
/** The dialog templates this blueprint provides: the three the gallery began with, and the foundation's quick create, lookup, side sheet and filter dialogs. */ const galleryDialogTemplates = [
|
|
165
169
|
confirmDialogTemplate,
|
|
166
170
|
formDialogTemplate,
|
|
167
|
-
detailDialogTemplate
|
|
171
|
+
detailDialogTemplate,
|
|
172
|
+
...dialogTemplates.foundationDialogTemplates
|
|
168
173
|
];
|
|
169
174
|
|
|
170
175
|
exports.confirmDialogTemplate = confirmDialogTemplate;
|