@strato-admin/cloudscape 0.1.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 (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/Admin.d.ts +17 -0
  4. package/dist/Admin.js +69 -0
  5. package/dist/RecordLink.d.ts +9 -0
  6. package/dist/RecordLink.js +43 -0
  7. package/dist/__mocks__/strato-core.js +50 -0
  8. package/dist/__mocks__to__delete/strato-core.js +50 -0
  9. package/dist/button/BulkDeleteButton.d.ts +7 -0
  10. package/dist/button/BulkDeleteButton.js +17 -0
  11. package/dist/button/Button.d.ts +6 -0
  12. package/dist/button/Button.js +6 -0
  13. package/dist/button/CreateButton.d.ts +6 -0
  14. package/dist/button/CreateButton.js +24 -0
  15. package/dist/button/EditButton.d.ts +8 -0
  16. package/dist/button/EditButton.js +24 -0
  17. package/dist/button/SaveButton.d.ts +6 -0
  18. package/dist/button/SaveButton.js +8 -0
  19. package/dist/button/index.d.ts +5 -0
  20. package/dist/button/index.js +5 -0
  21. package/dist/collection-hooks/index.d.ts +2 -0
  22. package/dist/collection-hooks/index.js +2 -0
  23. package/dist/collection-hooks/interfaces.d.ts +93 -0
  24. package/dist/collection-hooks/interfaces.js +1 -0
  25. package/dist/collection-hooks/useCollection.d.ts +3 -0
  26. package/dist/collection-hooks/useCollection.js +102 -0
  27. package/dist/create/Create.d.ts +40 -0
  28. package/dist/create/Create.js +34 -0
  29. package/dist/create/CreateHeader.d.ts +7 -0
  30. package/dist/create/CreateHeader.js +18 -0
  31. package/dist/create/index.d.ts +2 -0
  32. package/dist/create/index.js +2 -0
  33. package/dist/detail/KeyValuePairs.d.ts +36 -0
  34. package/dist/detail/KeyValuePairs.js +58 -0
  35. package/dist/detail/Show.d.ts +39 -0
  36. package/dist/detail/Show.js +40 -0
  37. package/dist/detail/ShowHeader.d.ts +7 -0
  38. package/dist/detail/ShowHeader.js +19 -0
  39. package/dist/detail/index.d.ts +3 -0
  40. package/dist/detail/index.js +3 -0
  41. package/dist/edit/Edit.d.ts +42 -0
  42. package/dist/edit/Edit.js +38 -0
  43. package/dist/edit/EditHeader.d.ts +7 -0
  44. package/dist/edit/EditHeader.js +18 -0
  45. package/dist/edit/index.d.ts +2 -0
  46. package/dist/edit/index.js +2 -0
  47. package/dist/field/ArrayField.d.ts +29 -0
  48. package/dist/field/ArrayField.js +30 -0
  49. package/dist/field/BadgeField.d.ts +12 -0
  50. package/dist/field/BadgeField.js +15 -0
  51. package/dist/field/BooleanField.d.ts +18 -0
  52. package/dist/field/BooleanField.js +14 -0
  53. package/dist/field/CurrencyField.d.ts +19 -0
  54. package/dist/field/CurrencyField.js +23 -0
  55. package/dist/field/DateField.d.ts +14 -0
  56. package/dist/field/DateField.js +17 -0
  57. package/dist/field/IdField.d.ts +17 -0
  58. package/dist/field/IdField.js +21 -0
  59. package/dist/field/NumberField.d.ts +14 -0
  60. package/dist/field/NumberField.js +18 -0
  61. package/dist/field/ReferenceField.d.ts +16 -0
  62. package/dist/field/ReferenceField.js +23 -0
  63. package/dist/field/ReferenceManyField.d.ts +55 -0
  64. package/dist/field/ReferenceManyField.js +19 -0
  65. package/dist/field/StatusIndicatorField.d.ts +56 -0
  66. package/dist/field/StatusIndicatorField.js +48 -0
  67. package/dist/field/TextField.d.ts +5 -0
  68. package/dist/field/TextField.js +11 -0
  69. package/dist/field/index.d.ts +23 -0
  70. package/dist/field/index.js +23 -0
  71. package/dist/field/types.d.ts +56 -0
  72. package/dist/field/types.js +1 -0
  73. package/dist/form/Form.d.ts +13 -0
  74. package/dist/form/Form.js +33 -0
  75. package/dist/form/index.d.ts +2 -0
  76. package/dist/form/index.js +2 -0
  77. package/dist/index.d.ts +22 -0
  78. package/dist/index.js +22 -0
  79. package/dist/input/AttributeEditor.d.ts +25 -0
  80. package/dist/input/AttributeEditor.js +80 -0
  81. package/dist/input/AutocompleteInput.d.ts +10 -0
  82. package/dist/input/AutocompleteInput.js +67 -0
  83. package/dist/input/FieldTitle.d.ts +8 -0
  84. package/dist/input/FieldTitle.js +29 -0
  85. package/dist/input/FormField.d.ts +7 -0
  86. package/dist/input/FormField.js +35 -0
  87. package/dist/input/FormFieldContext.d.ts +6 -0
  88. package/dist/input/FormFieldContext.js +3 -0
  89. package/dist/input/NumberInput.d.ts +7 -0
  90. package/dist/input/NumberInput.js +27 -0
  91. package/dist/input/ReferenceInput.d.ts +3 -0
  92. package/dist/input/ReferenceInput.js +25 -0
  93. package/dist/input/SelectInput.d.ts +15 -0
  94. package/dist/input/SelectInput.js +47 -0
  95. package/dist/input/SliderInput.d.ts +6 -0
  96. package/dist/input/SliderInput.js +25 -0
  97. package/dist/input/TextAreaInput.d.ts +6 -0
  98. package/dist/input/TextAreaInput.js +23 -0
  99. package/dist/input/TextInput.d.ts +7 -0
  100. package/dist/input/TextInput.js +23 -0
  101. package/dist/input/index.d.ts +11 -0
  102. package/dist/input/index.js +11 -0
  103. package/dist/input/types.d.ts +6 -0
  104. package/dist/input/types.js +1 -0
  105. package/dist/layout/AppLayout.d.ts +8 -0
  106. package/dist/layout/AppLayout.js +38 -0
  107. package/dist/layout/TopNavigation.d.ts +6 -0
  108. package/dist/layout/TopNavigation.js +53 -0
  109. package/dist/layout/index.d.ts +2 -0
  110. package/dist/layout/index.js +2 -0
  111. package/dist/list/Cards.d.ts +11 -0
  112. package/dist/list/Cards.js +27 -0
  113. package/dist/list/List.d.ts +43 -0
  114. package/dist/list/List.js +28 -0
  115. package/dist/list/Table.d.ts +112 -0
  116. package/dist/list/Table.examples.d.ts +1 -0
  117. package/dist/list/Table.examples.js +3 -0
  118. package/dist/list/Table.js +218 -0
  119. package/dist/list/TableHeader.d.ts +7 -0
  120. package/dist/list/TableHeader.js +22 -0
  121. package/dist/list/index.d.ts +4 -0
  122. package/dist/list/index.js +4 -0
  123. package/dist/preferences/index.d.ts +0 -0
  124. package/dist/preferences/index.js +1 -0
  125. package/dist/theme/ThemeManager.d.ts +2 -0
  126. package/dist/theme/ThemeManager.js +11 -0
  127. package/dist/theme/index.d.ts +2 -0
  128. package/dist/theme/index.js +2 -0
  129. package/package.json +73 -0
  130. package/src/Admin.test.tsx +32 -0
  131. package/src/Admin.tsx +123 -0
  132. package/src/RecordLink.stories.tsx +56 -0
  133. package/src/RecordLink.tsx +67 -0
  134. package/src/__mocks__/strato-core.tsx +52 -0
  135. package/src/button/BulkDeleteButton.stories.tsx +59 -0
  136. package/src/button/BulkDeleteButton.test.tsx +64 -0
  137. package/src/button/BulkDeleteButton.tsx +41 -0
  138. package/src/button/Button.stories.tsx +31 -0
  139. package/src/button/Button.tsx +12 -0
  140. package/src/button/CreateButton.stories.tsx +42 -0
  141. package/src/button/CreateButton.tsx +38 -0
  142. package/src/button/EditButton.stories.tsx +29 -0
  143. package/src/button/EditButton.tsx +38 -0
  144. package/src/button/SaveButton.stories.tsx +35 -0
  145. package/src/button/SaveButton.tsx +19 -0
  146. package/src/button/index.ts +5 -0
  147. package/src/collection-hooks/index.ts +2 -0
  148. package/src/collection-hooks/interfaces.ts +80 -0
  149. package/src/collection-hooks/useCollection.test.ts +413 -0
  150. package/src/collection-hooks/useCollection.ts +125 -0
  151. package/src/create/Create.test.tsx +63 -0
  152. package/src/create/Create.tsx +93 -0
  153. package/src/create/CreateHeader.tsx +34 -0
  154. package/src/create/index.ts +2 -0
  155. package/src/detail/KeyValuePairs.test.tsx +98 -0
  156. package/src/detail/KeyValuePairs.tsx +107 -0
  157. package/src/detail/Show.test.tsx +96 -0
  158. package/src/detail/Show.tsx +104 -0
  159. package/src/detail/ShowHeader.test.tsx +80 -0
  160. package/src/detail/ShowHeader.tsx +35 -0
  161. package/src/detail/index.ts +3 -0
  162. package/src/edit/Edit.test.tsx +91 -0
  163. package/src/edit/Edit.tsx +102 -0
  164. package/src/edit/EditHeader.tsx +34 -0
  165. package/src/edit/index.ts +2 -0
  166. package/src/field/ArrayField.tsx +51 -0
  167. package/src/field/BadgeField.tsx +33 -0
  168. package/src/field/BooleanField.stories.tsx +56 -0
  169. package/src/field/BooleanField.test.tsx +63 -0
  170. package/src/field/BooleanField.tsx +42 -0
  171. package/src/field/CurrencyField.stories.tsx +67 -0
  172. package/src/field/CurrencyField.tsx +45 -0
  173. package/src/field/DateField.stories.tsx +67 -0
  174. package/src/field/DateField.tsx +33 -0
  175. package/src/field/IdField.test.tsx +88 -0
  176. package/src/field/IdField.tsx +40 -0
  177. package/src/field/NumberField.stories.tsx +75 -0
  178. package/src/field/NumberField.tsx +35 -0
  179. package/src/field/ReferenceField.test.tsx +88 -0
  180. package/src/field/ReferenceField.tsx +64 -0
  181. package/src/field/ReferenceManyField.test.tsx +41 -0
  182. package/src/field/ReferenceManyField.tsx +73 -0
  183. package/src/field/StatusIndicatorField.stories.tsx +93 -0
  184. package/src/field/StatusIndicatorField.test.tsx +143 -0
  185. package/src/field/StatusIndicatorField.tsx +119 -0
  186. package/src/field/TextField.stories.tsx +45 -0
  187. package/src/field/TextField.tsx +17 -0
  188. package/src/field/index.ts +23 -0
  189. package/src/field/types.ts +58 -0
  190. package/src/form/Form.test.tsx +55 -0
  191. package/src/form/Form.tsx +66 -0
  192. package/src/form/index.ts +2 -0
  193. package/src/index.ts +25 -0
  194. package/src/input/AttributeEditor.test.tsx +147 -0
  195. package/src/input/AttributeEditor.tsx +185 -0
  196. package/src/input/AutocompleteInput.test.tsx +178 -0
  197. package/src/input/AutocompleteInput.tsx +116 -0
  198. package/src/input/FieldTitle.tsx +53 -0
  199. package/src/input/FormField.tsx +87 -0
  200. package/src/input/FormFieldContext.ts +9 -0
  201. package/src/input/NumberInput.tsx +56 -0
  202. package/src/input/ReferenceInput.test.tsx +35 -0
  203. package/src/input/ReferenceInput.tsx +36 -0
  204. package/src/input/SelectInput.tsx +91 -0
  205. package/src/input/SliderInput.test.tsx +103 -0
  206. package/src/input/SliderInput.tsx +49 -0
  207. package/src/input/TextAreaInput.tsx +48 -0
  208. package/src/input/TextInput.test.tsx +91 -0
  209. package/src/input/TextInput.tsx +51 -0
  210. package/src/input/index.ts +11 -0
  211. package/src/input/types.ts +14 -0
  212. package/src/layout/AppLayout.test.tsx +87 -0
  213. package/src/layout/AppLayout.tsx +60 -0
  214. package/src/layout/TopNavigation.test.tsx +78 -0
  215. package/src/layout/TopNavigation.tsx +84 -0
  216. package/src/layout/index.ts +2 -0
  217. package/src/list/Cards.tsx +58 -0
  218. package/src/list/List.tsx +76 -0
  219. package/src/list/Table.examples.tsx +11 -0
  220. package/src/list/Table.stories.tsx +73 -0
  221. package/src/list/Table.test.tsx +255 -0
  222. package/src/list/Table.tsx +438 -0
  223. package/src/list/TableHeader.test.tsx +114 -0
  224. package/src/list/TableHeader.tsx +44 -0
  225. package/src/list/index.ts +4 -0
  226. package/src/preferences/index.ts +0 -0
  227. package/src/stories/Button.stories.ts +54 -0
  228. package/src/stories/Button.tsx +31 -0
  229. package/src/stories/Configure.mdx +369 -0
  230. package/src/stories/Header.stories.ts +34 -0
  231. package/src/stories/Header.tsx +47 -0
  232. package/src/stories/Page.stories.ts +33 -0
  233. package/src/stories/Page.tsx +71 -0
  234. package/src/stories/RaStoryDecorator.tsx +38 -0
  235. package/src/stories/assets/accessibility.png +0 -0
  236. package/src/stories/assets/accessibility.svg +1 -0
  237. package/src/stories/assets/addon-library.png +0 -0
  238. package/src/stories/assets/assets.png +0 -0
  239. package/src/stories/assets/avif-test-image.avif +0 -0
  240. package/src/stories/assets/context.png +0 -0
  241. package/src/stories/assets/discord.svg +1 -0
  242. package/src/stories/assets/docs.png +0 -0
  243. package/src/stories/assets/figma-plugin.png +0 -0
  244. package/src/stories/assets/github.svg +1 -0
  245. package/src/stories/assets/share.png +0 -0
  246. package/src/stories/assets/styling.png +0 -0
  247. package/src/stories/assets/testing.png +0 -0
  248. package/src/stories/assets/theming.png +0 -0
  249. package/src/stories/assets/tutorials.svg +1 -0
  250. package/src/stories/assets/youtube.svg +1 -0
  251. package/src/stories/button.css +30 -0
  252. package/src/stories/header.css +32 -0
  253. package/src/stories/page.css +68 -0
  254. package/src/theme/ThemeManager.tsx +15 -0
  255. package/src/theme/index.ts +2 -0
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { type RaRecord } from '@strato-admin/core';
3
+ export interface CreateProps<RecordType extends RaRecord = RaRecord> {
4
+ children?: React.ReactNode;
5
+ inputSchema?: React.ReactNode;
6
+ title?: React.ReactNode;
7
+ actions?: React.ReactNode;
8
+ resource?: string;
9
+ record?: Partial<RecordType>;
10
+ redirect?: any;
11
+ transform?: any;
12
+ mutationOptions?: any;
13
+ include?: string[];
14
+ exclude?: string[];
15
+ }
16
+ /**
17
+ * A Create component that provides record context and a Cloudscape Container.
18
+ *
19
+ * @example
20
+ * <Create>
21
+ * <Form>
22
+ * <TextInput source="name" />
23
+ * </Form>
24
+ * </Create>
25
+ *
26
+ * @example
27
+ * // Using InputSchema from context
28
+ * <Create include={['name', 'price']} />
29
+ *
30
+ * @example
31
+ * // Passing a custom input schema
32
+ * <Create inputSchema={<InputSchema>...</InputSchema>}>
33
+ * <Form />
34
+ * </Create>
35
+ */
36
+ export declare const Create: {
37
+ <RecordType extends RaRecord = RaRecord<import("@strato-admin/ra-core").Identifier>>({ children, inputSchema, title, actions, include, exclude, ...props }: CreateProps<RecordType>): import("react/jsx-runtime").JSX.Element;
38
+ Header: ({ title, actions, ...props }: import("./CreateHeader").CreateHeaderProps) => import("react/jsx-runtime").JSX.Element;
39
+ };
40
+ export default Create;
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CreateBase, ResourceSchemaProvider } from '@strato-admin/core';
3
+ import Container from '@cloudscape-design/components/container';
4
+ import { CreateHeader } from './CreateHeader';
5
+ import Form from '../form/Form';
6
+ const CreateUI = ({ children, resource, inputSchema, title, actions, include, exclude, }) => {
7
+ const finalChildren = children || _jsx(Form, { include: include, exclude: exclude });
8
+ return (_jsx(ResourceSchemaProvider, { resource: resource, inputSchema: inputSchema, children: _jsx(Container, { header: _jsx(CreateHeader, { title: title, actions: actions }), children: finalChildren }) }));
9
+ };
10
+ /**
11
+ * A Create component that provides record context and a Cloudscape Container.
12
+ *
13
+ * @example
14
+ * <Create>
15
+ * <Form>
16
+ * <TextInput source="name" />
17
+ * </Form>
18
+ * </Create>
19
+ *
20
+ * @example
21
+ * // Using InputSchema from context
22
+ * <Create include={['name', 'price']} />
23
+ *
24
+ * @example
25
+ * // Passing a custom input schema
26
+ * <Create inputSchema={<InputSchema>...</InputSchema>}>
27
+ * <Form />
28
+ * </Create>
29
+ */
30
+ export const Create = ({ children, inputSchema, title, actions, include, exclude, ...props }) => {
31
+ return (_jsx(CreateBase, { ...props, children: _jsx(CreateUI, { resource: props.resource, title: title, actions: actions, include: include, exclude: exclude, inputSchema: inputSchema, children: children }) }));
32
+ };
33
+ Create.Header = CreateHeader;
34
+ export default Create;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { HeaderProps } from '@cloudscape-design/components/header';
3
+ export interface CreateHeaderProps extends Omit<HeaderProps, 'children'> {
4
+ title?: React.ReactNode;
5
+ }
6
+ export declare const CreateHeader: ({ title, actions, ...props }: CreateHeaderProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default CreateHeader;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import Header from '@cloudscape-design/components/header';
4
+ import SpaceBetween from '@cloudscape-design/components/space-between';
5
+ import { useCreateContext, useTranslate } from '@strato-admin/core';
6
+ export const CreateHeader = ({ title, actions, ...props }) => {
7
+ const translate = useTranslate();
8
+ const { defaultTitle } = useCreateContext();
9
+ const headerTitle = React.useMemo(() => {
10
+ if (title !== undefined) {
11
+ return typeof title === 'string' ? translate(title, { _: title }) : title;
12
+ }
13
+ return defaultTitle;
14
+ }, [title, defaultTitle, translate]);
15
+ const headerActions = actions || (_jsx(SpaceBetween, { direction: "horizontal", size: "xs" }));
16
+ return (_jsx(Header, { variant: "h2", ...props, actions: headerActions, children: headerTitle }));
17
+ };
18
+ export default CreateHeader;
@@ -0,0 +1,2 @@
1
+ export * from './Create';
2
+ export * from './CreateHeader';
@@ -0,0 +1,2 @@
1
+ export * from './Create';
2
+ export * from './CreateHeader';
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { type KeyValuePairsProps as CloudscapeKeyValuePairsProps } from '@cloudscape-design/components/key-value-pairs';
3
+ import { type RaRecord } from '@strato-admin/core';
4
+ export interface KeyValuePairsProps extends Partial<Omit<CloudscapeKeyValuePairsProps, 'items'>> {
5
+ children?: React.ReactNode;
6
+ include?: string[];
7
+ exclude?: string[];
8
+ columns?: number;
9
+ minColumnWidth?: number;
10
+ }
11
+ export interface KeyValueFieldProps {
12
+ source?: string;
13
+ label?: string;
14
+ children?: React.ReactNode;
15
+ field?: React.ComponentType<any>;
16
+ }
17
+ /**
18
+ * KeyValuePairs.Field is a helper component to define a field in a KeyValuePairs component.
19
+ * It mirrors the DataTable.Col pattern.
20
+ */
21
+ export declare const KeyValueField: ({ children, source, field: FieldComponent }: KeyValueFieldProps) => import("react/jsx-runtime").JSX.Element;
22
+ /**
23
+ * A KeyValuePairs component that mirrors the Cloudscape KeyValuePairs component
24
+ * but automatically handles labels and record context for its children.
25
+ *
26
+ * @example
27
+ * <KeyValuePairs columns={2}>
28
+ * <TextField source="name" label="Full Name" />
29
+ * <KeyValuePairs.Field source="age" label="Age" />
30
+ * </KeyValuePairs>
31
+ */
32
+ export declare const KeyValuePairs: {
33
+ <RecordType extends RaRecord = RaRecord<import("@strato-admin/ra-core").Identifier>>({ children, include, exclude, columns, minColumnWidth, ...props }: KeyValuePairsProps): import("react/jsx-runtime").JSX.Element;
34
+ Field: ({ children, source, field: FieldComponent }: KeyValueFieldProps) => import("react/jsx-runtime").JSX.Element;
35
+ };
36
+ export default KeyValuePairs;
@@ -0,0 +1,58 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import CloudscapeKeyValuePairs from '@cloudscape-design/components/key-value-pairs';
4
+ import { useResourceContext, useRecordContext, FieldTitle, RecordContextProvider, useFieldSchema, } from '@strato-admin/core';
5
+ import TextField from '../field/TextField';
6
+ /**
7
+ * KeyValuePairs.Field is a helper component to define a field in a KeyValuePairs component.
8
+ * It mirrors the DataTable.Col pattern.
9
+ */
10
+ export const KeyValueField = ({ children, source, field: FieldComponent }) => {
11
+ if (children) {
12
+ return (_jsx(_Fragment, { children: React.Children.map(children, (child) => React.isValidElement(child) ? React.cloneElement(child, { source }) : child) }));
13
+ }
14
+ if (FieldComponent) {
15
+ return _jsx(FieldComponent, { source: source });
16
+ }
17
+ return _jsx(TextField, { source: source });
18
+ };
19
+ /**
20
+ * A KeyValuePairs component that mirrors the Cloudscape KeyValuePairs component
21
+ * but automatically handles labels and record context for its children.
22
+ *
23
+ * @example
24
+ * <KeyValuePairs columns={2}>
25
+ * <TextField source="name" label="Full Name" />
26
+ * <KeyValuePairs.Field source="age" label="Age" />
27
+ * </KeyValuePairs>
28
+ */
29
+ export const KeyValuePairs = ({ children, include, exclude, columns = 3, // Default to 3 columns if not specified
30
+ minColumnWidth, ...props }) => {
31
+ const resource = useResourceContext();
32
+ const record = useRecordContext();
33
+ const schemaChildren = useFieldSchema();
34
+ const finalChildren = React.useMemo(() => {
35
+ const baseChildren = children || schemaChildren;
36
+ let result = React.Children.toArray(baseChildren);
37
+ if (include) {
38
+ result = result.filter((child) => React.isValidElement(child) && include.includes(child.props.source));
39
+ }
40
+ else if (exclude) {
41
+ result = result.filter((child) => React.isValidElement(child) && !exclude.includes(child.props.source));
42
+ }
43
+ return result;
44
+ }, [children, schemaChildren, include, exclude]);
45
+ const items = React.Children.map(finalChildren, (child) => {
46
+ if (!React.isValidElement(child)) {
47
+ return null;
48
+ }
49
+ const { source, label } = child.props;
50
+ return {
51
+ label: _jsx(FieldTitle, { source: source, resource: resource, label: label }),
52
+ value: _jsx(RecordContextProvider, { value: record, children: child }),
53
+ };
54
+ })?.filter((item) => item !== null) || [];
55
+ return _jsx(CloudscapeKeyValuePairs, { ...props, items: items, columns: columns, minColumnWidth: minColumnWidth });
56
+ };
57
+ KeyValuePairs.Field = KeyValueField;
58
+ export default KeyValuePairs;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import { type RaRecord } from '@strato-admin/core';
3
+ export interface ShowProps<_RecordType extends RaRecord = RaRecord> {
4
+ children?: React.ReactNode;
5
+ fieldSchema?: React.ReactNode;
6
+ title?: React.ReactNode;
7
+ actions?: React.ReactNode;
8
+ resource?: string;
9
+ id?: any;
10
+ queryOptions?: any;
11
+ include?: string[];
12
+ exclude?: string[];
13
+ }
14
+ /**
15
+ * A Show component that provides record context and a Cloudscape Container.
16
+ *
17
+ * @example
18
+ * <Show>
19
+ * <KeyValuePairs>
20
+ * <TextField source="name" />
21
+ * <NumberField source="price" />
22
+ * </KeyValuePairs>
23
+ * </Show>
24
+ *
25
+ * @example
26
+ * // Using FieldSchema from context
27
+ * <Show include={['name', 'price']} />
28
+ *
29
+ * @example
30
+ * // Passing a custom field schema
31
+ * <Show fieldSchema={<FieldSchema>...</FieldSchema>}>
32
+ * <KeyValuePairs />
33
+ * </Show>
34
+ */
35
+ export declare const Show: {
36
+ <RecordType extends RaRecord = RaRecord<import("@strato-admin/ra-core").Identifier>>({ children, fieldSchema, title, actions, include, exclude, ...props }: ShowProps<RecordType>): import("react/jsx-runtime").JSX.Element;
37
+ Header: ({ title, actions, ...props }: import("./ShowHeader").ShowHeaderProps) => import("react/jsx-runtime").JSX.Element;
38
+ };
39
+ export default Show;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ShowBase, useShowContext, ResourceSchemaProvider } from '@strato-admin/core';
3
+ import Container from '@cloudscape-design/components/container';
4
+ import SpaceBetween from '@cloudscape-design/components/space-between';
5
+ import { ShowHeader } from './ShowHeader';
6
+ import KeyValuePairs from './KeyValuePairs';
7
+ const ShowUI = ({ children, resource, fieldSchema, title, actions, include, exclude, }) => {
8
+ const { record, isLoading } = useShowContext();
9
+ if (isLoading || !record) {
10
+ return null;
11
+ }
12
+ const finalChildren = children || _jsx(KeyValuePairs, { include: include, exclude: exclude });
13
+ return (_jsx(ResourceSchemaProvider, { resource: resource, fieldSchema: fieldSchema, children: _jsx(Container, { header: _jsx(ShowHeader, { title: title, actions: actions }), children: _jsx(SpaceBetween, { direction: "vertical", size: "l", children: finalChildren }) }) }));
14
+ };
15
+ /**
16
+ * A Show component that provides record context and a Cloudscape Container.
17
+ *
18
+ * @example
19
+ * <Show>
20
+ * <KeyValuePairs>
21
+ * <TextField source="name" />
22
+ * <NumberField source="price" />
23
+ * </KeyValuePairs>
24
+ * </Show>
25
+ *
26
+ * @example
27
+ * // Using FieldSchema from context
28
+ * <Show include={['name', 'price']} />
29
+ *
30
+ * @example
31
+ * // Passing a custom field schema
32
+ * <Show fieldSchema={<FieldSchema>...</FieldSchema>}>
33
+ * <KeyValuePairs />
34
+ * </Show>
35
+ */
36
+ export const Show = ({ children, fieldSchema, title, actions, include, exclude, ...props }) => {
37
+ return (_jsx(ShowBase, { ...props, children: _jsx(ShowUI, { resource: props.resource, title: title, actions: actions, include: include, exclude: exclude, fieldSchema: fieldSchema, children: children }) }));
38
+ };
39
+ Show.Header = ShowHeader;
40
+ export default Show;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { HeaderProps } from '@cloudscape-design/components/header';
3
+ export interface ShowHeaderProps extends Omit<HeaderProps, 'children'> {
4
+ title?: React.ReactNode;
5
+ }
6
+ export declare const ShowHeader: ({ title, actions, ...props }: ShowHeaderProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default ShowHeader;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import Header from '@cloudscape-design/components/header';
4
+ import SpaceBetween from '@cloudscape-design/components/space-between';
5
+ import { useShowContext, useTranslate } from '@strato-admin/core';
6
+ import { EditButton } from '../button/EditButton';
7
+ export const ShowHeader = ({ title, actions, ...props }) => {
8
+ const translate = useTranslate();
9
+ const { record, defaultTitle } = useShowContext();
10
+ const headerTitle = React.useMemo(() => {
11
+ if (title !== undefined) {
12
+ return typeof title === 'string' ? translate(title, { _: title }) : title;
13
+ }
14
+ return defaultTitle;
15
+ }, [title, defaultTitle, translate]);
16
+ const headerActions = actions || (_jsx(SpaceBetween, { direction: "horizontal", size: "xs", children: _jsx(EditButton, { record: record }) }));
17
+ return (_jsx(Header, { variant: "h2", ...props, actions: headerActions, children: headerTitle }));
18
+ };
19
+ export default ShowHeader;
@@ -0,0 +1,3 @@
1
+ export * from './KeyValuePairs';
2
+ export * from './Show';
3
+ export * from './ShowHeader';
@@ -0,0 +1,3 @@
1
+ export * from './KeyValuePairs';
2
+ export * from './Show';
3
+ export * from './ShowHeader';
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { type RaRecord } from '@strato-admin/core';
3
+ export interface EditProps<_RecordType extends RaRecord = RaRecord> {
4
+ children?: React.ReactNode;
5
+ inputSchema?: React.ReactNode;
6
+ title?: React.ReactNode;
7
+ actions?: React.ReactNode;
8
+ resource?: string;
9
+ id?: any;
10
+ mutationMode?: 'pessimistic' | 'optimistic' | 'undoable';
11
+ mutationOptions?: any;
12
+ queryOptions?: any;
13
+ redirect?: any;
14
+ transform?: any;
15
+ include?: string[];
16
+ exclude?: string[];
17
+ }
18
+ /**
19
+ * An Edit component that provides record context and a Cloudscape Container.
20
+ *
21
+ * @example
22
+ * <Edit>
23
+ * <Form>
24
+ * <TextInput source="name" />
25
+ * </Form>
26
+ * </Edit>
27
+ *
28
+ * @example
29
+ * // Using InputSchema from context
30
+ * <Edit include={['name', 'price']} />
31
+ *
32
+ * @example
33
+ * // Passing a custom input schema
34
+ * <Edit inputSchema={<InputSchema>...</InputSchema>}>
35
+ * <Form />
36
+ * </Edit>
37
+ */
38
+ export declare const Edit: {
39
+ <RecordType extends RaRecord = any>({ children, inputSchema, title, actions, include, exclude, ...props }: EditProps<RecordType>): import("react/jsx-runtime").JSX.Element;
40
+ Header: ({ title, actions, ...props }: import("./EditHeader").EditHeaderProps) => import("react/jsx-runtime").JSX.Element;
41
+ };
42
+ export default Edit;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { EditBase, useEditContext, ResourceSchemaProvider } from '@strato-admin/core';
3
+ import Container from '@cloudscape-design/components/container';
4
+ import { EditHeader } from './EditHeader';
5
+ import Form from '../form/Form';
6
+ const EditUI = ({ children, resource, inputSchema, title, actions, include, exclude, }) => {
7
+ const { record, isLoading } = useEditContext();
8
+ if (isLoading || !record) {
9
+ return null;
10
+ }
11
+ const finalChildren = children || _jsx(Form, { include: include, exclude: exclude });
12
+ return (_jsx(ResourceSchemaProvider, { resource: resource, inputSchema: inputSchema, children: _jsx(Container, { header: _jsx(EditHeader, { title: title, actions: actions }), children: finalChildren }) }));
13
+ };
14
+ /**
15
+ * An Edit component that provides record context and a Cloudscape Container.
16
+ *
17
+ * @example
18
+ * <Edit>
19
+ * <Form>
20
+ * <TextInput source="name" />
21
+ * </Form>
22
+ * </Edit>
23
+ *
24
+ * @example
25
+ * // Using InputSchema from context
26
+ * <Edit include={['name', 'price']} />
27
+ *
28
+ * @example
29
+ * // Passing a custom input schema
30
+ * <Edit inputSchema={<InputSchema>...</InputSchema>}>
31
+ * <Form />
32
+ * </Edit>
33
+ */
34
+ export const Edit = ({ children, inputSchema, title, actions, include, exclude, ...props }) => {
35
+ return (_jsx(EditBase, { ...props, children: _jsx(EditUI, { resource: props.resource, title: title, actions: actions, include: include, exclude: exclude, inputSchema: inputSchema, children: children }) }));
36
+ };
37
+ Edit.Header = EditHeader;
38
+ export default Edit;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { HeaderProps } from '@cloudscape-design/components/header';
3
+ export interface EditHeaderProps extends Omit<HeaderProps, 'children'> {
4
+ title?: React.ReactNode;
5
+ }
6
+ export declare const EditHeader: ({ title, actions, ...props }: EditHeaderProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default EditHeader;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import Header from '@cloudscape-design/components/header';
4
+ import SpaceBetween from '@cloudscape-design/components/space-between';
5
+ import { useEditContext, useTranslate } from '@strato-admin/core';
6
+ export const EditHeader = ({ title, actions, ...props }) => {
7
+ const translate = useTranslate();
8
+ const { defaultTitle } = useEditContext();
9
+ const headerTitle = React.useMemo(() => {
10
+ if (title !== undefined) {
11
+ return typeof title === 'string' ? translate(title, { _: title }) : title;
12
+ }
13
+ return defaultTitle;
14
+ }, [title, defaultTitle, translate]);
15
+ const headerActions = actions || (_jsx(SpaceBetween, { direction: "horizontal", size: "xs" }));
16
+ return (_jsx(Header, { variant: "h2", ...props, actions: headerActions, children: headerTitle }));
17
+ };
18
+ export default EditHeader;
@@ -0,0 +1,2 @@
1
+ export * from './Edit';
2
+ export * from './EditHeader';
@@ -0,0 +1,2 @@
1
+ export * from './Edit';
2
+ export * from './EditHeader';
@@ -0,0 +1,29 @@
1
+ import { type RaRecord } from '@strato-admin/core';
2
+ import { type FieldProps } from './types';
3
+ export interface ArrayFieldProps<RecordType extends RaRecord = RaRecord> extends FieldProps<RecordType> {
4
+ /**
5
+ * Thecomponents to render for each item in the array.
6
+ */
7
+ children: React.ReactNode;
8
+ /**
9
+ * Number of items per page if pagination is used within the field.
10
+ */
11
+ perPage?: number;
12
+ }
13
+ /**
14
+ * ArrayField component that wraps its children with a ListContextProvider
15
+ * and ResourceContextProvider initialized with the array data and resource name.
16
+ *
17
+ * This allows using components that expect a ListContext or ResourceContext
18
+ * (like DataTable) to display nested arrays within a record.
19
+ *
20
+ * @example
21
+ * <ArrayField source="products" resource="products">
22
+ * <DataTable variant="embedded">
23
+ * <DataTable.Col source="title" label="Title" />
24
+ * <DataTable.NumberCol source="price" label="Price" />
25
+ * </DataTable>
26
+ * </ArrayField>
27
+ */
28
+ export declare const ArrayField: <RecordType extends RaRecord = any>(props: ArrayFieldProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
29
+ export default ArrayField;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRecordContext, useList, ListContextProvider, ResourceContextProvider } from '@strato-admin/core';
3
+ /**
4
+ * ArrayField component that wraps its children with a ListContextProvider
5
+ * and ResourceContextProvider initialized with the array data and resource name.
6
+ *
7
+ * This allows using components that expect a ListContext or ResourceContext
8
+ * (like DataTable) to display nested arrays within a record.
9
+ *
10
+ * @example
11
+ * <ArrayField source="products" resource="products">
12
+ * <DataTable variant="embedded">
13
+ * <DataTable.Col source="title" label="Title" />
14
+ * <DataTable.NumberCol source="price" label="Price" />
15
+ * </DataTable>
16
+ * </ArrayField>
17
+ */
18
+ export const ArrayField = (props) => {
19
+ const { source, resource, children, perPage = 10 } = props;
20
+ const record = useRecordContext();
21
+ const data = (source && record?.[source]) || [];
22
+ const targetResource = resource || source || '';
23
+ const listContext = useList({
24
+ data,
25
+ resource: targetResource,
26
+ perPage,
27
+ });
28
+ return (_jsx(ResourceContextProvider, { value: targetResource, children: _jsx(ListContextProvider, { value: listContext, children: children }) }));
29
+ };
30
+ export default ArrayField;
@@ -0,0 +1,12 @@
1
+ import { type BadgeProps } from '@cloudscape-design/components/badge';
2
+ import { type RaRecord } from '@strato-admin/core';
3
+ import { type FieldProps } from './types';
4
+ export interface BadgeFieldProps<RecordType extends RaRecord = RaRecord> extends FieldProps<RecordType> {
5
+ /**
6
+ * The color of the badge.
7
+ * @default "grey"
8
+ */
9
+ color?: BadgeProps['color'];
10
+ }
11
+ declare const BadgeField: <RecordType extends RaRecord = RaRecord>(props: BadgeFieldProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
12
+ export default BadgeField;
@@ -0,0 +1,15 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import Badge from '@cloudscape-design/components/badge';
3
+ import { useFieldValue, useRecordContext } from '@strato-admin/core';
4
+ import RecordLink from '../RecordLink';
5
+ const BadgeField = (props) => {
6
+ const { source, record: recordProp, emptyText, link, color = 'grey' } = props;
7
+ const record = useRecordContext({ record: recordProp });
8
+ const value = useFieldValue({ source: source, record });
9
+ const hasValue = value !== null && value !== undefined && value !== '';
10
+ if (!hasValue) {
11
+ return _jsx(_Fragment, { children: emptyText ?? null });
12
+ }
13
+ return (_jsx(RecordLink, { link: link, children: _jsx(Badge, { color: color, children: String(value) }) }));
14
+ };
15
+ export default BadgeField;
@@ -0,0 +1,18 @@
1
+ import { RaRecord } from '@strato-admin/core';
2
+ import { type FieldProps } from './types';
3
+ export type BooleanFieldProps<RecordType extends RaRecord = RaRecord> = FieldProps<RecordType> & {
4
+ /**
5
+ * The label to display when the value is true. Defaults to "Yes".
6
+ */
7
+ trueLabel?: string;
8
+ /**
9
+ * The label to display when the value is false. Defaults to "No".
10
+ */
11
+ falseLabel?: string;
12
+ /**
13
+ * Whether to show the text label alongside the icon.
14
+ */
15
+ showLabel?: boolean;
16
+ };
17
+ declare const BooleanField: <RecordType extends RaRecord = RaRecord>(props: BooleanFieldProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
18
+ export default BooleanField;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import StatusIndicator from '@cloudscape-design/components/status-indicator';
3
+ import { useFieldValue, useRecordContext, useTranslate } from '@strato-admin/core';
4
+ import RecordLink from '../RecordLink';
5
+ const BooleanField = (props) => {
6
+ const { source, record: recordProp, trueLabel, falseLabel, showLabel = false, link } = props;
7
+ const record = useRecordContext({ record: recordProp });
8
+ const value = useFieldValue({ source: source, record });
9
+ const translate = useTranslate();
10
+ const isTrue = !!value;
11
+ const content = isTrue ? (_jsx(StatusIndicator, { type: "success", colorOverride: "green", children: showLabel ? (trueLabel ?? translate('ra.boolean.true', { _: 'Yes' })) : null })) : (_jsx(StatusIndicator, { type: "not-started", children: showLabel ? (falseLabel ?? translate('ra.boolean.false', { _: 'No' })) : null }));
12
+ return _jsx(RecordLink, { link: link, children: content });
13
+ };
14
+ export default BooleanField;
@@ -0,0 +1,19 @@
1
+ import { type RaRecord } from '@strato-admin/core';
2
+ import { type FieldProps } from './types';
3
+ export type CurrencyFieldProps<RecordType extends RaRecord = RaRecord> = FieldProps<RecordType> & {
4
+ /**
5
+ * Options for Intl.NumberFormat.
6
+ */
7
+ options?: Intl.NumberFormatOptions;
8
+ /**
9
+ * Locale(s) to use for formatting. Defaults to the current app locale.
10
+ */
11
+ locales?: string | string[];
12
+ /**
13
+ * The currency to use in currency formatting.
14
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currency_2
15
+ */
16
+ currency: string;
17
+ };
18
+ declare const CurrencyField: <RecordType extends RaRecord = RaRecord>(props: CurrencyFieldProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
19
+ export default CurrencyField;
@@ -0,0 +1,23 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useFieldValue, useRecordContext, useLocale } from '@strato-admin/core';
3
+ import RecordLink from '../RecordLink';
4
+ const CurrencyField = (props) => {
5
+ const { source, record: recordProp, emptyText, options, locales, link, currency } = props;
6
+ const record = useRecordContext({ record: recordProp });
7
+ const value = useFieldValue({ source: source, record });
8
+ const currentLocale = useLocale();
9
+ const hasValue = value !== null && value !== undefined && value !== '';
10
+ if (!hasValue) {
11
+ return _jsx(_Fragment, { children: emptyText ?? null });
12
+ }
13
+ const numberValue = typeof value === 'string' ? parseFloat(value) : value;
14
+ const formatOptions = {
15
+ style: 'currency',
16
+ currency,
17
+ ...options,
18
+ };
19
+ const formattedValue = new Intl.NumberFormat(locales || currentLocale, formatOptions).format(numberValue);
20
+ return _jsx(RecordLink, { link: link, children: formattedValue });
21
+ };
22
+ CurrencyField.isNumberColumn = true;
23
+ export default CurrencyField;
@@ -0,0 +1,14 @@
1
+ import { type RaRecord } from '@strato-admin/core';
2
+ import { type FieldProps } from './types';
3
+ export type DateFieldProps<RecordType extends RaRecord = RaRecord> = FieldProps<RecordType> & {
4
+ /**
5
+ * Options for Intl.DateTimeFormat.
6
+ */
7
+ options?: Intl.DateTimeFormatOptions;
8
+ /**
9
+ * Locale(s) to use for formatting. Defaults to the current app locale.
10
+ */
11
+ locales?: string | string[];
12
+ };
13
+ declare const DateField: <RecordType extends RaRecord = RaRecord>(props: DateFieldProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
14
+ export default DateField;