@ederzeel/nuxt-schema-form-nightly 0.1.0-29021155.86a2d08 → 0.1.0-29022346.1443684

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,56 @@
1
+ <script setup lang="ts">
2
+ import { computed, type PropType } from 'vue'
3
+ import { DatePicker as VCalendarDatePicker } from 'v-calendar'
4
+ // @ts-ignore
5
+ import type { DatePickerDate, DatePickerRangeObject } from 'v-calendar/dist/types/src/use/datePicker'
6
+ import 'v-calendar/dist/style.css'
7
+
8
+ defineOptions({
9
+ inheritAttrs: false
10
+ })
11
+
12
+ const props = defineProps({
13
+ modelValue: {
14
+ type: [Date, Object] as PropType<DatePickerDate | DatePickerRangeObject | null>,
15
+ default: null
16
+ }
17
+ })
18
+
19
+ const emit = defineEmits(['update:model-value', 'close'])
20
+
21
+ const date = computed({
22
+ get: () => props.modelValue,
23
+ set: value => {
24
+ emit('update:model-value', value)
25
+ emit('close')
26
+ }
27
+ })
28
+
29
+ const attrs = {
30
+ transparent: true,
31
+ borderless: true,
32
+ color: 'primary',
33
+ 'is-dark': { selector: 'html', darkClass: 'dark' },
34
+ 'first-day-of-week': 2
35
+ }
36
+
37
+ function onDayClick(_: any, event: MouseEvent): void {
38
+ const target = event.target as HTMLElement
39
+ target.blur()
40
+ }
41
+ </script>
42
+
43
+ <template>
44
+ <VCalendarDatePicker
45
+ v-if="date && (date as DatePickerRangeObject)?.start && (date as DatePickerRangeObject)?.end"
46
+ v-model.range="date"
47
+ :columns="2"
48
+ v-bind="{ ...attrs, ...$attrs }"
49
+ @dayclick="onDayClick"
50
+ />
51
+ <VCalendarDatePicker v-else v-model="date" v-bind="{ ...attrs, ...$attrs }" @dayclick="onDayClick" />
52
+ </template>
53
+
54
+ <style>
55
+ :root{--vc-gray-50:rgb(var(--color-gray-50));--vc-gray-100:rgb(var(--color-gray-100));--vc-gray-200:rgb(var(--color-gray-200));--vc-gray-300:rgb(var(--color-gray-300));--vc-gray-400:rgb(var(--color-gray-400));--vc-gray-500:rgb(var(--color-gray-500));--vc-gray-600:rgb(var(--color-gray-600));--vc-gray-700:rgb(var(--color-gray-700));--vc-gray-800:rgb(var(--color-gray-800));--vc-gray-900:rgb(var(--color-gray-900))}.vc-primary{--vc-accent-50:rgb(var(--color-primary-50));--vc-accent-100:rgb(var(--color-primary-100));--vc-accent-200:rgb(var(--color-primary-200));--vc-accent-300:rgb(var(--color-primary-300));--vc-accent-400:rgb(var(--color-primary-400));--vc-accent-500:rgb(var(--color-primary-500));--vc-accent-600:rgb(var(--color-primary-600));--vc-accent-700:rgb(var(--color-primary-700));--vc-accent-800:rgb(var(--color-primary-800));--vc-accent-900:rgb(var(--color-primary-900))}
56
+ </style>
@@ -12,6 +12,8 @@ export type SComponentProps = {
12
12
  type: string
13
13
  properties?: Properties
14
14
  enum?: string[]
15
+ enum_titles?: string[]
16
+ format?: string
15
17
  description?: string
16
18
  jsonSchemaPath?: string
17
19
  validateFields?: (fields: string[]) => Promise<boolean>
@@ -35,6 +37,7 @@ const options = computed(() => ({
35
37
  v-model="value"
36
38
  />
37
39
 
40
+ <SDate v-else-if="type === 'string' && format === 'date-time'" v-bind="options" v-model="value" />
38
41
  <SInputField v-else-if="type === 'string'" v-bind="options" v-model="value" />
39
42
  <SToggle v-else-if="type === 'boolean'" v-bind="options" v-model="value" />
40
43
  <SObject v-else-if="type === 'object'" v-bind="options" v-model="value" />
@@ -0,0 +1,28 @@
1
+ <script lang="ts" setup>
2
+ import { format } from 'date-fns'
3
+ import { computed, ref } from 'vue'
4
+ import DatePicker from './DatePicker.vue'
5
+ const props = defineProps<{
6
+ id: string
7
+ title?: string
8
+ description?: string
9
+ type: string
10
+ }>()
11
+
12
+ const value = defineModel<string>({ required: true })
13
+ const date = ref(new Date(value.value))
14
+ </script>
15
+
16
+ <template>
17
+ <div>
18
+ <UFormGroup :label="props.title || id" :description="props.description" :name="props.id">
19
+ <UPopover :popper="{ placement: 'bottom-start' }">
20
+ <UButton icon="i-heroicons-calendar-days-20-solid" :label="format(date, 'd MMM, yyy')" />
21
+
22
+ <template #panel="{ close }">
23
+ <DatePicker v-model="date" is-required @close="close" />
24
+ </template>
25
+ </UPopover>
26
+ </UFormGroup>
27
+ </div>
28
+ </template>
@@ -1,18 +1,29 @@
1
1
  <script lang="ts" setup>
2
+ import { computed } from 'vue'
3
+
2
4
  const props = defineProps<{
3
5
  id: string
4
6
  title?: string
5
7
  description?: string
6
8
  enum: string[]
9
+ enum_titles: string[]
7
10
  }>()
8
11
 
12
+ const options = computed(() => props.enum.map((x, i) => ({ key: props?.enum_titles?.[i] ?? x, value: x })))
13
+
9
14
  const value = defineModel<string>({ required: true })
10
15
  </script>
11
16
 
12
17
  <template>
13
18
  <div>
14
19
  <UFormGroup :label="props.title || id" :description="props.description" :name="props.id">
15
- <USelect v-model="value" placeholder="select size" :options="props.enum" />
20
+ <USelect
21
+ v-model="value"
22
+ placeholder="select size"
23
+ :options="options"
24
+ value-attribute="value"
25
+ option-attribute="key"
26
+ />
16
27
  </UFormGroup>
17
28
  </div>
18
29
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ederzeel/nuxt-schema-form-nightly",
3
- "version": "0.1.0-29021155.86a2d08",
3
+ "version": "0.1.0-29022346.1443684",
4
4
  "description": "A runtime form generator for nuxt",
5
5
  "type": "module",
6
6
  "exports": {
@@ -47,6 +47,7 @@
47
47
  "@nuxt/kit": "^3.15.4",
48
48
  "@nuxt/module-builder": "^0.8.4",
49
49
  "@types/eslint": "^9.6.1",
50
+ "date-fns": "^4.1.0",
50
51
  "eslint": "^9.19.0",
51
52
  "eslint-config-prettier": "^10.0.1",
52
53
  "globals": "^15.14.0",
@@ -65,6 +66,7 @@
65
66
  "unplugin": "^2.1.2",
66
67
  "unplugin-auto-import": "^19.0.0",
67
68
  "unplugin-vue-components": "^28.0.0",
69
+ "v-calendar": "^3.1.2",
68
70
  "yup": "^1.6.1"
69
71
  },
70
72
  "resolutions": {