@sima-land/ui-nucleons 44.2.9 → 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 +2 -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
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDropdownFloatingStyle = exports.dropdownFloatingConfig = void 0;
|
|
4
|
+
const react_1 = require("@floating-ui/react");
|
|
5
|
+
const layer_1 = require("../helpers/layer");
|
|
6
|
+
/**
|
|
7
|
+
* Возвращает конфигурацию для `useFloating` по дизайн-гайдам.
|
|
8
|
+
* @return Конфигурация для `useFloating` по дизайн-гайдам.
|
|
9
|
+
*/
|
|
10
|
+
function dropdownFloatingConfig() {
|
|
11
|
+
return {
|
|
12
|
+
whileElementsMounted: react_1.autoUpdate,
|
|
13
|
+
placement: 'bottom-start',
|
|
14
|
+
middleware: [
|
|
15
|
+
(0, react_1.flip)({
|
|
16
|
+
padding: 16,
|
|
17
|
+
}),
|
|
18
|
+
(0, react_1.shift)({
|
|
19
|
+
padding: 16,
|
|
20
|
+
}),
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.dropdownFloatingConfig = dropdownFloatingConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Возвращает стили для элемента с учетом "слоя".
|
|
27
|
+
* @param floating Результат вызова useFloating.
|
|
28
|
+
* @return Стили для элемента с учетом "слоя".
|
|
29
|
+
*/
|
|
30
|
+
function useDropdownFloatingStyle({ strategy, x, y, refs, }) {
|
|
31
|
+
const layer = (0, layer_1.useLayer)();
|
|
32
|
+
const openerWidth = refs.reference.current
|
|
33
|
+
? `${refs.reference.current.getBoundingClientRect().width}px`
|
|
34
|
+
: undefined;
|
|
35
|
+
return {
|
|
36
|
+
position: strategy,
|
|
37
|
+
top: y !== null && y !== void 0 ? y : 0,
|
|
38
|
+
left: x !== null && x !== void 0 ? x : 0,
|
|
39
|
+
minWidth: openerWidth,
|
|
40
|
+
zIndex: layer + 2,
|
|
41
|
+
// для возможности стилизации
|
|
42
|
+
'--opener-width': openerWidth,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.useDropdownFloatingStyle = useDropdownFloatingStyle;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
@use '../colors';
|
|
2
2
|
|
|
3
|
-
$sizes: (
|
|
4
|
-
s: 40px,
|
|
5
|
-
m: 48px,
|
|
6
|
-
l: 56px,
|
|
7
|
-
xl: 72px,
|
|
8
|
-
);
|
|
9
|
-
|
|
10
3
|
.root {
|
|
11
4
|
display: flex;
|
|
12
|
-
|
|
13
|
-
padding: 0 24px;
|
|
5
|
+
padding: var(--menu-item-gutter-y) 16px;
|
|
14
6
|
font-size: 16px;
|
|
15
7
|
line-height: 24px;
|
|
8
|
+
min-height: var(--menu-item-min-height);
|
|
9
|
+
max-height: var(--menu-item-max-height);
|
|
10
|
+
background: #fff;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
--menu-item-primary-color: #{colors.$basic-gray87};
|
|
13
|
+
--menu-item-secondary-color: #{colors.$basic-gray38};
|
|
14
|
+
--menu-item-main-weight: 400;
|
|
15
|
+
&.selected {
|
|
16
|
+
--menu-item-primary-weight: 600;
|
|
17
|
+
}
|
|
18
|
+
&.disabled {
|
|
19
|
+
--menu-item-primary-color: #{colors.$basic-gray24};
|
|
20
|
+
--menu-item-secondary-color: #{colors.$basic-gray24};
|
|
21
|
+
}
|
|
16
22
|
&:not(.disabled):not(.no-hover).checked,
|
|
17
23
|
&:not(.disabled):not(.no-hover):hover {
|
|
18
24
|
cursor: pointer;
|
|
@@ -20,12 +26,71 @@ $sizes: (
|
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
// sizes
|
|
30
|
+
.size-s {
|
|
31
|
+
--menu-item-min-height: 40px;
|
|
32
|
+
--menu-item-max-height: 64px;
|
|
33
|
+
--menu-item-gutter-y: 8px;
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
.size-m {
|
|
37
|
+
--menu-item-min-height: 48px;
|
|
38
|
+
--menu-item-max-height: 72px;
|
|
39
|
+
--menu-item-gutter-y: 12px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.size-l {
|
|
43
|
+
--menu-item-min-height: 56px;
|
|
44
|
+
--menu-item-max-height: 80px;
|
|
45
|
+
--menu-item-gutter-y: 16px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.size-xl {
|
|
49
|
+
--menu-item-min-height: 72px;
|
|
50
|
+
--menu-item-max-height: 116px;
|
|
51
|
+
--menu-item-gutter-y: 12px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// items
|
|
55
|
+
.col + .col {
|
|
56
|
+
margin-left: 12px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.col-start {
|
|
60
|
+
color: var(--menu-item-primary-color);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.col-center {
|
|
64
|
+
flex-grow: 1;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.row-main {
|
|
68
|
+
color: var(--menu-item-primary-color);
|
|
69
|
+
font-weight: var(--menu-item-primary-weight);
|
|
70
|
+
max-height: 48px;
|
|
71
|
+
display: -webkit-box;
|
|
72
|
+
-webkit-box-orient: vertical;
|
|
73
|
+
-webkit-line-clamp: 2;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.row-comment {
|
|
78
|
+
margin-top: 4px;
|
|
79
|
+
font-size: 14px;
|
|
80
|
+
line-height: 20px;
|
|
81
|
+
max-height: 40px;
|
|
82
|
+
display: -webkit-box;
|
|
83
|
+
-webkit-box-orient: vertical;
|
|
84
|
+
-webkit-line-clamp: 2;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.col-end,
|
|
89
|
+
.row-comment {
|
|
90
|
+
color: var(--menu-item-secondary-color);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.icon {
|
|
94
|
+
display: block;
|
|
95
|
+
fill: currentColor;
|
|
31
96
|
}
|
package/dropdown-item/index.d.ts
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ComponentType, ReactNode, SVGAttributes } from 'react';
|
|
2
|
+
export type DropdownItemSize = 's' | 'm' | 'l' | 'xl';
|
|
2
3
|
export interface DropdownItemProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'size'> {
|
|
3
|
-
/** Отображать элемент как отмеченный или нет. */
|
|
4
|
+
/** Отображать элемент как отмеченный (активный) или нет. */
|
|
4
5
|
checked?: boolean;
|
|
6
|
+
/** Отображать элемент как выбранный или нет. */
|
|
7
|
+
selected?: boolean;
|
|
5
8
|
/** Отключен ли элемент. */
|
|
6
9
|
disabled?: boolean;
|
|
7
10
|
/** Нужно ли отключить эффект при наведении. */
|
|
8
11
|
noHover?: boolean;
|
|
9
12
|
/** Размер. */
|
|
10
|
-
size?:
|
|
13
|
+
size?: DropdownItemSize;
|
|
14
|
+
/** Строковое значение, ассоциированное с элементом списка. */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** Контент перед основным содержимым. */
|
|
17
|
+
startContent?: ReactNode;
|
|
18
|
+
/** Контент после основного содержимого. */
|
|
19
|
+
endContent?: ReactNode;
|
|
20
|
+
/** Иконка перед основным содержимым. При указании будет проигнорирован "startContent". */
|
|
21
|
+
startIcon?: ComponentType<SVGAttributes<SVGSVGElement>>;
|
|
22
|
+
/** Иконка после основного содержимого. При указании будет проигнорирован "endContent". */
|
|
23
|
+
endIcon?: ComponentType<SVGAttributes<SVGSVGElement>>;
|
|
24
|
+
/** Контент под основным содержимым. Выводится только при size='xl'. */
|
|
25
|
+
comment?: ReactNode;
|
|
11
26
|
/** Идентификатор для систем автоматизированного тестирования. */
|
|
12
27
|
'data-testid'?: string;
|
|
13
28
|
}
|
|
14
29
|
/**
|
|
15
|
-
*
|
|
30
|
+
* Элемент выпадающего списка.
|
|
16
31
|
* @param props Свойства.
|
|
17
|
-
* @param props.checked Отображать элемент как отмеченный или нет.
|
|
18
|
-
* @param props.disabled Отключен ли элемент.
|
|
19
|
-
* @param props.noHover Нужно ли отключить эффект при наведении.
|
|
20
|
-
* @param props.size Размер.
|
|
21
32
|
* @return Элемент.
|
|
22
33
|
*/
|
|
23
|
-
export declare
|
|
34
|
+
export declare function DropdownItem({ size, children, className, selected, disabled, noHover, checked, startContent, startIcon: StartIcon, endContent, endIcon: EndIcon, comment, 'data-testid': testId, ...restProps }: DropdownItemProps): JSX.Element;
|
package/dropdown-item/index.js
CHANGED
|
@@ -20,16 +20,19 @@ const bind_1 = __importDefault(require("classnames/bind"));
|
|
|
20
20
|
const dropdown_item_module_scss_1 = __importDefault(require("./dropdown-item.module.scss"));
|
|
21
21
|
const cx = bind_1.default.bind(dropdown_item_module_scss_1.default);
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Элемент выпадающего списка.
|
|
24
24
|
* @param props Свойства.
|
|
25
|
-
* @param props.checked Отображать элемент как отмеченный или нет.
|
|
26
|
-
* @param props.disabled Отключен ли элемент.
|
|
27
|
-
* @param props.noHover Нужно ли отключить эффект при наведении.
|
|
28
|
-
* @param props.size Размер.
|
|
29
25
|
* @return Элемент.
|
|
30
26
|
*/
|
|
31
|
-
|
|
32
|
-
var { size = 'm', children, className, disabled, noHover, checked, 'data-testid': testId = 'dropdown-item' } = _a, restProps = __rest(_a, ["size", "children", "className", "disabled", "noHover", "checked", 'data-testid']);
|
|
33
|
-
|
|
34
|
-
};
|
|
27
|
+
function DropdownItem(_a) {
|
|
28
|
+
var { size = 'm', children, className, selected, disabled, noHover, checked, startContent, startIcon: StartIcon, endContent, endIcon: EndIcon, comment, 'data-testid': testId = 'dropdown-item' } = _a, restProps = __rest(_a, ["size", "children", "className", "selected", "disabled", "noHover", "checked", "startContent", "startIcon", "endContent", "endIcon", "comment", 'data-testid']);
|
|
29
|
+
const start = StartIcon ? react_1.default.createElement(StartIcon, { className: cx('icon') }) : startContent;
|
|
30
|
+
const end = EndIcon ? react_1.default.createElement(EndIcon, { className: cx('icon') }) : endContent;
|
|
31
|
+
return (react_1.default.createElement("div", Object.assign({}, restProps, { className: cx('root', `size-${size}`, selected && 'selected', checked && 'checked', disabled && 'disabled', noHover && 'no-hover', className), "data-testid": testId }),
|
|
32
|
+
start && react_1.default.createElement("div", { className: cx('col', 'col-start') }, start),
|
|
33
|
+
react_1.default.createElement("div", { className: cx('col', 'col-center') },
|
|
34
|
+
react_1.default.createElement("div", { className: cx('row-main') }, children),
|
|
35
|
+
size === 'xl' && comment && react_1.default.createElement("div", { className: cx('row-comment') }, comment)),
|
|
36
|
+
end && react_1.default.createElement("div", { className: cx('col', 'col-end') }, end)));
|
|
37
|
+
}
|
|
35
38
|
exports.DropdownItem = DropdownItem;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isValidElement } from 'react';
|
|
2
|
+
import { DropdownItemElement } from './types';
|
|
3
|
+
/** Утилиты для работы с DropdownItem. */
|
|
4
|
+
export declare class DropdownItemUtils {
|
|
5
|
+
/**
|
|
6
|
+
* Определяет, является ли переданное значение элементом DropdownItem.
|
|
7
|
+
* @param value Значение.
|
|
8
|
+
* @return Является ли переданное значение элементом DropdownItem.
|
|
9
|
+
*/
|
|
10
|
+
static is(value: Parameters<typeof isValidElement>[0]): value is DropdownItemElement;
|
|
11
|
+
/**
|
|
12
|
+
* Возвращает значение элемента меню.
|
|
13
|
+
* @param menuItem Значение.
|
|
14
|
+
* @return Значение элемента меню.
|
|
15
|
+
*/
|
|
16
|
+
static getValue(menuItem: DropdownItemElement): string;
|
|
17
|
+
/**
|
|
18
|
+
* Получив опции меню вернет LinkedList и текущую позицию в нем.
|
|
19
|
+
* @param menuItems Опции.
|
|
20
|
+
* @param currentIndex Индекс текущей выбранной опции.
|
|
21
|
+
* @return Текущая позиция в списке и список.
|
|
22
|
+
*/
|
|
23
|
+
static asLoopedIterator(menuItems: DropdownItemElement[], currentIndex: number): LoopedIterator<number>;
|
|
24
|
+
}
|
|
25
|
+
/** Список с возможностью перемещаться вперед назад с закольцовыванием. */
|
|
26
|
+
export declare class LoopedIterator<T = unknown> {
|
|
27
|
+
private source;
|
|
28
|
+
private position;
|
|
29
|
+
/**
|
|
30
|
+
* Конструктор.
|
|
31
|
+
* @param source Источник данных.
|
|
32
|
+
* @param startPosition Начальная позиция.
|
|
33
|
+
*/
|
|
34
|
+
constructor(source: T[], startPosition?: number);
|
|
35
|
+
/**
|
|
36
|
+
* Возвращает следующий элемент списка.
|
|
37
|
+
* @return Элемент списка или undefined.
|
|
38
|
+
*/
|
|
39
|
+
next(): T | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Возвращает предыдущий элемент списка.
|
|
42
|
+
* @return Элемент списка или undefined.
|
|
43
|
+
*/
|
|
44
|
+
prev(): T | undefined;
|
|
45
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoopedIterator = exports.DropdownItemUtils = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
/** Утилиты для работы с DropdownItem. */
|
|
7
|
+
class DropdownItemUtils {
|
|
8
|
+
/**
|
|
9
|
+
* Определяет, является ли переданное значение элементом DropdownItem.
|
|
10
|
+
* @param value Значение.
|
|
11
|
+
* @return Является ли переданное значение элементом DropdownItem.
|
|
12
|
+
*/
|
|
13
|
+
static is(value) {
|
|
14
|
+
return (0, react_1.isValidElement)(value) && value.type === _1.DropdownItem;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Возвращает значение элемента меню.
|
|
18
|
+
* @param menuItem Значение.
|
|
19
|
+
* @return Значение элемента меню.
|
|
20
|
+
*/
|
|
21
|
+
static getValue(menuItem) {
|
|
22
|
+
const { value, children } = menuItem.props;
|
|
23
|
+
// нативный select преобразует содержимое option к строке если не указан value, делаем также
|
|
24
|
+
return typeof value === 'string' ? value : String(children);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Получив опции меню вернет LinkedList и текущую позицию в нем.
|
|
28
|
+
* @param menuItems Опции.
|
|
29
|
+
* @param currentIndex Индекс текущей выбранной опции.
|
|
30
|
+
* @return Текущая позиция в списке и список.
|
|
31
|
+
*/
|
|
32
|
+
static asLoopedIterator(menuItems, currentIndex) {
|
|
33
|
+
let currentPosition = -1;
|
|
34
|
+
const availableIndices = menuItems.reduce((acc, item, index) => {
|
|
35
|
+
if (index === currentIndex) {
|
|
36
|
+
currentPosition = acc.length;
|
|
37
|
+
}
|
|
38
|
+
if (!item.props.disabled) {
|
|
39
|
+
acc.push(index);
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, []);
|
|
43
|
+
return new LoopedIterator(availableIndices, currentPosition);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.DropdownItemUtils = DropdownItemUtils;
|
|
47
|
+
/** Список с возможностью перемещаться вперед назад с закольцовыванием. */
|
|
48
|
+
class LoopedIterator {
|
|
49
|
+
/**
|
|
50
|
+
* Конструктор.
|
|
51
|
+
* @param source Источник данных.
|
|
52
|
+
* @param startPosition Начальная позиция.
|
|
53
|
+
*/
|
|
54
|
+
constructor(source, startPosition = 0) {
|
|
55
|
+
this.source = source;
|
|
56
|
+
this.position = startPosition;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Возвращает следующий элемент списка.
|
|
60
|
+
* @return Элемент списка или undefined.
|
|
61
|
+
*/
|
|
62
|
+
next() {
|
|
63
|
+
if (this.source.length === 0) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
let nextIndex = this.position + 1;
|
|
67
|
+
if (nextIndex >= this.source.length) {
|
|
68
|
+
nextIndex = 0;
|
|
69
|
+
}
|
|
70
|
+
this.position = nextIndex;
|
|
71
|
+
return this.source[nextIndex];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Возвращает предыдущий элемент списка.
|
|
75
|
+
* @return Элемент списка или undefined.
|
|
76
|
+
*/
|
|
77
|
+
prev() {
|
|
78
|
+
if (this.source.length === 0) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
let nextIndex = this.position - 1;
|
|
82
|
+
if (nextIndex < 0) {
|
|
83
|
+
nextIndex = this.source.length - 1;
|
|
84
|
+
}
|
|
85
|
+
this.position = nextIndex;
|
|
86
|
+
return this.source[nextIndex];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.LoopedIterator = LoopedIterator;
|
package/expandable/utils.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.defineViewState = exports.useExpandable = void 0;
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const hooks_1 = require("../hooks");
|
|
9
|
-
const on_1 =
|
|
9
|
+
const on_1 = require("../helpers/on");
|
|
10
10
|
const expandable_group_module_scss_1 = __importDefault(require("./expandable-group.module.scss"));
|
|
11
11
|
/**
|
|
12
12
|
* Хук состояния группы элементов ограниченных несколькими строками с возможностью показать все.
|
|
@@ -50,11 +50,11 @@ function useExpandable({ expanded, wrapperRef, containerRef, openerRef, gap, })
|
|
|
50
50
|
setHiddenCount(state.lastVisibleIndex !== -1 ? items.length - state.lastVisibleIndex : 0);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
}, [expanded, gap]);
|
|
53
|
+
}, [expanded, gap, wrapperRef, containerRef, openerRef]);
|
|
54
54
|
// пересчитываем после каждого rerender'а
|
|
55
55
|
(0, hooks_1.useIsomorphicLayoutEffect)(calc);
|
|
56
56
|
// пересчитываем при resize
|
|
57
|
-
(0, react_1.useEffect)(() => (0, on_1.
|
|
57
|
+
(0, react_1.useEffect)(() => (0, on_1.on)(window, 'resize', calc), [calc]);
|
|
58
58
|
return { hiddenCount };
|
|
59
59
|
}
|
|
60
60
|
exports.useExpandable = useExpandable;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
@use '../colors';
|
|
2
|
+
|
|
3
|
+
.root {
|
|
4
|
+
font-size: 16px;
|
|
5
|
+
line-height: 24px;
|
|
6
|
+
width: var(--field-width, 240px);
|
|
7
|
+
color: var(--field-primary-text-color);
|
|
8
|
+
--field-primary-text-color: #{colors.$basic-gray87};
|
|
9
|
+
--field-label-text-color: #{colors.$basic-gray38};
|
|
10
|
+
--field-background: #fff;
|
|
11
|
+
--field-border-color: #{colors.$basic-gray12};
|
|
12
|
+
--field-caption-color: #{colors.$basic-gray38};
|
|
13
|
+
&.size-s {
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
line-height: 20px;
|
|
16
|
+
--field-height: 32px;
|
|
17
|
+
--field-gutter-horizontal: 12px;
|
|
18
|
+
--field-gutter-adornment: 8px;
|
|
19
|
+
--field-gutter-vertical: 6px;
|
|
20
|
+
}
|
|
21
|
+
&.size-m {
|
|
22
|
+
--field-height: 40px;
|
|
23
|
+
--field-gutter-horizontal: 12px;
|
|
24
|
+
--field-gutter-adornment: 8px;
|
|
25
|
+
--field-gutter-vertical: 8px;
|
|
26
|
+
}
|
|
27
|
+
&.size-l {
|
|
28
|
+
--field-height: 56px;
|
|
29
|
+
--field-gutter-horizontal: 16px;
|
|
30
|
+
--field-gutter-adornment: 12px;
|
|
31
|
+
--field-gutter-vertical: 8px;
|
|
32
|
+
&.no-label {
|
|
33
|
+
.main-col {
|
|
34
|
+
padding: 8px 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
&.focused {
|
|
39
|
+
--field-border-color: #{colors.$basic-blue};
|
|
40
|
+
}
|
|
41
|
+
&.disabled {
|
|
42
|
+
--field-primary-text-color: #{colors.$basic-gray24};
|
|
43
|
+
--field-main-text-color: #{colors.$basic-gray24};
|
|
44
|
+
--field-label-text-color: #{colors.$basic-gray24};
|
|
45
|
+
--field-background: #{colors.$basic-gray2};
|
|
46
|
+
--field-border-color: #{colors.$basic-gray12};
|
|
47
|
+
}
|
|
48
|
+
&.failed {
|
|
49
|
+
--field-caption-color: #{colors.$additional-deep-red};
|
|
50
|
+
--field-main-text-color: #{colors.$additional-deep-red};
|
|
51
|
+
&.label-as-placeholder {
|
|
52
|
+
--field-label-text-color: #{colors.$additional-deep-red};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
&.label-as-placeholder {
|
|
56
|
+
&.size-s {
|
|
57
|
+
.label {
|
|
58
|
+
// @todo из-за overflow:hidden + height:0 скрывается - поменять логику
|
|
59
|
+
// height: 0;
|
|
60
|
+
|
|
61
|
+
// размер шрифта 12px увеличиваем до 14px
|
|
62
|
+
transform: scale(calc(7 / 6)) translateY(1px);
|
|
63
|
+
max-width: calc(100% * (6 / 7));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
&.size-m {
|
|
67
|
+
.label {
|
|
68
|
+
// @todo из-за overflow:hidden + height:0 скрывается - поменять логику
|
|
69
|
+
// height: 0;
|
|
70
|
+
|
|
71
|
+
// размер шрифта 12px увеличиваем до 16px
|
|
72
|
+
transform: scale(calc(4 / 3)) translateY(1px);
|
|
73
|
+
max-width: calc(100% * (3 / 4));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
&.size-l {
|
|
77
|
+
.label {
|
|
78
|
+
// размер шрифта 12px увеличиваем до 16px
|
|
79
|
+
transform: scale(calc(4 / 3)) translateY(7px);
|
|
80
|
+
max-width: calc(100% * (3 / 4));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
.main {
|
|
84
|
+
opacity: 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.block {
|
|
90
|
+
border-radius: 4px;
|
|
91
|
+
outline: 0;
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: flex-start;
|
|
94
|
+
padding: var(--field-gutter-vertical) var(--field-gutter-horizontal);
|
|
95
|
+
width: 100%;
|
|
96
|
+
background: var(--field-background);
|
|
97
|
+
box-shadow: inset 0 0 0 1px var(--field-border-color);
|
|
98
|
+
&.fixed-height {
|
|
99
|
+
height: var(--field-height);
|
|
100
|
+
}
|
|
101
|
+
&:not(.fixed-height) {
|
|
102
|
+
min-height: var(--field-height);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.label {
|
|
107
|
+
max-width: 100%;
|
|
108
|
+
transform-origin: 0 0;
|
|
109
|
+
transition: transform 0.2s ease-in-out, max-width 0.2s ease-in-out;
|
|
110
|
+
height: 16px;
|
|
111
|
+
font-size: 12px;
|
|
112
|
+
line-height: 16px;
|
|
113
|
+
color: var(--field-label-text-color, var(--field-primary-text-color));
|
|
114
|
+
user-select: none;
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
white-space: nowrap;
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.col {
|
|
121
|
+
min-height: calc(var(--field-height) - (2 * var(--field-gutter-vertical)));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.main-col {
|
|
125
|
+
display: flex;
|
|
126
|
+
flex-direction: column;
|
|
127
|
+
flex-grow: 1;
|
|
128
|
+
min-width: 0; // чтобы не выбивал "соседей" за пределы блока
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.adornment-col {
|
|
132
|
+
flex-grow: 0;
|
|
133
|
+
flex-shrink: 0;
|
|
134
|
+
display: flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
&.start {
|
|
137
|
+
margin-right: var(--field-gutter-adornment);
|
|
138
|
+
}
|
|
139
|
+
&.end {
|
|
140
|
+
margin-left: var(--field-gutter-adornment);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.main {
|
|
145
|
+
max-width: 100%;
|
|
146
|
+
white-space: nowrap;
|
|
147
|
+
color: var(--field-main-text-color, var(--field-primary-text-color));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.caption {
|
|
151
|
+
margin-top: 8px;
|
|
152
|
+
font-size: 12px;
|
|
153
|
+
line-height: 16px;
|
|
154
|
+
color: var(--field-caption-color);
|
|
155
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ReactNode, HTMLAttributes, LabelHTMLAttributes, Ref, CSSProperties } from 'react';
|
|
2
|
+
export type FieldBlockSize = 's' | 'm' | 'l';
|
|
3
|
+
type NoChildren<T extends {
|
|
4
|
+
children?: any;
|
|
5
|
+
}> = Omit<T, 'children'>;
|
|
6
|
+
export interface FieldBlockStyle extends CSSProperties {
|
|
7
|
+
'--field-width'?: string;
|
|
8
|
+
'--field-main-text-color'?: string;
|
|
9
|
+
}
|
|
10
|
+
type WithStyle<T extends {
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
}> = Omit<T, 'style'> & {
|
|
13
|
+
style?: FieldBlockStyle;
|
|
14
|
+
};
|
|
15
|
+
export interface FieldBlockProps {
|
|
16
|
+
/** Отключенное состояние. */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Состояние с ошибкой. */
|
|
19
|
+
failed?: boolean;
|
|
20
|
+
/** Состояние фокуса. */
|
|
21
|
+
focused?: boolean;
|
|
22
|
+
/** Подпись под полем. */
|
|
23
|
+
caption?: string;
|
|
24
|
+
/** Ярлык в поле. */
|
|
25
|
+
label?: string;
|
|
26
|
+
/** Выводить ярлык вместо placeholder или введенного значения. */
|
|
27
|
+
labelAsPlaceholder?: boolean;
|
|
28
|
+
/** Опции элемента ярлыка. */
|
|
29
|
+
labelProps?: NoChildren<LabelHTMLAttributes<HTMLLabelElement>>;
|
|
30
|
+
/** Размер. */
|
|
31
|
+
size?: FieldBlockSize;
|
|
32
|
+
/** Фиксировать высоту. */
|
|
33
|
+
fixedHeight?: boolean;
|
|
34
|
+
/** Опции корневого элемента. */
|
|
35
|
+
rootProps?: NoChildren<WithStyle<HTMLAttributes<HTMLDivElement>>>;
|
|
36
|
+
/** Ref корневого элемента. */
|
|
37
|
+
rootRef?: Ref<HTMLDivElement>;
|
|
38
|
+
/** Опции элемента блока поля. */
|
|
39
|
+
blockProps?: NoChildren<WithStyle<HTMLAttributes<HTMLDivElement>>>;
|
|
40
|
+
/** Ref элемента блока поля. */
|
|
41
|
+
blockRef?: Ref<HTMLDivElement>;
|
|
42
|
+
/** Украшение перед основным содержимым. */
|
|
43
|
+
adornmentStart?: ReactNode;
|
|
44
|
+
/** Украшение после основного содержимого. */
|
|
45
|
+
adornmentEnd?: ReactNode;
|
|
46
|
+
/** Основное содержимое. */
|
|
47
|
+
main?: ReactNode;
|
|
48
|
+
/** Опции основного содержимого. */
|
|
49
|
+
mainProps?: NoChildren<WithStyle<HTMLAttributes<HTMLDivElement>>>;
|
|
50
|
+
/** Идентификатор для систем автоматизированного тестирования. */
|
|
51
|
+
'data-testid'?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare const FIELD_BLOCK_HEIGHT: Record<FieldBlockSize, number>;
|
|
54
|
+
export declare const FIELD_BLOCK_DEFAULTS: {
|
|
55
|
+
readonly size: "l";
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Блок поля по дизайн-гайдам.
|
|
59
|
+
* @param props Свойства.
|
|
60
|
+
* @return Элемент.
|
|
61
|
+
*/
|
|
62
|
+
export declare function FieldBlock({ size, main, mainProps, disabled, failed, focused, label, labelProps, labelAsPlaceholder, fixedHeight, caption, rootRef, rootProps, blockRef, blockProps, adornmentStart, adornmentEnd, 'data-testid': testId, }: FieldBlockProps): JSX.Element;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FieldBlock = exports.FIELD_BLOCK_DEFAULTS = exports.FIELD_BLOCK_HEIGHT = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const bind_1 = __importDefault(require("classnames/bind"));
|
|
9
|
+
const field_block_module_scss_1 = __importDefault(require("./field-block.module.scss"));
|
|
10
|
+
const cx = bind_1.default.bind(field_block_module_scss_1.default);
|
|
11
|
+
exports.FIELD_BLOCK_HEIGHT = {
|
|
12
|
+
s: 32,
|
|
13
|
+
m: 40,
|
|
14
|
+
l: 56,
|
|
15
|
+
};
|
|
16
|
+
exports.FIELD_BLOCK_DEFAULTS = {
|
|
17
|
+
size: 'l',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Блок поля по дизайн-гайдам.
|
|
21
|
+
* @param props Свойства.
|
|
22
|
+
* @return Элемент.
|
|
23
|
+
*/
|
|
24
|
+
function FieldBlock({ size = exports.FIELD_BLOCK_DEFAULTS.size, main, mainProps, disabled, failed, focused, label, labelProps, labelAsPlaceholder, fixedHeight = true, caption, rootRef, rootProps, blockRef, blockProps, adornmentStart, adornmentEnd, 'data-testid': testId = 'field-block', }) {
|
|
25
|
+
const needLabel = Boolean(label) && (size === 'l' || labelAsPlaceholder);
|
|
26
|
+
const rootClassName = cx('root', `size-${size}`, {
|
|
27
|
+
disabled,
|
|
28
|
+
focused,
|
|
29
|
+
failed,
|
|
30
|
+
'label-as-placeholder': needLabel && labelAsPlaceholder,
|
|
31
|
+
'no-label': !needLabel,
|
|
32
|
+
}, rootProps === null || rootProps === void 0 ? void 0 : rootProps.className);
|
|
33
|
+
const blockClassName = cx('block', fixedHeight && 'fixed-height', blockProps === null || blockProps === void 0 ? void 0 : blockProps.className);
|
|
34
|
+
return (react_1.default.createElement("div", Object.assign({}, rootProps, { ref: rootRef, className: rootClassName, "data-testid": testId }),
|
|
35
|
+
react_1.default.createElement("div", Object.assign({}, blockProps, { ref: blockRef, className: blockClassName, "data-testid": 'field-block:block' }),
|
|
36
|
+
adornmentStart && (react_1.default.createElement("div", { className: cx('col', 'adornment-col', 'start'), "data-testid": 'field-block:adornment-start' }, adornmentStart)),
|
|
37
|
+
react_1.default.createElement("div", { className: cx('col', 'main-col') },
|
|
38
|
+
needLabel && (react_1.default.createElement("label", Object.assign({}, labelProps, { className: cx('label', labelProps === null || labelProps === void 0 ? void 0 : labelProps.className), "data-testid": 'field-block:label' }), label)),
|
|
39
|
+
react_1.default.createElement("div", Object.assign({}, mainProps, { className: cx('main', mainProps === null || mainProps === void 0 ? void 0 : mainProps.className), "data-testid": 'field-block:main' }), main)),
|
|
40
|
+
adornmentEnd && (react_1.default.createElement("div", { className: cx('col', 'adornment-col', 'end'), "data-testid": 'field-block:adornment-end' }, adornmentEnd))),
|
|
41
|
+
caption && (react_1.default.createElement("div", { className: cx('caption'), "data-testid": 'field-block:caption' }, caption))));
|
|
42
|
+
}
|
|
43
|
+
exports.FieldBlock = FieldBlock;
|