@alfalab/core-components-date-range-input 3.0.4 → 3.0.6

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 (33) hide show
  1. package/Component-63dec22f.d.ts +172 -12
  2. package/Component-8b5756fe.d.ts +388 -0
  3. package/Component.desktop-8b5756fe.d.ts +68 -5
  4. package/Component.mobile-ebda875c.d.ts +6 -0
  5. package/components/date-range-input/Component.d.ts +1 -1
  6. package/components/date-range-input/Component.js +2 -8
  7. package/components/date-range-input/index.css +7 -7
  8. package/cssm/components/date-range-input/Component.js +1 -7
  9. package/cssm/{index-50136800.d.ts → index-2abb571d.d.ts} +5 -1
  10. package/esm/components/date-range-input/Component.js +2 -8
  11. package/esm/components/date-range-input/index.css +7 -7
  12. package/{modern/index-50136800.d.ts → esm/index-2abb571d.d.ts} +5 -1
  13. package/{esm/index-50136800.d.ts → index-2abb571d.d.ts} +5 -1
  14. package/index-9211a437.d.ts +1 -1
  15. package/index-ebda875c.d.ts +15 -115
  16. package/index-f034f741.d.ts +80 -2
  17. package/mobile-c219f8ca.d.ts +1 -367
  18. package/modern/Component-2abb571d.d.ts +6 -0
  19. package/modern/components/date-range-input/Component.js +2 -8
  20. package/modern/components/date-range-input/index.css +7 -7
  21. package/{index-50136800.d.ts → modern/index-2abb571d.d.ts} +5 -1
  22. package/package.json +4 -4
  23. package/src/components/date-range-input/Component.tsx +1 -10
  24. package/Component-50136800.d.ts +0 -186
  25. package/Component-5684a67d.d.ts +0 -23
  26. package/Component-e2b6c730.d.ts +0 -76
  27. package/Component.desktop-ebda875c.d.ts +0 -6
  28. package/desktop-8b5756fe.d.ts +0 -2
  29. package/utils-e0a54580.d.ts +0 -8
  30. /package/{cssm/Component-50136800.d.ts → Component-2abb571d.d.ts} +0 -0
  31. /package/{Component.responsive-755fbaa3.d.ts → Component.responsive-2e2b2125.d.ts} +0 -0
  32. /package/{esm/Component-50136800.d.ts → cssm/Component-2abb571d.d.ts} +0 -0
  33. /package/{modern/Component-50136800.d.ts → esm/Component-2abb571d.d.ts} +0 -0
@@ -1,367 +1 @@
1
- /// <reference types="react" />
2
- /// <reference types="react-transition-group" />
3
- import React from "react";
4
- import { ReactNode, FC, KeyboardEvent, MouseEvent, MutableRefObject, Ref, RefObject } from "react";
5
- import { CalendarDesktopProps } from "./Component.desktop-8b5756fe";
6
- import { TransitionProps } from "react-transition-group/Transition";
7
- import { CSSTransitionClassNames } from "react-transition-group/CSSTransition";
8
- import { NavigationBarProps } from "./types-83e2bd9e";
9
- type CalendarMobileProps = CalendarDesktopProps & {
10
- /**
11
- * Управление видимостью модалки
12
- */
13
- open: boolean;
14
- /**
15
- * Заголовок календаря
16
- */
17
- title?: string;
18
- /**
19
- * Обработчик закрытия модалки
20
- */
21
- onClose?: () => void;
22
- /**
23
- * Обработчик клика на название месяца в мобильном календаре
24
- */
25
- onMonthTitleClick?: (event: React.MouseEvent<HTMLSpanElement>) => void;
26
- /**
27
- * Количество лет для генерации в обе стороны от текущего года
28
- */
29
- yearsAmount?: number;
30
- /**
31
- * Нужно ли рендерить шапку
32
- */
33
- hasHeader?: boolean;
34
- /**
35
- * Разрешить выбор из недозаполненного диапазона дат.
36
- */
37
- allowSelectionFromEmptyRange?: boolean;
38
- };
39
- declare const CalendarMobile: React.ForwardRefExoticComponent<CalendarDesktopProps & {
40
- open: boolean;
41
- title?: string | undefined;
42
- onClose?: (() => void) | undefined;
43
- onMonthTitleClick?: ((event: React.MouseEvent<HTMLSpanElement>) => void) | undefined;
44
- yearsAmount?: number | undefined;
45
- hasHeader?: boolean | undefined;
46
- allowSelectionFromEmptyRange?: boolean | undefined;
47
- } & React.RefAttributes<HTMLDivElement>>;
48
- type BackdropProps = Partial<TransitionProps> & {
49
- /**
50
- * Прозрачный бэкдроп
51
- */
52
- invisible?: boolean;
53
- /**
54
- * Управляет видимостью компонента
55
- */
56
- open: boolean;
57
- /**
58
- * Обработчик клика по бэкдропу
59
- */
60
- onClose?: (event: MouseEvent<HTMLElement>) => void;
61
- /**
62
- * Дополнительный класс
63
- */
64
- className?: string;
65
- /**
66
- * Классы анимации
67
- *
68
- * http://reactcommunity.org/react-transition-group/css-transition#CSSTransition-prop-classNames
69
- */
70
- transitionClassNames?: string | CSSTransitionClassNames;
71
- /**
72
- * Идентификатор для систем автоматизированного тестирования
73
- */
74
- dataTestId?: string;
75
- /**
76
- * Дочерние элементы.
77
- */
78
- children?: ReactNode;
79
- };
80
- type PortalProps = {
81
- /** Контент */
82
- children?: ReactNode;
83
- /**
84
- * Функция, возвращающая контейнер, в который будут рендериться дочерние элементы
85
- */
86
- getPortalContainer?: () => Element;
87
- /**
88
- * Немедленно отрендерить дочерние элементы (false - контент будет отрендерен на след. рендер).
89
- */
90
- immediateMount?: boolean;
91
- };
92
- type BaseModalProps = {
93
- /**
94
- * Контент
95
- */
96
- children?: ReactNode;
97
- /**
98
- * Компонент бэкдропа
99
- */
100
- Backdrop?: FC<BackdropProps>;
101
- /**
102
- * Свойства для Бэкдропа
103
- */
104
- backdropProps?: Partial<BackdropProps> & Record<string, unknown>;
105
- /**
106
- * Нода, компонент или функция возвращающая их
107
- *
108
- * Контейнер к которому будут добавляться порталы
109
- */
110
- container?: PortalProps["getPortalContainer"];
111
- /**
112
- * Отключает автоматический перевод фокуса на модалку при открытии
113
- * @default false
114
- */
115
- disableAutoFocus?: boolean;
116
- /**
117
- * Отключает ловушку фокуса
118
- * @default false
119
- */
120
- disableFocusLock?: boolean;
121
- /**
122
- * Отключает восстановление фокуса на предыдущем элементе после закрытия модалки
123
- * @default false
124
- */
125
- disableRestoreFocus?: boolean;
126
- /**
127
- * Отключает вызов `callback` при нажатии Escape
128
- * @default false
129
- */
130
- disableEscapeKeyDown?: boolean;
131
- /**
132
- * Отключает вызов `callback` при клике на бэкдроп
133
- * @default false
134
- */
135
- disableBackdropClick?: boolean;
136
- /**
137
- * Отключает блокировку скролла при открытии модального окна
138
- * @default false
139
- */
140
- disableBlockingScroll?: boolean;
141
- /**
142
- * Содержимое модалки всегда в DOM
143
- * @default false
144
- */
145
- keepMounted?: boolean;
146
- /**
147
- * Управление видимостью модалки
148
- */
149
- open: boolean;
150
- /**
151
- * Дополнительный класс
152
- */
153
- className?: string;
154
- /**
155
- * Дополнительный класс
156
- */
157
- contentClassName?: string;
158
- /**
159
- * Дополнительные пропсы на обертку контента
160
- */
161
- contentProps?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
162
- /**
163
- * Дополнительные пропсы на компонентную обертку контента
164
- */
165
- componentDivProps?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
166
- /**
167
- * Дополнительный класс для обертки (Modal)
168
- */
169
- wrapperClassName?: string;
170
- /**
171
- * Обработчик скролла контента
172
- */
173
- scrollHandler?: "wrapper" | "content" | MutableRefObject<HTMLDivElement | null>;
174
- /**
175
- * Пропсы для анимации (CSSTransition)
176
- */
177
- transitionProps?: Partial<TransitionProps>;
178
- /**
179
- * Рендерить ли в контейнер через портал.
180
- * @default true
181
- */
182
- usePortal?: boolean;
183
- /**
184
- * Обработчик события нажатия на бэкдроп
185
- */
186
- onBackdropClick?: (event: MouseEvent) => void;
187
- /**
188
- * Обработчик события нажатия на Escape
189
- *
190
- * Если `disableEscapeKeyDown` - false и модальное окно в фокусе
191
- */
192
- onEscapeKeyDown?: (event: KeyboardEvent) => void;
193
- /**
194
- * Обработчик закрытия
195
- */
196
- onClose?: (event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>, reason?: "backdropClick" | "escapeKeyDown" | "closerClick") => void;
197
- /**
198
- * Обработчик события onEntered компонента Transition
199
- */
200
- onMount?: () => void;
201
- /**
202
- * Обработчик события onExited компонента Transition
203
- */
204
- onUnmount?: () => void;
205
- /**
206
- * Идентификатор для систем автоматизированного тестирования
207
- */
208
- dataTestId?: string;
209
- /**
210
- * z-index компонента
211
- */
212
- zIndex?: number;
213
- /**
214
- * Реф, который должен быть установлен компонентной области
215
- */
216
- componentRef?: MutableRefObject<HTMLDivElement | null>;
217
- };
218
- type BaseModalContext = {
219
- parentRef: React.RefObject<HTMLDivElement>;
220
- componentRef: React.RefObject<HTMLDivElement>;
221
- hasFooter?: boolean;
222
- hasHeader?: boolean;
223
- hasScroll?: boolean;
224
- headerHighlighted?: boolean;
225
- footerHighlighted?: boolean;
226
- headerOffset?: number;
227
- setHeaderOffset: (offset: number) => void;
228
- contentRef: Ref<HTMLElement>;
229
- setHasHeader: (exists: boolean) => void;
230
- setHasFooter: (exists: boolean) => void;
231
- onClose: Required<BaseModalProps>["onClose"];
232
- };
233
- // eslint-disable-next-line @typescript-eslint/no-redeclare
234
- declare const BaseModalContext: React.Context<BaseModalContext>;
235
- type ModalDesktopProps = BaseModalProps & {
236
- /**
237
- * Ширина модального окна
238
- * @default "m"
239
- */
240
- size?: "s" | "m" | "l" | "xl" | "fullscreen";
241
- /**
242
- * Растягивает модальное окно на весь экран
243
- * @deprecated Используйте размер fullscreen
244
- */
245
- fullscreen?: boolean;
246
- /**
247
- * Фиксирует позицию модального окна после открытия,
248
- * предотвращая скачки, если контент внутри будет меняться
249
- */
250
- fixedPosition?: boolean;
251
- /**
252
- * Управление наличием закрывающего крестика
253
- * @default false
254
- */
255
- hasCloser?: boolean;
256
- };
257
- type ModalMobileProps = Omit<ModalDesktopProps, "size" | "fixedPosition" | "fullscreen">;
258
- type View = "desktop" | "mobile";
259
- type TResponsiveModalContext = {
260
- view: View;
261
- size: NonNullable<ModalDesktopProps["size"]>;
262
- };
263
- type ContentProps = {
264
- /**
265
- * Контент
266
- */
267
- children?: ReactNode;
268
- /**
269
- * Дополнительный класс
270
- */
271
- className?: string;
272
- /**
273
- * Растягивает контент на всю высоту
274
- */
275
- flex?: boolean;
276
- };
277
- type HeaderProps = Omit<NavigationBarProps, "size" | "view" | "parentRef">;
278
- type FooterProps = {
279
- /**
280
- * Контент футера
281
- */
282
- children?: ReactNode;
283
- /**
284
- * Дополнительный класс
285
- */
286
- className?: string;
287
- /**
288
- * Фиксирует футер
289
- */
290
- sticky?: boolean;
291
- /**
292
- * Выравнивание элементов футера
293
- */
294
- layout?: "start" | "center" | "space-between" | "column";
295
- /**
296
- * Отступы между элементами футера
297
- */
298
- gap?: 16 | 24 | 32;
299
- };
300
- declare const ModalMobile: React.ForwardRefExoticComponent<ModalMobileProps & React.RefAttributes<HTMLDivElement>> & {
301
- Content: React.FC<ContentProps>;
302
- Header: React.FC<HeaderProps>;
303
- Footer: React.FC<FooterProps>;
304
- };
305
- declare const Content: FC<ContentProps>;
306
- declare const ResponsiveContext: React.Context<TResponsiveModalContext>;
307
- declare const Modal: React.ForwardRefExoticComponent<BaseModalProps & {
308
- size?: "s" | "m" | "l" | "xl" | "fullscreen" | undefined;
309
- fullscreen?: boolean | undefined;
310
- fixedPosition?: boolean | undefined;
311
- hasCloser?: boolean | undefined;
312
- } & {
313
- view: View;
314
- } & React.RefAttributes<HTMLDivElement>>;
315
- declare const ModalContext: import("react").Context<BaseModalContext>;
316
- /**
317
- * Набор констант для z-index соответствующих классов компонентов.
318
- * Значения выбраны по приоритету.
319
- */
320
- declare const stackingOrder: {
321
- FOCUSED: number;
322
- DEFAULT: number;
323
- POPOVER: number;
324
- MODAL: number;
325
- TOAST: number;
326
- };
327
- declare const StackingContext: import("react").Context<number>;
328
- type StackProps = {
329
- /**
330
- * Render prop, в который передается функция.
331
- * Функция принимает аргумент со значением z-index из текущего контекста.
332
- */
333
- children: (value: number) => ReactNode;
334
- /**
335
- * Исходное значение для z-index.
336
- * @default 5
337
- */
338
- value?: number;
339
- };
340
- declare const Stack: FC<StackProps>;
341
- declare const PORTAL_CONTAINER_ATTRIBUTE = "alfa-portal-container";
342
- declare const getDefaultPortalContainer: () => Element;
343
- declare function setRef<T>(ref: RefObject<T> | ((instance: T | null) => void) | null | undefined, value: T | null): void;
344
- type SavedStyle = {
345
- value: string;
346
- key: string;
347
- el: HTMLElement;
348
- };
349
- type RestoreStyle = {
350
- container: HTMLElement;
351
- modals: number;
352
- styles: SavedStyle[];
353
- };
354
- declare class ModalStore {
355
- private readonly restoreStyles;
356
- constructor();
357
- getRestoreStyles: () => RestoreStyle[];
358
- }
359
- declare const getModalStore: () => ModalStore;
360
- declare class GlobalStore {
361
- private readonly modalStore;
362
- constructor();
363
- getModalStore: () => ModalStore;
364
- }
365
- export { CalendarMobileProps, CalendarMobile, ModalMobile, ModalMobileProps, Content, ResponsiveContext, Modal, ModalContext, stackingOrder, StackingContext, StackProps, Stack, PORTAL_CONTAINER_ATTRIBUTE, getDefaultPortalContainer, setRef, getModalStore, GlobalStore };
366
- export * from "./Component.mobile-755fbaa3";
367
- export type { SavedStyle };
1
+ export * from "./Component-8b5756fe";
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+ import { NavigationBarProps } from "./types-83e2bd9e";
4
+ declare const NavigationBar: React.ForwardRefExoticComponent<NavigationBarProps & React.RefAttributes<HTMLDivElement>>;
5
+ export * from "./Component-63dec22f";
6
+ export { NavigationBar };
@@ -11,7 +11,7 @@ import { CalendarMIcon } from '@alfalab/icons-glyph/CalendarMIcon';
11
11
  import { parseTimestampToDate, DATE_FORMAT, format, parseDateString, DATE_MASK, isCompleteDateInput, isValid } from '../../utils/format.js';
12
12
  import 'date-fns/parse';
13
13
 
14
- const styles = {"component":"date-range-input__component_r7x48","calendarContainer":"date-range-input__calendarContainer_r7x48","calendarResponsive":"date-range-input__calendarResponsive_r7x48","block":"date-range-input__block_r7x48","calendarIcon":"date-range-input__calendarIcon_r7x48"};
14
+ const styles = {"component":"date-range-input__component_1v70p","calendarContainer":"date-range-input__calendarContainer_1v70p","calendarResponsive":"date-range-input__calendarResponsive_1v70p","block":"date-range-input__block_1v70p","calendarIcon":"date-range-input__calendarIcon_1v70p"};
15
15
  require('./index.css')
16
16
 
17
17
  /* eslint-disable no-useless-escape, jsx-a11y/click-events-have-key-events */
@@ -101,12 +101,6 @@ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverCla
101
101
  }
102
102
  }
103
103
  };
104
- const handleInputKeyDown = (event) => {
105
- const isCopy = (event.metaKey || event.ctrlKey) && event.key === 'c';
106
- if (disableUserInput && !isCopy && event.key !== 'Tab') {
107
- event.preventDefault();
108
- }
109
- };
110
104
  const handleBlur = (event) => {
111
105
  if (view === 'desktop') {
112
106
  const target = (event.relatedTarget || document.activeElement);
@@ -203,7 +197,7 @@ const DateRangeInput = React.forwardRef(({ className, inputClassName, popoverCla
203
197
  return (React.createElement("div", { className: cn(styles.component, className, {
204
198
  [styles.block]: block,
205
199
  }), onFocus: inputDisabled ? undefined : handleInputWrapperFocus, onBlur: handleBlur },
206
- InputComponent ? (React.createElement(InputComponent, { ...restProps, block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, onKeyDown: handleInputKeyDown, rightAddons: React.createElement(React.Fragment, null,
200
+ InputComponent ? (React.createElement(InputComponent, { ...restProps, block: block, ref: mergeRefs([ref, inputRef]), value: value, onChange: handleChange, disabled: disabled, readOnly: readOnly, className: inputClassName, onClear: handleClear, disableUserInput: disableUserInput, rightAddons: React.createElement(React.Fragment, null,
207
201
  rightAddons,
208
202
  picker && (React.createElement(IconButton, { className: styles.calendarIcon, ref: iconRef, onClick: inputDisabled ? undefined : handleIconButtonClick, icon: CalendarMIcon, size: 's' }))) })) : null,
209
203
  picker && (React.createElement(Popover, { open: open, useAnchorWidth: useAnchorWidth, anchorElement: inputRef.current, popperClassName: cn(styles.calendarContainer, {
@@ -1,4 +1,4 @@
1
- /* hash: 19mkh */
1
+ /* hash: 113ul */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-border-secondary: #e9e9eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
@@ -41,24 +41,24 @@
41
41
  /* marker */
42
42
  } :root {
43
43
  --calendar-popover-border-radius: var(--border-radius-m);
44
- } .date-range-input__component_r7x48 {
44
+ } .date-range-input__component_1v70p {
45
45
  display: inline-block;
46
46
  outline: none;
47
47
  position: relative;
48
- } .date-range-input__calendarContainer_r7x48 {
48
+ } .date-range-input__calendarContainer_1v70p {
49
49
  display: inline-block;
50
50
  box-sizing: border-box;
51
51
  border-radius: var(--calendar-popover-border-radius);
52
52
  border: 1px solid var(--color-light-border-secondary)
53
- } @media (max-width: 374px) { .date-range-input__calendarContainer_r7x48 {
53
+ } @media (max-width: 374px) { .date-range-input__calendarContainer_1v70p {
54
54
  width: 100%;
55
55
  min-width: 288px
56
56
  }
57
- } .date-range-input__calendarResponsive_r7x48 {
57
+ } .date-range-input__calendarResponsive_1v70p {
58
58
  width: var(--calendar-width);
59
- } .date-range-input__block_r7x48 {
59
+ } .date-range-input__block_1v70p {
60
60
  width: 100%;
61
- } .date-range-input__calendarIcon_r7x48 {
61
+ } .date-range-input__calendarIcon_1v70p {
62
62
  margin-right: var(--gap-s-neg);
63
63
  height: 100%;
64
64
  }
@@ -8,4 +8,8 @@ declare function easeInOutQuad(x: number): number;
8
8
  declare const easingFns: {
9
9
  easeInOutQuad: typeof easeInOutQuad;
10
10
  };
11
- export { isClient, getDataTestId, createPaddingStyle, easingFns };
11
+ declare function disableUserInput<T>(disabled: boolean | undefined, event: React.KeyboardEvent<T>): void;
12
+ declare const inputUtils: {
13
+ disableUserInput: typeof disableUserInput;
14
+ };
15
+ export { isClient, getDataTestId, createPaddingStyle, easingFns, inputUtils };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-date-range-input",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -35,9 +35,9 @@
35
35
  "react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@alfalab/core-components-input": "^12.0.2",
39
- "@alfalab/core-components-icon-button": "^6.2.2",
40
- "@alfalab/core-components-calendar": "^7.0.3",
38
+ "@alfalab/core-components-input": "^12.1.1",
39
+ "@alfalab/core-components-icon-button": "^6.2.3",
40
+ "@alfalab/core-components-calendar": "^7.0.4",
41
41
  "@alfalab/core-components-popover": "^6.1.0",
42
42
  "@alfalab/hooks": "^1.13.0",
43
43
  "@alfalab/icons-glyph": "^2.108.0",
@@ -3,7 +3,6 @@ import React, {
3
3
  ChangeEvent,
4
4
  ElementType,
5
5
  FocusEvent,
6
- KeyboardEvent,
7
6
  MouseEvent,
8
7
  useEffect,
9
8
  useRef,
@@ -316,14 +315,6 @@ export const DateRangeInput = React.forwardRef<HTMLInputElement, DateRangeInputP
316
315
  }
317
316
  };
318
317
 
319
- const handleInputKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
320
- const isCopy = (event.metaKey || event.ctrlKey) && event.key === 'c';
321
-
322
- if (disableUserInput && !isCopy && event.key !== 'Tab') {
323
- event.preventDefault();
324
- }
325
- };
326
-
327
318
  const handleBlur = (event: FocusEvent<HTMLDivElement>) => {
328
319
  if (view === 'desktop') {
329
320
  const target = (event.relatedTarget || document.activeElement) as HTMLElement;
@@ -476,7 +467,7 @@ export const DateRangeInput = React.forwardRef<HTMLInputElement, DateRangeInputP
476
467
  readOnly={readOnly}
477
468
  className={inputClassName}
478
469
  onClear={handleClear}
479
- onKeyDown={handleInputKeyDown}
470
+ disableUserInput={disableUserInput}
480
471
  rightAddons={
481
472
  <React.Fragment>
482
473
  {rightAddons}