torch-glare 2.5.5 → 2.6.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 +4 -3
- package/dist/bin/index.js +9 -24
- package/dist/bin/index.js.map +1 -1
- package/dist/src/commands/add.d.ts +2 -2
- package/dist/src/commands/add.d.ts.map +1 -1
- package/dist/src/commands/add.js +4 -70
- package/dist/src/commands/add.js.map +1 -1
- package/dist/src/commands/hook.d.ts +5 -4
- package/dist/src/commands/hook.d.ts.map +1 -1
- package/dist/src/commands/hook.js +7 -75
- package/dist/src/commands/hook.js.map +1 -1
- package/dist/src/commands/init.js +1 -1
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/layout.d.ts +5 -4
- package/dist/src/commands/layout.d.ts.map +1 -1
- package/dist/src/commands/layout.js +7 -75
- package/dist/src/commands/layout.js.map +1 -1
- package/dist/src/commands/provider.d.ts +5 -4
- package/dist/src/commands/provider.d.ts.map +1 -1
- package/dist/src/commands/provider.js +7 -75
- package/dist/src/commands/provider.js.map +1 -1
- package/dist/src/commands/update.d.ts.map +1 -1
- package/dist/src/commands/update.js +78 -43
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/utils.d.ts +5 -4
- package/dist/src/commands/utils.d.ts.map +1 -1
- package/dist/src/commands/utils.js +7 -80
- package/dist/src/commands/utils.js.map +1 -1
- package/dist/src/shared/addFromRegistry.d.ts +16 -0
- package/dist/src/shared/addFromRegistry.d.ts.map +1 -0
- package/dist/src/shared/addFromRegistry.js +88 -0
- package/dist/src/shared/addFromRegistry.js.map +1 -0
- package/dist/src/shared/getInstallCommand.d.ts.map +1 -1
- package/dist/src/shared/getInstallCommand.js +5 -0
- package/dist/src/shared/getInstallCommand.js.map +1 -1
- package/dist/src/shared/installDependencies.d.ts +0 -10
- package/dist/src/shared/installDependencies.d.ts.map +1 -1
- package/dist/src/shared/installDependencies.js +0 -17
- package/dist/src/shared/installDependencies.js.map +1 -1
- package/dist/src/shared/installFromPlan.d.ts +7 -5
- package/dist/src/shared/installFromPlan.d.ts.map +1 -1
- package/dist/src/shared/installFromPlan.js +103 -36
- package/dist/src/shared/installFromPlan.js.map +1 -1
- package/dist/src/shared/loadRegistry.d.ts +12 -3
- package/dist/src/shared/loadRegistry.d.ts.map +1 -1
- package/dist/src/shared/loadRegistry.js +19 -20
- package/dist/src/shared/loadRegistry.js.map +1 -1
- package/dist/src/shared/registryClient.d.ts +19 -0
- package/dist/src/shared/registryClient.d.ts.map +1 -0
- package/dist/src/shared/registryClient.js +128 -0
- package/dist/src/shared/registryClient.js.map +1 -0
- package/dist/src/shared/resolveEntry.d.ts +10 -7
- package/dist/src/shared/resolveEntry.d.ts.map +1 -1
- package/dist/src/shared/resolveEntry.js +18 -13
- package/dist/src/shared/resolveEntry.js.map +1 -1
- package/dist/src/shared/suggestOtherCommand.d.ts +7 -1
- package/dist/src/shared/suggestOtherCommand.d.ts.map +1 -1
- package/dist/src/shared/suggestOtherCommand.js +29 -23
- package/dist/src/shared/suggestOtherCommand.js.map +1 -1
- package/dist/src/types/main.d.ts +31 -2
- package/dist/src/types/main.d.ts.map +1 -1
- package/package.json +6 -11
- package/apps/lib/components/ActionButton.tsx +0 -93
- package/apps/lib/components/ActionsGroup.tsx +0 -27
- package/apps/lib/components/AlertDialog.tsx +0 -204
- package/apps/lib/components/Avatar.tsx +0 -46
- package/apps/lib/components/Badge.tsx +0 -250
- package/apps/lib/components/BadgeField.tsx +0 -338
- package/apps/lib/components/Breadcrumb.tsx +0 -280
- package/apps/lib/components/Button.tsx +0 -317
- package/apps/lib/components/ButtonGroup.tsx +0 -190
- package/apps/lib/components/Calendar.tsx +0 -115
- package/apps/lib/components/Card.tsx +0 -95
- package/apps/lib/components/Checkbox.tsx +0 -42
- package/apps/lib/components/ColorPicker.tsx +0 -441
- package/apps/lib/components/ConclusionHeader.tsx +0 -148
- package/apps/lib/components/ContextMenu.tsx +0 -571
- package/apps/lib/components/CountBadge.tsx +0 -52
- package/apps/lib/components/DataTable.tsx +0 -213
- package/apps/lib/components/DataViews/badge.ts +0 -49
- package/apps/lib/components/DataViews/cell.tsx +0 -324
- package/apps/lib/components/DataViews/context.ts +0 -144
- package/apps/lib/components/DataViews/data-views.tsx +0 -383
- package/apps/lib/components/DataViews/filters/children.tsx +0 -98
- package/apps/lib/components/DataViews/filters/custom.tsx +0 -34
- package/apps/lib/components/DataViews/filters/filters.tsx +0 -157
- package/apps/lib/components/DataViews/filters/index.ts +0 -4
- package/apps/lib/components/DataViews/filters/labelled.tsx +0 -20
- package/apps/lib/components/DataViews/filters/presets.tsx +0 -65
- package/apps/lib/components/DataViews/filters/sync.tsx +0 -35
- package/apps/lib/components/DataViews/filters/values.ts +0 -173
- package/apps/lib/components/DataViews/header.tsx +0 -220
- package/apps/lib/components/DataViews/hooks/index.ts +0 -5
- package/apps/lib/components/DataViews/hooks/useActiveRow.ts +0 -22
- package/apps/lib/components/DataViews/hooks/useControllable.ts +0 -52
- package/apps/lib/components/DataViews/index.ts +0 -84
- package/apps/lib/components/DataViews/panel/columns.tsx +0 -153
- package/apps/lib/components/DataViews/panel/controls.tsx +0 -106
- package/apps/lib/components/DataViews/panel/index.ts +0 -3
- package/apps/lib/components/DataViews/panel/panel.tsx +0 -164
- package/apps/lib/components/DataViews/panel/saved-views.tsx +0 -67
- package/apps/lib/components/DataViews/panel/section.tsx +0 -81
- package/apps/lib/components/DataViews/panel/sort.tsx +0 -42
- package/apps/lib/components/DataViews/panel/tab.tsx +0 -31
- package/apps/lib/components/DataViews/slots.ts +0 -63
- package/apps/lib/components/DataViews/states.tsx +0 -38
- package/apps/lib/components/DataViews/types.ts +0 -510
- package/apps/lib/components/DataViews/views/board-view.tsx +0 -381
- package/apps/lib/components/DataViews/views/card-rows.tsx +0 -36
- package/apps/lib/components/DataViews/views/inbox-view.tsx +0 -260
- package/apps/lib/components/DataViews/views/pane-views.tsx +0 -196
- package/apps/lib/components/DataViews/views/table-view.tsx +0 -493
- package/apps/lib/components/DataViews/views/tree-view.tsx +0 -367
- package/apps/lib/components/DatePicker.tsx +0 -232
- package/apps/lib/components/Dialog.tsx +0 -116
- package/apps/lib/components/Divider.tsx +0 -28
- package/apps/lib/components/Drawer.tsx +0 -420
- package/apps/lib/components/DropdownMenu.tsx +0 -540
- package/apps/lib/components/FieldHint.tsx +0 -69
- package/apps/lib/components/Form.tsx +0 -182
- package/apps/lib/components/FormBuilder/context.ts +0 -73
- package/apps/lib/components/FormBuilder/field-kind.ts +0 -28
- package/apps/lib/components/FormBuilder/fields/ChoiceFields.tsx +0 -60
- package/apps/lib/components/FormBuilder/fields/ColorField.tsx +0 -59
- package/apps/lib/components/FormBuilder/fields/CustomField.tsx +0 -11
- package/apps/lib/components/FormBuilder/fields/DateField.tsx +0 -32
- package/apps/lib/components/FormBuilder/fields/FieldArray.tsx +0 -74
- package/apps/lib/components/FormBuilder/fields/FieldShell.tsx +0 -163
- package/apps/lib/components/FormBuilder/fields/FileField.tsx +0 -39
- package/apps/lib/components/FormBuilder/fields/OptionListFields.tsx +0 -132
- package/apps/lib/components/FormBuilder/fields/OtpField.tsx +0 -31
- package/apps/lib/components/FormBuilder/fields/PhoneField.tsx +0 -109
- package/apps/lib/components/FormBuilder/fields/RichTextEditorField.tsx +0 -31
- package/apps/lib/components/FormBuilder/fields/SelectField.tsx +0 -91
- package/apps/lib/components/FormBuilder/fields/SignatureField.tsx +0 -157
- package/apps/lib/components/FormBuilder/fields/SliderField.tsx +0 -67
- package/apps/lib/components/FormBuilder/fields/SwitchBoxField.tsx +0 -41
- package/apps/lib/components/FormBuilder/fields/TableField.tsx +0 -336
- package/apps/lib/components/FormBuilder/fields/TextField.tsx +0 -213
- package/apps/lib/components/FormBuilder/fields/TreeSelectField.tsx +0 -43
- package/apps/lib/components/FormBuilder/fields/countries.ts +0 -303
- package/apps/lib/components/FormBuilder/fields/index.ts +0 -25
- package/apps/lib/components/FormBuilder/form-builder.tsx +0 -198
- package/apps/lib/components/FormBuilder/index.ts +0 -31
- package/apps/lib/components/FormBuilder/numberFormat.ts +0 -16
- package/apps/lib/components/FormBuilder/submit.tsx +0 -47
- package/apps/lib/components/FormBuilder/types.ts +0 -311
- package/apps/lib/components/FormRenderer/FormDrawer.tsx +0 -128
- package/apps/lib/components/FormRenderer/detail.tsx +0 -207
- package/apps/lib/components/FormRenderer/form-renderer.tsx +0 -297
- package/apps/lib/components/FormRenderer/header.tsx +0 -88
- package/apps/lib/components/FormRenderer/index.ts +0 -15
- package/apps/lib/components/FormRenderer/section.tsx +0 -39
- package/apps/lib/components/FormRenderer/stepper.tsx +0 -339
- package/apps/lib/components/FormRenderer/types.ts +0 -78
- package/apps/lib/components/FormSummary.tsx +0 -282
- package/apps/lib/components/HeaderBar.tsx +0 -117
- package/apps/lib/components/ImageAttachment.tsx +0 -209
- package/apps/lib/components/InnerLabelField.tsx +0 -154
- package/apps/lib/components/Input.tsx +0 -224
- package/apps/lib/components/InputField.tsx +0 -147
- package/apps/lib/components/InputOTP.tsx +0 -84
- package/apps/lib/components/Label.tsx +0 -129
- package/apps/lib/components/LabelField.tsx +0 -76
- package/apps/lib/components/LabeledCheckBox.tsx +0 -51
- package/apps/lib/components/LabeledRadio.tsx +0 -51
- package/apps/lib/components/LinkButton.tsx +0 -94
- package/apps/lib/components/LoginButton.tsx +0 -51
- package/apps/lib/components/PasswordLevel.tsx +0 -58
- package/apps/lib/components/Popover.tsx +0 -312
- package/apps/lib/components/ProfileMenu.tsx +0 -85
- package/apps/lib/components/Radio.tsx +0 -59
- package/apps/lib/components/RadioCard.tsx +0 -50
- package/apps/lib/components/ScrollArea.tsx +0 -54
- package/apps/lib/components/SearchField.tsx +0 -62
- package/apps/lib/components/SearchableSelect.tsx +0 -318
- package/apps/lib/components/SearchableTable.tsx +0 -344
- package/apps/lib/components/SearchableTree.tsx +0 -485
- package/apps/lib/components/SearchableTreeDialog.tsx +0 -502
- package/apps/lib/components/SectionBlock.tsx +0 -147
- package/apps/lib/components/Select.tsx +0 -347
- package/apps/lib/components/SimpleSelect.tsx +0 -225
- package/apps/lib/components/Skeleton.tsx +0 -12
- package/apps/lib/components/SlideDatePicker.tsx +0 -253
- package/apps/lib/components/SpinLoading.tsx +0 -174
- package/apps/lib/components/Stepper.tsx +0 -480
- package/apps/lib/components/Switch.tsx +0 -82
- package/apps/lib/components/TabFormItem.tsx +0 -153
- package/apps/lib/components/TabSwitch.tsx +0 -172
- package/apps/lib/components/Table.tsx +0 -610
- package/apps/lib/components/TextEditor/ChartBlockTool.ts +0 -676
- package/apps/lib/components/TextEditor/RichTextField.tsx +0 -46
- package/apps/lib/components/TextEditor/TableDnDWrapper.ts +0 -462
- package/apps/lib/components/TextEditor/TextEditor.tsx +0 -1164
- package/apps/lib/components/TextEditor/TextEditorToolbar.tsx +0 -429
- package/apps/lib/components/TextEditor/editor-tools/AlignmentTune.ts +0 -70
- package/apps/lib/components/TextEditor/editor-tools/ColorInlineTool.ts +0 -50
- package/apps/lib/components/TextEditor/editor-tools/StrikethroughInlineTool.ts +0 -48
- package/apps/lib/components/TextEditor/editor-tools/inlineFormat.ts +0 -98
- package/apps/lib/components/TextEditor/editorjs.d.ts +0 -60
- package/apps/lib/components/TextEditor/index.ts +0 -7
- package/apps/lib/components/TextEditor/markdownParser.ts +0 -346
- package/apps/lib/components/Textarea.tsx +0 -117
- package/apps/lib/components/Timeline.tsx +0 -263
- package/apps/lib/components/Toast.tsx +0 -87
- package/apps/lib/components/Toggle.tsx +0 -125
- package/apps/lib/components/ToggleButton.tsx +0 -140
- package/apps/lib/components/Tooltip.tsx +0 -116
- package/apps/lib/components/TransparentLabel.tsx +0 -71
- package/apps/lib/components/TreeDropDown.tsx +0 -115
- package/apps/lib/components/TreeFolder/TreeFolder.tsx +0 -380
- package/apps/lib/components/TreeFolder/TreeFolderBreadcrumb.tsx +0 -75
- package/apps/lib/components/TreeFolder/TreeFolderRow.tsx +0 -354
- package/apps/lib/components/TreeFolder/TreeFolderStyles.tsx +0 -60
- package/apps/lib/components/TreeFolder/icons.tsx +0 -60
- package/apps/lib/components/TreeFolder/index.ts +0 -24
- package/apps/lib/components/TreeFolder/treeFolderUtils.ts +0 -109
- package/apps/lib/components/TreeFolder/types.ts +0 -77
- package/apps/lib/components/TreeFolder/useTreeFolderDnD.ts +0 -118
- package/apps/lib/hooks/useActiveTreeItem.ts +0 -58
- package/apps/lib/hooks/useClickOutside.ts +0 -27
- package/apps/lib/hooks/useDragDrop.tsx +0 -365
- package/apps/lib/hooks/useInfiniteScroll.ts +0 -108
- package/apps/lib/hooks/useIsMobile.ts +0 -21
- package/apps/lib/hooks/useResize.ts +0 -67
- package/apps/lib/hooks/useTagSelection.ts +0 -214
- package/apps/lib/layouts/CNLayout.tsx +0 -372
- package/apps/lib/layouts/DataViewCard.tsx +0 -62
- package/apps/lib/layouts/FieldSection.tsx +0 -91
- package/apps/lib/layouts/TreeSubLayout.tsx +0 -173
- package/apps/lib/providers/ThemeProvider.tsx +0 -84
- package/apps/lib/registry.json +0 -1201
- package/apps/lib/tsconfig.json +0 -9
- package/apps/lib/tsconfig.tsbuildinfo +0 -1
- package/apps/lib/utils/cn.ts +0 -6
- package/apps/lib/utils/color.ts +0 -175
- package/apps/lib/utils/dataViews/path.ts +0 -67
- package/apps/lib/utils/dataViews/query.ts +0 -73
- package/apps/lib/utils/dataViews/types.ts +0 -187
- package/apps/lib/utils/dateFormat.ts +0 -108
- package/apps/lib/utils/resize.ts +0 -31
- package/apps/lib/utils/types.ts +0 -16
- package/docs/BLOCKS.md +0 -129
- package/docs/CHANGELOG-1.1.16.md +0 -108
- package/docs/Cover.png +0 -0
- package/docs/README.md +0 -215
- package/docs/components/action-button.md +0 -638
- package/docs/components/actions-group.md +0 -708
- package/docs/components/alert-dialog.md +0 -920
- package/docs/components/avatar.md +0 -709
- package/docs/components/badge-field.md +0 -712
- package/docs/components/badge.md +0 -301
- package/docs/components/breadcrumb.md +0 -930
- package/docs/components/button-group.md +0 -650
- package/docs/components/button.md +0 -639
- package/docs/components/calendar.md +0 -555
- package/docs/components/card.md +0 -622
- package/docs/components/chart-block-tool.md +0 -129
- package/docs/components/checkbox.md +0 -699
- package/docs/components/cn-layout.md +0 -854
- package/docs/components/color-picker.md +0 -101
- package/docs/components/conclusion-header.md +0 -80
- package/docs/components/context-menu.md +0 -483
- package/docs/components/count-badge.md +0 -560
- package/docs/components/data-table.md +0 -854
- package/docs/components/data-views/backend-response.md +0 -324
- package/docs/components/data-views/examples/a11y-rtl.md +0 -250
- package/docs/components/data-views/examples/api-orders-route.md +0 -130
- package/docs/components/data-views/examples/fields.md +0 -362
- package/docs/components/data-views/examples/filters.md +0 -307
- package/docs/components/data-views/examples/inbox-routing.md +0 -218
- package/docs/components/data-views/examples/index.md +0 -29
- package/docs/components/data-views/examples/overview.md +0 -244
- package/docs/components/data-views/examples/panel.md +0 -212
- package/docs/components/data-views/examples/scale.md +0 -231
- package/docs/components/data-views/examples/server-side.md +0 -210
- package/docs/components/data-views/examples/state.md +0 -250
- package/docs/components/data-views/examples/tree-custom.md +0 -388
- package/docs/components/data-views/examples/view-registry.md +0 -313
- package/docs/components/data-views/examples/views.md +0 -534
- package/docs/components/data-views/guide.md +0 -405
- package/docs/components/data-views/index.md +0 -1495
- package/docs/components/data-views/migration.md +0 -79
- package/docs/components/date-picker.md +0 -857
- package/docs/components/dialog.md +0 -929
- package/docs/components/divider.md +0 -766
- package/docs/components/drawer.md +0 -654
- package/docs/components/dropdown-menu.md +0 -668
- package/docs/components/field-hint.md +0 -898
- package/docs/components/field-section.md +0 -781
- package/docs/components/form-builder.md +0 -276
- package/docs/components/form-renderer.md +0 -326
- package/docs/components/form-summary.md +0 -138
- package/docs/components/form.md +0 -785
- package/docs/components/header-bar.md +0 -188
- package/docs/components/image-attachment.md +0 -906
- package/docs/components/inner-label-field.md +0 -819
- package/docs/components/input-field.md +0 -623
- package/docs/components/input-otp.md +0 -756
- package/docs/components/input.md +0 -634
- package/docs/components/label-field.md +0 -770
- package/docs/components/label.md +0 -761
- package/docs/components/labeled-check-box.md +0 -642
- package/docs/components/labeled-radio.md +0 -796
- package/docs/components/link-button.md +0 -685
- package/docs/components/login-button.md +0 -872
- package/docs/components/password-level.md +0 -803
- package/docs/components/popover.md +0 -649
- package/docs/components/profile-menu.md +0 -656
- package/docs/components/radio-card.md +0 -801
- package/docs/components/radio.md +0 -735
- package/docs/components/scroll-area.md +0 -691
- package/docs/components/search-field.md +0 -702
- package/docs/components/searchable-select.md +0 -368
- package/docs/components/searchable-table.md +0 -438
- package/docs/components/searchable-tree-dialog.md +0 -190
- package/docs/components/searchable-tree.md +0 -200
- package/docs/components/section-block.md +0 -477
- package/docs/components/select.md +0 -709
- package/docs/components/simple-select.md +0 -741
- package/docs/components/skeleton.md +0 -706
- package/docs/components/slide-date-picker.md +0 -837
- package/docs/components/spin-loading.md +0 -696
- package/docs/components/stepper.md +0 -316
- package/docs/components/switch.md +0 -770
- package/docs/components/tab-form-item.md +0 -773
- package/docs/components/tab-switch.md +0 -170
- package/docs/components/table-dnd-wrapper.md +0 -107
- package/docs/components/table.md +0 -1088
- package/docs/components/text-editor.md +0 -735
- package/docs/components/textarea.md +0 -681
- package/docs/components/timeline.md +0 -254
- package/docs/components/toast.md +0 -773
- package/docs/components/toggle-button.md +0 -643
- package/docs/components/toggle.md +0 -882
- package/docs/components/tooltip.md +0 -513
- package/docs/components/transparent-label.md +0 -721
- package/docs/components/tree-drop-down.md +0 -740
- package/docs/components/tree-folder.md +0 -110
- package/docs/components/tree-sub-layout.md +0 -707
- package/docs/explanation/architecture.md +0 -54
- package/docs/explanation/design-system.md +0 -52
- package/docs/how-to/form-and-list-recipes.md +0 -386
- package/docs/how-to/forms-with-form-builder.md +0 -472
- package/docs/how-to/guides.md +0 -1027
- package/docs/migration/changelog.md +0 -54
- package/docs/migration/form-builder-2.5.2.md +0 -113
- package/docs/reference/cli.md +0 -112
- package/docs/reference/components.md +0 -572
- package/docs/reference/hooks.md +0 -1500
- package/docs/reference/providers.md +0 -866
- package/docs/reference/tailwind-plugins.md +0 -942
- package/docs/reference/theme.md +0 -85
- package/docs/reference/types.md +0 -1016
- package/docs/reference/utilities.md +0 -704
- package/docs/tutorials/building-first-form.md +0 -846
- package/docs/tutorials/component-composition.md +0 -882
- package/docs/tutorials/getting-started.md +0 -302
- package/docs/tutorials/theming-basics.md +0 -785
|
@@ -1,781 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: FieldSection
|
|
3
|
-
description: Form section component with labels and responsive layout for grouping related form fields.
|
|
4
|
-
component: true
|
|
5
|
-
group: Layout & Containers
|
|
6
|
-
keywords: [form, section, layout, label, field, group, responsive]
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# FieldSection
|
|
10
|
-
|
|
11
|
-
A structured form section component that provides consistent layout for form fields with labels, secondary text, hints, and flexible responsive behavior. Perfect for building organized, accessible forms.
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
TORCH Glare is a copy-in library: the CLI copies this component's source into your project
|
|
16
|
-
(you do **not** install it from the npm package). Run `init` once, then `add`:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npx torch-glare@latest init
|
|
20
|
-
npx torch-glare@latest add FieldSection
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
`add` also copies any components, hooks, and utilities that `FieldSection` depends on.
|
|
24
|
-
|
|
25
|
-
## Imports
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
import { FieldSection } from '@/layouts/FieldSection'
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Basic Usage
|
|
32
|
-
|
|
33
|
-
```tsx
|
|
34
|
-
import { FieldSection } from '@/layouts/FieldSection'
|
|
35
|
-
import { InputField } from '@/components/InputField'
|
|
36
|
-
|
|
37
|
-
export function BasicFieldSection() {
|
|
38
|
-
return (
|
|
39
|
-
<FieldSection
|
|
40
|
-
label="Email Address"
|
|
41
|
-
secondaryLabel="We'll never share your email"
|
|
42
|
-
>
|
|
43
|
-
<InputField
|
|
44
|
-
type="email"
|
|
45
|
-
placeholder="Enter your email"
|
|
46
|
-
className="w-full"
|
|
47
|
-
/>
|
|
48
|
-
</FieldSection>
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Examples
|
|
54
|
-
|
|
55
|
-
### All Sizes
|
|
56
|
-
|
|
57
|
-
FieldSection supports three sizes: S, M, and L.
|
|
58
|
-
|
|
59
|
-
```tsx
|
|
60
|
-
export function FieldSectionSizes() {
|
|
61
|
-
return (
|
|
62
|
-
<div className="space-y-4">
|
|
63
|
-
<FieldSection
|
|
64
|
-
size="S"
|
|
65
|
-
label="Small Size"
|
|
66
|
-
secondaryLabel="Compact form section"
|
|
67
|
-
>
|
|
68
|
-
<InputField size="S" placeholder="Small input" className="w-full" />
|
|
69
|
-
</FieldSection>
|
|
70
|
-
|
|
71
|
-
<FieldSection
|
|
72
|
-
size="M"
|
|
73
|
-
label="Medium Size"
|
|
74
|
-
secondaryLabel="Standard form section"
|
|
75
|
-
>
|
|
76
|
-
<InputField size="M" placeholder="Medium input" className="w-full" />
|
|
77
|
-
</FieldSection>
|
|
78
|
-
|
|
79
|
-
<FieldSection
|
|
80
|
-
size="L"
|
|
81
|
-
label="Large Size"
|
|
82
|
-
secondaryLabel="Spacious form section"
|
|
83
|
-
>
|
|
84
|
-
<InputField size="M" placeholder="Large input" className="w-full" />
|
|
85
|
-
</FieldSection>
|
|
86
|
-
</div>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Layout Directions
|
|
92
|
-
|
|
93
|
-
Control how the label and content are positioned.
|
|
94
|
-
|
|
95
|
-
```tsx
|
|
96
|
-
export function LayoutDirections() {
|
|
97
|
-
return (
|
|
98
|
-
<div className="space-y-6">
|
|
99
|
-
{/* Vertical layout - stacks label above content */}
|
|
100
|
-
<FieldSection
|
|
101
|
-
direction="vertical"
|
|
102
|
-
label="Vertical Layout"
|
|
103
|
-
secondaryLabel="Label and content are stacked"
|
|
104
|
-
>
|
|
105
|
-
<InputField placeholder="Input field" className="w-full" />
|
|
106
|
-
</FieldSection>
|
|
107
|
-
|
|
108
|
-
{/* Horizontal layout - label and content side by side */}
|
|
109
|
-
<FieldSection
|
|
110
|
-
direction="horizontal"
|
|
111
|
-
label="Horizontal Layout"
|
|
112
|
-
secondaryLabel="Label on the left, content on the right"
|
|
113
|
-
>
|
|
114
|
-
<InputField placeholder="Input field" className="w-full" />
|
|
115
|
-
</FieldSection>
|
|
116
|
-
|
|
117
|
-
{/* Flexible layout - responsive, vertical on mobile, horizontal on desktop */}
|
|
118
|
-
<FieldSection
|
|
119
|
-
direction="flexible"
|
|
120
|
-
label="Flexible Layout"
|
|
121
|
-
secondaryLabel="Adapts to screen size"
|
|
122
|
-
>
|
|
123
|
-
<InputField placeholder="Input field" className="w-full" />
|
|
124
|
-
</FieldSection>
|
|
125
|
-
</div>
|
|
126
|
-
)
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### With Required Label
|
|
131
|
-
|
|
132
|
-
Show required field indicators.
|
|
133
|
-
|
|
134
|
-
```tsx
|
|
135
|
-
export function RequiredFields() {
|
|
136
|
-
return (
|
|
137
|
-
<div className="space-y-4">
|
|
138
|
-
<FieldSection
|
|
139
|
-
label="Full Name"
|
|
140
|
-
requiredLabel="Required"
|
|
141
|
-
secondaryLabel="Enter your first and last name"
|
|
142
|
-
>
|
|
143
|
-
<InputField placeholder="John Doe" className="w-full" required />
|
|
144
|
-
</FieldSection>
|
|
145
|
-
|
|
146
|
-
<FieldSection
|
|
147
|
-
label="Email"
|
|
148
|
-
requiredLabel="*"
|
|
149
|
-
secondaryLabel="Your primary email address"
|
|
150
|
-
>
|
|
151
|
-
<InputField type="email" placeholder="john@example.com" className="w-full" required />
|
|
152
|
-
</FieldSection>
|
|
153
|
-
|
|
154
|
-
<FieldSection
|
|
155
|
-
label="Phone"
|
|
156
|
-
secondaryLabel="Optional contact number"
|
|
157
|
-
>
|
|
158
|
-
<InputField type="tel" placeholder="+1 (555) 000-0000" className="w-full" />
|
|
159
|
-
</FieldSection>
|
|
160
|
-
</div>
|
|
161
|
-
)
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### With Field Hints
|
|
166
|
-
|
|
167
|
-
Add validation hints and feedback.
|
|
168
|
-
|
|
169
|
-
```tsx
|
|
170
|
-
import { FieldHint } from '@/components/FieldHint'
|
|
171
|
-
|
|
172
|
-
export function WithFieldHints() {
|
|
173
|
-
const [email, setEmail] = useState('')
|
|
174
|
-
const [error, setError] = useState('')
|
|
175
|
-
|
|
176
|
-
const validateEmail = (value) => {
|
|
177
|
-
if (!value.includes('@')) {
|
|
178
|
-
setError('Please enter a valid email address')
|
|
179
|
-
} else {
|
|
180
|
-
setError('')
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<FieldSection
|
|
186
|
-
label="Email Address"
|
|
187
|
-
requiredLabel="Required"
|
|
188
|
-
secondaryLabel="We'll send you account updates"
|
|
189
|
-
childrenUnderLabel={
|
|
190
|
-
<>
|
|
191
|
-
<FieldHint
|
|
192
|
-
label="Use your work email for business accounts"
|
|
193
|
-
state="info"
|
|
194
|
-
/>
|
|
195
|
-
{error && (
|
|
196
|
-
<FieldHint label={error} state="error" />
|
|
197
|
-
)}
|
|
198
|
-
</>
|
|
199
|
-
}
|
|
200
|
-
>
|
|
201
|
-
<InputField
|
|
202
|
-
type="email"
|
|
203
|
-
value={email}
|
|
204
|
-
onChange={(e) => {
|
|
205
|
-
setEmail(e.target.value)
|
|
206
|
-
validateEmail(e.target.value)
|
|
207
|
-
}}
|
|
208
|
-
placeholder="your.email@company.com"
|
|
209
|
-
className="w-full"
|
|
210
|
-
/>
|
|
211
|
-
</FieldSection>
|
|
212
|
-
)
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Multiple Form Fields
|
|
217
|
-
|
|
218
|
-
Group multiple related inputs in one section.
|
|
219
|
-
|
|
220
|
-
```tsx
|
|
221
|
-
export function MultipleFields() {
|
|
222
|
-
return (
|
|
223
|
-
<FieldSection
|
|
224
|
-
label="Shipping Address"
|
|
225
|
-
requiredLabel="Required"
|
|
226
|
-
secondaryLabel="Enter your complete shipping address"
|
|
227
|
-
>
|
|
228
|
-
<InputField
|
|
229
|
-
placeholder="Street Address"
|
|
230
|
-
className="w-full"
|
|
231
|
-
/>
|
|
232
|
-
<InputField
|
|
233
|
-
placeholder="Apartment, suite, etc. (optional)"
|
|
234
|
-
className="w-full"
|
|
235
|
-
/>
|
|
236
|
-
<div className="grid grid-cols-2 gap-3 w-full">
|
|
237
|
-
<InputField placeholder="City" />
|
|
238
|
-
<InputField placeholder="State/Province" />
|
|
239
|
-
</div>
|
|
240
|
-
<div className="grid grid-cols-2 gap-3 w-full">
|
|
241
|
-
<InputField placeholder="ZIP/Postal Code" />
|
|
242
|
-
<InputField placeholder="Country" />
|
|
243
|
-
</div>
|
|
244
|
-
</FieldSection>
|
|
245
|
-
)
|
|
246
|
-
}
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
### With Different Input Types
|
|
250
|
-
|
|
251
|
-
Mix various form input components.
|
|
252
|
-
|
|
253
|
-
```tsx
|
|
254
|
-
export function MixedInputTypes() {
|
|
255
|
-
return (
|
|
256
|
-
<div className="space-y-4">
|
|
257
|
-
<FieldSection
|
|
258
|
-
label="Project Name"
|
|
259
|
-
requiredLabel="Required"
|
|
260
|
-
secondaryLabel="Choose a descriptive name"
|
|
261
|
-
>
|
|
262
|
-
<InputField placeholder="My Awesome Project" className="w-full" />
|
|
263
|
-
</FieldSection>
|
|
264
|
-
|
|
265
|
-
<FieldSection
|
|
266
|
-
label="Project Description"
|
|
267
|
-
secondaryLabel="Provide details about your project"
|
|
268
|
-
>
|
|
269
|
-
<TextAreaInput
|
|
270
|
-
placeholder="Describe your project..."
|
|
271
|
-
rows={4}
|
|
272
|
-
className="w-full"
|
|
273
|
-
/>
|
|
274
|
-
</FieldSection>
|
|
275
|
-
|
|
276
|
-
<FieldSection
|
|
277
|
-
label="Project Type"
|
|
278
|
-
requiredLabel="Required"
|
|
279
|
-
>
|
|
280
|
-
<SimpleSelect
|
|
281
|
-
options={[
|
|
282
|
-
{ value: 'web', label: 'Web Application' },
|
|
283
|
-
{ value: 'mobile', label: 'Mobile App' },
|
|
284
|
-
{ value: 'desktop', label: 'Desktop Software' },
|
|
285
|
-
]}
|
|
286
|
-
className="w-full"
|
|
287
|
-
/>
|
|
288
|
-
</FieldSection>
|
|
289
|
-
|
|
290
|
-
<FieldSection
|
|
291
|
-
label="Enable Features"
|
|
292
|
-
>
|
|
293
|
-
<div className="w-full space-y-2">
|
|
294
|
-
<LabeledCheckBox id="notifications" label="Email Notifications" />
|
|
295
|
-
<LabeledCheckBox id="analytics" label="Analytics Tracking" />
|
|
296
|
-
<LabeledCheckBox id="api" label="API Access" />
|
|
297
|
-
</div>
|
|
298
|
-
</FieldSection>
|
|
299
|
-
</div>
|
|
300
|
-
)
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
### Profile Settings Form
|
|
305
|
-
|
|
306
|
-
Complete profile form with multiple sections.
|
|
307
|
-
|
|
308
|
-
```tsx
|
|
309
|
-
export function ProfileSettingsForm() {
|
|
310
|
-
return (
|
|
311
|
-
<form className="max-w-[1200px] space-y-0">
|
|
312
|
-
<FieldSection
|
|
313
|
-
size="M"
|
|
314
|
-
label="Display Name"
|
|
315
|
-
requiredLabel="Required"
|
|
316
|
-
secondaryLabel="This is how others will see you"
|
|
317
|
-
>
|
|
318
|
-
<InputField placeholder="John Doe" className="w-full" />
|
|
319
|
-
</FieldSection>
|
|
320
|
-
|
|
321
|
-
<FieldSection
|
|
322
|
-
size="M"
|
|
323
|
-
label="Username"
|
|
324
|
-
requiredLabel="Required"
|
|
325
|
-
secondaryLabel="Your unique identifier"
|
|
326
|
-
childrenUnderLabel={
|
|
327
|
-
<FieldHint
|
|
328
|
-
label="Can only contain letters, numbers, and underscores"
|
|
329
|
-
state="info"
|
|
330
|
-
/>
|
|
331
|
-
}
|
|
332
|
-
>
|
|
333
|
-
<InputField placeholder="johndoe" className="w-full" />
|
|
334
|
-
</FieldSection>
|
|
335
|
-
|
|
336
|
-
<FieldSection
|
|
337
|
-
size="M"
|
|
338
|
-
label="Bio"
|
|
339
|
-
secondaryLabel="Tell us about yourself"
|
|
340
|
-
>
|
|
341
|
-
<TextAreaInput
|
|
342
|
-
placeholder="I'm a developer who loves..."
|
|
343
|
-
rows={3}
|
|
344
|
-
className="w-full"
|
|
345
|
-
/>
|
|
346
|
-
</FieldSection>
|
|
347
|
-
|
|
348
|
-
<FieldSection
|
|
349
|
-
size="M"
|
|
350
|
-
label="Profile Photo"
|
|
351
|
-
secondaryLabel="Upload a profile picture"
|
|
352
|
-
>
|
|
353
|
-
<div className="w-full flex items-center gap-4">
|
|
354
|
-
<Avatar size="L" src="/default-avatar.jpg" />
|
|
355
|
-
<Button variant="BluSecStyle" size="M">
|
|
356
|
-
Upload New Photo
|
|
357
|
-
</Button>
|
|
358
|
-
</div>
|
|
359
|
-
</FieldSection>
|
|
360
|
-
|
|
361
|
-
<FieldSection
|
|
362
|
-
size="M"
|
|
363
|
-
label="Email Preferences"
|
|
364
|
-
secondaryLabel="Choose what emails you want to receive"
|
|
365
|
-
>
|
|
366
|
-
<div className="w-full space-y-2">
|
|
367
|
-
<LabeledCheckBox id="marketing" label="Marketing emails" />
|
|
368
|
-
<LabeledCheckBox id="updates" label="Product updates" />
|
|
369
|
-
<LabeledCheckBox id="security" label="Security alerts" />
|
|
370
|
-
</div>
|
|
371
|
-
</FieldSection>
|
|
372
|
-
</form>
|
|
373
|
-
)
|
|
374
|
-
}
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
### Password Change Section
|
|
378
|
-
|
|
379
|
-
Secure password update form.
|
|
380
|
-
|
|
381
|
-
```tsx
|
|
382
|
-
export function PasswordChangeSection() {
|
|
383
|
-
return (
|
|
384
|
-
<div className="max-w-[1200px]">
|
|
385
|
-
<FieldSection
|
|
386
|
-
label="Current Password"
|
|
387
|
-
requiredLabel="Required"
|
|
388
|
-
secondaryLabel="Enter your current password to make changes"
|
|
389
|
-
>
|
|
390
|
-
<InputField
|
|
391
|
-
type="password"
|
|
392
|
-
placeholder="••••••••"
|
|
393
|
-
className="w-full"
|
|
394
|
-
/>
|
|
395
|
-
</FieldSection>
|
|
396
|
-
|
|
397
|
-
<FieldSection
|
|
398
|
-
label="New Password"
|
|
399
|
-
requiredLabel="Required"
|
|
400
|
-
secondaryLabel="Must be at least 8 characters"
|
|
401
|
-
childrenUnderLabel={
|
|
402
|
-
<>
|
|
403
|
-
<FieldHint
|
|
404
|
-
label="Use a mix of letters, numbers, and symbols"
|
|
405
|
-
state="info"
|
|
406
|
-
/>
|
|
407
|
-
<FieldHint
|
|
408
|
-
label="Password strength: Strong"
|
|
409
|
-
state="success"
|
|
410
|
-
/>
|
|
411
|
-
</>
|
|
412
|
-
}
|
|
413
|
-
>
|
|
414
|
-
<InputField
|
|
415
|
-
type="password"
|
|
416
|
-
placeholder="••••••••"
|
|
417
|
-
className="w-full"
|
|
418
|
-
/>
|
|
419
|
-
</FieldSection>
|
|
420
|
-
|
|
421
|
-
<FieldSection
|
|
422
|
-
label="Confirm New Password"
|
|
423
|
-
requiredLabel="Required"
|
|
424
|
-
secondaryLabel="Re-enter your new password"
|
|
425
|
-
>
|
|
426
|
-
<InputField
|
|
427
|
-
type="password"
|
|
428
|
-
placeholder="••••••••"
|
|
429
|
-
className="w-full"
|
|
430
|
-
/>
|
|
431
|
-
</FieldSection>
|
|
432
|
-
</div>
|
|
433
|
-
)
|
|
434
|
-
}
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
### Account Settings
|
|
438
|
-
|
|
439
|
-
Comprehensive account management form.
|
|
440
|
-
|
|
441
|
-
```tsx
|
|
442
|
-
export function AccountSettings() {
|
|
443
|
-
return (
|
|
444
|
-
<div className="max-w-[1200px]">
|
|
445
|
-
<h2 className="text-xl font-bold mb-6">Account Settings</h2>
|
|
446
|
-
|
|
447
|
-
<FieldSection
|
|
448
|
-
label="Language"
|
|
449
|
-
secondaryLabel="Select your preferred language"
|
|
450
|
-
>
|
|
451
|
-
<SimpleSelect
|
|
452
|
-
options={[
|
|
453
|
-
{ value: 'en', label: 'English' },
|
|
454
|
-
{ value: 'es', label: 'Español' },
|
|
455
|
-
{ value: 'fr', label: 'Français' },
|
|
456
|
-
]}
|
|
457
|
-
className="w-full"
|
|
458
|
-
/>
|
|
459
|
-
</FieldSection>
|
|
460
|
-
|
|
461
|
-
<FieldSection
|
|
462
|
-
label="Time Zone"
|
|
463
|
-
secondaryLabel="Choose your local time zone"
|
|
464
|
-
>
|
|
465
|
-
<SimpleSelect
|
|
466
|
-
options={[
|
|
467
|
-
{ value: 'utc', label: 'UTC' },
|
|
468
|
-
{ value: 'est', label: 'Eastern Time (EST)' },
|
|
469
|
-
{ value: 'pst', label: 'Pacific Time (PST)' },
|
|
470
|
-
]}
|
|
471
|
-
className="w-full"
|
|
472
|
-
/>
|
|
473
|
-
</FieldSection>
|
|
474
|
-
|
|
475
|
-
<FieldSection
|
|
476
|
-
label="Privacy"
|
|
477
|
-
secondaryLabel="Control who can see your profile"
|
|
478
|
-
>
|
|
479
|
-
<RadioGroup value="public">
|
|
480
|
-
<div className="w-full space-y-2">
|
|
481
|
-
<LabeledRadio id="public" value="public" label="Public" />
|
|
482
|
-
<LabeledRadio id="friends" value="friends" label="Friends Only" />
|
|
483
|
-
<LabeledRadio id="private" value="private" label="Private" />
|
|
484
|
-
</div>
|
|
485
|
-
</RadioGroup>
|
|
486
|
-
</FieldSection>
|
|
487
|
-
|
|
488
|
-
<FieldSection
|
|
489
|
-
label="Danger Zone"
|
|
490
|
-
secondaryLabel="Irreversible account actions"
|
|
491
|
-
childrenUnderLabel={
|
|
492
|
-
<FieldHint
|
|
493
|
-
label="These actions cannot be undone"
|
|
494
|
-
state="warning"
|
|
495
|
-
/>
|
|
496
|
-
}
|
|
497
|
-
>
|
|
498
|
-
<div className="w-full space-y-2">
|
|
499
|
-
<Button variant="RedSecStyle" size="M">
|
|
500
|
-
Delete Account
|
|
501
|
-
</Button>
|
|
502
|
-
</div>
|
|
503
|
-
</FieldSection>
|
|
504
|
-
</div>
|
|
505
|
-
)
|
|
506
|
-
}
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
### Validation States
|
|
510
|
-
|
|
511
|
-
Show different validation states.
|
|
512
|
-
|
|
513
|
-
```tsx
|
|
514
|
-
export function ValidationStates() {
|
|
515
|
-
return (
|
|
516
|
-
<div className="space-y-4">
|
|
517
|
-
<FieldSection
|
|
518
|
-
label="Valid Field"
|
|
519
|
-
childrenUnderLabel={
|
|
520
|
-
<FieldHint label="Looks good!" state="success" />
|
|
521
|
-
}
|
|
522
|
-
>
|
|
523
|
-
<InputField value="Valid input" className="w-full" />
|
|
524
|
-
</FieldSection>
|
|
525
|
-
|
|
526
|
-
<FieldSection
|
|
527
|
-
label="Warning Field"
|
|
528
|
-
childrenUnderLabel={
|
|
529
|
-
<FieldHint
|
|
530
|
-
label="This might not be what you want"
|
|
531
|
-
state="warning"
|
|
532
|
-
/>
|
|
533
|
-
}
|
|
534
|
-
>
|
|
535
|
-
<InputField value="Questionable input" className="w-full" />
|
|
536
|
-
</FieldSection>
|
|
537
|
-
|
|
538
|
-
<FieldSection
|
|
539
|
-
label="Error Field"
|
|
540
|
-
requiredLabel="Required"
|
|
541
|
-
childrenUnderLabel={
|
|
542
|
-
<FieldHint label="This field is required" state="error" />
|
|
543
|
-
}
|
|
544
|
-
>
|
|
545
|
-
<InputField value="" className="w-full" />
|
|
546
|
-
</FieldSection>
|
|
547
|
-
|
|
548
|
-
<FieldSection
|
|
549
|
-
label="Info Field"
|
|
550
|
-
childrenUnderLabel={
|
|
551
|
-
<FieldHint
|
|
552
|
-
label="Pro tip: Use your work email"
|
|
553
|
-
state="info"
|
|
554
|
-
/>
|
|
555
|
-
}
|
|
556
|
-
>
|
|
557
|
-
<InputField placeholder="email@company.com" className="w-full" />
|
|
558
|
-
</FieldSection>
|
|
559
|
-
</div>
|
|
560
|
-
)
|
|
561
|
-
}
|
|
562
|
-
```
|
|
563
|
-
|
|
564
|
-
## API Reference
|
|
565
|
-
|
|
566
|
-
### FieldSection Props
|
|
567
|
-
|
|
568
|
-
| Prop | Type | Default | Description |
|
|
569
|
-
|------|------|---------|-------------|
|
|
570
|
-
| label | `ReactNode` | - | Primary label text |
|
|
571
|
-
| secondaryLabel | `ReactNode` | - | Secondary descriptive text |
|
|
572
|
-
| requiredLabel | `ReactNode` | - | Required field indicator |
|
|
573
|
-
| size | `'S' \| 'M' \| 'L'` | - | Label size |
|
|
574
|
-
| direction | `'horizontal' \| 'vertical' \| 'flexible'` | `'flexible'` | Layout direction |
|
|
575
|
-
| childrenUnderLabel | `ReactNode` | - | Content below labels (hints, errors) |
|
|
576
|
-
| theme | `Themes` | - | Theme override |
|
|
577
|
-
| className | `string` | - | Additional CSS classes |
|
|
578
|
-
| children | `ReactNode` | - | Form field content |
|
|
579
|
-
|
|
580
|
-
### Layout Directions
|
|
581
|
-
|
|
582
|
-
| Direction | Behavior | Best For |
|
|
583
|
-
|-----------|----------|----------|
|
|
584
|
-
| vertical | Always stacks vertically | Mobile-first designs |
|
|
585
|
-
| horizontal | Always side-by-side (350px label width) | Desktop forms |
|
|
586
|
-
| flexible | Vertical on mobile, horizontal on desktop | Responsive designs |
|
|
587
|
-
|
|
588
|
-
## Styling
|
|
589
|
-
|
|
590
|
-
### Base Structure
|
|
591
|
-
|
|
592
|
-
- **Border Top**: Separates sections with subtle border
|
|
593
|
-
- **Padding**: 16px vertical, 12px horizontal
|
|
594
|
-
- **Max Width**: 1200px for optimal readability
|
|
595
|
-
- **Grid Layout**: Responsive grid system
|
|
596
|
-
|
|
597
|
-
### Label Section
|
|
598
|
-
|
|
599
|
-
- **Fixed Width**: 350px on horizontal/flexible layouts
|
|
600
|
-
- **Gap**: 12px between label elements
|
|
601
|
-
|
|
602
|
-
### Content Section
|
|
603
|
-
|
|
604
|
-
- **Flexible Width**: Takes remaining space
|
|
605
|
-
- **Grid**: Single column with 12px gap
|
|
606
|
-
- **Alignment**: Content aligned to end
|
|
607
|
-
|
|
608
|
-
## TypeScript Types
|
|
609
|
-
|
|
610
|
-
```typescript
|
|
611
|
-
interface FieldSectionProps {
|
|
612
|
-
label?: ReactNode
|
|
613
|
-
secondaryLabel?: ReactNode
|
|
614
|
-
requiredLabel?: ReactNode
|
|
615
|
-
size?: 'S' | 'M' | 'L'
|
|
616
|
-
childrenUnderLabel?: ReactNode
|
|
617
|
-
theme?: Themes
|
|
618
|
-
className?: string
|
|
619
|
-
children?: ReactNode
|
|
620
|
-
direction?: 'horizontal' | 'vertical' | 'flexible'
|
|
621
|
-
}
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
## Common Patterns
|
|
625
|
-
|
|
626
|
-
### Form with Multiple Sections
|
|
627
|
-
|
|
628
|
-
```tsx
|
|
629
|
-
function CompleteForm() {
|
|
630
|
-
return (
|
|
631
|
-
<form className="space-y-0">
|
|
632
|
-
{formSections.map((section, index) => (
|
|
633
|
-
<FieldSection
|
|
634
|
-
key={index}
|
|
635
|
-
label={section.label}
|
|
636
|
-
secondaryLabel={section.description}
|
|
637
|
-
requiredLabel={section.required ? 'Required' : undefined}
|
|
638
|
-
>
|
|
639
|
-
{section.fields.map(field => (
|
|
640
|
-
<InputField
|
|
641
|
-
key={field.name}
|
|
642
|
-
{...field}
|
|
643
|
-
className="w-full"
|
|
644
|
-
/>
|
|
645
|
-
))}
|
|
646
|
-
</FieldSection>
|
|
647
|
-
))}
|
|
648
|
-
</form>
|
|
649
|
-
)
|
|
650
|
-
}
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
### Conditional Field Display
|
|
654
|
-
|
|
655
|
-
```tsx
|
|
656
|
-
function ConditionalFields() {
|
|
657
|
-
const [showAdvanced, setShowAdvanced] = useState(false)
|
|
658
|
-
|
|
659
|
-
return (
|
|
660
|
-
<>
|
|
661
|
-
<FieldSection label="Basic Settings">
|
|
662
|
-
<InputField className="w-full" />
|
|
663
|
-
</FieldSection>
|
|
664
|
-
|
|
665
|
-
{showAdvanced && (
|
|
666
|
-
<FieldSection label="Advanced Settings">
|
|
667
|
-
<InputField className="w-full" />
|
|
668
|
-
</FieldSection>
|
|
669
|
-
)}
|
|
670
|
-
|
|
671
|
-
<button onClick={() => setShowAdvanced(!showAdvanced)}>
|
|
672
|
-
{showAdvanced ? 'Hide' : 'Show'} Advanced
|
|
673
|
-
</button>
|
|
674
|
-
</>
|
|
675
|
-
)
|
|
676
|
-
}
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
## Testing
|
|
680
|
-
|
|
681
|
-
```typescript
|
|
682
|
-
import { render, screen } from '@testing-library/react'
|
|
683
|
-
import { FieldSection } from '@/layouts/FieldSection'
|
|
684
|
-
|
|
685
|
-
describe('FieldSection', () => {
|
|
686
|
-
it('renders with label', () => {
|
|
687
|
-
render(
|
|
688
|
-
<FieldSection label="Test Label">
|
|
689
|
-
<input />
|
|
690
|
-
</FieldSection>
|
|
691
|
-
)
|
|
692
|
-
|
|
693
|
-
expect(screen.getByText('Test Label')).toBeInTheDocument()
|
|
694
|
-
})
|
|
695
|
-
|
|
696
|
-
it('shows required indicator', () => {
|
|
697
|
-
render(
|
|
698
|
-
<FieldSection
|
|
699
|
-
label="Email"
|
|
700
|
-
requiredLabel="Required"
|
|
701
|
-
>
|
|
702
|
-
<input />
|
|
703
|
-
</FieldSection>
|
|
704
|
-
)
|
|
705
|
-
|
|
706
|
-
expect(screen.getByText('Required')).toBeInTheDocument()
|
|
707
|
-
})
|
|
708
|
-
|
|
709
|
-
it('applies correct layout direction', () => {
|
|
710
|
-
const { container } = render(
|
|
711
|
-
<FieldSection direction="horizontal" label="Test">
|
|
712
|
-
<input />
|
|
713
|
-
</FieldSection>
|
|
714
|
-
)
|
|
715
|
-
|
|
716
|
-
const section = container.querySelector('section')
|
|
717
|
-
expect(section).toHaveClass('grid-cols-[350px_1fr]')
|
|
718
|
-
})
|
|
719
|
-
|
|
720
|
-
it('renders children under label', () => {
|
|
721
|
-
render(
|
|
722
|
-
<FieldSection
|
|
723
|
-
label="Test"
|
|
724
|
-
childrenUnderLabel={<span>Helper text</span>}
|
|
725
|
-
>
|
|
726
|
-
<input />
|
|
727
|
-
</FieldSection>
|
|
728
|
-
)
|
|
729
|
-
|
|
730
|
-
expect(screen.getByText('Helper text')).toBeInTheDocument()
|
|
731
|
-
})
|
|
732
|
-
})
|
|
733
|
-
```
|
|
734
|
-
|
|
735
|
-
## Accessibility
|
|
736
|
-
|
|
737
|
-
- **Semantic HTML**: Uses section element
|
|
738
|
-
- **Label Association**: Labels are properly associated with inputs
|
|
739
|
-
- **Required Indicators**: Clear visual and programmatic required states
|
|
740
|
-
- **Screen Reader Support**: Proper structure for assistive technologies
|
|
741
|
-
- **Keyboard Navigation**: Full keyboard accessibility
|
|
742
|
-
- **ARIA Support**: Supports ARIA attributes for enhanced accessibility
|
|
743
|
-
|
|
744
|
-
## Performance
|
|
745
|
-
|
|
746
|
-
- **CSS Grid**: Efficient responsive layout
|
|
747
|
-
- **Minimal Re-renders**: Optimized component structure
|
|
748
|
-
- **Lazy Label Rendering**: Only renders labels when provided
|
|
749
|
-
- **Flexible Layout**: CSS-based responsive behavior
|
|
750
|
-
|
|
751
|
-
## Migration Guide
|
|
752
|
-
|
|
753
|
-
### From Custom Form Sections
|
|
754
|
-
|
|
755
|
-
```tsx
|
|
756
|
-
// Before: Custom form section
|
|
757
|
-
<div className="form-section">
|
|
758
|
-
<label>Email</label>
|
|
759
|
-
<p className="help-text">Enter your email</p>
|
|
760
|
-
<input type="email" />
|
|
761
|
-
</div>
|
|
762
|
-
|
|
763
|
-
// After: FieldSection
|
|
764
|
-
<FieldSection
|
|
765
|
-
label="Email"
|
|
766
|
-
secondaryLabel="Enter your email"
|
|
767
|
-
>
|
|
768
|
-
<InputField type="email" className="w-full" />
|
|
769
|
-
</FieldSection>
|
|
770
|
-
```
|
|
771
|
-
|
|
772
|
-
## Best Practices
|
|
773
|
-
|
|
774
|
-
1. **Consistent Sizing**: Use the same size across related sections
|
|
775
|
-
2. **Clear Labels**: Write descriptive, concise labels
|
|
776
|
-
3. **Helpful Secondary Text**: Provide context and guidance
|
|
777
|
-
4. **Required Indicators**: Always mark required fields
|
|
778
|
-
5. **Validation Feedback**: Show errors and success states
|
|
779
|
-
6. **Responsive Direction**: Use flexible direction for most cases
|
|
780
|
-
7. **Max Width**: Keep form sections within readable width
|
|
781
|
-
8. **Group Related Fields**: Use one section per logical group
|