ag-common 0.0.482 → 0.0.484

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.
@@ -49,6 +49,13 @@ const Node = styled_1.default.div `
49
49
  display: flex;
50
50
  flex-flow: column;
51
51
  height: min-content;
52
+ overflow: hidden;
53
+ &[data-leaf='true'] {
54
+ width: 100%;
55
+ height: 100%;
56
+ min-height: 1rem;
57
+ min-width: 1rem;
58
+ }
52
59
  `;
53
60
  const Title = styled_1.default.div `
54
61
  color: white;
@@ -60,25 +67,22 @@ const Title = styled_1.default.div `
60
67
  `;
61
68
  const render = ({ n, depth, head, headDim, tnd, }) => {
62
69
  var _a;
63
- let width = 0;
64
- let height = 0;
65
70
  const leaf = n.children.length === 0;
66
71
  const sizeMult = n.size / head.size;
67
- width = Math.floor(headDim.width * sizeMult) - 6; //6 = padding+margins
68
- if (n.children.length === 0) {
69
- height = Math.floor(headDim.height * sizeMult);
70
- }
72
+ const biggerDim = Math.max(headDim.width, headDim.height);
73
+ const nodeSize = Math.floor(biggerDim * sizeMult).toString();
71
74
  const title = ((_a = tnd.titleFn) === null || _a === void 0 ? void 0 : _a.call(tnd, {
72
75
  path: n.name,
73
76
  pathCount: n.size,
74
77
  fullCount: head.size,
75
78
  })) || `${n.name} (${n.size}/${head.size})`;
76
- return (react_1.default.createElement(Node, { "data-treenode": true, style: Object.assign({ backgroundColor: (0, styles_1.getColourWheel)(depth) }, (leaf && {
77
- width: width ? width + 'px' : '100%',
78
- height: height ? height + 'px' : '100%',
79
+ return (react_1.default.createElement(Node, { "data-treenode": true, "data-leaf": leaf.toString(), style: Object.assign({ backgroundColor: (0, styles_1.getColourWheel)(depth) }, (leaf &&
80
+ nodeSize && {
81
+ width: nodeSize + 'px',
82
+ height: nodeSize + 'px',
79
83
  })), key: n.name, "data-ch": n.children.length, "data-size": n.size, title: title },
80
84
  n.name && react_1.default.createElement(Title, null, n.name),
81
- react_1.default.createElement(NodeChildren, { "data-type": "nc" }, n.children.map((c) => render({ n: c, depth: depth + 1, head, headDim, tnd })))));
85
+ n.children.length > 0 && (react_1.default.createElement(NodeChildren, { "data-type": "nc" }, n.children.map((c) => render({ n: c, depth: depth + 1, head, headDim, tnd }))))));
82
86
  };
83
87
  const TreeChart = (tnd) => {
84
88
  const raw = (0, helpers_1.convertToRaw)({ tnd });
@@ -1,26 +1,20 @@
1
1
  /// <reference types="react" />
2
2
  /** function that returns css that gives a text outline drop shadow.
3
- * outlinecolour default='white'
4
- * size default = 1px
3
+ * @param outlineColour default='white'
4
+ * @param sizePx default = 1px
5
5
  */
6
- export declare const HardOutline: (outlineColour?: string, size?: number) => import("@emotion/react").SerializedStyles;
6
+ export declare const HardOutline: (outlineColour?: string, sizePx?: number) => import("@emotion/react").SerializedStyles;
7
+ /** disable user text selection */
7
8
  export declare const NoTextSelect: import("@emotion/react").SerializedStyles;
9
+ /** enable text overflow
10
+ * @param lines number of lines before overflow
11
+ */
8
12
  export declare const TextOverflowEllipsis: (lines: number) => import("@emotion/react").SerializedStyles;
9
- export declare const CssTransparentBlock: import("@emotion/react").SerializedStyles;
10
- export declare const FadeBottom: ({ height }: {
11
- height: string;
12
- }) => import("@emotion/react").SerializedStyles;
13
- export declare const Card: import("@emotion/styled").StyledComponent<{
14
- theme?: import("@emotion/react").Theme | undefined;
15
- as?: import("react").ElementType<any> | undefined;
16
- }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
13
+ /** stop dragging of element */
17
14
  export declare const noDrag: {
18
15
  draggable: boolean;
19
16
  onDragStart: React.DragEventHandler<HTMLDivElement>;
20
17
  onTouchStart: React.TouchEventHandler<HTMLDivElement>;
21
18
  };
22
- export declare const FullScreenPage: import("@emotion/styled").StyledComponent<{
23
- theme?: import("@emotion/react").Theme | undefined;
24
- as?: import("react").ElementType<any> | undefined;
25
- }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
19
+ /** apply bounce effect given a condition */
26
20
  export declare const bounce: (bounceattr: string) => import("@emotion/react").SerializedStyles;
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.bounce = exports.FullScreenPage = exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.TextOverflowEllipsis = exports.NoTextSelect = exports.HardOutline = void 0;
3
+ exports.bounce = exports.noDrag = exports.TextOverflowEllipsis = exports.NoTextSelect = exports.HardOutline = void 0;
7
4
  const react_1 = require("@emotion/react");
8
- const styled_1 = __importDefault(require("@emotion/styled"));
9
- const colours_1 = require("./colours");
10
5
  /** function that returns css that gives a text outline drop shadow.
11
- * outlinecolour default='white'
12
- * size default = 1px
6
+ * @param outlineColour default='white'
7
+ * @param sizePx default = 1px
13
8
  */
14
- const HardOutline = (outlineColour = 'white', size = 1) => {
15
- const px = `${size}px`;
9
+ const HardOutline = (outlineColour = 'white', sizePx = 1) => {
10
+ const px = `${sizePx}px`;
16
11
  return (0, react_1.css) `
17
12
  filter: drop-shadow(${px} ${px} 0px ${outlineColour})
18
13
  drop-shadow(-${px} ${px} 0px ${outlineColour})
@@ -21,6 +16,7 @@ const HardOutline = (outlineColour = 'white', size = 1) => {
21
16
  `;
22
17
  };
23
18
  exports.HardOutline = HardOutline;
19
+ /** disable user text selection */
24
20
  exports.NoTextSelect = (0, react_1.css) `
25
21
  user-select: none; /* supported by Chrome and Opera */
26
22
  -webkit-user-select: none; /* Safari */
@@ -28,6 +24,9 @@ exports.NoTextSelect = (0, react_1.css) `
28
24
  -moz-user-select: none; /* Firefox */
29
25
  -ms-user-select: none; /* Internet Explorer/Edge */
30
26
  `;
27
+ /** enable text overflow
28
+ * @param lines number of lines before overflow
29
+ */
31
30
  const TextOverflowEllipsis = (lines) => (0, react_1.css) `
32
31
  display: -webkit-box;
33
32
  -webkit-line-clamp: ${lines};
@@ -36,52 +35,7 @@ const TextOverflowEllipsis = (lines) => (0, react_1.css) `
36
35
  text-overflow: ellipsis;
37
36
  `;
38
37
  exports.TextOverflowEllipsis = TextOverflowEllipsis;
39
- exports.CssTransparentBlock = (0, react_1.css) `
40
- background-color: rgba(150, 150, 150, 0.5);
41
- border-radius: 3px;
42
- font-weight: 600;
43
- color: ${colours_1.colours.mainLight};
44
- `;
45
- const FadeBottom = ({ height }) => (0, react_1.css) `
46
- &:after {
47
- content: '';
48
- position: absolute;
49
- bottom: 0;
50
- width: 100%;
51
- height: ${height};
52
- background: -webkit-linear-gradient(
53
- rgba(255, 255, 255, 0) 0%,
54
- rgba(255, 255, 255, 1) 100%
55
- );
56
- background-image: -moz-linear-gradient(
57
- rgba(255, 255, 255, 0) 0%,
58
- rgba(255, 255, 255, 1) 100%
59
- );
60
- background-image: -o-linear-gradient(
61
- rgba(255, 255, 255, 0) 0%,
62
- rgba(255, 255, 255, 1) 100%
63
- );
64
- background-image: linear-gradient(
65
- rgba(255, 255, 255, 0) 0%,
66
- rgba(255, 255, 255, 1) 100%
67
- );
68
- background-image: -ms-linear-gradient(
69
- rgba(255, 255, 255, 0) 0%,
70
- rgba(255, 255, 255, 1) 100%
71
- );
72
- }
73
- `;
74
- exports.FadeBottom = FadeBottom;
75
- exports.Card = styled_1.default.div `
76
- background-color: white;
77
- margin: 0.5rem;
78
-
79
- position: relative;
80
- border-radius: 0.5rem;
81
- max-width: 40rem;
82
- padding: 1rem;
83
- border: solid 2px ${colours_1.colours.lighter};
84
- `;
38
+ /** stop dragging of element */
85
39
  exports.noDrag = {
86
40
  draggable: false,
87
41
  onDragStart: (e) => {
@@ -93,15 +47,7 @@ exports.noDrag = {
93
47
  e.stopPropagation();
94
48
  },
95
49
  };
96
- exports.FullScreenPage = styled_1.default.div `
97
- display: flex;
98
- width: 100%;
99
- flex-grow: 1;
100
- flex-flow: column;
101
- overflow: hidden;
102
- align-content: flex-start;
103
- align-items: flex-start;
104
- `;
50
+ /** apply bounce effect given a condition */
105
51
  const bounce = (bounceattr) => (0, react_1.css) `
106
52
  transition:
107
53
  opacity 0.2s ease,
@@ -1,7 +1,11 @@
1
1
  export declare const vSmallScreenPx = 500;
2
2
  export declare const smallScreenPx = 1024;
3
3
  export declare const bigScreenPx = 2000;
4
+ /** use in media query: @ media ${condition} */
4
5
  export declare const vSmallScreen: string;
6
+ /** use in media query: @ media ${condition} */
5
7
  export declare const smallScreen: string;
8
+ /** use in media query: @ media ${condition} */
6
9
  export declare const bigScreen: string;
10
+ /** use in media query: @ media ${condition} */
7
11
  export declare const vBigScreen: string;
@@ -4,7 +4,11 @@ exports.vBigScreen = exports.bigScreen = exports.smallScreen = exports.vSmallScr
4
4
  exports.vSmallScreenPx = 500;
5
5
  exports.smallScreenPx = 1024;
6
6
  exports.bigScreenPx = 2000;
7
+ /** use in media query: @ media ${condition} */
7
8
  exports.vSmallScreen = `(max-width: ${exports.vSmallScreenPx}px)`;
9
+ /** use in media query: @ media ${condition} */
8
10
  exports.smallScreen = `(max-width: ${exports.smallScreenPx}px)`;
11
+ /** use in media query: @ media ${condition} */
9
12
  exports.bigScreen = `(min-width: ${exports.smallScreenPx}px)`;
13
+ /** use in media query: @ media ${condition} */
10
14
  exports.vBigScreen = `(min-width: ${exports.bigScreenPx}px)`;
@@ -2,9 +2,7 @@
2
2
  export declare const SOBase: import("@emotion/styled").StyledComponent<{
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any> | undefined;
5
- } & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
6
- theme?: import("@emotion/react").Theme | undefined;
7
- }, {}, {}>;
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
8
6
  export declare const SOBR: import("@emotion/styled").StyledComponent<{
9
7
  theme?: import("@emotion/react").Theme | undefined;
10
8
  as?: import("react").ElementType<any> | undefined;
@@ -5,9 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SOA = exports.SOCenter = exports.SOP = exports.SOB = exports.SOBR = exports.SOBase = void 0;
7
7
  const styled_1 = __importDefault(require("@emotion/styled"));
8
- const common_1 = require("./common");
9
8
  const media_1 = require("./media");
10
- exports.SOBase = (0, styled_1.default)(common_1.FullScreenPage) `
9
+ exports.SOBase = styled_1.default.div `
10
+ display: flex;
11
+ width: 100%;
12
+ flex-grow: 1;
13
+ flex-flow: column;
14
+ overflow: hidden;
15
+ align-content: flex-start;
16
+ align-items: flex-start;
17
+
11
18
  > h1,
12
19
  h2,
13
20
  > p {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.482",
2
+ "version": "0.0.484",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",