@thecb/components 5.0.0-beta.15 → 5.0.0-beta.2
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/.eslintrc.json +29 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +18 -0
- package/.github/stale.yml +17 -0
- package/.github/workflows/bump-version.yml +30 -0
- package/.github/workflows/create-release/build-body.sh +35 -0
- package/.github/workflows/create-release.yml +52 -0
- package/.github/workflows/disabled-workflows/publish-update.yml +73 -0
- package/.prettierignore +3 -0
- package/.storybook/main.js +4 -0
- package/.storybook/page.js +64 -0
- package/.storybook/themes/apc.theme.js +1 -0
- package/.storybook/themes/index.js +2 -0
- package/.storybook/themes/sf.theme.js +1 -0
- package/.tool-versions +1 -0
- package/dist/index.cjs.js +1477 -678
- package/package.json +4 -9
- package/rollup.config.js +53 -0
- package/src/components/molecules/modal/Modal.js +1 -1
- package/src/components/molecules/payment-form-card/PaymentFormCard.state.js +1 -1
- package/src/deprecated/utility/__tests__/safeConcat.spec.js +28 -30
- package/src/deprecated/utility/__tests__/validateKeyType.spec.js +49 -65
- package/src/deprecated/utility/index.js +2 -2
- package/src/deprecated/utility/safeConcat.js +3 -3
- package/src/deprecated/utility/validateKeyType.js +6 -4
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -41581
- package/dist/index.esm.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/molecules/.DS_Store +0 -0
- package/src/deprecated/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thecb/components",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.2",
|
|
4
4
|
"description": "Common lib for CityBase react components",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -18,14 +18,9 @@
|
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/CityBaseInc/cb-components/issues"
|
|
20
20
|
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist",
|
|
23
|
-
"src"
|
|
24
|
-
],
|
|
25
21
|
"homepage": "https://github.com/CityBaseInc/cb-components#readme",
|
|
26
22
|
"devDependencies": {
|
|
27
23
|
"@babel/core": "^7.0.0-0",
|
|
28
|
-
"@babel/eslint-parser": "^7.15.8",
|
|
29
24
|
"@babel/preset-env": "^7.6.0",
|
|
30
25
|
"@babel/preset-react": "^7.0.0",
|
|
31
26
|
"@babel/register": "^7.6.2",
|
|
@@ -39,6 +34,7 @@
|
|
|
39
34
|
"@storybook/addon-viewport": "^5.3.14",
|
|
40
35
|
"@storybook/react": "^5.3.14",
|
|
41
36
|
"babel-core": "^6.26.3",
|
|
37
|
+
"babel-eslint": "^10.1.0",
|
|
42
38
|
"babel-loader": "^8.1.0",
|
|
43
39
|
"babel-preset-env": "^1.7.0",
|
|
44
40
|
"babel-preset-react": "^6.24.1",
|
|
@@ -77,14 +73,13 @@
|
|
|
77
73
|
}
|
|
78
74
|
},
|
|
79
75
|
"dependencies": {
|
|
80
|
-
"
|
|
81
|
-
"formatted-input": "^1.0.0",
|
|
76
|
+
"formatted-input": "^0.1.3",
|
|
82
77
|
"framer-motion": "^1.11.0",
|
|
83
78
|
"numeral": "^2.0.6",
|
|
84
79
|
"polished": "^4.0.3",
|
|
85
80
|
"ramda": "^0.27.0",
|
|
86
81
|
"react-aria-modal": "^4.0.0",
|
|
87
82
|
"react-pose": "^4.0.10",
|
|
88
|
-
"redux-freeform": "^5.1.0-beta.
|
|
83
|
+
"redux-freeform": "^5.1.0-beta.2"
|
|
89
84
|
}
|
|
90
85
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import resolve from "rollup-plugin-node-resolve";
|
|
2
|
+
import commonjs from "rollup-plugin-commonjs";
|
|
3
|
+
import babel from "rollup-plugin-babel";
|
|
4
|
+
import json from "rollup-plugin-json";
|
|
5
|
+
import visualizer from "rollup-plugin-visualizer";
|
|
6
|
+
import pkg from "./package.json";
|
|
7
|
+
|
|
8
|
+
import * as formattedInput from "formatted-input";
|
|
9
|
+
|
|
10
|
+
const globals = {
|
|
11
|
+
react: "React",
|
|
12
|
+
"react-dom": "ReactDOM"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const plugins = [
|
|
16
|
+
resolve({ preferBuiltins: false }),
|
|
17
|
+
babel({
|
|
18
|
+
exclude: "node_modules/**",
|
|
19
|
+
presets: ["@babel/env", "@babel/preset-react"]
|
|
20
|
+
}),
|
|
21
|
+
json(),
|
|
22
|
+
commonjs({
|
|
23
|
+
include: "node_modules/**",
|
|
24
|
+
namedExports: {
|
|
25
|
+
"formatted-input": Object.keys(formattedInput)
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
visualizer()
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const external = [...Object.keys(pkg.peerDependencies || {})];
|
|
32
|
+
|
|
33
|
+
const output_data = [
|
|
34
|
+
{
|
|
35
|
+
file: pkg.main,
|
|
36
|
+
format: "cjs"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
file: pkg.module,
|
|
40
|
+
format: "esm"
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
export default output_data.map(({ file, format }) => ({
|
|
45
|
+
input: "src/index.js",
|
|
46
|
+
output: {
|
|
47
|
+
file,
|
|
48
|
+
format,
|
|
49
|
+
globals
|
|
50
|
+
},
|
|
51
|
+
plugins,
|
|
52
|
+
external
|
|
53
|
+
}));
|
|
@@ -15,7 +15,7 @@ Styling accomplished with our atoms / layout primitives
|
|
|
15
15
|
|
|
16
16
|
Cancel button will (for now) always use hideModal as its action
|
|
17
17
|
Continue button takes an action, if you want to navigate to
|
|
18
|
-
a different route (as with a link) connect() and use "push" from
|
|
18
|
+
a different route (as with a link) connect() and use "push" from connected-react-router
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
const getApplicationNode = () => document.getElementById("root");
|
|
@@ -1,61 +1,59 @@
|
|
|
1
|
-
//
|
|
1
|
+
//
|
|
2
2
|
|
|
3
|
-
import safeConcat from
|
|
3
|
+
import safeConcat from '../safeConcat';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
5
|
+
describe('safeConcat', () => {
|
|
6
6
|
beforeEach(() => {
|
|
7
7
|
console.error = jest.fn();
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
describe(
|
|
11
|
-
describe(
|
|
12
|
-
it(
|
|
13
|
-
const result = safeConcat(
|
|
10
|
+
describe('arg validation', () => {
|
|
11
|
+
describe('when values not an array', () => {
|
|
12
|
+
it('throws console error', () => {
|
|
13
|
+
const result = safeConcat('a', '-');
|
|
14
14
|
|
|
15
15
|
const errors = console.error.mock.calls;
|
|
16
16
|
expect(errors.length).toEqual(1);
|
|
17
17
|
|
|
18
18
|
const firstError = errors[0][0];
|
|
19
|
-
expect(firstError).toEqual(
|
|
20
|
-
"'values' needs to be an array. Recieved string"
|
|
21
|
-
);
|
|
19
|
+
expect(firstError).toEqual('\'values\' needs to be an array. Recieved string');
|
|
22
20
|
|
|
23
21
|
expect(result).toEqual(undefined);
|
|
24
22
|
});
|
|
25
23
|
});
|
|
26
24
|
});
|
|
27
25
|
|
|
28
|
-
describe(
|
|
29
|
-
it(
|
|
30
|
-
const result = safeConcat([
|
|
31
|
-
expect(result).toEqual(
|
|
26
|
+
describe('with valid values', () => {
|
|
27
|
+
it('concatinates strings with concatinator', () => {
|
|
28
|
+
const result = safeConcat(['a', 'b', 'c'], '-');
|
|
29
|
+
expect(result).toEqual('a-b-c');
|
|
32
30
|
});
|
|
33
31
|
|
|
34
|
-
it(
|
|
35
|
-
const result = safeConcat([
|
|
36
|
-
expect(result).toEqual(
|
|
32
|
+
it('stringifies the concatinator', () => {
|
|
33
|
+
const result = safeConcat(['a', 'b', 'c'], 1);
|
|
34
|
+
expect(result).toEqual('a1b1c');
|
|
37
35
|
});
|
|
38
36
|
|
|
39
|
-
it(
|
|
40
|
-
const result = safeConcat([
|
|
41
|
-
expect(result).toEqual(
|
|
37
|
+
it('removes falsey string values from values array', () => {
|
|
38
|
+
const result = safeConcat(['a', undefined, 'b', ''], '-');
|
|
39
|
+
expect(result).toEqual('a-b');
|
|
42
40
|
});
|
|
43
41
|
|
|
44
|
-
it(
|
|
45
|
-
const result = safeConcat([
|
|
46
|
-
expect(result).toEqual(
|
|
42
|
+
it('does not append concatinator single values arrays', () => {
|
|
43
|
+
const result = safeConcat(['a'], '-');
|
|
44
|
+
expect(result).toEqual('a');
|
|
47
45
|
});
|
|
48
46
|
|
|
49
|
-
it(
|
|
50
|
-
const result = safeConcat([
|
|
51
|
-
expect(result).toEqual(
|
|
47
|
+
it('does not append concatinator to single truthy values', () => {
|
|
48
|
+
const result = safeConcat(['a', undefined], '-');
|
|
49
|
+
expect(result).toEqual('a');
|
|
52
50
|
});
|
|
53
51
|
});
|
|
54
52
|
|
|
55
|
-
describe(
|
|
56
|
-
it(
|
|
57
|
-
const result = safeConcat([undefined],
|
|
58
|
-
expect(result).toEqual(
|
|
53
|
+
describe('with no valid values', () => {
|
|
54
|
+
it('returns empty string when no valid values', () => {
|
|
55
|
+
const result = safeConcat([undefined], '-');
|
|
56
|
+
expect(result).toEqual('');
|
|
59
57
|
});
|
|
60
58
|
});
|
|
61
59
|
});
|
|
@@ -1,128 +1,112 @@
|
|
|
1
|
-
//
|
|
1
|
+
//
|
|
2
2
|
|
|
3
|
-
import validateKeyType from
|
|
3
|
+
import validateKeyType from '../validateKeyType';
|
|
4
4
|
|
|
5
|
-
describe(
|
|
5
|
+
describe('validateKeyType', () => {
|
|
6
6
|
const objParam = {
|
|
7
7
|
aArray: [1],
|
|
8
8
|
aBoolean: true,
|
|
9
9
|
aFunction: jest.fn(),
|
|
10
10
|
aNumber: 1,
|
|
11
|
-
aObject: { foo:
|
|
12
|
-
aString:
|
|
11
|
+
aObject: { foo: 'bar' },
|
|
12
|
+
aString: 'bar'
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
describe(
|
|
16
|
-
it(
|
|
17
|
-
const result = validateKeyType(objParam,
|
|
15
|
+
describe('when obj param does not contain key param', () => {
|
|
16
|
+
it('returns false', () => {
|
|
17
|
+
const result = validateKeyType(objParam, 'wrong-key', 'string');
|
|
18
18
|
expect(result).toEqual(false);
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
describe(
|
|
23
|
-
describe(
|
|
24
|
-
describe(
|
|
25
|
-
describe(
|
|
26
|
-
it(
|
|
27
|
-
const arrayResult = validateKeyType(objParam,
|
|
22
|
+
describe('when obj param contains key param', () => {
|
|
23
|
+
describe('when obj[key] type', () => {
|
|
24
|
+
describe('matches type param', () => {
|
|
25
|
+
describe('of Array', () => {
|
|
26
|
+
it('returns true', () => {
|
|
27
|
+
const arrayResult = validateKeyType(objParam, 'aArray', 'array');
|
|
28
28
|
expect(arrayResult).toEqual(true);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
describe(
|
|
33
|
-
it(
|
|
34
|
-
const arrayResult = validateKeyType(
|
|
35
|
-
objParam,
|
|
36
|
-
"aBoolean",
|
|
37
|
-
"boolean"
|
|
38
|
-
);
|
|
32
|
+
describe('of Boolean', () => {
|
|
33
|
+
it('returns true', () => {
|
|
34
|
+
const arrayResult = validateKeyType(objParam, 'aBoolean', 'boolean');
|
|
39
35
|
expect(arrayResult).toEqual(true);
|
|
40
36
|
});
|
|
41
37
|
});
|
|
42
38
|
|
|
43
|
-
describe(
|
|
44
|
-
it(
|
|
45
|
-
const arrayResult = validateKeyType(
|
|
46
|
-
objParam,
|
|
47
|
-
"aFunction",
|
|
48
|
-
"function"
|
|
49
|
-
);
|
|
39
|
+
describe('of Function', () => {
|
|
40
|
+
it('returns true', () => {
|
|
41
|
+
const arrayResult = validateKeyType(objParam, 'aFunction', 'function');
|
|
50
42
|
expect(arrayResult).toEqual(true);
|
|
51
43
|
});
|
|
52
44
|
});
|
|
53
45
|
|
|
54
|
-
describe(
|
|
55
|
-
it(
|
|
56
|
-
const arrayResult = validateKeyType(objParam,
|
|
46
|
+
describe('of Number', () => {
|
|
47
|
+
it('returns true', () => {
|
|
48
|
+
const arrayResult = validateKeyType(objParam, 'aNumber', 'number');
|
|
57
49
|
expect(arrayResult).toEqual(true);
|
|
58
50
|
});
|
|
59
51
|
});
|
|
60
52
|
|
|
61
|
-
describe(
|
|
62
|
-
it(
|
|
63
|
-
const arrayResult = validateKeyType(objParam,
|
|
53
|
+
describe('of Object', () => {
|
|
54
|
+
it('returns true', () => {
|
|
55
|
+
const arrayResult = validateKeyType(objParam, 'aObject', 'object');
|
|
64
56
|
expect(arrayResult).toEqual(true);
|
|
65
57
|
});
|
|
66
58
|
});
|
|
67
59
|
|
|
68
|
-
describe(
|
|
69
|
-
it(
|
|
70
|
-
const arrayResult = validateKeyType(objParam,
|
|
60
|
+
describe('of String', () => {
|
|
61
|
+
it('returns true', () => {
|
|
62
|
+
const arrayResult = validateKeyType(objParam, 'aString', 'string');
|
|
71
63
|
expect(arrayResult).toEqual(true);
|
|
72
64
|
});
|
|
73
65
|
});
|
|
74
66
|
});
|
|
75
67
|
|
|
76
|
-
describe(
|
|
77
|
-
describe(
|
|
78
|
-
it(
|
|
79
|
-
const arrayResult = validateKeyType(objParam,
|
|
68
|
+
describe('does not match type param', () => {
|
|
69
|
+
describe('of Array', () => {
|
|
70
|
+
it('returns false', () => {
|
|
71
|
+
const arrayResult = validateKeyType(objParam, 'aArray', 'string');
|
|
80
72
|
expect(arrayResult).toEqual(false);
|
|
81
73
|
|
|
82
|
-
const arrayObjResult = validateKeyType(
|
|
83
|
-
objParam,
|
|
84
|
-
"aArray",
|
|
85
|
-
"object"
|
|
86
|
-
);
|
|
74
|
+
const arrayObjResult = validateKeyType(objParam, 'aArray', 'object');
|
|
87
75
|
expect(arrayObjResult).toEqual(false);
|
|
88
76
|
});
|
|
89
77
|
});
|
|
90
78
|
|
|
91
|
-
describe(
|
|
92
|
-
it(
|
|
93
|
-
const arrayResult = validateKeyType(objParam,
|
|
79
|
+
describe('of Boolean', () => {
|
|
80
|
+
it('returns false', () => {
|
|
81
|
+
const arrayResult = validateKeyType(objParam, 'aBoolean', 'string');
|
|
94
82
|
expect(arrayResult).toEqual(false);
|
|
95
83
|
});
|
|
96
84
|
});
|
|
97
85
|
|
|
98
|
-
describe(
|
|
99
|
-
it(
|
|
100
|
-
const arrayResult = validateKeyType(
|
|
101
|
-
objParam,
|
|
102
|
-
"aFunction",
|
|
103
|
-
"string"
|
|
104
|
-
);
|
|
86
|
+
describe('of Function', () => {
|
|
87
|
+
it('returns false', () => {
|
|
88
|
+
const arrayResult = validateKeyType(objParam, 'aFunction', 'string');
|
|
105
89
|
expect(arrayResult).toEqual(false);
|
|
106
90
|
});
|
|
107
91
|
});
|
|
108
92
|
|
|
109
|
-
describe(
|
|
110
|
-
it(
|
|
111
|
-
const arrayResult = validateKeyType(objParam,
|
|
93
|
+
describe('of Number', () => {
|
|
94
|
+
it('returns false', () => {
|
|
95
|
+
const arrayResult = validateKeyType(objParam, 'aNumber', 'string');
|
|
112
96
|
expect(arrayResult).toEqual(false);
|
|
113
97
|
});
|
|
114
98
|
});
|
|
115
99
|
|
|
116
|
-
describe(
|
|
117
|
-
it(
|
|
118
|
-
const arrayResult = validateKeyType(objParam,
|
|
100
|
+
describe('of Object', () => {
|
|
101
|
+
it('returns false', () => {
|
|
102
|
+
const arrayResult = validateKeyType(objParam, 'aObject', 'string');
|
|
119
103
|
expect(arrayResult).toEqual(false);
|
|
120
104
|
});
|
|
121
105
|
});
|
|
122
106
|
|
|
123
|
-
describe(
|
|
124
|
-
it(
|
|
125
|
-
const arrayResult = validateKeyType(objParam,
|
|
107
|
+
describe('of String', () => {
|
|
108
|
+
it('returns false', () => {
|
|
109
|
+
const arrayResult = validateKeyType(objParam, 'aString', 'number');
|
|
126
110
|
expect(arrayResult).toEqual(false);
|
|
127
111
|
});
|
|
128
112
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as safeConcat } from
|
|
2
|
-
export { default as validateKeyType } from
|
|
1
|
+
export { default as safeConcat } from './safeConcat';
|
|
2
|
+
export { default as validateKeyType } from './validateKeyType';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//
|
|
1
|
+
//
|
|
2
2
|
|
|
3
|
-
export default function safeConcat(values, concatinator) {
|
|
3
|
+
export default function safeConcat(values , concatinator ) {
|
|
4
4
|
if (!Array.isArray(values)) {
|
|
5
5
|
console.error(`'values' needs to be an array. Recieved ${typeof values}`);
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
return values.filter(val => !!val).join(String(concatinator));
|
|
9
|
+
return values.filter((val ) => !!val).join(String(concatinator));
|
|
10
10
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
//
|
|
1
|
+
//
|
|
2
2
|
|
|
3
|
-
export default function validateKeyType(obj,
|
|
3
|
+
export default function validateKeyType(obj ,
|
|
4
|
+
expectedKey ,
|
|
5
|
+
expectedType ) {
|
|
4
6
|
if (!(expectedKey in obj)) {
|
|
5
7
|
return false;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
if (expectedType ===
|
|
10
|
+
if (expectedType === 'object' && Array.isArray(obj[expectedKey])) {
|
|
9
11
|
return false;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
if (expectedType ===
|
|
14
|
+
if (expectedType === 'array' && Array.isArray(obj[expectedKey])) {
|
|
13
15
|
return true;
|
|
14
16
|
}
|
|
15
17
|
|