@brickflow/ui 0.0.56 → 0.0.58

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 (47) hide show
  1. package/dist/module.d.mts +4 -2
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +35 -7
  4. package/dist/runtime/brickflow-ui.d.ts +1 -0
  5. package/dist/runtime/components/Button/index.vue +5 -3
  6. package/dist/runtime/components/Dialog/DemoContent.vue +33 -0
  7. package/dist/runtime/components/Dialog/DemoForm.vue +54 -0
  8. package/dist/runtime/components/Dialog/DemoSimple.vue +23 -0
  9. package/dist/runtime/components/Dialog/DemoStack.vue +41 -0
  10. package/dist/runtime/components/Dialog/Host.vue +654 -0
  11. package/dist/runtime/components/Dialog/basic.demo.vue +27 -0
  12. package/dist/runtime/components/Dialog/form.demo.vue +34 -0
  13. package/dist/runtime/components/Dialog/index.vue +53 -0
  14. package/dist/runtime/components/Dialog/scroll.demo.vue +27 -0
  15. package/dist/runtime/components/Dialog/stack.demo.vue +19 -0
  16. package/dist/runtime/components/Form/index.vue +46 -1
  17. package/dist/runtime/components/Form/login.demo.vue +12 -1
  18. package/dist/runtime/components/Form/rules.demo.vue +108 -0
  19. package/dist/runtime/components/Icon/gallery.demo.vue +1 -1
  20. package/dist/runtime/components/Icon/index.vue +3 -1
  21. package/dist/runtime/components/Input/index.vue +151 -27
  22. package/dist/runtime/components/Input/label.demo.vue +15 -3
  23. package/dist/runtime/components/Input/mask.demo.vue +73 -0
  24. package/dist/runtime/components/Input/variants.demo.vue +16 -0
  25. package/dist/runtime/components/InputNumber/controls.demo.vue +145 -0
  26. package/dist/runtime/components/InputNumber/denominator.demo.vue +1 -1
  27. package/dist/runtime/components/InputNumber/index.vue +29 -8
  28. package/dist/runtime/components/TransitionSize/duration.demo.vue +88 -0
  29. package/dist/runtime/components/TransitionSize/flex.demo.vue +112 -0
  30. package/dist/runtime/components/TransitionSize/height.demo.vue +88 -0
  31. package/dist/runtime/components/TransitionSize/index.vue +69 -27
  32. package/dist/runtime/components/TransitionSize/width.demo.vue +88 -0
  33. package/dist/runtime/composables/useBrickflow.d.ts +2 -0
  34. package/dist/runtime/composables/useDialog.d.ts +38 -0
  35. package/dist/runtime/composables/useDialog.js +40 -0
  36. package/dist/runtime/composables/useFieldRules.d.ts +16 -0
  37. package/dist/runtime/composables/useFieldRules.js +42 -0
  38. package/dist/runtime/composables/useScreen.d.ts +8 -0
  39. package/dist/runtime/plugins/dialog.d.ts +3 -0
  40. package/dist/runtime/plugins/dialog.js +22 -0
  41. package/dist/runtime/tailwind.d.ts +1 -1
  42. package/dist/runtime/tailwind.js +2 -2
  43. package/dist/runtime/utils/rules.d.ts +34 -0
  44. package/dist/runtime/utils/rules.js +68 -0
  45. package/dist/types.d.mts +4 -0
  46. package/package.json +7 -6
  47. package/dist/runtime/icon-font.d.ts +0 -4
@@ -0,0 +1,73 @@
1
+ <script lang="ts">
2
+ export const uiDemo = {
3
+ description:
4
+ 'Use Maska tokens in the mask prop. Pass an options object for custom tokens or an array for alternative masks.',
5
+ title: 'Mask',
6
+ }
7
+ </script>
8
+
9
+ <script lang="ts" setup>
10
+ import { ref } from 'vue'
11
+
12
+ import Input from './index.vue'
13
+
14
+ const phone = ref('')
15
+ const digits = ref('')
16
+ const alternativeMasks = ['###-###', '###-###-###']
17
+ const customMask = {
18
+ mask: 'AA-####',
19
+ tokens: {
20
+ A: { pattern: /[a-z]/i, transform: (character: string) => character.toUpperCase() },
21
+ },
22
+ }
23
+ </script>
24
+
25
+ <template>
26
+ <div class="flex max-w-sm flex-col gap-5">
27
+ <p class="text-sm text-zinc-400">
28
+ Default tokens:
29
+ <code>#</code>
30
+ is a digit,
31
+ <code>@</code>
32
+ is a letter, and
33
+ <code>*</code>
34
+ is a letter or digit. Other characters are literals; prefix a token with
35
+ <code>!</code>
36
+ to display it literally. See
37
+ <a
38
+ class="text-blue-400 underline"
39
+ href="https://beholdr.github.io/maska/v3/#/tokens"
40
+ target="_blank"
41
+ rel="noopener noreferrer"
42
+ >
43
+ Maska token documentation
44
+ </a>
45
+ .
46
+ </p>
47
+ <Input
48
+ :value="phone"
49
+ mask="+## (###) ###-##-##"
50
+ label="Phone: +## (###) ###-##-##"
51
+ placeholder="+48 (123) 456-78-90"
52
+ type="tel"
53
+ @input="(value) => (phone = value)"
54
+ @mask="(detail) => (digits = detail.unmasked)"
55
+ />
56
+ <div class="text-sm text-zinc-400">Masked: {{ phone }} · Raw: {{ digits }}</div>
57
+ <Input
58
+ mask="@@-####"
59
+ label="Letters and digits: @@-####"
60
+ placeholder="AB-1234"
61
+ />
62
+ <Input
63
+ :mask="alternativeMasks"
64
+ label="Alternative lengths: ###-### or ###-###-###"
65
+ placeholder="123-456-789"
66
+ />
67
+ <Input
68
+ :mask="customMask"
69
+ label="Custom uppercase token: AA-####"
70
+ placeholder="AB-1234"
71
+ />
72
+ </div>
73
+ </template>
@@ -5,11 +5,19 @@
5
5
  </script>
6
6
 
7
7
  <script lang="ts" setup>
8
+ import { onMounted, ref } from 'vue'
9
+
8
10
  import { uiConfig } from '#brickflow-ui'
9
11
 
12
+ import { rule } from '../../utils/rules'
10
13
  import Input from './index.vue'
11
14
 
12
15
  const inputConfig = uiConfig.input
16
+ const errorInputs = ref<InstanceType<typeof Input>[]>([])
17
+
18
+ onMounted(() => {
19
+ errorInputs.value.forEach((input) => input.validate())
20
+ })
13
21
  </script>
14
22
 
15
23
  <template>
@@ -24,6 +32,14 @@
24
32
  :label="`Variant ${variant}`"
25
33
  placeholder="Type here"
26
34
  />
35
+ <Input
36
+ ref="errorInputs"
37
+ :variant="variant"
38
+ :label="`Error ${variant}`"
39
+ :rules="[rule.required(), rule.minLength(4)]"
40
+ description="This description is hidden while the field has an error"
41
+ placeholder="Required field"
42
+ />
27
43
  <Input
28
44
  :variant="variant"
29
45
  :label="`Disabled ${variant}`"
@@ -0,0 +1,145 @@
1
+ <script lang="ts">
2
+ export const uiDemo = {
3
+ description: 'Custom step buttons built with the leading and trailing slots.',
4
+ title: 'Custom controls',
5
+ }
6
+ </script>
7
+
8
+ <script lang="ts" setup>
9
+ import { ref } from 'vue'
10
+
11
+ import InputNumber from './index.vue'
12
+
13
+ const horizontalValue = ref(20)
14
+ const verticalValue = ref(100)
15
+
16
+ const horizontalMin = 0
17
+ const horizontalMax = 25
18
+ const verticalMin = 0
19
+ const verticalMax = 120
20
+ const verticalStep = 5
21
+
22
+ const horizontalControlClass =
23
+ 'inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-plain-500 transition-colors enabled:hover:bg-plain-800 enabled:hover:text-plain-100 disabled:cursor-not-allowed disabled:opacity-40'
24
+ const verticalControlClass =
25
+ 'flex min-h-5 flex-1 items-center justify-center text-plain-500 transition-colors enabled:hover:bg-plain-800 enabled:hover:text-plain-100 disabled:cursor-not-allowed disabled:opacity-40'
26
+
27
+ function stepHorizontal(direction: -1 | 1): void {
28
+ horizontalValue.value = Math.max(horizontalMin, Math.min(horizontalMax, horizontalValue.value + direction))
29
+ }
30
+
31
+ function stepVertical(direction: -1 | 1): void {
32
+ verticalValue.value = Math.max(
33
+ verticalMin,
34
+ Math.min(verticalMax, verticalValue.value + direction * verticalStep),
35
+ )
36
+ }
37
+ </script>
38
+
39
+ <template>
40
+ <div class="flex max-w-sm flex-col gap-6">
41
+ <InputNumber
42
+ :value="horizontalValue"
43
+ align="center"
44
+ label="Number *"
45
+ description="This is a hint text to help user."
46
+ :min="horizontalMin"
47
+ :max="horizontalMax"
48
+ @input="horizontalValue = $event"
49
+ >
50
+ <template #leading>
51
+ <button
52
+ type="button"
53
+ :disabled="horizontalValue <= horizontalMin"
54
+ aria-label="Decrease number"
55
+ :class="[horizontalControlClass, '-ml-2']"
56
+ @click="stepHorizontal(-1)"
57
+ >
58
+ <span
59
+ aria-hidden="true"
60
+ class="text-2xl leading-none font-light"
61
+ >
62
+ −
63
+ </span>
64
+ </button>
65
+ </template>
66
+ <template #trailing>
67
+ <button
68
+ type="button"
69
+ :disabled="horizontalValue >= horizontalMax"
70
+ aria-label="Increase number"
71
+ :class="[horizontalControlClass, '-mr-2']"
72
+ @click="stepHorizontal(1)"
73
+ >
74
+ <span
75
+ aria-hidden="true"
76
+ class="text-2xl leading-none font-light"
77
+ >
78
+ +
79
+ </span>
80
+ </button>
81
+ </template>
82
+ </InputNumber>
83
+
84
+ <InputNumber
85
+ :value="verticalValue"
86
+ label="Number *"
87
+ description="This is a hint text to help user."
88
+ :step="verticalStep"
89
+ :min="verticalMin"
90
+ :max="verticalMax"
91
+ @input="verticalValue = $event"
92
+ >
93
+ <template #trailing>
94
+ <span
95
+ class="-mr-3 flex w-12 shrink-0 flex-col self-stretch overflow-hidden rounded-r-xl border-l border-neutral-600/20"
96
+ >
97
+ <button
98
+ type="button"
99
+ :disabled="verticalValue >= verticalMax"
100
+ aria-label="Increase number"
101
+ :class="verticalControlClass"
102
+ @click="stepVertical(1)"
103
+ >
104
+ <svg
105
+ aria-hidden="true"
106
+ class="size-4"
107
+ viewBox="0 0 16 16"
108
+ fill="none"
109
+ >
110
+ <path
111
+ d="m3 10 5-5 5 5"
112
+ stroke="currentColor"
113
+ stroke-width="2"
114
+ stroke-linecap="round"
115
+ stroke-linejoin="round"
116
+ />
117
+ </svg>
118
+ </button>
119
+ <button
120
+ type="button"
121
+ :disabled="verticalValue <= verticalMin"
122
+ aria-label="Decrease number"
123
+ :class="[verticalControlClass, 'border-t border-neutral-600/20']"
124
+ @click="stepVertical(-1)"
125
+ >
126
+ <svg
127
+ aria-hidden="true"
128
+ class="size-4"
129
+ viewBox="0 0 16 16"
130
+ fill="none"
131
+ >
132
+ <path
133
+ d="m3 6 5 5 5-5"
134
+ stroke="currentColor"
135
+ stroke-width="2"
136
+ stroke-linecap="round"
137
+ stroke-linejoin="round"
138
+ />
139
+ </svg>
140
+ </button>
141
+ </span>
142
+ </template>
143
+ </InputNumber>
144
+ </div>
145
+ </template>
@@ -10,7 +10,7 @@
10
10
 
11
11
  import InputNumber from './index.vue'
12
12
 
13
- const price = ref<number>(8.55)
13
+ const price = ref<number>(8)
14
14
  const price2 = ref<number>(12.55)
15
15
  </script>
16
16
 
@@ -1,5 +1,9 @@
1
1
  <script setup lang="ts" generic="T extends boolean = false">
2
- import { shallowRef, watch } from 'vue'
2
+ import { computed, ref, shallowRef, watch } from 'vue'
3
+
4
+ import type { IconName } from '#brickflow-ui'
5
+
6
+ import type { Rule } from '../../utils/rules'
3
7
 
4
8
  import { isEmpty } from '../../utils/checkup.js'
5
9
  import Input from '../Input/index.vue'
@@ -14,7 +18,7 @@
14
18
  denominator?: number
15
19
  description?: string
16
20
  disabled?: boolean
17
- icon?: string
21
+ icon?: IconName
18
22
  label?: string
19
23
  max?: number
20
24
  min?: number
@@ -28,9 +32,10 @@
28
32
  onTrailingIconClick?: () => void
29
33
  placeholder?: string
30
34
  readonly?: boolean
35
+ rules?: Rule<null | number>[]
31
36
  size?: InputProps['size']
32
37
  step?: number
33
- trailingIcon?: string
38
+ trailingIcon?: IconName
34
39
  value: true extends NoInfer<T> ? null | number : number
35
40
  variant?: InputProps['variant']
36
41
  }>(),
@@ -55,6 +60,7 @@
55
60
  onTrailingIconClick: undefined,
56
61
  placeholder: undefined,
57
62
  readonly: false,
63
+ rules: undefined,
58
64
  size: undefined,
59
65
  step: 1,
60
66
  trailingIcon: undefined,
@@ -64,7 +70,17 @@
64
70
 
65
71
  type InputProps = InstanceType<typeof Input>['$props']
66
72
 
73
+ const inputRef = ref<InstanceType<typeof Input> | null>(null)
67
74
  const inputValue = shallowRef(prepareValue(props.value))
75
+ const inputRules = computed(() =>
76
+ props.rules?.map(
77
+ (rule): Rule<string> =>
78
+ (value) =>
79
+ rule(value === '' ? null : Number(value)),
80
+ ),
81
+ )
82
+
83
+ defineExpose({ validate: () => inputRef.value?.validate() ?? true })
68
84
 
69
85
  watch(
70
86
  () => props.value,
@@ -99,6 +115,10 @@
99
115
  const allowedRegexp = /^-?\d*(?:\.\d*)?$/
100
116
  const validNumberRegexp = /^-?(?:\d+(?:\.\d+)?|\.\d+)$/
101
117
 
118
+ function emitInput(value: typeof props.value): void {
119
+ props.onInput?.(value)
120
+ }
121
+
102
122
  function handleInput(rawValue: string, target: HTMLInputElement | null): void {
103
123
  if (!target) {
104
124
  return
@@ -109,7 +129,7 @@
109
129
  if (isEmpty(nextValue)) {
110
130
  if (props.nullable) {
111
131
  inputValue.value = ''
112
- props.onInput?.(null as typeof props.value)
132
+ emitInput(null as typeof props.value)
113
133
  }
114
134
  return
115
135
  }
@@ -128,7 +148,7 @@
128
148
  if (isEmpty(nextValue) || !validNumberRegexp.test(nextValue)) {
129
149
  if (isEmpty(nextValue) && props.nullable) {
130
150
  inputValue.value = ''
131
- props.onInput?.(null as typeof props.value)
151
+ emitInput(null as typeof props.value)
132
152
  }
133
153
  return
134
154
  }
@@ -143,7 +163,7 @@
143
163
  nextValueNumber = props.max
144
164
  }
145
165
 
146
- props.onInput?.(nextValueNumber)
166
+ emitInput(nextValueNumber)
147
167
  }
148
168
 
149
169
  function handleKeydown(event: KeyboardEvent): void {
@@ -158,7 +178,6 @@
158
178
  if (!Number.isFinite(props.step) || props.step <= 0) {
159
179
  return
160
180
  }
161
-
162
181
  event.preventDefault()
163
182
  const parsedValue = Number(target.value)
164
183
  const currentValue = target.value !== '' && Number.isFinite(parsedValue) ? parsedValue : (props.value ?? 0)
@@ -174,7 +193,7 @@
174
193
  }
175
194
 
176
195
  target.value = prepareValue(nextValue)
177
- props.onInput?.(nextValue)
196
+ emitInput(nextValue)
178
197
  }
179
198
 
180
199
  function prepareValue(value: typeof props.value): string {
@@ -184,6 +203,7 @@
184
203
 
185
204
  <template>
186
205
  <Input
206
+ ref="inputRef"
187
207
  v-bind="{
188
208
  ...$attrs,
189
209
  }"
@@ -197,6 +217,7 @@
197
217
  :icon="props.icon"
198
218
  :placeholder="props.placeholder"
199
219
  :readonly="props.readonly"
220
+ :rules="inputRules"
200
221
  :size="props.size"
201
222
  :trailingIcon="props.trailingIcon"
202
223
  :type="props.denominator === 0 ? 'numeric' : 'decimal'"
@@ -0,0 +1,88 @@
1
+ <script lang="ts">
2
+ export const uiDemo = {
3
+ title: 'Duration',
4
+ }
5
+ </script>
6
+
7
+ <script lang="ts" setup>
8
+ import { ref } from 'vue'
9
+
10
+ import TransitionSize from './index.vue'
11
+
12
+ const active100 = ref(true)
13
+ const active500 = ref(true)
14
+ const active2000 = ref(true)
15
+ </script>
16
+
17
+ <template>
18
+ <div class="flex w-full flex-col">
19
+ <code class="mb-2">100</code>
20
+ <div class="flex w-full">
21
+ <TransitionSize
22
+ :duration="100"
23
+ dimension="width"
24
+ >
25
+ <div
26
+ v-if="active100"
27
+ class="w-full rounded-xl bg-slate-700 p-2 text-center"
28
+ >
29
+ Text
30
+ </div>
31
+ </TransitionSize>
32
+ <button
33
+ type="button"
34
+ class="ml-2 w-30 shrink-0 cursor-pointer rounded-xl px-3 py-2"
35
+ :class="active100 ? 'bg-blue-500' : 'bg-blue-800'"
36
+ @click="active100 = !active100"
37
+ >
38
+ {{ active100 ? 'Hide' : 'Show' }}
39
+ </button>
40
+ </div>
41
+
42
+ <code class="mt-4 mb-2">500</code>
43
+ <div class="flex">
44
+ <TransitionSize
45
+ :duration="500"
46
+ dimension="width"
47
+ >
48
+ <div
49
+ v-if="active500"
50
+ class="w-full rounded-xl bg-slate-700 p-2 text-center whitespace-nowrap"
51
+ >
52
+ Text
53
+ </div>
54
+ </TransitionSize>
55
+ <button
56
+ type="button"
57
+ class="ml-2 w-30 shrink-0 cursor-pointer rounded-xl px-3 py-2"
58
+ :class="active500 ? 'bg-blue-500' : 'bg-blue-800'"
59
+ @click="active500 = !active500"
60
+ >
61
+ {{ active500 ? 'Hide' : 'Show' }}
62
+ </button>
63
+ </div>
64
+
65
+ <code class="mt-4 mb-2">2000</code>
66
+ <div class="flex w-full">
67
+ <TransitionSize
68
+ :duration="2000"
69
+ dimension="width"
70
+ >
71
+ <div
72
+ v-if="active2000"
73
+ class="w-full rounded-xl bg-slate-700 p-2 text-center"
74
+ >
75
+ Text
76
+ </div>
77
+ </TransitionSize>
78
+ <button
79
+ type="button"
80
+ class="ml-2 w-30 shrink-0 cursor-pointer rounded-xl px-3 py-2"
81
+ :class="active2000 ? 'bg-blue-500' : 'bg-blue-800'"
82
+ @click="active2000 = !active2000"
83
+ >
84
+ {{ active2000 ? 'Hide' : 'Show' }}
85
+ </button>
86
+ </div>
87
+ </div>
88
+ </template>
@@ -0,0 +1,112 @@
1
+ <script lang="ts">
2
+ export const uiDemo = {
3
+ title: 'Flex Parent with Gap',
4
+ }
5
+ </script>
6
+
7
+ <script lang="ts" setup>
8
+ import { ref } from 'vue'
9
+
10
+ import TransitionSize from './index.vue'
11
+
12
+ const baseStartRef = ref<HTMLElement | null>(null)
13
+ const baseCenterRef = ref<HTMLElement | null>(null)
14
+ const baseEndRef = ref<HTMLElement | null>(null)
15
+ const activeStart = ref(true)
16
+ const activeCenter = ref(true)
17
+ const activeEnd = ref(true)
18
+ </script>
19
+
20
+ <template>
21
+ <div class="flex flex-col">
22
+ <code class="mb-2">flexDirection="start"</code>
23
+ <div
24
+ ref="baseStartRef"
25
+ class="flex grow basis-1 gap-10"
26
+ >
27
+ <TransitionSize
28
+ :duration="1000"
29
+ :flexParent="baseStartRef"
30
+ flexDirection="start"
31
+ dimension="width"
32
+ >
33
+ <div
34
+ v-if="activeStart"
35
+ class="h-10 grow rounded-xl bg-slate-700 p-2 text-center"
36
+ >
37
+ Text
38
+ </div>
39
+ </TransitionSize>
40
+ <div class="h-10 grow rounded-xl bg-slate-800 p-2 text-center">Text</div>
41
+ <div class="h-10 grow rounded-xl bg-slate-800 p-2 text-center">Text</div>
42
+ </div>
43
+ <button
44
+ type="button"
45
+ class="mt-3 w-30 shrink-0 cursor-pointer rounded-xl px-3 py-2"
46
+ :class="activeStart ? 'bg-blue-500' : 'bg-blue-800'"
47
+ @click="activeStart = !activeStart"
48
+ >
49
+ {{ activeStart ? 'Hide' : 'Show' }}
50
+ </button>
51
+
52
+ <code class="mt-6 mb-2">flexDirection="center"</code>
53
+ <div
54
+ ref="baseCenterRef"
55
+ class="flex grow basis-1 gap-10"
56
+ >
57
+ <div class="h-10 grow rounded-xl bg-slate-800 p-2 text-center">Text</div>
58
+ <TransitionSize
59
+ :duration="1000"
60
+ :flexParent="baseCenterRef"
61
+ flexDirection="center"
62
+ dimension="width"
63
+ >
64
+ <div
65
+ v-if="activeCenter"
66
+ class="h-10 grow rounded-xl bg-slate-700 p-2 text-center"
67
+ >
68
+ Text
69
+ </div>
70
+ </TransitionSize>
71
+ <div class="h-10 grow rounded-xl bg-slate-800 p-2 text-center">Text</div>
72
+ </div>
73
+ <button
74
+ type="button"
75
+ class="mt-3 w-30 shrink-0 cursor-pointer rounded-xl px-3 py-2"
76
+ :class="activeCenter ? 'bg-blue-500' : 'bg-blue-800'"
77
+ @click="activeCenter = !activeCenter"
78
+ >
79
+ {{ activeCenter ? 'Hide' : 'Show' }}
80
+ </button>
81
+
82
+ <code class="mt-6 mb-2">flexDirection="end"</code>
83
+ <div
84
+ ref="baseEndRef"
85
+ class="flex grow basis-1 gap-10"
86
+ >
87
+ <div class="h-10 grow rounded-xl bg-slate-800 p-2 text-center">Text</div>
88
+ <div class="h-10 grow rounded-xl bg-slate-800 p-2 text-center">Text</div>
89
+ <TransitionSize
90
+ :duration="1000"
91
+ :flexParent="baseEndRef"
92
+ flexDirection="end"
93
+ dimension="width"
94
+ >
95
+ <div
96
+ v-if="activeEnd"
97
+ class="h-10 grow rounded-xl bg-slate-700 p-2 text-center"
98
+ >
99
+ Text
100
+ </div>
101
+ </TransitionSize>
102
+ </div>
103
+ <button
104
+ type="button"
105
+ class="mt-3 w-30 shrink-0 cursor-pointer rounded-xl px-3 py-2"
106
+ :class="activeEnd ? 'bg-blue-500' : 'bg-blue-800'"
107
+ @click="activeEnd = !activeEnd"
108
+ >
109
+ {{ activeEnd ? 'Hide' : 'Show' }}
110
+ </button>
111
+ </div>
112
+ </template>
@@ -0,0 +1,88 @@
1
+ <script lang="ts">
2
+ export const uiDemo = {
3
+ title: 'Height',
4
+ }
5
+ </script>
6
+
7
+ <script lang="ts" setup>
8
+ import { ref } from 'vue'
9
+
10
+ import TransitionSize from './index.vue'
11
+
12
+ const activeHeightFixed = ref(true)
13
+ const activeHeightContent = ref(true)
14
+ const activeHeightFull = ref(true)
15
+ </script>
16
+
17
+ <template>
18
+ <div class="flex w-full gap-4">
19
+ <div class="flex grow basis-1 flex-col">
20
+ <label class="mb-2">Fixed height</label>
21
+ <TransitionSize
22
+ :duration="1000"
23
+ dimension="height"
24
+ >
25
+ <div
26
+ v-if="activeHeightFixed"
27
+ class="h-40 w-full rounded-xl bg-slate-700 p-2 text-center"
28
+ >
29
+ Text
30
+ </div>
31
+ </TransitionSize>
32
+ <button
33
+ type="button"
34
+ class="mt-3 w-full shrink-0 cursor-pointer rounded-xl px-3 py-2"
35
+ :class="activeHeightFixed ? 'bg-blue-500' : 'bg-blue-800'"
36
+ @click="activeHeightFixed = !activeHeightFixed"
37
+ >
38
+ {{ activeHeightFixed ? 'Hide' : 'Show' }}
39
+ </button>
40
+ </div>
41
+
42
+ <div class="flex grow basis-1 flex-col">
43
+ <label class="mb-2">Content based height</label>
44
+ <TransitionSize
45
+ :duration="1000"
46
+ dimension="height"
47
+ >
48
+ <div
49
+ v-if="activeHeightContent"
50
+ class="rounded-xl bg-slate-700 p-2 text-center"
51
+ >
52
+ Lorem, ipsum dolor sit amet consectetur adipisicing elit. Tenetur nihil possimus sunt ipsum rerum maiores
53
+ </div>
54
+ </TransitionSize>
55
+ <button
56
+ type="button"
57
+ class="mt-3 w-full shrink-0 cursor-pointer rounded-xl px-3 py-2"
58
+ :class="activeHeightContent ? 'bg-blue-500' : 'bg-blue-800'"
59
+ @click="activeHeightContent = !activeHeightContent"
60
+ >
61
+ {{ activeHeightContent ? 'Hide' : 'Show' }}
62
+ </button>
63
+ </div>
64
+
65
+ <div class="flex h-auto grow basis-1 flex-col self-stretch">
66
+ <label class="mb-2">Full height</label>
67
+ <TransitionSize
68
+ :duration="1000"
69
+ dimension="height"
70
+ >
71
+ <div
72
+ v-if="activeHeightFull"
73
+ class="w-full grow rounded-xl bg-slate-700 p-2 text-center"
74
+ >
75
+ Text
76
+ </div>
77
+ </TransitionSize>
78
+ <button
79
+ type="button"
80
+ class="mt-3 w-full shrink-0 cursor-pointer rounded-xl px-3 py-2"
81
+ :class="activeHeightFull ? 'bg-blue-500' : 'bg-blue-800'"
82
+ @click="activeHeightFull = !activeHeightFull"
83
+ >
84
+ {{ activeHeightFull ? 'Hide' : 'Show' }}
85
+ </button>
86
+ </div>
87
+ </div>
88
+ </template>