@epxing/dashboard 0.0.0-stage → 5.3.0-beta.2
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/API.md +80 -0
- package/README.md +41 -2
- package/dist/_virtual/_plugin-vue_export-helper.js +10 -0
- package/dist/_virtual/preload-helper.js +88 -0
- package/dist/assets/technology_bg-oWIS2awO.jpg +0 -0
- package/dist/src/Dashboard.js +333 -0
- package/dist/src/DashboardGrid.js +183 -0
- package/dist/src/DesignGrid.js +712 -0
- package/dist/src/DesignItem.js +64 -0
- package/dist/src/Div.js +409 -0
- package/dist/src/Header.js +386 -0
- package/dist/src/Preview.js +28 -0
- package/dist/src/Tabs.js +469 -0
- package/dist/src/Title.js +102 -0
- package/dist/src/Widget.js +267 -0
- package/dist/src/chart-request-scope.js +33 -0
- package/dist/src/design-target.js +58 -0
- package/dist/src/grid/compact.js +69 -0
- package/dist/src/grid/compat/GridItem.js +36 -0
- package/dist/src/grid/compat/GridLayout.js +77 -0
- package/dist/src/grid/designState.js +22 -0
- package/dist/src/grid/engines.js +26 -0
- package/dist/src/grid/geometry.js +45 -0
- package/dist/src/grid/gridstackParams.js +70 -0
- package/dist/src/grid/mixins.js +109 -0
- package/dist/src/grid/model.js +224 -0
- package/dist/src/grid/useViewportGate.js +56 -0
- package/dist/src/index.js +27 -0
- package/dist/src/layout-util.js +109 -0
- package/dist/src/mobile-design.js +51 -0
- package/dist/src/theme-style.js +134 -0
- package/dist/style.css +1009 -0
- package/package.json +86 -3
- package/src/Dashboard.vue +459 -0
- package/src/DashboardGrid.vue +189 -0
- package/src/DesignGrid.vue +851 -0
- package/src/DesignItem.vue +124 -0
- package/src/Div.vue +419 -0
- package/src/Header.vue +501 -0
- package/src/Preview.vue +30 -0
- package/src/Tabs.vue +484 -0
- package/src/Title.vue +107 -0
- package/src/Widget.vue +354 -0
- package/src/chart-request-scope.js +22 -0
- package/src/design-target.js +55 -0
- package/src/grid/compact.js +81 -0
- package/src/grid/compat/GridItem.vue +30 -0
- package/src/grid/compat/GridLayout.vue +76 -0
- package/src/grid/designState.js +17 -0
- package/src/grid/engines.js +22 -0
- package/src/grid/geometry.js +55 -0
- package/src/grid/gridstackParams.js +72 -0
- package/src/grid/mixins.js +114 -0
- package/src/grid/model.js +259 -0
- package/src/grid/useViewportGate.js +57 -0
- package/src/index.js +28 -0
- package/src/layout-util.js +157 -0
- package/src/mobile-design.js +50 -0
- package/src/theme-style.js +185 -0
- package/types/div.d.ts +1 -0
- package/types/index.d.ts +7 -0
- package/types/tabs.d.ts +1 -0
- package/types/title.d.ts +1 -0
- package/types/widget.d.ts +1 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import '../style.css';
|
|
2
|
+
const kebabCase = (key) => key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
3
|
+
const camelCase = (key) => key.replace(/-(\w)/g, (s, c) => c.toUpperCase());
|
|
4
|
+
const ACCENT_BASE = {
|
|
5
|
+
content: "''",
|
|
6
|
+
position: "absolute",
|
|
7
|
+
top: "0",
|
|
8
|
+
left: "0",
|
|
9
|
+
right: "0",
|
|
10
|
+
height: "3px",
|
|
11
|
+
"pointer-events": "none"
|
|
12
|
+
};
|
|
13
|
+
function formatStyleToCss(style, getFileUrl) {
|
|
14
|
+
if (!style) return "";
|
|
15
|
+
return Object.keys(style).filter((key) => style[key] !== "" && style[key] !== null && style[key] !== void 0).map((key) => {
|
|
16
|
+
const cssKey = kebabCase(key);
|
|
17
|
+
if (cssKey === "background-image") {
|
|
18
|
+
return `${cssKey}: url(${getFileUrl(style[key])});`;
|
|
19
|
+
}
|
|
20
|
+
return `${cssKey}: ${style[key]};`;
|
|
21
|
+
}).join("\n");
|
|
22
|
+
}
|
|
23
|
+
function flattenStyleGroups(style) {
|
|
24
|
+
if (!style || typeof style !== "object") return null;
|
|
25
|
+
const flat = {};
|
|
26
|
+
for (const key in style) {
|
|
27
|
+
const value = style[key];
|
|
28
|
+
if (value && typeof value === "object") {
|
|
29
|
+
Object.assign(flat, value);
|
|
30
|
+
} else if (value !== "" && value !== null && value !== void 0) {
|
|
31
|
+
flat[key] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return flat;
|
|
35
|
+
}
|
|
36
|
+
function collectStyleRules(parts, scope, getFileUrl, options = {}) {
|
|
37
|
+
const { containerSelector = ".epx-dashboard__container", hoverAncestor = "" } = options;
|
|
38
|
+
const { page = {}, component = {}, num = {} } = parts;
|
|
39
|
+
const rules = [];
|
|
40
|
+
const addRule = (selector, ...styleGroups) => {
|
|
41
|
+
const css = styleGroups.map((group) => formatStyleToCss(group, getFileUrl)).filter(Boolean).join("\n");
|
|
42
|
+
if (css) rules.push(`${selector} {
|
|
43
|
+
${css}
|
|
44
|
+
}`);
|
|
45
|
+
};
|
|
46
|
+
const addAccent = (selector, accent) => {
|
|
47
|
+
if (!accent || !Object.keys(accent).length) return;
|
|
48
|
+
addRule(selector, { position: "relative", overflow: "hidden" });
|
|
49
|
+
addRule(`${selector}::before`, { ...ACCENT_BASE, ...accent });
|
|
50
|
+
};
|
|
51
|
+
const hoverSel = (elementSel) => hoverAncestor ? `${scope} ${hoverAncestor}:hover ${elementSel}` : `${scope} ${elementSel}:hover`;
|
|
52
|
+
const addHoverFont = (elementSel, hoverStyle, selectors) => {
|
|
53
|
+
const font = hoverStyle && hoverStyle.fontStyle;
|
|
54
|
+
if (!font || !Object.keys(font).length) return;
|
|
55
|
+
const css = Object.keys(font).filter((key) => font[key] !== "" && font[key] !== null && font[key] !== void 0).map((key) => `${kebabCase(key)}: ${font[key]} !important;`).join("\n");
|
|
56
|
+
const base = hoverSel(elementSel);
|
|
57
|
+
if (css) rules.push(`${selectors.map((s) => `${base} ${s}`).join(", ")} {
|
|
58
|
+
${css}
|
|
59
|
+
}`);
|
|
60
|
+
};
|
|
61
|
+
addRule(`${scope} ${containerSelector}`.trim(), page.background);
|
|
62
|
+
addRule(`${scope} .epx-dashboard__component`, component.background, component.border, component.fontStyle, component.shadow);
|
|
63
|
+
addRule(hoverSel(".epx-dashboard__component"), flattenStyleGroups(component.hoverStyle));
|
|
64
|
+
addHoverFont(".epx-dashboard__component", component.hoverStyle, [".epx-chart__title", ".epx-card-num__title", ".epx-card-num__num font"]);
|
|
65
|
+
addAccent(`${scope} .epx-dashboard__component`, component.topAccent);
|
|
66
|
+
addRule(`${scope} .epx-chart__header`, component.titleBackground);
|
|
67
|
+
addRule(`${scope} .epx-chart__title, ${scope} .epx-card-num__title`, component.titleFontStyle);
|
|
68
|
+
addRule(`${scope} .epx-card-num`, num.background, num.border, num.shadow);
|
|
69
|
+
addRule(hoverSel(".epx-card-num"), flattenStyleGroups(num.hoverStyle));
|
|
70
|
+
addHoverFont(".epx-card-num", num.hoverStyle, [".epx-card-num__title", ".epx-card-num__num font"]);
|
|
71
|
+
addAccent(`${scope} .epx-card-num`, num.topAccent);
|
|
72
|
+
addRule(`${scope} .epx-card-num__title`, num.titleFontStyle);
|
|
73
|
+
addRule(`${scope} .epx-card-num__num font`, num.fontStyle);
|
|
74
|
+
return rules;
|
|
75
|
+
}
|
|
76
|
+
function buildThemeCss(themeStyles = {}, scope, getFileUrl, options = {}) {
|
|
77
|
+
const rules = collectStyleRules(themeStyles, scope, getFileUrl, options);
|
|
78
|
+
const customCss = themeStyles.customCss || themeStyles.custom && themeStyles.custom.css;
|
|
79
|
+
if (typeof customCss === "string" && customCss.trim()) {
|
|
80
|
+
rules.push(customCss.replace(/&/g, scope));
|
|
81
|
+
}
|
|
82
|
+
if (themeStyles.mobile && typeof themeStyles.mobile === "object") {
|
|
83
|
+
const mobileRules = collectStyleRules(themeStyles.mobile, scope, getFileUrl, options);
|
|
84
|
+
if (mobileRules.length) {
|
|
85
|
+
rules.push(`@media only screen and (max-width: 992px) {
|
|
86
|
+
${mobileRules.join("\n")}
|
|
87
|
+
}`);
|
|
88
|
+
}
|
|
89
|
+
if (options.mobilePreview) {
|
|
90
|
+
rules.push(...collectStyleRules(themeStyles.mobile, `${scope}.is-mobile-preview`, getFileUrl, options));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return rules.join("\n");
|
|
94
|
+
}
|
|
95
|
+
function buildThemeChartConfig(themeStyles = {}, isMobile = false) {
|
|
96
|
+
const baseComponent = themeStyles.component || {};
|
|
97
|
+
const baseChart = themeStyles.chart || {};
|
|
98
|
+
const mobile = isMobile && themeStyles.mobile || {};
|
|
99
|
+
const fontStyle = { ...baseComponent.fontStyle || {}, ...(mobile.component || {}).fontStyle || {} };
|
|
100
|
+
const chart = { ...baseChart, ...mobile.chart || {} };
|
|
101
|
+
const config = {};
|
|
102
|
+
if (Object.keys(fontStyle).length) {
|
|
103
|
+
const textStyle = {};
|
|
104
|
+
for (const key in fontStyle) {
|
|
105
|
+
textStyle[camelCase(key)] = fontStyle[key];
|
|
106
|
+
}
|
|
107
|
+
Object.assign(config, {
|
|
108
|
+
textStyle,
|
|
109
|
+
legend: { textStyle },
|
|
110
|
+
xAxis: { axisLabel: { ...textStyle } },
|
|
111
|
+
yAxis: { axisLabel: { ...textStyle } }
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const colors = typeof chart.colors === "string" ? chart.colors.split(/[,,\s]+/).filter(Boolean) : chart.colors;
|
|
115
|
+
if (Array.isArray(colors) && colors.length) {
|
|
116
|
+
config.color = colors;
|
|
117
|
+
}
|
|
118
|
+
if (chart.splitLineColor) {
|
|
119
|
+
const splitLine = { lineStyle: { color: chart.splitLineColor } };
|
|
120
|
+
config.xAxis = { ...config.xAxis, splitLine: { ...splitLine } };
|
|
121
|
+
config.yAxis = { ...config.yAxis, splitLine: { ...splitLine } };
|
|
122
|
+
}
|
|
123
|
+
if (chart.axisLineColor) {
|
|
124
|
+
const axisLine = { lineStyle: { color: chart.axisLineColor } };
|
|
125
|
+
config.xAxis = { ...config.xAxis, axisLine: { ...axisLine } };
|
|
126
|
+
config.yAxis = { ...config.yAxis, axisLine: { ...axisLine } };
|
|
127
|
+
}
|
|
128
|
+
return config;
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
buildThemeChartConfig,
|
|
132
|
+
buildThemeCss,
|
|
133
|
+
formatStyleToCss
|
|
134
|
+
};
|