@dosgato/templating 0.0.82 → 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.
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {