@spteck/fluentui-react-charts 1.0.1 → 1.0.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/dist/components/dashboard/DashBoard.d.ts +1 -1
- package/dist/fluentui-react-charts.cjs.development.js +614 -2
- package/dist/fluentui-react-charts.cjs.development.js.map +1 -1
- package/dist/fluentui-react-charts.cjs.production.min.js +1 -1
- package/dist/fluentui-react-charts.cjs.production.min.js.map +1 -1
- package/dist/fluentui-react-charts.esm.js +616 -5
- package/dist/fluentui-react-charts.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/dashboard/DashBoard.tsx +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Chart, CategoryScale, LinearScale, PointElement, LineElement, Tooltip as Tooltip$1, Filler, Legend, Title, BarElement, ArcElement, RadialLinearScale } from 'chart.js';
|
|
2
|
-
import React__default, { useRef, useState, useEffect, useMemo } from 'react';
|
|
3
|
-
import { Tooltip, Button, tokens, Caption1, mergeClasses, Menu, MenuTrigger, MenuButton, MenuPopover, MenuList, MenuItem, webLightTheme, ToggleButton } from '@fluentui/react-components';
|
|
2
|
+
import React__default, { useRef, useState, useEffect, useMemo, createElement, Fragment, isValidElement, useCallback } from 'react';
|
|
3
|
+
import { Tooltip, Button, tokens, Caption1, mergeClasses, Menu, MenuTrigger, MenuButton, MenuPopover, MenuList, MenuItem, webLightTheme, ToggleButton, Text, makeStyles, shorthands, Card, CardHeader } from '@fluentui/react-components';
|
|
4
4
|
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
|
5
5
|
import { Line, Bar, Bubble, Chart as Chart$1, Doughnut, Pie, PolarArea, Radar, Scatter } from 'react-chartjs-2';
|
|
6
6
|
import { css } from '@emotion/css';
|
|
7
7
|
import { ResizeObserver } from '@juggle/resize-observer';
|
|
8
|
-
import '@fluentui/react-icons';
|
|
9
|
-
import '@iconify/react';
|
|
8
|
+
import { bundleIcon, Settings20Filled, Settings20Regular } from '@fluentui/react-icons';
|
|
9
|
+
import { Icon } from '@iconify/react';
|
|
10
10
|
|
|
11
11
|
function _extends() {
|
|
12
12
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -2903,5 +2903,616 @@ function BarChart(_ref) {
|
|
|
2903
2903
|
})));
|
|
2904
2904
|
}
|
|
2905
2905
|
|
|
2906
|
-
|
|
2906
|
+
var BusinessReportIcon = function BusinessReportIcon(_ref) {
|
|
2907
|
+
var _ref$width = _ref.width,
|
|
2908
|
+
width = _ref$width === void 0 ? 200 : _ref$width,
|
|
2909
|
+
_ref$height = _ref.height,
|
|
2910
|
+
height = _ref$height === void 0 ? 200 : _ref$height,
|
|
2911
|
+
className = _ref.className,
|
|
2912
|
+
style = _ref.style;
|
|
2913
|
+
return React__default.createElement("svg", {
|
|
2914
|
+
width: width,
|
|
2915
|
+
height: height,
|
|
2916
|
+
viewBox: "200 400 1400 1000",
|
|
2917
|
+
className: className,
|
|
2918
|
+
style: _extends({
|
|
2919
|
+
fill: tokens.colorNeutralForeground2
|
|
2920
|
+
}, style),
|
|
2921
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
2922
|
+
}, React__default.createElement("g", {
|
|
2923
|
+
id: "BACKGROUND"
|
|
2924
|
+
}, React__default.createElement("rect", {
|
|
2925
|
+
style: {
|
|
2926
|
+
fill: tokens.colorNeutralBackground1
|
|
2927
|
+
},
|
|
2928
|
+
x: "200",
|
|
2929
|
+
y: "400",
|
|
2930
|
+
width: "1400",
|
|
2931
|
+
height: "1000"
|
|
2932
|
+
})), React__default.createElement("g", null, React__default.createElement("g", null, React__default.createElement("rect", {
|
|
2933
|
+
x: "486.006",
|
|
2934
|
+
y: "568.026",
|
|
2935
|
+
style: {
|
|
2936
|
+
fill: tokens.colorNeutralBackground1
|
|
2937
|
+
},
|
|
2938
|
+
width: "1038.994",
|
|
2939
|
+
height: "768.164"
|
|
2940
|
+
}), React__default.createElement("path", {
|
|
2941
|
+
style: {
|
|
2942
|
+
fill: tokens.colorNeutralStroke1
|
|
2943
|
+
},
|
|
2944
|
+
d: "M1527.5,1338.69H483.506V565.526H1527.5V1338.69z M488.506,1333.69H1522.5V570.526H488.506V1333.69z"
|
|
2945
|
+
})), React__default.createElement("g", null, React__default.createElement("rect", {
|
|
2946
|
+
x: "558.003",
|
|
2947
|
+
y: "1086.698",
|
|
2948
|
+
style: {
|
|
2949
|
+
fill: tokens.colorNeutralForeground3,
|
|
2950
|
+
opacity: 0.3
|
|
2951
|
+
},
|
|
2952
|
+
width: "85",
|
|
2953
|
+
height: "164.492"
|
|
2954
|
+
}), React__default.createElement("rect", {
|
|
2955
|
+
x: "693.003",
|
|
2956
|
+
y: "1004.672",
|
|
2957
|
+
style: {
|
|
2958
|
+
fill: tokens.colorNeutralForeground3,
|
|
2959
|
+
opacity: 0.3
|
|
2960
|
+
},
|
|
2961
|
+
width: "85",
|
|
2962
|
+
height: "246.519"
|
|
2963
|
+
}), React__default.createElement("rect", {
|
|
2964
|
+
x: "828.003",
|
|
2965
|
+
y: "835.487",
|
|
2966
|
+
style: {
|
|
2967
|
+
fill: tokens.colorNeutralForeground3,
|
|
2968
|
+
opacity: 0.3
|
|
2969
|
+
},
|
|
2970
|
+
width: "85",
|
|
2971
|
+
height: "415.703"
|
|
2972
|
+
}), React__default.createElement("rect", {
|
|
2973
|
+
x: "963.003",
|
|
2974
|
+
y: "955.6",
|
|
2975
|
+
style: {
|
|
2976
|
+
fill: tokens.colorNeutralForeground3,
|
|
2977
|
+
opacity: 0.3
|
|
2978
|
+
},
|
|
2979
|
+
width: "85",
|
|
2980
|
+
height: "295.591"
|
|
2981
|
+
}), React__default.createElement("rect", {
|
|
2982
|
+
x: "1098.003",
|
|
2983
|
+
y: "825.238",
|
|
2984
|
+
style: {
|
|
2985
|
+
fill: tokens.colorNeutralForeground3,
|
|
2986
|
+
opacity: 0.3
|
|
2987
|
+
},
|
|
2988
|
+
width: "85",
|
|
2989
|
+
height: "425.952"
|
|
2990
|
+
}), React__default.createElement("rect", {
|
|
2991
|
+
x: "1233.003",
|
|
2992
|
+
y: "847.489",
|
|
2993
|
+
style: {
|
|
2994
|
+
fill: tokens.colorNeutralForeground3,
|
|
2995
|
+
opacity: 0.3
|
|
2996
|
+
},
|
|
2997
|
+
width: "85",
|
|
2998
|
+
height: "403.701"
|
|
2999
|
+
}), React__default.createElement("rect", {
|
|
3000
|
+
x: "1368.003",
|
|
3001
|
+
y: "699.989",
|
|
3002
|
+
style: {
|
|
3003
|
+
fill: tokens.colorNeutralForeground3,
|
|
3004
|
+
opacity: 0.3
|
|
3005
|
+
},
|
|
3006
|
+
width: "85",
|
|
3007
|
+
height: "551.201"
|
|
3008
|
+
}), React__default.createElement("polygon", {
|
|
3009
|
+
style: {
|
|
3010
|
+
fill: tokens.colorBrandBackground
|
|
3011
|
+
},
|
|
3012
|
+
points: "583.634,1185.919 581.366,1181.462 723.336,1109.231 869.748,909.808 1003.791,1050.114 1141.593,912.312 1275.235,928.549 1409.365,774.548 1413.135,777.833 1277.265,933.832 1143.407,917.569 1003.709,1057.267 870.251,917.573 726.664,1113.149"
|
|
3013
|
+
})), React__default.createElement("rect", {
|
|
3014
|
+
x: "796.336",
|
|
3015
|
+
y: "662.857",
|
|
3016
|
+
style: {
|
|
3017
|
+
fill: tokens.colorBrandBackground
|
|
3018
|
+
},
|
|
3019
|
+
width: "418.333",
|
|
3020
|
+
height: "5"
|
|
3021
|
+
}), React__default.createElement("rect", {
|
|
3022
|
+
x: "937.543",
|
|
3023
|
+
y: "717.857",
|
|
3024
|
+
style: {
|
|
3025
|
+
fill: tokens.colorBrandBackground
|
|
3026
|
+
},
|
|
3027
|
+
width: "135.92",
|
|
3028
|
+
height: "5"
|
|
3029
|
+
})), React__default.createElement("g", null, React__default.createElement("g", null, React__default.createElement("rect", {
|
|
3030
|
+
x: "264.978",
|
|
3031
|
+
y: "441.049",
|
|
3032
|
+
style: {
|
|
3033
|
+
fill: tokens.colorNeutralBackground1
|
|
3034
|
+
},
|
|
3035
|
+
width: "482.581",
|
|
3036
|
+
height: "379.067"
|
|
3037
|
+
}), React__default.createElement("path", {
|
|
3038
|
+
style: {
|
|
3039
|
+
fill: tokens.colorNeutralStroke1
|
|
3040
|
+
},
|
|
3041
|
+
d: "M750.06,822.616H262.478V438.549H750.06V822.616z M267.478,817.616H745.06V443.549H267.478V817.616z"
|
|
3042
|
+
})), React__default.createElement("g", null, React__default.createElement("g", null, React__default.createElement("rect", {
|
|
3043
|
+
x: "330.537",
|
|
3044
|
+
y: "503.15",
|
|
3045
|
+
style: {
|
|
3046
|
+
fill: tokens.colorNeutralForeground3,
|
|
3047
|
+
opacity: 0.3
|
|
3048
|
+
},
|
|
3049
|
+
width: "108.842",
|
|
3050
|
+
height: "61.633"
|
|
3051
|
+
}), React__default.createElement("g", null, React__default.createElement("rect", {
|
|
3052
|
+
x: "485.277",
|
|
3053
|
+
y: "509.093",
|
|
3054
|
+
style: {
|
|
3055
|
+
fill: tokens.colorBrandBackground
|
|
3056
|
+
},
|
|
3057
|
+
width: "198.014",
|
|
3058
|
+
height: "2.623"
|
|
3059
|
+
}), React__default.createElement("rect", {
|
|
3060
|
+
x: "485.277",
|
|
3061
|
+
y: "532.656",
|
|
3062
|
+
style: {
|
|
3063
|
+
fill: tokens.colorNeutralForeground3,
|
|
3064
|
+
opacity: 0.3
|
|
3065
|
+
},
|
|
3066
|
+
width: "198.014",
|
|
3067
|
+
height: "2.623"
|
|
3068
|
+
}), React__default.createElement("rect", {
|
|
3069
|
+
x: "485.277",
|
|
3070
|
+
y: "556.218",
|
|
3071
|
+
style: {
|
|
3072
|
+
fill: tokens.colorNeutralForeground3,
|
|
3073
|
+
opacity: 0.3
|
|
3074
|
+
},
|
|
3075
|
+
width: "198.014",
|
|
3076
|
+
height: "2.623"
|
|
3077
|
+
}))), React__default.createElement("g", null, React__default.createElement("g", null, React__default.createElement("rect", {
|
|
3078
|
+
x: "381.691",
|
|
3079
|
+
y: "687.747",
|
|
3080
|
+
style: {
|
|
3081
|
+
fill: tokens.colorNeutralForeground3,
|
|
3082
|
+
opacity: 0.3
|
|
3083
|
+
},
|
|
3084
|
+
width: "22.73",
|
|
3085
|
+
height: "70.417"
|
|
3086
|
+
}), React__default.createElement("rect", {
|
|
3087
|
+
x: "404.421",
|
|
3088
|
+
y: "653.482",
|
|
3089
|
+
style: {
|
|
3090
|
+
fill: tokens.colorBrandBackground
|
|
3091
|
+
},
|
|
3092
|
+
width: "22.73",
|
|
3093
|
+
height: "104.682"
|
|
3094
|
+
})), React__default.createElement("g", null, React__default.createElement("rect", {
|
|
3095
|
+
x: "466.491",
|
|
3096
|
+
y: "641.634",
|
|
3097
|
+
style: {
|
|
3098
|
+
fill: tokens.colorNeutralForeground3,
|
|
3099
|
+
opacity: 0.3
|
|
3100
|
+
},
|
|
3101
|
+
width: "22.73",
|
|
3102
|
+
height: "116.089"
|
|
3103
|
+
}), React__default.createElement("rect", {
|
|
3104
|
+
x: "489.221",
|
|
3105
|
+
y: "714.758",
|
|
3106
|
+
style: {
|
|
3107
|
+
fill: tokens.colorBrandBackground
|
|
3108
|
+
},
|
|
3109
|
+
width: "22.73",
|
|
3110
|
+
height: "42.965"
|
|
3111
|
+
}))))));
|
|
3112
|
+
};
|
|
3113
|
+
|
|
3114
|
+
var NoDashboards = function NoDashboards(props) {
|
|
3115
|
+
var height = props.height;
|
|
3116
|
+
return createElement(Fragment, null, createElement(Stack, {
|
|
3117
|
+
style: {
|
|
3118
|
+
height: height || "100%"
|
|
3119
|
+
},
|
|
3120
|
+
justifyContent: "Center",
|
|
3121
|
+
alignItems: "Center"
|
|
3122
|
+
}, createElement(BusinessReportIcon, {
|
|
3123
|
+
width: 200,
|
|
3124
|
+
height: 200
|
|
3125
|
+
}), createElement(Text, {
|
|
3126
|
+
size: 500,
|
|
3127
|
+
weight: 'semibold'
|
|
3128
|
+
}, "No Dashboards Available")));
|
|
3129
|
+
};
|
|
3130
|
+
|
|
3131
|
+
var useRenderLabelStyles = /*#__PURE__*/makeStyles({
|
|
3132
|
+
labelContainer: /*#__PURE__*/_extends({
|
|
3133
|
+
display: "flex",
|
|
3134
|
+
flexDirection: "row",
|
|
3135
|
+
justifyContent: "flex-start",
|
|
3136
|
+
alignItems: "center"
|
|
3137
|
+
}, /*#__PURE__*/shorthands.gap("6px")),
|
|
3138
|
+
iconStyles: {
|
|
3139
|
+
width: "26px"
|
|
3140
|
+
},
|
|
3141
|
+
item: {
|
|
3142
|
+
paddingLeft: "15px"
|
|
3143
|
+
}
|
|
3144
|
+
});
|
|
3145
|
+
|
|
3146
|
+
var RenderLabel = function RenderLabel(props) {
|
|
3147
|
+
var label = props.label,
|
|
3148
|
+
icon = props.icon,
|
|
3149
|
+
isRequired = props.isRequired;
|
|
3150
|
+
var styles = useRenderLabelStyles();
|
|
3151
|
+
return createElement(Fragment, null, createElement("div", {
|
|
3152
|
+
className: styles.labelContainer
|
|
3153
|
+
}, icon && isValidElement(icon) ? icon : createElement(Icon, {
|
|
3154
|
+
icon: icon,
|
|
3155
|
+
className: styles.iconStyles,
|
|
3156
|
+
width: "20px",
|
|
3157
|
+
height: "20px",
|
|
3158
|
+
color: tokens.colorBrandForeground1
|
|
3159
|
+
}), createElement(Caption1, {
|
|
3160
|
+
style: {
|
|
3161
|
+
color: tokens.colorBrandForeground1
|
|
3162
|
+
}
|
|
3163
|
+
}, label), createElement(Caption1, {
|
|
3164
|
+
style: {
|
|
3165
|
+
color: tokens.colorPaletteRedForeground1
|
|
3166
|
+
}
|
|
3167
|
+
}, isRequired ? " *" : "")));
|
|
3168
|
+
};
|
|
3169
|
+
|
|
3170
|
+
var _templateObject$1, _templateObject2$1, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
3171
|
+
var useStyles = function useStyles() {
|
|
3172
|
+
return {
|
|
3173
|
+
gridContainer: css(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n display: grid;\n gap: 4px;\n padding: 8px;\n justify-content: center;\n "]))),
|
|
3174
|
+
cell: css(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteralLoose(["\n width: 30px;\n height: 30px;\n border: 1px solid ", ";\n background-color: ", ";\n cursor: pointer;\n transition: background-color 150ms ease, transform 150ms ease;\n will-change: background-color, transform;\n "])), tokens.colorNeutralStroke1, tokens.colorNeutralBackground1),
|
|
3175
|
+
hoveredCell: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n transform: scale(1.05);\n "])), tokens.colorNeutralBackground1Hover),
|
|
3176
|
+
selectedCell: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n "])), tokens.colorNeutralBackground1Selected),
|
|
3177
|
+
menuPopover: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n min-width: fit-content;\n "]))),
|
|
3178
|
+
bottomText: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n padding-left: 8px;\n padding-right: 8px;\n "])))
|
|
3179
|
+
};
|
|
3180
|
+
};
|
|
3181
|
+
var SelectZoom = function SelectZoom(props) {
|
|
3182
|
+
var onChange = props.onChange,
|
|
3183
|
+
defaultValues = props.values,
|
|
3184
|
+
maxCols = props.maxCols,
|
|
3185
|
+
maxRows = props.maxRows;
|
|
3186
|
+
var Settings = bundleIcon(Settings20Filled, Settings20Regular);
|
|
3187
|
+
var styles = useStyles();
|
|
3188
|
+
var _React$useState = useState(defaultValues),
|
|
3189
|
+
values = _React$useState[0],
|
|
3190
|
+
setValues = _React$useState[1];
|
|
3191
|
+
var _React$useState2 = useState(null),
|
|
3192
|
+
hovered = _React$useState2[0],
|
|
3193
|
+
setHovered = _React$useState2[1];
|
|
3194
|
+
var _React$useState3 = useState(false),
|
|
3195
|
+
open = _React$useState3[0],
|
|
3196
|
+
setOpen = _React$useState3[1];
|
|
3197
|
+
useEffect(function () {
|
|
3198
|
+
setValues(defaultValues);
|
|
3199
|
+
}, [defaultValues]);
|
|
3200
|
+
var onOpenChange = function onOpenChange(_, data) {
|
|
3201
|
+
setOpen(data.open);
|
|
3202
|
+
setHovered(null);
|
|
3203
|
+
};
|
|
3204
|
+
var handleCellClick = function handleCellClick(row, col) {
|
|
3205
|
+
var newValues = {
|
|
3206
|
+
spanCols: col + 1,
|
|
3207
|
+
spanRows: row + 1
|
|
3208
|
+
};
|
|
3209
|
+
setValues(newValues);
|
|
3210
|
+
onChange == null || onChange(newValues);
|
|
3211
|
+
setOpen(false);
|
|
3212
|
+
};
|
|
3213
|
+
var handleCellHover = function handleCellHover(row, col) {
|
|
3214
|
+
setHovered({
|
|
3215
|
+
spanCols: col + 1,
|
|
3216
|
+
spanRows: row + 1
|
|
3217
|
+
});
|
|
3218
|
+
};
|
|
3219
|
+
var handleMouseLeave = function handleMouseLeave() {
|
|
3220
|
+
setHovered(null);
|
|
3221
|
+
};
|
|
3222
|
+
var renderGridCells = function renderGridCells() {
|
|
3223
|
+
var cells = [];
|
|
3224
|
+
var _loop = function _loop(row) {
|
|
3225
|
+
var _loop2 = function _loop2(col) {
|
|
3226
|
+
var isSelected = row < values.spanRows && col < values.spanCols;
|
|
3227
|
+
var isHovered = hovered && row < hovered.spanRows && col < hovered.spanCols;
|
|
3228
|
+
cells.push(createElement("div", {
|
|
3229
|
+
key: row + "-" + col,
|
|
3230
|
+
className: styles.cell + " " + (isHovered ? styles.hoveredCell : "") + " " + (isSelected ? styles.selectedCell : ""),
|
|
3231
|
+
onMouseEnter: function onMouseEnter() {
|
|
3232
|
+
return handleCellHover(row, col);
|
|
3233
|
+
},
|
|
3234
|
+
onClick: function onClick() {
|
|
3235
|
+
return handleCellClick(row, col);
|
|
3236
|
+
}
|
|
3237
|
+
}));
|
|
3238
|
+
};
|
|
3239
|
+
for (var col = 0; col < maxCols; col++) {
|
|
3240
|
+
_loop2(col);
|
|
3241
|
+
}
|
|
3242
|
+
};
|
|
3243
|
+
for (var row = 0; row < maxRows; row++) {
|
|
3244
|
+
_loop(row);
|
|
3245
|
+
}
|
|
3246
|
+
return cells;
|
|
3247
|
+
};
|
|
3248
|
+
// Compute popover width dynamically
|
|
3249
|
+
var popoverWidth = useMemo(function () {
|
|
3250
|
+
return 30 * maxCols + 4 * (maxCols - 1) + 32;
|
|
3251
|
+
}, [maxCols]); // 30px for each cell, 4px gap, and 32px padding (16 left and right)
|
|
3252
|
+
return createElement(Menu, {
|
|
3253
|
+
open: open,
|
|
3254
|
+
onOpenChange: onOpenChange
|
|
3255
|
+
}, createElement(MenuTrigger, {
|
|
3256
|
+
disableButtonEnhancement: true
|
|
3257
|
+
}, createElement(Tooltip, {
|
|
3258
|
+
content: "Configure",
|
|
3259
|
+
relationship: "label"
|
|
3260
|
+
}, createElement(MenuButton, {
|
|
3261
|
+
icon: createElement(Settings, null),
|
|
3262
|
+
size: "small",
|
|
3263
|
+
appearance: "transparent"
|
|
3264
|
+
}))), createElement(MenuPopover, {
|
|
3265
|
+
style: {
|
|
3266
|
+
width: popoverWidth + "px",
|
|
3267
|
+
minWidth: "120px",
|
|
3268
|
+
padding: 8
|
|
3269
|
+
}
|
|
3270
|
+
}, createElement("div", {
|
|
3271
|
+
style: {
|
|
3272
|
+
display: "flex",
|
|
3273
|
+
flexDirection: "row",
|
|
3274
|
+
alignItems: "center",
|
|
3275
|
+
gap: "6px",
|
|
3276
|
+
width: "100%",
|
|
3277
|
+
boxSizing: "border-box",
|
|
3278
|
+
padding: "8px"
|
|
3279
|
+
}
|
|
3280
|
+
}, createElement(RenderLabel, {
|
|
3281
|
+
label: "Selected Span (" + values.spanCols + " \xD7 " + values.spanRows + ")",
|
|
3282
|
+
icon: createElement(Icon, {
|
|
3283
|
+
icon: "fluent:number-row-20-regular",
|
|
3284
|
+
width: "32",
|
|
3285
|
+
height: "32"
|
|
3286
|
+
})
|
|
3287
|
+
})), createElement("div", {
|
|
3288
|
+
className: styles.gridContainer,
|
|
3289
|
+
style: {
|
|
3290
|
+
gridTemplateColumns: "repeat(" + maxCols + ", 30px)",
|
|
3291
|
+
gridTemplateRows: "repeat(" + maxRows + ", 30px)"
|
|
3292
|
+
},
|
|
3293
|
+
onMouseLeave: handleMouseLeave
|
|
3294
|
+
}, renderGridCells()), createElement(Caption1, {
|
|
3295
|
+
className: styles.bottomText
|
|
3296
|
+
}, "Click to set span")));
|
|
3297
|
+
};
|
|
3298
|
+
|
|
3299
|
+
var useDashboardStyles = function useDashboardStyles() {
|
|
3300
|
+
return {
|
|
3301
|
+
dashboardContainer: css({
|
|
3302
|
+
display: 'grid',
|
|
3303
|
+
padding: '20px',
|
|
3304
|
+
gap: '16px',
|
|
3305
|
+
backgroundColor: tokens.colorNeutralBackground2,
|
|
3306
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(350px, 1fr))',
|
|
3307
|
+
gridAutoRows: '350px',
|
|
3308
|
+
overflowY: 'auto',
|
|
3309
|
+
overflowX: 'hidden',
|
|
3310
|
+
// Scrollbar styles
|
|
3311
|
+
'::-webkit-scrollbar': {
|
|
3312
|
+
width: '5px',
|
|
3313
|
+
height: '5px'
|
|
3314
|
+
},
|
|
3315
|
+
'::-webkit-scrollbar-track': {
|
|
3316
|
+
background: tokens.colorNeutralBackground4,
|
|
3317
|
+
borderRadius: '10px'
|
|
3318
|
+
},
|
|
3319
|
+
'::-webkit-scrollbar-thumb': {
|
|
3320
|
+
background: tokens.colorBrandStroke2Hover,
|
|
3321
|
+
borderRadius: '10px'
|
|
3322
|
+
},
|
|
3323
|
+
'::-webkit-scrollbar-thumb:hover': {
|
|
3324
|
+
background: tokens.colorNeutralStroke2
|
|
3325
|
+
},
|
|
3326
|
+
justifyContent: 'center',
|
|
3327
|
+
gridAutoFlow: 'dense'
|
|
3328
|
+
}),
|
|
3329
|
+
cardBody: css({
|
|
3330
|
+
display: 'flex',
|
|
3331
|
+
flexDirection: 'column',
|
|
3332
|
+
height: '100%',
|
|
3333
|
+
minHeight: '320px'
|
|
3334
|
+
}),
|
|
3335
|
+
chartContainer: css({
|
|
3336
|
+
flex: 1,
|
|
3337
|
+
width: '100%',
|
|
3338
|
+
minHeight: '280px'
|
|
3339
|
+
}),
|
|
3340
|
+
cardDescription: css({
|
|
3341
|
+
color: "" + tokens.colorNeutralForeground2,
|
|
3342
|
+
marginTop: '4px'
|
|
3343
|
+
}),
|
|
3344
|
+
cardWrapper: css({
|
|
3345
|
+
position: 'relative',
|
|
3346
|
+
height: '100%',
|
|
3347
|
+
minHeight: '300px',
|
|
3348
|
+
borderRadius: tokens.borderRadiusMedium,
|
|
3349
|
+
transition: 'all 0.2s ease',
|
|
3350
|
+
'&:hover': {
|
|
3351
|
+
transform: 'translateY(-2px)',
|
|
3352
|
+
boxShadow: "" + tokens.shadow16
|
|
3353
|
+
},
|
|
3354
|
+
'&:active': {
|
|
3355
|
+
transform: 'translateY(0)',
|
|
3356
|
+
boxShadow: "" + tokens.shadow8
|
|
3357
|
+
}
|
|
3358
|
+
})
|
|
3359
|
+
};
|
|
3360
|
+
};
|
|
3361
|
+
|
|
3362
|
+
var MINIMUM_DASHBOARD_WIDTH = 600;
|
|
3363
|
+
var MAX_ROWS = 4;
|
|
3364
|
+
var Dashboard = function Dashboard(_ref) {
|
|
3365
|
+
var cardCharts = _ref.cardCharts,
|
|
3366
|
+
theme = _ref.theme,
|
|
3367
|
+
containerWidth = _ref.containerWidth,
|
|
3368
|
+
_ref$containerHeight = _ref.containerHeight,
|
|
3369
|
+
containerHeight = _ref$containerHeight === void 0 ? '100%' : _ref$containerHeight,
|
|
3370
|
+
_ref$maxSpanRows = _ref.maxSpanRows,
|
|
3371
|
+
maxSpanRows = _ref$maxSpanRows === void 0 ? MAX_ROWS : _ref$maxSpanRows;
|
|
3372
|
+
var styles = useDashboardStyles();
|
|
3373
|
+
var _useGraphUtils = useGraphUtils(theme),
|
|
3374
|
+
getChartComponent = _useGraphUtils.getChartComponent;
|
|
3375
|
+
var _useState = useState([]),
|
|
3376
|
+
CardChartContainer = _useState[0],
|
|
3377
|
+
setCardChartContainer = _useState[1];
|
|
3378
|
+
var _useState2 = useState({}),
|
|
3379
|
+
sizes = _useState2[0],
|
|
3380
|
+
setSizes = _useState2[1];
|
|
3381
|
+
var dragItem = useRef(null);
|
|
3382
|
+
var dragOverItem = useRef(null);
|
|
3383
|
+
var containerRef = useRef(null);
|
|
3384
|
+
React__default.useEffect(function () {
|
|
3385
|
+
setCardChartContainer(cardCharts);
|
|
3386
|
+
setSizes(function () {
|
|
3387
|
+
var initialSizes = {};
|
|
3388
|
+
cardCharts.forEach(function (c) {
|
|
3389
|
+
var _c$defaultSpan$spanCo, _c$defaultSpan, _c$defaultSpan$spanRo, _c$defaultSpan2;
|
|
3390
|
+
initialSizes[c.id] = {
|
|
3391
|
+
spanCols: (_c$defaultSpan$spanCo = (_c$defaultSpan = c.defaultSpan) == null ? void 0 : _c$defaultSpan.spanCols) != null ? _c$defaultSpan$spanCo : 1,
|
|
3392
|
+
spanRows: (_c$defaultSpan$spanRo = (_c$defaultSpan2 = c.defaultSpan) == null ? void 0 : _c$defaultSpan2.spanRows) != null ? _c$defaultSpan$spanRo : 1
|
|
3393
|
+
};
|
|
3394
|
+
});
|
|
3395
|
+
return initialSizes;
|
|
3396
|
+
});
|
|
3397
|
+
}, [cardCharts]);
|
|
3398
|
+
useEffect(function () {
|
|
3399
|
+
if (containerWidth <= MINIMUM_DASHBOARD_WIDTH) {
|
|
3400
|
+
setSizes(function () {
|
|
3401
|
+
var reset = {};
|
|
3402
|
+
CardChartContainer.forEach(function (c) {
|
|
3403
|
+
reset[c.id] = {
|
|
3404
|
+
spanCols: 1,
|
|
3405
|
+
spanRows: 1
|
|
3406
|
+
};
|
|
3407
|
+
});
|
|
3408
|
+
return reset;
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3411
|
+
}, [containerWidth, CardChartContainer]);
|
|
3412
|
+
var showZoom = useMemo(function () {
|
|
3413
|
+
return containerWidth > MINIMUM_DASHBOARD_WIDTH;
|
|
3414
|
+
}, [containerWidth]);
|
|
3415
|
+
var _useMemo = useMemo(function () {
|
|
3416
|
+
return {
|
|
3417
|
+
minCardWidth: 350,
|
|
3418
|
+
gridGap: 16,
|
|
3419
|
+
containerPadding: 20
|
|
3420
|
+
};
|
|
3421
|
+
}, []),
|
|
3422
|
+
minCardWidth = _useMemo.minCardWidth,
|
|
3423
|
+
gridGap = _useMemo.gridGap,
|
|
3424
|
+
containerPadding = _useMemo.containerPadding;
|
|
3425
|
+
var innerWidth = containerWidth - containerPadding * 2;
|
|
3426
|
+
var columns = useMemo(function () {
|
|
3427
|
+
return Math.floor((innerWidth + gridGap) / (minCardWidth + gridGap));
|
|
3428
|
+
}, [innerWidth, gridGap, minCardWidth]);
|
|
3429
|
+
var maxZoom = Math.max(columns, 1);
|
|
3430
|
+
var handleSort = useCallback(function () {
|
|
3431
|
+
if (dragItem.current !== null && dragOverItem.current !== null && dragItem.current !== dragOverItem.current) {
|
|
3432
|
+
var copy = [].concat(CardChartContainer);
|
|
3433
|
+
var _copy$splice = copy.splice(dragItem.current, 1),
|
|
3434
|
+
moved = _copy$splice[0];
|
|
3435
|
+
copy.splice(dragOverItem.current, 0, moved);
|
|
3436
|
+
setCardChartContainer(copy);
|
|
3437
|
+
}
|
|
3438
|
+
dragItem.current = null;
|
|
3439
|
+
dragOverItem.current = null;
|
|
3440
|
+
}, [CardChartContainer]);
|
|
3441
|
+
var handleZoomSelect = useCallback(function (id, span) {
|
|
3442
|
+
setSizes(function (prev) {
|
|
3443
|
+
var _extends2;
|
|
3444
|
+
return _extends({}, prev, (_extends2 = {}, _extends2[id] = {
|
|
3445
|
+
spanCols: Math.min(Math.max(span.spanCols, 1), maxZoom),
|
|
3446
|
+
spanRows: Math.min(Math.max(span.spanRows, 1), maxSpanRows)
|
|
3447
|
+
}, _extends2));
|
|
3448
|
+
});
|
|
3449
|
+
}, [maxZoom, maxSpanRows]);
|
|
3450
|
+
var defaultColsAndRowSpanBasedOnNumberColumns = useMemo(function () {
|
|
3451
|
+
return CardChartContainer.reduce(function (acc, card) {
|
|
3452
|
+
var _card$defaultSpan$spa, _card$defaultSpan, _card$defaultSpan$spa2, _card$defaultSpan2;
|
|
3453
|
+
acc[card.id] = {
|
|
3454
|
+
spanCols: Math.min((_card$defaultSpan$spa = (_card$defaultSpan = card.defaultSpan) == null ? void 0 : _card$defaultSpan.spanCols) != null ? _card$defaultSpan$spa : 1, columns),
|
|
3455
|
+
spanRows: (_card$defaultSpan$spa2 = (_card$defaultSpan2 = card.defaultSpan) == null ? void 0 : _card$defaultSpan2.spanRows) != null ? _card$defaultSpan$spa2 : 1
|
|
3456
|
+
};
|
|
3457
|
+
return acc;
|
|
3458
|
+
}, {});
|
|
3459
|
+
}, [CardChartContainer, columns]);
|
|
3460
|
+
var renderCards = useMemo(function () {
|
|
3461
|
+
return CardChartContainer.map(function (cardContainer, idx) {
|
|
3462
|
+
var _sizes$cardContainer$, _defaultColsAndRowSpa, _sizes$cardContainer$2, _defaultColsAndRowSpa2;
|
|
3463
|
+
return React__default.createElement("div", {
|
|
3464
|
+
className: styles.cardWrapper,
|
|
3465
|
+
key: cardContainer.id,
|
|
3466
|
+
draggable: true,
|
|
3467
|
+
onDragStart: function onDragStart() {
|
|
3468
|
+
return dragItem.current = idx;
|
|
3469
|
+
},
|
|
3470
|
+
onDragEnter: function onDragEnter() {
|
|
3471
|
+
return dragOverItem.current = idx;
|
|
3472
|
+
},
|
|
3473
|
+
onDragOver: function onDragOver(e) {
|
|
3474
|
+
return e.preventDefault();
|
|
3475
|
+
},
|
|
3476
|
+
onDragEnd: handleSort,
|
|
3477
|
+
style: {
|
|
3478
|
+
gridColumnEnd: (_sizes$cardContainer$ = sizes[cardContainer.id]) != null && _sizes$cardContainer$.spanCols ? "span " + sizes[cardContainer.id].spanCols : "span " + (((_defaultColsAndRowSpa = defaultColsAndRowSpanBasedOnNumberColumns[cardContainer.id]) == null ? void 0 : _defaultColsAndRowSpa.spanCols) || 1),
|
|
3479
|
+
gridRowEnd: (_sizes$cardContainer$2 = sizes[cardContainer.id]) != null && _sizes$cardContainer$2.spanRows ? "span " + sizes[cardContainer.id].spanRows : "span " + (((_defaultColsAndRowSpa2 = defaultColsAndRowSpanBasedOnNumberColumns[cardContainer.id]) == null ? void 0 : _defaultColsAndRowSpa2.spanRows) || 1)
|
|
3480
|
+
}
|
|
3481
|
+
}, React__default.createElement(Card, {
|
|
3482
|
+
className: styles.cardBody
|
|
3483
|
+
}, React__default.createElement(CardHeader, {
|
|
3484
|
+
header: React__default.createElement(Text, {
|
|
3485
|
+
weight: "semibold",
|
|
3486
|
+
size: 400
|
|
3487
|
+
}, cardContainer.cardTitle),
|
|
3488
|
+
action: showZoom ? React__default.createElement(SelectZoom, {
|
|
3489
|
+
values: sizes[cardContainer.id] || defaultColsAndRowSpanBasedOnNumberColumns[cardContainer.id] || {
|
|
3490
|
+
spanCols: 1,
|
|
3491
|
+
spanRows: 1
|
|
3492
|
+
},
|
|
3493
|
+
maxCols: maxZoom,
|
|
3494
|
+
maxRows: maxSpanRows,
|
|
3495
|
+
IsOpen: false,
|
|
3496
|
+
onChange: function onChange(v) {
|
|
3497
|
+
return handleZoomSelect(cardContainer.id, v);
|
|
3498
|
+
}
|
|
3499
|
+
}) : undefined
|
|
3500
|
+
}), React__default.createElement("div", {
|
|
3501
|
+
className: styles.chartContainer,
|
|
3502
|
+
style: {
|
|
3503
|
+
height: containerHeight
|
|
3504
|
+
}
|
|
3505
|
+
}, theme && theme.fontSizeBase100 && getChartComponent(cardContainer.chart, theme))));
|
|
3506
|
+
});
|
|
3507
|
+
}, [CardChartContainer, handleSort, sizes, styles.cardBody, styles.chartContainer, showZoom, maxZoom, getChartComponent, handleZoomSelect, theme]);
|
|
3508
|
+
if (CardChartContainer.length === 0) {
|
|
3509
|
+
return React__default.createElement(NoDashboards, null);
|
|
3510
|
+
}
|
|
3511
|
+
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
3512
|
+
ref: containerRef,
|
|
3513
|
+
className: styles.dashboardContainer
|
|
3514
|
+
}, renderCards));
|
|
3515
|
+
};
|
|
3516
|
+
|
|
3517
|
+
export { Dashboard, createAxisLabelFormatter, createFluentTooltip, getFluentPalette, lightenColor, useGraphUtils };
|
|
2907
3518
|
//# sourceMappingURL=fluentui-react-charts.esm.js.map
|