@digital-ai/dot-components 2.7.2 → 2.7.4
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 +26 -2
- package/index.esm.js +181 -115
- package/index.umd.js +243 -154
- package/lib/components/auto-complete/AutoComplete.d.ts +3 -1
- package/lib/components/auto-complete/AutoComplete.stories.d.ts +2 -1
- package/lib/components/date-picker/DatePicker.d.ts +6 -3
- package/lib/components/date-picker/DatePicker.stories.d.ts +1 -5
- package/lib/components/date-picker/index.d.ts +2 -0
- package/lib/components/date-picker/utils/helpers.d.ts +5 -0
- package/lib/components/date-picker/utils/models.d.ts +5 -0
- package/lib/components/index.d.ts +1 -1
- package/lib/components/inline-edit/InlineEdit.d.ts +3 -1
- package/lib/components/inline-edit/InlineEdit.stories.d.ts +2 -1
- package/lib/components/time-picker/TimePicker.d.ts +12 -5
- package/lib/components/time-picker/TimePicker.stories.d.ts +3 -2
- package/lib/components/time-picker/TimePicker.stories.styles.d.ts +2 -0
- package/lib/components/time-picker/utils/helpers.d.ts +2 -0
- package/package.json +1 -1
package/CHANGE_LOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.7.4](https://www.npmjs.com/package/@digital-ai/dot-components) (05/04/2023)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/2.7.3...2.7.4)
|
|
6
|
+
|
|
7
|
+
**Features:**
|
|
8
|
+
|
|
9
|
+
- S-92362: `DotAutoComplete` - Expose `getOptionDisabled` from MUI Autocomplete [\#1474](https://github.com/digital-ai/dot-components/pull/1474) ([dmiletic85](https://github.com/dmiletic85))
|
|
10
|
+
- S-92310 Use ISO format for `DatePicker` and `TimePicker` [\#1472](https://github.com/digital-ai/dot-components/pull/1472) ([angel-git](https://github.com/angel-git))
|
|
11
|
+
- S-92224: `DotDatePicker`, `DotTimePicker` - Improve keyboard accessibility [\#1470](https://github.com/digital-ai/dot-components/pull/1470) ([dmiletic85](https://github.com/dmiletic85))
|
|
12
|
+
|
|
13
|
+
## [2.7.3](https://www.npmjs.com/package/@digital-ai/dot-components) (05/01/2023)
|
|
14
|
+
|
|
15
|
+
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/2.7.2...2.7.3)
|
|
16
|
+
|
|
17
|
+
**Features:**
|
|
18
|
+
|
|
19
|
+
- D-24626: Add startEditable attribute to InlineEdit [\#1466](https://github.com/digital-ai/dot-components/pull/1466) ([jmcnally](https://github.com/jmcnally))
|
|
20
|
+
|
|
21
|
+
**Misc:**
|
|
22
|
+
|
|
23
|
+
- Updates to deprecated github action `set-output` [\#1465](https://github.com/digital-ai/dot-components/pull/1465) ([CWSites](https://github.com/CWSites))
|
|
24
|
+
- remove use of set-output [\#1464](https://github.com/digital-ai/dot-components/pull/1464) ([CWSites](https://github.com/CWSites))
|
|
25
|
+
- S-91985: Improve form input labelling for accessibility [\#1463](https://github.com/digital-ai/dot-components/pull/1463) ([jmcnally](https://github.com/jmcnally))
|
|
26
|
+
|
|
3
27
|
## [2.7.2](https://www.npmjs.com/package/@digital-ai/dot-components) (04/24/2023)
|
|
4
28
|
|
|
5
29
|
[Full Changelog](https://digital-ai.github.io/dot-components/?path=/story/introduction--page/digital-ai/dot-components/compare/2.7.1...2.7.2)
|
|
@@ -575,7 +599,6 @@
|
|
|
575
599
|
- D-20736: Fix text alignment for small DotAvatar [\#1116](https://github.com/digital-ai/dot-components/pull/1116) ([selsemore](https://github.com/selsemore))
|
|
576
600
|
- 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))
|
|
577
601
|
- 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))
|
|
579
602
|
|
|
580
603
|
## [1.14.0](https://www.npmjs.com/package/@digital-ai/dot-components) (04/01/2022)
|
|
581
604
|
|
|
@@ -619,6 +642,7 @@
|
|
|
619
642
|
|
|
620
643
|
**Fixed bugs:**
|
|
621
644
|
|
|
645
|
+
- D-20511: remove extra period [\#1094](https://github.com/digital-ai/dot-components/pull/1094) ([CWSites](https://github.com/CWSites))
|
|
622
646
|
- 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))
|
|
623
647
|
- D-20418: `DotTable`: Strange scrolling behavior with action menu [\#1082](https://github.com/digital-ai/dot-components/pull/1082) ([dmiletic85](https://github.com/dmiletic85))
|
|
624
648
|
- 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))
|
|
@@ -941,6 +965,7 @@
|
|
|
941
965
|
|
|
942
966
|
- \#841 Fix DotDynamicForm initial form state for controls with initialValue false [\#842](https://github.com/digital-ai/dot-components/pull/842) ([selsemore](https://github.com/selsemore))
|
|
943
967
|
- D-19189: Extended sidenav drawer should collapse when another drawer option is clicked [\#830](https://github.com/digital-ai/dot-components/pull/830) ([dmiletic85](https://github.com/dmiletic85))
|
|
968
|
+
- D-19177: `Go back` item in `DotSidebar` is not aligned with rest of items [\#826](https://github.com/digital-ai/dot-components/pull/826) ([dmiletic85](https://github.com/dmiletic85))
|
|
944
969
|
|
|
945
970
|
**Misc:**
|
|
946
971
|
|
|
@@ -959,7 +984,6 @@
|
|
|
959
984
|
**Fixed bugs:**
|
|
960
985
|
|
|
961
986
|
- D-19151: `DotBadge` generates console warnings [\#827](https://github.com/digital-ai/dot-components/pull/827) ([dmiletic85](https://github.com/dmiletic85))
|
|
962
|
-
- D-19177: `Go back` item in `DotSidebar` is not aligned with rest of items [\#826](https://github.com/digital-ai/dot-components/pull/826) ([dmiletic85](https://github.com/dmiletic85))
|
|
963
987
|
|
|
964
988
|
## [1.3.4](https://www.npmjs.com/package/@digital-ai/dot-components) (11/30/2021)
|
|
965
989
|
|
package/index.esm.js
CHANGED
|
@@ -4290,6 +4290,9 @@ const getChipsFromAutocomplete = ({
|
|
|
4290
4290
|
};
|
|
4291
4291
|
const checkIfDuplicateItem = (itemText, autocompleteOptions) => autocompleteOptions.some(autocompleteOption => autocompleteOption.title === itemText);
|
|
4292
4292
|
|
|
4293
|
+
function ariaLabelOrAlternates(ariaLabel, label, placeholder) {
|
|
4294
|
+
return ariaLabel || label || placeholder;
|
|
4295
|
+
}
|
|
4293
4296
|
const DEFAULT_ACTION_ITEM_TEXT = 'Add new item';
|
|
4294
4297
|
const DotAutoComplete = ({
|
|
4295
4298
|
ListboxComponent,
|
|
@@ -4306,6 +4309,7 @@ const DotAutoComplete = ({
|
|
|
4306
4309
|
error: _error = false,
|
|
4307
4310
|
filterSelectedOptions: _filterSelectedOptions = true,
|
|
4308
4311
|
freesolo: _freesolo = true,
|
|
4312
|
+
checkIfOptionDisabled,
|
|
4309
4313
|
group: _group = false,
|
|
4310
4314
|
helperText,
|
|
4311
4315
|
inputId,
|
|
@@ -4527,6 +4531,7 @@ const DotAutoComplete = ({
|
|
|
4527
4531
|
filterSelectedOptions: _filterSelectedOptions,
|
|
4528
4532
|
freeSolo: _freesolo,
|
|
4529
4533
|
getOptionLabel: option => parseAutoCompleteValue(option),
|
|
4534
|
+
getOptionDisabled: checkIfOptionDisabled,
|
|
4530
4535
|
groupBy: _group ? option => option.group : undefined,
|
|
4531
4536
|
ListboxComponent: ListboxComponent,
|
|
4532
4537
|
loading: loading,
|
|
@@ -4582,11 +4587,17 @@ const DotAutoComplete = ({
|
|
|
4582
4587
|
error: _error,
|
|
4583
4588
|
focused: _readOnly ? false : undefined,
|
|
4584
4589
|
helperText: helperText,
|
|
4590
|
+
id: inputId,
|
|
4585
4591
|
inputProps: Object.assign(Object.assign({}, inputProps), {
|
|
4592
|
+
'aria-label': ariaLabelOrAlternates(ariaLabel, label, placeholder),
|
|
4593
|
+
'data-testid': dataTestId && `${dataTestId}-input`,
|
|
4586
4594
|
id: inputId,
|
|
4587
4595
|
className: useStylesWithRootClass(inputProps.className, 'dot-input'),
|
|
4588
4596
|
readOnly: _readOnly
|
|
4589
4597
|
}),
|
|
4598
|
+
InputLabelProps: {
|
|
4599
|
+
htmlFor: inputId
|
|
4600
|
+
},
|
|
4590
4601
|
InputProps: Object.assign(Object.assign({}, params.InputProps), {
|
|
4591
4602
|
endAdornment: !_readOnly ? renderEndAdornment(params.InputProps.endAdornment) : undefined
|
|
4592
4603
|
}),
|
|
@@ -7054,6 +7065,7 @@ const DotInlineEdit = ({
|
|
|
7054
7065
|
onEditStateChange,
|
|
7055
7066
|
readOnly,
|
|
7056
7067
|
selectTextOnEdit,
|
|
7068
|
+
startEditable: _startEditable = false,
|
|
7057
7069
|
tabIndex: _tabIndex = 0,
|
|
7058
7070
|
tooltip,
|
|
7059
7071
|
typography: _typography = 'body1',
|
|
@@ -7065,6 +7077,11 @@ const DotInlineEdit = ({
|
|
|
7065
7077
|
const [inputValue, setInputValue] = useState(_value);
|
|
7066
7078
|
const inputRef = useRef();
|
|
7067
7079
|
const inlineEditRef = useRef();
|
|
7080
|
+
useEffect(() => {
|
|
7081
|
+
if (_startEditable && !readOnly) {
|
|
7082
|
+
enterEditMode();
|
|
7083
|
+
}
|
|
7084
|
+
}, []);
|
|
7068
7085
|
useEffect(() => {
|
|
7069
7086
|
if (_value !== inputValue) {
|
|
7070
7087
|
setInputValue(_value);
|
|
@@ -7077,10 +7094,13 @@ const DotInlineEdit = ({
|
|
|
7077
7094
|
setShowTooltip(visible);
|
|
7078
7095
|
}
|
|
7079
7096
|
};
|
|
7080
|
-
const
|
|
7081
|
-
if (editing) return;
|
|
7097
|
+
const enterEditMode = () => {
|
|
7082
7098
|
setOriginalValue(inputValue);
|
|
7083
7099
|
setEditing(true);
|
|
7100
|
+
};
|
|
7101
|
+
const handleInlineEditClick = () => {
|
|
7102
|
+
if (editing) return;
|
|
7103
|
+
enterEditMode();
|
|
7084
7104
|
if (onEditStateChange) {
|
|
7085
7105
|
onEditStateChange(true);
|
|
7086
7106
|
}
|
|
@@ -7185,7 +7205,7 @@ const DotInlineEdit = ({
|
|
|
7185
7205
|
error: false,
|
|
7186
7206
|
fullWidth: _fullWidth,
|
|
7187
7207
|
inputProps: {
|
|
7188
|
-
'data-testid': dataTestId
|
|
7208
|
+
'data-testid': `${dataTestId}-input`,
|
|
7189
7209
|
className: 'dot-input',
|
|
7190
7210
|
maxLength: charactersLimit === null || charactersLimit === void 0 ? void 0 : charactersLimit.maxLength
|
|
7191
7211
|
},
|
|
@@ -9450,6 +9470,26 @@ const DotLinearProgress = ({
|
|
|
9450
9470
|
}, void 0);
|
|
9451
9471
|
};
|
|
9452
9472
|
|
|
9473
|
+
var DatePickerKeydownContext;
|
|
9474
|
+
(function (DatePickerKeydownContext) {
|
|
9475
|
+
DatePickerKeydownContext[DatePickerKeydownContext["Input"] = 0] = "Input";
|
|
9476
|
+
DatePickerKeydownContext[DatePickerKeydownContext["PickerButton"] = 1] = "PickerButton";
|
|
9477
|
+
DatePickerKeydownContext[DatePickerKeydownContext["Popper"] = 2] = "Popper";
|
|
9478
|
+
})(DatePickerKeydownContext || (DatePickerKeydownContext = {}));
|
|
9479
|
+
|
|
9480
|
+
/** This returns a `boolean` indicating whether the Day.js object contains a valid date or not. */
|
|
9481
|
+
const checkIfValidDate = (date, format) => dayjs(date, format, true).isValid();
|
|
9482
|
+
const getContextEnumBasedOnTarget = (event, inputElement, contextEnum) => {
|
|
9483
|
+
const targetElement = event.target;
|
|
9484
|
+
const isWithinInput = inputElement === null || inputElement === void 0 ? void 0 : inputElement.contains(targetElement);
|
|
9485
|
+
let currentContextEnum = contextEnum;
|
|
9486
|
+
// Key was captured within text field but not on the input itself
|
|
9487
|
+
if (contextEnum === DatePickerKeydownContext.Input && !isWithinInput) {
|
|
9488
|
+
currentContextEnum = DatePickerKeydownContext.PickerButton;
|
|
9489
|
+
}
|
|
9490
|
+
return currentContextEnum;
|
|
9491
|
+
};
|
|
9492
|
+
|
|
9453
9493
|
const rootClassName$1 = 'dot-date-picker';
|
|
9454
9494
|
const containerClassName$1 = 'dot-date-picker-container';
|
|
9455
9495
|
const rectanglePickersDayClassName = 'dot-rectangle-pickers-day';
|
|
@@ -9476,6 +9516,7 @@ const RectanglePickersDay = pickersDayProps => {
|
|
|
9476
9516
|
disableRipple: true
|
|
9477
9517
|
}), void 0);
|
|
9478
9518
|
};
|
|
9519
|
+
const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
|
|
9479
9520
|
const DotDatePicker = ({
|
|
9480
9521
|
ariaLabel,
|
|
9481
9522
|
autoFocus: _autoFocus = false,
|
|
@@ -9506,6 +9547,7 @@ const DotDatePicker = ({
|
|
|
9506
9547
|
onChange,
|
|
9507
9548
|
onClose,
|
|
9508
9549
|
onError,
|
|
9550
|
+
onKeyDown,
|
|
9509
9551
|
onOpen,
|
|
9510
9552
|
open,
|
|
9511
9553
|
persistentLabel,
|
|
@@ -9514,7 +9556,7 @@ const DotDatePicker = ({
|
|
|
9514
9556
|
showDaysOutsideCurrentMonth,
|
|
9515
9557
|
value
|
|
9516
9558
|
}) => {
|
|
9517
|
-
const
|
|
9559
|
+
const displayFormat = format || DEFAULT_DATE_FORMAT;
|
|
9518
9560
|
const hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
9519
9561
|
const hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
9520
9562
|
const isInputReadOnly = _readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
@@ -9548,13 +9590,13 @@ const DotDatePicker = ({
|
|
|
9548
9590
|
}, [locale]);
|
|
9549
9591
|
const handleChange = (changedValue, context) => {
|
|
9550
9592
|
if (!onChange || changedValue && !changedValue.isValid()) return;
|
|
9551
|
-
onChange(changedValue ? changedValue.format(
|
|
9593
|
+
onChange(changedValue ? changedValue.format(DEFAULT_DATE_FORMAT) : null, context);
|
|
9552
9594
|
};
|
|
9553
9595
|
const handleAccept = changedValue => {
|
|
9554
9596
|
if (!onAccept) return;
|
|
9555
|
-
onAccept(changedValue ? changedValue.format(
|
|
9597
|
+
onAccept(changedValue ? changedValue.format(DEFAULT_DATE_FORMAT) : null);
|
|
9556
9598
|
};
|
|
9557
|
-
const handleError = (validationError, currentValue) => onError === null || onError === void 0 ? void 0 : onError(validationError, dayjs(currentValue).format(
|
|
9599
|
+
const handleError = (validationError, currentValue) => onError === null || onError === void 0 ? void 0 : onError(validationError, dayjs(currentValue).format(DEFAULT_DATE_FORMAT));
|
|
9558
9600
|
const handleOpen = () => {
|
|
9559
9601
|
if (focusInputOnPopperOpened && inputRef.current) {
|
|
9560
9602
|
focusInput(inputRef);
|
|
@@ -9570,6 +9612,10 @@ const DotDatePicker = ({
|
|
|
9570
9612
|
}
|
|
9571
9613
|
return actionBar;
|
|
9572
9614
|
};
|
|
9615
|
+
const handleKeyDown = contextEnum => event => {
|
|
9616
|
+
const currentContextEnum = getContextEnumBasedOnTarget(event, inputRef === null || inputRef === void 0 ? void 0 : inputRef.current, contextEnum);
|
|
9617
|
+
onKeyDown(event, currentContextEnum);
|
|
9618
|
+
};
|
|
9573
9619
|
return jsx(StyledDatePickerContainer, Object.assign({
|
|
9574
9620
|
className: containerClasses,
|
|
9575
9621
|
"data-testid": dataTestId
|
|
@@ -9589,16 +9635,16 @@ const DotDatePicker = ({
|
|
|
9589
9635
|
autoFocus: _autoFocus,
|
|
9590
9636
|
closeOnSelect: _closeOnSelect,
|
|
9591
9637
|
className: rootClasses,
|
|
9592
|
-
defaultValue: defaultValue && dayjs(defaultValue,
|
|
9638
|
+
defaultValue: defaultValue && dayjs(defaultValue, DEFAULT_DATE_FORMAT),
|
|
9593
9639
|
disableOpenPicker: disableOpenPicker || isInputReadOnly || disabled,
|
|
9594
9640
|
disablePast: disablePast,
|
|
9595
9641
|
disabled: disabled,
|
|
9596
9642
|
displayWeekNumber: displayWeekNumber,
|
|
9597
9643
|
fixedWeekNumber: fixedWeekNumber,
|
|
9598
|
-
format:
|
|
9644
|
+
format: displayFormat,
|
|
9599
9645
|
label: persistentLabel ? null : label,
|
|
9600
|
-
maxDate: maxDate && dayjs(maxDate,
|
|
9601
|
-
minDate: minDate && dayjs(minDate,
|
|
9646
|
+
maxDate: maxDate && dayjs(maxDate, DEFAULT_DATE_FORMAT),
|
|
9647
|
+
minDate: minDate && dayjs(minDate, DEFAULT_DATE_FORMAT),
|
|
9602
9648
|
onAccept: handleAccept,
|
|
9603
9649
|
onChange: handleChange,
|
|
9604
9650
|
onClose: onClose,
|
|
@@ -9633,6 +9679,7 @@ const DotDatePicker = ({
|
|
|
9633
9679
|
'data-testid': 'dot-date-picker-input',
|
|
9634
9680
|
onBlur
|
|
9635
9681
|
},
|
|
9682
|
+
onKeyDown: onKeyDown && handleKeyDown(DatePickerKeydownContext.Input),
|
|
9636
9683
|
inputRef,
|
|
9637
9684
|
fullWidth: _fullWidth,
|
|
9638
9685
|
name: inputName
|
|
@@ -9644,10 +9691,11 @@ const DotDatePicker = ({
|
|
|
9644
9691
|
disableEnforceFocus: true
|
|
9645
9692
|
},
|
|
9646
9693
|
popper: {
|
|
9647
|
-
disablePortal: _disablePortal
|
|
9694
|
+
disablePortal: _disablePortal,
|
|
9695
|
+
onKeyDown: onKeyDown && handleKeyDown(DatePickerKeydownContext.Popper)
|
|
9648
9696
|
}
|
|
9649
9697
|
},
|
|
9650
|
-
value: value && dayjs(value,
|
|
9698
|
+
value: value && dayjs(value, DEFAULT_DATE_FORMAT)
|
|
9651
9699
|
}, void 0)]
|
|
9652
9700
|
}), void 0)
|
|
9653
9701
|
}), void 0);
|
|
@@ -9716,6 +9764,8 @@ const getPopperButtonTabIndex = (index, isSelected, selectedValue) => selectedVa
|
|
|
9716
9764
|
const getDaytimeButtonTabIndex = (currentDaytime, selectedDaytime) => selectedDaytime && currentDaytime === selectedDaytime || !selectedDaytime && currentDaytime === Daytime.AM ? undefined : -1;
|
|
9717
9765
|
const getSelectedDaytime = dateTime => dateTime && dateTime.format('A') || Daytime.AM;
|
|
9718
9766
|
const getTimePickerButtonType = selectedDaytime => selectedDaytime && selectedDaytime === Daytime.PM ? 'primary' : 'text';
|
|
9767
|
+
const checkIfOpenPropDefined = open => open !== null && open !== undefined;
|
|
9768
|
+
const getDaytimeButtonType = daytimeSelected => daytimeSelected && daytimeSelected === Daytime.AM ? 'primary' : 'text';
|
|
9719
9769
|
|
|
9720
9770
|
const rootClassName = 'dot-time-picker';
|
|
9721
9771
|
const containerClassName = 'dot-time-picker-container';
|
|
@@ -9737,17 +9787,18 @@ const StyledTimePicker = styled(TimePicker).withConfig({
|
|
|
9737
9787
|
}) => css(["&.", "{", ";}"], rootClassName, pickerInputStyles(theme)));
|
|
9738
9788
|
|
|
9739
9789
|
dayjs.extend(utc);
|
|
9740
|
-
const DEFAULT_PICKER_TIME_FORMAT = '
|
|
9741
|
-
const DEFAULT_TIME_FORMAT = '
|
|
9790
|
+
const DEFAULT_PICKER_TIME_FORMAT = 'HH:mm';
|
|
9791
|
+
const DEFAULT_TIME_FORMAT = 'HH:mm';
|
|
9742
9792
|
const DEFAULT_TIME = '01:00';
|
|
9743
9793
|
const DotTimePicker = ({
|
|
9744
|
-
ampm: _ampm =
|
|
9794
|
+
ampm: _ampm = false,
|
|
9745
9795
|
ariaLabel,
|
|
9746
9796
|
autoFocus: _autoFocus = false,
|
|
9747
9797
|
className,
|
|
9748
9798
|
'data-testid': dataTestId,
|
|
9749
9799
|
defaultValue,
|
|
9750
9800
|
disableOpenPicker: _disableOpenPicker = false,
|
|
9801
|
+
disableClickAwayListener: _disableClickAwayListener = false,
|
|
9751
9802
|
disabled,
|
|
9752
9803
|
error,
|
|
9753
9804
|
format,
|
|
@@ -9759,8 +9810,10 @@ const DotTimePicker = ({
|
|
|
9759
9810
|
label,
|
|
9760
9811
|
onAccept,
|
|
9761
9812
|
onBlur,
|
|
9813
|
+
onCancel,
|
|
9762
9814
|
onChange,
|
|
9763
9815
|
onClose,
|
|
9816
|
+
onKeyDown,
|
|
9764
9817
|
onOpen,
|
|
9765
9818
|
open,
|
|
9766
9819
|
persistentLabel,
|
|
@@ -9768,7 +9821,7 @@ const DotTimePicker = ({
|
|
|
9768
9821
|
required: _required = false,
|
|
9769
9822
|
value
|
|
9770
9823
|
}) => {
|
|
9771
|
-
const
|
|
9824
|
+
const displayFormat = format || DEFAULT_TIME_FORMAT;
|
|
9772
9825
|
const hasValueWithoutChangeHandler = value !== undefined && onChange === undefined;
|
|
9773
9826
|
const hasBothValueAndDefaultValue = value !== undefined && defaultValue !== undefined;
|
|
9774
9827
|
const isComponentReadOnly = _readOnly || hasValueWithoutChangeHandler || hasBothValueAndDefaultValue;
|
|
@@ -9785,7 +9838,7 @@ const DotTimePicker = ({
|
|
|
9785
9838
|
const minutes = getMinutesForTimePicker();
|
|
9786
9839
|
const daytimeSelected = getSelectedDaytime(pickerTime);
|
|
9787
9840
|
const selectedPickerHour = pickerTime && calculateHourBasedOnTimeFormat(pickerTime, _ampm);
|
|
9788
|
-
const isOpenPropDefined = open
|
|
9841
|
+
const isOpenPropDefined = checkIfOpenPropDefined(open);
|
|
9789
9842
|
const isControlledComponent = onChange && value !== undefined;
|
|
9790
9843
|
useEffect(() => {
|
|
9791
9844
|
if (hasValueWithoutChangeHandler) {
|
|
@@ -9798,9 +9851,9 @@ const DotTimePicker = ({
|
|
|
9798
9851
|
useEffect(() => {
|
|
9799
9852
|
let timeValue = null;
|
|
9800
9853
|
if (defaultValue) {
|
|
9801
|
-
timeValue = getDayjsUtcDate(defaultValue,
|
|
9854
|
+
timeValue = getDayjsUtcDate(defaultValue, DEFAULT_TIME_FORMAT);
|
|
9802
9855
|
} else if (value) {
|
|
9803
|
-
timeValue = getDayjsUtcDate(value,
|
|
9856
|
+
timeValue = getDayjsUtcDate(value, DEFAULT_TIME_FORMAT);
|
|
9804
9857
|
}
|
|
9805
9858
|
setTime(timeValue);
|
|
9806
9859
|
setPickerTime(timeValue);
|
|
@@ -9826,7 +9879,7 @@ const DotTimePicker = ({
|
|
|
9826
9879
|
const currentTimeValue = currentValue ? currentValue : null;
|
|
9827
9880
|
setPickerTime(currentValue ? currentValue : null);
|
|
9828
9881
|
!isControlledComponent && setTime(currentTimeValue);
|
|
9829
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(currentValue ? currentValue.format(
|
|
9882
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(currentValue ? currentValue.format(DEFAULT_TIME_FORMAT) : null, context);
|
|
9830
9883
|
};
|
|
9831
9884
|
const handleClose = () => {
|
|
9832
9885
|
!isOpenPropDefined && setIsPickerOpened(false);
|
|
@@ -9851,6 +9904,7 @@ const DotTimePicker = ({
|
|
|
9851
9904
|
};
|
|
9852
9905
|
const handleCancel = () => {
|
|
9853
9906
|
setPickerTime(time);
|
|
9907
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
9854
9908
|
handleClose();
|
|
9855
9909
|
};
|
|
9856
9910
|
const handleSet = () => {
|
|
@@ -9859,12 +9913,16 @@ const DotTimePicker = ({
|
|
|
9859
9913
|
return;
|
|
9860
9914
|
}
|
|
9861
9915
|
setTime(pickerTime);
|
|
9862
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(pickerTime.format(
|
|
9916
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(pickerTime.format(DEFAULT_TIME_FORMAT), {
|
|
9863
9917
|
validationError: null
|
|
9864
9918
|
});
|
|
9865
|
-
onAccept === null || onAccept === void 0 ? void 0 : onAccept(pickerTime.format(
|
|
9919
|
+
onAccept === null || onAccept === void 0 ? void 0 : onAccept(pickerTime.format(DEFAULT_TIME_FORMAT));
|
|
9866
9920
|
handleClose();
|
|
9867
9921
|
};
|
|
9922
|
+
const handleKeyDown = contextEnum => event => {
|
|
9923
|
+
const currentContextEnum = getContextEnumBasedOnTarget(event, inputRef === null || inputRef === void 0 ? void 0 : inputRef.current, contextEnum);
|
|
9924
|
+
onKeyDown(event, currentContextEnum);
|
|
9925
|
+
};
|
|
9868
9926
|
const scrollToSelectedTime = () => {
|
|
9869
9927
|
if (!(hoursRef === null || hoursRef === void 0 ? void 0 : hoursRef.current) || !(minutesRef === null || minutesRef === void 0 ? void 0 : minutesRef.current)) return;
|
|
9870
9928
|
const selectedHour = calculateHourBasedOnTimeFormat(time, _ampm);
|
|
@@ -9897,6 +9955,100 @@ const DotTimePicker = ({
|
|
|
9897
9955
|
if (event.key !== 'Escape' || !isPickerOpened) return;
|
|
9898
9956
|
handleCancel();
|
|
9899
9957
|
};
|
|
9958
|
+
const wrapWithClickAwayListener = children => jsx(ClickAwayListener, Object.assign({
|
|
9959
|
+
onClickAway: handleSet
|
|
9960
|
+
}, {
|
|
9961
|
+
children: children
|
|
9962
|
+
}), void 0);
|
|
9963
|
+
const renderTimePickerHours = () => hours.map((hour, index) => {
|
|
9964
|
+
const isSelected = pickerTime ? selectedPickerHour === hour : false;
|
|
9965
|
+
return jsx(DotButton, Object.assign({
|
|
9966
|
+
className: "dot-picker-button",
|
|
9967
|
+
"data-testid": dataTestId && `${dataTestId}-hour-button-${hour}`,
|
|
9968
|
+
onClick: () => handleHourClick(hour),
|
|
9969
|
+
onKeyDown: handleTimeKeydown(hoursRef, index),
|
|
9970
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, selectedPickerHour),
|
|
9971
|
+
type: isSelected ? 'primary' : 'text'
|
|
9972
|
+
}, {
|
|
9973
|
+
children: hour.toString().padStart(2, '0')
|
|
9974
|
+
}), hour);
|
|
9975
|
+
});
|
|
9976
|
+
const renderTimePickerMinutes = () => minutes.map((minute, index) => {
|
|
9977
|
+
const isSelected = pickerTime ? pickerTime.minute() === minute : false;
|
|
9978
|
+
return jsx(DotButton, Object.assign({
|
|
9979
|
+
className: "dot-picker-button",
|
|
9980
|
+
"data-testid": dataTestId && `${dataTestId}-minute-button-${minute}`,
|
|
9981
|
+
type: isSelected ? 'primary' : 'text',
|
|
9982
|
+
onClick: () => handleMinuteClick(minute),
|
|
9983
|
+
onKeyDown: handleTimeKeydown(minutesRef, index),
|
|
9984
|
+
tabIndex: getPopperButtonTabIndex(index, isSelected, pickerTime === null || pickerTime === void 0 ? void 0 : pickerTime.minute())
|
|
9985
|
+
}, {
|
|
9986
|
+
children: minute.toString().padStart(2, '0')
|
|
9987
|
+
}), minute);
|
|
9988
|
+
});
|
|
9989
|
+
const renderTimePickerActionButtons = () => jsxs("div", Object.assign({
|
|
9990
|
+
className: "dot-time-picker-action-buttons"
|
|
9991
|
+
}, {
|
|
9992
|
+
children: [jsx(DotButton, Object.assign({
|
|
9993
|
+
"data-testid": dataTestId && `${dataTestId}-cancel`,
|
|
9994
|
+
onClick: handleCancel,
|
|
9995
|
+
size: "small",
|
|
9996
|
+
type: "text"
|
|
9997
|
+
}, {
|
|
9998
|
+
children: "Cancel"
|
|
9999
|
+
}), void 0), jsx(DotButton, Object.assign({
|
|
10000
|
+
"data-testid": dataTestId && `${dataTestId}-set`,
|
|
10001
|
+
onClick: handleSet,
|
|
10002
|
+
size: "small",
|
|
10003
|
+
type: "text"
|
|
10004
|
+
}, {
|
|
10005
|
+
children: "Set"
|
|
10006
|
+
}), void 0)]
|
|
10007
|
+
}), void 0);
|
|
10008
|
+
const renderDaytime = () => jsxs("div", Object.assign({
|
|
10009
|
+
className: "dot-time-picker-daytime",
|
|
10010
|
+
ref: daytimeRef
|
|
10011
|
+
}, {
|
|
10012
|
+
children: [jsx(DotButton, Object.assign({
|
|
10013
|
+
className: "dot-picker-button",
|
|
10014
|
+
"data-testid": dataTestId && `${dataTestId}-am-button`,
|
|
10015
|
+
onClick: () => handleDaytimeSelection(Daytime.AM),
|
|
10016
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 0),
|
|
10017
|
+
tabIndex: getDaytimeButtonTabIndex(Daytime.AM, daytimeSelected),
|
|
10018
|
+
type: getDaytimeButtonType(daytimeSelected)
|
|
10019
|
+
}, {
|
|
10020
|
+
children: Daytime.AM
|
|
10021
|
+
}), Daytime.AM), jsx(DotButton, Object.assign({
|
|
10022
|
+
className: "dot-picker-button",
|
|
10023
|
+
"data-testid": dataTestId && `${dataTestId}-pm-button`,
|
|
10024
|
+
onClick: () => handleDaytimeSelection(Daytime.PM),
|
|
10025
|
+
onKeyDown: handleTimeKeydown(daytimeRef, 1),
|
|
10026
|
+
tabIndex: getDaytimeButtonTabIndex(Daytime.PM, daytimeSelected),
|
|
10027
|
+
type: getTimePickerButtonType(daytimeSelected)
|
|
10028
|
+
}, {
|
|
10029
|
+
children: Daytime.PM
|
|
10030
|
+
}), Daytime.PM)]
|
|
10031
|
+
}), void 0);
|
|
10032
|
+
const paperComponent = jsxs(Paper, Object.assign({
|
|
10033
|
+
className: "dot-time-picker-paper",
|
|
10034
|
+
elevation: 8
|
|
10035
|
+
}, {
|
|
10036
|
+
children: [jsxs("div", Object.assign({
|
|
10037
|
+
className: "dot-time-picker-selection"
|
|
10038
|
+
}, {
|
|
10039
|
+
children: [jsx("div", Object.assign({
|
|
10040
|
+
className: "dot-time-picker-hours",
|
|
10041
|
+
ref: hoursRef
|
|
10042
|
+
}, {
|
|
10043
|
+
children: renderTimePickerHours()
|
|
10044
|
+
}), void 0), jsx("div", Object.assign({
|
|
10045
|
+
className: "dot-time-picker-minutes",
|
|
10046
|
+
ref: minutesRef
|
|
10047
|
+
}, {
|
|
10048
|
+
children: renderTimePickerMinutes()
|
|
10049
|
+
}), void 0), _ampm && renderDaytime()]
|
|
10050
|
+
}), void 0), !hideActionButtons && renderTimePickerActionButtons()]
|
|
10051
|
+
}), void 0);
|
|
9900
10052
|
return jsxs(StyledTimePickerContainer, Object.assign({
|
|
9901
10053
|
className: containerClasses,
|
|
9902
10054
|
"data-testid": dataTestId,
|
|
@@ -9918,7 +10070,7 @@ const DotTimePicker = ({
|
|
|
9918
10070
|
autoFocus: _autoFocus,
|
|
9919
10071
|
className: rootClasses,
|
|
9920
10072
|
disabled: disabled,
|
|
9921
|
-
format:
|
|
10073
|
+
format: displayFormat,
|
|
9922
10074
|
inputRef: inputRef,
|
|
9923
10075
|
label: persistentLabel ? null : label,
|
|
9924
10076
|
onChange: handleInputChange,
|
|
@@ -9948,7 +10100,8 @@ const DotTimePicker = ({
|
|
|
9948
10100
|
onBlur
|
|
9949
10101
|
},
|
|
9950
10102
|
fullWidth: _fullWidth,
|
|
9951
|
-
name: inputName
|
|
10103
|
+
name: inputName,
|
|
10104
|
+
onKeyDown: onKeyDown && handleKeyDown(DatePickerKeydownContext.Input)
|
|
9952
10105
|
},
|
|
9953
10106
|
field: {
|
|
9954
10107
|
readOnly: isComponentReadOnly
|
|
@@ -9962,97 +10115,10 @@ const DotTimePicker = ({
|
|
|
9962
10115
|
"data-testid": dataTestId && `${dataTestId}-popper`,
|
|
9963
10116
|
disablePortal: true,
|
|
9964
10117
|
open: isPickerOpened,
|
|
10118
|
+
onKeyDown: onKeyDown && handleKeyDown(DatePickerKeydownContext.Popper),
|
|
9965
10119
|
placement: "bottom-start"
|
|
9966
10120
|
}, {
|
|
9967
|
-
children:
|
|
9968
|
-
onClickAway: handleSet
|
|
9969
|
-
}, {
|
|
9970
|
-
children: jsxs(Paper, Object.assign({
|
|
9971
|
-
className: "dot-time-picker-paper",
|
|
9972
|
-
elevation: 8
|
|
9973
|
-
}, {
|
|
9974
|
-
children: [jsxs("div", Object.assign({
|
|
9975
|
-
className: "dot-time-picker-selection"
|
|
9976
|
-
}, {
|
|
9977
|
-
children: [jsx("div", Object.assign({
|
|
9978
|
-
className: "dot-time-picker-hours",
|
|
9979
|
-
ref: hoursRef
|
|
9980
|
-
}, {
|
|
9981
|
-
children: hours.map((hour, index) => {
|
|
9982
|
-
const isSelected = pickerTime ? selectedPickerHour === hour : false;
|
|
9983
|
-
return jsx(DotButton, Object.assign({
|
|
9984
|
-
className: "dot-picker-button",
|
|
9985
|
-
"data-testid": dataTestId && `${dataTestId}-hour-button-${hour}`,
|
|
9986
|
-
onClick: () => handleHourClick(hour),
|
|
9987
|
-
onKeyDown: handleTimeKeydown(hoursRef, index),
|
|
9988
|
-
tabIndex: getPopperButtonTabIndex(index, isSelected, selectedPickerHour),
|
|
9989
|
-
type: isSelected ? 'primary' : 'text'
|
|
9990
|
-
}, {
|
|
9991
|
-
children: hour.toString().padStart(2, '0')
|
|
9992
|
-
}), hour);
|
|
9993
|
-
})
|
|
9994
|
-
}), void 0), jsx("div", Object.assign({
|
|
9995
|
-
className: "dot-time-picker-minutes",
|
|
9996
|
-
ref: minutesRef
|
|
9997
|
-
}, {
|
|
9998
|
-
children: minutes.map((minute, index) => {
|
|
9999
|
-
const isSelected = pickerTime ? pickerTime.minute() === minute : false;
|
|
10000
|
-
return jsx(DotButton, Object.assign({
|
|
10001
|
-
className: "dot-picker-button",
|
|
10002
|
-
"data-testid": dataTestId && `${dataTestId}-minute-button-${minute}`,
|
|
10003
|
-
type: isSelected ? 'primary' : 'text',
|
|
10004
|
-
onClick: () => handleMinuteClick(minute),
|
|
10005
|
-
onKeyDown: handleTimeKeydown(minutesRef, index),
|
|
10006
|
-
tabIndex: getPopperButtonTabIndex(index, isSelected, pickerTime === null || pickerTime === void 0 ? void 0 : pickerTime.minute())
|
|
10007
|
-
}, {
|
|
10008
|
-
children: minute.toString().padStart(2, '0')
|
|
10009
|
-
}), minute);
|
|
10010
|
-
})
|
|
10011
|
-
}), void 0), _ampm && jsxs("div", Object.assign({
|
|
10012
|
-
className: "dot-time-picker-daytime",
|
|
10013
|
-
ref: daytimeRef
|
|
10014
|
-
}, {
|
|
10015
|
-
children: [jsx(DotButton, Object.assign({
|
|
10016
|
-
className: "dot-picker-button",
|
|
10017
|
-
"data-testid": dataTestId && `${dataTestId}-am-button`,
|
|
10018
|
-
onClick: () => handleDaytimeSelection(Daytime.AM),
|
|
10019
|
-
onKeyDown: handleTimeKeydown(daytimeRef, 0),
|
|
10020
|
-
tabIndex: getDaytimeButtonTabIndex(Daytime.AM, daytimeSelected),
|
|
10021
|
-
type: daytimeSelected && daytimeSelected === Daytime.AM ? 'primary' : 'text'
|
|
10022
|
-
}, {
|
|
10023
|
-
children: Daytime.AM
|
|
10024
|
-
}), Daytime.AM), jsx(DotButton, Object.assign({
|
|
10025
|
-
className: "dot-picker-button",
|
|
10026
|
-
"data-testid": dataTestId && `${dataTestId}-pm-button`,
|
|
10027
|
-
onClick: () => handleDaytimeSelection(Daytime.PM),
|
|
10028
|
-
onKeyDown: handleTimeKeydown(daytimeRef, 1),
|
|
10029
|
-
tabIndex: getDaytimeButtonTabIndex(Daytime.PM, daytimeSelected),
|
|
10030
|
-
type: getTimePickerButtonType(daytimeSelected)
|
|
10031
|
-
}, {
|
|
10032
|
-
children: Daytime.PM
|
|
10033
|
-
}), Daytime.PM)]
|
|
10034
|
-
}), void 0)]
|
|
10035
|
-
}), void 0), !hideActionButtons && jsxs("div", Object.assign({
|
|
10036
|
-
className: "dot-time-picker-action-buttons"
|
|
10037
|
-
}, {
|
|
10038
|
-
children: [jsx(DotButton, Object.assign({
|
|
10039
|
-
"data-testid": dataTestId && `${dataTestId}-cancel`,
|
|
10040
|
-
onClick: handleCancel,
|
|
10041
|
-
size: "small",
|
|
10042
|
-
type: "text"
|
|
10043
|
-
}, {
|
|
10044
|
-
children: "Cancel"
|
|
10045
|
-
}), void 0), jsx(DotButton, Object.assign({
|
|
10046
|
-
"data-testid": dataTestId && `${dataTestId}-set`,
|
|
10047
|
-
onClick: handleSet,
|
|
10048
|
-
size: "small",
|
|
10049
|
-
type: "text"
|
|
10050
|
-
}, {
|
|
10051
|
-
children: "Set"
|
|
10052
|
-
}), void 0)]
|
|
10053
|
-
}), void 0)]
|
|
10054
|
-
}), void 0)
|
|
10055
|
-
}), void 0)
|
|
10121
|
+
children: _disableClickAwayListener ? paperComponent : wrapWithClickAwayListener(paperComponent)
|
|
10056
10122
|
}), void 0)]
|
|
10057
10123
|
}), void 0);
|
|
10058
10124
|
};
|
|
@@ -10069,4 +10135,4 @@ const DotClickAwayListener = ({
|
|
|
10069
10135
|
}, void 0);
|
|
10070
10136
|
};
|
|
10071
10137
|
|
|
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 };
|
|
10138
|
+
export { Cell, CreateUUID, CssCell, CssGrid, CssGridDebug, DatePickerKeydownContext, 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, checkIfValidDate, lightThemeColors as lightColors, mockScrollIntoView, parseAutoCompleteValue, variables as themeVariables, typographyOptions, useDotCoreApiContext, useDotSnackbarContext };
|