daisy-ui-kit 5.0.0-pre.3 → 5.0.0-pre.31
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/app/components/Accordion.vue +29 -0
- package/app/components/Alert.vue +36 -0
- package/app/components/Avatar.vue +131 -0
- package/app/components/AvatarGroup.vue +22 -0
- package/app/components/Badge.vue +72 -0
- package/app/components/Breadcrumbs.vue +7 -0
- package/app/components/Button.vue +140 -0
- package/app/components/Calendar.vue +175 -0
- package/app/components/CalendarInput.vue +275 -0
- package/app/components/CalendarSkeleton.vue +87 -0
- package/app/components/Card.vue +51 -0
- package/app/components/CardActions.vue +13 -0
- package/app/components/CardBody.vue +13 -0
- package/app/components/CardTitle.vue +11 -0
- package/app/components/Carousel.vue +24 -0
- package/app/components/CarouselItem.vue +5 -0
- package/app/components/Chat.vue +26 -0
- package/app/components/ChatBubble.vue +31 -0
- package/app/components/ChatFooter.vue +5 -0
- package/app/components/ChatHeader.vue +5 -0
- package/app/components/ChatImage.vue +5 -0
- package/app/components/Checkbox.vue +51 -0
- package/app/components/Collapse.vue +76 -0
- package/app/components/CollapseContent.vue +5 -0
- package/app/components/CollapseTitle.vue +15 -0
- package/app/components/Countdown.vue +15 -0
- package/app/components/CountdownTimers.vue +69 -0
- package/app/components/Counter.vue +21 -0
- package/app/components/Crumb.vue +5 -0
- package/app/components/DaisyLink.vue +56 -0
- package/app/components/Diff.vue +11 -0
- package/app/components/Divider.vue +43 -0
- package/app/components/Dock.vue +57 -0
- package/app/components/DockItem.vue +27 -0
- package/app/components/DockLabel.vue +5 -0
- package/app/components/Drawer.vue +50 -0
- package/app/components/DrawerContent.vue +20 -0
- package/app/components/DrawerSide.vue +21 -0
- package/app/components/Dropdown.vue +106 -0
- package/app/components/DropdownButton.vue +23 -0
- package/app/components/DropdownContent.vue +127 -0
- package/app/components/DropdownTarget.vue +21 -0
- package/app/components/Fab.vue +16 -0
- package/app/components/FabClose.vue +18 -0
- package/app/components/FabMainAction.vue +5 -0
- package/app/components/FabTrigger.vue +117 -0
- package/app/components/Fieldset.vue +20 -0
- package/app/components/FileInput.vue +53 -0
- package/app/components/Filter.vue +129 -0
- package/app/components/Flex.vue +89 -0
- package/app/components/FlexItem.vue +62 -0
- package/app/components/Footer.vue +31 -0
- package/app/components/FooterTitle.vue +18 -0
- package/app/components/FormControl.vue +5 -0
- package/app/components/Hero.vue +18 -0
- package/app/components/HeroContent.vue +18 -0
- package/app/components/HeroOverlay.vue +5 -0
- package/app/components/Hover3D.vue +22 -0
- package/app/components/HoverGallery.vue +11 -0
- package/app/components/Indicator.vue +20 -0
- package/app/components/IndicatorItem.vue +43 -0
- package/app/components/Input.vue +116 -0
- package/app/components/Join.vue +5 -0
- package/app/components/Kbd.vue +25 -0
- package/app/components/Label.vue +100 -0
- package/app/components/List.vue +5 -0
- package/app/components/ListColGrow.vue +5 -0
- package/app/components/ListColWrap.vue +5 -0
- package/app/components/ListRow.vue +5 -0
- package/app/components/LoadingBall.vue +42 -0
- package/app/components/LoadingBars.vue +42 -0
- package/app/components/LoadingDots.vue +42 -0
- package/app/components/LoadingInfinity.vue +42 -0
- package/app/components/LoadingRing.vue +42 -0
- package/app/components/LoadingSpinner.vue +42 -0
- package/app/components/Mask.vue +49 -0
- package/app/components/Menu.vue +30 -0
- package/app/components/MenuExpand.vue +92 -0
- package/app/components/MenuExpandToggle.vue +20 -0
- package/app/components/MenuItem.vue +39 -0
- package/app/components/MenuTitle.vue +5 -0
- package/app/components/MockupBrowser.vue +5 -0
- package/app/components/MockupBrowserToolbar.vue +5 -0
- package/app/components/MockupCode.vue +4 -0
- package/app/components/MockupPhone.vue +14 -0
- package/app/components/MockupWindow.vue +5 -0
- package/app/components/Modal.vue +63 -0
- package/app/components/ModalAction.vue +5 -0
- package/app/components/ModalBox.vue +5 -0
- package/app/components/NavButton.vue +12 -0
- package/app/components/Navbar.vue +12 -0
- package/app/components/NavbarCenter.vue +11 -0
- package/app/components/NavbarEnd.vue +11 -0
- package/app/components/NavbarStart.vue +11 -0
- package/app/components/Progress.vue +46 -0
- package/app/components/Prose.vue +37 -0
- package/app/components/RadialProgress.vue +36 -0
- package/app/components/Radio.vue +69 -0
- package/app/components/RadioGroup.vue +47 -0
- package/app/components/Range.vue +201 -0
- package/app/components/RangeMeasure.vue +87 -0
- package/app/components/RangeMeasureTick.vue +69 -0
- package/app/components/Rating.vue +197 -0
- package/app/components/Select.vue +101 -0
- package/app/components/Skeleton.vue +5 -0
- package/app/components/SkeletonText.vue +11 -0
- package/app/components/Stack.vue +30 -0
- package/app/components/Stat.vue +19 -0
- package/app/components/StatActions.vue +5 -0
- package/app/components/StatDesc.vue +5 -0
- package/app/components/StatFigure.vue +5 -0
- package/app/components/StatTitle.vue +5 -0
- package/app/components/StatValue.vue +5 -0
- package/app/components/Stats.vue +5 -0
- package/app/components/Status.vue +43 -0
- package/app/components/Step.vue +34 -0
- package/app/components/StepIcon.vue +5 -0
- package/app/components/Steps.vue +23 -0
- package/app/components/Swap.vue +56 -0
- package/app/components/Tab.vue +56 -0
- package/app/components/TabContent.vue +29 -0
- package/app/components/Table.vue +32 -0
- package/app/components/Tabs.vue +53 -0
- package/app/components/Text.vue +166 -0
- package/app/components/TextArea.vue +106 -0
- package/app/components/TextRotate.vue +24 -0
- package/app/components/ThemeController.vue +45 -0
- package/app/components/ThemeProvider.vue +302 -0
- package/app/components/ThemeTile.vue +50 -0
- package/app/components/Timeline.vue +22 -0
- package/app/components/TimelineEnd.vue +14 -0
- package/app/components/TimelineItem.vue +5 -0
- package/app/components/TimelineLine.vue +29 -0
- package/app/components/TimelineMiddle.vue +5 -0
- package/app/components/TimelineStart.vue +14 -0
- package/app/components/Toast.vue +67 -0
- package/app/components/Toggle.vue +60 -0
- package/app/components/Tooltip.vue +137 -0
- package/app/components/TooltipContent.vue +283 -0
- package/app/components/TooltipTarget.vue +20 -0
- package/app/components/ValidatorHint.vue +5 -0
- package/app/composables/__tests__/use-calendar.test.ts +239 -0
- package/app/composables/use-calendar.ts +288 -0
- package/app/composables/use-daisy-theme.ts +140 -0
- package/app/composables/use-toast.ts +345 -0
- package/app/composables/useSearch.ts +22 -0
- package/app/utils/drawer-utils.ts +34 -0
- package/app/utils/position-area.ts +40 -0
- package/nuxt.d.ts +13 -0
- package/nuxt.js +31 -0
- package/package.json +50 -22
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { provide, ref, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{
|
|
5
|
+
modelValue?: string | number
|
|
6
|
+
}>()
|
|
7
|
+
const emit = defineEmits(['update:modelValue'])
|
|
8
|
+
|
|
9
|
+
const value = ref(props.modelValue)
|
|
10
|
+
watch(
|
|
11
|
+
() => props.modelValue,
|
|
12
|
+
val => {
|
|
13
|
+
value.value = val
|
|
14
|
+
},
|
|
15
|
+
)
|
|
16
|
+
watch(value, val => {
|
|
17
|
+
if (props.modelValue !== val) {
|
|
18
|
+
emit('update:modelValue', val)
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
provide('accordion-value', value)
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<div class="daisy-ui-kit-accordion">
|
|
27
|
+
<slot />
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
outline?: boolean
|
|
4
|
+
dash?: boolean
|
|
5
|
+
soft?: boolean
|
|
6
|
+
type?: 'info' | 'success' | 'warning' | 'error'
|
|
7
|
+
info?: boolean
|
|
8
|
+
success?: boolean
|
|
9
|
+
warning?: boolean
|
|
10
|
+
error?: boolean
|
|
11
|
+
orientation?: 'vertical' | 'horizontal'
|
|
12
|
+
vertical?: boolean
|
|
13
|
+
horizontal?: boolean
|
|
14
|
+
}>()
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<div
|
|
19
|
+
class="alert"
|
|
20
|
+
:class="{
|
|
21
|
+
'alert-outline': props.outline,
|
|
22
|
+
'alert-dash': props.dash,
|
|
23
|
+
'alert-soft': props.soft,
|
|
24
|
+
|
|
25
|
+
'alert-info': props.info || props.type === 'info',
|
|
26
|
+
'alert-success': props.success || props.type === 'success',
|
|
27
|
+
'alert-warning': props.warning || props.type === 'warning',
|
|
28
|
+
'alert-error': props.error || props.type === 'error',
|
|
29
|
+
|
|
30
|
+
'alert-vertical': props.vertical || props.orientation === 'vertical',
|
|
31
|
+
'alert-horizontal': props.horizontal || props.orientation === 'horizontal',
|
|
32
|
+
}"
|
|
33
|
+
>
|
|
34
|
+
<slot />
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import Mask from './Mask.vue'
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
backgroundColor: { type: String, default: '#BBB' },
|
|
7
|
+
maskClasses: String,
|
|
8
|
+
showStatus: Boolean,
|
|
9
|
+
// Presence props
|
|
10
|
+
presence: String,
|
|
11
|
+
online: Boolean,
|
|
12
|
+
offline: Boolean,
|
|
13
|
+
// Mask shape props (self-contained, no Mask.config.ts dependency)
|
|
14
|
+
shape: String,
|
|
15
|
+
squircle: Boolean,
|
|
16
|
+
heart: Boolean,
|
|
17
|
+
hexagon: Boolean,
|
|
18
|
+
hexagon2: Boolean,
|
|
19
|
+
decagon: Boolean,
|
|
20
|
+
pentagon: Boolean,
|
|
21
|
+
diamond: Boolean,
|
|
22
|
+
square: Boolean,
|
|
23
|
+
circle: Boolean,
|
|
24
|
+
star: Boolean,
|
|
25
|
+
star2: Boolean,
|
|
26
|
+
triangle: Boolean,
|
|
27
|
+
triangle2: Boolean,
|
|
28
|
+
triangle3: Boolean,
|
|
29
|
+
triangle4: Boolean,
|
|
30
|
+
half1: Boolean,
|
|
31
|
+
half2: Boolean,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const maskShapeKeys = [
|
|
35
|
+
'mask-squircle',
|
|
36
|
+
'mask-heart',
|
|
37
|
+
'mask-hexagon',
|
|
38
|
+
'mask-hexagon-2',
|
|
39
|
+
'mask-decagon',
|
|
40
|
+
'mask-pentagon',
|
|
41
|
+
'mask-diamond',
|
|
42
|
+
'mask-square',
|
|
43
|
+
'mask-circle',
|
|
44
|
+
'mask-star',
|
|
45
|
+
'mask-star-2',
|
|
46
|
+
'mask-triangle',
|
|
47
|
+
'mask-triangle-2',
|
|
48
|
+
'mask-triangle-3',
|
|
49
|
+
'mask-triangle-4',
|
|
50
|
+
'mask-half-1',
|
|
51
|
+
'mask-half-2',
|
|
52
|
+
] as const
|
|
53
|
+
|
|
54
|
+
type AvatarClassKey = (typeof maskShapeKeys)[number] | 'rounded-box' | 'avatar-online' | 'avatar-offline'
|
|
55
|
+
|
|
56
|
+
const avatarClasses = computed<Record<AvatarClassKey, boolean>>(() => {
|
|
57
|
+
const mask: Record<AvatarClassKey, boolean> = {
|
|
58
|
+
'mask-squircle': props.squircle || props.shape === 'squircle',
|
|
59
|
+
'mask-heart': props.heart || props.shape === 'heart',
|
|
60
|
+
'mask-hexagon': props.hexagon || props.shape === 'hexagon',
|
|
61
|
+
'mask-hexagon-2': props.hexagon2 || props.shape === 'hexagon-2',
|
|
62
|
+
'mask-decagon': props.decagon || props.shape === 'decagon',
|
|
63
|
+
'mask-pentagon': props.pentagon || props.shape === 'pentagon',
|
|
64
|
+
'mask-diamond': props.diamond || props.shape === 'diamond',
|
|
65
|
+
'mask-square': props.square || props.shape === 'square',
|
|
66
|
+
'mask-circle': props.circle || props.shape === 'circle',
|
|
67
|
+
'mask-star': props.star || props.shape === 'star',
|
|
68
|
+
'mask-star-2': props.star2 || props.shape === 'star-2',
|
|
69
|
+
'mask-triangle': props.triangle || props.shape === 'triangle',
|
|
70
|
+
'mask-triangle-2': props.triangle2 || props.shape === 'triangle-2',
|
|
71
|
+
'mask-triangle-3': props.triangle3 || props.shape === 'triangle-3',
|
|
72
|
+
'mask-triangle-4': props.triangle4 || props.shape === 'triangle-4',
|
|
73
|
+
'mask-half-1': props.half1 || props.shape === 'half-1',
|
|
74
|
+
'mask-half-2': props.half2 || props.shape === 'half-2',
|
|
75
|
+
'rounded-box': false,
|
|
76
|
+
'avatar-online': props.presence === 'online' || props.online,
|
|
77
|
+
'avatar-offline': props.presence === 'offline' || props.offline,
|
|
78
|
+
}
|
|
79
|
+
const hasMask = maskShapeKeys.some(k => mask[k])
|
|
80
|
+
mask['rounded-box'] = !hasMask
|
|
81
|
+
return mask
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const color = computed(() => {
|
|
85
|
+
return `#${contrastingColor(props.backgroundColor.replace('#', ''))}`
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
function contrastingColor(color: any) {
|
|
89
|
+
return luma(color) >= 155 ? '000' : 'fff'
|
|
90
|
+
}
|
|
91
|
+
// color can be a hx string or an array of RGB values 0-255
|
|
92
|
+
function luma(color: any) {
|
|
93
|
+
const rgb = typeof color === 'string' ? hexToRGBArray(color) : color
|
|
94
|
+
return 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2] // SMPTE C, Rec. 709 weightings
|
|
95
|
+
}
|
|
96
|
+
function hexToRGBArray(color: any) {
|
|
97
|
+
if (color.length === 3) {
|
|
98
|
+
color = color.charAt(0) + color.charAt(0) + color.charAt(1) + color.charAt(1) + color.charAt(2) + color.charAt(2)
|
|
99
|
+
} else if (color.length !== 6) {
|
|
100
|
+
throw new Error(`Invalid hex color: ${color}`)
|
|
101
|
+
}
|
|
102
|
+
const rgb = []
|
|
103
|
+
for (let i = 0; i <= 2; i++) {
|
|
104
|
+
rgb[i] = Number.parseInt(color.substr(i * 2, 2), 16)
|
|
105
|
+
}
|
|
106
|
+
return rgb
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<template>
|
|
111
|
+
<div class="avatar">
|
|
112
|
+
<Mask
|
|
113
|
+
:style="{ backgroundColor, color }"
|
|
114
|
+
class="w-full h-full avatar-mask aspect-square"
|
|
115
|
+
:class="[avatarClasses, maskClasses]"
|
|
116
|
+
>
|
|
117
|
+
<slot />
|
|
118
|
+
</Mask>
|
|
119
|
+
</div>
|
|
120
|
+
</template>
|
|
121
|
+
|
|
122
|
+
<style lang="postcss">
|
|
123
|
+
.avatar-mask > * {
|
|
124
|
+
aspect-ratio: 1/1;
|
|
125
|
+
width: 100%;
|
|
126
|
+
height: 100%;
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
}
|
|
131
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
orientation: string
|
|
4
|
+
horizontal: boolean
|
|
5
|
+
vertical: boolean
|
|
6
|
+
}>()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div
|
|
11
|
+
class="avatar-group"
|
|
12
|
+
:class="{
|
|
13
|
+
'flex-row':
|
|
14
|
+
props.orientation === 'horizontal' ||
|
|
15
|
+
props.horizontal ||
|
|
16
|
+
(!props.orientation && !props.vertical && !props.horizontal),
|
|
17
|
+
'flex-col': props.orientation === 'vertical' || props.vertical,
|
|
18
|
+
}"
|
|
19
|
+
>
|
|
20
|
+
<slot />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, resolveComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineOptions({
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
const { is = 'div', ...props } = defineProps<{
|
|
9
|
+
is?: string
|
|
10
|
+
outline?: boolean
|
|
11
|
+
soft?: boolean
|
|
12
|
+
dash?: boolean
|
|
13
|
+
ghost?: boolean
|
|
14
|
+
|
|
15
|
+
size?: string
|
|
16
|
+
xl?: boolean
|
|
17
|
+
lg?: boolean
|
|
18
|
+
md?: boolean
|
|
19
|
+
sm?: boolean
|
|
20
|
+
xs?: boolean
|
|
21
|
+
|
|
22
|
+
color?: string
|
|
23
|
+
neutral?: boolean
|
|
24
|
+
primary?: boolean
|
|
25
|
+
secondary?: boolean
|
|
26
|
+
accent?: boolean
|
|
27
|
+
info?: boolean
|
|
28
|
+
success?: boolean
|
|
29
|
+
warning?: boolean
|
|
30
|
+
error?: boolean
|
|
31
|
+
}>()
|
|
32
|
+
|
|
33
|
+
const NuxtLink = resolveComponent('NuxtLink')
|
|
34
|
+
const RouterLink = resolveComponent('RouterLink')
|
|
35
|
+
|
|
36
|
+
const resolvedComponent = computed(() => {
|
|
37
|
+
if (is === 'NuxtLink') return NuxtLink
|
|
38
|
+
if (is === 'RouterLink') return RouterLink
|
|
39
|
+
return is
|
|
40
|
+
})
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<component
|
|
45
|
+
:is="resolvedComponent"
|
|
46
|
+
v-bind="$attrs"
|
|
47
|
+
class="badge"
|
|
48
|
+
:class="{
|
|
49
|
+
'badge-outline': props.outline,
|
|
50
|
+
'badge-ghost': props.ghost,
|
|
51
|
+
'badge-soft': props.soft,
|
|
52
|
+
'badge-dash': props.dash,
|
|
53
|
+
|
|
54
|
+
'badge-xl': props.xl || props.size === 'xl',
|
|
55
|
+
'badge-lg': props.lg || props.size === 'lg',
|
|
56
|
+
'badge-md': props.md || props.size === 'md',
|
|
57
|
+
'badge-sm': props.sm || props.size === 'sm',
|
|
58
|
+
'badge-xs': props.xs || props.size === 'xs',
|
|
59
|
+
|
|
60
|
+
'badge-neutral': props.neutral || props.color === 'neutral',
|
|
61
|
+
'badge-primary': props.primary || props.color === 'primary',
|
|
62
|
+
'badge-secondary': props.secondary || props.color === 'secondary',
|
|
63
|
+
'badge-accent': props.accent || props.color === 'accent',
|
|
64
|
+
'badge-info': props.info || props.color === 'info',
|
|
65
|
+
'badge-success': props.success || props.color === 'success',
|
|
66
|
+
'badge-warning': props.warning || props.color === 'warning',
|
|
67
|
+
'badge-error': props.error || props.color === 'error',
|
|
68
|
+
}"
|
|
69
|
+
>
|
|
70
|
+
<slot />
|
|
71
|
+
</component>
|
|
72
|
+
</template>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, resolveComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineOptions({
|
|
5
|
+
inheritAttrs: false,
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
const props = withDefaults(
|
|
9
|
+
defineProps<{
|
|
10
|
+
is?: string
|
|
11
|
+
join?: boolean
|
|
12
|
+
|
|
13
|
+
color?: string
|
|
14
|
+
neutral?: boolean
|
|
15
|
+
primary?: boolean
|
|
16
|
+
secondary?: boolean
|
|
17
|
+
accent?: boolean
|
|
18
|
+
info?: boolean
|
|
19
|
+
success?: boolean
|
|
20
|
+
warning?: boolean
|
|
21
|
+
error?: boolean
|
|
22
|
+
|
|
23
|
+
ghost?: boolean
|
|
24
|
+
link?: boolean
|
|
25
|
+
glass?: boolean
|
|
26
|
+
outline?: boolean
|
|
27
|
+
dash?: boolean
|
|
28
|
+
soft?: boolean
|
|
29
|
+
disabled?: boolean
|
|
30
|
+
|
|
31
|
+
shape?: 'circle' | 'square' | 'wide' | 'block'
|
|
32
|
+
circle?: boolean
|
|
33
|
+
square?: boolean
|
|
34
|
+
wide?: boolean
|
|
35
|
+
block?: boolean
|
|
36
|
+
|
|
37
|
+
noAnimation?: boolean
|
|
38
|
+
active?: boolean
|
|
39
|
+
|
|
40
|
+
size?: 'lg' | 'md' | 'sm' | 'xs' | 'xl'
|
|
41
|
+
xl?: boolean
|
|
42
|
+
lg?: boolean
|
|
43
|
+
md?: boolean
|
|
44
|
+
sm?: boolean
|
|
45
|
+
xs?: boolean
|
|
46
|
+
|
|
47
|
+
type?: 'button' | 'submit' | 'reset'
|
|
48
|
+
}>(),
|
|
49
|
+
{
|
|
50
|
+
type: 'button',
|
|
51
|
+
},
|
|
52
|
+
)
|
|
53
|
+
const NuxtLink = resolveComponent('NuxtLink')
|
|
54
|
+
const RouterLink = resolveComponent('RouterLink')
|
|
55
|
+
|
|
56
|
+
// Accessibility: Determine if rendering a native button
|
|
57
|
+
const isButton = computed(() => (props.is || 'button') === 'button')
|
|
58
|
+
|
|
59
|
+
// Resolve the component to render
|
|
60
|
+
const resolvedComponent = computed(() => {
|
|
61
|
+
if (!props.is || props.is === 'button' || props.is === 'a') {
|
|
62
|
+
return props.is || 'button'
|
|
63
|
+
}
|
|
64
|
+
if (props.is === 'NuxtLink') return NuxtLink
|
|
65
|
+
if (props.is === 'RouterLink') return RouterLink
|
|
66
|
+
return props.is
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// Accessibility: Keyboard event handler for custom elements
|
|
70
|
+
function onKeydown(e: KeyboardEvent) {
|
|
71
|
+
if (props.disabled) {
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
if (e.code === 'Space' || e.code === 'Enter' || e.key === ' ' || e.key === 'Enter') {
|
|
75
|
+
e.preventDefault()
|
|
76
|
+
// @ts-expect-error: $el may not exist yet
|
|
77
|
+
e.currentTarget?.click?.()
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<template>
|
|
83
|
+
<component
|
|
84
|
+
:is="resolvedComponent"
|
|
85
|
+
v-bind="$attrs"
|
|
86
|
+
:type="isButton ? type : undefined"
|
|
87
|
+
:disabled="isButton && disabled ? true : undefined"
|
|
88
|
+
:aria-disabled="!isButton && disabled ? true : undefined"
|
|
89
|
+
:tabindex="!isButton ? (disabled ? -1 : 0) : undefined"
|
|
90
|
+
:role="!isButton ? 'button' : undefined"
|
|
91
|
+
class="btn"
|
|
92
|
+
:class="{
|
|
93
|
+
'join-item': join,
|
|
94
|
+
|
|
95
|
+
'btn-neutral': !disabled && (neutral || color === 'neutral'),
|
|
96
|
+
'btn-primary': !disabled && (primary || color === 'primary'),
|
|
97
|
+
'btn-secondary': !disabled && (secondary || color === 'secondary'),
|
|
98
|
+
'btn-accent': !disabled && (accent || color === 'accent'),
|
|
99
|
+
'btn-info': !disabled && (info || color === 'info'),
|
|
100
|
+
'btn-success': !disabled && (success || color === 'success'),
|
|
101
|
+
'btn-warning': !disabled && (warning || color === 'warning'),
|
|
102
|
+
'btn-error': !disabled && (error || color === 'error'),
|
|
103
|
+
|
|
104
|
+
'text-primary': !disabled && (primary || color === 'primary') && link,
|
|
105
|
+
'text-secondary': !disabled && (secondary || color === 'secondary') && link,
|
|
106
|
+
'text-neutral': !disabled && (neutral || color === 'neutral') && link,
|
|
107
|
+
'text-accent': !disabled && (accent || color === 'accent') && link,
|
|
108
|
+
'text-info': !disabled && (info || color === 'info') && link,
|
|
109
|
+
'text-success': !disabled && (success || color === 'success') && link,
|
|
110
|
+
'text-warning': !disabled && (warning || color === 'warning') && link,
|
|
111
|
+
'text-error': !disabled && (error || color === 'error') && link,
|
|
112
|
+
|
|
113
|
+
glass: !disabled && glass,
|
|
114
|
+
|
|
115
|
+
'btn-circle': circle || shape === 'circle',
|
|
116
|
+
'btn-square': square || shape === 'square',
|
|
117
|
+
'btn-wide': wide || shape === 'wide',
|
|
118
|
+
'btn-block': block || shape === 'block',
|
|
119
|
+
|
|
120
|
+
'btn-xl': xl || size === 'xl',
|
|
121
|
+
'btn-lg': lg || size === 'lg',
|
|
122
|
+
'btn-md': md || size === 'md',
|
|
123
|
+
'btn-sm': sm || size === 'sm',
|
|
124
|
+
'btn-xs': xs || size === 'xs',
|
|
125
|
+
|
|
126
|
+
'btn-outline': !disabled && outline,
|
|
127
|
+
'btn-dash': !disabled && dash,
|
|
128
|
+
'btn-ghost': !disabled && ghost,
|
|
129
|
+
'btn-soft': !disabled && soft,
|
|
130
|
+
'btn-link': !disabled && link,
|
|
131
|
+
'btn-disabled': disabled,
|
|
132
|
+
|
|
133
|
+
'no-animation': noAnimation,
|
|
134
|
+
'btn-active': !disabled && active,
|
|
135
|
+
}"
|
|
136
|
+
@keydown="!isButton ? onKeydown : undefined"
|
|
137
|
+
>
|
|
138
|
+
<slot />
|
|
139
|
+
</component>
|
|
140
|
+
</template>
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { CalendarOptions } from '../composables/use-calendar'
|
|
3
|
+
import { computed, watch } from 'vue'
|
|
4
|
+
import { useCalendar } from '../composables/use-calendar'
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
/** Bound value: Date object or ISO string or null */
|
|
8
|
+
modelValue?: Date | string | null
|
|
9
|
+
/** Calendar options */
|
|
10
|
+
options?: CalendarOptions
|
|
11
|
+
/** If true, default to today when no value provided */
|
|
12
|
+
autoDefault?: boolean
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits<{
|
|
16
|
+
(e: 'update:modelValue', v: Date | null): void
|
|
17
|
+
}>()
|
|
18
|
+
|
|
19
|
+
// Parse initial date from modelValue
|
|
20
|
+
function parseDate(value: Date | string | null | undefined): Date | null {
|
|
21
|
+
if (!value) return null
|
|
22
|
+
if (value instanceof Date) return value
|
|
23
|
+
const d = new Date(value)
|
|
24
|
+
return Number.isNaN(d.getTime()) ? null : d
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const initialDate = computed(() => {
|
|
28
|
+
const parsed = parseDate(props.modelValue)
|
|
29
|
+
if (parsed) return parsed
|
|
30
|
+
if (props.autoDefault) return new Date()
|
|
31
|
+
return null
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
selectedDate,
|
|
36
|
+
viewMonth,
|
|
37
|
+
viewYear,
|
|
38
|
+
monthName,
|
|
39
|
+
weekdayHeaders,
|
|
40
|
+
weekdayHeadersFull,
|
|
41
|
+
calendarDays,
|
|
42
|
+
prevMonth,
|
|
43
|
+
nextMonth,
|
|
44
|
+
selectDate,
|
|
45
|
+
goToDate,
|
|
46
|
+
} = useCalendar(initialDate.value, props.options)
|
|
47
|
+
|
|
48
|
+
// Sync selectedDate back to modelValue
|
|
49
|
+
watch(selectedDate, date => {
|
|
50
|
+
emit('update:modelValue', date)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// Watch for external modelValue changes
|
|
54
|
+
watch(
|
|
55
|
+
() => props.modelValue,
|
|
56
|
+
newValue => {
|
|
57
|
+
const parsed = parseDate(newValue)
|
|
58
|
+
if (parsed && (!selectedDate.value || parsed.getTime() !== selectedDate.value.getTime())) {
|
|
59
|
+
selectDate(parsed)
|
|
60
|
+
goToDate(parsed)
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
function handleDayClick(day: (typeof calendarDays.value)[0]) {
|
|
66
|
+
if (day.isDisabled) return
|
|
67
|
+
selectDate(day.date)
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<template>
|
|
72
|
+
<div class="pika-single">
|
|
73
|
+
<div class="pika-lendar">
|
|
74
|
+
<!-- Header with navigation -->
|
|
75
|
+
<div class="pika-title">
|
|
76
|
+
<div class="pika-label">
|
|
77
|
+
{{ monthName }}
|
|
78
|
+
<select
|
|
79
|
+
class="pika-select pika-select-month"
|
|
80
|
+
:value="viewMonth"
|
|
81
|
+
@change="
|
|
82
|
+
e => {
|
|
83
|
+
const target = e.target as HTMLSelectElement
|
|
84
|
+
const newMonth = parseInt(target.value, 10)
|
|
85
|
+
const d = new Date(viewYear, newMonth, 1)
|
|
86
|
+
goToDate(d)
|
|
87
|
+
}
|
|
88
|
+
"
|
|
89
|
+
>
|
|
90
|
+
<option
|
|
91
|
+
v-for="(m, i) in [
|
|
92
|
+
'January',
|
|
93
|
+
'February',
|
|
94
|
+
'March',
|
|
95
|
+
'April',
|
|
96
|
+
'May',
|
|
97
|
+
'June',
|
|
98
|
+
'July',
|
|
99
|
+
'August',
|
|
100
|
+
'September',
|
|
101
|
+
'October',
|
|
102
|
+
'November',
|
|
103
|
+
'December',
|
|
104
|
+
]"
|
|
105
|
+
:key="i"
|
|
106
|
+
:value="i"
|
|
107
|
+
>
|
|
108
|
+
{{ m }}
|
|
109
|
+
</option>
|
|
110
|
+
</select>
|
|
111
|
+
</div>
|
|
112
|
+
<div class="pika-label">
|
|
113
|
+
{{ viewYear }}
|
|
114
|
+
<select
|
|
115
|
+
class="pika-select pika-select-year"
|
|
116
|
+
:value="viewYear"
|
|
117
|
+
@change="
|
|
118
|
+
e => {
|
|
119
|
+
const target = e.target as HTMLSelectElement
|
|
120
|
+
const newYear = parseInt(target.value, 10)
|
|
121
|
+
const d = new Date(newYear, viewMonth, 1)
|
|
122
|
+
goToDate(d)
|
|
123
|
+
}
|
|
124
|
+
"
|
|
125
|
+
>
|
|
126
|
+
<option v-for="y in Array.from({ length: 21 }, (_, i) => viewYear - 10 + i)" :key="y" :value="y">
|
|
127
|
+
{{ y }}
|
|
128
|
+
</option>
|
|
129
|
+
</select>
|
|
130
|
+
</div>
|
|
131
|
+
<button type="button" class="pika-prev" @click="prevMonth">Previous Month</button>
|
|
132
|
+
<button type="button" class="pika-next" @click="nextMonth">Next Month</button>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
<!-- Calendar grid -->
|
|
136
|
+
<table class="pika-table" role="grid">
|
|
137
|
+
<thead>
|
|
138
|
+
<tr>
|
|
139
|
+
<th v-for="(day, i) in weekdayHeaders" :key="i" scope="col">
|
|
140
|
+
<abbr :title="weekdayHeadersFull[i]">{{ day }}</abbr>
|
|
141
|
+
</th>
|
|
142
|
+
</tr>
|
|
143
|
+
</thead>
|
|
144
|
+
<tbody>
|
|
145
|
+
<tr v-for="week in 6" :key="week" class="pika-row">
|
|
146
|
+
<td
|
|
147
|
+
v-for="dayIndex in 7"
|
|
148
|
+
:key="dayIndex"
|
|
149
|
+
:class="{
|
|
150
|
+
'is-today': calendarDays[(week - 1) * 7 + dayIndex - 1]?.isToday,
|
|
151
|
+
'is-selected': calendarDays[(week - 1) * 7 + dayIndex - 1]?.isSelected,
|
|
152
|
+
'is-disabled': calendarDays[(week - 1) * 7 + dayIndex - 1]?.isDisabled,
|
|
153
|
+
'is-outside-current-month': calendarDays[(week - 1) * 7 + dayIndex - 1]?.isOutsideMonth,
|
|
154
|
+
}"
|
|
155
|
+
:aria-selected="calendarDays[(week - 1) * 7 + dayIndex - 1]?.isSelected"
|
|
156
|
+
:data-day="calendarDays[(week - 1) * 7 + dayIndex - 1]?.day"
|
|
157
|
+
>
|
|
158
|
+
<button
|
|
159
|
+
type="button"
|
|
160
|
+
class="pika-button pika-day"
|
|
161
|
+
:disabled="calendarDays[(week - 1) * 7 + dayIndex - 1]?.isDisabled"
|
|
162
|
+
:data-pika-year="calendarDays[(week - 1) * 7 + dayIndex - 1]?.year"
|
|
163
|
+
:data-pika-month="calendarDays[(week - 1) * 7 + dayIndex - 1]?.month"
|
|
164
|
+
:data-pika-day="calendarDays[(week - 1) * 7 + dayIndex - 1]?.day"
|
|
165
|
+
@click="handleDayClick(calendarDays[(week - 1) * 7 + dayIndex - 1]!)"
|
|
166
|
+
>
|
|
167
|
+
{{ calendarDays[(week - 1) * 7 + dayIndex - 1]?.day }}
|
|
168
|
+
</button>
|
|
169
|
+
</td>
|
|
170
|
+
</tr>
|
|
171
|
+
</tbody>
|
|
172
|
+
</table>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
</template>
|