@kwiz/fluentui 1.0.73 → 1.0.75
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/.github/workflows/npm-publish.yml +24 -24
- package/LICENSE +21 -21
- package/README.md +53 -53
- package/dist/@types/forwardRef.d.ts +0 -0
- package/dist/@types/forwardRef.js +1 -0
- package/dist/@types/forwardRef.js.map +1 -0
- package/dist/controls/error-boundary copy.d.ts +23 -0
- package/dist/controls/error-boundary copy.js +33 -0
- package/dist/controls/error-boundary copy.js.map +1 -0
- package/dist/controls/menu.js +2 -2
- package/dist/controls/menu.js.map +1 -1
- package/dist/controls/search.js +19 -11
- package/dist/controls/search.js.map +1 -1
- package/dist/controls/svg.js +21 -21
- package/dist/controls/svg.js.map +1 -1
- package/dist/helpers/common.d.ts +4 -0
- package/dist/helpers/common.js +2 -0
- package/dist/helpers/common.js.map +1 -0
- package/dist/helpers/context.d.ts +26 -0
- package/dist/helpers/context.js +15 -0
- package/dist/helpers/context.js.map +1 -0
- package/dist/helpers/drag-drop/exports.d.ts +12 -0
- package/dist/helpers/drag-drop/exports.js +3 -0
- package/dist/helpers/drag-drop/exports.js.map +1 -0
- package/dist/helpers/exports.d.ts +7 -0
- package/dist/helpers/exports.js +8 -0
- package/dist/helpers/exports.js.map +1 -0
- package/dist/helpers/use-editable-control.d.ts +1 -1
- package/dist/helpers/use-editable-control.js.map +1 -1
- package/package.json +85 -84
- package/src/_modules/config.ts +9 -9
- package/src/_modules/constants.ts +3 -3
- package/src/controls/ColorPickerDialog.tsx +83 -83
- package/src/controls/accordion.tsx +62 -62
- package/src/controls/button.tsx +180 -180
- package/src/controls/canvas/CustomEventTargetBase.ts +32 -32
- package/src/controls/canvas/DrawPad.tsx +296 -296
- package/src/controls/canvas/DrawPadManager.ts +694 -694
- package/src/controls/canvas/bezier.ts +109 -109
- package/src/controls/canvas/point.ts +44 -44
- package/src/controls/card-list.tsx +31 -31
- package/src/controls/card.tsx +77 -77
- package/src/controls/centered.tsx +14 -14
- package/src/controls/date.tsx +87 -87
- package/src/controls/diagram-picker.tsx +96 -96
- package/src/controls/divider.tsx +15 -15
- package/src/controls/dropdown.tsx +66 -66
- package/src/controls/error-boundary.tsx +41 -41
- package/src/controls/field-editor.tsx +42 -42
- package/src/controls/file-upload.tsx +155 -155
- package/src/controls/horizontal.tsx +48 -48
- package/src/controls/html-editor/editor.tsx +182 -182
- package/src/controls/index.ts +33 -33
- package/src/controls/input.tsx +160 -160
- package/src/controls/kwizoverflow.tsx +106 -106
- package/src/controls/list.tsx +119 -119
- package/src/controls/loading.tsx +10 -10
- package/src/controls/menu.tsx +173 -173
- package/src/controls/merge-text.tsx +126 -126
- package/src/controls/please-wait.tsx +32 -32
- package/src/controls/progress-bar.tsx +109 -109
- package/src/controls/prompt.tsx +121 -121
- package/src/controls/qrcode.tsx +36 -36
- package/src/controls/search.tsx +71 -61
- package/src/controls/section.tsx +133 -133
- package/src/controls/svg.tsx +138 -138
- package/src/controls/toolbar.tsx +46 -46
- package/src/controls/vertical-content.tsx +49 -49
- package/src/controls/vertical.tsx +42 -42
- package/src/helpers/block-nav.tsx +88 -88
- package/src/helpers/context-const.ts +29 -29
- package/src/helpers/context-export.tsx +77 -77
- package/src/helpers/context-internal.ts +13 -13
- package/src/helpers/drag-drop/drag-drop-container.tsx +53 -53
- package/src/helpers/drag-drop/drag-drop-context-internal.tsx +9 -9
- package/src/helpers/drag-drop/drag-drop-context.tsx +61 -61
- package/src/helpers/drag-drop/drag-drop.types.ts +21 -21
- package/src/helpers/drag-drop/index.ts +12 -12
- package/src/helpers/drag-drop/readme.md +75 -75
- package/src/helpers/drag-drop/use-draggable.ts +47 -47
- package/src/helpers/drag-drop/use-droppable.ts +38 -38
- package/src/helpers/forwardRef.ts +7 -7
- package/src/helpers/hooks-events.ts +149 -149
- package/src/helpers/hooks.tsx +141 -141
- package/src/helpers/index.ts +8 -8
- package/src/helpers/use-alerts.tsx +74 -74
- package/src/helpers/use-editable-control.tsx +37 -37
- package/src/helpers/use-toast.tsx +29 -29
- package/src/index.ts +2 -2
- package/src/styles/index.ts +1 -1
- package/src/styles/styles.ts +104 -104
- package/src/styles/theme.ts +90 -90
@@ -1,110 +1,110 @@
|
|
1
|
-
import { BasicPoint, Point } from './point';
|
2
|
-
|
3
|
-
export class Bezier {
|
4
|
-
public static fromPoints(
|
5
|
-
points: Point[],
|
6
|
-
widths: { start: number; end: number; },
|
7
|
-
): Bezier {
|
8
|
-
const c2 = this.calculateControlPoints(points[0], points[1], points[2]).c2;
|
9
|
-
const c3 = this.calculateControlPoints(points[1], points[2], points[3]).c1;
|
10
|
-
|
11
|
-
return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
|
12
|
-
}
|
13
|
-
|
14
|
-
private static calculateControlPoints(
|
15
|
-
s1: BasicPoint,
|
16
|
-
s2: BasicPoint,
|
17
|
-
s3: BasicPoint,
|
18
|
-
): {
|
19
|
-
c1: BasicPoint;
|
20
|
-
c2: BasicPoint;
|
21
|
-
} {
|
22
|
-
const dx1 = s1.x - s2.x;
|
23
|
-
const dy1 = s1.y - s2.y;
|
24
|
-
const dx2 = s2.x - s3.x;
|
25
|
-
const dy2 = s2.y - s3.y;
|
26
|
-
|
27
|
-
const m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
|
28
|
-
const m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
|
29
|
-
|
30
|
-
const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
31
|
-
const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
32
|
-
|
33
|
-
const dxm = m1.x - m2.x;
|
34
|
-
const dym = m1.y - m2.y;
|
35
|
-
|
36
|
-
const k = (l1 + l2) === 0 ? l2 : l2 / (l1 + l2);
|
37
|
-
|
38
|
-
const cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
|
39
|
-
|
40
|
-
const tx = s2.x - cm.x;
|
41
|
-
const ty = s2.y - cm.y;
|
42
|
-
|
43
|
-
return {
|
44
|
-
c1: new Point(m1.x + tx, m1.y + ty),
|
45
|
-
c2: new Point(m2.x + tx, m2.y + ty),
|
46
|
-
};
|
47
|
-
}
|
48
|
-
|
49
|
-
public constructor(
|
50
|
-
public startPoint: Point,
|
51
|
-
public control2: BasicPoint,
|
52
|
-
public control1: BasicPoint,
|
53
|
-
public endPoint: Point,
|
54
|
-
public startWidth: number,
|
55
|
-
public endWidth: number,
|
56
|
-
) { }
|
57
|
-
|
58
|
-
// Returns approximated length. Code taken from https://www.lemoda.net/maths/bezier-length/index.html.
|
59
|
-
public length(): number {
|
60
|
-
const steps = 10;
|
61
|
-
let length = 0;
|
62
|
-
let px;
|
63
|
-
let py;
|
64
|
-
|
65
|
-
for (let i = 0; i <= steps; i += 1) {
|
66
|
-
const t = i / steps;
|
67
|
-
const cx = this.point(
|
68
|
-
t,
|
69
|
-
this.startPoint.x,
|
70
|
-
this.control1.x,
|
71
|
-
this.control2.x,
|
72
|
-
this.endPoint.x,
|
73
|
-
);
|
74
|
-
const cy = this.point(
|
75
|
-
t,
|
76
|
-
this.startPoint.y,
|
77
|
-
this.control1.y,
|
78
|
-
this.control2.y,
|
79
|
-
this.endPoint.y,
|
80
|
-
);
|
81
|
-
|
82
|
-
if (i > 0) {
|
83
|
-
const xdiff = cx - (px as number);
|
84
|
-
const ydiff = cy - (py as number);
|
85
|
-
|
86
|
-
length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
|
87
|
-
}
|
88
|
-
|
89
|
-
px = cx;
|
90
|
-
py = cy;
|
91
|
-
}
|
92
|
-
|
93
|
-
return length;
|
94
|
-
}
|
95
|
-
|
96
|
-
// Calculate parametric value of x or y given t and the four point coordinates of a cubic bezier curve.
|
97
|
-
private point(
|
98
|
-
t: number,
|
99
|
-
start: number,
|
100
|
-
c1: number,
|
101
|
-
c2: number,
|
102
|
-
end: number,
|
103
|
-
): number {
|
104
|
-
// prettier-ignore
|
105
|
-
return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
|
106
|
-
+ (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
|
107
|
-
+ (3.0 * c2 * (1.0 - t) * t * t)
|
108
|
-
+ (end * t * t * t);
|
109
|
-
}
|
1
|
+
import { BasicPoint, Point } from './point';
|
2
|
+
|
3
|
+
export class Bezier {
|
4
|
+
public static fromPoints(
|
5
|
+
points: Point[],
|
6
|
+
widths: { start: number; end: number; },
|
7
|
+
): Bezier {
|
8
|
+
const c2 = this.calculateControlPoints(points[0], points[1], points[2]).c2;
|
9
|
+
const c3 = this.calculateControlPoints(points[1], points[2], points[3]).c1;
|
10
|
+
|
11
|
+
return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
|
12
|
+
}
|
13
|
+
|
14
|
+
private static calculateControlPoints(
|
15
|
+
s1: BasicPoint,
|
16
|
+
s2: BasicPoint,
|
17
|
+
s3: BasicPoint,
|
18
|
+
): {
|
19
|
+
c1: BasicPoint;
|
20
|
+
c2: BasicPoint;
|
21
|
+
} {
|
22
|
+
const dx1 = s1.x - s2.x;
|
23
|
+
const dy1 = s1.y - s2.y;
|
24
|
+
const dx2 = s2.x - s3.x;
|
25
|
+
const dy2 = s2.y - s3.y;
|
26
|
+
|
27
|
+
const m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
|
28
|
+
const m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
|
29
|
+
|
30
|
+
const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
31
|
+
const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
32
|
+
|
33
|
+
const dxm = m1.x - m2.x;
|
34
|
+
const dym = m1.y - m2.y;
|
35
|
+
|
36
|
+
const k = (l1 + l2) === 0 ? l2 : l2 / (l1 + l2);
|
37
|
+
|
38
|
+
const cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
|
39
|
+
|
40
|
+
const tx = s2.x - cm.x;
|
41
|
+
const ty = s2.y - cm.y;
|
42
|
+
|
43
|
+
return {
|
44
|
+
c1: new Point(m1.x + tx, m1.y + ty),
|
45
|
+
c2: new Point(m2.x + tx, m2.y + ty),
|
46
|
+
};
|
47
|
+
}
|
48
|
+
|
49
|
+
public constructor(
|
50
|
+
public startPoint: Point,
|
51
|
+
public control2: BasicPoint,
|
52
|
+
public control1: BasicPoint,
|
53
|
+
public endPoint: Point,
|
54
|
+
public startWidth: number,
|
55
|
+
public endWidth: number,
|
56
|
+
) { }
|
57
|
+
|
58
|
+
// Returns approximated length. Code taken from https://www.lemoda.net/maths/bezier-length/index.html.
|
59
|
+
public length(): number {
|
60
|
+
const steps = 10;
|
61
|
+
let length = 0;
|
62
|
+
let px;
|
63
|
+
let py;
|
64
|
+
|
65
|
+
for (let i = 0; i <= steps; i += 1) {
|
66
|
+
const t = i / steps;
|
67
|
+
const cx = this.point(
|
68
|
+
t,
|
69
|
+
this.startPoint.x,
|
70
|
+
this.control1.x,
|
71
|
+
this.control2.x,
|
72
|
+
this.endPoint.x,
|
73
|
+
);
|
74
|
+
const cy = this.point(
|
75
|
+
t,
|
76
|
+
this.startPoint.y,
|
77
|
+
this.control1.y,
|
78
|
+
this.control2.y,
|
79
|
+
this.endPoint.y,
|
80
|
+
);
|
81
|
+
|
82
|
+
if (i > 0) {
|
83
|
+
const xdiff = cx - (px as number);
|
84
|
+
const ydiff = cy - (py as number);
|
85
|
+
|
86
|
+
length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
|
87
|
+
}
|
88
|
+
|
89
|
+
px = cx;
|
90
|
+
py = cy;
|
91
|
+
}
|
92
|
+
|
93
|
+
return length;
|
94
|
+
}
|
95
|
+
|
96
|
+
// Calculate parametric value of x or y given t and the four point coordinates of a cubic bezier curve.
|
97
|
+
private point(
|
98
|
+
t: number,
|
99
|
+
start: number,
|
100
|
+
c1: number,
|
101
|
+
c2: number,
|
102
|
+
end: number,
|
103
|
+
): number {
|
104
|
+
// prettier-ignore
|
105
|
+
return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
|
106
|
+
+ (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
|
107
|
+
+ (3.0 * c2 * (1.0 - t) * t * t)
|
108
|
+
+ (end * t * t * t);
|
109
|
+
}
|
110
110
|
}
|
@@ -1,45 +1,45 @@
|
|
1
|
-
// Interface for point data structure used e.g. in SignaturePad#fromData method
|
2
|
-
export interface BasicPoint {
|
3
|
-
x: number;
|
4
|
-
y: number;
|
5
|
-
pressure: number;
|
6
|
-
time: number;
|
7
|
-
}
|
8
|
-
|
9
|
-
export class Point implements BasicPoint {
|
10
|
-
public x: number;
|
11
|
-
public y: number;
|
12
|
-
public pressure: number;
|
13
|
-
public time: number;
|
14
|
-
|
15
|
-
public constructor(x: number, y: number, pressure?: number, time?: number) {
|
16
|
-
if (isNaN(x) || isNaN(y)) {
|
17
|
-
throw new Error(`Point is invalid: (${x}, ${y})`);
|
18
|
-
}
|
19
|
-
this.x = +x;
|
20
|
-
this.y = +y;
|
21
|
-
this.pressure = pressure || 0;
|
22
|
-
this.time = time || Date.now();
|
23
|
-
}
|
24
|
-
|
25
|
-
public distanceTo(start: BasicPoint): number {
|
26
|
-
return Math.sqrt(
|
27
|
-
Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2),
|
28
|
-
);
|
29
|
-
}
|
30
|
-
|
31
|
-
public equals(other: BasicPoint): boolean {
|
32
|
-
return (
|
33
|
-
this.x === other.x &&
|
34
|
-
this.y === other.y &&
|
35
|
-
this.pressure === other.pressure &&
|
36
|
-
this.time === other.time
|
37
|
-
);
|
38
|
-
}
|
39
|
-
|
40
|
-
public velocityFrom(start: BasicPoint): number {
|
41
|
-
return this.time !== start.time
|
42
|
-
? this.distanceTo(start) / (this.time - start.time)
|
43
|
-
: 0;
|
44
|
-
}
|
1
|
+
// Interface for point data structure used e.g. in SignaturePad#fromData method
|
2
|
+
export interface BasicPoint {
|
3
|
+
x: number;
|
4
|
+
y: number;
|
5
|
+
pressure: number;
|
6
|
+
time: number;
|
7
|
+
}
|
8
|
+
|
9
|
+
export class Point implements BasicPoint {
|
10
|
+
public x: number;
|
11
|
+
public y: number;
|
12
|
+
public pressure: number;
|
13
|
+
public time: number;
|
14
|
+
|
15
|
+
public constructor(x: number, y: number, pressure?: number, time?: number) {
|
16
|
+
if (isNaN(x) || isNaN(y)) {
|
17
|
+
throw new Error(`Point is invalid: (${x}, ${y})`);
|
18
|
+
}
|
19
|
+
this.x = +x;
|
20
|
+
this.y = +y;
|
21
|
+
this.pressure = pressure || 0;
|
22
|
+
this.time = time || Date.now();
|
23
|
+
}
|
24
|
+
|
25
|
+
public distanceTo(start: BasicPoint): number {
|
26
|
+
return Math.sqrt(
|
27
|
+
Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2),
|
28
|
+
);
|
29
|
+
}
|
30
|
+
|
31
|
+
public equals(other: BasicPoint): boolean {
|
32
|
+
return (
|
33
|
+
this.x === other.x &&
|
34
|
+
this.y === other.y &&
|
35
|
+
this.pressure === other.pressure &&
|
36
|
+
this.time === other.time
|
37
|
+
);
|
38
|
+
}
|
39
|
+
|
40
|
+
public velocityFrom(start: BasicPoint): number {
|
41
|
+
return this.time !== start.time
|
42
|
+
? this.distanceTo(start) / (this.time - start.time)
|
43
|
+
: 0;
|
44
|
+
}
|
45
45
|
}
|
@@ -1,32 +1,32 @@
|
|
1
|
-
import { makeStyles } from '@fluentui/react-components';
|
2
|
-
import React from 'react';
|
3
|
-
import { CardEX, iCardProps } from './card';
|
4
|
-
import { Centered } from './centered';
|
5
|
-
import { Horizontal } from './horizontal';
|
6
|
-
|
7
|
-
const useStyles = makeStyles({
|
8
|
-
emptyList: {
|
9
|
-
position: "absolute", top: 0, bottom: 0, left: 0, right: 0,
|
10
|
-
display: "flex",
|
11
|
-
zIndex: -1
|
12
|
-
}
|
13
|
-
});
|
14
|
-
interface iProps {
|
15
|
-
cards: iCardProps[];
|
16
|
-
/** centered back-fill control */
|
17
|
-
backfill?: JSX.Element;
|
18
|
-
}
|
19
|
-
export const CardList: React.FunctionComponent<React.PropsWithChildren<iProps>> = (props) => {
|
20
|
-
const classes = useStyles();
|
21
|
-
return (
|
22
|
-
<Horizontal main wrap>
|
23
|
-
{props.backfill && <div className={classes.emptyList}>
|
24
|
-
<Centered>
|
25
|
-
{props.backfill}
|
26
|
-
</Centered>
|
27
|
-
</div>}
|
28
|
-
|
29
|
-
{props.cards.map((card, idx) => <CardEX key={`i${idx}`} {...card} />)}
|
30
|
-
</Horizontal>
|
31
|
-
);
|
1
|
+
import { makeStyles } from '@fluentui/react-components';
|
2
|
+
import React from 'react';
|
3
|
+
import { CardEX, iCardProps } from './card';
|
4
|
+
import { Centered } from './centered';
|
5
|
+
import { Horizontal } from './horizontal';
|
6
|
+
|
7
|
+
const useStyles = makeStyles({
|
8
|
+
emptyList: {
|
9
|
+
position: "absolute", top: 0, bottom: 0, left: 0, right: 0,
|
10
|
+
display: "flex",
|
11
|
+
zIndex: -1
|
12
|
+
}
|
13
|
+
});
|
14
|
+
interface iProps {
|
15
|
+
cards: iCardProps[];
|
16
|
+
/** centered back-fill control */
|
17
|
+
backfill?: JSX.Element;
|
18
|
+
}
|
19
|
+
export const CardList: React.FunctionComponent<React.PropsWithChildren<iProps>> = (props) => {
|
20
|
+
const classes = useStyles();
|
21
|
+
return (
|
22
|
+
<Horizontal main wrap>
|
23
|
+
{props.backfill && <div className={classes.emptyList}>
|
24
|
+
<Centered>
|
25
|
+
{props.backfill}
|
26
|
+
</Centered>
|
27
|
+
</div>}
|
28
|
+
|
29
|
+
{props.cards.map((card, idx) => <CardEX key={`i${idx}`} {...card} />)}
|
30
|
+
</Horizontal>
|
31
|
+
);
|
32
32
|
}
|
package/src/controls/card.tsx
CHANGED
@@ -1,78 +1,78 @@
|
|
1
|
-
import { Card, CardFooter, cardFooterClassNames, CardHeader, CardPreview, Label, makeStyles, tokens } from '@fluentui/react-components';
|
2
|
-
import { FluentIcon, MoreVerticalRegular } from '@fluentui/react-icons';
|
3
|
-
import { isNotEmptyArray, isNotEmptyString, isNullOrEmptyArray, isNullOrUndefined } from '@kwiz/common';
|
4
|
-
import React from 'react';
|
5
|
-
import { iMenuItemEX, MenuEx } from './menu';
|
6
|
-
|
7
|
-
const useStyles = makeStyles({
|
8
|
-
card: {
|
9
|
-
height: '225px',
|
10
|
-
width: '190px',
|
11
|
-
[`& .${cardFooterClassNames.root}>button`]: {
|
12
|
-
display: "none"
|
13
|
-
},
|
14
|
-
"&:hover": {
|
15
|
-
backgroundColor: tokens.colorNeutralBackground1Hover,
|
16
|
-
[`& .${cardFooterClassNames.root}>button`]: {
|
17
|
-
display: "block"
|
18
|
-
}
|
19
|
-
}
|
20
|
-
},
|
21
|
-
previewContent: {
|
22
|
-
textAlign: "center",
|
23
|
-
backgroundColor: tokens.colorBrandBackground,
|
24
|
-
color: tokens.colorBrandBackground2
|
25
|
-
},
|
26
|
-
previewContentNoDescription: {
|
27
|
-
textAlign: "center",
|
28
|
-
color: tokens.colorBrandBackground,
|
29
|
-
paddingTop: '20%'
|
30
|
-
},
|
31
|
-
cardIcon: {
|
32
|
-
height: '120px',
|
33
|
-
width: '100px'
|
34
|
-
|
35
|
-
},
|
36
|
-
cardLabels: {
|
37
|
-
whiteSpace: "nowrap",
|
38
|
-
overflow: "hidden",
|
39
|
-
textOverflow: "ellipsis",
|
40
|
-
maxWidth: '166px'
|
41
|
-
},
|
42
|
-
})
|
43
|
-
|
44
|
-
export interface iCardProps {
|
45
|
-
title: string;
|
46
|
-
description?: string;
|
47
|
-
icon: FluentIcon;
|
48
|
-
menuItems?: iMenuItemEX[];
|
49
|
-
footer?: JSX.Element;
|
50
|
-
onClick: React.MouseEventHandler<HTMLDivElement>;
|
51
|
-
}
|
52
|
-
export const CardEX: React.FunctionComponent<React.PropsWithChildren<iCardProps>> = (props) => {
|
53
|
-
const classes = useStyles();
|
54
|
-
const hasDescription = isNotEmptyString(props.description);
|
55
|
-
const hasActions = isNotEmptyArray(props.menuItems) || !isNullOrUndefined(props.footer);
|
56
|
-
return (
|
57
|
-
<Card className={classes.card} onClick={props.onClick}>
|
58
|
-
<CardPreview>
|
59
|
-
<div className={hasDescription ? classes.previewContent : classes.previewContentNoDescription}>
|
60
|
-
<props.icon className={classes.cardIcon} />
|
61
|
-
{!hasDescription && <>
|
62
|
-
<br />
|
63
|
-
<Label>{props.title}</Label>
|
64
|
-
</>}
|
65
|
-
</div>
|
66
|
-
</CardPreview>
|
67
|
-
{hasDescription && <CardHeader
|
68
|
-
header={<Label className={classes.cardLabels}>{props.title}</Label>}
|
69
|
-
description={<Label className={classes.cardLabels} size='small'>{props.description}</Label>}
|
70
|
-
/>}
|
71
|
-
{hasActions && <CardFooter action={isNullOrEmptyArray(props.menuItems)
|
72
|
-
? undefined
|
73
|
-
: <MenuEx trigger={{ title: 'more', icon: <MoreVerticalRegular /> }}
|
74
|
-
items={props.menuItems} />}>
|
75
|
-
{props.footer}
|
76
|
-
</CardFooter>}
|
77
|
-
</Card>);
|
1
|
+
import { Card, CardFooter, cardFooterClassNames, CardHeader, CardPreview, Label, makeStyles, tokens } from '@fluentui/react-components';
|
2
|
+
import { FluentIcon, MoreVerticalRegular } from '@fluentui/react-icons';
|
3
|
+
import { isNotEmptyArray, isNotEmptyString, isNullOrEmptyArray, isNullOrUndefined } from '@kwiz/common';
|
4
|
+
import React from 'react';
|
5
|
+
import { iMenuItemEX, MenuEx } from './menu';
|
6
|
+
|
7
|
+
const useStyles = makeStyles({
|
8
|
+
card: {
|
9
|
+
height: '225px',
|
10
|
+
width: '190px',
|
11
|
+
[`& .${cardFooterClassNames.root}>button`]: {
|
12
|
+
display: "none"
|
13
|
+
},
|
14
|
+
"&:hover": {
|
15
|
+
backgroundColor: tokens.colorNeutralBackground1Hover,
|
16
|
+
[`& .${cardFooterClassNames.root}>button`]: {
|
17
|
+
display: "block"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
},
|
21
|
+
previewContent: {
|
22
|
+
textAlign: "center",
|
23
|
+
backgroundColor: tokens.colorBrandBackground,
|
24
|
+
color: tokens.colorBrandBackground2
|
25
|
+
},
|
26
|
+
previewContentNoDescription: {
|
27
|
+
textAlign: "center",
|
28
|
+
color: tokens.colorBrandBackground,
|
29
|
+
paddingTop: '20%'
|
30
|
+
},
|
31
|
+
cardIcon: {
|
32
|
+
height: '120px',
|
33
|
+
width: '100px'
|
34
|
+
|
35
|
+
},
|
36
|
+
cardLabels: {
|
37
|
+
whiteSpace: "nowrap",
|
38
|
+
overflow: "hidden",
|
39
|
+
textOverflow: "ellipsis",
|
40
|
+
maxWidth: '166px'
|
41
|
+
},
|
42
|
+
})
|
43
|
+
|
44
|
+
export interface iCardProps {
|
45
|
+
title: string;
|
46
|
+
description?: string;
|
47
|
+
icon: FluentIcon;
|
48
|
+
menuItems?: iMenuItemEX[];
|
49
|
+
footer?: JSX.Element;
|
50
|
+
onClick: React.MouseEventHandler<HTMLDivElement>;
|
51
|
+
}
|
52
|
+
export const CardEX: React.FunctionComponent<React.PropsWithChildren<iCardProps>> = (props) => {
|
53
|
+
const classes = useStyles();
|
54
|
+
const hasDescription = isNotEmptyString(props.description);
|
55
|
+
const hasActions = isNotEmptyArray(props.menuItems) || !isNullOrUndefined(props.footer);
|
56
|
+
return (
|
57
|
+
<Card className={classes.card} onClick={props.onClick}>
|
58
|
+
<CardPreview>
|
59
|
+
<div className={hasDescription ? classes.previewContent : classes.previewContentNoDescription}>
|
60
|
+
<props.icon className={classes.cardIcon} />
|
61
|
+
{!hasDescription && <>
|
62
|
+
<br />
|
63
|
+
<Label>{props.title}</Label>
|
64
|
+
</>}
|
65
|
+
</div>
|
66
|
+
</CardPreview>
|
67
|
+
{hasDescription && <CardHeader
|
68
|
+
header={<Label className={classes.cardLabels}>{props.title}</Label>}
|
69
|
+
description={<Label className={classes.cardLabels} size='small'>{props.description}</Label>}
|
70
|
+
/>}
|
71
|
+
{hasActions && <CardFooter action={isNullOrEmptyArray(props.menuItems)
|
72
|
+
? undefined
|
73
|
+
: <MenuEx trigger={{ title: 'more', icon: <MoreVerticalRegular /> }}
|
74
|
+
items={props.menuItems} />}>
|
75
|
+
{props.footer}
|
76
|
+
</CardFooter>}
|
77
|
+
</Card>);
|
78
78
|
}
|
@@ -1,15 +1,15 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { Horizontal } from './horizontal';
|
3
|
-
import { Vertical } from './vertical';
|
4
|
-
|
5
|
-
interface IProps {
|
6
|
-
}
|
7
|
-
export const Centered: React.FunctionComponent<React.PropsWithChildren<IProps>> = (props) => {
|
8
|
-
return (
|
9
|
-
<Vertical main vCentered>
|
10
|
-
<Horizontal hCentered>
|
11
|
-
{props.children}
|
12
|
-
</Horizontal>
|
13
|
-
</Vertical>
|
14
|
-
);
|
1
|
+
import React from 'react';
|
2
|
+
import { Horizontal } from './horizontal';
|
3
|
+
import { Vertical } from './vertical';
|
4
|
+
|
5
|
+
interface IProps {
|
6
|
+
}
|
7
|
+
export const Centered: React.FunctionComponent<React.PropsWithChildren<IProps>> = (props) => {
|
8
|
+
return (
|
9
|
+
<Vertical main vCentered>
|
10
|
+
<Horizontal hCentered>
|
11
|
+
{props.children}
|
12
|
+
</Horizontal>
|
13
|
+
</Vertical>
|
14
|
+
);
|
15
15
|
}
|