@hh.ru/magritte-ui-select 13.5.0 → 13.6.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.
Files changed (74) hide show
  1. package/Select.d.ts +1 -1
  2. package/Select.js +42 -9
  3. package/Select.js.map +1 -1
  4. package/SelectBottomSheet.js +5 -2
  5. package/SelectBottomSheet.js.map +1 -1
  6. package/SelectDrop.js +5 -2
  7. package/SelectDrop.js.map +1 -1
  8. package/SelectEmptyHint.js +1 -1
  9. package/SelectOptions.js +37 -7
  10. package/SelectOptions.js.map +1 -1
  11. package/SelectSearchInput.js +2 -0
  12. package/SelectSearchInput.js.map +1 -1
  13. package/SelectSearchTrigger.js +4 -1
  14. package/SelectSearchTrigger.js.map +1 -1
  15. package/SelectSuggestTrigger.d.ts +24 -0
  16. package/SelectSuggestTrigger.js +106 -0
  17. package/SelectSuggestTrigger.js.map +1 -0
  18. package/SelectTrigger.js +3 -0
  19. package/SelectTrigger.js.map +1 -1
  20. package/UncontrolledSelect.js +3 -0
  21. package/UncontrolledSelect.js.map +1 -1
  22. package/index.css +35 -35
  23. package/index.js +3 -0
  24. package/index.js.map +1 -1
  25. package/index.mock.js +3 -0
  26. package/index.mock.js.map +1 -1
  27. package/internal/ConfigContext.d.ts +5 -1
  28. package/internal/ConfigContext.js +12 -0
  29. package/internal/ConfigContext.js.map +1 -1
  30. package/internal/CustomValuesContext.d.ts +4 -0
  31. package/internal/CustomValuesContext.js +10 -0
  32. package/internal/CustomValuesContext.js.map +1 -0
  33. package/internal/NavigationManagement.js +4 -3
  34. package/internal/NavigationManagement.js.map +1 -1
  35. package/internal/Option.js +1 -1
  36. package/internal/SearchStateContext.js +9 -3
  37. package/internal/SearchStateContext.js.map +1 -1
  38. package/internal/SelectDataProvider.js +2 -0
  39. package/internal/SelectDataProvider.js.map +1 -1
  40. package/internal/SelectError.js +3 -1
  41. package/internal/SelectError.js.map +1 -1
  42. package/internal/SelectReloadButton.js +2 -0
  43. package/internal/SelectReloadButton.js.map +1 -1
  44. package/internal/SelectStateContext.d.ts +4 -1
  45. package/internal/SelectStateContext.js +12 -2
  46. package/internal/SelectStateContext.js.map +1 -1
  47. package/internal/slots.d.ts +10 -0
  48. package/internal/slots.js.map +1 -1
  49. package/internal/useAutoSelectOnBlur.js +14 -2
  50. package/internal/useAutoSelectOnBlur.js.map +1 -1
  51. package/internal/useCustomOptions.d.ts +13 -0
  52. package/internal/useCustomOptions.js +63 -0
  53. package/internal/useCustomOptions.js.map +1 -0
  54. package/internal/useDataProvider.js +2 -0
  55. package/internal/useDataProvider.js.map +1 -1
  56. package/legacy/SelectLegacy.js +3 -0
  57. package/legacy/SelectLegacy.js.map +1 -1
  58. package/legacy/UncontrolledSelectLegacy.js +3 -0
  59. package/legacy/UncontrolledSelectLegacy.js.map +1 -1
  60. package/legacy/internal/BottomSheetHeaderLegacy.js +4 -4
  61. package/legacy/internal/FooterLegacy.js +4 -1
  62. package/legacy/internal/FooterLegacy.js.map +1 -1
  63. package/legacy/internal/TriggerLegacy.js +6 -3
  64. package/legacy/internal/TriggerLegacy.js.map +1 -1
  65. package/package.json +8 -8
  66. package/types.d.ts +26 -0
  67. package/useDataProvider.js +2 -0
  68. package/useDataProvider.js.map +1 -1
  69. package/useSearchState.js +2 -0
  70. package/useSearchState.js.map +1 -1
  71. package/useSelectContentState.js +12 -4
  72. package/useSelectContentState.js.map +1 -1
  73. package/useSelectTrigger.js +3 -0
  74. package/useSelectTrigger.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SelectSearchTrigger.js","sources":["src/SelectSearchTrigger.tsx"],"sourcesContent":["import { ReactElement, forwardRef, ForwardedRef, useRef, useCallback } from 'react';\nimport classnames from 'classnames';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { BaseInput } from '@hh.ru/magritte-ui-input/BaseInput';\nimport { useIsFocusWithin } from '@hh.ru/magritte-ui-select/internal/NavigationManagement';\nimport { FocusTarget, useFocusCandidate } from '@hh.ru/magritte-ui-select/internal/focusOrchestrator';\nimport { SelectUncontrolledTriggerProps } from '@hh.ru/magritte-ui-select/types';\nimport { useSearchState } from '@hh.ru/magritte-ui-select/useSearchState';\nimport { useSelectConfig } from '@hh.ru/magritte-ui-select/useSelectConfig';\nimport { useSelectTrigger, useTriggerRef } from '@hh.ru/magritte-ui-select/useSelectTrigger';\nimport { Trigger } from '@hh.ru/magritte-ui-trigger';\n\nimport styles from './select-search-trigger.less';\n\nconst SelectSearchTriggerComponent = <DataType extends StaticDataFetcherItem>(\n {\n 'aria-label': ariaLabel,\n 'data-qa': dataQa = 'magritte-select-activator',\n disabled,\n maxWidth,\n stretched,\n ...triggerProps\n }: SelectUncontrolledTriggerProps,\n ref: ForwardedRef<HTMLElement>\n): ReactElement => {\n const { hasExternalError } = useSelectConfig();\n const isFocusWithin = useIsFocusWithin();\n const showSearchInput = isFocusWithin && !hasExternalError;\n const activatorRef = useTriggerRef();\n const activatorRefCallback = useMultipleRefs(activatorRef, ref);\n const inputRef = useRef<HTMLInputElement>(null);\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n const { searchValue, setSearchValue } = useSearchState();\n\n const {\n onKeyDown,\n onChange,\n onBlur,\n expanded,\n onClear,\n values,\n onFocus,\n 'aria-haspopup': ariaHaspopup,\n 'aria-controls': ariaControls,\n } = useSelectTrigger<DataType>({ disabled: isComponentDisabled, searchable: true });\n\n useFocusCandidate('select-search-input', FocusTarget.Trigger, () => {\n const input = inputRef.current;\n if (!input) {\n return false;\n }\n input.focus();\n if (searchValue !== '') {\n input.select();\n }\n return true;\n });\n\n const onFocusTrigger = useCallback(() => {\n if (isComponentDisabled || expanded) {\n return;\n }\n onFocus?.();\n inputRef.current?.focus();\n }, [isComponentDisabled, expanded, onFocus]);\n\n return (\n <div\n ref={activatorRefCallback}\n className={classnames(styles.anchor, { [styles.anchorStretched]: stretched || Boolean(maxWidth) })}\n style={{ maxWidth }}\n >\n <div className={classnames(styles.defaultView, { [styles.hiddenView]: showSearchInput })}>\n <Trigger\n {...triggerProps}\n role=\"combobox\"\n maxWidth={maxWidth}\n stretched={stretched}\n expanded={expanded}\n onChange={onChange}\n onBlur={onBlur}\n onClear={onClear}\n onFocus={onFocusTrigger}\n onKeyDown={onKeyDown}\n values={values}\n data-qa={dataQa}\n disabled={isComponentDisabled}\n aria-label={ariaLabel || triggerProps.label}\n aria-haspopup={ariaHaspopup}\n aria-controls={ariaControls}\n />\n </div>\n <div\n className={classnames(styles.inputView, {\n [styles.hiddenView]: !showSearchInput,\n })}\n >\n <BaseInput\n size={triggerProps.size === 'large' ? 'large' : 'medium'}\n ref={inputRef}\n wrapperRef={activatorRef}\n value={searchValue}\n onChange={setSearchValue}\n onKeyDown={onKeyDown}\n onBlur={onBlur}\n data-qa=\"magritte-select-activator-input\"\n // oxlint-disable-next-line typescript/no-base-to-string\n placeholder={values.length > 0 ? values.join(', ') : triggerProps.label || ariaLabel}\n autoComplete=\"off\"\n role=\"combobox\"\n aria-expanded={expanded}\n aria-label={ariaLabel || triggerProps.label}\n aria-autocomplete=\"list\"\n aria-haspopup={ariaHaspopup}\n aria-controls={ariaControls}\n />\n </div>\n </div>\n );\n};\n\n/** Поисковый триггер Select на основе компонента Trigger и Input */\nconst SelectSearchTrigger = forwardRef<HTMLElement, SelectUncontrolledTriggerProps>(SelectSearchTriggerComponent);\n\nSelectSearchTrigger.displayName = 'SelectSearchTrigger';\n\nexport { SelectSearchTrigger };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,+BAA+B,CACjC;AAAA,EACI,YAAc,EAAA,SAAA;AAAA,EACd,WAAW,MAAS,GAAA,2BAAA;AAAA,EACpB,QAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAG,YAAA;AACP,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AO,SAAW,EAAA;AAAA,cACpC,CAAC,MAAA,CAAO,UAAU,GAAG,CAAC,eAAA;AAAA,aACzB,CAAA;AAAA,YAED,QAAA,kBAAA,GAAA;AAAA,cAAC,SAAA;AAAA,cAAA;AAAA,gBACG,IAAM,EAAA,YAAA,CAAa,IAAS,KAAA,OAAA,GAAU,OAAU,GAAA,QAAA;AAAA,gBAChD,GAAK,EAAA,QAAA;AAAA,gBACL,UAAY,EAAA,YAAA;AAAA,gBACZ,KAAO,EAAA,WAAA;AAAA,gBACP,QAAU,EAAA,cAAA;AAAA,gBACV,SAAA;AAAA,gBACA,MAAA;AAAA,gBACA,SAAQ,EAAA,iCAAA;AAAA,gBAER,WAAA,EAAa,OAAO,MAAS,GAAA,CAAA,GAAI,OAAO,IAAK,CAAA,IAAI,CAAI,GAAA,YAAA,CAAa,KAAS,IAAA,SAAA;AAAA,gBAC3E,YAAa,EAAA,KAAA;AAAA,gBACb,IAAK,EAAA,UAAA;AAAA,gBACL,eAAe,EAAA,QAAA;AAAA,gBACf,YAAA,EAAY,aAAa,YAAa,CAAA,KAAA;AAAA,gBACtC,mBAAkB,EAAA,MAAA;AAAA,gBAClB,eAAe,EAAA,YAAA;AAAA,gBACf,eAAe,EAAA,YAAA;AAAA,eAAA;AAAA,aACnB;AAAA,WAAA;AAAA,SACJ;AAAA,OAAA;AAAA,KAAA;AAAA,GACJ,CAAA;AAER,CAAA,CAAA;AAGM,MAAA,mBAAA,GAAsB,WAAwD,4BAA4B,EAAA;AAEhH,mBAAA,CAAoB,WAAc,GAAA,qBAAA;;;;"}
1
+ {"version":3,"file":"SelectSearchTrigger.js","sources":["src/SelectSearchTrigger.tsx"],"sourcesContent":["import { ReactElement, forwardRef, ForwardedRef, useRef, useCallback } from 'react';\nimport classnames from 'classnames';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { BaseInput } from '@hh.ru/magritte-ui-input/BaseInput';\nimport { useIsFocusWithin } from '@hh.ru/magritte-ui-select/internal/NavigationManagement';\nimport { FocusTarget, useFocusCandidate } from '@hh.ru/magritte-ui-select/internal/focusOrchestrator';\nimport { SelectUncontrolledTriggerProps } from '@hh.ru/magritte-ui-select/types';\nimport { useSearchState } from '@hh.ru/magritte-ui-select/useSearchState';\nimport { useSelectConfig } from '@hh.ru/magritte-ui-select/useSelectConfig';\nimport { useSelectTrigger, useTriggerRef } from '@hh.ru/magritte-ui-select/useSelectTrigger';\nimport { Trigger } from '@hh.ru/magritte-ui-trigger';\n\nimport styles from './select-search-trigger.less';\n\nconst SelectSearchTriggerComponent = <DataType extends StaticDataFetcherItem>(\n {\n 'aria-label': ariaLabel,\n 'data-qa': dataQa = 'magritte-select-activator',\n disabled,\n maxWidth,\n stretched,\n ...triggerProps\n }: SelectUncontrolledTriggerProps,\n ref: ForwardedRef<HTMLElement>\n): ReactElement => {\n const { hasExternalError } = useSelectConfig();\n const isFocusWithin = useIsFocusWithin();\n const showSearchInput = isFocusWithin && !hasExternalError;\n const activatorRef = useTriggerRef();\n const activatorRefCallback = useMultipleRefs(activatorRef, ref);\n const inputRef = useRef<HTMLInputElement>(null);\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n const { searchValue, setSearchValue } = useSearchState();\n\n const {\n onKeyDown,\n onChange,\n onBlur,\n expanded,\n onClear,\n values,\n onFocus,\n 'aria-haspopup': ariaHaspopup,\n 'aria-controls': ariaControls,\n } = useSelectTrigger<DataType>({ disabled: isComponentDisabled, searchable: true });\n\n useFocusCandidate('select-search-input', FocusTarget.Trigger, () => {\n const input = inputRef.current;\n if (!input) {\n return false;\n }\n input.focus();\n if (searchValue !== '') {\n input.select();\n }\n return true;\n });\n\n const onFocusTrigger = useCallback(() => {\n if (isComponentDisabled || expanded) {\n return;\n }\n onFocus?.();\n inputRef.current?.focus();\n }, [isComponentDisabled, expanded, onFocus]);\n\n return (\n <div\n ref={activatorRefCallback}\n className={classnames(styles.anchor, { [styles.anchorStretched]: stretched || Boolean(maxWidth) })}\n style={{ maxWidth }}\n >\n <div className={classnames(styles.defaultView, { [styles.hiddenView]: showSearchInput })}>\n <Trigger\n {...triggerProps}\n role=\"combobox\"\n maxWidth={maxWidth}\n stretched={stretched}\n expanded={expanded}\n onChange={onChange}\n onBlur={onBlur}\n onClear={onClear}\n onFocus={onFocusTrigger}\n onKeyDown={onKeyDown}\n values={values}\n data-qa={dataQa}\n disabled={isComponentDisabled}\n aria-label={ariaLabel || triggerProps.label}\n aria-haspopup={ariaHaspopup}\n aria-controls={ariaControls}\n />\n </div>\n <div\n className={classnames(styles.inputView, {\n [styles.hiddenView]: !showSearchInput,\n })}\n >\n <BaseInput\n size={triggerProps.size === 'large' ? 'large' : 'medium'}\n ref={inputRef}\n wrapperRef={activatorRef}\n value={searchValue}\n onChange={setSearchValue}\n onKeyDown={onKeyDown}\n onBlur={onBlur}\n data-qa=\"magritte-select-activator-input\"\n // oxlint-disable-next-line typescript/no-base-to-string\n placeholder={values.length > 0 ? values.join(', ') : triggerProps.label || ariaLabel}\n autoComplete=\"off\"\n role=\"combobox\"\n aria-expanded={expanded}\n aria-label={ariaLabel || triggerProps.label}\n aria-autocomplete=\"list\"\n aria-haspopup={ariaHaspopup}\n aria-controls={ariaControls}\n />\n </div>\n </div>\n );\n};\n\n/** Поисковый триггер Select на основе компонента Trigger и Input */\nconst SelectSearchTrigger = forwardRef<HTMLElement, SelectUncontrolledTriggerProps>(SelectSearchTriggerComponent);\n\nSelectSearchTrigger.displayName = 'SelectSearchTrigger';\n\nexport { SelectSearchTrigger };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,+BAA+B,CACjC;AAAA,EACI,YAAc,EAAA,SAAA;AAAA,EACd,WAAW,MAAS,GAAA,2BAAA;AAAA,EACpB,QAAA;AAAA,EACA,QAAA;AAAA,E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YACG,SAAA,EAAW,UAAW,CAAA,MAAA,CAAO,SAAW,EAAA;AAAA,cACpC,CAAC,MAAA,CAAO,UAAU,GAAG,CAAC,eAAA;AAAA,aACzB,CAAA;AAAA,YAED,QAAA,kBAAA,GAAA;AAAA,cAAC,SAAA;AAAA,cAAA;AAAA,gBACG,IAAM,EAAA,YAAA,CAAa,IAAS,KAAA,OAAA,GAAU,OAAU,GAAA,QAAA;AAAA,gBAChD,GAAK,EAAA,QAAA;AAAA,gBACL,UAAY,EAAA,YAAA;AAAA,gBACZ,KAAO,EAAA,WAAA;AAAA,gBACP,QAAU,EAAA,cAAA;AAAA,gBACV,SAAA;AAAA,gBACA,MAAA;AAAA,gBACA,SAAQ,EAAA,iCAAA;AAAA,gBAER,WAAA,EAAa,OAAO,MAAS,GAAA,CAAA,GAAI,OAAO,IAAK,CAAA,IAAI,CAAI,GAAA,YAAA,CAAa,KAAS,IAAA,SAAA;AAAA,gBAC3E,YAAa,EAAA,KAAA;AAAA,gBACb,IAAK,EAAA,UAAA;AAAA,gBACL,eAAe,EAAA,QAAA;AAAA,gBACf,YAAA,EAAY,aAAa,YAAa,CAAA,KAAA;AAAA,gBACtC,mBAAkB,EAAA,MAAA;AAAA,gBAClB,eAAe,EAAA,YAAA;AAAA,gBACf,eAAe,EAAA,YAAA;AAAA,eAAA;AAAA,aACnB;AAAA,WAAA;AAAA,SACJ;AAAA,OAAA;AAAA,KAAA;AAAA,GACJ,CAAA;AAER,CAAA,CAAA;AAGM,MAAA,mBAAA,GAAsB,WAAwD,4BAA4B,EAAA;AAEhH,mBAAA,CAAoB,WAAc,GAAA,qBAAA;;;;"}
@@ -0,0 +1,24 @@
1
+ import { ComponentProps } from 'react';
2
+ import { Input } from '@hh.ru/magritte-ui-input';
3
+ import { DistributiveOmit } from './internal/utils';
4
+ type ControlledSuggestTriggerKeys = 'value' | 'onChange' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onClick' | 'wrapperRef' | 'role' | 'autoComplete';
5
+ export type SelectSuggestTriggerProps = DistributiveOmit<ComponentProps<typeof Input>, ControlledSuggestTriggerKeys> & {
6
+ 'data-qa'?: string;
7
+ };
8
+ /** Триггер саджеста: инпут, значение которого — поисковый запрос Select */
9
+ declare const SelectSuggestTrigger: import("react").ForwardRefExoticComponent<(Omit<Omit<import("@hh.ru/magritte-ui-input").InputBaseProps & import("@hh.ru/magritte-ui-input").InputWithHintProps & import("@hh.ru/magritte-ui-input").InputClearableOnFocusProps & import("@hh.ru/magritte-ui-input").ControlledProps & Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "buttonDataQa" | "buttonIcon" | "buttonIconAriaLabel" | "buttonRef" | "clearable" | "clearableOnFocus" | "description" | "disabled" | "elevatePlaceholder" | "errorMessage" | "formatter" | "hint" | "invalid" | "maxLength" | "onBlur" | "onButtonClick" | "onChange" | "onFocus" | "placeholder" | "postfix" | "showHintAlways" | "size" | "value" | "wrapperRef"> & import("react").RefAttributes<HTMLInputElement>, ControlledSuggestTriggerKeys> & {
10
+ 'data-qa'?: string;
11
+ }, "ref"> | Omit<Omit<import("@hh.ru/magritte-ui-input").InputBaseProps & import("@hh.ru/magritte-ui-input").InputWithHintProps & import("@hh.ru/magritte-ui-input").InputClearableProps & import("@hh.ru/magritte-ui-input").ControlledProps & Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "buttonDataQa" | "buttonIcon" | "buttonIconAriaLabel" | "buttonRef" | "clearable" | "clearableOnFocus" | "description" | "disabled" | "elevatePlaceholder" | "errorMessage" | "formatter" | "hint" | "invalid" | "maxLength" | "onBlur" | "onButtonClick" | "onChange" | "onFocus" | "placeholder" | "postfix" | "showHintAlways" | "size" | "value" | "wrapperRef"> & import("react").RefAttributes<HTMLInputElement>, ControlledSuggestTriggerKeys> & {
12
+ 'data-qa'?: string;
13
+ }, "ref"> | Omit<Omit<import("@hh.ru/magritte-ui-input").InputBaseProps & import("@hh.ru/magritte-ui-input").InputWithHintProps & {
14
+ clearable?: never;
15
+ clearableOnFocus?: never;
16
+ buttonIcon: import("@hh.ru/magritte-ui-icon/types").IconWrapperComponentSize16 | import("@hh.ru/magritte-ui-icon/types").IconWrapperComponentSize24;
17
+ buttonIconAriaLabel?: string;
18
+ onButtonClick: (event: import("react").MouseEvent<HTMLButtonElement, MouseEvent>) => void;
19
+ } & import("@hh.ru/magritte-ui-input").ControlledProps & Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "buttonDataQa" | "buttonIcon" | "buttonIconAriaLabel" | "buttonRef" | "clearable" | "clearableOnFocus" | "description" | "disabled" | "elevatePlaceholder" | "errorMessage" | "formatter" | "hint" | "invalid" | "maxLength" | "onBlur" | "onButtonClick" | "onChange" | "onFocus" | "placeholder" | "postfix" | "showHintAlways" | "size" | "value" | "wrapperRef"> & import("react").RefAttributes<HTMLInputElement>, ControlledSuggestTriggerKeys> & {
20
+ 'data-qa'?: string;
21
+ }, "ref"> | Omit<Omit<import("@hh.ru/magritte-ui-input").InputBaseProps & import("@hh.ru/magritte-ui-input").InputWithHintProps & import("@hh.ru/magritte-ui-input").InputWithoutRightButtonProps & import("@hh.ru/magritte-ui-input").ControlledProps & Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "buttonDataQa" | "buttonIcon" | "buttonIconAriaLabel" | "buttonRef" | "clearable" | "clearableOnFocus" | "description" | "disabled" | "elevatePlaceholder" | "errorMessage" | "formatter" | "hint" | "invalid" | "maxLength" | "onBlur" | "onButtonClick" | "onChange" | "onFocus" | "placeholder" | "postfix" | "showHintAlways" | "size" | "value" | "wrapperRef"> & import("react").RefAttributes<HTMLInputElement>, ControlledSuggestTriggerKeys> & {
22
+ 'data-qa'?: string;
23
+ }, "ref">) & import("react").RefAttributes<HTMLInputElement>>;
24
+ export { SelectSuggestTrigger };
@@ -0,0 +1,106 @@
1
+ import './index.css';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { forwardRef, useRef, useCallback } from 'react';
4
+ import { keyboardMatches, keyboardKeys } from '@hh.ru/magritte-common-keyboard';
5
+ import { useDisabled } from '@hh.ru/magritte-common-use-disabled';
6
+ import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
7
+ import { Input } from '@hh.ru/magritte-ui-input';
8
+ import { useFocusCandidate, FocusTarget } from './internal/focusOrchestrator.js';
9
+ import { useRegisterSelectElementsSlot } from './internal/slots.js';
10
+ import { useSearchState } from './useSearchState.js';
11
+ import { useTriggerRef, useSelectTrigger } from './useSelectTrigger.js';
12
+ import { useVisibility } from './useVisibility.js';
13
+ import './internal/utils.js';
14
+ import '@hh.ru/magritte-internal-slot-registry';
15
+ import './internal/SearchStateContext.js';
16
+ import './internal/VisibilityContext.js';
17
+ import './internal/SelectStateContext.js';
18
+ import './internal/SelectStore.js';
19
+ import './useSelectConfig.js';
20
+ import './internal/ConfigContext.js';
21
+ import './useSelectContentState.js';
22
+ import './internal/useCustomOptions.js';
23
+ import '@hh.ru/magritte-common-fuzzy-search';
24
+ import './internal/CustomValuesContext.js';
25
+ import './useDataProvider.js';
26
+ import './internal/SelectDataProvider.js';
27
+ import '@hh.ru/magritte-common-data-provider';
28
+ import './internal/useDataProvider.js';
29
+
30
+ const SelectSuggestTriggerComponent = ({ "data-qa": dataQa = "magritte-select-activator", disabled, ...inputProps }, ref) => {
31
+ const activatorRef = useTriggerRef();
32
+ const inputRef = useRef(null);
33
+ const inputRefCallback = useMultipleRefs(inputRef, ref);
34
+ const forceDisabled = useDisabled();
35
+ const isComponentDisabled = disabled || forceDisabled;
36
+ const { searchValue, setSearchValue } = useSearchState();
37
+ const { showOptions, toggleListVisibility } = useVisibility();
38
+ useRegisterSelectElementsSlot("keepSearchOnClose", true);
39
+ useRegisterSelectElementsSlot("suggestListView", true);
40
+ const {
41
+ onKeyDown: onKeyDownTrigger,
42
+ onBlur,
43
+ expanded,
44
+ onFocus,
45
+ "aria-haspopup": ariaHaspopup,
46
+ "aria-controls": ariaControls
47
+ } = useSelectTrigger({ disabled: isComponentDisabled, searchable: true });
48
+ useFocusCandidate("select-suggest-input", FocusTarget.Trigger, () => {
49
+ const input = inputRef.current;
50
+ if (!input) {
51
+ return false;
52
+ }
53
+ input.focus();
54
+ return true;
55
+ });
56
+ const onChangeInput = useCallback(
57
+ (value) => {
58
+ setSearchValue(value);
59
+ if (!showOptions) {
60
+ toggleListVisibility(true);
61
+ }
62
+ },
63
+ [setSearchValue, showOptions, toggleListVisibility]
64
+ );
65
+ const onKeyDownInput = useCallback(
66
+ (event) => {
67
+ if (keyboardMatches(event.nativeEvent, [keyboardKeys.Enter, keyboardKeys.Space])) {
68
+ return;
69
+ }
70
+ onKeyDownTrigger?.(event);
71
+ },
72
+ [onKeyDownTrigger]
73
+ );
74
+ const onClickInput = useCallback(() => {
75
+ if (!isComponentDisabled && !showOptions) {
76
+ toggleListVisibility(true);
77
+ }
78
+ }, [isComponentDisabled, showOptions, toggleListVisibility]);
79
+ return /* @__PURE__ */ jsx(
80
+ Input,
81
+ {
82
+ ...inputProps,
83
+ ref: inputRefCallback,
84
+ wrapperRef: activatorRef,
85
+ value: searchValue,
86
+ onChange: onChangeInput,
87
+ onFocus,
88
+ onBlur,
89
+ onKeyDown: onKeyDownInput,
90
+ onClick: onClickInput,
91
+ disabled: isComponentDisabled,
92
+ "data-qa": dataQa,
93
+ autoComplete: "off",
94
+ role: "combobox",
95
+ "aria-expanded": expanded,
96
+ "aria-autocomplete": "list",
97
+ "aria-haspopup": ariaHaspopup,
98
+ "aria-controls": ariaControls
99
+ }
100
+ );
101
+ };
102
+ const SelectSuggestTrigger = forwardRef(SelectSuggestTriggerComponent);
103
+ SelectSuggestTrigger.displayName = "SelectSuggestTrigger";
104
+
105
+ export { SelectSuggestTrigger };
106
+ //# sourceMappingURL=SelectSuggestTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectSuggestTrigger.js","sources":["src/SelectSuggestTrigger.tsx"],"sourcesContent":["import {\n ReactElement,\n forwardRef,\n ForwardedRef,\n useRef,\n useCallback,\n ComponentProps,\n KeyboardEventHandler,\n} from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { keyboardKeys, keyboardMatches } from '@hh.ru/magritte-common-keyboard';\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { Input } from '@hh.ru/magritte-ui-input';\nimport { FocusTarget, useFocusCandidate } from '@hh.ru/magritte-ui-select/internal/focusOrchestrator';\nimport { useRegisterSelectElementsSlot } from '@hh.ru/magritte-ui-select/internal/slots';\nimport { DistributiveOmit } from '@hh.ru/magritte-ui-select/internal/utils';\nimport { useSearchState } from '@hh.ru/magritte-ui-select/useSearchState';\nimport { useSelectTrigger, useTriggerRef } from '@hh.ru/magritte-ui-select/useSelectTrigger';\nimport { useVisibility } from '@hh.ru/magritte-ui-select/useVisibility';\n\ntype ControlledSuggestTriggerKeys =\n | 'value'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'onKeyDown'\n | 'onClick'\n | 'wrapperRef'\n | 'role'\n | 'autoComplete';\n\nexport type SelectSuggestTriggerProps = DistributiveOmit<ComponentProps<typeof Input>, ControlledSuggestTriggerKeys> & {\n 'data-qa'?: string;\n};\n\nconst SelectSuggestTriggerComponent = <DataType extends StaticDataFetcherItem>(\n { 'data-qa': dataQa = 'magritte-select-activator', disabled, ...inputProps }: SelectSuggestTriggerProps,\n ref: ForwardedRef<HTMLInputElement>\n): ReactElement => {\n const activatorRef = useTriggerRef();\n const inputRef = useRef<HTMLInputElement>(null);\n const inputRefCallback = useMultipleRefs(inputRef, ref);\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n const { searchValue, setSearchValue } = useSearchState();\n const { showOptions, toggleListVisibility } = useVisibility();\n\n // запрос — это значение инпута: при закрытии пикера не сбрасываем\n useRegisterSelectElementsSlot('keepSearchOnClose', true);\n useRegisterSelectElementsSlot('suggestListView', true);\n\n const {\n onKeyDown: onKeyDownTrigger,\n onBlur,\n expanded,\n onFocus,\n 'aria-haspopup': ariaHaspopup,\n 'aria-controls': ariaControls,\n } = useSelectTrigger<DataType>({ disabled: isComponentDisabled, searchable: true });\n\n useFocusCandidate('select-suggest-input', FocusTarget.Trigger, () => {\n const input = inputRef.current;\n if (!input) {\n return false;\n }\n input.focus();\n return true;\n });\n\n const onChangeInput = useCallback(\n (value: string) => {\n setSearchValue(value);\n if (!showOptions) {\n toggleListVisibility(true);\n }\n },\n [setSearchValue, showOptions, toggleListVisibility]\n );\n\n const onKeyDownInput = useCallback<KeyboardEventHandler<HTMLInputElement>>(\n (event) => {\n // в инпуте Enter ничего не делает, а пробел — обычный символ\n if (keyboardMatches(event.nativeEvent, [keyboardKeys.Enter, keyboardKeys.Space])) {\n return;\n }\n onKeyDownTrigger?.(event);\n },\n [onKeyDownTrigger]\n );\n\n const onClickInput = useCallback(() => {\n if (!isComponentDisabled && !showOptions) {\n toggleListVisibility(true);\n }\n }, [isComponentDisabled, showOptions, toggleListVisibility]);\n\n return (\n <Input\n {...inputProps}\n ref={inputRefCallback}\n wrapperRef={activatorRef}\n value={searchValue}\n onChange={onChangeInput}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDownInput}\n onClick={onClickInput}\n disabled={isComponentDisabled}\n data-qa={dataQa}\n autoComplete=\"off\"\n role=\"combobox\"\n aria-expanded={expanded}\n aria-autocomplete=\"list\"\n aria-haspopup={ariaHaspopup}\n aria-controls={ariaControls}\n />\n );\n};\n\n/** Триггер саджеста: инпут, значение которого — поисковый запрос Select */\nconst SelectSuggestTrigger = forwardRef<HTMLInputElement, SelectSuggestTriggerProps>(SelectSuggestTriggerComponent);\n\nSelectSuggestTrigger.displayName = 'SelectSuggestTrigger';\n\nexport { SelectSuggestTrigger };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,6BAAA,GAAgC,CAClC,EAAE,SAAW,EAAA,MAAA,GAAS,6BAA6B,QAAU,EAAA,GAAG,UAAW,EA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;AAER,CAAA,CAAA;AAGM,MAAA,oBAAA,GAAuB,WAAwD,6BAA6B,EAAA;AAElH,oBAAA,CAAqB,WAAc,GAAA,sBAAA;;;;"}
package/SelectTrigger.js CHANGED
@@ -15,6 +15,9 @@ import './internal/ConfigContext.js';
15
15
  import './internal/slots.js';
16
16
  import '@hh.ru/magritte-internal-slot-registry';
17
17
  import './useSelectContentState.js';
18
+ import './internal/useCustomOptions.js';
19
+ import '@hh.ru/magritte-common-fuzzy-search';
20
+ import './internal/CustomValuesContext.js';
18
21
  import './useDataProvider.js';
19
22
  import './internal/SelectDataProvider.js';
20
23
  import '@hh.ru/magritte-common-data-provider';
@@ -1 +1 @@
1
- {"version":3,"file":"SelectTrigger.js","sources":["src/SelectTrigger.tsx"],"sourcesContent":["import { ReactElement, forwardRef, ForwardedRef } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { FocusTarget, useFocusCandidate } from '@hh.ru/magritte-ui-select/internal/focusOrchestrator';\nimport { SelectUncontrolledTriggerProps } from '@hh.ru/magritte-ui-select/types';\nimport { useSelectTrigger, useTriggerRef } from '@hh.ru/magritte-ui-select/useSelectTrigger';\nimport { Trigger } from '@hh.ru/magritte-ui-trigger';\n\nconst SelectTriggerComponent = <DataType extends StaticDataFetcherItem>(\n { 'data-qa': dataQa = 'magritte-select-activator', disabled, ...triggerProps }: SelectUncontrolledTriggerProps,\n ref: ForwardedRef<HTMLElement>\n): ReactElement => {\n const activatorRef = useTriggerRef();\n const activatorRefCallback = useMultipleRefs(activatorRef, ref);\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n\n const {\n onKeyDown,\n onChange,\n onBlur,\n expanded,\n onClear,\n values,\n onFocus,\n 'aria-haspopup': ariaHaspopup,\n 'aria-controls': ariaControls,\n } = useSelectTrigger<DataType>({ disabled: isComponentDisabled });\n\n useFocusCandidate('default-trigger', FocusTarget.Trigger, () => {\n const trigger = activatorRef.current;\n if (!trigger || isComponentDisabled) {\n return false;\n }\n trigger.focus();\n return true;\n });\n\n return (\n <Trigger\n {...triggerProps}\n ref={activatorRefCallback}\n role={'combobox'}\n disabled={isComponentDisabled}\n data-qa={dataQa}\n expanded={expanded}\n onChange={onChange}\n onBlur={onBlur}\n onClear={onClear}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n values={values}\n aria-label={triggerProps['aria-label'] || triggerProps.label}\n aria-haspopup={ariaHaspopup}\n aria-controls={ariaControls}\n />\n );\n};\n\n/** Триггер Select на основе компонента Trigger */\nconst SelectTrigger = forwardRef<HTMLElement, SelectUncontrolledTriggerProps>(SelectTriggerComponent);\n\nSelectTrigger.displayName = 'SelectTrigger';\n\nexport { SelectTrigger };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,sBAAA,GAAyB,CAC3B,EAAE,SAAW,EAAA,MAAA,GAAS,6BAA6B,QAAU,EAAA,GAAG,YAAa,EAAA,EAC7E,GACe,KAAA;AACf,EAAA,MAAM,eAAe,aAAc,EAAA,CAAA;AACnC,EAAM,MAAA,oBAAA,GAAuB,eAAgB,CAAA,YAAA,EAAc,GAAG,CAAA,CAAA;AAC9D,EAAA,MAAM,gBAAgB,WAAY,EAAA,CAAA;AAClC,EAAA,MAAM,sBAAsB,QAAY,IAAA,aAAA,CAAA;AAExC,EAAM,MAAA;AAAA,IACF,SAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,eAAiB,EAAA,YAAA;AAAA,IACjB,eAAiB,EAAA,YAAA;AAAA,GACjB,GAAA,gBAAA,CAA2B,EAAE,QAAA,EAAU,qBAAqB,CAAA,CAAA;AAEhE,EAAkB,iBAAA,CAAA,iBAAA,EAAmB,WAAY,CAAA,OAAA,EAAS,MAAM;AAC5D,IAAA,MAAM,UAAU,YAAa,CAAA,OAAA,CAAA;AAC7B,IAAI,IAAA,CAAC,WAAW,mBAAqB,EAAA;AACjC,MAAO,OAAA,KAAA,CAAA;AAAA,KACX;AACA,IAAA,OAAA,CAAQ,KAAM,EAAA,CAAA;AACd,IAAO,OAAA,IAAA,CAAA;AAAA,GACV,CAAA,CAAA;AAED,EACI,uBAAA,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACI,GAAG,YAAA;AAAA,MACJ,GAAK,EAAA,oBAAA;AAAA,MACL,IAAM,EAAA,UAAA;AAAA,MACN,QAAU,EAAA,mBAAA;AAAA,MACV,SAAS,EAAA,MAAA;AAAA,MACT,QAAA;AAAA,MACA,QAAA;AAAA,MACA,MAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA,YAAY,EAAA,YAAA,CAAa,YAAY,CAAA,IAAK,YAAa,CAAA,KAAA;AAAA,MACvD,eAAe,EAAA,YAAA;AAAA,MACf,eAAe,EAAA,YAAA;AAAA,KAAA;AAAA,GACnB,CAAA;AAER,CAAA,CAAA;AAGM,MAAA,aAAA,GAAgB,WAAwD,sBAAsB,EAAA;AAEpG,aAAA,CAAc,WAAc,GAAA,eAAA;;;;"}
1
+ {"version":3,"file":"SelectTrigger.js","sources":["src/SelectTrigger.tsx"],"sourcesContent":["import { ReactElement, forwardRef, ForwardedRef } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { FocusTarget, useFocusCandidate } from '@hh.ru/magritte-ui-select/internal/focusOrchestrator';\nimport { SelectUncontrolledTriggerProps } from '@hh.ru/magritte-ui-select/types';\nimport { useSelectTrigger, useTriggerRef } from '@hh.ru/magritte-ui-select/useSelectTrigger';\nimport { Trigger } from '@hh.ru/magritte-ui-trigger';\n\nconst SelectTriggerComponent = <DataType extends StaticDataFetcherItem>(\n { 'data-qa': dataQa = 'magritte-select-activator', disabled, ...triggerProps }: SelectUncontrolledTriggerProps,\n ref: ForwardedRef<HTMLElement>\n): ReactElement => {\n const activatorRef = useTriggerRef();\n const activatorRefCallback = useMultipleRefs(activatorRef, ref);\n const forceDisabled = useDisabled();\n const isComponentDisabled = disabled || forceDisabled;\n\n const {\n onKeyDown,\n onChange,\n onBlur,\n expanded,\n onClear,\n values,\n onFocus,\n 'aria-haspopup': ariaHaspopup,\n 'aria-controls': ariaControls,\n } = useSelectTrigger<DataType>({ disabled: isComponentDisabled });\n\n useFocusCandidate('default-trigger', FocusTarget.Trigger, () => {\n const trigger = activatorRef.current;\n if (!trigger || isComponentDisabled) {\n return false;\n }\n trigger.focus();\n return true;\n });\n\n return (\n <Trigger\n {...triggerProps}\n ref={activatorRefCallback}\n role={'combobox'}\n disabled={isComponentDisabled}\n data-qa={dataQa}\n expanded={expanded}\n onChange={onChange}\n onBlur={onBlur}\n onClear={onClear}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n values={values}\n aria-label={triggerProps['aria-label'] || triggerProps.label}\n aria-haspopup={ariaHaspopup}\n aria-controls={ariaControls}\n />\n );\n};\n\n/** Триггер Select на основе компонента Trigger */\nconst SelectTrigger = forwardRef<HTMLElement, SelectUncontrolledTriggerProps>(SelectTriggerComponent);\n\nSelectTrigger.displayName = 'SelectTrigger';\n\nexport { SelectTrigger };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,sBAAA,GAAyB,CAC3B,EAAE,SAAW,EAAA,MAAA,GAAS,6BAA6B,QAAU,EAAA,GAAG,YAAa,EAAA,EAC7E,GACe,KAAA;AACf,EAAA,MAAM,eAAe,aAAc,EAAA,CAAA;AACnC,EAAM,MAAA,oBAAA,GAAuB,eAAgB,CAAA,YAAA,EAAc,GAAG,CAAA,CAAA;AAC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AAA;;;;"}
@@ -44,6 +44,9 @@ import '@hh.ru/magritte-ui-typography';
44
44
  import './pickerDefaults.js';
45
45
  import './usePickerRef.js';
46
46
  import './useSelectContentState.js';
47
+ import './internal/useCustomOptions.js';
48
+ import '@hh.ru/magritte-common-fuzzy-search';
49
+ import './internal/CustomValuesContext.js';
47
50
  import './useSelectHint.js';
48
51
  import './SelectBottomSheetHeader.js';
49
52
  import '@hh.ru/magritte-ui-nav-bar';
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,qBAAqB,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ncontrolledSelect.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-5-0{
1
+ .magritte-error-container___ICGpQ_13-6-0{
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-5-0{
10
+ body.magritte-old-layout .magritte-error-container___ICGpQ_13-6-0{
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-5-0{
16
+ body:not(.magritte-old-layout) .magritte-error-container___ICGpQ_13-6-0{
17
17
  min-height:320px;
18
18
  height:auto;
19
19
  }
20
20
  }
21
21
 
22
- .magritte-content-placeholder___rOCxd_13-5-0{
22
+ .magritte-content-placeholder___rOCxd_13-6-0{
23
23
  display:flex;
24
24
  flex-direction:column;
25
25
  align-items:center;
@@ -27,25 +27,25 @@
27
27
  height:100%;
28
28
  text-align:center;
29
29
  }
30
- .magritte-select-bottom-sheet_without-header___KOKVh_13-5-0{
30
+ .magritte-select-bottom-sheet_without-header___KOKVh_13-6-0{
31
31
  padding-top:16px;
32
32
  }
33
33
 
34
- .magritte-select-drop-container-wrapper___OHM0q_13-5-0{
34
+ .magritte-select-drop-container-wrapper___OHM0q_13-6-0{
35
35
  display:flex;
36
36
  flex-direction:column;
37
37
  }
38
- .magritte-select-drop-container___hee1p_13-5-0{
38
+ .magritte-select-drop-container___hee1p_13-6-0{
39
39
  display:flex;
40
40
  flex-direction:column;
41
41
  padding:var(--magritte-select-drop-padding);
42
42
  margin:calc(-1 * var(--magritte-select-drop-padding));
43
43
  }
44
- .magritte-select-drop-container_with-footer___6wp-L_13-5-0{
44
+ .magritte-select-drop-container_with-footer___6wp-L_13-6-0{
45
45
  margin-bottom:0;
46
46
  padding-bottom:0;
47
47
  }
48
- .magritte-select-drop-loading___KsNuw_13-5-0{
48
+ .magritte-select-drop-loading___KsNuw_13-6-0{
49
49
  display:flex;
50
50
  align-items:center;
51
51
  height:150px;
@@ -70,7 +70,7 @@
70
70
  --magritte-color-background-accent-secondary-v26-0-3:#F1F4F7;
71
71
  --magritte-color-icon-accent-v26-0-3:#7195AF;
72
72
  }
73
- .magritte-select-empty-hint___B39XJ_13-5-0{
73
+ .magritte-select-empty-hint___B39XJ_13-6-0{
74
74
  display:flex;
75
75
  flex-direction:column;
76
76
  align-items:center;
@@ -79,18 +79,18 @@
79
79
  text-align:center;
80
80
  }
81
81
  @media (min-width: 1020px){
82
- body.magritte-old-layout .magritte-select-empty-hint___B39XJ_13-5-0{
82
+ body.magritte-old-layout .magritte-select-empty-hint___B39XJ_13-6-0{
83
83
  min-height:320px;
84
84
  height:auto;
85
85
  }
86
86
  }
87
87
  @media (min-width: 1024px){
88
- body:not(.magritte-old-layout) .magritte-select-empty-hint___B39XJ_13-5-0{
88
+ body:not(.magritte-old-layout) .magritte-select-empty-hint___B39XJ_13-6-0{
89
89
  min-height:320px;
90
90
  height:auto;
91
91
  }
92
92
  }
93
- .magritte-icon___F0GQx_13-5-0{
93
+ .magritte-icon___F0GQx_13-6-0{
94
94
  display:flex;
95
95
  align-items:center;
96
96
  justify-content:center;
@@ -98,11 +98,11 @@
98
98
  height:48px;
99
99
  border-radius:50%;
100
100
  }
101
- .magritte-icon-empty___sAFRT_13-5-0{
101
+ .magritte-icon-empty___sAFRT_13-6-0{
102
102
  background-color:var(--magritte-color-background-accent-secondary-v26-0-3);
103
103
  --magritte-ui-icon-color-override:var(--magritte-color-icon-accent-v26-0-3);
104
104
  }
105
- .magritte-icon-empty-search___O0pus_13-5-0{
105
+ .magritte-icon-empty-search___O0pus_13-6-0{
106
106
  background-color:var(--magritte-color-background-secondary-v26-0-3);
107
107
  --magritte-ui-icon-color-override:var(--magritte-color-icon-tertiary-v26-0-3);
108
108
  }
@@ -110,79 +110,79 @@
110
110
  :root{
111
111
  --magritte-color-component-input-stroke-state-accent-focused-accessible-v26-0-3:#0070ff7a;
112
112
  }
113
- .magritte-select-option-plain___u9kSx_13-5-0{
113
+ .magritte-select-option-plain___u9kSx_13-6-0{
114
114
  border-radius:8px;
115
115
  }
116
- .magritte-select-option-plain___u9kSx_13-5-0.focus-visible{
116
+ .magritte-select-option-plain___u9kSx_13-6-0.focus-visible{
117
117
  outline:var(--magritte-color-component-input-stroke-state-accent-focused-accessible-v26-0-3) solid 4px;
118
118
  }
119
119
  @media (min-width: 1020px){
120
- body.magritte-old-layout .magritte-select-option-plain___u9kSx_13-5-0:hover{
120
+ body.magritte-old-layout .magritte-select-option-plain___u9kSx_13-6-0:hover{
121
121
  cursor:default;
122
122
  }
123
123
  }
124
124
  @media (min-width: 1024px){
125
- body:not(.magritte-old-layout) .magritte-select-option-plain___u9kSx_13-5-0:hover{
125
+ body:not(.magritte-old-layout) .magritte-select-option-plain___u9kSx_13-6-0:hover{
126
126
  cursor:default;
127
127
  }
128
128
  }
129
129
  @media (min-width: 1020px){
130
- body.magritte-old-layout .magritte-select-option-plain_active___ynHQP_13-5-0:hover{
130
+ body.magritte-old-layout .magritte-select-option-plain_active___ynHQP_13-6-0:hover{
131
131
  cursor:pointer;
132
132
  }
133
133
  }
134
134
  @media (min-width: 1024px){
135
- body:not(.magritte-old-layout) .magritte-select-option-plain_active___ynHQP_13-5-0:hover{
135
+ body:not(.magritte-old-layout) .magritte-select-option-plain_active___ynHQP_13-6-0:hover{
136
136
  cursor:pointer;
137
137
  }
138
138
  }
139
- .magritte-select-label-option___wyUhk_13-5-0{
139
+ .magritte-select-label-option___wyUhk_13-6-0{
140
140
  display:flex;
141
141
  justify-content:center;
142
142
  }
143
143
 
144
- .magritte-options___E0JN-_13-5-0{
144
+ .magritte-options___E0JN-_13-6-0{
145
145
  display:flex;
146
146
  flex-direction:column;
147
147
  padding:0 16px;
148
148
  padding-bottom:16px;
149
149
  gap:12px;
150
150
  }
151
- .magritte-options_plain___-ihU5_13-5-0{
151
+ .magritte-options_plain___-ihU5_13-6-0{
152
152
  gap:0;
153
153
  }
154
- .magritte-options_desktop___gz7kx_13-5-0{
154
+ .magritte-options_desktop___gz7kx_13-6-0{
155
155
  gap:8px;
156
156
  padding:0;
157
157
  }
158
- .magritte-options_desktop-plain___L0WIC_13-5-0{
158
+ .magritte-options_desktop-plain___L0WIC_13-6-0{
159
159
  gap:16px;
160
160
  }
161
- .magritte-chips___EAQ3O_13-5-0{
161
+ .magritte-chips___EAQ3O_13-6-0{
162
162
  display:flex;
163
163
  flex-wrap:wrap;
164
164
  gap:12px;
165
165
  }
166
- .magritte-chips___EAQ3O_13-5-0:not(:last-child),
167
- .magritte-options___E0JN-_13-5-0:not(:last-child) > .magritte-chips___EAQ3O_13-5-0:last-child{
166
+ .magritte-chips___EAQ3O_13-6-0:not(:last-child),
167
+ .magritte-options___E0JN-_13-6-0:not(:last-child) > .magritte-chips___EAQ3O_13-6-0:last-child{
168
168
  padding-bottom:16px;
169
169
  }
170
170
 
171
- .magritte-select-layout___3THUn_13-5-0{
171
+ .magritte-select-layout___3THUn_13-6-0{
172
172
  display:contents;
173
173
  }
174
174
 
175
- .magritte-anchor___0KOBD_13-5-0{
175
+ .magritte-anchor___0KOBD_13-6-0{
176
176
  position:relative;
177
177
  width:fit-content;
178
178
  }
179
- .magritte-anchor-stretched___h7y6m_13-5-0{
179
+ .magritte-anchor-stretched___h7y6m_13-6-0{
180
180
  width:100%;
181
181
  }
182
- .magritte-default-view___3ptpo_13-5-0{
182
+ .magritte-default-view___3ptpo_13-6-0{
183
183
  min-width:0;
184
184
  }
185
- .magritte-input-view___ZeEKh_13-5-0{
185
+ .magritte-input-view___ZeEKh_13-6-0{
186
186
  position:absolute;
187
187
  top:0;
188
188
  left:0;
@@ -190,6 +190,6 @@
190
190
  display:flex;
191
191
  min-width:0;
192
192
  }
193
- .magritte-hidden-view___stvzX_13-5-0{
193
+ .magritte-hidden-view___stvzX_13-6-0{
194
194
  visibility:hidden;
195
195
  }
package/index.js CHANGED
@@ -62,6 +62,9 @@ import './internal/OptionControl.js';
62
62
  import '@hh.ru/magritte-ui-checkbox-radio';
63
63
  import './internal/focusOrchestrator.js';
64
64
  import './internal/useAutoSelectOnBlur.js';
65
+ import './internal/useCustomOptions.js';
66
+ import '@hh.ru/magritte-common-fuzzy-search';
67
+ import './internal/CustomValuesContext.js';
65
68
  import './SelectSearchTrigger.js';
66
69
  import '@hh.ru/magritte-ui-input/BaseInput';
67
70
  import './internal/NavigationManagement.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/index.mock.js CHANGED
@@ -20,6 +20,9 @@ import './internal/focusOrchestrator.js';
20
20
  import './internal/slots.js';
21
21
  import '@hh.ru/magritte-internal-slot-registry';
22
22
  import './internal/SearchStateContext.js';
23
+ import './internal/useCustomOptions.js';
24
+ import '@hh.ru/magritte-common-fuzzy-search';
25
+ import './internal/CustomValuesContext.js';
23
26
  import './internal/SelectDataProvider.js';
24
27
  import '@hh.ru/magritte-common-data-provider';
25
28
  import './internal/useDataProvider.js';
package/index.mock.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mock.js","sources":["src/index.mock.ts"],"sourcesContent":["import { mockComponent } from '@hh.ru/magritte-ui-mock-component';\n\nconst withChildren = { withChildren: true };\n\nconst ApplyChangesButton = mockComponent('SelectApplyChangesButton', undefined, withChildren);\nconst BottomSheet = mockComponent('SelectBottomSheet', undefined, withChildren);\nconst PickerCloseIcon = mockComponent('SelectPickerCloseIcon');\nconst BottomSheetHeader = mockComponent('SelectBottomSheetHeader');\nconst ClearButton = mockComponent('SelectClearButton', undefined, withChildren);\nconst ClearCard = mockComponent('SelectClearCard', undefined, withChildren);\nconst Drop = mockComponent('SelectDrop', undefined, withChildren);\nconst EmptyHint = mockComponent('SelectEmptyHint', undefined, withChildren);\nconst Options = mockComponent('SelectOptions');\nconst PickerProvider = mockComponent('SelectPickerProvider', undefined, withChildren);\nconst SearchInput = mockComponent('SelectSearchInput');\nconst SearchTrigger = mockComponent('SelectSearchTrigger');\nconst Trigger = mockComponent('SelectTrigger');\n\nconst SELECT_COMPONENTS = {\n ApplyChangesButton,\n BottomSheet,\n PickerCloseIcon,\n BottomSheetHeader,\n ClearButton,\n ClearCard,\n Drop,\n EmptyHint,\n Options,\n PickerProvider,\n SearchInput,\n SearchTrigger,\n Trigger,\n};\n\n// core компоненты\nexport const Select = Object.assign(mockComponent('Select', undefined, withChildren), SELECT_COMPONENTS);\nexport const UncontrolledSelect = Object.assign(\n mockComponent('UncontrolledSelect', undefined, withChildren),\n SELECT_COMPONENTS\n);\n\n// хуки для кастома\nexport { useSelectTrigger, useTriggerRef } from '@hh.ru/magritte-ui-select/useSelectTrigger';\nexport { useSearchState, type SearchContextValue } from '@hh.ru/magritte-ui-select/useSearchState';\nexport { useSelectContentState, type SelectContentState } from '@hh.ru/magritte-ui-select/useSelectContentState';\nexport { useDataProvider, type UseDataProvider } from '@hh.ru/magritte-ui-select/useDataProvider';\nexport { useVisibility } from '@hh.ru/magritte-ui-select/useVisibility';\nexport { useSelectError } from '@hh.ru/magritte-ui-select/useSelectError';\nexport { useSelectHint } from '@hh.ru/magritte-ui-select/useSelectHint';\nexport { useSelectPicker, useSelectUnsavedChangesAlert } from '@hh.ru/magritte-ui-select/SelectPickerContext';\nexport { usePickerRef } from '@hh.ru/magritte-ui-select/usePickerRef';\nexport { useSelectConfig } from '@hh.ru/magritte-ui-select/useSelectConfig';\n\n// свойства списка опций и кастомный layout опции\nexport type {\n OptionsProps,\n OptionCustomLayoutComponent,\n OptionCustomLayoutProps,\n OnChangeAction,\n} from '@hh.ru/magritte-ui-select/SelectOptions';\n\nexport type {\n SelectProps,\n UncontrolledSelectProps,\n SelectOptionType,\n SelectOption,\n SelectControlledTriggerProps,\n SelectUncontrolledTriggerProps,\n OptionsCount,\n OnOptionsChangeCallback,\n} from '@hh.ru/magritte-ui-select/types';\n\n// legacy компоненты\n/** @deprecated Адаптер старого API */\nexport const SelectLegacy = mockComponent('SelectLegacy');\n/** @deprecated Адаптер старого API */\nexport const UncontrolledSelectLegacy = mockComponent('UncontrolledSelect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cAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA;AAAA,EACA,OAAA;AACJ,CAAA,CAAA;AAGa,MAAA,MAAA,GAAS,OAAO,MAAO,CAAA,aAAA,CAAc,UAAU,KAAW,CAAA,EAAA,YAAY,GAAG,iBAAiB,EAAA;AAChG,MAAM,qBAAqB,MAAO,CAAA,MAAA;AAAA,EACrC,aAAA,CAAc,oBAAsB,EAAA,KAAA,CAAA,EAAW,YAAY,CAAA;AAAA,EAC3D,iBAAA;AACJ,EAAA;AAmCa,MAAA,YAAA,GAAe,cAAc,cAAc,EAAA;AAE3C,MAAA,wBAAA,GAA2B,cAAc,0BAA0B;;;;"}
1
+ {"version":3,"file":"index.mock.js","sources":["src/index.mock.ts"],"sourcesContent":["import { mockComponent } from '@hh.ru/magritte-ui-mock-component';\n\nconst withChildren = { withChildren: true };\n\nconst ApplyChangesButton = mockComponent('SelectApplyChangesButton', undefined, withChildren);\nconst BottomSheet = mockComponent('SelectBottomSheet', undefined, withChildren);\nconst PickerCloseIcon = mockComponent('SelectPickerCloseIcon');\nconst BottomSheetHeader = mockComponent('SelectBottomSheetHeader');\nconst ClearButton = mockComponent('SelectClearButton', undefined, withChildren);\nconst ClearCard = mockComponent('SelectClearCard', undefined, withChildren);\nconst Drop = mockComponent('SelectDrop', undefined, withChildren);\nconst EmptyHint = mockComponent('SelectEmptyHint', undefined, withChildren);\nconst Options = mockComponent('SelectOptions');\nconst PickerProvider = mockComponent('SelectPickerProvider', undefined, withChildren);\nconst SearchInput = mockComponent('SelectSearchInput');\nconst SearchTrigger = mockComponent('SelectSearchTrigger');\nconst Trigger = mockComponent('SelectTrigger');\n\nconst SELECT_COMPONENTS = {\n ApplyChangesButton,\n BottomSheet,\n PickerCloseIcon,\n BottomSheetHeader,\n ClearButton,\n ClearCard,\n Drop,\n EmptyHint,\n Options,\n PickerProvider,\n SearchInput,\n SearchTrigger,\n Trigger,\n};\n\n// core компоненты\nexport const Select = Object.assign(mockComponent('Select', undefined, withChildren), SELECT_COMPONENTS);\nexport const UncontrolledSelect = Object.assign(\n mockComponent('UncontrolledSelect', undefined, withChildren),\n SELECT_COMPONENTS\n);\n\n// хуки для кастома\nexport { useSelectTrigger, useTriggerRef } from '@hh.ru/magritte-ui-select/useSelectTrigger';\nexport { useSearchState, type SearchContextValue } from '@hh.ru/magritte-ui-select/useSearchState';\nexport { useSelectContentState, type SelectContentState } from '@hh.ru/magritte-ui-select/useSelectContentState';\nexport { useDataProvider, type UseDataProvider } from '@hh.ru/magritte-ui-select/useDataProvider';\nexport { useVisibility } from '@hh.ru/magritte-ui-select/useVisibility';\nexport { useSelectError } from '@hh.ru/magritte-ui-select/useSelectError';\nexport { useSelectHint } from '@hh.ru/magritte-ui-select/useSelectHint';\nexport { useSelectPicker, useSelectUnsavedChangesAlert } from '@hh.ru/magritte-ui-select/SelectPickerContext';\nexport { usePickerRef } from '@hh.ru/magritte-ui-select/usePickerRef';\nexport { useSelectConfig } from '@hh.ru/magritte-ui-select/useSelectConfig';\n\n// свойства списка опций и кастомный layout опции\nexport type {\n OptionsProps,\n OptionCustomLayoutComponent,\n OptionCustomLayoutProps,\n OnChangeAction,\n} from '@hh.ru/magritte-ui-select/SelectOptions';\n\nexport type {\n SelectProps,\n UncontrolledSelectProps,\n SelectOptionType,\n SelectOption,\n SelectControlledTriggerProps,\n SelectUncontrolledTriggerProps,\n OptionsCount,\n OnOptionsChangeCallback,\n} from '@hh.ru/magritte-ui-select/types';\n\n// legacy компоненты\n/** @deprecated Адаптер старого API */\nexport const SelectLegacy = mockComponent('SelectLegacy');\n/** @deprecated Адаптер старого API */\nexport const UncontrolledSelectLegacy = mockComponent('UncontrolledSelectLegacy');\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,YAAA,GAAe,EAAE,YAAA,EAAc,IAAK,EAAA,CAAA;AAE1C,MAAM,kBAAqB,GAAA,aAAA,CAAc,0BAA4B,EAAA,KAAA,CAAA,EAAW,YAAY,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qB,MAAO,CAAA,MAAA;AAAA,EACrC,aAAA,CAAc,oBAAsB,EAAA,KAAA,CAAA,EAAW,YAAY,CAAA;AAAA,EAC3D,iBAAA;AACJ,EAAA;AAmCa,MAAA,YAAA,GAAe,cAAc,cAAc,EAAA;AAE3C,MAAA,wBAAA,GAA2B,cAAc,0BAA0B;;;;"}
@@ -8,6 +8,10 @@ interface ConfigContextBaseProps {
8
8
  loading?: boolean;
9
9
  onSelectValidator?: (value: StaticDataFetcherItem) => boolean;
10
10
  autoSelectOnBlur?: boolean;
11
+ allowsCustomValues?: boolean;
12
+ customValueMinChars: number;
13
+ createCustomValue: (text: string) => StaticDataFetcherItem;
14
+ customValueMatcher: (query: string, value: StaticDataFetcherItem) => boolean;
11
15
  }
12
16
  export interface ConfigContextProps extends ConfigContextBaseProps {
13
17
  hasExternalError: boolean;
@@ -26,5 +30,5 @@ export interface HintContextProps {
26
30
  export declare const ConfigContext: import("react").Context<ConfigContextProps | null>;
27
31
  export declare const ErrorContext: import("react").Context<ErrorContextProps | null>;
28
32
  export declare const HintContext: import("react").Context<HintContextProps | null>;
29
- export declare const ConfigProvider: ({ children, maxSelectedOptions, multiple, name, loading, onSelectValidator, autoSelectOnBlur, error, providerError, emptyHint, emptySearchHint, }: ConfigContextBaseProps & ErrorContextProps & HintContextProps & PropsWithChildren) => ReactElement;
33
+ export declare const ConfigProvider: ({ children, maxSelectedOptions, multiple, name, loading, onSelectValidator, autoSelectOnBlur, allowsCustomValues, customValueMinChars, createCustomValue, customValueMatcher, error, providerError, emptyHint, emptySearchHint, }: ConfigContextBaseProps & ErrorContextProps & HintContextProps & PropsWithChildren) => ReactElement;
30
34
  export {};
@@ -13,6 +13,10 @@ const ConfigProvider = ({
13
13
  loading,
14
14
  onSelectValidator,
15
15
  autoSelectOnBlur,
16
+ allowsCustomValues,
17
+ customValueMinChars,
18
+ createCustomValue,
19
+ customValueMatcher,
16
20
  error,
17
21
  providerError,
18
22
  emptyHint,
@@ -30,6 +34,10 @@ const ConfigProvider = ({
30
34
  loading,
31
35
  onSelectValidator,
32
36
  autoSelectOnBlur,
37
+ allowsCustomValues,
38
+ customValueMinChars,
39
+ createCustomValue,
40
+ customValueMatcher,
33
41
  hasExternalError,
34
42
  hasProviderError,
35
43
  hasEmptyHint,
@@ -42,6 +50,10 @@ const ConfigProvider = ({
42
50
  loading,
43
51
  onSelectValidator,
44
52
  autoSelectOnBlur,
53
+ allowsCustomValues,
54
+ customValueMinChars,
55
+ createCustomValue,
56
+ customValueMatcher,
45
57
  hasExternalError,
46
58
  hasProviderError,
47
59
  hasEmptyHint,
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigContext.js","sources":["src/internal/ConfigContext.tsx"],"sourcesContent":["import { createContext, useMemo, type ReactElement, PropsWithChildren, ReactNode } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { ErrorState, ProviderErrorState } from '@hh.ru/magritte-ui-select/types';\n\ninterface ConfigContextBaseProps {\n maxSelectedOptions?: number;\n multiple?: boolean;\n name?: string;\n loading?: boolean;\n onSelectValidator?: (value: StaticDataFetcherItem) => boolean;\n autoSelectOnBlur?: boolean;\n}\n\nexport interface ConfigContextProps extends ConfigContextBaseProps {\n hasExternalError: boolean;\n hasProviderError: boolean;\n hasEmptyHint: boolean;\n hasEmptySearchHint: boolean;\n}\n\nexport interface ErrorContextProps {\n error?: ErrorState;\n providerError?: ProviderErrorState;\n}\n\nexport interface HintContextProps {\n emptyHint?: ReactNode;\n emptySearchHint?: ReactNode;\n}\n\nexport const ConfigContext = createContext<ConfigContextProps | null>(null);\n\nexport const ErrorContext = createContext<ErrorContextProps | null>(null);\n\nexport const HintContext = createContext<HintContextProps | null>(null);\n\n// провайдер внешних/глобальных свойств select\nexport const ConfigProvider = ({\n children,\n maxSelectedOptions,\n multiple,\n name,\n loading,\n onSelectValidator,\n autoSelectOnBlur,\n error,\n providerError,\n emptyHint,\n emptySearchHint,\n}: ConfigContextBaseProps & ErrorContextProps & HintContextProps & PropsWithChildren): ReactElement => {\n // свойства-примитивы\n const hasExternalError = Boolean(error);\n const hasProviderError = Boolean(providerError);\n const hasEmptyHint = Boolean(emptyHint);\n const hasEmptySearchHint = Boolean(emptySearchHint);\n const configValue = useMemo<ConfigContextProps>(\n () => ({\n maxSelectedOptions,\n multiple,\n name,\n loading,\n onSelectValidator,\n autoSelectOnBlur,\n hasExternalError,\n hasProviderError,\n hasEmptyHint,\n hasEmptySearchHint,\n }),\n [\n maxSelectedOptions,\n multiple,\n name,\n loading,\n onSelectValidator,\n autoSelectOnBlur,\n hasExternalError,\n hasProviderError,\n hasEmptyHint,\n hasEmptySearchHint,\n ]\n );\n\n // свойства-обьекты ошибок (используются в компонентах ошибок/bs)\n const errorValue = useMemo<ErrorContextProps>(\n () => ({\n error,\n providerError,\n }),\n // providerError добавляем как перечисление свойств, а не весь обьект\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [error, providerError?.title, providerError?.description, providerError?.reloadButton]\n );\n\n // свойства-обьекты подсказок (используются в компонентах подсказок)\n const hintValue = useMemo<HintContextProps>(\n () => ({\n emptyHint,\n emptySearchHint,\n }),\n [emptyHint, emptySearchHint]\n );\n\n return (\n <ConfigContext.Provider value={configValue}>\n <ErrorContext.Provider value={errorValue}>\n <HintContext.Provider value={hintValue}>{children}</HintContext.Provider>\n </ErrorContext.Provider>\n </ConfigContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;AA+Ba,MAAA,aAAA,GAAgB,cAAyC,IAAI,EAAA;AAE7D,MAAA,YAAA,GAAe,cAAwC,IAAI,EAAA;AAE3D,MAAA,WAAA,GAAc,cAAuC,IAAI,EAAA;AAG/D,MAAM,iBAAiB,CAAC;AAAA,EAC3B,QAAA;AAAA,EACA,kBAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;AAAA,EACA,KAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA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sB,OAAO,UAC1B,EAAA,QAAA,kBAAA,GAAA,CAAC,YAAY,QAAZ,EAAA,EAAqB,OAAO,SAAY,EAAA,QAAA,EAAS,GACtD,CACJ,EAAA,CAAA,CAAA;AAER;;;;"}
1
+ {"version":3,"file":"ConfigContext.js","sources":["src/internal/ConfigContext.tsx"],"sourcesContent":["import { createContext, useMemo, type ReactElement, PropsWithChildren, ReactNode } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\nimport { ErrorState, ProviderErrorState } from '@hh.ru/magritte-ui-select/types';\n\ninterface ConfigContextBaseProps {\n maxSelectedOptions?: number;\n multiple?: boolean;\n name?: string;\n loading?: boolean;\n onSelectValidator?: (value: StaticDataFetcherItem) => boolean;\n autoSelectOnBlur?: boolean;\n allowsCustomValues?: boolean;\n customValueMinChars: number;\n createCustomValue: (text: string) => StaticDataFetcherItem;\n customValueMatcher: (query: string, value: StaticDataFetcherItem) => boolean;\n}\n\nexport interface ConfigContextProps extends ConfigContextBaseProps {\n hasExternalError: boolean;\n hasProviderError: boolean;\n hasEmptyHint: boolean;\n hasEmptySearchHint: boolean;\n}\n\nexport interface ErrorContextProps {\n error?: ErrorState;\n providerError?: ProviderErrorState;\n}\n\nexport interface HintContextProps {\n emptyHint?: ReactNode;\n emptySearchHint?: ReactNode;\n}\n\nexport const ConfigContext = createContext<ConfigContextProps | null>(null);\n\nexport const ErrorContext = createContext<ErrorContextProps | null>(null);\n\nexport const HintContext = createContext<HintContextProps | null>(null);\n\n// провайдер внешних/глобальных свойств select\nexport const ConfigProvider = ({\n children,\n maxSelectedOptions,\n multiple,\n name,\n loading,\n onSelectValidator,\n autoSelectOnBlur,\n allowsCustomValues,\n customValueMinChars,\n createCustomValue,\n customValueMatcher,\n error,\n providerError,\n emptyHint,\n emptySearchHint,\n}: ConfigContextBaseProps & ErrorContextProps & HintContextProps & PropsWithChildren): ReactElement => {\n // свойства-примитивы\n const hasExternalError = Boolean(error);\n const hasProviderError = Boolean(providerError);\n const hasEmptyHint = Boolean(emptyHint);\n const hasEmptySearchHint = Boolean(emptySearchHint);\n const configValue = useMemo<ConfigContextProps>(\n () => ({\n maxSelectedOptions,\n multiple,\n name,\n loading,\n onSelectValidator,\n autoSelectOnBlur,\n allowsCustomValues,\n customValueMinChars,\n createCustomValue,\n customValueMatcher,\n hasExternalError,\n hasProviderError,\n hasEmptyHint,\n hasEmptySearchHint,\n }),\n [\n maxSelectedOptions,\n multiple,\n name,\n loading,\n onSelectValidator,\n autoSelectOnBlur,\n allowsCustomValues,\n customValueMinChars,\n createCustomValue,\n customValueMatcher,\n hasExternalError,\n hasProviderError,\n hasEmptyHint,\n hasEmptySearchHint,\n ]\n );\n\n // свойства-обьекты ошибок (используются в компонентах ошибок/bs)\n const errorValue = useMemo<ErrorContextProps>(\n () => ({\n error,\n providerError,\n }),\n // providerError добавляем как перечисление свойств, а не весь обьект\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [error, providerError?.title, providerError?.description, providerError?.reloadButton]\n );\n\n // свойства-обьекты подсказок (используются в компонентах подсказок)\n const hintValue = useMemo<HintContextProps>(\n () => ({\n emptyHint,\n emptySearchHint,\n }),\n [emptyHint, emptySearchHint]\n );\n\n return (\n <ConfigContext.Provider value={configValue}>\n <ErrorContext.Provider value={errorValue}>\n <HintContext.Provider value={hintValue}>{children}</HintContext.Provider>\n </ErrorContext.Provider>\n </ConfigContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;AAmCa,MAAA,aAAA,GAAgB,cAAyC,IAAI,EAAA;AAE7D,MAAA,YAAA,GAAe,cAAwC,IAAI,EAAA;AAE3D,MAAA,WAAA,GAAc,cAAuC,IAAI,EAAA;AAG/D,MAAM,iBAAiB,CAAC;AAAA,EAC3B,QAAA;AAAA,EACA,kBAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,iBAAA;AAAA,EACA,gBAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA,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O;AAAA,MACH,SAAA;AAAA,MACA,eAAA;AAAA,KACJ,CAAA;AAAA,IACA,CAAC,WAAW,eAAe,CAAA;AAAA,GAC/B,CAAA;AAEA,EACI,uBAAA,GAAA,CAAC,cAAc,QAAd,EAAA,EAAuB,OAAO,WAC3B,EAAA,QAAA,kBAAA,GAAA,CAAC,aAAa,QAAb,EAAA,EAAsB,OAAO,UAC1B,EAAA,QAAA,kBAAA,GAAA,CAAC,YAAY,QAAZ,EAAA,EAAqB,OAAO,SAAY,EAAA,QAAA,EAAS,GACtD,CACJ,EAAA,CAAA,CAAA;AAER;;;;"}
@@ -0,0 +1,4 @@
1
+ import { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';
2
+ export type CustomValues = Map<string, StaticDataFetcherItem>;
3
+ export declare const CustomValuesContext: import("react").Context<CustomValues | null>;
4
+ export declare const useCustomValues: <DataType extends StaticDataFetcherItem>() => Map<string, DataType> | null;
@@ -0,0 +1,10 @@
1
+ import './../index.css';
2
+ import { createContext, useContext } from 'react';
3
+
4
+ const CustomValuesContext = createContext(null);
5
+ const useCustomValues = () => {
6
+ return useContext(CustomValuesContext);
7
+ };
8
+
9
+ export { CustomValuesContext, useCustomValues };
10
+ //# sourceMappingURL=CustomValuesContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomValuesContext.js","sources":["src/internal/CustomValuesContext.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nimport { StaticDataFetcherItem } from '@hh.ru/magritte-common-data-provider';\n\n// история принятых (вернувшихся через value) значений из пользовательского ввода (allowsCustomValues)\n// снятие выбора их не удаляет, живут, пока смонтирован Select\nexport type CustomValues = Map<string, StaticDataFetcherItem>;\n\nexport const CustomValuesContext = createContext<CustomValues | null>(null);\n\nexport const useCustomValues = <DataType extends StaticDataFetcherItem>(): Map<string, DataType> | null => {\n return useContext(CustomValuesContext) as Map<string, DataType> | null;\n};\n"],"names":[],"mappings":";;AAQa,MAAA,mBAAA,GAAsB,cAAmC,IAAI,EAAA;AAEnE,MAAM,kBAAkB,MAA4E;AACvG,EAAA,OAAO,WAAW,mBAAmB,CAAA,CAAA;AACzC;;;;"}