Skip to content

Commit

Permalink
Merge pull request #26 from formsible/feat/components
Browse files Browse the repository at this point in the history
Feat/components
  • Loading branch information
tewnut authored Oct 29, 2024
2 parents 2bb716b + ea6397e commit f7e92d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
4 changes: 3 additions & 1 deletion components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ declare module 'vue' {
Html_block_list: typeof import('./src/components/html_block_list/index.vue')['default']
Html_block_media: typeof import('./src/components/html_block_media/index.vue')['default']
Image_choice: typeof import('./src/components/image_choice/index.vue')['default']
InputText: typeof import('primevue/inputtext')['default']
Likert_scale: typeof import('./src/components/likert_scale/index.vue')['default']
List: typeof import('./src/components/list/index.vue')['default']
Locale_selector: typeof import('./src/components/locale_selector/index.vue')['default']
Expand All @@ -40,7 +41,7 @@ declare module 'vue' {
Net_promoter_score: typeof import('./src/components/net_promoter_score/index.vue')['default']
Number: typeof import('./src/components/number/index.vue')['default']
Page_break: typeof import('./src/components/page_break/index.vue')['default']
Password: typeof import('primevue/password')['default']
Password: typeof import('./src/components/password/index.vue')['default']
Payment: typeof import('./src/components/payment/index.vue')['default']
Phone_number: typeof import('./src/components/phone_number/index.vue')['default']
ProgressSpinner: typeof import('primevue/progressspinner')['default']
Expand All @@ -52,6 +53,7 @@ declare module 'vue' {
Signature: typeof import('./src/components/signature/index.vue')['default']
Slider: typeof import('./src/components/slider/index.vue')['default']
Term_of_service: typeof import('./src/components/term_of_service/index.vue')['default']
Textarea: typeof import('primevue/textarea')['default']
Time_picker: typeof import('./src/components/time_picker/index.vue')['default']
Website: typeof import('./src/components/website/index.vue')['default']
}
Expand Down
19 changes: 3 additions & 16 deletions src/components/multiple_choice/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script setup lang="ts">
import { computed, ComputedRef } from 'vue'
import type { InputChoice, InputChoiceProperties } from '~/types'
import { computed } from 'vue'
import type { InputChoiceProperties } from '~/types'
import RadioButton from 'primevue/radiobutton'
import { useFetch } from '@vueuse/core'
interface Props {
input: InputChoiceProperties
Expand All @@ -13,22 +12,10 @@ const isRequired = computed(() =>
props.input.validations?.map((v) => v.rule).includes('required'),
)
const model = defineModel<string>({ default: '' })
const computedChoices: ComputedRef<InputChoice[] | null> = computed(() => {
if (props.input.fetch) {
const {
// isFetching,
// error: fetchError,
data,
} = useFetch<InputChoice[]>(props.input.fetch.url)
return data.value
} else return props.input.choices
})
</script>

<template>
<div>
<pre>{{ computedChoices }}</pre>
<label :for="input.key">
{{ input.label }}
<span v-if="isRequired" class="text-red-600 dark:text-red-400"
Expand All @@ -39,7 +26,7 @@ const computedChoices: ComputedRef<InputChoice[] | null> = computed(() => {
<p>{{ input.description }}</p>
<div>
<div
v-for="option in computedChoices"
v-for="option in input.choices"
:key="option.value"
class="flex items-center"
>
Expand Down

0 comments on commit f7e92d8

Please sign in to comment.