@ticatec/uniface-element 0.2.3 → 0.3.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/dist/accordion/README.md +169 -0
- package/dist/accordion/README_CN.md +176 -0
- package/dist/action-bar/README.md +275 -0
- package/dist/action-bar/README_CN.md +285 -0
- package/dist/app-layout/README.md +374 -0
- package/dist/app-layout/README_CN.md +381 -0
- package/dist/app-top-bar/README.md +357 -0
- package/dist/app-top-bar/README_CN.md +365 -0
- package/dist/attachment-files/AttachmentFilesField.svelte +67 -1
- package/dist/attachment-files/AttachmentFilesField.svelte.d.ts +8 -1
- package/dist/base-calendar/CalendarBase.svelte +0 -3
- package/dist/box/README.md +385 -0
- package/dist/box/README_CN.md +393 -0
- package/dist/breadcrumbs/README.md +442 -0
- package/dist/breadcrumbs/README_CN.md +442 -0
- package/dist/button/Button.svelte +27 -7
- package/dist/button/Button.svelte.d.ts +3 -1
- package/dist/button/IconButton.svelte +26 -6
- package/dist/button/IconButton.svelte.d.ts +3 -1
- package/dist/button/IconButton_README.md +513 -0
- package/dist/button/IconButton_README_CN.md +513 -0
- package/dist/button/README.md +428 -0
- package/dist/button/README_CN.md +428 -0
- package/dist/button/TextButton.svelte +26 -6
- package/dist/button/TextButton.svelte.d.ts +3 -1
- package/dist/button/TextButton_README.md +571 -0
- package/dist/button/TextButton_README_CN.md +571 -0
- package/dist/card/README.md +666 -0
- package/dist/card/README_CN.md +666 -0
- package/dist/cascade-options-select/CascadeOptionSelect.svelte +43 -7
- package/dist/cascade-options-select/CascadeOptionSelect.svelte.d.ts +3 -4
- package/dist/cascade-options-select/README.md +663 -2
- package/dist/cascade-options-select/README_CN.md +664 -0
- package/dist/checkbox/CheckBox.svelte +20 -6
- package/dist/checkbox/CheckBox.svelte.d.ts +4 -2
- package/dist/checkbox/README.md +562 -0
- package/dist/checkbox/README_CN.md +727 -0
- package/dist/common-editor/NumberInput.svelte +39 -26
- package/dist/common-editor/NumberInput.svelte.d.ts +5 -1
- package/dist/concise-data-table/ConciseListTable.svelte +133 -36
- package/dist/concise-data-table/ConciseListTable.svelte.d.ts +8 -1
- package/dist/concise-data-table/DataCell.svelte +5 -6
- package/dist/concise-data-table/DataRow.svelte +22 -2
- package/dist/concise-data-table/DataRow.svelte.d.ts +1 -0
- package/dist/concise-data-table/README.md +606 -0
- package/dist/concise-data-table/README_CN.md +611 -0
- package/dist/context-menu/ContextMenu.svelte +138 -21
- package/dist/context-menu/ContextMenu.svelte.d.ts +5 -0
- package/dist/context-menu/ContextMenuItem.d.ts +20 -4
- package/dist/context-menu/README.md +551 -0
- package/dist/context-menu/README_CN.md +551 -0
- package/dist/criteria-field/CriteriaField.svelte +3 -5
- package/dist/criteria-field/README.md +532 -0
- package/dist/criteria-field/README_CN.md +532 -0
- package/dist/data-table/README.md +712 -0
- package/dist/data-table/README_CN.md +712 -0
- package/dist/date-picker/DatePicker.svelte +44 -7
- package/dist/date-picker/DatePicker.svelte.d.ts +3 -4
- package/dist/date-picker/DateTimePicker.svelte +32 -8
- package/dist/date-picker/DateTimePicker.svelte.d.ts +3 -4
- package/dist/date-picker/README.md +326 -0
- package/dist/date-picker/README_CN.md +316 -0
- package/dist/date-picker/ScrollBar.svelte +18 -8
- package/dist/date-picker/ScrollBar.svelte.d.ts +1 -1
- package/dist/date-picker/TimePanel.svelte +5 -5
- package/dist/date-picker/TimePanel.svelte.d.ts +1 -1
- package/dist/date-range/README.md +374 -0
- package/dist/date-range/README_CN.md +374 -0
- package/dist/dialog/DialogBoard.svelte +1 -1
- package/dist/dialog/README.md +596 -0
- package/dist/dialog/README_CN.md +596 -0
- package/dist/drawer/README.md +679 -1
- package/dist/drawer/README_CN.md +679 -0
- package/dist/group-box/group-check-box/GroupCheckBox.svelte +62 -5
- package/dist/group-box/group-check-box/GroupCheckBox.svelte.d.ts +7 -2
- package/dist/group-box/group-check-box/README.md +749 -0
- package/dist/group-box/group-check-box/README_CN.md +750 -0
- package/dist/group-box/group-radio-box/GroupRadioBox.svelte +69 -4
- package/dist/group-box/group-radio-box/GroupRadioBox.svelte.d.ts +8 -2
- package/dist/group-box/group-radio-box/README.md +920 -0
- package/dist/group-box/group-radio-box/README_CN.md +920 -0
- package/dist/image-files/README.md +1346 -0
- package/dist/image-files/README_CN.md +1346 -0
- package/dist/input-options-select/InputOptionsSelect.svelte +161 -65
- package/dist/input-options-select/InputOptionsSelect.svelte.d.ts +4 -1
- package/dist/lib/forwardAllEvents.d.ts +3 -0
- package/dist/lib/forwardAllEvents.js +24 -0
- package/dist/list-box/README.md +579 -0
- package/dist/list-box/README_CN.md +682 -0
- package/dist/lookup-editor/LookupEditor.svelte +15 -3
- package/dist/lookup-editor/LookupEditor.svelte.d.ts +3 -4
- package/dist/lookup-editor/README.md +684 -0
- package/dist/lookup-editor/README_CN.md +684 -0
- package/dist/memo-editor/MemoEditor.svelte +77 -27
- package/dist/memo-editor/MemoEditor.svelte.d.ts +6 -3
- package/dist/memo-editor/README.md +819 -0
- package/dist/memo-editor/README_CN.md +819 -0
- package/dist/message-box/README.md +398 -0
- package/dist/message-box/README_CN.md +398 -0
- package/dist/number-editor/NumberEditor.svelte +2 -2
- package/dist/number-editor/NumberEditor.svelte.d.ts +1 -1
- package/dist/number-editor/README.md +353 -22
- package/dist/number-editor/README_CN.md +357 -0
- package/dist/number-range/README.md +443 -0
- package/dist/number-range/README_CN.md +443 -0
- package/dist/options-multi-select/OptionsMultiSelect.svelte +87 -12
- package/dist/options-multi-select/OptionsMultiSelect.svelte.d.ts +3 -1
- package/dist/options-multi-select/README.md +480 -0
- package/dist/options-multi-select/README_CN.md +480 -0
- package/dist/options-select/OptionsSelect.svelte +36 -5
- package/dist/options-select/OptionsSelect.svelte.d.ts +3 -4
- package/dist/options-select/README.md +632 -0
- package/dist/options-select/README_CN.md +632 -0
- package/dist/page/README.md +605 -0
- package/dist/page/README_CN.md +605 -0
- package/dist/pagination/README.md +946 -0
- package/dist/pagination/README_CN.md +946 -0
- package/dist/pagination-panel/README.md +1075 -0
- package/dist/pagination-panel/README_CN.md +1075 -0
- package/dist/popup-hint/README.md +841 -0
- package/dist/popup-hint/README_CN.md +840 -0
- package/dist/progress-bar/README.md +242 -0
- package/dist/progress-bar/README_CN.md +242 -0
- package/dist/progress-step-bar/README.md +316 -0
- package/dist/progress-step-bar/README_CN.md +316 -0
- package/dist/prompts-text-editor/PromptsTextEditor.svelte +6 -3
- package/dist/prompts-text-editor/PromptsTextEditor.svelte.d.ts +3 -1
- package/dist/prompts-text-editor/README.md +329 -0
- package/dist/prompts-text-editor/README_CN.md +329 -0
- package/dist/property-editor/README.md +969 -0
- package/dist/property-editor/README_CN.md +969 -0
- package/dist/radio-button/README.md +372 -0
- package/dist/radio-button/README_CN.md +372 -0
- package/dist/radio-button/RadioButton.svelte +32 -3
- package/dist/radio-button/RadioButton.svelte.d.ts +12 -1
- package/dist/search-box/README.md +425 -0
- package/dist/search-box/README_CN.md +424 -0
- package/dist/search-box/SearchBox.svelte +22 -6
- package/dist/search-box/SearchBox.svelte.d.ts +4 -1
- package/dist/tabs/README.md +919 -0
- package/dist/tabs/README_CN.md +920 -0
- package/dist/tag/README.md +922 -0
- package/dist/tag/README_CN.md +922 -0
- package/dist/text-editor/PasswordEditor.svelte +17 -2
- package/dist/text-editor/PasswordEditor.svelte.d.ts +3 -3
- package/dist/text-editor/PasswordEditor_README.md +551 -0
- package/dist/text-editor/PasswordEditor_README_CN.md +551 -0
- package/dist/text-editor/README.md +466 -0
- package/dist/text-editor/README_CN.md +466 -0
- package/dist/text-editor/TextEditor.svelte +51 -19
- package/dist/text-editor/TextEditor.svelte.d.ts +0 -1
- package/dist/ticatec-uniface-web.css +1 -0
- package/dist/time-editor/README.md +498 -24
- package/dist/time-editor/README_CN.md +498 -0
- package/dist/time-editor/TimeEditor.svelte +7 -3
- package/dist/time-editor/TimeEditor.svelte.d.ts +3 -1
- package/dist/toast/README.md +667 -0
- package/dist/toast/README_CN.md +667 -0
- package/dist/transfer/README.md +795 -0
- package/dist/transfer/Transfer.svelte +6 -4
- package/dist/transfer/Transfer.svelte.d.ts +3 -1
- package/dist/tree-view/README.md +761 -0
- package/dist/tree-view/README_CN.md +761 -0
- package/dist/tree-view/TreeView.svelte +5 -3
- package/dist/tree-view/TreeView.svelte.d.ts +3 -1
- package/dist/unit-number-editor/README.md +546 -20
- package/dist/unit-number-editor/README_CN.md +525 -0
- package/dist/unit-number-editor/UnitNumberEditor.svelte +62 -8
- package/dist/unit-number-editor/UnitNumberEditor.svelte.d.ts +5 -1
- package/docs/form-field/cn/README_CN.md +364 -0
- package/docs/form-field/en/README.md +364 -0
- package/docs/form-panel/flex-form/cn/README_CN.md +586 -0
- package/docs/form-panel/flex-form/en/README.md +586 -0
- package/docs/form-panel/flex-row-form/cn/README_CN.md +787 -0
- package/docs/form-panel/flex-row-form/en/README.md +787 -0
- package/docs/form-panel/grid-form/en/README.md +744 -0
- package/package.json +1 -1
- package/dist/drawer/README-CN.md +0 -1
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
# GroupCheckBox
|
|
2
|
+
|
|
3
|
+
A flexible group checkbox component that allows users to select multiple options from a predefined list. Supports string-based and bit-based value storage, custom styling variants, and comprehensive state management with focus/blur event handling.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ticatec/uniface-element
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Import
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import GroupCheckBox from "@ticatec/uniface-element/GroupCheckBox";
|
|
15
|
+
import { DisplayMode } from "@ticatec/uniface-element";
|
|
16
|
+
import type { OnChangeHandler } from "@ticatec/uniface-element";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Basic Usage
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script>
|
|
23
|
+
import GroupCheckBox from "@ticatec/uniface-element/GroupCheckBox";
|
|
24
|
+
|
|
25
|
+
const options = [
|
|
26
|
+
{ code: "js", text: "JavaScript" },
|
|
27
|
+
{ code: "ts", text: "TypeScript" },
|
|
28
|
+
{ code: "py", text: "Python" },
|
|
29
|
+
{ code: "go", text: "Go" }
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
let selectedLanguages = "";
|
|
33
|
+
|
|
34
|
+
function handleChange(value) {
|
|
35
|
+
console.log('Selected languages:', value);
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<GroupCheckBox
|
|
40
|
+
{options}
|
|
41
|
+
bind:value={selectedLanguages}
|
|
42
|
+
onchange={handleChange}
|
|
43
|
+
/>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Props
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
|------|------|---------|-------------|
|
|
50
|
+
| `value` | `string \| number` | required | Selected values (string with delimiter or bit value) |
|
|
51
|
+
| `options` | `Array<any>` | required | Array of option objects |
|
|
52
|
+
| `keyField` | `string` | `"code"` | Field name for option keys/values |
|
|
53
|
+
| `textField` | `string` | `"text"` | Field name for option display text |
|
|
54
|
+
| `delimiter` | `string` | `";"` | Delimiter for string-based values |
|
|
55
|
+
| `bitBase` | `boolean` | `false` | Whether to use bit-based value storage |
|
|
56
|
+
| `disabled` | `boolean` | `false` | Whether the component is disabled |
|
|
57
|
+
| `readonly` | `boolean` | `false` | Whether the component is read-only |
|
|
58
|
+
| `displayMode` | `DisplayMode` | `DisplayMode.Edit` | Display mode (Edit or View) |
|
|
59
|
+
| `variant` | `"" \| "plain" \| "outlined" \| "filled"` | `""` | Visual variant |
|
|
60
|
+
| `compact` | `boolean` | `false` | Whether to use compact spacing |
|
|
61
|
+
| `disabledOptions` | `Array<string>` | `[]` | Array of option keys to disable |
|
|
62
|
+
| `hideOptions` | `Array<string>` | `[]` | Array of option keys to hide |
|
|
63
|
+
| `style` | `string` | `""` | Additional CSS styles |
|
|
64
|
+
| `item$style` | `string` | `""` | CSS styles for individual checkbox items |
|
|
65
|
+
| `onchange` | `OnChangeHandler<string \| number>` | `null` | Change event handler |
|
|
66
|
+
| `onfocus` | `(() => void) \| null` | `null` | Focus event handler |
|
|
67
|
+
| `onblur` | `(() => void) \| null` | `null` | Blur event handler |
|
|
68
|
+
|
|
69
|
+
## Methods
|
|
70
|
+
|
|
71
|
+
| Method | Description |
|
|
72
|
+
|--------|-------------|
|
|
73
|
+
| `setFocus()` | Programmatically focus the first enabled checkbox |
|
|
74
|
+
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
### Basic String-Based Selection
|
|
78
|
+
|
|
79
|
+
```svelte
|
|
80
|
+
<script>
|
|
81
|
+
import GroupCheckBox from "@ticatec/uniface-element/GroupCheckBox";
|
|
82
|
+
import FormField from "@ticatec/uniface-element/FormField";
|
|
83
|
+
|
|
84
|
+
const technologies = [
|
|
85
|
+
{ code: "react", text: "React" },
|
|
86
|
+
{ code: "vue", text: "Vue.js" },
|
|
87
|
+
{ code: "svelte", text: "Svelte" },
|
|
88
|
+
{ code: "angular", text: "Angular" }
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
let selectedTech = "";
|
|
92
|
+
|
|
93
|
+
function handleTechChange(value) {
|
|
94
|
+
console.log('Selected technologies:', value);
|
|
95
|
+
console.log('As array:', value ? value.split(';') : []);
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<div class="demo-section">
|
|
100
|
+
<FormField label="Select Your Preferred Technologies">
|
|
101
|
+
<GroupCheckBox
|
|
102
|
+
options={technologies}
|
|
103
|
+
bind:value={selectedTech}
|
|
104
|
+
onchange={handleTechChange}
|
|
105
|
+
onfocus={() => console.log('Focus gained')}
|
|
106
|
+
onblur={() => console.log('Focus lost')}
|
|
107
|
+
/>
|
|
108
|
+
</FormField>
|
|
109
|
+
|
|
110
|
+
<p>Selected: {selectedTech || 'None'}</p>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<style>
|
|
114
|
+
.demo-section {
|
|
115
|
+
margin: 20px;
|
|
116
|
+
padding: 20px;
|
|
117
|
+
border: 1px solid #e2e8f0;
|
|
118
|
+
border-radius: 8px;
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Bit-Based Selection for Performance
|
|
124
|
+
|
|
125
|
+
```svelte
|
|
126
|
+
<script>
|
|
127
|
+
import GroupCheckBox from "@ticatec/uniface-element/GroupCheckBox";
|
|
128
|
+
import FormField from "@ticatec/uniface-element/FormField";
|
|
129
|
+
|
|
130
|
+
const permissions = [
|
|
131
|
+
{ code: "read", text: "Read" }, // Bit 0 (value 1)
|
|
132
|
+
{ code: "write", text: "Write" }, // Bit 1 (value 2)
|
|
133
|
+
{ code: "delete", text: "Delete" }, // Bit 2 (value 4)
|
|
134
|
+
{ code: "admin", text: "Admin" } // Bit 3 (value 8)
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
let userPermissions = 0;
|
|
138
|
+
|
|
139
|
+
function handlePermissionChange(value) {
|
|
140
|
+
console.log('Permission bits:', value);
|
|
141
|
+
console.log('Binary representation:', value.toString(2));
|
|
142
|
+
|
|
143
|
+
// Decode permissions
|
|
144
|
+
const activePermissions = [];
|
|
145
|
+
permissions.forEach((perm, index) => {
|
|
146
|
+
if (value & (1 << index)) {
|
|
147
|
+
activePermissions.push(perm.text);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
console.log('Active permissions:', activePermissions);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Helper function to check if specific permission is enabled
|
|
154
|
+
function hasPermission(permissionBit) {
|
|
155
|
+
return (userPermissions & (1 << permissionBit)) !== 0;
|
|
156
|
+
}
|
|
157
|
+
</script>
|
|
158
|
+
|
|
159
|
+
<div class="permissions-demo">
|
|
160
|
+
<FormField label="User Permissions">
|
|
161
|
+
<GroupCheckBox
|
|
162
|
+
options={permissions}
|
|
163
|
+
bitBase={true}
|
|
164
|
+
bind:value={userPermissions}
|
|
165
|
+
onchange={handlePermissionChange}
|
|
166
|
+
/>
|
|
167
|
+
</FormField>
|
|
168
|
+
|
|
169
|
+
<div class="permission-info">
|
|
170
|
+
<p>Permission Value: {userPermissions}</p>
|
|
171
|
+
<p>Binary: {userPermissions.toString(2).padStart(4, '0')}</p>
|
|
172
|
+
<div class="permission-checks">
|
|
173
|
+
<p>Can Read: {hasPermission(0) ? '✓' : '✗'}</p>
|
|
174
|
+
<p>Can Write: {hasPermission(1) ? '✓' : '✗'}</p>
|
|
175
|
+
<p>Can Delete: {hasPermission(2) ? '✓' : '✗'}</p>
|
|
176
|
+
<p>Is Admin: {hasPermission(3) ? '✓' : '✗'}</p>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<style>
|
|
182
|
+
.permissions-demo {
|
|
183
|
+
margin: 20px;
|
|
184
|
+
padding: 20px;
|
|
185
|
+
background: #f8fafc;
|
|
186
|
+
border-radius: 8px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.permission-info {
|
|
190
|
+
margin-top: 16px;
|
|
191
|
+
padding: 12px;
|
|
192
|
+
background: white;
|
|
193
|
+
border-radius: 6px;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.permission-checks {
|
|
197
|
+
display: grid;
|
|
198
|
+
grid-template-columns: 1fr 1fr;
|
|
199
|
+
gap: 8px;
|
|
200
|
+
margin-top: 8px;
|
|
201
|
+
}
|
|
202
|
+
</style>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Different Visual Variants
|
|
206
|
+
|
|
207
|
+
```svelte
|
|
208
|
+
<script>
|
|
209
|
+
import GroupCheckBox from "@ticatec/uniface-element/GroupCheckBox";
|
|
210
|
+
import FormField from "@ticatec/uniface-element/FormField";
|
|
211
|
+
|
|
212
|
+
const colors = [
|
|
213
|
+
{ code: "red", text: "Red" },
|
|
214
|
+
{ code: "blue", text: "Blue" },
|
|
215
|
+
{ code: "green", text: "Green" },
|
|
216
|
+
{ code: "yellow", text: "Yellow" }
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
let selectedColors = "";
|
|
220
|
+
</script>
|
|
221
|
+
|
|
222
|
+
<div class="variants-demo">
|
|
223
|
+
<div class="variant-section">
|
|
224
|
+
<h3>Default Variant</h3>
|
|
225
|
+
<FormField label="Select Colors">
|
|
226
|
+
<GroupCheckBox options={colors} bind:value={selectedColors} />
|
|
227
|
+
</FormField>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<div class="variant-section">
|
|
231
|
+
<h3>Outlined Variant</h3>
|
|
232
|
+
<FormField label="Select Colors">
|
|
233
|
+
<GroupCheckBox
|
|
234
|
+
options={colors}
|
|
235
|
+
variant="outlined"
|
|
236
|
+
bind:value={selectedColors}
|
|
237
|
+
/>
|
|
238
|
+
</FormField>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<div class="variant-section">
|
|
242
|
+
<h3>Filled Variant</h3>
|
|
243
|
+
<FormField label="Select Colors">
|
|
244
|
+
<GroupCheckBox
|
|
245
|
+
options={colors}
|
|
246
|
+
variant="filled"
|
|
247
|
+
bind:value={selectedColors}
|
|
248
|
+
/>
|
|
249
|
+
</FormField>
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
<div class="variant-section">
|
|
253
|
+
<h3>Compact Variant</h3>
|
|
254
|
+
<FormField label="Select Colors">
|
|
255
|
+
<GroupCheckBox
|
|
256
|
+
options={colors}
|
|
257
|
+
compact={true}
|
|
258
|
+
bind:value={selectedColors}
|
|
259
|
+
/>
|
|
260
|
+
</FormField>
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
|
|
264
|
+
<style>
|
|
265
|
+
.variants-demo {
|
|
266
|
+
display: grid;
|
|
267
|
+
grid-template-columns: 1fr 1fr;
|
|
268
|
+
gap: 20px;
|
|
269
|
+
margin: 20px;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.variant-section {
|
|
273
|
+
padding: 16px;
|
|
274
|
+
border: 1px solid #e2e8f0;
|
|
275
|
+
border-radius: 8px;
|
|
276
|
+
}
|
|
277
|
+
</style>
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Conditional Options and Dynamic Behavior
|
|
281
|
+
|
|
282
|
+
```svelte
|
|
283
|
+
<script>
|
|
284
|
+
import GroupCheckBox from "@ticatec/uniface-element/GroupCheckBox";
|
|
285
|
+
import FormField from "@ticatec/uniface-element/FormField";
|
|
286
|
+
|
|
287
|
+
const airlines = [
|
|
288
|
+
{ code: "none", text: "None" },
|
|
289
|
+
{ code: "aa", text: "American Airlines" },
|
|
290
|
+
{ code: "ua", text: "United Airlines" },
|
|
291
|
+
{ code: "dl", text: "Delta Airlines" },
|
|
292
|
+
{ code: "sw", text: "Southwest Airlines" }
|
|
293
|
+
];
|
|
294
|
+
|
|
295
|
+
let selectedAirlines = "";
|
|
296
|
+
let disabledOptions = [];
|
|
297
|
+
let hideOptions = [];
|
|
298
|
+
|
|
299
|
+
function handleAirlineChange(value) {
|
|
300
|
+
const selected = value ? value.split(';') : [];
|
|
301
|
+
|
|
302
|
+
// If "None" is selected, disable all other options
|
|
303
|
+
if (selected.includes('none')) {
|
|
304
|
+
if (selected.length > 1) {
|
|
305
|
+
// If other options were selected with "None", keep only "None"
|
|
306
|
+
selectedAirlines = "none";
|
|
307
|
+
}
|
|
308
|
+
disabledOptions = airlines
|
|
309
|
+
.filter(airline => airline.code !== 'none')
|
|
310
|
+
.map(airline => airline.code);
|
|
311
|
+
} else {
|
|
312
|
+
disabledOptions = [];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Hide Southwest on weekends (demo logic)
|
|
316
|
+
const today = new Date();
|
|
317
|
+
if (today.getDay() === 0 || today.getDay() === 6) {
|
|
318
|
+
hideOptions = ['sw'];
|
|
319
|
+
} else {
|
|
320
|
+
hideOptions = [];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Handle special "None" selection logic
|
|
325
|
+
function handleSpecialLogic(value) {
|
|
326
|
+
const selected = value ? value.split(';') : [];
|
|
327
|
+
|
|
328
|
+
if (selected.includes('none') && selected.length > 1) {
|
|
329
|
+
// Remove "none" if other options are selected
|
|
330
|
+
const filteredSelected = selected.filter(option => option !== 'none');
|
|
331
|
+
selectedAirlines = filteredSelected.join(';');
|
|
332
|
+
} else {
|
|
333
|
+
handleAirlineChange(value);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
</script>
|
|
337
|
+
|
|
338
|
+
<div class="conditional-demo">
|
|
339
|
+
<FormField label="Select Preferred Airlines">
|
|
340
|
+
<GroupCheckBox
|
|
341
|
+
options={airlines}
|
|
342
|
+
bind:value={selectedAirlines}
|
|
343
|
+
{disabledOptions}
|
|
344
|
+
{hideOptions}
|
|
345
|
+
onchange={handleSpecialLogic}
|
|
346
|
+
/>
|
|
347
|
+
</FormField>
|
|
348
|
+
|
|
349
|
+
<div class="info-panel">
|
|
350
|
+
<p><strong>Selected:</strong> {selectedAirlines || 'None'}</p>
|
|
351
|
+
<p><strong>Disabled:</strong> {disabledOptions.join(', ') || 'None'}</p>
|
|
352
|
+
<p><strong>Hidden:</strong> {hideOptions.join(', ') || 'None'}</p>
|
|
353
|
+
<p class="hint">💡 Select "None" to disable other options</p>
|
|
354
|
+
{#if hideOptions.includes('sw')}
|
|
355
|
+
<p class="weekend-notice">🚫 Southwest Airlines is not available on weekends</p>
|
|
356
|
+
{/if}
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
|
|
360
|
+
<style>
|
|
361
|
+
.conditional-demo {
|
|
362
|
+
margin: 20px;
|
|
363
|
+
padding: 20px;
|
|
364
|
+
border: 1px solid #e2e8f0;
|
|
365
|
+
border-radius: 8px;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.info-panel {
|
|
369
|
+
margin-top: 16px;
|
|
370
|
+
padding: 12px;
|
|
371
|
+
background: #f8fafc;
|
|
372
|
+
border-radius: 6px;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.hint {
|
|
376
|
+
color: #6b7280;
|
|
377
|
+
font-style: italic;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.weekend-notice {
|
|
381
|
+
color: #dc2626;
|
|
382
|
+
font-weight: 500;
|
|
383
|
+
}
|
|
384
|
+
</style>
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Read-Only and Display Modes
|
|
388
|
+
|
|
389
|
+
```svelte
|
|
390
|
+
<script>
|
|
391
|
+
import GroupCheckBox from "@ticatec/uniface-element/GroupCheckBox";
|
|
392
|
+
import FormField from "@ticatec/uniface-element/FormField";
|
|
393
|
+
import { DisplayMode } from "@ticatec/uniface-element";
|
|
394
|
+
|
|
395
|
+
const skills = [
|
|
396
|
+
{ code: "js", text: "JavaScript" },
|
|
397
|
+
{ code: "ts", text: "TypeScript" },
|
|
398
|
+
{ code: "react", text: "React" },
|
|
399
|
+
{ code: "node", text: "Node.js" }
|
|
400
|
+
];
|
|
401
|
+
|
|
402
|
+
let userSkills = "js;react;node"; // Pre-selected skills
|
|
403
|
+
</script>
|
|
404
|
+
|
|
405
|
+
<div class="readonly-demo">
|
|
406
|
+
<div class="mode-section">
|
|
407
|
+
<h3>Editable Mode</h3>
|
|
408
|
+
<FormField label="Edit Your Skills">
|
|
409
|
+
<GroupCheckBox
|
|
410
|
+
options={skills}
|
|
411
|
+
bind:value={userSkills}
|
|
412
|
+
/>
|
|
413
|
+
</FormField>
|
|
414
|
+
</div>
|
|
415
|
+
|
|
416
|
+
<div class="mode-section">
|
|
417
|
+
<h3>Read-Only Mode</h3>
|
|
418
|
+
<FormField label="Your Skills (Read-Only)">
|
|
419
|
+
<GroupCheckBox
|
|
420
|
+
options={skills}
|
|
421
|
+
value={userSkills}
|
|
422
|
+
readonly={true}
|
|
423
|
+
/>
|
|
424
|
+
</FormField>
|
|
425
|
+
</div>
|
|
426
|
+
|
|
427
|
+
<div class="mode-section">
|
|
428
|
+
<h3>Disabled Mode</h3>
|
|
429
|
+
<FormField label="Your Skills (Disabled)">
|
|
430
|
+
<GroupCheckBox
|
|
431
|
+
options={skills}
|
|
432
|
+
value={userSkills}
|
|
433
|
+
disabled={true}
|
|
434
|
+
/>
|
|
435
|
+
</FormField>
|
|
436
|
+
</div>
|
|
437
|
+
|
|
438
|
+
<div class="mode-section">
|
|
439
|
+
<h3>Display-Only Mode</h3>
|
|
440
|
+
<FormField label="Your Skills (Display)">
|
|
441
|
+
<GroupCheckBox
|
|
442
|
+
options={skills}
|
|
443
|
+
value={userSkills}
|
|
444
|
+
displayMode={DisplayMode.View}
|
|
445
|
+
/>
|
|
446
|
+
</FormField>
|
|
447
|
+
</div>
|
|
448
|
+
</div>
|
|
449
|
+
|
|
450
|
+
<style>
|
|
451
|
+
.readonly-demo {
|
|
452
|
+
display: grid;
|
|
453
|
+
grid-template-columns: 1fr 1fr;
|
|
454
|
+
gap: 20px;
|
|
455
|
+
margin: 20px;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.mode-section {
|
|
459
|
+
padding: 16px;
|
|
460
|
+
border: 1px solid #e2e8f0;
|
|
461
|
+
border-radius: 8px;
|
|
462
|
+
}
|
|
463
|
+
</style>
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Custom Styling and Field Configuration
|
|
467
|
+
|
|
468
|
+
```svelte
|
|
469
|
+
<script>
|
|
470
|
+
import GroupCheckBox from "@ticatec/uniface-element/GroupCheckBox";
|
|
471
|
+
import FormField from "@ticatec/uniface-element/FormField";
|
|
472
|
+
|
|
473
|
+
const departments = [
|
|
474
|
+
{ id: "eng", name: "Engineering", active: true },
|
|
475
|
+
{ id: "sales", name: "Sales", active: true },
|
|
476
|
+
{ id: "marketing", name: "Marketing", active: false },
|
|
477
|
+
{ id: "hr", name: "Human Resources", active: true }
|
|
478
|
+
];
|
|
479
|
+
|
|
480
|
+
let selectedDepartments = "";
|
|
481
|
+
</script>
|
|
482
|
+
|
|
483
|
+
<div class="custom-demo">
|
|
484
|
+
<FormField label="Select Departments">
|
|
485
|
+
<GroupCheckBox
|
|
486
|
+
options={departments}
|
|
487
|
+
keyField="id"
|
|
488
|
+
textField="name"
|
|
489
|
+
delimiter=","
|
|
490
|
+
bind:value={selectedDepartments}
|
|
491
|
+
variant="outlined"
|
|
492
|
+
style="border: 2px solid #3b82f6; border-radius: 12px; padding: 16px;"
|
|
493
|
+
item$style="margin: 8px 0; padding: 4px 8px; background: #f0f9ff; border-radius: 6px;"
|
|
494
|
+
/>
|
|
495
|
+
</FormField>
|
|
496
|
+
|
|
497
|
+
<div class="result">
|
|
498
|
+
<p><strong>Selected Departments:</strong></p>
|
|
499
|
+
<p>Raw value: {selectedDepartments}</p>
|
|
500
|
+
<p>As array: {JSON.stringify(selectedDepartments ? selectedDepartments.split(',') : [])}</p>
|
|
501
|
+
</div>
|
|
502
|
+
</div>
|
|
503
|
+
|
|
504
|
+
<style>
|
|
505
|
+
.custom-demo {
|
|
506
|
+
margin: 20px;
|
|
507
|
+
padding: 20px;
|
|
508
|
+
border: 1px solid #e2e8f0;
|
|
509
|
+
border-radius: 8px;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.result {
|
|
513
|
+
margin-top: 16px;
|
|
514
|
+
padding: 12px;
|
|
515
|
+
background: #f8fafc;
|
|
516
|
+
border-radius: 6px;
|
|
517
|
+
}
|
|
518
|
+
</style>
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### Form Integration with Validation
|
|
522
|
+
|
|
523
|
+
```svelte
|
|
524
|
+
<script>
|
|
525
|
+
import GroupCheckBox from "@ticatec/uniface-element/GroupCheckBox";
|
|
526
|
+
import FormField from "@ticatec/uniface-element/FormField";
|
|
527
|
+
|
|
528
|
+
const interests = [
|
|
529
|
+
{ code: "sports", text: "Sports" },
|
|
530
|
+
{ code: "music", text: "Music" },
|
|
531
|
+
{ code: "travel", text: "Travel" },
|
|
532
|
+
{ code: "cooking", text: "Cooking" },
|
|
533
|
+
{ code: "reading", text: "Reading" },
|
|
534
|
+
{ code: "gaming", text: "Gaming" }
|
|
535
|
+
];
|
|
536
|
+
|
|
537
|
+
let formData = {
|
|
538
|
+
name: '',
|
|
539
|
+
interests: '',
|
|
540
|
+
newsletter: false
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
let errors = {};
|
|
544
|
+
let groupCheckBoxRef;
|
|
545
|
+
|
|
546
|
+
function validateForm() {
|
|
547
|
+
errors = {};
|
|
548
|
+
|
|
549
|
+
if (!formData.name.trim()) {
|
|
550
|
+
errors.name = 'Name is required';
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (!formData.interests) {
|
|
554
|
+
errors.interests = 'Please select at least one interest';
|
|
555
|
+
} else {
|
|
556
|
+
const selectedCount = formData.interests.split(';').length;
|
|
557
|
+
if (selectedCount > 3) {
|
|
558
|
+
errors.interests = 'Please select no more than 3 interests';
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
return Object.keys(errors).length === 0;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function handleSubmit() {
|
|
566
|
+
if (validateForm()) {
|
|
567
|
+
console.log('Form submitted:', formData);
|
|
568
|
+
alert('Form submitted successfully!');
|
|
569
|
+
} else {
|
|
570
|
+
console.log('Validation errors:', errors);
|
|
571
|
+
// Focus first error field
|
|
572
|
+
if (errors.interests) {
|
|
573
|
+
groupCheckBoxRef.setFocus();
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function handleInterestChange(value) {
|
|
579
|
+
formData.interests = value;
|
|
580
|
+
// Clear error when user makes a selection
|
|
581
|
+
if (errors.interests && value) {
|
|
582
|
+
delete errors.interests;
|
|
583
|
+
errors = { ...errors };
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
</script>
|
|
587
|
+
|
|
588
|
+
<div class="form-demo">
|
|
589
|
+
<form on:submit|preventDefault={handleSubmit}>
|
|
590
|
+
<FormField label="Your Name" error={errors.name}>
|
|
591
|
+
<input
|
|
592
|
+
type="text"
|
|
593
|
+
bind:value={formData.name}
|
|
594
|
+
class="form-input"
|
|
595
|
+
class:error={errors.name}
|
|
596
|
+
/>
|
|
597
|
+
</FormField>
|
|
598
|
+
|
|
599
|
+
<FormField label="Your Interests (Select 1-3)" error={errors.interests}>
|
|
600
|
+
<GroupCheckBox
|
|
601
|
+
bind:this={groupCheckBoxRef}
|
|
602
|
+
options={interests}
|
|
603
|
+
bind:value={formData.interests}
|
|
604
|
+
onchange={handleInterestChange}
|
|
605
|
+
variant="outlined"
|
|
606
|
+
/>
|
|
607
|
+
<p class="field-hint">Choose up to 3 interests that best describe you</p>
|
|
608
|
+
</FormField>
|
|
609
|
+
|
|
610
|
+
<FormField label="Newsletter">
|
|
611
|
+
<label class="checkbox-label">
|
|
612
|
+
<input type="checkbox" bind:checked={formData.newsletter} />
|
|
613
|
+
Subscribe to our newsletter
|
|
614
|
+
</label>
|
|
615
|
+
</FormField>
|
|
616
|
+
|
|
617
|
+
<div class="form-actions">
|
|
618
|
+
<button type="submit" class="submit-btn">Submit</button>
|
|
619
|
+
<button type="button" on:click={() => console.log(formData)} class="preview-btn">
|
|
620
|
+
Preview Data
|
|
621
|
+
</button>
|
|
622
|
+
</div>
|
|
623
|
+
</form>
|
|
624
|
+
</div>
|
|
625
|
+
|
|
626
|
+
<style>
|
|
627
|
+
.form-demo {
|
|
628
|
+
max-width: 500px;
|
|
629
|
+
margin: 20px;
|
|
630
|
+
padding: 24px;
|
|
631
|
+
border: 1px solid #e2e8f0;
|
|
632
|
+
border-radius: 8px;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
.form-input {
|
|
636
|
+
width: 100%;
|
|
637
|
+
padding: 8px 12px;
|
|
638
|
+
border: 1px solid #d1d5db;
|
|
639
|
+
border-radius: 6px;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.form-input.error {
|
|
643
|
+
border-color: #dc2626;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
.field-hint {
|
|
647
|
+
margin-top: 4px;
|
|
648
|
+
font-size: 0.875rem;
|
|
649
|
+
color: #6b7280;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.checkbox-label {
|
|
653
|
+
display: flex;
|
|
654
|
+
align-items: center;
|
|
655
|
+
gap: 8px;
|
|
656
|
+
cursor: pointer;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
.form-actions {
|
|
660
|
+
display: flex;
|
|
661
|
+
gap: 12px;
|
|
662
|
+
margin-top: 20px;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
.submit-btn, .preview-btn {
|
|
666
|
+
padding: 10px 20px;
|
|
667
|
+
border-radius: 6px;
|
|
668
|
+
border: none;
|
|
669
|
+
cursor: pointer;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
.submit-btn {
|
|
673
|
+
background: #3b82f6;
|
|
674
|
+
color: white;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
.preview-btn {
|
|
678
|
+
background: #f3f4f6;
|
|
679
|
+
color: #374151;
|
|
680
|
+
border: 1px solid #d1d5db;
|
|
681
|
+
}
|
|
682
|
+
</style>
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
## Value Format
|
|
686
|
+
|
|
687
|
+
### String-Based Values
|
|
688
|
+
When `bitBase` is `false` (default), selected values are stored as a delimited string:
|
|
689
|
+
- Single selection: `"option1"`
|
|
690
|
+
- Multiple selections: `"option1;option2;option3"`
|
|
691
|
+
- Empty selection: `""`
|
|
692
|
+
|
|
693
|
+
### Bit-Based Values
|
|
694
|
+
When `bitBase` is `true`, selected values are stored as a number where each bit represents an option:
|
|
695
|
+
- First option (index 0): bit 0 (value 1)
|
|
696
|
+
- Second option (index 1): bit 1 (value 2)
|
|
697
|
+
- Third option (index 2): bit 2 (value 4)
|
|
698
|
+
- Combined: first + third options = 1 + 4 = 5
|
|
699
|
+
|
|
700
|
+
## Styling
|
|
701
|
+
|
|
702
|
+
The GroupCheckBox component can be styled using CSS custom properties:
|
|
703
|
+
|
|
704
|
+
```css
|
|
705
|
+
.uniface-group-box {
|
|
706
|
+
--checkbox-spacing: 8px;
|
|
707
|
+
--checkbox-padding: 4px 8px;
|
|
708
|
+
--border-color: #e2e8f0;
|
|
709
|
+
--background-color: #ffffff;
|
|
710
|
+
--hover-background: #f9fafb;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/* Variant-specific styling */
|
|
714
|
+
.uniface-group-box.outlined {
|
|
715
|
+
border: 1px solid var(--border-color);
|
|
716
|
+
border-radius: 6px;
|
|
717
|
+
padding: 12px;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.uniface-group-box.filled {
|
|
721
|
+
background-color: #f8fafc;
|
|
722
|
+
border-radius: 6px;
|
|
723
|
+
padding: 12px;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.uniface-group-box.compact {
|
|
727
|
+
--checkbox-spacing: 4px;
|
|
728
|
+
--checkbox-padding: 2px 4px;
|
|
729
|
+
}
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
## Accessibility
|
|
733
|
+
|
|
734
|
+
The GroupCheckBox component includes several accessibility features:
|
|
735
|
+
|
|
736
|
+
- Keyboard navigation between checkboxes
|
|
737
|
+
- Focus management with `setFocus()` method
|
|
738
|
+
- ARIA labels and descriptions
|
|
739
|
+
- Screen reader announcements for state changes
|
|
740
|
+
- Proper tab order management
|
|
741
|
+
|
|
742
|
+
## Best Practices
|
|
743
|
+
|
|
744
|
+
1. **Option Management**: Keep option arrays stable to prevent unnecessary re-renders
|
|
745
|
+
2. **Performance**: Use bit-based values for large datasets or when performance is critical
|
|
746
|
+
3. **Validation**: Implement proper validation for required selections
|
|
747
|
+
4. **User Experience**: Provide clear feedback for disabled/hidden options
|
|
748
|
+
5. **Accessibility**: Always provide meaningful labels and descriptions
|
|
749
|
+
6. **State Management**: Handle focus/blur events appropriately for form validation
|