@fiscozen/checkbox 1.0.0 → 1.1.0
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/README.md +142 -0
- package/dist/checkbox.js +743 -569
- package/dist/checkbox.umd.cjs +2 -2
- package/dist/src/FzCheckboxCard.vue.d.ts +240 -0
- package/dist/src/FzCheckboxGroup.vue.d.ts +8 -2
- package/dist/src/__tests__/FzCheckboxCard.spec.d.ts +1 -0
- package/dist/src/common.d.ts +16 -5
- package/dist/src/index.d.ts +2 -1
- package/dist/src/types.d.ts +71 -2
- package/dist/style.css +1 -1
- package/package.json +7 -7
- package/src/FzCheckboxCard.vue +209 -0
- package/src/FzCheckboxGroup.vue +33 -10
- package/src/__tests__/FzCheckboxCard.spec.ts +423 -0
- package/src/__tests__/__snapshots__/FzCheckboxCard.spec.ts.snap +17 -0
- package/src/common.ts +19 -0
- package/src/index.ts +6 -1
- package/src/types.ts +86 -1
- package/tsconfig.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ A fully accessible, WCAG 2.1 AA compliant checkbox component library for Vue 3 a
|
|
|
7
7
|
- **WCAG 2.1 AA Compliant** - Full accessibility support with comprehensive ARIA attributes
|
|
8
8
|
- **Flexible Data Models** - Support for boolean (single) and array (multi-select) v-model binding
|
|
9
9
|
- **Hierarchical Structures** - Parent-child checkbox relationships with automatic indeterminate state
|
|
10
|
+
- **Card-style Checkboxes** - Rich selection cards with images, titles, subtitles, and tooltips
|
|
10
11
|
- **Keyboard Navigation** - Complete keyboard accessibility with visible focus indicators
|
|
11
12
|
- **Screen Reader Optimized** - Proper semantic markup and live region announcements
|
|
12
13
|
- **Error Handling** - Built-in validation states with accessible error messages
|
|
@@ -113,6 +114,37 @@ const options = [
|
|
|
113
114
|
</template>
|
|
114
115
|
```
|
|
115
116
|
|
|
117
|
+
### Checkbox Card
|
|
118
|
+
|
|
119
|
+
```vue
|
|
120
|
+
<script setup lang="ts">
|
|
121
|
+
import { ref } from 'vue';
|
|
122
|
+
import { FzCheckboxCard } from '@fiscozen/checkbox';
|
|
123
|
+
|
|
124
|
+
const selected = ref<(string | number)[]>([]);
|
|
125
|
+
</script>
|
|
126
|
+
|
|
127
|
+
<template>
|
|
128
|
+
<div style="display: flex; gap: 12px;">
|
|
129
|
+
<FzCheckboxCard
|
|
130
|
+
v-model="selected"
|
|
131
|
+
label="option-a"
|
|
132
|
+
value="option-a"
|
|
133
|
+
title="Option A"
|
|
134
|
+
subtitle="Description for option A"
|
|
135
|
+
/>
|
|
136
|
+
|
|
137
|
+
<FzCheckboxCard
|
|
138
|
+
v-model="selected"
|
|
139
|
+
label="option-b"
|
|
140
|
+
value="option-b"
|
|
141
|
+
title="Option B"
|
|
142
|
+
subtitle="Description for option B"
|
|
143
|
+
/>
|
|
144
|
+
</div>
|
|
145
|
+
</template>
|
|
146
|
+
```
|
|
147
|
+
|
|
116
148
|
## API Reference
|
|
117
149
|
|
|
118
150
|
### FzCheckbox
|
|
@@ -191,6 +223,45 @@ v-model: string[]
|
|
|
191
223
|
|
|
192
224
|
---
|
|
193
225
|
|
|
226
|
+
### FzCheckboxCard
|
|
227
|
+
|
|
228
|
+
A card-style checkbox component with support for title, subtitle, optional image, and tooltip. Available in horizontal and vertical layout variants. Uses array v-model for multi-select patterns.
|
|
229
|
+
|
|
230
|
+
#### Props
|
|
231
|
+
|
|
232
|
+
| Prop | Type | Default | Description |
|
|
233
|
+
|------|------|---------|-------------|
|
|
234
|
+
| `label` | `string` | **required** | Accessible label for the underlying checkbox input |
|
|
235
|
+
| `value` | `string \| number` | `label` | Value tracked in the array v-model |
|
|
236
|
+
| `title` | `string` | **required** | Primary title text displayed in the card |
|
|
237
|
+
| `subtitle` | `string` | `undefined` | Optional secondary text below the title |
|
|
238
|
+
| `variant` | `'horizontal' \| 'vertical'` | `'horizontal'` | Layout direction of the card |
|
|
239
|
+
| `imageUrl` | `string` | `undefined` | URL of the card image (required when `variant` is `'vertical'`) |
|
|
240
|
+
| `imageAlt` | `string` | `undefined` | Alt text for the card image |
|
|
241
|
+
| `hasCheckbox` | `boolean` | `true` | Whether to show the checkbox icon inside the card |
|
|
242
|
+
| `emphasis` | `boolean` | `false` | Applies emphasis styling (blue icon when checked) |
|
|
243
|
+
| `disabled` | `boolean` | `false` | Disables the card |
|
|
244
|
+
| `error` | `boolean` | `false` | Shows error state (red checkbox icon) |
|
|
245
|
+
| `required` | `boolean` | `false` | Marks the input as required |
|
|
246
|
+
| `tooltip` | `string` | `undefined` | Text to display in the info tooltip |
|
|
247
|
+
| `tooltipStatus` | `FzTooltipStatus` | `'neutral'` | Tooltip color/status variant |
|
|
248
|
+
| `name` | `string` | `undefined` | Input `name` attribute for form submission |
|
|
249
|
+
|
|
250
|
+
> **Note:** When `variant` is `'vertical'`, the `imageUrl` prop is required since the vertical layout is designed around a full-width image.
|
|
251
|
+
|
|
252
|
+
#### v-model
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
v-model: (string | number | boolean)[]
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
#### Variant Layouts
|
|
259
|
+
|
|
260
|
+
- **Horizontal** (default) — Checkbox icon, optional thumbnail image (58×58), and text are arranged in a row. Compact layout suited for lists.
|
|
261
|
+
- **Vertical** — Full-width 16:9 image on top, checkbox icon overlaid, and text below. Designed for visually rich selections.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
194
265
|
## Advanced Usage
|
|
195
266
|
|
|
196
267
|
### With Error Validation
|
|
@@ -368,6 +439,67 @@ const dayOptions = [
|
|
|
368
439
|
</template>
|
|
369
440
|
```
|
|
370
441
|
|
|
442
|
+
### Checkbox Card — Vertical with Image
|
|
443
|
+
|
|
444
|
+
```vue
|
|
445
|
+
<script setup lang="ts">
|
|
446
|
+
import { ref } from 'vue';
|
|
447
|
+
import { FzCheckboxCard } from '@fiscozen/checkbox';
|
|
448
|
+
|
|
449
|
+
const selected = ref<(string | number)[]>([]);
|
|
450
|
+
</script>
|
|
451
|
+
|
|
452
|
+
<template>
|
|
453
|
+
<div style="display: flex; gap: 16px; max-width: 720px;">
|
|
454
|
+
<FzCheckboxCard
|
|
455
|
+
v-model="selected"
|
|
456
|
+
label="plan-basic"
|
|
457
|
+
value="basic"
|
|
458
|
+
variant="vertical"
|
|
459
|
+
image-url="/images/basic-plan.jpg"
|
|
460
|
+
image-alt="Basic plan illustration"
|
|
461
|
+
title="Basic Plan"
|
|
462
|
+
subtitle="For individuals getting started"
|
|
463
|
+
tooltip="Includes 5 GB storage"
|
|
464
|
+
/>
|
|
465
|
+
|
|
466
|
+
<FzCheckboxCard
|
|
467
|
+
v-model="selected"
|
|
468
|
+
label="plan-pro"
|
|
469
|
+
value="pro"
|
|
470
|
+
variant="vertical"
|
|
471
|
+
image-url="/images/pro-plan.jpg"
|
|
472
|
+
image-alt="Pro plan illustration"
|
|
473
|
+
title="Pro Plan"
|
|
474
|
+
subtitle="For growing teams"
|
|
475
|
+
tooltip="Includes 50 GB storage"
|
|
476
|
+
/>
|
|
477
|
+
</div>
|
|
478
|
+
</template>
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
### Checkbox Card — Without Checkbox Icon
|
|
482
|
+
|
|
483
|
+
```vue
|
|
484
|
+
<script setup lang="ts">
|
|
485
|
+
import { ref } from 'vue';
|
|
486
|
+
import { FzCheckboxCard } from '@fiscozen/checkbox';
|
|
487
|
+
|
|
488
|
+
const selected = ref<(string | number)[]>([]);
|
|
489
|
+
</script>
|
|
490
|
+
|
|
491
|
+
<template>
|
|
492
|
+
<FzCheckboxCard
|
|
493
|
+
v-model="selected"
|
|
494
|
+
label="option"
|
|
495
|
+
value="option"
|
|
496
|
+
title="Selectable Card"
|
|
497
|
+
subtitle="The card border highlights on selection"
|
|
498
|
+
:has-checkbox="false"
|
|
499
|
+
/>
|
|
500
|
+
</template>
|
|
501
|
+
```
|
|
502
|
+
|
|
371
503
|
### Disabled State
|
|
372
504
|
|
|
373
505
|
```vue
|
|
@@ -458,6 +590,7 @@ This package is written in TypeScript and provides full type definitions.
|
|
|
458
590
|
import type {
|
|
459
591
|
FzCheckboxProps,
|
|
460
592
|
FzCheckboxGroupProps,
|
|
593
|
+
FzCheckboxCardProps,
|
|
461
594
|
ParentCheckbox,
|
|
462
595
|
ChildCheckbox
|
|
463
596
|
} from '@fiscozen/checkbox';
|
|
@@ -473,6 +606,15 @@ const options: ParentCheckbox[] = [
|
|
|
473
606
|
]
|
|
474
607
|
}
|
|
475
608
|
];
|
|
609
|
+
|
|
610
|
+
// Example: Typed card props (vertical variant requires imageUrl)
|
|
611
|
+
const verticalCard: FzCheckboxCardProps = {
|
|
612
|
+
label: 'card',
|
|
613
|
+
title: 'Card Title',
|
|
614
|
+
subtitle: 'Description',
|
|
615
|
+
variant: 'vertical',
|
|
616
|
+
imageUrl: '/images/card.jpg',
|
|
617
|
+
};
|
|
476
618
|
```
|
|
477
619
|
|
|
478
620
|
## Accessibility Features
|