@donotdev/crud 0.0.8 → 0.0.9
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/dist/CrudService.d.ts +5 -53
- package/dist/CrudService.d.ts.map +1 -1
- package/dist/CrudService.js +1 -1
- package/dist/CrudStore.d.ts +1 -94
- package/dist/CrudStore.d.ts.map +1 -1
- package/dist/adapters/FirestoreAdapter.d.ts +3 -1
- package/dist/adapters/FirestoreAdapter.d.ts.map +1 -1
- package/dist/adapters/FirestoreAdapter.js +1 -1
- package/dist/adapters/FunctionsAdapter.d.ts +8 -1
- package/dist/adapters/FunctionsAdapter.d.ts.map +1 -1
- package/dist/adapters/FunctionsAdapter.js +1 -1
- package/dist/builtinFieldTypes.d.ts.map +1 -1
- package/dist/builtinFieldTypes.js +1 -1
- package/dist/components/EntityCardList.d.ts +5 -3
- package/dist/components/EntityCardList.d.ts.map +1 -1
- package/dist/components/EntityCardList.js +1 -1
- package/dist/components/EntityDisplayRenderer.d.ts +3 -3
- package/dist/components/EntityDisplayRenderer.d.ts.map +1 -1
- package/dist/components/EntityDisplayRenderer.js +1 -1
- package/dist/components/EntityFilters.d.ts +43 -0
- package/dist/components/EntityFilters.d.ts.map +1 -0
- package/dist/components/EntityFilters.js +1 -0
- package/dist/components/EntityFormRenderer.d.ts +22 -1
- package/dist/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/components/EntityFormRenderer.js +1 -1
- package/dist/components/EntityList.d.ts +12 -6
- package/dist/components/EntityList.d.ts.map +1 -1
- package/dist/components/EntityList.js +1 -1
- package/dist/components/FormFieldRenderer.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledAddressField.d.ts +3 -0
- package/dist/components/controlled/complex/ControlledAddressField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledDateField.d.ts +3 -0
- package/dist/components/controlled/complex/ControlledDateField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledGeoPointField.d.ts +3 -0
- package/dist/components/controlled/complex/ControlledGeoPointField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledMapField.d.ts +3 -0
- package/dist/components/controlled/complex/ControlledMapField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledMultiInputField.d.ts +3 -0
- package/dist/components/controlled/complex/ControlledMultiInputField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledRichTextField.d.ts +3 -0
- package/dist/components/controlled/complex/ControlledRichTextField.d.ts.map +1 -1
- package/dist/components/controlled/complex/ControlledTimestampField.d.ts +3 -0
- package/dist/components/controlled/complex/ControlledTimestampField.d.ts.map +1 -1
- package/dist/components/controlled/complex/index.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledDocumentField.d.ts +3 -0
- package/dist/components/controlled/file/ControlledDocumentField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledFileField.d.ts +3 -0
- package/dist/components/controlled/file/ControlledFileField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledImageField.d.ts +3 -0
- package/dist/components/controlled/file/ControlledImageField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledMultiDocumentField.d.ts +3 -0
- package/dist/components/controlled/file/ControlledMultiDocumentField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledMultiFileField.d.ts +3 -0
- package/dist/components/controlled/file/ControlledMultiFileField.d.ts.map +1 -1
- package/dist/components/controlled/file/ControlledMultiImageField.d.ts +3 -0
- package/dist/components/controlled/file/ControlledMultiImageField.d.ts.map +1 -1
- package/dist/components/controlled/file/index.d.ts.map +1 -1
- package/dist/components/controlled/index.d.ts +4 -0
- package/dist/components/controlled/index.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledCheckboxField.d.ts +3 -0
- package/dist/components/controlled/input/ControlledCheckboxField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledCheckboxField.js +1 -1
- package/dist/components/controlled/input/ControlledGdprConsentField.d.ts +8 -0
- package/dist/components/controlled/input/ControlledGdprConsentField.d.ts.map +1 -0
- package/dist/components/controlled/input/ControlledGdprConsentField.js +1 -0
- package/dist/components/controlled/input/ControlledNumberField.d.ts +3 -0
- package/dist/components/controlled/input/ControlledNumberField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledPasswordField.d.ts +3 -0
- package/dist/components/controlled/input/ControlledPasswordField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledPhoneField.d.ts +3 -0
- package/dist/components/controlled/input/ControlledPhoneField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledRangeField.d.ts +3 -0
- package/dist/components/controlled/input/ControlledRangeField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledSwitchField.d.ts +3 -0
- package/dist/components/controlled/input/ControlledSwitchField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledTextField.d.ts +3 -0
- package/dist/components/controlled/input/ControlledTextField.d.ts.map +1 -1
- package/dist/components/controlled/input/ControlledTextareaField.d.ts +3 -0
- package/dist/components/controlled/input/ControlledTextareaField.d.ts.map +1 -1
- package/dist/components/controlled/input/index.d.ts +1 -0
- package/dist/components/controlled/input/index.d.ts.map +1 -1
- package/dist/components/controlled/input/index.js +1 -1
- package/dist/components/controlled/select/ControlledComboboxField.d.ts +4 -0
- package/dist/components/controlled/select/ControlledComboboxField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledDropdownField.d.ts +4 -0
- package/dist/components/controlled/select/ControlledDropdownField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledMultiDropdownField.d.ts +4 -0
- package/dist/components/controlled/select/ControlledMultiDropdownField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledRadioField.d.ts +4 -0
- package/dist/components/controlled/select/ControlledRadioField.d.ts.map +1 -1
- package/dist/components/controlled/select/ControlledYearField.d.ts +9 -0
- package/dist/components/controlled/select/ControlledYearField.d.ts.map +1 -0
- package/dist/components/controlled/select/ControlledYearField.js +1 -0
- package/dist/components/controlled/select/index.d.ts +1 -0
- package/dist/components/controlled/select/index.d.ts.map +1 -1
- package/dist/components/controlled/select/index.js +1 -1
- package/dist/components/controlled/types.d.ts +6 -0
- package/dist/components/controlled/types.d.ts.map +1 -1
- package/dist/components/form/fields/CheckboxFieldComponent.d.ts +3 -3
- package/dist/components/form/fields/CheckboxFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/DocumentFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/FileFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/GdprConsentFieldComponent.d.ts +26 -0
- package/dist/components/form/fields/GdprConsentFieldComponent.d.ts.map +1 -0
- package/dist/components/form/fields/GdprConsentFieldComponent.js +1 -0
- package/dist/components/form/fields/ImageFieldComponent.d.ts +3 -2
- package/dist/components/form/fields/ImageFieldComponent.d.ts.map +1 -1
- package/dist/components/form/fields/ImageFieldComponent.js +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.d.ts.map +1 -1
- package/dist/components/form/fields/PhoneNumberComponent.js +1 -1
- package/dist/components/form/fields/RichTextComponent.d.ts +2 -21
- package/dist/components/form/fields/RichTextComponent.d.ts.map +1 -1
- package/dist/components/form/fields/TextAreaComponent.d.ts.map +1 -1
- package/dist/components/form/fields/TextAreaComponent.js +1 -1
- package/dist/components/form/fields/index.d.ts +3 -1
- package/dist/components/form/fields/index.d.ts.map +1 -1
- package/dist/components/form/fields/index.js +1 -1
- package/dist/components/form/fields/internal/TiptapEditor.d.ts +1 -1
- package/dist/components/form/fields/internal/TiptapEditor.d.ts.map +1 -1
- package/dist/components/form/fields/types.d.ts +33 -0
- package/dist/components/form/fields/types.d.ts.map +1 -0
- package/dist/components/form/fields/types.js +0 -0
- package/dist/components/form/internal/ImageViewerDialog.d.ts +2 -1
- package/dist/components/form/internal/ImageViewerDialog.d.ts.map +1 -1
- package/dist/components/form/internal/ImageViewerDialog.js +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/contexts/UploadContext.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityForm.d.ts.map +1 -1
- package/dist/forms/hooks/useEntityForm.js +1 -1
- package/dist/forms/index.d.ts +2 -2
- package/dist/forms/index.d.ts.map +1 -1
- package/dist/forms/index.js +1 -1
- package/dist/forms/types.d.ts +15 -0
- package/dist/forms/types.d.ts.map +1 -1
- package/dist/forms/utils/index.d.ts +0 -2
- package/dist/forms/utils/index.d.ts.map +1 -1
- package/dist/forms/utils/index.js +1 -1
- package/dist/hooks/useFileUpload.d.ts.map +1 -1
- package/dist/hooks/useFileUpload.js +1 -1
- package/dist/hooks/useFormNavigationGuard.d.ts +34 -0
- package/dist/hooks/useFormNavigationGuard.d.ts.map +1 -0
- package/dist/hooks/useFormNavigationGuard.js +1 -0
- package/dist/hooks/useUnsavedChangesWarning.d.ts +51 -0
- package/dist/hooks/useUnsavedChangesWarning.d.ts.map +1 -0
- package/dist/hooks/useUnsavedChangesWarning.js +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/stores/FormStore.d.ts +17 -0
- package/dist/stores/FormStore.d.ts.map +1 -1
- package/dist/stores/FormStore.js +1 -1
- package/dist/stores/index.d.ts +1 -1
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +167 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +0 -0
- package/dist/useCrud.d.ts +1 -2
- package/dist/useCrud.d.ts.map +1 -1
- package/dist/useCrud.js +1 -1
- package/dist/useCrudCardList.d.ts.map +1 -1
- package/dist/useCrudCardList.js +1 -1
- package/dist/useCrudList.d.ts +7 -0
- package/dist/useCrudList.d.ts.map +1 -1
- package/dist/useCrudList.js +1 -1
- package/dist/utils/mergeWithOptimistic.d.ts +1 -1
- package/dist/utils/mergeWithOptimistic.d.ts.map +1 -1
- package/dist/utils/uploadValidation.d.ts.map +1 -1
- package/package.json +17 -11
- package/dist/forms/utils/optionHelpers.d.ts +0 -54
- package/dist/forms/utils/optionHelpers.d.ts.map +0 -1
- package/dist/forms/utils/optionHelpers.js +0 -1
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Shared CRUD Types
|
|
3
|
+
* @description Types shared between CrudService and CrudStore to break circular dependencies
|
|
4
|
+
*
|
|
5
|
+
* @version 0.0.1
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
9
|
+
import type { dndevSchema, QueryClient } from '@donotdev/core';
|
|
10
|
+
import type { QueryOptions } from './adapters/FirestoreAdapter';
|
|
11
|
+
import type { PaginatedQueryResult } from './adapters/FunctionsAdapter';
|
|
12
|
+
/**
|
|
13
|
+
* Backend type for CRUD operations
|
|
14
|
+
*
|
|
15
|
+
* @version 0.0.1
|
|
16
|
+
* @since 0.0.1
|
|
17
|
+
* @author AMBROISE PARK Consulting
|
|
18
|
+
*/
|
|
19
|
+
export type BackendType = 'functions' | 'firestore';
|
|
20
|
+
/**
|
|
21
|
+
* Optimistic operation status
|
|
22
|
+
*/
|
|
23
|
+
export type OptimisticStatus = 'pending' | 'confirmed' | 'failed';
|
|
24
|
+
/**
|
|
25
|
+
* Optimistic operation metadata
|
|
26
|
+
*/
|
|
27
|
+
export interface OptimisticMeta {
|
|
28
|
+
tempId: string;
|
|
29
|
+
originalData: unknown | null;
|
|
30
|
+
status: OptimisticStatus;
|
|
31
|
+
operation: 'add' | 'update' | 'delete';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* CRUD store state interface
|
|
35
|
+
*
|
|
36
|
+
* @version 0.0.2
|
|
37
|
+
* @since 0.0.1
|
|
38
|
+
* @author AMBROISE PARK Consulting
|
|
39
|
+
*/
|
|
40
|
+
export interface CrudState {
|
|
41
|
+
backend: BackendType | null;
|
|
42
|
+
crudService: CrudServiceInterface | null;
|
|
43
|
+
collections: Record<string, {
|
|
44
|
+
loading: boolean;
|
|
45
|
+
error: Error | null;
|
|
46
|
+
data: Record<string, unknown>;
|
|
47
|
+
lastUpdated: number;
|
|
48
|
+
/** Optimistic operation metadata keyed by document id */
|
|
49
|
+
optimistic: Record<string, OptimisticMeta>;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* CRUD store actions interface
|
|
54
|
+
*
|
|
55
|
+
* @version 0.0.2
|
|
56
|
+
* @since 0.0.1
|
|
57
|
+
* @author AMBROISE PARK Consulting
|
|
58
|
+
*/
|
|
59
|
+
export interface CrudActions {
|
|
60
|
+
setCrudService: (service: CrudServiceInterface) => void;
|
|
61
|
+
setBackend: (backend: BackendType) => void;
|
|
62
|
+
setLoading: (collection: string, loading: boolean) => void;
|
|
63
|
+
setError: (collection: string, error: Error | null) => void;
|
|
64
|
+
setData: (collection: string, id: string, data: unknown) => void;
|
|
65
|
+
/** Batch update multiple documents in a single state update (performance) */
|
|
66
|
+
setDataBatch: (collection: string, items: Array<{
|
|
67
|
+
id: string;
|
|
68
|
+
data: unknown;
|
|
69
|
+
}>) => void;
|
|
70
|
+
removeData: (collection: string, id: string) => void;
|
|
71
|
+
clearCollection: (collection: string) => void;
|
|
72
|
+
clearError: (collection: string) => void;
|
|
73
|
+
/** Add item optimistically (before server confirms) */
|
|
74
|
+
addOptimistic: (collection: string, tempId: string, data: unknown) => void;
|
|
75
|
+
/** Confirm optimistic add - replace temp item with real item */
|
|
76
|
+
confirmOptimistic: (collection: string, tempId: string, realId: string, realData: unknown) => void;
|
|
77
|
+
/** Reject optimistic add - remove temp item */
|
|
78
|
+
rejectOptimistic: (collection: string, tempId: string) => void;
|
|
79
|
+
/** Update item optimistically */
|
|
80
|
+
updateOptimistic: (collection: string, id: string, data: unknown, originalData: unknown) => void;
|
|
81
|
+
/** Confirm optimistic update */
|
|
82
|
+
confirmUpdate: (collection: string, id: string) => void;
|
|
83
|
+
/** Reject optimistic update - restore original data */
|
|
84
|
+
rejectUpdate: (collection: string, id: string) => void;
|
|
85
|
+
/** Delete item optimistically (hide but keep for rollback) */
|
|
86
|
+
deleteOptimistic: (collection: string, id: string, originalData: unknown) => void;
|
|
87
|
+
/** Confirm optimistic delete - remove completely */
|
|
88
|
+
confirmDelete: (collection: string, id: string) => void;
|
|
89
|
+
/** Reject optimistic delete - restore item */
|
|
90
|
+
rejectDelete: (collection: string, id: string) => void;
|
|
91
|
+
getLoading: (collection: string) => boolean;
|
|
92
|
+
getError: (collection: string) => Error | null;
|
|
93
|
+
getData: (collection: string, id: string) => unknown | null;
|
|
94
|
+
/** Check if item is optimistic (not yet confirmed by server) */
|
|
95
|
+
isOptimistic: (collection: string, id: string) => boolean;
|
|
96
|
+
/** Get optimistic status for an item */
|
|
97
|
+
getOptimisticStatus: (collection: string, id: string) => OptimisticStatus | null;
|
|
98
|
+
/** Get all items in collection (including optimistic, excluding deleted) */
|
|
99
|
+
getCollectionData: (collection: string) => Array<{
|
|
100
|
+
id: string;
|
|
101
|
+
data: unknown;
|
|
102
|
+
isOptimistic: boolean;
|
|
103
|
+
}>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Store API type for CrudService - typed instead of any
|
|
107
|
+
* Used by CrudService to type the store it receives
|
|
108
|
+
*/
|
|
109
|
+
export type CrudStoreApi = {
|
|
110
|
+
getState: () => CrudState & CrudActions;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Cache options for read operations
|
|
114
|
+
*/
|
|
115
|
+
export interface CacheOptions {
|
|
116
|
+
/** Bypass cache and fetch directly from adapter */
|
|
117
|
+
noCache?: boolean;
|
|
118
|
+
/** Custom stale time in ms (default: Infinity) */
|
|
119
|
+
staleTime?: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* CRUD Service Interface
|
|
123
|
+
* Complete interface for CRUD operations with caching and optimistic updates
|
|
124
|
+
*
|
|
125
|
+
* @version 0.0.4
|
|
126
|
+
* @since 0.0.1
|
|
127
|
+
* @author AMBROISE PARK Consulting
|
|
128
|
+
*/
|
|
129
|
+
export interface CrudServiceInterface {
|
|
130
|
+
initialize(backend: BackendType): Promise<void>;
|
|
131
|
+
setStore(store: CrudStoreApi): void;
|
|
132
|
+
/** Schema accepts unknown since OperationSchemas stores dndevSchema<unknown>. T is for return type. */
|
|
133
|
+
getListQueryOptions<T>(collection: string, queryOptions: QueryOptions, schema: dndevSchema<unknown>, cacheOptions?: CacheOptions, schemaType?: 'list' | 'listCard'): {
|
|
134
|
+
queryKey: readonly string[];
|
|
135
|
+
queryFn: () => Promise<PaginatedQueryResult<T>>;
|
|
136
|
+
staleTime: number;
|
|
137
|
+
};
|
|
138
|
+
/** Schema accepts unknown since OperationSchemas stores dndevSchema<unknown>. T is for return type. */
|
|
139
|
+
getDocQueryOptions<T>(collection: string, id: string, schema: dndevSchema<unknown>, cacheOptions?: CacheOptions): {
|
|
140
|
+
queryKey: readonly string[];
|
|
141
|
+
queryFn: () => Promise<T | null>;
|
|
142
|
+
staleTime: number;
|
|
143
|
+
};
|
|
144
|
+
get<T>(collection: string, id: string, schema: dndevSchema<T>, options?: CacheOptions): Promise<T | null>;
|
|
145
|
+
query<T>(collection: string, options: QueryOptions, schema: dndevSchema<T>, cacheOptions?: CacheOptions, schemaType?: 'list' | 'listCard'): Promise<PaginatedQueryResult<T>>;
|
|
146
|
+
set<T>(collection: string, id: string, data: T, schema: dndevSchema<T>): Promise<void>;
|
|
147
|
+
update<T>(collection: string, id: string, data: Partial<T>): Promise<void>;
|
|
148
|
+
delete(collection: string, id: string): Promise<void>;
|
|
149
|
+
add<T>(collection: string, data: T, schema: dndevSchema<T>): Promise<string>;
|
|
150
|
+
subscribe<T>(collection: string, id: string, callback: (data: T | null, error?: Error) => void, schema: dndevSchema<T>): () => void;
|
|
151
|
+
subscribeToCollection<T>(collection: string, options: QueryOptions, callback: (data: T[], error?: Error) => void, schema: dndevSchema<T>): () => void;
|
|
152
|
+
/** Add with optimistic update - shows item immediately, confirms/rolls back after server */
|
|
153
|
+
addOptimistic<T extends {
|
|
154
|
+
id?: string;
|
|
155
|
+
}>(collection: string, data: T, schema: dndevSchema<T>): Promise<T & {
|
|
156
|
+
id: string;
|
|
157
|
+
}>;
|
|
158
|
+
/** Update with optimistic update - shows change immediately, confirms/rolls back after server */
|
|
159
|
+
updateOptimistic<T>(collection: string, id: string, data: Partial<T>, schema: dndevSchema<T>): Promise<T>;
|
|
160
|
+
/** Delete with optimistic update - hides item immediately, confirms/restores after server */
|
|
161
|
+
deleteOptimistic(collection: string, id: string): Promise<void>;
|
|
162
|
+
/** Invalidate all cached queries for a collection */
|
|
163
|
+
invalidateCollection(collection: string): Promise<void>;
|
|
164
|
+
/** Get the shared QueryClient instance from @donotdev/core */
|
|
165
|
+
getQueryClient(): QueryClient;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACxC;AAED;;;;;;GAMG;AAC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CAAC,IAAI,CAAC,CAAC;IACxD,8DAA8D;IAC9D,cAAc,IAAI,WAAW,CAAC;CAC/B"}
|
package/dist/types.js
ADDED
|
File without changes
|
package/dist/useCrud.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { dndevSchema, Entity, FeatureStatus, OperationSchemas, CrudAPI } from '@donotdev/core';
|
|
2
|
-
import type { CrudServiceInterface, CacheOptions } from './
|
|
3
|
-
import type { BackendType } from './CrudStore';
|
|
2
|
+
import type { CrudServiceInterface, CacheOptions, BackendType } from './types';
|
|
4
3
|
export declare const EMPTY_DATA: Record<string, unknown>;
|
|
5
4
|
export declare const EMPTY_OPTIMISTIC: Record<string, unknown>;
|
|
6
5
|
/**
|
package/dist/useCrud.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrud.d.ts","sourceRoot":"","sources":["../src/useCrud.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,OAAO,EACR,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"useCrud.d.ts","sourceRoot":"","sources":["../src/useCrud.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,OAAO,EACR,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAK/E,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAC;AACtD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAC;AAM5D;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,oBAAoB,GAAG,IAAI,CAEpE;AAMD,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACxB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAElD,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACvC,8BAA8B;IAC9B,aAAa,EAAE,YAAY,CAAC;IAC5B,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,aAAa,CAAC;AACtD,wBAAgB,OAAO,CAAC,CAAC,GAAG,OAAO,EACjC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC1B,aAAa,CAAC,CAAC,CAAC,CAAC;AACpB,wBAAgB,OAAO,CAAC,CAAC,GAAG,OAAO,EACjC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC1B,aAAa,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/useCrud.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as B,useMemo as y,useCallback as n}from"react";import{useFeatureConsent as L,FRAMEWORK_FEATURES as j,FEATURE_STATUS as f,handleError as V,isClient as W,createSchemas as Z,DEGRADED_CRUD_API as $}from"@donotdev/core";import{getCrudService as H}from"./CrudService";import{useCrudStore as a}from"./CrudStore";const J={},ee={};let U=null,v=null,D=!1;function
|
|
1
|
+
"use client";import{useEffect as B,useMemo as y,useCallback as n}from"react";import{useFeatureConsent as L,FRAMEWORK_FEATURES as j,FEATURE_STATUS as f,handleError as V,isClient as W,createSchemas as Z,DEGRADED_CRUD_API as $}from"@donotdev/core";import{getCrudService as H}from"./CrudService";import{useCrudStore as a}from"./CrudStore";const J={},ee={};let U=null,v=null,D=!1;function i(){return U}function te(u,o={}){const m=L(j.CRUD),w=a(e=>e.crudService),E=m&&!w,h=m?E?f.INITIALIZING:f.READY:f.DEGRADED;if(u==="status")return h;const S=typeof u=="object"?u:o.entity,t=typeof u=="string"?u:u.collection,d=o.backend||"functions",g=o.noCache??!1,T=o.staleTime,l=y(()=>({noCache:g,staleTime:T}),[g,T]),s=y(()=>{if(o.schema){const e=o.schema;return{create:e,draft:e,update:e,get:e,list:e,listCard:e,delete:e}}if(S)return Z(S)},[o.schema?"custom":S?.name,t]),b=a(e=>e.collections[t]?.data||J),P=a(e=>e.collections[t]?.loading||!1),A=a(e=>e.collections[t]?.error||null),F=a(e=>e.collections[t]?.data.current||null);B(()=>{if(!W()||!m||!s)return;const{crudService:e,backend:c}=a.getState();e&&c===d||v||(v=(async()=>{try{const r=H();U=r,r.setStore(a),await r.initialize(d),D=!1,a.getState().setBackend(d),a.getState().setCrudService(r)}catch(r){D||(V(r,{userMessage:"Failed to initialize CRUD service.",context:{backend:d,collection:t},severity:"error"}),D=!0)}finally{v=null}})())},[m,d,t,s?"hasSchema":"noSchema"]);const C=E||P,k=h===f.READY,x=n(async e=>{const c=i();return!c||!s?null:c.get(t,e,s.get,l)},[t,s?"hasSchema":"noSchema",l]),M=n(async(e,c)=>{const r=i();if(!r||!s)return;const G=c?.status==="draft"?s.draft:s.create;await r.set(t,e,c,G)},[t,s?"hasSchema":"noSchema"]),N=n(async(e,c)=>{const r=i();r&&await r.update(t,e,c)},[t]),z=n(async e=>{const c=i();c&&await c.delete(t,e)},[t]),Y=n(async e=>{const c=i();if(!c||!s)return"";const R=e?.status==="draft"?s.draft:s.create;return c.add(t,e,R)},[t,s?"hasSchema":"noSchema"]),q=n(async e=>{const c=i();return!c||!s?[]:(await c.query(t,e,s.list,l)).items},[t,s?"hasSchema":"noSchema",l]),p=n((e,c)=>{const r=i();return!r||!s?()=>{}:r.subscribe(t,e,c,s.get)},[t,s?"hasSchema":"noSchema"]),_=n((e,c)=>{const r=i();return!r||!s?()=>{}:r.subscribeToCollection(t,e,c,s.list)},[t,s?"hasSchema":"noSchema"]),I=n(async()=>{const e=i();e&&await e.invalidateCollection(t)},[t]);return k?{status:f.READY,data:F,loading:C,error:A,get:x,set:M,update:N,delete:z,add:Y,query:q,subscribe:p,subscribeToCollection:_,invalidate:I,isAvailable:!0,_collection:t,_schemas:s,_cacheOptions:l,_storeData:b}:{...$,status:h,loading:C,error:A,subscribe:p,subscribeToCollection:_,invalidate:I,_collection:t,_schemas:s,_cacheOptions:l,_storeData:b}}export{J as EMPTY_DATA,ee as EMPTY_OPTIMISTIC,i as getCrudServiceInstance,te as useCrud};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrudCardList.d.ts","sourceRoot":"","sources":["../src/useCrudCardList.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,WAAW,sBAAsB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAClE,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE;QAAE,KAAK,EAAE,CAAC,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5B,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,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BAAgB,eAAe,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACvE,kBAAkB,EAAE,MAAM,GAAG,MAAM,EACnC,OAAO,GAAE,sBAAsB,CAAC,CAAC,CAAM,GACtC,qBAAqB,CAAC,CAAC,CAAC,CA6F1B"}
|
package/dist/useCrudCardList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as y,useCallback as
|
|
1
|
+
import{useMemo as y,useCallback as S}from"react";import{useQuery as T}from"@donotdev/core";import{useCrudStore as _}from"./CrudStore";import{useCrud as h,getCrudServiceInstance as L,EMPTY_OPTIMISTIC as A}from"./useCrud";import{mergeWithOptimistic as D}from"./utils/mergeWithOptimistic";function K(p,n={}){const C=n.enabled??!0,i=h("status"),e=i==="ready",g=h(p,n),{error:c,invalidate:u,_collection:r,_schemas:a,_cacheOptions:l,_storeData:m}=g,d=_(t=>t.collections[r]?.optimistic||A),s=y(()=>{if(!e||!a)return null;const t=L();return t?t.getListQueryOptions(r,{},a.listCard,l,"listCard"):null},[e,r,l,a?"hasSchema":"noSchema"]),{data:o,isLoading:b,isFetching:q,error:v,refetch:f}=T({queryKey:s?.queryKey??["crud",r,"disabled"],queryFn:s?.queryFn??(()=>Promise.resolve({items:[]})),staleTime:s?.staleTime,enabled:C&&!!s}),O=y(()=>{if(!o||!e)return[];const t=o.items;return D(t,d,m)},[o,d,m,e]),I=S(async()=>{e&&(await u(),await f())},[u,f,e]);return e?{status:i,data:{items:O},loading:b,fetching:q,error:v??c,mutate:I,isAvailable:!0}:{status:i,data:{items:[]},loading:!1,fetching:!1,error:c,mutate:async()=>{},isAvailable:!1}}export{K as useCrudCardList};
|
package/dist/useCrudList.d.ts
CHANGED
|
@@ -12,11 +12,18 @@ import type { UseCrudOptions } from './useCrud';
|
|
|
12
12
|
export interface UseCrudListOptions<T> extends UseCrudOptions<T> {
|
|
13
13
|
/** Automatically fetch data on mount (default: true) */
|
|
14
14
|
enabled?: boolean;
|
|
15
|
+
/** Pagination mode: 'client' (default) fetches all, 'server' fetches per page */
|
|
16
|
+
pagination?: 'client' | 'server';
|
|
17
|
+
/** Page number for server-side pagination (1-indexed, default: 1) */
|
|
18
|
+
page?: number;
|
|
19
|
+
/** Page size for server-side pagination (default: 10) */
|
|
20
|
+
pageSize?: number;
|
|
15
21
|
}
|
|
16
22
|
export interface UseCrudListReturn<T> {
|
|
17
23
|
status: FeatureStatus;
|
|
18
24
|
data: {
|
|
19
25
|
items: T[];
|
|
26
|
+
total?: number;
|
|
20
27
|
} | null;
|
|
21
28
|
/** True during initial fetch (show skeletons) */
|
|
22
29
|
loading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrudList.d.ts","sourceRoot":"","sources":["../src/useCrudList.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"useCrudList.d.ts","sourceRoot":"","sources":["../src/useCrudList.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAKhD,MAAM,WAAW,kBAAkB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IAC9D,wDAAwD;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iFAAiF;IACjF,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACjC,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE;QAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5C,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,8BAA8B;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACnE,kBAAkB,EAAE,MAAM,GAAG,MAAM,EACnC,OAAO,GAAE,kBAAkB,CAAC,CAAC,CAAM,GAClC,iBAAiB,CAAC,CAAC,CAAC,CA6NtB"}
|
package/dist/useCrudList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as
|
|
1
|
+
import{useMemo as w,useCallback as B,useRef as x}from"react";import{useQuery as G}from"@donotdev/core";import{useCrudStore as H}from"./CrudStore";import{useCrud as A,getCrudServiceInstance as J,EMPTY_OPTIMISTIC as N}from"./useCrud";import{mergeWithOptimistic as U}from"./utils/mergeWithOptimistic";function ae(L,f={}){const _=f.enabled??!0,l=f.pagination??"client",e=f.page??1,s=f.pageSize??10,b=A("status"),r=b==="ready",E=A(L,f),{error:v,invalidate:C,_collection:m,_schemas:h,_cacheOptions:I,_storeData:O}=E,F=H(t=>t.collections[m]?.optimistic||N),T=x(new Map([[1,null]])),g=x(0),p=w(()=>{if(!r||!h)return null;const t=J();if(!t)return null;if(l==="client")return t.getListQueryOptions(m,{},h.list,I,"list");const d=T.current,i=g.current;let n,o;if(d.has(e))n=d.get(e)??void 0,o=s;else if(e>i&&d.has(i)){const M=e-i;n=d.get(i)??void 0,o=M*s}else n=void 0,o=e*s;return t.getListQueryOptions(m,{limit:o,startAfterId:n},h.list,I,"list")},[r,m,I,h?"hasSchema":"noSchema",l,e,s]),{data:u,isLoading:Q,isFetching:R,error:j,refetch:q}=G({queryKey:p?.queryKey??["crud",m,"disabled"],queryFn:p?.queryFn??(()=>Promise.resolve({items:[]})),staleTime:p?.staleTime,enabled:_&&!!p}),z=w(()=>{if(!u||!r)return{items:[],total:void 0};let t=u.items;if(l==="server"&&t.length>0){const a=T.current,c=g.current,k=t.length;if(Math.ceil(k/s)>1||e>c){const S=a.has(e)?e:c+1;for(let y=S;y<=e;y++){const D=(y-S+1)*s-1;if(D<t.length){const Y=t[D];a.set(y+1,Y.id)}}}u.lastVisible&&a.set(e+1,u.lastVisible),g.current=Math.max(c,e);const P=a.has(e)?0:(e-c-1)*s,W=P+s;t=t.slice(P,W)}const d=U(t,F,O),i=new Set(t.map(a=>a.id));let n=0,o=0;for(const[a,c]of Object.entries(F))c.operation==="add"&&!i.has(a)?n++:c.operation==="delete"&&i.has(a)&&o++;const V=(u.total??t.length)+n-o;return{items:d,total:V}},[u,F,O,r,l,e,s]),K=B(async()=>{r&&(l==="server"&&(T.current=new Map([[1,null]]),g.current=0),await C(),await q())},[C,q,r,l]);return r?{status:b,data:z,loading:Q,fetching:R,error:j??v,mutate:K,isAvailable:!0}:{status:b,data:{items:[],total:void 0},loading:!1,fetching:!1,error:v,mutate:async()=>{},isAvailable:!1}}export{ae as useCrudList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeWithOptimistic.d.ts","sourceRoot":"","sources":["../../src/utils/mergeWithOptimistic.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mergeWithOptimistic.d.ts","sourceRoot":"","sources":["../../src/utils/mergeWithOptimistic.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,UAAU,MAAM;IACd,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAClD,SAAS,EAAE,CAAC,EAAE,EACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAC1C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,CAAC,EAAE,CA4BL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadValidation.d.ts","sourceRoot":"","sources":["../../src/utils/uploadValidation.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGjD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"uploadValidation.d.ts","sourceRoot":"","sources":["../../src/utils/uploadValidation.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGjD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAGzD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,SAAK,GAAG,MAAM,EAAE,CA2C/D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAE9C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/crud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -49,35 +49,41 @@
|
|
|
49
49
|
"type-check": "tsc --noEmit"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
52
|
+
"@dnd-kit/core": "^6.3.1",
|
|
53
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
54
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
55
|
+
"@donotdev/components": "^0.0.14",
|
|
56
|
+
"@donotdev/core": "^0.0.18",
|
|
54
57
|
"@hookform/resolvers": "^5.2.2",
|
|
55
58
|
"react-easy-crop": "^5.5.6"
|
|
56
59
|
},
|
|
57
60
|
"peerDependencies": {
|
|
58
|
-
"@donotdev/firebase": "^0.0.
|
|
61
|
+
"@donotdev/firebase": "^0.0.6",
|
|
62
|
+
"@tiptap/extension-placeholder": "^3.16.0",
|
|
63
|
+
"@tiptap/pm": "^3.16.0",
|
|
64
|
+
"@tiptap/react": "^3.16.0",
|
|
65
|
+
"@tiptap/starter-kit": "^3.16.0",
|
|
59
66
|
"firebase": "^12.5.0",
|
|
60
67
|
"lucide-react": "^0.562.0",
|
|
61
68
|
"react": "^19.2.3",
|
|
62
69
|
"react-dom": "^19.2.3",
|
|
63
70
|
"react-hook-form": "^7.71.0",
|
|
64
|
-
"valibot": "^1.2.0"
|
|
65
|
-
"@tiptap/react": "^3.16.0",
|
|
66
|
-
"@tiptap/pm": "^3.16.0",
|
|
67
|
-
"@tiptap/starter-kit": "^3.16.0",
|
|
68
|
-
"@tiptap/extension-placeholder": "^3.16.0"
|
|
71
|
+
"valibot": "^1.2.0"
|
|
69
72
|
},
|
|
70
73
|
"peerDependenciesMeta": {
|
|
71
|
-
"@tiptap/
|
|
74
|
+
"@tiptap/extension-placeholder": {
|
|
72
75
|
"optional": true
|
|
73
76
|
},
|
|
74
77
|
"@tiptap/pm": {
|
|
75
78
|
"optional": true
|
|
76
79
|
},
|
|
80
|
+
"@tiptap/react": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
77
83
|
"@tiptap/starter-kit": {
|
|
78
84
|
"optional": true
|
|
79
85
|
},
|
|
80
|
-
"
|
|
86
|
+
"tiptap": {
|
|
81
87
|
"optional": true
|
|
82
88
|
}
|
|
83
89
|
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Option generation helpers for select fields
|
|
3
|
-
* @description Simple utilities to generate options arrays for select/dropdown fields.
|
|
4
|
-
*
|
|
5
|
-
* @version 0.0.1
|
|
6
|
-
* @since 0.0.1
|
|
7
|
-
* @author AMBROISE PARK Consulting
|
|
8
|
-
*/
|
|
9
|
-
/** Standard option format for select fields */
|
|
10
|
-
export interface SelectOption {
|
|
11
|
-
value: string;
|
|
12
|
-
label: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Generates year options for a select field.
|
|
16
|
-
*
|
|
17
|
-
* @param startYear - First year in the range
|
|
18
|
-
* @param endYear - Last year in the range (defaults to current year)
|
|
19
|
-
* @param descending - Whether to sort descending (newest first, default: true)
|
|
20
|
-
* @returns Array of options with value and label
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* // In entity definition
|
|
25
|
-
* year: {
|
|
26
|
-
* type: 'select',
|
|
27
|
-
* validation: {
|
|
28
|
-
* required: true,
|
|
29
|
-
* options: yearOptions(1995) // 2026, 2025, 2024, ... 1995
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export declare function yearOptions(startYear: number, endYear?: number, descending?: boolean): SelectOption[];
|
|
35
|
-
/**
|
|
36
|
-
* Generates numeric range options for a select field.
|
|
37
|
-
*
|
|
38
|
-
* @param start - First number in the range
|
|
39
|
-
* @param end - Last number in the range
|
|
40
|
-
* @param step - Increment between numbers (default: 1)
|
|
41
|
-
* @param descending - Whether to sort descending (default: false)
|
|
42
|
-
* @returns Array of options with value and label
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* // Quantities 1-10
|
|
47
|
-
* options: rangeOptions(1, 10)
|
|
48
|
-
*
|
|
49
|
-
* // Percentages 0-100 by 10
|
|
50
|
-
* options: rangeOptions(0, 100, 10)
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export declare function rangeOptions(start: number, end: number, step?: number, descending?: boolean): SelectOption[];
|
|
54
|
-
//# sourceMappingURL=optionHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"optionHelpers.d.ts","sourceRoot":"","sources":["../../../src/forms/utils/optionHelpers.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,MAAiC,EAC1C,UAAU,GAAE,OAAc,GACzB,YAAY,EAAE,CAchB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAU,EAChB,UAAU,GAAE,OAAe,GAC1B,YAAY,EAAE,CAchB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function o(n,t=new Date().getFullYear(),i=!0){const r=[];if(i)for(let e=t;e>=n;e--)r.push({value:String(e),label:String(e)});else for(let e=n;e<=t;e++)r.push({value:String(e),label:String(e)});return r}function u(n,t,i=1,r=!1){const e=[];if(r)for(let l=t;l>=n;l-=i)e.push({value:String(l),label:String(l)});else for(let l=n;l<=t;l+=i)e.push({value:String(l),label:String(l)});return e}export{u as rangeOptions,o as yearOptions};
|