@contentful/f36-drag-handle 4.14.0 → 4.16.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 +24 -0
- package/dist/main.js +43 -44
- package/dist/main.js.map +1 -1
- package/dist/module.js +43 -44
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.16.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @contentful/f36-icons@4.16.0
|
|
9
|
+
- @contentful/f36-core@4.16.0
|
|
10
|
+
|
|
11
|
+
## 4.15.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies []:
|
|
16
|
+
- @contentful/f36-icons@4.15.1
|
|
17
|
+
- @contentful/f36-core@4.15.1
|
|
18
|
+
|
|
19
|
+
## 4.15.0
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies []:
|
|
24
|
+
- @contentful/f36-icons@4.15.0
|
|
25
|
+
- @contentful/f36-core@4.15.0
|
|
26
|
+
|
|
3
27
|
## 4.14.0
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/main.js
CHANGED
|
@@ -18,44 +18,43 @@ $parcel$export(module.exports, "DragHandle", () => $7340ff11beb99de7$export$a0c2
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
const $590c5f6da3a22459$export$ffd58b7f6f099a57 = ()=>({
|
|
21
|
-
label: /*#__PURE__*/ $9zqHf$emotion.css({
|
|
21
|
+
label: /*#__PURE__*/ (0, $9zqHf$emotion.css)({
|
|
22
22
|
name: "1b512s9",
|
|
23
23
|
styles: "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0;"
|
|
24
24
|
}),
|
|
25
25
|
root: ({ isActive: isActive , isFocused: isFocused , isHovered: isHovered })=>{
|
|
26
|
-
return $9zqHf$emotion.cx(/*#__PURE__*/ $9zqHf$emotion.css({
|
|
27
|
-
alignItems:
|
|
28
|
-
backgroundColor: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).gray100,
|
|
26
|
+
return (0, $9zqHf$emotion.cx)(/*#__PURE__*/ (0, $9zqHf$emotion.css)({
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
backgroundColor: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).gray100,
|
|
29
29
|
border: 0,
|
|
30
|
-
borderBottomLeftRadius: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).borderRadiusMedium,
|
|
31
|
-
borderRight: `1px solid ${($parcel$interopDefault($9zqHf$contentfulf36tokens)).gray200}`,
|
|
32
|
-
borderTopLeftRadius: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).borderRadiusMedium,
|
|
33
|
-
boxSizing:
|
|
34
|
-
display:
|
|
35
|
-
justifyContent:
|
|
30
|
+
borderBottomLeftRadius: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).borderRadiusMedium,
|
|
31
|
+
borderRight: `1px solid ${(0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).gray200}`,
|
|
32
|
+
borderTopLeftRadius: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).borderRadiusMedium,
|
|
33
|
+
boxSizing: "border-box",
|
|
34
|
+
display: "flex",
|
|
35
|
+
justifyContent: "center",
|
|
36
36
|
padding: 0,
|
|
37
|
-
position:
|
|
38
|
-
transition: `background-color ${($parcel$interopDefault($9zqHf$contentfulf36tokens)).transitionDurationDefault} ${($parcel$interopDefault($9zqHf$contentfulf36tokens)).transitionEasingDefault}`,
|
|
39
|
-
width: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).spacingL,
|
|
40
|
-
|
|
41
|
-
backgroundColor: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).gray200
|
|
37
|
+
position: "relative",
|
|
38
|
+
transition: `background-color ${(0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).transitionDurationDefault} ${(0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).transitionEasingDefault}`,
|
|
39
|
+
width: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).spacingL,
|
|
40
|
+
"&:hover": {
|
|
41
|
+
backgroundColor: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).gray200
|
|
42
42
|
},
|
|
43
|
-
|
|
44
|
-
boxShadow: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).glowPrimary
|
|
43
|
+
"&:focus": {
|
|
44
|
+
boxShadow: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).glowPrimary
|
|
45
45
|
},
|
|
46
|
-
|
|
47
|
-
boxShadow:
|
|
46
|
+
"&:focus:not(:focus-visible)": {
|
|
47
|
+
boxShadow: "unset"
|
|
48
48
|
},
|
|
49
|
-
|
|
50
|
-
boxShadow: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).glowPrimary
|
|
49
|
+
"&:focus-visible": {
|
|
50
|
+
boxShadow: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).glowPrimary
|
|
51
51
|
}
|
|
52
|
-
}), (isActive || isFocused || isHovered) && /*#__PURE__*/ $9zqHf$emotion.css({
|
|
53
|
-
backgroundColor: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).gray200,
|
|
54
|
-
cursor: isActive ?
|
|
52
|
+
}), (isActive || isFocused || isHovered) && /*#__PURE__*/ (0, $9zqHf$emotion.css)({
|
|
53
|
+
backgroundColor: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).gray200,
|
|
54
|
+
cursor: isActive ? "grabbing" : "grab"
|
|
55
55
|
}));
|
|
56
56
|
}
|
|
57
|
-
})
|
|
58
|
-
;
|
|
57
|
+
});
|
|
59
58
|
|
|
60
59
|
|
|
61
60
|
//
|
|
@@ -66,43 +65,43 @@ const $590c5f6da3a22459$export$ffd58b7f6f099a57 = ()=>({
|
|
|
66
65
|
//
|
|
67
66
|
// default shouldCancelStart callback:
|
|
68
67
|
// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js
|
|
69
|
-
const $7340ff11beb99de7$var$DRAG_HANDLE_DEFAULT_TAG =
|
|
68
|
+
const $7340ff11beb99de7$var$DRAG_HANDLE_DEFAULT_TAG = "div";
|
|
70
69
|
function $7340ff11beb99de7$var$_DragHandle(props, ref) {
|
|
71
|
-
const styles = $590c5f6da3a22459$export$ffd58b7f6f099a57();
|
|
72
|
-
const { as: as = $7340ff11beb99de7$var$DRAG_HANDLE_DEFAULT_TAG , className: className , isActive: isActive , isFocused: isFocusedProp , isHovered: isHoveredProp , label: label , onBlur: onBlur , onFocus: onFocus , onMouseEnter: onMouseEnter , onMouseLeave: onMouseLeave , testId: testId =
|
|
73
|
-
const [isFocused, setisFocused] = $9zqHf$react.useState(isFocusedProp);
|
|
74
|
-
const [isHovered, setisHovered] = $9zqHf$react.useState(isHoveredProp);
|
|
75
|
-
const handleFocus = $9zqHf$react.useCallback((event)=>{
|
|
70
|
+
const styles = (0, $590c5f6da3a22459$export$ffd58b7f6f099a57)();
|
|
71
|
+
const { as: as = $7340ff11beb99de7$var$DRAG_HANDLE_DEFAULT_TAG , className: className , isActive: isActive , isFocused: isFocusedProp , isHovered: isHoveredProp , label: label , onBlur: onBlur , onFocus: onFocus , onMouseEnter: onMouseEnter , onMouseLeave: onMouseLeave , testId: testId = "cf-ui-drag-handle" , style: style , ...otherProps } = props;
|
|
72
|
+
const [isFocused, setisFocused] = (0, $9zqHf$react.useState)(isFocusedProp);
|
|
73
|
+
const [isHovered, setisHovered] = (0, $9zqHf$react.useState)(isHoveredProp);
|
|
74
|
+
const handleFocus = (0, $9zqHf$react.useCallback)((event)=>{
|
|
76
75
|
setisFocused(true);
|
|
77
76
|
if (onFocus) onFocus(event);
|
|
78
77
|
}, [
|
|
79
78
|
onFocus
|
|
80
79
|
]);
|
|
81
|
-
const handleBlur = $9zqHf$react.useCallback((event)=>{
|
|
80
|
+
const handleBlur = (0, $9zqHf$react.useCallback)((event)=>{
|
|
82
81
|
setisFocused(false);
|
|
83
82
|
if (onBlur) onBlur(event);
|
|
84
83
|
}, [
|
|
85
84
|
onBlur
|
|
86
85
|
]);
|
|
87
|
-
const handleMouseEnter = $9zqHf$react.useCallback((event)=>{
|
|
86
|
+
const handleMouseEnter = (0, $9zqHf$react.useCallback)((event)=>{
|
|
88
87
|
setisHovered(true);
|
|
89
88
|
if (onMouseEnter) onMouseEnter(event);
|
|
90
89
|
}, [
|
|
91
90
|
onMouseEnter
|
|
92
91
|
]);
|
|
93
|
-
const handleMouseLeave = $9zqHf$react.useCallback((event)=>{
|
|
92
|
+
const handleMouseLeave = (0, $9zqHf$react.useCallback)((event)=>{
|
|
94
93
|
setisHovered(false);
|
|
95
94
|
if (onMouseLeave) onMouseLeave(event);
|
|
96
95
|
}, [
|
|
97
96
|
onMouseLeave
|
|
98
97
|
]);
|
|
99
98
|
const commonProps = {
|
|
100
|
-
className: $9zqHf$emotion.cx(styles.root({
|
|
99
|
+
className: (0, $9zqHf$emotion.cx)(styles.root({
|
|
101
100
|
isActive: isActive,
|
|
102
101
|
isFocused: isFocused,
|
|
103
102
|
isHovered: isHovered
|
|
104
103
|
}), className),
|
|
105
|
-
|
|
104
|
+
"data-test-id": testId,
|
|
106
105
|
onBlur: handleBlur,
|
|
107
106
|
onFocus: handleFocus,
|
|
108
107
|
onMouseEnter: handleMouseEnter,
|
|
@@ -110,27 +109,27 @@ function $7340ff11beb99de7$var$_DragHandle(props, ref) {
|
|
|
110
109
|
ref: ref,
|
|
111
110
|
style: style
|
|
112
111
|
};
|
|
113
|
-
if (as ===
|
|
112
|
+
if (as === "div") return /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement("div", {
|
|
114
113
|
...otherProps,
|
|
115
114
|
...commonProps,
|
|
116
115
|
role: "button",
|
|
117
116
|
tabIndex: 0
|
|
118
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement($9zqHf$contentfulf36icons.DragIcon, {
|
|
117
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement((0, $9zqHf$contentfulf36icons.DragIcon), {
|
|
119
118
|
variant: "muted"
|
|
120
|
-
}), /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement("span", {
|
|
119
|
+
}), /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement("span", {
|
|
121
120
|
className: styles.label
|
|
122
121
|
}, label));
|
|
123
|
-
return /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement("button", {
|
|
122
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement("button", {
|
|
124
123
|
...otherProps,
|
|
125
124
|
...commonProps,
|
|
126
125
|
type: "button"
|
|
127
|
-
}, /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement($9zqHf$contentfulf36icons.DragIcon, {
|
|
126
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement((0, $9zqHf$contentfulf36icons.DragIcon), {
|
|
128
127
|
variant: "muted"
|
|
129
|
-
}), /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement("span", {
|
|
128
|
+
}), /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement("span", {
|
|
130
129
|
className: styles.label
|
|
131
130
|
}, label));
|
|
132
131
|
}
|
|
133
|
-
const $7340ff11beb99de7$export$a0c24614540b0efb = /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).forwardRef($7340ff11beb99de7$var$_DragHandle);
|
|
132
|
+
const $7340ff11beb99de7$export$a0c24614540b0efb = /*#__PURE__*/ (0, ($parcel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kCAAD;QAAU,OAAA,EAAQ,OAAlB;MAAR,gBACQ,qDAAC,MAAD;QAAM,SAAA,EAAWnB,MAAM,CAACN,KAAR;OAAgBA,KAAD,CAAvC,CAHI,CAIJ;IAIE,qBACE,qDAAC,QAAD;QAAQ,GAAIgB,UAAJ;QAAgB,GAAIS,WAAJ;QAAiB,IAAA,EAAK,QAA9C;qBACE,qDAAC,kCAAD;QAAU,OAAA,EAAQ,OAAlB;MAAN,gBACM,qDAAC,MAAD;QAAM,SAAA,EAAWnB,MAAM,CAACN,KAAR;OAAgBA,KAAD,CAArC,CAHE,CAIF;CAEC;AAEM,MAAMrB,yCAAU,iBAInBE,sCAAK,CAAC8C,UAAN,CAAiBxB,iCAAjB,CAJG,AAAP;;AD7JA","sources":["packages/components/drag-handle/src/index.ts","packages/components/drag-handle/src/DragHandle.tsx","packages/components/drag-handle/src/DragHandle.styles.ts"],"sourcesContent":["export { DragHandle } from './DragHandle';\nexport type { DragHandleProps } from './DragHandle';\n","import React, { useCallback, useState } from 'react';\nimport type {\n /* ElementRef, */\n ElementType,\n FocusEventHandler,\n MouseEventHandler,\n Ref,\n} from 'react';\nimport { cx } from 'emotion';\nimport type {\n PolymorphicComponent,\n PolymorphicProps,\n} from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { DragIcon } from '@contentful/f36-icons';\nimport { getStyles } from './DragHandle.styles';\n\n// We use div instead of a button because react-sortable-hoc lib cancels sorting if the event target is button.\n//\n// The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,\n// in every place where we use this component with react-sortable-hoc.\n// (the custom callback with all the logic from default callback, but without button event cancelation).\n// So we decided that just changing it to the div, as it was in v3, is a better fix.\n//\n// default shouldCancelStart callback:\n// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js\nconst DRAG_HANDLE_DEFAULT_TAG = 'div';\n\nexport interface DragHandleInternalProps extends CommonProps {\n /**\n * The element used for the root node\n * @default div\n */\n as?: 'button' | 'div';\n /**\n * Applies styling for when the component is actively being dragged by\n * the user\n */\n isActive?: boolean;\n /**\n * Applies focus styling\n */\n isFocused?: boolean;\n /**\n * Applies hover styling\n */\n isHovered?: boolean;\n /**\n * Label rendered in DragHandle - not visible on screen as its purpose\n * is for screen readers only\n */\n label: string;\n /**\n * Set type button for div element\n */\n type?: string;\n}\n\nexport type DragHandleProps<\n E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG\n> = PolymorphicProps<DragHandleInternalProps, E>;\n\nfunction _DragHandle<E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG>(\n props: DragHandleProps<E>,\n ref: Ref<any>,\n) {\n const styles = getStyles();\n const {\n as = DRAG_HANDLE_DEFAULT_TAG,\n className,\n isActive,\n isFocused: isFocusedProp,\n isHovered: isHoveredProp,\n label,\n onBlur,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n testId = 'cf-ui-drag-handle',\n style,\n ...otherProps\n } = props;\n const [isFocused, setisFocused] = useState(isFocusedProp);\n const [isHovered, setisHovered] = useState(isHoveredProp);\n\n const handleFocus = useCallback<FocusEventHandler<HTMLElement>>(\n (event) => {\n setisFocused(true);\n\n if (onFocus) {\n onFocus(event);\n }\n },\n [onFocus],\n );\n\n const handleBlur = useCallback<FocusEventHandler<HTMLElement>>(\n (event) => {\n setisFocused(false);\n\n if (onBlur) {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback<MouseEventHandler<HTMLElement>>(\n (event) => {\n setisHovered(true);\n\n if (onMouseEnter) {\n onMouseEnter(event);\n }\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback<MouseEventHandler<HTMLElement>>(\n (event) => {\n setisHovered(false);\n\n if (onMouseLeave) {\n onMouseLeave(event);\n }\n },\n [onMouseLeave],\n );\n\n const commonProps = {\n className: cx(styles.root({ isActive, isFocused, isHovered }), className),\n 'data-test-id': testId,\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n ref,\n style,\n };\n\n if (as === 'div') {\n return (\n <div {...otherProps} {...commonProps} role=\"button\" tabIndex={0}>\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </div>\n );\n }\n\n return (\n <button {...otherProps} {...commonProps} type=\"button\">\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </button>\n );\n}\n\nexport const DragHandle: PolymorphicComponent<\n ExpandProps<DragHandleInternalProps>,\n typeof DRAG_HANDLE_DEFAULT_TAG,\n 'disabled'\n> = React.forwardRef(_DragHandle);\n","import { cx, css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getStyles = () => ({\n label: css({\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: 0,\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n border: 0,\n }),\n root: ({\n isActive,\n isFocused,\n isHovered,\n }: {\n isActive: boolean;\n isFocused: boolean;\n isHovered: boolean;\n }) => {\n return cx(\n css({\n alignItems: 'center',\n backgroundColor: tokens.gray100,\n border: 0,\n borderBottomLeftRadius: tokens.borderRadiusMedium,\n borderRight: `1px solid ${tokens.gray200}`,\n borderTopLeftRadius: tokens.borderRadiusMedium,\n boxSizing: 'border-box',\n display: 'flex',\n justifyContent: 'center',\n padding: 0,\n position: 'relative',\n transition: `background-color ${tokens.transitionDurationDefault} ${tokens.transitionEasingDefault}`,\n width: tokens.spacingL,\n '&:hover': {\n backgroundColor: tokens.gray200,\n },\n '&:focus': {\n boxShadow: tokens.glowPrimary,\n },\n '&:focus:not(:focus-visible)': {\n boxShadow: 'unset',\n },\n '&:focus-visible': {\n boxShadow: tokens.glowPrimary,\n },\n }),\n (isActive || isFocused || isHovered) &&\n css({\n backgroundColor: tokens.gray200,\n cursor: isActive ? 'grabbing' : 'grab',\n }),\n );\n },\n});\n"],"names":["DragHandle","DragHandleProps","React","useCallback","useState","ElementType","FocusEventHandler","MouseEventHandler","Ref","PolymorphicComponent","PolymorphicProps","CommonProps","ExpandProps","DragIcon","getStyles","DRAG_HANDLE_DEFAULT_TAG","DragHandleInternalProps","as","isActive","isFocused","isHovered","label","type","E","_DragHandle","props","ref","styles","className","isFocusedProp","isHoveredProp","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style","otherProps","setisFocused","setisHovered","handleFocus","HTMLElement","event","handleBlur","handleMouseEnter","handleMouseLeave","commonProps","root","forwardRef","tokens","alignItems","backgroundColor","gray100","border","borderBottomLeftRadius","borderRadiusMedium","borderRight","gray200","borderTopLeftRadius","boxSizing","display","justifyContent","padding","position","transition","transitionDurationDefault","transitionEasingDefault","width","spacingL","boxShadow","glowPrimary","cursor"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;A;;;A;;;AEGO,MAAMc,yCAAS,GAAG,IAAO,CAAA;QAC9BO,KAAK,EAAA,aAAE,CAAA,CAAA,GAAA,kBAAPA,CAAAA,CAAAA;YAAO,IAAA,EAAA,SAAA;YAAA,MAAA,EAAA,8GAAA;SAAA,CADuB;QAW9B0B,IAAI,EAAE,CAAC,YACL7B,QADK,CAAA,aAELC,SAFK,CAAA,aAGLC,SAAAA,CAAAA,EAHI,GAQA;YACJ,OAAO,CAAA,GAAA,iBAAA,CAAA,CAAA,aACL,CAAA,CAAA,GAAA,kBAAA,CAAA,CAAI;gBACF8B,UAAU,EAAE,QADV;gBAEFC,eAAe,EAAEF,CAAAA,GAAAA,oDAAM,CAAA,CAACG,OAFtB;gBAGFC,MAAM,EAAE,CAHN;gBAIFC,sBAAsB,EAAEL,CAAAA,GAAAA,oDAAM,CAAA,CAACM,kBAJ7B;gBAKFC,WAAW,EAAG,CAAA,UAAA,EAAYP,CAAAA,GAAAA,oDAAM,CAAA,CAACQ,OAAQ,CAAA,CALvC;gBAMFC,mBAAmB,EAAET,CAAAA,GAAAA,oDAAM,CAAA,CAACM,kBA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,yCAAU,iBAInBE,CAAAA,GAAAA,sCAAK,CAAA,CAAC8C,UAAN,CAAiBxB,iCAAjB,CAJG,AAAP;;AD/JA","sources":["packages/components/drag-handle/src/index.ts","packages/components/drag-handle/src/DragHandle.tsx","packages/components/drag-handle/src/DragHandle.styles.ts"],"sourcesContent":["export { DragHandle } from './DragHandle';\nexport type { DragHandleProps } from './DragHandle';\n","import React, {\n useCallback,\n useState,\n type ElementType,\n type FocusEventHandler,\n type MouseEventHandler,\n type Ref,\n} from 'react';\nimport { cx } from 'emotion';\nimport type {\n PolymorphicComponent,\n PolymorphicProps,\n CommonProps,\n ExpandProps,\n} from '@contentful/f36-core';\nimport { DragIcon } from '@contentful/f36-icons';\n\nimport { getStyles } from './DragHandle.styles';\n\n// We use div instead of a button because react-sortable-hoc lib cancels sorting if the event target is button.\n//\n// The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,\n// in every place where we use this component with react-sortable-hoc.\n// (the custom callback with all the logic from default callback, but without button event cancelation).\n// So we decided that just changing it to the div, as it was in v3, is a better fix.\n//\n// default shouldCancelStart callback:\n// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js\nconst DRAG_HANDLE_DEFAULT_TAG = 'div';\n\nexport interface DragHandleInternalProps extends CommonProps {\n /**\n * The element used for the root node\n * @default div\n */\n as?: 'button' | 'div';\n /**\n * Applies styling for when the component is actively being dragged by\n * the user\n */\n isActive?: boolean;\n /**\n * Applies focus styling\n */\n isFocused?: boolean;\n /**\n * Applies hover styling\n */\n isHovered?: boolean;\n /**\n * Label rendered in DragHandle - not visible on screen as its purpose\n * is for screen readers only\n */\n label: string;\n /**\n * Set type button for div element\n */\n type?: string;\n}\n\nexport type DragHandleProps<\n E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG,\n> = PolymorphicProps<DragHandleInternalProps, E>;\n\nfunction _DragHandle<E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG>(\n props: DragHandleProps<E>,\n ref: Ref<any>,\n) {\n const styles = getStyles();\n const {\n as = DRAG_HANDLE_DEFAULT_TAG,\n className,\n isActive,\n isFocused: isFocusedProp,\n isHovered: isHoveredProp,\n label,\n onBlur,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n testId = 'cf-ui-drag-handle',\n style,\n ...otherProps\n } = props;\n const [isFocused, setisFocused] = useState(isFocusedProp);\n const [isHovered, setisHovered] = useState(isHoveredProp);\n\n const handleFocus = useCallback<FocusEventHandler<HTMLElement>>(\n (event) => {\n setisFocused(true);\n\n if (onFocus) {\n onFocus(event);\n }\n },\n [onFocus],\n );\n\n const handleBlur = useCallback<FocusEventHandler<HTMLElement>>(\n (event) => {\n setisFocused(false);\n\n if (onBlur) {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback<MouseEventHandler<HTMLElement>>(\n (event) => {\n setisHovered(true);\n\n if (onMouseEnter) {\n onMouseEnter(event);\n }\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback<MouseEventHandler<HTMLElement>>(\n (event) => {\n setisHovered(false);\n\n if (onMouseLeave) {\n onMouseLeave(event);\n }\n },\n [onMouseLeave],\n );\n\n const commonProps = {\n className: cx(styles.root({ isActive, isFocused, isHovered }), className),\n 'data-test-id': testId,\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n ref,\n style,\n };\n\n if (as === 'div') {\n return (\n <div {...otherProps} {...commonProps} role=\"button\" tabIndex={0}>\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </div>\n );\n }\n\n return (\n <button {...otherProps} {...commonProps} type=\"button\">\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </button>\n );\n}\n\nexport const DragHandle: PolymorphicComponent<\n ExpandProps<DragHandleInternalProps>,\n typeof DRAG_HANDLE_DEFAULT_TAG,\n 'disabled'\n> = React.forwardRef(_DragHandle);\n","import { cx, css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getStyles = () => ({\n label: css({\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: 0,\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n border: 0,\n }),\n root: ({\n isActive,\n isFocused,\n isHovered,\n }: {\n isActive: boolean;\n isFocused: boolean;\n isHovered: boolean;\n }) => {\n return cx(\n css({\n alignItems: 'center',\n backgroundColor: tokens.gray100,\n border: 0,\n borderBottomLeftRadius: tokens.borderRadiusMedium,\n borderRight: `1px solid ${tokens.gray200}`,\n borderTopLeftRadius: tokens.borderRadiusMedium,\n boxSizing: 'border-box',\n display: 'flex',\n justifyContent: 'center',\n padding: 0,\n position: 'relative',\n transition: `background-color ${tokens.transitionDurationDefault} ${tokens.transitionEasingDefault}`,\n width: tokens.spacingL,\n '&:hover': {\n backgroundColor: tokens.gray200,\n },\n '&:focus': {\n boxShadow: tokens.glowPrimary,\n },\n '&:focus:not(:focus-visible)': {\n boxShadow: 'unset',\n },\n '&:focus-visible': {\n boxShadow: tokens.glowPrimary,\n },\n }),\n (isActive || isFocused || isHovered) &&\n css({\n backgroundColor: tokens.gray200,\n cursor: isActive ? 'grabbing' : 'grab',\n }),\n );\n },\n});\n"],"names":["DragHandle","DragHandleProps","React","useCallback","useState","ElementType","FocusEventHandler","MouseEventHandler","Ref","PolymorphicComponent","PolymorphicProps","CommonProps","ExpandProps","DragIcon","getStyles","DRAG_HANDLE_DEFAULT_TAG","DragHandleInternalProps","as","isActive","isFocused","isHovered","label","type","E","_DragHandle","props","ref","styles","className","isFocusedProp","isHoveredProp","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style","otherProps","setisFocused","setisHovered","handleFocus","HTMLElement","event","handleBlur","handleMouseEnter","handleMouseLeave","commonProps","root","forwardRef","tokens","alignItems","backgroundColor","gray100","border","borderBottomLeftRadius","borderRadiusMedium","borderRight","gray200","borderTopLeftRadius","boxSizing","display","justifyContent","padding","position","transition","transitionDurationDefault","transitionEasingDefault","width","spacingL","boxShadow","glowPrimary","cursor"],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -10,44 +10,43 @@ import $8USmO$contentfulf36tokens from "@contentful/f36-tokens";
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
const $1282af47e008eae6$export$ffd58b7f6f099a57 = ()=>({
|
|
13
|
-
label: /*#__PURE__*/ $8USmO$css({
|
|
13
|
+
label: /*#__PURE__*/ (0, $8USmO$css)({
|
|
14
14
|
name: "1b512s9",
|
|
15
15
|
styles: "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0;"
|
|
16
16
|
}),
|
|
17
17
|
root: ({ isActive: isActive , isFocused: isFocused , isHovered: isHovered })=>{
|
|
18
|
-
return $8USmO$cx(/*#__PURE__*/ $8USmO$css({
|
|
19
|
-
alignItems:
|
|
20
|
-
backgroundColor: $8USmO$contentfulf36tokens.gray100,
|
|
18
|
+
return (0, $8USmO$cx)(/*#__PURE__*/ (0, $8USmO$css)({
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
backgroundColor: (0, $8USmO$contentfulf36tokens).gray100,
|
|
21
21
|
border: 0,
|
|
22
|
-
borderBottomLeftRadius: $8USmO$contentfulf36tokens.borderRadiusMedium,
|
|
23
|
-
borderRight: `1px solid ${$8USmO$contentfulf36tokens.gray200}`,
|
|
24
|
-
borderTopLeftRadius: $8USmO$contentfulf36tokens.borderRadiusMedium,
|
|
25
|
-
boxSizing:
|
|
26
|
-
display:
|
|
27
|
-
justifyContent:
|
|
22
|
+
borderBottomLeftRadius: (0, $8USmO$contentfulf36tokens).borderRadiusMedium,
|
|
23
|
+
borderRight: `1px solid ${(0, $8USmO$contentfulf36tokens).gray200}`,
|
|
24
|
+
borderTopLeftRadius: (0, $8USmO$contentfulf36tokens).borderRadiusMedium,
|
|
25
|
+
boxSizing: "border-box",
|
|
26
|
+
display: "flex",
|
|
27
|
+
justifyContent: "center",
|
|
28
28
|
padding: 0,
|
|
29
|
-
position:
|
|
30
|
-
transition: `background-color ${$8USmO$contentfulf36tokens.transitionDurationDefault} ${$8USmO$contentfulf36tokens.transitionEasingDefault}`,
|
|
31
|
-
width: $8USmO$contentfulf36tokens.spacingL,
|
|
32
|
-
|
|
33
|
-
backgroundColor: $8USmO$contentfulf36tokens.gray200
|
|
29
|
+
position: "relative",
|
|
30
|
+
transition: `background-color ${(0, $8USmO$contentfulf36tokens).transitionDurationDefault} ${(0, $8USmO$contentfulf36tokens).transitionEasingDefault}`,
|
|
31
|
+
width: (0, $8USmO$contentfulf36tokens).spacingL,
|
|
32
|
+
"&:hover": {
|
|
33
|
+
backgroundColor: (0, $8USmO$contentfulf36tokens).gray200
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
boxShadow: $8USmO$contentfulf36tokens.glowPrimary
|
|
35
|
+
"&:focus": {
|
|
36
|
+
boxShadow: (0, $8USmO$contentfulf36tokens).glowPrimary
|
|
37
37
|
},
|
|
38
|
-
|
|
39
|
-
boxShadow:
|
|
38
|
+
"&:focus:not(:focus-visible)": {
|
|
39
|
+
boxShadow: "unset"
|
|
40
40
|
},
|
|
41
|
-
|
|
42
|
-
boxShadow: $8USmO$contentfulf36tokens.glowPrimary
|
|
41
|
+
"&:focus-visible": {
|
|
42
|
+
boxShadow: (0, $8USmO$contentfulf36tokens).glowPrimary
|
|
43
43
|
}
|
|
44
|
-
}), (isActive || isFocused || isHovered) && /*#__PURE__*/ $8USmO$css({
|
|
45
|
-
backgroundColor: $8USmO$contentfulf36tokens.gray200,
|
|
46
|
-
cursor: isActive ?
|
|
44
|
+
}), (isActive || isFocused || isHovered) && /*#__PURE__*/ (0, $8USmO$css)({
|
|
45
|
+
backgroundColor: (0, $8USmO$contentfulf36tokens).gray200,
|
|
46
|
+
cursor: isActive ? "grabbing" : "grab"
|
|
47
47
|
}));
|
|
48
48
|
}
|
|
49
|
-
})
|
|
50
|
-
;
|
|
49
|
+
});
|
|
51
50
|
|
|
52
51
|
|
|
53
52
|
//
|
|
@@ -58,43 +57,43 @@ const $1282af47e008eae6$export$ffd58b7f6f099a57 = ()=>({
|
|
|
58
57
|
//
|
|
59
58
|
// default shouldCancelStart callback:
|
|
60
59
|
// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js
|
|
61
|
-
const $0d6e001a91dc675e$var$DRAG_HANDLE_DEFAULT_TAG =
|
|
60
|
+
const $0d6e001a91dc675e$var$DRAG_HANDLE_DEFAULT_TAG = "div";
|
|
62
61
|
function $0d6e001a91dc675e$var$_DragHandle(props, ref) {
|
|
63
|
-
const styles = $1282af47e008eae6$export$ffd58b7f6f099a57();
|
|
64
|
-
const { as: as = $0d6e001a91dc675e$var$DRAG_HANDLE_DEFAULT_TAG , className: className , isActive: isActive , isFocused: isFocusedProp , isHovered: isHoveredProp , label: label , onBlur: onBlur , onFocus: onFocus , onMouseEnter: onMouseEnter , onMouseLeave: onMouseLeave , testId: testId =
|
|
65
|
-
const [isFocused, setisFocused] = $8USmO$useState(isFocusedProp);
|
|
66
|
-
const [isHovered, setisHovered] = $8USmO$useState(isHoveredProp);
|
|
67
|
-
const handleFocus = $8USmO$useCallback((event)=>{
|
|
62
|
+
const styles = (0, $1282af47e008eae6$export$ffd58b7f6f099a57)();
|
|
63
|
+
const { as: as = $0d6e001a91dc675e$var$DRAG_HANDLE_DEFAULT_TAG , className: className , isActive: isActive , isFocused: isFocusedProp , isHovered: isHoveredProp , label: label , onBlur: onBlur , onFocus: onFocus , onMouseEnter: onMouseEnter , onMouseLeave: onMouseLeave , testId: testId = "cf-ui-drag-handle" , style: style , ...otherProps } = props;
|
|
64
|
+
const [isFocused, setisFocused] = (0, $8USmO$useState)(isFocusedProp);
|
|
65
|
+
const [isHovered, setisHovered] = (0, $8USmO$useState)(isHoveredProp);
|
|
66
|
+
const handleFocus = (0, $8USmO$useCallback)((event)=>{
|
|
68
67
|
setisFocused(true);
|
|
69
68
|
if (onFocus) onFocus(event);
|
|
70
69
|
}, [
|
|
71
70
|
onFocus
|
|
72
71
|
]);
|
|
73
|
-
const handleBlur = $8USmO$useCallback((event)=>{
|
|
72
|
+
const handleBlur = (0, $8USmO$useCallback)((event)=>{
|
|
74
73
|
setisFocused(false);
|
|
75
74
|
if (onBlur) onBlur(event);
|
|
76
75
|
}, [
|
|
77
76
|
onBlur
|
|
78
77
|
]);
|
|
79
|
-
const handleMouseEnter = $8USmO$useCallback((event)=>{
|
|
78
|
+
const handleMouseEnter = (0, $8USmO$useCallback)((event)=>{
|
|
80
79
|
setisHovered(true);
|
|
81
80
|
if (onMouseEnter) onMouseEnter(event);
|
|
82
81
|
}, [
|
|
83
82
|
onMouseEnter
|
|
84
83
|
]);
|
|
85
|
-
const handleMouseLeave = $8USmO$useCallback((event)=>{
|
|
84
|
+
const handleMouseLeave = (0, $8USmO$useCallback)((event)=>{
|
|
86
85
|
setisHovered(false);
|
|
87
86
|
if (onMouseLeave) onMouseLeave(event);
|
|
88
87
|
}, [
|
|
89
88
|
onMouseLeave
|
|
90
89
|
]);
|
|
91
90
|
const commonProps = {
|
|
92
|
-
className: $8USmO$cx(styles.root({
|
|
91
|
+
className: (0, $8USmO$cx)(styles.root({
|
|
93
92
|
isActive: isActive,
|
|
94
93
|
isFocused: isFocused,
|
|
95
94
|
isHovered: isHovered
|
|
96
95
|
}), className),
|
|
97
|
-
|
|
96
|
+
"data-test-id": testId,
|
|
98
97
|
onBlur: handleBlur,
|
|
99
98
|
onFocus: handleFocus,
|
|
100
99
|
onMouseEnter: handleMouseEnter,
|
|
@@ -102,27 +101,27 @@ function $0d6e001a91dc675e$var$_DragHandle(props, ref) {
|
|
|
102
101
|
ref: ref,
|
|
103
102
|
style: style
|
|
104
103
|
};
|
|
105
|
-
if (as ===
|
|
104
|
+
if (as === "div") return /*#__PURE__*/ (0, $8USmO$react).createElement("div", {
|
|
106
105
|
...otherProps,
|
|
107
106
|
...commonProps,
|
|
108
107
|
role: "button",
|
|
109
108
|
tabIndex: 0
|
|
110
|
-
}, /*#__PURE__*/ $8USmO$react.createElement($8USmO$DragIcon, {
|
|
109
|
+
}, /*#__PURE__*/ (0, $8USmO$react).createElement((0, $8USmO$DragIcon), {
|
|
111
110
|
variant: "muted"
|
|
112
|
-
}), /*#__PURE__*/ $8USmO$react.createElement("span", {
|
|
111
|
+
}), /*#__PURE__*/ (0, $8USmO$react).createElement("span", {
|
|
113
112
|
className: styles.label
|
|
114
113
|
}, label));
|
|
115
|
-
return /*#__PURE__*/ $8USmO$react.createElement("button", {
|
|
114
|
+
return /*#__PURE__*/ (0, $8USmO$react).createElement("button", {
|
|
116
115
|
...otherProps,
|
|
117
116
|
...commonProps,
|
|
118
117
|
type: "button"
|
|
119
|
-
}, /*#__PURE__*/ $8USmO$react.createElement($8USmO$DragIcon, {
|
|
118
|
+
}, /*#__PURE__*/ (0, $8USmO$react).createElement((0, $8USmO$DragIcon), {
|
|
120
119
|
variant: "muted"
|
|
121
|
-
}), /*#__PURE__*/ $8USmO$react.createElement("span", {
|
|
120
|
+
}), /*#__PURE__*/ (0, $8USmO$react).createElement("span", {
|
|
122
121
|
className: styles.label
|
|
123
122
|
}, label));
|
|
124
123
|
}
|
|
125
|
-
const $0d6e001a91dc675e$export$a0c24614540b0efb = /*#__PURE__*/ $8USmO$react.forwardRef($0d6e001a91dc675e$var$_DragHandle);
|
|
124
|
+
const $0d6e001a91dc675e$export$a0c24614540b0efb = /*#__PURE__*/ (0, $8USmO$react).forwardRef($0d6e001a91dc675e$var$_DragHandle);
|
|
126
125
|
|
|
127
126
|
|
|
128
127
|
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;A;;;A;;;AEGO,MAAMc,yCAAS,GAAG,IAAO,CAAA;QAC9BO,KAAK,EAAA,aAAE,CAAA,UAAPA,CAAAA;YAAO,IAAA,EAA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M,2BAAC,MAAD;QAAM,SAAA,EAAWnB,MAAM,CAACN,KAAR;OAAgBA,KAAD,CAArC,CAHE,CAIF;CAEC;AAEM,MAAMrB,yCAAU,iBAInBE,YAAK,CAAC8C,UAAN,CAAiBxB,iCAAjB,CAJG,AAAP;;AD7JA","sources":["packages/components/drag-handle/src/index.ts","packages/components/drag-handle/src/DragHandle.tsx","packages/components/drag-handle/src/DragHandle.styles.ts"],"sourcesContent":["export { DragHandle } from './DragHandle';\nexport type { DragHandleProps } from './DragHandle';\n","import React, { useCallback, useState } from 'react';\nimport type {\n /* ElementRef, */\n ElementType,\n FocusEventHandler,\n MouseEventHandler,\n Ref,\n} from 'react';\nimport { cx } from 'emotion';\nimport type {\n PolymorphicComponent,\n PolymorphicProps,\n} from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { DragIcon } from '@contentful/f36-icons';\nimport { getStyles } from './DragHandle.styles';\n\n// We use div instead of a button because react-sortable-hoc lib cancels sorting if the event target is button.\n//\n// The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,\n// in every place where we use this component with react-sortable-hoc.\n// (the custom callback with all the logic from default callback, but without button event cancelation).\n// So we decided that just changing it to the div, as it was in v3, is a better fix.\n//\n// default shouldCancelStart callback:\n// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js\nconst DRAG_HANDLE_DEFAULT_TAG = 'div';\n\nexport interface DragHandleInternalProps extends CommonProps {\n /**\n * The element used for the root node\n * @default div\n */\n as?: 'button' | 'div';\n /**\n * Applies styling for when the component is actively being dragged by\n * the user\n */\n isActive?: boolean;\n /**\n * Applies focus styling\n */\n isFocused?: boolean;\n /**\n * Applies hover styling\n */\n isHovered?: boolean;\n /**\n * Label rendered in DragHandle - not visible on screen as its purpose\n * is for screen readers only\n */\n label: string;\n /**\n * Set type button for div element\n */\n type?: string;\n}\n\nexport type DragHandleProps<\n E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG\n> = PolymorphicProps<DragHandleInternalProps, E>;\n\nfunction _DragHandle<E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG>(\n props: DragHandleProps<E>,\n ref: Ref<any>,\n) {\n const styles = getStyles();\n const {\n as = DRAG_HANDLE_DEFAULT_TAG,\n className,\n isActive,\n isFocused: isFocusedProp,\n isHovered: isHoveredProp,\n label,\n onBlur,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n testId = 'cf-ui-drag-handle',\n style,\n ...otherProps\n } = props;\n const [isFocused, setisFocused] = useState(isFocusedProp);\n const [isHovered, setisHovered] = useState(isHoveredProp);\n\n const handleFocus = useCallback<FocusEventHandler<HTMLElement>>(\n (event) => {\n setisFocused(true);\n\n if (onFocus) {\n onFocus(event);\n }\n },\n [onFocus],\n );\n\n const handleBlur = useCallback<FocusEventHandler<HTMLElement>>(\n (event) => {\n setisFocused(false);\n\n if (onBlur) {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback<MouseEventHandler<HTMLElement>>(\n (event) => {\n setisHovered(true);\n\n if (onMouseEnter) {\n onMouseEnter(event);\n }\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback<MouseEventHandler<HTMLElement>>(\n (event) => {\n setisHovered(false);\n\n if (onMouseLeave) {\n onMouseLeave(event);\n }\n },\n [onMouseLeave],\n );\n\n const commonProps = {\n className: cx(styles.root({ isActive, isFocused, isHovered }), className),\n 'data-test-id': testId,\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n ref,\n style,\n };\n\n if (as === 'div') {\n return (\n <div {...otherProps} {...commonProps} role=\"button\" tabIndex={0}>\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </div>\n );\n }\n\n return (\n <button {...otherProps} {...commonProps} type=\"button\">\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </button>\n );\n}\n\nexport const DragHandle: PolymorphicComponent<\n ExpandProps<DragHandleInternalProps>,\n typeof DRAG_HANDLE_DEFAULT_TAG,\n 'disabled'\n> = React.forwardRef(_DragHandle);\n","import { cx, css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getStyles = () => ({\n label: css({\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: 0,\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n border: 0,\n }),\n root: ({\n isActive,\n isFocused,\n isHovered,\n }: {\n isActive: boolean;\n isFocused: boolean;\n isHovered: boolean;\n }) => {\n return cx(\n css({\n alignItems: 'center',\n backgroundColor: tokens.gray100,\n border: 0,\n borderBottomLeftRadius: tokens.borderRadiusMedium,\n borderRight: `1px solid ${tokens.gray200}`,\n borderTopLeftRadius: tokens.borderRadiusMedium,\n boxSizing: 'border-box',\n display: 'flex',\n justifyContent: 'center',\n padding: 0,\n position: 'relative',\n transition: `background-color ${tokens.transitionDurationDefault} ${tokens.transitionEasingDefault}`,\n width: tokens.spacingL,\n '&:hover': {\n backgroundColor: tokens.gray200,\n },\n '&:focus': {\n boxShadow: tokens.glowPrimary,\n },\n '&:focus:not(:focus-visible)': {\n boxShadow: 'unset',\n },\n '&:focus-visible': {\n boxShadow: tokens.glowPrimary,\n },\n }),\n (isActive || isFocused || isHovered) &&\n css({\n backgroundColor: tokens.gray200,\n cursor: isActive ? 'grabbing' : 'grab',\n }),\n );\n },\n});\n"],"names":["DragHandle","DragHandleProps","React","useCallback","useState","ElementType","FocusEventHandler","MouseEventHandler","Ref","PolymorphicComponent","PolymorphicProps","CommonProps","ExpandProps","DragIcon","getStyles","DRAG_HANDLE_DEFAULT_TAG","DragHandleInternalProps","as","isActive","isFocused","isHovered","label","type","E","_DragHandle","props","ref","styles","className","isFocusedProp","isHoveredProp","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style","otherProps","setisFocused","setisHovered","handleFocus","HTMLElement","event","handleBlur","handleMouseEnter","handleMouseLeave","commonProps","root","forwardRef","tokens","alignItems","backgroundColor","gray100","border","borderBottomLeftRadius","borderRadiusMedium","borderRight","gray200","borderTopLeftRadius","boxSizing","display","justifyContent","padding","position","transition","transitionDurationDefault","transitionEasingDefault","width","spacingL","boxShadow","glowPrimary","cursor"],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;A;;;A;;;AEGO,MAAMc,yCAAS,GAAG,IAAO,CAAA;QAC9BO,KAAK,EAAA,aAAE,CAAA,CAAA,GAAA,UAAPA,CAAAA,CAAAA;YAAO,IAAA,EAAA,SAAA;YAAA,MAAA,EAAA,8GAAA;SAAA,CADuB;QAW9B0B,IAAI,EAAE,CAAC,YACL7B,QADK,CAAA,aAELC,SAFK,CAAA,aAGLC,SAAAA,CAAAA,EAHI,GAQA;YACJ,OAAO,CAAA,GAAA,SAAA,CAAA,CAAA,aACL,CAAA,CAAA,GAAA,UAAA,CAAA,CAAI;gBACF8B,UAAU,EAAE,QADV;gBAEFC,eAAe,EAAEF,CAAAA,GAAAA,0BAAM,CAAA,CAACG,OAFtB;gBAGFC,MAAM,EAAE,CAHN;gBAIFC,sBAAsB,EAAEL,CAAAA,GAAAA,0BAAM,CAAA,CAACM,kBAJ7B;gBAKFC,WAAW,EAAG,CAAA,UAAA,EAAYP,CAAAA,GAAAA,0BAAM,CAAA,CAACQ,OAAQ,CAAA,CALvC;gBAMFC,mBAAmB,EAAET,CAAAA,GAAAA,0BAAM,CAAA,CAACM,kBAN1B;gBAOFI,SAAS,EAAE,YAPT;gBAQFC,OAAO,EAAE,MARP;gBASFC,cAAc,EAAE,QATd;gBAUFC,OAAO,EAAE,CAVP;gBAWFC,QAAQ,EAAE,UAXR;gBAYFC,UAAU,EAAG,CAAA,iBAAA,EAAmBf,CAAAA,GAAAA,0BAAM,CAAA,CAACgB,yBAA0B,CAAA,CAAA,EAAGhB,CAAAA,GAAAA,0BAAM,CAAA,CAACiB,uBAAwB,CAAA,CAZjG;gBA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S,EAAE,CAAA,GAAA,SAAA,CAAA,CAAGD,MAAM,CAACoB,IAAP,CAAY;sBAAE7B,QAAF;uBAAYC,SAAZ;uBAAuBC,SAAAA;SAAnC,CAAH,EAAoDQ,SAApD,CADO;QAElB,cAAA,EAAgBO,MAFE;QAGlBJ,MAAM,EAAEY,UAHU;QAIlBX,OAAO,EAAEQ,WAJS;QAKlBP,YAAY,EAAEW,gBALI;QAMlBV,YAAY,EAAEW,gBANI;aAOlBnB,GAPkB;eAQlBU,KAAAA;KARF,AAAoB;IAWpB,IAAInB,EAAE,KAAK,KAAX,EACE,qBACE,gCAAC,KAAD;QAAK,GAAIoB,UAAJ;QAAgB,GAAIS,WAAJ;QAAiB,IAAA,EAAK,QAA3C;QAAoD,QAAA,EAAU,CAAD;qBAC3D,gCAAC,CAAA,GAAA,eAAD,CAAA;QAAU,OAAA,EAAQ,OAAlB;MAAR,gBACQ,gCAAC,MAAD;QAAM,SAAA,EAAWnB,MAAM,CAACN,KAAR;OAAgBA,KAAD,CAAvC,CAHI,CAIJ;IAIE,qBACE,gCAAC,QAAD;QAAQ,GAAIgB,UAAJ;QAAgB,GAAIS,WAAJ;QAAiB,IAAA,EAAK,QAA9C;qBACE,gCAAC,CAAA,GAAA,eAAD,CAAA;QAAU,OAAA,EAAQ,OAAlB;MAAN,gBACM,gCAAC,MAAD;QAAM,SAAA,EAAWnB,MAAM,CAACN,KAAR;OAAgBA,KAAD,CAArC,CAHE,CAIF;CAEC;AAEM,MAAMrB,yCAAU,iBAInBE,CAAAA,GAAAA,YAAK,CAAA,CAAC8C,UAAN,CAAiBxB,iCAAjB,CAJG,AAAP;;AD/JA","sources":["packages/components/drag-handle/src/index.ts","packages/components/drag-handle/src/DragHandle.tsx","packages/components/drag-handle/src/DragHandle.styles.ts"],"sourcesContent":["export { DragHandle } from './DragHandle';\nexport type { DragHandleProps } from './DragHandle';\n","import React, {\n useCallback,\n useState,\n type ElementType,\n type FocusEventHandler,\n type MouseEventHandler,\n type Ref,\n} from 'react';\nimport { cx } from 'emotion';\nimport type {\n PolymorphicComponent,\n PolymorphicProps,\n CommonProps,\n ExpandProps,\n} from '@contentful/f36-core';\nimport { DragIcon } from '@contentful/f36-icons';\n\nimport { getStyles } from './DragHandle.styles';\n\n// We use div instead of a button because react-sortable-hoc lib cancels sorting if the event target is button.\n//\n// The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,\n// in every place where we use this component with react-sortable-hoc.\n// (the custom callback with all the logic from default callback, but without button event cancelation).\n// So we decided that just changing it to the div, as it was in v3, is a better fix.\n//\n// default shouldCancelStart callback:\n// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js\nconst DRAG_HANDLE_DEFAULT_TAG = 'div';\n\nexport interface DragHandleInternalProps extends CommonProps {\n /**\n * The element used for the root node\n * @default div\n */\n as?: 'button' | 'div';\n /**\n * Applies styling for when the component is actively being dragged by\n * the user\n */\n isActive?: boolean;\n /**\n * Applies focus styling\n */\n isFocused?: boolean;\n /**\n * Applies hover styling\n */\n isHovered?: boolean;\n /**\n * Label rendered in DragHandle - not visible on screen as its purpose\n * is for screen readers only\n */\n label: string;\n /**\n * Set type button for div element\n */\n type?: string;\n}\n\nexport type DragHandleProps<\n E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG,\n> = PolymorphicProps<DragHandleInternalProps, E>;\n\nfunction _DragHandle<E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG>(\n props: DragHandleProps<E>,\n ref: Ref<any>,\n) {\n const styles = getStyles();\n const {\n as = DRAG_HANDLE_DEFAULT_TAG,\n className,\n isActive,\n isFocused: isFocusedProp,\n isHovered: isHoveredProp,\n label,\n onBlur,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n testId = 'cf-ui-drag-handle',\n style,\n ...otherProps\n } = props;\n const [isFocused, setisFocused] = useState(isFocusedProp);\n const [isHovered, setisHovered] = useState(isHoveredProp);\n\n const handleFocus = useCallback<FocusEventHandler<HTMLElement>>(\n (event) => {\n setisFocused(true);\n\n if (onFocus) {\n onFocus(event);\n }\n },\n [onFocus],\n );\n\n const handleBlur = useCallback<FocusEventHandler<HTMLElement>>(\n (event) => {\n setisFocused(false);\n\n if (onBlur) {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback<MouseEventHandler<HTMLElement>>(\n (event) => {\n setisHovered(true);\n\n if (onMouseEnter) {\n onMouseEnter(event);\n }\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback<MouseEventHandler<HTMLElement>>(\n (event) => {\n setisHovered(false);\n\n if (onMouseLeave) {\n onMouseLeave(event);\n }\n },\n [onMouseLeave],\n );\n\n const commonProps = {\n className: cx(styles.root({ isActive, isFocused, isHovered }), className),\n 'data-test-id': testId,\n onBlur: handleBlur,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n ref,\n style,\n };\n\n if (as === 'div') {\n return (\n <div {...otherProps} {...commonProps} role=\"button\" tabIndex={0}>\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </div>\n );\n }\n\n return (\n <button {...otherProps} {...commonProps} type=\"button\">\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </button>\n );\n}\n\nexport const DragHandle: PolymorphicComponent<\n ExpandProps<DragHandleInternalProps>,\n typeof DRAG_HANDLE_DEFAULT_TAG,\n 'disabled'\n> = React.forwardRef(_DragHandle);\n","import { cx, css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const getStyles = () => ({\n label: css({\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: 0,\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n border: 0,\n }),\n root: ({\n isActive,\n isFocused,\n isHovered,\n }: {\n isActive: boolean;\n isFocused: boolean;\n isHovered: boolean;\n }) => {\n return cx(\n css({\n alignItems: 'center',\n backgroundColor: tokens.gray100,\n border: 0,\n borderBottomLeftRadius: tokens.borderRadiusMedium,\n borderRight: `1px solid ${tokens.gray200}`,\n borderTopLeftRadius: tokens.borderRadiusMedium,\n boxSizing: 'border-box',\n display: 'flex',\n justifyContent: 'center',\n padding: 0,\n position: 'relative',\n transition: `background-color ${tokens.transitionDurationDefault} ${tokens.transitionEasingDefault}`,\n width: tokens.spacingL,\n '&:hover': {\n backgroundColor: tokens.gray200,\n },\n '&:focus': {\n boxShadow: tokens.glowPrimary,\n },\n '&:focus:not(:focus-visible)': {\n boxShadow: 'unset',\n },\n '&:focus-visible': {\n boxShadow: tokens.glowPrimary,\n },\n }),\n (isActive || isFocused || isHovered) &&\n css({\n backgroundColor: tokens.gray200,\n cursor: isActive ? 'grabbing' : 'grab',\n }),\n );\n },\n});\n"],"names":["DragHandle","DragHandleProps","React","useCallback","useState","ElementType","FocusEventHandler","MouseEventHandler","Ref","PolymorphicComponent","PolymorphicProps","CommonProps","ExpandProps","DragIcon","getStyles","DRAG_HANDLE_DEFAULT_TAG","DragHandleInternalProps","as","isActive","isFocused","isHovered","label","type","E","_DragHandle","props","ref","styles","className","isFocusedProp","isHoveredProp","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style","otherProps","setisFocused","setisHovered","handleFocus","HTMLElement","event","handleBlur","handleMouseEnter","handleMouseLeave","commonProps","root","forwardRef","tokens","alignItems","backgroundColor","gray100","border","borderBottomLeftRadius","borderRadiusMedium","borderRight","gray200","borderTopLeftRadius","boxSizing","display","justifyContent","padding","position","transition","transitionDurationDefault","transitionEasingDefault","width","spacingL","boxShadow","glowPrimary","cursor"],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;
|
|
1
|
+
{"mappings":";;AC4BA,QAAA,MAAM,+BAA+B,CAAC;AAEtC,iCAAyC,SAAQ,WAAW;IAC1D;;;OAGG;IACH,EAAE,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,4BACE,CAAC,SAAS,WAAW,GAAG,8BAA8B,IACpD,iBAAiB,uBAAuB,EAAE,CAAC,CAAC,CAAC;AAiGjD,OAAO,MAAM,YAAY,qBACvB,YAAY,uBAAuB,CAAC,EACpC,8BAA8B,EAC9B,UAAU,CACqB,CAAC","sources":["packages/components/drag-handle/src/src/DragHandle.styles.ts","packages/components/drag-handle/src/src/DragHandle.tsx","packages/components/drag-handle/src/src/index.ts","packages/components/drag-handle/src/index.ts"],"sourcesContent":[null,null,null,"export { DragHandle } from './DragHandle';\nexport type { DragHandleProps } from './DragHandle';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/f36-drag-handle",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.0",
|
|
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": "^4.
|
|
11
|
-
"@contentful/f36-icons": "^4.
|
|
10
|
+
"@contentful/f36-core": "^4.16.0",
|
|
11
|
+
"@contentful/f36-icons": "^4.16.0",
|
|
12
12
|
"@contentful/f36-tokens": "^4.0.1",
|
|
13
13
|
"emotion": "^10.0.17"
|
|
14
14
|
},
|