@iotready/nextjs-components-library 1.0.0-preview1 → 1.0.0-preview3

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.
@@ -2,7 +2,7 @@ import { UserType } from '../../types/user';
2
2
  import { Theme } from "@emotion/react";
3
3
  export default function UserMenuAccount({ userInfo, handleClick, handleSignOut, accountRoute, theme }: {
4
4
  userInfo: UserType;
5
- handleClick: () => Promise<void>;
5
+ handleClick: () => void;
6
6
  handleSignOut: () => Promise<void>;
7
7
  accountRoute?: string;
8
8
  theme: Theme;
@@ -18,10 +18,12 @@ import 'moment/locale/it';
18
18
  // import 'moment/locale/en-gb'; // TODO set locale based on browser
19
19
  import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
20
20
  import { ThemeProvider } from '@mui/material/styles';
21
+ import TimelineIcon from '@mui/icons-material/Timeline';
22
+ import MuiTooltip from '@mui/material/Tooltip';
21
23
  const lineOptions = {
22
24
  parsing: false,
23
25
  normalized: true,
24
- spanGaps: true, // enable for all datasets
26
+ spanGaps: false, // enable for all datasets
25
27
  // showLine: false, // disable for all datasets
26
28
  animation: false,
27
29
  responsive: true,
@@ -191,6 +193,7 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
191
193
  const [loadingButton, setLoadingButton] = useState(false);
192
194
  const csvLinkRef = useRef(null);
193
195
  const [csvData, setCsvData] = useState('');
196
+ const [spanGapsOption, setSpanGapsOption] = useState(false);
194
197
  const [options, setOptions] = useState({
195
198
  ...lineOptions,
196
199
  plugins: {
@@ -229,6 +232,13 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
229
232
  setDataMeasures([...[]]);
230
233
  setCsvData("");
231
234
  };
235
+ const handleSpanGaps = (spanG) => {
236
+ setOptions({
237
+ ...options,
238
+ spanGaps: spanG,
239
+ });
240
+ setSpanGapsOption(spanG);
241
+ };
232
242
  const handleChange = (event, newPeriod) => {
233
243
  setZoomed(false);
234
244
  setDatePickerUsed(false);
@@ -280,7 +290,7 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
280
290
  pointRadius: 1,
281
291
  pointHoverRadius: 5,
282
292
  pointHoverBackgroundColor: 'rgba(52, 125, 236, 0.5)',
283
- spanGaps: false,
293
+ // spanGaps: false,
284
294
  fill: false
285
295
  };
286
296
  });
@@ -397,16 +407,16 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
397
407
  // format="DD/MM/YY hh:mm A"
398
408
  onChange: (newValue) => {
399
409
  setTimeStart((moment(newValue).unix()));
400
- }, maxDate: moment(timeEnd * 1000), slotProps: {
410
+ }, maxDateTime: moment(timeEnd * 1000), slotProps: {
401
411
  textField: { size: 'small', sx: { width: { sm: 210 } } }
402
412
  } }), " \u00A0\u00A0 ", _jsx(Box, { children: "\u2013" }), " \u00A0\u00A0", _jsx(DateTimePicker, { value: moment(timeEnd * 1000),
403
413
  // format="DD/MM/YY hh:mm A"
404
414
  onChange: (newValue) => {
405
415
  setTimeEnd((moment(newValue).unix()));
406
- }, minDate: moment(timeStart * 1000), slotProps: {
416
+ }, minDateTime: moment(timeStart * 1000), slotProps: {
407
417
  textField: { size: 'small', sx: { width: { sm: 210 } } }
408
418
  } })] }) });
409
- return (_jsxs(ThemeProvider, { theme: theme, children: [enableDatePicker && _jsx(Box, { sx: { display: { xs: 'flex', lg: 'none', justifyContent: 'flex-end' }, mb: 2 }, children: datePicker }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs(Box, { children: [enableExportData && (_jsxs(_Fragment, { children: [_jsxs(LoadingButton, { sx: { minWidth: '40px !important', mr: 1, px: 1 }, loading: loadingButton, type: "submit", variant: "text", color: "primary", onClick: handleExportData, disabled: !dataMeasures || !dataMeasures.length, size: 'small', children: [_jsx(LoginIcon, { fontSize: 'small', style: { transform: "rotate(90deg)" } }), _jsx(Box, { sx: { display: { xs: 'none', xl: 'block' }, ml: { md: 1 } }, children: "Export" })] }), _jsx(CSVLink
419
+ return (_jsxs(ThemeProvider, { theme: theme, children: [enableDatePicker && _jsx(Box, { sx: { display: { xs: 'flex', lg: 'none', justifyContent: 'flex-end' }, mb: 2 }, children: datePicker }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center' }, children: [!enableExportData && measures && measures.length === 1 ? _jsx(Typography, { variant: 'body1', sx: { mr: 2 }, children: measures[0].name }) : '', enableExportData && (_jsxs(_Fragment, { children: [_jsxs(LoadingButton, { sx: { minWidth: '40px !important', mr: 1, px: 1 }, loading: loadingButton, type: "submit", variant: "text", color: "primary", onClick: handleExportData, disabled: !dataMeasures || !dataMeasures.length, size: 'small', children: [_jsx(LoginIcon, { fontSize: 'small', style: { transform: "rotate(90deg)" } }), _jsx(Box, { sx: { display: { xs: 'none', xl: 'block' }, ml: { md: 1 } }, children: "Export" })] }), _jsx(CSVLink
410
420
  //@ts-ignore
411
421
  , {
412
422
  //@ts-ignore
@@ -431,7 +441,7 @@ const TrendChart = ({ deviceId, measures, enableExportData, enableDatePicker, ha
431
441
  }
432
442
  }, children: [_jsx(ZoomOut, { fontSize: 'small' }), _jsx(Box, { sx: { display: { xs: 'none', xl: 'block' }, ml: { md: 1 } }, children: "Reset" })] }))] }), _jsxs(Box, { sx: { display: 'flex', justifyContent: 'flex-end' }, children: [enableDatePicker && _jsx(Box, { sx: { display: { xs: 'none', lg: 'flex' } }, children: datePicker }), _jsxs(ToggleButtonGroup, { color: "primary", value: chartPeriod, exclusive: true, onChange: handleChange, size: "small",
433
443
  // sx={{ boxShadow: 1 }}
434
- disabled: chartLoading, children: [_jsx(ToggleButton, { value: "1D", sx: { px: 1 }, children: "1d" }), _jsx(ToggleButton, { value: "1W", sx: { px: 1 }, children: "1w" }), _jsx(ToggleButton, { value: "1M", sx: { px: 1 }, children: "1M" }), _jsx(ToggleButton, { value: "3M", sx: { px: 1 }, children: "3M" }), _jsx(ToggleButton, { value: "6M", sx: { px: 1 }, children: "6M" }), _jsx(ToggleButton, { value: "1Y", sx: { px: 1 }, children: "1Y" }), _jsx(ToggleButton, { value: "ALL", sx: { px: 1 }, children: "ALL" })] })] })] }), _jsx(Box, { component: 'div', className: "chart-container", sx: { height: { xs: enableDatePicker && props.height ? `calc(${props.height} - 50px)` : props.height, lg: props.height }, minHeight: 300, mt: 2 }, children: chartJsLoaded && !chartLoading && typeof window !== 'undefined' ?
444
+ disabled: chartLoading, children: [_jsx(ToggleButton, { value: "1D", sx: { px: 1 }, children: "1d" }), _jsx(ToggleButton, { value: "1W", sx: { px: 1 }, children: "1w" }), _jsx(ToggleButton, { value: "1M", sx: { px: 1 }, children: "1M" }), _jsx(ToggleButton, { value: "3M", sx: { px: 1 }, children: "3M" }), _jsx(ToggleButton, { value: "6M", sx: { px: 1 }, children: "6M" }), _jsx(ToggleButton, { value: "1Y", sx: { px: 1 }, children: "1Y" }), _jsx(ToggleButton, { value: "ALL", sx: { px: 1 }, children: "ALL" })] }), _jsx(MuiTooltip, { placement: "top", arrow: true, title: "Connect point values", children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: spanGapsOption, disabled: chartLoading, onChange: () => handleSpanGaps(!spanGapsOption), sx: { ml: 2 }, children: _jsx(TimelineIcon, {}) }) })] })] }), _jsx(Box, { component: 'div', className: "chart-container", sx: { height: { xs: enableDatePicker && props.height ? `calc(${props.height} - 50px)` : props.height, lg: props.height }, minHeight: 300, mt: 2 }, children: chartJsLoaded && !chartLoading && typeof window !== 'undefined' ?
435
445
  _jsx(_Fragment, { children: dataMeasures && dataMeasures[0]?.data?.length ?
436
446
  (_jsx(Line, { options: options, data: {
437
447
  datasets: dataMeasures || [{ data: [] }]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iotready/nextjs-components-library",
3
- "version": "1.0.0-preview1",
3
+ "version": "1.0.0-preview3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build": "rm -rf dist && tsc --project tsconfig.build.json && cp package.json dist/",