@dbmx/toasts 0.0.70 → 0.0.72
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/cjs/components/SdmxDatagrid/utils/index.cjs +7 -9
- package/cjs/fake-ZW05emqw.js +35 -0
- package/cjs/fake-ZW05emqw.js.map +1 -0
- package/cjs/index.cjs.map +1 -0
- package/esm/fake-JHdVf8lQ.js +14 -0
- package/esm/fake-JHdVf8lQ.js.map +1 -0
- package/esm/index-lo-MKsEb.js +556 -0
- package/esm/index-lo-MKsEb.js.map +1 -0
- package/esm/index.js +1 -1
- package/package.json +3 -3
- package/yarn-error.log +7136 -0
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/concat.cjs +0 -69
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/equals.cjs +0 -42
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/filter.cjs +0 -63
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_arrayFromIterator.cjs +0 -13
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_complement.cjs +0 -10
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_equals.cjs +0 -143
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_filter.cjs +0 -17
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_functionName.cjs +0 -10
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_includes.cjs +0 -11
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_includesWith.cjs +0 -16
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_indexOf.cjs +0 -61
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_isFunction.cjs +0 -9
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_isObject.cjs +0 -8
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_objectIs.cjs +0 -18
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_quote.cjs +0 -10
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_toISOString.cjs +0 -17
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_toString.cjs +0 -62
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/internal/_xfilter.cjs +0 -26
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/reject.cjs +0 -43
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/times.cjs +0 -49
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/toString.cjs +0 -53
- package/cjs/node_modules/@dbmx/sdmx/cjs/node_modules/ramda/es/type.cjs +0 -41
- package/esm/index-FCPRKLj2.js +0 -720
- package/esm/index-FCPRKLj2.js.map +0 -1
- package/esm/index-Mh78z9aW.js +0 -562
- package/esm/index-Mh78z9aW.js.map +0 -1
- package/esm/index-T2bcfyHI.js +0 -8510
- package/esm/index-T2bcfyHI.js.map +0 -1
- package/esm/index-W7MLRHBf.js +0 -87
- package/esm/index-W7MLRHBf.js.map +0 -1
- package/esm/index-gBe37Ynf.js +0 -8438
- package/esm/index-gBe37Ynf.js.map +0 -1
- package/esm/index-ndYjFD6I.js +0 -8438
- package/esm/index-ndYjFD6I.js.map +0 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.cjs');
|
|
4
|
+
var sdmx = require('@dbmx/sdmx');
|
|
4
5
|
var urljoin = require('url-join');
|
|
5
|
-
var core = require('../../../node_modules/@dbmx/sdmx/esm/core.cjs');
|
|
6
|
-
var datastructures = require('../../../node_modules/@dbmx/sdmx/esm/datastructures.cjs');
|
|
7
|
-
var query = require('../../../node_modules/@dbmx/sdmx/esm/query.cjs');
|
|
8
6
|
|
|
9
7
|
function sortByKey(array, key) {
|
|
10
8
|
return array.sort(function (a, b) {
|
|
@@ -67,9 +65,9 @@ var getStructure = /*#__PURE__*/function () {
|
|
|
67
65
|
};
|
|
68
66
|
}();
|
|
69
67
|
var getDataStructure = function getDataStructure(dataflow, structure) {
|
|
70
|
-
if (!(dataflow !== null && dataflow !== void 0 && dataflow.structure)) throw new Error("Cannot get dataStructure from dataflow ".concat(
|
|
71
|
-
var dsRef =
|
|
72
|
-
return
|
|
68
|
+
if (!(dataflow !== null && dataflow !== void 0 && dataflow.structure)) throw new Error("Cannot get dataStructure from dataflow ".concat(sdmx.ID(dataflow)));
|
|
69
|
+
var dsRef = sdmx.urn2FullRef(dataflow.structure);
|
|
70
|
+
return sdmx.resolveResourceFromStructure(structure, dataflow, dsRef, {
|
|
73
71
|
noError: true
|
|
74
72
|
});
|
|
75
73
|
};
|
|
@@ -94,7 +92,7 @@ var getColumns = function getColumns() {
|
|
|
94
92
|
};
|
|
95
93
|
};
|
|
96
94
|
var getSelectedComponents = function getSelectedComponents(resource) {
|
|
97
|
-
var components =
|
|
95
|
+
var components = sdmx.getComponents(resource);
|
|
98
96
|
return components.reduce(function (acc, component) {
|
|
99
97
|
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, acc), {}, _rollupPluginBabelHelpers.defineProperty({}, component.id, component));
|
|
100
98
|
}, {});
|
|
@@ -113,9 +111,9 @@ var getData = /*#__PURE__*/function () {
|
|
|
113
111
|
min: 1,
|
|
114
112
|
max: 100
|
|
115
113
|
};
|
|
116
|
-
dataUrl =
|
|
114
|
+
dataUrl = sdmx.dataQueryUrl(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({
|
|
117
115
|
context: 'dataflow'
|
|
118
|
-
},
|
|
116
|
+
}, sdmx.getRef(dataflow)), {}, {
|
|
119
117
|
endpoint: endpoint
|
|
120
118
|
}));
|
|
121
119
|
min = range.min, max = range.max;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var core = require('@mantine/core');
|
|
5
|
+
var PropTypes = require('prop-types');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
25
|
+
|
|
26
|
+
var Fake = function Fake(_ref) {
|
|
27
|
+
var message = _ref.message;
|
|
28
|
+
return /*#__PURE__*/React__namespace.createElement(core.Text, null, "COUCOU ".concat(message));
|
|
29
|
+
};
|
|
30
|
+
Fake.propTypes = {
|
|
31
|
+
message: PropTypes.string.isRequired
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.default = Fake;
|
|
35
|
+
//# sourceMappingURL=fake-ZW05emqw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-ZW05emqw.js","sources":["../src/components/fake.js"],"sourcesContent":["import * as React from 'react'\nimport { Text } from '@mantine/core'\nimport PropTypes from 'prop-types'\n\nconst Fake = ({ message }) => {\n return <Text>{`COUCOU ${message}`}</Text>\n}\n\nFake.propTypes = {\n message: PropTypes.string.isRequired,\n}\n\nexport default Fake\n"],"names":["Fake","_ref","message","React","createElement","Text","concat","propTypes","PropTypes","string","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,IAAI,GAAG,SAAPA,IAAIA,CAAAC,IAAA,EAAoB;AAAA,EAAA,IAAdC,OAAO,GAAAD,IAAA,CAAPC,OAAO,CAAA;EACrB,oBAAOC,gBAAA,CAAAC,aAAA,CAACC,SAAI,kBAAAC,MAAA,CAAYJ,OAAO,CAAS,CAAC,CAAA;AAC3C,EAAC;AAEDF,IAAI,CAACO,SAAS,GAAG;AACfL,EAAAA,OAAO,EAAEM,SAAS,CAACC,MAAM,CAACC,UAAAA;AAC5B,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.js"],"sourcesContent":["import { lazy } from 'react'\n\nconst importPath = '@dbmx/toasts'\nconst type = importPath\n\nconst toasts = [\n {\n id: 'fake',\n importPath,\n type,\n name: 'Fake Component',\n description: ' blah blah blah ...',\n component: lazy(() => import('./components/fake.js')),\n image: 'https://ui.mantine.dev/_next/static/media/stats-light.c6e8954d.svg',\n props: {\n message: {\n type: 'string',\n required: false,\n defaultValue: 'ici les bidibules',\n },\n },\n },\n]\n\nexport default toasts\n"],"names":["importPath","type","toasts","id","name","description","component","lazy","image","props","message","required","defaultValue"],"mappings":";;;;AAEA,IAAMA,UAAU,GAAG,cAAc,CAAA;AACjC,IAAMC,IAAI,GAAGD,UAAU,CAAA;AAEjBE,IAAAA,MAAM,GAAG,CACb;AACEC,EAAAA,EAAE,EAAE,MAAM;AACVH,EAAAA,UAAU,EAAVA,UAAU;AACVC,EAAAA,IAAI,EAAJA,IAAI;AACJG,EAAAA,IAAI,EAAE,gBAAgB;AACtBC,EAAAA,WAAW,EAAE,qBAAqB;EAClCC,SAAS,eAAEC,UAAI,CAAC,YAAA;IAAA,OAAM,oDAAO,oBAAsB,KAAC,CAAA;GAAC,CAAA;AACrDC,EAAAA,KAAK,EAAE,oEAAoE;AAC3EC,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE;AACPT,MAAAA,IAAI,EAAE,QAAQ;AACdU,MAAAA,QAAQ,EAAE,KAAK;AACfC,MAAAA,YAAY,EAAE,mBAAA;AAChB,KAAA;AACF,GAAA;AACF,CAAC;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Text } from '@mantine/core';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
var Fake = function Fake(_ref) {
|
|
6
|
+
var message = _ref.message;
|
|
7
|
+
return /*#__PURE__*/React.createElement(Text, null, "COUCOU ".concat(message));
|
|
8
|
+
};
|
|
9
|
+
Fake.propTypes = {
|
|
10
|
+
message: PropTypes.string.isRequired
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { Fake as default };
|
|
14
|
+
//# sourceMappingURL=fake-JHdVf8lQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-JHdVf8lQ.js","sources":["../src/components/fake.js"],"sourcesContent":["import * as React from 'react'\nimport { Text } from '@mantine/core'\nimport PropTypes from 'prop-types'\n\nconst Fake = ({ message }) => {\n return <Text>{`COUCOU ${message}`}</Text>\n}\n\nFake.propTypes = {\n message: PropTypes.string.isRequired,\n}\n\nexport default Fake\n"],"names":["Fake","_ref","message","React","createElement","Text","concat","propTypes","PropTypes","string","isRequired"],"mappings":";;;;AAIA,IAAMA,IAAI,GAAG,SAAPA,IAAIA,CAAAC,IAAA,EAAoB;AAAA,EAAA,IAAdC,OAAO,GAAAD,IAAA,CAAPC,OAAO,CAAA;EACrB,oBAAOC,KAAA,CAAAC,aAAA,CAACC,IAAI,kBAAAC,MAAA,CAAYJ,OAAO,CAAS,CAAC,CAAA;AAC3C,EAAC;AAEDF,IAAI,CAACO,SAAS,GAAG;AACfL,EAAAA,OAAO,EAAEM,SAAS,CAACC,MAAM,CAACC,UAAAA;AAC5B,CAAC;;;;"}
|
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import { _ as _asyncToGenerator, a as _objectSpread2, b as _defineProperty, c as _regeneratorRuntime, d as _createForOfIteratorHelper, e as _slicedToArray, f as _toConsumableArray, g as _inherits, h as _createSuper, i as _createClass, j as _classCallCheck, k as _assertThisInitialized, l as createRoot, m as _wrapNativeSuper } from './client-gw8asYiR.js';
|
|
2
|
+
import React, { useMemo, useState, useEffect, useReducer } from 'react';
|
|
3
|
+
import { defineMessages, useIntl, IntlProvider } from 'react-intl';
|
|
4
|
+
import { createStyles, Box, Loader, rem, Text, createEmotionCache, MantineProvider } from '@mantine/core';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { IconAlertCircleFilled, IconThumbDown } from '@tabler/icons-react';
|
|
7
|
+
import { getObservations } from '@dbmx/sdmx/cjs/data';
|
|
8
|
+
import { MantineReactTable, MRT_ShowHideColumnsButton, MRT_ToggleFullScreenButton } from 'mantine-react-table';
|
|
9
|
+
import { ID, urn2FullRef, resolveResourceFromStructure, getComponents, dataQueryUrl, getRef } from '@dbmx/sdmx';
|
|
10
|
+
import urljoin from 'url-join';
|
|
11
|
+
import 'react-dom';
|
|
12
|
+
|
|
13
|
+
var messages = defineMessages({
|
|
14
|
+
urlIsRequired: {
|
|
15
|
+
id: 'components.SdmxComponent.urlIsRequired',
|
|
16
|
+
defaultMessage: 'URL Is Required!'
|
|
17
|
+
},
|
|
18
|
+
noData: {
|
|
19
|
+
id: 'components.SdmxComponent.noData',
|
|
20
|
+
defaultMessage: 'No Data Available!'
|
|
21
|
+
},
|
|
22
|
+
dimension: {
|
|
23
|
+
id: 'components.SdmxComponent.dimension',
|
|
24
|
+
defaultMessage: 'Dimension'
|
|
25
|
+
},
|
|
26
|
+
timeDimension: {
|
|
27
|
+
id: 'components.SdmxComponent.timeDimension',
|
|
28
|
+
defaultMessage: 'Time Dimension'
|
|
29
|
+
},
|
|
30
|
+
measure: {
|
|
31
|
+
id: 'components.SdmxComponent.measure',
|
|
32
|
+
defaultMessage: 'Measure'
|
|
33
|
+
},
|
|
34
|
+
invalidComProps: {
|
|
35
|
+
id: 'components.SdmxComponent.invalidComProps',
|
|
36
|
+
defaultMessage: 'Invalid component props!'
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
var useStyles$1 = createStyles(function () {
|
|
41
|
+
return {
|
|
42
|
+
loadingContainer: {
|
|
43
|
+
width: '100%',
|
|
44
|
+
height: '100%',
|
|
45
|
+
display: 'flex',
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
alignItems: 'center'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
var LoadingBox = function LoadingBox() {
|
|
52
|
+
var _useStyles = useStyles$1(),
|
|
53
|
+
classes = _useStyles.classes;
|
|
54
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
55
|
+
className: classes.loadingContainer
|
|
56
|
+
}, /*#__PURE__*/React.createElement(Loader, {
|
|
57
|
+
color: "blue",
|
|
58
|
+
size: "lg"
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
function sortByKey(array, key) {
|
|
63
|
+
return array.sort(function (a, b) {
|
|
64
|
+
var x = a[key];
|
|
65
|
+
var y = b[key];
|
|
66
|
+
return x < y ? -1 : x > y ? 1 : 0;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
var getStructure = /*#__PURE__*/function () {
|
|
70
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
|
|
71
|
+
var headers,
|
|
72
|
+
response,
|
|
73
|
+
data,
|
|
74
|
+
responseHeaders,
|
|
75
|
+
_iterator,
|
|
76
|
+
_step,
|
|
77
|
+
pair,
|
|
78
|
+
_args = arguments;
|
|
79
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
80
|
+
while (1) switch (_context.prev = _context.next) {
|
|
81
|
+
case 0:
|
|
82
|
+
headers = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
83
|
+
_context.next = 3;
|
|
84
|
+
return fetch(url, {
|
|
85
|
+
method: 'GET',
|
|
86
|
+
headers: _objectSpread2({
|
|
87
|
+
'Content-Type': 'application/json'
|
|
88
|
+
}, headers)
|
|
89
|
+
});
|
|
90
|
+
case 3:
|
|
91
|
+
response = _context.sent;
|
|
92
|
+
_context.next = 6;
|
|
93
|
+
return response.json();
|
|
94
|
+
case 6:
|
|
95
|
+
data = _context.sent;
|
|
96
|
+
responseHeaders = {};
|
|
97
|
+
_iterator = _createForOfIteratorHelper(response.headers.entries());
|
|
98
|
+
try {
|
|
99
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
100
|
+
pair = _step.value;
|
|
101
|
+
responseHeaders[pair[0]] = pair[1];
|
|
102
|
+
}
|
|
103
|
+
} catch (err) {
|
|
104
|
+
_iterator.e(err);
|
|
105
|
+
} finally {
|
|
106
|
+
_iterator.f();
|
|
107
|
+
}
|
|
108
|
+
return _context.abrupt("return", {
|
|
109
|
+
data: data,
|
|
110
|
+
responseHeaders: responseHeaders
|
|
111
|
+
});
|
|
112
|
+
case 11:
|
|
113
|
+
case "end":
|
|
114
|
+
return _context.stop();
|
|
115
|
+
}
|
|
116
|
+
}, _callee);
|
|
117
|
+
}));
|
|
118
|
+
return function getStructure(_x) {
|
|
119
|
+
return _ref.apply(this, arguments);
|
|
120
|
+
};
|
|
121
|
+
}();
|
|
122
|
+
var getDataStructure = function getDataStructure(dataflow, structure) {
|
|
123
|
+
if (!(dataflow !== null && dataflow !== void 0 && dataflow.structure)) throw new Error("Cannot get dataStructure from dataflow ".concat(ID(dataflow)));
|
|
124
|
+
var dsRef = urn2FullRef(dataflow.structure);
|
|
125
|
+
return resolveResourceFromStructure(structure, dataflow, dsRef, {
|
|
126
|
+
noError: true
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
var getColumns = function getColumns() {
|
|
130
|
+
var components = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
131
|
+
var comps = Object.values(components);
|
|
132
|
+
var dimensions = comps.filter(function (comp) {
|
|
133
|
+
return comp.type === 'dimension';
|
|
134
|
+
});
|
|
135
|
+
var timeDimension = comps.filter(function (comp) {
|
|
136
|
+
return comp.type === 'timeDimension';
|
|
137
|
+
})[0];
|
|
138
|
+
var measures = comps.filter(function (comp) {
|
|
139
|
+
return comp.type === 'measure';
|
|
140
|
+
});
|
|
141
|
+
var sortedDimensions = sortByKey(dimensions, 'position');
|
|
142
|
+
var sortedMesures = sortByKey(measures, 'id');
|
|
143
|
+
return {
|
|
144
|
+
dimensions: sortedDimensions,
|
|
145
|
+
timeDimension: timeDimension,
|
|
146
|
+
measures: sortedMesures
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
var getSelectedComponents = function getSelectedComponents(resource) {
|
|
150
|
+
var components = getComponents(resource);
|
|
151
|
+
return components.reduce(function (acc, component) {
|
|
152
|
+
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, component.id, component));
|
|
153
|
+
}, {});
|
|
154
|
+
};
|
|
155
|
+
var getData = /*#__PURE__*/function () {
|
|
156
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(dataflow, endpoint) {
|
|
157
|
+
var range,
|
|
158
|
+
dataUrl,
|
|
159
|
+
min,
|
|
160
|
+
max,
|
|
161
|
+
_args2 = arguments;
|
|
162
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
163
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
164
|
+
case 0:
|
|
165
|
+
range = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {
|
|
166
|
+
min: 1,
|
|
167
|
+
max: 100
|
|
168
|
+
};
|
|
169
|
+
dataUrl = dataQueryUrl(_objectSpread2(_objectSpread2({
|
|
170
|
+
context: 'dataflow'
|
|
171
|
+
}, getRef(dataflow)), {}, {
|
|
172
|
+
endpoint: endpoint
|
|
173
|
+
}));
|
|
174
|
+
min = range.min, max = range.max;
|
|
175
|
+
return _context2.abrupt("return", getStructure(dataUrl, {
|
|
176
|
+
'x-Range': "values=".concat(min, "-").concat(max)
|
|
177
|
+
}));
|
|
178
|
+
case 4:
|
|
179
|
+
case "end":
|
|
180
|
+
return _context2.stop();
|
|
181
|
+
}
|
|
182
|
+
}, _callee2);
|
|
183
|
+
}));
|
|
184
|
+
return function getData(_x2, _x3) {
|
|
185
|
+
return _ref2.apply(this, arguments);
|
|
186
|
+
};
|
|
187
|
+
}();
|
|
188
|
+
var getCellValue = function getCellValue(cell) {
|
|
189
|
+
var cellValue = cell.getValue();
|
|
190
|
+
return (cellValue === null || cellValue === void 0 ? void 0 : cellValue.name) || (cellValue === null || cellValue === void 0 ? void 0 : cellValue.id) || (cellValue === null || cellValue === void 0 ? void 0 : cellValue.value);
|
|
191
|
+
};
|
|
192
|
+
var getSdmxUrl = function getSdmxUrl(_ref3) {
|
|
193
|
+
var endpoint = _ref3.endpoint,
|
|
194
|
+
resourceType = _ref3.resourceType,
|
|
195
|
+
_ref3$agencyID = _ref3.agencyID,
|
|
196
|
+
agencyID = _ref3$agencyID === void 0 ? '*' : _ref3$agencyID,
|
|
197
|
+
_ref3$id = _ref3.id,
|
|
198
|
+
id = _ref3$id === void 0 ? '*' : _ref3$id,
|
|
199
|
+
_ref3$version = _ref3.version,
|
|
200
|
+
version = _ref3$version === void 0 ? '~' : _ref3$version;
|
|
201
|
+
if (!endpoint || !resourceType) throw new Error('endpoint & resourceType are required');
|
|
202
|
+
var url = urljoin(endpoint, 'structure', resourceType, agencyID, id, version, '?detail=full&references=all');
|
|
203
|
+
return url;
|
|
204
|
+
};
|
|
205
|
+
var getRange = function getRange(pagination) {
|
|
206
|
+
var pageIndex = pagination.pageIndex,
|
|
207
|
+
pageSize = pagination.pageSize;
|
|
208
|
+
var min = pageSize * pageIndex;
|
|
209
|
+
var max = pageSize * pageIndex + pageSize - 1;
|
|
210
|
+
return {
|
|
211
|
+
min: min,
|
|
212
|
+
max: max
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
var getObservationsCount = function getObservationsCount(responseHeaders) {
|
|
216
|
+
var contentRange = responseHeaders['content-range'];
|
|
217
|
+
return parseInt(contentRange.split('/')[1]);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
var SDMXGrid = function SDMXGrid(_ref) {
|
|
221
|
+
var dataStructure = _ref.dataStructure,
|
|
222
|
+
data = _ref.data,
|
|
223
|
+
pagination = _ref.pagination,
|
|
224
|
+
onPaginationChange = _ref.onPaginationChange,
|
|
225
|
+
observationCount = _ref.observationCount,
|
|
226
|
+
isLoading = _ref.isLoading;
|
|
227
|
+
if (!data) return /*#__PURE__*/React.createElement(LoadingBox, null);
|
|
228
|
+
var intl = useIntl();
|
|
229
|
+
var components = useMemo(function () {
|
|
230
|
+
return getSelectedComponents(dataStructure);
|
|
231
|
+
}, [dataStructure]);
|
|
232
|
+
var columns = useMemo(function () {
|
|
233
|
+
var _getColumns = getColumns(components),
|
|
234
|
+
dimensions = _getColumns.dimensions,
|
|
235
|
+
timeDimension = _getColumns.timeDimension,
|
|
236
|
+
measures = _getColumns.measures;
|
|
237
|
+
return [{
|
|
238
|
+
accessorKey: 'dimension',
|
|
239
|
+
header: intl.formatMessage(messages.dimension),
|
|
240
|
+
columns: dimensions.map(function (col) {
|
|
241
|
+
return {
|
|
242
|
+
accessorKey: col.id,
|
|
243
|
+
header: col.id || col.name,
|
|
244
|
+
Cell: function Cell(_ref2) {
|
|
245
|
+
var cell = _ref2.cell;
|
|
246
|
+
return getCellValue(cell);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
})
|
|
250
|
+
}, {
|
|
251
|
+
accessorKey: 'timeDimension',
|
|
252
|
+
header: intl.formatMessage(messages.timeDimension),
|
|
253
|
+
columns: [{
|
|
254
|
+
accessorKey: timeDimension.id,
|
|
255
|
+
header: timeDimension.id || timeDimension.name,
|
|
256
|
+
Cell: function Cell(_ref3) {
|
|
257
|
+
var cell = _ref3.cell;
|
|
258
|
+
return getCellValue(cell);
|
|
259
|
+
}
|
|
260
|
+
}]
|
|
261
|
+
}, {
|
|
262
|
+
accessorKey: 'measure',
|
|
263
|
+
header: intl.formatMessage(messages.measure),
|
|
264
|
+
columns: measures.map(function (col) {
|
|
265
|
+
return {
|
|
266
|
+
accessorKey: col.id,
|
|
267
|
+
header: col.id || col.name,
|
|
268
|
+
Cell: function Cell(_ref4) {
|
|
269
|
+
var cell = _ref4.cell;
|
|
270
|
+
return getCellValue(cell);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
})
|
|
274
|
+
}];
|
|
275
|
+
}, [components]);
|
|
276
|
+
return /*#__PURE__*/React.createElement(MantineReactTable, {
|
|
277
|
+
data: data,
|
|
278
|
+
columns: columns,
|
|
279
|
+
initialState: {
|
|
280
|
+
density: 'xs'
|
|
281
|
+
},
|
|
282
|
+
mantineTableProps: {
|
|
283
|
+
striped: true
|
|
284
|
+
},
|
|
285
|
+
enableStickyHeader: true,
|
|
286
|
+
enableColumnFilterModes: false,
|
|
287
|
+
enableColumnActions: false,
|
|
288
|
+
enableSorting: false,
|
|
289
|
+
enablePinning: true,
|
|
290
|
+
manualPagination: true,
|
|
291
|
+
rowCount: observationCount,
|
|
292
|
+
onPaginationChange: onPaginationChange,
|
|
293
|
+
state: {
|
|
294
|
+
pagination: pagination,
|
|
295
|
+
isLoading: isLoading
|
|
296
|
+
},
|
|
297
|
+
mantinePaginationProps: {
|
|
298
|
+
rowsPerPageOptions: ['100', '500', '1000', '2000'],
|
|
299
|
+
withEdges: true
|
|
300
|
+
},
|
|
301
|
+
renderToolbarInternalActions: function renderToolbarInternalActions(_ref5) {
|
|
302
|
+
var table = _ref5.table;
|
|
303
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MRT_ShowHideColumnsButton, {
|
|
304
|
+
table: table
|
|
305
|
+
}), /*#__PURE__*/React.createElement(MRT_ToggleFullScreenButton, {
|
|
306
|
+
table: table
|
|
307
|
+
}));
|
|
308
|
+
},
|
|
309
|
+
mantineTableContainerProps: {
|
|
310
|
+
sx: {
|
|
311
|
+
height: 'calc(100% - 110px)'
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
mantinePaperProps: {
|
|
315
|
+
sx: {
|
|
316
|
+
height: '100%'
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
SDMXGrid.propTypes = {
|
|
322
|
+
dataStructure: PropTypes.object,
|
|
323
|
+
data: PropTypes.array,
|
|
324
|
+
pagination: PropTypes.object.isRequired,
|
|
325
|
+
onPaginationChange: PropTypes.func.isRequired,
|
|
326
|
+
observationCount: PropTypes.number.isRequired,
|
|
327
|
+
isLoading: PropTypes.bool.isRequired
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
var useStyles = createStyles(function (theme) {
|
|
331
|
+
return {
|
|
332
|
+
wrongContainer: {
|
|
333
|
+
width: '100%',
|
|
334
|
+
height: '100%',
|
|
335
|
+
display: 'flex',
|
|
336
|
+
flexDirection: 'column',
|
|
337
|
+
justifyContent: 'center',
|
|
338
|
+
alignItems: 'center',
|
|
339
|
+
backgroundColor: theme.colors.gray[0]
|
|
340
|
+
},
|
|
341
|
+
alertIcon: {
|
|
342
|
+
width: rem(80),
|
|
343
|
+
height: rem(80),
|
|
344
|
+
color: theme.colors.gray[4]
|
|
345
|
+
},
|
|
346
|
+
alertMsg: {
|
|
347
|
+
marginTop: theme.spacing.sm,
|
|
348
|
+
color: theme.colors.gray[6]
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
});
|
|
352
|
+
var SdmxDatagrid = function SdmxDatagrid(_ref) {
|
|
353
|
+
var endpoint = _ref.endpoint,
|
|
354
|
+
resourceType = _ref.resourceType,
|
|
355
|
+
agencyID = _ref.agencyID,
|
|
356
|
+
id = _ref.id,
|
|
357
|
+
version = _ref.version;
|
|
358
|
+
var _useStyles = useStyles(),
|
|
359
|
+
classes = _useStyles.classes;
|
|
360
|
+
var intl = useIntl();
|
|
361
|
+
var _useState = useState(false),
|
|
362
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
363
|
+
isLoading = _useState2[0],
|
|
364
|
+
setIsLoading = _useState2[1];
|
|
365
|
+
var _useState3 = useState(false),
|
|
366
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
367
|
+
isError = _useState4[0],
|
|
368
|
+
setIsError = _useState4[1];
|
|
369
|
+
var _useState5 = useState(),
|
|
370
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
371
|
+
dataflow = _useState6[0],
|
|
372
|
+
setDataflow = _useState6[1];
|
|
373
|
+
var _useState7 = useState(),
|
|
374
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
375
|
+
dataStructure = _useState8[0],
|
|
376
|
+
setDataStructure = _useState8[1];
|
|
377
|
+
var _useState9 = useState(),
|
|
378
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
379
|
+
data = _useState10[0],
|
|
380
|
+
setData = _useState10[1];
|
|
381
|
+
var url = useMemo(function () {
|
|
382
|
+
if (!endpoint || !resourceType || !agencyID || !id || !version) return null;else return getSdmxUrl({
|
|
383
|
+
endpoint: endpoint,
|
|
384
|
+
resourceType: resourceType,
|
|
385
|
+
agencyID: agencyID,
|
|
386
|
+
id: id,
|
|
387
|
+
version: version
|
|
388
|
+
});
|
|
389
|
+
}, [endpoint, resourceType, agencyID, id, version]);
|
|
390
|
+
var _useState11 = useState({
|
|
391
|
+
pageIndex: 0,
|
|
392
|
+
pageSize: 100
|
|
393
|
+
}),
|
|
394
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
395
|
+
pagination = _useState12[0],
|
|
396
|
+
setPagination = _useState12[1];
|
|
397
|
+
var range = useMemo(function () {
|
|
398
|
+
return getRange(pagination);
|
|
399
|
+
}, [pagination]);
|
|
400
|
+
var _useState13 = useState(0),
|
|
401
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
402
|
+
observationCount = _useState14[0],
|
|
403
|
+
setObservationCount = _useState14[1];
|
|
404
|
+
|
|
405
|
+
// Initializing
|
|
406
|
+
useEffect(function () {
|
|
407
|
+
setDataflow();
|
|
408
|
+
setDataStructure();
|
|
409
|
+
setData();
|
|
410
|
+
setIsLoading(false);
|
|
411
|
+
setIsError(false);
|
|
412
|
+
if (url) {
|
|
413
|
+
setIsLoading(true);
|
|
414
|
+
getStructure(url).then(function (_ref2) {
|
|
415
|
+
var _structure$data;
|
|
416
|
+
var structure = _ref2.data;
|
|
417
|
+
var df = (_structure$data = structure.data) === null || _structure$data === void 0 || (_structure$data = _structure$data.dataflows) === null || _structure$data === void 0 ? void 0 : _structure$data[0];
|
|
418
|
+
var ds = getDataStructure(df, structure);
|
|
419
|
+
setDataflow(df);
|
|
420
|
+
setDataStructure(ds);
|
|
421
|
+
})["catch"](function () {
|
|
422
|
+
setIsError(true);
|
|
423
|
+
setIsLoading(false);
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}, [url]);
|
|
427
|
+
|
|
428
|
+
// getting data
|
|
429
|
+
useEffect(function () {
|
|
430
|
+
if (dataflow) {
|
|
431
|
+
setIsLoading(true);
|
|
432
|
+
setIsError(false);
|
|
433
|
+
getData(dataflow, endpoint, range).then(function (_ref3) {
|
|
434
|
+
var dataStructure = _ref3.data,
|
|
435
|
+
responseHeaders = _ref3.responseHeaders;
|
|
436
|
+
setObservationCount(getObservationsCount(responseHeaders));
|
|
437
|
+
setData(_toConsumableArray(getObservations(dataStructure)));
|
|
438
|
+
setIsLoading(false);
|
|
439
|
+
})["catch"](function () {
|
|
440
|
+
setIsError(true);
|
|
441
|
+
setIsLoading(false);
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}, [range, dataflow]);
|
|
445
|
+
var handlePaginationChange = function handlePaginationChange(options) {
|
|
446
|
+
return setPagination(options);
|
|
447
|
+
};
|
|
448
|
+
if (isLoading && !dataStructure) return /*#__PURE__*/React.createElement(LoadingBox, null);
|
|
449
|
+
if (!url) return /*#__PURE__*/React.createElement(Box, {
|
|
450
|
+
className: classes.wrongContainer
|
|
451
|
+
}, /*#__PURE__*/React.createElement(IconAlertCircleFilled, {
|
|
452
|
+
className: classes.alertIcon
|
|
453
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
454
|
+
size: "sm",
|
|
455
|
+
className: classes.alertMsg
|
|
456
|
+
}, intl.formatMessage(messages.invalidComProps)));
|
|
457
|
+
if (isError && !data) {
|
|
458
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
459
|
+
className: classes.wrongContainer
|
|
460
|
+
}, /*#__PURE__*/React.createElement(IconThumbDown, {
|
|
461
|
+
className: classes.alertIcon
|
|
462
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
463
|
+
size: "sm",
|
|
464
|
+
className: classes.alertMsg
|
|
465
|
+
}, intl.formatMessage(messages.noData)));
|
|
466
|
+
}
|
|
467
|
+
return /*#__PURE__*/React.createElement(SDMXGrid, {
|
|
468
|
+
dataStructure: dataStructure,
|
|
469
|
+
data: data,
|
|
470
|
+
pagination: pagination,
|
|
471
|
+
onPaginationChange: handlePaginationChange,
|
|
472
|
+
observationCount: observationCount,
|
|
473
|
+
isLoading: isLoading
|
|
474
|
+
});
|
|
475
|
+
};
|
|
476
|
+
SdmxDatagrid.propTypes = {
|
|
477
|
+
endpoint: PropTypes.string.isRequired,
|
|
478
|
+
resourceType: PropTypes.string.isRequired,
|
|
479
|
+
agencyID: PropTypes.string.isRequired,
|
|
480
|
+
id: PropTypes.string.isRequired,
|
|
481
|
+
version: PropTypes.string.isRequired
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
var SDMXDatagrid = /*#__PURE__*/function (_HTMLElement) {
|
|
485
|
+
_inherits(SDMXDatagrid, _HTMLElement);
|
|
486
|
+
var _super = _createSuper(SDMXDatagrid);
|
|
487
|
+
function SDMXDatagrid() {
|
|
488
|
+
var _this;
|
|
489
|
+
_classCallCheck(this, SDMXDatagrid);
|
|
490
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
491
|
+
args[_key] = arguments[_key];
|
|
492
|
+
}
|
|
493
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
494
|
+
_defineProperty(_assertThisInitialized(_this), "forceUpdateComponent", void 0);
|
|
495
|
+
_defineProperty(_assertThisInitialized(_this), "container", function () {
|
|
496
|
+
var forceUpdate = useReducer(function () {
|
|
497
|
+
return {};
|
|
498
|
+
}, {})[1];
|
|
499
|
+
_this.forceUpdateComponent = forceUpdate;
|
|
500
|
+
var props = {
|
|
501
|
+
endpoint: _this.getAttribute('endpoint'),
|
|
502
|
+
resourceType: _this.getAttribute('resourceType'),
|
|
503
|
+
agencyID: _this.getAttribute('agencyID'),
|
|
504
|
+
id: _this.getAttribute('id'),
|
|
505
|
+
version: _this.getAttribute('version')
|
|
506
|
+
};
|
|
507
|
+
var containerProps = _this.getAttribute('containerProps') || {};
|
|
508
|
+
var containerPropsValue = typeof containerProps === 'string' ? JSON.parse(containerProps) : {};
|
|
509
|
+
return /*#__PURE__*/React.createElement(IntlProvider, {
|
|
510
|
+
defaultLocale: "en",
|
|
511
|
+
locale: "en",
|
|
512
|
+
messages: {}
|
|
513
|
+
}, /*#__PURE__*/React.createElement("div", containerPropsValue, /*#__PURE__*/React.createElement(SdmxDatagrid, props)));
|
|
514
|
+
});
|
|
515
|
+
return _this;
|
|
516
|
+
}
|
|
517
|
+
_createClass(SDMXDatagrid, [{
|
|
518
|
+
key: "connectedCallback",
|
|
519
|
+
value: function connectedCallback() {
|
|
520
|
+
var shadowRoot = this.attachShadow({
|
|
521
|
+
mode: 'open'
|
|
522
|
+
});
|
|
523
|
+
var mountPoint = document.createElement('div');
|
|
524
|
+
var emotionRoot = document.createElement('div');
|
|
525
|
+
shadowRoot.appendChild(mountPoint);
|
|
526
|
+
shadowRoot.appendChild(emotionRoot);
|
|
527
|
+
var appendCache = createEmotionCache({
|
|
528
|
+
key: 'mantine-wc',
|
|
529
|
+
container: emotionRoot
|
|
530
|
+
});
|
|
531
|
+
var root = createRoot(mountPoint);
|
|
532
|
+
root.render( /*#__PURE__*/React.createElement(MantineProvider, {
|
|
533
|
+
emotionCache: appendCache,
|
|
534
|
+
withGlobalStyles: true,
|
|
535
|
+
withNormalizeCSS: true
|
|
536
|
+
}, /*#__PURE__*/React.createElement(IntlProvider, {
|
|
537
|
+
defaultLocale: "en",
|
|
538
|
+
locale: "en",
|
|
539
|
+
messages: {}
|
|
540
|
+
}, /*#__PURE__*/React.createElement(this.container, null))));
|
|
541
|
+
}
|
|
542
|
+
}, {
|
|
543
|
+
key: "attributeChangedCallback",
|
|
544
|
+
value: function attributeChangedCallback() {
|
|
545
|
+
if (typeof this.forceUpdateComponent === 'function') this.forceUpdateComponent();
|
|
546
|
+
}
|
|
547
|
+
}], [{
|
|
548
|
+
key: "observedAttributes",
|
|
549
|
+
get: function get() {
|
|
550
|
+
return ['endpoint', 'resourceType', 'agencyID', 'id', 'version'];
|
|
551
|
+
}
|
|
552
|
+
}]);
|
|
553
|
+
return SDMXDatagrid;
|
|
554
|
+
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
|
|
555
|
+
customElements.define('sdmx-datagrid', SDMXDatagrid);
|
|
556
|
+
//# sourceMappingURL=index-lo-MKsEb.js.map
|