@imaginario27/air-ui-ds 1.2.4 → 1.2.5

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.
@@ -0,0 +1,244 @@
1
+ <template>
2
+ <!-- Overlay -->
3
+ <Transition
4
+ enter-active-class="transition-opacity duration-200 ease-out"
5
+ enter-from-class="opacity-0"
6
+ enter-to-class="opacity-100"
7
+ leave-active-class="transition-opacity duration-200 ease-in"
8
+ leave-from-class="opacity-100"
9
+ leave-to-class="opacity-0"
10
+ >
11
+ <div
12
+ v-if="isOpen && hasOverlay"
13
+ :class="[
14
+ 'fixed',
15
+ 'inset-0',
16
+ 'bg-background-overlay',
17
+ 'backdrop-blur-sm',
18
+ 'z-[10000]',
19
+ overlayClass,
20
+ ]"
21
+ @click="closeOnOverlayClick ? close() : null"
22
+ />
23
+ </Transition>
24
+
25
+ <!-- Drawer -->
26
+ <Transition
27
+ :enter-active-class="transitionClasses.enterActive"
28
+ :enter-from-class="transitionClasses.enterFrom"
29
+ :enter-to-class="transitionClasses.enterTo"
30
+ :leave-active-class="transitionClasses.leaveActive"
31
+ :leave-from-class="transitionClasses.leaveFrom"
32
+ :leave-to-class="transitionClasses.leaveTo"
33
+ >
34
+ <aside
35
+ v-if="isOpen"
36
+ :class="[
37
+ 'fixed',
38
+ 'bg-background-container-surface',
39
+ 'shadow-xl',
40
+ 'z-[10000]',
41
+ 'p-4',
42
+ 'flex',
43
+ 'flex-col',
44
+ 'gap-4',
45
+ positionClasses,
46
+ sizeClasses,
47
+ drawerClass,
48
+ borderClass,
49
+ ]"
50
+ :style="drawerInlineStyle"
51
+ >
52
+ <!-- Header -->
53
+ <div
54
+ v-if="hasHeader"
55
+ :class="[
56
+ 'flex',
57
+ 'items-center',
58
+ 'justify-between',
59
+ ]"
60
+ >
61
+ <component
62
+ :is="titleHeadingTag"
63
+ class="text-lg font-semibold"
64
+ >
65
+ {{ title }}
66
+ </component>
67
+
68
+ <ActionIconButton
69
+ v-if="hasCloseButton"
70
+ :icon="buttonCloseIcon"
71
+ :styleType="ButtonStyleType.NEUTRAL_TRANSPARENT"
72
+ @click="close"
73
+ />
74
+ </div>
75
+
76
+ <!-- Content -->
77
+ <div class="flex-1 overflow-y-auto">
78
+ <slot />
79
+ </div>
80
+ </aside>
81
+ </Transition>
82
+ </template>
83
+
84
+ <script setup lang="ts">
85
+ // Props
86
+ const props = defineProps({
87
+ modelValue: {
88
+ type: Boolean as PropType<boolean>,
89
+ required: true,
90
+ },
91
+ direction: {
92
+ type: String as PropType<Direction>,
93
+ default: Direction.RIGHT,
94
+ validator: (value: Direction) => Object.values(Direction).includes(value),
95
+ },
96
+ maxSize: {
97
+ type: Number as PropType<number>,
98
+ default: 320,
99
+ },
100
+ hasHeader: {
101
+ type: Boolean as PropType<boolean>,
102
+ default: true,
103
+ },
104
+ hasCloseButton: {
105
+ type: Boolean as PropType<boolean>,
106
+ default: true,
107
+ },
108
+ hasOverlay: {
109
+ type: Boolean as PropType<boolean>,
110
+ default: true,
111
+ },
112
+ closeOnOverlayClick: {
113
+ type: Boolean as PropType<boolean>,
114
+ default: true,
115
+ },
116
+ title: {
117
+ type: String as PropType<string>,
118
+ default: 'Drawer',
119
+ },
120
+ titleHeadingTag: {
121
+ type: String as PropType<'h2' | 'h3' | 'h4' | 'h5' | 'h6'>,
122
+ default: 'h2',
123
+ },
124
+ buttonCloseIcon: {
125
+ type: String as PropType<string>,
126
+ default: 'mdi:close',
127
+ },
128
+ hasBorder: {
129
+ type: Boolean as PropType<boolean>,
130
+ default: true,
131
+ },
132
+ drawerClass: String as PropType<string>,
133
+ overlayClass: String as PropType<string>,
134
+ })
135
+
136
+ // Emits
137
+ const emit = defineEmits(['update:modelValue'])
138
+
139
+ const isOpen = computed(() => props.modelValue)
140
+
141
+ // Computed classes
142
+ const positionClasses = computed(() => {
143
+ const map: Record<Direction, string[]> = {
144
+ [Direction.RIGHT]: ['top-0', 'right-0', 'h-full'],
145
+ [Direction.LEFT]: ['top-0', 'left-0', 'h-full'],
146
+ [Direction.TOP]: ['top-0', 'left-0', 'w-full'],
147
+ [Direction.BOTTOM]: ['bottom-0', 'left-0', 'w-full'],
148
+ }
149
+
150
+ return map[props.direction]
151
+ })
152
+
153
+ const sizeClasses = computed(() => {
154
+ if (props.direction === Direction.LEFT || props.direction === Direction.RIGHT) {
155
+ return ['w-full']
156
+ }
157
+
158
+ return []
159
+ })
160
+
161
+ const drawerInlineStyle = computed(() => {
162
+ if (props.direction === Direction.LEFT || props.direction === Direction.RIGHT) {
163
+ return { maxWidth: props.maxSize + 'px' }
164
+ }
165
+
166
+ return { maxHeight: props.maxSize + 'px' }
167
+ })
168
+
169
+ const transitionClasses = computed(() => {
170
+ const base = 'transform transition-transform duration-300 ease-out'
171
+ const leaveBase = 'transform transition-transform duration-300 ease-in'
172
+
173
+ const map: Record<
174
+ Direction,
175
+ {
176
+ enterActive: string
177
+ enterFrom: string
178
+ enterTo: string
179
+ leaveActive: string
180
+ leaveFrom: string
181
+ leaveTo: string
182
+ }
183
+ > = {
184
+ [Direction.RIGHT]: {
185
+ enterActive: base,
186
+ enterFrom: 'translate-x-full',
187
+ enterTo: 'translate-x-0',
188
+ leaveActive: leaveBase,
189
+ leaveFrom: 'translate-x-0',
190
+ leaveTo: 'translate-x-full',
191
+ },
192
+ [Direction.LEFT]: {
193
+ enterActive: base,
194
+ enterFrom: '-translate-x-full',
195
+ enterTo: 'translate-x-0',
196
+ leaveActive: leaveBase,
197
+ leaveFrom: 'translate-x-0',
198
+ leaveTo: '-translate-x-full',
199
+ },
200
+ [Direction.TOP]: {
201
+ enterActive: base,
202
+ enterFrom: '-translate-y-full',
203
+ enterTo: 'translate-y-0',
204
+ leaveActive: leaveBase,
205
+ leaveFrom: 'translate-y-0',
206
+ leaveTo: '-translate-y-full',
207
+ },
208
+ [Direction.BOTTOM]: {
209
+ enterActive: base,
210
+ enterFrom: 'translate-y-full',
211
+ enterTo: 'translate-y-0',
212
+ leaveActive: leaveBase,
213
+ leaveFrom: 'translate-y-0',
214
+ leaveTo: 'translate-y-full',
215
+ },
216
+ }
217
+
218
+ return map[props.direction]
219
+ })
220
+
221
+ const borderClass = computed(() => {
222
+ if (!props.hasBorder) return ''
223
+
224
+ const colorClass = 'border-border-default'
225
+
226
+ switch (props.direction) {
227
+ case Direction.RIGHT:
228
+ return `border-l ${colorClass}`
229
+ case Direction.LEFT:
230
+ return `border-r ${colorClass}`
231
+ case Direction.TOP:
232
+ return `border-b ${colorClass}`
233
+ case Direction.BOTTOM:
234
+ return `border-t ${colorClass}`
235
+ default:
236
+ return ''
237
+ }
238
+ })
239
+
240
+ // Handlers
241
+ const close = () => {
242
+ emit('update:modelValue', false)
243
+ }
244
+ </script>
@@ -0,0 +1,6 @@
1
+ export enum Direction {
2
+ LEFT = 'left',
3
+ RIGHT = 'right',
4
+ TOP = 'top',
5
+ BOTTOM = 'bottom'
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imaginario27/air-ui-ds",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "author": "imaginario27",
5
5
  "type": "module",
6
6
  "homepage": "https://air-ui.netlify.app/",