@micromag/core 0.4.83 → 0.4.86

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.
@@ -97,9 +97,10 @@ declare function BackButton({ className, ...props }: BackButtonProps): react_jsx
97
97
 
98
98
  interface ClearButtonProps {
99
99
  onClick?: ((...args: unknown[]) => void) | null;
100
+ iconOnly?: boolean;
100
101
  className?: string | null;
101
102
  }
102
- declare function ClearButton({ onClick, className, ...props }: ClearButtonProps): react_jsx_runtime.JSX.Element;
103
+ declare function ClearButton({ onClick, className, iconOnly, ...props }: ClearButtonProps): react_jsx_runtime.JSX.Element;
103
104
 
104
105
  interface FormProps {
105
106
  action: string;
package/es/components.js CHANGED
@@ -328,61 +328,68 @@ function BackButton(t0) {
328
328
  var styles$w = {"container":"micromag-core-buttons-clear-container","icon":"micromag-core-buttons-clear-icon"};
329
329
 
330
330
  function ClearButton(t0) {
331
- const $ = c(11);
331
+ const $ = c(13);
332
332
  let props;
333
333
  let t1;
334
334
  let t2;
335
+ let t3;
335
336
  if ($[0] !== t0) {
336
337
  ({
337
338
  onClick: t1,
338
339
  className: t2,
340
+ iconOnly: t3,
339
341
  ...props
340
342
  } = t0);
341
343
  $[0] = t0;
342
344
  $[1] = props;
343
345
  $[2] = t1;
344
346
  $[3] = t2;
347
+ $[4] = t3;
345
348
  } else {
346
349
  props = $[1];
347
350
  t1 = $[2];
348
351
  t2 = $[3];
352
+ t3 = $[4];
349
353
  }
350
354
  const onClick = t1 === undefined ? null : t1;
351
355
  const className = t2 === undefined ? null : t2;
352
- let t3;
353
- if ($[4] !== className) {
354
- t3 = classNames([styles$w.container, className]);
355
- $[4] = className;
356
- $[5] = t3;
356
+ const iconOnly = t3 === undefined ? false : t3;
357
+ const ButtonComponent = iconOnly ? "span" : "button";
358
+ let t4;
359
+ if ($[5] !== className) {
360
+ t4 = classNames([styles$w.container, className]);
361
+ $[5] = className;
362
+ $[6] = t4;
357
363
  } else {
358
- t3 = $[5];
364
+ t4 = $[6];
359
365
  }
360
- let t4;
361
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
362
- t4 = /*#__PURE__*/jsx(FontAwesomeIcon, {
366
+ let t5;
367
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
368
+ t5 = /*#__PURE__*/jsx(FontAwesomeIcon, {
363
369
  className: styles$w.icon,
364
370
  icon: faClose
365
371
  });
366
- $[6] = t4;
372
+ $[7] = t5;
367
373
  } else {
368
- t4 = $[6];
374
+ t5 = $[7];
369
375
  }
370
- let t5;
371
- if ($[7] !== onClick || $[8] !== props || $[9] !== t3) {
372
- t5 = /*#__PURE__*/jsx("button", {
373
- className: t3,
376
+ let t6;
377
+ if ($[8] !== ButtonComponent || $[9] !== onClick || $[10] !== props || $[11] !== t4) {
378
+ t6 = /*#__PURE__*/jsx(ButtonComponent, {
379
+ className: t4,
374
380
  onClick: onClick,
375
381
  ...props,
376
- children: t4
382
+ children: t5
377
383
  });
378
- $[7] = onClick;
379
- $[8] = props;
380
- $[9] = t3;
381
- $[10] = t5;
384
+ $[8] = ButtonComponent;
385
+ $[9] = onClick;
386
+ $[10] = props;
387
+ $[11] = t4;
388
+ $[12] = t6;
382
389
  } else {
383
- t5 = $[10];
390
+ t6 = $[12];
384
391
  }
385
- return t5;
392
+ return t6;
386
393
  }
387
394
 
388
395
  const emptyArray$8 = [];
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/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.83",
3
+ "version": "0.4.86",
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": "323b1d85d8fe4665b160783048a92d78f663050f",
160
+ "gitHead": "24785d81e840b81c58dc101ba7305d088e61f0e0",
161
161
  "types": "es/index.d.ts"
162
162
  }