pristine-charts 0.1.0
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/README.md +154 -0
- package/dist/area-chart/index.cjs +1736 -0
- package/dist/area-chart/index.cjs.map +1 -0
- package/dist/area-chart/index.d.cts +75 -0
- package/dist/area-chart/index.d.ts +75 -0
- package/dist/area-chart/index.js +1730 -0
- package/dist/area-chart/index.js.map +1 -0
- package/dist/bar-chart/index.cjs +1808 -0
- package/dist/bar-chart/index.cjs.map +1 -0
- package/dist/bar-chart/index.d.cts +72 -0
- package/dist/bar-chart/index.d.ts +72 -0
- package/dist/bar-chart/index.js +1802 -0
- package/dist/bar-chart/index.js.map +1 -0
- package/dist/box-plot/index.cjs +1858 -0
- package/dist/box-plot/index.cjs.map +1 -0
- package/dist/box-plot/index.d.cts +58 -0
- package/dist/box-plot/index.d.ts +58 -0
- package/dist/box-plot/index.js +1852 -0
- package/dist/box-plot/index.js.map +1 -0
- package/dist/bullet-chart/index.cjs +1707 -0
- package/dist/bullet-chart/index.cjs.map +1 -0
- package/dist/bullet-chart/index.d.cts +68 -0
- package/dist/bullet-chart/index.d.ts +68 -0
- package/dist/bullet-chart/index.js +1701 -0
- package/dist/bullet-chart/index.js.map +1 -0
- package/dist/histogram-chart/index.cjs +1876 -0
- package/dist/histogram-chart/index.cjs.map +1 -0
- package/dist/histogram-chart/index.d.cts +76 -0
- package/dist/histogram-chart/index.d.ts +76 -0
- package/dist/histogram-chart/index.js +1870 -0
- package/dist/histogram-chart/index.js.map +1 -0
- package/dist/index.cjs +6940 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +6860 -0
- package/dist/index.js.map +1 -0
- package/dist/kpi-card/index.cjs +1315 -0
- package/dist/kpi-card/index.cjs.map +1 -0
- package/dist/kpi-card/index.d.cts +79 -0
- package/dist/kpi-card/index.d.ts +79 -0
- package/dist/kpi-card/index.js +1304 -0
- package/dist/kpi-card/index.js.map +1 -0
- package/dist/line-chart/index.cjs +1742 -0
- package/dist/line-chart/index.cjs.map +1 -0
- package/dist/line-chart/index.d.cts +54 -0
- package/dist/line-chart/index.d.ts +54 -0
- package/dist/line-chart/index.js +1736 -0
- package/dist/line-chart/index.js.map +1 -0
- package/dist/linearSeries-BQL4Ud3w.d.cts +14 -0
- package/dist/linearSeries-BQL4Ud3w.d.ts +14 -0
- package/dist/pie-donut-chart/index.cjs +1663 -0
- package/dist/pie-donut-chart/index.cjs.map +1 -0
- package/dist/pie-donut-chart/index.d.cts +83 -0
- package/dist/pie-donut-chart/index.d.ts +83 -0
- package/dist/pie-donut-chart/index.js +1655 -0
- package/dist/pie-donut-chart/index.js.map +1 -0
- package/dist/progress-bar/index.cjs +1336 -0
- package/dist/progress-bar/index.cjs.map +1 -0
- package/dist/progress-bar/index.d.cts +54 -0
- package/dist/progress-bar/index.d.ts +54 -0
- package/dist/progress-bar/index.js +1329 -0
- package/dist/progress-bar/index.js.map +1 -0
- package/dist/ranked-list/index.cjs +1584 -0
- package/dist/ranked-list/index.cjs.map +1 -0
- package/dist/ranked-list/index.d.cts +70 -0
- package/dist/ranked-list/index.d.ts +70 -0
- package/dist/ranked-list/index.js +1576 -0
- package/dist/ranked-list/index.js.map +1 -0
- package/dist/result-C2epnG6V.d.cts +33 -0
- package/dist/result-C2epnG6V.d.ts +33 -0
- package/dist/scatter-plot/index.cjs +1618 -0
- package/dist/scatter-plot/index.cjs.map +1 -0
- package/dist/scatter-plot/index.d.cts +55 -0
- package/dist/scatter-plot/index.d.ts +55 -0
- package/dist/scatter-plot/index.js +1612 -0
- package/dist/scatter-plot/index.js.map +1 -0
- package/dist/sparkline/index.cjs +1456 -0
- package/dist/sparkline/index.cjs.map +1 -0
- package/dist/sparkline/index.d.cts +47 -0
- package/dist/sparkline/index.d.ts +47 -0
- package/dist/sparkline/index.js +1451 -0
- package/dist/sparkline/index.js.map +1 -0
- package/package.json +126 -0
|
@@ -0,0 +1,1802 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { scaleBand, scaleLinear, min, max as max$1 } from 'd3';
|
|
4
|
+
|
|
5
|
+
// src/bar-chart/BarChart.tsx
|
|
6
|
+
|
|
7
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isPlaceholder.js
|
|
8
|
+
function _isPlaceholder(a) {
|
|
9
|
+
return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_curry1.js
|
|
13
|
+
function _curry1(fn) {
|
|
14
|
+
return function f1(a) {
|
|
15
|
+
if (arguments.length === 0 || _isPlaceholder(a)) {
|
|
16
|
+
return f1;
|
|
17
|
+
} else {
|
|
18
|
+
return fn.apply(this, arguments);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_curry2.js
|
|
24
|
+
function _curry2(fn) {
|
|
25
|
+
return function f2(a, b) {
|
|
26
|
+
switch (arguments.length) {
|
|
27
|
+
case 0:
|
|
28
|
+
return f2;
|
|
29
|
+
case 1:
|
|
30
|
+
return _isPlaceholder(a) ? f2 : _curry1(function(_b) {
|
|
31
|
+
return fn(a, _b);
|
|
32
|
+
});
|
|
33
|
+
default:
|
|
34
|
+
return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function(_a) {
|
|
35
|
+
return fn(_a, b);
|
|
36
|
+
}) : _isPlaceholder(b) ? _curry1(function(_b) {
|
|
37
|
+
return fn(a, _b);
|
|
38
|
+
}) : fn(a, b);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isArray.js
|
|
44
|
+
var isArray_default = Array.isArray || function _isArray(val) {
|
|
45
|
+
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === "[object Array]";
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isTransformer.js
|
|
49
|
+
function _isTransformer(obj) {
|
|
50
|
+
return obj != null && typeof obj["@@transducer/step"] === "function";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_dispatchable.js
|
|
54
|
+
function _dispatchable(methodNames, transducerCreator, fn) {
|
|
55
|
+
return function() {
|
|
56
|
+
if (arguments.length === 0) {
|
|
57
|
+
return fn();
|
|
58
|
+
}
|
|
59
|
+
var obj = arguments[arguments.length - 1];
|
|
60
|
+
if (!isArray_default(obj)) {
|
|
61
|
+
var idx = 0;
|
|
62
|
+
while (idx < methodNames.length) {
|
|
63
|
+
if (typeof obj[methodNames[idx]] === "function") {
|
|
64
|
+
return obj[methodNames[idx]].apply(obj, Array.prototype.slice.call(arguments, 0, -1));
|
|
65
|
+
}
|
|
66
|
+
idx += 1;
|
|
67
|
+
}
|
|
68
|
+
if (_isTransformer(obj)) {
|
|
69
|
+
var transducer = transducerCreator.apply(null, Array.prototype.slice.call(arguments, 0, -1));
|
|
70
|
+
return transducer(obj);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return fn.apply(this, arguments);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_reduced.js
|
|
78
|
+
function _reduced(x) {
|
|
79
|
+
return x && x["@@transducer/reduced"] ? x : {
|
|
80
|
+
"@@transducer/value": x,
|
|
81
|
+
"@@transducer/reduced": true
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_xfBase.js
|
|
86
|
+
var xfBase_default = {
|
|
87
|
+
init: function() {
|
|
88
|
+
return this.xf["@@transducer/init"]();
|
|
89
|
+
},
|
|
90
|
+
result: function(result) {
|
|
91
|
+
return this.xf["@@transducer/result"](result);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_xall.js
|
|
96
|
+
var XAll = /* @__PURE__ */ (function() {
|
|
97
|
+
function XAll2(f, xf) {
|
|
98
|
+
this.xf = xf;
|
|
99
|
+
this.f = f;
|
|
100
|
+
this.all = true;
|
|
101
|
+
}
|
|
102
|
+
XAll2.prototype["@@transducer/init"] = xfBase_default.init;
|
|
103
|
+
XAll2.prototype["@@transducer/result"] = function(result) {
|
|
104
|
+
if (this.all) {
|
|
105
|
+
result = this.xf["@@transducer/step"](result, true);
|
|
106
|
+
}
|
|
107
|
+
return this.xf["@@transducer/result"](result);
|
|
108
|
+
};
|
|
109
|
+
XAll2.prototype["@@transducer/step"] = function(result, input) {
|
|
110
|
+
if (!this.f(input)) {
|
|
111
|
+
this.all = false;
|
|
112
|
+
result = _reduced(this.xf["@@transducer/step"](result, false));
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
};
|
|
116
|
+
return XAll2;
|
|
117
|
+
})();
|
|
118
|
+
function _xall(f) {
|
|
119
|
+
return function(xf) {
|
|
120
|
+
return new XAll(f, xf);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/all.js
|
|
125
|
+
var all = /* @__PURE__ */ _curry2(/* @__PURE__ */ _dispatchable(["all"], _xall, function all2(fn, list) {
|
|
126
|
+
var idx = 0;
|
|
127
|
+
while (idx < list.length) {
|
|
128
|
+
if (!fn(list[idx])) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
idx += 1;
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
}));
|
|
135
|
+
var all_default = all;
|
|
136
|
+
|
|
137
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_arity.js
|
|
138
|
+
function _arity(n, fn) {
|
|
139
|
+
switch (n) {
|
|
140
|
+
case 0:
|
|
141
|
+
return function() {
|
|
142
|
+
return fn.apply(this, arguments);
|
|
143
|
+
};
|
|
144
|
+
case 1:
|
|
145
|
+
return function(a0) {
|
|
146
|
+
return fn.apply(this, arguments);
|
|
147
|
+
};
|
|
148
|
+
case 2:
|
|
149
|
+
return function(a0, a1) {
|
|
150
|
+
return fn.apply(this, arguments);
|
|
151
|
+
};
|
|
152
|
+
case 3:
|
|
153
|
+
return function(a0, a1, a2) {
|
|
154
|
+
return fn.apply(this, arguments);
|
|
155
|
+
};
|
|
156
|
+
case 4:
|
|
157
|
+
return function(a0, a1, a2, a3) {
|
|
158
|
+
return fn.apply(this, arguments);
|
|
159
|
+
};
|
|
160
|
+
case 5:
|
|
161
|
+
return function(a0, a1, a2, a3, a4) {
|
|
162
|
+
return fn.apply(this, arguments);
|
|
163
|
+
};
|
|
164
|
+
case 6:
|
|
165
|
+
return function(a0, a1, a2, a3, a4, a5) {
|
|
166
|
+
return fn.apply(this, arguments);
|
|
167
|
+
};
|
|
168
|
+
case 7:
|
|
169
|
+
return function(a0, a1, a2, a3, a4, a5, a6) {
|
|
170
|
+
return fn.apply(this, arguments);
|
|
171
|
+
};
|
|
172
|
+
case 8:
|
|
173
|
+
return function(a0, a1, a2, a3, a4, a5, a6, a7) {
|
|
174
|
+
return fn.apply(this, arguments);
|
|
175
|
+
};
|
|
176
|
+
case 9:
|
|
177
|
+
return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
178
|
+
return fn.apply(this, arguments);
|
|
179
|
+
};
|
|
180
|
+
case 10:
|
|
181
|
+
return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
182
|
+
return fn.apply(this, arguments);
|
|
183
|
+
};
|
|
184
|
+
default:
|
|
185
|
+
throw new Error("First argument to _arity must be a non-negative integer no greater than ten");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_curryN.js
|
|
190
|
+
function _curryN(length, received, fn) {
|
|
191
|
+
return function() {
|
|
192
|
+
var combined = [];
|
|
193
|
+
var argsIdx = 0;
|
|
194
|
+
var left = length;
|
|
195
|
+
var combinedIdx = 0;
|
|
196
|
+
var hasPlaceholder = false;
|
|
197
|
+
while (combinedIdx < received.length || argsIdx < arguments.length) {
|
|
198
|
+
var result;
|
|
199
|
+
if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) {
|
|
200
|
+
result = received[combinedIdx];
|
|
201
|
+
} else {
|
|
202
|
+
result = arguments[argsIdx];
|
|
203
|
+
argsIdx += 1;
|
|
204
|
+
}
|
|
205
|
+
combined[combinedIdx] = result;
|
|
206
|
+
if (!_isPlaceholder(result)) {
|
|
207
|
+
left -= 1;
|
|
208
|
+
} else {
|
|
209
|
+
hasPlaceholder = true;
|
|
210
|
+
}
|
|
211
|
+
combinedIdx += 1;
|
|
212
|
+
}
|
|
213
|
+
return !hasPlaceholder && left <= 0 ? fn.apply(this, combined) : _arity(Math.max(0, left), _curryN(length, combined, fn));
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/curryN.js
|
|
218
|
+
var curryN = /* @__PURE__ */ _curry2(function curryN2(length, fn) {
|
|
219
|
+
if (length === 1) {
|
|
220
|
+
return _curry1(fn);
|
|
221
|
+
}
|
|
222
|
+
return _arity(length, _curryN(length, [], fn));
|
|
223
|
+
});
|
|
224
|
+
var curryN_default = curryN;
|
|
225
|
+
|
|
226
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_arrayFromIterator.js
|
|
227
|
+
function _arrayFromIterator(iter) {
|
|
228
|
+
var list = [];
|
|
229
|
+
var next;
|
|
230
|
+
while (!(next = iter.next()).done) {
|
|
231
|
+
list.push(next.value);
|
|
232
|
+
}
|
|
233
|
+
return list;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_includesWith.js
|
|
237
|
+
function _includesWith(pred, x, list) {
|
|
238
|
+
var idx = 0;
|
|
239
|
+
var len = list.length;
|
|
240
|
+
while (idx < len) {
|
|
241
|
+
if (pred(x, list[idx])) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
idx += 1;
|
|
245
|
+
}
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_functionName.js
|
|
250
|
+
function _functionName(f) {
|
|
251
|
+
var match = String(f).match(/^function (\w*)/);
|
|
252
|
+
return match == null ? "" : match[1];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_has.js
|
|
256
|
+
function _has(prop3, obj) {
|
|
257
|
+
return Object.prototype.hasOwnProperty.call(obj, prop3);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_objectIs.js
|
|
261
|
+
function _objectIs(a, b) {
|
|
262
|
+
if (a === b) {
|
|
263
|
+
return a !== 0 || 1 / a === 1 / b;
|
|
264
|
+
} else {
|
|
265
|
+
return a !== a && b !== b;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
var objectIs_default = typeof Object.is === "function" ? Object.is : _objectIs;
|
|
269
|
+
|
|
270
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isArguments.js
|
|
271
|
+
var toString = Object.prototype.toString;
|
|
272
|
+
var _isArguments = /* @__PURE__ */ (function() {
|
|
273
|
+
return toString.call(arguments) === "[object Arguments]" ? function _isArguments2(x) {
|
|
274
|
+
return toString.call(x) === "[object Arguments]";
|
|
275
|
+
} : function _isArguments2(x) {
|
|
276
|
+
return _has("callee", x);
|
|
277
|
+
};
|
|
278
|
+
})();
|
|
279
|
+
var isArguments_default = _isArguments;
|
|
280
|
+
|
|
281
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/keys.js
|
|
282
|
+
var hasEnumBug = !/* @__PURE__ */ {
|
|
283
|
+
toString: null
|
|
284
|
+
}.propertyIsEnumerable("toString");
|
|
285
|
+
var nonEnumerableProps = ["constructor", "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString"];
|
|
286
|
+
var hasArgsEnumBug = /* @__PURE__ */ (function() {
|
|
287
|
+
return arguments.propertyIsEnumerable("length");
|
|
288
|
+
})();
|
|
289
|
+
var contains = function contains2(list, item) {
|
|
290
|
+
var idx = 0;
|
|
291
|
+
while (idx < list.length) {
|
|
292
|
+
if (list[idx] === item) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
idx += 1;
|
|
296
|
+
}
|
|
297
|
+
return false;
|
|
298
|
+
};
|
|
299
|
+
var keys = typeof Object.keys === "function" && !hasArgsEnumBug ? /* @__PURE__ */ _curry1(function keys2(obj) {
|
|
300
|
+
return Object(obj) !== obj ? [] : Object.keys(obj);
|
|
301
|
+
}) : /* @__PURE__ */ _curry1(function keys3(obj) {
|
|
302
|
+
if (Object(obj) !== obj) {
|
|
303
|
+
return [];
|
|
304
|
+
}
|
|
305
|
+
var prop3, nIdx;
|
|
306
|
+
var ks = [];
|
|
307
|
+
var checkArgsLength = hasArgsEnumBug && isArguments_default(obj);
|
|
308
|
+
for (prop3 in obj) {
|
|
309
|
+
if (_has(prop3, obj) && (!checkArgsLength || prop3 !== "length")) {
|
|
310
|
+
ks[ks.length] = prop3;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (hasEnumBug) {
|
|
314
|
+
nIdx = nonEnumerableProps.length - 1;
|
|
315
|
+
while (nIdx >= 0) {
|
|
316
|
+
prop3 = nonEnumerableProps[nIdx];
|
|
317
|
+
if (_has(prop3, obj) && !contains(ks, prop3)) {
|
|
318
|
+
ks[ks.length] = prop3;
|
|
319
|
+
}
|
|
320
|
+
nIdx -= 1;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return ks;
|
|
324
|
+
});
|
|
325
|
+
var keys_default = keys;
|
|
326
|
+
|
|
327
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/type.js
|
|
328
|
+
var type = /* @__PURE__ */ _curry1(function type2(val) {
|
|
329
|
+
return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
|
|
330
|
+
});
|
|
331
|
+
var type_default = type;
|
|
332
|
+
|
|
333
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_equals.js
|
|
334
|
+
function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
|
|
335
|
+
var a = _arrayFromIterator(aIterator);
|
|
336
|
+
var b = _arrayFromIterator(bIterator);
|
|
337
|
+
function eq(_a, _b) {
|
|
338
|
+
return _equals(_a, _b, stackA.slice(), stackB.slice());
|
|
339
|
+
}
|
|
340
|
+
return !_includesWith(function(b2, aItem) {
|
|
341
|
+
return !_includesWith(eq, aItem, b2);
|
|
342
|
+
}, b, a);
|
|
343
|
+
}
|
|
344
|
+
function _equals(a, b, stackA, stackB) {
|
|
345
|
+
if (objectIs_default(a, b)) {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
var typeA = type_default(a);
|
|
349
|
+
if (typeA !== type_default(b)) {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
if (typeof a["fantasy-land/equals"] === "function" || typeof b["fantasy-land/equals"] === "function") {
|
|
353
|
+
return typeof a["fantasy-land/equals"] === "function" && a["fantasy-land/equals"](b) && typeof b["fantasy-land/equals"] === "function" && b["fantasy-land/equals"](a);
|
|
354
|
+
}
|
|
355
|
+
if (typeof a.equals === "function" || typeof b.equals === "function") {
|
|
356
|
+
return typeof a.equals === "function" && a.equals(b) && typeof b.equals === "function" && b.equals(a);
|
|
357
|
+
}
|
|
358
|
+
switch (typeA) {
|
|
359
|
+
case "Arguments":
|
|
360
|
+
case "Array":
|
|
361
|
+
case "Object":
|
|
362
|
+
if (typeof a.constructor === "function" && _functionName(a.constructor) === "Promise") {
|
|
363
|
+
return a === b;
|
|
364
|
+
}
|
|
365
|
+
break;
|
|
366
|
+
case "Boolean":
|
|
367
|
+
case "Number":
|
|
368
|
+
case "String":
|
|
369
|
+
if (!(typeof a === typeof b && objectIs_default(a.valueOf(), b.valueOf()))) {
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
break;
|
|
373
|
+
case "Date":
|
|
374
|
+
if (!objectIs_default(a.valueOf(), b.valueOf())) {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
break;
|
|
378
|
+
case "Error":
|
|
379
|
+
return a.name === b.name && a.message === b.message;
|
|
380
|
+
case "RegExp":
|
|
381
|
+
if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
var idx = stackA.length - 1;
|
|
387
|
+
while (idx >= 0) {
|
|
388
|
+
if (stackA[idx] === a) {
|
|
389
|
+
return stackB[idx] === b;
|
|
390
|
+
}
|
|
391
|
+
idx -= 1;
|
|
392
|
+
}
|
|
393
|
+
switch (typeA) {
|
|
394
|
+
case "Map":
|
|
395
|
+
if (a.size !== b.size) {
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
|
|
399
|
+
case "Set":
|
|
400
|
+
if (a.size !== b.size) {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
|
|
404
|
+
case "Arguments":
|
|
405
|
+
case "Array":
|
|
406
|
+
case "Object":
|
|
407
|
+
case "Boolean":
|
|
408
|
+
case "Number":
|
|
409
|
+
case "String":
|
|
410
|
+
case "Date":
|
|
411
|
+
case "Error":
|
|
412
|
+
case "RegExp":
|
|
413
|
+
case "Int8Array":
|
|
414
|
+
case "Uint8Array":
|
|
415
|
+
case "Uint8ClampedArray":
|
|
416
|
+
case "Int16Array":
|
|
417
|
+
case "Uint16Array":
|
|
418
|
+
case "Int32Array":
|
|
419
|
+
case "Uint32Array":
|
|
420
|
+
case "Float32Array":
|
|
421
|
+
case "Float64Array":
|
|
422
|
+
case "ArrayBuffer":
|
|
423
|
+
break;
|
|
424
|
+
default:
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
var keysA = keys_default(a);
|
|
428
|
+
if (keysA.length !== keys_default(b).length) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
var extendedStackA = stackA.concat([a]);
|
|
432
|
+
var extendedStackB = stackB.concat([b]);
|
|
433
|
+
idx = keysA.length - 1;
|
|
434
|
+
while (idx >= 0) {
|
|
435
|
+
var key = keysA[idx];
|
|
436
|
+
if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
idx -= 1;
|
|
440
|
+
}
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/equals.js
|
|
445
|
+
var equals = /* @__PURE__ */ _curry2(function equals2(a, b) {
|
|
446
|
+
return _equals(a, b, [], []);
|
|
447
|
+
});
|
|
448
|
+
var equals_default = equals;
|
|
449
|
+
|
|
450
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_indexOf.js
|
|
451
|
+
function _indexOf(list, a, idx) {
|
|
452
|
+
var inf, item;
|
|
453
|
+
if (typeof list.indexOf === "function") {
|
|
454
|
+
switch (typeof a) {
|
|
455
|
+
case "number":
|
|
456
|
+
if (a === 0) {
|
|
457
|
+
inf = 1 / a;
|
|
458
|
+
while (idx < list.length) {
|
|
459
|
+
item = list[idx];
|
|
460
|
+
if (item === 0 && 1 / item === inf) {
|
|
461
|
+
return idx;
|
|
462
|
+
}
|
|
463
|
+
idx += 1;
|
|
464
|
+
}
|
|
465
|
+
return -1;
|
|
466
|
+
} else if (a !== a) {
|
|
467
|
+
while (idx < list.length) {
|
|
468
|
+
item = list[idx];
|
|
469
|
+
if (typeof item === "number" && item !== item) {
|
|
470
|
+
return idx;
|
|
471
|
+
}
|
|
472
|
+
idx += 1;
|
|
473
|
+
}
|
|
474
|
+
return -1;
|
|
475
|
+
}
|
|
476
|
+
return list.indexOf(a, idx);
|
|
477
|
+
// all these types can utilise Set
|
|
478
|
+
case "string":
|
|
479
|
+
case "boolean":
|
|
480
|
+
case "function":
|
|
481
|
+
case "undefined":
|
|
482
|
+
return list.indexOf(a, idx);
|
|
483
|
+
case "object":
|
|
484
|
+
if (a === null) {
|
|
485
|
+
return list.indexOf(a, idx);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
while (idx < list.length) {
|
|
490
|
+
if (equals_default(list[idx], a)) {
|
|
491
|
+
return idx;
|
|
492
|
+
}
|
|
493
|
+
idx += 1;
|
|
494
|
+
}
|
|
495
|
+
return -1;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_includes.js
|
|
499
|
+
function _includes(a, list) {
|
|
500
|
+
return _indexOf(list, a, 0) >= 0;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_map.js
|
|
504
|
+
function _map(fn, functor) {
|
|
505
|
+
var idx = 0;
|
|
506
|
+
var len = functor.length;
|
|
507
|
+
var result = Array(len);
|
|
508
|
+
while (idx < len) {
|
|
509
|
+
result[idx] = fn(functor[idx]);
|
|
510
|
+
idx += 1;
|
|
511
|
+
}
|
|
512
|
+
return result;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_quote.js
|
|
516
|
+
function _quote(s) {
|
|
517
|
+
var escaped = s.replace(/\\/g, "\\\\").replace(/[\b]/g, "\\b").replace(/\f/g, "\\f").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\v/g, "\\v").replace(/\0/g, "\\0");
|
|
518
|
+
return '"' + escaped.replace(/"/g, '\\"') + '"';
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_toISOString.js
|
|
522
|
+
var pad = function pad2(n) {
|
|
523
|
+
return (n < 10 ? "0" : "") + n;
|
|
524
|
+
};
|
|
525
|
+
var _toISOString = typeof Date.prototype.toISOString === "function" ? function _toISOString2(d) {
|
|
526
|
+
return d.toISOString();
|
|
527
|
+
} : function _toISOString3(d) {
|
|
528
|
+
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "." + (d.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5) + "Z";
|
|
529
|
+
};
|
|
530
|
+
var toISOString_default = _toISOString;
|
|
531
|
+
|
|
532
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_complement.js
|
|
533
|
+
function _complement(f) {
|
|
534
|
+
return function() {
|
|
535
|
+
return !f.apply(this, arguments);
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_arrayReduce.js
|
|
540
|
+
function _arrayReduce(reducer, acc, list) {
|
|
541
|
+
var index = 0;
|
|
542
|
+
var length = list.length;
|
|
543
|
+
while (index < length) {
|
|
544
|
+
acc = reducer(acc, list[index]);
|
|
545
|
+
index += 1;
|
|
546
|
+
}
|
|
547
|
+
return acc;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_filter.js
|
|
551
|
+
function _filter(fn, list) {
|
|
552
|
+
var idx = 0;
|
|
553
|
+
var len = list.length;
|
|
554
|
+
var result = [];
|
|
555
|
+
while (idx < len) {
|
|
556
|
+
if (fn(list[idx])) {
|
|
557
|
+
result[result.length] = list[idx];
|
|
558
|
+
}
|
|
559
|
+
idx += 1;
|
|
560
|
+
}
|
|
561
|
+
return result;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isObject.js
|
|
565
|
+
function _isObject(x) {
|
|
566
|
+
return Object.prototype.toString.call(x) === "[object Object]";
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_xfilter.js
|
|
570
|
+
var XFilter = /* @__PURE__ */ (function() {
|
|
571
|
+
function XFilter2(f, xf) {
|
|
572
|
+
this.xf = xf;
|
|
573
|
+
this.f = f;
|
|
574
|
+
}
|
|
575
|
+
XFilter2.prototype["@@transducer/init"] = xfBase_default.init;
|
|
576
|
+
XFilter2.prototype["@@transducer/result"] = xfBase_default.result;
|
|
577
|
+
XFilter2.prototype["@@transducer/step"] = function(result, input) {
|
|
578
|
+
return this.f(input) ? this.xf["@@transducer/step"](result, input) : result;
|
|
579
|
+
};
|
|
580
|
+
return XFilter2;
|
|
581
|
+
})();
|
|
582
|
+
function _xfilter(f) {
|
|
583
|
+
return function(xf) {
|
|
584
|
+
return new XFilter(f, xf);
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/filter.js
|
|
589
|
+
var filter = /* @__PURE__ */ _curry2(/* @__PURE__ */ _dispatchable(["fantasy-land/filter", "filter"], _xfilter, function(pred, filterable) {
|
|
590
|
+
return _isObject(filterable) ? _arrayReduce(function(acc, key) {
|
|
591
|
+
if (pred(filterable[key])) {
|
|
592
|
+
acc[key] = filterable[key];
|
|
593
|
+
}
|
|
594
|
+
return acc;
|
|
595
|
+
}, {}, keys_default(filterable)) : (
|
|
596
|
+
// else
|
|
597
|
+
_filter(pred, filterable)
|
|
598
|
+
);
|
|
599
|
+
}));
|
|
600
|
+
var filter_default = filter;
|
|
601
|
+
|
|
602
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/reject.js
|
|
603
|
+
var reject = /* @__PURE__ */ _curry2(function reject2(pred, filterable) {
|
|
604
|
+
return filter_default(_complement(pred), filterable);
|
|
605
|
+
});
|
|
606
|
+
var reject_default = reject;
|
|
607
|
+
|
|
608
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_toString.js
|
|
609
|
+
function _toString(x, seen) {
|
|
610
|
+
var recur = function recur2(y) {
|
|
611
|
+
var xs = seen.concat([x]);
|
|
612
|
+
return _includes(y, xs) ? "<Circular>" : _toString(y, xs);
|
|
613
|
+
};
|
|
614
|
+
var mapPairs = function(obj, keys4) {
|
|
615
|
+
return _map(function(k) {
|
|
616
|
+
return _quote(k) + ": " + recur(obj[k]);
|
|
617
|
+
}, keys4.slice().sort());
|
|
618
|
+
};
|
|
619
|
+
switch (Object.prototype.toString.call(x)) {
|
|
620
|
+
case "[object Arguments]":
|
|
621
|
+
return "(function() { return arguments; }(" + _map(recur, x).join(", ") + "))";
|
|
622
|
+
case "[object Array]":
|
|
623
|
+
return "[" + _map(recur, x).concat(mapPairs(x, reject_default(function(k) {
|
|
624
|
+
return /^\d+$/.test(k);
|
|
625
|
+
}, keys_default(x)))).join(", ") + "]";
|
|
626
|
+
case "[object Boolean]":
|
|
627
|
+
return typeof x === "object" ? "new Boolean(" + recur(x.valueOf()) + ")" : x.toString();
|
|
628
|
+
case "[object Date]":
|
|
629
|
+
return "new Date(" + (isNaN(x.valueOf()) ? recur(NaN) : _quote(toISOString_default(x))) + ")";
|
|
630
|
+
case "[object Map]":
|
|
631
|
+
return "new Map(" + recur(Array.from(x)) + ")";
|
|
632
|
+
case "[object Null]":
|
|
633
|
+
return "null";
|
|
634
|
+
case "[object Number]":
|
|
635
|
+
return typeof x === "object" ? "new Number(" + recur(x.valueOf()) + ")" : 1 / x === -Infinity ? "-0" : x.toString(10);
|
|
636
|
+
case "[object Set]":
|
|
637
|
+
return "new Set(" + recur(Array.from(x).sort()) + ")";
|
|
638
|
+
case "[object String]":
|
|
639
|
+
return typeof x === "object" ? "new String(" + recur(x.valueOf()) + ")" : _quote(x);
|
|
640
|
+
case "[object Undefined]":
|
|
641
|
+
return "undefined";
|
|
642
|
+
default:
|
|
643
|
+
if (typeof x.toString === "function") {
|
|
644
|
+
var repr = x.toString();
|
|
645
|
+
if (repr !== "[object Object]") {
|
|
646
|
+
return repr;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return "{" + mapPairs(x, keys_default(x)).join(", ") + "}";
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/toString.js
|
|
654
|
+
var toString2 = /* @__PURE__ */ _curry1(function toString3(val) {
|
|
655
|
+
return _toString(val, []);
|
|
656
|
+
});
|
|
657
|
+
var toString_default = toString2;
|
|
658
|
+
|
|
659
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/max.js
|
|
660
|
+
var max = /* @__PURE__ */ _curry2(function max2(a, b) {
|
|
661
|
+
if (a === b) {
|
|
662
|
+
return b;
|
|
663
|
+
}
|
|
664
|
+
function safeMax(x, y) {
|
|
665
|
+
if (x > y !== y > x) {
|
|
666
|
+
return y > x ? y : x;
|
|
667
|
+
}
|
|
668
|
+
return void 0;
|
|
669
|
+
}
|
|
670
|
+
var maxByValue = safeMax(a, b);
|
|
671
|
+
if (maxByValue !== void 0) {
|
|
672
|
+
return maxByValue;
|
|
673
|
+
}
|
|
674
|
+
var maxByType = safeMax(typeof a, typeof b);
|
|
675
|
+
if (maxByType !== void 0) {
|
|
676
|
+
return maxByType === typeof a ? a : b;
|
|
677
|
+
}
|
|
678
|
+
var stringA = toString_default(a);
|
|
679
|
+
var maxByStringValue = safeMax(stringA, toString_default(b));
|
|
680
|
+
if (maxByStringValue !== void 0) {
|
|
681
|
+
return maxByStringValue === stringA ? a : b;
|
|
682
|
+
}
|
|
683
|
+
return b;
|
|
684
|
+
});
|
|
685
|
+
var max_default = max;
|
|
686
|
+
|
|
687
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_xmap.js
|
|
688
|
+
var XMap = /* @__PURE__ */ (function() {
|
|
689
|
+
function XMap2(f, xf) {
|
|
690
|
+
this.xf = xf;
|
|
691
|
+
this.f = f;
|
|
692
|
+
}
|
|
693
|
+
XMap2.prototype["@@transducer/init"] = xfBase_default.init;
|
|
694
|
+
XMap2.prototype["@@transducer/result"] = xfBase_default.result;
|
|
695
|
+
XMap2.prototype["@@transducer/step"] = function(result, input) {
|
|
696
|
+
return this.xf["@@transducer/step"](result, this.f(input));
|
|
697
|
+
};
|
|
698
|
+
return XMap2;
|
|
699
|
+
})();
|
|
700
|
+
var _xmap = function _xmap2(f) {
|
|
701
|
+
return function(xf) {
|
|
702
|
+
return new XMap(f, xf);
|
|
703
|
+
};
|
|
704
|
+
};
|
|
705
|
+
var xmap_default = _xmap;
|
|
706
|
+
|
|
707
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/map.js
|
|
708
|
+
var map = /* @__PURE__ */ _curry2(/* @__PURE__ */ _dispatchable(["fantasy-land/map", "map"], xmap_default, function map2(fn, functor) {
|
|
709
|
+
switch (Object.prototype.toString.call(functor)) {
|
|
710
|
+
case "[object Function]":
|
|
711
|
+
return curryN_default(functor.length, function() {
|
|
712
|
+
return fn.call(this, functor.apply(this, arguments));
|
|
713
|
+
});
|
|
714
|
+
case "[object Object]":
|
|
715
|
+
return _arrayReduce(function(acc, key) {
|
|
716
|
+
acc[key] = fn(functor[key]);
|
|
717
|
+
return acc;
|
|
718
|
+
}, {}, keys_default(functor));
|
|
719
|
+
default:
|
|
720
|
+
return _map(fn, functor);
|
|
721
|
+
}
|
|
722
|
+
}));
|
|
723
|
+
var map_default = map;
|
|
724
|
+
|
|
725
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isInteger.js
|
|
726
|
+
var isInteger_default = Number.isInteger || function _isInteger(n) {
|
|
727
|
+
return n << 0 === n;
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isString.js
|
|
731
|
+
function _isString(x) {
|
|
732
|
+
return Object.prototype.toString.call(x) === "[object String]";
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_nth.js
|
|
736
|
+
function _nth(offset, list) {
|
|
737
|
+
var idx = offset < 0 ? list.length + offset : offset;
|
|
738
|
+
return _isString(list) ? list.charAt(idx) : list[idx];
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/prop.js
|
|
742
|
+
var prop = /* @__PURE__ */ _curry2(function prop2(p, obj) {
|
|
743
|
+
if (obj == null) {
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
return isInteger_default(p) ? _nth(p, obj) : obj[p];
|
|
747
|
+
});
|
|
748
|
+
var prop_default = prop;
|
|
749
|
+
|
|
750
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/pluck.js
|
|
751
|
+
var pluck = /* @__PURE__ */ _curry2(function pluck2(p, list) {
|
|
752
|
+
return map_default(prop_default(p), list);
|
|
753
|
+
});
|
|
754
|
+
var pluck_default = pluck;
|
|
755
|
+
|
|
756
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_curry3.js
|
|
757
|
+
function _curry3(fn) {
|
|
758
|
+
return function f3(a, b, c) {
|
|
759
|
+
switch (arguments.length) {
|
|
760
|
+
case 0:
|
|
761
|
+
return f3;
|
|
762
|
+
case 1:
|
|
763
|
+
return _isPlaceholder(a) ? f3 : _curry2(function(_b, _c) {
|
|
764
|
+
return fn(a, _b, _c);
|
|
765
|
+
});
|
|
766
|
+
case 2:
|
|
767
|
+
return _isPlaceholder(a) && _isPlaceholder(b) ? f3 : _isPlaceholder(a) ? _curry2(function(_a, _c) {
|
|
768
|
+
return fn(_a, b, _c);
|
|
769
|
+
}) : _isPlaceholder(b) ? _curry2(function(_b, _c) {
|
|
770
|
+
return fn(a, _b, _c);
|
|
771
|
+
}) : _curry1(function(_c) {
|
|
772
|
+
return fn(a, b, _c);
|
|
773
|
+
});
|
|
774
|
+
default:
|
|
775
|
+
return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3 : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function(_a, _b) {
|
|
776
|
+
return fn(_a, _b, c);
|
|
777
|
+
}) : _isPlaceholder(a) && _isPlaceholder(c) ? _curry2(function(_a, _c) {
|
|
778
|
+
return fn(_a, b, _c);
|
|
779
|
+
}) : _isPlaceholder(b) && _isPlaceholder(c) ? _curry2(function(_b, _c) {
|
|
780
|
+
return fn(a, _b, _c);
|
|
781
|
+
}) : _isPlaceholder(a) ? _curry1(function(_a) {
|
|
782
|
+
return fn(_a, b, c);
|
|
783
|
+
}) : _isPlaceholder(b) ? _curry1(function(_b) {
|
|
784
|
+
return fn(a, _b, c);
|
|
785
|
+
}) : _isPlaceholder(c) ? _curry1(function(_c) {
|
|
786
|
+
return fn(a, b, _c);
|
|
787
|
+
}) : fn(a, b, c);
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isArrayLike.js
|
|
793
|
+
var _isArrayLike = /* @__PURE__ */ _curry1(function isArrayLike(x) {
|
|
794
|
+
if (isArray_default(x)) {
|
|
795
|
+
return true;
|
|
796
|
+
}
|
|
797
|
+
if (!x) {
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
if (typeof x !== "object") {
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
if (_isString(x)) {
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
if (x.length === 0) {
|
|
807
|
+
return true;
|
|
808
|
+
}
|
|
809
|
+
if (x.length > 0) {
|
|
810
|
+
return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
|
|
811
|
+
}
|
|
812
|
+
return false;
|
|
813
|
+
});
|
|
814
|
+
var isArrayLike_default = _isArrayLike;
|
|
815
|
+
|
|
816
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_createReduce.js
|
|
817
|
+
var symIterator = typeof Symbol !== "undefined" ? Symbol.iterator : "@@iterator";
|
|
818
|
+
function _createReduce(arrayReduce, methodReduce, iterableReduce) {
|
|
819
|
+
return function _reduce2(xf, acc, list) {
|
|
820
|
+
if (isArrayLike_default(list)) {
|
|
821
|
+
return arrayReduce(xf, acc, list);
|
|
822
|
+
}
|
|
823
|
+
if (list == null) {
|
|
824
|
+
return acc;
|
|
825
|
+
}
|
|
826
|
+
if (typeof list["fantasy-land/reduce"] === "function") {
|
|
827
|
+
return methodReduce(xf, acc, list, "fantasy-land/reduce");
|
|
828
|
+
}
|
|
829
|
+
if (list[symIterator] != null) {
|
|
830
|
+
return iterableReduce(xf, acc, list[symIterator]());
|
|
831
|
+
}
|
|
832
|
+
if (typeof list.next === "function") {
|
|
833
|
+
return iterableReduce(xf, acc, list);
|
|
834
|
+
}
|
|
835
|
+
if (typeof list.reduce === "function") {
|
|
836
|
+
return methodReduce(xf, acc, list, "reduce");
|
|
837
|
+
}
|
|
838
|
+
throw new TypeError("reduce: list must be array or iterable");
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_xArrayReduce.js
|
|
843
|
+
function _xArrayReduce(xf, acc, list) {
|
|
844
|
+
var idx = 0;
|
|
845
|
+
var len = list.length;
|
|
846
|
+
while (idx < len) {
|
|
847
|
+
acc = xf["@@transducer/step"](acc, list[idx]);
|
|
848
|
+
if (acc && acc["@@transducer/reduced"]) {
|
|
849
|
+
acc = acc["@@transducer/value"];
|
|
850
|
+
break;
|
|
851
|
+
}
|
|
852
|
+
idx += 1;
|
|
853
|
+
}
|
|
854
|
+
return xf["@@transducer/result"](acc);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/bind.js
|
|
858
|
+
var bind = /* @__PURE__ */ _curry2(function bind2(fn, thisObj) {
|
|
859
|
+
return _arity(fn.length, function() {
|
|
860
|
+
return fn.apply(thisObj, arguments);
|
|
861
|
+
});
|
|
862
|
+
});
|
|
863
|
+
var bind_default = bind;
|
|
864
|
+
|
|
865
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_xReduce.js
|
|
866
|
+
function _xIterableReduce(xf, acc, iter) {
|
|
867
|
+
var step = iter.next();
|
|
868
|
+
while (!step.done) {
|
|
869
|
+
acc = xf["@@transducer/step"](acc, step.value);
|
|
870
|
+
if (acc && acc["@@transducer/reduced"]) {
|
|
871
|
+
acc = acc["@@transducer/value"];
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
step = iter.next();
|
|
875
|
+
}
|
|
876
|
+
return xf["@@transducer/result"](acc);
|
|
877
|
+
}
|
|
878
|
+
function _xMethodReduce(xf, acc, obj, methodName) {
|
|
879
|
+
return xf["@@transducer/result"](obj[methodName](bind_default(xf["@@transducer/step"], xf), acc));
|
|
880
|
+
}
|
|
881
|
+
var _xReduce = /* @__PURE__ */ _createReduce(_xArrayReduce, _xMethodReduce, _xIterableReduce);
|
|
882
|
+
var xReduce_default = _xReduce;
|
|
883
|
+
|
|
884
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_xwrap.js
|
|
885
|
+
var XWrap = /* @__PURE__ */ (function() {
|
|
886
|
+
function XWrap2(fn) {
|
|
887
|
+
this.f = fn;
|
|
888
|
+
}
|
|
889
|
+
XWrap2.prototype["@@transducer/init"] = function() {
|
|
890
|
+
throw new Error("init not implemented on XWrap");
|
|
891
|
+
};
|
|
892
|
+
XWrap2.prototype["@@transducer/result"] = function(acc) {
|
|
893
|
+
return acc;
|
|
894
|
+
};
|
|
895
|
+
XWrap2.prototype["@@transducer/step"] = function(acc, x) {
|
|
896
|
+
return this.f(acc, x);
|
|
897
|
+
};
|
|
898
|
+
return XWrap2;
|
|
899
|
+
})();
|
|
900
|
+
function _xwrap(fn) {
|
|
901
|
+
return new XWrap(fn);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/reduce.js
|
|
905
|
+
var reduce = /* @__PURE__ */ _curry3(function(xf, acc, list) {
|
|
906
|
+
return xReduce_default(typeof xf === "function" ? _xwrap(xf) : xf, acc, list);
|
|
907
|
+
});
|
|
908
|
+
var reduce_default = reduce;
|
|
909
|
+
|
|
910
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/allPass.js
|
|
911
|
+
var allPass = /* @__PURE__ */ _curry1(function allPass2(preds) {
|
|
912
|
+
return curryN_default(reduce_default(max_default, 0, pluck_default("length", preds)), function() {
|
|
913
|
+
var idx = 0;
|
|
914
|
+
var len = preds.length;
|
|
915
|
+
while (idx < len) {
|
|
916
|
+
if (!preds[idx].apply(this, arguments)) {
|
|
917
|
+
return false;
|
|
918
|
+
}
|
|
919
|
+
idx += 1;
|
|
920
|
+
}
|
|
921
|
+
return true;
|
|
922
|
+
});
|
|
923
|
+
});
|
|
924
|
+
var allPass_default = allPass;
|
|
925
|
+
|
|
926
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/always.js
|
|
927
|
+
var always = /* @__PURE__ */ _curry1(function always2(val) {
|
|
928
|
+
return function() {
|
|
929
|
+
return val;
|
|
930
|
+
};
|
|
931
|
+
});
|
|
932
|
+
var always_default = always;
|
|
933
|
+
|
|
934
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_concat.js
|
|
935
|
+
function _concat(set1, set2) {
|
|
936
|
+
set1 = set1 || [];
|
|
937
|
+
set2 = set2 || [];
|
|
938
|
+
var idx;
|
|
939
|
+
var len1 = set1.length;
|
|
940
|
+
var len2 = set2.length;
|
|
941
|
+
var result = [];
|
|
942
|
+
idx = 0;
|
|
943
|
+
while (idx < len1) {
|
|
944
|
+
result[result.length] = set1[idx];
|
|
945
|
+
idx += 1;
|
|
946
|
+
}
|
|
947
|
+
idx = 0;
|
|
948
|
+
while (idx < len2) {
|
|
949
|
+
result[result.length] = set2[idx];
|
|
950
|
+
idx += 1;
|
|
951
|
+
}
|
|
952
|
+
return result;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_reduce.js
|
|
956
|
+
function _iterableReduce(reducer, acc, iter) {
|
|
957
|
+
var step = iter.next();
|
|
958
|
+
while (!step.done) {
|
|
959
|
+
acc = reducer(acc, step.value);
|
|
960
|
+
step = iter.next();
|
|
961
|
+
}
|
|
962
|
+
return acc;
|
|
963
|
+
}
|
|
964
|
+
function _methodReduce(reducer, acc, obj, methodName) {
|
|
965
|
+
return obj[methodName](reducer, acc);
|
|
966
|
+
}
|
|
967
|
+
var _reduce = /* @__PURE__ */ _createReduce(_arrayReduce, _methodReduce, _iterableReduce);
|
|
968
|
+
var reduce_default2 = _reduce;
|
|
969
|
+
|
|
970
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/ap.js
|
|
971
|
+
var ap = /* @__PURE__ */ _curry2(function ap2(applyF, applyX) {
|
|
972
|
+
return typeof applyX["fantasy-land/ap"] === "function" ? applyX["fantasy-land/ap"](applyF) : typeof applyF.ap === "function" ? applyF.ap(applyX) : typeof applyF === "function" ? function(x) {
|
|
973
|
+
return applyF(x)(applyX(x));
|
|
974
|
+
} : reduce_default2(function(acc, f) {
|
|
975
|
+
return _concat(acc, map_default(f, applyX));
|
|
976
|
+
}, [], applyF);
|
|
977
|
+
});
|
|
978
|
+
var ap_default = ap;
|
|
979
|
+
|
|
980
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/liftN.js
|
|
981
|
+
var liftN = /* @__PURE__ */ _curry2(function liftN2(arity, fn) {
|
|
982
|
+
var lifted = curryN_default(arity, fn);
|
|
983
|
+
return curryN_default(arity, function() {
|
|
984
|
+
return _arrayReduce(ap_default, map_default(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1));
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
var liftN_default = liftN;
|
|
988
|
+
|
|
989
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/lift.js
|
|
990
|
+
var lift = /* @__PURE__ */ _curry1(function lift2(fn) {
|
|
991
|
+
return liftN_default(fn.length, fn);
|
|
992
|
+
});
|
|
993
|
+
var lift_default = lift;
|
|
994
|
+
|
|
995
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/not.js
|
|
996
|
+
var not = /* @__PURE__ */ _curry1(function not2(a) {
|
|
997
|
+
return !a;
|
|
998
|
+
});
|
|
999
|
+
var not_default = not;
|
|
1000
|
+
|
|
1001
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/complement.js
|
|
1002
|
+
var complement = /* @__PURE__ */ lift_default(not_default);
|
|
1003
|
+
var complement_default = complement;
|
|
1004
|
+
|
|
1005
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/cond.js
|
|
1006
|
+
var cond = /* @__PURE__ */ _curry1(function cond2(pairs) {
|
|
1007
|
+
var arity = reduce_default(max_default, 0, map_default(function(pair) {
|
|
1008
|
+
return pair[0].length;
|
|
1009
|
+
}, pairs));
|
|
1010
|
+
return _arity(arity, function() {
|
|
1011
|
+
var idx = 0;
|
|
1012
|
+
while (idx < pairs.length) {
|
|
1013
|
+
if (pairs[idx][0].apply(this, arguments)) {
|
|
1014
|
+
return pairs[idx][1].apply(this, arguments);
|
|
1015
|
+
}
|
|
1016
|
+
idx += 1;
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
});
|
|
1020
|
+
var cond_default = cond;
|
|
1021
|
+
|
|
1022
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/defaultTo.js
|
|
1023
|
+
var defaultTo = /* @__PURE__ */ _curry2(function defaultTo2(d, v) {
|
|
1024
|
+
return v == null || v !== v ? d : v;
|
|
1025
|
+
});
|
|
1026
|
+
var defaultTo_default = defaultTo;
|
|
1027
|
+
|
|
1028
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_xfindIndex.js
|
|
1029
|
+
var XFindIndex = /* @__PURE__ */ (function() {
|
|
1030
|
+
function XFindIndex2(f, xf) {
|
|
1031
|
+
this.xf = xf;
|
|
1032
|
+
this.f = f;
|
|
1033
|
+
this.idx = -1;
|
|
1034
|
+
this.found = false;
|
|
1035
|
+
}
|
|
1036
|
+
XFindIndex2.prototype["@@transducer/init"] = xfBase_default.init;
|
|
1037
|
+
XFindIndex2.prototype["@@transducer/result"] = function(result) {
|
|
1038
|
+
if (!this.found) {
|
|
1039
|
+
result = this.xf["@@transducer/step"](result, -1);
|
|
1040
|
+
}
|
|
1041
|
+
return this.xf["@@transducer/result"](result);
|
|
1042
|
+
};
|
|
1043
|
+
XFindIndex2.prototype["@@transducer/step"] = function(result, input) {
|
|
1044
|
+
this.idx += 1;
|
|
1045
|
+
if (this.f(input)) {
|
|
1046
|
+
this.found = true;
|
|
1047
|
+
result = _reduced(this.xf["@@transducer/step"](result, this.idx));
|
|
1048
|
+
}
|
|
1049
|
+
return result;
|
|
1050
|
+
};
|
|
1051
|
+
return XFindIndex2;
|
|
1052
|
+
})();
|
|
1053
|
+
function _xfindIndex(f) {
|
|
1054
|
+
return function(xf) {
|
|
1055
|
+
return new XFindIndex(f, xf);
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/findIndex.js
|
|
1060
|
+
var findIndex = /* @__PURE__ */ _curry2(/* @__PURE__ */ _dispatchable([], _xfindIndex, function findIndex2(fn, list) {
|
|
1061
|
+
var idx = 0;
|
|
1062
|
+
var len = list.length;
|
|
1063
|
+
while (idx < len) {
|
|
1064
|
+
if (fn(list[idx])) {
|
|
1065
|
+
return idx;
|
|
1066
|
+
}
|
|
1067
|
+
idx += 1;
|
|
1068
|
+
}
|
|
1069
|
+
return -1;
|
|
1070
|
+
}));
|
|
1071
|
+
var findIndex_default = findIndex;
|
|
1072
|
+
|
|
1073
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/ifElse.js
|
|
1074
|
+
var ifElse = /* @__PURE__ */ _curry3(function ifElse2(condition, onTrue, onFalse) {
|
|
1075
|
+
return curryN_default(Math.max(condition.length, onTrue.length, onFalse.length), function _ifElse() {
|
|
1076
|
+
return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments);
|
|
1077
|
+
});
|
|
1078
|
+
});
|
|
1079
|
+
var ifElse_default = ifElse;
|
|
1080
|
+
|
|
1081
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_checkForMethod.js
|
|
1082
|
+
function _checkForMethod(methodname, fn) {
|
|
1083
|
+
return function() {
|
|
1084
|
+
var length = arguments.length;
|
|
1085
|
+
if (length === 0) {
|
|
1086
|
+
return fn();
|
|
1087
|
+
}
|
|
1088
|
+
var obj = arguments[length - 1];
|
|
1089
|
+
return isArray_default(obj) || typeof obj[methodname] !== "function" ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/slice.js
|
|
1094
|
+
var slice = /* @__PURE__ */ _curry3(/* @__PURE__ */ _checkForMethod("slice", function slice2(fromIndex, toIndex, list) {
|
|
1095
|
+
return Array.prototype.slice.call(list, fromIndex, toIndex);
|
|
1096
|
+
}));
|
|
1097
|
+
var slice_default = slice;
|
|
1098
|
+
|
|
1099
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isTypedArray.js
|
|
1100
|
+
function _isTypedArray(val) {
|
|
1101
|
+
var type3 = Object.prototype.toString.call(val);
|
|
1102
|
+
return type3 === "[object Uint8ClampedArray]" || type3 === "[object Int8Array]" || type3 === "[object Uint8Array]" || type3 === "[object Int16Array]" || type3 === "[object Uint16Array]" || type3 === "[object Int32Array]" || type3 === "[object Uint32Array]" || type3 === "[object Float32Array]" || type3 === "[object Float64Array]" || type3 === "[object BigInt64Array]" || type3 === "[object BigUint64Array]";
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/empty.js
|
|
1106
|
+
var empty = /* @__PURE__ */ _curry1(function empty2(x) {
|
|
1107
|
+
return x != null && typeof x["fantasy-land/empty"] === "function" ? x["fantasy-land/empty"]() : x != null && x.constructor != null && typeof x.constructor["fantasy-land/empty"] === "function" ? x.constructor["fantasy-land/empty"]() : x != null && typeof x.empty === "function" ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === "function" ? x.constructor.empty() : isArray_default(x) ? [] : _isString(x) ? "" : _isObject(x) ? {} : isArguments_default(x) ? /* @__PURE__ */ (function() {
|
|
1108
|
+
return arguments;
|
|
1109
|
+
})() : _isTypedArray(x) ? x.constructor.from("") : void 0;
|
|
1110
|
+
});
|
|
1111
|
+
var empty_default = empty;
|
|
1112
|
+
|
|
1113
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/isEmpty.js
|
|
1114
|
+
var isEmpty = /* @__PURE__ */ _curry1(function isEmpty2(x) {
|
|
1115
|
+
return x != null && equals_default(x, empty_default(x));
|
|
1116
|
+
});
|
|
1117
|
+
var isEmpty_default = isEmpty;
|
|
1118
|
+
|
|
1119
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/isNil.js
|
|
1120
|
+
var isNil = /* @__PURE__ */ _curry1(function isNil2(x) {
|
|
1121
|
+
return x == null;
|
|
1122
|
+
});
|
|
1123
|
+
var isNil_default = isNil;
|
|
1124
|
+
|
|
1125
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_pipe.js
|
|
1126
|
+
function _pipe(f, g) {
|
|
1127
|
+
return function() {
|
|
1128
|
+
return g.call(this, f.apply(this, arguments));
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/tail.js
|
|
1133
|
+
var tail = /* @__PURE__ */ _curry1(/* @__PURE__ */ _checkForMethod("tail", /* @__PURE__ */ slice_default(1, Infinity)));
|
|
1134
|
+
var tail_default = tail;
|
|
1135
|
+
|
|
1136
|
+
// node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/pipe.js
|
|
1137
|
+
function pipe() {
|
|
1138
|
+
if (arguments.length === 0) {
|
|
1139
|
+
throw new Error("pipe requires at least one argument");
|
|
1140
|
+
}
|
|
1141
|
+
return _arity(arguments[0].length, reduce_default(_pipe, arguments[0], tail_default(arguments)));
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// src/shared/className.ts
|
|
1145
|
+
var isPresentClassName = (value) => value.trim().length > 0;
|
|
1146
|
+
var classNames = (values) => filter_default(isPresentClassName, [...values]).join(" ");
|
|
1147
|
+
|
|
1148
|
+
// src/shared/option.ts
|
|
1149
|
+
var none = { status: "none" };
|
|
1150
|
+
function some(value) {
|
|
1151
|
+
return { status: "some", value };
|
|
1152
|
+
}
|
|
1153
|
+
var isSome = (option) => option.status === "some";
|
|
1154
|
+
var isNone = (option) => option.status === "none";
|
|
1155
|
+
var fromNullable = (value) => ifElse_default(
|
|
1156
|
+
isNil_default,
|
|
1157
|
+
always_default(none),
|
|
1158
|
+
some
|
|
1159
|
+
)(value);
|
|
1160
|
+
var getOrElse = (fallback) => (option) => ifElse_default(
|
|
1161
|
+
isSome,
|
|
1162
|
+
(someOption) => someOption.value,
|
|
1163
|
+
always_default(fallback)
|
|
1164
|
+
)(option);
|
|
1165
|
+
function matchOption(option, matcher) {
|
|
1166
|
+
return ifElse_default(
|
|
1167
|
+
isSome,
|
|
1168
|
+
(someOption) => matcher.some(someOption.value),
|
|
1169
|
+
matcher.none
|
|
1170
|
+
)(option);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// src/shared/number.ts
|
|
1174
|
+
var isNumber = (value) => typeof value === "number";
|
|
1175
|
+
var withNumberDefault = (fallback) => (value) => matchOption(fromNullable(value), {
|
|
1176
|
+
none: () => fallback,
|
|
1177
|
+
some: (resolvedValue) => ifElse_default(
|
|
1178
|
+
isNumber,
|
|
1179
|
+
(numberValue) => defaultTo_default(fallback, numberValue),
|
|
1180
|
+
always_default(fallback)
|
|
1181
|
+
)(resolvedValue)
|
|
1182
|
+
});
|
|
1183
|
+
|
|
1184
|
+
// src/shared/result.ts
|
|
1185
|
+
function ok(value) {
|
|
1186
|
+
return { status: "ok", value };
|
|
1187
|
+
}
|
|
1188
|
+
function err(error) {
|
|
1189
|
+
return { status: "error", error };
|
|
1190
|
+
}
|
|
1191
|
+
var isOk = (result) => result.status === "ok";
|
|
1192
|
+
var andThenResult = (transform) => (result) => matchResult(result, {
|
|
1193
|
+
error: err,
|
|
1194
|
+
ok: transform
|
|
1195
|
+
});
|
|
1196
|
+
var mapResult = (transform) => (result) => andThenResult((value) => ok(transform(value)))(result);
|
|
1197
|
+
var bindResult = (transform, merge) => (result) => andThenResult(
|
|
1198
|
+
(context) => mapResult((value) => merge(context, value))(
|
|
1199
|
+
transform(context)
|
|
1200
|
+
)
|
|
1201
|
+
)(result);
|
|
1202
|
+
function matchResult(result, matcher) {
|
|
1203
|
+
return ifElse_default(
|
|
1204
|
+
isOk,
|
|
1205
|
+
(okResult) => matcher.ok(okResult.value),
|
|
1206
|
+
(errorResult) => matcher.error(errorResult.error)
|
|
1207
|
+
)(result);
|
|
1208
|
+
}
|
|
1209
|
+
var renderDetails = (details) => matchOption(details, {
|
|
1210
|
+
none: () => null,
|
|
1211
|
+
some: (value) => /* @__PURE__ */ jsx("p", { className: "pristine-chart-error__details", children: value })
|
|
1212
|
+
});
|
|
1213
|
+
function ChartError({
|
|
1214
|
+
title,
|
|
1215
|
+
message,
|
|
1216
|
+
details,
|
|
1217
|
+
className,
|
|
1218
|
+
role
|
|
1219
|
+
}) {
|
|
1220
|
+
return /* @__PURE__ */ jsxs("div", { className: classNames(["pristine-chart-error", className]), role, children: [
|
|
1221
|
+
/* @__PURE__ */ jsx("p", { className: "pristine-chart-error__title", children: title }),
|
|
1222
|
+
/* @__PURE__ */ jsx("p", { className: "pristine-chart-error__message", children: message }),
|
|
1223
|
+
renderDetails(details)
|
|
1224
|
+
] });
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
// src/bar-chart/BarChart.domain.ts
|
|
1228
|
+
var DEFAULT_BAR_CHART_ORDER_STRATEGY = {
|
|
1229
|
+
kind: "insertion"
|
|
1230
|
+
};
|
|
1231
|
+
var VALUE_ORDER_FALLBACK = "ascending";
|
|
1232
|
+
var barChartRules = {
|
|
1233
|
+
emptyDataset: () => ({
|
|
1234
|
+
type: "EmptyDataset",
|
|
1235
|
+
message: "A bar chart needs at least one category.",
|
|
1236
|
+
details: none
|
|
1237
|
+
}),
|
|
1238
|
+
invalidValue: (index) => ({
|
|
1239
|
+
type: "InvalidValue",
|
|
1240
|
+
message: "Every bar chart value must be a finite number.",
|
|
1241
|
+
details: some(`Invalid value at index ${String(index)}.`)
|
|
1242
|
+
}),
|
|
1243
|
+
duplicateCategory: (category) => ({
|
|
1244
|
+
type: "DuplicateCategory",
|
|
1245
|
+
message: "Bar chart categories must be unique.",
|
|
1246
|
+
details: some(`Duplicate category: ${category}.`)
|
|
1247
|
+
}),
|
|
1248
|
+
emptyCategoryName: (index) => ({
|
|
1249
|
+
type: "EmptyCategoryName",
|
|
1250
|
+
message: "Every bar chart category needs a non-empty name.",
|
|
1251
|
+
details: some(`Empty category at index ${String(index)}.`)
|
|
1252
|
+
}),
|
|
1253
|
+
missingValueSortDirection: () => ({
|
|
1254
|
+
type: "MissingValueSortDirection",
|
|
1255
|
+
message: "Sorting by value requires an ascending or descending direction.",
|
|
1256
|
+
details: none
|
|
1257
|
+
}),
|
|
1258
|
+
missingCategoriesInCustomOrder: (categories) => ({
|
|
1259
|
+
type: "MissingCategoriesInCustomOrder",
|
|
1260
|
+
message: "Custom bar chart ordering must include every category.",
|
|
1261
|
+
details: some(`Missing categories: ${categories.join(", ")}.`)
|
|
1262
|
+
})
|
|
1263
|
+
};
|
|
1264
|
+
var isFiniteNumber = (value) => allPass_default([
|
|
1265
|
+
(candidate) => typeof candidate === "number",
|
|
1266
|
+
(candidate) => Number.isFinite(candidate)
|
|
1267
|
+
])(value);
|
|
1268
|
+
var isNonEmptyString = (value) => value.trim().length > 0;
|
|
1269
|
+
var getCategories = (data) => map_default(prop_default("category"), [...data]);
|
|
1270
|
+
var getValues = (data) => map_default(prop_default("value"), [...data]);
|
|
1271
|
+
var hasOnlyFiniteValues = (data) => all_default(isFiniteNumber, getValues(data));
|
|
1272
|
+
var findInvalidValueIndex = (data) => findIndex_default(complement_default(isFiniteNumber), getValues(data));
|
|
1273
|
+
var findEmptyCategoryIndex = (data) => findIndex_default(complement_default(isNonEmptyString), getCategories(data));
|
|
1274
|
+
var hasOnlyNamedCategories = (data) => all_default(isNonEmptyString, getCategories(data));
|
|
1275
|
+
var hasUniqueCategories = (data) => {
|
|
1276
|
+
const categories = getCategories(data);
|
|
1277
|
+
return categories.length === new Set(categories).size;
|
|
1278
|
+
};
|
|
1279
|
+
var findDuplicateCategory = (data) => {
|
|
1280
|
+
const categories = getCategories(data);
|
|
1281
|
+
return defaultTo_default(
|
|
1282
|
+
"unknown category",
|
|
1283
|
+
categories.find((category, index) => categories.indexOf(category) !== index)
|
|
1284
|
+
);
|
|
1285
|
+
};
|
|
1286
|
+
var isByValueOrderStrategy = (strategy) => strategy.kind === "value";
|
|
1287
|
+
var isCustomOrderStrategy = (strategy) => strategy.kind === "custom";
|
|
1288
|
+
var getValueOrderDirection = (strategy) => ifElse_default(
|
|
1289
|
+
isByValueOrderStrategy,
|
|
1290
|
+
(valueStrategy) => fromNullable(valueStrategy.direction),
|
|
1291
|
+
always_default(some(VALUE_ORDER_FALLBACK))
|
|
1292
|
+
)(strategy);
|
|
1293
|
+
var isMissingValueSortDirection = (strategy) => allPass_default([
|
|
1294
|
+
isByValueOrderStrategy,
|
|
1295
|
+
pipe(getValueOrderDirection, isNone)
|
|
1296
|
+
])(strategy);
|
|
1297
|
+
var getCustomOrderCategories = (strategy) => ifElse_default(
|
|
1298
|
+
isCustomOrderStrategy,
|
|
1299
|
+
(customStrategy) => customStrategy.categories,
|
|
1300
|
+
always_default([])
|
|
1301
|
+
)(strategy);
|
|
1302
|
+
var includesCategory = (categories) => (category) => categories.includes(category);
|
|
1303
|
+
var getMissingCustomCategories = (data, strategy) => filter_default(
|
|
1304
|
+
complement_default(includesCategory(getCustomOrderCategories(strategy))),
|
|
1305
|
+
getCategories(data)
|
|
1306
|
+
);
|
|
1307
|
+
var isMissingCustomCategories = (input) => allPass_default([
|
|
1308
|
+
(candidate) => isCustomOrderStrategy(candidate.orderStrategy),
|
|
1309
|
+
(candidate) => complement_default(isEmpty_default)(getMissingCustomCategories(candidate.data, candidate.orderStrategy))
|
|
1310
|
+
])(input);
|
|
1311
|
+
var datasetValidators = [
|
|
1312
|
+
[isEmpty_default, () => err(barChartRules.emptyDataset())],
|
|
1313
|
+
[
|
|
1314
|
+
complement_default(hasOnlyFiniteValues),
|
|
1315
|
+
(candidate) => err(barChartRules.invalidValue(findInvalidValueIndex(candidate)))
|
|
1316
|
+
],
|
|
1317
|
+
[
|
|
1318
|
+
complement_default(hasOnlyNamedCategories),
|
|
1319
|
+
(candidate) => err(barChartRules.emptyCategoryName(findEmptyCategoryIndex(candidate)))
|
|
1320
|
+
],
|
|
1321
|
+
[
|
|
1322
|
+
complement_default(hasUniqueCategories),
|
|
1323
|
+
(candidate) => err(barChartRules.duplicateCategory(findDuplicateCategory(candidate)))
|
|
1324
|
+
],
|
|
1325
|
+
[always_default(true), (candidate) => ok(candidate)]
|
|
1326
|
+
];
|
|
1327
|
+
var validateDataset = cond_default(datasetValidators);
|
|
1328
|
+
var orderStrategyValidators = [
|
|
1329
|
+
[
|
|
1330
|
+
(candidate) => isMissingValueSortDirection(candidate.orderStrategy),
|
|
1331
|
+
() => err(barChartRules.missingValueSortDirection())
|
|
1332
|
+
],
|
|
1333
|
+
[
|
|
1334
|
+
isMissingCustomCategories,
|
|
1335
|
+
(candidate) => err(
|
|
1336
|
+
barChartRules.missingCategoriesInCustomOrder(
|
|
1337
|
+
getMissingCustomCategories(candidate.data, candidate.orderStrategy)
|
|
1338
|
+
)
|
|
1339
|
+
)
|
|
1340
|
+
],
|
|
1341
|
+
[always_default(true), (candidate) => ok(candidate.orderStrategy)]
|
|
1342
|
+
];
|
|
1343
|
+
var validateOrderStrategy = cond_default(orderStrategyValidators);
|
|
1344
|
+
function validateBarChartInput(input) {
|
|
1345
|
+
return bindResult(
|
|
1346
|
+
() => validateOrderStrategy(input),
|
|
1347
|
+
(context, orderStrategy) => ({ ...context, orderStrategy })
|
|
1348
|
+
)(
|
|
1349
|
+
bindResult(
|
|
1350
|
+
() => validateDataset(input.data),
|
|
1351
|
+
(_, data) => ({ data })
|
|
1352
|
+
)(ok({}))
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
var byCategory = (left, right) => left.category.localeCompare(right.category);
|
|
1356
|
+
var byAscendingValue = (left, right) => left.value - right.value;
|
|
1357
|
+
var byDescendingValue = (left, right) => right.value - left.value;
|
|
1358
|
+
var byCustomOrder = (categories) => (left, right) => categories.indexOf(left.category) - categories.indexOf(right.category);
|
|
1359
|
+
var isAlphabeticalOrderStrategy = (strategy) => strategy.kind === "alphabetical";
|
|
1360
|
+
var isInsertionOrderStrategy = (strategy) => strategy.kind === "insertion";
|
|
1361
|
+
var isAscendingSortDirection = (direction) => direction === "ascending";
|
|
1362
|
+
var getOrderedData = (data, orderStrategy) => cond_default([
|
|
1363
|
+
[isInsertionOrderStrategy, always_default([...data])],
|
|
1364
|
+
[isAlphabeticalOrderStrategy, always_default([...data].sort(byCategory))],
|
|
1365
|
+
[
|
|
1366
|
+
isByValueOrderStrategy,
|
|
1367
|
+
(strategy) => ifElse_default(
|
|
1368
|
+
isAscendingSortDirection,
|
|
1369
|
+
always_default([...data].sort(byAscendingValue)),
|
|
1370
|
+
always_default([...data].sort(byDescendingValue))
|
|
1371
|
+
)(getOrElse(VALUE_ORDER_FALLBACK)(getValueOrderDirection(strategy)))
|
|
1372
|
+
],
|
|
1373
|
+
[
|
|
1374
|
+
isCustomOrderStrategy,
|
|
1375
|
+
(strategy) => [...data].sort(byCustomOrder(strategy.categories))
|
|
1376
|
+
]
|
|
1377
|
+
])(orderStrategy);
|
|
1378
|
+
var POSITIVE_DIRECTION = "positive";
|
|
1379
|
+
var NEGATIVE_DIRECTION = "negative";
|
|
1380
|
+
var ZERO_DIRECTION = "zero";
|
|
1381
|
+
var barDirectionRules = [
|
|
1382
|
+
[(candidate) => candidate > 0, always_default(POSITIVE_DIRECTION)],
|
|
1383
|
+
[(candidate) => candidate < 0, always_default(NEGATIVE_DIRECTION)],
|
|
1384
|
+
[always_default(true), always_default(ZERO_DIRECTION)]
|
|
1385
|
+
];
|
|
1386
|
+
var getBarDirection = cond_default(barDirectionRules);
|
|
1387
|
+
var toBar = (datum) => ({
|
|
1388
|
+
...datum,
|
|
1389
|
+
direction: getBarDirection(datum.value)
|
|
1390
|
+
});
|
|
1391
|
+
var computeBars = (input) => map_default(toBar, getOrderedData(input.data, input.orderStrategy));
|
|
1392
|
+
function computeBarChart(input) {
|
|
1393
|
+
return mapResult(computeBars)(
|
|
1394
|
+
validateBarChartInput(input)
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
var BAR_CHART_MARGIN = {
|
|
1398
|
+
top: 24,
|
|
1399
|
+
right: 16,
|
|
1400
|
+
bottom: 42,
|
|
1401
|
+
left: 42
|
|
1402
|
+
};
|
|
1403
|
+
var getMinValue = (bars) => withNumberDefault(0)(min(map_default(prop_default("value"), [...bars])));
|
|
1404
|
+
var getMaxValue = (bars) => withNumberDefault(0)(max$1(map_default(prop_default("value"), [...bars])));
|
|
1405
|
+
var getLowerDomain = (bars) => Math.min(0, getMinValue(bars));
|
|
1406
|
+
var getUpperDomain = (bars) => Math.max(0, getMaxValue(bars));
|
|
1407
|
+
var getCategory = (bar) => bar.category;
|
|
1408
|
+
var getValueY = (plotBottom) => (bar, y, height) => ifElse_default(
|
|
1409
|
+
(candidate) => candidate.direction === "negative",
|
|
1410
|
+
always_default(Math.min(plotBottom - 6, y + height + 12)),
|
|
1411
|
+
always_default(Math.max(BAR_CHART_MARGIN.top + 10, y - 6))
|
|
1412
|
+
)(bar);
|
|
1413
|
+
var buildBarChartModel = (bars, width, height) => {
|
|
1414
|
+
const plotBottom = height - BAR_CHART_MARGIN.bottom;
|
|
1415
|
+
const xScale = scaleBand().domain(map_default(getCategory, [...bars])).range([BAR_CHART_MARGIN.left, width - BAR_CHART_MARGIN.right]).padding(0.22);
|
|
1416
|
+
const yScale = scaleLinear().domain([getLowerDomain(bars), getUpperDomain(bars)]).nice().range([plotBottom, BAR_CHART_MARGIN.top]);
|
|
1417
|
+
const baselineY = yScale(0);
|
|
1418
|
+
const toRenderedBar = (bar) => {
|
|
1419
|
+
const y = Math.min(yScale(bar.value), baselineY);
|
|
1420
|
+
const barHeight = Math.abs(baselineY - yScale(bar.value));
|
|
1421
|
+
return {
|
|
1422
|
+
...bar,
|
|
1423
|
+
x: withNumberDefault(BAR_CHART_MARGIN.left)(xScale(bar.category)),
|
|
1424
|
+
y,
|
|
1425
|
+
width: xScale.bandwidth(),
|
|
1426
|
+
height: barHeight,
|
|
1427
|
+
valueY: getValueY(plotBottom)(bar, y, barHeight)
|
|
1428
|
+
};
|
|
1429
|
+
};
|
|
1430
|
+
return {
|
|
1431
|
+
baselineY,
|
|
1432
|
+
plotBottom,
|
|
1433
|
+
yTicks: yScale.ticks(5),
|
|
1434
|
+
bars: map_default(toRenderedBar, [...bars]),
|
|
1435
|
+
yScale
|
|
1436
|
+
};
|
|
1437
|
+
};
|
|
1438
|
+
function BarChartCaption({ caption }) {
|
|
1439
|
+
return matchOption(caption, {
|
|
1440
|
+
none: () => null,
|
|
1441
|
+
some: (value) => /* @__PURE__ */ jsx("figcaption", { className: "pristine-bar-chart__caption", children: value })
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
function BarChartAxes({ chart, width }) {
|
|
1445
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1446
|
+
/* @__PURE__ */ jsx(
|
|
1447
|
+
"line",
|
|
1448
|
+
{
|
|
1449
|
+
className: "pristine-bar-chart__axis",
|
|
1450
|
+
x1: BAR_CHART_MARGIN.left,
|
|
1451
|
+
x2: width - BAR_CHART_MARGIN.right,
|
|
1452
|
+
y1: chart.baselineY,
|
|
1453
|
+
y2: chart.baselineY
|
|
1454
|
+
}
|
|
1455
|
+
),
|
|
1456
|
+
/* @__PURE__ */ jsx(
|
|
1457
|
+
"line",
|
|
1458
|
+
{
|
|
1459
|
+
className: "pristine-bar-chart__axis",
|
|
1460
|
+
x1: BAR_CHART_MARGIN.left,
|
|
1461
|
+
x2: BAR_CHART_MARGIN.left,
|
|
1462
|
+
y1: BAR_CHART_MARGIN.top,
|
|
1463
|
+
y2: chart.plotBottom
|
|
1464
|
+
}
|
|
1465
|
+
)
|
|
1466
|
+
] });
|
|
1467
|
+
}
|
|
1468
|
+
var getHitAreaY = ifElse_default(
|
|
1469
|
+
(bar) => bar.height > 0,
|
|
1470
|
+
(bar) => bar.y,
|
|
1471
|
+
(bar) => bar.y - 4
|
|
1472
|
+
);
|
|
1473
|
+
function BarChartBar({ bar }) {
|
|
1474
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1475
|
+
/* @__PURE__ */ jsx(
|
|
1476
|
+
"rect",
|
|
1477
|
+
{
|
|
1478
|
+
className: `pristine-bar-chart__bar pristine-bar-chart__bar--${bar.direction}`,
|
|
1479
|
+
x: bar.x,
|
|
1480
|
+
y: bar.y,
|
|
1481
|
+
width: bar.width,
|
|
1482
|
+
height: bar.height,
|
|
1483
|
+
"aria-hidden": "true"
|
|
1484
|
+
}
|
|
1485
|
+
),
|
|
1486
|
+
/* @__PURE__ */ jsx(
|
|
1487
|
+
"rect",
|
|
1488
|
+
{
|
|
1489
|
+
className: "pristine-bar-chart__bar-hit-area",
|
|
1490
|
+
x: bar.x,
|
|
1491
|
+
y: getHitAreaY(bar),
|
|
1492
|
+
width: bar.width,
|
|
1493
|
+
height: Math.max(bar.height, 8),
|
|
1494
|
+
"aria-hidden": "true"
|
|
1495
|
+
}
|
|
1496
|
+
)
|
|
1497
|
+
] });
|
|
1498
|
+
}
|
|
1499
|
+
function BarChartCategoryLabel({ bar, height }) {
|
|
1500
|
+
return /* @__PURE__ */ jsx(
|
|
1501
|
+
"text",
|
|
1502
|
+
{
|
|
1503
|
+
className: "pristine-bar-chart__label",
|
|
1504
|
+
x: bar.x + bar.width / 2,
|
|
1505
|
+
y: height - 12,
|
|
1506
|
+
textAnchor: "middle",
|
|
1507
|
+
children: bar.category
|
|
1508
|
+
}
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
function BarChartValueLabel({ bar, formatValue }) {
|
|
1512
|
+
return /* @__PURE__ */ jsx(
|
|
1513
|
+
"text",
|
|
1514
|
+
{
|
|
1515
|
+
className: "pristine-bar-chart__value",
|
|
1516
|
+
x: bar.x + bar.width / 2,
|
|
1517
|
+
y: bar.valueY,
|
|
1518
|
+
textAnchor: "middle",
|
|
1519
|
+
children: formatValue(bar.value)
|
|
1520
|
+
}
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
function BarChartCategory({
|
|
1524
|
+
active,
|
|
1525
|
+
bar,
|
|
1526
|
+
formatValue,
|
|
1527
|
+
height,
|
|
1528
|
+
onActivate,
|
|
1529
|
+
onDeactivate,
|
|
1530
|
+
showValues
|
|
1531
|
+
}) {
|
|
1532
|
+
const renderValueLabel = ifElse_default(
|
|
1533
|
+
always_default(showValues),
|
|
1534
|
+
() => /* @__PURE__ */ jsx(BarChartValueLabel, { bar, formatValue }),
|
|
1535
|
+
always_default(null)
|
|
1536
|
+
);
|
|
1537
|
+
const activeClassName = ifElse_default(
|
|
1538
|
+
always_default(active),
|
|
1539
|
+
always_default("pristine-bar-chart__category--active"),
|
|
1540
|
+
always_default("")
|
|
1541
|
+
)(active);
|
|
1542
|
+
const accessibleLabel = `${bar.category}: ${formatValue(bar.value)}`;
|
|
1543
|
+
const handleKeyDown = (event) => ifElse_default(
|
|
1544
|
+
(candidate) => candidate.key === "Escape",
|
|
1545
|
+
() => onDeactivate(),
|
|
1546
|
+
always_default(void 0)
|
|
1547
|
+
)(event);
|
|
1548
|
+
return /* @__PURE__ */ jsxs(
|
|
1549
|
+
"g",
|
|
1550
|
+
{
|
|
1551
|
+
className: classNames([
|
|
1552
|
+
"pristine-bar-chart__category",
|
|
1553
|
+
activeClassName
|
|
1554
|
+
]),
|
|
1555
|
+
role: "img",
|
|
1556
|
+
"aria-label": accessibleLabel,
|
|
1557
|
+
tabIndex: 0,
|
|
1558
|
+
onBlur: onDeactivate,
|
|
1559
|
+
onClick: onActivate,
|
|
1560
|
+
onFocus: onActivate,
|
|
1561
|
+
onKeyDown: handleKeyDown,
|
|
1562
|
+
onMouseEnter: onActivate,
|
|
1563
|
+
onMouseLeave: onDeactivate,
|
|
1564
|
+
children: [
|
|
1565
|
+
/* @__PURE__ */ jsx(BarChartBar, { bar }),
|
|
1566
|
+
renderValueLabel(),
|
|
1567
|
+
/* @__PURE__ */ jsx(BarChartCategoryLabel, { bar, height })
|
|
1568
|
+
]
|
|
1569
|
+
}
|
|
1570
|
+
);
|
|
1571
|
+
}
|
|
1572
|
+
function BarChartCategories({
|
|
1573
|
+
activeCategory,
|
|
1574
|
+
chart,
|
|
1575
|
+
formatValue,
|
|
1576
|
+
height,
|
|
1577
|
+
onActivate,
|
|
1578
|
+
onDeactivate,
|
|
1579
|
+
showValues
|
|
1580
|
+
}) {
|
|
1581
|
+
return chart.bars.map((bar) => /* @__PURE__ */ jsx(
|
|
1582
|
+
BarChartCategory,
|
|
1583
|
+
{
|
|
1584
|
+
active: activeCategory === bar.category,
|
|
1585
|
+
bar,
|
|
1586
|
+
formatValue,
|
|
1587
|
+
height,
|
|
1588
|
+
onActivate: () => onActivate(bar.category),
|
|
1589
|
+
onDeactivate,
|
|
1590
|
+
showValues
|
|
1591
|
+
},
|
|
1592
|
+
bar.category
|
|
1593
|
+
));
|
|
1594
|
+
}
|
|
1595
|
+
function BarChartGridLines({ chart, width }) {
|
|
1596
|
+
return chart.yTicks.map((tick) => /* @__PURE__ */ jsxs("g", { className: "pristine-bar-chart__grid-line", children: [
|
|
1597
|
+
/* @__PURE__ */ jsx(
|
|
1598
|
+
"line",
|
|
1599
|
+
{
|
|
1600
|
+
x1: BAR_CHART_MARGIN.left,
|
|
1601
|
+
x2: width - BAR_CHART_MARGIN.right,
|
|
1602
|
+
y1: chart.yScale(tick),
|
|
1603
|
+
y2: chart.yScale(tick)
|
|
1604
|
+
}
|
|
1605
|
+
),
|
|
1606
|
+
/* @__PURE__ */ jsx("text", { x: BAR_CHART_MARGIN.left - 8, y: chart.yScale(tick), textAnchor: "end", children: tick })
|
|
1607
|
+
] }, tick));
|
|
1608
|
+
}
|
|
1609
|
+
function BarChartPlotArea({ chart, width }) {
|
|
1610
|
+
return /* @__PURE__ */ jsx(
|
|
1611
|
+
"rect",
|
|
1612
|
+
{
|
|
1613
|
+
className: "pristine-bar-chart__plot",
|
|
1614
|
+
x: BAR_CHART_MARGIN.left,
|
|
1615
|
+
y: BAR_CHART_MARGIN.top,
|
|
1616
|
+
width: width - BAR_CHART_MARGIN.left - BAR_CHART_MARGIN.right,
|
|
1617
|
+
height: chart.plotBottom - BAR_CHART_MARGIN.top
|
|
1618
|
+
}
|
|
1619
|
+
);
|
|
1620
|
+
}
|
|
1621
|
+
var TOOLTIP_HEIGHT = 22;
|
|
1622
|
+
var TOOLTIP_MIN_WIDTH = 30;
|
|
1623
|
+
var TOOLTIP_PADDING_X = 8;
|
|
1624
|
+
var TOOLTIP_CHAR_WIDTH = 7;
|
|
1625
|
+
var VIEWBOX_PADDING = 4;
|
|
1626
|
+
var getTooltipWidth = (label) => Math.max(TOOLTIP_MIN_WIDTH, label.length * TOOLTIP_CHAR_WIDTH + TOOLTIP_PADDING_X * 2);
|
|
1627
|
+
var clamp = (minimum, maximum, value) => Math.min(Math.max(value, minimum), maximum);
|
|
1628
|
+
function BarChartTooltip({
|
|
1629
|
+
bar,
|
|
1630
|
+
formatValue,
|
|
1631
|
+
height,
|
|
1632
|
+
width
|
|
1633
|
+
}) {
|
|
1634
|
+
const label = formatValue(bar.value);
|
|
1635
|
+
const tooltipWidth = getTooltipWidth(label);
|
|
1636
|
+
const x = clamp(
|
|
1637
|
+
VIEWBOX_PADDING,
|
|
1638
|
+
width - tooltipWidth - VIEWBOX_PADDING,
|
|
1639
|
+
bar.x + bar.width / 2 - tooltipWidth / 2
|
|
1640
|
+
);
|
|
1641
|
+
const y = clamp(
|
|
1642
|
+
VIEWBOX_PADDING,
|
|
1643
|
+
height - TOOLTIP_HEIGHT - VIEWBOX_PADDING,
|
|
1644
|
+
bar.valueY - TOOLTIP_HEIGHT / 2
|
|
1645
|
+
);
|
|
1646
|
+
return /* @__PURE__ */ jsxs("g", { className: "pristine-bar-chart__tooltip", "aria-hidden": "true", children: [
|
|
1647
|
+
/* @__PURE__ */ jsx(
|
|
1648
|
+
"rect",
|
|
1649
|
+
{
|
|
1650
|
+
className: "pristine-bar-chart__tooltip-background",
|
|
1651
|
+
x,
|
|
1652
|
+
y,
|
|
1653
|
+
width: tooltipWidth,
|
|
1654
|
+
height: TOOLTIP_HEIGHT,
|
|
1655
|
+
rx: 4
|
|
1656
|
+
}
|
|
1657
|
+
),
|
|
1658
|
+
/* @__PURE__ */ jsx(
|
|
1659
|
+
"text",
|
|
1660
|
+
{
|
|
1661
|
+
className: "pristine-bar-chart__tooltip-text",
|
|
1662
|
+
x: x + tooltipWidth / 2,
|
|
1663
|
+
y: y + TOOLTIP_HEIGHT / 2,
|
|
1664
|
+
textAnchor: "middle",
|
|
1665
|
+
children: label
|
|
1666
|
+
}
|
|
1667
|
+
)
|
|
1668
|
+
] });
|
|
1669
|
+
}
|
|
1670
|
+
function BarChartSvg({
|
|
1671
|
+
ariaLabel,
|
|
1672
|
+
chart,
|
|
1673
|
+
formatValue,
|
|
1674
|
+
height,
|
|
1675
|
+
showValues,
|
|
1676
|
+
width
|
|
1677
|
+
}) {
|
|
1678
|
+
const [activeCategory, setActiveCategory] = useState(null);
|
|
1679
|
+
const activeBars = chart.bars.filter((bar) => bar.category === activeCategory);
|
|
1680
|
+
return /* @__PURE__ */ jsxs(
|
|
1681
|
+
"svg",
|
|
1682
|
+
{
|
|
1683
|
+
className: "pristine-bar-chart__svg",
|
|
1684
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
1685
|
+
role: "img",
|
|
1686
|
+
"aria-label": ariaLabel,
|
|
1687
|
+
children: [
|
|
1688
|
+
/* @__PURE__ */ jsx(BarChartPlotArea, { chart, width }),
|
|
1689
|
+
/* @__PURE__ */ jsx(BarChartGridLines, { chart, width }),
|
|
1690
|
+
/* @__PURE__ */ jsx(BarChartAxes, { chart, width }),
|
|
1691
|
+
/* @__PURE__ */ jsx(
|
|
1692
|
+
BarChartCategories,
|
|
1693
|
+
{
|
|
1694
|
+
activeCategory,
|
|
1695
|
+
chart,
|
|
1696
|
+
formatValue,
|
|
1697
|
+
height,
|
|
1698
|
+
onActivate: setActiveCategory,
|
|
1699
|
+
onDeactivate: () => setActiveCategory(null),
|
|
1700
|
+
showValues
|
|
1701
|
+
}
|
|
1702
|
+
),
|
|
1703
|
+
activeBars.map((bar) => /* @__PURE__ */ jsx(
|
|
1704
|
+
BarChartTooltip,
|
|
1705
|
+
{
|
|
1706
|
+
bar,
|
|
1707
|
+
formatValue,
|
|
1708
|
+
height,
|
|
1709
|
+
width
|
|
1710
|
+
},
|
|
1711
|
+
bar.category
|
|
1712
|
+
))
|
|
1713
|
+
]
|
|
1714
|
+
}
|
|
1715
|
+
);
|
|
1716
|
+
}
|
|
1717
|
+
function BarChartFigure({
|
|
1718
|
+
ariaLabel,
|
|
1719
|
+
caption,
|
|
1720
|
+
chart,
|
|
1721
|
+
className,
|
|
1722
|
+
formatValue,
|
|
1723
|
+
height,
|
|
1724
|
+
showValues,
|
|
1725
|
+
width
|
|
1726
|
+
}) {
|
|
1727
|
+
return /* @__PURE__ */ jsxs("figure", { className: classNames(["pristine-bar-chart", className]), "aria-label": ariaLabel, children: [
|
|
1728
|
+
/* @__PURE__ */ jsx(
|
|
1729
|
+
BarChartSvg,
|
|
1730
|
+
{
|
|
1731
|
+
ariaLabel,
|
|
1732
|
+
chart,
|
|
1733
|
+
formatValue,
|
|
1734
|
+
height,
|
|
1735
|
+
showValues,
|
|
1736
|
+
width
|
|
1737
|
+
}
|
|
1738
|
+
),
|
|
1739
|
+
/* @__PURE__ */ jsx(BarChartCaption, { caption })
|
|
1740
|
+
] });
|
|
1741
|
+
}
|
|
1742
|
+
function BarChart({
|
|
1743
|
+
data,
|
|
1744
|
+
width,
|
|
1745
|
+
height,
|
|
1746
|
+
ariaLabel,
|
|
1747
|
+
className,
|
|
1748
|
+
caption,
|
|
1749
|
+
orderStrategy,
|
|
1750
|
+
showValues,
|
|
1751
|
+
formatValue
|
|
1752
|
+
}) {
|
|
1753
|
+
const result = useMemo(
|
|
1754
|
+
() => computeBarChart({ data, orderStrategy }),
|
|
1755
|
+
[data, orderStrategy]
|
|
1756
|
+
);
|
|
1757
|
+
return matchResult(result, {
|
|
1758
|
+
error: (error) => /* @__PURE__ */ jsx(
|
|
1759
|
+
ChartError,
|
|
1760
|
+
{
|
|
1761
|
+
className: classNames(["pristine-bar-chart__error", className]),
|
|
1762
|
+
title: "Chart unavailable",
|
|
1763
|
+
message: error.message,
|
|
1764
|
+
details: error.details,
|
|
1765
|
+
role: "alert"
|
|
1766
|
+
}
|
|
1767
|
+
),
|
|
1768
|
+
ok: (bars) => {
|
|
1769
|
+
const chart = buildBarChartModel(bars, width, height);
|
|
1770
|
+
return /* @__PURE__ */ jsx(
|
|
1771
|
+
BarChartFigure,
|
|
1772
|
+
{
|
|
1773
|
+
ariaLabel,
|
|
1774
|
+
caption,
|
|
1775
|
+
chart,
|
|
1776
|
+
className,
|
|
1777
|
+
formatValue,
|
|
1778
|
+
height,
|
|
1779
|
+
showValues,
|
|
1780
|
+
width
|
|
1781
|
+
}
|
|
1782
|
+
);
|
|
1783
|
+
}
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
// src/bar-chart/BarChart.defaults.ts
|
|
1788
|
+
var formatDefaultValue = (value) => String(value);
|
|
1789
|
+
var DEFAULT_BAR_CHART_VIEW_PROPS = {
|
|
1790
|
+
width: 480,
|
|
1791
|
+
height: 280,
|
|
1792
|
+
ariaLabel: "Bar chart",
|
|
1793
|
+
className: "",
|
|
1794
|
+
caption: none,
|
|
1795
|
+
orderStrategy: DEFAULT_BAR_CHART_ORDER_STRATEGY,
|
|
1796
|
+
showValues: false,
|
|
1797
|
+
formatValue: formatDefaultValue
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
export { BarChart, DEFAULT_BAR_CHART_ORDER_STRATEGY, DEFAULT_BAR_CHART_VIEW_PROPS, computeBarChart, validateBarChartInput };
|
|
1801
|
+
//# sourceMappingURL=index.js.map
|
|
1802
|
+
//# sourceMappingURL=index.js.map
|