@simplybusiness/mobius 3.5.1 → 3.6.1
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/CHANGELOG.md +23 -0
- package/dist/cjs/components/Alert/Alert.js +1 -5
- package/dist/cjs/components/Alert/Alert.js.map +1 -1
- package/dist/cjs/components/Checkbox/Checkbox.test.js +0 -2
- package/dist/cjs/components/Checkbox/Checkbox.test.js.map +1 -1
- package/dist/cjs/components/Checkbox/CheckboxGroup.test.js +0 -2
- package/dist/cjs/components/Checkbox/CheckboxGroup.test.js.map +1 -1
- package/dist/cjs/components/Chopin/Question/Question.test.js +0 -2
- package/dist/cjs/components/Chopin/Question/Question.test.js.map +1 -1
- package/dist/cjs/components/Chopin/Steps/StepItem.js +1 -5
- package/dist/cjs/components/Chopin/Steps/StepItem.js.map +1 -1
- package/dist/cjs/components/Icon/IconFromObject.js +4 -20
- package/dist/cjs/components/Icon/IconFromObject.js.map +1 -1
- package/dist/cjs/components/Radio/Radio.js +2 -6
- package/dist/cjs/components/Radio/Radio.js.map +1 -1
- package/dist/cjs/components/Radio/Radio.test.js +0 -2
- package/dist/cjs/components/Radio/Radio.test.js.map +1 -1
- package/dist/cjs/components/Radio/RadioButton.js +2 -6
- package/dist/cjs/components/Radio/RadioButton.js.map +1 -1
- package/dist/cjs/components/Radio/RadioButton.test.js +0 -2
- package/dist/cjs/components/Radio/RadioButton.test.js.map +1 -1
- package/dist/cjs/components/Select/Select.js +1 -5
- package/dist/cjs/components/Select/Select.js.map +1 -1
- package/dist/cjs/components/Select/Select.test.js +0 -2
- package/dist/cjs/components/Select/Select.test.js.map +1 -1
- package/dist/cjs/components/Slider/Slider.js +1 -21
- package/dist/cjs/components/Slider/Slider.js.map +1 -1
- package/dist/cjs/components/Slider/Thumb.js +1 -7
- package/dist/cjs/components/Slider/Thumb.js.map +1 -1
- package/dist/cjs/components/TextArea/TextArea.js +1 -5
- package/dist/cjs/components/TextArea/TextArea.js.map +1 -1
- package/dist/cjs/components/TextField/TextField.js +1 -5
- package/dist/cjs/components/TextField/TextField.js.map +1 -1
- package/dist/cjs/components/TextField/TextField.test.js +0 -2
- package/dist/cjs/components/TextField/TextField.test.js.map +1 -1
- package/dist/cjs/contexts/ThemeContext/ThemeContext.js +1 -1
- package/dist/cjs/contexts/ThemeContext/ThemeContext.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/components/Alert/Alert.js +1 -5
- package/dist/esm/components/Alert/Alert.js.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.test.js +0 -2
- package/dist/esm/components/Checkbox/Checkbox.test.js.map +1 -1
- package/dist/esm/components/Checkbox/CheckboxGroup.test.js +0 -2
- package/dist/esm/components/Checkbox/CheckboxGroup.test.js.map +1 -1
- package/dist/esm/components/Chopin/Question/Question.test.js +0 -2
- package/dist/esm/components/Chopin/Question/Question.test.js.map +1 -1
- package/dist/esm/components/Chopin/Steps/StepItem.js +1 -5
- package/dist/esm/components/Chopin/Steps/StepItem.js.map +1 -1
- package/dist/esm/components/Icon/IconFromObject.js +4 -20
- package/dist/esm/components/Icon/IconFromObject.js.map +1 -1
- package/dist/esm/components/Radio/Radio.js +2 -6
- package/dist/esm/components/Radio/Radio.js.map +1 -1
- package/dist/esm/components/Radio/Radio.test.js +0 -2
- package/dist/esm/components/Radio/Radio.test.js.map +1 -1
- package/dist/esm/components/Radio/RadioButton.js +2 -6
- package/dist/esm/components/Radio/RadioButton.js.map +1 -1
- package/dist/esm/components/Radio/RadioButton.test.js +0 -2
- package/dist/esm/components/Radio/RadioButton.test.js.map +1 -1
- package/dist/esm/components/Select/Select.js +1 -5
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/Select.test.js +0 -2
- package/dist/esm/components/Select/Select.test.js.map +1 -1
- package/dist/esm/components/Slider/Slider.js +1 -21
- package/dist/esm/components/Slider/Slider.js.map +1 -1
- package/dist/esm/components/Slider/Thumb.js +1 -7
- package/dist/esm/components/Slider/Thumb.js.map +1 -1
- package/dist/esm/components/TextArea/TextArea.js +1 -5
- package/dist/esm/components/TextArea/TextArea.js.map +1 -1
- package/dist/esm/components/TextField/TextField.js +1 -5
- package/dist/esm/components/TextField/TextField.js.map +1 -1
- package/dist/esm/components/TextField/TextField.test.js +0 -2
- package/dist/esm/components/TextField/TextField.test.js.map +1 -1
- package/dist/esm/contexts/ThemeContext/ThemeContext.js +1 -1
- package/dist/esm/contexts/ThemeContext/ThemeContext.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -4
- package/src/components/Alert/Alert.tsx +1 -6
- package/src/components/Button/Button.story.mdx +2 -6
- package/src/components/Checkbox/Checkbox.test.tsx +0 -3
- package/src/components/Checkbox/CheckboxGroup.test.tsx +0 -3
- package/src/components/Chopin/Question/Question.story.mdx +27 -49
- package/src/components/Chopin/Question/Question.story.styles.css +35 -0
- package/src/components/Chopin/Question/Question.test.tsx +0 -3
- package/src/components/Chopin/Steps/StepItem.tsx +1 -6
- package/src/components/Fieldset/Fieldset.story.mdx +0 -1
- package/src/components/Grid/Grid.story.mdx +60 -70
- package/src/components/Grid/Grid.story.styles.css +16 -0
- package/src/components/Icon/Icon.story.mdx +13 -6
- package/src/components/Icon/IconFromObject.tsx +4 -22
- package/src/components/Image/Image.story.mdx +1 -1
- package/src/components/Modal/Modal.story.mdx +81 -1
- package/src/components/NumberField/__snapshots__/NumberField.test.tsx.snap +0 -2
- package/src/components/Radio/Radio.test.tsx +0 -3
- package/src/components/Radio/Radio.tsx +5 -8
- package/src/components/Radio/RadioButton.test.tsx +0 -3
- package/src/components/Radio/RadioButton.tsx +5 -8
- package/src/components/Select/Select.test.tsx +0 -3
- package/src/components/Select/Select.tsx +2 -9
- package/src/components/Slider/Slider.tsx +7 -36
- package/src/components/Slider/Thumb.tsx +2 -9
- package/src/components/Text/Text.story.mdx +5 -7
- package/src/components/TextArea/TextArea.tsx +2 -10
- package/src/components/TextField/TextField.test.tsx +0 -3
- package/src/components/TextField/TextField.tsx +2 -10
- package/src/contexts/ThemeContext/ThemeContext.tsx +1 -1
- package/dist/cjs/components/Fieldset/stories/StyledLegend.d.ts +0 -5
- package/dist/cjs/components/Fieldset/stories/StyledLegend.js +0 -13
- package/dist/cjs/components/Fieldset/stories/StyledLegend.js.map +0 -1
- package/dist/cjs/utils/combineTruthyObjects.d.ts +0 -6
- package/dist/cjs/utils/combineTruthyObjects.js +0 -38
- package/dist/cjs/utils/combineTruthyObjects.js.map +0 -1
- package/dist/cjs/utils/combineTruthyObjects.test.d.ts +0 -1
- package/dist/cjs/utils/combineTruthyObjects.test.js +0 -122
- package/dist/cjs/utils/combineTruthyObjects.test.js.map +0 -1
- package/dist/esm/components/Fieldset/stories/StyledLegend.js +0 -7
- package/dist/esm/components/Fieldset/stories/StyledLegend.js.map +0 -1
- package/dist/esm/utils/combineTruthyObjects.js +0 -11
- package/dist/esm/utils/combineTruthyObjects.js.map +0 -1
- package/dist/esm/utils/combineTruthyObjects.test.js +0 -120
- package/dist/esm/utils/combineTruthyObjects.test.js.map +0 -1
- package/src/components/Fieldset/stories/StyledLegend.tsx +0 -7
- package/src/utils/combineTruthyObjects.test.ts +0 -125
- package/src/utils/combineTruthyObjects.ts +0 -12
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const combineTruthyObjects_1 = require("./combineTruthyObjects");
|
|
4
|
-
describe("combineTruthyObjects", () => {
|
|
5
|
-
it("combines objects correctly", () => {
|
|
6
|
-
const input = [
|
|
7
|
-
{
|
|
8
|
-
foo: "foo",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
bar: "bar",
|
|
12
|
-
},
|
|
13
|
-
];
|
|
14
|
-
const expected = {
|
|
15
|
-
foo: "foo",
|
|
16
|
-
bar: "bar",
|
|
17
|
-
};
|
|
18
|
-
const result = (0, combineTruthyObjects_1.combineTruthyObjects)(input);
|
|
19
|
-
expect(result).toStrictEqual(expected);
|
|
20
|
-
});
|
|
21
|
-
it("ignores false and null values", () => {
|
|
22
|
-
const input = [
|
|
23
|
-
{
|
|
24
|
-
foo: "foo",
|
|
25
|
-
},
|
|
26
|
-
false && {
|
|
27
|
-
baz: "baz",
|
|
28
|
-
},
|
|
29
|
-
null,
|
|
30
|
-
{
|
|
31
|
-
bar: "bar",
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
const expected = {
|
|
35
|
-
foo: "foo",
|
|
36
|
-
bar: "bar",
|
|
37
|
-
};
|
|
38
|
-
const result = (0, combineTruthyObjects_1.combineTruthyObjects)(input);
|
|
39
|
-
expect(result).toStrictEqual(expected);
|
|
40
|
-
});
|
|
41
|
-
it("overwrites earlier values with later values", () => {
|
|
42
|
-
const input = [
|
|
43
|
-
{
|
|
44
|
-
foo: "one",
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
foo: "two",
|
|
48
|
-
},
|
|
49
|
-
];
|
|
50
|
-
const expected = {
|
|
51
|
-
foo: "two",
|
|
52
|
-
};
|
|
53
|
-
const result = (0, combineTruthyObjects_1.combineTruthyObjects)(input);
|
|
54
|
-
expect(result).toStrictEqual(expected);
|
|
55
|
-
});
|
|
56
|
-
it("deep merges nested objects", () => {
|
|
57
|
-
const input = [
|
|
58
|
-
{
|
|
59
|
-
foo: {
|
|
60
|
-
bar: "bar",
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
foo: {
|
|
65
|
-
baz: "baz",
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
];
|
|
69
|
-
const expected = {
|
|
70
|
-
foo: {
|
|
71
|
-
bar: "bar",
|
|
72
|
-
baz: "baz",
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
const result = (0, combineTruthyObjects_1.combineTruthyObjects)(input);
|
|
76
|
-
expect(result).toStrictEqual(expected);
|
|
77
|
-
});
|
|
78
|
-
it("deep merges multiple levels", () => {
|
|
79
|
-
const input = [
|
|
80
|
-
{
|
|
81
|
-
foo: {
|
|
82
|
-
bar: {
|
|
83
|
-
one: "one",
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
foo: {
|
|
89
|
-
bar: {
|
|
90
|
-
two: "two",
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
];
|
|
95
|
-
const expected = {
|
|
96
|
-
foo: {
|
|
97
|
-
bar: {
|
|
98
|
-
one: "one",
|
|
99
|
-
two: "two",
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
const result = (0, combineTruthyObjects_1.combineTruthyObjects)(input);
|
|
104
|
-
expect(result).toStrictEqual(expected);
|
|
105
|
-
});
|
|
106
|
-
it("merges array values together", () => {
|
|
107
|
-
const input = [
|
|
108
|
-
{
|
|
109
|
-
foo: [1, 2, 3],
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
foo: [4, 5, 6],
|
|
113
|
-
},
|
|
114
|
-
];
|
|
115
|
-
const expected = {
|
|
116
|
-
foo: [1, 2, 3, 4, 5, 6],
|
|
117
|
-
};
|
|
118
|
-
const result = (0, combineTruthyObjects_1.combineTruthyObjects)(input);
|
|
119
|
-
expect(result).toStrictEqual(expected);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
//# sourceMappingURL=combineTruthyObjects.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"combineTruthyObjects.test.js","sourceRoot":"","sources":["../../../src/utils/combineTruthyObjects.test.ts"],"names":[],"mappings":";;AAAA,iEAA8D;AAE9D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,KAAK,GAAG;YACZ;gBACE,GAAG,EAAE,KAAK;aACX;YACD;gBACE,GAAG,EAAE,KAAK;aACX;S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CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StyledLegend.js","sourceRoot":"","sources":["../../../../../src/components/Fieldset/stories/StyledLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAA;;;;CAIxC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as merge from "deepmerge";
|
|
2
|
-
/**
|
|
3
|
-
* Combines the provided objects into a single output object,
|
|
4
|
-
* while removing any null or false values.
|
|
5
|
-
* @param objects - the objects to combine
|
|
6
|
-
*/
|
|
7
|
-
export function combineTruthyObjects(objects) {
|
|
8
|
-
const truthyObjects = objects.filter(o => o && o !== null);
|
|
9
|
-
return merge.all(truthyObjects);
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=combineTruthyObjects.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"combineTruthyObjects.js","sourceRoot":"","sources":["../../../src/utils/combineTruthyObjects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAI,OAA+B;IACrE,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;IAE3D,OAAO,KAAK,CAAC,GAAG,CAAC,aAAyB,CAAM,CAAC;AACnD,CAAC"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { combineTruthyObjects } from "./combineTruthyObjects";
|
|
2
|
-
describe("combineTruthyObjects", () => {
|
|
3
|
-
it("combines objects correctly", () => {
|
|
4
|
-
const input = [
|
|
5
|
-
{
|
|
6
|
-
foo: "foo",
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
bar: "bar",
|
|
10
|
-
},
|
|
11
|
-
];
|
|
12
|
-
const expected = {
|
|
13
|
-
foo: "foo",
|
|
14
|
-
bar: "bar",
|
|
15
|
-
};
|
|
16
|
-
const result = combineTruthyObjects(input);
|
|
17
|
-
expect(result).toStrictEqual(expected);
|
|
18
|
-
});
|
|
19
|
-
it("ignores false and null values", () => {
|
|
20
|
-
const input = [
|
|
21
|
-
{
|
|
22
|
-
foo: "foo",
|
|
23
|
-
},
|
|
24
|
-
false && {
|
|
25
|
-
baz: "baz",
|
|
26
|
-
},
|
|
27
|
-
null,
|
|
28
|
-
{
|
|
29
|
-
bar: "bar",
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
const expected = {
|
|
33
|
-
foo: "foo",
|
|
34
|
-
bar: "bar",
|
|
35
|
-
};
|
|
36
|
-
const result = combineTruthyObjects(input);
|
|
37
|
-
expect(result).toStrictEqual(expected);
|
|
38
|
-
});
|
|
39
|
-
it("overwrites earlier values with later values", () => {
|
|
40
|
-
const input = [
|
|
41
|
-
{
|
|
42
|
-
foo: "one",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
foo: "two",
|
|
46
|
-
},
|
|
47
|
-
];
|
|
48
|
-
const expected = {
|
|
49
|
-
foo: "two",
|
|
50
|
-
};
|
|
51
|
-
const result = combineTruthyObjects(input);
|
|
52
|
-
expect(result).toStrictEqual(expected);
|
|
53
|
-
});
|
|
54
|
-
it("deep merges nested objects", () => {
|
|
55
|
-
const input = [
|
|
56
|
-
{
|
|
57
|
-
foo: {
|
|
58
|
-
bar: "bar",
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
foo: {
|
|
63
|
-
baz: "baz",
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
];
|
|
67
|
-
const expected = {
|
|
68
|
-
foo: {
|
|
69
|
-
bar: "bar",
|
|
70
|
-
baz: "baz",
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
const result = combineTruthyObjects(input);
|
|
74
|
-
expect(result).toStrictEqual(expected);
|
|
75
|
-
});
|
|
76
|
-
it("deep merges multiple levels", () => {
|
|
77
|
-
const input = [
|
|
78
|
-
{
|
|
79
|
-
foo: {
|
|
80
|
-
bar: {
|
|
81
|
-
one: "one",
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
foo: {
|
|
87
|
-
bar: {
|
|
88
|
-
two: "two",
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
const expected = {
|
|
94
|
-
foo: {
|
|
95
|
-
bar: {
|
|
96
|
-
one: "one",
|
|
97
|
-
two: "two",
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
const result = combineTruthyObjects(input);
|
|
102
|
-
expect(result).toStrictEqual(expected);
|
|
103
|
-
});
|
|
104
|
-
it("merges array values together", () => {
|
|
105
|
-
const input = [
|
|
106
|
-
{
|
|
107
|
-
foo: [1, 2, 3],
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
foo: [4, 5, 6],
|
|
111
|
-
},
|
|
112
|
-
];
|
|
113
|
-
const expected = {
|
|
114
|
-
foo: [1, 2, 3, 4, 5, 6],
|
|
115
|
-
};
|
|
116
|
-
const result = combineTruthyObjects(input);
|
|
117
|
-
expect(result).toStrictEqual(expected);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
//# sourceMappingURL=combineTruthyObjects.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"combineTruthyObjects.test.js","sourceRoot":"","sources":["../../../src/utils/combineTruthyObjects.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAC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,CAAC;SACxB,CAAC;QACF,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { combineTruthyObjects } from "./combineTruthyObjects";
|
|
2
|
-
|
|
3
|
-
describe("combineTruthyObjects", () => {
|
|
4
|
-
it("combines objects correctly", () => {
|
|
5
|
-
const input = [
|
|
6
|
-
{
|
|
7
|
-
foo: "foo",
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
bar: "bar",
|
|
11
|
-
},
|
|
12
|
-
];
|
|
13
|
-
const expected = {
|
|
14
|
-
foo: "foo",
|
|
15
|
-
bar: "bar",
|
|
16
|
-
};
|
|
17
|
-
const result = combineTruthyObjects(input);
|
|
18
|
-
expect(result).toStrictEqual(expected);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("ignores false and null values", () => {
|
|
22
|
-
const input = [
|
|
23
|
-
{
|
|
24
|
-
foo: "foo",
|
|
25
|
-
},
|
|
26
|
-
false && {
|
|
27
|
-
baz: "baz",
|
|
28
|
-
},
|
|
29
|
-
null,
|
|
30
|
-
{
|
|
31
|
-
bar: "bar",
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
const expected = {
|
|
35
|
-
foo: "foo",
|
|
36
|
-
bar: "bar",
|
|
37
|
-
};
|
|
38
|
-
const result = combineTruthyObjects(input);
|
|
39
|
-
expect(result).toStrictEqual(expected);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("overwrites earlier values with later values", () => {
|
|
43
|
-
const input = [
|
|
44
|
-
{
|
|
45
|
-
foo: "one",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
foo: "two",
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
const expected = {
|
|
52
|
-
foo: "two",
|
|
53
|
-
};
|
|
54
|
-
const result = combineTruthyObjects(input);
|
|
55
|
-
expect(result).toStrictEqual(expected);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("deep merges nested objects", () => {
|
|
59
|
-
const input = [
|
|
60
|
-
{
|
|
61
|
-
foo: {
|
|
62
|
-
bar: "bar",
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
foo: {
|
|
67
|
-
baz: "baz",
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
const expected = {
|
|
72
|
-
foo: {
|
|
73
|
-
bar: "bar",
|
|
74
|
-
baz: "baz",
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
const result = combineTruthyObjects(input);
|
|
78
|
-
expect(result).toStrictEqual(expected);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("deep merges multiple levels", () => {
|
|
82
|
-
const input = [
|
|
83
|
-
{
|
|
84
|
-
foo: {
|
|
85
|
-
bar: {
|
|
86
|
-
one: "one",
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
foo: {
|
|
92
|
-
bar: {
|
|
93
|
-
two: "two",
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
];
|
|
98
|
-
const expected = {
|
|
99
|
-
foo: {
|
|
100
|
-
bar: {
|
|
101
|
-
one: "one",
|
|
102
|
-
two: "two",
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
const result = combineTruthyObjects(input);
|
|
107
|
-
expect(result).toStrictEqual(expected);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("merges array values together", () => {
|
|
111
|
-
const input = [
|
|
112
|
-
{
|
|
113
|
-
foo: [1, 2, 3],
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
foo: [4, 5, 6],
|
|
117
|
-
},
|
|
118
|
-
];
|
|
119
|
-
const expected = {
|
|
120
|
-
foo: [1, 2, 3, 4, 5, 6],
|
|
121
|
-
};
|
|
122
|
-
const result = combineTruthyObjects(input);
|
|
123
|
-
expect(result).toStrictEqual(expected);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as merge from "deepmerge";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Combines the provided objects into a single output object,
|
|
5
|
-
* while removing any null or false values.
|
|
6
|
-
* @param objects - the objects to combine
|
|
7
|
-
*/
|
|
8
|
-
export function combineTruthyObjects<T>(objects: (T | boolean | null)[]) {
|
|
9
|
-
const truthyObjects = objects.filter(o => o && o !== null);
|
|
10
|
-
|
|
11
|
-
return merge.all(truthyObjects as object[]) as T;
|
|
12
|
-
}
|