@panneau/core 4.0.11 → 4.0.15
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/contexts.d.ts +450 -0
- package/{es → dist}/contexts.js +170 -170
- package/dist/hooks.d.ts +362 -0
- package/{es → dist}/hooks.js +60 -60
- package/dist/index.d.ts +502 -0
- package/{es → dist}/index.js +7 -258
- package/dist/utils.d.ts +207 -0
- package/{es → dist}/utils.js +56 -57
- package/package.json +23 -23
- package/es/types/core.d.ts +0 -133
- package/es/types/form.d.ts +0 -58
- package/es/types/index.d.ts +0 -20
- package/es/types/panneau.d.ts +0 -50
- package/es/types/resource.d.ts +0 -112
- package/lib/contexts.js +0 -1432
- package/lib/hooks.js +0 -1168
- package/lib/index.js +0 -1019
- package/lib/utils.js +0 -789
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { ReactNode, SubmitEvent, RefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
interface UseAnimationFrameOptions {
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare function useAnimationFrame(onFrame: (progress: number) => void, { disabled }?: UseAnimationFrameOptions): void;
|
|
8
|
+
|
|
9
|
+
interface UseFormattedDateOptions {
|
|
10
|
+
format?: Intl.DateTimeFormatOptions | null;
|
|
11
|
+
showToday?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface UseFormattedTimeOptions {
|
|
14
|
+
format?: Intl.DateTimeFormatOptions | null;
|
|
15
|
+
showNow?: boolean;
|
|
16
|
+
timeGap?: number;
|
|
17
|
+
}
|
|
18
|
+
declare function useFormattedDate({ format, showToday, }?: UseFormattedDateOptions): (date: string | Date | Dayjs) => string;
|
|
19
|
+
declare function useFormattedTime({ format, showNow, timeGap, }?: UseFormattedTimeOptions): (date: string | Date | Dayjs) => string;
|
|
20
|
+
|
|
21
|
+
declare const useDocumentEvent: (event: string, callback: (...args: unknown[]) => void, enabled?: boolean) => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Form Types
|
|
25
|
+
* TypeScript interfaces for form-related components
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Field definition
|
|
30
|
+
*/
|
|
31
|
+
interface Field$1 {
|
|
32
|
+
name?: string;
|
|
33
|
+
type?: string;
|
|
34
|
+
component?: string;
|
|
35
|
+
label?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resource Types
|
|
40
|
+
* TypeScript interfaces for resources, items, users, media, and other entities
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
interface ResourceIntlValues {
|
|
44
|
+
a_singular?: string;
|
|
45
|
+
a_plural?: string;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Internationalization configuration
|
|
50
|
+
*/
|
|
51
|
+
interface ResourceIntl {
|
|
52
|
+
messages?: Record<string, string>;
|
|
53
|
+
values?: ResourceIntlValues;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resource definition
|
|
57
|
+
*/
|
|
58
|
+
interface Resource {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
intl?: ResourceIntl;
|
|
62
|
+
fields?: Field$1[];
|
|
63
|
+
forms?: Record<string, unknown>;
|
|
64
|
+
shows_in_navbar?: boolean;
|
|
65
|
+
settings?: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type FieldInput = string | Field$1;
|
|
69
|
+
interface FieldErrors {
|
|
70
|
+
[key: string]: string[] | FieldErrors;
|
|
71
|
+
}
|
|
72
|
+
interface FieldValue {
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
interface ProcessedField extends Field$1 {
|
|
76
|
+
name: string | null;
|
|
77
|
+
component: string | null;
|
|
78
|
+
value: unknown;
|
|
79
|
+
errors: string[] | null;
|
|
80
|
+
onChange: (fieldValue: unknown) => void;
|
|
81
|
+
fields?: ProcessedField[] | null;
|
|
82
|
+
}
|
|
83
|
+
interface RequestState {
|
|
84
|
+
success: boolean;
|
|
85
|
+
loading: boolean;
|
|
86
|
+
error: boolean;
|
|
87
|
+
}
|
|
88
|
+
interface UseFormOptions {
|
|
89
|
+
fields?: FieldInput[];
|
|
90
|
+
action?: string | null;
|
|
91
|
+
postForm?: ((action: string, data: Record<string, unknown>) => Promise<unknown>) | null;
|
|
92
|
+
initialErrors?: FieldErrors | null;
|
|
93
|
+
errors?: FieldErrors | null;
|
|
94
|
+
setErrors?: ((errors: FieldErrors | null) => void) | null;
|
|
95
|
+
initialGeneralError?: string | null;
|
|
96
|
+
generalError?: string | null;
|
|
97
|
+
setGeneralError?: ((error: string | null) => void) | null;
|
|
98
|
+
initialValue?: FieldValue | null;
|
|
99
|
+
value?: FieldValue | null;
|
|
100
|
+
setValue?: ((value: FieldValue) => void) | null;
|
|
101
|
+
withoutDefault?: boolean;
|
|
102
|
+
withoutPropagation?: boolean;
|
|
103
|
+
onComplete?: ((response: unknown) => void) | null;
|
|
104
|
+
onError?: ((error: Error) => void) | null;
|
|
105
|
+
locales?: string[];
|
|
106
|
+
}
|
|
107
|
+
interface UseFormReturn extends RequestState {
|
|
108
|
+
value: FieldValue | null;
|
|
109
|
+
setValue: (value: FieldValue) => void;
|
|
110
|
+
csrfToken: string | null;
|
|
111
|
+
submit: (submitValue?: FieldValue | null) => void;
|
|
112
|
+
onSubmit: (e: SubmitEvent) => void;
|
|
113
|
+
status: 'loading' | 'success' | 'error' | null;
|
|
114
|
+
response: unknown;
|
|
115
|
+
fields: ProcessedField[];
|
|
116
|
+
errors: FieldErrors | null;
|
|
117
|
+
generalError: string | null;
|
|
118
|
+
}
|
|
119
|
+
declare function useForm(opts?: UseFormOptions): UseFormReturn;
|
|
120
|
+
|
|
121
|
+
interface UseIsVisibleOptions {
|
|
122
|
+
rootMargin?: string;
|
|
123
|
+
threshold?: number;
|
|
124
|
+
persist?: boolean;
|
|
125
|
+
}
|
|
126
|
+
interface UseIsVisibleResult {
|
|
127
|
+
ref: RefObject<HTMLElement>;
|
|
128
|
+
visible: boolean;
|
|
129
|
+
}
|
|
130
|
+
declare function useIsVisible({ rootMargin, threshold, persist, }?: UseIsVisibleOptions): UseIsVisibleResult;
|
|
131
|
+
|
|
132
|
+
declare const KEYCODES: {
|
|
133
|
+
ARROW_LEFT: number;
|
|
134
|
+
ARROW_UP: number;
|
|
135
|
+
ARROW_RIGHT: number;
|
|
136
|
+
ARROW_DOWN: number;
|
|
137
|
+
ESCAPE: number;
|
|
138
|
+
SPACE: number;
|
|
139
|
+
};
|
|
140
|
+
interface UseKeyboardKeysOptions {
|
|
141
|
+
eventName?: string;
|
|
142
|
+
}
|
|
143
|
+
declare function useKeyboardKeys(keys?: Record<number, (e: KeyboardEvent) => void>, { eventName }?: UseKeyboardKeysOptions): void;
|
|
144
|
+
|
|
145
|
+
interface FontConfig {
|
|
146
|
+
type?: 'google' | 'custom' | 'system';
|
|
147
|
+
name: string;
|
|
148
|
+
}
|
|
149
|
+
declare function useLoadedFonts(fonts: (string | FontConfig)[]): {
|
|
150
|
+
loaded: boolean;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
interface UseMediaApiOptions {
|
|
154
|
+
url?: string | null;
|
|
155
|
+
initialMuted?: boolean;
|
|
156
|
+
onTimeUpdate?: ((time: number) => void) | null;
|
|
157
|
+
onProgressStep?: ((step: number) => void) | null;
|
|
158
|
+
onDurationChanged?: ((duration: number) => void) | null;
|
|
159
|
+
onVolumeChanged?: ((muted: boolean, volume: number) => void) | null;
|
|
160
|
+
onPlay?: ((opts: {
|
|
161
|
+
initial: boolean;
|
|
162
|
+
}) => void) | null;
|
|
163
|
+
onPause?: ((opts: {
|
|
164
|
+
midway: boolean;
|
|
165
|
+
}) => void) | null;
|
|
166
|
+
onEnded?: (() => void) | null;
|
|
167
|
+
onSeeked?: ((time: number) => void) | null;
|
|
168
|
+
onLoadStart?: (() => void) | null;
|
|
169
|
+
onCanPlayThough?: (() => void) | null;
|
|
170
|
+
}
|
|
171
|
+
interface UseMediaApiReturn {
|
|
172
|
+
ref: RefObject<HTMLMediaElement>;
|
|
173
|
+
play: () => void;
|
|
174
|
+
pause: () => void;
|
|
175
|
+
togglePlay: () => void;
|
|
176
|
+
stop: () => void;
|
|
177
|
+
seek: (time: number) => void;
|
|
178
|
+
mute: () => void;
|
|
179
|
+
unMute: () => void;
|
|
180
|
+
toggleMute: () => void;
|
|
181
|
+
muted: boolean;
|
|
182
|
+
currentTime: number | null;
|
|
183
|
+
duration: number | null;
|
|
184
|
+
playing: boolean;
|
|
185
|
+
paused: boolean;
|
|
186
|
+
ready: boolean;
|
|
187
|
+
}
|
|
188
|
+
declare function useMediaApi({ url, initialMuted, onTimeUpdate, onProgressStep, onDurationChanged, onVolumeChanged, onPlay, onPause, onEnded, onSeeked, onLoadStart, onCanPlayThough, }?: UseMediaApiOptions): UseMediaApiReturn;
|
|
189
|
+
|
|
190
|
+
interface Manager {
|
|
191
|
+
getDefinition: (type: string) => Record<string, unknown> | null;
|
|
192
|
+
}
|
|
193
|
+
interface MediasParserOptions {
|
|
194
|
+
fieldsManager: Manager;
|
|
195
|
+
screensManager: Manager;
|
|
196
|
+
}
|
|
197
|
+
interface Media$1 {
|
|
198
|
+
id?: string | null;
|
|
199
|
+
[key: string]: unknown;
|
|
200
|
+
}
|
|
201
|
+
interface Field {
|
|
202
|
+
id?: string | null;
|
|
203
|
+
name?: string | null;
|
|
204
|
+
type?: string | null;
|
|
205
|
+
media?: boolean;
|
|
206
|
+
fields?: Field[];
|
|
207
|
+
itemsField?: Field | null;
|
|
208
|
+
settings?: Field[];
|
|
209
|
+
[key: string]: unknown;
|
|
210
|
+
}
|
|
211
|
+
interface Screen$1 {
|
|
212
|
+
type: string;
|
|
213
|
+
[key: string]: unknown;
|
|
214
|
+
}
|
|
215
|
+
interface Story {
|
|
216
|
+
theme?: Story | null;
|
|
217
|
+
components?: Screen$1[];
|
|
218
|
+
medias?: Record<string, Media$1> | null;
|
|
219
|
+
[key: string]: unknown;
|
|
220
|
+
}
|
|
221
|
+
declare class MediasParser {
|
|
222
|
+
fieldsManager: Manager;
|
|
223
|
+
screensManager: Manager;
|
|
224
|
+
constructor({ fieldsManager, screensManager }: MediasParserOptions);
|
|
225
|
+
toPath(story: Story | null): Story | null;
|
|
226
|
+
fromPath(story: Story | null, defaultMedias?: Record<string, Media$1> | null): Story | null;
|
|
227
|
+
getMediaFieldsPattern(fields: Field[], namePrefix?: string | null): RegExp[];
|
|
228
|
+
static fieldIsMedia({ media }: Field): boolean;
|
|
229
|
+
static fieldIsFontFamily({ id }: Field): boolean;
|
|
230
|
+
static replacePathsWithMedias(data: unknown, medias: Record<string, Media$1>, patterns: RegExp[], keyPrefix?: string | null): unknown;
|
|
231
|
+
static getMediaPath({ id }: Media$1): string | null;
|
|
232
|
+
static replaceMediasWithPaths(data: unknown, patterns: RegExp[], medias?: Record<string, Media$1> | null, keyPrefix?: string | null): {
|
|
233
|
+
data: unknown;
|
|
234
|
+
medias: Record<string, Media$1> | null;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
interface UseMediasParserReturn {
|
|
239
|
+
toPath: (story: unknown) => string;
|
|
240
|
+
fromPath: (story: unknown) => unknown;
|
|
241
|
+
parser: MediasParser;
|
|
242
|
+
}
|
|
243
|
+
declare function useMediasParser(): UseMediasParserReturn;
|
|
244
|
+
|
|
245
|
+
type ObserverConstructor<T> = (new (callback: (entries: T[]) => void, options?: Record<string, unknown>) => {
|
|
246
|
+
observe: (element: Element) => void;
|
|
247
|
+
unobserve?: (element: Element) => void;
|
|
248
|
+
disconnect: () => void;
|
|
249
|
+
}) | null;
|
|
250
|
+
interface ObserverWrapper<T> {
|
|
251
|
+
subscribe: (element: Element, callback: (entry: T) => void) => void;
|
|
252
|
+
unsubscribe: (element: Element, callback?: ((entry: T) => void) | null) => void;
|
|
253
|
+
observer: ReturnType<NonNullable<ObserverConstructor<T>>>;
|
|
254
|
+
}
|
|
255
|
+
interface ObserverOptions {
|
|
256
|
+
root?: Element | null;
|
|
257
|
+
rootMargin?: string | null;
|
|
258
|
+
threshold?: number | number[] | null;
|
|
259
|
+
disabled?: boolean;
|
|
260
|
+
}
|
|
261
|
+
declare function getObserver<T>(Observer: ObserverConstructor<T>, options?: ObserverOptions): ObserverWrapper<T>;
|
|
262
|
+
interface UseObserverReturn<T> {
|
|
263
|
+
ref: RefObject<Element>;
|
|
264
|
+
entry: T;
|
|
265
|
+
}
|
|
266
|
+
declare function useObserver<T>(Observer: ObserverConstructor<T>, opts?: ObserverOptions, initialEntry?: T): UseObserverReturn<T>;
|
|
267
|
+
interface IntersectionObserverEntry {
|
|
268
|
+
target: Element | null;
|
|
269
|
+
time: number | null;
|
|
270
|
+
isVisible: boolean;
|
|
271
|
+
isIntersecting: boolean;
|
|
272
|
+
intersectionRatio: number;
|
|
273
|
+
intersectionRect: DOMRectReadOnly | null;
|
|
274
|
+
boundingClientRect: DOMRectReadOnly | null;
|
|
275
|
+
rootBounds: DOMRectReadOnly | null;
|
|
276
|
+
}
|
|
277
|
+
interface UseIntersectionObserverOptions {
|
|
278
|
+
root?: Element | null;
|
|
279
|
+
rootMargin?: string;
|
|
280
|
+
threshold?: number | number[];
|
|
281
|
+
disabled?: boolean;
|
|
282
|
+
}
|
|
283
|
+
declare function useIntersectionObserver({ root, rootMargin, threshold, disabled, }?: UseIntersectionObserverOptions): UseObserverReturn<IntersectionObserverEntry>;
|
|
284
|
+
/**
|
|
285
|
+
* Resize Observer
|
|
286
|
+
*/
|
|
287
|
+
interface ResizeObserverEntry {
|
|
288
|
+
target: Element | null;
|
|
289
|
+
contentRect: DOMRectReadOnly | null;
|
|
290
|
+
contentBoxSize: ReadonlyArray<ResizeObserverSize> | null;
|
|
291
|
+
borderBoxSize: ReadonlyArray<ResizeObserverSize> | null;
|
|
292
|
+
}
|
|
293
|
+
interface UseResizeObserverOptions {
|
|
294
|
+
disabled?: boolean;
|
|
295
|
+
}
|
|
296
|
+
declare function useResizeObserver({ disabled, }?: UseResizeObserverOptions): UseObserverReturn<ResizeObserverEntry>;
|
|
297
|
+
|
|
298
|
+
interface ResourceType {
|
|
299
|
+
id?: string | null;
|
|
300
|
+
name?: string | null;
|
|
301
|
+
}
|
|
302
|
+
interface ResourceWithTypes extends Resource {
|
|
303
|
+
types?: ResourceType[];
|
|
304
|
+
settings?: {
|
|
305
|
+
hideTypeNames?: boolean;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
declare function useResourceTypeName(resource: ResourceWithTypes | null, type?: string | null): string | null;
|
|
309
|
+
|
|
310
|
+
type ResourceUrlGenerator = (routeResourceId: string | Resource, routeName?: string | Record<string, unknown> | null, params?: Record<string, unknown> | null) => string | null;
|
|
311
|
+
declare function useResourceUrlGenerator(resourceId?: string | Resource | null): ResourceUrlGenerator;
|
|
312
|
+
|
|
313
|
+
interface QueryParams {
|
|
314
|
+
page?: number;
|
|
315
|
+
count?: number;
|
|
316
|
+
[key: string]: unknown;
|
|
317
|
+
}
|
|
318
|
+
interface UseQueryReturn {
|
|
319
|
+
query: QueryParams | null;
|
|
320
|
+
onPageChange: (newPage: number) => void;
|
|
321
|
+
onQueryChange: (newQuery: QueryParams | null) => void;
|
|
322
|
+
onQueryReset: () => void;
|
|
323
|
+
}
|
|
324
|
+
declare function useQuery(initialBaseQuery?: QueryParams | null, paginated?: boolean): UseQueryReturn;
|
|
325
|
+
|
|
326
|
+
interface Screen {
|
|
327
|
+
name: string;
|
|
328
|
+
mediaQuery?: string | null;
|
|
329
|
+
}
|
|
330
|
+
interface Media {
|
|
331
|
+
type: string;
|
|
332
|
+
width: string;
|
|
333
|
+
height: string;
|
|
334
|
+
}
|
|
335
|
+
interface UseScreenSizeOptions {
|
|
336
|
+
width?: number | null;
|
|
337
|
+
height?: number | null;
|
|
338
|
+
landscape?: boolean;
|
|
339
|
+
screens?: Screen[];
|
|
340
|
+
mediaType?: string;
|
|
341
|
+
media?: Media | null;
|
|
342
|
+
}
|
|
343
|
+
interface ScreenSize {
|
|
344
|
+
screen: string | null;
|
|
345
|
+
screens: string[];
|
|
346
|
+
width: number | null;
|
|
347
|
+
height: number | null;
|
|
348
|
+
landscape: boolean;
|
|
349
|
+
}
|
|
350
|
+
interface UseScreenSizeFromElementOptions extends Omit<UseScreenSizeOptions, 'landscape'> {
|
|
351
|
+
withoutMaxSize?: boolean;
|
|
352
|
+
}
|
|
353
|
+
interface UseScreenSizeFromElementReturn {
|
|
354
|
+
ref: RefObject<Element>;
|
|
355
|
+
screenSize: ScreenSize;
|
|
356
|
+
}
|
|
357
|
+
declare function useScreenSizeFromElement({ width, height, ...opts }?: UseScreenSizeFromElementOptions): UseScreenSizeFromElementReturn;
|
|
358
|
+
declare function useScreenSizeFromWindow(opts?: UseScreenSizeOptions): ScreenSize;
|
|
359
|
+
|
|
360
|
+
declare const useWindowEvent: (event: string, callback: (...args: unknown[]) => void, enabled?: boolean) => void;
|
|
361
|
+
|
|
362
|
+
export { KEYCODES, getObserver, useAnimationFrame, useDocumentEvent, useForm, useFormattedDate, useFormattedTime, useIntersectionObserver, useIsVisible, useKeyboardKeys, useLoadedFonts, useMediaApi, useMediasParser, useObserver, useQuery, useResizeObserver, useResourceTypeName, useResourceUrlGenerator, useScreenSizeFromElement, useScreenSizeFromWindow, useWindowEvent };
|
package/{es → dist}/hooks.js
RENAMED
|
@@ -7,10 +7,10 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
|
7
7
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
8
8
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
9
9
|
import { getCsrfToken, postJSON, getCSRFHeaders } from '@folklore/fetch';
|
|
10
|
-
import get from 'lodash
|
|
11
|
-
import isArray from 'lodash
|
|
12
|
-
import isObject from 'lodash
|
|
13
|
-
import isString from 'lodash
|
|
10
|
+
import get from 'lodash/get';
|
|
11
|
+
import isArray from 'lodash/isArray';
|
|
12
|
+
import isObject from 'lodash/isObject';
|
|
13
|
+
import isString from 'lodash/isString';
|
|
14
14
|
import { useFieldsManager, usePanneauResources, useResource, useUrlGenerator } from '@panneau/core/contexts';
|
|
15
15
|
import dayjs from 'dayjs';
|
|
16
16
|
import { useIntl } from 'react-intl';
|
|
@@ -42,7 +42,7 @@ function useAnimationFrame(onFrame) {
|
|
|
42
42
|
}, [disabled]);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
function useFormattedDate() {
|
|
46
46
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
47
47
|
_ref$format = _ref.format,
|
|
48
48
|
format = _ref$format === void 0 ? null : _ref$format,
|
|
@@ -67,8 +67,8 @@ var useFormattedDate = function useFormattedDate() {
|
|
|
67
67
|
day: '2-digit'
|
|
68
68
|
}, format));
|
|
69
69
|
}, [today, showToday, format]);
|
|
70
|
-
}
|
|
71
|
-
|
|
70
|
+
}
|
|
71
|
+
function useFormattedTime() {
|
|
72
72
|
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
73
73
|
_ref2$format = _ref2.format,
|
|
74
74
|
format = _ref2$format === void 0 ? null : _ref2$format,
|
|
@@ -94,14 +94,14 @@ var useFormattedTime = function useFormattedTime() {
|
|
|
94
94
|
minute: 'numeric'
|
|
95
95
|
}, format));
|
|
96
96
|
}, [now, showNow, timeGap, format]);
|
|
97
|
-
}
|
|
97
|
+
}
|
|
98
98
|
|
|
99
99
|
var eventsManager$1 = typeof document !== 'undefined' ? new EventsManager(document) : null;
|
|
100
100
|
var useDocumentEvent = createUseEvent(eventsManager$1);
|
|
101
101
|
|
|
102
102
|
var _excluded$1 = ["value", "errors", "onChange"];
|
|
103
103
|
// prettier-ignore
|
|
104
|
-
|
|
104
|
+
function getFieldsPropsFromFields(fields, _ref) {
|
|
105
105
|
var value = _ref.value,
|
|
106
106
|
errors = _ref.errors,
|
|
107
107
|
_onChange = _ref.onChange,
|
|
@@ -143,15 +143,15 @@ var _getFieldsPropsFromFields = function getFieldsPropsFromFields(fields, _ref)
|
|
|
143
143
|
onChange: function onChange(fieldValue) {
|
|
144
144
|
return _onChange(name, fieldValue);
|
|
145
145
|
},
|
|
146
|
-
fields: fieldFields !== null && isArray(fieldFields) ?
|
|
146
|
+
fields: fieldFields !== null && isArray(fieldFields) ? getFieldsPropsFromFields(fieldFields, {
|
|
147
147
|
value: value !== null && name !== null && isObject(value[name]) ? value[name] : null,
|
|
148
148
|
errors: subfieldErrors,
|
|
149
149
|
onChange: _onChange
|
|
150
150
|
}, locales) : null
|
|
151
151
|
}, props)]);
|
|
152
152
|
}, []);
|
|
153
|
-
}
|
|
154
|
-
|
|
153
|
+
}
|
|
154
|
+
function useForm() {
|
|
155
155
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
156
156
|
var _opts$fields = opts.fields,
|
|
157
157
|
fields = _opts$fields === void 0 ? [] : _opts$fields,
|
|
@@ -242,7 +242,7 @@ var useForm = function useForm() {
|
|
|
242
242
|
setValue(_objectSpread(_objectSpread({}, value || {}), {}, _defineProperty({}, fieldName, fieldValue)));
|
|
243
243
|
}, [value, errors, requestState, setErrors, setValue].concat(_toConsumableArray(fields)));
|
|
244
244
|
var fieldsProps = useMemo(function () {
|
|
245
|
-
return
|
|
245
|
+
return getFieldsPropsFromFields(fields, {
|
|
246
246
|
value: value,
|
|
247
247
|
errors: errors,
|
|
248
248
|
onChange: onFieldChange
|
|
@@ -331,21 +331,21 @@ var useForm = function useForm() {
|
|
|
331
331
|
errors: errors,
|
|
332
332
|
generalError: generalError
|
|
333
333
|
});
|
|
334
|
-
}
|
|
334
|
+
}
|
|
335
335
|
|
|
336
|
-
|
|
336
|
+
function buildThresholdArray() {
|
|
337
337
|
return [0, 1.0];
|
|
338
|
-
}
|
|
338
|
+
}
|
|
339
339
|
var observersCache = new Map();
|
|
340
|
-
|
|
340
|
+
function getOptionsKey(_ref) {
|
|
341
341
|
var _ref$root = _ref.root,
|
|
342
342
|
root = _ref$root === void 0 ? null : _ref$root,
|
|
343
343
|
rootMargin = _ref.rootMargin,
|
|
344
344
|
_ref$threshold = _ref.threshold,
|
|
345
345
|
threshold = _ref$threshold === void 0 ? null : _ref$threshold;
|
|
346
346
|
return "root_".concat(root, "_rootMargin_").concat(rootMargin || null, "_threshold_").concat(threshold);
|
|
347
|
-
}
|
|
348
|
-
|
|
347
|
+
}
|
|
348
|
+
function createObserver(Observer) {
|
|
349
349
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
350
350
|
var subscribers = [];
|
|
351
351
|
var addSubscriber = function addSubscriber(element, callback) {
|
|
@@ -422,8 +422,8 @@ var createObserver = function createObserver(Observer) {
|
|
|
422
422
|
unsubscribe: unsubscribe,
|
|
423
423
|
observer: observer
|
|
424
424
|
};
|
|
425
|
-
}
|
|
426
|
-
|
|
425
|
+
}
|
|
426
|
+
function getObserver(Observer) {
|
|
427
427
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
428
428
|
if (Observer === null) {
|
|
429
429
|
throw new Error('Observer constructor is null');
|
|
@@ -438,8 +438,8 @@ var getObserver = function getObserver(Observer) {
|
|
|
438
438
|
observersCache.set(Observer, observers);
|
|
439
439
|
}
|
|
440
440
|
return observers[observerKey];
|
|
441
|
-
}
|
|
442
|
-
|
|
441
|
+
}
|
|
442
|
+
function useObserver(Observer) {
|
|
443
443
|
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
444
444
|
var initialEntry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
445
445
|
var _opts$root = opts.root,
|
|
@@ -491,7 +491,7 @@ var useObserver = function useObserver(Observer) {
|
|
|
491
491
|
ref: nodeRef,
|
|
492
492
|
entry: entry
|
|
493
493
|
};
|
|
494
|
-
}
|
|
494
|
+
}
|
|
495
495
|
|
|
496
496
|
/**
|
|
497
497
|
* Intersection Observer
|
|
@@ -507,7 +507,7 @@ var intersectionObserverInitialEntry = {
|
|
|
507
507
|
boundingClientRect: null,
|
|
508
508
|
rootBounds: null
|
|
509
509
|
};
|
|
510
|
-
|
|
510
|
+
function useIntersectionObserver() {
|
|
511
511
|
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
512
512
|
_ref3$root = _ref3.root,
|
|
513
513
|
root = _ref3$root === void 0 ? null : _ref3$root,
|
|
@@ -523,7 +523,7 @@ var useIntersectionObserver = function useIntersectionObserver() {
|
|
|
523
523
|
threshold: threshold,
|
|
524
524
|
disabled: disabled
|
|
525
525
|
}, intersectionObserverInitialEntry);
|
|
526
|
-
}
|
|
526
|
+
}
|
|
527
527
|
|
|
528
528
|
/**
|
|
529
529
|
* Resize Observer
|
|
@@ -535,14 +535,14 @@ var resizeObserverInitialEntry = {
|
|
|
535
535
|
contentBoxSize: null,
|
|
536
536
|
borderBoxSize: null
|
|
537
537
|
};
|
|
538
|
-
|
|
538
|
+
function useResizeObserver() {
|
|
539
539
|
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
540
540
|
_ref4$disabled = _ref4.disabled,
|
|
541
541
|
disabled = _ref4$disabled === void 0 ? false : _ref4$disabled;
|
|
542
542
|
return useObserver(typeof window !== 'undefined' ? ResizeObserver : null, {
|
|
543
543
|
disabled: disabled
|
|
544
544
|
}, resizeObserverInitialEntry);
|
|
545
|
-
}
|
|
545
|
+
}
|
|
546
546
|
|
|
547
547
|
function useIsVisible() {
|
|
548
548
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
@@ -603,30 +603,30 @@ var fontsMap = {
|
|
|
603
603
|
loading: [],
|
|
604
604
|
active: []
|
|
605
605
|
};
|
|
606
|
-
|
|
606
|
+
function isFontLoading(name) {
|
|
607
607
|
return fontsMap.loading.indexOf(name) !== -1;
|
|
608
|
-
}
|
|
609
|
-
|
|
608
|
+
}
|
|
609
|
+
function isFontActive(name) {
|
|
610
610
|
return fontsMap.active.indexOf(name) !== -1;
|
|
611
|
-
}
|
|
612
|
-
|
|
611
|
+
}
|
|
612
|
+
function addFontLoading(name) {
|
|
613
613
|
fontsMap.active = fontsMap.active.filter(function (it) {
|
|
614
614
|
return it !== name;
|
|
615
615
|
});
|
|
616
616
|
fontsMap.loading = [].concat(_toConsumableArray(fontsMap.loading), [name]);
|
|
617
|
-
}
|
|
618
|
-
|
|
617
|
+
}
|
|
618
|
+
function removeFontLoading(name) {
|
|
619
619
|
fontsMap.loading = fontsMap.loading.filter(function (it) {
|
|
620
620
|
return it !== name;
|
|
621
621
|
});
|
|
622
|
-
}
|
|
623
|
-
|
|
622
|
+
}
|
|
623
|
+
function addFontActive(name) {
|
|
624
624
|
fontsMap.loading = fontsMap.loading.filter(function (it) {
|
|
625
625
|
return it !== name;
|
|
626
626
|
});
|
|
627
627
|
fontsMap.active = [].concat(_toConsumableArray(fontsMap.active), [name]);
|
|
628
|
-
}
|
|
629
|
-
|
|
628
|
+
}
|
|
629
|
+
function useLoadedFonts(fonts) {
|
|
630
630
|
var _useState = useState(false),
|
|
631
631
|
_useState2 = _slicedToArray(_useState, 2),
|
|
632
632
|
loaded = _useState2[0],
|
|
@@ -675,10 +675,10 @@ var useLoadedFonts = function useLoadedFonts(fonts) {
|
|
|
675
675
|
return {
|
|
676
676
|
loaded: loaded
|
|
677
677
|
};
|
|
678
|
-
}
|
|
678
|
+
}
|
|
679
679
|
|
|
680
680
|
var progressSteps = [0.1, 0.25, 0.5, 0.75, 0.9];
|
|
681
|
-
|
|
681
|
+
function useMediaApi() {
|
|
682
682
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
683
683
|
_ref$url = _ref.url,
|
|
684
684
|
url = _ref$url === void 0 ? null : _ref$url,
|
|
@@ -910,9 +910,9 @@ var useMediaApi = function useMediaApi() {
|
|
|
910
910
|
paused: paused,
|
|
911
911
|
ready: ready
|
|
912
912
|
};
|
|
913
|
-
}
|
|
913
|
+
}
|
|
914
914
|
|
|
915
|
-
|
|
915
|
+
function useMediasParser() {
|
|
916
916
|
// const screensManager = useScreensManager();
|
|
917
917
|
var fieldsManager = useFieldsManager();
|
|
918
918
|
|
|
@@ -934,9 +934,9 @@ var useMediasParser = function useMediasParser() {
|
|
|
934
934
|
fromPath: fromPath,
|
|
935
935
|
parser: parser
|
|
936
936
|
};
|
|
937
|
-
}
|
|
937
|
+
}
|
|
938
938
|
|
|
939
|
-
|
|
939
|
+
function useResourceTypeName(resource) {
|
|
940
940
|
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
941
941
|
var typeName = useMemo(function () {
|
|
942
942
|
var _ref = resource || {},
|
|
@@ -962,14 +962,14 @@ var useResourceTypeName = function useResourceTypeName(resource) {
|
|
|
962
962
|
return name === resourceName ? null : name;
|
|
963
963
|
}, [type, resource]);
|
|
964
964
|
return typeName;
|
|
965
|
-
}
|
|
965
|
+
}
|
|
966
966
|
|
|
967
|
-
|
|
967
|
+
function getResource(resources, resourceId) {
|
|
968
968
|
return resourceId !== null && !isObject(resourceId) ? resources.find(function (it) {
|
|
969
969
|
return it.id === resourceId;
|
|
970
970
|
}) || null : resourceId;
|
|
971
|
-
}
|
|
972
|
-
|
|
971
|
+
}
|
|
972
|
+
function useResourceUrlGenerator() {
|
|
973
973
|
var resourceId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
974
974
|
var resources = usePanneauResources();
|
|
975
975
|
var contextResource = useResource();
|
|
@@ -989,9 +989,9 @@ var useResourceUrlGenerator = function useResourceUrlGenerator() {
|
|
|
989
989
|
})) : null;
|
|
990
990
|
return finalRoute;
|
|
991
991
|
};
|
|
992
|
-
}
|
|
992
|
+
}
|
|
993
993
|
|
|
994
|
-
|
|
994
|
+
function useQuery() {
|
|
995
995
|
var initialBaseQuery = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
996
996
|
var paginated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
997
997
|
var initialQuery = useMemo(function () {
|
|
@@ -1028,11 +1028,11 @@ var useQuery = function useQuery() {
|
|
|
1028
1028
|
onQueryChange: onQueryChange,
|
|
1029
1029
|
onQueryReset: onQueryReset
|
|
1030
1030
|
};
|
|
1031
|
-
}
|
|
1031
|
+
}
|
|
1032
1032
|
|
|
1033
1033
|
var _excluded = ["width", "height"],
|
|
1034
1034
|
_excluded2 = ["withoutMaxSize"];
|
|
1035
|
-
|
|
1035
|
+
function useScreenSize(_ref) {
|
|
1036
1036
|
var _ref$width = _ref.width,
|
|
1037
1037
|
width = _ref$width === void 0 ? null : _ref$width,
|
|
1038
1038
|
_ref$height = _ref.height,
|
|
@@ -1072,8 +1072,8 @@ var useScreenSize = function useScreenSize(_ref) {
|
|
|
1072
1072
|
height: height,
|
|
1073
1073
|
landscape: landscape
|
|
1074
1074
|
};
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1075
|
+
}
|
|
1076
|
+
function useScreenSizeFromElement() {
|
|
1077
1077
|
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1078
1078
|
_ref4$width = _ref4.width,
|
|
1079
1079
|
width = _ref4$width === void 0 ? null : _ref4$width,
|
|
@@ -1111,14 +1111,14 @@ var useScreenSizeFromElement = function useScreenSizeFromElement() {
|
|
|
1111
1111
|
ref: ref,
|
|
1112
1112
|
screenSize: screenSize
|
|
1113
1113
|
};
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1114
|
+
}
|
|
1115
|
+
function getWindowSize() {
|
|
1116
1116
|
return {
|
|
1117
1117
|
width: typeof window !== 'undefined' ? window.innerWidth : null,
|
|
1118
1118
|
height: typeof window !== 'undefined' ? window.innerHeight : null
|
|
1119
1119
|
};
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1120
|
+
}
|
|
1121
|
+
function useScreenSizeFromWindow() {
|
|
1122
1122
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1123
1123
|
var _useState = useState(getWindowSize()),
|
|
1124
1124
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -1138,7 +1138,7 @@ var useScreenSizeFromWindow = function useScreenSizeFromWindow() {
|
|
|
1138
1138
|
};
|
|
1139
1139
|
}, [setWindowSize]);
|
|
1140
1140
|
return useScreenSize(_objectSpread(_objectSpread({}, opts), windowSize));
|
|
1141
|
-
}
|
|
1141
|
+
}
|
|
1142
1142
|
|
|
1143
1143
|
var eventsManager = typeof window !== 'undefined' ? new EventsManager(window) : null;
|
|
1144
1144
|
var useWindowEvent = createUseEvent(eventsManager);
|