design-system-next 2.7.12 → 2.7.15
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 +1017 -983
- 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/sidepanel/sidepanel.vue +18 -31
- package/src/components/sidepanel/use-sidepanel.ts +66 -22
- package/src/components/switch/switch.ts +7 -0
- package/src/components/switch/switch.vue +6 -3
- package/src/components/switch/use-switch.ts +8 -1
- package/src/vite-env.d.ts +6 -0
|
@@ -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="!isLeftTextLabel" :for="defaultId" class="spr-cursor-pointer">
|
|
4
4
|
<slot name="leftText">
|
|
5
5
|
<slot></slot>
|
|
6
6
|
</slot>
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
ref="switchRef"
|
|
17
17
|
v-model="proxyValue"
|
|
18
18
|
type="checkbox"
|
|
19
|
+
:id="defaultId"
|
|
19
20
|
name="checkbox"
|
|
20
21
|
:class="[
|
|
21
22
|
'input spr-absolute spr-left-0 spr-top-0 spr-z-10 spr-m-0 spr-h-6 spr-w-12 spr-opacity-0',
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
]"
|
|
31
32
|
></span>
|
|
32
33
|
</div>
|
|
33
|
-
<label>
|
|
34
|
+
<label v-if="!isRightTextLabel" :for="defaultId" class="spr-cursor-pointer">
|
|
34
35
|
<slot name="rightText"></slot>
|
|
35
36
|
</label>
|
|
36
37
|
</div>
|
|
@@ -45,9 +46,11 @@ import { useSwitch } from './use-switch';
|
|
|
45
46
|
const props = defineProps(switchPropTypes);
|
|
46
47
|
const emit = defineEmits(switchEmitTypes);
|
|
47
48
|
|
|
49
|
+
const defaultId = props.id ? props.id + '_' + Math.random().toString(36).substring(2, 8) : 'switch_input_' + Math.random().toString(36).substring(2, 8);
|
|
50
|
+
|
|
48
51
|
const proxyValue = useVModel(props, 'modelValue', emit);
|
|
49
52
|
|
|
50
|
-
const { switchWrapperRef, switchRef, switchProps, switchMarkClass, switchTextClass, switchInputClass } =
|
|
53
|
+
const { switchWrapperRef, switchRef, switchProps, switchMarkClass, switchTextClass, switchInputClass, isLeftTextLabel, isRightTextLabel } =
|
|
51
54
|
useSwitch(props);
|
|
52
55
|
</script>
|
|
53
56
|
|
|
@@ -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,11 @@ 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 isLeftTextLabel = (!slots.default || slots.default().length === 0) && !slots.leftText;
|
|
19
|
+
const isRightTextLabel = !slots.rightText;
|
|
15
20
|
|
|
16
21
|
const switchProps: ComputedRef<Record<string, unknown>> = computed(() => {
|
|
17
22
|
return {
|
|
@@ -96,5 +101,7 @@ export const useSwitch = (props: SwitchPropTypes) => {
|
|
|
96
101
|
switchMarkClass,
|
|
97
102
|
switchTextClass,
|
|
98
103
|
switchInputClass,
|
|
104
|
+
isLeftTextLabel,
|
|
105
|
+
isRightTextLabel
|
|
99
106
|
};
|
|
100
107
|
};
|