@sima-land/ui-nucleons 44.2.10 → 45.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_internal/custom-scrollbar/index.d.ts +13 -7
- package/_internal/custom-scrollbar/index.js +29 -15
- package/_internal/dropdown-loading/index.d.ts +3 -3
- package/_internal/dropdown-loading/index.js +4 -2
- package/_internal/page-scroll-lock/adapters/body-scroll-lock.d.ts +39 -0
- package/_internal/page-scroll-lock/adapters/body-scroll-lock.js +62 -0
- package/_internal/page-scroll-lock/adapters/ui-nucleons.d.ts +25 -0
- package/_internal/page-scroll-lock/adapters/ui-nucleons.js +103 -0
- package/_internal/page-scroll-lock/context.d.ts +13 -0
- package/_internal/page-scroll-lock/context.js +54 -0
- package/_internal/page-scroll-lock/hook.d.ts +12 -0
- package/_internal/page-scroll-lock/hook.js +26 -0
- package/_internal/page-scroll-lock/index.d.ts +4 -0
- package/_internal/page-scroll-lock/index.js +9 -0
- package/_internal/page-scroll-lock/types.d.ts +22 -0
- package/_internal/{checkbox/index.js → page-scroll-lock/types.js} +0 -0
- package/_internal/readme.md +2 -0
- package/_internal/utils/dropdown.d.ts +1 -0
- package/_internal/utils/dropdown.js +1 -0
- package/alert/alert.module.scss +1 -24
- package/alert/index.d.ts +11 -17
- package/alert/index.js +33 -16
- package/arrow-button/arrow-button.module.scss +2 -0
- package/arrow-button/index.d.ts +2 -2
- package/autocomplete/autocomplete.d.ts +8 -0
- package/autocomplete/autocomplete.js +190 -0
- package/autocomplete/autocomplete.module.scss +2 -15
- package/autocomplete/index.d.ts +2 -27
- package/autocomplete/index.js +2 -126
- package/autocomplete/types.d.ts +19 -0
- package/autocomplete/types.js +2 -0
- package/autocomplete-deprecated/autocomplete.module.scss +20 -0
- package/autocomplete-deprecated/index.d.ts +28 -0
- package/autocomplete-deprecated/index.js +130 -0
- package/avatar/index.d.ts +2 -2
- package/avatar/user.d.ts +1 -1
- package/base-input/base-input.d.ts +11 -0
- package/base-input/base-input.js +96 -0
- package/base-input/base-input.module.scss +3 -3
- package/base-input/index.d.ts +2 -23
- package/base-input/index.js +2 -76
- package/base-input/types.d.ts +31 -0
- package/base-input/types.js +2 -0
- package/base-input/utils.d.ts +6 -0
- package/base-input/utils.js +14 -0
- package/base-input-deprecated/base-input.module.scss +66 -0
- package/base-input-deprecated/index.d.ts +24 -0
- package/base-input-deprecated/index.js +80 -0
- package/bordered-layout/index.d.ts +1 -0
- package/bordered-layout/index.js +1 -0
- package/bottom-bar/bottom-bar-util.scss +20 -0
- package/bottom-bar/bottom-bar.d.ts +12 -0
- package/bottom-bar/bottom-bar.js +47 -0
- package/bottom-bar/bottom-bar.module.scss +14 -0
- package/bottom-bar/index.d.ts +2 -21
- package/bottom-bar/index.js +5 -44
- package/bottom-bar/types.d.ts +10 -0
- package/bottom-bar/types.js +2 -0
- package/box/index.d.ts +1 -1
- package/breakpoints.scss +1 -1
- package/button/button.module.scss +70 -53
- package/button/index.d.ts +26 -41
- package/button/index.js +22 -46
- package/card/index.d.ts +2 -1
- package/card/index.js +23 -6
- package/card/slots.d.ts +17 -3
- package/card/slots.js +15 -13
- package/carousel/draggable.d.ts +7 -3
- package/carousel/draggable.js +10 -3
- package/carousel/helpers/draggable-event.d.ts +5 -2
- package/carousel/helpers/draggable-event.js +5 -0
- package/carousel/index.d.ts +1 -1
- package/carousel/index.js +24 -24
- package/checkbox/checkbox.module.scss +1 -0
- package/checkbox/index.d.ts +3 -3
- package/checkbox-field/index.d.ts +3 -0
- package/checkbox-field/index.js +3 -0
- package/clean-buttons/clean-buttons-util.scss +15 -0
- package/clean-buttons/clean-buttons.module.scss +5 -3
- package/clean-buttons/index.d.ts +16 -7
- package/clean-buttons/index.js +17 -14
- package/clean-buttons/types.d.ts +1 -1
- package/clean-buttons/utils.d.ts +5 -1
- package/clean-buttons/utils.js +4 -0
- package/{colors.d.ts → colors/index.d.ts} +1 -1
- package/{colors.js → colors/index.js} +0 -0
- package/dot-nav/index.d.ts +1 -1
- package/dropdown/index.d.ts +1 -0
- package/dropdown/utils.d.ts +19 -0
- package/dropdown/utils.js +45 -0
- package/dropdown-item/dropdown-item.module.scss +80 -15
- package/dropdown-item/index.d.ts +20 -9
- package/dropdown-item/index.js +12 -9
- package/dropdown-item/types.d.ts +3 -0
- package/dropdown-item/types.js +2 -0
- package/dropdown-item/utils.d.ts +45 -0
- package/dropdown-item/utils.js +89 -0
- package/expandable/utils.js +3 -3
- package/field-block/field-block.module.scss +155 -0
- package/field-block/index.d.ts +63 -0
- package/field-block/index.js +43 -0
- package/field-grid/index.d.ts +5 -4
- package/field-grid/index.js +1 -0
- package/helpers/bounds-of.d.ts +5 -1
- package/helpers/bounds-of.js +5 -0
- package/helpers/center-of.d.ts +4 -1
- package/helpers/center-of.js +8 -1
- package/helpers/create-container.d.ts +5 -2
- package/helpers/create-container.js +7 -2
- package/helpers/define-slots.d.ts +3 -3
- package/helpers/define-slots.js +5 -3
- package/helpers/events.d.ts +16 -8
- package/helpers/events.js +41 -15
- package/helpers/find-child-element.d.ts +12 -9
- package/helpers/find-child-element.js +9 -5
- package/helpers/find-offset-parent.d.ts +1 -2
- package/helpers/find-offset-parent.js +2 -2
- package/helpers/find-sibling-index.d.ts +11 -8
- package/helpers/find-sibling-index.js +8 -3
- package/helpers/fit-element-height.d.ts +5 -5
- package/helpers/fit-element-height.js +9 -7
- package/helpers/format-date.d.ts +11 -11
- package/helpers/format-date.js +15 -13
- package/helpers/format-number.d.ts +1 -1
- package/helpers/format-number.js +2 -2
- package/helpers/get-date-interval-data.d.ts +4 -1
- package/helpers/get-date-interval-data.js +7 -2
- package/helpers/get-declination.d.ts +5 -1
- package/helpers/get-declination.js +5 -0
- package/helpers/get-fraction-depth.d.ts +1 -1
- package/helpers/get-fraction-depth.js +2 -2
- package/helpers/get-no-index.d.ts +2 -2
- package/helpers/get-no-index.js +4 -3
- package/helpers/get-relative-pos.d.ts +4 -1
- package/helpers/get-relative-pos.js +7 -2
- package/helpers/get-scroll-parent.d.ts +1 -2
- package/helpers/get-scroll-parent.js +5 -5
- package/helpers/is-browser.d.ts +4 -1
- package/helpers/is-browser.js +8 -1
- package/helpers/is-fully-scrolled.d.ts +3 -3
- package/helpers/is-fully-scrolled.js +2 -2
- package/helpers/is-touch-device.d.ts +1 -1
- package/helpers/is-touch-device.js +4 -5
- package/helpers/layer.d.ts +1 -1
- package/helpers/layer.js +2 -2
- package/helpers/max-index-of.d.ts +4 -1
- package/helpers/max-index-of.js +7 -2
- package/helpers/media-query-list.d.ts +1 -1
- package/helpers/media-query-list.js +2 -2
- package/helpers/on.d.ts +4 -1
- package/helpers/on.js +7 -2
- package/helpers/point.d.ts +4 -1
- package/helpers/point.js +8 -1
- package/helpers/rename.d.ts +3 -1
- package/helpers/rename.js +1 -0
- package/helpers/scroll-to-child.d.ts +1 -1
- package/helpers/scroll-to-child.js +3 -2
- package/helpers/styles.d.ts +8 -2
- package/helpers/styles.js +18 -4
- package/helpers/with-prevent.d.ts +9 -6
- package/helpers/with-prevent.js +16 -9
- package/hint/hint-view.d.ts +26 -0
- package/hint/hint-view.js +43 -0
- package/hint/hint-view.module.scss +31 -0
- package/hint/hint.d.ts +14 -0
- package/hint/hint.js +41 -0
- package/hint/index.d.ts +5 -8
- package/hint/index.js +13 -48
- package/hint/utils.d.ts +61 -0
- package/hint/utils.js +161 -0
- package/{hint → hint-deprecated}/hint.module.scss +0 -0
- package/hint-deprecated/index.d.ts +11 -0
- package/hint-deprecated/index.js +53 -0
- package/hooks/breakpoint/index.d.ts +7 -4
- package/hooks/breakpoint/index.js +21 -13
- package/hooks/breakpoint/types.d.ts +3 -4
- package/hooks/breakpoint/utils.d.ts +2 -1
- package/hooks/breakpoint/utils.js +2 -1
- package/hooks/index.d.ts +8 -8
- package/hooks/index.js +27 -19
- package/hooks/intersection/test-utils.d.ts +1 -1
- package/hooks/intersection/test-utils.js +2 -1
- package/hooks/styles.d.ts +6 -0
- package/hooks/styles.js +26 -0
- package/info-text/index.d.ts +23 -0
- package/info-text/index.js +60 -0
- package/info-text/info-text.module.scss +28 -0
- package/input/index.d.ts +32 -0
- package/input/index.js +96 -0
- package/input/input.module.scss +20 -0
- package/input/utils.d.ts +36 -0
- package/input/utils.js +71 -0
- package/layout/index.d.ts +6 -11
- package/layout/index.js +6 -60
- package/layout/layout.d.ts +10 -0
- package/layout/layout.js +32 -0
- package/layout/layout.module.scss +33 -26
- package/layout/legacy.d.ts +15 -0
- package/layout/legacy.js +68 -0
- package/layout/legacy.module.scss +49 -0
- package/layout/types.d.ts +6 -0
- package/layout/types.js +2 -0
- package/link/index.d.ts +4 -1
- package/link/index.js +2 -2
- package/link/link.module.scss +10 -0
- package/loading-overlay/index.d.ts +1 -0
- package/loading-overlay/index.js +1 -0
- package/masked-field/index.d.ts +1 -0
- package/masked-field/index.js +1 -0
- package/masked-input/hook.d.ts +8 -0
- package/masked-input/hook.js +72 -0
- package/masked-input/index.d.ts +5 -0
- package/masked-input/index.js +7 -0
- package/masked-input/masked-input.d.ts +8 -0
- package/masked-input/masked-input.js +73 -0
- package/masked-input/types.d.ts +51 -0
- package/masked-input/types.js +2 -0
- package/masked-input/utils.d.ts +15 -0
- package/masked-input/utils.js +49 -0
- package/modal/index.d.ts +10 -12
- package/modal/index.js +27 -64
- package/modal/modal.module.scss +98 -55
- package/modal/slots.d.ts +13 -10
- package/modal/slots.js +30 -28
- package/modal/utils.d.ts +8 -10
- package/modal/utils.js +2 -26
- package/modal-overlay/index.d.ts +13 -0
- package/modal-overlay/index.js +60 -0
- package/modal-overlay/modal-overlay-util.scss +1 -0
- package/modal-overlay/modal-overlay.module.scss +14 -0
- package/modal-overlay/utils.d.ts +14 -0
- package/modal-overlay/utils.js +32 -0
- package/package.json +49 -41
- package/pagination/utils.d.ts +2 -2
- package/panel/index.d.ts +27 -13
- package/panel/index.js +43 -9
- package/panel/panel.module.scss +49 -8
- package/phone-input/index.d.ts +4 -28
- package/phone-input/index.js +2 -121
- package/phone-input/phone-input.d.ts +8 -0
- package/phone-input/phone-input.js +133 -0
- package/phone-input/phone-input.module.scss +8 -32
- package/phone-input/presets.d.ts +21 -22
- package/phone-input/presets.js +1 -2
- package/phone-input/types.d.ts +6 -0
- package/phone-input/types.js +2 -0
- package/phone-input/utils.d.ts +30 -1
- package/phone-input/utils.js +52 -3
- package/phone-input-deprecated/index.d.ts +29 -0
- package/phone-input-deprecated/index.js +124 -0
- package/phone-input-deprecated/phone-input.module.scss +41 -0
- package/plate/index.d.ts +3 -3
- package/plate/index.js +2 -2
- package/plate/plate.module.scss +3 -0
- package/popup/index.d.ts +5 -0
- package/popup/index.js +12 -0
- package/popup/popup-view.d.ts +14 -0
- package/popup/popup-view.js +35 -0
- package/popup/popup-view.module.scss +40 -0
- package/popup/popup.d.ts +17 -0
- package/popup/popup.js +73 -0
- package/popup/utils.d.ts +38 -0
- package/popup/utils.js +83 -0
- package/price/index.d.ts +1 -1
- package/price/index.js +3 -3
- package/price/utils.d.ts +5 -5
- package/price/utils.js +33 -23
- package/radio-button/index.d.ts +10 -0
- package/radio-button/index.js +33 -0
- package/radio-button/radio-button.module.scss +46 -0
- package/rating/index.d.ts +2 -1
- package/rating/types.d.ts +1 -1
- package/readme.md +34 -41
- package/screen/index.d.ts +4 -2
- package/screen/index.js +34 -3
- package/screen/screen.module.scss +0 -2
- package/screen/slots.d.ts +2 -8
- package/screen/slots.js +8 -9
- package/screen/utils.d.ts +2 -1
- package/select/index.d.ts +2 -33
- package/select/index.js +3 -109
- package/select/parts/block.d.ts +8 -0
- package/select/parts/block.js +70 -0
- package/select/parts/block.module.scss +3 -0
- package/select/parts/button.d.ts +8 -0
- package/select/parts/button.js +69 -0
- package/select/parts/menu.d.ts +8 -0
- package/select/parts/menu.js +105 -0
- package/select/parts/menu.module.scss +4 -0
- package/select/select.d.ts +14 -0
- package/select/select.js +145 -0
- package/select/types.d.ts +55 -0
- package/select/types.js +2 -0
- package/select/utils.d.ts +3 -0
- package/select/utils.js +13 -0
- package/select-deprecated/index.d.ts +34 -0
- package/select-deprecated/index.js +112 -0
- package/{select → select-deprecated}/select.module.scss +0 -0
- package/shadows.scss +18 -0
- package/side-page/index.d.ts +11 -26
- package/side-page/index.js +21 -26
- package/side-page/side-page.module.scss +35 -29
- package/side-page/slots.d.ts +12 -20
- package/side-page/slots.js +16 -28
- package/spinner/index.d.ts +18 -6
- package/spinner/index.js +25 -12
- package/spinner/spinner.module.scss +8 -0
- package/stepper/index.d.ts +18 -10
- package/stepper/index.js +17 -8
- package/stepper/stepper.module.scss +14 -15
- package/styling/fonts.d.ts +3 -3
- package/switcher-row/index.d.ts +42 -0
- package/switcher-row/index.js +59 -0
- package/switcher-row/switcher-row.module.scss +55 -0
- package/text/index.d.ts +1 -1
- package/text-button/index.d.ts +42 -0
- package/text-button/index.js +46 -0
- package/text-button/text-button.module.scss +99 -0
- package/text-field/index.d.ts +7 -6
- package/text-field/index.js +3 -2
- package/textarea/index.d.ts +21 -0
- package/textarea/index.js +85 -0
- package/textarea/textarea.module.scss +15 -0
- package/toggle/index.d.ts +3 -3
- package/toggle/toggle.module.scss +17 -8
- package/tooltip/index.d.ts +1 -0
- package/tooltip/index.js +1 -0
- package/top-bar/index.d.ts +3 -40
- package/top-bar/index.js +4 -60
- package/top-bar/top-bar-util.scss +29 -0
- package/top-bar/top-bar.d.ts +9 -0
- package/top-bar/top-bar.js +101 -0
- package/top-bar/top-bar.module.scss +129 -67
- package/top-bar/types.d.ts +31 -0
- package/top-bar/types.js +2 -0
- package/top-bar/utils.d.ts +14 -0
- package/top-bar/utils.js +56 -0
- package/touch-slider/index.d.ts +1 -0
- package/touch-slider/index.js +3 -2
- package/types.d.ts +18 -0
- package/types.js +2 -0
- package/unknown-content/index.d.ts +3 -3
- package/unknown-content/index.js +3 -3
- package/unknown-content/unknown-content.module.scss +16 -12
- package/upload-area/index.d.ts +2 -0
- package/upload-area/index.js +5 -0
- package/upload-area/types.d.ts +32 -0
- package/upload-area/types.js +2 -0
- package/upload-area/upload-area-util.scss +17 -0
- package/upload-area/upload-area.d.ts +8 -0
- package/upload-area/upload-area.js +105 -0
- package/upload-area/upload-area.module.scss +78 -0
- package/{upload → upload-area}/upload.svg +0 -0
- package/upload-area/utils.d.ts +17 -0
- package/upload-area/utils.js +48 -0
- package/utils.scss +74 -1
- package/with-hint/index.d.ts +3 -2
- package/with-hint/index.js +1 -0
- package/with-hint/positioning-hint.d.ts +1 -1
- package/with-hint/positioning-hint.js +2 -2
- package/with-tooltip/index.d.ts +2 -1
- package/with-tooltip/index.js +1 -0
- package/with-tooltip/utils.d.ts +2 -2
- package/_internal/body-scroll.d.ts +0 -23
- package/_internal/body-scroll.js +0 -41
- package/_internal/checkbox/index.d.ts +0 -5
- package/constants.d.ts +0 -6
- package/constants.js +0 -9
- package/nav-bar/index.d.ts +0 -46
- package/nav-bar/index.js +0 -76
- package/nav-bar/nav-bar.module.scss +0 -95
- package/upload/area.d.ts +0 -25
- package/upload/area.js +0 -65
- package/upload/area.module.scss +0 -44
- package/upload/utils.d.ts +0 -29
- package/upload/utils.js +0 -45
package/field-grid/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TextFieldProps } from '../text-field';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type ItOrArray<T> = T[] | T;
|
|
4
|
+
type CellSize = 'full' | 'half' | 'third';
|
|
5
5
|
interface CommonCellProps {
|
|
6
6
|
size?: CellSize;
|
|
7
7
|
rounds?: TextFieldProps['rounds'];
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
type OnlyOneRequired<T, K extends keyof T = keyof T> = {
|
|
10
10
|
[key in K]?: Required<Pick<T, key>> & Partial<Record<Exclude<K, key>, undefined>>;
|
|
11
11
|
}[K];
|
|
12
|
-
export
|
|
12
|
+
export type CellProps = CommonCellProps & OnlyOneRequired<{
|
|
13
13
|
field: React.ReactElement<Pick<TextFieldProps, 'rounds' | 'caption' | 'classes' | 'className'>>;
|
|
14
14
|
renderField: (props: Pick<TextFieldProps, 'rounds' | 'caption'>) => React.ReactNode;
|
|
15
15
|
}>;
|
|
@@ -30,6 +30,7 @@ export interface FieldGridComponent extends React.FC<FieldGridProps> {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Компонент сетки полей.
|
|
33
|
+
* @deprecated В макетах больше не используются "склеивания" полей.
|
|
33
34
|
* @param props Свойства.
|
|
34
35
|
* @param props.children Содержимое, дочерними элементами могут быть только FieldGrid.Row.
|
|
35
36
|
* @param props.rootProps Свойства корневого элемента.
|
package/field-grid/index.js
CHANGED
|
@@ -42,6 +42,7 @@ const TypeCheck = {
|
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
44
|
* Компонент сетки полей.
|
|
45
|
+
* @deprecated В макетах больше не используются "склеивания" полей.
|
|
45
46
|
* @param props Свойства.
|
|
46
47
|
* @param props.children Содержимое, дочерними элементами могут быть только FieldGrid.Row.
|
|
47
48
|
* @param props.rootProps Свойства корневого элемента.
|
package/helpers/bounds-of.d.ts
CHANGED
|
@@ -3,4 +3,8 @@
|
|
|
3
3
|
* @param element Элемент.
|
|
4
4
|
* @return Ограничивающий прямоугольник.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export declare function boundsOf<T>(element: T): T extends Element ? DOMRect : null;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
9
|
+
*/
|
|
10
|
+
export default boundsOf;
|
package/helpers/bounds-of.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.boundsOf = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* Возвращает ограничивающий прямоугольник элемента.
|
|
5
6
|
* @param element Элемент.
|
|
@@ -8,4 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
9
|
function boundsOf(element) {
|
|
9
10
|
return (element instanceof Element ? element.getBoundingClientRect() : null);
|
|
10
11
|
}
|
|
12
|
+
exports.boundsOf = boundsOf;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
15
|
+
*/
|
|
11
16
|
exports.default = boundsOf;
|
package/helpers/center-of.d.ts
CHANGED
|
@@ -3,5 +3,8 @@
|
|
|
3
3
|
* @param rect Прямоугольник.
|
|
4
4
|
* @return Центр.
|
|
5
5
|
*/
|
|
6
|
-
declare
|
|
6
|
+
export declare function centerOf(rect: DOMRect): import("./point").IPoint;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
9
|
+
*/
|
|
7
10
|
export default centerOf;
|
package/helpers/center-of.js
CHANGED
|
@@ -3,11 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.centerOf = void 0;
|
|
6
7
|
const point_1 = __importDefault(require("./point"));
|
|
7
8
|
/**
|
|
8
9
|
* Возвращает координаты центра прямоугольника.
|
|
9
10
|
* @param rect Прямоугольник.
|
|
10
11
|
* @return Центр.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
function centerOf(rect) {
|
|
14
|
+
return (0, point_1.default)((rect.right + rect.left) / 2, (rect.bottom + rect.top) / 2);
|
|
15
|
+
}
|
|
16
|
+
exports.centerOf = centerOf;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
19
|
+
*/
|
|
13
20
|
exports.default = centerOf;
|
|
@@ -3,11 +3,14 @@ export interface Container<T> {
|
|
|
3
3
|
set: (v: T) => void;
|
|
4
4
|
setObserver: (fn: Observer<T> | null) => void;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
type Observer<T> = (prev: T | undefined, next: T | undefined) => void;
|
|
7
7
|
/**
|
|
8
8
|
* Фабрика контейнеров для произвольных значений.
|
|
9
9
|
* @param initialValue Начальное значение в контейнере.
|
|
10
10
|
* @return Контейнер.
|
|
11
11
|
*/
|
|
12
|
-
declare
|
|
12
|
+
export declare function createContainer<T = any>(initialValue?: T): Container<T>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
15
|
+
*/
|
|
13
16
|
export default createContainer;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createContainer = void 0;
|
|
3
4
|
/**
|
|
4
5
|
* Фабрика контейнеров для произвольных значений.
|
|
5
6
|
* @param initialValue Начальное значение в контейнере.
|
|
6
7
|
* @return Контейнер.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
function createContainer(initialValue) {
|
|
9
10
|
let value = initialValue;
|
|
10
11
|
let observe;
|
|
11
12
|
/**
|
|
@@ -30,5 +31,9 @@ const createContainer = (initialValue) => {
|
|
|
30
31
|
observe = newObserve;
|
|
31
32
|
};
|
|
32
33
|
return { get, set, setObserver };
|
|
33
|
-
}
|
|
34
|
+
}
|
|
35
|
+
exports.createContainer = createContainer;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
38
|
+
*/
|
|
34
39
|
exports.default = createContainer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type SlotsDict = Record<string, React.ElementType>;
|
|
3
|
+
export type Slots<M extends SlotsDict> = {
|
|
4
4
|
[key in keyof M]: React.ReactElement<React.ComponentProps<M[key]>, M[key]> | undefined;
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
@@ -9,4 +9,4 @@ export declare type Slots<M extends SlotsDict> = {
|
|
|
9
9
|
* @param dict Словарь типов элементов.
|
|
10
10
|
* @return Дочерние элементы разбитые по слотам.
|
|
11
11
|
*/
|
|
12
|
-
export declare
|
|
12
|
+
export declare function defineSlots<T extends SlotsDict>(children: React.ReactNode, dict: T): Slots<T>;
|
package/helpers/define-slots.js
CHANGED
|
@@ -8,14 +8,16 @@ const react_1 = require("react");
|
|
|
8
8
|
* @param type Тип.
|
|
9
9
|
* @return Результат.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
function isComponentOfType(value, type) {
|
|
12
|
+
return value.type === type;
|
|
13
|
+
}
|
|
12
14
|
/**
|
|
13
15
|
* Распределяет дочерние элементы по слотам.
|
|
14
16
|
* @param children Дочерние элементы.
|
|
15
17
|
* @param dict Словарь типов элементов.
|
|
16
18
|
* @return Дочерние элементы разбитые по слотам.
|
|
17
19
|
*/
|
|
18
|
-
|
|
20
|
+
function defineSlots(children, dict) {
|
|
19
21
|
const allKeys = Object.keys(dict);
|
|
20
22
|
const slots = react_1.Children.toArray(children).reduce((result, item) => {
|
|
21
23
|
if ((0, react_1.isValidElement)(item)) {
|
|
@@ -29,5 +31,5 @@ const defineSlots = (children, dict) => {
|
|
|
29
31
|
return result;
|
|
30
32
|
}, {});
|
|
31
33
|
return slots;
|
|
32
|
-
}
|
|
34
|
+
}
|
|
33
35
|
exports.defineSlots = defineSlots;
|
package/helpers/events.d.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export
|
|
2
|
+
export type EventWithPosition<T extends HTMLElement = HTMLElement> = MouseEvent | TouchEvent | React.MouseEvent<T> | React.TouchEvent<T>;
|
|
3
3
|
/**
|
|
4
4
|
* Проверяет, является ли событие событием нажатия основной кнопки мыши.
|
|
5
|
-
* @param
|
|
5
|
+
* @param event Событие.
|
|
6
6
|
* @return Является ли.
|
|
7
7
|
*/
|
|
8
|
-
export declare
|
|
8
|
+
export declare function isMainMouseButton(event: any): boolean;
|
|
9
9
|
/**
|
|
10
10
|
* Проверяет, является ли переданное событие touch-событием.
|
|
11
|
-
* @param
|
|
12
|
-
* @return Является
|
|
11
|
+
* @param event Событие.
|
|
12
|
+
* @return Является ли переданное событие touch-событием.
|
|
13
13
|
*/
|
|
14
|
-
export declare
|
|
14
|
+
export declare function isTouchEvent(event: any): event is TouchEvent | React.TouchEvent;
|
|
15
15
|
/**
|
|
16
16
|
* Берет данные позиции из события.
|
|
17
|
-
* @param
|
|
17
|
+
* @param event Touch- или Mouse-событие.
|
|
18
18
|
* @return Данные позиции.
|
|
19
19
|
*/
|
|
20
|
-
export declare
|
|
20
|
+
export declare function getEventClientPos<T extends HTMLElement = HTMLElement>(event: EventWithPosition<T>): import("./point").IPoint;
|
|
21
|
+
/**
|
|
22
|
+
* Вызывает событие input на элементе input/textarea/select.
|
|
23
|
+
* Полезен когда необходимо сообщить React'у что был произведен ввод значения пользователем.
|
|
24
|
+
* За основу взята реализация отсюда: https://stackoverflow.com/a/47409362/13166471.
|
|
25
|
+
* @param element Элемент.
|
|
26
|
+
* @param value Значение.
|
|
27
|
+
*/
|
|
28
|
+
export declare function triggerInput(element: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement, value: string): void;
|
package/helpers/events.js
CHANGED
|
@@ -1,31 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEventClientPos = exports.isTouchEvent = exports.isMainMouseButton = void 0;
|
|
7
|
-
const point_1 =
|
|
3
|
+
exports.triggerInput = exports.getEventClientPos = exports.isTouchEvent = exports.isMainMouseButton = void 0;
|
|
4
|
+
const point_1 = require("./point");
|
|
8
5
|
/**
|
|
9
6
|
* Проверяет, является ли событие событием нажатия основной кнопки мыши.
|
|
10
|
-
* @param
|
|
7
|
+
* @param event Событие.
|
|
11
8
|
* @return Является ли.
|
|
12
9
|
*/
|
|
13
|
-
|
|
10
|
+
function isMainMouseButton(event) {
|
|
11
|
+
return (event === null || event === void 0 ? void 0 : event.button) === 0;
|
|
12
|
+
}
|
|
14
13
|
exports.isMainMouseButton = isMainMouseButton;
|
|
15
14
|
/**
|
|
16
15
|
* Проверяет, является ли переданное событие touch-событием.
|
|
17
|
-
* @param
|
|
18
|
-
* @return Является
|
|
16
|
+
* @param event Событие.
|
|
17
|
+
* @return Является ли переданное событие touch-событием.
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
function isTouchEvent(event) {
|
|
20
|
+
return Boolean(event === null || event === void 0 ? void 0 : event.touches);
|
|
21
|
+
}
|
|
21
22
|
exports.isTouchEvent = isTouchEvent;
|
|
22
23
|
/**
|
|
23
24
|
* Берет данные позиции из события.
|
|
24
|
-
* @param
|
|
25
|
+
* @param event Touch- или Mouse-событие.
|
|
25
26
|
* @return Данные позиции.
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
-
const source =
|
|
29
|
-
return (0, point_1.
|
|
30
|
-
}
|
|
28
|
+
function getEventClientPos(event) {
|
|
29
|
+
const source = isTouchEvent(event) ? event.touches[0] : event;
|
|
30
|
+
return (0, point_1.Point)(source === null || source === void 0 ? void 0 : source.clientX, source === null || source === void 0 ? void 0 : source.clientY);
|
|
31
|
+
}
|
|
31
32
|
exports.getEventClientPos = getEventClientPos;
|
|
33
|
+
/**
|
|
34
|
+
* Вызывает событие input на элементе input/textarea/select.
|
|
35
|
+
* Полезен когда необходимо сообщить React'у что был произведен ввод значения пользователем.
|
|
36
|
+
* За основу взята реализация отсюда: https://stackoverflow.com/a/47409362/13166471.
|
|
37
|
+
* @param element Элемент.
|
|
38
|
+
* @param value Значение.
|
|
39
|
+
*/
|
|
40
|
+
function triggerInput(element, value) {
|
|
41
|
+
var _a;
|
|
42
|
+
const constructors = [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement];
|
|
43
|
+
let constructor = null;
|
|
44
|
+
for (const item of constructors) {
|
|
45
|
+
if (element instanceof item) {
|
|
46
|
+
constructor = item;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (constructor) {
|
|
50
|
+
const setValue = (_a = Object.getOwnPropertyDescriptor(constructor.prototype, 'value')) === null || _a === void 0 ? void 0 : _a.set;
|
|
51
|
+
if (setValue) {
|
|
52
|
+
setValue.call(element, value);
|
|
53
|
+
element.dispatchEvent(new Event('input', { bubbles: true }));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.triggerInput = triggerInput;
|
|
@@ -7,14 +7,17 @@
|
|
|
7
7
|
* @param props.defaultResult Результат в случае если ни один элемент не прошел проверку.
|
|
8
8
|
* @param props.isSuitable Должна определить удовлетворяет ли элемент условию.
|
|
9
9
|
* @param props.needBreakLoop Должна определить нужно ли останавливать цикл.
|
|
10
|
-
* @return
|
|
10
|
+
* @return Индекс дочернего элемента.
|
|
11
11
|
*/
|
|
12
|
-
declare
|
|
12
|
+
export declare function findChildIndex({ target, startIndex, increment, defaultResult, isSuitable, needBreakLoop, }: {
|
|
13
13
|
target?: HTMLElement | null | undefined;
|
|
14
|
-
startIndex?: number
|
|
15
|
-
increment?: number
|
|
16
|
-
defaultResult?: number
|
|
17
|
-
isSuitable?: (
|
|
18
|
-
needBreakLoop?: (
|
|
19
|
-
})
|
|
20
|
-
|
|
14
|
+
startIndex?: number;
|
|
15
|
+
increment?: number;
|
|
16
|
+
defaultResult?: number;
|
|
17
|
+
isSuitable?: (el: Element) => boolean;
|
|
18
|
+
needBreakLoop?: (passed: boolean) => boolean;
|
|
19
|
+
}): number;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
22
|
+
*/
|
|
23
|
+
export default findChildIndex;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.findChildIndex = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Выполняет цикл для поиска родственного элемента по заданным условиям.
|
|
6
6
|
* @param props Свойства.
|
|
@@ -10,9 +10,9 @@ const lodash_1 = require("lodash");
|
|
|
10
10
|
* @param props.defaultResult Результат в случае если ни один элемент не прошел проверку.
|
|
11
11
|
* @param props.isSuitable Должна определить удовлетворяет ли элемент условию.
|
|
12
12
|
* @param props.needBreakLoop Должна определить нужно ли останавливать цикл.
|
|
13
|
-
* @return
|
|
13
|
+
* @return Индекс дочернего элемента.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
function findChildIndex({ target, startIndex = 0, increment = 1, defaultResult = -1, isSuitable, needBreakLoop = a => a, }) {
|
|
16
16
|
let result = defaultResult;
|
|
17
17
|
if (target && target.children && isSuitable !== undefined) {
|
|
18
18
|
const { children } = target;
|
|
@@ -28,5 +28,9 @@ const findChildElement = ({ target, startIndex = 0, increment = 1, defaultResult
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
return result;
|
|
31
|
-
}
|
|
32
|
-
exports.
|
|
31
|
+
}
|
|
32
|
+
exports.findChildIndex = findChildIndex;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
35
|
+
*/
|
|
36
|
+
exports.default = findChildIndex;
|
|
@@ -6,7 +6,7 @@ exports.findOffsetParent = void 0;
|
|
|
6
6
|
* @param element Элемент.
|
|
7
7
|
* @return Правильный offsetParent.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
function findOffsetParent(element) {
|
|
10
10
|
let parent = element.offsetParent || document.body;
|
|
11
11
|
if (getComputedStyle(parent).position === 'static') {
|
|
12
12
|
parent =
|
|
@@ -15,5 +15,5 @@ const findOffsetParent = (element) => {
|
|
|
15
15
|
: document.documentElement;
|
|
16
16
|
}
|
|
17
17
|
return parent;
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
exports.findOffsetParent = findOffsetParent;
|
|
@@ -4,17 +4,20 @@
|
|
|
4
4
|
* @param props.target Элемент для которого нужно найти родственный элемент.
|
|
5
5
|
* @param [props.startIndex=0] Индекс элемента с которого нужно начать поиск.
|
|
6
6
|
* @param [props.increment=1] Значение инкремента.
|
|
7
|
-
* @param [props.defaultResult=-1]
|
|
7
|
+
* @param [props.defaultResult=-1] Результат в случае если ни один элемент не прошел проверку.
|
|
8
8
|
* @param [props.isSuitable] Должна определить удовлетворяет ли элемент условию.
|
|
9
9
|
* @param [props.needBreakLoop] Должна определить нужно ли останавливать цикл.
|
|
10
10
|
* @return Родственный элемент.
|
|
11
11
|
*/
|
|
12
|
-
declare
|
|
12
|
+
export declare function findSiblingIndex({ target, startIndex, increment, defaultResult, isSuitable, needBreakLoop, }: {
|
|
13
13
|
target: HTMLElement;
|
|
14
|
-
startIndex?: number
|
|
15
|
-
increment?: number
|
|
16
|
-
defaultResult?: number
|
|
17
|
-
isSuitable?: (
|
|
18
|
-
needBreakLoop?: (
|
|
19
|
-
})
|
|
14
|
+
startIndex?: number;
|
|
15
|
+
increment?: number;
|
|
16
|
+
defaultResult?: number;
|
|
17
|
+
isSuitable?: (el: Element) => boolean;
|
|
18
|
+
needBreakLoop?: (passed: boolean) => boolean;
|
|
19
|
+
}): number;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
22
|
+
*/
|
|
20
23
|
export default findSiblingIndex;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findSiblingIndex = void 0;
|
|
3
4
|
const lodash_1 = require("lodash");
|
|
4
5
|
/**
|
|
5
6
|
* Выполняет цикл для поиска родственного элемента по заданным условиям.
|
|
@@ -7,12 +8,12 @@ const lodash_1 = require("lodash");
|
|
|
7
8
|
* @param props.target Элемент для которого нужно найти родственный элемент.
|
|
8
9
|
* @param [props.startIndex=0] Индекс элемента с которого нужно начать поиск.
|
|
9
10
|
* @param [props.increment=1] Значение инкремента.
|
|
10
|
-
* @param [props.defaultResult=-1]
|
|
11
|
+
* @param [props.defaultResult=-1] Результат в случае если ни один элемент не прошел проверку.
|
|
11
12
|
* @param [props.isSuitable] Должна определить удовлетворяет ли элемент условию.
|
|
12
13
|
* @param [props.needBreakLoop] Должна определить нужно ли останавливать цикл.
|
|
13
14
|
* @return Родственный элемент.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
function findSiblingIndex({ target, startIndex = 0, increment = 1, defaultResult = -1, isSuitable, needBreakLoop = lodash_1.identity, }) {
|
|
16
17
|
let result = defaultResult;
|
|
17
18
|
if (target && target.parentElement && (0, lodash_1.isFunction)(isSuitable)) {
|
|
18
19
|
const { children } = target.parentElement;
|
|
@@ -28,5 +29,9 @@ const findSiblingIndex = ({ target, startIndex = 0, increment = 1, defaultResult
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
return result;
|
|
31
|
-
}
|
|
32
|
+
}
|
|
33
|
+
exports.findSiblingIndex = findSiblingIndex;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
36
|
+
*/
|
|
32
37
|
exports.default = findSiblingIndex;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param
|
|
4
|
-
* @param
|
|
2
|
+
* Подгонит высоту поля под содержимое.
|
|
3
|
+
* @param eventLike Событие.
|
|
4
|
+
* @param eventLike.target Поле.
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare function fitElementHeight({ target }: {
|
|
7
7
|
target: HTMLElement;
|
|
8
|
-
})
|
|
8
|
+
}): void;
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fitElementHeight = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
5
|
+
* Подгонит высоту поля под содержимое.
|
|
6
|
+
* @param eventLike Событие.
|
|
7
|
+
* @param eventLike.target Поле.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
function fitElementHeight({ target }) {
|
|
10
10
|
target.style.height = 'auto';
|
|
11
|
-
// актуальные значения
|
|
11
|
+
// ВАЖНО (1): актуальные значения берем ПОСЛЕ установки "auto" (в начало функции не переносить)
|
|
12
|
+
// ВАЖНО (2): дважды обращаемся к scrollHeight из-за бага в Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1799404
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
14
|
const { scrollHeight, offsetHeight, clientHeight } = target;
|
|
13
|
-
target.style.height = `${scrollHeight + offsetHeight - clientHeight}px`;
|
|
14
|
-
}
|
|
15
|
+
target.style.height = `${target.scrollHeight + offsetHeight - clientHeight}px`;
|
|
16
|
+
}
|
|
15
17
|
exports.fitElementHeight = fitElementHeight;
|
package/helpers/format-date.d.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @param options.invalidPlaceholder Вернется в случае невалидности даты.
|
|
7
7
|
* @return Функция для форматирования даты.
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
10
|
-
formatFrom?: string | string[]
|
|
11
|
-
formatTo?: string | ((d: Date) => string)
|
|
9
|
+
export declare function createDateFormatter({ formatFrom, formatTo, invalidPlaceholder, }?: {
|
|
10
|
+
formatFrom?: string | string[];
|
|
11
|
+
formatTo?: string | ((d: Date) => string);
|
|
12
12
|
invalidPlaceholder?: any;
|
|
13
|
-
})
|
|
13
|
+
}): (dateString: string) => any;
|
|
14
14
|
/**
|
|
15
15
|
* Работает аналогично "date-fns/parse", но позволяет передать множество форматов в виде массива.
|
|
16
16
|
* @param dateString Строка с датой.
|
|
@@ -19,11 +19,11 @@ export declare const createDateFormatter: ({ formatFrom, formatTo, invalidPlaceh
|
|
|
19
19
|
* @param options Опции "date-fns/parse".
|
|
20
20
|
* @return Дата.
|
|
21
21
|
*/
|
|
22
|
-
export declare
|
|
23
|
-
locale?: Locale
|
|
24
|
-
weekStartsOn?: 0 |
|
|
25
|
-
firstWeekContainsDate?:
|
|
26
|
-
useAdditionalWeekYearTokens?: boolean
|
|
27
|
-
useAdditionalDayOfYearTokens?: boolean
|
|
28
|
-
}
|
|
22
|
+
export declare function parseMultiple(dateString: string, formatString: string | string[], referenceDate: Date, options?: {
|
|
23
|
+
locale?: Locale;
|
|
24
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
25
|
+
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
26
|
+
useAdditionalWeekYearTokens?: boolean;
|
|
27
|
+
useAdditionalDayOfYearTokens?: boolean;
|
|
28
|
+
}): Date;
|
|
29
29
|
export declare const formatDate: (dateString: string) => any;
|
package/helpers/format-date.js
CHANGED
|
@@ -17,16 +17,18 @@ const ru_1 = __importDefault(require("date-fns/locale/ru"));
|
|
|
17
17
|
* @param options.invalidPlaceholder Вернется в случае невалидности даты.
|
|
18
18
|
* @return Функция для форматирования даты.
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
function createDateFormatter({ formatFrom = ['yyyy-MM-dd', 'dd.MM.yyyy'], formatTo = 'dd MMMM yyyy', invalidPlaceholder = '', } = {}) {
|
|
21
|
+
return (dateString) => {
|
|
22
|
+
const date = parseMultiple(dateString, formatFrom, new Date());
|
|
23
|
+
let result = invalidPlaceholder;
|
|
24
|
+
if ((0, isValid_1.default)(date)) {
|
|
25
|
+
result = (0, format_1.default)(date, (0, lodash_1.isFunction)(formatTo) ? formatTo(new Date(date.getTime())) : formatTo, {
|
|
26
|
+
locale: ru_1.default,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
30
32
|
exports.createDateFormatter = createDateFormatter;
|
|
31
33
|
/**
|
|
32
34
|
* Работает аналогично "date-fns/parse", но позволяет передать множество форматов в виде массива.
|
|
@@ -36,7 +38,7 @@ exports.createDateFormatter = createDateFormatter;
|
|
|
36
38
|
* @param options Опции "date-fns/parse".
|
|
37
39
|
* @return Дата.
|
|
38
40
|
*/
|
|
39
|
-
|
|
41
|
+
function parseMultiple(dateString, formatString, referenceDate, options) {
|
|
40
42
|
let result;
|
|
41
43
|
if (Array.isArray(formatString)) {
|
|
42
44
|
for (let i = 0; i < formatString.length; i++) {
|
|
@@ -50,6 +52,6 @@ const parseMultiple = (dateString, formatString, referenceDate, options) => {
|
|
|
50
52
|
result = (0, parse_1.default)(dateString, formatString, referenceDate, options);
|
|
51
53
|
}
|
|
52
54
|
return result;
|
|
53
|
-
}
|
|
55
|
+
}
|
|
54
56
|
exports.parseMultiple = parseMultiple;
|
|
55
|
-
exports.formatDate =
|
|
57
|
+
exports.formatDate = createDateFormatter();
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @param separator Разделяющий символ для чисел больше 999.
|
|
5
5
|
* @return Массив строк с целой и дробной отоформатированными частями числа.
|
|
6
6
|
*/
|
|
7
|
-
export declare
|
|
7
|
+
export declare function formatNumber(value: number | string, separator?: string): string[];
|
package/helpers/format-number.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.formatNumber = void 0;
|
|
|
7
7
|
* @param separator Разделяющий символ для чисел больше 999.
|
|
8
8
|
* @return Массив строк с целой и дробной отоформатированными частями числа.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
function formatNumber(value, separator) {
|
|
11
11
|
const pureSeparator = String(separator) === separator ? separator : ' ';
|
|
12
12
|
const number = Number(value);
|
|
13
13
|
let result = [];
|
|
@@ -25,5 +25,5 @@ const formatNumber = (value, separator) => {
|
|
|
25
25
|
result[0] = separated.join(pureSeparator); // подменяем целую часть на целую разделённую
|
|
26
26
|
}
|
|
27
27
|
return result;
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
exports.formatNumber = formatNumber;
|
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* @param endDate Конечная дата.
|
|
5
5
|
* @return Объект с данными сформированного интервала.
|
|
6
6
|
*/
|
|
7
|
-
declare
|
|
7
|
+
export declare function getDateIntervalData(startDate: string, endDate: string): {
|
|
8
8
|
date: string | undefined;
|
|
9
9
|
isInterval: boolean | undefined;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
13
|
+
*/
|
|
11
14
|
export default getDateIntervalData;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDateIntervalData = void 0;
|
|
6
7
|
const format_1 = __importDefault(require("date-fns/format"));
|
|
7
8
|
const parse_1 = __importDefault(require("date-fns/parse"));
|
|
8
9
|
const isEqual_1 = __importDefault(require("date-fns/isEqual"));
|
|
@@ -17,7 +18,7 @@ const formatOptions = { locale: ru_1.default };
|
|
|
17
18
|
* @param endDate Конечная дата.
|
|
18
19
|
* @return Объект с данными сформированного интервала.
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
function getDateIntervalData(startDate, endDate) {
|
|
21
22
|
const start = (0, parse_1.default)(startDate, inputFormat, new Date());
|
|
22
23
|
const end = (0, parse_1.default)(endDate, inputFormat, new Date());
|
|
23
24
|
let date;
|
|
@@ -34,5 +35,9 @@ const getDateIntervalData = (startDate, endDate) => {
|
|
|
34
35
|
isInterval = false;
|
|
35
36
|
}
|
|
36
37
|
return { date, isInterval };
|
|
37
|
-
}
|
|
38
|
+
}
|
|
39
|
+
exports.getDateIntervalData = getDateIntervalData;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Следует использовать именованный экспорт. Экспорт по умолчанию будет удалён в будущем.
|
|
42
|
+
*/
|
|
38
43
|
exports.default = getDateIntervalData;
|