@sproutsocial/racine 11.8.0 → 11.9.0-typescript.0
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/__flow__/Button/{index.js → index.tsx} +20 -21
- package/__flow__/Button/{styles.js → styles.ts} +1 -1
- package/__flow__/Checkbox/index.stories.js +73 -56
- package/__flow__/Checkbox/styles.js +75 -75
- package/__flow__/Collapsible/index.js +3 -2
- package/__flow__/Icon/index.stories.js +41 -36
- package/__flow__/Image/index.js +10 -2
- package/__flow__/Loader/index.stories.js +18 -14
- package/__flow__/Numeral/index.stories.js +109 -50
- package/__flow__/Radio/index.stories.js +41 -26
- package/__flow__/SegmentedControl/index.js +3 -2
- package/__flow__/Switch/index.stories.js +26 -18
- package/__flow__/TableCell/index.js +9 -2
- package/__flow__/ToggleHint/index.js +9 -2
- package/__flow__/systemProps/color.js +1 -2
- package/__flow__/utils/responsiveProps/index.test.js +10 -2
- package/package.json +6 -1
- package/commonjs/Button/index.js +0 -70
- package/commonjs/Button/styles.js +0 -66
- package/lib/Button/index.js +0 -57
- package/lib/Button/styles.js +0 -48
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { number, select } from "@storybook/addon-knobs";
|
|
3
2
|
import Numeral from "./index";
|
|
4
3
|
|
|
5
|
-
const localeOptions =
|
|
6
|
-
""
|
|
4
|
+
const localeOptions = [
|
|
5
|
+
"United States (en-US)",
|
|
6
|
+
"English (en)",
|
|
7
|
+
"Arabic (ar-EG)",
|
|
8
|
+
"Brazil (pt-BR)",
|
|
9
|
+
"India (en-IN)",
|
|
10
|
+
"French (fr-FR)",
|
|
11
|
+
"Spain (es-ES)",
|
|
12
|
+
"Mexico (es-MX)",
|
|
13
|
+
"Germany (de-DE)",
|
|
14
|
+
"German (de)",
|
|
15
|
+
"Japan (ja-JP)",
|
|
16
|
+
"Japanese (ja)",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const localeMapping = {
|
|
7
20
|
"United States (en-US)": "en-US",
|
|
8
21
|
"English (en)": "en",
|
|
9
22
|
"Arabic (ar-EG)": "ar-EG",
|
|
@@ -18,8 +31,15 @@ const localeOptions = {
|
|
|
18
31
|
"Japanese (ja)": "ja",
|
|
19
32
|
};
|
|
20
33
|
|
|
21
|
-
const currencyOptions =
|
|
22
|
-
""
|
|
34
|
+
const currencyOptions = [
|
|
35
|
+
"Egyptian £",
|
|
36
|
+
"European €",
|
|
37
|
+
"Indian ₹",
|
|
38
|
+
"Japanese ¥",
|
|
39
|
+
"USA $",
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const currencyMapping = {
|
|
23
43
|
"Egyptian £": "EGP",
|
|
24
44
|
"European €": "EUR",
|
|
25
45
|
"Indian ₹": "INR",
|
|
@@ -27,15 +47,24 @@ const currencyOptions = {
|
|
|
27
47
|
"USA $": "USD",
|
|
28
48
|
};
|
|
29
49
|
|
|
30
|
-
const formatOptions =
|
|
31
|
-
|
|
50
|
+
const formatOptions = ["decimal", "currency", "percent"];
|
|
51
|
+
|
|
52
|
+
const formatMapping = {
|
|
32
53
|
decimal: "decimal",
|
|
33
54
|
currency: "currency",
|
|
34
55
|
percent: "percent",
|
|
35
56
|
};
|
|
36
57
|
|
|
37
|
-
const abbreviateOptions =
|
|
38
|
-
""
|
|
58
|
+
const abbreviateOptions = [
|
|
59
|
+
"true",
|
|
60
|
+
"false",
|
|
61
|
+
" 500",
|
|
62
|
+
"1_000",
|
|
63
|
+
"10_000",
|
|
64
|
+
"100_000",
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const abbreviateMapping = {
|
|
39
68
|
true: true,
|
|
40
69
|
false: false,
|
|
41
70
|
" 500": 500,
|
|
@@ -44,79 +73,109 @@ const abbreviateOptions = {
|
|
|
44
73
|
"100_000": 100000,
|
|
45
74
|
};
|
|
46
75
|
|
|
47
|
-
const precisionOptions =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
76
|
+
const precisionOptions = ["0", "1", "2", "3", "6", "none"];
|
|
77
|
+
|
|
78
|
+
const precisionMapping = {
|
|
79
|
+
"0": 0,
|
|
80
|
+
"1": 1,
|
|
81
|
+
"2": 2,
|
|
82
|
+
"3": 3,
|
|
83
|
+
"6": 6,
|
|
54
84
|
none: "none",
|
|
55
85
|
};
|
|
56
86
|
|
|
57
87
|
export default {
|
|
58
88
|
title: "Numeral",
|
|
89
|
+
component: Numeral,
|
|
90
|
+
argTypes: {
|
|
91
|
+
locale: {
|
|
92
|
+
control: "select",
|
|
93
|
+
options: localeOptions,
|
|
94
|
+
mapping: localeMapping,
|
|
95
|
+
},
|
|
96
|
+
format: {
|
|
97
|
+
control: "select",
|
|
98
|
+
options: formatOptions,
|
|
99
|
+
mapping: formatMapping,
|
|
100
|
+
},
|
|
101
|
+
currency: {
|
|
102
|
+
control: "select",
|
|
103
|
+
options: currencyOptions,
|
|
104
|
+
mapping: currencyMapping,
|
|
105
|
+
},
|
|
106
|
+
abbreviate: {
|
|
107
|
+
control: "select",
|
|
108
|
+
options: abbreviateOptions,
|
|
109
|
+
mapping: abbreviateMapping,
|
|
110
|
+
},
|
|
111
|
+
precision: {
|
|
112
|
+
control: "select",
|
|
113
|
+
options: precisionOptions,
|
|
114
|
+
mapping: precisionMapping,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
args: {
|
|
118
|
+
color: "text.headline",
|
|
119
|
+
number: 12.89,
|
|
120
|
+
},
|
|
59
121
|
};
|
|
60
122
|
|
|
61
|
-
|
|
62
|
-
const _select = (...args) => {
|
|
63
|
-
const answer = select(...args);
|
|
64
|
-
|
|
65
|
-
return answer === null ? undefined : answer;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const defaultStory = () => (
|
|
69
|
-
<Numeral
|
|
70
|
-
number={number("Number", 12.89)}
|
|
71
|
-
locale={_select("Locale", localeOptions)}
|
|
72
|
-
format={_select("Format", formatOptions)}
|
|
73
|
-
currency={_select("Currency", currencyOptions)}
|
|
74
|
-
abbreviate={_select("Abbreviate", abbreviateOptions)}
|
|
75
|
-
precision={_select("Precision", precisionOptions)}
|
|
76
|
-
color="text.headline"
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
123
|
+
export const defaultStory = (args) => <Numeral {...args} />;
|
|
79
124
|
|
|
80
125
|
defaultStory.story = {
|
|
81
126
|
name: "Default",
|
|
82
127
|
};
|
|
83
128
|
|
|
84
|
-
export const total = () =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
);
|
|
129
|
+
export const total = (args) => <Numeral {...args} />;
|
|
130
|
+
|
|
131
|
+
total.args = {
|
|
132
|
+
number: 100,
|
|
133
|
+
fontWeight: "semibold",
|
|
134
|
+
fontSize: 500,
|
|
135
|
+
};
|
|
92
136
|
|
|
93
137
|
total.story = {
|
|
94
138
|
name: "Total",
|
|
95
139
|
};
|
|
96
140
|
|
|
97
|
-
export const trend = () => <Numeral
|
|
141
|
+
export const trend = (args) => <Numeral {...args} />;
|
|
142
|
+
|
|
143
|
+
trend.args = {
|
|
144
|
+
number: 100,
|
|
145
|
+
color: "teal.500",
|
|
146
|
+
};
|
|
98
147
|
|
|
99
148
|
trend.story = {
|
|
100
149
|
name: "Trend",
|
|
101
150
|
};
|
|
102
151
|
|
|
103
|
-
export const noPrecision = () =>
|
|
104
|
-
|
|
105
|
-
|
|
152
|
+
export const noPrecision = (args) => <Numeral {...args} />;
|
|
153
|
+
|
|
154
|
+
noPrecision.args = {
|
|
155
|
+
number: 123.45678,
|
|
156
|
+
precision: "none",
|
|
157
|
+
};
|
|
106
158
|
|
|
107
159
|
noPrecision.story = {
|
|
108
160
|
name: "No Precision",
|
|
109
161
|
};
|
|
110
162
|
|
|
111
|
-
export const currencyPrecision = () =>
|
|
112
|
-
|
|
113
|
-
|
|
163
|
+
export const currencyPrecision = (args) => <Numeral {...args} />;
|
|
164
|
+
|
|
165
|
+
currencyPrecision.args = {
|
|
166
|
+
number: 123.4,
|
|
167
|
+
format: "currency",
|
|
168
|
+
};
|
|
114
169
|
|
|
115
170
|
currencyPrecision.story = {
|
|
116
171
|
name: "Currency precision",
|
|
117
172
|
};
|
|
118
173
|
|
|
119
|
-
export const invalid = () => <Numeral
|
|
174
|
+
export const invalid = (args) => <Numeral {...args} />;
|
|
175
|
+
|
|
176
|
+
invalid.args = {
|
|
177
|
+
number: null,
|
|
178
|
+
};
|
|
120
179
|
|
|
121
180
|
invalid.story = {
|
|
122
181
|
name: "Invalid",
|
|
@@ -1,58 +1,73 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { boolean } from "@storybook/addon-knobs";
|
|
3
|
-
|
|
4
2
|
import Radio from "./";
|
|
5
3
|
|
|
6
4
|
export default {
|
|
7
5
|
title: "Radio",
|
|
6
|
+
component: Radio,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Unchecked = (args) => <Radio {...args} />;
|
|
10
|
+
|
|
11
|
+
Unchecked.args = {
|
|
12
|
+
checked: false,
|
|
8
13
|
};
|
|
9
14
|
|
|
10
|
-
export const
|
|
15
|
+
export const Checked = (args) => <Radio {...args} />;
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
Checked.args = {
|
|
18
|
+
checked: true,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const DisabledUnchecked = (args) => <Radio {...args} />;
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
DisabledUnchecked.args = {
|
|
24
|
+
disabled: true,
|
|
25
|
+
};
|
|
17
26
|
|
|
18
27
|
DisabledUnchecked.story = {
|
|
19
28
|
name: "Disabled/Unchecked",
|
|
20
29
|
};
|
|
21
30
|
|
|
22
|
-
export const DisabledChecked = () =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
export const DisabledChecked = (args) => <Radio {...args} />;
|
|
32
|
+
|
|
33
|
+
DisabledChecked.args = {
|
|
34
|
+
checked: true,
|
|
35
|
+
disabled: true,
|
|
36
|
+
};
|
|
28
37
|
|
|
29
38
|
DisabledChecked.story = {
|
|
30
39
|
name: "Disabled/Checked",
|
|
31
40
|
};
|
|
32
41
|
|
|
33
|
-
export const LabelledChecked = () =>
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
export const LabelledChecked = (args) => <Radio {...args} />;
|
|
43
|
+
|
|
44
|
+
LabelledChecked.args = {
|
|
45
|
+
checked: true,
|
|
46
|
+
label: "Toggle Me",
|
|
47
|
+
};
|
|
36
48
|
|
|
37
49
|
LabelledChecked.story = {
|
|
38
50
|
name: "Labelled/Checked",
|
|
39
51
|
};
|
|
40
52
|
|
|
41
|
-
export const LabelledUnchecked = () =>
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
export const LabelledUnchecked = (args) => <Radio {...args} />;
|
|
54
|
+
|
|
55
|
+
LabelledUnchecked.args = {
|
|
56
|
+
checked: false,
|
|
57
|
+
label: "Toggle Me",
|
|
58
|
+
};
|
|
44
59
|
|
|
45
60
|
LabelledUnchecked.story = {
|
|
46
61
|
name: "Labelled/Unchecked",
|
|
47
62
|
};
|
|
48
63
|
|
|
49
|
-
export const LabelledDisabled = () =>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
export const LabelledDisabled = (args) => <Radio {...args} />;
|
|
65
|
+
|
|
66
|
+
LabelledDisabled.args = {
|
|
67
|
+
checked: false,
|
|
68
|
+
disabled: true,
|
|
69
|
+
label: "Toggle Me",
|
|
70
|
+
};
|
|
56
71
|
|
|
57
72
|
LabelledDisabled.story = {
|
|
58
73
|
name: "Labelled/Disabled",
|
|
@@ -17,8 +17,9 @@ type TypeSegmentedControlContext = {
|
|
|
17
17
|
onChange: (e: SyntheticInputEvent<HTMLInputElement>) => void,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const SegmentedControlContext =
|
|
21
|
-
|
|
20
|
+
const SegmentedControlContext = React.createContext<?TypeSegmentedControlContext>(
|
|
21
|
+
null
|
|
22
|
+
);
|
|
22
23
|
|
|
23
24
|
type TypeSegmentedControlItemProps = {
|
|
24
25
|
/** The value of this item. Should be unique among sibling items. */
|
|
@@ -1,33 +1,41 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { boolean } from "@storybook/addon-knobs";
|
|
3
|
-
|
|
4
2
|
import Switch from "./";
|
|
5
3
|
|
|
6
4
|
export default {
|
|
7
5
|
title: "Switch",
|
|
6
|
+
component: Switch,
|
|
8
7
|
};
|
|
9
8
|
|
|
10
|
-
export const
|
|
11
|
-
export const On = () => <Switch checked={boolean("checked", true)} />;
|
|
9
|
+
export const On = (args) => <Switch {...args} />;
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
disabled={boolean("disabled", true)}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
11
|
+
On.args = {
|
|
12
|
+
checked: true,
|
|
13
|
+
};
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
export const Off = (args) => <Switch {...args} />;
|
|
16
|
+
|
|
17
|
+
Off.args = {
|
|
18
|
+
checked: false,
|
|
22
19
|
};
|
|
23
20
|
|
|
24
|
-
export const DisabledOn = () =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
export const DisabledOn = (args) => <Switch {...args} />;
|
|
22
|
+
|
|
23
|
+
DisabledOn.args = {
|
|
24
|
+
checked: true,
|
|
25
|
+
disabled: true,
|
|
26
|
+
};
|
|
30
27
|
|
|
31
28
|
DisabledOn.story = {
|
|
32
29
|
name: "Disabled/On",
|
|
33
30
|
};
|
|
31
|
+
|
|
32
|
+
export const DisabledOff = (args) => <Switch {...args} />;
|
|
33
|
+
|
|
34
|
+
DisabledOff.args = {
|
|
35
|
+
checked: false,
|
|
36
|
+
disabled: true,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
DisabledOff.story = {
|
|
40
|
+
name: "Disabled/Off",
|
|
41
|
+
};
|
|
@@ -22,8 +22,15 @@ export type TypeTableCell = {
|
|
|
22
22
|
*/
|
|
23
23
|
export default class TableCell extends React.Component<TypeTableCell> {
|
|
24
24
|
render() {
|
|
25
|
-
const {
|
|
26
|
-
|
|
25
|
+
const {
|
|
26
|
+
id,
|
|
27
|
+
content,
|
|
28
|
+
colSpan,
|
|
29
|
+
width,
|
|
30
|
+
align,
|
|
31
|
+
children,
|
|
32
|
+
...rest
|
|
33
|
+
} = this.props;
|
|
27
34
|
|
|
28
35
|
return (
|
|
29
36
|
<Container
|
|
@@ -32,8 +32,15 @@ export default class ToggleHint extends React.Component<TypeProps> {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
render() {
|
|
35
|
-
const {
|
|
36
|
-
|
|
35
|
+
const {
|
|
36
|
+
icon,
|
|
37
|
+
isOpen,
|
|
38
|
+
openString,
|
|
39
|
+
closeString,
|
|
40
|
+
qa,
|
|
41
|
+
className,
|
|
42
|
+
...rest
|
|
43
|
+
} = this.props;
|
|
37
44
|
|
|
38
45
|
return (
|
|
39
46
|
<Container
|
|
@@ -14,8 +14,7 @@ import type {
|
|
|
14
14
|
|
|
15
15
|
// https://styled-system.com/table#color
|
|
16
16
|
|
|
17
|
-
type TypeBackgroundColorSystemProp =
|
|
18
|
-
TypeResponsiveBaseSystemProp<BackgroundColorProperty>;
|
|
17
|
+
type TypeBackgroundColorSystemProp = TypeResponsiveBaseSystemProp<BackgroundColorProperty>;
|
|
19
18
|
export type TypeColorSystemProps = $ReadOnly<{|
|
|
20
19
|
backgroundColor?: TypeBackgroundColorSystemProp,
|
|
21
20
|
bg?: TypeBackgroundColorSystemProp,
|
|
@@ -19,13 +19,21 @@ describe("normalizeResponsiveProp", () => {
|
|
|
19
19
|
|
|
20
20
|
it("should handle arrays with 4 values", () => {
|
|
21
21
|
expect(normalizeResponsiveProp([0, 1, 2, 3])).toMatchObject([
|
|
22
|
-
0,
|
|
22
|
+
0,
|
|
23
|
+
1,
|
|
24
|
+
2,
|
|
25
|
+
3,
|
|
26
|
+
3,
|
|
23
27
|
]);
|
|
24
28
|
});
|
|
25
29
|
|
|
26
30
|
it("should handle arrays with 5 values", () => {
|
|
27
31
|
expect(normalizeResponsiveProp([0, 1, 2, 3, 4])).toMatchObject([
|
|
28
|
-
0,
|
|
32
|
+
0,
|
|
33
|
+
1,
|
|
34
|
+
2,
|
|
35
|
+
3,
|
|
36
|
+
4,
|
|
29
37
|
]);
|
|
30
38
|
});
|
|
31
39
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutsocial/racine",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.9.0-typescript.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"__flow__",
|
|
@@ -66,6 +66,10 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@styled-system/theme-get": "^5.1.2",
|
|
69
|
+
"@types/jest": "^27.5.1",
|
|
70
|
+
"@types/node": "^17.0.38",
|
|
71
|
+
"@types/react": "^18.0.10",
|
|
72
|
+
"@types/react-dom": "^18.0.5",
|
|
69
73
|
"classnames": "^2.2.6",
|
|
70
74
|
"lodash.curry": "^4.1.1",
|
|
71
75
|
"lodash.uniqueid": "^4.0.1",
|
|
@@ -81,6 +85,7 @@
|
|
|
81
85
|
"react-virtualized": "9.18.5",
|
|
82
86
|
"scroll-into-view-if-needed": "1.1.0",
|
|
83
87
|
"styled-system": "^5.1.5",
|
|
88
|
+
"typescript": "^4.7.2",
|
|
84
89
|
"use-measure": "^0.2.2"
|
|
85
90
|
},
|
|
86
91
|
"devDependencies": {
|
package/commonjs/Button/index.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
|
|
6
|
-
var React = _interopRequireWildcard(require("react"));
|
|
7
|
-
|
|
8
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
9
|
-
|
|
10
|
-
var _excluded = ["href", "appearance", "active", "disabled", "external", "children", "size", "innerRef", "onClick", "title", "qa", "as", "ariaLabel"];
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
18
|
-
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); }
|
|
19
|
-
|
|
20
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
|
-
|
|
22
|
-
var Button = function Button(_ref) {
|
|
23
|
-
var href = _ref.href,
|
|
24
|
-
_ref$appearance = _ref.appearance,
|
|
25
|
-
appearance = _ref$appearance === void 0 ? "unstyled" : _ref$appearance,
|
|
26
|
-
_ref$active = _ref.active,
|
|
27
|
-
active = _ref$active === void 0 ? false : _ref$active,
|
|
28
|
-
disabled = _ref.disabled,
|
|
29
|
-
external = _ref.external,
|
|
30
|
-
children = _ref.children,
|
|
31
|
-
_ref$size = _ref.size,
|
|
32
|
-
size = _ref$size === void 0 ? "default" : _ref$size,
|
|
33
|
-
innerRef = _ref.innerRef,
|
|
34
|
-
onClick = _ref.onClick,
|
|
35
|
-
title = _ref.title,
|
|
36
|
-
_ref$qa = _ref.qa,
|
|
37
|
-
qa = _ref$qa === void 0 ? {} : _ref$qa,
|
|
38
|
-
as = _ref.as,
|
|
39
|
-
ariaLabel = _ref.ariaLabel,
|
|
40
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
41
|
-
|
|
42
|
-
if (!href && external) {
|
|
43
|
-
console.warn("Warning: external prop cannot be set without a href declaration");
|
|
44
|
-
} // plans to properly deprecate captured in DS-1096
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var appearanceCheck = appearance === "default" ? "unstyled" : appearance;
|
|
48
|
-
return /*#__PURE__*/React.createElement(_styles.default, _extends({
|
|
49
|
-
title: title,
|
|
50
|
-
active: active,
|
|
51
|
-
href: href,
|
|
52
|
-
target: external ? "_blank" : undefined,
|
|
53
|
-
rel: external ? "noopener noreferrer" : undefined,
|
|
54
|
-
as: as || (href ? "a" : "button"),
|
|
55
|
-
type: href ? undefined : "button",
|
|
56
|
-
"aria-disabled": disabled ? disabled : undefined,
|
|
57
|
-
disabled: disabled,
|
|
58
|
-
buttonSize: size,
|
|
59
|
-
appearance: appearanceCheck,
|
|
60
|
-
ref: innerRef,
|
|
61
|
-
onClick: onClick,
|
|
62
|
-
"data-qa-button": title || "",
|
|
63
|
-
"data-qa-button-isdisabled": disabled === true,
|
|
64
|
-
"aria-label": ariaLabel
|
|
65
|
-
}, qa, rest), children);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
Button.displayName = "Button";
|
|
69
|
-
var _default = Button;
|
|
70
|
-
exports.default = _default;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
|
|
6
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
7
|
-
|
|
8
|
-
var _systemProps = require("../utils/system-props");
|
|
9
|
-
|
|
10
|
-
var _mixins = require("../utils/mixins");
|
|
11
|
-
|
|
12
|
-
var _styles = _interopRequireDefault(require("../Icon/styles"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
var Container = _styledComponents.default.button.withConfig({
|
|
21
|
-
displayName: "styles__Container",
|
|
22
|
-
componentId: "sc-1juy94s-0"
|
|
23
|
-
})(["display:inline-block;box-sizing:border-box;text-align:center;font-family:", ";border:1px solid ", ";border-radius:", ";border-style:", ";background:", ";color:", ";cursor:pointer;text-decoration:none;line-height:16px;white-space:nowrap;font-weight:", ";transition:all ", " linear;margin:0;padding:", ";font-size:", ";&:visited{color:", ";}&:hover{color:", ";background:", ";text-decoration:none;box-shadow:", ";}&:active{color:", ";background:", ";transform:translateY(1px);}&:focus{", "}&:focus:active{box-shadow:none;}", " ", " ", " ", "{vertical-align:text-bottom;}", " ", ""], function (props) {
|
|
24
|
-
return props.theme.fontFamily;
|
|
25
|
-
}, function (props) {
|
|
26
|
-
return props.theme.colors.button[props.appearance].border.base;
|
|
27
|
-
}, function (props) {
|
|
28
|
-
return props.theme.radii[500];
|
|
29
|
-
}, function (props) {
|
|
30
|
-
return props.appearance === "placeholder" ? "dashed" : "solid";
|
|
31
|
-
}, function (props) {
|
|
32
|
-
return props.theme.colors.button[props.appearance].background.base;
|
|
33
|
-
}, function (props) {
|
|
34
|
-
return props.theme.colors.button[props.appearance].text.base;
|
|
35
|
-
}, function (props) {
|
|
36
|
-
return props.theme.fontWeights.bold;
|
|
37
|
-
}, function (props) {
|
|
38
|
-
return props.theme.duration.fast;
|
|
39
|
-
}, function (props) {
|
|
40
|
-
return props.buttonSize === "default" ? "" + props.theme.space[300] : "" + props.theme.space[350];
|
|
41
|
-
}, function (props) {
|
|
42
|
-
return props.buttonSize === "default" ? props.theme.typography[200].fontSize : props.theme.typography[300].fontSize;
|
|
43
|
-
}, function (props) {
|
|
44
|
-
return props.theme.colors.button[props.appearance].text.base;
|
|
45
|
-
}, function (props) {
|
|
46
|
-
return props.theme.colors.button[props.appearance].text.hover;
|
|
47
|
-
}, function (props) {
|
|
48
|
-
return props.theme.colors.button[props.appearance].background.hover;
|
|
49
|
-
}, function (props) {
|
|
50
|
-
return props.appearance === "placeholder" ? props.theme.shadows.low : "none";
|
|
51
|
-
}, function (props) {
|
|
52
|
-
return props.theme.colors.button[props.appearance].text.hover;
|
|
53
|
-
}, function (props) {
|
|
54
|
-
return props.theme.colors.button[props.appearance].background.active;
|
|
55
|
-
}, _mixins.focusRing, function (props) {
|
|
56
|
-
return props.active && (0, _styledComponents.css)(["color:", " !important;background:", " !important;"], props.theme.colors.button[props.appearance].text.hover, props.theme.colors.button[props.appearance].background.active);
|
|
57
|
-
}, function (props) {
|
|
58
|
-
return props.disabled && _mixins.disabled;
|
|
59
|
-
}, function (props) {
|
|
60
|
-
return props.appearance === "pill" && (0, _styledComponents.css)(["display:inline-flex;align-items:center;justify-content:center;mix-blend-mode:", ";", ""], props.theme.mode === "dark" ? "screen" : "multiply", _mixins.pill);
|
|
61
|
-
}, _styles.default, _systemProps.LAYOUT, _systemProps.COMMON);
|
|
62
|
-
|
|
63
|
-
Container.displayName = "Button-Container";
|
|
64
|
-
var _default = Container; //${props.theme.mode === "dark" ? "screen" : "multiply"}
|
|
65
|
-
|
|
66
|
-
exports.default = _default;
|