react-align 1.1.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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/Grid/GridArea/index.d.ts +19 -0
  4. package/dist/Grid/GridItem/index.d.ts +26 -0
  5. package/dist/Grid/GridSection/index.d.ts +13 -0
  6. package/dist/Grid/GridWrapper/index.d.ts +12 -0
  7. package/dist/Icon/icons.d.ts +14 -0
  8. package/dist/Icon/index.d.ts +12 -0
  9. package/dist/context.d.ts +7 -0
  10. package/dist/index.d.ts +6 -0
  11. package/dist/index.js +8 -0
  12. package/dist/react-align.cjs.development.js +727 -0
  13. package/dist/react-align.cjs.development.js.map +1 -0
  14. package/dist/react-align.cjs.production.min.js +2 -0
  15. package/dist/react-align.cjs.production.min.js.map +1 -0
  16. package/dist/react-align.esm.js +716 -0
  17. package/dist/react-align.esm.js.map +1 -0
  18. package/package.json +80 -0
  19. package/src/Grid/GridArea/index.tsx +177 -0
  20. package/src/Grid/GridItem/index.tsx +252 -0
  21. package/src/Grid/GridSection/index.tsx +46 -0
  22. package/src/Grid/GridWrapper/index.tsx +39 -0
  23. package/src/Grid/grid.css +78 -0
  24. package/src/Grid/interfaces.ts +5 -0
  25. package/src/Icon/Icons/alignCenter.svg +4 -0
  26. package/src/Icon/Icons/alignCenterV.svg +4 -0
  27. package/src/Icon/Icons/alignEnd.svg +4 -0
  28. package/src/Icon/Icons/alignEndV.svg +4 -0
  29. package/src/Icon/Icons/alignStart.svg +4 -0
  30. package/src/Icon/Icons/alignStartV.svg +4 -0
  31. package/src/Icon/Icons/horizontalExtend.svg +8 -0
  32. package/src/Icon/Icons/horizontalNormal.svg +7 -0
  33. package/src/Icon/Icons/moveArrows.svg +10 -0
  34. package/src/Icon/Icons/verticalExtend.svg +8 -0
  35. package/src/Icon/Icons/verticalNormal.svg +7 -0
  36. package/src/Icon/icons.ts +25 -0
  37. package/src/Icon/index.tsx +45 -0
  38. package/src/context.tsx +6 -0
  39. package/src/index.tsx +8 -0
  40. package/src/stories/GridArea.stories.tsx +28 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-align.esm.js","sources":["../src/context.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/Grid/GridWrapper/index.tsx","../src/Grid/GridSection/index.tsx","../src/Icon/icons.ts","../src/Icon/index.tsx","../src/Grid/GridItem/index.tsx","../src/Grid/GridArea/index.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nexport const EditorModeContext = createContext<{\n enabled: boolean | undefined;\n}>({ enabled: undefined });\nexport const useEditorMode = () => useContext(EditorModeContext);\n","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React, { CSSProperties } from 'react';\nimport { DndProvider } from 'react-dnd';\nimport { HTML5Backend } from 'react-dnd-html5-backend';\nimport { EditorModeContext } from '../../context';\nimport '../grid.css';\n\nexport type GridWrapperProps = {\n className?: string;\n enabled?: boolean;\n vertical?: boolean;\n stretch?: boolean;\n // Extra customizable parts only for the really picky\n styles?: CSSProperties;\n editorStyles?: CSSProperties;\n};\n\nconst GridWrapper: React.FC<GridWrapperProps> = ({\n className,\n enabled,\n vertical,\n stretch,\n styles,\n editorStyles,\n children,\n}) => (\n <div\n className={`wrapper ${className} ${vertical && 'vertical'} ${stretch &&\n 'stretch'}`}\n style={enabled ? editorStyles : styles}\n >\n <DndProvider backend={HTML5Backend}>\n <EditorModeContext.Provider value={{ enabled }}>\n {children}\n </EditorModeContext.Provider>\n </DndProvider>\n </div>\n);\n\nexport default GridWrapper;\n","import React, { CSSProperties } from 'react';\nimport { useEditorMode } from '../../context';\nimport '../grid.css';\n\nexport type GridSectionProps = {\n className?: string;\n horizontal?: boolean;\n stretch?: boolean;\n fixedWidth?: number;\n fixedHeight?: number;\n // Extra customizable parts only for the really picky\n styles?: CSSProperties;\n editorStyles?: CSSProperties;\n};\n\nconst GridSection: React.FC<GridSectionProps> = ({\n className,\n horizontal,\n stretch,\n fixedWidth,\n fixedHeight,\n styles,\n editorStyles,\n children,\n}) => {\n const { enabled } = useEditorMode();\n const stylesFromProps: CSSProperties | undefined = enabled\n ? editorStyles\n : styles;\n\n return (\n <div\n className={`section ${className} ${horizontal &&\n 'horizontal'} ${stretch && 'stretch'}`}\n style={{\n ...stylesFromProps,\n height: fixedHeight + 'px',\n width: fixedWidth + 'px',\n }}\n >\n {children}\n </div>\n );\n};\n\nexport default GridSection;\n","import HorizontalExtend from './Icons/horizontalExtend.svg';\nimport HorizontalNormal from './Icons/horizontalNormal.svg';\nimport VerticalExtend from './Icons/verticalExtend.svg';\nimport VerticalNormal from './Icons/verticalNormal.svg';\nimport MoveArrows from './Icons/moveArrows.svg';\nimport AlignStart from './Icons/alignStart.svg';\nimport AlignCenter from './Icons/alignCenter.svg';\nimport AlignEnd from './Icons/alignEnd.svg';\nimport AlignStartV from './Icons/alignStartV.svg';\nimport AlignCenterV from './Icons/alignCenterV.svg';\nimport AlignEndV from './Icons/alignEndV.svg';\n\nexport default {\n horizontalExtend: HorizontalExtend,\n horizontalNormal: HorizontalNormal,\n verticalExtend: VerticalExtend,\n verticalNormal: VerticalNormal,\n moveArrows: MoveArrows,\n alignStart: AlignStart,\n alignCenter: AlignCenter,\n alignEnd: AlignEnd,\n alignStartV: AlignStartV,\n alignCenterV: AlignCenterV,\n alignEndV: AlignEndV,\n};\n","import React, { CSSProperties } from 'react';\nimport { css } from 'glamor';\n\nimport Icons from './icons';\n\nexport type Icons = keyof typeof Icons;\n\nexport type IconProps = {\n className?: string;\n name: string | Icons;\n size?: number;\n onClick?: () => void;\n styles?: CSSProperties;\n};\n\nconst IconStyles = (size?: number) =>\n css({\n cursor: 'pointer',\n width: size || 24 + 'px',\n height: size || 24 + 'px',\n ' svg': {\n height: size || 24 + 'px',\n width: size || 24 + 'px',\n },\n });\n\nconst Icon: React.FC<IconProps> = ({\n className,\n name,\n size,\n onClick,\n styles,\n}) => {\n const LocalIconComponent = Icons[name as Icons];\n return (\n <LocalIconComponent\n className={className}\n {...IconStyles(size)}\n style={styles}\n onClick={onClick}\n />\n );\n};\n\nexport default Icon;\n","import React, { useMemo, useRef, CSSProperties, useState } from 'react';\nimport { useDrag, useDrop, DragSourceMonitor } from 'react-dnd';\nimport { useEditorMode } from '../../context';\nimport { DragItem } from '../interfaces';\n\nimport Icon from '../../Icon';\n\nimport '../grid.css';\n\nexport type ItemProps<T = unknown> = {\n className?: string;\n id: string;\n index: number;\n extendable?: boolean;\n extended?: boolean;\n draggable?: boolean; // Optional to override or not use editorMode context. **Needs to be accompanied with GridAreas droppable prop**\n onReorder: (\n id: string,\n originalLocation: T,\n currentIndex: number,\n hoverIndex: number\n ) => void;\n onMoveArea: (\n currentItem: string,\n dropLocation: T,\n originalLocation?: T\n ) => void;\n onExtend?: (id: string, extended: boolean) => void;\n // Props passed from parent.\n location: T;\n end?: boolean;\n vertical?: boolean;\n // Extra customizable parts only for the really picky.\n styles?: CSSProperties;\n editorStyles?: CSSProperties;\n iconSize?: number;\n iconColor?: string;\n};\n\nexport const ItemType = {\n ITEM: 'react-align_item',\n GROUP: 'react-align_group',\n};\n\nconst GridItem: React.FC<ItemProps<Location>> = ({\n className,\n children,\n id,\n index,\n extendable,\n extended,\n draggable,\n onReorder,\n onMoveArea,\n onExtend,\n // Passed from parent (aka GridArea).\n location,\n end,\n vertical,\n // Picky stuff.\n styles,\n editorStyles,\n iconSize,\n iconColor = 'rgb(255, 255, 255)',\n}) => {\n const ref = useRef<HTMLDivElement>(null);\n const { enabled } = useEditorMode();\n\n const [isHovered, setHovered] = useState(false);\n\n const handleExtend = () => {\n if (!extendable || !onExtend) return;\n setHovered(false);\n onExtend(id, !extended);\n };\n\n // ***************************************\n // Drag n drop logic\n const [{ handlerId }, drop] = useDrop({\n accept: [ItemType.ITEM, ItemType.GROUP],\n collect(monitor) {\n return {\n handlerId: monitor.getHandlerId(),\n };\n },\n hover(item: DragItem, monitor) {\n if (!ref.current || !enabled || draggable) {\n return;\n }\n\n const dragIndex = item.index;\n const hoverIndex = index;\n\n if (dragIndex === hoverIndex) {\n return;\n }\n\n const hoverBoundingRect = ref.current?.getBoundingClientRect();\n\n const hoverMiddleY =\n (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const hoverMiddleX =\n (hoverBoundingRect.right - hoverBoundingRect.left) / 2;\n\n const clientOffset = monitor.getClientOffset();\n if (!clientOffset) return;\n\n const hoverClientY = clientOffset.y - hoverBoundingRect.top;\n const hoverClientX = clientOffset.x - hoverBoundingRect.left;\n\n if (vertical) {\n if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {\n return;\n }\n\n if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {\n return;\n }\n } else {\n if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX) {\n return;\n }\n\n if (dragIndex > hoverIndex && hoverClientX > hoverMiddleX) {\n return;\n }\n }\n\n onReorder(item.id, location, dragIndex, hoverIndex);\n },\n });\n\n const [{ isDragging }, drag, preview] = useDrag({\n type: ItemType.ITEM,\n item: { id, index },\n canDrag: draggable ?? enabled,\n end: (item, monitor) => {\n const dropResults: {\n location: Location;\n } | null = monitor.getDropResult();\n\n if (dropResults) {\n onMoveArea(item.id, dropResults.location, location);\n }\n },\n collect: (monitor: DragSourceMonitor) => ({\n isDragging: monitor.isDragging(),\n }),\n });\n\n preview(drop(ref));\n // ***************************************\n\n // ***************************************\n // External styles for editorMode or the vanilla grid\n const stylesFromProps: CSSProperties | undefined = enabled\n ? editorStyles\n : styles;\n\n const itemStyles: CSSProperties = useMemo(\n () => ({\n opacity: isDragging ? 0.5 : 1,\n minHeight: isHovered && enabled ? '40px' : undefined,\n width: !vertical && extended ? '100%' : undefined,\n minWidth:\n isHovered && enabled ? (extendable ? '70px' : '30px') : undefined,\n height: vertical && extended ? '100%' : undefined,\n }),\n [isDragging, isHovered, enabled, vertical, extended, extendable]\n );\n\n const containerStyle: CSSProperties = useMemo(\n () => ({\n position: 'relative',\n display: 'inline-block',\n minHeight: isHovered && enabled ? '40px' : undefined,\n width: !vertical && extended ? '100%' : undefined,\n minWidth:\n isHovered && enabled ? (extendable ? '70px' : '30px') : undefined,\n height: vertical && extended ? '100%' : undefined,\n }),\n [isHovered, enabled, vertical, extended, extendable]\n );\n\n const overlayStyles: CSSProperties = {\n position: 'absolute',\n top: '0',\n left: '0',\n width: '100%',\n height: '100%',\n boxSizing: 'border-box',\n background: 'rgba(0,0,0,0.6)',\n borderRadius: '6px',\n };\n\n const buttonStyles: CSSProperties = useMemo(\n () => ({\n display: 'flex',\n alignItems: end ? 'end' : 'start',\n justifyContent: 'space-between',\n padding: '6px',\n float: end ? 'right' : 'left',\n }),\n [end]\n );\n // ***************************************\n\n const childrenWithParentProps = React.Children.map(children, child =>\n React.cloneElement(child as React.ReactElement<{ extended: boolean }>, {\n extended: extended,\n })\n );\n\n return (\n <div\n id={id}\n ref={ref}\n data-handler-id={handlerId}\n className={`${className} item`}\n style={{ ...itemStyles, ...stylesFromProps }}\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n >\n <div style={containerStyle}>\n {(draggable ?? enabled) && isHovered && (\n <div style={overlayStyles}>\n <div style={buttonStyles}>\n <div ref={drag}>\n <Icon\n name=\"moveArrows\"\n size={iconSize}\n styles={{ color: iconColor }}\n />\n </div>\n {extendable && (\n <Icon\n name={vertical ? 'verticalExtend' : 'horizontalExtend'}\n size={iconSize}\n styles={{ color: iconColor, marginLeft: '8px' }}\n onClick={handleExtend}\n />\n )}\n </div>\n </div>\n )}\n {childrenWithParentProps}\n </div>\n </div>\n );\n};\n\nexport default GridItem;\n","import React, { CSSProperties, useCallback, useMemo } from 'react';\nimport { useDrop, DropTargetMonitor } from 'react-dnd';\nimport { ItemProps } from '../GridItem';\nimport { useEditorMode } from '../../context';\nimport Icon from '../../Icon';\nimport '../grid.css';\n\nimport { ItemType } from '../GridItem';\n\nexport type Alignment = 'start' | 'end' | 'centered';\n\nexport type AreaProps<T = unknown> = {\n className?: string;\n vertical?: boolean;\n reverse?: boolean;\n stretch?: boolean;\n end?: boolean;\n droppable?: boolean; // optional to override editorMode context (enabled param passed to GridWrapper) **Needs to be accompanied with GridItems draggable prop**\n align?: Alignment;\n location: T;\n // Extra customizable parts only for the really picky\n styles?: CSSProperties;\n editorStyles?: CSSProperties;\n iconColor?: string;\n onAlignChange?: (a: Alignment) => void;\n};\n\nconst GridArea: React.FC<AreaProps<Location>> = ({\n className,\n vertical,\n reverse,\n stretch,\n end,\n droppable,\n align,\n onAlignChange,\n location,\n children,\n // Picky stuff\n styles,\n editorStyles,\n iconColor = '#FFFFFF',\n}) => {\n const { enabled } = useEditorMode();\n\n const handleAlignChange = useCallback(\n (align: Alignment) => {\n switch (align) {\n case 'start':\n onAlignChange?.('centered');\n break;\n case 'centered':\n onAlignChange?.('end');\n break;\n default:\n onAlignChange?.('start');\n break;\n }\n },\n [onAlignChange]\n );\n\n // ***************************************\n // Drop logic\n const [{ isOver }, drop] = useDrop(() => ({\n accept: [ItemType.ITEM, ItemType.GROUP],\n drop: () => ({ location: location }),\n collect: (monitor: DropTargetMonitor) => ({\n isOver: monitor.isOver(),\n }),\n }));\n // ***************************************\n\n // ***************************************\n // Internal styles used\n const buttonStyle: CSSProperties = useMemo(\n () => ({\n position: 'absolute',\n left: vertical ? (end ? 0 : undefined) : '50%',\n right: vertical ? (!end ? 0 : undefined) : '50%',\n bottom: !vertical && !end ? 0 : vertical ? '50%' : undefined,\n top: vertical ? '50%' : end ? 0 : undefined,\n opacity: (droppable ?? enabled) && align ? 1 : 0,\n transition: 'all 0.5s ease-in-out',\n }),\n [vertical, end, droppable, enabled, align]\n );\n\n const mainStyles: CSSProperties = useMemo(\n () => ({\n opacity: isOver ? 0.8 : 1,\n minHeight: !React.Children.count(children) && !enabled ? '0px' : '26px',\n minWidth: !React.Children.count(children) && !enabled ? '0px' : '46px',\n }),\n [isOver, children, enabled]\n );\n\n const stylesFromProps: CSSProperties | undefined = enabled\n ? editorStyles\n : styles;\n // ***************************************\n\n // Rebuilds the GridItem children to receive their parent GridArea's 'end' and 'vertical' values.\n // Used to know where to align the overlay buttons (end) and how to extend the GridItems (vertical).\n const childrenWithParentProps = React.Children.map(children, child =>\n React.cloneElement(child as React.ReactElement<ItemProps<Location>>, {\n end,\n vertical,\n location,\n })\n );\n\n return (\n <div\n ref={drop}\n className={`\n ${className}\n area\n ${stretch && 'stretch'}\n ${end && 'end'}\n ${\n align === 'centered'\n ? 'just-centered'\n : align === 'end'\n ? 'just-end'\n : 'start'\n }\n ${\n vertical\n ? reverse\n ? 'vertical-r'\n : 'vertical'\n : reverse\n ? 'horizontal-r'\n : 'horizontal'\n }\n ${enabled ? 'area-transition-in' : 'area-transition-out'}\n `}\n style={{ ...mainStyles, ...stylesFromProps }}\n >\n {childrenWithParentProps}\n <div style={buttonStyle}>\n <Icon\n name={\n align === 'centered'\n ? vertical\n ? 'alignCenterV'\n : 'alignCenter'\n : align === 'end'\n ? vertical\n ? 'alignEndV'\n : 'alignEnd'\n : vertical\n ? 'alignStartV'\n : 'alignStart'\n }\n styles={{\n color: iconColor,\n cursor:\n (droppable ?? enabled) &&\n align &&\n !!React.Children.count(children)\n ? 'pointer'\n : 'default',\n }}\n onClick={\n (droppable ?? enabled) && align && !!React.Children.count(children)\n ? () => handleAlignChange(align)\n : undefined\n }\n />\n </div>\n </div>\n );\n};\n\nexport default GridArea;\n"],"names":["EditorModeContext","createContext","enabled","undefined","useEditorMode","useContext","GridWrapper","className","vertical","stretch","styles","editorStyles","children","React","style","DndProvider","backend","HTML5Backend","Provider","value","GridSection","horizontal","fixedWidth","fixedHeight","stylesFromProps","height","width","horizontalExtend","HorizontalExtend","horizontalNormal","HorizontalNormal","verticalExtend","VerticalExtend","verticalNormal","VerticalNormal","moveArrows","MoveArrows","alignStart","AlignStart","alignCenter","AlignCenter","alignEnd","AlignEnd","alignStartV","AlignStartV","alignCenterV","AlignCenterV","alignEndV","AlignEndV","IconStyles","size","css","cursor","Icon","name","onClick","LocalIconComponent","Icons","ItemType","ITEM","GROUP","GridItem","id","index","extendable","extended","draggable","onReorder","onMoveArea","onExtend","location","end","iconSize","iconColor","ref","useRef","useState","isHovered","setHovered","handleExtend","useDrop","accept","collect","monitor","handlerId","getHandlerId","hover","item","current","dragIndex","hoverIndex","hoverBoundingRect","getBoundingClientRect","hoverMiddleY","bottom","top","hoverMiddleX","right","left","clientOffset","getClientOffset","hoverClientY","y","hoverClientX","x","drop","useDrag","type","canDrag","dropResults","getDropResult","isDragging","drag","preview","itemStyles","useMemo","opacity","minHeight","minWidth","containerStyle","position","display","overlayStyles","boxSizing","background","borderRadius","buttonStyles","alignItems","justifyContent","padding","childrenWithParentProps","Children","map","child","cloneElement","onMouseEnter","onMouseLeave","color","marginLeft","GridArea","reverse","droppable","align","onAlignChange","handleAlignChange","useCallback","isOver","buttonStyle","transition","mainStyles","count"],"mappings":";;;;;AAEO,IAAMA,iBAAiB,gBAAGC,aAAa,CAE3C;AAAEC,EAAAA,OAAO,EAAEC;AAAX,CAF2C,CAAvC;AAGA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB;AAAA,SAAMC,UAAU,CAACL,iBAAD,CAAhB;AAAA,CAAtB;;ACLP,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;AACjC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;AAC9B;A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CAAemB,KAAf,CAAqB1I,QAArB,CAFF,GAGI,SAHJ,GAII;AAPA;AASR2C,IAAAA,OAAO,EACL,CAACsF,SAAD,WAACA,SAAD,GAAc3I,OAAd,KAA0B4I,KAA1B,IAAmC,CAAC,CAACjI,cAAK,CAACsH,QAAN,CAAemB,KAAf,CAAqB1I,QAArB,CAArC,GACI;AAAA,aAAMoI,iBAAiB,CAACF,KAAD,CAAvB;AAAA,KADJ,GAEI3I;GA1BR,CADF,CA5BF,CADF;AA8DD,CAnJD;;;;"}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "react-align",
3
+ "version": "1.1.2",
4
+ "author": "KaWaite",
5
+ "module": "dist/realign.esm.js",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "scripts": {
10
+ "start": "tsdx watch",
11
+ "build": "tsdx build",
12
+ "test": "tsdx test --passWithNoTests",
13
+ "lint": "tsdx lint",
14
+ "prepare": "tsdx build",
15
+ "size": "size-limit",
16
+ "analyze": "size-limit --why",
17
+ "storybook": "start-storybook -p 6006",
18
+ "build-storybook": "build-storybook"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "src"
23
+ ],
24
+ "engines": {
25
+ "node": ">=10"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=16"
29
+ },
30
+ "husky": {
31
+ "hooks": {
32
+ "pre-commit": "tsdx lint"
33
+ }
34
+ },
35
+ "prettier": {
36
+ "printWidth": 80,
37
+ "semi": true,
38
+ "singleQuote": true,
39
+ "trailingComma": "es5"
40
+ },
41
+ "size-limit": [
42
+ {
43
+ "path": "dist/realign.cjs.production.min.js",
44
+ "limit": "10 KB"
45
+ },
46
+ {
47
+ "path": "dist/realign.esm.js",
48
+ "limit": "10 KB"
49
+ }
50
+ ],
51
+ "devDependencies": {
52
+ "@babel/core": "^7.14.3",
53
+ "@size-limit/preset-small-lib": "^4.11.0",
54
+ "@storybook/addon-essentials": "^6.2.9",
55
+ "@storybook/addon-info": "^5.3.21",
56
+ "@storybook/addon-links": "^6.2.9",
57
+ "@storybook/addons": "^6.2.9",
58
+ "@storybook/react": "^6.2.9",
59
+ "@svgr/rollup": "^5.5.0",
60
+ "@types/react": "^17.0.8",
61
+ "@types/react-dom": "^17.0.5",
62
+ "babel-loader": "^8.2.2",
63
+ "cssnano": "^5.0.7",
64
+ "husky": "^6.0.0",
65
+ "postcss": "^8.3.6",
66
+ "react": "^17.0.2",
67
+ "react-dom": "^17.0.2",
68
+ "react-is": "^17.0.2",
69
+ "rollup-plugin-postcss": "^4.0.0",
70
+ "size-limit": "^4.11.0",
71
+ "tsdx": "^0.14.1",
72
+ "tslib": "^2.2.0",
73
+ "typescript": "^4.2.4"
74
+ },
75
+ "dependencies": {
76
+ "glamor": "^2.20.40",
77
+ "react-dnd": "^14.0.2",
78
+ "react-dnd-html5-backend": "^14.0.0"
79
+ }
80
+ }
@@ -0,0 +1,177 @@
1
+ import React, { CSSProperties, useCallback, useMemo } from 'react';
2
+ import { useDrop, DropTargetMonitor } from 'react-dnd';
3
+ import { ItemProps } from '../GridItem';
4
+ import { useEditorMode } from '../../context';
5
+ import Icon from '../../Icon';
6
+ import '../grid.css';
7
+
8
+ import { ItemType } from '../GridItem';
9
+
10
+ export type Alignment = 'start' | 'end' | 'centered';
11
+
12
+ export type AreaProps<T = unknown> = {
13
+ className?: string;
14
+ vertical?: boolean;
15
+ reverse?: boolean;
16
+ stretch?: boolean;
17
+ end?: boolean;
18
+ droppable?: boolean; // optional to override editorMode context (enabled param passed to GridWrapper) **Needs to be accompanied with GridItems draggable prop**
19
+ align?: Alignment;
20
+ location: T;
21
+ // Extra customizable parts only for the really picky
22
+ styles?: CSSProperties;
23
+ editorStyles?: CSSProperties;
24
+ iconColor?: string;
25
+ onAlignChange?: (a: Alignment) => void;
26
+ };
27
+
28
+ const GridArea: React.FC<AreaProps<Location>> = ({
29
+ className,
30
+ vertical,
31
+ reverse,
32
+ stretch,
33
+ end,
34
+ droppable,
35
+ align,
36
+ onAlignChange,
37
+ location,
38
+ children,
39
+ // Picky stuff
40
+ styles,
41
+ editorStyles,
42
+ iconColor = '#FFFFFF',
43
+ }) => {
44
+ const { enabled } = useEditorMode();
45
+
46
+ const handleAlignChange = useCallback(
47
+ (align: Alignment) => {
48
+ switch (align) {
49
+ case 'start':
50
+ onAlignChange?.('centered');
51
+ break;
52
+ case 'centered':
53
+ onAlignChange?.('end');
54
+ break;
55
+ default:
56
+ onAlignChange?.('start');
57
+ break;
58
+ }
59
+ },
60
+ [onAlignChange]
61
+ );
62
+
63
+ // ***************************************
64
+ // Drop logic
65
+ const [{ isOver }, drop] = useDrop(() => ({
66
+ accept: [ItemType.ITEM, ItemType.GROUP],
67
+ drop: () => ({ location: location }),
68
+ collect: (monitor: DropTargetMonitor) => ({
69
+ isOver: monitor.isOver(),
70
+ }),
71
+ }));
72
+ // ***************************************
73
+
74
+ // ***************************************
75
+ // Internal styles used
76
+ const buttonStyle: CSSProperties = useMemo(
77
+ () => ({
78
+ position: 'absolute',
79
+ left: vertical ? (end ? 0 : undefined) : '50%',
80
+ right: vertical ? (!end ? 0 : undefined) : '50%',
81
+ bottom: !vertical && !end ? 0 : vertical ? '50%' : undefined,
82
+ top: vertical ? '50%' : end ? 0 : undefined,
83
+ opacity: (droppable ?? enabled) && align ? 1 : 0,
84
+ transition: 'all 0.5s ease-in-out',
85
+ }),
86
+ [vertical, end, droppable, enabled, align]
87
+ );
88
+
89
+ const mainStyles: CSSProperties = useMemo(
90
+ () => ({
91
+ opacity: isOver ? 0.8 : 1,
92
+ minHeight: !React.Children.count(children) && !enabled ? '0px' : '26px',
93
+ minWidth: !React.Children.count(children) && !enabled ? '0px' : '46px',
94
+ }),
95
+ [isOver, children, enabled]
96
+ );
97
+
98
+ const stylesFromProps: CSSProperties | undefined = enabled
99
+ ? editorStyles
100
+ : styles;
101
+ // ***************************************
102
+
103
+ // Rebuilds the GridItem children to receive their parent GridArea's 'end' and 'vertical' values.
104
+ // Used to know where to align the overlay buttons (end) and how to extend the GridItems (vertical).
105
+ const childrenWithParentProps = React.Children.map(children, child =>
106
+ React.cloneElement(child as React.ReactElement<ItemProps<Location>>, {
107
+ end,
108
+ vertical,
109
+ location,
110
+ })
111
+ );
112
+
113
+ return (
114
+ <div
115
+ ref={drop}
116
+ className={`
117
+ ${className}
118
+ area
119
+ ${stretch && 'stretch'}
120
+ ${end && 'end'}
121
+ ${
122
+ align === 'centered'
123
+ ? 'just-centered'
124
+ : align === 'end'
125
+ ? 'just-end'
126
+ : 'start'
127
+ }
128
+ ${
129
+ vertical
130
+ ? reverse
131
+ ? 'vertical-r'
132
+ : 'vertical'
133
+ : reverse
134
+ ? 'horizontal-r'
135
+ : 'horizontal'
136
+ }
137
+ ${enabled ? 'area-transition-in' : 'area-transition-out'}
138
+ `}
139
+ style={{ ...mainStyles, ...stylesFromProps }}
140
+ >
141
+ {childrenWithParentProps}
142
+ <div style={buttonStyle}>
143
+ <Icon
144
+ name={
145
+ align === 'centered'
146
+ ? vertical
147
+ ? 'alignCenterV'
148
+ : 'alignCenter'
149
+ : align === 'end'
150
+ ? vertical
151
+ ? 'alignEndV'
152
+ : 'alignEnd'
153
+ : vertical
154
+ ? 'alignStartV'
155
+ : 'alignStart'
156
+ }
157
+ styles={{
158
+ color: iconColor,
159
+ cursor:
160
+ (droppable ?? enabled) &&
161
+ align &&
162
+ !!React.Children.count(children)
163
+ ? 'pointer'
164
+ : 'default',
165
+ }}
166
+ onClick={
167
+ (droppable ?? enabled) && align && !!React.Children.count(children)
168
+ ? () => handleAlignChange(align)
169
+ : undefined
170
+ }
171
+ />
172
+ </div>
173
+ </div>
174
+ );
175
+ };
176
+
177
+ export default GridArea;
@@ -0,0 +1,252 @@
1
+ import React, { useMemo, useRef, CSSProperties, useState } from 'react';
2
+ import { useDrag, useDrop, DragSourceMonitor } from 'react-dnd';
3
+ import { useEditorMode } from '../../context';
4
+ import { DragItem } from '../interfaces';
5
+
6
+ import Icon from '../../Icon';
7
+
8
+ import '../grid.css';
9
+
10
+ export type ItemProps<T = unknown> = {
11
+ className?: string;
12
+ id: string;
13
+ index: number;
14
+ extendable?: boolean;
15
+ extended?: boolean;
16
+ draggable?: boolean; // Optional to override or not use editorMode context. **Needs to be accompanied with GridAreas droppable prop**
17
+ onReorder: (
18
+ id: string,
19
+ originalLocation: T,
20
+ currentIndex: number,
21
+ hoverIndex: number
22
+ ) => void;
23
+ onMoveArea: (
24
+ currentItem: string,
25
+ dropLocation: T,
26
+ originalLocation?: T
27
+ ) => void;
28
+ onExtend?: (id: string, extended: boolean) => void;
29
+ // Props passed from parent.
30
+ location: T;
31
+ end?: boolean;
32
+ vertical?: boolean;
33
+ // Extra customizable parts only for the really picky.
34
+ styles?: CSSProperties;
35
+ editorStyles?: CSSProperties;
36
+ iconSize?: number;
37
+ iconColor?: string;
38
+ };
39
+
40
+ export const ItemType = {
41
+ ITEM: 'react-align_item',
42
+ GROUP: 'react-align_group',
43
+ };
44
+
45
+ const GridItem: React.FC<ItemProps<Location>> = ({
46
+ className,
47
+ children,
48
+ id,
49
+ index,
50
+ extendable,
51
+ extended,
52
+ draggable,
53
+ onReorder,
54
+ onMoveArea,
55
+ onExtend,
56
+ // Passed from parent (aka GridArea).
57
+ location,
58
+ end,
59
+ vertical,
60
+ // Picky stuff.
61
+ styles,
62
+ editorStyles,
63
+ iconSize,
64
+ iconColor = 'rgb(255, 255, 255)',
65
+ }) => {
66
+ const ref = useRef<HTMLDivElement>(null);
67
+ const { enabled } = useEditorMode();
68
+
69
+ const [isHovered, setHovered] = useState(false);
70
+
71
+ const handleExtend = () => {
72
+ if (!extendable || !onExtend) return;
73
+ setHovered(false);
74
+ onExtend(id, !extended);
75
+ };
76
+
77
+ // ***************************************
78
+ // Drag n drop logic
79
+ const [{ handlerId }, drop] = useDrop({
80
+ accept: [ItemType.ITEM, ItemType.GROUP],
81
+ collect(monitor) {
82
+ return {
83
+ handlerId: monitor.getHandlerId(),
84
+ };
85
+ },
86
+ hover(item: DragItem, monitor) {
87
+ if (!ref.current || !enabled || draggable) {
88
+ return;
89
+ }
90
+
91
+ const dragIndex = item.index;
92
+ const hoverIndex = index;
93
+
94
+ if (dragIndex === hoverIndex) {
95
+ return;
96
+ }
97
+
98
+ const hoverBoundingRect = ref.current?.getBoundingClientRect();
99
+
100
+ const hoverMiddleY =
101
+ (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
102
+ const hoverMiddleX =
103
+ (hoverBoundingRect.right - hoverBoundingRect.left) / 2;
104
+
105
+ const clientOffset = monitor.getClientOffset();
106
+ if (!clientOffset) return;
107
+
108
+ const hoverClientY = clientOffset.y - hoverBoundingRect.top;
109
+ const hoverClientX = clientOffset.x - hoverBoundingRect.left;
110
+
111
+ if (vertical) {
112
+ if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {
113
+ return;
114
+ }
115
+
116
+ if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {
117
+ return;
118
+ }
119
+ } else {
120
+ if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX) {
121
+ return;
122
+ }
123
+
124
+ if (dragIndex > hoverIndex && hoverClientX > hoverMiddleX) {
125
+ return;
126
+ }
127
+ }
128
+
129
+ onReorder(item.id, location, dragIndex, hoverIndex);
130
+ },
131
+ });
132
+
133
+ const [{ isDragging }, drag, preview] = useDrag({
134
+ type: ItemType.ITEM,
135
+ item: { id, index },
136
+ canDrag: draggable ?? enabled,
137
+ end: (item, monitor) => {
138
+ const dropResults: {
139
+ location: Location;
140
+ } | null = monitor.getDropResult();
141
+
142
+ if (dropResults) {
143
+ onMoveArea(item.id, dropResults.location, location);
144
+ }
145
+ },
146
+ collect: (monitor: DragSourceMonitor) => ({
147
+ isDragging: monitor.isDragging(),
148
+ }),
149
+ });
150
+
151
+ preview(drop(ref));
152
+ // ***************************************
153
+
154
+ // ***************************************
155
+ // External styles for editorMode or the vanilla grid
156
+ const stylesFromProps: CSSProperties | undefined = enabled
157
+ ? editorStyles
158
+ : styles;
159
+
160
+ const itemStyles: CSSProperties = useMemo(
161
+ () => ({
162
+ opacity: isDragging ? 0.5 : 1,
163
+ minHeight: isHovered && enabled ? '40px' : undefined,
164
+ width: !vertical && extended ? '100%' : undefined,
165
+ minWidth:
166
+ isHovered && enabled ? (extendable ? '70px' : '30px') : undefined,
167
+ height: vertical && extended ? '100%' : undefined,
168
+ }),
169
+ [isDragging, isHovered, enabled, vertical, extended, extendable]
170
+ );
171
+
172
+ const containerStyle: CSSProperties = useMemo(
173
+ () => ({
174
+ position: 'relative',
175
+ display: 'inline-block',
176
+ minHeight: isHovered && enabled ? '40px' : undefined,
177
+ width: !vertical && extended ? '100%' : undefined,
178
+ minWidth:
179
+ isHovered && enabled ? (extendable ? '70px' : '30px') : undefined,
180
+ height: vertical && extended ? '100%' : undefined,
181
+ }),
182
+ [isHovered, enabled, vertical, extended, extendable]
183
+ );
184
+
185
+ const overlayStyles: CSSProperties = {
186
+ position: 'absolute',
187
+ top: '0',
188
+ left: '0',
189
+ width: '100%',
190
+ height: '100%',
191
+ boxSizing: 'border-box',
192
+ background: 'rgba(0,0,0,0.6)',
193
+ borderRadius: '6px',
194
+ };
195
+
196
+ const buttonStyles: CSSProperties = useMemo(
197
+ () => ({
198
+ display: 'flex',
199
+ alignItems: end ? 'end' : 'start',
200
+ justifyContent: 'space-between',
201
+ padding: '6px',
202
+ float: end ? 'right' : 'left',
203
+ }),
204
+ [end]
205
+ );
206
+ // ***************************************
207
+
208
+ const childrenWithParentProps = React.Children.map(children, child =>
209
+ React.cloneElement(child as React.ReactElement<{ extended: boolean }>, {
210
+ extended: extended,
211
+ })
212
+ );
213
+
214
+ return (
215
+ <div
216
+ id={id}
217
+ ref={ref}
218
+ data-handler-id={handlerId}
219
+ className={`${className} item`}
220
+ style={{ ...itemStyles, ...stylesFromProps }}
221
+ onMouseEnter={() => setHovered(true)}
222
+ onMouseLeave={() => setHovered(false)}
223
+ >
224
+ <div style={containerStyle}>
225
+ {(draggable ?? enabled) && isHovered && (
226
+ <div style={overlayStyles}>
227
+ <div style={buttonStyles}>
228
+ <div ref={drag}>
229
+ <Icon
230
+ name="moveArrows"
231
+ size={iconSize}
232
+ styles={{ color: iconColor }}
233
+ />
234
+ </div>
235
+ {extendable && (
236
+ <Icon
237
+ name={vertical ? 'verticalExtend' : 'horizontalExtend'}
238
+ size={iconSize}
239
+ styles={{ color: iconColor, marginLeft: '8px' }}
240
+ onClick={handleExtend}
241
+ />
242
+ )}
243
+ </div>
244
+ </div>
245
+ )}
246
+ {childrenWithParentProps}
247
+ </div>
248
+ </div>
249
+ );
250
+ };
251
+
252
+ export default GridItem;
@@ -0,0 +1,46 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import { useEditorMode } from '../../context';
3
+ import '../grid.css';
4
+
5
+ export type GridSectionProps = {
6
+ className?: string;
7
+ horizontal?: boolean;
8
+ stretch?: boolean;
9
+ fixedWidth?: number;
10
+ fixedHeight?: number;
11
+ // Extra customizable parts only for the really picky
12
+ styles?: CSSProperties;
13
+ editorStyles?: CSSProperties;
14
+ };
15
+
16
+ const GridSection: React.FC<GridSectionProps> = ({
17
+ className,
18
+ horizontal,
19
+ stretch,
20
+ fixedWidth,
21
+ fixedHeight,
22
+ styles,
23
+ editorStyles,
24
+ children,
25
+ }) => {
26
+ const { enabled } = useEditorMode();
27
+ const stylesFromProps: CSSProperties | undefined = enabled
28
+ ? editorStyles
29
+ : styles;
30
+
31
+ return (
32
+ <div
33
+ className={`section ${className} ${horizontal &&
34
+ 'horizontal'} ${stretch && 'stretch'}`}
35
+ style={{
36
+ ...stylesFromProps,
37
+ height: fixedHeight + 'px',
38
+ width: fixedWidth + 'px',
39
+ }}
40
+ >
41
+ {children}
42
+ </div>
43
+ );
44
+ };
45
+
46
+ export default GridSection;
@@ -0,0 +1,39 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import { DndProvider } from 'react-dnd';
3
+ import { HTML5Backend } from 'react-dnd-html5-backend';
4
+ import { EditorModeContext } from '../../context';
5
+ import '../grid.css';
6
+
7
+ export type GridWrapperProps = {
8
+ className?: string;
9
+ enabled?: boolean;
10
+ vertical?: boolean;
11
+ stretch?: boolean;
12
+ // Extra customizable parts only for the really picky
13
+ styles?: CSSProperties;
14
+ editorStyles?: CSSProperties;
15
+ };
16
+
17
+ const GridWrapper: React.FC<GridWrapperProps> = ({
18
+ className,
19
+ enabled,
20
+ vertical,
21
+ stretch,
22
+ styles,
23
+ editorStyles,
24
+ children,
25
+ }) => (
26
+ <div
27
+ className={`wrapper ${className} ${vertical && 'vertical'} ${stretch &&
28
+ 'stretch'}`}
29
+ style={enabled ? editorStyles : styles}
30
+ >
31
+ <DndProvider backend={HTML5Backend}>
32
+ <EditorModeContext.Provider value={{ enabled }}>
33
+ {children}
34
+ </EditorModeContext.Provider>
35
+ </DndProvider>
36
+ </div>
37
+ );
38
+
39
+ export default GridWrapper;