@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.
Files changed (149) hide show
  1. package/.claude-plugin/marketplace.json +14 -3
  2. package/README.md +19 -4
  3. package/package.json +3 -3
  4. package/plugins/smart-angular/.claude-plugin/plugin.json +6 -0
  5. package/plugins/{smart → smart-angular}/skills/angular-components-button/SKILL.md +1 -1
  6. package/plugins/{smart → smart-angular}/skills/angular-components-container/SKILL.md +8 -8
  7. package/plugins/{smart → smart-angular}/skills/angular-components-drawer/SKILL.md +5 -9
  8. package/plugins/{smart → smart-angular}/skills/angular-components-list-container/SKILL.md +2 -5
  9. package/plugins/{smart → smart-angular}/skills/angular-components-media-object/SKILL.md +1 -1
  10. package/plugins/{smart → smart-angular}/skills/angular-components-modal/SKILL.md +1 -1
  11. package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/SKILL.md +1 -1
  12. package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-claude-config.md +13 -9
  13. package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/patch-delta.md +1 -1
  14. package/plugins/{smart → smart-core}/.claude-plugin/README.md +31 -16
  15. package/plugins/{smart → smart-core}/.claude-plugin/merge-permissions.js +7 -6
  16. package/plugins/smart-core/.claude-plugin/plugin.json +5 -0
  17. package/plugins/{smart → smart-core}/.claude-plugin/settings.template.json +2 -2
  18. package/plugins/{smart → smart-core}/hooks/README.md +1 -1
  19. package/plugins/{smart → smart-core}/skills/audit-log/SKILL.md +2 -2
  20. package/plugins/{smart → smart-core}/skills/format-code/SKILL.md +1 -1
  21. package/plugins/smart-react/.claude-plugin/plugin.json +6 -0
  22. package/plugins/smart-react/agents/react-components.md +260 -0
  23. package/plugins/smart-react/skills/react-components-accordion/SKILL.md +204 -0
  24. package/plugins/smart-react/skills/react-components-action-panel/SKILL.md +191 -0
  25. package/plugins/smart-react/skills/react-components-alert/SKILL.md +244 -0
  26. package/plugins/smart-react/skills/react-components-app/SKILL.md +236 -0
  27. package/plugins/smart-react/skills/react-components-avatar/SKILL.md +176 -0
  28. package/plugins/smart-react/skills/react-components-badge/SKILL.md +165 -0
  29. package/plugins/smart-react/skills/react-components-breadcrumbs/SKILL.md +183 -0
  30. package/plugins/smart-react/skills/react-components-button/SKILL.md +239 -0
  31. package/plugins/smart-react/skills/react-components-button-group/SKILL.md +187 -0
  32. package/plugins/smart-react/skills/react-components-calendar/SKILL.md +270 -0
  33. package/plugins/smart-react/skills/react-components-card/SKILL.md +201 -0
  34. package/plugins/smart-react/skills/react-components-card-heading/SKILL.md +133 -0
  35. package/plugins/smart-react/skills/react-components-command-palette/SKILL.md +228 -0
  36. package/plugins/smart-react/skills/react-components-container/SKILL.md +134 -0
  37. package/plugins/smart-react/skills/react-components-date-edit/SKILL.md +186 -0
  38. package/plugins/smart-react/skills/react-components-date-range/SKILL.md +259 -0
  39. package/plugins/smart-react/skills/react-components-description-list/SKILL.md +144 -0
  40. package/plugins/smart-react/skills/react-components-detail/SKILL.md +272 -0
  41. package/plugins/smart-react/skills/react-components-details/SKILL.md +250 -0
  42. package/plugins/smart-react/skills/react-components-divider/SKILL.md +128 -0
  43. package/plugins/smart-react/skills/react-components-drawer/SKILL.md +165 -0
  44. package/plugins/smart-react/skills/react-components-dropdown/SKILL.md +194 -0
  45. package/plugins/smart-react/skills/react-components-empty-state/SKILL.md +202 -0
  46. package/plugins/smart-react/skills/react-components-export/SKILL.md +120 -0
  47. package/plugins/smart-react/skills/react-components-feed/SKILL.md +171 -0
  48. package/plugins/smart-react/skills/react-components-form/SKILL.md +319 -0
  49. package/plugins/smart-react/skills/react-components-grid-list/SKILL.md +172 -0
  50. package/plugins/smart-react/skills/react-components-icon/SKILL.md +117 -0
  51. package/plugins/smart-react/skills/react-components-import/SKILL.md +113 -0
  52. package/plugins/smart-react/skills/react-components-info/SKILL.md +147 -0
  53. package/plugins/smart-react/skills/react-components-input/SKILL.md +406 -0
  54. package/plugins/smart-react/skills/react-components-list/SKILL.md +384 -0
  55. package/plugins/smart-react/skills/react-components-list-container/SKILL.md +105 -0
  56. package/plugins/smart-react/skills/react-components-loader/SKILL.md +126 -0
  57. package/plugins/smart-react/skills/react-components-media-object/SKILL.md +130 -0
  58. package/plugins/smart-react/skills/react-components-modal/SKILL.md +266 -0
  59. package/plugins/smart-react/skills/react-components-multi-column-layout/SKILL.md +155 -0
  60. package/plugins/smart-react/skills/react-components-navbar/SKILL.md +211 -0
  61. package/plugins/smart-react/skills/react-components-notification/SKILL.md +223 -0
  62. package/plugins/smart-react/skills/react-components-overlays/SKILL.md +182 -0
  63. package/plugins/smart-react/skills/react-components-page/SKILL.md +224 -0
  64. package/plugins/smart-react/skills/react-components-page-heading/SKILL.md +155 -0
  65. package/plugins/smart-react/skills/react-components-paging/SKILL.md +183 -0
  66. package/plugins/smart-react/skills/react-components-password-strength/SKILL.md +149 -0
  67. package/plugins/smart-react/skills/react-components-progress-bars/SKILL.md +195 -0
  68. package/plugins/smart-react/skills/react-components-searchbar/SKILL.md +150 -0
  69. package/plugins/smart-react/skills/react-components-section-heading/SKILL.md +138 -0
  70. package/plugins/smart-react/skills/react-components-select-menu/SKILL.md +168 -0
  71. package/plugins/smart-react/skills/react-components-sidebar-layout/SKILL.md +155 -0
  72. package/plugins/smart-react/skills/react-components-sidebar-navigation/SKILL.md +277 -0
  73. package/plugins/smart-react/skills/react-components-sign-in-form/SKILL.md +228 -0
  74. package/plugins/smart-react/skills/react-components-stacked-layout/SKILL.md +146 -0
  75. package/plugins/smart-react/skills/react-components-stacked-list/SKILL.md +156 -0
  76. package/plugins/smart-react/skills/react-components-stats/SKILL.md +149 -0
  77. package/plugins/smart-react/skills/react-components-table/SKILL.md +222 -0
  78. package/plugins/smart-react/skills/react-components-tabs/SKILL.md +189 -0
  79. package/plugins/smart-react/skills/react-components-textarea/SKILL.md +202 -0
  80. package/plugins/smart-react/skills/react-components-toggle/SKILL.md +157 -0
  81. package/plugins/smart-react/skills/react-components-vertical-navigation/SKILL.md +212 -0
  82. package/plugins/smart-react/skills/react-forms/SKILL.md +272 -0
  83. package/plugins/smart-react/skills/react-provider/SKILL.md +368 -0
  84. package/plugins/smart-react/skills/smart-crud-react/SKILL.md +410 -0
  85. package/plugins/smart/.claude-plugin/plugin.json +0 -5
  86. /package/plugins/{smart/agents/angular-components/AGENT.md → smart-angular/agents/angular-components.md} +0 -0
  87. /package/plugins/{smart → smart-angular}/skills/angular-components-accordion/SKILL.md +0 -0
  88. /package/plugins/{smart → smart-angular}/skills/angular-components-action-panel/SKILL.md +0 -0
  89. /package/plugins/{smart → smart-angular}/skills/angular-components-alert/SKILL.md +0 -0
  90. /package/plugins/{smart → smart-angular}/skills/angular-components-avatar/SKILL.md +0 -0
  91. /package/plugins/{smart → smart-angular}/skills/angular-components-badge/SKILL.md +0 -0
  92. /package/plugins/{smart → smart-angular}/skills/angular-components-breadcrumbs/SKILL.md +0 -0
  93. /package/plugins/{smart → smart-angular}/skills/angular-components-button-group/SKILL.md +0 -0
  94. /package/plugins/{smart → smart-angular}/skills/angular-components-calendar/SKILL.md +0 -0
  95. /package/plugins/{smart → smart-angular}/skills/angular-components-card/SKILL.md +0 -0
  96. /package/plugins/{smart → smart-angular}/skills/angular-components-card-heading/SKILL.md +0 -0
  97. /package/plugins/{smart → smart-angular}/skills/angular-components-command-palette/SKILL.md +0 -0
  98. /package/plugins/{smart → smart-angular}/skills/angular-components-date-edit/SKILL.md +0 -0
  99. /package/plugins/{smart → smart-angular}/skills/angular-components-date-range/SKILL.md +0 -0
  100. /package/plugins/{smart → smart-angular}/skills/angular-components-description-list/SKILL.md +0 -0
  101. /package/plugins/{smart → smart-angular}/skills/angular-components-detail/SKILL.md +0 -0
  102. /package/plugins/{smart → smart-angular}/skills/angular-components-details/SKILL.md +0 -0
  103. /package/plugins/{smart → smart-angular}/skills/angular-components-divider/SKILL.md +0 -0
  104. /package/plugins/{smart → smart-angular}/skills/angular-components-dropdown/SKILL.md +0 -0
  105. /package/plugins/{smart → smart-angular}/skills/angular-components-empty-state/SKILL.md +0 -0
  106. /package/plugins/{smart → smart-angular}/skills/angular-components-feed/SKILL.md +0 -0
  107. /package/plugins/{smart → smart-angular}/skills/angular-components-form/SKILL.md +0 -0
  108. /package/plugins/{smart → smart-angular}/skills/angular-components-grid-list/SKILL.md +0 -0
  109. /package/plugins/{smart → smart-angular}/skills/angular-components-icon/SKILL.md +0 -0
  110. /package/plugins/{smart → smart-angular}/skills/angular-components-info/SKILL.md +0 -0
  111. /package/plugins/{smart → smart-angular}/skills/angular-components-input/SKILL.md +0 -0
  112. /package/plugins/{smart → smart-angular}/skills/angular-components-list/SKILL.md +0 -0
  113. /package/plugins/{smart → smart-angular}/skills/angular-components-multi-column-layout/SKILL.md +0 -0
  114. /package/plugins/{smart → smart-angular}/skills/angular-components-navbar/SKILL.md +0 -0
  115. /package/plugins/{smart → smart-angular}/skills/angular-components-notification/SKILL.md +0 -0
  116. /package/plugins/{smart → smart-angular}/skills/angular-components-page/SKILL.md +0 -0
  117. /package/plugins/{smart → smart-angular}/skills/angular-components-page-heading/SKILL.md +0 -0
  118. /package/plugins/{smart → smart-angular}/skills/angular-components-paging/SKILL.md +0 -0
  119. /package/plugins/{smart → smart-angular}/skills/angular-components-password-strength/SKILL.md +0 -0
  120. /package/plugins/{smart → smart-angular}/skills/angular-components-progress-bars/SKILL.md +0 -0
  121. /package/plugins/{smart → smart-angular}/skills/angular-components-searchbar/SKILL.md +0 -0
  122. /package/plugins/{smart → smart-angular}/skills/angular-components-section-heading/SKILL.md +0 -0
  123. /package/plugins/{smart → smart-angular}/skills/angular-components-select-menu/SKILL.md +0 -0
  124. /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-layout/SKILL.md +0 -0
  125. /package/plugins/{smart → smart-angular}/skills/angular-components-sidebar-navigation/SKILL.md +0 -0
  126. /package/plugins/{smart → smart-angular}/skills/angular-components-sign-in-form/SKILL.md +0 -0
  127. /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-layout/SKILL.md +0 -0
  128. /package/plugins/{smart → smart-angular}/skills/angular-components-stacked-list/SKILL.md +0 -0
  129. /package/plugins/{smart → smart-angular}/skills/angular-components-stats/SKILL.md +0 -0
  130. /package/plugins/{smart → smart-angular}/skills/angular-components-table/SKILL.md +0 -0
  131. /package/plugins/{smart → smart-angular}/skills/angular-components-tabs/SKILL.md +0 -0
  132. /package/plugins/{smart → smart-angular}/skills/angular-components-textarea/SKILL.md +0 -0
  133. /package/plugins/{smart → smart-angular}/skills/angular-components-toggle/SKILL.md +0 -0
  134. /package/plugins/{smart → smart-angular}/skills/angular-components-vertical-navigation/SKILL.md +0 -0
  135. /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-app.md +0 -0
  136. /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/base-shared-lib.md +0 -0
  137. /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/references/version-resolution.md +0 -0
  138. /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/derive-prefix.sh +0 -0
  139. /package/plugins/{smart → smart-angular}/skills/scaffold-nx-workspace/scripts/verify-scaffold.sh +0 -0
  140. /package/plugins/{smart → smart-angular}/skills/smart-crud/SKILL.md +0 -0
  141. /package/plugins/{smart → smart-core}/hooks/CONFIG.md +0 -0
  142. /package/plugins/{smart → smart-core}/hooks/audit_logger.py +0 -0
  143. /package/plugins/{smart → smart-core}/hooks/auto_format.sh +0 -0
  144. /package/plugins/{smart → smart-core}/hooks/hooks.json +0 -0
  145. /package/plugins/{smart → smart-core}/hooks/safety_validator.py +0 -0
  146. /package/plugins/{smart → smart-core}/hooks/sensitive_file_blocker.py +0 -0
  147. /package/plugins/{smart → smart-core}/hooks/skill_validator.py +0 -0
  148. /package/plugins/{smart → smart-core}/skills/project-conventions/SKILL.md +0 -0
  149. /package/plugins/{smart → smart-core}/skills/safety-check/SKILL.md +0 -0
@@ -0,0 +1,368 @@
1
+ ---
2
+ name: react-provider
3
+ description: SmartProvider of @smartsoft001/react, the root every React component reads — the components registry (every registry key), SMART_PRESET_COMPONENTS and the per-area preset maps, translations (language, translations, translate, useTranslate), the navigation adapter for a router (createHistoryNavigation, linkComponent), the services and their hooks (auth, HTTP, files, toasts, alerts, modals, menu, app), the model providers, styles.css and dark mode, and the shared option types.
4
+ user-invocable: false
5
+ ---
6
+
7
+ # SmartProvider (`@smartsoft001/react`)
8
+
9
+ `SmartProvider` is the root of an application built with `@smartsoft001/react`. It supplies, to every component below it: the translations, a router-agnostic navigation adapter, the services (auth, storage, HTTP, files, toasts, alerts, modals, menu, app title), the **component registry** that swaps implementations, and the model providers. It also renders the hosts of toasts, alerts and modals after its children. Without a provider the components still work, against a default configuration created on first use.
10
+
11
+ ## When to Use This Skill
12
+
13
+ - Setting up a React application: install, stylesheet, dark mode, the provider at the root
14
+ - Restyling the application with the presets (`SMART_PRESET_COMPONENTS`) or registering implementations of your own (`components`, `inputFieldComponents`, `detailFieldComponents`, `listModeComponents`)
15
+ - Looking up the registry key of a component
16
+ - Connecting a router (React Router, Next.js, ...) through `navigation` and `linkComponent`
17
+ - Translating the library (Polish by default, English with `language="eng"`), adding `MODEL.<field>` labels, or plugging in i18next
18
+ - Using the services from a component (`useAuthService`, `useHttpClient`, `useToastService`, ...)
19
+ - Supplying labels, options or validators of model fields from code (the model providers)
20
+
21
+ ## Install and set up
22
+
23
+ ```bash
24
+ npm install @smartsoft001/react @smartsoft001/domain-core @smartsoft001/models @smartsoft001/utils react react-dom reflect-metadata
25
+ ```
26
+
27
+ - React 19, `reflect-metadata` and the three `@smartsoft001` packages are peer dependencies. Import `reflect-metadata` once before any `@Model` class is evaluated, and enable `experimentalDecorators` / `emitDecoratorMetadata` in the TypeScript config for the model decorators.
28
+ - Import the compiled stylesheet once: `import '@smartsoft001/react/styles.css';`. Every utility in it carries the `smart:` prefix, so it does not clash with the application's own Tailwind (your own markup uses your own classes, not `smart:` ones).
29
+ - Dark mode is class-based: a `dark` class on `<html>` (or any ancestor) switches every component to its `smart:dark:` variants.
30
+
31
+ ```tsx
32
+ import 'reflect-metadata';
33
+ import '@smartsoft001/react/styles.css';
34
+
35
+ import type { ReactNode } from 'react';
36
+
37
+ import {
38
+ createHistoryNavigation,
39
+ SMART_PRESET_COMPONENTS,
40
+ SmartProvider,
41
+ } from '@smartsoft001/react';
42
+
43
+ // Created once: the adapter listens to the browser history.
44
+ const navigation = createHistoryNavigation();
45
+
46
+ const translations = {
47
+ MODEL: { title: 'Title', body: 'Body' },
48
+ ROUTES: { notes: 'Notes' },
49
+ };
50
+
51
+ export function AppProviders({ children }: { children: ReactNode }) {
52
+ return (
53
+ <SmartProvider
54
+ language="eng"
55
+ translations={translations}
56
+ navigation={navigation}
57
+ fileServiceConfig={{ apiUrl: '/api' }}
58
+ {...SMART_PRESET_COMPONENTS}
59
+ >
60
+ {children}
61
+ </SmartProvider>
62
+ );
63
+ }
64
+ ```
65
+
66
+ The provider creates its services **once** and keeps them for its lifetime. Pass stable objects (module constants or memoised values) for `components`, `translations`, `navigation` and the providers, or the context changes on every render.
67
+
68
+ ## `SmartProvider` props
69
+
70
+ | Prop | Type | Default | What it does |
71
+ | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
72
+ | `language` | `string` | `'pl'` | `'pl'` or `'eng'`, the languages the library ships text for. |
73
+ | `translations` | `SmartTranslations` | — | The application's dictionary, deep-merged over the library's. |
74
+ | `translate` | `SmartTranslateFn` | — | Replaces the dictionary lookup entirely (e.g. i18next's `t`); `language` and `translations` are then ignored. |
75
+ | `navigation` | `ISmartNavigation` | `createHistoryNavigation()` | How components navigate and render internal links. |
76
+ | `components` | `SmartComponentOverrides` | `{}` | Implementations by registry key (see below). |
77
+ | `inputFieldComponents` | `Partial<Record<FieldTypeDef, ComponentType<any>>>` | `{}` | Form field components by `FieldType` (`react-components-input`). |
78
+ | `detailFieldComponents` | `Partial<Record<FieldTypeDef, ComponentType<any>>>` | `{}` | Detail field components by `FieldType` (`react-components-detail`). |
79
+ | `listModeComponents` | `Partial<Record<ListMode, ComponentType<any>>>` | `{}` | List components by `ListMode` (`react-components-list`). |
80
+ | `overlays` | `ReactNode` | `<SmartOverlays />` | Rendered after `children`: the toast, alert and modal hosts. `null` to render them yourself (`react-components-overlays`). |
81
+ | `fileServiceConfig` | `IFileServiceConfig` (`{ apiUrl }`) | — | Creates the `FileService` (attachments under `<apiUrl>/attachments`); enables the upload fields. |
82
+ | `fileService` | `FileService` | — | A file service of your own (wins over `fileServiceConfig`). |
83
+ | `http` | `SmartHttpClient` | a client with the auth interceptor | The HTTP client the services and CRUD features use. |
84
+ | `authInterceptor` | `boolean` | `true` | Adds the bearer token to the default HTTP client's requests. |
85
+ | `storageService`, `authService`, `toastService`, `alertService`, `modalService`, `menuService`, `appService` | the service classes | created by the provider | Services of your own (e.g. subclasses). |
86
+ | `modelLabelProvider` | `IModelLabelProvider \| null` | `null` | Field labels from code. |
87
+ | `modelPossibilitiesProvider` | `IModelPossibilitiesProvider \| null` | `null` | Options of `enum` / `radio` / `check` / `strings` fields from code. |
88
+ | `modelValidatorsProvider` | `IModelValidatorsProvider \| null` | `null` | Validators of model fields from code (`react-forms`). |
89
+ | `modelExportProvider`, `modelImportProvider`, `appProvider` | provider interfaces | `null` | Held in the context (`useSmart()`) for components of your own; no library component reads them. |
90
+ | `children` | `ReactNode` | — | The application. |
91
+
92
+ ## The components registry
93
+
94
+ A wrapper component (`SmartButton`, `SmartCard`, ...) renders `useSmartComponent(key, Standard)`: the component registered under its key on `SmartProvider`, else its standard implementation. A registered component receives the same props as the standard one, so it can be a preset, a component of your own built on the wrapper's `use<Name>` hook, or a wrapper around the standard one.
95
+
96
+ ```tsx
97
+ import type { ReactNode } from 'react';
98
+
99
+ import {
100
+ SmartButtonProps,
101
+ SmartButtonStandard,
102
+ SmartCardPreset,
103
+ SmartProvider,
104
+ } from '@smartsoft001/react';
105
+
106
+ function TrackedButton(props: SmartButtonProps) {
107
+ return (
108
+ <SmartButtonStandard
109
+ {...props}
110
+ options={{
111
+ ...props.options,
112
+ click: () => {
113
+ console.info('button clicked');
114
+ props.options.click();
115
+ },
116
+ }}
117
+ />
118
+ );
119
+ }
120
+
121
+ // The preset card, and the standard button wrapped with tracking.
122
+ const components = { card: SmartCardPreset, button: TrackedButton };
123
+
124
+ export function AppProviders({ children }: { children: ReactNode }) {
125
+ return <SmartProvider components={components}>{children}</SmartProvider>;
126
+ }
127
+ ```
128
+
129
+ ### Registry keys
130
+
131
+ | Key | Wrapper | Standard | Preset | Skill |
132
+ | ---------------------------------- | --------------------------------------------------------------- | -------------------------------------------------------- | ------------------------------- | -------------------------------------- |
133
+ | `action-panel` | `SmartActionPanel` | `SmartActionPanelStandard` | `SmartActionPanelPreset` | `react-components-action-panel` |
134
+ | `alert` | `SmartAlert` (and `AlertService` dialogs) | `SmartAlertStandard` | — | `react-components-alert` |
135
+ | `app` | `SmartApp` | `SmartAppStandard` | — | `react-components-app` |
136
+ | `avatar` | `SmartAvatar` | `SmartAvatarStandard` | `SmartAvatarPreset` | `react-components-avatar` |
137
+ | `badge` | `SmartBadge` | `SmartBadgeStandard` | `SmartBadgePreset` | `react-components-badge` |
138
+ | `breadcrumbs` | `SmartBreadcrumbs` | `SmartBreadcrumbsStandard` | `SmartBreadcrumbsPreset` | `react-components-breadcrumbs` |
139
+ | `button` | `SmartButton` (also `SmartExport`, `SmartImport`, page buttons) | `SmartButtonStandard` | `SmartButtonPreset` | `react-components-button` |
140
+ | `button-group` | `SmartButtonGroup` | `SmartButtonGroupStandard` | `SmartButtonGroupPreset` | `react-components-button-group` |
141
+ | `calendar` | `SmartCalendar` | `SmartCalendarStandard` | `SmartCalendarPreset` | `react-components-calendar` |
142
+ | `card` | `SmartCard` | `SmartCardStandard` | `SmartCardPreset` | `react-components-card` |
143
+ | `card-heading` | `SmartCardHeading` | `SmartCardHeadingStandard` | `SmartCardHeadingPreset` | `react-components-card-heading` |
144
+ | `command-palette` | `SmartCommandPalette` | `SmartCommandPaletteStandard` | `SmartCommandPalettePreset` | `react-components-command-palette` |
145
+ | `container` | `SmartContainer` | `SmartContainerStandard` | `SmartContainerPreset` | `react-components-container` |
146
+ | `description-list` | `SmartDescriptionList` | `SmartDescriptionListStandard` | `SmartDescriptionListPreset` | `react-components-description-list` |
147
+ | `details` | `SmartDetails` | `SmartDetailsStandard` | — | `react-components-details` |
148
+ | `divider` | `SmartDivider` | `SmartDividerStandard` | `SmartDividerPreset` | `react-components-divider` |
149
+ | `drawer` | `SmartDrawer` | `SmartDrawerStandard` | `SmartDrawerPreset` | `react-components-drawer` |
150
+ | `dropdown` | `SmartDropdown` | `SmartDropdownStandard` | `SmartDropdownPreset` | `react-components-dropdown` |
151
+ | `empty-state` | `SmartEmptyState` | `SmartEmptyStateStandard` | `SmartEmptyStatePreset` | `react-components-empty-state` |
152
+ | `feed` | `SmartFeed` | `SmartFeedStandard` | `SmartFeedPreset` | `react-components-feed` |
153
+ | `form` | `SmartForm` (the body) | `SmartFormStandard` | `SmartFormPreset` | `react-components-form` |
154
+ | `grid-list` | `SmartGridList` | `SmartGridListStandard` | `SmartGridListPreset` | `react-components-grid-list` |
155
+ | `info` | `SmartInfo` | `SmartInfoStandard` | `SmartInfoPreset` | `react-components-info` |
156
+ | `input-error` | the messages of `SmartInput` | `SmartInputError` | `SmartInputErrorPreset` | `react-components-input` |
157
+ | `list` | `SmartList` (every mode) | per `listModeComponents` | — | `react-components-list` |
158
+ | `list-container` | `SmartListContainer` | `SmartListContainerStandard` | — | `react-components-list-container` |
159
+ | `loader` | `SmartLoader` | `SmartLoaderStandard` | `SmartLoaderPreset` | `react-components-loader` |
160
+ | `media-object` | `SmartMediaObject` | `SmartMediaObjectStandard` | `SmartMediaObjectPreset` | `react-components-media-object` |
161
+ | `modal` | `SmartModal` (and `ModalService` modals) | `SmartModalStandard` | `SmartModalPreset` | `react-components-modal` |
162
+ | `multi-column-layout` | `SmartMultiColumnLayout` | `SmartMultiColumnLayoutStandard` | `SmartMultiColumnLayoutPreset` | `react-components-multi-column-layout` |
163
+ | `navbar` | `SmartNavbar` | `SmartNavbarStandard` | `SmartNavbarPreset` | `react-components-navbar` |
164
+ | `notification` | `SmartNotification` (and `ToastService` toasts) | `SmartNotificationStandard` | `SmartNotificationPreset` | `react-components-notification` |
165
+ | `page`, `page:<variant>` | `SmartPage` | `SmartPageStandard` | `SmartPagePreset` | `react-components-page` |
166
+ | `page-heading` | `SmartPageHeading` | `SmartPageHeadingStandard` | `SmartPageHeadingPreset` | `react-components-page-heading` |
167
+ | `paging` | `SmartPaging` | `SmartPagingStandard` | `SmartPagingPreset` | `react-components-paging` |
168
+ | `password-strength` | `SmartPasswordStrength` | `SmartPasswordStrengthStandard` | — | `react-components-password-strength` |
169
+ | `progress-bars` | `SmartProgressBars` | `SmartProgressBarsStandard` | `SmartProgressBarsPreset` | `react-components-progress-bars` |
170
+ | `searchbar` | `SmartSearchbar` | `SmartSearchbarStandard` | — | `react-components-searchbar` |
171
+ | `section-heading` | `SmartSectionHeading` | `SmartSectionHeadingStandard` | `SmartSectionHeadingPreset` | `react-components-section-heading` |
172
+ | `select-menu` | `SmartSelectMenu` | `SmartSelectMenuStandard` | — | `react-components-select-menu` |
173
+ | `sidebar-layout` | `SmartSidebarLayout` | `SmartSidebarLayoutStandard` | `SmartSidebarLayoutPreset` | `react-components-sidebar-layout` |
174
+ | `sidebar-navigation` | `SmartSidebarNavigation` | `SmartSidebarNavigationStandard` | — | `react-components-sidebar-navigation` |
175
+ | `sign-in-form` | `SmartSignInForm` | `SmartSignInFormStandard` | `SmartSignInFormPreset` | `react-components-sign-in-form` |
176
+ | `stacked-layout` | `SmartStackedLayout` | `SmartStackedLayoutStandard` | `SmartStackedLayoutPreset` | `react-components-stacked-layout` |
177
+ | `stacked-list` | `SmartStackedList` | `SmartStackedListStandard` | `SmartStackedListPreset` | `react-components-stacked-list` |
178
+ | `stats` | `SmartStats` | `SmartStatsStandard` | `SmartStatsPreset` | `react-components-stats` |
179
+ | `table` | `SmartTable` | `SmartTableStandard` | `SmartTablePreset` | `react-components-table` |
180
+ | `tabs` | `SmartTabs` | `SmartTabsStandard` | `SmartTabsPreset` | `react-components-tabs` |
181
+ | `textarea` | `SmartTextarea` | `SmartTextareaStandard` | `SmartTextareaPreset` | `react-components-textarea` |
182
+ | `toggle` | `SmartToggle` | `SmartToggleStandard` | `SmartTogglePreset` | `react-components-toggle` |
183
+ | `vertical-navigation` | `SmartVerticalNavigation` | `SmartVerticalNavigationStandard` | `SmartVerticalNavigationPreset` | `react-components-vertical-navigation` |
184
+ | `crud-list-page`, `crud-item-page` | the bodies of the CRUD pages | `SmartCrudListPageStandard`, `SmartCrudItemPageStandard` | — | `smart-crud-react` |
185
+
186
+ Components without a registry key: `SmartAccordion` (render `SmartAccordionPreset` directly), `SmartDateEdit` and `SmartDateRange` (a `variant` prop), `SmartIcon` (a `template` prop), `SmartExport` / `SmartImport` (they render `SmartButton`), `SmartDetail` / `SmartInput` (field maps) and the overlay hosts.
187
+
188
+ `DynamicComponentType` is the union of the built-in keys; `SmartComponentKey` also accepts any other string (the page variants, keys of your own).
189
+
190
+ ## Presets
191
+
192
+ `SMART_PRESET_COMPONENTS` is every preset the library ships, in the shape of `SmartProvider`'s props, so one spread restyles a whole application:
193
+
194
+ ```tsx
195
+ <SmartProvider {...SMART_PRESET_COMPONENTS}>{children}</SmartProvider>
196
+ ```
197
+
198
+ | Member | Registers |
199
+ | ----------------------- | ------------------------------------------------------------------------------------------------------------------------ |
200
+ | `components` | The `<Name>Preset` of every key in the table above that has one (including `page` and `page:preset`, and `input-error`). |
201
+ | `inputFieldComponents` | `INPUT_PRESET_FIELD_COMPONENTS`, the preset field component of every `FieldType`. |
202
+ | `detailFieldComponents` | `DETAIL_PRESET_FIELD_COMPONENTS`, the preset detail component of the field types that have one. |
203
+ | `listModeComponents` | `LIST_PRESET_MODE_COMPONENTS`, the preset desktop, mobile and masonry-grid lists. |
204
+
205
+ Pick single entries to register only some presets, and spread to combine them with components of your own: `components={{ ...SMART_PRESET_COMPONENTS.components, card: MyCard }}`. `PAGE_PRESET_VARIANT_COMPONENTS` registers only the `'page:preset'` page variant. Without any registration the standard implementations render; several of them (avatar, badge, container, list container, ...) are deliberately unstyled markup with `data-*` attributes and class hooks.
206
+
207
+ ## Translations
208
+
209
+ - `language`: `'pl'` (default) or `'eng'`; the library's dictionaries are `SMART_DEFAULT_TRANSLATIONS.pl` / `.eng` (`TRANSLATE_DATA_PL`, `TRANSLATE_DATA_ENG`).
210
+ - `translations`: deep-merged over the library's dictionary (`mergeTranslations`). Keys are looked up flat first, then as a path (`'MODEL.name'`); `{{name}}` placeholders are filled from params.
211
+ - `translate`: replaces the lookup (e.g. `i18next.t`). It must return the key itself for a missing translation, as the default does: label helpers rely on that.
212
+ - `useTranslate()` returns the current function: `t('cancel')`, `t('MODEL.title')`.
213
+
214
+ Keys the library reads: the top-level words (`cancel`, `confirm`, `search`, `save`, `noResults`, `details`, ...), `MODEL.<field>` (field labels), `ROUTES.<segment>` (document title parts, see `react-components-app`), `OBJECT.confirmDelete`, `INPUT.ERRORS.*` (validation messages), `INPUT.PASSWORD-STRENGTH.*`, `CALENDAR.*`, `APP.*` and `ERRORS.*`.
215
+
216
+ A field label is the `modelLabelProvider`'s answer, else the translation of `MODEL.<key>` (`useModelLabel(instance, key, type)`).
217
+
218
+ ## Navigation
219
+
220
+ The library does not depend on a router. Components navigate through an `ISmartNavigation` adapter: `navigate(url, { replace? })`, `back()`, `getCurrentUrl()` (path + query), `subscribe(listener)` and an optional `linkComponent` that renders internal links (navbar, tabs, vertical and sidebar navigation, progress steps). `createHistoryNavigation()` drives `window.history` and is the default. `useNavigation()` returns the adapter.
221
+
222
+ An adapter for React Router v6+:
223
+
224
+ ```tsx
225
+ import { useEffect, useMemo, useRef } from 'react';
226
+ import type { ComponentType, ReactNode } from 'react';
227
+
228
+ import {
229
+ ISmartLinkProps,
230
+ ISmartNavigation,
231
+ SmartProvider,
232
+ } from '@smartsoft001/react';
233
+
234
+ // The router's hooks and Link, passed in so the adapter does not import a router here.
235
+ interface RouterBindings {
236
+ navigate: (to: string | number, options?: { replace?: boolean }) => void;
237
+ location: { pathname: string; search: string };
238
+ Link: ComponentType<Omit<ISmartLinkProps, 'href'> & { to: string }>;
239
+ }
240
+
241
+ export function RouterSmartProvider({
242
+ router,
243
+ children,
244
+ }: {
245
+ router: RouterBindings;
246
+ children: ReactNode;
247
+ }) {
248
+ const listeners = useRef(new Set<(url: string) => void>());
249
+ const url = router.location.pathname + router.location.search;
250
+ const urlRef = useRef(url);
251
+ urlRef.current = url;
252
+
253
+ useEffect(() => {
254
+ for (const listener of [...listeners.current]) listener(url);
255
+ }, [url]);
256
+
257
+ const { navigate, Link } = router;
258
+
259
+ const navigation = useMemo<ISmartNavigation>(
260
+ () => ({
261
+ navigate: (to, options) => navigate(to, { replace: options?.replace }),
262
+ back: () => navigate(-1),
263
+ getCurrentUrl: () => urlRef.current,
264
+ subscribe: (listener) => {
265
+ listeners.current.add(listener);
266
+ return () => listeners.current.delete(listener);
267
+ },
268
+ linkComponent: ({ href, ...rest }: ISmartLinkProps) => (
269
+ <Link to={href} {...rest} />
270
+ ),
271
+ }),
272
+ [navigate, Link],
273
+ );
274
+
275
+ return <SmartProvider navigation={navigation}>{children}</SmartProvider>;
276
+ }
277
+ ```
278
+
279
+ With React Router, `router.navigate` is `useNavigate()`, `router.location` is `useLocation()` and `router.Link` wraps `Link`. Keep the adapter stable (memoised on stable inputs): a new object changes the context.
280
+
281
+ ## Services and hooks
282
+
283
+ | Hook | Returns | Use it for |
284
+ | ---------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
285
+ | `useSmart()` | `SmartContextValue` | The whole context (every service, provider and registry). |
286
+ | `useTranslate()` | `SmartTranslateFn` | Translating keys. |
287
+ | `useNavigation()` | `ISmartNavigation` | Navigating, reading the URL. |
288
+ | `useSmartComponent(key, fallback)` | `ComponentType` | Resolving a registry key in a wrapper of your own. |
289
+ | `useAuthService()` | `AuthService` | The JWT in storage (`AUTH_TOKEN`): `isAuthenticated()`, `expectPermissions(perms)`, `getPermissions()`, `getTokenPayload()`, `getAccessToken()`, `setToken(token)`, `removeToken()`. An expired token is removed when read. |
290
+ | `useHttpClient()` | `SmartHttpClient` | `get`, `post`, `put`, `patch`, `delete`, `request` over `fetch`, with interceptors (`addInterceptor`); non-2xx responses throw `SmartHttpError` (`status`, `body`). `createAuthInterceptor(getToken)` adds `Authorization: Bearer`. |
291
+ | `useFileService()` | `FileService \| null` | `upload(file, onProgress)`, `download(id)`, `delete(id)`, `getUrl(id)` under `<apiUrl>/attachments`; `null` without `fileServiceConfig`. `useFileUrl(file)` gives an attachment's URL. |
292
+ | `useToastService()` | `ToastService` | `info({ message, title?, duration?, buttons? })`, `error(...)` (`react-components-overlays`). |
293
+ | `useAlertService()` | `AlertService` | `show(options)` resolving with the chosen button (`react-components-alert`). |
294
+ | `useModalService()` | `ModalService` | `show({ component, props })` and `dismiss(data)` (`react-components-modal`). |
295
+ | `useMenuService()` | `MenuService` | Menu items, `enable()` / `disable()`, `openEnd({ component, props })` / `closeEnd()` and the `endContent` store (`react-components-app`). |
296
+ | `useAppService()` | `AppService` | `addEndButton` / `removeEndButton` (the `endButtons` store) and the document title (`initTitle`, `updateTitle(url)`). |
297
+ | `useStorageService()` | `StorageService` | JSON values in `localStorage`, safe during server-side rendering. |
298
+ | `useErrorService()` | `ErrorService` | Logs an error and shows an error toast. |
299
+ | `useStyleService()` | `StyleService` | Writes style settings as CSS custom properties on an element. |
300
+ | `useDetailsService()` | `DetailsService` | The root object of the shown form or details, for `$root` in `enabled` specifications. |
301
+ | `useFormFactory()` | `FormFactory` | Building forms from models (`react-forms`). |
302
+
303
+ The services that hold UI state keep it in a `SmartStore` (`get()`, `set()`, `update()`, `subscribe()`); read one in a component with `useStore(store, selector?)`, which re-renders only when the selected value changes.
304
+
305
+ ## Model providers
306
+
307
+ Abstract classes to extend and pass to `SmartProvider`:
308
+
309
+ ```ts
310
+ import {
311
+ IModelLabelOptions,
312
+ IModelLabelProvider,
313
+ IModelPossibilitiesOptions,
314
+ IModelPossibilitiesProvider,
315
+ SmartPossibility,
316
+ } from '@smartsoft001/react';
317
+
318
+ export class AppLabelProvider extends IModelLabelProvider {
319
+ get({ key, type }: IModelLabelOptions): string | null {
320
+ // Return nothing to fall back to the MODEL.<key> translation.
321
+ return type?.name === 'Invoice' && key === 'total' ? 'Total (gross)' : null;
322
+ }
323
+ }
324
+
325
+ export class AppPossibilitiesProvider extends IModelPossibilitiesProvider {
326
+ async get({
327
+ key,
328
+ }: IModelPossibilitiesOptions): Promise<SmartPossibility[] | null> {
329
+ if (key !== 'country') return null; // keep the field's own possibilities
330
+ const countries: Array<{ code: string; name: string }> = await fetch(
331
+ '/api/countries',
332
+ ).then((r) => r.json());
333
+ return countries.map((c) => ({ id: c.code, text: c.name, checked: false }));
334
+ }
335
+ }
336
+ ```
337
+
338
+ `IModelPossibilitiesProvider.get` is asked again (500 ms after the form's value last changed), so options can depend on other fields; CRUD filters use it too. `IModelValidatorsProvider` is described in `react-forms`.
339
+
340
+ ## Shared option types
341
+
342
+ | Type | Values |
343
+ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
344
+ | `SmartColor` | `'slate' \| 'gray' \| 'zinc' \| 'neutral' \| 'stone' \| 'red' \| 'orange' \| 'amber' \| 'yellow' \| 'lime' \| 'green' \| 'emerald' \| 'teal' \| 'cyan' \| 'sky' \| 'blue' \| 'indigo' \| 'violet' \| 'purple' \| 'fuchsia' \| 'pink' \| 'rose'` (default `'indigo'` where a component has one) |
345
+ | `SmartSize` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` |
346
+ | `SmartVariant` | `'primary' \| 'secondary' \| 'soft'` |
347
+ | `SmartPossibility` | `{ id: any; text: string; checked: boolean }`, an option of an `enum` / `radio` / `check` / `strings` field |
348
+
349
+ `COMPONENT_COLORS` maps every `SmartColor` to the `primary` / `secondary` / `soft` class lists (with dark variants) the button uses.
350
+
351
+ ## Utilities
352
+
353
+ - `cn(...classes)`: joins class names, skipping falsy values and flattening arrays.
354
+ - `trustHtml(html)`, `sanitizeHtml(html)`, `toInnerHtml(value)`, `escapeHtml(text)`: HTML that details and lists render is sanitised with DOMPurify; a cell pipe returning `trustHtml(html)` opts out.
355
+ - `useModelLabel(instance, key, type)`, `useModelLabelFn()`, `useListHeaderFn()`: labels through the label provider and translations.
356
+
357
+ ## File Locations
358
+
359
+ Source: `packages/shared/react/src/lib/` in the smartsoft001 repository.
360
+
361
+ - `providers/smart-provider.tsx`, `providers/smart-context.ts`: `SmartProvider`, `SmartConfig`, `useSmart`, `createSmartServices`
362
+ - `providers/hooks.ts`: `useTranslate`, `useNavigation`, `useSmartComponent`, the service hooks
363
+ - `providers/navigation.ts`: `ISmartNavigation`, `createHistoryNavigation`
364
+ - `providers/model-*.provider.ts`: the model provider classes
365
+ - `components/presets/presets.ts`: `SMART_PRESET_COMPONENTS`
366
+ - `i18n/`: `createTranslator`, `mergeTranslations`, the default dictionaries
367
+ - `services/`: the services; `store/store.ts`: `SmartStore`, `useStore`
368
+ - `models/interfaces.ts`: the option interfaces and shared types