wave-ui 1.61.0 → 1.63.0
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/wave-ui.cjs.js +1 -1
- package/dist/wave-ui.css +1 -1
- package/dist/wave-ui.es.js +649 -511
- package/dist/wave-ui.umd.js +1 -1
- package/package.json +1 -1
- package/src/wave-ui/components/index.js +1 -0
- package/src/wave-ui/components/transitions/w-transition-expand.vue +26 -15
- package/src/wave-ui/components/w-confirm.vue +4 -1
- package/src/wave-ui/components/w-list.vue +5 -2
- package/src/wave-ui/components/w-notification-manager.vue +2 -3
- package/src/wave-ui/components/w-scrollbar.vue +24 -0
- package/src/wave-ui/components/w-select.vue +9 -4
- package/src/wave-ui/components/w-switch.vue +1 -1
- package/src/wave-ui/components/w-table.vue +93 -8
- package/src/wave-ui/components/w-tree.vue +56 -19
- package/src/wave-ui/core.js +45 -69
- package/src/wave-ui/scss/_layout.scss +1 -1
- package/src/wave-ui/utils/colors.js +56 -2
- package/src/wave-ui/utils/config.js +17 -8
- package/src/wave-ui/utils/dynamic-css.js +2 -2
- package/src/wave-ui/utils/notification-manager.js +3 -3
package/src/wave-ui/core.js
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { mergeConfig } from './utils/config'
|
|
2
2
|
import NotificationManager from './utils/notification-manager'
|
|
3
|
-
import
|
|
3
|
+
import { colorPalette, generateColorShades, flattenColors } from './utils/colors'
|
|
4
4
|
// import * as directives from './directives'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Inject presets into a Vue component props defaults before its registration into the app.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} component the Vue component to inject presets into.
|
|
10
|
+
* @param {Object} presets the presets to inject. E.g. `{ bgColor: 'green' }`.
|
|
11
|
+
*/
|
|
12
|
+
const injectPresets = (component, presets) => {
|
|
13
|
+
for (const preset in presets) {
|
|
14
|
+
component.props[preset].default = presets[preset]
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
export default class WaveUI {
|
|
13
19
|
static instance = null
|
|
14
20
|
static vueInstance = null // Needed until constructor is called.
|
|
15
|
-
#notificationManager
|
|
16
21
|
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
// Exposed as a global object and also `app.provide`d.
|
|
23
|
+
// Accessible from this.$waveui, or inject('$waveui').
|
|
24
|
+
$waveui = {
|
|
25
|
+
breakpoint: {
|
|
26
|
+
name: '',
|
|
27
|
+
xs: false,
|
|
28
|
+
sm: false,
|
|
29
|
+
md: false,
|
|
30
|
+
lg: false,
|
|
31
|
+
xl: false
|
|
32
|
+
},
|
|
33
|
+
config: {},
|
|
34
|
+
colors: {}, // Object of pairs of color-name => color hex.
|
|
35
|
+
_notificationManager: null,
|
|
36
|
+
|
|
37
|
+
// Callable from this.$waveui.
|
|
38
|
+
notify (...args) {
|
|
39
|
+
this._notificationManager.notify(...args)
|
|
40
|
+
}
|
|
25
41
|
}
|
|
26
42
|
|
|
27
|
-
// A public object containing pairs of color-name => color hex.
|
|
28
|
-
// Accessible from anywhere via `this.$waveui.colors`.
|
|
29
|
-
// These colors generate the CSS in `w-app` on mounted.
|
|
30
|
-
colors = colors.reduce((obj, color) => {
|
|
31
|
-
obj[color.label] = color.color
|
|
32
|
-
color.shades.forEach(shade => (obj[shade.label] = shade.color))
|
|
33
|
-
return obj
|
|
34
|
-
}, { ...config.colors, black: '#000', white: '#fff', transparent: 'transparent', inherit: 'inherit' })
|
|
35
|
-
|
|
36
|
-
config = {} // Store and expose the config in the $waveui object.
|
|
37
|
-
|
|
38
43
|
static install (Vue, options = {}) {
|
|
39
44
|
// Register directives.
|
|
40
45
|
// for (const id in directives) {
|
|
@@ -57,6 +62,8 @@ export default class WaveUI {
|
|
|
57
62
|
const { components = {} } = options || {}
|
|
58
63
|
for (let id in components) {
|
|
59
64
|
const component = components[id]
|
|
65
|
+
// If presets are defined for this component inject them into the props defaults.
|
|
66
|
+
if (options.presets?.[component.name]) injectPresets(component, options.presets[component.name])
|
|
60
67
|
Vue.component(component.name, component)
|
|
61
68
|
}
|
|
62
69
|
|
|
@@ -74,53 +81,22 @@ export default class WaveUI {
|
|
|
74
81
|
constructor (options = {}) {
|
|
75
82
|
if (WaveUI.instance) return WaveUI.instance
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
this.#notificationManager = new NotificationManager()
|
|
79
|
-
|
|
80
|
-
// Merge user options into the default config.
|
|
81
|
-
mergeConfig(options)
|
|
82
|
-
|
|
83
|
-
// Add color shades for each custom color given in options.
|
|
84
|
-
if (config.css.colorShades) {
|
|
85
|
-
config.colorShades = {}
|
|
86
|
-
|
|
87
|
-
for (let color in config.colors) {
|
|
88
|
-
color = { label: color, color: config.colors[color].replace('#', '') }
|
|
89
|
-
const col = color.color
|
|
90
|
-
if (col.length === 3) color.color = col[0] + '' + col[0] + col[1] + col[1] + col[2] + col[2]
|
|
84
|
+
this.$waveui._notificationManager = new NotificationManager()
|
|
91
85
|
|
|
92
|
-
|
|
86
|
+
// Merge user options into the default config.
|
|
87
|
+
this.$waveui.config = mergeConfig(options)
|
|
88
|
+
const config = this.$waveui.config
|
|
93
89
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this.colors[`${color.label}-light${i}`] = lighterColor
|
|
98
|
-
this.colors[`${color.label}-dark${i}`] = darkerColor
|
|
90
|
+
// Generates color shades for each color of each theme and store in the config.colors object.
|
|
91
|
+
if (config.css.colorShades) generateColorShades(config)
|
|
92
|
+
this.$waveui.colors = flattenColors(config.colors, colorPalette)
|
|
99
93
|
|
|
100
|
-
|
|
101
|
-
config.colorShades[`${color.label}-light${i}`] = lighterColor
|
|
102
|
-
config.colorShades[`${color.label}-dark${i}`] = darkerColor
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
this.config = config
|
|
108
|
-
this.notify = (...args) => notificationManager.notify(...args)
|
|
109
|
-
WaveUI.instance = this
|
|
94
|
+
WaveUI.instance = this
|
|
110
95
|
|
|
111
|
-
|
|
112
|
-
|
|
96
|
+
// Make Wave UI reactive and expose the single instance in the app.
|
|
97
|
+
const $waveui = WaveUI.vueInstance.observable(this.$waveui)
|
|
98
|
+
WaveUI.vueInstance.prototype.$waveui = $waveui
|
|
113
99
|
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
notify (...args) {
|
|
119
|
-
this.#notificationManager.notify(...args)
|
|
100
|
+
delete WaveUI.vueInstance // Get rid of the Vue instance that we don't need anymore.
|
|
120
101
|
}
|
|
121
102
|
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Returns the WaveUI instance. Equivalent to using `$waveui` inside templates.
|
|
125
|
-
*/
|
|
126
|
-
export const useWaveUI = () => inject('$waveui')
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
|
|
171
171
|
// Sizes.
|
|
172
172
|
// ----------------------------------------------
|
|
173
|
-
// In all the sizes
|
|
173
|
+
// In all the sizes below, round(x / 2) * 2 to always have even numbers.
|
|
174
174
|
// Different heights with a mix of odd and even numbers will misalign
|
|
175
175
|
// when vertically centering (vertical-align or align-items center).
|
|
176
176
|
.size--xs {font-size: round(0.85 * $base-font-size);}
|
|
@@ -1,4 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
const shadeColor = (color, amount) => {
|
|
2
|
+
return '#' + color.slice(1).match(/../g)
|
|
3
|
+
.map(x => {
|
|
4
|
+
x = +`0x${x}` + amount
|
|
5
|
+
return (x < 0 ? 0 : (x > 255 ? 255 : x)).toString(16).padStart(2, 0)
|
|
6
|
+
})
|
|
7
|
+
.join('')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generates the color shades for each custom color and status colors for the current theme (only),
|
|
12
|
+
* and save it in the config object.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} config
|
|
15
|
+
*/
|
|
16
|
+
export const generateColorShades = config => {
|
|
17
|
+
config.shades = {}
|
|
18
|
+
|
|
19
|
+
for (let color in config.colors) {
|
|
20
|
+
color = { label: color, color: config.colors[color].replace('#', '') }
|
|
21
|
+
const col = color.color
|
|
22
|
+
if (col.length === 3) color.color = col[0] + '' + col[0] + col[1] + col[1] + col[2] + col[2]
|
|
23
|
+
|
|
24
|
+
for (let i = 1; i <= 3; i++) {
|
|
25
|
+
const lighterColor = shadeColor(`#${color.color}`, i * 40)
|
|
26
|
+
const darkerColor = shadeColor(`#${color.color}`, -i * 40)
|
|
27
|
+
|
|
28
|
+
// Adding the shades to the config object to generate the CSS from w-app.
|
|
29
|
+
config.shades[`${color.label}-light${i}`] = lighterColor
|
|
30
|
+
config.shades[`${color.label}-dark${i}`] = darkerColor
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const flattenColors = (themeColors, colorPalette) => {
|
|
36
|
+
const colors = {
|
|
37
|
+
...colorPalette.reduce((obj, color) => {
|
|
38
|
+
obj[color.label] = color.color
|
|
39
|
+
const shades = (color.shades || []).reduce((obj, color) => {
|
|
40
|
+
obj[color.label] = color.color
|
|
41
|
+
return obj
|
|
42
|
+
}, {})
|
|
43
|
+
return { ...obj, ...shades }
|
|
44
|
+
}, { ...themeColors, ...themeColors.shades })
|
|
45
|
+
}
|
|
46
|
+
delete colors.shades
|
|
47
|
+
|
|
48
|
+
return colors
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const colorPalette = [
|
|
2
52
|
{
|
|
3
53
|
label: 'pink',
|
|
4
54
|
color: '#e91e63',
|
|
@@ -342,5 +392,9 @@ export default [
|
|
|
342
392
|
{ label: 'grey-dark5', color: '#353535' },
|
|
343
393
|
{ label: 'grey-dark6', color: '#252525' }
|
|
344
394
|
]
|
|
345
|
-
}
|
|
395
|
+
},
|
|
396
|
+
{ label: 'black', color: '#000' },
|
|
397
|
+
{ label: 'white', color: '#fff' },
|
|
398
|
+
{ label: 'transparent', color: 'transparent' },
|
|
399
|
+
{ label: 'inherit', color: 'inherit' }
|
|
346
400
|
]
|
|
@@ -11,7 +11,7 @@ const config = Vue.observable({
|
|
|
11
11
|
},
|
|
12
12
|
css: {
|
|
13
13
|
// Generate shades for custom colors and status colors.
|
|
14
|
-
//
|
|
14
|
+
// Note: the color palette shades are always generated separately from SCSS.
|
|
15
15
|
colorShades: true,
|
|
16
16
|
|
|
17
17
|
// Generate palette colors and palette color shades.
|
|
@@ -27,10 +27,10 @@ const config = Vue.observable({
|
|
|
27
27
|
colors: {
|
|
28
28
|
primary: '#234781',
|
|
29
29
|
secondary: '#d3ebff',
|
|
30
|
-
|
|
31
|
-
error: '#f65555',
|
|
30
|
+
info: '#3d9ff5',
|
|
32
31
|
warning: '#f80',
|
|
33
|
-
|
|
32
|
+
success: '#54b946',
|
|
33
|
+
error: '#f65555'
|
|
34
34
|
},
|
|
35
35
|
icons: [],
|
|
36
36
|
iconsLigature: false,
|
|
@@ -44,9 +44,18 @@ const config = Vue.observable({
|
|
|
44
44
|
export { config as default }
|
|
45
45
|
|
|
46
46
|
export const mergeConfig = (options, conf = config) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
// If the conf object is empty, populate with options (case of presets).
|
|
48
|
+
if (!Object.keys(conf).length) conf = Object.assign(conf, options)
|
|
49
|
+
|
|
50
|
+
else {
|
|
51
|
+
for (const key in options) {
|
|
52
|
+
const option = options[key]
|
|
53
|
+
if (typeof option === 'object') {
|
|
54
|
+
mergeConfig(options[key], conf[key])
|
|
55
|
+
}
|
|
56
|
+
else conf[key] = option
|
|
57
|
+
}
|
|
51
58
|
}
|
|
59
|
+
|
|
60
|
+
return conf
|
|
52
61
|
}
|
|
@@ -19,8 +19,8 @@ const generateColors = config => {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// Color shades are generated in core.js, if the option is on.
|
|
22
|
-
if (config.css.colorShades && config.
|
|
23
|
-
Object.entries(config.
|
|
22
|
+
if (config.css.colorShades && config.shades) {
|
|
23
|
+
Object.entries(config.shades).forEach(([label, color]) => {
|
|
24
24
|
styles +=
|
|
25
25
|
`${cssScope} .${label}--bg{background-color:${color}}` +
|
|
26
26
|
`${cssScope} .${label}{color:${color}}`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Vue from 'vue'
|
|
2
2
|
|
|
3
3
|
export default class NotificationManager {
|
|
4
|
-
static instance
|
|
4
|
+
static #instance
|
|
5
5
|
notifications
|
|
6
6
|
// Private fields.
|
|
7
7
|
#uid // A unique ID for each notification.
|
|
@@ -9,9 +9,9 @@ export default class NotificationManager {
|
|
|
9
9
|
|
|
10
10
|
constructor () {
|
|
11
11
|
// Singleton pattern.
|
|
12
|
-
if (NotificationManager
|
|
12
|
+
if (NotificationManager.#instance) return NotificationManager.#instance
|
|
13
13
|
|
|
14
|
-
NotificationManager
|
|
14
|
+
NotificationManager.#instance = this
|
|
15
15
|
this.notifications = []
|
|
16
16
|
this.#uid = 0
|
|
17
17
|
this.#notificationDefaults = {
|