@ederzeel/nuxt-schema-form-nightly 0.1.0-28989865.c565459
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.
- package/.github/semantic.yml +15 -0
- package/.github/workflows/ci.yml +79 -0
- package/.github/workflows/release.yml +62 -0
- package/LICENSE.md +9 -0
- package/README.md +11 -0
- package/eslint.config.mjs +73 -0
- package/package.json +66 -0
- package/playground/app.vue +5 -0
- package/playground/assets/schema-custom.json +111 -0
- package/playground/assets/schema-easy.json +16 -0
- package/playground/assets/schema.json +116 -0
- package/playground/components/ColorMode.vue +26 -0
- package/playground/components/CustomInput.vue +7 -0
- package/playground/components/MultiStage.vue +164 -0
- package/playground/components/Stepper.vue +63 -0
- package/playground/nuxt.config.ts +13 -0
- package/playground/package.json +8 -0
- package/playground/pages/index.vue +32 -0
- package/playground/tailwind.config.js +1 -0
- package/playground/tsconfig.json +4 -0
- package/pnpm-workspace.yaml +2 -0
- package/prettier.config.mjs +8 -0
- package/scripts/bump-nightly.ts +25 -0
- package/scripts/release-nightly.sh +24 -0
- package/scripts/release.sh +21 -0
- package/src/defaults.ts +3 -0
- package/src/module.ts +35 -0
- package/src/plugins/app-config.ts +24 -0
- package/src/plugins/components.ts +68 -0
- package/src/plugins/nuxt-environment.ts +40 -0
- package/src/runtime/components/SComponent.vue +57 -0
- package/src/runtime/components/SForm.vue +59 -0
- package/src/runtime/components/SInputField.vue +25 -0
- package/src/runtime/components/SObject.vue +34 -0
- package/src/runtime/components/SSelect.vue +26 -0
- package/src/runtime/components/STextarea.vue +24 -0
- package/src/runtime/components/SToggle.vue +21 -0
- package/src/runtime/types/utils.ts +44 -0
- package/src/unplugin.ts +46 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
id: string
|
|
4
|
+
title: string
|
|
5
|
+
description: string
|
|
6
|
+
type: string
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const value = defineModel<string | number>({ required: true })
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<div>
|
|
14
|
+
<UFormGroup
|
|
15
|
+
:label="props.title || id"
|
|
16
|
+
:description="props.description"
|
|
17
|
+
:name="props.id"
|
|
18
|
+
>
|
|
19
|
+
<UInput
|
|
20
|
+
v-model="value"
|
|
21
|
+
:type="props.type"
|
|
22
|
+
/>
|
|
23
|
+
</UFormGroup>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import SComponent from './SComponent.vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{
|
|
5
|
+
id: string
|
|
6
|
+
jsonSchemaPath: string
|
|
7
|
+
properties: PropertiesType
|
|
8
|
+
modelValue: Record<string, unknown>
|
|
9
|
+
}>()
|
|
10
|
+
|
|
11
|
+
type PropertiesType = {
|
|
12
|
+
[key: string]: unknown
|
|
13
|
+
}
|
|
14
|
+
const emit = defineEmits(['update:modelValue'])
|
|
15
|
+
const onInput = (value: unknown, key: string) => {
|
|
16
|
+
emit('update:modelValue', { ...props.modelValue, [key]: value })
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div>
|
|
22
|
+
<h3>{{ props.properties.title }}</h3>
|
|
23
|
+
|
|
24
|
+
<SComponent
|
|
25
|
+
v-for="[key, options] of Object.entries(properties)"
|
|
26
|
+
:id="id.length <= 0 ? `${key}` : `${id}.${key}`"
|
|
27
|
+
:key="key"
|
|
28
|
+
:model-value="modelValue[key]"
|
|
29
|
+
:json-schema-path="jsonSchemaPath?.length <= 0 ? `properties.${key}` : `${jsonSchemaPath}.properties.${key}`"
|
|
30
|
+
v-bind="options"
|
|
31
|
+
@update:model-value="event => onInput(event, key)"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
id: string
|
|
4
|
+
title: string
|
|
5
|
+
description: string
|
|
6
|
+
enum: string[]
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const value = defineModel<string>({ required: true })
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<div>
|
|
14
|
+
<UFormGroup
|
|
15
|
+
:label="props.title || id"
|
|
16
|
+
:description="props.description"
|
|
17
|
+
:name="props.id"
|
|
18
|
+
>
|
|
19
|
+
<USelect
|
|
20
|
+
v-model="value"
|
|
21
|
+
placeholder="select size"
|
|
22
|
+
:options="props.enum"
|
|
23
|
+
/>
|
|
24
|
+
</UFormGroup>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
id: string
|
|
4
|
+
title: string
|
|
5
|
+
description: string
|
|
6
|
+
}>()
|
|
7
|
+
|
|
8
|
+
const value = defineModel<string | number>({ required: true })
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<div>
|
|
13
|
+
<UFormGroup
|
|
14
|
+
:label="props.title || id"
|
|
15
|
+
:description="props.description"
|
|
16
|
+
:name="props.id"
|
|
17
|
+
>
|
|
18
|
+
<UTextarea
|
|
19
|
+
v-model="value"
|
|
20
|
+
v-bind="properties"
|
|
21
|
+
/>
|
|
22
|
+
</UFormGroup>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
id: string
|
|
4
|
+
title: string
|
|
5
|
+
description: string
|
|
6
|
+
}>()
|
|
7
|
+
|
|
8
|
+
const value = defineModel<boolean>({ required: true })
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<div>
|
|
13
|
+
<UFormGroup
|
|
14
|
+
:label="props.title || id"
|
|
15
|
+
:description="props.description"
|
|
16
|
+
:name="props.id"
|
|
17
|
+
>
|
|
18
|
+
<UToggle v-model="value" />
|
|
19
|
+
</UFormGroup>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { VNode } from 'vue'
|
|
2
|
+
|
|
3
|
+
export interface TightMap<O = any> {
|
|
4
|
+
[key: string]: TightMap | O
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type DeepPartial<T, O = any> = {
|
|
8
|
+
[P in keyof T]?: T[P] extends Array<string> ? string : T[P] extends object ? DeepPartial<T[P], O> : T[P]
|
|
9
|
+
} & {
|
|
10
|
+
[key: string]: O | TightMap<O>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type DynamicSlots<T extends { slot?: string }, SlotProps, Slot = T['slot']> = Record<string, SlotProps> &
|
|
14
|
+
(Slot extends string ? Record<Slot, SlotProps> : Record<string, never>)
|
|
15
|
+
|
|
16
|
+
export type GetObjectField<MaybeObject, Key extends string> =
|
|
17
|
+
MaybeObject extends Record<string, any> ? MaybeObject[Key] : never
|
|
18
|
+
|
|
19
|
+
export type PartialString<T> = {
|
|
20
|
+
[K in keyof T]?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type MaybeArrayOfArray<T> = T[] | T[][]
|
|
24
|
+
export type MaybeArrayOfArrayItem<I> = I extends Array<infer T> ? (T extends Array<infer U> ? U : T) : never
|
|
25
|
+
|
|
26
|
+
export type SelectModelValue<T, V, M extends boolean = false, DV = T> = (
|
|
27
|
+
T extends Record<string, any> ? (V extends keyof T ? T[V] : DV) : T
|
|
28
|
+
) extends infer U
|
|
29
|
+
? M extends true
|
|
30
|
+
? U[]
|
|
31
|
+
: U
|
|
32
|
+
: never
|
|
33
|
+
|
|
34
|
+
export type SelectItemKey<T> = T extends Record<string, any> ? keyof T : string
|
|
35
|
+
|
|
36
|
+
export type SelectModelValueEmits<T, V, M extends boolean = false, DV = T> = {
|
|
37
|
+
'update:modelValue': [payload: SelectModelValue<T, V, M, DV>]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type StringOrVNode = string | VNode | (() => VNode)
|
|
41
|
+
|
|
42
|
+
export type EmitsToProps<T> = {
|
|
43
|
+
[K in keyof T as `on${Capitalize<string & K>}`]: T[K] extends [...args: infer Args] ? (...args: Args) => void : never
|
|
44
|
+
}
|
package/src/unplugin.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
|
|
3
|
+
import { join, normalize } from 'pathe'
|
|
4
|
+
import { createUnplugin } from 'unplugin'
|
|
5
|
+
import AutoImport from 'unplugin-auto-import'
|
|
6
|
+
import { defu } from 'defu'
|
|
7
|
+
// import tailwind from '@tailwindcss/vite'
|
|
8
|
+
// import type colors from 'tailwindcss/colors'
|
|
9
|
+
|
|
10
|
+
// import type * as ui from '#build/ui'
|
|
11
|
+
|
|
12
|
+
import { defaultOptions } from './defaults'
|
|
13
|
+
import type { ModuleOptions } from './module'
|
|
14
|
+
|
|
15
|
+
// import TemplatePlugin from './plugins/templates'
|
|
16
|
+
// import PluginsPlugin from './plugins/plugins'
|
|
17
|
+
import AppConfigPlugin from './plugins/app-config'
|
|
18
|
+
import ComponentImportPlugin from './plugins/components'
|
|
19
|
+
import NuxtEnvironmentPlugin from './plugins/nuxt-environment'
|
|
20
|
+
|
|
21
|
+
// import type { DeepPartial } from './runtime/types/utils'
|
|
22
|
+
|
|
23
|
+
// type AppConfigUI = DeepPartial<typeof ui>
|
|
24
|
+
|
|
25
|
+
export interface NuxtUIOptions extends Omit<ModuleOptions, 'fonts' | 'colorMode'> {
|
|
26
|
+
ui?: object
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const runtimeDir = normalize(fileURLToPath(new URL('./runtime', import.meta.url)))
|
|
30
|
+
|
|
31
|
+
export const NuxtUIPlugin = createUnplugin<NuxtUIOptions | undefined>((_options = {}, meta) => {
|
|
32
|
+
const options = defu(_options, { fonts: false, devtools: { enabled: false } }, defaultOptions)
|
|
33
|
+
|
|
34
|
+
const appConfig = { ui: options.ui }
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
37
|
+
return [
|
|
38
|
+
NuxtEnvironmentPlugin(),
|
|
39
|
+
...ComponentImportPlugin(meta.framework, options),
|
|
40
|
+
AutoImport[meta.framework]({ dts: true, dirs: [join(runtimeDir, 'composables')] }),
|
|
41
|
+
// tailwind(),
|
|
42
|
+
// PluginsPlugin(options),
|
|
43
|
+
// TemplatePlugin(options, appConfig),
|
|
44
|
+
AppConfigPlugin(options, appConfig)
|
|
45
|
+
]
|
|
46
|
+
})
|