its_ui_vite 1.1.2 → 1.1.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 +16 -3
- package/src/components/CDatepicker.vue +139 -36
- package/src/components/CInput2Select.vue +35 -4
- package/src/components/CSelect.vue +12 -4
- package/src/pages/index.vue +7 -3
- package/src/stories/CAlert.stories.js +66 -0
- package/src/stories/CButton.stories.js +105 -0
- package/src/stories/CCheckbox.stories.js +112 -0
- package/src/stories/CCheckbox2.stories.js +102 -0
- package/src/stories/CDatepicker.stories.js +147 -0
- package/src/stories/CDropdown.stories.js +161 -0
- package/src/stories/CIcon.stories.js +54 -0
- package/src/stories/CInput.stories.js +102 -0
- package/src/stories/CInput2.stories.js +104 -0
- package/src/stories/CInput2Select.stories.js +208 -0
- package/src/stories/CPopup.stories.js +62 -0
- package/src/stories/CScroll.stories.js +66 -0
- package/src/stories/CSelect.stories.js +150 -0
- package/src/stories/CTabs.stories.js +83 -0
- package/src/stories/CTooltip.stories.js +172 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "its_ui_vite",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"main": "./src/libIndex.js",
|
|
5
5
|
"module": "./src/libIndex.js",
|
|
6
6
|
"files": [
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
"dev": "vite",
|
|
18
18
|
"build": "vite build",
|
|
19
19
|
"preview": "vite preview",
|
|
20
|
-
"icons": "node ./icon.js"
|
|
20
|
+
"icons": "node ./icon.js",
|
|
21
|
+
"storybook": "storybook dev -p 6006",
|
|
22
|
+
"build-storybook": "storybook build"
|
|
21
23
|
},
|
|
22
24
|
"dependencies": {
|
|
23
25
|
"compression": "^1.7.4",
|
|
@@ -31,7 +33,18 @@
|
|
|
31
33
|
"devDependencies": {
|
|
32
34
|
"@vitejs/plugin-vue": "^4.6.2",
|
|
33
35
|
"sass": "^1.69.5",
|
|
34
|
-
"vite": "^5.0.8"
|
|
36
|
+
"vite": "^5.0.8",
|
|
37
|
+
"storybook": "^10.2.8",
|
|
38
|
+
"@storybook/vue3-vite": "^10.2.8",
|
|
39
|
+
"@chromatic-com/storybook": "^5.0.1",
|
|
40
|
+
"@storybook/addon-vitest": "^10.2.8",
|
|
41
|
+
"@storybook/addon-a11y": "^10.2.8",
|
|
42
|
+
"@storybook/addon-docs": "^10.2.8",
|
|
43
|
+
"@storybook/addon-onboarding": "^10.2.8",
|
|
44
|
+
"vitest": "^4.0.18",
|
|
45
|
+
"playwright": "^1.58.2",
|
|
46
|
+
"@vitest/browser-playwright": "^4.0.18",
|
|
47
|
+
"@vitest/coverage-v8": "^4.0.18"
|
|
35
48
|
},
|
|
36
49
|
"peerDependencies": {
|
|
37
50
|
"sass": ">=1"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div
|
|
3
3
|
ref="root"
|
|
4
4
|
:data-c-datepicker-id="datePickerId"
|
|
5
|
-
class="c-datepicker"
|
|
5
|
+
:class="['c-datepicker', color]"
|
|
6
6
|
:style="`--transition: ${transition}ms; --width: ${width}; --picker-content-indent-y: ${pickerContentIndentY}px`"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
@click="setIsOpen(!isOpenPicker)"
|
|
12
12
|
>
|
|
13
13
|
<CInput
|
|
14
|
-
class="c-datepicker__inp"
|
|
14
|
+
:class="['c-datepicker__inp', { 'empty-date': isEmptyDate }]"
|
|
15
15
|
size="sm"
|
|
16
16
|
:width="width"
|
|
17
17
|
:placeholder="datePlaceholder"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<div
|
|
38
38
|
v-if="showTime"
|
|
39
39
|
ref="time"
|
|
40
|
-
:class="['c-datepicker__time_wrap', { open: isOpenTime }]"
|
|
40
|
+
:class="['c-datepicker__time_wrap', { open: isOpenTime, 'empty-date': isEmptyDate }]"
|
|
41
41
|
>
|
|
42
42
|
<div
|
|
43
43
|
class="c-datepicker__time_inps"
|
|
@@ -176,14 +176,14 @@
|
|
|
176
176
|
class="c-datepicker__action_btn"
|
|
177
177
|
variant="outlined"
|
|
178
178
|
size="md"
|
|
179
|
-
@click="
|
|
179
|
+
@click="cancelDate"
|
|
180
180
|
>
|
|
181
181
|
{{ text.cancel }}
|
|
182
182
|
</CButton>
|
|
183
183
|
<CButton
|
|
184
184
|
class="c-datepicker__action_btn"
|
|
185
185
|
size="md"
|
|
186
|
-
:disabled="
|
|
186
|
+
:disabled="isDisableDate"
|
|
187
187
|
@click="setDate"
|
|
188
188
|
>
|
|
189
189
|
{{ text.accept }}
|
|
@@ -210,7 +210,9 @@ import { computed, ref, watch, onMounted, onUnmounted, Teleport } from 'vue';
|
|
|
210
210
|
|
|
211
211
|
type TProps = {
|
|
212
212
|
date?: string,
|
|
213
|
-
|
|
213
|
+
emptyDate?: boolean,
|
|
214
|
+
showTime?: boolean,
|
|
215
|
+
color?: 'green' | 'green2',
|
|
214
216
|
locale?: 'rus' | 'usa' | 'tur' | 'spa',
|
|
215
217
|
max?: string,
|
|
216
218
|
min?: string,
|
|
@@ -222,6 +224,8 @@ type TProps = {
|
|
|
222
224
|
|
|
223
225
|
const props = withDefaults(defineProps<TProps>(), {
|
|
224
226
|
locale: 'rus',
|
|
227
|
+
color: 'green',
|
|
228
|
+
emptyDate: false,
|
|
225
229
|
showTime: true,
|
|
226
230
|
isOpen: false,
|
|
227
231
|
width: '100%',
|
|
@@ -238,6 +242,7 @@ type TMonthDay = {
|
|
|
238
242
|
type TSelectOption = {
|
|
239
243
|
text: string,
|
|
240
244
|
value: number,
|
|
245
|
+
disable?: boolean,
|
|
241
246
|
}
|
|
242
247
|
|
|
243
248
|
const transition = 200;
|
|
@@ -262,6 +267,8 @@ let oldDateISO = ref<any>(defaultDate.toISO())
|
|
|
262
267
|
let activeDate = ref<any>(defaultDate);
|
|
263
268
|
let activeMonth = ref<number>(defaultDate.month);
|
|
264
269
|
let activeYear = ref<number>(defaultDate.year);
|
|
270
|
+
let isEmptyDate = ref<boolean>(false);
|
|
271
|
+
let isDisableDate = ref<boolean>(false);
|
|
265
272
|
|
|
266
273
|
let modelMonth: any = ref([]);
|
|
267
274
|
let modelYear: any = ref([]);
|
|
@@ -290,27 +297,7 @@ const TracingElement = addTracingElement(root, handlePicker);
|
|
|
290
297
|
const TracingTime = addTracingElement(time, handleTime);
|
|
291
298
|
|
|
292
299
|
onMounted(() => {
|
|
293
|
-
|
|
294
|
-
if (typeof props.date === 'string') {
|
|
295
|
-
activeDate.value = DateTime.fromISO(props.date)
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (!activeDate.value?.isValid) {
|
|
299
|
-
activeDate.value = defaultDate
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const currentDate = activeDate.value.toISO();
|
|
304
|
-
|
|
305
|
-
oldDateISO.value = currentDate;
|
|
306
|
-
|
|
307
|
-
activeMonth.value = activeDate.value.month;
|
|
308
|
-
activeYear.value = activeDate.value.year;
|
|
309
|
-
|
|
310
|
-
fillMonthDays(currentDate);
|
|
311
|
-
|
|
312
|
-
setTime('hour', activeDate.value.toFormat('HH'));
|
|
313
|
-
setTime('minute', activeDate.value.toFormat('mm'));
|
|
300
|
+
isEmptyDate.value = props.emptyDate && !props.date;
|
|
314
301
|
|
|
315
302
|
TracingElement.addListeners();
|
|
316
303
|
TracingTime.addListeners();
|
|
@@ -320,6 +307,15 @@ onMounted(() => {
|
|
|
320
307
|
fullscreenEvents.forEach((eventName) => {
|
|
321
308
|
document.addEventListener(eventName, setTeleportTo);
|
|
322
309
|
});
|
|
310
|
+
|
|
311
|
+
if (isEmptyDate.value) {
|
|
312
|
+
isDisableDate.value = true;
|
|
313
|
+
|
|
314
|
+
setTime('hour', '00');
|
|
315
|
+
setTime('minute', '00');
|
|
316
|
+
} else {
|
|
317
|
+
initDate(props.date)
|
|
318
|
+
}
|
|
323
319
|
});
|
|
324
320
|
|
|
325
321
|
onUnmounted(() => {
|
|
@@ -345,6 +341,7 @@ const text = computed(() => {
|
|
|
345
341
|
daysOfWeek: ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'],
|
|
346
342
|
months: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
|
|
347
343
|
cancel: 'Отмена',
|
|
344
|
+
emptyDate: 'дд.мм.гггг',
|
|
348
345
|
accept: 'OK',
|
|
349
346
|
},
|
|
350
347
|
|
|
@@ -352,6 +349,7 @@ const text = computed(() => {
|
|
|
352
349
|
daysOfWeek: [ 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa' ],
|
|
353
350
|
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
354
351
|
cancel: 'Cancel',
|
|
352
|
+
emptyDate: 'dd.mm.yyyy',
|
|
355
353
|
accept: 'OK',
|
|
356
354
|
},
|
|
357
355
|
|
|
@@ -359,6 +357,7 @@ const text = computed(() => {
|
|
|
359
357
|
daysOfWeek: [ 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa' ],
|
|
360
358
|
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
361
359
|
cancel: 'Cancel',
|
|
360
|
+
emptyDate: 'dd.mm.yyyy',
|
|
362
361
|
accept: 'OK',
|
|
363
362
|
},
|
|
364
363
|
|
|
@@ -366,6 +365,7 @@ const text = computed(() => {
|
|
|
366
365
|
daysOfWeek: [ 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa' ],
|
|
367
366
|
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
368
367
|
cancel: 'Cancel',
|
|
368
|
+
emptyDate: 'dd.mm.aaaa',
|
|
369
369
|
accept: 'OK',
|
|
370
370
|
},
|
|
371
371
|
};
|
|
@@ -374,17 +374,31 @@ const text = computed(() => {
|
|
|
374
374
|
});
|
|
375
375
|
|
|
376
376
|
const datePlaceholder = computed(() => {
|
|
377
|
-
|
|
377
|
+
if (isEmptyDate.value) return text.value.emptyDate
|
|
378
|
+
|
|
379
|
+
const currentDateISO = activeDate.value.toISO()
|
|
378
380
|
return DateTime.fromISO(currentDateISO).setLocale(props.locale).toFormat('dd LLLL yyyy')
|
|
379
381
|
});
|
|
380
382
|
|
|
381
383
|
const monthsOption = computed(() => {
|
|
382
384
|
let options: TSelectOption[] = [];
|
|
383
385
|
|
|
386
|
+
const maxDateStr = props?.max || '';
|
|
387
|
+
const minDateStr = props?.min || '';
|
|
388
|
+
const maxDate = DateTime.fromISO(maxDateStr);
|
|
389
|
+
const minDate = DateTime.fromISO(minDateStr);
|
|
390
|
+
|
|
384
391
|
text.value.months.forEach((item, index) => {
|
|
392
|
+
const monthIndex = index + 1;
|
|
393
|
+
|
|
394
|
+
const isMaxMonth = activeDate.value.year === maxDate.year && monthIndex > maxDate.month;
|
|
395
|
+
const isMinMonth = activeDate.value.year === minDate.year && monthIndex < minDate.month;
|
|
396
|
+
const isDisable = isMaxMonth || isMinMonth;
|
|
397
|
+
|
|
385
398
|
options.push({
|
|
386
399
|
text: item,
|
|
387
|
-
value:
|
|
400
|
+
value: monthIndex,
|
|
401
|
+
disable: isDisable,
|
|
388
402
|
});
|
|
389
403
|
});
|
|
390
404
|
|
|
@@ -394,14 +408,22 @@ const monthsOption = computed(() => {
|
|
|
394
408
|
const yearOption = computed(() => {
|
|
395
409
|
let options: TSelectOption[] = [];
|
|
396
410
|
|
|
411
|
+
const maxDateStr = props?.max || '';
|
|
412
|
+
const minDateStr = props?.min || '';
|
|
413
|
+
const maxDate = DateTime.fromISO(maxDateStr);
|
|
414
|
+
const minDate = DateTime.fromISO(minDateStr);
|
|
415
|
+
|
|
397
416
|
const range = 10;
|
|
398
|
-
const minYear =
|
|
399
|
-
const maxYear =
|
|
417
|
+
const minYear = defaultDate.year - range;
|
|
418
|
+
const maxYear = defaultDate.year + range;
|
|
400
419
|
|
|
401
420
|
for(let i = minYear; i < maxYear; i++) {
|
|
421
|
+
const isDisable = i > maxDate.year || i < minDate.year;
|
|
422
|
+
|
|
402
423
|
options.push({
|
|
403
424
|
text: String(i),
|
|
404
425
|
value: i,
|
|
426
|
+
disable: isDisable,
|
|
405
427
|
})
|
|
406
428
|
}
|
|
407
429
|
|
|
@@ -439,6 +461,10 @@ const minuteOptions = computed(() => {
|
|
|
439
461
|
});
|
|
440
462
|
|
|
441
463
|
watch(() => isOpenPicker.value, (newValue) => {
|
|
464
|
+
if (isEmptyDate.value) {
|
|
465
|
+
isDisableDate.value = true;
|
|
466
|
+
}
|
|
467
|
+
|
|
442
468
|
emit('update:isOpen', newValue);
|
|
443
469
|
})
|
|
444
470
|
|
|
@@ -474,6 +500,24 @@ function handlePicker(positionInfo?: any) {
|
|
|
474
500
|
setIsOpen(false);
|
|
475
501
|
}
|
|
476
502
|
|
|
503
|
+
function initDate(date?: string) {
|
|
504
|
+
const currentDate = DateTime.fromISO(date || '');
|
|
505
|
+
|
|
506
|
+
activeDate.value = currentDate.isValid ? currentDate : defaultDate;
|
|
507
|
+
|
|
508
|
+
const currentDateISO = activeDate.value.toISO();
|
|
509
|
+
|
|
510
|
+
oldDateISO.value = currentDateISO;
|
|
511
|
+
|
|
512
|
+
activeMonth.value = activeDate.value.month;
|
|
513
|
+
activeYear.value = activeDate.value.year;
|
|
514
|
+
|
|
515
|
+
fillMonthDays(currentDateISO);
|
|
516
|
+
|
|
517
|
+
setTime('hour', activeDate.value.toFormat('HH'));
|
|
518
|
+
setTime('minute', activeDate.value.toFormat('mm'));
|
|
519
|
+
}
|
|
520
|
+
|
|
477
521
|
function handleClickPicker(evt: MouseEvent) {
|
|
478
522
|
const target = (evt.target as HTMLElement);
|
|
479
523
|
const classesArr = [
|
|
@@ -596,8 +640,10 @@ function setTime(name: 'hour' | 'minute', value: string) {
|
|
|
596
640
|
|
|
597
641
|
const format = name === 'hour' ? 'HH' : 'mm';
|
|
598
642
|
|
|
599
|
-
const
|
|
600
|
-
const
|
|
643
|
+
const maxDateStr = props?.max || '';
|
|
644
|
+
const minDateStr = props?.min || '';
|
|
645
|
+
const maxDate = DateTime.fromISO(maxDateStr);
|
|
646
|
+
const minDate = DateTime.fromISO(minDateStr);
|
|
601
647
|
|
|
602
648
|
// max Day
|
|
603
649
|
const isMismatchMaxDay = maxDate.isValid && (maxDate.day === activeDate.value.day && maxDate.month === activeDate.value.month && maxDate.year === activeDate.value.year);
|
|
@@ -625,9 +671,10 @@ function getTimeStr(value: number | string) {
|
|
|
625
671
|
}
|
|
626
672
|
|
|
627
673
|
function isDisableTime(name: 'hour' | 'minute', value: number) {
|
|
628
|
-
const
|
|
629
|
-
const
|
|
630
|
-
|
|
674
|
+
const maxDateStr = props?.max || '';
|
|
675
|
+
const minDateStr = props?.min || '';
|
|
676
|
+
const maxDate = DateTime.fromISO(maxDateStr);
|
|
677
|
+
const minDate = DateTime.fromISO(minDateStr);
|
|
631
678
|
|
|
632
679
|
// max Day
|
|
633
680
|
const isMismatchMaxDay = maxDate.day !== activeDate.value.day || maxDate.month !== activeDate.value.month || maxDate.year !== activeDate.value.year;
|
|
@@ -665,6 +712,8 @@ function setOldDate(value: boolean) {
|
|
|
665
712
|
if (value) {
|
|
666
713
|
oldDateISO.value = activeDate.value.toISO()
|
|
667
714
|
} else {
|
|
715
|
+
if (isEmptyDate.value && !isDisableDate.value) return;
|
|
716
|
+
|
|
668
717
|
activeDate.value = DateTime.fromISO(oldDateISO.value);
|
|
669
718
|
activeMonth.value = activeDate.value.month;
|
|
670
719
|
activeYear.value = activeDate.value.year;
|
|
@@ -675,12 +724,23 @@ function setOldDate(value: boolean) {
|
|
|
675
724
|
}
|
|
676
725
|
|
|
677
726
|
function setDate() {
|
|
727
|
+
isDisableDate.value = false;
|
|
728
|
+
isEmptyDate.value = false;
|
|
729
|
+
|
|
678
730
|
setTime('hour', activeDate.value.toFormat('HH'));
|
|
679
731
|
setTime('minute', activeDate.value.toFormat('mm'));
|
|
680
732
|
|
|
681
733
|
dispatchEmit();
|
|
682
734
|
}
|
|
683
735
|
|
|
736
|
+
function cancelDate() {
|
|
737
|
+
if (isEmptyDate.value) {
|
|
738
|
+
isDisableDate.value = false;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
setIsOpen(false);
|
|
742
|
+
}
|
|
743
|
+
|
|
684
744
|
function dispatchEmit() {
|
|
685
745
|
const currentDateISO = activeDate.value.toISO();
|
|
686
746
|
setIsOpen(false);
|
|
@@ -693,6 +753,7 @@ function dispatchEmit() {
|
|
|
693
753
|
function setActiveDay(ISO: string) {
|
|
694
754
|
if (isDisableDay(ISO)) return;
|
|
695
755
|
|
|
756
|
+
isDisableDate.value = false;
|
|
696
757
|
const currentDate = DateTime.fromISO(ISO);
|
|
697
758
|
|
|
698
759
|
const currentActiveDate = DateTime.fromISO(activeDate.value.toISO()).set({
|
|
@@ -725,11 +786,15 @@ function setSelect(dateName: 'month' | 'year', value: number) {
|
|
|
725
786
|
activeDate.value = DateTime.fromISO(currentISO).set({ month: activeMonth.value, year: activeYear.value });
|
|
726
787
|
const currentDate = activeDate.value.toISO();
|
|
727
788
|
|
|
789
|
+
isDisableDate.value = isDisableDay(currentDate)
|
|
790
|
+
|
|
728
791
|
monthDays.value = [];
|
|
729
792
|
fillMonthDays(currentDate);
|
|
730
793
|
}
|
|
731
794
|
|
|
732
795
|
function isActiveDay(ISO: string): boolean {
|
|
796
|
+
if (isDisableDate.value) return false;
|
|
797
|
+
|
|
733
798
|
const currentDate = DateTime.fromISO(ISO);
|
|
734
799
|
|
|
735
800
|
return activeDate.value.year === currentDate.year && activeDate.value.month === currentDate.month && activeDate.value.day === currentDate.day
|
|
@@ -751,8 +816,38 @@ $timeWidth: 54px;
|
|
|
751
816
|
|
|
752
817
|
gap: 15px;
|
|
753
818
|
|
|
819
|
+
// prop.color
|
|
820
|
+
&.green2 {
|
|
821
|
+
.c-input {
|
|
822
|
+
border-color: var(--green-dark);
|
|
823
|
+
|
|
824
|
+
background: var(--green-low);
|
|
825
|
+
color: var(--white);
|
|
826
|
+
|
|
827
|
+
&::placeholder {
|
|
828
|
+
color: var(--green-medium);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
.c-datepicker__time_wrap {
|
|
833
|
+
border-color: var(--green-dark);
|
|
834
|
+
|
|
835
|
+
background: var(--green-low);
|
|
836
|
+
|
|
837
|
+
span,
|
|
838
|
+
input {
|
|
839
|
+
color: var(--green-medium);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
// ./prop.color
|
|
844
|
+
|
|
754
845
|
&__inp {
|
|
755
846
|
|
|
847
|
+
&.empty-date .c-input::placeholder {
|
|
848
|
+
color: var(--green-medium);
|
|
849
|
+
}
|
|
850
|
+
|
|
756
851
|
.c-input {
|
|
757
852
|
padding: 7px 10px;
|
|
758
853
|
}
|
|
@@ -857,6 +952,14 @@ $timeWidth: 54px;
|
|
|
857
952
|
&:hover {
|
|
858
953
|
border: 1px solid var(--green-light);
|
|
859
954
|
}
|
|
955
|
+
|
|
956
|
+
&.empty-date {
|
|
957
|
+
pointer-events: none;
|
|
958
|
+
|
|
959
|
+
.c-datepicker__time_inps {
|
|
960
|
+
color: var(--green-medium);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
860
963
|
}
|
|
861
964
|
}
|
|
862
965
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
ref="root"
|
|
4
4
|
:data-c-input2-select-id="CInput2SelectId"
|
|
5
5
|
:style="`--transition: ${transition}ms; --width: ${width}; --list-indent-y: ${listIndentY}px`"
|
|
6
|
-
:class="[classes.root, variant, size, { disabled, open: isOpen }]"
|
|
6
|
+
:class="[classes.root, variant, color, size, { disabled, open: isOpen }]"
|
|
7
7
|
>
|
|
8
8
|
<CInput
|
|
9
9
|
:placeholder="activePlaceholder"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
:width="width"
|
|
13
13
|
:iconPosition="iconInfo.position.value"
|
|
14
14
|
v-model.trim="findValue"
|
|
15
|
-
:class="[classes.input, {open: isOpen}]"
|
|
15
|
+
:class="[classes.input, {open: isOpen}, { 'have-value': activeOptions.size > 0 }]"
|
|
16
16
|
>
|
|
17
17
|
<template #customIcon>
|
|
18
18
|
<div class="c-input2-select__inp_icon-content">
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<CIcon
|
|
26
26
|
:class="['c-input2-select__inp_icon', 'c-input2-select__inp_icon-clear', { visible: activeOptions.size > 0 }]"
|
|
27
27
|
:size="24"
|
|
28
|
-
:name="
|
|
28
|
+
:name="iconInfo.clearable.value"
|
|
29
29
|
|
|
30
30
|
@click.stop="clear"
|
|
31
31
|
/>
|
|
@@ -114,11 +114,13 @@ type TProps = {
|
|
|
114
114
|
options?: TOption[],
|
|
115
115
|
variant?: 'default' | 'multiple',
|
|
116
116
|
size?: 'lg' | 'md' | 'sm',
|
|
117
|
+
color?: 'green' | 'green2',
|
|
117
118
|
selectAll?: boolean,
|
|
118
119
|
autocomplete?: boolean,
|
|
119
120
|
disabled?: boolean,
|
|
120
121
|
transformVal?: boolean,
|
|
121
122
|
iconPosition?: Array<'left' | 'right'>,
|
|
123
|
+
clearable?: keyof TIcon,
|
|
122
124
|
iconName?: keyof TIcon,
|
|
123
125
|
isOpen?: boolean,
|
|
124
126
|
locale?: 'rus' | 'usa' | 'tur' | 'spa',
|
|
@@ -131,6 +133,7 @@ const props = withDefaults(defineProps<TProps>(), {
|
|
|
131
133
|
options: () => [],
|
|
132
134
|
variant: 'default',
|
|
133
135
|
size: 'lg',
|
|
136
|
+
color: 'green',
|
|
134
137
|
selectAll: false,
|
|
135
138
|
autocomplete: false,
|
|
136
139
|
disabled: false,
|
|
@@ -227,7 +230,16 @@ const iconInfo = {
|
|
|
227
230
|
const defaultIcon = {'Dropdown': true}
|
|
228
231
|
|
|
229
232
|
return props.iconName ? propIcon : defaultIcon;
|
|
230
|
-
})
|
|
233
|
+
}),
|
|
234
|
+
|
|
235
|
+
clearable: computed(() => {
|
|
236
|
+
const strIconName = String(props?.clearable)
|
|
237
|
+
const propIcon = {[strIconName]: true}
|
|
238
|
+
|
|
239
|
+
const defaultIcon = {'Cross': true}
|
|
240
|
+
|
|
241
|
+
return props.clearable ? propIcon : defaultIcon;
|
|
242
|
+
}),
|
|
231
243
|
}
|
|
232
244
|
|
|
233
245
|
const foundOptions = computed(() => {
|
|
@@ -646,6 +658,21 @@ defineExpose({
|
|
|
646
658
|
}
|
|
647
659
|
// ./prop.size
|
|
648
660
|
|
|
661
|
+
// prop.color
|
|
662
|
+
&.green2 {
|
|
663
|
+
.c-input {
|
|
664
|
+
border-color: var(--green-dark);
|
|
665
|
+
|
|
666
|
+
background: var(--green-low);
|
|
667
|
+
color: var(--white);
|
|
668
|
+
|
|
669
|
+
&::placeholder {
|
|
670
|
+
color: var(--green-medium);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
// ./prop.color
|
|
675
|
+
|
|
649
676
|
// prop.disabled
|
|
650
677
|
&.disabled {
|
|
651
678
|
opacity: 0.6;
|
|
@@ -673,6 +700,10 @@ defineExpose({
|
|
|
673
700
|
|
|
674
701
|
order: -1;
|
|
675
702
|
}
|
|
703
|
+
|
|
704
|
+
&.have-value .c-input::placeholder {
|
|
705
|
+
color: var(--white);
|
|
706
|
+
}
|
|
676
707
|
}
|
|
677
708
|
|
|
678
709
|
&_count {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
v-for="item in foundOptions"
|
|
52
52
|
:key="item.value"
|
|
53
53
|
@click="debounceEvent(item, $event)"
|
|
54
|
-
:class="classes.optionBtn"
|
|
54
|
+
:class="[classes.optionBtn, { disable: item.disable }]"
|
|
55
55
|
>
|
|
56
56
|
<component
|
|
57
57
|
:class="classes.option"
|
|
@@ -91,6 +91,7 @@ type TOption = {
|
|
|
91
91
|
text?: string,
|
|
92
92
|
value?: any,
|
|
93
93
|
id?: any,
|
|
94
|
+
disable?: boolean,
|
|
94
95
|
[key: string]: any,
|
|
95
96
|
}
|
|
96
97
|
|
|
@@ -317,14 +318,15 @@ function getCheckboxProp(option: TOption) {
|
|
|
317
318
|
if (!isMultiple.value) return {}
|
|
318
319
|
return {
|
|
319
320
|
size: 'sm',
|
|
320
|
-
modelValue: isChecked,
|
|
321
|
+
modelValue: !option.disable && isChecked,
|
|
322
|
+
disable: option.disable,
|
|
321
323
|
}
|
|
322
324
|
}
|
|
323
325
|
|
|
324
326
|
function setAllOption(evt: MouseEvent) {
|
|
325
327
|
const target = (evt.target as HTMLElement);
|
|
326
328
|
const list = target.closest(`.${classes.list}`);
|
|
327
|
-
const inputs = (list!.querySelectorAll<HTMLInputElement>(`.${classes.optionBtn} input`));
|
|
329
|
+
const inputs = (list!.querySelectorAll<HTMLInputElement>(`.${classes.optionBtn}:not(.disable) input`));
|
|
328
330
|
const inputsChecked = list!.querySelectorAll(`.${classes.optionBtn}:not(:first-child) input:checked`);
|
|
329
331
|
const selectAllInput = inputs[0];
|
|
330
332
|
|
|
@@ -337,7 +339,8 @@ function setAllOption(evt: MouseEvent) {
|
|
|
337
339
|
});
|
|
338
340
|
|
|
339
341
|
props.options.forEach((option) => {
|
|
340
|
-
|
|
342
|
+
const isAdd = selectAllInput.checked && !option.disable;
|
|
343
|
+
activeOptions.value[isAdd ? 'add' : 'delete'](option);
|
|
341
344
|
});
|
|
342
345
|
} else {
|
|
343
346
|
selectAllInput.checked = isOneNotChecked;
|
|
@@ -550,6 +553,11 @@ defineExpose({
|
|
|
550
553
|
background: var(--green-dark);
|
|
551
554
|
}
|
|
552
555
|
|
|
556
|
+
&.disable {
|
|
557
|
+
opacity: 0.5;
|
|
558
|
+
pointer-events: none;
|
|
559
|
+
}
|
|
560
|
+
|
|
553
561
|
.c-checkbox__wrap {
|
|
554
562
|
min-height: var(--option-height);
|
|
555
563
|
|
package/src/pages/index.vue
CHANGED
|
@@ -830,7 +830,7 @@
|
|
|
830
830
|
<!-- col -->
|
|
831
831
|
<div class="table__col checkboxes">
|
|
832
832
|
<div class="table__item">
|
|
833
|
-
<CDatepicker date="2026-02-06T00:00:00.000+03:00" @change_cdatepicker="(e) => console.log(e)" />
|
|
833
|
+
<CDatepicker date="2026-02-06T00:00:00.000+03:00" color="green2" @change_cdatepicker="(e) => console.log(e)" />
|
|
834
834
|
</div>
|
|
835
835
|
<div class="table__item">
|
|
836
836
|
<CDatepicker date="2026-02-06T23:59:59.999+03:00" @change_cdatepicker="(e) => console.log(e)" />
|
|
@@ -843,11 +843,14 @@
|
|
|
843
843
|
<div class="table__item" style="display: flex; flex-direction: column;">
|
|
844
844
|
<CDatepicker
|
|
845
845
|
date="2025-10-10T00:00:00.000+03:00"
|
|
846
|
-
max="
|
|
847
|
-
min="
|
|
846
|
+
max="2026-10-10T04:04:00.000+03:00"
|
|
847
|
+
min="2024-02-07T01:01:00.000+03:00"
|
|
848
848
|
@change_cdatepicker="(e) => console.log(e)"
|
|
849
849
|
/>
|
|
850
850
|
</div>
|
|
851
|
+
<div class="table__item">
|
|
852
|
+
<CDatepicker :empty-date="true" @change_cdatepicker="(e) => console.log(e)" />
|
|
853
|
+
</div>
|
|
851
854
|
</div>
|
|
852
855
|
<!-- ./col -->
|
|
853
856
|
</div>
|
|
@@ -1144,6 +1147,7 @@
|
|
|
1144
1147
|
<CInput2Select
|
|
1145
1148
|
:options="optionGroup"
|
|
1146
1149
|
v-model="VModelOption3"
|
|
1150
|
+
color="green2"
|
|
1147
1151
|
:autocomplete="true"
|
|
1148
1152
|
@change_cinput2select="(evt) => log(['CInput2Select default', evt])"
|
|
1149
1153
|
/>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import CAlert from '../components/CAlert.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/CAlert',
|
|
5
|
+
component: CAlert,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
argTypes: {
|
|
8
|
+
variant: {
|
|
9
|
+
control: 'select',
|
|
10
|
+
options: ['notification', 'success', 'error'],
|
|
11
|
+
},
|
|
12
|
+
liveTime: { control: 'number' },
|
|
13
|
+
width: { control: 'text' },
|
|
14
|
+
text: { control: 'text' },
|
|
15
|
+
default: {
|
|
16
|
+
control: 'text',
|
|
17
|
+
description: 'Slot content',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
args: {
|
|
21
|
+
variant: 'notification',
|
|
22
|
+
liveTime: 10000,
|
|
23
|
+
width: 'auto',
|
|
24
|
+
default: 'Время ожидания сервером истекло. Повторите попытку позже или обратитесь к администратору',
|
|
25
|
+
},
|
|
26
|
+
render: (args) => ({
|
|
27
|
+
components: { CAlert },
|
|
28
|
+
setup() { return { args }; },
|
|
29
|
+
template: `<CAlert v-bind="args">{{ args.default }}</CAlert>`,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const Notification = {};
|
|
34
|
+
|
|
35
|
+
export const Success = {
|
|
36
|
+
args: {
|
|
37
|
+
variant: 'success',
|
|
38
|
+
default: 'Очередь успешно отправлена',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const Error = {
|
|
43
|
+
args: {
|
|
44
|
+
variant: 'error',
|
|
45
|
+
default: 'Ошибка соединения. Обратитесь к администратору',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const AllVariants = {
|
|
50
|
+
render: () => ({
|
|
51
|
+
components: { CAlert },
|
|
52
|
+
template: `
|
|
53
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
54
|
+
<CAlert variant="notification">
|
|
55
|
+
Время ожидания сервером истекло. Повторите попытку позже
|
|
56
|
+
</CAlert>
|
|
57
|
+
<CAlert variant="success">
|
|
58
|
+
Очередь успешно отправлена
|
|
59
|
+
</CAlert>
|
|
60
|
+
<CAlert variant="error">
|
|
61
|
+
Ошибка соединения. Обратитесь к администратору
|
|
62
|
+
</CAlert>
|
|
63
|
+
</div>
|
|
64
|
+
`,
|
|
65
|
+
}),
|
|
66
|
+
};
|