@dosgato/templating 0.0.62 → 0.0.64
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 -7
- package/dist/component.js +16 -6
- package/dist/uitemplate.d.ts +11 -1
- package/package.json +1 -2
package/dist/component.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
116
116
|
*/
|
|
117
117
|
renderComponents(components?: RenderedComponent[] | string, opts?: {
|
|
118
118
|
hideInheritBars?: boolean;
|
|
119
|
-
editBarOpts?:
|
|
119
|
+
editBarOpts?: RenderAreaEditBarOpts;
|
|
120
120
|
}): string;
|
|
121
121
|
/**
|
|
122
122
|
* helper function to print an area and set a minimum or maximum number of components
|
|
@@ -128,8 +128,8 @@ export declare abstract class Component<DataType extends ComponentData = any, Fe
|
|
|
128
128
|
maxWarning?: string;
|
|
129
129
|
hideInheritBars?: boolean;
|
|
130
130
|
newBarOpts: NewBarOpts;
|
|
131
|
-
editBarOpts:
|
|
132
|
-
}):
|
|
131
|
+
editBarOpts: RenderAreaEditBarOpts;
|
|
132
|
+
}): string;
|
|
133
133
|
/**
|
|
134
134
|
* During rendering, each component should determine the CSS blocks that it needs. This may
|
|
135
135
|
* change depending on the data. For instance, if you need some CSS to style up an image, but
|
|
@@ -256,16 +256,18 @@ export interface ContextBase {
|
|
|
256
256
|
}
|
|
257
257
|
interface BarOpts {
|
|
258
258
|
editMode?: boolean;
|
|
259
|
+
label?: string;
|
|
260
|
+
extraClass?: string;
|
|
259
261
|
}
|
|
260
262
|
export interface EditBarOpts extends BarOpts {
|
|
261
|
-
label?: string | ((c: Component) => string);
|
|
262
|
-
extraClass?: string | ((c: Component) => string);
|
|
263
263
|
inheritedFrom?: string;
|
|
264
264
|
disableDelete?: boolean;
|
|
265
265
|
}
|
|
266
|
+
export interface RenderAreaEditBarOpts extends Omit<Omit<EditBarOpts, 'label'>, 'extraClass'> {
|
|
267
|
+
label?: string | ((c: Component) => string);
|
|
268
|
+
extraClass?: string | ((c: Component) => string);
|
|
269
|
+
}
|
|
266
270
|
export interface NewBarOpts extends BarOpts {
|
|
267
|
-
label?: string;
|
|
268
|
-
extraClass?: string;
|
|
269
271
|
disabled?: boolean;
|
|
270
272
|
}
|
|
271
273
|
export interface RenderedComponent<C extends Component = Component> {
|
package/dist/component.js
CHANGED
|
@@ -89,7 +89,15 @@ export class Component extends ResourceProvider {
|
|
|
89
89
|
renderComponents(components = [], opts) {
|
|
90
90
|
if (!Array.isArray(components))
|
|
91
91
|
components = this.renderedAreas.get(components) ?? [];
|
|
92
|
-
return components
|
|
92
|
+
return components
|
|
93
|
+
.flatMap(c => c.component.inheritedFrom &&
|
|
94
|
+
opts?.hideInheritBars
|
|
95
|
+
? [c.output]
|
|
96
|
+
: [c.component.editBar({
|
|
97
|
+
...opts?.editBarOpts,
|
|
98
|
+
label: typeof opts?.editBarOpts?.label === 'function' ? opts.editBarOpts.label(c.component) : opts?.editBarOpts?.label,
|
|
99
|
+
extraClass: typeof opts?.editBarOpts?.extraClass === 'function' ? opts.editBarOpts.extraClass(c.component) : opts?.editBarOpts?.extraClass
|
|
100
|
+
}), c.output]).join('');
|
|
93
101
|
}
|
|
94
102
|
/**
|
|
95
103
|
* helper function to print an area and set a minimum or maximum number of components
|
|
@@ -105,6 +113,7 @@ export class Component extends ResourceProvider {
|
|
|
105
113
|
else {
|
|
106
114
|
output += this.newBar(areaName, opts?.newBarOpts);
|
|
107
115
|
}
|
|
116
|
+
return output;
|
|
108
117
|
}
|
|
109
118
|
/**
|
|
110
119
|
* During rendering, each component should determine the CSS blocks that it needs. This may
|
|
@@ -157,11 +166,12 @@ export class Component extends ResourceProvider {
|
|
|
157
166
|
* Generally should not be overridden - override editLabel and editClass instead
|
|
158
167
|
*/
|
|
159
168
|
editBar(opts = {}) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
const options = { ...opts };
|
|
170
|
+
options.label ?? (options.label = this.editLabel() ?? this.autoLabel);
|
|
171
|
+
options.extraClass ?? (options.extraClass = this.editClass());
|
|
172
|
+
options.editMode ?? (options.editMode = this.editMode);
|
|
173
|
+
options.inheritedFrom ?? (options.inheritedFrom = this.inheritedFrom);
|
|
174
|
+
return Component.editBar(this.path, options);
|
|
165
175
|
}
|
|
166
176
|
/**
|
|
167
177
|
* Components may override this function to provide a custom new bar
|
package/dist/uitemplate.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import type { IconifyIcon } from '@iconify/svelte';
|
|
2
1
|
export interface SvelteComponent {
|
|
3
2
|
$set: (props?: Record<string, any>) => void;
|
|
4
3
|
$on: (event: string, callback: (event: any) => void) => () => void;
|
|
5
4
|
$destroy: () => void;
|
|
6
5
|
[accessor: string]: any;
|
|
7
6
|
}
|
|
7
|
+
interface IconifyIcon {
|
|
8
|
+
body: string;
|
|
9
|
+
rotate?: number;
|
|
10
|
+
hFlip?: boolean;
|
|
11
|
+
vFlip?: boolean;
|
|
12
|
+
left?: number;
|
|
13
|
+
top?: number;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
}
|
|
8
17
|
export interface IconOrSVG extends IconifyIcon {
|
|
9
18
|
raw?: true;
|
|
10
19
|
}
|
|
@@ -14,3 +23,4 @@ export interface UITemplate {
|
|
|
14
23
|
preview?: IconOrSVG;
|
|
15
24
|
icon?: IconOrSVG;
|
|
16
25
|
}
|
|
26
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dosgato/templating",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.64",
|
|
4
4
|
"description": "A library to support building templates for dosgato CMS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"build": "rm -rf dist && tsc"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@iconify/svelte": "^3.0.0",
|
|
18
17
|
"txstate-utils": "^1.7.4"
|
|
19
18
|
},
|
|
20
19
|
"devDependencies": {
|