@zohodesk/dot 1.0.0-temp-193.1 → 1.0.0-temp-193.3
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/es/v1/DotProvider/downloadAssets.js +29 -0
- package/es/v1/DotProvider/libraryChunks/dynamicImports.js +11 -3
- package/es/v1/DotProvider/useDotProvider.js +10 -10
- package/es/v1/DotProvider/utils/errorValidation.js +13 -0
- package/es/v1/DotProvider/utils/importFiles.js +2 -3
- package/lib/v1/DotProvider/downloadAssets.js +35 -0
- package/lib/v1/DotProvider/libraryChunks/dynamicImports.js +11 -3
- package/lib/v1/DotProvider/useDotProvider.js +12 -12
- package/lib/v1/DotProvider/utils/errorValidation.js +18 -0
- package/lib/v1/DotProvider/utils/importFiles.js +2 -5
- package/package.json +5 -5
- package/result.json +1 -1
- package/es/v1/DotProvider/providerAssets.js +0 -38
- package/es/v1/DotProvider/utils/errorMessage.js +0 -7
- package/lib/v1/DotProvider/providerAssets.js +0 -44
- package/lib/v1/DotProvider/utils/errorMessage.js +0 -14
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getAppearance, getTheme, getZoomSize, getFontSize } from './libraryChunks/dynamicImports';
|
|
2
|
+
export function downloadAssets(_ref) {
|
|
3
|
+
let {
|
|
4
|
+
appearance,
|
|
5
|
+
theme,
|
|
6
|
+
baseZoomSize,
|
|
7
|
+
baseFontSize,
|
|
8
|
+
providerElement,
|
|
9
|
+
sizeVariableName,
|
|
10
|
+
fontSizeVariableName
|
|
11
|
+
} = _ref;
|
|
12
|
+
const promises = [];
|
|
13
|
+
const libAppearance = getAppearance(appearance);
|
|
14
|
+
promises.push(libAppearance);
|
|
15
|
+
const libTheme = getTheme(appearance, theme);
|
|
16
|
+
promises.push(libTheme);
|
|
17
|
+
const zoomSize = getZoomSize();
|
|
18
|
+
promises.push(zoomSize);
|
|
19
|
+
const fontSize = getFontSize();
|
|
20
|
+
promises.push(fontSize);
|
|
21
|
+
const providerElem = providerElement();
|
|
22
|
+
|
|
23
|
+
if (providerElem) {
|
|
24
|
+
providerElem.style.setProperty(sizeVariableName, baseZoomSize);
|
|
25
|
+
providerElem.style.setProperty(fontSizeVariableName, baseFontSize);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return Promise.all(promises);
|
|
29
|
+
}
|
|
@@ -2,13 +2,17 @@ import { importFiles } from "../../../../es/v1/DotProvider/utils/importFiles";
|
|
|
2
2
|
import { appearanceImports, appearanceMapping } from "../utils/appearanceProperties";
|
|
3
3
|
import { themeImports, themeMapping } from "../utils/themeProperties";
|
|
4
4
|
import { imports, mapping } from "../utils/sizeProperties";
|
|
5
|
-
import {
|
|
5
|
+
import { errorValidation } from "../utils/errorValidation";
|
|
6
6
|
const defaultLib = ['component', 'dot', 'svg'];
|
|
7
7
|
const modeArray = ['light', 'dark', 'pureDark'];
|
|
8
8
|
const themeArray = ['blue', 'green', 'orange', 'red', 'yellow'];
|
|
9
9
|
export function getAppearance(mode) {
|
|
10
10
|
const libArray = defaultLib;
|
|
11
|
-
|
|
11
|
+
errorValidation({
|
|
12
|
+
options: modeArray,
|
|
13
|
+
value: mode,
|
|
14
|
+
type: 'appearance'
|
|
15
|
+
});
|
|
12
16
|
const importFilesArray = [];
|
|
13
17
|
libArray.map(libName => {
|
|
14
18
|
const importFile = appearanceMapping[libName][mode];
|
|
@@ -21,7 +25,11 @@ export function getAppearance(mode) {
|
|
|
21
25
|
}
|
|
22
26
|
export function getTheme(mode, theme) {
|
|
23
27
|
const libArray = defaultLib;
|
|
24
|
-
|
|
28
|
+
errorValidation({
|
|
29
|
+
options: themeArray,
|
|
30
|
+
value: theme,
|
|
31
|
+
type: 'theme'
|
|
32
|
+
});
|
|
25
33
|
const importFilesArray = [];
|
|
26
34
|
libArray.map(libName => {
|
|
27
35
|
const importFile = themeMapping[libName][theme][mode];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLayoutEffect } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { downloadAssets } from './downloadAssets';
|
|
3
3
|
import '@zohodesk/components/assets/Contrast/lightContrastLightness.module.css';
|
|
4
4
|
import '@zohodesk/components/assets/Contrast/darkContrastLightness.module.css';
|
|
5
5
|
import '@zohodesk/components/assets/Contrast/pureDarkContrastLightness.module.css';
|
|
@@ -14,27 +14,27 @@ function useDotProvider(_ref) {
|
|
|
14
14
|
let {
|
|
15
15
|
appearance = 'light',
|
|
16
16
|
theme = 'blue',
|
|
17
|
-
baseZoomSize =
|
|
18
|
-
baseFontSize =
|
|
19
|
-
|
|
17
|
+
baseZoomSize = '1px',
|
|
18
|
+
baseFontSize = '16px',
|
|
19
|
+
providerElement = () => {
|
|
20
20
|
return document.documentElement;
|
|
21
21
|
},
|
|
22
22
|
getAssetPromise,
|
|
23
|
-
sizeVariableName = '--
|
|
24
|
-
fontSizeVariableName = '--
|
|
23
|
+
sizeVariableName = '--zd_baseUnit',
|
|
24
|
+
fontSizeVariableName = '--zd_baseFontUnit'
|
|
25
25
|
} = _ref;
|
|
26
26
|
useLayoutEffect(() => {
|
|
27
|
-
|
|
27
|
+
const assetPromise = downloadAssets({
|
|
28
28
|
appearance,
|
|
29
29
|
theme,
|
|
30
30
|
baseZoomSize,
|
|
31
31
|
baseFontSize,
|
|
32
|
-
|
|
33
|
-
getAssetPromise,
|
|
32
|
+
providerElement,
|
|
34
33
|
sizeVariableName,
|
|
35
34
|
fontSizeVariableName
|
|
36
35
|
});
|
|
37
|
-
|
|
36
|
+
getAssetPromise && getAssetPromise(assetPromise);
|
|
37
|
+
}, [appearance, theme, baseZoomSize, baseFontSize, providerElement, getAssetPromise, sizeVariableName, fontSizeVariableName]);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export default useDotProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function errorValidation(_ref) {
|
|
2
|
+
let {
|
|
3
|
+
options,
|
|
4
|
+
value,
|
|
5
|
+
type
|
|
6
|
+
} = _ref;
|
|
7
|
+
|
|
8
|
+
if (!options.includes(value)) {
|
|
9
|
+
throw new Error(`We do not support the '${value} in ${type}'. Please provide valid '${type}' values or check spelling.`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
@@ -8,11 +8,10 @@ export function importFiles(_ref) {
|
|
|
8
8
|
if (imports[fileKey]) {
|
|
9
9
|
promises.push(imports[fileKey]());
|
|
10
10
|
} else {
|
|
11
|
-
console.error(`Import not found for ${fileKey}`);
|
|
11
|
+
console.error(`Import not found for ${fileKey} from ${imports}`);
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
return Promise.all(promises).
|
|
14
|
+
return Promise.all(promises).catch(error => {
|
|
15
15
|
console.error(`Error importing files:`, error);
|
|
16
|
-
return Promise.reject(error);
|
|
17
16
|
});
|
|
18
17
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.downloadAssets = downloadAssets;
|
|
7
|
+
|
|
8
|
+
var _dynamicImports = require("./libraryChunks/dynamicImports");
|
|
9
|
+
|
|
10
|
+
function downloadAssets(_ref) {
|
|
11
|
+
var appearance = _ref.appearance,
|
|
12
|
+
theme = _ref.theme,
|
|
13
|
+
baseZoomSize = _ref.baseZoomSize,
|
|
14
|
+
baseFontSize = _ref.baseFontSize,
|
|
15
|
+
providerElement = _ref.providerElement,
|
|
16
|
+
sizeVariableName = _ref.sizeVariableName,
|
|
17
|
+
fontSizeVariableName = _ref.fontSizeVariableName;
|
|
18
|
+
var promises = [];
|
|
19
|
+
var libAppearance = (0, _dynamicImports.getAppearance)(appearance);
|
|
20
|
+
promises.push(libAppearance);
|
|
21
|
+
var libTheme = (0, _dynamicImports.getTheme)(appearance, theme);
|
|
22
|
+
promises.push(libTheme);
|
|
23
|
+
var zoomSize = (0, _dynamicImports.getZoomSize)();
|
|
24
|
+
promises.push(zoomSize);
|
|
25
|
+
var fontSize = (0, _dynamicImports.getFontSize)();
|
|
26
|
+
promises.push(fontSize);
|
|
27
|
+
var providerElem = providerElement();
|
|
28
|
+
|
|
29
|
+
if (providerElem) {
|
|
30
|
+
providerElem.style.setProperty(sizeVariableName, baseZoomSize);
|
|
31
|
+
providerElem.style.setProperty(fontSizeVariableName, baseFontSize);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return Promise.all(promises);
|
|
35
|
+
}
|
|
@@ -16,7 +16,7 @@ var _themeProperties = require("../utils/themeProperties");
|
|
|
16
16
|
|
|
17
17
|
var _sizeProperties = require("../utils/sizeProperties");
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _errorValidation = require("../utils/errorValidation");
|
|
20
20
|
|
|
21
21
|
var defaultLib = ['component', 'dot', 'svg'];
|
|
22
22
|
var modeArray = ['light', 'dark', 'pureDark'];
|
|
@@ -24,7 +24,11 @@ var themeArray = ['blue', 'green', 'orange', 'red', 'yellow'];
|
|
|
24
24
|
|
|
25
25
|
function getAppearance(mode) {
|
|
26
26
|
var libArray = defaultLib;
|
|
27
|
-
(0,
|
|
27
|
+
(0, _errorValidation.errorValidation)({
|
|
28
|
+
options: modeArray,
|
|
29
|
+
value: mode,
|
|
30
|
+
type: 'appearance'
|
|
31
|
+
});
|
|
28
32
|
var importFilesArray = [];
|
|
29
33
|
libArray.map(function (libName) {
|
|
30
34
|
var importFile = _appearanceProperties.appearanceMapping[libName][mode];
|
|
@@ -38,7 +42,11 @@ function getAppearance(mode) {
|
|
|
38
42
|
|
|
39
43
|
function getTheme(mode, theme) {
|
|
40
44
|
var libArray = defaultLib;
|
|
41
|
-
(0,
|
|
45
|
+
(0, _errorValidation.errorValidation)({
|
|
46
|
+
options: themeArray,
|
|
47
|
+
value: theme,
|
|
48
|
+
type: 'theme'
|
|
49
|
+
});
|
|
42
50
|
var importFilesArray = [];
|
|
43
51
|
libArray.map(function (libName) {
|
|
44
52
|
var importFile = _themeProperties.themeMapping[libName][theme][mode];
|
|
@@ -7,7 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _downloadAssets = require("./downloadAssets");
|
|
11
11
|
|
|
12
12
|
require("@zohodesk/components/assets/Contrast/lightContrastLightness.module.css");
|
|
13
13
|
|
|
@@ -33,30 +33,30 @@ function useDotProvider(_ref) {
|
|
|
33
33
|
_ref$theme = _ref.theme,
|
|
34
34
|
theme = _ref$theme === void 0 ? 'blue' : _ref$theme,
|
|
35
35
|
_ref$baseZoomSize = _ref.baseZoomSize,
|
|
36
|
-
baseZoomSize = _ref$baseZoomSize === void 0 ?
|
|
36
|
+
baseZoomSize = _ref$baseZoomSize === void 0 ? '1px' : _ref$baseZoomSize,
|
|
37
37
|
_ref$baseFontSize = _ref.baseFontSize,
|
|
38
|
-
baseFontSize = _ref$baseFontSize === void 0 ?
|
|
39
|
-
_ref$
|
|
40
|
-
|
|
38
|
+
baseFontSize = _ref$baseFontSize === void 0 ? '16px' : _ref$baseFontSize,
|
|
39
|
+
_ref$providerElement = _ref.providerElement,
|
|
40
|
+
providerElement = _ref$providerElement === void 0 ? function () {
|
|
41
41
|
return document.documentElement;
|
|
42
|
-
} : _ref$
|
|
42
|
+
} : _ref$providerElement,
|
|
43
43
|
getAssetPromise = _ref.getAssetPromise,
|
|
44
44
|
_ref$sizeVariableName = _ref.sizeVariableName,
|
|
45
|
-
sizeVariableName = _ref$sizeVariableName === void 0 ? '--
|
|
45
|
+
sizeVariableName = _ref$sizeVariableName === void 0 ? '--zd_baseUnit' : _ref$sizeVariableName,
|
|
46
46
|
_ref$fontSizeVariable = _ref.fontSizeVariableName,
|
|
47
|
-
fontSizeVariableName = _ref$fontSizeVariable === void 0 ? '--
|
|
47
|
+
fontSizeVariableName = _ref$fontSizeVariable === void 0 ? '--zd_baseFontUnit' : _ref$fontSizeVariable;
|
|
48
48
|
(0, _react.useLayoutEffect)(function () {
|
|
49
|
-
(0,
|
|
49
|
+
var assetPromise = (0, _downloadAssets.downloadAssets)({
|
|
50
50
|
appearance: appearance,
|
|
51
51
|
theme: theme,
|
|
52
52
|
baseZoomSize: baseZoomSize,
|
|
53
53
|
baseFontSize: baseFontSize,
|
|
54
|
-
|
|
55
|
-
getAssetPromise: getAssetPromise,
|
|
54
|
+
providerElement: providerElement,
|
|
56
55
|
sizeVariableName: sizeVariableName,
|
|
57
56
|
fontSizeVariableName: fontSizeVariableName
|
|
58
57
|
});
|
|
59
|
-
|
|
58
|
+
getAssetPromise && getAssetPromise(assetPromise);
|
|
59
|
+
}, [appearance, theme, baseZoomSize, baseFontSize, providerElement, getAssetPromise, sizeVariableName, fontSizeVariableName]);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
var _default = useDotProvider;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.errorValidation = errorValidation;
|
|
7
|
+
|
|
8
|
+
function errorValidation(_ref) {
|
|
9
|
+
var options = _ref.options,
|
|
10
|
+
value = _ref.value,
|
|
11
|
+
type = _ref.type;
|
|
12
|
+
|
|
13
|
+
if (!options.includes(value)) {
|
|
14
|
+
throw new Error("We do not support the '".concat(value, " in ").concat(type, "'. Please provide valid '").concat(type, "' values or check spelling."));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
@@ -13,13 +13,10 @@ function importFiles(_ref) {
|
|
|
13
13
|
if (imports[fileKey]) {
|
|
14
14
|
promises.push(imports[fileKey]());
|
|
15
15
|
} else {
|
|
16
|
-
console.error("Import not found for ".concat(fileKey));
|
|
16
|
+
console.error("Import not found for ".concat(fileKey, " from ").concat(imports));
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
return Promise.all(promises)
|
|
20
|
-
return Promise.resolve();
|
|
21
|
-
})["catch"](function (error) {
|
|
19
|
+
return Promise.all(promises)["catch"](function (error) {
|
|
22
20
|
console.error("Error importing files:", error);
|
|
23
|
-
return Promise.reject(error);
|
|
24
21
|
});
|
|
25
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/dot",
|
|
3
|
-
"version": "1.0.0-temp-193.
|
|
3
|
+
"version": "1.0.0-temp-193.3",
|
|
4
4
|
"main": "lib/index",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"@zohodesk/a11y": "2.2.3",
|
|
66
66
|
"@zohodesk/components": "1.2.40",
|
|
67
67
|
"@zohodesk/hooks": "2.0.4",
|
|
68
|
-
"@zohodesk/icons": "1.0.
|
|
68
|
+
"@zohodesk/icons": "1.0.51",
|
|
69
69
|
"@zohodesk/svg": "1.1.14",
|
|
70
|
-
"@zohodesk/utils": "1.3.
|
|
70
|
+
"@zohodesk/utils": "1.3.14",
|
|
71
71
|
"@zohodesk/variables": "1.0.0",
|
|
72
72
|
"@zohodesk/virtualizer": "1.0.3",
|
|
73
73
|
"react-sortable-hoc": "^0.8.3",
|
|
@@ -77,12 +77,12 @@
|
|
|
77
77
|
"velocity-react": "1.4.3",
|
|
78
78
|
"@zohodesk/variables": "1.0.0",
|
|
79
79
|
"@zohodesk/components": "1.2.40",
|
|
80
|
-
"@zohodesk/icons": "1.0.
|
|
80
|
+
"@zohodesk/icons": "1.0.51",
|
|
81
81
|
"@zohodesk/svg": "1.1.14",
|
|
82
82
|
"@zohodesk/virtualizer": "1.0.3",
|
|
83
83
|
"react-sortable-hoc": "^0.8.3",
|
|
84
84
|
"@zohodesk/hooks": "2.0.4",
|
|
85
|
-
"@zohodesk/utils": "1.3.
|
|
85
|
+
"@zohodesk/utils": "1.3.14",
|
|
86
86
|
"@zohodesk/a11y": "2.2.3"
|
|
87
87
|
}
|
|
88
88
|
}
|