@hh.ru/magritte-ui-select 13.0.30 → 13.0.31
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/Select.js +2 -0
- package/Select.js.map +1 -1
- package/SelectBottomSheet.js +5 -3
- package/SelectBottomSheet.js.map +1 -1
- package/SelectDrop.js +3 -2
- package/SelectDrop.js.map +1 -1
- package/SelectEmptyHint.js +1 -1
- package/SelectOptions.js +1 -1
- package/SelectSearchTrigger.js +1 -1
- package/UncontrolledSelect.js +2 -0
- package/UncontrolledSelect.js.map +1 -1
- package/index.css +34 -34
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/internal/NavigationManagement.js +1 -1
- package/internal/Option.js +1 -1
- package/internal/SelectError.js +1 -1
- package/legacy/SelectLegacy.js +2 -0
- package/legacy/SelectLegacy.js.map +1 -1
- package/legacy/UncontrolledSelectLegacy.js +2 -0
- package/legacy/UncontrolledSelectLegacy.js.map +1 -1
- package/package.json +9 -5
- package/pickerDefaults.d.ts +15 -0
- package/pickerDefaults.js +10 -0
- package/pickerDefaults.js.map +1 -0
package/Select.js
CHANGED
|
@@ -40,6 +40,7 @@ import 'classnames';
|
|
|
40
40
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
41
41
|
import '@hh.ru/magritte-ui-action-bar';
|
|
42
42
|
import '@hh.ru/magritte-ui-bottom-sheet';
|
|
43
|
+
import '@hh.ru/magritte-ui-bottom-sheet/actionBarDefaults';
|
|
43
44
|
import '@hh.ru/magritte-ui-loader';
|
|
44
45
|
import './internal/SelectError.js';
|
|
45
46
|
import './internal/SelectReloadButton.js';
|
|
@@ -48,6 +49,7 @@ import './useSelectError.js';
|
|
|
48
49
|
import '@hh.ru/magritte-ui-spacing';
|
|
49
50
|
import '@hh.ru/magritte-ui-title';
|
|
50
51
|
import '@hh.ru/magritte-ui-typography';
|
|
52
|
+
import './pickerDefaults.js';
|
|
51
53
|
import './usePickerRef.js';
|
|
52
54
|
import './useSelectContentState.js';
|
|
53
55
|
import './useSelectHint.js';
|
package/Select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["src/Select.tsx"],"sourcesContent":["import { ReactElement, useState } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { ApplyChangesButton } from '@hh.ru/magritte-ui-select/ApplyChangesButton';\nimport { ClearButton } from '@hh.ru/magritte-ui-select/ClearButton';\nimport { ClearCard } from '@hh.ru/magritte-ui-select/ClearCard';\nimport { SelectBottomSheet } from '@hh.ru/magritte-ui-select/SelectBottomSheet';\nimport { SelectBottomSheetHeader } from '@hh.ru/magritte-ui-select/SelectBottomSheetHeader';\nimport { SelectDrop } from '@hh.ru/magritte-ui-select/SelectDrop';\nimport { SelectEmptyHint } from '@hh.ru/magritte-ui-select/SelectEmptyHint';\nimport { SelectOptions } from '@hh.ru/magritte-ui-select/SelectOptions';\nimport { SelectPickerCloseIcon } from '@hh.ru/magritte-ui-select/SelectPickerCloseIcon';\nimport { SelectPickerProvider } from '@hh.ru/magritte-ui-select/SelectPickerContext';\nimport { SelectSearchInput } from '@hh.ru/magritte-ui-select/SelectSearchInput';\nimport { SelectSearchTrigger } from '@hh.ru/magritte-ui-select/SelectSearchTrigger';\nimport { SelectTrigger } from '@hh.ru/magritte-ui-select/SelectTrigger';\nimport { ConfigProvider } from '@hh.ru/magritte-ui-select/internal/ConfigContext';\nimport { NavigationManagement } from '@hh.ru/magritte-ui-select/internal/NavigationManagement';\nimport { SearchStateProvider } from '@hh.ru/magritte-ui-select/internal/SearchStateContext';\nimport { SelectDataProvider } from '@hh.ru/magritte-ui-select/internal/SelectDataProvider';\nimport { SelectStateProvider } from '@hh.ru/magritte-ui-select/internal/SelectStateContext';\nimport { VisibilityProvider } from '@hh.ru/magritte-ui-select/internal/VisibilityContext';\nimport { FocusOrchestratorProvider } from '@hh.ru/magritte-ui-select/internal/focusOrchestrator';\nimport { SelectElementsSlotRegistryProvider } from '@hh.ru/magritte-ui-select/internal/slots';\nimport { useEventCallback } from '@hh.ru/magritte-ui-select/internal/utils';\nimport { SelectProps } from '@hh.ru/magritte-ui-select/types';\n\nexport interface SelectComponents {\n /** Кнопка применения values */\n ApplyChangesButton: typeof ApplyChangesButton;\n /** Пикер Select в виде BottomSheet */\n BottomSheet: typeof SelectBottomSheet;\n /** Крест закрытия пикера (Drop/BottomSheet) */\n PickerCloseIcon: typeof SelectPickerCloseIcon;\n /** Default header для select bottom-sheet */\n BottomSheetHeader: typeof SelectBottomSheetHeader;\n /** Кнопка сброса values */\n ClearButton: typeof ClearButton;\n /** Кнопка сброса values в виде карточки */\n ClearCard: typeof ClearCard;\n /** Пикер Select в виде Drop */\n Drop: typeof SelectDrop;\n /** Триггер Select на основе компонента Trigger */\n Trigger: typeof SelectTrigger;\n /** Дефолтное вью подсказки о пустом списке, передаётся в свойства emptyHint/emptySearchHint */\n EmptyHint: typeof SelectEmptyHint;\n /** Поисковый триггер Select на основе компонента Trigger и Input */\n SearchTrigger: typeof SelectSearchTrigger;\n /** Поисковый Input для обновления стейта поиска (подходит для использования в NavBar) */\n SearchInput: typeof SelectSearchInput;\n /**\n * Компонент позволяет создавать кастомные пикеры (например, select modal).\n * Провайдер предоставляет набор функций для работы с моделью выбора.\n */\n PickerProvider: typeof SelectPickerProvider;\n /** Используется для отображения списка опций */\n Options: typeof SelectOptions;\n}\n\nconst SelectRoot = <MultipleType extends boolean, DataType extends StaticDataFetcherItem>({\n children,\n dataProvider,\n maxSelectedOptions,\n multiple,\n name,\n loading,\n onBlur: onBlurExternal,\n onChange: onChangeExternal,\n onFocus: onFocusExternal,\n onOptionsChange: onOptionsChangeExternal,\n options,\n value,\n error,\n providerError,\n emptyHint,\n emptySearchHint,\n}: SelectProps<MultipleType, DataType>): ReactElement => {\n const onBlur = useEventCallback(onBlurExternal);\n const onFocus = useEventCallback(onFocusExternal);\n const onChange = useEventCallback(onChangeExternal);\n const onOptionsChange = useEventCallback(onOptionsChangeExternal);\n const [showOptions, setShowOptions] = useState(false);\n const [searchValue, setSearchValue] = useState('');\n return (\n <SelectElementsSlotRegistryProvider>\n <ConfigProvider\n maxSelectedOptions={maxSelectedOptions}\n multiple={multiple}\n name={name}\n loading={loading}\n error={error || undefined}\n providerError={providerError || undefined}\n emptyHint={emptyHint}\n emptySearchHint={emptySearchHint}\n >\n <VisibilityProvider showOptions={showOptions} setShowOptions={setShowOptions}>\n <SelectStateProvider<MultipleType, DataType> onChange={onChange} value={value}>\n <SearchStateProvider searchValue={searchValue} setSearchValue={setSearchValue}>\n <SelectDataProvider<DataType>\n dataProvider={dataProvider}\n options={options}\n onOptionsChange={onOptionsChange}\n >\n <FocusOrchestratorProvider>\n <NavigationManagement onBlur={onBlur} onFocus={onFocus}>\n {children}\n </NavigationManagement>\n </FocusOrchestratorProvider>\n </SelectDataProvider>\n </SearchStateProvider>\n </SelectStateProvider>\n </VisibilityProvider>\n </ConfigProvider>\n </SelectElementsSlotRegistryProvider>\n );\n};\n\nconst Select = SelectRoot as typeof SelectRoot & SelectComponents;\n\nSelect.ApplyChangesButton = ApplyChangesButton;\nSelect.BottomSheet = SelectBottomSheet;\nSelect.PickerCloseIcon = SelectPickerCloseIcon;\nSelect.BottomSheetHeader = SelectBottomSheetHeader;\nSelect.ClearButton = ClearButton;\nSelect.ClearCard = ClearCard;\nSelect.Drop = SelectDrop;\nSelect.EmptyHint = SelectEmptyHint;\nSelect.Trigger = SelectTrigger;\nSelect.PickerProvider = SelectPickerProvider;\nSelect.SearchTrigger = SelectSearchTrigger;\nSelect.SearchInput = SelectSearchInput;\nSelect.Options = SelectOptions;\n\nexport { Select };\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["src/Select.tsx"],"sourcesContent":["import { ReactElement, useState } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { ApplyChangesButton } from '@hh.ru/magritte-ui-select/ApplyChangesButton';\nimport { ClearButton } from '@hh.ru/magritte-ui-select/ClearButton';\nimport { ClearCard } from '@hh.ru/magritte-ui-select/ClearCard';\nimport { SelectBottomSheet } from '@hh.ru/magritte-ui-select/SelectBottomSheet';\nimport { SelectBottomSheetHeader } from '@hh.ru/magritte-ui-select/SelectBottomSheetHeader';\nimport { SelectDrop } from '@hh.ru/magritte-ui-select/SelectDrop';\nimport { SelectEmptyHint } from '@hh.ru/magritte-ui-select/SelectEmptyHint';\nimport { SelectOptions } from '@hh.ru/magritte-ui-select/SelectOptions';\nimport { SelectPickerCloseIcon } from '@hh.ru/magritte-ui-select/SelectPickerCloseIcon';\nimport { SelectPickerProvider } from '@hh.ru/magritte-ui-select/SelectPickerContext';\nimport { SelectSearchInput } from '@hh.ru/magritte-ui-select/SelectSearchInput';\nimport { SelectSearchTrigger } from '@hh.ru/magritte-ui-select/SelectSearchTrigger';\nimport { SelectTrigger } from '@hh.ru/magritte-ui-select/SelectTrigger';\nimport { ConfigProvider } from '@hh.ru/magritte-ui-select/internal/ConfigContext';\nimport { NavigationManagement } from '@hh.ru/magritte-ui-select/internal/NavigationManagement';\nimport { SearchStateProvider } from '@hh.ru/magritte-ui-select/internal/SearchStateContext';\nimport { SelectDataProvider } from '@hh.ru/magritte-ui-select/internal/SelectDataProvider';\nimport { SelectStateProvider } from '@hh.ru/magritte-ui-select/internal/SelectStateContext';\nimport { VisibilityProvider } from '@hh.ru/magritte-ui-select/internal/VisibilityContext';\nimport { FocusOrchestratorProvider } from '@hh.ru/magritte-ui-select/internal/focusOrchestrator';\nimport { SelectElementsSlotRegistryProvider } from '@hh.ru/magritte-ui-select/internal/slots';\nimport { useEventCallback } from '@hh.ru/magritte-ui-select/internal/utils';\nimport { SelectProps } from '@hh.ru/magritte-ui-select/types';\n\nexport interface SelectComponents {\n /** Кнопка применения values */\n ApplyChangesButton: typeof ApplyChangesButton;\n /** Пикер Select в виде BottomSheet */\n BottomSheet: typeof SelectBottomSheet;\n /** Крест закрытия пикера (Drop/BottomSheet) */\n PickerCloseIcon: typeof SelectPickerCloseIcon;\n /** Default header для select bottom-sheet */\n BottomSheetHeader: typeof SelectBottomSheetHeader;\n /** Кнопка сброса values */\n ClearButton: typeof ClearButton;\n /** Кнопка сброса values в виде карточки */\n ClearCard: typeof ClearCard;\n /** Пикер Select в виде Drop */\n Drop: typeof SelectDrop;\n /** Триггер Select на основе компонента Trigger */\n Trigger: typeof SelectTrigger;\n /** Дефолтное вью подсказки о пустом списке, передаётся в свойства emptyHint/emptySearchHint */\n EmptyHint: typeof SelectEmptyHint;\n /** Поисковый триггер Select на основе компонента Trigger и Input */\n SearchTrigger: typeof SelectSearchTrigger;\n /** Поисковый Input для обновления стейта поиска (подходит для использования в NavBar) */\n SearchInput: typeof SelectSearchInput;\n /**\n * Компонент позволяет создавать кастомные пикеры (например, select modal).\n * Провайдер предоставляет набор функций для работы с моделью выбора.\n */\n PickerProvider: typeof SelectPickerProvider;\n /** Используется для отображения списка опций */\n Options: typeof SelectOptions;\n}\n\nconst SelectRoot = <MultipleType extends boolean, DataType extends StaticDataFetcherItem>({\n children,\n dataProvider,\n maxSelectedOptions,\n multiple,\n name,\n loading,\n onBlur: onBlurExternal,\n onChange: onChangeExternal,\n onFocus: onFocusExternal,\n onOptionsChange: onOptionsChangeExternal,\n options,\n value,\n error,\n providerError,\n emptyHint,\n emptySearchHint,\n}: SelectProps<MultipleType, DataType>): ReactElement => {\n const onBlur = useEventCallback(onBlurExternal);\n const onFocus = useEventCallback(onFocusExternal);\n const onChange = useEventCallback(onChangeExternal);\n const onOptionsChange = useEventCallback(onOptionsChangeExternal);\n const [showOptions, setShowOptions] = useState(false);\n const [searchValue, setSearchValue] = useState('');\n return (\n <SelectElementsSlotRegistryProvider>\n <ConfigProvider\n maxSelectedOptions={maxSelectedOptions}\n multiple={multiple}\n name={name}\n loading={loading}\n error={error || undefined}\n providerError={providerError || undefined}\n emptyHint={emptyHint}\n emptySearchHint={emptySearchHint}\n >\n <VisibilityProvider showOptions={showOptions} setShowOptions={setShowOptions}>\n <SelectStateProvider<MultipleType, DataType> onChange={onChange} value={value}>\n <SearchStateProvider searchValue={searchValue} setSearchValue={setSearchValue}>\n <SelectDataProvider<DataType>\n dataProvider={dataProvider}\n options={options}\n onOptionsChange={onOptionsChange}\n >\n <FocusOrchestratorProvider>\n <NavigationManagement onBlur={onBlur} onFocus={onFocus}>\n {children}\n </NavigationManagement>\n </FocusOrchestratorProvider>\n </SelectDataProvider>\n </SearchStateProvider>\n </SelectStateProvider>\n </VisibilityProvider>\n </ConfigProvider>\n </SelectElementsSlotRegistryProvider>\n );\n};\n\nconst Select = SelectRoot as typeof SelectRoot & SelectComponents;\n\nSelect.ApplyChangesButton = ApplyChangesButton;\nSelect.BottomSheet = SelectBottomSheet;\nSelect.PickerCloseIcon = SelectPickerCloseIcon;\nSelect.BottomSheetHeader = SelectBottomSheetHeader;\nSelect.ClearButton = ClearButton;\nSelect.ClearCard = ClearCard;\nSelect.Drop = SelectDrop;\nSelect.EmptyHint = SelectEmptyHint;\nSelect.Trigger = SelectTrigger;\nSelect.PickerProvider = SelectPickerProvider;\nSelect.SearchTrigger = SelectSearchTrigger;\nSelect.SearchInput = SelectSearchInput;\nSelect.Options = SelectOptions;\n\nexport { Select };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAM,aAAa,CAAuE;AAAA,EACtF,QAAA;AAAA,EACA,YAAA;AAAA,EACA,kBAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAQ,EAAA,cAAA;AAAA,EACR,QAAU,EAAA,gBAAA;AAAA,EACV,OAAS,EAAA,eAAA;AAAA,EACT,eAAiB,EAAA,uBAAA;AAAA,EACjB,OAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AACJ,CAAyD,KA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,MAAM,MAAS,GAAA,WAAA;AAEf,MAAA,CAAO,kBAAqB,GAAA,kBAAA,CAAA;AAC5B,MAAA,CAAO,WAAc,GAAA,iBAAA,CAAA;AACrB,MAAA,CAAO,eAAkB,GAAA,qBAAA,CAAA;AACzB,MAAA,CAAO,iBAAoB,GAAA,uBAAA,CAAA;AAC3B,MAAA,CAAO,WAAc,GAAA,WAAA,CAAA;AACrB,MAAA,CAAO,SAAY,GAAA,SAAA,CAAA;AACnB,MAAA,CAAO,IAAO,GAAA,UAAA,CAAA;AACd,MAAA,CAAO,SAAY,GAAA,eAAA,CAAA;AACnB,MAAA,CAAO,OAAU,GAAA,aAAA,CAAA;AACjB,MAAA,CAAO,cAAiB,GAAA,oBAAA,CAAA;AACxB,MAAA,CAAO,aAAgB,GAAA,mBAAA,CAAA;AACvB,MAAA,CAAO,WAAc,GAAA,iBAAA,CAAA;AACrB,MAAA,CAAO,OAAU,GAAA,aAAA;;;;"}
|
package/SelectBottomSheet.js
CHANGED
|
@@ -5,12 +5,14 @@ import classnames from 'classnames';
|
|
|
5
5
|
import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
|
|
6
6
|
import { ActionBarDefaultPropsContext } from '@hh.ru/magritte-ui-action-bar';
|
|
7
7
|
import { BottomSheetFooter, BottomSheet } from '@hh.ru/magritte-ui-bottom-sheet';
|
|
8
|
+
import { BOTTOM_SHEET_ACTION_BAR_DEFAULTS } from '@hh.ru/magritte-ui-bottom-sheet/actionBarDefaults';
|
|
8
9
|
import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
|
|
9
10
|
import { Loader } from '@hh.ru/magritte-ui-loader';
|
|
10
11
|
import { useSelectPicker, SelectPickerProvider } from './SelectPickerContext.js';
|
|
11
12
|
import { SelectError } from './internal/SelectError.js';
|
|
12
13
|
import { SelectReloadButton } from './internal/SelectReloadButton.js';
|
|
13
14
|
import { useRegisterSelectElementsSlot } from './internal/slots.js';
|
|
15
|
+
import { SELECT_BOTTOM_SHEET_HEIGHT_DEFAULT } from './pickerDefaults.js';
|
|
14
16
|
import { usePickerRef } from './usePickerRef.js';
|
|
15
17
|
import { useSelectContentState } from './useSelectContentState.js';
|
|
16
18
|
import { useSelectError } from './useSelectError.js';
|
|
@@ -35,9 +37,9 @@ import './internal/useDataProvider.js';
|
|
|
35
37
|
import './useSearchState.js';
|
|
36
38
|
import './internal/SearchStateContext.js';
|
|
37
39
|
|
|
38
|
-
var styles = {"content-placeholder":"magritte-content-placeholder___rOCxd_13-0-
|
|
40
|
+
var styles = {"content-placeholder":"magritte-content-placeholder___rOCxd_13-0-31","contentPlaceholder":"magritte-content-placeholder___rOCxd_13-0-31","select-bottom-sheet_without-header":"magritte-select-bottom-sheet_without-header___KOKVh_13-0-31","selectBottomSheetWithoutHeader":"magritte-select-bottom-sheet_without-header___KOKVh_13-0-31"};
|
|
39
41
|
|
|
40
|
-
const ACTION_BAR_DEFAULT_PROPS =
|
|
42
|
+
const ACTION_BAR_DEFAULT_PROPS = BOTTOM_SHEET_ACTION_BAR_DEFAULTS;
|
|
41
43
|
const SelectBottomSheetComponentRenderFunc = ({ children, footer, header, ...props }, ref) => {
|
|
42
44
|
const { isMobile } = useBreakpoint();
|
|
43
45
|
const pickerRef = usePickerRef(isMobile);
|
|
@@ -66,7 +68,7 @@ const SelectBottomSheetComponentRenderFunc = ({ children, footer, header, ...pro
|
|
|
66
68
|
BottomSheet,
|
|
67
69
|
{
|
|
68
70
|
...props,
|
|
69
|
-
height: props.height ??
|
|
71
|
+
height: props.height ?? SELECT_BOTTOM_SHEET_HEIGHT_DEFAULT,
|
|
70
72
|
ref: bottomSheetRefCallback,
|
|
71
73
|
allowScrollWhileFocused: true,
|
|
72
74
|
keyboardOverlaysFooter: false,
|
package/SelectBottomSheet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectBottomSheet.js","sources":["src/SelectBottomSheet.tsx"],"sourcesContent":["import { ReactElement, ComponentProps, forwardRef, ForwardedRef, useCallback } from 'react';\nimport classnames from 'classnames';\n\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { ActionBarProps, ActionBarDefaultPropsContext } from '@hh.ru/magritte-ui-action-bar';\nimport { BottomSheet, BottomSheetFooter } from '@hh.ru/magritte-ui-bottom-sheet';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { SelectPickerProvider, useSelectPicker } from '@hh.ru/magritte-ui-select/SelectPickerContext';\nimport { SelectError } from '@hh.ru/magritte-ui-select/internal/SelectError';\nimport { SelectReloadButton } from '@hh.ru/magritte-ui-select/internal/SelectReloadButton';\nimport { useRegisterSelectElementsSlot } from '@hh.ru/magritte-ui-select/internal/slots';\nimport { usePickerRef } from '@hh.ru/magritte-ui-select/usePickerRef';\nimport { useSelectContentState } from '@hh.ru/magritte-ui-select/useSelectContentState';\nimport { useSelectError } from '@hh.ru/magritte-ui-select/useSelectError';\nimport { useSelectHint } from '@hh.ru/magritte-ui-select/useSelectHint';\nimport { useVisibility } from '@hh.ru/magritte-ui-select/useVisibility';\n\nimport styles from './select-bottom-sheet.less';\n\ntype SelectBottomSheetProps = Omit<\n ComponentProps<typeof BottomSheet>,\n 'allowScrollWhileFocused' | 'keyboardOverlaysFooter' | 'visible' | 'withContentPaddings' | 'onClose' | 'ref'\n>;\n\nconst ACTION_BAR_DEFAULT_PROPS: Partial<ActionBarProps> =
|
|
1
|
+
{"version":3,"file":"SelectBottomSheet.js","sources":["src/SelectBottomSheet.tsx"],"sourcesContent":["import { ReactElement, ComponentProps, forwardRef, ForwardedRef, useCallback } from 'react';\nimport classnames from 'classnames';\n\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { ActionBarProps, ActionBarDefaultPropsContext } from '@hh.ru/magritte-ui-action-bar';\nimport { BottomSheet, BottomSheetFooter } from '@hh.ru/magritte-ui-bottom-sheet';\nimport { BOTTOM_SHEET_ACTION_BAR_DEFAULTS } from '@hh.ru/magritte-ui-bottom-sheet/actionBarDefaults';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { SelectPickerProvider, useSelectPicker } from '@hh.ru/magritte-ui-select/SelectPickerContext';\nimport { SelectError } from '@hh.ru/magritte-ui-select/internal/SelectError';\nimport { SelectReloadButton } from '@hh.ru/magritte-ui-select/internal/SelectReloadButton';\nimport { useRegisterSelectElementsSlot } from '@hh.ru/magritte-ui-select/internal/slots';\nimport { SELECT_BOTTOM_SHEET_HEIGHT_DEFAULT } from '@hh.ru/magritte-ui-select/pickerDefaults';\nimport { usePickerRef } from '@hh.ru/magritte-ui-select/usePickerRef';\nimport { useSelectContentState } from '@hh.ru/magritte-ui-select/useSelectContentState';\nimport { useSelectError } from '@hh.ru/magritte-ui-select/useSelectError';\nimport { useSelectHint } from '@hh.ru/magritte-ui-select/useSelectHint';\nimport { useVisibility } from '@hh.ru/magritte-ui-select/useVisibility';\n\nimport styles from './select-bottom-sheet.less';\n\ntype SelectBottomSheetProps = Omit<\n ComponentProps<typeof BottomSheet>,\n 'allowScrollWhileFocused' | 'keyboardOverlaysFooter' | 'visible' | 'withContentPaddings' | 'onClose' | 'ref'\n>;\n\n// те же дефолты, что BottomSheet даёт ActionBar в футере: их же снимает шаблон Code Connect\nconst ACTION_BAR_DEFAULT_PROPS: Partial<ActionBarProps> = BOTTOM_SHEET_ACTION_BAR_DEFAULTS;\n\nconst SelectBottomSheetComponentRenderFunc = (\n { children, footer, header, ...props }: SelectBottomSheetProps,\n ref: ForwardedRef<HTMLElement>\n): ReactElement => {\n const { isMobile } = useBreakpoint();\n const pickerRef = usePickerRef(isMobile);\n const bottomSheetRefCallback = useMultipleRefs(pickerRef, ref);\n\n useRegisterSelectElementsSlot('keepPickerOpenOnBlur', isMobile || undefined);\n\n const { showOptions } = useVisibility();\n\n const { error: errorExternal, providerError } = useSelectError();\n\n const contentState = useSelectContentState();\n\n const { emptyHint, emptySearchHint } = useSelectHint();\n\n let pickerFooter = footer;\n if (contentState === 'external-error') {\n pickerFooter = <BottomSheetFooter>{errorExternal?.resetButton}</BottomSheetFooter>;\n } else if (contentState === 'provider-error' && providerError) {\n pickerFooter = (\n <BottomSheetFooter>\n <SelectReloadButton label={providerError.reloadButton} />\n </BottomSheetFooter>\n );\n }\n\n const { onCloseRequestWithUnsavedChanges } = useSelectPicker();\n\n const onClose = useCallback(\n (cancelCloseFunc: VoidFunction | null) => {\n if (!onCloseRequestWithUnsavedChanges()) {\n cancelCloseFunc?.();\n }\n },\n [onCloseRequestWithUnsavedChanges]\n );\n\n return (\n <BottomSheet\n {...props}\n height={props.height ?? SELECT_BOTTOM_SHEET_HEIGHT_DEFAULT}\n ref={bottomSheetRefCallback}\n allowScrollWhileFocused\n keyboardOverlaysFooter={false}\n visible={\n // bottom-sheet хотим показывать, если был включен showOptions без учета contentState\n showOptions\n }\n withContentPaddings={\n contentState === 'external-error' || (contentState === 'provider-error' && Boolean(providerError))\n }\n header={header}\n footer={\n pickerFooter ? (\n <ActionBarDefaultPropsContext props={ACTION_BAR_DEFAULT_PROPS}>\n {pickerFooter}\n </ActionBarDefaultPropsContext>\n ) : undefined\n }\n onClose={onClose}\n >\n {contentState === 'loading' && (\n <div className={styles.contentPlaceholder}>\n <Loader size={24} />\n </div>\n )}\n {contentState === 'provider-error' && <SelectError />}\n {contentState === 'external-error' && errorExternal?.placeholder}\n {contentState === 'empty-hint' && emptyHint}\n {contentState === 'empty-search-hint' && emptySearchHint}\n {(contentState === 'options' ||\n contentState === 'pending' ||\n (contentState === 'empty-hint' && !emptyHint) ||\n (contentState === 'empty-search-hint' && !emptySearchHint)) && (\n <div className={classnames({ [styles.selectBottomSheetWithoutHeader]: !header })}>{children}</div>\n )}\n </BottomSheet>\n );\n};\n\nconst SelectBottomSheetComponent = forwardRef<HTMLElement, SelectBottomSheetProps>(\n SelectBottomSheetComponentRenderFunc\n);\nSelectBottomSheetComponent.displayName = 'SelectBottomSheetComponent';\n\nconst SelectBottomSheetRenderFunc = (\n { children, ...props }: SelectBottomSheetProps,\n ref: ForwardedRef<HTMLElement>\n): ReactElement => {\n return (\n <SelectPickerProvider>\n <SelectBottomSheetComponent {...props} ref={ref}>\n {children}\n </SelectBottomSheetComponent>\n </SelectPickerProvider>\n );\n};\n\n/** Пикер Select в виде BottomSheet */\nconst SelectBottomSheet = forwardRef<HTMLElement, SelectBottomSheetProps>(SelectBottomSheetRenderFunc);\nSelectBottomSheet.displayName = 'SelectBottomSheet';\n\nexport { SelectBottomSheet };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,wBAAoD,GAAA,gCAAA,CAAA;AAE1D,MAAM,oCAAA,GAAuC,CACzC,EAAE,QAAA,EAAU,QAAQ,MAAQ,EAAA,GAAG,KAAM,EAAA,EACrC,GACe,KAAA;AACf,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,aAAc,EAAA,CAAA;AACnC,EAAM,MAAA,SAAA,GAAY,aAAa,QAAQ,CAAA,CAAA;AACvC,EAAM,MAAA,sBAAA,GAAyB,eAAgB,CAAA,SAAA,EAAW,GAAG,CAAA,CAAA;AAE7D,EAA8B,6BAAA,CAAA,sBAAA,EAAwB,YAAY,KAAS,CAAA,CAAA,CAAA;AAE3E,EAAM,MAAA,EAAE,WAAY,EAAA,GAAI,aAAc,EAAA,CAAA;AAEtC,EAAA,MAAM,EAAE,KAAA,EAAO,aAAe,EAAA,aAAA,KAAkB,cAAe,EAAA,CAAA;AAE/D,EAAA,MAAM,eAAe,qBAAsB,EAAA,CAAA;AAE3C,EAAA,MAAM,EAAE,SAAA,EAAW,eAAgB,EAAA,GAAI,aAAc,EAAA,CAAA;AAErD,EAAA,IAAI,YAAe,GAAA,MAAA,CAAA;AACnB,EAAA,IAAI,iBAAiB,gBAAkB,EAAA;AACnC,IAAe,YAAA,mBAAA,GAAA,CAAC,iBAAm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EAAA,EAAI,CACtB,EAAA,CAAA;AAAA,QAEH,YAAA,KAAiB,gBAAoB,oBAAA,GAAA,CAAC,WAAY,EAAA,EAAA,CAAA;AAAA,QAClD,YAAA,KAAiB,oBAAoB,aAAe,EAAA,WAAA;AAAA,QACpD,iBAAiB,YAAgB,IAAA,SAAA;AAAA,QACjC,iBAAiB,mBAAuB,IAAA,eAAA;AAAA,QACvC,CAAA,YAAA,KAAiB,SACf,IAAA,YAAA,KAAiB,SAChB,IAAA,YAAA,KAAiB,gBAAgB,CAAC,SAAA,IAClC,YAAiB,KAAA,mBAAA,IAAuB,CAAC,eAAA,yBACzC,KAAI,EAAA,EAAA,SAAA,EAAW,UAAW,CAAA,EAAE,CAAC,MAAA,CAAO,8BAA8B,GAAG,CAAC,MAAA,EAAQ,CAAA,EAAI,QAAS,EAAA,CAAA;AAAA,OAAA;AAAA,KAAA;AAAA,GAEpG,CAAA;AAER,CAAA,CAAA;AAEA,MAAM,0BAA6B,GAAA,UAAA;AAAA,EAC/B,oCAAA;AACJ,CAAA,CAAA;AACA,0BAAA,CAA2B,WAAc,GAAA,4BAAA,CAAA;AAEzC,MAAM,8BAA8B,CAChC,EAAE,UAAU,GAAG,KAAA,IACf,GACe,KAAA;AACf,EACI,uBAAA,GAAA,CAAC,wBACG,QAAC,kBAAA,GAAA,CAAA,0BAAA,EAAA,EAA4B,GAAG,KAAO,EAAA,GAAA,EAClC,UACL,CACJ,EAAA,CAAA,CAAA;AAER,CAAA,CAAA;AAGM,MAAA,iBAAA,GAAoB,WAAgD,2BAA2B,EAAA;AACrG,iBAAA,CAAkB,WAAc,GAAA,mBAAA;;;;"}
|
package/SelectDrop.js
CHANGED
|
@@ -11,6 +11,7 @@ import { useSelectPicker, SelectPickerProvider } from './SelectPickerContext.js'
|
|
|
11
11
|
import { SelectError } from './internal/SelectError.js';
|
|
12
12
|
import { useSelectElementsValue, useRegisterSelectElementsSlot } from './internal/slots.js';
|
|
13
13
|
import { useEventCallback, isElementInsideActivatorOrPicker } from './internal/utils.js';
|
|
14
|
+
import { SELECT_DROP_ACTION_BAR_DEFAULTS } from './pickerDefaults.js';
|
|
14
15
|
import { usePickerRef } from './usePickerRef.js';
|
|
15
16
|
import { useSelectConfig } from './useSelectConfig.js';
|
|
16
17
|
import { useSelectContentState } from './useSelectContentState.js';
|
|
@@ -35,10 +36,10 @@ import '@hh.ru/magritte-ui-spacing';
|
|
|
35
36
|
import '@hh.ru/magritte-ui-title';
|
|
36
37
|
import '@hh.ru/magritte-ui-typography';
|
|
37
38
|
|
|
38
|
-
var styles = {"select-drop-container-wrapper":"magritte-select-drop-container-wrapper___OHM0q_13-0-
|
|
39
|
+
var styles = {"select-drop-container-wrapper":"magritte-select-drop-container-wrapper___OHM0q_13-0-31","selectDropContainerWrapper":"magritte-select-drop-container-wrapper___OHM0q_13-0-31","select-drop-container":"magritte-select-drop-container___hee1p_13-0-31","selectDropContainer":"magritte-select-drop-container___hee1p_13-0-31","select-drop-container_plain":"magritte-select-drop-container_plain___766zl_13-0-31","selectDropContainerPlain":"magritte-select-drop-container_plain___766zl_13-0-31","select-drop-container_with-footer":"magritte-select-drop-container_with-footer___6wp-L_13-0-31","selectDropContainerWithFooter":"magritte-select-drop-container_with-footer___6wp-L_13-0-31","select-drop-loading":"magritte-select-drop-loading___KsNuw_13-0-31","selectDropLoading":"magritte-select-drop-loading___KsNuw_13-0-31"};
|
|
39
40
|
|
|
40
41
|
const DROP_PLACEMENT = ["bottom-left", "top-left", "bottom-right", "top-right"];
|
|
41
|
-
const ACTION_BAR_DEFAULT_PROPS =
|
|
42
|
+
const ACTION_BAR_DEFAULT_PROPS = SELECT_DROP_ACTION_BAR_DEFAULTS;
|
|
42
43
|
const SelectDropComponentRenderFunc = ({
|
|
43
44
|
onClose: onCloseExternal,
|
|
44
45
|
widthEqualToActivator = true,
|
package/SelectDrop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectDrop.js","sources":["src/SelectDrop.tsx"],"sourcesContent":["import { type ReactElement, useId, ComponentProps, useEffect, forwardRef, ForwardedRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { ActionBarProps, ActionBarDefaultPropsContext } from '@hh.ru/magritte-ui-action-bar';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { Drop } from '@hh.ru/magritte-ui-drop';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { SelectPickerProvider, useSelectPicker } from '@hh.ru/magritte-ui-select/SelectPickerContext';\nimport { SelectError } from '@hh.ru/magritte-ui-select/internal/SelectError';\nimport { useSelectElementsValue, useRegisterSelectElementsSlot } from '@hh.ru/magritte-ui-select/internal/slots';\nimport { useEventCallback, isElementInsideActivatorOrPicker } from '@hh.ru/magritte-ui-select/internal/utils';\nimport { usePickerRef } from '@hh.ru/magritte-ui-select/usePickerRef';\nimport { useSelectConfig } from '@hh.ru/magritte-ui-select/useSelectConfig';\nimport { useSelectContentState } from '@hh.ru/magritte-ui-select/useSelectContentState';\nimport { useSelectHint } from '@hh.ru/magritte-ui-select/useSelectHint';\nimport { useVisibility } from '@hh.ru/magritte-ui-select/useVisibility';\n\nimport styles from './select-drop.less';\n\ntype SelectDropProps = Omit<\n ComponentProps<typeof Drop>,\n | 'id'\n | 'placement'\n | 'autoFocusWhenOpened'\n | 'role'\n | 'keyboardNavigationMode'\n | 'closeByClickOutside'\n | 'padding'\n | 'forcePlacement'\n | 'visible'\n | 'activatorRef'\n | 'returnFocusOnClose'\n | 'ref'\n>;\n\ninterface SelectDropHelper {\n /**\n * По умолчанию, drop закрывается, если список опций пуст\n * Свойство позволяет держать drop открытым, даже если опций нет\n * Подходит для реализации поиска внутри drop\n */\n forceDropVisibleWithEmptyOptions?: boolean;\n /** Максимальная высота выпадающего блока для desktop */\n maxHeight?: number;\n}\n\nconst DROP_PLACEMENT = ['bottom-left', 'top-left', 'bottom-right', 'top-right'];\n\nconst ACTION_BAR_DEFAULT_PROPS: Partial<ActionBarProps> = { type: 'vertical', padding: 0, showDivider: false };\n\nconst SelectDropComponentRenderFunc = (\n {\n onClose: onCloseExternal,\n widthEqualToActivator = true,\n forceDropVisibleWithEmptyOptions,\n maxHeight = 460,\n width,\n children,\n footer,\n ...props\n }: SelectDropProps & SelectDropHelper,\n ref: ForwardedRef<HTMLElement>\n): ReactElement | null => {\n const pickerId = useId();\n const { isMobile } = useBreakpoint();\n const pickerRef = usePickerRef(!isMobile);\n const dropRefCallback = useMultipleRefs(pickerRef, ref);\n\n const onClose = useEventCallback(onCloseExternal);\n\n const activatorRef = useSelectElementsValue('activatorRef');\n const plain = useSelectElementsValue('plain');\n\n const { showOptions } = useVisibility();\n const { hasProviderError, hasEmptyHint, hasEmptySearchHint } = useSelectConfig();\n const { emptyHint, emptySearchHint } = useSelectHint();\n\n const contentState = useSelectContentState();\n\n useRegisterSelectElementsSlot('pickerId', !isMobile ? pickerId : undefined);\n\n const { discardChanges, onCloseRequestWithUnsavedChanges } = useSelectPicker();\n\n // не переоткрываем select при клике на тригер\n useEffect(() => {\n if (!showOptions || isMobile || !activatorRef) {\n return void 0;\n }\n const controller = new AbortController();\n const closeOnOutsideInteraction = (event: Event) => {\n if (isElementInsideActivatorOrPicker(activatorRef, pickerRef, event.target as Node)) {\n return;\n }\n controller.abort();\n discardChanges();\n onCloseRequestWithUnsavedChanges();\n };\n document.addEventListener('focus', closeOnOutsideInteraction, { capture: true, signal: controller.signal });\n document.addEventListener('click', closeOnOutsideInteraction, { capture: true, signal: controller.signal });\n return () => controller.abort();\n }, [isMobile, activatorRef, showOptions, discardChanges, onCloseRequestWithUnsavedChanges, pickerRef]);\n\n if (!activatorRef) {\n return null;\n }\n\n return (\n <Drop\n {...props}\n ref={dropRefCallback}\n width={width}\n autoFocusWhenOpened={false}\n visible={\n /**\n * пикер в виде дропа хотим показывать, если был включен showOptions и при этом\n * - есть что показать: опции, лоадер, ошибка провайдера или подсказка\n * - либо потребитель держит дроп открытым сам\n * внешняя ошибка (external-error) в дроп не попадает — её показывает тригер\n */\n showOptions &&\n (contentState === 'options' ||\n (contentState === 'empty-hint' && hasEmptyHint) ||\n (contentState === 'empty-search-hint' && hasEmptySearchHint) ||\n (contentState === 'provider-error' && hasProviderError) ||\n contentState === 'loading' ||\n forceDropVisibleWithEmptyOptions)\n }\n placement={DROP_PLACEMENT}\n activatorRef={activatorRef}\n padding={plain ? 24 : 12}\n keyboardNavigationMode=\"list\"\n onClose={() => {\n discardChanges();\n onCloseRequestWithUnsavedChanges();\n onClose?.();\n }}\n closeByClickOutside={false}\n widthEqualToActivator={widthEqualToActivator || (contentState === 'loading' && width === undefined)}\n forcePlacement\n returnFocusOnClose={false}\n footer={\n footer ? (\n <ActionBarDefaultPropsContext props={ACTION_BAR_DEFAULT_PROPS}>\n {footer}\n </ActionBarDefaultPropsContext>\n ) : undefined\n }\n id={pickerId}\n role=\"dialog\"\n >\n <div className={styles.selectDropContainerWrapper} style={{ maxHeight: `${maxHeight}px` }}>\n <div\n className={classnames(\n styles.selectDropContainer,\n { [styles.selectDropContainerPlain]: plain },\n { [styles.selectDropContainerWithFooter]: Boolean(footer) }\n )}\n >\n {contentState === 'loading' && (\n <div className={styles.selectDropLoading}>\n <Loader size={24} />\n </div>\n )}\n {contentState === 'provider-error' && <SelectError />}\n {contentState === 'empty-hint' && emptyHint}\n {contentState === 'empty-search-hint' && emptySearchHint}\n {(contentState === 'options' ||\n contentState === 'pending' ||\n (contentState === 'empty-hint' && !emptyHint) ||\n (contentState === 'empty-search-hint' && !emptySearchHint)) &&\n children}\n </div>\n </div>\n </Drop>\n );\n};\n\nconst SelectDropComponent = forwardRef<HTMLElement, SelectDropProps & SelectDropHelper>(SelectDropComponentRenderFunc);\nSelectDropComponent.displayName = 'SelectDropComponent';\n\nconst SelectDropRenderFunc = (\n { children, ...props }: SelectDropProps & SelectDropHelper,\n ref: ForwardedRef<HTMLElement>\n): ReactElement => {\n return (\n <SelectPickerProvider>\n <SelectDropComponent {...props} ref={ref}>\n {children}\n </SelectDropComponent>\n </SelectPickerProvider>\n );\n};\n\n/** Пикер Select в виде Drop */\nconst SelectDrop = forwardRef<HTMLElement, SelectDropProps & SelectDropHelper>(SelectDropRenderFunc);\nSelectDrop.displayName = 'SelectDrop';\n\nexport { SelectDrop };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,cAAiB,GAAA,CAAC,aAAe,EAAA,UAAA,EAAY,gBAAgB,WAAW,CAAA,CAAA;AAE9E,MAAM,2BAAoD,EAAE,IAAA,EAAM,YAAY,OAAS,EAAA,CAAA,EAAG,aAAa,KAAM,EAAA,CAAA;AAE7G,MAAM,gCAAgC,CAClC;AAAA,EACI,OAAS,EAAA,eAAA;AAAA,EACT,qBAAwB,GAAA,IAAA;AAAA,EACxB,gCAAA;AAAA,EACA,SAAY,GAAA,GAAA;AAAA,EACZ,KAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAG,KAAA;AACP,CAAA,EACA,GACsB,KAAA;AACtB,EAAA,MAAM,WAAW,KAAM,EAAA,CAAA;AACvB,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,aAAc,EAAA,CAAA;AACnC,EAAM,MAAA,SAAA,GAAY,YAAa,CAAA,CAAC,QAAQ,CAAA,CAAA;AACxC,EAAM,MAAA,eAAA,GAAkB,eAAgB,CAAA,SAAA,EAAW,GAAG,CAAA,CAAA;AAEtD,EAAM,MAAA,OAAA,GAAU,iBAAiB,eAAe,CAAA,CAAA;AAEhD,EAAM,MAAA,YAAA,GAAe,uBAAuB,cAAc,CAAA,CAAA;AAC1D,EAAM,MAAA,KAAA,GAAQ,uBAAuB,OAAO,CAAA,CAAA;AAE5C,EAAM,MAAA,EAAE,WAAY,EAAA,GAAI,aAAc,EAAA,CAAA;AACtC,EAAA,MAAM,EAAE,gBAAA,EAAkB,YAAc,EAAA,kBAAA,KAAuB,eAAgB,E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;AAGM,MAAA,UAAA,GAAa,WAA4D,oBAAoB,EAAA;AACnG,UAAA,CAAW,WAAc,GAAA,YAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"SelectDrop.js","sources":["src/SelectDrop.tsx"],"sourcesContent":["import { type ReactElement, useId, ComponentProps, useEffect, forwardRef, ForwardedRef } from 'react';\nimport classnames from 'classnames';\n\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { ActionBarProps, ActionBarDefaultPropsContext } from '@hh.ru/magritte-ui-action-bar';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { Drop } from '@hh.ru/magritte-ui-drop';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { SelectPickerProvider, useSelectPicker } from '@hh.ru/magritte-ui-select/SelectPickerContext';\nimport { SelectError } from '@hh.ru/magritte-ui-select/internal/SelectError';\nimport { useSelectElementsValue, useRegisterSelectElementsSlot } from '@hh.ru/magritte-ui-select/internal/slots';\nimport { useEventCallback, isElementInsideActivatorOrPicker } from '@hh.ru/magritte-ui-select/internal/utils';\nimport { SELECT_DROP_ACTION_BAR_DEFAULTS } from '@hh.ru/magritte-ui-select/pickerDefaults';\nimport { usePickerRef } from '@hh.ru/magritte-ui-select/usePickerRef';\nimport { useSelectConfig } from '@hh.ru/magritte-ui-select/useSelectConfig';\nimport { useSelectContentState } from '@hh.ru/magritte-ui-select/useSelectContentState';\nimport { useSelectHint } from '@hh.ru/magritte-ui-select/useSelectHint';\nimport { useVisibility } from '@hh.ru/magritte-ui-select/useVisibility';\n\nimport styles from './select-drop.less';\n\ntype SelectDropProps = Omit<\n ComponentProps<typeof Drop>,\n | 'id'\n | 'placement'\n | 'autoFocusWhenOpened'\n | 'role'\n | 'keyboardNavigationMode'\n | 'closeByClickOutside'\n | 'padding'\n | 'forcePlacement'\n | 'visible'\n | 'activatorRef'\n | 'returnFocusOnClose'\n | 'ref'\n>;\n\ninterface SelectDropHelper {\n /**\n * По умолчанию, drop закрывается, если список опций пуст\n * Свойство позволяет держать drop открытым, даже если опций нет\n * Подходит для реализации поиска внутри drop\n */\n forceDropVisibleWithEmptyOptions?: boolean;\n /** Максимальная высота выпадающего блока для desktop */\n maxHeight?: number;\n}\n\nconst DROP_PLACEMENT = ['bottom-left', 'top-left', 'bottom-right', 'top-right'];\n\nconst ACTION_BAR_DEFAULT_PROPS: Partial<ActionBarProps> = SELECT_DROP_ACTION_BAR_DEFAULTS;\n\nconst SelectDropComponentRenderFunc = (\n {\n onClose: onCloseExternal,\n widthEqualToActivator = true,\n forceDropVisibleWithEmptyOptions,\n maxHeight = 460,\n width,\n children,\n footer,\n ...props\n }: SelectDropProps & SelectDropHelper,\n ref: ForwardedRef<HTMLElement>\n): ReactElement | null => {\n const pickerId = useId();\n const { isMobile } = useBreakpoint();\n const pickerRef = usePickerRef(!isMobile);\n const dropRefCallback = useMultipleRefs(pickerRef, ref);\n\n const onClose = useEventCallback(onCloseExternal);\n\n const activatorRef = useSelectElementsValue('activatorRef');\n const plain = useSelectElementsValue('plain');\n\n const { showOptions } = useVisibility();\n const { hasProviderError, hasEmptyHint, hasEmptySearchHint } = useSelectConfig();\n const { emptyHint, emptySearchHint } = useSelectHint();\n\n const contentState = useSelectContentState();\n\n useRegisterSelectElementsSlot('pickerId', !isMobile ? pickerId : undefined);\n\n const { discardChanges, onCloseRequestWithUnsavedChanges } = useSelectPicker();\n\n // не переоткрываем select при клике на тригер\n useEffect(() => {\n if (!showOptions || isMobile || !activatorRef) {\n return void 0;\n }\n const controller = new AbortController();\n const closeOnOutsideInteraction = (event: Event) => {\n if (isElementInsideActivatorOrPicker(activatorRef, pickerRef, event.target as Node)) {\n return;\n }\n controller.abort();\n discardChanges();\n onCloseRequestWithUnsavedChanges();\n };\n document.addEventListener('focus', closeOnOutsideInteraction, { capture: true, signal: controller.signal });\n document.addEventListener('click', closeOnOutsideInteraction, { capture: true, signal: controller.signal });\n return () => controller.abort();\n }, [isMobile, activatorRef, showOptions, discardChanges, onCloseRequestWithUnsavedChanges, pickerRef]);\n\n if (!activatorRef) {\n return null;\n }\n\n return (\n <Drop\n {...props}\n ref={dropRefCallback}\n width={width}\n autoFocusWhenOpened={false}\n visible={\n /**\n * пикер в виде дропа хотим показывать, если был включен showOptions и при этом\n * - есть что показать: опции, лоадер, ошибка провайдера или подсказка\n * - либо потребитель держит дроп открытым сам\n * внешняя ошибка (external-error) в дроп не попадает — её показывает тригер\n */\n showOptions &&\n (contentState === 'options' ||\n (contentState === 'empty-hint' && hasEmptyHint) ||\n (contentState === 'empty-search-hint' && hasEmptySearchHint) ||\n (contentState === 'provider-error' && hasProviderError) ||\n contentState === 'loading' ||\n forceDropVisibleWithEmptyOptions)\n }\n placement={DROP_PLACEMENT}\n activatorRef={activatorRef}\n padding={plain ? 24 : 12}\n keyboardNavigationMode=\"list\"\n onClose={() => {\n discardChanges();\n onCloseRequestWithUnsavedChanges();\n onClose?.();\n }}\n closeByClickOutside={false}\n widthEqualToActivator={widthEqualToActivator || (contentState === 'loading' && width === undefined)}\n forcePlacement\n returnFocusOnClose={false}\n footer={\n footer ? (\n <ActionBarDefaultPropsContext props={ACTION_BAR_DEFAULT_PROPS}>\n {footer}\n </ActionBarDefaultPropsContext>\n ) : undefined\n }\n id={pickerId}\n role=\"dialog\"\n >\n <div className={styles.selectDropContainerWrapper} style={{ maxHeight: `${maxHeight}px` }}>\n <div\n className={classnames(\n styles.selectDropContainer,\n { [styles.selectDropContainerPlain]: plain },\n { [styles.selectDropContainerWithFooter]: Boolean(footer) }\n )}\n >\n {contentState === 'loading' && (\n <div className={styles.selectDropLoading}>\n <Loader size={24} />\n </div>\n )}\n {contentState === 'provider-error' && <SelectError />}\n {contentState === 'empty-hint' && emptyHint}\n {contentState === 'empty-search-hint' && emptySearchHint}\n {(contentState === 'options' ||\n contentState === 'pending' ||\n (contentState === 'empty-hint' && !emptyHint) ||\n (contentState === 'empty-search-hint' && !emptySearchHint)) &&\n children}\n </div>\n </div>\n </Drop>\n );\n};\n\nconst SelectDropComponent = forwardRef<HTMLElement, SelectDropProps & SelectDropHelper>(SelectDropComponentRenderFunc);\nSelectDropComponent.displayName = 'SelectDropComponent';\n\nconst SelectDropRenderFunc = (\n { children, ...props }: SelectDropProps & SelectDropHelper,\n ref: ForwardedRef<HTMLElement>\n): ReactElement => {\n return (\n <SelectPickerProvider>\n <SelectDropComponent {...props} ref={ref}>\n {children}\n </SelectDropComponent>\n </SelectPickerProvider>\n );\n};\n\n/** Пикер Select в виде Drop */\nconst SelectDrop = forwardRef<HTMLElement, SelectDropProps & SelectDropHelper>(SelectDropRenderFunc);\nSelectDrop.displayName = 'SelectDrop';\n\nexport { SelectDrop };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,cAAiB,GAAA,CAAC,aAAe,EAAA,UAAA,EAAY,gBAAgB,WAAW,CAAA,CAAA;AAE9E,MAAM,wBAAoD,GAAA,+BAAA,CAAA;AAE1D,MAAM,gCAAgC,CAClC;AAAA,EACI,OAAS,EAAA,eAAA;AAAA,EACT,qBAAwB,GAAA,IAAA;AAAA,EACxB,gCAAA;AAAA,EACA,SAAY,GAAA,GAAA;AAAA,EACZ,KAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAG,KAAA;AACP,CAAA,EACA,GACsB,KAAA;AACtB,EAAA,MAAM,WAAW,KAAM,EAAA,CAAA;AACvB,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,aAAc,EAAA,CAAA;AACnC,EAAM,MAAA,SAAA,GAAY,YAAa,CAAA,CAAC,QAAQ,CAAA,CAAA;AACxC,EAAM,MAAA,eAAA,GAAkB,eAAgB,CAAA,SAAA,EAAW,GAAG,CAAA,CAAA;AAEtD,EAAM,MAAA,OAAA,GAAU,iBAAiB,eAAe,CAAA,CAAA;AAEhD,EAAM,MAAA,YAAA,GAAe,uBAAuB,cAAc,CAAA,CAAA;AAC1D,EAAM,MAAA,KAAA,GAA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e,KAAA;AACf,EACI,uBAAA,GAAA,CAAC,wBACG,QAAC,kBAAA,GAAA,CAAA,mBAAA,EAAA,EAAqB,GAAG,KAAO,EAAA,GAAA,EAC3B,UACL,CACJ,EAAA,CAAA,CAAA;AAER,CAAA,CAAA;AAGM,MAAA,UAAA,GAAa,WAA4D,oBAAoB,EAAA;AACnG,UAAA,CAAW,WAAc,GAAA,YAAA;;;;"}
|
package/SelectEmptyHint.js
CHANGED
|
@@ -6,7 +6,7 @@ import { VSpacing } from '@hh.ru/magritte-ui-spacing';
|
|
|
6
6
|
import { Title } from '@hh.ru/magritte-ui-title';
|
|
7
7
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
8
8
|
|
|
9
|
-
var styles = {"select-empty-hint":"magritte-select-empty-hint___B39XJ_13-0-
|
|
9
|
+
var styles = {"select-empty-hint":"magritte-select-empty-hint___B39XJ_13-0-31","selectEmptyHint":"magritte-select-empty-hint___B39XJ_13-0-31","icon":"magritte-icon___F0GQx_13-0-31","icon-empty":"magritte-icon-empty___sAFRT_13-0-31","iconEmpty":"magritte-icon-empty___sAFRT_13-0-31","icon-empty-search":"magritte-icon-empty-search___O0pus_13-0-31","iconEmptySearch":"magritte-icon-empty-search___O0pus_13-0-31"};
|
|
10
10
|
|
|
11
11
|
const SelectEmptyHint = (props) => {
|
|
12
12
|
const { type = "init", title, children } = props;
|
package/SelectOptions.js
CHANGED
|
@@ -30,7 +30,7 @@ import '@hh.ru/magritte-common-data-provider';
|
|
|
30
30
|
import './internal/useDataProvider.js';
|
|
31
31
|
import './internal/SearchStateContext.js';
|
|
32
32
|
|
|
33
|
-
var styles = {"options":"magritte-options___E0JN-_13-0-
|
|
33
|
+
var styles = {"options":"magritte-options___E0JN-_13-0-31","options_plain":"magritte-options_plain___-ihU5_13-0-31","optionsPlain":"magritte-options_plain___-ihU5_13-0-31","options_desktop":"magritte-options_desktop___gz7kx_13-0-31","optionsDesktop":"magritte-options_desktop___gz7kx_13-0-31","options_desktop-plain":"magritte-options_desktop-plain___L0WIC_13-0-31","optionsDesktopPlain":"magritte-options_desktop-plain___L0WIC_13-0-31"};
|
|
34
34
|
|
|
35
35
|
const SelectOptions = ({
|
|
36
36
|
type = "checkbox",
|
package/SelectSearchTrigger.js
CHANGED
|
@@ -28,7 +28,7 @@ import './internal/SelectDataProvider.js';
|
|
|
28
28
|
import '@hh.ru/magritte-common-data-provider';
|
|
29
29
|
import './internal/useDataProvider.js';
|
|
30
30
|
|
|
31
|
-
var styles = {"anchor":"magritte-anchor___0KOBD_13-0-
|
|
31
|
+
var styles = {"anchor":"magritte-anchor___0KOBD_13-0-31","anchor-stretched":"magritte-anchor-stretched___h7y6m_13-0-31","anchorStretched":"magritte-anchor-stretched___h7y6m_13-0-31","default-view":"magritte-default-view___3ptpo_13-0-31","defaultView":"magritte-default-view___3ptpo_13-0-31","input-view":"magritte-input-view___ZeEKh_13-0-31","inputView":"magritte-input-view___ZeEKh_13-0-31","hidden-view":"magritte-hidden-view___stvzX_13-0-31","hiddenView":"magritte-hidden-view___stvzX_13-0-31"};
|
|
32
32
|
|
|
33
33
|
const SelectSearchTriggerComponent = ({
|
|
34
34
|
"aria-label": ariaLabel,
|
package/UncontrolledSelect.js
CHANGED
|
@@ -31,6 +31,7 @@ import 'classnames';
|
|
|
31
31
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
32
32
|
import '@hh.ru/magritte-ui-action-bar';
|
|
33
33
|
import '@hh.ru/magritte-ui-bottom-sheet';
|
|
34
|
+
import '@hh.ru/magritte-ui-bottom-sheet/actionBarDefaults';
|
|
34
35
|
import '@hh.ru/magritte-ui-loader';
|
|
35
36
|
import './internal/SelectError.js';
|
|
36
37
|
import './internal/SelectReloadButton.js';
|
|
@@ -39,6 +40,7 @@ import './useSelectError.js';
|
|
|
39
40
|
import '@hh.ru/magritte-ui-spacing';
|
|
40
41
|
import '@hh.ru/magritte-ui-title';
|
|
41
42
|
import '@hh.ru/magritte-ui-typography';
|
|
43
|
+
import './pickerDefaults.js';
|
|
42
44
|
import './usePickerRef.js';
|
|
43
45
|
import './useSelectContentState.js';
|
|
44
46
|
import './useSelectHint.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UncontrolledSelect.js","sources":["src/UncontrolledSelect.tsx"],"sourcesContent":["import { type ReactElement, useState } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { Select } from '@hh.ru/magritte-ui-select/Select';\nimport type { UncontrolledSelectProps } from '@hh.ru/magritte-ui-select/types';\n\nconst UncontrolledSelect = <MultipleType extends boolean, DataType extends StaticDataFetcherItem>({\n name,\n onChange,\n children,\n ...props\n}: UncontrolledSelectProps<MultipleType, DataType>): ReactElement => {\n const [controlledValue, setValue] = useState(props.value);\n return (\n <>\n <Select\n {...props}\n onChange={(values) => {\n setValue(values);\n onChange?.(values);\n }}\n value={controlledValue}\n name={name}\n >\n {children}\n </Select>\n {Array.isArray(controlledValue) ? (\n controlledValue.map((value) => (\n <input\n type=\"hidden\"\n name={name}\n value={value.value}\n key={value.value}\n onChange={() => null}\n data-qa=\"uncontrolled-select-hidden-input\"\n />\n ))\n ) : (\n <input\n type=\"hidden\"\n name={name}\n // без фолбэка инпут стартует неконтролируемым и React ругается на первый выбор значения\n value={controlledValue?.value ?? ''}\n onChange={() => null}\n data-qa=\"uncontrolled-select-hidden-input\"\n />\n )}\n </>\n );\n};\n\nUncontrolledSelect.displayName = 'UncontrolledSelect';\n\nexport { UncontrolledSelect };\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UncontrolledSelect.js","sources":["src/UncontrolledSelect.tsx"],"sourcesContent":["import { type ReactElement, useState } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { Select } from '@hh.ru/magritte-ui-select/Select';\nimport type { UncontrolledSelectProps } from '@hh.ru/magritte-ui-select/types';\n\nconst UncontrolledSelect = <MultipleType extends boolean, DataType extends StaticDataFetcherItem>({\n name,\n onChange,\n children,\n ...props\n}: UncontrolledSelectProps<MultipleType, DataType>): ReactElement => {\n const [controlledValue, setValue] = useState(props.value);\n return (\n <>\n <Select\n {...props}\n onChange={(values) => {\n setValue(values);\n onChange?.(values);\n }}\n value={controlledValue}\n name={name}\n >\n {children}\n </Select>\n {Array.isArray(controlledValue) ? (\n controlledValue.map((value) => (\n <input\n type=\"hidden\"\n name={name}\n value={value.value}\n key={value.value}\n onChange={() => null}\n data-qa=\"uncontrolled-select-hidden-input\"\n />\n ))\n ) : (\n <input\n type=\"hidden\"\n name={name}\n // без фолбэка инпут стартует неконтролируемым и React ругается на первый выбор значения\n value={controlledValue?.value ?? ''}\n onChange={() => null}\n data-qa=\"uncontrolled-select-hidden-input\"\n />\n )}\n </>\n );\n};\n\nUncontrolledSelect.displayName = 'UncontrolledSelect';\n\nexport { UncontrolledSelect };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,qBAAqB,CAAuE;AAAA,EAC9F,IAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG,KAAA;AACP,CAAqE,KAAA;AACjE,EAAA,MAAM,CAAC,eAAiB,EAAA,QAAQ,CAAI,GAAA,QAAA,CAAS,MAAM,KAAK,CAAA,CAAA;AACxD,EAAA,uBAEQ,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACI,GAAG,KAAA;AAAA,QACJ,QAAA,EAAU,CAAC,MAAW,KAAA;AAClB,UAAA,QAAA,CAAS,MAAM,CAAA,CAAA;AACf,UAAA,QAAA,GAAW,MAAM,CAAA,CAAA;AAAA,SACrB;AAAA,QACA,KAAO,EAAA,eAAA;AAAA,QACP,IAAA;AAAA,QAEC,QAAA;AAAA,OAAA;AAAA,KACL;AAAA,IACC,MAAM,OAAQ,CAAA,eAAe,IAC1B,eAAgB,CAAA,GAAA,CAAI,CAAC,KACjB,qBAAA,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACG,IAAK,EAAA,QAAA;AAAA,QACL,IAAA;AAAA,QACA,OAAO,KAAM,CAAA,KAAA;AAAA,QAEb,UAAU,MAAM,IAAA;AAAA,QAChB,SAAQ,EAAA,kCAAA;AAAA,OAAA;AAAA,MAFH,KAAM,CAAA,KAAA;AAAA,KAIlB,CAED,mBAAA,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACG,IAAK,EAAA,QAAA;AAAA,QACL,IAAA;AAAA,QAEA,KAAA,EAAO,iBAAiB,KAAS,IAAA,EAAA;AAAA,QACjC,UAAU,MAAM,IAAA;AAAA,QAChB,SAAQ,EAAA,kCAAA;AAAA,OAAA;AAAA,KACZ;AAAA,GAER,EAAA,CAAA,CAAA;AAER,EAAA;AAEA,kBAAA,CAAmB,WAAc,GAAA,oBAAA;;;;"}
|
package/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.magritte-error-container___ICGpQ_13-0-
|
|
1
|
+
.magritte-error-container___ICGpQ_13-0-31{
|
|
2
2
|
display:flex;
|
|
3
3
|
flex-direction:column;
|
|
4
4
|
align-items:center;
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
text-align:center;
|
|
8
8
|
}
|
|
9
9
|
@media (min-width: 1020px){
|
|
10
|
-
body.magritte-old-layout .magritte-error-container___ICGpQ_13-0-
|
|
10
|
+
body.magritte-old-layout .magritte-error-container___ICGpQ_13-0-31{
|
|
11
11
|
min-height:320px;
|
|
12
12
|
height:auto;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
@media (min-width: 1024px){
|
|
16
|
-
body:not(.magritte-old-layout) .magritte-error-container___ICGpQ_13-0-
|
|
16
|
+
body:not(.magritte-old-layout) .magritte-error-container___ICGpQ_13-0-31{
|
|
17
17
|
min-height:320px;
|
|
18
18
|
height:auto;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
.magritte-content-placeholder___rOCxd_13-0-
|
|
22
|
+
.magritte-content-placeholder___rOCxd_13-0-31{
|
|
23
23
|
display:flex;
|
|
24
24
|
flex-direction:column;
|
|
25
25
|
align-items:center;
|
|
@@ -27,29 +27,29 @@
|
|
|
27
27
|
height:100%;
|
|
28
28
|
text-align:center;
|
|
29
29
|
}
|
|
30
|
-
.magritte-select-bottom-sheet_without-header___KOKVh_13-0-
|
|
30
|
+
.magritte-select-bottom-sheet_without-header___KOKVh_13-0-31{
|
|
31
31
|
padding-top:16px;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
.magritte-select-drop-container-wrapper___OHM0q_13-0-
|
|
34
|
+
.magritte-select-drop-container-wrapper___OHM0q_13-0-31{
|
|
35
35
|
display:flex;
|
|
36
36
|
flex-direction:column;
|
|
37
37
|
}
|
|
38
|
-
.magritte-select-drop-container___hee1p_13-0-
|
|
38
|
+
.magritte-select-drop-container___hee1p_13-0-31{
|
|
39
39
|
display:flex;
|
|
40
40
|
flex-direction:column;
|
|
41
41
|
padding:12px;
|
|
42
42
|
margin:calc(-1 * 12px);
|
|
43
43
|
}
|
|
44
|
-
.magritte-select-drop-container_plain___766zl_13-0-
|
|
44
|
+
.magritte-select-drop-container_plain___766zl_13-0-31{
|
|
45
45
|
padding:24px;
|
|
46
46
|
margin:calc(-1 * 24px);
|
|
47
47
|
}
|
|
48
|
-
.magritte-select-drop-container_with-footer___6wp-L_13-0-
|
|
48
|
+
.magritte-select-drop-container_with-footer___6wp-L_13-0-31{
|
|
49
49
|
margin-bottom:0;
|
|
50
50
|
padding-bottom:0;
|
|
51
51
|
}
|
|
52
|
-
.magritte-select-drop-loading___KsNuw_13-0-
|
|
52
|
+
.magritte-select-drop-loading___KsNuw_13-0-31{
|
|
53
53
|
display:flex;
|
|
54
54
|
align-items:center;
|
|
55
55
|
height:150px;
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
--magritte-color-background-accent-secondary-v26-0-2:#F1F4F7;
|
|
75
75
|
--magritte-color-icon-accent-v26-0-2:#7195AF;
|
|
76
76
|
}
|
|
77
|
-
.magritte-select-empty-hint___B39XJ_13-0-
|
|
77
|
+
.magritte-select-empty-hint___B39XJ_13-0-31{
|
|
78
78
|
display:flex;
|
|
79
79
|
flex-direction:column;
|
|
80
80
|
align-items:center;
|
|
@@ -83,18 +83,18 @@
|
|
|
83
83
|
text-align:center;
|
|
84
84
|
}
|
|
85
85
|
@media (min-width: 1020px){
|
|
86
|
-
body.magritte-old-layout .magritte-select-empty-hint___B39XJ_13-0-
|
|
86
|
+
body.magritte-old-layout .magritte-select-empty-hint___B39XJ_13-0-31{
|
|
87
87
|
min-height:320px;
|
|
88
88
|
height:auto;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
@media (min-width: 1024px){
|
|
92
|
-
body:not(.magritte-old-layout) .magritte-select-empty-hint___B39XJ_13-0-
|
|
92
|
+
body:not(.magritte-old-layout) .magritte-select-empty-hint___B39XJ_13-0-31{
|
|
93
93
|
min-height:320px;
|
|
94
94
|
height:auto;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
.magritte-icon___F0GQx_13-0-
|
|
97
|
+
.magritte-icon___F0GQx_13-0-31{
|
|
98
98
|
display:flex;
|
|
99
99
|
align-items:center;
|
|
100
100
|
justify-content:center;
|
|
@@ -102,11 +102,11 @@
|
|
|
102
102
|
height:48px;
|
|
103
103
|
border-radius:50%;
|
|
104
104
|
}
|
|
105
|
-
.magritte-icon-empty___sAFRT_13-0-
|
|
105
|
+
.magritte-icon-empty___sAFRT_13-0-31{
|
|
106
106
|
background-color:var(--magritte-color-background-accent-secondary-v26-0-2);
|
|
107
107
|
--magritte-ui-icon-color-override:var(--magritte-color-icon-accent-v26-0-2);
|
|
108
108
|
}
|
|
109
|
-
.magritte-icon-empty-search___O0pus_13-0-
|
|
109
|
+
.magritte-icon-empty-search___O0pus_13-0-31{
|
|
110
110
|
background-color:var(--magritte-color-background-secondary-v26-0-2);
|
|
111
111
|
--magritte-ui-icon-color-override:var(--magritte-color-icon-tertiary-v26-0-2);
|
|
112
112
|
}
|
|
@@ -114,74 +114,74 @@
|
|
|
114
114
|
:root{
|
|
115
115
|
--magritte-color-component-input-stroke-state-accent-focused-accessible-v26-0-2:#0070ff7a;
|
|
116
116
|
}
|
|
117
|
-
.magritte-select-option-plain___u9kSx_13-0-
|
|
117
|
+
.magritte-select-option-plain___u9kSx_13-0-31{
|
|
118
118
|
border-radius:8px;
|
|
119
119
|
}
|
|
120
|
-
.magritte-select-option-plain___u9kSx_13-0-
|
|
120
|
+
.magritte-select-option-plain___u9kSx_13-0-31.focus-visible{
|
|
121
121
|
outline:var(--magritte-color-component-input-stroke-state-accent-focused-accessible-v26-0-2) solid 4px;
|
|
122
122
|
}
|
|
123
123
|
@media (min-width: 1020px){
|
|
124
|
-
body.magritte-old-layout .magritte-select-option-plain___u9kSx_13-0-
|
|
124
|
+
body.magritte-old-layout .magritte-select-option-plain___u9kSx_13-0-31:hover{
|
|
125
125
|
cursor:default;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
@media (min-width: 1024px){
|
|
129
|
-
body:not(.magritte-old-layout) .magritte-select-option-plain___u9kSx_13-0-
|
|
129
|
+
body:not(.magritte-old-layout) .magritte-select-option-plain___u9kSx_13-0-31:hover{
|
|
130
130
|
cursor:default;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
@media (min-width: 1020px){
|
|
134
|
-
body.magritte-old-layout .magritte-select-option-plain_active___ynHQP_13-0-
|
|
134
|
+
body.magritte-old-layout .magritte-select-option-plain_active___ynHQP_13-0-31:hover{
|
|
135
135
|
cursor:pointer;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
@media (min-width: 1024px){
|
|
139
|
-
body:not(.magritte-old-layout) .magritte-select-option-plain_active___ynHQP_13-0-
|
|
139
|
+
body:not(.magritte-old-layout) .magritte-select-option-plain_active___ynHQP_13-0-31:hover{
|
|
140
140
|
cursor:pointer;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
.magritte-select-label-option___wyUhk_13-0-
|
|
143
|
+
.magritte-select-label-option___wyUhk_13-0-31{
|
|
144
144
|
display:flex;
|
|
145
145
|
justify-content:center;
|
|
146
146
|
}
|
|
147
|
-
.magritte-select-delimiter___SsBtb_13-0-
|
|
147
|
+
.magritte-select-delimiter___SsBtb_13-0-31{
|
|
148
148
|
padding-left:16px;
|
|
149
149
|
padding-top:12px;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
.magritte-options___E0JN-_13-0-
|
|
152
|
+
.magritte-options___E0JN-_13-0-31{
|
|
153
153
|
display:flex;
|
|
154
154
|
flex-direction:column;
|
|
155
155
|
padding:0 16px;
|
|
156
156
|
padding-bottom:16px;
|
|
157
157
|
gap:12px;
|
|
158
158
|
}
|
|
159
|
-
.magritte-options_plain___-ihU5_13-0-
|
|
159
|
+
.magritte-options_plain___-ihU5_13-0-31{
|
|
160
160
|
gap:0;
|
|
161
161
|
}
|
|
162
|
-
.magritte-options_desktop___gz7kx_13-0-
|
|
162
|
+
.magritte-options_desktop___gz7kx_13-0-31{
|
|
163
163
|
gap:8px;
|
|
164
164
|
padding:0;
|
|
165
165
|
}
|
|
166
|
-
.magritte-options_desktop-plain___L0WIC_13-0-
|
|
166
|
+
.magritte-options_desktop-plain___L0WIC_13-0-31{
|
|
167
167
|
gap:16px;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
.magritte-select-layout___3THUn_13-0-
|
|
170
|
+
.magritte-select-layout___3THUn_13-0-31{
|
|
171
171
|
display:contents;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
.magritte-anchor___0KOBD_13-0-
|
|
174
|
+
.magritte-anchor___0KOBD_13-0-31{
|
|
175
175
|
position:relative;
|
|
176
176
|
width:fit-content;
|
|
177
177
|
}
|
|
178
|
-
.magritte-anchor-stretched___h7y6m_13-0-
|
|
178
|
+
.magritte-anchor-stretched___h7y6m_13-0-31{
|
|
179
179
|
width:100%;
|
|
180
180
|
}
|
|
181
|
-
.magritte-default-view___3ptpo_13-0-
|
|
181
|
+
.magritte-default-view___3ptpo_13-0-31{
|
|
182
182
|
min-width:0;
|
|
183
183
|
}
|
|
184
|
-
.magritte-input-view___ZeEKh_13-0-
|
|
184
|
+
.magritte-input-view___ZeEKh_13-0-31{
|
|
185
185
|
position:absolute;
|
|
186
186
|
top:0;
|
|
187
187
|
left:0;
|
|
@@ -189,6 +189,6 @@
|
|
|
189
189
|
display:flex;
|
|
190
190
|
min-width:0;
|
|
191
191
|
}
|
|
192
|
-
.magritte-hidden-view___stvzX_13-0-
|
|
192
|
+
.magritte-hidden-view___stvzX_13-0-31{
|
|
193
193
|
visibility:hidden;
|
|
194
194
|
}
|
package/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import 'classnames';
|
|
|
33
33
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
34
34
|
import '@hh.ru/magritte-ui-action-bar';
|
|
35
35
|
import '@hh.ru/magritte-ui-bottom-sheet';
|
|
36
|
+
import '@hh.ru/magritte-ui-bottom-sheet/actionBarDefaults';
|
|
36
37
|
import '@hh.ru/magritte-ui-loader';
|
|
37
38
|
import './internal/SelectError.js';
|
|
38
39
|
import './internal/SelectReloadButton.js';
|
|
@@ -40,6 +41,7 @@ import '@hh.ru/magritte-ui-button';
|
|
|
40
41
|
import '@hh.ru/magritte-ui-spacing';
|
|
41
42
|
import '@hh.ru/magritte-ui-title';
|
|
42
43
|
import '@hh.ru/magritte-ui-typography';
|
|
44
|
+
import './pickerDefaults.js';
|
|
43
45
|
import './SelectBottomSheetHeader.js';
|
|
44
46
|
import '@hh.ru/magritte-ui-nav-bar';
|
|
45
47
|
import './SelectPickerCloseIcon.js';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -10,7 +10,7 @@ import { useVisibility } from '../useVisibility.js';
|
|
|
10
10
|
import '@hh.ru/magritte-internal-slot-registry';
|
|
11
11
|
import './VisibilityContext.js';
|
|
12
12
|
|
|
13
|
-
var styles = {"select-layout":"magritte-select-layout___3THUn_13-0-
|
|
13
|
+
var styles = {"select-layout":"magritte-select-layout___3THUn_13-0-31","selectLayout":"magritte-select-layout___3THUn_13-0-31"};
|
|
14
14
|
|
|
15
15
|
const CLOSED_BY_USER_KEYS = [keyboardKeys.Escape, keyboardKeys.Enter, keyboardKeys.Space];
|
|
16
16
|
const FocusWithinContext = createContext(false);
|
package/internal/Option.js
CHANGED
|
@@ -11,7 +11,7 @@ import { OptionControl } from './OptionControl.js';
|
|
|
11
11
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
12
12
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
13
13
|
|
|
14
|
-
var styles = {"select-option-plain":"magritte-select-option-plain___u9kSx_13-0-
|
|
14
|
+
var styles = {"select-option-plain":"magritte-select-option-plain___u9kSx_13-0-31","selectOptionPlain":"magritte-select-option-plain___u9kSx_13-0-31","select-option-plain_active":"magritte-select-option-plain_active___ynHQP_13-0-31","selectOptionPlainActive":"magritte-select-option-plain_active___ynHQP_13-0-31","select-label-option":"magritte-select-label-option___wyUhk_13-0-31","selectLabelOption":"magritte-select-label-option___wyUhk_13-0-31","select-delimiter":"magritte-select-delimiter___SsBtb_13-0-31","selectDelimiter":"magritte-select-delimiter___SsBtb_13-0-31"};
|
|
15
15
|
|
|
16
16
|
const OptionLayoutComponentDefault = ({
|
|
17
17
|
data,
|
package/internal/SelectError.js
CHANGED
|
@@ -20,7 +20,7 @@ import '../useVisibility.js';
|
|
|
20
20
|
import './VisibilityContext.js';
|
|
21
21
|
import './ConfigContext.js';
|
|
22
22
|
|
|
23
|
-
var styles = {"error-container":"magritte-error-container___ICGpQ_13-0-
|
|
23
|
+
var styles = {"error-container":"magritte-error-container___ICGpQ_13-0-31","errorContainer":"magritte-error-container___ICGpQ_13-0-31"};
|
|
24
24
|
|
|
25
25
|
const SelectError = () => {
|
|
26
26
|
const { isMobile } = useBreakpoint();
|
package/legacy/SelectLegacy.js
CHANGED
|
@@ -38,6 +38,7 @@ import 'classnames';
|
|
|
38
38
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
39
39
|
import '@hh.ru/magritte-ui-action-bar';
|
|
40
40
|
import '@hh.ru/magritte-ui-bottom-sheet';
|
|
41
|
+
import '@hh.ru/magritte-ui-bottom-sheet/actionBarDefaults';
|
|
41
42
|
import '@hh.ru/magritte-ui-loader';
|
|
42
43
|
import '../internal/SelectError.js';
|
|
43
44
|
import '../internal/SelectReloadButton.js';
|
|
@@ -45,6 +46,7 @@ import '@hh.ru/magritte-ui-button';
|
|
|
45
46
|
import '../useSelectError.js';
|
|
46
47
|
import '@hh.ru/magritte-ui-title';
|
|
47
48
|
import '@hh.ru/magritte-ui-typography';
|
|
49
|
+
import '../pickerDefaults.js';
|
|
48
50
|
import '../usePickerRef.js';
|
|
49
51
|
import '../useSelectContentState.js';
|
|
50
52
|
import '../useSelectHint.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectLegacy.js","sources":["src/legacy/SelectLegacy.tsx"],"sourcesContent":["import { ReactElement, ReactNode, forwardRef, ForwardedRef, useMemo, useRef } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { Select } from '@hh.ru/magritte-ui-select/Select';\nimport { extractValues, isArraysEquals, useEventCallback } from '@hh.ru/magritte-ui-select/internal/utils';\nimport { BottomSheetHeaderLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/BottomSheetHeaderLegacy';\nimport { ContentBeforeLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/ContentBeforeLegacy';\nimport { FooterLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/FooterLegacy';\nimport { makeLegacyOptionLayout } from '@hh.ru/magritte-ui-select/legacy/internal/OptionLayoutLegacy';\nimport { TriggerLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/TriggerLegacy';\nimport { UnsavedChangesAlertLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/UnsavedChangesAlertLegacy';\nimport type { SelectProps, TriggerExternalProps } from '@hh.ru/magritte-ui-select/legacy/types';\nimport type { SelectUncontrolledTriggerProps } from '@hh.ru/magritte-ui-select/types';\nimport { VSpacing } from '@hh.ru/magritte-ui-spacing';\n\nconst DEFAULT_DATA_QA = 'magritte-select-activator';\nconst DEFAULT_TRIGGER_PROPS = { size: 'medium' } as TriggerExternalProps;\n\nconst SelectLegacyComponent = <MultipleType extends boolean, DataType extends StaticDataFetcherItem>(\n {\n type,\n multiple,\n value,\n maxSelectedOptions,\n loading,\n error,\n searchable,\n bottomSheetHeight = 'full-screen',\n onChange,\n renderTrigger,\n triggerProps = DEFAULT_TRIGGER_PROPS,\n renderMobileItem,\n renderDesktopItem,\n name,\n maxWidth,\n maxHeight = 460,\n renderAlertOnExitWithoutSaving,\n renderButtonsContainer,\n renderHeader,\n headerTitle,\n clearButton,\n applyChangesButton,\n forceDropVisibleWithEmptyOptions,\n plain = false,\n widthEqualToActivator = true,\n renderContentBefore,\n onBlur,\n onFocus,\n onDropOpen,\n onDropClose,\n onBottomSheetClose,\n onBottomSheetOpen,\n onSearchSubmit,\n onApply,\n onClear,\n onSelectOption,\n pickerRef,\n dataProvider,\n emptyOptionsHint,\n emptyOptionsSearchHint,\n onOptionsChange,\n innerErrorTrls,\n optionDataQa,\n dropWidth,\n applyOnClear = true,\n }: SelectProps<MultipleType, DataType>,\n activatorRef: ForwardedRef<HTMLElement>\n): ReactElement => {\n const optionLayoutComponent = useMemo(\n () =>\n renderDesktopItem || renderMobileItem\n ? makeLegacyOptionLayout<DataType>({\n renderDesktopItem,\n renderMobileItem,\n name,\n dataQa: optionDataQa,\n })\n : undefined,\n [renderDesktopItem, renderMobileItem, name, optionDataQa]\n );\n const options = (\n <Select.Options<DataType>\n type={type}\n plain={plain}\n optionLayoutComponent={optionLayoutComponent}\n data-qa={optionDataQa}\n onOptionSelect={onSelectOption ? (values) => onSelectOption([...values]) : undefined}\n />\n );\n\n // aria-атрибуты связи с пикером новый селект считает сам\n const { 'aria-haspopup': _, 'aria-controls': __, ...restTriggerProps } = triggerProps;\n const newTriggerProps = restTriggerProps as SelectUncontrolledTriggerProps;\n const dataQa = triggerProps['data-qa'] ?? DEFAULT_DATA_QA;\n const trigger = renderTrigger ? (\n <TriggerLegacy\n renderTrigger={renderTrigger}\n triggerProps={triggerProps}\n dataQa={dataQa}\n activatorRef={activatorRef}\n searchable={searchable}\n />\n ) : (\n <>\n {searchable ? (\n <Select.SearchTrigger {...newTriggerProps} ref={activatorRef} data-qa={dataQa} />\n ) : (\n <Select.Trigger {...newTriggerProps} ref={activatorRef} data-qa={dataQa} />\n )}\n </>\n );\n\n // старый селект сравнивал применяемое с последним отданным, а не с текущим стором (кот. мог быть обновлен извне)\n // как следствие, клиент опирался на onChange, который эмитился при совпадающих значениях в сторе\n const lastEmittedValuesRef = useRef(value);\n const handleChange = useEventCallback((next: typeof value) => {\n lastEmittedValuesRef.current = next;\n (onChange as ((value: typeof next) => void) | undefined)?.(next);\n });\n\n const onPickerOpen = useEventCallback(() => {\n lastEmittedValuesRef.current = value;\n });\n\n const onChangeWithLastEmittedCheck = useEventCallback((values: readonly DataType[]) => {\n const lastEmittedValues = Array.isArray(lastEmittedValuesRef.current)\n ? lastEmittedValuesRef.current\n : ([lastEmittedValuesRef.current] as DataType[]);\n if (isArraysEquals(extractValues<DataType>(values), extractValues(lastEmittedValues.filter(Boolean)))) {\n return;\n }\n handleChange((multiple ? [...values] : values[0]) as typeof value);\n });\n\n const hasFooterContent = (buttons: ReactNode[]) =>\n Boolean(renderButtonsContainer) || (!loading && buttons.some(Boolean));\n\n const renderFooter = (withClearButton: boolean) => (\n <FooterLegacy\n applyChangesButton={applyChangesButton}\n clearButton={clearButton}\n withClearButton={withClearButton}\n applyOnClear={applyOnClear}\n onApply={onApply}\n onChangeWithLastEmittedCheck={onChangeWithLastEmittedCheck}\n onPickerOpen={onPickerOpen}\n onClear={onClear}\n renderButtonsContainer={renderButtonsContainer}\n />\n );\n\n const dropFooter = hasFooterContent([applyChangesButton])\n ? renderFooter(Boolean(renderButtonsContainer))\n : undefined;\n const bottomSheetFooter = hasFooterContent([applyChangesButton, clearButton]) ? renderFooter(true) : undefined;\n\n const content = (\n <>\n {trigger}\n <Select.Drop\n ref={pickerRef}\n footer={dropFooter}\n forceDropVisibleWithEmptyOptions={forceDropVisibleWithEmptyOptions}\n maxWidth={maxWidth}\n width={dropWidth}\n maxHeight={maxHeight}\n widthEqualToActivator={widthEqualToActivator}\n onAppear={onDropOpen}\n onAfterExit={onDropClose}\n >\n {renderContentBefore && (\n <>\n <ContentBeforeLegacy\n renderContentBefore={renderContentBefore}\n applyOnClear={applyOnClear}\n onClear={onClear}\n />\n <VSpacing default={8} />\n </>\n )}\n {options}\n </Select.Drop>\n <Select.BottomSheet\n ref={pickerRef}\n height={searchable || Boolean(error) || loading ? 'full-screen' : bottomSheetHeight}\n header={\n <BottomSheetHeaderLegacy\n headerTitle={headerTitle || triggerProps.label}\n searchable={searchable}\n renderHeader={renderHeader}\n onSearchSubmit={onSearchSubmit}\n />\n }\n footer={bottomSheetFooter}\n onAppear={onBottomSheetOpen}\n onAfterExit={onBottomSheetClose}\n >\n {options}\n {renderAlertOnExitWithoutSaving && (\n <UnsavedChangesAlertLegacy renderAlertOnExitWithoutSaving={renderAlertOnExitWithoutSaving} />\n )}\n </Select.BottomSheet>\n </>\n );\n\n const commonProps = {\n dataProvider,\n name,\n loading,\n error,\n maxSelectedOptions,\n onBlur,\n onFocus,\n onOptionsChange,\n providerError: innerErrorTrls,\n emptyHint: emptyOptionsHint,\n emptySearchHint: emptyOptionsSearchHint,\n };\n\n if (multiple) {\n return (\n <Select<true, DataType>\n {...commonProps}\n multiple\n value={value as DataType[] | undefined}\n onChange={handleChange as (value: DataType[]) => void}\n >\n {content}\n </Select>\n );\n }\n\n return (\n <Select<false, DataType>\n {...commonProps}\n value={value as DataType | undefined}\n onChange={handleChange as (value: DataType) => void}\n >\n {content}\n </Select>\n );\n};\n\n/** @deprecated Компонент SelectLegacy deprecated, используйте Select */\nconst SelectLegacy = forwardRef(SelectLegacyComponent) as (<\n MultipleType extends boolean,\n DataType extends StaticDataFetcherItem,\n>(\n props: SelectProps<MultipleType, DataType> & { ref?: ForwardedRef<HTMLElement> }\n) => ReactElement | null) & { displayName: string };\n\nSelectLegacy.displayName = 'SelectLegacy';\n\nexport { SelectLegacy };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,eAAkB,GAAA,2BAAA,CAAA;AACxB,MAAM,qBAAA,GAAwB,EAAE,IAAA,EAAM,QAAS,EAAA,CAAA;AAE/C,MAAM,wBAAwB,CAC1B;AAAA,EACI,IAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,kBAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAoB,GAAA,aAAA;AAAA,EACpB,QAAA;AAAA,EACA,aAAA;AAAA,EACA,YAAe,GAAA,qBAAA;AAAA,EACf,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAY,GAAA,GAAA;AAAA,EACZ,8BAAA;AAAA,EACA,sBAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,kBAAA;AAAA,EACA,gCAAA;AAAA,EACA,KAAQ,GAAA,KAAA;AAA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AAA;AACV,IACI,uBAAA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACI,GAAG,WAAA;AAAA,QACJ,QAAQ,EAAA,IAAA;AAAA,QACR,KAAA;AAAA,QACA,QAAU,EAAA,YAAA;AAAA,QAET,QAAA,EAAA,OAAA;AAAA,OAAA;AAAA,KACL,CAAA;AAAA,GAER;AAEA,EACI,uBAAA,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACI,GAAG,WAAA;AAAA,MACJ,KAAA;AAAA,MACA,QAAU,EAAA,YAAA;AAAA,MAET,QAAA,EAAA,OAAA;AAAA,KAAA;AAAA,GACL,CAAA;AAER,CAAA,CAAA;AAGM,MAAA,YAAA,GAAe,WAAW,qBAAqB,EAAA;AAOrD,YAAA,CAAa,WAAc,GAAA,cAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"SelectLegacy.js","sources":["src/legacy/SelectLegacy.tsx"],"sourcesContent":["import { ReactElement, ReactNode, forwardRef, ForwardedRef, useMemo, useRef } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { Select } from '@hh.ru/magritte-ui-select/Select';\nimport { extractValues, isArraysEquals, useEventCallback } from '@hh.ru/magritte-ui-select/internal/utils';\nimport { BottomSheetHeaderLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/BottomSheetHeaderLegacy';\nimport { ContentBeforeLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/ContentBeforeLegacy';\nimport { FooterLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/FooterLegacy';\nimport { makeLegacyOptionLayout } from '@hh.ru/magritte-ui-select/legacy/internal/OptionLayoutLegacy';\nimport { TriggerLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/TriggerLegacy';\nimport { UnsavedChangesAlertLegacy } from '@hh.ru/magritte-ui-select/legacy/internal/UnsavedChangesAlertLegacy';\nimport type { SelectProps, TriggerExternalProps } from '@hh.ru/magritte-ui-select/legacy/types';\nimport type { SelectUncontrolledTriggerProps } from '@hh.ru/magritte-ui-select/types';\nimport { VSpacing } from '@hh.ru/magritte-ui-spacing';\n\nconst DEFAULT_DATA_QA = 'magritte-select-activator';\nconst DEFAULT_TRIGGER_PROPS = { size: 'medium' } as TriggerExternalProps;\n\nconst SelectLegacyComponent = <MultipleType extends boolean, DataType extends StaticDataFetcherItem>(\n {\n type,\n multiple,\n value,\n maxSelectedOptions,\n loading,\n error,\n searchable,\n bottomSheetHeight = 'full-screen',\n onChange,\n renderTrigger,\n triggerProps = DEFAULT_TRIGGER_PROPS,\n renderMobileItem,\n renderDesktopItem,\n name,\n maxWidth,\n maxHeight = 460,\n renderAlertOnExitWithoutSaving,\n renderButtonsContainer,\n renderHeader,\n headerTitle,\n clearButton,\n applyChangesButton,\n forceDropVisibleWithEmptyOptions,\n plain = false,\n widthEqualToActivator = true,\n renderContentBefore,\n onBlur,\n onFocus,\n onDropOpen,\n onDropClose,\n onBottomSheetClose,\n onBottomSheetOpen,\n onSearchSubmit,\n onApply,\n onClear,\n onSelectOption,\n pickerRef,\n dataProvider,\n emptyOptionsHint,\n emptyOptionsSearchHint,\n onOptionsChange,\n innerErrorTrls,\n optionDataQa,\n dropWidth,\n applyOnClear = true,\n }: SelectProps<MultipleType, DataType>,\n activatorRef: ForwardedRef<HTMLElement>\n): ReactElement => {\n const optionLayoutComponent = useMemo(\n () =>\n renderDesktopItem || renderMobileItem\n ? makeLegacyOptionLayout<DataType>({\n renderDesktopItem,\n renderMobileItem,\n name,\n dataQa: optionDataQa,\n })\n : undefined,\n [renderDesktopItem, renderMobileItem, name, optionDataQa]\n );\n const options = (\n <Select.Options<DataType>\n type={type}\n plain={plain}\n optionLayoutComponent={optionLayoutComponent}\n data-qa={optionDataQa}\n onOptionSelect={onSelectOption ? (values) => onSelectOption([...values]) : undefined}\n />\n );\n\n // aria-атрибуты связи с пикером новый селект считает сам\n const { 'aria-haspopup': _, 'aria-controls': __, ...restTriggerProps } = triggerProps;\n const newTriggerProps = restTriggerProps as SelectUncontrolledTriggerProps;\n const dataQa = triggerProps['data-qa'] ?? DEFAULT_DATA_QA;\n const trigger = renderTrigger ? (\n <TriggerLegacy\n renderTrigger={renderTrigger}\n triggerProps={triggerProps}\n dataQa={dataQa}\n activatorRef={activatorRef}\n searchable={searchable}\n />\n ) : (\n <>\n {searchable ? (\n <Select.SearchTrigger {...newTriggerProps} ref={activatorRef} data-qa={dataQa} />\n ) : (\n <Select.Trigger {...newTriggerProps} ref={activatorRef} data-qa={dataQa} />\n )}\n </>\n );\n\n // старый селект сравнивал применяемое с последним отданным, а не с текущим стором (кот. мог быть обновлен извне)\n // как следствие, клиент опирался на onChange, который эмитился при совпадающих значениях в сторе\n const lastEmittedValuesRef = useRef(value);\n const handleChange = useEventCallback((next: typeof value) => {\n lastEmittedValuesRef.current = next;\n (onChange as ((value: typeof next) => void) | undefined)?.(next);\n });\n\n const onPickerOpen = useEventCallback(() => {\n lastEmittedValuesRef.current = value;\n });\n\n const onChangeWithLastEmittedCheck = useEventCallback((values: readonly DataType[]) => {\n const lastEmittedValues = Array.isArray(lastEmittedValuesRef.current)\n ? lastEmittedValuesRef.current\n : ([lastEmittedValuesRef.current] as DataType[]);\n if (isArraysEquals(extractValues<DataType>(values), extractValues(lastEmittedValues.filter(Boolean)))) {\n return;\n }\n handleChange((multiple ? [...values] : values[0]) as typeof value);\n });\n\n const hasFooterContent = (buttons: ReactNode[]) =>\n Boolean(renderButtonsContainer) || (!loading && buttons.some(Boolean));\n\n const renderFooter = (withClearButton: boolean) => (\n <FooterLegacy\n applyChangesButton={applyChangesButton}\n clearButton={clearButton}\n withClearButton={withClearButton}\n applyOnClear={applyOnClear}\n onApply={onApply}\n onChangeWithLastEmittedCheck={onChangeWithLastEmittedCheck}\n onPickerOpen={onPickerOpen}\n onClear={onClear}\n renderButtonsContainer={renderButtonsContainer}\n />\n );\n\n const dropFooter = hasFooterContent([applyChangesButton])\n ? renderFooter(Boolean(renderButtonsContainer))\n : undefined;\n const bottomSheetFooter = hasFooterContent([applyChangesButton, clearButton]) ? renderFooter(true) : undefined;\n\n const content = (\n <>\n {trigger}\n <Select.Drop\n ref={pickerRef}\n footer={dropFooter}\n forceDropVisibleWithEmptyOptions={forceDropVisibleWithEmptyOptions}\n maxWidth={maxWidth}\n width={dropWidth}\n maxHeight={maxHeight}\n widthEqualToActivator={widthEqualToActivator}\n onAppear={onDropOpen}\n onAfterExit={onDropClose}\n >\n {renderContentBefore && (\n <>\n <ContentBeforeLegacy\n renderContentBefore={renderContentBefore}\n applyOnClear={applyOnClear}\n onClear={onClear}\n />\n <VSpacing default={8} />\n </>\n )}\n {options}\n </Select.Drop>\n <Select.BottomSheet\n ref={pickerRef}\n height={searchable || Boolean(error) || loading ? 'full-screen' : bottomSheetHeight}\n header={\n <BottomSheetHeaderLegacy\n headerTitle={headerTitle || triggerProps.label}\n searchable={searchable}\n renderHeader={renderHeader}\n onSearchSubmit={onSearchSubmit}\n />\n }\n footer={bottomSheetFooter}\n onAppear={onBottomSheetOpen}\n onAfterExit={onBottomSheetClose}\n >\n {options}\n {renderAlertOnExitWithoutSaving && (\n <UnsavedChangesAlertLegacy renderAlertOnExitWithoutSaving={renderAlertOnExitWithoutSaving} />\n )}\n </Select.BottomSheet>\n </>\n );\n\n const commonProps = {\n dataProvider,\n name,\n loading,\n error,\n maxSelectedOptions,\n onBlur,\n onFocus,\n onOptionsChange,\n providerError: innerErrorTrls,\n emptyHint: emptyOptionsHint,\n emptySearchHint: emptyOptionsSearchHint,\n };\n\n if (multiple) {\n return (\n <Select<true, DataType>\n {...commonProps}\n multiple\n value={value as DataType[] | undefined}\n onChange={handleChange as (value: DataType[]) => void}\n >\n {content}\n </Select>\n );\n }\n\n return (\n <Select<false, DataType>\n {...commonProps}\n value={value as DataType | undefined}\n onChange={handleChange as (value: DataType) => void}\n >\n {content}\n </Select>\n );\n};\n\n/** @deprecated Компонент SelectLegacy deprecated, используйте Select */\nconst SelectLegacy = forwardRef(SelectLegacyComponent) as (<\n MultipleType extends boolean,\n DataType extends StaticDataFetcherItem,\n>(\n props: SelectProps<MultipleType, DataType> & { ref?: ForwardedRef<HTMLElement> }\n) => ReactElement | null) & { displayName: string };\n\nSelectLegacy.displayName = 'SelectLegacy';\n\nexport { SelectLegacy };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,eAAkB,GAAA,2BAAA,CAAA;AACxB,MAAM,qBAAA,GAAwB,EAAE,IAAA,EAAM,QAAS,EAAA,CAAA;AAE/C,MAAM,wBAAwB,CAC1B;AAAA,EACI,IAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,kBAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAoB,GAAA,aAAA;AAAA,EACpB,QAAA;AAAA,EACA,aAAA;AAAA,EACA,YAAe,GAAA,qBAAA;AAAA,EACf,gBAAA;AAAA,EACA,iBAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAY,GAAA,GAAA;AAAA,EACZ,8BAAA;AAAA,EACA,sBAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,kBAAA;AAAA,EACA,gCAAA;AAAA,EACA,KAAQ,GAAA,KAAA;AAAA,EACR,qBAAwB,GAAA,IAAA;AAAA,EACxB,mBAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,cAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,cAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA,gBAAA;AAAA,EACA,sBAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;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,MAET,QAAA,EAAA,OAAA;AAAA,KAAA;AAAA,GACL,CAAA;AAER,CAAA,CAAA;AAGM,MAAA,YAAA,GAAe,WAAW,qBAAqB,EAAA;AAOrD,YAAA,CAAa,WAAc,GAAA,cAAA;;;;"}
|
|
@@ -32,6 +32,7 @@ import 'classnames';
|
|
|
32
32
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
33
33
|
import '@hh.ru/magritte-ui-action-bar';
|
|
34
34
|
import '@hh.ru/magritte-ui-bottom-sheet';
|
|
35
|
+
import '@hh.ru/magritte-ui-bottom-sheet/actionBarDefaults';
|
|
35
36
|
import '@hh.ru/magritte-ui-loader';
|
|
36
37
|
import '../internal/SelectError.js';
|
|
37
38
|
import '../internal/SelectReloadButton.js';
|
|
@@ -40,6 +41,7 @@ import '../useSelectError.js';
|
|
|
40
41
|
import '@hh.ru/magritte-ui-spacing';
|
|
41
42
|
import '@hh.ru/magritte-ui-title';
|
|
42
43
|
import '@hh.ru/magritte-ui-typography';
|
|
44
|
+
import '../pickerDefaults.js';
|
|
43
45
|
import '../usePickerRef.js';
|
|
44
46
|
import '../useSelectContentState.js';
|
|
45
47
|
import '../useSelectHint.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UncontrolledSelectLegacy.js","sources":["src/legacy/UncontrolledSelectLegacy.tsx"],"sourcesContent":["import { type ReactElement, useState } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { SelectLegacy } from '@hh.ru/magritte-ui-select/legacy/SelectLegacy';\nimport type { UncontrolledSelectProps } from '@hh.ru/magritte-ui-select/legacy/types';\n\n// function, а не стрелка: для const с присвоенным displayName TS 7 выводит в d.ts function + namespace и теряет JSDoc\n/** @deprecated Компонент UncontrolledSelectLegacy deprecated, используйте UncontrolledSelect */\nfunction UncontrolledSelectLegacy<MultipleType extends boolean, DataType extends StaticDataFetcherItem>({\n name,\n onChange,\n ...props\n}: UncontrolledSelectProps<MultipleType, DataType>): ReactElement {\n const { value } = props;\n const [controlledValue, setValue] = useState(value);\n return (\n <>\n <SelectLegacy\n {...props}\n onChange={(values) => {\n setValue(values);\n onChange?.(values);\n }}\n value={controlledValue}\n name={name}\n />\n {Array.isArray(controlledValue) ? (\n controlledValue.map((value) => (\n <input type=\"hidden\" name={name} value={value.value} key={value.value} onChange={() => null} />\n ))\n ) : (\n <input type=\"hidden\" name={name} value={controlledValue?.value ?? ''} onChange={() => null} />\n )}\n </>\n );\n}\n\nUncontrolledSelectLegacy.displayName = 'UncontrolledSelectLegacy';\n\nexport { UncontrolledSelectLegacy };\n"],"names":["value"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UncontrolledSelectLegacy.js","sources":["src/legacy/UncontrolledSelectLegacy.tsx"],"sourcesContent":["import { type ReactElement, useState } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { SelectLegacy } from '@hh.ru/magritte-ui-select/legacy/SelectLegacy';\nimport type { UncontrolledSelectProps } from '@hh.ru/magritte-ui-select/legacy/types';\n\n// function, а не стрелка: для const с присвоенным displayName TS 7 выводит в d.ts function + namespace и теряет JSDoc\n/** @deprecated Компонент UncontrolledSelectLegacy deprecated, используйте UncontrolledSelect */\nfunction UncontrolledSelectLegacy<MultipleType extends boolean, DataType extends StaticDataFetcherItem>({\n name,\n onChange,\n ...props\n}: UncontrolledSelectProps<MultipleType, DataType>): ReactElement {\n const { value } = props;\n const [controlledValue, setValue] = useState(value);\n return (\n <>\n <SelectLegacy\n {...props}\n onChange={(values) => {\n setValue(values);\n onChange?.(values);\n }}\n value={controlledValue}\n name={name}\n />\n {Array.isArray(controlledValue) ? (\n controlledValue.map((value) => (\n <input type=\"hidden\" name={name} value={value.value} key={value.value} onChange={() => null} />\n ))\n ) : (\n <input type=\"hidden\" name={name} value={controlledValue?.value ?? ''} onChange={() => null} />\n )}\n </>\n );\n}\n\nUncontrolledSelectLegacy.displayName = 'UncontrolledSelectLegacy';\n\nexport { Unc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
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-select",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.31",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
"ts-check": "yarn root:ts-check $(pwd)",
|
|
18
18
|
"test": "yarn root:test $(pwd)",
|
|
19
19
|
"test:types": "yarn root:test:types $(pwd)",
|
|
20
|
-
"watch": "yarn root:watch $(pwd)"
|
|
20
|
+
"watch": "yarn root:watch $(pwd)",
|
|
21
|
+
"figma-publish": "yarn root:figma-publish $(pwd)",
|
|
22
|
+
"figma-unpublish": "yarn root:figma-unpublish $(pwd)",
|
|
23
|
+
"figma-snapshot-check": "yarn root:figma-snapshot $(pwd)",
|
|
24
|
+
"figma-snapshot-update": "yarn root:figma-snapshot $(pwd) --update"
|
|
21
25
|
},
|
|
22
26
|
"peerDependencies": {
|
|
23
27
|
"classnames": ">=2.3.2",
|
|
@@ -36,7 +40,7 @@
|
|
|
36
40
|
"@hh.ru/magritte-design-tokens": "26.0.2",
|
|
37
41
|
"@hh.ru/magritte-internal-slot-registry": "1.1.2",
|
|
38
42
|
"@hh.ru/magritte-ui-action-bar": "5.4.27",
|
|
39
|
-
"@hh.ru/magritte-ui-bottom-sheet": "9.4.
|
|
43
|
+
"@hh.ru/magritte-ui-bottom-sheet": "9.4.54",
|
|
40
44
|
"@hh.ru/magritte-ui-breakpoint": "6.1.3",
|
|
41
45
|
"@hh.ru/magritte-ui-button": "7.3.9",
|
|
42
46
|
"@hh.ru/magritte-ui-card": "8.7.7",
|
|
@@ -48,11 +52,11 @@
|
|
|
48
52
|
"@hh.ru/magritte-ui-input": "9.4.54",
|
|
49
53
|
"@hh.ru/magritte-ui-loader": "4.1.7",
|
|
50
54
|
"@hh.ru/magritte-ui-mock-component": "1.1.9",
|
|
51
|
-
"@hh.ru/magritte-ui-nav-bar": "2.0.
|
|
55
|
+
"@hh.ru/magritte-ui-nav-bar": "2.0.23",
|
|
52
56
|
"@hh.ru/magritte-ui-spacing": "2.1.32",
|
|
53
57
|
"@hh.ru/magritte-ui-title": "8.3.15",
|
|
54
58
|
"@hh.ru/magritte-ui-trigger": "4.3.50",
|
|
55
59
|
"@hh.ru/magritte-ui-typography": "5.3.17"
|
|
56
60
|
},
|
|
57
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "5c3c2c1bf7101bd746688b009408e18f03fe200a"
|
|
58
62
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Values the Select pickers supply on their own, read from TWO sides: the components apply them, and the Code
|
|
3
|
+
* Connect templates read them so a snippet does not repeat what the picker already provides. A literal copied
|
|
4
|
+
* into a template would drift silently — change a value here and the published snippet would keep asserting
|
|
5
|
+
* the old one, with no build error and no render error. The bundler inlines this file into every template that
|
|
6
|
+
* imports it, which is the other reason it must stay free of runtime imports.
|
|
7
|
+
*/
|
|
8
|
+
/** The ActionBar props `Select.Drop` supplies to its `footer`, through `ActionBarDefaultPropsContext`. */
|
|
9
|
+
export declare const SELECT_DROP_ACTION_BAR_DEFAULTS: {
|
|
10
|
+
readonly type: 'vertical';
|
|
11
|
+
readonly padding: 0;
|
|
12
|
+
readonly showDivider: false;
|
|
13
|
+
};
|
|
14
|
+
/** The `height` of `Select.BottomSheet` when none is passed — unlike `BottomSheet`, whose default is `content`. */
|
|
15
|
+
export declare const SELECT_BOTTOM_SHEET_HEIGHT_DEFAULT = "full-screen";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
const SELECT_DROP_ACTION_BAR_DEFAULTS = {
|
|
3
|
+
type: "vertical",
|
|
4
|
+
padding: 0,
|
|
5
|
+
showDivider: false
|
|
6
|
+
};
|
|
7
|
+
const SELECT_BOTTOM_SHEET_HEIGHT_DEFAULT = "full-screen";
|
|
8
|
+
|
|
9
|
+
export { SELECT_BOTTOM_SHEET_HEIGHT_DEFAULT, SELECT_DROP_ACTION_BAR_DEFAULTS };
|
|
10
|
+
//# sourceMappingURL=pickerDefaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickerDefaults.js","sources":["src/pickerDefaults.ts"],"sourcesContent":["/**\n * Values the Select pickers supply on their own, read from TWO sides: the components apply them, and the Code\n * Connect templates read them so a snippet does not repeat what the picker already provides. A literal copied\n * into a template would drift silently — change a value here and the published snippet would keep asserting\n * the old one, with no build error and no render error. The bundler inlines this file into every template that\n * imports it, which is the other reason it must stay free of runtime imports.\n */\n\n/** The ActionBar props `Select.Drop` supplies to its `footer`, through `ActionBarDefaultPropsContext`. */\nexport const SELECT_DROP_ACTION_BAR_DEFAULTS = {\n type: 'vertical',\n padding: 0,\n showDivider: false,\n} as const;\n\n/** The `height` of `Select.BottomSheet` when none is passed — unlike `BottomSheet`, whose default is `content`. */\nexport const SELECT_BOTTOM_SHEET_HEIGHT_DEFAULT = 'full-screen';\n"],"names":[],"mappings":"AASO,MAAM,+BAAkC,GAAA;AAAA,EAC3C,IAAM,EAAA,UAAA;AAAA,EACN,OAAS,EAAA,CAAA;AAAA,EACT,WAAa,EAAA,KAAA;AACjB,EAAA;AAGO,MAAM,kCAAqC,GAAA;;;;"}
|