@htlkg/components 0.0.1
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/dist/composables/index.js +388 -0
- package/dist/composables/index.js.map +1 -0
- package/package.json +41 -0
- package/src/composables/index.ts +6 -0
- package/src/composables/useForm.test.ts +229 -0
- package/src/composables/useForm.ts +130 -0
- package/src/composables/useFormValidation.test.ts +189 -0
- package/src/composables/useFormValidation.ts +83 -0
- package/src/composables/useModal.property.test.ts +164 -0
- package/src/composables/useModal.ts +43 -0
- package/src/composables/useNotifications.test.ts +166 -0
- package/src/composables/useNotifications.ts +81 -0
- package/src/composables/useTable.property.test.ts +198 -0
- package/src/composables/useTable.ts +134 -0
- package/src/composables/useTabs.property.test.ts +247 -0
- package/src/composables/useTabs.ts +101 -0
- package/src/data/Chart.demo.vue +340 -0
- package/src/data/Chart.md +525 -0
- package/src/data/Chart.vue +133 -0
- package/src/data/DataList.md +80 -0
- package/src/data/DataList.test.ts +69 -0
- package/src/data/DataList.vue +46 -0
- package/src/data/SearchableSelect.md +107 -0
- package/src/data/SearchableSelect.vue +124 -0
- package/src/data/Table.demo.vue +296 -0
- package/src/data/Table.md +588 -0
- package/src/data/Table.property.test.ts +548 -0
- package/src/data/Table.test.ts +562 -0
- package/src/data/Table.unit.test.ts +544 -0
- package/src/data/Table.vue +321 -0
- package/src/data/index.ts +5 -0
- package/src/domain/BrandCard.md +81 -0
- package/src/domain/BrandCard.vue +63 -0
- package/src/domain/BrandSelector.md +84 -0
- package/src/domain/BrandSelector.vue +65 -0
- package/src/domain/ProductBadge.md +60 -0
- package/src/domain/ProductBadge.vue +47 -0
- package/src/domain/UserAvatar.md +84 -0
- package/src/domain/UserAvatar.vue +60 -0
- package/src/domain/domain-components.property.test.ts +449 -0
- package/src/domain/index.ts +4 -0
- package/src/forms/DateRange.demo.vue +273 -0
- package/src/forms/DateRange.md +337 -0
- package/src/forms/DateRange.vue +110 -0
- package/src/forms/JsonSchemaForm.demo.vue +549 -0
- package/src/forms/JsonSchemaForm.md +112 -0
- package/src/forms/JsonSchemaForm.property.test.ts +817 -0
- package/src/forms/JsonSchemaForm.test.ts +601 -0
- package/src/forms/JsonSchemaForm.unit.test.ts +801 -0
- package/src/forms/JsonSchemaForm.vue +615 -0
- package/src/forms/index.ts +3 -0
- package/src/index.ts +17 -0
- package/src/navigation/Breadcrumbs.demo.vue +142 -0
- package/src/navigation/Breadcrumbs.md +102 -0
- package/src/navigation/Breadcrumbs.test.ts +69 -0
- package/src/navigation/Breadcrumbs.vue +58 -0
- package/src/navigation/Stepper.demo.vue +337 -0
- package/src/navigation/Stepper.md +174 -0
- package/src/navigation/Stepper.vue +146 -0
- package/src/navigation/Tabs.demo.vue +293 -0
- package/src/navigation/Tabs.md +163 -0
- package/src/navigation/Tabs.test.ts +176 -0
- package/src/navigation/Tabs.vue +104 -0
- package/src/navigation/index.ts +5 -0
- package/src/overlays/Alert.demo.vue +377 -0
- package/src/overlays/Alert.md +248 -0
- package/src/overlays/Alert.test.ts +166 -0
- package/src/overlays/Alert.vue +70 -0
- package/src/overlays/Drawer.md +140 -0
- package/src/overlays/Drawer.test.ts +92 -0
- package/src/overlays/Drawer.vue +76 -0
- package/src/overlays/Modal.demo.vue +149 -0
- package/src/overlays/Modal.md +385 -0
- package/src/overlays/Modal.test.ts +128 -0
- package/src/overlays/Modal.vue +86 -0
- package/src/overlays/Notification.md +150 -0
- package/src/overlays/Notification.test.ts +96 -0
- package/src/overlays/Notification.vue +58 -0
- package/src/overlays/index.ts +4 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# JsonSchemaForm Component
|
|
2
|
+
|
|
3
|
+
A dynamic form generator that creates forms from JSON Schema definitions with built-in validation using AJV.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **JSON Schema validation**: Full AJV validation with format support
|
|
8
|
+
- **Dynamic field generation**: Auto-generates form fields from schema
|
|
9
|
+
- **Widget inference**: Smart widget selection based on field types
|
|
10
|
+
- **Custom UI schema**: Override default widgets and add placeholders
|
|
11
|
+
- **v-model support**: Two-way binding for form data
|
|
12
|
+
- **Real-time validation**: Validates fields as user types
|
|
13
|
+
- **Exposed methods**: Programmatic validation and reset
|
|
14
|
+
|
|
15
|
+
## Import
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { JsonSchemaForm } from '@htlkg/components';
|
|
19
|
+
// or
|
|
20
|
+
import { JsonSchemaForm } from '@htlkg/components/forms';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
| Prop | Type | Default | Description |
|
|
26
|
+
|------|------|---------|-------------|
|
|
27
|
+
| `schema` | `JsonSchema` | required | JSON Schema definition |
|
|
28
|
+
| `modelValue` | `Record<string, any>` | `{}` | Form data (v-model) |
|
|
29
|
+
| `uiSchema` | `Record<string, any>` | `{}` | UI customization schema |
|
|
30
|
+
| `loading` | `boolean` | `false` | Show loading state |
|
|
31
|
+
|
|
32
|
+
## Events
|
|
33
|
+
|
|
34
|
+
| Event | Payload | Description |
|
|
35
|
+
|-------|---------|-------------|
|
|
36
|
+
| `update:modelValue` | `Record<string, any>` | Form data changed |
|
|
37
|
+
| `validation-error` | `Array<{field: string, message: string}>` | Validation failed |
|
|
38
|
+
| `submit` | `Record<string, any>` | Form submitted successfully |
|
|
39
|
+
|
|
40
|
+
## Exposed Methods
|
|
41
|
+
|
|
42
|
+
| Method | Description |
|
|
43
|
+
|--------|-------------|
|
|
44
|
+
| `validate()` | Validate form and return errors |
|
|
45
|
+
| `reset()` | Reset form to empty state |
|
|
46
|
+
|
|
47
|
+
## Usage Examples
|
|
48
|
+
|
|
49
|
+
### Basic Form
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<script setup>
|
|
53
|
+
import { ref } from 'vue';
|
|
54
|
+
import { JsonSchemaForm } from '@htlkg/components';
|
|
55
|
+
|
|
56
|
+
const formData = ref({});
|
|
57
|
+
|
|
58
|
+
const schema = {
|
|
59
|
+
type: 'object',
|
|
60
|
+
title: 'User Profile',
|
|
61
|
+
properties: {
|
|
62
|
+
name: { type: 'string', title: 'Name', minLength: 1 },
|
|
63
|
+
email: { type: 'string', title: 'Email', format: 'email', minLength: 1 },
|
|
64
|
+
age: { type: 'number', title: 'Age', minimum: 18, maximum: 120 }
|
|
65
|
+
},
|
|
66
|
+
required: ['name', 'email']
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleSubmit = (data) => {
|
|
70
|
+
console.log('Form submitted:', data);
|
|
71
|
+
};
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<JsonSchemaForm
|
|
76
|
+
v-model="formData"
|
|
77
|
+
:schema="schema"
|
|
78
|
+
@submit="handleSubmit"
|
|
79
|
+
/>
|
|
80
|
+
</template>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### With Custom Widgets
|
|
84
|
+
|
|
85
|
+
```vue
|
|
86
|
+
<script setup>
|
|
87
|
+
const schema = {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
password: { type: 'string', title: 'Password' },
|
|
91
|
+
volume: { type: 'integer', title: 'Volume', minimum: 0, maximum: 100 }
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const uiSchema = {
|
|
96
|
+
password: { 'ui:widget': 'password' },
|
|
97
|
+
volume: { 'ui:widget': 'slider' }
|
|
98
|
+
};
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<template>
|
|
102
|
+
<JsonSchemaForm
|
|
103
|
+
v-model="formData"
|
|
104
|
+
:schema="schema"
|
|
105
|
+
:uiSchema="uiSchema"
|
|
106
|
+
/>
|
|
107
|
+
</template>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Demo
|
|
111
|
+
|
|
112
|
+
See the [JsonSchemaForm demo page](/components/json-schema-form) for interactive examples.
|