@consta/uikit 5.27.1 → 5.28.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/ModalDeprecated/index.d.ts +1 -0
- package/ModalDeprecated/index.js +1 -0
- package/Notification/index.d.ts +1 -0
- package/Notification/index.js +1 -0
- package/SidebarDeprecated/index.d.ts +1 -0
- package/SidebarDeprecated/index.js +1 -0
- package/__internal__/src/components/Chips/ChipsChoice/ChipsChoice.js +1 -1
- package/__internal__/src/components/Chips/ChipsChoice/ChipsChoice.js.map +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.js +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevel/ContextMenuLevel.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePicker.js +1 -1
- package/__internal__/src/components/DatePicker/DatePicker.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerDropdown/DatePickerDropdown.d.ts +2 -4
- package/__internal__/src/components/DatePicker/DatePickerDropdown/DatePickerDropdown.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.d.ts +2 -4
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.d.ts +3 -6
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.d.ts +1 -0
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/helpers.d.ts +2 -0
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.d.ts +2 -4
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/helpers.d.ts +3 -6
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/DatePickerFieldTypeYear.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/DatePickerFieldTypeYear.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/helpers.d.ts +27 -8
- package/__internal__/src/components/DatePicker/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/types.d.ts +26 -5
- package/__internal__/src/components/DatePicker/types.js +1 -1
- package/__internal__/src/components/DatePicker/types.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTime.js +1 -1
- package/__internal__/src/components/DateTime/DateTime.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeDate/DateTimeTypeDate.js +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeDate/DateTimeTypeDate.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeDateTime/DateTimeTypeDateTime.js +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeDateTime/DateTimeTypeDateTime.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeDateTime/useOnChange.d.ts +2 -2
- package/__internal__/src/components/DateTime/DateTimeTypeDateTime/useOnChange.js +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeDateTime/useOnChange.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeMonth/DateTimeTypeMonth.js +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeMonth/DateTimeTypeMonth.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeTime/DateTimeTypeTime.js +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeTime/DateTimeTypeTime.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeTime/helpers.d.ts +5 -2
- package/__internal__/src/components/DateTime/DateTimeTypeTime/helpers.js +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeTime/helpers.js.map +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeYear/DateTimeTypeYear.js +1 -1
- package/__internal__/src/components/DateTime/DateTimeTypeYear/DateTimeTypeYear.js.map +1 -1
- package/__internal__/src/components/DateTime/helpers/getDisableDatesKey.d.ts +2 -0
- package/__internal__/src/components/DateTime/helpers/getDisableDatesKey.js +2 -0
- package/__internal__/src/components/DateTime/helpers/getDisableDatesKey.js.map +1 -0
- package/__internal__/src/components/DateTime/helpers/getTimeNumbers.d.ts +2 -0
- package/__internal__/src/components/DateTime/helpers/getTimeNumbers.js +2 -0
- package/__internal__/src/components/DateTime/helpers/getTimeNumbers.js.map +1 -0
- package/__internal__/src/components/DateTime/helpers/getTimeOptionsKey.d.ts +2 -0
- package/__internal__/src/components/DateTime/helpers/getTimeOptionsKey.js +2 -0
- package/__internal__/src/components/DateTime/helpers/getTimeOptionsKey.js.map +1 -0
- package/__internal__/src/components/DateTime/helpers/index.d.ts +3 -0
- package/__internal__/src/components/DateTime/helpers/index.js +1 -1
- package/__internal__/src/components/DateTime/helpers/index.js.map +1 -1
- package/__internal__/src/components/DateTime/helpers/types.d.ts +30 -3
- package/__internal__/src/components/DateTime/helpers/types.js.map +1 -1
- package/__internal__/src/components/DragNDropFieldCanary/DragNDropFieldInformer/DragNDropFieldInformer.d.ts +11 -2
- package/__internal__/src/components/DragNDropFieldCanary/DragNDropFieldInformer/DragNDropFieldInformer.js.map +1 -1
- package/__internal__/src/components/DragNDropFieldCanary/types.d.ts +2 -2
- package/__internal__/src/components/DragNDropFieldCanary/types.js.map +1 -1
- package/__internal__/src/components/FlatSelect/FlatSelect.js.map +1 -1
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.js.map +1 -1
- package/__internal__/src/components/FlatSelect/defaultProps.js.map +1 -1
- package/__internal__/src/components/ModalDeprecated/ModalDeprecated.css +1 -0
- package/__internal__/src/components/ModalDeprecated/ModalDeprecated.d.ts +27 -0
- package/__internal__/src/components/ModalDeprecated/ModalDeprecated.js +2 -0
- package/__internal__/src/components/ModalDeprecated/ModalDeprecated.js.map +1 -0
- package/__internal__/src/components/ModalDeprecated/index.d.ts +1 -0
- package/__internal__/src/components/ModalDeprecated/index.js +2 -0
- package/__internal__/src/components/ModalDeprecated/index.js.map +1 -0
- package/__internal__/src/components/Notification/Notification/Notification.css +1 -0
- package/__internal__/src/components/Notification/Notification/Notification.d.ts +4 -0
- package/__internal__/src/components/Notification/Notification/Notification.js +2 -0
- package/__internal__/src/components/Notification/Notification/Notification.js.map +1 -0
- package/__internal__/src/components/Notification/Notification/helpers.d.ts +70 -0
- package/__internal__/src/components/Notification/Notification/helpers.js +2 -0
- package/__internal__/src/components/Notification/Notification/helpers.js.map +1 -0
- package/__internal__/src/components/Notification/Notification/index.d.ts +2 -0
- package/__internal__/src/components/Notification/Notification/index.js +2 -0
- package/__internal__/src/components/Notification/Notification/index.js.map +1 -0
- package/__internal__/src/components/Notification/Notification/types.d.ts +66 -0
- package/__internal__/src/components/Notification/Notification/types.js +2 -0
- package/__internal__/src/components/Notification/Notification/types.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationActions/NotificationActions.d.ts +2 -0
- package/__internal__/src/components/Notification/NotificationActions/NotificationActions.js +2 -0
- package/__internal__/src/components/Notification/NotificationActions/NotificationActions.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationActions/helpers.d.ts +21 -0
- package/__internal__/src/components/Notification/NotificationActions/helpers.js +2 -0
- package/__internal__/src/components/Notification/NotificationActions/helpers.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationActions/index.d.ts +2 -0
- package/__internal__/src/components/Notification/NotificationActions/index.js +2 -0
- package/__internal__/src/components/Notification/NotificationActions/index.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationActions/types.d.ts +30 -0
- package/__internal__/src/components/Notification/NotificationActions/types.js +2 -0
- package/__internal__/src/components/Notification/NotificationActions/types.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationCaption/NotificationCaption.css +1 -0
- package/__internal__/src/components/Notification/NotificationCaption/NotificationCaption.d.ts +7 -0
- package/__internal__/src/components/Notification/NotificationCaption/NotificationCaption.js +2 -0
- package/__internal__/src/components/Notification/NotificationCaption/NotificationCaption.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationCaption/index.d.ts +1 -0
- package/__internal__/src/components/Notification/NotificationCaption/index.js +2 -0
- package/__internal__/src/components/Notification/NotificationCaption/index.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationGroup/NotificationGroup.css +1 -0
- package/__internal__/src/components/Notification/NotificationGroup/NotificationGroup.d.ts +4 -0
- package/__internal__/src/components/Notification/NotificationGroup/NotificationGroup.js +2 -0
- package/__internal__/src/components/Notification/NotificationGroup/NotificationGroup.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationGroup/index.d.ts +2 -0
- package/__internal__/src/components/Notification/NotificationGroup/index.js +2 -0
- package/__internal__/src/components/Notification/NotificationGroup/index.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationGroup/types.d.ts +12 -0
- package/__internal__/src/components/Notification/NotificationGroup/types.js +2 -0
- package/__internal__/src/components/Notification/NotificationGroup/types.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationHeader/NotificationHeader.css +1 -0
- package/__internal__/src/components/Notification/NotificationHeader/NotificationHeader.d.ts +5 -0
- package/__internal__/src/components/Notification/NotificationHeader/NotificationHeader.js +2 -0
- package/__internal__/src/components/Notification/NotificationHeader/NotificationHeader.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationHeader/index.d.ts +2 -0
- package/__internal__/src/components/Notification/NotificationHeader/index.js +2 -0
- package/__internal__/src/components/Notification/NotificationHeader/index.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationHeader/types.d.ts +14 -0
- package/__internal__/src/components/Notification/NotificationHeader/types.js +2 -0
- package/__internal__/src/components/Notification/NotificationHeader/types.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationItem/NotificationItem.css +1 -0
- package/__internal__/src/components/Notification/NotificationItem/NotificationItem.d.ts +6 -0
- package/__internal__/src/components/Notification/NotificationItem/NotificationItem.js +2 -0
- package/__internal__/src/components/Notification/NotificationItem/NotificationItem.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationItem/index.d.ts +2 -0
- package/__internal__/src/components/Notification/NotificationItem/index.js +2 -0
- package/__internal__/src/components/Notification/NotificationItem/index.js.map +1 -0
- package/__internal__/src/components/Notification/NotificationItem/types.d.ts +19 -0
- package/__internal__/src/components/Notification/NotificationItem/types.js +2 -0
- package/__internal__/src/components/Notification/NotificationItem/types.js.map +1 -0
- package/__internal__/src/components/Notification/helpers/defaultDateFormat.d.ts +1 -0
- package/__internal__/src/components/Notification/helpers/defaultDateFormat.js +2 -0
- package/__internal__/src/components/Notification/helpers/defaultDateFormat.js.map +1 -0
- package/__internal__/src/components/Notification/helpers/groupLabelByDay.d.ts +1 -0
- package/__internal__/src/components/Notification/helpers/groupLabelByDay.js +2 -0
- package/__internal__/src/components/Notification/helpers/groupLabelByDay.js.map +1 -0
- package/__internal__/src/components/Notification/helpers/groupsByDay.d.ts +1 -0
- package/__internal__/src/components/Notification/helpers/groupsByDay.js +2 -0
- package/__internal__/src/components/Notification/helpers/groupsByDay.js.map +1 -0
- package/__internal__/src/components/Notification/helpers/index.d.ts +4 -0
- package/__internal__/src/components/Notification/helpers/index.js +2 -0
- package/__internal__/src/components/Notification/helpers/index.js.map +1 -0
- package/__internal__/src/components/Notification/helpers/sortGroupByDay.d.ts +5 -0
- package/__internal__/src/components/Notification/helpers/sortGroupByDay.js +2 -0
- package/__internal__/src/components/Notification/helpers/sortGroupByDay.js.map +1 -0
- package/__internal__/src/components/Notification/index.d.ts +7 -0
- package/__internal__/src/components/Notification/index.js +2 -0
- package/__internal__/src/components/Notification/index.js.map +1 -0
- package/__internal__/src/components/Sidebar/Sidebar.js +1 -1
- package/__internal__/src/components/Sidebar/Sidebar.js.map +1 -1
- package/__internal__/src/components/Sidebar/types.d.ts +3 -2
- package/__internal__/src/components/Sidebar/types.js.map +1 -1
- package/__internal__/src/components/SidebarDeprecated/SidebarDeprecated.css +1 -0
- package/__internal__/src/components/SidebarDeprecated/SidebarDeprecated.d.ts +39 -0
- package/__internal__/src/components/SidebarDeprecated/SidebarDeprecated.js +2 -0
- package/__internal__/src/components/SidebarDeprecated/SidebarDeprecated.js.map +1 -0
- package/__internal__/src/components/SidebarDeprecated/index.d.ts +1 -0
- package/__internal__/src/components/SidebarDeprecated/index.js +2 -0
- package/__internal__/src/components/SidebarDeprecated/index.js.map +1 -0
- package/__internal__/src/utils/getItemClick.d.ts +5 -0
- package/__internal__/src/utils/getItemClick.js +2 -0
- package/__internal__/src/utils/getItemClick.js.map +1 -0
- package/__internal__/src/utils/object/keys.d.ts +1 -0
- package/__internal__/src/utils/object/keys.js +2 -0
- package/__internal__/src/utils/object/keys.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerTypeTime.js","names":["React","forwardRef","useEffect","useRef","useClickOutside","useForkRef","setRef","DatePickerDropdown","DatePickerFieldTypeTime","datePickerPropFormatTypeDateTime","getDropdownZIndex","
|
|
1
|
+
{"version":3,"file":"DatePickerTypeTime.js","names":["React","forwardRef","useEffect","useRef","useClickOutside","useForkRef","setRef","DatePickerDropdown","DatePickerFieldTypeTime","datePickerPropFormatTypeDateTime","getDropdownZIndex","getTimeOptionsByFormat","datePickerPropDateTimeViewDefault","useCalendarVisible","DatePickerTypeTime","props","ref","events","dateTimeView","locale","dropdownForm","dropdownClassName","dropdownRef","timeOptionsProp","timeOptions","renderAdditionalControls","currentVisibleDate","onChangeCurrentVisibleDate","onDropdownOpen","dropdownOpen","ignoreOutsideClicksRefs","disabled","inputRefProp","inputRef","disableDates","otherProps","format","fieldRef","calendarRef","startRef","calendarVisible","setCalendarVisible","current","isActive","ignoreClicksInsideRefs","handler","off","on","value","minDate","maxDate","onChange","style"],"sources":["../../../../../../src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.tsx"],"sourcesContent":["import React, { forwardRef, useEffect, useRef } from 'react';\n\nimport { useClickOutside } from '##/hooks/useClickOutside/useClickOutside';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { setRef } from '##/utils/setRef';\n\nimport { DatePickerDropdown } from '../DatePickerDropdown/DatePickerDropdown';\nimport { DatePickerFieldTypeTime } from '../DatePickerFieldTypeTime/DatePickerFieldTypeTime';\nimport {\n datePickerPropFormatTypeDateTime,\n getDropdownZIndex,\n getTimeOptionsByFormat,\n} from '../helpers';\nimport {\n datePickerPropDateTimeViewDefault,\n DatePickerTypeComponent,\n} from '../types';\nimport { useCalendarVisible } from '../useCalendarVisible';\n\nexport const DatePickerTypeTime: DatePickerTypeComponent<'time'> = forwardRef(\n (props, ref) => {\n const {\n events,\n dateTimeView = datePickerPropDateTimeViewDefault,\n locale,\n dropdownForm,\n dropdownClassName,\n dropdownRef,\n timeOptions: timeOptionsProp,\n renderAdditionalControls,\n currentVisibleDate,\n onChangeCurrentVisibleDate,\n onDropdownOpen,\n dropdownOpen,\n ignoreOutsideClicksRefs,\n disabled,\n inputRef: inputRefProp,\n disableDates,\n ...otherProps\n } = props;\n\n const timeOptions = getTimeOptionsByFormat(\n otherProps.format || datePickerPropFormatTypeDateTime,\n timeOptionsProp,\n );\n\n const fieldRef = useRef<HTMLDivElement>(null);\n const calendarRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n\n const [calendarVisible, setCalendarVisible] = useCalendarVisible({\n dropdownOpen,\n onDropdownOpen,\n disabled,\n startRef: inputRef,\n });\n\n useEffect(() => {\n if (ref) {\n setRef(ref, fieldRef.current);\n }\n }, [ref, fieldRef]);\n\n useClickOutside({\n isActive: calendarVisible,\n ignoreClicksInsideRefs: [\n fieldRef,\n calendarRef,\n ...(ignoreOutsideClicksRefs ?? []),\n ],\n handler: setCalendarVisible.off,\n });\n\n return (\n <>\n <DatePickerFieldTypeTime\n {...otherProps}\n ref={fieldRef}\n inputRef={useForkRef([inputRef, inputRefProp])}\n onClick={setCalendarVisible.on}\n timeOptions={timeOptions}\n disabled={disabled}\n />\n <DatePickerDropdown\n ref={useForkRef([dropdownRef, calendarRef])}\n anchorRef={fieldRef}\n isOpen={calendarVisible}\n value={props.value || undefined}\n type=\"time\"\n view={dateTimeView}\n events={events}\n locale={locale}\n minDate={props.minDate}\n maxDate={props.maxDate}\n form={dropdownForm}\n className={dropdownClassName}\n onChange={props.onChange}\n renderAdditionalControls={renderAdditionalControls}\n timeOptions={timeOptions}\n zIndex={getDropdownZIndex(props.style)}\n disableDates={disableDates}\n />\n </>\n );\n },\n);\n"],"mappings":"2fAAA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,SAA5B,CAAuCC,MAAvC,KAAqD,OAArD,CAEA,OAASC,eAAT,sDACA,OAASC,UAAT,iCACA,OAASC,MAAT,6BAEA,OAASC,kBAAT,gDACA,OAASC,uBAAT,0DACA,OACEC,gCADF,CAEEC,iBAFF,CAGEC,sBAHF,kBAKA,OACEC,iCADF,gBAIA,OAASC,kBAAT,6BAEA,MAAO,IAAMC,mBAAmD,CAAGb,UAAU,CAC3E,SAACc,CAAD,CAAQC,CAAR,CAAgB,IAEZC,EAFY,CAmBVF,CAnBU,CAEZE,MAFY,GAmBVF,CAnBU,CAGZG,YAHY,CAGZA,CAHY,YAGGN,iCAHH,GAIZO,CAJY,CAmBVJ,CAnBU,CAIZI,MAJY,CAKZC,CALY,CAmBVL,CAnBU,CAKZK,YALY,CAMZC,CANY,CAmBVN,CAnBU,CAMZM,iBANY,CAOZC,CAPY,CAmBVP,CAnBU,CAOZO,WAPY,CAQCC,CARD,CAmBVR,CAnBU,CAQZS,WARY,CASZC,CATY,CAmBVV,CAnBU,CASZU,wBATY,CAUZC,CAVY,CAmBVX,CAnBU,CAUZW,kBAVY,CAWZC,CAXY,CAmBVZ,CAnBU,CAWZY,0BAXY,CAYZC,CAZY,CAmBVb,CAnBU,CAYZa,cAZY,CAaZC,CAbY,CAmBVd,CAnBU,CAaZc,YAbY,CAcZC,CAdY,CAmBVf,CAnBU,CAcZe,uBAdY,CAeZC,CAfY,CAmBVhB,CAnBU,CAeZgB,QAfY,CAgBFC,C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cgB,CAAd,CAAD,CADjB,CAEE,SAAS,CAAED,CAFb,CAGE,MAAM,CAAEG,CAHV,CAIE,KAAK,CAAEzB,CAAK,CAACiC,KAAN,QAJT,CAKE,IAAI,CAAC,MALP,CAME,IAAI,CAAE9B,CANR,CAOE,MAAM,CAAED,CAPV,CAQE,MAAM,CAAEE,CARV,CASE,OAAO,CAAEJ,CAAK,CAACkC,OATjB,CAUE,OAAO,CAAElC,CAAK,CAACmC,OAVjB,CAWE,IAAI,CAAE9B,CAXR,CAYE,SAAS,CAAEC,CAZb,CAaE,QAAQ,CAAEN,CAAK,CAACoC,QAblB,CAcE,wBAAwB,CAAE1B,CAd5B,CAeE,WAAW,CAAED,CAff,CAgBE,MAAM,CAAEd,iBAAiB,CAACK,CAAK,CAACqC,KAAP,CAhB3B,CAiBE,YAAY,CAAElB,CAjBhB,EATF,CA8BH,CArF0E,CAAtE"}
|
|
@@ -1,21 +1,39 @@
|
|
|
1
|
-
import { useIMask } from 'react-imask';
|
|
1
|
+
import { IMask, useIMask } from 'react-imask';
|
|
2
2
|
import { TextFieldPropForm } from '../TextField';
|
|
3
3
|
import { DateRange } from '../../utils/types/Date';
|
|
4
|
+
import { TimeOptions, TimeUnitOptions } from '../DateTime';
|
|
4
5
|
import { DatePickerPropType } from './types';
|
|
5
6
|
export declare const datePickerPropSeparatorDefault = ".";
|
|
6
7
|
export declare const datePickerPropFormatTypeDate = "dd.MM.yyyy";
|
|
7
|
-
export declare const datePickerPropPlaceholderTypeDate = "\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413";
|
|
8
8
|
export declare const datePickerPropFormatTypeTime = "HH:mm:ss";
|
|
9
|
-
export declare const datePickerPropPlaceholderTypeTime = "\u0427\u0427:\u041C\u041C:\u0421\u0421";
|
|
10
9
|
export declare const datePickerPropFormatTypeDateTime = "dd.MM.yyyy HH:mm:ss";
|
|
11
|
-
export declare const datePickerPropPlaceholderTypeDateTime = "\u0414\u0414.\u041C\u041C.\u0413\u0413\u0413\u0413 \u0427\u0427:\u041C\u041C:\u0421\u0421";
|
|
12
10
|
export declare const datePickerPropFormatTypeYear = "yyyy";
|
|
13
|
-
export declare const datePickerPropPlaceholderTypeYear = "\u0413\u0413\u0413\u0413";
|
|
14
11
|
export declare const datePickerPropFormatTypeMonth = "MM.yyyy";
|
|
15
|
-
export declare const datePickerPropPlaceholderTypeMonth = "MM.\u0413\u0413\u0413\u0413";
|
|
16
12
|
export declare const normalizeRangeValue: (dateRange: DateRange) => DateRange;
|
|
17
|
-
export declare const
|
|
18
|
-
|
|
13
|
+
export declare const getTimeOptionsByFormat: (format: string, timeOptions?: TimeOptions) => {
|
|
14
|
+
hours: TimeUnitOptions | undefined;
|
|
15
|
+
minutes: TimeUnitOptions | undefined;
|
|
16
|
+
seconds: TimeUnitOptions | undefined;
|
|
17
|
+
};
|
|
18
|
+
export declare const adaptFormat: (format: string, timeOptions?: TimeOptions) => string;
|
|
19
|
+
export declare const placeholderByFormat: (format: string) => string;
|
|
20
|
+
type MaskBlock = {
|
|
21
|
+
mask: typeof IMask.MaskedRange;
|
|
22
|
+
from: number;
|
|
23
|
+
to: number;
|
|
24
|
+
};
|
|
25
|
+
type MaskBlocks = Partial<{
|
|
26
|
+
dd: MaskBlock;
|
|
27
|
+
MM: MaskBlock;
|
|
28
|
+
yyyy: MaskBlock;
|
|
29
|
+
HH: MaskBlock;
|
|
30
|
+
mm: MaskBlock;
|
|
31
|
+
ss: MaskBlock;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const getMaskBlocks: ({ includeDate, includeTime, }?: {
|
|
34
|
+
includeDate?: boolean | undefined;
|
|
35
|
+
includeTime?: boolean | undefined;
|
|
36
|
+
}) => MaskBlocks;
|
|
19
37
|
export declare const getFormForStart: (form: TextFieldPropForm) => "default" | "defaultClear" | "defaultBrick" | "brick" | "brickDefault" | "brickClear" | "brickRound" | "round" | "roundClear" | "roundBrick" | "clearRound" | "clearDefault" | "clearBrick" | "clearClear";
|
|
20
38
|
export declare const getFormForEnd: (form: TextFieldPropForm) => "default" | "defaultClear" | "defaultBrick" | "brick" | "brickDefault" | "brickClear" | "brickRound" | "round" | "roundClear" | "roundBrick" | "clearRound" | "clearDefault" | "clearBrick" | "clearClear";
|
|
21
39
|
export declare const getPartDate: (formatArray: string[], stringArray: string[], marker: string) => string | undefined;
|
|
@@ -28,4 +46,5 @@ type DatePickerFieldTypeDatePropOnChange = (value: Date | null, props: {
|
|
|
28
46
|
e: Event;
|
|
29
47
|
}) => void;
|
|
30
48
|
export declare const useStringValue: (value: Date | undefined | null, formatProp: string, separator: string, onChangeRef: React.MutableRefObject<DatePickerFieldTypeDatePropOnChange | undefined>, imaskProps: ReturnType<typeof useIMask<HTMLInputElement>>) => import("react").MouseEventHandler<HTMLButtonElement>;
|
|
49
|
+
export declare const isValidTimeByTimeOptions: (date: Date, timeOptions?: TimeOptions) => boolean;
|
|
31
50
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{format,isValid,parse
|
|
1
|
+
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{format,isValid,parse}from"date-fns";import{useCallback,useEffect}from"react";import{IMask}from"react-imask";import{getForm}from"../FieldGroup";import{useMutableRef}from"../../hooks/useMutableRef";import{getTimeNumbers}from"../DateTime/helpers";export var datePickerPropSeparatorDefault=".";export var datePickerPropFormatTypeDate="dd".concat(".","MM").concat(".","yyyy");export var datePickerPropFormatTypeTime="HH:mm:ss";export var datePickerPropFormatTypeDateTime="".concat(datePickerPropFormatTypeDate," ").concat("HH:mm:ss");export var datePickerPropFormatTypeYear="yyyy";export var datePickerPropFormatTypeMonth="MM".concat(".","yyyy");export var normalizeRangeValue=function(a){var b,c;return a[0]&&a[1]&&(null===(b=a[0])||void 0===b?void 0:b.getTime())>(null===(c=a[1])||void 0===c?void 0:c.getTime())?[a[1],a[0]]:a};export var getTimeOptionsByFormat=function(a,b){var c,d=null===(c=a.split(" ")[1])||void 0===c?void 0:c.split(":"),e={HH:null===b||void 0===b?void 0:b.hours,mm:null===b||void 0===b?void 0:b.minutes,ss:null===b||void 0===b?void 0:b.seconds},f=["HH","mm","ss"].map(function(a){return null!==d&&void 0!==d&&d.includes(a)?e[a]:[]}),g=_slicedToArray(f,3),h=g[0],i=g[1],j=g[2];return{hours:h,minutes:i,seconds:j}};export var adaptFormat=function(a,b){for(var c,d=a.split(" "),e=null!==(c=d[1])&&void 0!==c?c:a,f=function shouldRemoveTimePart(a){return!!(a&&Array.isArray(a)&&0===a.length)||a&&!Array.isArray(a)&&0===a.step},g=[{marker:"HH",timeOption:null===b||void 0===b?void 0:b.hours},{marker:"mm",timeOption:null===b||void 0===b?void 0:b.minutes},{marker:"ss",timeOption:null===b||void 0===b?void 0:b.seconds}],h=0,i=g;h<i.length;h++){var j=i[h],k=j.marker,l=j.timeOption;f(l)&&(e=e.replace(new RegExp(":?".concat(k),"g"),""))}return e=e.replace(/:+$/,"").replace(/^:+/,"").replace(/:+/g,":").replace(/\s+/g," ").trim(),1<d.length?(d[1]=e,d.filter(function(a){return 0<a.length}).join(" ")):e};export var placeholderByFormat=function placeholderByFormat(a){return a.replace(/yyyy/g,"\u0413\u0413\u0413\u0413").replace(/MM/g,"\u041C\u041C").replace(/dd/g,"\u0414\u0414").replace(/HH/g,"\u0427\u0427").replace(/mm/g,"\u041C\u041C").replace(/ss/g,"\u0421\u0421")};export var getMaskBlocks=function getMaskBlocks(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},b=a.includeDate,c=void 0===b||b,d=a.includeTime,e=void 0===d||d,f={};return c&&(f.dd={mask:IMask.MaskedRange,from:1,to:31},f.MM={mask:IMask.MaskedRange,from:1,to:12},f.yyyy={mask:IMask.MaskedRange,from:1,to:9999}),e&&(f.HH={mask:IMask.MaskedRange,from:0,to:23},f.mm={mask:IMask.MaskedRange,from:0,to:59},f.ss={mask:IMask.MaskedRange,from:0,to:59}),f};export var getFormForStart=function getFormForStart(a){return getForm(a,0,2)};export var getFormForEnd=function getFormForEnd(a){return getForm(a,1,2)};export var getPartDate=function getPartDate(a,b,c){var d=a.indexOf(c);return 0<=d&&b[d]&&b[d].length===c.length?b[d]:void 0};export var getParts=function getParts(a,b,c){if(c){var d=a.split(" "),e=_slicedToArray(d,2),f=e[0],g=e[1];return[].concat(_toConsumableArray(f?f.split(b):[]),_toConsumableArray(g?g.split(":"):[]))}return a.split(b)};export var getPartsDate=function getPartsDate(a,b,c,d,e){var f=getParts(b,c,d),g=getParts(a,c,d);return e.map(function(a){return getPartDate(f,g,a)})};export var isTypeWithTime=function isTypeWithTime(a){return-1!==a.indexOf("time")};var fieldPrefixs=["start","end"];export var getFieldName=function getFieldName(a,b){return a?Array.isArray(a)?a[b]:"".concat(a,"_").concat(fieldPrefixs[b]):void 0};export var getDropdownZIndex=function getDropdownZIndex(a){return"number"==typeof(null===a||void 0===a?void 0:a.zIndex)?a.zIndex+1:void 0};export var useStringValue=function useStringValue(a,b,c,d,e){var f=e.value,g=useMutableRef([e.setValue,a]),h=useCallback(function(a){var b;g.current[0](a),null!==(b=e.ref)&&void 0!==b&&b.current&&(e.ref.current.value=a),e.maskRef.current&&e.maskRef.current.updateValue()},[]),i=useCallback(function(a){if(h(""),g.current[1]){var b;null===(b=d.current)||void 0===b?void 0:b.call(d,null,{e:a})}},[]);return useEffect(function(){if(a&&isValid(a)&&h(format(a,b)),!a&&f){var d=getParts(b,c,!1),e=getParts(f,c,!1),g=d.map(function(a){return getPartDate(d,e,a)}).filter(function(a){return!!a}),i=d.length===g.length?parse(e.join(datePickerPropSeparatorDefault),d.join(datePickerPropSeparatorDefault),new Date):void 0;isValid(i)&&h("")}},[null===a||void 0===a?void 0:a.getTime()]),i};export var isValidTimeByTimeOptions=function isValidTimeByTimeOptions(a,b){var c=function isUnitValid(a,b,c){if(!c)return!0;var d=getTimeNumbers(a,c);return!(0!==d.length)||d.includes(b)};if(!b)return!0;var d=c("hours",a.getHours(),b.hours),e=c("minutes",a.getMinutes(),b.minutes),f=c("seconds",a.getSeconds(),b.seconds);return d&&e&&f};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["format","isValid","parse","startOfToday","useCallback","useEffect","getForm","useMutableRef","range","datePickerPropSeparatorDefault","datePickerPropFormatTypeDate","datePickerPropPlaceholderTypeDate","datePickerPropFormatTypeTime","datePickerPropPlaceholderTypeTime","datePickerPropFormatTypeDateTime","datePickerPropPlaceholderTypeDateTime","datePickerPropFormatTypeYear","datePickerPropPlaceholderTypeYear","datePickerPropFormatTypeMonth","datePickerPropPlaceholderTypeMonth","normalizeRangeValue","dateRange","getTime","getMultiplicityTime","multiplicityHours","multiplicityMinutes","multiplicitySeconds","formatArray","split","map","HH","mm","ss","marker","indexOf","getTimeEnum","length","multiplicity","startOfUnits","addUnits","getItemLabel","numbers","Math","floor","startDate","number","getFormForStart","form","getFormForEnd","getPartDate","stringArray","index","getParts","separator","withTime","date","time","getPartsDate","value","markers","isTypeWithTime","type","fieldPrefixs","getFieldName","name","rangeIndex","Array","isArray","getDropdownZIndex","style","zIndex","useStringValue","formatProp","onChangeRef","imaskProps","stringValue","refs","setValue","setStringValue","current","ref","maskRef","updateValue","handleClear","e","valueArray","validArray","filter","item","join","Date"],"sources":["../../../../../src/components/DatePicker/helpers.ts"],"sourcesContent":["import { format, isValid, parse, startOfToday } from 'date-fns';\nimport { useCallback, useEffect } from 'react';\nimport { useIMask } from 'react-imask';\n\nimport { getForm } from '##/components/FieldGroup';\nimport { TextFieldPropForm } from '##/components/TextField';\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { range } from '##/utils/array';\nimport { DateRange } from '##/utils/types/Date';\n\nimport { DatePickerPropType } from './types';\n\nexport const datePickerPropSeparatorDefault = '.';\nexport const datePickerPropFormatTypeDate = `dd${datePickerPropSeparatorDefault}MM${datePickerPropSeparatorDefault}yyyy`;\nexport const datePickerPropPlaceholderTypeDate = `ДД${datePickerPropSeparatorDefault}ММ${datePickerPropSeparatorDefault}ГГГГ`;\n\nexport const datePickerPropFormatTypeTime = `HH:mm:ss`;\nexport const datePickerPropPlaceholderTypeTime = `ЧЧ:ММ:СС`;\n\nexport const datePickerPropFormatTypeDateTime = `${datePickerPropFormatTypeDate} ${datePickerPropFormatTypeTime}`;\nexport const datePickerPropPlaceholderTypeDateTime = `${datePickerPropPlaceholderTypeDate} ${datePickerPropPlaceholderTypeTime}`;\n\nexport const datePickerPropFormatTypeYear = `yyyy`;\nexport const datePickerPropPlaceholderTypeYear = `ГГГГ`;\n\nexport const datePickerPropFormatTypeMonth = `MM${datePickerPropSeparatorDefault}yyyy`;\nexport const datePickerPropPlaceholderTypeMonth = `MM${datePickerPropSeparatorDefault}ГГГГ`;\n\nexport const normalizeRangeValue = (dateRange: DateRange): DateRange => {\n if (\n dateRange[0] &&\n dateRange[1] &&\n dateRange[0]?.getTime() > dateRange[1]?.getTime()\n ) {\n return [dateRange[1], dateRange[0]];\n }\n return dateRange;\n};\n\nexport const getMultiplicityTime = (\n format: string,\n multiplicityHours: number | undefined,\n multiplicityMinutes: number | undefined,\n multiplicitySeconds: number | undefined,\n) => {\n const markers = ['HH', 'mm', 'ss'] as const;\n const formatArray = format.split(' ')[1]?.split(':');\n const map = {\n HH: multiplicityHours,\n mm: multiplicityMinutes,\n ss: multiplicitySeconds,\n } as const;\n\n return markers.map((marker) =>\n formatArray?.indexOf(marker) < 0 ? 0 : map[marker],\n );\n};\n\nexport const getTimeEnum = (\n length: number,\n multiplicity = 1,\n startOfUnits: (date: Date) => Date,\n addUnits: (date: Date, amount: number) => Date,\n getItemLabel: (date: Date) => string,\n) => {\n const numbers = range(multiplicity ? Math.floor(length / multiplicity) : 0);\n\n if (numbers.length === 0) {\n return [];\n }\n\n const startDate = startOfUnits(startOfToday());\n\n return numbers.map((number) => {\n return getItemLabel(addUnits(startDate, number * multiplicity));\n });\n};\n\nexport const getFormForStart = (form: TextFieldPropForm) => getForm(form, 0, 2);\nexport const getFormForEnd = (form: TextFieldPropForm) => getForm(form, 1, 2);\n\nexport const getPartDate = (\n formatArray: string[],\n stringArray: string[],\n marker: string,\n) => {\n const index = formatArray.indexOf(marker);\n\n if (\n index >= 0 &&\n stringArray[index] &&\n stringArray[index].length === marker.length\n ) {\n return stringArray[index];\n }\n\n return undefined;\n};\n\nexport const getParts = (\n format: string,\n separator: string,\n withTime?: boolean,\n) => {\n if (withTime) {\n const [date, time] = format.split(' ');\n\n return [\n ...(date ? date.split(separator) : []),\n ...(time ? time.split(':') : []),\n ];\n }\n\n return format.split(separator);\n};\n\nexport const getPartsDate = (\n value: string,\n format: string,\n separator: string,\n withTime: boolean,\n markers: string[],\n) => {\n const formatArray = getParts(format, separator, withTime);\n const stringArray = getParts(value, separator, withTime);\n\n return markers.map((marker) => getPartDate(formatArray, stringArray, marker));\n};\n\nexport const isTypeWithTime = (type: DatePickerPropType) =>\n type.indexOf('time') !== -1;\n\nconst fieldPrefixs = ['start', 'end'] as const;\n\nexport const getFieldName = (\n name: [string?, string?] | string | undefined,\n rangeIndex: 0 | 1,\n) => {\n if (!name) {\n return undefined;\n }\n\n if (Array.isArray(name)) {\n return name[rangeIndex];\n }\n\n return `${name}_${fieldPrefixs[rangeIndex]}`;\n};\n\nexport const getDropdownZIndex = (style?: React.CSSProperties) =>\n typeof style?.zIndex === 'number' ? style.zIndex + 1 : undefined;\n\ntype DatePickerFieldTypeDatePropOnChange = (\n value: Date | null,\n props: {\n e: Event;\n },\n) => void;\n\nexport const useStringValue = (\n value: Date | undefined | null,\n formatProp: string,\n separator: string,\n onChangeRef: React.MutableRefObject<\n DatePickerFieldTypeDatePropOnChange | undefined\n >,\n imaskProps: ReturnType<typeof useIMask<HTMLInputElement>>,\n) => {\n const stringValue = imaskProps.value;\n\n const refs = useMutableRef([imaskProps.setValue, value] as const);\n\n const setStringValue = useCallback((value: string) => {\n refs.current[0](value);\n if (imaskProps.ref?.current) {\n imaskProps.ref.current.value = value;\n }\n if (imaskProps.maskRef.current) {\n imaskProps.maskRef.current.updateValue();\n }\n }, []);\n\n const handleClear: React.MouseEventHandler<HTMLButtonElement> = useCallback(\n (e) => {\n setStringValue('');\n\n if (refs.current[1]) {\n onChangeRef.current?.(null, { e: e as unknown as Event });\n }\n },\n [],\n );\n\n useEffect(() => {\n if (value && isValid(value)) {\n setStringValue(format(value, formatProp));\n }\n\n if (!value && stringValue) {\n const formatArray = getParts(formatProp, separator, false);\n const valueArray = getParts(stringValue, separator, false);\n const validArray = formatArray\n .map((marker) => getPartDate(formatArray, valueArray, marker))\n .filter((item) => Boolean(item));\n\n const date =\n formatArray.length === validArray.length\n ? parse(\n valueArray.join(datePickerPropSeparatorDefault),\n formatArray.join(datePickerPropSeparatorDefault),\n new Date(),\n )\n : undefined;\n\n if (isValid(date)) {\n setStringValue('');\n }\n }\n }, [value?.getTime()]);\n\n return handleClear;\n};\n"],"mappings":"0IAAA,OAASA,MAAT,CAAiBC,OAAjB,CAA0BC,KAA1B,CAAiCC,YAAjC,KAAqD,UAArD,CACA,OAASC,WAAT,CAAsBC,SAAtB,KAAuC,OAAvC,CAGA,OAASC,OAAT,qBAEA,OAASC,aAAT,iCACA,OAASC,KAAT,yBAKA,MAAO,IAAMC,+BAA8B,CAAG,GAAvC,CACP,MAAO,IAAMC,6BAA4B,yCAAlC,CACP,MAAO,IAAMC,kCAAiC,iFAAvC,CAEP,MAAO,IAAMC,6BAA4B,WAAlC,CACP,MAAO,IAAMC,kCAAiC,yCAAvC,CAEP,MAAO,IAAMC,iCAAgC,WAAMJ,4BAAN,wBAAtC,CACP,MAAO,IAAMK,sCAAqC,WAAMJ,iCAAN,sDAA3C,CAEP,MAAO,IAAMK,6BAA4B,OAAlC,CACP,MAAO,IAAMC,kCAAiC,2BAAvC,CAEP,MAAO,IAAMC,8BAA6B,wBAAnC,CACP,MAAO,IAAM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AW,CAAC8D,IAAZ,CAAiBhF,8BAAjB,CAFG,CAGH,GAAIiF,KAHD,CADT,OARuB,CAgBrBzF,OAAO,CAACsD,CAAD,CAhBc,EAiBvBuB,CAAc,CAAC,EAAD,CAEjB,CACF,CAzBQ,CAyBN,QAACpB,CAAD,WAACA,CAAD,QAACA,CAAK,CAAEpC,OAAP,EAAD,CAzBM,CA2BT,CAAO6D,CACR,CA9DM"}
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["format","isValid","parse","useCallback","useEffect","IMask","getForm","useMutableRef","getTimeNumbers","datePickerPropSeparatorDefault","datePickerPropFormatTypeDate","datePickerPropFormatTypeTime","datePickerPropFormatTypeDateTime","datePickerPropFormatTypeYear","datePickerPropFormatTypeMonth","normalizeRangeValue","dateRange","getTime","getTimeOptionsByFormat","timeOptions","formatArray","split","mapTimeOptions","HH","hours","mm","minutes","ss","seconds","map","marker","includes","hoursOptions","minutesOptions","secondsOptions","adaptFormat","adaptedFormat","shouldRemoveTimePart","timeOption","Array","isArray","length","step","timeMarkers","replace","RegExp","trim","filter","part","join","placeholderByFormat","getMaskBlocks","includeDate","includeTime","blocks","dd","mask","MaskedRange","from","to","MM","yyyy","getFormForStart","form","getFormForEnd","getPartDate","stringArray","index","indexOf","getParts","separator","withTime","date","time","getPartsDate","value","markers","isTypeWithTime","type","fieldPrefixs","getFieldName","name","rangeIndex","getDropdownZIndex","style","zIndex","useStringValue","formatProp","onChangeRef","imaskProps","stringValue","refs","setValue","setStringValue","current","ref","maskRef","updateValue","handleClear","e","valueArray","validArray","item","Date","isValidTimeByTimeOptions","isUnitValid","unit","options","allowed","isHoursValid","getHours","isMinutesValid","getMinutes","isSecondsValid","getSeconds"],"sources":["../../../../../src/components/DatePicker/helpers.ts"],"sourcesContent":["import { format, isValid, parse } from 'date-fns';\nimport { useCallback, useEffect } from 'react';\nimport { IMask, useIMask } from 'react-imask';\n\nimport { getForm } from '##/components/FieldGroup';\nimport { TextFieldPropForm } from '##/components/TextField';\nimport { useMutableRef } from '##/hooks/useMutableRef';\nimport { DateRange } from '##/utils/types/Date';\n\nimport { TimeOptions, TimeUnitOptions } from '../DateTime';\nimport { getTimeNumbers } from '../DateTime/helpers';\nimport { DatePickerPropType } from './types';\n\nexport const datePickerPropSeparatorDefault = '.';\nexport const datePickerPropFormatTypeDate = `dd${datePickerPropSeparatorDefault}MM${datePickerPropSeparatorDefault}yyyy`;\n\nexport const datePickerPropFormatTypeTime = `HH:mm:ss`;\n\nexport const datePickerPropFormatTypeDateTime = `${datePickerPropFormatTypeDate} ${datePickerPropFormatTypeTime}`;\n\nexport const datePickerPropFormatTypeYear = `yyyy`;\n\nexport const datePickerPropFormatTypeMonth = `MM${datePickerPropSeparatorDefault}yyyy`;\n\nexport const normalizeRangeValue = (dateRange: DateRange): DateRange => {\n if (\n dateRange[0] &&\n dateRange[1] &&\n dateRange[0]?.getTime() > dateRange[1]?.getTime()\n ) {\n return [dateRange[1], dateRange[0]];\n }\n return dateRange;\n};\n\nexport const getTimeOptionsByFormat = (\n format: string,\n timeOptions?: TimeOptions,\n) => {\n const markers = ['HH', 'mm', 'ss'] as const;\n const formatArray = format.split(' ')[1]?.split(':');\n const mapTimeOptions = {\n HH: timeOptions?.hours,\n mm: timeOptions?.minutes,\n ss: timeOptions?.seconds,\n } as const;\n\n const [hoursOptions, minutesOptions, secondsOptions] = markers.map((marker) =>\n formatArray?.includes(marker) ? mapTimeOptions[marker] : [],\n ) as [\n TimeUnitOptions | undefined,\n TimeUnitOptions | undefined,\n TimeUnitOptions | undefined,\n ];\n\n const effectiveTimeOptions = {\n hours: hoursOptions,\n minutes: minutesOptions,\n seconds: secondsOptions,\n };\n\n return effectiveTimeOptions;\n};\n\nexport const adaptFormat = (\n format: string,\n timeOptions?: TimeOptions,\n): string => {\n const formatArray = format.split(' ');\n let adaptedFormat = formatArray[1] ?? format;\n\n const shouldRemoveTimePart = (\n timeOption: TimeUnitOptions | undefined,\n ): boolean => {\n if (timeOption && Array.isArray(timeOption) && timeOption.length === 0)\n return true;\n if (timeOption && !Array.isArray(timeOption) && timeOption.step === 0)\n return true;\n\n return false;\n };\n\n const timeMarkers = [\n { marker: 'HH', timeOption: timeOptions?.hours },\n { marker: 'mm', timeOption: timeOptions?.minutes },\n { marker: 'ss', timeOption: timeOptions?.seconds },\n ];\n\n for (const { marker, timeOption } of timeMarkers) {\n if (shouldRemoveTimePart(timeOption)) {\n adaptedFormat = adaptedFormat.replace(new RegExp(`:?${marker}`, 'g'), '');\n }\n }\n\n adaptedFormat = adaptedFormat\n .replace(/:+$/, '')\n .replace(/^:+/, '')\n .replace(/:+/g, ':')\n .replace(/\\s+/g, ' ')\n .trim();\n\n if (formatArray.length > 1) {\n formatArray[1] = adaptedFormat;\n return formatArray.filter((part) => part.length > 0).join(' ');\n }\n return adaptedFormat;\n};\n\nexport const placeholderByFormat = (format: string): string => {\n return format\n .replace(/yyyy/g, 'ГГГГ')\n .replace(/MM/g, 'ММ')\n .replace(/dd/g, 'ДД')\n .replace(/HH/g, 'ЧЧ')\n .replace(/mm/g, 'ММ')\n .replace(/ss/g, 'СС');\n};\n\ntype MaskBlock = {\n mask: typeof IMask.MaskedRange;\n from: number;\n to: number;\n};\n\ntype MaskBlocks = Partial<{\n dd: MaskBlock;\n MM: MaskBlock;\n yyyy: MaskBlock;\n HH: MaskBlock;\n mm: MaskBlock;\n ss: MaskBlock;\n}>;\n\nexport const getMaskBlocks = ({\n includeDate = true,\n includeTime = true,\n} = {}): MaskBlocks => {\n const blocks: MaskBlocks = {};\n\n if (includeDate) {\n blocks.dd = { mask: IMask.MaskedRange, from: 1, to: 31 };\n blocks.MM = { mask: IMask.MaskedRange, from: 1, to: 12 };\n blocks.yyyy = { mask: IMask.MaskedRange, from: 1, to: 9999 };\n }\n\n if (includeTime) {\n blocks.HH = { mask: IMask.MaskedRange, from: 0, to: 23 };\n blocks.mm = { mask: IMask.MaskedRange, from: 0, to: 59 };\n blocks.ss = { mask: IMask.MaskedRange, from: 0, to: 59 };\n }\n\n return blocks;\n};\n\nexport const getFormForStart = (form: TextFieldPropForm) => getForm(form, 0, 2);\nexport const getFormForEnd = (form: TextFieldPropForm) => getForm(form, 1, 2);\n\nexport const getPartDate = (\n formatArray: string[],\n stringArray: string[],\n marker: string,\n) => {\n const index = formatArray.indexOf(marker);\n\n if (\n index >= 0 &&\n stringArray[index] &&\n stringArray[index].length === marker.length\n ) {\n return stringArray[index];\n }\n\n return undefined;\n};\n\nexport const getParts = (\n format: string,\n separator: string,\n withTime?: boolean,\n) => {\n if (withTime) {\n const [date, time] = format.split(' ');\n\n return [\n ...(date ? date.split(separator) : []),\n ...(time ? time.split(':') : []),\n ];\n }\n\n return format.split(separator);\n};\n\nexport const getPartsDate = (\n value: string,\n format: string,\n separator: string,\n withTime: boolean,\n markers: string[],\n) => {\n const formatArray = getParts(format, separator, withTime);\n const stringArray = getParts(value, separator, withTime);\n\n return markers.map((marker) => getPartDate(formatArray, stringArray, marker));\n};\n\nexport const isTypeWithTime = (type: DatePickerPropType) =>\n type.indexOf('time') !== -1;\n\nconst fieldPrefixs = ['start', 'end'] as const;\n\nexport const getFieldName = (\n name: [string?, string?] | string | undefined,\n rangeIndex: 0 | 1,\n) => {\n if (!name) {\n return undefined;\n }\n\n if (Array.isArray(name)) {\n return name[rangeIndex];\n }\n\n return `${name}_${fieldPrefixs[rangeIndex]}`;\n};\n\nexport const getDropdownZIndex = (style?: React.CSSProperties) =>\n typeof style?.zIndex === 'number' ? style.zIndex + 1 : undefined;\n\ntype DatePickerFieldTypeDatePropOnChange = (\n value: Date | null,\n props: {\n e: Event;\n },\n) => void;\n\nexport const useStringValue = (\n value: Date | undefined | null,\n formatProp: string,\n separator: string,\n onChangeRef: React.MutableRefObject<\n DatePickerFieldTypeDatePropOnChange | undefined\n >,\n imaskProps: ReturnType<typeof useIMask<HTMLInputElement>>,\n) => {\n const stringValue = imaskProps.value;\n\n const refs = useMutableRef([imaskProps.setValue, value] as const);\n\n const setStringValue = useCallback((value: string) => {\n refs.current[0](value);\n if (imaskProps.ref?.current) {\n imaskProps.ref.current.value = value;\n }\n if (imaskProps.maskRef.current) {\n imaskProps.maskRef.current.updateValue();\n }\n }, []);\n\n const handleClear: React.MouseEventHandler<HTMLButtonElement> = useCallback(\n (e) => {\n setStringValue('');\n\n if (refs.current[1]) {\n onChangeRef.current?.(null, { e: e as unknown as Event });\n }\n },\n [],\n );\n\n useEffect(() => {\n if (value && isValid(value)) {\n setStringValue(format(value, formatProp));\n }\n\n if (!value && stringValue) {\n const formatArray = getParts(formatProp, separator, false);\n const valueArray = getParts(stringValue, separator, false);\n const validArray = formatArray\n .map((marker) => getPartDate(formatArray, valueArray, marker))\n .filter((item) => Boolean(item));\n\n const date =\n formatArray.length === validArray.length\n ? parse(\n valueArray.join(datePickerPropSeparatorDefault),\n formatArray.join(datePickerPropSeparatorDefault),\n new Date(),\n )\n : undefined;\n\n if (isValid(date)) {\n setStringValue('');\n }\n }\n }, [value?.getTime()]);\n\n return handleClear;\n};\n\nexport const isValidTimeByTimeOptions = (\n date: Date,\n timeOptions?: TimeOptions,\n): boolean => {\n const isUnitValid = (\n unit: 'hours' | 'minutes' | 'seconds',\n value: number,\n options?: TimeUnitOptions,\n ): boolean => {\n if (!options) return true;\n\n const allowed = getTimeNumbers(unit, options);\n if (allowed.length === 0) return true;\n\n return allowed.includes(value);\n };\n\n if (!timeOptions) return true;\n const isHoursValid = isUnitValid('hours', date.getHours(), timeOptions.hours);\n const isMinutesValid = isUnitValid(\n 'minutes',\n date.getMinutes(),\n timeOptions.minutes,\n );\n const isSecondsValid = isUnitValid(\n 'seconds',\n date.getSeconds(),\n timeOptions.seconds,\n );\n\n return isHoursValid && isMinutesValid && isSecondsValid;\n};\n"],"mappings":"0IAAA,OAASA,MAAT,CAAiBC,OAAjB,CAA0BC,KAA1B,KAAuC,UAAvC,CACA,OAASC,WAAT,CAAsBC,SAAtB,KAAuC,OAAvC,CACA,OAASC,KAAT,KAAgC,aAAhC,CAEA,OAASC,OAAT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CAA2B3F,CAAW,CAACK,KAAvC,CAfpB,CAgBNuF,CAAc,CAAGN,CAAW,CAChC,SADgC,CAEhCjC,CAAI,CAACwC,UAAL,EAFgC,CAGhC7F,CAAW,CAACO,OAHoB,CAhBtB,CAqBNuF,CAAc,CAAGR,CAAW,CAChC,SADgC,CAEhCjC,CAAI,CAAC0C,UAAL,EAFgC,CAGhC/F,CAAW,CAACS,OAHoB,CArBtB,CA2BZ,MAAOiF,EAAY,EAAIE,CAAhB,EAAkCE,CAC1C,CA/BM"}
|
|
@@ -2,7 +2,7 @@ import { IconComponent, IconPropSize } from '@consta/icons/Icon';
|
|
|
2
2
|
import { Locale } from 'date-fns';
|
|
3
3
|
import { DateRange } from '../../utils/types/Date';
|
|
4
4
|
import { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';
|
|
5
|
-
import { DateTimePropDisableDates, DateTimePropView } from '../DateTime/helpers';
|
|
5
|
+
import { DateTimePropDisableDates, DateTimePropView, TimeOptions } from '../DateTime/helpers';
|
|
6
6
|
import { TextFieldPropForm, TextFieldPropSize, TextFieldPropStatus, TextFieldPropView } from '../TextField/TextField';
|
|
7
7
|
export declare const datePickerPropType: readonly ["date", "date-range", "date-time", "date-time-range", "time", "year", "year-range", "month", "month-range"];
|
|
8
8
|
export type DatePickerPropType = typeof datePickerPropType[number];
|
|
@@ -10,7 +10,8 @@ export declare const datePickerPropTypeDefault: "date";
|
|
|
10
10
|
export type DatePickerPropDateTimeView = DateTimePropView;
|
|
11
11
|
export declare const datePickerPropDateTimeViewDefault: "classic";
|
|
12
12
|
type Range = 'date-range' | 'date-time-range' | 'year-range' | 'month-range';
|
|
13
|
-
|
|
13
|
+
type Time = 'time' | 'date-time' | 'date-time-range';
|
|
14
|
+
export declare const datePickerErrorTypes: readonly ["outOfRange", "invalidInputAttempt", "startDateIsGreaterThanEndDate", "invalidTimeByTimeOptions"];
|
|
14
15
|
export type DatePickerPropValue<TYPE extends DatePickerPropType> = (TYPE extends Range ? DateRange : Date) | null;
|
|
15
16
|
export type DatePickerPropPlaceholder<TYPE> = TYPE extends Range ? [string?, string?] | string : string;
|
|
16
17
|
export type DatePickerPropOnChange<TYPE extends DatePickerPropType> = (value: DatePickerPropValue<TYPE>, props: {
|
|
@@ -73,9 +74,22 @@ export type DatePickerProps<TYPE extends DatePickerPropType = 'date'> = PropsWit
|
|
|
73
74
|
labelPosition?: 'top' | 'left';
|
|
74
75
|
onChangeCurrentVisibleDate?: (date: Date) => void;
|
|
75
76
|
currentVisibleDate?: Date;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
timeOptions?: TYPE extends Time ? TimeOptions : never;
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated Use timeOptions instead.
|
|
80
|
+
* TODO: major - удалить при мажорном релизе все свойства multiplicity*, оставив только работу с timeOptions.
|
|
81
|
+
*/
|
|
82
|
+
multiplicitySeconds?: TYPE extends Time ? number : never;
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Use timeOptions instead.
|
|
85
|
+
* TODO: major - удалить при мажорном релизе все свойства multiplicity*, оставив только работу с timeOptions.
|
|
86
|
+
*/
|
|
87
|
+
multiplicityMinutes?: TYPE extends Time ? number : never;
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Use timeOptions instead.
|
|
90
|
+
* TODO: major - удалить при мажорном релизе все свойства multiplicity*, оставив только работу с timeOptions.
|
|
91
|
+
*/
|
|
92
|
+
multiplicityHours?: TYPE extends Time ? number : never;
|
|
79
93
|
isMobile?: number;
|
|
80
94
|
withClearButton?: boolean;
|
|
81
95
|
onDropdownOpen?: (isOpen: boolean) => void;
|
|
@@ -106,5 +120,12 @@ export type DatePickerPropOnError = (props: {
|
|
|
106
120
|
} | {
|
|
107
121
|
type: typeof datePickerErrorTypes[2];
|
|
108
122
|
date: [Date, Date];
|
|
123
|
+
} | {
|
|
124
|
+
type: typeof datePickerErrorTypes[3];
|
|
125
|
+
stringValue: string;
|
|
126
|
+
date: Date;
|
|
127
|
+
HH?: string;
|
|
128
|
+
mm?: string;
|
|
129
|
+
ss?: string;
|
|
109
130
|
}) => void;
|
|
110
131
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{dateTimePropViewDefault}from"../DateTime/helpers";export var datePickerPropType=["date","date-range","date-time","date-time-range","time","year","year-range","month","month-range"];export var datePickerPropTypeDefault=datePickerPropType[0];export var datePickerPropDateTimeViewDefault=dateTimePropViewDefault;export var datePickerErrorTypes=["outOfRange","invalidInputAttempt","startDateIsGreaterThanEndDate"];export var datePickerPropDropdownForm=["default","brick","round"];export var datePickerPropDropdownFormDefault=datePickerPropDropdownForm[0];
|
|
1
|
+
import{dateTimePropViewDefault}from"../DateTime/helpers";export var datePickerPropType=["date","date-range","date-time","date-time-range","time","year","year-range","month","month-range"];export var datePickerPropTypeDefault=datePickerPropType[0];export var datePickerPropDateTimeViewDefault=dateTimePropViewDefault;export var datePickerErrorTypes=["outOfRange","invalidInputAttempt","startDateIsGreaterThanEndDate","invalidTimeByTimeOptions"];export var datePickerPropDropdownForm=["default","brick","round"];export var datePickerPropDropdownFormDefault=datePickerPropDropdownForm[0];
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["dateTimePropViewDefault","datePickerPropType","datePickerPropTypeDefault","datePickerPropDateTimeViewDefault","datePickerErrorTypes","datePickerPropDropdownForm","datePickerPropDropdownFormDefault"],"sources":["../../../../../src/components/DatePicker/types.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { Locale } from 'date-fns';\n\nimport { DateRange } from '../../utils/types/Date';\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\nimport {\n DateTimePropDisableDates,\n DateTimePropView,\n dateTimePropViewDefault,\n} from '../DateTime/helpers';\nimport {\n TextFieldPropForm,\n TextFieldPropSize,\n TextFieldPropStatus,\n TextFieldPropView,\n} from '../TextField/TextField';\n\nexport const datePickerPropType = [\n 'date',\n 'date-range',\n 'date-time',\n 'date-time-range',\n 'time',\n 'year',\n 'year-range',\n 'month',\n 'month-range',\n] as const;\n\nexport type DatePickerPropType = typeof datePickerPropType[number];\nexport const datePickerPropTypeDefault = datePickerPropType[0];\n\nexport type DatePickerPropDateTimeView = DateTimePropView;\nexport const datePickerPropDateTimeViewDefault = dateTimePropViewDefault;\n\ntype Range = 'date-range' | 'date-time-range' | 'year-range' | 'month-range';\n\nexport const datePickerErrorTypes = [\n 'outOfRange',\n 'invalidInputAttempt',\n 'startDateIsGreaterThanEndDate',\n] as const;\n\nexport type DatePickerPropValue<TYPE extends DatePickerPropType> =\n | (TYPE extends Range ? DateRange : Date)\n | null;\n\nexport type DatePickerPropPlaceholder<TYPE> = TYPE extends Range\n ? [string?, string?] | string\n : string;\n\nexport type DatePickerPropOnChange<TYPE extends DatePickerPropType> = (\n value: DatePickerPropValue<TYPE>,\n props: {\n e: React.MouseEvent<HTMLButtonElement, MouseEvent> | Event;\n },\n) => void;\n\nexport const datePickerPropDropdownForm = [\n 'default',\n 'brick',\n 'round',\n] as const;\nexport type DatePickerPropDropdownForm =\n typeof datePickerPropDropdownForm[number];\nexport const datePickerPropDropdownFormDefault = datePickerPropDropdownForm[0];\n\ntype DatePickerPropInputRef<TYPE> = TYPE extends Range\n ? [React.Ref<HTMLInputElement>?, React.Ref<HTMLInputElement>?]\n : React.Ref<HTMLInputElement>;\n\ntype DatePickerPropSide<TYPE> = TYPE extends Range\n ?\n | [(string | IconComponent)?, (string | IconComponent)?]\n | string\n | IconComponent\n : string | IconComponent;\n\ntype DatePickerPropOnFocus<TYPE> = TYPE extends Range\n ?\n | [\n React.FocusEventHandler<HTMLElement>?,\n React.FocusEventHandler<HTMLElement>?,\n ]\n | React.FocusEventHandler<HTMLElement>\n : React.FocusEventHandler<HTMLElement>;\n\ntype DatePickerPropName<TYPE> = TYPE extends Range\n ? [string?, string?] | string\n : string;\n\nexport type DatePickerAdditionalControlRenderFn = (props: {\n currentVisibleDate?: Date;\n}) => React.ReactNode | React.ReactNode[];\n\nexport type DatePickerAdditionalControlRenderProp =\n | React.ReactNode\n | DatePickerAdditionalControlRenderFn;\n\nexport type DatePickerProps<TYPE extends DatePickerPropType = 'date'> =\n PropsWithHTMLAttributesAndRef<\n {\n type?: TYPE;\n value?: DatePickerPropValue<TYPE>;\n onChange?: DatePickerPropOnChange<TYPE>;\n minDate?: Date;\n maxDate?: Date;\n renderAdditionalControls?: DatePickerAdditionalControlRenderProp;\n events?: Date[];\n dateTimeView?: DatePickerPropDateTimeView;\n locale?: Locale;\n children?: never;\n onError?: DatePickerPropOnError;\n id?: string;\n name?: DatePickerPropName<TYPE>;\n disabled?: boolean;\n disableDates?: DateTimePropDisableDates;\n dropdownClassName?: string;\n dropdownRef?: React.Ref<HTMLDivElement>;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n status?: TextFieldPropStatus;\n onFocus?: DatePickerPropOnFocus<TYPE>;\n onBlur?: DatePickerPropOnFocus<TYPE>;\n autoFocus?: boolean;\n placeholder?: DatePickerPropPlaceholder<TYPE>;\n readOnly?: boolean;\n required?: boolean;\n tabIndex?: number;\n inputRef?: DatePickerPropInputRef<TYPE>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n format?: string;\n separator?: string;\n dropdownForm?: DatePickerPropDropdownForm;\n leftSide?: DatePickerPropSide<TYPE>;\n rightSide?: DatePickerPropSide<TYPE>;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n onChangeCurrentVisibleDate?: (date: Date) => void;\n currentVisibleDate?: Date;\n multiplicitySeconds?: number;\n multiplicityMinutes?: number;\n multiplicityHours?: number;\n isMobile?: number;\n withClearButton?: boolean;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n },\n HTMLDivElement\n >;\n\nexport type DatePickerComponent = <TYPE extends DatePickerPropType = 'date'>(\n props: DatePickerProps<TYPE>,\n) => React.ReactNode | null;\n\nexport type DatePickerTypeComponent<TYPE extends DatePickerPropType> = (\n props: Omit<DatePickerProps<TYPE>, 'type'>,\n) => React.ReactNode | null;\n\nexport type DatePickerPropOnError = (\n props:\n | {\n type: typeof datePickerErrorTypes[0];\n stringValue: string;\n dd?: string;\n MM?: string;\n yyyy?: string;\n ss?: string;\n mm?: string;\n HH?: string;\n date: Date;\n }\n | {\n type: typeof datePickerErrorTypes[1];\n stringValue: string;\n dd?: string;\n MM?: string;\n yyyy?: string;\n ss?: string;\n mm?: string;\n HH?: string;\n }\n | {\n type: typeof datePickerErrorTypes[2];\n date: [Date, Date];\n },\n) => void;\n"],"mappings":"AAKA,OAGEA,uBAHF,
|
|
1
|
+
{"version":3,"file":"types.js","names":["dateTimePropViewDefault","datePickerPropType","datePickerPropTypeDefault","datePickerPropDateTimeViewDefault","datePickerErrorTypes","datePickerPropDropdownForm","datePickerPropDropdownFormDefault"],"sources":["../../../../../src/components/DatePicker/types.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { Locale } from 'date-fns';\n\nimport { DateRange } from '../../utils/types/Date';\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\nimport {\n DateTimePropDisableDates,\n DateTimePropView,\n dateTimePropViewDefault,\n TimeOptions,\n} from '../DateTime/helpers';\nimport {\n TextFieldPropForm,\n TextFieldPropSize,\n TextFieldPropStatus,\n TextFieldPropView,\n} from '../TextField/TextField';\n\nexport const datePickerPropType = [\n 'date',\n 'date-range',\n 'date-time',\n 'date-time-range',\n 'time',\n 'year',\n 'year-range',\n 'month',\n 'month-range',\n] as const;\n\nexport type DatePickerPropType = typeof datePickerPropType[number];\nexport const datePickerPropTypeDefault = datePickerPropType[0];\n\nexport type DatePickerPropDateTimeView = DateTimePropView;\nexport const datePickerPropDateTimeViewDefault = dateTimePropViewDefault;\n\ntype Range = 'date-range' | 'date-time-range' | 'year-range' | 'month-range';\ntype Time = 'time' | 'date-time' | 'date-time-range';\n\nexport const datePickerErrorTypes = [\n 'outOfRange',\n 'invalidInputAttempt',\n 'startDateIsGreaterThanEndDate',\n 'invalidTimeByTimeOptions',\n] as const;\n\nexport type DatePickerPropValue<TYPE extends DatePickerPropType> =\n | (TYPE extends Range ? DateRange : Date)\n | null;\n\nexport type DatePickerPropPlaceholder<TYPE> = TYPE extends Range\n ? [string?, string?] | string\n : string;\n\nexport type DatePickerPropOnChange<TYPE extends DatePickerPropType> = (\n value: DatePickerPropValue<TYPE>,\n props: {\n e: React.MouseEvent<HTMLButtonElement, MouseEvent> | Event;\n },\n) => void;\n\nexport const datePickerPropDropdownForm = [\n 'default',\n 'brick',\n 'round',\n] as const;\nexport type DatePickerPropDropdownForm =\n typeof datePickerPropDropdownForm[number];\nexport const datePickerPropDropdownFormDefault = datePickerPropDropdownForm[0];\n\ntype DatePickerPropInputRef<TYPE> = TYPE extends Range\n ? [React.Ref<HTMLInputElement>?, React.Ref<HTMLInputElement>?]\n : React.Ref<HTMLInputElement>;\n\ntype DatePickerPropSide<TYPE> = TYPE extends Range\n ?\n | [(string | IconComponent)?, (string | IconComponent)?]\n | string\n | IconComponent\n : string | IconComponent;\n\ntype DatePickerPropOnFocus<TYPE> = TYPE extends Range\n ?\n | [\n React.FocusEventHandler<HTMLElement>?,\n React.FocusEventHandler<HTMLElement>?,\n ]\n | React.FocusEventHandler<HTMLElement>\n : React.FocusEventHandler<HTMLElement>;\n\ntype DatePickerPropName<TYPE> = TYPE extends Range\n ? [string?, string?] | string\n : string;\n\nexport type DatePickerAdditionalControlRenderFn = (props: {\n currentVisibleDate?: Date;\n}) => React.ReactNode | React.ReactNode[];\n\nexport type DatePickerAdditionalControlRenderProp =\n | React.ReactNode\n | DatePickerAdditionalControlRenderFn;\n\nexport type DatePickerProps<TYPE extends DatePickerPropType = 'date'> =\n PropsWithHTMLAttributesAndRef<\n {\n type?: TYPE;\n value?: DatePickerPropValue<TYPE>;\n onChange?: DatePickerPropOnChange<TYPE>;\n minDate?: Date;\n maxDate?: Date;\n renderAdditionalControls?: DatePickerAdditionalControlRenderProp;\n events?: Date[];\n dateTimeView?: DatePickerPropDateTimeView;\n locale?: Locale;\n children?: never;\n onError?: DatePickerPropOnError;\n id?: string;\n name?: DatePickerPropName<TYPE>;\n disabled?: boolean;\n disableDates?: DateTimePropDisableDates;\n dropdownClassName?: string;\n dropdownRef?: React.Ref<HTMLDivElement>;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n status?: TextFieldPropStatus;\n onFocus?: DatePickerPropOnFocus<TYPE>;\n onBlur?: DatePickerPropOnFocus<TYPE>;\n autoFocus?: boolean;\n placeholder?: DatePickerPropPlaceholder<TYPE>;\n readOnly?: boolean;\n required?: boolean;\n tabIndex?: number;\n inputRef?: DatePickerPropInputRef<TYPE>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n format?: string;\n separator?: string;\n dropdownForm?: DatePickerPropDropdownForm;\n leftSide?: DatePickerPropSide<TYPE>;\n rightSide?: DatePickerPropSide<TYPE>;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n onChangeCurrentVisibleDate?: (date: Date) => void;\n currentVisibleDate?: Date;\n timeOptions?: TYPE extends Time ? TimeOptions : never;\n /**\n * @deprecated Use timeOptions instead.\n * TODO: major - удалить при мажорном релизе все свойства multiplicity*, оставив только работу с timeOptions.\n */\n multiplicitySeconds?: TYPE extends Time ? number : never;\n /**\n * @deprecated Use timeOptions instead.\n * TODO: major - удалить при мажорном релизе все свойства multiplicity*, оставив только работу с timeOptions.\n */\n multiplicityMinutes?: TYPE extends Time ? number : never;\n /**\n * @deprecated Use timeOptions instead.\n * TODO: major - удалить при мажорном релизе все свойства multiplicity*, оставив только работу с timeOptions.\n */\n multiplicityHours?: TYPE extends Time ? number : never;\n isMobile?: number;\n withClearButton?: boolean;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n },\n HTMLDivElement\n >;\n\nexport type DatePickerComponent = <TYPE extends DatePickerPropType = 'date'>(\n props: DatePickerProps<TYPE>,\n) => React.ReactNode | null;\n\nexport type DatePickerTypeComponent<TYPE extends DatePickerPropType> = (\n props: Omit<DatePickerProps<TYPE>, 'type'>,\n) => React.ReactNode | null;\n\nexport type DatePickerPropOnError = (\n props:\n | {\n type: typeof datePickerErrorTypes[0];\n stringValue: string;\n dd?: string;\n MM?: string;\n yyyy?: string;\n ss?: string;\n mm?: string;\n HH?: string;\n date: Date;\n }\n | {\n type: typeof datePickerErrorTypes[1];\n stringValue: string;\n dd?: string;\n MM?: string;\n yyyy?: string;\n ss?: string;\n mm?: string;\n HH?: string;\n }\n | {\n type: typeof datePickerErrorTypes[2];\n date: [Date, Date];\n }\n | {\n type: typeof datePickerErrorTypes[3];\n stringValue: string;\n date: Date;\n HH?: string;\n mm?: string;\n ss?: string;\n },\n) => void;\n"],"mappings":"AAKA,OAGEA,uBAHF,2BAaA,MAAO,IAAMC,mBAAkB,CAAG,CAChC,MADgC,CAEhC,YAFgC,CAGhC,WAHgC,CAIhC,iBAJgC,CAKhC,MALgC,CAMhC,MANgC,CAOhC,YAPgC,CAQhC,OARgC,CAShC,aATgC,CAA3B,CAaP,MAAO,IAAMC,0BAAyB,CAAGD,kBAAkB,CAAC,CAAD,CAApD,CAGP,MAAO,IAAME,kCAAiC,CAAGH,uBAA1C,CAKP,MAAO,IAAMI,qBAAoB,CAAG,CAClC,YADkC,CAElC,qBAFkC,CAGlC,+BAHkC,CAIlC,0BAJkC,CAA7B,CAsBP,MAAO,IAAMC,2BAA0B,CAAG,CACxC,SADwC,CAExC,OAFwC,CAGxC,OAHwC,CAAnC,CAOP,MAAO,IAAMC,kCAAiC,CAAGD,0BAA0B,CAAC,CAAD,CAApE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["type"];import React,{forwardRef,useRef}from"react";import{usePropsHandler}from"../EventInterceptor/usePropsHandler";import{useForkRef}from"../../hooks/useForkRef/useForkRef";import{getByMap}from"../../utils/getByMap";import{DateTimeTypeDate}from"./DateTimeTypeDate/DateTimeTypeDate";import{DateTimeTypeDateTime}from"./DateTimeTypeDateTime/DateTimeTypeDateTime";import{DateTimeTypeMonth}from"./DateTimeTypeMonth/DateTimeTypeMonth";import{DateTimeTypeTime}from"./DateTimeTypeTime/DateTimeTypeTime";import{DateTimeTypeYear}from"./DateTimeTypeYear/DateTimeTypeYear";import{dateTimePropTypeDefault}from"./helpers/types";var typeMap={date:DateTimeTypeDate,month:DateTimeTypeMonth,year:DateTimeTypeYear,time:DateTimeTypeTime,"date-time":DateTimeTypeDateTime};export var COMPONENT_NAME="DateTime";export var DateTime=forwardRef(function(a,b){var c=useRef(null),d=usePropsHandler(COMPONENT_NAME,a,c),e=d.type,f=void 0===e?dateTimePropTypeDefault:e,g=_objectWithoutProperties(d,_excluded),h=getByMap(typeMap,f);return React.createElement(
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["type","timeOptions","multiplicityHours","multiplicityMinutes","multiplicitySeconds"];import React,{forwardRef,useMemo,useRef}from"react";import{usePropsHandler}from"../EventInterceptor/usePropsHandler";import{useForkRef}from"../../hooks/useForkRef/useForkRef";import{getByMap}from"../../utils/getByMap";import{DateTimeTypeDate}from"./DateTimeTypeDate/DateTimeTypeDate";import{DateTimeTypeDateTime}from"./DateTimeTypeDateTime/DateTimeTypeDateTime";import{DateTimeTypeMonth}from"./DateTimeTypeMonth/DateTimeTypeMonth";import{DateTimeTypeTime}from"./DateTimeTypeTime/DateTimeTypeTime";import{DateTimeTypeYear}from"./DateTimeTypeYear/DateTimeTypeYear";import{isTypeWithTime}from"./helpers";import{getTimeOptionsKey}from"./helpers/getTimeOptionsKey";import{dateTimePropTypeDefault}from"./helpers/types";var typeMap={date:DateTimeTypeDate,month:DateTimeTypeMonth,year:DateTimeTypeYear,time:DateTimeTypeTime,"date-time":DateTimeTypeDateTime};export var COMPONENT_NAME="DateTime";export var DateTime=forwardRef(function(a,b){var c=useRef(null),d=usePropsHandler(COMPONENT_NAME,a,c),e=d.type,f=void 0===e?dateTimePropTypeDefault:e,g=d.timeOptions,h=d.multiplicityHours,i=d.multiplicityMinutes,j=d.multiplicitySeconds,k=_objectWithoutProperties(d,_excluded),l=useMemo(function(){var a,b,c;return{hours:null!==(a=null===g||void 0===g?void 0:g.hours)&&void 0!==a?a:h===void 0?void 0:{step:h},minutes:null!==(b=null===g||void 0===g?void 0:g.minutes)&&void 0!==b?b:i===void 0?void 0:{step:i},seconds:null!==(c=null===g||void 0===g?void 0:g.seconds)&&void 0!==c?c:j===void 0?void 0:{step:j}}},[getTimeOptionsKey(g),h,i,j]),m=useMemo(function(){return isTypeWithTime(f)?{timeOptions:l}:void 0},[f,l]),n=getByMap(typeMap,f);return React.createElement(n,Object.assign({},k,m,{ref:useForkRef([b,c])}))});export*from"./helpers/types";
|
|
2
2
|
//# sourceMappingURL=DateTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.js","names":["React","forwardRef","useRef","usePropsHandler","useForkRef","getByMap","DateTimeTypeDate","DateTimeTypeDateTime","DateTimeTypeMonth","DateTimeTypeTime","DateTimeTypeYear","dateTimePropTypeDefault","typeMap","COMPONENT_NAME","DateTime","props","ref","dateTimeRef","type","otherProps","Component"],"sources":["../../../../../src/components/DateTime/DateTime.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\n\nimport { usePropsHandler } from '##/components/EventInterceptor/usePropsHandler';\nimport { useForkRef } from '##/hooks/useForkRef/useForkRef';\nimport { getByMap } from '##/utils/getByMap';\n\nimport { DateTimeTypeDate } from './DateTimeTypeDate/DateTimeTypeDate';\nimport { DateTimeTypeDateTime } from './DateTimeTypeDateTime/DateTimeTypeDateTime';\nimport { DateTimeTypeMonth } from './DateTimeTypeMonth/DateTimeTypeMonth';\nimport { DateTimeTypeTime } from './DateTimeTypeTime/DateTimeTypeTime';\nimport { DateTimeTypeYear } from './DateTimeTypeYear/DateTimeTypeYear';\nimport {\n DateTimeComponent,\n DateTimePropType,\n dateTimePropTypeDefault,\n DateTimeTypeComponent,\n} from './helpers/types';\n\nconst typeMap: Record<\n DateTimePropType,\n DateTimeTypeComponent<DateTimePropType>\n> = {\n 'date': DateTimeTypeDate,\n 'month': DateTimeTypeMonth,\n 'year': DateTimeTypeYear,\n 'time': DateTimeTypeTime,\n 'date-time': DateTimeTypeDateTime,\n} as const;\n\nexport const COMPONENT_NAME = 'DateTime' as const;\n\nexport const DateTime: DateTimeComponent = forwardRef((props, ref) => {\n const dateTimeRef = useRef<HTMLDivElement>(null);\n const {
|
|
1
|
+
{"version":3,"file":"DateTime.js","names":["React","forwardRef","useMemo","useRef","usePropsHandler","useForkRef","getByMap","DateTimeTypeDate","DateTimeTypeDateTime","DateTimeTypeMonth","DateTimeTypeTime","DateTimeTypeYear","isTypeWithTime","getTimeOptionsKey","dateTimePropTypeDefault","typeMap","COMPONENT_NAME","DateTime","props","ref","dateTimeRef","type","timeOptions","multiplicityHours","multiplicityMinutes","multiplicitySeconds","otherProps","effectiveTimeOptions","hours","step","minutes","seconds","timeProps","Component"],"sources":["../../../../../src/components/DateTime/DateTime.tsx"],"sourcesContent":["import React, { forwardRef, useMemo, useRef } from 'react';\n\nimport { usePropsHandler } from '##/components/EventInterceptor/usePropsHandler';\nimport { useForkRef } from '##/hooks/useForkRef/useForkRef';\nimport { getByMap } from '##/utils/getByMap';\n\nimport { DateTimeTypeDate } from './DateTimeTypeDate/DateTimeTypeDate';\nimport { DateTimeTypeDateTime } from './DateTimeTypeDateTime/DateTimeTypeDateTime';\nimport { DateTimeTypeMonth } from './DateTimeTypeMonth/DateTimeTypeMonth';\nimport { DateTimeTypeTime } from './DateTimeTypeTime/DateTimeTypeTime';\nimport { DateTimeTypeYear } from './DateTimeTypeYear/DateTimeTypeYear';\nimport { isTypeWithTime } from './helpers';\nimport { getTimeOptionsKey } from './helpers/getTimeOptionsKey';\nimport {\n DateTimeComponent,\n DateTimePropType,\n dateTimePropTypeDefault,\n DateTimeTypeComponent,\n TimeOptions,\n} from './helpers/types';\n\nconst typeMap: Record<\n DateTimePropType,\n DateTimeTypeComponent<DateTimePropType>\n> = {\n 'date': DateTimeTypeDate,\n 'month': DateTimeTypeMonth,\n 'year': DateTimeTypeYear,\n 'time': DateTimeTypeTime,\n 'date-time': DateTimeTypeDateTime,\n} as const;\n\nexport const COMPONENT_NAME = 'DateTime' as const;\n\nexport const DateTime: DateTimeComponent = forwardRef((props, ref) => {\n const dateTimeRef = useRef<HTMLDivElement>(null);\n const {\n type = dateTimePropTypeDefault,\n timeOptions,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n ...otherProps\n } = usePropsHandler(COMPONENT_NAME, props, dateTimeRef);\n\n // TODO: major - удалить multiplicity* props конвертацию, используйте timeOptions напрямую\n const effectiveTimeOptions = useMemo((): TimeOptions => {\n return {\n hours:\n timeOptions?.hours ??\n (multiplicityHours !== undefined\n ? { step: multiplicityHours }\n : undefined),\n minutes:\n timeOptions?.minutes ??\n (multiplicityMinutes !== undefined\n ? { step: multiplicityMinutes }\n : undefined),\n seconds:\n timeOptions?.seconds ??\n (multiplicitySeconds !== undefined\n ? { step: multiplicitySeconds }\n : undefined),\n };\n }, [\n getTimeOptionsKey(timeOptions),\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n ]);\n\n const timeProps = useMemo(\n () =>\n isTypeWithTime(type) ? { timeOptions: effectiveTimeOptions } : undefined,\n [type, effectiveTimeOptions],\n );\n\n const Component = getByMap(typeMap, type);\n\n return (\n <Component\n {...otherProps}\n {...timeProps}\n ref={useForkRef([ref, dateTimeRef])}\n />\n );\n});\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AEJN,CAAmB,SAAnB,QACG,CAAEI,IAAI,CAAEJ,CAAR,CAdD,CAiBR,CAlBmC,CAkBjC,CACDZ,iBAAiB,CAACS,CAAD,CADhB,CAEDC,CAFC,CAGDC,CAHC,CAIDC,CAJC,CAlBiC,CAZgC,CAqC9DO,CAAS,CAAG9B,OAAO,CACvB,iBACEU,eAAc,CAACS,CAAD,CAAd,CAAuB,CAAEC,WAAW,CAAEK,CAAf,CAAvB,OADF,CADuB,CAGvB,CAACN,CAAD,CAAOM,CAAP,CAHuB,CArC2C,CA2C9DM,CAAS,CAAG3B,QAAQ,CAACS,OAAD,CAAUM,CAAV,CA3C0C,CA6CpE,MACE,qBAAC,CAAD,kBACMK,CADN,CAEMM,CAFN,EAGE,GAAG,CAAE3B,UAAU,CAAC,CAACc,CAAD,CAAMC,CAAN,CAAD,CAHjB,GAMH,CApDoD,CAA9C,CAsDP"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","minDate","maxDate","value","disableDates","onChange","onChangeRange","currentVisibleDate","events","locale","view","
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","minDate","maxDate","value","disableDates","onChange","onChangeRange","currentVisibleDate","events","locale","view","onMove","onChangeCurrentVisibleDate"];import{addMonths,startOfMonth}from"date-fns";import ruLocale from"date-fns/locale/ru";import React,{forwardRef,useEffect}from"react";import{useFlag}from"../../../hooks/useFlag/useFlag";import{DateTimeLabel}from"../DateTimeLabel/DateTimeLabel";import{DateTimeMonth}from"../DateTimeMonth/DateTimeMonth";import{DateTimeToggler}from"../DateTimeToggler/DateTimeToggler";import{DateTimeTypeMonth}from"../DateTimeTypeMonth/DateTimeTypeMonth";import{DateTimeYearSlider}from"../DateTimeYearSlider/DateTimeYearSlider";import{getDaysOfMonth,getDaysOfWeek,getHandleSelectDate,getMouthLabelWithYear,isEqualDay,moveTypes,useCurrentVisibleDate}from"../helpers";import{dateTimePropView,dateTimePropViewDefault}from"../helpers/types";import{cnDateTimeMixLayout}from"../mixs";export var DateTimeTypeDate=forwardRef(function(a,b){var c=a.className,d=a.minDate,e=a.maxDate,f=a.value,g=a.disableDates,h=a.onChange,i=a.onChangeRange,j=a.currentVisibleDate,k=a.events,l=a.locale,m=void 0===l?ruLocale:l,n=a.view,o=void 0===n?dateTimePropViewDefault:n,p=a.onMove,q=a.onChangeCurrentVisibleDate,r=_objectWithoutProperties(a,_excluded),s=useFlag(),t=_slicedToArray(s,2),u=t[0],v=t[1];useEffect(function(){u||(null===p||void 0===p?void 0:p(moveTypes[2]))},[u]);var w=useCurrentVisibleDate({currentVisibleDate:j,maxDate:e,minDate:d,value:f,startOfUnit:startOfMonth,onChangeCurrentVisibleDate:q}),x=_slicedToArray(w,2),y=x[0],z=x[1];if(u)return React.createElement(DateTimeTypeMonth,Object.assign({},r,{ref:b,className:c,minDate:d,maxDate:e,locale:m,events:k,currentVisibleDate:y,view:o,onChange:function(a){z(a),v.off()},onMove:p}));var A=getHandleSelectDate({minDate:d,maxDate:e,value:f,onChange:h,onChangeRange:i,isEqualUnit:isEqualDay}),B=getDaysOfMonth({date:y,disableDates:g,handleDayClick:A,value:f,events:k,minDate:d,maxDate:e,locale:m}),C=getMouthLabelWithYear(y,m),D=getDaysOfWeek(m),E=function(){return z(addMonths(y,1))},F=function(){return z(addMonths(y,-1))};if(o===dateTimePropView[0])return React.createElement("div",Object.assign({},r,{ref:b,className:cnDateTimeMixLayout({view:o},[c])}),React.createElement(DateTimeToggler,{className:cnDateTimeMixLayout("Label"),prevOnClick:F,nextOnClick:E,label:C,onLabelClick:v.on}),React.createElement(DateTimeMonth,{daysOfWeek:D,daysOfMonth:B}));var G=addMonths(y,1),H=getDaysOfMonth({date:G,disableDates:g,handleDayClick:A,value:f,events:k,minDate:d,maxDate:e,locale:m}),I=getMouthLabelWithYear(G,m);return o===dateTimePropView[1]?React.createElement("div",Object.assign({},r,{ref:b,className:cnDateTimeMixLayout({view:o},[c])}),React.createElement("div",{className:cnDateTimeMixLayout("Page")},React.createElement(DateTimeToggler,{className:cnDateTimeMixLayout("Label"),prevOnClick:F,label:C,onLabelClick:v.on}),React.createElement(DateTimeMonth,{daysOfWeek:D,daysOfMonth:B})),React.createElement("div",{className:cnDateTimeMixLayout("Page")},React.createElement(DateTimeToggler,{className:cnDateTimeMixLayout("Label"),nextOnClick:E,label:I,onLabelClick:v.on}),React.createElement(DateTimeMonth,{daysOfWeek:D,daysOfMonth:H}))):React.createElement("div",Object.assign({},r,{ref:b,className:cnDateTimeMixLayout({view:o},[c])}),React.createElement(DateTimeYearSlider,{className:cnDateTimeMixLayout("Slider"),currentVisibleDate:y,onChange:z,value:f,locale:m}),React.createElement("div",{className:cnDateTimeMixLayout("PageWrapper")},React.createElement("div",{className:cnDateTimeMixLayout("Page")},React.createElement(DateTimeLabel,{className:cnDateTimeMixLayout("Label"),label:C,onClick:v.on,cursor:"pointer"}),React.createElement(DateTimeMonth,{daysOfWeek:D,daysOfMonth:B})),React.createElement("div",{className:cnDateTimeMixLayout("Page")},React.createElement(DateTimeLabel,{className:cnDateTimeMixLayout("Label"),label:I,onClick:v.on,cursor:"pointer"}),React.createElement(DateTimeMonth,{daysOfWeek:D,daysOfMonth:H}))))});
|
|
2
2
|
//# sourceMappingURL=DateTimeTypeDate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeTypeDate.js","names":["addMonths","startOfMonth","ruLocale","React","forwardRef","useEffect","useFlag","DateTimeLabel","DateTimeMonth","DateTimeToggler","DateTimeTypeMonth","DateTimeYearSlider","getDaysOfMonth","getDaysOfWeek","getHandleSelectDate","getMouthLabelWithYear","isEqualDay","moveTypes","useCurrentVisibleDate","dateTimePropView","dateTimePropViewDefault","cnDateTimeMixLayout","DateTimeTypeDate","props","ref","className","minDate","maxDate","value","disableDates","onChange","onChangeRange","currentVisibleDateProp","currentVisibleDate","events","locale","view","multiplicityHours","multiplicityMinutes","multiplicitySeconds","onMove","onChangeCurrentVisibleDate","otherProps","changeMonth","setChangeMonth","startOfUnit","setCurrentVisibleDate","off","handleSelectDate","isEqualUnit","pageOneDaysOfMonth","date","handleDayClick","pageOneLabel","daysOfWeek","nextMonthHandle","prevMonthHandle","on","pageTwoCurrentVisibleDate","pageTwoDaysOfMonth","pageTwoLabel"],"sources":["../../../../../../src/components/DateTime/DateTimeTypeDate/DateTimeTypeDate.tsx"],"sourcesContent":["import { addMonths, startOfMonth } from 'date-fns';\nimport ruLocale from 'date-fns/locale/ru';\nimport React, { forwardRef, useEffect } from 'react';\n\nimport { useFlag } from '../../../hooks/useFlag/useFlag';\nimport { DateTimeLabel } from '../DateTimeLabel/DateTimeLabel';\nimport { DateTimeMonth } from '../DateTimeMonth/DateTimeMonth';\nimport { DateTimeToggler } from '../DateTimeToggler/DateTimeToggler';\nimport { DateTimeTypeMonth } from '../DateTimeTypeMonth/DateTimeTypeMonth';\nimport { DateTimeYearSlider } from '../DateTimeYearSlider/DateTimeYearSlider';\nimport {\n DateTimeTypeComponent,\n getDaysOfMonth,\n getDaysOfWeek,\n getHandleSelectDate,\n getMouthLabelWithYear,\n isEqualDay,\n moveTypes,\n useCurrentVisibleDate,\n} from '../helpers';\nimport { dateTimePropView, dateTimePropViewDefault } from '../helpers/types';\nimport { cnDateTimeMixLayout } from '../mixs';\n\nexport const DateTimeTypeDate: DateTimeTypeComponent<'date'> = forwardRef(\n (props, ref) => {\n const {\n className,\n minDate,\n maxDate,\n value,\n disableDates,\n onChange,\n onChangeRange,\n currentVisibleDate: currentVisibleDateProp,\n events,\n locale = ruLocale,\n view = dateTimePropViewDefault,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n onMove,\n onChangeCurrentVisibleDate,\n ...otherProps\n } = props;\n\n const [changeMonth, setChangeMonth] = useFlag();\n\n useEffect(() => {\n !changeMonth && onMove?.(moveTypes[2]);\n }, [changeMonth]);\n\n const [currentVisibleDate, setCurrentVisibleDate] = useCurrentVisibleDate({\n currentVisibleDate: currentVisibleDateProp,\n maxDate,\n minDate,\n value,\n startOfUnit: startOfMonth,\n onChangeCurrentVisibleDate,\n });\n\n if (changeMonth) {\n return (\n <DateTimeTypeMonth\n {...otherProps}\n ref={ref}\n className={className}\n minDate={minDate}\n maxDate={maxDate}\n locale={locale}\n events={events}\n currentVisibleDate={currentVisibleDate}\n view={view}\n onChange={(value) => {\n setCurrentVisibleDate(value);\n setChangeMonth.off();\n }}\n onMove={onMove}\n />\n );\n }\n\n const handleSelectDate = getHandleSelectDate({\n minDate,\n maxDate,\n value,\n onChange,\n onChangeRange,\n isEqualUnit: isEqualDay,\n });\n\n const pageOneDaysOfMonth = getDaysOfMonth({\n date: currentVisibleDate,\n disableDates,\n handleDayClick: handleSelectDate,\n value,\n events,\n minDate,\n maxDate,\n locale,\n });\n\n const pageOneLabel = getMouthLabelWithYear(currentVisibleDate, locale);\n\n const daysOfWeek = getDaysOfWeek(locale);\n\n const nextMonthHandle = () =>\n setCurrentVisibleDate(addMonths(currentVisibleDate, 1));\n const prevMonthHandle = () =>\n setCurrentVisibleDate(addMonths(currentVisibleDate, -1));\n\n if (view === dateTimePropView[0]) {\n return (\n <div\n {...otherProps}\n ref={ref}\n className={cnDateTimeMixLayout({ view }, [className])}\n >\n <DateTimeToggler\n className={cnDateTimeMixLayout('Label')}\n prevOnClick={prevMonthHandle}\n nextOnClick={nextMonthHandle}\n label={pageOneLabel}\n onLabelClick={setChangeMonth.on}\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageOneDaysOfMonth}\n />\n </div>\n );\n }\n\n const pageTwoCurrentVisibleDate = addMonths(currentVisibleDate, 1);\n\n const pageTwoDaysOfMonth = getDaysOfMonth({\n date: pageTwoCurrentVisibleDate,\n disableDates,\n handleDayClick: handleSelectDate,\n value,\n events,\n minDate,\n maxDate,\n locale,\n });\n\n const pageTwoLabel = getMouthLabelWithYear(\n pageTwoCurrentVisibleDate,\n locale,\n );\n\n if (view === dateTimePropView[1]) {\n return (\n <div\n {...otherProps}\n ref={ref}\n className={cnDateTimeMixLayout({ view }, [className])}\n >\n <div className={cnDateTimeMixLayout('Page')}>\n <DateTimeToggler\n className={cnDateTimeMixLayout('Label')}\n prevOnClick={prevMonthHandle}\n label={pageOneLabel}\n onLabelClick={setChangeMonth.on}\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageOneDaysOfMonth}\n />\n </div>\n <div className={cnDateTimeMixLayout('Page')}>\n <DateTimeToggler\n className={cnDateTimeMixLayout('Label')}\n nextOnClick={nextMonthHandle}\n label={pageTwoLabel}\n onLabelClick={setChangeMonth.on}\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageTwoDaysOfMonth}\n />\n </div>\n </div>\n );\n }\n\n return (\n <div\n {...otherProps}\n ref={ref}\n className={cnDateTimeMixLayout({ view }, [className])}\n >\n <DateTimeYearSlider\n className={cnDateTimeMixLayout('Slider')}\n currentVisibleDate={currentVisibleDate}\n onChange={setCurrentVisibleDate}\n value={value}\n locale={locale}\n />\n <div className={cnDateTimeMixLayout('PageWrapper')}>\n <div className={cnDateTimeMixLayout('Page')}>\n <DateTimeLabel\n className={cnDateTimeMixLayout('Label')}\n label={pageOneLabel}\n onClick={setChangeMonth.on}\n cursor=\"pointer\"\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageOneDaysOfMonth}\n />\n </div>\n <div className={cnDateTimeMixLayout('Page')}>\n <DateTimeLabel\n className={cnDateTimeMixLayout('Label')}\n label={pageTwoLabel}\n onClick={setChangeMonth.on}\n cursor=\"pointer\"\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageTwoDaysOfMonth}\n />\n </div>\n </div>\n </div>\n );\n },\n);\n"],"mappings":"4YAAA,OAASA,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,CALV,EALF,CAYE,2BAAK,SAAS,CAAEd,mBAAmB,CAAC,aAAD,CAAnC,EACE,2BAAK,SAAS,CAAEA,mBAAmB,CAAC,MAAD,CAAnC,EACE,oBAAC,aAAD,EACE,SAAS,CAAEA,mBAAmB,CAAC,OAAD,CADhC,CAEE,KAAK,CAAEgC,CAFT,CAGE,OAAO,CAAET,CAAc,CAACa,EAH1B,CAIE,MAAM,CAAC,SAJT,EADF,CAOE,oBAAC,aAAD,EACE,UAAU,CAAEH,CADd,CAEE,WAAW,CAAEJ,CAFf,EAPF,CADF,CAaE,2BAAK,SAAS,CAAE7B,mBAAmB,CAAC,MAAD,CAAnC,EACE,oBAAC,aAAD,EACE,SAAS,CAAEA,mBAAmB,CAAC,OAAD,CADhC,CAEE,KAAK,CAAEuC,CAFT,CAGE,OAAO,CAAEhB,CAAc,CAACa,EAH1B,CAIE,MAAM,CAAC,SAJT,EADF,CAOE,oBAAC,aAAD,EACE,UAAU,CAAEH,CADd,CAEE,WAAW,CAAEK,CAFf,EAPF,CAbF,CAZF,CAwCH,CA3MsE,CAAlE"}
|
|
1
|
+
{"version":3,"file":"DateTimeTypeDate.js","names":["addMonths","startOfMonth","ruLocale","React","forwardRef","useEffect","useFlag","DateTimeLabel","DateTimeMonth","DateTimeToggler","DateTimeTypeMonth","DateTimeYearSlider","getDaysOfMonth","getDaysOfWeek","getHandleSelectDate","getMouthLabelWithYear","isEqualDay","moveTypes","useCurrentVisibleDate","dateTimePropView","dateTimePropViewDefault","cnDateTimeMixLayout","DateTimeTypeDate","props","ref","className","minDate","maxDate","value","disableDates","onChange","onChangeRange","currentVisibleDateProp","currentVisibleDate","events","locale","view","onMove","onChangeCurrentVisibleDate","otherProps","changeMonth","setChangeMonth","startOfUnit","setCurrentVisibleDate","off","handleSelectDate","isEqualUnit","pageOneDaysOfMonth","date","handleDayClick","pageOneLabel","daysOfWeek","nextMonthHandle","prevMonthHandle","on","pageTwoCurrentVisibleDate","pageTwoDaysOfMonth","pageTwoLabel"],"sources":["../../../../../../src/components/DateTime/DateTimeTypeDate/DateTimeTypeDate.tsx"],"sourcesContent":["import { addMonths, startOfMonth } from 'date-fns';\nimport ruLocale from 'date-fns/locale/ru';\nimport React, { forwardRef, useEffect } from 'react';\n\nimport { useFlag } from '../../../hooks/useFlag/useFlag';\nimport { DateTimeLabel } from '../DateTimeLabel/DateTimeLabel';\nimport { DateTimeMonth } from '../DateTimeMonth/DateTimeMonth';\nimport { DateTimeToggler } from '../DateTimeToggler/DateTimeToggler';\nimport { DateTimeTypeMonth } from '../DateTimeTypeMonth/DateTimeTypeMonth';\nimport { DateTimeYearSlider } from '../DateTimeYearSlider/DateTimeYearSlider';\nimport {\n DateTimeTypeComponent,\n getDaysOfMonth,\n getDaysOfWeek,\n getHandleSelectDate,\n getMouthLabelWithYear,\n isEqualDay,\n moveTypes,\n useCurrentVisibleDate,\n} from '../helpers';\nimport { dateTimePropView, dateTimePropViewDefault } from '../helpers/types';\nimport { cnDateTimeMixLayout } from '../mixs';\n\nexport const DateTimeTypeDate: DateTimeTypeComponent<'date'> = forwardRef(\n (props, ref) => {\n const {\n className,\n minDate,\n maxDate,\n value,\n disableDates,\n onChange,\n onChangeRange,\n currentVisibleDate: currentVisibleDateProp,\n events,\n locale = ruLocale,\n view = dateTimePropViewDefault,\n onMove,\n onChangeCurrentVisibleDate,\n ...otherProps\n } = props;\n\n const [changeMonth, setChangeMonth] = useFlag();\n\n useEffect(() => {\n !changeMonth && onMove?.(moveTypes[2]);\n }, [changeMonth]);\n\n const [currentVisibleDate, setCurrentVisibleDate] = useCurrentVisibleDate({\n currentVisibleDate: currentVisibleDateProp,\n maxDate,\n minDate,\n value,\n startOfUnit: startOfMonth,\n onChangeCurrentVisibleDate,\n });\n\n if (changeMonth) {\n return (\n <DateTimeTypeMonth\n {...otherProps}\n ref={ref}\n className={className}\n minDate={minDate}\n maxDate={maxDate}\n locale={locale}\n events={events}\n currentVisibleDate={currentVisibleDate}\n view={view}\n onChange={(value) => {\n setCurrentVisibleDate(value);\n setChangeMonth.off();\n }}\n onMove={onMove}\n />\n );\n }\n\n const handleSelectDate = getHandleSelectDate({\n minDate,\n maxDate,\n value,\n onChange,\n onChangeRange,\n isEqualUnit: isEqualDay,\n });\n\n const pageOneDaysOfMonth = getDaysOfMonth({\n date: currentVisibleDate,\n disableDates,\n handleDayClick: handleSelectDate,\n value,\n events,\n minDate,\n maxDate,\n locale,\n });\n\n const pageOneLabel = getMouthLabelWithYear(currentVisibleDate, locale);\n\n const daysOfWeek = getDaysOfWeek(locale);\n\n const nextMonthHandle = () =>\n setCurrentVisibleDate(addMonths(currentVisibleDate, 1));\n const prevMonthHandle = () =>\n setCurrentVisibleDate(addMonths(currentVisibleDate, -1));\n\n if (view === dateTimePropView[0]) {\n return (\n <div\n {...otherProps}\n ref={ref}\n className={cnDateTimeMixLayout({ view }, [className])}\n >\n <DateTimeToggler\n className={cnDateTimeMixLayout('Label')}\n prevOnClick={prevMonthHandle}\n nextOnClick={nextMonthHandle}\n label={pageOneLabel}\n onLabelClick={setChangeMonth.on}\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageOneDaysOfMonth}\n />\n </div>\n );\n }\n\n const pageTwoCurrentVisibleDate = addMonths(currentVisibleDate, 1);\n\n const pageTwoDaysOfMonth = getDaysOfMonth({\n date: pageTwoCurrentVisibleDate,\n disableDates,\n handleDayClick: handleSelectDate,\n value,\n events,\n minDate,\n maxDate,\n locale,\n });\n\n const pageTwoLabel = getMouthLabelWithYear(\n pageTwoCurrentVisibleDate,\n locale,\n );\n\n if (view === dateTimePropView[1]) {\n return (\n <div\n {...otherProps}\n ref={ref}\n className={cnDateTimeMixLayout({ view }, [className])}\n >\n <div className={cnDateTimeMixLayout('Page')}>\n <DateTimeToggler\n className={cnDateTimeMixLayout('Label')}\n prevOnClick={prevMonthHandle}\n label={pageOneLabel}\n onLabelClick={setChangeMonth.on}\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageOneDaysOfMonth}\n />\n </div>\n <div className={cnDateTimeMixLayout('Page')}>\n <DateTimeToggler\n className={cnDateTimeMixLayout('Label')}\n nextOnClick={nextMonthHandle}\n label={pageTwoLabel}\n onLabelClick={setChangeMonth.on}\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageTwoDaysOfMonth}\n />\n </div>\n </div>\n );\n }\n\n return (\n <div\n {...otherProps}\n ref={ref}\n className={cnDateTimeMixLayout({ view }, [className])}\n >\n <DateTimeYearSlider\n className={cnDateTimeMixLayout('Slider')}\n currentVisibleDate={currentVisibleDate}\n onChange={setCurrentVisibleDate}\n value={value}\n locale={locale}\n />\n <div className={cnDateTimeMixLayout('PageWrapper')}>\n <div className={cnDateTimeMixLayout('Page')}>\n <DateTimeLabel\n className={cnDateTimeMixLayout('Label')}\n label={pageOneLabel}\n onClick={setChangeMonth.on}\n cursor=\"pointer\"\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageOneDaysOfMonth}\n />\n </div>\n <div className={cnDateTimeMixLayout('Page')}>\n <DateTimeLabel\n className={cnDateTimeMixLayout('Label')}\n label={pageTwoLabel}\n onClick={setChangeMonth.on}\n cursor=\"pointer\"\n />\n <DateTimeMonth\n daysOfWeek={daysOfWeek}\n daysOfMonth={pageTwoDaysOfMonth}\n />\n </div>\n </div>\n </div>\n );\n },\n);\n"],"mappings":"4UAAA,OAASA,SAAT,CAAoBC,YAApB,KAAwC,UAAxC,CACA,MAAOC,SAAP,KAAqB,oBAArB,CACA,MAAOC,MAAP,EAAgBC,UAAhB,CAA4BC,SAA5B,KAA6C,OAA7C,CAEA,OAASC,OAAT,sCACA,OAASC,aAAT,sCACA,OAASC,aAAT,sCACA,OAASC,eAAT,0CACA,OAASC,iBAAT,8CACA,OAASC,kBAAT,gDACA,OAEEC,cAFF,CAGEC,aAHF,CAIEC,mBAJF,CAKEC,qBALF,CAMEC,UANF,CAOEC,SAPF,CAQEC,qBARF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T,CAGE,OAAO,CAAEhB,CAAc,CAACa,EAH1B,CAIE,MAAM,CAAC,SAJT,EADF,CAOE,oBAAC,aAAD,EACE,UAAU,CAAEH,CADd,CAEE,WAAW,CAAEK,CAFf,EAPF,CAbF,CAZF,CAwCH,CAxMsE,CAAlE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","onMove","currentVisibleDate","value","onChange","onChangeRange","minDate","maxDate","events","disableDates","locale","onChangeCurrentVisibleDate","
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","onMove","currentVisibleDate","value","onChange","onChangeRange","minDate","maxDate","events","disableDates","locale","onChangeCurrentVisibleDate","timeOptions","style","timeFor"];function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"./DateTimeTypeDateTime.css";import React,{forwardRef,useEffect,useRef,useState}from"react";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{cn}from"../../../utils/bem";import{DateTimeTypeDate}from"../DateTimeTypeDate/DateTimeTypeDate";import{DateTimeTypeTime}from"../DateTimeTypeTime/DateTimeTypeTime";import{moveTypes}from"../helpers";import{useOnChange}from"./useOnChange";var cnDateTimeTypeDateTime=cn("DateTimeTypeDateTime");export var DateTimeTypeDateTime=forwardRef(function(a,b){var c=a.className,d=a.onMove,e=a.currentVisibleDate,f=a.value,g=a.onChange,h=a.onChangeRange,i=a.minDate,j=a.maxDate,k=a.events,l=a.disableDates,m=a.locale,n=a.onChangeCurrentVisibleDate,o=a.timeOptions,p=a.style,q=a.timeFor,r=void 0===q?"start":q,s=_objectWithoutProperties(a,_excluded),t=useState(moveTypes[2]),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useState({"--root-padding-left":"0px"}),y=_slicedToArray(x,2),z=y[0],A=y[1],B=useOnChange(g,h,f,r,o,i,j,l),C=_slicedToArray(B,4),D=C[0],E=C[1],F=C[2],G=C[3],H=useRef(null),I=v===moveTypes[2];return useEffect(function(){H.current&&A({"--root-padding-left":window.getComputedStyle(H.current).paddingLeft||"0px"})},[]),React.createElement("div",Object.assign({},s,{className:cnDateTimeTypeDateTime({withTime:I},[c]),ref:useForkRef([H,b]),style:_objectSpread(_objectSpread({},p),z)}),React.createElement(DateTimeTypeDate,{className:cnDateTimeTypeDateTime("Date",{withTime:I}),onMove:function onMove(a){w(a),null===d||void 0===d?void 0:d(a)},currentVisibleDate:e,value:f,onChange:D,onChangeRange:E,minDate:i,disableDates:l,maxDate:j,events:k,locale:m,onChangeCurrentVisibleDate:n}),I&&React.createElement(DateTimeTypeTime,{className:cnDateTimeTypeDateTime("Time"),value:G,onChange:F,minDate:i,maxDate:j,disableDates:l,locale:m,timeOptions:o}))});
|
|
2
2
|
//# sourceMappingURL=DateTimeTypeDateTime.js.map
|
package/__internal__/src/components/DateTime/DateTimeTypeDateTime/DateTimeTypeDateTime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeTypeDateTime.js","names":["React","forwardRef","useEffect","useRef","useState","useForkRef","cn","DateTimeTypeDate","DateTimeTypeTime","moveTypes","useOnChange","cnDateTimeTypeDateTime","DateTimeTypeDateTime","props","ref","className","onMoveProp","onMove","currentVisibleDate","value","onChange","onChangeRange","minDate","maxDate","events","disableDates","locale","onChangeCurrentVisibleDate","
|
|
1
|
+
{"version":3,"file":"DateTimeTypeDateTime.js","names":["React","forwardRef","useEffect","useRef","useState","useForkRef","cn","DateTimeTypeDate","DateTimeTypeTime","moveTypes","useOnChange","cnDateTimeTypeDateTime","DateTimeTypeDateTime","props","ref","className","onMoveProp","onMove","currentVisibleDate","value","onChange","onChangeRange","minDate","maxDate","events","disableDates","locale","onChangeCurrentVisibleDate","timeOptions","style","timeFor","otherProps","moveType","setMoveType","cssVars","setCssVars","onDateChange","onDateChangeRange","onTimeChange","valueTime","rootRef","withTime","current","window","getComputedStyle","paddingLeft","type"],"sources":["../../../../../../src/components/DateTime/DateTimeTypeDateTime/DateTimeTypeDateTime.tsx"],"sourcesContent":["import './DateTimeTypeDateTime.css';\n\nimport React, { forwardRef, useEffect, useRef, useState } from 'react';\n\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { cn } from '../../../utils/bem';\nimport { DateTimeTypeDate } from '../DateTimeTypeDate/DateTimeTypeDate';\nimport { DateTimeTypeTime } from '../DateTimeTypeTime/DateTimeTypeTime';\nimport { DateTimeTypeComponent, MoveType, moveTypes } from '../helpers';\nimport { useOnChange } from './useOnChange';\n\nconst cnDateTimeTypeDateTime = cn('DateTimeTypeDateTime');\n\ntype CssVars = {\n '--root-padding-left': string;\n};\n\nexport const DateTimeTypeDateTime: DateTimeTypeComponent<'date-time'> =\n forwardRef((props, ref) => {\n const {\n className,\n onMove: onMoveProp,\n currentVisibleDate,\n value,\n onChange,\n onChangeRange,\n minDate,\n maxDate,\n events,\n disableDates,\n locale,\n onChangeCurrentVisibleDate,\n timeOptions,\n style,\n timeFor = 'start',\n ...otherProps\n } = props;\n\n const [moveType, setMoveType] = useState<MoveType>(moveTypes[2]);\n const [cssVars, setCssVars] = useState<CssVars>({\n '--root-padding-left': '0px',\n });\n\n const [onDateChange, onDateChangeRange, onTimeChange, valueTime] =\n useOnChange(\n onChange,\n onChangeRange,\n value,\n timeFor,\n timeOptions,\n minDate,\n maxDate,\n disableDates,\n );\n\n const rootRef = useRef<HTMLDivElement>(null);\n\n const onMove = (type: MoveType) => {\n setMoveType(type);\n onMoveProp?.(type);\n };\n\n const withTime = moveType === moveTypes[2];\n\n useEffect(() => {\n if (rootRef.current) {\n setCssVars({\n '--root-padding-left':\n window.getComputedStyle(rootRef.current).paddingLeft || '0px',\n });\n }\n }, []);\n\n return (\n <div\n {...otherProps}\n className={cnDateTimeTypeDateTime({ withTime }, [className])}\n ref={useForkRef([rootRef, ref])}\n style={{\n ...style,\n ...cssVars,\n }}\n >\n <DateTimeTypeDate\n className={cnDateTimeTypeDateTime('Date', { withTime })}\n onMove={onMove}\n currentVisibleDate={currentVisibleDate}\n value={value}\n onChange={onDateChange}\n onChangeRange={onDateChangeRange}\n minDate={minDate}\n disableDates={disableDates}\n maxDate={maxDate}\n events={events}\n locale={locale}\n onChangeCurrentVisibleDate={onChangeCurrentVisibleDate}\n />\n {withTime && (\n <DateTimeTypeTime\n className={cnDateTimeTypeDateTime('Time')}\n value={valueTime}\n onChange={onTimeChange}\n minDate={minDate}\n maxDate={maxDate}\n disableDates={disableDates}\n locale={locale}\n timeOptions={timeOptions}\n />\n )}\n </div>\n );\n });\n"],"mappings":"0gCAAA,mCAEA,MAAOA,MAAP,EAAgBC,UAAhB,CAA4BC,SAA5B,CAAuCC,MAAvC,CAA+CC,QAA/C,KAA+D,OAA/D,CAEA,OAASC,UAAT,4CACA,OAASC,EAAT,0BACA,OAASC,gBAAT,4CACA,OAASC,gBAAT,4CACA,OAA0CC,SAA1C,kBACA,OAASC,WAAT,qBAEA,GAAMC,uBAAsB,CAAGL,EAAE,CAAC,sBAAD,CAAjC,CAMA,MAAO,IAAMM,qBAAwD,CACnEX,UAAU,CAAC,SAACY,CAAD,CAAQC,CAAR,CAAgB,IAEvBC,EAFuB,CAkBrBF,CAlBqB,C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BJ,CAqCH,CA7FS,CADL"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DateRange } from '../../../utils/types/Date';
|
|
2
|
-
import { DateTimePropOnChange, DateTimePropOnChangeRange } from '../helpers';
|
|
3
|
-
export declare const useOnChange: (onChange: DateTimePropOnChange | undefined, onChangeRange: DateTimePropOnChangeRange<"date-time"> | undefined, value: DateRange | Date | undefined, timeFor: "start" | "end") => [DateTimePropOnChange, DateTimePropOnChangeRange<"date-time">, DateTimePropOnChange, Date | undefined];
|
|
2
|
+
import { DateTimePropDisableDates, DateTimePropOnChange, DateTimePropOnChangeRange, TimeOptions } from '../helpers';
|
|
3
|
+
export declare const useOnChange: (onChange: DateTimePropOnChange | undefined, onChangeRange: DateTimePropOnChangeRange<"date-time"> | undefined, value: DateRange | Date | undefined, timeFor: "start" | "end", timeOptions?: TimeOptions, minDate?: Date, maxDate?: Date, disableDates?: DateTimePropDisableDates) => [DateTimePropOnChange, DateTimePropOnChangeRange<"date-time">, DateTimePropOnChange, Date | undefined];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{getHours,getMinutes,getSeconds,set}from"date-fns";import{useCallback,useEffect
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{getHours,getMinutes,getSeconds,set,startOfDay,startOfToday}from"date-fns";import{useCallback,useEffect}from"react";import{useMutableRef}from"../../../hooks/useMutableRef/useMutableRef";import{getFirstValidDateTime}from"../DateTimeTypeTime/helpers";import{getDisableDatesKey}from"../helpers/getDisableDatesKey";import{getTimeOptionsKey}from"../helpers/getTimeOptionsKey";var getTime=function(a){return a?[getHours(a),getMinutes(a),getSeconds(a)]:[0,0,0]};export var useOnChange=function(a,b,c,d,e,f,g,h){var i=void 0!==c&&Array.isArray(c),j=i?c["start"===d?0:1]:c,k=useMutableRef(i?j:void 0),l=useMutableRef(a),m=useMutableRef(b),n=useCallback(function(a){var b=startOfDay(a||startOfToday()),c=getFirstValidDateTime(b,e,f,g,h);return c},[getTimeOptionsKey(e),null===f||void 0===f?void 0:f.getTime(),null===g||void 0===g?void 0:g.getTime(),getDisableDatesKey(h)]),o=function(a,b){if(!b)return a;var c=getTime(b),d=_slicedToArray(c,3),e=d[0],f=d[1],g=d[2],h=_slicedToArray(a,2),i=h[0],j=h[1],k=i?set(i,{hours:e,minutes:f,seconds:g}):i,l=j?set(j,{hours:e,minutes:f,seconds:g}):j;return[k,l]},p=useCallback(function(a,b){var c,d=b.e,e=n(a);null===(c=l.current)||void 0===c?void 0:c.call(l,e,{e:d})},[n]),q=useCallback(function(a,b){var c,f=b.e,e=a,g="start"===d?e[0]:e[1],h=k.current||void 0,i=(null===g||void 0===g?void 0:g.getTime())!==(null===h||void 0===h?void 0:h.getTime()),j=i?n(g):g,l=o(e,j);null===(c=m.current)||void 0===c?void 0:c.call(m,l,{e:f})},[d,n]),r=useCallback(function(a,b){var c,d=b.e;null===(c=l.current)||void 0===c?void 0:c.call(l,a,{e:d})},[]);return useEffect(function(){k.current=i?j:void 0},[i,null===j||void 0===j?void 0:j.getTime()]),[p,q,r,j]};
|
|
2
2
|
//# sourceMappingURL=useOnChange.js.map
|