carbon-react 105.2.0 → 106.0.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/esm/__internal__/tooltip-provider/index.js +1 -1
- package/esm/__internal__/utils/helpers/browser/index.d.ts +15 -1
- package/esm/__internal__/utils/helpers/browser/index.js +33 -1
- package/esm/__internal__/utils/helpers/browser-type-check/index.d.ts +7 -1
- package/esm/__internal__/utils/helpers/browser-type-check/index.js +8 -1
- package/esm/__internal__/utils/helpers/events/composedPath.d.ts +1 -1
- package/esm/__internal__/utils/helpers/events/events.d.ts +132 -31
- package/esm/__internal__/utils/helpers/events/events.js +10 -125
- package/esm/__internal__/utils/helpers/guid/index.d.ts +5 -0
- package/esm/__internal__/utils/helpers/guid/{guid.js → index.js} +0 -2
- package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +4 -2
- package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +2 -1
- package/esm/__internal__/utils/helpers/tags/tags.d.ts +10 -6
- package/esm/__internal__/utils/helpers/tags/tags.js +2 -6
- package/esm/__internal__/utils/helpers/useUniqueId/index.d.ts +2 -0
- package/esm/__internal__/utils/helpers/useUniqueId/index.js +7 -0
- package/esm/__internal__/utils/logger/index.d.ts +5 -1
- package/esm/__internal__/utils/logger/index.js +25 -1
- package/esm/components/app-wrapper/app-wrapper.component.js +5 -3
- package/esm/components/confirm/confirm.component.js +1 -1
- package/esm/components/dialog/dialog.component.js +1 -1
- package/esm/components/dialog-full-screen/dialog-full-screen.component.js +1 -1
- package/esm/components/fieldset/fieldset.component.d.ts +6 -1
- package/esm/components/fieldset/fieldset.component.js +14 -15
- package/esm/components/portrait/portrait-initials.component.js +1 -1
- package/esm/components/select/select-list/select-list.component.js +1 -1
- package/esm/components/select/select-textbox/select-textbox.component.js +1 -1
- package/esm/components/split-button/index.d.ts +1 -0
- package/esm/components/tabs/__internal__/tab-title/tab-title.style.js +3 -5
- package/esm/components/textbox/textbox.component.d.ts +1 -2
- package/esm/components/textbox/textbox.component.js +7 -6
- package/esm/style/{fonts → assets}/carbon-icons-webfont.woff +0 -0
- package/esm/style/fonts.css +30 -0
- package/esm/style/global-style.js +1 -1
- package/esm/style/themes/base/base-theme.config.d.ts +17 -8
- package/esm/style/themes/sage/index.d.ts +17 -8
- package/lib/__internal__/tooltip-provider/index.js +1 -1
- package/lib/__internal__/utils/helpers/browser/index.d.ts +15 -1
- package/lib/__internal__/utils/helpers/browser/index.js +33 -8
- package/lib/__internal__/utils/helpers/browser-type-check/index.d.ts +7 -1
- package/lib/__internal__/utils/helpers/browser-type-check/index.js +10 -21
- package/lib/__internal__/utils/helpers/events/composedPath.d.ts +1 -1
- package/lib/__internal__/utils/helpers/events/events.d.ts +132 -31
- package/lib/__internal__/utils/helpers/events/events.js +10 -125
- package/lib/__internal__/utils/helpers/guid/index.d.ts +5 -0
- package/lib/__internal__/utils/helpers/guid/{guid.js → index.js} +0 -2
- package/lib/__internal__/utils/helpers/guid/package.json +5 -2
- package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +4 -2
- package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +2 -1
- package/lib/__internal__/utils/helpers/tags/tags.d.ts +10 -6
- package/lib/__internal__/utils/helpers/tags/tags.js +2 -6
- package/lib/__internal__/utils/helpers/useUniqueId/index.d.ts +2 -0
- package/lib/__internal__/utils/helpers/useUniqueId/index.js +20 -0
- package/lib/__internal__/utils/helpers/useUniqueId/package.json +6 -0
- package/lib/__internal__/utils/logger/index.d.ts +5 -1
- package/lib/__internal__/utils/logger/index.js +26 -8
- package/lib/components/app-wrapper/app-wrapper.component.js +5 -4
- package/lib/components/confirm/confirm.component.js +1 -1
- package/lib/components/dialog/dialog.component.js +1 -1
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +1 -1
- package/lib/components/fieldset/fieldset.component.d.ts +6 -1
- package/lib/components/fieldset/fieldset.component.js +14 -16
- package/lib/components/portrait/portrait-initials.component.js +1 -1
- package/lib/components/select/select-list/select-list.component.js +1 -1
- package/lib/components/select/select-textbox/select-textbox.component.js +1 -1
- package/lib/components/split-button/index.d.ts +1 -0
- package/lib/components/tabs/__internal__/tab-title/tab-title.style.js +3 -5
- package/lib/components/textbox/textbox.component.d.ts +1 -2
- package/lib/components/textbox/textbox.component.js +7 -8
- package/lib/style/{fonts → assets}/carbon-icons-webfont.woff +0 -0
- package/lib/style/fonts.css +30 -0
- package/lib/style/global-style.js +1 -1
- package/lib/style/themes/base/base-theme.config.d.ts +17 -8
- package/lib/style/themes/sage/index.d.ts +17 -8
- package/package.json +4 -3
- package/esm/__internal__/utils/ether/ether.d.ts +0 -19
- package/esm/__internal__/utils/ether/ether.js +0 -29
- package/esm/__internal__/utils/ether/index.d.ts +0 -1
- package/esm/__internal__/utils/ether/index.js +0 -1
- package/esm/__internal__/utils/helpers/browser/browser.d.ts +0 -17
- package/esm/__internal__/utils/helpers/browser/browser.js +0 -198
- package/esm/__internal__/utils/helpers/browser-type-check/browser-type-check.d.ts +0 -7
- package/esm/__internal__/utils/helpers/browser-type-check/browser-type-check.js +0 -14
- package/esm/__internal__/utils/helpers/guid/__spec__.d.ts +0 -1
- package/esm/__internal__/utils/helpers/guid/__spec__.js +0 -10
- package/esm/__internal__/utils/helpers/guid/guid.d.ts +0 -2
- package/esm/__internal__/utils/helpers/guid/package.json +0 -3
- package/esm/__internal__/utils/helpers/immutable/__spec__.d.ts +0 -1
- package/esm/__internal__/utils/helpers/immutable/__spec__.js +0 -117
- package/esm/__internal__/utils/helpers/immutable/immutable.d.ts +0 -4
- package/esm/__internal__/utils/helpers/immutable/immutable.js +0 -36
- package/esm/__internal__/utils/helpers/immutable/package.json +0 -4
- package/esm/__internal__/utils/helpers/with-unique-id-props/index.d.ts +0 -1
- package/esm/__internal__/utils/helpers/with-unique-id-props/index.js +0 -1
- package/esm/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.d.ts +0 -7
- package/esm/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.js +0 -82
- package/esm/__internal__/utils/logger/logger.d.ts +0 -9
- package/esm/__internal__/utils/logger/logger.js +0 -71
- package/lib/__internal__/utils/ether/ether.d.ts +0 -19
- package/lib/__internal__/utils/ether/ether.js +0 -33
- package/lib/__internal__/utils/ether/index.d.ts +0 -1
- package/lib/__internal__/utils/ether/index.js +0 -18
- package/lib/__internal__/utils/ether/package.json +0 -6
- package/lib/__internal__/utils/helpers/browser/browser.d.ts +0 -17
- package/lib/__internal__/utils/helpers/browser/browser.js +0 -213
- package/lib/__internal__/utils/helpers/browser-type-check/browser-type-check.d.ts +0 -7
- package/lib/__internal__/utils/helpers/browser-type-check/browser-type-check.js +0 -26
- package/lib/__internal__/utils/helpers/guid/__spec__.d.ts +0 -1
- package/lib/__internal__/utils/helpers/guid/__spec__.js +0 -15
- package/lib/__internal__/utils/helpers/guid/guid.d.ts +0 -2
- package/lib/__internal__/utils/helpers/immutable/__spec__.d.ts +0 -1
- package/lib/__internal__/utils/helpers/immutable/__spec__.js +0 -135
- package/lib/__internal__/utils/helpers/immutable/immutable.d.ts +0 -4
- package/lib/__internal__/utils/helpers/immutable/immutable.js +0 -46
- package/lib/__internal__/utils/helpers/immutable/package.json +0 -4
- package/lib/__internal__/utils/helpers/with-unique-id-props/index.d.ts +0 -1
- package/lib/__internal__/utils/helpers/with-unique-id-props/index.js +0 -15
- package/lib/__internal__/utils/helpers/with-unique-id-props/package.json +0 -6
- package/lib/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.d.ts +0 -7
- package/lib/__internal__/utils/helpers/with-unique-id-props/with-unique-id-props.hoc.js +0 -96
- package/lib/__internal__/utils/logger/logger.d.ts +0 -9
- package/lib/__internal__/utils/logger/logger.js +0 -78
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export default Browser;
|
|
2
|
-
declare namespace Browser {
|
|
3
|
-
function isDomAvailable(): boolean;
|
|
4
|
-
function getWindow(): any;
|
|
5
|
-
function getDocument(): Document;
|
|
6
|
-
function getActiveElement(): Element | null;
|
|
7
|
-
function redirectTo(url: any): void;
|
|
8
|
-
function redirectAfter(url: any, seconds: any): NodeJS.Timeout;
|
|
9
|
-
function reload(): void;
|
|
10
|
-
function editFocus(ref: any): void;
|
|
11
|
-
function setFocus(reactNode: any): void;
|
|
12
|
-
function setInputFocus(inputComponent: any): void;
|
|
13
|
-
function setCookie(name: any, value: any, options?: Object): void;
|
|
14
|
-
function getCookie(name: string): string | null;
|
|
15
|
-
function postToNewWindow(url: string, data: Object, target?: Object): void;
|
|
16
|
-
function submitForm(form: any): void;
|
|
17
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Browser Helper
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* Provides helper methods for working with Browser behavior.
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
const Browser = {
|
|
24
|
-
isDomAvailable: () => {
|
|
25
|
-
const _window = Browser.getWindow();
|
|
26
|
-
|
|
27
|
-
const _document = Browser.getDocument();
|
|
28
|
-
|
|
29
|
-
return !!(typeof _window !== "undefined" && _document && _document.createElement);
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Get the current window
|
|
34
|
-
*
|
|
35
|
-
* @return window
|
|
36
|
-
*/
|
|
37
|
-
getWindow: () => {
|
|
38
|
-
return global.window;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Get the current document
|
|
43
|
-
*
|
|
44
|
-
* @return window
|
|
45
|
-
*/
|
|
46
|
-
getDocument: () => {
|
|
47
|
-
return document;
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Get the current activeElement
|
|
52
|
-
*
|
|
53
|
-
* @return HTMLElement
|
|
54
|
-
*/
|
|
55
|
-
getActiveElement: () => {
|
|
56
|
-
const doc = Browser.getDocument();
|
|
57
|
-
return doc.activeElement;
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Redirect to URL
|
|
62
|
-
*
|
|
63
|
-
* @method redirectTo
|
|
64
|
-
* @param url => URL string format
|
|
65
|
-
*/
|
|
66
|
-
redirectTo: url => {
|
|
67
|
-
Browser.getWindow().location = url;
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Redirects to URL after the given number of seconds have elapsed
|
|
72
|
-
*
|
|
73
|
-
* @method redirectAfter
|
|
74
|
-
* @param url => URL string format
|
|
75
|
-
* @param seconds => the number of seconds to wait before redirecting
|
|
76
|
-
*/
|
|
77
|
-
redirectAfter: (url, seconds) => {
|
|
78
|
-
return setTimeout(() => Browser.redirectTo(url), seconds * 1000);
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Reload the current page
|
|
83
|
-
*
|
|
84
|
-
* @method reload
|
|
85
|
-
*/
|
|
86
|
-
reload: () => {
|
|
87
|
-
Browser.getWindow().location.reload();
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Focuses and sets cursor of input field
|
|
92
|
-
*
|
|
93
|
-
* @method editFocus
|
|
94
|
-
*/
|
|
95
|
-
editFocus: ref => {
|
|
96
|
-
const node = _reactDom.default.findDOMNode(ref._input); // eslint-disable-line react/no-find-dom-node
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
node.focus();
|
|
100
|
-
node.select();
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Focuses and sets cursor of react node
|
|
105
|
-
*
|
|
106
|
-
* @method setFocus
|
|
107
|
-
*/
|
|
108
|
-
setFocus: reactNode => {
|
|
109
|
-
const node = _reactDom.default.findDOMNode(reactNode); // eslint-disable-line react/no-find-dom-node
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
node.focus();
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Focuses and sets cursor of input field but does not select text
|
|
117
|
-
*
|
|
118
|
-
* @method setInputFocus
|
|
119
|
-
*/
|
|
120
|
-
setInputFocus: inputComponent => {
|
|
121
|
-
Browser.setFocus(inputComponent._input);
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Sets a cookie where name=value
|
|
126
|
-
*
|
|
127
|
-
* @param {Object} options includes expires or max-age
|
|
128
|
-
* @method setCookie
|
|
129
|
-
*/
|
|
130
|
-
setCookie: (name, value, options = {}) => {
|
|
131
|
-
let cookie = `${name}=${value}`;
|
|
132
|
-
|
|
133
|
-
if (options.expires) {
|
|
134
|
-
cookie += `; expires=${options.expires}`;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (options["max-age"]) {
|
|
138
|
-
cookie += `; max-age=${options["max-age"]}`;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
Browser.getDocument().cookie = cookie;
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Returns a cookies value by passed name
|
|
146
|
-
*
|
|
147
|
-
* @param {String} name cookie name key
|
|
148
|
-
* @method getCookieValueByName
|
|
149
|
-
*/
|
|
150
|
-
getCookie: name => {
|
|
151
|
-
const cookies = Browser.getDocument().cookie.split(";");
|
|
152
|
-
|
|
153
|
-
for (let i = 0; i < cookies.length; i++) {
|
|
154
|
-
const cookie = cookies[i].trim().split("=");
|
|
155
|
-
|
|
156
|
-
if (cookie[0] === name) {
|
|
157
|
-
return cookie[1];
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return null;
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Submits POST in new window
|
|
166
|
-
*
|
|
167
|
-
* @method postToNewWindow
|
|
168
|
-
* @param {String} url URL to POST to
|
|
169
|
-
* @param {Object} data Data to POST
|
|
170
|
-
* @param {Object} target Optional target window name
|
|
171
|
-
* @return {Void}
|
|
172
|
-
*/
|
|
173
|
-
postToNewWindow: (url, data, target = "_blank") => {
|
|
174
|
-
const doc = Browser.getDocument(),
|
|
175
|
-
containerId = "carbonPostFormContainer";
|
|
176
|
-
let container = doc.getElementById(containerId);
|
|
177
|
-
|
|
178
|
-
if (!container) {
|
|
179
|
-
container = doc.createElement("div");
|
|
180
|
-
container.setAttribute("id", containerId);
|
|
181
|
-
doc.body.appendChild(container);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
_reactDom.default.render( /*#__PURE__*/_react.default.createElement("form", {
|
|
185
|
-
action: url,
|
|
186
|
-
method: "post",
|
|
187
|
-
target: target
|
|
188
|
-
}, (0, _lodash.keys)(data).map(key => {
|
|
189
|
-
return /*#__PURE__*/_react.default.createElement("input", {
|
|
190
|
-
type: "hidden",
|
|
191
|
-
key: key,
|
|
192
|
-
name: key,
|
|
193
|
-
value: data[key]
|
|
194
|
-
});
|
|
195
|
-
})), container, function () {
|
|
196
|
-
Browser.submitForm(this);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
_reactDom.default.unmountComponentAtNode(container);
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Submits a passed Form
|
|
204
|
-
*
|
|
205
|
-
* @method submitForm
|
|
206
|
-
* @param {HTML Form} form to submit
|
|
207
|
-
*/
|
|
208
|
-
submitForm: form => {
|
|
209
|
-
form.submit();
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
var _default = Browser;
|
|
213
|
-
exports.default = _default;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isSafari = isSafari;
|
|
7
|
-
exports.isEdge = isEdge;
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Check for Chrome or Firefox.
|
|
12
|
-
*/
|
|
13
|
-
function browserTypeCheck(_window) {
|
|
14
|
-
return Boolean(_window.chrome || _window.sidebar);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function isSafari(navigator) {
|
|
18
|
-
return navigator.vendor.includes("Apple");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function isEdge(navigator) {
|
|
22
|
-
return navigator.userAgent.includes("Edge");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var _default = browserTypeCheck;
|
|
26
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _guid = _interopRequireDefault(require("./guid"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
describe("guid", () => {
|
|
8
|
-
it("returns a 36 character id", () => {
|
|
9
|
-
expect((0, _guid.default)().length).toEqual(36);
|
|
10
|
-
});
|
|
11
|
-
it("returns a unique id", () => {
|
|
12
|
-
const id = (0, _guid.default)();
|
|
13
|
-
expect((0, _guid.default)()).not.toEqual(id);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _immutable = _interopRequireDefault(require("immutable"));
|
|
4
|
-
|
|
5
|
-
var _immutable2 = _interopRequireDefault(require("./immutable"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
|
-
describe("Immutable Helper", () => {
|
|
10
|
-
describe("parseJSON", () => {
|
|
11
|
-
describe("when the passed json is not an object", () => {
|
|
12
|
-
it("returns the json", () => {
|
|
13
|
-
expect(_immutable2.default.parseJSON("a")).toEqual("a");
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
describe("when the passed json is null", () => {
|
|
17
|
-
it("returns null", () => {
|
|
18
|
-
expect(_immutable2.default.parseJSON(null)).toBeNull();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe("when the JSON is a simple array", () => {
|
|
22
|
-
let data, expectedData, result;
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
data = ["a", "b", "c"];
|
|
25
|
-
expectedData = _immutable.default.Seq(data).toList();
|
|
26
|
-
result = _immutable2.default.parseJSON(data);
|
|
27
|
-
});
|
|
28
|
-
it("returns a immutable object of that array", () => {
|
|
29
|
-
expect(result).toEqual(expectedData);
|
|
30
|
-
expect(result.get(0)).toEqual("a");
|
|
31
|
-
expect(result.get(1)).toEqual("b");
|
|
32
|
-
expect(result.get(2)).toEqual("c");
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe("when the JSON object is a array of objects", () => {
|
|
36
|
-
let data, result;
|
|
37
|
-
it("returns a immutable object of that array", () => {
|
|
38
|
-
data = [{
|
|
39
|
-
foo: "a"
|
|
40
|
-
}, {
|
|
41
|
-
bar: "b"
|
|
42
|
-
}, {
|
|
43
|
-
baz: "c"
|
|
44
|
-
}];
|
|
45
|
-
result = _immutable2.default.parseJSON(data);
|
|
46
|
-
expect(result.get(0).get("foo")).toEqual("a");
|
|
47
|
-
expect(result.get(1).get("bar")).toEqual("b");
|
|
48
|
-
expect(result.get(2).get("baz")).toEqual("c");
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe("when JSON is a object", () => {
|
|
52
|
-
let data, expectedData;
|
|
53
|
-
beforeEach(() => {
|
|
54
|
-
data = {
|
|
55
|
-
foo: "bar",
|
|
56
|
-
baz: "qux"
|
|
57
|
-
};
|
|
58
|
-
expectedData = _immutable.default.Seq(data).toMap();
|
|
59
|
-
});
|
|
60
|
-
it("returns a ordered immutable map", () => {
|
|
61
|
-
const result = _immutable2.default.parseJSON(data);
|
|
62
|
-
|
|
63
|
-
expect(result).toEqual(expectedData);
|
|
64
|
-
expect(result.get("foo")).toEqual("bar");
|
|
65
|
-
expect(result.get("baz")).toEqual("qux");
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
describe("when JSON is a complex value with nest arrays and objects", () => {
|
|
69
|
-
let data, expectedData;
|
|
70
|
-
beforeEach(() => {
|
|
71
|
-
data = [{
|
|
72
|
-
foo: "bar",
|
|
73
|
-
baz: "qux"
|
|
74
|
-
}, {
|
|
75
|
-
a: ["a", "b", "c"],
|
|
76
|
-
b: "b"
|
|
77
|
-
}];
|
|
78
|
-
|
|
79
|
-
const obj1 = _immutable.default.Seq({
|
|
80
|
-
foo: "bar",
|
|
81
|
-
baz: "qux"
|
|
82
|
-
}).toMap();
|
|
83
|
-
|
|
84
|
-
const array1 = _immutable.default.Seq(["a", "b", "c"]).toList();
|
|
85
|
-
|
|
86
|
-
const obj2 = _immutable.default.Seq({
|
|
87
|
-
a: array1,
|
|
88
|
-
b: "b"
|
|
89
|
-
}).toMap();
|
|
90
|
-
|
|
91
|
-
expectedData = _immutable.default.Seq([obj1, obj2]).toList();
|
|
92
|
-
});
|
|
93
|
-
it("creates a immutable object in the same format", () => {
|
|
94
|
-
const result = _immutable2.default.parseJSON(data);
|
|
95
|
-
|
|
96
|
-
expect(result.toJS()).toEqual(expectedData.toJS());
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
describe("when passed a number", () => {
|
|
100
|
-
it("casts it to a string", () => {
|
|
101
|
-
expect(_immutable2.default.parseJSON(1)).toEqual(_immutable.default.fromJS("1"));
|
|
102
|
-
expect(_immutable2.default.parseJSON(3.142)).toEqual(_immutable.default.fromJS("3.142"));
|
|
103
|
-
});
|
|
104
|
-
describe("as a nested element", () => {
|
|
105
|
-
it("casts all numbers to a string", () => {
|
|
106
|
-
const data = [{
|
|
107
|
-
foo: "bar",
|
|
108
|
-
baz: "qux"
|
|
109
|
-
}, {
|
|
110
|
-
a: [1, 2, "c"],
|
|
111
|
-
b: 2
|
|
112
|
-
}];
|
|
113
|
-
|
|
114
|
-
const obj1 = _immutable.default.Seq({
|
|
115
|
-
foo: "bar",
|
|
116
|
-
baz: "qux"
|
|
117
|
-
}).toMap();
|
|
118
|
-
|
|
119
|
-
const array1 = _immutable.default.Seq(["1", "2", "c"]).toList();
|
|
120
|
-
|
|
121
|
-
const obj2 = _immutable.default.Seq({
|
|
122
|
-
a: array1,
|
|
123
|
-
b: "2"
|
|
124
|
-
}).toMap();
|
|
125
|
-
|
|
126
|
-
const expectedData = _immutable.default.Seq([obj1, obj2]).toList();
|
|
127
|
-
|
|
128
|
-
const result = _immutable2.default.parseJSON(data);
|
|
129
|
-
|
|
130
|
-
expect(result.toJS()).toEqual(expectedData.toJS());
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _immutable = _interopRequireDefault(require("immutable"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Immutable Helper
|
|
14
|
-
*
|
|
15
|
-
* Provides helper methods for working with immutable data.
|
|
16
|
-
*
|
|
17
|
-
* @object ImmutableHelper
|
|
18
|
-
* @param {String} name
|
|
19
|
-
* @param {Object} form
|
|
20
|
-
*/
|
|
21
|
-
const ImmutableHelper = {
|
|
22
|
-
/**
|
|
23
|
-
* Parses a regular JSON object into an Immutable data object, mapping the data
|
|
24
|
-
* correctly and applying custom transforms to make the data easier to work with.
|
|
25
|
-
*
|
|
26
|
-
* @method parseJSON
|
|
27
|
-
* @param {Object} js
|
|
28
|
-
*/
|
|
29
|
-
parseJSON: js => {
|
|
30
|
-
if (typeof js !== "object" || js === null) {
|
|
31
|
-
if (typeof js === "number") {
|
|
32
|
-
return String(js);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return js;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (Array.isArray(js)) {
|
|
39
|
-
return _immutable.default.Seq(js).map(ImmutableHelper.parseJSON).toList();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return _immutable.default.Seq(js).map(ImmutableHelper.parseJSON).toMap();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var _default = ImmutableHelper;
|
|
46
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./with-unique-id-props.hoc";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _withUniqueIdProps.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
var _withUniqueIdProps = _interopRequireDefault(require("./with-unique-id-props.hoc"));
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _guid = _interopRequireDefault(require("../guid"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
-
|
|
18
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
-
|
|
20
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
21
|
-
|
|
22
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
23
|
-
|
|
24
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
25
|
-
|
|
26
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
27
|
-
|
|
28
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
29
|
-
|
|
30
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
31
|
-
|
|
32
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
33
|
-
|
|
34
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
35
|
-
|
|
36
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
37
|
-
|
|
38
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
39
|
-
|
|
40
|
-
const withUniqueIdProps = WrappedComponent => {
|
|
41
|
-
let WithUniqueIdProps = /*#__PURE__*/function (_React$Component) {
|
|
42
|
-
_inherits(WithUniqueIdProps, _React$Component);
|
|
43
|
-
|
|
44
|
-
var _super = _createSuper(WithUniqueIdProps);
|
|
45
|
-
|
|
46
|
-
function WithUniqueIdProps(...args) {
|
|
47
|
-
var _this;
|
|
48
|
-
|
|
49
|
-
_classCallCheck(this, WithUniqueIdProps);
|
|
50
|
-
|
|
51
|
-
_this = _super.call(this, ...args);
|
|
52
|
-
|
|
53
|
-
_defineProperty(_assertThisInitialized(_this), "id", (0, _guid.default)());
|
|
54
|
-
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "name", (0, _guid.default)());
|
|
56
|
-
|
|
57
|
-
return _this;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_createClass(WithUniqueIdProps, [{
|
|
61
|
-
key: "render",
|
|
62
|
-
value: function render() {
|
|
63
|
-
const {
|
|
64
|
-
forwardedRef,
|
|
65
|
-
id,
|
|
66
|
-
...props
|
|
67
|
-
} = this.props;
|
|
68
|
-
return /*#__PURE__*/_react.default.createElement(WrappedComponent, _extends({
|
|
69
|
-
id: id || this.id,
|
|
70
|
-
name: this.name,
|
|
71
|
-
ref: forwardedRef
|
|
72
|
-
}, props));
|
|
73
|
-
}
|
|
74
|
-
}]);
|
|
75
|
-
|
|
76
|
-
return WithUniqueIdProps;
|
|
77
|
-
}(_react.default.Component);
|
|
78
|
-
|
|
79
|
-
WithUniqueIdProps.propTypes = {
|
|
80
|
-
forwardedRef: _propTypes.default.object,
|
|
81
|
-
id: _propTypes.default.string
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const Component = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
85
|
-
return /*#__PURE__*/_react.default.createElement(WithUniqueIdProps, _extends({}, props, {
|
|
86
|
-
forwardedRef: ref
|
|
87
|
-
}));
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const displayName = WrappedComponent.displayName || WrappedComponent.name || "WithUniqueIdProps(Unknown)";
|
|
91
|
-
Component.displayName = displayName.replace(/^Base/, "");
|
|
92
|
-
return Component;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
var _default = withUniqueIdProps;
|
|
96
|
-
exports.default = _default;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export default Logger;
|
|
2
|
-
declare namespace Logger {
|
|
3
|
-
function setEnabledState(newState: any): void;
|
|
4
|
-
function error(message: any, opts: any): void;
|
|
5
|
-
function info(message: any, opts: any): void;
|
|
6
|
-
function log(message: any, opts: any): void;
|
|
7
|
-
function warn(message: any, opts: any): void;
|
|
8
|
-
function deprecate(message: any, opts: any): void;
|
|
9
|
-
}
|