@soave/ui 0.2.2 → 0.3.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 (100) hide show
  1. package/dist/components/Button.vue +36 -0
  2. package/dist/components/Card.vue +23 -0
  3. package/dist/components/Checkbox.vue +44 -0
  4. package/dist/components/Dialog.vue +99 -0
  5. package/dist/components/Input.vue +48 -0
  6. package/dist/components/RadioGroup.vue +35 -0
  7. package/dist/components/RadioItem.vue +55 -0
  8. package/dist/components/Select.vue +95 -0
  9. package/dist/components/SelectContent.vue +40 -0
  10. package/dist/components/SelectItem.vue +44 -0
  11. package/dist/components/SelectTrigger.vue +61 -0
  12. package/dist/components/Switch.vue +43 -0
  13. package/dist/components/Textarea.vue +55 -0
  14. package/dist/components/index.d.ts +13 -0
  15. package/dist/components/index.mjs +13 -0
  16. package/dist/composables/useButton.d.ts +2 -2
  17. package/dist/composables/useButton.mjs +14 -41
  18. package/dist/composables/useCard.d.ts +2 -2
  19. package/dist/composables/useCard.mjs +5 -18
  20. package/dist/composables/useCheckbox.d.ts +2 -1
  21. package/dist/composables/useCheckbox.mjs +11 -44
  22. package/dist/composables/useFileInput.d.ts +2 -0
  23. package/dist/composables/useFileInput.mjs +15 -30
  24. package/dist/composables/useInput.d.ts +2 -2
  25. package/dist/composables/useInput.mjs +12 -33
  26. package/dist/composables/useRadio.d.ts +2 -1
  27. package/dist/composables/useRadio.mjs +10 -42
  28. package/dist/composables/useSelect.d.ts +3 -0
  29. package/dist/composables/useSelect.mjs +20 -49
  30. package/dist/composables/useSwitch.d.ts +2 -1
  31. package/dist/composables/useSwitch.mjs +10 -43
  32. package/dist/composables/useTextarea.d.ts +2 -1
  33. package/dist/composables/useTextarea.mjs +12 -33
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.mjs +1 -1
  36. package/dist/types/button.d.ts +19 -5
  37. package/dist/types/card.d.ts +11 -2
  38. package/dist/types/checkbox.d.ts +15 -6
  39. package/dist/types/composables.d.ts +33 -5
  40. package/dist/types/file-input.d.ts +15 -5
  41. package/dist/types/input.d.ts +17 -6
  42. package/dist/types/radio.d.ts +14 -6
  43. package/dist/types/select.d.ts +25 -7
  44. package/dist/types/switch.d.ts +14 -5
  45. package/dist/types/textarea.d.ts +18 -7
  46. package/package.json +1 -9
  47. package/dist/components/ui/Alert.vue +0 -41
  48. package/dist/components/ui/AlertDescription.vue +0 -22
  49. package/dist/components/ui/AlertTitle.vue +0 -22
  50. package/dist/components/ui/Button.vue +0 -85
  51. package/dist/components/ui/Card.vue +0 -39
  52. package/dist/components/ui/CardContent.vue +0 -22
  53. package/dist/components/ui/CardDescription.vue +0 -22
  54. package/dist/components/ui/CardFooter.vue +0 -22
  55. package/dist/components/ui/CardHeader.vue +0 -22
  56. package/dist/components/ui/CardTitle.vue +0 -22
  57. package/dist/components/ui/Checkbox.vue +0 -94
  58. package/dist/components/ui/Dialog.vue +0 -110
  59. package/dist/components/ui/DialogDescription.vue +0 -22
  60. package/dist/components/ui/DialogFooter.vue +0 -22
  61. package/dist/components/ui/DialogHeader.vue +0 -22
  62. package/dist/components/ui/DialogTitle.vue +0 -22
  63. package/dist/components/ui/DropdownMenu.vue +0 -32
  64. package/dist/components/ui/DropdownMenuContent.vue +0 -69
  65. package/dist/components/ui/DropdownMenuItem.vue +0 -71
  66. package/dist/components/ui/DropdownMenuLabel.vue +0 -20
  67. package/dist/components/ui/DropdownMenuSeparator.vue +0 -16
  68. package/dist/components/ui/DropdownMenuTrigger.vue +0 -38
  69. package/dist/components/ui/FileInput.vue +0 -153
  70. package/dist/components/ui/FormError.vue +0 -20
  71. package/dist/components/ui/FormField.vue +0 -12
  72. package/dist/components/ui/FormInput.vue +0 -46
  73. package/dist/components/ui/FormLabel.vue +0 -19
  74. package/dist/components/ui/FormTextarea.vue +0 -39
  75. package/dist/components/ui/Input.vue +0 -72
  76. package/dist/components/ui/Popover.vue +0 -35
  77. package/dist/components/ui/PopoverContent.vue +0 -66
  78. package/dist/components/ui/PopoverTrigger.vue +0 -36
  79. package/dist/components/ui/RadioGroup.vue +0 -47
  80. package/dist/components/ui/RadioItem.vue +0 -62
  81. package/dist/components/ui/Select.vue +0 -62
  82. package/dist/components/ui/SelectContent.vue +0 -55
  83. package/dist/components/ui/SelectItem.vue +0 -55
  84. package/dist/components/ui/SelectTrigger.vue +0 -70
  85. package/dist/components/ui/SelectValue.vue +0 -27
  86. package/dist/components/ui/Sheet.vue +0 -148
  87. package/dist/components/ui/SheetDescription.vue +0 -22
  88. package/dist/components/ui/SheetFooter.vue +0 -22
  89. package/dist/components/ui/SheetHeader.vue +0 -22
  90. package/dist/components/ui/SheetTitle.vue +0 -22
  91. package/dist/components/ui/Switch.vue +0 -63
  92. package/dist/components/ui/Textarea.vue +0 -73
  93. package/dist/components/ui/Toast.vue +0 -116
  94. package/dist/components/ui/Toaster.vue +0 -76
  95. package/dist/components/ui/Tooltip.vue +0 -41
  96. package/dist/components/ui/TooltipContent.vue +0 -71
  97. package/dist/components/ui/TooltipTrigger.vue +0 -39
  98. package/dist/components/ui/UIProvider.vue +0 -23
  99. package/dist/components/ui/index.d.ts +0 -52
  100. package/dist/components/ui/index.mjs +0 -52
@@ -1,85 +0,0 @@
1
- <template>
2
- <button
3
- :class="[computed_classes, props.class]"
4
- :disabled="composable.is_disabled.value"
5
- v-bind="composable.aria_attributes.value"
6
- @click="handleClick"
7
- >
8
- <slot name="icon-left" />
9
- <span v-if="composable.is_loading.value" class="animate-spin">
10
- <slot name="loading">
11
- <svg
12
- class="h-4 w-4"
13
- xmlns="http://www.w3.org/2000/svg"
14
- fill="none"
15
- viewBox="0 0 24 24"
16
- >
17
- <circle
18
- class="opacity-25"
19
- cx="12"
20
- cy="12"
21
- r="10"
22
- stroke="currentColor"
23
- stroke-width="4"
24
- />
25
- <path
26
- class="opacity-75"
27
- fill="currentColor"
28
- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
29
- />
30
- </svg>
31
- </slot>
32
- </span>
33
- <slot />
34
- <slot name="icon-right" />
35
- </button>
36
- </template>
37
-
38
- <script setup lang="ts">
39
- import { toRef, computed } from "vue"
40
- import { useButton } from "../../composables/useButton"
41
- import { useStyleAdapter, useUI } from "../../composables/useUIConfig"
42
- import type { ButtonProps } from "../../types/button"
43
- import type { ButtonState } from "../../types/composables"
44
-
45
- interface ButtonComponentProps extends ButtonProps {
46
- class?: string
47
- unstyled?: boolean
48
- }
49
-
50
- const props = withDefaults(defineProps<ButtonComponentProps>(), {
51
- disabled: false,
52
- loading: false,
53
- unstyled: false
54
- })
55
-
56
- const emit = defineEmits<{
57
- click: [event: MouseEvent]
58
- }>()
59
-
60
- const ui_config = useUI("button")
61
- const style_adapter = useStyleAdapter()
62
- const composable = useButton(toRef(() => props))
63
-
64
- // StyleAdapterからクラスを取得
65
- const computed_classes = computed(() => {
66
- if (props.unstyled) {
67
- return ""
68
- }
69
-
70
- const state: ButtonState = {
71
- variant: props.variant ?? ui_config.default_variant,
72
- size: props.size ?? ui_config.default_size,
73
- disabled: composable.is_disabled.value,
74
- loading: composable.is_loading.value
75
- }
76
-
77
- return style_adapter.getClasses("button", state)
78
- })
79
-
80
- const handleClick = (event: MouseEvent) => {
81
- if (!composable.is_disabled.value && !composable.is_loading.value) {
82
- emit("click", event)
83
- }
84
- }
85
- </script>
@@ -1,39 +0,0 @@
1
- <template>
2
- <div :class="[computed_classes, props.class]">
3
- <slot />
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { toRef, computed } from "vue"
9
- import { useCard } from "../../composables/useCard"
10
- import { useStyleAdapter, useUI } from "../../composables/useUIConfig"
11
- import type { CardProps } from "../../types/card"
12
- import type { CardState } from "../../types/composables"
13
-
14
- interface CardComponentProps extends CardProps {
15
- class?: string
16
- unstyled?: boolean
17
- }
18
-
19
- const props = withDefaults(defineProps<CardComponentProps>(), {
20
- unstyled: false
21
- })
22
-
23
- const ui_config = useUI("card")
24
- const style_adapter = useStyleAdapter()
25
- const composable = useCard(toRef(() => props))
26
-
27
- // StyleAdapterからクラスを取得
28
- const computed_classes = computed(() => {
29
- if (props.unstyled) {
30
- return ""
31
- }
32
-
33
- const state: CardState = {
34
- padding: props.padding ?? ui_config.default_padding
35
- }
36
-
37
- return style_adapter.getClasses("card", state)
38
- })
39
- </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <div :class="[computed_classes, props.class]">
3
- <slot />
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from "vue"
9
- import { useStyleAdapter } from "../../composables"
10
- import type { CardContentProps } from "../../types/card"
11
-
12
- const props = withDefaults(defineProps<CardContentProps>(), {
13
- unstyled: false
14
- })
15
-
16
- const style_adapter = useStyleAdapter()
17
-
18
- const computed_classes = computed(() => {
19
- if (props.unstyled) return ""
20
- return style_adapter.getClasses("card-content", {})
21
- })
22
- </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <p :class="[computed_classes, props.class]">
3
- <slot />
4
- </p>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from "vue"
9
- import { useStyleAdapter } from "../../composables"
10
- import type { CardDescriptionProps } from "../../types/card"
11
-
12
- const props = withDefaults(defineProps<CardDescriptionProps>(), {
13
- unstyled: false
14
- })
15
-
16
- const style_adapter = useStyleAdapter()
17
-
18
- const computed_classes = computed(() => {
19
- if (props.unstyled) return ""
20
- return style_adapter.getClasses("card-description", {})
21
- })
22
- </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <div :class="[computed_classes, props.class]">
3
- <slot />
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from "vue"
9
- import { useStyleAdapter } from "../../composables"
10
- import type { CardFooterProps } from "../../types/card"
11
-
12
- const props = withDefaults(defineProps<CardFooterProps>(), {
13
- unstyled: false
14
- })
15
-
16
- const style_adapter = useStyleAdapter()
17
-
18
- const computed_classes = computed(() => {
19
- if (props.unstyled) return ""
20
- return style_adapter.getClasses("card-footer", {})
21
- })
22
- </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <div :class="[computed_classes, props.class]">
3
- <slot />
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from "vue"
9
- import { useStyleAdapter } from "../../composables"
10
- import type { CardHeaderProps } from "../../types/card"
11
-
12
- const props = withDefaults(defineProps<CardHeaderProps>(), {
13
- unstyled: false
14
- })
15
-
16
- const style_adapter = useStyleAdapter()
17
-
18
- const computed_classes = computed(() => {
19
- if (props.unstyled) return ""
20
- return style_adapter.getClasses("card-header", {})
21
- })
22
- </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <h3 :class="[computed_classes, props.class]">
3
- <slot />
4
- </h3>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from "vue"
9
- import { useStyleAdapter } from "../../composables"
10
- import type { CardTitleProps } from "../../types/card"
11
-
12
- const props = withDefaults(defineProps<CardTitleProps>(), {
13
- unstyled: false
14
- })
15
-
16
- const style_adapter = useStyleAdapter()
17
-
18
- const computed_classes = computed(() => {
19
- if (props.unstyled) return ""
20
- return style_adapter.getClasses("card-title", {})
21
- })
22
- </script>
@@ -1,94 +0,0 @@
1
- <template>
2
- <button
3
- type="button"
4
- :class="[computed_classes, props.class]"
5
- :disabled="composable.is_disabled.value"
6
- :data-state="dataState"
7
- v-bind="composable.aria_attributes.value"
8
- @click="handleClick"
9
- >
10
- <span
11
- v-if="modelValue || composable.is_indeterminate.value"
12
- :class="composable.indicator_classes.value"
13
- >
14
- <svg
15
- v-if="composable.is_indeterminate.value"
16
- xmlns="http://www.w3.org/2000/svg"
17
- viewBox="0 0 24 24"
18
- fill="none"
19
- stroke="currentColor"
20
- stroke-width="3"
21
- stroke-linecap="round"
22
- >
23
- <line x1="5" y1="12" x2="19" y2="12" />
24
- </svg>
25
- <svg
26
- v-else
27
- xmlns="http://www.w3.org/2000/svg"
28
- viewBox="0 0 24 24"
29
- fill="none"
30
- stroke="currentColor"
31
- stroke-width="3"
32
- stroke-linecap="round"
33
- stroke-linejoin="round"
34
- >
35
- <polyline points="20 6 9 17 4 12" />
36
- </svg>
37
- </span>
38
- </button>
39
- </template>
40
-
41
- <script setup lang="ts">
42
- import { computed, toRef } from "vue"
43
- import { useCheckbox } from "../../composables/useCheckbox"
44
- import { useStyleAdapter } from "../../composables/useUIConfig"
45
- import type { CheckboxProps } from "../../types/checkbox"
46
- import type { CheckboxState } from "../../types/composables"
47
-
48
- interface Props extends CheckboxProps {
49
- modelValue?: boolean
50
- class?: string
51
- unstyled?: boolean
52
- }
53
-
54
- const props = withDefaults(defineProps<Props>(), {
55
- modelValue: false,
56
- disabled: false,
57
- indeterminate: false,
58
- unstyled: false
59
- })
60
-
61
- const emit = defineEmits<{
62
- "update:modelValue": [value: boolean]
63
- }>()
64
-
65
- const style_adapter = useStyleAdapter()
66
- const checked = toRef(() => props.modelValue)
67
- const composable = useCheckbox(toRef(() => props), checked)
68
-
69
- // StyleAdapterからクラスを取得
70
- const computed_classes = computed(() => {
71
- if (props.unstyled) {
72
- return ""
73
- }
74
-
75
- const state: CheckboxState = {
76
- checked: props.modelValue,
77
- disabled: composable.is_disabled.value,
78
- indeterminate: composable.is_indeterminate.value
79
- }
80
-
81
- return style_adapter.getClasses("checkbox", state)
82
- })
83
-
84
- const dataState = computed(() => {
85
- if (props.indeterminate) return "indeterminate"
86
- return props.modelValue ? "checked" : "unchecked"
87
- })
88
-
89
- const handleClick = () => {
90
- if (!composable.is_disabled.value) {
91
- emit("update:modelValue", !props.modelValue)
92
- }
93
- }
94
- </script>
@@ -1,110 +0,0 @@
1
- <template>
2
- <Teleport to="body">
3
- <Transition name="dialog">
4
- <div
5
- v-if="is_open"
6
- class="fixed inset-0 z-50 flex items-center justify-center"
7
- >
8
- <div
9
- :class="overlay_classes"
10
- @click="handleOverlayClick"
11
- />
12
- <div
13
- :class="[computed_classes, props.class]"
14
- role="dialog"
15
- aria-modal="true"
16
- >
17
- <slot />
18
- <button
19
- v-if="show_close_button"
20
- :class="close_button_classes"
21
- @click="close"
22
- >
23
- <svg
24
- xmlns="http://www.w3.org/2000/svg"
25
- width="24"
26
- height="24"
27
- viewBox="0 0 24 24"
28
- fill="none"
29
- stroke="currentColor"
30
- stroke-width="2"
31
- stroke-linecap="round"
32
- stroke-linejoin="round"
33
- class="h-4 w-4"
34
- >
35
- <path d="M18 6 6 18" />
36
- <path d="m6 6 12 12" />
37
- </svg>
38
- <span class="sr-only">閉じる</span>
39
- </button>
40
- </div>
41
- </div>
42
- </Transition>
43
- </Teleport>
44
- </template>
45
-
46
- <script setup lang="ts">
47
- import { computed, provide } from "vue"
48
- import { useStyleAdapter } from "../../composables"
49
- import type { DialogProps } from "../../types/dialog"
50
- import { DIALOG_KEY } from "../../types/dialog"
51
- import type { DialogState } from "../../types/composables"
52
-
53
- interface DialogComponentProps extends DialogProps {
54
- class?: string
55
- }
56
-
57
- const props = withDefaults(defineProps<DialogComponentProps>(), {
58
- open: false,
59
- modal: true,
60
- showCloseButton: true,
61
- unstyled: false
62
- })
63
-
64
- const emit = defineEmits<{
65
- "update:open": [value: boolean]
66
- }>()
67
-
68
- const style_adapter = useStyleAdapter()
69
-
70
- const is_open = computed({
71
- get: () => props.open,
72
- set: (value) => emit("update:open", value)
73
- })
74
-
75
- const show_close_button = computed(() => props.showCloseButton)
76
-
77
- const computed_classes = computed(() => {
78
- if (props.unstyled) return ""
79
- const state: DialogState = {
80
- is_open: is_open.value
81
- }
82
- return style_adapter.getClasses("dialog", state)
83
- })
84
-
85
- const overlay_classes = computed(() => {
86
- if (props.unstyled) return ""
87
- return style_adapter.getClasses("dialog-overlay", {})
88
- })
89
-
90
- const close_button_classes = computed(() => {
91
- if (props.unstyled) return ""
92
- return style_adapter.getClasses("dialog-close", {})
93
- })
94
-
95
- const close = () => {
96
- is_open.value = false
97
- }
98
-
99
- const handleOverlayClick = () => {
100
- if (props.modal) {
101
- close()
102
- }
103
- }
104
-
105
- provide(DIALOG_KEY, { close })
106
- </script>
107
-
108
- <style scoped>
109
- .dialog-enter-active,.dialog-leave-active{transition:opacity .2s ease}.dialog-enter-from,.dialog-leave-to{opacity:0}
110
- </style>
@@ -1,22 +0,0 @@
1
- <template>
2
- <p :class="[computed_classes, props.class]">
3
- <slot />
4
- </p>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from "vue"
9
- import { useStyleAdapter } from "../../composables"
10
- import type { DialogDescriptionProps } from "../../types/dialog"
11
-
12
- const props = withDefaults(defineProps<DialogDescriptionProps>(), {
13
- unstyled: false
14
- })
15
-
16
- const style_adapter = useStyleAdapter()
17
-
18
- const computed_classes = computed(() => {
19
- if (props.unstyled) return ""
20
- return style_adapter.getClasses("dialog-description", {})
21
- })
22
- </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <div :class="[computed_classes, props.class]">
3
- <slot />
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from "vue"
9
- import { useStyleAdapter } from "../../composables"
10
- import type { DialogFooterProps } from "../../types/dialog"
11
-
12
- const props = withDefaults(defineProps<DialogFooterProps>(), {
13
- unstyled: false
14
- })
15
-
16
- const style_adapter = useStyleAdapter()
17
-
18
- const computed_classes = computed(() => {
19
- if (props.unstyled) return ""
20
- return style_adapter.getClasses("dialog-footer", {})
21
- })
22
- </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <div :class="[computed_classes, props.class]">
3
- <slot />
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from "vue"
9
- import { useStyleAdapter } from "../../composables"
10
- import type { DialogHeaderProps } from "../../types/dialog"
11
-
12
- const props = withDefaults(defineProps<DialogHeaderProps>(), {
13
- unstyled: false
14
- })
15
-
16
- const style_adapter = useStyleAdapter()
17
-
18
- const computed_classes = computed(() => {
19
- if (props.unstyled) return ""
20
- return style_adapter.getClasses("dialog-header", {})
21
- })
22
- </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <h2 :class="[computed_classes, props.class]">
3
- <slot />
4
- </h2>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from "vue"
9
- import { useStyleAdapter } from "../../composables"
10
- import type { DialogTitleProps } from "../../types/dialog"
11
-
12
- const props = withDefaults(defineProps<DialogTitleProps>(), {
13
- unstyled: false
14
- })
15
-
16
- const style_adapter = useStyleAdapter()
17
-
18
- const computed_classes = computed(() => {
19
- if (props.unstyled) return ""
20
- return style_adapter.getClasses("dialog-title", {})
21
- })
22
- </script>
@@ -1,32 +0,0 @@
1
- <template>
2
- <div class="relative inline-block" :class="props.class">
3
- <slot />
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { provide, ref, type Ref } from "vue"
9
- import { useDropdown } from "../../composables/useDropdown"
10
- import type { DropdownSide, DropdownAlign } from "../../types/dropdown"
11
- import { DROPDOWN_CONTEXT_KEY } from "../../types/dropdown"
12
-
13
- interface Props {
14
- side?: DropdownSide
15
- align?: DropdownAlign
16
- class?: string
17
- }
18
-
19
- const props = withDefaults(defineProps<Props>(), {
20
- side: "bottom",
21
- align: "start"
22
- })
23
-
24
- const dropdown_props = ref({
25
- side: props.side,
26
- align: props.align
27
- })
28
-
29
- const dropdown = useDropdown(dropdown_props as Ref<typeof dropdown_props.value>)
30
-
31
- provide(DROPDOWN_CONTEXT_KEY, dropdown)
32
- </script>
@@ -1,69 +0,0 @@
1
- <template>
2
- <Transition name="dropdown">
3
- <div
4
- v-if="is_open"
5
- ref="content_element"
6
- :id="dropdown_id"
7
- role="menu"
8
- :aria-labelledby="`${dropdown_id}-trigger`"
9
- :style="position_styles"
10
- :class="[computed_classes, props.class]"
11
- tabindex="-1"
12
- @keydown="handleContentKeyDown"
13
- >
14
- <slot />
15
- </div>
16
- </Transition>
17
- </template>
18
-
19
- <script setup lang="ts">
20
- import { inject, ref, computed, watchEffect, nextTick, watch } from "vue"
21
- import { useStyleAdapter } from "../../composables"
22
- import type { DropdownContentProps } from "../../types/dropdown"
23
- import { DROPDOWN_CONTEXT_KEY } from "../../types/dropdown"
24
- import type { DropdownState } from "../../types/composables"
25
-
26
- const props = withDefaults(defineProps<DropdownContentProps>(), {
27
- unstyled: false
28
- })
29
-
30
- const context = inject(DROPDOWN_CONTEXT_KEY)
31
-
32
- if (!context) {
33
- throw new Error("DropdownMenuContent must be used within a DropdownMenu component")
34
- }
35
-
36
- const {
37
- is_open,
38
- content_ref,
39
- dropdown_id,
40
- position_styles,
41
- handleContentKeyDown
42
- } = context
43
-
44
- const style_adapter = useStyleAdapter()
45
- const content_element = ref<HTMLElement | null>(null)
46
-
47
- watchEffect(() => {
48
- content_ref.value = content_element.value
49
- })
50
-
51
- watch(is_open, async (open) => {
52
- if (open) {
53
- await nextTick()
54
- content_element.value?.focus()
55
- }
56
- })
57
-
58
- const computed_classes = computed(() => {
59
- if (props.unstyled) return ""
60
- const state: DropdownState = {
61
- is_open: is_open.value
62
- }
63
- return style_adapter.getClasses("dropdown", state)
64
- })
65
- </script>
66
-
67
- <style scoped>
68
- .dropdown-enter-active,.dropdown-leave-active{transition:opacity .15s ease,transform .15s ease}.dropdown-enter-from,.dropdown-leave-to{opacity:0;transform:scale(.95)}
69
- </style>