@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/alert/index.js
CHANGED
|
@@ -26,29 +26,46 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Alert = void 0;
|
|
29
|
+
exports.AlertBody = exports.Alert = void 0;
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
|
-
const
|
|
31
|
+
const page_scroll_lock_1 = require("../_internal/page-scroll-lock");
|
|
32
|
+
const modal_overlay_1 = require("../modal-overlay");
|
|
33
|
+
const card_1 = require("../card");
|
|
34
|
+
const top_bar_1 = require("../top-bar");
|
|
35
|
+
const bottom_bar_1 = require("../bottom-bar");
|
|
36
|
+
const define_slots_1 = require("../helpers/define-slots");
|
|
37
|
+
const utils_1 = require("../modal-overlay/utils");
|
|
32
38
|
const bind_1 = __importDefault(require("classnames/bind"));
|
|
33
39
|
const alert_module_scss_1 = __importDefault(require("./alert.module.scss"));
|
|
34
|
-
const borders_1 = require("../styling/borders");
|
|
35
|
-
const layer_1 = require("../helpers/layer");
|
|
36
|
-
const body_scroll_1 = require("../_internal/body-scroll");
|
|
37
40
|
const cx = bind_1.default.bind(alert_module_scss_1.default);
|
|
38
41
|
/**
|
|
39
42
|
* Компонент модального диалога.
|
|
40
43
|
* @param props Свойства.
|
|
41
44
|
* @return Элемент.
|
|
42
45
|
*/
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
46
|
+
function Alert({ children, withScrollDisable = false, scrollDisableOptions, onClose, }) {
|
|
47
|
+
const scrollableRef = (0, react_1.useRef)(null);
|
|
48
|
+
(0, page_scroll_lock_1.usePageScrollLock)(scrollableRef, Object.assign({ lockEnabled: withScrollDisable }, scrollDisableOptions));
|
|
49
|
+
const { topBar, body, bottomBar } = (0, define_slots_1.defineSlots)(children, {
|
|
50
|
+
topBar: top_bar_1.TopBar,
|
|
51
|
+
body: AlertBody,
|
|
52
|
+
bottomBar: bottom_bar_1.BottomBar,
|
|
53
|
+
});
|
|
54
|
+
const overlayClickBind = (0, utils_1.useExactClick)(onClose);
|
|
55
|
+
(0, react_1.useImperativeHandle)(body === null || body === void 0 ? void 0 : body.props.scrollableRef, () => scrollableRef.current);
|
|
56
|
+
return (react_1.default.createElement(modal_overlay_1.ModalOverlay, Object.assign({ className: alert_module_scss_1.default.overlay }, overlayClickBind),
|
|
57
|
+
react_1.default.createElement(card_1.Card, { shadow: 'z4', rounds: 'm', className: cx('alert'), "data-testid": 'alert' },
|
|
58
|
+
topBar && react_1.default.createElement(top_bar_1.TopBar, Object.assign({}, topBar.props, { size: 's' })),
|
|
59
|
+
body && (react_1.default.createElement(card_1.CardContent, Object.assign({}, body.props, { scrollableRef: scrollableRef }), body)),
|
|
60
|
+
bottomBar && react_1.default.createElement(bottom_bar_1.BottomBar, Object.assign({}, bottomBar.props, { size: 's' })))));
|
|
61
|
+
}
|
|
54
62
|
exports.Alert = Alert;
|
|
63
|
+
/**
|
|
64
|
+
* Основной контент Alert.
|
|
65
|
+
* @param props Свойства.
|
|
66
|
+
* @return Элемент.
|
|
67
|
+
*/
|
|
68
|
+
function AlertBody({ children }) {
|
|
69
|
+
return react_1.default.createElement(react_1.default.Fragment, null, children);
|
|
70
|
+
}
|
|
71
|
+
exports.AlertBody = AlertBody;
|
package/arrow-button/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type ArrowButtonSize = 's' | 'l';
|
|
3
|
+
export type ArrowDirection = 'up' | 'right' | 'down' | 'left';
|
|
4
4
|
export interface ArrowButtonProps extends Omit<JSX.IntrinsicElements['button'], 'size' | 'children'> {
|
|
5
5
|
/** Размер. */
|
|
6
6
|
size?: ArrowButtonSize;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AutocompleteProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Поле ввода с подсказками.
|
|
5
|
+
* @param props Свойства.
|
|
6
|
+
* @return Элемент.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Autocomplete({ children, loading, filterOption, dropdownProps, autoComplete, autoFocus, defaultValue, disabled, id, name, onBlur, onChange, onFocus, onInput, placeholder, readOnly, required, type, value, adornmentEnd, baseInputProps, ...restProps }: AutocompleteProps): JSX.Element;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.Autocomplete = void 0;
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const dropdown_1 = require("../dropdown");
|
|
43
|
+
const dropdown_item_1 = require("../dropdown-item");
|
|
44
|
+
const utils_1 = require("../dropdown-item/utils");
|
|
45
|
+
const dropdown_loading_1 = require("../_internal/dropdown-loading");
|
|
46
|
+
const react_2 = require("@floating-ui/react");
|
|
47
|
+
const input_1 = require("../input");
|
|
48
|
+
const hooks_1 = require("../hooks");
|
|
49
|
+
const utils_2 = require("../dropdown/utils");
|
|
50
|
+
const events_1 = require("../helpers/events");
|
|
51
|
+
const down_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/down"));
|
|
52
|
+
const up_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/up"));
|
|
53
|
+
const autocomplete_module_scss_1 = __importDefault(require("./autocomplete.module.scss"));
|
|
54
|
+
/**
|
|
55
|
+
* Поле ввода с подсказками.
|
|
56
|
+
* @param props Свойства.
|
|
57
|
+
* @return Элемент.
|
|
58
|
+
*/
|
|
59
|
+
function Autocomplete(_a) {
|
|
60
|
+
var {
|
|
61
|
+
// specific Autocomplete props:
|
|
62
|
+
children, loading, filterOption = defaultFilterOption, dropdownProps,
|
|
63
|
+
// rest props:
|
|
64
|
+
autoComplete, autoFocus, defaultValue, disabled, id, name, onBlur, onChange, onFocus, onInput, placeholder, readOnly, required, type, value, adornmentEnd = getDefaultAdornmentEnd, baseInputProps } = _a, restProps = __rest(_a, ["children", "loading", "filterOption", "dropdownProps", "autoComplete", "autoFocus", "defaultValue", "disabled", "id", "name", "onBlur", "onChange", "onFocus", "onInput", "placeholder", "readOnly", "required", "type", "value", "adornmentEnd", "baseInputProps"]);
|
|
65
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
66
|
+
const [needMenu, setNeedMenu] = (0, react_1.useState)(false);
|
|
67
|
+
const _b = (0, react_2.useFloating)(Object.assign({ open: needMenu }, (0, utils_2.dropdownFloatingConfig)())), { refs } = _b, floating = __rest(_b, ["refs"]);
|
|
68
|
+
const floatingStyle = (0, utils_2.useDropdownFloatingStyle)(Object.assign({ refs }, floating));
|
|
69
|
+
const [activeIndex, setActiveIndex] = (0, react_1.useState)(-1);
|
|
70
|
+
const [currentValue, setCurrentValue] = (0, react_1.useState)(() => { var _a; return `${(_a = value !== null && value !== void 0 ? value : defaultValue) !== null && _a !== void 0 ? _a : ''}`; });
|
|
71
|
+
const items = react_1.Children.toArray(children).filter((item) => utils_1.DropdownItemUtils.is(item) && filterOption(item, currentValue));
|
|
72
|
+
const canShowMenu = !disabled && (currentValue.length > 0 || items.length > 0);
|
|
73
|
+
const menuShown = needMenu && canShowMenu;
|
|
74
|
+
const selectItem = (0, react_1.useCallback)((item) => {
|
|
75
|
+
inputRef.current && (0, events_1.triggerInput)(inputRef.current, utils_1.DropdownItemUtils.getValue(item));
|
|
76
|
+
setNeedMenu(false);
|
|
77
|
+
setActiveIndex(-1);
|
|
78
|
+
}, [inputRef]);
|
|
79
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
80
|
+
inputRef.current && setCurrentValue(inputRef.current.value);
|
|
81
|
+
}, [value]);
|
|
82
|
+
const onKeyDown = baseInputProps === null || baseInputProps === void 0 ? void 0 : baseInputProps.onKeyDown;
|
|
83
|
+
const handleKeyDown = (0, react_1.useCallback)(event => {
|
|
84
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
85
|
+
switch (event.code) {
|
|
86
|
+
case 'Escape': {
|
|
87
|
+
setNeedMenu(false);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case 'Enter': {
|
|
91
|
+
if (menuShown) {
|
|
92
|
+
const item = items[activeIndex];
|
|
93
|
+
item && selectItem(item);
|
|
94
|
+
setNeedMenu(false);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
setNeedMenu(true);
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'ArrowUp': {
|
|
102
|
+
if (menuShown) {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
setActiveIndex(n => { var _a; return (_a = utils_1.DropdownItemUtils.asLoopedIterator(items, n).prev()) !== null && _a !== void 0 ? _a : -1; });
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
setNeedMenu(true);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
case 'ArrowDown': {
|
|
112
|
+
if (menuShown) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
setActiveIndex(n => { var _a; return (_a = utils_1.DropdownItemUtils.asLoopedIterator(items, n).next()) !== null && _a !== void 0 ? _a : -1; });
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
setNeedMenu(true);
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, [menuShown, activeIndex, items, selectItem, onKeyDown]);
|
|
123
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
124
|
+
react_1.default.createElement(input_1.Input, Object.assign({}, restProps, {
|
|
125
|
+
autoComplete,
|
|
126
|
+
autoFocus,
|
|
127
|
+
defaultValue,
|
|
128
|
+
disabled,
|
|
129
|
+
id,
|
|
130
|
+
name,
|
|
131
|
+
onInput,
|
|
132
|
+
placeholder,
|
|
133
|
+
readOnly,
|
|
134
|
+
required,
|
|
135
|
+
type,
|
|
136
|
+
value,
|
|
137
|
+
}, { inputRef: inputRef, blockRef: refs.setReference, onFocus: e => {
|
|
138
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
|
|
139
|
+
setNeedMenu(true);
|
|
140
|
+
}, onBlur: e => {
|
|
141
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
142
|
+
setNeedMenu(false);
|
|
143
|
+
setActiveIndex(-1);
|
|
144
|
+
}, onChange: e => {
|
|
145
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
146
|
+
setNeedMenu(true);
|
|
147
|
+
setActiveIndex(-1);
|
|
148
|
+
setCurrentValue(e.target.value);
|
|
149
|
+
},
|
|
150
|
+
// @todo выяснить надо ли переключать меню при клике и раскомментировать/убрать
|
|
151
|
+
// blockProps={{
|
|
152
|
+
// onMouseDown: () => {
|
|
153
|
+
// !disabled && setNeedMenu(a => !a);
|
|
154
|
+
// },
|
|
155
|
+
// }}
|
|
156
|
+
baseInputProps: Object.assign(Object.assign({}, baseInputProps), { onKeyDown: handleKeyDown }), adornmentEnd: typeof adornmentEnd === 'function' ? adornmentEnd({ menuShown }) : adornmentEnd })),
|
|
157
|
+
react_1.default.createElement(react_2.FloatingPortal, { id: '' }, menuShown && (react_1.default.createElement(dropdown_1.Dropdown, Object.assign({ ref: refs.setFloating }, dropdownProps, { style: Object.assign(Object.assign({}, dropdownProps === null || dropdownProps === void 0 ? void 0 : dropdownProps.style), floatingStyle) }),
|
|
158
|
+
!loading &&
|
|
159
|
+
items.length > 0 &&
|
|
160
|
+
items.map((item, index) => (react_1.default.createElement(dropdown_item_1.DropdownItem, Object.assign({ key: index, checked: index === activeIndex }, item.props, { onMouseDown: e => {
|
|
161
|
+
var _a, _b;
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
(_b = (_a = item.props).onMouseDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
164
|
+
}, onClick: e => {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
(_b = (_a = item.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
167
|
+
!e.defaultPrevented && selectItem(item);
|
|
168
|
+
} })))),
|
|
169
|
+
!loading && items.length === 0 && (react_1.default.createElement(dropdown_item_1.DropdownItem, { size: 's', noHover: true }, "\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E")),
|
|
170
|
+
loading && react_1.default.createElement(dropdown_loading_1.DropdownLoading, null))))));
|
|
171
|
+
}
|
|
172
|
+
exports.Autocomplete = Autocomplete;
|
|
173
|
+
/**
|
|
174
|
+
* Фильтр вариантов выбора по умолчанию.
|
|
175
|
+
* @param item Вариант из меню.
|
|
176
|
+
* @param inputValue Текущее значение в поле.
|
|
177
|
+
* @return Нужно ли выводить опцию.
|
|
178
|
+
*/
|
|
179
|
+
function defaultFilterOption(item, inputValue) {
|
|
180
|
+
return utils_1.DropdownItemUtils.getValue(item).toLowerCase().includes(inputValue.toLowerCase());
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Возвращает стандартную стрелку для поля ввода с подсказками.
|
|
184
|
+
* @param data Данные о состоянии поля.
|
|
185
|
+
* @return Элемент.
|
|
186
|
+
*/
|
|
187
|
+
function getDefaultAdornmentEnd(data) {
|
|
188
|
+
const ArrowSVG = data.menuShown ? up_1.default : down_1.default;
|
|
189
|
+
return react_1.default.createElement(ArrowSVG, { className: autocomplete_module_scss_1.default.arrow, "data-testid": 'autocomplete:arrow-up' });
|
|
190
|
+
}
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
@use '../colors';
|
|
2
2
|
|
|
3
|
-
.root {
|
|
4
|
-
position: relative;
|
|
5
|
-
width: var(--width, 320px);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
3
|
.arrow {
|
|
4
|
+
display: block;
|
|
5
|
+
flex-shrink: 0;
|
|
9
6
|
fill: colors.$basic-gray38;
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
.field {
|
|
13
|
-
width: 100%;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.menu {
|
|
17
|
-
position: absolute;
|
|
18
|
-
width: 100%;
|
|
19
|
-
z-index: 2;
|
|
20
|
-
}
|
package/autocomplete/index.d.ts
CHANGED
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { TextFieldProps } from '../text-field';
|
|
4
|
-
export interface AutocompleteProps extends Omit<TextFieldProps, 'ref' | 'value' | 'defaultValue'> {
|
|
5
|
-
/** Значение по умолчанию. */
|
|
6
|
-
defaultValue?: string;
|
|
7
|
-
/** Элементы меню. */
|
|
8
|
-
items?: any[];
|
|
9
|
-
/** Размер элемента меню. */
|
|
10
|
-
itemSize?: DropdownItemProps['size'];
|
|
11
|
-
/** Нужно ли выводить состояние загрузки списка. */
|
|
12
|
-
loading?: boolean;
|
|
13
|
-
/** Сработает при выборе. */
|
|
14
|
-
onSelect?: (item: any) => void;
|
|
15
|
-
/** Пресет (со стрелкой или без). */
|
|
16
|
-
preset?: 'default' | 'filled-only-list';
|
|
17
|
-
/** Выведет содержимое элемента. */
|
|
18
|
-
renderItem?: (item: any) => React.ReactNode;
|
|
19
|
-
/** Значение. */
|
|
20
|
-
value?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Поле ввода с подсказками.
|
|
24
|
-
* @param props Свойства.
|
|
25
|
-
* @return Элемент.
|
|
26
|
-
*/
|
|
27
|
-
export declare const Autocomplete: ({ items, itemSize, onSelect, onChange, onKeyDown, style, className, value, defaultValue, loading, renderItem, preset, "data-testid": dataTestId, ...restProps }: AutocompleteProps) => JSX.Element;
|
|
1
|
+
export type { AutocompleteProps } from './types';
|
|
2
|
+
export { Autocomplete } from './autocomplete';
|
package/autocomplete/index.js
CHANGED
|
@@ -1,129 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
3
|
exports.Autocomplete = void 0;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const dropdown_item_1 = require("../dropdown-item");
|
|
44
|
-
const text_field_1 = require("../text-field");
|
|
45
|
-
const dropdown_2 = require("../_internal/utils/dropdown");
|
|
46
|
-
const down_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/down"));
|
|
47
|
-
const up_1 = __importDefault(require("@sima-land/ui-quarks/icons/16x16/Stroked/Arrows/up"));
|
|
48
|
-
const dropdown_loading_1 = require("../_internal/dropdown-loading");
|
|
49
|
-
const bind_1 = __importDefault(require("classnames/bind"));
|
|
50
|
-
const autocomplete_module_scss_1 = __importDefault(require("./autocomplete.module.scss"));
|
|
51
|
-
const cx = bind_1.default.bind(autocomplete_module_scss_1.default);
|
|
52
|
-
/**
|
|
53
|
-
* Поле ввода с подсказками.
|
|
54
|
-
* @param props Свойства.
|
|
55
|
-
* @return Элемент.
|
|
56
|
-
*/
|
|
57
|
-
const Autocomplete = (_a) => {
|
|
58
|
-
var { items, itemSize, onSelect, onChange, onKeyDown, style, className, value, defaultValue, loading, renderItem = String, preset = 'default', 'data-testid': dataTestId } = _a, restProps = __rest(_a, ["items", "itemSize", "onSelect", "onChange", "onKeyDown", "style", "className", "value", "defaultValue", "loading", "renderItem", "preset", 'data-testid']);
|
|
59
|
-
const osComponentRef = (0, react_1.useRef)(null);
|
|
60
|
-
const fieldRef = (0, react_1.useRef)(null);
|
|
61
|
-
const menuRef = (0, react_1.useRef)(null);
|
|
62
|
-
const [withMenu, toggleMenu] = (0, react_1.useState)(false);
|
|
63
|
-
const [realValue, setRealValue] = (0, react_1.useState)(value || defaultValue);
|
|
64
|
-
const [activeIndex, setActiveIndex] = (0, react_1.useState)(null);
|
|
65
|
-
const needMenu = preset === 'filled-only-list' ? withMenu && realValue && realValue.length > 0 : withMenu;
|
|
66
|
-
const arrowIcon = needMenu ? (react_1.default.createElement(up_1.default, { className: cx('arrow'), "data-testid": 'autocomplete:arrow-up' })) : (react_1.default.createElement(down_1.default, { className: cx('arrow'), "data-testid": 'autocomplete:arrow-down' }));
|
|
67
|
-
const endAdornment = preset === 'default' ? arrowIcon : undefined;
|
|
68
|
-
(0, react_1.useEffect)(() => {
|
|
69
|
-
setRealValue(value);
|
|
70
|
-
}, [value]);
|
|
71
|
-
(0, react_1.useEffect)(() => {
|
|
72
|
-
setActiveIndex(null);
|
|
73
|
-
}, [items]);
|
|
74
|
-
(0, react_1.useEffect)(() => {
|
|
75
|
-
var _a;
|
|
76
|
-
const menu = menuRef.current;
|
|
77
|
-
const osInstance = (_a = osComponentRef.current) === null || _a === void 0 ? void 0 : _a.osInstance();
|
|
78
|
-
if (menu && osInstance && activeIndex !== null) {
|
|
79
|
-
const child = menu.querySelectorAll('[role="menuitem"]')[activeIndex];
|
|
80
|
-
child instanceof HTMLElement &&
|
|
81
|
-
osInstance.scroll({
|
|
82
|
-
el: child,
|
|
83
|
-
scroll: { y: 'ifneeded' },
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}, [activeIndex]);
|
|
87
|
-
return (react_1.default.createElement("div", { style: style, className: cx('root', className), "data-testid": dataTestId },
|
|
88
|
-
react_1.default.createElement(text_field_1.TextField, Object.assign({}, restProps, { ref: fieldRef, focused: withMenu, endAdornment: endAdornment, "data-testid": 'autocomplete:field', variant: 'desktop', value: realValue, multiline: false, className: cx('field'), onFocus: () => {
|
|
89
|
-
toggleMenu(true);
|
|
90
|
-
setActiveIndex(null);
|
|
91
|
-
}, onBlur: () => {
|
|
92
|
-
toggleMenu(false);
|
|
93
|
-
}, onChange: (event) => {
|
|
94
|
-
setRealValue(event.target.value);
|
|
95
|
-
setActiveIndex(0);
|
|
96
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
97
|
-
}, onKeyDown: (event) => {
|
|
98
|
-
const size = (items === null || items === void 0 ? void 0 : items.length) || 0;
|
|
99
|
-
let nextIndex;
|
|
100
|
-
switch (event.key) {
|
|
101
|
-
case 'ArrowDown':
|
|
102
|
-
nextIndex = (activeIndex !== null ? size + activeIndex + 1 : 0) % size;
|
|
103
|
-
break;
|
|
104
|
-
case 'ArrowUp':
|
|
105
|
-
nextIndex = (size + Number(activeIndex) - 1) % size;
|
|
106
|
-
break;
|
|
107
|
-
case 'Enter':
|
|
108
|
-
if (items && activeIndex !== null && items.length > activeIndex) {
|
|
109
|
-
onSelect && onSelect(items[activeIndex]);
|
|
110
|
-
toggleMenu(false);
|
|
111
|
-
}
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
if (typeof nextIndex === 'number') {
|
|
115
|
-
event.preventDefault(); // не даём каретке в поле перемещаться
|
|
116
|
-
setActiveIndex(nextIndex);
|
|
117
|
-
}
|
|
118
|
-
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
119
|
-
} })),
|
|
120
|
-
needMenu && (react_1.default.createElement(dropdown_1.Dropdown, Object.assign({}, (0, dropdown_2.placeDropdown)(restProps.size), { ref: menuRef, "data-testid": 'autocomplete:menu', className: cx('menu'), role: 'menu', customScrollbarProps: { osComponentRef } }), loading ? (react_1.default.createElement(dropdown_loading_1.DropdownLoading, { "data-testid": 'autocomplete:loading-area' })) : (react_1.default.createElement(react_1.default.Fragment, null, items && items.length > 0 ? (items.map((item, index) => (react_1.default.createElement(dropdown_item_1.DropdownItem, { size: itemSize, key: index, role: 'menuitem', checked: index === activeIndex, onMouseDown: event => {
|
|
121
|
-
// чтобы при нажатии на опцию предотвратить blur на поле
|
|
122
|
-
event.preventDefault();
|
|
123
|
-
}, onClick: () => {
|
|
124
|
-
onSelect === null || onSelect === void 0 ? void 0 : onSelect(item);
|
|
125
|
-
setActiveIndex(null);
|
|
126
|
-
toggleMenu(false);
|
|
127
|
-
} }, renderItem(item))))) : (react_1.default.createElement(dropdown_item_1.DropdownItem, { size: 'm', noHover: true }, "\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E"))))))));
|
|
128
|
-
};
|
|
129
|
-
exports.Autocomplete = Autocomplete;
|
|
4
|
+
var autocomplete_1 = require("./autocomplete");
|
|
5
|
+
Object.defineProperty(exports, "Autocomplete", { enumerable: true, get: function () { return autocomplete_1.Autocomplete; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { DropdownProps } from '../dropdown';
|
|
3
|
+
import type { DropdownItemElement } from '../dropdown-item/types';
|
|
4
|
+
import type { FieldBlockProps } from '../field-block';
|
|
5
|
+
import type { InputProps } from '../input';
|
|
6
|
+
export interface AutocompleteProps extends InputProps {
|
|
7
|
+
/** Содержимое. */
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
/** Выводить вместо списка спиннер. */
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
/** Получив опцию должен определить, нужно ли выводить ее в списке. */
|
|
12
|
+
filterOption?: (option: DropdownItemElement, inputValue: string) => boolean;
|
|
13
|
+
/** Украшение после основного содержимого. */
|
|
14
|
+
adornmentEnd?: FieldBlockProps['adornmentEnd'] | ((data: {
|
|
15
|
+
menuShown: boolean;
|
|
16
|
+
}) => ReactNode);
|
|
17
|
+
/** Свойства выпадающего списка. */
|
|
18
|
+
dropdownProps?: Pick<DropdownProps, 'className' | 'style'>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@use '../colors';
|
|
2
|
+
|
|
3
|
+
.root {
|
|
4
|
+
position: relative;
|
|
5
|
+
width: var(--width, 320px);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.arrow {
|
|
9
|
+
fill: colors.$basic-gray38;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.field {
|
|
13
|
+
width: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.menu {
|
|
17
|
+
position: absolute;
|
|
18
|
+
width: 100%;
|
|
19
|
+
z-index: 2;
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DropdownItemProps } from '../dropdown-item';
|
|
3
|
+
import { TextFieldProps } from '../text-field';
|
|
4
|
+
export interface AutocompleteProps extends Omit<TextFieldProps, 'ref' | 'value' | 'defaultValue'> {
|
|
5
|
+
/** Значение по умолчанию. */
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
/** Элементы меню. */
|
|
8
|
+
items?: any[];
|
|
9
|
+
/** Размер элемента меню. */
|
|
10
|
+
itemSize?: DropdownItemProps['size'];
|
|
11
|
+
/** Нужно ли выводить состояние загрузки списка. */
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
/** Сработает при выборе. */
|
|
14
|
+
onSelect?: (item: any) => void;
|
|
15
|
+
/** Пресет (со стрелкой или без). */
|
|
16
|
+
preset?: 'default' | 'filled-only-list';
|
|
17
|
+
/** Выведет содержимое элемента. */
|
|
18
|
+
renderItem?: (item: any) => React.ReactNode;
|
|
19
|
+
/** Значение. */
|
|
20
|
+
value?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Поле ввода с подсказками.
|
|
24
|
+
* @deprecated Нужно использовать новую реализацию "@sima-land/ui-nucleons/autocomplete".
|
|
25
|
+
* @param props Свойства.
|
|
26
|
+
* @return Элемент.
|
|
27
|
+
*/
|
|
28
|
+
export declare const Autocomplete: ({ items, itemSize, onSelect, onChange, onKeyDown, style, className, value, defaultValue, loading, renderItem, preset, "data-testid": dataTestId, ...restProps }: AutocompleteProps) => JSX.Element;
|