@sproutsocial/racine 11.4.1-input-beta.0 → 11.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 11.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fa8a45d: Dependency upgrades: upgraded severe vulnerabilities as well as storybook and jest suite fixes. Upgraded styled components from beta to stable v5.2.3.
8
+
9
+ ## 11.4.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 89c935f: Handle focus management in Input handleClear more consistently
14
+ - Previously, focus would be returned to the input when Input.ClearButton was triggered only if the innerRef prop was undefined or an object, not if it was a function.
15
+ - Now, focus is always returned to the input when the clear button is clicked, regardless of the type of the innerRef prop.
16
+
3
17
  ## 11.4.0
4
18
 
5
19
  ### Minor Changes
@@ -84,4 +84,6 @@ const Button = ({
84
84
  );
85
85
  };
86
86
 
87
+ Button.displayName = "Button";
88
+
87
89
  export default Button;
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import { boolean, text, number } from "@storybook/addon-knobs";
3
2
  import Button from "./index";
4
3
  import Icon from "../Icon";
5
4
  import Box from "../Box";
@@ -8,155 +7,140 @@ export default {
8
7
  title: "Button",
9
8
  };
10
9
 
11
- export const defaultStory = () => (
12
- <Button
13
- appearance={text("appearance", "default")}
14
- onClick={() => alert("Testing...")}
15
- >
10
+ export const defaultStory = (args) => (
11
+ <Button {...args} onClick={() => alert("Testing...")}>
16
12
  Default
17
13
  </Button>
18
14
  );
19
15
 
16
+ defaultStory.args = { appearance: "default" };
17
+
20
18
  defaultStory.story = {
21
19
  name: "Default",
22
20
  };
23
21
 
24
- export const primary = () => (
25
- <Button
26
- appearance={text("appearance", "primary")}
27
- onClick={() => alert("Testing...")}
28
- >
22
+ export const primary = (args) => (
23
+ <Button {...args} onClick={() => alert("Testing...")}>
29
24
  Primary Button
30
25
  </Button>
31
26
  );
32
27
 
28
+ primary.args = { appearance: "primary" };
29
+
33
30
  primary.story = {
34
31
  name: "Primary",
35
32
  };
36
33
 
37
- export const secondary = () => (
38
- <Button appearance={text("appearance", "secondary")}>Secondary Button</Button>
39
- );
34
+ export const secondary = (args) => <Button {...args}>Secondary Button</Button>;
35
+
36
+ secondary.args = { appearance: "secondary" };
40
37
 
41
38
  secondary.story = {
42
39
  name: "Secondary",
43
40
  };
44
41
 
45
- export const destructive = () => (
46
- <Button appearance={text("appearance", "destructive")}>
47
- Destructive Button
48
- </Button>
42
+ export const destructive = (args) => (
43
+ <Button {...args}>Destructive Button</Button>
49
44
  );
50
45
 
46
+ destructive.args = { appearance: "destructive" };
51
47
  destructive.story = {
52
48
  name: "Destructive",
53
49
  };
54
50
 
55
- export const placeholder = () => (
56
- <Button appearance={text("appearance", "placeholder")}>
57
- Placeholder Button
58
- </Button>
51
+ export const placeholder = (args) => (
52
+ <Button {...args}>Placeholder Button</Button>
59
53
  );
60
54
 
55
+ placeholder.args = { appearance: "placeholder" };
61
56
  placeholder.story = {
62
57
  name: "Placeholder",
63
58
  };
64
59
 
65
- export const largeButton = () => (
66
- <Button
67
- appearance={text("appearance", "primary")}
68
- size={text("size", "large")}
69
- >
70
- Large Button
71
- </Button>
72
- );
60
+ export const largeButton = (args) => <Button {...args}>Large Button</Button>;
61
+ largeButton.args = { size: "large", appearance: "primary" };
73
62
 
74
63
  largeButton.story = {
75
64
  name: "Large button",
76
65
  };
77
66
 
78
- export const pillButton = () => (
67
+ export const pillButton = (args) => (
79
68
  <Box bg="container.background.base" p={400}>
80
- <Button appearance={text("shape", "pill")}>
69
+ <Button {...args}>
81
70
  <Icon name="reply" mr={350} />
82
71
  Pill Button
83
72
  </Button>
84
73
  </Box>
85
74
  );
86
-
75
+ pillButton.args = { appearance: "pill" };
87
76
  pillButton.story = {
88
77
  name: "Pill button",
89
78
  };
90
79
 
91
- export const pillIconOnlyButton = () => (
80
+ export const pillIconOnlyButton = (args) => (
92
81
  <Box bg="container.background.base" p={400}>
93
- <Button appearance={text("shape", "pill")} ariaLabel="This is a label">
82
+ <Button {...args} ariaLabel="This is a label">
94
83
  <Icon name="circle-check-outline" />
95
84
  </Button>
96
85
  </Box>
97
86
  );
98
87
 
88
+ pillIconOnlyButton.args = { appearance: "pill" };
99
89
  pillIconOnlyButton.story = {
100
90
  name: "Pill icon only button",
101
91
  };
102
92
 
103
- export const activeButton = () => (
104
- <Button
105
- appearance={text("appearance", "secondary")}
106
- active={boolean("active", true)}
107
- >
108
- Active Button
109
- </Button>
110
- );
93
+ export const activeButton = (args) => <Button {...args}>Active Button</Button>;
111
94
 
95
+ activeButton.args = { appearance: "secondary", active: true };
112
96
  activeButton.story = {
113
97
  name: "Active button",
114
98
  };
115
99
 
116
- export const buttonAsALink = () => (
117
- <Button
118
- href={text("href", "http://sproutsocial.style")}
119
- external={boolean("external", true)}
120
- appearance={text("appearance", "primary")}
121
- >
122
- Button using anchor element
123
- </Button>
100
+ export const buttonAsALink = (args) => (
101
+ <Button {...args}>Button using anchor element</Button>
124
102
  );
125
-
103
+ buttonAsALink.args = {
104
+ appearance: "primary",
105
+ external: true,
106
+ href: "http://sproutsocial.style",
107
+ };
126
108
  buttonAsALink.story = {
127
109
  name: "Button as a link",
128
110
  };
129
111
 
130
- export const disabledButton = () => (
131
- <Button
132
- appearance={text("appearance", "primary")}
133
- disabled={text("disabled", "true")}
134
- >
135
- This Button is disabled
136
- </Button>
112
+ export const disabledButton = (args) => (
113
+ <Button {...args}>This Button is disabled</Button>
137
114
  );
138
-
115
+ disabledButton.args = {
116
+ appearance: "primary",
117
+ disabled: true,
118
+ };
139
119
  disabledButton.story = {
140
120
  name: "Disabled button",
141
121
  };
142
122
 
143
- export const fullWidthButton = () => (
144
- <Button appearance={text("appearance", "primary")} width={number("width", 1)}>
145
- Full-Width Button
146
- </Button>
123
+ export const fullWidthButton = (args) => (
124
+ <Button {...args}>Full-Width Button</Button>
147
125
  );
148
-
126
+ fullWidthButton.args = {
127
+ appearance: "primary",
128
+ width: 1,
129
+ };
149
130
  fullWidthButton.story = {
150
131
  name: "Full width button",
151
132
  };
152
133
 
153
- export const withIcon = () => (
154
- <Button appearance={text("appearance", "secondary")}>
134
+ export const withIcon = (args) => (
135
+ <Button {...args}>
155
136
  <Icon name="twitter" mr={350} />
156
137
  Secondary Button
157
138
  </Button>
158
139
  );
159
140
 
141
+ withIcon.args = {
142
+ appearance: "secondary",
143
+ };
160
144
  withIcon.story = {
161
145
  name: "With icon",
162
146
  };
@@ -99,7 +99,7 @@ const Container: StyledComponent<any, TypeTheme, *> = styled.button`
99
99
  ${LAYOUT}
100
100
  ${COMMON}
101
101
  `;
102
-
102
+ Container.displayName = "Button-Container";
103
103
  export default Container;
104
104
 
105
105
  //${props.theme.mode === "dark" ? "screen" : "multiply"}
@@ -182,90 +182,90 @@ const getIcon = (type, color) => {
182
182
 
183
183
  // eslint-disable-next-line prettier/prettier
184
184
  export const CheckboxContainer: StyledComponent<any, TypeTheme, *> = styled.span(
185
- (props) => css`
186
- display: inline-flex;
187
- align-items: center;
188
- box-sizing: border-box;
189
- position: relative;
190
- transition: all ${props.theme.duration.fast} ${props.theme.easing.ease_in};
191
-
192
- @supports (-webkit-appearance: none) {
193
- &:before {
194
- /* stylelint-disable */
195
- content: url("data:image/svg+xml;utf8,${getIcon(
196
- props.indeterminate ? "indeterminate" : "check",
197
-
198
- props.checked
199
- ? props.theme.colors.form.background.base
200
- : props.theme.colors.form.border.base
201
- )}");
202
- opacity: ${props.checked ? 1 : 0};
203
- position: absolute;
204
- width: ${props.theme.space[400]};
205
- height: ${props.theme.space[400]};
206
- text-align: center;
207
- transform: translateY(1px);
208
- line-height: 1;
209
- margin: auto;
210
- pointer-events: none;
211
- transition: ${props.theme.duration.fast}
212
- ${props.theme.easing.ease_inout};
213
- }
214
-
215
- &:hover:before {
216
- opacity: ${props.disabled && !props.checked ? 0 : 1};
217
- }
218
-
219
- ${props.disabled &&
220
- css`
221
- opacity: 0.4;
222
- `}
223
-
224
- input[type='checkbox'] {
225
- box-sizing: border-box;
226
- appearance: none;
227
- margin: 0;
228
- padding: 0;
229
- width: ${props.theme.space[400]};
230
- height: ${props.theme.space[400]};
231
- border: 1px solid ${props.theme.colors.form.border.base};
232
- border-radius: 4px;
233
- background-color: ${props.theme.colors.form.background.base};
234
- transition: all ${props.theme.duration.fast}
235
- ${props.theme.easing.ease_in};
236
- cursor: ${props.disabled ? "not-allowed" : "pointer"};
237
- flex-shrink: 0;
238
-
239
- &:not(:checked) {
240
- ${!props.indeterminate &&
241
- css`
242
- border-color: ${props.theme.colors
243
- .neutral[300]} !important; /* We don't want the focus ring to remove the border */
244
- background-color: ${props.theme.colors.form.background.base};
245
- `}
185
+ (props) => css`
186
+ display: inline-flex;
187
+ align-items: center;
188
+ box-sizing: border-box;
189
+ position: relative;
190
+ transition: all ${props.theme.duration.fast} ${props.theme.easing.ease_in};
191
+
192
+ @supports (-webkit-appearance: none) {
193
+ &:before {
194
+ /* stylelint-disable */
195
+ content: url("data:image/svg+xml;utf8,${getIcon(
196
+ props.indeterminate ? "indeterminate" : "check",
197
+
198
+ props.checked
199
+ ? props.theme.colors.form.background.base
200
+ : props.theme.colors.form.border.base
201
+ )}");
202
+ opacity: ${props.checked ? 1 : 0};
203
+ position: absolute;
204
+ width: ${props.theme.space[400]};
205
+ height: ${props.theme.space[400]};
206
+ text-align: center;
207
+ transform: translateY(1px);
208
+ line-height: 1;
209
+ margin: auto;
210
+ pointer-events: none;
211
+ transition: ${props.theme.duration.fast}
212
+ ${props.theme.easing.ease_inout};
246
213
  }
247
214
 
248
- &:checked {
249
- border-color: ${props.theme.colors.form.border.selected};
250
- background-color: ${props.theme.colors.form.background.selected};
215
+ &:hover:before {
216
+ opacity: ${props.disabled && !props.checked ? 0 : 1};
251
217
  }
252
218
 
253
- ${props.indeterminate &&
254
- props.checked &&
219
+ ${props.disabled &&
255
220
  css`
256
- border-color: ${props.theme.colors.form.border.selected} !important;
257
- background-color: ${props.theme.colors.form.background
258
- .selected} !important;
221
+ opacity: 0.4;
259
222
  `}
260
223
 
261
- &:focus {
262
- ${focusRing}
224
+ input[type='checkbox'] {
225
+ box-sizing: border-box;
226
+ appearance: none;
227
+ margin: 0;
228
+ padding: 0;
229
+ width: ${props.theme.space[400]};
230
+ height: ${props.theme.space[400]};
231
+ border: 1px solid ${props.theme.colors.form.border.base};
232
+ border-radius: 4px;
233
+ background-color: ${props.theme.colors.form.background.base};
234
+ transition: all ${props.theme.duration.fast}
235
+ ${props.theme.easing.ease_in};
236
+ cursor: ${props.disabled ? "not-allowed" : "pointer"};
237
+ flex-shrink: 0;
238
+
239
+ &:not(:checked) {
240
+ ${!props.indeterminate &&
241
+ css`
242
+ border-color: ${props.theme.colors
243
+ .neutral[300]} !important; /* We don't want the focus ring to remove the border */
244
+ background-color: ${props.theme.colors.form.background.base};
245
+ `}
246
+ }
247
+
248
+ &:checked {
249
+ border-color: ${props.theme.colors.form.border.selected};
250
+ background-color: ${props.theme.colors.form.background.selected};
251
+ }
252
+
253
+ ${props.indeterminate &&
254
+ props.checked &&
255
+ css`
256
+ border-color: ${props.theme.colors.form.border.selected} !important;
257
+ background-color: ${props.theme.colors.form.background
258
+ .selected} !important;
259
+ `}
260
+
261
+ &:focus {
262
+ ${focusRing}
263
+ }
263
264
  }
264
265
  }
265
- }
266
266
 
267
- ${COMMON}
268
- `
269
- );
267
+ ${COMMON}
268
+ `
269
+ );
270
270
 
271
271
  export default Container;
@@ -73,9 +73,8 @@ const Trigger = ({ children, ...rest }) => {
73
73
  };
74
74
 
75
75
  const Panel = ({ children, ...rest }) => {
76
- const { isOpen, id, offset, collapsedHeight, openHeight } = useContext(
77
- CollapsibleContext
78
- );
76
+ const { isOpen, id, offset, collapsedHeight, openHeight } =
77
+ useContext(CollapsibleContext);
79
78
  const ref = useRef();
80
79
  const measurement = useMeasure(ref);
81
80
  const [isHidden, setIsHidden] = useState(undefined);
@@ -105,7 +105,7 @@ describe("EmptyState", () => {
105
105
  <EmptyState
106
106
  media={
107
107
  <Image
108
- alt="No assets matching yoursearch or filters"
108
+ alt="No assets matching your search or filters"
109
109
  src="https://cl.ly/db498c7682df/download/analytics.svg"
110
110
  m={0}
111
111
  />
@@ -80,16 +80,8 @@ export default class Image extends React.Component<TypeProps, TypeState> {
80
80
  };
81
81
 
82
82
  render() {
83
- const {
84
- alt,
85
- title,
86
- onClick,
87
- onError,
88
- onLoad,
89
- src,
90
- qa,
91
- ...rest
92
- } = this.props;
83
+ const { alt, title, onClick, onError, onLoad, src, qa, ...rest } =
84
+ this.props;
93
85
 
94
86
  return (
95
87
  <ImageContainer
@@ -14,12 +14,12 @@ exports[`Menu AsMenuButton should match snapshot 1`] = `
14
14
  fill: currentColor;
15
15
  }
16
16
 
17
- _:-ms-fullscreen .c3,
17
+ _:-ms-fullscreen .c2,
18
18
  html .c3 {
19
19
  width: 16px;
20
20
  }
21
21
 
22
- .pdf-page .c3 {
22
+ .pdf-page .c2 {
23
23
  width: 16px;
24
24
  }
25
25
 
@@ -17,9 +17,8 @@ type TypeSegmentedControlContext = {
17
17
  onChange: (e: SyntheticInputEvent<HTMLInputElement>) => void,
18
18
  };
19
19
 
20
- const SegmentedControlContext = React.createContext<?TypeSegmentedControlContext>(
21
- null
22
- );
20
+ const SegmentedControlContext =
21
+ React.createContext<?TypeSegmentedControlContext>(null);
23
22
 
24
23
  type TypeSegmentedControlItemProps = {
25
24
  /** The value of this item. Should be unique among sibling items. */
@@ -22,15 +22,8 @@ export type TypeTableCell = {
22
22
  */
23
23
  export default class TableCell extends React.Component<TypeTableCell> {
24
24
  render() {
25
- const {
26
- id,
27
- content,
28
- colSpan,
29
- width,
30
- align,
31
- children,
32
- ...rest
33
- } = this.props;
25
+ const { id, content, colSpan, width, align, children, ...rest } =
26
+ this.props;
34
27
 
35
28
  return (
36
29
  <Container
@@ -32,15 +32,8 @@ export default class ToggleHint extends React.Component<TypeProps> {
32
32
  };
33
33
 
34
34
  render() {
35
- const {
36
- icon,
37
- isOpen,
38
- openString,
39
- closeString,
40
- qa,
41
- className,
42
- ...rest
43
- } = this.props;
35
+ const { icon, isOpen, openString, closeString, qa, className, ...rest } =
36
+ this.props;
44
37
 
45
38
  return (
46
39
  <Container
@@ -1,5 +1,5 @@
1
1
  import "mutationobserver-shim";
2
- import "jest-dom/extend-expect";
2
+ import "@testing-library/jest-dom/extend-expect";
3
3
  import "jest-axe/extend-expect";
4
4
  import "babel-polyfill";
5
5
  import "jest-styled-components";
@@ -14,7 +14,8 @@ import type {
14
14
 
15
15
  // https://styled-system.com/table#color
16
16
 
17
- type TypeBackgroundColorSystemProp = TypeResponsiveBaseSystemProp<BackgroundColorProperty>;
17
+ type TypeBackgroundColorSystemProp =
18
+ TypeResponsiveBaseSystemProp<BackgroundColorProperty>;
18
19
  export type TypeColorSystemProps = $ReadOnly<{|
19
20
  backgroundColor?: TypeBackgroundColorSystemProp,
20
21
  bg?: TypeBackgroundColorSystemProp,
@@ -1,19 +1,5 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`layout system props display 1`] = `
4
- .c0 {
5
- display: -webkit-string;
6
- display: string;
7
- }
8
-
9
- <div>
10
- <div
11
- class="c0"
12
- display="string"
13
- />
14
- </div>
15
- `;
16
-
17
3
  exports[`layout system props height 1`] = `
18
4
  .c0 {
19
5
  height: string;
@@ -10,15 +10,6 @@ describe("layout system props", () => {
10
10
  ${layoutSystemProps}
11
11
  `;
12
12
 
13
- test("display", () => {
14
- const { container } = render(
15
- <>
16
- <Component display="string" />
17
- </>
18
- );
19
- expect(container).toMatchSnapshot();
20
- });
21
-
22
13
  test("height", () => {
23
14
  const { container } = render(
24
15
  <>
@@ -19,21 +19,13 @@ describe("normalizeResponsiveProp", () => {
19
19
 
20
20
  it("should handle arrays with 4 values", () => {
21
21
  expect(normalizeResponsiveProp([0, 1, 2, 3])).toMatchObject([
22
- 0,
23
- 1,
24
- 2,
25
- 3,
26
- 3,
22
+ 0, 1, 2, 3, 3,
27
23
  ]);
28
24
  });
29
25
 
30
26
  it("should handle arrays with 5 values", () => {
31
27
  expect(normalizeResponsiveProp([0, 1, 2, 3, 4])).toMatchObject([
32
- 0,
33
- 1,
34
- 2,
35
- 3,
36
- 4,
28
+ 0, 1, 2, 3, 4,
37
29
  ]);
38
30
  });
39
31
  });
@@ -65,5 +65,6 @@ var Button = function Button(_ref) {
65
65
  }, qa, rest), children);
66
66
  };
67
67
 
68
+ Button.displayName = "Button";
68
69
  var _default = Button;
69
70
  exports.default = _default;
@@ -60,6 +60,7 @@ var Container = _styledComponents.default.button.withConfig({
60
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
61
  }, _styles.default, _systemProps.LAYOUT, _systemProps.COMMON);
62
62
 
63
+ Container.displayName = "Button-Container";
63
64
  var _default = Container; //${props.theme.mode === "dark" ? "screen" : "multiply"}
64
65
 
65
66
  exports.default = _default;
@@ -105,7 +105,7 @@ exports.MessageBody = MessageBody;
105
105
  var MessageFooter = (0, _styledComponents.default)(_Box.default).withConfig({
106
106
  displayName: "styles__MessageFooter",
107
107
  componentId: "sc-1ju6d1v-3"
108
- })(["padding-bottom:", ";padding-left:", ";padding-right:", ";border-radius:0 0 ", " ", ";display:flex;justify-content:space-between;align-items:center;flex-wrap:", ";>:first-child{margin-left:-", ";}"], function (props) {
108
+ })(["padding-bottom:", ";padding-left:", ";padding-right:", ";border-radius:0 0 ", " ", ";display:flex;justify-content:space-between;align-items:center;flex-wrap:", ";> :first-child{margin-left:-", ";}"], function (props) {
109
109
  return props.density === _Message.default.DENSITIES.CONDENSED ? 0 : props.theme.space[300];
110
110
  }, function (props) {
111
111
  return getContentPadding(props);
@@ -53,4 +53,5 @@ var Button = function Button(_ref) {
53
53
  }, qa, rest), children);
54
54
  };
55
55
 
56
+ Button.displayName = "Button";
56
57
  export default Button;
@@ -44,4 +44,5 @@ var Container = styled.button.withConfig({
44
44
  }, function (props) {
45
45
  return props.appearance === "pill" && css(["display:inline-flex;align-items:center;justify-content:center;mix-blend-mode:", ";", ""], props.theme.mode === "dark" ? "screen" : "multiply", pill);
46
46
  }, Icon, LAYOUT, COMMON);
47
+ Container.displayName = "Button-Container";
47
48
  export default Container; //${props.theme.mode === "dark" ? "screen" : "multiply"}
@@ -91,7 +91,7 @@ export var MessageBody = styled(Box).withConfig({
91
91
  export var MessageFooter = styled(Box).withConfig({
92
92
  displayName: "styles__MessageFooter",
93
93
  componentId: "sc-1ju6d1v-3"
94
- })(["padding-bottom:", ";padding-left:", ";padding-right:", ";border-radius:0 0 ", " ", ";display:flex;justify-content:space-between;align-items:center;flex-wrap:", ";>:first-child{margin-left:-", ";}"], function (props) {
94
+ })(["padding-bottom:", ";padding-left:", ";padding-right:", ";border-radius:0 0 ", " ", ";display:flex;justify-content:space-between;align-items:center;flex-wrap:", ";> :first-child{margin-left:-", ";}"], function (props) {
95
95
  return props.density === Message.DENSITIES.CONDENSED ? 0 : props.theme.space[300];
96
96
  }, function (props) {
97
97
  return getContentPadding(props);