@dosgato/templating 0.0.81 → 0.0.83
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/dist/component.d.ts +9 -0
- package/dist/component.js +6 -6
- package/dist/uitemplate.d.ts +7 -0
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -251,6 +251,7 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
251
251
|
autoLabel: string;
|
|
252
252
|
reqHeaders: IncomingHttpHeaders;
|
|
253
253
|
reqQuery: ParsedUrlQuery;
|
|
254
|
+
indexInArea: number;
|
|
254
255
|
/**
|
|
255
256
|
* For logging errors during rendering without crashing the render. If your fetch, setContext,
|
|
256
257
|
* render, or renderVariation functions throw, the error will be logged but the page render will
|
|
@@ -284,6 +285,7 @@ export interface PageRecordOptionalData<DataType extends PageData = PageData> ex
|
|
|
284
285
|
export interface ComponentData {
|
|
285
286
|
templateKey: string;
|
|
286
287
|
areas?: Record<string, ComponentData[]>;
|
|
288
|
+
[keys: string]: any;
|
|
287
289
|
}
|
|
288
290
|
export interface PageData extends ComponentData {
|
|
289
291
|
savedAtVersion: string;
|
|
@@ -291,6 +293,7 @@ export interface PageData extends ComponentData {
|
|
|
291
293
|
export interface DataData {
|
|
292
294
|
templateKey: string;
|
|
293
295
|
savedAtVersion: string;
|
|
296
|
+
[keys: string]: any;
|
|
294
297
|
}
|
|
295
298
|
export interface ContextBase {
|
|
296
299
|
/**
|
|
@@ -358,6 +361,12 @@ export interface RenderComponentsWrapParams {
|
|
|
358
361
|
* wrapping or you'll end up with an empty wrapper element.
|
|
359
362
|
*/
|
|
360
363
|
bar: string;
|
|
364
|
+
/**
|
|
365
|
+
* The index of the component currently being wrapped
|
|
366
|
+
*
|
|
367
|
+
* After pulling in any inherited components.
|
|
368
|
+
*/
|
|
369
|
+
indexInArea: number;
|
|
361
370
|
/**
|
|
362
371
|
* Contains the full component being wrapped.
|
|
363
372
|
*
|
package/dist/component.js
CHANGED
|
@@ -69,7 +69,7 @@ export class Component extends ResourceProvider {
|
|
|
69
69
|
* to reduce the number of components that get inherited.
|
|
70
70
|
*/
|
|
71
71
|
inheritArea(page, areaName, opts) {
|
|
72
|
-
const components = get(page.data, areaName).filter(opts?.filter ?? (() => true));
|
|
72
|
+
const components = get(page.data, `areas.${areaName}`).filter(opts?.filter ?? (() => true));
|
|
73
73
|
this.registerInherited(areaName, components, page.id, opts?.mode);
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
@@ -114,11 +114,11 @@ export class Component extends ResourceProvider {
|
|
|
114
114
|
components = this.renderedAreas.get(components) ?? [];
|
|
115
115
|
const wrap = opts?.wrap ?? defaultWrap;
|
|
116
116
|
if (opts?.skipBars || opts?.skipEditBars)
|
|
117
|
-
return components.map(c => wrap({ ...c, content: c.output, bar: '' })).join('');
|
|
117
|
+
return components.map((c, indexInArea) => wrap({ ...c, content: c.output, bar: '', indexInArea })).join('');
|
|
118
118
|
return components
|
|
119
|
-
.map(c => {
|
|
119
|
+
.map((c, indexInArea) => {
|
|
120
120
|
if (c.component.inheritedFrom && opts?.hideInheritBars) {
|
|
121
|
-
return opts.skipContent ? '' : wrap({ ...c, content: c.output, bar: '' });
|
|
121
|
+
return opts.skipContent ? '' : wrap({ ...c, content: c.output, bar: '', indexInArea });
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
124
|
const bar = c.component.editBar({
|
|
@@ -126,7 +126,7 @@ export class Component extends ResourceProvider {
|
|
|
126
126
|
label: typeof opts?.editBarOpts?.label === 'function' ? opts.editBarOpts.label(c.component) : opts?.editBarOpts?.label,
|
|
127
127
|
extraClass: typeof opts?.editBarOpts?.extraClass === 'function' ? opts.editBarOpts.extraClass(c.component) : opts?.editBarOpts?.extraClass
|
|
128
128
|
});
|
|
129
|
-
return wrap({ output: bar + c.output, content: c.output, bar, component: c.component });
|
|
129
|
+
return wrap({ output: bar + c.output, content: c.output, bar, component: c.component, indexInArea });
|
|
130
130
|
}
|
|
131
131
|
}).join('');
|
|
132
132
|
}
|
|
@@ -158,7 +158,7 @@ export class Component extends ResourceProvider {
|
|
|
158
158
|
bar = this.newBar(areaName, opts?.newBarOpts);
|
|
159
159
|
}
|
|
160
160
|
if (bar != null)
|
|
161
|
-
output += wrap({ output: bar, content: '', bar });
|
|
161
|
+
output += wrap({ output: bar, content: '', bar, indexInArea: components.length });
|
|
162
162
|
}
|
|
163
163
|
return output;
|
|
164
164
|
}
|
package/dist/uitemplate.d.ts
CHANGED
|
@@ -37,6 +37,13 @@ export interface UITemplate {
|
|
|
37
37
|
*
|
|
38
38
|
* You can place that introductory content here and it will be automatically placed into
|
|
39
39
|
* components with this template upon creation (and never again).
|
|
40
|
+
*
|
|
41
|
+
* Whatever you put here will be added beneath the component's `areas` property, so it would
|
|
42
|
+
* be structured like:
|
|
43
|
+
* {
|
|
44
|
+
* someArea: [componentData1, componentData2],
|
|
45
|
+
* anotherArea: [componentData3]
|
|
46
|
+
* }
|
|
40
47
|
*/
|
|
41
48
|
defaultContent?: Record<string, ComponentData[]>;
|
|
42
49
|
/**
|