@digital-ai/dot-components 2.7.0 → 2.7.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/CHANGE_LOG.md +31 -1
- package/index.esm.js +151 -36
- package/index.umd.js +179 -45
- package/lib/components/button/Button.d.ts +2 -1
- package/lib/components/click-away-listener/ClickAwayListener.d.ts +10 -0
- package/lib/components/click-away-listener/ClickAwayListener.stories.d.ts +5 -0
- package/lib/components/click-away-listener/index.d.ts +2 -0
- package/lib/components/date-picker/DatePicker.d.ts +11 -1
- package/lib/components/date-picker/DatePicker.stories.d.ts +11 -1
- package/lib/components/date-picker/DatePicker.stories.styles.d.ts +2 -0
- package/lib/components/helpers.d.ts +3 -1
- package/lib/components/index.d.ts +2 -0
- package/lib/components/time-picker/TimePicker.d.ts +3 -1
- package/lib/components/time-picker/TimePicker.stories.d.ts +3 -1
- package/lib/components/time-picker/utils/helpers.d.ts +5 -0
- package/lib/testing-utils/index.d.ts +2 -1
- package/lib/testing-utils/scroll-into-view-mock.d.ts +3 -1
- package/package.json +1 -2
package/CHANGE_LOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.7.2](https://www.npmjs.com/package/@digital-ai/dot-components) (04/24/2023)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/2.7.1...2.7.2)
|
|
6
|
+
|
|
7
|
+
**Features:**
|
|
8
|
+
|
|
9
|
+
- S-92086: `DotDatePicker` improvements [\#1461](https://github.com/digital-ai/dot-components/pull/1461) ([dmiletic85](https://github.com/dmiletic85))
|
|
10
|
+
|
|
11
|
+
**Fixed bugs:**
|
|
12
|
+
|
|
13
|
+
- Issue-1449: Update status pills to have generally lighter backgrounds [\#1456](https://github.com/digital-ai/dot-components/pull/1456) ([jmcnally](https://github.com/jmcnally))
|
|
14
|
+
|
|
15
|
+
## [2.7.1](https://www.npmjs.com/package/@digital-ai/dot-components) (04/20/2023)
|
|
16
|
+
|
|
17
|
+
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/2.7.0...2.7.1)
|
|
18
|
+
|
|
19
|
+
**Features:**
|
|
20
|
+
|
|
21
|
+
- S-91943: `DotDatePicker` - add `minDate` and `maxDate` props [\#1450](https://github.com/digital-ai/dot-components/pull/1450) ([dmiletic85](https://github.com/dmiletic85))
|
|
22
|
+
|
|
23
|
+
**Fixed bugs:**
|
|
24
|
+
|
|
25
|
+
- `DotTimePicker`, `DotDatePicker`: fix issues with controlled and uncontrolled states [\#1454](https://github.com/digital-ai/dot-components/pull/1454) ([dmiletic85](https://github.com/dmiletic85))
|
|
26
|
+
- D-24807: `Demo app` - fix error when starting demo application [\#1451](https://github.com/digital-ai/dot-components/pull/1451) ([dmiletic85](https://github.com/dmiletic85))
|
|
27
|
+
|
|
28
|
+
**Misc:**
|
|
29
|
+
|
|
30
|
+
- S-91314: Remove use of deprecated `StylesProvider` [\#1457](https://github.com/digital-ai/dot-components/pull/1457) ([CWSites](https://github.com/CWSites))
|
|
31
|
+
- S-91975: `TimePicker` - Improve keyboard access [\#1455](https://github.com/digital-ai/dot-components/pull/1455) ([dmiletic85](https://github.com/dmiletic85))
|
|
32
|
+
|
|
3
33
|
## [2.7.0](https://www.npmjs.com/package/@digital-ai/dot-components) (04/14/2023)
|
|
4
34
|
|
|
5
35
|
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/2.6.1...2.7.0)
|
|
@@ -545,6 +575,7 @@
|
|
|
545
575
|
- D-20736: Fix text alignment for small DotAvatar [\#1116](https://github.com/digital-ai/dot-components/pull/1116) ([selsemore](https://github.com/selsemore))
|
|
546
576
|
- D-20719: `DotTable`: Checkbox column takes up to much space in a multi-select table [\#1112](https://github.com/digital-ai/dot-components/pull/1112) ([dmiletic85](https://github.com/dmiletic85))
|
|
547
577
|
- D-20660: `DotNavigationRail`: Should be able to update the selected rail [\#1106](https://github.com/digital-ai/dot-components/pull/1106) ([dmiletic85](https://github.com/dmiletic85))
|
|
578
|
+
- D-20511: remove extra period [\#1094](https://github.com/digital-ai/dot-components/pull/1094) ([CWSites](https://github.com/CWSites))
|
|
548
579
|
|
|
549
580
|
## [1.14.0](https://www.npmjs.com/package/@digital-ai/dot-components) (04/01/2022)
|
|
550
581
|
|
|
@@ -588,7 +619,6 @@
|
|
|
588
619
|
|
|
589
620
|
**Fixed bugs:**
|
|
590
621
|
|
|
591
|
-
- D-20511: remove extra period [\#1094](https://github.com/digital-ai/dot-components/pull/1094) ([CWSites](https://github.com/CWSites))
|
|
592
622
|
- D-20463: Change the DotDrawer stories to make drawers not open initially [\#1086](https://github.com/digital-ai/dot-components/pull/1086) ([selsemore](https://github.com/selsemore))
|
|
593
623
|
- D-20418: `DotTable`: Strange scrolling behavior with action menu [\#1082](https://github.com/digital-ai/dot-components/pull/1082) ([dmiletic85](https://github.com/dmiletic85))
|
|
594
624
|
- D-20426: `DotConfirmation `: `title` and `message` prop are not applying correct font family [\#1081](https://github.com/digital-ai/dot-components/pull/1081) ([dmiletic85](https://github.com/dmiletic85))
|
package/index.esm.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useState, useEffect, useRef, useMemo, useContext, createContext, forwardRef, Fragment, useCallback, createElement, useLayoutEffect } from 'react';
|
|
4
|
-
import { Tooltip, Icon, Typography, Accordion, AccordionSummary, AccordionDetails, AccordionActions, InputAdornment, InputLabel, TextField, Toolbar, Alert, Fade, Avatar, Button, darken, Link, List, ListItem, CircularProgress, Popper, MenuList, MenuItem, Paper, ClickAwayListener, Drawer, IconButton, ListItemIcon, Collapse, ListSubheader, Divider, ListItemText, Badge, useMediaQuery, Autocomplete, Chip, AvatarGroup, Breadcrumbs, ToggleButtonGroup, ToggleButton, Card, CardContent, CardHeader, FormControlLabel, Checkbox, FormControl, FormGroup, FormLabel, FormHelperText, Dialog, DialogContent, DialogActions, useTheme as useTheme$1, RadioGroup, Radio, Switch, Skeleton, Snackbar, ButtonGroup, Stepper, Step, StepLabel, StepContent, TablePagination, TableContainer, TableCell, TableRow, TableBody, TableSortLabel, TableHead, Table, Tabs, Tab, LinearProgress } from '@mui/material';
|
|
4
|
+
import { Tooltip, Icon, Typography, Accordion, AccordionSummary, AccordionDetails, AccordionActions, InputAdornment, InputLabel, TextField, Toolbar, Alert, Fade, StyledEngineProvider, Avatar, Button, darken, Link, List, ListItem, CircularProgress, Popper, MenuList, MenuItem, Paper, ClickAwayListener, Drawer, IconButton, ListItemIcon, Collapse, ListSubheader, Divider, ListItemText, Badge, useMediaQuery, Autocomplete, Chip, AvatarGroup, Breadcrumbs, ToggleButtonGroup, ToggleButton, Card, CardContent, CardHeader, FormControlLabel, Checkbox, FormControl, FormGroup, FormLabel, FormHelperText, Dialog, DialogContent, DialogActions, useTheme as useTheme$1, RadioGroup, Radio, Switch, Skeleton, Snackbar, ButtonGroup, Stepper, Step, StepLabel, StepContent, TablePagination, TableContainer, TableCell, TableRow, TableBody, TableSortLabel, TableHead, Table, Tabs, Tab, LinearProgress } from '@mui/material';
|
|
5
5
|
import '@digital-ai/dot-icons';
|
|
6
6
|
import styled, { css, createGlobalStyle, ThemeProvider as ThemeProvider$1, keyframes } from 'styled-components';
|
|
7
7
|
import { createTheme, ThemeProvider, alpha, useTheme } from '@mui/material/styles';
|
|
8
|
-
import { StylesProvider } from '@mui/styles';
|
|
9
8
|
import jwt_decode from 'jwt-decode';
|
|
10
9
|
import { useDropzone } from 'react-dropzone';
|
|
11
10
|
import GridLayout, { WidthProvider } from 'react-grid-layout';
|
|
@@ -873,7 +872,7 @@ function DotThemeProvider({
|
|
|
873
872
|
theme = lightTheme
|
|
874
873
|
}) {
|
|
875
874
|
const userTheme = typeof theme === 'string' && theme === 'dark' ? darkTheme : lightTheme;
|
|
876
|
-
return jsx(
|
|
875
|
+
return jsx(StyledEngineProvider, Object.assign({
|
|
877
876
|
injectFirst: true
|
|
878
877
|
}, {
|
|
879
878
|
children: jsx(ThemeProvider, Object.assign({
|
|
@@ -914,6 +913,8 @@ const renderNodeOrTypography = (content, typographyVariant = 'body1') => {
|
|
|
914
913
|
children: content
|
|
915
914
|
}), void 0) : content;
|
|
916
915
|
};
|
|
916
|
+
const checkIfArrowUpPressed = event => event.key === 'ArrowUp';
|
|
917
|
+
const checkIfArrowDownPressed = event => event.key === 'ArrowDown';
|
|
917
918
|
|
|
918
919
|
const DotAlertBanner = ({
|
|
919
920
|
action,
|
|
@@ -1728,6 +1729,7 @@ const DotButton = /*#__PURE__*/forwardRef(({
|
|
|
1728
1729
|
fullWidth: _fullWidth = false,
|
|
1729
1730
|
isSubmit: _isSubmit = false,
|
|
1730
1731
|
onClick,
|
|
1732
|
+
onKeyDown,
|
|
1731
1733
|
size: _size = 'medium',
|
|
1732
1734
|
startIcon,
|
|
1733
1735
|
tabIndex,
|
|
@@ -1771,6 +1773,7 @@ const DotButton = /*#__PURE__*/forwardRef(({
|
|
|
1771
1773
|
endIcon: endIcon,
|
|
1772
1774
|
fullWidth: _fullWidth,
|
|
1773
1775
|
onClick: event => onClick && onClick(event),
|
|
1776
|
+
onKeyDown: onKeyDown,
|
|
1774
1777
|
ref: ref,
|
|
1775
1778
|
size: _size,
|
|
1776
1779
|
startIcon: startIcon,
|
|
@@ -7321,7 +7324,7 @@ const StyledPill = styled(Chip).withConfig({
|
|
|
7321
7324
|
componentId: "l7oxi2-0"
|
|
7322
7325
|
})(["", ""], ({
|
|
7323
7326
|
theme
|
|
7324
|
-
}) => css(["&.", "{background-color:", ";color:", ";border-color:", ";&.error{background-color:", ";color:", ";}&.success{background-color:", ";color:", ";}&.warning{background-color:", ";color:", ";}&.in-progress{background-color:", ";color:", ";}"], rootClassName$n, ({
|
|
7327
|
+
}) => css(["&.", "{background-color:", ";color:", ";border-color:", ";&.error{background-color:", ";border-color:", ";.dot-icon{color:", ";}color:", ";}&.success{background-color:", ";border-color:", ";.dot-icon{color:", ";}color:", ";}&.warning{background-color:", ";border-color:", ";.dot-icon{color:", ";}color:", ";}&.in-progress{background-color:", ";border-color:", ";.dot-icon{color:", ";}color:", ";}"], rootClassName$n, ({
|
|
7325
7328
|
backgroundcolor
|
|
7326
7329
|
}) => {
|
|
7327
7330
|
return backgroundcolor || theme.palette.grey[200];
|
|
@@ -7333,7 +7336,7 @@ const StyledPill = styled(Chip).withConfig({
|
|
|
7333
7336
|
bordercolor
|
|
7334
7337
|
}) => {
|
|
7335
7338
|
return bordercolor ? bordercolor : theme.palette.layer.n700;
|
|
7336
|
-
}, theme.palette.error[
|
|
7339
|
+
}, theme.palette.error[100], theme.palette.error.main, theme.palette.error.main, theme.palette.layer.n700, theme.palette.success[100], theme.palette.success.main, theme.palette.success.main, theme.palette.layer.n700, theme.palette.warning[100], theme.palette.warning.main, theme.palette.warning.main, theme.palette.layer.n700, theme.palette.primary[100], theme.palette.primary.main, theme.palette.primary.main, theme.palette.layer.n700));
|
|
7337
7340
|
|
|
7338
7341
|
const DotPill = ({
|
|
7339
7342
|
ariaLabel,
|
|
@@ -9479,13 +9482,16 @@ const DotDatePicker = ({
|
|
|
9479
9482
|
className,
|
|
9480
9483
|
closeOnSelect: _closeOnSelect = true,
|
|
9481
9484
|
'data-testid': dataTestId,
|
|
9485
|
+
defaultValue,
|
|
9482
9486
|
disableOpenPicker,
|
|
9483
9487
|
disablePast,
|
|
9488
|
+
disablePortal: _disablePortal = false,
|
|
9484
9489
|
disabled,
|
|
9485
9490
|
displayWeekNumber,
|
|
9486
9491
|
displayClearButton: _displayClearButton = true,
|
|
9487
9492
|
error,
|
|
9488
9493
|
fixedWeekNumber,
|
|
9494
|
+
focusInputOnPopperOpened,
|
|
9489
9495
|
format,
|
|
9490
9496
|
fullWidth: _fullWidth = false,
|
|
9491
9497
|
helperText,
|
|
@@ -9493,6 +9499,8 @@ const DotDatePicker = ({
|
|
|
9493
9499
|
inputName,
|
|
9494
9500
|
label,
|
|
9495
9501
|
locale,
|
|
9502
|
+
maxDate,
|
|
9503
|
+
minDate,
|
|
9496
9504
|
onAccept,
|
|
9497
9505
|
onBlur,
|
|
9498
9506
|
onChange,
|
|
@@ -9506,8 +9514,31 @@ const DotDatePicker = ({
|
|
|
9506
9514
|
showDaysOutsideCurrentMonth,
|
|
9507
9515
|
value
|
|
9508
9516
|
}) => {
|
|
9509
|
-
const
|
|
9517
|
+
const dateFormat = format || 'YYYY-MM-DD';
|
|
9518
|
+
const hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
9519
|
+
const hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
9520
|
+
const isInputReadOnly = _readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
9521
|
+
const inputRef = useRef(null);
|
|
9522
|
+
const rootClasses = useStylesWithRootClass(rootClassName$1, className, isInputReadOnly ? 'read-only' : '');
|
|
9510
9523
|
const containerClasses = useStylesWithRootClass(containerClassName$1, _fullWidth ? 'full-width' : '', className);
|
|
9524
|
+
const focusInput = ref => {
|
|
9525
|
+
setTimeout(() => {
|
|
9526
|
+
ref.current.focus();
|
|
9527
|
+
}, 0);
|
|
9528
|
+
};
|
|
9529
|
+
useEffect(() => {
|
|
9530
|
+
if (focusInputOnPopperOpened && open && inputRef.current) {
|
|
9531
|
+
focusInput(inputRef);
|
|
9532
|
+
}
|
|
9533
|
+
}, [open, focusInputOnPopperOpened]);
|
|
9534
|
+
useEffect(() => {
|
|
9535
|
+
if (hasValueWithoutChangeHandler) {
|
|
9536
|
+
console.warn('Warning: You provided a `value` prop without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.');
|
|
9537
|
+
}
|
|
9538
|
+
if (hasBothValueAndDefaultValue) {
|
|
9539
|
+
console.warn('Warning: A component contains both `value` and `defaultValue` props. Component must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props.');
|
|
9540
|
+
}
|
|
9541
|
+
}, []);
|
|
9511
9542
|
useEffect(() => {
|
|
9512
9543
|
if (!locale) return;
|
|
9513
9544
|
const userLocaleName = dayjs.locale();
|
|
@@ -9515,7 +9546,6 @@ const DotDatePicker = ({
|
|
|
9515
9546
|
dayjs.extend(updateLocale);
|
|
9516
9547
|
dayjs.updateLocale(userLocaleName, Object.assign(Object.assign({}, userLocaleProps), locale));
|
|
9517
9548
|
}, [locale]);
|
|
9518
|
-
const dateFormat = format || 'YYYY-MM-DD';
|
|
9519
9549
|
const handleChange = (changedValue, context) => {
|
|
9520
9550
|
if (!onChange || changedValue && !changedValue.isValid()) return;
|
|
9521
9551
|
onChange(changedValue ? changedValue.format(dateFormat) : null, context);
|
|
@@ -9524,6 +9554,13 @@ const DotDatePicker = ({
|
|
|
9524
9554
|
if (!onAccept) return;
|
|
9525
9555
|
onAccept(changedValue ? changedValue.format(dateFormat) : null);
|
|
9526
9556
|
};
|
|
9557
|
+
const handleError = (validationError, currentValue) => onError === null || onError === void 0 ? void 0 : onError(validationError, dayjs(currentValue).format(dateFormat));
|
|
9558
|
+
const handleOpen = () => {
|
|
9559
|
+
if (focusInputOnPopperOpened && inputRef.current) {
|
|
9560
|
+
focusInput(inputRef);
|
|
9561
|
+
}
|
|
9562
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
9563
|
+
};
|
|
9527
9564
|
const createActionBar = () => {
|
|
9528
9565
|
const actionBar = {
|
|
9529
9566
|
actions: []
|
|
@@ -9552,18 +9589,21 @@ const DotDatePicker = ({
|
|
|
9552
9589
|
autoFocus: _autoFocus,
|
|
9553
9590
|
closeOnSelect: _closeOnSelect,
|
|
9554
9591
|
className: rootClasses,
|
|
9555
|
-
|
|
9592
|
+
defaultValue: defaultValue && dayjs(defaultValue, dateFormat),
|
|
9593
|
+
disableOpenPicker: disableOpenPicker || isInputReadOnly || disabled,
|
|
9556
9594
|
disablePast: disablePast,
|
|
9557
9595
|
disabled: disabled,
|
|
9558
9596
|
displayWeekNumber: displayWeekNumber,
|
|
9559
9597
|
fixedWeekNumber: fixedWeekNumber,
|
|
9560
|
-
format:
|
|
9598
|
+
format: dateFormat,
|
|
9561
9599
|
label: persistentLabel ? null : label,
|
|
9600
|
+
maxDate: maxDate && dayjs(maxDate, dateFormat),
|
|
9601
|
+
minDate: minDate && dayjs(minDate, dateFormat),
|
|
9562
9602
|
onAccept: handleAccept,
|
|
9563
9603
|
onChange: handleChange,
|
|
9564
9604
|
onClose: onClose,
|
|
9565
|
-
onError:
|
|
9566
|
-
onOpen:
|
|
9605
|
+
onError: handleError,
|
|
9606
|
+
onOpen: handleOpen,
|
|
9567
9607
|
open: open,
|
|
9568
9608
|
showDaysOutsideCurrentMonth: showDaysOutsideCurrentMonth,
|
|
9569
9609
|
slots: {
|
|
@@ -9587,20 +9627,27 @@ const DotDatePicker = ({
|
|
|
9587
9627
|
required: _required,
|
|
9588
9628
|
helperText,
|
|
9589
9629
|
error,
|
|
9590
|
-
focused:
|
|
9630
|
+
focused: isInputReadOnly ? false : undefined,
|
|
9591
9631
|
inputProps: {
|
|
9592
9632
|
className: 'dot-input',
|
|
9593
9633
|
'data-testid': 'dot-date-picker-input',
|
|
9594
9634
|
onBlur
|
|
9595
9635
|
},
|
|
9636
|
+
inputRef,
|
|
9596
9637
|
fullWidth: _fullWidth,
|
|
9597
9638
|
name: inputName
|
|
9598
9639
|
},
|
|
9599
9640
|
field: {
|
|
9600
|
-
readOnly:
|
|
9641
|
+
readOnly: isInputReadOnly
|
|
9642
|
+
},
|
|
9643
|
+
desktopTrapFocus: {
|
|
9644
|
+
disableEnforceFocus: true
|
|
9645
|
+
},
|
|
9646
|
+
popper: {
|
|
9647
|
+
disablePortal: _disablePortal
|
|
9601
9648
|
}
|
|
9602
9649
|
},
|
|
9603
|
-
value: value && dayjs(value)
|
|
9650
|
+
value: value && dayjs(value, dateFormat)
|
|
9604
9651
|
}, void 0)]
|
|
9605
9652
|
}), void 0)
|
|
9606
9653
|
}), void 0);
|
|
@@ -9665,6 +9712,10 @@ const getSelectedHourButtonIndex = (selectedHour, is12HourFormat) => {
|
|
|
9665
9712
|
return selectedHour;
|
|
9666
9713
|
}
|
|
9667
9714
|
};
|
|
9715
|
+
const getPopperButtonTabIndex = (index, isSelected, selectedValue) => selectedValue && isSelected || !selectedValue && index === 0 ? undefined : -1;
|
|
9716
|
+
const getDaytimeButtonTabIndex = (currentDaytime, selectedDaytime) => selectedDaytime && currentDaytime === selectedDaytime || !selectedDaytime && currentDaytime === Daytime.AM ? undefined : -1;
|
|
9717
|
+
const getSelectedDaytime = dateTime => dateTime && dateTime.format('A') || Daytime.AM;
|
|
9718
|
+
const getTimePickerButtonType = selectedDaytime => selectedDaytime && selectedDaytime === Daytime.PM ? 'primary' : 'text';
|
|
9668
9719
|
|
|
9669
9720
|
const rootClassName = 'dot-time-picker';
|
|
9670
9721
|
const containerClassName = 'dot-time-picker-container';
|
|
@@ -9695,6 +9746,7 @@ const DotTimePicker = ({
|
|
|
9695
9746
|
autoFocus: _autoFocus = false,
|
|
9696
9747
|
className,
|
|
9697
9748
|
'data-testid': dataTestId,
|
|
9749
|
+
defaultValue,
|
|
9698
9750
|
disableOpenPicker: _disableOpenPicker = false,
|
|
9699
9751
|
disabled,
|
|
9700
9752
|
error,
|
|
@@ -9716,24 +9768,43 @@ const DotTimePicker = ({
|
|
|
9716
9768
|
required: _required = false,
|
|
9717
9769
|
value
|
|
9718
9770
|
}) => {
|
|
9719
|
-
const
|
|
9771
|
+
const timeFormat = format || DEFAULT_TIME_FORMAT;
|
|
9772
|
+
const hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
9773
|
+
const hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
9774
|
+
const isComponentReadOnly = _readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
9775
|
+
const rootClasses = useStylesWithRootClass(rootClassName, className, isComponentReadOnly ? 'read-only' : '');
|
|
9720
9776
|
const containerClasses = useStylesWithRootClass(containerClassName, _fullWidth ? 'full-width' : '', className);
|
|
9721
9777
|
const inputRef = useRef(null);
|
|
9722
9778
|
const [isPickerOpened, setIsPickerOpened] = useState(false);
|
|
9723
|
-
const timeFormat = format || DEFAULT_TIME_FORMAT;
|
|
9724
9779
|
const [time, setTime] = useState(null);
|
|
9725
9780
|
const [pickerTime, setPickerTime] = useState();
|
|
9726
9781
|
const hoursRef = useRef(null);
|
|
9727
9782
|
const minutesRef = useRef(null);
|
|
9783
|
+
const daytimeRef = useRef(null);
|
|
9728
9784
|
const hours = getHoursForTimePicker(_ampm);
|
|
9729
9785
|
const minutes = getMinutesForTimePicker();
|
|
9730
|
-
const daytimeSelected = pickerTime
|
|
9786
|
+
const daytimeSelected = getSelectedDaytime(pickerTime);
|
|
9787
|
+
const selectedPickerHour = pickerTime && calculateHourBasedOnTimeFormat(pickerTime, _ampm);
|
|
9731
9788
|
const isOpenPropDefined = open !== null && open !== undefined;
|
|
9789
|
+
const isControlledComponent = onChange && value !== undefined;
|
|
9790
|
+
useEffect(() => {
|
|
9791
|
+
if (hasValueWithoutChangeHandler) {
|
|
9792
|
+
console.warn('Warning: You provided a `value` prop without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.');
|
|
9793
|
+
}
|
|
9794
|
+
if (hasBothValueAndDefaultValue) {
|
|
9795
|
+
console.warn('Warning: A component contains both `value` and `defaultValue` props. Component must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props.');
|
|
9796
|
+
}
|
|
9797
|
+
}, []);
|
|
9732
9798
|
useEffect(() => {
|
|
9733
|
-
|
|
9799
|
+
let timeValue = null;
|
|
9800
|
+
if (defaultValue) {
|
|
9801
|
+
timeValue = getDayjsUtcDate(defaultValue, timeFormat);
|
|
9802
|
+
} else if (value) {
|
|
9803
|
+
timeValue = getDayjsUtcDate(value, timeFormat);
|
|
9804
|
+
}
|
|
9734
9805
|
setTime(timeValue);
|
|
9735
9806
|
setPickerTime(timeValue);
|
|
9736
|
-
}, [value]);
|
|
9807
|
+
}, [value, defaultValue]);
|
|
9737
9808
|
useLayoutEffect(() => {
|
|
9738
9809
|
if (isPickerOpened && time) {
|
|
9739
9810
|
scrollToSelectedTime();
|
|
@@ -9752,7 +9823,9 @@ const DotTimePicker = ({
|
|
|
9752
9823
|
setPickerTime(pickedDateTime);
|
|
9753
9824
|
};
|
|
9754
9825
|
const handleInputChange = (currentValue, context) => {
|
|
9826
|
+
const currentTimeValue = currentValue ? currentValue : null;
|
|
9755
9827
|
setPickerTime(currentValue ? currentValue : null);
|
|
9828
|
+
!isControlledComponent && setTime(currentTimeValue);
|
|
9756
9829
|
onChange === null || onChange === void 0 ? void 0 : onChange(currentValue ? currentValue.format(timeFormat) : null, context);
|
|
9757
9830
|
};
|
|
9758
9831
|
const handleClose = () => {
|
|
@@ -9781,12 +9854,16 @@ const DotTimePicker = ({
|
|
|
9781
9854
|
handleClose();
|
|
9782
9855
|
};
|
|
9783
9856
|
const handleSet = () => {
|
|
9784
|
-
|
|
9857
|
+
if (!pickerTime) {
|
|
9858
|
+
handleClose();
|
|
9859
|
+
return;
|
|
9860
|
+
}
|
|
9785
9861
|
setTime(pickerTime);
|
|
9786
9862
|
onChange === null || onChange === void 0 ? void 0 : onChange(pickerTime.format(timeFormat), {
|
|
9787
9863
|
validationError: null
|
|
9788
9864
|
});
|
|
9789
9865
|
onAccept === null || onAccept === void 0 ? void 0 : onAccept(pickerTime.format(timeFormat));
|
|
9866
|
+
handleClose();
|
|
9790
9867
|
};
|
|
9791
9868
|
const scrollToSelectedTime = () => {
|
|
9792
9869
|
if (!(hoursRef === null || hoursRef === void 0 ? void 0 : hoursRef.current) || !(minutesRef === null || minutesRef === void 0 ? void 0 : minutesRef.current)) return;
|
|
@@ -9804,9 +9881,26 @@ const DotTimePicker = ({
|
|
|
9804
9881
|
minutesRef.current.children[selectedMinute].scrollIntoView(scrollOptions);
|
|
9805
9882
|
}
|
|
9806
9883
|
};
|
|
9884
|
+
const handleTimeKeydown = (ref, index) => event => {
|
|
9885
|
+
const numberOfElements = ref.current.children.length;
|
|
9886
|
+
const prevElement = index > 0 && ref.current.children[index - 1];
|
|
9887
|
+
const nextElement = index < numberOfElements - 1 && ref.current.children[index + 1];
|
|
9888
|
+
if (checkIfArrowUpPressed(event) && prevElement) {
|
|
9889
|
+
event.preventDefault();
|
|
9890
|
+
prevElement.focus();
|
|
9891
|
+
} else if (checkIfArrowDownPressed(event) && nextElement) {
|
|
9892
|
+
event.preventDefault();
|
|
9893
|
+
nextElement.focus();
|
|
9894
|
+
}
|
|
9895
|
+
};
|
|
9896
|
+
const handleTimePickerKeyDown = event => {
|
|
9897
|
+
if (event.key !== 'Escape' || !isPickerOpened) return;
|
|
9898
|
+
handleCancel();
|
|
9899
|
+
};
|
|
9807
9900
|
return jsxs(StyledTimePickerContainer, Object.assign({
|
|
9808
9901
|
className: containerClasses,
|
|
9809
|
-
"data-testid": dataTestId
|
|
9902
|
+
"data-testid": dataTestId,
|
|
9903
|
+
onKeyDown: handleTimePickerKeyDown
|
|
9810
9904
|
}, {
|
|
9811
9905
|
children: [jsxs(LocalizationProvider, Object.assign({
|
|
9812
9906
|
dateAdapter: AdapterDayjs
|
|
@@ -9833,14 +9927,14 @@ const DotTimePicker = ({
|
|
|
9833
9927
|
required: _required,
|
|
9834
9928
|
helperText,
|
|
9835
9929
|
error,
|
|
9836
|
-
focused:
|
|
9930
|
+
focused: isComponentReadOnly ? false : undefined,
|
|
9837
9931
|
InputProps: {
|
|
9838
9932
|
endAdornment: jsxs(Fragment$1, {
|
|
9839
9933
|
children: [error && jsx(DotIcon, {
|
|
9840
9934
|
className: "dot-error-icon",
|
|
9841
9935
|
"data-testid": dataTestId && `${dataTestId}-input-error-icon`,
|
|
9842
9936
|
iconId: "error-solid"
|
|
9843
|
-
}, void 0), !_disableOpenPicker && !
|
|
9937
|
+
}, void 0), !_disableOpenPicker && !isComponentReadOnly && !disabled && jsx(DotIconButton, {
|
|
9844
9938
|
"data-testid": dataTestId && `${dataTestId}-open-btn`,
|
|
9845
9939
|
iconId: "pending-clock",
|
|
9846
9940
|
onClick: _event => handleTimePickerButtonClick(),
|
|
@@ -9857,17 +9951,17 @@ const DotTimePicker = ({
|
|
|
9857
9951
|
name: inputName
|
|
9858
9952
|
},
|
|
9859
9953
|
field: {
|
|
9860
|
-
readOnly:
|
|
9954
|
+
readOnly: isComponentReadOnly
|
|
9861
9955
|
}
|
|
9862
9956
|
},
|
|
9863
9957
|
value: time
|
|
9864
9958
|
}, void 0)]
|
|
9865
9959
|
}), void 0), jsx(Popper, Object.assign({
|
|
9960
|
+
anchorEl: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current,
|
|
9866
9961
|
className: "dot-time-picker-popper",
|
|
9867
9962
|
"data-testid": dataTestId && `${dataTestId}-popper`,
|
|
9868
|
-
open: isPickerOpened,
|
|
9869
|
-
anchorEl: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current,
|
|
9870
9963
|
disablePortal: true,
|
|
9964
|
+
open: isPickerOpened,
|
|
9871
9965
|
placement: "bottom-start"
|
|
9872
9966
|
}, {
|
|
9873
9967
|
children: jsx(ClickAwayListener, Object.assign({
|
|
@@ -9884,12 +9978,14 @@ const DotTimePicker = ({
|
|
|
9884
9978
|
className: "dot-time-picker-hours",
|
|
9885
9979
|
ref: hoursRef
|
|
9886
9980
|
}, {
|
|
9887
|
-
children: hours.map(hour => {
|
|
9888
|
-
const isSelected = pickerTime ?
|
|
9981
|
+
children: hours.map((hour, index) => {
|
|
9982
|
+
const isSelected = pickerTime ? selectedPickerHour === hour : false;
|
|
9889
9983
|
return jsx(DotButton, Object.assign({
|
|
9890
9984
|
className: "dot-picker-button",
|
|
9891
9985
|
"data-testid": dataTestId && `${dataTestId}-hour-button-${hour}`,
|
|
9892
9986
|
onClick: () => handleHourClick(hour),
|
|
9987
|
+
onKeyDown: handleTimeKeydown(hoursRef, index),
|
|
9988
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, selectedPickerHour),
|
|
9893
9989
|
type: isSelected ? 'primary' : 'text'
|
|
9894
9990
|
}, {
|
|
9895
9991
|
children: hour.toString().padStart(2, '0')
|
|
@@ -9899,32 +9995,39 @@ const DotTimePicker = ({
|
|
|
9899
9995
|
className: "dot-time-picker-minutes",
|
|
9900
9996
|
ref: minutesRef
|
|
9901
9997
|
}, {
|
|
9902
|
-
children: minutes.map(minute => {
|
|
9998
|
+
children: minutes.map((minute, index) => {
|
|
9903
9999
|
const isSelected = pickerTime ? pickerTime.minute() === minute : false;
|
|
9904
10000
|
return jsx(DotButton, Object.assign({
|
|
9905
10001
|
className: "dot-picker-button",
|
|
9906
10002
|
"data-testid": dataTestId && `${dataTestId}-minute-button-${minute}`,
|
|
9907
10003
|
type: isSelected ? 'primary' : 'text',
|
|
9908
|
-
onClick: () => handleMinuteClick(minute)
|
|
10004
|
+
onClick: () => handleMinuteClick(minute),
|
|
10005
|
+
onKeyDown: handleTimeKeydown(minutesRef, index),
|
|
10006
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, pickerTime === null || pickerTime === void 0 ? void 0 : pickerTime.minute())
|
|
9909
10007
|
}, {
|
|
9910
10008
|
children: minute.toString().padStart(2, '0')
|
|
9911
10009
|
}), minute);
|
|
9912
10010
|
})
|
|
9913
10011
|
}), void 0), _ampm && jsxs("div", Object.assign({
|
|
9914
|
-
className: "dot-time-picker-daytime"
|
|
10012
|
+
className: "dot-time-picker-daytime",
|
|
10013
|
+
ref: daytimeRef
|
|
9915
10014
|
}, {
|
|
9916
10015
|
children: [jsx(DotButton, Object.assign({
|
|
9917
10016
|
className: "dot-picker-button",
|
|
9918
10017
|
"data-testid": dataTestId && `${dataTestId}-am-button`,
|
|
9919
|
-
|
|
9920
|
-
|
|
10018
|
+
onClick: () => handleDaytimeSelection(Daytime.AM),
|
|
10019
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 0),
|
|
10020
|
+
tabIndex: getDaytimeButtonTabIndex(Daytime.AM, daytimeSelected),
|
|
10021
|
+
type: daytimeSelected && daytimeSelected === Daytime.AM ? 'primary' : 'text'
|
|
9921
10022
|
}, {
|
|
9922
10023
|
children: Daytime.AM
|
|
9923
10024
|
}), Daytime.AM), jsx(DotButton, Object.assign({
|
|
9924
10025
|
className: "dot-picker-button",
|
|
9925
10026
|
"data-testid": dataTestId && `${dataTestId}-pm-button`,
|
|
9926
|
-
|
|
9927
|
-
|
|
10027
|
+
onClick: () => handleDaytimeSelection(Daytime.PM),
|
|
10028
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 1),
|
|
10029
|
+
tabIndex: getDaytimeButtonTabIndex(Daytime.PM, daytimeSelected),
|
|
10030
|
+
type: getTimePickerButtonType(daytimeSelected)
|
|
9928
10031
|
}, {
|
|
9929
10032
|
children: Daytime.PM
|
|
9930
10033
|
}), Daytime.PM)]
|
|
@@ -9954,4 +10057,16 @@ const DotTimePicker = ({
|
|
|
9954
10057
|
}), void 0);
|
|
9955
10058
|
};
|
|
9956
10059
|
|
|
9957
|
-
|
|
10060
|
+
const DotClickAwayListener = ({
|
|
10061
|
+
children,
|
|
10062
|
+
disableReactTree: _disableReactTree = false,
|
|
10063
|
+
onClickAway
|
|
10064
|
+
}) => {
|
|
10065
|
+
return jsx(ClickAwayListener, {
|
|
10066
|
+
children: children,
|
|
10067
|
+
disableReactTree: _disableReactTree,
|
|
10068
|
+
onClickAway: onClickAway
|
|
10069
|
+
}, void 0);
|
|
10070
|
+
};
|
|
10071
|
+
|
|
10072
|
+
export { Cell, CreateUUID, CssCell, CssGrid, CssGridDebug, Daytime, DotAccordion, DotActionToolbar, DotAlertBanner, DotAppLogo, DotAppSwitcher, DotAppToolbar, DotAutoComplete, DotAvatar, DotAvatarGroup, DotBadge, DotBreadcrumbs, DotButton, DotButtonToggle, DotCard, DotCardContent, DotCardFooter, DotCardHeader, DotCheckbox, DotCheckboxGroup, DotChip, DotClickAwayListener, DotConfirmationDialog, DotCopyButton, DotCoreApiProvider, DotDatePicker, DotDialog, DotDivider, DotDraggableList, DotDrawer, DotDynamicForm, DotEmptyState, DotFileListItem, DotFileUpload, DotForm, DotFormGroup, DotHeaderRow, DotIcon, DotIconButton, DotInlineEdit, DotInputSelect, DotInputText, DotLinearProgress, DotLink, DotList, DotMenu, DotNavigationRail, DotPill, DotPopper, DotProgress, DotProgressButton, DotRadioButton, DotRadioGroup, DotSidebar, DotSkeleton, DotSnackbar, DotSnackbarContainer, DotSnackbarProvider, DotSplitButton, DotStepper, DotSwitch, DotTable, DotTableAction, DotTableActions, DotTablePagination, DotTabs, DotThemeProvider, DotTimePicker, DotTooltip, DotTruncateWithTooltip, DotTypography, avatarColors, lightThemeColors as lightColors, mockScrollIntoView, parseAutoCompleteValue, variables as themeVariables, typographyOptions, useDotCoreApiContext, useDotSnackbarContext };
|
package/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@mui/material'), require('@digital-ai/dot-icons'), require('styled-components'), require('@mui/material/styles'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@mui/material', '@digital-ai/dot-icons', 'styled-components', '@mui/material/styles', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DotComponents = {}, global.jsxRuntime, global.React, global.MuiCore, null, global.styled, global.styles, global.
|
|
5
|
-
})(this, (function (exports, jsxRuntime, React, material, dotIcons, styled, styles,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('@mui/material'), require('@digital-ai/dot-icons'), require('styled-components'), require('@mui/material/styles'), require('jwt-decode'), require('react-dropzone'), require('react-grid-layout'), require('dayjs'), require('dayjs/plugin/updateLocale'), require('@mui/x-date-pickers'), require('@mui/x-date-pickers/AdapterDayjs'), require('dayjs/plugin/utc')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', '@mui/material', '@digital-ai/dot-icons', 'styled-components', '@mui/material/styles', 'jwt-decode', 'react-dropzone', 'react-grid-layout', 'dayjs', 'dayjs/plugin/updateLocale', '@mui/x-date-pickers', '@mui/x-date-pickers/AdapterDayjs', 'dayjs/plugin/utc'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DotComponents = {}, global.jsxRuntime, global.React, global.MuiCore, null, global.styled, global.styles, global.jwt_decode, global.ReactDropzone, global.GridLayout, global.dayjs, global.updateLocale, global.xDatePickers, global.AdapterDayjs, global.utc));
|
|
5
|
+
})(this, (function (exports, jsxRuntime, React, material, dotIcons, styled, styles, jwt_decode, reactDropzone, GridLayout, dayjs, updateLocale, xDatePickers, AdapterDayjs, utc) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -1007,7 +1007,7 @@
|
|
|
1007
1007
|
_b = _a.theme,
|
|
1008
1008
|
theme = _b === void 0 ? lightTheme : _b;
|
|
1009
1009
|
var userTheme = typeof theme === 'string' && theme === 'dark' ? darkTheme : lightTheme;
|
|
1010
|
-
return jsxRuntime.jsx(
|
|
1010
|
+
return jsxRuntime.jsx(material.StyledEngineProvider, __assign({
|
|
1011
1011
|
injectFirst: true
|
|
1012
1012
|
}, {
|
|
1013
1013
|
children: jsxRuntime.jsx(styles.ThemeProvider, __assign({
|
|
@@ -1059,6 +1059,12 @@
|
|
|
1059
1059
|
children: content
|
|
1060
1060
|
}), void 0) : content;
|
|
1061
1061
|
};
|
|
1062
|
+
var checkIfArrowUpPressed = function checkIfArrowUpPressed(event) {
|
|
1063
|
+
return event.key === 'ArrowUp';
|
|
1064
|
+
};
|
|
1065
|
+
var checkIfArrowDownPressed = function checkIfArrowDownPressed(event) {
|
|
1066
|
+
return event.key === 'ArrowDown';
|
|
1067
|
+
};
|
|
1062
1068
|
|
|
1063
1069
|
var DotAlertBanner = function DotAlertBanner(_a) {
|
|
1064
1070
|
var action = _a.action,
|
|
@@ -1954,6 +1960,7 @@
|
|
|
1954
1960
|
_f = _a.isSubmit,
|
|
1955
1961
|
isSubmit = _f === void 0 ? false : _f,
|
|
1956
1962
|
onClick = _a.onClick,
|
|
1963
|
+
onKeyDown = _a.onKeyDown,
|
|
1957
1964
|
_g = _a.size,
|
|
1958
1965
|
size = _g === void 0 ? 'medium' : _g,
|
|
1959
1966
|
startIcon = _a.startIcon,
|
|
@@ -2000,6 +2007,7 @@
|
|
|
2000
2007
|
onClick: function (event) {
|
|
2001
2008
|
return onClick && onClick(event);
|
|
2002
2009
|
},
|
|
2010
|
+
onKeyDown: onKeyDown,
|
|
2003
2011
|
ref: ref,
|
|
2004
2012
|
size: size,
|
|
2005
2013
|
startIcon: startIcon,
|
|
@@ -7940,7 +7948,7 @@
|
|
|
7940
7948
|
componentId: "l7oxi2-0"
|
|
7941
7949
|
})(templateObject_2$m || (templateObject_2$m = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
|
|
7942
7950
|
var theme = _a.theme;
|
|
7943
|
-
return styled.css(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\n &.", " {\n background-color: ", ";\n color: ", ";\n border-color: ", ";\n\n &.error {\n background-color: ", ";\n color: ", ";\n }\n\n &.success {\n background-color: ", ";\n color: ", ";\n }\n &.warning {\n background-color: ", ";\n color: ", ";\n }\n\n &.in-progress {\n background-color: ", ";\n color: ", ";\n }\n "], ["\n &.", " {\n background-color: ", ";\n color: ", ";\n border-color: ", ";\n\n &.error {\n background-color: ", ";\n color: ", ";\n }\n\n &.success {\n background-color: ", ";\n color: ", ";\n }\n &.warning {\n background-color: ", ";\n color: ", ";\n }\n\n &.in-progress {\n background-color: ", ";\n color: ", ";\n }\n "])), rootClassName$n, function (_a) {
|
|
7951
|
+
return styled.css(templateObject_1$n || (templateObject_1$n = __makeTemplateObject(["\n &.", " {\n background-color: ", ";\n color: ", ";\n border-color: ", ";\n\n &.error {\n background-color: ", ";\n border-color: ", ";\n .dot-icon {\n color: ", ";\n }\n color: ", ";\n }\n\n &.success {\n background-color: ", ";\n border-color: ", ";\n .dot-icon {\n color: ", ";\n }\n color: ", ";\n }\n\n &.warning {\n background-color: ", ";\n border-color: ", ";\n .dot-icon {\n color: ", ";\n }\n color: ", ";\n }\n\n &.in-progress {\n background-color: ", ";\n border-color: ", ";\n .dot-icon {\n color: ", ";\n }\n color: ", ";\n }\n "], ["\n &.", " {\n background-color: ", ";\n color: ", ";\n border-color: ", ";\n\n &.error {\n background-color: ", ";\n border-color: ", ";\n .dot-icon {\n color: ", ";\n }\n color: ", ";\n }\n\n &.success {\n background-color: ", ";\n border-color: ", ";\n .dot-icon {\n color: ", ";\n }\n color: ", ";\n }\n\n &.warning {\n background-color: ", ";\n border-color: ", ";\n .dot-icon {\n color: ", ";\n }\n color: ", ";\n }\n\n &.in-progress {\n background-color: ", ";\n border-color: ", ";\n .dot-icon {\n color: ", ";\n }\n color: ", ";\n }\n "])), rootClassName$n, function (_a) {
|
|
7944
7952
|
var backgroundcolor = _a.backgroundcolor;
|
|
7945
7953
|
return backgroundcolor || theme.palette.grey[200];
|
|
7946
7954
|
}, function (_a) {
|
|
@@ -7949,7 +7957,7 @@
|
|
|
7949
7957
|
}, function (_a) {
|
|
7950
7958
|
var bordercolor = _a.bordercolor;
|
|
7951
7959
|
return bordercolor ? bordercolor : theme.palette.layer.n700;
|
|
7952
|
-
}, theme.palette.error[
|
|
7960
|
+
}, theme.palette.error[100], theme.palette.error.main, theme.palette.error.main, theme.palette.layer.n700, theme.palette.success[100], theme.palette.success.main, theme.palette.success.main, theme.palette.layer.n700, theme.palette.warning[100], theme.palette.warning.main, theme.palette.warning.main, theme.palette.layer.n700, theme.palette.primary[100], theme.palette.primary.main, theme.palette.primary.main, theme.palette.layer.n700);
|
|
7953
7961
|
});
|
|
7954
7962
|
var templateObject_1$n, templateObject_2$m;
|
|
7955
7963
|
|
|
@@ -10308,22 +10316,28 @@
|
|
|
10308
10316
|
_c = _a.closeOnSelect,
|
|
10309
10317
|
closeOnSelect = _c === void 0 ? true : _c,
|
|
10310
10318
|
dataTestId = _a["data-testid"],
|
|
10319
|
+
defaultValue = _a.defaultValue,
|
|
10311
10320
|
disableOpenPicker = _a.disableOpenPicker,
|
|
10312
10321
|
disablePast = _a.disablePast,
|
|
10322
|
+
_d = _a.disablePortal,
|
|
10323
|
+
disablePortal = _d === void 0 ? false : _d,
|
|
10313
10324
|
disabled = _a.disabled,
|
|
10314
10325
|
displayWeekNumber = _a.displayWeekNumber,
|
|
10315
|
-
|
|
10316
|
-
displayClearButton =
|
|
10326
|
+
_e = _a.displayClearButton,
|
|
10327
|
+
displayClearButton = _e === void 0 ? true : _e,
|
|
10317
10328
|
error = _a.error,
|
|
10318
10329
|
fixedWeekNumber = _a.fixedWeekNumber,
|
|
10330
|
+
focusInputOnPopperOpened = _a.focusInputOnPopperOpened,
|
|
10319
10331
|
format = _a.format,
|
|
10320
|
-
|
|
10321
|
-
fullWidth =
|
|
10332
|
+
_f = _a.fullWidth,
|
|
10333
|
+
fullWidth = _f === void 0 ? false : _f,
|
|
10322
10334
|
helperText = _a.helperText,
|
|
10323
10335
|
inputId = _a.inputId,
|
|
10324
10336
|
inputName = _a.inputName,
|
|
10325
10337
|
label = _a.label,
|
|
10326
10338
|
locale = _a.locale,
|
|
10339
|
+
maxDate = _a.maxDate,
|
|
10340
|
+
minDate = _a.minDate,
|
|
10327
10341
|
onAccept = _a.onAccept,
|
|
10328
10342
|
onBlur = _a.onBlur,
|
|
10329
10343
|
onChange = _a.onChange,
|
|
@@ -10332,14 +10346,37 @@
|
|
|
10332
10346
|
onOpen = _a.onOpen,
|
|
10333
10347
|
open = _a.open,
|
|
10334
10348
|
persistentLabel = _a.persistentLabel,
|
|
10335
|
-
|
|
10336
|
-
readOnly =
|
|
10337
|
-
|
|
10338
|
-
required =
|
|
10349
|
+
_g = _a.readOnly,
|
|
10350
|
+
readOnly = _g === void 0 ? false : _g,
|
|
10351
|
+
_h = _a.required,
|
|
10352
|
+
required = _h === void 0 ? false : _h,
|
|
10339
10353
|
showDaysOutsideCurrentMonth = _a.showDaysOutsideCurrentMonth,
|
|
10340
10354
|
value = _a.value;
|
|
10341
|
-
var
|
|
10355
|
+
var dateFormat = format || 'YYYY-MM-DD';
|
|
10356
|
+
var hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
10357
|
+
var hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
10358
|
+
var isInputReadOnly = readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
10359
|
+
var inputRef = React.useRef(null);
|
|
10360
|
+
var rootClasses = useStylesWithRootClass(rootClassName$1, className, isInputReadOnly ? 'read-only' : '');
|
|
10342
10361
|
var containerClasses = useStylesWithRootClass(containerClassName$1, fullWidth ? 'full-width' : '', className);
|
|
10362
|
+
var focusInput = function focusInput(ref) {
|
|
10363
|
+
setTimeout(function () {
|
|
10364
|
+
ref.current.focus();
|
|
10365
|
+
}, 0);
|
|
10366
|
+
};
|
|
10367
|
+
React.useEffect(function () {
|
|
10368
|
+
if (focusInputOnPopperOpened && open && inputRef.current) {
|
|
10369
|
+
focusInput(inputRef);
|
|
10370
|
+
}
|
|
10371
|
+
}, [open, focusInputOnPopperOpened]);
|
|
10372
|
+
React.useEffect(function () {
|
|
10373
|
+
if (hasValueWithoutChangeHandler) {
|
|
10374
|
+
console.warn('Warning: You provided a `value` prop without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.');
|
|
10375
|
+
}
|
|
10376
|
+
if (hasBothValueAndDefaultValue) {
|
|
10377
|
+
console.warn('Warning: A component contains both `value` and `defaultValue` props. Component must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props.');
|
|
10378
|
+
}
|
|
10379
|
+
}, []);
|
|
10343
10380
|
React.useEffect(function () {
|
|
10344
10381
|
if (!locale) return;
|
|
10345
10382
|
var userLocaleName = dayjs__default["default"].locale();
|
|
@@ -10347,7 +10384,6 @@
|
|
|
10347
10384
|
dayjs__default["default"].extend(updateLocale__default["default"]);
|
|
10348
10385
|
dayjs__default["default"].updateLocale(userLocaleName, __assign(__assign({}, userLocaleProps), locale));
|
|
10349
10386
|
}, [locale]);
|
|
10350
|
-
var dateFormat = format || 'YYYY-MM-DD';
|
|
10351
10387
|
var handleChange = function handleChange(changedValue, context) {
|
|
10352
10388
|
if (!onChange || changedValue && !changedValue.isValid()) return;
|
|
10353
10389
|
onChange(changedValue ? changedValue.format(dateFormat) : null, context);
|
|
@@ -10356,6 +10392,15 @@
|
|
|
10356
10392
|
if (!onAccept) return;
|
|
10357
10393
|
onAccept(changedValue ? changedValue.format(dateFormat) : null);
|
|
10358
10394
|
};
|
|
10395
|
+
var handleError = function handleError(validationError, currentValue) {
|
|
10396
|
+
return onError === null || onError === void 0 ? void 0 : onError(validationError, dayjs__default["default"](currentValue).format(dateFormat));
|
|
10397
|
+
};
|
|
10398
|
+
var handleOpen = function handleOpen() {
|
|
10399
|
+
if (focusInputOnPopperOpened && inputRef.current) {
|
|
10400
|
+
focusInput(inputRef);
|
|
10401
|
+
}
|
|
10402
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
10403
|
+
};
|
|
10359
10404
|
var createActionBar = function createActionBar() {
|
|
10360
10405
|
var actionBar = {
|
|
10361
10406
|
actions: []
|
|
@@ -10384,18 +10429,21 @@
|
|
|
10384
10429
|
autoFocus: autoFocus,
|
|
10385
10430
|
closeOnSelect: closeOnSelect,
|
|
10386
10431
|
className: rootClasses,
|
|
10387
|
-
|
|
10432
|
+
defaultValue: defaultValue && dayjs__default["default"](defaultValue, dateFormat),
|
|
10433
|
+
disableOpenPicker: disableOpenPicker || isInputReadOnly || disabled,
|
|
10388
10434
|
disablePast: disablePast,
|
|
10389
10435
|
disabled: disabled,
|
|
10390
10436
|
displayWeekNumber: displayWeekNumber,
|
|
10391
10437
|
fixedWeekNumber: fixedWeekNumber,
|
|
10392
|
-
format:
|
|
10438
|
+
format: dateFormat,
|
|
10393
10439
|
label: persistentLabel ? null : label,
|
|
10440
|
+
maxDate: maxDate && dayjs__default["default"](maxDate, dateFormat),
|
|
10441
|
+
minDate: minDate && dayjs__default["default"](minDate, dateFormat),
|
|
10394
10442
|
onAccept: handleAccept,
|
|
10395
10443
|
onChange: handleChange,
|
|
10396
10444
|
onClose: onClose,
|
|
10397
|
-
onError:
|
|
10398
|
-
onOpen:
|
|
10445
|
+
onError: handleError,
|
|
10446
|
+
onOpen: handleOpen,
|
|
10399
10447
|
open: open,
|
|
10400
10448
|
showDaysOutsideCurrentMonth: showDaysOutsideCurrentMonth,
|
|
10401
10449
|
slots: {
|
|
@@ -10423,20 +10471,27 @@
|
|
|
10423
10471
|
required: required,
|
|
10424
10472
|
helperText: helperText,
|
|
10425
10473
|
error: error,
|
|
10426
|
-
focused:
|
|
10474
|
+
focused: isInputReadOnly ? false : undefined,
|
|
10427
10475
|
inputProps: {
|
|
10428
10476
|
className: 'dot-input',
|
|
10429
10477
|
'data-testid': 'dot-date-picker-input',
|
|
10430
10478
|
onBlur: onBlur
|
|
10431
10479
|
},
|
|
10480
|
+
inputRef: inputRef,
|
|
10432
10481
|
fullWidth: fullWidth,
|
|
10433
10482
|
name: inputName
|
|
10434
10483
|
},
|
|
10435
10484
|
field: {
|
|
10436
|
-
readOnly:
|
|
10485
|
+
readOnly: isInputReadOnly
|
|
10486
|
+
},
|
|
10487
|
+
desktopTrapFocus: {
|
|
10488
|
+
disableEnforceFocus: true
|
|
10489
|
+
},
|
|
10490
|
+
popper: {
|
|
10491
|
+
disablePortal: disablePortal
|
|
10437
10492
|
}
|
|
10438
10493
|
},
|
|
10439
|
-
value: value && dayjs__default["default"](value)
|
|
10494
|
+
value: value && dayjs__default["default"](value, dateFormat)
|
|
10440
10495
|
}, void 0)]
|
|
10441
10496
|
}), void 0)
|
|
10442
10497
|
}), void 0);
|
|
@@ -10511,6 +10566,18 @@
|
|
|
10511
10566
|
return selectedHour;
|
|
10512
10567
|
}
|
|
10513
10568
|
};
|
|
10569
|
+
var getPopperButtonTabIndex = function getPopperButtonTabIndex(index, isSelected, selectedValue) {
|
|
10570
|
+
return selectedValue && isSelected || !selectedValue && index === 0 ? undefined : -1;
|
|
10571
|
+
};
|
|
10572
|
+
var getDaytimeButtonTabIndex = function getDaytimeButtonTabIndex(currentDaytime, selectedDaytime) {
|
|
10573
|
+
return selectedDaytime && currentDaytime === selectedDaytime || !selectedDaytime && currentDaytime === exports.Daytime.AM ? undefined : -1;
|
|
10574
|
+
};
|
|
10575
|
+
var getSelectedDaytime = function getSelectedDaytime(dateTime) {
|
|
10576
|
+
return dateTime && dateTime.format('A') || exports.Daytime.AM;
|
|
10577
|
+
};
|
|
10578
|
+
var getTimePickerButtonType = function getTimePickerButtonType(selectedDaytime) {
|
|
10579
|
+
return selectedDaytime && selectedDaytime === exports.Daytime.PM ? 'primary' : 'text';
|
|
10580
|
+
};
|
|
10514
10581
|
|
|
10515
10582
|
var rootClassName = 'dot-time-picker';
|
|
10516
10583
|
var containerClassName = 'dot-time-picker-container';
|
|
@@ -10546,6 +10613,7 @@
|
|
|
10546
10613
|
autoFocus = _c === void 0 ? false : _c,
|
|
10547
10614
|
className = _a.className,
|
|
10548
10615
|
dataTestId = _a["data-testid"],
|
|
10616
|
+
defaultValue = _a.defaultValue,
|
|
10549
10617
|
_d = _a.disableOpenPicker,
|
|
10550
10618
|
disableOpenPicker = _d === void 0 ? false : _d,
|
|
10551
10619
|
disabled = _a.disabled,
|
|
@@ -10570,13 +10638,16 @@
|
|
|
10570
10638
|
_g = _a.required,
|
|
10571
10639
|
required = _g === void 0 ? false : _g,
|
|
10572
10640
|
value = _a.value;
|
|
10573
|
-
var
|
|
10641
|
+
var timeFormat = format || DEFAULT_TIME_FORMAT;
|
|
10642
|
+
var hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
10643
|
+
var hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
10644
|
+
var isComponentReadOnly = readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
10645
|
+
var rootClasses = useStylesWithRootClass(rootClassName, className, isComponentReadOnly ? 'read-only' : '');
|
|
10574
10646
|
var containerClasses = useStylesWithRootClass(containerClassName, fullWidth ? 'full-width' : '', className);
|
|
10575
10647
|
var inputRef = React.useRef(null);
|
|
10576
10648
|
var _h = React.useState(false),
|
|
10577
10649
|
isPickerOpened = _h[0],
|
|
10578
10650
|
setIsPickerOpened = _h[1];
|
|
10579
|
-
var timeFormat = format || DEFAULT_TIME_FORMAT;
|
|
10580
10651
|
var _j = React.useState(null),
|
|
10581
10652
|
time = _j[0],
|
|
10582
10653
|
setTime = _j[1];
|
|
@@ -10585,15 +10656,31 @@
|
|
|
10585
10656
|
setPickerTime = _k[1];
|
|
10586
10657
|
var hoursRef = React.useRef(null);
|
|
10587
10658
|
var minutesRef = React.useRef(null);
|
|
10659
|
+
var daytimeRef = React.useRef(null);
|
|
10588
10660
|
var hours = getHoursForTimePicker(ampm);
|
|
10589
10661
|
var minutes = getMinutesForTimePicker();
|
|
10590
|
-
var daytimeSelected = pickerTime
|
|
10662
|
+
var daytimeSelected = getSelectedDaytime(pickerTime);
|
|
10663
|
+
var selectedPickerHour = pickerTime && calculateHourBasedOnTimeFormat(pickerTime, ampm);
|
|
10591
10664
|
var isOpenPropDefined = open !== null && open !== undefined;
|
|
10665
|
+
var isControlledComponent = onChange && value !== undefined;
|
|
10666
|
+
React.useEffect(function () {
|
|
10667
|
+
if (hasValueWithoutChangeHandler) {
|
|
10668
|
+
console.warn('Warning: You provided a `value` prop without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.');
|
|
10669
|
+
}
|
|
10670
|
+
if (hasBothValueAndDefaultValue) {
|
|
10671
|
+
console.warn('Warning: A component contains both `value` and `defaultValue` props. Component must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props.');
|
|
10672
|
+
}
|
|
10673
|
+
}, []);
|
|
10592
10674
|
React.useEffect(function () {
|
|
10593
|
-
var timeValue =
|
|
10675
|
+
var timeValue = null;
|
|
10676
|
+
if (defaultValue) {
|
|
10677
|
+
timeValue = getDayjsUtcDate(defaultValue, timeFormat);
|
|
10678
|
+
} else if (value) {
|
|
10679
|
+
timeValue = getDayjsUtcDate(value, timeFormat);
|
|
10680
|
+
}
|
|
10594
10681
|
setTime(timeValue);
|
|
10595
10682
|
setPickerTime(timeValue);
|
|
10596
|
-
}, [value]);
|
|
10683
|
+
}, [value, defaultValue]);
|
|
10597
10684
|
React.useLayoutEffect(function () {
|
|
10598
10685
|
if (isPickerOpened && time) {
|
|
10599
10686
|
scrollToSelectedTime();
|
|
@@ -10612,7 +10699,9 @@
|
|
|
10612
10699
|
setPickerTime(pickedDateTime);
|
|
10613
10700
|
};
|
|
10614
10701
|
var handleInputChange = function handleInputChange(currentValue, context) {
|
|
10702
|
+
var currentTimeValue = currentValue ? currentValue : null;
|
|
10615
10703
|
setPickerTime(currentValue ? currentValue : null);
|
|
10704
|
+
!isControlledComponent && setTime(currentTimeValue);
|
|
10616
10705
|
onChange === null || onChange === void 0 ? void 0 : onChange(currentValue ? currentValue.format(timeFormat) : null, context);
|
|
10617
10706
|
};
|
|
10618
10707
|
var handleClose = function handleClose() {
|
|
@@ -10641,12 +10730,16 @@
|
|
|
10641
10730
|
handleClose();
|
|
10642
10731
|
};
|
|
10643
10732
|
var handleSet = function handleSet() {
|
|
10644
|
-
|
|
10733
|
+
if (!pickerTime) {
|
|
10734
|
+
handleClose();
|
|
10735
|
+
return;
|
|
10736
|
+
}
|
|
10645
10737
|
setTime(pickerTime);
|
|
10646
10738
|
onChange === null || onChange === void 0 ? void 0 : onChange(pickerTime.format(timeFormat), {
|
|
10647
10739
|
validationError: null
|
|
10648
10740
|
});
|
|
10649
10741
|
onAccept === null || onAccept === void 0 ? void 0 : onAccept(pickerTime.format(timeFormat));
|
|
10742
|
+
handleClose();
|
|
10650
10743
|
};
|
|
10651
10744
|
var scrollToSelectedTime = function scrollToSelectedTime() {
|
|
10652
10745
|
if (!(hoursRef === null || hoursRef === void 0 ? void 0 : hoursRef.current) || !(minutesRef === null || minutesRef === void 0 ? void 0 : minutesRef.current)) return;
|
|
@@ -10664,9 +10757,28 @@
|
|
|
10664
10757
|
minutesRef.current.children[selectedMinute].scrollIntoView(scrollOptions);
|
|
10665
10758
|
}
|
|
10666
10759
|
};
|
|
10760
|
+
var handleTimeKeydown = function handleTimeKeydown(ref, index) {
|
|
10761
|
+
return function (event) {
|
|
10762
|
+
var numberOfElements = ref.current.children.length;
|
|
10763
|
+
var prevElement = index > 0 && ref.current.children[index - 1];
|
|
10764
|
+
var nextElement = index < numberOfElements - 1 && ref.current.children[index + 1];
|
|
10765
|
+
if (checkIfArrowUpPressed(event) && prevElement) {
|
|
10766
|
+
event.preventDefault();
|
|
10767
|
+
prevElement.focus();
|
|
10768
|
+
} else if (checkIfArrowDownPressed(event) && nextElement) {
|
|
10769
|
+
event.preventDefault();
|
|
10770
|
+
nextElement.focus();
|
|
10771
|
+
}
|
|
10772
|
+
};
|
|
10773
|
+
};
|
|
10774
|
+
var handleTimePickerKeyDown = function handleTimePickerKeyDown(event) {
|
|
10775
|
+
if (event.key !== 'Escape' || !isPickerOpened) return;
|
|
10776
|
+
handleCancel();
|
|
10777
|
+
};
|
|
10667
10778
|
return jsxRuntime.jsxs(StyledTimePickerContainer, __assign({
|
|
10668
10779
|
className: containerClasses,
|
|
10669
|
-
"data-testid": dataTestId
|
|
10780
|
+
"data-testid": dataTestId,
|
|
10781
|
+
onKeyDown: handleTimePickerKeyDown
|
|
10670
10782
|
}, {
|
|
10671
10783
|
children: [jsxRuntime.jsxs(xDatePickers.LocalizationProvider, __assign({
|
|
10672
10784
|
dateAdapter: AdapterDayjs.AdapterDayjs
|
|
@@ -10693,14 +10805,14 @@
|
|
|
10693
10805
|
required: required,
|
|
10694
10806
|
helperText: helperText,
|
|
10695
10807
|
error: error,
|
|
10696
|
-
focused:
|
|
10808
|
+
focused: isComponentReadOnly ? false : undefined,
|
|
10697
10809
|
InputProps: {
|
|
10698
10810
|
endAdornment: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
10699
10811
|
children: [error && jsxRuntime.jsx(DotIcon, {
|
|
10700
10812
|
className: "dot-error-icon",
|
|
10701
10813
|
"data-testid": dataTestId && dataTestId + "-input-error-icon",
|
|
10702
10814
|
iconId: "error-solid"
|
|
10703
|
-
}, void 0), !disableOpenPicker && !
|
|
10815
|
+
}, void 0), !disableOpenPicker && !isComponentReadOnly && !disabled && jsxRuntime.jsx(DotIconButton, {
|
|
10704
10816
|
"data-testid": dataTestId && dataTestId + "-open-btn",
|
|
10705
10817
|
iconId: "pending-clock",
|
|
10706
10818
|
onClick: function (_event) {
|
|
@@ -10719,17 +10831,17 @@
|
|
|
10719
10831
|
name: inputName
|
|
10720
10832
|
},
|
|
10721
10833
|
field: {
|
|
10722
|
-
readOnly:
|
|
10834
|
+
readOnly: isComponentReadOnly
|
|
10723
10835
|
}
|
|
10724
10836
|
},
|
|
10725
10837
|
value: time
|
|
10726
10838
|
}, void 0)]
|
|
10727
10839
|
}), void 0), jsxRuntime.jsx(material.Popper, __assign({
|
|
10840
|
+
anchorEl: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current,
|
|
10728
10841
|
className: "dot-time-picker-popper",
|
|
10729
10842
|
"data-testid": dataTestId && dataTestId + "-popper",
|
|
10730
|
-
open: isPickerOpened,
|
|
10731
|
-
anchorEl: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current,
|
|
10732
10843
|
disablePortal: true,
|
|
10844
|
+
open: isPickerOpened,
|
|
10733
10845
|
placement: "bottom-start"
|
|
10734
10846
|
}, {
|
|
10735
10847
|
children: jsxRuntime.jsx(material.ClickAwayListener, __assign({
|
|
@@ -10746,14 +10858,16 @@
|
|
|
10746
10858
|
className: "dot-time-picker-hours",
|
|
10747
10859
|
ref: hoursRef
|
|
10748
10860
|
}, {
|
|
10749
|
-
children: hours.map(function (hour) {
|
|
10750
|
-
var isSelected = pickerTime ?
|
|
10861
|
+
children: hours.map(function (hour, index) {
|
|
10862
|
+
var isSelected = pickerTime ? selectedPickerHour === hour : false;
|
|
10751
10863
|
return jsxRuntime.jsx(DotButton, __assign({
|
|
10752
10864
|
className: "dot-picker-button",
|
|
10753
10865
|
"data-testid": dataTestId && dataTestId + "-hour-button-" + hour,
|
|
10754
10866
|
onClick: function () {
|
|
10755
10867
|
return handleHourClick(hour);
|
|
10756
10868
|
},
|
|
10869
|
+
onKeyDown: handleTimeKeydown(hoursRef, index),
|
|
10870
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, selectedPickerHour),
|
|
10757
10871
|
type: isSelected ? 'primary' : 'text'
|
|
10758
10872
|
}, {
|
|
10759
10873
|
children: hour.toString().padStart(2, '0')
|
|
@@ -10763,7 +10877,7 @@
|
|
|
10763
10877
|
className: "dot-time-picker-minutes",
|
|
10764
10878
|
ref: minutesRef
|
|
10765
10879
|
}, {
|
|
10766
|
-
children: minutes.map(function (minute) {
|
|
10880
|
+
children: minutes.map(function (minute, index) {
|
|
10767
10881
|
var isSelected = pickerTime ? pickerTime.minute() === minute : false;
|
|
10768
10882
|
return jsxRuntime.jsx(DotButton, __assign({
|
|
10769
10883
|
className: "dot-picker-button",
|
|
@@ -10771,30 +10885,37 @@
|
|
|
10771
10885
|
type: isSelected ? 'primary' : 'text',
|
|
10772
10886
|
onClick: function () {
|
|
10773
10887
|
return handleMinuteClick(minute);
|
|
10774
|
-
}
|
|
10888
|
+
},
|
|
10889
|
+
onKeyDown: handleTimeKeydown(minutesRef, index),
|
|
10890
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, pickerTime === null || pickerTime === void 0 ? void 0 : pickerTime.minute())
|
|
10775
10891
|
}, {
|
|
10776
10892
|
children: minute.toString().padStart(2, '0')
|
|
10777
10893
|
}), minute);
|
|
10778
10894
|
})
|
|
10779
10895
|
}), void 0), ampm && jsxRuntime.jsxs("div", __assign({
|
|
10780
|
-
className: "dot-time-picker-daytime"
|
|
10896
|
+
className: "dot-time-picker-daytime",
|
|
10897
|
+
ref: daytimeRef
|
|
10781
10898
|
}, {
|
|
10782
10899
|
children: [jsxRuntime.jsx(DotButton, __assign({
|
|
10783
10900
|
className: "dot-picker-button",
|
|
10784
10901
|
"data-testid": dataTestId && dataTestId + "-am-button",
|
|
10785
|
-
type: daytimeSelected && daytimeSelected === exports.Daytime.AM ? 'primary' : 'text',
|
|
10786
10902
|
onClick: function () {
|
|
10787
10903
|
return handleDaytimeSelection(exports.Daytime.AM);
|
|
10788
|
-
}
|
|
10904
|
+
},
|
|
10905
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 0),
|
|
10906
|
+
tabIndex: getDaytimeButtonTabIndex(exports.Daytime.AM, daytimeSelected),
|
|
10907
|
+
type: daytimeSelected && daytimeSelected === exports.Daytime.AM ? 'primary' : 'text'
|
|
10789
10908
|
}, {
|
|
10790
10909
|
children: exports.Daytime.AM
|
|
10791
10910
|
}), exports.Daytime.AM), jsxRuntime.jsx(DotButton, __assign({
|
|
10792
10911
|
className: "dot-picker-button",
|
|
10793
10912
|
"data-testid": dataTestId && dataTestId + "-pm-button",
|
|
10794
|
-
type: daytimeSelected && daytimeSelected === exports.Daytime.PM ? 'primary' : 'text',
|
|
10795
10913
|
onClick: function () {
|
|
10796
10914
|
return handleDaytimeSelection(exports.Daytime.PM);
|
|
10797
|
-
}
|
|
10915
|
+
},
|
|
10916
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 1),
|
|
10917
|
+
tabIndex: getDaytimeButtonTabIndex(exports.Daytime.PM, daytimeSelected),
|
|
10918
|
+
type: getTimePickerButtonType(daytimeSelected)
|
|
10798
10919
|
}, {
|
|
10799
10920
|
children: exports.Daytime.PM
|
|
10800
10921
|
}), exports.Daytime.PM)]
|
|
@@ -10824,6 +10945,18 @@
|
|
|
10824
10945
|
}), void 0);
|
|
10825
10946
|
};
|
|
10826
10947
|
|
|
10948
|
+
var DotClickAwayListener = function DotClickAwayListener(_a) {
|
|
10949
|
+
var children = _a.children,
|
|
10950
|
+
_b = _a.disableReactTree,
|
|
10951
|
+
disableReactTree = _b === void 0 ? false : _b,
|
|
10952
|
+
onClickAway = _a.onClickAway;
|
|
10953
|
+
return jsxRuntime.jsx(material.ClickAwayListener, {
|
|
10954
|
+
children: children,
|
|
10955
|
+
disableReactTree: disableReactTree,
|
|
10956
|
+
onClickAway: onClickAway
|
|
10957
|
+
}, void 0);
|
|
10958
|
+
};
|
|
10959
|
+
|
|
10827
10960
|
exports.Cell = Cell;
|
|
10828
10961
|
exports.CreateUUID = CreateUUID;
|
|
10829
10962
|
exports.CssCell = CssCell;
|
|
@@ -10849,6 +10982,7 @@
|
|
|
10849
10982
|
exports.DotCheckbox = DotCheckbox;
|
|
10850
10983
|
exports.DotCheckboxGroup = DotCheckboxGroup;
|
|
10851
10984
|
exports.DotChip = DotChip;
|
|
10985
|
+
exports.DotClickAwayListener = DotClickAwayListener;
|
|
10852
10986
|
exports.DotConfirmationDialog = DotConfirmationDialog;
|
|
10853
10987
|
exports.DotCopyButton = DotCopyButton;
|
|
10854
10988
|
exports.DotCoreApiProvider = DotCoreApiProvider;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { KeyboardEventHandler, ReactNode } from 'react';
|
|
2
2
|
import { BaseButtonProps } from '../BaseButtonProps';
|
|
3
3
|
export interface ButtonProps extends BaseButtonProps {
|
|
4
4
|
/** The text for the button. Button text should be in sentence case. */
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
/** Icon placed after the children. */
|
|
7
7
|
endIcon?: ReactNode;
|
|
8
|
+
onKeyDown?: KeyboardEventHandler;
|
|
8
9
|
/** Icon placed before the children. */
|
|
9
10
|
startIcon?: ReactNode;
|
|
10
11
|
/** Tab order for the button. */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
export interface ClickAwayListenerProps {
|
|
3
|
+
/** The wrapped element. */
|
|
4
|
+
children: ReactElement;
|
|
5
|
+
/** If true, the React tree is ignored and only the DOM tree is considered. This prop changes how portaled elements are handled. */
|
|
6
|
+
disableReactTree?: boolean;
|
|
7
|
+
/** Callback fired when a "click away" event is detected. */
|
|
8
|
+
onClickAway: (event: MouseEvent | TouchEvent) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const DotClickAwayListener: ({ children, disableReactTree, onClickAway, }: ClickAwayListenerProps) => JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentMeta, Story } from '@storybook/react';
|
|
2
|
+
import { ClickAwayListenerProps } from './ClickAwayListener';
|
|
3
|
+
declare const _default: ComponentMeta<({ children, disableReactTree, onClickAway, }: ClickAwayListenerProps) => JSX.Element>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Default: Story<ClickAwayListenerProps>;
|
|
@@ -9,10 +9,14 @@ export interface DatePickerProps extends CommonProps {
|
|
|
9
9
|
autoFocus?: boolean;
|
|
10
10
|
/** If `true`, the popover or modal will close after submitting the full date. */
|
|
11
11
|
closeOnSelect?: boolean;
|
|
12
|
+
/** The default value. Use when the component is not controlled. */
|
|
13
|
+
defaultValue?: string;
|
|
12
14
|
/** If `true`, the open picker button will not be rendered (renders only the field). */
|
|
13
15
|
disableOpenPicker?: boolean;
|
|
14
16
|
/** If `true`, disable values before the current date for date components, time for time components and both for date time components. */
|
|
15
17
|
disablePast?: boolean;
|
|
18
|
+
/** Disable the portal behavior. If true, children stay within parent DOM hierarchy. */
|
|
19
|
+
disablePortal?: boolean;
|
|
16
20
|
/** If `true`, the picker and text field are disabled. */
|
|
17
21
|
disabled?: boolean;
|
|
18
22
|
/** If `true`, 'Clear' button will be displayed in the calendar popper. `True` by default. */
|
|
@@ -23,6 +27,8 @@ export interface DatePickerProps extends CommonProps {
|
|
|
23
27
|
error?: boolean;
|
|
24
28
|
/** Calendar will show more weeks in order to match this value. Put it to 6 for having fix number of week in Gregorian calendars */
|
|
25
29
|
fixedWeekNumber?: number;
|
|
30
|
+
/** If `true`, focus will be automatically set to the input field when popper opens */
|
|
31
|
+
focusInputOnPopperOpened?: boolean;
|
|
26
32
|
/** Format of the date when rendered in the input(s). Defaults to localized format based on the used `views`. */
|
|
27
33
|
format?: string;
|
|
28
34
|
/** If true, the input will take up the full width of its container */
|
|
@@ -37,6 +43,10 @@ export interface DatePickerProps extends CommonProps {
|
|
|
37
43
|
label?: string;
|
|
38
44
|
/** Locale for the date library you are using */
|
|
39
45
|
locale?: DatePickerLocale;
|
|
46
|
+
/** Maximal selectable date */
|
|
47
|
+
maxDate?: string;
|
|
48
|
+
/** Minimal selectable date. */
|
|
49
|
+
minDate?: string;
|
|
40
50
|
/** Callback fired when the value is accepted. */
|
|
41
51
|
onAccept?: (value: string) => void;
|
|
42
52
|
/** A function that should be executed when the input loses focus */
|
|
@@ -67,4 +77,4 @@ export interface DatePickerProps extends CommonProps {
|
|
|
67
77
|
/** The selected value. Used when the component is controlled. */
|
|
68
78
|
value?: string;
|
|
69
79
|
}
|
|
70
|
-
export declare const DotDatePicker: ({ ariaLabel, autoFocus, className, closeOnSelect, "data-testid": dataTestId, disableOpenPicker, disablePast, disabled, displayWeekNumber, displayClearButton, error, fixedWeekNumber, format, fullWidth, helperText, inputId, inputName, label, locale, onAccept, onBlur, onChange, onClose, onError, onOpen, open, persistentLabel, readOnly, required, showDaysOutsideCurrentMonth, value, }: DatePickerProps) => JSX.Element;
|
|
80
|
+
export declare const DotDatePicker: ({ ariaLabel, autoFocus, className, closeOnSelect, "data-testid": dataTestId, defaultValue, disableOpenPicker, disablePast, disablePortal, disabled, displayWeekNumber, displayClearButton, error, fixedWeekNumber, focusInputOnPopperOpened, format, fullWidth, helperText, inputId, inputName, label, locale, maxDate, minDate, onAccept, onBlur, onChange, onClose, onError, onOpen, open, persistentLabel, readOnly, required, showDaysOutsideCurrentMonth, value, }: DatePickerProps) => JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentMeta, Story } from '@storybook/react';
|
|
2
2
|
import { DatePickerProps } from './';
|
|
3
|
-
declare const _default: ComponentMeta<({ ariaLabel, autoFocus, className, closeOnSelect, "data-testid": dataTestId, disableOpenPicker, disablePast, disabled, displayWeekNumber, displayClearButton, error, fixedWeekNumber, format, fullWidth, helperText, inputId, inputName, label, locale, onAccept, onBlur, onChange, onClose, onError, onOpen, open, persistentLabel, readOnly, required, showDaysOutsideCurrentMonth, value, }: DatePickerProps) => JSX.Element>;
|
|
3
|
+
declare const _default: ComponentMeta<({ ariaLabel, autoFocus, className, closeOnSelect, "data-testid": dataTestId, defaultValue, disableOpenPicker, disablePast, disablePortal, disabled, displayWeekNumber, displayClearButton, error, fixedWeekNumber, focusInputOnPopperOpened, format, fullWidth, helperText, inputId, inputName, label, locale, maxDate, minDate, onAccept, onBlur, onChange, onClose, onError, onOpen, open, persistentLabel, readOnly, required, showDaysOutsideCurrentMonth, value, }: DatePickerProps) => JSX.Element>;
|
|
4
4
|
export default _default;
|
|
5
5
|
export declare const Default: DatePickerProps;
|
|
6
6
|
export declare const WithHelperText: any;
|
|
@@ -16,6 +16,16 @@ export declare const WithRequiredOption: any;
|
|
|
16
16
|
export declare const WithDaysOutsideOfCurrentMonth: any;
|
|
17
17
|
export declare const WithFullWidth: any;
|
|
18
18
|
export declare const WithoutClearButton: any;
|
|
19
|
+
export declare const WithConsoleWarning: any;
|
|
20
|
+
export declare const WithDefaultValue: any;
|
|
21
|
+
export declare const WithInputFocusOnPopperOpened: any;
|
|
19
22
|
export declare const WithControlledMode: Story<DatePickerProps>;
|
|
23
|
+
export declare const WithMinMaxDates: Story<DatePickerProps>;
|
|
20
24
|
export declare const WithLocaleConfiguration: Story<DatePickerProps>;
|
|
21
25
|
export declare const WithChangeOnBlur: Story<DatePickerProps>;
|
|
26
|
+
export declare const WithOpenedPopperInControlledMode: Story<DatePickerProps>;
|
|
27
|
+
export interface TaskDateViewContentProps {
|
|
28
|
+
date: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const TaskDateViewContent: ({ date }: TaskDateViewContentProps) => JSX.Element;
|
|
31
|
+
export declare const WithConditionalRendering: Story<DatePickerProps>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const datePickerWithControlledModeClassName = "dot-date-picker-with-controlled-mode";
|
|
2
2
|
export declare const datePickerWithLocaleClassName = "dot-date-picker-with-locale";
|
|
3
3
|
export declare const datePickerWithBlurClassName = "dot-date-picker-with-blur";
|
|
4
|
+
export declare const datePickerWithConditionalRenderingClassName = "dot-date-picker-with-conditional-rendering";
|
|
4
5
|
export declare const StyledDatePickerWithControlledMode: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
6
|
export declare const StyledDatePickerWithChangeOnBlur: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
7
|
export declare const StyledDatePickerWithLocale: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const StyledDatePickerWithConditionalRendering: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ReactNode, KeyboardEvent } from 'react';
|
|
2
2
|
import { TypographyVariant } from './typography/Typography';
|
|
3
3
|
import { AvatarColor } from './avatar/Avatar';
|
|
4
4
|
export declare const calculateNumberFromText: (text: string) => number;
|
|
@@ -9,3 +9,5 @@ export declare const isLowerCase: (str: string) => boolean;
|
|
|
9
9
|
export declare const isNumber: (num: unknown) => boolean;
|
|
10
10
|
export declare const renderNodeOrTypography: (content: string | ReactNode, typographyVariant?: TypographyVariant) => ReactNode;
|
|
11
11
|
export declare const searchString: (needle: string, haystack: string) => boolean;
|
|
12
|
+
export declare const checkIfArrowUpPressed: (event: KeyboardEvent) => boolean;
|
|
13
|
+
export declare const checkIfArrowDownPressed: (event: KeyboardEvent) => boolean;
|
|
@@ -35,6 +35,7 @@ export type { FileItemProps, FileUploadError, FileUploadProps, ListItemFile, Map
|
|
|
35
35
|
export type { LinearProgressColor, LinearProgressProps, LinearProgressVariant, } from './linear-progress';
|
|
36
36
|
export type { DatePickerLocale, DatePickerProps, FieldChangeHandlerContext, } from './date-picker';
|
|
37
37
|
export type { TimePickerProps } from './time-picker';
|
|
38
|
+
export type { ClickAwayListenerProps } from './click-away-listener';
|
|
38
39
|
export { DotAccordion } from './accordion/Accordion';
|
|
39
40
|
export { DotActionToolbar } from './action-toolbar/ActionToolbar';
|
|
40
41
|
export { DotAlertBanner } from './alert-banner/AlertBanner';
|
|
@@ -97,4 +98,5 @@ export { DotDraggableList } from './draggable-list';
|
|
|
97
98
|
export { DotLinearProgress } from './linear-progress';
|
|
98
99
|
export { DotDatePicker } from './date-picker';
|
|
99
100
|
export { Daytime, DotTimePicker, mockScrollIntoView } from './time-picker';
|
|
101
|
+
export { DotClickAwayListener } from './click-away-listener';
|
|
100
102
|
export { CreateUUID } from './createUUID';
|
|
@@ -6,6 +6,8 @@ export interface TimePickerProps extends CommonProps {
|
|
|
6
6
|
ampm?: boolean;
|
|
7
7
|
/** If `true`, the `input` element is focused during the first mount. */
|
|
8
8
|
autoFocus?: boolean;
|
|
9
|
+
/** The default value. Use when the component is not controlled. */
|
|
10
|
+
defaultValue?: string;
|
|
9
11
|
/** If `true`, the open picker button will not be rendered (renders only the field). */
|
|
10
12
|
disableOpenPicker?: boolean;
|
|
11
13
|
/** If `true`, the picker and text field are disabled. */
|
|
@@ -49,4 +51,4 @@ export interface TimePickerProps extends CommonProps {
|
|
|
49
51
|
export declare const DEFAULT_PICKER_TIME_FORMAT = "hh:mm";
|
|
50
52
|
export declare const DEFAULT_TIME_FORMAT = "hh:mm A";
|
|
51
53
|
export declare const DEFAULT_TIME = "01:00";
|
|
52
|
-
export declare const DotTimePicker: ({ ampm, ariaLabel, autoFocus, className, "data-testid": dataTestId, disableOpenPicker, disabled, error, format, fullWidth, helperText, hideActionButtons, inputId, inputName, label, onAccept, onBlur, onChange, onClose, onOpen, open, persistentLabel, readOnly, required, value, }: TimePickerProps) => JSX.Element;
|
|
54
|
+
export declare const DotTimePicker: ({ ampm, ariaLabel, autoFocus, className, "data-testid": dataTestId, defaultValue, disableOpenPicker, disabled, error, format, fullWidth, helperText, hideActionButtons, inputId, inputName, label, onAccept, onBlur, onChange, onClose, onOpen, open, persistentLabel, readOnly, required, value, }: TimePickerProps) => JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentMeta, Story } from '@storybook/react';
|
|
2
2
|
import { TimePickerProps } from './';
|
|
3
|
-
declare const _default: ComponentMeta<({ ampm, ariaLabel, autoFocus, className, "data-testid": dataTestId, disableOpenPicker, disabled, error, format, fullWidth, helperText, hideActionButtons, inputId, inputName, label, onAccept, onBlur, onChange, onClose, onOpen, open, persistentLabel, readOnly, required, value, }: TimePickerProps) => JSX.Element>;
|
|
3
|
+
declare const _default: ComponentMeta<({ ampm, ariaLabel, autoFocus, className, "data-testid": dataTestId, defaultValue, disableOpenPicker, disabled, error, format, fullWidth, helperText, hideActionButtons, inputId, inputName, label, onAccept, onBlur, onChange, onClose, onOpen, open, persistentLabel, readOnly, required, value, }: TimePickerProps) => JSX.Element>;
|
|
4
4
|
export default _default;
|
|
5
5
|
export declare const Default: TimePickerProps;
|
|
6
6
|
export declare const WithAutoFocus: any;
|
|
@@ -15,6 +15,8 @@ export declare const WithReadOnly: any;
|
|
|
15
15
|
export declare const WithHelperText: any;
|
|
16
16
|
export declare const WithRequiredOption: any;
|
|
17
17
|
export declare const WithOpenedTimePopper: any;
|
|
18
|
+
export declare const WithConsoleWarning: any;
|
|
19
|
+
export declare const WithDefaultValue: any;
|
|
18
20
|
export declare const WithControlledMode: Story<TimePickerProps>;
|
|
19
21
|
export declare const WithHourFormatPicker: Story<TimePickerProps>;
|
|
20
22
|
export declare const WithOutsideTimeSetter: Story<TimePickerProps>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import dayjs, { Dayjs } from 'dayjs';
|
|
2
2
|
import { Daytime } from './models';
|
|
3
|
+
import { ButtonType } from '../../BaseButtonProps';
|
|
3
4
|
export declare const getDayjsUtcDate: (value: string, timeFormat?: string) => dayjs.Dayjs;
|
|
4
5
|
export declare const createNumbersArray: (length: number, offset?: number) => number[];
|
|
5
6
|
export declare const getHoursForTimePicker: (hasDaytimeSelection: boolean) => number[];
|
|
@@ -9,3 +10,7 @@ export declare const calculateTimeForHourSelection: (is12hourFormat: boolean, se
|
|
|
9
10
|
export declare const calculateTimeForDaytimeSelection: (currentTime: Dayjs, selectedDaytime: Daytime) => Dayjs;
|
|
10
11
|
export declare const calculateHourBasedOnTimeFormat: (time: Dayjs, is12hourFormat: boolean) => number;
|
|
11
12
|
export declare const getSelectedHourButtonIndex: (selectedHour: number, is12HourFormat: boolean) => number;
|
|
13
|
+
export declare const getPopperButtonTabIndex: (index: number, isSelected: boolean, selectedValue?: number) => number | undefined;
|
|
14
|
+
export declare const getDaytimeButtonTabIndex: (currentDaytime: Daytime, selectedDaytime?: string) => number | undefined;
|
|
15
|
+
export declare const getSelectedDaytime: (dateTime?: Dayjs) => string;
|
|
16
|
+
export declare const getTimePickerButtonType: (selectedDaytime: string) => ButtonType;
|
|
@@ -56,5 +56,6 @@ declare const renderWithTheme: (ui: ReactNode) => {
|
|
|
56
56
|
findByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions, waitForElementOptions?: import("@testing-library/react").waitForOptions) => Promise<HTMLElement>;
|
|
57
57
|
findAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions, waitForElementOptions?: import("@testing-library/react").waitForOptions) => Promise<HTMLElement[]>;
|
|
58
58
|
};
|
|
59
|
+
declare const rerenderWithTheme: (rerenderFn: (ui: ReactNode) => void, ui: ReactNode) => void;
|
|
59
60
|
export * from '@testing-library/react';
|
|
60
|
-
export { renderWithTheme as render };
|
|
61
|
+
export { renderWithTheme as render, rerenderWithTheme as rerender };
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
declare type ScrollIntoViewMock = (arg?: boolean | ScrollIntoViewOptions) => void;
|
|
2
|
+
export declare const mockScrollIntoView: (scrollIntoViewMock: ScrollIntoViewMock) => void;
|
|
3
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digital-ai/dot-components",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE.md>",
|
|
6
6
|
"contributors": [
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"@emotion/react": "^11.10.4",
|
|
29
29
|
"@emotion/styled": "^11.10.4",
|
|
30
30
|
"@mui/material": "^5.2.5",
|
|
31
|
-
"@mui/styles": "^5.2.3",
|
|
32
31
|
"@mui/x-date-pickers": "^6.0.1",
|
|
33
32
|
"jwt-decode": "^3.1.2",
|
|
34
33
|
"react-dropzone": "^11.4.2",
|