@smartsoft001/claude-plugins 2.194.0 → 2.195.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/.claude-plugin/marketplace.json +14 -3
- package/README.md +19 -4
- package/package.json +3 -3
- package/plugins/smart-angular/.claude-plugin/plugin.json +6 -0
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/SKILL.md +1 -1
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-claude-config.md +13 -9
- package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/patch-delta.md +1 -1
- package/plugins/{smart → smart-core}/.claude-plugin/README.md +31 -16
- package/plugins/{smart → smart-core}/.claude-plugin/merge-permissions.js +7 -6
- package/plugins/smart-core/.claude-plugin/plugin.json +5 -0
- package/plugins/{smart → smart-core}/.claude-plugin/settings.template.json +2 -2
- package/plugins/{smart → smart-core}/hooks/README.md +1 -1
- package/plugins/{smart → smart-core}/skills/audit-log/SKILL.md +2 -2
- package/plugins/{smart → smart-core}/skills/format-code/SKILL.md +1 -1
- package/plugins/smart-react/.claude-plugin/plugin.json +6 -0
- package/plugins/smart-react/agents/react-components.md +260 -0
- package/plugins/smart-react/skills/react-components-accordion/SKILL.md +204 -0
- package/plugins/smart-react/skills/react-components-action-panel/SKILL.md +191 -0
- package/plugins/smart-react/skills/react-components-alert/SKILL.md +244 -0
- package/plugins/smart-react/skills/react-components-app/SKILL.md +236 -0
- package/plugins/smart-react/skills/react-components-avatar/SKILL.md +176 -0
- package/plugins/smart-react/skills/react-components-badge/SKILL.md +165 -0
- package/plugins/smart-react/skills/react-components-breadcrumbs/SKILL.md +183 -0
- package/plugins/smart-react/skills/react-components-button/SKILL.md +239 -0
- package/plugins/smart-react/skills/react-components-button-group/SKILL.md +187 -0
- package/plugins/smart-react/skills/react-components-calendar/SKILL.md +270 -0
- package/plugins/smart-react/skills/react-components-card/SKILL.md +201 -0
- package/plugins/smart-react/skills/react-components-card-heading/SKILL.md +133 -0
- package/plugins/smart-react/skills/react-components-command-palette/SKILL.md +228 -0
- package/plugins/smart-react/skills/react-components-container/SKILL.md +134 -0
- package/plugins/smart-react/skills/react-components-date-edit/SKILL.md +186 -0
- package/plugins/smart-react/skills/react-components-date-range/SKILL.md +259 -0
- package/plugins/smart-react/skills/react-components-description-list/SKILL.md +144 -0
- package/plugins/smart-react/skills/react-components-detail/SKILL.md +272 -0
- package/plugins/smart-react/skills/react-components-details/SKILL.md +250 -0
- package/plugins/smart-react/skills/react-components-divider/SKILL.md +128 -0
- package/plugins/smart-react/skills/react-components-drawer/SKILL.md +165 -0
- package/plugins/smart-react/skills/react-components-dropdown/SKILL.md +194 -0
- package/plugins/smart-react/skills/react-components-empty-state/SKILL.md +202 -0
- package/plugins/smart-react/skills/react-components-export/SKILL.md +120 -0
- package/plugins/smart-react/skills/react-components-feed/SKILL.md +171 -0
- package/plugins/smart-react/skills/react-components-form/SKILL.md +319 -0
- package/plugins/smart-react/skills/react-components-grid-list/SKILL.md +172 -0
- package/plugins/smart-react/skills/react-components-icon/SKILL.md +117 -0
- package/plugins/smart-react/skills/react-components-import/SKILL.md +113 -0
- package/plugins/smart-react/skills/react-components-info/SKILL.md +147 -0
- package/plugins/smart-react/skills/react-components-input/SKILL.md +406 -0
- package/plugins/smart-react/skills/react-components-list/SKILL.md +384 -0
- package/plugins/smart-react/skills/react-components-list-container/SKILL.md +105 -0
- package/plugins/smart-react/skills/react-components-loader/SKILL.md +126 -0
- package/plugins/smart-react/skills/react-components-media-object/SKILL.md +130 -0
- package/plugins/smart-react/skills/react-components-modal/SKILL.md +266 -0
- package/plugins/smart-react/skills/react-components-multi-column-layout/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-navbar/SKILL.md +211 -0
- package/plugins/smart-react/skills/react-components-notification/SKILL.md +223 -0
- package/plugins/smart-react/skills/react-components-overlays/SKILL.md +182 -0
- package/plugins/smart-react/skills/react-components-page/SKILL.md +224 -0
- package/plugins/smart-react/skills/react-components-page-heading/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-paging/SKILL.md +183 -0
- package/plugins/smart-react/skills/react-components-password-strength/SKILL.md +149 -0
- package/plugins/smart-react/skills/react-components-progress-bars/SKILL.md +195 -0
- package/plugins/smart-react/skills/react-components-searchbar/SKILL.md +150 -0
- package/plugins/smart-react/skills/react-components-section-heading/SKILL.md +138 -0
- package/plugins/smart-react/skills/react-components-select-menu/SKILL.md +168 -0
- package/plugins/smart-react/skills/react-components-sidebar-layout/SKILL.md +155 -0
- package/plugins/smart-react/skills/react-components-sidebar-navigation/SKILL.md +277 -0
- package/plugins/smart-react/skills/react-components-sign-in-form/SKILL.md +228 -0
- package/plugins/smart-react/skills/react-components-stacked-layout/SKILL.md +146 -0
- package/plugins/smart-react/skills/react-components-stacked-list/SKILL.md +156 -0
- package/plugins/smart-react/skills/react-components-stats/SKILL.md +149 -0
- package/plugins/smart-react/skills/react-components-table/SKILL.md +222 -0
- package/plugins/smart-react/skills/react-components-tabs/SKILL.md +189 -0
- package/plugins/smart-react/skills/react-components-textarea/SKILL.md +202 -0
- package/plugins/smart-react/skills/react-components-toggle/SKILL.md +157 -0
- package/plugins/smart-react/skills/react-components-vertical-navigation/SKILL.md +212 -0
- package/plugins/smart-react/skills/react-forms/SKILL.md +272 -0
- package/plugins/smart-react/skills/react-provider/SKILL.md +368 -0
- package/plugins/smart-react/skills/smart-crud-react/SKILL.md +410 -0
- package/plugins/smart/.claude-plugin/plugin.json +0 -5
- /package/plugins/{smart/agents/angular-components/AGENT.md → smart-angular/agents/angular-components.md} +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-accordion/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-action-panel/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-alert/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-avatar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-badge/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-breadcrumbs/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-button/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-button-group/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-calendar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-card/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-card-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-command-palette/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-container/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-date-edit/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-date-range/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-description-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-detail/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-details/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-divider/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-drawer/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-dropdown/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-empty-state/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-feed/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-form/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-grid-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-icon/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-info/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-input/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-list-container/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-media-object/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-modal/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-multi-column-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-navbar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-notification/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-page/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-page-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-paging/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-password-strength/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-progress-bars/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-searchbar/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-section-heading/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-select-menu/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-navigation/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-sign-in-form/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-layout/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-list/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-stats/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-table/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-tabs/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-textarea/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-toggle/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/angular-components-vertical-navigation/SKILL.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-app.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-shared-lib.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/version-resolution.md +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/derive-prefix.sh +0 -0
- /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/verify-scaffold.sh +0 -0
- /package/plugins/{smart → smart-angular}/skills/smart-crud/SKILL.md +0 -0
- /package/plugins/{smart → smart-core}/hooks/CONFIG.md +0 -0
- /package/plugins/{smart → smart-core}/hooks/audit_logger.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/auto_format.sh +0 -0
- /package/plugins/{smart → smart-core}/hooks/hooks.json +0 -0
- /package/plugins/{smart → smart-core}/hooks/safety_validator.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/sensitive_file_blocker.py +0 -0
- /package/plugins/{smart → smart-core}/hooks/skill_validator.py +0 -0
- /package/plugins/{smart → smart-core}/skills/project-conventions/SKILL.md +0 -0
- /package/plugins/{smart → smart-core}/skills/safety-check/SKILL.md +0 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-textarea
|
|
3
|
+
description: SmartTextarea React component API (@smartsoft001/react) — multi-line text field (comment box) with label, rows, maxLength, actions reported with the text (onActionClick), avatar/toolbar/preview/footer slots and five preset variants, controlled value/onValueChange or uncontrolled defaultValue, the 'textarea' registry key, SmartTextareaPreset and useTextarea.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Textarea (`SmartTextarea`)
|
|
8
|
+
|
|
9
|
+
`SmartTextarea` is a multi-line text field shaped for comment and message boxes: a label, the `<textarea>`, and a bar of `actions` (e.g. Post, Attach) reported through `onActionClick({ actionId, value })` with the current text, plus slots for an avatar, a toolbar, a preview and a footer. The text is controlled (`value` + `onValueChange`) or kept inside (`defaultValue`). `SmartTextareaPreset` adds five `variant`s (including Write / Preview tabs), focuses on mount with `autoFocus` and shows a character counter for `maxLength`.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- A comment, reply or message box with a submit action
|
|
14
|
+
- A plain multi-line field outside a model-driven form
|
|
15
|
+
- Restyling every textarea (the `textarea` registry key)
|
|
16
|
+
|
|
17
|
+
Inside a form generated from a model, `longText` fields render their own input (`react-components-input`).
|
|
18
|
+
|
|
19
|
+
## Exports
|
|
20
|
+
|
|
21
|
+
All from `@smartsoft001/react`.
|
|
22
|
+
|
|
23
|
+
| Export | Kind | What it is |
|
|
24
|
+
| ----------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
25
|
+
| `SmartTextarea` | component | Renders the implementation registered as `components.textarea` on `SmartProvider`, `SmartTextareaStandard` by default. |
|
|
26
|
+
| `SmartTextareaPreset` | component | Styled textarea variation (preset). |
|
|
27
|
+
| `SmartTextareaStandard` | component | The default, unstyled textarea. |
|
|
28
|
+
| `useTextarea` | hook | The behaviour every textarea variant shares: the `value`, controlled through `value` / `onValueChange` or kept internally from `defaultValue`, and `actionClick()`, which reports an action with the current text unless `disabled`. |
|
|
29
|
+
|
|
30
|
+
The preset's class helpers (`textareaFieldClasses`, `textareaFrameClasses`, `textareaBarClasses`, `textareaBarInside`, `textareaActionClasses`, `textareaTabClasses`, `TEXTAREA_ROOT`, `TEXTAREA_AVATAR`, `TEXTAREA_BODY`, `TEXTAREA_LABEL`, `TEXTAREA_REQUIRED`, `TEXTAREA_TOOLBAR`, `TEXTAREA_ACTIONS`, `TEXTAREA_TABS`, `TEXTAREA_PREVIEW_PANE`, `TEXTAREA_PREVIEW_BELOW`, `TEXTAREA_COUNTER`, `TEXTAREA_FOOTER`) are exported too, for a custom implementation that wants the preset look.
|
|
31
|
+
|
|
32
|
+
## Props and Types
|
|
33
|
+
|
|
34
|
+
### `SmartTextareaProps`
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Default | Description |
|
|
37
|
+
| ---------------- | --------------------------------------- | ------- | -------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `value?` | `string` | — | The text. Leave it `undefined` for an uncontrolled textarea that starts from `defaultValue`. |
|
|
39
|
+
| `defaultValue?` | `string` | `''` | Initial text of an uncontrolled textarea. |
|
|
40
|
+
| `onValueChange?` | `(value: string) => void` | — | Called with the edited text. |
|
|
41
|
+
| `placeholder?` | `string` | `''` | Placeholder of the field. |
|
|
42
|
+
| `disabled?` | `boolean` | `false` | Disables the field; action clicks are ignored. |
|
|
43
|
+
| `options?` | `ITextareaOptions` | — | Field attributes, actions and slots. |
|
|
44
|
+
| `className?` | `string` | — | Classes on the root element. |
|
|
45
|
+
| `onActionClick?` | `(event: ITextareaActionClick) => void` | — | An action was clicked; reported with the current text. |
|
|
46
|
+
|
|
47
|
+
### `ITextareaOptions`
|
|
48
|
+
|
|
49
|
+
| Field | Type | Default | Description |
|
|
50
|
+
| ------------- | ---------------------- | ---------- | ---------------------------------------------------------------------------------- |
|
|
51
|
+
| `rows?` | `number` | `3` | Visible rows. |
|
|
52
|
+
| `maxLength?` | `number` | — | Maximum length (a counter in the preset). |
|
|
53
|
+
| `variant?` | `SmartTextareaVariant` | `'simple'` | Preset look; the standard ignores it. |
|
|
54
|
+
| `label?` | `string` | — | Label of the field. |
|
|
55
|
+
| `name?` | `string` | — | `name` attribute. |
|
|
56
|
+
| `required?` | `boolean` | — | `required` attribute. |
|
|
57
|
+
| `autoFocus?` | `boolean` | — | Preset: focuses the field on mount. |
|
|
58
|
+
| `ariaLabel?` | `string` | — | Accessible name when there is no label. |
|
|
59
|
+
| `actions?` | `ITextareaAction[]` | `[]` | Buttons of the action bar. |
|
|
60
|
+
| `avatarTpl?` | `ReactNode` | — | Avatar beside the field. |
|
|
61
|
+
| `toolbarTpl?` | `ReactNode` | — | Toolbar (formatting, attachments). |
|
|
62
|
+
| `previewTpl?` | `ReactNode` | — | Preview content (the preset's `with-preview` variant shows it on the Preview tab). |
|
|
63
|
+
| `footerTpl?` | `ReactNode` | — | A slot below. |
|
|
64
|
+
|
|
65
|
+
### `ITextareaActionClick`
|
|
66
|
+
|
|
67
|
+
Payload of `onActionClick`.
|
|
68
|
+
|
|
69
|
+
| Field | Type | Default | Description |
|
|
70
|
+
| ---------- | -------- | -------- | ---------------------------------- |
|
|
71
|
+
| `actionId` | `string` | required | The `id` of the clicked action. |
|
|
72
|
+
| `value` | `string` | required | The text at the time of the click. |
|
|
73
|
+
|
|
74
|
+
### `ITextareaAction`
|
|
75
|
+
|
|
76
|
+
| Field | Type | Default | Description |
|
|
77
|
+
| ---------- | ------------------------------------- | ---------- | --------------------------------------- |
|
|
78
|
+
| `id` | `string` | required | Reported as `actionId`. |
|
|
79
|
+
| `label?` | `string` | — | Button text. |
|
|
80
|
+
| `iconTpl?` | `ReactNode` | — | Icon of the button. |
|
|
81
|
+
| `variant?` | `'primary' \| 'secondary' \| 'ghost'` | `'simple'` | `primary`, `secondary` or `ghost` look. |
|
|
82
|
+
|
|
83
|
+
### Related types
|
|
84
|
+
|
|
85
|
+
- `SmartTextareaVariant`: `'simple' \| 'with-avatar-actions' \| 'with-underline' \| 'with-pill-actions' \| 'with-preview'`
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { useState } from 'react';
|
|
91
|
+
|
|
92
|
+
import { SmartAvatarPreset, SmartTextareaPreset } from '@smartsoft001/react';
|
|
93
|
+
|
|
94
|
+
export function CommentBox({ onPost }: { onPost: (text: string) => void }) {
|
|
95
|
+
const [text, setText] = useState('');
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<SmartTextareaPreset
|
|
99
|
+
value={text}
|
|
100
|
+
onValueChange={setText}
|
|
101
|
+
placeholder="Add your comment…"
|
|
102
|
+
options={{
|
|
103
|
+
variant: 'with-avatar-actions',
|
|
104
|
+
label: 'Comment',
|
|
105
|
+
rows: 4,
|
|
106
|
+
maxLength: 500,
|
|
107
|
+
avatarTpl: <SmartAvatarPreset initials="AK" size="sm" />,
|
|
108
|
+
actions: [{ id: 'post', label: 'Post', variant: 'primary' }],
|
|
109
|
+
}}
|
|
110
|
+
onActionClick={({ actionId, value }) => {
|
|
111
|
+
if (actionId === 'post' && value.trim()) {
|
|
112
|
+
onPost(value);
|
|
113
|
+
setText('');
|
|
114
|
+
}
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Replacing the Implementation
|
|
122
|
+
|
|
123
|
+
`SmartTextarea` renders the component registered under the `'textarea'` key of `SmartProvider`'s `components`, and `SmartTextareaStandard` when nothing is registered there. Every `SmartTextarea` below the provider then renders the registered component, which receives the same props.
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import type { ReactNode } from 'react';
|
|
127
|
+
|
|
128
|
+
import { SmartProvider, SmartTextareaPreset } from '@smartsoft001/react';
|
|
129
|
+
|
|
130
|
+
// A module constant: a new object on every render would change the context.
|
|
131
|
+
const components = { textarea: SmartTextareaPreset };
|
|
132
|
+
|
|
133
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
134
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`SmartTextareaPreset` is the styled (preset) implementation: register it as above, render it directly in place of `SmartTextarea`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
139
|
+
|
|
140
|
+
### The `useTextarea` hook
|
|
141
|
+
|
|
142
|
+
The behaviour every textarea variant shares: the `value`, controlled through `value` / `onValueChange` or kept internally from `defaultValue`, and `actionClick()`, which reports an action with the current text unless `disabled`.
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
function useTextarea({
|
|
146
|
+
value: valueProp,
|
|
147
|
+
defaultValue = '',
|
|
148
|
+
onValueChange,
|
|
149
|
+
disabled = false,
|
|
150
|
+
onActionClick,
|
|
151
|
+
}: SmartTextareaProps);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
| Returns | Type | Description |
|
|
155
|
+
| ------------- | ---------------------------- | ------------------------------------------------------------------ |
|
|
156
|
+
| `value` | `string` | The text (controlled or internal). |
|
|
157
|
+
| `setValue` | `(next: string) => void` | Sets the text and calls `onValueChange`. |
|
|
158
|
+
| `actionClick` | `(actionId: string) => void` | Reports an action with the current text; ignored while `disabled`. |
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { SmartTextareaProps, useTextarea } from '@smartsoft001/react';
|
|
162
|
+
|
|
163
|
+
export function AutoGrowTextarea(props: SmartTextareaProps) {
|
|
164
|
+
const { value, setValue, actionClick } = useTextarea(props);
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div className={props.className}>
|
|
168
|
+
<textarea
|
|
169
|
+
value={value}
|
|
170
|
+
placeholder={props.placeholder}
|
|
171
|
+
disabled={props.disabled}
|
|
172
|
+
rows={Math.max(props.options?.rows ?? 3, value.split('\n').length)}
|
|
173
|
+
onChange={(event) => setValue(event.target.value)}
|
|
174
|
+
/>
|
|
175
|
+
{props.options?.actions?.map((action) => (
|
|
176
|
+
<button
|
|
177
|
+
key={action.id}
|
|
178
|
+
type="button"
|
|
179
|
+
onClick={() => actionClick(action.id)}
|
|
180
|
+
>
|
|
181
|
+
{action.label}
|
|
182
|
+
</button>
|
|
183
|
+
))}
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Styling
|
|
190
|
+
|
|
191
|
+
- The standard textarea is unstyled; the preset renders the comment-form looks with `smart:dark:` variants.
|
|
192
|
+
|
|
193
|
+
## File Locations
|
|
194
|
+
|
|
195
|
+
Source: `packages/shared/react/src/lib/components/textarea/` in the smartsoft001 repository.
|
|
196
|
+
|
|
197
|
+
- `preset/textarea-preset.tsx`: `SmartTextareaPreset`
|
|
198
|
+
- `standard/textarea-standard.tsx`: `SmartTextareaStandard`
|
|
199
|
+
- `textarea.tsx`: `SmartTextarea`
|
|
200
|
+
- `textarea.types.ts`: `ITextareaActionClick`, `SmartTextareaProps`
|
|
201
|
+
- `use-textarea.ts`: `useTextarea`
|
|
202
|
+
- `textarea.stories.tsx`: Storybook stories
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-toggle
|
|
3
|
+
description: SmartToggle React component API (@smartsoft001/react) — on/off switch (a checkbox) with label, description and left/right label position, controlled value/onValueChange or uncontrolled defaultValue, disabled, the 'toggle' registry key, SmartTogglePreset and useToggle.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Toggle (`SmartToggle`)
|
|
8
|
+
|
|
9
|
+
`SmartToggle` is an on/off switch. The value is controlled (`value` + `onValueChange`) or kept inside (`defaultValue`, `false` by default); `disabled` blocks it. `options.label` and `options.description` render beside it (right by default, left with `labelPosition: 'left'`), and `options.ariaLabel` names it when there is no visible label. `SmartToggleStandard` is a native checkbox; `SmartTogglePreset` renders a switch track and thumb driven by a visually hidden checkbox.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Turning a setting on or off (notifications, dark mode, visibility)
|
|
14
|
+
- A labelled switch with a description
|
|
15
|
+
- Restyling every toggle (the `toggle` registry key)
|
|
16
|
+
|
|
17
|
+
Inside a form generated from a model, `flag` fields render their own input (`react-components-input`).
|
|
18
|
+
|
|
19
|
+
## Exports
|
|
20
|
+
|
|
21
|
+
All from `@smartsoft001/react`.
|
|
22
|
+
|
|
23
|
+
| Export | Kind | What it is |
|
|
24
|
+
| --------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| `SmartToggle` | component | Renders the implementation registered as `components.toggle` on `SmartProvider`, `SmartToggleStandard` by default. |
|
|
26
|
+
| `SmartTogglePreset` | component | Styled toggle (switch) variation (preset). |
|
|
27
|
+
| `SmartToggleStandard` | component | Barebones native-HTML toggle (checkbox). |
|
|
28
|
+
| `useToggle` | hook | The behaviour every toggle variant shares: the `value`, controlled through `value` / `onValueChange` or kept internally from `defaultValue`, and `toggle()`, which flips it unless `disabled`. |
|
|
29
|
+
|
|
30
|
+
The preset's class helpers (`getToggleContainerClasses`, `getToggleSwitchClasses`, `getToggleTrackClasses`, `getToggleThumbClasses`, `getToggleTextWrapClasses`, `getToggleLabelClasses`, `getToggleDescriptionClasses`, `TOGGLE_INPUT_CLASSES`) are exported too, for a custom implementation that wants the preset look.
|
|
31
|
+
|
|
32
|
+
## Props and Types
|
|
33
|
+
|
|
34
|
+
### `SmartToggleProps`
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Default | Description |
|
|
37
|
+
| ---------------- | -------------------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `value?` | `boolean` | — | Whether the toggle is on. Leave it `undefined` for an uncontrolled toggle that starts from `defaultValue`. |
|
|
39
|
+
| `defaultValue?` | `boolean` | `false` | Initial value of an uncontrolled toggle. |
|
|
40
|
+
| `onValueChange?` | `(value: boolean) => void` | — | Called when the toggle is switched on or off. |
|
|
41
|
+
| `disabled?` | `boolean` | `false` | Disables the switch. |
|
|
42
|
+
| `options?` | `IToggleOptions` | — | Label, description and accessible name. |
|
|
43
|
+
| `className?` | `string` | — | Classes on the checkbox (standard) or the root (preset). |
|
|
44
|
+
|
|
45
|
+
### `IToggleOptions`
|
|
46
|
+
|
|
47
|
+
| Field | Type | Default | Description |
|
|
48
|
+
| ---------------- | ------------------- | --------- | ----------------------------------------------- |
|
|
49
|
+
| `label?` | `string` | `''` | Visible label (the accessible name). |
|
|
50
|
+
| `description?` | `string` | `''` | Text under the label (`aria-describedby`). |
|
|
51
|
+
| `labelPosition?` | `'left' \| 'right'` | `'right'` | Side of the label and description. |
|
|
52
|
+
| `ariaLabel?` | `string` | — | Accessible name when there is no visible label. |
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { useState } from 'react';
|
|
58
|
+
|
|
59
|
+
import { SmartToggle, SmartTogglePreset } from '@smartsoft001/react';
|
|
60
|
+
|
|
61
|
+
export function NotificationSettings() {
|
|
62
|
+
const [email, setEmail] = useState(true);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<SmartTogglePreset
|
|
67
|
+
value={email}
|
|
68
|
+
onValueChange={setEmail}
|
|
69
|
+
options={{
|
|
70
|
+
label: 'Email notifications',
|
|
71
|
+
description: 'Get an email for every mention.',
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
{/* Uncontrolled, label on the left. */}
|
|
75
|
+
<SmartToggle
|
|
76
|
+
defaultValue={false}
|
|
77
|
+
options={{ label: 'Weekly digest', labelPosition: 'left' }}
|
|
78
|
+
/>
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Replacing the Implementation
|
|
85
|
+
|
|
86
|
+
`SmartToggle` renders the component registered under the `'toggle'` key of `SmartProvider`'s `components`, and `SmartToggleStandard` when nothing is registered there. Every `SmartToggle` below the provider then renders the registered component, which receives the same props.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import type { ReactNode } from 'react';
|
|
90
|
+
|
|
91
|
+
import { SmartProvider, SmartTogglePreset } from '@smartsoft001/react';
|
|
92
|
+
|
|
93
|
+
// A module constant: a new object on every render would change the context.
|
|
94
|
+
const components = { toggle: SmartTogglePreset };
|
|
95
|
+
|
|
96
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
97
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`SmartTogglePreset` is the styled (preset) implementation: register it as above, render it directly in place of `SmartToggle`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
102
|
+
|
|
103
|
+
### The `useToggle` hook
|
|
104
|
+
|
|
105
|
+
The behaviour every toggle variant shares: the `value`, controlled through `value` / `onValueChange` or kept internally from `defaultValue`, and `toggle()`, which flips it unless `disabled`.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
function useToggle({
|
|
109
|
+
value: valueProp,
|
|
110
|
+
defaultValue = false,
|
|
111
|
+
onValueChange,
|
|
112
|
+
disabled = false,
|
|
113
|
+
}: SmartToggleProps);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
| Returns | Type | Description |
|
|
117
|
+
| ---------- | ------------------------- | ------------------------------------------- |
|
|
118
|
+
| `value` | `boolean` | The current value (controlled or internal). |
|
|
119
|
+
| `setValue` | `(next: boolean) => void` | Sets the value and calls `onValueChange`. |
|
|
120
|
+
| `toggle` | `() => void` | Flips the value unless `disabled`. |
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import { SmartToggleProps, useToggle } from '@smartsoft001/react';
|
|
124
|
+
|
|
125
|
+
export function SwitchButton(props: SmartToggleProps) {
|
|
126
|
+
const { value, toggle } = useToggle(props);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
role="switch"
|
|
132
|
+
aria-checked={value}
|
|
133
|
+
aria-label={props.options?.label ?? props.options?.ariaLabel}
|
|
134
|
+
disabled={props.disabled}
|
|
135
|
+
className={props.className}
|
|
136
|
+
onClick={toggle}
|
|
137
|
+
>
|
|
138
|
+
{value ? 'On' : 'Off'}
|
|
139
|
+
</button>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Styling
|
|
145
|
+
|
|
146
|
+
- `SmartToggleStandard` is a native checkbox with a `<label htmlFor>`; `SmartTogglePreset` draws the track and thumb with `peer-*` states and `smart:dark:` variants.
|
|
147
|
+
|
|
148
|
+
## File Locations
|
|
149
|
+
|
|
150
|
+
Source: `packages/shared/react/src/lib/components/toggle/` in the smartsoft001 repository.
|
|
151
|
+
|
|
152
|
+
- `preset/toggle-preset.tsx`: `SmartTogglePreset`
|
|
153
|
+
- `standard/toggle-standard.tsx`: `SmartToggleStandard`
|
|
154
|
+
- `toggle.tsx`: `SmartToggle`
|
|
155
|
+
- `toggle.types.ts`: `SmartToggleProps`
|
|
156
|
+
- `use-toggle.ts`: `useToggle`
|
|
157
|
+
- `toggle.stories.tsx`: Storybook stories
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-vertical-navigation
|
|
3
|
+
description: SmartVerticalNavigation React component API (@smartsoft001/react) — vertical list of navigation links (router links through the navigation adapter) with icons, initials, badges and titled groups, onItemClick, the 'vertical-navigation' registry key, SmartVerticalNavigationPreset and useVerticalNavigation.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Vertical Navigation (`SmartVerticalNavigation`)
|
|
8
|
+
|
|
9
|
+
`SmartVerticalNavigation` renders a vertical list of navigation items: `options.items` (an untitled first group) followed by titled `options.groups`. Items show an icon or an initial, a label and a badge; the `current` one is highlighted. Items with an internal `href` render through the navigation adapter's `linkComponent` when one is set; items without `href` are buttons reported through `onItemClick({ itemId })`. `SmartVerticalNavigationPreset` renders vertical tabs with an accented current item.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- A secondary navigation inside a page (settings sections, account menu)
|
|
14
|
+
- Navigation in the side column of `SmartMultiColumnLayout` or `SmartSidebarLayout`
|
|
15
|
+
- Restyling every vertical navigation (the `vertical-navigation` registry key)
|
|
16
|
+
|
|
17
|
+
For the main application sidebar with a logo, expandable sections and a profile, use `SmartSidebarNavigation`.
|
|
18
|
+
|
|
19
|
+
## Exports
|
|
20
|
+
|
|
21
|
+
All from `@smartsoft001/react`.
|
|
22
|
+
|
|
23
|
+
| Export | Kind | What it is |
|
|
24
|
+
| --------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| `SmartVerticalNavigation` | component | Renders the implementation registered as `components['vertical-navigation']` on `SmartProvider`, `SmartVerticalNavigationStandard` by default. |
|
|
26
|
+
| `SmartVerticalNavigationPreset` | component | Styled vertical navigation variation (preset). |
|
|
27
|
+
| `SmartVerticalNavigationStandard` | component | The default vertical navigation rendering. |
|
|
28
|
+
| `useVerticalNavigation` | hook | The behaviour every vertical navigation variant shares: `options.items` normalised into a first, untitled group followed by `options.groups`, and the item click. |
|
|
29
|
+
|
|
30
|
+
The preset's class helpers (`getVerticalNavContainerClasses`, `getVerticalNavNavClasses`, `getVerticalNavGroupTitleClasses`, `getVerticalNavItemClasses`, `getVerticalNavIconClasses`, `getVerticalNavInitialClasses`, `getVerticalNavBadgeClasses`) are exported too, for a custom implementation that wants the preset look.
|
|
31
|
+
|
|
32
|
+
## Props and Types
|
|
33
|
+
|
|
34
|
+
### `SmartVerticalNavigationProps`
|
|
35
|
+
|
|
36
|
+
| Prop | Type | Default | Description |
|
|
37
|
+
| -------------- | ---------------------------------------- | ------- | ---------------------------------- |
|
|
38
|
+
| `options?` | `IVerticalNavOptions` | — | Items and groups. |
|
|
39
|
+
| `className?` | `string` | — | Classes on the root element. |
|
|
40
|
+
| `onItemClick?` | `(event: IVerticalNavItemClick) => void` | — | A click on an item without `href`. |
|
|
41
|
+
|
|
42
|
+
### `IVerticalNavOptions`
|
|
43
|
+
|
|
44
|
+
| Field | Type | Default | Description |
|
|
45
|
+
| ------------ | ------------------------ | ----------- | -------------------------------------------------------------------------------------------- |
|
|
46
|
+
| `layout?` | `SmartVerticalNavLayout` | — | Declared (`SmartVerticalNavLayout`); neither the standard nor the preset rendering reads it. |
|
|
47
|
+
| `ariaLabel?` | `string` | `'Sidebar'` | Accessible name of the `nav`. |
|
|
48
|
+
| `items?` | `IVerticalNavItem[]` | — | The first, untitled group. |
|
|
49
|
+
| `groups?` | `IVerticalNavGroup[]` | — | Further groups, each with a title. |
|
|
50
|
+
|
|
51
|
+
### `IVerticalNavItemClick`
|
|
52
|
+
|
|
53
|
+
| Field | Type | Default | Description |
|
|
54
|
+
| -------- | -------- | -------- | ----------------------------- |
|
|
55
|
+
| `itemId` | `string` | required | The `id` of the clicked item. |
|
|
56
|
+
|
|
57
|
+
### `IVerticalNavItem`
|
|
58
|
+
|
|
59
|
+
| Field | Type | Default | Description |
|
|
60
|
+
| ---------- | ------------------ | -------- | ------------------------------------------------------------------- |
|
|
61
|
+
| `id` | `string` | required | Reported as `itemId`. |
|
|
62
|
+
| `label?` | `string` | — | Item text. |
|
|
63
|
+
| `href?` | `string` | — | Renders a link (through the navigation adapter for internal paths). |
|
|
64
|
+
| `current?` | `boolean` | — | Marks the current item. |
|
|
65
|
+
| `badge?` | `string \| number` | — | A count or text badge. |
|
|
66
|
+
| `iconTpl?` | `ReactNode` | — | Item icon. |
|
|
67
|
+
| `initial?` | `string` | — | A letter shown instead of an icon. |
|
|
68
|
+
|
|
69
|
+
### `IVerticalNavGroup`
|
|
70
|
+
|
|
71
|
+
| Field | Type | Default | Description |
|
|
72
|
+
| -------- | -------------------- | -------- | ------------------ |
|
|
73
|
+
| `id?` | `string` | — | Key of the group. |
|
|
74
|
+
| `title?` | `string` | — | Group heading. |
|
|
75
|
+
| `items` | `IVerticalNavItem[]` | required | The group's items. |
|
|
76
|
+
|
|
77
|
+
### Related types
|
|
78
|
+
|
|
79
|
+
- `SmartVerticalNavLayout`: `'simple' \| 'with-badges' \| 'with-icons' \| 'with-icons-and-badges' \| 'with-secondary-navigation' \| 'on-gray'`
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { SmartVerticalNavigationPreset } from '@smartsoft001/react';
|
|
85
|
+
|
|
86
|
+
export function SettingsNav({
|
|
87
|
+
section,
|
|
88
|
+
onSection,
|
|
89
|
+
}: {
|
|
90
|
+
section: string;
|
|
91
|
+
onSection: (id: string) => void;
|
|
92
|
+
}) {
|
|
93
|
+
return (
|
|
94
|
+
<SmartVerticalNavigationPreset
|
|
95
|
+
options={{
|
|
96
|
+
ariaLabel: 'Settings',
|
|
97
|
+
items: [
|
|
98
|
+
{ id: 'profile', label: 'Profile', current: section === 'profile' },
|
|
99
|
+
{
|
|
100
|
+
id: 'billing',
|
|
101
|
+
label: 'Billing',
|
|
102
|
+
current: section === 'billing',
|
|
103
|
+
badge: 1,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
groups: [
|
|
107
|
+
{
|
|
108
|
+
id: 'workspace',
|
|
109
|
+
title: 'Workspace',
|
|
110
|
+
items: [
|
|
111
|
+
{ id: 'members', label: 'Members', href: '/settings/members' },
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
}}
|
|
116
|
+
onItemClick={({ itemId }) => onSection(itemId)}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Replacing the Implementation
|
|
123
|
+
|
|
124
|
+
`SmartVerticalNavigation` renders the component registered under the `'vertical-navigation'` key of `SmartProvider`'s `components`, and `SmartVerticalNavigationStandard` when nothing is registered there. Every `SmartVerticalNavigation` below the provider then renders the registered component, which receives the same props.
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import type { ReactNode } from 'react';
|
|
128
|
+
|
|
129
|
+
import {
|
|
130
|
+
SmartProvider,
|
|
131
|
+
SmartVerticalNavigationPreset,
|
|
132
|
+
} from '@smartsoft001/react';
|
|
133
|
+
|
|
134
|
+
// A module constant: a new object on every render would change the context.
|
|
135
|
+
const components = { 'vertical-navigation': SmartVerticalNavigationPreset };
|
|
136
|
+
|
|
137
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
138
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`SmartVerticalNavigationPreset` is the styled (preset) implementation: register it as above, render it directly in place of `SmartVerticalNavigation`, or spread `SMART_PRESET_COMPONENTS` on the provider to register every preset at once (see the `react-provider` skill). Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
143
|
+
|
|
144
|
+
### The `useVerticalNavigation` hook
|
|
145
|
+
|
|
146
|
+
The behaviour every vertical navigation variant shares: `options.items` normalised into a first, untitled group followed by `options.groups`, and the item click.
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
function useVerticalNavigation({
|
|
150
|
+
options,
|
|
151
|
+
onItemClick,
|
|
152
|
+
}: SmartVerticalNavigationProps);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
| Returns | Type | Description |
|
|
156
|
+
| ----------- | --------------------------------------- | ----------------------------------------------------------------- |
|
|
157
|
+
| `groups` | `IVerticalNavGroup[]` | `options.items` as a first untitled group, then `options.groups`. |
|
|
158
|
+
| `itemClick` | `(itemId: string) => void \| undefined` | Reports a click on an item without `href`. |
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import {
|
|
162
|
+
SmartVerticalNavigationProps,
|
|
163
|
+
useVerticalNavigation,
|
|
164
|
+
} from '@smartsoft001/react';
|
|
165
|
+
|
|
166
|
+
export function PlainVerticalNav(props: SmartVerticalNavigationProps) {
|
|
167
|
+
const { groups, itemClick } = useVerticalNavigation(props);
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<nav
|
|
171
|
+
aria-label={props.options?.ariaLabel ?? 'Sidebar'}
|
|
172
|
+
className={props.className}
|
|
173
|
+
>
|
|
174
|
+
{groups.map((group, index) => (
|
|
175
|
+
<ul key={group.id ?? index} aria-label={group.title}>
|
|
176
|
+
{group.items.map((item) => (
|
|
177
|
+
<li key={item.id}>
|
|
178
|
+
{item.href ? (
|
|
179
|
+
<a
|
|
180
|
+
href={item.href}
|
|
181
|
+
aria-current={item.current ? 'page' : undefined}
|
|
182
|
+
>
|
|
183
|
+
{item.label}
|
|
184
|
+
</a>
|
|
185
|
+
) : (
|
|
186
|
+
<button type="button" onClick={() => itemClick(item.id)}>
|
|
187
|
+
{item.label}
|
|
188
|
+
</button>
|
|
189
|
+
)}
|
|
190
|
+
</li>
|
|
191
|
+
))}
|
|
192
|
+
</ul>
|
|
193
|
+
))}
|
|
194
|
+
</nav>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Styling
|
|
200
|
+
|
|
201
|
+
- The standard rendering is unstyled; the preset renders every group as its own `<nav>` after its title, with `smart:dark:` variants.
|
|
202
|
+
|
|
203
|
+
## File Locations
|
|
204
|
+
|
|
205
|
+
Source: `packages/shared/react/src/lib/components/vertical-navigation/` in the smartsoft001 repository.
|
|
206
|
+
|
|
207
|
+
- `preset/vertical-navigation-preset.tsx`: `SmartVerticalNavigationPreset`
|
|
208
|
+
- `standard/vertical-navigation-standard.tsx`: `SmartVerticalNavigationStandard`
|
|
209
|
+
- `use-vertical-navigation.ts`: `useVerticalNavigation`
|
|
210
|
+
- `vertical-navigation.tsx`: `SmartVerticalNavigation`
|
|
211
|
+
- `vertical-navigation.types.ts`: `IVerticalNavItemClick`, `SmartVerticalNavigationProps`
|
|
212
|
+
- `vertical-navigation.stories.tsx`: Storybook stories
|