Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default defineConfig({
{ text: 'useFieldProps', link: '/guide/composables/useFieldProps' },
{ text: 'useFieldValidate', link: '/guide/composables/useFieldValidate' },
{ text: 'useFormModel', link: '/guide/composables/useFormModel' },
{ text: 'useLabelIcon', link: '/guide/composables/useLabelIcon' },
{ text: 'useValidation', link: '/guide/composables/useValidation' }
]
},
Expand Down
22 changes: 22 additions & 0 deletions apps/docs/guide/composables/useLabelIcon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
outline: [2,3]
---
# useLabelIcon <Badge type="tip" text="2.7.0+" />
> Determines which icon to display and the position to display it in

## Usage
```vue
<script setup>
import { useLabelIcon } from '@kevinkosterr/vue3-form-generator'

const { labelIcon, labelIconPosition } = useLabelIcon(props.field.labelIcon)
</script>
```

## Returns

### `labelIcon` <Badge type="info" text="ComputedRef<string | ComponentPublicInstance | null>" />
Either the icon class or icon component as determined by the `labelIcon` property of a field schema.

### `labelIconPosition` <Badge type="info" text="ComputedRef<'left' | 'right' | null>" />
Position of the label, defaults to `left`.
33 changes: 17 additions & 16 deletions apps/docs/parts/shared-field-properties.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
| Property | Default | Type | Description |
|-------------|-----------|---------------------------------------------|-------------------------------------------------------------------------------------------------|
| name | - | `string` | Name of the field |
| model | - | `string` | Key of model in the form schema model |
| label | - | `string` | Label for the field |
| type | - | `string` | Type of field, generally `input` if the field is an input. |
| inputType | - | `string` | Type of input, only required when `type === 'input'` |
| id | _computed_ | `string` | `id` of the field |
| visible | `true` | `Boolean \| Function` | Whether the field is visible, method will be passed the `model`, `field` and field component* |
| required | `false` | `Boolean \| Function` | Whether the field is required, method will be passed the `model`, `field` and field component* |
| readonly | `false` | `Boolean \| Function` | Whether the field is read only, method will be passed the `model`, `field` and field component* |
| disabled | `false` | `Boolean \| Function` | Whether the field is disabled, method will be passed the `model`, `field` and field component* |
| hint | - | `string \| Function` | Hint to display underneath the field, can be passed a method* |
| validator | _computed_ | `Array<Function> \| Function \| undefined` | A (list of) validator(s) to be validating the field against. |
| validate | `onBlur` | `'onChanged'` \| `'onBlur'` | Method of validation for the field. |
| onValidated | - | `Function \| undefined` | Method to be called after validation has been completed. |
| Property | Default | Type | Description |
|-------------|-----------|------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
| name | - | `string` | Name of the field |
| model | - | `string` | Key of model in the form schema model |
| label | - | `string` | Label for the field |
| labelIcon | - | `string \| ComponentPublicInstance \| LabelIconDefinition` | Label for the field |
| type | - | `string` | Type of field, generally `input` if the field is an input. |
| inputType | - | `string` | Type of input, only required when `type === 'input'` |
| id | _computed_ | `string` | `id` of the field |
| visible | `true` | `Boolean \| Function` | Whether the field is visible, method will be passed the `model`, `field` and field component* |
| required | `false` | `Boolean \| Function` | Whether the field is required, method will be passed the `model`, `field` and field component* |
| readonly | `false` | `Boolean \| Function` | Whether the field is read only, method will be passed the `model`, `field` and field component* |
| disabled | `false` | `Boolean \| Function` | Whether the field is disabled, method will be passed the `model`, `field` and field component* |
| hint | - | `string \| Function` | Hint to display underneath the field, can be passed a method* |
| validator | _computed_ | `Array<Function> \| Function \| undefined` | A (list of) validator(s) to be validating the field against. |
| validate | `onBlur` | `'onChanged'` \| `'onBlur'` | Method of validation for the field. |
| onValidated | - | `Function \| undefined` | Method to be called after validation has been completed. |

_*_ see [determineDynamicAttribute()](/guide/mixins/abstractField#determinedynamicattribute) for more information.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css" rel="stylesheet">
<title>Vite App</title>
</head>
<body>
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dev": "vite",
"dev:sass": "sass --watch src/scss/themes:apps/playground/css/",
"test": "vitest",
"test:ui": "vitest --ui",
"build": "vite build && sass src/scss/themes/:dist/themes/",
"preview": "vite preview",
"docs:dev": "vitepress dev apps/docs",
Expand Down Expand Up @@ -55,6 +56,7 @@
"@stylistic/eslint-plugin": "^2.8.0",
"@typescript-eslint/parser": "^8.13.0",
"@vitejs/plugin-vue": "^5.1.3",
"@vitest/ui": "^3.2.4",
"@vue/test-utils": "^2.4.6",
"clipboard": "^2.0.11",
"eslint": "^9.10.0",
Expand Down
Loading