@panneau/core 4.1.0 → 5.0.0-alpha.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.
- package/README.md +83 -0
- package/dist/definition/abilities.d.ts +21 -0
- package/dist/definition/abilities.d.ts.map +1 -0
- package/dist/definition/abilities.js +47 -0
- package/dist/definition/abilities.js.map +1 -0
- package/dist/definition/form.d.ts +31 -0
- package/dist/definition/form.d.ts.map +1 -0
- package/dist/definition/form.js +54 -0
- package/dist/definition/form.js.map +1 -0
- package/dist/definition/list.d.ts +44 -0
- package/dist/definition/list.d.ts.map +1 -0
- package/dist/definition/list.js +70 -0
- package/dist/definition/list.js.map +1 -0
- package/dist/definition/resource.d.ts +21 -0
- package/dist/definition/resource.d.ts.map +1 -0
- package/dist/definition/resource.js +24 -0
- package/dist/definition/resource.js.map +1 -0
- package/dist/form/form.d.ts +148 -0
- package/dist/form/form.d.ts.map +1 -0
- package/dist/form/form.js +239 -0
- package/dist/form/form.js.map +1 -0
- package/dist/form/messages.d.ts +7 -0
- package/dist/form/messages.d.ts.map +1 -0
- package/dist/form/messages.js +25 -0
- package/dist/form/messages.js.map +1 -0
- package/dist/form/problem.d.ts +16 -0
- package/dist/form/problem.d.ts.map +1 -0
- package/dist/form/problem.js +34 -0
- package/dist/form/problem.js.map +1 -0
- package/dist/form/selectors.d.ts +16 -0
- package/dist/form/selectors.d.ts.map +1 -0
- package/dist/form/selectors.js +27 -0
- package/dist/form/selectors.js.map +1 -0
- package/dist/form/store.d.ts +19 -0
- package/dist/form/store.d.ts.map +1 -0
- package/dist/form/store.js +29 -0
- package/dist/form/store.js.map +1 -0
- package/dist/index.d.ts +17 -651
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -536
- package/dist/list/list.d.ts +68 -0
- package/dist/list/list.d.ts.map +1 -0
- package/dist/list/list.js +191 -0
- package/dist/list/list.js.map +1 -0
- package/dist/list/router.d.ts +26 -0
- package/dist/list/router.d.ts.map +1 -0
- package/dist/list/router.js +54 -0
- package/dist/list/router.js.map +1 -0
- package/dist/plugins.d.ts +73 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +54 -0
- package/dist/plugins.js.map +1 -0
- package/dist/react/provider.d.ts +38 -0
- package/dist/react/provider.d.ts.map +1 -0
- package/dist/react/provider.js +63 -0
- package/dist/react/provider.js.map +1 -0
- package/dist/react/useForm.d.ts +26 -0
- package/dist/react/useForm.d.ts.map +1 -0
- package/dist/react/useForm.js +115 -0
- package/dist/react/useForm.js.map +1 -0
- package/dist/react/useList.d.ts +11 -0
- package/dist/react/useList.d.ts.map +1 -0
- package/dist/react/useList.js +47 -0
- package/dist/react/useList.js.map +1 -0
- package/dist/values.d.ts +12 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +44 -0
- package/dist/values.js.map +1 -0
- package/package.json +19 -81
- package/dist/contexts.d.ts +0 -638
- package/dist/contexts.js +0 -1754
- package/dist/hooks.d.ts +0 -492
- package/dist/hooks.js +0 -2146
- package/dist/utils.d.ts +0 -322
- package/dist/utils.js +0 -530
package/dist/utils.d.ts
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
export { kebabCase as dashCase, pascalCase, snakeCase } from 'change-case';
|
|
2
|
-
import { ElementType, ComponentProps, ReactNode, ReactElement, ForwardedRef } from 'react';
|
|
3
|
-
import { FormattedMessage, MessageDescriptor } from 'react-intl';
|
|
4
|
-
|
|
5
|
-
interface CheckClickableOptions {
|
|
6
|
-
maxParentDistance?: number;
|
|
7
|
-
tags?: string[];
|
|
8
|
-
}
|
|
9
|
-
interface ElementLike {
|
|
10
|
-
tagName?: string | null;
|
|
11
|
-
parentNode?: ElementLike | null;
|
|
12
|
-
dataset?: Record<string, unknown>;
|
|
13
|
-
}
|
|
14
|
-
declare function checkClickable(el: ElementLike | null, options?: CheckClickableOptions, parentDistance?: number): boolean;
|
|
15
|
-
|
|
16
|
-
declare function convertStyleToString(style: Record<string, unknown> | null): string;
|
|
17
|
-
|
|
18
|
-
declare function createNullableOnChange<T = unknown>(onChange?: ((value: T | null) => void) | null): (newValue: T) => void;
|
|
19
|
-
|
|
20
|
-
interface EventsManager {
|
|
21
|
-
subscribe: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
22
|
-
unsubscribe: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
23
|
-
}
|
|
24
|
-
declare function createUseEvent(eventsManager: EventsManager | null): (event: string, callback: (...args: unknown[]) => void, enabled?: boolean) => void;
|
|
25
|
-
|
|
26
|
-
/*! clipboard-copy. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
27
|
-
declare function copyToClipboard(text: string): Promise<void>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Core UI Types
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Internationalization message definition
|
|
35
|
-
*/
|
|
36
|
-
type Message = MessageDescriptor;
|
|
37
|
-
/**
|
|
38
|
-
* Values that can be interpolated in an internationalization message
|
|
39
|
-
* (the `values` prop of FormattedMessage)
|
|
40
|
-
*/
|
|
41
|
-
type MessageValues = NonNullable<ComponentProps<typeof FormattedMessage>['values']>;
|
|
42
|
-
type MessageValue = MessageValues[string];
|
|
43
|
-
/**
|
|
44
|
-
* Label can be either a message object or any React node
|
|
45
|
-
*/
|
|
46
|
-
type Label = Message | ReactNode;
|
|
47
|
-
/**
|
|
48
|
-
* Map of components, can be nested by namespace (ex: { fields: { text: TextField } })
|
|
49
|
-
*/
|
|
50
|
-
interface ComponentsMap {
|
|
51
|
-
[name: string]: ElementType | ComponentsMap;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Form control size
|
|
55
|
-
*/
|
|
56
|
-
type ControlSize = 'lg' | 'sm' | null;
|
|
57
|
-
/**
|
|
58
|
-
* Generic item (base interface for data items)
|
|
59
|
-
*/
|
|
60
|
-
interface Item {
|
|
61
|
-
id: string;
|
|
62
|
-
[key: string]: unknown;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Generic definition
|
|
66
|
-
*/
|
|
67
|
-
interface Definition {
|
|
68
|
-
id: string;
|
|
69
|
-
component?: string | ElementType;
|
|
70
|
-
[key: string]: unknown;
|
|
71
|
-
}
|
|
72
|
-
interface RouteDefinition {
|
|
73
|
-
path?: string;
|
|
74
|
-
route?: string;
|
|
75
|
-
component: string | ElementType;
|
|
76
|
-
[key: string]: unknown;
|
|
77
|
-
}
|
|
78
|
-
interface PageDefinition {
|
|
79
|
-
component: string | ElementType;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Form Types
|
|
84
|
-
* TypeScript interfaces for form-related components
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Select option (more flexible than FieldOption)
|
|
89
|
-
*/
|
|
90
|
-
type SelectOption = string | number | {
|
|
91
|
-
value?: unknown;
|
|
92
|
-
label?: Label | string;
|
|
93
|
-
} | Record<string, unknown>;
|
|
94
|
-
/**
|
|
95
|
-
* Field definition
|
|
96
|
-
*/
|
|
97
|
-
interface Field {
|
|
98
|
-
name?: string;
|
|
99
|
-
type?: string;
|
|
100
|
-
label?: Label;
|
|
101
|
-
component?: string;
|
|
102
|
-
size?: ControlSize;
|
|
103
|
-
[key: string]: unknown;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Form definition
|
|
107
|
-
*/
|
|
108
|
-
interface Form {
|
|
109
|
-
title?: ReactNode;
|
|
110
|
-
fields?: Field[];
|
|
111
|
-
method?: string | null;
|
|
112
|
-
action?: string | null;
|
|
113
|
-
submitButtonLabel?: Label | null;
|
|
114
|
-
[key: string]: unknown;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Resource Types
|
|
119
|
-
* TypeScript interfaces for resources, items, users, media, and other entities
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Table column definition
|
|
124
|
-
*/
|
|
125
|
-
type TableColumn = string | Column;
|
|
126
|
-
interface Column extends Record<string, unknown> {
|
|
127
|
-
id?: string | null;
|
|
128
|
-
name?: string | null;
|
|
129
|
-
label?: unknown;
|
|
130
|
-
path?: string;
|
|
131
|
-
valueKey?: string;
|
|
132
|
-
component?: string | ElementType | null;
|
|
133
|
-
field?: Field | string | null;
|
|
134
|
-
actions?: ActionDefinition[] | null;
|
|
135
|
-
}
|
|
136
|
-
interface Action {
|
|
137
|
-
id?: string;
|
|
138
|
-
component?: string;
|
|
139
|
-
label?: string | null;
|
|
140
|
-
icon?: string | null;
|
|
141
|
-
href?: string | null;
|
|
142
|
-
external?: boolean;
|
|
143
|
-
theme?: string;
|
|
144
|
-
target?: string;
|
|
145
|
-
onClick?: (() => void) | null;
|
|
146
|
-
endpoint?: string | null;
|
|
147
|
-
withoutConfirmation?: boolean;
|
|
148
|
-
[key: string]: unknown;
|
|
149
|
-
}
|
|
150
|
-
type ActionDefinition = string | Action;
|
|
151
|
-
interface ResourceIntlValues {
|
|
152
|
-
a_singular?: string;
|
|
153
|
-
a_plural?: string;
|
|
154
|
-
[key: string]: MessageValue;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Internationalization configuration
|
|
158
|
-
*/
|
|
159
|
-
interface ResourceIntl {
|
|
160
|
-
messages?: Record<string, string>;
|
|
161
|
-
values?: ResourceIntlValues;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Resource definition
|
|
165
|
-
*/
|
|
166
|
-
interface ResourceIndex {
|
|
167
|
-
filters?: Filter[];
|
|
168
|
-
columns?: TableColumn[];
|
|
169
|
-
actions?: ActionDefinition[];
|
|
170
|
-
fields?: Field[];
|
|
171
|
-
[key: string]: unknown;
|
|
172
|
-
}
|
|
173
|
-
interface ResourcePages {
|
|
174
|
-
index?: PageDefinition;
|
|
175
|
-
show?: PageDefinition;
|
|
176
|
-
create?: PageDefinition;
|
|
177
|
-
edit?: PageDefinition;
|
|
178
|
-
delete?: PageDefinition;
|
|
179
|
-
duplicate?: PageDefinition;
|
|
180
|
-
[key: string]: PageDefinition | undefined;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Form definition of a resource (the id is optional, the form is identified by its key)
|
|
184
|
-
*/
|
|
185
|
-
interface ResourceForm extends Form {
|
|
186
|
-
id?: string;
|
|
187
|
-
component?: string | ElementType;
|
|
188
|
-
}
|
|
189
|
-
interface ResourceForms {
|
|
190
|
-
default?: ResourceForm | null;
|
|
191
|
-
create?: ResourceForm | null;
|
|
192
|
-
edit?: ResourceForm | null;
|
|
193
|
-
delete?: ResourceForm | null;
|
|
194
|
-
modal?: ResourceForm | null;
|
|
195
|
-
[key: string]: ResourceForm | null | undefined;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Resource type (sub-type of a resource, ex: page types)
|
|
199
|
-
*/
|
|
200
|
-
interface ResourceType {
|
|
201
|
-
id?: string;
|
|
202
|
-
name?: string;
|
|
203
|
-
fields?: Field[];
|
|
204
|
-
settings?: {
|
|
205
|
-
canCreate?: boolean;
|
|
206
|
-
[key: string]: unknown;
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
interface Resource {
|
|
210
|
-
id: string;
|
|
211
|
-
name: string;
|
|
212
|
-
intl?: ResourceIntl;
|
|
213
|
-
fields?: Field[];
|
|
214
|
-
index?: ResourceIndex;
|
|
215
|
-
forms?: ResourceForms;
|
|
216
|
-
settings?: Record<string, unknown>;
|
|
217
|
-
extraRoutes?: RouteDefinition[];
|
|
218
|
-
pages?: ResourcePages;
|
|
219
|
-
types?: ResourceType[];
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Filter definition
|
|
223
|
-
*/
|
|
224
|
-
interface Filter {
|
|
225
|
-
id?: string;
|
|
226
|
-
component?: string;
|
|
227
|
-
[key: string]: unknown;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
declare function flattenComponents(components: ComponentsMap | null, prefix?: string | null): Record<string, ElementType> | null;
|
|
231
|
-
|
|
232
|
-
declare function formatDuration(timeInSeconds: number | string): string;
|
|
233
|
-
|
|
234
|
-
declare function getColumnsWithFields(resource: Resource, columns: TableColumn[] | null): Column[];
|
|
235
|
-
|
|
236
|
-
interface ComponentResult {
|
|
237
|
-
name: string | ElementType | null;
|
|
238
|
-
props: Record<string, unknown> | null;
|
|
239
|
-
}
|
|
240
|
-
declare function getComponent(component: string | {
|
|
241
|
-
component: string | ElementType;
|
|
242
|
-
[key: string]: unknown;
|
|
243
|
-
}): ComponentResult;
|
|
244
|
-
|
|
245
|
-
declare function getComponentFromName(name?: string | ElementType | null, components?: Record<string, ElementType> | null, defaultComponent?: ElementType | string | null): ElementType | null;
|
|
246
|
-
|
|
247
|
-
declare function getDefinitionFromId<T extends Definition = Definition>(id?: string | null, items?: T[] | null, defaultObject?: T | null): T | null;
|
|
248
|
-
|
|
249
|
-
interface ComponentWithName {
|
|
250
|
-
displayName?: string | null;
|
|
251
|
-
name?: string | null;
|
|
252
|
-
}
|
|
253
|
-
declare function getDisplayName({ displayName, name }: ComponentWithName): string;
|
|
254
|
-
|
|
255
|
-
interface FieldWithSubFields$1 extends Field {
|
|
256
|
-
fields?: FieldWithSubFields$1[];
|
|
257
|
-
}
|
|
258
|
-
declare function getFieldByName(fields: FieldWithSubFields$1[], name: string | null): FieldWithSubFields$1 | null;
|
|
259
|
-
|
|
260
|
-
interface FieldDefinition {
|
|
261
|
-
fields?: Field[] | null;
|
|
262
|
-
settings?: Field[] | null;
|
|
263
|
-
itemsField?: Field | null;
|
|
264
|
-
}
|
|
265
|
-
interface FieldManager {
|
|
266
|
-
getDefinition: (type: string) => FieldDefinition;
|
|
267
|
-
}
|
|
268
|
-
interface FieldWithSubFields extends Field {
|
|
269
|
-
type?: string | null;
|
|
270
|
-
fields?: Field[] | null;
|
|
271
|
-
field?: Field | null;
|
|
272
|
-
settings?: Field[] | null;
|
|
273
|
-
itemsField?: Field | null;
|
|
274
|
-
listItems?: boolean;
|
|
275
|
-
}
|
|
276
|
-
declare function getFieldFromPath(path: string | string[], fields: Field[], fieldManager: FieldManager): FieldWithSubFields | null;
|
|
277
|
-
|
|
278
|
-
declare function getFileName(url?: string | null): string | null;
|
|
279
|
-
|
|
280
|
-
declare function getPathValue(it: unknown, path: string | string[]): unknown;
|
|
281
|
-
|
|
282
|
-
interface FormattedOption {
|
|
283
|
-
value: unknown;
|
|
284
|
-
label: string | ReactElement;
|
|
285
|
-
}
|
|
286
|
-
declare function getSelectOptions(options: SelectOption[]): FormattedOption[];
|
|
287
|
-
|
|
288
|
-
declare function isMessage(message: unknown): message is Message;
|
|
289
|
-
|
|
290
|
-
declare function loadPackage<T = unknown>(name: string, loader: () => Promise<T>): Promise<T>;
|
|
291
|
-
|
|
292
|
-
declare function mergeRefs<T>(...refs: Array<ForwardedRef<T> | null | undefined>): (value: T | null) => void;
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Parse a date-only value as a local date, ignoring its timezone.
|
|
296
|
-
*
|
|
297
|
-
* A date stored at midnight represents a calendar day, not an instant: converting it to the
|
|
298
|
-
* browser timezone would show the previous day west of the server timezone (ex: a date saved as
|
|
299
|
-
* 2026-10-01 00:00 UTC is 2026-09-30 20:00 in Montreal). Returns null when the value has a time,
|
|
300
|
-
* so the caller can parse it as an instant.
|
|
301
|
-
*/
|
|
302
|
-
declare function parseDateOnly(value: string | null | undefined): Date | null;
|
|
303
|
-
|
|
304
|
-
declare function toggleSelectedItem(items: Item[] | null, item: Item, { multiple: multipleSelection }?: {
|
|
305
|
-
multiple?: boolean;
|
|
306
|
-
}): Item[] | null;
|
|
307
|
-
declare function selectItems(items: Item[] | null, itemsToSelect: Item[]): Item[] | null;
|
|
308
|
-
declare function unselectItems(items: Item[] | null, itemsToUnselect: Item[]): Item[] | null;
|
|
309
|
-
|
|
310
|
-
type Value = Record<string, unknown> | unknown[] | null;
|
|
311
|
-
declare function setValue(value: Value, keyParts: string[], fieldValue: unknown): Value;
|
|
312
|
-
|
|
313
|
-
declare function slug(str: string, separator?: string | null): string;
|
|
314
|
-
|
|
315
|
-
interface FieldWithValidation extends Field {
|
|
316
|
-
type?: string;
|
|
317
|
-
fields?: FieldWithValidation[];
|
|
318
|
-
required?: boolean;
|
|
319
|
-
}
|
|
320
|
-
declare function validateFields(fields: FieldWithValidation[], value: Record<string, unknown> | null): boolean;
|
|
321
|
-
|
|
322
|
-
export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, mergeRefs, parseDateOnly, selectItems, setValue as setFieldValue, slug, toggleSelectedItem, unselectItems, validateFields };
|