@voicenter-team/voicenter-ui-plus 4.0.0 → 4.0.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/MIGRATION_v3.md +196 -196
- package/README.md +1051 -1051
- package/library/assets/assets/sass/main.css +1 -1
- package/library/assets/components/VcFileUploader/VcFileUploaderSimple.css +1 -1
- package/library/assets/components/VcJsonSchema/Components/JsonSchemaEditor.css +1 -1
- package/library/assets/components/VcLoading/Loaders/Circles.css +1 -1
- package/library/assets/components/VcLoading/Loaders/DotSpinner.css +1 -1
- package/library/assets/components/VcLoading/Loaders/LdsSpinner.css +1 -1
- package/library/assets/components/VcLoading/Loaders/LoadIcon.css +1 -1
- package/library/assets/components/VcLoading/Loaders/Stretch.css +1 -1
- package/library/assets/components/VcLoading/VcLoading.css +1 -1
- package/library/assets/components/VcMdEditor/ParameterNode.css +1 -1
- package/library/assets/components/VcSegmented/VcSegmented.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Card.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Circle.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Row.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Square.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Text.css +1 -1
- package/library/components/VcCheckbox/VcCheckbox.vue.mjs +1 -1
- package/library/components/VcCheckbox/VcCheckboxButton.vue.mjs +1 -1
- package/library/components/VcDatePicker/VcDatePicker.vue.mjs +1 -1
- package/library/components/VcDropdown/VcDropdownItem.vue.mjs +1 -1
- package/library/components/VcFileUploader/VcFileUploaderSimple.vue.mjs +1 -1
- package/library/components/VcForm/VcForm.vue.mjs +1 -1
- package/library/components/VcForm/VcFormItem.vue.mjs +1 -1
- package/library/components/VcHtmlEditor/VcHtmlEditorToolbar.vue.mjs +1 -1
- package/library/components/VcInput/VcInput.vue.mjs +1 -1
- package/library/components/VcJsonSchema/Components/JsonSchemaEditor.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/Circles.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/DotSpinner.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/DotSpinner.vue2.mjs +2 -2
- package/library/components/VcLoading/Loaders/LdsSpinner.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/LoadIcon.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/Stretch.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/Stretch.vue2.mjs +1 -1
- package/library/components/VcLoading/VcLoading.vue.mjs +1 -1
- package/library/components/VcMdEditor/ParameterNode.vue.mjs +1 -1
- package/library/components/VcMdEditor/VcMdEditor.vue.mjs +1 -1
- package/library/components/VcMdEditor/VcMdEditorToolbar.vue.mjs +1 -1
- package/library/components/VcMessage/reactions/VcMessageReactionBar.vue.mjs +1 -1
- package/library/components/VcRadio/VcRadio.vue.mjs +1 -1
- package/library/components/VcSegmented/VcSegmented.vue.mjs +1 -1
- package/library/components/VcSelect/VcSelect.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Card.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Circle.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Row.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Square.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Text.vue.mjs +1 -1
- package/library/components/VcSlider/VcSlider.vue.mjs +1 -1
- package/library/components/VcTable/VcTable.vue.mjs +4 -1
- package/library/entity/components/Table/VcEntityListTable.vue.mjs +8 -3
- package/library/index.mjs.gz +0 -0
- package/library/localization/index.mjs.gz +0 -0
- package/library/plugin.mjs.gz +0 -0
- package/library/style.css +16 -16
- package/library/style.css.br +0 -0
- package/library/style.css.gz +0 -0
- package/library/theme/index.mjs.gz +0 -0
- package/library/types/localization/locales/en.json.d.ts +415 -415
- package/library/types/theme/themes.json.d.ts +72 -72
- package/library/utils/jsonSchema/index.mjs.gz +0 -0
- package/package.json +311 -311
- package/src/theme/index.ts +101 -101
- package/src/theme/tailwindScheme.js +78 -78
- package/src/theme/theme.types.ts +31 -31
- package/src/theme/themeMerge.ts +63 -63
- package/src/theme/themes.json +72 -72
- package/tailwind.config.d.ts +5 -5
- package/tailwind.config.js +178 -178
- /package/library/assets/node_modules/element-plus/theme-chalk/src/{tooltip.css → dropdown-item.css} +0 -0
package/src/theme/index.ts
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import { themesType, themeType, UIThemeConfig } from './theme.types' // Must be relative as doing publish
|
|
2
|
-
import __themes from './themes.json' // Must be relative as doing publish
|
|
3
|
-
import { overrideElementTheme as _overrideElementTheme, globalVariables } from './themeMerge'
|
|
4
|
-
|
|
5
|
-
const _default: themeType = __themes.voicenter
|
|
6
|
-
|
|
7
|
-
const themes: themesType = __themes
|
|
8
|
-
|
|
9
|
-
// Re-exported for back-compat with consumers that imported it directly.
|
|
10
|
-
// The implementation lives in `themeMerge.ts` so the build-time codegen
|
|
11
|
-
// can reuse it without dragging in browser-globals from the rest of this
|
|
12
|
-
// module.
|
|
13
|
-
export const overrideElementTheme = _overrideElementTheme
|
|
14
|
-
|
|
15
|
-
export function appendGlobalCssVariables (cssData: { [key: string]: string }, appendTo: HTMLElement) {
|
|
16
|
-
Object.entries(cssData).forEach(([ variableName, variableValue ]) => {
|
|
17
|
-
appendTo.style.setProperty(`--${variableName}`, variableValue)
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function getThemeConfigData (themeConfig?: UIThemeConfig) {
|
|
22
|
-
let currentTheme = _default
|
|
23
|
-
|
|
24
|
-
if (themeConfig) {
|
|
25
|
-
|
|
26
|
-
if (themeConfig.type === 'local') {
|
|
27
|
-
if (themes[themeConfig.themeName]) {
|
|
28
|
-
currentTheme = themes[themeConfig.themeName]
|
|
29
|
-
} else {
|
|
30
|
-
console.warn(`[VoicenterUI-plus] No such theme: ${themeConfig.themeName}`)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (themeConfig.type === 'remote') {
|
|
35
|
-
let body = JSON.stringify(
|
|
36
|
-
{
|
|
37
|
-
SectionList: [
|
|
38
|
-
themeConfig.brandingSectionName
|
|
39
|
-
],
|
|
40
|
-
Domain: window.location.hostname
|
|
41
|
-
}
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
if (themeConfig.payloadData) {
|
|
45
|
-
body = JSON.stringify(themeConfig.payloadData)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const apiStyling = await fetch(themeConfig.apiUrl, {
|
|
49
|
-
method: 'POST',
|
|
50
|
-
cache: 'no-cache',
|
|
51
|
-
headers: {
|
|
52
|
-
'Content-Type': 'application/json'
|
|
53
|
-
},
|
|
54
|
-
referrerPolicy: 'no-referrer',
|
|
55
|
-
body
|
|
56
|
-
})
|
|
57
|
-
.then(res => res.json())
|
|
58
|
-
.then(res => res.Data)
|
|
59
|
-
.then(res => {
|
|
60
|
-
return Object.fromEntries(Object.entries(res).map(([ key, value ]) => {
|
|
61
|
-
return [
|
|
62
|
-
key.replace(`${themeConfig.brandingSectionName}.`, ''),
|
|
63
|
-
String(value)
|
|
64
|
-
]
|
|
65
|
-
}))
|
|
66
|
-
})
|
|
67
|
-
.catch(e => console.error(e))
|
|
68
|
-
|
|
69
|
-
if (apiStyling) {
|
|
70
|
-
currentTheme = apiStyling
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (themeConfig.type === 'customJson') {
|
|
75
|
-
currentTheme = themeConfig.config ?? {}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return currentTheme
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export default async function (themeConfig?: UIThemeConfig, appendTo: HTMLElement = document.documentElement) {
|
|
83
|
-
|
|
84
|
-
if (themeConfig?.type === 'none') {
|
|
85
|
-
return themeConfig?.onSetupCallback ? themeConfig?.onSetupCallback({}) : {}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const currentTheme = await getThemeConfigData(themeConfig)
|
|
89
|
-
|
|
90
|
-
appendGlobalCssVariables(
|
|
91
|
-
{
|
|
92
|
-
...overrideElementTheme(currentTheme),
|
|
93
|
-
...globalVariables
|
|
94
|
-
},
|
|
95
|
-
appendTo
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
if (themeConfig?.onSetupCallback) {
|
|
99
|
-
themeConfig.onSetupCallback(currentTheme)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
1
|
+
import { themesType, themeType, UIThemeConfig } from './theme.types' // Must be relative as doing publish
|
|
2
|
+
import __themes from './themes.json' // Must be relative as doing publish
|
|
3
|
+
import { overrideElementTheme as _overrideElementTheme, globalVariables } from './themeMerge'
|
|
4
|
+
|
|
5
|
+
const _default: themeType = __themes.voicenter
|
|
6
|
+
|
|
7
|
+
const themes: themesType = __themes
|
|
8
|
+
|
|
9
|
+
// Re-exported for back-compat with consumers that imported it directly.
|
|
10
|
+
// The implementation lives in `themeMerge.ts` so the build-time codegen
|
|
11
|
+
// can reuse it without dragging in browser-globals from the rest of this
|
|
12
|
+
// module.
|
|
13
|
+
export const overrideElementTheme = _overrideElementTheme
|
|
14
|
+
|
|
15
|
+
export function appendGlobalCssVariables (cssData: { [key: string]: string }, appendTo: HTMLElement) {
|
|
16
|
+
Object.entries(cssData).forEach(([ variableName, variableValue ]) => {
|
|
17
|
+
appendTo.style.setProperty(`--${variableName}`, variableValue)
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function getThemeConfigData (themeConfig?: UIThemeConfig) {
|
|
22
|
+
let currentTheme = _default
|
|
23
|
+
|
|
24
|
+
if (themeConfig) {
|
|
25
|
+
|
|
26
|
+
if (themeConfig.type === 'local') {
|
|
27
|
+
if (themes[themeConfig.themeName]) {
|
|
28
|
+
currentTheme = themes[themeConfig.themeName]
|
|
29
|
+
} else {
|
|
30
|
+
console.warn(`[VoicenterUI-plus] No such theme: ${themeConfig.themeName}`)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (themeConfig.type === 'remote') {
|
|
35
|
+
let body = JSON.stringify(
|
|
36
|
+
{
|
|
37
|
+
SectionList: [
|
|
38
|
+
themeConfig.brandingSectionName
|
|
39
|
+
],
|
|
40
|
+
Domain: window.location.hostname
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
if (themeConfig.payloadData) {
|
|
45
|
+
body = JSON.stringify(themeConfig.payloadData)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const apiStyling = await fetch(themeConfig.apiUrl, {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
cache: 'no-cache',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json'
|
|
53
|
+
},
|
|
54
|
+
referrerPolicy: 'no-referrer',
|
|
55
|
+
body
|
|
56
|
+
})
|
|
57
|
+
.then(res => res.json())
|
|
58
|
+
.then(res => res.Data)
|
|
59
|
+
.then(res => {
|
|
60
|
+
return Object.fromEntries(Object.entries(res).map(([ key, value ]) => {
|
|
61
|
+
return [
|
|
62
|
+
key.replace(`${themeConfig.brandingSectionName}.`, ''),
|
|
63
|
+
String(value)
|
|
64
|
+
]
|
|
65
|
+
}))
|
|
66
|
+
})
|
|
67
|
+
.catch(e => console.error(e))
|
|
68
|
+
|
|
69
|
+
if (apiStyling) {
|
|
70
|
+
currentTheme = apiStyling
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (themeConfig.type === 'customJson') {
|
|
75
|
+
currentTheme = themeConfig.config ?? {}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return currentTheme
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default async function (themeConfig?: UIThemeConfig, appendTo: HTMLElement = document.documentElement) {
|
|
83
|
+
|
|
84
|
+
if (themeConfig?.type === 'none') {
|
|
85
|
+
return themeConfig?.onSetupCallback ? themeConfig?.onSetupCallback({}) : {}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const currentTheme = await getThemeConfigData(themeConfig)
|
|
89
|
+
|
|
90
|
+
appendGlobalCssVariables(
|
|
91
|
+
{
|
|
92
|
+
...overrideElementTheme(currentTheme),
|
|
93
|
+
...globalVariables
|
|
94
|
+
},
|
|
95
|
+
appendTo
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if (themeConfig?.onSetupCallback) {
|
|
99
|
+
themeConfig.onSetupCallback(currentTheme)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
// Colour scheme for Tailwind: `{category}-{role}`, then the state.
|
|
2
|
-
//
|
|
3
|
-
// The same map feeds text-*, bg-*, border-*, ring-*, divide-*, fill-*,
|
|
4
|
-
// stroke-* and shadow-* colours:
|
|
5
|
-
//
|
|
6
|
-
// bg-action-primary text-onfill hover:bg-action-primary-hover
|
|
7
|
-
// text-content-secondary border-border border-input ring-ring
|
|
8
|
-
// bg-action-danger-subtle-hover text-content-danger
|
|
9
|
-
//
|
|
10
|
-
// Text and icons use `content-*`; text on a solid fill uses `onfill-*`;
|
|
11
|
-
// tinted backgrounds use the action washes (`*-subtle-hover`, `*-subtle-pressed`).
|
|
12
|
-
// CSS variables keep the `--vc-` prefix (Element Plus owns `--el-*`); Tailwind
|
|
13
|
-
// keys drop it.
|
|
14
|
-
const v = name => `var(--vc-${name})`
|
|
15
|
-
|
|
16
|
-
// The solid fills: each has its interaction states (_theme.scss) and its own text colour.
|
|
17
|
-
const fills = [ 'primary', 'secondary', 'info', 'success', 'warning', 'danger' ]
|
|
18
|
-
|
|
19
|
-
const intent = name => ({
|
|
20
|
-
DEFAULT: v(name),
|
|
21
|
-
hover: v(`${name}--hover`),
|
|
22
|
-
pressed: v(`${name}--pressed`),
|
|
23
|
-
disabled: v(`${name}--disabled`),
|
|
24
|
-
'subtle-hover': v(`${name}--subtle-hover`),
|
|
25
|
-
'subtle-pressed': v(`${name}--subtle-pressed`)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
module.exports = {
|
|
29
|
-
transparent: 'transparent',
|
|
30
|
-
current: 'currentColor',
|
|
31
|
-
white: '#FFFFFF',
|
|
32
|
-
black: '#000000',
|
|
33
|
-
|
|
34
|
-
// Background levels (--vc-bg-*). Nesting: page → surface → inset → inset-strong.
|
|
35
|
-
// On dark themes inset levels get darker (recessed) while muted gets lighter.
|
|
36
|
-
page: v('bg-page'),
|
|
37
|
-
surface: v('bg-surface'),
|
|
38
|
-
inset: v('bg-inset'),
|
|
39
|
-
'inset-strong': v('bg-inset-strong'),
|
|
40
|
-
muted: v('bg-muted'),
|
|
41
|
-
field: v('bg-field'),
|
|
42
|
-
overlay: v('bg-overlay'),
|
|
43
|
-
skeleton: v('bg-skeleton'),
|
|
44
|
-
|
|
45
|
-
content: {
|
|
46
|
-
primary: v('content-primary'),
|
|
47
|
-
secondary: {
|
|
48
|
-
DEFAULT: v('content-secondary'),
|
|
49
|
-
hover: v('content-secondary--hover')
|
|
50
|
-
},
|
|
51
|
-
tertiary: v('content-tertiary'),
|
|
52
|
-
disabled: v('content-disabled'),
|
|
53
|
-
// Brand-coloured text: links, active tabs, outline and borderless primary buttons.
|
|
54
|
-
brand: {
|
|
55
|
-
DEFAULT: v('content-brand'),
|
|
56
|
-
hover: v('content-brand--hover'),
|
|
57
|
-
pressed: v('content-brand--pressed')
|
|
58
|
-
},
|
|
59
|
-
success: v('content-success'),
|
|
60
|
-
warning: v('content-warning'),
|
|
61
|
-
danger: v('content-danger'),
|
|
62
|
-
info: v('content-info')
|
|
63
|
-
},
|
|
64
|
-
onfill: {
|
|
65
|
-
DEFAULT: v('onfill'),
|
|
66
|
-
// Per-fill text colour; each falls back to the shared onfill.
|
|
67
|
-
...Object.fromEntries(fills.map(fill => [ fill, `var(--vc-onfill-${fill}, var(--vc-onfill))` ]))
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
action: Object.fromEntries(fills.map(fill => [ fill, intent(`action-${fill}`) ])),
|
|
71
|
-
|
|
72
|
-
border: {
|
|
73
|
-
DEFAULT: v('border'),
|
|
74
|
-
strong: v('border-strong')
|
|
75
|
-
},
|
|
76
|
-
input: v('input'),
|
|
77
|
-
ring: v('ring')
|
|
78
|
-
}
|
|
1
|
+
// Colour scheme for Tailwind: `{category}-{role}`, then the state.
|
|
2
|
+
//
|
|
3
|
+
// The same map feeds text-*, bg-*, border-*, ring-*, divide-*, fill-*,
|
|
4
|
+
// stroke-* and shadow-* colours:
|
|
5
|
+
//
|
|
6
|
+
// bg-action-primary text-onfill hover:bg-action-primary-hover
|
|
7
|
+
// text-content-secondary border-border border-input ring-ring
|
|
8
|
+
// bg-action-danger-subtle-hover text-content-danger
|
|
9
|
+
//
|
|
10
|
+
// Text and icons use `content-*`; text on a solid fill uses `onfill-*`;
|
|
11
|
+
// tinted backgrounds use the action washes (`*-subtle-hover`, `*-subtle-pressed`).
|
|
12
|
+
// CSS variables keep the `--vc-` prefix (Element Plus owns `--el-*`); Tailwind
|
|
13
|
+
// keys drop it.
|
|
14
|
+
const v = name => `var(--vc-${name})`
|
|
15
|
+
|
|
16
|
+
// The solid fills: each has its interaction states (_theme.scss) and its own text colour.
|
|
17
|
+
const fills = [ 'primary', 'secondary', 'info', 'success', 'warning', 'danger' ]
|
|
18
|
+
|
|
19
|
+
const intent = name => ({
|
|
20
|
+
DEFAULT: v(name),
|
|
21
|
+
hover: v(`${name}--hover`),
|
|
22
|
+
pressed: v(`${name}--pressed`),
|
|
23
|
+
disabled: v(`${name}--disabled`),
|
|
24
|
+
'subtle-hover': v(`${name}--subtle-hover`),
|
|
25
|
+
'subtle-pressed': v(`${name}--subtle-pressed`)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
transparent: 'transparent',
|
|
30
|
+
current: 'currentColor',
|
|
31
|
+
white: '#FFFFFF',
|
|
32
|
+
black: '#000000',
|
|
33
|
+
|
|
34
|
+
// Background levels (--vc-bg-*). Nesting: page → surface → inset → inset-strong.
|
|
35
|
+
// On dark themes inset levels get darker (recessed) while muted gets lighter.
|
|
36
|
+
page: v('bg-page'),
|
|
37
|
+
surface: v('bg-surface'),
|
|
38
|
+
inset: v('bg-inset'),
|
|
39
|
+
'inset-strong': v('bg-inset-strong'),
|
|
40
|
+
muted: v('bg-muted'),
|
|
41
|
+
field: v('bg-field'),
|
|
42
|
+
overlay: v('bg-overlay'),
|
|
43
|
+
skeleton: v('bg-skeleton'),
|
|
44
|
+
|
|
45
|
+
content: {
|
|
46
|
+
primary: v('content-primary'),
|
|
47
|
+
secondary: {
|
|
48
|
+
DEFAULT: v('content-secondary'),
|
|
49
|
+
hover: v('content-secondary--hover')
|
|
50
|
+
},
|
|
51
|
+
tertiary: v('content-tertiary'),
|
|
52
|
+
disabled: v('content-disabled'),
|
|
53
|
+
// Brand-coloured text: links, active tabs, outline and borderless primary buttons.
|
|
54
|
+
brand: {
|
|
55
|
+
DEFAULT: v('content-brand'),
|
|
56
|
+
hover: v('content-brand--hover'),
|
|
57
|
+
pressed: v('content-brand--pressed')
|
|
58
|
+
},
|
|
59
|
+
success: v('content-success'),
|
|
60
|
+
warning: v('content-warning'),
|
|
61
|
+
danger: v('content-danger'),
|
|
62
|
+
info: v('content-info')
|
|
63
|
+
},
|
|
64
|
+
onfill: {
|
|
65
|
+
DEFAULT: v('onfill'),
|
|
66
|
+
// Per-fill text colour; each falls back to the shared onfill.
|
|
67
|
+
...Object.fromEntries(fills.map(fill => [ fill, `var(--vc-onfill-${fill}, var(--vc-onfill))` ]))
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
action: Object.fromEntries(fills.map(fill => [ fill, intent(`action-${fill}`) ])),
|
|
71
|
+
|
|
72
|
+
border: {
|
|
73
|
+
DEFAULT: v('border'),
|
|
74
|
+
strong: v('border-strong')
|
|
75
|
+
},
|
|
76
|
+
input: v('input'),
|
|
77
|
+
ring: v('ring')
|
|
78
|
+
}
|
package/src/theme/theme.types.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
export type themeType = {
|
|
2
|
-
[key: string]: string
|
|
3
|
-
}
|
|
4
|
-
export type themesType = {
|
|
5
|
-
[key: string]: themeType
|
|
6
|
-
}
|
|
7
|
-
export type UIThemeBaseConfig = {
|
|
8
|
-
type: string
|
|
9
|
-
onSetupCallback?: (loadedTheme: themeType) => void
|
|
10
|
-
}
|
|
11
|
-
export type UIThemeLocalConfig = UIThemeBaseConfig & {
|
|
12
|
-
type: 'local'
|
|
13
|
-
themeName: string
|
|
14
|
-
}
|
|
15
|
-
export type UIThemeRemoteConfig = UIThemeBaseConfig & {
|
|
16
|
-
type: 'remote'
|
|
17
|
-
brandingSectionName?: string
|
|
18
|
-
payloadData?: Record<string, unknown>
|
|
19
|
-
apiUrl: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type UIThemeCustomObjectJsonConfig = UIThemeBaseConfig & {
|
|
23
|
-
type: 'customJson',
|
|
24
|
-
config: themeType
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type UiThemeNoneConfig = UIThemeBaseConfig & {
|
|
28
|
-
type: 'none'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export declare type UIThemeConfig = UIThemeLocalConfig | UIThemeRemoteConfig | UIThemeCustomObjectJsonConfig | UiThemeNoneConfig
|
|
1
|
+
export type themeType = {
|
|
2
|
+
[key: string]: string
|
|
3
|
+
}
|
|
4
|
+
export type themesType = {
|
|
5
|
+
[key: string]: themeType
|
|
6
|
+
}
|
|
7
|
+
export type UIThemeBaseConfig = {
|
|
8
|
+
type: string
|
|
9
|
+
onSetupCallback?: (loadedTheme: themeType) => void
|
|
10
|
+
}
|
|
11
|
+
export type UIThemeLocalConfig = UIThemeBaseConfig & {
|
|
12
|
+
type: 'local'
|
|
13
|
+
themeName: string
|
|
14
|
+
}
|
|
15
|
+
export type UIThemeRemoteConfig = UIThemeBaseConfig & {
|
|
16
|
+
type: 'remote'
|
|
17
|
+
brandingSectionName?: string
|
|
18
|
+
payloadData?: Record<string, unknown>
|
|
19
|
+
apiUrl: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type UIThemeCustomObjectJsonConfig = UIThemeBaseConfig & {
|
|
23
|
+
type: 'customJson',
|
|
24
|
+
config: themeType
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type UiThemeNoneConfig = UIThemeBaseConfig & {
|
|
28
|
+
type: 'none'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare type UIThemeConfig = UIThemeLocalConfig | UIThemeRemoteConfig | UIThemeCustomObjectJsonConfig | UiThemeNoneConfig
|
package/src/theme/themeMerge.ts
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
// Pure helpers shared by the runtime theme installer (theme/index.ts) and
|
|
2
|
-
// the build-time codegen (vite.config.ts). Single source of truth for the
|
|
3
|
-
// keys derived from a theme's own keys (the element-plus override map, the
|
|
4
|
-
// status text colours) and the global variable constants — neither place
|
|
5
|
-
// hardcodes variable names.
|
|
6
|
-
|
|
7
|
-
export const globalVariables: Record<string, string> = {
|
|
8
|
-
'input-font-size': '0.875rem',
|
|
9
|
-
'input-font-weight': 'var(--vc-font-weight-normal)',
|
|
10
|
-
'select-option-height': '2rem'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// The status colours whose text key defaults to the fill.
|
|
14
|
-
const statusColors = [ 'success', 'warning', 'danger', 'info' ]
|
|
15
|
-
|
|
16
|
-
export function overrideElementTheme (theme: Record<string, string>): Record<string, string> {
|
|
17
|
-
const merged: Record<string, string | undefined> = {
|
|
18
|
-
...theme,
|
|
19
|
-
// A status text colour the theme does not set is the theme's fill of that status.
|
|
20
|
-
...Object.fromEntries(statusColors.map(color => [ `vc-content-${color}`, theme[`vc-content-${color}`] ?? theme[`vc-action-${color}`] ])),
|
|
21
|
-
// Brand-coloured text (links, active tabs, outline and borderless primary buttons), if the theme does not set it, is its primary fill.
|
|
22
|
-
'vc-content-brand': theme['vc-content-brand'] ?? theme['vc-action-primary'],
|
|
23
|
-
'el-color-primary': theme['el-color-primary'] ?? theme['vc-action-primary'],
|
|
24
|
-
'el-color-success': theme['el-color-success'] ?? theme['vc-action-success'],
|
|
25
|
-
'el-color-warning': theme['el-color-warning'] ?? theme['vc-action-warning'],
|
|
26
|
-
'el-color-danger': theme['el-color-danger'] ?? theme['vc-action-danger'],
|
|
27
|
-
'el-color-error': theme['el-color-error'] ?? theme['vc-action-danger'],
|
|
28
|
-
'el-color-info': theme['el-color-info'] ?? theme['vc-action-secondary'],
|
|
29
|
-
'el-fill-color': theme['el-fill-color'] ?? theme['vc-bg-field'],
|
|
30
|
-
'el-text-color-primary': theme['el-text-color-primary'] ?? theme['vc-content-primary'],
|
|
31
|
-
'el-text-color-regular': theme['el-text-color-regular'] ?? theme['vc-content-primary'],
|
|
32
|
-
'el-text-color-placeholder': theme['el-text-color-placeholder'] ?? theme['vc-content-tertiary'],
|
|
33
|
-
'el-disabled-text-color': theme['el-disabled-text-color'] ?? theme['vc-content-disabled'],
|
|
34
|
-
'el-text-color-disabled': theme['el-text-color-disabled'] ?? theme['vc-content-disabled'],
|
|
35
|
-
// Panels, borders and hover fills: Element Plus hard-codes light values
|
|
36
|
-
// for these, which leaves white panels and light lines on a dark theme.
|
|
37
|
-
'el-bg-color': theme['el-bg-color'] ?? theme['vc-bg-surface'],
|
|
38
|
-
'el-bg-color-overlay': theme['el-bg-color-overlay'] ?? theme['vc-bg-surface'],
|
|
39
|
-
'el-fill-color-blank': theme['el-fill-color-blank'] ?? theme['vc-bg-surface'],
|
|
40
|
-
'el-fill-color-light': theme['el-fill-color-light'] ?? theme['vc-bg-muted'],
|
|
41
|
-
'el-text-color-secondary': theme['el-text-color-secondary'] ?? theme['vc-content-secondary'],
|
|
42
|
-
'el-border-color': theme['el-border-color'] ?? theme['vc-border'],
|
|
43
|
-
'el-border-color-light': theme['el-border-color-light'] ?? theme['vc-border'],
|
|
44
|
-
'el-border-color-lighter': theme['el-border-color-lighter'] ?? theme['vc-border'],
|
|
45
|
-
'el-border-color-extra-light': theme['el-border-color-extra-light'] ?? theme['vc-border'],
|
|
46
|
-
// The hover border of the ui-plus fields, which _theme.scss derives in CSS.
|
|
47
|
-
'el-border-color-hover': theme['el-border-color-hover'] ?? 'var(--vc-input--hover)',
|
|
48
|
-
transparent: 'transparent',
|
|
49
|
-
white: '#FFFFFF',
|
|
50
|
-
black: '#000000',
|
|
51
|
-
current: 'currentColor'
|
|
52
|
-
}
|
|
53
|
-
// A key whose source the theme does not set is left out, so the variable
|
|
54
|
-
// keeps the value it already has instead of becoming "undefined".
|
|
55
|
-
return Object.fromEntries(Object.entries(merged).filter((entry): entry is [ string, string ] => entry[1] !== undefined))
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function mergeThemeWithDefaults (theme: Record<string, string>): Record<string, string> {
|
|
59
|
-
return {
|
|
60
|
-
...overrideElementTheme(theme),
|
|
61
|
-
...globalVariables
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
// Pure helpers shared by the runtime theme installer (theme/index.ts) and
|
|
2
|
+
// the build-time codegen (vite.config.ts). Single source of truth for the
|
|
3
|
+
// keys derived from a theme's own keys (the element-plus override map, the
|
|
4
|
+
// status text colours) and the global variable constants — neither place
|
|
5
|
+
// hardcodes variable names.
|
|
6
|
+
|
|
7
|
+
export const globalVariables: Record<string, string> = {
|
|
8
|
+
'input-font-size': '0.875rem',
|
|
9
|
+
'input-font-weight': 'var(--vc-font-weight-normal)',
|
|
10
|
+
'select-option-height': '2rem'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// The status colours whose text key defaults to the fill.
|
|
14
|
+
const statusColors = [ 'success', 'warning', 'danger', 'info' ]
|
|
15
|
+
|
|
16
|
+
export function overrideElementTheme (theme: Record<string, string>): Record<string, string> {
|
|
17
|
+
const merged: Record<string, string | undefined> = {
|
|
18
|
+
...theme,
|
|
19
|
+
// A status text colour the theme does not set is the theme's fill of that status.
|
|
20
|
+
...Object.fromEntries(statusColors.map(color => [ `vc-content-${color}`, theme[`vc-content-${color}`] ?? theme[`vc-action-${color}`] ])),
|
|
21
|
+
// Brand-coloured text (links, active tabs, outline and borderless primary buttons), if the theme does not set it, is its primary fill.
|
|
22
|
+
'vc-content-brand': theme['vc-content-brand'] ?? theme['vc-action-primary'],
|
|
23
|
+
'el-color-primary': theme['el-color-primary'] ?? theme['vc-action-primary'],
|
|
24
|
+
'el-color-success': theme['el-color-success'] ?? theme['vc-action-success'],
|
|
25
|
+
'el-color-warning': theme['el-color-warning'] ?? theme['vc-action-warning'],
|
|
26
|
+
'el-color-danger': theme['el-color-danger'] ?? theme['vc-action-danger'],
|
|
27
|
+
'el-color-error': theme['el-color-error'] ?? theme['vc-action-danger'],
|
|
28
|
+
'el-color-info': theme['el-color-info'] ?? theme['vc-action-secondary'],
|
|
29
|
+
'el-fill-color': theme['el-fill-color'] ?? theme['vc-bg-field'],
|
|
30
|
+
'el-text-color-primary': theme['el-text-color-primary'] ?? theme['vc-content-primary'],
|
|
31
|
+
'el-text-color-regular': theme['el-text-color-regular'] ?? theme['vc-content-primary'],
|
|
32
|
+
'el-text-color-placeholder': theme['el-text-color-placeholder'] ?? theme['vc-content-tertiary'],
|
|
33
|
+
'el-disabled-text-color': theme['el-disabled-text-color'] ?? theme['vc-content-disabled'],
|
|
34
|
+
'el-text-color-disabled': theme['el-text-color-disabled'] ?? theme['vc-content-disabled'],
|
|
35
|
+
// Panels, borders and hover fills: Element Plus hard-codes light values
|
|
36
|
+
// for these, which leaves white panels and light lines on a dark theme.
|
|
37
|
+
'el-bg-color': theme['el-bg-color'] ?? theme['vc-bg-surface'],
|
|
38
|
+
'el-bg-color-overlay': theme['el-bg-color-overlay'] ?? theme['vc-bg-surface'],
|
|
39
|
+
'el-fill-color-blank': theme['el-fill-color-blank'] ?? theme['vc-bg-surface'],
|
|
40
|
+
'el-fill-color-light': theme['el-fill-color-light'] ?? theme['vc-bg-muted'],
|
|
41
|
+
'el-text-color-secondary': theme['el-text-color-secondary'] ?? theme['vc-content-secondary'],
|
|
42
|
+
'el-border-color': theme['el-border-color'] ?? theme['vc-border'],
|
|
43
|
+
'el-border-color-light': theme['el-border-color-light'] ?? theme['vc-border'],
|
|
44
|
+
'el-border-color-lighter': theme['el-border-color-lighter'] ?? theme['vc-border'],
|
|
45
|
+
'el-border-color-extra-light': theme['el-border-color-extra-light'] ?? theme['vc-border'],
|
|
46
|
+
// The hover border of the ui-plus fields, which _theme.scss derives in CSS.
|
|
47
|
+
'el-border-color-hover': theme['el-border-color-hover'] ?? 'var(--vc-input--hover)',
|
|
48
|
+
transparent: 'transparent',
|
|
49
|
+
white: '#FFFFFF',
|
|
50
|
+
black: '#000000',
|
|
51
|
+
current: 'currentColor'
|
|
52
|
+
}
|
|
53
|
+
// A key whose source the theme does not set is left out, so the variable
|
|
54
|
+
// keeps the value it already has instead of becoming "undefined".
|
|
55
|
+
return Object.fromEntries(Object.entries(merged).filter((entry): entry is [ string, string ] => entry[1] !== undefined))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function mergeThemeWithDefaults (theme: Record<string, string>): Record<string, string> {
|
|
59
|
+
return {
|
|
60
|
+
...overrideElementTheme(theme),
|
|
61
|
+
...globalVariables
|
|
62
|
+
}
|
|
63
|
+
}
|