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,198 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ReactDOM from "react-dom";
|
|
3
|
-
import { keys } from "lodash";
|
|
4
|
-
/**
|
|
5
|
-
* Browser Helper
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* Provides helper methods for working with Browser behavior.
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const Browser = {
|
|
13
|
-
isDomAvailable: () => {
|
|
14
|
-
const _window = Browser.getWindow();
|
|
15
|
-
|
|
16
|
-
const _document = Browser.getDocument();
|
|
17
|
-
|
|
18
|
-
return !!(typeof _window !== "undefined" && _document && _document.createElement);
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Get the current window
|
|
23
|
-
*
|
|
24
|
-
* @return window
|
|
25
|
-
*/
|
|
26
|
-
getWindow: () => {
|
|
27
|
-
return global.window;
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Get the current document
|
|
32
|
-
*
|
|
33
|
-
* @return window
|
|
34
|
-
*/
|
|
35
|
-
getDocument: () => {
|
|
36
|
-
return document;
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get the current activeElement
|
|
41
|
-
*
|
|
42
|
-
* @return HTMLElement
|
|
43
|
-
*/
|
|
44
|
-
getActiveElement: () => {
|
|
45
|
-
const doc = Browser.getDocument();
|
|
46
|
-
return doc.activeElement;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Redirect to URL
|
|
51
|
-
*
|
|
52
|
-
* @method redirectTo
|
|
53
|
-
* @param url => URL string format
|
|
54
|
-
*/
|
|
55
|
-
redirectTo: url => {
|
|
56
|
-
Browser.getWindow().location = url;
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Redirects to URL after the given number of seconds have elapsed
|
|
61
|
-
*
|
|
62
|
-
* @method redirectAfter
|
|
63
|
-
* @param url => URL string format
|
|
64
|
-
* @param seconds => the number of seconds to wait before redirecting
|
|
65
|
-
*/
|
|
66
|
-
redirectAfter: (url, seconds) => {
|
|
67
|
-
return setTimeout(() => Browser.redirectTo(url), seconds * 1000);
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Reload the current page
|
|
72
|
-
*
|
|
73
|
-
* @method reload
|
|
74
|
-
*/
|
|
75
|
-
reload: () => {
|
|
76
|
-
Browser.getWindow().location.reload();
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Focuses and sets cursor of input field
|
|
81
|
-
*
|
|
82
|
-
* @method editFocus
|
|
83
|
-
*/
|
|
84
|
-
editFocus: ref => {
|
|
85
|
-
const node = ReactDOM.findDOMNode(ref._input); // eslint-disable-line react/no-find-dom-node
|
|
86
|
-
|
|
87
|
-
node.focus();
|
|
88
|
-
node.select();
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Focuses and sets cursor of react node
|
|
93
|
-
*
|
|
94
|
-
* @method setFocus
|
|
95
|
-
*/
|
|
96
|
-
setFocus: reactNode => {
|
|
97
|
-
const node = ReactDOM.findDOMNode(reactNode); // eslint-disable-line react/no-find-dom-node
|
|
98
|
-
|
|
99
|
-
node.focus();
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Focuses and sets cursor of input field but does not select text
|
|
104
|
-
*
|
|
105
|
-
* @method setInputFocus
|
|
106
|
-
*/
|
|
107
|
-
setInputFocus: inputComponent => {
|
|
108
|
-
Browser.setFocus(inputComponent._input);
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Sets a cookie where name=value
|
|
113
|
-
*
|
|
114
|
-
* @param {Object} options includes expires or max-age
|
|
115
|
-
* @method setCookie
|
|
116
|
-
*/
|
|
117
|
-
setCookie: (name, value, options = {}) => {
|
|
118
|
-
let cookie = `${name}=${value}`;
|
|
119
|
-
|
|
120
|
-
if (options.expires) {
|
|
121
|
-
cookie += `; expires=${options.expires}`;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (options["max-age"]) {
|
|
125
|
-
cookie += `; max-age=${options["max-age"]}`;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
Browser.getDocument().cookie = cookie;
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Returns a cookies value by passed name
|
|
133
|
-
*
|
|
134
|
-
* @param {String} name cookie name key
|
|
135
|
-
* @method getCookieValueByName
|
|
136
|
-
*/
|
|
137
|
-
getCookie: name => {
|
|
138
|
-
const cookies = Browser.getDocument().cookie.split(";");
|
|
139
|
-
|
|
140
|
-
for (let i = 0; i < cookies.length; i++) {
|
|
141
|
-
const cookie = cookies[i].trim().split("=");
|
|
142
|
-
|
|
143
|
-
if (cookie[0] === name) {
|
|
144
|
-
return cookie[1];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return null;
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Submits POST in new window
|
|
153
|
-
*
|
|
154
|
-
* @method postToNewWindow
|
|
155
|
-
* @param {String} url URL to POST to
|
|
156
|
-
* @param {Object} data Data to POST
|
|
157
|
-
* @param {Object} target Optional target window name
|
|
158
|
-
* @return {Void}
|
|
159
|
-
*/
|
|
160
|
-
postToNewWindow: (url, data, target = "_blank") => {
|
|
161
|
-
const doc = Browser.getDocument(),
|
|
162
|
-
containerId = "carbonPostFormContainer";
|
|
163
|
-
let container = doc.getElementById(containerId);
|
|
164
|
-
|
|
165
|
-
if (!container) {
|
|
166
|
-
container = doc.createElement("div");
|
|
167
|
-
container.setAttribute("id", containerId);
|
|
168
|
-
doc.body.appendChild(container);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
ReactDOM.render( /*#__PURE__*/React.createElement("form", {
|
|
172
|
-
action: url,
|
|
173
|
-
method: "post",
|
|
174
|
-
target: target
|
|
175
|
-
}, keys(data).map(key => {
|
|
176
|
-
return /*#__PURE__*/React.createElement("input", {
|
|
177
|
-
type: "hidden",
|
|
178
|
-
key: key,
|
|
179
|
-
name: key,
|
|
180
|
-
value: data[key]
|
|
181
|
-
});
|
|
182
|
-
})), container, function () {
|
|
183
|
-
Browser.submitForm(this);
|
|
184
|
-
});
|
|
185
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Submits a passed Form
|
|
190
|
-
*
|
|
191
|
-
* @method submitForm
|
|
192
|
-
* @param {HTML Form} form to submit
|
|
193
|
-
*/
|
|
194
|
-
submitForm: form => {
|
|
195
|
-
form.submit();
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
export default Browser;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check for Chrome or Firefox.
|
|
3
|
-
*/
|
|
4
|
-
function browserTypeCheck(_window) {
|
|
5
|
-
return Boolean(_window.chrome || _window.sidebar);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function isSafari(navigator) {
|
|
9
|
-
return navigator.vendor.includes("Apple");
|
|
10
|
-
}
|
|
11
|
-
export function isEdge(navigator) {
|
|
12
|
-
return navigator.userAgent.includes("Edge");
|
|
13
|
-
}
|
|
14
|
-
export default browserTypeCheck;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import Immutable from "immutable";
|
|
2
|
-
import ImmutableHelper from "./immutable";
|
|
3
|
-
describe("Immutable Helper", () => {
|
|
4
|
-
describe("parseJSON", () => {
|
|
5
|
-
describe("when the passed json is not an object", () => {
|
|
6
|
-
it("returns the json", () => {
|
|
7
|
-
expect(ImmutableHelper.parseJSON("a")).toEqual("a");
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
describe("when the passed json is null", () => {
|
|
11
|
-
it("returns null", () => {
|
|
12
|
-
expect(ImmutableHelper.parseJSON(null)).toBeNull();
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe("when the JSON is a simple array", () => {
|
|
16
|
-
let data, expectedData, result;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
data = ["a", "b", "c"];
|
|
19
|
-
expectedData = Immutable.Seq(data).toList();
|
|
20
|
-
result = ImmutableHelper.parseJSON(data);
|
|
21
|
-
});
|
|
22
|
-
it("returns a immutable object of that array", () => {
|
|
23
|
-
expect(result).toEqual(expectedData);
|
|
24
|
-
expect(result.get(0)).toEqual("a");
|
|
25
|
-
expect(result.get(1)).toEqual("b");
|
|
26
|
-
expect(result.get(2)).toEqual("c");
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe("when the JSON object is a array of objects", () => {
|
|
30
|
-
let data, result;
|
|
31
|
-
it("returns a immutable object of that array", () => {
|
|
32
|
-
data = [{
|
|
33
|
-
foo: "a"
|
|
34
|
-
}, {
|
|
35
|
-
bar: "b"
|
|
36
|
-
}, {
|
|
37
|
-
baz: "c"
|
|
38
|
-
}];
|
|
39
|
-
result = ImmutableHelper.parseJSON(data);
|
|
40
|
-
expect(result.get(0).get("foo")).toEqual("a");
|
|
41
|
-
expect(result.get(1).get("bar")).toEqual("b");
|
|
42
|
-
expect(result.get(2).get("baz")).toEqual("c");
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe("when JSON is a object", () => {
|
|
46
|
-
let data, expectedData;
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
data = {
|
|
49
|
-
foo: "bar",
|
|
50
|
-
baz: "qux"
|
|
51
|
-
};
|
|
52
|
-
expectedData = Immutable.Seq(data).toMap();
|
|
53
|
-
});
|
|
54
|
-
it("returns a ordered immutable map", () => {
|
|
55
|
-
const result = ImmutableHelper.parseJSON(data);
|
|
56
|
-
expect(result).toEqual(expectedData);
|
|
57
|
-
expect(result.get("foo")).toEqual("bar");
|
|
58
|
-
expect(result.get("baz")).toEqual("qux");
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe("when JSON is a complex value with nest arrays and objects", () => {
|
|
62
|
-
let data, expectedData;
|
|
63
|
-
beforeEach(() => {
|
|
64
|
-
data = [{
|
|
65
|
-
foo: "bar",
|
|
66
|
-
baz: "qux"
|
|
67
|
-
}, {
|
|
68
|
-
a: ["a", "b", "c"],
|
|
69
|
-
b: "b"
|
|
70
|
-
}];
|
|
71
|
-
const obj1 = Immutable.Seq({
|
|
72
|
-
foo: "bar",
|
|
73
|
-
baz: "qux"
|
|
74
|
-
}).toMap();
|
|
75
|
-
const array1 = Immutable.Seq(["a", "b", "c"]).toList();
|
|
76
|
-
const obj2 = Immutable.Seq({
|
|
77
|
-
a: array1,
|
|
78
|
-
b: "b"
|
|
79
|
-
}).toMap();
|
|
80
|
-
expectedData = Immutable.Seq([obj1, obj2]).toList();
|
|
81
|
-
});
|
|
82
|
-
it("creates a immutable object in the same format", () => {
|
|
83
|
-
const result = ImmutableHelper.parseJSON(data);
|
|
84
|
-
expect(result.toJS()).toEqual(expectedData.toJS());
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
describe("when passed a number", () => {
|
|
88
|
-
it("casts it to a string", () => {
|
|
89
|
-
expect(ImmutableHelper.parseJSON(1)).toEqual(Immutable.fromJS("1"));
|
|
90
|
-
expect(ImmutableHelper.parseJSON(3.142)).toEqual(Immutable.fromJS("3.142"));
|
|
91
|
-
});
|
|
92
|
-
describe("as a nested element", () => {
|
|
93
|
-
it("casts all numbers to a string", () => {
|
|
94
|
-
const data = [{
|
|
95
|
-
foo: "bar",
|
|
96
|
-
baz: "qux"
|
|
97
|
-
}, {
|
|
98
|
-
a: [1, 2, "c"],
|
|
99
|
-
b: 2
|
|
100
|
-
}];
|
|
101
|
-
const obj1 = Immutable.Seq({
|
|
102
|
-
foo: "bar",
|
|
103
|
-
baz: "qux"
|
|
104
|
-
}).toMap();
|
|
105
|
-
const array1 = Immutable.Seq(["1", "2", "c"]).toList();
|
|
106
|
-
const obj2 = Immutable.Seq({
|
|
107
|
-
a: array1,
|
|
108
|
-
b: "2"
|
|
109
|
-
}).toMap();
|
|
110
|
-
const expectedData = Immutable.Seq([obj1, obj2]).toList();
|
|
111
|
-
const result = ImmutableHelper.parseJSON(data);
|
|
112
|
-
expect(result.toJS()).toEqual(expectedData.toJS());
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import Immutable from "immutable";
|
|
2
|
-
/**
|
|
3
|
-
* Immutable Helper
|
|
4
|
-
*
|
|
5
|
-
* Provides helper methods for working with immutable data.
|
|
6
|
-
*
|
|
7
|
-
* @object ImmutableHelper
|
|
8
|
-
* @param {String} name
|
|
9
|
-
* @param {Object} form
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const ImmutableHelper = {
|
|
13
|
-
/**
|
|
14
|
-
* Parses a regular JSON object into an Immutable data object, mapping the data
|
|
15
|
-
* correctly and applying custom transforms to make the data easier to work with.
|
|
16
|
-
*
|
|
17
|
-
* @method parseJSON
|
|
18
|
-
* @param {Object} js
|
|
19
|
-
*/
|
|
20
|
-
parseJSON: js => {
|
|
21
|
-
if (typeof js !== "object" || js === null) {
|
|
22
|
-
if (typeof js === "number") {
|
|
23
|
-
return String(js);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return js;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (Array.isArray(js)) {
|
|
30
|
-
return Immutable.Seq(js).map(ImmutableHelper.parseJSON).toList();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return Immutable.Seq(js).map(ImmutableHelper.parseJSON).toMap();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
export default ImmutableHelper;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./with-unique-id-props.hoc";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./with-unique-id-props.hoc";
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
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); }
|
|
2
|
-
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
|
-
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); } }
|
|
6
|
-
|
|
7
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8
|
-
|
|
9
|
-
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); }
|
|
10
|
-
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
|
|
13
|
-
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); }; }
|
|
14
|
-
|
|
15
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
16
|
-
|
|
17
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
|
|
19
|
-
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; } }
|
|
20
|
-
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
|
|
25
|
-
import React from "react";
|
|
26
|
-
import PropTypes from "prop-types";
|
|
27
|
-
import guid from "../guid";
|
|
28
|
-
|
|
29
|
-
const withUniqueIdProps = WrappedComponent => {
|
|
30
|
-
let WithUniqueIdProps = /*#__PURE__*/function (_React$Component) {
|
|
31
|
-
_inherits(WithUniqueIdProps, _React$Component);
|
|
32
|
-
|
|
33
|
-
var _super = _createSuper(WithUniqueIdProps);
|
|
34
|
-
|
|
35
|
-
function WithUniqueIdProps(...args) {
|
|
36
|
-
var _this;
|
|
37
|
-
|
|
38
|
-
_classCallCheck(this, WithUniqueIdProps);
|
|
39
|
-
|
|
40
|
-
_this = _super.call(this, ...args);
|
|
41
|
-
|
|
42
|
-
_defineProperty(_assertThisInitialized(_this), "id", guid());
|
|
43
|
-
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "name", guid());
|
|
45
|
-
|
|
46
|
-
return _this;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
_createClass(WithUniqueIdProps, [{
|
|
50
|
-
key: "render",
|
|
51
|
-
value: function render() {
|
|
52
|
-
const {
|
|
53
|
-
forwardedRef,
|
|
54
|
-
id,
|
|
55
|
-
...props
|
|
56
|
-
} = this.props;
|
|
57
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({
|
|
58
|
-
id: id || this.id,
|
|
59
|
-
name: this.name,
|
|
60
|
-
ref: forwardedRef
|
|
61
|
-
}, props));
|
|
62
|
-
}
|
|
63
|
-
}]);
|
|
64
|
-
|
|
65
|
-
return WithUniqueIdProps;
|
|
66
|
-
}(React.Component);
|
|
67
|
-
|
|
68
|
-
WithUniqueIdProps.propTypes = {
|
|
69
|
-
forwardedRef: PropTypes.object,
|
|
70
|
-
id: PropTypes.string
|
|
71
|
-
};
|
|
72
|
-
const Component = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
73
|
-
return /*#__PURE__*/React.createElement(WithUniqueIdProps, _extends({}, props, {
|
|
74
|
-
forwardedRef: ref
|
|
75
|
-
}));
|
|
76
|
-
});
|
|
77
|
-
const displayName = WrappedComponent.displayName || WrappedComponent.name || "WithUniqueIdProps(Unknown)";
|
|
78
|
-
Component.displayName = displayName.replace(/^Base/, "");
|
|
79
|
-
return Component;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export default withUniqueIdProps;
|
|
@@ -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
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Globally enable the logger
|
|
2
|
-
let enabled = process.env.NODE_ENV !== "production";
|
|
3
|
-
const delays = {};
|
|
4
|
-
const groupedMessages = {}; // Log the message
|
|
5
|
-
|
|
6
|
-
const log = (message, type, opts = {}) => {
|
|
7
|
-
if (enabled) {
|
|
8
|
-
if (opts.group) {
|
|
9
|
-
// if a group is defined, collect all occurrences to output together
|
|
10
|
-
groupedMessages[opts.group] = groupedMessages[opts.group] || [];
|
|
11
|
-
groupedMessages[opts.group].push(message);
|
|
12
|
-
const delay = delays[opts.group];
|
|
13
|
-
|
|
14
|
-
if (delay) {
|
|
15
|
-
clearTimeout(delay);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
delays[opts.group] = setTimeout(() => {
|
|
19
|
-
console[type](groupedMessages[opts.group][0], {
|
|
20
|
-
// eslint-disable-line no-console
|
|
21
|
-
all: groupedMessages[opts.group]
|
|
22
|
-
});
|
|
23
|
-
}, 500);
|
|
24
|
-
} else {
|
|
25
|
-
// output the message
|
|
26
|
-
console[type](message); // eslint-disable-line no-console
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
/*
|
|
31
|
-
* Logger
|
|
32
|
-
*
|
|
33
|
-
* Logger function will only output when enabled. By default this
|
|
34
|
-
* enabled state is set when your NODE_ENV !== 'production'
|
|
35
|
-
*
|
|
36
|
-
* If you wish to enable or disable the logger globally you can import the Logger
|
|
37
|
-
* and call setEnabledState(bool) passing the newState as a boolean.
|
|
38
|
-
*
|
|
39
|
-
* Methods
|
|
40
|
-
* error - console.error
|
|
41
|
-
* info - console.info
|
|
42
|
-
* log - console.log
|
|
43
|
-
* warn - console.warn
|
|
44
|
-
* deprecate - console.warn which prepends the message with [Deprecation]
|
|
45
|
-
*
|
|
46
|
-
* You can also pass an option of 'group', this will group messages together that
|
|
47
|
-
* share the same group name and are triggered within 500ms of one another.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const Logger = {
|
|
52
|
-
setEnabledState: newState => {
|
|
53
|
-
enabled = newState;
|
|
54
|
-
},
|
|
55
|
-
error: (message, opts) => {
|
|
56
|
-
log(message, "error", opts);
|
|
57
|
-
},
|
|
58
|
-
info: (message, opts) => {
|
|
59
|
-
log(message, "info", opts);
|
|
60
|
-
},
|
|
61
|
-
log: (message, opts) => {
|
|
62
|
-
log(message, "log", opts);
|
|
63
|
-
},
|
|
64
|
-
warn: (message, opts) => {
|
|
65
|
-
log(message, "warn", opts);
|
|
66
|
-
},
|
|
67
|
-
deprecate: (message, opts) => {
|
|
68
|
-
log(`[Deprecation] ${message}`, "warn", opts);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
export default Logger;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ether
|
|
3
|
-
*
|
|
4
|
-
* Ether provides functional-like helper methods for Carbon specific tasks.
|
|
5
|
-
* As we are dealing with stateful values (user input, browser state) Ether
|
|
6
|
-
* does not provide pure functions in all cases.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Returns the props that were passed to a component but excludes the props listed in propTypes
|
|
10
|
-
*
|
|
11
|
-
* Optionally includes the safeProps which can be defined as a static property on a Class or passed as the second
|
|
12
|
-
* argument.
|
|
13
|
-
*
|
|
14
|
-
* @method validProps
|
|
15
|
-
* @param {Object} instance
|
|
16
|
-
* @param {Array?} safeProps
|
|
17
|
-
* @return {Object} props
|
|
18
|
-
*/
|
|
19
|
-
export function validProps(instance: Object, safeProps: any[] | null): Object;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.validProps = validProps;
|
|
7
|
-
|
|
8
|
-
var _lodash = require("lodash");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Ether
|
|
12
|
-
*
|
|
13
|
-
* Ether provides functional-like helper methods for Carbon specific tasks.
|
|
14
|
-
* As we are dealing with stateful values (user input, browser state) Ether
|
|
15
|
-
* does not provide pure functions in all cases.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Returns the props that were passed to a component but excludes the props listed in propTypes
|
|
20
|
-
*
|
|
21
|
-
* Optionally includes the safeProps which can be defined as a static property on a Class or passed as the second
|
|
22
|
-
* argument.
|
|
23
|
-
*
|
|
24
|
-
* @method validProps
|
|
25
|
-
* @param {Object} instance
|
|
26
|
-
* @param {Array?} safeProps
|
|
27
|
-
* @return {Object} props
|
|
28
|
-
*/
|
|
29
|
-
function validProps(instance, safeProps) {
|
|
30
|
-
const component = instance.isReactComponent ? instance.constructor : instance;
|
|
31
|
-
const unsafeProps = (0, _lodash.difference)(Object.keys(component.propTypes), safeProps || component.safeProps || []);
|
|
32
|
-
return (0, _lodash.omit)(instance.props, unsafeProps);
|
|
33
|
-
} // eslint-disable-next-line import/prefer-default-export
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./ether";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _ether = require("./ether");
|
|
8
|
-
|
|
9
|
-
Object.keys(_ether).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _ether[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _ether[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|