design-system-next 1.2.8 → 1.2.10
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/design-system-next.js +939 -935
- package/dist/design-system-next.js.gz +0 -0
- package/dist/main.css +1 -1
- package/dist/main.css.gz +0 -0
- package/package.json +1 -1
- package/src/components/avatar/use-avatar.ts +30 -30
- package/src/components/badge/use-badge.ts +17 -21
- package/src/components/empty-state/use-empty-state.ts +7 -7
- package/src/components/input/use-input.ts +19 -19
- package/src/components/lozenge/use-lozenge.ts +22 -17
- package/src/components/modal/use-modal.ts +6 -6
- package/src/components/switch/use-switch.ts +5 -5
- package/src/components/timePicker/timePicker.vue +2 -3
- package/src/components/timePicker/use-timePicker.ts +21 -23
- package/src/components/tooltip/use-tooltip.ts +14 -29
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
'cursor-pointer',
|
|
39
39
|
{
|
|
40
40
|
'background-color-single-active rounded-border-radius-md':
|
|
41
|
-
option.toUpperCase() === selectedValue
|
|
41
|
+
option.toUpperCase() === selectedValue?.toUpperCase(),
|
|
42
42
|
},
|
|
43
43
|
]"
|
|
44
44
|
@mousedown.prevent="selectOption(option)"
|
|
45
45
|
>
|
|
46
46
|
{{ option }}
|
|
47
47
|
|
|
48
|
-
<span v-if="option.toUpperCase() === selectedValue
|
|
48
|
+
<span v-if="option.toUpperCase() === selectedValue?.toUpperCase()" class="text-color-brand-base font-bold">
|
|
49
49
|
<Icon icon="ph:check" />
|
|
50
50
|
</span>
|
|
51
51
|
</div>
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
|
|
58
58
|
<script setup lang="ts">
|
|
59
59
|
import { Icon } from '@iconify/vue';
|
|
60
|
-
|
|
61
60
|
import { timePickerPropTypes, timePickerEmitTypes } from './timePicker';
|
|
62
61
|
import { useTimePicker } from './use-timePicker';
|
|
63
62
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { computed, ref, ComputedRef } from 'vue';
|
|
1
|
+
import { computed, ref, ComputedRef, toRefs } from 'vue';
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import type { TimePickerPropTypes, TimePickerEmitTypes } from './timePicker';
|
|
4
4
|
import type { SetupContext } from 'vue';
|
|
5
|
+
import { useVModel } from '@vueuse/core';
|
|
5
6
|
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
|
|
8
9
|
export const useTimePicker = (props: TimePickerPropTypes, emit: SetupContext<TimePickerEmitTypes>['emit']) => {
|
|
9
|
-
const { error, disabled, format, interval, disableTyping, fullWidth } = props;
|
|
10
|
+
const { error, disabled, format, interval, disableTyping, fullWidth } = toRefs(props);
|
|
10
11
|
|
|
11
12
|
const isOpen = ref<boolean>(false);
|
|
12
|
-
const selectedValue =
|
|
13
|
+
const selectedValue = useVModel(props, 'modelValue', emit);
|
|
13
14
|
|
|
14
15
|
const timepickerClasses: ComputedRef<string> = computed(() => {
|
|
15
16
|
return classNames(
|
|
@@ -28,14 +29,14 @@ export const useTimePicker = (props: TimePickerPropTypes, emit: SetupContext<Tim
|
|
|
28
29
|
'outline-none',
|
|
29
30
|
'ring-0',
|
|
30
31
|
{
|
|
31
|
-
'!border-[1.5px]': error,
|
|
32
|
-
'!border-tomato-600': error,
|
|
33
|
-
'focus:!border-tomato-600': error,
|
|
34
|
-
'!border-white-100': disabled,
|
|
35
|
-
'background-color-disabled': disabled,
|
|
36
|
-
'cursor-not-allowed': disabled,
|
|
37
|
-
'text-color-on-fill-disabled': disabled,
|
|
38
|
-
'cursor-pointer': disableTyping,
|
|
32
|
+
'!border-[1.5px]': error.value,
|
|
33
|
+
'!border-tomato-600': error.value,
|
|
34
|
+
'focus:!border-tomato-600': error.value,
|
|
35
|
+
'!border-white-100': disabled.value,
|
|
36
|
+
'background-color-disabled': disabled.value,
|
|
37
|
+
'cursor-not-allowed': disabled.value,
|
|
38
|
+
'text-color-on-fill-disabled': disabled.value,
|
|
39
|
+
'cursor-pointer': disableTyping.value,
|
|
39
40
|
},
|
|
40
41
|
);
|
|
41
42
|
});
|
|
@@ -43,7 +44,7 @@ export const useTimePicker = (props: TimePickerPropTypes, emit: SetupContext<Tim
|
|
|
43
44
|
const optionClasses: ComputedRef<string> = computed(() => {
|
|
44
45
|
return classNames(
|
|
45
46
|
'absolute',
|
|
46
|
-
'z-
|
|
47
|
+
'z-50 ',
|
|
47
48
|
'mt-1',
|
|
48
49
|
'max-h-[300px]',
|
|
49
50
|
'w-[240px]',
|
|
@@ -56,20 +57,20 @@ export const useTimePicker = (props: TimePickerPropTypes, emit: SetupContext<Tim
|
|
|
56
57
|
'shadow-[0_2px_8px_-2px_rgba(38, 43, 43, 0.20)]',
|
|
57
58
|
'p-size-spacing-3xs',
|
|
58
59
|
{
|
|
59
|
-
'w-full': fullWidth,
|
|
60
|
+
'w-full': fullWidth.value,
|
|
60
61
|
},
|
|
61
62
|
);
|
|
62
63
|
});
|
|
63
64
|
|
|
64
65
|
const iconClasses: ComputedRef<string> = computed(() => {
|
|
65
66
|
return classNames('absolute right-3 text-color-supporting', {
|
|
66
|
-
'!text-tomato-600': error,
|
|
67
|
+
'!text-tomato-600': error.value,
|
|
67
68
|
});
|
|
68
69
|
});
|
|
69
70
|
|
|
70
71
|
const labelClasses: ComputedRef<string> = computed(() => {
|
|
71
72
|
return classNames('body-sm-regular text-color-strong block mb-size-spacing-4xs ', {
|
|
72
|
-
'text-color-on-fill-disabled': disabled,
|
|
73
|
+
'text-color-on-fill-disabled': disabled.value,
|
|
73
74
|
});
|
|
74
75
|
});
|
|
75
76
|
|
|
@@ -83,15 +84,13 @@ export const useTimePicker = (props: TimePickerPropTypes, emit: SetupContext<Tim
|
|
|
83
84
|
if (!target) return;
|
|
84
85
|
|
|
85
86
|
const input = target.value.toUpperCase();
|
|
86
|
-
const regex = format === '12' ? /^[0-9:APM\s]*$/ : /^[0-9:]*$/;
|
|
87
|
+
const regex = format.value === '12' ? /^[0-9:APM\s]*$/ : /^[0-9:]*$/;
|
|
87
88
|
|
|
88
89
|
if (!regex.test(input)) {
|
|
89
|
-
selectedValue.value = selectedValue.value
|
|
90
|
+
selectedValue.value = selectedValue.value?.slice(0, -1);
|
|
90
91
|
} else {
|
|
91
92
|
selectedValue.value = input;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
-
emit('update:modelValue', selectedValue.value);
|
|
95
94
|
};
|
|
96
95
|
|
|
97
96
|
const generateTimeOptions = (): string[] => {
|
|
@@ -102,7 +101,7 @@ export const useTimePicker = (props: TimePickerPropTypes, emit: SetupContext<Tim
|
|
|
102
101
|
let current = start;
|
|
103
102
|
while (current.isBefore(end) || current.isSame(end)) {
|
|
104
103
|
options.push(formatTime(current));
|
|
105
|
-
current = current.add(interval, 'minute');
|
|
104
|
+
current = current.add(interval.value, 'minute');
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
return options;
|
|
@@ -127,12 +126,11 @@ export const useTimePicker = (props: TimePickerPropTypes, emit: SetupContext<Tim
|
|
|
127
126
|
|
|
128
127
|
const selectOption = (option: string) => {
|
|
129
128
|
selectedValue.value = option;
|
|
130
|
-
emit('update:modelValue', option);
|
|
131
129
|
isOpen.value = false;
|
|
132
130
|
};
|
|
133
131
|
|
|
134
132
|
const handleClick = (event: FocusEvent) => {
|
|
135
|
-
if (disabled) {
|
|
133
|
+
if (disabled.value) {
|
|
136
134
|
event.preventDefault();
|
|
137
135
|
return;
|
|
138
136
|
}
|
|
@@ -140,7 +138,7 @@ export const useTimePicker = (props: TimePickerPropTypes, emit: SetupContext<Tim
|
|
|
140
138
|
};
|
|
141
139
|
|
|
142
140
|
const getPlaceHolder: ComputedRef<string> = computed(() => {
|
|
143
|
-
return format === '12' ? 'HH : MM AM/PM' : 'HH : MM';
|
|
141
|
+
return format.value === '12' ? 'HH : MM AM/PM' : 'HH : MM';
|
|
144
142
|
});
|
|
145
143
|
|
|
146
144
|
return {
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import { computed, ref } from 'vue';
|
|
1
|
+
import { computed, ref, toRefs } from 'vue';
|
|
2
2
|
import { useElementHover } from '@vueuse/core';
|
|
3
3
|
import { TooltipPropTypes } from './tooltip';
|
|
4
4
|
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
|
|
7
7
|
export const useTooltip = (props: TooltipPropTypes) => {
|
|
8
|
-
const { position, text } = props
|
|
9
|
-
text: string;
|
|
10
|
-
position:
|
|
11
|
-
| 'top'
|
|
12
|
-
| 'top-start'
|
|
13
|
-
| 'top-end'
|
|
14
|
-
| 'bottom'
|
|
15
|
-
| 'bottom-start'
|
|
16
|
-
| 'bottom-end'
|
|
17
|
-
| 'left'
|
|
18
|
-
| 'left-start'
|
|
19
|
-
| 'left-end'
|
|
20
|
-
| 'right'
|
|
21
|
-
| 'right-start'
|
|
22
|
-
| 'right-end';
|
|
23
|
-
};
|
|
8
|
+
const { position, text } = toRefs(props);
|
|
24
9
|
|
|
25
10
|
const componentRef = ref<HTMLDivElement | null>(null);
|
|
26
11
|
const isHovered = useElementHover(componentRef);
|
|
@@ -29,18 +14,18 @@ export const useTooltip = (props: TooltipPropTypes) => {
|
|
|
29
14
|
// Tooltip Gap: 6px
|
|
30
15
|
return classNames({
|
|
31
16
|
hidden: !isHovered.value,
|
|
32
|
-
'bottom-[calc(100%+6px)] left-[50%] translate-x-[-50%]': position === 'top',
|
|
33
|
-
'bottom-[calc(100%+6px)] left-0': position === 'top-start',
|
|
34
|
-
'bottom-[calc(100%+6px)] right-0': position === 'top-end',
|
|
35
|
-
'top-[calc(100%+6px)] left-[50%] translate-x-[-50%]': position === 'bottom',
|
|
36
|
-
'top-[calc(100%+6px)] left-0': position === 'bottom-start',
|
|
37
|
-
'top-[calc(100%+6px)] right-0': position === 'bottom-end',
|
|
38
|
-
'left-[calc(100%+6px)] top-[50%] translate-y-[-50%]': position === 'right',
|
|
39
|
-
'left-[calc(100%+6px)] top-0': position === 'right-start',
|
|
40
|
-
'left-[calc(100%+6px)] bottom-0': position === 'right-end',
|
|
41
|
-
'right-[calc(100%+6px)] top-[50%] translate-y-[-50%]': position === 'left',
|
|
42
|
-
'right-[calc(100%+6px)] top-0': position === 'left-start',
|
|
43
|
-
'right-[calc(100%+6px)] bottom-0': position === 'left-end',
|
|
17
|
+
'bottom-[calc(100%+6px)] left-[50%] translate-x-[-50%]': position.value === 'top',
|
|
18
|
+
'bottom-[calc(100%+6px)] left-0': position.value === 'top-start',
|
|
19
|
+
'bottom-[calc(100%+6px)] right-0': position.value === 'top-end',
|
|
20
|
+
'top-[calc(100%+6px)] left-[50%] translate-x-[-50%]': position.value === 'bottom',
|
|
21
|
+
'top-[calc(100%+6px)] left-0': position.value === 'bottom-start',
|
|
22
|
+
'top-[calc(100%+6px)] right-0': position.value === 'bottom-end',
|
|
23
|
+
'left-[calc(100%+6px)] top-[50%] translate-y-[-50%]': position.value === 'right',
|
|
24
|
+
'left-[calc(100%+6px)] top-0': position.value === 'right-start',
|
|
25
|
+
'left-[calc(100%+6px)] bottom-0': position.value === 'right-end',
|
|
26
|
+
'right-[calc(100%+6px)] top-[50%] translate-y-[-50%]': position.value === 'left',
|
|
27
|
+
'right-[calc(100%+6px)] top-0': position.value === 'left-start',
|
|
28
|
+
'right-[calc(100%+6px)] bottom-0': position.value === 'left-end',
|
|
44
29
|
});
|
|
45
30
|
});
|
|
46
31
|
|