@consta/uikit 4.14.2 → 4.16.0
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/__internal__/src/components/AutoCompleteCanary/useAutoComplete.js +1 -1
- package/__internal__/src/components/AutoCompleteCanary/useAutoComplete.js.map +1 -1
- package/__internal__/src/components/Combobox/Combobox.js +1 -1
- package/__internal__/src/components/Combobox/Combobox.js.map +1 -1
- package/__internal__/src/components/Combobox/helpers.d.ts +18 -7
- package/__internal__/src/components/Combobox/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/DatePickerFieldTypeDate.d.ts +3 -2
- 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/DatePickerFieldTypeDate/helpers.d.ts +2 -0
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDate/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateRange/DatePickerFieldTypeDateRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateRange/DatePickerFieldTypeDateRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.d.ts +3 -2
- 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 +2 -0
- 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.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.d.ts +3 -2
- 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/DatePickerFieldTypeMonth/helpers.d.ts +2 -0
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonthRange/DatePickerFieldTypeMonthRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonthRange/DatePickerFieldTypeMonthRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.d.ts +3 -2
- 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 +2 -0
- 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.d.ts +3 -2
- 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/DatePickerFieldTypeYear/helpers.d.ts +2 -0
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/helpers.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYear/helpers.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerFieldTypeYearRange/DatePickerFieldTypeYearRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/types.d.ts +1 -0
- package/__internal__/src/components/DatePicker/types.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/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 +2 -1
- 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/getDaysOfMonth.d.ts +2 -1
- package/__internal__/src/components/DateTime/helpers/getDaysOfMonth.js +1 -1
- package/__internal__/src/components/DateTime/helpers/getDaysOfMonth.js.map +1 -1
- package/__internal__/src/components/DateTime/helpers/getMonthsOfYear.d.ts +2 -1
- package/__internal__/src/components/DateTime/helpers/getMonthsOfYear.js +1 -1
- package/__internal__/src/components/DateTime/helpers/getMonthsOfYear.js.map +1 -1
- package/__internal__/src/components/DateTime/helpers/getYearsOfDecade.d.ts +2 -1
- package/__internal__/src/components/DateTime/helpers/getYearsOfDecade.js +1 -1
- package/__internal__/src/components/DateTime/helpers/getYearsOfDecade.js.map +1 -1
- package/__internal__/src/components/DateTime/helpers/types.d.ts +2 -0
- package/__internal__/src/components/DateTime/helpers/types.js.map +1 -1
- package/__internal__/src/components/EventInterceptor/propsHandlers/useTextFieldEventsHandler.d.ts +3 -2
- package/__internal__/src/components/FieldLabel/FieldLabel.css +1 -1
- package/__internal__/src/components/FieldLabel/FieldLabel.d.ts +2 -0
- package/__internal__/src/components/FieldLabel/FieldLabel.js +1 -1
- package/__internal__/src/components/FieldLabel/FieldLabel.js.map +1 -1
- package/__internal__/src/components/Select/helpers.d.ts +5 -2
- package/__internal__/src/components/Select/helpers.js.map +1 -1
- package/__internal__/src/components/SelectComponents/Select.css +1 -1
- package/__internal__/src/components/SelectComponents/SelectContainer/SelectContainer.d.ts +3 -1
- package/__internal__/src/components/SelectComponents/SelectContainer/SelectContainer.js +1 -1
- package/__internal__/src/components/SelectComponents/SelectContainer/SelectContainer.js.map +1 -1
- package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.d.ts +7 -2
- package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js +1 -1
- package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js.map +1 -1
- package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.d.ts +2 -0
- package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.js +1 -1
- package/__internal__/src/components/SelectComponents/SelectItem/SelectItem.js.map +1 -1
- package/__internal__/src/components/SelectComponents/SelectItemAll/SelectItemAll.css +1 -0
- package/__internal__/src/components/SelectComponents/SelectItemAll/SelectSelectAll.d.ts +13 -0
- package/__internal__/src/components/SelectComponents/SelectItemAll/SelectSelectAll.js +2 -0
- package/__internal__/src/components/SelectComponents/SelectItemAll/SelectSelectAll.js.map +1 -0
- package/__internal__/src/components/SelectComponents/SelectValueTag/SelectValueTag.css +1 -1
- package/__internal__/src/components/SelectComponents/types.d.ts +1 -1
- package/__internal__/src/components/SelectComponents/types.js +1 -1
- package/__internal__/src/components/SelectComponents/types.js.map +1 -1
- package/__internal__/src/components/Slider/Slider.js +1 -1
- package/__internal__/src/components/Slider/Slider.js.map +1 -1
- package/__internal__/src/components/Slider/helper.d.ts +1 -0
- package/__internal__/src/components/Slider/helper.js.map +1 -1
- package/__internal__/src/components/TagBase/TagBase.d.ts +1 -1
- package/__internal__/src/components/TextField/TextField.css +1 -1
- package/__internal__/src/components/TextField/TextField.js +1 -1
- package/__internal__/src/components/TextField/TextField.js.map +1 -1
- package/__internal__/src/components/TextField/types.d.ts +1 -0
- package/__internal__/src/components/TextField/types.js.map +1 -1
- package/__internal__/src/components/User/User.js +1 -1
- package/__internal__/src/components/User/User.js.map +1 -1
- package/__internal__/src/components/UserSelect/helpers.d.ts +5 -2
- package/__internal__/src/components/UserSelect/helpers.js.map +1 -1
- package/__internal__/src/hooks/useSelect/useSelect.d.ts +5 -2
- package/__internal__/src/hooks/useSelect/useSelect.js +1 -1
- package/__internal__/src/hooks/useSelect/useSelect.js.map +1 -1
- package/__internal__/src/utils/date/index.d.ts +1 -0
- package/__internal__/src/utils/date/index.js +1 -1
- package/__internal__/src/utils/date/index.js.map +1 -1
- package/__internal__/src/utils/date/isDisableDate.d.ts +8 -0
- package/__internal__/src/utils/date/isDisableDate.js +2 -0
- package/__internal__/src/utils/date/isDisableDate.js.map +1 -0
- package/__internal__/src/utils/date/isInMinMaxDade.d.ts +1 -1
- package/__internal__/src/utils/date/isInMinMaxDade.js +1 -1
- package/__internal__/src/utils/date/isInMinMaxDade.js.map +1 -1
- package/__internal__/src/utils/getGroups.d.ts +12 -0
- package/__internal__/src/utils/getGroups.js +1 -1
- package/__internal__/src/utils/getGroups.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ export declare const DatePickerFieldTypeDateTime: React.ForwardRefExoticComponen
|
|
|
12
12
|
disabled?: boolean | undefined;
|
|
13
13
|
size?: "m" | "s" | "xs" | "l" | undefined;
|
|
14
14
|
view?: "default" | "clear" | undefined;
|
|
15
|
-
form?: "default" | "round" | "
|
|
15
|
+
form?: "default" | "round" | "defaultClear" | "defaultBrick" | "brick" | "brickDefault" | "brickClear" | "brickRound" | "roundClear" | "roundBrick" | "clearRound" | "clearDefault" | "clearBrick" | "clearClear" | undefined;
|
|
16
16
|
status?: "alert" | "warning" | "success" | undefined;
|
|
17
17
|
width?: "default" | "full" | undefined;
|
|
18
18
|
onFocus?: React.FocusEventHandler<HTMLElement> | undefined;
|
|
@@ -37,7 +37,8 @@ export declare const DatePickerFieldTypeDateTime: React.ForwardRefExoticComponen
|
|
|
37
37
|
multiplicityMinutes?: number | undefined;
|
|
38
38
|
multiplicityHours?: number | undefined;
|
|
39
39
|
label?: string | undefined;
|
|
40
|
+
labelIcon?: import("@consta/icons/Icon").IconComponent | undefined;
|
|
40
41
|
caption?: string | undefined;
|
|
41
42
|
labelPosition?: "left" | "top" | undefined;
|
|
42
43
|
withClearButton?: boolean | undefined;
|
|
43
|
-
} & Omit<React.HTMLAttributes<HTMLDivElement>, "css" | "className" | "id" | "placeholder" | "tabIndex" | "children" | "onFocus" | "onBlur" | "onChange" | "onError" | "size" | "caption" | "form" | "label" | "view" | "separator" | "status" | "name" | "width" | "format" | "autoFocus" | "disabled" | "value" | "readOnly" | "required" | "inputRef" | "focused" | "ariaLabel" | "labelPosition" | "leftSide" | "rightSide" | "withClearButton" | "iconSize" | "minDate" | "maxDate" | "multiplicitySeconds" | "multiplicityMinutes" | "multiplicityHours"> & React.RefAttributes<HTMLDivElement>>;
|
|
44
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "css" | "className" | "id" | "placeholder" | "tabIndex" | "children" | "onFocus" | "onBlur" | "onChange" | "onError" | "size" | "caption" | "form" | "label" | "view" | "separator" | "status" | "name" | "width" | "format" | "autoFocus" | "disabled" | "value" | "readOnly" | "required" | "inputRef" | "focused" | "ariaLabel" | "labelIcon" | "labelPosition" | "leftSide" | "rightSide" | "withClearButton" | "iconSize" | "minDate" | "maxDate" | "multiplicitySeconds" | "multiplicityMinutes" | "multiplicityHours"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes"];import React from"react";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{TextField}from"../../TextField/TextField";import{datePickerPropFormatTypeDateTime,datePickerPropPlaceholderTypeDateTime,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeDateTime=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeDateTime:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeDateTime:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=a.multiplicityHours,r=a.multiplicitySeconds,s=a.multiplicityMinutes,t=_objectWithoutProperties(a,_excluded),u=usePicker({onChange:i,value:o,onError:j,maxDate:n,minDate:l,multiplicityHours:q,multiplicityMinutes:s,multiplicitySeconds:r,separator:f,format:d}),v=u.stringValue,w=u.inputRef;return React.createElement(TextField,Object.assign({},t,{type:"text",inputContainerRef:b,inputRef:useForkRef([w,p]),value:v,placeholder:h}))});
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes"];import React from"react";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{TextField}from"../../TextField/TextField";import{datePickerPropFormatTypeDateTime,datePickerPropPlaceholderTypeDateTime,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeDateTime=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeDateTime:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeDateTime:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=a.multiplicityHours,r=a.multiplicitySeconds,s=a.multiplicityMinutes,t=_objectWithoutProperties(a,_excluded),u=usePicker({onChange:i,value:o,onError:j,maxDate:n,minDate:l,multiplicityHours:q,multiplicityMinutes:s,multiplicitySeconds:r,separator:f,format:d}),v=u.stringValue,w=u.inputRef,x=u.clearValue;return React.createElement(TextField,Object.assign({},t,{type:"text",onChange:function(a){var b=a.e,c=a.value;return null===c&&x(b.nativeEvent)},inputContainerRef:b,inputRef:useForkRef([w,p]),value:v,placeholder:h}))});
|
|
2
2
|
//# sourceMappingURL=DatePickerFieldTypeDateTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerFieldTypeDateTime.js","names":["React","useForkRef","maxDateDefault","minDateDefault","TextField","datePickerPropFormatTypeDateTime","datePickerPropPlaceholderTypeDateTime","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeDateTime","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes","otherProps","stringValue"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { maxDateDefault, minDateDefault } from '../../../utils/date';\nimport { TextField } from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeDateTime,\n datePickerPropPlaceholderTypeDateTime,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeDateTimeProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeDateTime = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeDateTimeProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeDateTime,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeDateTime,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n multiplicityHours,\n multiplicitySeconds,\n multiplicityMinutes,\n ...otherProps\n } = props;\n\n const { stringValue, inputRef } = usePicker({\n onChange,\n value,\n onError,\n maxDate,\n minDate,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n separator,\n format,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n value={stringValue}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"oQAAA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,UAAT,4CACA,OAASC,cAAT,CAAyBC,cAAzB,2BACA,OAASC,SAAT,iCACA,OACEC,gCADF,CAEEC,qCAFF,CAGEC,8BAHF,kBAKA,OAA2CC,SAA3C,iBAEA,MAAO,IAAMC,4BAA2B,CAAGT,KAAK,CAACU,UAAN,CAGzC,SAACC,CAAD,CAAQC,CAAR,CAAgB,OAeZD,CAfY,CAEdE,MAFc,CAEdA,CAFc,YAELR,gCAFK,KAeZM,CAfY,CAGdG,SAHc,CAGdA,CAHc,YAGFP,8BAHE,KAeZI,CAfY,CAIdI,WAJc,CAIdA,CAJc,YAIAT,qCAJA,GAKdU,CALc,CAeZL,CAfY,CAKdK,QALc,CAMdC,CANc,CAeZN,CAfY,CAMdM,OANc,GAeZN,CAfY,CAOdO,OAPc,CAOdA,CAPc,YAOJf,cAPI,KAeZQ,CAfY,CAQdQ,OARc,CAQdA,CARc,YAQJjB,cARI,GASdkB,CATc,CAeZT,CAfY,CASdS,KATc,CAUJC,CAVI,CAeZV,CAfY,CAUdW,QAVc,CAWdC,CAXc,CAeZZ,CAfY,CAWdY,iBAXc,CAYdC,CAZc,CAeZb,CAfY,CAYda,mBAZc,CAadC,CAbc,CAeZd,CAfY,CAadc,mBAbc,CAcXC,CAdW,0BAeZf,CAfY,
|
|
1
|
+
{"version":3,"file":"DatePickerFieldTypeDateTime.js","names":["React","useForkRef","maxDateDefault","minDateDefault","TextField","datePickerPropFormatTypeDateTime","datePickerPropPlaceholderTypeDateTime","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeDateTime","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes","otherProps","stringValue","clearValue","e","nativeEvent"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { maxDateDefault, minDateDefault } from '../../../utils/date';\nimport { TextField } from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeDateTime,\n datePickerPropPlaceholderTypeDateTime,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeDateTimeProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeDateTime = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeDateTimeProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeDateTime,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeDateTime,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n multiplicityHours,\n multiplicitySeconds,\n multiplicityMinutes,\n ...otherProps\n } = props;\n\n const { stringValue, inputRef, clearValue } = usePicker({\n onChange,\n value,\n onError,\n maxDate,\n minDate,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n separator,\n format,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n onChange={({ e, value }) => value === null && clearValue(e.nativeEvent)}\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n value={stringValue}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"oQAAA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,UAAT,4CACA,OAASC,cAAT,CAAyBC,cAAzB,2BACA,OAASC,SAAT,iCACA,OACEC,gCADF,CAEEC,qCAFF,CAGEC,8BAHF,kBAKA,OAA2CC,SAA3C,iBAEA,MAAO,IAAMC,4BAA2B,CAAGT,KAAK,CAACU,UAAN,CAGzC,SAACC,CAAD,CAAQC,CAAR,CAAgB,OAeZD,CAfY,CAEdE,MAFc,CAEdA,CAFc,YAELR,gCAFK,KAeZM,CAfY,CAGdG,SAHc,CAGdA,CAHc,YAGFP,8BAHE,KAeZI,CAfY,CAIdI,WAJc,CAIdA,CAJc,YAIAT,qCAJA,GAKdU,CALc,CAeZL,CAfY,CAKdK,QALc,CAMdC,CANc,CAeZN,CAfY,CAMdM,OANc,GAeZN,CAfY,CAOdO,OAPc,CAOdA,CAPc,YAOJf,cAPI,KAeZQ,CAfY,CAQdQ,OARc,CAQdA,CARc,YAQJjB,cARI,GASdkB,CATc,CAeZT,CAfY,CASdS,KATc,CAUJC,CAVI,CAeZV,CAfY,CAUdW,QAVc,CAWdC,CAXc,CAeZZ,CAfY,CAWdY,iBAXc,CAYdC,CAZc,CAeZb,CAfY,CAYda,mBAZc,CAadC,CAbc,CAeZd,CAfY,CAadc,mBAbc,CAcXC,CAdW,0BAeZf,CAfY,cAiB8BH,SAAS,CAAC,CACtDQ,QAAQ,CAARA,CADsD,CAEtDI,KAAK,CAALA,CAFsD,CAGtDH,OAAO,CAAPA,CAHsD,CAItDE,OAAO,CAAPA,CAJsD,CAKtDD,OAAO,CAAPA,CALsD,CAMtDK,iBAAiB,CAAjBA,CANsD,CAOtDE,mBAAmB,CAAnBA,CAPsD,CAQtDD,mBAAmB,CAAnBA,CARsD,CAStDV,SAAS,CAATA,CATsD,CAUtDD,MAAM,CAANA,CAVsD,CAAD,CAjBvC,CAiBRc,CAjBQ,GAiBRA,WAjBQ,CAiBKL,CAjBL,GAiBKA,QAjBL,CAiBeM,CAjBf,GAiBeA,UAjBf,CA8BhB,MACE,qBAAC,SAAD,kBACMF,CADN,EAEE,IAAI,CAAC,MAFP,CAGE,QAAQ,CAAE,eAAGG,EAAH,GAAGA,CAAH,CAAMT,CAAN,GAAMA,KAAN,OAA4B,KAAV,GAAAA,CAAK,EAAaQ,CAAU,CAACC,CAAC,CAACC,WAAH,CAA9C,CAHZ,CAIE,iBAAiB,CAAElB,CAJrB,CAKE,QAAQ,CAAEX,UAAU,CAAC,CAACqB,CAAD,CAAWD,CAAX,CAAD,CALtB,CAME,KAAK,CAAEM,CANT,CAOE,WAAW,CAAEZ,CAPf,GAUH,CA5C0C,CAApC"}
|
|
@@ -42,6 +42,7 @@ export declare type DatePickerFieldTypeDateTimeProps = PropsWithHTMLAttributes<{
|
|
|
42
42
|
multiplicityMinutes?: number;
|
|
43
43
|
multiplicityHours?: number;
|
|
44
44
|
label?: string;
|
|
45
|
+
labelIcon?: IconComponent;
|
|
45
46
|
caption?: string;
|
|
46
47
|
labelPosition?: 'top' | 'left';
|
|
47
48
|
withClearButton?: boolean;
|
|
@@ -61,5 +62,6 @@ declare type UsePickerProps = {
|
|
|
61
62
|
export declare const usePicker: (props: UsePickerProps) => {
|
|
62
63
|
stringValue: string | null;
|
|
63
64
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
65
|
+
clearValue: (e: Event) => void;
|
|
64
66
|
};
|
|
65
67
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{addHours,addMinutes,addSeconds,format as _format,isValid,isWithinInterval,parse as _parse,startOfDay,startOfHour,startOfMinute}from"date-fns";import IMask from"imask";import{useCallback,useEffect,useMemo,useState}from"react";import{useIMask}from"../../TextField";import{useMutableRef}from"../../../hooks/useMutableRef/useMutableRef";import{leapYear}from"../../../utils/date";import{getLabelHours,getLabelMinutes,getLabelSeconds}from"../../DateTime/helpers";import{datePickerPropFormatTypeDate,datePickerPropFormatTypeDateTime,datePickerPropSeparatorDefault,getParts,getPartsDate,getTimeEnum}from"../helpers";import{datePickerErrorTypes}from"../types";export var usePicker=function(a){var b=a.value,c=a.onChange,d=a.onError,f=a.format,g=a.separator,h=a.maxDate,i=a.minDate,j=a.multiplicityHours,k=a.multiplicityMinutes,l=a.multiplicitySeconds,m=useMutableRef(c),n=useMutableRef(b),o=useMutableRef(d),p=useState(b&&isValid(b)?_format(b,f):null),q=_slicedToArray(p,2),r=q[0],s=q[1],t=useMutableRef(r),u=useMemo(function(){return getParts(f,g,!0)},[f,g]),v=useCallback(function(a){var b=a.e,c=a.value;if(t.current!==c){s(c);var d=m.current,e=n.current;if(d){if(!c)return void(e&&d({e:b,value:null}));var j=getPartsDate(c,f,g,!0,["dd","MM","yyyy","HH","mm","ss"]),k=_slicedToArray(j,6),l=k[0],p=k[1],q=k[2],r=k[3],v=k[4],w=k[5];if(j.filter(function(a){return!!a}).length===u.length){var y=_parse("".concat(l).concat(datePickerPropSeparatorDefault).concat(p).concat(datePickerPropSeparatorDefault).concat(q," ").concat(r||"00",":").concat(v||"00",":").concat(w||"00"),datePickerPropFormatTypeDateTime,new Date);if(!isWithinInterval(y,{start:i,end:h})){var x;return null===(x=o.current)||void 0===x?void 0:x.call(o,{type:datePickerErrorTypes[0],stringValue:c,dd:l,MM:p,yyyy:q,date:y,HH:r,mm:v,ss:w}),void(e&&d({e:b,value:null}))}d({e:b,value:y})}else e&&d({e:b,value:null})}}},[null===i||void 0===i?void 0:i.getTime(),null===h||void 0===h?void 0:h.getTime(),f,g]),w=useMemo(function(){return{mask:Date,pattern:f,blocks:{yyyy:{mask:IMask.MaskedRange,from:1,to:9999},MM:{mask:IMask.MaskedRange,from:1,to:12},dd:{mask:IMask.MaskedRange,from:1,to:31},HH:j&&1<j?{mask:IMask.MaskedEnum,enum:getTimeEnum(24,j,startOfDay,addHours,getLabelHours)}:{mask:IMask.MaskedRange,from:0,to:23},mm:k&&1<k?{mask:IMask.MaskedEnum,enum:getTimeEnum(60,k,startOfHour,addMinutes,getLabelMinutes)}:{mask:IMask.MaskedRange,from:0,to:59},ss:l&&1<l?{mask:IMask.MaskedEnum,enum:getTimeEnum(60,l,startOfMinute,addSeconds,getLabelSeconds)}:{mask:IMask.MaskedRange,from:0,to:59}},lazy:!0,autofix:!0,format:function format(a){return _format(a,f)},parse:function parse(a){return _parse(a,f,new Date)},validate:function validate(a){var b=getPartsDate(a,f,g,!0,["dd","MM","yyyy","HH","mm","ss"]),c=_slicedToArray(b,6),d=c[0],e=c[1],h=c[2],i=c[3],j=c[4],k=c[5];if(d&&e&&!isValid(_parse("".concat(d).concat(datePickerPropSeparatorDefault).concat(e).concat(datePickerPropSeparatorDefault).concat(leapYear),datePickerPropFormatTypeDate,new Date))){var l;return null===(l=o.current)||void 0===l?void 0:l.call(o,{type:datePickerErrorTypes[1],stringValue:a,dd:d,MM:e,yyyy:h,HH:i,mm:j,ss:k}),!1}if(d&&e&&h&&!isValid(_parse("".concat(d).concat(datePickerPropSeparatorDefault).concat(e).concat(datePickerPropSeparatorDefault).concat(h),datePickerPropFormatTypeDate,new Date))){var m;return null===(m=o.current)||void 0===m?void 0:m.call(o,{type:datePickerErrorTypes[1],stringValue:a,dd:d,MM:e,yyyy:h,HH:i,mm:j,ss:k}),!1}return!0}}},[f,g,j,l,k]),x=useIMask({value:r,onChange:function(a,b){return null===v||void 0===v?void 0:v(b)},maskOptions:w}),y=x.inputRef;return useEffect(function(){b&&isValid(b)?s(_format(b,f)):(null===r||void 0===r?void 0:r.length)===f.length&&s("")},[null===b||void 0===b?void 0:b.getTime()]),{stringValue:r,inputRef:y}};
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{addHours,addMinutes,addSeconds,format as _format,isValid,isWithinInterval,parse as _parse,startOfDay,startOfHour,startOfMinute}from"date-fns";import IMask from"imask";import{useCallback,useEffect,useMemo,useState}from"react";import{useIMask}from"../../TextField";import{useMutableRef}from"../../../hooks/useMutableRef/useMutableRef";import{leapYear}from"../../../utils/date";import{getLabelHours,getLabelMinutes,getLabelSeconds}from"../../DateTime/helpers";import{datePickerPropFormatTypeDate,datePickerPropFormatTypeDateTime,datePickerPropSeparatorDefault,getParts,getPartsDate,getTimeEnum}from"../helpers";import{datePickerErrorTypes}from"../types";export var usePicker=function(a){var b=a.value,c=a.onChange,d=a.onError,f=a.format,g=a.separator,h=a.maxDate,i=a.minDate,j=a.multiplicityHours,k=a.multiplicityMinutes,l=a.multiplicitySeconds,m=useMutableRef(c),n=useMutableRef(b),o=useMutableRef(d),p=useState(b&&isValid(b)?_format(b,f):null),q=_slicedToArray(p,2),r=q[0],s=q[1],t=useMutableRef(r),u=useMemo(function(){return getParts(f,g,!0)},[f,g]),v=useCallback(function(a){var b=a.e,c=a.value;if(t.current!==c){s(c);var d=m.current,e=n.current;if(d){if(!c)return void(e&&d({e:b,value:null}));var j=getPartsDate(c,f,g,!0,["dd","MM","yyyy","HH","mm","ss"]),k=_slicedToArray(j,6),l=k[0],p=k[1],q=k[2],r=k[3],v=k[4],w=k[5];if(j.filter(function(a){return!!a}).length===u.length){var y=_parse("".concat(l).concat(datePickerPropSeparatorDefault).concat(p).concat(datePickerPropSeparatorDefault).concat(q," ").concat(r||"00",":").concat(v||"00",":").concat(w||"00"),datePickerPropFormatTypeDateTime,new Date);if(!isWithinInterval(y,{start:i,end:h})){var x;return null===(x=o.current)||void 0===x?void 0:x.call(o,{type:datePickerErrorTypes[0],stringValue:c,dd:l,MM:p,yyyy:q,date:y,HH:r,mm:v,ss:w}),void(e&&d({e:b,value:null}))}d({e:b,value:y})}else e&&d({e:b,value:null})}}},[null===i||void 0===i?void 0:i.getTime(),null===h||void 0===h?void 0:h.getTime(),f,g]),w=useMemo(function(){return{mask:Date,pattern:f,blocks:{yyyy:{mask:IMask.MaskedRange,from:1,to:9999},MM:{mask:IMask.MaskedRange,from:1,to:12},dd:{mask:IMask.MaskedRange,from:1,to:31},HH:j&&1<j?{mask:IMask.MaskedEnum,enum:getTimeEnum(24,j,startOfDay,addHours,getLabelHours)}:{mask:IMask.MaskedRange,from:0,to:23},mm:k&&1<k?{mask:IMask.MaskedEnum,enum:getTimeEnum(60,k,startOfHour,addMinutes,getLabelMinutes)}:{mask:IMask.MaskedRange,from:0,to:59},ss:l&&1<l?{mask:IMask.MaskedEnum,enum:getTimeEnum(60,l,startOfMinute,addSeconds,getLabelSeconds)}:{mask:IMask.MaskedRange,from:0,to:59}},lazy:!0,autofix:!0,format:function format(a){return _format(a,f)},parse:function parse(a){return _parse(a,f,new Date)},validate:function validate(a){var b=getPartsDate(a,f,g,!0,["dd","MM","yyyy","HH","mm","ss"]),c=_slicedToArray(b,6),d=c[0],e=c[1],h=c[2],i=c[3],j=c[4],k=c[5];if(d&&e&&!isValid(_parse("".concat(d).concat(datePickerPropSeparatorDefault).concat(e).concat(datePickerPropSeparatorDefault).concat(leapYear),datePickerPropFormatTypeDate,new Date))){var l;return null===(l=o.current)||void 0===l?void 0:l.call(o,{type:datePickerErrorTypes[1],stringValue:a,dd:d,MM:e,yyyy:h,HH:i,mm:j,ss:k}),!1}if(d&&e&&h&&!isValid(_parse("".concat(d).concat(datePickerPropSeparatorDefault).concat(e).concat(datePickerPropSeparatorDefault).concat(h),datePickerPropFormatTypeDate,new Date))){var m;return null===(m=o.current)||void 0===m?void 0:m.call(o,{type:datePickerErrorTypes[1],stringValue:a,dd:d,MM:e,yyyy:h,HH:i,mm:j,ss:k}),!1}return!0}}},[f,g,j,l,k]),x=useIMask({value:r,onChange:function(a,b){return null===v||void 0===v?void 0:v(b)},maskOptions:w}),y=x.inputRef;return useEffect(function(){b&&isValid(b)?s(_format(b,f)):(null===r||void 0===r?void 0:r.length)===f.length&&s("")},[null===b||void 0===b?void 0:b.getTime()]),{stringValue:r,inputRef:y,clearValue:function clearValue(a){s(null),null===c||void 0===c?void 0:c({e:a,value:null})}}};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["addHours","addMinutes","addSeconds","format","isValid","isWithinInterval","parse","startOfDay","startOfHour","startOfMinute","IMask","useCallback","useEffect","useMemo","useState","useIMask","useMutableRef","leapYear","getLabelHours","getLabelMinutes","getLabelSeconds","datePickerPropFormatTypeDate","datePickerPropFormatTypeDateTime","datePickerPropSeparatorDefault","getParts","getPartsDate","getTimeEnum","datePickerErrorTypes","usePicker","props","value","onChange","onError","formatProp","separator","maxDate","minDate","multiplicityHours","multiplicityMinutes","multiplicitySeconds","onChangeRef","valueRef","onErrorRef","stringValue","setStringValue","stringValueRef","formatParts","handleChange","e","current","partsDate","dd","MM","yyyy","HH","mm","ss","filter","item","length","date","Date","start","end","type","getTime","options","mask","pattern","blocks","MaskedRange","from","to","MaskedEnum","lazy","autofix","string","validate","_val","params","maskOptions","inputRef"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport {\n addHours,\n addMinutes,\n addSeconds,\n format,\n isValid,\n isWithinInterval,\n parse,\n startOfDay,\n startOfHour,\n startOfMinute,\n} from 'date-fns';\nimport IMask from 'imask';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { useIMask } from '##/components/TextField';\n\nimport { useMutableRef } from '../../../hooks/useMutableRef/useMutableRef';\nimport { leapYear } from '../../../utils/date';\nimport { PropsWithHTMLAttributes } from '../../../utils/types/PropsWithHTMLAttributes';\nimport {\n getLabelHours,\n getLabelMinutes,\n getLabelSeconds,\n} from '../../DateTime/helpers';\nimport {\n TextFieldPropForm,\n TextFieldPropSize,\n TextFieldPropStatus,\n TextFieldPropView,\n TextFieldPropWidth,\n} from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeDate,\n datePickerPropFormatTypeDateTime,\n datePickerPropSeparatorDefault,\n getParts,\n getPartsDate,\n getTimeEnum,\n} from '../helpers';\nimport { datePickerErrorTypes, DatePickerPropOnError } from '../types';\n\ntype DatePickerFieldTypeDateTimePropOnChange = (props: {\n e: Event;\n value: Date | null;\n}) => void;\n\nexport type DatePickerFieldTypeDateTimeProps = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: Date | null;\n onChange?: DatePickerFieldTypeDateTimePropOnChange;\n onError?: DatePickerPropOnError;\n id?: string;\n name?: string;\n disabled?: boolean;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n status?: TextFieldPropStatus;\n width?: TextFieldPropWidth;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n readOnly?: boolean;\n required?: boolean;\n tabIndex?: number;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n format?: string;\n separator?: string;\n minDate?: Date;\n maxDate?: Date;\n focused?: boolean;\n multiplicitySeconds?: number;\n multiplicityMinutes?: number;\n multiplicityHours?: number;\n label?: string;\n caption?: string;\n labelPosition?: 'top' | 'left';\n withClearButton?: boolean;\n },\n HTMLDivElement\n>;\n\ntype UsePickerProps = {\n value?: Date | null;\n onChange?: DatePickerFieldTypeDateTimePropOnChange;\n onError?: DatePickerPropOnError;\n format: string;\n separator: string;\n minDate: Date;\n maxDate: Date;\n multiplicityHours: number | undefined;\n multiplicitySeconds: number | undefined;\n multiplicityMinutes: number | undefined;\n};\n\nexport const usePicker = (props: UsePickerProps) => {\n const {\n value,\n onChange,\n onError,\n format: formatProp,\n separator,\n maxDate,\n minDate,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n } = props;\n const onChangeRef = useMutableRef(onChange);\n const valueRef = useMutableRef(value);\n const onErrorRef = useMutableRef(onError);\n\n const [stringValue, setStringValue] = useState<string | null>(\n value && isValid(value) ? format(value, formatProp) : null,\n );\n const stringValueRef = useMutableRef(stringValue);\n\n const formatParts = useMemo(\n () => getParts(formatProp, separator, true),\n [formatProp, separator],\n );\n\n const handleChange = useCallback(\n ({ e, value: stringValue }: { e: Event; value: string | null }) => {\n if (stringValueRef.current === stringValue) {\n return;\n }\n\n setStringValue(stringValue);\n const onChange = onChangeRef.current;\n const value = valueRef.current;\n\n if (onChange) {\n if (!stringValue) {\n if (value) {\n onChange({ e, value: null });\n }\n return;\n }\n\n const partsDate = getPartsDate(\n stringValue,\n formatProp,\n separator,\n true,\n ['dd', 'MM', 'yyyy', 'HH', 'mm', 'ss'],\n );\n\n const [dd, MM, yyyy, HH, mm, ss] = partsDate;\n\n if (partsDate.filter((item) => !!item).length === formatParts.length) {\n const date = parse(\n `${dd}${datePickerPropSeparatorDefault}${MM}${datePickerPropSeparatorDefault}${yyyy} ${\n HH || '00'\n }:${mm || '00'}:${ss || '00'}`,\n datePickerPropFormatTypeDateTime,\n new Date(),\n );\n if (!isWithinInterval(date, { start: minDate, end: maxDate })) {\n onErrorRef.current?.({\n type: datePickerErrorTypes[0],\n stringValue,\n dd,\n MM,\n yyyy,\n date,\n HH,\n mm,\n ss,\n });\n\n if (value) {\n onChange({ e, value: null });\n }\n return;\n }\n onChange({ e, value: date });\n } else if (value) {\n onChange({ e, value: null });\n }\n }\n },\n [minDate?.getTime(), maxDate?.getTime(), formatProp, separator],\n );\n\n const options: IMask.InputMask<IMask.MaskedDateOptions> = useMemo(\n () =>\n ({\n mask: Date,\n pattern: formatProp,\n blocks: {\n yyyy: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 9999,\n },\n MM: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 12,\n },\n dd: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 31,\n },\n HH:\n multiplicityHours && multiplicityHours > 1\n ? {\n mask: IMask.MaskedEnum,\n enum: getTimeEnum(\n 24,\n multiplicityHours,\n startOfDay,\n addHours,\n getLabelHours,\n ),\n }\n : {\n mask: IMask.MaskedRange,\n from: 0,\n to: 23,\n },\n mm:\n multiplicityMinutes && multiplicityMinutes > 1\n ? {\n mask: IMask.MaskedEnum,\n enum: getTimeEnum(\n 60,\n multiplicityMinutes,\n startOfHour,\n addMinutes,\n getLabelMinutes,\n ),\n }\n : {\n mask: IMask.MaskedRange,\n from: 0,\n to: 59,\n },\n ss:\n multiplicitySeconds && multiplicitySeconds > 1\n ? {\n mask: IMask.MaskedEnum,\n enum: getTimeEnum(\n 60,\n multiplicitySeconds,\n startOfMinute,\n addSeconds,\n getLabelSeconds,\n ),\n }\n : {\n mask: IMask.MaskedRange,\n from: 0,\n to: 59,\n },\n },\n lazy: true,\n autofix: true,\n format: (date: Date) => format(date, formatProp),\n parse: (string: string) => parse(string, formatProp, new Date()),\n validate: (string: string) => {\n const [dd, MM, yyyy, HH, mm, ss] = getPartsDate(\n string,\n formatProp,\n separator,\n true,\n ['dd', 'MM', 'yyyy', 'HH', 'mm', 'ss'],\n );\n if (\n dd &&\n MM &&\n !isValid(\n parse(\n `${dd}${datePickerPropSeparatorDefault}${MM}${datePickerPropSeparatorDefault}${leapYear}`,\n datePickerPropFormatTypeDate,\n new Date(),\n ),\n )\n ) {\n onErrorRef.current?.({\n type: datePickerErrorTypes[1],\n stringValue: string,\n dd,\n MM,\n yyyy,\n HH,\n mm,\n ss,\n });\n return false;\n }\n if (\n dd &&\n MM &&\n yyyy &&\n !isValid(\n parse(\n `${dd}${datePickerPropSeparatorDefault}${MM}${datePickerPropSeparatorDefault}${yyyy}`,\n datePickerPropFormatTypeDate,\n new Date(),\n ),\n )\n ) {\n onErrorRef.current?.({\n type: datePickerErrorTypes[1],\n stringValue: string,\n dd,\n MM,\n yyyy,\n HH,\n mm,\n ss,\n });\n return false;\n }\n return true;\n },\n // проблема в типах IMask\n } as unknown as IMask.InputMask<IMask.MaskedDateOptions>),\n [\n formatProp,\n separator,\n multiplicityHours,\n multiplicitySeconds,\n multiplicityMinutes,\n ],\n );\n\n const { inputRef } = useIMask({\n value: stringValue,\n onChange: (_val, params) => handleChange?.(params),\n maskOptions: options,\n });\n\n // при изменении value, нужно обновить stringValue\n useEffect(() => {\n if (value && isValid(value)) {\n setStringValue(format(value, formatProp));\n } else if (stringValue?.length === formatProp.length) {\n // если количество введенных символов меньше чем в формате маски\n // то не нужно мешать вводу с клавиатуры\n // если дата была введена полностью и value пришел null,\n // то можно считать что поле нуждается в очистке\n setStringValue('');\n }\n }, [value?.getTime()]);\n\n return {\n stringValue,\n inputRef,\n };\n};\n"],"mappings":"iEACA,OACEA,QADF,CAEEC,UAFF,CAGEC,UAHF,CAIEC,MAAM,GAANA,QAJF,CAKEC,OALF,CAMEC,gBANF,CAOEC,KAAK,GAALA,OAPF,CAQEC,UARF,CASEC,WATF,CAUEC,aAVF,KAWO,UAXP,CAYA,MAAOC,MAAP,KAAkB,OAAlB,CACA,OAAgBC,WAAhB,CAA6BC,SAA7B,CAAwCC,OAAxC,CAAiDC,QAAjD,KAAiE,OAAjE,CAEA,OAASC,QAAT,uBAEA,OAASC,aAAT,kDACA,OAASC,QAAT,2BAEA,OACEC,aADF,CAEEC,eAFF,CAGEC,eAHF,8BAYA,OACEC,4BADF,CAEEC,gCAFF,CAGEC,8BAHF,CAIEC,QAJF,CAKEC,YALF,CAMEC,WANF,kBAQA,OAASC,oBAAT,gBA+DA,MAAO,IAAMC,UA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CALF,CAxI+D,CA1Ff,GA2O7BvB,QAAQ,CAAC,CAC5Be,KAAK,CAAEa,CADqB,CAE5BZ,QAAQ,CAAE,SAAC+C,CAAD,CAAOC,CAAP,gBAAkBhC,CAAlB,WAAkBA,CAAlB,QAAkBA,CAAY,CAAGgC,CAAH,CAA9B,CAFkB,CAG5BC,WAAW,CAAEd,CAHe,CAAD,CA3OqB,CA2O1Ce,CA3O0C,GA2O1CA,QA3O0C,CA8PlD,MAZArE,UAAS,CAAC,UAAM,CACVkB,CAAK,EAAI1B,OAAO,CAAC0B,CAAD,CADN,CAEZc,CAAc,CAACzC,OAAM,CAAC2B,CAAD,CAAQG,CAAR,CAAP,CAFF,CAGH,QAAAU,CAAW,WAAXA,CAAA,QAAAA,CAAW,CAAEgB,MAAb,IAAwB1B,CAAU,CAAC0B,MAHhC,EAQZf,CAAc,CAAC,EAAD,CAEjB,CAVQ,CAUN,QAACd,CAAD,WAACA,CAAD,QAACA,CAAK,CAAEmC,OAAP,EAAD,CAVM,CAYT,CAAO,CACLtB,WAAW,CAAXA,CADK,CAELsC,QAAQ,CAARA,CAFK,CAIR,CAlQM"}
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["addHours","addMinutes","addSeconds","format","isValid","isWithinInterval","parse","startOfDay","startOfHour","startOfMinute","IMask","useCallback","useEffect","useMemo","useState","useIMask","useMutableRef","leapYear","getLabelHours","getLabelMinutes","getLabelSeconds","datePickerPropFormatTypeDate","datePickerPropFormatTypeDateTime","datePickerPropSeparatorDefault","getParts","getPartsDate","getTimeEnum","datePickerErrorTypes","usePicker","props","value","onChange","onError","formatProp","separator","maxDate","minDate","multiplicityHours","multiplicityMinutes","multiplicitySeconds","onChangeRef","valueRef","onErrorRef","stringValue","setStringValue","stringValueRef","formatParts","handleChange","e","current","partsDate","dd","MM","yyyy","HH","mm","ss","filter","item","length","date","Date","start","end","type","getTime","options","mask","pattern","blocks","MaskedRange","from","to","MaskedEnum","lazy","autofix","string","validate","_val","params","maskOptions","inputRef","clearValue"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDateTime/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport {\n addHours,\n addMinutes,\n addSeconds,\n format,\n isValid,\n isWithinInterval,\n parse,\n startOfDay,\n startOfHour,\n startOfMinute,\n} from 'date-fns';\nimport IMask from 'imask';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { useIMask } from '##/components/TextField';\n\nimport { useMutableRef } from '../../../hooks/useMutableRef/useMutableRef';\nimport { leapYear } from '../../../utils/date';\nimport { PropsWithHTMLAttributes } from '../../../utils/types/PropsWithHTMLAttributes';\nimport {\n getLabelHours,\n getLabelMinutes,\n getLabelSeconds,\n} from '../../DateTime/helpers';\nimport {\n TextFieldPropForm,\n TextFieldPropSize,\n TextFieldPropStatus,\n TextFieldPropView,\n TextFieldPropWidth,\n} from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeDate,\n datePickerPropFormatTypeDateTime,\n datePickerPropSeparatorDefault,\n getParts,\n getPartsDate,\n getTimeEnum,\n} from '../helpers';\nimport { datePickerErrorTypes, DatePickerPropOnError } from '../types';\n\ntype DatePickerFieldTypeDateTimePropOnChange = (props: {\n e: Event;\n value: Date | null;\n}) => void;\n\nexport type DatePickerFieldTypeDateTimeProps = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: Date | null;\n onChange?: DatePickerFieldTypeDateTimePropOnChange;\n onError?: DatePickerPropOnError;\n id?: string;\n name?: string;\n disabled?: boolean;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n status?: TextFieldPropStatus;\n width?: TextFieldPropWidth;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n readOnly?: boolean;\n required?: boolean;\n tabIndex?: number;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n format?: string;\n separator?: string;\n minDate?: Date;\n maxDate?: Date;\n focused?: boolean;\n multiplicitySeconds?: number;\n multiplicityMinutes?: number;\n multiplicityHours?: number;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n withClearButton?: boolean;\n },\n HTMLDivElement\n>;\n\ntype UsePickerProps = {\n value?: Date | null;\n onChange?: DatePickerFieldTypeDateTimePropOnChange;\n onError?: DatePickerPropOnError;\n format: string;\n separator: string;\n minDate: Date;\n maxDate: Date;\n multiplicityHours: number | undefined;\n multiplicitySeconds: number | undefined;\n multiplicityMinutes: number | undefined;\n};\n\nexport const usePicker = (props: UsePickerProps) => {\n const {\n value,\n onChange,\n onError,\n format: formatProp,\n separator,\n maxDate,\n minDate,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n } = props;\n const onChangeRef = useMutableRef(onChange);\n const valueRef = useMutableRef(value);\n const onErrorRef = useMutableRef(onError);\n\n const [stringValue, setStringValue] = useState<string | null>(\n value && isValid(value) ? format(value, formatProp) : null,\n );\n const stringValueRef = useMutableRef(stringValue);\n\n const formatParts = useMemo(\n () => getParts(formatProp, separator, true),\n [formatProp, separator],\n );\n\n const handleChange = useCallback(\n ({ e, value: stringValue }: { e: Event; value: string | null }) => {\n if (stringValueRef.current === stringValue) {\n return;\n }\n\n setStringValue(stringValue);\n const onChange = onChangeRef.current;\n const value = valueRef.current;\n\n if (onChange) {\n if (!stringValue) {\n if (value) {\n onChange({ e, value: null });\n }\n return;\n }\n\n const partsDate = getPartsDate(\n stringValue,\n formatProp,\n separator,\n true,\n ['dd', 'MM', 'yyyy', 'HH', 'mm', 'ss'],\n );\n\n const [dd, MM, yyyy, HH, mm, ss] = partsDate;\n\n if (partsDate.filter((item) => !!item).length === formatParts.length) {\n const date = parse(\n `${dd}${datePickerPropSeparatorDefault}${MM}${datePickerPropSeparatorDefault}${yyyy} ${\n HH || '00'\n }:${mm || '00'}:${ss || '00'}`,\n datePickerPropFormatTypeDateTime,\n new Date(),\n );\n if (!isWithinInterval(date, { start: minDate, end: maxDate })) {\n onErrorRef.current?.({\n type: datePickerErrorTypes[0],\n stringValue,\n dd,\n MM,\n yyyy,\n date,\n HH,\n mm,\n ss,\n });\n\n if (value) {\n onChange({ e, value: null });\n }\n return;\n }\n onChange({ e, value: date });\n } else if (value) {\n onChange({ e, value: null });\n }\n }\n },\n [minDate?.getTime(), maxDate?.getTime(), formatProp, separator],\n );\n\n const options: IMask.InputMask<IMask.MaskedDateOptions> = useMemo(\n () =>\n ({\n mask: Date,\n pattern: formatProp,\n blocks: {\n yyyy: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 9999,\n },\n MM: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 12,\n },\n dd: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 31,\n },\n HH:\n multiplicityHours && multiplicityHours > 1\n ? {\n mask: IMask.MaskedEnum,\n enum: getTimeEnum(\n 24,\n multiplicityHours,\n startOfDay,\n addHours,\n getLabelHours,\n ),\n }\n : {\n mask: IMask.MaskedRange,\n from: 0,\n to: 23,\n },\n mm:\n multiplicityMinutes && multiplicityMinutes > 1\n ? {\n mask: IMask.MaskedEnum,\n enum: getTimeEnum(\n 60,\n multiplicityMinutes,\n startOfHour,\n addMinutes,\n getLabelMinutes,\n ),\n }\n : {\n mask: IMask.MaskedRange,\n from: 0,\n to: 59,\n },\n ss:\n multiplicitySeconds && multiplicitySeconds > 1\n ? {\n mask: IMask.MaskedEnum,\n enum: getTimeEnum(\n 60,\n multiplicitySeconds,\n startOfMinute,\n addSeconds,\n getLabelSeconds,\n ),\n }\n : {\n mask: IMask.MaskedRange,\n from: 0,\n to: 59,\n },\n },\n lazy: true,\n autofix: true,\n format: (date: Date) => format(date, formatProp),\n parse: (string: string) => parse(string, formatProp, new Date()),\n validate: (string: string) => {\n const [dd, MM, yyyy, HH, mm, ss] = getPartsDate(\n string,\n formatProp,\n separator,\n true,\n ['dd', 'MM', 'yyyy', 'HH', 'mm', 'ss'],\n );\n if (\n dd &&\n MM &&\n !isValid(\n parse(\n `${dd}${datePickerPropSeparatorDefault}${MM}${datePickerPropSeparatorDefault}${leapYear}`,\n datePickerPropFormatTypeDate,\n new Date(),\n ),\n )\n ) {\n onErrorRef.current?.({\n type: datePickerErrorTypes[1],\n stringValue: string,\n dd,\n MM,\n yyyy,\n HH,\n mm,\n ss,\n });\n return false;\n }\n if (\n dd &&\n MM &&\n yyyy &&\n !isValid(\n parse(\n `${dd}${datePickerPropSeparatorDefault}${MM}${datePickerPropSeparatorDefault}${yyyy}`,\n datePickerPropFormatTypeDate,\n new Date(),\n ),\n )\n ) {\n onErrorRef.current?.({\n type: datePickerErrorTypes[1],\n stringValue: string,\n dd,\n MM,\n yyyy,\n HH,\n mm,\n ss,\n });\n return false;\n }\n return true;\n },\n // проблема в типах IMask\n } as unknown as IMask.InputMask<IMask.MaskedDateOptions>),\n [\n formatProp,\n separator,\n multiplicityHours,\n multiplicitySeconds,\n multiplicityMinutes,\n ],\n );\n\n const { inputRef } = useIMask({\n value: stringValue,\n onChange: (_val, params) => handleChange?.(params),\n maskOptions: options,\n });\n\n const clearValue = (e: Event) => {\n setStringValue(null);\n onChange?.({ e, value: null });\n };\n\n // при изменении value, нужно обновить stringValue\n useEffect(() => {\n if (value && isValid(value)) {\n setStringValue(format(value, formatProp));\n } else if (stringValue?.length === formatProp.length) {\n // если количество введенных символов меньше чем в формате маски\n // то не нужно мешать вводу с клавиатуры\n // если дата была введена полностью и value пришел null,\n // то можно считать что поле нуждается в очистке\n setStringValue('');\n }\n }, [value?.getTime()]);\n\n return {\n stringValue,\n inputRef,\n clearValue,\n };\n};\n"],"mappings":"iEACA,OACEA,QADF,CAEEC,UAFF,CAGEC,UAHF,CAIEC,MAAM,GAANA,QAJF,CAKEC,OALF,CAMEC,gBANF,CAOEC,KAAK,GAALA,OAPF,CAQEC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CAADA,CAAF,CAAKlB,KAAK,CAAE,IAAZ,CAAH,CACT,CAeM,CAKR,CAxQM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","form","startFieldInputRef","startFieldLeftSide","startFieldRightSide","endFieldInputRef","endFieldLeftSide","endFieldRightSide","value","onChange","onError","disabled","size","view","status","autoFocus","placeholder","readOnly","required","tabIndex","ariaLabel","iconSize","format","separator","minDate","maxDate","startFieldOnBlur","startFieldOnFocus","endFieldOnBlur","endFieldOnFocus","startFieldRef","endFieldRef","startFocused","endFocused","label","labelPosition","caption","width","startFieldName","endFieldName","withClearButton"];import React,{forwardRef}from"react";import{FieldCaption}from"../../FieldCaption/FieldCaption";import{FieldLabel}from"../../FieldLabel/FieldLabel";import{DatePickerFieldTypeDateTime}from"../DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime";import{cnDatePickerMixRangeField}from"../DatePickerMixRangeField/DatePickerMixRangeField";import{getChangeFnRange}from"../getChangeFnRange";import{getFormForEnd,getFormForStart}from"../helpers";export var DatePickerFieldTypeDateTimeRange=forwardRef(function(a,b){var c=a.className,d=a.form,e=void 0===d?"default":d,f=a.startFieldInputRef,g=a.startFieldLeftSide,h=a.startFieldRightSide,i=a.endFieldInputRef,j=a.endFieldLeftSide,k=a.endFieldRightSide,l=a.value,m=void 0===l?[]:l,n=a.onChange,o=a.onError,p=a.disabled,q=a.size,r=a.view,s=a.status,t=a.autoFocus,u=a.placeholder,v=a.readOnly,w=a.required,x=a.tabIndex,y=a.ariaLabel,z=a.iconSize,A=a.format,B=a.separator,C=a.minDate,D=a.maxDate,E=a.startFieldOnBlur,F=a.startFieldOnFocus,G=a.endFieldOnBlur,H=a.endFieldOnFocus,I=a.startFieldRef,J=a.endFieldRef,K=a.startFocused,L=a.endFocused,M=a.label,N=a.
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","form","startFieldInputRef","startFieldLeftSide","startFieldRightSide","endFieldInputRef","endFieldLeftSide","endFieldRightSide","value","onChange","onError","disabled","size","view","status","autoFocus","placeholder","readOnly","required","tabIndex","ariaLabel","iconSize","format","separator","minDate","maxDate","startFieldOnBlur","startFieldOnFocus","endFieldOnBlur","endFieldOnFocus","startFieldRef","endFieldRef","startFocused","endFocused","label","labelIcon","labelPosition","caption","width","startFieldName","endFieldName","withClearButton"];import React,{forwardRef}from"react";import{FieldCaption}from"../../FieldCaption/FieldCaption";import{FieldLabel}from"../../FieldLabel/FieldLabel";import{DatePickerFieldTypeDateTime}from"../DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime";import{cnDatePickerMixRangeField}from"../DatePickerMixRangeField/DatePickerMixRangeField";import{getChangeFnRange}from"../getChangeFnRange";import{getFormForEnd,getFormForStart}from"../helpers";export var DatePickerFieldTypeDateTimeRange=forwardRef(function(a,b){var c=a.className,d=a.form,e=void 0===d?"default":d,f=a.startFieldInputRef,g=a.startFieldLeftSide,h=a.startFieldRightSide,i=a.endFieldInputRef,j=a.endFieldLeftSide,k=a.endFieldRightSide,l=a.value,m=void 0===l?[]:l,n=a.onChange,o=a.onError,p=a.disabled,q=a.size,r=a.view,s=a.status,t=a.autoFocus,u=a.placeholder,v=a.readOnly,w=a.required,x=a.tabIndex,y=a.ariaLabel,z=a.iconSize,A=a.format,B=a.separator,C=a.minDate,D=a.maxDate,E=a.startFieldOnBlur,F=a.startFieldOnFocus,G=a.endFieldOnBlur,H=a.endFieldOnFocus,I=a.startFieldRef,J=a.endFieldRef,K=a.startFocused,L=a.endFocused,M=a.label,N=a.labelIcon,O=a.labelPosition,P=a.caption,Q=a.width,R=a.startFieldName,S=a.endFieldName,T=a.withClearButton,U=_objectWithoutProperties(a,_excluded),V={className:cnDatePickerMixRangeField("Field"),disabled:p,onError:o,size:q,view:r,status:s,placeholder:u,readOnly:v,required:w,tabIndex:x,ariaLabel:y,iconSize:z,format:A,separator:B,minDate:C,maxDate:D,withClearButton:T},W=getChangeFnRange(n,o,m),X=_slicedToArray(W,2),Y=X[0],Z=X[1];return React.createElement("div",Object.assign({},U,{className:cnDatePickerMixRangeField({view:r,labelPosition:O,width:Q,size:q},[c]),ref:b}),M&&React.createElement(FieldLabel,{icon:N,required:w,className:cnDatePickerMixRangeField("Label",{labelPosition:O}),size:q},M),React.createElement("div",{className:cnDatePickerMixRangeField("Body")},React.createElement("div",{className:cnDatePickerMixRangeField("Fields")},React.createElement(DatePickerFieldTypeDateTime,Object.assign({},V,{inputRef:f,ref:I,leftSide:g,rightSide:h,form:getFormForStart(e),value:null===m||void 0===m?void 0:m[0],onChange:Y,onFocus:F,onBlur:E,focused:K,autoFocus:t,name:R})),React.createElement(DatePickerFieldTypeDateTime,Object.assign({},V,{inputRef:i,ref:J,leftSide:j,rightSide:k,form:getFormForEnd(e),value:null===m||void 0===m?void 0:m[1],onChange:Z,onFocus:H,onBlur:G,focused:L,name:S}))),P&&React.createElement(FieldCaption,{className:cnDatePickerMixRangeField("Caption"),status:s},P)))});
|
|
2
2
|
//# sourceMappingURL=DatePickerFieldTypeDateTimeRange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerFieldTypeDateTimeRange.js","names":["React","forwardRef","FieldCaption","FieldLabel","DatePickerFieldTypeDateTime","cnDatePickerMixRangeField","getChangeFnRange","getFormForEnd","getFormForStart","DatePickerFieldTypeDateTimeRange","props","ref","className","form","startFieldInputRef","startFieldLeftSide","startFieldRightSide","endFieldInputRef","endFieldLeftSide","endFieldRightSide","value","onChange","onError","disabled","size","view","status","autoFocus","placeholder","readOnly","required","tabIndex","ariaLabel","iconSize","format","separator","minDate","maxDate","startFieldOnBlur","startFieldOnFocus","endFieldOnBlur","endFieldOnFocus","startFieldRef","endFieldRef","startFocused","endFocused","label","labelPosition","caption","width","startFieldName","endFieldName","withClearButton","otherProps","commonProps","handleStartDateChange","handleEndDateChange"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { FieldCaption } from '../../FieldCaption/FieldCaption';\nimport { FieldLabel } from '../../FieldLabel/FieldLabel';\nimport { DatePickerFieldTypeDateTime } from '../DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime';\nimport { cnDatePickerMixRangeField } from '../DatePickerMixRangeField/DatePickerMixRangeField';\nimport { getChangeFnRange } from '../getChangeFnRange';\nimport { getFormForEnd, getFormForStart } from '../helpers';\nimport { DatePickerFieldTypeDateTimeRangeProps } from './helpers';\n\nexport const DatePickerFieldTypeDateTimeRange = forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeDateTimeRangeProps\n>((props, ref) => {\n const {\n className,\n form = 'default',\n startFieldInputRef,\n startFieldLeftSide,\n startFieldRightSide,\n endFieldInputRef,\n endFieldLeftSide,\n endFieldRightSide,\n value = [],\n onChange,\n onError,\n disabled,\n size,\n view,\n status,\n autoFocus,\n placeholder,\n readOnly,\n required,\n tabIndex,\n ariaLabel,\n iconSize,\n format,\n separator,\n minDate,\n maxDate,\n startFieldOnBlur,\n startFieldOnFocus,\n endFieldOnBlur,\n endFieldOnFocus,\n startFieldRef,\n endFieldRef,\n startFocused,\n endFocused,\n label,\n labelPosition,\n caption,\n width,\n startFieldName,\n endFieldName,\n withClearButton,\n ...otherProps\n } = props;\n\n const commonProps = {\n className: cnDatePickerMixRangeField('Field'),\n disabled,\n onError,\n size,\n view,\n status,\n placeholder,\n readOnly,\n required,\n tabIndex,\n ariaLabel,\n iconSize,\n format,\n separator,\n minDate,\n maxDate,\n withClearButton,\n };\n\n const [handleStartDateChange, handleEndDateChange] = getChangeFnRange(\n onChange,\n onError,\n value,\n );\n\n return (\n <div\n {...otherProps}\n className={cnDatePickerMixRangeField(\n { view, labelPosition, width, size },\n [className],\n )}\n ref={ref}\n >\n {label && (\n <FieldLabel\n required={required}\n className={cnDatePickerMixRangeField('Label', { labelPosition })}\n size={size}\n >\n {label}\n </FieldLabel>\n )}\n <div className={cnDatePickerMixRangeField('Body')}>\n <div className={cnDatePickerMixRangeField('Fields')}>\n <DatePickerFieldTypeDateTime\n {...commonProps}\n inputRef={startFieldInputRef}\n ref={startFieldRef}\n leftSide={startFieldLeftSide}\n rightSide={startFieldRightSide}\n form={getFormForStart(form)}\n value={value?.[0]}\n onChange={handleStartDateChange}\n onFocus={startFieldOnFocus}\n onBlur={startFieldOnBlur}\n focused={startFocused}\n autoFocus={autoFocus}\n name={startFieldName}\n />\n <DatePickerFieldTypeDateTime\n {...commonProps}\n inputRef={endFieldInputRef}\n ref={endFieldRef}\n leftSide={endFieldLeftSide}\n rightSide={endFieldRightSide}\n form={getFormForEnd(form)}\n value={value?.[1]}\n onChange={handleEndDateChange}\n onFocus={endFieldOnFocus}\n onBlur={endFieldOnBlur}\n focused={endFocused}\n name={endFieldName}\n />\n </div>\n {caption && (\n <FieldCaption\n className={cnDatePickerMixRangeField('Caption')}\n status={status}\n >\n {caption}\n </FieldCaption>\n )}\n </div>\n </div>\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatePickerFieldTypeDateTimeRange.js","names":["React","forwardRef","FieldCaption","FieldLabel","DatePickerFieldTypeDateTime","cnDatePickerMixRangeField","getChangeFnRange","getFormForEnd","getFormForStart","DatePickerFieldTypeDateTimeRange","props","ref","className","form","startFieldInputRef","startFieldLeftSide","startFieldRightSide","endFieldInputRef","endFieldLeftSide","endFieldRightSide","value","onChange","onError","disabled","size","view","status","autoFocus","placeholder","readOnly","required","tabIndex","ariaLabel","iconSize","format","separator","minDate","maxDate","startFieldOnBlur","startFieldOnFocus","endFieldOnBlur","endFieldOnFocus","startFieldRef","endFieldRef","startFocused","endFocused","label","labelIcon","labelPosition","caption","width","startFieldName","endFieldName","withClearButton","otherProps","commonProps","handleStartDateChange","handleEndDateChange"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeDateTimeRange/DatePickerFieldTypeDateTimeRange.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { FieldCaption } from '../../FieldCaption/FieldCaption';\nimport { FieldLabel } from '../../FieldLabel/FieldLabel';\nimport { DatePickerFieldTypeDateTime } from '../DatePickerFieldTypeDateTime/DatePickerFieldTypeDateTime';\nimport { cnDatePickerMixRangeField } from '../DatePickerMixRangeField/DatePickerMixRangeField';\nimport { getChangeFnRange } from '../getChangeFnRange';\nimport { getFormForEnd, getFormForStart } from '../helpers';\nimport { DatePickerFieldTypeDateTimeRangeProps } from './helpers';\n\nexport const DatePickerFieldTypeDateTimeRange = forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeDateTimeRangeProps\n>((props, ref) => {\n const {\n className,\n form = 'default',\n startFieldInputRef,\n startFieldLeftSide,\n startFieldRightSide,\n endFieldInputRef,\n endFieldLeftSide,\n endFieldRightSide,\n value = [],\n onChange,\n onError,\n disabled,\n size,\n view,\n status,\n autoFocus,\n placeholder,\n readOnly,\n required,\n tabIndex,\n ariaLabel,\n iconSize,\n format,\n separator,\n minDate,\n maxDate,\n startFieldOnBlur,\n startFieldOnFocus,\n endFieldOnBlur,\n endFieldOnFocus,\n startFieldRef,\n endFieldRef,\n startFocused,\n endFocused,\n label,\n labelIcon,\n labelPosition,\n caption,\n width,\n startFieldName,\n endFieldName,\n withClearButton,\n ...otherProps\n } = props;\n\n const commonProps = {\n className: cnDatePickerMixRangeField('Field'),\n disabled,\n onError,\n size,\n view,\n status,\n placeholder,\n readOnly,\n required,\n tabIndex,\n ariaLabel,\n iconSize,\n format,\n separator,\n minDate,\n maxDate,\n withClearButton,\n };\n\n const [handleStartDateChange, handleEndDateChange] = getChangeFnRange(\n onChange,\n onError,\n value,\n );\n\n return (\n <div\n {...otherProps}\n className={cnDatePickerMixRangeField(\n { view, labelPosition, width, size },\n [className],\n )}\n ref={ref}\n >\n {label && (\n <FieldLabel\n icon={labelIcon}\n required={required}\n className={cnDatePickerMixRangeField('Label', { labelPosition })}\n size={size}\n >\n {label}\n </FieldLabel>\n )}\n <div className={cnDatePickerMixRangeField('Body')}>\n <div className={cnDatePickerMixRangeField('Fields')}>\n <DatePickerFieldTypeDateTime\n {...commonProps}\n inputRef={startFieldInputRef}\n ref={startFieldRef}\n leftSide={startFieldLeftSide}\n rightSide={startFieldRightSide}\n form={getFormForStart(form)}\n value={value?.[0]}\n onChange={handleStartDateChange}\n onFocus={startFieldOnFocus}\n onBlur={startFieldOnBlur}\n focused={startFocused}\n autoFocus={autoFocus}\n name={startFieldName}\n />\n <DatePickerFieldTypeDateTime\n {...commonProps}\n inputRef={endFieldInputRef}\n ref={endFieldRef}\n leftSide={endFieldLeftSide}\n rightSide={endFieldRightSide}\n form={getFormForEnd(form)}\n value={value?.[1]}\n onChange={handleEndDateChange}\n onFocus={endFieldOnFocus}\n onBlur={endFieldOnBlur}\n focused={endFocused}\n name={endFieldName}\n />\n </div>\n {caption && (\n <FieldCaption\n className={cnDatePickerMixRangeField('Caption')}\n status={status}\n >\n {caption}\n </FieldCaption>\n )}\n </div>\n </div>\n );\n});\n"],"mappings":"ytBAAA,MAAOA,MAAP,EAAgBC,UAAhB,KAAkC,OAAlC,CAEA,OAASC,YAAT,uCACA,OAASC,UAAT,mCACA,OAASC,2BAAT,kEACA,OAASC,yBAAT,0DACA,OAASC,gBAAT,2BACA,OAASC,aAAT,CAAwBC,eAAxB,kBAGA,MAAO,IAAMC,iCAAgC,CAAGR,UAAU,CAGxD,SAACS,CAAD,CAAQC,CAAR,CAAgB,IAEdC,EAFc,CA6CZF,CA7CY,CAEdE,SAFc,GA6CZF,CA7CY,CAGdG,IAHc,CAGdA,CAHc,YAGP,SAHO,GAIdC,CAJc,CA6CZJ,CA7CY,CAIdI,kBAJc,CAKdC,CALc,CA6CZL,CA7CY,CAKdK,kBALc,CAMdC,CANc,CA6CZN,CA7CY,CAMdM,mBANc,CAOdC,CAPc,C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CARZ,CASE,OAAO,CAAEhB,CATX,CAUE,MAAM,CAAED,CAVV,CAWE,OAAO,CAAEK,CAXX,CAYE,IAAI,CAAEO,CAZR,GAhBF,CADF,CAgCGH,CAAO,EACN,oBAAC,YAAD,EACE,SAAS,CAAE5C,yBAAyB,CAAC,SAAD,CADtC,CAEE,MAAM,CAAEqB,CAFV,EAIGuB,CAJH,CAjCJ,CAlBF,CA6DH,CA1IyD,CAAnD"}
|
|
@@ -12,7 +12,7 @@ export declare const DatePickerFieldTypeMonth: React.ForwardRefExoticComponent<{
|
|
|
12
12
|
disabled?: boolean | undefined;
|
|
13
13
|
size?: "m" | "s" | "xs" | "l" | undefined;
|
|
14
14
|
view?: "default" | "clear" | undefined;
|
|
15
|
-
form?: "default" | "round" | "
|
|
15
|
+
form?: "default" | "round" | "defaultClear" | "defaultBrick" | "brick" | "brickDefault" | "brickClear" | "brickRound" | "roundClear" | "roundBrick" | "clearRound" | "clearDefault" | "clearBrick" | "clearClear" | undefined;
|
|
16
16
|
status?: "alert" | "warning" | "success" | undefined;
|
|
17
17
|
width?: "default" | "full" | undefined;
|
|
18
18
|
onFocus?: React.FocusEventHandler<HTMLElement> | undefined;
|
|
@@ -34,7 +34,8 @@ export declare const DatePickerFieldTypeMonth: React.ForwardRefExoticComponent<{
|
|
|
34
34
|
maxDate?: Date | undefined;
|
|
35
35
|
focused?: boolean | undefined;
|
|
36
36
|
label?: string | undefined;
|
|
37
|
+
labelIcon?: import("@consta/icons/Icon").IconComponent | undefined;
|
|
37
38
|
caption?: string | undefined;
|
|
38
39
|
labelPosition?: "left" | "top" | undefined;
|
|
39
40
|
withClearButton?: boolean | undefined;
|
|
40
|
-
} & Omit<React.HTMLAttributes<HTMLDivElement>, "css" | "className" | "id" | "placeholder" | "tabIndex" | "children" | "onFocus" | "onBlur" | "onChange" | "onError" | "size" | "caption" | "form" | "label" | "view" | "separator" | "status" | "name" | "width" | "format" | "autoFocus" | "disabled" | "value" | "readOnly" | "required" | "inputRef" | "focused" | "ariaLabel" | "labelPosition" | "leftSide" | "rightSide" | "withClearButton" | "iconSize" | "minDate" | "maxDate"> & React.RefAttributes<HTMLDivElement>>;
|
|
41
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "css" | "className" | "id" | "placeholder" | "tabIndex" | "children" | "onFocus" | "onBlur" | "onChange" | "onError" | "size" | "caption" | "form" | "label" | "view" | "separator" | "status" | "name" | "width" | "format" | "autoFocus" | "disabled" | "value" | "readOnly" | "required" | "inputRef" | "focused" | "ariaLabel" | "labelIcon" | "labelPosition" | "leftSide" | "rightSide" | "withClearButton" | "iconSize" | "minDate" | "maxDate"> & React.RefAttributes<HTMLDivElement>>;
|
package/__internal__/src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef"];import React from"react";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{TextField}from"../../TextField/TextField";import{datePickerPropFormatTypeMonth,datePickerPropPlaceholderTypeMonth,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeMonth=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeMonth:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeMonth:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=_objectWithoutProperties(a,_excluded),r=usePicker({value:o,format:d,separator:f,minDate:l,maxDate:n,onChange:i,onError:j}),s=r.stringValue,t=r.inputRef;return React.createElement(TextField,Object.assign({},q,{type:"text",inputContainerRef:b,inputRef:useForkRef([t,p]),value:s,placeholder:h}))});
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef"];import React from"react";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{TextField}from"../../TextField/TextField";import{datePickerPropFormatTypeMonth,datePickerPropPlaceholderTypeMonth,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeMonth=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeMonth:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeMonth:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=_objectWithoutProperties(a,_excluded),r=usePicker({value:o,format:d,separator:f,minDate:l,maxDate:n,onChange:i,onError:j}),s=r.stringValue,t=r.inputRef,u=r.clearValue;return React.createElement(TextField,Object.assign({},q,{type:"text",onChange:function(a){var b=a.e,c=a.value;return null===c&&u(b.nativeEvent)},inputContainerRef:b,inputRef:useForkRef([t,p]),value:s,placeholder:h}))});
|
|
2
2
|
//# sourceMappingURL=DatePickerFieldTypeMonth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerFieldTypeMonth.js","names":["React","useForkRef","maxDateDefault","minDateDefault","TextField","datePickerPropFormatTypeMonth","datePickerPropPlaceholderTypeMonth","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeMonth","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","otherProps","stringValue"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { maxDateDefault, minDateDefault } from '../../../utils/date';\nimport { TextField } from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeMonth,\n datePickerPropPlaceholderTypeMonth,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeMonthProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeMonth = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeMonthProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeMonth,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeMonth,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n ...otherProps\n } = props;\n\n const { stringValue, inputRef } = usePicker({\n value,\n format,\n separator,\n minDate,\n maxDate,\n onChange,\n onError,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n value={stringValue}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"oMAAA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,UAAT,4CACA,OAASC,cAAT,CAAyBC,cAAzB,2BACA,OAASC,SAAT,iCACA,OACEC,6BADF,CAEEC,kCAFF,CAGEC,8BAHF,kBAKA,OAAwCC,SAAxC,iBAEA,MAAO,IAAMC,yBAAwB,CAAGT,KAAK,CAACU,UAAN,CAGtC,SAACC,CAAD,CAAQC,CAAR,CAAgB,OAYZD,CAZY,CAEdE,MAFc,CAEdA,CAFc,YAELR,6BAFK,KAYZM,CAZY,CAGdG,SAHc,CAGdA,CAHc,YAGFP,8BAHE,KAYZI,CAZY,CAIdI,WAJc,CAIdA,CAJc,YAIAT,kCAJA,GAKdU,CALc,CAYZL,CAZY,CAKdK,QALc,CAMdC,CANc,CAYZN,CAZY,CAMdM,OANc,GAYZN,CAZY,CAOdO,OAPc,CAOdA,CAPc,YAOJf,cAPI,KAYZQ,CAZY,CAQdQ,OARc,CAQdA,CARc,YAQJjB,cARI,GASdkB,CATc,CAYZT,CAZY,CASdS,KATc,CAUJC,CAVI,CAYZV,CAZY,CAUdW,QAVc,CAWXC,CAXW,0BAYZZ,CAZY,
|
|
1
|
+
{"version":3,"file":"DatePickerFieldTypeMonth.js","names":["React","useForkRef","maxDateDefault","minDateDefault","TextField","datePickerPropFormatTypeMonth","datePickerPropPlaceholderTypeMonth","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeMonth","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","otherProps","stringValue","clearValue","e","nativeEvent"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeMonth/DatePickerFieldTypeMonth.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { maxDateDefault, minDateDefault } from '../../../utils/date';\nimport { TextField } from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeMonth,\n datePickerPropPlaceholderTypeMonth,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeMonthProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeMonth = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeMonthProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeMonth,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeMonth,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n ...otherProps\n } = props;\n\n const { stringValue, inputRef, clearValue } = usePicker({\n value,\n format,\n separator,\n minDate,\n maxDate,\n onChange,\n onError,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n onChange={({ e, value }) => value === null && clearValue(e.nativeEvent)}\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n value={stringValue}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"oMAAA,MAAOA,MAAP,KAAkB,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B,CAKE,QAAQ,CAAEX,UAAU,CAAC,CAACqB,CAAD,CAAWD,CAAX,CAAD,CALtB,CAME,KAAK,CAAEG,CANT,CAOE,WAAW,CAAET,CAPf,GAUH,CAtCuC,CAAjC"}
|
|
@@ -39,6 +39,7 @@ export declare type DatePickerFieldTypeMonthProps = PropsWithHTMLAttributes<{
|
|
|
39
39
|
maxDate?: Date;
|
|
40
40
|
focused?: boolean;
|
|
41
41
|
label?: string;
|
|
42
|
+
labelIcon?: IconComponent;
|
|
42
43
|
caption?: string;
|
|
43
44
|
labelPosition?: 'top' | 'left';
|
|
44
45
|
withClearButton?: boolean;
|
|
@@ -55,5 +56,6 @@ declare type UsePickerProps = {
|
|
|
55
56
|
export declare const usePicker: (props: UsePickerProps) => {
|
|
56
57
|
stringValue: string | null;
|
|
57
58
|
inputRef: import("react").RefObject<HTMLInputElement>;
|
|
59
|
+
clearValue: (e: Event) => void;
|
|
58
60
|
};
|
|
59
61
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{format as _format,isValid,isWithinInterval,parse as _parse}from"date-fns";import IMask from"imask";import{useCallback,useEffect,useMemo,useState}from"react";import{useIMask}from"../../TextField";import{useMutableRef}from"../../../hooks/useMutableRef/useMutableRef";import{datePickerPropFormatTypeMonth,datePickerPropSeparatorDefault,getPartsDate}from"../helpers";import{datePickerErrorTypes}from"../types";export var usePicker=function(a){var b=a.value,c=a.onChange,d=a.onError,f=a.format,g=a.separator,h=a.maxDate,i=a.minDate,j=useMutableRef(c),k=useMutableRef(b),l=useMutableRef(d),m=useState(b&&isValid(b)?_format(b,f):null),n=_slicedToArray(m,2),o=n[0],p=n[1],q=useMutableRef(o),r=useCallback(function(a){var b=a.e,c=a.value;if(q.current!==c){p(c);var d=j.current,e=k.current;if(d){if(!c)return void(e&&d({e:b,value:null}));var m=getPartsDate(c,f,g,!1,["MM","yyyy"]),n=_slicedToArray(m,2),o=n[0],r=n[1];if(o&&r){var t=_parse("".concat(o).concat(datePickerPropSeparatorDefault).concat(r),datePickerPropFormatTypeMonth,new Date);if(!isWithinInterval(t,{start:i,end:h})){var s;return null===(s=l.current)||void 0===s?void 0:s.call(l,{type:datePickerErrorTypes[0],stringValue:c,MM:o,yyyy:r,date:t}),void(e&&d({e:b,value:null}))}d({e:b,value:t})}else e&&d({e:b,value:null})}}},[null===i||void 0===i?void 0:i.getTime(),null===h||void 0===h?void 0:h.getTime(),f,g]),s=useMemo(function(){return{mask:Date,pattern:f,blocks:{yyyy:{mask:IMask.MaskedRange,from:1,to:9999},MM:{mask:IMask.MaskedRange,from:1,to:12}},lazy:!0,autofix:!0,format:function format(a){return _format(a,f)},parse:function parse(a){return _parse(a,f,new Date)},validate:function validate(a){var b=getPartsDate(a,f,g,!1,["MM","yyyy"]),c=_slicedToArray(b,2),e=c[0],h=c[1];if(e&&h&&!isValid(_parse("".concat(e).concat(datePickerPropSeparatorDefault).concat(h),datePickerPropFormatTypeMonth,new Date))){var i;return d&&(null===(i=l.current)||void 0===i?void 0:i.call(l,{type:datePickerErrorTypes[1],stringValue:a,MM:e,yyyy:h})),!1}return!0}}},[f,g]),t=useIMask({value:o,onChange:function(a,b){return null===r||void 0===r?void 0:r(b)},maskOptions:s}),u=t.inputRef;return useEffect(function(){b&&isValid(b)?p(_format(b,f)):(null===o||void 0===o?void 0:o.length)===f.length&&p("")},[null===b||void 0===b?void 0:b.getTime()]),{stringValue:o,inputRef:u}};
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{format as _format,isValid,isWithinInterval,parse as _parse}from"date-fns";import IMask from"imask";import{useCallback,useEffect,useMemo,useState}from"react";import{useIMask}from"../../TextField";import{useMutableRef}from"../../../hooks/useMutableRef/useMutableRef";import{datePickerPropFormatTypeMonth,datePickerPropSeparatorDefault,getPartsDate}from"../helpers";import{datePickerErrorTypes}from"../types";export var usePicker=function(a){var b=a.value,c=a.onChange,d=a.onError,f=a.format,g=a.separator,h=a.maxDate,i=a.minDate,j=useMutableRef(c),k=useMutableRef(b),l=useMutableRef(d),m=useState(b&&isValid(b)?_format(b,f):null),n=_slicedToArray(m,2),o=n[0],p=n[1],q=useMutableRef(o),r=useCallback(function(a){var b=a.e,c=a.value;if(q.current!==c){p(c);var d=j.current,e=k.current;if(d){if(!c)return void(e&&d({e:b,value:null}));var m=getPartsDate(c,f,g,!1,["MM","yyyy"]),n=_slicedToArray(m,2),o=n[0],r=n[1];if(o&&r){var t=_parse("".concat(o).concat(datePickerPropSeparatorDefault).concat(r),datePickerPropFormatTypeMonth,new Date);if(!isWithinInterval(t,{start:i,end:h})){var s;return null===(s=l.current)||void 0===s?void 0:s.call(l,{type:datePickerErrorTypes[0],stringValue:c,MM:o,yyyy:r,date:t}),void(e&&d({e:b,value:null}))}d({e:b,value:t})}else e&&d({e:b,value:null})}}},[null===i||void 0===i?void 0:i.getTime(),null===h||void 0===h?void 0:h.getTime(),f,g]),s=useMemo(function(){return{mask:Date,pattern:f,blocks:{yyyy:{mask:IMask.MaskedRange,from:1,to:9999},MM:{mask:IMask.MaskedRange,from:1,to:12}},lazy:!0,autofix:!0,format:function format(a){return _format(a,f)},parse:function parse(a){return _parse(a,f,new Date)},validate:function validate(a){var b=getPartsDate(a,f,g,!1,["MM","yyyy"]),c=_slicedToArray(b,2),e=c[0],h=c[1];if(e&&h&&!isValid(_parse("".concat(e).concat(datePickerPropSeparatorDefault).concat(h),datePickerPropFormatTypeMonth,new Date))){var i;return d&&(null===(i=l.current)||void 0===i?void 0:i.call(l,{type:datePickerErrorTypes[1],stringValue:a,MM:e,yyyy:h})),!1}return!0}}},[f,g]),t=useIMask({value:o,onChange:function(a,b){return null===r||void 0===r?void 0:r(b)},maskOptions:s}),u=t.inputRef;return useEffect(function(){b&&isValid(b)?p(_format(b,f)):(null===o||void 0===o?void 0:o.length)===f.length&&p("")},[null===b||void 0===b?void 0:b.getTime()]),{stringValue:o,inputRef:u,clearValue:function clearValue(a){p(null),null===c||void 0===c?void 0:c({e:a,value:null})}}};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["format","isValid","isWithinInterval","parse","IMask","useCallback","useEffect","useMemo","useState","useIMask","useMutableRef","datePickerPropFormatTypeMonth","datePickerPropSeparatorDefault","getPartsDate","datePickerErrorTypes","usePicker","props","value","onChange","onError","formatProp","separator","maxDate","minDate","onChangeRef","valueRef","onErrorRef","stringValue","setStringValue","stringValueRef","handleChange","e","current","MM","yyyy","date","Date","start","end","type","getTime","options","mask","pattern","blocks","MaskedRange","from","to","lazy","autofix","string","validate","_val","params","maskOptions","inputRef","length"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeMonth/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { format, isValid, isWithinInterval, parse } from 'date-fns';\nimport IMask from 'imask';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { useIMask } from '##/components/TextField';\n\nimport { useMutableRef } from '../../../hooks/useMutableRef/useMutableRef';\nimport { PropsWithHTMLAttributes } from '../../../utils/types/PropsWithHTMLAttributes';\nimport {\n TextFieldPropForm,\n TextFieldPropSize,\n TextFieldPropStatus,\n TextFieldPropView,\n TextFieldPropWidth,\n} from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeMonth,\n datePickerPropSeparatorDefault,\n getPartsDate,\n} from '../helpers';\nimport { datePickerErrorTypes, DatePickerPropOnError } from '../types';\n\ntype DatePickerFieldTypeMonthPropOnChange = (props: {\n e: Event;\n value: Date | null;\n}) => void;\n\nexport type DatePickerFieldTypeMonthProps = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: Date | null;\n onChange?: DatePickerFieldTypeMonthPropOnChange;\n onError?: DatePickerPropOnError;\n id?: string;\n name?: string;\n disabled?: boolean;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n status?: TextFieldPropStatus;\n width?: TextFieldPropWidth;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n readOnly?: boolean;\n required?: boolean;\n tabIndex?: number;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n format?: string;\n separator?: string;\n minDate?: Date;\n maxDate?: Date;\n focused?: boolean;\n label?: string;\n caption?: string;\n labelPosition?: 'top' | 'left';\n withClearButton?: boolean;\n },\n HTMLDivElement\n>;\n\ntype UsePickerProps = {\n value?: Date | null;\n onChange?: DatePickerFieldTypeMonthPropOnChange;\n onError?: DatePickerPropOnError;\n format: string;\n separator: string;\n minDate: Date;\n maxDate: Date;\n};\n\nexport const usePicker = (props: UsePickerProps) => {\n const {\n value,\n onChange,\n onError,\n format: formatProp,\n separator,\n maxDate,\n minDate,\n } = props;\n const onChangeRef = useMutableRef(onChange);\n const valueRef = useMutableRef(value);\n const onErrorRef = useMutableRef(onError);\n\n const [stringValue, setStringValue] = useState<string | null>(\n value && isValid(value) ? format(value, formatProp) : null,\n );\n const stringValueRef = useMutableRef(stringValue);\n\n const handleChange = useCallback(\n ({ e, value: stringValue }: { e: Event; value: string | null }) => {\n if (stringValueRef.current === stringValue) {\n return;\n }\n setStringValue(stringValue);\n const onChange = onChangeRef.current;\n const value = valueRef.current;\n if (onChange) {\n if (!stringValue) {\n if (value) {\n onChange({ e, value: null });\n }\n return;\n }\n const [MM, yyyy] = getPartsDate(\n stringValue,\n formatProp,\n separator,\n false,\n ['MM', 'yyyy'],\n );\n if (MM && yyyy) {\n const date = parse(\n `${MM}${datePickerPropSeparatorDefault}${yyyy}`,\n datePickerPropFormatTypeMonth,\n new Date(),\n );\n if (!isWithinInterval(date, { start: minDate, end: maxDate })) {\n onErrorRef.current?.({\n type: datePickerErrorTypes[0],\n stringValue,\n MM,\n yyyy,\n date,\n });\n if (value) {\n onChange({ e, value: null });\n }\n return;\n }\n onChange({ e, value: date });\n } else if (value) {\n onChange({ e, value: null });\n }\n }\n },\n [minDate?.getTime(), maxDate?.getTime(), formatProp, separator],\n );\n\n const options: IMask.InputMask<IMask.MaskedDateOptions> = useMemo(\n () =>\n ({\n mask: Date,\n pattern: formatProp,\n blocks: {\n yyyy: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 9999,\n },\n MM: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 12,\n },\n },\n lazy: true,\n autofix: true,\n format: (date: Date) => format(date, formatProp),\n parse: (string: string) => parse(string, formatProp, new Date()),\n validate: (string: string) => {\n const [MM, yyyy] = getPartsDate(\n string,\n formatProp,\n separator,\n false,\n ['MM', 'yyyy'],\n );\n if (\n MM &&\n yyyy &&\n !isValid(\n parse(\n `${MM}${datePickerPropSeparatorDefault}${yyyy}`,\n datePickerPropFormatTypeMonth,\n new Date(),\n ),\n )\n ) {\n onError &&\n onErrorRef.current?.({\n type: datePickerErrorTypes[1],\n stringValue: string,\n MM,\n yyyy,\n });\n\n return false;\n }\n return true;\n },\n // проблема в типах IMask\n } as unknown as IMask.InputMask<IMask.MaskedDateOptions>),\n [formatProp, separator],\n );\n\n const { inputRef } = useIMask({\n value: stringValue,\n onChange: (_val, params) => handleChange?.(params),\n maskOptions: options,\n });\n\n // при изменении value, нужно обновить stringValue\n useEffect(() => {\n if (value && isValid(value)) {\n setStringValue(format(value, formatProp));\n } else if (stringValue?.length === formatProp.length) {\n // если количество введенных символов меньше чем в формате маски\n // то не нужно мешать вводу с клавиатуры\n // если дата была введена полностью и value пришел null,\n // то можно считать что поле нуждается в очистке\n setStringValue('');\n }\n }, [value?.getTime()]);\n\n return {\n stringValue,\n inputRef,\n };\n};\n"],"mappings":"iEACA,OAASA,MAAM,GAANA,QAAT,CAAiBC,OAAjB,CAA0BC,gBAA1B,CAA4CC,KAAK,GAALA,OAA5C,KAAyD,UAAzD,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,QACD,CAjDF,CADH,CAD+D,CAsD/D,CAACd,CAAD,CAAaC,CAAb,CAtD+D,CArEf,GA8H7BZ,QAAQ,CAAC,CAC5BQ,KAAK,CAAEU,CADqB,CAE5BT,QAAQ,CAAE,SAACkC,CAAD,CAAOC,CAAP,gBAAkBvB,CAAlB,WAAkBA,CAAlB,QAAkBA,CAAY,CAAGuB,CAAH,CAA9B,CAFkB,CAG5BC,WAAW,CAAEb,CAHe,CAAD,CA9HqB,CA8H1Cc,CA9H0C,GA8H1CA,QA9H0C,CAiJlD,MAZAjD,UAAS,CAAC,UAAM,CACVW,CAAK,EAAIhB,OAAO,CAACgB,CAAD,CADN,CAEZW,CAAc,CAAC5B,OAAM,CAACiB,CAAD,CAAQG,CAAR,CAAP,CAFF,CAGH,QAAAO,CAAW,WAAXA,CAAA,QAAAA,CAAW,CAAE6B,MAAb,IAAwBpC,CAAU,CAACoC,MAHhC,EAQZ5B,CAAc,CAAC,EAAD,CAEjB,CAVQ,CAUN,QAACX,CAAD,WAACA,CAAD,QAACA,CAAK,CAAEuB,OAAP,EAAD,CAVM,CAYT,CAAO,CACLb,WAAW,CAAXA,CADK,CAEL4B,QAAQ,CAARA,CAFK,CAIR,CArJM"}
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["format","isValid","isWithinInterval","parse","IMask","useCallback","useEffect","useMemo","useState","useIMask","useMutableRef","datePickerPropFormatTypeMonth","datePickerPropSeparatorDefault","getPartsDate","datePickerErrorTypes","usePicker","props","value","onChange","onError","formatProp","separator","maxDate","minDate","onChangeRef","valueRef","onErrorRef","stringValue","setStringValue","stringValueRef","handleChange","e","current","MM","yyyy","date","Date","start","end","type","getTime","options","mask","pattern","blocks","MaskedRange","from","to","lazy","autofix","string","validate","_val","params","maskOptions","inputRef","length","clearValue"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeMonth/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport { format, isValid, isWithinInterval, parse } from 'date-fns';\nimport IMask from 'imask';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { useIMask } from '##/components/TextField';\n\nimport { useMutableRef } from '../../../hooks/useMutableRef/useMutableRef';\nimport { PropsWithHTMLAttributes } from '../../../utils/types/PropsWithHTMLAttributes';\nimport {\n TextFieldPropForm,\n TextFieldPropSize,\n TextFieldPropStatus,\n TextFieldPropView,\n TextFieldPropWidth,\n} from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeMonth,\n datePickerPropSeparatorDefault,\n getPartsDate,\n} from '../helpers';\nimport { datePickerErrorTypes, DatePickerPropOnError } from '../types';\n\ntype DatePickerFieldTypeMonthPropOnChange = (props: {\n e: Event;\n value: Date | null;\n}) => void;\n\nexport type DatePickerFieldTypeMonthProps = PropsWithHTMLAttributes<\n {\n className?: string;\n value?: Date | null;\n onChange?: DatePickerFieldTypeMonthPropOnChange;\n onError?: DatePickerPropOnError;\n id?: string;\n name?: string;\n disabled?: boolean;\n size?: TextFieldPropSize;\n view?: TextFieldPropView;\n form?: TextFieldPropForm;\n status?: TextFieldPropStatus;\n width?: TextFieldPropWidth;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n autoFocus?: boolean;\n placeholder?: string;\n leftSide?: string | IconComponent;\n rightSide?: string | IconComponent;\n readOnly?: boolean;\n required?: boolean;\n tabIndex?: number;\n inputRef?: React.Ref<HTMLTextAreaElement | HTMLInputElement>;\n ariaLabel?: string;\n iconSize?: IconPropSize;\n children?: never;\n format?: string;\n separator?: string;\n minDate?: Date;\n maxDate?: Date;\n focused?: boolean;\n label?: string;\n labelIcon?: IconComponent;\n caption?: string;\n labelPosition?: 'top' | 'left';\n withClearButton?: boolean;\n },\n HTMLDivElement\n>;\n\ntype UsePickerProps = {\n value?: Date | null;\n onChange?: DatePickerFieldTypeMonthPropOnChange;\n onError?: DatePickerPropOnError;\n format: string;\n separator: string;\n minDate: Date;\n maxDate: Date;\n};\n\nexport const usePicker = (props: UsePickerProps) => {\n const {\n value,\n onChange,\n onError,\n format: formatProp,\n separator,\n maxDate,\n minDate,\n } = props;\n const onChangeRef = useMutableRef(onChange);\n const valueRef = useMutableRef(value);\n const onErrorRef = useMutableRef(onError);\n\n const [stringValue, setStringValue] = useState<string | null>(\n value && isValid(value) ? format(value, formatProp) : null,\n );\n const stringValueRef = useMutableRef(stringValue);\n\n const handleChange = useCallback(\n ({ e, value: stringValue }: { e: Event; value: string | null }) => {\n if (stringValueRef.current === stringValue) {\n return;\n }\n setStringValue(stringValue);\n const onChange = onChangeRef.current;\n const value = valueRef.current;\n if (onChange) {\n if (!stringValue) {\n if (value) {\n onChange({ e, value: null });\n }\n return;\n }\n const [MM, yyyy] = getPartsDate(\n stringValue,\n formatProp,\n separator,\n false,\n ['MM', 'yyyy'],\n );\n if (MM && yyyy) {\n const date = parse(\n `${MM}${datePickerPropSeparatorDefault}${yyyy}`,\n datePickerPropFormatTypeMonth,\n new Date(),\n );\n if (!isWithinInterval(date, { start: minDate, end: maxDate })) {\n onErrorRef.current?.({\n type: datePickerErrorTypes[0],\n stringValue,\n MM,\n yyyy,\n date,\n });\n if (value) {\n onChange({ e, value: null });\n }\n return;\n }\n onChange({ e, value: date });\n } else if (value) {\n onChange({ e, value: null });\n }\n }\n },\n [minDate?.getTime(), maxDate?.getTime(), formatProp, separator],\n );\n\n const options: IMask.InputMask<IMask.MaskedDateOptions> = useMemo(\n () =>\n ({\n mask: Date,\n pattern: formatProp,\n blocks: {\n yyyy: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 9999,\n },\n MM: {\n mask: IMask.MaskedRange,\n from: 1,\n to: 12,\n },\n },\n lazy: true,\n autofix: true,\n format: (date: Date) => format(date, formatProp),\n parse: (string: string) => parse(string, formatProp, new Date()),\n validate: (string: string) => {\n const [MM, yyyy] = getPartsDate(\n string,\n formatProp,\n separator,\n false,\n ['MM', 'yyyy'],\n );\n if (\n MM &&\n yyyy &&\n !isValid(\n parse(\n `${MM}${datePickerPropSeparatorDefault}${yyyy}`,\n datePickerPropFormatTypeMonth,\n new Date(),\n ),\n )\n ) {\n onError &&\n onErrorRef.current?.({\n type: datePickerErrorTypes[1],\n stringValue: string,\n MM,\n yyyy,\n });\n\n return false;\n }\n return true;\n },\n // проблема в типах IMask\n } as unknown as IMask.InputMask<IMask.MaskedDateOptions>),\n [formatProp, separator],\n );\n\n const { inputRef } = useIMask({\n value: stringValue,\n onChange: (_val, params) => handleChange?.(params),\n maskOptions: options,\n });\n\n const clearValue = (e: Event) => {\n setStringValue(null);\n onChange?.({ e, value: null });\n };\n\n // при изменении value, нужно обновить stringValue\n useEffect(() => {\n if (value && isValid(value)) {\n setStringValue(format(value, formatProp));\n } else if (stringValue?.length === formatProp.length) {\n // если количество введенных символов меньше чем в формате маски\n // то не нужно мешать вводу с клавиатуры\n // если дата была введена полностью и value пришел null,\n // то можно считать что поле нуждается в очистке\n setStringValue('');\n }\n }, [value?.getTime()]);\n\n return {\n stringValue,\n inputRef,\n clearValue,\n };\n};\n"],"mappings":"iEACA,OAASA,MAAM,GAANA,QAAT,CAAiBC,OAAjB,CAA0BC,gBAA1B,CAA4CC,KAAK,GAALA,OAA5C,KAAyD,UAAzD,CACA,MAAOC,MAAP,KAAkB,OAAlB,CACA,OAASC,WAAT,CAAsBC,SAAtB,CAAiCC,OAAjC,CAA0CC,QAA1C,KAA0D,OAA1D,CAEA,OAASC,QAAT,uBAEA,OAASC,aAAT,kDASA,OACEC,6BADF,CAEEC,8BAFF,CAGEC,YAHF,kBAKA,OAASC,oBAAT,gBA0DA,MAAO,IAAMC,UAAS,CAAG,SAACC,CAAD,CAA2B,IAEhDC,EAFgD,CAS9CD,CAT8C,CAEhDC,KAFgD,CAGhDC,CAHgD,CAS9CF,CAT8C,CAGhDE,QAHgD,CAIhDC,CAJgD,CAS9CH,CAT8C,CAIhDG,OAJgD,CAKxCC,CALwC,CAS9CJ,CAT8C,CAKhDhB,MALgD,CAMhDqB,CANgD,CAS9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,CAGH,QAAAO,CAAW,WAAXA,CAAA,QAAAA,CAAW,CAAE6B,MAAb,IAAwBpC,CAAU,CAACoC,MAHhC,EAQZ5B,CAAc,CAAC,EAAD,CAEjB,CAVQ,CAUN,QAACX,CAAD,WAACA,CAAD,QAACA,CAAK,CAAEuB,OAAP,EAAD,CAVM,CAYT,CAAO,CACLb,WAAW,CAAXA,CADK,CAEL4B,QAAQ,CAARA,CAFK,CAGLE,UAAU,CArBO,QAAbA,WAAa,CAAC1B,CAAD,CAAc,CAC/BH,CAAc,CAAC,IAAD,CADiB,QAE/BV,CAF+B,WAE/BA,CAF+B,QAE/BA,CAAQ,CAAG,CAAEa,CAAC,CAADA,CAAF,CAAKd,KAAK,CAAE,IAAZ,CAAH,CACT,CAeM,CAKR,CA3JM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","form","startFieldInputRef","startFieldLeftSide","startFieldRightSide","endFieldInputRef","endFieldLeftSide","endFieldRightSide","value","onChange","onError","startFieldName","endFieldName","disabled","size","view","status","autoFocus","placeholder","readOnly","required","tabIndex","ariaLabel","iconSize","format","separator","minDate","maxDate","startFieldOnBlur","startFieldOnFocus","endFieldOnBlur","endFieldOnFocus","startFieldRef","endFieldRef","startFocused","endFocused","label","labelPosition","caption","width","withClearButton"];import React,{forwardRef}from"react";import{FieldCaption}from"../../FieldCaption/FieldCaption";import{FieldLabel}from"../../FieldLabel/FieldLabel";import{DatePickerFieldTypeMonth}from"../DatePickerFieldTypeMonth/DatePickerFieldTypeMonth";import{cnDatePickerMixRangeField}from"../DatePickerMixRangeField/DatePickerMixRangeField";import{getChangeFnRange}from"../getChangeFnRange";import{getFormForEnd,getFormForStart}from"../helpers";export var DatePickerFieldTypeMonthRange=forwardRef(function(a,b){var c=a.className,d=a.form,e=void 0===d?"default":d,f=a.startFieldInputRef,g=a.startFieldLeftSide,h=a.startFieldRightSide,i=a.endFieldInputRef,j=a.endFieldLeftSide,k=a.endFieldRightSide,l=a.value,m=void 0===l?[]:l,n=a.onChange,o=a.onError,p=a.startFieldName,q=a.endFieldName,r=a.disabled,s=a.size,t=a.view,u=a.status,v=a.autoFocus,w=a.placeholder,x=a.readOnly,y=a.required,z=a.tabIndex,A=a.ariaLabel,B=a.iconSize,C=a.format,D=a.separator,E=a.minDate,F=a.maxDate,G=a.startFieldOnBlur,H=a.startFieldOnFocus,I=a.endFieldOnBlur,J=a.endFieldOnFocus,K=a.startFieldRef,L=a.endFieldRef,M=a.startFocused,N=a.endFocused,O=a.label,P=a.
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["className","form","startFieldInputRef","startFieldLeftSide","startFieldRightSide","endFieldInputRef","endFieldLeftSide","endFieldRightSide","value","onChange","onError","startFieldName","endFieldName","disabled","size","view","status","autoFocus","placeholder","readOnly","required","tabIndex","ariaLabel","iconSize","format","separator","minDate","maxDate","startFieldOnBlur","startFieldOnFocus","endFieldOnBlur","endFieldOnFocus","startFieldRef","endFieldRef","startFocused","endFocused","label","labelIcon","labelPosition","caption","width","withClearButton"];import React,{forwardRef}from"react";import{FieldCaption}from"../../FieldCaption/FieldCaption";import{FieldLabel}from"../../FieldLabel/FieldLabel";import{DatePickerFieldTypeMonth}from"../DatePickerFieldTypeMonth/DatePickerFieldTypeMonth";import{cnDatePickerMixRangeField}from"../DatePickerMixRangeField/DatePickerMixRangeField";import{getChangeFnRange}from"../getChangeFnRange";import{getFormForEnd,getFormForStart}from"../helpers";export var DatePickerFieldTypeMonthRange=forwardRef(function(a,b){var c=a.className,d=a.form,e=void 0===d?"default":d,f=a.startFieldInputRef,g=a.startFieldLeftSide,h=a.startFieldRightSide,i=a.endFieldInputRef,j=a.endFieldLeftSide,k=a.endFieldRightSide,l=a.value,m=void 0===l?[]:l,n=a.onChange,o=a.onError,p=a.startFieldName,q=a.endFieldName,r=a.disabled,s=a.size,t=a.view,u=a.status,v=a.autoFocus,w=a.placeholder,x=a.readOnly,y=a.required,z=a.tabIndex,A=a.ariaLabel,B=a.iconSize,C=a.format,D=a.separator,E=a.minDate,F=a.maxDate,G=a.startFieldOnBlur,H=a.startFieldOnFocus,I=a.endFieldOnBlur,J=a.endFieldOnFocus,K=a.startFieldRef,L=a.endFieldRef,M=a.startFocused,N=a.endFocused,O=a.label,P=a.labelIcon,Q=a.labelPosition,R=a.caption,S=a.width,T=a.withClearButton,U=_objectWithoutProperties(a,_excluded),V={className:cnDatePickerMixRangeField("Field"),disabled:r,onError:o,size:s,view:t,status:u,autoFocus:v,placeholder:w,readOnly:x,required:y,tabIndex:z,ariaLabel:A,iconSize:B,format:C,separator:D,minDate:E,maxDate:F,withClearButton:T},W=getChangeFnRange(n,o,m),X=_slicedToArray(W,2),Y=X[0],Z=X[1];return React.createElement("div",Object.assign({},U,{className:cnDatePickerMixRangeField({view:t,labelPosition:Q,width:S,size:s},[c]),ref:b}),O&&React.createElement(FieldLabel,{icon:P,required:y,className:cnDatePickerMixRangeField("Label",{labelPosition:Q}),size:s},O),React.createElement("div",{className:cnDatePickerMixRangeField("Body")},React.createElement("div",{className:cnDatePickerMixRangeField("Fields")},React.createElement(DatePickerFieldTypeMonth,Object.assign({},V,{inputRef:f,ref:K,leftSide:g,rightSide:h,form:getFormForStart(e),value:null===m||void 0===m?void 0:m[0],onChange:Y,onFocus:H,onBlur:G,focused:M,name:p})),React.createElement(DatePickerFieldTypeMonth,Object.assign({},V,{name:q,inputRef:i,ref:L,leftSide:j,rightSide:k,form:getFormForEnd(e),value:null===m||void 0===m?void 0:m[1],onChange:Z,onFocus:J,onBlur:I,focused:N}))),R&&React.createElement(FieldCaption,{className:cnDatePickerMixRangeField("Caption"),status:u},R)))});
|
|
2
2
|
//# sourceMappingURL=DatePickerFieldTypeMonthRange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerFieldTypeMonthRange.js","names":["React","forwardRef","FieldCaption","FieldLabel","DatePickerFieldTypeMonth","cnDatePickerMixRangeField","getChangeFnRange","getFormForEnd","getFormForStart","DatePickerFieldTypeMonthRange","props","ref","className","form","startFieldInputRef","startFieldLeftSide","startFieldRightSide","endFieldInputRef","endFieldLeftSide","endFieldRightSide","value","onChange","onError","startFieldName","endFieldName","disabled","size","view","status","autoFocus","placeholder","readOnly","required","tabIndex","ariaLabel","iconSize","format","separator","minDate","maxDate","startFieldOnBlur","startFieldOnFocus","endFieldOnBlur","endFieldOnFocus","startFieldRef","endFieldRef","startFocused","endFocused","label","labelPosition","caption","width","withClearButton","otherProps","commonProps","handleStartDateChange","handleEndDateChange"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeMonthRange/DatePickerFieldTypeMonthRange.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { FieldCaption } from '../../FieldCaption/FieldCaption';\nimport { FieldLabel } from '../../FieldLabel/FieldLabel';\nimport { DatePickerFieldTypeMonth } from '../DatePickerFieldTypeMonth/DatePickerFieldTypeMonth';\nimport { cnDatePickerMixRangeField } from '../DatePickerMixRangeField/DatePickerMixRangeField';\nimport { getChangeFnRange } from '../getChangeFnRange';\nimport { getFormForEnd, getFormForStart } from '../helpers';\nimport { DatePickerFieldTypeMonthRangeProps } from './helpers';\n\nexport const DatePickerFieldTypeMonthRange = forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeMonthRangeProps\n>((props, ref) => {\n const {\n className,\n form = 'default',\n startFieldInputRef,\n startFieldLeftSide,\n startFieldRightSide,\n endFieldInputRef,\n endFieldLeftSide,\n endFieldRightSide,\n value = [],\n onChange,\n onError,\n startFieldName,\n endFieldName,\n disabled,\n size,\n view,\n status,\n autoFocus,\n placeholder,\n readOnly,\n required,\n tabIndex,\n ariaLabel,\n iconSize,\n format,\n separator,\n minDate,\n maxDate,\n startFieldOnBlur,\n startFieldOnFocus,\n endFieldOnBlur,\n endFieldOnFocus,\n startFieldRef,\n endFieldRef,\n startFocused,\n endFocused,\n label,\n labelPosition,\n caption,\n width,\n withClearButton,\n ...otherProps\n } = props;\n\n const commonProps = {\n className: cnDatePickerMixRangeField('Field'),\n disabled,\n onError,\n size,\n view,\n status,\n autoFocus,\n placeholder,\n readOnly,\n required,\n tabIndex,\n ariaLabel,\n iconSize,\n format,\n separator,\n minDate,\n maxDate,\n withClearButton,\n };\n\n const [handleStartDateChange, handleEndDateChange] = getChangeFnRange(\n onChange,\n onError,\n value,\n );\n\n return (\n <div\n {...otherProps}\n className={cnDatePickerMixRangeField(\n { view, labelPosition, width, size },\n [className],\n )}\n ref={ref}\n >\n {label && (\n <FieldLabel\n required={required}\n className={cnDatePickerMixRangeField('Label', { labelPosition })}\n size={size}\n >\n {label}\n </FieldLabel>\n )}\n <div className={cnDatePickerMixRangeField('Body')}>\n <div className={cnDatePickerMixRangeField('Fields')}>\n <DatePickerFieldTypeMonth\n {...commonProps}\n inputRef={startFieldInputRef}\n ref={startFieldRef}\n leftSide={startFieldLeftSide}\n rightSide={startFieldRightSide}\n form={getFormForStart(form)}\n value={value?.[0]}\n onChange={handleStartDateChange}\n onFocus={startFieldOnFocus}\n onBlur={startFieldOnBlur}\n focused={startFocused}\n name={startFieldName}\n />\n <DatePickerFieldTypeMonth\n {...commonProps}\n name={endFieldName}\n inputRef={endFieldInputRef}\n ref={endFieldRef}\n leftSide={endFieldLeftSide}\n rightSide={endFieldRightSide}\n form={getFormForEnd(form)}\n value={value?.[1]}\n onChange={handleEndDateChange}\n onFocus={endFieldOnFocus}\n onBlur={endFieldOnBlur}\n focused={endFocused}\n />\n </div>\n {caption && (\n <FieldCaption\n className={cnDatePickerMixRangeField('Caption')}\n status={status}\n >\n {caption}\n </FieldCaption>\n )}\n </div>\n </div>\n );\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatePickerFieldTypeMonthRange.js","names":["React","forwardRef","FieldCaption","FieldLabel","DatePickerFieldTypeMonth","cnDatePickerMixRangeField","getChangeFnRange","getFormForEnd","getFormForStart","DatePickerFieldTypeMonthRange","props","ref","className","form","startFieldInputRef","startFieldLeftSide","startFieldRightSide","endFieldInputRef","endFieldLeftSide","endFieldRightSide","value","onChange","onError","startFieldName","endFieldName","disabled","size","view","status","autoFocus","placeholder","readOnly","required","tabIndex","ariaLabel","iconSize","format","separator","minDate","maxDate","startFieldOnBlur","startFieldOnFocus","endFieldOnBlur","endFieldOnFocus","startFieldRef","endFieldRef","startFocused","endFocused","label","labelIcon","labelPosition","caption","width","withClearButton","otherProps","commonProps","handleStartDateChange","handleEndDateChange"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeMonthRange/DatePickerFieldTypeMonthRange.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { FieldCaption } from '../../FieldCaption/FieldCaption';\nimport { FieldLabel } from '../../FieldLabel/FieldLabel';\nimport { DatePickerFieldTypeMonth } from '../DatePickerFieldTypeMonth/DatePickerFieldTypeMonth';\nimport { cnDatePickerMixRangeField } from '../DatePickerMixRangeField/DatePickerMixRangeField';\nimport { getChangeFnRange } from '../getChangeFnRange';\nimport { getFormForEnd, getFormForStart } from '../helpers';\nimport { DatePickerFieldTypeMonthRangeProps } from './helpers';\n\nexport const DatePickerFieldTypeMonthRange = forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeMonthRangeProps\n>((props, ref) => {\n const {\n className,\n form = 'default',\n startFieldInputRef,\n startFieldLeftSide,\n startFieldRightSide,\n endFieldInputRef,\n endFieldLeftSide,\n endFieldRightSide,\n value = [],\n onChange,\n onError,\n startFieldName,\n endFieldName,\n disabled,\n size,\n view,\n status,\n autoFocus,\n placeholder,\n readOnly,\n required,\n tabIndex,\n ariaLabel,\n iconSize,\n format,\n separator,\n minDate,\n maxDate,\n startFieldOnBlur,\n startFieldOnFocus,\n endFieldOnBlur,\n endFieldOnFocus,\n startFieldRef,\n endFieldRef,\n startFocused,\n endFocused,\n label,\n labelIcon,\n labelPosition,\n caption,\n width,\n withClearButton,\n ...otherProps\n } = props;\n\n const commonProps = {\n className: cnDatePickerMixRangeField('Field'),\n disabled,\n onError,\n size,\n view,\n status,\n autoFocus,\n placeholder,\n readOnly,\n required,\n tabIndex,\n ariaLabel,\n iconSize,\n format,\n separator,\n minDate,\n maxDate,\n withClearButton,\n };\n\n const [handleStartDateChange, handleEndDateChange] = getChangeFnRange(\n onChange,\n onError,\n value,\n );\n\n return (\n <div\n {...otherProps}\n className={cnDatePickerMixRangeField(\n { view, labelPosition, width, size },\n [className],\n )}\n ref={ref}\n >\n {label && (\n <FieldLabel\n icon={labelIcon}\n required={required}\n className={cnDatePickerMixRangeField('Label', { labelPosition })}\n size={size}\n >\n {label}\n </FieldLabel>\n )}\n <div className={cnDatePickerMixRangeField('Body')}>\n <div className={cnDatePickerMixRangeField('Fields')}>\n <DatePickerFieldTypeMonth\n {...commonProps}\n inputRef={startFieldInputRef}\n ref={startFieldRef}\n leftSide={startFieldLeftSide}\n rightSide={startFieldRightSide}\n form={getFormForStart(form)}\n value={value?.[0]}\n onChange={handleStartDateChange}\n onFocus={startFieldOnFocus}\n onBlur={startFieldOnBlur}\n focused={startFocused}\n name={startFieldName}\n />\n <DatePickerFieldTypeMonth\n {...commonProps}\n name={endFieldName}\n inputRef={endFieldInputRef}\n ref={endFieldRef}\n leftSide={endFieldLeftSide}\n rightSide={endFieldRightSide}\n form={getFormForEnd(form)}\n value={value?.[1]}\n onChange={handleEndDateChange}\n onFocus={endFieldOnFocus}\n onBlur={endFieldOnBlur}\n focused={endFocused}\n />\n </div>\n {caption && (\n <FieldCaption\n className={cnDatePickerMixRangeField('Caption')}\n status={status}\n >\n {caption}\n </FieldCaption>\n )}\n </div>\n </div>\n );\n});\n"],"mappings":"ytBAAA,MAAOA,MAAP,EAAgBC,UAAhB,KAAkC,OAAlC,CAEA,OAASC,YAAT,uCACA,OAASC,UAAT,mCACA,OAASC,wBAAT,4DACA,OAASC,yBAAT,0DACA,OAAS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,CAUE,MAAM,CAAED,CAVV,CAWE,OAAO,CAAEM,CAXX,CAYE,IAAI,CAAEvB,CAZR,GADF,CAeE,oBAAC,wBAAD,kBACMgC,CADN,EAEE,IAAI,CAAE/B,CAFR,CAGE,QAAQ,CAAEP,CAHZ,CAIE,GAAG,CAAE4B,CAJP,CAKE,QAAQ,CAAE3B,CALZ,CAME,SAAS,CAAEC,CANb,CAOE,IAAI,CAAEZ,aAAa,CAACM,CAAD,CAPrB,CAQE,KAAK,QAAEO,CAAF,WAAEA,CAAF,QAAEA,CAAK,CAAG,CAAH,CARd,CASE,QAAQ,CAAEqC,CATZ,CAUE,OAAO,CAAEd,CAVX,CAWE,MAAM,CAAED,CAXV,CAYE,OAAO,CAAEK,CAZX,GAfF,CADF,CA+BGI,CAAO,EACN,oBAAC,YAAD,EACE,SAAS,CAAE9C,yBAAyB,CAAC,SAAD,CADtC,CAEE,MAAM,CAAEuB,CAFV,EAIGuB,CAJH,CAhCJ,CAlBF,CA4DH,CA1IsD,CAAhD"}
|
package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const DatePickerFieldTypeTime: React.ForwardRefExoticComponent<{
|
|
|
12
12
|
disabled?: boolean | undefined;
|
|
13
13
|
size?: "m" | "s" | "xs" | "l" | undefined;
|
|
14
14
|
view?: "default" | "clear" | undefined;
|
|
15
|
-
form?: "default" | "round" | "
|
|
15
|
+
form?: "default" | "round" | "defaultClear" | "defaultBrick" | "brick" | "brickDefault" | "brickClear" | "brickRound" | "roundClear" | "roundBrick" | "clearRound" | "clearDefault" | "clearBrick" | "clearClear" | undefined;
|
|
16
16
|
status?: "alert" | "warning" | "success" | undefined;
|
|
17
17
|
width?: "default" | "full" | undefined;
|
|
18
18
|
onFocus?: React.FocusEventHandler<HTMLElement> | undefined;
|
|
@@ -37,7 +37,8 @@ export declare const DatePickerFieldTypeTime: React.ForwardRefExoticComponent<{
|
|
|
37
37
|
multiplicityMinutes?: number | undefined;
|
|
38
38
|
multiplicityHours?: number | undefined;
|
|
39
39
|
label?: string | undefined;
|
|
40
|
+
labelIcon?: import("@consta/icons/Icon").IconComponent | undefined;
|
|
40
41
|
caption?: string | undefined;
|
|
41
42
|
labelPosition?: "left" | "top" | undefined;
|
|
42
43
|
withClearButton?: boolean | undefined;
|
|
43
|
-
} & Omit<React.HTMLAttributes<HTMLDivElement>, "css" | "className" | "id" | "placeholder" | "tabIndex" | "children" | "onFocus" | "onBlur" | "onChange" | "onError" | "size" | "caption" | "form" | "label" | "view" | "separator" | "status" | "name" | "width" | "format" | "autoFocus" | "disabled" | "value" | "readOnly" | "required" | "inputRef" | "focused" | "ariaLabel" | "labelPosition" | "leftSide" | "rightSide" | "withClearButton" | "iconSize" | "minDate" | "maxDate" | "multiplicitySeconds" | "multiplicityMinutes" | "multiplicityHours"> & React.RefAttributes<HTMLDivElement>>;
|
|
44
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "css" | "className" | "id" | "placeholder" | "tabIndex" | "children" | "onFocus" | "onBlur" | "onChange" | "onError" | "size" | "caption" | "form" | "label" | "view" | "separator" | "status" | "name" | "width" | "format" | "autoFocus" | "disabled" | "value" | "readOnly" | "required" | "inputRef" | "focused" | "ariaLabel" | "labelIcon" | "labelPosition" | "leftSide" | "rightSide" | "withClearButton" | "iconSize" | "minDate" | "maxDate" | "multiplicitySeconds" | "multiplicityMinutes" | "multiplicityHours"> & React.RefAttributes<HTMLDivElement>>;
|
package/__internal__/src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes"];import React from"react";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{TextField}from"../../TextField/TextField";import{datePickerPropFormatTypeTime,datePickerPropPlaceholderTypeTime,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeTime=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeTime:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeTime:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=a.multiplicityHours,r=a.multiplicitySeconds,s=a.multiplicityMinutes,t=_objectWithoutProperties(a,_excluded),u=usePicker({value:o,onChange:i,onError:j,separator:f,format:d,minDate:l,maxDate:n,multiplicityHours:q,multiplicityMinutes:s,multiplicitySeconds:r}),v=u.stringValue,w=u.inputRef;return React.createElement(TextField,Object.assign({},t,{type:"text",inputContainerRef:b,inputRef:useForkRef([w,p]),value:v,placeholder:h}))});
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes"];import React from"react";import{useForkRef}from"../../../hooks/useForkRef/useForkRef";import{maxDateDefault,minDateDefault}from"../../../utils/date";import{TextField}from"../../TextField/TextField";import{datePickerPropFormatTypeTime,datePickerPropPlaceholderTypeTime,datePickerPropSeparatorDefault}from"../helpers";import{usePicker}from"./helpers";export var DatePickerFieldTypeTime=React.forwardRef(function(a,b){var c=a.format,d=void 0===c?datePickerPropFormatTypeTime:c,e=a.separator,f=void 0===e?datePickerPropSeparatorDefault:e,g=a.placeholder,h=void 0===g?datePickerPropPlaceholderTypeTime:g,i=a.onChange,j=a.onError,k=a.minDate,l=void 0===k?minDateDefault:k,m=a.maxDate,n=void 0===m?maxDateDefault:m,o=a.value,p=a.inputRef,q=a.multiplicityHours,r=a.multiplicitySeconds,s=a.multiplicityMinutes,t=_objectWithoutProperties(a,_excluded),u=usePicker({value:o,onChange:i,onError:j,separator:f,format:d,minDate:l,maxDate:n,multiplicityHours:q,multiplicityMinutes:s,multiplicitySeconds:r}),v=u.stringValue,w=u.inputRef,x=u.clearValue;return React.createElement(TextField,Object.assign({},t,{type:"text",onChange:function(a){var b=a.e,c=a.value;return null===c&&x(b.nativeEvent)},inputContainerRef:b,inputRef:useForkRef([w,p]),value:v,placeholder:h}))});
|
|
2
2
|
//# sourceMappingURL=DatePickerFieldTypeTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerFieldTypeTime.js","names":["React","useForkRef","maxDateDefault","minDateDefault","TextField","datePickerPropFormatTypeTime","datePickerPropPlaceholderTypeTime","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeTime","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes","otherProps","stringValue"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { maxDateDefault, minDateDefault } from '../../../utils/date';\nimport { TextField } from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeTime,\n datePickerPropPlaceholderTypeTime,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeTimeProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeTime = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeTimeProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeTime,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeTime,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n multiplicityHours,\n multiplicitySeconds,\n multiplicityMinutes,\n ...otherProps\n } = props;\n\n const { stringValue, inputRef } = usePicker({\n value,\n onChange,\n onError,\n separator,\n format,\n minDate,\n maxDate,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n value={stringValue}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"oQAAA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,UAAT,4CACA,OAASC,cAAT,CAAyBC,cAAzB,2BACA,OAASC,SAAT,iCACA,OACEC,4BADF,CAEEC,iCAFF,CAGEC,8BAHF,kBAKA,OAAuCC,SAAvC,iBAEA,MAAO,IAAMC,wBAAuB,CAAGT,KAAK,CAACU,UAAN,CAGrC,SAACC,CAAD,CAAQC,CAAR,CAAgB,OAeZD,CAfY,CAEdE,MAFc,CAEdA,CAFc,YAELR,4BAFK,KAeZM,CAfY,CAGdG,SAHc,CAGdA,CAHc,YAGFP,8BAHE,KAeZI,CAfY,CAIdI,WAJc,CAIdA,CAJc,YAIAT,iCAJA,GAKdU,CALc,CAeZL,CAfY,CAKdK,QALc,CAMdC,CANc,CAeZN,CAfY,CAMdM,OANc,GAeZN,CAfY,CAOdO,OAPc,CAOdA,CAPc,YAOJf,cAPI,KAeZQ,CAfY,CAQdQ,OARc,CAQdA,CARc,YAQJjB,cARI,GASdkB,CATc,CAeZT,CAfY,CASdS,KATc,CAUJC,CAVI,CAeZV,CAfY,CAUdW,QAVc,CAWdC,CAXc,CAeZZ,CAfY,CAWdY,iBAXc,CAYdC,CAZc,CAeZb,CAfY,CAYda,mBAZc,CAadC,CAbc,CAeZd,CAfY,CAadc,mBAbc,CAcXC,CAdW,0BAeZf,CAfY,
|
|
1
|
+
{"version":3,"file":"DatePickerFieldTypeTime.js","names":["React","useForkRef","maxDateDefault","minDateDefault","TextField","datePickerPropFormatTypeTime","datePickerPropPlaceholderTypeTime","datePickerPropSeparatorDefault","usePicker","DatePickerFieldTypeTime","forwardRef","props","ref","format","separator","placeholder","onChange","onError","minDate","maxDate","value","inputRefProp","inputRef","multiplicityHours","multiplicitySeconds","multiplicityMinutes","otherProps","stringValue","clearValue","e","nativeEvent"],"sources":["../../../../../../src/components/DatePicker/DatePickerFieldTypeTime/DatePickerFieldTypeTime.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForkRef } from '../../../hooks/useForkRef/useForkRef';\nimport { maxDateDefault, minDateDefault } from '../../../utils/date';\nimport { TextField } from '../../TextField/TextField';\nimport {\n datePickerPropFormatTypeTime,\n datePickerPropPlaceholderTypeTime,\n datePickerPropSeparatorDefault,\n} from '../helpers';\nimport { DatePickerFieldTypeTimeProps, usePicker } from './helpers';\n\nexport const DatePickerFieldTypeTime = React.forwardRef<\n HTMLDivElement,\n DatePickerFieldTypeTimeProps\n>((props, ref) => {\n const {\n format = datePickerPropFormatTypeTime,\n separator = datePickerPropSeparatorDefault,\n placeholder = datePickerPropPlaceholderTypeTime,\n onChange,\n onError,\n minDate = minDateDefault,\n maxDate = maxDateDefault,\n value,\n inputRef: inputRefProp,\n multiplicityHours,\n multiplicitySeconds,\n multiplicityMinutes,\n ...otherProps\n } = props;\n\n const { stringValue, inputRef, clearValue } = usePicker({\n value,\n onChange,\n onError,\n separator,\n format,\n minDate,\n maxDate,\n multiplicityHours,\n multiplicityMinutes,\n multiplicitySeconds,\n });\n\n return (\n <TextField\n {...otherProps}\n type=\"text\"\n onChange={({ e, value }) => value === null && clearValue(e.nativeEvent)}\n inputContainerRef={ref}\n inputRef={useForkRef([inputRef, inputRefProp])}\n value={stringValue}\n placeholder={placeholder}\n />\n );\n});\n"],"mappings":"oQAAA,MAAOA,MAAP,KAAkB,OAAlB,CAEA,OAASC,UAAT,4CACA,OAASC,cAAT,CAAyBC,cAAzB,2BACA,OAASC,SAAT,iCACA,OACEC,4BADF,CAEEC,iCAFF,CAGEC,8BAHF,kBAKA,OAAuCC,SAAvC,iBAEA,MAAO,IAAMC,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U,CAACC,CAAC,CAACC,WAAH,CAA9C,CAHZ,CAIE,iBAAiB,CAAElB,CAJrB,CAKE,QAAQ,CAAEX,UAAU,CAAC,CAACqB,CAAD,CAAWD,CAAX,CAAD,CALtB,CAME,KAAK,CAAEM,CANT,CAOE,WAAW,CAAEZ,CAPf,GAUH,CA5CsC,CAAhC"}
|
|
@@ -42,6 +42,7 @@ export declare type DatePickerFieldTypeTimeProps = PropsWithHTMLAttributes<{
|
|
|
42
42
|
multiplicityMinutes?: number;
|
|
43
43
|
multiplicityHours?: number;
|
|
44
44
|
label?: string;
|
|
45
|
+
labelIcon?: IconComponent;
|
|
45
46
|
caption?: string;
|
|
46
47
|
labelPosition?: 'top' | 'left';
|
|
47
48
|
withClearButton?: boolean;
|
|
@@ -61,5 +62,6 @@ declare type UsePickerProps = {
|
|
|
61
62
|
export declare const usePicker: (props: UsePickerProps) => {
|
|
62
63
|
stringValue: string | null;
|
|
63
64
|
inputRef: React.RefObject<HTMLInputElement>;
|
|
65
|
+
clearValue: (e: Event) => void;
|
|
64
66
|
};
|
|
65
67
|
export {};
|