@alfalab/core-components-date-time-input 6.0.24 → 6.0.25-alfasans
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/Component.responsive.js.map +1 -1
- package/components/date-time-input/Component.js +2 -6
- package/components/date-time-input/Component.js.map +1 -1
- package/components/date-time-input/index.css +6 -6
- package/components/date-time-input/index.module.css.js +1 -1
- package/components/date-time-input/index.module.css.js.map +1 -1
- package/cssm/Component.responsive.js.map +1 -1
- package/cssm/components/date-time-input/Component.js +2 -6
- package/cssm/components/date-time-input/Component.js.map +1 -1
- package/cssm/desktop/Component.desktop.js.map +1 -1
- package/cssm/mobile/Component.mobile.js.map +1 -1
- package/cssm/utils/format.js.map +1 -1
- package/desktop/Component.desktop.js.map +1 -1
- package/esm/Component.responsive.js.map +1 -1
- package/esm/components/date-time-input/Component.js +2 -6
- package/esm/components/date-time-input/Component.js.map +1 -1
- package/esm/components/date-time-input/index.css +6 -6
- package/esm/components/date-time-input/index.module.css.js +1 -1
- package/esm/components/date-time-input/index.module.css.js.map +1 -1
- package/esm/desktop/Component.desktop.js.map +1 -1
- package/esm/mobile/Component.mobile.js.map +1 -1
- package/esm/utils/format.js.map +1 -1
- package/mobile/Component.mobile.js.map +1 -1
- package/modern/Component.responsive.js.map +1 -1
- package/modern/components/date-time-input/Component.js +2 -6
- package/modern/components/date-time-input/Component.js.map +1 -1
- package/modern/components/date-time-input/index.css +6 -6
- package/modern/components/date-time-input/index.module.css.js +1 -1
- package/modern/components/date-time-input/index.module.css.js.map +1 -1
- package/modern/desktop/Component.desktop.js.map +1 -1
- package/modern/mobile/Component.mobile.js.map +1 -1
- package/modern/utils/format.js.map +1 -1
- package/moderncssm/Component.responsive.js.map +1 -1
- package/moderncssm/components/date-time-input/Component.js +2 -6
- package/moderncssm/components/date-time-input/Component.js.map +1 -1
- package/moderncssm/desktop/Component.desktop.js.map +1 -1
- package/moderncssm/mobile/Component.mobile.js.map +1 -1
- package/moderncssm/utils/format.js.map +1 -1
- package/package.json +8 -8
- package/utils/format.js.map +1 -1
|
@@ -13,30 +13,30 @@
|
|
|
13
13
|
:root {
|
|
14
14
|
--calendar-popover-border-radius: var(--border-radius-8);
|
|
15
15
|
}
|
|
16
|
-
.date-time-
|
|
16
|
+
.date-time-input__component_11t63 {
|
|
17
17
|
display: inline-block;
|
|
18
18
|
outline: none;
|
|
19
19
|
position: relative;
|
|
20
20
|
}
|
|
21
|
-
.date-time-
|
|
21
|
+
.date-time-input__calendarContainer_11t63 {
|
|
22
22
|
display: inline-block;
|
|
23
23
|
box-sizing: border-box;
|
|
24
24
|
border-radius: var(--calendar-popover-border-radius);
|
|
25
25
|
border: 1px solid var(--color-light-neutral-300);
|
|
26
26
|
}
|
|
27
27
|
@media (max-width: 374px) {
|
|
28
|
-
.date-time-
|
|
28
|
+
.date-time-input__calendarContainer_11t63 {
|
|
29
29
|
width: 100%;
|
|
30
30
|
min-width: 288px;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
.date-time-
|
|
33
|
+
.date-time-input__calendarResponsive_11t63 {
|
|
34
34
|
width: var(--calendar-width);
|
|
35
35
|
}
|
|
36
|
-
.date-time-
|
|
36
|
+
.date-time-input__block_11t63 {
|
|
37
37
|
width: 100%;
|
|
38
38
|
}
|
|
39
|
-
.date-time-
|
|
39
|
+
.date-time-input__calendarIcon_11t63 {
|
|
40
40
|
margin-right: var(--gap-12-neg);
|
|
41
41
|
height: 100%;
|
|
42
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
|
|
3
|
-
var styles = {"component":"date-time-
|
|
3
|
+
var styles = {"component":"date-time-input__component_11t63","calendarContainer":"date-time-input__calendarContainer_11t63","calendarResponsive":"date-time-input__calendarResponsive_11t63","block":"date-time-input__block_11t63","calendarIcon":"date-time-input__calendarIcon_11t63"};
|
|
4
4
|
|
|
5
5
|
export { styles as default };
|
|
6
6
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["../../src/components/date-time-input/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n@import '../../../../calendar/src/vars.css';\n\n:root {\n --calendar-popover-border-radius: var(--border-radius-8);\n}\n\n.component {\n display: inline-block;\n outline: none;\n position: relative;\n}\n\n.calendarContainer {\n display: inline-block;\n box-sizing: border-box;\n border-radius: var(--calendar-popover-border-radius);\n border: 1px solid var(--color-light-neutral-300);\n\n @media (max-width: 374px) {\n width: 100%;\n min-width: 288px;\n }\n}\n\n.calendarResponsive {\n width: var(--calendar-width);\n}\n\n.block {\n width: 100%;\n}\n\n.calendarIcon {\n margin-right: var(--gap-12-neg);\n height: 100%;\n}\n"],"names":[],"mappings":";;AAEgB,aAAe,CAAC,WAAW,CAAC,kCAAkC,CAAC,mBAAmB,CAAC,0CAA0C,CAAC,oBAAoB,CAAC,2CAA2C,CAAC,OAAO,CAAC,8BAA8B,CAAC,cAAc,CAAC,qCAAqC,CAAC
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../../src/components/date-time-input/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n@import '../../../../calendar/src/vars.css';\n\n:root {\n --calendar-popover-border-radius: var(--border-radius-8);\n}\n\n.component {\n display: inline-block;\n outline: none;\n position: relative;\n}\n\n.calendarContainer {\n display: inline-block;\n box-sizing: border-box;\n border-radius: var(--calendar-popover-border-radius);\n border: 1px solid var(--color-light-neutral-300);\n\n @media (max-width: 374px) {\n width: 100%;\n min-width: 288px;\n }\n}\n\n.calendarResponsive {\n width: var(--calendar-width);\n}\n\n.block {\n width: 100%;\n}\n\n.calendarIcon {\n margin-right: var(--gap-12-neg);\n height: 100%;\n}\n"],"names":[],"mappings":";;AAEgB,aAAe,CAAC,WAAW,CAAC,kCAAkC,CAAC,mBAAmB,CAAC,0CAA0C,CAAC,oBAAoB,CAAC,2CAA2C,CAAC,OAAO,CAAC,8BAA8B,CAAC,cAAc,CAAC,qCAAqC,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.desktop.js","sources":["../../src/desktop/Component.desktop.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarDesktop } from '@alfalab/core-components-calendar/desktop';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputDesktop } from '@alfalab/core-components-input/desktop';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputDesktopProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const DateTimeInputDesktop = forwardRef<HTMLInputElement, DateTimeInputDesktopProps>(\n (props, ref) => (\n <DateTimeInput\n Calendar={CalendarDesktop}\n InputComponent={InputDesktop}\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;;AAWA;;;AAGG;AACI,IAAM,oBAAoB,GAAG,UAAU,CAC1C,UAAC,KAAK,EAAE,GAAG,EAAK,
|
|
1
|
+
{"version":3,"file":"Component.desktop.js","sources":["../../src/desktop/Component.desktop.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarDesktop } from '@alfalab/core-components-calendar/desktop';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputDesktop } from '@alfalab/core-components-input/desktop';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputDesktopProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const DateTimeInputDesktop = forwardRef<HTMLInputElement, DateTimeInputDesktopProps>(\n (props, ref) => (\n <DateTimeInput\n Calendar={CalendarDesktop}\n InputComponent={InputDesktop}\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;;AAWA;;;AAGG;AACI,IAAM,oBAAoB,GAAG,UAAU,CAC1C,UAAC,KAAK,EAAE,GAAG,EAAA,EAAK,QACZ,KAAA,CAAA,aAAA,CAAC,aAAa,EAAA,QAAA,CAAA,EACV,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,YAAY,IACxB,KAAK,EAAA,EACT,GAAG,EAAE,GAAG,EAAA,CAAA,CACV,EACL,CAPe,CAOf;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.mobile.js","sources":["../../src/mobile/Component.mobile.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarMobile } from '@alfalab/core-components-calendar/mobile';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputMobile } from '@alfalab/core-components-input/mobile';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\nexport const DateTimeInputMobile = forwardRef<HTMLInputElement, DateTimeInputMobileProps>(\n (props, ref) => (\n <DateTimeInput\n InputComponent={InputMobile}\n Calendar={CalendarMobile}\n view='mobile'\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"Component.mobile.js","sources":["../../src/mobile/Component.mobile.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarMobile } from '@alfalab/core-components-calendar/mobile';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputMobile } from '@alfalab/core-components-input/mobile';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\nexport const DateTimeInputMobile = forwardRef<HTMLInputElement, DateTimeInputMobileProps>(\n (props, ref) => (\n <DateTimeInput\n InputComponent={InputMobile}\n Calendar={CalendarMobile}\n view='mobile'\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;;AAWO,IAAM,mBAAmB,GAAG,UAAU,CACzC,UAAC,KAAK,EAAE,GAAG,IAAK,QACZ,oBAAC,aAAa,EAAA,QAAA,CAAA,EACV,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,QAAQ,EAAA,EACT,KAAK,EAAA,EACT,GAAG,EAAE,GAAG,EAAA,CAAA,CACV,EACL,CARe,CAQf;;"}
|
package/esm/utils/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sources":["../../src/utils/format.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nimport { isValid as dateFnsIsValid, parse } from 'date-fns';\n\nexport const DATE_FORMAT = 'dd.MM.yyyy';\nexport const DATE_MASK = [\n /\\d/,\n /\\d/,\n '.',\n /\\d/,\n /\\d/,\n '.',\n /\\d/,\n /\\d/,\n /\\d/,\n /\\d/,\n ',',\n ' ',\n /\\d/,\n /\\d/,\n ':',\n /\\d/,\n /\\d/,\n];\n\nexport const DATE_WITH_TIME_LENGTH = DATE_MASK.length;\nexport const isCompleteDateInput = (input: string) => input.length === DATE_WITH_TIME_LENGTH;\nexport const parseDateString = (value: string, dateFormat = DATE_FORMAT) =>\n parse(value, dateFormat, new Date());\nexport const isValidTimeFormat = (value: string): boolean => {\n const timeArr = value.split(':');\n const hours = timeArr[0];\n const mins = timeArr[1];\n\n if (hours.length !== 2 || Number(hours) > 23) {\n return false;\n }\n\n if (mins.length !== 2 || Number(mins) > 59) {\n return false;\n }\n\n return true;\n};\n\nexport const isValid = (inputValue: string) => {\n const inputValueArr = inputValue.split(', ');\n const date = inputValueArr[0];\n const time = inputValueArr[1];\n\n return (\n !inputValue ||\n (isCompleteDateInput(inputValue) &&\n dateFnsIsValid(parseDateString(date)) &&\n isValidTimeFormat(time))\n );\n};\n\nexport const format = (value: string): string =>\n value\n .replace(/^(\\d\\d)(\\d)$/, '$1.$2') // 121 => 12.1\n .replace(/^(\\d\\d)\\.(\\d\\d)(\\d)$/, '$1.$2.$3') // 12.122 => 12.12.2\n .replace(/^(\\d\\d)\\d\\.(.*)/, '$1.$2') // 123.12.2005 => 12.12.2005\n .replace(/^(\\d\\d\\.\\d\\d)\\d\\.(.*)/, '$1.$2') // 12.123.2005 => 12.12.2005\n .replace(/\\.$/, '') // 12. => 12\n .replace(/\\ $/, '') // 1 2 => 12\n .replace(/\\:$/, '') // 1:2 => 12\n .replace(/^(\\d\\d)(\\d.*)/, '$1.$2') // 1212 => 12.12\n .replace(/^(\\d\\d.\\d\\d)(\\d.*)/, '$1.$2') // 12.122 => 12.12.2\n .replace(/^(\\d\\d\\.\\d\\d)(\\d\\d\\d\\d)/, '$1.$2') // 12.122005 => 12.12.2005\n .replace(/^(\\d\\d)(\\d\\d\\.\\d\\d\\d\\d)/, '$1.$2') // 1212.2005 => 12.12.2005\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d),/, '$1') // 12.12.2005 => 12.12.2005\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d)(\\d)/, '$1, $2') // 12.12.20050 => 12.12.2005, 0\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d),(\\d.*)/, '$1, $2') // 12.12.2005,00:00 => 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d) (\\d.*)/, '$1, $2') // 12.12.2005 00:00 => 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d)(\\d.*)/, '$1, $2') // 12.12.200500:00=> 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d), (\\d\\d):/, '$1, $2') // 12.12.2005, 00: => 12.12.2005, 00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d), (\\d\\d)(\\d)/, '$1, $2:$3') // 12.12.2005, 000 => 12.12.2005, 00:0\n .replace(/^(\\d\\.\\d\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 1.12.2005123123 => 1.12.2005\n .replace(/^(\\d\\d\\.\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 01.2.20055125125 => 01.2.2005\n .replace(/^(\\d)\\.(\\d\\d)([0-9]*)\\.(\\d\\d\\d\\d)/, '$1.$2.$4') // 1.123123.2005 => 1.12.2005\n .replace(/^(\\d\\.\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 1.2.20055125125 => 1.2.2005\n .replace(/^(\\d\\d)\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // 01..2005123123 => 01..2005\n .replace(/^(\\d)\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // 1..2005123123 => 1..2005\n .replace(/^()\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // ..2005123123 => ..2005\n .replace(/^()\\.(\\d)\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3'); // .2.2005123123 => .2.2005\n\nexport const parseTimestampToDate = (timestamp: number): string => {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n\n let month: number | string = date.getMonth() + 1;\n let day: number | string = date.getDate();\n\n if (month < 10) {\n month = `0${month}`;\n }\n if (day < 10) {\n day = `0${day}`;\n }\n\n return `${day}.${month}.${year}`;\n};\n\nexport const getDateWithoutTime = (value: string): Date => {\n const valueArr = value.split(', ');\n\n let day;\n let month;\n let year;\n\n if (valueArr[0]) {\n const date = valueArr[0].split('.');\n\n [day, month, year] = date;\n }\n\n const date = new Date();\n\n date.setFullYear(Number(year), Number(month) - 1, Number(day));\n date.setHours(0, 0, 0, 0);\n\n return date;\n};\n\nexport const getFullDateTime = (value: string): Date => {\n const valueArr = value.split(', ');\n\n let day;\n let month;\n let year;\n let hours;\n let mins;\n\n if (valueArr[0]) {\n const date = valueArr[0].split('.');\n\n [day, month, year] = date;\n }\n if (valueArr[1]) {\n const time = valueArr[1].split(':');\n\n hours = Number(time[0]);\n mins = Number(time[1]);\n }\n\n const fullDate = new Date();\n\n fullDate.setFullYear(Number(year), Number(month) - 1, Number(day));\n fullDate.setHours(Number(hours) || 0);\n fullDate.setMinutes(Number(mins) || 0);\n fullDate.setSeconds(0);\n fullDate.setMilliseconds(0);\n\n return fullDate;\n};\n\nexport const addTimeToDate = (value: string): string => {\n if (value.length === 10 && dateFnsIsValid(parseDateString(value))) {\n return `${value}, 00:00`;\n }\n\n return value;\n};\n"],"names":["dateFnsIsValid"],"mappings":";;AAAA;AAIO,IAAM,WAAW,GAAG;AACd,IAAA,SAAS,GAAG;IACrB,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;;AAGK,IAAA,qBAAqB,GAAG,SAAS,CAAC;AACxC,IAAM,mBAAmB,GAAG,UAAC,KAAa,EAAA,EAAK,OAAA,KAAK,CAAC,MAAM,KAAK,qBAAqB,CAAA;AAC/E,IAAA,eAAe,GAAG,UAAC,KAAa,EAAE,UAAwB,EAAA;AAAxB,IAAA,IAAA,UAAA,KAAA,MAAA,EAAA,EAAA,UAAwB,GAAA,WAAA,CAAA;IACnE,OAAA,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC;AAApC;AACG,IAAM,iBAAiB,GAAG,UAAC,KAAa,EAAA;IAC3C,IAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAChC,IAAA,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC;AACxB,IAAA,IAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC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AC,CAAC,KAAK,CAAC,GAAG,CAAC;AAElC,QAAA,GAAG,GAAiB,IAAI,CAArB,CAAA,CAAA,EAAE,KAAK,GAAU,IAAI,CAAA,CAAA,CAAd,EAAE,IAAI,GAAI,IAAI,GAAR;;AAErB,IAAA,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE;QACb,IAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;QAEnC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;AAG1B,IAAA,IAAM,QAAQ,GAAG,IAAI,IAAI,EAAE;IAE3B,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAClE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtC,IAAA,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AACtB,IAAA,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;AAE3B,IAAA,OAAO,QAAQ;AACnB;AAEO,IAAM,aAAa,GAAG,UAAC,KAAa,EAAA;AACvC,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,IAAIA,SAAc,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/D,OAAO,EAAA,CAAA,MAAA,CAAG,KAAK,EAAA,SAAA,CAAS;;AAG5B,IAAA,OAAO,KAAK;AAChB;;;;"}
|
|
1
|
+
{"version":3,"file":"format.js","sources":["../../src/utils/format.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nimport { isValid as dateFnsIsValid, parse } from 'date-fns';\n\nexport const DATE_FORMAT = 'dd.MM.yyyy';\nexport const DATE_MASK = [\n /\\d/,\n /\\d/,\n '.',\n /\\d/,\n /\\d/,\n '.',\n /\\d/,\n /\\d/,\n /\\d/,\n /\\d/,\n ',',\n ' ',\n /\\d/,\n /\\d/,\n ':',\n /\\d/,\n /\\d/,\n];\n\nexport const DATE_WITH_TIME_LENGTH = DATE_MASK.length;\nexport const isCompleteDateInput = (input: string) => input.length === DATE_WITH_TIME_LENGTH;\nexport const parseDateString = (value: string, dateFormat = DATE_FORMAT) =>\n parse(value, dateFormat, new Date());\nexport const isValidTimeFormat = (value: string): boolean => {\n const timeArr = value.split(':');\n const hours = timeArr[0];\n const mins = timeArr[1];\n\n if (hours.length !== 2 || Number(hours) > 23) {\n return false;\n }\n\n if (mins.length !== 2 || Number(mins) > 59) {\n return false;\n }\n\n return true;\n};\n\nexport const isValid = (inputValue: string) => {\n const inputValueArr = inputValue.split(', ');\n const date = inputValueArr[0];\n const time = inputValueArr[1];\n\n return (\n !inputValue ||\n (isCompleteDateInput(inputValue) &&\n dateFnsIsValid(parseDateString(date)) &&\n isValidTimeFormat(time))\n );\n};\n\nexport const format = (value: string): string =>\n value\n .replace(/^(\\d\\d)(\\d)$/, '$1.$2') // 121 => 12.1\n .replace(/^(\\d\\d)\\.(\\d\\d)(\\d)$/, '$1.$2.$3') // 12.122 => 12.12.2\n .replace(/^(\\d\\d)\\d\\.(.*)/, '$1.$2') // 123.12.2005 => 12.12.2005\n .replace(/^(\\d\\d\\.\\d\\d)\\d\\.(.*)/, '$1.$2') // 12.123.2005 => 12.12.2005\n .replace(/\\.$/, '') // 12. => 12\n .replace(/\\ $/, '') // 1 2 => 12\n .replace(/\\:$/, '') // 1:2 => 12\n .replace(/^(\\d\\d)(\\d.*)/, '$1.$2') // 1212 => 12.12\n .replace(/^(\\d\\d.\\d\\d)(\\d.*)/, '$1.$2') // 12.122 => 12.12.2\n .replace(/^(\\d\\d\\.\\d\\d)(\\d\\d\\d\\d)/, '$1.$2') // 12.122005 => 12.12.2005\n .replace(/^(\\d\\d)(\\d\\d\\.\\d\\d\\d\\d)/, '$1.$2') // 1212.2005 => 12.12.2005\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d),/, '$1') // 12.12.2005 => 12.12.2005\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d)(\\d)/, '$1, $2') // 12.12.20050 => 12.12.2005, 0\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d),(\\d.*)/, '$1, $2') // 12.12.2005,00:00 => 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d) (\\d.*)/, '$1, $2') // 12.12.2005 00:00 => 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d)(\\d.*)/, '$1, $2') // 12.12.200500:00=> 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d), (\\d\\d):/, '$1, $2') // 12.12.2005, 00: => 12.12.2005, 00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d), (\\d\\d)(\\d)/, '$1, $2:$3') // 12.12.2005, 000 => 12.12.2005, 00:0\n .replace(/^(\\d\\.\\d\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 1.12.2005123123 => 1.12.2005\n .replace(/^(\\d\\d\\.\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 01.2.20055125125 => 01.2.2005\n .replace(/^(\\d)\\.(\\d\\d)([0-9]*)\\.(\\d\\d\\d\\d)/, '$1.$2.$4') // 1.123123.2005 => 1.12.2005\n .replace(/^(\\d\\.\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 1.2.20055125125 => 1.2.2005\n .replace(/^(\\d\\d)\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // 01..2005123123 => 01..2005\n .replace(/^(\\d)\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // 1..2005123123 => 1..2005\n .replace(/^()\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // ..2005123123 => ..2005\n .replace(/^()\\.(\\d)\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3'); // .2.2005123123 => .2.2005\n\nexport const parseTimestampToDate = (timestamp: number): string => {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n\n let month: number | string = date.getMonth() + 1;\n let day: number | string = date.getDate();\n\n if (month < 10) {\n month = `0${month}`;\n }\n if (day < 10) {\n day = `0${day}`;\n }\n\n return `${day}.${month}.${year}`;\n};\n\nexport const getDateWithoutTime = (value: string): Date => {\n const valueArr = value.split(', ');\n\n let day;\n let month;\n let year;\n\n if (valueArr[0]) {\n const date = valueArr[0].split('.');\n\n [day, month, year] = date;\n }\n\n const date = new Date();\n\n date.setFullYear(Number(year), Number(month) - 1, Number(day));\n date.setHours(0, 0, 0, 0);\n\n return date;\n};\n\nexport const getFullDateTime = (value: string): Date => {\n const valueArr = value.split(', ');\n\n let day;\n let month;\n let year;\n let hours;\n let mins;\n\n if (valueArr[0]) {\n const date = valueArr[0].split('.');\n\n [day, month, year] = date;\n }\n if (valueArr[1]) {\n const time = valueArr[1].split(':');\n\n hours = Number(time[0]);\n mins = Number(time[1]);\n }\n\n const fullDate = new Date();\n\n fullDate.setFullYear(Number(year), Number(month) - 1, Number(day));\n fullDate.setHours(Number(hours) || 0);\n fullDate.setMinutes(Number(mins) || 0);\n fullDate.setSeconds(0);\n fullDate.setMilliseconds(0);\n\n return fullDate;\n};\n\nexport const addTimeToDate = (value: string): string => {\n if (value.length === 10 && dateFnsIsValid(parseDateString(value))) {\n return `${value}, 00:00`;\n }\n\n return value;\n};\n"],"names":["dateFnsIsValid"],"mappings":";;AAAA;AAIO,IAAM,WAAW,GAAG;AACpB,IAAM,SAAS,GAAG;IACrB,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IAC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,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAClE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtC,IAAA,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AACtB,IAAA,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;AAE3B,IAAA,OAAO,QAAQ;AACnB;AAEO,IAAM,aAAa,GAAG,UAAC,KAAa,EAAA;AACvC,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,IAAIA,SAAc,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/D,OAAO,EAAA,CAAA,MAAA,CAAG,KAAK,EAAA,SAAA,CAAS;IAC5B;AAEA,IAAA,OAAO,KAAK;AAChB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.mobile.js","sources":["../src/mobile/Component.mobile.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarMobile } from '@alfalab/core-components-calendar/mobile';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputMobile } from '@alfalab/core-components-input/mobile';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\nexport const DateTimeInputMobile = forwardRef<HTMLInputElement, DateTimeInputMobileProps>(\n (props, ref) => (\n <DateTimeInput\n InputComponent={InputMobile}\n Calendar={CalendarMobile}\n view='mobile'\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":["forwardRef","React","DateTimeInput","__assign","InputMobile","CalendarMobile"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Component.mobile.js","sources":["../src/mobile/Component.mobile.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarMobile } from '@alfalab/core-components-calendar/mobile';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputMobile } from '@alfalab/core-components-input/mobile';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\nexport const DateTimeInputMobile = forwardRef<HTMLInputElement, DateTimeInputMobileProps>(\n (props, ref) => (\n <DateTimeInput\n InputComponent={InputMobile}\n Calendar={CalendarMobile}\n view='mobile'\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":["forwardRef","React","DateTimeInput","__assign","InputMobile","CalendarMobile"],"mappings":";;;;;;;;;;;;;;AAWO,IAAM,mBAAmB,GAAGA,gBAAU,CACzC,UAAC,KAAK,EAAE,GAAG,IAAK,QACZC,qCAACC,uBAAa,EAAAC,cAAA,CAAA,EACV,cAAc,EAAEC,oBAAW,EAC3B,QAAQ,EAAEC,qBAAc,EACxB,IAAI,EAAC,QAAQ,EAAA,EACT,KAAK,EAAA,EACT,GAAG,EAAE,GAAG,EAAA,CAAA,CACV,EACL,CARe,CAQf;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.responsive.js","sources":["../src/Component.responsive.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { useIsDesktop } from '@alfalab/core-components-mq';\n\nimport { type DateTimeInputProps } from './components/date-time-input/Component';\nimport { DateTimeInputDesktop } from './desktop';\nimport { DateTimeInputMobile } from './mobile';\n\nexport type DateTimeInputResponsiveProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'> & {\n /**\n * Контрольная точка, с нее начинается desktop версия\n * @default 1024\n */\n breakpoint?: number;\n\n /**\n * Версия, которая будет использоваться при серверном рендеринге\n */\n client?: 'desktop' | 'mobile';\n};\n\nexport type DateTimeInputMedia = 'desktop' | 'mobile';\n\nexport const DateTimeInputResponsive = forwardRef<HTMLInputElement, DateTimeInputResponsiveProps>(\n ({ breakpoint, client, ...restProps }, ref) => {\n const isDesktop = useIsDesktop(breakpoint, client === 'desktop');\n\n return isDesktop ? (\n <DateTimeInputDesktop {...restProps} ref={ref} />\n ) : (\n <DateTimeInputMobile {...restProps} ref={ref} />\n );\n },\n);\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Component.responsive.js","sources":["../src/Component.responsive.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { useIsDesktop } from '@alfalab/core-components-mq';\n\nimport { type DateTimeInputProps } from './components/date-time-input/Component';\nimport { DateTimeInputDesktop } from './desktop';\nimport { DateTimeInputMobile } from './mobile';\n\nexport type DateTimeInputResponsiveProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'> & {\n /**\n * Контрольная точка, с нее начинается desktop версия\n * @default 1024\n */\n breakpoint?: number;\n\n /**\n * Версия, которая будет использоваться при серверном рендеринге\n */\n client?: 'desktop' | 'mobile';\n};\n\nexport type DateTimeInputMedia = 'desktop' | 'mobile';\n\nexport const DateTimeInputResponsive = forwardRef<HTMLInputElement, DateTimeInputResponsiveProps>(\n ({ breakpoint, client, ...restProps }, ref) => {\n const isDesktop = useIsDesktop(breakpoint, client === 'desktop');\n\n return isDesktop ? (\n <DateTimeInputDesktop {...restProps} ref={ref} />\n ) : (\n <DateTimeInputMobile {...restProps} ref={ref} />\n );\n },\n);\n"],"names":[],"mappings":";;;;;AAyBO,MAAM,uBAAuB,GAAG,UAAU,CAC7C,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,EAAE,GAAG,KAAI;IAC1C,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,KAAK,SAAS,CAAC;AAEhE,IAAA,OAAO,SAAS,IACZ,KAAA,CAAA,aAAA,CAAC,oBAAoB,EAAA,EAAA,GAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAA,CAAI,KAEjD,KAAA,CAAA,aAAA,CAAC,mBAAmB,EAAA,EAAA,GAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAA,CAAI,CACnD;AACL,CAAC;;"}
|
|
@@ -121,18 +121,14 @@ const DateTimeInput = React.forwardRef(({ className, inputClassName, popoverClas
|
|
|
121
121
|
inputRef.current.focus();
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
-
const renderCalendar = () => Calendar ? (
|
|
125
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
126
|
-
React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
124
|
+
const renderCalendar = () => Calendar ? (React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
127
125
|
React.createElement(Calendar, { ...calendarProps, responsive: calendarResponsive, open: open, onClose: handleMobileCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, value: checkInputValueIsValid(value) ? calendarValue : undefined, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events }))) : null;
|
|
128
126
|
return (React.createElement("div", { className: cn(styles.component, className, {
|
|
129
127
|
[styles.block]: block,
|
|
130
128
|
}), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
131
129
|
InputComponent ? (React.createElement(InputComponent, { autoComplete: picker ? 'off' : undefined, ...restProps, block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, disableUserInput: disableUserInput, error: error, rightAddons: React.createElement(React.Fragment, null,
|
|
132
130
|
rightAddons,
|
|
133
|
-
shouldShowPicker && (
|
|
134
|
-
// eslint-disable-next-line jsx-a11y/control-has-associated-label
|
|
135
|
-
React.createElement(IconButton, { className: styles.calendarIcon, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 48 }))) })) : null,
|
|
131
|
+
shouldShowPicker && (React.createElement(IconButton, { className: styles.calendarIcon, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 48 }))) })) : null,
|
|
136
132
|
picker &&
|
|
137
133
|
(view === 'desktop' ? (React.createElement(Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, {
|
|
138
134
|
[styles.calendarResponsive]: calendarResponsive,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../../../src/components/date-time-input/Component.tsx"],"sourcesContent":["/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */\n\nimport React, {\n type ChangeEvent,\n type ElementType,\n type FocusEvent,\n type MouseEvent,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport { type CalendarDesktopProps } from '@alfalab/core-components-calendar/desktop';\nimport { type CalendarMobileProps } from '@alfalab/core-components-calendar/mobile';\nimport { dateInLimits } from '@alfalab/core-components-calendar/shared';\nimport { IconButton } from '@alfalab/core-components-icon-button';\nimport { type InputProps } from '@alfalab/core-components-input';\nimport { Popover, type PopoverProps } from '@alfalab/core-components-popover';\nimport { useDidUpdateEffect } from '@alfalab/hooks';\nimport { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';\n\nimport {\n addTimeToDate,\n DATE_WITH_TIME_LENGTH,\n format,\n getDateWithoutTime,\n getFullDateTime,\n isCompleteDateInput,\n isValid,\n parseTimestampToDate,\n} from '../../utils';\n\nimport styles from './index.module.css';\n\nexport type DateTimeInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Дополнительный класс\n */\n className?: string;\n\n /**\n * Дополнительный класс для инпута\n */\n inputClassName?: string;\n\n /**\n * Дополнительный класс для поповера\n */\n popoverClassName?: string;\n\n /**\n * Обработчик изменения значения\n */\n picker?: boolean;\n\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement> | null,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement> | null,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Компонент календаря\n */\n Calendar?: ElementType;\n\n /**\n * Доп. пропсы для календаря\n */\n calendarProps?:\n | (CalendarDesktopProps & Record<string, unknown>)\n | (CalendarMobileProps & Record<string, unknown>);\n\n /**\n * Месяц в календаре по умолчанию (timestamp)\n */\n defaultMonth?: number;\n\n /**\n * Минимальная дата, доступная для выбора (timestamp)\n */\n minDate?: number;\n\n /**\n * Максимальная дата, доступная для выбора (timestamp)\n */\n maxDate?: number;\n\n /**\n * Список событий\n */\n events?: Array<Date | number>;\n\n /**\n * Список выходных\n */\n offDays?: Array<Date | number>;\n\n /**\n * Состояние открытия по умолчанию\n */\n defaultOpen?: boolean;\n\n /**\n * Позиционирование поповера с календарем\n */\n popoverPosition?: PopoverProps['position'];\n\n /**\n * z-index Popover\n */\n zIndexPopover?: PopoverProps['zIndex'];\n\n /**\n * Запрещает поповеру менять свою позицию.\n * Например, если места снизу недостаточно,то он все равно будет показан снизу\n */\n preventFlip?: boolean;\n\n /**\n * Календарь будет принимать ширину инпута\n */\n useAnchorWidth?: boolean;\n\n /**\n * Растягивает компонент на ширину контейнера\n */\n block?: boolean;\n\n /**\n * Отображение компонента в мобильном или десктопном виде\n */\n view?: 'desktop' | 'mobile';\n\n /**\n * Компонент инпута\n */\n InputComponent?: ElementType;\n\n /**\n * Запретить ввод с клавиатуры\n */\n disableUserInput?: boolean;\n};\n\nexport const DateTimeInput = React.forwardRef<HTMLInputElement, DateTimeInputProps>(\n (\n {\n className,\n inputClassName,\n popoverClassName,\n disabled,\n readOnly,\n disableUserInput = false,\n picker,\n defaultValue = '',\n value: propValue,\n onChange,\n onComplete,\n rightAddons,\n useAnchorWidth,\n block,\n popoverPosition = 'bottom-start',\n zIndexPopover,\n preventFlip,\n InputComponent,\n Calendar,\n calendarProps = {},\n defaultMonth,\n minDate = calendarProps.minDate,\n maxDate = calendarProps.maxDate,\n offDays = calendarProps.offDays || [],\n events = calendarProps.events || [],\n defaultOpen = false,\n error,\n view = 'desktop',\n ...restProps\n },\n ref,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const calendarRef = useRef<HTMLDivElement>(null);\n\n const [value, setValue] = useState(propValue || defaultValue);\n const [open, setOpen] = useState(false);\n\n const calendarValue = value ? getDateWithoutTime(value).getTime() : undefined;\n\n const inputDisabled = disabled || readOnly;\n const shouldShowPicker = picker && !disabled && !readOnly;\n\n const calendarResponsive = calendarProps?.responsive ?? true;\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n useDidUpdateEffect(() => {\n const newPropValue = propValue || '';\n\n setValue((prevValue) => (prevValue === propValue ? prevValue : newPropValue));\n }, [propValue]);\n\n const checkInputValueIsValid = (newInputValue?: string) => {\n if (!newInputValue || error) return false;\n\n const dateValue = getDateWithoutTime(newInputValue).getTime();\n\n return (\n dateValue &&\n dateInLimits(dateValue, minDate, maxDate) &&\n !offDays.includes(dateValue)\n );\n };\n\n const setTimeToDate = () => {\n setValue((prevValue) => {\n const dateWithTime = addTimeToDate(prevValue);\n\n if (dateWithTime !== prevValue && dateWithTime.length === DATE_WITH_TIME_LENGTH) {\n onComplete?.(null, {\n date: getFullDateTime(dateWithTime),\n value: dateWithTime,\n });\n }\n\n return dateWithTime;\n });\n };\n\n const handleInputWrapperFocus = (event: FocusEvent<HTMLDivElement>) => {\n if (view === 'desktop') {\n if (picker) {\n setOpen(true);\n }\n if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {\n calendarRef.current.focus();\n }\n }\n };\n\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (view === 'desktop') {\n const target = (event.relatedTarget || document.activeElement) as HTMLElement;\n\n if (calendarRef.current && calendarRef.current.contains(target) === false) {\n setOpen(false);\n setTimeToDate();\n }\n }\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n\n if (newValue.length > DATE_WITH_TIME_LENGTH) return;\n\n // Позволяем вводить только цифры, точки, запятую, двоеточие и пробел\n if (/[^\\d., :]/.test(newValue)) {\n return;\n }\n\n const dots = newValue.match(/\\./g);\n const colon = newValue.match(/:/g);\n const comma = newValue.match(/,/g);\n\n // Не даем вводить больше, чем 2 точки, 1 двоеточие и 1 запятую\n if (\n (dots && dots.length > 2) ||\n (colon && colon.length > 1) ||\n (comma && comma.length > 1)\n ) {\n return;\n }\n\n const formattedValue = format(newValue);\n const date = getFullDateTime(formattedValue);\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { date, value: formattedValue });\n\n if (isCompleteDateInput(formattedValue)) {\n const valid = isValid(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) {\n onComplete(event, { date, value: formattedValue });\n }\n }\n };\n\n const handleMobileCalendarClose = () => {\n setOpen(false);\n setTimeToDate();\n };\n\n const handleClear = () => {\n setValue('');\n };\n\n const handleCalendarChange = (date?: number) => {\n if (date) {\n const newValue = parseTimestampToDate(date);\n\n setValue(newValue);\n onChange?.(null, { date: getFullDateTime(newValue), value: newValue });\n }\n };\n\n const handleCalendarWrapperMouseDown = (event: MouseEvent<HTMLDivElement>) => {\n // Не дает инпуту терять фокус при выборе даты\n event.preventDefault();\n };\n\n const handleIconButtonClick = () => {\n if (!open) setOpen(true);\n\n if (view === 'desktop' && inputRef.current) {\n inputRef.current.focus();\n }\n };\n\n const renderCalendar = () =>\n Calendar ? (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div onMouseDown={handleCalendarWrapperMouseDown}>\n <Calendar\n {...calendarProps}\n responsive={calendarResponsive}\n open={open}\n onClose={handleMobileCalendarClose}\n ref={calendarRef}\n defaultMonth={defaultMonth}\n value={checkInputValueIsValid(value) ? calendarValue : undefined}\n onChange={handleCalendarChange}\n minDate={minDate}\n maxDate={maxDate}\n offDays={offDays}\n events={events}\n />\n </div>\n ) : null;\n\n return (\n <div\n className={cn(styles.component, className, {\n [styles.block]: block,\n })}\n onFocus={inputDisabled ? undefined : handleInputWrapperFocus}\n onBlur={handleBlur}\n >\n {InputComponent ? (\n <InputComponent\n autoComplete={picker ? 'off' : undefined}\n {...restProps}\n block={block}\n ref={mergeRefs([ref, inputRef])}\n value={value}\n onChange={handleChange}\n disabled={disabled}\n readOnly={readOnly}\n className={inputClassName}\n onClear={handleClear}\n disableUserInput={disableUserInput}\n error={error}\n rightAddons={\n <React.Fragment>\n {rightAddons}\n {shouldShowPicker && (\n // eslint-disable-next-line jsx-a11y/control-has-associated-label\n <IconButton\n className={styles.calendarIcon}\n onClick={inputDisabled ? undefined : handleIconButtonClick}\n icon={CalendarMIcon}\n size={48}\n />\n )}\n </React.Fragment>\n }\n />\n ) : null}\n {picker &&\n (view === 'desktop' ? (\n <Popover\n open={open}\n useAnchorWidth={useAnchorWidth}\n anchorElement={inputRef.current as HTMLElement}\n popperClassName={cn(styles.calendarContainer, {\n [styles.calendarResponsive]: calendarResponsive,\n })}\n className={popoverClassName}\n position={popoverPosition}\n offset={[0, 8]}\n withTransition={false}\n preventFlip={preventFlip}\n zIndex={zIndexPopover}\n >\n {renderCalendar()}\n </Popover>\n ) : (\n renderCalendar()\n ))}\n </div>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;MA6Ja,aAAa,GAAG,KAAK,CAAC,UAAU,CACzC,CACI,EACI,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,gBAAgB,GAAG,KAAK,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,KAAK,EAAE,SAAS,EAChB,QAAQ,EACR,UAAU,EACV,WAAW,EACX,cAAc,EACd,KAAK,EACL,eAAe,GAAG,cAAc,EACh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AAc,EAAE,cAAc,EAC9B,aAAa,EAAE,QAAQ,CAAC,OAAsB,EAC9C,eAAe,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,EAAE;AAC1C,oBAAA,CAAC,MAAM,CAAC,kBAAkB,GAAG,kBAAkB;AAClD,iBAAA,CAAC,EACF,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EACd,cAAc,EAAE,KAAK,EACrB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,aAAa,EAEpB,EAAA,cAAc,EAAE,CACX,KAEV,cAAc,EAAE,CACnB,CAAC,CACJ;AAEd,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../../../src/components/date-time-input/Component.tsx"],"sourcesContent":["/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */\n\nimport React, {\n type ChangeEvent,\n type ElementType,\n type FocusEvent,\n type MouseEvent,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport { type CalendarDesktopProps } from '@alfalab/core-components-calendar/desktop';\nimport { type CalendarMobileProps } from '@alfalab/core-components-calendar/mobile';\nimport { dateInLimits } from '@alfalab/core-components-calendar/shared';\nimport { IconButton } from '@alfalab/core-components-icon-button';\nimport { type InputProps } from '@alfalab/core-components-input';\nimport { Popover, type PopoverProps } from '@alfalab/core-components-popover';\nimport { useDidUpdateEffect } from '@alfalab/hooks';\nimport { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';\n\nimport {\n addTimeToDate,\n DATE_WITH_TIME_LENGTH,\n format,\n getDateWithoutTime,\n getFullDateTime,\n isCompleteDateInput,\n isValid,\n parseTimestampToDate,\n} from '../../utils';\n\nimport styles from './index.module.css';\n\nexport type DateTimeInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Дополнительный класс\n */\n className?: string;\n\n /**\n * Дополнительный класс для инпута\n */\n inputClassName?: string;\n\n /**\n * Дополнительный класс для поповера\n */\n popoverClassName?: string;\n\n /**\n * Обработчик изменения значения\n */\n picker?: boolean;\n\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement> | null,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement> | null,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Компонент календаря\n */\n Calendar?: ElementType;\n\n /**\n * Доп. пропсы для календаря\n */\n calendarProps?:\n | (CalendarDesktopProps & Record<string, unknown>)\n | (CalendarMobileProps & Record<string, unknown>);\n\n /**\n * Месяц в календаре по умолчанию (timestamp)\n */\n defaultMonth?: number;\n\n /**\n * Минимальная дата, доступная для выбора (timestamp)\n */\n minDate?: number;\n\n /**\n * Максимальная дата, доступная для выбора (timestamp)\n */\n maxDate?: number;\n\n /**\n * Список событий\n */\n events?: Array<Date | number>;\n\n /**\n * Список выходных\n */\n offDays?: Array<Date | number>;\n\n /**\n * Состояние открытия по умолчанию\n */\n defaultOpen?: boolean;\n\n /**\n * Позиционирование поповера с календарем\n */\n popoverPosition?: PopoverProps['position'];\n\n /**\n * z-index Popover\n */\n zIndexPopover?: PopoverProps['zIndex'];\n\n /**\n * Запрещает поповеру менять свою позицию.\n * Например, если места снизу недостаточно,то он все равно будет показан снизу\n */\n preventFlip?: boolean;\n\n /**\n * Календарь будет принимать ширину инпута\n */\n useAnchorWidth?: boolean;\n\n /**\n * Растягивает компонент на ширину контейнера\n */\n block?: boolean;\n\n /**\n * Отображение компонента в мобильном или десктопном виде\n */\n view?: 'desktop' | 'mobile';\n\n /**\n * Компонент инпута\n */\n InputComponent?: ElementType;\n\n /**\n * Запретить ввод с клавиатуры\n */\n disableUserInput?: boolean;\n};\n\nexport const DateTimeInput = React.forwardRef<HTMLInputElement, DateTimeInputProps>(\n (\n {\n className,\n inputClassName,\n popoverClassName,\n disabled,\n readOnly,\n disableUserInput = false,\n picker,\n defaultValue = '',\n value: propValue,\n onChange,\n onComplete,\n rightAddons,\n useAnchorWidth,\n block,\n popoverPosition = 'bottom-start',\n zIndexPopover,\n preventFlip,\n InputComponent,\n Calendar,\n calendarProps = {},\n defaultMonth,\n minDate = calendarProps.minDate,\n maxDate = calendarProps.maxDate,\n offDays = calendarProps.offDays || [],\n events = calendarProps.events || [],\n defaultOpen = false,\n error,\n view = 'desktop',\n ...restProps\n },\n ref,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const calendarRef = useRef<HTMLDivElement>(null);\n\n const [value, setValue] = useState(propValue || defaultValue);\n const [open, setOpen] = useState(false);\n\n const calendarValue = value ? getDateWithoutTime(value).getTime() : undefined;\n\n const inputDisabled = disabled || readOnly;\n const shouldShowPicker = picker && !disabled && !readOnly;\n\n const calendarResponsive = calendarProps?.responsive ?? true;\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n useDidUpdateEffect(() => {\n const newPropValue = propValue || '';\n\n setValue((prevValue) => (prevValue === propValue ? prevValue : newPropValue));\n }, [propValue]);\n\n const checkInputValueIsValid = (newInputValue?: string) => {\n if (!newInputValue || error) return false;\n\n const dateValue = getDateWithoutTime(newInputValue).getTime();\n\n return (\n dateValue &&\n dateInLimits(dateValue, minDate, maxDate) &&\n !offDays.includes(dateValue)\n );\n };\n\n const setTimeToDate = () => {\n setValue((prevValue) => {\n const dateWithTime = addTimeToDate(prevValue);\n\n if (dateWithTime !== prevValue && dateWithTime.length === DATE_WITH_TIME_LENGTH) {\n onComplete?.(null, {\n date: getFullDateTime(dateWithTime),\n value: dateWithTime,\n });\n }\n\n return dateWithTime;\n });\n };\n\n const handleInputWrapperFocus = (event: FocusEvent<HTMLDivElement>) => {\n if (view === 'desktop') {\n if (picker) {\n setOpen(true);\n }\n if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {\n calendarRef.current.focus();\n }\n }\n };\n\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (view === 'desktop') {\n const target = (event.relatedTarget || document.activeElement) as HTMLElement;\n\n if (calendarRef.current && calendarRef.current.contains(target) === false) {\n setOpen(false);\n setTimeToDate();\n }\n }\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n\n if (newValue.length > DATE_WITH_TIME_LENGTH) return;\n\n // Позволяем вводить только цифры, точки, запятую, двоеточие и пробел\n if (/[^\\d., :]/.test(newValue)) {\n return;\n }\n\n const dots = newValue.match(/\\./g);\n const colon = newValue.match(/:/g);\n const comma = newValue.match(/,/g);\n\n // Не даем вводить больше, чем 2 точки, 1 двоеточие и 1 запятую\n if (\n (dots && dots.length > 2) ||\n (colon && colon.length > 1) ||\n (comma && comma.length > 1)\n ) {\n return;\n }\n\n const formattedValue = format(newValue);\n const date = getFullDateTime(formattedValue);\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { date, value: formattedValue });\n\n if (isCompleteDateInput(formattedValue)) {\n const valid = isValid(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) {\n onComplete(event, { date, value: formattedValue });\n }\n }\n };\n\n const handleMobileCalendarClose = () => {\n setOpen(false);\n setTimeToDate();\n };\n\n const handleClear = () => {\n setValue('');\n };\n\n const handleCalendarChange = (date?: number) => {\n if (date) {\n const newValue = parseTimestampToDate(date);\n\n setValue(newValue);\n onChange?.(null, { date: getFullDateTime(newValue), value: newValue });\n }\n };\n\n const handleCalendarWrapperMouseDown = (event: MouseEvent<HTMLDivElement>) => {\n // Не дает инпуту терять фокус при выборе даты\n event.preventDefault();\n };\n\n const handleIconButtonClick = () => {\n if (!open) setOpen(true);\n\n if (view === 'desktop' && inputRef.current) {\n inputRef.current.focus();\n }\n };\n\n const renderCalendar = () =>\n Calendar ? (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div onMouseDown={handleCalendarWrapperMouseDown}>\n <Calendar\n {...calendarProps}\n responsive={calendarResponsive}\n open={open}\n onClose={handleMobileCalendarClose}\n ref={calendarRef}\n defaultMonth={defaultMonth}\n value={checkInputValueIsValid(value) ? calendarValue : undefined}\n onChange={handleCalendarChange}\n minDate={minDate}\n maxDate={maxDate}\n offDays={offDays}\n events={events}\n />\n </div>\n ) : null;\n\n return (\n <div\n className={cn(styles.component, className, {\n [styles.block]: block,\n })}\n onFocus={inputDisabled ? undefined : handleInputWrapperFocus}\n onBlur={handleBlur}\n >\n {InputComponent ? (\n <InputComponent\n autoComplete={picker ? 'off' : undefined}\n {...restProps}\n block={block}\n ref={mergeRefs([ref, inputRef])}\n value={value}\n onChange={handleChange}\n disabled={disabled}\n readOnly={readOnly}\n className={inputClassName}\n onClear={handleClear}\n disableUserInput={disableUserInput}\n error={error}\n rightAddons={\n <React.Fragment>\n {rightAddons}\n {shouldShowPicker && (\n // eslint-disable-next-line jsx-a11y/control-has-associated-label\n <IconButton\n className={styles.calendarIcon}\n onClick={inputDisabled ? undefined : handleIconButtonClick}\n icon={CalendarMIcon}\n size={48}\n />\n )}\n </React.Fragment>\n }\n />\n ) : null}\n {picker &&\n (view === 'desktop' ? (\n <Popover\n open={open}\n useAnchorWidth={useAnchorWidth}\n anchorElement={inputRef.current as HTMLElement}\n popperClassName={cn(styles.calendarContainer, {\n [styles.calendarResponsive]: calendarResponsive,\n })}\n className={popoverClassName}\n position={popoverPosition}\n offset={[0, 8]}\n withTransition={false}\n preventFlip={preventFlip}\n zIndex={zIndexPopover}\n >\n {renderCalendar()}\n </Popover>\n ) : (\n renderCalendar()\n ))}\n </div>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;MA6Ja,aAAa,GAAG,KAAK,CAAC,UAAU,CACzC,CACI,EACI,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,gBAAgB,GAAG,KAAK,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,KAAK,EAAE,SAAS,EAChB,QAAQ,EACR,UAAU,EACV,WAAW,EACX,cAAc,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EAAE,EAAA,CACV,CACL,CACY,EAAA,CAEvB,IACF,IAAI;QACP,MAAM;AACH,aAAC,IAAI,KAAK,SAAS,IACf,KAAA,CAAA,aAAA,CAAC,OAAO,EAAA,EACJ,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,QAAQ,CAAC,OAAsB,EAC9C,eAAe,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,EAAE;AAC1C,oBAAA,CAAC,MAAM,CAAC,kBAAkB,GAAG,kBAAkB;AAClD,iBAAA,CAAC,EACF,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EACd,cAAc,EAAE,KAAK,EACrB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,aAAa,EAAA,EAEpB,cAAc,EAAE,CACX,KAEV,cAAc,EAAE,CACnB,CAAC,CACJ;AAEd,CAAC;;"}
|
|
@@ -13,30 +13,30 @@
|
|
|
13
13
|
:root {
|
|
14
14
|
--calendar-popover-border-radius: var(--border-radius-8);
|
|
15
15
|
}
|
|
16
|
-
.date-time-
|
|
16
|
+
.date-time-input__component_11t63 {
|
|
17
17
|
display: inline-block;
|
|
18
18
|
outline: none;
|
|
19
19
|
position: relative;
|
|
20
20
|
}
|
|
21
|
-
.date-time-
|
|
21
|
+
.date-time-input__calendarContainer_11t63 {
|
|
22
22
|
display: inline-block;
|
|
23
23
|
box-sizing: border-box;
|
|
24
24
|
border-radius: var(--calendar-popover-border-radius);
|
|
25
25
|
border: 1px solid var(--color-light-neutral-300);
|
|
26
26
|
}
|
|
27
27
|
@media (max-width: 374px) {
|
|
28
|
-
.date-time-
|
|
28
|
+
.date-time-input__calendarContainer_11t63 {
|
|
29
29
|
width: 100%;
|
|
30
30
|
min-width: 288px;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
.date-time-
|
|
33
|
+
.date-time-input__calendarResponsive_11t63 {
|
|
34
34
|
width: var(--calendar-width);
|
|
35
35
|
}
|
|
36
|
-
.date-time-
|
|
36
|
+
.date-time-input__block_11t63 {
|
|
37
37
|
width: 100%;
|
|
38
38
|
}
|
|
39
|
-
.date-time-
|
|
39
|
+
.date-time-input__calendarIcon_11t63 {
|
|
40
40
|
margin-right: var(--gap-12-neg);
|
|
41
41
|
height: 100%;
|
|
42
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
|
|
3
|
-
const styles = {"component":"date-time-
|
|
3
|
+
const styles = {"component":"date-time-input__component_11t63","calendarContainer":"date-time-input__calendarContainer_11t63","calendarResponsive":"date-time-input__calendarResponsive_11t63","block":"date-time-input__block_11t63","calendarIcon":"date-time-input__calendarIcon_11t63"};
|
|
4
4
|
|
|
5
5
|
export { styles as default };
|
|
6
6
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":["../../src/components/date-time-input/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n@import '../../../../calendar/src/vars.css';\n\n:root {\n --calendar-popover-border-radius: var(--border-radius-8);\n}\n\n.component {\n display: inline-block;\n outline: none;\n position: relative;\n}\n\n.calendarContainer {\n display: inline-block;\n box-sizing: border-box;\n border-radius: var(--calendar-popover-border-radius);\n border: 1px solid var(--color-light-neutral-300);\n\n @media (max-width: 374px) {\n width: 100%;\n min-width: 288px;\n }\n}\n\n.calendarResponsive {\n width: var(--calendar-width);\n}\n\n.block {\n width: 100%;\n}\n\n.calendarIcon {\n margin-right: var(--gap-12-neg);\n height: 100%;\n}\n"],"names":[],"mappings":";;AAEgB,eAAe,CAAC,WAAW,CAAC,kCAAkC,CAAC,mBAAmB,CAAC,0CAA0C,CAAC,oBAAoB,CAAC,2CAA2C,CAAC,OAAO,CAAC,8BAA8B,CAAC,cAAc,CAAC,qCAAqC,CAAC
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":["../../src/components/date-time-input/index.module.css"],"sourcesContent":["@import '@alfalab/core-components-vars/src/index.css';\n@import '../../../../calendar/src/vars.css';\n\n:root {\n --calendar-popover-border-radius: var(--border-radius-8);\n}\n\n.component {\n display: inline-block;\n outline: none;\n position: relative;\n}\n\n.calendarContainer {\n display: inline-block;\n box-sizing: border-box;\n border-radius: var(--calendar-popover-border-radius);\n border: 1px solid var(--color-light-neutral-300);\n\n @media (max-width: 374px) {\n width: 100%;\n min-width: 288px;\n }\n}\n\n.calendarResponsive {\n width: var(--calendar-width);\n}\n\n.block {\n width: 100%;\n}\n\n.calendarIcon {\n margin-right: var(--gap-12-neg);\n height: 100%;\n}\n"],"names":[],"mappings":";;AAEgB,eAAe,CAAC,WAAW,CAAC,kCAAkC,CAAC,mBAAmB,CAAC,0CAA0C,CAAC,oBAAoB,CAAC,2CAA2C,CAAC,OAAO,CAAC,8BAA8B,CAAC,cAAc,CAAC,qCAAqC,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.desktop.js","sources":["../../src/desktop/Component.desktop.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarDesktop } from '@alfalab/core-components-calendar/desktop';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputDesktop } from '@alfalab/core-components-input/desktop';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputDesktopProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const DateTimeInputDesktop = forwardRef<HTMLInputElement, DateTimeInputDesktopProps>(\n (props, ref) => (\n <DateTimeInput\n Calendar={CalendarDesktop}\n InputComponent={InputDesktop}\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;AAWA;;;AAGG;AACI,MAAM,oBAAoB,GAAG,UAAU,CAC1C,CAAC,KAAK,EAAE,GAAG,MACP,
|
|
1
|
+
{"version":3,"file":"Component.desktop.js","sources":["../../src/desktop/Component.desktop.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarDesktop } from '@alfalab/core-components-calendar/desktop';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputDesktop } from '@alfalab/core-components-input/desktop';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputDesktopProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const DateTimeInputDesktop = forwardRef<HTMLInputElement, DateTimeInputDesktopProps>(\n (props, ref) => (\n <DateTimeInput\n Calendar={CalendarDesktop}\n InputComponent={InputDesktop}\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;AAWA;;;AAGG;AACI,MAAM,oBAAoB,GAAG,UAAU,CAC1C,CAAC,KAAK,EAAE,GAAG,MACP,KAAA,CAAA,aAAA,CAAC,aAAa,EAAA,EACV,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,YAAY,EAAA,GACxB,KAAK,EACT,GAAG,EAAE,GAAG,EAAA,CACV,CACL;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.mobile.js","sources":["../../src/mobile/Component.mobile.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarMobile } from '@alfalab/core-components-calendar/mobile';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputMobile } from '@alfalab/core-components-input/mobile';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\nexport const DateTimeInputMobile = forwardRef<HTMLInputElement, DateTimeInputMobileProps>(\n (props, ref) => (\n <DateTimeInput\n InputComponent={InputMobile}\n Calendar={CalendarMobile}\n view='mobile'\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Component.mobile.js","sources":["../../src/mobile/Component.mobile.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarMobile } from '@alfalab/core-components-calendar/mobile';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputMobile } from '@alfalab/core-components-input/mobile';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\nexport const DateTimeInputMobile = forwardRef<HTMLInputElement, DateTimeInputMobileProps>(\n (props, ref) => (\n <DateTimeInput\n InputComponent={InputMobile}\n Calendar={CalendarMobile}\n view='mobile'\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;AAWO,MAAM,mBAAmB,GAAG,UAAU,CACzC,CAAC,KAAK,EAAE,GAAG,MACP,KAAA,CAAA,aAAA,CAAC,aAAa,EAAA,EACV,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,QAAQ,EAAA,GACT,KAAK,EACT,GAAG,EAAE,GAAG,EAAA,CACV,CACL;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sources":["../../src/utils/format.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nimport { isValid as dateFnsIsValid, parse } from 'date-fns';\n\nexport const DATE_FORMAT = 'dd.MM.yyyy';\nexport const DATE_MASK = [\n /\\d/,\n /\\d/,\n '.',\n /\\d/,\n /\\d/,\n '.',\n /\\d/,\n /\\d/,\n /\\d/,\n /\\d/,\n ',',\n ' ',\n /\\d/,\n /\\d/,\n ':',\n /\\d/,\n /\\d/,\n];\n\nexport const DATE_WITH_TIME_LENGTH = DATE_MASK.length;\nexport const isCompleteDateInput = (input: string) => input.length === DATE_WITH_TIME_LENGTH;\nexport const parseDateString = (value: string, dateFormat = DATE_FORMAT) =>\n parse(value, dateFormat, new Date());\nexport const isValidTimeFormat = (value: string): boolean => {\n const timeArr = value.split(':');\n const hours = timeArr[0];\n const mins = timeArr[1];\n\n if (hours.length !== 2 || Number(hours) > 23) {\n return false;\n }\n\n if (mins.length !== 2 || Number(mins) > 59) {\n return false;\n }\n\n return true;\n};\n\nexport const isValid = (inputValue: string) => {\n const inputValueArr = inputValue.split(', ');\n const date = inputValueArr[0];\n const time = inputValueArr[1];\n\n return (\n !inputValue ||\n (isCompleteDateInput(inputValue) &&\n dateFnsIsValid(parseDateString(date)) &&\n isValidTimeFormat(time))\n );\n};\n\nexport const format = (value: string): string =>\n value\n .replace(/^(\\d\\d)(\\d)$/, '$1.$2') // 121 => 12.1\n .replace(/^(\\d\\d)\\.(\\d\\d)(\\d)$/, '$1.$2.$3') // 12.122 => 12.12.2\n .replace(/^(\\d\\d)\\d\\.(.*)/, '$1.$2') // 123.12.2005 => 12.12.2005\n .replace(/^(\\d\\d\\.\\d\\d)\\d\\.(.*)/, '$1.$2') // 12.123.2005 => 12.12.2005\n .replace(/\\.$/, '') // 12. => 12\n .replace(/\\ $/, '') // 1 2 => 12\n .replace(/\\:$/, '') // 1:2 => 12\n .replace(/^(\\d\\d)(\\d.*)/, '$1.$2') // 1212 => 12.12\n .replace(/^(\\d\\d.\\d\\d)(\\d.*)/, '$1.$2') // 12.122 => 12.12.2\n .replace(/^(\\d\\d\\.\\d\\d)(\\d\\d\\d\\d)/, '$1.$2') // 12.122005 => 12.12.2005\n .replace(/^(\\d\\d)(\\d\\d\\.\\d\\d\\d\\d)/, '$1.$2') // 1212.2005 => 12.12.2005\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d),/, '$1') // 12.12.2005 => 12.12.2005\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d)(\\d)/, '$1, $2') // 12.12.20050 => 12.12.2005, 0\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d),(\\d.*)/, '$1, $2') // 12.12.2005,00:00 => 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d) (\\d.*)/, '$1, $2') // 12.12.2005 00:00 => 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d)(\\d.*)/, '$1, $2') // 12.12.200500:00=> 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d), (\\d\\d):/, '$1, $2') // 12.12.2005, 00: => 12.12.2005, 00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d), (\\d\\d)(\\d)/, '$1, $2:$3') // 12.12.2005, 000 => 12.12.2005, 00:0\n .replace(/^(\\d\\.\\d\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 1.12.2005123123 => 1.12.2005\n .replace(/^(\\d\\d\\.\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 01.2.20055125125 => 01.2.2005\n .replace(/^(\\d)\\.(\\d\\d)([0-9]*)\\.(\\d\\d\\d\\d)/, '$1.$2.$4') // 1.123123.2005 => 1.12.2005\n .replace(/^(\\d\\.\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 1.2.20055125125 => 1.2.2005\n .replace(/^(\\d\\d)\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // 01..2005123123 => 01..2005\n .replace(/^(\\d)\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // 1..2005123123 => 1..2005\n .replace(/^()\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // ..2005123123 => ..2005\n .replace(/^()\\.(\\d)\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3'); // .2.2005123123 => .2.2005\n\nexport const parseTimestampToDate = (timestamp: number): string => {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n\n let month: number | string = date.getMonth() + 1;\n let day: number | string = date.getDate();\n\n if (month < 10) {\n month = `0${month}`;\n }\n if (day < 10) {\n day = `0${day}`;\n }\n\n return `${day}.${month}.${year}`;\n};\n\nexport const getDateWithoutTime = (value: string): Date => {\n const valueArr = value.split(', ');\n\n let day;\n let month;\n let year;\n\n if (valueArr[0]) {\n const date = valueArr[0].split('.');\n\n [day, month, year] = date;\n }\n\n const date = new Date();\n\n date.setFullYear(Number(year), Number(month) - 1, Number(day));\n date.setHours(0, 0, 0, 0);\n\n return date;\n};\n\nexport const getFullDateTime = (value: string): Date => {\n const valueArr = value.split(', ');\n\n let day;\n let month;\n let year;\n let hours;\n let mins;\n\n if (valueArr[0]) {\n const date = valueArr[0].split('.');\n\n [day, month, year] = date;\n }\n if (valueArr[1]) {\n const time = valueArr[1].split(':');\n\n hours = Number(time[0]);\n mins = Number(time[1]);\n }\n\n const fullDate = new Date();\n\n fullDate.setFullYear(Number(year), Number(month) - 1, Number(day));\n fullDate.setHours(Number(hours) || 0);\n fullDate.setMinutes(Number(mins) || 0);\n fullDate.setSeconds(0);\n fullDate.setMilliseconds(0);\n\n return fullDate;\n};\n\nexport const addTimeToDate = (value: string): string => {\n if (value.length === 10 && dateFnsIsValid(parseDateString(value))) {\n return `${value}, 00:00`;\n }\n\n return value;\n};\n"],"names":["dateFnsIsValid"],"mappings":";;AAAA;AAIO,MAAM,WAAW,GAAG;AACd,MAAA,SAAS,GAAG;IACrB,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;;AAGK,MAAA,qBAAqB,GAAG,SAAS,CAAC;AACxC,MAAM,mBAAmB,GAAG,CAAC,KAAa,KAAK,KAAK,CAAC,MAAM,K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AChB;;;;"}
|
|
1
|
+
{"version":3,"file":"format.js","sources":["../../src/utils/format.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\n\nimport { isValid as dateFnsIsValid, parse } from 'date-fns';\n\nexport const DATE_FORMAT = 'dd.MM.yyyy';\nexport const DATE_MASK = [\n /\\d/,\n /\\d/,\n '.',\n /\\d/,\n /\\d/,\n '.',\n /\\d/,\n /\\d/,\n /\\d/,\n /\\d/,\n ',',\n ' ',\n /\\d/,\n /\\d/,\n ':',\n /\\d/,\n /\\d/,\n];\n\nexport const DATE_WITH_TIME_LENGTH = DATE_MASK.length;\nexport const isCompleteDateInput = (input: string) => input.length === DATE_WITH_TIME_LENGTH;\nexport const parseDateString = (value: string, dateFormat = DATE_FORMAT) =>\n parse(value, dateFormat, new Date());\nexport const isValidTimeFormat = (value: string): boolean => {\n const timeArr = value.split(':');\n const hours = timeArr[0];\n const mins = timeArr[1];\n\n if (hours.length !== 2 || Number(hours) > 23) {\n return false;\n }\n\n if (mins.length !== 2 || Number(mins) > 59) {\n return false;\n }\n\n return true;\n};\n\nexport const isValid = (inputValue: string) => {\n const inputValueArr = inputValue.split(', ');\n const date = inputValueArr[0];\n const time = inputValueArr[1];\n\n return (\n !inputValue ||\n (isCompleteDateInput(inputValue) &&\n dateFnsIsValid(parseDateString(date)) &&\n isValidTimeFormat(time))\n );\n};\n\nexport const format = (value: string): string =>\n value\n .replace(/^(\\d\\d)(\\d)$/, '$1.$2') // 121 => 12.1\n .replace(/^(\\d\\d)\\.(\\d\\d)(\\d)$/, '$1.$2.$3') // 12.122 => 12.12.2\n .replace(/^(\\d\\d)\\d\\.(.*)/, '$1.$2') // 123.12.2005 => 12.12.2005\n .replace(/^(\\d\\d\\.\\d\\d)\\d\\.(.*)/, '$1.$2') // 12.123.2005 => 12.12.2005\n .replace(/\\.$/, '') // 12. => 12\n .replace(/\\ $/, '') // 1 2 => 12\n .replace(/\\:$/, '') // 1:2 => 12\n .replace(/^(\\d\\d)(\\d.*)/, '$1.$2') // 1212 => 12.12\n .replace(/^(\\d\\d.\\d\\d)(\\d.*)/, '$1.$2') // 12.122 => 12.12.2\n .replace(/^(\\d\\d\\.\\d\\d)(\\d\\d\\d\\d)/, '$1.$2') // 12.122005 => 12.12.2005\n .replace(/^(\\d\\d)(\\d\\d\\.\\d\\d\\d\\d)/, '$1.$2') // 1212.2005 => 12.12.2005\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d),/, '$1') // 12.12.2005 => 12.12.2005\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d)(\\d)/, '$1, $2') // 12.12.20050 => 12.12.2005, 0\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d),(\\d.*)/, '$1, $2') // 12.12.2005,00:00 => 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d) (\\d.*)/, '$1, $2') // 12.12.2005 00:00 => 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d)(\\d.*)/, '$1, $2') // 12.12.200500:00=> 12.12.2005, 00:00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d), (\\d\\d):/, '$1, $2') // 12.12.2005, 00: => 12.12.2005, 00\n .replace(/^(\\d\\d.\\d\\d\\.\\d\\d\\d\\d), (\\d\\d)(\\d)/, '$1, $2:$3') // 12.12.2005, 000 => 12.12.2005, 00:0\n .replace(/^(\\d\\.\\d\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 1.12.2005123123 => 1.12.2005\n .replace(/^(\\d\\d\\.\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 01.2.20055125125 => 01.2.2005\n .replace(/^(\\d)\\.(\\d\\d)([0-9]*)\\.(\\d\\d\\d\\d)/, '$1.$2.$4') // 1.123123.2005 => 1.12.2005\n .replace(/^(\\d\\.\\d\\.\\d\\d\\d\\d)([0-9]*)/, '$1') // 1.2.20055125125 => 1.2.2005\n .replace(/^(\\d\\d)\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // 01..2005123123 => 01..2005\n .replace(/^(\\d)\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // 1..2005123123 => 1..2005\n .replace(/^()\\.()\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3') // ..2005123123 => ..2005\n .replace(/^()\\.(\\d)\\.(\\d\\d\\d\\d)([0-9]*)/, '$1.$2.$3'); // .2.2005123123 => .2.2005\n\nexport const parseTimestampToDate = (timestamp: number): string => {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n\n let month: number | string = date.getMonth() + 1;\n let day: number | string = date.getDate();\n\n if (month < 10) {\n month = `0${month}`;\n }\n if (day < 10) {\n day = `0${day}`;\n }\n\n return `${day}.${month}.${year}`;\n};\n\nexport const getDateWithoutTime = (value: string): Date => {\n const valueArr = value.split(', ');\n\n let day;\n let month;\n let year;\n\n if (valueArr[0]) {\n const date = valueArr[0].split('.');\n\n [day, month, year] = date;\n }\n\n const date = new Date();\n\n date.setFullYear(Number(year), Number(month) - 1, Number(day));\n date.setHours(0, 0, 0, 0);\n\n return date;\n};\n\nexport const getFullDateTime = (value: string): Date => {\n const valueArr = value.split(', ');\n\n let day;\n let month;\n let year;\n let hours;\n let mins;\n\n if (valueArr[0]) {\n const date = valueArr[0].split('.');\n\n [day, month, year] = date;\n }\n if (valueArr[1]) {\n const time = valueArr[1].split(':');\n\n hours = Number(time[0]);\n mins = Number(time[1]);\n }\n\n const fullDate = new Date();\n\n fullDate.setFullYear(Number(year), Number(month) - 1, Number(day));\n fullDate.setHours(Number(hours) || 0);\n fullDate.setMinutes(Number(mins) || 0);\n fullDate.setSeconds(0);\n fullDate.setMilliseconds(0);\n\n return fullDate;\n};\n\nexport const addTimeToDate = (value: string): string => {\n if (value.length === 10 && dateFnsIsValid(parseDateString(value))) {\n return `${value}, 00:00`;\n }\n\n return value;\n};\n"],"names":["dateFnsIsValid"],"mappings":";;A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I,CAAC,IAAI,CAAC,CAAC;AACtC,IAAA,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AACtB,IAAA,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;AAE3B,IAAA,OAAO,QAAQ;AACnB;AAEO,MAAM,aAAa,GAAG,CAAC,KAAa,KAAY;AACnD,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,IAAIA,SAAc,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/D,OAAO,CAAA,EAAG,KAAK,CAAA,OAAA,CAAS;IAC5B;AAEA,IAAA,OAAO,KAAK;AAChB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.responsive.js","sources":["../src/Component.responsive.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { useIsDesktop } from '@alfalab/core-components-mq';\n\nimport { type DateTimeInputProps } from './components/date-time-input/Component';\nimport { DateTimeInputDesktop } from './desktop';\nimport { DateTimeInputMobile } from './mobile';\n\nexport type DateTimeInputResponsiveProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'> & {\n /**\n * Контрольная точка, с нее начинается desktop версия\n * @default 1024\n */\n breakpoint?: number;\n\n /**\n * Версия, которая будет использоваться при серверном рендеринге\n */\n client?: 'desktop' | 'mobile';\n};\n\nexport type DateTimeInputMedia = 'desktop' | 'mobile';\n\nexport const DateTimeInputResponsive = forwardRef<HTMLInputElement, DateTimeInputResponsiveProps>(\n ({ breakpoint, client, ...restProps }, ref) => {\n const isDesktop = useIsDesktop(breakpoint, client === 'desktop');\n\n return isDesktop ? (\n <DateTimeInputDesktop {...restProps} ref={ref} />\n ) : (\n <DateTimeInputMobile {...restProps} ref={ref} />\n );\n },\n);\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Component.responsive.js","sources":["../src/Component.responsive.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { useIsDesktop } from '@alfalab/core-components-mq';\n\nimport { type DateTimeInputProps } from './components/date-time-input/Component';\nimport { DateTimeInputDesktop } from './desktop';\nimport { DateTimeInputMobile } from './mobile';\n\nexport type DateTimeInputResponsiveProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'> & {\n /**\n * Контрольная точка, с нее начинается desktop версия\n * @default 1024\n */\n breakpoint?: number;\n\n /**\n * Версия, которая будет использоваться при серверном рендеринге\n */\n client?: 'desktop' | 'mobile';\n};\n\nexport type DateTimeInputMedia = 'desktop' | 'mobile';\n\nexport const DateTimeInputResponsive = forwardRef<HTMLInputElement, DateTimeInputResponsiveProps>(\n ({ breakpoint, client, ...restProps }, ref) => {\n const isDesktop = useIsDesktop(breakpoint, client === 'desktop');\n\n return isDesktop ? (\n <DateTimeInputDesktop {...restProps} ref={ref} />\n ) : (\n <DateTimeInputMobile {...restProps} ref={ref} />\n );\n },\n);\n"],"names":[],"mappings":";;;;;AAyBO,MAAM,uBAAuB,GAAG,UAAU,CAC7C,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,EAAE,GAAG,KAAI;IAC1C,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,KAAK,SAAS,CAAC;AAEhE,IAAA,OAAO,SAAS,IACZ,KAAA,CAAA,aAAA,CAAC,oBAAoB,EAAA,EAAA,GAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAA,CAAI,KAEjD,KAAA,CAAA,aAAA,CAAC,mBAAmB,EAAA,EAAA,GAAK,SAAS,EAAE,GAAG,EAAE,GAAG,EAAA,CAAI,CACnD;AACL,CAAC;;"}
|
|
@@ -121,18 +121,14 @@ const DateTimeInput = React.forwardRef(({ className, inputClassName, popoverClas
|
|
|
121
121
|
inputRef.current.focus();
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
-
const renderCalendar = () => Calendar ? (
|
|
125
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
126
|
-
React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
124
|
+
const renderCalendar = () => Calendar ? (React.createElement("div", { onMouseDown: handleCalendarWrapperMouseDown },
|
|
127
125
|
React.createElement(Calendar, { ...calendarProps, responsive: calendarResponsive, open: open, onClose: handleMobileCalendarClose, ref: calendarRef, defaultMonth: defaultMonth, value: checkInputValueIsValid(value) ? calendarValue : undefined, onChange: handleCalendarChange, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events }))) : null;
|
|
128
126
|
return (React.createElement("div", { className: cn(styles.component, className, {
|
|
129
127
|
[styles.block]: block,
|
|
130
128
|
}), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
|
|
131
129
|
InputComponent ? (React.createElement(InputComponent, { autoComplete: picker ? 'off' : undefined, ...restProps, block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, disableUserInput: disableUserInput, error: error, rightAddons: React.createElement(React.Fragment, null,
|
|
132
130
|
rightAddons,
|
|
133
|
-
shouldShowPicker && (
|
|
134
|
-
// eslint-disable-next-line jsx-a11y/control-has-associated-label
|
|
135
|
-
React.createElement(IconButton, { className: styles.calendarIcon, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 48 }))) })) : null,
|
|
131
|
+
shouldShowPicker && (React.createElement(IconButton, { className: styles.calendarIcon, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 48 }))) })) : null,
|
|
136
132
|
picker &&
|
|
137
133
|
(view === 'desktop' ? (React.createElement(Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, {
|
|
138
134
|
[styles.calendarResponsive]: calendarResponsive,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sources":["../../../src/components/date-time-input/Component.tsx"],"sourcesContent":["/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */\n\nimport React, {\n type ChangeEvent,\n type ElementType,\n type FocusEvent,\n type MouseEvent,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport { type CalendarDesktopProps } from '@alfalab/core-components-calendar/desktop';\nimport { type CalendarMobileProps } from '@alfalab/core-components-calendar/mobile';\nimport { dateInLimits } from '@alfalab/core-components-calendar/shared';\nimport { IconButton } from '@alfalab/core-components-icon-button';\nimport { type InputProps } from '@alfalab/core-components-input';\nimport { Popover, type PopoverProps } from '@alfalab/core-components-popover';\nimport { useDidUpdateEffect } from '@alfalab/hooks';\nimport { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';\n\nimport {\n addTimeToDate,\n DATE_WITH_TIME_LENGTH,\n format,\n getDateWithoutTime,\n getFullDateTime,\n isCompleteDateInput,\n isValid,\n parseTimestampToDate,\n} from '../../utils';\n\nimport styles from './index.module.css';\n\nexport type DateTimeInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Дополнительный класс\n */\n className?: string;\n\n /**\n * Дополнительный класс для инпута\n */\n inputClassName?: string;\n\n /**\n * Дополнительный класс для поповера\n */\n popoverClassName?: string;\n\n /**\n * Обработчик изменения значения\n */\n picker?: boolean;\n\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement> | null,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement> | null,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Компонент календаря\n */\n Calendar?: ElementType;\n\n /**\n * Доп. пропсы для календаря\n */\n calendarProps?:\n | (CalendarDesktopProps & Record<string, unknown>)\n | (CalendarMobileProps & Record<string, unknown>);\n\n /**\n * Месяц в календаре по умолчанию (timestamp)\n */\n defaultMonth?: number;\n\n /**\n * Минимальная дата, доступная для выбора (timestamp)\n */\n minDate?: number;\n\n /**\n * Максимальная дата, доступная для выбора (timestamp)\n */\n maxDate?: number;\n\n /**\n * Список событий\n */\n events?: Array<Date | number>;\n\n /**\n * Список выходных\n */\n offDays?: Array<Date | number>;\n\n /**\n * Состояние открытия по умолчанию\n */\n defaultOpen?: boolean;\n\n /**\n * Позиционирование поповера с календарем\n */\n popoverPosition?: PopoverProps['position'];\n\n /**\n * z-index Popover\n */\n zIndexPopover?: PopoverProps['zIndex'];\n\n /**\n * Запрещает поповеру менять свою позицию.\n * Например, если места снизу недостаточно,то он все равно будет показан снизу\n */\n preventFlip?: boolean;\n\n /**\n * Календарь будет принимать ширину инпута\n */\n useAnchorWidth?: boolean;\n\n /**\n * Растягивает компонент на ширину контейнера\n */\n block?: boolean;\n\n /**\n * Отображение компонента в мобильном или десктопном виде\n */\n view?: 'desktop' | 'mobile';\n\n /**\n * Компонент инпута\n */\n InputComponent?: ElementType;\n\n /**\n * Запретить ввод с клавиатуры\n */\n disableUserInput?: boolean;\n};\n\nexport const DateTimeInput = React.forwardRef<HTMLInputElement, DateTimeInputProps>(\n (\n {\n className,\n inputClassName,\n popoverClassName,\n disabled,\n readOnly,\n disableUserInput = false,\n picker,\n defaultValue = '',\n value: propValue,\n onChange,\n onComplete,\n rightAddons,\n useAnchorWidth,\n block,\n popoverPosition = 'bottom-start',\n zIndexPopover,\n preventFlip,\n InputComponent,\n Calendar,\n calendarProps = {},\n defaultMonth,\n minDate = calendarProps.minDate,\n maxDate = calendarProps.maxDate,\n offDays = calendarProps.offDays || [],\n events = calendarProps.events || [],\n defaultOpen = false,\n error,\n view = 'desktop',\n ...restProps\n },\n ref,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const calendarRef = useRef<HTMLDivElement>(null);\n\n const [value, setValue] = useState(propValue || defaultValue);\n const [open, setOpen] = useState(false);\n\n const calendarValue = value ? getDateWithoutTime(value).getTime() : undefined;\n\n const inputDisabled = disabled || readOnly;\n const shouldShowPicker = picker && !disabled && !readOnly;\n\n const calendarResponsive = calendarProps?.responsive ?? true;\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n useDidUpdateEffect(() => {\n const newPropValue = propValue || '';\n\n setValue((prevValue) => (prevValue === propValue ? prevValue : newPropValue));\n }, [propValue]);\n\n const checkInputValueIsValid = (newInputValue?: string) => {\n if (!newInputValue || error) return false;\n\n const dateValue = getDateWithoutTime(newInputValue).getTime();\n\n return (\n dateValue &&\n dateInLimits(dateValue, minDate, maxDate) &&\n !offDays.includes(dateValue)\n );\n };\n\n const setTimeToDate = () => {\n setValue((prevValue) => {\n const dateWithTime = addTimeToDate(prevValue);\n\n if (dateWithTime !== prevValue && dateWithTime.length === DATE_WITH_TIME_LENGTH) {\n onComplete?.(null, {\n date: getFullDateTime(dateWithTime),\n value: dateWithTime,\n });\n }\n\n return dateWithTime;\n });\n };\n\n const handleInputWrapperFocus = (event: FocusEvent<HTMLDivElement>) => {\n if (view === 'desktop') {\n if (picker) {\n setOpen(true);\n }\n if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {\n calendarRef.current.focus();\n }\n }\n };\n\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (view === 'desktop') {\n const target = (event.relatedTarget || document.activeElement) as HTMLElement;\n\n if (calendarRef.current && calendarRef.current.contains(target) === false) {\n setOpen(false);\n setTimeToDate();\n }\n }\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n\n if (newValue.length > DATE_WITH_TIME_LENGTH) return;\n\n // Позволяем вводить только цифры, точки, запятую, двоеточие и пробел\n if (/[^\\d., :]/.test(newValue)) {\n return;\n }\n\n const dots = newValue.match(/\\./g);\n const colon = newValue.match(/:/g);\n const comma = newValue.match(/,/g);\n\n // Не даем вводить больше, чем 2 точки, 1 двоеточие и 1 запятую\n if (\n (dots && dots.length > 2) ||\n (colon && colon.length > 1) ||\n (comma && comma.length > 1)\n ) {\n return;\n }\n\n const formattedValue = format(newValue);\n const date = getFullDateTime(formattedValue);\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { date, value: formattedValue });\n\n if (isCompleteDateInput(formattedValue)) {\n const valid = isValid(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) {\n onComplete(event, { date, value: formattedValue });\n }\n }\n };\n\n const handleMobileCalendarClose = () => {\n setOpen(false);\n setTimeToDate();\n };\n\n const handleClear = () => {\n setValue('');\n };\n\n const handleCalendarChange = (date?: number) => {\n if (date) {\n const newValue = parseTimestampToDate(date);\n\n setValue(newValue);\n onChange?.(null, { date: getFullDateTime(newValue), value: newValue });\n }\n };\n\n const handleCalendarWrapperMouseDown = (event: MouseEvent<HTMLDivElement>) => {\n // Не дает инпуту терять фокус при выборе даты\n event.preventDefault();\n };\n\n const handleIconButtonClick = () => {\n if (!open) setOpen(true);\n\n if (view === 'desktop' && inputRef.current) {\n inputRef.current.focus();\n }\n };\n\n const renderCalendar = () =>\n Calendar ? (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div onMouseDown={handleCalendarWrapperMouseDown}>\n <Calendar\n {...calendarProps}\n responsive={calendarResponsive}\n open={open}\n onClose={handleMobileCalendarClose}\n ref={calendarRef}\n defaultMonth={defaultMonth}\n value={checkInputValueIsValid(value) ? calendarValue : undefined}\n onChange={handleCalendarChange}\n minDate={minDate}\n maxDate={maxDate}\n offDays={offDays}\n events={events}\n />\n </div>\n ) : null;\n\n return (\n <div\n className={cn(styles.component, className, {\n [styles.block]: block,\n })}\n onFocus={inputDisabled ? undefined : handleInputWrapperFocus}\n onBlur={handleBlur}\n >\n {InputComponent ? (\n <InputComponent\n autoComplete={picker ? 'off' : undefined}\n {...restProps}\n block={block}\n ref={mergeRefs([ref, inputRef])}\n value={value}\n onChange={handleChange}\n disabled={disabled}\n readOnly={readOnly}\n className={inputClassName}\n onClear={handleClear}\n disableUserInput={disableUserInput}\n error={error}\n rightAddons={\n <React.Fragment>\n {rightAddons}\n {shouldShowPicker && (\n // eslint-disable-next-line jsx-a11y/control-has-associated-label\n <IconButton\n className={styles.calendarIcon}\n onClick={inputDisabled ? undefined : handleIconButtonClick}\n icon={CalendarMIcon}\n size={48}\n />\n )}\n </React.Fragment>\n }\n />\n ) : null}\n {picker &&\n (view === 'desktop' ? (\n <Popover\n open={open}\n useAnchorWidth={useAnchorWidth}\n anchorElement={inputRef.current as HTMLElement}\n popperClassName={cn(styles.calendarContainer, {\n [styles.calendarResponsive]: calendarResponsive,\n })}\n className={popoverClassName}\n position={popoverPosition}\n offset={[0, 8]}\n withTransition={false}\n preventFlip={preventFlip}\n zIndex={zIndexPopover}\n >\n {renderCalendar()}\n </Popover>\n ) : (\n renderCalendar()\n ))}\n </div>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;MA6Ja,aAAa,GAAG,KAAK,CAAC,UAAU,CACzC,CACI,EACI,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,gBAAgB,GAAG,KAAK,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,KAAK,EAAE,SAAS,EAChB,QAAQ,EACR,UAAU,EACV,WAAW,EACX,cAAc,EACd,KAAK,EACL,eAAe,GAAG,cAAc,EAChC,aAAa,EACb,WAAW,EACX,cAAc,EACd,QAAQ,EACR,aAAa,GAAG,EAAE,EAClB,YAAY,EACZ,OAAO,GAAG,aAAa,CAAC,OAAO,EAC/B,OAAO,GAAG,aAAa,CAAC,OAAO,EAC/B,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,EAAE,EACrC,MAAM,GAAG,aAAa,CAAC,MAAM,IAAI,EAAE,EACnC,WAAW,GAAG,KAAK,EACnB,KAAK,EACL,IAAI,GAAG,SAAS,EAChB,GAAG,SAAS,EACf,EACD,GAAG,KACH;AACA,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC;AAC/C,IAAA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,CAAC,CACJ;AAEd,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Component.js","sources":["../../../src/components/date-time-input/Component.tsx"],"sourcesContent":["/* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */\n\nimport React, {\n type ChangeEvent,\n type ElementType,\n type FocusEvent,\n type MouseEvent,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport { type CalendarDesktopProps } from '@alfalab/core-components-calendar/desktop';\nimport { type CalendarMobileProps } from '@alfalab/core-components-calendar/mobile';\nimport { dateInLimits } from '@alfalab/core-components-calendar/shared';\nimport { IconButton } from '@alfalab/core-components-icon-button';\nimport { type InputProps } from '@alfalab/core-components-input';\nimport { Popover, type PopoverProps } from '@alfalab/core-components-popover';\nimport { useDidUpdateEffect } from '@alfalab/hooks';\nimport { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';\n\nimport {\n addTimeToDate,\n DATE_WITH_TIME_LENGTH,\n format,\n getDateWithoutTime,\n getFullDateTime,\n isCompleteDateInput,\n isValid,\n parseTimestampToDate,\n} from '../../utils';\n\nimport styles from './index.module.css';\n\nexport type DateTimeInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Дополнительный класс\n */\n className?: string;\n\n /**\n * Дополнительный класс для инпута\n */\n inputClassName?: string;\n\n /**\n * Дополнительный класс для поповера\n */\n popoverClassName?: string;\n\n /**\n * Обработчик изменения значения\n */\n picker?: boolean;\n\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement> | null,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement> | null,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Компонент календаря\n */\n Calendar?: ElementType;\n\n /**\n * Доп. пропсы для календаря\n */\n calendarProps?:\n | (CalendarDesktopProps & Record<string, unknown>)\n | (CalendarMobileProps & Record<string, unknown>);\n\n /**\n * Месяц в календаре по умолчанию (timestamp)\n */\n defaultMonth?: number;\n\n /**\n * Минимальная дата, доступная для выбора (timestamp)\n */\n minDate?: number;\n\n /**\n * Максимальная дата, доступная для выбора (timestamp)\n */\n maxDate?: number;\n\n /**\n * Список событий\n */\n events?: Array<Date | number>;\n\n /**\n * Список выходных\n */\n offDays?: Array<Date | number>;\n\n /**\n * Состояние открытия по умолчанию\n */\n defaultOpen?: boolean;\n\n /**\n * Позиционирование поповера с календарем\n */\n popoverPosition?: PopoverProps['position'];\n\n /**\n * z-index Popover\n */\n zIndexPopover?: PopoverProps['zIndex'];\n\n /**\n * Запрещает поповеру менять свою позицию.\n * Например, если места снизу недостаточно,то он все равно будет показан снизу\n */\n preventFlip?: boolean;\n\n /**\n * Календарь будет принимать ширину инпута\n */\n useAnchorWidth?: boolean;\n\n /**\n * Растягивает компонент на ширину контейнера\n */\n block?: boolean;\n\n /**\n * Отображение компонента в мобильном или десктопном виде\n */\n view?: 'desktop' | 'mobile';\n\n /**\n * Компонент инпута\n */\n InputComponent?: ElementType;\n\n /**\n * Запретить ввод с клавиатуры\n */\n disableUserInput?: boolean;\n};\n\nexport const DateTimeInput = React.forwardRef<HTMLInputElement, DateTimeInputProps>(\n (\n {\n className,\n inputClassName,\n popoverClassName,\n disabled,\n readOnly,\n disableUserInput = false,\n picker,\n defaultValue = '',\n value: propValue,\n onChange,\n onComplete,\n rightAddons,\n useAnchorWidth,\n block,\n popoverPosition = 'bottom-start',\n zIndexPopover,\n preventFlip,\n InputComponent,\n Calendar,\n calendarProps = {},\n defaultMonth,\n minDate = calendarProps.minDate,\n maxDate = calendarProps.maxDate,\n offDays = calendarProps.offDays || [],\n events = calendarProps.events || [],\n defaultOpen = false,\n error,\n view = 'desktop',\n ...restProps\n },\n ref,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const calendarRef = useRef<HTMLDivElement>(null);\n\n const [value, setValue] = useState(propValue || defaultValue);\n const [open, setOpen] = useState(false);\n\n const calendarValue = value ? getDateWithoutTime(value).getTime() : undefined;\n\n const inputDisabled = disabled || readOnly;\n const shouldShowPicker = picker && !disabled && !readOnly;\n\n const calendarResponsive = calendarProps?.responsive ?? true;\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n useDidUpdateEffect(() => {\n const newPropValue = propValue || '';\n\n setValue((prevValue) => (prevValue === propValue ? prevValue : newPropValue));\n }, [propValue]);\n\n const checkInputValueIsValid = (newInputValue?: string) => {\n if (!newInputValue || error) return false;\n\n const dateValue = getDateWithoutTime(newInputValue).getTime();\n\n return (\n dateValue &&\n dateInLimits(dateValue, minDate, maxDate) &&\n !offDays.includes(dateValue)\n );\n };\n\n const setTimeToDate = () => {\n setValue((prevValue) => {\n const dateWithTime = addTimeToDate(prevValue);\n\n if (dateWithTime !== prevValue && dateWithTime.length === DATE_WITH_TIME_LENGTH) {\n onComplete?.(null, {\n date: getFullDateTime(dateWithTime),\n value: dateWithTime,\n });\n }\n\n return dateWithTime;\n });\n };\n\n const handleInputWrapperFocus = (event: FocusEvent<HTMLDivElement>) => {\n if (view === 'desktop') {\n if (picker) {\n setOpen(true);\n }\n if (!open && event.target.tagName !== 'INPUT' && calendarRef.current) {\n calendarRef.current.focus();\n }\n }\n };\n\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n if (view === 'desktop') {\n const target = (event.relatedTarget || document.activeElement) as HTMLElement;\n\n if (calendarRef.current && calendarRef.current.contains(target) === false) {\n setOpen(false);\n setTimeToDate();\n }\n }\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n\n if (newValue.length > DATE_WITH_TIME_LENGTH) return;\n\n // Позволяем вводить только цифры, точки, запятую, двоеточие и пробел\n if (/[^\\d., :]/.test(newValue)) {\n return;\n }\n\n const dots = newValue.match(/\\./g);\n const colon = newValue.match(/:/g);\n const comma = newValue.match(/,/g);\n\n // Не даем вводить больше, чем 2 точки, 1 двоеточие и 1 запятую\n if (\n (dots && dots.length > 2) ||\n (colon && colon.length > 1) ||\n (comma && comma.length > 1)\n ) {\n return;\n }\n\n const formattedValue = format(newValue);\n const date = getFullDateTime(formattedValue);\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { date, value: formattedValue });\n\n if (isCompleteDateInput(formattedValue)) {\n const valid = isValid(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) {\n onComplete(event, { date, value: formattedValue });\n }\n }\n };\n\n const handleMobileCalendarClose = () => {\n setOpen(false);\n setTimeToDate();\n };\n\n const handleClear = () => {\n setValue('');\n };\n\n const handleCalendarChange = (date?: number) => {\n if (date) {\n const newValue = parseTimestampToDate(date);\n\n setValue(newValue);\n onChange?.(null, { date: getFullDateTime(newValue), value: newValue });\n }\n };\n\n const handleCalendarWrapperMouseDown = (event: MouseEvent<HTMLDivElement>) => {\n // Не дает инпуту терять фокус при выборе даты\n event.preventDefault();\n };\n\n const handleIconButtonClick = () => {\n if (!open) setOpen(true);\n\n if (view === 'desktop' && inputRef.current) {\n inputRef.current.focus();\n }\n };\n\n const renderCalendar = () =>\n Calendar ? (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div onMouseDown={handleCalendarWrapperMouseDown}>\n <Calendar\n {...calendarProps}\n responsive={calendarResponsive}\n open={open}\n onClose={handleMobileCalendarClose}\n ref={calendarRef}\n defaultMonth={defaultMonth}\n value={checkInputValueIsValid(value) ? calendarValue : undefined}\n onChange={handleCalendarChange}\n minDate={minDate}\n maxDate={maxDate}\n offDays={offDays}\n events={events}\n />\n </div>\n ) : null;\n\n return (\n <div\n className={cn(styles.component, className, {\n [styles.block]: block,\n })}\n onFocus={inputDisabled ? undefined : handleInputWrapperFocus}\n onBlur={handleBlur}\n >\n {InputComponent ? (\n <InputComponent\n autoComplete={picker ? 'off' : undefined}\n {...restProps}\n block={block}\n ref={mergeRefs([ref, inputRef])}\n value={value}\n onChange={handleChange}\n disabled={disabled}\n readOnly={readOnly}\n className={inputClassName}\n onClear={handleClear}\n disableUserInput={disableUserInput}\n error={error}\n rightAddons={\n <React.Fragment>\n {rightAddons}\n {shouldShowPicker && (\n // eslint-disable-next-line jsx-a11y/control-has-associated-label\n <IconButton\n className={styles.calendarIcon}\n onClick={inputDisabled ? undefined : handleIconButtonClick}\n icon={CalendarMIcon}\n size={48}\n />\n )}\n </React.Fragment>\n }\n />\n ) : null}\n {picker &&\n (view === 'desktop' ? (\n <Popover\n open={open}\n useAnchorWidth={useAnchorWidth}\n anchorElement={inputRef.current as HTMLElement}\n popperClassName={cn(styles.calendarContainer, {\n [styles.calendarResponsive]: calendarResponsive,\n })}\n className={popoverClassName}\n position={popoverPosition}\n offset={[0, 8]}\n withTransition={false}\n preventFlip={preventFlip}\n zIndex={zIndexPopover}\n >\n {renderCalendar()}\n </Popover>\n ) : (\n renderCalendar()\n ))}\n </div>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;MA6Ja,aAAa,GAAG,KAAK,CAAC,UAAU,CACzC,CACI,EACI,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,gBAAgB,GAAG,KAAK,EACxB,MAAM,EACN,YAAY,GAAG,EAAE,EACjB,KAAK,EAAE,SAAS,EAChB,QAAQ,EACR,UAAU,EACV,WAAW,EACX,cAAc,EACd,KAAK,EACL,eAAe,GAAG,cAAc,EAChC,aAAa,EACb,WAAW,EACX,cAAc,EACd,QAAQ,EACR,aAAa,GAAG,EAAE,EAClB,YAAY,EACZ,OAAO,GAAG,aAAa,CAAC,OAAO,EAC/B,OAAO,GAAG,aAAa,CAAC,OAAO,EAC/B,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,EAAE,EACrC,MAAM,GAAG,aAAa,CAAC,MAAM,IAAI,EAAE,EACnC,WAAW,GAAG,KAAK,EACnB,KAAK,EACL,IAAI,GAAG,SAAS,EAChB,GAAG,SAAS,EACf,EACD,GAAG,KACH;AACA,IAAA,MAAM,QAAQ,GAAG,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,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EACd,cAAc,EAAE,KAAK,EACrB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,aAAa,EAAA,EAEpB,cAAc,EAAE,CACX,KAEV,cAAc,EAAE,CACnB,CAAC,CACJ;AAEd,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.desktop.js","sources":["../../src/desktop/Component.desktop.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarDesktop } from '@alfalab/core-components-calendar/desktop';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputDesktop } from '@alfalab/core-components-input/desktop';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputDesktopProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const DateTimeInputDesktop = forwardRef<HTMLInputElement, DateTimeInputDesktopProps>(\n (props, ref) => (\n <DateTimeInput\n Calendar={CalendarDesktop}\n InputComponent={InputDesktop}\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;AAWA;;;AAGG;AACI,MAAM,oBAAoB,GAAG,UAAU,CAC1C,CAAC,KAAK,EAAE,GAAG,MACP,
|
|
1
|
+
{"version":3,"file":"Component.desktop.js","sources":["../../src/desktop/Component.desktop.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarDesktop } from '@alfalab/core-components-calendar/desktop';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputDesktop } from '@alfalab/core-components-input/desktop';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputDesktopProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const DateTimeInputDesktop = forwardRef<HTMLInputElement, DateTimeInputDesktopProps>(\n (props, ref) => (\n <DateTimeInput\n Calendar={CalendarDesktop}\n InputComponent={InputDesktop}\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;AAWA;;;AAGG;AACI,MAAM,oBAAoB,GAAG,UAAU,CAC1C,CAAC,KAAK,EAAE,GAAG,MACP,KAAA,CAAA,aAAA,CAAC,aAAa,EAAA,EACV,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,YAAY,EAAA,GACxB,KAAK,EACT,GAAG,EAAE,GAAG,EAAA,CACV,CACL;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.mobile.js","sources":["../../src/mobile/Component.mobile.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarMobile } from '@alfalab/core-components-calendar/mobile';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputMobile } from '@alfalab/core-components-input/mobile';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\nexport const DateTimeInputMobile = forwardRef<HTMLInputElement, DateTimeInputMobileProps>(\n (props, ref) => (\n <DateTimeInput\n InputComponent={InputMobile}\n Calendar={CalendarMobile}\n view='mobile'\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Component.mobile.js","sources":["../../src/mobile/Component.mobile.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { CalendarMobile } from '@alfalab/core-components-calendar/mobile';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { InputProps } from '@alfalab/core-components-input';\nimport { InputMobile } from '@alfalab/core-components-input/mobile';\n\nimport { DateTimeInput, type DateTimeInputProps } from '../components/date-time-input/Component';\n\nexport type DateTimeInputMobileProps = Omit<DateTimeInputProps, 'view' | 'InputComponent'>;\n\nexport const DateTimeInputMobile = forwardRef<HTMLInputElement, DateTimeInputMobileProps>(\n (props, ref) => (\n <DateTimeInput\n InputComponent={InputMobile}\n Calendar={CalendarMobile}\n view='mobile'\n {...props}\n ref={ref}\n />\n ),\n);\n"],"names":[],"mappings":";;;;;AAWO,MAAM,mBAAmB,GAAG,UAAU,CACzC,CAAC,KAAK,EAAE,GAAG,MACP,KAAA,CAAA,aAAA,CAAC,aAAa,EAAA,EACV,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,QAAQ,EAAA,GACT,KAAK,EACT,GAAG,EAAE,GAAG,EAAA,CACV,CACL;;"}
|