daisy-ui-kit 5.0.0-pre.9 → 5.0.1

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.
Files changed (94) hide show
  1. package/README.md +277 -48
  2. package/app/components/Accordion.vue +8 -5
  3. package/app/components/Alert.vue +2 -1
  4. package/app/components/Avatar.vue +10 -7
  5. package/app/components/AvatarGroup.vue +6 -2
  6. package/app/components/Badge.vue +19 -1
  7. package/app/components/Button.vue +66 -46
  8. package/app/components/Calendar.vue +151 -42
  9. package/app/components/CalendarInput.vue +229 -130
  10. package/app/components/CalendarSkeleton.vue +51 -10
  11. package/app/components/Card.vue +20 -2
  12. package/app/components/CardActions.vue +1 -1
  13. package/app/components/CardBody.vue +1 -1
  14. package/app/components/CardTitle.vue +1 -1
  15. package/app/components/Carousel.vue +2 -1
  16. package/app/components/Chat.vue +6 -1
  17. package/app/components/Checkbox.vue +1 -1
  18. package/app/components/Collapse.vue +38 -5
  19. package/app/components/CollapseTitle.vue +11 -1
  20. package/app/components/Countdown.vue +3 -3
  21. package/app/components/CountdownTimers.vue +4 -7
  22. package/app/components/Counter.vue +14 -3
  23. package/app/components/DaisyLink.vue +33 -15
  24. package/app/components/Dock.vue +5 -6
  25. package/app/components/DockItem.vue +5 -3
  26. package/app/components/Drawer.vue +15 -12
  27. package/app/components/DrawerContent.vue +9 -6
  28. package/app/components/DrawerSide.vue +9 -6
  29. package/app/components/Dropdown.vue +61 -50
  30. package/app/components/DropdownButton.vue +11 -4
  31. package/app/components/DropdownContent.vue +90 -20
  32. package/app/components/DropdownTarget.vue +10 -3
  33. package/app/components/Fab.vue +16 -0
  34. package/app/components/FabClose.vue +18 -0
  35. package/app/components/FabMainAction.vue +5 -0
  36. package/app/components/FabTrigger.vue +117 -0
  37. package/app/components/Fieldset.vue +5 -4
  38. package/app/components/FileInput.vue +1 -1
  39. package/app/components/Filter.vue +45 -38
  40. package/app/components/Flex.vue +8 -1
  41. package/app/components/FlexItem.vue +30 -27
  42. package/app/components/Footer.vue +16 -12
  43. package/app/components/FooterTitle.vue +8 -5
  44. package/app/components/Hero.vue +9 -6
  45. package/app/components/HeroContent.vue +9 -6
  46. package/app/components/Hover3D.vue +22 -0
  47. package/app/components/HoverGallery.vue +11 -0
  48. package/app/components/Indicator.vue +12 -5
  49. package/app/components/IndicatorItem.vue +21 -14
  50. package/app/components/Input.vue +44 -47
  51. package/app/components/Kbd.vue +2 -1
  52. package/app/components/Label.vue +32 -29
  53. package/app/components/MenuExpand.vue +5 -13
  54. package/app/components/MenuExpandToggle.vue +7 -1
  55. package/app/components/MenuItem.vue +6 -4
  56. package/app/components/Modal.vue +23 -17
  57. package/app/components/Progress.vue +13 -1
  58. package/app/components/Prose.vue +7 -2
  59. package/app/components/RadialProgress.vue +8 -8
  60. package/app/components/Radio.vue +1 -1
  61. package/app/components/RadioGroup.vue +2 -2
  62. package/app/components/Range.vue +186 -46
  63. package/app/components/RangeMeasure.vue +33 -30
  64. package/app/components/RangeMeasureTick.vue +4 -5
  65. package/app/components/Rating.vue +70 -53
  66. package/app/components/Select.vue +44 -47
  67. package/app/components/SkeletonText.vue +11 -0
  68. package/app/components/Stack.vue +5 -0
  69. package/app/components/Steps.vue +7 -2
  70. package/app/components/Swap.vue +4 -10
  71. package/app/components/Tab.vue +23 -5
  72. package/app/components/Text.vue +47 -23
  73. package/app/components/TextArea.vue +75 -30
  74. package/app/components/TextRotate.vue +24 -0
  75. package/app/components/ThemeController.vue +3 -4
  76. package/app/components/ThemeProvider.vue +47 -32
  77. package/app/components/TimelineLine.vue +1 -1
  78. package/app/components/TimelineStart.vue +2 -1
  79. package/app/components/Toast.vue +3 -8
  80. package/app/components/Toggle.vue +2 -2
  81. package/app/components/Tooltip.vue +111 -21
  82. package/app/components/TooltipContent.vue +279 -1
  83. package/app/components/TooltipTarget.vue +20 -0
  84. package/app/composables/__tests__/use-calendar.test.ts +239 -0
  85. package/app/composables/use-calendar.ts +288 -0
  86. package/app/composables/use-daisy-theme.ts +140 -0
  87. package/app/composables/use-toast.ts +345 -0
  88. package/app/composables/useSearch.ts +22 -0
  89. package/app/utils/drawer-utils.ts +15 -13
  90. package/app/utils/position-area.ts +40 -0
  91. package/nuxt.d.ts +13 -0
  92. package/nuxt.js +12 -9
  93. package/package.json +34 -17
  94. package/app/utils/random-string.ts +0 -19
@@ -1,54 +1,69 @@
1
1
  <script setup lang="ts">
2
- import { autoUpdate, useFloating } from '@floating-ui/vue'
3
- import { onClickOutside, syncRefs, useElementHover } from '@vueuse/core'
4
- import { onMounted, provide, reactive, ref } from 'vue'
5
- import { randomString } from '../utils/random-string'
6
-
7
- const props = withDefaults(defineProps<{
8
- // allows passing a custom id to the dropdown. Required for SSR hydration.
9
- randomId?: string
10
- autoFocus?: boolean
11
-
12
- placement?: 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end'
13
- strategy?: 'fixed' | 'absolute'
14
-
15
- hover?: boolean
16
- delayEnter?: number
17
- delayLeave?: number
18
- closeOnClickOutside?: boolean
19
- }>(), {
20
- autoFocus: false,
21
- placement: 'bottom-start',
22
- hover: false,
23
- delayEnter: 0,
24
- delayLeave: 300,
25
- closeOnClickOutside: true,
26
- })
2
+ import { useId } from 'vue'
3
+ import { useElementHover } from '@vueuse/core'
4
+ import { onMounted, provide, ref, watch } from 'vue'
5
+
6
+ const props = withDefaults(
7
+ defineProps<{
8
+ autoFocus?: boolean
9
+
10
+ placement?:
11
+ | 'top'
12
+ | 'top-start'
13
+ | 'top-end'
14
+ | 'right'
15
+ | 'right-start'
16
+ | 'right-end'
17
+ | 'bottom'
18
+ | 'bottom-start'
19
+ | 'bottom-end'
20
+ | 'left'
21
+ | 'left-start'
22
+ | 'left-end'
23
+
24
+ hover?: boolean
25
+ delayEnter?: number
26
+ delayLeave?: number
27
+ closeOnClickOutside?: boolean
28
+ }>(),
29
+ {
30
+ autoFocus: false,
31
+ placement: 'bottom-start',
32
+ hover: false,
33
+ delayEnter: 0,
34
+ delayLeave: 300,
35
+ closeOnClickOutside: true,
36
+ },
37
+ )
38
+
27
39
  // Dropdown Visibility
28
- const isOpen = defineModel('open')
40
+ const isOpen = defineModel('open', { default: false })
29
41
  provide('isDropdownOpen', isOpen)
30
42
 
31
43
  const autoFocus = ref(props.autoFocus)
32
44
  provide('dropdownAutoFocus', autoFocus)
33
45
 
34
- const randomValue = props.randomId || randomString(12)
35
- const wrapperId = `dropdown-wrapper-${randomValue}`
36
- const id = `dropdown-${randomValue}`
46
+ // Use Nuxt's useId() for unique IDs
47
+ const uniqueId = useId()
48
+ const wrapperId = `dropdown-wrapper-${uniqueId}`
49
+ const id = `dropdown-${uniqueId}`
37
50
  provide('dropdownId', id)
38
51
 
39
- // set up the floating ui instance
52
+ // Provide placement for CSS anchor positioning
53
+ provide('dropdownPlacement', ref(props.placement))
54
+
55
+ // Provide closeOnClickOutside for popover mode selection
56
+ provide('dropdownCloseOnClickOutside', ref(props.closeOnClickOutside))
57
+
58
+ // Provide hover mode for button behavior
59
+ provide('dropdownHover', ref(props.hover))
60
+
61
+ // References
40
62
  const buttonEl = ref(null)
41
63
  const contentEl = ref(null)
42
- const floatingConfig = reactive({
43
- placement: ref(props.placement),
44
- strategy: ref(props.strategy),
45
- whileElementsMounted: autoUpdate,
46
- })
47
- const { floatingStyles } = useFloating(buttonEl, contentEl, floatingConfig)
48
64
 
49
65
  provide('buttonEl', buttonEl)
50
66
  provide('contentEl', contentEl)
51
- provide('floatingStyles', floatingStyles)
52
67
 
53
68
  // Visibility Utils
54
69
  function toggle() {
@@ -67,29 +82,25 @@ provide('closeDropdown', close)
67
82
  const dropdownWrapper = ref(null)
68
83
 
69
84
  onMounted(() => {
70
- // Close when clicking outside the element
71
- // use a slight delay to avoid conflict with the focus trap in the DropdownContent.
72
- onClickOutside(contentEl, () => {
73
- if (props.closeOnClickOutside) {
74
- setTimeout(() => {
75
- isOpen.value = false
76
- }, 50)
77
- }
78
- })
79
-
80
- // Sync with top-level isHovered ref. For SSR compatibility.
85
+ // Note: closeOnClickOutside is handled automatically by popover="auto"
86
+ // The popover API provides "light dismiss" behavior by default
87
+
88
+ // Sync with hover state for SSR compatibility
81
89
  if (props.hover) {
82
90
  const hover = useElementHover(dropdownWrapper, {
83
91
  delayLeave: props.delayLeave,
84
92
  delayEnter: props.delayEnter,
85
93
  })
86
- syncRefs(hover, isOpen)
94
+
95
+ watch(hover, newValue => {
96
+ isOpen.value = newValue
97
+ })
87
98
  }
88
99
  })
89
100
  </script>
90
101
 
91
102
  <template>
92
- <div :id="wrapperId" ref="dropdownWrapper" class="relative inline-block floating-dropdown">
103
+ <div :id="wrapperId" ref="dropdownWrapper" class="relative inline-block">
93
104
  <slot v-bind="{ toggle, open, close }" />
94
105
  </div>
95
106
  </template>
@@ -3,14 +3,21 @@ import { inject } from 'vue'
3
3
 
4
4
  const id = inject('dropdownId')
5
5
  const isOpen = inject('isDropdownOpen')
6
- const toggleDropdown = inject('toggleDropdown')
7
6
  const buttonEl = inject('buttonEl')
8
-
9
- const toggle = toggleDropdown
7
+ const isHover = inject('dropdownHover')
10
8
  </script>
11
9
 
12
10
  <template>
13
- <Button :id="id" ref="buttonEl" :aria-expanded="isOpen" aria-haspopup="menu" class="dropdown-button" @click="toggle">
11
+ <Button
12
+ :id="id"
13
+ ref="buttonEl"
14
+ :aria-expanded="isOpen"
15
+ aria-haspopup="menu"
16
+ :popovertarget="`${id}-content`"
17
+ :popovertargetaction="isHover ? 'show' : undefined"
18
+ :style="{ 'anchor-name': `--${id}` }"
19
+ class="dropdown-button"
20
+ >
14
21
  <slot />
15
22
  </Button>
16
23
  </template>
@@ -1,19 +1,27 @@
1
1
  <script setup>
2
2
  import { useFocusTrap } from '@vueuse/integrations/useFocusTrap'
3
- import { inject, nextTick, ref, watchEffect } from 'vue'
3
+ import { computed, inject, nextTick, watch, watchEffect } from 'vue'
4
+ import { getPositionArea, getPositionFallbacks } from '../utils/position-area'
4
5
 
5
6
  const autoFocus = inject('dropdownAutoFocus')
6
7
  const id = inject('dropdownId')
7
8
  const isOpen = inject('isDropdownOpen')
8
- const isOpenDelayed = ref(isOpen.value)
9
9
  const contentEl = inject('contentEl')
10
- const floatingStyles = inject('floatingStyles')
10
+ const placement = inject('dropdownPlacement')
11
+ const closeOnClickOutside = inject('dropdownCloseOnClickOutside')
11
12
 
12
13
  // Dropdown Utils
13
14
  const toggle = inject('toggleDropdown')
14
15
  const open = inject('openDropdown')
15
16
  const close = inject('closeDropdown')
16
17
 
18
+ // Compute CSS position-area value based on placement
19
+ const positionArea = computed(() => getPositionArea(placement.value))
20
+ const positionFallbacks = computed(() => getPositionFallbacks(placement.value))
21
+
22
+ // Determine popover mode: "auto" for light dismiss, "manual" to disable it
23
+ const popoverMode = computed(() => (closeOnClickOutside.value ? 'auto' : 'manual'))
24
+
17
25
  let activate
18
26
  let deactivate
19
27
 
@@ -29,29 +37,91 @@ if (autoFocus.value) {
29
37
  }
30
38
  })
31
39
  }
32
- // const { activate, deactivate, hasFocus } = useFocusTrap(contentEl, { immediate: true })
33
-
34
- // synchronize isOpenDelayed with isOpen
35
- watchEffect(async () => {
36
- if (isOpen.value) {
37
- isOpenDelayed.value = true
38
- if (autoFocus.value) {
39
- await nextTick()
40
- activate()
40
+
41
+ // Sync popover state with isOpen model (for programmatic control)
42
+ watch(
43
+ isOpen,
44
+ async newValue => {
45
+ if (contentEl.value) {
46
+ try {
47
+ // Check current popover state
48
+ const isPopoverOpen = contentEl.value.matches(':popover-open')
49
+
50
+ // Only programmatically control if state differs
51
+ if (newValue && !isPopoverOpen) {
52
+ contentEl.value.showPopover()
53
+ if (autoFocus.value) {
54
+ await nextTick()
55
+ activate?.()
56
+ }
57
+ } else if (!newValue && isPopoverOpen) {
58
+ contentEl.value.hidePopover()
59
+ if (autoFocus.value) {
60
+ deactivate?.()
61
+ await nextTick()
62
+ }
63
+ }
64
+ } catch (e) {
65
+ // Silently handle if popover API is not supported
66
+ console.warn('Popover API not supported:', e)
67
+ }
41
68
  }
42
- }
43
- else {
44
- if (autoFocus.value) {
45
- deactivate()
46
- await nextTick()
69
+ },
70
+ { flush: 'post' },
71
+ )
72
+
73
+ // Listen to popover toggle events to sync back to isOpen model
74
+ function handleToggle(event) {
75
+ const newState = event.newState === 'open'
76
+
77
+ if (isOpen.value !== newState) {
78
+ isOpen.value = newState
79
+
80
+ if (newState && autoFocus.value) {
81
+ nextTick().then(() => activate?.())
82
+ } else if (!newState && autoFocus.value) {
83
+ deactivate?.()
47
84
  }
48
- isOpenDelayed.value = false
49
85
  }
50
- })
86
+ }
51
87
  </script>
52
88
 
53
89
  <template>
54
- <div v-if="isOpen" ref="contentEl" :style="floatingStyles" :aria-labelledby="id" role="menu">
90
+ <div
91
+ :id="`${id}-content`"
92
+ ref="contentEl"
93
+ :anchor="id"
94
+ :aria-labelledby="id"
95
+ role="menu"
96
+ :popover="popoverMode"
97
+ class="dropdown-content dropdown-popover"
98
+ :style="{
99
+ 'position-anchor': `--${id}`,
100
+ 'position-area': positionArea,
101
+ 'position-try-fallbacks': positionFallbacks,
102
+ }"
103
+ @toggle="handleToggle"
104
+ >
55
105
  <slot v-bind="{ toggle, open, close }" />
56
106
  </div>
57
107
  </template>
108
+
109
+ <style>
110
+ @layer components {
111
+ /* Reset default popover styles - in components layer so utilities can override */
112
+ .dropdown-popover[popover] {
113
+ border: none;
114
+ color: inherit;
115
+ overflow: visible;
116
+ /* Use auto for inset to allow anchor positioning to work */
117
+ inset: auto;
118
+ margin: 0;
119
+ background-color: transparent;
120
+ }
121
+
122
+ /* Position anchoring support */
123
+ .dropdown-popover[popover]:popover-open {
124
+ position: fixed;
125
+ }
126
+ }
127
+ </style>
@@ -3,12 +3,19 @@ import { inject } from 'vue'
3
3
 
4
4
  const id = inject('dropdownId')
5
5
  const isOpen = inject('isDropdownOpen')
6
- const toggle = inject('toggleDropdown')
7
6
  const buttonEl = inject('buttonEl')
8
7
  </script>
9
8
 
10
9
  <template>
11
- <div :id="id" ref="buttonEl" :aria-expanded="isOpen" aria-haspopup="menu" class="dropdown-target" @click="toggle">
10
+ <button
11
+ :id="id"
12
+ ref="buttonEl"
13
+ :aria-expanded="isOpen"
14
+ aria-haspopup="menu"
15
+ :popovertarget="`${id}-content`"
16
+ :style="{ 'anchor-name': `--${id}` }"
17
+ class="dropdown-target"
18
+ >
12
19
  <slot />
13
- </div>
20
+ </button>
14
21
  </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ flower?: boolean
4
+ }>()
5
+ </script>
6
+
7
+ <template>
8
+ <div
9
+ class="fab"
10
+ :class="{
11
+ 'fab-flower': flower,
12
+ }"
13
+ >
14
+ <slot />
15
+ </div>
16
+ </template>
@@ -0,0 +1,18 @@
1
+ <script setup lang="ts">
2
+ function handleMouseDown(event: MouseEvent) {
3
+ event.preventDefault()
4
+ const fab = (event.currentTarget as HTMLElement)?.closest('.fab')
5
+ if (fab instanceof HTMLElement) {
6
+ fab.blur()
7
+ }
8
+ if (document.activeElement instanceof HTMLElement) {
9
+ document.activeElement.blur()
10
+ }
11
+ }
12
+ </script>
13
+
14
+ <template>
15
+ <div class="fab-close" @mousedown="handleMouseDown">
16
+ <slot />
17
+ </div>
18
+ </template>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <div class="fab-main-action">
3
+ <slot />
4
+ </div>
5
+ </template>
@@ -0,0 +1,117 @@
1
+ <script setup lang="ts">
2
+ defineOptions({
3
+ inheritAttrs: false,
4
+ })
5
+
6
+ const props = withDefaults(
7
+ defineProps<{
8
+ btn?: boolean
9
+ join?: boolean
10
+ close?: boolean
11
+
12
+ color?: string
13
+ neutral?: boolean
14
+ primary?: boolean
15
+ secondary?: boolean
16
+ accent?: boolean
17
+ info?: boolean
18
+ success?: boolean
19
+ warning?: boolean
20
+ error?: boolean
21
+
22
+ ghost?: boolean
23
+ link?: boolean
24
+ glass?: boolean
25
+ outline?: boolean
26
+ dash?: boolean
27
+ soft?: boolean
28
+
29
+ shape?: 'circle' | 'square' | 'wide' | 'block'
30
+ circle?: boolean
31
+ square?: boolean
32
+ wide?: boolean
33
+ block?: boolean
34
+
35
+ noAnimation?: boolean
36
+ active?: boolean
37
+
38
+ size?: 'lg' | 'md' | 'sm' | 'xs' | 'xl'
39
+ xl?: boolean
40
+ lg?: boolean
41
+ md?: boolean
42
+ sm?: boolean
43
+ xs?: boolean
44
+ }>(),
45
+ {
46
+ btn: true,
47
+ },
48
+ )
49
+
50
+ function handleMouseDown(event: MouseEvent) {
51
+ if (!props.close) return
52
+ const fab = (event.currentTarget as HTMLElement)?.closest('.fab')
53
+ // Only close if FAB is already open (has focus within)
54
+ if (fab instanceof HTMLElement && fab.matches(':focus-within')) {
55
+ event.preventDefault()
56
+ fab.blur()
57
+ if (document.activeElement instanceof HTMLElement) {
58
+ document.activeElement.blur()
59
+ }
60
+ }
61
+ }
62
+ </script>
63
+
64
+ <template>
65
+ <div
66
+ tabindex="0"
67
+ role="button"
68
+ v-bind="$attrs"
69
+ :class="{
70
+ btn,
71
+ 'join-item': join,
72
+
73
+ 'btn-neutral': neutral || color === 'neutral',
74
+ 'btn-primary': primary || color === 'primary',
75
+ 'btn-secondary': secondary || color === 'secondary',
76
+ 'btn-accent': accent || color === 'accent',
77
+ 'btn-info': info || color === 'info',
78
+ 'btn-success': success || color === 'success',
79
+ 'btn-warning': warning || color === 'warning',
80
+ 'btn-error': error || color === 'error',
81
+
82
+ 'text-primary': (primary || color === 'primary') && link,
83
+ 'text-secondary': (secondary || color === 'secondary') && link,
84
+ 'text-neutral': (neutral || color === 'neutral') && link,
85
+ 'text-accent': (accent || color === 'accent') && link,
86
+ 'text-info': (info || color === 'info') && link,
87
+ 'text-success': (success || color === 'success') && link,
88
+ 'text-warning': (warning || color === 'warning') && link,
89
+ 'text-error': (error || color === 'error') && link,
90
+
91
+ glass,
92
+
93
+ 'btn-circle': circle || shape === 'circle',
94
+ 'btn-square': square || shape === 'square',
95
+ 'btn-wide': wide || shape === 'wide',
96
+ 'btn-block': block || shape === 'block',
97
+
98
+ 'btn-xl': xl || size === 'xl',
99
+ 'btn-lg': lg || size === 'lg',
100
+ 'btn-md': md || size === 'md',
101
+ 'btn-sm': sm || size === 'sm',
102
+ 'btn-xs': xs || size === 'xs',
103
+
104
+ 'btn-outline': outline,
105
+ 'btn-dash': dash,
106
+ 'btn-ghost': ghost,
107
+ 'btn-soft': soft,
108
+ 'btn-link': link,
109
+
110
+ 'no-animation': noAnimation,
111
+ 'btn-active': active,
112
+ }"
113
+ @mousedown="handleMouseDown"
114
+ >
115
+ <slot />
116
+ </div>
117
+ </template>
@@ -1,4 +1,8 @@
1
1
  <script setup lang="ts">
2
+ defineOptions({
3
+ inheritAttrs: false,
4
+ })
5
+
2
6
  const { is = 'fieldset', legend } = defineProps<{
3
7
  is?: string
4
8
  legend?: string
@@ -6,10 +10,7 @@ const { is = 'fieldset', legend } = defineProps<{
6
10
  </script>
7
11
 
8
12
  <template>
9
- <component
10
- :is="is"
11
- class="fieldset bg-base-200 border-base-300 rounded-box border p-4"
12
- >
13
+ <component :is="is" v-bind="$attrs" class="fieldset bg-base-200 border-base-300 rounded-box border p-4">
13
14
  <legend v-if="legend" class="fieldset-legend">
14
15
  {{ legend }}
15
16
  </legend>
@@ -49,5 +49,5 @@ defineEmits(['files'])
49
49
  'file-input-ghost': ghost,
50
50
  }"
51
51
  @input="$emit('files', ($event.target as any).value)"
52
- >
52
+ />
53
53
  </template>
@@ -1,6 +1,46 @@
1
1
  <script setup lang="ts">
2
2
  import { computed } from 'vue'
3
3
 
4
+ defineOptions({
5
+ inheritAttrs: false,
6
+ })
7
+
8
+ const props = withDefaults(
9
+ defineProps<{
10
+ is?: string
11
+ name: string
12
+ items: FilterItemInput[]
13
+ modelValue?: any
14
+ resetLabel?: string
15
+ position?: 'start' | 'end'
16
+ start?: boolean
17
+ end?: boolean
18
+
19
+ color?: string
20
+ neutral?: boolean
21
+ primary?: boolean
22
+ secondary?: boolean
23
+ accent?: boolean
24
+ info?: boolean
25
+ success?: boolean
26
+ warning?: boolean
27
+ error?: boolean
28
+
29
+ size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs'
30
+ xl?: boolean
31
+ lg?: boolean
32
+ md?: boolean
33
+ sm?: boolean
34
+ xs?: boolean
35
+ }>(),
36
+ {
37
+ resetLabel: 'All',
38
+ is: 'div',
39
+ },
40
+ )
41
+
42
+ const emit = defineEmits(['update:modelValue'])
43
+
4
44
  interface FilterItem {
5
45
  label: string
6
46
  value: any
@@ -8,39 +48,6 @@ interface FilterItem {
8
48
 
9
49
  type FilterItemInput = string | FilterItem
10
50
 
11
- const props = withDefaults(defineProps<{
12
- is?: string
13
- name: string
14
- items: FilterItemInput[]
15
- modelValue?: any
16
- resetLabel?: string
17
- position?: 'start' | 'end'
18
- start?: boolean
19
- end?: boolean
20
-
21
- color?: string
22
- neutral?: boolean
23
- primary?: boolean
24
- secondary?: boolean
25
- accent?: boolean
26
- info?: boolean
27
- success?: boolean
28
- warning?: boolean
29
- error?: boolean
30
-
31
- size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs'
32
- xl?: boolean
33
- lg?: boolean
34
- md?: boolean
35
- sm?: boolean
36
- xs?: boolean
37
- }>(), {
38
- resetLabel: 'All',
39
- is: 'div',
40
- })
41
-
42
- const emit = defineEmits(['update:modelValue'])
43
-
44
51
  const currentValue = computed({
45
52
  get: () => props.modelValue,
46
53
  set(val) {
@@ -49,7 +56,7 @@ const currentValue = computed({
49
56
  })
50
57
 
51
58
  const normalizedItems = computed(() => {
52
- return props.items.map((item) => {
59
+ return props.items.map(item => {
53
60
  if (typeof item === 'string') {
54
61
  return { label: item, value: item }
55
62
  }
@@ -59,7 +66,7 @@ const normalizedItems = computed(() => {
59
66
  </script>
60
67
 
61
68
  <template>
62
- <component :is="props.is" class="filter">
69
+ <component :is="props.is" v-bind="$attrs" class="filter">
63
70
  <!-- Reset button at start -->
64
71
  <input
65
72
  v-if="resetLabel && (start || position === 'start')"
@@ -76,7 +83,7 @@ const normalizedItems = computed(() => {
76
83
  :name="name"
77
84
  :aria-label="resetLabel"
78
85
  :value="null"
79
- >
86
+ />
80
87
 
81
88
  <!-- Filter items -->
82
89
  <template v-for="(item, index) in normalizedItems" :key="index">
@@ -102,7 +109,7 @@ const normalizedItems = computed(() => {
102
109
  :name="name"
103
110
  :aria-label="item.label"
104
111
  :value="item.value"
105
- >
112
+ />
106
113
  </template>
107
114
 
108
115
  <!-- Reset button at end -->
@@ -114,7 +121,7 @@ const normalizedItems = computed(() => {
114
121
  :name="name"
115
122
  :aria-label="resetLabel"
116
123
  :value="null"
117
- >
124
+ />
118
125
 
119
126
  <!-- Optional slot for custom items -->
120
127
  <slot />
@@ -1,4 +1,8 @@
1
1
  <script setup lang="ts">
2
+ defineOptions({
3
+ inheritAttrs: false,
4
+ })
5
+
2
6
  const { is = 'div', ...props } = defineProps<{
3
7
  is?: string | object
4
8
  join?: boolean
@@ -44,7 +48,10 @@ const { is = 'div', ...props } = defineProps<{
44
48
 
45
49
  <template>
46
50
  <component
47
- :is="is" class="flex" :class="{
51
+ :is="is"
52
+ v-bind="$attrs"
53
+ class="flex"
54
+ :class="{
48
55
  'join-item': props.join,
49
56
 
50
57
  'flex-1': props.flex1,