dendelion-ui 0.0.12 → 0.0.13
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/dendelion-ui.cjs.js +2 -2
- package/dist/dendelion-ui.es.js +319 -316
- package/dist/dendelion-ui.umd.js +2 -2
- package/dist/types/components/button/Button.vue.d.ts +2 -12
- package/dist/types/components/card/Card.vue.d.ts +2 -11
- package/dist/types/components/card/CardBody.vue.d.ts +2 -4
- package/dist/types/components/container/Container.vue.d.ts +2 -10
- package/dist/types/components/modal/Modal.vue.d.ts +2 -23
- package/dist/types/components/stepper/Step.vue.d.ts +2 -8
- package/dist/types/components/stepper/StepList.vue.d.ts +2 -4
- package/dist/types/components/stepper/StepPanel.vue.d.ts +2 -9
- package/dist/types/components/stepper/StepPanels.vue.d.ts +2 -10
- package/dist/types/components/stepper/Stepper.vue.d.ts +2 -11
- package/dist/types/components/table/interface.d.ts +10 -2
- package/package.json +79 -75
- package/src/components/button/Button.vue +32 -29
- package/src/components/button/SimpleButton.vue +5 -8
- package/src/components/button/index.ts +3 -3
- package/src/components/button/interface.ts +13 -13
- package/src/components/card/Card.vue +32 -25
- package/src/components/card/CardBody.vue +7 -9
- package/src/components/card/CardTitle.vue +20 -18
- package/src/components/card/index.ts +4 -4
- package/src/components/card/interface.ts +9 -9
- package/src/components/container/Container.vue +20 -21
- package/src/components/container/index.ts +2 -2
- package/src/components/container/interface.ts +4 -5
- package/src/components/modal/Modal.vue +70 -52
- package/src/components/modal/index.ts +2 -2
- package/src/components/modal/interface.ts +12 -12
- package/src/components/search/SearchBar.vue +62 -53
- package/src/components/search/index.ts +1 -1
- package/src/components/stepper/Step.vue +37 -35
- package/src/components/stepper/StepList.vue +7 -8
- package/src/components/stepper/StepPanel.vue +29 -30
- package/src/components/stepper/StepPanels.vue +16 -17
- package/src/components/stepper/Stepper.vue +35 -33
- package/src/components/stepper/index.ts +6 -6
- package/src/components/stepper/interface.ts +3 -4
- package/src/components/table/Table.vue +135 -104
- package/src/components/table/index.ts +2 -2
- package/src/components/table/interface.ts +39 -31
- package/src/components.ts +7 -7
- package/src/index.ts +91 -91
- package/src/shims-vue.d.ts +7 -11
- package/src/types/color.ts +169 -170
- package/src/types/index.ts +2 -2
- package/src/types/size.ts +78 -78
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import classNames from 'classnames';
|
|
9
|
-
import { ref } from 'vue';
|
|
10
|
-
import { CardProps } from './interface';
|
|
11
|
-
import { Color, BackgroundColorUtils, RoundedSizeUtils } from '@/types';
|
|
12
|
-
|
|
13
|
-
const props = withDefaults(defineProps<CardProps>(), {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const classes = ref(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { ref } from 'vue';
|
|
10
|
+
import { CardProps } from './interface';
|
|
11
|
+
import { Color, BackgroundColorUtils, RoundedSizeUtils } from '@/types';
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<CardProps>(), {
|
|
14
|
+
backgroundColor: Color.Primary,
|
|
15
|
+
shadow: false,
|
|
16
|
+
fullWidth: false,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const classes = ref(
|
|
20
|
+
classNames(
|
|
21
|
+
'card',
|
|
22
|
+
BackgroundColorUtils.toClassName(props.backgroundColor),
|
|
23
|
+
props.shadow ? 'shadow-lg' : '',
|
|
24
|
+
props.fullWidth ? 'w-full' : '',
|
|
25
|
+
props.rounded && !props.roundedSize
|
|
26
|
+
? 'rounded'
|
|
27
|
+
: props.roundedSize
|
|
28
|
+
? RoundedSizeUtils.toClassName(props.roundedSize)
|
|
29
|
+
: '',
|
|
30
|
+
),
|
|
31
|
+
);
|
|
32
|
+
</script>
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="is" class="card-title">
|
|
3
|
+
{{ text }}
|
|
4
|
+
</component>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import type { Component } from 'vue';
|
|
9
|
+
|
|
10
|
+
withDefaults(
|
|
11
|
+
defineProps<{
|
|
12
|
+
is?: string | object | Component;
|
|
13
|
+
text: string;
|
|
14
|
+
}>(),
|
|
15
|
+
{
|
|
16
|
+
is: 'h1',
|
|
17
|
+
text: '',
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as Card } from './Card.vue';
|
|
2
|
-
export { default as CardBody } from './CardBody.vue';
|
|
3
|
-
export { default as CardTitle } from './CardTitle.vue';
|
|
4
|
-
export type { CardProps } from './interface';
|
|
1
|
+
export { default as Card } from './Card.vue';
|
|
2
|
+
export { default as CardBody } from './CardBody.vue';
|
|
3
|
+
export { default as CardTitle } from './CardTitle.vue';
|
|
4
|
+
export type { CardProps } from './interface';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Color, Size } from
|
|
2
|
-
|
|
3
|
-
export type CardProps = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
1
|
+
import { Color, Size } from '@/types';
|
|
2
|
+
|
|
3
|
+
export type CardProps = {
|
|
4
|
+
backgroundColor?: Color;
|
|
5
|
+
shadow?: boolean;
|
|
6
|
+
fullWidth?: boolean;
|
|
7
|
+
rounded?: boolean;
|
|
8
|
+
roundedSize?: Size;
|
|
9
|
+
};
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { ref } from 'vue';
|
|
9
|
-
import { ContainerProps } from './interface';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { ref } from 'vue';
|
|
9
|
+
import { ContainerProps } from './interface';
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<ContainerProps>(), {
|
|
12
|
+
container: true,
|
|
13
|
+
padding: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const classes = ref([
|
|
17
|
+
props.container ? 'container' : '', //To disable the max width in some cases
|
|
18
|
+
props.padding ? 'p-6' : '',
|
|
19
|
+
]);
|
|
20
|
+
</script>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as Container } from './Container.vue';
|
|
2
|
-
export type { ContainerProps } from './interface';
|
|
1
|
+
export { default as Container } from './Container.vue';
|
|
2
|
+
export type { ContainerProps } from './interface';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
export type ContainerProps = {
|
|
2
|
+
container?: boolean;
|
|
3
|
+
padding?: boolean;
|
|
4
|
+
};
|
|
@@ -1,52 +1,70 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<dialog
|
|
3
|
+
ref="modal"
|
|
4
|
+
:class="[classes, $attrs.class]"
|
|
5
|
+
aria-modal="true"
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
role="dialog"
|
|
8
|
+
@close="(e) => emit('close', e)"
|
|
9
|
+
>
|
|
10
|
+
<div :class="boxClasses">
|
|
11
|
+
<form v-if="closeButton" method="dialog">
|
|
12
|
+
<button :class="closeButtonClasses">✕</button>
|
|
13
|
+
</form>
|
|
14
|
+
<slot></slot>
|
|
15
|
+
</div>
|
|
16
|
+
<form method="dialog" class="modal-backdrop">
|
|
17
|
+
<button>close</button>
|
|
18
|
+
</form>
|
|
19
|
+
</dialog>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import { ref } from 'vue';
|
|
24
|
+
import { ModalProps } from './interface';
|
|
25
|
+
import classNames from 'classnames';
|
|
26
|
+
import { Size, ButtonSizeUtils } from '@/types';
|
|
27
|
+
|
|
28
|
+
const modal = ref<HTMLDialogElement | null>(null);
|
|
29
|
+
|
|
30
|
+
const emit = defineEmits(['close']);
|
|
31
|
+
|
|
32
|
+
const props = withDefaults(defineProps<ModalProps>(), {
|
|
33
|
+
closeButton: true,
|
|
34
|
+
overflow: false,
|
|
35
|
+
closeButtonSize: Size.SM,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const boxClasses = ref(classNames('modal-box', props.extraBoxClasses));
|
|
39
|
+
|
|
40
|
+
const classes = ref(
|
|
41
|
+
classNames('modal', {
|
|
42
|
+
'overflow-visible': props.overflow,
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const closeButtonClasses = ref(
|
|
47
|
+
classNames(
|
|
48
|
+
'btn',
|
|
49
|
+
ButtonSizeUtils.toClassName(props.closeButtonSize),
|
|
50
|
+
'btn-circle',
|
|
51
|
+
'btn-ghost',
|
|
52
|
+
'absolute',
|
|
53
|
+
'right-2',
|
|
54
|
+
'top-2',
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const showModal = () => {
|
|
59
|
+
modal.value?.showModal();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const closeModal = () => {
|
|
63
|
+
modal.value?.close();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
defineExpose({
|
|
67
|
+
showModal,
|
|
68
|
+
closeModal,
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {default as Modal} from './Modal.vue';
|
|
2
|
-
export type {ModalProps} from './interface';
|
|
1
|
+
export { default as Modal } from './Modal.vue';
|
|
2
|
+
export type { ModalProps } from './interface';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Size } from
|
|
2
|
-
|
|
3
|
-
export type ModalProps = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface Modal {
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
import { Size } from '@/types';
|
|
2
|
+
|
|
3
|
+
export type ModalProps = {
|
|
4
|
+
closeButton?: boolean;
|
|
5
|
+
overflow?: boolean;
|
|
6
|
+
closeButtonSize?: Size;
|
|
7
|
+
extraBoxClasses?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export interface Modal {
|
|
11
|
+
showModal: () => void;
|
|
12
|
+
}
|
|
@@ -1,53 +1,62 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hidden w-full max-w-sm lg:flex">
|
|
3
|
+
<label class="relative mx-3 w-full">
|
|
4
|
+
<svg
|
|
5
|
+
class="pointer-events-none absolute z-10 my-3.5 ms-4 text-base-content opacity-60"
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
width="16"
|
|
8
|
+
height="16"
|
|
9
|
+
viewBox="0.48 0.48 23.04 23.04"
|
|
10
|
+
fill="currentColor"
|
|
11
|
+
>
|
|
12
|
+
<path fill="none" d="M0 0h24v24H0z"></path>
|
|
13
|
+
<path
|
|
14
|
+
d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 109.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
|
|
15
|
+
></path>
|
|
16
|
+
</svg>
|
|
17
|
+
<div class="relative w-full max-w-full">
|
|
18
|
+
<form>
|
|
19
|
+
<input
|
|
20
|
+
ref="searchInput"
|
|
21
|
+
type="search"
|
|
22
|
+
placeholder="Zoeken..."
|
|
23
|
+
:value="props.modelValue"
|
|
24
|
+
@input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
|
|
25
|
+
class="color-[inherit] w-full rounded-xl border-[2px] border-solid border-transparent bg-transparent px-3 py-2 ps-10 focus:border-[2px] focus:border-base-200 focus:outline-none"
|
|
26
|
+
/>
|
|
27
|
+
</form>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="pointer-events-none absolute end-10 top-2.5 hidden gap-1 opacity-50 lg:flex rtl:flex-row-reverse">
|
|
30
|
+
<kbd class="kbd kbd-sm">ctrl</kbd>
|
|
31
|
+
<kbd class="kbd kbd-sm">K</kbd>
|
|
32
|
+
</div>
|
|
33
|
+
</label>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script setup lang="ts">
|
|
38
|
+
import { onMounted, onUnmounted, ref } from 'vue';
|
|
39
|
+
|
|
40
|
+
const props = defineProps(['modelValue']);
|
|
41
|
+
|
|
42
|
+
const searchInput = ref<HTMLInputElement | null>(null);
|
|
43
|
+
|
|
44
|
+
const emit = defineEmits(['update:modelValue']);
|
|
45
|
+
|
|
46
|
+
const handleKeyPress = (event: KeyboardEvent) => {
|
|
47
|
+
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'k') {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
if (searchInput.value) {
|
|
50
|
+
searchInput.value.focus();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
onMounted(() => {
|
|
56
|
+
document.addEventListener('keydown', handleKeyPress);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
onUnmounted(() => {
|
|
60
|
+
document.removeEventListener('keydown', handleKeyPress);
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as SearchBar } from './SearchBar.vue';
|
|
1
|
+
export { default as SearchBar } from './SearchBar.vue';
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { inject, onMounted, ref, watch, type Ref } from 'vue';
|
|
9
|
-
import { StepperProps } from './interface';
|
|
10
|
-
|
|
11
|
-
const props = defineProps<StepperProps>()
|
|
12
|
-
|
|
13
|
-
const stepper = inject<{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}>(
|
|
17
|
-
|
|
18
|
-
const activeClass = ref('');
|
|
19
|
-
|
|
20
|
-
watch(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<li class="step" :class="activeClass">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</li>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { inject, onMounted, ref, watch, type Ref } from 'vue';
|
|
9
|
+
import { StepperProps } from './interface';
|
|
10
|
+
|
|
11
|
+
const props = defineProps<StepperProps>();
|
|
12
|
+
|
|
13
|
+
const stepper = inject<{
|
|
14
|
+
value: Ref<string>;
|
|
15
|
+
updateValue: (value: string) => void;
|
|
16
|
+
}>('stepper');
|
|
17
|
+
|
|
18
|
+
const activeClass = ref('');
|
|
19
|
+
|
|
20
|
+
watch(
|
|
21
|
+
() => stepper?.value.value,
|
|
22
|
+
(value) => {
|
|
23
|
+
if (value && props.value) {
|
|
24
|
+
activeClass.value = Number(value) >= Number(props.value) ? 'step-primary' : '';
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
if (stepper) {
|
|
31
|
+
activeClass.value = stepper.value.value === props.value ? 'step-primary' : '';
|
|
32
|
+
if (Number(stepper.value.value) >= Number(props.value)) {
|
|
33
|
+
activeClass.value = 'step-primary';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<ul class="steps">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</ul>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts"></script>
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { computed, inject, type Ref } from 'vue';
|
|
9
|
-
import { StepperProps } from './interface';
|
|
10
|
-
|
|
11
|
-
defineProps<StepperProps>()
|
|
12
|
-
|
|
13
|
-
const stepperValue = computed(() => stepper?.value.value)
|
|
14
|
-
|
|
15
|
-
const stepper = inject<{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}>(
|
|
19
|
-
|
|
20
|
-
const activateCallback = (index: number) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="value === stepperValue">
|
|
3
|
+
<slot :activateCallback="activateCallback"></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed, inject, type Ref } from 'vue';
|
|
9
|
+
import { StepperProps } from './interface';
|
|
10
|
+
|
|
11
|
+
defineProps<StepperProps>();
|
|
12
|
+
|
|
13
|
+
const stepperValue = computed(() => stepper?.value.value);
|
|
14
|
+
|
|
15
|
+
const stepper = inject<{
|
|
16
|
+
value: Ref<string>;
|
|
17
|
+
updateValue: (value: string) => void;
|
|
18
|
+
}>('stepper');
|
|
19
|
+
|
|
20
|
+
const activateCallback = (index: number) => {
|
|
21
|
+
if (stepper) {
|
|
22
|
+
stepper.updateValue(index.toString());
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
defineExpose({
|
|
27
|
+
activateCallback,
|
|
28
|
+
});
|
|
29
|
+
</script>
|