@strato-admin/cloudscape 0.1.1 → 0.3.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 (231) hide show
  1. package/dist/Admin.d.ts +6 -2
  2. package/dist/Admin.js +14 -8
  3. package/dist/RecordLink.js +5 -4
  4. package/dist/Settings.d.ts +17 -0
  5. package/dist/Settings.js +14 -0
  6. package/dist/button/BulkDeleteButton.d.ts +2 -1
  7. package/dist/button/BulkDeleteButton.js +17 -11
  8. package/dist/button/Button.d.ts +2 -1
  9. package/dist/button/CancelButton.d.ts +6 -0
  10. package/dist/button/CancelButton.js +10 -0
  11. package/dist/button/CreateButton.js +9 -8
  12. package/dist/button/DeleteButton.d.ts +13 -0
  13. package/dist/button/DeleteButton.js +36 -0
  14. package/dist/button/EditButton.d.ts +1 -1
  15. package/dist/button/EditButton.js +10 -10
  16. package/dist/button/SaveButton.js +2 -2
  17. package/dist/button/index.d.ts +2 -0
  18. package/dist/button/index.js +2 -0
  19. package/dist/collection-hooks/interfaces.d.ts +7 -3
  20. package/dist/collection-hooks/useCollection.d.ts +1 -1
  21. package/dist/collection-hooks/useCollection.js +15 -10
  22. package/dist/create/Create.d.ts +9 -17
  23. package/dist/create/Create.js +40 -12
  24. package/dist/create/CreateHeader.d.ts +2 -2
  25. package/dist/create/CreateHeader.js +4 -5
  26. package/dist/defaults.d.ts +6 -0
  27. package/dist/defaults.js +21 -0
  28. package/dist/detail/Detail.d.ts +33 -0
  29. package/dist/detail/Detail.js +22 -0
  30. package/dist/detail/DetailHeader.d.ts +11 -0
  31. package/dist/detail/{ShowHeader.js → DetailHeader.js} +7 -5
  32. package/dist/detail/DetailHub.d.ts +27 -0
  33. package/dist/detail/DetailHub.js +63 -0
  34. package/dist/detail/KeyValuePairs.d.ts +7 -1
  35. package/dist/detail/KeyValuePairs.js +14 -8
  36. package/dist/detail/index.d.ts +3 -2
  37. package/dist/detail/index.js +3 -2
  38. package/dist/edit/Edit.d.ts +8 -19
  39. package/dist/edit/Edit.js +48 -12
  40. package/dist/edit/EditHeader.d.ts +2 -2
  41. package/dist/edit/EditHeader.js +5 -4
  42. package/dist/field/ArrayField.d.ts +26 -10
  43. package/dist/field/ArrayField.js +38 -10
  44. package/dist/field/BadgeField.d.ts +1 -1
  45. package/dist/field/BadgeField.js +1 -1
  46. package/dist/field/BooleanField.d.ts +1 -1
  47. package/dist/field/BooleanField.js +2 -2
  48. package/dist/field/CurrencyField.d.ts +1 -1
  49. package/dist/field/CurrencyField.js +1 -1
  50. package/dist/field/DateField.d.ts +1 -1
  51. package/dist/field/DateField.js +1 -1
  52. package/dist/field/IdField.d.ts +1 -1
  53. package/dist/field/IdField.js +3 -3
  54. package/dist/field/NumberField.d.ts +1 -1
  55. package/dist/field/NumberField.js +1 -1
  56. package/dist/field/ReferenceField.d.ts +1 -1
  57. package/dist/field/ReferenceField.js +4 -2
  58. package/dist/field/ReferenceManyField.d.ts +35 -4
  59. package/dist/field/ReferenceManyField.js +17 -4
  60. package/dist/field/StatusIndicatorField.d.ts +1 -1
  61. package/dist/field/StatusIndicatorField.js +6 -5
  62. package/dist/field/TextField.d.ts +1 -1
  63. package/dist/field/TextField.js +1 -1
  64. package/dist/field/types.d.ts +9 -9
  65. package/dist/form/Form.d.ts +12 -2
  66. package/dist/form/Form.js +10 -16
  67. package/dist/form/index.d.ts +1 -1
  68. package/dist/form/index.js +1 -1
  69. package/dist/hooks/useSchemaFields.d.ts +22 -0
  70. package/dist/hooks/useSchemaFields.js +45 -0
  71. package/dist/i18n/Message.d.ts +15 -0
  72. package/dist/i18n/Message.js +19 -0
  73. package/dist/i18n/RecordMessage.d.ts +14 -0
  74. package/dist/i18n/RecordMessage.js +16 -0
  75. package/dist/i18n/index.d.ts +3 -0
  76. package/dist/i18n/index.js +2 -0
  77. package/dist/i18n/types.d.ts +19 -0
  78. package/dist/i18n/types.js +1 -0
  79. package/dist/index.d.ts +5 -1
  80. package/dist/index.js +5 -1
  81. package/dist/input/ArrayInput.d.ts +33 -0
  82. package/dist/input/{AttributeEditor.js → ArrayInput.js} +18 -11
  83. package/dist/input/AutocompleteInput.d.ts +1 -1
  84. package/dist/input/AutocompleteInput.js +3 -3
  85. package/dist/input/BooleanInput.d.ts +6 -0
  86. package/dist/input/BooleanInput.js +23 -0
  87. package/dist/input/CommonInputProps.d.ts +6 -0
  88. package/dist/input/CommonInputProps.js +6 -0
  89. package/dist/input/FieldTitle.js +4 -4
  90. package/dist/input/FormField.js +12 -3
  91. package/dist/input/FormFieldContext.d.ts +1 -1
  92. package/dist/input/NumberInput.d.ts +1 -1
  93. package/dist/input/NumberInput.js +3 -3
  94. package/dist/input/ReferenceInput.d.ts +1 -1
  95. package/dist/input/ReferenceInput.js +22 -12
  96. package/dist/input/SelectInput.d.ts +1 -1
  97. package/dist/input/SelectInput.js +3 -3
  98. package/dist/input/SliderInput.d.ts +1 -1
  99. package/dist/input/SliderInput.js +4 -4
  100. package/dist/input/TextAreaInput.d.ts +1 -1
  101. package/dist/input/TextAreaInput.js +3 -3
  102. package/dist/input/TextInput.d.ts +1 -1
  103. package/dist/input/TextInput.js +6 -12
  104. package/dist/input/index.d.ts +2 -1
  105. package/dist/input/index.js +2 -1
  106. package/dist/input/types.d.ts +33 -2
  107. package/dist/layout/AppLayout.js +6 -3
  108. package/dist/layout/Notifications.d.ts +1 -0
  109. package/dist/layout/Notifications.js +51 -0
  110. package/dist/layout/Ready.d.ts +6 -0
  111. package/dist/layout/Ready.js +24 -0
  112. package/dist/layout/TopNavigation.d.ts +4 -2
  113. package/dist/layout/TopNavigation.js +7 -7
  114. package/dist/layout/index.d.ts +2 -0
  115. package/dist/layout/index.js +2 -0
  116. package/dist/list/Cards.d.ts +31 -4
  117. package/dist/list/Cards.js +81 -10
  118. package/dist/list/List.d.ts +9 -12
  119. package/dist/list/List.js +41 -11
  120. package/dist/list/Table.d.ts +8 -4
  121. package/dist/list/Table.js +55 -55
  122. package/dist/list/TableHeader.d.ts +2 -2
  123. package/dist/list/TableHeader.js +4 -5
  124. package/dist/theme/ThemeManager.js +1 -1
  125. package/package.json +8 -5
  126. package/src/Admin.tsx +35 -18
  127. package/src/RecordLink.stories.tsx +1 -1
  128. package/src/RecordLink.tsx +5 -4
  129. package/src/Settings.tsx +16 -0
  130. package/src/__mocks__/ra-core.tsx +83 -0
  131. package/src/__mocks__/strato-core.tsx +36 -42
  132. package/src/button/BulkDeleteButton.test.tsx +17 -4
  133. package/src/button/BulkDeleteButton.tsx +24 -29
  134. package/src/button/Button.tsx +31 -2
  135. package/src/button/CancelButton.tsx +20 -0
  136. package/src/button/CreateButton.tsx +12 -10
  137. package/src/button/DeleteButton.tsx +96 -0
  138. package/src/button/EditButton.tsx +13 -12
  139. package/src/button/SaveButton.tsx +2 -3
  140. package/src/button/index.ts +2 -0
  141. package/src/collection-hooks/interfaces.ts +7 -3
  142. package/src/collection-hooks/useCollection.test.ts +115 -2
  143. package/src/collection-hooks/useCollection.ts +15 -10
  144. package/src/create/Create.test.tsx +3 -3
  145. package/src/create/Create.tsx +68 -37
  146. package/src/create/CreateHeader.tsx +6 -10
  147. package/src/defaults.tsx +28 -0
  148. package/src/detail/Detail-CollectionFields.test.tsx +84 -0
  149. package/src/detail/Detail.test.tsx +91 -0
  150. package/src/detail/Detail.tsx +48 -0
  151. package/src/detail/{ShowHeader.test.tsx → DetailHeader.test.tsx} +11 -9
  152. package/src/detail/DetailHeader.tsx +42 -0
  153. package/src/detail/DetailHub.tsx +88 -0
  154. package/src/detail/KeyValuePairs.test.tsx +2 -2
  155. package/src/detail/KeyValuePairs.tsx +25 -18
  156. package/src/detail/index.ts +3 -2
  157. package/src/edit/Edit.test.tsx +7 -5
  158. package/src/edit/Edit.tsx +92 -40
  159. package/src/edit/EditHeader.tsx +7 -5
  160. package/src/field/ArrayField.tsx +57 -11
  161. package/src/field/BadgeField.tsx +2 -3
  162. package/src/field/BooleanField.test.tsx +2 -3
  163. package/src/field/BooleanField.tsx +3 -3
  164. package/src/field/CurrencyField.tsx +1 -1
  165. package/src/field/DateField.tsx +1 -1
  166. package/src/field/IdField.test.tsx +8 -20
  167. package/src/field/IdField.tsx +5 -20
  168. package/src/field/NumberField.tsx +1 -1
  169. package/src/field/ReferenceField.test.tsx +15 -6
  170. package/src/field/ReferenceField.tsx +10 -7
  171. package/src/field/ReferenceManyField.test.tsx +55 -10
  172. package/src/field/ReferenceManyField.tsx +84 -13
  173. package/src/field/StatusIndicatorField.test.tsx +7 -21
  174. package/src/field/StatusIndicatorField.tsx +8 -20
  175. package/src/field/TextField.tsx +1 -1
  176. package/src/field/types.ts +12 -13
  177. package/src/form/Form.test.tsx +8 -4
  178. package/src/form/Form.tsx +24 -19
  179. package/src/form/index.ts +1 -1
  180. package/src/hooks/useSchemaFields.ts +89 -0
  181. package/src/i18n/Message.tsx +22 -0
  182. package/src/i18n/RecordMessage.tsx +22 -0
  183. package/src/i18n/index.ts +3 -0
  184. package/src/i18n/types.ts +19 -0
  185. package/src/index.ts +5 -1
  186. package/src/input/ArrayInput.test.tsx +81 -0
  187. package/src/input/{AttributeEditor.tsx → ArrayInput.tsx} +36 -18
  188. package/src/input/AutocompleteInput.test.tsx +2 -4
  189. package/src/input/AutocompleteInput.tsx +9 -11
  190. package/src/input/BooleanInput.tsx +42 -0
  191. package/src/input/CommonInputProps.tsx +8 -0
  192. package/src/input/FieldTitle.tsx +3 -15
  193. package/src/input/FormField.tsx +78 -67
  194. package/src/input/FormFieldContext.ts +1 -1
  195. package/src/input/NumberInput.tsx +10 -7
  196. package/src/input/ReferenceInput.test.tsx +12 -2
  197. package/src/input/ReferenceInput.tsx +32 -14
  198. package/src/input/SelectInput.tsx +14 -17
  199. package/src/input/SliderInput.test.tsx +2 -3
  200. package/src/input/SliderInput.tsx +48 -38
  201. package/src/input/TextAreaInput.tsx +10 -6
  202. package/src/input/TextInput.test.tsx +2 -4
  203. package/src/input/TextInput.tsx +35 -20
  204. package/src/input/index.ts +2 -1
  205. package/src/input/types.ts +40 -8
  206. package/src/layout/AppLayout.test.tsx +23 -3
  207. package/src/layout/AppLayout.tsx +11 -8
  208. package/src/layout/Notifications.test.tsx +102 -0
  209. package/src/layout/Notifications.tsx +61 -0
  210. package/src/layout/Ready.tsx +123 -0
  211. package/src/layout/TopNavigation.test.tsx +2 -3
  212. package/src/layout/TopNavigation.tsx +9 -8
  213. package/src/layout/index.ts +2 -0
  214. package/src/list/Cards.test.tsx +320 -0
  215. package/src/list/Cards.tsx +146 -16
  216. package/src/list/List.tsx +87 -26
  217. package/src/list/Table.test.tsx +40 -5
  218. package/src/list/Table.tsx +89 -98
  219. package/src/list/TableHeader.test.tsx +15 -11
  220. package/src/list/TableHeader.tsx +6 -8
  221. package/src/theme/ThemeManager.tsx +1 -1
  222. package/dist/__mocks__/strato-core.js +0 -50
  223. package/dist/__mocks__to__delete/strato-core.js +0 -50
  224. package/dist/detail/Show.d.ts +0 -39
  225. package/dist/detail/Show.js +0 -40
  226. package/dist/detail/ShowHeader.d.ts +0 -7
  227. package/dist/input/AttributeEditor.d.ts +0 -25
  228. package/src/detail/Show.test.tsx +0 -96
  229. package/src/detail/Show.tsx +0 -104
  230. package/src/detail/ShowHeader.tsx +0 -35
  231. package/src/input/AttributeEditor.test.tsx +0 -147
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Button, Container, Header, SpaceBetween, Link, Icon, ContentLayout, ColumnLayout, } from '@cloudscape-design/components';
3
+ import { CodeView } from '@cloudscape-design/code-view';
4
+ import typescriptHighlight from '@cloudscape-design/code-view/highlight/typescript';
5
+ import { useDefaultTitle } from '@strato-admin/ra-core';
6
+ /**
7
+ * Default component to display when the admin has no resources.
8
+ * This is a Cloudscape-themed replacement for the default react-admin Ready component.
9
+ */
10
+ export const Ready = () => {
11
+ const defaultTitle = useDefaultTitle();
12
+ const appTitle = typeof defaultTitle === 'string' ? defaultTitle : 'Strato Admin';
13
+ const codeSnippet = `import { Admin, ResourceSchema, TextField } from '@strato-admin/admin';
14
+
15
+ export const App = () => (
16
+ <Admin dataProvider={...}>
17
+ <ResourceSchema name="posts" >
18
+ <TextField source="id" />
19
+ </ResourceSchema>
20
+ </Admin>
21
+ );`;
22
+ return (_jsx(ContentLayout, { maxContentWidth: 1040, headerVariant: "high-contrast", header: _jsx(Box, { padding: { vertical: 'xxxl' }, textAlign: "center", children: _jsxs(SpaceBetween, { size: "l", children: [_jsxs(Header, { variant: "h1", description: "Your Strato Admin application is properly configured and ready to go.", children: ["Welcome to ", appTitle] }), _jsxs(Box, { variant: "p", children: ["Strato Admin uses a ", _jsx("strong", { children: "Schema First" }), " approach to build admin interfaces efficiently. Start by defining your resources and let us handle the rest."] }), _jsx(Box, { margin: { top: 'm' }, children: _jsxs(SpaceBetween, { direction: "horizontal", size: "xs", children: [_jsx(Button, { variant: "primary", href: "https://strato-admin.dev/docs/getting-started/tutorial", iconName: "external", iconAlign: "right", children: "Get started with the tutorial" }), _jsx(Button, { href: "https://github.com/vadimgu/strato-admin", iconName: "external", iconAlign: "right", children: "View on GitHub" })] }) })] }) }), children: _jsxs(SpaceBetween, { size: "xxl", children: [_jsxs(SpaceBetween, { size: "l", children: [_jsx(Container, { header: _jsx(Header, { variant: "h2", children: "How to add your first resource" }), children: _jsxs(SpaceBetween, { size: "m", children: [_jsxs(Box, { variant: "p", children: ["Add a ", _jsx("code", { children: "<ResourceSchema>" }), " component as a child of your ", _jsx("code", { children: "<Admin>" }), " to define your data model."] }), _jsx(CodeView, { content: codeSnippet, highlight: typescriptHighlight })] }) }), _jsx(Container, { header: _jsx(Header, { variant: "h2", children: "Next steps" }), children: _jsxs(ColumnLayout, { columns: 2, variant: "text-grid", children: [_jsxs("div", { children: [_jsxs(Box, { variant: "h3", fontWeight: "bold", children: [_jsx(Icon, { name: "status-info", variant: "link" }), " Core Concepts"] }), _jsxs(Box, { variant: "p", children: ["Learn how", ' ', _jsx(Link, { href: "https://strato-admin.dev/docs/core-concepts/schema", external: true, children: "Schemas" }), ' ', "work to automate your UI."] })] }), _jsxs("div", { children: [_jsxs(Box, { variant: "h3", fontWeight: "bold", children: [_jsx(Icon, { name: "star", variant: "warning" }), " Design System"] }), _jsxs(Box, { variant: "p", children: ["Explore the", ' ', _jsx(Link, { href: "https://cloudscape.design/", external: true, children: "Cloudscape design system" }), ' ', "components."] })] })] }) })] }), _jsxs(Box, { textAlign: "center", color: "text-label", margin: { top: 'xs' }, padding: { bottom: 'xxxl' }, children: ["Built with", ' ', _jsx(Link, { href: "https://www.strato-admin.dev", external: true, children: "Strato Admin" }), "."] })] }) }));
23
+ };
24
+ export default Ready;
@@ -1,6 +1,8 @@
1
1
  import { TopNavigationProps } from '@cloudscape-design/components/top-navigation';
2
- export interface MyTopNavigationProps extends Omit<TopNavigationProps, 'identity'> {
2
+ export interface MyTopNavigationProps {
3
3
  identity?: TopNavigationProps.Identity;
4
+ utilities?: ReadonlyArray<TopNavigationProps.Utility>;
5
+ extraUtilities?: ReadonlyArray<TopNavigationProps.Utility>;
4
6
  }
5
- export declare const TopNavigation: ({ utilities: providedUtilities, identity, ...props }: MyTopNavigationProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const TopNavigation: ({ utilities: providedUtilities, identity, extraUtilities }: MyTopNavigationProps) => import("react/jsx-runtime").JSX.Element;
6
8
  export default TopNavigation;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import CloudscapeTopNavigation from '@cloudscape-design/components/top-navigation';
3
- import { useLocale, useSetLocale, useLocales, useTranslate, useAuthProvider, useStore } from '@strato-admin/core';
3
+ import { useLocale, useSetLocale, useLocales, useTranslate, useAuthProvider, useStore } from '@strato-admin/ra-core';
4
4
  const LightModeIcon = (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", focusable: "false", children: [_jsx("path", { d: "M8 1.5v13a6.5 6.5 0 0 0 0-13z", fill: "currentColor" }), _jsx("circle", { cx: "8", cy: "8", r: "7", fill: "none", stroke: "currentColor", "stroke-width": "1.5" })] }));
5
5
  const DarkModeIcon = (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", focusable: "false", children: [_jsx("path", { d: "M8 1.5v13a6.5 6.5 0 0 1 0-13z", fill: "currentColor" }), _jsx("circle", { cx: "8", cy: "8", r: "7", fill: "none", stroke: "currentColor", "stroke-width": "1.5" })] }));
6
- export const TopNavigation = ({ utilities: providedUtilities, identity, ...props }) => {
6
+ export const TopNavigation = ({ utilities: providedUtilities, identity, extraUtilities }) => {
7
7
  const locale = useLocale();
8
8
  const setLocale = useSetLocale();
9
9
  const locales = useLocales();
@@ -38,16 +38,16 @@ export const TopNavigation = ({ utilities: providedUtilities, identity, ...props
38
38
  if (authProvider) {
39
39
  autoUtilities.push({
40
40
  type: 'menu-dropdown',
41
- text: translate('ra.auth.user_menu', { _: 'User' }),
41
+ text: translate('strato.auth.user_menu', { _: 'User' }),
42
42
  iconName: 'user-profile',
43
43
  items: [
44
- { id: 'profile', text: translate('ra.auth.profile', { _: 'Profile' }) },
45
- { id: 'signout', text: translate('ra.auth.logout', { _: 'Sign out' }) },
44
+ { id: 'profile', text: translate('strato.auth.profile', { _: 'Profile' }) },
45
+ { id: 'signout', text: translate('strato.auth.logout', { _: 'Sign out' }) },
46
46
  ],
47
47
  });
48
48
  }
49
- utilities = autoUtilities;
49
+ utilities = extraUtilities ? [...autoUtilities, ...extraUtilities] : autoUtilities;
50
50
  }
51
- return (_jsx("div", { id: "header", children: _jsx(CloudscapeTopNavigation, { identity: identity || { title: 'Strato Admin', href: '/' }, utilities: utilities, ...props }) }));
51
+ return (_jsx("div", { id: "header", children: _jsx(CloudscapeTopNavigation, { identity: identity || { title: 'Strato Admin', href: '/' }, utilities: utilities }) }));
52
52
  };
53
53
  export default TopNavigation;
@@ -1,2 +1,4 @@
1
1
  export * from './AppLayout';
2
2
  export * from './TopNavigation';
3
+ export * from './Ready';
4
+ export * from './Notifications';
@@ -1,2 +1,4 @@
1
1
  export * from './AppLayout';
2
2
  export * from './TopNavigation';
3
+ export * from './Ready';
4
+ export * from './Notifications';
@@ -1,11 +1,38 @@
1
1
  import React from 'react';
2
2
  import { CardsProps } from '@cloudscape-design/components/cards';
3
- import { RaRecord } from '@strato-admin/core';
4
- export interface ListCardsProps<T extends RaRecord = any> extends Omit<CardsProps<T>, 'items' | 'cardDefinition'> {
3
+ import { RaRecord } from '@strato-admin/ra-core';
4
+ export interface ListCardsProps<T extends RaRecord = any> extends Omit<CardsProps<T>, 'items' | 'cardDefinition' | 'preferences'> {
5
5
  renderItem?: (item: T) => React.ReactNode;
6
6
  include?: string[];
7
7
  exclude?: string[];
8
+ children?: React.ReactNode;
9
+ title?: React.ReactNode;
10
+ description?: string;
11
+ actions?: React.ReactNode;
12
+ selectionType?: 'single' | 'multi';
13
+ /**
14
+ * Whether to enable text filtering.
15
+ * @default true
16
+ */
17
+ filtering?: boolean;
18
+ /**
19
+ * Placeholder text for the filter input.
20
+ * @default "Search..."
21
+ */
22
+ filteringPlaceholder?: string;
23
+ /**
24
+ * Options for the page size selector.
25
+ */
26
+ pageSizeOptions?: ReadonlyArray<{
27
+ value: number;
28
+ label?: string;
29
+ }>;
30
+ /**
31
+ * Whether to show the preferences button or custom preferences content.
32
+ * @default true
33
+ */
34
+ preferences?: boolean | React.ReactNode;
8
35
  }
9
- export declare const ListCards: <T extends RaRecord = any>({ renderItem, include, exclude, ...props }: ListCardsProps<T>) => import("react/jsx-runtime").JSX.Element;
10
- export declare const Cards: <T extends RaRecord = any>({ renderItem, include, exclude, ...props }: ListCardsProps<T>) => import("react/jsx-runtime").JSX.Element;
36
+ export declare const ListCards: <T extends RaRecord = any>({ renderItem, include, exclude, children, title, description, actions, selectionType, filtering, filteringPlaceholder, pageSizeOptions, preferences, ...props }: ListCardsProps<T>) => import("react/jsx-runtime").JSX.Element;
37
+ export declare const Cards: <T extends RaRecord = any>({ renderItem, include, exclude, children, title, description, actions, selectionType, filtering, filteringPlaceholder, pageSizeOptions, preferences, ...props }: ListCardsProps<T>) => import("react/jsx-runtime").JSX.Element;
11
38
  export default ListCards;
@@ -1,27 +1,98 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
2
3
  import CloudscapeCards from '@cloudscape-design/components/cards';
3
4
  import Pagination from '@cloudscape-design/components/pagination';
4
- import { RecordContextProvider, useFieldSchema } from '@strato-admin/core';
5
+ import TextFilter from '@cloudscape-design/components/text-filter';
6
+ import CollectionPreferences from '@cloudscape-design/components/collection-preferences';
7
+ import { RecordContextProvider, useTranslateLabel, useTranslate } from '@strato-admin/ra-core';
8
+ import { useResourceSchema, useSettings } from '@strato-admin/core';
5
9
  import { useCollection } from '../collection-hooks';
10
+ import { useSchemaFields } from '../hooks/useSchemaFields';
6
11
  import KeyValuePairs from '../detail/KeyValuePairs';
7
- export const ListCards = ({ renderItem, include, exclude, ...props }) => {
8
- const { items, paginationProps, collectionProps } = useCollection({
9
- filtering: {},
10
- pagination: {},
11
- sorting: {},
12
+ import TableHeader from './TableHeader';
13
+ export const ListCards = ({ renderItem, include, exclude, children, title, description, actions, selectionType, filtering = true, filteringPlaceholder, pageSizeOptions, preferences = true, ...props }) => {
14
+ const translate = useTranslate();
15
+ const { listPageSizes, listPageSizeLabel } = useSettings();
16
+ const resolvedPageSizeOptions = pageSizeOptions ??
17
+ (listPageSizes && listPageSizeLabel
18
+ ? listPageSizes.map((value) => ({ value, label: listPageSizeLabel(value) }))
19
+ : undefined);
20
+ const translateLabel = useTranslateLabel();
21
+ const { resource, label: schemaLabel, definition } = useResourceSchema();
22
+ const { getListFields } = useSchemaFields();
23
+ const finalSelectionType = selectionType ?? (definition?.options?.canDelete ? 'multi' : undefined);
24
+ const finalChildren = React.useMemo(() => getListFields(children, { include, exclude }), [getListFields, children, include, exclude]);
25
+ const visibleContentOptions = React.useMemo(() => {
26
+ const options = [];
27
+ finalChildren.forEach((child, index) => {
28
+ if (!React.isValidElement(child))
29
+ return;
30
+ const { source, label } = child.props;
31
+ const headerLabel = translateLabel({ label, resource, source });
32
+ if (typeof headerLabel === 'string') {
33
+ options.push({
34
+ id: source || `section-${index}`,
35
+ label: headerLabel,
36
+ });
37
+ }
38
+ });
39
+ return options;
40
+ }, [finalChildren, resource, translateLabel]);
41
+ const { items, paginationProps, collectionProps, filterProps, preferencesProps } = useCollection({
42
+ preferences: {
43
+ pageSizeOptions: resolvedPageSizeOptions,
44
+ visibleContentOptions: visibleContentOptions.length > 0 ? visibleContentOptions : undefined,
45
+ },
12
46
  });
13
- const schemaChildren = useFieldSchema();
14
- const defaultRenderItem = (_item) => (_jsx(KeyValuePairs, { include: include, exclude: exclude, children: schemaChildren }));
47
+ const displayedChildren = React.useMemo(() => {
48
+ const { visibleContent } = preferencesProps.preferences;
49
+ if (!visibleContent)
50
+ return finalChildren;
51
+ return finalChildren.filter((child) => {
52
+ if (!React.isValidElement(child))
53
+ return true;
54
+ const { source } = child.props;
55
+ // If the child doesn't have a source, we don't know how to toggle it, so we keep it.
56
+ if (!source)
57
+ return true;
58
+ // If it's not in the options, it's not toggleable, so we keep it.
59
+ if (!visibleContentOptions.some((opt) => opt.id === source))
60
+ return true;
61
+ return visibleContent.includes(source);
62
+ });
63
+ }, [finalChildren, preferencesProps.preferences.visibleContent, visibleContentOptions]);
64
+ const defaultRenderItem = (_item) => _jsx(KeyValuePairs, { children: displayedChildren });
15
65
  const finalRenderItem = renderItem || defaultRenderItem;
16
66
  const cardDefinition = {
17
67
  sections: [
18
68
  {
19
69
  id: 'main',
20
- content: (item) => _jsx(RecordContextProvider, { value: item, children: finalRenderItem(item) }),
70
+ content: (item) => (_jsx(RecordContextProvider, { value: item, children: finalRenderItem(item) })),
21
71
  },
22
72
  ],
23
73
  };
24
- return (_jsx(CloudscapeCards, { ...collectionProps, ...props, items: items || [], cardDefinition: cardDefinition, pagination: _jsx(Pagination, { ...paginationProps }) }));
74
+ const cardsHeader = React.useMemo(() => {
75
+ if (React.isValidElement(title)) {
76
+ return title;
77
+ }
78
+ const finalTitle = title !== undefined ? title : schemaLabel;
79
+ return _jsx(TableHeader, { title: finalTitle, description: description, actions: actions });
80
+ }, [title, description, actions, schemaLabel]);
81
+ return (_jsx(CloudscapeCards, { ...collectionProps, ...props, items: items || [], cardDefinition: cardDefinition, pagination: _jsx(Pagination, { ...paginationProps }), header: cardsHeader, selectionType: finalSelectionType, filter: filtering && _jsx(TextFilter, { ...filterProps, filteringPlaceholder: filteringPlaceholder }), preferences: preferences === true || resolvedPageSizeOptions ? (_jsx(CollectionPreferences, { ...preferencesProps, pageSizePreference: resolvedPageSizeOptions
82
+ ? {
83
+ options: resolvedPageSizeOptions,
84
+ }
85
+ : undefined, visibleContentPreference: visibleContentOptions.length > 0
86
+ ? {
87
+ title: translate('strato.action.select_sections', { _: 'Select visible sections' }),
88
+ options: [
89
+ {
90
+ label: translate('strato.action.select_sections', { _: 'Select visible sections' }),
91
+ options: visibleContentOptions,
92
+ },
93
+ ],
94
+ }
95
+ : undefined })) : React.isValidElement(preferences) ? (preferences) : undefined }));
25
96
  };
26
97
  export const Cards = ListCards;
27
98
  export default ListCards;
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- import { type RaRecord } from '@strato-admin/core';
3
- export interface ListProps<_RecordType extends RaRecord = any> {
2
+ import { type RaRecord, type ListBaseProps } from '@strato-admin/ra-core';
3
+ export interface ListProps<RecordType extends RaRecord = any> extends ListBaseProps<RecordType> {
4
4
  children?: React.ReactNode;
5
- fieldSchema?: React.ReactNode;
6
5
  include?: string[];
7
6
  exclude?: string[];
8
- title?: React.ReactNode;
7
+ title?: React.ReactNode | (() => React.ReactNode);
8
+ description?: React.ReactNode | (() => React.ReactNode);
9
9
  actions?: React.ReactNode;
10
10
  /**
11
11
  * Whether to enable text filtering in the implicit Table.
@@ -17,7 +17,10 @@ export interface ListProps<_RecordType extends RaRecord = any> {
17
17
  * @default true
18
18
  */
19
19
  preferences?: boolean | React.ReactNode;
20
- [key: string]: any;
20
+ /**
21
+ * The fields to display by default.
22
+ */
23
+ display?: string[];
21
24
  }
22
25
  /**
23
26
  * A List component that provides a list context and a Cloudscape Table.
@@ -32,12 +35,6 @@ export interface ListProps<_RecordType extends RaRecord = any> {
32
35
  * @example
33
36
  * // Using FieldSchema from context
34
37
  * <List include={['name', 'price']} />
35
- *
36
- * @example
37
- * // Passing a custom field schema
38
- * <List fieldSchema={<FieldSchema>...</FieldSchema>}>
39
- * <Table />
40
- * </List>
41
38
  */
42
- export declare const List: <RecordType extends RaRecord = any>({ children, fieldSchema, include, exclude, title, actions, filtering, preferences, ...props }: ListProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
39
+ export declare const List: <RecordType extends RaRecord = any>({ children, include, exclude, title, actions, description, filtering, preferences, display, ...props }: ListProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
43
40
  export default List;
package/dist/list/List.js CHANGED
@@ -1,6 +1,41 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ListBase, ResourceSchemaProvider } from '@strato-admin/core';
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { ListBase, useTranslate } from '@strato-admin/ra-core';
4
+ import { ResourceSchemaProvider, useResourceSchema, useConstructedPageTitle, useSettings } from '@strato-admin/core';
3
5
  import Table from './Table';
6
+ const ListUI = ({ children, title, actions, description, include, exclude, filtering, preferences, display, }) => {
7
+ const { label, listTitle, listDescription, listComponent: ListComponent = Table } = useResourceSchema();
8
+ const translate = useTranslate();
9
+ const constructedTitle = useConstructedPageTitle('list', label);
10
+ const finalTitle = React.useMemo(() => {
11
+ if (typeof title === 'function')
12
+ return title();
13
+ if (React.isValidElement(title))
14
+ return title;
15
+ if (title)
16
+ return translate(title);
17
+ if (React.isValidElement(listTitle))
18
+ return listTitle;
19
+ if (listTitle)
20
+ return translate(listTitle);
21
+ return constructedTitle;
22
+ }, [title, listTitle, translate, constructedTitle]);
23
+ const finalDescription = React.useMemo(() => {
24
+ if (typeof description === 'function')
25
+ return description();
26
+ if (React.isValidElement(description))
27
+ return description;
28
+ if (description)
29
+ return translate(description);
30
+ if (React.isValidElement(listDescription))
31
+ return listDescription;
32
+ if (listDescription)
33
+ return translate(listDescription);
34
+ return undefined;
35
+ }, [description, listDescription, translate]);
36
+ const finalChildren = children || (_jsx(ListComponent, { include: include, exclude: exclude, display: display, title: finalTitle, description: finalDescription, actions: actions, filtering: filtering, preferences: preferences }));
37
+ return _jsx(_Fragment, { children: finalChildren });
38
+ };
4
39
  /**
5
40
  * A List component that provides a list context and a Cloudscape Table.
6
41
  *
@@ -14,15 +49,10 @@ import Table from './Table';
14
49
  * @example
15
50
  * // Using FieldSchema from context
16
51
  * <List include={['name', 'price']} />
17
- *
18
- * @example
19
- * // Passing a custom field schema
20
- * <List fieldSchema={<FieldSchema>...</FieldSchema>}>
21
- * <Table />
22
- * </List>
23
52
  */
24
- export const List = ({ children, fieldSchema, include, exclude, title, actions, filtering = true, preferences = true, ...props }) => {
25
- const finalChildren = children || (_jsx(Table, { include: include, exclude: exclude, title: title, actions: actions, filtering: filtering, preferences: preferences }));
26
- return (_jsx(ListBase, { ...props, children: _jsx(ResourceSchemaProvider, { resource: props.resource, fieldSchema: fieldSchema, children: finalChildren }) }));
53
+ export const List = ({ children, include, exclude, title, actions, description, filtering = true, preferences = true, display, ...props }) => {
54
+ const { queryOptions } = useResourceSchema(props.resource);
55
+ const { listPageSize } = useSettings();
56
+ return (_jsx(ListBase, { queryOptions: queryOptions, ...props, perPage: props.perPage ?? listPageSize, children: _jsx(ResourceSchemaProvider, { resource: props.resource, children: _jsx(ListUI, { title: title, actions: actions, description: description, include: include, exclude: exclude, filtering: filtering, preferences: preferences, display: display, children: children }) }) }));
27
57
  };
28
58
  export default List;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { TableProps as CloudscapeTableProps } from '@cloudscape-design/components/table';
3
- import { RaRecord } from '@strato-admin/core';
3
+ import { RaRecord } from '@strato-admin/ra-core';
4
4
  import { type RecordLinkType } from '../RecordLink';
5
5
  export type CloudscapeColumnDefinitionProps = Partial<Omit<CloudscapeTableProps.ColumnDefinition<any>, 'id' | 'header' | 'cell' | 'sortingField'>>;
6
6
  export interface ColumnProps extends CloudscapeColumnDefinitionProps {
@@ -38,6 +38,10 @@ export interface TableProps<RecordType extends RaRecord = any> extends Partial<O
38
38
  * The title content of the table. Can be a string or a React node.
39
39
  */
40
40
  title?: React.ReactNode;
41
+ /**
42
+ * The description content of the table.
43
+ */
44
+ description?: React.ReactNode;
41
45
  /**
42
46
  * Actions to display in the table header, typically a button group.
43
47
  */
@@ -86,7 +90,7 @@ export interface TableProps<RecordType extends RaRecord = any> extends Partial<O
86
90
  * Can be an array of field sources/IDs.
87
91
  * If not specified, the first 5 fields will be shown.
88
92
  */
89
- defaultVisibleFields?: string[];
93
+ display?: string[];
90
94
  }
91
95
  /**
92
96
  * The Table component provides a declarative way to build data tables with Cloudscape components
@@ -101,12 +105,12 @@ export interface TableProps<RecordType extends RaRecord = any> extends Partial<O
101
105
  * ```
102
106
  */
103
107
  export declare const Table: {
104
- <RecordType extends RaRecord = any>({ title, actions, children, include, exclude, filtering, filteringPlaceholder, pageSizeOptions, preferences, reorderable, defaultVisibleFields, selectionType, ...props }: TableProps<RecordType>): import("react/jsx-runtime").JSX.Element;
108
+ <RecordType extends RaRecord = any>({ title, description, actions, children, include, exclude, filtering, filteringPlaceholder, pageSizeOptions, preferences, reorderable, display, selectionType, pagination, ...props }: TableProps<RecordType>): import("react/jsx-runtime").JSX.Element;
105
109
  Column: ({ children, source, link, field: FieldComponent }: ColumnProps) => import("react/jsx-runtime").JSX.Element;
106
110
  NumberColumn: ({ children, source, link, field: FieldComponent }: NumberColumnProps) => import("react/jsx-runtime").JSX.Element;
107
111
  DateColumn: ({ children, source, link, field: FieldComponent }: DateColumnProps) => import("react/jsx-runtime").JSX.Element;
108
112
  BooleanColumn: ({ children, source, field: FieldComponent }: BooleanColumnProps) => import("react/jsx-runtime").JSX.Element;
109
113
  ReferenceColumn: ({ children, source, reference, link, field: FieldComponent }: ReferenceColumnProps) => import("react/jsx-runtime").JSX.Element;
110
- Header: ({ title, actions, ...props }: import("./TableHeader").TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
114
+ Header: ({ title, actions, description, counter, info, variant, headingTagOverride }: import("./TableHeader").TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
111
115
  };
112
116
  export default Table;
@@ -5,8 +5,10 @@ import Pagination from '@cloudscape-design/components/pagination';
5
5
  import Box from '@cloudscape-design/components/box';
6
6
  import TextFilter from '@cloudscape-design/components/text-filter';
7
7
  import CollectionPreferences from '@cloudscape-design/components/collection-preferences';
8
- import { RecordContextProvider, useResourceContext, useFieldSchema, useResourceDefinition, useGetResourceLabel, useTranslateLabel, useTranslate } from '@strato-admin/core';
8
+ import { RecordContextProvider, useTranslateLabel, useTranslate } from '@strato-admin/ra-core';
9
+ import { useResourceSchema, useSettings } from '@strato-admin/core';
9
10
  import { useCollection } from '../collection-hooks';
11
+ import { useSchemaFields } from '../hooks/useSchemaFields';
10
12
  import TextField from '../field/TextField';
11
13
  import NumberField from '../field/NumberField';
12
14
  import DateField from '../field/DateField';
@@ -57,12 +59,6 @@ export const ReferenceColumn = ({ children, source, reference, link, field: Fiel
57
59
  }
58
60
  return (_jsx(ReferenceField, { reference: reference, link: link, source: source, children: children }));
59
61
  };
60
- const defaultPageSizeOptions = [
61
- { value: 10, label: '10 items' },
62
- { value: 25, label: '25 items' },
63
- { value: 50, label: '50 items' },
64
- { value: 100, label: '100 items' },
65
- ];
66
62
  /**
67
63
  * The Table component provides a declarative way to build data tables with Cloudscape components
68
64
  * while integrating with React Admin's data fetching and state management.
@@ -75,24 +71,22 @@ const defaultPageSizeOptions = [
75
71
  * </Table>
76
72
  * ```
77
73
  */
78
- export const Table = ({ title, actions, children, include, exclude, filtering = true, filteringPlaceholder, pageSizeOptions = defaultPageSizeOptions, preferences = true, reorderable = true, defaultVisibleFields, selectionType, ...props }) => {
79
- const resource = useResourceContext();
74
+ export const Table = ({ title, description, actions, children, include, exclude, filtering = true, filteringPlaceholder, pageSizeOptions, preferences = true, reorderable = true, display, selectionType, pagination = true, ...props }) => {
80
75
  const translate = useTranslate();
76
+ const { listPageSizes, listPageSizeLabel } = useSettings();
77
+ const resolvedPageSizeOptions = pageSizeOptions ??
78
+ (listPageSizes && listPageSizeLabel
79
+ ? listPageSizes.map((value) => ({
80
+ value,
81
+ label: listPageSizeLabel(value),
82
+ }))
83
+ : undefined);
81
84
  const translateLabel = useTranslateLabel();
82
- const schemaChildren = useFieldSchema();
83
- const resourceDefinition = useResourceDefinition({ resource });
84
- const finalSelectionType = selectionType ?? (resourceDefinition?.options?.canDelete ? 'multi' : undefined);
85
- const finalChildren = React.useMemo(() => {
86
- const baseChildren = children || schemaChildren;
87
- let result = React.Children.toArray(baseChildren);
88
- if (include) {
89
- result = result.filter((child) => React.isValidElement(child) && include.includes(child.props.source));
90
- }
91
- else if (exclude) {
92
- result = result.filter((child) => React.isValidElement(child) && !exclude.includes(child.props.source));
93
- }
94
- return result;
95
- }, [children, schemaChildren, include, exclude]);
85
+ const { resource, definition, label: schemaLabel, listDisplay } = useResourceSchema();
86
+ const { getListFields } = useSchemaFields();
87
+ const finalSelectionType = selectionType ?? (definition?.options?.canDelete ? 'multi' : undefined);
88
+ const finalDisplay = display || listDisplay;
89
+ const finalChildren = React.useMemo(() => getListFields(children, { include, exclude }), [getListFields, children, include, exclude]);
96
90
  // 1. Extract columns and options before calling useCollection
97
91
  const extractedColumns = React.useMemo(() => {
98
92
  const columns = [];
@@ -130,19 +124,18 @@ export const Table = ({ title, actions, children, include, exclude, filtering =
130
124
  const defaultVisibleContent = React.useMemo(() => {
131
125
  if (extractedColumns.options.length === 0)
132
126
  return undefined;
133
- if (defaultVisibleFields) {
127
+ if (finalDisplay) {
134
128
  // Map user-provided fields to their actual IDs
135
129
  return extractedColumns.options
136
130
  .filter((opt) => {
137
131
  const column = extractedColumns.columns.find((c) => c.id === opt.id);
138
- return (defaultVisibleFields.includes(opt.id) ||
139
- (column?.sortingField && defaultVisibleFields.includes(column.sortingField)));
132
+ return finalDisplay.includes(opt.id) || (column?.sortingField && finalDisplay.includes(column.sortingField));
140
133
  })
141
134
  .map((opt) => opt.id);
142
135
  }
143
136
  // Default to first 5 toggleable columns
144
137
  return extractedColumns.options.slice(0, 5).map((opt) => opt.id);
145
- }, [extractedColumns, defaultVisibleFields]);
138
+ }, [extractedColumns, finalDisplay]);
146
139
  const defaultContentDisplay = React.useMemo(() => {
147
140
  if (extractedColumns.options.length === 0)
148
141
  return undefined;
@@ -153,11 +146,8 @@ export const Table = ({ title, actions, children, include, exclude, filtering =
153
146
  }));
154
147
  }, [extractedColumns.options, defaultVisibleContent]);
155
148
  const { items, paginationProps, collectionProps, filterProps, preferencesProps } = useCollection({
156
- filtering: {},
157
- pagination: {},
158
- sorting: {},
159
149
  preferences: {
160
- pageSizeOptions,
150
+ pageSizeOptions: resolvedPageSizeOptions,
161
151
  visibleContentOptions: !reorderable && extractedColumns.options.length > 0 ? extractedColumns.options : undefined,
162
152
  contentDisplayOptions: reorderable && extractedColumns.options.length > 0 ? extractedColumns.options : undefined,
163
153
  visibleContent: defaultVisibleContent,
@@ -177,7 +167,6 @@ export const Table = ({ title, actions, children, include, exclude, filtering =
177
167
  return preferencesProps.preferences.visibleContent?.includes(col.id);
178
168
  });
179
169
  }, [extractedColumns.columns, extractedColumns.options, preferencesProps.preferences.visibleContent, reorderable]);
180
- const getResourceLabel = useGetResourceLabel();
181
170
  const tableHeader = React.useMemo(() => {
182
171
  if (title === null || title === false) {
183
172
  return undefined;
@@ -185,29 +174,40 @@ export const Table = ({ title, actions, children, include, exclude, filtering =
185
174
  if (React.isValidElement(title)) {
186
175
  return title;
187
176
  }
188
- const finalTitle = title !== undefined ? title : getResourceLabel(resource, 2);
189
- return _jsx(TableHeader, { title: finalTitle, actions: actions });
190
- }, [title, actions, resource, getResourceLabel]);
191
- return (_jsx(CloudscapeTable, { ...collectionProps, ...props, selectionType: finalSelectionType, stripedRows: preferencesProps.preferences.stripedRows, wrapLines: preferencesProps.preferences.wrapLines, columnDefinitions: columnDefinitions, columnDisplay: reorderable ? preferencesProps.preferences.contentDisplay : undefined, items: items || [], header: tableHeader, filter: filtering && (_jsx(TextFilter, { ...filterProps })), pagination: _jsx(Pagination, { ...paginationProps }), preferences: preferences === true || pageSizeOptions ? (_jsx(CollectionPreferences, { ...preferencesProps, pageSizePreference: pageSizeOptions
192
- ? {
193
- options: pageSizeOptions,
194
- }
195
- : undefined, visibleContentPreference: !reorderable && extractedColumns.options.length > 0
196
- ? {
197
- title: translate('ra.action.select_columns', { _: 'Select visible columns' }),
198
- options: [
199
- {
200
- label: translate('ra.action.select_columns', { _: 'Select visible columns' }),
201
- options: extractedColumns.options,
202
- },
203
- ],
204
- }
205
- : undefined, contentDisplayPreference: reorderable && extractedColumns.options.length > 0
206
- ? {
207
- title: translate('ra.action.select_columns', { _: 'Select visible columns' }),
208
- options: extractedColumns.options,
209
- }
210
- : undefined })) : React.isValidElement(preferences) ? (preferences) : undefined }));
177
+ const finalTitle = title !== undefined ? title : schemaLabel;
178
+ return _jsx(TableHeader, { title: finalTitle, description: description, actions: actions });
179
+ }, [title, description, actions, schemaLabel]);
180
+ const finalPreferences = React.useMemo(() => {
181
+ if (preferences === false)
182
+ return undefined;
183
+ if (React.isValidElement(preferences))
184
+ return preferences;
185
+ // preferences is true or an object, or we have pageSizeOptions
186
+ if (preferences === true || resolvedPageSizeOptions) {
187
+ return (_jsx(CollectionPreferences, { ...preferencesProps, pageSizePreference: resolvedPageSizeOptions
188
+ ? {
189
+ options: resolvedPageSizeOptions,
190
+ }
191
+ : undefined, visibleContentPreference: !reorderable && extractedColumns.options.length > 0
192
+ ? {
193
+ title: translate('strato.action.select_columns', { _: 'Select visible columns' }),
194
+ options: [
195
+ {
196
+ label: translate('strato.action.select_columns', { _: 'Select visible columns' }),
197
+ options: extractedColumns.options,
198
+ },
199
+ ],
200
+ }
201
+ : undefined, contentDisplayPreference: reorderable && extractedColumns.options.length > 0
202
+ ? {
203
+ title: translate('strato.action.select_columns', { _: 'Select visible columns' }),
204
+ options: extractedColumns.options,
205
+ }
206
+ : undefined }));
207
+ }
208
+ return undefined;
209
+ }, [preferences, resolvedPageSizeOptions, preferencesProps, reorderable, extractedColumns.options, translate]);
210
+ return (_jsx(CloudscapeTable, { ...collectionProps, ...props, selectionType: finalSelectionType, stripedRows: preferencesProps.preferences.stripedRows, wrapLines: preferencesProps.preferences.wrapLines, columnDefinitions: columnDefinitions, columnDisplay: reorderable ? preferencesProps.preferences.contentDisplay : undefined, items: items || [], header: tableHeader, filter: filtering && _jsx(TextFilter, { ...filterProps }), pagination: pagination === true ? _jsx(Pagination, { ...paginationProps }) : pagination || undefined, preferences: finalPreferences }));
211
211
  };
212
212
  Table.Column = Column;
213
213
  Table.NumberColumn = NumberColumn;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { HeaderProps } from '@cloudscape-design/components/header';
3
- export interface TableHeaderProps extends Omit<HeaderProps, 'children'> {
3
+ export interface TableHeaderProps extends Pick<HeaderProps, 'variant' | 'counter' | 'actions' | 'description' | 'info' | 'headingTagOverride'> {
4
4
  title?: React.ReactNode;
5
5
  }
6
- export declare const TableHeader: ({ title, actions, ...props }: TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
6
+ export declare const TableHeader: ({ title, actions, description, counter, info, variant, headingTagOverride }: TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
7
7
  export default TableHeader;
@@ -2,21 +2,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import Header from '@cloudscape-design/components/header';
4
4
  import SpaceBetween from '@cloudscape-design/components/space-between';
5
- import { useListContext, useTranslate, useLocale } from '@strato-admin/core';
5
+ import { useListContext, useTranslate, useLocale } from '@strato-admin/ra-core';
6
6
  import { BulkDeleteButton } from '../button/BulkDeleteButton';
7
7
  import { CreateButton } from '../button/CreateButton';
8
- export const TableHeader = ({ title, actions, ...props }) => {
8
+ export const TableHeader = ({ title, actions, description, counter, info, variant = 'h2', headingTagOverride }) => {
9
9
  const translate = useTranslate();
10
10
  const locale = useLocale();
11
- const { total, isPending, defaultTitle } = useListContext();
11
+ const { defaultTitle } = useListContext();
12
12
  const headerTitle = React.useMemo(() => {
13
13
  if (title !== undefined) {
14
14
  return typeof title === 'string' ? translate(title, { _: title }) : title;
15
15
  }
16
16
  return defaultTitle;
17
17
  }, [title, defaultTitle, translate, locale]);
18
- const counter = props.counter !== undefined ? props.counter : !isPending && total !== undefined ? `(${total})` : undefined;
19
18
  const headerActions = actions !== undefined ? (actions) : (_jsxs(SpaceBetween, { direction: "horizontal", size: "xs", children: [_jsx(BulkDeleteButton, {}), _jsx(CreateButton, {})] }));
20
- return (_jsx(Header, { variant: "h2", ...props, actions: headerActions, counter: counter, children: headerTitle }));
19
+ return (_jsx(Header, { variant: variant, actions: headerActions, counter: counter, description: description, info: info, headingTagOverride: headingTagOverride, children: headerTitle }));
21
20
  };
22
21
  export default TableHeader;
@@ -1,5 +1,5 @@
1
1
  import { useEffect } from 'react';
2
- import { useStore } from '@strato-admin/core';
2
+ import { useStore } from '@strato-admin/ra-core';
3
3
  import { Mode, applyMode } from '@cloudscape-design/global-styles';
4
4
  export const ThemeManager = () => {
5
5
  const [theme] = useStore('theme', 'light');