@digital-ai/dot-components 2.6.1 → 2.7.1
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 +36 -9
- package/index.esm.js +123 -35
- package/index.umd.js +142 -37
- package/lib/components/button/Button.d.ts +4 -1
- package/lib/components/button/Button.stories.d.ts +4 -3
- package/lib/components/button/Button.stories.styles.d.ts +2 -0
- package/lib/components/date-picker/DatePicker.d.ts +10 -2
- package/lib/components/date-picker/DatePicker.stories.d.ts +6 -1
- package/lib/components/date-picker/DatePicker.stories.styles.d.ts +2 -0
- package/lib/components/helpers.d.ts +3 -1
- package/lib/components/time-picker/TimePicker.d.ts +8 -2
- package/lib/components/time-picker/TimePicker.stories.d.ts +4 -1
- package/lib/components/time-picker/TimePicker.stories.styles.d.ts +2 -0
- 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,36 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.7.1](https://www.npmjs.com/package/@digital-ai/dot-components) (04/20/2023)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/2.7.0...2.7.1)
|
|
6
|
+
|
|
7
|
+
**Features:**
|
|
8
|
+
|
|
9
|
+
- S-91943: `DotDatePicker` - add `minDate` and `maxDate` props [\#1450](https://github.com/digital-ai/dot-components/pull/1450) ([dmiletic85](https://github.com/dmiletic85))
|
|
10
|
+
|
|
11
|
+
**Fixed bugs:**
|
|
12
|
+
|
|
13
|
+
- `DotTimePicker`, `DotDatePicker`: fix issues with controlled and uncontrolled states [\#1454](https://github.com/digital-ai/dot-components/pull/1454) ([dmiletic85](https://github.com/dmiletic85))
|
|
14
|
+
- 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))
|
|
15
|
+
|
|
16
|
+
**Misc:**
|
|
17
|
+
|
|
18
|
+
- S-91314: Remove use of deprecated `StylesProvider` [\#1457](https://github.com/digital-ai/dot-components/pull/1457) ([CWSites](https://github.com/CWSites))
|
|
19
|
+
- S-91975: `TimePicker` - Improve keyboard access [\#1455](https://github.com/digital-ai/dot-components/pull/1455) ([dmiletic85](https://github.com/dmiletic85))
|
|
20
|
+
|
|
21
|
+
## [2.7.0](https://www.npmjs.com/package/@digital-ai/dot-components) (04/14/2023)
|
|
22
|
+
|
|
23
|
+
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/2.6.1...2.7.0)
|
|
24
|
+
|
|
25
|
+
**Features:**
|
|
26
|
+
|
|
27
|
+
- S-91919: `DotDatePicker`, `DotTimePicker`: expose `onBlur` prop [\#1443](https://github.com/digital-ai/dot-components/pull/1443) ([dmiletic85](https://github.com/dmiletic85))
|
|
28
|
+
- S-91870 `DotButton`: expose `tabIndex` prop [\#1439](https://github.com/digital-ai/dot-components/pull/1439) ([dmiletic85](https://github.com/dmiletic85))
|
|
29
|
+
|
|
30
|
+
**Fixed bugs:**
|
|
31
|
+
|
|
32
|
+
- D-24793: `DotTimePicker` - set clock instead of calendar icon [\#1444](https://github.com/digital-ai/dot-components/pull/1444) ([dmiletic85](https://github.com/dmiletic85))
|
|
33
|
+
|
|
3
34
|
## [2.6.1](https://www.npmjs.com/package/@digital-ai/dot-components) (04/06/2023)
|
|
4
35
|
|
|
5
36
|
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/2.6.0...2.6.1)
|
|
@@ -292,10 +323,6 @@
|
|
|
292
323
|
|
|
293
324
|
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/1.21.4...2.0.0-rc.3)
|
|
294
325
|
|
|
295
|
-
**Features:**
|
|
296
|
-
|
|
297
|
-
- S-87620 Adjust height for inputs and for medium sized buttons [\#1263](https://github.com/digital-ai/dot-components/pull/1263) ([nikolinadapic](https://github.com/nikolinadapic))
|
|
298
|
-
|
|
299
326
|
**Fixed bugs:**
|
|
300
327
|
|
|
301
328
|
- D-22512: Design differences between 2.0 and 1.x [\#1285](https://github.com/digital-ai/dot-components/pull/1285) ([CWSites](https://github.com/CWSites))
|
|
@@ -313,6 +340,7 @@
|
|
|
313
340
|
**Features:**
|
|
314
341
|
|
|
315
342
|
- S-87871 Expose callback when sidebar collapses/expands [\#1274](https://github.com/digital-ai/dot-components/pull/1274) ([angel-git](https://github.com/angel-git))
|
|
343
|
+
- S-87620 Adjust height for inputs and for medium sized buttons [\#1263](https://github.com/digital-ai/dot-components/pull/1263) ([nikolinadapic](https://github.com/nikolinadapic))
|
|
316
344
|
|
|
317
345
|
**Fixed bugs:**
|
|
318
346
|
|
|
@@ -354,6 +382,7 @@
|
|
|
354
382
|
|
|
355
383
|
**Fixed bugs:**
|
|
356
384
|
|
|
385
|
+
- S-86692: component cleanup [\#1238](https://github.com/digital-ai/dot-components/pull/1238) ([CWSites](https://github.com/CWSites))
|
|
357
386
|
- S-84151: fix e2e tests for Release 2.0 [\#1146](https://github.com/digital-ai/dot-components/pull/1146) ([CWSites](https://github.com/CWSites))
|
|
358
387
|
|
|
359
388
|
**Misc:**
|
|
@@ -384,7 +413,6 @@
|
|
|
384
413
|
|
|
385
414
|
**Fixed bugs:**
|
|
386
415
|
|
|
387
|
-
- S-86692: component cleanup [\#1238](https://github.com/digital-ai/dot-components/pull/1238) ([CWSites](https://github.com/CWSites))
|
|
388
416
|
- D-20931: `DotAccordion` - display top border correctly when expanded [\#1232](https://github.com/digital-ai/dot-components/pull/1232) ([CWSites](https://github.com/CWSites))
|
|
389
417
|
- D-22087: `DotRadioGroup` / `DotCheckboxGroup` helper texts do not follow the same styles as other helper texts [\#1225](https://github.com/digital-ai/dot-components/pull/1225) ([dmiletic85](https://github.com/dmiletic85))
|
|
390
418
|
|
|
@@ -497,7 +525,6 @@
|
|
|
497
525
|
|
|
498
526
|
**Fixed bugs:**
|
|
499
527
|
|
|
500
|
-
- S-84816: `InlineEdit`: Disable Save button when value contains only spaces [\#1156](https://github.com/digital-ai/dot-components/pull/1156) ([dmiletic85](https://github.com/dmiletic85))
|
|
501
528
|
- D-20958: Safari animation jitter [\#1154](https://github.com/digital-ai/dot-components/pull/1154) ([CWSites](https://github.com/CWSites))
|
|
502
529
|
|
|
503
530
|
**Misc:**
|
|
@@ -514,6 +541,7 @@
|
|
|
514
541
|
|
|
515
542
|
**Fixed bugs:**
|
|
516
543
|
|
|
544
|
+
- S-84816: `InlineEdit`: Disable Save button when value contains only spaces [\#1156](https://github.com/digital-ai/dot-components/pull/1156) ([dmiletic85](https://github.com/dmiletic85))
|
|
517
545
|
- D-20970: DotTableActions component [\#1134](https://github.com/digital-ai/dot-components/pull/1134) ([selsemore](https://github.com/selsemore))
|
|
518
546
|
- D-20359: only display tooltip if string [\#1127](https://github.com/digital-ai/dot-components/pull/1127) ([CWSites](https://github.com/CWSites))
|
|
519
547
|
|
|
@@ -895,7 +923,6 @@
|
|
|
895
923
|
- S-79571: DotInput - expose onKeyDown [\#846](https://github.com/digital-ai/dot-components/pull/846) ([monapatel91](https://github.com/monapatel91))
|
|
896
924
|
- S-79357: evaluate codebase and remove old references to core Tooltip [\#844](https://github.com/digital-ai/dot-components/pull/844) ([CWSites](https://github.com/CWSites))
|
|
897
925
|
- S-80621: file upload [\#840](https://github.com/digital-ai/dot-components/pull/840) ([CWSites](https://github.com/CWSites))
|
|
898
|
-
- S-80473: Expose onFocus and onBlur callbacks for DotInputText and DotInputSelect components [\#832](https://github.com/digital-ai/dot-components/pull/832) ([selsemore](https://github.com/selsemore))
|
|
899
926
|
- S-76922: file upload [\#820](https://github.com/digital-ai/dot-components/pull/820) ([CWSites](https://github.com/CWSites))
|
|
900
927
|
|
|
901
928
|
**Fixed bugs:**
|
|
@@ -914,6 +941,7 @@
|
|
|
914
941
|
|
|
915
942
|
**Features:**
|
|
916
943
|
|
|
944
|
+
- S-80473: Expose onFocus and onBlur callbacks for DotInputText and DotInputSelect components [\#832](https://github.com/digital-ai/dot-components/pull/832) ([selsemore](https://github.com/selsemore))
|
|
917
945
|
- S-80268: `DotDynamicForm` improvements [\#821](https://github.com/digital-ai/dot-components/pull/821) ([dmiletic85](https://github.com/dmiletic85))
|
|
918
946
|
|
|
919
947
|
**Fixed bugs:**
|
|
@@ -1090,6 +1118,7 @@
|
|
|
1090
1118
|
|
|
1091
1119
|
- MINOR release [\#695](https://github.com/digital-ai/dot-components/pull/695) ([CWSites](https://github.com/CWSites))
|
|
1092
1120
|
- pass value to tab [\#694](https://github.com/digital-ai/dot-components/pull/694) ([kmmarsh](https://github.com/kmmarsh))
|
|
1121
|
+
- S-78831: update AppToolbar component for Agility [\#691](https://github.com/digital-ai/dot-components/pull/691) ([CWSites](https://github.com/CWSites))
|
|
1093
1122
|
|
|
1094
1123
|
## [1.0.12](https://www.npmjs.com/package/@digital-ai/dot-components) (09/23/2021)
|
|
1095
1124
|
|
|
@@ -1108,7 +1137,6 @@
|
|
|
1108
1137
|
|
|
1109
1138
|
**Misc:**
|
|
1110
1139
|
|
|
1111
|
-
- S-78831: update AppToolbar component for Agility [\#691](https://github.com/digital-ai/dot-components/pull/691) ([CWSites](https://github.com/CWSites))
|
|
1112
1140
|
- Next Release [\#689](https://github.com/digital-ai/dot-components/pull/689) ([CWSites](https://github.com/CWSites))
|
|
1113
1141
|
|
|
1114
1142
|
## [1.0.11](https://www.npmjs.com/package/@digital-ai/dot-components) (09/16/2021)
|
|
@@ -1238,7 +1266,6 @@
|
|
|
1238
1266
|
- S-77681: setup test-coverage for reporting on dot-components [\#610](https://github.com/digital-ai/dot-components/pull/610) ([CWSites](https://github.com/CWSites))
|
|
1239
1267
|
- S-76838: address Sonarcloud code issues [\#608](https://github.com/digital-ai/dot-components/pull/608) ([CWSites](https://github.com/CWSites))
|
|
1240
1268
|
- S-77317: Add 'height' prop to DotDrawer component [\#603](https://github.com/digital-ai/dot-components/pull/603) ([selsemore](https://github.com/selsemore))
|
|
1241
|
-
- Update GitHub prerelease [\#599](https://github.com/digital-ai/dot-components/pull/599) ([CWSites](https://github.com/CWSites))
|
|
1242
1269
|
- S-76917: remove progressionBoard styles from theme provider [\#597](https://github.com/digital-ai/dot-components/pull/597) ([CWSites](https://github.com/CWSites))
|
|
1243
1270
|
|
|
1244
1271
|
## [1.0.3](https://www.npmjs.com/package/@digital-ai/dot-components) (07/27/2021)
|
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,8 +1729,10 @@ 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,
|
|
1735
|
+
tabIndex,
|
|
1733
1736
|
tooltip,
|
|
1734
1737
|
type: _type = 'primary'
|
|
1735
1738
|
}, ref) => {
|
|
@@ -1770,9 +1773,11 @@ const DotButton = /*#__PURE__*/forwardRef(({
|
|
|
1770
1773
|
endIcon: endIcon,
|
|
1771
1774
|
fullWidth: _fullWidth,
|
|
1772
1775
|
onClick: event => onClick && onClick(event),
|
|
1776
|
+
onKeyDown: onKeyDown,
|
|
1773
1777
|
ref: ref,
|
|
1774
1778
|
size: _size,
|
|
1775
1779
|
startIcon: startIcon,
|
|
1780
|
+
tabIndex: tabIndex,
|
|
1776
1781
|
type: _isSubmit ? 'submit' : 'button',
|
|
1777
1782
|
variant: variant
|
|
1778
1783
|
}, {
|
|
@@ -9477,6 +9482,7 @@ const DotDatePicker = ({
|
|
|
9477
9482
|
className,
|
|
9478
9483
|
closeOnSelect: _closeOnSelect = true,
|
|
9479
9484
|
'data-testid': dataTestId,
|
|
9485
|
+
defaultValue,
|
|
9480
9486
|
disableOpenPicker,
|
|
9481
9487
|
disablePast,
|
|
9482
9488
|
disabled,
|
|
@@ -9491,7 +9497,10 @@ const DotDatePicker = ({
|
|
|
9491
9497
|
inputName,
|
|
9492
9498
|
label,
|
|
9493
9499
|
locale,
|
|
9500
|
+
maxDate,
|
|
9501
|
+
minDate,
|
|
9494
9502
|
onAccept,
|
|
9503
|
+
onBlur,
|
|
9495
9504
|
onChange,
|
|
9496
9505
|
onClose,
|
|
9497
9506
|
onError,
|
|
@@ -9503,8 +9512,20 @@ const DotDatePicker = ({
|
|
|
9503
9512
|
showDaysOutsideCurrentMonth,
|
|
9504
9513
|
value
|
|
9505
9514
|
}) => {
|
|
9506
|
-
const
|
|
9515
|
+
const dateFormat = format || 'YYYY-MM-DD';
|
|
9516
|
+
const hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
9517
|
+
const hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
9518
|
+
const isInputReadOnly = _readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
9519
|
+
const rootClasses = useStylesWithRootClass(rootClassName$1, className, isInputReadOnly ? 'read-only' : '');
|
|
9507
9520
|
const containerClasses = useStylesWithRootClass(containerClassName$1, _fullWidth ? 'full-width' : '', className);
|
|
9521
|
+
useEffect(() => {
|
|
9522
|
+
if (hasValueWithoutChangeHandler) {
|
|
9523
|
+
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`.');
|
|
9524
|
+
}
|
|
9525
|
+
if (hasBothValueAndDefaultValue) {
|
|
9526
|
+
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.');
|
|
9527
|
+
}
|
|
9528
|
+
}, []);
|
|
9508
9529
|
useEffect(() => {
|
|
9509
9530
|
if (!locale) return;
|
|
9510
9531
|
const userLocaleName = dayjs.locale();
|
|
@@ -9512,7 +9533,6 @@ const DotDatePicker = ({
|
|
|
9512
9533
|
dayjs.extend(updateLocale);
|
|
9513
9534
|
dayjs.updateLocale(userLocaleName, Object.assign(Object.assign({}, userLocaleProps), locale));
|
|
9514
9535
|
}, [locale]);
|
|
9515
|
-
const dateFormat = format || 'YYYY-MM-DD';
|
|
9516
9536
|
const handleChange = (changedValue, context) => {
|
|
9517
9537
|
if (!onChange || changedValue && !changedValue.isValid()) return;
|
|
9518
9538
|
onChange(changedValue ? changedValue.format(dateFormat) : null, context);
|
|
@@ -9521,6 +9541,7 @@ const DotDatePicker = ({
|
|
|
9521
9541
|
if (!onAccept) return;
|
|
9522
9542
|
onAccept(changedValue ? changedValue.format(dateFormat) : null);
|
|
9523
9543
|
};
|
|
9544
|
+
const handleError = (validationError, currentValue) => onError === null || onError === void 0 ? void 0 : onError(validationError, dayjs(currentValue).format(dateFormat));
|
|
9524
9545
|
const createActionBar = () => {
|
|
9525
9546
|
const actionBar = {
|
|
9526
9547
|
actions: []
|
|
@@ -9549,17 +9570,20 @@ const DotDatePicker = ({
|
|
|
9549
9570
|
autoFocus: _autoFocus,
|
|
9550
9571
|
closeOnSelect: _closeOnSelect,
|
|
9551
9572
|
className: rootClasses,
|
|
9552
|
-
|
|
9573
|
+
defaultValue: defaultValue && dayjs(defaultValue, dateFormat),
|
|
9574
|
+
disableOpenPicker: disableOpenPicker || isInputReadOnly || disabled,
|
|
9553
9575
|
disablePast: disablePast,
|
|
9554
9576
|
disabled: disabled,
|
|
9555
9577
|
displayWeekNumber: displayWeekNumber,
|
|
9556
9578
|
fixedWeekNumber: fixedWeekNumber,
|
|
9557
|
-
format:
|
|
9579
|
+
format: dateFormat,
|
|
9558
9580
|
label: persistentLabel ? null : label,
|
|
9581
|
+
maxDate: maxDate && dayjs(maxDate, dateFormat),
|
|
9582
|
+
minDate: minDate && dayjs(minDate, dateFormat),
|
|
9559
9583
|
onAccept: handleAccept,
|
|
9560
9584
|
onChange: handleChange,
|
|
9561
9585
|
onClose: onClose,
|
|
9562
|
-
onError:
|
|
9586
|
+
onError: handleError,
|
|
9563
9587
|
onOpen: onOpen,
|
|
9564
9588
|
open: open,
|
|
9565
9589
|
showDaysOutsideCurrentMonth: showDaysOutsideCurrentMonth,
|
|
@@ -9584,19 +9608,23 @@ const DotDatePicker = ({
|
|
|
9584
9608
|
required: _required,
|
|
9585
9609
|
helperText,
|
|
9586
9610
|
error,
|
|
9587
|
-
focused:
|
|
9611
|
+
focused: isInputReadOnly ? false : undefined,
|
|
9588
9612
|
inputProps: {
|
|
9589
9613
|
className: 'dot-input',
|
|
9590
|
-
'data-testid': 'dot-date-picker-input'
|
|
9614
|
+
'data-testid': 'dot-date-picker-input',
|
|
9615
|
+
onBlur
|
|
9591
9616
|
},
|
|
9592
9617
|
fullWidth: _fullWidth,
|
|
9593
9618
|
name: inputName
|
|
9594
9619
|
},
|
|
9595
9620
|
field: {
|
|
9596
|
-
readOnly:
|
|
9621
|
+
readOnly: isInputReadOnly
|
|
9622
|
+
},
|
|
9623
|
+
desktopTrapFocus: {
|
|
9624
|
+
disableEnforceFocus: true
|
|
9597
9625
|
}
|
|
9598
9626
|
},
|
|
9599
|
-
value: value && dayjs(value)
|
|
9627
|
+
value: value && dayjs(value, dateFormat)
|
|
9600
9628
|
}, void 0)]
|
|
9601
9629
|
}), void 0)
|
|
9602
9630
|
}), void 0);
|
|
@@ -9661,6 +9689,10 @@ const getSelectedHourButtonIndex = (selectedHour, is12HourFormat) => {
|
|
|
9661
9689
|
return selectedHour;
|
|
9662
9690
|
}
|
|
9663
9691
|
};
|
|
9692
|
+
const getPopperButtonTabIndex = (index, isSelected, selectedValue) => selectedValue && isSelected || !selectedValue && index === 0 ? undefined : -1;
|
|
9693
|
+
const getDaytimeButtonTabIndex = (currentDaytime, selectedDaytime) => selectedDaytime && currentDaytime === selectedDaytime || !selectedDaytime && currentDaytime === Daytime.AM ? undefined : -1;
|
|
9694
|
+
const getSelectedDaytime = dateTime => dateTime && dateTime.format('A') || Daytime.AM;
|
|
9695
|
+
const getTimePickerButtonType = selectedDaytime => selectedDaytime && selectedDaytime === Daytime.PM ? 'primary' : 'text';
|
|
9664
9696
|
|
|
9665
9697
|
const rootClassName = 'dot-time-picker';
|
|
9666
9698
|
const containerClassName = 'dot-time-picker-container';
|
|
@@ -9691,6 +9723,7 @@ const DotTimePicker = ({
|
|
|
9691
9723
|
autoFocus: _autoFocus = false,
|
|
9692
9724
|
className,
|
|
9693
9725
|
'data-testid': dataTestId,
|
|
9726
|
+
defaultValue,
|
|
9694
9727
|
disableOpenPicker: _disableOpenPicker = false,
|
|
9695
9728
|
disabled,
|
|
9696
9729
|
error,
|
|
@@ -9701,6 +9734,8 @@ const DotTimePicker = ({
|
|
|
9701
9734
|
inputId,
|
|
9702
9735
|
inputName,
|
|
9703
9736
|
label,
|
|
9737
|
+
onAccept,
|
|
9738
|
+
onBlur,
|
|
9704
9739
|
onChange,
|
|
9705
9740
|
onClose,
|
|
9706
9741
|
onOpen,
|
|
@@ -9710,24 +9745,43 @@ const DotTimePicker = ({
|
|
|
9710
9745
|
required: _required = false,
|
|
9711
9746
|
value
|
|
9712
9747
|
}) => {
|
|
9713
|
-
const
|
|
9748
|
+
const timeFormat = format || DEFAULT_TIME_FORMAT;
|
|
9749
|
+
const hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
9750
|
+
const hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
9751
|
+
const isComponentReadOnly = _readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
9752
|
+
const rootClasses = useStylesWithRootClass(rootClassName, className, isComponentReadOnly ? 'read-only' : '');
|
|
9714
9753
|
const containerClasses = useStylesWithRootClass(containerClassName, _fullWidth ? 'full-width' : '', className);
|
|
9715
9754
|
const inputRef = useRef(null);
|
|
9716
9755
|
const [isPickerOpened, setIsPickerOpened] = useState(false);
|
|
9717
|
-
const timeFormat = format || DEFAULT_TIME_FORMAT;
|
|
9718
9756
|
const [time, setTime] = useState(null);
|
|
9719
9757
|
const [pickerTime, setPickerTime] = useState();
|
|
9720
9758
|
const hoursRef = useRef(null);
|
|
9721
9759
|
const minutesRef = useRef(null);
|
|
9760
|
+
const daytimeRef = useRef(null);
|
|
9722
9761
|
const hours = getHoursForTimePicker(_ampm);
|
|
9723
9762
|
const minutes = getMinutesForTimePicker();
|
|
9724
|
-
const daytimeSelected = pickerTime
|
|
9763
|
+
const daytimeSelected = getSelectedDaytime(pickerTime);
|
|
9764
|
+
const selectedPickerHour = pickerTime && calculateHourBasedOnTimeFormat(pickerTime, _ampm);
|
|
9725
9765
|
const isOpenPropDefined = open !== null && open !== undefined;
|
|
9766
|
+
const isControlledComponent = onChange && value !== undefined;
|
|
9767
|
+
useEffect(() => {
|
|
9768
|
+
if (hasValueWithoutChangeHandler) {
|
|
9769
|
+
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`.');
|
|
9770
|
+
}
|
|
9771
|
+
if (hasBothValueAndDefaultValue) {
|
|
9772
|
+
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.');
|
|
9773
|
+
}
|
|
9774
|
+
}, []);
|
|
9726
9775
|
useEffect(() => {
|
|
9727
|
-
|
|
9776
|
+
let timeValue = null;
|
|
9777
|
+
if (defaultValue) {
|
|
9778
|
+
timeValue = getDayjsUtcDate(defaultValue, timeFormat);
|
|
9779
|
+
} else if (value) {
|
|
9780
|
+
timeValue = getDayjsUtcDate(value, timeFormat);
|
|
9781
|
+
}
|
|
9728
9782
|
setTime(timeValue);
|
|
9729
9783
|
setPickerTime(timeValue);
|
|
9730
|
-
}, [value]);
|
|
9784
|
+
}, [value, defaultValue]);
|
|
9731
9785
|
useLayoutEffect(() => {
|
|
9732
9786
|
if (isPickerOpened && time) {
|
|
9733
9787
|
scrollToSelectedTime();
|
|
@@ -9746,7 +9800,9 @@ const DotTimePicker = ({
|
|
|
9746
9800
|
setPickerTime(pickedDateTime);
|
|
9747
9801
|
};
|
|
9748
9802
|
const handleInputChange = (currentValue, context) => {
|
|
9803
|
+
const currentTimeValue = currentValue ? currentValue : null;
|
|
9749
9804
|
setPickerTime(currentValue ? currentValue : null);
|
|
9805
|
+
!isControlledComponent && setTime(currentTimeValue);
|
|
9750
9806
|
onChange === null || onChange === void 0 ? void 0 : onChange(currentValue ? currentValue.format(timeFormat) : null, context);
|
|
9751
9807
|
};
|
|
9752
9808
|
const handleClose = () => {
|
|
@@ -9775,11 +9831,16 @@ const DotTimePicker = ({
|
|
|
9775
9831
|
handleClose();
|
|
9776
9832
|
};
|
|
9777
9833
|
const handleSet = () => {
|
|
9778
|
-
|
|
9834
|
+
if (!pickerTime) {
|
|
9835
|
+
handleClose();
|
|
9836
|
+
return;
|
|
9837
|
+
}
|
|
9779
9838
|
setTime(pickerTime);
|
|
9780
9839
|
onChange === null || onChange === void 0 ? void 0 : onChange(pickerTime.format(timeFormat), {
|
|
9781
9840
|
validationError: null
|
|
9782
9841
|
});
|
|
9842
|
+
onAccept === null || onAccept === void 0 ? void 0 : onAccept(pickerTime.format(timeFormat));
|
|
9843
|
+
handleClose();
|
|
9783
9844
|
};
|
|
9784
9845
|
const scrollToSelectedTime = () => {
|
|
9785
9846
|
if (!(hoursRef === null || hoursRef === void 0 ? void 0 : hoursRef.current) || !(minutesRef === null || minutesRef === void 0 ? void 0 : minutesRef.current)) return;
|
|
@@ -9797,9 +9858,26 @@ const DotTimePicker = ({
|
|
|
9797
9858
|
minutesRef.current.children[selectedMinute].scrollIntoView(scrollOptions);
|
|
9798
9859
|
}
|
|
9799
9860
|
};
|
|
9861
|
+
const handleTimeKeydown = (ref, index) => event => {
|
|
9862
|
+
const numberOfElements = ref.current.children.length;
|
|
9863
|
+
const prevElement = index > 0 && ref.current.children[index - 1];
|
|
9864
|
+
const nextElement = index < numberOfElements - 1 && ref.current.children[index + 1];
|
|
9865
|
+
if (checkIfArrowUpPressed(event) && prevElement) {
|
|
9866
|
+
event.preventDefault();
|
|
9867
|
+
prevElement.focus();
|
|
9868
|
+
} else if (checkIfArrowDownPressed(event) && nextElement) {
|
|
9869
|
+
event.preventDefault();
|
|
9870
|
+
nextElement.focus();
|
|
9871
|
+
}
|
|
9872
|
+
};
|
|
9873
|
+
const handleTimePickerKeyDown = event => {
|
|
9874
|
+
if (event.key !== 'Escape' || !isPickerOpened) return;
|
|
9875
|
+
handleCancel();
|
|
9876
|
+
};
|
|
9800
9877
|
return jsxs(StyledTimePickerContainer, Object.assign({
|
|
9801
9878
|
className: containerClasses,
|
|
9802
|
-
"data-testid": dataTestId
|
|
9879
|
+
"data-testid": dataTestId,
|
|
9880
|
+
onKeyDown: handleTimePickerKeyDown
|
|
9803
9881
|
}, {
|
|
9804
9882
|
children: [jsxs(LocalizationProvider, Object.assign({
|
|
9805
9883
|
dateAdapter: AdapterDayjs
|
|
@@ -9826,16 +9904,16 @@ const DotTimePicker = ({
|
|
|
9826
9904
|
required: _required,
|
|
9827
9905
|
helperText,
|
|
9828
9906
|
error,
|
|
9829
|
-
focused:
|
|
9907
|
+
focused: isComponentReadOnly ? false : undefined,
|
|
9830
9908
|
InputProps: {
|
|
9831
9909
|
endAdornment: jsxs(Fragment$1, {
|
|
9832
9910
|
children: [error && jsx(DotIcon, {
|
|
9833
9911
|
className: "dot-error-icon",
|
|
9834
9912
|
"data-testid": dataTestId && `${dataTestId}-input-error-icon`,
|
|
9835
9913
|
iconId: "error-solid"
|
|
9836
|
-
}, void 0), !_disableOpenPicker && !
|
|
9914
|
+
}, void 0), !_disableOpenPicker && !isComponentReadOnly && !disabled && jsx(DotIconButton, {
|
|
9837
9915
|
"data-testid": dataTestId && `${dataTestId}-open-btn`,
|
|
9838
|
-
iconId: "
|
|
9916
|
+
iconId: "pending-clock",
|
|
9839
9917
|
onClick: _event => handleTimePickerButtonClick(),
|
|
9840
9918
|
size: "small"
|
|
9841
9919
|
}, void 0)]
|
|
@@ -9843,23 +9921,24 @@ const DotTimePicker = ({
|
|
|
9843
9921
|
},
|
|
9844
9922
|
inputProps: {
|
|
9845
9923
|
className: 'dot-input',
|
|
9846
|
-
'data-testid': dataTestId && `${dataTestId}-input
|
|
9924
|
+
'data-testid': dataTestId && `${dataTestId}-input`,
|
|
9925
|
+
onBlur
|
|
9847
9926
|
},
|
|
9848
9927
|
fullWidth: _fullWidth,
|
|
9849
9928
|
name: inputName
|
|
9850
9929
|
},
|
|
9851
9930
|
field: {
|
|
9852
|
-
readOnly:
|
|
9931
|
+
readOnly: isComponentReadOnly
|
|
9853
9932
|
}
|
|
9854
9933
|
},
|
|
9855
9934
|
value: time
|
|
9856
9935
|
}, void 0)]
|
|
9857
9936
|
}), void 0), jsx(Popper, Object.assign({
|
|
9937
|
+
anchorEl: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current,
|
|
9858
9938
|
className: "dot-time-picker-popper",
|
|
9859
9939
|
"data-testid": dataTestId && `${dataTestId}-popper`,
|
|
9860
|
-
open: isPickerOpened,
|
|
9861
|
-
anchorEl: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current,
|
|
9862
9940
|
disablePortal: true,
|
|
9941
|
+
open: isPickerOpened,
|
|
9863
9942
|
placement: "bottom-start"
|
|
9864
9943
|
}, {
|
|
9865
9944
|
children: jsx(ClickAwayListener, Object.assign({
|
|
@@ -9876,12 +9955,14 @@ const DotTimePicker = ({
|
|
|
9876
9955
|
className: "dot-time-picker-hours",
|
|
9877
9956
|
ref: hoursRef
|
|
9878
9957
|
}, {
|
|
9879
|
-
children: hours.map(hour => {
|
|
9880
|
-
const isSelected = pickerTime ?
|
|
9958
|
+
children: hours.map((hour, index) => {
|
|
9959
|
+
const isSelected = pickerTime ? selectedPickerHour === hour : false;
|
|
9881
9960
|
return jsx(DotButton, Object.assign({
|
|
9882
9961
|
className: "dot-picker-button",
|
|
9883
9962
|
"data-testid": dataTestId && `${dataTestId}-hour-button-${hour}`,
|
|
9884
9963
|
onClick: () => handleHourClick(hour),
|
|
9964
|
+
onKeyDown: handleTimeKeydown(hoursRef, index),
|
|
9965
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, selectedPickerHour),
|
|
9885
9966
|
type: isSelected ? 'primary' : 'text'
|
|
9886
9967
|
}, {
|
|
9887
9968
|
children: hour.toString().padStart(2, '0')
|
|
@@ -9891,32 +9972,39 @@ const DotTimePicker = ({
|
|
|
9891
9972
|
className: "dot-time-picker-minutes",
|
|
9892
9973
|
ref: minutesRef
|
|
9893
9974
|
}, {
|
|
9894
|
-
children: minutes.map(minute => {
|
|
9975
|
+
children: minutes.map((minute, index) => {
|
|
9895
9976
|
const isSelected = pickerTime ? pickerTime.minute() === minute : false;
|
|
9896
9977
|
return jsx(DotButton, Object.assign({
|
|
9897
9978
|
className: "dot-picker-button",
|
|
9898
9979
|
"data-testid": dataTestId && `${dataTestId}-minute-button-${minute}`,
|
|
9899
9980
|
type: isSelected ? 'primary' : 'text',
|
|
9900
|
-
onClick: () => handleMinuteClick(minute)
|
|
9981
|
+
onClick: () => handleMinuteClick(minute),
|
|
9982
|
+
onKeyDown: handleTimeKeydown(minutesRef, index),
|
|
9983
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, pickerTime === null || pickerTime === void 0 ? void 0 : pickerTime.minute())
|
|
9901
9984
|
}, {
|
|
9902
9985
|
children: minute.toString().padStart(2, '0')
|
|
9903
9986
|
}), minute);
|
|
9904
9987
|
})
|
|
9905
9988
|
}), void 0), _ampm && jsxs("div", Object.assign({
|
|
9906
|
-
className: "dot-time-picker-daytime"
|
|
9989
|
+
className: "dot-time-picker-daytime",
|
|
9990
|
+
ref: daytimeRef
|
|
9907
9991
|
}, {
|
|
9908
9992
|
children: [jsx(DotButton, Object.assign({
|
|
9909
9993
|
className: "dot-picker-button",
|
|
9910
9994
|
"data-testid": dataTestId && `${dataTestId}-am-button`,
|
|
9911
|
-
|
|
9912
|
-
|
|
9995
|
+
onClick: () => handleDaytimeSelection(Daytime.AM),
|
|
9996
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 0),
|
|
9997
|
+
tabIndex: getDaytimeButtonTabIndex(Daytime.AM, daytimeSelected),
|
|
9998
|
+
type: daytimeSelected && daytimeSelected === Daytime.AM ? 'primary' : 'text'
|
|
9913
9999
|
}, {
|
|
9914
10000
|
children: Daytime.AM
|
|
9915
10001
|
}), Daytime.AM), jsx(DotButton, Object.assign({
|
|
9916
10002
|
className: "dot-picker-button",
|
|
9917
10003
|
"data-testid": dataTestId && `${dataTestId}-pm-button`,
|
|
9918
|
-
|
|
9919
|
-
|
|
10004
|
+
onClick: () => handleDaytimeSelection(Daytime.PM),
|
|
10005
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 1),
|
|
10006
|
+
tabIndex: getDaytimeButtonTabIndex(Daytime.PM, daytimeSelected),
|
|
10007
|
+
type: getTimePickerButtonType(daytimeSelected)
|
|
9920
10008
|
}, {
|
|
9921
10009
|
children: Daytime.PM
|
|
9922
10010
|
}), Daytime.PM)]
|
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,9 +1960,11 @@
|
|
|
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,
|
|
1967
|
+
tabIndex = _a.tabIndex,
|
|
1960
1968
|
tooltip = _a.tooltip,
|
|
1961
1969
|
_h = _a.type,
|
|
1962
1970
|
type = _h === void 0 ? 'primary' : _h;
|
|
@@ -1999,9 +2007,11 @@
|
|
|
1999
2007
|
onClick: function (event) {
|
|
2000
2008
|
return onClick && onClick(event);
|
|
2001
2009
|
},
|
|
2010
|
+
onKeyDown: onKeyDown,
|
|
2002
2011
|
ref: ref,
|
|
2003
2012
|
size: size,
|
|
2004
2013
|
startIcon: startIcon,
|
|
2014
|
+
tabIndex: tabIndex,
|
|
2005
2015
|
type: isSubmit ? 'submit' : 'button',
|
|
2006
2016
|
variant: variant
|
|
2007
2017
|
}, {
|
|
@@ -10306,6 +10316,7 @@
|
|
|
10306
10316
|
_c = _a.closeOnSelect,
|
|
10307
10317
|
closeOnSelect = _c === void 0 ? true : _c,
|
|
10308
10318
|
dataTestId = _a["data-testid"],
|
|
10319
|
+
defaultValue = _a.defaultValue,
|
|
10309
10320
|
disableOpenPicker = _a.disableOpenPicker,
|
|
10310
10321
|
disablePast = _a.disablePast,
|
|
10311
10322
|
disabled = _a.disabled,
|
|
@@ -10322,7 +10333,10 @@
|
|
|
10322
10333
|
inputName = _a.inputName,
|
|
10323
10334
|
label = _a.label,
|
|
10324
10335
|
locale = _a.locale,
|
|
10336
|
+
maxDate = _a.maxDate,
|
|
10337
|
+
minDate = _a.minDate,
|
|
10325
10338
|
onAccept = _a.onAccept,
|
|
10339
|
+
onBlur = _a.onBlur,
|
|
10326
10340
|
onChange = _a.onChange,
|
|
10327
10341
|
onClose = _a.onClose,
|
|
10328
10342
|
onError = _a.onError,
|
|
@@ -10335,8 +10349,20 @@
|
|
|
10335
10349
|
required = _g === void 0 ? false : _g,
|
|
10336
10350
|
showDaysOutsideCurrentMonth = _a.showDaysOutsideCurrentMonth,
|
|
10337
10351
|
value = _a.value;
|
|
10338
|
-
var
|
|
10352
|
+
var dateFormat = format || 'YYYY-MM-DD';
|
|
10353
|
+
var hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
10354
|
+
var hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
10355
|
+
var isInputReadOnly = readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
10356
|
+
var rootClasses = useStylesWithRootClass(rootClassName$1, className, isInputReadOnly ? 'read-only' : '');
|
|
10339
10357
|
var containerClasses = useStylesWithRootClass(containerClassName$1, fullWidth ? 'full-width' : '', className);
|
|
10358
|
+
React.useEffect(function () {
|
|
10359
|
+
if (hasValueWithoutChangeHandler) {
|
|
10360
|
+
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`.');
|
|
10361
|
+
}
|
|
10362
|
+
if (hasBothValueAndDefaultValue) {
|
|
10363
|
+
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.');
|
|
10364
|
+
}
|
|
10365
|
+
}, []);
|
|
10340
10366
|
React.useEffect(function () {
|
|
10341
10367
|
if (!locale) return;
|
|
10342
10368
|
var userLocaleName = dayjs__default["default"].locale();
|
|
@@ -10344,7 +10370,6 @@
|
|
|
10344
10370
|
dayjs__default["default"].extend(updateLocale__default["default"]);
|
|
10345
10371
|
dayjs__default["default"].updateLocale(userLocaleName, __assign(__assign({}, userLocaleProps), locale));
|
|
10346
10372
|
}, [locale]);
|
|
10347
|
-
var dateFormat = format || 'YYYY-MM-DD';
|
|
10348
10373
|
var handleChange = function handleChange(changedValue, context) {
|
|
10349
10374
|
if (!onChange || changedValue && !changedValue.isValid()) return;
|
|
10350
10375
|
onChange(changedValue ? changedValue.format(dateFormat) : null, context);
|
|
@@ -10353,6 +10378,9 @@
|
|
|
10353
10378
|
if (!onAccept) return;
|
|
10354
10379
|
onAccept(changedValue ? changedValue.format(dateFormat) : null);
|
|
10355
10380
|
};
|
|
10381
|
+
var handleError = function handleError(validationError, currentValue) {
|
|
10382
|
+
return onError === null || onError === void 0 ? void 0 : onError(validationError, dayjs__default["default"](currentValue).format(dateFormat));
|
|
10383
|
+
};
|
|
10356
10384
|
var createActionBar = function createActionBar() {
|
|
10357
10385
|
var actionBar = {
|
|
10358
10386
|
actions: []
|
|
@@ -10381,17 +10409,20 @@
|
|
|
10381
10409
|
autoFocus: autoFocus,
|
|
10382
10410
|
closeOnSelect: closeOnSelect,
|
|
10383
10411
|
className: rootClasses,
|
|
10384
|
-
|
|
10412
|
+
defaultValue: defaultValue && dayjs__default["default"](defaultValue, dateFormat),
|
|
10413
|
+
disableOpenPicker: disableOpenPicker || isInputReadOnly || disabled,
|
|
10385
10414
|
disablePast: disablePast,
|
|
10386
10415
|
disabled: disabled,
|
|
10387
10416
|
displayWeekNumber: displayWeekNumber,
|
|
10388
10417
|
fixedWeekNumber: fixedWeekNumber,
|
|
10389
|
-
format:
|
|
10418
|
+
format: dateFormat,
|
|
10390
10419
|
label: persistentLabel ? null : label,
|
|
10420
|
+
maxDate: maxDate && dayjs__default["default"](maxDate, dateFormat),
|
|
10421
|
+
minDate: minDate && dayjs__default["default"](minDate, dateFormat),
|
|
10391
10422
|
onAccept: handleAccept,
|
|
10392
10423
|
onChange: handleChange,
|
|
10393
10424
|
onClose: onClose,
|
|
10394
|
-
onError:
|
|
10425
|
+
onError: handleError,
|
|
10395
10426
|
onOpen: onOpen,
|
|
10396
10427
|
open: open,
|
|
10397
10428
|
showDaysOutsideCurrentMonth: showDaysOutsideCurrentMonth,
|
|
@@ -10420,19 +10451,23 @@
|
|
|
10420
10451
|
required: required,
|
|
10421
10452
|
helperText: helperText,
|
|
10422
10453
|
error: error,
|
|
10423
|
-
focused:
|
|
10454
|
+
focused: isInputReadOnly ? false : undefined,
|
|
10424
10455
|
inputProps: {
|
|
10425
10456
|
className: 'dot-input',
|
|
10426
|
-
'data-testid': 'dot-date-picker-input'
|
|
10457
|
+
'data-testid': 'dot-date-picker-input',
|
|
10458
|
+
onBlur: onBlur
|
|
10427
10459
|
},
|
|
10428
10460
|
fullWidth: fullWidth,
|
|
10429
10461
|
name: inputName
|
|
10430
10462
|
},
|
|
10431
10463
|
field: {
|
|
10432
|
-
readOnly:
|
|
10464
|
+
readOnly: isInputReadOnly
|
|
10465
|
+
},
|
|
10466
|
+
desktopTrapFocus: {
|
|
10467
|
+
disableEnforceFocus: true
|
|
10433
10468
|
}
|
|
10434
10469
|
},
|
|
10435
|
-
value: value && dayjs__default["default"](value)
|
|
10470
|
+
value: value && dayjs__default["default"](value, dateFormat)
|
|
10436
10471
|
}, void 0)]
|
|
10437
10472
|
}), void 0)
|
|
10438
10473
|
}), void 0);
|
|
@@ -10507,6 +10542,18 @@
|
|
|
10507
10542
|
return selectedHour;
|
|
10508
10543
|
}
|
|
10509
10544
|
};
|
|
10545
|
+
var getPopperButtonTabIndex = function getPopperButtonTabIndex(index, isSelected, selectedValue) {
|
|
10546
|
+
return selectedValue && isSelected || !selectedValue && index === 0 ? undefined : -1;
|
|
10547
|
+
};
|
|
10548
|
+
var getDaytimeButtonTabIndex = function getDaytimeButtonTabIndex(currentDaytime, selectedDaytime) {
|
|
10549
|
+
return selectedDaytime && currentDaytime === selectedDaytime || !selectedDaytime && currentDaytime === exports.Daytime.AM ? undefined : -1;
|
|
10550
|
+
};
|
|
10551
|
+
var getSelectedDaytime = function getSelectedDaytime(dateTime) {
|
|
10552
|
+
return dateTime && dateTime.format('A') || exports.Daytime.AM;
|
|
10553
|
+
};
|
|
10554
|
+
var getTimePickerButtonType = function getTimePickerButtonType(selectedDaytime) {
|
|
10555
|
+
return selectedDaytime && selectedDaytime === exports.Daytime.PM ? 'primary' : 'text';
|
|
10556
|
+
};
|
|
10510
10557
|
|
|
10511
10558
|
var rootClassName = 'dot-time-picker';
|
|
10512
10559
|
var containerClassName = 'dot-time-picker-container';
|
|
@@ -10542,6 +10589,7 @@
|
|
|
10542
10589
|
autoFocus = _c === void 0 ? false : _c,
|
|
10543
10590
|
className = _a.className,
|
|
10544
10591
|
dataTestId = _a["data-testid"],
|
|
10592
|
+
defaultValue = _a.defaultValue,
|
|
10545
10593
|
_d = _a.disableOpenPicker,
|
|
10546
10594
|
disableOpenPicker = _d === void 0 ? false : _d,
|
|
10547
10595
|
disabled = _a.disabled,
|
|
@@ -10554,6 +10602,8 @@
|
|
|
10554
10602
|
inputId = _a.inputId,
|
|
10555
10603
|
inputName = _a.inputName,
|
|
10556
10604
|
label = _a.label,
|
|
10605
|
+
onAccept = _a.onAccept,
|
|
10606
|
+
onBlur = _a.onBlur,
|
|
10557
10607
|
onChange = _a.onChange,
|
|
10558
10608
|
onClose = _a.onClose,
|
|
10559
10609
|
onOpen = _a.onOpen,
|
|
@@ -10564,13 +10614,16 @@
|
|
|
10564
10614
|
_g = _a.required,
|
|
10565
10615
|
required = _g === void 0 ? false : _g,
|
|
10566
10616
|
value = _a.value;
|
|
10567
|
-
var
|
|
10617
|
+
var timeFormat = format || DEFAULT_TIME_FORMAT;
|
|
10618
|
+
var hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
10619
|
+
var hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
10620
|
+
var isComponentReadOnly = readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
10621
|
+
var rootClasses = useStylesWithRootClass(rootClassName, className, isComponentReadOnly ? 'read-only' : '');
|
|
10568
10622
|
var containerClasses = useStylesWithRootClass(containerClassName, fullWidth ? 'full-width' : '', className);
|
|
10569
10623
|
var inputRef = React.useRef(null);
|
|
10570
10624
|
var _h = React.useState(false),
|
|
10571
10625
|
isPickerOpened = _h[0],
|
|
10572
10626
|
setIsPickerOpened = _h[1];
|
|
10573
|
-
var timeFormat = format || DEFAULT_TIME_FORMAT;
|
|
10574
10627
|
var _j = React.useState(null),
|
|
10575
10628
|
time = _j[0],
|
|
10576
10629
|
setTime = _j[1];
|
|
@@ -10579,15 +10632,31 @@
|
|
|
10579
10632
|
setPickerTime = _k[1];
|
|
10580
10633
|
var hoursRef = React.useRef(null);
|
|
10581
10634
|
var minutesRef = React.useRef(null);
|
|
10635
|
+
var daytimeRef = React.useRef(null);
|
|
10582
10636
|
var hours = getHoursForTimePicker(ampm);
|
|
10583
10637
|
var minutes = getMinutesForTimePicker();
|
|
10584
|
-
var daytimeSelected = pickerTime
|
|
10638
|
+
var daytimeSelected = getSelectedDaytime(pickerTime);
|
|
10639
|
+
var selectedPickerHour = pickerTime && calculateHourBasedOnTimeFormat(pickerTime, ampm);
|
|
10585
10640
|
var isOpenPropDefined = open !== null && open !== undefined;
|
|
10641
|
+
var isControlledComponent = onChange && value !== undefined;
|
|
10642
|
+
React.useEffect(function () {
|
|
10643
|
+
if (hasValueWithoutChangeHandler) {
|
|
10644
|
+
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`.');
|
|
10645
|
+
}
|
|
10646
|
+
if (hasBothValueAndDefaultValue) {
|
|
10647
|
+
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.');
|
|
10648
|
+
}
|
|
10649
|
+
}, []);
|
|
10586
10650
|
React.useEffect(function () {
|
|
10587
|
-
var timeValue =
|
|
10651
|
+
var timeValue = null;
|
|
10652
|
+
if (defaultValue) {
|
|
10653
|
+
timeValue = getDayjsUtcDate(defaultValue, timeFormat);
|
|
10654
|
+
} else if (value) {
|
|
10655
|
+
timeValue = getDayjsUtcDate(value, timeFormat);
|
|
10656
|
+
}
|
|
10588
10657
|
setTime(timeValue);
|
|
10589
10658
|
setPickerTime(timeValue);
|
|
10590
|
-
}, [value]);
|
|
10659
|
+
}, [value, defaultValue]);
|
|
10591
10660
|
React.useLayoutEffect(function () {
|
|
10592
10661
|
if (isPickerOpened && time) {
|
|
10593
10662
|
scrollToSelectedTime();
|
|
@@ -10606,7 +10675,9 @@
|
|
|
10606
10675
|
setPickerTime(pickedDateTime);
|
|
10607
10676
|
};
|
|
10608
10677
|
var handleInputChange = function handleInputChange(currentValue, context) {
|
|
10678
|
+
var currentTimeValue = currentValue ? currentValue : null;
|
|
10609
10679
|
setPickerTime(currentValue ? currentValue : null);
|
|
10680
|
+
!isControlledComponent && setTime(currentTimeValue);
|
|
10610
10681
|
onChange === null || onChange === void 0 ? void 0 : onChange(currentValue ? currentValue.format(timeFormat) : null, context);
|
|
10611
10682
|
};
|
|
10612
10683
|
var handleClose = function handleClose() {
|
|
@@ -10635,11 +10706,16 @@
|
|
|
10635
10706
|
handleClose();
|
|
10636
10707
|
};
|
|
10637
10708
|
var handleSet = function handleSet() {
|
|
10638
|
-
|
|
10709
|
+
if (!pickerTime) {
|
|
10710
|
+
handleClose();
|
|
10711
|
+
return;
|
|
10712
|
+
}
|
|
10639
10713
|
setTime(pickerTime);
|
|
10640
10714
|
onChange === null || onChange === void 0 ? void 0 : onChange(pickerTime.format(timeFormat), {
|
|
10641
10715
|
validationError: null
|
|
10642
10716
|
});
|
|
10717
|
+
onAccept === null || onAccept === void 0 ? void 0 : onAccept(pickerTime.format(timeFormat));
|
|
10718
|
+
handleClose();
|
|
10643
10719
|
};
|
|
10644
10720
|
var scrollToSelectedTime = function scrollToSelectedTime() {
|
|
10645
10721
|
if (!(hoursRef === null || hoursRef === void 0 ? void 0 : hoursRef.current) || !(minutesRef === null || minutesRef === void 0 ? void 0 : minutesRef.current)) return;
|
|
@@ -10657,9 +10733,28 @@
|
|
|
10657
10733
|
minutesRef.current.children[selectedMinute].scrollIntoView(scrollOptions);
|
|
10658
10734
|
}
|
|
10659
10735
|
};
|
|
10736
|
+
var handleTimeKeydown = function handleTimeKeydown(ref, index) {
|
|
10737
|
+
return function (event) {
|
|
10738
|
+
var numberOfElements = ref.current.children.length;
|
|
10739
|
+
var prevElement = index > 0 && ref.current.children[index - 1];
|
|
10740
|
+
var nextElement = index < numberOfElements - 1 && ref.current.children[index + 1];
|
|
10741
|
+
if (checkIfArrowUpPressed(event) && prevElement) {
|
|
10742
|
+
event.preventDefault();
|
|
10743
|
+
prevElement.focus();
|
|
10744
|
+
} else if (checkIfArrowDownPressed(event) && nextElement) {
|
|
10745
|
+
event.preventDefault();
|
|
10746
|
+
nextElement.focus();
|
|
10747
|
+
}
|
|
10748
|
+
};
|
|
10749
|
+
};
|
|
10750
|
+
var handleTimePickerKeyDown = function handleTimePickerKeyDown(event) {
|
|
10751
|
+
if (event.key !== 'Escape' || !isPickerOpened) return;
|
|
10752
|
+
handleCancel();
|
|
10753
|
+
};
|
|
10660
10754
|
return jsxRuntime.jsxs(StyledTimePickerContainer, __assign({
|
|
10661
10755
|
className: containerClasses,
|
|
10662
|
-
"data-testid": dataTestId
|
|
10756
|
+
"data-testid": dataTestId,
|
|
10757
|
+
onKeyDown: handleTimePickerKeyDown
|
|
10663
10758
|
}, {
|
|
10664
10759
|
children: [jsxRuntime.jsxs(xDatePickers.LocalizationProvider, __assign({
|
|
10665
10760
|
dateAdapter: AdapterDayjs.AdapterDayjs
|
|
@@ -10686,16 +10781,16 @@
|
|
|
10686
10781
|
required: required,
|
|
10687
10782
|
helperText: helperText,
|
|
10688
10783
|
error: error,
|
|
10689
|
-
focused:
|
|
10784
|
+
focused: isComponentReadOnly ? false : undefined,
|
|
10690
10785
|
InputProps: {
|
|
10691
10786
|
endAdornment: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
10692
10787
|
children: [error && jsxRuntime.jsx(DotIcon, {
|
|
10693
10788
|
className: "dot-error-icon",
|
|
10694
10789
|
"data-testid": dataTestId && dataTestId + "-input-error-icon",
|
|
10695
10790
|
iconId: "error-solid"
|
|
10696
|
-
}, void 0), !disableOpenPicker && !
|
|
10791
|
+
}, void 0), !disableOpenPicker && !isComponentReadOnly && !disabled && jsxRuntime.jsx(DotIconButton, {
|
|
10697
10792
|
"data-testid": dataTestId && dataTestId + "-open-btn",
|
|
10698
|
-
iconId: "
|
|
10793
|
+
iconId: "pending-clock",
|
|
10699
10794
|
onClick: function (_event) {
|
|
10700
10795
|
return handleTimePickerButtonClick();
|
|
10701
10796
|
},
|
|
@@ -10705,23 +10800,24 @@
|
|
|
10705
10800
|
},
|
|
10706
10801
|
inputProps: {
|
|
10707
10802
|
className: 'dot-input',
|
|
10708
|
-
'data-testid': dataTestId && dataTestId + "-input"
|
|
10803
|
+
'data-testid': dataTestId && dataTestId + "-input",
|
|
10804
|
+
onBlur: onBlur
|
|
10709
10805
|
},
|
|
10710
10806
|
fullWidth: fullWidth,
|
|
10711
10807
|
name: inputName
|
|
10712
10808
|
},
|
|
10713
10809
|
field: {
|
|
10714
|
-
readOnly:
|
|
10810
|
+
readOnly: isComponentReadOnly
|
|
10715
10811
|
}
|
|
10716
10812
|
},
|
|
10717
10813
|
value: time
|
|
10718
10814
|
}, void 0)]
|
|
10719
10815
|
}), void 0), jsxRuntime.jsx(material.Popper, __assign({
|
|
10816
|
+
anchorEl: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current,
|
|
10720
10817
|
className: "dot-time-picker-popper",
|
|
10721
10818
|
"data-testid": dataTestId && dataTestId + "-popper",
|
|
10722
|
-
open: isPickerOpened,
|
|
10723
|
-
anchorEl: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current,
|
|
10724
10819
|
disablePortal: true,
|
|
10820
|
+
open: isPickerOpened,
|
|
10725
10821
|
placement: "bottom-start"
|
|
10726
10822
|
}, {
|
|
10727
10823
|
children: jsxRuntime.jsx(material.ClickAwayListener, __assign({
|
|
@@ -10738,14 +10834,16 @@
|
|
|
10738
10834
|
className: "dot-time-picker-hours",
|
|
10739
10835
|
ref: hoursRef
|
|
10740
10836
|
}, {
|
|
10741
|
-
children: hours.map(function (hour) {
|
|
10742
|
-
var isSelected = pickerTime ?
|
|
10837
|
+
children: hours.map(function (hour, index) {
|
|
10838
|
+
var isSelected = pickerTime ? selectedPickerHour === hour : false;
|
|
10743
10839
|
return jsxRuntime.jsx(DotButton, __assign({
|
|
10744
10840
|
className: "dot-picker-button",
|
|
10745
10841
|
"data-testid": dataTestId && dataTestId + "-hour-button-" + hour,
|
|
10746
10842
|
onClick: function () {
|
|
10747
10843
|
return handleHourClick(hour);
|
|
10748
10844
|
},
|
|
10845
|
+
onKeyDown: handleTimeKeydown(hoursRef, index),
|
|
10846
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, selectedPickerHour),
|
|
10749
10847
|
type: isSelected ? 'primary' : 'text'
|
|
10750
10848
|
}, {
|
|
10751
10849
|
children: hour.toString().padStart(2, '0')
|
|
@@ -10755,7 +10853,7 @@
|
|
|
10755
10853
|
className: "dot-time-picker-minutes",
|
|
10756
10854
|
ref: minutesRef
|
|
10757
10855
|
}, {
|
|
10758
|
-
children: minutes.map(function (minute) {
|
|
10856
|
+
children: minutes.map(function (minute, index) {
|
|
10759
10857
|
var isSelected = pickerTime ? pickerTime.minute() === minute : false;
|
|
10760
10858
|
return jsxRuntime.jsx(DotButton, __assign({
|
|
10761
10859
|
className: "dot-picker-button",
|
|
@@ -10763,30 +10861,37 @@
|
|
|
10763
10861
|
type: isSelected ? 'primary' : 'text',
|
|
10764
10862
|
onClick: function () {
|
|
10765
10863
|
return handleMinuteClick(minute);
|
|
10766
|
-
}
|
|
10864
|
+
},
|
|
10865
|
+
onKeyDown: handleTimeKeydown(minutesRef, index),
|
|
10866
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, pickerTime === null || pickerTime === void 0 ? void 0 : pickerTime.minute())
|
|
10767
10867
|
}, {
|
|
10768
10868
|
children: minute.toString().padStart(2, '0')
|
|
10769
10869
|
}), minute);
|
|
10770
10870
|
})
|
|
10771
10871
|
}), void 0), ampm && jsxRuntime.jsxs("div", __assign({
|
|
10772
|
-
className: "dot-time-picker-daytime"
|
|
10872
|
+
className: "dot-time-picker-daytime",
|
|
10873
|
+
ref: daytimeRef
|
|
10773
10874
|
}, {
|
|
10774
10875
|
children: [jsxRuntime.jsx(DotButton, __assign({
|
|
10775
10876
|
className: "dot-picker-button",
|
|
10776
10877
|
"data-testid": dataTestId && dataTestId + "-am-button",
|
|
10777
|
-
type: daytimeSelected && daytimeSelected === exports.Daytime.AM ? 'primary' : 'text',
|
|
10778
10878
|
onClick: function () {
|
|
10779
10879
|
return handleDaytimeSelection(exports.Daytime.AM);
|
|
10780
|
-
}
|
|
10880
|
+
},
|
|
10881
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 0),
|
|
10882
|
+
tabIndex: getDaytimeButtonTabIndex(exports.Daytime.AM, daytimeSelected),
|
|
10883
|
+
type: daytimeSelected && daytimeSelected === exports.Daytime.AM ? 'primary' : 'text'
|
|
10781
10884
|
}, {
|
|
10782
10885
|
children: exports.Daytime.AM
|
|
10783
10886
|
}), exports.Daytime.AM), jsxRuntime.jsx(DotButton, __assign({
|
|
10784
10887
|
className: "dot-picker-button",
|
|
10785
10888
|
"data-testid": dataTestId && dataTestId + "-pm-button",
|
|
10786
|
-
type: daytimeSelected && daytimeSelected === exports.Daytime.PM ? 'primary' : 'text',
|
|
10787
10889
|
onClick: function () {
|
|
10788
10890
|
return handleDaytimeSelection(exports.Daytime.PM);
|
|
10789
|
-
}
|
|
10891
|
+
},
|
|
10892
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 1),
|
|
10893
|
+
tabIndex: getDaytimeButtonTabIndex(exports.Daytime.PM, daytimeSelected),
|
|
10894
|
+
type: getTimePickerButtonType(daytimeSelected)
|
|
10790
10895
|
}, {
|
|
10791
10896
|
children: exports.Daytime.PM
|
|
10792
10897
|
}), exports.Daytime.PM)]
|
|
@@ -1,12 +1,15 @@
|
|
|
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;
|
|
11
|
+
/** Tab order for the button. */
|
|
12
|
+
tabIndex?: number;
|
|
10
13
|
}
|
|
11
14
|
/** This component wraps the Button component from @material-ui. */
|
|
12
15
|
export declare const DotButton: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { ComponentMeta } from '@storybook/react';
|
|
1
|
+
import { ComponentMeta, Story } from '@storybook/react';
|
|
3
2
|
import { ButtonProps } from './Button';
|
|
4
|
-
|
|
3
|
+
import React from 'react';
|
|
4
|
+
declare const _default: ComponentMeta<React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>>;
|
|
5
5
|
export default _default;
|
|
6
6
|
export declare const Default: any;
|
|
7
7
|
export declare const WithStartIcon: any;
|
|
@@ -9,3 +9,4 @@ export declare const WithEndIcon: any;
|
|
|
9
9
|
export declare const WithDestructiveType: any;
|
|
10
10
|
export declare const WithOutlinedType: any;
|
|
11
11
|
export declare const WithTextType: any;
|
|
12
|
+
export declare const WithTabbableLinkAsChildren: Story<ButtonProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { FocusEvent, ReactNode } from 'react';
|
|
2
2
|
import { PickersDayProps } from '@mui/x-date-pickers';
|
|
3
3
|
import { FieldChangeHandlerContext } from '@mui/x-date-pickers/internals';
|
|
4
4
|
import { CommonProps } from '../CommonProps';
|
|
@@ -9,6 +9,8 @@ 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. */
|
|
@@ -37,8 +39,14 @@ export interface DatePickerProps extends CommonProps {
|
|
|
37
39
|
label?: string;
|
|
38
40
|
/** Locale for the date library you are using */
|
|
39
41
|
locale?: DatePickerLocale;
|
|
42
|
+
/** Maximal selectable date */
|
|
43
|
+
maxDate?: string;
|
|
44
|
+
/** Minimal selectable date. */
|
|
45
|
+
minDate?: string;
|
|
40
46
|
/** Callback fired when the value is accepted. */
|
|
41
47
|
onAccept?: (value: string) => void;
|
|
48
|
+
/** A function that should be executed when the input loses focus */
|
|
49
|
+
onBlur?: (event: FocusEvent<HTMLInputElement | HTMLTextAreaElement, Element>) => void;
|
|
42
50
|
/** Callback fired when the value changes. */
|
|
43
51
|
onChange?: (value: string, context: FieldChangeHandlerContext<string>) => void;
|
|
44
52
|
/** Callback fired when the popup requests to be closed. Use in controlled mode (see `open`). */
|
|
@@ -65,4 +73,4 @@ export interface DatePickerProps extends CommonProps {
|
|
|
65
73
|
/** The selected value. Used when the component is controlled. */
|
|
66
74
|
value?: string;
|
|
67
75
|
}
|
|
68
|
-
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, onChange, onClose, onError, onOpen, open, persistentLabel, readOnly, required, showDaysOutsideCurrentMonth, value, }: DatePickerProps) => JSX.Element;
|
|
76
|
+
export declare const DotDatePicker: ({ ariaLabel, autoFocus, className, closeOnSelect, "data-testid": dataTestId, defaultValue, disableOpenPicker, disablePast, disabled, displayWeekNumber, displayClearButton, error, fixedWeekNumber, 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, 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, disabled, displayWeekNumber, displayClearButton, error, fixedWeekNumber, 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,5 +16,10 @@ 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;
|
|
19
21
|
export declare const WithControlledMode: Story<DatePickerProps>;
|
|
22
|
+
export declare const WithMinMaxDates: Story<DatePickerProps>;
|
|
20
23
|
export declare const WithLocaleConfiguration: Story<DatePickerProps>;
|
|
24
|
+
export declare const WithChangeOnBlur: Story<DatePickerProps>;
|
|
25
|
+
export declare const WithOpenedPopperInControlledMode: Story<DatePickerProps>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const datePickerWithControlledModeClassName = "dot-date-picker-with-controlled-mode";
|
|
2
2
|
export declare const datePickerWithLocaleClassName = "dot-date-picker-with-locale";
|
|
3
|
+
export declare const datePickerWithBlurClassName = "dot-date-picker-with-blur";
|
|
3
4
|
export declare const StyledDatePickerWithControlledMode: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const StyledDatePickerWithChangeOnBlur: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
6
|
export declare const StyledDatePickerWithLocale: 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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { FocusEvent, ReactNode } from 'react';
|
|
2
2
|
import { FieldChangeHandlerContext } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { CommonProps } from '../CommonProps';
|
|
4
4
|
export interface TimePickerProps extends CommonProps {
|
|
@@ -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. */
|
|
@@ -25,6 +27,10 @@ export interface TimePickerProps extends CommonProps {
|
|
|
25
27
|
inputName?: string;
|
|
26
28
|
/** The label content. */
|
|
27
29
|
label?: string;
|
|
30
|
+
/** Callback fired when the value is changed from the popper. */
|
|
31
|
+
onAccept?: (value: string) => void;
|
|
32
|
+
/** A function that should be executed when the input loses focus */
|
|
33
|
+
onBlur?: (event: FocusEvent<HTMLInputElement | HTMLTextAreaElement, Element>) => void;
|
|
28
34
|
/** Callback fired when the value changes. */
|
|
29
35
|
onChange?: (value: string, context: FieldChangeHandlerContext<string>) => void;
|
|
30
36
|
/** Callback fired when the popup requests to be closed. Use in controlled mode (see `open`). */
|
|
@@ -45,4 +51,4 @@ export interface TimePickerProps extends CommonProps {
|
|
|
45
51
|
export declare const DEFAULT_PICKER_TIME_FORMAT = "hh:mm";
|
|
46
52
|
export declare const DEFAULT_TIME_FORMAT = "hh:mm A";
|
|
47
53
|
export declare const DEFAULT_TIME = "01:00";
|
|
48
|
-
export declare const DotTimePicker: ({ ampm, ariaLabel, autoFocus, className, "data-testid": dataTestId, disableOpenPicker, disabled, error, format, fullWidth, helperText, hideActionButtons, inputId, inputName, label, 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, 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,9 @@ 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>;
|
|
23
|
+
export declare const WithChangeOnBlur: Story<TimePickerProps>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const timePickerWithControlledModeClassName = "dot-time-picker-with-controlled-mode";
|
|
2
2
|
export declare const timePickerWithHourFormatPickerClassName = "dot-time-picker-with-hour-format-picker";
|
|
3
3
|
export declare const timePickerWithOutsideTimeSetterClassName = "dot-time-picker-with-outside-time-setter";
|
|
4
|
+
export declare const timePickerWithBlurClassName = "dot-time-picker-with-blur";
|
|
4
5
|
export declare const StyledTimePickerWithControlledMode: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
6
|
export declare const StyledTimePickerWithHourFormatPicker: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
7
|
export declare const StyledTimePickerWithOutsideTimeSetter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const StyledTimePickerWithChangeOnBlur: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -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.
|
|
3
|
+
"version": "2.7.1",
|
|
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",
|