@contentful/f36-drag-handle 4.16.0 → 4.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.19.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @contentful/f36-icons@4.19.0
9
+ - @contentful/f36-core@4.19.0
10
+
11
+ ## 4.18.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies []:
16
+ - @contentful/f36-icons@4.18.0
17
+ - @contentful/f36-core@4.18.0
18
+
19
+ ## 4.17.0
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies []:
24
+ - @contentful/f36-icons@4.17.0
25
+ - @contentful/f36-core@4.17.0
26
+
3
27
  ## 4.16.0
4
28
 
5
29
  ### Patch Changes
@@ -1,5 +1,6 @@
1
- import { ElementType } from "react";
2
- import { PolymorphicComponent, PolymorphicProps, CommonProps, ExpandProps } from "@contentful/f36-core";
1
+ import { ElementType } from 'react';
2
+ import { PolymorphicProps, PolymorphicComponent, ExpandProps, CommonProps } from '@contentful/f36-core';
3
+
3
4
  declare const DRAG_HANDLE_DEFAULT_TAG = "div";
4
5
  interface DragHandleInternalProps extends CommonProps {
5
6
  /**
@@ -30,7 +31,7 @@ interface DragHandleInternalProps extends CommonProps {
30
31
  */
31
32
  type?: string;
32
33
  }
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'>;
34
+ declare type DragHandleProps<E extends ElementType = typeof DRAG_HANDLE_DEFAULT_TAG> = PolymorphicProps<DragHandleInternalProps, E>;
35
+ declare const DragHandle: PolymorphicComponent<ExpandProps<DragHandleInternalProps>, typeof DRAG_HANDLE_DEFAULT_TAG, 'disabled'>;
35
36
 
36
- //# sourceMappingURL=types.d.ts.map
37
+ export { DragHandle, DragHandleProps };
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var a = require('react');
6
+ var emotion = require('emotion');
7
+ var f36Icons = require('@contentful/f36-icons');
8
+ var t = require('@contentful/f36-tokens');
9
+
10
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
+
12
+ var a__default = /*#__PURE__*/_interopDefaultLegacy(a);
13
+ var t__default = /*#__PURE__*/_interopDefaultLegacy(t);
14
+
15
+ var $=Object.defineProperty,j=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var x=(o,r,e)=>r in o?$(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,i=(o,r)=>{for(var e in r||(r={}))P.call(r,e)&&x(o,e,r[e]);if(l)for(var e of l(r))h.call(r,e)&&x(o,e,r[e]);return o},b=(o,r)=>j(o,z(r));var A=(o,r)=>{var e={};for(var n in o)P.call(o,n)&&r.indexOf(n)<0&&(e[n]=o[n]);if(o!=null&&l)for(var n of l(o))r.indexOf(n)<0&&h.call(o,n)&&(e[n]=o[n]);return e};var L=()=>({label:emotion.css({position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",border:0}),root:({isActive:o,isFocused:r,isHovered:e})=>emotion.cx(emotion.css({alignItems:"center",backgroundColor:t__default["default"].gray100,border:0,borderBottomLeftRadius:t__default["default"].borderRadiusMedium,borderRight:`1px solid ${t__default["default"].gray200}`,borderTopLeftRadius:t__default["default"].borderRadiusMedium,boxSizing:"border-box",display:"flex",justifyContent:"center",padding:0,position:"relative",transition:`background-color ${t__default["default"].transitionDurationDefault} ${t__default["default"].transitionEasingDefault}`,width:t__default["default"].spacingL,"&:hover":{backgroundColor:t__default["default"].gray200},"&:focus":{boxShadow:t__default["default"].glowPrimary},"&:focus:not(:focus-visible)":{boxShadow:"unset"},"&:focus-visible":{boxShadow:t__default["default"].glowPrimary}}),(o||r||e)&&emotion.css({backgroundColor:t__default["default"].gray200,cursor:o?"grabbing":"grab"}))});var K="div";function O(o,r){let e=L(),D=o,{as:n=K,className:M,isActive:_,isFocused:w,isHovered:C,label:g,onBlur:p,onFocus:u,onMouseEnter:c,onMouseLeave:m,testId:G="cf-ui-drag-handle",style:N}=D,y=A(D,["as","className","isActive","isFocused","isHovered","label","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style"]),[I,E]=a.useState(w),[R,H]=a.useState(C),S=a.useCallback(s=>{E(!0),u&&u(s);},[u]),k=a.useCallback(s=>{E(!1),p&&p(s);},[p]),B=a.useCallback(s=>{H(!0),c&&c(s);},[c]),U=a.useCallback(s=>{H(!1),m&&m(s);},[m]),v={className:emotion.cx(e.root({isActive:_,isFocused:I,isHovered:R}),M),"data-test-id":G,onBlur:k,onFocus:S,onMouseEnter:B,onMouseLeave:U,ref:r,style:N};return n==="div"?a__default["default"].createElement("div",b(i(i({},y),v),{role:"button",tabIndex:0}),a__default["default"].createElement(f36Icons.DragIcon,{variant:"muted"}),a__default["default"].createElement("span",{className:e.label},g)):a__default["default"].createElement("button",b(i(i({},y),v),{type:"button"}),a__default["default"].createElement(f36Icons.DragIcon,{variant:"muted"}),a__default["default"].createElement("span",{className:e.label},g))}var Q=a__default["default"].forwardRef(O);
16
+
17
+ exports.DragHandle = Q;
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/DragHandle.tsx","../src/DragHandle.styles.ts"],"names":["React","useCallback","useState","cx","DragIcon","css","tokens","getStyles","isActive","isFocused","isHovered","DRAG_HANDLE_DEFAULT_TAG","_DragHandle","props","ref","styles","_a","as","className","isFocusedProp","isHoveredProp","label","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style","otherProps","__objRest","setisFocused","setisHovered","handleFocus","event","handleBlur","handleMouseEnter","handleMouseLeave","commonProps","__spreadProps","__spreadValues","DragHandle"],"mappings":"+kBAAA,OAAOA,GACL,eAAAC,EACA,YAAAC,MAKK,QACP,OAAS,MAAAC,MAAU,UAOnB,OAAS,YAAAC,MAAgB,wBCfzB,OAAS,MAAAD,EAAI,OAAAE,MAAW,UACxB,OAAOC,MAAY,yBAEZ,IAAMC,EAAY,KAAO,CAC9B,MAAOF,EAAI,CACT,SAAU,WACV,MAAO,MACP,OAAQ,MACR,QAAS,EACT,OAAQ,OACR,SAAU,SACV,KAAM,mBACN,OAAQ,CACV,CAAC,EACD,KAAM,CAAC,CACL,SAAAG,EACA,UAAAC,EACA,UAAAC,CACF,IAKSP,EACLE,EAAI,CACF,WAAY,SACZ,gBAAiBC,EAAO,QACxB,OAAQ,EACR,uBAAwBA,EAAO,mBAC/B,YAAa,aAAaA,EAAO,UACjC,oBAAqBA,EAAO,mBAC5B,UAAW,aACX,QAAS,OACT,eAAgB,SAChB,QAAS,EACT,SAAU,WACV,WAAY,oBAAoBA,EAAO,6BAA6BA,EAAO,0BAC3E,MAAOA,EAAO,SACd,UAAW,CACT,gBAAiBA,EAAO,OAC1B,EACA,UAAW,CACT,UAAWA,EAAO,WACpB,EACA,8BAA+B,CAC7B,UAAW,OACb,EACA,kBAAmB,CACjB,UAAWA,EAAO,WACpB,CACF,CAAC,GACAE,GAAYC,GAAaC,IACxBL,EAAI,CACF,gBAAiBC,EAAO,QACxB,OAAQE,EAAW,WAAa,MAClC,CAAC,CACL,CAEJ,GD9BA,IAAMG,EAA0B,MAoChC,SAASC,EACPC,EACAC,EACA,CACA,IAAMC,EAASR,EAAU,EAerBS,EAAAH,EAbF,IAAAI,EAAKN,EACL,UAAAO,EACA,SAAAV,EACA,UAAWW,EACX,UAAWC,EACX,MAAAC,EACA,OAAAC,EACA,QAAAC,EACA,aAAAC,EAC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,UAAWe,EAAO,OAAQM,CAAM,CACxC,CAEJ,CAEO,IAAMmB,EAITxC,EAAM,WAAWY,CAAW","sourcesContent":["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"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import a, { useState, useCallback } from 'react';
2
+ import { cx, css } from 'emotion';
3
+ import { DragIcon } from '@contentful/f36-icons';
4
+ import t from '@contentful/f36-tokens';
5
+
6
+ var $=Object.defineProperty,j=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var x=(o,r,e)=>r in o?$(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,i=(o,r)=>{for(var e in r||(r={}))P.call(r,e)&&x(o,e,r[e]);if(l)for(var e of l(r))h.call(r,e)&&x(o,e,r[e]);return o},b=(o,r)=>j(o,z(r));var A=(o,r)=>{var e={};for(var n in o)P.call(o,n)&&r.indexOf(n)<0&&(e[n]=o[n]);if(o!=null&&l)for(var n of l(o))r.indexOf(n)<0&&h.call(o,n)&&(e[n]=o[n]);return e};var L=()=>({label:css({position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",border:0}),root:({isActive:o,isFocused:r,isHovered:e})=>cx(css({alignItems:"center",backgroundColor:t.gray100,border:0,borderBottomLeftRadius:t.borderRadiusMedium,borderRight:`1px solid ${t.gray200}`,borderTopLeftRadius:t.borderRadiusMedium,boxSizing:"border-box",display:"flex",justifyContent:"center",padding:0,position:"relative",transition:`background-color ${t.transitionDurationDefault} ${t.transitionEasingDefault}`,width:t.spacingL,"&:hover":{backgroundColor:t.gray200},"&:focus":{boxShadow:t.glowPrimary},"&:focus:not(:focus-visible)":{boxShadow:"unset"},"&:focus-visible":{boxShadow:t.glowPrimary}}),(o||r||e)&&css({backgroundColor:t.gray200,cursor:o?"grabbing":"grab"}))});var K="div";function O(o,r){let e=L(),D=o,{as:n=K,className:M,isActive:_,isFocused:w,isHovered:C,label:g,onBlur:p,onFocus:u,onMouseEnter:c,onMouseLeave:m,testId:G="cf-ui-drag-handle",style:N}=D,y=A(D,["as","className","isActive","isFocused","isHovered","label","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style"]),[I,E]=useState(w),[R,H]=useState(C),S=useCallback(s=>{E(!0),u&&u(s);},[u]),k=useCallback(s=>{E(!1),p&&p(s);},[p]),B=useCallback(s=>{H(!0),c&&c(s);},[c]),U=useCallback(s=>{H(!1),m&&m(s);},[m]),v={className:cx(e.root({isActive:_,isFocused:I,isHovered:R}),M),"data-test-id":G,onBlur:k,onFocus:S,onMouseEnter:B,onMouseLeave:U,ref:r,style:N};return n==="div"?a.createElement("div",b(i(i({},y),v),{role:"button",tabIndex:0}),a.createElement(DragIcon,{variant:"muted"}),a.createElement("span",{className:e.label},g)):a.createElement("button",b(i(i({},y),v),{type:"button"}),a.createElement(DragIcon,{variant:"muted"}),a.createElement("span",{className:e.label},g))}var Q=a.forwardRef(O);
7
+
8
+ export { Q as DragHandle };
9
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/DragHandle.tsx","../src/DragHandle.styles.ts"],"names":["React","useCallback","useState","cx","DragIcon","css","tokens","getStyles","isActive","isFocused","isHovered","DRAG_HANDLE_DEFAULT_TAG","_DragHandle","props","ref","styles","_a","as","className","isFocusedProp","isHoveredProp","label","onBlur","onFocus","onMouseEnter","onMouseLeave","testId","style","otherProps","__objRest","setisFocused","setisHovered","handleFocus","event","handleBlur","handleMouseEnter","handleMouseLeave","commonProps","__spreadProps","__spreadValues","DragHandle"],"mappings":"+kBAAA,OAAOA,GACL,eAAAC,EACA,YAAAC,MAKK,QACP,OAAS,MAAAC,MAAU,UAOnB,OAAS,YAAAC,MAAgB,wBCfzB,OAAS,MAAAD,EAAI,OAAAE,MAAW,UACxB,OAAOC,MAAY,yBAEZ,IAAMC,EAAY,KAAO,CAC9B,MAAOF,EAAI,CACT,SAAU,WACV,MAAO,MACP,OAAQ,MACR,QAAS,EACT,OAAQ,OACR,SAAU,SACV,KAAM,mBACN,OAAQ,CACV,CAAC,EACD,KAAM,CAAC,CACL,SAAAG,EACA,UAAAC,EACA,UAAAC,CACF,IAKSP,EACLE,EAAI,CACF,WAAY,SACZ,gBAAiBC,EAAO,QACxB,OAAQ,EACR,uBAAwBA,EAAO,mBAC/B,YAAa,aAAaA,EAAO,UACjC,oBAAqBA,EAAO,mBAC5B,UAAW,aACX,QAAS,OACT,eAAgB,SAChB,QAAS,EACT,SAAU,WACV,WAAY,oBAAoBA,EAAO,6BAA6BA,EAAO,0BAC3E,MAAOA,EAAO,SACd,UAAW,CACT,gBAAiBA,EAAO,OAC1B,EACA,UAAW,CACT,UAAWA,EAAO,WACpB,EACA,8BAA+B,CAC7B,UAAW,OACb,EACA,kBAAmB,CACjB,UAAWA,EAAO,WACpB,CACF,CAAC,GACAE,GAAYC,GAAaC,IACxBL,EAAI,CACF,gBAAiBC,EAAO,QACxB,OAAQE,EAAW,WAAa,MAClC,CAAC,C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QAAQ,EAC1BJ,EAAA,cAAC,QAAK,UAAWe,EAAO,OAAQM,CAAM,CACxC,EAKFrB,EAAA,cAAC,SAAAsC,EAAAC,IAAA,GAAWX,GAAgBS,GAA3B,CAAwC,KAAK,WAC5CrC,EAAA,cAACI,EAAA,CAAS,QAAQ,QAAQ,EAC1BJ,EAAA,cAAC,QAAK,UAAWe,EAAO,OAAQM,CAAM,CACxC,CAEJ,CAEO,IAAMmB,EAITxC,EAAM,WAAWY,CAAW","sourcesContent":["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"]}
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@contentful/f36-drag-handle",
3
- "version": "4.16.0",
3
+ "version": "4.19.0",
4
4
  "description": "Forma 36: DragHandle component",
5
5
  "scripts": {
6
- "build": "parcel build"
6
+ "build": "tsup"
7
7
  },
8
8
  "dependencies": {
9
9
  "@babel/runtime": "^7.6.2",
10
- "@contentful/f36-core": "^4.16.0",
11
- "@contentful/f36-icons": "^4.16.0",
10
+ "@contentful/f36-core": "^4.19.0",
11
+ "@contentful/f36-icons": "^4.19.0",
12
12
  "@contentful/f36-tokens": "^4.0.1",
13
13
  "emotion": "^10.0.17"
14
14
  },
@@ -19,9 +19,9 @@
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
- "main": "dist/main.js",
23
- "module": "dist/module.js",
24
- "types": "dist/types.d.ts",
22
+ "main": "dist/index.js",
23
+ "module": "dist/index.mjs",
24
+ "types": "dist/index.d.ts",
25
25
  "source": "src/index.ts",
26
26
  "sideEffects": false,
27
27
  "browserslist": "extends @contentful/browserslist-config",
package/dist/main.js DELETED
@@ -1,137 +0,0 @@
1
- var $9zqHf$emotion = require("emotion");
2
- var $9zqHf$react = require("react");
3
- var $9zqHf$contentfulf36icons = require("@contentful/f36-icons");
4
- var $9zqHf$contentfulf36tokens = require("@contentful/f36-tokens");
5
-
6
- function $parcel$export(e, n, v, s) {
7
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
- }
9
- function $parcel$interopDefault(a) {
10
- return a && a.__esModule ? a.default : a;
11
- }
12
-
13
- $parcel$export(module.exports, "DragHandle", () => $7340ff11beb99de7$export$a0c24614540b0efb);
14
-
15
-
16
-
17
-
18
-
19
-
20
- const $590c5f6da3a22459$export$ffd58b7f6f099a57 = ()=>({
21
- label: /*#__PURE__*/ (0, $9zqHf$emotion.css)({
22
- name: "1b512s9",
23
- styles: "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0;"
24
- }),
25
- root: ({ isActive: isActive , isFocused: isFocused , isHovered: isHovered })=>{
26
- return (0, $9zqHf$emotion.cx)(/*#__PURE__*/ (0, $9zqHf$emotion.css)({
27
- alignItems: "center",
28
- backgroundColor: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).gray100,
29
- border: 0,
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
- padding: 0,
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
- },
43
- "&:focus": {
44
- boxShadow: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).glowPrimary
45
- },
46
- "&:focus:not(:focus-visible)": {
47
- boxShadow: "unset"
48
- },
49
- "&:focus-visible": {
50
- boxShadow: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).glowPrimary
51
- }
52
- }), (isActive || isFocused || isHovered) && /*#__PURE__*/ (0, $9zqHf$emotion.css)({
53
- backgroundColor: (0, ($parcel$interopDefault($9zqHf$contentfulf36tokens))).gray200,
54
- cursor: isActive ? "grabbing" : "grab"
55
- }));
56
- }
57
- });
58
-
59
-
60
- //
61
- // The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,
62
- // in every place where we use this component with react-sortable-hoc.
63
- // (the custom callback with all the logic from default callback, but without button event cancelation).
64
- // So we decided that just changing it to the div, as it was in v3, is a better fix.
65
- //
66
- // default shouldCancelStart callback:
67
- // https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js
68
- const $7340ff11beb99de7$var$DRAG_HANDLE_DEFAULT_TAG = "div";
69
- function $7340ff11beb99de7$var$_DragHandle(props, ref) {
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)=>{
75
- setisFocused(true);
76
- if (onFocus) onFocus(event);
77
- }, [
78
- onFocus
79
- ]);
80
- const handleBlur = (0, $9zqHf$react.useCallback)((event)=>{
81
- setisFocused(false);
82
- if (onBlur) onBlur(event);
83
- }, [
84
- onBlur
85
- ]);
86
- const handleMouseEnter = (0, $9zqHf$react.useCallback)((event)=>{
87
- setisHovered(true);
88
- if (onMouseEnter) onMouseEnter(event);
89
- }, [
90
- onMouseEnter
91
- ]);
92
- const handleMouseLeave = (0, $9zqHf$react.useCallback)((event)=>{
93
- setisHovered(false);
94
- if (onMouseLeave) onMouseLeave(event);
95
- }, [
96
- onMouseLeave
97
- ]);
98
- const commonProps = {
99
- className: (0, $9zqHf$emotion.cx)(styles.root({
100
- isActive: isActive,
101
- isFocused: isFocused,
102
- isHovered: isHovered
103
- }), className),
104
- "data-test-id": testId,
105
- onBlur: handleBlur,
106
- onFocus: handleFocus,
107
- onMouseEnter: handleMouseEnter,
108
- onMouseLeave: handleMouseLeave,
109
- ref: ref,
110
- style: style
111
- };
112
- if (as === "div") return /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement("div", {
113
- ...otherProps,
114
- ...commonProps,
115
- role: "button",
116
- tabIndex: 0
117
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement((0, $9zqHf$contentfulf36icons.DragIcon), {
118
- variant: "muted"
119
- }), /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement("span", {
120
- className: styles.label
121
- }, label));
122
- return /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement("button", {
123
- ...otherProps,
124
- ...commonProps,
125
- type: "button"
126
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement((0, $9zqHf$contentfulf36icons.DragIcon), {
127
- variant: "muted"
128
- }), /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).createElement("span", {
129
- className: styles.label
130
- }, label));
131
- }
132
- const $7340ff11beb99de7$export$a0c24614540b0efb = /*#__PURE__*/ (0, ($parcel$interopDefault($9zqHf$react))).forwardRef($7340ff11beb99de7$var$_DragHandle);
133
-
134
-
135
-
136
-
137
- //# sourceMappingURL=main.js.map
package/dist/main.js.map DELETED
@@ -1 +0,0 @@
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,kBAN1B;gBAOFI,SAAS,EAAE,YAPT;gBAQFC,OAAO,EAAE,MARP;gBASFC,cA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B,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 DELETED
@@ -1,130 +0,0 @@
1
- import {cx as $8USmO$cx, css as $8USmO$css} from "emotion";
2
- import $8USmO$react, {useState as $8USmO$useState, useCallback as $8USmO$useCallback} from "react";
3
- import {DragIcon as $8USmO$DragIcon} from "@contentful/f36-icons";
4
- import $8USmO$contentfulf36tokens from "@contentful/f36-tokens";
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
- const $1282af47e008eae6$export$ffd58b7f6f099a57 = ()=>({
13
- label: /*#__PURE__*/ (0, $8USmO$css)({
14
- name: "1b512s9",
15
- styles: "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0;"
16
- }),
17
- root: ({ isActive: isActive , isFocused: isFocused , isHovered: isHovered })=>{
18
- return (0, $8USmO$cx)(/*#__PURE__*/ (0, $8USmO$css)({
19
- alignItems: "center",
20
- backgroundColor: (0, $8USmO$contentfulf36tokens).gray100,
21
- border: 0,
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
- padding: 0,
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
- },
35
- "&:focus": {
36
- boxShadow: (0, $8USmO$contentfulf36tokens).glowPrimary
37
- },
38
- "&:focus:not(:focus-visible)": {
39
- boxShadow: "unset"
40
- },
41
- "&:focus-visible": {
42
- boxShadow: (0, $8USmO$contentfulf36tokens).glowPrimary
43
- }
44
- }), (isActive || isFocused || isHovered) && /*#__PURE__*/ (0, $8USmO$css)({
45
- backgroundColor: (0, $8USmO$contentfulf36tokens).gray200,
46
- cursor: isActive ? "grabbing" : "grab"
47
- }));
48
- }
49
- });
50
-
51
-
52
- //
53
- // The other alternative way to fix it was to pass a custom `shouldCancelStart` callback,
54
- // in every place where we use this component with react-sortable-hoc.
55
- // (the custom callback with all the logic from default callback, but without button event cancelation).
56
- // So we decided that just changing it to the div, as it was in v3, is a better fix.
57
- //
58
- // default shouldCancelStart callback:
59
- // https://github.com/clauderic/react-sortable-hoc/blob/d94ba3cc67cfc7d6d460b585e7723bdb50015e53/src/SortableContainer/defaultShouldCancelStart.js
60
- const $0d6e001a91dc675e$var$DRAG_HANDLE_DEFAULT_TAG = "div";
61
- function $0d6e001a91dc675e$var$_DragHandle(props, ref) {
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)=>{
67
- setisFocused(true);
68
- if (onFocus) onFocus(event);
69
- }, [
70
- onFocus
71
- ]);
72
- const handleBlur = (0, $8USmO$useCallback)((event)=>{
73
- setisFocused(false);
74
- if (onBlur) onBlur(event);
75
- }, [
76
- onBlur
77
- ]);
78
- const handleMouseEnter = (0, $8USmO$useCallback)((event)=>{
79
- setisHovered(true);
80
- if (onMouseEnter) onMouseEnter(event);
81
- }, [
82
- onMouseEnter
83
- ]);
84
- const handleMouseLeave = (0, $8USmO$useCallback)((event)=>{
85
- setisHovered(false);
86
- if (onMouseLeave) onMouseLeave(event);
87
- }, [
88
- onMouseLeave
89
- ]);
90
- const commonProps = {
91
- className: (0, $8USmO$cx)(styles.root({
92
- isActive: isActive,
93
- isFocused: isFocused,
94
- isHovered: isHovered
95
- }), className),
96
- "data-test-id": testId,
97
- onBlur: handleBlur,
98
- onFocus: handleFocus,
99
- onMouseEnter: handleMouseEnter,
100
- onMouseLeave: handleMouseLeave,
101
- ref: ref,
102
- style: style
103
- };
104
- if (as === "div") return /*#__PURE__*/ (0, $8USmO$react).createElement("div", {
105
- ...otherProps,
106
- ...commonProps,
107
- role: "button",
108
- tabIndex: 0
109
- }, /*#__PURE__*/ (0, $8USmO$react).createElement((0, $8USmO$DragIcon), {
110
- variant: "muted"
111
- }), /*#__PURE__*/ (0, $8USmO$react).createElement("span", {
112
- className: styles.label
113
- }, label));
114
- return /*#__PURE__*/ (0, $8USmO$react).createElement("button", {
115
- ...otherProps,
116
- ...commonProps,
117
- type: "button"
118
- }, /*#__PURE__*/ (0, $8USmO$react).createElement((0, $8USmO$DragIcon), {
119
- variant: "muted"
120
- }), /*#__PURE__*/ (0, $8USmO$react).createElement("span", {
121
- className: styles.label
122
- }, label));
123
- }
124
- const $0d6e001a91dc675e$export$a0c24614540b0efb = /*#__PURE__*/ (0, $8USmO$react).forwardRef($0d6e001a91dc675e$var$_DragHandle);
125
-
126
-
127
-
128
-
129
- export {$0d6e001a91dc675e$export$a0c24614540b0efb as DragHandle};
130
- //# sourceMappingURL=module.js.map
@@ -1 +0,0 @@
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,OAA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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"}
@@ -1 +0,0 @@
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"}