admin-lib-cms 1.2.18 → 1.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -129,6 +129,35 @@ export const cmsConfig: CmsConfig = {
129
129
  };
130
130
  ```
131
131
 
132
+ ### Custom collection fields
133
+
134
+ Use `customRender` when a field needs application-specific behavior. Keep the
135
+ component and its business rules in your app, then provide it to the CMS
136
+ configuration. Use `renderCell` for its table display and `formatExport` for
137
+ its exported value.
138
+
139
+ ```tsx
140
+ {
141
+ id: "availability",
142
+ label: "Availability",
143
+ type: "text",
144
+ colSpan: 12,
145
+ defaultValue: {},
146
+ customRender: ({ value, record, onChange, readOnly }) =>
147
+ <AvailabilityEditor
148
+ value={value}
149
+ record={record}
150
+ onChange={onChange}
151
+ readOnly={readOnly}
152
+ />,
153
+ renderCell: (value) => <AvailabilitySummary value={value} />,
154
+ formatExport: (value) => summarizeAvailability(value),
155
+ }
156
+ ```
157
+
158
+ The package also exports reusable field controls (`FormattedNumberInput`,
159
+ `SearchableMultiSelect`, and `AdminTimeRangePicker`) for custom renderers.
160
+
132
161
  ### 4. Wrap your application with the CmsProvider
133
162
  Typically in your `layout.tsx` or `_app.tsx`, pass your adapter and configuration to the provider:
134
163
 
package/dist/index.d.mts CHANGED
@@ -1,12 +1,14 @@
1
1
  export { CmsProvider, EditableFile, EditableImage, EditableLink, EditableList, EditableReference, EditableText, useCmsContext, useCmsOptional, useSubmit } from './client.mjs';
2
2
  import * as React from 'react';
3
3
  import React__default, { ReactNode } from 'react';
4
+ import { TimePicker } from 'antd';
4
5
  import { MenuLabels } from './types.mjs';
5
6
  export { CmsConfig, CollectionDef, CollectionEntry, CollectionField, EditableMeta, FieldType, GlobalGroup, OverridesMap, PageDef, StorageAdapter, Submission } from './types.mjs';
6
7
  export { generateDefaultTemplate, sendEmailNotification } from './emails/index.mjs';
7
8
 
8
9
  type AdminLocale = "es" | "en";
9
10
 
11
+ declare function AdminTimeRangePicker(props: React__default.ComponentProps<typeof TimePicker.RangePicker>): React__default.JSX.Element;
10
12
  interface CustomAdminSection {
11
13
  id: string;
12
14
  label: string;
@@ -31,6 +33,31 @@ interface AdminAppProps {
31
33
  lang?: AdminLocale | string;
32
34
  }
33
35
  declare function AdminApp(props: AdminAppProps): React__default.JSX.Element;
36
+ declare function FormattedNumberInput({ value, onChange, isPrice, isPercent, allowEmpty, placeholder, className, containerClassName, }: {
37
+ value: unknown;
38
+ onChange: (val: number | null) => void;
39
+ isPrice?: boolean;
40
+ isPercent?: boolean;
41
+ allowEmpty?: boolean;
42
+ placeholder?: string;
43
+ className?: string;
44
+ containerClassName?: string;
45
+ }): React__default.JSX.Element;
46
+ declare function SearchableMultiSelect({ options, value, onChange, placeholder, searchable, searchPlaceholder, emptyMessage, loading, error, max, }: {
47
+ options: {
48
+ value: string;
49
+ label: string;
50
+ }[];
51
+ value: string[];
52
+ onChange: (value: string[]) => void;
53
+ placeholder: string;
54
+ searchable?: boolean;
55
+ searchPlaceholder?: string;
56
+ emptyMessage?: string;
57
+ loading?: boolean;
58
+ error?: string;
59
+ max?: number;
60
+ }): React__default.JSX.Element;
34
61
 
35
62
  interface AdminLoginProps {
36
63
  authApiRoute?: string;
@@ -71,4 +98,4 @@ declare function SubscriptionProvider({ children, apiUrl, projectId, email, vali
71
98
 
72
99
  declare function SubscriptionPage(): React.JSX.Element;
73
100
 
74
- export { AdminApp, AdminLogin, type AdminLoginProps, MenuLabels, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useSubscription, useSubscriptionContext };
101
+ export { AdminApp, AdminLogin, type AdminLoginProps, AdminTimeRangePicker, FormattedNumberInput, MenuLabels, SearchableMultiSelect, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useSubscription, useSubscriptionContext };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  export { CmsProvider, EditableFile, EditableImage, EditableLink, EditableList, EditableReference, EditableText, useCmsContext, useCmsOptional, useSubmit } from './client.js';
2
2
  import * as React from 'react';
3
3
  import React__default, { ReactNode } from 'react';
4
+ import { TimePicker } from 'antd';
4
5
  import { MenuLabels } from './types.js';
5
6
  export { CmsConfig, CollectionDef, CollectionEntry, CollectionField, EditableMeta, FieldType, GlobalGroup, OverridesMap, PageDef, StorageAdapter, Submission } from './types.js';
6
7
  export { generateDefaultTemplate, sendEmailNotification } from './emails/index.js';
7
8
 
8
9
  type AdminLocale = "es" | "en";
9
10
 
11
+ declare function AdminTimeRangePicker(props: React__default.ComponentProps<typeof TimePicker.RangePicker>): React__default.JSX.Element;
10
12
  interface CustomAdminSection {
11
13
  id: string;
12
14
  label: string;
@@ -31,6 +33,31 @@ interface AdminAppProps {
31
33
  lang?: AdminLocale | string;
32
34
  }
33
35
  declare function AdminApp(props: AdminAppProps): React__default.JSX.Element;
36
+ declare function FormattedNumberInput({ value, onChange, isPrice, isPercent, allowEmpty, placeholder, className, containerClassName, }: {
37
+ value: unknown;
38
+ onChange: (val: number | null) => void;
39
+ isPrice?: boolean;
40
+ isPercent?: boolean;
41
+ allowEmpty?: boolean;
42
+ placeholder?: string;
43
+ className?: string;
44
+ containerClassName?: string;
45
+ }): React__default.JSX.Element;
46
+ declare function SearchableMultiSelect({ options, value, onChange, placeholder, searchable, searchPlaceholder, emptyMessage, loading, error, max, }: {
47
+ options: {
48
+ value: string;
49
+ label: string;
50
+ }[];
51
+ value: string[];
52
+ onChange: (value: string[]) => void;
53
+ placeholder: string;
54
+ searchable?: boolean;
55
+ searchPlaceholder?: string;
56
+ emptyMessage?: string;
57
+ loading?: boolean;
58
+ error?: string;
59
+ max?: number;
60
+ }): React__default.JSX.Element;
34
61
 
35
62
  interface AdminLoginProps {
36
63
  authApiRoute?: string;
@@ -71,4 +98,4 @@ declare function SubscriptionProvider({ children, apiUrl, projectId, email, vali
71
98
 
72
99
  declare function SubscriptionPage(): React.JSX.Element;
73
100
 
74
- export { AdminApp, AdminLogin, type AdminLoginProps, MenuLabels, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useSubscription, useSubscriptionContext };
101
+ export { AdminApp, AdminLogin, type AdminLoginProps, AdminTimeRangePicker, FormattedNumberInput, MenuLabels, SearchableMultiSelect, type SubscriptionContextValue, type SubscriptionData, SubscriptionPage, SubscriptionProvider, useSubscription, useSubscriptionContext };