feat: support presets (#14)

This commit is contained in:
Benjamin Canac
2021-11-26 14:22:43 +01:00
committed by GitHub
parent e05cc89866
commit 8f09d0c5ef
11 changed files with 351 additions and 269 deletions

View File

@@ -54,6 +54,8 @@
</template>
<script setup>
import $ui from '#build/ui'
const nuxtApp = useNuxtApp()
const { params } = useRoute()
@@ -74,8 +76,15 @@ const refProps = Object.entries(componentProps).map(([key, prop]) => {
let values
if (prop.validator) {
const result = prop.validator.toString().match(/\[.*\]/g, '')[0]
values = JSON.parse(result.replace(/'/g, '"')).filter(Boolean)
const arrayRegex = prop.validator.toString().match(/\[.*\]/g, '')
if (arrayRegex) {
values = JSON.parse(arrayRegex[0].replace(/'/g, '"')).filter(Boolean)
} else {
const $uiProp = $ui[params.component.toLowerCase()][key]
if ($uiProp) {
values = Object.keys($uiProp).filter(Boolean)
}
}
}
if (value) {