@formixru/b2b-ui 3.0.2 → 3.0.4
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/package.json +3 -2
- package/src/components/color-input/index.vue +155 -0
- package/src/components/date-input/index.vue +240 -0
- package/src/components/file-input/index.vue +333 -0
- package/src/components/font-input/index.vue +174 -0
- package/src/components/quantity-input/index.vue +143 -0
- package/src/components/range-input/index.vue +185 -0
- package/src/components/suggest-input/index.vue +328 -0
- package/src/components/warning-message/index.vue +101 -0
- package/src/variables.scss +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formixru/b2b-ui",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -91,7 +91,8 @@
|
|
|
91
91
|
},
|
|
92
92
|
"files": [
|
|
93
93
|
"src/**/*.scss",
|
|
94
|
-
"src/**/*.js"
|
|
94
|
+
"src/**/*.js",
|
|
95
|
+
"src/**/*.vue"
|
|
95
96
|
],
|
|
96
97
|
"msw": {
|
|
97
98
|
"workerDirectory": [
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
import { cssVar } from '../../utils/css-var.js';
|
|
82
|
+
|
|
83
|
+
const ICONS_PATH = window.ICONS_PATH;
|
|
84
|
+
|
|
85
|
+
const emit = defineEmits(['input']);
|
|
86
|
+
|
|
87
|
+
const props = defineProps({
|
|
88
|
+
name: {
|
|
89
|
+
type: String,
|
|
90
|
+
required: true,
|
|
91
|
+
},
|
|
92
|
+
value: {
|
|
93
|
+
type: String,
|
|
94
|
+
required: true,
|
|
95
|
+
},
|
|
96
|
+
preset: {
|
|
97
|
+
type: Array,
|
|
98
|
+
default() {
|
|
99
|
+
return [];
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
custom: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
},
|
|
105
|
+
transparent: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
},
|
|
108
|
+
autocolor: {
|
|
109
|
+
type: String,
|
|
110
|
+
default: '',
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const { name, value, preset, custom, transparent, autocolor } = toRefs(props);
|
|
115
|
+
|
|
116
|
+
const getHexColor = (color) => {
|
|
117
|
+
if (color.charAt(0) === '$') {
|
|
118
|
+
const colorValue = cssVar(color.replace('$', '--'));
|
|
119
|
+
return Color(colorValue).hex().toLowerCase();
|
|
120
|
+
}
|
|
121
|
+
return color;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const currentColor = ref(value.value);
|
|
125
|
+
const isTransparentColorActive = computed(() => currentColor.value === 'transparent');
|
|
126
|
+
const isAutoColorActive = computed(() => currentColor.value.indexOf('autocolor') === 0);
|
|
127
|
+
const isCustomColorActive = computed(
|
|
128
|
+
() => !preset.value.includes(currentColor.value) && !isTransparentColorActive.value && !isAutoColorActive.value,
|
|
129
|
+
);
|
|
130
|
+
const currentColorHex = computed(() => getHexColor(currentColor.value));
|
|
131
|
+
|
|
132
|
+
watch(value, (newValue) => {
|
|
133
|
+
currentColor.value = newValue;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const setColor = (color) => {
|
|
137
|
+
currentColor.value = color;
|
|
138
|
+
emit('input', currentColor.value);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const getActiveBorderColor = (color) => {
|
|
142
|
+
const colorHex = getHexColor(color);
|
|
143
|
+
// https://www.w3.org/TR/WCAG21/#contrast-minimum
|
|
144
|
+
if (Color(colorHex).contrast(Color('#ffffff')) >= 3) {
|
|
145
|
+
return colorHex;
|
|
146
|
+
}
|
|
147
|
+
return '';
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const getIconModifier = () => {
|
|
151
|
+
return !isTransparentColorActive.value && !isAutoColorActive.value && Color(currentColorHex.value).isDark()
|
|
152
|
+
? 'color-input__icon_light'
|
|
153
|
+
: 'color-input__icon_dark';
|
|
154
|
+
};
|
|
155
|
+
</script>
|
|
@@ -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 dayjs from 'dayjs';
|
|
74
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
75
|
+
import { isString } from 'es-toolkit';
|
|
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 && isString(value)) {
|
|
189
|
+
const arrValue = value.split(',');
|
|
190
|
+
date.value = {
|
|
191
|
+
start: arrValue[0],
|
|
192
|
+
end: arrValue[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>
|