@bino-bi/bn-template-engine 1.0.0-next.32 → 1.0.0-next.33
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/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/p-b4efbcb5.entry.js +1 -0
- package/dist/bn-template-engine/{p-225cd474.entry.js → p-fcc42077.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +1 -1
- package/dist/cjs/bn-grid.cjs.entry.js +51 -14
- package/dist/collection/components/bn-grid/bn-grid.js +51 -14
- package/dist/collection/components/bn-layout-card/bn-layout-card.css +8 -0
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/esm/bn-annotation-layer_30.entry.js +1 -1
- package/dist/esm/bn-grid.entry.js +51 -14
- package/dist/types/components/bn-grid/bn-grid.d.ts +6 -2
- package/package.json +1 -1
- package/dist/bn-template-engine/p-ce39e111.entry.js +0 -1
|
@@ -25826,7 +25826,7 @@ function templateProblem(customTemplate) {
|
|
|
25826
25826
|
return undefined;
|
|
25827
25827
|
}
|
|
25828
25828
|
|
|
25829
|
-
const bnLayoutCardCss = () => `:host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}`;
|
|
25829
|
+
const bnLayoutCardCss = () => `:host{--bn-baseline-offset-top:0px;--bn-baseline-offset-left:0px;--bn-baseline-offset-right:0px;background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}bn-body{box-sizing:border-box;padding:var(--bn-baseline-offset-top) var(--bn-baseline-offset-right) 0 var(--bn-baseline-offset-left)}`;
|
|
25830
25830
|
|
|
25831
25831
|
const LayoutCard = class {
|
|
25832
25832
|
constructor(hostRef) {
|
|
@@ -245,6 +245,17 @@ const CONFIG_ELEMENTS = new Set([
|
|
|
245
245
|
"bn-ruleset",
|
|
246
246
|
"bn-scaling-group",
|
|
247
247
|
]);
|
|
248
|
+
/**
|
|
249
|
+
* Frames around a component: a cell aligns on what is inside them, and moves
|
|
250
|
+
* the content inside the frame, so the title of the frame stays in place.
|
|
251
|
+
*/
|
|
252
|
+
const FRAME_ELEMENTS = new Set(["bn-layout-card"]);
|
|
253
|
+
/** The CSS properties a frame reads to move its content, by offset side. */
|
|
254
|
+
const FRAME_OFFSET_PROPERTIES = {
|
|
255
|
+
top: "--bn-baseline-offset-top",
|
|
256
|
+
left: "--bn-baseline-offset-left",
|
|
257
|
+
right: "--bn-baseline-offset-right",
|
|
258
|
+
};
|
|
248
259
|
/** A pass that keeps changing the offsets stops after this many: a component whose baseline follows its width could chase it. */
|
|
249
260
|
const MAX_ADJUSTMENTS = 5;
|
|
250
261
|
const Grid = class {
|
|
@@ -316,6 +327,8 @@ const Grid = class {
|
|
|
316
327
|
this.captions = {};
|
|
317
328
|
/** Per slot: how far the baseline pass moved the content. */
|
|
318
329
|
this.offsets = {};
|
|
330
|
+
/** Per slot: the frame around its component, from the last baseline pass. */
|
|
331
|
+
this.frames = new Map();
|
|
319
332
|
this.observed = new WeakSet();
|
|
320
333
|
this.scheduled = false;
|
|
321
334
|
this.run = 0;
|
|
@@ -397,6 +410,7 @@ const Grid = class {
|
|
|
397
410
|
this.run++;
|
|
398
411
|
if (Object.keys(this.offsets).length > 0)
|
|
399
412
|
this.offsets = {};
|
|
413
|
+
this.applyFrameOffsets();
|
|
400
414
|
return;
|
|
401
415
|
}
|
|
402
416
|
if (this.scheduled)
|
|
@@ -461,16 +475,30 @@ const Grid = class {
|
|
|
461
475
|
isBaselineMode() {
|
|
462
476
|
return this.resolvedVertical === "baseline" || this.resolvedHorizontal === "baseline";
|
|
463
477
|
}
|
|
464
|
-
/** The first visual component in a slot, or the slotted element itself. */
|
|
465
|
-
|
|
466
|
-
var _a;
|
|
478
|
+
/** The first visual component in a slot, or the slotted element itself, and the frame around it. */
|
|
479
|
+
contentIn(slot) {
|
|
467
480
|
const slotted = Array.from(this.element.children).find((child) => child.getAttribute("slot") === slot);
|
|
468
481
|
if (!slotted)
|
|
469
|
-
return
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
482
|
+
return {};
|
|
483
|
+
const all = [slotted, ...Array.from(slotted.querySelectorAll("*"))];
|
|
484
|
+
const visual = all.find((el) => el.localName.startsWith("bn-") && !CONFIG_ELEMENTS.has(el.localName) && !FRAME_ELEMENTS.has(el.localName));
|
|
485
|
+
const frame = visual
|
|
486
|
+
? all.find((el) => FRAME_ELEMENTS.has(el.localName) && el.contains(visual))
|
|
487
|
+
: undefined;
|
|
488
|
+
return { visual, frame };
|
|
489
|
+
}
|
|
490
|
+
/** Writes the offsets of framed slots onto their frames, and removes them when a slot has none. */
|
|
491
|
+
applyFrameOffsets() {
|
|
492
|
+
this.frames.forEach((frame, slot) => {
|
|
493
|
+
const offset = this.offsets[slot];
|
|
494
|
+
Object.keys(FRAME_OFFSET_PROPERTIES).forEach((side) => {
|
|
495
|
+
const value = offset === null || offset === void 0 ? void 0 : offset[side];
|
|
496
|
+
if (value)
|
|
497
|
+
frame.style.setProperty(FRAME_OFFSET_PROPERTIES[side], `${value}px`);
|
|
498
|
+
else
|
|
499
|
+
frame.style.removeProperty(FRAME_OFFSET_PROPERTIES[side]);
|
|
500
|
+
});
|
|
501
|
+
});
|
|
474
502
|
}
|
|
475
503
|
async align() {
|
|
476
504
|
var _a;
|
|
@@ -479,7 +507,8 @@ const Grid = class {
|
|
|
479
507
|
return;
|
|
480
508
|
const { rows, columns } = this.gridConfig;
|
|
481
509
|
const slots = rows.flatMap((row, rowIndex) => columns.map((column, columnIndex) => ({ slot: getSlotName(row, column), row: rowIndex, column: columnIndex })));
|
|
482
|
-
const
|
|
510
|
+
const contents = slots.map(({ slot }) => this.contentIn(slot));
|
|
511
|
+
const visuals = contents.map((content) => content.visual);
|
|
483
512
|
await Promise.all(visuals.map((visual) => { var _a; return (_a = visual === null || visual === void 0 ? void 0 : visual.componentOnReady) === null || _a === void 0 ? void 0 : _a.call(visual); }));
|
|
484
513
|
if (run !== this.run)
|
|
485
514
|
return;
|
|
@@ -494,13 +523,18 @@ const Grid = class {
|
|
|
494
523
|
var _a;
|
|
495
524
|
wrappers.set((_a = el.getAttribute("data-slot")) !== null && _a !== void 0 ? _a : "", el);
|
|
496
525
|
});
|
|
526
|
+
this.frames = new Map();
|
|
527
|
+
contents.forEach(({ frame }, index) => frame && this.frames.set(slots[index].slot, frame));
|
|
497
528
|
const cells = slots.map(({ slot, row, column }, index) => {
|
|
498
529
|
const visual = visuals[index];
|
|
499
530
|
const baseline = baselines[index];
|
|
500
531
|
// what is drawn now, not what is in the state: a render can still be pending
|
|
501
|
-
const
|
|
502
|
-
const
|
|
503
|
-
const
|
|
532
|
+
const cardFrame = contents[index].frame;
|
|
533
|
+
const holder = cardFrame !== null && cardFrame !== void 0 ? cardFrame : wrappers.get(slot);
|
|
534
|
+
const applied = (property) => parseFloat((holder === null || holder === void 0 ? void 0 : holder.style.getPropertyValue(property)) || "0") || 0;
|
|
535
|
+
const cell = cardFrame
|
|
536
|
+
? { slot, row, column, top: applied(FRAME_OFFSET_PROPERTIES.top), left: applied(FRAME_OFFSET_PROPERTIES.left) }
|
|
537
|
+
: { slot, row, column, top: applied("padding-top"), left: applied("margin-left") };
|
|
504
538
|
if (visual) {
|
|
505
539
|
const box = frame.toLocal(visual.getBoundingClientRect());
|
|
506
540
|
if (baseline.y !== undefined)
|
|
@@ -523,6 +557,7 @@ const Grid = class {
|
|
|
523
557
|
}
|
|
524
558
|
this.adjustments++;
|
|
525
559
|
this.offsets = next;
|
|
560
|
+
this.applyFrameOffsets();
|
|
526
561
|
// check once more after the new offsets are drawn; the status stays held until then
|
|
527
562
|
this.schedule();
|
|
528
563
|
}
|
|
@@ -767,6 +802,7 @@ const Grid = class {
|
|
|
767
802
|
* moves it onto the baseline. Without alignment the wrapper is a plain block.
|
|
768
803
|
*/
|
|
769
804
|
renderCellContent(slotName, style) {
|
|
805
|
+
var _a;
|
|
770
806
|
const text = this.captions[slotName];
|
|
771
807
|
const caption = text !== undefined ? (index.h("div", { class: "grid-caption", style: {
|
|
772
808
|
"font-size": `${style.captionFontSize}px`,
|
|
@@ -793,7 +829,8 @@ const Grid = class {
|
|
|
793
829
|
else if (this.resolvedVertical === "bottom") {
|
|
794
830
|
wrapper["margin-top"] = "auto";
|
|
795
831
|
}
|
|
796
|
-
|
|
832
|
+
// a frame moves its own content; the wrapper only moves a component without a frame
|
|
833
|
+
const offset = this.frames.has(slotName) ? { bottom: (_a = this.offsets[slotName]) === null || _a === void 0 ? void 0 : _a.bottom } : this.offsets[slotName];
|
|
797
834
|
if (offset === null || offset === void 0 ? void 0 : offset.bottom)
|
|
798
835
|
wrapper["margin-top"] = "auto";
|
|
799
836
|
if (offset === null || offset === void 0 ? void 0 : offset.top)
|
|
@@ -824,7 +861,7 @@ const Grid = class {
|
|
|
824
861
|
// would only be as wide as their content, and charts measure that width.
|
|
825
862
|
const fill = this.resolvedWidth === "equal";
|
|
826
863
|
const gridContainerStyle = Object.assign(Object.assign({ display: fill ? "grid" : "inline-grid" }, (fill ? { width: "100%" } : {})), { "grid-template-columns": this.getGridTemplateColumns(), "grid-template-rows": this.getGridTemplateRows(), gap: this.cellGap });
|
|
827
|
-
return (index.h(index.Host, { key: '
|
|
864
|
+
return (index.h(index.Host, { key: '643b4d675bac89c542618e7d6ec5f2c0ef8d6d6c', style: fill ? Object.assign(Object.assign({}, this.getFontStyles()), { display: "block" }) : this.getFontStyles() }, index.h("div", { key: '4bc671a6868b313c809f37aeb2f32ca30c7e9142', class: "grid-container", style: gridContainerStyle }, this.renderTitle(), this.renderColumnHeaders(), this.renderDataCells()), index.h("slot", { key: '5e66d95c65a0bad59d3816cf0009bb88fbe53f9c' })));
|
|
828
865
|
}
|
|
829
866
|
get element() { return index.getElement(this); }
|
|
830
867
|
static get watchers() { return {
|
|
@@ -16,6 +16,17 @@ const CONFIG_ELEMENTS = new Set([
|
|
|
16
16
|
"bn-ruleset",
|
|
17
17
|
"bn-scaling-group",
|
|
18
18
|
]);
|
|
19
|
+
/**
|
|
20
|
+
* Frames around a component: a cell aligns on what is inside them, and moves
|
|
21
|
+
* the content inside the frame, so the title of the frame stays in place.
|
|
22
|
+
*/
|
|
23
|
+
const FRAME_ELEMENTS = new Set(["bn-layout-card"]);
|
|
24
|
+
/** The CSS properties a frame reads to move its content, by offset side. */
|
|
25
|
+
const FRAME_OFFSET_PROPERTIES = {
|
|
26
|
+
top: "--bn-baseline-offset-top",
|
|
27
|
+
left: "--bn-baseline-offset-left",
|
|
28
|
+
right: "--bn-baseline-offset-right",
|
|
29
|
+
};
|
|
19
30
|
/** A pass that keeps changing the offsets stops after this many: a component whose baseline follows its width could chase it. */
|
|
20
31
|
const MAX_ADJUSTMENTS = 5;
|
|
21
32
|
/**
|
|
@@ -94,6 +105,8 @@ export class Grid {
|
|
|
94
105
|
this.captions = {};
|
|
95
106
|
/** Per slot: how far the baseline pass moved the content. */
|
|
96
107
|
this.offsets = {};
|
|
108
|
+
/** Per slot: the frame around its component, from the last baseline pass. */
|
|
109
|
+
this.frames = new Map();
|
|
97
110
|
this.observed = new WeakSet();
|
|
98
111
|
this.scheduled = false;
|
|
99
112
|
this.run = 0;
|
|
@@ -175,6 +188,7 @@ export class Grid {
|
|
|
175
188
|
this.run++;
|
|
176
189
|
if (Object.keys(this.offsets).length > 0)
|
|
177
190
|
this.offsets = {};
|
|
191
|
+
this.applyFrameOffsets();
|
|
178
192
|
return;
|
|
179
193
|
}
|
|
180
194
|
if (this.scheduled)
|
|
@@ -239,16 +253,30 @@ export class Grid {
|
|
|
239
253
|
isBaselineMode() {
|
|
240
254
|
return this.resolvedVertical === "baseline" || this.resolvedHorizontal === "baseline";
|
|
241
255
|
}
|
|
242
|
-
/** The first visual component in a slot, or the slotted element itself. */
|
|
243
|
-
|
|
244
|
-
var _a;
|
|
256
|
+
/** The first visual component in a slot, or the slotted element itself, and the frame around it. */
|
|
257
|
+
contentIn(slot) {
|
|
245
258
|
const slotted = Array.from(this.element.children).find((child) => child.getAttribute("slot") === slot);
|
|
246
259
|
if (!slotted)
|
|
247
|
-
return
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
260
|
+
return {};
|
|
261
|
+
const all = [slotted, ...Array.from(slotted.querySelectorAll("*"))];
|
|
262
|
+
const visual = all.find((el) => el.localName.startsWith("bn-") && !CONFIG_ELEMENTS.has(el.localName) && !FRAME_ELEMENTS.has(el.localName));
|
|
263
|
+
const frame = visual
|
|
264
|
+
? all.find((el) => FRAME_ELEMENTS.has(el.localName) && el.contains(visual))
|
|
265
|
+
: undefined;
|
|
266
|
+
return { visual, frame };
|
|
267
|
+
}
|
|
268
|
+
/** Writes the offsets of framed slots onto their frames, and removes them when a slot has none. */
|
|
269
|
+
applyFrameOffsets() {
|
|
270
|
+
this.frames.forEach((frame, slot) => {
|
|
271
|
+
const offset = this.offsets[slot];
|
|
272
|
+
Object.keys(FRAME_OFFSET_PROPERTIES).forEach((side) => {
|
|
273
|
+
const value = offset === null || offset === void 0 ? void 0 : offset[side];
|
|
274
|
+
if (value)
|
|
275
|
+
frame.style.setProperty(FRAME_OFFSET_PROPERTIES[side], `${value}px`);
|
|
276
|
+
else
|
|
277
|
+
frame.style.removeProperty(FRAME_OFFSET_PROPERTIES[side]);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
252
280
|
}
|
|
253
281
|
async align() {
|
|
254
282
|
var _a;
|
|
@@ -257,7 +285,8 @@ export class Grid {
|
|
|
257
285
|
return;
|
|
258
286
|
const { rows, columns } = this.gridConfig;
|
|
259
287
|
const slots = rows.flatMap((row, rowIndex) => columns.map((column, columnIndex) => ({ slot: getSlotName(row, column), row: rowIndex, column: columnIndex })));
|
|
260
|
-
const
|
|
288
|
+
const contents = slots.map(({ slot }) => this.contentIn(slot));
|
|
289
|
+
const visuals = contents.map((content) => content.visual);
|
|
261
290
|
await Promise.all(visuals.map((visual) => { var _a; return (_a = visual === null || visual === void 0 ? void 0 : visual.componentOnReady) === null || _a === void 0 ? void 0 : _a.call(visual); }));
|
|
262
291
|
if (run !== this.run)
|
|
263
292
|
return;
|
|
@@ -272,13 +301,18 @@ export class Grid {
|
|
|
272
301
|
var _a;
|
|
273
302
|
wrappers.set((_a = el.getAttribute("data-slot")) !== null && _a !== void 0 ? _a : "", el);
|
|
274
303
|
});
|
|
304
|
+
this.frames = new Map();
|
|
305
|
+
contents.forEach(({ frame }, index) => frame && this.frames.set(slots[index].slot, frame));
|
|
275
306
|
const cells = slots.map(({ slot, row, column }, index) => {
|
|
276
307
|
const visual = visuals[index];
|
|
277
308
|
const baseline = baselines[index];
|
|
278
309
|
// what is drawn now, not what is in the state: a render can still be pending
|
|
279
|
-
const
|
|
280
|
-
const
|
|
281
|
-
const
|
|
310
|
+
const cardFrame = contents[index].frame;
|
|
311
|
+
const holder = cardFrame !== null && cardFrame !== void 0 ? cardFrame : wrappers.get(slot);
|
|
312
|
+
const applied = (property) => parseFloat((holder === null || holder === void 0 ? void 0 : holder.style.getPropertyValue(property)) || "0") || 0;
|
|
313
|
+
const cell = cardFrame
|
|
314
|
+
? { slot, row, column, top: applied(FRAME_OFFSET_PROPERTIES.top), left: applied(FRAME_OFFSET_PROPERTIES.left) }
|
|
315
|
+
: { slot, row, column, top: applied("padding-top"), left: applied("margin-left") };
|
|
282
316
|
if (visual) {
|
|
283
317
|
const box = frame.toLocal(visual.getBoundingClientRect());
|
|
284
318
|
if (baseline.y !== undefined)
|
|
@@ -301,6 +335,7 @@ export class Grid {
|
|
|
301
335
|
}
|
|
302
336
|
this.adjustments++;
|
|
303
337
|
this.offsets = next;
|
|
338
|
+
this.applyFrameOffsets();
|
|
304
339
|
// check once more after the new offsets are drawn; the status stays held until then
|
|
305
340
|
this.schedule();
|
|
306
341
|
}
|
|
@@ -545,6 +580,7 @@ export class Grid {
|
|
|
545
580
|
* moves it onto the baseline. Without alignment the wrapper is a plain block.
|
|
546
581
|
*/
|
|
547
582
|
renderCellContent(slotName, style) {
|
|
583
|
+
var _a;
|
|
548
584
|
const text = this.captions[slotName];
|
|
549
585
|
const caption = text !== undefined ? (h("div", { class: "grid-caption", style: {
|
|
550
586
|
"font-size": `${style.captionFontSize}px`,
|
|
@@ -571,7 +607,8 @@ export class Grid {
|
|
|
571
607
|
else if (this.resolvedVertical === "bottom") {
|
|
572
608
|
wrapper["margin-top"] = "auto";
|
|
573
609
|
}
|
|
574
|
-
|
|
610
|
+
// a frame moves its own content; the wrapper only moves a component without a frame
|
|
611
|
+
const offset = this.frames.has(slotName) ? { bottom: (_a = this.offsets[slotName]) === null || _a === void 0 ? void 0 : _a.bottom } : this.offsets[slotName];
|
|
575
612
|
if (offset === null || offset === void 0 ? void 0 : offset.bottom)
|
|
576
613
|
wrapper["margin-top"] = "auto";
|
|
577
614
|
if (offset === null || offset === void 0 ? void 0 : offset.top)
|
|
@@ -602,7 +639,7 @@ export class Grid {
|
|
|
602
639
|
// would only be as wide as their content, and charts measure that width.
|
|
603
640
|
const fill = this.resolvedWidth === "equal";
|
|
604
641
|
const gridContainerStyle = Object.assign(Object.assign({ display: fill ? "grid" : "inline-grid" }, (fill ? { width: "100%" } : {})), { "grid-template-columns": this.getGridTemplateColumns(), "grid-template-rows": this.getGridTemplateRows(), gap: this.cellGap });
|
|
605
|
-
return (h(Host, { key: '
|
|
642
|
+
return (h(Host, { key: '643b4d675bac89c542618e7d6ec5f2c0ef8d6d6c', style: fill ? Object.assign(Object.assign({}, this.getFontStyles()), { display: "block" }) : this.getFontStyles() }, h("div", { key: '4bc671a6868b313c809f37aeb2f32ca30c7e9142', class: "grid-container", style: gridContainerStyle }, this.renderTitle(), this.renderColumnHeaders(), this.renderDataCells()), h("slot", { key: '5e66d95c65a0bad59d3816cf0009bb88fbe53f9c' })));
|
|
606
643
|
}
|
|
607
644
|
static get is() { return "bn-grid"; }
|
|
608
645
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
:host {
|
|
2
|
+
--bn-baseline-offset-top: 0px;
|
|
3
|
+
--bn-baseline-offset-left: 0px;
|
|
4
|
+
--bn-baseline-offset-right: 0px;
|
|
2
5
|
background: var(--bn-font-background, white);
|
|
3
6
|
color: var(--bn-font-color, black);
|
|
4
7
|
font-family: var(--bn-font-family, "Noto Sans", sans-serif);
|
|
@@ -28,4 +31,9 @@
|
|
|
28
31
|
height: 4em;
|
|
29
32
|
width: auto;
|
|
30
33
|
display: inline;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
bn-body {
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
padding: var(--bn-baseline-offset-top) var(--bn-baseline-offset-right) 0 var(--bn-baseline-offset-left);
|
|
31
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,h as e,a as l,t as s}from"./p-D6YGOYV1.js";import{LAYOUT_STATE_VERSION as o}from"./index.js";import{o as n,m as r}from"./p-DSkyHSIL.js";import{r as a,a as d}from"./p-CckAR27O.js";import{l as h}from"./p-CMCnX0iM.js";import{w as c}from"./p-DEHnizot.js";import{w as u}from"./p-DdGnuNtc.js";import{w as v}from"./p-C6XrNN2m.js";import{w as g}from"./p-CGI6XIaK.js";function f(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);return Array.isArray(i)?i.map(((t,i)=>{var e,l,s;return"string"==typeof t?{label:t,id:i+""}:"object"==typeof t&&null!==t?{label:null!==(l=null!==(e=t.label)&&void 0!==e?e:t.name)&&void 0!==l?l:i+"",id:null!==(s=t.id)&&void 0!==s?s:i+""}:{label:t+"",id:i+""}})):[]}catch(t){return console.error("parseHeaders: failed to parse JSON",t),[]}}function p(t,i){return`${t.id}-${i.id}`}function m(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);if(!Array.isArray(i))return["Headers must be an array"];const e=[],l=new Set;return i.forEach(((t,i)=>{"object"==typeof t&&null!==t&&void 0!==t.id&&("string"!=typeof t.id?e.push(`Header[${i}]: 'id' must be a string`):l.has(t.id)?e.push(`Header[${i}]: duplicate id '${t.id}'`):l.add(t.id),void 0!==t.label&&"string"!=typeof t.label&&e.push(`Header[${i}]: 'label' must be a string`))})),e}catch(t){return console.error("validateHeadersJson: failed to parse JSON",t),["Invalid JSON structure"]}}const b=["auto","equal"],w=["top","center","bottom","baseline"],y=["left","center","right","baseline"],C={top:"flex-start",center:"center",bottom:"flex-end",baseline:"flex-start"},x={left:"stretch",center:"center",right:"flex-end",baseline:"stretch"},H=t=>Math.round(100*t)/100,S=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]),j=t(class extends i{validateRowHeaders(t){const i="ERR_rowHeaders",e=m(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:"row-headers: "+e.join("; ")}):this.errors.remove(i),this.updateGridConfig()}validateColumnHeaders(t){const i="ERR_columnHeaders",e=m(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:"column-headers: "+e.join("; ")}):this.errors.remove(i),this.updateGridConfig()}validateCellHeight(t){this.resolvedHeight=this.validateChoice("cell-height","ERR_cellHeight",t,b,"auto")}validateCellWidth(t){this.resolvedWidth=this.validateChoice("cell-width","ERR_cellWidth",t,b,"auto")}validateCellVerticalAlign(t){this.resolvedVertical=this.validateChoice("cell-vertical-align","ERR_cellVerticalAlign",t,w,"top"),this.schedule()}validateCellHorizontalAlign(t){this.resolvedHorizontal=this.validateChoice("cell-horizontal-align","ERR_cellHorizontalAlign",t,y,"left"),this.schedule()}validateCellCaptions(t){const i=function(t){if(void 0===t||""===t.trim())return{};let i;try{i=JSON.parse(t)}catch(t){return}if("object"!=typeof i||null===i||Array.isArray(i))return;const e={};for(const[t,l]of Object.entries(i)){if("string"!=typeof l)return;""!==l&&(e[t]=l)}return e}(t);i?this.errors.remove("ERR_cellCaptions"):this.errors.addOrReplace({id:"ERR_cellCaptions",type:"error",message:"cell-captions: not a JSON object from slot name to text."}),this.captions=null!=i?i:{}}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.gridConfig={rows:[],columns:[]},this.resolvedHeight="auto",this.resolvedWidth="auto",this.resolvedVertical="top",this.resolvedHorizontal="left",this.captions={},this.offsets={},this.observed=new WeakSet,this.scheduled=!1,this.run=0,this.adjustments=0,this.chartTitle="",this.rowHeaders="[]",this.columnHeaders="[]",this.showRowHeaders=!0,this.showColumnHeaders=!0,this.showBorders=!0,this.rowHeaderWidth="auto",this.cellGap="0px",this.cellHeight="auto",this.cellWidth="auto",this.cellVerticalAlign="top",this.cellHorizontalAlign="left",this.cellCaptions="",this.schedule=()=>{if(!this.isBaselineMode())return this.run++,void(Object.keys(this.offsets).length>0&&(this.offsets={}));this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.align().catch((t=>console.error("bn-grid: aligning the baselines failed",t))).finally(t)}))}))))},u(this),this.holdStatus=c(this),this.errors=g(this),this.componentStyle=v(this)}connectedCallback(){var t;this.observed=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver(this.schedule),this.mutationObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot"]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule)}disconnectedCallback(){var t,i,e;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.mutationObserver)||void 0===i||i.disconnect(),null===(e=document.fonts)||void 0===e||e.removeEventListener("loadingdone",this.schedule),this.run++}componentDidRender(){this.schedule()}validateChoice(t,i,e,l,s){return null==e||""===e?(this.errors.remove(i),s):l.includes(e)?(this.errors.remove(i),e):(this.errors.addOrReplace({id:i,type:"error",message:`${t}: "${e}" is not one of ${l.join(", ")}.`}),s)}isBaselineMode(){return"baseline"===this.resolvedVertical||"baseline"===this.resolvedHorizontal}visualIn(t){var i;const e=Array.from(this.element.children).find((i=>i.getAttribute("slot")===t));if(!e)return;const l=t=>t.localName.startsWith("bn-")&&!S.has(t.localName);return l(e)?e:null!==(i=Array.from(e.querySelectorAll("*")).find(l))&&void 0!==i?i:void 0}async align(){var t;const i=++this.run;if(!this.element.isConnected||!this.isBaselineMode())return;const{rows:e,columns:l}=this.gridConfig,s=e.flatMap(((t,i)=>l.map(((e,l)=>({slot:p(t,e),row:i,column:l}))))),o=s.map((({slot:t})=>this.visualIn(t)));if(await Promise.all(o.map((t=>{var i;return null===(i=null==t?void 0:t.componentOnReady)||void 0===i?void 0:i.call(t)}))),i!==this.run)return;o.forEach((t=>t&&this.observe(t)));const n=await Promise.all(o.map((t=>"function"==typeof(null==t?void 0:t.getBaseline)?t.getBaseline().catch((()=>({}))):Promise.resolve({}))));if(i!==this.run)return;const r=h(this.element),a=new Map;null===(t=this.element.shadowRoot)||void 0===t||t.querySelectorAll(".grid-slot").forEach((t=>{var i;a.set(null!==(i=t.getAttribute("data-slot"))&&void 0!==i?i:"",t)}));const d=function(t,i,e){const l={};for(const i of t)l[i.slot]={};const s=(i,e,s,o)=>{var n;const r=new Map;for(const e of t)r.set(e[i],[...null!==(n=r.get(e[i]))&&void 0!==n?n:[],e]);for(const t of r.values()){const i=t.map((t=>{const i=e(t);return void 0===i?void 0:i-s(t)})),n=i.filter((t=>void 0!==t)),r=n.length>0?Math.max(...n):0,a=i.map((t=>void 0===t?void 0:H(r-t))),d=Math.max(0,...a.filter((t=>void 0!==t)));t.forEach(((t,i)=>o(l[t.slot],a[i],d)))}};return i&&s("row",(t=>t.y),(t=>t.top),((t,i)=>{void 0===i?t.bottom=!0:t.top=i})),e&&s("column",(t=>t.x),(t=>t.left),((t,i,e)=>{void 0!==i&&(t.left=i);const l=H(e-(null!=i?i:0));l>0&&(t.right=l)})),l}(s.map((({slot:t,row:i,column:e},l)=>{const s=o[l],d=n[l],h=a.get(t),c=t=>parseFloat((null==h?void 0:h.style.getPropertyValue(t))||"0")||0,u={slot:t,row:i,column:e,top:c("padding-top"),left:c("margin-left")};if(s){const t=r.toLocal(s.getBoundingClientRect());void 0!==d.y&&(u.y=t.y+d.y),void 0!==d.x&&(u.x=t.x+d.x)}return u})),"baseline"===this.resolvedVertical,"baseline"===this.resolvedHorizontal);if(function(t,i){var e,l,s,o,n,r,a,d;const h=new Set([...Object.keys(t),...Object.keys(i)]);for(const c of h){const h=null!==(e=t[c])&&void 0!==e?e:{},u=null!==(l=i[c])&&void 0!==l?l:{};if(!!h.bottom!=!!u.bottom)return!1;if(Math.abs((null!==(s=h.top)&&void 0!==s?s:0)-(null!==(o=u.top)&&void 0!==o?o:0))>=.5)return!1;if(Math.abs((null!==(n=h.left)&&void 0!==n?n:0)-(null!==(r=u.left)&&void 0!==r?r:0))>=.5)return!1;if(Math.abs((null!==(a=h.right)&&void 0!==a?a:0)-(null!==(d=u.right)&&void 0!==d?d:0))>=.5)return!1}return!0}(d,this.offsets))this.adjustments=0;else{if(this.adjustments>=5)return console.warn("bn-grid: the baselines did not settle; the cells keep their last alignment."),void(this.adjustments=0);this.adjustments++,this.offsets=d,this.schedule()}}observe(t){var i;this.observed.has(t)||(this.observed.add(t),null===(i=this.resizeObserver)||void 0===i||i.observe(t));const e=t=>{var i;t&&(this.observed.has(t)||(this.observed.add(t),null===(i=this.mutationObserver)||void 0===i||i.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["x1","y1","x2","y2","x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>e(t.shadowRoot))))};e(t.shadowRoot)}async getLayoutState(t){var i,e,l,s;const h=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",c=n(this.element),u=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),{rows:v,columns:g}=this.gridConfig,f={version:o,tag:this.element.localName,id:d(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:r(this.element,c),em:{fontSizePx:u,appliedScaleFactor:1},regions:[],metadata:{title:this.chartTitle||void 0,rowCount:v.length,columnCount:g.length,cellCount:v.length*g.length},diagnostics:a(this.element)},p=null===(l=this.element.shadowRoot)||void 0===l?void 0:l.querySelector(".grid-container");if(p&&f.regions.push({id:"grid",rect:r(p,c)}),"full"!==h||!p)return f;const m=[],b=t=>m.push(t),w=p.querySelector(".grid-title");return w&&b({kind:"gridTitle",label:(null===(s=w.textContent)||void 0===s?void 0:s.trim())||void 0,rect:r(w,c)}),p.querySelectorAll(".grid-header-col").forEach(((t,i)=>{var e,l;b({kind:"gridHeader",columnId:null===(e=g[i])||void 0===e?void 0:e.id,label:(null===(l=t.textContent)||void 0===l?void 0:l.trim())||void 0,rect:r(t,c)})})),p.querySelectorAll(".grid-header-row").forEach(((t,i)=>{var e,l;b({kind:"gridHeader",rowId:null===(e=v[i])||void 0===e?void 0:e.id,label:(null===(l=t.textContent)||void 0===l?void 0:l.trim())||void 0,rect:r(t,c)})})),p.querySelectorAll(".grid-cell").forEach(((t,i)=>{var e,l,s,o;b({kind:"gridCell",rowId:g.length>0?null===(e=v[Math.floor(i/g.length)])||void 0===e?void 0:e.id:void 0,columnId:g.length>0?null===(l=g[i%g.length])||void 0===l?void 0:l.id:void 0,slot:null!==(o=null===(s=t.querySelector("slot"))||void 0===s?void 0:s.getAttribute("name"))&&void 0!==o?o:void 0,rect:r(t,c)})})),p.querySelectorAll(".grid-caption").forEach((t=>{var i,e,l,s;b({kind:"gridCaption",slot:null!==(l=null===(e=null===(i=t.parentElement)||void 0===i?void 0:i.querySelector("slot"))||void 0===e?void 0:e.getAttribute("name"))&&void 0!==l?l:void 0,label:(null===(s=t.textContent)||void 0===s?void 0:s.trim())||void 0,rect:r(t,c)})})),f.elements=m,f}getGridStyle(){return this.componentStyle((t=>t["bn-grid"]))}componentWillLoad(){this.validateRowHeaders(this.rowHeaders),this.validateColumnHeaders(this.columnHeaders),this.validateCellHeight(this.cellHeight),this.validateCellWidth(this.cellWidth),this.validateCellVerticalAlign(this.cellVerticalAlign),this.validateCellHorizontalAlign(this.cellHorizontalAlign),this.validateCellCaptions(this.cellCaptions)}updateGridConfig(){this.gridConfig=function(t,i){return{rows:f(t),columns:f(i)}}(this.rowHeaders,this.columnHeaders)}shouldShowRowHeaders(){return this.showRowHeaders&&this.gridConfig.rows.length>0}shouldShowColumnHeaders(){return this.showColumnHeaders&&this.gridConfig.columns.length>0}shouldShowBorders(){return this.showBorders}getGridTemplateColumns(){const t=[];this.shouldShowRowHeaders()&&t.push(this.rowHeaderWidth);const i=this.gridConfig.columns.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedWidth?"minmax(0, 1fr)":"auto");return t.join(" ")}getGridTemplateRows(){const t=[];this.chartTitle&&t.push("auto"),this.shouldShowColumnHeaders()&&t.push("auto");const i=this.gridConfig.rows.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedHeight?"1fr":"auto");return t.join(" ")}renderTitle(){if(!this.chartTitle)return null;const t=(this.shouldShowRowHeaders()?1:0)+this.gridConfig.columns.length;return e("div",{class:"grid-title",style:{"grid-column":"1 / span "+t,"grid-row":"1"}},this.chartTitle)}renderColumnHeaders(){if(!this.shouldShowColumnHeaders())return null;const t=this.getGridStyle(),i=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",l=this.shouldShowRowHeaders()?2:1,s=this.chartTitle?2:1;return this.gridConfig.columns.map(((o,n)=>{const r=n>0;return e("div",{key:"col-header-"+o.id,class:"grid-header grid-header-col",style:{"grid-column":l+n+"","grid-row":s+"","border-left":r?i:"none",padding:t.cellPadding+"px","padding-left":r?t.cellPadding+4+"px":t.cellPadding+"px"}},o.label)}))}renderDataCells(){const t=this.getGridStyle(),i=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",l=this.shouldShowRowHeaders()?2:1,s=(this.chartTitle?1:0)+(this.shouldShowColumnHeaders()?1:0)+1,o=[];return this.gridConfig.rows.length>0&&this.gridConfig.columns.length>0&&this.gridConfig.rows.forEach(((n,r)=>{if(this.shouldShowRowHeaders()){const l=r>0;o.push(e("div",{key:"row-header-"+n.id,class:"grid-header grid-header-row",style:{"grid-column":"1","grid-row":s+r+"","border-top":l?i:"none",padding:t.cellPadding+"px","padding-top":l?t.cellPadding+4+"px":t.cellPadding+"px"}},n.label))}this.gridConfig.columns.forEach(((a,d)=>{const h=p(n,a),c=d>0,u=r>0;o.push(e("div",{key:"cell-"+h,class:"grid-cell",style:Object.assign({"grid-column":l+d+"","grid-row":s+r+"","border-left":c?i:"none","border-top":u?i:"none","padding-left":c?t.cellPadding+4+"px":"0","padding-top":u?t.cellPadding+4+"px":"0"},this.cellAlignStyle())},this.renderCellContent(h,t)))}))})),o}cellAlignStyle(){return"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal?{}:{display:"flex","flex-direction":"column","justify-content":C[this.resolvedVertical],"align-items":x[this.resolvedHorizontal]}}renderCellContent(t,i){const l=this.captions[t],s=void 0!==l?e("div",{class:"grid-caption",style:{"font-size":i.captionFontSize+"px","font-weight":i.captionFontWeight+"",color:i.captionColor,"margin-bottom":i.captionGap+"px","align-self":"flex-start"}},l):null,o={};"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal||(o["align-self"]="stretch","center"!==this.resolvedHorizontal&&"right"!==this.resolvedHorizontal||(o.display="flex",o["flex-direction"]="column",o["align-items"]=x[this.resolvedHorizontal])),"center"===this.resolvedVertical?(o["margin-top"]="auto",o["margin-bottom"]="auto"):"bottom"===this.resolvedVertical&&(o["margin-top"]="auto");const n=this.offsets[t];return(null==n?void 0:n.bottom)&&(o["margin-top"]="auto"),(null==n?void 0:n.top)&&(o["padding-top"]=n.top+"px"),(null==n?void 0:n.left)&&(o["margin-left"]=n.left+"px"),(null==n?void 0:n.right)&&(o["margin-right"]=n.right+"px"),[s,e("div",{class:"grid-slot","data-slot":t,style:o},e("slot",{name:t}))]}getFontStyles(){return this.componentStyle((t=>{var i,e,l,s;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":((null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333)+"px","--bn-font-color":(null===(l=t.global)||void 0===l?void 0:l.fontColor)||"#000000","--bn-font-background":(null===(s=t.global)||void 0===s?void 0:s.fontBackgroundColor)||"#ffffff"}}))}render(){const t="equal"===this.resolvedWidth,i=Object.assign(Object.assign({display:t?"grid":"inline-grid"},t?{width:"100%"}:{}),{"grid-template-columns":this.getGridTemplateColumns(),"grid-template-rows":this.getGridTemplateRows(),gap:this.cellGap});return e(l,{key:"3fcfe5d215a02a65652c00e37a2873377b708043",style:t?Object.assign(Object.assign({},this.getFontStyles()),{display:"block"}):this.getFontStyles()},e("div",{key:"55a2ae64a80a2f660601eaddbb5bd6e90e224796",class:"grid-container",style:i},this.renderTitle(),this.renderColumnHeaders(),this.renderDataCells()),e("slot",{key:"1c47b472d38b8e12a42e7f1609466681cdde98f3"}))}get element(){return this}static get watchers(){return{rowHeaders:[{validateRowHeaders:0}],columnHeaders:[{validateColumnHeaders:0}],cellHeight:[{validateCellHeight:0}],cellWidth:[{validateCellWidth:0}],cellVerticalAlign:[{validateCellVerticalAlign:0}],cellHorizontalAlign:[{validateCellHorizontalAlign:0}],cellCaptions:[{validateCellCaptions:0}]}}static get style(){return':host{display:inline-block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.grid-container{display:inline-grid;box-sizing:border-box}.grid-title{font-weight:normal;padding-bottom:8px}.grid-header{display:flex;align-items:flex-end;box-sizing:border-box}.grid-header-row{justify-content:flex-end;padding-right:8px}.grid-header-col{white-space:nowrap;justify-content:flex-start}.grid-cell{position:relative;box-sizing:border-box}'}},[257,"bn-grid",{selectedStyle:[513,"selected-style"],chartTitle:[1,"chart-title"],rowHeaders:[1,"row-headers"],columnHeaders:[1,"column-headers"],showRowHeaders:[4,"show-row-headers"],showColumnHeaders:[4,"show-column-headers"],i18nNamespace:[513,"i18n-namespace"],showBorders:[4,"show-borders"],rowHeaderWidth:[1,"row-header-width"],cellGap:[1,"cell-gap"],cellHeight:[1,"cell-height"],cellWidth:[1,"cell-width"],cellVerticalAlign:[1,"cell-vertical-align"],cellHorizontalAlign:[1,"cell-horizontal-align"],cellCaptions:[1,"cell-captions"],gridConfig:[32],resolvedHeight:[32],resolvedWidth:[32],resolvedVertical:[32],resolvedHorizontal:[32],captions:[32],offsets:[32],getLayoutState:[64]},void 0,{rowHeaders:[{validateRowHeaders:0}],columnHeaders:[{validateColumnHeaders:0}],cellHeight:[{validateCellHeight:0}],cellWidth:[{validateCellWidth:0}],cellVerticalAlign:[{validateCellVerticalAlign:0}],cellHorizontalAlign:[{validateCellHorizontalAlign:0}],cellCaptions:[{validateCellCaptions:0}]}]),R=j,A=function(){"undefined"!=typeof customElements&&["bn-grid"].forEach((t=>{"bn-grid"===t&&(customElements.get(s(t))||customElements.define(s(t),j))}))};export{R as BnGrid,A as defineCustomElement}
|
|
1
|
+
import{p as t,H as i,h as e,a as l,t as s}from"./p-D6YGOYV1.js";import{LAYOUT_STATE_VERSION as o}from"./index.js";import{o as n,m as r}from"./p-DSkyHSIL.js";import{r as a,a as d}from"./p-CckAR27O.js";import{l as h}from"./p-CMCnX0iM.js";import{w as c}from"./p-DEHnizot.js";import{w as u}from"./p-DdGnuNtc.js";import{w as v}from"./p-C6XrNN2m.js";import{w as f}from"./p-CGI6XIaK.js";function g(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);return Array.isArray(i)?i.map(((t,i)=>{var e,l,s;return"string"==typeof t?{label:t,id:i+""}:"object"==typeof t&&null!==t?{label:null!==(l=null!==(e=t.label)&&void 0!==e?e:t.name)&&void 0!==l?l:i+"",id:null!==(s=t.id)&&void 0!==s?s:i+""}:{label:t+"",id:i+""}})):[]}catch(t){return console.error("parseHeaders: failed to parse JSON",t),[]}}function p(t,i){return`${t.id}-${i.id}`}function m(t){if(!t||""===t.trim()||"[]"===t)return[];try{const i=JSON.parse(t);if(!Array.isArray(i))return["Headers must be an array"];const e=[],l=new Set;return i.forEach(((t,i)=>{"object"==typeof t&&null!==t&&void 0!==t.id&&("string"!=typeof t.id?e.push(`Header[${i}]: 'id' must be a string`):l.has(t.id)?e.push(`Header[${i}]: duplicate id '${t.id}'`):l.add(t.id),void 0!==t.label&&"string"!=typeof t.label&&e.push(`Header[${i}]: 'label' must be a string`))})),e}catch(t){return console.error("validateHeadersJson: failed to parse JSON",t),["Invalid JSON structure"]}}const b=["auto","equal"],w=["top","center","bottom","baseline"],y=["left","center","right","baseline"],x={top:"flex-start",center:"center",bottom:"flex-end",baseline:"flex-start"},C={left:"stretch",center:"center",right:"flex-end",baseline:"stretch"},H=t=>Math.round(100*t)/100,S=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]),j=new Set(["bn-layout-card"]),R={top:"--bn-baseline-offset-top",left:"--bn-baseline-offset-left",right:"--bn-baseline-offset-right"},A=t(class extends i{validateRowHeaders(t){const i="ERR_rowHeaders",e=m(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:"row-headers: "+e.join("; ")}):this.errors.remove(i),this.updateGridConfig()}validateColumnHeaders(t){const i="ERR_columnHeaders",e=m(t);e.length>0?this.errors.addOrReplace({id:i,type:"error",message:"column-headers: "+e.join("; ")}):this.errors.remove(i),this.updateGridConfig()}validateCellHeight(t){this.resolvedHeight=this.validateChoice("cell-height","ERR_cellHeight",t,b,"auto")}validateCellWidth(t){this.resolvedWidth=this.validateChoice("cell-width","ERR_cellWidth",t,b,"auto")}validateCellVerticalAlign(t){this.resolvedVertical=this.validateChoice("cell-vertical-align","ERR_cellVerticalAlign",t,w,"top"),this.schedule()}validateCellHorizontalAlign(t){this.resolvedHorizontal=this.validateChoice("cell-horizontal-align","ERR_cellHorizontalAlign",t,y,"left"),this.schedule()}validateCellCaptions(t){const i=function(t){if(void 0===t||""===t.trim())return{};let i;try{i=JSON.parse(t)}catch(t){return}if("object"!=typeof i||null===i||Array.isArray(i))return;const e={};for(const[t,l]of Object.entries(i)){if("string"!=typeof l)return;""!==l&&(e[t]=l)}return e}(t);i?this.errors.remove("ERR_cellCaptions"):this.errors.addOrReplace({id:"ERR_cellCaptions",type:"error",message:"cell-captions: not a JSON object from slot name to text."}),this.captions=null!=i?i:{}}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.gridConfig={rows:[],columns:[]},this.resolvedHeight="auto",this.resolvedWidth="auto",this.resolvedVertical="top",this.resolvedHorizontal="left",this.captions={},this.offsets={},this.frames=new Map,this.observed=new WeakSet,this.scheduled=!1,this.run=0,this.adjustments=0,this.chartTitle="",this.rowHeaders="[]",this.columnHeaders="[]",this.showRowHeaders=!0,this.showColumnHeaders=!0,this.showBorders=!0,this.rowHeaderWidth="auto",this.cellGap="0px",this.cellHeight="auto",this.cellWidth="auto",this.cellVerticalAlign="top",this.cellHorizontalAlign="left",this.cellCaptions="",this.schedule=()=>{if(!this.isBaselineMode())return this.run++,Object.keys(this.offsets).length>0&&(this.offsets={}),void this.applyFrameOffsets();this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.align().catch((t=>console.error("bn-grid: aligning the baselines failed",t))).finally(t)}))}))))},u(this),this.holdStatus=c(this),this.errors=f(this),this.componentStyle=v(this)}connectedCallback(){var t;this.observed=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver(this.schedule),this.mutationObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot"]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule)}disconnectedCallback(){var t,i,e;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.mutationObserver)||void 0===i||i.disconnect(),null===(e=document.fonts)||void 0===e||e.removeEventListener("loadingdone",this.schedule),this.run++}componentDidRender(){this.schedule()}validateChoice(t,i,e,l,s){return null==e||""===e?(this.errors.remove(i),s):l.includes(e)?(this.errors.remove(i),e):(this.errors.addOrReplace({id:i,type:"error",message:`${t}: "${e}" is not one of ${l.join(", ")}.`}),s)}isBaselineMode(){return"baseline"===this.resolvedVertical||"baseline"===this.resolvedHorizontal}contentIn(t){const i=Array.from(this.element.children).find((i=>i.getAttribute("slot")===t));if(!i)return{};const e=[i,...Array.from(i.querySelectorAll("*"))],l=e.find((t=>t.localName.startsWith("bn-")&&!S.has(t.localName)&&!j.has(t.localName))),s=l?e.find((t=>j.has(t.localName)&&t.contains(l))):void 0;return{visual:l,frame:s}}applyFrameOffsets(){this.frames.forEach(((t,i)=>{const e=this.offsets[i];Object.keys(R).forEach((i=>{const l=null==e?void 0:e[i];l?t.style.setProperty(R[i],l+"px"):t.style.removeProperty(R[i])}))}))}async align(){var t;const i=++this.run;if(!this.element.isConnected||!this.isBaselineMode())return;const{rows:e,columns:l}=this.gridConfig,s=e.flatMap(((t,i)=>l.map(((e,l)=>({slot:p(t,e),row:i,column:l}))))),o=s.map((({slot:t})=>this.contentIn(t))),n=o.map((t=>t.visual));if(await Promise.all(n.map((t=>{var i;return null===(i=null==t?void 0:t.componentOnReady)||void 0===i?void 0:i.call(t)}))),i!==this.run)return;n.forEach((t=>t&&this.observe(t)));const r=await Promise.all(n.map((t=>"function"==typeof(null==t?void 0:t.getBaseline)?t.getBaseline().catch((()=>({}))):Promise.resolve({}))));if(i!==this.run)return;const a=h(this.element),d=new Map;null===(t=this.element.shadowRoot)||void 0===t||t.querySelectorAll(".grid-slot").forEach((t=>{var i;d.set(null!==(i=t.getAttribute("data-slot"))&&void 0!==i?i:"",t)})),this.frames=new Map,o.forEach((({frame:t},i)=>t&&this.frames.set(s[i].slot,t)));const c=function(t,i,e){const l={};for(const i of t)l[i.slot]={};const s=(i,e,s,o)=>{var n;const r=new Map;for(const e of t)r.set(e[i],[...null!==(n=r.get(e[i]))&&void 0!==n?n:[],e]);for(const t of r.values()){const i=t.map((t=>{const i=e(t);return void 0===i?void 0:i-s(t)})),n=i.filter((t=>void 0!==t)),r=n.length>0?Math.max(...n):0,a=i.map((t=>void 0===t?void 0:H(r-t))),d=Math.max(0,...a.filter((t=>void 0!==t)));t.forEach(((t,i)=>o(l[t.slot],a[i],d)))}};return i&&s("row",(t=>t.y),(t=>t.top),((t,i)=>{void 0===i?t.bottom=!0:t.top=i})),e&&s("column",(t=>t.x),(t=>t.left),((t,i,e)=>{void 0!==i&&(t.left=i);const l=H(e-(null!=i?i:0));l>0&&(t.right=l)})),l}(s.map((({slot:t,row:i,column:e},l)=>{const s=n[l],h=r[l],c=o[l].frame,u=null!=c?c:d.get(t),v=t=>parseFloat((null==u?void 0:u.style.getPropertyValue(t))||"0")||0,f=c?{slot:t,row:i,column:e,top:v(R.top),left:v(R.left)}:{slot:t,row:i,column:e,top:v("padding-top"),left:v("margin-left")};if(s){const t=a.toLocal(s.getBoundingClientRect());void 0!==h.y&&(f.y=t.y+h.y),void 0!==h.x&&(f.x=t.x+h.x)}return f})),"baseline"===this.resolvedVertical,"baseline"===this.resolvedHorizontal);if(function(t,i){var e,l,s,o,n,r,a,d;const h=new Set([...Object.keys(t),...Object.keys(i)]);for(const c of h){const h=null!==(e=t[c])&&void 0!==e?e:{},u=null!==(l=i[c])&&void 0!==l?l:{};if(!!h.bottom!=!!u.bottom)return!1;if(Math.abs((null!==(s=h.top)&&void 0!==s?s:0)-(null!==(o=u.top)&&void 0!==o?o:0))>=.5)return!1;if(Math.abs((null!==(n=h.left)&&void 0!==n?n:0)-(null!==(r=u.left)&&void 0!==r?r:0))>=.5)return!1;if(Math.abs((null!==(a=h.right)&&void 0!==a?a:0)-(null!==(d=u.right)&&void 0!==d?d:0))>=.5)return!1}return!0}(c,this.offsets))this.adjustments=0;else{if(this.adjustments>=5)return console.warn("bn-grid: the baselines did not settle; the cells keep their last alignment."),void(this.adjustments=0);this.adjustments++,this.offsets=c,this.applyFrameOffsets(),this.schedule()}}observe(t){var i;this.observed.has(t)||(this.observed.add(t),null===(i=this.resizeObserver)||void 0===i||i.observe(t));const e=t=>{var i;t&&(this.observed.has(t)||(this.observed.add(t),null===(i=this.mutationObserver)||void 0===i||i.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["x1","y1","x2","y2","x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>e(t.shadowRoot))))};e(t.shadowRoot)}async getLayoutState(t){var i,e,l,s;const h=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",c=n(this.element),u=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),{rows:v,columns:f}=this.gridConfig,g={version:o,tag:this.element.localName,id:d(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:r(this.element,c),em:{fontSizePx:u,appliedScaleFactor:1},regions:[],metadata:{title:this.chartTitle||void 0,rowCount:v.length,columnCount:f.length,cellCount:v.length*f.length},diagnostics:a(this.element)},p=null===(l=this.element.shadowRoot)||void 0===l?void 0:l.querySelector(".grid-container");if(p&&g.regions.push({id:"grid",rect:r(p,c)}),"full"!==h||!p)return g;const m=[],b=t=>m.push(t),w=p.querySelector(".grid-title");return w&&b({kind:"gridTitle",label:(null===(s=w.textContent)||void 0===s?void 0:s.trim())||void 0,rect:r(w,c)}),p.querySelectorAll(".grid-header-col").forEach(((t,i)=>{var e,l;b({kind:"gridHeader",columnId:null===(e=f[i])||void 0===e?void 0:e.id,label:(null===(l=t.textContent)||void 0===l?void 0:l.trim())||void 0,rect:r(t,c)})})),p.querySelectorAll(".grid-header-row").forEach(((t,i)=>{var e,l;b({kind:"gridHeader",rowId:null===(e=v[i])||void 0===e?void 0:e.id,label:(null===(l=t.textContent)||void 0===l?void 0:l.trim())||void 0,rect:r(t,c)})})),p.querySelectorAll(".grid-cell").forEach(((t,i)=>{var e,l,s,o;b({kind:"gridCell",rowId:f.length>0?null===(e=v[Math.floor(i/f.length)])||void 0===e?void 0:e.id:void 0,columnId:f.length>0?null===(l=f[i%f.length])||void 0===l?void 0:l.id:void 0,slot:null!==(o=null===(s=t.querySelector("slot"))||void 0===s?void 0:s.getAttribute("name"))&&void 0!==o?o:void 0,rect:r(t,c)})})),p.querySelectorAll(".grid-caption").forEach((t=>{var i,e,l,s;b({kind:"gridCaption",slot:null!==(l=null===(e=null===(i=t.parentElement)||void 0===i?void 0:i.querySelector("slot"))||void 0===e?void 0:e.getAttribute("name"))&&void 0!==l?l:void 0,label:(null===(s=t.textContent)||void 0===s?void 0:s.trim())||void 0,rect:r(t,c)})})),g.elements=m,g}getGridStyle(){return this.componentStyle((t=>t["bn-grid"]))}componentWillLoad(){this.validateRowHeaders(this.rowHeaders),this.validateColumnHeaders(this.columnHeaders),this.validateCellHeight(this.cellHeight),this.validateCellWidth(this.cellWidth),this.validateCellVerticalAlign(this.cellVerticalAlign),this.validateCellHorizontalAlign(this.cellHorizontalAlign),this.validateCellCaptions(this.cellCaptions)}updateGridConfig(){this.gridConfig=function(t,i){return{rows:g(t),columns:g(i)}}(this.rowHeaders,this.columnHeaders)}shouldShowRowHeaders(){return this.showRowHeaders&&this.gridConfig.rows.length>0}shouldShowColumnHeaders(){return this.showColumnHeaders&&this.gridConfig.columns.length>0}shouldShowBorders(){return this.showBorders}getGridTemplateColumns(){const t=[];this.shouldShowRowHeaders()&&t.push(this.rowHeaderWidth);const i=this.gridConfig.columns.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedWidth?"minmax(0, 1fr)":"auto");return t.join(" ")}getGridTemplateRows(){const t=[];this.chartTitle&&t.push("auto"),this.shouldShowColumnHeaders()&&t.push("auto");const i=this.gridConfig.rows.length||1;for(let e=0;e<i;e++)t.push("equal"===this.resolvedHeight?"1fr":"auto");return t.join(" ")}renderTitle(){if(!this.chartTitle)return null;const t=(this.shouldShowRowHeaders()?1:0)+this.gridConfig.columns.length;return e("div",{class:"grid-title",style:{"grid-column":"1 / span "+t,"grid-row":"1"}},this.chartTitle)}renderColumnHeaders(){if(!this.shouldShowColumnHeaders())return null;const t=this.getGridStyle(),i=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",l=this.shouldShowRowHeaders()?2:1,s=this.chartTitle?2:1;return this.gridConfig.columns.map(((o,n)=>{const r=n>0;return e("div",{key:"col-header-"+o.id,class:"grid-header grid-header-col",style:{"grid-column":l+n+"","grid-row":s+"","border-left":r?i:"none",padding:t.cellPadding+"px","padding-left":r?t.cellPadding+4+"px":t.cellPadding+"px"}},o.label)}))}renderDataCells(){const t=this.getGridStyle(),i=this.shouldShowBorders()?`${t.borderWidth}px solid ${t.borderColor}`:"none",l=this.shouldShowRowHeaders()?2:1,s=(this.chartTitle?1:0)+(this.shouldShowColumnHeaders()?1:0)+1,o=[];return this.gridConfig.rows.length>0&&this.gridConfig.columns.length>0&&this.gridConfig.rows.forEach(((n,r)=>{if(this.shouldShowRowHeaders()){const l=r>0;o.push(e("div",{key:"row-header-"+n.id,class:"grid-header grid-header-row",style:{"grid-column":"1","grid-row":s+r+"","border-top":l?i:"none",padding:t.cellPadding+"px","padding-top":l?t.cellPadding+4+"px":t.cellPadding+"px"}},n.label))}this.gridConfig.columns.forEach(((a,d)=>{const h=p(n,a),c=d>0,u=r>0;o.push(e("div",{key:"cell-"+h,class:"grid-cell",style:Object.assign({"grid-column":l+d+"","grid-row":s+r+"","border-left":c?i:"none","border-top":u?i:"none","padding-left":c?t.cellPadding+4+"px":"0","padding-top":u?t.cellPadding+4+"px":"0"},this.cellAlignStyle())},this.renderCellContent(h,t)))}))})),o}cellAlignStyle(){return"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal?{}:{display:"flex","flex-direction":"column","justify-content":x[this.resolvedVertical],"align-items":C[this.resolvedHorizontal]}}renderCellContent(t,i){var l;const s=this.captions[t],o=void 0!==s?e("div",{class:"grid-caption",style:{"font-size":i.captionFontSize+"px","font-weight":i.captionFontWeight+"",color:i.captionColor,"margin-bottom":i.captionGap+"px","align-self":"flex-start"}},s):null,n={};"top"===this.resolvedVertical&&"left"===this.resolvedHorizontal||(n["align-self"]="stretch","center"!==this.resolvedHorizontal&&"right"!==this.resolvedHorizontal||(n.display="flex",n["flex-direction"]="column",n["align-items"]=C[this.resolvedHorizontal])),"center"===this.resolvedVertical?(n["margin-top"]="auto",n["margin-bottom"]="auto"):"bottom"===this.resolvedVertical&&(n["margin-top"]="auto");const r=this.frames.has(t)?{bottom:null===(l=this.offsets[t])||void 0===l?void 0:l.bottom}:this.offsets[t];return(null==r?void 0:r.bottom)&&(n["margin-top"]="auto"),(null==r?void 0:r.top)&&(n["padding-top"]=r.top+"px"),(null==r?void 0:r.left)&&(n["margin-left"]=r.left+"px"),(null==r?void 0:r.right)&&(n["margin-right"]=r.right+"px"),[o,e("div",{class:"grid-slot","data-slot":t,style:n},e("slot",{name:t}))]}getFontStyles(){return this.componentStyle((t=>{var i,e,l,s;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":((null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333)+"px","--bn-font-color":(null===(l=t.global)||void 0===l?void 0:l.fontColor)||"#000000","--bn-font-background":(null===(s=t.global)||void 0===s?void 0:s.fontBackgroundColor)||"#ffffff"}}))}render(){const t="equal"===this.resolvedWidth,i=Object.assign(Object.assign({display:t?"grid":"inline-grid"},t?{width:"100%"}:{}),{"grid-template-columns":this.getGridTemplateColumns(),"grid-template-rows":this.getGridTemplateRows(),gap:this.cellGap});return e(l,{key:"643b4d675bac89c542618e7d6ec5f2c0ef8d6d6c",style:t?Object.assign(Object.assign({},this.getFontStyles()),{display:"block"}):this.getFontStyles()},e("div",{key:"4bc671a6868b313c809f37aeb2f32ca30c7e9142",class:"grid-container",style:i},this.renderTitle(),this.renderColumnHeaders(),this.renderDataCells()),e("slot",{key:"5e66d95c65a0bad59d3816cf0009bb88fbe53f9c"}))}get element(){return this}static get watchers(){return{rowHeaders:[{validateRowHeaders:0}],columnHeaders:[{validateColumnHeaders:0}],cellHeight:[{validateCellHeight:0}],cellWidth:[{validateCellWidth:0}],cellVerticalAlign:[{validateCellVerticalAlign:0}],cellHorizontalAlign:[{validateCellHorizontalAlign:0}],cellCaptions:[{validateCellCaptions:0}]}}static get style(){return':host{display:inline-block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.grid-container{display:inline-grid;box-sizing:border-box}.grid-title{font-weight:normal;padding-bottom:8px}.grid-header{display:flex;align-items:flex-end;box-sizing:border-box}.grid-header-row{justify-content:flex-end;padding-right:8px}.grid-header-col{white-space:nowrap;justify-content:flex-start}.grid-cell{position:relative;box-sizing:border-box}'}},[257,"bn-grid",{selectedStyle:[513,"selected-style"],chartTitle:[1,"chart-title"],rowHeaders:[1,"row-headers"],columnHeaders:[1,"column-headers"],showRowHeaders:[4,"show-row-headers"],showColumnHeaders:[4,"show-column-headers"],i18nNamespace:[513,"i18n-namespace"],showBorders:[4,"show-borders"],rowHeaderWidth:[1,"row-header-width"],cellGap:[1,"cell-gap"],cellHeight:[1,"cell-height"],cellWidth:[1,"cell-width"],cellVerticalAlign:[1,"cell-vertical-align"],cellHorizontalAlign:[1,"cell-horizontal-align"],cellCaptions:[1,"cell-captions"],gridConfig:[32],resolvedHeight:[32],resolvedWidth:[32],resolvedVertical:[32],resolvedHorizontal:[32],captions:[32],offsets:[32],getLayoutState:[64]},void 0,{rowHeaders:[{validateRowHeaders:0}],columnHeaders:[{validateColumnHeaders:0}],cellHeight:[{validateCellHeight:0}],cellWidth:[{validateCellWidth:0}],cellVerticalAlign:[{validateCellVerticalAlign:0}],cellHorizontalAlign:[{validateCellHorizontalAlign:0}],cellCaptions:[{validateCellCaptions:0}]}]),O=A,k=function(){"undefined"!=typeof customElements&&["bn-grid"].forEach((t=>{"bn-grid"===t&&(customElements.get(s(t))||customElements.define(s(t),A))}))};export{O as BnGrid,k as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,h as s,F as
|
|
1
|
+
import{p as t,H as e,h as s,F as i,t as r}from"./p-D6YGOYV1.js";import{g as a}from"./p-BcOud3dQ.js";import{w as n}from"./p-DEHnizot.js";import{w as o}from"./p-CGI6XIaK.js";import{a as l}from"./p-BoUkFdpu.js";import{t as d,a as c,b as m,c as h,C as p,d as b}from"./p-Dq4KMCDU.js";import{d as u}from"./p-Ku08TQL1.js";import{d as f}from"./p-8a2-IS-y.js";import{d as g}from"./p-De82WP7z.js";import{d as y}from"./p-B2jqpOF9.js";import{d as x}from"./p-BpCL2bfw.js";const k=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.titleImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.footerText="",this.cardLayout="full",this.cardCustomTemplate='"a b" "c d"',this.cardGridGap="0",this.cardFitToContent=!1,this.cardShowBorder=!0,n(this),this.errors=o(this),this.resolveInherited=l(this,[{propName:"titleScenarios",ancestorAttr:"title-scenarios"},{propName:"titleVariances",ancestorAttr:"title-variances"},{propName:"titleOrder",ancestorAttr:"title-order"},{propName:"titleOrderDirection",ancestorAttr:"title-order-direction"},{propName:"ruleset",ancestorAttr:"ruleset"}])}connectedCallback(){this.stores=a(this.element)}getCommonStyles(){let t="100%";return!0===this.cardFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.cardGridGap+"px"}}getGridTemplateColumns(t){return d(this.getTemplatePattern(t))}getRowCount(t){return c(this.getTemplatePattern(t)).length||1}getGridTemplateRows(t){const e=this.getRowCount(t);return this.cardFitToContent?Array(e).fill("auto").join(" "):Array(e).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplatePattern(this.cardLayout),"grid-template-columns":this.getGridTemplateColumns(this.cardLayout),"grid-template-rows":this.getGridTemplateRows(this.cardLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const e=this.createDivAreaStyles(t);return s(i,null,e.map(((t,e)=>s("div",{style:t},s("slot",{name:"card-slot-"+e})))))}extractSlotNames(t){return m(t)}getTemplatePattern(t){return h(t,this.cardCustomTemplate)}componentWillRender(){const t=this.cardLayout===p?b(this.cardCustomTemplate):void 0;t?this.errors.addOrReplace({id:"WARN_cardCustomTemplate",type:"warning",message:"cardCustomTemplate: "+t}):this.errors.remove("WARN_cardCustomTemplate")}setCardClass(){return!0===this.cardShowBorder?"card_box border":"card_box"}titleProp(t){return this.resolveInherited(t,this[t],"").value}prepareTitleImage(t){if(null==t||""===t)return"";const e=this.stores.assets.state;return t.startsWith("asset:")?e[t.substring(6)]:e[t]||t}render(){var t;const e=this.getLayoutStyle(),i=this.extractSlotNames(e["grid-template-areas"]);return s("bn-card",{key:"867690c16715585ca9f879ac80e00c95cb37b577",styles:this.styles,"selected-style":this.selectedStyle,class:this.setCardClass()},s("div",{key:"c25c8e5aec46acebe38d6fac2a4516f41d25fe90",class:"cardtitle"},s("bn-title",{key:"8a3da2a58cb7fb72fddcd838f27a1b231c2805e2","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:this.titleProp("ruleset"),"business-unit":this.titleBusinessUnit,scenarios:this.titleProp("titleScenarios"),variances:this.titleProp("titleVariances"),order:this.titleProp("titleOrder"),"order-direction":this.titleProp("titleOrderDirection"),measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),null!=this.titleImage&&""!==this.titleImage?s("img",{class:"image",src:this.prepareTitleImage(this.titleImage)}):""),s("bn-body",{key:"c0616d184dce59190238ceb98ecd2828e65991af"},s("div",{key:"42596bc88ddf38c2b820de17a69091df2e3c4227",style:e,"data-bn-fit-content":this.cardFitToContent?this.getRowCount(this.cardLayout)+"":null},this.getSlots(i))),s("bn-footer",{key:"ca29bc6d17eb385b3ded5fb46e0efe1ee228e405",text:this.footerText,"page-number":"0","display-page-number":"false"}))}get element(){return this}static get style(){return':host{--bn-baseline-offset-top:0px;--bn-baseline-offset-left:0px;--bn-baseline-offset-right:0px;background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}bn-body{box-sizing:border-box;padding:var(--bn-baseline-offset-top) var(--bn-baseline-offset-right) 0 var(--bn-baseline-offset-left)}'}},[257,"bn-layout-card",{styles:[1],selectedStyle:[1,"selected-style"],ruleset:[1],titleImage:[1,"title-image"],titleBusinessUnit:[1,"title-business-unit"],titleScenarios:[1,"title-scenarios"],titleVariances:[1,"title-variances"],titleOrder:[1,"title-order"],titleOrderDirection:[1,"title-order-direction"],titleMeasures:[1,"title-measures"],titleDateStart:[1,"title-date-start"],titleDateEnd:[1,"title-date-end"],titleDateFormat:[1,"title-date-format"],titleDateLink:[1,"title-date-link"],titleNamespace:[1,"title-namespace"],i18nNamespace:[513,"i18n-namespace"],footerText:[1,"footer-text"],cardLayout:[1,"card-layout"],cardCustomTemplate:[1,"card-custom-template"],cardGridGap:[1,"card-grid-gap"],cardFitToContent:[4,"card-fit-to-content"],cardShowBorder:[4,"card-show-border"]}]),v=k,w=function(){"undefined"!=typeof customElements&&["bn-layout-card","bn-body","bn-card","bn-footer","bn-title","bn-title-renderer"].forEach((t=>{switch(t){case"bn-layout-card":customElements.get(r(t))||customElements.define(r(t),k);break;case"bn-body":customElements.get(r(t))||u();break;case"bn-card":customElements.get(r(t))||f();break;case"bn-footer":customElements.get(r(t))||g();break;case"bn-title":customElements.get(r(t))||y();break;case"bn-title-renderer":customElements.get(r(t))||x()}}))};export{v as BnLayoutCard,w as defineCustomElement}
|
|
@@ -25824,7 +25824,7 @@ function templateProblem(customTemplate) {
|
|
|
25824
25824
|
return undefined;
|
|
25825
25825
|
}
|
|
25826
25826
|
|
|
25827
|
-
const bnLayoutCardCss = () => `:host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}`;
|
|
25827
|
+
const bnLayoutCardCss = () => `:host{--bn-baseline-offset-top:0px;--bn-baseline-offset-left:0px;--bn-baseline-offset-right:0px;background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}bn-body{box-sizing:border-box;padding:var(--bn-baseline-offset-top) var(--bn-baseline-offset-right) 0 var(--bn-baseline-offset-left)}`;
|
|
25828
25828
|
|
|
25829
25829
|
const LayoutCard = class {
|
|
25830
25830
|
constructor(hostRef) {
|
|
@@ -243,6 +243,17 @@ const CONFIG_ELEMENTS = new Set([
|
|
|
243
243
|
"bn-ruleset",
|
|
244
244
|
"bn-scaling-group",
|
|
245
245
|
]);
|
|
246
|
+
/**
|
|
247
|
+
* Frames around a component: a cell aligns on what is inside them, and moves
|
|
248
|
+
* the content inside the frame, so the title of the frame stays in place.
|
|
249
|
+
*/
|
|
250
|
+
const FRAME_ELEMENTS = new Set(["bn-layout-card"]);
|
|
251
|
+
/** The CSS properties a frame reads to move its content, by offset side. */
|
|
252
|
+
const FRAME_OFFSET_PROPERTIES = {
|
|
253
|
+
top: "--bn-baseline-offset-top",
|
|
254
|
+
left: "--bn-baseline-offset-left",
|
|
255
|
+
right: "--bn-baseline-offset-right",
|
|
256
|
+
};
|
|
246
257
|
/** A pass that keeps changing the offsets stops after this many: a component whose baseline follows its width could chase it. */
|
|
247
258
|
const MAX_ADJUSTMENTS = 5;
|
|
248
259
|
const Grid = class {
|
|
@@ -314,6 +325,8 @@ const Grid = class {
|
|
|
314
325
|
this.captions = {};
|
|
315
326
|
/** Per slot: how far the baseline pass moved the content. */
|
|
316
327
|
this.offsets = {};
|
|
328
|
+
/** Per slot: the frame around its component, from the last baseline pass. */
|
|
329
|
+
this.frames = new Map();
|
|
317
330
|
this.observed = new WeakSet();
|
|
318
331
|
this.scheduled = false;
|
|
319
332
|
this.run = 0;
|
|
@@ -395,6 +408,7 @@ const Grid = class {
|
|
|
395
408
|
this.run++;
|
|
396
409
|
if (Object.keys(this.offsets).length > 0)
|
|
397
410
|
this.offsets = {};
|
|
411
|
+
this.applyFrameOffsets();
|
|
398
412
|
return;
|
|
399
413
|
}
|
|
400
414
|
if (this.scheduled)
|
|
@@ -459,16 +473,30 @@ const Grid = class {
|
|
|
459
473
|
isBaselineMode() {
|
|
460
474
|
return this.resolvedVertical === "baseline" || this.resolvedHorizontal === "baseline";
|
|
461
475
|
}
|
|
462
|
-
/** The first visual component in a slot, or the slotted element itself. */
|
|
463
|
-
|
|
464
|
-
var _a;
|
|
476
|
+
/** The first visual component in a slot, or the slotted element itself, and the frame around it. */
|
|
477
|
+
contentIn(slot) {
|
|
465
478
|
const slotted = Array.from(this.element.children).find((child) => child.getAttribute("slot") === slot);
|
|
466
479
|
if (!slotted)
|
|
467
|
-
return
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
480
|
+
return {};
|
|
481
|
+
const all = [slotted, ...Array.from(slotted.querySelectorAll("*"))];
|
|
482
|
+
const visual = all.find((el) => el.localName.startsWith("bn-") && !CONFIG_ELEMENTS.has(el.localName) && !FRAME_ELEMENTS.has(el.localName));
|
|
483
|
+
const frame = visual
|
|
484
|
+
? all.find((el) => FRAME_ELEMENTS.has(el.localName) && el.contains(visual))
|
|
485
|
+
: undefined;
|
|
486
|
+
return { visual, frame };
|
|
487
|
+
}
|
|
488
|
+
/** Writes the offsets of framed slots onto their frames, and removes them when a slot has none. */
|
|
489
|
+
applyFrameOffsets() {
|
|
490
|
+
this.frames.forEach((frame, slot) => {
|
|
491
|
+
const offset = this.offsets[slot];
|
|
492
|
+
Object.keys(FRAME_OFFSET_PROPERTIES).forEach((side) => {
|
|
493
|
+
const value = offset === null || offset === void 0 ? void 0 : offset[side];
|
|
494
|
+
if (value)
|
|
495
|
+
frame.style.setProperty(FRAME_OFFSET_PROPERTIES[side], `${value}px`);
|
|
496
|
+
else
|
|
497
|
+
frame.style.removeProperty(FRAME_OFFSET_PROPERTIES[side]);
|
|
498
|
+
});
|
|
499
|
+
});
|
|
472
500
|
}
|
|
473
501
|
async align() {
|
|
474
502
|
var _a;
|
|
@@ -477,7 +505,8 @@ const Grid = class {
|
|
|
477
505
|
return;
|
|
478
506
|
const { rows, columns } = this.gridConfig;
|
|
479
507
|
const slots = rows.flatMap((row, rowIndex) => columns.map((column, columnIndex) => ({ slot: getSlotName(row, column), row: rowIndex, column: columnIndex })));
|
|
480
|
-
const
|
|
508
|
+
const contents = slots.map(({ slot }) => this.contentIn(slot));
|
|
509
|
+
const visuals = contents.map((content) => content.visual);
|
|
481
510
|
await Promise.all(visuals.map((visual) => { var _a; return (_a = visual === null || visual === void 0 ? void 0 : visual.componentOnReady) === null || _a === void 0 ? void 0 : _a.call(visual); }));
|
|
482
511
|
if (run !== this.run)
|
|
483
512
|
return;
|
|
@@ -492,13 +521,18 @@ const Grid = class {
|
|
|
492
521
|
var _a;
|
|
493
522
|
wrappers.set((_a = el.getAttribute("data-slot")) !== null && _a !== void 0 ? _a : "", el);
|
|
494
523
|
});
|
|
524
|
+
this.frames = new Map();
|
|
525
|
+
contents.forEach(({ frame }, index) => frame && this.frames.set(slots[index].slot, frame));
|
|
495
526
|
const cells = slots.map(({ slot, row, column }, index) => {
|
|
496
527
|
const visual = visuals[index];
|
|
497
528
|
const baseline = baselines[index];
|
|
498
529
|
// what is drawn now, not what is in the state: a render can still be pending
|
|
499
|
-
const
|
|
500
|
-
const
|
|
501
|
-
const
|
|
530
|
+
const cardFrame = contents[index].frame;
|
|
531
|
+
const holder = cardFrame !== null && cardFrame !== void 0 ? cardFrame : wrappers.get(slot);
|
|
532
|
+
const applied = (property) => parseFloat((holder === null || holder === void 0 ? void 0 : holder.style.getPropertyValue(property)) || "0") || 0;
|
|
533
|
+
const cell = cardFrame
|
|
534
|
+
? { slot, row, column, top: applied(FRAME_OFFSET_PROPERTIES.top), left: applied(FRAME_OFFSET_PROPERTIES.left) }
|
|
535
|
+
: { slot, row, column, top: applied("padding-top"), left: applied("margin-left") };
|
|
502
536
|
if (visual) {
|
|
503
537
|
const box = frame.toLocal(visual.getBoundingClientRect());
|
|
504
538
|
if (baseline.y !== undefined)
|
|
@@ -521,6 +555,7 @@ const Grid = class {
|
|
|
521
555
|
}
|
|
522
556
|
this.adjustments++;
|
|
523
557
|
this.offsets = next;
|
|
558
|
+
this.applyFrameOffsets();
|
|
524
559
|
// check once more after the new offsets are drawn; the status stays held until then
|
|
525
560
|
this.schedule();
|
|
526
561
|
}
|
|
@@ -765,6 +800,7 @@ const Grid = class {
|
|
|
765
800
|
* moves it onto the baseline. Without alignment the wrapper is a plain block.
|
|
766
801
|
*/
|
|
767
802
|
renderCellContent(slotName, style) {
|
|
803
|
+
var _a;
|
|
768
804
|
const text = this.captions[slotName];
|
|
769
805
|
const caption = text !== undefined ? (h("div", { class: "grid-caption", style: {
|
|
770
806
|
"font-size": `${style.captionFontSize}px`,
|
|
@@ -791,7 +827,8 @@ const Grid = class {
|
|
|
791
827
|
else if (this.resolvedVertical === "bottom") {
|
|
792
828
|
wrapper["margin-top"] = "auto";
|
|
793
829
|
}
|
|
794
|
-
|
|
830
|
+
// a frame moves its own content; the wrapper only moves a component without a frame
|
|
831
|
+
const offset = this.frames.has(slotName) ? { bottom: (_a = this.offsets[slotName]) === null || _a === void 0 ? void 0 : _a.bottom } : this.offsets[slotName];
|
|
795
832
|
if (offset === null || offset === void 0 ? void 0 : offset.bottom)
|
|
796
833
|
wrapper["margin-top"] = "auto";
|
|
797
834
|
if (offset === null || offset === void 0 ? void 0 : offset.top)
|
|
@@ -822,7 +859,7 @@ const Grid = class {
|
|
|
822
859
|
// would only be as wide as their content, and charts measure that width.
|
|
823
860
|
const fill = this.resolvedWidth === "equal";
|
|
824
861
|
const gridContainerStyle = Object.assign(Object.assign({ display: fill ? "grid" : "inline-grid" }, (fill ? { width: "100%" } : {})), { "grid-template-columns": this.getGridTemplateColumns(), "grid-template-rows": this.getGridTemplateRows(), gap: this.cellGap });
|
|
825
|
-
return (h(Host, { key: '
|
|
862
|
+
return (h(Host, { key: '643b4d675bac89c542618e7d6ec5f2c0ef8d6d6c', style: fill ? Object.assign(Object.assign({}, this.getFontStyles()), { display: "block" }) : this.getFontStyles() }, h("div", { key: '4bc671a6868b313c809f37aeb2f32ca30c7e9142', class: "grid-container", style: gridContainerStyle }, this.renderTitle(), this.renderColumnHeaders(), this.renderDataCells()), h("slot", { key: '5e66d95c65a0bad59d3816cf0009bb88fbe53f9c' })));
|
|
826
863
|
}
|
|
827
864
|
get element() { return getElement(this); }
|
|
828
865
|
static get watchers() { return {
|
|
@@ -17,6 +17,8 @@ export declare class Grid {
|
|
|
17
17
|
private captions;
|
|
18
18
|
/** Per slot: how far the baseline pass moved the content. */
|
|
19
19
|
private offsets;
|
|
20
|
+
/** Per slot: the frame around its component, from the last baseline pass. */
|
|
21
|
+
private frames;
|
|
20
22
|
private readonly errors;
|
|
21
23
|
private readonly componentStyle;
|
|
22
24
|
private readonly holdStatus;
|
|
@@ -125,8 +127,10 @@ export declare class Grid {
|
|
|
125
127
|
* until then, so a printer does not print a half-aligned grid.
|
|
126
128
|
*/
|
|
127
129
|
private readonly schedule;
|
|
128
|
-
/** The first visual component in a slot, or the slotted element itself. */
|
|
129
|
-
private
|
|
130
|
+
/** The first visual component in a slot, or the slotted element itself, and the frame around it. */
|
|
131
|
+
private contentIn;
|
|
132
|
+
/** Writes the offsets of framed slots onto their frames, and removes them when a slot has none. */
|
|
133
|
+
private applyFrameOffsets;
|
|
130
134
|
private align;
|
|
131
135
|
/** A chart redraws inside its shadow roots, where the host and a mutation observer on it see nothing. */
|
|
132
136
|
private observe;
|