@cocoar/vue-ui 3.1.0 → 3.2.0-beta.6
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/components/checkbox/CoarCheckbox.vue.d.ts +1 -1
- package/dist/components/checkbox/CoarCheckbox.vue.d.ts.map +1 -1
- package/dist/components/code-block/CoarCodeBlock.vue.d.ts +1 -1
- package/dist/components/code-block/CoarCodeBlock.vue.d.ts.map +1 -1
- package/dist/components/data-list/CoarDataList.vue.d.ts +158 -0
- package/dist/components/data-list/CoarDataList.vue.d.ts.map +1 -0
- package/dist/components/data-list/CoarDataListToolbar.vue.d.ts +30 -0
- package/dist/components/data-list/CoarDataListToolbar.vue.d.ts.map +1 -0
- package/dist/components/data-list/data-list-builder.d.ts +288 -0
- package/dist/components/data-list/data-list-builder.d.ts.map +1 -0
- package/dist/components/data-list/index.d.ts +12 -0
- package/dist/components/data-list/index.d.ts.map +1 -0
- package/dist/components/data-list/internal/compare.d.ts +14 -0
- package/dist/components/data-list/internal/compare.d.ts.map +1 -0
- package/dist/components/data-list/internal/reorder-core.d.ts +46 -0
- package/dist/components/data-list/internal/reorder-core.d.ts.map +1 -0
- package/dist/components/data-list/internal/search.d.ts +16 -0
- package/dist/components/data-list/internal/search.d.ts.map +1 -0
- package/dist/components/data-list/internal/useDataListLines.d.ts +92 -0
- package/dist/components/data-list/internal/useDataListLines.d.ts.map +1 -0
- package/dist/components/data-list/internal/useDataListReorder.d.ts +68 -0
- package/dist/components/data-list/internal/useDataListReorder.d.ts.map +1 -0
- package/dist/components/data-list/internal/useSearchHighlight.d.ts +19 -0
- package/dist/components/data-list/internal/useSearchHighlight.d.ts.map +1 -0
- package/dist/components/data-list/types.d.ts +185 -0
- package/dist/components/data-list/types.d.ts.map +1 -0
- package/dist/components/data-list/useDataListModel.d.ts +79 -0
- package/dist/components/data-list/useDataListModel.d.ts.map +1 -0
- package/dist/components/date-time/_shared/maskito-config.d.ts +7 -2
- package/dist/components/date-time/_shared/maskito-config.d.ts.map +1 -1
- package/dist/components/date-time/_shared/time-helpers.d.ts +11 -4
- package/dist/components/date-time/_shared/time-helpers.d.ts.map +1 -1
- package/dist/components/date-time/_shared/use-date-picker-base.d.ts +1 -1
- package/dist/components/date-time/plain-date-picker/CoarPlainDatePicker.vue.d.ts +1 -1
- package/dist/components/date-time/plain-date-picker/CoarPlainDatePicker.vue.d.ts.map +1 -1
- package/dist/components/date-time/plain-date-time-picker/CoarPlainDateTimePicker.vue.d.ts +1 -1
- package/dist/components/date-time/plain-date-time-picker/CoarPlainDateTimePicker.vue.d.ts.map +1 -1
- package/dist/components/date-time/zoned-date-time-picker/CoarZonedDateTimePicker.vue.d.ts +1 -1
- package/dist/components/date-time/zoned-date-time-picker/CoarZonedDateTimePicker.vue.d.ts.map +1 -1
- package/dist/components/dual-listbox/CoarDualListbox.vue.d.ts +3 -0
- package/dist/components/dual-listbox/CoarDualListbox.vue.d.ts.map +1 -1
- package/dist/components/form-field/CoarFormField.vue.d.ts +1 -1
- package/dist/components/form-field/CoarFormField.vue.d.ts.map +1 -1
- package/dist/components/icon/CoarIcon.vue.d.ts +2 -2
- package/dist/components/icon/CoarIcon.vue.d.ts.map +1 -1
- package/dist/components/listbox/CoarListbox.vue.d.ts +7 -0
- package/dist/components/listbox/CoarListbox.vue.d.ts.map +1 -1
- package/dist/components/number-input/CoarNumberInput.vue.d.ts +1 -1
- package/dist/components/number-input/CoarNumberInput.vue.d.ts.map +1 -1
- package/dist/components/otp-input/CoarOtpInput.vue.d.ts +1 -1
- package/dist/components/otp-input/CoarOtpInput.vue.d.ts.map +1 -1
- package/dist/components/password-input/CoarPasswordInput.vue.d.ts +1 -1
- package/dist/components/password-input/CoarPasswordInput.vue.d.ts.map +1 -1
- package/dist/components/switch/CoarSwitch.vue.d.ts +1 -1
- package/dist/components/switch/CoarSwitch.vue.d.ts.map +1 -1
- package/dist/components/text-input/CoarTextInput.vue.d.ts +1 -1
- package/dist/components/text-input/CoarTextInput.vue.d.ts.map +1 -1
- package/dist/composables/dragRegistry.d.ts +12 -0
- package/dist/composables/dragRegistry.d.ts.map +1 -1
- package/dist/composables/index.d.ts +2 -2
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/useDragDrop.d.ts +62 -6
- package/dist/composables/useDragDrop.d.ts.map +1 -1
- package/dist/composables/useVirtualList.d.ts +21 -1
- package/dist/composables/useVirtualList.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4508 -2039
- package/package.json +5 -3
- package/skills/cocoar-vue-ui/SKILL.md +244 -0
- package/skills/cocoar-vue-ui/references/components/avatar.md +178 -0
- package/skills/cocoar-vue-ui/references/components/badge.md +290 -0
- package/skills/cocoar-vue-ui/references/components/breadcrumb.md +238 -0
- package/skills/cocoar-vue-ui/references/components/button.md +252 -0
- package/skills/cocoar-vue-ui/references/components/calendar/agenda-view.md +353 -0
- package/skills/cocoar-vue-ui/references/components/calendar/coar-calendar.md +1645 -0
- package/skills/cocoar-vue-ui/references/components/calendar/day-view.md +361 -0
- package/skills/cocoar-vue-ui/references/components/calendar/index.md +312 -0
- package/skills/cocoar-vue-ui/references/components/calendar/month-view.md +475 -0
- package/skills/cocoar-vue-ui/references/components/calendar/performance.md +186 -0
- package/skills/cocoar-vue-ui/references/components/calendar/timeline-view.md +301 -0
- package/skills/cocoar-vue-ui/references/components/calendar/week-view.md +382 -0
- package/skills/cocoar-vue-ui/references/components/calendar/work-week-view.md +145 -0
- package/skills/cocoar-vue-ui/references/components/calendar/year-view.md +63 -0
- package/skills/cocoar-vue-ui/references/components/card.md +151 -0
- package/skills/cocoar-vue-ui/references/components/checkbox-group.md +103 -0
- package/skills/cocoar-vue-ui/references/components/checkbox.md +279 -0
- package/skills/cocoar-vue-ui/references/components/code-block.md +241 -0
- package/skills/cocoar-vue-ui/references/components/context-menu.md +355 -0
- package/skills/cocoar-vue-ui/references/components/data-grid/checkbox.md +213 -0
- package/skills/cocoar-vue-ui/references/components/data-grid/date-columns.md +272 -0
- package/skills/cocoar-vue-ui/references/components/data-grid/editing.md +236 -0
- package/skills/cocoar-vue-ui/references/components/data-grid/multi-select.md +193 -0
- package/skills/cocoar-vue-ui/references/components/data-grid/number.md +147 -0
- package/skills/cocoar-vue-ui/references/components/data-grid/select.md +202 -0
- package/skills/cocoar-vue-ui/references/components/data-grid/text.md +127 -0
- package/skills/cocoar-vue-ui/references/components/data-grid.md +1225 -0
- package/skills/cocoar-vue-ui/references/components/data-list.md +2121 -0
- package/skills/cocoar-vue-ui/references/components/date-or-time-picker.md +200 -0
- package/skills/cocoar-vue-ui/references/components/date-picker.md +203 -0
- package/skills/cocoar-vue-ui/references/components/date-time-picker.md +154 -0
- package/skills/cocoar-vue-ui/references/components/date-views.md +212 -0
- package/skills/cocoar-vue-ui/references/components/dialog.md +148 -0
- package/skills/cocoar-vue-ui/references/components/divider.md +157 -0
- package/skills/cocoar-vue-ui/references/components/document-viewer/annotations.md +400 -0
- package/skills/cocoar-vue-ui/references/components/document-viewer/coar-document-viewer.md +327 -0
- package/skills/cocoar-vue-ui/references/components/document-viewer/index.md +234 -0
- package/skills/cocoar-vue-ui/references/components/document-viewer/toolbar.md +221 -0
- package/skills/cocoar-vue-ui/references/components/drag-drop.md +267 -0
- package/skills/cocoar-vue-ui/references/components/dual-listbox.md +449 -0
- package/skills/cocoar-vue-ui/references/components/file-explorer/asset-store.md +327 -0
- package/skills/cocoar-vue-ui/references/components/file-explorer/in-memory-store.md +176 -0
- package/skills/cocoar-vue-ui/references/components/file-explorer/index.md +311 -0
- package/skills/cocoar-vue-ui/references/components/file-explorer/use-file-explorer.md +300 -0
- package/skills/cocoar-vue-ui/references/components/form-field.md +1025 -0
- package/skills/cocoar-vue-ui/references/components/fragment-parser.md +298 -0
- package/skills/cocoar-vue-ui/references/components/link.md +235 -0
- package/skills/cocoar-vue-ui/references/components/listbox.md +575 -0
- package/skills/cocoar-vue-ui/references/components/map/editor.md +448 -0
- package/skills/cocoar-vue-ui/references/components/map/index.md +351 -0
- package/skills/cocoar-vue-ui/references/components/markdown-diagrams.md +210 -0
- package/skills/cocoar-vue-ui/references/components/markdown-editor.md +1478 -0
- package/skills/cocoar-vue-ui/references/components/markdown-embeds.md +387 -0
- package/skills/cocoar-vue-ui/references/components/markdown-form.md +447 -0
- package/skills/cocoar-vue-ui/references/components/markdown.md +276 -0
- package/skills/cocoar-vue-ui/references/components/menu.md +380 -0
- package/skills/cocoar-vue-ui/references/components/mermaid.md +172 -0
- package/skills/cocoar-vue-ui/references/components/navbar.md +147 -0
- package/skills/cocoar-vue-ui/references/components/note.md +96 -0
- package/skills/cocoar-vue-ui/references/components/notice.md +131 -0
- package/skills/cocoar-vue-ui/references/components/number-input.md +215 -0
- package/skills/cocoar-vue-ui/references/components/otp-input.md +324 -0
- package/skills/cocoar-vue-ui/references/components/page-builder/authoring-contract.md +271 -0
- package/skills/cocoar-vue-ui/references/components/page-builder/coar-page-builder.md +476 -0
- package/skills/cocoar-vue-ui/references/components/page-builder/coar-page-renderer.md +677 -0
- package/skills/cocoar-vue-ui/references/components/page-builder/custom-elements.md +441 -0
- package/skills/cocoar-vue-ui/references/components/page-builder/idp-integration.md +122 -0
- package/skills/cocoar-vue-ui/references/components/page-builder/index.md +573 -0
- package/skills/cocoar-vue-ui/references/components/pagination.md +150 -0
- package/skills/cocoar-vue-ui/references/components/panel-layout.md +372 -0
- package/skills/cocoar-vue-ui/references/components/password-input.md +175 -0
- package/skills/cocoar-vue-ui/references/components/popconfirm.md +186 -0
- package/skills/cocoar-vue-ui/references/components/popover.md +173 -0
- package/skills/cocoar-vue-ui/references/components/progress-bar.md +178 -0
- package/skills/cocoar-vue-ui/references/components/radio-group.md +225 -0
- package/skills/cocoar-vue-ui/references/components/script-editor.md +1271 -0
- package/skills/cocoar-vue-ui/references/components/segmented-control.md +238 -0
- package/skills/cocoar-vue-ui/references/components/select.md +463 -0
- package/skills/cocoar-vue-ui/references/components/sidebar.md +421 -0
- package/skills/cocoar-vue-ui/references/components/spinner.md +132 -0
- package/skills/cocoar-vue-ui/references/components/switch.md +195 -0
- package/skills/cocoar-vue-ui/references/components/table.md +170 -0
- package/skills/cocoar-vue-ui/references/components/tabs.md +382 -0
- package/skills/cocoar-vue-ui/references/components/tag.md +178 -0
- package/skills/cocoar-vue-ui/references/components/text-input.md +256 -0
- package/skills/cocoar-vue-ui/references/components/toast.md +160 -0
- package/skills/cocoar-vue-ui/references/components/tooltip.md +121 -0
- package/skills/cocoar-vue-ui/references/components/transitions.md +193 -0
- package/skills/cocoar-vue-ui/references/components/tree.md +2388 -0
- package/skills/cocoar-vue-ui/references/components/virtual-list.md +212 -0
- package/skills/cocoar-vue-ui/references/components/wizard.md +251 -0
- package/skills/cocoar-vue-ui/references/components/zoned-date-time-picker.md +177 -0
- package/skills/cocoar-vue-ui/references/foundations/colors.md +708 -0
- package/skills/cocoar-vue-ui/references/foundations/design-principles.md +115 -0
- package/skills/cocoar-vue-ui/references/foundations/icons.md +381 -0
- package/skills/cocoar-vue-ui/references/foundations/localization/formatting.md +530 -0
- package/skills/cocoar-vue-ui/references/foundations/localization/setup.md +86 -0
- package/skills/cocoar-vue-ui/references/foundations/localization/timezones.md +182 -0
- package/skills/cocoar-vue-ui/references/foundations/localization/translations.md +305 -0
- package/skills/cocoar-vue-ui/references/foundations/motion.md +549 -0
- package/skills/cocoar-vue-ui/references/foundations/spacing.md +330 -0
- package/skills/cocoar-vue-ui/references/foundations/theming.md +140 -0
- package/skills/cocoar-vue-ui/references/foundations/typography.md +206 -0
- package/skills/cocoar-vue-ui/references/guide/error-handling.md +162 -0
- package/skills/cocoar-vue-ui/references/guide/getting-started.md +119 -0
- package/skills/cocoar-vue-ui/references/guide/migration-page-builder-3.md +207 -0
- package/skills/cocoar-vue-ui/references/guide/migration.md +140 -0
- package/skills/cocoar-vue-ui/references/guide/theming.md +98 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
<!-- Generated from apps/docs/components/text-input.md by apps/docs/scripts/sync-skill.mjs. Do not edit; edit the docs page. -->
|
|
2
|
+
|
|
3
|
+
# Text Input
|
|
4
|
+
|
|
5
|
+
The go-to component for collecting short text from users -- names, emails, search queries, and more. It handles labels, validation, prefix/suffix decorations, and can even stretch into a textarea when you need longer content.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { CoarTextInput, CoarFormField } from '@cocoar/vue-ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
Wire up a text input with `v-model` and wrap it in a `CoarFormField` to add a label, placeholder, and optional hint to guide the user.
|
|
14
|
+
|
|
15
|
+
**Demo — `text-input/demos/BasicTextInput.vue`**
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div style="display: flex; flex-direction: column; gap: 12px; max-width: 320px;">
|
|
20
|
+
<CoarFormField label="Username" hint="Choose a unique username">
|
|
21
|
+
<CoarTextInput
|
|
22
|
+
v-model="value"
|
|
23
|
+
placeholder="Enter your username"
|
|
24
|
+
/>
|
|
25
|
+
</CoarFormField>
|
|
26
|
+
<span style="font-size: 13px; color: #64748b;">Value: {{ value || 'empty' }}</span>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
import { ref } from 'vue';
|
|
32
|
+
import { CoarTextInput, CoarFormField } from '@cocoar/vue-ui';
|
|
33
|
+
|
|
34
|
+
const value = ref('');
|
|
35
|
+
</script>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Validation States
|
|
39
|
+
|
|
40
|
+
Add `required` to both `CoarFormField` (for the asterisk) and the input (for the HTML attribute). Pass an `error` string to `CoarFormField` to surface validation feedback beneath the input.
|
|
41
|
+
|
|
42
|
+
**Demo — `text-input/demos/TextInputValidation.vue`**
|
|
43
|
+
|
|
44
|
+
```vue
|
|
45
|
+
<template>
|
|
46
|
+
<div style="display: flex; flex-direction: column; gap: 12px; max-width: 320px;">
|
|
47
|
+
<CoarFormField label="Email" hint="Required field" required>
|
|
48
|
+
<CoarTextInput
|
|
49
|
+
v-model="email"
|
|
50
|
+
placeholder="your@email.com"
|
|
51
|
+
:required="true"
|
|
52
|
+
/>
|
|
53
|
+
</CoarFormField>
|
|
54
|
+
<CoarFormField label="Email" error="Please enter a valid email address">
|
|
55
|
+
<CoarTextInput
|
|
56
|
+
value="invalid-email"
|
|
57
|
+
/>
|
|
58
|
+
</CoarFormField>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { ref } from 'vue';
|
|
64
|
+
import { CoarTextInput, CoarFormField } from '@cocoar/vue-ui';
|
|
65
|
+
|
|
66
|
+
const email = ref('');
|
|
67
|
+
</script>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Disabled & Readonly
|
|
71
|
+
|
|
72
|
+
Use `disabled` when the field should be completely non-interactive, and `readonly` when users should be able to see and copy the value but not change it.
|
|
73
|
+
|
|
74
|
+
**Demo — `text-input/demos/TextInputDisabledReadonly.vue`**
|
|
75
|
+
|
|
76
|
+
```vue
|
|
77
|
+
<template>
|
|
78
|
+
<div style="display: flex; flex-direction: column; gap: 12px; max-width: 320px;">
|
|
79
|
+
<CoarFormField label="Disabled">
|
|
80
|
+
<CoarTextInput value="Cannot edit" :disabled="true" />
|
|
81
|
+
</CoarFormField>
|
|
82
|
+
<CoarFormField label="Readonly">
|
|
83
|
+
<CoarTextInput value="View only" :readonly="true" />
|
|
84
|
+
</CoarFormField>
|
|
85
|
+
</div>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<script setup lang="ts">
|
|
89
|
+
import { CoarTextInput, CoarFormField } from '@cocoar/vue-ui';
|
|
90
|
+
</script>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Prefix & Suffix
|
|
94
|
+
|
|
95
|
+
Prefix and suffix slots help users understand the expected format -- think currency symbols, units, or domain names.
|
|
96
|
+
|
|
97
|
+
**Demo — `text-input/demos/TextInputPrefixSuffix.vue`**
|
|
98
|
+
|
|
99
|
+
```vue
|
|
100
|
+
<template>
|
|
101
|
+
<div style="display: flex; flex-direction: column; gap: 12px; max-width: 320px;">
|
|
102
|
+
<CoarFormField label="Website">
|
|
103
|
+
<CoarTextInput v-model="website" placeholder="example.com" prefix="https://" />
|
|
104
|
+
</CoarFormField>
|
|
105
|
+
<CoarFormField label="Price">
|
|
106
|
+
<CoarTextInput v-model="price" placeholder="0.00" suffix="EUR" />
|
|
107
|
+
</CoarFormField>
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
110
|
+
|
|
111
|
+
<script setup lang="ts">
|
|
112
|
+
import { ref } from 'vue';
|
|
113
|
+
import { CoarTextInput, CoarFormField } from '@cocoar/vue-ui';
|
|
114
|
+
|
|
115
|
+
const website = ref('');
|
|
116
|
+
const price = ref('');
|
|
117
|
+
</script>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Clear Button
|
|
121
|
+
|
|
122
|
+
When `clearable` is enabled, a small X button appears on hover or focus so users can quickly reset the field. It's **off by default** — set `clearable` to opt in.
|
|
123
|
+
|
|
124
|
+
**Demo — `text-input/demos/TextInputClearable.vue`**
|
|
125
|
+
|
|
126
|
+
```vue
|
|
127
|
+
<template>
|
|
128
|
+
<div style="display: flex; flex-direction: column; gap: 12px; max-width: 320px;">
|
|
129
|
+
<CoarFormField label="Search">
|
|
130
|
+
<CoarTextInput
|
|
131
|
+
v-model="search"
|
|
132
|
+
placeholder="Type to search..."
|
|
133
|
+
:clearable="true"
|
|
134
|
+
/>
|
|
135
|
+
</CoarFormField>
|
|
136
|
+
<span style="font-size: 13px; color: #64748b;">Value: {{ search || 'empty' }}</span>
|
|
137
|
+
</div>
|
|
138
|
+
</template>
|
|
139
|
+
|
|
140
|
+
<script setup lang="ts">
|
|
141
|
+
import { ref } from 'vue';
|
|
142
|
+
import { CoarTextInput, CoarFormField } from '@cocoar/vue-ui';
|
|
143
|
+
|
|
144
|
+
const search = ref('');
|
|
145
|
+
</script>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Sizes
|
|
149
|
+
|
|
150
|
+
Four sizes let you match the input to its surroundings -- compact toolbars, standard forms, or spacious layouts.
|
|
151
|
+
|
|
152
|
+
**Demo — `text-input/demos/TextInputSizes.vue`**
|
|
153
|
+
|
|
154
|
+
```vue
|
|
155
|
+
<template>
|
|
156
|
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px;">
|
|
157
|
+
<CoarFormField label="Extra Small">
|
|
158
|
+
<CoarTextInput size="xs" placeholder="27px" />
|
|
159
|
+
</CoarFormField>
|
|
160
|
+
<CoarFormField label="Small">
|
|
161
|
+
<CoarTextInput size="s" placeholder="32px" />
|
|
162
|
+
</CoarFormField>
|
|
163
|
+
<CoarFormField label="Medium">
|
|
164
|
+
<CoarTextInput size="m" placeholder="40px" />
|
|
165
|
+
</CoarFormField>
|
|
166
|
+
<CoarFormField label="Large">
|
|
167
|
+
<CoarTextInput size="l" placeholder="48px" />
|
|
168
|
+
</CoarFormField>
|
|
169
|
+
</div>
|
|
170
|
+
</template>
|
|
171
|
+
|
|
172
|
+
<script setup lang="ts">
|
|
173
|
+
import { CoarTextInput, CoarFormField } from '@cocoar/vue-ui';
|
|
174
|
+
</script>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Multiline (Textarea)
|
|
178
|
+
|
|
179
|
+
Set `rows` to 2 or more and the input switches to a textarea, perfect for descriptions, notes, or any free-form content.
|
|
180
|
+
|
|
181
|
+
**Demo — `text-input/demos/TextInputMultiline.vue`**
|
|
182
|
+
|
|
183
|
+
```vue
|
|
184
|
+
<template>
|
|
185
|
+
<div style="display: flex; flex-direction: column; gap: 16px; max-width: 400px;">
|
|
186
|
+
<CoarFormField label="Bio" hint="Max 500 characters">
|
|
187
|
+
<CoarTextInput
|
|
188
|
+
v-model="bio"
|
|
189
|
+
placeholder="Tell us about yourself..."
|
|
190
|
+
:rows="4"
|
|
191
|
+
/>
|
|
192
|
+
</CoarFormField>
|
|
193
|
+
<CoarFormField label="6 Rows">
|
|
194
|
+
<CoarTextInput :rows="6" placeholder="Taller textarea..." />
|
|
195
|
+
</CoarFormField>
|
|
196
|
+
</div>
|
|
197
|
+
</template>
|
|
198
|
+
|
|
199
|
+
<script setup lang="ts">
|
|
200
|
+
import { ref } from 'vue';
|
|
201
|
+
import { CoarTextInput, CoarFormField } from '@cocoar/vue-ui';
|
|
202
|
+
|
|
203
|
+
const bio = ref('');
|
|
204
|
+
</script>
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Accessibility
|
|
208
|
+
|
|
209
|
+
### Keyboard Navigation
|
|
210
|
+
|
|
211
|
+
| Key | Action |
|
|
212
|
+
|-----|--------|
|
|
213
|
+
| `Tab` | Move focus to input |
|
|
214
|
+
| `Shift + Tab` | Move focus backward |
|
|
215
|
+
| `Escape` | Clear input (when clearable) |
|
|
216
|
+
|
|
217
|
+
> **Info**
|
|
218
|
+
>
|
|
219
|
+
> Labels are automatically associated with their inputs. The required asterisk is announced by screen readers.
|
|
220
|
+
|
|
221
|
+
### Screen Reader Support
|
|
222
|
+
|
|
223
|
+
- Label text announces on focus
|
|
224
|
+
- Required state properly communicated
|
|
225
|
+
- Error messages are linked via `aria-describedby`
|
|
226
|
+
- Hint text is accessible to assistive technology
|
|
227
|
+
|
|
228
|
+
## API
|
|
229
|
+
|
|
230
|
+
### Props
|
|
231
|
+
|
|
232
|
+
| Prop | Type | Default | Description |
|
|
233
|
+
|------|------|---------|-------------|
|
|
234
|
+
| `v-model` | `string` | `''` | Current input value (two-way binding) |
|
|
235
|
+
| `placeholder` | `string` | `''` | Placeholder text when empty |
|
|
236
|
+
| `prefix` | `string` | `''` | Prefix text before the input |
|
|
237
|
+
| `suffix` | `string` | `''` | Suffix text after the input |
|
|
238
|
+
| `size` | `'xs' \| 's' \| 'm' \| 'l'` | `'m'` | Input size |
|
|
239
|
+
| `rows` | `number` | `1` | Rows >= 2 enables textarea mode |
|
|
240
|
+
| `clearable` | `boolean` | `false` | Show clear button when input has value |
|
|
241
|
+
| `error` | `boolean` | `false` | Error state (auto-injected from `CoarFormField`) |
|
|
242
|
+
| `disabled` | `boolean` | `false` | Disable the input |
|
|
243
|
+
| `readonly` | `boolean` | `false` | Make read-only |
|
|
244
|
+
| `required` | `boolean` | `false` | HTML required attribute |
|
|
245
|
+
|
|
246
|
+
> **Tip**
|
|
247
|
+
>
|
|
248
|
+
> Label, hint, and error are provided by [`CoarFormField`](./form-field.md). Wrap inputs in a `CoarFormField` to add these features.
|
|
249
|
+
|
|
250
|
+
## i18n Keys
|
|
251
|
+
|
|
252
|
+
These keys can be translated via [`@cocoar/vue-localization`](../foundations/localization/translations.md).
|
|
253
|
+
|
|
254
|
+
| Key | Default (English) | Used as |
|
|
255
|
+
|-----|-------------------|---------|
|
|
256
|
+
| `coar.ui.textInput.clear` | `'Clear'` | Clear button `aria-label` |
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<!-- Generated from apps/docs/components/toast.md by apps/docs/scripts/sync-skill.mjs. Do not edit; edit the docs page. -->
|
|
2
|
+
|
|
3
|
+
# Toast
|
|
4
|
+
|
|
5
|
+
Non-blocking notification messages that slide in, deliver a brief update, and dismiss themselves. Toasts are perfect for confirming background actions -- a file uploaded, a record saved, or a network error encountered -- without interrupting the user's current workflow.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { useToast } from '@cocoar/vue-ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Variants
|
|
12
|
+
|
|
13
|
+
Four semantic variants communicate the nature of the notification at a glance. Click each button below to see the corresponding toast.
|
|
14
|
+
|
|
15
|
+
**Demo — `toast/demos/ToastVariants.vue`**
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center;">
|
|
20
|
+
<CoarButton variant="primary" @click="showSuccess">Success</CoarButton>
|
|
21
|
+
<CoarButton variant="danger" @click="showError">Error</CoarButton>
|
|
22
|
+
<CoarButton variant="secondary" @click="showWarning">Warning</CoarButton>
|
|
23
|
+
<CoarButton variant="ghost" @click="showInfo">Info</CoarButton>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { CoarButton, useToast } from '@cocoar/vue-ui';
|
|
29
|
+
|
|
30
|
+
const toast = useToast();
|
|
31
|
+
|
|
32
|
+
function showSuccess() {
|
|
33
|
+
toast.success('Changes saved successfully!', { title: 'Saved' });
|
|
34
|
+
}
|
|
35
|
+
function showError() {
|
|
36
|
+
toast.error('Something went wrong. Please try again.', { title: 'Error' });
|
|
37
|
+
}
|
|
38
|
+
function showWarning() {
|
|
39
|
+
toast.warning('Your session will expire in 5 minutes.', { title: 'Warning' });
|
|
40
|
+
}
|
|
41
|
+
function showInfo() {
|
|
42
|
+
toast.info('A new version is available. Refresh to update.', { title: 'Update Available' });
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Without Title
|
|
48
|
+
|
|
49
|
+
For straightforward messages, skip the title entirely. A single-line toast keeps the notification compact and fast to read.
|
|
50
|
+
|
|
51
|
+
**Demo — `toast/demos/ToastNoTitle.vue`**
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<template>
|
|
55
|
+
<CoarButton @click="showNoTitle">Simple message</CoarButton>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
<script setup lang="ts">
|
|
59
|
+
import { CoarButton, useToast } from '@cocoar/vue-ui';
|
|
60
|
+
|
|
61
|
+
const toast = useToast();
|
|
62
|
+
|
|
63
|
+
function showNoTitle() {
|
|
64
|
+
toast.success('File uploaded successfully.');
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Duration Control
|
|
70
|
+
|
|
71
|
+
By default, toasts dismiss after 5 seconds (error toasts stay until dismissed). Pass a custom `duration` in milliseconds for longer messages, or set `duration: 0` to create a persistent toast that stays visible until the user explicitly dismisses it.
|
|
72
|
+
|
|
73
|
+
**Demo — `toast/demos/ToastDuration.vue`**
|
|
74
|
+
|
|
75
|
+
```vue
|
|
76
|
+
<template>
|
|
77
|
+
<div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center;">
|
|
78
|
+
<CoarButton variant="secondary" @click="showLong">Long duration (6s)</CoarButton>
|
|
79
|
+
<CoarButton variant="secondary" @click="showPersistent">Persistent (no auto-dismiss)</CoarButton>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<script setup lang="ts">
|
|
84
|
+
import { CoarButton, useToast } from '@cocoar/vue-ui';
|
|
85
|
+
|
|
86
|
+
const toast = useToast();
|
|
87
|
+
|
|
88
|
+
function showLong() {
|
|
89
|
+
toast.info('This is a longer notification message that contains more detailed information about what just happened in the application.', {
|
|
90
|
+
title: 'Detailed Message',
|
|
91
|
+
duration: 6000,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function showPersistent() {
|
|
96
|
+
toast.warning('This notification stays until dismissed.', {
|
|
97
|
+
title: 'Persistent',
|
|
98
|
+
duration: 0,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
</script>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Setup
|
|
105
|
+
|
|
106
|
+
Register the overlay plugin once in your app entry point:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
// main.ts
|
|
110
|
+
import { CoarOverlayPlugin } from '@cocoar/vue-ui';
|
|
111
|
+
|
|
112
|
+
createApp(App)
|
|
113
|
+
.use(CoarOverlayPlugin)
|
|
114
|
+
.mount('#app');
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Then add the toast container to your `App.vue`:
|
|
118
|
+
|
|
119
|
+
```vue
|
|
120
|
+
<template>
|
|
121
|
+
<RouterView />
|
|
122
|
+
<CoarToastContainer />
|
|
123
|
+
</template>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`<CoarToastContainer />` needs no props — its `service` defaults to the `getToastService()` singleton that `CoarOverlayPlugin` registers (the same one `useToast()` wraps). Pass an explicit `:service` only for a non-singleton instance (e.g. an isolated test harness). If the plugin isn't installed it throws a clear "install `CoarOverlayPlugin`" error rather than rendering nothing.
|
|
127
|
+
|
|
128
|
+
## API
|
|
129
|
+
|
|
130
|
+
### `useToast()` Methods
|
|
131
|
+
|
|
132
|
+
| Method | Parameters | Description |
|
|
133
|
+
|--------|-----------|-------------|
|
|
134
|
+
| `toast.show(config)` | `ToastConfig` | Show a fully custom toast |
|
|
135
|
+
| `toast.success(message, config?)` | `string, Partial<ToastConfig>?` | Show success toast |
|
|
136
|
+
| `toast.error(message, config?)` | `string, Partial<ToastConfig>?` | Show error toast (persistent by default) |
|
|
137
|
+
| `toast.warning(message, config?)` | `string, Partial<ToastConfig>?` | Show warning toast |
|
|
138
|
+
| `toast.info(message, config?)` | `string, Partial<ToastConfig>?` | Show info toast |
|
|
139
|
+
| `toast.dismissAll()` | — | Dismiss all visible toasts |
|
|
140
|
+
|
|
141
|
+
### `ToastConfig`
|
|
142
|
+
|
|
143
|
+
| Option | Type | Default | Description |
|
|
144
|
+
|--------|------|---------|-------------|
|
|
145
|
+
| `message` | `string` | — | Toast message (required for `show()`) |
|
|
146
|
+
| `title` | `string` | `undefined` | Optional toast title |
|
|
147
|
+
| `duration` | `number` | `5000` (errors: `0`) | Duration in ms (0 = persistent) |
|
|
148
|
+
| `position` | `'top-right' \| 'top-left' \| 'top-center' \| 'bottom-right' \| 'bottom-left' \| 'bottom-center'` | `'top-right'` | Screen position |
|
|
149
|
+
| `dismissible` | `boolean` | `true` | Show close button |
|
|
150
|
+
| `showProgress` | `boolean` | `true` | Show progress bar |
|
|
151
|
+
| `action` | `{ label: string; callback: () => void }` | `undefined` | Optional action button |
|
|
152
|
+
|
|
153
|
+
## i18n Keys
|
|
154
|
+
|
|
155
|
+
These keys can be translated via [`@cocoar/vue-localization`](../foundations/localization/translations.md).
|
|
156
|
+
|
|
157
|
+
| Key | Default (English) | Used as |
|
|
158
|
+
|-----|-------------------|---------|
|
|
159
|
+
| `coar.ui.toast.dismiss` | `'Dismiss notification'` | Dismiss button `aria-label` |
|
|
160
|
+
| `coar.ui.toast.notifications` | `'Notifications'` | Toast container region `aria-label` |
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<!-- Generated from apps/docs/components/tooltip.md by apps/docs/scripts/sync-skill.mjs. Do not edit; edit the docs page. -->
|
|
2
|
+
|
|
3
|
+
# Tooltip
|
|
4
|
+
|
|
5
|
+
Tooltips are small, text-only hints that appear on hover or focus. They are the simplest way to add contextual labels to icon buttons, truncated text, or any element that benefits from a brief explanation. Use the `v-tooltip` directive on any element -- no wrapper component needed.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { vTooltip } from '@cocoar/vue-ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Tooltip
|
|
12
|
+
|
|
13
|
+
Pass a string directly to `v-tooltip` for the quickest setup. Hover over any button below to see its tooltip.
|
|
14
|
+
|
|
15
|
+
**Demo — `tooltip/demos/TooltipBasic.vue`**
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center;">
|
|
20
|
+
<CoarButton v-tooltip="'Save your changes'">Save</CoarButton>
|
|
21
|
+
<CoarButton variant="danger" v-tooltip="'This action cannot be undone'">Delete</CoarButton>
|
|
22
|
+
<CoarButton variant="ghost" v-tooltip="'Cancel and go back'">Cancel</CoarButton>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { CoarButton, vTooltip } from '@cocoar/vue-ui';
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Placements
|
|
32
|
+
|
|
33
|
+
By default, tooltips appear above the trigger. Use the options object form to position them on any side. Pick the placement that avoids clipping in your layout.
|
|
34
|
+
|
|
35
|
+
**Demo — `tooltip/demos/TooltipPlacements.vue`**
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<template>
|
|
39
|
+
<div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 16px 0;">
|
|
40
|
+
<CoarButton v-tooltip="{ text: 'Top tooltip', placement: 'top' }">Top</CoarButton>
|
|
41
|
+
<CoarButton v-tooltip="{ text: 'Bottom tooltip', placement: 'bottom' }">Bottom</CoarButton>
|
|
42
|
+
<CoarButton v-tooltip="{ text: 'Left tooltip', placement: 'left' }">Left</CoarButton>
|
|
43
|
+
<CoarButton v-tooltip="{ text: 'Right tooltip', placement: 'right' }">Right</CoarButton>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script setup lang="ts">
|
|
48
|
+
import { CoarButton, vTooltip } from '@cocoar/vue-ui';
|
|
49
|
+
</script>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## On Icon Buttons
|
|
53
|
+
|
|
54
|
+
Icon-only buttons look clean, but their meaning can be ambiguous. Adding a tooltip provides both a visual hint for sighted users and an accessible label for screen readers -- making tooltips essential for any icon-only control.
|
|
55
|
+
|
|
56
|
+
**Demo — `tooltip/demos/TooltipIcons.vue`**
|
|
57
|
+
|
|
58
|
+
```vue
|
|
59
|
+
<template>
|
|
60
|
+
<div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center;">
|
|
61
|
+
<CoarButton variant="ghost" icon-start="plus" v-tooltip="'Add new item'" aria-label="Add new item" />
|
|
62
|
+
<CoarButton variant="ghost" icon-start="copy" v-tooltip="'Copy to clipboard'" aria-label="Copy" />
|
|
63
|
+
<CoarButton variant="ghost" icon-start="trash-2" v-tooltip="'Delete selected'" aria-label="Delete" />
|
|
64
|
+
<CoarButton variant="ghost" icon-start="settings" v-tooltip="'Open settings'" aria-label="Settings" />
|
|
65
|
+
</div>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script setup lang="ts">
|
|
69
|
+
import { CoarButton, vTooltip } from '@cocoar/vue-ui';
|
|
70
|
+
</script>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## On Any Element
|
|
74
|
+
|
|
75
|
+
`v-tooltip` is a directive, so it works on any HTML element -- spans, icons, code snippets, or custom components. No special wrapper needed.
|
|
76
|
+
|
|
77
|
+
**Demo — `tooltip/demos/TooltipElements.vue`**
|
|
78
|
+
|
|
79
|
+
```vue
|
|
80
|
+
<template>
|
|
81
|
+
<div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center;">
|
|
82
|
+
<span
|
|
83
|
+
v-tooltip="'This is a span'"
|
|
84
|
+
style="padding: 4px 8px; border: 1px solid var(--coar-border-neutral-secondary); border-radius: 4px; font-size: 13px; cursor: default;"
|
|
85
|
+
>Hover me (span)</span>
|
|
86
|
+
<CoarIcon name="circle-help" size="l" v-tooltip="'Help: Click for more info'" style="cursor: help" />
|
|
87
|
+
<code
|
|
88
|
+
v-tooltip="'CSS custom property'"
|
|
89
|
+
style="cursor: default; background: var(--coar-background-neutral-tertiary); padding: 2px 6px; border-radius: 3px; font-size: 13px;"
|
|
90
|
+
>--coar-spacing-m</code>
|
|
91
|
+
</div>
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
<script setup lang="ts">
|
|
95
|
+
import { CoarIcon, vTooltip } from '@cocoar/vue-ui';
|
|
96
|
+
</script>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
> **Tip: Tooltip vs Popover**
|
|
100
|
+
>
|
|
101
|
+
> Use **Tooltip** for short, non-interactive text hints on hover or focus. Use **Popover** for rich interactive content that opens on click. Tooltips are text-only and disappear when the pointer leaves; popovers can hold buttons, forms, and full HTML.
|
|
102
|
+
|
|
103
|
+
## API
|
|
104
|
+
|
|
105
|
+
### `v-tooltip` Options
|
|
106
|
+
|
|
107
|
+
The directive accepts either a plain string or an options object:
|
|
108
|
+
|
|
109
|
+
```vue
|
|
110
|
+
<!-- String shorthand -->
|
|
111
|
+
<CoarButton v-tooltip="'Save changes'">Save</CoarButton>
|
|
112
|
+
|
|
113
|
+
<!-- Options object -->
|
|
114
|
+
<CoarButton v-tooltip="{ text: 'Delete item', placement: 'top' }">Delete</CoarButton>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
| Option | Type | Default | Description |
|
|
118
|
+
|--------|------|---------|-------------|
|
|
119
|
+
| `text` | `string` | -- | Tooltip text (or pass string directly to the directive) |
|
|
120
|
+
| `placement` | `'top' \| 'bottom' \| 'left' \| 'right'` | `'top'` | Preferred tooltip placement |
|
|
121
|
+
| `disabled` | `boolean` | `false` | Disable the tooltip |
|