@kenpan/zds-r8f3v1 0.2.0 → 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/_virtual/index.js +5 -3
- package/dist/_virtual/index.js.map +1 -1
- package/dist/_virtual/index2.js +3 -2
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.js +2 -2
- package/dist/_virtual/index5.js +2 -5
- package/dist/_virtual/index5.js.map +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/AppBar/AppBar.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Autocomplete/Autocomplete.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Avatar/Avatar.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Backdrop/Backdrop.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Box/Box.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Button/Button.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/ButtonBase/ButtonBase.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/ButtonBase/Ripple.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/ButtonBase/TouchRipple.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Checkbox/Checkbox.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Chip/Chip.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/CircularProgress/CircularProgress.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/ClickAwayListener/ClickAwayListener.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Collapse/Collapse.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/DefaultPropsProvider/DefaultPropsProvider.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Dialog/Dialog.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Divider/Divider.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Drawer/Drawer.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Fade/Fade.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/FilledInput/FilledInput.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/FormControl/FormControl.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/FormGroup/FormGroup.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/FormHelperText/FormHelperText.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/FormLabel/FormLabel.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/GlobalStyles/GlobalStyles.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Grow/Grow.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/IconButton/IconButton.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Input/Input.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/InputAdornment/InputAdornment.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/InputBase/InputBase.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/InputLabel/InputLabel.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/LinearProgress/LinearProgress.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/List/List.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/ListItemButton/ListItemButton.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/ListItemIcon/ListItemIcon.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/ListItemText/ListItemText.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/ListSubheader/ListSubheader.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Menu/Menu.js +2 -2
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/MenuItem/MenuItem.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/MenuList/MenuList.js +2 -2
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Modal/Modal.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/NativeSelect/NativeSelectInput.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/OutlinedInput/NotchedOutline.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/OutlinedInput/OutlinedInput.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Paper/Paper.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Popover/Popover.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Popper/BasePopper.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Popper/Popper.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Portal/Portal.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Radio/Radio.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Radio/RadioButtonIcon.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/RadioGroup/RadioGroup.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Select/Select.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Select/SelectInput.js +2 -2
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Skeleton/Skeleton.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Slide/Slide.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Slider/Slider.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Slider/SliderValueLabel.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Snackbar/Snackbar.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/SnackbarContent/SnackbarContent.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Stack/Stack.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Step/Step.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/StepConnector/StepConnector.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/StepIcon/StepIcon.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/StepLabel/StepLabel.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Stepper/Stepper.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/SvgIcon/SvgIcon.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Switch/Switch.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Tab/Tab.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/TabScrollButton/TabScrollButton.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Tabs/ScrollbarSize.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Tabs/Tabs.js +2 -2
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/TextField/TextField.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/TextareaAutosize/TextareaAutosize.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Toolbar/Toolbar.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Tooltip/Tooltip.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Typography/Typography.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/Unstable_TrapFocus/FocusTrap.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/material/esm/internal/SwitchBase.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/system/esm/DefaultPropsProvider/DefaultPropsProvider.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/system/esm/RtlProvider/index.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/system/esm/responsivePropType/responsivePropType.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/utils/esm/deepmerge/deepmerge.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/utils/esm/elementAcceptingRef/elementAcceptingRef.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/utils/esm/elementTypeAcceptingRef/elementTypeAcceptingRef.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/utils/esm/getDisplayName/getDisplayName.js +1 -1
- package/dist/packages/zenith-ui/node_modules/@mui/utils/esm/refType/refType.js +1 -1
- package/dist/packages/zenith-ui/node_modules/prop-types/index.js +1 -1
- package/dist/packages/zenith-ui/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/dist/packages/zenith-ui/node_modules/react-is/index.js +1 -1
- package/dist/packages/zenith-ui/node_modules/react-transition-group/esm/Transition.js +1 -1
- package/dist/packages/zenith-ui/node_modules/react-transition-group/esm/TransitionGroup.js +1 -1
- package/dist/packages/zenith-ui/node_modules/react-transition-group/esm/utils/PropTypes.js +1 -1
- package/guidelines/Guidelines.md +67 -0
- package/guidelines/components/button.md +127 -43
- package/guidelines/components/dialog.md +164 -87
- package/guidelines/components/forms.md +239 -77
- package/guidelines/components/table.md +221 -87
- package/guidelines/design-tokens/colors.md +181 -0
- package/guidelines/design-tokens/spacing.md +135 -0
- package/guidelines/design-tokens/typography.md +146 -0
- package/guidelines/overview-components.md +136 -0
- package/guidelines/overview-icons.md +144 -0
- package/package.json +1 -1
- package/guidelines/overview.md +0 -81
- package/guidelines/tokens.md +0 -149
|
@@ -1,119 +1,196 @@
|
|
|
1
1
|
# Dialog Component
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Purpose**: Display focused content that requires user attention or action. Use for confirmations, forms, and important messages.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Import**:
|
|
6
|
+
```tsx
|
|
7
|
+
import { Dialog, DialogHeader, DialogFooter, Button } from '@kenpan/zds-r8f3v1'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Props
|
|
11
|
+
|
|
12
|
+
### Dialog Props
|
|
13
|
+
|
|
14
|
+
| Prop | Type | Default | Description |
|
|
15
|
+
|------|------|---------|-------------|
|
|
16
|
+
| `open` | `boolean` | - | **Required**. Controls dialog visibility |
|
|
17
|
+
| `onClose` | `() => void` | - | **Required**. Called when dialog should close |
|
|
18
|
+
| `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Dialog width |
|
|
19
|
+
| `children` | `ReactNode` | - | Dialog content |
|
|
6
20
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
21
|
+
### DialogHeader Props
|
|
22
|
+
|
|
23
|
+
| Prop | Type | Default | Description |
|
|
24
|
+
|------|------|---------|-------------|
|
|
25
|
+
| `title` | `string` | - | Header title |
|
|
26
|
+
| `subtitle` | `string` | - | Optional subtitle |
|
|
27
|
+
| `onClose` | `() => void` | - | Close button handler |
|
|
28
|
+
| `icon` | `ReactNode` | - | Optional icon before title |
|
|
29
|
+
|
|
30
|
+
### DialogFooter Props
|
|
31
|
+
|
|
32
|
+
| Prop | Type | Default | Description |
|
|
33
|
+
|------|------|---------|-------------|
|
|
34
|
+
| `children` | `ReactNode` | - | Footer content (usually buttons) |
|
|
35
|
+
| `align` | `'left' \| 'right' \| 'center'` | `'right'` | Button alignment |
|
|
11
36
|
|
|
12
37
|
## Basic Usage
|
|
13
38
|
|
|
14
39
|
```tsx
|
|
15
|
-
import {
|
|
40
|
+
import { useState } from 'react'
|
|
41
|
+
import { Dialog, DialogHeader, DialogFooter, Button } from '@kenpan/zds-r8f3v1'
|
|
42
|
+
|
|
43
|
+
function MyComponent() {
|
|
44
|
+
const [open, setOpen] = useState(false)
|
|
16
45
|
|
|
17
|
-
function ConfirmDialog({ open, onClose, onConfirm }) {
|
|
18
46
|
return (
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
</
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
<>
|
|
48
|
+
<Button onClick={() => setOpen(true)}>Open Dialog</Button>
|
|
49
|
+
|
|
50
|
+
<Dialog open={open} onClose={() => setOpen(false)}>
|
|
51
|
+
<DialogHeader
|
|
52
|
+
title="Confirm Action"
|
|
53
|
+
onClose={() => setOpen(false)}
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
<Box sx={{ p: 6 }}>
|
|
57
|
+
<Typography>Are you sure you want to continue?</Typography>
|
|
58
|
+
</Box>
|
|
59
|
+
|
|
60
|
+
<DialogFooter>
|
|
61
|
+
<Button variant="secondary-gray" onClick={() => setOpen(false)}>
|
|
62
|
+
Cancel
|
|
63
|
+
</Button>
|
|
64
|
+
<Button variant="primary" onClick={() => setOpen(false)}>
|
|
65
|
+
Confirm
|
|
66
|
+
</Button>
|
|
67
|
+
</DialogFooter>
|
|
68
|
+
</Dialog>
|
|
69
|
+
</>
|
|
36
70
|
)
|
|
37
71
|
}
|
|
38
72
|
```
|
|
39
73
|
|
|
40
|
-
##
|
|
74
|
+
## Sizes
|
|
41
75
|
|
|
42
76
|
```tsx
|
|
43
|
-
|
|
44
|
-
<Dialog size="sm"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<Dialog size="
|
|
77
|
+
<Dialog open={open} onClose={onClose} size="xs"> // 400px
|
|
78
|
+
<Dialog open={open} onClose={onClose} size="sm"> // 480px
|
|
79
|
+
<Dialog open={open} onClose={onClose} size="md"> // 560px (default)
|
|
80
|
+
<Dialog open={open} onClose={onClose} size="lg"> // 640px
|
|
81
|
+
<Dialog open={open} onClose={onClose} size="xl"> // 800px
|
|
82
|
+
```
|
|
48
83
|
|
|
49
|
-
|
|
50
|
-
<Dialog size="lg">...</Dialog>
|
|
84
|
+
## With Form
|
|
51
85
|
|
|
52
|
-
|
|
53
|
-
<Dialog
|
|
86
|
+
```tsx
|
|
87
|
+
<Dialog open={open} onClose={onClose} size="lg">
|
|
88
|
+
<DialogHeader title="Create New Item" onClose={onClose} />
|
|
89
|
+
|
|
90
|
+
<Box sx={{ p: 6 }}>
|
|
91
|
+
<Stack spacing={4}>
|
|
92
|
+
<InputField label="Name" placeholder="Enter name" />
|
|
93
|
+
<InputField label="Description" placeholder="Enter description" multiline rows={3} />
|
|
94
|
+
</Stack>
|
|
95
|
+
</Box>
|
|
96
|
+
|
|
97
|
+
<DialogFooter>
|
|
98
|
+
<Button variant="secondary-gray" onClick={onClose}>Cancel</Button>
|
|
99
|
+
<Button variant="primary" onClick={handleSubmit}>Create</Button>
|
|
100
|
+
</DialogFooter>
|
|
101
|
+
</Dialog>
|
|
54
102
|
```
|
|
55
103
|
|
|
56
|
-
##
|
|
104
|
+
## Confirmation Dialog
|
|
57
105
|
|
|
58
106
|
```tsx
|
|
59
|
-
|
|
60
|
-
<DialogHeader
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
107
|
+
<Dialog open={open} onClose={onClose} size="sm">
|
|
108
|
+
<DialogHeader
|
|
109
|
+
title="Delete Item?"
|
|
110
|
+
onClose={onClose}
|
|
111
|
+
/>
|
|
112
|
+
|
|
113
|
+
<Box sx={{ p: 6 }}>
|
|
114
|
+
<Typography>
|
|
115
|
+
This action cannot be undone. The item will be permanently deleted.
|
|
116
|
+
</Typography>
|
|
117
|
+
</Box>
|
|
118
|
+
|
|
119
|
+
<DialogFooter>
|
|
120
|
+
<Button variant="secondary-gray" onClick={onClose}>Cancel</Button>
|
|
121
|
+
<Button variant="primary" destructive onClick={handleDelete}>
|
|
122
|
+
Delete
|
|
123
|
+
</Button>
|
|
124
|
+
</DialogFooter>
|
|
125
|
+
</Dialog>
|
|
75
126
|
```
|
|
76
127
|
|
|
77
|
-
##
|
|
128
|
+
## With Icon in Header
|
|
78
129
|
|
|
79
130
|
```tsx
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
131
|
+
import { AlertTriangleIcon } from '@kenpan/zds-r8f3v1/icons'
|
|
132
|
+
import { FeaturedIcon } from '@kenpan/zds-r8f3v1'
|
|
133
|
+
|
|
134
|
+
<Dialog open={open} onClose={onClose} size="sm">
|
|
135
|
+
<DialogHeader
|
|
136
|
+
title="Warning"
|
|
137
|
+
subtitle="Please review before continuing"
|
|
138
|
+
onClose={onClose}
|
|
139
|
+
icon={
|
|
140
|
+
<FeaturedIcon color="warning" size="lg" theme="light">
|
|
141
|
+
<AlertTriangleIcon />
|
|
142
|
+
</FeaturedIcon>
|
|
143
|
+
}
|
|
144
|
+
/>
|
|
145
|
+
{/* ... */}
|
|
146
|
+
</Dialog>
|
|
94
147
|
```
|
|
95
148
|
|
|
96
|
-
##
|
|
149
|
+
## Usage Guidelines
|
|
150
|
+
|
|
151
|
+
### Do:
|
|
152
|
+
- Use dialogs for focused tasks that require completion
|
|
153
|
+
- Keep dialog content focused and minimal
|
|
154
|
+
- Provide clear action buttons (Cancel/Confirm pattern)
|
|
155
|
+
- Use appropriate size for content
|
|
156
|
+
- Close dialog after action completion
|
|
157
|
+
|
|
158
|
+
### Don't:
|
|
159
|
+
- Don't nest dialogs inside other dialogs
|
|
160
|
+
- Don't use dialogs for simple notifications (use Toast instead)
|
|
161
|
+
- Don't put long forms in dialogs (use a page instead)
|
|
162
|
+
- Don't forget to handle the close action
|
|
163
|
+
- Don't use dialogs for navigation
|
|
97
164
|
|
|
165
|
+
## Common Patterns
|
|
166
|
+
|
|
167
|
+
### Alert/Warning Dialog
|
|
98
168
|
```tsx
|
|
99
|
-
|
|
100
|
-
<
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
</
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</DialogFooter>
|
|
169
|
+
<Dialog open={open} onClose={onClose} size="sm">
|
|
170
|
+
<DialogHeader title="Are you sure?" onClose={onClose} />
|
|
171
|
+
<Box sx={{ p: 6 }}>
|
|
172
|
+
<Alert color="warning">This action cannot be undone.</Alert>
|
|
173
|
+
</Box>
|
|
174
|
+
<DialogFooter>
|
|
175
|
+
<Button variant="secondary-gray" onClick={onClose}>Cancel</Button>
|
|
176
|
+
<Button variant="primary" destructive onClick={handleConfirm}>Proceed</Button>
|
|
177
|
+
</DialogFooter>
|
|
178
|
+
</Dialog>
|
|
110
179
|
```
|
|
111
180
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
181
|
+
### Info Dialog
|
|
182
|
+
```tsx
|
|
183
|
+
<Dialog open={open} onClose={onClose} size="md">
|
|
184
|
+
<DialogHeader
|
|
185
|
+
title="About This Feature"
|
|
186
|
+
subtitle="Learn how it works"
|
|
187
|
+
onClose={onClose}
|
|
188
|
+
/>
|
|
189
|
+
<Box sx={{ p: 6 }}>
|
|
190
|
+
<Typography>Detailed information here...</Typography>
|
|
191
|
+
</Box>
|
|
192
|
+
<DialogFooter>
|
|
193
|
+
<Button variant="primary" onClick={onClose}>Got it</Button>
|
|
194
|
+
</DialogFooter>
|
|
195
|
+
</Dialog>
|
|
196
|
+
```
|
|
@@ -1,151 +1,313 @@
|
|
|
1
1
|
# Form Components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Purpose**: Collect user input through various form controls.
|
|
4
|
+
|
|
5
|
+
**Import**:
|
|
6
|
+
```tsx
|
|
7
|
+
import {
|
|
8
|
+
InputField,
|
|
9
|
+
InputNumber,
|
|
10
|
+
InputSearch,
|
|
11
|
+
Checkbox,
|
|
12
|
+
Radio,
|
|
13
|
+
Switch,
|
|
14
|
+
Slider
|
|
15
|
+
} from '@kenpan/zds-r8f3v1'
|
|
16
|
+
```
|
|
4
17
|
|
|
5
18
|
## InputField
|
|
6
19
|
|
|
7
|
-
Text input with label,
|
|
20
|
+
Text input with label, hint, and validation support.
|
|
8
21
|
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
### Props
|
|
23
|
+
|
|
24
|
+
| Prop | Type | Default | Description |
|
|
25
|
+
|------|------|---------|-------------|
|
|
26
|
+
| `label` | `string` | - | Field label |
|
|
27
|
+
| `placeholder` | `string` | - | Placeholder text |
|
|
28
|
+
| `hint` | `string` | - | Helper text below input |
|
|
29
|
+
| `error` | `boolean` | `false` | Show error state |
|
|
30
|
+
| `errorMessage` | `string` | - | Error message text |
|
|
31
|
+
| `disabled` | `boolean` | `false` | Disable input |
|
|
32
|
+
| `required` | `boolean` | `false` | Mark as required |
|
|
33
|
+
| `value` | `string` | - | Controlled value |
|
|
34
|
+
| `onChange` | `(e) => void` | - | Change handler |
|
|
35
|
+
| `multiline` | `boolean` | `false` | Textarea mode |
|
|
36
|
+
| `rows` | `number` | - | Textarea rows |
|
|
11
37
|
|
|
12
|
-
|
|
38
|
+
### Examples
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
// Basic input
|
|
13
42
|
<InputField
|
|
14
43
|
label="Email"
|
|
15
|
-
placeholder="Enter your email"
|
|
16
|
-
|
|
44
|
+
placeholder="Enter your email"
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
// With hint
|
|
48
|
+
<InputField
|
|
49
|
+
label="Password"
|
|
50
|
+
type="password"
|
|
51
|
+
hint="Must be at least 8 characters"
|
|
17
52
|
/>
|
|
18
53
|
|
|
19
|
-
// With error
|
|
54
|
+
// With error
|
|
20
55
|
<InputField
|
|
21
56
|
label="Email"
|
|
22
|
-
error
|
|
23
|
-
|
|
57
|
+
error
|
|
58
|
+
errorMessage="Please enter a valid email"
|
|
24
59
|
/>
|
|
25
60
|
|
|
26
|
-
//
|
|
61
|
+
// Textarea
|
|
27
62
|
<InputField
|
|
28
|
-
label="
|
|
29
|
-
|
|
63
|
+
label="Description"
|
|
64
|
+
multiline
|
|
65
|
+
rows={4}
|
|
66
|
+
placeholder="Enter description..."
|
|
30
67
|
/>
|
|
31
68
|
|
|
32
|
-
//
|
|
69
|
+
// Controlled
|
|
70
|
+
const [value, setValue] = useState('')
|
|
33
71
|
<InputField
|
|
34
|
-
label="
|
|
35
|
-
|
|
72
|
+
label="Name"
|
|
73
|
+
value={value}
|
|
74
|
+
onChange={(e) => setValue(e.target.value)}
|
|
36
75
|
/>
|
|
37
76
|
```
|
|
38
77
|
|
|
39
|
-
##
|
|
78
|
+
## InputNumber
|
|
79
|
+
|
|
80
|
+
Numeric input with increment/decrement buttons.
|
|
81
|
+
|
|
82
|
+
### Props
|
|
83
|
+
|
|
84
|
+
| Prop | Type | Default | Description |
|
|
85
|
+
|------|------|---------|-------------|
|
|
86
|
+
| `label` | `string` | - | Field label |
|
|
87
|
+
| `value` | `number` | - | Controlled value |
|
|
88
|
+
| `onChange` | `(value: number) => void` | - | Value change handler |
|
|
89
|
+
| `min` | `number` | - | Minimum value |
|
|
90
|
+
| `max` | `number` | - | Maximum value |
|
|
91
|
+
| `step` | `number` | `1` | Increment step |
|
|
92
|
+
| `disabled` | `boolean` | `false` | Disable input |
|
|
93
|
+
|
|
94
|
+
### Example
|
|
40
95
|
|
|
41
96
|
```tsx
|
|
42
|
-
|
|
97
|
+
const [quantity, setQuantity] = useState(1)
|
|
98
|
+
|
|
99
|
+
<InputNumber
|
|
100
|
+
label="Quantity"
|
|
101
|
+
value={quantity}
|
|
102
|
+
onChange={setQuantity}
|
|
103
|
+
min={1}
|
|
104
|
+
max={100}
|
|
105
|
+
/>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## InputSearch
|
|
109
|
+
|
|
110
|
+
Search input with clear button.
|
|
111
|
+
|
|
112
|
+
### Props
|
|
113
|
+
|
|
114
|
+
| Prop | Type | Default | Description |
|
|
115
|
+
|------|------|---------|-------------|
|
|
116
|
+
| `placeholder` | `string` | `'Search...'` | Placeholder text |
|
|
117
|
+
| `value` | `string` | - | Controlled value |
|
|
118
|
+
| `onChange` | `(value: string) => void` | - | Value change handler |
|
|
119
|
+
| `onSearch` | `(value: string) => void` | - | Search submit handler |
|
|
120
|
+
| `onClear` | `() => void` | - | Clear handler |
|
|
121
|
+
|
|
122
|
+
### Example
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
const [search, setSearch] = useState('')
|
|
126
|
+
|
|
127
|
+
<InputSearch
|
|
128
|
+
placeholder="Search items..."
|
|
129
|
+
value={search}
|
|
130
|
+
onChange={setSearch}
|
|
131
|
+
onSearch={(val) => console.log('Search:', val)}
|
|
132
|
+
/>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Checkbox
|
|
136
|
+
|
|
137
|
+
Checkbox with label and optional description.
|
|
138
|
+
|
|
139
|
+
### Props
|
|
43
140
|
|
|
44
|
-
|
|
45
|
-
|
|
141
|
+
| Prop | Type | Default | Description |
|
|
142
|
+
|------|------|---------|-------------|
|
|
143
|
+
| `label` | `string` | - | Checkbox label |
|
|
144
|
+
| `description` | `string` | - | Additional description |
|
|
145
|
+
| `checked` | `boolean` | - | Controlled checked state |
|
|
146
|
+
| `onChange` | `(e) => void` | - | Change handler |
|
|
147
|
+
| `disabled` | `boolean` | `false` | Disable checkbox |
|
|
148
|
+
| `indeterminate` | `boolean` | `false` | Indeterminate state |
|
|
149
|
+
|
|
150
|
+
### Examples
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
// Basic
|
|
154
|
+
<Checkbox label="Accept terms and conditions" />
|
|
46
155
|
|
|
47
156
|
// With description
|
|
48
157
|
<Checkbox
|
|
49
|
-
label="
|
|
50
|
-
description="Receive
|
|
158
|
+
label="Email notifications"
|
|
159
|
+
description="Receive updates about your account"
|
|
51
160
|
/>
|
|
52
161
|
|
|
53
162
|
// Controlled
|
|
163
|
+
const [checked, setChecked] = useState(false)
|
|
54
164
|
<Checkbox
|
|
55
|
-
checked={isChecked}
|
|
56
|
-
onChange={(e) => setIsChecked(e.target.checked)}
|
|
57
165
|
label="Remember me"
|
|
166
|
+
checked={checked}
|
|
167
|
+
onChange={(e) => setChecked(e.target.checked)}
|
|
58
168
|
/>
|
|
59
|
-
|
|
60
|
-
// Indeterminate (for "select all" patterns)
|
|
61
|
-
<Checkbox indeterminate label="Select all items" />
|
|
62
169
|
```
|
|
63
170
|
|
|
64
171
|
## Radio
|
|
65
172
|
|
|
173
|
+
Radio button groups for mutually exclusive options.
|
|
174
|
+
|
|
175
|
+
### Props
|
|
176
|
+
|
|
177
|
+
| Prop | Type | Default | Description |
|
|
178
|
+
|------|------|---------|-------------|
|
|
179
|
+
| `label` | `string` | - | Radio label |
|
|
180
|
+
| `value` | `string` | - | Radio value |
|
|
181
|
+
| `checked` | `boolean` | - | Checked state |
|
|
182
|
+
| `onChange` | `(e) => void` | - | Change handler |
|
|
183
|
+
| `disabled` | `boolean` | `false` | Disable radio |
|
|
184
|
+
|
|
185
|
+
### Example
|
|
186
|
+
|
|
66
187
|
```tsx
|
|
67
|
-
|
|
188
|
+
const [selected, setSelected] = useState('option1')
|
|
68
189
|
|
|
69
|
-
<RadioGroup value={
|
|
70
|
-
<Radio
|
|
71
|
-
<Radio
|
|
72
|
-
<Radio
|
|
190
|
+
<RadioGroup value={selected} onChange={(e) => setSelected(e.target.value)}>
|
|
191
|
+
<Radio label="Option 1" value="option1" />
|
|
192
|
+
<Radio label="Option 2" value="option2" />
|
|
193
|
+
<Radio label="Option 3" value="option3" />
|
|
73
194
|
</RadioGroup>
|
|
74
195
|
```
|
|
75
196
|
|
|
76
197
|
## Switch
|
|
77
198
|
|
|
78
|
-
|
|
79
|
-
import { Switch } from '@kenpan/zds-r8f3v1'
|
|
199
|
+
Toggle switch for on/off states.
|
|
80
200
|
|
|
81
|
-
|
|
82
|
-
|
|
201
|
+
### Props
|
|
202
|
+
|
|
203
|
+
| Prop | Type | Default | Description |
|
|
204
|
+
|------|------|---------|-------------|
|
|
205
|
+
| `label` | `string` | - | Switch label |
|
|
206
|
+
| `checked` | `boolean` | - | Controlled checked state |
|
|
207
|
+
| `onChange` | `(e) => void` | - | Change handler |
|
|
208
|
+
| `disabled` | `boolean` | `false` | Disable switch |
|
|
209
|
+
| `size` | `'sm' \| 'md'` | `'md'` | Switch size |
|
|
83
210
|
|
|
84
|
-
|
|
85
|
-
|
|
211
|
+
### Examples
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
// Basic
|
|
215
|
+
<Switch label="Enable notifications" />
|
|
86
216
|
|
|
87
217
|
// Controlled
|
|
218
|
+
const [enabled, setEnabled] = useState(false)
|
|
88
219
|
<Switch
|
|
89
|
-
|
|
220
|
+
label="Dark mode"
|
|
221
|
+
checked={enabled}
|
|
90
222
|
onChange={(e) => setEnabled(e.target.checked)}
|
|
91
|
-
label="Active"
|
|
92
223
|
/>
|
|
93
224
|
```
|
|
94
225
|
|
|
95
226
|
## Slider
|
|
96
227
|
|
|
228
|
+
Range slider for numeric values.
|
|
229
|
+
|
|
230
|
+
### Props
|
|
231
|
+
|
|
232
|
+
| Prop | Type | Default | Description |
|
|
233
|
+
|------|------|---------|-------------|
|
|
234
|
+
| `label` | `string` | - | Slider label |
|
|
235
|
+
| `value` | `number` | - | Controlled value |
|
|
236
|
+
| `onChange` | `(value: number) => void` | - | Value change handler |
|
|
237
|
+
| `min` | `number` | `0` | Minimum value |
|
|
238
|
+
| `max` | `number` | `100` | Maximum value |
|
|
239
|
+
| `step` | `number` | `1` | Step increment |
|
|
240
|
+
| `disabled` | `boolean` | `false` | Disable slider |
|
|
241
|
+
| `showValue` | `boolean` | `true` | Show current value |
|
|
242
|
+
|
|
243
|
+
### Example
|
|
244
|
+
|
|
97
245
|
```tsx
|
|
98
|
-
|
|
246
|
+
const [volume, setVolume] = useState(50)
|
|
99
247
|
|
|
100
|
-
// Single value
|
|
101
248
|
<Slider
|
|
102
|
-
|
|
103
|
-
|
|
249
|
+
label="Volume"
|
|
250
|
+
value={volume}
|
|
251
|
+
onChange={setVolume}
|
|
104
252
|
min={0}
|
|
105
253
|
max={100}
|
|
106
254
|
/>
|
|
255
|
+
```
|
|
107
256
|
|
|
108
|
-
|
|
109
|
-
<Slider
|
|
110
|
-
value={[20, 80]}
|
|
111
|
-
onChange={(e, value) => setRange(value)}
|
|
112
|
-
mode="dual"
|
|
113
|
-
/>
|
|
257
|
+
## Form Layout Patterns
|
|
114
258
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
/>
|
|
259
|
+
### Vertical Form
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
<Stack spacing={4}>
|
|
263
|
+
<InputField label="First Name" placeholder="Enter first name" />
|
|
264
|
+
<InputField label="Last Name" placeholder="Enter last name" />
|
|
265
|
+
<InputField label="Email" type="email" placeholder="Enter email" />
|
|
266
|
+
<Button variant="primary" fullWidth>Submit</Button>
|
|
267
|
+
</Stack>
|
|
121
268
|
```
|
|
122
269
|
|
|
123
|
-
|
|
270
|
+
### Inline Form Fields
|
|
124
271
|
|
|
125
272
|
```tsx
|
|
126
|
-
|
|
273
|
+
<Stack direction="row" spacing={4}>
|
|
274
|
+
<InputField label="First Name" sx={{ flex: 1 }} />
|
|
275
|
+
<InputField label="Last Name" sx={{ flex: 1 }} />
|
|
276
|
+
</Stack>
|
|
277
|
+
```
|
|
127
278
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
279
|
+
### Form with Validation
|
|
280
|
+
|
|
281
|
+
```tsx
|
|
282
|
+
const [email, setEmail] = useState('')
|
|
283
|
+
const [error, setError] = useState(false)
|
|
284
|
+
|
|
285
|
+
const validateEmail = (value) => {
|
|
286
|
+
const isValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
|
|
287
|
+
setError(!isValid)
|
|
288
|
+
}
|
|
134
289
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
290
|
+
<InputField
|
|
291
|
+
label="Email"
|
|
292
|
+
value={email}
|
|
293
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
294
|
+
onBlur={() => validateEmail(email)}
|
|
295
|
+
error={error}
|
|
296
|
+
errorMessage="Please enter a valid email address"
|
|
141
297
|
/>
|
|
142
298
|
```
|
|
143
299
|
|
|
144
|
-
##
|
|
300
|
+
## Usage Guidelines
|
|
301
|
+
|
|
302
|
+
### Do:
|
|
303
|
+
- Always provide labels for form fields
|
|
304
|
+
- Use appropriate input types (email, password, number)
|
|
305
|
+
- Provide helpful hints for complex fields
|
|
306
|
+
- Show clear error messages
|
|
307
|
+
- Use controlled components for form state
|
|
145
308
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
6. **Progressive disclosure** - Show advanced options only when needed
|
|
309
|
+
### Don't:
|
|
310
|
+
- Don't use placeholders as labels
|
|
311
|
+
- Don't hide required field indicators
|
|
312
|
+
- Don't use generic error messages
|
|
313
|
+
- Don't nest form controls
|