@energie360/ui-library 0.0.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/.browserslistrc +1 -0
- package/README.md +3 -0
- package/base/_accessibility.scss +5 -0
- package/base/_base.scss +104 -0
- package/base/_body.scss +7 -0
- package/base/_focus-handling.scss +18 -0
- package/base/_html.scss +11 -0
- package/base/_input-resets.scss +49 -0
- package/base/_print.scss +6 -0
- package/base/_resets.scss +53 -0
- package/base/abstracts/_functions.scss +21 -0
- package/base/abstracts/_layers.scss +6 -0
- package/base/abstracts/_mixins.scss +80 -0
- package/base/abstracts/_resets.scss +11 -0
- package/base/abstracts/_variables.scss +42 -0
- package/base/abstracts/index.scss +5 -0
- package/base/base-v2.scss +35 -0
- package/base/custom-element-base.scss +14 -0
- package/base/index.scss +5 -0
- package/base/main.scss +14 -0
- package/dist/index.css +1 -0
- package/dist/index.js +5182 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +20 -0
- package/dist/style.js +2 -0
- package/dist/style.js.map +1 -0
- package/elements/button/_button-base.scss +49 -0
- package/elements/button/_button-filled-inverted.scss +41 -0
- package/elements/button/_button-filled.scss +32 -0
- package/elements/button/_button-outlined-inverted.scss +38 -0
- package/elements/button/_button-outlined.scss +38 -0
- package/elements/button/_button-plain-small.scss +7 -0
- package/elements/button/_button-plain.scss +49 -0
- package/elements/button/_button-secondary-outlined.scss +38 -0
- package/elements/button/button.js +12 -0
- package/elements/button/button.scss +68 -0
- package/elements/button/button.vue +42 -0
- package/elements/icon/icon.ce.scss +6 -0
- package/elements/icon/icon.js +13 -0
- package/elements/icon/icon.scss +25 -0
- package/elements/icon/icon.vue +80 -0
- package/elements/icon-button/_icon-button-base.scss +59 -0
- package/elements/icon-button/_icon-button-filled-inverted.scss +42 -0
- package/elements/icon-button/_icon-button-filled.scss +32 -0
- package/elements/icon-button/_icon-button-outlined-inverted.scss +34 -0
- package/elements/icon-button/_icon-button-outlined.scss +38 -0
- package/elements/icon-button/_icon-button-plain-inverted.scss +32 -0
- package/elements/icon-button/_icon-button-plain.scss +32 -0
- package/elements/icon-button/icon-button.js +12 -0
- package/elements/icon-button/icon-button.scss +51 -0
- package/elements/icon-button/icon-button.vue +41 -0
- package/elements/index.js +11 -0
- package/elements/loader/loader.ce.scss +5 -0
- package/elements/loader/loader.js +13 -0
- package/elements/loader/loader.scss +106 -0
- package/elements/loader/loader.vue +18 -0
- package/globals.js +4 -0
- package/index.js +1 -0
- package/package.json +30 -0
- package/style.js +2 -0
- package/utils/math/clamp.js +14 -0
- package/utils/math/index.js +1 -0
- package/utils/object/deep-get.js +26 -0
- package/utils/object/index.js +2 -0
- package/utils/translations/index.js +1 -0
- package/utils/translations/translate.js +10 -0
- package/vite.config.js +31 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@mixin icon-button-filled-inverted {
|
|
2
|
+
&::before {
|
|
3
|
+
background-color: var(--e-c-mono-00);
|
|
4
|
+
border-color: var(--e-c-mono-00);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.icon,
|
|
8
|
+
e-icon {
|
|
9
|
+
--icon-fill-color: var(--e-c-primary-01-700);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&:hover {
|
|
13
|
+
&::before {
|
|
14
|
+
background-color: var(--e-c-primary-01-100);
|
|
15
|
+
border-color: var(--e-c-primary-01-100);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.icon,
|
|
19
|
+
e-icon {
|
|
20
|
+
--icon-fill-color: var(--e-c-secondary-01-700);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:active {
|
|
25
|
+
&::before {
|
|
26
|
+
background-color: var(--e-c-primary-01-200);
|
|
27
|
+
border-color: var(--e-c-primary-01-200);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:disabled {
|
|
32
|
+
&::before {
|
|
33
|
+
background-color: var(--e-c-mono-500);
|
|
34
|
+
border-color: var(--e-c-mono-500);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.icon,
|
|
38
|
+
e-icon {
|
|
39
|
+
--icon-fill-color: var(--e-c-mono-700);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@mixin icon-button-filled {
|
|
2
|
+
&::before {
|
|
3
|
+
background-color: var(--e-c-primary-01-700);
|
|
4
|
+
border-color: var(--e-c-primary-01-700);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.icon,
|
|
8
|
+
e-icon {
|
|
9
|
+
--icon-fill-color: var(--e-c-mono-00);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&:hover {
|
|
13
|
+
&::before {
|
|
14
|
+
background-color: var(--e-c-secondary-01-900);
|
|
15
|
+
border-color: var(--e-c-secondary-01-900);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&:active {
|
|
20
|
+
&::before {
|
|
21
|
+
background-color: var(--e-c-secondary-01-700);
|
|
22
|
+
border-color: var(--e-c-secondary-01-700);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&:disabled {
|
|
27
|
+
&::before {
|
|
28
|
+
background-color: var(--e-c-mono-500);
|
|
29
|
+
border-color: var(--e-c-mono-500);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@mixin icon-button-outlined-inverted {
|
|
2
|
+
&::before {
|
|
3
|
+
background-color: transparent;
|
|
4
|
+
border-color: var(--e-c-mono-00);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.icon,
|
|
8
|
+
e-icon {
|
|
9
|
+
--icon-fill-color: var(--e-c-mono-00);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&:hover {
|
|
13
|
+
&::before {
|
|
14
|
+
border-color: var(--e-c-primary-01-200);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:active {
|
|
19
|
+
&::before {
|
|
20
|
+
border-color: var(--e-c-primary-01-500);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:disabled {
|
|
25
|
+
&::before {
|
|
26
|
+
border-color: var(--e-c-mono-500);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.icon,
|
|
30
|
+
e-icon {
|
|
31
|
+
--icon-fill-color: var(--e-c-mono-500);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@mixin icon-button-outline-hover-state {
|
|
2
|
+
&::before {
|
|
3
|
+
border-color: var(--e-c-primary-01-200);
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
@mixin icon-button-outlined {
|
|
8
|
+
&::before {
|
|
9
|
+
background-color: transparent;
|
|
10
|
+
border-color: var(--e-c-mono-500);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.icon,
|
|
14
|
+
e-icon {
|
|
15
|
+
--icon-fill-color: var(--e-c-mono-900);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:hover {
|
|
19
|
+
@include icon-button-outline-hover-state;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&:active {
|
|
23
|
+
&::before {
|
|
24
|
+
border-color: var(--e-c-primary-01-500);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:disabled {
|
|
29
|
+
&::before {
|
|
30
|
+
border-color: var(--e-c-mono-500);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.icon,
|
|
34
|
+
e-icon {
|
|
35
|
+
--icon-fill-color: var(--e-c-mono-500);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@mixin icon-button-plain-inverted {
|
|
2
|
+
&::before {
|
|
3
|
+
background-color: transparent;
|
|
4
|
+
border-color: transparent;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.icon,
|
|
8
|
+
e-icon {
|
|
9
|
+
--icon-fill-color: var(--e-c-mono-00);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&:hover {
|
|
13
|
+
&::before {
|
|
14
|
+
background-color: var(--e-c-secondary-01-700);
|
|
15
|
+
border-color: var(--e-c-secondary-01-700);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&:active {
|
|
20
|
+
&::before {
|
|
21
|
+
background-color: var(--e-c-secondary-01-900);
|
|
22
|
+
border-color: var(--e-c-secondary-01-900);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&:disabled {
|
|
27
|
+
.icon,
|
|
28
|
+
e-icon {
|
|
29
|
+
--icon-fill-color: var(--e-c-mono-500);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@mixin icon-button-plain {
|
|
2
|
+
&::before {
|
|
3
|
+
background-color: transparent;
|
|
4
|
+
border-color: transparent;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.icon,
|
|
8
|
+
e-icon {
|
|
9
|
+
--icon-fill-color: var(--e-c-primary-01-700);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&:hover {
|
|
13
|
+
&::before {
|
|
14
|
+
background-color: var(--e-c-primary-01-50);
|
|
15
|
+
border-color: var(--e-c-primary-01-50);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&:active {
|
|
20
|
+
&::before {
|
|
21
|
+
background-color: var(--e-c-primary-01-100);
|
|
22
|
+
border-color: var(--e-c-primary-01-100);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&:disabled {
|
|
27
|
+
.icon,
|
|
28
|
+
e-icon {
|
|
29
|
+
--icon-fill-color: var(--e-c-mono-500);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineCustomElement } from 'vue'
|
|
2
|
+
import IconButton from './icon-button.vue'
|
|
3
|
+
import customElementBaseStyle from '../../base/custom-element-base.scss?inline'
|
|
4
|
+
import styles from './icon-button.scss?inline'
|
|
5
|
+
|
|
6
|
+
IconButton.styles = [customElementBaseStyle, styles]
|
|
7
|
+
|
|
8
|
+
export const IconButtonElement = {
|
|
9
|
+
register: () => {
|
|
10
|
+
customElements.define('e-icon-button', defineCustomElement(IconButton))
|
|
11
|
+
},
|
|
12
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Custom ELement base
|
|
2
|
+
@use '../../base/abstracts' as a;
|
|
3
|
+
@use '../../base/custom-element-base';
|
|
4
|
+
@use '../../base/focus-handling';
|
|
5
|
+
@use '../../base/resets';
|
|
6
|
+
@use '../../base/accessibility';
|
|
7
|
+
|
|
8
|
+
// Icon Button base and variants
|
|
9
|
+
@use './icon-button-base' as *;
|
|
10
|
+
@use './icon-button-filled' as *;
|
|
11
|
+
@use './icon-button-outlined' as *;
|
|
12
|
+
@use './icon-button-plain' as *;
|
|
13
|
+
@use './icon-button-filled-inverted' as *;
|
|
14
|
+
@use './icon-button-outlined-inverted' as *;
|
|
15
|
+
@use './icon-button-plain-inverted' as *;
|
|
16
|
+
|
|
17
|
+
.icon-button {
|
|
18
|
+
.icon,
|
|
19
|
+
e-icon {
|
|
20
|
+
// Icons must always have this size in button.
|
|
21
|
+
width: a.rem(24);
|
|
22
|
+
height: a.rem(24);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@include icon-button-base;
|
|
26
|
+
|
|
27
|
+
// ---- PRIMARY ----
|
|
28
|
+
& {
|
|
29
|
+
@include icon-button-filled;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.outlined {
|
|
33
|
+
@include icon-button-outlined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.plain {
|
|
37
|
+
@include icon-button-plain;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.filled-inverted {
|
|
41
|
+
@include icon-button-filled-inverted;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&.outlined-inverted {
|
|
45
|
+
@include icon-button-outlined-inverted;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.plain-inverted {
|
|
49
|
+
@include icon-button-plain-inverted;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import Icon from '../icon/icon.vue'
|
|
3
|
+
|
|
4
|
+
defineProps({
|
|
5
|
+
label: String,
|
|
6
|
+
icon: String,
|
|
7
|
+
variant: String,
|
|
8
|
+
disabled: Boolean,
|
|
9
|
+
href: String,
|
|
10
|
+
target: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: '_blank',
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<template v-if="href">
|
|
19
|
+
<a :class="['icon-button', variant]" :href="href" :target="target">
|
|
20
|
+
<Icon v-if="icon" :name="icon" />
|
|
21
|
+
|
|
22
|
+
<span class="visually-hidden">
|
|
23
|
+
{{ label }}
|
|
24
|
+
</span>
|
|
25
|
+
</a>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<template v-else>
|
|
29
|
+
<button :class="['icon-button', variant]" :disabled="disabled || null">
|
|
30
|
+
<Icon v-if="icon" :name="icon" />
|
|
31
|
+
|
|
32
|
+
<span class="visually-hidden">
|
|
33
|
+
{{ label }}
|
|
34
|
+
</span>
|
|
35
|
+
</button>
|
|
36
|
+
</template>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<style lang="scss" scoped>
|
|
40
|
+
@use './icon-button.scss';
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonElement as Button } from './button/button.js'
|
|
2
|
+
import { IconButtonElement as IconButton } from './icon-button/icon-button.js'
|
|
3
|
+
import { IconElement as Icon } from './icon/icon.js'
|
|
4
|
+
import { LoaderElement as Loader } from './loader/loader.js'
|
|
5
|
+
|
|
6
|
+
export const Elements = {
|
|
7
|
+
Button,
|
|
8
|
+
IconButton,
|
|
9
|
+
Icon,
|
|
10
|
+
Loader,
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineCustomElement } from 'vue'
|
|
2
|
+
import Loader from './loader.vue'
|
|
3
|
+
import customElementBaseStyle from '../../base/custom-element-base.scss?inline'
|
|
4
|
+
import ceStyles from './loader.ce.scss?inline'
|
|
5
|
+
import styles from './loader.scss?inline'
|
|
6
|
+
|
|
7
|
+
Loader.styles = [customElementBaseStyle, ceStyles, styles]
|
|
8
|
+
|
|
9
|
+
export const LoaderElement = {
|
|
10
|
+
register: () => {
|
|
11
|
+
customElements.define('e-loader', defineCustomElement(Loader))
|
|
12
|
+
},
|
|
13
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
$horizontal-width: 64px;
|
|
2
|
+
$vertical-height: 12px;
|
|
3
|
+
|
|
4
|
+
@keyframes horizontal {
|
|
5
|
+
0% {
|
|
6
|
+
transform: translateX(0);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
20% {
|
|
10
|
+
transform: translateX(0);
|
|
11
|
+
opacity: 1;
|
|
12
|
+
width: 8px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
50% {
|
|
16
|
+
transform: translateX(calc(#{$horizontal-width} / 2 - 8px));
|
|
17
|
+
opacity: 0.7;
|
|
18
|
+
width: 16px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
80% {
|
|
22
|
+
transform: translateX(calc(#{$horizontal-width} - 8px));
|
|
23
|
+
opacity: 1;
|
|
24
|
+
width: 8px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
100% {
|
|
28
|
+
transform: translateX(calc(#{$horizontal-width} - 8px));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@keyframes vertical {
|
|
33
|
+
0% {
|
|
34
|
+
transform: translateY(0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
50% {
|
|
38
|
+
transform: translateY(0);
|
|
39
|
+
opacity: 1;
|
|
40
|
+
height: 8px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
55% {
|
|
44
|
+
transform: translateY(-#{$vertical-height});
|
|
45
|
+
opacity: 0.7;
|
|
46
|
+
height: 16px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
60% {
|
|
50
|
+
transform: translateY(0);
|
|
51
|
+
opacity: 1;
|
|
52
|
+
height: 8px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
70% {
|
|
56
|
+
transform: translateY(-4px);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
100% {
|
|
60
|
+
transform: translateY(0);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Default loader styles */
|
|
65
|
+
.loader {
|
|
66
|
+
position: relative;
|
|
67
|
+
display: inline-flex;
|
|
68
|
+
|
|
69
|
+
--dot-color: var(--e-c-mono-900);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.loader > span {
|
|
73
|
+
display: block;
|
|
74
|
+
width: 8px;
|
|
75
|
+
height: 8px;
|
|
76
|
+
border-radius: 4px;
|
|
77
|
+
background-color: var(--dot-color);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Horizontal animation */
|
|
81
|
+
.loader.horizontal {
|
|
82
|
+
width: #{$horizontal-width};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.loader.horizontal > span {
|
|
86
|
+
transform: translateX(0);
|
|
87
|
+
animation-name: horizontal;
|
|
88
|
+
animation-duration: 1s;
|
|
89
|
+
animation-direction: alternate;
|
|
90
|
+
animation-timing-function: cubic-bezier(0.4, 0.61, 0.61, 0.4);
|
|
91
|
+
animation-iteration-count: infinite;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Vertical animation */
|
|
95
|
+
.loader.vertical {
|
|
96
|
+
height: 8px;
|
|
97
|
+
width: 8px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.loader.vertical > span {
|
|
101
|
+
transform: translateY(0);
|
|
102
|
+
animation-name: vertical;
|
|
103
|
+
animation-duration: 2000ms;
|
|
104
|
+
animation-timing-function: cubic-bezier(0.47, 0.52, 0.165, 1.005);
|
|
105
|
+
animation-iteration-count: infinite;
|
|
106
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineProps({
|
|
3
|
+
anim: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: 'horizontal',
|
|
6
|
+
},
|
|
7
|
+
})
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<span :class="['loader', anim]">
|
|
12
|
+
<span></span>
|
|
13
|
+
</span>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style lang="scss" scoped>
|
|
17
|
+
@use './loader.scss';
|
|
18
|
+
</style>
|
package/globals.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// A possible idea would be to use a cdn when the package is built.
|
|
2
|
+
// Currently we'll use a fixed path for the assets on dev and prod. This must be made available by the application using ui-library.
|
|
3
|
+
export const assetsPath =
|
|
4
|
+
import.meta.env.DEV === true ? '/static/ui-assets' : '/static/ui-assets'
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './elements/'
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@energie360/ui-library",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js",
|
|
8
|
+
"./style.css": "./dist/style.css",
|
|
9
|
+
"./elements/*": "./elements/*"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
16
|
+
"autoprefixer": "^10.4.20",
|
|
17
|
+
"postcss": "^8.5.1",
|
|
18
|
+
"sass": "^1.83.4",
|
|
19
|
+
"vite": "^6.0.7",
|
|
20
|
+
"vue": "^3.5.13"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@energie360/design-tokens": "^1.1.0"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "NODE_ENV=development vite build --watch --mode developement",
|
|
27
|
+
"build": "vite build",
|
|
28
|
+
"prepublish": "npm run build"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/style.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamp number to given bounds.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* clamp(123, 50, 110) // -> 110
|
|
6
|
+
*
|
|
7
|
+
* @param {Number} num
|
|
8
|
+
* @param {Number} lower - Lower bound
|
|
9
|
+
* @param {Number} upper - Upper bound
|
|
10
|
+
* @returns {Number}
|
|
11
|
+
*/
|
|
12
|
+
export const clamp = (num, lower, upper) => {
|
|
13
|
+
return Math.min(Math.max(num, lower), upper)
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { clamp } from './clamp.js'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* eslint no-useless-escape:off */
|
|
2
|
+
// From https://www.30secondsofcode.org/js/s/get-nested-object-value/
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} obj
|
|
7
|
+
* @param {Array} keys
|
|
8
|
+
* @returns {*}
|
|
9
|
+
*/
|
|
10
|
+
export const deepGet = (obj, keys) =>
|
|
11
|
+
keys.reduce((xs, x) => xs?.[x] ?? null, obj)
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} obj
|
|
16
|
+
* @param {string} path
|
|
17
|
+
* @returns {*}
|
|
18
|
+
*/
|
|
19
|
+
export const deepGetByPath = (obj, path) =>
|
|
20
|
+
deepGet(
|
|
21
|
+
obj,
|
|
22
|
+
path
|
|
23
|
+
.replace(/\[([^\[\]]*)\]/g, '.$1.')
|
|
24
|
+
.split('.')
|
|
25
|
+
.filter((t) => t !== ''),
|
|
26
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { translate } from './translate.js'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { deepGetByPath } from '../object/deep-get.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {string} translationKeyPath
|
|
6
|
+
* @param {string} defaultValue
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export const translate = (translationKeyPath, defaultValue = '') =>
|
|
10
|
+
deepGetByPath(window._EC.translations, translationKeyPath) || defaultValue
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { resolve } from 'path'
|
|
2
|
+
import { defineConfig } from 'vite'
|
|
3
|
+
import vue from '@vitejs/plugin-vue'
|
|
4
|
+
import autoprefixer from 'autoprefixer'
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
plugins: [vue()],
|
|
8
|
+
build: {
|
|
9
|
+
cssCodeSplit: true,
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
lib: {
|
|
12
|
+
entry: [resolve(__dirname, 'index.js'), resolve(__dirname, 'style.js')],
|
|
13
|
+
name: '@energie360/ui-library',
|
|
14
|
+
formats: ['es'],
|
|
15
|
+
fileName: (format, entryName) => `${entryName}.js`,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
optimizeDeps: {
|
|
19
|
+
entries: [],
|
|
20
|
+
},
|
|
21
|
+
css: {
|
|
22
|
+
postcss: {
|
|
23
|
+
plugins: [autoprefixer],
|
|
24
|
+
},
|
|
25
|
+
preprocessorOptions: {
|
|
26
|
+
scss: {
|
|
27
|
+
api: 'modern-compiler',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|