react-align 2.0.5 → 2.2.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.
@@ -1,13 +1,9 @@
1
- import React, { CSSProperties, ReactNode, useCallback, useState } from 'react';
2
- import {
3
- DragDropContext,
4
- DropResult,
5
- ResponderProvided,
6
- } from 'react-beautiful-dnd';
1
+ import { CSSProperties, ReactNode, useCallback, useState } from "react";
2
+ import { DragDropContext, DropResult, ResponderProvided } from "react-beautiful-dnd";
7
3
 
8
- import { Context } from './context';
9
- import { Alignment } from './GridArea';
10
- import './grid.css';
4
+ import { Context } from "./context";
5
+ import { Alignment } from "./GridArea";
6
+ import "./grid.css";
11
7
 
12
8
  export type GridWrapperProps = {
13
9
  className?: string;
@@ -23,7 +19,7 @@ export type GridWrapperProps = {
23
19
  destAreaId: string,
24
20
  destIndex: number,
25
21
  prevAreaId: string,
26
- prevIndex: number
22
+ prevIndex: number,
27
23
  ) => void;
28
24
  onAlignChange?: (areaId: string, align: Alignment) => void;
29
25
  onExtend?: (id: string, extended: boolean) => void;
@@ -52,7 +48,7 @@ const GridWrapper: React.FC<GridWrapperProps> = ({
52
48
  setDragging(false);
53
49
  if (
54
50
  !result.destination ||
55
- result.reason !== 'DROP' ||
51
+ result.reason !== "DROP" ||
56
52
  (result.destination.droppableId === result.source.droppableId &&
57
53
  result.destination.index === result.source.index)
58
54
  )
@@ -62,22 +58,20 @@ const GridWrapper: React.FC<GridWrapperProps> = ({
62
58
  result.destination.droppableId,
63
59
  result.destination.index,
64
60
  result.source.droppableId,
65
- result.source.index
61
+ result.source.index,
66
62
  );
67
63
  },
68
- [onMove]
64
+ [onMove],
69
65
  );
70
66
 
71
67
  return (
72
68
  <div
73
- className={`wrapper ${className} ${vertical && 'vertical'} ${stretch &&
74
- 'stretch'}`}
75
- style={editing ? editorStyle : style}
76
- >
69
+ className={["reactalign", "wrapper", className, vertical && "vertical", stretch && "stretch"]
70
+ .filter(Boolean)
71
+ .join(" ")}
72
+ style={editing ? editorStyle : style}>
77
73
  <DragDropContext onDragStart={handleDragStart} onDragEnd={handleDragEnd}>
78
- <Context.Provider
79
- value={{ editing: !!editing, onAlignChange, onExtend, isDragging }}
80
- >
74
+ <Context.Provider value={{ editing: !!editing, onAlignChange, onExtend, isDragging }}>
81
75
  {children}
82
76
  </Context.Provider>
83
77
  </DragDropContext>
package/src/Icon/icons.ts CHANGED
@@ -1,14 +1,14 @@
1
- import HorizontalExtend from './Icons/horizontalExtend.svg';
2
- import HorizontalNormal from './Icons/horizontalNormal.svg';
3
- import VerticalExtend from './Icons/verticalExtend.svg';
4
- import VerticalNormal from './Icons/verticalNormal.svg';
5
- import MoveArrows from './Icons/moveArrows.svg';
6
- import AlignStart from './Icons/alignStart.svg';
7
- import AlignCenter from './Icons/alignCenter.svg';
8
- import AlignEnd from './Icons/alignEnd.svg';
9
- import AlignStartV from './Icons/alignStartV.svg';
10
- import AlignCenterV from './Icons/alignCenterV.svg';
11
- import AlignEndV from './Icons/alignEndV.svg';
1
+ import { ReactComponent as AlignCenter } from "./Icons/alignCenter.svg";
2
+ import { ReactComponent as AlignCenterV } from "./Icons/alignCenterV.svg";
3
+ import { ReactComponent as AlignEnd } from "./Icons/alignEnd.svg";
4
+ import { ReactComponent as AlignEndV } from "./Icons/alignEndV.svg";
5
+ import { ReactComponent as AlignStart } from "./Icons/alignStart.svg";
6
+ import { ReactComponent as AlignStartV } from "./Icons/alignStartV.svg";
7
+ import { ReactComponent as HorizontalExtend } from "./Icons/horizontalExtend.svg";
8
+ import { ReactComponent as HorizontalNormal } from "./Icons/horizontalNormal.svg";
9
+ import { ReactComponent as MoveArrows } from "./Icons/moveArrows.svg";
10
+ import { ReactComponent as VerticalExtend } from "./Icons/verticalExtend.svg";
11
+ import { ReactComponent as VerticalNormal } from "./Icons/verticalNormal.svg";
12
12
 
13
13
  export default {
14
14
  horizontalExtend: HorizontalExtend,
@@ -1,17 +1,17 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
 
3
- import Icons from './icons';
3
+ import Icons from "./icons";
4
4
 
5
- export type Icons = keyof typeof Icons;
5
+ export type IconKeys = keyof typeof Icons;
6
6
 
7
7
  export type IconProps = {
8
8
  className?: string;
9
- name: string | Icons;
9
+ name: string | IconKeys;
10
10
  onClick?: () => void;
11
11
  };
12
12
 
13
13
  const Icon: React.FC<IconProps> = ({ className, name, onClick }) => {
14
- const LocalIconComponent = Icons[name as Icons];
14
+ const LocalIconComponent = Icons[name as IconKeys];
15
15
  return <LocalIconComponent className={className} onClick={onClick} />;
16
16
  };
17
17
 
package/src/context.tsx CHANGED
@@ -1,5 +1,6 @@
1
- import { createContext, useContext } from 'react';
2
- import { Alignment } from '.';
1
+ import { createContext, useContext } from "react";
2
+
3
+ import { Alignment } from ".";
3
4
 
4
5
  export const Context = createContext<{
5
6
  editing: boolean;
package/src/env.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /// <reference types="vite/client" />
2
+ /// <reference types="vite-plugin-svgr/client" />
package/src/grid.css CHANGED
@@ -1,17 +1,17 @@
1
1
  /* Default component styles */
2
- .wrapper {
2
+ .reactalign.wrapper {
3
3
  height: 100%;
4
4
  display: flex;
5
5
  justify-content: space-between;
6
6
  }
7
7
 
8
- .section {
8
+ .reactalign .section {
9
9
  display: flex;
10
10
  flex-direction: column;
11
11
  justify-content: space-between;
12
12
  }
13
13
 
14
- .area {
14
+ .reactalign .area {
15
15
  display: flex;
16
16
  border: 0 solid transparent;
17
17
  box-sizing: border-box;
@@ -19,47 +19,46 @@
19
19
  position: relative;
20
20
  }
21
21
 
22
- .area-transition-in {
22
+ .reactalign .area-transition-in {
23
23
  transition: all 0.3s ease-in-out, min-height 0.5s ease-in-out 0.2s, min-width 0.5s ease-in-out 0.2s;
24
24
  }
25
25
 
26
- .area-transition-out {
26
+ .reactalign .area-transition-out {
27
27
  transition: all 0.3s ease-in-out 0.4s, min-height 0.5s ease-in-out 0.2s, min-width 0.5s ease-in-out 0.2s;
28
28
  }
29
29
 
30
- .item {
30
+ .reactalign .item {
31
31
  position: relative;
32
32
  border: 0 solid transparent;
33
33
  margin: 6px;
34
34
  border-radius: 6px;
35
35
  }
36
36
 
37
- .stretch {
37
+ .reactalign .stretch {
38
38
  flex: auto;
39
39
  }
40
40
 
41
- .middle {
42
- flex-grow: 0;
43
- flex: auto;
44
- }
45
-
46
- .just-centered {
41
+ .reactalign .just-centered {
47
42
  justify-content: center;
48
43
  }
49
44
 
50
- .just-end {
45
+ .reactalign .just-end {
51
46
  justify-content: flex-end;
52
47
  }
53
48
 
54
- .end {
55
- align-items:flex-end;
49
+ .reactalign .middle {
50
+ align-items: center;
51
+ }
52
+
53
+ .reactalign .bottom {
54
+ align-items: flex-end;
56
55
  }
57
56
 
58
- .hide {
57
+ .reactalign .hide {
59
58
  display: none;
60
59
  }
61
60
 
62
- .overlay {
61
+ .reactalign .overlay {
63
62
  position: absolute;
64
63
  top: 0;
65
64
  left: 0;
@@ -69,7 +68,7 @@
69
68
  background: rgba(0,0,0,0.6);
70
69
  }
71
70
 
72
- .overlay-buttons {
71
+ .reactalign .overlay-buttons {
73
72
  display: flex;
74
73
  padding: 6px;
75
74
  box-sizing: border-box;
@@ -4,5 +4,4 @@ export { default as GridArea } from "./GridArea";
4
4
  export { default as GridItem } from "./GridItem";
5
5
  export { default as Icon } from "./Icon";
6
6
 
7
- // eslint-disable-next-line prettier/prettier
8
7
  export type { Alignment } from "./GridArea";
@@ -1,18 +0,0 @@
1
- import { CSSProperties, PropsWithChildren } from 'react';
2
- import './grid.css';
3
- export declare type Alignment = 'start' | 'centered' | 'end';
4
- export declare type AreaProps = {
5
- id: string;
6
- className?: string;
7
- vertical?: boolean;
8
- stretch?: boolean;
9
- end?: boolean;
10
- align?: Alignment;
11
- disabled?: boolean;
12
- /** Extra customizable parts only for the really picky */
13
- style?: CSSProperties;
14
- editorStyle?: CSSProperties;
15
- iconColor?: string;
16
- onAlignChange?: (alignment: Alignment) => void;
17
- };
18
- export default function GridArea({ id, className, vertical, stretch, end, disabled, align, onAlignChange, children, style, editorStyle, iconColor, }: PropsWithChildren<AreaProps>): JSX.Element;
@@ -1,26 +0,0 @@
1
- import { CSSProperties, ReactNode } from 'react';
2
- import './grid.css';
3
- export declare type ItemProps = {
4
- className?: string;
5
- id: string;
6
- index: number;
7
- extendable?: boolean;
8
- extended?: boolean;
9
- disabled?: boolean;
10
- onExtend?: (extended: boolean) => void;
11
- children?: ReactNode | ((context: {
12
- id: string;
13
- editing: boolean;
14
- isDragging: boolean;
15
- isHovered: boolean;
16
- extended: boolean;
17
- extendable: boolean;
18
- disabled: boolean;
19
- index: number;
20
- }) => ReactNode);
21
- /** Extra customizable parts only for the really picky */
22
- style?: CSSProperties;
23
- editorStyle?: CSSProperties;
24
- iconColor?: string;
25
- };
26
- export default function GridItem({ className, children, id, index, extendable, extended, disabled, style, editorStyle, iconColor, ...props }: ItemProps): JSX.Element;
@@ -1,15 +0,0 @@
1
- import React, { CSSProperties, ReactNode } from 'react';
2
- import './grid.css';
3
- export declare type GridSectionProps = {
4
- className?: string;
5
- children?: ReactNode;
6
- horizontal?: boolean;
7
- stretch?: boolean;
8
- fixedWidth?: number;
9
- fixedHeight?: number;
10
- /** Extra customizable parts only for the really picky */
11
- style?: CSSProperties;
12
- editorStyle?: CSSProperties;
13
- };
14
- declare const GridSection: React.FC<GridSectionProps>;
15
- export default GridSection;
@@ -1,18 +0,0 @@
1
- import React, { CSSProperties, ReactNode } from 'react';
2
- import { Alignment } from './GridArea';
3
- import './grid.css';
4
- export declare type GridWrapperProps = {
5
- className?: string;
6
- children?: ReactNode;
7
- editing?: boolean;
8
- vertical?: boolean;
9
- stretch?: boolean;
10
- /** Extra customizable parts only for the really picky */
11
- style?: CSSProperties;
12
- editorStyle?: CSSProperties;
13
- onMove?: (id: string, destAreaId: string, destIndex: number, prevAreaId: string, prevIndex: number) => void;
14
- onAlignChange?: (areaId: string, align: Alignment) => void;
15
- onExtend?: (id: string, extended: boolean) => void;
16
- };
17
- declare const GridWrapper: React.FC<GridWrapperProps>;
18
- export default GridWrapper;
@@ -1,14 +0,0 @@
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;
@@ -1,10 +0,0 @@
1
- import React 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
- onClick?: () => void;
8
- };
9
- declare const Icon: React.FC<IconProps>;
10
- export default Icon;
package/dist/context.d.ts DELETED
@@ -1,14 +0,0 @@
1
- /// <reference types="react" />
2
- import { Alignment } from '.';
3
- export declare const Context: import("react").Context<{
4
- editing: boolean;
5
- isDragging: boolean;
6
- onAlignChange?: ((areaId: string, align: Alignment) => void) | undefined;
7
- onExtend?: ((id: string, extended: boolean) => void) | undefined;
8
- }>;
9
- export declare const useAlignContext: () => {
10
- editing: boolean;
11
- isDragging: boolean;
12
- onAlignChange?: ((areaId: string, align: Alignment) => void) | undefined;
13
- onExtend?: ((id: string, extended: boolean) => void) | undefined;
14
- };
package/dist/index.js DELETED
@@ -1,8 +0,0 @@
1
-
2
- 'use strict'
3
-
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./react-align.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./react-align.cjs.development.js')
8
- }