@formixru/b2b-ui 1.0.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/CONTRIBUTING.md +61 -0
- package/README.md +30 -0
- package/package.json +110 -0
- package/src/base.scss +89 -0
- package/src/components/action-list/index.scss +38 -0
- package/src/components/banner/index.scss +30 -0
- package/src/components/breadcrumbs/index.js +8 -0
- package/src/components/breadcrumbs/index.scss +55 -0
- package/src/components/button/index.scss +223 -0
- package/src/components/checkbox/index.scss +94 -0
- package/src/components/color-input/index.scss +88 -0
- package/src/components/color-input/index.vue +156 -0
- package/src/components/date-input/index.scss +126 -0
- package/src/components/date-input/index.vue +240 -0
- package/src/components/delete-all/index.scss +44 -0
- package/src/components/dialog/index.js +221 -0
- package/src/components/dialog/index.scss +198 -0
- package/src/components/empty-list/index.scss +97 -0
- package/src/components/file-input/index.scss +119 -0
- package/src/components/file-input/index.vue +333 -0
- package/src/components/font-input/index.scss +47 -0
- package/src/components/font-input/index.vue +154 -0
- package/src/components/form/index.js +228 -0
- package/src/components/form/index.scss +398 -0
- package/src/components/header-announcement/index.scss +48 -0
- package/src/components/input/index.js +85 -0
- package/src/components/input/index.scss +87 -0
- package/src/components/link/index.scss +266 -0
- package/src/components/loader/index.js +65 -0
- package/src/components/loader/index.scss +99 -0
- package/src/components/nobr/index.scss +5 -0
- package/src/components/overlay/index.js +82 -0
- package/src/components/overlay/index.scss +29 -0
- package/src/components/pagination/index.scss +59 -0
- package/src/components/pagination-group/index.js +5 -0
- package/src/components/pagination-group/index.scss +86 -0
- package/src/components/quantity-input/index.scss +179 -0
- package/src/components/quantity-input/index.vue +141 -0
- package/src/components/radio/index.scss +80 -0
- package/src/components/radio-list/index.scss +79 -0
- package/src/components/range-input/index.scss +109 -0
- package/src/components/range-input/index.vue +185 -0
- package/src/components/rating-input/index.js +32 -0
- package/src/components/rating-input/index.scss +36 -0
- package/src/components/select/index.js +6 -0
- package/src/components/select/index.scss +84 -0
- package/src/components/sidebar/index.js +174 -0
- package/src/components/sidebar/index.scss +398 -0
- package/src/components/simple-page/index.scss +32 -0
- package/src/components/slider-nav/index.scss +82 -0
- package/src/components/slider-pagination/index.scss +130 -0
- package/src/components/spinner/index.scss +35 -0
- package/src/components/sr-only/index.scss +25 -0
- package/src/components/steps/index.scss +155 -0
- package/src/components/suggest-input/index.scss +141 -0
- package/src/components/suggest-input/index.vue +324 -0
- package/src/components/tabs/index.js +192 -0
- package/src/components/tabs/index.scss +137 -0
- package/src/components/time-select/index.scss +27 -0
- package/src/components/toggle/index.scss +76 -0
- package/src/components/tooltip/index.js +69 -0
- package/src/components/tooltip/index.scss +112 -0
- package/src/components/total/index.scss +162 -0
- package/src/components/warning-message/index.scss +170 -0
- package/src/components/warning-message/index.vue +94 -0
- package/src/components/wysiwyg/index.scss +344 -0
- package/src/helpers/css-var.js +8 -0
- package/src/helpers/error-handler.js +61 -0
- package/src/helpers/get-smart-captcha.js +7 -0
- package/src/helpers/is-in-viewport.js +10 -0
- package/src/helpers/mm.js +52 -0
- package/src/helpers/scroll-to.js +21 -0
- package/src/variables.scss +1295 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@use '../../variables' as *;
|
|
2
|
+
|
|
3
|
+
$b: '.checkbox';
|
|
4
|
+
|
|
5
|
+
#{$b} {
|
|
6
|
+
align-items: baseline;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
|
|
9
|
+
&__input {
|
|
10
|
+
align-items: center;
|
|
11
|
+
background-color: $checkbox-bg;
|
|
12
|
+
border: $checkbox-border-width solid $checkbox-border-color;
|
|
13
|
+
border-radius: $checkbox-radius;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-shrink: 0;
|
|
17
|
+
height: $checkbox-size;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
position: relative;
|
|
20
|
+
transition-duration: var(--duration-micro-s);
|
|
21
|
+
transition-property: background-color, border-color;
|
|
22
|
+
transition-timing-function: var(--easing-standard);
|
|
23
|
+
width: $checkbox-size;
|
|
24
|
+
|
|
25
|
+
&::before {
|
|
26
|
+
border-bottom: 3px solid $checkbox-check-color;
|
|
27
|
+
border-left: 3px solid $checkbox-check-color;
|
|
28
|
+
content: '';
|
|
29
|
+
height: 6px;
|
|
30
|
+
margin-top: -2px;
|
|
31
|
+
opacity: 0;
|
|
32
|
+
position: absolute;
|
|
33
|
+
transform: rotate(-50deg);
|
|
34
|
+
transition-duration: var(--duration-micro-s);
|
|
35
|
+
transition-property: opacity;
|
|
36
|
+
transition-timing-function: var(--easing-acceleration);
|
|
37
|
+
width: 10px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
:focus-visible + & {
|
|
41
|
+
background-color: $checkbox-active-bg;
|
|
42
|
+
border-color: $checkbox-active-border-color;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:disabled + & {
|
|
46
|
+
background-color: $checkbox-disabled-bg;
|
|
47
|
+
border-color: $checkbox-disabled-border-color;
|
|
48
|
+
cursor: default;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:checked + &::before {
|
|
52
|
+
opacity: 1;
|
|
53
|
+
transition-timing-function: var(--easing-deceleration);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
:checked:disabled + &::before {
|
|
57
|
+
opacity: 0.5;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&_square {
|
|
61
|
+
&::before {
|
|
62
|
+
background-color: $checkbox-check-color;
|
|
63
|
+
border-bottom-style: none;
|
|
64
|
+
border-left-style: none;
|
|
65
|
+
border-radius: 1px;
|
|
66
|
+
height: 10px;
|
|
67
|
+
margin-top: 0;
|
|
68
|
+
transform: none;
|
|
69
|
+
width: 10px;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&__label {
|
|
75
|
+
color: $checkbox-label-color;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-basis: 100%;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
margin-left: 4px * 2;
|
|
81
|
+
position: relative;
|
|
82
|
+
top: -2px;
|
|
83
|
+
transition-duration: var(--duration-micro-s);
|
|
84
|
+
transition-property: color;
|
|
85
|
+
transition-timing-function: var(--easing-standard);
|
|
86
|
+
|
|
87
|
+
@include font($checkbox-label-font);
|
|
88
|
+
|
|
89
|
+
:disabled ~ & {
|
|
90
|
+
color: $checkbox-disabled-label-color;
|
|
91
|
+
cursor: default;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
@use '../../variables' as *;
|
|
2
|
+
|
|
3
|
+
$b: '.color-input';
|
|
4
|
+
|
|
5
|
+
#{$b} {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
margin: 4px * -1;
|
|
9
|
+
|
|
10
|
+
&__color {
|
|
11
|
+
align-items: center;
|
|
12
|
+
border: $color-input-border-width solid $color-input-border-color;
|
|
13
|
+
border-radius: $color-input-radius;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
display: flex;
|
|
16
|
+
height: 4px * 9;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
margin: 4px;
|
|
19
|
+
transition-duration: var(--duration-micro-s);
|
|
20
|
+
transition-property: border-color;
|
|
21
|
+
transition-timing-function: var(--easing-standard);
|
|
22
|
+
width: 4px * 9;
|
|
23
|
+
|
|
24
|
+
&_active {
|
|
25
|
+
border-color: $color-input-active-border-color;
|
|
26
|
+
cursor: default;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&__example {
|
|
31
|
+
align-items: center;
|
|
32
|
+
border-radius: $color-input-radius;
|
|
33
|
+
display: flex;
|
|
34
|
+
height: 4px * 7;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
position: relative;
|
|
37
|
+
transition-duration: var(--duration-micro-s);
|
|
38
|
+
transition-property: background-color;
|
|
39
|
+
transition-timing-function: var(--easing-standard);
|
|
40
|
+
width: 4px * 7;
|
|
41
|
+
|
|
42
|
+
&_transparent {
|
|
43
|
+
background-image: linear-gradient(45deg, $color-grey-80 25%, transparent 25%),
|
|
44
|
+
linear-gradient(-45deg, $color-grey-80 25%, transparent 25%),
|
|
45
|
+
linear-gradient(45deg, transparent 75%, $color-grey-80 75%),
|
|
46
|
+
linear-gradient(-45deg, transparent 75%, $color-grey-80 75%);
|
|
47
|
+
background-position:
|
|
48
|
+
0 0,
|
|
49
|
+
0 5px,
|
|
50
|
+
5px -5px,
|
|
51
|
+
-5px 0;
|
|
52
|
+
background-size: 10px 10px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&_autocolor {
|
|
56
|
+
background-image: linear-gradient(90deg, $color-white 50%, $color-grey 50%);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&__icon {
|
|
61
|
+
height: 4px * 3;
|
|
62
|
+
position: absolute;
|
|
63
|
+
transition-duration: var(--duration-micro-s);
|
|
64
|
+
transition-property: fill;
|
|
65
|
+
transition-timing-function: var(--easing-standard);
|
|
66
|
+
width: 4px * 3;
|
|
67
|
+
|
|
68
|
+
&_dark {
|
|
69
|
+
fill: $color-input-icon-dark-color;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&_light {
|
|
73
|
+
fill: $color-input-icon-light-color;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#{$b}__example_autocolor & {
|
|
77
|
+
&:first-child {
|
|
78
|
+
clip: rect(auto, 6px, auto, auto);
|
|
79
|
+
fill: $color-input-icon-dark-color;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&:last-child {
|
|
83
|
+
clip: rect(auto, auto, auto, 6px);
|
|
84
|
+
fill: $color-input-icon-light-color;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="color-input">
|
|
3
|
+
<label
|
|
4
|
+
v-for="color in preset"
|
|
5
|
+
:key="color"
|
|
6
|
+
class="color-input__color"
|
|
7
|
+
:class="{ 'color-input__color_active': color === currentColor }"
|
|
8
|
+
:style="{ borderColor: color === currentColor ? getActiveBorderColor(color) : '' }"
|
|
9
|
+
>
|
|
10
|
+
<input
|
|
11
|
+
hidden
|
|
12
|
+
type="radio"
|
|
13
|
+
:name="name"
|
|
14
|
+
:value="color"
|
|
15
|
+
:checked="color === currentColor"
|
|
16
|
+
@change="setColor(color)"
|
|
17
|
+
/>
|
|
18
|
+
<span class="color-input__example" :style="{ backgroundColor: getHexColor(color) }"></span>
|
|
19
|
+
</label>
|
|
20
|
+
<template v-if="custom">
|
|
21
|
+
<label
|
|
22
|
+
class="color-input__color"
|
|
23
|
+
:class="{ 'color-input__color_active': isCustomColorActive }"
|
|
24
|
+
:style="{ borderColor: isCustomColorActive ? getActiveBorderColor(currentColorHex) : '' }"
|
|
25
|
+
>
|
|
26
|
+
<input
|
|
27
|
+
class="sr-only"
|
|
28
|
+
type="color"
|
|
29
|
+
:name="name"
|
|
30
|
+
:value="currentColorHex"
|
|
31
|
+
@change="setColor($event.target.value)"
|
|
32
|
+
/>
|
|
33
|
+
<span class="color-input__example" :style="{ backgroundColor: currentColorHex }">
|
|
34
|
+
<svg class="color-input__icon" :class="[getIconModifier()]">
|
|
35
|
+
<use :href="`${ICONS_PATH}#color-picker`" />
|
|
36
|
+
</svg>
|
|
37
|
+
</span>
|
|
38
|
+
</label>
|
|
39
|
+
<input hidden type="radio" :value="currentColorHex" :checked="isCustomColorActive" />
|
|
40
|
+
</template>
|
|
41
|
+
<label
|
|
42
|
+
v-if="transparent"
|
|
43
|
+
class="color-input__color"
|
|
44
|
+
:class="{ 'color-input__color_active': isTransparentColorActive }"
|
|
45
|
+
>
|
|
46
|
+
<input
|
|
47
|
+
hidden
|
|
48
|
+
type="radio"
|
|
49
|
+
:name="name"
|
|
50
|
+
value="transparent"
|
|
51
|
+
:checked="isTransparentColorActive"
|
|
52
|
+
@change="setColor($event.target.value)"
|
|
53
|
+
/>
|
|
54
|
+
<span class="color-input__example color-input__example_transparent"></span>
|
|
55
|
+
</label>
|
|
56
|
+
<label v-if="autocolor" class="color-input__color" :class="{ 'color-input__color_active': isAutoColorActive }">
|
|
57
|
+
<input
|
|
58
|
+
hidden
|
|
59
|
+
type="radio"
|
|
60
|
+
:name="name"
|
|
61
|
+
:value="autocolor"
|
|
62
|
+
:checked="isAutoColorActive"
|
|
63
|
+
@change="setColor($event.target.value)"
|
|
64
|
+
/>
|
|
65
|
+
<span class="color-input__example color-input__example_autocolor">
|
|
66
|
+
<svg class="color-input__icon">
|
|
67
|
+
<use :href="`${ICONS_PATH}#magic-wand`" />
|
|
68
|
+
</svg>
|
|
69
|
+
<svg class="color-input__icon">
|
|
70
|
+
<use :href="`${ICONS_PATH}#magic-wand`" />
|
|
71
|
+
</svg>
|
|
72
|
+
</span>
|
|
73
|
+
</label>
|
|
74
|
+
</div>
|
|
75
|
+
</template>
|
|
76
|
+
|
|
77
|
+
<script setup>
|
|
78
|
+
import Color from 'color';
|
|
79
|
+
import { computed, ref, toRefs, watch } from 'vue';
|
|
80
|
+
|
|
81
|
+
const ICONS_PATH = window.ICONS_PATH;
|
|
82
|
+
|
|
83
|
+
const emit = defineEmits(['input']);
|
|
84
|
+
|
|
85
|
+
const props = defineProps({
|
|
86
|
+
name: {
|
|
87
|
+
type: String,
|
|
88
|
+
required: true,
|
|
89
|
+
},
|
|
90
|
+
value: {
|
|
91
|
+
type: String,
|
|
92
|
+
required: true,
|
|
93
|
+
},
|
|
94
|
+
preset: {
|
|
95
|
+
type: Array,
|
|
96
|
+
default() {
|
|
97
|
+
return [];
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
custom: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
},
|
|
103
|
+
transparent: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
},
|
|
106
|
+
autocolor: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: '',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const { name, value, preset, custom, transparent, autocolor } = toRefs(props);
|
|
113
|
+
const currentColor = ref(value.value);
|
|
114
|
+
const isTransparentColorActive = computed(() => currentColor.value === 'transparent');
|
|
115
|
+
const isAutoColorActive = computed(() => currentColor.value.indexOf('autocolor') === 0);
|
|
116
|
+
const isCustomColorActive = computed(
|
|
117
|
+
() => !preset.value.includes(currentColor.value) && !isTransparentColorActive.value && !isAutoColorActive.value,
|
|
118
|
+
);
|
|
119
|
+
const currentColorHex = computed(() => getHexColor(currentColor.value));
|
|
120
|
+
|
|
121
|
+
watch(value, (newValue) => {
|
|
122
|
+
currentColor.value = newValue;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const setColor = (color) => {
|
|
126
|
+
currentColor.value = color;
|
|
127
|
+
emit('input', currentColor.value);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const getHexColor = (color) => {
|
|
131
|
+
if (color.charAt(0) === '$') {
|
|
132
|
+
const $div = document.createElement('div');
|
|
133
|
+
$div.classList.add(color.replace('$', 'theme-'));
|
|
134
|
+
document.body.append($div);
|
|
135
|
+
color = getComputedStyle($div).backgroundColor;
|
|
136
|
+
$div.remove();
|
|
137
|
+
return Color(color).hex().toLowerCase();
|
|
138
|
+
}
|
|
139
|
+
return color;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const getActiveBorderColor = (color) => {
|
|
143
|
+
color = getHexColor(color);
|
|
144
|
+
// https://www.w3.org/TR/WCAG21/#contrast-minimum
|
|
145
|
+
if (Color(color).contrast(Color('#ffffff')) >= 3) {
|
|
146
|
+
return color;
|
|
147
|
+
}
|
|
148
|
+
return '';
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const getIconModifier = () => {
|
|
152
|
+
return !isTransparentColorActive.value && !isAutoColorActive.value && Color(currentColorHex.value).isDark()
|
|
153
|
+
? 'color-input__icon_light'
|
|
154
|
+
: 'color-input__icon_dark';
|
|
155
|
+
};
|
|
156
|
+
</script>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
@use 'sass:color';
|
|
2
|
+
@use '../../variables' as *;
|
|
3
|
+
|
|
4
|
+
$b: '.date-input';
|
|
5
|
+
|
|
6
|
+
#{$b} {
|
|
7
|
+
position: relative;
|
|
8
|
+
|
|
9
|
+
&__input {
|
|
10
|
+
width: 100%;
|
|
11
|
+
|
|
12
|
+
&.input {
|
|
13
|
+
padding-left: $input-padding-x + $date-input-icon-size + 4px * 2;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&.input_small {
|
|
17
|
+
padding-left: $input-small-padding-x + $date-input-small-icon-size + 4px * 2;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&__icon {
|
|
22
|
+
fill: $date-input-icon-color;
|
|
23
|
+
height: $date-input-icon-size;
|
|
24
|
+
left: $input-padding-x;
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 50%;
|
|
27
|
+
transform: translateY(-50%);
|
|
28
|
+
transition-duration: var(--duration-micro-s);
|
|
29
|
+
transition-property: fill;
|
|
30
|
+
transition-timing-function: var(--easing-standard);
|
|
31
|
+
width: $date-input-icon-size;
|
|
32
|
+
|
|
33
|
+
#{$b}__input:disabled ~ & {
|
|
34
|
+
fill: $date-input-disabled-icon-color;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.input_small ~ & {
|
|
38
|
+
height: $date-input-small-icon-size;
|
|
39
|
+
left: $input-small-padding-x;
|
|
40
|
+
width: $date-input-small-icon-size;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&__solid {
|
|
45
|
+
&_bg {
|
|
46
|
+
background-color: $date-input-solid-bg !important;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&_color {
|
|
50
|
+
color: $date-input-solid-color !important;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&__light {
|
|
55
|
+
&_bg {
|
|
56
|
+
background-color: $date-input-light-bg !important;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&_color {
|
|
60
|
+
color: $date-input-light-color !important;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&__outline {
|
|
65
|
+
&_bg {
|
|
66
|
+
background-color: $date-input-outline-bg !important;
|
|
67
|
+
border-color: $date-input-outline-border-color !important;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&_color {
|
|
71
|
+
color: $date-input-outline-color !important;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.vc-container {
|
|
76
|
+
background-color: $date-input-bg;
|
|
77
|
+
border: none;
|
|
78
|
+
border-radius: $date-input-radius;
|
|
79
|
+
box-shadow: $date-input-shadow !important;
|
|
80
|
+
|
|
81
|
+
.is-dark-mode & {
|
|
82
|
+
@include dark-border($width: 1px);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.vc-container {
|
|
86
|
+
border: none !important;
|
|
87
|
+
box-shadow: none !important;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.vc-arrow {
|
|
92
|
+
color: $date-input-arrow-color;
|
|
93
|
+
|
|
94
|
+
&:hover,
|
|
95
|
+
&:focus {
|
|
96
|
+
background-color: $date-input-arrow-active-bg;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.vc-title {
|
|
101
|
+
color: $date-input-title-color !important;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.vc-weekday {
|
|
105
|
+
color: $date-input-weekday-color !important;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.vc-day-content {
|
|
109
|
+
color: $date-input-color;
|
|
110
|
+
|
|
111
|
+
&:hover,
|
|
112
|
+
&:focus {
|
|
113
|
+
background-color: color.change($date-input-solid-bg, $alpha: 0.1) !important;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&.is-disabled {
|
|
117
|
+
color: $date-input-disabled-color !important;
|
|
118
|
+
|
|
119
|
+
&:hover,
|
|
120
|
+
&:focus {
|
|
121
|
+
background-color: transparent !important;
|
|
122
|
+
cursor: default !important;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="date-input">
|
|
3
|
+
<VDatePicker
|
|
4
|
+
v-if="range"
|
|
5
|
+
v-model.range.string="date"
|
|
6
|
+
:min-date="minDate"
|
|
7
|
+
:max-date="maxDate"
|
|
8
|
+
:disabled-dates="parsedDisabledDates"
|
|
9
|
+
locale="ru-RU"
|
|
10
|
+
:masks="{ modelValue: 'DD.MM.YYYY' }"
|
|
11
|
+
:popover="{ visibility: 'click' }"
|
|
12
|
+
:attributes="attributes"
|
|
13
|
+
:select-attribute="selectAttribute"
|
|
14
|
+
:drag-attribute="dragAttribute"
|
|
15
|
+
@update:model-value="model = $event"
|
|
16
|
+
>
|
|
17
|
+
<template #default="{ inputValue, inputEvents }">
|
|
18
|
+
<div>
|
|
19
|
+
<input
|
|
20
|
+
:id="id"
|
|
21
|
+
class="date-input__input input"
|
|
22
|
+
:class="{ input_error: error, input_small: small }"
|
|
23
|
+
type="text"
|
|
24
|
+
readonly
|
|
25
|
+
:name="name"
|
|
26
|
+
:placeholder="placeholder || 'Введите даты'"
|
|
27
|
+
:value="inputValue.start && inputValue.end ? `${inputValue.start} — ${inputValue.end}` : ''"
|
|
28
|
+
:required="required"
|
|
29
|
+
:disabled="disabled"
|
|
30
|
+
v-on="inputEvents.start"
|
|
31
|
+
/>
|
|
32
|
+
<svg class="date-input__icon"><use :href="`${ICONS_PATH}#date`" /></svg>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
</VDatePicker>
|
|
36
|
+
<VDatePicker
|
|
37
|
+
v-else
|
|
38
|
+
v-model.string="date"
|
|
39
|
+
:min-date="minDate"
|
|
40
|
+
:max-date="maxDate"
|
|
41
|
+
:disabled-dates="parsedDisabledDates"
|
|
42
|
+
locale="ru-RU"
|
|
43
|
+
:masks="{ modelValue: 'DD.MM.YYYY' }"
|
|
44
|
+
:popover="{ visibility: 'click' }"
|
|
45
|
+
:attributes="attributes"
|
|
46
|
+
:select-attribute="selectAttribute"
|
|
47
|
+
:drag-attribute="dragAttribute"
|
|
48
|
+
@update:model-value="model = $event"
|
|
49
|
+
>
|
|
50
|
+
<template #default="{ inputValue, inputEvents }">
|
|
51
|
+
<div>
|
|
52
|
+
<input
|
|
53
|
+
:id="id"
|
|
54
|
+
class="date-input__input input"
|
|
55
|
+
:class="{ input_error: error, input_small: small }"
|
|
56
|
+
type="text"
|
|
57
|
+
readonly
|
|
58
|
+
:name="name"
|
|
59
|
+
:placeholder="placeholder || 'Введите дату'"
|
|
60
|
+
:value="inputValue"
|
|
61
|
+
:required="required"
|
|
62
|
+
:disabled="disabled"
|
|
63
|
+
v-on="inputEvents"
|
|
64
|
+
/>
|
|
65
|
+
<svg class="date-input__icon"><use :href="`${ICONS_PATH}#date`" /></svg>
|
|
66
|
+
</div>
|
|
67
|
+
</template>
|
|
68
|
+
</VDatePicker>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script setup>
|
|
73
|
+
import { is } from '@advdominion/is';
|
|
74
|
+
import dayjs from 'dayjs';
|
|
75
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
76
|
+
import { DatePicker } from 'v-calendar';
|
|
77
|
+
import { ref, toRefs, watch } from 'vue';
|
|
78
|
+
|
|
79
|
+
const ICONS_PATH = window.ICONS_PATH;
|
|
80
|
+
|
|
81
|
+
dayjs.extend(customParseFormat);
|
|
82
|
+
const VDatePicker = DatePicker;
|
|
83
|
+
|
|
84
|
+
const model = defineModel({ type: String, default: '' });
|
|
85
|
+
|
|
86
|
+
const props = defineProps({
|
|
87
|
+
id: {
|
|
88
|
+
type: String,
|
|
89
|
+
default: '',
|
|
90
|
+
},
|
|
91
|
+
name: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: '',
|
|
94
|
+
},
|
|
95
|
+
placeholder: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: '',
|
|
98
|
+
},
|
|
99
|
+
min: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: '',
|
|
102
|
+
},
|
|
103
|
+
max: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: '',
|
|
106
|
+
},
|
|
107
|
+
range: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
},
|
|
110
|
+
required: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
},
|
|
113
|
+
disabled: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
},
|
|
116
|
+
small: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
},
|
|
119
|
+
error: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
},
|
|
122
|
+
disabledDates: {
|
|
123
|
+
type: Array,
|
|
124
|
+
default() {
|
|
125
|
+
return [];
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const { id, name, placeholder, min, max, range, required, disabled, small, error, disabledDates } = toRefs(props);
|
|
131
|
+
|
|
132
|
+
const attributes = ref([
|
|
133
|
+
{
|
|
134
|
+
key: 'today',
|
|
135
|
+
highlight: {
|
|
136
|
+
fillMode: 'outline',
|
|
137
|
+
class: 'date-input__outline_bg',
|
|
138
|
+
contentClass: 'date-input__outline_color',
|
|
139
|
+
},
|
|
140
|
+
dates: new Date(),
|
|
141
|
+
},
|
|
142
|
+
]);
|
|
143
|
+
|
|
144
|
+
const selectAttribute = ref({
|
|
145
|
+
order: 1,
|
|
146
|
+
highlight: {
|
|
147
|
+
start: {
|
|
148
|
+
fillMode: 'solid',
|
|
149
|
+
class: 'date-input__solid_bg',
|
|
150
|
+
contentClass: 'date-input__solid_color',
|
|
151
|
+
},
|
|
152
|
+
base: {
|
|
153
|
+
fillMode: 'light',
|
|
154
|
+
class: 'date-input__light_bg',
|
|
155
|
+
contentClass: 'date-input__light_color',
|
|
156
|
+
},
|
|
157
|
+
end: {
|
|
158
|
+
fillMode: 'solid',
|
|
159
|
+
class: 'date-input__solid_bg',
|
|
160
|
+
contentClass: 'date-input__solid_color',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const dragAttribute = ref({
|
|
166
|
+
highlight: {
|
|
167
|
+
start: {
|
|
168
|
+
fillMode: 'outline',
|
|
169
|
+
class: 'date-input__outline_bg',
|
|
170
|
+
contentClass: 'date-input__outline_color',
|
|
171
|
+
},
|
|
172
|
+
base: {
|
|
173
|
+
fillMode: 'light',
|
|
174
|
+
class: 'date-input__light_bg',
|
|
175
|
+
contentClass: 'date-input__light_color',
|
|
176
|
+
},
|
|
177
|
+
end: {
|
|
178
|
+
fillMode: 'outline',
|
|
179
|
+
class: 'date-input__outline_bg',
|
|
180
|
+
contentClass: 'date-input__outline_color',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const date = ref();
|
|
186
|
+
const setDate = (value) => {
|
|
187
|
+
if (value) {
|
|
188
|
+
if (range.value && is(value, 'String')) {
|
|
189
|
+
value = value.split(',');
|
|
190
|
+
date.value = {
|
|
191
|
+
start: value[0],
|
|
192
|
+
end: value[1],
|
|
193
|
+
};
|
|
194
|
+
} else {
|
|
195
|
+
date.value = value;
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
date.value = undefined;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
setDate(model.value);
|
|
202
|
+
watch(model, () => {
|
|
203
|
+
setDate(model.value);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const minDate = ref();
|
|
207
|
+
const setMin = (value) => {
|
|
208
|
+
minDate.value = value ? dayjs(value, 'DD.MM.YYYY').toDate() : undefined;
|
|
209
|
+
};
|
|
210
|
+
setMin(min.value);
|
|
211
|
+
watch(min, (newMinValue) => {
|
|
212
|
+
setMin(newMinValue);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const maxDate = ref();
|
|
216
|
+
const setMax = (value) => {
|
|
217
|
+
maxDate.value = value ? dayjs(value, 'DD.MM.YYYY').toDate() : undefined;
|
|
218
|
+
};
|
|
219
|
+
setMax(max.value);
|
|
220
|
+
watch(max, (newMaxValue) => {
|
|
221
|
+
setMax(newMaxValue);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const parsedDisabledDates = ref();
|
|
225
|
+
const setParsedDisabledDates = (value) => {
|
|
226
|
+
parsedDisabledDates.value = value.map((date) => {
|
|
227
|
+
return date ? dayjs(date, 'DD.MM.YYYY').toDate() : '';
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
setParsedDisabledDates(disabledDates.value);
|
|
231
|
+
watch(disabledDates, (newDisabledDates) => {
|
|
232
|
+
setParsedDisabledDates(newDisabledDates);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
defineExpose({
|
|
236
|
+
setDate,
|
|
237
|
+
setMin,
|
|
238
|
+
setMax,
|
|
239
|
+
});
|
|
240
|
+
</script>
|