@histoire/shared 0.7.7 → 0.7.8

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/state.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import type { Variant } from './types';
2
2
  export declare function clone(data: any): any;
3
3
  export declare function omit(data: any, keys: string[]): {};
4
- export declare function applyStateToVariant(variant: Variant, state: any): void;
4
+ export declare function applyStateToVariant(variant: Variant, state: any, override?: boolean): void;
package/dist/state.js CHANGED
@@ -22,10 +22,10 @@ export function omit(data, keys) {
22
22
  }
23
23
  return copy;
24
24
  }
25
- export function applyStateToVariant(variant, state) {
25
+ export function applyStateToVariant(variant, state, override = false) {
26
26
  if (variant.state) {
27
27
  for (const key in state) {
28
- if (variant.state[key] && !key.startsWith('_h') && typeof variant.state[key] === 'object' && !Array.isArray(variant.state[key])) {
28
+ if (!override && variant.state[key] && !key.startsWith('_h') && typeof variant.state[key] === 'object' && !Array.isArray(variant.state[key])) {
29
29
  Object.assign(variant.state[key], state[key]);
30
30
  }
31
31
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@histoire/shared",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "description": "Shared utilities for Histoire",
5
5
  "license": "MIT",
6
6
  "author": {
package/src/state.ts CHANGED
@@ -24,10 +24,10 @@ export function omit (data, keys: string[]) {
24
24
  return copy
25
25
  }
26
26
 
27
- export function applyStateToVariant (variant: Variant, state: any) {
27
+ export function applyStateToVariant (variant: Variant, state: any, override = false) {
28
28
  if (variant.state) {
29
29
  for (const key in state) {
30
- if (variant.state[key] && !key.startsWith('_h') && typeof variant.state[key] === 'object' && !Array.isArray(variant.state[key])) {
30
+ if (!override && variant.state[key] && !key.startsWith('_h') && typeof variant.state[key] === 'object' && !Array.isArray(variant.state[key])) {
31
31
  Object.assign(variant.state[key], state[key])
32
32
  } else {
33
33
  variant.state[key] = state[key]