@micromag/core 0.4.85 → 0.4.88

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/es/contexts.d.ts CHANGED
@@ -195,6 +195,7 @@ declare class ComponentsManager extends EventEmitter {
195
195
 
196
196
  declare class DefinitionsManager<T extends Definition = Definition> extends EventEmitter {
197
197
  definitions: T[];
198
+ components: Record<string, Component> | null;
198
199
  constructor(definitions?: T[]);
199
200
  addDefinition(definition: T | T[]): this;
200
201
  addDefinitions(definitions: T[]): this;
package/es/contexts.js CHANGED
@@ -552,7 +552,7 @@ function _temp$3(t0) {
552
552
  const ScreensContext = /*#__PURE__*/createContext(null);
553
553
  const useScreensManager = () => use(ScreensContext);
554
554
  function ScreensProvider(t0) {
555
- const $ = c(17);
555
+ const $ = c(14);
556
556
  const {
557
557
  screens: t1,
558
558
  namespaces: t2,
@@ -595,58 +595,39 @@ function ScreensProvider(t0) {
595
595
  const [finalManager] = useState(t5);
596
596
  let t6;
597
597
  if ($[6] !== finalManager) {
598
- t6 = () => finalManager.getComponents();
598
+ t6 = finalManager.getComponents();
599
599
  $[6] = finalManager;
600
600
  $[7] = t6;
601
601
  } else {
602
602
  t6 = $[7];
603
603
  }
604
- const [components, setComponents] = useState(t6);
604
+ const components = t6;
605
605
  let t7;
606
- let t8;
607
- if ($[8] !== finalManager) {
608
- t7 = () => {
609
- const onChange = () => setComponents(finalManager.getComponents());
610
- finalManager.on("change", onChange);
611
- return () => {
612
- finalManager.off("change", onChange);
613
- };
614
- };
615
- t8 = [finalManager, setComponents];
616
- $[8] = finalManager;
617
- $[9] = t7;
618
- $[10] = t8;
619
- } else {
620
- t7 = $[9];
621
- t8 = $[10];
622
- }
623
- useEffect(t7, t8);
624
- let t9;
625
- if ($[11] !== children || $[12] !== components) {
626
- t9 = /*#__PURE__*/jsx(ComponentsProvider, {
606
+ if ($[8] !== children || $[9] !== components) {
607
+ t7 = /*#__PURE__*/jsx(ComponentsProvider, {
627
608
  namespace: SCREENS_NAMESPACE,
628
609
  components: components,
629
610
  children: children
630
611
  });
631
- $[11] = children;
632
- $[12] = components;
633
- $[13] = t9;
612
+ $[8] = children;
613
+ $[9] = components;
614
+ $[10] = t7;
634
615
  } else {
635
- t9 = $[13];
616
+ t7 = $[10];
636
617
  }
637
- let t10;
638
- if ($[14] !== finalManager || $[15] !== t9) {
639
- t10 = /*#__PURE__*/jsx(ScreensContext, {
618
+ let t8;
619
+ if ($[11] !== finalManager || $[12] !== t7) {
620
+ t8 = /*#__PURE__*/jsx(ScreensContext, {
640
621
  value: finalManager,
641
- children: t9
622
+ children: t7
642
623
  });
643
- $[14] = finalManager;
644
- $[15] = t9;
645
- $[16] = t10;
624
+ $[11] = finalManager;
625
+ $[12] = t7;
626
+ $[13] = t8;
646
627
  } else {
647
- t10 = $[16];
628
+ t8 = $[13];
648
629
  }
649
- return t10;
630
+ return t8;
650
631
  }
651
632
 
652
633
  const StoryContext = /*#__PURE__*/createContext(null);
package/es/hooks.js CHANGED
@@ -259,7 +259,7 @@ const defaultDragOptions = {
259
259
  filterTaps: true
260
260
  };
261
261
  function useDragProgress(t0) {
262
- const $ = c(41);
262
+ const $ = c(36);
263
263
  const {
264
264
  progress: wantedProgress,
265
265
  onTap: t1,
@@ -337,7 +337,8 @@ function useDragProgress(t0) {
337
337
  const {
338
338
  active,
339
339
  tap,
340
- first
340
+ first,
341
+ last
341
342
  } = gestureState;
342
343
  if (disabled) {
343
344
  draggingRef.current = false;
@@ -373,7 +374,7 @@ function useDragProgress(t0) {
373
374
  }
374
375
  },
375
376
  onStart: first ? onTransitionStart : undefined,
376
- onRest: !active ? onTransitionComplete : undefined,
377
+ onRest: last ? onTransitionComplete : undefined,
377
378
  ...springParams
378
379
  });
379
380
  if (onProgress !== null) {
@@ -459,38 +460,27 @@ function useDragProgress(t0) {
459
460
  t21 = $[29];
460
461
  }
461
462
  useEffect(t20, t21);
462
- let t22;
463
- if ($[30] !== dragging || $[31] !== progress || $[32] !== transitioned || $[33] !== wantedProgress) {
464
- t22 = wantedProgress !== progress.get() || progress.isAnimating || dragging || !transitioned;
465
- $[30] = dragging;
466
- $[31] = progress;
467
- $[32] = transitioned;
468
- $[33] = wantedProgress;
469
- $[34] = t22;
470
- } else {
471
- t22 = $[34];
472
- }
473
- const transitioning = t22;
474
- const t23 = wantedProgress !== lastWantedProgress ? wantedProgress < lastWantedProgress ? -1 : 1 : direction;
475
- let t24;
476
- if ($[35] !== bind || $[36] !== dragging || $[37] !== progress || $[38] !== t23 || $[39] !== transitioning) {
477
- t24 = {
463
+ const transitioning = progress.isAnimating || dragging || !transitioned;
464
+ const t22 = wantedProgress !== lastWantedProgress ? wantedProgress < lastWantedProgress ? -1 : 1 : direction;
465
+ let t23;
466
+ if ($[30] !== bind || $[31] !== dragging || $[32] !== progress || $[33] !== t22 || $[34] !== transitioning) {
467
+ t23 = {
478
468
  transitioning,
479
469
  bind,
480
470
  dragging,
481
471
  progress,
482
- direction: t23
472
+ direction: t22
483
473
  };
484
- $[35] = bind;
485
- $[36] = dragging;
486
- $[37] = progress;
487
- $[38] = t23;
488
- $[39] = transitioning;
489
- $[40] = t24;
474
+ $[30] = bind;
475
+ $[31] = dragging;
476
+ $[32] = progress;
477
+ $[33] = t22;
478
+ $[34] = transitioning;
479
+ $[35] = t23;
490
480
  } else {
491
- t24 = $[40];
481
+ t23 = $[35];
492
482
  }
493
- return t24;
483
+ return t23;
494
484
  }
495
485
 
496
486
  function useForm(t0) {
package/es/index.d.ts CHANGED
@@ -492,6 +492,7 @@ declare class ComponentsManager extends EventEmitter {
492
492
 
493
493
  declare class DefinitionsManager<T extends Definition = Definition> extends EventEmitter {
494
494
  definitions: T[];
495
+ components: Record<string, Component> | null;
495
496
  constructor(definitions?: T[]);
496
497
  addDefinition(definition: T | T[]): this;
497
498
  addDefinitions(definitions: T[]): this;
package/es/index.js CHANGED
@@ -236,6 +236,7 @@ class DefinitionsManager extends EventEmitter {
236
236
  constructor(definitions = []) {
237
237
  super();
238
238
  this.definitions = definitions || [];
239
+ this.components = null;
239
240
  }
240
241
  addDefinition(definition) {
241
242
  this.addDefinitions(isArray(definition) ? definition : [definition]);
@@ -243,6 +244,7 @@ class DefinitionsManager extends EventEmitter {
243
244
  }
244
245
  addDefinitions(definitions) {
245
246
  this.definitions = uniqBy([...definitions, ...this.definitions], it => it.id);
247
+ this.components = null;
246
248
  this.emit('change');
247
249
  return this;
248
250
  }
@@ -273,13 +275,16 @@ class DefinitionsManager extends EventEmitter {
273
275
  return component;
274
276
  }
275
277
  getComponents() {
276
- return this.definitions.reduce((allComponents, {
277
- id,
278
- component = null
279
- }) => component !== null ? {
280
- ...allComponents,
281
- [id]: component
282
- } : allComponents, {});
278
+ if (this.components === null) {
279
+ this.components = this.definitions.reduce((allComponents, {
280
+ id,
281
+ component = null
282
+ }) => component !== null ? {
283
+ ...allComponents,
284
+ [id]: component
285
+ } : allComponents, {});
286
+ }
287
+ return this.components;
283
288
  }
284
289
  }
285
290
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/core",
3
- "version": "0.4.85",
3
+ "version": "0.4.88",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -157,6 +157,6 @@
157
157
  "access": "public",
158
158
  "registry": "https://registry.npmjs.org/"
159
159
  },
160
- "gitHead": "21705788dfb96bc235356c11501fae2365d02a58",
160
+ "gitHead": "cf331286bb6037d61e664cd5c961955c136719c6",
161
161
  "types": "es/index.d.ts"
162
162
  }