design-system-next 2.7.11 → 2.7.14
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 +617 -590
- 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/date-picker/date-picker.ts +1 -0
- package/src/components/date-picker/date-picker.vue +3 -0
- package/src/components/filter/filter.vue +1 -0
- package/src/components/sidepanel/sidepanel.vue +18 -31
- package/src/components/sidepanel/use-sidepanel.ts +66 -22
- package/src/components/switch/switch.vue +3 -3
- package/src/components/switch/use-switch.ts +6 -1
- package/src/components/textarea/textarea.vue +2 -1
- package/src/components/time-picker/time-picker.ts +4 -0
- package/src/components/time-picker/time-picker.vue +1 -0
- package/src/vite-env.d.ts +6 -0
|
@@ -1,35 +1,81 @@
|
|
|
1
|
-
import { ref, computed,
|
|
1
|
+
import { ref, toRefs, computed, ComputedRef, watch, onMounted, onUnmounted } from 'vue';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import type { SetupContext } from 'vue';
|
|
6
6
|
import type { SidepanelPropTypes, SidepanelEmitTypes } from './sidepanel';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
interface SidepanelClasses {
|
|
9
|
+
sidepanelBaseClasses: string;
|
|
10
|
+
sidepanelHeaderClasses: string;
|
|
11
|
+
sidepanelHeaderTitleClasses: string;
|
|
12
|
+
sidepanelHeaderIconClasses: string;
|
|
13
|
+
sidepanelContentClasses: string;
|
|
14
|
+
sidepanelFooterClasses: string;
|
|
15
|
+
sidepanelTransitionActiveClasses: string;
|
|
16
|
+
sidepanelTransitionHiddenClasses: string;
|
|
17
|
+
sidepanelTransitionVisibleClasses: string;
|
|
18
|
+
backdropBaseClasses: string;
|
|
19
|
+
}
|
|
10
20
|
|
|
21
|
+
export const useSidepanel = (props: SidepanelPropTypes, emit: SetupContext<SidepanelEmitTypes>['emit']) => {
|
|
11
22
|
const { size, position } = toRefs(props);
|
|
12
23
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
'spr-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const sidepanelClasses: ComputedRef<SidepanelClasses> = computed(() => {
|
|
25
|
+
const sidepanelBaseClasses = classNames(
|
|
26
|
+
'spr-fixed spr-right-4 spr-top-1/2 spr-z-[1015] spr-flex spr-h-full spr-min-h-[200px] spr-translate-y-[-50%] spr-flex-col spr-rounded-border-radius-xl spr-bg-white-50 spr-drop-shadow',
|
|
27
|
+
{
|
|
28
|
+
'spr-w-[360px] sm:spr-w-[calc(100%-35px)]': size.value === 'sm',
|
|
29
|
+
'spr-w-[420px] sm:spr-w-[calc(100%-35px)]': size.value === 'md',
|
|
30
|
+
'spr-w-[480px] sm:spr-w-[calc(100%-35px)]': size.value === 'lg',
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const sidepanelHeaderClasses = classNames(
|
|
35
|
+
'spr-tw-min-h-12 spr-text-color-strong spr-flex spr-justify-between spr-border-0 spr-border-b spr-border-solid spr-border-mushroom-200 spr-p-4',
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const sidepanelHeaderTitleClasses = classNames('spr-subheading-xs');
|
|
39
|
+
|
|
40
|
+
const sidepanelHeaderIconClasses = classNames('spr-text-color-weak spr-h-5 spr-w-5 spr-cursor-pointer');
|
|
41
|
+
|
|
42
|
+
const sidepanelContentClasses = classNames('spr-h-full spr-overflow-y-auto');
|
|
20
43
|
|
|
21
|
-
|
|
22
|
-
|
|
44
|
+
const sidepanelFooterClasses = classNames(
|
|
45
|
+
'spr-bottom-0 spr-left-0 spr-w-full spr-rounded-b-border-radius-xl spr-border-0 spr-border-t spr-border-solid spr-border-mushroom-200 spr-bg-white-50 spr-py-3',
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const sidepanelTransitionActiveClasses = classNames(
|
|
49
|
+
'spr-transition-transform spr-duration-[150ms] spr-ease-[ease-in-out]',
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const sidepanelTransitionHiddenClasses = classNames({
|
|
23
53
|
'spr-translate-x-full -spr-translate-y-2/4': position.value === 'right',
|
|
24
54
|
});
|
|
25
|
-
});
|
|
26
55
|
|
|
27
|
-
|
|
28
|
-
return classNames({
|
|
56
|
+
const sidepanelTransitionVisibleClasses = classNames({
|
|
29
57
|
'spr-translate-x-0 -spr-translate-y-2/4': position.value === 'right',
|
|
30
58
|
});
|
|
59
|
+
const backdropBaseClasses = classNames(
|
|
60
|
+
'spr-fixed spr-left-0 spr-top-0 spr-z-[1010] spr-h-full spr-w-full spr-bg-mushroom-700/60',
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
sidepanelBaseClasses,
|
|
65
|
+
sidepanelHeaderClasses,
|
|
66
|
+
sidepanelHeaderTitleClasses,
|
|
67
|
+
sidepanelHeaderIconClasses,
|
|
68
|
+
sidepanelContentClasses,
|
|
69
|
+
sidepanelFooterClasses,
|
|
70
|
+
sidepanelTransitionActiveClasses,
|
|
71
|
+
sidepanelTransitionHiddenClasses,
|
|
72
|
+
sidepanelTransitionVisibleClasses,
|
|
73
|
+
backdropBaseClasses,
|
|
74
|
+
};
|
|
31
75
|
});
|
|
32
76
|
|
|
77
|
+
const sidepanelRef = ref<HTMLDivElement | null>(null);
|
|
78
|
+
|
|
33
79
|
const handleClose = () => {
|
|
34
80
|
emit('close');
|
|
35
81
|
};
|
|
@@ -45,7 +91,7 @@ export const useSidepanel = (props: SidepanelPropTypes, emit: SetupContext<Sidep
|
|
|
45
91
|
|
|
46
92
|
const handleEscapeClose = (event: KeyboardEvent) => {
|
|
47
93
|
if (event.key === 'Escape' && props.isOpen && props.escapeClose) {
|
|
48
|
-
emit('close')
|
|
94
|
+
emit('close');
|
|
49
95
|
}
|
|
50
96
|
};
|
|
51
97
|
|
|
@@ -74,10 +120,8 @@ export const useSidepanel = (props: SidepanelPropTypes, emit: SetupContext<Sidep
|
|
|
74
120
|
});
|
|
75
121
|
|
|
76
122
|
return {
|
|
123
|
+
sidepanelClasses,
|
|
77
124
|
sidepanelRef,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
handleClose
|
|
82
|
-
}
|
|
83
|
-
}
|
|
125
|
+
handleClose,
|
|
126
|
+
};
|
|
127
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-bind="switchProps" :class="['spr-flex spr-items-center spr-gap-2', switchTextClass]">
|
|
3
|
-
<label>
|
|
3
|
+
<label v-if="!isSlotEmpty">
|
|
4
4
|
<slot name="leftText">
|
|
5
5
|
<slot></slot>
|
|
6
6
|
</slot>
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
]"
|
|
31
31
|
></span>
|
|
32
32
|
</div>
|
|
33
|
-
<label>
|
|
33
|
+
<label v-if="!isSlotEmpty">
|
|
34
34
|
<slot name="rightText"></slot>
|
|
35
35
|
</label>
|
|
36
36
|
</div>
|
|
@@ -47,7 +47,7 @@ const emit = defineEmits(switchEmitTypes);
|
|
|
47
47
|
|
|
48
48
|
const proxyValue = useVModel(props, 'modelValue', emit);
|
|
49
49
|
|
|
50
|
-
const { switchWrapperRef, switchRef, switchProps, switchMarkClass, switchTextClass, switchInputClass } =
|
|
50
|
+
const { switchWrapperRef, switchRef, switchProps, switchMarkClass, switchTextClass, switchInputClass, isSlotEmpty } =
|
|
51
51
|
useSwitch(props);
|
|
52
52
|
</script>
|
|
53
53
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, ref, ComputedRef, toRefs } from 'vue';
|
|
1
|
+
import { computed, ref, ComputedRef, toRefs, useSlots } from 'vue';
|
|
2
2
|
import { useElementHover, useMousePressed } from '@vueuse/core';
|
|
3
3
|
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -12,6 +12,10 @@ export const useSwitch = (props: SwitchPropTypes) => {
|
|
|
12
12
|
const isHovered = useElementHover(switchWrapperRef);
|
|
13
13
|
const { pressed } = useMousePressed({ target: switchRef });
|
|
14
14
|
const { disabled, state, modelValue } = toRefs(props);
|
|
15
|
+
const slots = useSlots();
|
|
16
|
+
|
|
17
|
+
// if the slot label is empty, we will not show the label
|
|
18
|
+
const isSlotEmpty = (!slots.default || slots.default().length === 0) && !slots.leftText && !slots.rightText;
|
|
15
19
|
|
|
16
20
|
const switchProps: ComputedRef<Record<string, unknown>> = computed(() => {
|
|
17
21
|
return {
|
|
@@ -96,5 +100,6 @@ export const useSwitch = (props: SwitchPropTypes) => {
|
|
|
96
100
|
switchMarkClass,
|
|
97
101
|
switchTextClass,
|
|
98
102
|
switchInputClass,
|
|
103
|
+
isSlotEmpty
|
|
99
104
|
};
|
|
100
105
|
};
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
<div :class="textareaClasses.wrapperClasses">
|
|
3
3
|
<label v-if="label" :for="id" :class="textareaClasses.labelClasses">{{ label }}</label>
|
|
4
4
|
<textarea
|
|
5
|
-
:class="textareaClasses.textAreaClasses"
|
|
6
5
|
v-bind="$attrs"
|
|
6
|
+
:id="props.id"
|
|
7
|
+
:class="textareaClasses.textAreaClasses"
|
|
7
8
|
:rows="rows"
|
|
8
9
|
:placeholder="placeholder"
|
|
9
10
|
:value="modelValue"
|
|
@@ -55,6 +55,10 @@ export const timePickerPropTypes = {
|
|
|
55
55
|
type: String,
|
|
56
56
|
default: '',
|
|
57
57
|
},
|
|
58
|
+
id: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: 'time-picker',
|
|
61
|
+
},
|
|
58
62
|
};
|
|
59
63
|
export const timePickerEmitTypes = {
|
|
60
64
|
'update:modelValue': (evt: MouseEvent): evt is MouseEvent => evt instanceof MouseEvent,
|