@contentful/f36-drag-handle 4.0.1-beta.2482 → 4.0.1-beta.2500
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/package.json +6 -7
- package/src/DragHandle.styles.ts +0 -50
- package/src/DragHandle.tsx +0 -129
- package/src/index.ts +0 -2
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/f36-drag-handle",
|
|
3
|
-
"version": "4.0.1-beta.
|
|
3
|
+
"version": "4.0.1-beta.2500+37347e82",
|
|
4
4
|
"description": "Forma 36: DragHandle component",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "parcel build"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@babel/runtime": "^7.6.2",
|
|
10
|
-
"@contentful/f36-core": "
|
|
11
|
-
"@contentful/f36-icons": "
|
|
12
|
-
"@contentful/f36-tokens": "
|
|
10
|
+
"@contentful/f36-core": "4.0.1-beta.2500+37347e82",
|
|
11
|
+
"@contentful/f36-icons": "4.0.1-beta.2500+37347e82",
|
|
12
|
+
"@contentful/f36-tokens": "4.0.1-beta.2500+37347e82",
|
|
13
13
|
"emotion": "^10.0.17"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
21
|
-
"src"
|
|
20
|
+
"dist"
|
|
22
21
|
],
|
|
23
22
|
"main": "dist/main.js",
|
|
24
23
|
"module": "dist/module.js",
|
|
@@ -33,5 +32,5 @@
|
|
|
33
32
|
"publishConfig": {
|
|
34
33
|
"access": "public"
|
|
35
34
|
},
|
|
36
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "37347e8217c4fb99af8df64f564f67be4bdcea04"
|
|
37
36
|
}
|
package/src/DragHandle.styles.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { cx, css } from 'emotion';
|
|
2
|
-
import tokens from '@contentful/f36-tokens';
|
|
3
|
-
|
|
4
|
-
export const getStyles = () => ({
|
|
5
|
-
label: css({
|
|
6
|
-
position: 'absolute',
|
|
7
|
-
width: '1px',
|
|
8
|
-
height: '1px',
|
|
9
|
-
padding: 0,
|
|
10
|
-
margin: '-1px',
|
|
11
|
-
overflow: 'hidden',
|
|
12
|
-
clip: 'rect(0, 0, 0, 0)',
|
|
13
|
-
border: 0,
|
|
14
|
-
}),
|
|
15
|
-
root: ({
|
|
16
|
-
isActive,
|
|
17
|
-
isFocused,
|
|
18
|
-
isHovered,
|
|
19
|
-
}: {
|
|
20
|
-
isActive: boolean;
|
|
21
|
-
isFocused: boolean;
|
|
22
|
-
isHovered: boolean;
|
|
23
|
-
}) => {
|
|
24
|
-
return cx(
|
|
25
|
-
css({
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
backgroundColor: tokens.gray100,
|
|
28
|
-
border: 0,
|
|
29
|
-
borderBottomLeftRadius: tokens.borderRadiusMedium,
|
|
30
|
-
borderRight: `1px solid ${tokens.gray200}`,
|
|
31
|
-
borderTopLeftRadius: tokens.borderRadiusMedium,
|
|
32
|
-
boxSizing: 'border-box',
|
|
33
|
-
display: 'flex',
|
|
34
|
-
justifyContent: 'center',
|
|
35
|
-
padding: 0,
|
|
36
|
-
position: 'relative',
|
|
37
|
-
transition: `background-color ${tokens.transitionDurationDefault} ${tokens.transitionEasingDefault}`,
|
|
38
|
-
width: tokens.spacingL,
|
|
39
|
-
'&:hover, &:focus': {
|
|
40
|
-
backgroundColor: tokens.colorElementLight,
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
(isActive || isFocused || isHovered) &&
|
|
44
|
-
css({
|
|
45
|
-
backgroundColor: tokens.gray200,
|
|
46
|
-
cursor: isActive ? 'grabbing' : 'grab',
|
|
47
|
-
}),
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
});
|
package/src/DragHandle.tsx
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useCallback,
|
|
4
|
-
useState,
|
|
5
|
-
FocusEventHandler,
|
|
6
|
-
MouseEventHandler,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import { cx } from 'emotion';
|
|
9
|
-
import type { PropsWithHTMLElement } from '@contentful/f36-core';
|
|
10
|
-
import type { CommonProps } from '@contentful/f36-core';
|
|
11
|
-
import { DragIcon } from '@contentful/f36-icons';
|
|
12
|
-
import { getStyles } from './DragHandle.styles';
|
|
13
|
-
|
|
14
|
-
export type DragHandleInternalProps = CommonProps & {
|
|
15
|
-
/**
|
|
16
|
-
* Applies styling for when the component is actively being dragged by
|
|
17
|
-
* the user
|
|
18
|
-
*/
|
|
19
|
-
isActive?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Applies focus styling
|
|
22
|
-
*/
|
|
23
|
-
isFocused?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Applies hover styling
|
|
26
|
-
*/
|
|
27
|
-
isHovered?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Label rendered in DragHandle - not visible on screen as its purpose
|
|
30
|
-
* is for screen readers only
|
|
31
|
-
*/
|
|
32
|
-
label: string;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type DragHandleProps = PropsWithHTMLElement<
|
|
36
|
-
DragHandleInternalProps,
|
|
37
|
-
'button'
|
|
38
|
-
>;
|
|
39
|
-
|
|
40
|
-
export const DragHandle = forwardRef<HTMLButtonElement, DragHandleProps>(
|
|
41
|
-
(
|
|
42
|
-
{
|
|
43
|
-
className,
|
|
44
|
-
isActive,
|
|
45
|
-
isFocused: isFocusedProp,
|
|
46
|
-
isHovered: isHoveredProp,
|
|
47
|
-
label,
|
|
48
|
-
onBlur,
|
|
49
|
-
onFocus,
|
|
50
|
-
onMouseEnter,
|
|
51
|
-
onMouseLeave,
|
|
52
|
-
testId = 'cf-ui-drag-handle',
|
|
53
|
-
style,
|
|
54
|
-
...otherProps
|
|
55
|
-
},
|
|
56
|
-
forwardedRef,
|
|
57
|
-
) => {
|
|
58
|
-
const styles = getStyles();
|
|
59
|
-
const [isFocused, setisFocused] = useState(isFocusedProp);
|
|
60
|
-
const [isHovered, setisHovered] = useState(isHoveredProp);
|
|
61
|
-
|
|
62
|
-
const handleFocus = useCallback<FocusEventHandler<HTMLButtonElement>>(
|
|
63
|
-
(event) => {
|
|
64
|
-
setisFocused(true);
|
|
65
|
-
|
|
66
|
-
if (onFocus) {
|
|
67
|
-
onFocus(event);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
[onFocus],
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const handleBlur = useCallback<FocusEventHandler<HTMLButtonElement>>(
|
|
74
|
-
(event) => {
|
|
75
|
-
setisFocused(false);
|
|
76
|
-
|
|
77
|
-
if (onBlur) {
|
|
78
|
-
onBlur(event);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
[onBlur],
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const handleMouseEnter = useCallback<MouseEventHandler<HTMLButtonElement>>(
|
|
85
|
-
(event) => {
|
|
86
|
-
setisHovered(true);
|
|
87
|
-
|
|
88
|
-
if (onMouseEnter) {
|
|
89
|
-
onMouseEnter(event);
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
[onMouseEnter],
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const handleMouseLeave = useCallback<MouseEventHandler<HTMLButtonElement>>(
|
|
96
|
-
(event) => {
|
|
97
|
-
setisHovered(false);
|
|
98
|
-
|
|
99
|
-
if (onMouseLeave) {
|
|
100
|
-
onMouseLeave(event);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
[onMouseLeave],
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<button
|
|
108
|
-
type="button"
|
|
109
|
-
{...otherProps}
|
|
110
|
-
className={cx(
|
|
111
|
-
styles.root({ isActive, isFocused, isHovered }),
|
|
112
|
-
className,
|
|
113
|
-
)}
|
|
114
|
-
onBlur={handleBlur}
|
|
115
|
-
onFocus={handleFocus}
|
|
116
|
-
onMouseEnter={handleMouseEnter}
|
|
117
|
-
onMouseLeave={handleMouseLeave}
|
|
118
|
-
data-test-id={testId}
|
|
119
|
-
ref={forwardedRef}
|
|
120
|
-
style={style}
|
|
121
|
-
>
|
|
122
|
-
<DragIcon variant="muted" />
|
|
123
|
-
<span className={styles.label}>{label}</span>
|
|
124
|
-
</button>
|
|
125
|
-
);
|
|
126
|
-
},
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
DragHandle.displayName = 'DragHandle';
|
package/src/index.ts
DELETED