@micromag/core 0.3.832 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/assets/css/styles.css +31 -31
  2. package/assets/css/vendor.css +4 -3
  3. package/es/components.d.ts +628 -0
  4. package/es/components.js +947 -2301
  5. package/es/contexts.d.ts +297 -0
  6. package/es/contexts.js +154 -341
  7. package/es/hooks.d.ts +333 -0
  8. package/es/hooks.js +22 -17
  9. package/es/index.d.ts +665 -0
  10. package/es/index.js +2 -772
  11. package/es/styles.css +35 -0
  12. package/es/utils.d.ts +214 -0
  13. package/lib/components.js +955 -2309
  14. package/lib/contexts.js +153 -340
  15. package/lib/hooks.js +21 -16
  16. package/lib/index.js +0 -771
  17. package/lib/styles.css +35 -0
  18. package/package.json +39 -46
  19. package/styles/bootstrap-overrides.css +111 -0
  20. package/styles/bootstrap-patches.css +486 -0
  21. package/styles/breadcrumb.module.css +5 -0
  22. package/styles/button.module.css +82 -0
  23. package/styles/buttons.module.css +3 -0
  24. package/styles/clear.module.css +23 -0
  25. package/styles/collapsable-panel.module.css +31 -0
  26. package/styles/conversation.module.css +37 -0
  27. package/styles/dialog.module.css +13 -0
  28. package/styles/empty.module.css +22 -0
  29. package/styles/form-panel.module.css +3 -0
  30. package/styles/form.module.css +22 -0
  31. package/styles/link.module.css +9 -0
  32. package/styles/map.module.css +43 -0
  33. package/styles/media.module.css +3 -0
  34. package/styles/modal.module.css +22 -0
  35. package/styles/modals.module.css +12 -0
  36. package/styles/navbar.module.css +9 -0
  37. package/styles/pagination.module.css +3 -0
  38. package/styles/panel.module.css +3 -0
  39. package/styles/panels.module.css +3 -0
  40. package/styles/placeholder-block.module.css +29 -0
  41. package/styles/placeholder-text.module.css +17 -0
  42. package/styles/placeholders.module.css +3 -0
  43. package/styles/preview.module.css +34 -0
  44. package/styles/quiz-answer.module.css +29 -0
  45. package/styles/screen-placeholder.module.css +5 -0
  46. package/styles/screen-sizer.module.css +14 -0
  47. package/styles/screen.module.css +52 -0
  48. package/styles/screens.module.css +16 -0
  49. package/styles/share-options.module.css +27 -0
  50. package/{scss/_placeholders.scss → styles/shared.module.css} +103 -97
  51. package/styles/slideshow.module.css +28 -0
  52. package/styles/spinner.module.css +43 -0
  53. package/styles/styles.css +1 -0
  54. package/styles/survey-answer.module.css +18 -0
  55. package/styles/tabs.module.css +4 -0
  56. package/styles/theme.css +84 -0
  57. package/styles/transition.module.css +9 -0
  58. package/{scss/vendor.scss → styles/vendor.css} +16 -30
  59. package/styles/video-360.module.css +15 -0
  60. package/scss/_mixins.scss +0 -34
  61. package/scss/_theme.scss +0 -114
  62. package/scss/_variables.scss +0 -12
  63. package/scss/styles.scss +0 -1
  64. package/scss/upload.scss +0 -1
package/es/hooks.d.ts ADDED
@@ -0,0 +1,333 @@
1
+ import * as react from 'react';
2
+ import * as _use_gesture_react_dist_declarations_src_types from '@use-gesture/react/dist/declarations/src/types';
3
+ import * as _react_spring_core from '@react-spring/core';
4
+
5
+ declare function useActivityDetector({ element: providedElement, disabled, timeout: timeoutDelay }?: {
6
+ element?: any;
7
+ disabled?: boolean;
8
+ timeout?: number;
9
+ }): {
10
+ ref: react.RefObject<any>;
11
+ detected: boolean;
12
+ };
13
+
14
+ declare const useAnimationFrame: (onFrame: any, { disabled }?: {
15
+ disabled?: boolean;
16
+ }) => void;
17
+
18
+ declare const useFormattedDate: ({ format, showToday }?: {
19
+ format?: any;
20
+ showToday?: boolean;
21
+ }) => (date: any) => string;
22
+ declare const useFormattedTime: ({ format, showNow, timeGap }?: {
23
+ format?: any;
24
+ showNow?: boolean;
25
+ timeGap?: number;
26
+ }) => (date: any) => string;
27
+
28
+ declare const useDebounced: (handler: any, watchedValue: any, delay?: number) => void;
29
+
30
+ declare const useDocumentEvent: (event: any, callback: any, enabled?: boolean) => void;
31
+
32
+ declare function useDragProgress({ progress: wantedProgress, onTap, disabled, dragDisabled, computeProgress, onProgress, onPointerDown, onScroll, springParams, dragOptions, }?: {
33
+ onTap?: any;
34
+ disabled?: boolean;
35
+ dragDisabled?: boolean;
36
+ computeProgress?: any;
37
+ onProgress?: any;
38
+ onPointerDown?: any;
39
+ onScroll?: any;
40
+ springParams?: any;
41
+ dragOptions?: {
42
+ filterTaps: boolean;
43
+ };
44
+ }): {
45
+ transitioning: any;
46
+ bind: (...args: any[]) => _use_gesture_react_dist_declarations_src_types.ReactDOMAttributes;
47
+ dragging: boolean;
48
+ progress: any;
49
+ direction: number;
50
+ };
51
+
52
+ declare const useForm: ({ fields: providedFields, injectInFields, ...opts }?: {
53
+ fields?: any[];
54
+ injectInFields?: boolean;
55
+ }) => any;
56
+
57
+ declare const useFormTransition: (paths?: any[], styles?: {}) => {
58
+ direction: string;
59
+ name: {
60
+ enter: string;
61
+ enterActive: string;
62
+ leave: any;
63
+ leaveActive: string;
64
+ };
65
+ timeout: number;
66
+ };
67
+
68
+ declare const useFullscreen: (element: any) => {
69
+ toggle: () => void;
70
+ fullscreen: () => void;
71
+ unFullscreen: () => void;
72
+ active: boolean;
73
+ enabled: any;
74
+ };
75
+
76
+ declare const useIsVisible: ({ rootMargin, persist, disabled }?: {
77
+ persist?: boolean;
78
+ disabled?: boolean;
79
+ }) => {
80
+ ref: react.RefObject<any>;
81
+ visible: any;
82
+ };
83
+
84
+ declare const useLoadedFonts: (fonts: any) => {
85
+ loaded: boolean;
86
+ };
87
+
88
+ declare const useLongPress: ({ onLongPress, onLongPressStart, onLongPressEnd, onClick, shouldPreventDefault, shouldStopPropagation, preventClick, delay, }?: {
89
+ onLongPress?: any;
90
+ onLongPressStart?: any;
91
+ onLongPressEnd?: any;
92
+ onClick?: any;
93
+ shouldPreventDefault?: boolean;
94
+ shouldStopPropagation?: boolean;
95
+ preventClick?: boolean;
96
+ delay?: number;
97
+ }) => {
98
+ bind: (props?: any) => {
99
+ onMouseDown: (e: any) => void;
100
+ onTouchStart: (e: any) => void;
101
+ onMouseUp: (e: any) => void;
102
+ onMouseLeave: (e: any) => void;
103
+ onTouchEnd: (e: any) => void;
104
+ };
105
+ pressed: boolean;
106
+ triggered: boolean;
107
+ };
108
+
109
+ declare const useMediaApi: ({ url, onTimeUpdate, onProgressStep, onDurationChange, onVolumeChange, onPlay, onPause, onEnded, onSeeked, onSuspend, onLoadStart, onCanPlayThough, onCanPlay, onLoadedData, onLoadedMetadata, }?: {
110
+ url?: any;
111
+ onTimeUpdate?: any;
112
+ onProgressStep?: any;
113
+ onDurationChange?: any;
114
+ onVolumeChange?: any;
115
+ onPlay?: any;
116
+ onPause?: any;
117
+ onEnded?: any;
118
+ onSeeked?: any;
119
+ onSuspend?: any;
120
+ onLoadStart?: any;
121
+ onCanPlayThough?: any;
122
+ onCanPlay?: any;
123
+ onLoadedData?: any;
124
+ onLoadedMetadata?: any;
125
+ }) => {
126
+ ref: react.RefObject<any>;
127
+ play: () => void;
128
+ pause: () => void;
129
+ stop: () => void;
130
+ seek: (time: any) => void;
131
+ currentTime: any;
132
+ duration: any;
133
+ playing: boolean;
134
+ paused: boolean;
135
+ ready: boolean;
136
+ dataReady: boolean;
137
+ suspended: boolean;
138
+ };
139
+
140
+ declare const useMediaBuffering: (mediaElement?: any, interval?: number) => {
141
+ buffering: boolean;
142
+ };
143
+
144
+ declare const useMediaState: (mediaElement?: any, { playing: wantedPlaying, muted: wantedMuted }?: {
145
+ playing?: boolean;
146
+ muted?: boolean;
147
+ }) => {
148
+ playing: boolean;
149
+ muted: any;
150
+ buffering: boolean;
151
+ };
152
+
153
+ declare function useMediaCurrentTime(element: any, { id, disabled, updateInterval, onUpdate: customOnUpdate }?: {
154
+ id?: any;
155
+ disabled?: boolean;
156
+ updateInterval?: number;
157
+ onUpdate?: any;
158
+ }): number;
159
+
160
+ declare function useMediaDuration(element: any, { id }?: {
161
+ id?: any;
162
+ }): any;
163
+
164
+ declare function useMediaLoad(element: any, { preload, shouldLoad }?: {
165
+ preload?: string;
166
+ shouldLoad?: boolean;
167
+ }): void;
168
+
169
+ declare function useMediaProgress(media: any, { disabled, ...props }?: {
170
+ disabled?: boolean;
171
+ }): number;
172
+
173
+ declare function useMediaReady(element: any, { id }?: {
174
+ id?: any;
175
+ }): boolean;
176
+
177
+ declare function useMediaTimestampOffset(element: any, { attributeName }?: {
178
+ attributeName?: string;
179
+ }): number;
180
+
181
+ declare class MediasParser {
182
+ constructor({ fieldsManager, screensManager, fieldsPattern }: {
183
+ fieldsManager: any;
184
+ screensManager: any;
185
+ fieldsPattern?: {};
186
+ });
187
+ getParsedStoryTheme(storyId: any, theme: any): any;
188
+ getFieldsPatternByScreen(type: any): any;
189
+ toPath(story: any): any;
190
+ fromPath(story: any, defaultMedias?: any): any;
191
+ getFieldsPattern(fields: any, namePrefix?: any): any;
192
+ static fieldIsMedia({ media }: {
193
+ media?: boolean;
194
+ }): boolean;
195
+ static fieldIsFontFamily({ id }: {
196
+ id?: any;
197
+ }): boolean;
198
+ static replacePathsWithMedias(data: any, medias: any, patterns: any, keyPrefix?: any): any;
199
+ static getMediaPath({ id }: {
200
+ id?: any;
201
+ }): string;
202
+ static replaceMediasWithPaths(data: any, patterns: any, medias?: any, keyPrefix?: any): any;
203
+ static getMediaPatternsFromData(obj: any): RegExp[];
204
+ static dot(obj: any): any;
205
+ static keys(obj: any): any[];
206
+ }
207
+
208
+ declare const useMediasParser: () => {
209
+ toPath: (story: any) => any;
210
+ fromPath: (story: any) => any;
211
+ parser: MediasParser;
212
+ };
213
+
214
+ declare function useMediaThumbnail(media: any, file?: any): any;
215
+
216
+ declare function useMediaWaveform(media: any, { fake, reduceBufferFactor }?: {
217
+ fake?: boolean;
218
+ reduceBufferFactor?: number;
219
+ }): any;
220
+
221
+ declare const getObserver: (Observer: any, options?: {}) => any;
222
+ declare const useObserver: (Observer: any, opts?: {}, initialEntry?: {}) => {
223
+ ref: react.RefObject<any>;
224
+ entry: {};
225
+ };
226
+ declare const useIntersectionObserver: ({ root, rootMargin, threshold, disabled, }?: {
227
+ root?: any;
228
+ rootMargin?: string;
229
+ threshold?: number[];
230
+ disabled?: boolean;
231
+ }) => {
232
+ ref: react.RefObject<any>;
233
+ entry: {};
234
+ };
235
+ declare const useResizeObserver: ({ disabled }?: {
236
+ disabled?: boolean;
237
+ }) => {
238
+ ref: react.RefObject<any>;
239
+ entry: {};
240
+ };
241
+ declare const useDimensionObserver: (...args: any[]) => {
242
+ entry: {};
243
+ width: any;
244
+ height: any;
245
+ ref: react.RefObject<any>;
246
+ };
247
+
248
+ declare const useParsedStory: (story: any, { disabled, withTheme, withMedias, withFonts, withMigrations, }?: {
249
+ disabled?: boolean;
250
+ withTheme?: boolean;
251
+ withMedias?: boolean;
252
+ withFonts?: boolean;
253
+ withMigrations?: boolean;
254
+ }) => any;
255
+
256
+ declare const usePlaceholderStyle: (className: any, placeholderStyle: any) => string;
257
+
258
+ declare function useProgressSteps({ disabled, currentTime, duration, onStep, steps, }?: {
259
+ disabled?: boolean;
260
+ onStep?: any;
261
+ steps?: number[];
262
+ }): void;
263
+
264
+ declare const useDevicePixelRatio: () => number;
265
+ declare const useScreenSizeFromElement: ({ width, height, ...opts }?: {
266
+ width?: any;
267
+ height?: any;
268
+ }) => {
269
+ ref: react.RefObject<any>;
270
+ fullWidth: any;
271
+ fullHeight: any;
272
+ screenSize: {
273
+ screen: any;
274
+ screens: any[];
275
+ width: any;
276
+ height: any;
277
+ landscape: boolean;
278
+ menuOverScreen: boolean;
279
+ resolution: number;
280
+ imageResolution: number;
281
+ };
282
+ scale: number;
283
+ resolution: number;
284
+ };
285
+ declare const useScreenSizeFromWindow: (opts: any) => {
286
+ screen: any;
287
+ screens: any[];
288
+ width: any;
289
+ height: any;
290
+ landscape: boolean;
291
+ menuOverScreen: boolean;
292
+ resolution: number;
293
+ imageResolution: number;
294
+ };
295
+
296
+ declare function useSpringValue(wantedProgress: any, immediate: any, params: any): any;
297
+
298
+ declare function useSupportsWebp(defaultValue?: boolean): boolean;
299
+
300
+ declare const useSwipe: ({ width, items, withSpring, swipeWidthThreshold, animateScale, disabled, lockAxis, onSwipeStart, onSwipeEnd, onSwipeCancel, onTap, }?: {
301
+ width?: any;
302
+ items?: any[];
303
+ withSpring?: boolean;
304
+ swipeWidthThreshold?: number;
305
+ animateScale?: boolean;
306
+ disabled?: boolean;
307
+ lockAxis?: boolean;
308
+ onSwipeStart?: any;
309
+ onSwipeEnd?: any;
310
+ onSwipeCancel?: any;
311
+ onTap?: any;
312
+ }) => {
313
+ items: {
314
+ x: _react_spring_core.SpringValue<number>;
315
+ y: _react_spring_core.SpringValue<number>;
316
+ zIndex: _react_spring_core.SpringValue<number>;
317
+ }[];
318
+ bind: (...args: any[]) => _use_gesture_react_dist_declarations_src_types.ReactDOMAttributes;
319
+ index: number;
320
+ setIndex: (idx: any) => void;
321
+ };
322
+
323
+ declare const useThemeParser: () => (story: any) => any;
324
+
325
+ declare const useTrackScreenView: () => (screen?: any, index?: any) => void;
326
+ declare const useTrackScreenEvent: (type?: any) => (action?: any, label?: any, opts?: any) => void;
327
+ declare const useTrackScreenMedia: (type?: any) => (media?: any, action?: any, opts?: any) => void;
328
+ declare const useTrackEvent: () => (category?: any, action?: any, label?: any, opts?: any) => void;
329
+ declare const useTrackMedia: (type?: any) => (media?: any, action?: any, opts?: any) => void;
330
+
331
+ declare const useWindowEvent: (event: any, callback: any, enabled?: boolean) => void;
332
+
333
+ export { getObserver, useActivityDetector, useAnimationFrame, useDebounced as useDebounce, useDevicePixelRatio, useDimensionObserver, useDocumentEvent, useDragProgress, useForm, useFormTransition, useFormattedDate, useFormattedTime, useFullscreen, useIntersectionObserver, useIsVisible, useLoadedFonts, useLongPress, useMediaApi, useMediaBuffering, useMediaCurrentTime, useMediaDuration, useMediaLoad, useMediaProgress, useMediaReady, useMediaState, useMediaThumbnail, useMediaTimestampOffset, useMediaWaveform, useMediasParser, useObserver, useParsedStory, usePlaceholderStyle, useProgressSteps, useResizeObserver, useScreenSizeFromElement, useScreenSizeFromWindow, useSpringValue, useSupportsWebp, useSwipe, useThemeParser, useTrackEvent, useTrackMedia, useTrackScreenEvent, useTrackScreenMedia, useTrackScreenView, useWindowEvent };
package/es/hooks.js CHANGED
@@ -3,7 +3,7 @@ import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
3
3
  import { EventsManager, MediasParser, StoryParser, ThemeParser } from '@micromag/core';
4
4
  import { createUseEvent, getMediaFilesAsArray } from '@micromag/core/utils';
5
5
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
6
- import { useSpring, useSprings } from '@react-spring/core';
6
+ import { useSpringRef, useSpring, useSprings } from '@react-spring/core';
7
7
  import { useGesture, useDrag } from '@use-gesture/react';
8
8
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
9
9
  import { useForm as useForm$1 } from '@folklore/forms';
@@ -226,16 +226,21 @@ function useDragProgress() {
226
226
  _useState4 = _slicedToArray(_useState3, 2),
227
227
  direction = _useState4[0],
228
228
  setDirection = _useState4[1];
229
- var spring = useCallback(function () {
230
- return _objectSpread({
231
- progress: wantedProgress,
232
- immediate: dragging || disabled,
233
- onResolve: function onResolve() {
234
- setDirection(0);
235
- }
236
- }, springParams);
237
- }, [wantedProgress, disabled]);
238
- var _useSpring = useSpring(spring),
229
+
230
+ // In react-spring v10, useSpring(fn) without deps stores the initial update and
231
+ // re-applies it via ctrl.start() in a layout effect on EVERY render, resetting the
232
+ // spring to its initial value. To prevent this, we pass a dummy SpringRef as `ref`
233
+ // in the props — when ctrl.ref is set, the layout effect queues updates instead of
234
+ // starting them, so our imperative api.start() calls are not overridden.
235
+ var imperativeRef = useSpringRef();
236
+ var _useSpring = useSpring(function () {
237
+ return _objectSpread({
238
+ ref: imperativeRef,
239
+ from: {
240
+ progress: wantedProgress
241
+ }
242
+ }, springParams);
243
+ }),
239
244
  _useSpring2 = _slicedToArray(_useSpring, 2),
240
245
  progress = _useSpring2[0].progress,
241
246
  api = _useSpring2[1];
@@ -262,13 +267,13 @@ function useDragProgress() {
262
267
  if (active !== dragging) {
263
268
  setDragging(active);
264
269
  }
265
- api.start({
270
+ api.start(_objectSpread({
266
271
  progress: newProgress,
267
272
  immediate: active,
268
273
  onResolve: !active ? function () {
269
274
  setDirection(0);
270
275
  } : function () {}
271
- });
276
+ }, springParams));
272
277
  if (onProgress !== null) {
273
278
  onProgress(newProgress, gestureState);
274
279
  }
@@ -284,15 +289,15 @@ function useDragProgress() {
284
289
  if (!refDragging.current && wantedProgress !== refProgress.current) {
285
290
  setDirection(wantedProgress < refProgress.current ? -1 : 1);
286
291
  refProgress.current = wantedProgress;
287
- api.start({
292
+ api.start(_objectSpread({
288
293
  progress: wantedProgress,
289
- immediate: false,
294
+ immediate: disabled,
290
295
  onResolve: function onResolve() {
291
296
  setDirection(0);
292
297
  }
293
- });
298
+ }, springParams));
294
299
  }
295
- }, [wantedProgress]);
300
+ }, [wantedProgress, disabled]);
296
301
  var transitioning = useMemo(function () {
297
302
  return wantedProgress !== progress.get() || progress.isAnimating || dragging;
298
303
  }, [wantedProgress, progress.isAnimating, dragging]);