Skip to content

Commit 11207ac

Browse files
authored
Merge pull request #31 from QuickFlo/quasar-tags-field
quasar tags field
2 parents 625e1e1 + 4010c54 commit 11207ac

File tree

12 files changed

+693
-4
lines changed

12 files changed

+693
-4
lines changed

docs/guide/components.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,183 @@ import type {
863863

864864
---
865865

866+
## TagsField (Quasar)
867+
868+
A chip-based tags input for arrays of free-form strings. Ideal for email addresses, keywords, labels, or any list where users type and add values.
869+
870+
### Handles
871+
872+
- `type: 'array'` with `'x-render': 'tags'`
873+
874+
### Example Schema
875+
876+
**Email recipients:**
877+
```typescript
878+
{
879+
type: 'array',
880+
title: 'Recipients',
881+
description: 'Email addresses to send to',
882+
'x-render': 'tags',
883+
items: {
884+
type: 'string',
885+
format: 'email'
886+
},
887+
minItems: 1
888+
}
889+
```
890+
891+
**Keywords:**
892+
```typescript
893+
{
894+
type: 'array',
895+
title: 'Keywords',
896+
'x-render': 'tags',
897+
'x-placeholder': 'Add keywords...',
898+
items: {
899+
type: 'string',
900+
minLength: 2
901+
}
902+
}
903+
```
904+
905+
### Features
906+
907+
- **Type and press Enter** to add a new tag
908+
- **Paste multiple values** - comma/semicolon/newline separated values are parsed automatically
909+
- **Click X to remove** tags
910+
- **Per-item validation** - invalid items show as red chips with error icon
911+
- **Duplicate prevention** - same value won't be added twice
912+
- **Smart placeholder** - auto-detects email format for contextual placeholder
913+
- **Full QChip customization** - color, icon, outline, size, etc.
914+
915+
### Per-Item Validation
916+
917+
The TagsField validates each item against the `items` schema:
918+
919+
- `format: 'email'` - validates email format
920+
- `format: 'url'` - validates URL format
921+
- `minLength` / `maxLength` - validates string length
922+
- `pattern` - validates against regex pattern
923+
- `enum` - validates against allowed values
924+
925+
Invalid items are displayed as **red chips with an error icon** and trigger validation errors that block form submission.
926+
927+
### Schema Extensions
928+
929+
| Extension | Type | Default | Description |
930+
|-----------|------|---------|-------------|
931+
| `x-render` | `'tags'` | - | Required. Enables tags input mode |
932+
| `x-placeholder` | `string` | Auto-detected | Custom placeholder text |
933+
934+
### QuickForms Features (`x-quickforms-quasar`)
935+
936+
**Chip customization:**
937+
```typescript
938+
{
939+
type: 'array',
940+
title: 'Tags',
941+
'x-render': 'tags',
942+
items: { type: 'string' },
943+
'x-quickforms-quasar': {
944+
chip: {
945+
color: 'secondary', // Quasar color
946+
textColor: 'white', // Text color
947+
icon: 'label', // Icon inside chip
948+
outline: true, // Outline style
949+
dense: true, // Dense mode
950+
square: true // Square corners
951+
}
952+
}
953+
}
954+
```
955+
956+
**Custom separator pattern:**
957+
```typescript
958+
{
959+
type: 'array',
960+
title: 'Emails',
961+
'x-render': 'tags',
962+
items: { type: 'string', format: 'email' },
963+
'x-quickforms-quasar': {
964+
separator: /[,;\n]+/ // Only split on comma, semicolon, newline (not spaces)
965+
}
966+
}
967+
```
968+
969+
**Default chip props:**
970+
```typescript
971+
// Default styling applied to all chips
972+
{
973+
removable: true,
974+
dense: true,
975+
color: 'primary',
976+
textColor: 'white'
977+
}
978+
```
979+
980+
### Global Defaults
981+
982+
```typescript
983+
const options: QuasarFormOptions = {
984+
registry: createQuasarRegistry(),
985+
quickformsDefaults: {
986+
tags: {
987+
chip: {
988+
color: 'accent',
989+
textColor: 'white',
990+
dense: true
991+
},
992+
separator: /[,;\s]+/ // Default: comma, semicolon, or whitespace
993+
}
994+
}
995+
}
996+
```
997+
998+
### Native Quasar Props
999+
1000+
The underlying QSelect accepts native props via `x-quasar-props`:
1001+
1002+
```typescript
1003+
{
1004+
type: 'array',
1005+
title: 'Tags',
1006+
'x-render': 'tags',
1007+
items: { type: 'string' },
1008+
'x-quasar-props': {
1009+
outlined: true,
1010+
filled: false,
1011+
color: 'secondary',
1012+
dense: true
1013+
}
1014+
}
1015+
```
1016+
1017+
### Comparison: TagsField vs ArrayField vs MultiEnumField
1018+
1019+
| Feature | TagsField | ArrayField | MultiEnumField |
1020+
|---------|-----------|------------|----------------|
1021+
| Use case | Free-form input | Structured items | Fixed options |
1022+
| Input method | Type + Enter | Add button | Select from list |
1023+
| Display | Chips inline | Expandable items | Chips |
1024+
| Validation | Per-item | Per-item | Enum only |
1025+
| Schema | `x-render: 'tags'` | `type: 'array'` | `items.enum` |
1026+
1027+
**When to use TagsField:**
1028+
- Email addresses (to, cc, bcc)
1029+
- Keywords or labels
1030+
- Any free-form list where users type values
1031+
1032+
**When to use ArrayField:**
1033+
- Complex item objects
1034+
- Items with multiple fields
1035+
- Items that need individual editing
1036+
1037+
**When to use MultiEnumField:**
1038+
- Fixed set of allowed values
1039+
- Selecting from predefined options
1040+
1041+
---
1042+
8661043
## ArrayField
8671044

8681045
Renders dynamic array fields with add/remove buttons.

docs/guide/quasar.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ The Quasar package provides pre-built Quasar-wrapped components:
7676
- **QuasarDateTimeField** - `QInput` with `QDate` and `QTime` popups
7777
- **QuasarObjectField** - `QExpansionItem` for nested objects
7878
- **QuasarArrayField** - `QCard` with add/remove buttons
79+
- **QuasarTagsField** - `QSelect` chips input for free-form arrays (emails, keywords)
7980
- **QuasarOneOfField** - `QSelect` for conditional schemas
8081

8182
## Configuration Options
@@ -193,6 +194,35 @@ Customize array field buttons with native QBtn props:
193194
- `addButton` - Native QBtn props (label, icon, color, size, push, fab, etc.)
194195
- `removeButton` - Native QBtn props
195196

197+
#### Tags/Chips Input
198+
199+
For free-form arrays like email addresses or keywords, use `x-render: 'tags'`:
200+
201+
```typescript
202+
{
203+
type: 'array',
204+
title: 'Email Recipients',
205+
'x-render': 'tags',
206+
items: {
207+
type: 'string',
208+
format: 'email'
209+
},
210+
'x-quickforms-quasar': {
211+
chip: {
212+
color: 'primary',
213+
icon: 'email'
214+
},
215+
separator: /[,;\n]+/ // Custom paste separator
216+
}
217+
}
218+
```
219+
220+
**Tags Properties:**
221+
- `chip` - Native QChip props (color, textColor, icon, outline, dense, etc.)
222+
- `separator` - RegExp or string pattern for parsing pasted values (default: `/[,;\s]+/`)
223+
224+
See [TagsField documentation](/guide/components#tagsfield-quasar) for full details.
225+
196226
## Supported Formats
197227

198228
QuickForms Quasar supports all standard JSON Schema formats:
@@ -303,6 +333,10 @@ interface QuasarFormOptions extends FormOptions {
303333
addButton?: Record<string, any>
304334
removeButton?: Record<string, any>
305335
}
336+
tags?: {
337+
chip?: Record<string, any> // QChip props for tag chips
338+
separator?: RegExp | string // Paste separator pattern
339+
}
306340
jsoneditor?: {
307341
height?: string // Editor height (default: '300px')
308342
darkTheme?: boolean // Use dark theme (default: false, auto-detects from Quasar Dark)

docs/guide/schema-extensions.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ All `x-*` attributes are optional. QuickForms works perfectly with standard JSON
281281
- `addButton` - Native QBtn props
282282
- `removeButton` - Native QBtn props
283283

284-
**Related:** [Quasar Package Docs](/guide/quasar#quickforms-convenience-features)
284+
**For Tags (arrays with `x-render: 'tags'`):**
285+
- `chip` - Native QChip props (color, textColor, icon, outline, dense, etc.)
286+
- `separator` - RegExp or string pattern for parsing pasted values (default: `/[,;\s]+/`)
287+
288+
**Related:** [Quasar Package Docs](/guide/quasar#quickforms-convenience-features), [TagsField](/guide/components#tagsfield-quasar)
285289

286290
---
287291

@@ -542,8 +546,10 @@ All `x-*` attributes are optional. QuickForms works perfectly with standard JSON
542546
- `'datetime'` - Date/time picker field (Quasar only)
543547
- `'object'` - Object field with nested properties
544548
- `'array'` - Array field with add/remove items
549+
- `'tags'` - Chip-based tags input for arrays (Quasar only) - ideal for emails, keywords
545550
- `'keyvalue'` - Key-value pair editor
546551
- `'json'` or `'jsoneditor'` - JSON code editor with syntax highlighting, linting, and formatting
552+
- `'condition-builder'` or `'jsonlogic-builder'` - Visual JSONLogic condition builder (Quasar only)
547553

548554
**Use Cases:**
549555
- **Override default renderers**: Force a string field even when a custom renderer would normally match

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@quickflo/quickforms",
3-
"version": "1.14.8",
3+
"version": "1.15.0",
44
"description": "Framework-agnostic core for QuickForms - JSON Schema form generator",
55
"type": "module",
66
"main": "./dist/index.js",

packages/quasar/dev/App.vue

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,47 @@ const schema: JSONSchema = {
196196
},
197197
},
198198
199+
// === TAGS INPUT (CHIPS) ===
200+
emailRecipients: {
201+
type: "array",
202+
title: "Email Recipients",
203+
description:
204+
"Chip-based tags input for emails. Type and press Enter, or paste multiple comma-separated values.",
205+
"x-render": "tags",
206+
items: {
207+
type: "string",
208+
format: "email",
209+
},
210+
minItems: 1,
211+
"x-quickforms-quasar": {
212+
chip: {
213+
color: "primary",
214+
textColor: "white",
215+
icon: "email",
216+
},
217+
},
218+
},
219+
220+
// === TAGS INPUT (CUSTOM STYLING) ===
221+
keywords: {
222+
type: "array",
223+
title: "Keywords",
224+
description: "Tags with custom chip styling - try pasting: vue, react, angular",
225+
"x-render": "tags",
226+
items: {
227+
type: "string",
228+
},
229+
"x-placeholder": "Add keywords...",
230+
"x-quickforms-quasar": {
231+
chip: {
232+
color: "secondary",
233+
outline: true,
234+
dense: true,
235+
},
236+
separator: /[,;\n]+/, // Only split on comma, semicolon, newline (not spaces)
237+
},
238+
},
239+
199240
// === ARRAY OF OBJECTS ===
200241
teamMembers: {
201242
type: "array",

packages/quasar/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@quickflo/quickforms-quasar",
3-
"version": "1.14.8",
3+
"version": "1.15.0",
44
"description": "Quasar UI components for QuickForms - JSON Schema form generator",
55
"type": "module",
66
"main": "./dist/index.js",

0 commit comments

Comments
 (0)