@alfalab/core-components-date-input 4.4.16 → 4.4.17-snapshot-1393ffa

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.
Files changed (104) hide show
  1. package/Component.js +12 -13
  2. package/Component.js.map +1 -0
  3. package/cssm/Component.js +12 -11
  4. package/cssm/Component.js.map +1 -0
  5. package/cssm/index.js +12 -11
  6. package/cssm/index.js.map +1 -0
  7. package/cssm/index.module.css +5 -24
  8. package/{Component.d.ts → cssm/src/Component.d.ts} +4 -7
  9. package/cssm/src/index.d.ts +2 -0
  10. package/cssm/src/utils/format.d.ts +8 -0
  11. package/cssm/src/utils/index.d.ts +2 -0
  12. package/cssm/{utils → src/utils}/native-supports.d.ts +1 -2
  13. package/cssm/utils/format.js +1 -0
  14. package/cssm/utils/format.js.map +1 -0
  15. package/cssm/utils/index.js +12 -11
  16. package/cssm/utils/index.js.map +1 -0
  17. package/cssm/utils/native-supports.js +1 -0
  18. package/cssm/utils/native-supports.js.map +1 -0
  19. package/esm/Component.js +3 -4
  20. package/esm/Component.js.map +1 -0
  21. package/esm/index.css +7 -27
  22. package/esm/index.js +1 -0
  23. package/esm/index.js.map +1 -0
  24. package/esm/index.module.css.js +6 -0
  25. package/esm/index.module.css.js.map +1 -0
  26. package/{cssm → esm/src}/Component.d.ts +4 -7
  27. package/esm/src/index.d.ts +2 -0
  28. package/esm/src/utils/format.d.ts +8 -0
  29. package/esm/src/utils/index.d.ts +2 -0
  30. package/esm/{utils → src/utils}/native-supports.d.ts +1 -2
  31. package/esm/utils/format.js +1 -0
  32. package/esm/utils/format.js.map +1 -0
  33. package/esm/utils/index.js +1 -0
  34. package/esm/utils/index.js.map +1 -0
  35. package/esm/utils/native-supports.js +1 -0
  36. package/esm/utils/native-supports.js.map +1 -0
  37. package/index.css +7 -27
  38. package/index.js +12 -11
  39. package/index.js.map +1 -0
  40. package/index.module.css.js +8 -0
  41. package/index.module.css.js.map +1 -0
  42. package/modern/Component.js +3 -4
  43. package/modern/Component.js.map +1 -0
  44. package/modern/index.css +7 -27
  45. package/modern/index.js +1 -0
  46. package/modern/index.js.map +1 -0
  47. package/modern/index.module.css.js +6 -0
  48. package/modern/index.module.css.js.map +1 -0
  49. package/{esm → modern/src}/Component.d.ts +4 -7
  50. package/modern/src/index.d.ts +2 -0
  51. package/modern/src/utils/format.d.ts +8 -0
  52. package/modern/src/utils/index.d.ts +2 -0
  53. package/modern/{utils → src/utils}/native-supports.d.ts +1 -2
  54. package/modern/utils/format.js +1 -0
  55. package/modern/utils/format.js.map +1 -0
  56. package/modern/utils/index.js +1 -0
  57. package/modern/utils/index.js.map +1 -0
  58. package/modern/utils/native-supports.js +1 -0
  59. package/modern/utils/native-supports.js.map +1 -0
  60. package/moderncssm/Component.js +2 -1
  61. package/moderncssm/Component.js.map +1 -0
  62. package/moderncssm/index.js +1 -0
  63. package/moderncssm/index.js.map +1 -0
  64. package/moderncssm/index.module.css +3 -3
  65. package/{modern → moderncssm/src}/Component.d.ts +4 -7
  66. package/moderncssm/src/index.d.ts +2 -0
  67. package/moderncssm/src/utils/format.d.ts +8 -0
  68. package/moderncssm/src/utils/index.d.ts +2 -0
  69. package/moderncssm/{utils → src/utils}/native-supports.d.ts +1 -2
  70. package/moderncssm/utils/format.js +1 -0
  71. package/moderncssm/utils/format.js.map +1 -0
  72. package/moderncssm/utils/index.js +1 -0
  73. package/moderncssm/utils/index.js.map +1 -0
  74. package/moderncssm/utils/native-supports.js +1 -0
  75. package/moderncssm/utils/native-supports.js.map +1 -0
  76. package/package.json +4 -4
  77. package/src/Component.d.ts +46 -0
  78. package/src/index.d.ts +2 -0
  79. package/src/utils/format.d.ts +8 -0
  80. package/src/utils/index.d.ts +2 -0
  81. package/src/utils/native-supports.d.ts +4 -0
  82. package/utils/format.js +1 -0
  83. package/utils/format.js.map +1 -0
  84. package/utils/index.js +12 -11
  85. package/utils/index.js.map +1 -0
  86. package/utils/native-supports.js +1 -0
  87. package/utils/native-supports.js.map +1 -0
  88. package/cssm/index.d.ts +0 -2
  89. package/cssm/utils/format.d.ts +0 -9
  90. package/cssm/utils/index.d.ts +0 -2
  91. package/esm/index.d.ts +0 -2
  92. package/esm/utils/format.d.ts +0 -9
  93. package/esm/utils/index.d.ts +0 -2
  94. package/index.d.ts +0 -2
  95. package/modern/index.d.ts +0 -2
  96. package/modern/utils/format.d.ts +0 -9
  97. package/modern/utils/index.d.ts +0 -2
  98. package/moderncssm/Component.d.ts +0 -49
  99. package/moderncssm/index.d.ts +0 -2
  100. package/moderncssm/utils/format.d.ts +0 -9
  101. package/moderncssm/utils/index.d.ts +0 -2
  102. package/utils/format.d.ts +0 -9
  103. package/utils/index.d.ts +0 -2
  104. package/utils/native-supports.d.ts +0 -5
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent } from "react";
4
- import { InputProps } from "@alfalab/core-components-input";
5
- type DateInputProps = Omit<InputProps, 'onChange'> & {
1
+ import React, { ChangeEvent } from 'react';
2
+ import { InputProps } from '@alfalab/core-components-input';
3
+ export declare type DateInputProps = Omit<InputProps, 'onChange'> & {
6
4
  /**
7
5
  * Управление нативным режимом на мобильных устройствах
8
6
  */
@@ -26,7 +24,7 @@ type DateInputProps = Omit<InputProps, 'onChange'> & {
26
24
  * @deprecated
27
25
  * use UniversalDateInput instead
28
26
  */
29
- declare const DateInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
27
+ export declare const DateInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
30
28
  /**
31
29
  * Управление нативным режимом на мобильных устройствах
32
30
  */
@@ -46,4 +44,3 @@ declare const DateInput: React.ForwardRefExoticComponent<Omit<InputProps, "onCha
46
44
  value: string;
47
45
  }) => void) | undefined;
48
46
  } & React.RefAttributes<HTMLInputElement>>;
49
- export { DateInputProps, DateInput };
@@ -0,0 +1,2 @@
1
+ export * from './Component';
2
+ export * from './utils';
@@ -0,0 +1,8 @@
1
+ export declare const DATE_FORMAT = "dd.MM.yyyy";
2
+ export declare const NATIVE_DATE_FORMAT = "yyyy-MM-dd";
3
+ export declare const DATE_MASK: (string | RegExp)[];
4
+ export declare const isCompleteDateInput: (input: string) => boolean;
5
+ export declare const formatDate: (date: Date | number, dateFormat?: string) => string;
6
+ export declare const parseDateString: (value: string, dateFormat?: string) => Date;
7
+ export declare const isValid: (inputValue?: string) => boolean;
8
+ export declare const format: (value: string) => string;
@@ -0,0 +1,2 @@
1
+ export * from './format';
2
+ export * from './native-supports';
@@ -1,5 +1,4 @@
1
1
  /**
2
2
  * Возвращает `true`, если поддерживается `input[type="date"]`
3
3
  */
4
- declare function isInputDateSupported(): boolean;
5
- export { isInputDateSupported };
4
+ export declare function isInputDateSupported(): boolean;
@@ -38,3 +38,4 @@ var format = function (value) {
38
38
  }; // .2.2005123123 => .2.2005
39
39
 
40
40
  export { DATE_FORMAT, DATE_MASK, NATIVE_DATE_FORMAT, format, formatDate, isCompleteDateInput, isValid, parseDateString };
41
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sources":["../../../src/utils/format.ts"],"sourcesContent":["import dateFnsFormat from 'date-fns/format';\nimport dateFnsIsValid from 'date-fns/isValid';\nimport parse from 'date-fns/parse';\n\nexport const DATE_FORMAT = 'dd.MM.yyyy';\nexport const NATIVE_DATE_FORMAT = 'yyyy-MM-dd';\nexport const DATE_MASK = [/\\d/, /\\d/, '.', /\\d/, /\\d/, '.', /\\d/, /\\d/, /\\d/, /\\d/];\n\nexport const isCompleteDateInput = (input: string) => input.length === DATE_MASK.length;\n\nexport const formatDate = (date: Date | number, dateFormat = DATE_FORMAT) =>\n dateFnsFormat(date, dateFormat);\n\nexport const parseDateString = (value: string, dateFormat = DATE_FORMAT) =>\n parse(value, dateFormat, new Date());\n\nexport const isValid = (inputValue?: string) =>\n !inputValue || (isCompleteDateInput(inputValue) && dateFnsIsValid(parseDateString(inputValue)));\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(/^(\\d\\d\\.\\d\\d\\.\\d\\d\\d\\d).*/, '$1') // 12.12.20056 => 12.12.2005\n .replace(/\\.$/, '') // 12. => 12\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)([0-9]*)/, '$1') // 1.12.2005123123 => 01.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\\d\\d\\d)([0-9]*)/, '$1') // 1.2.20055125125 => 1.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.$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"],"names":[],"mappings":";;;;AAIO,IAAM,WAAW,GAAG;AACpB,IAAM,kBA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CAAC;AAC3C,SAAA,OAAO,CAAC,yBAAyB,EAAE,OAAO,CAAC;AAC3C,SAAA,OAAO,CAAC,+BAA+B,EAAE,IAAI,CAAC;AAC9C,SAAA,OAAO,CAAC,+BAA+B,EAAE,IAAI,CAAC;AAC9C,SAAA,OAAO,CAAC,6BAA6B,EAAE,IAAI,CAAC;AAC5C,SAAA,OAAO,CAAC,mCAAmC,EAAE,UAAU,CAAC;AACxD,SAAA,OAAO,CAAC,iCAAiC,EAAE,UAAU,CAAC;AACtD,SAAA,OAAO,CAAC,+BAA+B,EAAE,UAAU,CAAC;AACpD,SAAA,OAAO,CAAC,6BAA6B,EAAE,UAAU,CAAC;AAClD,SAAA,OAAO,CAAC,+BAA+B,EAAE,UAAU,CAAC;AAhBzD,EAgB0D;;;;"}
@@ -1,2 +1,3 @@
1
1
  export { DATE_FORMAT, DATE_MASK, NATIVE_DATE_FORMAT, format, formatDate, isCompleteDateInput, isValid, parseDateString } from './format.js';
2
2
  export { isInputDateSupported } from './native-supports.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -10,3 +10,4 @@ function isInputDateSupported() {
10
10
  }
11
11
 
12
12
  export { isInputDateSupported };
13
+ //# sourceMappingURL=native-supports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-supports.js","sources":["../../../src/utils/native-supports.ts"],"sourcesContent":["/**\n * Возвращает `true`, если поддерживается `input[type=\"date\"]`\n */\nexport function isInputDateSupported() {\n const input = document.createElement('input');\n const value = 'a';\n\n input.setAttribute('type', 'date');\n input.setAttribute('value', value);\n\n return input.value !== value;\n}\n"],"names":[],"mappings":"AAAA;;AAEG;SACa,oBAAoB,GAAA;IAChC,IAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;IAC7C,IAAM,KAAK,GAAG,GAAG;AAEjB,IAAA,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;AAClC,IAAA,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC;AAElC,IAAA,OAAO,KAAK,CAAC,KAAK,KAAK,KAAK;AAChC;;;;"}
package/index.css CHANGED
@@ -1,38 +1,18 @@
1
- /* hash: 12psr */
2
- :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
- } /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
4
- } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
5
- } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
6
- } :root {
7
-
8
- /* Hard */
9
-
10
- /* Up */
11
-
12
- /* Hard up */
13
- } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
14
-
15
- /* новые значения, используйте их */
16
- } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
17
-
18
- /* новые значения, используйте их */
19
-
20
- /* no-unit может приводить к проблемам в calc (#1559) */
21
- /* stylelint-disable-next-line length-zero-no-unit */
1
+ :root {
22
2
  --gap-0: 0px;
23
- } :root {
24
- } :root {
25
- } /* сбрасывает синюю подсветку при нажатии */ .date-input__nativeInput_w0ab5 {
3
+ } .date-input__nativeInput_17btv {
26
4
  opacity: 0;
27
5
  position: absolute;
28
6
  top: var(--gap-0);
29
7
  left: var(--gap-0);
30
8
  width: 100%;
31
9
  height: 100%;
32
- appearance: none;
10
+ -webkit-appearance: none;
11
+ -moz-appearance: none;
12
+ appearance: none;
33
13
  z-index: 1
34
- } .date-input__nativeInput_w0ab5::-webkit-calendar-picker-indicator {
14
+ } .date-input__nativeInput_17btv::-webkit-calendar-picker-indicator {
35
15
  display: none;
36
- } .date-input__nativeInput_w0ab5::-webkit-inner-spin-button {
16
+ } .date-input__nativeInput_17btv::-webkit-inner-spin-button {
37
17
  display: none;
38
18
  }
package/index.js CHANGED
@@ -3,18 +3,19 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var Component = require('./Component.js');
6
- var utils_format = require('./utils/format.js');
7
- var utils_nativeSupports = require('./utils/native-supports.js');
6
+ var format = require('./utils/format.js');
7
+ var nativeSupports = require('./utils/native-supports.js');
8
8
 
9
9
 
10
10
 
11
11
  exports.DateInput = Component.DateInput;
12
- exports.DATE_FORMAT = utils_format.DATE_FORMAT;
13
- exports.DATE_MASK = utils_format.DATE_MASK;
14
- exports.NATIVE_DATE_FORMAT = utils_format.NATIVE_DATE_FORMAT;
15
- exports.format = utils_format.format;
16
- exports.formatDate = utils_format.formatDate;
17
- exports.isCompleteDateInput = utils_format.isCompleteDateInput;
18
- exports.isValid = utils_format.isValid;
19
- exports.parseDateString = utils_format.parseDateString;
20
- exports.isInputDateSupported = utils_nativeSupports.isInputDateSupported;
12
+ exports.DATE_FORMAT = format.DATE_FORMAT;
13
+ exports.DATE_MASK = format.DATE_MASK;
14
+ exports.NATIVE_DATE_FORMAT = format.NATIVE_DATE_FORMAT;
15
+ exports.format = format.format;
16
+ exports.formatDate = format.formatDate;
17
+ exports.isCompleteDateInput = format.isCompleteDateInput;
18
+ exports.isValid = format.isValid;
19
+ exports.parseDateString = format.parseDateString;
20
+ exports.isInputDateSupported = nativeSupports.isInputDateSupported;
21
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ require('./index.css');
4
+
5
+ var styles = {"nativeInput":"date-input__nativeInput_17btv"};
6
+
7
+ module.exports = styles;
8
+ //# sourceMappingURL=index.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.module.css.js","sources":["src/index.module.css"],"sourcesContent":["@import '../../vars/src/index.css';\n\n.nativeInput {\n opacity: 0;\n position: absolute;\n top: var(--gap-0);\n left: var(--gap-0);\n width: 100%;\n height: 100%;\n appearance: none;\n z-index: 1;\n\n &::-webkit-calendar-picker-indicator {\n display: none;\n }\n &::-webkit-inner-spin-button {\n display: none;\n }\n}\n"],"names":[],"mappings":";;;;AAEgB,aAAe,CAAC,aAAa,CAAC,+BAA+B,CAAC;;;;"}
@@ -1,11 +1,9 @@
1
1
  import React, { forwardRef, useRef, useState, useEffect } from 'react';
2
2
  import mergeRefs from 'react-merge-refs';
3
3
  import { Input } from '@alfalab/core-components-input/modern';
4
- import { format, parseDateString, isCompleteDateInput, isValid, NATIVE_DATE_FORMAT, formatDate } from './utils/format.js';
4
+ import { format, parseDateString, isCompleteDateInput, isValid, formatDate, NATIVE_DATE_FORMAT } from './utils/format.js';
5
5
  import { isInputDateSupported } from './utils/native-supports.js';
6
-
7
- const styles = {"nativeInput":"date-input__nativeInput_w0ab5"};
8
- require('./index.css')
6
+ import styles from './index.module.css.js';
9
7
 
10
8
  /**
11
9
  * @deprecated
@@ -93,3 +91,4 @@ function getDotsCount(value) {
93
91
  }
94
92
 
95
93
  export { DateInput };
94
+ //# sourceMappingURL=Component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Component.js","sources":["../../src/Component.tsx"],"sourcesContent":["import React, { ChangeEvent, FocusEvent, forwardRef, useEffect, useRef, useState } from 'react';\nimport mergeRefs from 'react-merge-refs';\n\nimport { Input, InputProps } from '@alfalab/core-components-input';\n\nimport {\n format,\n formatDate,\n isCompleteDateInput,\n isInputDateSupported,\n isValid,\n NATIVE_DATE_FORMAT,\n parseDateString,\n} from './utils';\n\nimport styles from './index.module.css';\n\nexport type DateInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Управление нативным режимом на мобильных устройствах\n */\n mobileMode?: 'input' | 'native';\n\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { date: Date; value: string },\n ) => void;\n};\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const DateInput = forwardRef<HTMLInputElement, DateInputProps>(\n (\n {\n mobileMode = 'input',\n defaultValue = '',\n rightAddons,\n error,\n value: propValue,\n onBlur,\n onChange,\n onComplete,\n ...restProps\n },\n ref,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const [shouldRenderNative, setShouldRenderNative] = useState(false);\n\n const [value, setValue] = useState(propValue || defaultValue);\n\n const moveCaretTo = (pos: number) => {\n requestAnimationFrame(() => {\n inputRef.current?.setSelectionRange(pos, pos);\n });\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n const caretPos = event.target.selectionStart || 0;\n\n // Позволяем вводить только цифры и точки\n if (/[^\\d.]/.test(newValue)) {\n moveCaretTo(caretPos - 1);\n\n return;\n }\n\n // Не даем вводить больше, чем 2 точки\n if (getDotsCount(newValue) > 2) {\n moveCaretTo(caretPos - 1);\n\n return;\n }\n\n // Форматируем введенное значение (добавляем точки)\n const formattedValue = format(newValue);\n const date = parseDateString(formattedValue);\n\n // Управляем кареткой, если она находится не в конце инпута\n if (caretPos !== newValue.length) {\n if (formattedValue === value) {\n moveCaretTo(caretPos);\n } else if (newValue.length - formattedValue.length === 1) {\n moveCaretTo(caretPos);\n } else if (\n formattedValue.length - newValue.length === 1 &&\n getDotsCount(formattedValue) > getDotsCount(newValue)\n ) {\n moveCaretTo(caretPos);\n }\n }\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { date, value: formattedValue });\n\n if (isCompleteDateInput(formattedValue)) {\n const valid = formattedValue.length > 0 && isValid(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) onComplete(event, { date, value: formattedValue });\n }\n };\n\n const handleNativeInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n const newDate = parseDateString(event.target.value, NATIVE_DATE_FORMAT);\n const newValue = event.target.value === '' ? '' : formatDate(newDate);\n\n setValue(newValue);\n\n if (onComplete) onComplete(event, { date: newDate, value: newValue });\n if (onChange) onChange(event, { date: newDate, value: newValue });\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n if (onBlur) onBlur(event);\n };\n\n useEffect(() => {\n if (mobileMode === 'native' && isInputDateSupported()) {\n setShouldRenderNative(true);\n }\n }, [mobileMode]);\n\n useEffect(() => {\n if (typeof propValue !== 'undefined') {\n setValue(propValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [propValue]);\n\n return (\n <Input\n {...restProps}\n ref={mergeRefs([ref, inputRef])}\n value={value}\n inputMode='decimal'\n pattern='[0-9\\.]*'\n onChange={handleChange}\n onBlur={handleBlur}\n placeholder='ДД.ММ.ГГГГ'\n error={error}\n rightAddons={\n <React.Fragment>\n {rightAddons}\n\n {shouldRenderNative && (\n <input\n type='date'\n ref={ref}\n defaultValue={defaultValue}\n onChange={handleNativeInputChange}\n className={styles.nativeInput}\n />\n )}\n </React.Fragment>\n }\n />\n );\n },\n);\n\nfunction getDotsCount(value: string) {\n return (value.match(/\\./g) || []).length;\n}\n"],"names":[],"mappings":";;;;;;;AAwCA;;;AAGG;AACU,MAAA,SAAS,GAAG,UAAU,CAC/B,CACI,EACI,UAAU,GAAG,OAAO,EACpB,YAAY,GAAG,EAAE,EACjB,WAAW,EACX,KAAK,EACL,KAAK,EAAE,SAAS,EAChB,MAAM,EACN,QAAQ,EACR,UAAU,EACV,GAAG,SAAS,EACf,EACD,GAAG,KACH;AACA,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC;IAE/C,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAEnE,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,SAAS,IAAI,YAAY,CAAC;AAE7D,IAAA,MAAM,WAAW,GAAG,CAAC,GAAW,KAAI;QAChC,qBAAqB,CAAC,MAAK;YACvB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC;AACjD,SAAC,CAAC;AACN,KAAC;AAED,IAAA,MAAM,YAAY,GAAG,CAAC,KAAoC,KAAI;QAC1D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,MAAM;QACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc,IAAI,CAAC;;AAGjD,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;AACzB,YAAA,WAAW,CAAC,QAAQ,GAAG,CAAC,CAAC;YAEzB;AACH;;AAGD,QAAA,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AAA,aAAA,CAAA,OAAA,EAAA,EAAA,IAAI,EAAC,MAAM,EACX,GAAG,EAAE,GAAG,EACR,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,uBAAuB,EACjC,SAAS,EAAE,MAAM,CAAC,WAAW,EAC/B,CAAA,CACL,CACY,EAAA,CAEvB;AAEV,CAAC;AAGL,SAAS,YAAY,CAAC,KAAa,EAAA;AAC/B,IAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,MAAM;AAC5C;;;;"}
package/modern/index.css CHANGED
@@ -1,38 +1,18 @@
1
- /* hash: 12psr */
2
- :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
- } /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
4
- } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
5
- } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
6
- } :root {
7
-
8
- /* Hard */
9
-
10
- /* Up */
11
-
12
- /* Hard up */
13
- } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
14
-
15
- /* новые значения, используйте их */
16
- } :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
17
-
18
- /* новые значения, используйте их */
19
-
20
- /* no-unit может приводить к проблемам в calc (#1559) */
21
- /* stylelint-disable-next-line length-zero-no-unit */
1
+ :root {
22
2
  --gap-0: 0px;
23
- } :root {
24
- } :root {
25
- } /* сбрасывает синюю подсветку при нажатии */ .date-input__nativeInput_w0ab5 {
3
+ } .date-input__nativeInput_17btv {
26
4
  opacity: 0;
27
5
  position: absolute;
28
6
  top: var(--gap-0);
29
7
  left: var(--gap-0);
30
8
  width: 100%;
31
9
  height: 100%;
32
- appearance: none;
10
+ -webkit-appearance: none;
11
+ -moz-appearance: none;
12
+ appearance: none;
33
13
  z-index: 1
34
- } .date-input__nativeInput_w0ab5::-webkit-calendar-picker-indicator {
14
+ } .date-input__nativeInput_17btv::-webkit-calendar-picker-indicator {
35
15
  display: none;
36
- } .date-input__nativeInput_w0ab5::-webkit-inner-spin-button {
16
+ } .date-input__nativeInput_17btv::-webkit-inner-spin-button {
37
17
  display: none;
38
18
  }
package/modern/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { DateInput } from './Component.js';
2
2
  export { DATE_FORMAT, DATE_MASK, NATIVE_DATE_FORMAT, format, formatDate, isCompleteDateInput, isValid, parseDateString } from './utils/format.js';
3
3
  export { isInputDateSupported } from './utils/native-supports.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,6 @@
1
+ import './index.css';
2
+
3
+ const styles = {"nativeInput":"date-input__nativeInput_17btv"};
4
+
5
+ export { styles as default };
6
+ //# sourceMappingURL=index.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.module.css.js","sources":["src/index.module.css"],"sourcesContent":["@import '../../vars/src/index.css';\n\n.nativeInput {\n opacity: 0;\n position: absolute;\n top: var(--gap-0);\n left: var(--gap-0);\n width: 100%;\n height: 100%;\n appearance: none;\n z-index: 1;\n\n &::-webkit-calendar-picker-indicator {\n display: none;\n }\n &::-webkit-inner-spin-button {\n display: none;\n }\n}\n"],"names":[],"mappings":";;AAEgB,eAAe,CAAC,aAAa,CAAC,+BAA+B,CAAC;;;;"}
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent } from "react";
4
- import { InputProps } from "@alfalab/core-components-input";
5
- type DateInputProps = Omit<InputProps, 'onChange'> & {
1
+ import React, { ChangeEvent } from 'react';
2
+ import { InputProps } from '@alfalab/core-components-input';
3
+ export declare type DateInputProps = Omit<InputProps, 'onChange'> & {
6
4
  /**
7
5
  * Управление нативным режимом на мобильных устройствах
8
6
  */
@@ -26,7 +24,7 @@ type DateInputProps = Omit<InputProps, 'onChange'> & {
26
24
  * @deprecated
27
25
  * use UniversalDateInput instead
28
26
  */
29
- declare const DateInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
27
+ export declare const DateInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
30
28
  /**
31
29
  * Управление нативным режимом на мобильных устройствах
32
30
  */
@@ -46,4 +44,3 @@ declare const DateInput: React.ForwardRefExoticComponent<Omit<InputProps, "onCha
46
44
  value: string;
47
45
  }) => void) | undefined;
48
46
  } & React.RefAttributes<HTMLInputElement>>;
49
- export { DateInputProps, DateInput };
@@ -0,0 +1,2 @@
1
+ export * from './Component';
2
+ export * from './utils';
@@ -0,0 +1,8 @@
1
+ export declare const DATE_FORMAT = "dd.MM.yyyy";
2
+ export declare const NATIVE_DATE_FORMAT = "yyyy-MM-dd";
3
+ export declare const DATE_MASK: (string | RegExp)[];
4
+ export declare const isCompleteDateInput: (input: string) => boolean;
5
+ export declare const formatDate: (date: Date | number, dateFormat?: string) => string;
6
+ export declare const parseDateString: (value: string, dateFormat?: string) => Date;
7
+ export declare const isValid: (inputValue?: string) => boolean;
8
+ export declare const format: (value: string) => string;
@@ -0,0 +1,2 @@
1
+ export * from './format';
2
+ export * from './native-supports';
@@ -1,5 +1,4 @@
1
1
  /**
2
2
  * Возвращает `true`, если поддерживается `input[type="date"]`
3
3
  */
4
- declare function isInputDateSupported(): boolean;
5
- export { isInputDateSupported };
4
+ export declare function isInputDateSupported(): boolean;
@@ -28,3 +28,4 @@ const format = (value) => value
28
28
  .replace(/^()\.(\d)\.(\d\d\d\d)([0-9]*)/, '$1.$2.$3'); // .2.2005123123 => .2.2005
29
29
 
30
30
  export { DATE_FORMAT, DATE_MASK, NATIVE_DATE_FORMAT, format, formatDate, isCompleteDateInput, isValid, parseDateString };
31
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sources":["../../../src/utils/format.ts"],"sourcesContent":["import dateFnsFormat from 'date-fns/format';\nimport dateFnsIsValid from 'date-fns/isValid';\nimport parse from 'date-fns/parse';\n\nexport const DATE_FORMAT = 'dd.MM.yyyy';\nexport const NATIVE_DATE_FORMAT = 'yyyy-MM-dd';\nexport const DATE_MASK = [/\\d/, /\\d/, '.', /\\d/, /\\d/, '.', /\\d/, /\\d/, /\\d/, /\\d/];\n\nexport const isCompleteDateInput = (input: string) => input.length === DATE_MASK.length;\n\nexport const formatDate = (date: Date | number, dateFormat = DATE_FORMAT) =>\n dateFnsFormat(date, dateFormat);\n\nexport const parseDateString = (value: string, dateFormat = DATE_FORMAT) =>\n parse(value, dateFormat, new Date());\n\nexport const isValid = (inputValue?: string) =>\n !inputValue || (isCompleteDateInput(inputValue) && dateFnsIsValid(parseDateString(inputValue)));\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(/^(\\d\\d\\.\\d\\d\\.\\d\\d\\d\\d).*/, '$1') // 12.12.20056 => 12.12.2005\n .replace(/\\.$/, '') // 12. => 12\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)([0-9]*)/, '$1') // 1.12.2005123123 => 01.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\\d\\d\\d)([0-9]*)/, '$1') // 1.2.20055125125 => 1.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.$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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A6B,EAAE,IAAI,CAAC;AAC5C,KAAA,OAAO,CAAC,mCAAmC,EAAE,UAAU,CAAC;AACxD,KAAA,OAAO,CAAC,iCAAiC,EAAE,UAAU,CAAC;AACtD,KAAA,OAAO,CAAC,+BAA+B,EAAE,UAAU,CAAC;AACpD,KAAA,OAAO,CAAC,6BAA6B,EAAE,UAAU,CAAC;AAClD,KAAA,OAAO,CAAC,+BAA+B,EAAE,UAAU,EAAE;;;;"}
@@ -1,2 +1,3 @@
1
1
  export { DATE_FORMAT, DATE_MASK, NATIVE_DATE_FORMAT, format, formatDate, isCompleteDateInput, isValid, parseDateString } from './format.js';
2
2
  export { isInputDateSupported } from './native-supports.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -10,3 +10,4 @@ function isInputDateSupported() {
10
10
  }
11
11
 
12
12
  export { isInputDateSupported };
13
+ //# sourceMappingURL=native-supports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-supports.js","sources":["../../../src/utils/native-supports.ts"],"sourcesContent":["/**\n * Возвращает `true`, если поддерживается `input[type=\"date\"]`\n */\nexport function isInputDateSupported() {\n const input = document.createElement('input');\n const value = 'a';\n\n input.setAttribute('type', 'date');\n input.setAttribute('value', value);\n\n return input.value !== value;\n}\n"],"names":[],"mappings":"AAAA;;AAEG;SACa,oBAAoB,GAAA;IAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;IAC7C,MAAM,KAAK,GAAG,GAAG;AAEjB,IAAA,KAAK,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;AAClC,IAAA,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC;AAElC,IAAA,OAAO,KAAK,CAAC,KAAK,KAAK,KAAK;AAChC;;;;"}
@@ -1,7 +1,7 @@
1
1
  import React, { forwardRef, useRef, useState, useEffect } from 'react';
2
2
  import mergeRefs from 'react-merge-refs';
3
3
  import { Input } from '@alfalab/core-components-input/moderncssm';
4
- import { format, parseDateString, isCompleteDateInput, isValid, NATIVE_DATE_FORMAT, formatDate } from './utils/format.js';
4
+ import { format, parseDateString, isCompleteDateInput, isValid, formatDate, NATIVE_DATE_FORMAT } from './utils/format.js';
5
5
  import { isInputDateSupported } from './utils/native-supports.js';
6
6
  import styles from './index.module.css';
7
7
 
@@ -91,3 +91,4 @@ function getDotsCount(value) {
91
91
  }
92
92
 
93
93
  export { DateInput };
94
+ //# sourceMappingURL=Component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Component.js","sources":["../../src/Component.tsx"],"sourcesContent":["import React, { ChangeEvent, FocusEvent, forwardRef, useEffect, useRef, useState } from 'react';\nimport mergeRefs from 'react-merge-refs';\n\nimport { Input, InputProps } from '@alfalab/core-components-input';\n\nimport {\n format,\n formatDate,\n isCompleteDateInput,\n isInputDateSupported,\n isValid,\n NATIVE_DATE_FORMAT,\n parseDateString,\n} from './utils';\n\nimport styles from './index.module.css';\n\nexport type DateInputProps = Omit<InputProps, 'onChange'> & {\n /**\n * Управление нативным режимом на мобильных устройствах\n */\n mobileMode?: 'input' | 'native';\n\n /**\n * Обработчик изменения значения\n */\n onChange?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { date: Date; value: string },\n ) => void;\n\n /**\n * Обработчик окончания ввода\n */\n onComplete?: (\n event: ChangeEvent<HTMLInputElement>,\n payload: { date: Date; value: string },\n ) => void;\n};\n\n/**\n * @deprecated\n * use UniversalDateInput instead\n */\nexport const DateInput = forwardRef<HTMLInputElement, DateInputProps>(\n (\n {\n mobileMode = 'input',\n defaultValue = '',\n rightAddons,\n error,\n value: propValue,\n onBlur,\n onChange,\n onComplete,\n ...restProps\n },\n ref,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const [shouldRenderNative, setShouldRenderNative] = useState(false);\n\n const [value, setValue] = useState(propValue || defaultValue);\n\n const moveCaretTo = (pos: number) => {\n requestAnimationFrame(() => {\n inputRef.current?.setSelectionRange(pos, pos);\n });\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: newValue } = event.target;\n const caretPos = event.target.selectionStart || 0;\n\n // Позволяем вводить только цифры и точки\n if (/[^\\d.]/.test(newValue)) {\n moveCaretTo(caretPos - 1);\n\n return;\n }\n\n // Не даем вводить больше, чем 2 точки\n if (getDotsCount(newValue) > 2) {\n moveCaretTo(caretPos - 1);\n\n return;\n }\n\n // Форматируем введенное значение (добавляем точки)\n const formattedValue = format(newValue);\n const date = parseDateString(formattedValue);\n\n // Управляем кареткой, если она находится не в конце инпута\n if (caretPos !== newValue.length) {\n if (formattedValue === value) {\n moveCaretTo(caretPos);\n } else if (newValue.length - formattedValue.length === 1) {\n moveCaretTo(caretPos);\n } else if (\n formattedValue.length - newValue.length === 1 &&\n getDotsCount(formattedValue) > getDotsCount(newValue)\n ) {\n moveCaretTo(caretPos);\n }\n }\n\n setValue(formattedValue);\n\n if (onChange) onChange(event, { date, value: formattedValue });\n\n if (isCompleteDateInput(formattedValue)) {\n const valid = formattedValue.length > 0 && isValid(formattedValue);\n\n if (!valid) return;\n\n if (onComplete) onComplete(event, { date, value: formattedValue });\n }\n };\n\n const handleNativeInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n const newDate = parseDateString(event.target.value, NATIVE_DATE_FORMAT);\n const newValue = event.target.value === '' ? '' : formatDate(newDate);\n\n setValue(newValue);\n\n if (onComplete) onComplete(event, { date: newDate, value: newValue });\n if (onChange) onChange(event, { date: newDate, value: newValue });\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n if (onBlur) onBlur(event);\n };\n\n useEffect(() => {\n if (mobileMode === 'native' && isInputDateSupported()) {\n setShouldRenderNative(true);\n }\n }, [mobileMode]);\n\n useEffect(() => {\n if (typeof propValue !== 'undefined') {\n setValue(propValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [propValue]);\n\n return (\n <Input\n {...restProps}\n ref={mergeRefs([ref, inputRef])}\n value={value}\n inputMode='decimal'\n pattern='[0-9\\.]*'\n onChange={handleChange}\n onBlur={handleBlur}\n placeholder='ДД.ММ.ГГГГ'\n error={error}\n rightAddons={\n <React.Fragment>\n {rightAddons}\n\n {shouldRenderNative && (\n <input\n type='date'\n ref={ref}\n defaultValue={defaultValue}\n onChange={handleNativeInputChange}\n className={styles.nativeInput}\n />\n )}\n </React.Fragment>\n }\n />\n );\n },\n);\n\nfunction getDotsCount(value: string) {\n return (value.match(/\\./g) || []).length;\n}\n"],"names":[],"mappings":";;;;;;;AAwCA;;;AAGG;AACU,MAAA,SAAS,GAAG,UAAU,CAC/B,CACI,EACI,UAAU,GAAG,OAAO,EACpB,YAAY,GAAG,EAAE,EACjB,WAAW,EACX,KAAK,EACL,KAAK,EAAE,SAAS,EAChB,MAAM,EACN,QAAQ,EACR,UAAU,EACV,GAAG,SAAS,EACf,EACD,GAAG,KACH;AACA,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC;IAE/C,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAEnE,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,SAAS,IAAI,YAAY,CAAC;AAE7D,IAAA,MAAM,WAAW,GAAG,CAAC,GAAW,KAAI;QAChC,qBAAqB,CAAC,MAAK;YACvB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC;AACjD,SAAC,CAAC;AACN,KAAC;AAED,IAAA,MAAM,YAAY,GAAG,CAAC,KAAoC,KAAI;QAC1D,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,MAAM;QACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc,IAAI,CAAC;;AAGjD,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC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AA,CAAA,aAAA,CAAC,KAAK,CAAC,QAAQ,EAAA,IAAA;YACV,WAAW;AAEX,YAAA,kBAAkB,KACf,KACI,CAAA,aAAA,CAAA,OAAA,EAAA,EAAA,IAAI,EAAC,MAAM,EACX,GAAG,EAAE,GAAG,EACR,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,uBAAuB,EACjC,SAAS,EAAE,MAAM,CAAC,WAAW,EAC/B,CAAA,CACL,CACY,EAAA,CAEvB;AAEV,CAAC;AAGL,SAAS,YAAY,CAAC,KAAa,EAAA;AAC/B,IAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,MAAM;AAC5C;;;;"}
@@ -1,3 +1,4 @@
1
1
  export { DateInput } from './Component.js';
2
2
  export { DATE_FORMAT, DATE_MASK, NATIVE_DATE_FORMAT, format, formatDate, isCompleteDateInput, isValid, parseDateString } from './utils/format.js';
3
3
  export { isInputDateSupported } from './utils/native-supports.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,5 +1,3 @@
1
- /* */
2
-
3
1
  .nativeInput {
4
2
  opacity: 0;
5
3
  position: absolute;
@@ -7,7 +5,9 @@
7
5
  left: var(--gap-0);
8
6
  width: 100%;
9
7
  height: 100%;
10
- appearance: none;
8
+ -webkit-appearance: none;
9
+ -moz-appearance: none;
10
+ appearance: none;
11
11
  z-index: 1
12
12
  }
13
13
 
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { ChangeEvent } from "react";
4
- import { InputProps } from "@alfalab/core-components-input";
5
- type DateInputProps = Omit<InputProps, 'onChange'> & {
1
+ import React, { ChangeEvent } from 'react';
2
+ import { InputProps } from '@alfalab/core-components-input';
3
+ export declare type DateInputProps = Omit<InputProps, 'onChange'> & {
6
4
  /**
7
5
  * Управление нативным режимом на мобильных устройствах
8
6
  */
@@ -26,7 +24,7 @@ type DateInputProps = Omit<InputProps, 'onChange'> & {
26
24
  * @deprecated
27
25
  * use UniversalDateInput instead
28
26
  */
29
- declare const DateInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
27
+ export declare const DateInput: React.ForwardRefExoticComponent<Omit<InputProps, "onChange"> & {
30
28
  /**
31
29
  * Управление нативным режимом на мобильных устройствах
32
30
  */
@@ -46,4 +44,3 @@ declare const DateInput: React.ForwardRefExoticComponent<Omit<InputProps, "onCha
46
44
  value: string;
47
45
  }) => void) | undefined;
48
46
  } & React.RefAttributes<HTMLInputElement>>;
49
- export { DateInputProps, DateInput };
@@ -0,0 +1,2 @@
1
+ export * from './Component';
2
+ export * from './utils';
@@ -0,0 +1,8 @@
1
+ export declare const DATE_FORMAT = "dd.MM.yyyy";
2
+ export declare const NATIVE_DATE_FORMAT = "yyyy-MM-dd";
3
+ export declare const DATE_MASK: (string | RegExp)[];
4
+ export declare const isCompleteDateInput: (input: string) => boolean;
5
+ export declare const formatDate: (date: Date | number, dateFormat?: string) => string;
6
+ export declare const parseDateString: (value: string, dateFormat?: string) => Date;
7
+ export declare const isValid: (inputValue?: string) => boolean;
8
+ export declare const format: (value: string) => string;
@@ -0,0 +1,2 @@
1
+ export * from './format';
2
+ export * from './native-supports';
@@ -1,5 +1,4 @@
1
1
  /**
2
2
  * Возвращает `true`, если поддерживается `input[type="date"]`
3
3
  */
4
- declare function isInputDateSupported(): boolean;
5
- export { isInputDateSupported };
4
+ export declare function isInputDateSupported(): boolean;
@@ -28,3 +28,4 @@ const format = (value) => value
28
28
  .replace(/^()\.(\d)\.(\d\d\d\d)([0-9]*)/, '$1.$2.$3'); // .2.2005123123 => .2.2005
29
29
 
30
30
  export { DATE_FORMAT, DATE_MASK, NATIVE_DATE_FORMAT, format, formatDate, isCompleteDateInput, isValid, parseDateString };
31
+ //# sourceMappingURL=format.js.map