@dosgato/templating 0.0.82 → 0.0.84
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 +7 -0
- package/dist/component.js +5 -5
- package/dist/render.js +1 -1
- package/dist/uitemplate.d.ts +17 -1
- package/dist/uitemplate.js +7 -1
- 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
|
|
@@ -360,6 +361,12 @@ export interface RenderComponentsWrapParams {
|
|
|
360
361
|
* wrapping or you'll end up with an empty wrapper element.
|
|
361
362
|
*/
|
|
362
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;
|
|
363
370
|
/**
|
|
364
371
|
* Contains the full component being wrapped.
|
|
365
372
|
*
|
package/dist/component.js
CHANGED
|
@@ -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/render.js
CHANGED
|
@@ -6,7 +6,7 @@ export function printHeader(ctx, content) {
|
|
|
6
6
|
if (level < 1)
|
|
7
7
|
return `<h1>${content}</h1>`;
|
|
8
8
|
if (level > 6)
|
|
9
|
-
return `<h6>${content}</
|
|
9
|
+
return `<h6>${content}</h6>`;
|
|
10
10
|
return `<h${level}>${content}</h${level}>`;
|
|
11
11
|
}
|
|
12
12
|
export function advanceHeader(ctx, content) {
|
package/dist/uitemplate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentData } from './component.js';
|
|
1
|
+
import { ComponentData, PageData } from './component.js';
|
|
2
2
|
interface IconifyIcon {
|
|
3
3
|
body: string;
|
|
4
4
|
rotate?: number;
|
|
@@ -26,6 +26,8 @@ export interface UITemplate {
|
|
|
26
26
|
* - creating: boolean, true when creating component for the first time, false when editing
|
|
27
27
|
* - data: ComponentData, the current data on the page, should not be mutated during editing,
|
|
28
28
|
* undefined when creating
|
|
29
|
+
* - page: DialogPageProp, the current page so that you can reference the full page data or
|
|
30
|
+
* make a further graphql query based on its id/path.
|
|
29
31
|
* - templateProperties: the template properties for the current page template, so you can make
|
|
30
32
|
* things like color pickers that visually match the colors of the current page template
|
|
31
33
|
* - environmentConfig: base URLs in case you need to generate a link to the API or something
|
|
@@ -60,4 +62,18 @@ export interface UITemplate {
|
|
|
60
62
|
*/
|
|
61
63
|
icon?: IconOrSVG;
|
|
62
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* This is a type for the data that will be passed to dialog Svelte components as
|
|
67
|
+
* the `page` prop.
|
|
68
|
+
*/
|
|
69
|
+
export interface DialogPageProp {
|
|
70
|
+
id: string;
|
|
71
|
+
path: string;
|
|
72
|
+
data: PageData;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A function you may use in your dialogs to make an authenticated graphql request to the DosGato
|
|
76
|
+
* API.
|
|
77
|
+
*/
|
|
78
|
+
export declare function dialogQuery<T = any>(query: string, variables: any): Promise<T>;
|
|
63
79
|
export {};
|
package/dist/uitemplate.js
CHANGED