@bino-bi/bn-template-engine 1.0.0-alpha.11 → 1.0.0-alpha.13

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.
Files changed (127) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-3c827826.entry.js +1 -0
  3. package/dist/bn-template-engine/p-46699464.entry.js +1 -0
  4. package/dist/bn-template-engine/{p-e783733e.entry.js → p-52097456.entry.js} +1 -1
  5. package/dist/bn-template-engine/p-637e3b8f.entry.js +1 -0
  6. package/dist/bn-template-engine/{p-c2cbb8ea.entry.js → p-67eae33e.entry.js} +1 -1
  7. package/dist/bn-template-engine/{p-fdb3e99a.entry.js → p-82023539.entry.js} +1 -1
  8. package/dist/bn-template-engine/p-BVFHvEXF.js +1 -0
  9. package/dist/bn-template-engine/p-BjBz5cSL.js +1 -0
  10. package/dist/bn-template-engine/p-CQnZV3JG.js +1 -0
  11. package/dist/bn-template-engine/p-DHheVOfP.js +1 -0
  12. package/dist/bn-template-engine/{p-e94b4e31.entry.js → p-ab3ea8cf.entry.js} +1 -1
  13. package/dist/cjs/bn-asset_21.cjs.entry.js +576 -730
  14. package/dist/cjs/bn-grid.cjs.entry.js +2 -2
  15. package/dist/cjs/bn-image.cjs.entry.js +2 -2
  16. package/dist/cjs/bn-internationalization.cjs.entry.js +2 -2
  17. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  18. package/dist/cjs/bn-text.cjs.entry.js +3 -3
  19. package/dist/cjs/bn-tree.cjs.entry.js +2 -2
  20. package/dist/cjs/context-protocol-Op7uUwN3.js +9214 -0
  21. package/dist/cjs/editor-companion.cjs.entry.js +13 -6
  22. package/dist/cjs/loader.cjs.js +1 -1
  23. package/dist/cjs/{scaling-eyzCrFB8.js → scaling-57N4Cxb_.js} +44 -40
  24. package/dist/cjs/{withBodyObserver-D7BKWN2N.js → withBodyObserver-BKUE_ypL.js} +12 -7
  25. package/dist/cjs/withStyled-C2kmGAK3.js +1405 -0
  26. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +11 -6
  27. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +50 -22
  28. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +51 -48
  29. package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +5 -4
  30. package/dist/collection/components/bn-chart-time/bn-chart-time.js +11 -6
  31. package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +47 -22
  32. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +76 -60
  33. package/dist/collection/components/bn-chart-time/utils/model/TimeChartComponentConfig.js +5 -4
  34. package/dist/collection/components/bn-chart-time/utils/model/TimeChartDataRow.js +2 -0
  35. package/dist/collection/components/bn-dataset/bn-dataset.js +214 -23
  36. package/dist/collection/components/bn-datasource/bn-datasource.js +27 -9
  37. package/dist/collection/components/bn-table/bn-table.js +13 -5
  38. package/dist/collection/components/bn-table/ibcs-table.js +52 -25
  39. package/dist/collection/components/bn-table/utils/Table.js +27 -21
  40. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +2 -2
  41. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +52 -43
  42. package/dist/collection/components/bn-table/utils/helper/QueryGroup.js +4 -9
  43. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +5 -4
  44. package/dist/collection/components/editor-companion/editor-companion.js +12 -5
  45. package/dist/collection/context/scopedDb.js +113 -0
  46. package/dist/collection/stores/createScopedStores.js +3 -4
  47. package/dist/collection/utils/dataAnalyzer.js +14 -8
  48. package/dist/collection/utils/withBodyObserver.js +12 -7
  49. package/dist/collection/utils/withDataset.js +43 -39
  50. package/dist/collection/utils/withDatasource.js +28 -18
  51. package/dist/components/DataFormatDigits.js +1 -1
  52. package/dist/components/DateStringFactory.js +1 -1
  53. package/dist/components/Order.js +1 -1
  54. package/dist/components/SVGVariancesStyleGroup.js +1 -1
  55. package/dist/components/bn-chart-structure.js +1 -1
  56. package/dist/components/bn-chart-time.js +1 -1
  57. package/dist/components/bn-dataset.js +1 -1
  58. package/dist/components/bn-datasource.js +1 -1
  59. package/dist/components/bn-table.js +1 -1
  60. package/dist/components/bn-title2.js +1 -1
  61. package/dist/components/context-protocol.js +1 -1
  62. package/dist/components/editor-companion.js +1 -1
  63. package/dist/components/ibcs-chart-structure2.js +1 -1
  64. package/dist/components/ibcs-chart-time2.js +1 -1
  65. package/dist/components/ibcs-table2.js +1 -1
  66. package/dist/components/ibcs-title2.js +1 -1
  67. package/dist/components/ibcsRuleSet.js +1 -1
  68. package/dist/components/luxon.js +1 -0
  69. package/dist/components/scaling.js +1 -1
  70. package/dist/components/withBodyObserver.js +1 -1
  71. package/dist/esm/bn-asset_21.entry.js +571 -725
  72. package/dist/esm/bn-grid.entry.js +2 -2
  73. package/dist/esm/bn-image.entry.js +2 -2
  74. package/dist/esm/bn-internationalization.entry.js +2 -2
  75. package/dist/esm/bn-template-engine.js +1 -1
  76. package/dist/esm/bn-text.entry.js +3 -3
  77. package/dist/esm/bn-tree.entry.js +2 -2
  78. package/dist/esm/context-protocol-BDhzNbeD.js +9204 -0
  79. package/dist/esm/editor-companion.entry.js +13 -6
  80. package/dist/esm/loader.js +1 -1
  81. package/dist/esm/{scaling-BzbiBnuN.js → scaling-La1Ow72h.js} +44 -40
  82. package/dist/esm/{withBodyObserver-AFk2wwHT.js → withBodyObserver-IokS6fHD.js} +12 -7
  83. package/dist/esm/withStyled-Bl9cSoRW.js +1372 -0
  84. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +4 -2
  85. package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +7 -3
  86. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +11 -12
  87. package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +5 -3
  88. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +4 -2
  89. package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +7 -3
  90. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +11 -12
  91. package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +5 -3
  92. package/dist/types/components/bn-dataset/bn-dataset.d.ts +39 -5
  93. package/dist/types/components/bn-datasource/bn-datasource.d.ts +5 -0
  94. package/dist/types/components/bn-table/bn-table.d.ts +4 -2
  95. package/dist/types/components/bn-table/ibcs-table.d.ts +11 -3
  96. package/dist/types/components/bn-table/utils/Table.d.ts +8 -6
  97. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +2 -2
  98. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +7 -3
  99. package/dist/types/components/bn-table/utils/helper/QueryGroup.d.ts +4 -5
  100. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +5 -3
  101. package/dist/types/components/editor-companion/editor-companion.d.ts +2 -0
  102. package/dist/types/components.d.ts +105 -46
  103. package/dist/types/context/context-protocol.d.ts +4 -3
  104. package/dist/types/context/scopedDb.d.ts +37 -0
  105. package/dist/types/stores/createScopedStores.d.ts +1 -2
  106. package/dist/types/utils/DateStringFactory.d.ts +1 -1
  107. package/dist/types/utils/dataAnalyzer.d.ts +2 -1
  108. package/dist/types/utils/withDataset.d.ts +6 -2
  109. package/dist/types/utils/withDatasource.d.ts +3 -3
  110. package/package.json +2 -1
  111. package/dist/bn-template-engine/p-095f74d7.entry.js +0 -1
  112. package/dist/bn-template-engine/p-14318b0d.entry.js +0 -1
  113. package/dist/bn-template-engine/p-2133e02b.entry.js +0 -1
  114. package/dist/bn-template-engine/p-7HSTE79g.js +0 -1
  115. package/dist/bn-template-engine/p-Bi2wx-el.js +0 -1
  116. package/dist/bn-template-engine/p-CWiZks2h.js +0 -1
  117. package/dist/bn-template-engine/p-DSXNgKLa.js +0 -1
  118. package/dist/cjs/context-protocol-B_jipZpJ.js +0 -665
  119. package/dist/cjs/withStyled-V7xz_x1c.js +0 -9535
  120. package/dist/collection/stores/datasets.js +0 -14
  121. package/dist/collection/stores/datasources.js +0 -14
  122. package/dist/components/_commonjsHelpers.js +0 -1
  123. package/dist/components/alasql.min.js +0 -1
  124. package/dist/esm/context-protocol-D-o_UZ33.js +0 -658
  125. package/dist/esm/withStyled-5RqF8WBL.js +0 -9501
  126. package/dist/types/stores/datasets.d.ts +0 -14
  127. package/dist/types/stores/datasources.d.ts +0 -14
@@ -1,658 +0,0 @@
1
- import { S as StencilCore } from './index-B_d-jp99.js';
2
-
3
- const appendToMap = (map, propName, value) => {
4
- let refs = map.get(propName);
5
- if (!refs) {
6
- refs = [];
7
- map.set(propName, refs);
8
- }
9
- if (!refs.some((ref) => ref.deref() === value)) {
10
- refs.push(new WeakRef(value));
11
- }
12
- };
13
- const debounce = (fn, ms) => {
14
- let timeoutId;
15
- return (...args) => {
16
- if (timeoutId) {
17
- clearTimeout(timeoutId);
18
- }
19
- timeoutId = setTimeout(() => {
20
- timeoutId = 0;
21
- fn(...args);
22
- }, ms);
23
- };
24
- };
25
-
26
- /**
27
- * Check if a possible element isConnected.
28
- * The property might not be there, so we check for it.
29
- *
30
- * We want it to return true if isConnected is not a property,
31
- * otherwise we would remove these elements and would not update.
32
- *
33
- * Better leak in Edge than to be useless.
34
- */
35
- const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
36
- const cleanupElements = debounce((map) => {
37
- for (let key of map.keys()) {
38
- const refs = map.get(key).filter((ref) => {
39
- const elm = ref.deref();
40
- return elm && isConnected(elm);
41
- });
42
- map.set(key, refs);
43
- }
44
- }, 2_000);
45
- const core = StencilCore;
46
- const forceUpdate = core.forceUpdate;
47
- const getRenderingRef = core.getRenderingRef;
48
- const stencilSubscription = () => {
49
- if (typeof getRenderingRef !== 'function' || typeof forceUpdate !== 'function') {
50
- // If we are not in a stencil project, we do nothing.
51
- // This function is not really exported by @stencil/core.
52
- return {};
53
- }
54
- const ensureForceUpdate = forceUpdate;
55
- const ensureGetRenderingRef = getRenderingRef;
56
- const elmsToUpdate = new Map();
57
- return {
58
- dispose: () => elmsToUpdate.clear(),
59
- get: (propName) => {
60
- const elm = ensureGetRenderingRef();
61
- if (elm) {
62
- appendToMap(elmsToUpdate, propName, elm);
63
- }
64
- },
65
- set: (propName) => {
66
- const refs = elmsToUpdate.get(propName);
67
- if (refs) {
68
- const nextRefs = refs.filter((ref) => {
69
- const elm = ref.deref();
70
- if (!elm)
71
- return false;
72
- return ensureForceUpdate(elm);
73
- });
74
- elmsToUpdate.set(propName, nextRefs);
75
- }
76
- cleanupElements(elmsToUpdate);
77
- },
78
- reset: () => {
79
- elmsToUpdate.forEach((refs) => {
80
- refs.forEach((ref) => {
81
- const elm = ref.deref();
82
- if (elm)
83
- ensureForceUpdate(elm);
84
- });
85
- });
86
- cleanupElements(elmsToUpdate);
87
- },
88
- };
89
- };
90
-
91
- const unwrap = (val) => (typeof val === 'function' ? val() : val);
92
- const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
93
- const resolveDefaultState = () => (unwrap(defaultState) ?? {});
94
- const initialState = resolveDefaultState();
95
- let states = new Map(Object.entries(initialState));
96
- const proxyAvailable = typeof Proxy !== 'undefined';
97
- const plainState = proxyAvailable ? null : {};
98
- const handlers = {
99
- dispose: [],
100
- get: [],
101
- set: [],
102
- reset: [],
103
- };
104
- // Track onChange listeners to enable removeListener functionality
105
- const changeListeners = new Map();
106
- const reset = () => {
107
- // When resetting the state, the default state may be a function - unwrap it to invoke it.
108
- // otherwise, the state won't be properly reset
109
- states = new Map(Object.entries(resolveDefaultState()));
110
- if (!proxyAvailable) {
111
- syncPlainStateKeys();
112
- }
113
- handlers.reset.forEach((cb) => cb());
114
- };
115
- const dispose = () => {
116
- // Call first dispose as resetting the state would
117
- // cause less updates ;)
118
- handlers.dispose.forEach((cb) => cb());
119
- reset();
120
- };
121
- const get = (propName) => {
122
- handlers.get.forEach((cb) => cb(propName));
123
- return states.get(propName);
124
- };
125
- const set = (propName, value) => {
126
- const oldValue = states.get(propName);
127
- if (shouldUpdate(value, oldValue, propName)) {
128
- states.set(propName, value);
129
- if (!proxyAvailable) {
130
- ensurePlainProperty(propName);
131
- }
132
- handlers.set.forEach((cb) => cb(propName, value, oldValue));
133
- }
134
- };
135
- const state = (proxyAvailable
136
- ? new Proxy(initialState, {
137
- get(_, propName) {
138
- return get(propName);
139
- },
140
- ownKeys(_) {
141
- return Array.from(states.keys());
142
- },
143
- getOwnPropertyDescriptor() {
144
- return {
145
- enumerable: true,
146
- configurable: true,
147
- };
148
- },
149
- has(_, propName) {
150
- return states.has(propName);
151
- },
152
- set(_, propName, value) {
153
- set(propName, value);
154
- return true;
155
- },
156
- })
157
- : (() => {
158
- syncPlainStateKeys();
159
- return plainState;
160
- })());
161
- const on = (eventName, callback) => {
162
- handlers[eventName].push(callback);
163
- return () => {
164
- removeFromArray(handlers[eventName], callback);
165
- };
166
- };
167
- const onChange = (propName, cb) => {
168
- const setHandler = (key, newValue) => {
169
- if (key === propName) {
170
- cb(newValue);
171
- }
172
- };
173
- const resetHandler = () => {
174
- const snapshot = resolveDefaultState();
175
- cb(snapshot[propName]);
176
- };
177
- // Register the handlers
178
- const unSet = on('set', setHandler);
179
- const unReset = on('reset', resetHandler);
180
- // Track the relationship between the user callback and internal handlers
181
- changeListeners.set(cb, { setHandler, resetHandler, propName });
182
- return () => {
183
- unSet();
184
- unReset();
185
- changeListeners.delete(cb);
186
- };
187
- };
188
- const use = (...subscriptions) => {
189
- const unsubs = subscriptions.reduce((unsubs, subscription) => {
190
- if (subscription.set) {
191
- unsubs.push(on('set', subscription.set));
192
- }
193
- if (subscription.get) {
194
- unsubs.push(on('get', subscription.get));
195
- }
196
- if (subscription.reset) {
197
- unsubs.push(on('reset', subscription.reset));
198
- }
199
- if (subscription.dispose) {
200
- unsubs.push(on('dispose', subscription.dispose));
201
- }
202
- return unsubs;
203
- }, []);
204
- return () => unsubs.forEach((unsub) => unsub());
205
- };
206
- const forceUpdate = (key) => {
207
- const oldValue = states.get(key);
208
- handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
209
- };
210
- const removeListener = (propName, listener) => {
211
- const listenerInfo = changeListeners.get(listener);
212
- if (listenerInfo && listenerInfo.propName === propName) {
213
- // Remove the specific handlers that were created for this listener
214
- removeFromArray(handlers.set, listenerInfo.setHandler);
215
- removeFromArray(handlers.reset, listenerInfo.resetHandler);
216
- changeListeners.delete(listener);
217
- }
218
- };
219
- function ensurePlainProperty(key) {
220
- if (proxyAvailable || !plainState) {
221
- return;
222
- }
223
- if (Object.prototype.hasOwnProperty.call(plainState, key)) {
224
- return;
225
- }
226
- Object.defineProperty(plainState, key, {
227
- configurable: true,
228
- enumerable: true,
229
- get() {
230
- return get(key);
231
- },
232
- set(value) {
233
- set(key, value);
234
- },
235
- });
236
- }
237
- function syncPlainStateKeys() {
238
- if (proxyAvailable || !plainState) {
239
- return;
240
- }
241
- const knownKeys = new Set(states.keys());
242
- for (const key of Object.keys(plainState)) {
243
- if (!knownKeys.has(key)) {
244
- delete plainState[key];
245
- }
246
- }
247
- for (const key of knownKeys) {
248
- ensurePlainProperty(key);
249
- }
250
- }
251
- return {
252
- state,
253
- get,
254
- set,
255
- on,
256
- onChange,
257
- use,
258
- dispose,
259
- reset,
260
- forceUpdate,
261
- removeListener,
262
- };
263
- };
264
- const removeFromArray = (array, item) => {
265
- const index = array.indexOf(item);
266
- if (index >= 0) {
267
- array[index] = array[array.length - 1];
268
- array.length--;
269
- }
270
- };
271
-
272
- const createStore = (defaultState, shouldUpdate) => {
273
- const map = createObservableMap(defaultState, shouldUpdate);
274
- map.use(stencilSubscription());
275
- return map;
276
- };
277
-
278
- const SYSTEM_STYLE_DEFAULTS = {
279
- global: {
280
- fontFamily: "'Noto Sans', sans-serif",
281
- fontSizePx: 13.3333,
282
- fontColor: "#000000",
283
- fontBackgroundColor: "#ffffff",
284
- },
285
- "bn-text": {},
286
- "bn-chart-time": {
287
- scaleFactors: {
288
- scenarioOffset: 0.3,
289
- scenarioLabelToColumn: 0.3,
290
- labelToColumn: 0.3,
291
- labelToAxis: 0.3,
292
- needleWidth: 0.3,
293
- needleHeadWidth: 0.6,
294
- columnWidth: 2.0,
295
- varianceAxisLineWidth: 0.3,
296
- axisLineWidth: 0.1,
297
- auxiliaryLineWidth: 0.1,
298
- scenarioLineWidth: 0.2,
299
- markerWidth: 0.7,
300
- markerOffset: 0.0,
301
- categoryWidth: 3.0,
302
- axisTickLength: 0.3,
303
- },
304
- axisStyles: {
305
- ac: { stroke: "#121212", fill: "#121212", width: 0.1 },
306
- fc: { stroke: "#121212", fill: "#ffffff", width: 0.1, dasharray: "10 5 5 5" },
307
- pp: { stroke: "#606060", fill: "#606060", width: 0.1 },
308
- pl: { stroke: "#121212", fill: "#ffffff", width: 0.1 },
309
- },
310
- barStyles: {
311
- ac: { stroke: "#404040", fill: "#404040", width: 0.1 },
312
- fc: { stroke: "#404040", fill: "#ffffff", width: 0.5, fillpattern: "fc" },
313
- pp: { stroke: "#A6A6A6", fill: "#A6A6A6", width: 0.1 },
314
- pl: { stroke: "#404040", fill: "#ffffff", width: 0.1 },
315
- },
316
- varianceStyles: {
317
- pos: { stroke: "#008f96", fill: "#008f96", width: 0.1 },
318
- neg: { stroke: "#ff0000", fill: "#ff0000", width: 0.1 },
319
- neu: { stroke: "#808080", fill: "#808080", width: 0.1 },
320
- },
321
- stackColors: ["#000000", "#c0c0c0", "#808080"],
322
- padding: {
323
- top: 10,
324
- left: 10,
325
- right: 10,
326
- bottom: 10,
327
- },
328
- },
329
- "bn-chart-structure": {
330
- scaleFactors: {
331
- scenarioOffset: 0.3,
332
- scenarioLabelToBar: 0.1,
333
- labelToBar: 0.3,
334
- labelToAxis: 0.3,
335
- needleWidth: 0.3,
336
- needleHeadWidth: 0.6,
337
- barWidth: 1.2,
338
- varianceAxisLineWidth: 0.3,
339
- axisLineWidth: 0.1,
340
- auxiliaryLineWidth: 0.1,
341
- scenarioLineWidth: 0.2,
342
- markerWidth: 0.7,
343
- markerOffset: 0.0,
344
- categoryWidth: 1.9,
345
- axisTickLength: 0.3,
346
- },
347
- axisStyles: {
348
- ac: { stroke: "#121212", fill: "#121212", width: 0.1 },
349
- fc: { stroke: "#121212", fill: "#ffffff", width: 0.1, dasharray: "10 5 5 5" },
350
- pp: { stroke: "#606060", fill: "#606060", width: 0.1 },
351
- pl: { stroke: "#121212", fill: "#ffffff", width: 0.1 },
352
- },
353
- barStyles: {
354
- ac: { stroke: "#404040", fill: "#404040", width: 0.1 },
355
- fc: { stroke: "#404040", fill: "#ffffff", width: 0.5, fillpattern: "fc" },
356
- pp: { stroke: "#A6A6A6", fill: "#A6A6A6", width: 0.1 },
357
- pl: { stroke: "#404040", fill: "#ffffff", width: 0.1 },
358
- },
359
- varianceStyles: {
360
- pos: { stroke: "#008f96", fill: "#008f96", width: 0.1 },
361
- neg: { stroke: "#ff0000", fill: "#ff0000", width: 0.1 },
362
- neu: { stroke: "#808080", fill: "#808080", width: 0.1 },
363
- },
364
- stackColors: ["#000000", "#c0c0c0", "#808080"],
365
- padding: {
366
- top: 10,
367
- left: 10,
368
- right: 10,
369
- bottom: 10,
370
- },
371
- },
372
- "bn-tree": {
373
- edgeColor: "#404040",
374
- edgeWidth: 1,
375
- operatorCircleRadius: 10,
376
- operatorFontSizeScale: 0.9,
377
- operatorColor: "#404040",
378
- },
379
- "bn-grid": {
380
- headerBackground: "transparent",
381
- borderColor: "#A6A6A6",
382
- borderWidth: 1,
383
- cellPadding: 4,
384
- },
385
- };
386
-
387
- /**
388
- * Recursively flattens a nested object into a single-depth object with
389
- * dot-separated keys.
390
- *
391
- * Used by the i18n store to convert hierarchical locale files into a flat
392
- * lookup map, e.g. `{ a: { b: "hello" } }` becomes `{ "a.b": "hello" }`.
393
- *
394
- * @param ob - The nested object to flatten
395
- * @param prefix - Internal accumulator for the current key path (omit on initial call)
396
- * @param result - Internal accumulator for the output object (omit on initial call)
397
- * @returns A flat object with dot-separated keys mapping to leaf values
398
- */
399
- function flattenObject(ob, prefix = undefined, result = null) {
400
- result = result || {};
401
- prefix = prefix ? prefix + "." : "";
402
- for (const i in ob) {
403
- if (Object.prototype.hasOwnProperty.call(ob, i)) {
404
- if (typeof ob[i] === "object" && ob[i] !== null) {
405
- // Recursion on deeper objects
406
- flattenObject(ob[i], prefix + i, result);
407
- }
408
- else {
409
- result[prefix + i] = ob[i];
410
- }
411
- }
412
- }
413
- return result;
414
- }
415
-
416
- /**
417
- * Reactive store for internationalized labels and symbols.
418
- *
419
- * Organized by namespace (`_system` ships built-in `de`/`en` bundles). Each
420
- * bundle is a flat key-value map produced by `flattenObject()` from a nested
421
- * `{ namespace: { key: label } }` structure, yielding keys like `"bn-table.SUM_TOTAL"`.
422
- *
423
- * **Token pattern**: Variance symbols use `{%}` as a placeholder for the
424
- * scenario abbreviation. For example, `"Δ{%}"` becomes `"ΔPY"` when the
425
- * comparison scenario is "PY". The `{%}` replacement is performed at render
426
- * time by the `withTranslation` mixin.
427
- *
428
- * @module stores/internationalization
429
- */
430
- /**
431
- * Keys that are treated as global (not namespace-scoped) across all components.
432
- * Includes scenario abbreviations (ac1..pl4), sort-order arrows, and IBCS
433
- * variance symbols with the `{%}` token for scenario substitution.
434
- */
435
- const globalLabelKeys = [
436
- "ORDER_asc",
437
- "ORDER_desc",
438
- "ac1",
439
- "pp1",
440
- "fc1",
441
- "pl1",
442
- "ac2",
443
- "pp2",
444
- "fc2",
445
- "pl2",
446
- "ac3",
447
- "pp3",
448
- "fc3",
449
- "pl3",
450
- "ac4",
451
- "pp4",
452
- "fc4",
453
- "pl4",
454
- "ibcssymbol_delta_ac",
455
- "ibcssymbol_delta_generic",
456
- "ibcssymbol_delta_ac_relative",
457
- "ibcssymbol_delta_generic_relative",
458
- ];
459
- const de = flattenObject({
460
- global: {
461
- ac1: "AC",
462
- pp1: "PY",
463
- fc1: "FC",
464
- pl1: "PL",
465
- ac2: "AC2",
466
- pp2: "PY2",
467
- fc2: "FC2",
468
- pl2: "PL2",
469
- ac3: "AC3",
470
- pp3: "PY3",
471
- fc3: "FC3",
472
- pl3: "PL3",
473
- ac4: "AC4",
474
- pp4: "PY4",
475
- fc4: "FC4",
476
- pl4: "PL4",
477
- ORDER_asc: "↑",
478
- ORDER_desc: "↓",
479
- ibcssymbol_delta_ac: "Δ{%}",
480
- ibcssymbol_delta_generic: "Δ({%})",
481
- ibcssymbol_delta_ac_relative: "Δ{%}%",
482
- ibcssymbol_delta_generic_relative: "Δ({%})%",
483
- },
484
- "bn-title": {
485
- SEPERATOR_WS: ", ",
486
- CONNECTOR_WS: " und ",
487
- in: "in",
488
- },
489
- "bn-chart": {},
490
- "bn-table": {
491
- in: "in",
492
- category: " ",
493
- operation: " ",
494
- there_of: "davon",
495
- part_of: "in % von",
496
- SUM_TOTAL: "❖",
497
- REST: "REST",
498
- },
499
- });
500
- const en = flattenObject({
501
- global: {
502
- ac1: "AC",
503
- pp1: "PY",
504
- fc1: "FC",
505
- pl1: "PL",
506
- ac2: "AC2",
507
- pp2: "PY2",
508
- fc2: "FC2",
509
- pl2: "PL2",
510
- ac3: "AC3",
511
- pp3: "PY3",
512
- fc3: "FC3",
513
- pl3: "PL3",
514
- ac4: "AC4",
515
- pp4: "PY4",
516
- fc4: "FC4",
517
- pl4: "PL4",
518
- ORDER_asc: "↑",
519
- ORDER_desc: "↓",
520
- ibcssymbol_delta_ac: "Δ{%}",
521
- ibcssymbol_delta_generic: "Δ({%})",
522
- ibcssymbol_delta_ac_relative: "Δ{%}%",
523
- ibcssymbol_delta_generic_relative: "Δ({%})%",
524
- },
525
- "bn-title": {
526
- SEPERATOR_WS: ", ",
527
- CONNECTOR_WS: " and ",
528
- in: "in",
529
- },
530
- "bn-chart": {},
531
- "bn-table": {
532
- category: " ",
533
- operation: " ",
534
- there_of: "there of",
535
- part_of: "in % of",
536
- SUM_TOTAL: "❖",
537
- REST: "REST",
538
- },
539
- });
540
- const BN_INTERNATIONALIZATION_KEYS = Object.keys(de || {});
541
- const SYSTEM_I18N_DEFAULTS = { _system: { de, en } };
542
-
543
- /**
544
- * Factory that creates a fresh set of all 8 `@stencil/store` instances.
545
- *
546
- * Called once per `<bn-context>` element so that each context owns isolated
547
- * reactive state. The returned object satisfies the {@link ScopedStores} interface.
548
- *
549
- * @module stores/createScopedStores
550
- */
551
- function createScopedStores() {
552
- const datasources = createStore({});
553
- const datasets = createStore({});
554
- const datasetsMeta = createStore({});
555
- const componentStyles = createStore({
556
- _system: SYSTEM_STYLE_DEFAULTS,
557
- });
558
- const internationalization = createStore(Object.assign({}, SYSTEM_I18N_DEFAULTS));
559
- const assets = createStore({});
560
- const context = createStore({ locale: "en" });
561
- const scalingGroups = createStore({});
562
- return {
563
- datasources,
564
- datasets,
565
- datasetsMeta,
566
- componentStyles,
567
- internationalization,
568
- assets,
569
- context,
570
- scalingGroups,
571
- };
572
- }
573
-
574
- /**
575
- * Scoped store resolution for `<bn-context>`.
576
- *
577
- * Each `<bn-context>` element owns its own set of `@stencil/store` instances.
578
- * Because Stencil does NOT guarantee parent-before-child initialization order,
579
- * stores are created lazily: the first component that calls `getStores()` walks
580
- * the DOM to find the nearest `<bn-context>` element and creates (or retrieves)
581
- * the stores for it. When `<bn-context>` itself initializes, it picks up the
582
- * already-created stores from the registry.
583
- *
584
- * @module context/context-protocol
585
- */
586
- /**
587
- * Module-level registry mapping `<bn-context>` DOM elements to their stores.
588
- * Stores are created lazily by `getOrCreateStores()` — whichever component
589
- * initializes first triggers creation for its ancestor `<bn-context>`.
590
- */
591
- const contextRegistry = new WeakMap();
592
- /**
593
- * Returns the stores for a `<bn-context>` element, creating them if needed.
594
- * Called both by descendant components (via `getStores()`) and by the
595
- * `<bn-context>` component itself during its initialization.
596
- */
597
- function getOrCreateStores(contextElement) {
598
- let stores = contextRegistry.get(contextElement);
599
- if (!stores) {
600
- stores = createScopedStores();
601
- contextRegistry.set(contextElement, stores);
602
- }
603
- return stores;
604
- }
605
- const storesCache = new WeakMap();
606
- /**
607
- * Walks up the DOM tree (crossing shadow boundaries) to find the nearest
608
- * `<bn-context>` ancestor element.
609
- */
610
- function findContextElement(element) {
611
- var _a;
612
- let current = element.parentNode;
613
- while (current) {
614
- if (current instanceof HTMLElement && ((_a = current.nodeName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "bn-context") {
615
- return current;
616
- }
617
- if (current.parentNode) {
618
- current = current.parentNode;
619
- }
620
- else if (current instanceof ShadowRoot) {
621
- current = current.host;
622
- }
623
- else {
624
- break;
625
- }
626
- }
627
- return undefined;
628
- }
629
- /**
630
- * Resolves scoped stores from the nearest `<bn-context>` ancestor.
631
- *
632
- * Walks the DOM tree to find the nearest `<bn-context>` element, then
633
- * returns (or lazily creates) the stores for it. This works regardless
634
- * of Stencil component initialization order because it only depends on
635
- * the native DOM tree being in place.
636
- *
637
- * Results are cached per element in a WeakMap.
638
- *
639
- * @throws Error if no `<bn-context>` ancestor is found in the DOM
640
- */
641
- function getStores(element) {
642
- const cached = storesCache.get(element);
643
- if (cached)
644
- return cached;
645
- const contextEl = findContextElement(element);
646
- if (!contextEl) {
647
- throw new Error(`[bn] <${element.localName}> must be inside a <bn-context>. No ancestor <bn-context> found.`);
648
- }
649
- const stores = getOrCreateStores(contextEl);
650
- storesCache.set(element, stores);
651
- return stores;
652
- }
653
- /** Removes the cached stores entry for an element (call in `disconnectedCallback`). */
654
- function clearStoresCache(element) {
655
- storesCache.delete(element);
656
- }
657
-
658
- export { BN_INTERNATIONALIZATION_KEYS as B, globalLabelKeys as a, getOrCreateStores as b, clearStoresCache as c, flattenObject as f, getStores as g };