@capillarytech/blaze-ui 5.21.0 → 5.22.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/CapLanguageProvider/actions.js +125 -0
- package/CapLanguageProvider/actions.js.map +1 -0
- package/CapLanguageProvider/constants.js +37 -0
- package/CapLanguageProvider/constants.js.map +1 -0
- package/package.json +1 -1
- package/CapActionBar/README.md +0 -11
- package/CapAdvancedIcon/README.md +0 -185
- package/CapAdvancedIcon/use-cases.md +0 -44
- package/CapAlert/README.md +0 -144
- package/CapAppNotEnabled/README.md +0 -84
- package/CapAskAira/README.md +0 -328
- package/CapBanner/README.md +0 -4
- package/CapBlock/README.md +0 -175
- package/CapBorderedBox/Status.md +0 -40
- package/CapCSVFileUploader/README.md +0 -124
- package/CapCSVFileUploader/Status.md +0 -47
- package/CapCard/README.md +0 -85
- package/CapCard/Status.md +0 -41
- package/CapCardBox/README.md +0 -169
- package/CapCardBox/Status.md +0 -52
- package/CapCarousel/README.md +0 -190
- package/CapCarousel/Status.md +0 -73
- package/CapCheckbox/README.md +0 -254
- package/CapCheckbox/Status.md +0 -41
- package/CapColorPicker/README.md +0 -112
- package/CapColorPicker/Status.md +0 -52
- package/CapColorPicker/tests/USE_CASES_ANALYSIS.md +0 -92
- package/CapColoredTag/README.md +0 -167
- package/CapColoredTag/Status.md +0 -49
- package/CapConditionPreview/MIGRATION_ANALYSIS.md +0 -70
- package/CapConditionPreview/README.md +0 -40
- package/CapConditionPreview/tests/USE_CASES_CapConditionPreview.md +0 -65
- package/CapCustomCard/README.md +0 -182
- package/CapCustomCard/Status.md +0 -40
- package/CapCustomCarousel/Status.md +0 -69
- package/CapCustomCheckboxList/README.md +0 -178
- package/CapCustomCheckboxList/Status.md +0 -52
- package/CapCustomCheckboxList/tests/USE_CASES_ANALYSIS.md +0 -174
- package/CapCustomList/README.md +0 -117
- package/CapCustomList/Status.md +0 -77
- package/CapCustomList/tests/USE_CASES_ANALYSIS.md +0 -124
- package/CapCustomSelect/README.md +0 -38
- package/CapDatePicker/README.md +0 -139
- package/CapDateRangePicker/README.md +0 -159
- package/CapDateTimePicker/README.md +0 -136
- package/CapDateTimeRangePicker/README.md +0 -243
- package/CapDivider/README.md +0 -122
- package/CapDrawer/README.md +0 -207
- package/CapDrawer/Status.md +0 -52
- package/CapDrawer/tests/MISSING_USE_CASES.md +0 -170
- package/CapDropdown/README.md +0 -515
- package/CapDropdown/Status.md +0 -45
- package/CapDropdown/tests/USE_CASES_ANALYSIS.md +0 -137
- package/CapError/README.md +0 -88
- package/CapErrorBoundary/CapErrorBoundary-use-cases.md +0 -89
- package/CapErrorBoundary/README.md +0 -150
- package/CapErrorStateIllustration/README.md +0 -222
- package/CapErrorStateIllustration/USE_CASES.md +0 -33
- package/CapExpressionEditor/README.md +0 -32
- package/CapForm/README.md +0 -132
- package/CapForm/Status.md +0 -40
- package/CapForm/tests/PHASE1_UNFULFILLED_USE_CASES.md +0 -113
- package/CapForm/tests/USE_CASES_ANALYSIS.md +0 -119
- package/CapFormItem/README.md +0 -320
- package/CapFormItem/Status.md +0 -73
- package/CapFormItem/tests/USE_CASES_ANALYSIS.md +0 -84
- package/CapGraph/README.md +0 -69
- package/CapGraph/USE_CASES.md +0 -66
- package/CapHamburgerMenu/README.md +0 -234
- package/CapHamburgerMenu/USE_CASES.md +0 -48
- package/CapHeader/Status.md +0 -41
- package/CapHeading/README.md +0 -220
- package/CapHeading/Status.md +0 -41
- package/CapIcon/README.md +0 -207
- package/CapIllustration/Status.md +0 -41
- package/CapImage/README.md +0 -50
- package/CapImportMFEComponent/README.md +0 -121
- package/CapInfoNote/Status.md +0 -40
- package/CapInfoNote/tests/USE_CASES_ANALYSIS.md +0 -114
- package/CapInput/README.md +0 -196
- package/CapInput/Status.md +0 -123
- package/CapInput/tests/USE_CASES_ANALYSIS.md +0 -169
- package/CapLanguageProvider/CapLanguageProvider-use-cases.md +0 -56
- package/CapLanguageProvider/README.md +0 -206
- package/CapLevelGraphRenderer/CapLevelGraphRenderer-test-cases.md +0 -50
- package/CapLevelGraphRenderer/README.md +0 -123
- package/CapLevelGraphRenderer/Tooltip_MIGRATION_ANALYSIS.md +0 -120
- package/CapLink/README.md +0 -203
- package/CapLink/Status.md +0 -32
- package/CapLink/tests/CapLink.missingUseCases.md +0 -95
- package/CapList/README.md +0 -129
- package/CapList/Status.md +0 -69
- package/CapListLayout/README.md +0 -7
- package/CapLogin/README.md +0 -7
- package/CapMenu/README.md +0 -86
- package/CapModal/README.md +0 -357
- package/CapModal/Status.md +0 -52
- package/CapModal/tests/USE_CASES_GAPS.md +0 -207
- package/CapMultiSelect/README.md +0 -170
- package/CapMultiSelect/tests/USE_CASES_ANALYSIS.md +0 -29
- package/CapMultiSelectDatePicker/README.md +0 -11
- package/CapNavigation/README.md +0 -72
- package/CapNotification/README.md +0 -228
- package/CapNotificationDropdown/README.md +0 -5
- package/CapPopover/README.md +0 -234
- package/CapProgress/Status.md +0 -40
- package/CapRadio/Status.md +0 -54
- package/CapRadioButton/README.md +0 -152
- package/CapRadioButton/Status.md +0 -70
- package/CapRadioButton/tests/USE_CASES_ANALYSIS.md +0 -120
- package/CapRadioCard/README.md +0 -161
- package/CapRadioCard/Status.md +0 -78
- package/CapRadioGroup/README.md +0 -141
- package/CapRadioGroup/Status.md +0 -59
- package/CapReorderComponent/README.md +0 -179
- package/CapReorderComponent/Status.md +0 -41
- package/CapRoadMap/README.md +0 -126
- package/CapRoadMap/Status.md +0 -53
- package/CapRoadMap/tests/USE_CASE_GAPS.md +0 -92
- package/CapRow/README.md +0 -424
- package/CapSKUUploader/README.md +0 -189
- package/CapSKUUploader/Status.md +0 -66
- package/CapSecondaryTopBar/README.md +0 -7
- package/CapSelect/README.md +0 -243
- package/CapSelectFilter/README.md +0 -121
- package/CapShape/README.md +0 -96
- package/CapShape/Status.md +0 -36
- package/CapShape/tests/USE_CASES_ANALYSIS.md +0 -120
- package/CapSideBar/README.md +0 -298
- package/CapSideBar/Status.md +0 -5
- package/CapSlideBox/README.md +0 -68
- package/CapSlider/README.md +0 -423
- package/CapSlider/Status.md +0 -48
- package/CapSlider/tests/TEST_COVERAGE.md +0 -118
- package/CapSnackBar/README.md +0 -222
- package/CapSnackBar/Status.md +0 -41
- package/CapSomethingWentWrong/README.md +0 -97
- package/CapSplit/README.md +0 -19
- package/CapStatisticCard/README.md +0 -138
- package/CapStatus/README.md +0 -148
- package/CapStatus/Status.md +0 -40
- package/CapSteps/Status.md +0 -40
- package/CapStepsAccordian/README.md +0 -305
- package/CapStepsAccordian/Status.md +0 -48
- package/CapSupportVideosWrapper/README.md +0 -14
- package/CapSwitch/README.md +0 -351
- package/CapTab/README.md +0 -406
- package/CapTab/Status.md +0 -104
- package/CapTab/tests/USE_CASE_GAPS.md +0 -143
- package/CapTabV3/ANALYSIS.md +0 -60
- package/CapTabV3/README.md +0 -156
- package/CapTabV3/Status.md +0 -52
- package/CapTabV3/tests/USE_CASE_GAPS.md +0 -149
- package/CapTable/README.md +0 -160
- package/CapTable/Status.md +0 -41
- package/CapTag/README.md +0 -16
- package/CapTagDropdown/README.md +0 -171
- package/CapTagDropdown/Status.md +0 -55
- package/CapTimePicker/README.md +0 -170
- package/CapTooltip/README.md +0 -336
- package/CapTooltipWithInfo/Status.md +0 -75
- package/CapTopBar/README.md +0 -146
- package/CapTree/README.md +0 -124
- package/CapTree/Status.md +0 -48
- package/CapTree/tests/STATUS.md +0 -154
- package/CapTreeSelect/README.md +0 -217
- package/CapTreeSelect/Status.md +0 -52
- package/CapTruncateList/README.md +0 -13
- package/CapUnifiedSelect/README.md +0 -40
- package/CapUploader/README.md +0 -313
- package/CapUploader/Status.md +0 -76
- package/CapUploader/tests/USE_CASES_ANALYSIS.md +0 -225
- package/CapUserProfile/README.md +0 -105
- package/CapUserProfile/Status.md +0 -95
- package/CapVirtualList/README.md +0 -162
- package/CapVirtualList/Status.md +0 -71
- package/assets/HOCs/ComponentWithLabelHOC/README.md +0 -230
package/CapSwitch/README.md
DELETED
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
# CapSwitch
|
|
2
|
-
|
|
3
|
-
Switch component for toggling between two states. Built on Ant Design v6 with Cap UI styling.
|
|
4
|
-
|
|
5
|
-
## Summary of Changes from cap-ui-library
|
|
6
|
-
|
|
7
|
-
The `CapSwitch` component has been migrated from `cap-ui-library` to `blaze-ui` with the following updates:
|
|
8
|
-
|
|
9
|
-
- **TypeScript**: Full TypeScript implementation with proper type definitions
|
|
10
|
-
- **Ant Design v6**: Updated to use Ant Design v6 APIs
|
|
11
|
-
- **Functional Component**: Converted from class component to functional component with `forwardRef` support
|
|
12
|
-
- **SCSS Modules**: Converted from regular SCSS to SCSS modules
|
|
13
|
-
- **Removed HOC**: Removed `ComponentWithLabelHOC` wrapper (use `CapLabel` component separately if needed)
|
|
14
|
-
- **No Breaking Changes**: Fully backward compatible with `cap-ui-library` v8.x
|
|
15
|
-
|
|
16
|
-
## Props
|
|
17
|
-
|
|
18
|
-
The component accepts all Ant Design v6 `Switch` props. Key props include:
|
|
19
|
-
|
|
20
|
-
| Prop | Type | Default | Description |
|
|
21
|
-
|------|------|---------|-------------|
|
|
22
|
-
| `checked` | `boolean` | `false` | Whether the switch is checked (controlled mode) |
|
|
23
|
-
| `defaultChecked` | `boolean` | `false` | Default checked state (uncontrolled mode) |
|
|
24
|
-
| `disabled` | `boolean` | `false` | Whether the switch is disabled |
|
|
25
|
-
| `size` | `'small' \| 'default'` | `'default'` | The size of the switch |
|
|
26
|
-
| `loading` | `boolean` | `false` | Loading state of switch |
|
|
27
|
-
| `autoFocus` | `boolean` | `false` | Get focus when component mounted |
|
|
28
|
-
| `checkedChildren` | `React.ReactNode` | - | Content to be shown when the state is checked |
|
|
29
|
-
| `unCheckedChildren` | `React.ReactNode` | - | Content to be shown when the state is unchecked |
|
|
30
|
-
| `onChange` | `(checked: boolean, event: React.MouseEvent \| React.KeyboardEvent) => void` | - | Callback function when switch state changes |
|
|
31
|
-
| `onClick` | `(checked: boolean, event: React.MouseEvent) => void` | - | Callback function when switch is clicked |
|
|
32
|
-
| `className` | `string` | - | Additional CSS class name |
|
|
33
|
-
|
|
34
|
-
**Note**: The component accepts all other Ant Design v6 `Switch` props. See [Ant Design Switch documentation](https://ant.design/components/switch) for complete prop list.
|
|
35
|
-
|
|
36
|
-
## API Changes
|
|
37
|
-
|
|
38
|
-
### Removed Props
|
|
39
|
-
|
|
40
|
-
- **`children`**: Removed support for children prop. The original component wrapped children through `ComponentWithLabelHOC`, but this has been removed. Use `CapLabel` component separately if you need label functionality.
|
|
41
|
-
|
|
42
|
-
### Controlled vs Uncontrolled Mode
|
|
43
|
-
|
|
44
|
-
The component supports both controlled and uncontrolled modes:
|
|
45
|
-
|
|
46
|
-
**Controlled Mode:**
|
|
47
|
-
```tsx
|
|
48
|
-
const [checked, setChecked] = useState(false);
|
|
49
|
-
|
|
50
|
-
<CapSwitch
|
|
51
|
-
checked={checked}
|
|
52
|
-
onChange={(newChecked) => setChecked(newChecked)}
|
|
53
|
-
/>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**Uncontrolled Mode:**
|
|
57
|
-
```tsx
|
|
58
|
-
<CapSwitch
|
|
59
|
-
defaultChecked={false}
|
|
60
|
-
onChange={(checked) => console.log('Changed:', checked)}
|
|
61
|
-
/>
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Behavioral Changes
|
|
65
|
-
|
|
66
|
-
### No Breaking Changes
|
|
67
|
-
|
|
68
|
-
The component maintains **100% backward compatibility** with `cap-ui-library` v8.x for all standard Switch props. All existing code will continue to work without modifications.
|
|
69
|
-
|
|
70
|
-
### Removed Features
|
|
71
|
-
|
|
72
|
-
- **ComponentWithLabelHOC**: The original component was wrapped with `ComponentWithLabelHOC` which provided label functionality. This wrapper has been removed. If you need label functionality, use `CapLabel` component separately:
|
|
73
|
-
|
|
74
|
-
**Before (cap-ui-library):**
|
|
75
|
-
```tsx
|
|
76
|
-
<CapSwitch checked={true}>
|
|
77
|
-
<span>Enable Feature</span>
|
|
78
|
-
</CapSwitch>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**After (blaze-ui):**
|
|
82
|
-
```tsx
|
|
83
|
-
<CapRow align="middle" gap={12}>
|
|
84
|
-
<CapColumn>
|
|
85
|
-
<CapSwitch checked={true} />
|
|
86
|
-
</CapColumn>
|
|
87
|
-
<CapColumn>
|
|
88
|
-
<CapLabel>Enable Feature</CapLabel>
|
|
89
|
-
</CapColumn>
|
|
90
|
-
</CapRow>
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Enhanced Features
|
|
94
|
-
|
|
95
|
-
- **Ref Forwarding**: The component now supports ref forwarding using `React.forwardRef`
|
|
96
|
-
- **TypeScript Support**: Full TypeScript type definitions for better developer experience
|
|
97
|
-
- **Improved Styling**: Enhanced SCSS modules with better size consistency and visual alignment
|
|
98
|
-
|
|
99
|
-
## Migration Steps for Consumers
|
|
100
|
-
|
|
101
|
-
### Step 1: Update Imports
|
|
102
|
-
|
|
103
|
-
**Before:**
|
|
104
|
-
```tsx
|
|
105
|
-
import { CapSwitch } from '@capillarytech/cap-ui-library';
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
**After:**
|
|
109
|
-
```tsx
|
|
110
|
-
import { CapSwitch } from '@capillarytech/blaze-ui';
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Step 2: Update Label Usage (If Applicable)
|
|
114
|
-
|
|
115
|
-
If you were using the `children` prop for labels, update to use `CapLabel` separately:
|
|
116
|
-
|
|
117
|
-
**Before:**
|
|
118
|
-
```tsx
|
|
119
|
-
<CapSwitch checked={isEnabled}>
|
|
120
|
-
<span>Enable Notifications</span>
|
|
121
|
-
</CapSwitch>
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**After:**
|
|
125
|
-
```tsx
|
|
126
|
-
import { CapSwitch, CapLabel, CapRow, CapColumn } from '@capillarytech/blaze-ui';
|
|
127
|
-
|
|
128
|
-
<CapRow align="middle" gap={12}>
|
|
129
|
-
<CapColumn>
|
|
130
|
-
<CapSwitch checked={isEnabled} />
|
|
131
|
-
</CapColumn>
|
|
132
|
-
<CapColumn>
|
|
133
|
-
<CapLabel>Enable Notifications</CapLabel>
|
|
134
|
-
</CapColumn>
|
|
135
|
-
</CapRow>
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Step 3: No Other Changes Required
|
|
139
|
-
|
|
140
|
-
All other props and usage patterns remain the same. The component is fully backward compatible.
|
|
141
|
-
|
|
142
|
-
## Code Examples
|
|
143
|
-
|
|
144
|
-
### Basic Usage
|
|
145
|
-
|
|
146
|
-
```tsx
|
|
147
|
-
import { CapSwitch } from '@capillarytech/blaze-ui';
|
|
148
|
-
|
|
149
|
-
function MyComponent() {
|
|
150
|
-
const [enabled, setEnabled] = useState(false);
|
|
151
|
-
|
|
152
|
-
return (
|
|
153
|
-
<CapSwitch
|
|
154
|
-
checked={enabled}
|
|
155
|
-
onChange={setEnabled}
|
|
156
|
-
/>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### Uncontrolled Mode
|
|
162
|
-
|
|
163
|
-
```tsx
|
|
164
|
-
<CapSwitch
|
|
165
|
-
defaultChecked={false}
|
|
166
|
-
onChange={(checked) => {
|
|
167
|
-
console.log('Switch toggled:', checked);
|
|
168
|
-
}}
|
|
169
|
-
/>
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### With Text Content
|
|
173
|
-
|
|
174
|
-
```tsx
|
|
175
|
-
<CapSwitch
|
|
176
|
-
checked={true}
|
|
177
|
-
checkedChildren="ON"
|
|
178
|
-
unCheckedChildren="OFF"
|
|
179
|
-
/>
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### With Custom Content
|
|
183
|
-
|
|
184
|
-
```tsx
|
|
185
|
-
<CapSwitch
|
|
186
|
-
checked={true}
|
|
187
|
-
checkedChildren={<span style={{ color: 'green' }}>✓</span>}
|
|
188
|
-
unCheckedChildren={<span style={{ color: 'red' }}>✗</span>}
|
|
189
|
-
/>
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Disabled State
|
|
193
|
-
|
|
194
|
-
```tsx
|
|
195
|
-
<CapSwitch
|
|
196
|
-
checked={true}
|
|
197
|
-
disabled
|
|
198
|
-
/>
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Loading State
|
|
202
|
-
|
|
203
|
-
```tsx
|
|
204
|
-
<CapSwitch
|
|
205
|
-
checked={true}
|
|
206
|
-
loading
|
|
207
|
-
/>
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Different Sizes
|
|
211
|
-
|
|
212
|
-
```tsx
|
|
213
|
-
<CapSwitch size="default" checked={true} />
|
|
214
|
-
<CapSwitch size="small" checked={true} />
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### With Label (Using CapLabel)
|
|
218
|
-
|
|
219
|
-
```tsx
|
|
220
|
-
import { CapSwitch, CapLabel, CapRow, CapColumn } from '@capillarytech/blaze-ui';
|
|
221
|
-
|
|
222
|
-
<CapRow align="middle" gap={12}>
|
|
223
|
-
<CapColumn>
|
|
224
|
-
<CapSwitch checked={notificationsEnabled} />
|
|
225
|
-
</CapColumn>
|
|
226
|
-
<CapColumn>
|
|
227
|
-
<CapLabel>Email Notifications</CapLabel>
|
|
228
|
-
</CapColumn>
|
|
229
|
-
</CapRow>
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Settings Panel Example
|
|
233
|
-
|
|
234
|
-
```tsx
|
|
235
|
-
import { useState } from 'react';
|
|
236
|
-
import { CapSwitch, CapRow, CapColumn } from '@capillarytech/blaze-ui';
|
|
237
|
-
|
|
238
|
-
function SettingsPanel() {
|
|
239
|
-
const [settings, setSettings] = useState({
|
|
240
|
-
notifications: true,
|
|
241
|
-
darkMode: false,
|
|
242
|
-
autoSave: true,
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
const handleChange = (key: string) => (checked: boolean) => {
|
|
246
|
-
setSettings(prev => ({ ...prev, [key]: checked }));
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
return (
|
|
250
|
-
<CapRow gap={16} vertical>
|
|
251
|
-
<CapColumn>
|
|
252
|
-
<CapRow justify="space-between" align="middle">
|
|
253
|
-
<CapColumn>Email Notifications</CapColumn>
|
|
254
|
-
<CapColumn>
|
|
255
|
-
<CapSwitch
|
|
256
|
-
checked={settings.notifications}
|
|
257
|
-
onChange={handleChange('notifications')}
|
|
258
|
-
/>
|
|
259
|
-
</CapColumn>
|
|
260
|
-
</CapRow>
|
|
261
|
-
</CapColumn>
|
|
262
|
-
<CapColumn>
|
|
263
|
-
<CapRow justify="space-between" align="middle">
|
|
264
|
-
<CapColumn>Dark Mode</CapColumn>
|
|
265
|
-
<CapColumn>
|
|
266
|
-
<CapSwitch
|
|
267
|
-
checked={settings.darkMode}
|
|
268
|
-
onChange={handleChange('darkMode')}
|
|
269
|
-
/>
|
|
270
|
-
</CapColumn>
|
|
271
|
-
</CapRow>
|
|
272
|
-
</CapColumn>
|
|
273
|
-
<CapColumn>
|
|
274
|
-
<CapRow justify="space-between" align="middle">
|
|
275
|
-
<CapColumn>Auto Save</CapColumn>
|
|
276
|
-
<CapColumn>
|
|
277
|
-
<CapSwitch
|
|
278
|
-
checked={settings.autoSave}
|
|
279
|
-
onChange={handleChange('autoSave')}
|
|
280
|
-
/>
|
|
281
|
-
</CapColumn>
|
|
282
|
-
</CapRow>
|
|
283
|
-
</CapColumn>
|
|
284
|
-
</CapRow>
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### With Ref Forwarding
|
|
290
|
-
|
|
291
|
-
```tsx
|
|
292
|
-
import { useRef } from 'react';
|
|
293
|
-
|
|
294
|
-
function MyComponent() {
|
|
295
|
-
const switchRef = useRef<HTMLButtonElement>(null);
|
|
296
|
-
|
|
297
|
-
const handleFocus = () => {
|
|
298
|
-
switchRef.current?.focus();
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
return (
|
|
302
|
-
<div>
|
|
303
|
-
<CapSwitch ref={switchRef} />
|
|
304
|
-
<button onClick={handleFocus}>Focus Switch</button>
|
|
305
|
-
</div>
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
## Import Examples
|
|
311
|
-
|
|
312
|
-
### Default Import
|
|
313
|
-
|
|
314
|
-
```tsx
|
|
315
|
-
import CapSwitch from '@capillarytech/blaze-ui/components/CapSwitch';
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### Named Import
|
|
319
|
-
|
|
320
|
-
```tsx
|
|
321
|
-
import { CapSwitch } from '@capillarytech/blaze-ui';
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
### With TypeScript Types
|
|
325
|
-
|
|
326
|
-
```tsx
|
|
327
|
-
import { CapSwitch } from '@capillarytech/blaze-ui';
|
|
328
|
-
import type { CapSwitchProps } from '@capillarytech/blaze-ui';
|
|
329
|
-
|
|
330
|
-
const props: CapSwitchProps = {
|
|
331
|
-
checked: true,
|
|
332
|
-
disabled: false,
|
|
333
|
-
size: 'default',
|
|
334
|
-
};
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
## Notes
|
|
338
|
-
|
|
339
|
-
- **No Breaking Changes**: The component is fully backward compatible with `cap-ui-library` v8.x for all standard Switch props
|
|
340
|
-
- **Label Support**: If you need label functionality, use `CapLabel` component separately with `CapRow`/`CapColumn` for layout
|
|
341
|
-
- **Ref Forwarding**: The component supports ref forwarding to the underlying Switch element
|
|
342
|
-
- **Controlled/Uncontrolled**: Supports both controlled (`checked` prop) and uncontrolled (`defaultChecked` prop) modes
|
|
343
|
-
- **Styling**: Uses SCSS modules with consistent sizing and visual alignment
|
|
344
|
-
|
|
345
|
-
## Related Components
|
|
346
|
-
|
|
347
|
-
- `CapLabel` - Label component for use with switches
|
|
348
|
-
- `CapRow` / `CapColumn` - Layout components for arranging switches with labels
|
|
349
|
-
- `CapCheckbox` - Checkbox component for similar use cases
|
|
350
|
-
- `CapRadio` - Radio button component for selection
|
|
351
|
-
|