@contentful/f36-drag-handle 4.8.1 → 4.8.2
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 +8 -0
- package/dist/main.js +43 -21
- package/dist/main.js.map +1 -1
- package/dist/module.js +44 -22
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +10 -27
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/main.js
CHANGED
|
@@ -37,8 +37,17 @@ const $590c5f6da3a22459$export$ffd58b7f6f099a57 = ()=>({
|
|
|
37
37
|
position: 'relative',
|
|
38
38
|
transition: `background-color ${($parcel$interopDefault($9zqHf$contentfulf36tokens)).transitionDurationDefault} ${($parcel$interopDefault($9zqHf$contentfulf36tokens)).transitionEasingDefault}`,
|
|
39
39
|
width: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).spacingL,
|
|
40
|
-
'&:hover
|
|
41
|
-
backgroundColor: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).
|
|
40
|
+
'&:hover': {
|
|
41
|
+
backgroundColor: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).gray200
|
|
42
|
+
},
|
|
43
|
+
'&:focus': {
|
|
44
|
+
boxShadow: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).glowPrimary
|
|
45
|
+
},
|
|
46
|
+
'&:focus:not(:focus-visible)': {
|
|
47
|
+
boxShadow: 'unset'
|
|
48
|
+
},
|
|
49
|
+
'&:focus-visible': {
|
|
50
|
+
boxShadow: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).glowPrimary
|
|
42
51
|
}
|
|
43
52
|
}), (isActive || isFocused || isHovered) && /*#__PURE__*/ $9zqHf$emotion.css({
|
|
44
53
|
backgroundColor: ($parcel$interopDefault($9zqHf$contentfulf36tokens)).gray200,
|
|
@@ -49,8 +58,18 @@ const $590c5f6da3a22459$export$ffd58b7f6f099a57 = ()=>({
|
|
|
49
58
|
;
|
|
50
59
|
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
//
|
|
62
|
+
// The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,
|
|
63
|
+
// in every place where we use this component with react-sortable-hoc.
|
|
64
|
+
// (the custom callback with all the logic from default callback, but without button event cancelation).
|
|
65
|
+
// So we decided that just changing it to the div, as it was in v3, is a better fix.
|
|
66
|
+
//
|
|
67
|
+
// default shouldCancelStart callback:
|
|
68
|
+
// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js
|
|
69
|
+
const $7340ff11beb99de7$var$DRAG_HANDLE_DEFAULT_TAG = 'div';
|
|
70
|
+
function $7340ff11beb99de7$var$_DragHandle(props, ref) {
|
|
53
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 = 'cf-ui-drag-handle' , style: style , ...otherProps } = props;
|
|
54
73
|
const [isFocused, setisFocused] = $9zqHf$react.useState(isFocusedProp);
|
|
55
74
|
const [isHovered, setisHovered] = $9zqHf$react.useState(isHoveredProp);
|
|
56
75
|
const handleFocus = $9zqHf$react.useCallback((event)=>{
|
|
@@ -77,38 +96,41 @@ const $7340ff11beb99de7$export$a0c24614540b0efb = /*#__PURE__*/ $9zqHf$react.for
|
|
|
77
96
|
}, [
|
|
78
97
|
onMouseLeave
|
|
79
98
|
]);
|
|
80
|
-
|
|
81
|
-
// The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,
|
|
82
|
-
// in every place where we use this component with react-sortable-hoc.
|
|
83
|
-
// (the custom callback with all the logic from default callback, but without button event cancelation).
|
|
84
|
-
// So we decided that just changing it to the div, as it was in v3, is a better fix.
|
|
85
|
-
//
|
|
86
|
-
// default shouldCancelStart callback:
|
|
87
|
-
// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js
|
|
88
|
-
/*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement("div", {
|
|
89
|
-
role: "button",
|
|
90
|
-
tabIndex: 0,
|
|
91
|
-
type: "button",
|
|
92
|
-
...otherProps,
|
|
99
|
+
const commonProps = {
|
|
93
100
|
className: $9zqHf$emotion.cx(styles.root({
|
|
94
101
|
isActive: isActive,
|
|
95
102
|
isFocused: isFocused,
|
|
96
103
|
isHovered: isHovered
|
|
97
104
|
}), className),
|
|
105
|
+
'data-test-id': testId,
|
|
98
106
|
onBlur: handleBlur,
|
|
99
107
|
onFocus: handleFocus,
|
|
100
108
|
onMouseEnter: handleMouseEnter,
|
|
101
109
|
onMouseLeave: handleMouseLeave,
|
|
102
|
-
|
|
103
|
-
ref: forwardedRef,
|
|
110
|
+
ref: ref,
|
|
104
111
|
style: style
|
|
112
|
+
};
|
|
113
|
+
if (as === 'div') return /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement("div", {
|
|
114
|
+
...otherProps,
|
|
115
|
+
...commonProps,
|
|
116
|
+
role: "button",
|
|
117
|
+
tabIndex: 0
|
|
118
|
+
}, /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement($9zqHf$contentfulf36icons.DragIcon, {
|
|
119
|
+
variant: "muted"
|
|
120
|
+
}), /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement("span", {
|
|
121
|
+
className: styles.label
|
|
122
|
+
}, label));
|
|
123
|
+
return /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement("button", {
|
|
124
|
+
...otherProps,
|
|
125
|
+
...commonProps,
|
|
126
|
+
type: "button"
|
|
105
127
|
}, /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement($9zqHf$contentfulf36icons.DragIcon, {
|
|
106
128
|
variant: "muted"
|
|
107
129
|
}), /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).createElement("span", {
|
|
108
130
|
className: styles.label
|
|
109
|
-
}, label))
|
|
110
|
-
}
|
|
111
|
-
$7340ff11beb99de7$export$a0c24614540b0efb
|
|
131
|
+
}, label));
|
|
132
|
+
}
|
|
133
|
+
const $7340ff11beb99de7$export$a0c24614540b0efb = /*#__PURE__*/ ($parcel$interopDefault($9zqHf$react)).forwardRef($7340ff11beb99de7$var$_DragHandle);
|
|
112
134
|
|
|
113
135
|
|
|
114
136
|
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;A;;;A;;;AEGO,MAAMY,yCAAS,GAAG,IAAO,CAAA;QAC9BK,KAAK,EAAA,aAAE,CAAA,kBAAPA,CAAAA;YAAO,IAAA,EAAA,SAAA;YAAA,MAAA,EAAA,8GAAA;SAAA,CADuB;QAW9BsB,IAAI,EAAE,CAAC,E,UACLzB,QADK,CAAA,E,WAELC,SAFK,CAAA,E,WAGLC,SAAAA,CAAAA,EAHI,GAQA;YACJ,OAAO,iBAAA,CAAA,aACL,CAAA,kBAAA,CAAI;gBACF0B,UAAU,EAAE,QADV;gBAEFC,eAAe,EAAEF,oDAAM,CAACG,OAFtB;gBAGFC,MAAM,EAAE,CAHN;gBAIFC,sBAAsB,EAAEL,oDAAM,CAACM,kBAJ7B;gBAKFC,WAAW,EAAG,CAAA,UAAA,EAAYP,oDAAM,CAACQ,OAAQ,CAAA,CALvC;gBAMFC,mBAAmB,EAAET,oDAAM,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,oDAAM,CAACgB,yBAA0B,CAAA,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AAM,CAACd,KAAR;OAAgBA,KAAD,CAAvC,CACA,EA7BI;CArEgC,CAA7B,AAoGJ;AAGHjB,yCAAU,CAACwC,WAAX,GAAyB,YAAzB,CAAAxC;;ADlJA","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 forwardRef,\n useCallback,\n useState,\n FocusEventHandler,\n MouseEventHandler,\n} from 'react';\nimport { cx } from 'emotion';\nimport type { PropsWithHTMLElement } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { DragIcon } from '@contentful/f36-icons';\nimport { getStyles } from './DragHandle.styles';\n\nexport type DragHandleInternalProps = CommonProps & {\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 = PropsWithHTMLElement<\n DragHandleInternalProps,\n 'div'\n>;\n\nexport const DragHandle = forwardRef<\n HTMLDivElement,\n ExpandProps<DragHandleProps>\n>(\n (\n {\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 },\n forwardedRef,\n ) => {\n const styles = getStyles();\n const [isFocused, setisFocused] = useState(isFocusedProp);\n const [isHovered, setisHovered] = useState(isHoveredProp);\n\n const handleFocus = useCallback<FocusEventHandler<HTMLDivElement>>(\n (event) => {\n setisFocused(true);\n\n if (onFocus) {\n onFocus(event);\n }\n },\n [onFocus],\n );\n\n const handleBlur = useCallback<FocusEventHandler<HTMLDivElement>>(\n (event) => {\n setisFocused(false);\n\n if (onBlur) {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n setisHovered(true);\n\n if (onMouseEnter) {\n onMouseEnter(event);\n }\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n setisHovered(false);\n\n if (onMouseLeave) {\n onMouseLeave(event);\n }\n },\n [onMouseLeave],\n );\n\n return (\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\n <div\n role=\"button\"\n tabIndex={0}\n type=\"button\"\n {...otherProps}\n className={cx(\n styles.root({ isActive, isFocused, isHovered }),\n className,\n )}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n data-test-id={testId}\n ref={forwardedRef}\n style={style}\n >\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </div>\n );\n },\n);\n\nDragHandle.displayName = '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, &:focus': {\n backgroundColor: tokens.colorElementLight,\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","forwardRef","useCallback","useState","FocusEventHandler","MouseEventHandler","PropsWithHTMLElement","CommonProps","ExpandProps","DragIcon","getStyles","DragHandleInternalProps","isActive","isFocused","isHovered","label","type","HTMLDivElement","className","isFocusedProp","isHoveredProp","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style","otherProps","forwardedRef","styles","setisFocused","setisHovered","handleFocus","event","handleBlur","handleMouseEnter","handleMouseLeave","root","displayName","tokens","alignItems","backgroundColor","gray100","border","borderBottomLeftRadius","borderRadiusMedium","borderRight","gray200","borderTopLeftRadius","boxSizing","display","justifyContent","padding","position","transition","transitionDurationDefault","transitionEasingDefault","width","spacingL","colorElementLight","cursor"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;A;;;A;;;AEGO,MAAMc,yCAAS,GAAG,IAAO,CAAA;QAC9BO,KAAK,EAAA,aAAE,CAAA,kBAAPA,CAAAA;YAAO,IAAA,EAAA,SAAA;YAAA,MAAA,EAAA,8GAAA;SAAA,CADuB;QAW9B0B,IAAI,EAAE,CAAC,E,UACL7B,QADK,CAAA,E,WAELC,SAFK,CAAA,E,WAGLC,SAAAA,CAAAA,EAHI,GAQA;YACJ,OAAO,iBAAA,CAAA,aACL,CAAA,kBAAA,CAAI;gBACF8B,UAAU,EAAE,QADV;gBAEFC,eAAe,E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.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"}
|
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {cx as $8USmO$cx, css as $8USmO$css} from "emotion";
|
|
2
|
-
import $8USmO$react, {
|
|
2
|
+
import $8USmO$react, {useState as $8USmO$useState, useCallback as $8USmO$useCallback} from "react";
|
|
3
3
|
import {DragIcon as $8USmO$DragIcon} from "@contentful/f36-icons";
|
|
4
4
|
import $8USmO$contentfulf36tokens from "@contentful/f36-tokens";
|
|
5
5
|
|
|
@@ -29,8 +29,17 @@ const $1282af47e008eae6$export$ffd58b7f6f099a57 = ()=>({
|
|
|
29
29
|
position: 'relative',
|
|
30
30
|
transition: `background-color ${$8USmO$contentfulf36tokens.transitionDurationDefault} ${$8USmO$contentfulf36tokens.transitionEasingDefault}`,
|
|
31
31
|
width: $8USmO$contentfulf36tokens.spacingL,
|
|
32
|
-
'&:hover
|
|
33
|
-
backgroundColor: $8USmO$contentfulf36tokens.
|
|
32
|
+
'&:hover': {
|
|
33
|
+
backgroundColor: $8USmO$contentfulf36tokens.gray200
|
|
34
|
+
},
|
|
35
|
+
'&:focus': {
|
|
36
|
+
boxShadow: $8USmO$contentfulf36tokens.glowPrimary
|
|
37
|
+
},
|
|
38
|
+
'&:focus:not(:focus-visible)': {
|
|
39
|
+
boxShadow: 'unset'
|
|
40
|
+
},
|
|
41
|
+
'&:focus-visible': {
|
|
42
|
+
boxShadow: $8USmO$contentfulf36tokens.glowPrimary
|
|
34
43
|
}
|
|
35
44
|
}), (isActive || isFocused || isHovered) && /*#__PURE__*/ $8USmO$css({
|
|
36
45
|
backgroundColor: $8USmO$contentfulf36tokens.gray200,
|
|
@@ -41,8 +50,18 @@ const $1282af47e008eae6$export$ffd58b7f6f099a57 = ()=>({
|
|
|
41
50
|
;
|
|
42
51
|
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
//
|
|
54
|
+
// The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,
|
|
55
|
+
// in every place where we use this component with react-sortable-hoc.
|
|
56
|
+
// (the custom callback with all the logic from default callback, but without button event cancelation).
|
|
57
|
+
// So we decided that just changing it to the div, as it was in v3, is a better fix.
|
|
58
|
+
//
|
|
59
|
+
// default shouldCancelStart callback:
|
|
60
|
+
// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js
|
|
61
|
+
const $0d6e001a91dc675e$var$DRAG_HANDLE_DEFAULT_TAG = 'div';
|
|
62
|
+
function $0d6e001a91dc675e$var$_DragHandle(props, ref) {
|
|
45
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 = 'cf-ui-drag-handle' , style: style , ...otherProps } = props;
|
|
46
65
|
const [isFocused, setisFocused] = $8USmO$useState(isFocusedProp);
|
|
47
66
|
const [isHovered, setisHovered] = $8USmO$useState(isHoveredProp);
|
|
48
67
|
const handleFocus = $8USmO$useCallback((event)=>{
|
|
@@ -69,38 +88,41 @@ const $0d6e001a91dc675e$export$a0c24614540b0efb = /*#__PURE__*/ $8USmO$forwardRe
|
|
|
69
88
|
}, [
|
|
70
89
|
onMouseLeave
|
|
71
90
|
]);
|
|
72
|
-
|
|
73
|
-
// The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,
|
|
74
|
-
// in every place where we use this component with react-sortable-hoc.
|
|
75
|
-
// (the custom callback with all the logic from default callback, but without button event cancelation).
|
|
76
|
-
// So we decided that just changing it to the div, as it was in v3, is a better fix.
|
|
77
|
-
//
|
|
78
|
-
// default shouldCancelStart callback:
|
|
79
|
-
// https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js
|
|
80
|
-
/*#__PURE__*/ $8USmO$react.createElement("div", {
|
|
81
|
-
role: "button",
|
|
82
|
-
tabIndex: 0,
|
|
83
|
-
type: "button",
|
|
84
|
-
...otherProps,
|
|
91
|
+
const commonProps = {
|
|
85
92
|
className: $8USmO$cx(styles.root({
|
|
86
93
|
isActive: isActive,
|
|
87
94
|
isFocused: isFocused,
|
|
88
95
|
isHovered: isHovered
|
|
89
96
|
}), className),
|
|
97
|
+
'data-test-id': testId,
|
|
90
98
|
onBlur: handleBlur,
|
|
91
99
|
onFocus: handleFocus,
|
|
92
100
|
onMouseEnter: handleMouseEnter,
|
|
93
101
|
onMouseLeave: handleMouseLeave,
|
|
94
|
-
|
|
95
|
-
ref: forwardedRef,
|
|
102
|
+
ref: ref,
|
|
96
103
|
style: style
|
|
104
|
+
};
|
|
105
|
+
if (as === 'div') return /*#__PURE__*/ $8USmO$react.createElement("div", {
|
|
106
|
+
...otherProps,
|
|
107
|
+
...commonProps,
|
|
108
|
+
role: "button",
|
|
109
|
+
tabIndex: 0
|
|
110
|
+
}, /*#__PURE__*/ $8USmO$react.createElement($8USmO$DragIcon, {
|
|
111
|
+
variant: "muted"
|
|
112
|
+
}), /*#__PURE__*/ $8USmO$react.createElement("span", {
|
|
113
|
+
className: styles.label
|
|
114
|
+
}, label));
|
|
115
|
+
return /*#__PURE__*/ $8USmO$react.createElement("button", {
|
|
116
|
+
...otherProps,
|
|
117
|
+
...commonProps,
|
|
118
|
+
type: "button"
|
|
97
119
|
}, /*#__PURE__*/ $8USmO$react.createElement($8USmO$DragIcon, {
|
|
98
120
|
variant: "muted"
|
|
99
121
|
}), /*#__PURE__*/ $8USmO$react.createElement("span", {
|
|
100
122
|
className: styles.label
|
|
101
|
-
}, label))
|
|
102
|
-
}
|
|
103
|
-
$0d6e001a91dc675e$export$a0c24614540b0efb
|
|
123
|
+
}, label));
|
|
124
|
+
}
|
|
125
|
+
const $0d6e001a91dc675e$export$a0c24614540b0efb = /*#__PURE__*/ $8USmO$react.forwardRef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AACU,KAAD,CAAZ,CAAAV;KAL8B,EAQlC;QAACA,YAAD;KARkC,CAApC,AAOG;IAIH,MAAMa,gBAAgB,GAAGlC,kBAAW,CACjC+B,CAAAA,KAAD,GAAW;QACTF,YAAY,CAAC,KAAD,CAAZ,CAAAA;QAEA,IAAIP,YAAJ,EACEA,YAAY,CAACS,KAAD,CAAZ,CAAAT;KAL8B,EAQlC;QAACA,YAAD;KARkC,CAApC,AAOG;IAIH,OAEE,EAAA;IACA,yFAAA;IACA,sEAAA;IACA,wGAAA;IACA,oFAAA;IACA,EAAA;IACA,sCAAA;IACA,kJAAA;kBACA,2BAAC,KAAD;QACE,IAAA,EAAK,QADP;QAEE,QAAA,EAAU,CAAD;QACT,IAAA,EAAK,QAHP;QAIE,GAAIG,UAAJ;QACA,SAAA,EAAW,SAAA,CACTE,MAAM,CAACQ,IAAP,CAAY;Y,UAAEzB,QAAF;Y,WAAYC,SAAZ;Y,WAAuBC,SAAAA;SAAnC,CADS,EAETI,SAFS,CAAD;QAIV,MAAA,EAAQgB,UAAD;QACP,OAAA,EAASF,WAAD;QACR,YAAA,EAAcG,gBAAD;QACb,YAAA,EAAcC,gBAAD;QACb,cAAA,EAAcX,MAAD;QACb,GAAA,EAAKG,YAAD;QACJ,KAAA,EAAOF,KAAD;qBAEN,2BAAC,eAAD;QAAU,OAAA,EAAQ,OAAlB;MAAR,gBACQ,2BAAC,MAAD;QAAM,SAAA,EAAWG,MAAM,CAACd,KAAR;OAAgBA,KAAD,CAAvC,CACA,EA7BI;CArEgC,CAA7B,AAoGJ;AAGHjB,yCAAU,CAACwC,WAAX,GAAyB,YAAzB,CAAAxC;;ADlJA","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 forwardRef,\n useCallback,\n useState,\n FocusEventHandler,\n MouseEventHandler,\n} from 'react';\nimport { cx } from 'emotion';\nimport type { PropsWithHTMLElement } from '@contentful/f36-core';\nimport type { CommonProps, ExpandProps } from '@contentful/f36-core';\nimport { DragIcon } from '@contentful/f36-icons';\nimport { getStyles } from './DragHandle.styles';\n\nexport type DragHandleInternalProps = CommonProps & {\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 = PropsWithHTMLElement<\n DragHandleInternalProps,\n 'div'\n>;\n\nexport const DragHandle = forwardRef<\n HTMLDivElement,\n ExpandProps<DragHandleProps>\n>(\n (\n {\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 },\n forwardedRef,\n ) => {\n const styles = getStyles();\n const [isFocused, setisFocused] = useState(isFocusedProp);\n const [isHovered, setisHovered] = useState(isHoveredProp);\n\n const handleFocus = useCallback<FocusEventHandler<HTMLDivElement>>(\n (event) => {\n setisFocused(true);\n\n if (onFocus) {\n onFocus(event);\n }\n },\n [onFocus],\n );\n\n const handleBlur = useCallback<FocusEventHandler<HTMLDivElement>>(\n (event) => {\n setisFocused(false);\n\n if (onBlur) {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n setisHovered(true);\n\n if (onMouseEnter) {\n onMouseEnter(event);\n }\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback<MouseEventHandler<HTMLDivElement>>(\n (event) => {\n setisHovered(false);\n\n if (onMouseLeave) {\n onMouseLeave(event);\n }\n },\n [onMouseLeave],\n );\n\n return (\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\n <div\n role=\"button\"\n tabIndex={0}\n type=\"button\"\n {...otherProps}\n className={cx(\n styles.root({ isActive, isFocused, isHovered }),\n className,\n )}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n data-test-id={testId}\n ref={forwardedRef}\n style={style}\n >\n <DragIcon variant=\"muted\" />\n <span className={styles.label}>{label}</span>\n </div>\n );\n },\n);\n\nDragHandle.displayName = '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, &:focus': {\n backgroundColor: tokens.colorElementLight,\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","forwardRef","useCallback","useState","FocusEventHandler","MouseEventHandler","PropsWithHTMLElement","CommonProps","ExpandProps","DragIcon","getStyles","DragHandleInternalProps","isActive","isFocused","isHovered","label","type","HTMLDivElement","className","isFocusedProp","isHoveredProp","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style","otherProps","forwardedRef","styles","setisFocused","setisHovered","handleFocus","event","handleBlur","handleMouseEnter","handleMouseLeave","root","displayName","tokens","alignItems","backgroundColor","gray100","border","borderBottomLeftRadius","borderRadiusMedium","borderRight","gray200","borderTopLeftRadius","boxSizing","display","justifyContent","padding","position","transition","transitionDurationDefault","transitionEasingDefault","width","spacingL","colorElementLight","cursor"],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;A;;;A;;;AEGO,MAAMc,yCAAS,GAAG,IAAO,CAAA;QAC9BO,KAAK,EAAA,aAAE,CAAA,UAAPA,CAAAA;YAAO,IAAA,EAAA,SAAA;YAAA,MAAA,EAAA,8GAAA;SAAA,CADuB;QAW9B0B,IAAI,EAAE,CAAC,E,UACL7B,QADK,CAAA,E,WAELC,SAFK,CAAA,E,WAGLC,SAAAA,CAAAA,EAHI,GAQA;YACJ,OAAO,SAAA,CAAA,aACL,CAAA,UAAA,CAAI;gBACF8B,UAAU,EAAE,QADV;gBAEFC,eAAe,EAAEF,0BAAM,CAACG,OAFtB;gBAGFC,MAAM,EAAE,CAHN;gBAIFC,sBAAsB,EAAEL,0BAAM,CAACM,kBAJ7B;gBAKFC,WAAW,EAAG,CAAA,UAAA,EAAYP,0BAAM,CAACQ,OAAQ,CAAA,CALvC;gBAMFC,mBAAmB,EAAET,0BAAM,CAACM,kBAN1B;gBAOFI,SAAS,EAAE,YAPT;gBAQFC,OAAO,EAAE,MARP;gBASFC,cAAc,EAAE,QATd;gBAUFC,OAAO,EAAE,CAVP;gBAWFC,QAAQ,EAAE,UAXR;gBAY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AElB,cAAA,EAAgBO,MAFE;QAGlBJ,MAAM,EAAEY,UAHU;QAIlBX,OAAO,EAAEQ,WAJS;QAKlBP,YAAY,EAAEW,gBALI;QAMlBV,YAAY,EAAEW,gBANI;Q,KAOlBnB,GAPkB;Q,OAQlBU,KAAAA;KARF,AAAoB;IAWpB,IAAInB,EAAE,KAAK,KAAX,EACE,qBACE,2BAAC,KAAD;QAAK,GAAIoB,UAAJ;QAAgB,GAAIS,WAAJ;QAAiB,IAAA,EAAK,QAA3C;QAAoD,QAAA,EAAU,CAAD;qBAC3D,2BAAC,eAAD;QAAU,OAAA,EAAQ,OAAlB;MAAR,gBACQ,2BAAC,MAAD;QAAM,SAAA,EAAWnB,MAAM,CAACN,KAAR;OAAgBA,KAAD,CAAvC,CAHI,CAIJ;IAIE,qBACE,2BAAC,QAAD;QAAQ,GAAIgB,UAAJ;QAAgB,GAAIS,WAAJ;QAAiB,IAAA,EAAK,QAA9C;qBACE,2BAAC,eAAD;QAAU,OAAA,EAAQ,OAAlB;MAAN,gBACM,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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,31 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ElementType } from "react";
|
|
2
|
+
import { PolymorphicComponent, PolymorphicProps, CommonProps, ExpandProps } from "@contentful/f36-core";
|
|
3
|
+
declare const DRAG_HANDLE_DEFAULT_TAG = "div";
|
|
4
|
+
interface DragHandleInternalProps extends CommonProps {
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
isActive?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Applies focus styling
|
|
11
|
-
*/
|
|
12
|
-
isFocused?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Applies hover styling
|
|
6
|
+
* The element used for the root node
|
|
7
|
+
* @default div
|
|
15
8
|
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Label rendered in DragHandle - not visible on screen as its purpose
|
|
19
|
-
* is for screen readers only
|
|
20
|
-
*/
|
|
21
|
-
label: string;
|
|
22
|
-
/**
|
|
23
|
-
* Set type button for div element
|
|
24
|
-
*/
|
|
25
|
-
type?: string;
|
|
26
|
-
};
|
|
27
|
-
export type DragHandleProps = PropsWithHTMLElement<DragHandleInternalProps, 'div'>;
|
|
28
|
-
export const DragHandle: React.ForwardRefExoticComponent<Omit<Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>>, never>, "isActive" | "isFocused" | "isHovered" | "label" | keyof CommonProps | "type"> & CommonProps & {
|
|
9
|
+
as?: 'button' | 'div';
|
|
29
10
|
/**
|
|
30
11
|
* Applies styling for when the component is actively being dragged by
|
|
31
12
|
* the user
|
|
@@ -48,6 +29,8 @@ export const DragHandle: React.ForwardRefExoticComponent<Omit<Omit<Pick<React.De
|
|
|
48
29
|
* Set type button for div element
|
|
49
30
|
*/
|
|
50
31
|
type?: string;
|
|
51
|
-
}
|
|
32
|
+
}
|
|
33
|
+
export type DragHandleProps<E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG> = PolymorphicProps<DragHandleInternalProps, E>;
|
|
34
|
+
export const DragHandle: PolymorphicComponent<ExpandProps<DragHandleInternalProps>, typeof DRAG_HANDLE_DEFAULT_TAG, 'disabled'>;
|
|
52
35
|
|
|
53
36
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;
|
|
1
|
+
{"mappings":";;AC0BA,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.8.
|
|
3
|
+
"version": "4.8.2",
|
|
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.8.
|
|
11
|
-
"@contentful/f36-icons": "^4.8.
|
|
10
|
+
"@contentful/f36-core": "^4.8.2",
|
|
11
|
+
"@contentful/f36-icons": "^4.8.2",
|
|
12
12
|
"@contentful/f36-tokens": "^4.0.1",
|
|
13
13
|
"emotion": "^10.0.17"
|
|
14
14
|
},
|