@dartcom/ui-kit 3.1.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/layers/leaflet/hooks/useGetLeafletLayer.js +15 -9
- package/dist/cjs/components/layers/leaflet/hooks/useGetLeafletLayer.js.map +1 -1
- package/dist/cjs/components/layers/leaflet/leaflet.js +4 -8
- package/dist/cjs/components/layers/leaflet/leaflet.js.map +1 -1
- package/dist/cjs/configs/global/global.js +23 -19
- package/dist/cjs/configs/global/global.js.map +1 -1
- package/dist/cjs/node_modules/mobx/dist/mobx.esm.js +5378 -0
- package/dist/cjs/node_modules/mobx/dist/mobx.esm.js.map +1 -0
- package/dist/esm/components/layers/leaflet/hooks/useGetLeafletLayer.js +1 -1
- package/dist/esm/components/layers/leaflet/hooks/useGetLeafletLayer.js.map +1 -1
- package/dist/esm/components/layers/leaflet/leaflet.js +1 -1
- package/dist/esm/components/layers/leaflet/leaflet.js.map +1 -1
- package/dist/esm/configs/global/global.js +1 -1
- package/dist/esm/configs/global/global.js.map +1 -1
- package/dist/esm/node_modules/mobx/dist/mobx.esm.js +2 -0
- package/dist/esm/node_modules/mobx/dist/mobx.esm.js.map +1 -0
- package/dist/esm/scene.yaml.js +1 -1
- package/dist/esm/types/components/layers/leaflet/hooks/useGetLeafletLayer.d.ts.map +1 -1
- package/dist/esm/types/components/layers/leaflet/leaflet.d.ts.map +1 -1
- package/dist/esm/types/configs/global/global.d.ts +6 -3
- package/dist/esm/types/configs/global/global.d.ts.map +1 -1
- package/dist/esm/types/configs/global/types.d.ts +5 -0
- package/dist/esm/types/configs/global/types.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var sceneTiles = require('@/../scene.yaml');
|
|
5
|
+
var global = require('../../../../configs/global/global.js');
|
|
5
6
|
|
|
6
7
|
function _interopNamespaceDefault(e) {
|
|
7
8
|
var n = Object.create(null);
|
|
@@ -23,21 +24,26 @@ function _interopNamespaceDefault(e) {
|
|
|
23
24
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
24
25
|
|
|
25
26
|
const useGetLeafletLayer = () => {
|
|
27
|
+
const { instance: { isValidApiKey }, } = global.GlobalConfig;
|
|
26
28
|
const [layer, setLayer] = React__namespace.useState(null);
|
|
27
|
-
const getLeafletLayer = () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const getLeafletLayer = (isValidApiKey) => {
|
|
30
|
+
if (isValidApiKey) {
|
|
31
|
+
Promise.resolve().then(function () { return require('../../../../node_modules/tangram/dist/tangram.min.js'); }).then(() => {
|
|
32
|
+
if (window.Tangram) {
|
|
33
|
+
const leafletLayer = window.Tangram.leafletLayer({
|
|
34
|
+
scene: sceneTiles,
|
|
35
|
+
});
|
|
36
|
+
setLayer(leafletLayer);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
34
40
|
};
|
|
35
41
|
React__namespace.useEffect(() => {
|
|
36
|
-
getLeafletLayer();
|
|
42
|
+
getLeafletLayer(isValidApiKey);
|
|
37
43
|
return () => {
|
|
38
44
|
setLayer(null);
|
|
39
45
|
};
|
|
40
|
-
}, []);
|
|
46
|
+
}, [isValidApiKey]);
|
|
41
47
|
return layer;
|
|
42
48
|
};
|
|
43
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetLeafletLayer.js","sources":["../../../../../../src/components/layers/leaflet/hooks/useGetLeafletLayer.ts"],"sourcesContent":["import * as React from 'react';\r\n\r\nimport sceneTiles from '@/../scene.yaml';\r\nimport { Nullable } from '@/types';\r\n\r\nimport { TangramLeafletLayer } from '../types';\r\n\r\nexport const useGetLeafletLayer = () => {\r\n const [layer, setLayer] = React.useState<Nullable<TangramLeafletLayer>>(null);\r\n\r\n const getLeafletLayer = () => {\r\n import('tangram').then(() => {\r\n
|
|
1
|
+
{"version":3,"file":"useGetLeafletLayer.js","sources":["../../../../../../src/components/layers/leaflet/hooks/useGetLeafletLayer.ts"],"sourcesContent":["import * as React from 'react';\r\n\r\nimport sceneTiles from '@/../scene.yaml';\r\nimport { GlobalConfig } from '@/configs';\r\nimport { Nullable } from '@/types';\r\n\r\nimport { TangramLeafletLayer } from '../types';\r\n\r\nexport const useGetLeafletLayer = () => {\r\n const {\r\n instance: { isValidApiKey },\r\n } = GlobalConfig;\r\n\r\n const [layer, setLayer] = React.useState<Nullable<TangramLeafletLayer>>(null);\r\n\r\n const getLeafletLayer = (isValidApiKey: boolean) => {\r\n if (isValidApiKey) {\r\n import('tangram').then(() => {\r\n if (window.Tangram) {\r\n const leafletLayer = window.Tangram.leafletLayer({\r\n scene: sceneTiles,\r\n });\r\n\r\n setLayer(leafletLayer);\r\n }\r\n });\r\n }\r\n };\r\n\r\n React.useEffect(() => {\r\n getLeafletLayer(isValidApiKey);\r\n\r\n return () => {\r\n setLayer(null);\r\n };\r\n }, [isValidApiKey]);\r\n\r\n return layer;\r\n};\r\n"],"names":["GlobalConfig","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAQO,MAAM,kBAAkB,GAAG,MAAK;IACrC,MAAM,EACJ,QAAQ,EAAE,EAAE,aAAa,EAAE,GAC5B,GAAGA,mBAAY;AAEhB,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGC,gBAAK,CAAC,QAAQ,CAAgC,IAAI,CAAC;AAE7E,IAAA,MAAM,eAAe,GAAG,CAAC,aAAsB,KAAI;QACjD,IAAI,aAAa,EAAE;AACjB,YAAA,oDAAO,sDAAS,KAAC,CAAC,IAAI,CAAC,MAAK;AAC1B,gBAAA,IAAI,MAAM,CAAC,OAAO,EAAE;AAClB,oBAAA,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;AAC/C,wBAAA,KAAK,EAAE,UAAU;AAClB,qBAAA,CAAC;oBAEF,QAAQ,CAAC,YAAY,CAAC;gBACxB;AACF,YAAA,CAAC,CAAC;QACJ;AACF,IAAA,CAAC;AAED,IAAAA,gBAAK,CAAC,SAAS,CAAC,MAAK;QACnB,eAAe,CAAC,aAAa,CAAC;AAE9B,QAAA,OAAO,MAAK;YACV,QAAQ,CAAC,IAAI,CAAC;AAChB,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;AAEnB,IAAA,OAAO,KAAK;AACd;;;;"}
|
|
@@ -27,18 +27,14 @@ function _interopNamespaceDefault(e) {
|
|
|
27
27
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
28
28
|
|
|
29
29
|
const LeafletLayer = () => {
|
|
30
|
+
const { instance: { isValidApiKey }, } = global.GlobalConfig;
|
|
30
31
|
const layer = useGetLeafletLayer.useGetLeafletLayer();
|
|
31
|
-
const { instance } = global.GlobalConfig;
|
|
32
32
|
const map = hooks.useMap();
|
|
33
33
|
React__namespace.useEffect(() => {
|
|
34
|
-
if (layer) {
|
|
35
|
-
|
|
36
|
-
if (isValidKey) {
|
|
37
|
-
map.addLayer(layer);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
34
|
+
if (layer && isValidApiKey) {
|
|
35
|
+
map.addLayer(layer);
|
|
40
36
|
}
|
|
41
|
-
}, [layer]);
|
|
37
|
+
}, [layer, isValidApiKey]);
|
|
42
38
|
return null;
|
|
43
39
|
};
|
|
44
40
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leaflet.js","sources":["../../../../../src/components/layers/leaflet/leaflet.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMap } from 'react-leaflet';\n\nimport { GlobalConfig } from '@/configs';\n\nimport { useGetLeafletLayer } from './hooks/useGetLeafletLayer';\n\nconst LeafletLayer: React.FC = () => {\n const
|
|
1
|
+
{"version":3,"file":"leaflet.js","sources":["../../../../../src/components/layers/leaflet/leaflet.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMap } from 'react-leaflet';\n\nimport { GlobalConfig } from '@/configs';\n\nimport { useGetLeafletLayer } from './hooks/useGetLeafletLayer';\n\nconst LeafletLayer: React.FC = () => {\n const {\n instance: { isValidApiKey },\n } = GlobalConfig;\n\n const layer = useGetLeafletLayer();\n\n const map = useMap();\n\n React.useEffect(() => {\n if (layer && isValidApiKey) {\n map.addLayer(layer);\n }\n }, [layer, isValidApiKey]);\n\n return null;\n};\n\nexport default LeafletLayer;\n"],"names":["GlobalConfig","useGetLeafletLayer","useMap","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,YAAY,GAAa,MAAK;IAClC,MAAM,EACJ,QAAQ,EAAE,EAAE,aAAa,EAAE,GAC5B,GAAGA,mBAAY;AAEhB,IAAA,MAAM,KAAK,GAAGC,qCAAkB,EAAE;AAElC,IAAA,MAAM,GAAG,GAAGC,YAAM,EAAE;AAEpB,IAAAC,gBAAK,CAAC,SAAS,CAAC,MAAK;AACnB,QAAA,IAAI,KAAK,IAAI,aAAa,EAAE;AAC1B,YAAA,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;QACrB;AACF,IAAA,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;AAE1B,IAAA,OAAO,IAAI;AACb;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var mobx_esm = require('../../node_modules/mobx/dist/mobx.esm.js');
|
|
3
4
|
var api_service = require('../../services/api/api.service.js');
|
|
4
5
|
|
|
5
6
|
class GlobalConfig {
|
|
@@ -18,40 +19,43 @@ class GlobalConfig {
|
|
|
18
19
|
}
|
|
19
20
|
return GlobalConfig._instance;
|
|
20
21
|
}
|
|
21
|
-
constructor({ apiKey }) {
|
|
22
|
-
this
|
|
22
|
+
constructor({ apiKey, onCheck }) {
|
|
23
|
+
mobx_esm.makeAutoObservable(this);
|
|
24
|
+
this._apiKey = apiKey;
|
|
25
|
+
this._getCheckKeyData().then((data) => {
|
|
26
|
+
if (data) {
|
|
27
|
+
const { valid } = data;
|
|
28
|
+
onCheck?.(data);
|
|
29
|
+
this.isValidApiKey = valid;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
23
32
|
}
|
|
24
33
|
_apiKey = '';
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
_isValidApiKey = false;
|
|
35
|
+
get isValidApiKey() {
|
|
36
|
+
return this._isValidApiKey;
|
|
27
37
|
}
|
|
28
|
-
set
|
|
29
|
-
this.
|
|
38
|
+
set isValidApiKey(value) {
|
|
39
|
+
this._isValidApiKey = value;
|
|
30
40
|
}
|
|
31
|
-
async
|
|
32
|
-
|
|
33
|
-
throw new Error('Ключ не задан');
|
|
34
|
-
}
|
|
35
|
-
const isValidKey = await api_service.apiService
|
|
41
|
+
async _getCheckKeyData() {
|
|
42
|
+
const checkKeyData = await api_service.apiService
|
|
36
43
|
.get({
|
|
37
44
|
url: 'check_tile_token',
|
|
38
45
|
config: {
|
|
39
46
|
params: {
|
|
40
|
-
tile_token: this.
|
|
47
|
+
tile_token: this._apiKey,
|
|
41
48
|
},
|
|
42
49
|
},
|
|
43
50
|
})
|
|
44
|
-
.then((
|
|
45
|
-
return valid;
|
|
46
|
-
})
|
|
51
|
+
.then((data) => data)
|
|
47
52
|
.catch(({ response, }) => {
|
|
48
53
|
if (response) {
|
|
49
|
-
const { data: { detail
|
|
50
|
-
return
|
|
54
|
+
const { data: { detail }, } = response;
|
|
55
|
+
return detail;
|
|
51
56
|
}
|
|
52
|
-
return false;
|
|
53
57
|
});
|
|
54
|
-
return
|
|
58
|
+
return checkKeyData;
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.js","sources":["../../../../src/configs/global/global.ts"],"sourcesContent":["import { AxiosError } from 'axios';\r\n\r\nimport { apiService } from '@/services';\r\nimport { Nullable } from '@/types';\r\n\r\nexport interface ConfigOptions {\r\n apiKey: string;\r\n}\r\n\r\nexport class GlobalConfig {\r\n private static _instance: Nullable<GlobalConfig> = null;\r\n\r\n public static initialize(options: ConfigOptions) {\r\n if (!GlobalConfig._instance) {\r\n GlobalConfig._instance = new GlobalConfig(options);\r\n }\r\n }\r\n\r\n public static deactivate() {\r\n this._instance = null;\r\n }\r\n\r\n public static get instance() {\r\n if (!GlobalConfig._instance) {\r\n throw new Error(\r\n 'Dartcom Config не инициализирован с приватным ключом. Вызовите Config.initialize(...) первым, чтобы иметь возможность пользоваться компонентами нашей библиотеки',\r\n );\r\n }\r\n\r\n return GlobalConfig._instance;\r\n }\r\n\r\n private constructor({ apiKey }: ConfigOptions) {\r\n this.
|
|
1
|
+
{"version":3,"file":"global.js","sources":["../../../../src/configs/global/global.ts"],"sourcesContent":["import { AxiosError } from 'axios';\r\nimport { makeAutoObservable } from 'mobx';\r\n\r\nimport { apiService } from '@/services';\r\nimport { Nullable } from '@/types';\r\n\r\nimport { ResponseData } from './types';\r\n\r\nexport interface ConfigOptions {\r\n apiKey: string;\r\n\r\n onCheck?: (data: ResponseData) => void;\r\n}\r\n\r\nexport class GlobalConfig {\r\n private static _instance: Nullable<GlobalConfig> = null;\r\n\r\n public static initialize(options: ConfigOptions) {\r\n if (!GlobalConfig._instance) {\r\n GlobalConfig._instance = new GlobalConfig(options);\r\n }\r\n }\r\n\r\n public static deactivate() {\r\n this._instance = null;\r\n }\r\n\r\n public static get instance() {\r\n if (!GlobalConfig._instance) {\r\n throw new Error(\r\n 'Dartcom Config не инициализирован с приватным ключом. Вызовите Config.initialize(...) первым, чтобы иметь возможность пользоваться компонентами нашей библиотеки',\r\n );\r\n }\r\n\r\n return GlobalConfig._instance;\r\n }\r\n\r\n private constructor({ apiKey, onCheck }: ConfigOptions) {\r\n makeAutoObservable(this);\r\n\r\n this._apiKey = apiKey;\r\n\r\n this._getCheckKeyData().then((data) => {\r\n if (data) {\r\n const { valid } = data;\r\n\r\n onCheck?.(data);\r\n\r\n this.isValidApiKey = valid;\r\n }\r\n });\r\n }\r\n\r\n private _apiKey = '';\r\n\r\n private _isValidApiKey = false;\r\n public get isValidApiKey() {\r\n return this._isValidApiKey;\r\n }\r\n public set isValidApiKey(value) {\r\n this._isValidApiKey = value;\r\n }\r\n\r\n public async _getCheckKeyData() {\r\n const checkKeyData = await apiService\r\n .get<ResponseData>({\r\n url: 'check_tile_token',\r\n config: {\r\n params: {\r\n tile_token: this._apiKey,\r\n },\r\n },\r\n })\r\n .then((data) => data)\r\n .catch(\r\n ({\r\n response,\r\n }: AxiosError<{\r\n detail: ResponseData;\r\n }>) => {\r\n if (response) {\r\n const {\r\n data: { detail },\r\n } = response;\r\n\r\n return detail;\r\n }\r\n },\r\n );\r\n\r\n return checkKeyData;\r\n }\r\n}\r\n"],"names":["makeAutoObservable","apiService"],"mappings":";;;;;MAca,YAAY,CAAA;AACf,IAAA,OAAO,SAAS,GAA2B,IAAI;IAEhD,OAAO,UAAU,CAAC,OAAsB,EAAA;AAC7C,QAAA,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;YAC3B,YAAY,CAAC,SAAS,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC;QACpD;IACF;AAEO,IAAA,OAAO,UAAU,GAAA;AACtB,QAAA,IAAI,CAAC,SAAS,GAAG,IAAI;IACvB;AAEO,IAAA,WAAW,QAAQ,GAAA;AACxB,QAAA,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;AAC3B,YAAA,MAAM,IAAI,KAAK,CACb,kKAAkK,CACnK;QACH;QAEA,OAAO,YAAY,CAAC,SAAS;IAC/B;AAEA,IAAA,WAAA,CAAoB,EAAE,MAAM,EAAE,OAAO,EAAiB,EAAA;QACpDA,2BAAkB,CAAC,IAAI,CAAC;AAExB,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM;QAErB,IAAI,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,KAAI;YACpC,IAAI,IAAI,EAAE;AACR,gBAAA,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;AAEtB,gBAAA,OAAO,GAAG,IAAI,CAAC;AAEf,gBAAA,IAAI,CAAC,aAAa,GAAG,KAAK;YAC5B;AACF,QAAA,CAAC,CAAC;IACJ;IAEQ,OAAO,GAAG,EAAE;IAEZ,cAAc,GAAG,KAAK;AAC9B,IAAA,IAAW,aAAa,GAAA;QACtB,OAAO,IAAI,CAAC,cAAc;IAC5B;IACA,IAAW,aAAa,CAAC,KAAK,EAAA;AAC5B,QAAA,IAAI,CAAC,cAAc,GAAG,KAAK;IAC7B;AAEO,IAAA,MAAM,gBAAgB,GAAA;QAC3B,MAAM,YAAY,GAAG,MAAMC;AACxB,aAAA,GAAG,CAAe;AACjB,YAAA,GAAG,EAAE,kBAAkB;AACvB,YAAA,MAAM,EAAE;AACN,gBAAA,MAAM,EAAE;oBACN,UAAU,EAAE,IAAI,CAAC,OAAO;AACzB,iBAAA;AACF,aAAA;SACF;AACA,aAAA,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI;AACnB,aAAA,KAAK,CACJ,CAAC,EACC,QAAQ,GAGR,KAAI;YACJ,IAAI,QAAQ,EAAE;gBACZ,MAAM,EACJ,IAAI,EAAE,EAAE,MAAM,EAAE,GACjB,GAAG,QAAQ;AAEZ,gBAAA,OAAO,MAAM;YACf;AACF,QAAA,CAAC,CACF;AAEH,QAAA,OAAO,YAAY;IACrB;;;;;"}
|