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.
- package/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/Grid/GridArea/index.d.ts +19 -0
- package/dist/Grid/GridItem/index.d.ts +26 -0
- package/dist/Grid/GridSection/index.d.ts +13 -0
- package/dist/Grid/GridWrapper/index.d.ts +12 -0
- package/dist/Icon/icons.d.ts +14 -0
- package/dist/Icon/index.d.ts +12 -0
- package/dist/context.d.ts +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -0
- package/dist/react-align.cjs.development.js +727 -0
- package/dist/react-align.cjs.development.js.map +1 -0
- package/dist/react-align.cjs.production.min.js +2 -0
- package/dist/react-align.cjs.production.min.js.map +1 -0
- package/dist/react-align.esm.js +716 -0
- package/dist/react-align.esm.js.map +1 -0
- package/package.json +80 -0
- package/src/Grid/GridArea/index.tsx +177 -0
- package/src/Grid/GridItem/index.tsx +252 -0
- package/src/Grid/GridSection/index.tsx +46 -0
- package/src/Grid/GridWrapper/index.tsx +39 -0
- package/src/Grid/grid.css +78 -0
- package/src/Grid/interfaces.ts +5 -0
- package/src/Icon/Icons/alignCenter.svg +4 -0
- package/src/Icon/Icons/alignCenterV.svg +4 -0
- package/src/Icon/Icons/alignEnd.svg +4 -0
- package/src/Icon/Icons/alignEndV.svg +4 -0
- package/src/Icon/Icons/alignStart.svg +4 -0
- package/src/Icon/Icons/alignStartV.svg +4 -0
- package/src/Icon/Icons/horizontalExtend.svg +8 -0
- package/src/Icon/Icons/horizontalNormal.svg +7 -0
- package/src/Icon/Icons/moveArrows.svg +10 -0
- package/src/Icon/Icons/verticalExtend.svg +8 -0
- package/src/Icon/Icons/verticalNormal.svg +7 -0
- package/src/Icon/icons.ts +25 -0
- package/src/Icon/index.tsx +45 -0
- package/src/context.tsx +6 -0
- package/src/index.tsx +8 -0
- package/src/stories/GridArea.stories.tsx +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 KaWaite
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# React Align
|
|
2
|
+
|
|
3
|
+
A highly customizable and powerful drag 'n drop align system for React.
|
|
4
|
+
|
|
5
|
+
- Build your own alignment grid as simple or complex as you need
|
|
6
|
+
- Toggleable editor mode
|
|
7
|
+
- Customizable features and styles to integrate into your app effectively
|
|
8
|
+
- Fully written in TypeScript
|
|
9
|
+
|
|
10
|
+
### **Drag 'n drop**
|
|
11
|
+
|
|
12
|
+
<img width="638" alt="Screen Shot 2021-06-24 at 18 19 33" src="https://user-images.githubusercontent.com/34051327/123242363-ed2ecd00-d51c-11eb-8f59-b7a74a39e942.png">
|
|
13
|
+
|
|
14
|
+
### **Alignment**
|
|
15
|
+
|
|
16
|
+
<img width="1278" alt="Screen Shot 2021-06-24 at 18 46 47" src="https://user-images.githubusercontent.com/34051327/123242051-9e813300-d51c-11eb-88e4-0620db121148.png">
|
|
17
|
+
|
|
18
|
+
## Basic use
|
|
19
|
+
```tsx
|
|
20
|
+
<div style={{ width: "100vw", height: "100vh" }}>
|
|
21
|
+
// element containing GridWrapper needs to set the width and height
|
|
22
|
+
<GridWrapper>
|
|
23
|
+
<GridSection>
|
|
24
|
+
<GridArea location={{ section: "left", area: "top" }}>
|
|
25
|
+
<GridItem
|
|
26
|
+
id="1234"
|
|
27
|
+
index={1}
|
|
28
|
+
minH={100}
|
|
29
|
+
maxH={150}
|
|
30
|
+
minW={100}
|
|
31
|
+
maxW={150}
|
|
32
|
+
onReorder={YourReorderCallbackFunction}
|
|
33
|
+
onMoveArea={YourMoveAreaCallback}>
|
|
34
|
+
...your component
|
|
35
|
+
</GridItem>
|
|
36
|
+
</GridArea>
|
|
37
|
+
</GridSection>
|
|
38
|
+
</GridWrapper>
|
|
39
|
+
</div>
|
|
40
|
+
```
|
|
41
|
+
All props used in the example above are **mandatory**.
|
|
42
|
+
|
|
43
|
+
Location is based on a section/area combo that allows for unique grid layouts. The drag n drop will recognize the GridAreas based on your own desired naming convention that makes sense with your layout.
|
|
44
|
+
|
|
45
|
+
GridItem's id, index, onReorder and onMoveArea are necessary for the drag n drop as well. The id and index are presumed to be needed in your onMoveArea and OnReorder callback functions, respectively, as a way to manipulate your unique data. Types necessary for the callbacks are:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
type onReorder: (
|
|
49
|
+
id?: string,
|
|
50
|
+
originalLocation?: { section: string, area: string },
|
|
51
|
+
currentIndex?: number,
|
|
52
|
+
hoverIndex?: number
|
|
53
|
+
) => void;
|
|
54
|
+
onMoveArea: (
|
|
55
|
+
currentItem?: string,
|
|
56
|
+
dropLocation?: { section: string, area: string},
|
|
57
|
+
originalLocation?: { section: string, area: string}
|
|
58
|
+
) => void;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Finally, the min/max for width and height is expected to set the GridItem container that will dynamically shrink when space is limited or if you choose to allow your GridItems to extend.
|
|
62
|
+
|
|
63
|
+
## Editor mode
|
|
64
|
+
Re:Align's editor mode is easily toggleable by passing an *enabled* prop to the GridWrapper.
|
|
65
|
+
|
|
66
|
+
<img width="854" alt="Screen Shot 2021-06-24 at 18 15 51" src="https://user-images.githubusercontent.com/34051327/123240889-ad1b1a80-d51b-11eb-9a7d-8f9e75a9b9e0.png">
|
|
67
|
+
|
|
68
|
+
(If you want to use your own method and/or avoid style changes between editor mode and non-editor mode, pass *draggable* into GridItem and *droppable* into GridArea to enable drag 'n drop functionality directly)
|
|
69
|
+
|
|
70
|
+
Enjoy!
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
[MIT License](LICENSE)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import '../grid.css';
|
|
3
|
+
export declare type Alignment = 'start' | 'end' | 'centered';
|
|
4
|
+
export declare type AreaProps<T = unknown> = {
|
|
5
|
+
className?: string;
|
|
6
|
+
vertical?: boolean;
|
|
7
|
+
reverse?: boolean;
|
|
8
|
+
stretch?: boolean;
|
|
9
|
+
end?: boolean;
|
|
10
|
+
droppable?: boolean;
|
|
11
|
+
align?: Alignment;
|
|
12
|
+
location: T;
|
|
13
|
+
styles?: CSSProperties;
|
|
14
|
+
editorStyles?: CSSProperties;
|
|
15
|
+
iconColor?: string;
|
|
16
|
+
onAlignChange?: (a: Alignment) => void;
|
|
17
|
+
};
|
|
18
|
+
declare const GridArea: React.FC<AreaProps<Location>>;
|
|
19
|
+
export default GridArea;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import '../grid.css';
|
|
3
|
+
export declare type ItemProps<T = unknown> = {
|
|
4
|
+
className?: string;
|
|
5
|
+
id: string;
|
|
6
|
+
index: number;
|
|
7
|
+
extendable?: boolean;
|
|
8
|
+
extended?: boolean;
|
|
9
|
+
draggable?: boolean;
|
|
10
|
+
onReorder: (id: string, originalLocation: T, currentIndex: number, hoverIndex: number) => void;
|
|
11
|
+
onMoveArea: (currentItem: string, dropLocation: T, originalLocation?: T) => void;
|
|
12
|
+
onExtend?: (id: string, extended: boolean) => void;
|
|
13
|
+
location: T;
|
|
14
|
+
end?: boolean;
|
|
15
|
+
vertical?: boolean;
|
|
16
|
+
styles?: CSSProperties;
|
|
17
|
+
editorStyles?: CSSProperties;
|
|
18
|
+
iconSize?: number;
|
|
19
|
+
iconColor?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const ItemType: {
|
|
22
|
+
ITEM: string;
|
|
23
|
+
GROUP: string;
|
|
24
|
+
};
|
|
25
|
+
declare const GridItem: React.FC<ItemProps<Location>>;
|
|
26
|
+
export default GridItem;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import '../grid.css';
|
|
3
|
+
export declare type GridSectionProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
horizontal?: boolean;
|
|
6
|
+
stretch?: boolean;
|
|
7
|
+
fixedWidth?: number;
|
|
8
|
+
fixedHeight?: number;
|
|
9
|
+
styles?: CSSProperties;
|
|
10
|
+
editorStyles?: CSSProperties;
|
|
11
|
+
};
|
|
12
|
+
declare const GridSection: React.FC<GridSectionProps>;
|
|
13
|
+
export default GridSection;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import '../grid.css';
|
|
3
|
+
export declare type GridWrapperProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
vertical?: boolean;
|
|
7
|
+
stretch?: boolean;
|
|
8
|
+
styles?: CSSProperties;
|
|
9
|
+
editorStyles?: CSSProperties;
|
|
10
|
+
};
|
|
11
|
+
declare const GridWrapper: React.FC<GridWrapperProps>;
|
|
12
|
+
export default GridWrapper;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
horizontalExtend: any;
|
|
3
|
+
horizontalNormal: any;
|
|
4
|
+
verticalExtend: any;
|
|
5
|
+
verticalNormal: any;
|
|
6
|
+
moveArrows: any;
|
|
7
|
+
alignStart: any;
|
|
8
|
+
alignCenter: any;
|
|
9
|
+
alignEnd: any;
|
|
10
|
+
alignStartV: any;
|
|
11
|
+
alignCenterV: any;
|
|
12
|
+
alignEndV: any;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import Icons from './icons';
|
|
3
|
+
export declare type Icons = keyof typeof Icons;
|
|
4
|
+
export declare type IconProps = {
|
|
5
|
+
className?: string;
|
|
6
|
+
name: string | Icons;
|
|
7
|
+
size?: number;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
styles?: CSSProperties;
|
|
10
|
+
};
|
|
11
|
+
declare const Icon: React.FC<IconProps>;
|
|
12
|
+
export default Icon;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as GridWrapper } from "./Grid/GridWrapper";
|
|
2
|
+
export { default as GridSection } from "./Grid/GridSection";
|
|
3
|
+
export { default as GridArea } from "./Grid/GridArea";
|
|
4
|
+
export { default as GridItem } from "./Grid/GridItem";
|
|
5
|
+
export { default as Icon } from "./Icon";
|
|
6
|
+
export type { Alignment } from "./Grid/GridArea";
|