@bino-bi/bn-template-engine 1.0.0-alpha.7 → 1.0.0-alpha.8
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-0d41c5d8.entry.js +1 -0
- package/dist/bn-template-engine/p-67538176.entry.js +1 -0
- package/dist/bn-template-engine/p-825a07a8.entry.js +1 -0
- package/dist/bn-template-engine/p-916296a5.entry.js +1 -0
- package/dist/bn-template-engine/{p-1164c0b0.entry.js → p-96006b06.entry.js} +1 -1
- package/dist/bn-template-engine/p-B4JfKvVT.js +1 -0
- package/dist/bn-template-engine/{p-JNHhIe7t.js → p-B_d-jp99.js} +1 -1
- package/dist/bn-template-engine/p-Ck-NYtot.js +1 -0
- package/dist/bn-template-engine/p-CnDq0oVa.js +1 -0
- package/dist/bn-template-engine/p-DSXNgKLa.js +1 -0
- package/dist/bn-template-engine/p-bc711fb0.entry.js +1 -0
- package/dist/bn-template-engine/p-e6f646b1.entry.js +1 -0
- package/dist/bn-template-engine/p-f41d9242.entry.js +1 -0
- package/dist/bn-template-engine/{p-B0lsgVuN.js → p-gFbbuhtl.js} +1 -1
- package/dist/cjs/{SVGVariancesStyleGroup-BqAdPYtL.js → bn-asset_20.cjs.entry.js} +21948 -6938
- package/dist/cjs/bn-grid.cjs.entry.js +6 -9
- package/dist/cjs/bn-image.cjs.entry.js +6 -9
- package/dist/cjs/bn-internationalization.cjs.entry.js +5 -6
- package/dist/cjs/bn-template-engine.cjs.js +2 -2
- package/dist/cjs/bn-template.cjs.entry.js +3 -4
- package/dist/cjs/bn-text.cjs.entry.js +7 -10
- package/dist/cjs/bn-tree.cjs.entry.js +6 -9
- package/dist/cjs/{context-protocol-DRQWrwsA.js → context-protocol-ohYzcb5F.js} +1 -1
- package/dist/cjs/editor-companion.cjs.entry.js +2 -2
- package/dist/cjs/{index-Cjw0q6gP.js → index-CDKG4xmO.js} +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{scaling-BidPsO53.js → scaling-CIAClQR5.js} +3 -3
- package/dist/cjs/{withBodyObserver-C6gLgq_e.js → withBodyObserver-D7BKWN2N.js} +2 -2
- package/dist/cjs/{withHasError-B8gHkfV2.js → withHasError-Cl2gTQzA.js} +106 -2
- package/dist/cjs/{Order-BGx39pS5.js → withStyled-qd94SSb4.js} +648 -6
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +20 -4
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +20 -4
- package/dist/collection/components/bn-layout-card/bn-layout-card.js +12 -6
- package/dist/collection/components/bn-layout-page/bn-layout-page.js +12 -7
- package/dist/collection/components/bn-table/bn-table.js +25 -7
- package/dist/collection/components/bn-table/ibcs-table.js +68 -3
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/components/bn-layout-page.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/ibcs-table2.js +1 -1
- package/dist/esm/{SVGVariancesStyleGroup-DOIT-zvI.js → bn-asset_20.entry.js} +22048 -7042
- package/dist/esm/bn-grid.entry.js +4 -7
- package/dist/esm/bn-image.entry.js +4 -7
- package/dist/esm/bn-internationalization.entry.js +4 -5
- package/dist/esm/bn-template-engine.js +3 -3
- package/dist/esm/bn-template.entry.js +2 -3
- package/dist/esm/bn-text.entry.js +5 -8
- package/dist/esm/bn-tree.entry.js +4 -7
- package/dist/esm/{context-protocol-2peaD4y8.js → context-protocol-DdbSplvE.js} +2 -2
- package/dist/esm/editor-companion.entry.js +2 -2
- package/dist/esm/{index-JNHhIe7t.js → index-B_d-jp99.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{scaling-BOcjT8M0.js → scaling-DGKKkuL9.js} +4 -4
- package/dist/esm/{withBodyObserver-DczL5ia8.js → withBodyObserver-AFk2wwHT.js} +2 -2
- package/dist/esm/{withHasError-B3QX2emi.js → withHasError-DW_vMDUp.js} +106 -2
- package/dist/esm/{Order-sRO-lj7X.js → withStyled-BIkqU2w4.js} +616 -1
- package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +1 -0
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +1 -0
- package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +8 -2
- package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +8 -3
- package/dist/types/components/bn-table/ibcs-table.d.ts +19 -0
- package/dist/types/components.d.ts +8 -8
- package/package.json +1 -1
- package/dist/bn-template-engine/p-0fabe296.entry.js +0 -1
- package/dist/bn-template-engine/p-355abdf0.entry.js +0 -1
- package/dist/bn-template-engine/p-79KuA4Ox.js +0 -1
- package/dist/bn-template-engine/p-859cc06d.entry.js +0 -1
- package/dist/bn-template-engine/p-8acec99e.entry.js +0 -1
- package/dist/bn-template-engine/p-8f490c45.entry.js +0 -1
- package/dist/bn-template-engine/p-9721a5bb.entry.js +0 -1
- package/dist/bn-template-engine/p-9a564f8f.entry.js +0 -1
- package/dist/bn-template-engine/p-9cee22fa.entry.js +0 -1
- package/dist/bn-template-engine/p-B7p8beYH.js +0 -1
- package/dist/bn-template-engine/p-BDh7GfC5.js +0 -1
- package/dist/bn-template-engine/p-BoMtoHJB.js +0 -1
- package/dist/bn-template-engine/p-Bs8BqBsb.js +0 -1
- package/dist/bn-template-engine/p-CYjZRKdI.js +0 -1
- package/dist/bn-template-engine/p-DG-1MR_T.js +0 -1
- package/dist/bn-template-engine/p-Dnkv5rt8.js +0 -1
- package/dist/bn-template-engine/p-bdd2b243.entry.js +0 -1
- package/dist/bn-template-engine/p-f27995c9.entry.js +0 -1
- package/dist/bn-template-engine/p-f6ecb265.entry.js +0 -1
- package/dist/bn-template-engine/p-sRO-lj7X.js +0 -1
- package/dist/bn-template-engine/p-tzFCK9qn.js +0 -1
- package/dist/cjs/bn-asset_16.cjs.entry.js +0 -9099
- package/dist/cjs/bn-card.cjs.entry.js +0 -36
- package/dist/cjs/bn-chart-time.cjs.entry.js +0 -1031
- package/dist/cjs/bn-layout-card.cjs.entry.js +0 -279
- package/dist/cjs/formatter-4XCS0d2B.js +0 -221
- package/dist/cjs/ibcs-chart-time.cjs.entry.js +0 -4137
- package/dist/cjs/withComponentStatus-_x4LQZ0N.js +0 -109
- package/dist/cjs/withComponentStyle-ClSJfCku.js +0 -128
- package/dist/cjs/withInheritedProps-BH2KNER3.js +0 -157
- package/dist/cjs/withStyled-9tG024gQ.js +0 -522
- package/dist/esm/bn-asset_16.entry.js +0 -9082
- package/dist/esm/bn-card.entry.js +0 -34
- package/dist/esm/bn-chart-time.entry.js +0 -1029
- package/dist/esm/bn-layout-card.entry.js +0 -277
- package/dist/esm/formatter-BDh7GfC5.js +0 -215
- package/dist/esm/ibcs-chart-time.entry.js +0 -4135
- package/dist/esm/withComponentStatus-DodoSXe-.js +0 -107
- package/dist/esm/withComponentStyle-D3VWOsto.js +0 -126
- package/dist/esm/withInheritedProps-BlXDxhHK.js +0 -154
- package/dist/esm/withStyled-CE3_3taP.js +0 -495
|
@@ -1,522 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Order = require('./Order-BGx39pS5.js');
|
|
4
|
-
var index = require('./index-Cjw0q6gP.js');
|
|
5
|
-
var withHasError = require('./withHasError-B8gHkfV2.js');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Prop validators for Stencil @Watch handlers.
|
|
9
|
-
*
|
|
10
|
-
* Each validator returns an array of invalid items; an empty array means the input is valid.
|
|
11
|
-
* These are used in component @Watch methods to warn about malformed attribute values
|
|
12
|
-
* without crashing the component.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Checks whether a value is blank, null, undefined, or the string `"null"`.
|
|
16
|
-
* The string `"null"` check handles serialized null values from HTML attributes,
|
|
17
|
-
* which arrive as the literal string "null" rather than a JS null.
|
|
18
|
-
*/
|
|
19
|
-
function isBlankInput(value) {
|
|
20
|
-
return value === null || value === undefined || value === "" || value === "null";
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Validates a comma-separated list of scenario identifiers.
|
|
24
|
-
* The special value `"auto"` is always valid. Base scenarios are validated against
|
|
25
|
-
* the Scenarios enum; remaining invalid entries are passed to `validateVariancesList`
|
|
26
|
-
* for variance format checking (e.g. `d_ac1_pl1_pos`).
|
|
27
|
-
*/
|
|
28
|
-
function validateScenarioList(value) {
|
|
29
|
-
if (isBlankInput(value)) {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
if (value.trim().toLowerCase() === "auto") {
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
const invalidScenarios = value === null || value === void 0 ? void 0 : value.split(",").filter((element) => !(element.toUpperCase().trim() in Order.Scenarios));
|
|
36
|
-
return validateVariancesList(invalidScenarios.toString());
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Validates variance identifiers in the format `d_<base>_<delta>_<sentiment>` or
|
|
40
|
-
* `dr_<base>_<delta>_<sentiment>`. Each component is checked against the Scenarios
|
|
41
|
-
* and Sentiments enums. Returns items that fail validation.
|
|
42
|
-
*/
|
|
43
|
-
function validateVariancesList(value) {
|
|
44
|
-
if (isBlankInput(value)) {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
const invalidScenarios = value
|
|
48
|
-
.replace(";", ",")
|
|
49
|
-
.split(",")
|
|
50
|
-
.filter((element) => {
|
|
51
|
-
var _a, _b, _c;
|
|
52
|
-
const splittedElement = element.split("_");
|
|
53
|
-
const scenarioSubtrahend = (_a = splittedElement[0]) === null || _a === void 0 ? void 0 : _a.replace(/^dr|^d/, "").toUpperCase().trim();
|
|
54
|
-
const scenarioMinuend = (_b = splittedElement[1]) === null || _b === void 0 ? void 0 : _b.toUpperCase().trim();
|
|
55
|
-
const scenarioSentiment = (_c = splittedElement[2]) === null || _c === void 0 ? void 0 : _c.toUpperCase().trim();
|
|
56
|
-
return (splittedElement.length !== 3 ||
|
|
57
|
-
!(scenarioSubtrahend in Order.Scenarios) ||
|
|
58
|
-
!(scenarioMinuend in Order.Scenarios) ||
|
|
59
|
-
!(scenarioSentiment in Order.Sentiments));
|
|
60
|
-
});
|
|
61
|
-
return invalidScenarios;
|
|
62
|
-
}
|
|
63
|
-
function validateOrderList(value) {
|
|
64
|
-
if (isBlankInput(value)) {
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
if (value.trim().toLowerCase() === "auto") {
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
const invalidScenarios = value.split(",").filter((element) => !(element.toUpperCase() in Order.OrderColumn));
|
|
71
|
-
return validateVariancesList(invalidScenarios.toString());
|
|
72
|
-
}
|
|
73
|
-
function isValidInteger(value) {
|
|
74
|
-
if (isBlankInput(value)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
return Number.isInteger(Number(value));
|
|
78
|
-
}
|
|
79
|
-
function isValidNumber(value) {
|
|
80
|
-
if (isBlankInput(value)) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return !Number.isNaN(Number(value));
|
|
84
|
-
}
|
|
85
|
-
function isValidDirection(value) {
|
|
86
|
-
if (isBlankInput(value)) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase()) in Order.OrderDirection;
|
|
90
|
-
}
|
|
91
|
-
function isValidLevel(value) {
|
|
92
|
-
if ((value === null || value === void 0 ? void 0 : value.toLowerCase()) === "auto") {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase()) in Order.AggregationLevel;
|
|
96
|
-
}
|
|
97
|
-
function validateMeasureList(value) {
|
|
98
|
-
if (isBlankInput(value)) {
|
|
99
|
-
return [];
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
const newObj = JSON.parse(value);
|
|
103
|
-
if (newObj instanceof Array) {
|
|
104
|
-
return newObj.filter((elem) => !(elem.hasOwnProperty("name") && elem.hasOwnProperty("unit")));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
console.error("validateMeasureList: failed to parse JSON", e);
|
|
109
|
-
}
|
|
110
|
-
return ["Invalid JSON structure"];
|
|
111
|
-
}
|
|
112
|
-
function isValidDate(value) {
|
|
113
|
-
const newDate = Date.parse(value);
|
|
114
|
-
return Number.isInteger(newDate);
|
|
115
|
-
}
|
|
116
|
-
function isValidDateLink(value) {
|
|
117
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase()) in Order.DateLink;
|
|
118
|
-
}
|
|
119
|
-
function isValidDateFormat(value) {
|
|
120
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase()) in Order.DateDistance;
|
|
121
|
-
}
|
|
122
|
-
function isValidAxisLabelsMode(value) {
|
|
123
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase()) in Order.AxisLabelsMode;
|
|
124
|
-
}
|
|
125
|
-
function isValidDataFormat(value) {
|
|
126
|
-
if (isBlankInput(value)) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase()) in Order.DataFormat;
|
|
130
|
-
}
|
|
131
|
-
function isValidBoolean(value) {
|
|
132
|
-
if (isBlankInput(value)) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
const validValues = ["true", "false", true, false];
|
|
136
|
-
return validValues.some((elem) => elem === value);
|
|
137
|
-
}
|
|
138
|
-
function isValidTableType(value) {
|
|
139
|
-
if (isBlankInput(value)) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase()) in Order.TableType;
|
|
143
|
-
}
|
|
144
|
-
function validateThereOfJsonStr(value) {
|
|
145
|
-
if (isBlankInput(value)) {
|
|
146
|
-
return [];
|
|
147
|
-
}
|
|
148
|
-
try {
|
|
149
|
-
const jsonObject = JSON.parse(value);
|
|
150
|
-
if (jsonObject instanceof Array) {
|
|
151
|
-
// return newObj.filter(elem => elem.hasOwnProperty('rowgroup') && elem.hasOwnProperty('category') && elem.hasOwnProperty('subcategory'))
|
|
152
|
-
return jsonObject.filter((elem) => !(elem.hasOwnProperty("rowGroup") && elem.hasOwnProperty("category") && elem.hasOwnProperty("subCategory")));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (err) {
|
|
156
|
-
console.error("validateThereOfJsonStr: failed to parse JSON", err);
|
|
157
|
-
}
|
|
158
|
-
return ["Invalid JSON structure"];
|
|
159
|
-
}
|
|
160
|
-
function validatePartOfJsonStr(value) {
|
|
161
|
-
if (isBlankInput(value)) {
|
|
162
|
-
return [];
|
|
163
|
-
}
|
|
164
|
-
try {
|
|
165
|
-
const jsonObject = JSON.parse(value);
|
|
166
|
-
if (jsonObject instanceof Array) {
|
|
167
|
-
// return newObj.filter(elem => elem.hasOwnProperty('rowgroup') && elem.hasOwnProperty('category') && elem.hasOwnProperty('subcategory'))
|
|
168
|
-
return jsonObject.filter((elem) => !(elem.hasOwnProperty("rowGroup") && elem.hasOwnProperty("category")));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
catch (e) {
|
|
172
|
-
console.error("validatePartOfJsonStr: failed to parse JSON", e);
|
|
173
|
-
}
|
|
174
|
-
return ["Invalid JSON structure"];
|
|
175
|
-
}
|
|
176
|
-
function isValidMeasureType(value) {
|
|
177
|
-
return (value === null || value === void 0 ? void 0 : value.trim().toUpperCase()) in Order.MeasureType;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Validates a measure-scale attribute value.
|
|
181
|
-
* Accepted values: `"_"` (no scaling), SI prefix letters (k, M, G, T, P, E, Z, Y, m, etc.),
|
|
182
|
-
* or auto-detection modes `"GREATEST"` / `"LEAST"`.
|
|
183
|
-
*/
|
|
184
|
-
function isValidMeasureScale(value) {
|
|
185
|
-
return (["_", "k", "M", "G", "T", "P", "E", "Z", "Y", "m", "μ", "n", "p", "P", "f", "a", "z", "y"].includes(value === null || value === void 0 ? void 0 : value.trim()) || ["GREATEST", "LEAST"].includes(value === null || value === void 0 ? void 0 : value.trim().toUpperCase()));
|
|
186
|
-
}
|
|
187
|
-
function isTableCategoryWidth(value) {
|
|
188
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase().trim()) in Order.TableCategoryWidth;
|
|
189
|
-
}
|
|
190
|
-
function isTableBarColumnWidth(value) {
|
|
191
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase().trim()) in Order.TableBarColumnWidth;
|
|
192
|
-
}
|
|
193
|
-
function validateColumnThereOfJsonStr(value) {
|
|
194
|
-
if (isBlankInput(value)) {
|
|
195
|
-
return [];
|
|
196
|
-
}
|
|
197
|
-
try {
|
|
198
|
-
const jsonObject = JSON.parse(value);
|
|
199
|
-
return jsonObject.filter((elem) => !(elem.hasOwnProperty("scenario") && elem.hasOwnProperty("name") && elem.hasOwnProperty("subGroups")));
|
|
200
|
-
}
|
|
201
|
-
catch (e) {
|
|
202
|
-
console.error("validateColumnThereOfJsonStr: failed to parse JSON", e);
|
|
203
|
-
}
|
|
204
|
-
return ["Invalid JSON structure"];
|
|
205
|
-
}
|
|
206
|
-
function validateStackConfig(value) {
|
|
207
|
-
if (isBlankInput(value)) {
|
|
208
|
-
return [];
|
|
209
|
-
}
|
|
210
|
-
try {
|
|
211
|
-
const config = JSON.parse(value);
|
|
212
|
-
if (typeof config !== "object" || config === null || Array.isArray(config)) {
|
|
213
|
-
return ["stack: must be a JSON object"];
|
|
214
|
-
}
|
|
215
|
-
const errors = [];
|
|
216
|
-
if (!config.hasOwnProperty("by")) {
|
|
217
|
-
errors.push("stack: 'by' is required");
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
const validBy = ["scenarios", "dimensions"];
|
|
221
|
-
if (!validBy.includes(config.by)) {
|
|
222
|
-
errors.push(`stack: 'by' must be one of: ${validBy.join(", ")}`);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
if (config.hasOwnProperty("mode")) {
|
|
226
|
-
const validModes = ["absolute", "relative", "absolute-relative"];
|
|
227
|
-
if (!validModes.includes(config.mode)) {
|
|
228
|
-
errors.push(`stack: 'mode' must be one of: ${validModes.join(", ")}`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (config.hasOwnProperty("order")) {
|
|
232
|
-
const validOrders = ["asc", "desc", "dataset"];
|
|
233
|
-
if (!validOrders.includes(config.order)) {
|
|
234
|
-
errors.push(`stack: 'order' must be one of: ${validOrders.join(", ")}`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return errors;
|
|
238
|
-
}
|
|
239
|
-
catch (_e) {
|
|
240
|
-
return ["stack: invalid JSON"];
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
class StyleSheet {
|
|
245
|
-
constructor() {
|
|
246
|
-
this.cache = new Map();
|
|
247
|
-
this.tag = StyleSheet.makeStyleTag();
|
|
248
|
-
}
|
|
249
|
-
static makeStyleTag() {
|
|
250
|
-
const tag = document.createElement("style");
|
|
251
|
-
tag.type = "text/css";
|
|
252
|
-
tag.setAttribute("data-bn-computed-style", "");
|
|
253
|
-
tag.append(document.createTextNode(""));
|
|
254
|
-
(document.head || document.querySelector("head")).append(tag);
|
|
255
|
-
return tag;
|
|
256
|
-
}
|
|
257
|
-
apply(data) {
|
|
258
|
-
data.forEach((value) => this.cache.set(value.className, value.style));
|
|
259
|
-
this.tag.innerHTML = Array.from(this.cache.values())
|
|
260
|
-
.map((value) => value)
|
|
261
|
-
.join("\n");
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const styleSheet = new StyleSheet();
|
|
265
|
-
|
|
266
|
-
/* eslint-disable */
|
|
267
|
-
// Inspired by https://github.com/garycourt/murmurhash-js
|
|
268
|
-
// Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86
|
|
269
|
-
function murmur2(str) {
|
|
270
|
-
// 'm' and 'r' are mixing constants generated offline.
|
|
271
|
-
// They're not really 'magic', they just happen to work well.
|
|
272
|
-
// const m = 0x5bd1e995;
|
|
273
|
-
// const r = 24;
|
|
274
|
-
// Initialize the hash
|
|
275
|
-
var h = 0; // Mix 4 bytes at a time into the hash
|
|
276
|
-
|
|
277
|
-
var k,
|
|
278
|
-
i = 0,
|
|
279
|
-
len = str.length;
|
|
280
|
-
|
|
281
|
-
for (; len >= 4; ++i, len -= 4) {
|
|
282
|
-
k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
|
|
283
|
-
k =
|
|
284
|
-
/* Math.imul(k, m): */
|
|
285
|
-
(k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);
|
|
286
|
-
k ^=
|
|
287
|
-
/* k >>> r: */
|
|
288
|
-
k >>> 24;
|
|
289
|
-
h =
|
|
290
|
-
/* Math.imul(k, m): */
|
|
291
|
-
(k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^
|
|
292
|
-
/* Math.imul(h, m): */
|
|
293
|
-
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
|
|
294
|
-
} // Handle the last few bytes of the input array
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
switch (len) {
|
|
298
|
-
case 3:
|
|
299
|
-
h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
|
|
300
|
-
|
|
301
|
-
case 2:
|
|
302
|
-
h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
|
|
303
|
-
|
|
304
|
-
case 1:
|
|
305
|
-
h ^= str.charCodeAt(i) & 0xff;
|
|
306
|
-
h =
|
|
307
|
-
/* Math.imul(h, m): */
|
|
308
|
-
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
|
|
309
|
-
} // Do a few final mixes of the hash to ensure the last few
|
|
310
|
-
// bytes are well-incorporated.
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
h ^= h >>> 13;
|
|
314
|
-
h =
|
|
315
|
-
/* Math.imul(h, m): */
|
|
316
|
-
(h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
|
|
317
|
-
return ((h ^ h >>> 15) >>> 0).toString(36);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const transofrmToUnitString = (value) => {
|
|
321
|
-
if (isValidNumber(value)) {
|
|
322
|
-
return `${value}px`;
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
return value;
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
const width = {
|
|
329
|
-
className: "w",
|
|
330
|
-
cssName: "width",
|
|
331
|
-
attrName: "width",
|
|
332
|
-
transform: transofrmToUnitString,
|
|
333
|
-
};
|
|
334
|
-
const height = {
|
|
335
|
-
className: "h",
|
|
336
|
-
cssName: "height",
|
|
337
|
-
attrName: "height",
|
|
338
|
-
transform: transofrmToUnitString,
|
|
339
|
-
};
|
|
340
|
-
const position = {
|
|
341
|
-
className: "pst",
|
|
342
|
-
cssName: "position",
|
|
343
|
-
attrName: "position",
|
|
344
|
-
};
|
|
345
|
-
const top = {
|
|
346
|
-
className: "top",
|
|
347
|
-
cssName: "top",
|
|
348
|
-
attrName: "top",
|
|
349
|
-
transform: transofrmToUnitString,
|
|
350
|
-
};
|
|
351
|
-
const right = {
|
|
352
|
-
className: "rgt",
|
|
353
|
-
cssName: "right",
|
|
354
|
-
attrName: "right",
|
|
355
|
-
transform: transofrmToUnitString,
|
|
356
|
-
};
|
|
357
|
-
const bottom = {
|
|
358
|
-
className: "btm",
|
|
359
|
-
cssName: "bottom",
|
|
360
|
-
attrName: "bottom",
|
|
361
|
-
transform: transofrmToUnitString,
|
|
362
|
-
};
|
|
363
|
-
const left = {
|
|
364
|
-
className: "lft",
|
|
365
|
-
cssName: "left",
|
|
366
|
-
attrName: "left",
|
|
367
|
-
transform: transofrmToUnitString,
|
|
368
|
-
};
|
|
369
|
-
const fontSize = {
|
|
370
|
-
className: "fts",
|
|
371
|
-
cssName: "font-size",
|
|
372
|
-
attrName: "font-size",
|
|
373
|
-
transform: transofrmToUnitString,
|
|
374
|
-
};
|
|
375
|
-
const gridColumn = {
|
|
376
|
-
className: "gdc",
|
|
377
|
-
cssName: "grid-column",
|
|
378
|
-
attrName: "grid-column",
|
|
379
|
-
};
|
|
380
|
-
const gridRow = {
|
|
381
|
-
className: "gdr",
|
|
382
|
-
cssName: "grid-row",
|
|
383
|
-
attrName: "grid-row",
|
|
384
|
-
};
|
|
385
|
-
const attributes = {
|
|
386
|
-
width: width,
|
|
387
|
-
height: height,
|
|
388
|
-
position: position,
|
|
389
|
-
top: top,
|
|
390
|
-
right: right,
|
|
391
|
-
bottom: bottom,
|
|
392
|
-
left: left,
|
|
393
|
-
"font-size": fontSize,
|
|
394
|
-
"grid-column": gridColumn,
|
|
395
|
-
"grid-row": gridRow,
|
|
396
|
-
};
|
|
397
|
-
const attributesNames = Object.keys(attributes);
|
|
398
|
-
function getClassName(attr, value) {
|
|
399
|
-
const valueKey = murmur2(value);
|
|
400
|
-
return `bn-c-${attr.className}_${valueKey}`;
|
|
401
|
-
}
|
|
402
|
-
function getStyle(attr, className, value) {
|
|
403
|
-
return `.${className} {${attr.cssName}: ${value};}`;
|
|
404
|
-
}
|
|
405
|
-
function getCSS(attr, value) {
|
|
406
|
-
const className = getClassName(attr, value);
|
|
407
|
-
const style = getStyle(attr, className, value);
|
|
408
|
-
return { className, style };
|
|
409
|
-
}
|
|
410
|
-
const apply = (el) => {
|
|
411
|
-
const map = new Map();
|
|
412
|
-
//map.set("position", getCSS(attributes["position"], "absolute"))
|
|
413
|
-
attributesNames.forEach((name) => {
|
|
414
|
-
const value = el.getAttribute(name);
|
|
415
|
-
if (value) {
|
|
416
|
-
if (["top", "left", "right", "bottom"].includes(name)) {
|
|
417
|
-
map.set("position", getCSS(attributes["position"], "absolute"));
|
|
418
|
-
}
|
|
419
|
-
const transform = attributes[name].transform ||
|
|
420
|
-
function (v) {
|
|
421
|
-
return v;
|
|
422
|
-
};
|
|
423
|
-
map.set(name, getCSS(attributes[name], transform(value)));
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
return map;
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Shared MutationObserver that watches for style-attribute changes on all
|
|
431
|
-
* subscribed elements. When a monitored attribute changes, it re-applies the
|
|
432
|
-
* Styletron CSS-in-JS stylesheet and updates the element's className,
|
|
433
|
-
* preserving any non-`bn-c-` classes.
|
|
434
|
-
*/
|
|
435
|
-
const observer = new MutationObserver((mutations) => {
|
|
436
|
-
for (const mutation of mutations) {
|
|
437
|
-
const el = mutation.target;
|
|
438
|
-
const map = apply(el);
|
|
439
|
-
styleSheet.apply(map);
|
|
440
|
-
const classes = Array.from(map.values()).map((value) => value.className);
|
|
441
|
-
el.className = el.className
|
|
442
|
-
.split(" ")
|
|
443
|
-
.filter((value) => !value.startsWith("bn-c-"))
|
|
444
|
-
.concat(...classes)
|
|
445
|
-
.join(" ");
|
|
446
|
-
index.forceUpdate(el);
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
/**
|
|
450
|
-
* Registers an element with the Styletron observer: applies the initial
|
|
451
|
-
* stylesheet, assigns generated `bn-c-*` class names, and begins watching
|
|
452
|
-
* for attribute mutations that affect styling.
|
|
453
|
-
*/
|
|
454
|
-
const subscribe = (el) => {
|
|
455
|
-
const map = apply(el);
|
|
456
|
-
styleSheet.apply(map);
|
|
457
|
-
const classes = Array.from(map.values()).map((value) => value.className);
|
|
458
|
-
el.className = el.className
|
|
459
|
-
.split(" ")
|
|
460
|
-
.filter((value) => !value.startsWith("bn-c-"))
|
|
461
|
-
.concat(...classes)
|
|
462
|
-
.join(" ");
|
|
463
|
-
observer.observe(el, { attributes: true, attributeFilter: attributesNames, childList: false, subtree: false });
|
|
464
|
-
};
|
|
465
|
-
/**
|
|
466
|
-
* Mixin that integrates Styletron CSS-in-JS styling into a Stencil component.
|
|
467
|
-
*
|
|
468
|
-
* On `connectedCallback`, it subscribes the host element to a shared
|
|
469
|
-
* MutationObserver that watches for style-related attribute changes. When
|
|
470
|
-
* attributes change, the Styletron stylesheet is re-applied and the element's
|
|
471
|
-
* class list is updated with generated `bn-c-*` class names, followed by a
|
|
472
|
-
* forced re-render.
|
|
473
|
-
*
|
|
474
|
-
* @param component - The Stencil component instance
|
|
475
|
-
*/
|
|
476
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
477
|
-
const withStyled = (component) => {
|
|
478
|
-
const cstrConnectedCallback = component["connectedCallback"];
|
|
479
|
-
const cstrDisconnectedCallback = component["disconnectedCallback"];
|
|
480
|
-
component["connectedCallback"] = () => {
|
|
481
|
-
const elm = index.getElement(component);
|
|
482
|
-
if (elm) {
|
|
483
|
-
subscribe(elm);
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
throw new Error(`Can't find element field in component ${undefined}`);
|
|
487
|
-
}
|
|
488
|
-
withHasError.runIfExisits(cstrConnectedCallback, component);
|
|
489
|
-
};
|
|
490
|
-
component["disconnectedCallback"] = () => {
|
|
491
|
-
// MutationObserver has no per-element unobserve — the shared observer
|
|
492
|
-
// automatically stops firing for elements removed from the DOM.
|
|
493
|
-
withHasError.runIfExisits(cstrDisconnectedCallback, component);
|
|
494
|
-
};
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
exports.isBlankInput = isBlankInput;
|
|
498
|
-
exports.isTableBarColumnWidth = isTableBarColumnWidth;
|
|
499
|
-
exports.isTableCategoryWidth = isTableCategoryWidth;
|
|
500
|
-
exports.isValidAxisLabelsMode = isValidAxisLabelsMode;
|
|
501
|
-
exports.isValidBoolean = isValidBoolean;
|
|
502
|
-
exports.isValidDataFormat = isValidDataFormat;
|
|
503
|
-
exports.isValidDate = isValidDate;
|
|
504
|
-
exports.isValidDateFormat = isValidDateFormat;
|
|
505
|
-
exports.isValidDateLink = isValidDateLink;
|
|
506
|
-
exports.isValidDirection = isValidDirection;
|
|
507
|
-
exports.isValidInteger = isValidInteger;
|
|
508
|
-
exports.isValidLevel = isValidLevel;
|
|
509
|
-
exports.isValidMeasureScale = isValidMeasureScale;
|
|
510
|
-
exports.isValidMeasureType = isValidMeasureType;
|
|
511
|
-
exports.isValidNumber = isValidNumber;
|
|
512
|
-
exports.isValidTableType = isValidTableType;
|
|
513
|
-
exports.murmur2 = murmur2;
|
|
514
|
-
exports.validateColumnThereOfJsonStr = validateColumnThereOfJsonStr;
|
|
515
|
-
exports.validateMeasureList = validateMeasureList;
|
|
516
|
-
exports.validateOrderList = validateOrderList;
|
|
517
|
-
exports.validatePartOfJsonStr = validatePartOfJsonStr;
|
|
518
|
-
exports.validateScenarioList = validateScenarioList;
|
|
519
|
-
exports.validateStackConfig = validateStackConfig;
|
|
520
|
-
exports.validateThereOfJsonStr = validateThereOfJsonStr;
|
|
521
|
-
exports.validateVariancesList = validateVariancesList;
|
|
522
|
-
exports.withStyled = withStyled;
|