@dosgato/templating 0.0.68 → 0.0.70
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 +13 -1
- package/dist/component.js +22 -11
- package/dist/uitemplate.d.ts +1 -7
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -116,10 +116,20 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
116
116
|
*/
|
|
117
117
|
renderComponents(components?: RenderedComponent[] | string, opts?: {
|
|
118
118
|
hideInheritBars?: boolean;
|
|
119
|
+
skipBars?: boolean;
|
|
120
|
+
skipContent?: boolean;
|
|
119
121
|
editBarOpts?: RenderAreaEditBarOpts;
|
|
120
122
|
}): string;
|
|
121
123
|
/**
|
|
122
124
|
* helper function to print an area and set a minimum or maximum number of components
|
|
125
|
+
*
|
|
126
|
+
* In some cases you might be rendering the edit bars in a separate div instead of placing
|
|
127
|
+
* them above each component. For instance, a slider that only shows one slide at a time may
|
|
128
|
+
* prefer not to put bars with slides because that would mean only one bar is visible at a time
|
|
129
|
+
* and then there's no way to re-order slides.
|
|
130
|
+
*
|
|
131
|
+
* In that case you would call this.renderArea('areaname', { ..., skipEditBars: true }) first
|
|
132
|
+
* and then this.renderArea('areaname', { ..., skipContent: true }) in another place.
|
|
123
133
|
*/
|
|
124
134
|
renderArea(areaName: string, opts?: {
|
|
125
135
|
min?: number;
|
|
@@ -127,6 +137,8 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
127
137
|
hideMaxWarning?: boolean;
|
|
128
138
|
maxWarning?: string;
|
|
129
139
|
hideInheritBars?: boolean;
|
|
140
|
+
skipBars?: boolean;
|
|
141
|
+
skipContent?: boolean;
|
|
130
142
|
newBarOpts?: NewBarOpts;
|
|
131
143
|
editBarOpts?: RenderAreaEditBarOpts;
|
|
132
144
|
}): string;
|
|
@@ -230,7 +242,7 @@ export interface PageRecord<DataType extends PageData = PageData> {
|
|
|
230
242
|
linkId: string;
|
|
231
243
|
createdAt: Date;
|
|
232
244
|
modifiedAt: Date;
|
|
233
|
-
publishedAt
|
|
245
|
+
publishedAt?: Date;
|
|
234
246
|
path: string;
|
|
235
247
|
data: DataType;
|
|
236
248
|
site: SiteInfo;
|
package/dist/component.js
CHANGED
|
@@ -95,30 +95,41 @@ export class Component extends ResourceProvider {
|
|
|
95
95
|
renderComponents(components = [], opts) {
|
|
96
96
|
if (!Array.isArray(components))
|
|
97
97
|
components = this.renderedAreas.get(components) ?? [];
|
|
98
|
+
if (opts?.skipBars)
|
|
99
|
+
return components.map(c => c.output).join('');
|
|
98
100
|
return components
|
|
99
|
-
.flatMap(c => c.component.inheritedFrom &&
|
|
100
|
-
opts
|
|
101
|
-
? [c.output]
|
|
101
|
+
.flatMap(c => c.component.inheritedFrom && opts?.hideInheritBars
|
|
102
|
+
? [opts.skipContent ? '' : c.output]
|
|
102
103
|
: [c.component.editBar({
|
|
103
104
|
...opts?.editBarOpts,
|
|
104
105
|
label: typeof opts?.editBarOpts?.label === 'function' ? opts.editBarOpts.label(c.component) : opts?.editBarOpts?.label,
|
|
105
106
|
extraClass: typeof opts?.editBarOpts?.extraClass === 'function' ? opts.editBarOpts.extraClass(c.component) : opts?.editBarOpts?.extraClass
|
|
106
|
-
}), c.output]).join('');
|
|
107
|
+
}), opts?.skipContent ? '' : c.output]).join('');
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
109
110
|
* helper function to print an area and set a minimum or maximum number of components
|
|
111
|
+
*
|
|
112
|
+
* In some cases you might be rendering the edit bars in a separate div instead of placing
|
|
113
|
+
* them above each component. For instance, a slider that only shows one slide at a time may
|
|
114
|
+
* prefer not to put bars with slides because that would mean only one bar is visible at a time
|
|
115
|
+
* and then there's no way to re-order slides.
|
|
116
|
+
*
|
|
117
|
+
* In that case you would call this.renderArea('areaname', { ..., skipEditBars: true }) first
|
|
118
|
+
* and then this.renderArea('areaname', { ..., skipContent: true }) in another place.
|
|
110
119
|
*/
|
|
111
120
|
renderArea(areaName, opts) {
|
|
112
121
|
const components = this.renderedAreas.get(areaName) ?? [];
|
|
113
122
|
const ownedComponentCount = components.filter(c => !c.component.inheritedFrom).length;
|
|
114
123
|
const full = !!(opts?.max && ownedComponentCount >= opts.max);
|
|
115
|
-
let output = this.renderComponents(components, { hideInheritBars: opts?.hideInheritBars, editBarOpts: { ...opts?.editBarOpts, disableDelete: ownedComponentCount <= (opts?.min ?? 0), disableDrop: full } });
|
|
116
|
-
if (
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
let output = this.renderComponents(components, { hideInheritBars: opts?.hideInheritBars, skipBars: opts?.skipBars, skipContent: opts?.skipContent, editBarOpts: { ...opts?.editBarOpts, disableDelete: ownedComponentCount <= (opts?.min ?? 0), disableDrop: full } });
|
|
125
|
+
if (!opts?.skipBars) {
|
|
126
|
+
if (full) {
|
|
127
|
+
if (!opts.hideMaxWarning)
|
|
128
|
+
output += this.newBar(areaName, { ...opts.newBarOpts, label: opts.maxWarning ?? 'Maximum Reached', disabled: true });
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
output += this.newBar(areaName, opts?.newBarOpts);
|
|
132
|
+
}
|
|
122
133
|
}
|
|
123
134
|
return output;
|
|
124
135
|
}
|
package/dist/uitemplate.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { ComponentData } from './component.js';
|
|
2
|
-
export interface SvelteComponent {
|
|
3
|
-
$set: (props?: Record<string, any>) => void;
|
|
4
|
-
$on: (event: string, callback: (event: any) => void) => () => void;
|
|
5
|
-
$destroy: () => void;
|
|
6
|
-
[accessor: string]: any;
|
|
7
|
-
}
|
|
8
2
|
interface IconifyIcon {
|
|
9
3
|
body: string;
|
|
10
4
|
rotate?: number;
|
|
@@ -36,7 +30,7 @@ export interface UITemplate {
|
|
|
36
30
|
* things like color pickers that visually match the colors of the current page template
|
|
37
31
|
* - environmentConfig: base URLs in case you need to generate a link to the API or something
|
|
38
32
|
*/
|
|
39
|
-
dialog?: new (...args: any[]) =>
|
|
33
|
+
dialog?: new (...args: any[]) => any;
|
|
40
34
|
/**
|
|
41
35
|
* Sometimes when you create a component that has areas, you want to automatically fill
|
|
42
36
|
* one or more areas with some default introductory content.
|