@cocoar/vue-ui 3.1.0 → 3.2.0-beta.11
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/bin/cli.mjs +53 -0
- 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 +9 -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 +372 -0
- package/skills/cocoar-vue-ui/references/components/calendar/coar-calendar.md +1647 -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 +486 -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 +116 -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,279 @@
|
|
|
1
|
+
<!-- Generated from apps/docs/components/checkbox.md by apps/docs/scripts/sync-skill.mjs. Do not edit; edit the docs page. -->
|
|
2
|
+
|
|
3
|
+
# Checkbox
|
|
4
|
+
|
|
5
|
+
Checkboxes let users pick one or more options from a list, or flip a single boolean on or off. Reach for a checkbox when the choice does not take effect until the user explicitly submits -- for instant toggles, consider a [Switch](./switch.md) instead.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { CoarCheckbox } from '@cocoar/vue-ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
Bind a boolean with `v-model` and provide a `label`. That is all you need for a working checkbox.
|
|
14
|
+
|
|
15
|
+
**Demo — `checkbox/demos/BasicCheckbox.vue`**
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
20
|
+
<CoarCheckbox v-model="checked" label="Accept terms and conditions" />
|
|
21
|
+
<span style="font-size: 13px; color: #64748b;">Checked: {{ checked }}</span>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { ref } from 'vue';
|
|
27
|
+
import { CoarCheckbox } from '@cocoar/vue-ui';
|
|
28
|
+
|
|
29
|
+
const checked = ref(false);
|
|
30
|
+
</script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## States
|
|
34
|
+
|
|
35
|
+
Checkboxes support `required`, `disabled`, and `error` states, giving you full control over form validation flows.
|
|
36
|
+
|
|
37
|
+
**Demo — `checkbox/demos/CheckboxStates.vue`**
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<template>
|
|
41
|
+
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
42
|
+
<CoarCheckbox v-model="required" label="Required checkbox" :required="true" />
|
|
43
|
+
<CoarCheckbox :model-value="true" label="Disabled (checked)" :disabled="true" />
|
|
44
|
+
<CoarCheckbox :model-value="false" label="Disabled (unchecked)" :disabled="true" />
|
|
45
|
+
<CoarFormField error="This field is required">
|
|
46
|
+
<CoarCheckbox :model-value="false" label="With error" />
|
|
47
|
+
</CoarFormField>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import { ref } from 'vue';
|
|
53
|
+
import { CoarCheckbox, CoarFormField } from '@cocoar/vue-ui';
|
|
54
|
+
|
|
55
|
+
const required = ref(false);
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Indeterminate
|
|
60
|
+
|
|
61
|
+
The indeterminate state shows a dash instead of a checkmark -- handy for "select all" controls where only some children are checked.
|
|
62
|
+
|
|
63
|
+
**Demo — `checkbox/demos/CheckboxIndeterminate.vue`**
|
|
64
|
+
|
|
65
|
+
```vue
|
|
66
|
+
<template>
|
|
67
|
+
<div>
|
|
68
|
+
<CoarCheckbox v-model="checked" :indeterminate="true" label="Select all (partial)" />
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script setup lang="ts">
|
|
73
|
+
import { ref } from 'vue';
|
|
74
|
+
import { CoarCheckbox } from '@cocoar/vue-ui';
|
|
75
|
+
|
|
76
|
+
const checked = ref(false);
|
|
77
|
+
</script>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Sizes
|
|
81
|
+
|
|
82
|
+
Four sizes to match different information densities, from compact data tables to spacious settings pages.
|
|
83
|
+
|
|
84
|
+
**Demo — `checkbox/demos/CheckboxSizes.vue`**
|
|
85
|
+
|
|
86
|
+
```vue
|
|
87
|
+
<template>
|
|
88
|
+
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
89
|
+
<CoarCheckbox :model-value="true" size="xs" label="Extra-small checkbox" />
|
|
90
|
+
<CoarCheckbox :model-value="true" size="s" label="Small checkbox" />
|
|
91
|
+
<CoarCheckbox :model-value="true" size="m" label="Medium checkbox (default)" />
|
|
92
|
+
<CoarCheckbox :model-value="true" size="l" label="Large checkbox" />
|
|
93
|
+
</div>
|
|
94
|
+
</template>
|
|
95
|
+
|
|
96
|
+
<script setup lang="ts">
|
|
97
|
+
import { CoarCheckbox } from '@cocoar/vue-ui';
|
|
98
|
+
</script>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Hint Text
|
|
102
|
+
|
|
103
|
+
Wrap in `CoarFormField` with a `hint` prop to give users extra context without cluttering the label itself. When the form field owns the label, use `layout="inline"` for checkbox and switch rows.
|
|
104
|
+
|
|
105
|
+
**Demo — `checkbox/demos/CheckboxHint.vue`**
|
|
106
|
+
|
|
107
|
+
```vue
|
|
108
|
+
<template>
|
|
109
|
+
<div style="display: flex; flex-direction: column; gap: 8px">
|
|
110
|
+
<CoarFormField
|
|
111
|
+
label="Subscribe to newsletter"
|
|
112
|
+
hint="Receive weekly updates about new features."
|
|
113
|
+
layout="inline"
|
|
114
|
+
label-position="after"
|
|
115
|
+
>
|
|
116
|
+
<CoarCheckbox :model-value="false" />
|
|
117
|
+
</CoarFormField>
|
|
118
|
+
<CoarFormField
|
|
119
|
+
label="Enable analytics"
|
|
120
|
+
hint="Help us improve the product by sharing usage data."
|
|
121
|
+
layout="inline"
|
|
122
|
+
label-position="after"
|
|
123
|
+
>
|
|
124
|
+
<CoarCheckbox :model-value="false" />
|
|
125
|
+
</CoarFormField>
|
|
126
|
+
</div>
|
|
127
|
+
</template>
|
|
128
|
+
|
|
129
|
+
<script setup lang="ts">
|
|
130
|
+
import { CoarCheckbox, CoarFormField } from '@cocoar/vue-ui';
|
|
131
|
+
</script>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Label Position
|
|
135
|
+
|
|
136
|
+
Place the label before or after the checkbox with the `labelPosition` prop. Defaults to `'after'`.
|
|
137
|
+
|
|
138
|
+
**Demo — `checkbox/demos/CheckboxLabelPosition.vue`**
|
|
139
|
+
|
|
140
|
+
```vue
|
|
141
|
+
<template>
|
|
142
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
143
|
+
<CoarCheckbox v-model="a" label="Label after (default)" label-position="after" />
|
|
144
|
+
<CoarCheckbox v-model="b" label="Label before" label-position="before" />
|
|
145
|
+
</div>
|
|
146
|
+
</template>
|
|
147
|
+
|
|
148
|
+
<script setup lang="ts">
|
|
149
|
+
import { ref } from 'vue';
|
|
150
|
+
import { CoarCheckbox } from '@cocoar/vue-ui';
|
|
151
|
+
|
|
152
|
+
const a = ref(true);
|
|
153
|
+
const b = ref(true);
|
|
154
|
+
</script>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Long Labels
|
|
158
|
+
|
|
159
|
+
Checkbox labels may wrap naturally. These deliberately narrow examples show both label positions and a mixed-length group.
|
|
160
|
+
|
|
161
|
+
**Demo — `checkbox/demos/CheckboxLongLabel.vue`**
|
|
162
|
+
|
|
163
|
+
```vue
|
|
164
|
+
<template>
|
|
165
|
+
<div class="long-label-demo">
|
|
166
|
+
<section>
|
|
167
|
+
<h4>Label after</h4>
|
|
168
|
+
<CoarCheckbox
|
|
169
|
+
v-model="after"
|
|
170
|
+
label="Send me a weekly summary of activity, security events, and account changes"
|
|
171
|
+
/>
|
|
172
|
+
</section>
|
|
173
|
+
|
|
174
|
+
<section>
|
|
175
|
+
<h4>Label before</h4>
|
|
176
|
+
<CoarCheckbox
|
|
177
|
+
v-model="before"
|
|
178
|
+
label="Send me a weekly summary of activity, security events, and account changes"
|
|
179
|
+
label-position="before"
|
|
180
|
+
/>
|
|
181
|
+
</section>
|
|
182
|
+
|
|
183
|
+
<section>
|
|
184
|
+
<h4>Inside a group</h4>
|
|
185
|
+
<CoarCheckboxGroup v-model="selected">
|
|
186
|
+
<CoarCheckbox
|
|
187
|
+
value="security"
|
|
188
|
+
label="Notify me when a security-sensitive setting is changed by another administrator"
|
|
189
|
+
/>
|
|
190
|
+
<CoarCheckbox value="product" label="Receive occasional product announcements" />
|
|
191
|
+
</CoarCheckboxGroup>
|
|
192
|
+
</section>
|
|
193
|
+
</div>
|
|
194
|
+
</template>
|
|
195
|
+
|
|
196
|
+
<script setup lang="ts">
|
|
197
|
+
import { ref } from 'vue';
|
|
198
|
+
import { CoarCheckbox, CoarCheckboxGroup } from '@cocoar/vue-ui';
|
|
199
|
+
|
|
200
|
+
const after = ref(false);
|
|
201
|
+
const before = ref(false);
|
|
202
|
+
const selected = ref<string[]>([]);
|
|
203
|
+
</script>
|
|
204
|
+
|
|
205
|
+
<style scoped>
|
|
206
|
+
.long-label-demo {
|
|
207
|
+
display: grid;
|
|
208
|
+
gap: var(--coar-spacing-l);
|
|
209
|
+
width: min(100%, 320px);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.long-label-demo section {
|
|
213
|
+
display: grid;
|
|
214
|
+
gap: var(--coar-spacing-xs);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.long-label-demo h4 {
|
|
218
|
+
margin: 0;
|
|
219
|
+
color: var(--coar-text-neutral-secondary);
|
|
220
|
+
font-size: 12px;
|
|
221
|
+
font-weight: 500;
|
|
222
|
+
}
|
|
223
|
+
</style>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Without Label
|
|
227
|
+
|
|
228
|
+
For table rows or tight custom layouts you can omit the visible label -- just make sure to pass an `aria-label` so the checkbox remains accessible.
|
|
229
|
+
|
|
230
|
+
**Demo — `checkbox/demos/CheckboxWithoutLabel.vue`**
|
|
231
|
+
|
|
232
|
+
```vue
|
|
233
|
+
<template>
|
|
234
|
+
<div style="display: flex; gap: 16px; align-items: center;">
|
|
235
|
+
<CoarCheckbox :model-value="false" aria-label="Select row 1" />
|
|
236
|
+
<CoarCheckbox :model-value="true" aria-label="Select row 2" />
|
|
237
|
+
<CoarCheckbox :model-value="false" :indeterminate="true" aria-label="Select all" />
|
|
238
|
+
</div>
|
|
239
|
+
</template>
|
|
240
|
+
|
|
241
|
+
<script setup lang="ts">
|
|
242
|
+
import { CoarCheckbox } from '@cocoar/vue-ui';
|
|
243
|
+
</script>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Accessibility
|
|
247
|
+
|
|
248
|
+
### Keyboard Navigation
|
|
249
|
+
|
|
250
|
+
| Key | Action |
|
|
251
|
+
|-----|--------|
|
|
252
|
+
| `Tab` | Move focus to checkbox |
|
|
253
|
+
| `Space` | Toggle checked state |
|
|
254
|
+
|
|
255
|
+
> **Info**
|
|
256
|
+
>
|
|
257
|
+
> The indeterminate state is visual only. Clicking an indeterminate checkbox toggles it to checked. Always provide `aria-label` when no visible label is used.
|
|
258
|
+
|
|
259
|
+
### Screen Reader Support
|
|
260
|
+
|
|
261
|
+
- Label text or `aria-label` announces on focus
|
|
262
|
+
- Checked / unchecked state communicated
|
|
263
|
+
- Required and error states announced
|
|
264
|
+
- Hint text accessible via `aria-describedby`
|
|
265
|
+
|
|
266
|
+
## API
|
|
267
|
+
|
|
268
|
+
### Props
|
|
269
|
+
|
|
270
|
+
| Prop | Type | Default | Description |
|
|
271
|
+
|------|------|---------|-------------|
|
|
272
|
+
| `v-model` | `boolean` | `false` | Checked state |
|
|
273
|
+
| `label` | `string` | `''` | Label text |
|
|
274
|
+
| `error` | `boolean` | `false` | Error state (auto-injected from `CoarFormField`) |
|
|
275
|
+
| `size` | `'xs' \| 's' \| 'm' \| 'l'` | `'m'` | Checkbox size |
|
|
276
|
+
| `labelPosition` | `'before' \| 'after'` | `'after'` | Label position relative to the checkbox |
|
|
277
|
+
| `indeterminate` | `boolean` | `false` | Show indeterminate (dash) state |
|
|
278
|
+
| `disabled` | `boolean` | `false` | Disable the checkbox |
|
|
279
|
+
| `required` | `boolean` | `false` | Mark as required |
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<!-- Generated from apps/docs/components/code-block.md by apps/docs/scripts/sync-skill.mjs. Do not edit; edit the docs page. -->
|
|
2
|
+
|
|
3
|
+
# Code Block
|
|
4
|
+
|
|
5
|
+
Display source code with syntax highlighting, a one-click copy button, and optional collapsing. Use it in documentation, onboarding flows, or anywhere users need to read or copy code snippets.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { CoarCodeBlock } from '@cocoar/vue-ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Language Support
|
|
12
|
+
|
|
13
|
+
Built-in highlighting for TypeScript, HTML, CSS, Bash, JSON, and more. The language is detected from the `language` prop, so colors and tokens always match the syntax.
|
|
14
|
+
|
|
15
|
+
**Demo — `code-block/demos/CodeBlockLanguages.vue`**
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
20
|
+
<div>
|
|
21
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">TypeScript</p>
|
|
22
|
+
<CoarCodeBlock :code="tsExample" language="typescript" />
|
|
23
|
+
</div>
|
|
24
|
+
<div>
|
|
25
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">HTML / Template</p>
|
|
26
|
+
<CoarCodeBlock :code="htmlExample" language="html" />
|
|
27
|
+
</div>
|
|
28
|
+
<div>
|
|
29
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">CSS</p>
|
|
30
|
+
<CoarCodeBlock :code="cssExample" language="css" />
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import { CoarCodeBlock } from '@cocoar/vue-ui';
|
|
37
|
+
|
|
38
|
+
const tsExample = `import { ref, computed } from 'vue';
|
|
39
|
+
import { CoarButton } from '@cocoar/vue-ui';
|
|
40
|
+
|
|
41
|
+
const count = ref(0);
|
|
42
|
+
const doubled = computed(() => count.value * 2);
|
|
43
|
+
|
|
44
|
+
function increment() {
|
|
45
|
+
count.value++;
|
|
46
|
+
}`;
|
|
47
|
+
|
|
48
|
+
const htmlExample = `<template>
|
|
49
|
+
<CoarButton
|
|
50
|
+
variant="primary"
|
|
51
|
+
icon-start="plus"
|
|
52
|
+
@click="increment"
|
|
53
|
+
>
|
|
54
|
+
Count: {{ count }}
|
|
55
|
+
</CoarButton>
|
|
56
|
+
<p>Doubled: {{ doubled }}</p>
|
|
57
|
+
</template>`;
|
|
58
|
+
|
|
59
|
+
const cssExample = `.my-component {
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
gap: var(--coar-spacing-m);
|
|
63
|
+
padding: var(--coar-spacing-l);
|
|
64
|
+
border-radius: var(--coar-radius-m);
|
|
65
|
+
background: var(--coar-background-neutral-primary);
|
|
66
|
+
box-shadow: var(--coar-shadow-s);
|
|
67
|
+
}`;
|
|
68
|
+
</script>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Demo — `code-block/demos/CodeBlockBashJson.vue`**
|
|
72
|
+
|
|
73
|
+
```vue
|
|
74
|
+
<template>
|
|
75
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
76
|
+
<div>
|
|
77
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">Bash</p>
|
|
78
|
+
<CoarCodeBlock :code="bashExample" language="bash" />
|
|
79
|
+
</div>
|
|
80
|
+
<div>
|
|
81
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">JSON</p>
|
|
82
|
+
<CoarCodeBlock :code="jsonExample" language="json" />
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<script setup lang="ts">
|
|
88
|
+
import { CoarCodeBlock } from '@cocoar/vue-ui';
|
|
89
|
+
|
|
90
|
+
const bashExample = `# Install dependencies
|
|
91
|
+
pnpm install
|
|
92
|
+
|
|
93
|
+
# Start development server
|
|
94
|
+
pnpm dev
|
|
95
|
+
|
|
96
|
+
# Build for production
|
|
97
|
+
pnpm build`;
|
|
98
|
+
|
|
99
|
+
const jsonExample = `{
|
|
100
|
+
"name": "@cocoar/vue-ui",
|
|
101
|
+
"version": "1.0.0",
|
|
102
|
+
"exports": {
|
|
103
|
+
".": {
|
|
104
|
+
"source": "./src/index.ts",
|
|
105
|
+
"import": "./dist/index.js"
|
|
106
|
+
},
|
|
107
|
+
"./styles": "./styles/bundle.css"
|
|
108
|
+
}
|
|
109
|
+
}`;
|
|
110
|
+
</script>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Collapsible Behavior
|
|
114
|
+
|
|
115
|
+
Keep long snippets from dominating the page. Start them collapsed so users can expand on demand, or disable collapsing when the code should always be visible.
|
|
116
|
+
|
|
117
|
+
**Demo — `code-block/demos/CodeBlockCollapsed.vue`**
|
|
118
|
+
|
|
119
|
+
```vue
|
|
120
|
+
<template>
|
|
121
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
122
|
+
<div>
|
|
123
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">Collapsed by default (click to expand)</p>
|
|
124
|
+
<CoarCodeBlock :code="code" language="typescript" :collapsed="true" />
|
|
125
|
+
</div>
|
|
126
|
+
<div>
|
|
127
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">Non-collapsible (always visible)</p>
|
|
128
|
+
<CoarCodeBlock :code="shortCode" language="bash" :collapsible="false" />
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</template>
|
|
132
|
+
|
|
133
|
+
<script setup lang="ts">
|
|
134
|
+
import { CoarCodeBlock } from '@cocoar/vue-ui';
|
|
135
|
+
|
|
136
|
+
const code = `import { ref, computed } from 'vue';
|
|
137
|
+
import { CoarButton } from '@cocoar/vue-ui';
|
|
138
|
+
|
|
139
|
+
const count = ref(0);
|
|
140
|
+
const doubled = computed(() => count.value * 2);
|
|
141
|
+
|
|
142
|
+
function increment() {
|
|
143
|
+
count.value++;
|
|
144
|
+
}`;
|
|
145
|
+
|
|
146
|
+
const shortCode = `# Install dependencies
|
|
147
|
+
pnpm install
|
|
148
|
+
|
|
149
|
+
# Start development server
|
|
150
|
+
pnpm dev`;
|
|
151
|
+
</script>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Variants
|
|
155
|
+
|
|
156
|
+
The default `neutral` variant uses a neutral background. Other variants color the header area to match semantic context — `info`, `success`, `warning`, `error`, or `accent`.
|
|
157
|
+
|
|
158
|
+
**Demo — `code-block/demos/CodeBlockVariants.vue`**
|
|
159
|
+
|
|
160
|
+
```vue
|
|
161
|
+
<template>
|
|
162
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
163
|
+
<div>
|
|
164
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">Neutral (default)</p>
|
|
165
|
+
<CoarCodeBlock code="import { CoarButton } from '@cocoar/vue-ui';" language="typescript" :collapsible="false" />
|
|
166
|
+
</div>
|
|
167
|
+
<div>
|
|
168
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">Info</p>
|
|
169
|
+
<CoarCodeBlock code="import { CoarButton } from '@cocoar/vue-ui';" language="typescript" variant="info" :collapsible="false" />
|
|
170
|
+
</div>
|
|
171
|
+
<div>
|
|
172
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">Success</p>
|
|
173
|
+
<CoarCodeBlock code="import { CoarButton } from '@cocoar/vue-ui';" language="typescript" variant="success" :collapsible="false" />
|
|
174
|
+
</div>
|
|
175
|
+
<div>
|
|
176
|
+
<p style="margin: 0 0 4px; font-size: 13px; color: #64748b;">Error</p>
|
|
177
|
+
<CoarCodeBlock code="import { CoarButton } from '@cocoar/vue-ui';" language="typescript" variant="error" :collapsible="false" />
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</template>
|
|
181
|
+
|
|
182
|
+
<script setup lang="ts">
|
|
183
|
+
import { CoarCodeBlock } from '@cocoar/vue-ui';
|
|
184
|
+
</script>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## With Line Numbers
|
|
188
|
+
|
|
189
|
+
Enable line numbers for larger code blocks where users need to reference specific lines.
|
|
190
|
+
|
|
191
|
+
**Demo — `code-block/demos/CodeBlockNoLineNumbers.vue`**
|
|
192
|
+
|
|
193
|
+
```vue
|
|
194
|
+
<template>
|
|
195
|
+
<CoarCodeBlock :code="code" language="typescript" :show-line-numbers="true" :collapsible="false" />
|
|
196
|
+
</template>
|
|
197
|
+
|
|
198
|
+
<script setup lang="ts">
|
|
199
|
+
import { CoarCodeBlock } from '@cocoar/vue-ui';
|
|
200
|
+
|
|
201
|
+
const code = `import { ref, computed } from 'vue';
|
|
202
|
+
|
|
203
|
+
const count = ref(0);
|
|
204
|
+
const doubled = computed(() => count.value * 2);
|
|
205
|
+
|
|
206
|
+
function increment() {
|
|
207
|
+
count.value++;
|
|
208
|
+
}`;
|
|
209
|
+
</script>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## API
|
|
213
|
+
|
|
214
|
+
### Props
|
|
215
|
+
|
|
216
|
+
| Prop | Type | Default | Description |
|
|
217
|
+
|------|------|---------|-------------|
|
|
218
|
+
| `code` | `string` | `''` | The source code to display |
|
|
219
|
+
| `language` | `string` | `'html'` | Syntax highlighting language |
|
|
220
|
+
| `variant` | `'neutral' \| 'info' \| 'success' \| 'warning' \| 'error' \| 'accent'` | `'neutral'` | Header color variant |
|
|
221
|
+
| `title` | `string` | `''` | Optional title/filename label |
|
|
222
|
+
| `collapsible` | `boolean` | `true` | Show collapse/expand toggle |
|
|
223
|
+
| `collapsed` | `boolean` | `false` | Start in collapsed state |
|
|
224
|
+
| `showLineNumbers` | `boolean` | `false` | Show line numbers |
|
|
225
|
+
| `showCopy` | `boolean` | `true` | Show copy-to-clipboard button |
|
|
226
|
+
| `maxHeight` | `number` | `0` | Maximum height in px before scrolling (0 = no limit) |
|
|
227
|
+
| `borderless` | `boolean` | `false` | Hide border and border-radius |
|
|
228
|
+
| `elevated` | `boolean` | `false` | Add box shadow |
|
|
229
|
+
|
|
230
|
+
## i18n Keys
|
|
231
|
+
|
|
232
|
+
These keys can be translated via [`@cocoar/vue-localization`](../foundations/localization/translations.md).
|
|
233
|
+
|
|
234
|
+
| Key | Default (English) | Used as |
|
|
235
|
+
|-----|-------------------|---------|
|
|
236
|
+
| `coar.ui.codeBlock.copy` | `'Copy'` | Copy button text |
|
|
237
|
+
| `coar.ui.codeBlock.copied` | `'Copied!'` | Copy button text (after success) |
|
|
238
|
+
| `coar.ui.codeBlock.failed` | `'Failed'` | Copy button text (after error) |
|
|
239
|
+
| `coar.ui.codeBlock.copyLabel` | `'Copy code'` | Copy button `aria-label` |
|
|
240
|
+
| `coar.ui.codeBlock.toggleVisibility` | `'Toggle code visibility'` | Collapse/expand button `aria-label` |
|
|
241
|
+
| `coar.ui.codeBlock.code` | `'Code'` | Code block `aria-label` |
|