@smartsoft001/claude-plugins 2.193.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/angular-components-button/SKILL.md +1 -1
- package/plugins/{smart → smart-angular}/skills/angular-components-container/SKILL.md +8 -8
- package/plugins/{smart → smart-angular}/skills/angular-components-drawer/SKILL.md +5 -9
- package/plugins/{smart → smart-angular}/skills/angular-components-list-container/SKILL.md +2 -5
- package/plugins/{smart → smart-angular}/skills/angular-components-media-object/SKILL.md +1 -1
- package/plugins/{smart → smart-angular}/skills/angular-components-modal/SKILL.md +1 -1
- 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-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-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-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-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,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-password-strength
|
|
3
|
+
description: SmartPasswordStrength React component API (@smartsoft001/react) — three-bar password strength meter with translated poor/notGood/good message and an optional list of unmet rules, onPasswordStrength, the 'password-strength' registry key and the usePasswordStrength hook.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Password Strength (`SmartPasswordStrength`)
|
|
8
|
+
|
|
9
|
+
`SmartPasswordStrength` rates `passwordToCheck` on four rules (lower-case letters, upper-case letters, symbols, more than 6 characters) and shows a three-bar meter with a translated message (`INPUT.PASSWORD-STRENGTH.poor` / `notGood` / `good`). With `showHint` it lists the rules the password does not meet yet. `onPasswordStrength(strong)` reports whenever the rating changes; `strong` is `true` once all rules are met. There is no preset: the standard meter is already styled.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- A sign-up or change-password form that shows how strong the new password is
|
|
14
|
+
- Blocking submission until the password is strong (`onPasswordStrength`)
|
|
15
|
+
- Providing the application's own meter (the `password-strength` registry key) on `usePasswordStrength`
|
|
16
|
+
|
|
17
|
+
## Exports
|
|
18
|
+
|
|
19
|
+
All from `@smartsoft001/react`.
|
|
20
|
+
|
|
21
|
+
| Export | Kind | What it is |
|
|
22
|
+
| ------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
23
|
+
| `SmartPasswordStrength` | component | Renders the implementation registered as `components['password-strength']` on `SmartProvider`, `SmartPasswordStrengthStandard` by default. |
|
|
24
|
+
| `SmartPasswordStrengthStandard` | component | The default password strength meter. |
|
|
25
|
+
| `usePasswordStrength` | hook | The rating every password strength variant shares. |
|
|
26
|
+
|
|
27
|
+
## Props and Types
|
|
28
|
+
|
|
29
|
+
### `SmartPasswordStrengthProps`
|
|
30
|
+
|
|
31
|
+
Props of `<SmartPasswordStrength>`.
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Default | Description |
|
|
34
|
+
| --------------------- | --------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| `passwordToCheck` | `string` | required | The password to rate. |
|
|
36
|
+
| `showHint` | `boolean` | required | Lists the rules the password does not meet yet. |
|
|
37
|
+
| `className?` | `string` | — | Classes appended to the container. |
|
|
38
|
+
| `onPasswordStrength?` | `(strong: boolean) => void` | — | Called whenever the strength changes: `true` once the password is strong (lower and upper letters, a symbol and more than 6 characters). |
|
|
39
|
+
|
|
40
|
+
### `PasswordStrengthResult`
|
|
41
|
+
|
|
42
|
+
Which rules the password meets.
|
|
43
|
+
|
|
44
|
+
| Field | Type | Default | Description |
|
|
45
|
+
| -------------- | --------- | -------- | ------------------------------ |
|
|
46
|
+
| `lowerLetters` | `boolean` | required | Contains a lower-case letter. |
|
|
47
|
+
| `upperLetters` | `boolean` | required | Contains an upper-case letter. |
|
|
48
|
+
| `symbols` | `boolean` | required | Contains a symbol. |
|
|
49
|
+
| `passLength` | `boolean` | required | Longer than 6 characters. |
|
|
50
|
+
|
|
51
|
+
### Related types
|
|
52
|
+
|
|
53
|
+
- `PasswordStrengthMessage`: `'' \| 'poor' \| 'notGood' \| 'good'` — The message key suffix (`''` while empty).
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { useState } from 'react';
|
|
59
|
+
|
|
60
|
+
import { SmartPasswordStrength } from '@smartsoft001/react';
|
|
61
|
+
|
|
62
|
+
export function NewPassword({
|
|
63
|
+
onStrong,
|
|
64
|
+
}: {
|
|
65
|
+
onStrong: (strong: boolean) => void;
|
|
66
|
+
}) {
|
|
67
|
+
const [password, setPassword] = useState('');
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<label>
|
|
71
|
+
New password
|
|
72
|
+
<input
|
|
73
|
+
type="password"
|
|
74
|
+
value={password}
|
|
75
|
+
onChange={(event) => setPassword(event.target.value)}
|
|
76
|
+
/>
|
|
77
|
+
<SmartPasswordStrength
|
|
78
|
+
passwordToCheck={password}
|
|
79
|
+
showHint
|
|
80
|
+
onPasswordStrength={onStrong}
|
|
81
|
+
/>
|
|
82
|
+
</label>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Replacing the Implementation
|
|
88
|
+
|
|
89
|
+
`SmartPasswordStrength` renders the component registered under the `'password-strength'` key of `SmartProvider`'s `components`, and `SmartPasswordStrengthStandard` when nothing is registered there. Every `SmartPasswordStrength` below the provider then renders the registered component, which receives the same props.
|
|
90
|
+
|
|
91
|
+
There is no preset for this component: register a component of your own that takes `SmartPasswordStrengthProps`, as shown below, as `components={{ 'password-strength': MyPasswordStrength }}`. Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
92
|
+
|
|
93
|
+
### The `usePasswordStrength` hook
|
|
94
|
+
|
|
95
|
+
The rating every password strength variant shares.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
function usePasswordStrength({
|
|
99
|
+
passwordToCheck,
|
|
100
|
+
className = '',
|
|
101
|
+
onPasswordStrength,
|
|
102
|
+
}: SmartPasswordStrengthProps);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
| Returns | Type | Description |
|
|
106
|
+
| ------------------ | ------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
107
|
+
| `result` | `PasswordStrengthResult` | The rules the password meets. |
|
|
108
|
+
| `strength` | `number` | The score: 10 (poor), 20 (not good), 30 (strong); any other value (an empty password, digits only) is not rated. |
|
|
109
|
+
| `strengthIndex` | `0 \| 2 \| 1 \| 3` | `0` poor, `1` not good, `2` good, `3` not rated. |
|
|
110
|
+
| `msg` | `PasswordStrengthMessage` | The message key suffix for `INPUT.PASSWORD-STRENGTH.<msg>`. |
|
|
111
|
+
| `barClasses` | `string[]` | The classes of the three bars (filled per strength). |
|
|
112
|
+
| `msgClass` | `string` | The colour class of the message. |
|
|
113
|
+
| `containerClasses` | `string` | The container classes, with `className` appended. |
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import {
|
|
117
|
+
SmartPasswordStrengthProps,
|
|
118
|
+
usePasswordStrength,
|
|
119
|
+
useTranslate,
|
|
120
|
+
} from '@smartsoft001/react';
|
|
121
|
+
|
|
122
|
+
export function TextPasswordStrength(props: SmartPasswordStrengthProps) {
|
|
123
|
+
const { msg, result } = usePasswordStrength(props);
|
|
124
|
+
const t = useTranslate();
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<p className={props.className}>
|
|
128
|
+
{msg && t('INPUT.PASSWORD-STRENGTH.' + msg)}
|
|
129
|
+
{props.showHint && !result.symbols && (
|
|
130
|
+
<small> {t('INPUT.ERRORS.symbols')}</small>
|
|
131
|
+
)}
|
|
132
|
+
</p>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Styling
|
|
138
|
+
|
|
139
|
+
- The standard meter fills the bars in red / yellow / green tones with `smart:dark:` variants; the container is a third of the width (`smart:w-1/3`, full width below `sm`).
|
|
140
|
+
|
|
141
|
+
## File Locations
|
|
142
|
+
|
|
143
|
+
Source: `packages/shared/react/src/lib/components/password-strength/` in the smartsoft001 repository.
|
|
144
|
+
|
|
145
|
+
- `password-strength.tsx`: `SmartPasswordStrength`
|
|
146
|
+
- `password-strength.types.ts`: `SmartPasswordStrengthProps`
|
|
147
|
+
- `standard/password-strength-standard.tsx`: `SmartPasswordStrengthStandard`
|
|
148
|
+
- `use-password-strength.ts`: `usePasswordStrength`, `PasswordStrengthMessage`, `PasswordStrengthResult`
|
|
149
|
+
- `password-strength.stories.tsx`: Storybook stories
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-progress-bars
|
|
3
|
+
description: SmartProgressBars React component API (@smartsoft001/react) — step indicators (simple, panels, bullets, circles, with text) or a percentage progress bar with columns, step status complete/current/upcoming, router links and onStepClick, the 'progress-bars' registry key and SmartProgressBarsPreset.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Progress Bars (`SmartProgressBars`)
|
|
8
|
+
|
|
9
|
+
`SmartProgressBars` shows progress in two ways. With a step layout it renders `steps` (each `complete`, `current` or `upcoming`) as a `<nav>` list; steps with an internal `href` render through the navigation adapter's `linkComponent` when one is set, steps without `href` are buttons reported through `onStepClick({ stepId })`. With `layout: 'progress-bar'` it renders a track filled to `value` percent, with an optional title and column captions.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- A multi-step form or checkout ("Account → Profile → Confirm")
|
|
14
|
+
- A percentage progress bar with labelled stages (`progress-bar` layout + `columns`)
|
|
15
|
+
- Restyling every progress indicator (the `progress-bars` registry key)
|
|
16
|
+
|
|
17
|
+
## Exports
|
|
18
|
+
|
|
19
|
+
All from `@smartsoft001/react`.
|
|
20
|
+
|
|
21
|
+
| Export | Kind | What it is |
|
|
22
|
+
| --------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| `SmartProgressBars` | component | Renders the implementation registered as `components['progress-bars']` on `SmartProvider`, `SmartProgressBarsStandard` by default. |
|
|
24
|
+
| `SmartProgressBarsPreset` | component | Styled progress bars variation (preset). |
|
|
25
|
+
| `SmartProgressBarsStandard` | component | The default progress bars rendering: the steps as a `<nav>` list, or a progress bar for the `progress-bar` layout. |
|
|
26
|
+
|
|
27
|
+
The preset's class helpers (`getProgressBarsColumnClasses`, `isProgressBarsVertical`, `isProgressBarsBullet`, `isProgressBarsCircle`, `isProgressBarsPanel`, `isProgressBarsSimple`, `getProgressBarsListClasses`, `getProgressBarsStepClasses`, `getProgressBarsMarkerClasses`, `getProgressBarsNameClasses`, `getProgressBarsConnectorClasses`, `PROGRESS_BARS_WRAPPER`, `PROGRESS_BARS_HEADER`, `PROGRESS_BARS_TITLE`, `PROGRESS_BARS_VALUE_LABEL`, `PROGRESS_BARS_TRACK`, `PROGRESS_BARS_FILL`, `PROGRESS_BARS_COLUMNS`, `PROGRESS_BARS_NAV`, `PROGRESS_BARS_STEPPER_TITLE`, `PROGRESS_BARS_DESCRIPTION`, `PROGRESS_BARS_INDEX`, `PROGRESS_BARS_STEP_BUTTON`, `PROGRESS_BARS_STEP_LINK`, `PROGRESS_BARS_CHECK_ICON`) are exported too, for a custom implementation that wants the preset look.
|
|
28
|
+
|
|
29
|
+
## Props and Types
|
|
30
|
+
|
|
31
|
+
### `SmartProgressBarsProps`
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Default | Description |
|
|
34
|
+
| -------------- | ------------------------------------- | ------- | ------------------------------------ |
|
|
35
|
+
| `options?` | `IProgressBarsOptions` | — | Layout, steps or the progress value. |
|
|
36
|
+
| `className?` | `string` | — | Classes on the root element. |
|
|
37
|
+
| `onStepClick?` | `(event: IProgressStepClick) => void` | — | A click on a step without `href`. |
|
|
38
|
+
|
|
39
|
+
### `IProgressBarsOptions`
|
|
40
|
+
|
|
41
|
+
| Field | Type | Default | Description |
|
|
42
|
+
| -------------- | ------------------------- | ------------ | -------------------------------------------------------- |
|
|
43
|
+
| `layout?` | `SmartProgressBarsLayout` | `'simple'` | A step layout, or `progress-bar` for the percentage bar. |
|
|
44
|
+
| `ariaLabel?` | `string` | `'Progress'` | Accessible name of the `<nav>`. |
|
|
45
|
+
| `steps?` | `IProgressStep[]` | `[]` | The steps of a step layout. |
|
|
46
|
+
| `title?` | `string` | — | Title of the progress bar. |
|
|
47
|
+
| `srOnlyTitle?` | `string` | — | Title for screen readers only. |
|
|
48
|
+
| `value?` | `number` | `0` | Percentage of the progress bar (0–100). |
|
|
49
|
+
| `columns?` | `IProgressBarColumn[]` | `[]` | Captions under the progress bar. |
|
|
50
|
+
|
|
51
|
+
### `IProgressStepClick`
|
|
52
|
+
|
|
53
|
+
| Field | Type | Default | Description |
|
|
54
|
+
| -------- | -------- | -------- | ----------------------------- |
|
|
55
|
+
| `stepId` | `string` | required | The `id` of the clicked step. |
|
|
56
|
+
|
|
57
|
+
### `IProgressStep`
|
|
58
|
+
|
|
59
|
+
| Field | Type | Default | Description |
|
|
60
|
+
| -------------- | ------------------------- | -------- | ---------------------------------------------- |
|
|
61
|
+
| `id` | `string` | required | Reported as `stepId`. |
|
|
62
|
+
| `name?` | `string` | — | Step name. |
|
|
63
|
+
| `description?` | `string` | — | Text under the name (layouts "with text"). |
|
|
64
|
+
| `status?` | `SmartProgressStepStatus` | — | `complete`, `current` or `upcoming`. |
|
|
65
|
+
| `href?` | `string` | — | Renders the step as a link. |
|
|
66
|
+
| `iconTpl?` | `ReactNode` | — | Icon of the step. |
|
|
67
|
+
| `index?` | `string` | — | Number shown in the step marker (e.g. `'01'`). |
|
|
68
|
+
|
|
69
|
+
### `IProgressBarColumn`
|
|
70
|
+
|
|
71
|
+
| Field | Type | Default | Description |
|
|
72
|
+
| --------- | --------- | -------- | ----------------------- |
|
|
73
|
+
| `label` | `string` | required | Caption text. |
|
|
74
|
+
| `active?` | `boolean` | — | Highlights the caption. |
|
|
75
|
+
|
|
76
|
+
### Related types
|
|
77
|
+
|
|
78
|
+
- `SmartProgressBarsLayout`: `'simple' \| 'panels' \| 'bullets' \| 'panels-with-border' \| 'circles' \| 'bullets-and-text' \| 'circles-with-text' \| 'progress-bar'`
|
|
79
|
+
- `SmartProgressStepStatus`: `'complete' \| 'current' \| 'upcoming'`
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import {
|
|
85
|
+
SmartProgressBars,
|
|
86
|
+
SmartProgressBarsPreset,
|
|
87
|
+
} from '@smartsoft001/react';
|
|
88
|
+
|
|
89
|
+
export function CheckoutProgress({ onStep }: { onStep: (id: string) => void }) {
|
|
90
|
+
return (
|
|
91
|
+
<>
|
|
92
|
+
<SmartProgressBarsPreset
|
|
93
|
+
options={{
|
|
94
|
+
layout: 'circles-with-text',
|
|
95
|
+
steps: [
|
|
96
|
+
{
|
|
97
|
+
id: 'cart',
|
|
98
|
+
name: 'Cart',
|
|
99
|
+
description: 'Review items',
|
|
100
|
+
status: 'complete',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: 'shipping',
|
|
104
|
+
name: 'Shipping',
|
|
105
|
+
description: 'Address and method',
|
|
106
|
+
status: 'current',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'payment',
|
|
110
|
+
name: 'Payment',
|
|
111
|
+
description: 'Card or transfer',
|
|
112
|
+
status: 'upcoming',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
}}
|
|
116
|
+
onStepClick={({ stepId }) => onStep(stepId)}
|
|
117
|
+
/>
|
|
118
|
+
|
|
119
|
+
<SmartProgressBars
|
|
120
|
+
options={{
|
|
121
|
+
layout: 'progress-bar',
|
|
122
|
+
title: 'Migrating MySQL database…',
|
|
123
|
+
value: 37,
|
|
124
|
+
columns: [
|
|
125
|
+
{ label: 'Copying files', active: true },
|
|
126
|
+
{ label: 'Migrating database', active: true },
|
|
127
|
+
{ label: 'Compiling assets' },
|
|
128
|
+
],
|
|
129
|
+
}}
|
|
130
|
+
/>
|
|
131
|
+
</>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Replacing the Implementation
|
|
137
|
+
|
|
138
|
+
`SmartProgressBars` renders the component registered under the `'progress-bars'` key of `SmartProvider`'s `components`, and `SmartProgressBarsStandard` when nothing is registered there. Every `SmartProgressBars` below the provider then renders the registered component, which receives the same props.
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import type { ReactNode } from 'react';
|
|
142
|
+
|
|
143
|
+
import { SmartProvider, SmartProgressBarsPreset } from '@smartsoft001/react';
|
|
144
|
+
|
|
145
|
+
// A module constant: a new object on every render would change the context.
|
|
146
|
+
const components = { 'progress-bars': SmartProgressBarsPreset };
|
|
147
|
+
|
|
148
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
149
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`SmartProgressBarsPreset` is the styled (preset) implementation: register it as above, render it directly in place of `SmartProgressBars`, 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.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import { SmartProgressBarsProps } from '@smartsoft001/react';
|
|
157
|
+
|
|
158
|
+
export function DotsProgress({
|
|
159
|
+
options,
|
|
160
|
+
className,
|
|
161
|
+
onStepClick,
|
|
162
|
+
}: SmartProgressBarsProps) {
|
|
163
|
+
return (
|
|
164
|
+
<ol aria-label={options?.ariaLabel ?? 'Progress'} className={className}>
|
|
165
|
+
{(options?.steps ?? []).map((step) => (
|
|
166
|
+
<li
|
|
167
|
+
key={step.id}
|
|
168
|
+
aria-current={step.status === 'current' ? 'step' : undefined}
|
|
169
|
+
>
|
|
170
|
+
<button
|
|
171
|
+
type="button"
|
|
172
|
+
onClick={() => onStepClick?.({ stepId: step.id })}
|
|
173
|
+
>
|
|
174
|
+
{step.status === 'complete' ? '●' : '○'} {step.name}
|
|
175
|
+
</button>
|
|
176
|
+
</li>
|
|
177
|
+
))}
|
|
178
|
+
</ol>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Styling
|
|
184
|
+
|
|
185
|
+
- The standard rendering is unstyled; `SmartProgressBarsPreset` renders every layout (connectors between horizontal circles and bullets, the track and fill of the bar) with `smart:dark:` variants.
|
|
186
|
+
|
|
187
|
+
## File Locations
|
|
188
|
+
|
|
189
|
+
Source: `packages/shared/react/src/lib/components/progress-bars/` in the smartsoft001 repository.
|
|
190
|
+
|
|
191
|
+
- `preset/progress-bars-preset.tsx`: `SmartProgressBarsPreset`
|
|
192
|
+
- `progress-bars.tsx`: `SmartProgressBars`
|
|
193
|
+
- `progress-bars.types.ts`: `IProgressStepClick`, `SmartProgressBarsProps`
|
|
194
|
+
- `standard/progress-bars-standard.tsx`: `SmartProgressBarsStandard`
|
|
195
|
+
- `progress-bars.stories.tsx`: Storybook stories
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-searchbar
|
|
3
|
+
description: SmartSearchbar React component API (@smartsoft001/react) — debounced search input (text/onTextChange after debounceTime, 1000 ms by default) that hides itself on blur while empty, with an optional toggle button, controlled or uncontrolled show and text, the 'searchbar' registry key and the useSearchbar hook.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Searchbar (`SmartSearchbar`)
|
|
8
|
+
|
|
9
|
+
`SmartSearchbar` is a search input whose text is reported **once the typing settles** (`options.debounceTime`, 1000 ms by default) through `onTextChange`. While empty, it hides itself on blur; with `options.showToggleButton` a magnifier button shows it again. Both `text` and `show` can be controlled (`text` / `onTextChange`, `show` / `onShowChange`) or left to the component (`defaultText`, `defaultShow` = `true`). There is no preset.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- A search box that filters a list after the user stops typing
|
|
14
|
+
- A collapsible search field behind a magnifier button
|
|
15
|
+
- Providing the application's own search box (the `searchbar` registry key) on `useSearchbar`
|
|
16
|
+
|
|
17
|
+
## Exports
|
|
18
|
+
|
|
19
|
+
All from `@smartsoft001/react`.
|
|
20
|
+
|
|
21
|
+
| Export | Kind | What it is |
|
|
22
|
+
| ------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
23
|
+
| `SmartSearchbar` | component | Renders the implementation registered as `components.searchbar` on `SmartProvider`, `SmartSearchbarStandard` by default. |
|
|
24
|
+
| `SmartSearchbarStandard` | component | The default searchbar: a search input bound to the hook's `control`, hidden on blur while empty. |
|
|
25
|
+
| `useSearchbar` | hook | The behaviour every searchbar variant shares. |
|
|
26
|
+
|
|
27
|
+
## Props and Types
|
|
28
|
+
|
|
29
|
+
### `SmartSearchbarProps`
|
|
30
|
+
|
|
31
|
+
| Prop | Type | Default | Description |
|
|
32
|
+
| --------------- | ------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
33
|
+
| `options?` | `ISearchbarOptions` | — | Placeholder, label, debounce and toggle button. |
|
|
34
|
+
| `className?` | `string` | — | Classes on the input. |
|
|
35
|
+
| `show?` | `boolean` | — | Whether the search field is shown. Leave it `undefined` for an uncontrolled searchbar that starts from `defaultShow`. |
|
|
36
|
+
| `defaultShow?` | `boolean` | `true` | Initial `show` of an uncontrolled searchbar (default `true`). |
|
|
37
|
+
| `onShowChange?` | `(show: boolean) => void` | — | Called when the search field is shown or hidden. |
|
|
38
|
+
| `text?` | `string` | — | The search text, updated once the typing settles for `options.debounceTime` ms (1000 by default). Leave it `undefined` for an uncontrolled searchbar that starts from `defaultText`. |
|
|
39
|
+
| `defaultText?` | `string` | `''` | Initial text of an uncontrolled searchbar. |
|
|
40
|
+
| `onTextChange?` | `(text: string) => void` | — | Called with the search text once the typing settles. |
|
|
41
|
+
|
|
42
|
+
### `ISearchbarOptions`
|
|
43
|
+
|
|
44
|
+
| Field | Type | Default | Description |
|
|
45
|
+
| ------------------- | ------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| `placeholder?` | `string` | `'search'` | Placeholder of the input, passed through the translations (a key or text). |
|
|
47
|
+
| `label?` | `string` | — | Declared for implementations of your own; the standard rendering does not read it (give the input a visible label around it, or use your own implementation). |
|
|
48
|
+
| `debounceTime?` | `number` | `1000` | Milliseconds the typing has to settle before `onTextChange`. |
|
|
49
|
+
| `showToggleButton?` | `boolean` | — | Renders a magnifier button while the field is hidden. |
|
|
50
|
+
| `size?` | `SmartSize` | — | Declared for implementations of your own; the standard rendering does not read it. |
|
|
51
|
+
| `color?` | `SmartColor` | — | Declared for implementations of your own; the standard rendering does not read it. |
|
|
52
|
+
|
|
53
|
+
`SmartColor`, `SmartSize` are described in the `react-provider` skill.
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { useState } from 'react';
|
|
59
|
+
|
|
60
|
+
import { SmartSearchbar } from '@smartsoft001/react';
|
|
61
|
+
|
|
62
|
+
export function NoteSearch({ onSearch }: { onSearch: (text: string) => void }) {
|
|
63
|
+
const [text, setText] = useState('');
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<SmartSearchbar
|
|
67
|
+
text={text}
|
|
68
|
+
onTextChange={(next) => {
|
|
69
|
+
setText(next);
|
|
70
|
+
onSearch(next);
|
|
71
|
+
}}
|
|
72
|
+
options={{
|
|
73
|
+
placeholder: 'Search notes',
|
|
74
|
+
debounceTime: 300,
|
|
75
|
+
showToggleButton: true,
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Replacing the Implementation
|
|
83
|
+
|
|
84
|
+
`SmartSearchbar` renders the component registered under the `'searchbar'` key of `SmartProvider`'s `components`, and `SmartSearchbarStandard` when nothing is registered there. Every `SmartSearchbar` below the provider then renders the registered component, which receives the same props.
|
|
85
|
+
|
|
86
|
+
There is no preset for this component: register a component of your own that takes `SmartSearchbarProps`, as shown below, as `components={{ searchbar: MySearchbar }}`. Pass `components` as a stable object (a module constant or a memoised value), or the context changes on every render.
|
|
87
|
+
|
|
88
|
+
### The `useSearchbar` hook
|
|
89
|
+
|
|
90
|
+
The behaviour every searchbar variant shares. The field is bound to `control`. Its changes reach `text` once they settle for `options.debounceTime` ms (1000 by default); a non-empty `text` coming from outside is copied into the control without being reported back. `tryHide()` (on blur) hides an empty searchbar, `setShow()` shows it again. `show` and `text` are controlled through `show` / `onShowChange` and `text` / `onTextChange`, or kept internally from `defaultShow` / `defaultText`.
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
function useSearchbar({
|
|
94
|
+
options,
|
|
95
|
+
show: showProp,
|
|
96
|
+
defaultShow = true,
|
|
97
|
+
onShowChange,
|
|
98
|
+
text: textProp,
|
|
99
|
+
defaultText = '',
|
|
100
|
+
onTextChange,
|
|
101
|
+
}: SmartSearchbarProps);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
| Returns | Type | Description |
|
|
105
|
+
| --------- | ---------------------------------- | ----------------------------------------------------------------------- |
|
|
106
|
+
| `show` | `boolean` | Whether the field is shown (controlled or internal). |
|
|
107
|
+
| `text` | `string` | The settled search text (controlled or internal). |
|
|
108
|
+
| `control` | `SmartFormControl<string \| null>` | The `SmartFormControl` the input is bound to (see `useControlBinding`). |
|
|
109
|
+
| `setShow` | `() => void` | Shows the field. |
|
|
110
|
+
| `tryHide` | `() => void` | Hides the field when it is empty (call on blur). |
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import {
|
|
114
|
+
SmartSearchbarProps,
|
|
115
|
+
useControlBinding,
|
|
116
|
+
useSearchbar,
|
|
117
|
+
} from '@smartsoft001/react';
|
|
118
|
+
|
|
119
|
+
export function AlwaysOnSearch(props: SmartSearchbarProps) {
|
|
120
|
+
const { control } = useSearchbar(props);
|
|
121
|
+
const binding = useControlBinding(control);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<input
|
|
125
|
+
type="search"
|
|
126
|
+
className={props.className}
|
|
127
|
+
aria-label={props.options?.label ?? 'Search'}
|
|
128
|
+
placeholder={props.options?.placeholder}
|
|
129
|
+
value={binding.value ?? ''}
|
|
130
|
+
onChange={(event) => binding.onChange(event.target.value)}
|
|
131
|
+
onBlur={binding.onBlur}
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Styling
|
|
138
|
+
|
|
139
|
+
- `className` goes on the input; the standard input carries `smart:dark:` variants.
|
|
140
|
+
- A non-empty `text` coming from the parent is copied into the field without being reported back.
|
|
141
|
+
|
|
142
|
+
## File Locations
|
|
143
|
+
|
|
144
|
+
Source: `packages/shared/react/src/lib/components/searchbar/` in the smartsoft001 repository.
|
|
145
|
+
|
|
146
|
+
- `searchbar.tsx`: `SmartSearchbar`
|
|
147
|
+
- `searchbar.types.ts`: `SmartSearchbarProps`
|
|
148
|
+
- `standard/searchbar-standard.tsx`: `SmartSearchbarStandard`
|
|
149
|
+
- `use-searchbar.ts`: `useSearchbar`
|
|
150
|
+
- `searchbar.stories.tsx`: Storybook stories
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-section-heading
|
|
3
|
+
description: SmartSectionHeading React component API (@smartsoft001/react) — heading of a page section with title, label, description and slots for actions, tabs, input group, badge and image, half/narrow/wide/vertical presentations, the 'section-heading' registry key and SmartSectionHeadingPreset.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Section Heading (`SmartSectionHeading`)
|
|
8
|
+
|
|
9
|
+
`SmartSectionHeading` titles a section of a page: a title with an optional eyebrow `label`, a description, and `ReactNode` slots for actions, tabs, an input group, a badge and an image. The standard rendering is an unstyled `<h3>` header with the slots and the tabs underneath. `SmartSectionHeadingPreset` renders a "content with image" block (eyebrow label + badge, `<h2>` title, description and actions beside `imageTpl`) laid out by `options.presentation.layout`.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- The heading of a section inside a page, with actions or tabs on the side
|
|
14
|
+
- A marketing-style text-and-image block (preset layouts)
|
|
15
|
+
- Restyling every section heading (the `section-heading` registry key)
|
|
16
|
+
|
|
17
|
+
## Exports
|
|
18
|
+
|
|
19
|
+
All from `@smartsoft001/react`.
|
|
20
|
+
|
|
21
|
+
| Export | Kind | What it is |
|
|
22
|
+
| ----------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
23
|
+
| `SmartSectionHeading` | component | Renders the implementation registered as `components['section-heading']` on `SmartProvider`, `SmartSectionHeadingStandard` by default. |
|
|
24
|
+
| `SmartSectionHeadingPreset` | component | HyperUI-styled "content with image" section heading (preset). |
|
|
25
|
+
| `SmartSectionHeadingStandard` | component | The default section heading rendering: an unstyled `<h3>` title (with its `label`), description and the badge / input group / actions slots, and a tabs slot under the header. |
|
|
26
|
+
|
|
27
|
+
The preset's class helpers (`getSectionHeadingGridClasses`, `getSectionHeadingTextClasses`, `getSectionHeadingImageClasses`, `SECTION_HEADING_SECTION_CLASSES`, `SECTION_HEADING_CONTAINER_CLASSES`, `SECTION_HEADING_EYEBROW_CLASSES`, `SECTION_HEADING_TITLE_CLASSES`, `SECTION_HEADING_DESCRIPTION_CLASSES`, `SECTION_HEADING_ACTIONS_CLASSES`) are exported too, for a custom implementation that wants the preset look.
|
|
28
|
+
|
|
29
|
+
## Props and Types
|
|
30
|
+
|
|
31
|
+
### `SmartSectionHeadingProps`
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Default | Description |
|
|
34
|
+
| ------------ | ------------------------ | ------- | ------------------------------------- |
|
|
35
|
+
| `options?` | `ISectionHeadingOptions` | — | Title, texts, slots and presentation. |
|
|
36
|
+
| `className?` | `string` | — | Classes on the root element. |
|
|
37
|
+
|
|
38
|
+
### `ISectionHeadingOptions`
|
|
39
|
+
|
|
40
|
+
| Field | Type | Default | Description |
|
|
41
|
+
| ---------------- | ---------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------- |
|
|
42
|
+
| `title?` | `string` | — | The heading. |
|
|
43
|
+
| `description?` | `string` | — | Text under the heading. |
|
|
44
|
+
| `label?` | `string` | — | Eyebrow text next to / above the title. |
|
|
45
|
+
| `actionsTpl?` | `ReactNode` | — | Action buttons. |
|
|
46
|
+
| `tabsTpl?` | `ReactNode` | — | Tabs under the header (standard). |
|
|
47
|
+
| `inputGroupTpl?` | `ReactNode` | — | A search or input group (standard). |
|
|
48
|
+
| `badgeTpl?` | `ReactNode` | — | A badge next to the label. |
|
|
49
|
+
| `imageTpl?` | `ReactNode` | — | Image beside the text (preset). |
|
|
50
|
+
| `presentation?` | `{ layout?: 'half' \| 'narrow' \| 'wide' \| 'vertical'; }` | — | `layout` of the preset: `half` (default), `narrow`, `wide` (image first) or `vertical`. |
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import {
|
|
56
|
+
SmartButton,
|
|
57
|
+
SmartSectionHeading,
|
|
58
|
+
SmartTabs,
|
|
59
|
+
} from '@smartsoft001/react';
|
|
60
|
+
|
|
61
|
+
export function CandidatesHeading({ onAdd }: { onAdd: () => void }) {
|
|
62
|
+
return (
|
|
63
|
+
<SmartSectionHeading
|
|
64
|
+
options={{
|
|
65
|
+
title: 'Candidates',
|
|
66
|
+
description: 'Everyone who applied in the last 30 days.',
|
|
67
|
+
actionsTpl: (
|
|
68
|
+
<SmartButton options={{ click: onAdd }}>Add candidate</SmartButton>
|
|
69
|
+
),
|
|
70
|
+
tabsTpl: (
|
|
71
|
+
<SmartTabs
|
|
72
|
+
options={{
|
|
73
|
+
items: [
|
|
74
|
+
{ id: 'applied', label: 'Applied' },
|
|
75
|
+
{ id: 'interview', label: 'Interview' },
|
|
76
|
+
],
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
),
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Replacing the Implementation
|
|
87
|
+
|
|
88
|
+
`SmartSectionHeading` renders the component registered under the `'section-heading'` key of `SmartProvider`'s `components`, and `SmartSectionHeadingStandard` when nothing is registered there. Every `SmartSectionHeading` below the provider then renders the registered component, which receives the same props.
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import type { ReactNode } from 'react';
|
|
92
|
+
|
|
93
|
+
import { SmartProvider, SmartSectionHeadingPreset } from '@smartsoft001/react';
|
|
94
|
+
|
|
95
|
+
// A module constant: a new object on every render would change the context.
|
|
96
|
+
const components = { 'section-heading': SmartSectionHeadingPreset };
|
|
97
|
+
|
|
98
|
+
export function AppProviders({ children }: { children: ReactNode }) {
|
|
99
|
+
return <SmartProvider components={components}>{children}</SmartProvider>;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`SmartSectionHeadingPreset` is the styled (preset) implementation: register it as above, render it directly in place of `SmartSectionHeading`, 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.
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { SmartSectionHeadingProps } from '@smartsoft001/react';
|
|
107
|
+
|
|
108
|
+
export function RuleSectionHeading({
|
|
109
|
+
options,
|
|
110
|
+
className,
|
|
111
|
+
}: SmartSectionHeadingProps) {
|
|
112
|
+
return (
|
|
113
|
+
<div className={className}>
|
|
114
|
+
<h2>
|
|
115
|
+
{options?.title} {options?.badgeTpl}
|
|
116
|
+
</h2>
|
|
117
|
+
{options?.description && <p>{options.description}</p>}
|
|
118
|
+
{options?.actionsTpl}
|
|
119
|
+
<hr />
|
|
120
|
+
{options?.tabsTpl}
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Styling
|
|
127
|
+
|
|
128
|
+
- The standard rendering is unstyled; the preset carries the four layouts with `smart:dark:` variants.
|
|
129
|
+
|
|
130
|
+
## File Locations
|
|
131
|
+
|
|
132
|
+
Source: `packages/shared/react/src/lib/components/section-heading/` in the smartsoft001 repository.
|
|
133
|
+
|
|
134
|
+
- `preset/section-heading-preset.tsx`: `SmartSectionHeadingPreset`
|
|
135
|
+
- `section-heading.tsx`: `SmartSectionHeading`
|
|
136
|
+
- `section-heading.types.ts`: `SmartSectionHeadingProps`
|
|
137
|
+
- `standard/section-heading-standard.tsx`: `SmartSectionHeadingStandard`
|
|
138
|
+
- `section-heading.stories.tsx`: Storybook stories
|