@zap-wunschlachen/wl-shared-components 1.0.0
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/.github/workflows/playwright.yml +215 -0
- package/.github/workflows/static.yml +62 -0
- package/.prettierrc +5 -0
- package/.storybook/main.ts +18 -0
- package/.storybook/preview.ts +37 -0
- package/.storybook/storyWrapper.vue +18 -0
- package/.storybook/withVuetifyTheme.decorator.ts +21 -0
- package/App.vue +95 -0
- package/README.md +56 -0
- package/heroicons.ts +75 -0
- package/index.html +19 -0
- package/package.json +66 -0
- package/playwright.config.ts +35 -0
- package/public/audio/dummy_pink_noise.wav +0 -0
- package/public/background.svg +60 -0
- package/public/javascript.svg +1 -0
- package/public/style.css +187 -0
- package/public/technologies.svg +22 -0
- package/src/assets/css/base.css +235 -0
- package/src/assets/css/variables.css +96 -0
- package/src/assets/fonts/Outfit-Black.ttf +0 -0
- package/src/assets/fonts/Outfit-Bold.ttf +0 -0
- package/src/assets/fonts/Outfit-ExtraBold.ttf +0 -0
- package/src/assets/fonts/Outfit-ExtraLight.ttf +0 -0
- package/src/assets/fonts/Outfit-Light.ttf +0 -0
- package/src/assets/fonts/Outfit-Medium.ttf +0 -0
- package/src/assets/fonts/Outfit-Regular.ttf +0 -0
- package/src/assets/fonts/Outfit-SemiBold.ttf +0 -0
- package/src/assets/fonts/Outfit-Thin.ttf +0 -0
- package/src/components/Accordion/Accordion.css +59 -0
- package/src/components/Accordion/AccordionGroup.vue +51 -0
- package/src/components/Accordion/AccordionItem.vue +66 -0
- package/src/components/Appointment/Card/Actions.css +30 -0
- package/src/components/Appointment/Card/Actions.vue +66 -0
- package/src/components/Appointment/Card/Card.css +49 -0
- package/src/components/Appointment/Card/Card.vue +55 -0
- package/src/components/Appointment/Card/Details.css +51 -0
- package/src/components/Appointment/Card/Details.vue +44 -0
- package/src/components/Audio/Audio.vue +188 -0
- package/src/components/Audio/Waveform.vue +118 -0
- package/src/components/Button/Button.vue +119 -0
- package/src/components/CheckBox/CheckBox.css +185 -0
- package/src/components/CheckBox/Checkbox.vue +130 -0
- package/src/components/DateInput/DateInput.css +3 -0
- package/src/components/DateInput/DateInput.vue +263 -0
- package/src/components/Dialog/Dialog.css +6 -0
- package/src/components/Dialog/Dialog.vue +29 -0
- package/src/components/EditField/EditField.css +20 -0
- package/src/components/EditField/EditField.vue +202 -0
- package/src/components/IconBullet/IconBullet.vue +86 -0
- package/src/components/IconBullet/IconBulletList.vue +41 -0
- package/src/components/Icons/Audio/CloudFailed.vue +21 -0
- package/src/components/Icons/Audio/CloudSaved.vue +22 -0
- package/src/components/Icons/Audio/Delete.vue +16 -0
- package/src/components/Icons/Audio/Pause.vue +19 -0
- package/src/components/Icons/Audio/Play.vue +16 -0
- package/src/components/Icons/CalendarNotification.vue +126 -0
- package/src/components/Icons/Chair.vue +32 -0
- package/src/components/Icons/ChairNotification.vue +35 -0
- package/src/components/Icons/Circle.vue +66 -0
- package/src/components/Icons/FavIcon.vue +22 -0
- package/src/components/Icons/FilledCircle.vue +11 -0
- package/src/components/Icons/Group3.vue +46 -0
- package/src/components/Icons/RingNotification.vue +54 -0
- package/src/components/Icons/SolidArrowRight.vue +14 -0
- package/src/components/Icons/calendar.vue +17 -0
- package/src/components/Icons/checkbox.vue +19 -0
- package/src/components/Icons/outlineChecked.vue +27 -0
- package/src/components/Icons/play.vue +6 -0
- package/src/components/Input/Input.css +187 -0
- package/src/components/Input/Input.vue +247 -0
- package/src/components/Laboratory/AppointmentCard/AppointmentCard.css +7 -0
- package/src/components/Laboratory/AppointmentCard/AppointmentCard.vue +116 -0
- package/src/components/Laboratory/ChatBoxImage/ChatBoxImage.vue +81 -0
- package/src/components/Laboratory/ChatMessage/ChatMessage.vue +113 -0
- package/src/components/Laboratory/ChatMessage/ChatMessageBadge.css +4 -0
- package/src/components/Laboratory/ChatMessage/ChatMessageBadge.vue +99 -0
- package/src/components/Laboratory/ChatNotification/ChatNotification.vue +130 -0
- package/src/components/Laboratory/DocumentCard/DocumentCard.css +3 -0
- package/src/components/Laboratory/DocumentCard/DocumentCard.vue +50 -0
- package/src/components/Laboratory/DocumentCard/DocumentCardItem.vue +53 -0
- package/src/components/Laboratory/InfoCard/InfoCard.vue +162 -0
- package/src/components/Laboratory/MainColumnsBar/MainColumnsBar.vue +102 -0
- package/src/components/Laboratory/ProgressCircle/ProgressCircle.vue +152 -0
- package/src/components/Laboratory/ProgressLinear/ProgressLinear.css +33 -0
- package/src/components/Laboratory/ProgressLinear/ProgressLinear.vue +75 -0
- package/src/components/Laboratory/SelectionColumnBar/SelectionColumnBar.vue +92 -0
- package/src/components/Laboratory/StatusNotification/StatusNotification.vue +49 -0
- package/src/components/Laboratory/TagLabel/TagLabel.vue +126 -0
- package/src/components/Laboratory/TagLabelGroup/TagLabelGroup.vue +97 -0
- package/src/components/Laboratory/TicketCard/TicketCard.css +3 -0
- package/src/components/Laboratory/TicketCard/TicketCard.vue +143 -0
- package/src/components/Laboratory/TimeLine/TimeLineEvent.css +18 -0
- package/src/components/Laboratory/TimeLine/TimeLineEvent.vue +119 -0
- package/src/components/Laboratory/TimeLine/Timeline.css +4 -0
- package/src/components/Laboratory/TimeLine/Timeline.vue +30 -0
- package/src/components/Modal/Modal.css +6 -0
- package/src/components/Modal/Modal.vue +23 -0
- package/src/components/NotificationBubble/NotificationBubble.css +4 -0
- package/src/components/NotificationBubble/NotificationBubble.vue +90 -0
- package/src/components/OtpInput/OtpInput.css +39 -0
- package/src/components/OtpInput/OtpInput.vue +144 -0
- package/src/components/PhoneInput/PhoneInput.css +32 -0
- package/src/components/PhoneInput/PhoneInput.vue +114 -0
- package/src/components/Select/Select.css +150 -0
- package/src/components/Select/Select.vue +304 -0
- package/src/components/TextArea/TextArea.css +3 -0
- package/src/components/TextArea/TextArea.vue +126 -0
- package/src/components/TickBox/TickBox.css +49 -0
- package/src/components/TickBox/TickBox.vue +126 -0
- package/src/components/index.ts +20 -0
- package/src/constants/buttonEnums.ts +0 -0
- package/src/constants/iconEnums.ts +4 -0
- package/src/i18n/i18n.ts +16 -0
- package/src/i18n/locales/de.json +19 -0
- package/src/i18n/locales/en.json +19 -0
- package/src/index.ts +31 -0
- package/src/main.ts +11 -0
- package/src/plugins/vuetify.ts +131 -0
- package/src/shims-vue.d.ts +10 -0
- package/src/stories/Accordion.stories.ts +650 -0
- package/src/stories/Audio.stories.ts +29 -0
- package/src/stories/Button.stories.ts +263 -0
- package/src/stories/CheckBox.stories.ts +348 -0
- package/src/stories/DateInput.stories.ts +54 -0
- package/src/stories/Dialog.stories.ts +147 -0
- package/src/stories/EditField.stories.ts +79 -0
- package/src/stories/IconBullet/IconBullet.stories.ts +201 -0
- package/src/stories/IconBullet/IconBulletList.stories.ts +275 -0
- package/src/stories/Input.stories.ts +351 -0
- package/src/stories/Laboratory/Cards/AppointmentCard/AppointmentCard.stories.ts +260 -0
- package/src/stories/Laboratory/Cards/DocumentCard/DocumentCard.stories.ts +176 -0
- package/src/stories/Laboratory/Cards/DocumentCard/DocumentCardItem.stories.ts +119 -0
- package/src/stories/Laboratory/Cards/InfoCard/InfoCard.stories.ts +320 -0
- package/src/stories/Laboratory/Cards/TicketCard/TicketCard.stories.ts +335 -0
- package/src/stories/Laboratory/Chat/ChatBoxImage.stories.ts +82 -0
- package/src/stories/Laboratory/Chat/ChatMessage.stories.ts +198 -0
- package/src/stories/Laboratory/Chat/ChatMessageBadge.stories.ts +204 -0
- package/src/stories/Laboratory/Chat/ChatNotification.stories.ts +144 -0
- package/src/stories/Laboratory/Chat/ProgressLinear.stories.ts +186 -0
- package/src/stories/Laboratory/Chat/StatusNotification.stories.ts +111 -0
- package/src/stories/Laboratory/MainColumnsBar.stories.ts +48 -0
- package/src/stories/Laboratory/ProgressCircle.stories.ts +261 -0
- package/src/stories/Laboratory/SelectionColumnBar.stories.ts +234 -0
- package/src/stories/Laboratory/TagLabel.stories.ts +418 -0
- package/src/stories/Laboratory/TagLabelGroup.stories.ts +234 -0
- package/src/stories/Laboratory/Timeline.stories.ts +403 -0
- package/src/stories/NotificationBubble.stories.ts +194 -0
- package/src/stories/OtpInput.stories.ts +101 -0
- package/src/stories/PhoneInput.stories.ts +53 -0
- package/src/stories/Select.stories.ts +419 -0
- package/src/stories/TextArea.stories.ts +112 -0
- package/src/stories/TickBox.stories.ts +294 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/src/stories/v-icon.stories.ts +91 -0
- package/src/types/index.ts +21 -0
- package/src/vite-env.d.ts +1 -0
- package/tests/e2e/README.md +221 -0
- package/tests/e2e/accessibility.spec.ts +639 -0
- package/tests/e2e/accordion.spec.ts +42 -0
- package/tests/e2e/additional-components.spec.ts +438 -0
- package/tests/e2e/all-components.spec.ts +135 -0
- package/tests/e2e/button-fixed.spec.ts +59 -0
- package/tests/e2e/button.spec.ts +76 -0
- package/tests/e2e/checkbox.spec.ts +50 -0
- package/tests/e2e/date-input.spec.ts +46 -0
- package/tests/e2e/debug.spec.ts +52 -0
- package/tests/e2e/dialog.spec.ts +58 -0
- package/tests/e2e/input.spec.ts +55 -0
- package/tests/e2e/laboratory-components.spec.ts +321 -0
- package/tests/e2e/otp-input.spec.ts +50 -0
- package/tests/e2e/select.spec.ts +52 -0
- package/tests/e2e/storybook-utils.ts +59 -0
- package/tests/e2e/test-basic.spec.ts +34 -0
- package/tests/e2e/visual-regression.spec.ts +351 -0
- package/tests/unit/components/Accordion/AccordionGroup.spec.ts +343 -0
- package/tests/unit/components/Accordion/AccordionItem.spec.ts +384 -0
- package/tests/unit/components/Audio/Audio.spec.ts +404 -0
- package/tests/unit/components/Audio/Waveform.spec.ts +484 -0
- package/tests/unit/components/Core/Button.spec.ts +337 -0
- package/tests/unit/components/Core/Checkbox.spec.ts +545 -0
- package/tests/unit/components/Core/DateInput.spec.ts +691 -0
- package/tests/unit/components/Core/Dialog.spec.ts +486 -0
- package/tests/unit/components/Core/EditField.spec.ts +783 -0
- package/tests/unit/components/Core/Input.spec.ts +513 -0
- package/tests/unit/components/Core/Modal.spec.ts +519 -0
- package/tests/unit/components/Core/NotificationBubble.spec.ts +607 -0
- package/tests/unit/components/Core/OtpInput.spec.ts +709 -0
- package/tests/unit/components/Core/PhoneInput.spec.ts +620 -0
- package/tests/unit/components/Core/Select.spec.ts +713 -0
- package/tests/unit/components/Core/TextArea.spec.ts +566 -0
- package/tests/unit/components/Core/TickBox.spec.ts +780 -0
- package/tests/unit/components/IconBullet/IconBullet.spec.ts +357 -0
- package/tests/unit/components/IconBullet/IconBulletList.spec.ts +372 -0
- package/tests/unit/components/Icons/Audio/CloudFailed.spec.ts +109 -0
- package/tests/unit/components/Icons/Audio/CloudSaved.spec.ts +150 -0
- package/tests/unit/components/Icons/Audio/Delete.spec.ts +159 -0
- package/tests/unit/components/Icons/Audio/Pause.spec.ts +209 -0
- package/tests/unit/components/Icons/Audio/Play.spec.ts +218 -0
- package/tests/unit/components/Icons/CalendarNotification.spec.ts +187 -0
- package/tests/unit/components/Icons/Chair.spec.ts +235 -0
- package/tests/unit/components/Icons/ChairNotification.spec.ts +312 -0
- package/tests/unit/components/Icons/Circle.spec.ts +256 -0
- package/tests/unit/components/Icons/FavIcon.spec.ts +252 -0
- package/tests/unit/components/Icons/FilledCircle.spec.ts +275 -0
- package/tests/unit/components/Icons/Group3.spec.ts +356 -0
- package/tests/unit/components/Icons/RingNotification.spec.ts +394 -0
- package/tests/unit/components/Icons/calendar.spec.ts +287 -0
- package/tests/unit/components/Icons/checkbox.spec.ts +316 -0
- package/tests/unit/components/Icons/outlineChecked.spec.ts +435 -0
- package/tests/unit/components/Icons/play.spec.ts +309 -0
- package/tests/unit/components/Laboratory/AppointmentCard.spec.ts +168 -0
- package/tests/unit/components/Laboratory/ChatBoxImage.spec.ts +180 -0
- package/tests/unit/components/Laboratory/ChatMessage.spec.ts +264 -0
- package/tests/unit/components/Laboratory/ChatMessageBadge.spec.ts +283 -0
- package/tests/unit/components/Laboratory/ChatNotification.spec.ts +257 -0
- package/tests/unit/components/Laboratory/DocumentCard.spec.ts +229 -0
- package/tests/unit/components/Laboratory/DocumentCardItem.spec.ts +237 -0
- package/tests/unit/components/Laboratory/InfoCard.spec.ts +309 -0
- package/tests/unit/components/Laboratory/MainColumnsBar.spec.ts +252 -0
- package/tests/unit/components/Laboratory/ProgressCircle.spec.ts +291 -0
- package/tests/unit/components/Laboratory/ProgressLinear.spec.ts +276 -0
- package/tests/unit/components/Laboratory/SelectionColumnBar.spec.ts +289 -0
- package/tests/unit/components/Laboratory/StatusNotification.spec.ts +297 -0
- package/tests/unit/components/Laboratory/TagLabel.spec.ts +354 -0
- package/tests/unit/components/Laboratory/TagLabelGroup.spec.ts +378 -0
- package/tests/unit/components/Laboratory/TicketCard.spec.ts +352 -0
- package/tests/unit/components/Laboratory/TimeLineEvent.spec.ts +382 -0
- package/tests/unit/components/Laboratory/Timeline.spec.ts +420 -0
- package/tests/unit/constants/iconEnums.spec.ts +40 -0
- package/tests/unit/i18n/i18n.spec.ts +89 -0
- package/tests/unit/plugins/vuetify.spec.ts +221 -0
- package/tests/unit/setup.ts +190 -0
- package/tests/unit/src/components/index.spec.ts +193 -0
- package/tests/unit/src/index.spec.ts +183 -0
- package/tests/unit/src/main.spec.ts +152 -0
- package/tsconfig.json +26 -0
- package/vite.config.ts +29 -0
- package/vitest.config.ts +84 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="waveform" class="waveform"></div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import { ref, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
|
7
|
+
import WaveSurfer from 'wavesurfer.js'
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
src: { type: String },
|
|
11
|
+
blob: { type: Blob }
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const emit = defineEmits(['timeupdate', 'finish', 'ready'])
|
|
15
|
+
|
|
16
|
+
const waveform = ref(null)
|
|
17
|
+
let waveColor = '#93B1CF'
|
|
18
|
+
let progressColor = '#172774'
|
|
19
|
+
let ws = null
|
|
20
|
+
|
|
21
|
+
onMounted(() => {
|
|
22
|
+
const styles = getComputedStyle(document.documentElement)
|
|
23
|
+
waveColor = styles.getPropertyValue('--Dental-Light-Blue-2').trim()
|
|
24
|
+
progressColor = styles.getPropertyValue('--Dental-Blue-0').trim()
|
|
25
|
+
|
|
26
|
+
nextTick(() => {
|
|
27
|
+
try {
|
|
28
|
+
createWaveform()
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Error initializing WaveSurfer:', error);
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
function createWaveform() {
|
|
36
|
+
try {
|
|
37
|
+
// Check if the waveform element is available
|
|
38
|
+
if (!waveform.value) {
|
|
39
|
+
throw new Error('Waveform container element not found');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const containerWidth = waveform.value.clientWidth;
|
|
43
|
+
const containerHeight = waveform.value.clientHeight;
|
|
44
|
+
|
|
45
|
+
ws = WaveSurfer.create({
|
|
46
|
+
container: waveform.value,
|
|
47
|
+
waveColor: waveColor,
|
|
48
|
+
progressColor: progressColor,
|
|
49
|
+
barWidth: 2,
|
|
50
|
+
barGap: 2,
|
|
51
|
+
barRadius: 4,
|
|
52
|
+
cursorWidth: 0,
|
|
53
|
+
height: containerHeight,
|
|
54
|
+
width: containerWidth,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
ws.on('audioprocess', (currentTime) => {
|
|
58
|
+
emit('timeupdate', currentTime);
|
|
59
|
+
})
|
|
60
|
+
ws.on('finish', () => {
|
|
61
|
+
emit('finish');
|
|
62
|
+
})
|
|
63
|
+
ws.on('ready', (totalDuration) => {
|
|
64
|
+
emit('ready', totalDuration);
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
ws.on('error', e => console.error(e))
|
|
68
|
+
|
|
69
|
+
if (props.blob) {
|
|
70
|
+
ws.loadBlob(props.blob)
|
|
71
|
+
} else if (props.src) {
|
|
72
|
+
ws.load(props.src)
|
|
73
|
+
} else {
|
|
74
|
+
throw new Error('No audio source provided')
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error('Error initializing WaveSurfer:', error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function play() {
|
|
82
|
+
if (ws) {
|
|
83
|
+
ws.play()
|
|
84
|
+
} else {
|
|
85
|
+
console.warn('WaveSurfer instance not ready')
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function pause() {
|
|
90
|
+
if (ws) {
|
|
91
|
+
ws.pause()
|
|
92
|
+
} else {
|
|
93
|
+
console.warn('WaveSurfer instance not ready')
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getCurrentTime() {
|
|
98
|
+
return ws ? ws.getCurrentTime() : 0
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
defineExpose({ play, pause, getCurrentTime })
|
|
102
|
+
|
|
103
|
+
onBeforeUnmount(() => {
|
|
104
|
+
if (ws) ws.destroy()
|
|
105
|
+
})
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<style scoped>
|
|
109
|
+
.waveform {
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-grow: 1;
|
|
112
|
+
flex-shrink: 1;
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
min-height: 16px;
|
|
116
|
+
min-width: 0px;
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-btn
|
|
3
|
+
:color="color"
|
|
4
|
+
:disabled="disabled"
|
|
5
|
+
:prepend-icon="prependIcon"
|
|
6
|
+
:append-icon="appendIcon"
|
|
7
|
+
:loading="loading"
|
|
8
|
+
rounded="lg"
|
|
9
|
+
:density="density"
|
|
10
|
+
class="text-none wl-button"
|
|
11
|
+
:variant="variant"
|
|
12
|
+
:size="size"
|
|
13
|
+
:readonly="readonly"
|
|
14
|
+
data-testid="root"
|
|
15
|
+
>
|
|
16
|
+
{{ label }}
|
|
17
|
+
</v-btn>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup>
|
|
21
|
+
import { defineProps } from 'vue';
|
|
22
|
+
|
|
23
|
+
const props = defineProps({
|
|
24
|
+
/**
|
|
25
|
+
* The color of the button.
|
|
26
|
+
* Default is '#172774' (a dark blue color).
|
|
27
|
+
*/
|
|
28
|
+
color: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: '#172774',
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Icon to display before the button label.
|
|
34
|
+
* Accepts the name of an icon (String).
|
|
35
|
+
*/
|
|
36
|
+
prependIcon: {
|
|
37
|
+
type: String,
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Icon to display after the button label.
|
|
41
|
+
* Can be any valid icon name or value (type not specified for flexibility).
|
|
42
|
+
*/
|
|
43
|
+
appendIcon: {},
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Boolean to set the loading state of the button.
|
|
47
|
+
* When true, it shows a loading spinner.
|
|
48
|
+
* Default is false.
|
|
49
|
+
*/
|
|
50
|
+
loading: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Defines the density of the button.
|
|
57
|
+
* Accepts 'default', 'comfortable', or other Vuetify density options.
|
|
58
|
+
* Default is 'default'.
|
|
59
|
+
*/
|
|
60
|
+
density: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: 'default',
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The visual style of the button.
|
|
67
|
+
* Accepts 'flat', 'outlined', 'contained', etc.
|
|
68
|
+
* Default is 'flat'.
|
|
69
|
+
*/
|
|
70
|
+
variant: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: 'flat',
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Size of the button.
|
|
77
|
+
* Accepts 'small', 'medium', 'large', or 'default'.
|
|
78
|
+
* Default is 'default'.
|
|
79
|
+
*/
|
|
80
|
+
size: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: 'default',
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The text label to display inside the button.
|
|
87
|
+
* Default is 'Button'.
|
|
88
|
+
*/
|
|
89
|
+
label: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: 'Button',
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Boolean to disable the button.
|
|
96
|
+
* When true, the button is disabled and not clickable.
|
|
97
|
+
* Default is false.
|
|
98
|
+
*/
|
|
99
|
+
disabled: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: false,
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* Boolean to set the button to read-only state.
|
|
105
|
+
* When true, the button displays the readonly attribute.
|
|
106
|
+
* Default is false.
|
|
107
|
+
*/
|
|
108
|
+
readonly: {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
default: false,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<style>
|
|
116
|
+
.wl-button .v-btn--variant-outlined {
|
|
117
|
+
border-width: 1.5px;
|
|
118
|
+
}
|
|
119
|
+
</style>
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/* Normal State */
|
|
2
|
+
|
|
3
|
+
/* Label */
|
|
4
|
+
.label {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 12px;
|
|
8
|
+
font-size: 0.875rem;
|
|
9
|
+
line-height: 15.6px;
|
|
10
|
+
letter-spacing: -0.13px;
|
|
11
|
+
color: var(--Dental-Blue-0);
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* Checkbox Container */
|
|
16
|
+
.checkbox-container {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Checkbox (Normal) */
|
|
23
|
+
.input-checkbox {
|
|
24
|
+
appearance: none;
|
|
25
|
+
background-color: white;
|
|
26
|
+
margin: 0;
|
|
27
|
+
padding: 0;
|
|
28
|
+
/* Width and height will be set by density classes */
|
|
29
|
+
border: 1px solid;
|
|
30
|
+
border-radius: 4px;
|
|
31
|
+
display: grid;
|
|
32
|
+
place-content: center;
|
|
33
|
+
transform: translateY(-0.075em);
|
|
34
|
+
border-color: var(--Soft-Concrete-2);
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.input-checkbox:hover {
|
|
39
|
+
border-width: 2px;
|
|
40
|
+
background-color: var(--Dental-Light-Blue--2);
|
|
41
|
+
border-color: var(--Dental-Blue-0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.input-checkbox::before {
|
|
45
|
+
content: '';
|
|
46
|
+
/* Width and height will be set by density classes */
|
|
47
|
+
transform: scale(0);
|
|
48
|
+
transition: 120ms transform ease-in-out;
|
|
49
|
+
box-shadow: inset 1em 1em var(--Dental-Blue-0);
|
|
50
|
+
background-color: var(--Dental-Blue-0);
|
|
51
|
+
border-radius: 2px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.input-checkbox:checked::before {
|
|
55
|
+
transform: scale(1);
|
|
56
|
+
background-color: var(--Dental-Blue-0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.input-checkbox:checked {
|
|
60
|
+
border-width: 2px;
|
|
61
|
+
border-color: var(--Dental-Blue-0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.input-checkbox:hover::before {
|
|
65
|
+
border-color: var(--Dental-Blue-0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Density Levels */
|
|
69
|
+
|
|
70
|
+
/* Comfortable */
|
|
71
|
+
.density-comfortable.input-checkbox {
|
|
72
|
+
width: 32px;
|
|
73
|
+
height: 32px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.density-comfortable.input-checkbox::before {
|
|
77
|
+
width: 20px;
|
|
78
|
+
height: 20px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Default */
|
|
82
|
+
.density-default.input-checkbox {
|
|
83
|
+
width: 28px;
|
|
84
|
+
height: 28px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.density-default.input-checkbox::before {
|
|
88
|
+
width: 16px;
|
|
89
|
+
height: 16px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Compact */
|
|
93
|
+
.density-compact.input-checkbox {
|
|
94
|
+
width: 24px;
|
|
95
|
+
height: 24px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.density-compact.input-checkbox::before {
|
|
99
|
+
width: 12px;
|
|
100
|
+
height: 12px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Success State */
|
|
104
|
+
|
|
105
|
+
/* Success Label */
|
|
106
|
+
.label-success {
|
|
107
|
+
color: var(--Success-Green-1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* Success Checkbox */
|
|
111
|
+
.input-success {
|
|
112
|
+
border-color: var(--Success-Green-0);
|
|
113
|
+
color: var(--Success-Green-0);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.input-success:hover {
|
|
117
|
+
border-color: var(--Success-Green-0);
|
|
118
|
+
background-color: var(--Success-Green--1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.input-success.input-checkbox:checked {
|
|
122
|
+
border-color: var(--Success-Green-0);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.input-success.input-checkbox::before {
|
|
126
|
+
box-shadow: inset 1em 1em var(--Success-Green-0);
|
|
127
|
+
background-color: var(--Success-Green-0);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Error State */
|
|
131
|
+
|
|
132
|
+
/* Error Label */
|
|
133
|
+
.label-error {
|
|
134
|
+
color: var(--Error-Red-0);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* Error Checkbox */
|
|
138
|
+
.input-error {
|
|
139
|
+
border-color: var(--Error-Red-0);
|
|
140
|
+
color: var(--Error-Red-0);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.input-error:hover {
|
|
144
|
+
border-color: var(--Error-Red-0);
|
|
145
|
+
background-color: var(--Light-Gum--3);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.input-error.input-checkbox:checked {
|
|
149
|
+
border-color: var(--Error-Red-0);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.input-error.input-checkbox::before {
|
|
153
|
+
box-shadow: inset 1em 1em var(--Error-Red-0);
|
|
154
|
+
background-color: var(--Error-Red-0);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* Disabled State */
|
|
158
|
+
|
|
159
|
+
/* Disabled Label */
|
|
160
|
+
.label-disabled {
|
|
161
|
+
color: var(--Soft-Concrete-2);
|
|
162
|
+
opacity: 0.5;
|
|
163
|
+
cursor: not-allowed;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* Disabled Checkbox */
|
|
167
|
+
.input-disabled {
|
|
168
|
+
opacity: 0.5;
|
|
169
|
+
cursor: not-allowed;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.input-checkbox:disabled::before {
|
|
173
|
+
border-color: var(--Dental-Blue-0);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.input-disabled.input-checkbox:hover {
|
|
177
|
+
border-width: 0.5px;
|
|
178
|
+
background-color: white;
|
|
179
|
+
border-color: var(--Soft-Concrete-2);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* Label Text */
|
|
183
|
+
.label-text {
|
|
184
|
+
font-weight: 300;
|
|
185
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label :class="labelClasses" data-testid="root">
|
|
3
|
+
<span class="checkbox-container">
|
|
4
|
+
<input
|
|
5
|
+
type="checkbox"
|
|
6
|
+
:name="value"
|
|
7
|
+
:checked="isChecked"
|
|
8
|
+
@change="updateValue"
|
|
9
|
+
:class="inputClasses"
|
|
10
|
+
:disabled="disabled"
|
|
11
|
+
/>
|
|
12
|
+
</span>
|
|
13
|
+
{{ label }}
|
|
14
|
+
</label>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
import { defineProps, defineEmits, computed } from 'vue';
|
|
19
|
+
import './CheckBox.css';
|
|
20
|
+
|
|
21
|
+
// Define props for the checkbox component with default values and validation
|
|
22
|
+
const props = defineProps({
|
|
23
|
+
/**
|
|
24
|
+
* The label text associated with the checkbox.
|
|
25
|
+
*/
|
|
26
|
+
label: {
|
|
27
|
+
type: String,
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Boolean indicating if the checkbox is in a success state.
|
|
31
|
+
* When true, the success style will be applied.
|
|
32
|
+
*/
|
|
33
|
+
success: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false,
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Boolean indicating if the checkbox is in an error state.
|
|
39
|
+
* When true, the error style will be applied.
|
|
40
|
+
*/
|
|
41
|
+
error: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* Boolean indicating if the checkbox is disabled.
|
|
47
|
+
* When true, the checkbox will be non-interactive.
|
|
48
|
+
*/
|
|
49
|
+
disabled: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* The value associated with the checkbox input.
|
|
55
|
+
* Should be unique for each checkbox to track selections correctly.
|
|
56
|
+
*/
|
|
57
|
+
value: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: 'checkbox',
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* The model value of the checkbox.
|
|
63
|
+
* Can be an array for multiple selections or a boolean for single selection.
|
|
64
|
+
* Default is an empty array for multiple selections.
|
|
65
|
+
*/
|
|
66
|
+
modelValue: {
|
|
67
|
+
type: [Array, Boolean],
|
|
68
|
+
default: () => [], // Default empty array for multiple selections
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* The density of the checkbox.
|
|
72
|
+
* Controls the size and spacing of the checkbox, accepting 'comfortable', 'default', or 'compact'.
|
|
73
|
+
* Default is 'default'.
|
|
74
|
+
*/
|
|
75
|
+
density: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: 'default',
|
|
78
|
+
validator: (value) => ['comfortable', 'default', 'compact'].includes(value), // Validate acceptable values
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Define events that can be emitted from the component
|
|
83
|
+
const emit = defineEmits(['update:modelValue', 'input-error']);
|
|
84
|
+
|
|
85
|
+
// Computed property to check if the checkbox is selected
|
|
86
|
+
const isChecked = computed(() => {
|
|
87
|
+
if (Array.isArray(props.modelValue)) {
|
|
88
|
+
return props.modelValue.includes(props.value); // For multiple selections, check if value is in the array
|
|
89
|
+
}
|
|
90
|
+
return props.modelValue; // For single selection (boolean), return the model value
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Function to update the modelValue based on the checkbox state
|
|
94
|
+
const updateValue = (event) => {
|
|
95
|
+
const checked = event.target.checked;
|
|
96
|
+
let newValue;
|
|
97
|
+
|
|
98
|
+
// Handle array (multiple selection) and boolean (single selection) cases
|
|
99
|
+
if (Array.isArray(props.modelValue)) {
|
|
100
|
+
if (checked) {
|
|
101
|
+
newValue = [...props.modelValue, props.value]; // Add value if checked
|
|
102
|
+
} else {
|
|
103
|
+
newValue = props.modelValue.filter((item) => item !== props.value); // Remove value if unchecked
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
newValue = checked; // For boolean, just set to checked state
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Emit the updated value and a potential input error event
|
|
110
|
+
emit('update:modelValue', newValue);
|
|
111
|
+
emit('input-error', { id: props.value, isError: !checked });
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// Computed classes for the label, dynamically applying success, error, or disabled styles
|
|
115
|
+
const labelClasses = computed(() => ({
|
|
116
|
+
label: true,
|
|
117
|
+
'label-success': props.success, // Success state class
|
|
118
|
+
'label-error': props.error, // Error state class
|
|
119
|
+
'label-disabled': props.disabled, // Disabled state class
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
// Computed classes for the checkbox input, dynamically applying success, error, or disabled styles
|
|
123
|
+
const inputClasses = computed(() => ({
|
|
124
|
+
'input-checkbox': true,
|
|
125
|
+
'input-success': props.success, // Success state class
|
|
126
|
+
'input-error': props.error, // Error state class
|
|
127
|
+
'input-disabled': props.disabled, // Disabled state class
|
|
128
|
+
[`density-${props.density}`]: true, // Density class (comfortable, default, or compact)
|
|
129
|
+
}));
|
|
130
|
+
</script>
|