@toptal/picasso-dropzone 3.0.0 → 3.0.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Dropzone.d.ts","sourceRoot":"","sources":["../../../src/Dropzone/Dropzone.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAKzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAOvD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG1D,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IAClC,kCAAkC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACpD,8CAA8C;IAC9C,cAAc,CAAC,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAA;IAClD,8CAA8C;IAC9C,cAAc,CAAC,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAA;IAClD,8CAA8C;IAC9C,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAA;IAClC,iCAAiC;IACjC,SAAS,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAA;IACxC,qCAAqC;IACrC,KAAK,CAAC,EAAE,UAAU,EAAE,C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,EAAE,UAAU,EAAE,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAgDD,eAAO,MAAM,QAAQ,gFAgGnB,CAAA;AAWF,eAAe,QAAQ,CAAA"}
@@ -1,16 +1,33 @@
1
- import React, { forwardRef } from 'react';
1
+ import React, { forwardRef, useMemo } from 'react';
2
2
  import { useDropzone } from 'react-dropzone';
3
- import cx from 'classnames';
4
- import { makeStyles } from '@material-ui/core/styles';
3
+ import { twJoin } from '@toptal/picasso-tailwind-merge';
5
4
  import { Upload24 } from '@toptal/picasso-icons';
6
5
  import { FormHint } from '@toptal/picasso-form';
7
6
  import { Container } from '@toptal/picasso-container';
8
7
  import { FileList } from '@toptal/picasso-file-input';
9
8
  import { Typography } from '@toptal/picasso-typography';
10
- import styles from './styles';
11
- const useStyles = makeStyles(styles, { name: 'Dropzone' });
9
+ import { SPACING_6 } from '@toptal/picasso-utils';
10
+ const getCursorClasses = ({ isDisabled, isHovered, isFocused, isDragActive, }) => {
11
+ if (isDisabled) {
12
+ return 'cursor-not-allowed';
13
+ }
14
+ if (isHovered || isFocused || isDragActive) {
15
+ return 'cursor-pointer';
16
+ }
17
+ return 'hover:cursor-pointer focus:cursor-pointer';
18
+ };
19
+ const getBorderColorClasses = ({ isDisabled, isHovered, isFocused, isDragActive, }) => {
20
+ if (isDisabled) {
21
+ return 'border-gray-400 hover:border-gray-400';
22
+ }
23
+ if (isHovered || isFocused || isDragActive) {
24
+ return 'border-blue-500';
25
+ }
26
+ return 'border-gray-400 hover:border-blue-500 focus:border-blue-500';
27
+ };
28
+ const getBackgroundColorClasses = ({ isDisabled }) => isDisabled ? 'bg-gray-100' : 'bg-white';
12
29
  export const Dropzone = forwardRef(function Dropzone(props, ref) {
13
- const { hint, hideContentText, onRemove, value, className, style, 'data-testid': dataTestId, focused, hovered,
30
+ const { hint, hideContentText, onRemove, value, className, style, 'data-testid': dataTestId, focused: isFocused, hovered: isHovered,
14
31
  // dropzoneOptions
15
32
  accept, minSize, maxSize, multiple, disabled, onDrop, onDropAccepted, onDropRejected, validator, } = props;
16
33
  const isDisabled = Boolean(disabled || (!multiple && value && value.length > 0));
@@ -25,20 +42,18 @@ export const Dropzone = forwardRef(function Dropzone(props, ref) {
25
42
  onDropRejected,
26
43
  validator,
27
44
  });
28
- const classes = useStyles();
45
+ const componentState = useMemo(() => ({
46
+ isDisabled,
47
+ isHovered,
48
+ isFocused,
49
+ isDragActive,
50
+ }), [isDisabled, isHovered, isFocused, isDragActive]);
29
51
  return (React.createElement(Container, { style: style, ref: ref, className: className },
30
- React.createElement(Container, Object.assign({ flex: true, direction: 'column', alignItems: 'center', "data-testid": dataTestId }, getRootProps({
31
- className: cx(classes.root, {
32
- [classes.dragActive]: isDragActive,
33
- [classes.hovered]: hovered,
34
- [classes.disabled]: isDisabled,
35
- [classes.focused]: focused,
36
- }),
37
- })),
38
- React.createElement("input", Object.assign({}, getInputProps({ className: classes.nativeInput }))),
52
+ React.createElement(Container, Object.assign({ flex: true, direction: 'column', alignItems: 'center', rounded: true, "aria-disabled": isDisabled, padded: SPACING_6, "data-testid": dataTestId }, getRootProps({}), { className: twJoin('border border-dashed', 'box-border', 'text-graphite-700', 'gap-2', 'transition-all ease-out duration-350', getCursorClasses(componentState), getBorderColorClasses(componentState), getBackgroundColorClasses(componentState), isDisabled && 'hover:no-drop') }),
53
+ React.createElement("input", Object.assign({}, getInputProps())),
39
54
  React.createElement(Upload24, { color: 'darkGrey' }),
40
55
  !hideContentText && (React.createElement(Typography, { size: 'medium', color: 'black', weight: 'semibold' }, "Click or drag to upload")),
41
- hint && React.createElement(FormHint, { className: cx(classes.hint) }, hint)),
56
+ hint && (React.createElement(FormHint, { className: twJoin('m-0', '[&>*]:leading-4') }, hint))),
42
57
  value && value.length > 0 && (React.createElement(Container, { top: 'xsmall' },
43
58
  React.createElement(FileList, { files: value, onItemRemove: onRemove })))));
44
59
  });
@@ -1 +1 @@
1
- {"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asso-dropzone",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Toptal UI components library - Dropzone",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -36,7 +36,7 @@
36
36
  "**/styles.js"
37
37
  ],
38
38
  "peerDependencies": {
39
- "@material-ui/core": "4.12.4",
39
+ "@toptal/picasso-tailwind-merge": "^1.0.1",
40
40
  "@toptal/picasso-tailwind": ">=2.7",
41
41
  "react": ">=16.12.0 < 19.0.0"
42
42
  },
@@ -1,17 +1,15 @@
1
- import React, { forwardRef } from 'react'
1
+ import React, { forwardRef, useMemo } from 'react'
2
2
  import { useDropzone } from 'react-dropzone'
3
- import cx from 'classnames'
4
- import type { Theme } from '@material-ui/core/styles'
5
- import { makeStyles } from '@material-ui/core/styles'
3
+ import { twJoin } from '@toptal/picasso-tailwind-merge'
6
4
  import type { BaseProps } from '@toptal/picasso-shared'
7
5
  import { Upload24 } from '@toptal/picasso-icons'
8
6
  import { FormHint } from '@toptal/picasso-form'
9
7
  import { Container } from '@toptal/picasso-container'
10
8
  import { FileList } from '@toptal/picasso-file-input'
11
9
  import { Typography } from '@toptal/picasso-typography'
10
+ import { SPACING_6 } from '@toptal/picasso-utils'
12
11
 
13
12
  import type { FileUpload, DropzoneOptions } from './types'
14
- import styles from './styles'
15
13
 
16
14
  export interface Props extends BaseProps {
17
15
  /**
@@ -46,7 +44,51 @@ export interface Props extends BaseProps {
46
44
  hovered?: boolean
47
45
  }
48
46
 
49
- const useStyles = makeStyles<Theme>(styles, { name: 'Dropzone' })
47
+ type DropzoneState = {
48
+ isDisabled?: boolean
49
+ isHovered?: boolean
50
+ isFocused?: boolean
51
+ isDragActive?: boolean
52
+ }
53
+
54
+ type StateToClassMatcher = (currentState: DropzoneState) => string
55
+
56
+ const getCursorClasses: StateToClassMatcher = ({
57
+ isDisabled,
58
+ isHovered,
59
+ isFocused,
60
+ isDragActive,
61
+ }) => {
62
+ if (isDisabled) {
63
+ return 'cursor-not-allowed'
64
+ }
65
+
66
+ if (isHovered || isFocused || isDragActive) {
67
+ return 'cursor-pointer'
68
+ }
69
+
70
+ return 'hover:cursor-pointer focus:cursor-pointer'
71
+ }
72
+
73
+ const getBorderColorClasses: StateToClassMatcher = ({
74
+ isDisabled,
75
+ isHovered,
76
+ isFocused,
77
+ isDragActive,
78
+ }) => {
79
+ if (isDisabled) {
80
+ return 'border-gray-400 hover:border-gray-400'
81
+ }
82
+
83
+ if (isHovered || isFocused || isDragActive) {
84
+ return 'border-blue-500'
85
+ }
86
+
87
+ return 'border-gray-400 hover:border-blue-500 focus:border-blue-500'
88
+ }
89
+
90
+ const getBackgroundColorClasses: StateToClassMatcher = ({ isDisabled }) =>
91
+ isDisabled ? 'bg-gray-100' : 'bg-white'
50
92
 
51
93
  export const Dropzone = forwardRef<HTMLInputElement, Props>(function Dropzone(
52
94
  props,
@@ -60,8 +102,8 @@ export const Dropzone = forwardRef<HTMLInputElement, Props>(function Dropzone(
60
102
  className,
61
103
  style,
62
104
  'data-testid': dataTestId,
63
- focused,
64
- hovered,
105
+ focused: isFocused,
106
+ hovered: isHovered,
65
107
 
66
108
  // dropzoneOptions
67
109
  accept,
@@ -91,7 +133,15 @@ export const Dropzone = forwardRef<HTMLInputElement, Props>(function Dropzone(
91
133
  validator,
92
134
  })
93
135
 
94
- const classes = useStyles()
136
+ const componentState = useMemo(
137
+ () => ({
138
+ isDisabled,
139
+ isHovered,
140
+ isFocused,
141
+ isDragActive,
142
+ }),
143
+ [isDisabled, isHovered, isFocused, isDragActive]
144
+ )
95
145
 
96
146
  return (
97
147
  <Container style={style} ref={ref} className={className}>
@@ -99,24 +149,35 @@ export const Dropzone = forwardRef<HTMLInputElement, Props>(function Dropzone(
99
149
  flex
100
150
  direction='column'
101
151
  alignItems='center'
152
+ rounded
153
+ aria-disabled={isDisabled}
154
+ padded={SPACING_6}
102
155
  data-testid={dataTestId}
103
- {...getRootProps({
104
- className: cx(classes.root, {
105
- [classes.dragActive]: isDragActive,
106
- [classes.hovered]: hovered,
107
- [classes.disabled]: isDisabled,
108
- [classes.focused]: focused,
109
- }),
110
- })}
156
+ {...getRootProps({})}
157
+ className={twJoin(
158
+ 'border border-dashed',
159
+ 'box-border',
160
+ 'text-graphite-700',
161
+ 'gap-2',
162
+ 'transition-all ease-out duration-350',
163
+ getCursorClasses(componentState),
164
+ getBorderColorClasses(componentState),
165
+ getBackgroundColorClasses(componentState),
166
+ isDisabled && 'hover:no-drop'
167
+ )}
111
168
  >
112
- <input {...getInputProps({ className: classes.nativeInput })} />
169
+ <input {...getInputProps()} />
113
170
  <Upload24 color='darkGrey' />
114
171
  {!hideContentText && (
115
172
  <Typography size='medium' color='black' weight='semibold'>
116
173
  Click or drag to upload
117
174
  </Typography>
118
175
  )}
119
- {hint && <FormHint className={cx(classes.hint)}>{hint}</FormHint>}
176
+ {hint && (
177
+ <FormHint className={twJoin('m-0', '[&>*]:leading-4')}>
178
+ {hint}
179
+ </FormHint>
180
+ )}
120
181
  </Container>
121
182
  {value && value.length > 0 && (
122
183
  <Container top='xsmall'>
@@ -9,7 +9,8 @@ exports[`Dropzone renders 1`] = `
9
9
  class=""
10
10
  >
11
11
  <div
12
- class="items-center flex flex-col Dropzone-root"
12
+ aria-disabled="false"
13
+ class="p-6 items-center rounded-md flex flex-col border border-dashed box-border text-graphite gap-2 transition-all ease-out duration-350 hover:cursor-pointer focus:cursor-pointer border-gray hover:border-blue focus:border-blue bg-white"
13
14
  role="presentation"
14
15
  tabindex="0"
15
16
  >
@@ -53,7 +53,7 @@ describe('Dropzone', () => {
53
53
  ],
54
54
  })
55
55
 
56
- expect(getByTestId('dropzone').className).toContain('disabled')
56
+ expect(getByTestId('dropzone').getAttribute('aria-disabled')).toBe('true')
57
57
  })
58
58
  })
59
59
 
@@ -1,4 +0,0 @@
1
- import type { Theme } from '@material-ui/core/styles';
2
- declare const _default: ({ palette, sizes, transitions }: Theme) => import("@material-ui/styles").StyleRules<{}, "root" | "disabled" | "hint" | "completed" | "error" | "dragActive" | "hovered" | "focused">;
3
- export default _default;
4
- //# sourceMappingURL=styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Dropzone/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;0DAGJ,KAAK;AAAtD,wBAwCI"}
@@ -1,42 +0,0 @@
1
- import { createStyles } from '@material-ui/core/styles';
2
- export default ({ palette, sizes, transitions }) => createStyles({
3
- root: {
4
- padding: '20px',
5
- borderWidth: sizes.borderWidth,
6
- borderRadius: sizes.borderRadius.medium,
7
- borderColor: palette.grey.light2,
8
- borderStyle: 'dashed',
9
- backgroundColor: palette.common.white,
10
- color: palette.grey.dark,
11
- outline: 'none',
12
- transition: `all ${transitions.duration.short}ms ${transitions.easing.easeOut}`,
13
- transitionProperty: 'border, background-color',
14
- gap: '0.5rem',
15
- '&:hover, &$hovered, &:focus, &$focused, &$dragActive': {
16
- borderColor: palette.blue.main,
17
- cursor: 'pointer',
18
- },
19
- '&$disabled': {
20
- backgroundColor: palette.grey.lighter,
21
- '&:hover': {
22
- cursor: 'no-drop',
23
- borderColor: palette.grey.light2,
24
- },
25
- },
26
- },
27
- hint: {
28
- margin: 0,
29
- '& > *': {
30
- lineHeight: '1rem',
31
- },
32
- },
33
- completed: {},
34
- error: {
35
- margin: 0,
36
- },
37
- dragActive: {},
38
- hovered: {},
39
- disabled: {},
40
- focused: {},
41
- });
42
- //# sourceMappingURL=styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/Dropzone/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,eAAe,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAS,EAAE,EAAE,CACxD,YAAY,CAAC;IACX,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM;QACf,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,YAAY,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM;QACvC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM;QAChC,WAAW,EAAE,QAAQ;QACrB,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK;QACrC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;QACxB,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,OAAO,WAAW,CAAC,QAAQ,CAAC,KAAK,MAAM,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE;QAC/E,kBAAkB,EAAE,0BAA0B;QAC9C,GAAG,EAAE,QAAQ;QACb,sDAAsD,EAAE;YACtD,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;YAC9B,MAAM,EAAE,SAAS;SAClB;QACD,YAAY,EAAE;YACZ,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO;YACrC,SAAS,EAAE;gBACT,MAAM,EAAE,SAAS;gBACjB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM;aACjC;SACF;KACF;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC;QACT,OAAO,EAAE;YACP,UAAU,EAAE,MAAM;SACnB;KACF;IACD,SAAS,EAAE,EAAE;IACb,KAAK,EAAE;QACL,MAAM,EAAE,CAAC;KACV;IACD,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,EAAE;CACZ,CAAC,CAAA"}
@@ -1,44 +0,0 @@
1
- import type { Theme } from '@material-ui/core/styles'
2
- import { createStyles } from '@material-ui/core/styles'
3
-
4
- export default ({ palette, sizes, transitions }: Theme) =>
5
- createStyles({
6
- root: {
7
- padding: '20px',
8
- borderWidth: sizes.borderWidth,
9
- borderRadius: sizes.borderRadius.medium,
10
- borderColor: palette.grey.light2,
11
- borderStyle: 'dashed',
12
- backgroundColor: palette.common.white,
13
- color: palette.grey.dark,
14
- outline: 'none',
15
- transition: `all ${transitions.duration.short}ms ${transitions.easing.easeOut}`,
16
- transitionProperty: 'border, background-color',
17
- gap: '0.5rem',
18
- '&:hover, &$hovered, &:focus, &$focused, &$dragActive': {
19
- borderColor: palette.blue.main,
20
- cursor: 'pointer',
21
- },
22
- '&$disabled': {
23
- backgroundColor: palette.grey.lighter,
24
- '&:hover': {
25
- cursor: 'no-drop',
26
- borderColor: palette.grey.light2,
27
- },
28
- },
29
- },
30
- hint: {
31
- margin: 0,
32
- '& > *': {
33
- lineHeight: '1rem',
34
- },
35
- },
36
- completed: {},
37
- error: {
38
- margin: 0,
39
- },
40
- dragActive: {},
41
- hovered: {},
42
- disabled: {},
43
- focused: {},
44
- })