@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,260 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components
|
|
3
|
+
description: Build UI in React applications using @smartsoft001/react components and @smartsoft001/crud-shell-react screens. Knows which component fits a requirement and delegates to the per-component react-components-* skills, react-provider, react-forms and smart-crud-react for exact APIs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# React Components Agent
|
|
7
|
+
|
|
8
|
+
Agent for building UI in React applications with the components of `@smartsoft001/react` (and the CRUD screens of `@smartsoft001/crud-shell-react`).
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
Use this agent when a developer needs to:
|
|
13
|
+
|
|
14
|
+
- Build a page or feature UI from `@smartsoft001/react` components
|
|
15
|
+
- Choose the right component for a UI requirement
|
|
16
|
+
- Get the correct props, options objects, callbacks and imports of a component
|
|
17
|
+
- Restyle components application-wide (presets, the `components` registry of `SmartProvider`)
|
|
18
|
+
- Write a custom implementation of a component on its `use<Name>` hook and register it
|
|
19
|
+
- Build model-driven forms, details and lists, or complete CRUD screens
|
|
20
|
+
|
|
21
|
+
## How the library works
|
|
22
|
+
|
|
23
|
+
- Every component is a function component configured with props and, usually, an `options` object (`IButtonOptions`, `IFormOptions`, ...). Content slots are `ReactNode` props (`*Tpl`), state that can change is a plain prop, and two-way values are **controlled props with an uncontrolled fallback** (`value` / `defaultValue` / `onValueChange`, `open` / `defaultOpen` / `onOpenChange`, ...).
|
|
24
|
+
- `SmartProvider` (skill `react-provider`) is the root: translations, navigation adapter, services, model providers and the **component registry**. A wrapper such as `SmartButton` renders the component registered under its key (`components={{ button: MyButton }}`), else its `Standard` implementation; `<Name>Preset` is the styled implementation, and `SMART_PRESET_COMPONENTS` registers every preset at once.
|
|
25
|
+
- Each wrapper exposes its shared logic as a `use<Name>` hook; a custom implementation takes the same props, calls the hook and is registered under the wrapper's key.
|
|
26
|
+
- Forms, details and lists read the model's `@Model` / `@Field` metadata from `@smartsoft001/models` (skills `react-forms`, `react-components-form`, `react-components-input`, `react-components-details`, `react-components-detail`, `react-components-list`).
|
|
27
|
+
- Styling: Tailwind CSS 4 classes with the `smart:` prefix, precompiled in `@smartsoft001/react/styles.css`; dark mode through a `dark` class on `<html>`. Several standard implementations are deliberately unstyled markup with `data-*` attributes and class hooks; the presets carry the visual design.
|
|
28
|
+
|
|
29
|
+
## Component Availability
|
|
30
|
+
|
|
31
|
+
### Components with a registry key
|
|
32
|
+
|
|
33
|
+
Each renders the component registered under its key on `SmartProvider`, else its standard implementation.
|
|
34
|
+
|
|
35
|
+
| Component | Skill | Wrapper | Registry key | Preset |
|
|
36
|
+
| ------------------- | -------------------------------------- | ------------------------- | --------------------- | ------------------------------- |
|
|
37
|
+
| Action Panel | `react-components-action-panel` | `SmartActionPanel` | `action-panel` | `SmartActionPanelPreset` |
|
|
38
|
+
| Alert | `react-components-alert` | `SmartAlert` | `alert` | — |
|
|
39
|
+
| App | `react-components-app` | `SmartApp` | `app` | — |
|
|
40
|
+
| Avatar | `react-components-avatar` | `SmartAvatar` | `avatar` | `SmartAvatarPreset` |
|
|
41
|
+
| Badge | `react-components-badge` | `SmartBadge` | `badge` | `SmartBadgePreset` |
|
|
42
|
+
| Breadcrumbs | `react-components-breadcrumbs` | `SmartBreadcrumbs` | `breadcrumbs` | `SmartBreadcrumbsPreset` |
|
|
43
|
+
| Button | `react-components-button` | `SmartButton` | `button` | `SmartButtonPreset` |
|
|
44
|
+
| Button Group | `react-components-button-group` | `SmartButtonGroup` | `button-group` | `SmartButtonGroupPreset` |
|
|
45
|
+
| Calendar | `react-components-calendar` | `SmartCalendar` | `calendar` | `SmartCalendarPreset` |
|
|
46
|
+
| Card | `react-components-card` | `SmartCard` | `card` | `SmartCardPreset` |
|
|
47
|
+
| Card Heading | `react-components-card-heading` | `SmartCardHeading` | `card-heading` | `SmartCardHeadingPreset` |
|
|
48
|
+
| Command Palette | `react-components-command-palette` | `SmartCommandPalette` | `command-palette` | `SmartCommandPalettePreset` |
|
|
49
|
+
| Container | `react-components-container` | `SmartContainer` | `container` | `SmartContainerPreset` |
|
|
50
|
+
| Description List | `react-components-description-list` | `SmartDescriptionList` | `description-list` | `SmartDescriptionListPreset` |
|
|
51
|
+
| Details | `react-components-details` | `SmartDetails` | `details` | — |
|
|
52
|
+
| Divider | `react-components-divider` | `SmartDivider` | `divider` | `SmartDividerPreset` |
|
|
53
|
+
| Drawer | `react-components-drawer` | `SmartDrawer` | `drawer` | `SmartDrawerPreset` |
|
|
54
|
+
| Dropdown | `react-components-dropdown` | `SmartDropdown` | `dropdown` | `SmartDropdownPreset` |
|
|
55
|
+
| Empty State | `react-components-empty-state` | `SmartEmptyState` | `empty-state` | `SmartEmptyStatePreset` |
|
|
56
|
+
| Feed | `react-components-feed` | `SmartFeed` | `feed` | `SmartFeedPreset` |
|
|
57
|
+
| Form | `react-components-form` | `SmartForm` | `form` | `SmartFormPreset` |
|
|
58
|
+
| Grid List | `react-components-grid-list` | `SmartGridList` | `grid-list` | `SmartGridListPreset` |
|
|
59
|
+
| Info | `react-components-info` | `SmartInfo` | `info` | `SmartInfoPreset` |
|
|
60
|
+
| List Container | `react-components-list-container` | `SmartListContainer` | `list-container` | — |
|
|
61
|
+
| Loader | `react-components-loader` | `SmartLoader` | `loader` | `SmartLoaderPreset` |
|
|
62
|
+
| Media Object | `react-components-media-object` | `SmartMediaObject` | `media-object` | `SmartMediaObjectPreset` |
|
|
63
|
+
| Modal | `react-components-modal` | `SmartModal` | `modal` | `SmartModalPreset` |
|
|
64
|
+
| Multi-Column Layout | `react-components-multi-column-layout` | `SmartMultiColumnLayout` | `multi-column-layout` | `SmartMultiColumnLayoutPreset` |
|
|
65
|
+
| Navbar | `react-components-navbar` | `SmartNavbar` | `navbar` | `SmartNavbarPreset` |
|
|
66
|
+
| Notification | `react-components-notification` | `SmartNotification` | `notification` | `SmartNotificationPreset` |
|
|
67
|
+
| Page Heading | `react-components-page-heading` | `SmartPageHeading` | `page-heading` | `SmartPageHeadingPreset` |
|
|
68
|
+
| Paging | `react-components-paging` | `SmartPaging` | `paging` | `SmartPagingPreset` |
|
|
69
|
+
| Password Strength | `react-components-password-strength` | `SmartPasswordStrength` | `password-strength` | — |
|
|
70
|
+
| Progress Bars | `react-components-progress-bars` | `SmartProgressBars` | `progress-bars` | `SmartProgressBarsPreset` |
|
|
71
|
+
| Searchbar | `react-components-searchbar` | `SmartSearchbar` | `searchbar` | — |
|
|
72
|
+
| Section Heading | `react-components-section-heading` | `SmartSectionHeading` | `section-heading` | `SmartSectionHeadingPreset` |
|
|
73
|
+
| Select Menu | `react-components-select-menu` | `SmartSelectMenu` | `select-menu` | — |
|
|
74
|
+
| Sidebar Layout | `react-components-sidebar-layout` | `SmartSidebarLayout` | `sidebar-layout` | `SmartSidebarLayoutPreset` |
|
|
75
|
+
| Sidebar Navigation | `react-components-sidebar-navigation` | `SmartSidebarNavigation` | `sidebar-navigation` | — |
|
|
76
|
+
| Sign-in Form | `react-components-sign-in-form` | `SmartSignInForm` | `sign-in-form` | `SmartSignInFormPreset` |
|
|
77
|
+
| Stacked Layout | `react-components-stacked-layout` | `SmartStackedLayout` | `stacked-layout` | `SmartStackedLayoutPreset` |
|
|
78
|
+
| Stacked List | `react-components-stacked-list` | `SmartStackedList` | `stacked-list` | `SmartStackedListPreset` |
|
|
79
|
+
| Stats | `react-components-stats` | `SmartStats` | `stats` | `SmartStatsPreset` |
|
|
80
|
+
| Table | `react-components-table` | `SmartTable` | `table` | `SmartTablePreset` |
|
|
81
|
+
| Tabs | `react-components-tabs` | `SmartTabs` | `tabs` | `SmartTabsPreset` |
|
|
82
|
+
| Textarea | `react-components-textarea` | `SmartTextarea` | `textarea` | `SmartTextareaPreset` |
|
|
83
|
+
| Toggle | `react-components-toggle` | `SmartToggle` | `toggle` | `SmartTogglePreset` |
|
|
84
|
+
| Vertical Navigation | `react-components-vertical-navigation` | `SmartVerticalNavigation` | `vertical-navigation` | `SmartVerticalNavigationPreset` |
|
|
85
|
+
|
|
86
|
+
### Components resolved differently
|
|
87
|
+
|
|
88
|
+
| Component | Skill | Main export | How it is customised |
|
|
89
|
+
| ---------- | ----------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
90
|
+
| Accordion | `react-components-accordion` | `SmartAccordion` | No registry key: render `SmartAccordionPreset`, or a component of your own on `useAccordion`. |
|
|
91
|
+
| Date Edit | `react-components-date-edit` | `SmartDateEdit` | `variant` prop: `standard` or `preset` (`SmartDateEditPreset`); `useDateEdit`. |
|
|
92
|
+
| Date Range | `react-components-date-range` | `SmartDateRange` | `variant` prop: `standard` or `preset` (`SmartDateRangePreset`); `useDateRange`. |
|
|
93
|
+
| Detail | `react-components-detail` | `SmartDetail` | Field components by `FieldType`: `detailFieldComponents` (`DETAIL_PRESET_FIELD_COMPONENTS`); `useDetail`. |
|
|
94
|
+
| Export | `react-components-export` | `SmartExport` | Renders `SmartButton` (the `button` key); `useExport`. |
|
|
95
|
+
| Icon | `react-components-icon` | `SmartIcon` | No registry key: `template` prop, or `SmartIconPreset`. |
|
|
96
|
+
| Import | `react-components-import` | `SmartImport` | Renders `SmartButton` (the `button` key); `useImport`. |
|
|
97
|
+
| Input | `react-components-input` | `SmartInput` | Field components by `FieldType`: `inputFieldComponents` (`INPUT_PRESET_FIELD_COMPONENTS`); messages under `input-error`; `useInput`. |
|
|
98
|
+
| List | `react-components-list` | `SmartList` | Mode components: `listModeComponents` (`LIST_PRESET_MODE_COMPONENTS`); every mode at once under `list`; `useList`. |
|
|
99
|
+
| Overlays | `react-components-overlays` | `SmartOverlays` | Hosts of `ToastService` / `AlertService` / `ModalService`; they render through the `notification`, `alert` and `modal` keys. |
|
|
100
|
+
| Page | `react-components-page` | `SmartPage` | Per variant: `page` for `standard`, `page:<variant>` otherwise (`PAGE_PRESET_VARIANT_COMPONENTS`); `usePage`. |
|
|
101
|
+
|
|
102
|
+
### Cross-cutting skills
|
|
103
|
+
|
|
104
|
+
| Skill | Covers |
|
|
105
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
106
|
+
| `react-provider` | `SmartProvider` props, the full registry key table, presets, translations, the navigation adapter (routers), services and their hooks, model providers, shared types, `styles.css` and dark mode. |
|
|
107
|
+
| `react-forms` | `SmartFormControl` / `SmartFormGroup` / `SmartFormArray`, `SmartValidators`, `useControlBinding`, `FormFactory`, `useModelForm`, how `@Field` options become controls and validators. |
|
|
108
|
+
| `smart-crud-react` | `@smartsoft001/crud-shell-react`: `CrudProvider`, `CrudFullConfig`, `SmartCrudPages` / `SmartCrudListPage` / `SmartCrudItemPage`, the `crud-list-page` / `crud-item-page` bodies, filters, export, multiselect, groups, the facade and `useCrudState`. |
|
|
109
|
+
|
|
110
|
+
## Decision Logic
|
|
111
|
+
|
|
112
|
+
When a developer asks for UI:
|
|
113
|
+
|
|
114
|
+
1. **Application setup, presets, restyling everything, routing, translations, services** (toasts, alerts, modals, auth, HTTP) → use skill `react-provider` (and `react-components-overlays` for toasts / dialogs / modals from code).
|
|
115
|
+
2. **A list / item screen of a collection backed by the API** → use skill `smart-crud-react`; it builds on `SmartPage`, `SmartList`, `SmartForm` and `SmartDetails`.
|
|
116
|
+
3. **A form for a model** → `react-components-form` (rendering) and `react-forms` (building, validation); per-field editors → `react-components-input`.
|
|
117
|
+
4. **Read-only fields of a record** → `react-components-details` (whole record) or `react-components-detail` (single fields).
|
|
118
|
+
5. **Records of a model in a list** → `react-components-list`; plain rows → `react-components-table` or `react-components-stacked-list`.
|
|
119
|
+
6. **Any other component** → the matching `react-components-*` skill from the tables above, for its props, callbacks, registry key, preset and hook.
|
|
120
|
+
7. **A custom implementation of a component** → that component's skill: it shows the props type to accept, the `use<Name>` hook to build on and the key to register under.
|
|
121
|
+
|
|
122
|
+
Always open the component's skill before writing code against it: props and option names differ between components, and several option fields are declared but read only by the preset (or by none), which the skills point out.
|
|
123
|
+
|
|
124
|
+
## Skills to Use
|
|
125
|
+
|
|
126
|
+
Always delegate to the per-component skill for detailed API, usage examples and customisation:
|
|
127
|
+
|
|
128
|
+
- **Accordion** (`SmartAccordion`) → use skill `react-components-accordion`
|
|
129
|
+
- **Action Panel** (`SmartActionPanel`) → use skill `react-components-action-panel`
|
|
130
|
+
- **Alert** (`SmartAlert`) → use skill `react-components-alert`
|
|
131
|
+
- **App** (`SmartApp`) → use skill `react-components-app`
|
|
132
|
+
- **Avatar** (`SmartAvatar`) → use skill `react-components-avatar`
|
|
133
|
+
- **Badge** (`SmartBadge`) → use skill `react-components-badge`
|
|
134
|
+
- **Breadcrumbs** (`SmartBreadcrumbs`) → use skill `react-components-breadcrumbs`
|
|
135
|
+
- **Button** (`SmartButton`) → use skill `react-components-button`
|
|
136
|
+
- **Button Group** (`SmartButtonGroup`) → use skill `react-components-button-group`
|
|
137
|
+
- **Calendar** (`SmartCalendar`) → use skill `react-components-calendar`
|
|
138
|
+
- **Card** (`SmartCard`) → use skill `react-components-card`
|
|
139
|
+
- **Card Heading** (`SmartCardHeading`) → use skill `react-components-card-heading`
|
|
140
|
+
- **Command Palette** (`SmartCommandPalette`) → use skill `react-components-command-palette`
|
|
141
|
+
- **Container** (`SmartContainer`) → use skill `react-components-container`
|
|
142
|
+
- **Date Edit** (`SmartDateEdit`) → use skill `react-components-date-edit`
|
|
143
|
+
- **Date Range** (`SmartDateRange`) → use skill `react-components-date-range`
|
|
144
|
+
- **Description List** (`SmartDescriptionList`) → use skill `react-components-description-list`
|
|
145
|
+
- **Detail** (`SmartDetail`) → use skill `react-components-detail`
|
|
146
|
+
- **Details** (`SmartDetails`) → use skill `react-components-details`
|
|
147
|
+
- **Divider** (`SmartDivider`) → use skill `react-components-divider`
|
|
148
|
+
- **Drawer** (`SmartDrawer`) → use skill `react-components-drawer`
|
|
149
|
+
- **Dropdown** (`SmartDropdown`) → use skill `react-components-dropdown`
|
|
150
|
+
- **Empty State** (`SmartEmptyState`) → use skill `react-components-empty-state`
|
|
151
|
+
- **Export** (`SmartExport`) → use skill `react-components-export`
|
|
152
|
+
- **Feed** (`SmartFeed`) → use skill `react-components-feed`
|
|
153
|
+
- **Form** (`SmartForm`) → use skill `react-components-form`
|
|
154
|
+
- **Grid List** (`SmartGridList`) → use skill `react-components-grid-list`
|
|
155
|
+
- **Icon** (`SmartIcon`) → use skill `react-components-icon`
|
|
156
|
+
- **Import** (`SmartImport`) → use skill `react-components-import`
|
|
157
|
+
- **Info** (`SmartInfo`) → use skill `react-components-info`
|
|
158
|
+
- **Input** (`SmartInput`) → use skill `react-components-input`
|
|
159
|
+
- **List** (`SmartList`) → use skill `react-components-list`
|
|
160
|
+
- **List Container** (`SmartListContainer`) → use skill `react-components-list-container`
|
|
161
|
+
- **Loader** (`SmartLoader`) → use skill `react-components-loader`
|
|
162
|
+
- **Media Object** (`SmartMediaObject`) → use skill `react-components-media-object`
|
|
163
|
+
- **Modal** (`SmartModal`) → use skill `react-components-modal`
|
|
164
|
+
- **Multi-Column Layout** (`SmartMultiColumnLayout`) → use skill `react-components-multi-column-layout`
|
|
165
|
+
- **Navbar** (`SmartNavbar`) → use skill `react-components-navbar`
|
|
166
|
+
- **Notification** (`SmartNotification`) → use skill `react-components-notification`
|
|
167
|
+
- **Overlays** (`SmartOverlays`) → use skill `react-components-overlays`
|
|
168
|
+
- **Page** (`SmartPage`) → use skill `react-components-page`
|
|
169
|
+
- **Page Heading** (`SmartPageHeading`) → use skill `react-components-page-heading`
|
|
170
|
+
- **Paging** (`SmartPaging`) → use skill `react-components-paging`
|
|
171
|
+
- **Password Strength** (`SmartPasswordStrength`) → use skill `react-components-password-strength`
|
|
172
|
+
- **Progress Bars** (`SmartProgressBars`) → use skill `react-components-progress-bars`
|
|
173
|
+
- **Searchbar** (`SmartSearchbar`) → use skill `react-components-searchbar`
|
|
174
|
+
- **Section Heading** (`SmartSectionHeading`) → use skill `react-components-section-heading`
|
|
175
|
+
- **Select Menu** (`SmartSelectMenu`) → use skill `react-components-select-menu`
|
|
176
|
+
- **Sidebar Layout** (`SmartSidebarLayout`) → use skill `react-components-sidebar-layout`
|
|
177
|
+
- **Sidebar Navigation** (`SmartSidebarNavigation`) → use skill `react-components-sidebar-navigation`
|
|
178
|
+
- **Sign-in Form** (`SmartSignInForm`) → use skill `react-components-sign-in-form`
|
|
179
|
+
- **Stacked Layout** (`SmartStackedLayout`) → use skill `react-components-stacked-layout`
|
|
180
|
+
- **Stacked List** (`SmartStackedList`) → use skill `react-components-stacked-list`
|
|
181
|
+
- **Stats** (`SmartStats`) → use skill `react-components-stats`
|
|
182
|
+
- **Table** (`SmartTable`) → use skill `react-components-table`
|
|
183
|
+
- **Tabs** (`SmartTabs`) → use skill `react-components-tabs`
|
|
184
|
+
- **Textarea** (`SmartTextarea`) → use skill `react-components-textarea`
|
|
185
|
+
- **Toggle** (`SmartToggle`) → use skill `react-components-toggle`
|
|
186
|
+
- **Vertical Navigation** (`SmartVerticalNavigation`) → use skill `react-components-vertical-navigation`
|
|
187
|
+
- **Provider, registry, presets, services, navigation, translations** → use skill `react-provider`
|
|
188
|
+
- **Form engine, validators, model forms** → use skill `react-forms`
|
|
189
|
+
- **CRUD screens** → use skill `smart-crud-react`
|
|
190
|
+
|
|
191
|
+
## Installation
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
npm install @smartsoft001/react @smartsoft001/domain-core @smartsoft001/models @smartsoft001/utils react react-dom reflect-metadata
|
|
195
|
+
# CRUD screens:
|
|
196
|
+
npm install @smartsoft001/crud-shell-react
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Import `@smartsoft001/react/styles.css` (and `@smartsoft001/crud-shell-react/styles.css` with the CRUD screens) once, import `reflect-metadata` before the models, and wrap the application in `SmartProvider`.
|
|
200
|
+
|
|
201
|
+
## Public documentation
|
|
202
|
+
|
|
203
|
+
The package pages describe the same API: https://framework.smartflow.biz.pl/docs/packages/react and https://framework.smartflow.biz.pl/docs/packages/crud-shell-react. Every component also has Storybook stories in the repository (`packages/shared/react/src/lib/components/<name>/<name>.stories.tsx`).
|
|
204
|
+
|
|
205
|
+
## Import Patterns
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
// Components, their Standard / Preset implementations, hooks and types
|
|
209
|
+
import {
|
|
210
|
+
SmartButton,
|
|
211
|
+
SmartButtonPreset,
|
|
212
|
+
SmartButtonStandard,
|
|
213
|
+
useButton,
|
|
214
|
+
SmartButtonProps,
|
|
215
|
+
IButtonOptions,
|
|
216
|
+
} from '@smartsoft001/react';
|
|
217
|
+
|
|
218
|
+
// Provider, presets, services and hooks
|
|
219
|
+
import {
|
|
220
|
+
SmartProvider,
|
|
221
|
+
SMART_PRESET_COMPONENTS,
|
|
222
|
+
useTranslate,
|
|
223
|
+
useNavigation,
|
|
224
|
+
useToastService,
|
|
225
|
+
} from '@smartsoft001/react';
|
|
226
|
+
|
|
227
|
+
// Forms
|
|
228
|
+
import {
|
|
229
|
+
SmartForm,
|
|
230
|
+
SmartInput,
|
|
231
|
+
useModelForm,
|
|
232
|
+
SmartFormControl,
|
|
233
|
+
SmartValidators,
|
|
234
|
+
} from '@smartsoft001/react';
|
|
235
|
+
|
|
236
|
+
// Model metadata
|
|
237
|
+
import { Model, Field, FieldType } from '@smartsoft001/models';
|
|
238
|
+
|
|
239
|
+
// CRUD screens
|
|
240
|
+
import {
|
|
241
|
+
CrudProvider,
|
|
242
|
+
CrudFullConfig,
|
|
243
|
+
SmartCrudPages,
|
|
244
|
+
useCrudFacade,
|
|
245
|
+
useCrudState,
|
|
246
|
+
} from '@smartsoft001/crud-shell-react';
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Shared Types
|
|
250
|
+
|
|
251
|
+
- `SmartVariant`: `'primary' | 'secondary' | 'soft'`
|
|
252
|
+
- `SmartSize`: `'xs' | 'sm' | 'md' | 'lg' | 'xl'`
|
|
253
|
+
- `SmartColor`: 22 Tailwind colour names (default `'indigo'` where a component has one)
|
|
254
|
+
- `SmartPossibility`: `{ id, text, checked }`, an option of an `enum` / `radio` / `check` / `strings` field
|
|
255
|
+
|
|
256
|
+
## Styling
|
|
257
|
+
|
|
258
|
+
- Tailwind CSS 4 with the `smart:` prefix, precompiled in `@smartsoft001/react/styles.css`; use your own classes in your own markup.
|
|
259
|
+
- Dark mode via a `dark` class on `<html>`; the components carry `smart:dark:` variants.
|
|
260
|
+
- External classes through the `className` prop (each skill says which element receives it).
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-components-accordion
|
|
3
|
+
description: SmartAccordion React component API (@smartsoft001/react) — collapsible section with accordionHeader/accordionBody slots, controlled show/onShowChange or uncontrolled defaultShow, SmartAccordionPreset and the useAccordion hook for custom implementations.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Accordion (`SmartAccordion`)
|
|
8
|
+
|
|
9
|
+
`SmartAccordion` is a collapsible section: a header button that toggles a body. The header and body are `ReactNode` slots (`accordionHeader`, `accordionBody`). The open state is either controlled (`show` + `onShowChange`) or kept inside the component (`defaultShow`, or `options.open` applied once on the first render). The accordion has **no registry key**: `SmartAccordion` always renders `SmartAccordionDefault`; for the styled look render `SmartAccordionPreset` directly.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Showing or hiding a block of content behind a clickable header (FAQ entries, advanced settings)
|
|
14
|
+
- Controlling the open state from the parent (`show` + `onShowChange`) or leaving it to the component
|
|
15
|
+
- Choosing between the default bordered card and the styled `SmartAccordionPreset`
|
|
16
|
+
- Building a collapsible section of your own on `useAccordion`
|
|
17
|
+
|
|
18
|
+
## Exports
|
|
19
|
+
|
|
20
|
+
All from `@smartsoft001/react`.
|
|
21
|
+
|
|
22
|
+
| Export | Kind | What it is |
|
|
23
|
+
| ----------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
24
|
+
| `SmartAccordion` | component | `SmartAccordionDefault` fed with the `accordionHeader` / `accordionBody` slots. |
|
|
25
|
+
| `SmartAccordionBody` | component | The padded content of an open accordion. |
|
|
26
|
+
| `SmartAccordionDefault` | component | The default accordion rendering: a bordered card whose header toggles the body. |
|
|
27
|
+
| `SmartAccordionHeader` | component | The header button of `SmartAccordionDefault`, with a chevron pointing up while `open`. |
|
|
28
|
+
| `SmartAccordionPreset` | component | Styled accordion variation (preset), based on the Preline bordered accordion. |
|
|
29
|
+
| `useAccordion` | hook | The behaviour every accordion variant shares: the open state, controlled through `show` + `onShowChange` or kept internally, and `toggle()`, which does nothing while `options.disabled`. |
|
|
30
|
+
|
|
31
|
+
The preset's class helpers (`getAccordionPresetContainerClasses`, `getAccordionPresetToggleClasses`, `getAccordionPresetContentClasses`, `getAccordionPresetIconClasses`) are exported too, for a custom implementation that wants the preset look.
|
|
32
|
+
|
|
33
|
+
## Props and Types
|
|
34
|
+
|
|
35
|
+
### `SmartAccordionProps`
|
|
36
|
+
|
|
37
|
+
Props of `SmartAccordion`. Extends `SmartAccordionStateProps`.
|
|
38
|
+
|
|
39
|
+
| Prop | Type | Default | Description |
|
|
40
|
+
| ------------------ | ----------- | ------- | ---------------------------------- |
|
|
41
|
+
| `className?` | `string` | — | Classes appended to the container. |
|
|
42
|
+
| `accordionHeader?` | `ReactNode` | — | Content of the header button. |
|
|
43
|
+
| `accordionBody?` | `ReactNode` | — | Content shown while open. |
|
|
44
|
+
|
|
45
|
+
### `SmartAccordionStateProps`
|
|
46
|
+
|
|
47
|
+
The open state every accordion shares: `show` and `options`. Pass `show` + `onShowChange` to control it; leave `show` undefined to let the accordion keep its own state, starting from `defaultShow` (or `options.open`).
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Default | Description |
|
|
50
|
+
| --------------- | ------------------------- | ------- | -------------------------------------------------------------------------------- |
|
|
51
|
+
| `show?` | `boolean` | — | Controlled open state; `undefined` keeps the state internal. |
|
|
52
|
+
| `defaultShow?` | `boolean` | `false` | Initial open state when uncontrolled. |
|
|
53
|
+
| `onShowChange?` | `(show: boolean) => void` | — | Every change of `show`: toggles and the initial `options.open`. |
|
|
54
|
+
| `options?` | `IAccordionOptions` | — | `open` (initial state, applied once) and `disabled` (the header ignores clicks). |
|
|
55
|
+
|
|
56
|
+
### `SmartAccordionBaseProps`
|
|
57
|
+
|
|
58
|
+
Props of the accordion variations (`SmartAccordionDefault`, `SmartAccordionPreset`): the slots are `headerTpl` / `bodyTpl` instead of `accordionHeader` / `accordionBody`. Extends `SmartAccordionStateProps`.
|
|
59
|
+
|
|
60
|
+
| Prop | Type | Default | Description |
|
|
61
|
+
| ------------ | ----------- | -------- | ---------------------------------- |
|
|
62
|
+
| `className?` | `string` | — | Classes appended to the container. |
|
|
63
|
+
| `headerTpl` | `ReactNode` | required | Content of the header button. |
|
|
64
|
+
| `bodyTpl` | `ReactNode` | required | Content shown while open. |
|
|
65
|
+
|
|
66
|
+
### `SmartAccordionHeaderProps`
|
|
67
|
+
|
|
68
|
+
Props of `SmartAccordionHeader`, the header button of the default variation.
|
|
69
|
+
|
|
70
|
+
| Prop | Type | Default | Description |
|
|
71
|
+
| ------------ | ----------- | ------- | ------------------------------- |
|
|
72
|
+
| `open?` | `boolean` | `false` | Chevron up while `true`. |
|
|
73
|
+
| `disabled?` | `boolean` | `false` | Renders the button disabled. |
|
|
74
|
+
| `className?` | `string` | — | Classes appended to the button. |
|
|
75
|
+
| `children?` | `ReactNode` | — | Content of the button. |
|
|
76
|
+
|
|
77
|
+
### `SmartAccordionBodyProps`
|
|
78
|
+
|
|
79
|
+
Props of `SmartAccordionBody`, the padded body of the default variation.
|
|
80
|
+
|
|
81
|
+
| Prop | Type | Default | Description |
|
|
82
|
+
| ------------ | ----------- | ------- | ----------------------------- |
|
|
83
|
+
| `className?` | `string` | — | Classes appended to the body. |
|
|
84
|
+
| `children?` | `ReactNode` | — | Content of the body. |
|
|
85
|
+
|
|
86
|
+
### `IAccordionOptions`
|
|
87
|
+
|
|
88
|
+
| Field | Type | Default | Description |
|
|
89
|
+
| ----------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
90
|
+
| `open?` | `boolean` | — | Initial open state, applied once on the first render by every variant: an uncontrolled accordion starts open, and `onShowChange(true)` is reported unless `show` / `defaultShow` was already `true`. Later changes to this flag are ignored; toggles and the `show` prop take over. A controlled accordion stays as its `show` prop says until the parent applies the reported change. |
|
|
91
|
+
| `disabled?` | `boolean` | `false` | Prevents `toggle()` from changing `show` (the header ignores clicks). |
|
|
92
|
+
| `animated?` | `boolean` | — | @deprecated No accordion variant (default or preset) animates anything; this flag has no effect. |
|
|
93
|
+
|
|
94
|
+
## Controlled and uncontrolled
|
|
95
|
+
|
|
96
|
+
- **Uncontrolled**: leave `show` undefined. The accordion keeps its own state, starting from `defaultShow` (default `false`) or `options.open`. `onShowChange` still reports every toggle.
|
|
97
|
+
- **Controlled**: pass `show` and update it from `onShowChange`. A toggle only calls `onShowChange(next)`; the accordion stays as `show` says until the parent changes it.
|
|
98
|
+
- `options.open` is read once, on the first render. When it is `true` and the initial state is closed, the accordion reports `onShowChange(true)` once. Later changes of `options.open` are ignored.
|
|
99
|
+
- `options.disabled` makes the header ignore clicks (the header is rendered disabled).
|
|
100
|
+
|
|
101
|
+
## Usage
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { useState } from 'react';
|
|
105
|
+
|
|
106
|
+
import { SmartAccordion, SmartAccordionPreset } from '@smartsoft001/react';
|
|
107
|
+
|
|
108
|
+
export function Faq() {
|
|
109
|
+
const [open, setOpen] = useState(false);
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div className="space-y-4">
|
|
113
|
+
{/* Uncontrolled, starts closed. */}
|
|
114
|
+
<SmartAccordion
|
|
115
|
+
accordionHeader="What is the return policy?"
|
|
116
|
+
accordionBody={<p>You can return any item within 30 days.</p>}
|
|
117
|
+
/>
|
|
118
|
+
|
|
119
|
+
{/* Controlled by the parent. */}
|
|
120
|
+
<SmartAccordion
|
|
121
|
+
show={open}
|
|
122
|
+
onShowChange={setOpen}
|
|
123
|
+
accordionHeader="Shipping"
|
|
124
|
+
accordionBody={<p>We ship worldwide.</p>}
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
{/* The styled variation, rendered directly (slots are headerTpl / bodyTpl). */}
|
|
128
|
+
<SmartAccordionPreset
|
|
129
|
+
headerTpl="What is the best thing about Switzerland?"
|
|
130
|
+
bodyTpl="I don't know, but the flag is a big plus."
|
|
131
|
+
defaultShow
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Replacing the Implementation
|
|
139
|
+
|
|
140
|
+
The accordion has no `SmartProvider` registry key, so it cannot be swapped application-wide. Pick the variation where you render it:
|
|
141
|
+
|
|
142
|
+
- `SmartAccordion` (slots `accordionHeader` / `accordionBody`) renders `SmartAccordionDefault`, a bordered card with `SmartAccordionHeader` and `SmartAccordionBody`.
|
|
143
|
+
- `SmartAccordionPreset` (slots `headerTpl` / `bodyTpl`) is the styled variation, based on the Preline bordered accordion: the toggle button carries `aria-expanded` / `aria-controls` and the open body is a `region`.
|
|
144
|
+
- For a look of your own, write a component on `useAccordion` and render it in place of `SmartAccordion`.
|
|
145
|
+
|
|
146
|
+
### The `useAccordion` hook
|
|
147
|
+
|
|
148
|
+
The behaviour every accordion variant shares: the open state, controlled through `show` + `onShowChange` or kept internally, and `toggle()`, which does nothing while `options.disabled`. `options.open` is applied once, on the first render: an uncontrolled accordion starts open, and `onShowChange(true)` is reported unless `show` / `defaultShow` was already `true`. A controlled accordion stays as its `show` prop says until the parent applies that change. Later changes of `options.open` are ignored.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
function useAccordion({
|
|
152
|
+
show: showProp,
|
|
153
|
+
defaultShow = false,
|
|
154
|
+
onShowChange,
|
|
155
|
+
options,
|
|
156
|
+
}: SmartAccordionStateProps);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
| Returns | Type | Description |
|
|
160
|
+
| ------------------------ | ------------ | --------------------------------------------------------------------------------------------- |
|
|
161
|
+
| `show` | `boolean` | The current open state (the `show` prop when controlled). |
|
|
162
|
+
| `toggle` | `() => void` | Flips the state and reports it through `onShowChange`; does nothing while `options.disabled`. |
|
|
163
|
+
| `sharedContainerClasses` | `string[]` | The border and divider classes (with `smart:dark:` variants) of the default container. |
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import { SmartAccordionBaseProps, useAccordion } from '@smartsoft001/react';
|
|
167
|
+
|
|
168
|
+
export function PlainAccordion(props: SmartAccordionBaseProps) {
|
|
169
|
+
const { show, toggle } = useAccordion(props);
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<section className={props.className}>
|
|
173
|
+
<button
|
|
174
|
+
type="button"
|
|
175
|
+
aria-expanded={show}
|
|
176
|
+
onClick={toggle}
|
|
177
|
+
disabled={props.options?.disabled}
|
|
178
|
+
>
|
|
179
|
+
{props.headerTpl}
|
|
180
|
+
</button>
|
|
181
|
+
{show && <div>{props.bodyTpl}</div>}
|
|
182
|
+
</section>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Styling
|
|
188
|
+
|
|
189
|
+
- Tailwind 4 classes with the `smart:` prefix; the default container uses `useAccordion().sharedContainerClasses` and the preset its own `getAccordionPreset*Classes`, both with `smart:dark:` variants.
|
|
190
|
+
- `className` is appended to the container in both variations.
|
|
191
|
+
- `options.animated` is deprecated and has no effect.
|
|
192
|
+
|
|
193
|
+
## File Locations
|
|
194
|
+
|
|
195
|
+
Source: `packages/shared/react/src/lib/components/accordion/` in the smartsoft001 repository.
|
|
196
|
+
|
|
197
|
+
- `accordion.tsx`: `SmartAccordion`
|
|
198
|
+
- `accordion.types.ts`: `SmartAccordionStateProps`, `SmartAccordionBaseProps`, `SmartAccordionProps`, `SmartAccordionHeaderProps`, `SmartAccordionBodyProps`
|
|
199
|
+
- `body/accordion-body.tsx`: `SmartAccordionBody`
|
|
200
|
+
- `default/accordion-default.tsx`: `SmartAccordionDefault`
|
|
201
|
+
- `header/accordion-header.tsx`: `SmartAccordionHeader`
|
|
202
|
+
- `preset/accordion-preset.tsx`: `SmartAccordionPreset`
|
|
203
|
+
- `use-accordion.ts`: `useAccordion`
|
|
204
|
+
- `accordion.stories.tsx`: Storybook stories
|