@antscorp/antsomi-ui 1.3.5-beta.700 → 1.3.5-beta.702
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { Dayjs } from 'dayjs';
|
|
2
3
|
import { TAdvancedType, TCalculationType, TOperatorKey, TOption, TShowCalculationTypeCondition, ValueTypes } from './types';
|
|
3
4
|
export interface AdvancedPickerProps {
|
|
4
5
|
label?: string;
|
|
@@ -24,16 +25,25 @@ export interface AdvancedPickerProps {
|
|
|
24
25
|
isViewMode?: boolean;
|
|
25
26
|
/**
|
|
26
27
|
*
|
|
27
|
-
* @example const disabledTime = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
* @example const disabledTime = (date?: Dayjs) => {
|
|
29
|
+
if (date?.get('date') !== 31)
|
|
30
|
+
return {
|
|
31
|
+
disabledHours: () => [],
|
|
32
|
+
disabledMinutes: () => [],
|
|
33
|
+
disabledSeconds: () => [],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
disabledHours: () => range(0, 24).splice(4, 20),
|
|
38
|
+
disabledMinutes: () => range(30, 60),
|
|
39
|
+
disabledSeconds: () => [55, 56],
|
|
40
|
+
};
|
|
31
41
|
};
|
|
32
42
|
*/
|
|
33
|
-
disabledTime?: {
|
|
34
|
-
disabledHours: number[];
|
|
35
|
-
disabledMinutes: number[];
|
|
36
|
-
disabledSeconds: number[];
|
|
43
|
+
disabledTime?: (date?: Dayjs) => {
|
|
44
|
+
disabledHours: () => number[];
|
|
45
|
+
disabledMinutes: () => number[];
|
|
46
|
+
disabledSeconds: () => number[];
|
|
37
47
|
};
|
|
38
48
|
/**
|
|
39
49
|
* Only show fixed calendar (hide dynamic and )
|
|
@@ -24,12 +24,12 @@ import { DatePickerCustomInput, DatePickerHeader, DropdownContent, DropdownHeade
|
|
|
24
24
|
import { CALCULATION_DATES, CALCULATION_TYPES, DATE_TYPES, DEFAULT_DATE_FORMAT, VALUE_TYPES, ADVANCED_PICKER_TYPE, WEEK_ARR, QUARTER_PLACEHOLDER, WEEK_PLACEHOLDER, DAY_LABEL_SHORT, MONTH_LABEL_FULL, DAY_OF_MONTH, ANCHOR_LEAP_YEAR, GRANULARITY_MAPPING, } from './constants';
|
|
25
25
|
import { globalToken, THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
26
26
|
import { useOutsideClick } from '@antscorp/antsomi-ui/es/hooks/useOutsideClick';
|
|
27
|
-
const isDisabledSpecificTime = (current, info, disabledTime) => {
|
|
27
|
+
const isDisabledSpecificTime = (current, info, disabledTime, date) => {
|
|
28
28
|
if (info.type !== 'time' || typeof current !== 'number' || !disabledTime)
|
|
29
29
|
return false;
|
|
30
|
-
const isDisabledHour = info.subType === 'hour' && disabledTime.disabledHours.includes(current);
|
|
31
|
-
const isDisabledMinute = info.subType === 'minute' && disabledTime.disabledMinutes.includes(current);
|
|
32
|
-
const isDisabledSecond = info.subType === 'second' && disabledTime.disabledSeconds.includes(current);
|
|
30
|
+
const isDisabledHour = info.subType === 'hour' && disabledTime(date).disabledHours().includes(current);
|
|
31
|
+
const isDisabledMinute = info.subType === 'minute' && disabledTime(date).disabledMinutes().includes(current);
|
|
32
|
+
const isDisabledSecond = info.subType === 'second' && disabledTime(date).disabledSeconds().includes(current);
|
|
33
33
|
return isDisabledHour || isDisabledMinute || isDisabledSecond;
|
|
34
34
|
};
|
|
35
35
|
const PATH = '@antscorp/antsomi-ui/es/components/molecules/DatePicker/components/Advanced/DatePickerAdvanced.tsx';
|
|
@@ -351,7 +351,7 @@ export const AdvancedPicker = props => {
|
|
|
351
351
|
renderDropdownFooter()));
|
|
352
352
|
};
|
|
353
353
|
const cellRender = useCallback((current, info) => {
|
|
354
|
-
const isDisabledTime = isDisabledSpecificTime(current, info, disabledTime);
|
|
354
|
+
const isDisabledTime = isDisabledSpecificTime(current, info, disabledTime, dayjs(date));
|
|
355
355
|
return (React.createElement("div", { className: "antsomi-picker-cell-inner", style: Object.assign({ pointerEvents: 'all', width: '100%' }, (isDisabledTime
|
|
356
356
|
? {
|
|
357
357
|
color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorTextDisabled,
|
|
@@ -36,6 +36,7 @@ import { flatTree, recursiveSearchItems } from '@antscorp/antsomi-ui/es/utils';
|
|
|
36
36
|
import { getSelectedTreeData } from './utils';
|
|
37
37
|
// Icons
|
|
38
38
|
import { DataIcon, WarningIcon } from '../../icons';
|
|
39
|
+
import isEqual from 'react-fast-compare';
|
|
39
40
|
const initialState = {
|
|
40
41
|
isOpenPopover: false,
|
|
41
42
|
};
|
|
@@ -80,11 +81,11 @@ export function MatchesAny(props) {
|
|
|
80
81
|
}, []);
|
|
81
82
|
useDeepCompareEffect(() => {
|
|
82
83
|
const selectedTreeData = getSelectedTreeData(items || [], selectedItems || [], selectedTreeDataProp || []);
|
|
83
|
-
if (!isEmpty(selectedTreeData)) {
|
|
84
|
+
if (!isEqual(selectedTreeData, selectedTreeDataProp) && !isEmpty(selectedTreeData)) {
|
|
84
85
|
onSelectedTreeDataChange(selectedTreeData);
|
|
85
86
|
}
|
|
86
87
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
87
|
-
}, [items, selectedItems]);
|
|
88
|
+
}, [items, selectedItems, selectedTreeDataProp]);
|
|
88
89
|
// Handlers
|
|
89
90
|
/**
|
|
90
91
|
* Adds an item and, if applicable, its leaf descendants to the list of selected items.
|