prime-ui-kit 0.2.3 → 0.3.1
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 +172 -34
- package/dist/components/accordion/Accordion.d.ts +70 -0
- package/dist/components/accordion/Accordion.d.ts.map +1 -0
- package/dist/components/avatar/Avatar.d.ts +58 -0
- package/dist/components/avatar/Avatar.d.ts.map +1 -0
- package/dist/components/badge/Badge.d.ts +51 -0
- package/dist/components/badge/Badge.d.ts.map +1 -0
- package/dist/components/banner/Banner.d.ts +78 -0
- package/dist/components/banner/Banner.d.ts.map +1 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +47 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/dist/components/button/Button.d.ts +57 -0
- package/dist/components/button/Button.d.ts.map +1 -0
- package/dist/components/button-group/ButtonGroup.d.ts +34 -0
- package/dist/components/button-group/ButtonGroup.d.ts.map +1 -0
- package/dist/components/card/Card.d.ts +234 -0
- package/dist/components/card/Card.d.ts.map +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +42 -0
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/code-block/CodeBlock.d.ts +17 -0
- package/dist/components/code-block/CodeBlock.d.ts.map +1 -0
- package/dist/components/color-picker/ColorPicker.d.ts +76 -0
- package/dist/components/color-picker/ColorPicker.d.ts.map +1 -0
- package/dist/components/color-picker/ColorPickerRac.d.ts +76 -0
- package/dist/components/color-picker/ColorPickerRac.d.ts.map +1 -0
- package/dist/components/command-menu/CommandMenu.d.ts +74 -0
- package/dist/components/command-menu/CommandMenu.d.ts.map +1 -0
- package/dist/components/data-table/DataTable.d.ts +78 -0
- package/dist/components/data-table/DataTable.d.ts.map +1 -0
- package/dist/components/datepicker/Datepicker.d.ts +104 -0
- package/dist/components/datepicker/Datepicker.d.ts.map +1 -0
- package/dist/components/digit-input/DigitInput.d.ts +21 -0
- package/dist/components/digit-input/DigitInput.d.ts.map +1 -0
- package/dist/components/divider/Divider.d.ts +26 -0
- package/dist/components/divider/Divider.d.ts.map +1 -0
- package/dist/components/drawer/Drawer.d.ts +71 -0
- package/dist/components/drawer/Drawer.d.ts.map +1 -0
- package/dist/components/dropdown/Dropdown.d.ts +147 -0
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -0
- package/dist/components/dropdown/dropdownGeometry.d.ts +10 -0
- package/dist/components/dropdown/dropdownGeometry.d.ts.map +1 -0
- package/dist/components/dropdown/menuKeyboard.d.ts +4 -0
- package/dist/components/dropdown/menuKeyboard.d.ts.map +1 -0
- package/dist/components/dropdown/useDropdownPosition.d.ts +18 -0
- package/dist/components/dropdown/useDropdownPosition.d.ts.map +1 -0
- package/dist/components/example-frame/ExampleFrame.d.ts +53 -0
- package/dist/components/example-frame/ExampleFrame.d.ts.map +1 -0
- package/dist/components/file-upload/FileUpload.d.ts +176 -0
- package/dist/components/file-upload/FileUpload.d.ts.map +1 -0
- package/dist/components/hint/Hint.d.ts +27 -0
- package/dist/components/hint/Hint.d.ts.map +1 -0
- package/dist/components/index.css +6306 -5964
- package/dist/components/index.css.map +7 -1
- package/dist/components/index.d.ts +95 -2679
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +8750 -6666
- package/dist/components/index.js.map +7 -1
- package/dist/components/input/Input.d.ts +73 -0
- package/dist/components/input/Input.d.ts.map +1 -0
- package/dist/components/kbd/Kbd.d.ts +15 -0
- package/dist/components/kbd/Kbd.d.ts.map +1 -0
- package/dist/components/label/Label.d.ts +29 -0
- package/dist/components/label/Label.d.ts.map +1 -0
- package/dist/components/link-button/LinkButton.d.ts +18 -0
- package/dist/components/link-button/LinkButton.d.ts.map +1 -0
- package/dist/components/modal/Modal.d.ts +58 -0
- package/dist/components/modal/Modal.d.ts.map +1 -0
- package/dist/components/notification/Notification.d.ts +42 -0
- package/dist/components/notification/Notification.d.ts.map +1 -0
- package/dist/components/notification/NotificationStore.d.ts +18 -0
- package/dist/components/notification/NotificationStore.d.ts.map +1 -0
- package/dist/components/page-content/PageContent.d.ts +51 -0
- package/dist/components/page-content/PageContent.d.ts.map +1 -0
- package/dist/components/pagination/Pagination.d.ts +19 -0
- package/dist/components/pagination/Pagination.d.ts.map +1 -0
- package/dist/components/popover/Popover.d.ts +48 -0
- package/dist/components/popover/Popover.d.ts.map +1 -0
- package/dist/components/popover/popoverGeometry.d.ts +6 -0
- package/dist/components/popover/popoverGeometry.d.ts.map +1 -0
- package/dist/components/popover/usePopoverPosition.d.ts +18 -0
- package/dist/components/popover/usePopoverPosition.d.ts.map +1 -0
- package/dist/components/progress-bar/ProgressBar.d.ts +14 -0
- package/dist/components/progress-bar/ProgressBar.d.ts.map +1 -0
- package/dist/components/progress-circle/ProgressCircle.d.ts +33 -0
- package/dist/components/progress-circle/ProgressCircle.d.ts.map +1 -0
- package/dist/components/radio/Radio.d.ts +40 -0
- package/dist/components/radio/Radio.d.ts.map +1 -0
- package/dist/components/scroll-container/ScrollContainer.d.ts +42 -0
- package/dist/components/scroll-container/ScrollContainer.d.ts.map +1 -0
- package/dist/components/segmented-control/SegmentedControl.d.ts +40 -0
- package/dist/components/segmented-control/SegmentedControl.d.ts.map +1 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.d.ts +22 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.d.ts.map +1 -0
- package/dist/components/select/Select.d.ts +84 -0
- package/dist/components/select/Select.d.ts.map +1 -0
- package/dist/components/select/selectListbox.d.ts +13 -0
- package/dist/components/select/selectListbox.d.ts.map +1 -0
- package/dist/components/slider/Slider.d.ts +23 -0
- package/dist/components/slider/Slider.d.ts.map +1 -0
- package/dist/components/stepper/HorizontalStepper.d.ts +41 -0
- package/dist/components/stepper/HorizontalStepper.d.ts.map +1 -0
- package/dist/components/stepper/Stepper.d.ts +77 -0
- package/dist/components/stepper/Stepper.d.ts.map +1 -0
- package/dist/components/stepper/VerticalStepper.d.ts +41 -0
- package/dist/components/stepper/VerticalStepper.d.ts.map +1 -0
- package/dist/components/stepper/stepperAlignContext.d.ts +11 -0
- package/dist/components/stepper/stepperAlignContext.d.ts.map +1 -0
- package/dist/components/switch/Switch.d.ts +48 -0
- package/dist/components/switch/Switch.d.ts.map +1 -0
- package/dist/components/tabs/Tabs.d.ts +69 -0
- package/dist/components/tabs/Tabs.d.ts.map +1 -0
- package/dist/components/tag/Tag.d.ts +29 -0
- package/dist/components/tag/Tag.d.ts.map +1 -0
- package/dist/components/textarea/Textarea.d.ts +43 -0
- package/dist/components/textarea/Textarea.d.ts.map +1 -0
- package/dist/components/tooltip/Tooltip.d.ts +47 -0
- package/dist/components/tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/typography/Typography.d.ts +30 -0
- package/dist/components/typography/Typography.d.ts.map +1 -0
- package/dist/hooks/useControllableState.d.ts +8 -0
- package/dist/hooks/useControllableState.d.ts.map +1 -0
- package/dist/hooks/useEscapeKey.d.ts +7 -0
- package/dist/hooks/useEscapeKey.d.ts.map +1 -0
- package/dist/hooks/useFieldIds.d.ts +17 -0
- package/dist/hooks/useFieldIds.d.ts.map +1 -0
- package/dist/hooks/useFocusTrap.d.ts +16 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -0
- package/dist/hooks/useMergedRefs.d.ts +3 -0
- package/dist/hooks/useMergedRefs.d.ts.map +1 -0
- package/dist/hooks/useOutsideClick.d.ts +16 -0
- package/dist/hooks/useOutsideClick.d.ts.map +1 -0
- package/dist/hooks/useOverlayModal.d.ts +7 -0
- package/dist/hooks/useOverlayModal.d.ts.map +1 -0
- package/dist/hooks/usePosition.d.ts +41 -0
- package/dist/hooks/usePosition.d.ts.map +1 -0
- package/dist/hooks/useResponsiveMonths.d.ts +18 -0
- package/dist/hooks/useResponsiveMonths.d.ts.map +1 -0
- package/dist/hooks/useScrollLock.d.ts +8 -0
- package/dist/hooks/useScrollLock.d.ts.map +1 -0
- package/dist/icons/Icon.d.ts +13 -0
- package/dist/icons/Icon.d.ts.map +1 -0
- package/dist/icons/index.d.ts +40 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/index.css +6299 -7273
- package/dist/index.css.map +7 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8784 -6676
- package/dist/index.js.map +7 -1
- package/dist/internal/ControlSizeContext.d.ts +17 -0
- package/dist/internal/ControlSizeContext.d.ts.map +1 -0
- package/dist/internal/DividerContentContext.d.ts +4 -0
- package/dist/internal/DividerContentContext.d.ts.map +1 -0
- package/dist/internal/OverlayPortalLayerContext.d.ts +13 -0
- package/dist/internal/OverlayPortalLayerContext.d.ts.map +1 -0
- package/dist/internal/Portal.d.ts +8 -0
- package/dist/internal/Portal.d.ts.map +1 -0
- package/dist/internal/context.d.ts +11 -0
- package/dist/internal/context.d.ts.map +1 -0
- package/dist/internal/cx.d.ts +2 -0
- package/dist/internal/cx.d.ts.map +1 -0
- package/dist/internal/data-attributes.d.ts +6 -0
- package/dist/internal/data-attributes.d.ts.map +1 -0
- package/dist/internal/highlightTsxHtml.d.ts +3 -0
- package/dist/internal/highlightTsxHtml.d.ts.map +1 -0
- package/dist/internal/layoutPxFromPrimitives.d.ts +13 -0
- package/dist/internal/layoutPxFromPrimitives.d.ts.map +1 -0
- package/dist/internal/mergeRefs.d.ts +4 -0
- package/dist/internal/mergeRefs.d.ts.map +1 -0
- package/dist/internal/runtimeUnits.d.ts +3 -0
- package/dist/internal/runtimeUnits.d.ts.map +1 -0
- package/dist/internal/scrollAncestors.d.ts +3 -0
- package/dist/internal/scrollAncestors.d.ts.map +1 -0
- package/dist/internal/slot.d.ts +19 -0
- package/dist/internal/slot.d.ts.map +1 -0
- package/dist/internal/states.d.ts +87 -0
- package/dist/internal/states.d.ts.map +1 -0
- package/dist/layout/app-shell/AppShell.d.ts +54 -0
- package/dist/layout/app-shell/AppShell.d.ts.map +1 -0
- package/dist/layout/index.d.ts +7 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/sidebar/Sidebar.d.ts +241 -0
- package/dist/layout/sidebar/Sidebar.d.ts.map +1 -0
- package/dist/layout/sidebar/SidebarRoot.d.ts +51 -0
- package/dist/layout/sidebar/SidebarRoot.d.ts.map +1 -0
- package/dist/layout/sidebar/sidebar-context.d.ts +19 -0
- package/dist/layout/sidebar/sidebar-context.d.ts.map +1 -0
- package/dist/layout/sidebar/sidebarLayout.d.ts +12 -0
- package/dist/layout/sidebar/sidebarLayout.d.ts.map +1 -0
- package/dist/tokens/primitives.d.ts +390 -0
- package/dist/tokens/primitives.d.ts.map +1 -0
- package/dist/tokens/semantic.d.ts +732 -0
- package/dist/tokens/semantic.d.ts.map +1 -0
- package/dist/tokens/themes/dark.d.ts +143 -0
- package/dist/tokens/themes/dark.d.ts.map +1 -0
- package/dist/tokens/themes/light.d.ts +16 -0
- package/dist/tokens/themes/light.d.ts.map +1 -0
- package/package.json +14 -6
- package/src/components/accordion/COMPONENT.md +137 -0
- package/src/components/avatar/COMPONENT.md +100 -0
- package/src/components/badge/COMPONENT.md +78 -0
- package/src/components/banner/COMPONENT.md +118 -0
- package/src/components/breadcrumb/COMPONENT.md +94 -0
- package/src/components/button/COMPONENT.md +80 -0
- package/src/components/button-group/COMPONENT.md +83 -0
- package/src/components/card/COMPONENT.md +489 -0
- package/src/components/checkbox/COMPONENT.md +98 -0
- package/src/components/code-block/COMPONENT.md +58 -0
- package/src/components/color-picker/COMPONENT.md +149 -0
- package/src/components/command-menu/COMPONENT.md +167 -0
- package/src/components/data-table/COMPONENT.md +113 -0
- package/src/components/datepicker/COMPONENT.md +137 -0
- package/src/components/digit-input/COMPONENT.md +68 -0
- package/src/components/divider/COMPONENT.md +70 -0
- package/src/components/drawer/COMPONENT.md +149 -0
- package/src/components/dropdown/COMPONENT.md +192 -0
- package/src/components/file-upload/COMPONENT.md +200 -0
- package/src/components/hint/COMPONENT.md +67 -0
- package/src/components/input/COMPONENT.md +119 -0
- package/src/components/kbd/COMPONENT.md +59 -0
- package/src/components/label/COMPONENT.md +94 -0
- package/src/components/link-button/COMPONENT.md +60 -0
- package/src/components/modal/COMPONENT.md +105 -0
- package/src/components/notification/COMPONENT.md +120 -0
- package/src/components/pagination/COMPONENT.md +61 -0
- package/src/components/popover/COMPONENT.md +93 -0
- package/src/components/progress-bar/COMPONENT.md +59 -0
- package/src/components/progress-circle/COMPONENT.md +63 -0
- package/src/components/radio/COMPONENT.md +95 -0
- package/src/components/segmented-control/COMPONENT.md +86 -0
- package/src/components/segmented-progress-bar/COMPONENT.md +75 -0
- package/src/components/select/COMPONENT.md +175 -0
- package/src/components/slider/COMPONENT.md +62 -0
- package/src/components/stepper/COMPONENT.md +186 -0
- package/src/components/switch/COMPONENT.md +98 -0
- package/src/components/tabs/COMPONENT.md +114 -0
- package/src/components/tag/COMPONENT.md +67 -0
- package/src/components/textarea/COMPONENT.md +98 -0
- package/src/components/tooltip/COMPONENT.md +87 -0
- package/src/components/typography/COMPONENT.md +89 -0
- package/src/styles/theme-dark.css +43 -0
- package/src/styles/theme-light.css +43 -0
- package/src/styles/tokens.css +23 -4
- package/src/styles/tokens.test.ts +0 -27
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# FileUpload
|
|
2
|
+
|
|
3
|
+
**Проектирование по умолчанию:** при проектировании экранов и примеров изначально выбирай **`m`** для `size` (где есть ось размера), если явно не оговорено иное.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
Composable UI for choosing files: a `label` wrapping a hidden `input type="file"`, optional drag-and-drop styling, and building blocks for per-file rows (badge, name/meta, progress, actions).
|
|
8
|
+
|
|
9
|
+
**When to use**
|
|
10
|
+
|
|
11
|
+
- A visible drop zone plus native picker, with `accept`, `multiple`, and optional `disabled`.
|
|
12
|
+
- Drag-and-drop and click on the same target, with `onFilesChange` to feed app or server logic.
|
|
13
|
+
- Lists of uploads styled as cards with `FormatBadge`, typography slots, and optional `ItemProgress`.
|
|
14
|
+
- Dense modal layouts using `DropBody`, `Title`, `BrowseLink`, `ActionsRow`, and `Chip`, often with `inputRef` to open the dialog from nested controls.
|
|
15
|
+
|
|
16
|
+
**When not to use**
|
|
17
|
+
|
|
18
|
+
- A headless file field with no shared drop-zone affordance (use a plain `input` or minimal markup).
|
|
19
|
+
- Built-in upload, scanning, or storage integration (only UI and `File[]` callbacks).
|
|
20
|
+
- Automatic list state or remove/retry semantics inside the kit (`Item` is presentational).
|
|
21
|
+
- Scenarios where a non-`label` activation pattern is required without rethinking focus and hit targets.
|
|
22
|
+
|
|
23
|
+
## Composition
|
|
24
|
+
|
|
25
|
+
- **`FileUpload.Root`** — outer `label`, hidden file `input`, `ControlSizeProvider` for descendants. Omit `children` to get the default inner layout (`Icon`, `Title`, `Hint`, `BrowseLabel`). Replace `children` with `DropBody` / `Title` / `BrowseLink` / `ActionsRow` / `Chip` / `ChipLabel` for custom copy; use `inputRef` + `click()` from `BrowseLink` or `Chip` handlers because those elements stop propagation to the `label`.
|
|
26
|
+
- **File row** — `FileUpload.Item` (optional `variant`, `size`) → `ItemRow` → `FormatBadge` and `ItemMain`. Inside `ItemMain`, use `ItemTextGroup` with `ItemName` / `ItemMeta` / `ItemMetaSep`, or `ItemStack` with `ItemTryAgain` for error layouts; optional `ItemActions`. Below the row, optional `ItemProgress` (bar when `value` is set and `children` omitted) or `ItemFooter`.
|
|
27
|
+
|
|
28
|
+
### Minimal example
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { FileUpload } from "prime-ui-kit";
|
|
32
|
+
|
|
33
|
+
export function Example() {
|
|
34
|
+
return <FileUpload.Root />;
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Rules
|
|
39
|
+
|
|
40
|
+
- After each change or drop, `onFilesChange` receives a `File[]`; the input’s value is cleared so selecting the same file again still fires the callback.
|
|
41
|
+
- When `disabled` is set, the input is disabled, drops are ignored, and `data-disabled` is set on the `label` (`aria-disabled` is mirrored on the input).
|
|
42
|
+
- While a drag hovers the zone, the root `label` has `data-dragover` for styling.
|
|
43
|
+
- `BrowseLink` and `Chip` call `preventDefault` and `stopPropagation` on click — they do not open the picker unless you call `inputRef.current?.click()`.
|
|
44
|
+
- `FileUpload.Icon` and `FileUpload.FormatBadge` set `aria-hidden`; expose file meaning in visible text (e.g. `ItemName` / `ItemMeta`).
|
|
45
|
+
- `ItemProgress` renders `ProgressBar.Root` when `value` is defined and `children` are omitted; with no `value` and no `children`, only the empty wrapper is present.
|
|
46
|
+
- `DropBody` uses `pointer-events: none` on the wrapper so nested controls must remain interactive via nested `pointer-events` (as in the module styles).
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### FileUpload.Root
|
|
51
|
+
|
|
52
|
+
| Prop | Type | Default | Required | Description |
|
|
53
|
+
|------|------|---------|----------|-------------|
|
|
54
|
+
| size | `FileUploadSize` (`"s" \| "m" \| "l" \| "xl"`) | `"m"` | No | Tokens for the zone, built-in icon, and hint context. |
|
|
55
|
+
| appearance | `FileUploadAppearance` (`"dashed" \| "solid"`) | `"dashed"` | No | Dashed vs solid border and field-like background. |
|
|
56
|
+
| inputRef | `React.Ref<HTMLInputElement>` | — | No | Ref to the hidden input (e.g. programmatic `click()`). |
|
|
57
|
+
| accept | `string` | — | No | Native `accept`. |
|
|
58
|
+
| multiple | `boolean` | — | No | Multi-select in the file dialog. |
|
|
59
|
+
| disabled | `boolean` | — | No | Disables input and drops. |
|
|
60
|
+
| onFilesChange | `(files: File[]) => void` | — | No | Called after picker change or drop. |
|
|
61
|
+
| children | `React.ReactNode` | — | No | Replaces the default drop-zone body. |
|
|
62
|
+
| className | `string` | — | No | Class on the `label`. |
|
|
63
|
+
| …rest | `Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "children">` | — | No | `id`, `htmlFor`, ARIA, and other label attributes. |
|
|
64
|
+
|
|
65
|
+
### FileUpload.Icon
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Default | Required | Description |
|
|
68
|
+
|------|------|---------|----------|-------------|
|
|
69
|
+
| className | `string` | — | No | Wrapper class. |
|
|
70
|
+
| children | `React.ReactNode` | — | No | Icon or other content. |
|
|
71
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Passed to `span` (`aria-hidden` is set on the component). |
|
|
72
|
+
|
|
73
|
+
### FileUpload.Title
|
|
74
|
+
|
|
75
|
+
| Prop | Type | Default | Required | Description |
|
|
76
|
+
|------|------|---------|----------|-------------|
|
|
77
|
+
| tone | `"default" \| "muted"` | `"default"` | No | Text emphasis. |
|
|
78
|
+
| className | `string` | — | No | Class on the `p`. |
|
|
79
|
+
| children | `React.ReactNode` | — | No | Title text. |
|
|
80
|
+
| …rest | `React.HTMLAttributes<HTMLParagraphElement>` | — | No | Other paragraph attributes. |
|
|
81
|
+
|
|
82
|
+
### FileUpload.Hint
|
|
83
|
+
|
|
84
|
+
| Prop | Type | Default | Required | Description |
|
|
85
|
+
|------|------|---------|----------|-------------|
|
|
86
|
+
| className | `string` | — | No | Class passed to `Hint.Root`. |
|
|
87
|
+
| children | `React.ReactNode` | — | No | Hint content. |
|
|
88
|
+
| …rest | `React.HTMLAttributes<HTMLParagraphElement>` | — | No | Forwarded into `Hint.Root`; size follows `Root` context. |
|
|
89
|
+
|
|
90
|
+
### FileUpload.BrowseLabel
|
|
91
|
+
|
|
92
|
+
| Prop | Type | Default | Required | Description |
|
|
93
|
+
|------|------|---------|----------|-------------|
|
|
94
|
+
| className | `string` | — | No | `span` class. |
|
|
95
|
+
| children | `React.ReactNode` | — | No | Browse chip label. |
|
|
96
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Other `span` attributes. |
|
|
97
|
+
|
|
98
|
+
### FileUpload.BrowseLink
|
|
99
|
+
|
|
100
|
+
| Prop | Type | Default | Required | Description |
|
|
101
|
+
|------|------|---------|----------|-------------|
|
|
102
|
+
| type | `"button" \| "submit" \| "reset"` | `"button"` | No | Button `type`. |
|
|
103
|
+
| className | `string` | — | No | Class on the `button`. |
|
|
104
|
+
| onClick | `React.MouseEventHandler<HTMLButtonElement>` | — | No | Invoked after `preventDefault` / `stopPropagation`. |
|
|
105
|
+
| children | `React.ReactNode` | — | No | Link text. |
|
|
106
|
+
| …rest | `React.ButtonHTMLAttributes<HTMLButtonElement>` | — | No | Other button attributes. |
|
|
107
|
+
|
|
108
|
+
### FileUpload.DropBody
|
|
109
|
+
|
|
110
|
+
| Prop | Type | Default | Required | Description |
|
|
111
|
+
|------|------|---------|----------|-------------|
|
|
112
|
+
| className | `string` | — | No | Column wrapper class. |
|
|
113
|
+
| children | `React.ReactNode` | — | No | Custom layout. |
|
|
114
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | `div` attributes. |
|
|
115
|
+
|
|
116
|
+
### FileUpload.ActionsRow
|
|
117
|
+
|
|
118
|
+
| Prop | Type | Default | Required | Description |
|
|
119
|
+
|------|------|---------|----------|-------------|
|
|
120
|
+
| className | `string` | — | No | Row class. |
|
|
121
|
+
| children | `React.ReactNode` | — | No | Chips or other actions. |
|
|
122
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | `div` attributes. |
|
|
123
|
+
|
|
124
|
+
### FileUpload.Chip
|
|
125
|
+
|
|
126
|
+
| Prop | Type | Default | Required | Description |
|
|
127
|
+
|------|------|---------|----------|-------------|
|
|
128
|
+
| type | `"button" \| "submit" \| "reset"` | `"button"` | No | Button `type`. |
|
|
129
|
+
| className | `string` | — | No | Class on the `button`. |
|
|
130
|
+
| onClick | `React.MouseEventHandler<HTMLButtonElement>` | — | No | Invoked after `preventDefault` / `stopPropagation`. |
|
|
131
|
+
| children | `React.ReactNode` | — | No | Chip contents (e.g. icon + `ChipLabel`). |
|
|
132
|
+
| …rest | `React.ButtonHTMLAttributes<HTMLButtonElement>` | — | No | Other button attributes. |
|
|
133
|
+
|
|
134
|
+
### FileUpload.ChipLabel
|
|
135
|
+
|
|
136
|
+
| Prop | Type | Default | Required | Description |
|
|
137
|
+
|------|------|---------|----------|-------------|
|
|
138
|
+
| className | `string` | — | No | Class on the `span`. |
|
|
139
|
+
| children | `React.ReactNode` | — | No | Chip text. |
|
|
140
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | `span` attributes. |
|
|
141
|
+
|
|
142
|
+
### FileUpload.FormatBadge
|
|
143
|
+
|
|
144
|
+
| Prop | Type | Default | Required | Description |
|
|
145
|
+
|------|------|---------|----------|-------------|
|
|
146
|
+
| format | `string` | — | Yes | Source string; trimmed, truncated, and uppercased for display. |
|
|
147
|
+
| color | `FileUploadFormatBadgeColor` | `"gray"` | No | Badge palette (`gray`, `red`, `blue`, `green`, `orange`, `purple`, `sky`, `yellow`). |
|
|
148
|
+
| className | `string` | — | No | Extra class on the `span`. |
|
|
149
|
+
|
|
150
|
+
### FileUpload.Item
|
|
151
|
+
|
|
152
|
+
| Prop | Type | Default | Required | Description |
|
|
153
|
+
|------|------|---------|----------|-------------|
|
|
154
|
+
| variant | `FileUploadItemVariant` (`"default" \| "error"`) | `"default"` | No | Card emphasis. |
|
|
155
|
+
| size | `FileUploadSize` | `"m"` | No | Card and inline scale. |
|
|
156
|
+
| className | `string` | — | No | Container class. |
|
|
157
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | `div` attributes. |
|
|
158
|
+
|
|
159
|
+
### FileUpload.ItemRow, ItemMain, ItemStack, ItemTextGroup, ItemName, ItemMeta, ItemActions, ItemFooter
|
|
160
|
+
|
|
161
|
+
| Prop | Type | Default | Required | Description |
|
|
162
|
+
|------|------|---------|----------|-------------|
|
|
163
|
+
| className | `string` | — | No | Extra class. |
|
|
164
|
+
| children | `React.ReactNode` | — | No | Nested markup. |
|
|
165
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | `div` attributes. |
|
|
166
|
+
|
|
167
|
+
### FileUpload.ItemMetaSep
|
|
168
|
+
|
|
169
|
+
| Prop | Type | Default | Required | Description |
|
|
170
|
+
|------|------|---------|----------|-------------|
|
|
171
|
+
| className | `string` | — | No | `span` class. |
|
|
172
|
+
| children | `React.ReactNode` | — | No | Avoid relying on `children`; the glyph is fixed. |
|
|
173
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Passed to `span` (`aria-hidden`). |
|
|
174
|
+
|
|
175
|
+
### FileUpload.ItemTryAgain
|
|
176
|
+
|
|
177
|
+
| Prop | Type | Default | Required | Description |
|
|
178
|
+
|------|------|---------|----------|-------------|
|
|
179
|
+
| type | `"button" \| "submit" \| "reset"` | `"button"` | No | Button `type`. |
|
|
180
|
+
| className | `string` | — | No | Class on the `button`. |
|
|
181
|
+
| children | `React.ReactNode` | — | No | Label. |
|
|
182
|
+
| …rest | `React.ButtonHTMLAttributes<HTMLButtonElement>` | — | No | Other button attributes. |
|
|
183
|
+
|
|
184
|
+
### FileUpload.ItemProgress
|
|
185
|
+
|
|
186
|
+
| Prop | Type | Default | Required | Description |
|
|
187
|
+
|------|------|---------|----------|-------------|
|
|
188
|
+
| value | `number` | — | No | When set and `children` omitted, renders `ProgressBar.Root`. |
|
|
189
|
+
| max | `number` | — | No | Progress maximum (passed to `ProgressBar.Root`). |
|
|
190
|
+
| className | `string` | — | No | Wrapper class. |
|
|
191
|
+
| children | `React.ReactNode` | — | No | Custom indicator instead of the bar. |
|
|
192
|
+
|
|
193
|
+
## Related
|
|
194
|
+
|
|
195
|
+
- [Button](../button/COMPONENT.md) — actions that call `inputRef.current?.click()`, clear lists, or sit in `ItemActions`.
|
|
196
|
+
- [Hint](../hint/COMPONENT.md) — underlying primitive for `FileUpload.Hint`.
|
|
197
|
+
- [ProgressBar](../progress-bar/COMPONENT.md) — used inside `ItemProgress` when `value` is provided without custom `children`.
|
|
198
|
+
- [Label](../label/COMPONENT.md) — pairing copy with the zone in forms.
|
|
199
|
+
- [Avatar](../avatar/COMPONENT.md) — image preview next to upload actions on profile-style screens.
|
|
200
|
+
- [Divider](../divider/COMPONENT.md) — separating rows in attachment lists.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Hint
|
|
2
|
+
|
|
3
|
+
**Проектирование по умолчанию:** при проектировании экранов и примеров изначально выбирай **`m`** для `size` (где есть ось размера), если явно не оговорено иное.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
`Hint` is a compact line of helper or status text under a field: neutral copy, validation errors, or muted text for inactive inputs, with an optional leading icon.
|
|
8
|
+
|
|
9
|
+
- **When to use** — explain format rules, limits, units, or where a read-only value comes from under a single control.
|
|
10
|
+
- **When to use** — show validation or integration errors tied to a field without a separate notification block.
|
|
11
|
+
- **When to use** — align typography and spacing with the field via the same `size` tier as the control.
|
|
12
|
+
- **When not to use** — as the primary name of the field; use [Label](../label/COMPONENT.md) for that.
|
|
13
|
+
- **When not to use** — when [Input](../input/COMPONENT.md) already takes `hint` / `error` on the root, or [Textarea](../textarea/COMPONENT.md) already includes `Textarea.Hint` / `Textarea.Error` in the same field block.
|
|
14
|
+
- **When not to use** — for long prose or page-level messaging; prefer dedicated content or banner patterns.
|
|
15
|
+
|
|
16
|
+
## Composition
|
|
17
|
+
|
|
18
|
+
- **`Hint.Root`** — required wrapper: a `p` with `data-size` and `data-variant`, wrapped in `ControlSizeProvider` so size cascades to the icon slot.
|
|
19
|
+
- **`Hint.Icon`** — optional; render as the first child of `Hint.Root` when you need a decorative icon before the text.
|
|
20
|
+
- Order: `Hint.Root` contains optional `Hint.Icon` then text (or mixed `ReactNode`); no other named parts.
|
|
21
|
+
|
|
22
|
+
### Minimal example
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { Hint } from "prime-ui-kit";
|
|
26
|
+
|
|
27
|
+
export function FieldHint() {
|
|
28
|
+
return <Hint.Root>The invitation will be valid for 7 days.</Hint.Root>;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Rules
|
|
33
|
+
|
|
34
|
+
- **Variants:** `default` is secondary helper text; `error` is for validation or failure copy; `disabled` matches visually inactive fields (there is no separate `disabled` boolean on the root).
|
|
35
|
+
- **Sizing:** `size` is one of `s`, `m`, `l`, `xl`; pick the same tier as the paired field for consistent type and icon gap.
|
|
36
|
+
- **Semantics:** the root is always a `<p>` — there is no `asChild` or element polymorphism.
|
|
37
|
+
- **Association:** give `Hint.Root` a stable `id` and point the control at it with `aria-describedby` so assistive tech reads hint after the label.
|
|
38
|
+
- **Errors:** you may pass `role="alert"` or live-region attributes through `…rest` on `Hint.Root` if your form flow requires it.
|
|
39
|
+
- **`Hint.Icon`** is `aria-hidden`; do not rely on it to convey meaning without redundant text.
|
|
40
|
+
- **State:** text and `variant` are fully controlled by the parent (no built-in validation or open state).
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
### Hint.Root
|
|
45
|
+
|
|
46
|
+
| Prop | Type | Default | Required | Description |
|
|
47
|
+
|------|------|---------|----------|-------------|
|
|
48
|
+
| size | `HintSize` (`"s" \| "m" \| "l" \| "xl"`) | `"m"` | No | Nominal size aligned with the field. |
|
|
49
|
+
| variant | `"default" \| "error" \| "disabled"` | `"default"` | No | Text tone: secondary, danger, or disabled content. |
|
|
50
|
+
| children | `React.ReactNode` | — | No | Text; optionally include `Hint.Icon`. |
|
|
51
|
+
| className | `string` | — | No | Additional class on the root `p`. |
|
|
52
|
+
| …rest | `React.HTMLAttributes<HTMLParagraphElement>` | — | No | Native paragraph attributes (`id`, `role`, `aria-*`, etc.). |
|
|
53
|
+
|
|
54
|
+
### Hint.Icon
|
|
55
|
+
|
|
56
|
+
| Prop | Type | Default | Required | Description |
|
|
57
|
+
|------|------|---------|----------|-------------|
|
|
58
|
+
| children | `React.ReactNode` | — | Yes | Icon markup (for example SVG). |
|
|
59
|
+
| className | `string` | — | No | Additional class on the wrapper `span`. |
|
|
60
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Other attributes on the wrapper. |
|
|
61
|
+
|
|
62
|
+
## Related
|
|
63
|
+
|
|
64
|
+
- [Label](../label/COMPONENT.md) — primary field caption and `htmlFor` / `id` wiring.
|
|
65
|
+
- [Input](../input/COMPONENT.md) — field composition with optional built-in hint and error.
|
|
66
|
+
- [Textarea](../textarea/COMPONENT.md) — multiline field with the same metadata pattern where applicable.
|
|
67
|
+
- [Button](../button/COMPONENT.md) — actions that trigger validation and updated hint copy or `variant`.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Input
|
|
2
|
+
|
|
3
|
+
**Проектирование по умолчанию:** при проектировании экранов и примеров изначально выбирай **`m`** для `size` (где есть ось размера), если явно не оговорено иное.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
A composite single-line text field: optional label row outside the control, a bordered wrapper around the native `input`, and optional icons or text affixes inside the row. Hint and error text render below via the shared Hint primitive.
|
|
8
|
+
|
|
9
|
+
**When to use**
|
|
10
|
+
|
|
11
|
+
- Single-line text, email, password, search, tel, number, and other native `input` types in forms, filters, and settings.
|
|
12
|
+
- Fields that need a built-in label, optional secondary header text, hint, or error line tied to the input id.
|
|
13
|
+
- Dense layouts where `Input.Icon`, `Input.Affix`, or `Input.InlineAffix` clarify format (URL prefix, currency, search glyph) without extra wrappers.
|
|
14
|
+
|
|
15
|
+
**When not to use**
|
|
16
|
+
|
|
17
|
+
- Multiline or auto-growing text — use [Textarea](../textarea/COMPONENT.md).
|
|
18
|
+
- Fixed-length codes split into cells or heavy masking — use [DigitInput](../digit-input/COMPONENT.md) or app-level logic.
|
|
19
|
+
- When the label must be fully decoupled from the field chrome — consider [Label](../label/COMPONENT.md) plus a minimal field pattern instead of `label` on Root.
|
|
20
|
+
|
|
21
|
+
## Composition
|
|
22
|
+
|
|
23
|
+
- **`Input.Root`** — outer `div` with `data-size`, context provider, and `ControlSizeProvider`. Optional header: `label` (`htmlFor` → input id) and `optionalLabel`. Children (usually **`Input.Wrapper`**) sit between header and meta. If `hint` or `error` is set, a meta block renders **`Hint.Root`** rows for each.
|
|
24
|
+
- **`Input.Wrapper`** — flex row with field border and background; `data-size` and `data-has-error` come from context. Place **`Input.Field`**, **`Input.Icon`**, **`Input.Affix`**, and **`Input.InlineAffix`** inside in the order your layout needs.
|
|
25
|
+
- **`Input.Field`** — the actual `<input>`; receives `id`, merged `aria-describedby`, and `aria-invalid` from context.
|
|
26
|
+
- **`Input` namespace** — `Root`, `Wrapper`, `Field`, `Icon`, `Affix`, `InlineAffix`. **`useInputContext`** is exported for custom inner pieces that must align with the same size and ids.
|
|
27
|
+
|
|
28
|
+
### Minimal example
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { Input } from "prime-ui-kit";
|
|
32
|
+
|
|
33
|
+
export function Example() {
|
|
34
|
+
return (
|
|
35
|
+
<Input.Root>
|
|
36
|
+
<Input.Wrapper>
|
|
37
|
+
<Input.Field />
|
|
38
|
+
</Input.Wrapper>
|
|
39
|
+
</Input.Root>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Rules
|
|
45
|
+
|
|
46
|
+
- Use **`Input.Root`** `size` for control sizing; **`Input.Field`** omits the HTML `size` attribute (it is stripped from props) — do not rely on passing `size` to the native input.
|
|
47
|
+
- Passing **`error`** on Root sets **`hasError`** internally for visuals and `aria-invalid`; you may set **`hasError`** alone for validation without message text.
|
|
48
|
+
- Controlled usage: pass **`value`** / **`onChange`** (and related) on **`Input.Field`**. Uncontrolled: omit **`value`** and optionally use **`defaultValue`**.
|
|
49
|
+
- Prefer Root **`label`** for the common case; if there is no visible label, set **`aria-label`** or **`aria-labelledby`** on **`Input.Field`**.
|
|
50
|
+
- **`Input.Icon`**, **`Input.Affix`**, and **`Input.InlineAffix`** are **`aria-hidden`**; do not rely on them for the accessible name. You may append ids to **`aria-describedby`** on **`Input.Field`**; values merge with hint/error ids from context.
|
|
51
|
+
- Set **`id`** on Root when you need a stable input id (e.g. tests or external `htmlFor`). Otherwise an id is generated in **`useFieldIds`**.
|
|
52
|
+
- There is no separate **`variant`** prop: visual error state comes from **`error`** / **`hasError`**. Behavioral differences use native attributes on **`Input.Field`** (`type`, `autoComplete`, `inputMode`, `pattern`, `maxLength`, `disabled`, `readOnly`, **`required`**, etc.).
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
56
|
+
### Input.Root
|
|
57
|
+
|
|
58
|
+
| Prop | Type | Default | Required | Description |
|
|
59
|
+
|------|------|---------|----------|-------------|
|
|
60
|
+
| size | `"s" \| "m" \| "l" \| "xl"` | `"m"` | no | Control size from `--prime-sys-size-control-*` tokens. |
|
|
61
|
+
| hasError | `boolean` | `false` | no | Invalid state: propagates to wrapper and `aria-invalid` on the field; if `error` is set, treated as true. |
|
|
62
|
+
| label | `React.ReactNode` | — | no | Label; rendered as `<label htmlFor={inputId}>`. |
|
|
63
|
+
| optionalLabel | `React.ReactNode` | — | no | Secondary text in the header row. |
|
|
64
|
+
| hint | `React.ReactNode` | — | no | Hint below the field. |
|
|
65
|
+
| error | `React.ReactNode` | — | no | Error message; implies error styling and `hasError` behavior. |
|
|
66
|
+
| id | `string` | — | no | Explicit input id; otherwise generated via `useFieldIds`. |
|
|
67
|
+
| children | `React.ReactNode` | — | yes | Field body (typically `Input.Wrapper` with content). |
|
|
68
|
+
| className | `string` | — | no | Class on the root element. |
|
|
69
|
+
|
|
70
|
+
### Input.Wrapper
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Default | Required | Description |
|
|
73
|
+
|------|------|---------|----------|-------------|
|
|
74
|
+
| children | `React.ReactNode` | — | yes | Content inside the field border. |
|
|
75
|
+
| className | `string` | — | no | Extra class; `data-size` and `data-has-error` come from context. |
|
|
76
|
+
|
|
77
|
+
### Input.Field
|
|
78
|
+
|
|
79
|
+
| Prop | Type | Default | Required | Description |
|
|
80
|
+
|------|------|---------|----------|-------------|
|
|
81
|
+
| className | `string` | — | no | Class on the `input`. |
|
|
82
|
+
| aria-describedby | `string` | — | no | Appended to the id list from context (hint/error). |
|
|
83
|
+
| …rest | `Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">` | — | no | Standard `input` attributes except `size` (reserved for the design system). |
|
|
84
|
+
|
|
85
|
+
### Input.Icon
|
|
86
|
+
|
|
87
|
+
| Prop | Type | Default | Required | Description |
|
|
88
|
+
|------|------|---------|----------|-------------|
|
|
89
|
+
| side | `"start" \| "end"` | — | yes | Icon position inside the wrapper. |
|
|
90
|
+
| children | `React.ReactNode` | — | yes | Usually an icon component from the kit. |
|
|
91
|
+
| className | `string` | — | no | Class on the wrapping `span`. |
|
|
92
|
+
|
|
93
|
+
### Input.Affix
|
|
94
|
+
|
|
95
|
+
| Prop | Type | Default | Required | Description |
|
|
96
|
+
|------|------|---------|----------|-------------|
|
|
97
|
+
| side | `"start" \| "end"` | — | yes | Side of the block affix. |
|
|
98
|
+
| children | `React.ReactNode` | — | yes | Static text segment (e.g. URL prefix). |
|
|
99
|
+
| className | `string` | — | no | Class on the container. |
|
|
100
|
+
|
|
101
|
+
### Input.InlineAffix
|
|
102
|
+
|
|
103
|
+
| Prop | Type | Default | Required | Description |
|
|
104
|
+
|------|------|---------|----------|-------------|
|
|
105
|
+
| side | `"start" \| "end"` | — | yes | Side of the inline affix. |
|
|
106
|
+
| children | `React.ReactNode` | — | yes | Short text (e.g. currency symbol). |
|
|
107
|
+
| className | `string` | — | no | Class on the `span`. |
|
|
108
|
+
|
|
109
|
+
### useInputContext()
|
|
110
|
+
|
|
111
|
+
Returns `{ size, hasError, inputId, describedBy }` for building custom subcomponents that stay consistent with **`Input.Field`**.
|
|
112
|
+
|
|
113
|
+
## Related
|
|
114
|
+
|
|
115
|
+
- [Label](../label/COMPONENT.md)
|
|
116
|
+
- [Hint](../hint/COMPONENT.md)
|
|
117
|
+
- [Textarea](../textarea/COMPONENT.md)
|
|
118
|
+
- [Button](../button/COMPONENT.md)
|
|
119
|
+
- [DigitInput](../digit-input/COMPONENT.md)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Kbd
|
|
2
|
+
|
|
3
|
+
**Проектирование по умолчанию:** при проектировании экранов и примеров изначально выбирай **`m`** для `size` (где есть ось размера), если явно не оговорено иное.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
`Kbd` is a single-part primitive: `Kbd.Root` renders a semantic `kbd` with kit styling so key names and shortcut fragments read as UI chrome, not body copy.
|
|
8
|
+
|
|
9
|
+
- **When to use** — show hotkeys next to menu items, toolbar actions, or command labels in dense app chrome.
|
|
10
|
+
- **When to use** — mark one or a few keys inside helper text, field hints, or modal footers where the shortcut is part of the instruction.
|
|
11
|
+
- **When to use** — pair with the same `size` tier as nearby controls so typography and nested icons stay aligned with [Input](../input/COMPONENT.md), [Button](../button/COMPONENT.md), or other sized surfaces.
|
|
12
|
+
- **When not to use** — as the only actionable control; shortcuts still need a real [Button](../button/COMPONENT.md), [Link button](../link-button/COMPONENT.md), or focusable target.
|
|
13
|
+
- **When not to use** — when you need the element to listen for or mirror actual keyboard input; this component is display-only.
|
|
14
|
+
- **When not to use** — for long prose or documentation pages where plain text or a code font is clearer than chip-style keys.
|
|
15
|
+
|
|
16
|
+
## Composition
|
|
17
|
+
|
|
18
|
+
- **`Kbd`** exports **`Root` only** — a flat API with no nested parts or ordering rules beyond wrapping the key label (text, icons, or mixed `ReactNode`) inside **`Kbd.Root`**.
|
|
19
|
+
- **`Root`** renders a native **`kbd`**, applies `data-size`, and wraps **`children`** in **`ControlSizeProvider`** so nested **`Icon`** (and similar) pick up the same control-size context.
|
|
20
|
+
|
|
21
|
+
### Minimal example
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Kbd } from "prime-ui-kit";
|
|
25
|
+
|
|
26
|
+
export function Example() {
|
|
27
|
+
return <Kbd.Root>Esc</Kbd.Root>;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Rules
|
|
32
|
+
|
|
33
|
+
- **Sizing:** optional **`size`** is **`"s"` \| `"m"` \| `"l"` \| `"xl"`** (`KbdSize`). If omitted, the effective size comes from the nearest ancestor **`ControlSizeProvider`** (via **`useOptionalControlSize`**), mapped with **`controlSurfaceToInputSize`** — **`"xs"`** on the control surface becomes **`"s"`** on the `kbd`. If there is no context, the fallback is **`"m"`**.
|
|
34
|
+
- **Presentation only:** the component does not handle key events, focus management, or OS shortcut state; it only displays a label.
|
|
35
|
+
- **Semantics:** there is no **`asChild`** or element polymorphism — the root is always **`kbd`**.
|
|
36
|
+
- **Accessibility:** semantic **`kbd`** helps assistive tech distinguish key labels from surrounding text. For chord hints, prefer several **`Kbd.Root`** instances with short separators (**`+`**, “or”) **outside** the keys, or mark decorative separators with **`aria-hidden`**, so they are not announced as part of each key. Use **`title`** (or visible copy) when the shortcut needs extra explanation; do not rely on surface color alone for meaning.
|
|
37
|
+
- **Platform copy:** glyphs such as **⌘** vs **Ctrl** are a product/i18n choice; the kit does not normalize platform key names.
|
|
38
|
+
- **Styling:** one built-in look (raised surface, border, light shadow). Further changes go through **`className`** or project styles, not a separate **`variant`** prop.
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
### Kbd.Root
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Default | Required | Description |
|
|
45
|
+
|------|------|---------|----------|-------------|
|
|
46
|
+
| size | `KbdSize` (`"s" \| "m" \| "l" \| "xl"`) | from context or `"m"` | No | Nominal size; without the prop, taken from `ControlSizeProvider` if present, otherwise `"m"`; `xs` context maps to `s`. |
|
|
47
|
+
| children | `React.ReactNode` | — | Yes | Key label, icons, or mixed content. |
|
|
48
|
+
| className | `string` | — | No | Additional class on the `kbd`. |
|
|
49
|
+
| …rest | `Omit<React.HTMLAttributes<HTMLElement>, "size">` | — | No | Native attributes (`title`, `hidden`, `aria-*`, `data-*`, etc.). |
|
|
50
|
+
|
|
51
|
+
## Related
|
|
52
|
+
|
|
53
|
+
- [Button](../button/COMPONENT.md) — primary action a shortcut often refers to.
|
|
54
|
+
- [Link button](../link-button/COMPONENT.md) — text-style actions that may show a key hint beside the label.
|
|
55
|
+
- [Input](../input/COMPONENT.md) — fields whose `hint` or label area can include `Kbd`.
|
|
56
|
+
- [Textarea](../textarea/COMPONENT.md) — multiline fields with the same hint pattern where applicable.
|
|
57
|
+
- [Select](../select/COMPONENT.md) — triggers and lists that may document shortcuts.
|
|
58
|
+
- [Tooltip](../tooltip/COMPONENT.md) — longer explanations that can repeat keys with `Kbd`.
|
|
59
|
+
- [Command menu](../command-menu/COMPONENT.md) — lists that commonly show per-item shortcuts.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Label
|
|
2
|
+
|
|
3
|
+
**Проектирование по умолчанию:** при проектировании экранов и примеров изначально выбирай **`m`** для `size` (где есть ось размера), если явно не оговорено иное.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
Composite caption for form fields: `Label.Root` is a native `label` with optional slots `Label.Icon`, `Label.Asterisk`, and `Label.Sub` for icon, required marker, and secondary text.
|
|
8
|
+
|
|
9
|
+
- **Use** to associate visible text with a control via `htmlFor` / `id` or by nesting the control inside the root.
|
|
10
|
+
- **Use** when you want a consistent type scale (`size`) and optional icon or second-line hint in one label row.
|
|
11
|
+
- **Use** `Label.Asterisk` for a visual required marker next to the caption.
|
|
12
|
+
- **Do not use** as a replacement for field validation messages or long help copy; pair with [Hint](../hint/COMPONENT.md) or similar when you need status or errors below the field.
|
|
13
|
+
- **Do not use** expecting the label to set `required` on inputs; that remains on the control.
|
|
14
|
+
- **Do not use** `Label` as a non-label wrapper; the root is always a `label` element (no polymorphic `asChild`).
|
|
15
|
+
|
|
16
|
+
## Composition
|
|
17
|
+
|
|
18
|
+
- **`Label.Root`** — `<label>`; sets `data-size` (from `size`, default `m`) and `data-disabled` when `disabled`. Wraps children in `LabelSizeContext` so slots inherit the same size.
|
|
19
|
+
- **`Label.Icon`** — `<span>` before or beside the main text; forwards label size to children via `ControlSizeProvider` (e.g. for kit `Icon` sizing).
|
|
20
|
+
- **`Label.Asterisk`** — `<span>` for the required marker; default child text is `*` if `children` is omitted.
|
|
21
|
+
- **`Label.Sub`** — `<span>` for secondary line or hint text on the same label.
|
|
22
|
+
- Slot order in markup is flexible; keep reading order sensible for screen readers (e.g. icon, title, asterisk, sub).
|
|
23
|
+
|
|
24
|
+
### Minimal example
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { Label } from "prime-ui-kit";
|
|
28
|
+
|
|
29
|
+
export function Example() {
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<Label.Root htmlFor="field-id">Caption</Label.Root>
|
|
33
|
+
<input id="field-id" />
|
|
34
|
+
</>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Rules
|
|
40
|
+
|
|
41
|
+
- **Association:** set **`htmlFor` on `Label.Root`** to match the control’s **`id`**, or place the interactive control inside **`Label.Root`** so the caption is programmatically linked.
|
|
42
|
+
- **`disabled` on `Label.Root`:** sets **`aria-disabled`** and **`data-disabled`** for muted styling; keep the actual field non-interactive (`disabled`, `readOnly`, etc.) or behavior will not match the label-only state.
|
|
43
|
+
- **`Label.Icon`:** when the icon is decorative and the visible label text is sufficient, mark the icon **`aria-hidden`**.
|
|
44
|
+
- **`Label.Asterisk`** is visual-only; expose required state on the control with **`required`** / **`aria-required`** and errors via hint or validation UI as needed.
|
|
45
|
+
- There is no separate **`variant`** prop; appearance follows **`size`** and slot composition (asterisk uses danger-accent styling from the theme).
|
|
46
|
+
- The root does **not** implement **`asChild`**; it is always a **`label`**.
|
|
47
|
+
- Nesting an input inside **`Label.Root`** is valid HTML; the common kit pattern is sibling **`Label.Root`** + control with **`htmlFor`** / **`id`**.
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
### Label.Root
|
|
52
|
+
|
|
53
|
+
| Prop | Type | Default | Required | Description |
|
|
54
|
+
|------|------|---------|----------|-------------|
|
|
55
|
+
| size | `"s" \| "m" \| "l" \| "xl"` | `"m"` | No | Type scale, spacing, and size context for nested slots (e.g. `Label.Icon`) |
|
|
56
|
+
| disabled | `boolean` | — | No | Disabled look; sets `aria-disabled` and `data-disabled` |
|
|
57
|
+
| htmlFor | `string` | — | No | `id` of the associated control |
|
|
58
|
+
| className | `string` | — | No | Additional class on the root |
|
|
59
|
+
| children | `React.ReactNode` | — | No | Text and `Label.Icon`, `Label.Asterisk`, `Label.Sub` |
|
|
60
|
+
| …rest | `Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "size">` | — | No | Other native `label` attributes (`size` is reserved for the design-system prop) |
|
|
61
|
+
|
|
62
|
+
### Label.Icon
|
|
63
|
+
|
|
64
|
+
| Prop | Type | Default | Required | Description |
|
|
65
|
+
|------|------|---------|----------|-------------|
|
|
66
|
+
| className | `string` | — | No | Additional class on the wrapper |
|
|
67
|
+
| children | `React.ReactNode` | — | No | Typically an icon; receives control size from label context |
|
|
68
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Other `span` attributes |
|
|
69
|
+
|
|
70
|
+
### Label.Asterisk
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Default | Required | Description |
|
|
73
|
+
|------|------|---------|----------|-------------|
|
|
74
|
+
| className | `string` | — | No | Additional class on the wrapper |
|
|
75
|
+
| children | `React.ReactNode` | `"*"` | No | Overrides the default asterisk character when provided |
|
|
76
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Other `span` attributes |
|
|
77
|
+
|
|
78
|
+
### Label.Sub
|
|
79
|
+
|
|
80
|
+
| Prop | Type | Default | Required | Description |
|
|
81
|
+
|------|------|---------|----------|-------------|
|
|
82
|
+
| className | `string` | — | No | Additional class on the wrapper |
|
|
83
|
+
| children | `React.ReactNode` | — | No | Secondary line under the main caption |
|
|
84
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Other `span` attributes |
|
|
85
|
+
|
|
86
|
+
## Related
|
|
87
|
+
|
|
88
|
+
- [Input](../input/COMPONENT.md)
|
|
89
|
+
- [Textarea](../textarea/COMPONENT.md)
|
|
90
|
+
- [Select](../select/COMPONENT.md)
|
|
91
|
+
- [Checkbox](../checkbox/COMPONENT.md)
|
|
92
|
+
- [Radio](../radio/COMPONENT.md)
|
|
93
|
+
- [Switch](../switch/COMPONENT.md)
|
|
94
|
+
- [Hint](../hint/COMPONENT.md)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# LinkButton
|
|
2
|
+
|
|
3
|
+
**Проектирование по умолчанию:** при проектировании экранов и примеров изначально выбирай **`m`** для `size` (где есть ось размера), если явно не оговорено иное.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
Text-style navigation control: one subpart (`LinkButton.Root`) with control typography and padding, underline on hover and `:focus-visible`, and four size options (`s`–`xl`).
|
|
8
|
+
|
|
9
|
+
- **Use** for in-app routes and sections when the UI should read as a **link**, not a filled button.
|
|
10
|
+
- **Use** inline in copy (help, legal, helper text) where a compact or scaled text link fits the layout.
|
|
11
|
+
- **Use** when nested icons should follow **control** size tokens—`size` sets **`ControlSizeProvider`** for children.
|
|
12
|
+
- **Do not use** for actions that do not navigate (submit, toggle, open dialogs); use **Button** or another control.
|
|
13
|
+
- **Do not use** expecting **`asChild`** or polymorphic roots; you cannot attach these styles to a child router **`Link`** via one prop.
|
|
14
|
+
- **Do not use** **`disabled`** to mean “still in tab order with full link semantics”; disabled mode removes focus and drops anchor attributes (see Rules).
|
|
15
|
+
|
|
16
|
+
## Composition
|
|
17
|
+
|
|
18
|
+
- **`LinkButton`** — namespace object with **`LinkButton.Root`** only; import **`LinkButton`** from **`prime-ui-kit`** and render **`LinkButton.Root`**.
|
|
19
|
+
- **`LinkButton.Root`** — when **`disabled`** is false (default), renders **`<a>`** with anchor attributes from props and wraps **`children`** in **`ControlSizeProvider`** for **`size`**.
|
|
20
|
+
- When **`disabled`** is true, renders **`<span role="link">`** with **`aria-disabled="true"`**, **`tabIndex={-1}`**, and the same size context—no **`href`** or other spread anchor props on the DOM node.
|
|
21
|
+
|
|
22
|
+
### Minimal example
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { LinkButton } from "prime-ui-kit";
|
|
26
|
+
|
|
27
|
+
export function Example() {
|
|
28
|
+
return <LinkButton.Root href="/">Home</LinkButton.Root>;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Rules
|
|
33
|
+
|
|
34
|
+
- **`size`** defaults to **`m`**; valid values are **`"s"`**, **`"m"`**, **`"l"`**, **`"xl"`** (control token tier).
|
|
35
|
+
- With **`disabled={true}`**, **`...rest`** from **`React.AnchorHTMLAttributes`** is **not** applied—the root is a **`span`**, so **`href`**, **`target`**, **`onClick`**, and similar props have **no effect** on the output; do not rely on them for accessibility or behavior in that mode.
|
|
36
|
+
- Active link: native **`<a>`** with your **`href`**; keyboard **Enter** activates like a normal link.
|
|
37
|
+
- Disabled presentation: **`role="link"`**, **`aria-disabled="true"`**, **`tabIndex={-1}`**—not in tab order by default; avoid if the item should remain focusable as a link.
|
|
38
|
+
- For **icon-only** links, provide a name (**`aria-label`** or visible text).
|
|
39
|
+
- For **`target="_blank"`**, set **`rel="noopener noreferrer"`** (and warn in UI if policy requires it).
|
|
40
|
+
- There is no loading or error variant; for async work without navigation, prefer **Button** (or another pattern).
|
|
41
|
+
- One visual style only (no **`variant`**); hierarchy comes from **`size`** and surrounding layout. No built-in **`fullWidth`**—use layout or **`className`** on the root if you need block-level stretch.
|
|
42
|
+
- **`ref`** is forwarded to the DOM root (**`<a>`** or the disabled **`<span>`**); the public ref type is **`HTMLAnchorElement`** even though the disabled node is a **`span`**.
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
### LinkButton.Root
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Required | Description |
|
|
49
|
+
|------|------|---------|----------|-------------|
|
|
50
|
+
| size | `"s" \| "m" \| "l" \| "xl"` | `"m"` | No | Control height / type scale; size context for nested icons via `ControlSizeProvider`. |
|
|
51
|
+
| disabled | `boolean` | `false` | No | Renders `span` with `role="link"` instead of `a`; no navigation. |
|
|
52
|
+
| children | `React.ReactNode` | — | No | Link content (text, icons, etc.). |
|
|
53
|
+
| className | `string` | — | No | Additional class on the root element. |
|
|
54
|
+
| …rest | `React.AnchorHTMLAttributes<HTMLAnchorElement>` | — | No | Forwarded to `<a>` only when `disabled` is false (e.g. `href`, `target`, `rel`, `download`, `onClick`, `aria-*`, `tabIndex`). |
|
|
55
|
+
|
|
56
|
+
## Related
|
|
57
|
+
|
|
58
|
+
- [Button](../button/COMPONENT.md) — actions, forms, loading/disabled without link semantics.
|
|
59
|
+
- [Breadcrumb](../breadcrumb/COMPONENT.md) — trail navigation; items may use `LinkButton` internally.
|
|
60
|
+
- [Typography](../typography/COMPONENT.md) — body text and inline links without control padding; `LinkButton` matches control alignment and scale.
|