@consta/uikit 5.29.2 → 5.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FileCanary/index.d.ts +1 -0
- package/FileCanary/index.js +1 -0
- package/__internal__/src/components/AutoComplete/AutoComplete.js +1 -1
- package/__internal__/src/components/AutoComplete/AutoComplete.js.map +1 -1
- package/__internal__/src/components/AutoComplete/helpers.d.ts +1 -0
- package/__internal__/src/components/AutoComplete/types.d.ts +1 -0
- package/__internal__/src/components/AutoComplete/types.js.map +1 -1
- package/__internal__/src/components/AutoCompleteCanary/AutoCompleteTypeText/AutoCompleteTypeText.js +1 -1
- package/__internal__/src/components/AutoCompleteCanary/AutoCompleteTypeText/AutoCompleteTypeText.js.map +1 -1
- package/__internal__/src/components/AutoCompleteCanary/AutoCompleteTypeTextArray/AutoCompleteTypeTextArray.js +1 -1
- package/__internal__/src/components/AutoCompleteCanary/AutoCompleteTypeTextArray/AutoCompleteTypeTextArray.js.map +1 -1
- package/__internal__/src/components/AutoCompleteCanary/helpers.d.ts +1 -0
- package/__internal__/src/components/AutoCompleteCanary/types.d.ts +1 -0
- package/__internal__/src/components/AutoCompleteCanary/types.js.map +1 -1
- package/__internal__/src/components/Combobox/Combobox.js +1 -1
- package/__internal__/src/components/Combobox/Combobox.js.map +1 -1
- package/__internal__/src/components/Combobox/helpers.d.ts +3 -1
- package/__internal__/src/components/Combobox/helpers.js.map +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.js +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuLevelWrapper/ContextMenuLevelWrapper.js.map +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.js +1 -1
- package/__internal__/src/components/ContextMenu/ContextMenuWrapper/ContextMenuWrapper.js.map +1 -1
- package/__internal__/src/components/ContextMenu/helpers.d.ts +4 -2
- package/__internal__/src/components/ContextMenu/types.d.ts +3 -0
- package/__internal__/src/components/ContextMenu/types.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerDropdown/DatePickerDropdown.d.ts +1 -0
- package/__internal__/src/components/DatePicker/DatePickerDropdown/DatePickerDropdown.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerDropdown/DatePickerDropdown.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDate/DatePickerTypeDate.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDate/DatePickerTypeDate.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateRange/DatePickerTypeDateRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateRange/DatePickerTypeDateRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTime/DatePickerTypeDateTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeDateTimeRange/DatePickerTypeDateTimeRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeMonth/DatePickerTypeMonth.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeMonth/DatePickerTypeMonth.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeMonthRange/DatePickerTypeMonthRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeMonthRange/DatePickerTypeMonthRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeTime/DatePickerTypeTime.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeYear/DatePickerTypeYear.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeYear/DatePickerTypeYear.js.map +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeYearRange/DatePickerTypeYearRange.js +1 -1
- package/__internal__/src/components/DatePicker/DatePickerTypeYearRange/DatePickerTypeYearRange.js.map +1 -1
- package/__internal__/src/components/DatePicker/types.d.ts +1 -0
- package/__internal__/src/components/DatePicker/types.js.map +1 -1
- package/__internal__/src/components/FileCanary/FileCanary.d.ts +1 -0
- package/__internal__/src/components/FileCanary/FileCanary.js +2 -0
- package/__internal__/src/components/FileCanary/FileCanary.js.map +1 -0
- package/__internal__/src/components/FileCanary/FileCanaryBase/FileCanaryBase.css +1 -0
- package/__internal__/src/components/FileCanary/FileCanaryBase/FileCanaryBase.d.ts +4 -0
- package/__internal__/src/components/FileCanary/FileCanaryBase/FileCanaryBase.js +2 -0
- package/__internal__/src/components/FileCanary/FileCanaryBase/FileCanaryBase.js.map +1 -0
- package/__internal__/src/components/FileCanary/config.d.ts +2 -0
- package/__internal__/src/components/FileCanary/config.js +2 -0
- package/__internal__/src/components/FileCanary/config.js.map +1 -0
- package/__internal__/src/components/FileCanary/fileCanaryGenerator.d.ts +2 -0
- package/__internal__/src/components/FileCanary/fileCanaryGenerator.js +2 -0
- package/__internal__/src/components/FileCanary/fileCanaryGenerator.js.map +1 -0
- package/__internal__/src/components/FileCanary/index.d.ts +4 -0
- package/__internal__/src/components/FileCanary/index.js +2 -0
- package/__internal__/src/components/FileCanary/index.js.map +1 -0
- package/__internal__/src/components/FileCanary/types.d.ts +25 -0
- package/__internal__/src/components/FileCanary/types.js +2 -0
- package/__internal__/src/components/FileCanary/types.js.map +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelect.js +1 -1
- package/__internal__/src/components/FlatSelect/FlatSelect.js.map +1 -1
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.js +1 -1
- package/__internal__/src/components/FlatSelect/FlatSelectRoot/FlatSelectRoot.js.map +1 -1
- package/__internal__/src/components/FlatSelect/types.d.ts +1 -0
- package/__internal__/src/components/FlatSelect/types.js.map +1 -1
- package/__internal__/src/components/Select/Select.js +1 -1
- package/__internal__/src/components/Select/Select.js.map +1 -1
- package/__internal__/src/components/Select/helpers.d.ts +3 -1
- package/__internal__/src/components/Select/helpers.js.map +1 -1
- package/__internal__/src/components/SelectCanary/SelectDropdown/SelectDropdown.d.ts +1 -0
- package/__internal__/src/components/SelectCanary/SelectDropdown/SelectDropdown.js +1 -1
- package/__internal__/src/components/SelectCanary/SelectDropdown/SelectDropdown.js.map +1 -1
- package/__internal__/src/components/SelectCanary/SelectMultiple/SelectMultiple.js +1 -1
- package/__internal__/src/components/SelectCanary/SelectMultiple/SelectMultiple.js.map +1 -1
- package/__internal__/src/components/SelectCanary/SelectMultiple/__test__/SelectMultiple.test.js +1 -1
- package/__internal__/src/components/SelectCanary/SelectMultiple/__test__/SelectMultiple.test.js.map +1 -1
- package/__internal__/src/components/SelectCanary/SelectPopover/SelectPopover.d.ts +1 -0
- package/__internal__/src/components/SelectCanary/SelectPopover/SelectPopover.js +1 -1
- package/__internal__/src/components/SelectCanary/SelectPopover/SelectPopover.js.map +1 -1
- package/__internal__/src/components/SelectCanary/SelectSingle/SelectSingle.js +1 -1
- package/__internal__/src/components/SelectCanary/SelectSingle/SelectSingle.js.map +1 -1
- package/__internal__/src/components/SelectCanary/SelectSingle/__test__/SelectSingle.test.js +1 -1
- package/__internal__/src/components/SelectCanary/SelectSingle/__test__/SelectSingle.test.js.map +1 -1
- package/__internal__/src/components/SelectCanary/helpers.d.ts +2 -1
- package/__internal__/src/components/SelectCanary/types.d.ts +1 -0
- package/__internal__/src/components/SelectCanary/types.js.map +1 -1
- package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.d.ts +1 -0
- package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js +1 -1
- package/__internal__/src/components/SelectComponents/SelectDropdown/SelectDropdown.js.map +1 -1
- package/__internal__/src/components/Theme/_font/Silkscreen-Regular.woff +0 -0
- package/__internal__/src/components/Theme/_font/Silkscreen-Regular.woff2 +0 -0
- package/__internal__/src/components/Theme/_font/Theme_font_gpnDefault.css +1 -1
- package/__internal__/src/components/UserSelect/UserSelect.js +1 -1
- package/__internal__/src/components/UserSelect/UserSelect.js.map +1 -1
- package/__internal__/src/components/UserSelect/helpers.d.ts +3 -1
- package/__internal__/src/components/UserSelect/helpers.js.map +1 -1
- package/__internal__/src/hooks/useBodyScrollFreeze/index.d.ts +1 -0
- package/__internal__/src/hooks/useBodyScrollFreeze/index.js +2 -0
- package/__internal__/src/hooks/useBodyScrollFreeze/index.js.map +1 -0
- package/__internal__/src/hooks/useBodyScrollFreeze/useBodyScrollFreeze.css +1 -0
- package/__internal__/src/hooks/useBodyScrollFreeze/useBodyScrollFreeze.d.ts +6 -0
- package/__internal__/src/hooks/useBodyScrollFreeze/useBodyScrollFreeze.js +2 -0
- package/__internal__/src/hooks/useBodyScrollFreeze/useBodyScrollFreeze.js.map +1 -0
- package/__internal__/src/hooks/useHover/index.d.ts +1 -0
- package/__internal__/src/hooks/useHover/index.js +2 -0
- package/__internal__/src/hooks/useHover/index.js.map +1 -0
- package/__internal__/src/hooks/useHover/useHover.d.ts +9 -0
- package/__internal__/src/hooks/useHover/useHover.js +2 -0
- package/__internal__/src/hooks/useHover/useHover.js.map +1 -0
- package/package.json +2 -2
- package/useBodyScrollFreeze/index.d.ts +1 -0
- package/useBodyScrollFreeze/index.js +1 -0
- package/useHover/index.d.ts +1 -0
- package/useHover/index.js +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":["IconSelect","React","forwardRef","useRef","usePropsHandler","cnSelect","COMPONENT_NAME","defaultLabelForEmptyItems","SelectContainer","SelectDropdown","SelectItem","defaultPropForm","defaultPropSize","defaultPropView","useSelect","useForkRef","isNotNil","iconSizeMap","withDefaultGetters","SelectRender","props","ref","defaultDropdownRef","controlRef","placeholder","onBlur","onFocus","items","onChange","value","required","disabled","ariaLabel","id","dropdownRef","form","view","size","dropdownClassName","name","groups","getItemLabel","labelForEmptyItems","getItemKey","getItemGroupKey","getItemDisabled","getGroupKey","getGroupLabel","renderItem","isLoading","renderValueProp","renderValue","inputRefProp","inputRef","style","dropdownForm","onDropdownOpen","onScrollToBottom","virtualScroll","dropdownOpen","ignoreOutsideClicksRefs","dropdownViewportRef","restProps","multiple","getKeyProps","getOptionProps","isOpen","visibleItems","isFocused","handleInputFocus","handleInputBlur","handleToggleDropdown","handleInputClick","notFound","hasItems","optionsRefs","inputId","renderValueDefault","label","item","renderItemDefault","active","hovered","onClick","onMouseEnter","zIndex","Select"],"sources":["../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import '##/components/SelectComponents/Select.css';\n\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport React, { forwardRef, useRef } from 'react';\n\nimport { usePropsHandler } from '##/components/EventInterceptor/usePropsHandler';\nimport {\n cnSelect,\n COMPONENT_NAME,\n} from '##/components/SelectComponents/cnSelect';\nimport { defaultLabelForEmptyItems } from '##/components/SelectComponents/helpers';\nimport { SelectContainer } from '##/components/SelectComponents/SelectContainer';\nimport { SelectDropdown } from '##/components/SelectComponents/SelectDropdown';\nimport { SelectItem } from '##/components/SelectComponents/SelectItem';\nimport {\n defaultPropForm,\n defaultPropSize,\n defaultPropView,\n} from '##/components/SelectComponents/types';\nimport { useSelect } from '##/components/SelectComponents/useSelect';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { isNotNil } from '##/utils/type-guards';\n\nimport {\n iconSizeMap,\n PropRenderItem,\n PropRenderValue,\n SelectComponent,\n SelectGroupDefault,\n SelectItemDefault,\n SelectProps,\n withDefaultGetters,\n} from './helpers';\n\nconst SelectRender = <ITEM = SelectItemDefault, GROUP = SelectGroupDefault>(\n props: SelectProps<ITEM, GROUP>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const defaultDropdownRef = useRef<HTMLDivElement>(null);\n const controlRef = useRef<HTMLDivElement | null>(null);\n\n const {\n placeholder,\n onBlur,\n onFocus,\n items,\n onChange,\n value,\n required,\n disabled,\n ariaLabel,\n id,\n dropdownRef,\n form = defaultPropForm,\n view = defaultPropView,\n size = defaultPropSize,\n dropdownClassName,\n name,\n groups = [],\n getItemLabel,\n labelForEmptyItems = defaultLabelForEmptyItems,\n getItemKey,\n getItemGroupKey,\n getItemDisabled,\n getGroupKey,\n getGroupLabel,\n renderItem,\n isLoading,\n renderValue: renderValueProp,\n inputRef: inputRefProp,\n style,\n dropdownForm = 'default',\n onDropdownOpen,\n onScrollToBottom,\n virtualScroll,\n dropdownOpen,\n ignoreOutsideClicksRefs,\n dropdownViewportRef,\n ...restProps\n } = usePropsHandler(COMPONENT_NAME, withDefaultGetters(props), controlRef);\n\n const {\n getKeyProps,\n getOptionProps,\n isOpen,\n visibleItems,\n isFocused,\n handleInputFocus,\n handleInputBlur,\n handleToggleDropdown,\n inputRef,\n handleInputClick,\n notFound,\n hasItems,\n optionsRefs,\n } = useSelect<ITEM, GROUP, false>({\n items,\n groups,\n value,\n onChange,\n dropdownRef: defaultDropdownRef,\n controlRef,\n disabled,\n getItemLabel,\n getItemKey,\n getGroupKey,\n getItemGroupKey,\n getItemDisabled,\n multiple: false,\n onBlur,\n onFocus,\n onDropdownOpen,\n dropdownOpen,\n ignoreOutsideClicksRefs,\n });\n\n const inputId = id ? `${id}-input` : id;\n\n const renderItemDefault: PropRenderItem<ITEM> = (props) => {\n const { item, active, hovered, onClick, onMouseEnter, ref } = props;\n\n return (\n <SelectItem\n label={getItemLabel(item)}\n active={active}\n hovered={hovered}\n multiple={false}\n size={size}\n indent={dropdownForm === 'round' ? 'increased' : 'normal'}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n disabled={getItemDisabled(item)}\n ref={ref}\n />\n );\n };\n\n const renderValueDefault: PropRenderValue<ITEM> = (props) => {\n const label = getItemLabel(props.item);\n\n return (\n <span className={cnSelect('ControlValue')} title={label}>\n {label}\n </span>\n );\n };\n\n const renderValue = renderValueProp || renderValueDefault;\n\n return (\n <>\n <SelectContainer\n focused={isFocused}\n disabled={disabled}\n size={size}\n view={view}\n form={form}\n required={required}\n ref={ref}\n style={style}\n id={inputId}\n {...restProps}\n >\n <div\n className={cnSelect('Control')}\n ref={controlRef}\n aria-expanded={isOpen}\n aria-haspopup=\"listbox\"\n id={id}\n >\n <div className={cnSelect('ControlInner')}>\n <div className={cnSelect('ControlValueContainer')}>\n <input\n {...getKeyProps()}\n className={cnSelect('FakeField')}\n type=\"text\"\n name={name}\n id={inputId}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n aria-label={ariaLabel}\n onClick={handleInputClick}\n ref={useForkRef([inputRef, inputRefProp])}\n readOnly\n />\n {isNotNil(value) && renderValue({ item: value })}\n {!isNotNil(value) && placeholder && (\n <span className={cnSelect('Placeholder')} title=\"placeholder\">\n {placeholder}\n </span>\n )}\n </div>\n </div>\n <span className={cnSelect('Indicators')}>\n <button\n type=\"button\"\n className={cnSelect('IndicatorsDropdown')}\n tabIndex={-1}\n onClick={handleToggleDropdown}\n >\n <IconSelect\n size={iconSizeMap[size]}\n className={cnSelect('DropdownIndicatorIcon')}\n />\n </button>\n </span>\n </div>\n </SelectContainer>\n <SelectDropdown\n isOpen={isOpen}\n size={size}\n controlRef={controlRef}\n getOptionProps={getOptionProps}\n dropdownRef={useForkRef([dropdownRef, defaultDropdownRef])}\n form={dropdownForm}\n className={dropdownClassName}\n renderItem={renderItem || renderItemDefault}\n getGroupLabel={getGroupLabel}\n visibleItems={visibleItems}\n notFound={notFound}\n isLoading={isLoading}\n labelForEmptyItems={labelForEmptyItems}\n hasItems={hasItems}\n itemsRefs={optionsRefs}\n virtualScroll={virtualScroll}\n onScrollToBottom={onScrollToBottom}\n viewportRef={dropdownViewportRef}\n style={\n typeof style?.zIndex === 'number'\n ? { zIndex: style.zIndex + 1 }\n : undefined\n }\n />\n </>\n );\n};\n\nexport const Select = forwardRef(SelectRender) as SelectComponent;\n\nexport * from './helpers';\n"],"mappings":"8jBAAA,uCAEA,OAASA,UAAT,KAA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CAA8D/D,CAA9D,CAA+B+D,OAA/B,CAAwCC,CAAxC,CAA8DhE,CAA9D,CAAwCgE,YAAxC,CAAsD/D,CAAtD,CAA8DD,CAA9D,CAAsDC,GAAtD,CAEA,MACE,qBAAC,UAAD,EACE,KAAK,CAAEoB,CAAY,CAACsC,CAAD,CADrB,CAEE,MAAM,CAAEE,CAFV,CAGE,OAAO,CAAEC,CAHX,CAIE,QAAQ,GAJV,CAKE,IAAI,CAAE7C,CALR,CAME,MAAM,CAAmB,OAAjB,GAAAkB,CAAY,CAAe,WAAf,CAA6B,QANnD,CAOE,OAAO,CAAE4B,CAPX,CAQE,YAAY,CAAEC,CARhB,CASE,QAAQ,CAAEvC,CAAe,CAACkC,CAAD,CAT3B,CAUE,GAAG,CAAE1D,CAVP,EAaH,CAyEG,CASE,aAAa,CAAE0B,CATjB,CAUE,YAAY,CAAEoB,CAVhB,CAWE,QAAQ,CAAEM,EAXZ,CAYE,SAAS,CAAExB,CAZb,CAaE,kBAAkB,CAAEP,CAbtB,CAcE,QAAQ,CAAEgC,EAdZ,CAeE,SAAS,CAAEC,EAfb,CAgBE,aAAa,CAAEjB,CAhBjB,CAiBE,gBAAgB,CAAED,CAjBpB,CAkBE,WAAW,CAAEI,CAlBf,CAmBE,KAAK,CACsB,QAAzB,gBAAOP,CAAP,WAAOA,CAAP,QAAOA,CAAK,CAAE+B,MAAd,EACI,CAAEA,MAAM,CAAE/B,CAAK,CAAC+B,MAAN,CAAe,CAAzB,CADJ,OApBJ,EA1DF,CAqFH,CAzMD,CA2MA,MAAO,IAAMC,OAAM,CAAGpF,UAAU,CAACiB,YAAD,CAAzB,CAEP"}
|
|
1
|
+
{"version":3,"file":"Select.js","names":["IconSelect","React","forwardRef","useRef","usePropsHandler","cnSelect","COMPONENT_NAME","defaultLabelForEmptyItems","SelectContainer","SelectDropdown","SelectItem","defaultPropForm","defaultPropSize","defaultPropView","useSelect","useForkRef","isNotNil","iconSizeMap","withDefaultGetters","SelectRender","props","ref","defaultDropdownRef","controlRef","placeholder","onBlur","onFocus","items","onChange","value","required","disabled","ariaLabel","id","dropdownRef","form","view","size","dropdownClassName","name","groups","getItemLabel","labelForEmptyItems","getItemKey","getItemGroupKey","getItemDisabled","getGroupKey","getGroupLabel","renderItem","isLoading","renderValueProp","renderValue","inputRefProp","inputRef","style","dropdownForm","onDropdownOpen","onScrollToBottom","virtualScroll","dropdownOpen","ignoreOutsideClicksRefs","dropdownViewportRef","dropdownContainer","restProps","multiple","getKeyProps","getOptionProps","isOpen","visibleItems","isFocused","handleInputFocus","handleInputBlur","handleToggleDropdown","handleInputClick","notFound","hasItems","optionsRefs","inputId","renderValueDefault","label","item","renderItemDefault","active","hovered","onClick","onMouseEnter","zIndex","Select"],"sources":["../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import '##/components/SelectComponents/Select.css';\n\nimport { IconSelect } from '@consta/icons/IconSelect';\nimport React, { forwardRef, useRef } from 'react';\n\nimport { usePropsHandler } from '##/components/EventInterceptor/usePropsHandler';\nimport {\n cnSelect,\n COMPONENT_NAME,\n} from '##/components/SelectComponents/cnSelect';\nimport { defaultLabelForEmptyItems } from '##/components/SelectComponents/helpers';\nimport { SelectContainer } from '##/components/SelectComponents/SelectContainer';\nimport { SelectDropdown } from '##/components/SelectComponents/SelectDropdown';\nimport { SelectItem } from '##/components/SelectComponents/SelectItem';\nimport {\n defaultPropForm,\n defaultPropSize,\n defaultPropView,\n} from '##/components/SelectComponents/types';\nimport { useSelect } from '##/components/SelectComponents/useSelect';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { isNotNil } from '##/utils/type-guards';\n\nimport {\n iconSizeMap,\n PropRenderItem,\n PropRenderValue,\n SelectComponent,\n SelectGroupDefault,\n SelectItemDefault,\n SelectProps,\n withDefaultGetters,\n} from './helpers';\n\nconst SelectRender = <ITEM = SelectItemDefault, GROUP = SelectGroupDefault>(\n props: SelectProps<ITEM, GROUP>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const defaultDropdownRef = useRef<HTMLDivElement>(null);\n const controlRef = useRef<HTMLDivElement | null>(null);\n\n const {\n placeholder,\n onBlur,\n onFocus,\n items,\n onChange,\n value,\n required,\n disabled,\n ariaLabel,\n id,\n dropdownRef,\n form = defaultPropForm,\n view = defaultPropView,\n size = defaultPropSize,\n dropdownClassName,\n name,\n groups = [],\n getItemLabel,\n labelForEmptyItems = defaultLabelForEmptyItems,\n getItemKey,\n getItemGroupKey,\n getItemDisabled,\n getGroupKey,\n getGroupLabel,\n renderItem,\n isLoading,\n renderValue: renderValueProp,\n inputRef: inputRefProp,\n style,\n dropdownForm = 'default',\n onDropdownOpen,\n onScrollToBottom,\n virtualScroll,\n dropdownOpen,\n ignoreOutsideClicksRefs,\n dropdownViewportRef,\n dropdownContainer,\n ...restProps\n } = usePropsHandler(COMPONENT_NAME, withDefaultGetters(props), controlRef);\n\n const {\n getKeyProps,\n getOptionProps,\n isOpen,\n visibleItems,\n isFocused,\n handleInputFocus,\n handleInputBlur,\n handleToggleDropdown,\n inputRef,\n handleInputClick,\n notFound,\n hasItems,\n optionsRefs,\n } = useSelect<ITEM, GROUP, false>({\n items,\n groups,\n value,\n onChange,\n dropdownRef: defaultDropdownRef,\n controlRef,\n disabled,\n getItemLabel,\n getItemKey,\n getGroupKey,\n getItemGroupKey,\n getItemDisabled,\n multiple: false,\n onBlur,\n onFocus,\n onDropdownOpen,\n dropdownOpen,\n ignoreOutsideClicksRefs,\n });\n\n const inputId = id ? `${id}-input` : id;\n\n const renderItemDefault: PropRenderItem<ITEM> = (props) => {\n const { item, active, hovered, onClick, onMouseEnter, ref } = props;\n\n return (\n <SelectItem\n label={getItemLabel(item)}\n active={active}\n hovered={hovered}\n multiple={false}\n size={size}\n indent={dropdownForm === 'round' ? 'increased' : 'normal'}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n disabled={getItemDisabled(item)}\n ref={ref}\n />\n );\n };\n\n const renderValueDefault: PropRenderValue<ITEM> = (props) => {\n const label = getItemLabel(props.item);\n\n return (\n <span className={cnSelect('ControlValue')} title={label}>\n {label}\n </span>\n );\n };\n\n const renderValue = renderValueProp || renderValueDefault;\n\n return (\n <>\n <SelectContainer\n focused={isFocused}\n disabled={disabled}\n size={size}\n view={view}\n form={form}\n required={required}\n ref={ref}\n style={style}\n id={inputId}\n {...restProps}\n >\n <div\n className={cnSelect('Control')}\n ref={controlRef}\n aria-expanded={isOpen}\n aria-haspopup=\"listbox\"\n id={id}\n >\n <div className={cnSelect('ControlInner')}>\n <div className={cnSelect('ControlValueContainer')}>\n <input\n {...getKeyProps()}\n className={cnSelect('FakeField')}\n type=\"text\"\n name={name}\n id={inputId}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n aria-label={ariaLabel}\n onClick={handleInputClick}\n ref={useForkRef([inputRef, inputRefProp])}\n readOnly\n />\n {isNotNil(value) && renderValue({ item: value })}\n {!isNotNil(value) && placeholder && (\n <span className={cnSelect('Placeholder')} title=\"placeholder\">\n {placeholder}\n </span>\n )}\n </div>\n </div>\n <span className={cnSelect('Indicators')}>\n <button\n type=\"button\"\n className={cnSelect('IndicatorsDropdown')}\n tabIndex={-1}\n onClick={handleToggleDropdown}\n >\n <IconSelect\n size={iconSizeMap[size]}\n className={cnSelect('DropdownIndicatorIcon')}\n />\n </button>\n </span>\n </div>\n </SelectContainer>\n <SelectDropdown\n isOpen={isOpen}\n size={size}\n controlRef={controlRef}\n getOptionProps={getOptionProps}\n dropdownRef={useForkRef([dropdownRef, defaultDropdownRef])}\n form={dropdownForm}\n className={dropdownClassName}\n renderItem={renderItem || renderItemDefault}\n getGroupLabel={getGroupLabel}\n visibleItems={visibleItems}\n notFound={notFound}\n isLoading={isLoading}\n labelForEmptyItems={labelForEmptyItems}\n hasItems={hasItems}\n itemsRefs={optionsRefs}\n virtualScroll={virtualScroll}\n onScrollToBottom={onScrollToBottom}\n viewportRef={dropdownViewportRef}\n container={dropdownContainer}\n style={\n typeof style?.zIndex === 'number'\n ? { zIndex: style.zIndex + 1 }\n : undefined\n }\n />\n </>\n );\n};\n\nexport const Select = forwardRef(SelectRender) as SelectComponent;\n\nexport * from './helpers';\n"],"mappings":"klBAAA,uCAEA,OAASA,UAAT,KAA2B,0BAA3B,CACA,MAAOC,MAAP,EAAgBC,UAAhB,CAA4BC,MAA5B,KAA0C,OAA1C,CAEA,OAASC,eAAT,2CACA,OACEC,QADF,CAEEC,cAFF,oCAIA,OAASC,yBAAT,mCACA,OAASC,eAAT,2CACA,OAASC,cAAT,0CACA,OAASC,UAAT,sCACA,OACEC,eADF,CAEEC,eAFF,CAGEC,eAHF,iCAKA,OAASC,SAAT,qCACA,OAASC,UAAT,8BACA,OAASC,QAAT,+BAEA,OACEC,WADF,CAQEC,kBARF,iBAWA,GAAMC,aAAY,CAAG,SACnBC,CADmB,CAEnBC,CAFmB,CAGhB,IACGC,EAAkB,CAAGnB,MAAM,CAAiB,IAAjB,CAD9B,CAEGoB,CAAU,CAAGpB,MAAM,CAAwB,IAAxB,CAFtB,GA2CCC,eAAe,CAACE,cAAD,CAAiBY,kBAAkB,CAACE,CAAD,CAAnC,CAA4CG,CAA5C,CA3ChB,CAKDC,CALC,GAKDA,WALC,CAMDC,CANC,GAMDA,MANC,CAODC,CAPC,GAODA,OAPC,CAQDC,CARC,GAQDA,KARC,CASDC,CATC,GASDA,QATC,CAUDC,CAVC,GAUDA,KAVC,CAWDC,CAXC,GAWDA,QAXC,CAYDC,CAZC,GAYDA,QAZC,CAaDC,CAbC,GAaDA,SAbC,CAcDC,CAdC,GAcDA,EAdC,CAeDC,CAfC,GAeDA,WAfC,KAgBDC,IAhBC,CAgBDA,CAhBC,YAgBMxB,eAhBN,OAiBDyB,IAjBC,CAiBDA,CAjBC,YAiBMvB,eAjBN,OAkBDwB,IAlBC,CAkBDA,CAlBC,YAkBMzB,eAlBN,GAmBD0B,CAnBC,GAmBDA,iBAnBC,CAoBDC,CApBC,GAoBDA,IApBC,KAqBDC,MArBC,CAqBDA,CArBC,YAqBQ,EArBR,GAsBD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ectProps<ITEM = SelectItemDefault, GROUP = SelectGroupDefault> =
|
|
|
68
68
|
dropdownOpen?: boolean;
|
|
69
69
|
ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;
|
|
70
70
|
dropdownViewportRef?: React.RefObject<HTMLElement>;
|
|
71
|
+
dropdownContainer?: Element;
|
|
71
72
|
}, HTMLDivElement> & (ITEM extends {
|
|
72
73
|
label: SelectItemDefault['label'];
|
|
73
74
|
} ? {} : {
|
|
@@ -133,7 +134,8 @@ export declare function withDefaultGetters<ITEM, GROUP>(props: SelectProps<ITEM,
|
|
|
133
134
|
dropdownOpen?: boolean;
|
|
134
135
|
ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;
|
|
135
136
|
dropdownViewportRef?: React.RefObject<HTMLElement>;
|
|
136
|
-
|
|
137
|
+
dropdownContainer?: Element;
|
|
138
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "css" | "onFocus" | "onBlur" | "onChange" | "size" | "view" | "form" | "status" | "caption" | "label" | "name" | "disabled" | "value" | "placeholder" | "required" | "inputRef" | "items" | "dropdownForm" | "focused" | "ariaLabel" | "dropdownClassName" | "dropdownRef" | "isLoading" | "labelForEmptyItems" | "renderItem" | "renderValue" | "groups" | "getItemLabel" | "getItemKey" | "getItemGroupKey" | "getItemDisabled" | "getGroupLabel" | "getGroupKey" | "labelIcon" | "labelPosition" | "onScrollToBottom" | "onDropdownOpen" | "dropdownOpen" | "ignoreOutsideClicksRefs" | "virtualScroll" | "dropdownViewportRef" | "dropdownContainer"> & React.RefAttributes<HTMLDivElement> & (ITEM extends {
|
|
137
139
|
label: SelectItemDefault["label"];
|
|
138
140
|
} ? {} : {
|
|
139
141
|
getItemLabel: SelectPropGetItemLabel<ITEM>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["defaultGetItemKey","item","id","defaultGetItemLabel","label","defaultGetItemGroupKey","groupId","defaultGetItemDisabled","disabled","defaultGetGroupKey","group","defaultGetGroupLabel","withDefaultGetters","props","getItemLabel","getItemKey","getItemGroupKey","getItemDisabled","getGroupLabel","getGroupKey","iconSizeMap","xs","s","m","l"],"sources":["../../../../../src/components/Select/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\nimport {\n PropForm,\n PropSize,\n PropStatus,\n PropView,\n RenderItemProps,\n} from '../SelectComponents/types';\n\nexport type SelectItemDefault = {\n label: string;\n id: string | number;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type SelectGroupDefault = {\n label: string;\n id: string | number;\n};\n\ntype SelectPropValue<ITEM> = ITEM | null | undefined;\n\ntype SelectRenderValueProps<ITEM> = {\n item: ITEM;\n};\n\nexport type SelectPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type SelectPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type SelectPropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type SelectPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type SelectPropGetGroupKey<GROUP> = (group: GROUP) => string | number;\nexport type SelectPropGetGroupLabel<GROUP> = (group: GROUP) => string;\nexport type PropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactNode | null;\nexport type PropRenderValue<ITEM> = (\n props: SelectRenderValueProps<ITEM>,\n) => React.ReactNode | null;\n\nexport type SelectPropOnChange<ITEM> = (\n value: ITEM | null,\n props: { e: React.SyntheticEvent },\n) => void;\n\nexport type SelectProps<\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n onChange: SelectPropOnChange<ITEM>;\n disabled?: boolean;\n form?: PropForm;\n dropdownForm?: 'default' | 'brick' | 'round';\n size?: PropSize;\n view?: PropView;\n status?: PropStatus;\n focused?: boolean;\n placeholder?: string;\n ariaLabel?: string;\n dropdownClassName?: string;\n dropdownRef?: React.RefObject<HTMLDivElement>;\n required?: boolean;\n name?: string;\n isLoading?: boolean;\n labelForEmptyItems?: string;\n value?: SelectPropValue<ITEM>;\n renderItem?: PropRenderItem<ITEM>;\n renderValue?: PropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n inputRef?: React.RefObject<HTMLInputElement>;\n groups?: GROUP[];\n getItemLabel?: SelectPropGetItemLabel<ITEM>;\n getItemKey?: SelectPropGetItemKey<ITEM>;\n getItemGroupKey?: SelectPropGetItemGroupKey<ITEM>;\n getItemDisabled?: SelectPropGetItemDisabled<ITEM>;\n getGroupLabel?: SelectPropGetGroupLabel<GROUP>;\n getGroupKey?: SelectPropGetGroupKey<GROUP>;\n label?: string;\n labelIcon?: IconComponent;\n labelPosition?: 'top' | 'left';\n caption?: string;\n virtualScroll?: boolean;\n onScrollToBottom?: (length: number) => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n dropdownViewportRef?: React.RefObject<HTMLElement>;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: SelectItemDefault['label'] }\n ? {}\n : { getItemLabel: SelectPropGetItemLabel<ITEM> }) &\n (ITEM extends { id: SelectItemDefault['id'] }\n ? {}\n : { getItemKey: SelectPropGetItemKey<ITEM> }) &\n (GROUP extends { label: SelectGroupDefault['label'] }\n ? {}\n : { getGroupLabel: SelectPropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: SelectGroupDefault['id'] }\n ? {}\n : { getGroupKey: SelectPropGetGroupKey<GROUP> });\n\nexport type SelectComponent = <\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n>(\n props: SelectProps<ITEM, GROUP>,\n) => React.ReactNode | null;\n\nexport const defaultGetItemKey: SelectPropGetItemKey<SelectItemDefault> = (\n item,\n) => item.id;\nexport const defaultGetItemLabel: SelectPropGetItemLabel<SelectItemDefault> = (\n item,\n) => item.label;\nexport const defaultGetItemGroupKey: SelectPropGetItemGroupKey<\n SelectItemDefault\n> = (item) => item.groupId;\nexport const defaultGetItemDisabled: SelectPropGetItemDisabled<\n SelectItemDefault\n> = (item) => item.disabled;\n\nexport const defaultGetGroupKey: SelectPropGetGroupKey<SelectGroupDefault> = (\n group,\n) => group.id;\nexport const defaultGetGroupLabel: SelectPropGetGroupLabel<\n SelectGroupDefault\n> = (group) => group.label;\n\nexport function withDefaultGetters<ITEM, GROUP>(\n props: SelectProps<ITEM, GROUP>,\n) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemKey: props.getItemKey || defaultGetItemKey,\n getItemGroupKey: props.getItemGroupKey || defaultGetItemGroupKey,\n getItemDisabled: props.getItemDisabled || defaultGetItemDisabled,\n getGroupLabel: props.getGroupLabel || defaultGetGroupLabel,\n getGroupKey: props.getGroupKey || defaultGetGroupKey,\n };\n}\n\nexport const iconSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["defaultGetItemKey","item","id","defaultGetItemLabel","label","defaultGetItemGroupKey","groupId","defaultGetItemDisabled","disabled","defaultGetGroupKey","group","defaultGetGroupLabel","withDefaultGetters","props","getItemLabel","getItemKey","getItemGroupKey","getItemDisabled","getGroupLabel","getGroupKey","iconSizeMap","xs","s","m","l"],"sources":["../../../../../src/components/Select/helpers.ts"],"sourcesContent":["import { IconComponent, IconPropSize } from '@consta/icons/Icon';\nimport React from 'react';\n\nimport { PropsWithHTMLAttributesAndRef } from '../../utils/types/PropsWithHTMLAttributes';\nimport {\n PropForm,\n PropSize,\n PropStatus,\n PropView,\n RenderItemProps,\n} from '../SelectComponents/types';\n\nexport type SelectItemDefault = {\n label: string;\n id: string | number;\n groupId?: string | number;\n disabled?: boolean;\n};\n\nexport type SelectGroupDefault = {\n label: string;\n id: string | number;\n};\n\ntype SelectPropValue<ITEM> = ITEM | null | undefined;\n\ntype SelectRenderValueProps<ITEM> = {\n item: ITEM;\n};\n\nexport type SelectPropGetItemLabel<ITEM> = (item: ITEM) => string;\nexport type SelectPropGetItemKey<ITEM> = (item: ITEM) => string | number;\nexport type SelectPropGetItemGroupKey<ITEM> = (\n item: ITEM,\n) => string | number | undefined;\nexport type SelectPropGetItemDisabled<ITEM> = (\n item: ITEM,\n) => boolean | undefined;\nexport type SelectPropGetGroupKey<GROUP> = (group: GROUP) => string | number;\nexport type SelectPropGetGroupLabel<GROUP> = (group: GROUP) => string;\nexport type PropRenderItem<ITEM> = (\n props: RenderItemProps<ITEM>,\n) => React.ReactNode | null;\nexport type PropRenderValue<ITEM> = (\n props: SelectRenderValueProps<ITEM>,\n) => React.ReactNode | null;\n\nexport type SelectPropOnChange<ITEM> = (\n value: ITEM | null,\n props: { e: React.SyntheticEvent },\n) => void;\n\nexport type SelectProps<\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n> = PropsWithHTMLAttributesAndRef<\n {\n items: ITEM[];\n onChange: SelectPropOnChange<ITEM>;\n disabled?: boolean;\n form?: PropForm;\n dropdownForm?: 'default' | 'brick' | 'round';\n size?: PropSize;\n view?: PropView;\n status?: PropStatus;\n focused?: boolean;\n placeholder?: string;\n ariaLabel?: string;\n dropdownClassName?: string;\n dropdownRef?: React.RefObject<HTMLDivElement>;\n required?: boolean;\n name?: string;\n isLoading?: boolean;\n labelForEmptyItems?: string;\n value?: SelectPropValue<ITEM>;\n renderItem?: PropRenderItem<ITEM>;\n renderValue?: PropRenderValue<ITEM>;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n inputRef?: React.RefObject<HTMLInputElement>;\n groups?: GROUP[];\n getItemLabel?: SelectPropGetItemLabel<ITEM>;\n getItemKey?: SelectPropGetItemKey<ITEM>;\n getItemGroupKey?: SelectPropGetItemGroupKey<ITEM>;\n getItemDisabled?: SelectPropGetItemDisabled<ITEM>;\n getGroupLabel?: SelectPropGetGroupLabel<GROUP>;\n getGroupKey?: SelectPropGetGroupKey<GROUP>;\n label?: string;\n labelIcon?: IconComponent;\n labelPosition?: 'top' | 'left';\n caption?: string;\n virtualScroll?: boolean;\n onScrollToBottom?: (length: number) => void;\n onDropdownOpen?: (isOpen: boolean) => void;\n dropdownOpen?: boolean;\n ignoreOutsideClicksRefs?: ReadonlyArray<React.RefObject<HTMLElement>>;\n dropdownViewportRef?: React.RefObject<HTMLElement>;\n dropdownContainer?: Element;\n },\n HTMLDivElement\n> &\n (ITEM extends { label: SelectItemDefault['label'] }\n ? {}\n : { getItemLabel: SelectPropGetItemLabel<ITEM> }) &\n (ITEM extends { id: SelectItemDefault['id'] }\n ? {}\n : { getItemKey: SelectPropGetItemKey<ITEM> }) &\n (GROUP extends { label: SelectGroupDefault['label'] }\n ? {}\n : { getGroupLabel: SelectPropGetGroupLabel<GROUP> }) &\n (GROUP extends { id: SelectGroupDefault['id'] }\n ? {}\n : { getGroupKey: SelectPropGetGroupKey<GROUP> });\n\nexport type SelectComponent = <\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n>(\n props: SelectProps<ITEM, GROUP>,\n) => React.ReactNode | null;\n\nexport const defaultGetItemKey: SelectPropGetItemKey<SelectItemDefault> = (\n item,\n) => item.id;\nexport const defaultGetItemLabel: SelectPropGetItemLabel<SelectItemDefault> = (\n item,\n) => item.label;\nexport const defaultGetItemGroupKey: SelectPropGetItemGroupKey<\n SelectItemDefault\n> = (item) => item.groupId;\nexport const defaultGetItemDisabled: SelectPropGetItemDisabled<\n SelectItemDefault\n> = (item) => item.disabled;\n\nexport const defaultGetGroupKey: SelectPropGetGroupKey<SelectGroupDefault> = (\n group,\n) => group.id;\nexport const defaultGetGroupLabel: SelectPropGetGroupLabel<\n SelectGroupDefault\n> = (group) => group.label;\n\nexport function withDefaultGetters<ITEM, GROUP>(\n props: SelectProps<ITEM, GROUP>,\n) {\n return {\n ...props,\n getItemLabel: props.getItemLabel || defaultGetItemLabel,\n getItemKey: props.getItemKey || defaultGetItemKey,\n getItemGroupKey: props.getItemGroupKey || defaultGetItemGroupKey,\n getItemDisabled: props.getItemDisabled || defaultGetItemDisabled,\n getGroupLabel: props.getGroupLabel || defaultGetGroupLabel,\n getGroupKey: props.getGroupKey || defaultGetGroupKey,\n };\n}\n\nexport const iconSizeMap: Record<PropSize, IconPropSize> = {\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'm',\n};\n"],"mappings":"qqBAyHA,MAAO,IAAMA,kBAA0D,CAAG,SACxEC,CADwE,QAErEA,EAAI,CAACC,EAFgE,CAAnE,CAGP,MAAO,IAAMC,oBAA8D,CAAG,SAC5EF,CAD4E,QAEzEA,EAAI,CAACG,KAFoE,CAAvE,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACJ,CAAD,QAAUA,EAAI,CAACK,OAAf,CAFG,CAGP,MAAO,IAAMC,uBAEZ,CAAG,SAACN,CAAD,QAAUA,EAAI,CAACO,QAAf,CAFG,CAIP,MAAO,IAAMC,mBAA6D,CAAG,SAC3EC,CAD2E,QAExEA,EAAK,CAACR,EAFkE,CAAtE,CAGP,MAAO,IAAMS,qBAEZ,CAAG,SAACD,CAAD,QAAWA,EAAK,CAACN,KAAjB,CAFG,CAIP,MAAO,SAASQ,mBAAT,CACLC,CADK,CAEL,CACA,sCACKA,CADL,MAEEC,YAAY,CAAED,CAAK,CAACC,YAAN,EAAsBX,mBAFtC,CAGEY,UAAU,CAAEF,CAAK,CAACE,UAAN,EAAoBf,iBAHlC,CAIEgB,eAAe,CAAEH,CAAK,CAACG,eAAN,EAAyBX,sBAJ5C,CAKEY,eAAe,CAAEJ,CAAK,CAACI,eAAN,EAAyBV,sBAL5C,CAMEW,aAAa,CAAEL,CAAK,CAACK,aAAN,EAAuBP,oBANxC,CAOEQ,WAAW,CAAEN,CAAK,CAACM,WAAN,EAAqBV,kBAPpC,EASD,CAED,MAAO,IAAMW,YAA2C,CAAG,CACzDC,EAAE,CAAE,IADqD,CAEzDC,CAAC,CAAE,GAFsD,CAGzDC,CAAC,CAAE,GAHsD,CAIzDC,CAAC,CAAE,GAJsD,CAApD"}
|
|
@@ -49,6 +49,7 @@ type Props<ITEM, GROUP> = PropsWithJsxAttributes<{
|
|
|
49
49
|
dropdownZIndexAtom: AtomMut<number | undefined>;
|
|
50
50
|
selectAllLabel: string;
|
|
51
51
|
viewportRef?: React.RefObject<HTMLElement>;
|
|
52
|
+
container?: Element;
|
|
52
53
|
}>;
|
|
53
54
|
type SelectDropdownComponent = <ITEM, GROUP>(props: Props<ITEM, GROUP>) => React.ReactNode | null;
|
|
54
55
|
export declare const SelectDropdown: SelectDropdownComponent;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["controlRef","size","getOptionActions","dropdownRef","labelForCreate","className","labelForNotFound","labelForEmptyItems","hasItemsAtom","form","openAtom","offset","renderItem","visibleItemsAtom","isLoading","getGroupLabel","notFound","itemsRefs","virtualScroll","onScrollToBottom","highlightedIndexAtom","valueAtom","getItemKeyAtom","highlightIndex","onCreate","onChange","onChangeAll","inputValueAtom","groupsCounterAtom","dropdownZIndexAtom","selectAllLabel"];import"./SelectDropdown.css";import{useAtom}from"@reatom/npm-react";import React,{Fragment,memo,useMemo}from"react";import{ListItem,ListLoader,mapVerticalSpace}from"../../ListCanary";import{isNotOptionForCreate,isOptionForCreate,isOptionForSelectAll}from"../useSelect";import{forkRef,useForkRef}from"../../../hooks/useForkRef";import{useVirtualScroll}from"../../../hooks/useVirtualScroll";import{cnMixScrollBar}from"../../../mixs/MixScrollBar";import{cnMixSpace}from"../../../mixs/MixSpace";import{cnCanary as cn}from"../../../utils/bem";import{fabricIndex}from"../../../utils/fabricIndex";import{SelectCreateButton}from"../SelectCreateButton/SelectCreateButton";import{SelectGroupLabel}from"../SelectGroupLabel/SelectGroupLabel";import{SelectItemAll}from"../SelectItemAll/SelectItemAll";import{SelectLoader}from"../SelectLoader/SelectLoader";import{SelectPopover}from"../SelectPopover";import{SelectRenderItem}from"../SelectRenderItem";export var selectDropdownForm=["default","brick","round"];export var defaultSelectDropdownPropForm=selectDropdownForm[0];var cnSelectDropdown=cn("SelectDropdown"),getLengthElements=function(a){for(var b=1>=a.length?0:a.length,c=0;c<a.length;c++){var d,e=a[c];isNotOptionForCreate(e)&&null!==e&&void 0!==e&&null!==(d=e.items)&&void 0!==d&&d.length&&(b+=e.items.length)}return b},isVisible=function(a,b){return b>=a[0]&&b<a[1]};export var SelectDropdown=memo(function(a){var b=a.controlRef,c=a.size,d=a.getOptionActions,e=a.dropdownRef,f=a.labelForCreate,g=a.className,h=a.labelForNotFound,i=a.labelForEmptyItems,j=a.hasItemsAtom,k=a.form,l=a.openAtom,m=a.offset,n=void 0===m?"none":m,o=a.renderItem,p=a.visibleItemsAtom,q=a.isLoading,r=a.getGroupLabel,s=a.notFound,t=a.itemsRefs,u=a.virtualScroll,v=a.onScrollToBottom,w=a.highlightedIndexAtom,x=a.valueAtom,y=a.getItemKeyAtom,z=a.highlightIndex,A=a.onCreate,B=a.onChange,C=a.onChangeAll,D=a.inputValueAtom,E=a.groupsCounterAtom,F=a.dropdownZIndexAtom,G=a.selectAllLabel,H=_objectWithoutProperties(a,_excluded),
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["controlRef","size","getOptionActions","dropdownRef","labelForCreate","className","labelForNotFound","labelForEmptyItems","hasItemsAtom","form","openAtom","offset","renderItem","visibleItemsAtom","isLoading","getGroupLabel","notFound","itemsRefs","virtualScroll","onScrollToBottom","highlightedIndexAtom","valueAtom","getItemKeyAtom","highlightIndex","onCreate","onChange","onChangeAll","inputValueAtom","groupsCounterAtom","dropdownZIndexAtom","selectAllLabel","container"];import"./SelectDropdown.css";import{useAtom}from"@reatom/npm-react";import React,{Fragment,memo,useMemo}from"react";import{ListItem,ListLoader,mapVerticalSpace}from"../../ListCanary";import{isNotOptionForCreate,isOptionForCreate,isOptionForSelectAll}from"../useSelect";import{forkRef,useForkRef}from"../../../hooks/useForkRef";import{useVirtualScroll}from"../../../hooks/useVirtualScroll";import{cnMixScrollBar}from"../../../mixs/MixScrollBar";import{cnMixSpace}from"../../../mixs/MixSpace";import{cnCanary as cn}from"../../../utils/bem";import{fabricIndex}from"../../../utils/fabricIndex";import{SelectCreateButton}from"../SelectCreateButton/SelectCreateButton";import{SelectGroupLabel}from"../SelectGroupLabel/SelectGroupLabel";import{SelectItemAll}from"../SelectItemAll/SelectItemAll";import{SelectLoader}from"../SelectLoader/SelectLoader";import{SelectPopover}from"../SelectPopover";import{SelectRenderItem}from"../SelectRenderItem";export var selectDropdownForm=["default","brick","round"];export var defaultSelectDropdownPropForm=selectDropdownForm[0];var cnSelectDropdown=cn("SelectDropdown"),getLengthElements=function(a){for(var b=1>=a.length?0:a.length,c=0;c<a.length;c++){var d,e=a[c];isNotOptionForCreate(e)&&null!==e&&void 0!==e&&null!==(d=e.items)&&void 0!==d&&d.length&&(b+=e.items.length)}return b},isVisible=function(a,b){return b>=a[0]&&b<a[1]};export var SelectDropdown=memo(function(a){var b=a.controlRef,c=a.size,d=a.getOptionActions,e=a.dropdownRef,f=a.labelForCreate,g=a.className,h=a.labelForNotFound,i=a.labelForEmptyItems,j=a.hasItemsAtom,k=a.form,l=a.openAtom,m=a.offset,n=void 0===m?"none":m,o=a.renderItem,p=a.visibleItemsAtom,q=a.isLoading,r=a.getGroupLabel,s=a.notFound,t=a.itemsRefs,u=a.virtualScroll,v=a.onScrollToBottom,w=a.highlightedIndexAtom,x=a.valueAtom,y=a.getItemKeyAtom,z=a.highlightIndex,A=a.onCreate,B=a.onChange,C=a.onChangeAll,D=a.inputValueAtom,E=a.groupsCounterAtom,F=a.dropdownZIndexAtom,G=a.selectAllLabel,H=a.container,I=_objectWithoutProperties(a,_excluded),J=useAtom(p),K=_slicedToArray(J,1),L=K[0],M=useAtom(j),N=_slicedToArray(M,1),O=N[0],P=useAtom(!1),Q=_slicedToArray(P,2),R=Q[0],S=Q[1],T=useAtom(y),U=_slicedToArray(T,1),V=U[0],W="round"===k?"increased":"normal",X=useMemo(function(){return 0<L.filter(function(a){return isOptionForCreate(a)||Array.isArray(a.items)&&0<a.items.length}).length},[L]),Y="none"===n?void 0:n,Z=useMemo(function(){return getLengthElements(L)},[L]),$=useVirtualScroll({length:Z,isActive:u&&R,onScrollToBottom:v}),_=$.spaceTop,aa=$.slice,ba=$.listRefs,ca=$.scrollElementRef,da=useForkRef([ca,e]),ea=0===aa[0]&&u?[0,50]:aa,fa=fabricIndex(),ga=fabricIndex(),ha=useAtom(F),ia=_slicedToArray(ha,1),ja=ia[0];return React.createElement(SelectPopover,Object.assign({},I,{anchorRef:b,offset:Y,role:"listbox",className:cnSelectDropdown(),size:c,controlRef:b,openAtom:l,form:k,onMount:S,style:{zIndex:ja},container:H}),R&&React.createElement("div",{className:cnSelectDropdown("ScrollContainer",[cnMixSpace({pV:mapVerticalSpace[c]}),cnMixScrollBar({size:"xs"})]),ref:da},q&&!X&&React.createElement(SelectLoader,null),React.createElement("div",{className:cnSelectDropdown("List"),key:cnSelectDropdown("List"),style:{marginTop:_}},L.map(function(a){if(isOptionForCreate(a)){var e=fa();return React.createElement(SelectCreateButton,{size:c,key:cnSelectDropdown("List",{key:"CreateButton"}),labelForCreate:f,indent:W,ref:t[e],onClick:A,highlightedIndexAtom:w,inputValueAtom:D,highlightIndex:z,index:e})}var b=1<L.length?ga():0;return React.createElement(Fragment,{key:a.key},a.group&&r&&isVisible(ea,b)&&React.createElement(SelectGroupLabel,{label:r(a.group),size:c,indent:W,ref:ba[b],key:"group-".concat(a.key,"-Label")}),a.items.map(function(b){if(isOptionForSelectAll(b)){var e=ga(),f=fa();if(isVisible(ea,e))return React.createElement(SelectItemAll,Object.assign({label:G,groupId:a.key,highlightedIndexAtom:w,groupsCounterAtom:E,key:cnSelectDropdown("SelectItemAll",{group:a.key}),ref:forkRef([ba[e],t[f]]),indent:W,size:c},d({index:f,item:b}),{index:f}))}else{var g=ga(),h=fa();if(isVisible(ea,g))return React.createElement(SelectRenderItem,Object.assign({key:cnSelectDropdown("SelectRenderItem",{group:a.key,item:V(b)}),getItemKeyAtom:y,highlightedIndexAtom:w,rootRef:forkRef([ba[g],t[h]]),renderItem:o,item:b},d({index:h,item:b}),{index:h,valueAtom:x}))}}))}),q&&X&&React.createElement(ListLoader,{size:c,innerOffset:W})),!q&&!O&&i&&React.createElement(ListItem,{size:c,label:i,innerOffset:W},i)))});
|
|
2
2
|
//# sourceMappingURL=SelectDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectDropdown.js","names":["useAtom","React","Fragment","memo","useMemo","ListItem","ListLoader","mapVerticalSpace","isNotOptionForCreate","isOptionForCreate","isOptionForSelectAll","forkRef","useForkRef","useVirtualScroll","cnMixScrollBar","cnMixSpace","cnCanary","cn","fabricIndex","SelectCreateButton","SelectGroupLabel","SelectItemAll","SelectLoader","SelectPopover","SelectRenderItem","selectDropdownForm","defaultSelectDropdownPropForm","cnSelectDropdown","getLengthElements","elements","length","index","element","items","isVisible","slice","SelectDropdown","props","controlRef","size","getOptionActions","dropdownRefProp","dropdownRef","labelForCreate","className","labelForNotFound","labelForEmptyItems","hasItemsAtom","form","openAtom","offset","offsetProp","renderItem","visibleItemsAtom","isLoading","getGroupLabel","notFound","itemsRefs","virtualScroll","onScrollToBottom","highlightedIndexAtom","valueAtom","getItemKeyAtom","highlightIndex","onCreate","onChange","onChangeAll","inputValueAtom","groupsCounterAtom","dropdownZIndexAtom","selectAllLabel","otherProps","visibleItems","hasItems","isListMount","setIsListMount","getItemKey","indent","isListShowed","filter","group","Array","isArray","lengthForVirtualScroll","isActive","spaceTop","sliceHookProp","listRefs","scrollElementRef","scrollContainerRef","getIndex","getVirtualIndex","zIndex","pV","marginTop","map","key","virtualIndex","item"],"sources":["../../../../../../src/components/SelectCanary/SelectDropdown/SelectDropdown.tsx"],"sourcesContent":["import './SelectDropdown.css';\n\nimport { AtomMut } from '@reatom/framework';\nimport { useAtom } from '@reatom/npm-react';\nimport React, { Fragment, memo, useMemo } from 'react';\n\nimport { FieldPropSize } from '##/components/FieldComponents';\nimport {\n ListItem,\n ListLoader,\n mapVerticalSpace,\n} from '##/components/ListCanary';\nimport { PopoverPropOffset } from '##/components/Popover';\nimport {\n GetOptionPropsResult,\n isNotOptionForCreate,\n isOptionForCreate,\n isOptionForSelectAll,\n OptionForCreate,\n OptionProps,\n} from '##/components/SelectCanary/useSelect';\nimport { forkRef, useForkRef } from '##/hooks/useForkRef';\nimport { useVirtualScroll } from '##/hooks/useVirtualScroll';\nimport { cnMixScrollBar } from '##/mixs/MixScrollBar';\nimport { cnMixSpace } from '##/mixs/MixSpace';\nimport { cnCanary as cn } from '##/utils/bem';\nimport { fabricIndex } from '##/utils/fabricIndex';\nimport { SelectAllItem } from '##/utils/getGroups';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport { SelectCreateButton } from '../SelectCreateButton/SelectCreateButton';\nimport { SelectGroupLabel } from '../SelectGroupLabel/SelectGroupLabel';\nimport { SelectItemAll } from '../SelectItemAll/SelectItemAll';\nimport { SelectLoader } from '../SelectLoader/SelectLoader';\nimport { SelectPopover } from '../SelectPopover';\nimport { SelectRenderItem } from '../SelectRenderItem';\nimport { CountedGroup } from '../types';\n\nexport const selectDropdownForm = ['default', 'brick', 'round'] as const;\nexport type SelectDropdownPropForm = typeof selectDropdownForm[number];\nexport const defaultSelectDropdownPropForm = selectDropdownForm[0];\n\ntype RenderItemProps<ITEM> = {\n item: ITEM;\n active: boolean;\n hovered: boolean;\n onClick: (e: React.MouseEvent) => void;\n onMouseEnter: (e: React.MouseEvent) => void;\n ref: React.Ref<HTMLDivElement>;\n};\n\ntype Props<ITEM, GROUP> = PropsWithJsxAttributes<{\n size: FieldPropSize;\n controlRef: React.MutableRefObject<HTMLDivElement | null>;\n dropdownRef: React.Ref<HTMLDivElement>;\n getOptionActions(props: OptionProps<ITEM>): GetOptionPropsResult;\n form: SelectDropdownPropForm;\n openAtom: AtomMut<boolean>;\n offset?: PopoverPropOffset | 'none';\n isLoading?: boolean;\n renderItem: (props: RenderItemProps<ITEM>) => React.ReactNode | null;\n highlightedIndexAtom: AtomMut<number>;\n visibleItemsAtom: AtomMut<(OptionForCreate | CountedGroup<ITEM, GROUP>)[]>;\n getGroupLabel?: (group: GROUP) => string;\n labelForCreate?:\n | ((label: string | undefined) => React.ReactNode)\n | React.ReactNode;\n labelForNotFound?: string;\n labelForEmptyItems?: string;\n notFound?: boolean;\n hasItemsAtom: AtomMut<boolean>;\n itemsRefs: React.RefObject<HTMLDivElement>[];\n virtualScroll?: boolean;\n onScrollToBottom?: (length: number) => void;\n valueAtom: AtomMut<ITEM[]>;\n getItemKeyAtom: AtomMut<(item: ITEM) => string | number>;\n onChangeAll: (e: React.SyntheticEvent, items: ITEM[]) => void;\n highlightIndex: (index: number) => void;\n onCreate: (e: React.SyntheticEvent) => void;\n onChange: (e: React.SyntheticEvent, item: ITEM) => void;\n inputValueAtom: AtomMut<string>;\n groupsCounterAtom: AtomMut<Record<string, [number, number]>>;\n dropdownZIndexAtom: AtomMut<number | undefined>;\n selectAllLabel: string;\n viewportRef?: React.RefObject<HTMLElement>;\n}>;\n\ntype SelectDropdownComponent = <ITEM, GROUP>(\n props: Props<ITEM, GROUP>,\n) => React.ReactNode | null;\n\nconst cnSelectDropdown = cn('SelectDropdown');\n\nconst getLengthElements = <ITEM, GROUP>(\n elements: (\n | OptionForCreate\n | {\n items: Array<SelectAllItem | ITEM>;\n key: string | number;\n group?: GROUP;\n }\n )[],\n) => {\n let length = elements.length <= 1 ? 0 : elements.length;\n\n for (let index = 0; index < elements.length; index++) {\n const element = elements[index];\n\n if (isNotOptionForCreate(element) && element?.items?.length) {\n length += element.items.length;\n }\n }\n\n return length;\n};\n\nconst isVisible = (slice: [number, number], index: number) => {\n return index >= slice[0] && index < slice[1];\n};\n\nexport const SelectDropdown: SelectDropdownComponent = memo((props) => {\n const {\n controlRef,\n size,\n getOptionActions,\n dropdownRef: dropdownRefProp,\n labelForCreate,\n className,\n labelForNotFound,\n labelForEmptyItems,\n hasItemsAtom,\n form,\n openAtom,\n offset: offsetProp = 'none',\n renderItem,\n visibleItemsAtom,\n isLoading,\n getGroupLabel,\n notFound,\n itemsRefs,\n virtualScroll,\n onScrollToBottom,\n highlightedIndexAtom,\n valueAtom,\n getItemKeyAtom,\n highlightIndex,\n onCreate,\n onChange,\n onChangeAll,\n inputValueAtom,\n groupsCounterAtom,\n dropdownZIndexAtom,\n selectAllLabel,\n ...otherProps\n } = props;\n\n const [visibleItems] = useAtom(visibleItemsAtom);\n\n const [hasItems] = useAtom(hasItemsAtom);\n const [isListMount, setIsListMount] = useAtom(false);\n const [getItemKey] = useAtom(getItemKeyAtom);\n const indent = form === 'round' ? 'increased' : 'normal';\n\n const isListShowed = useMemo(() => {\n return (\n visibleItems.filter(\n (group) =>\n isOptionForCreate(group) ||\n (Array.isArray(group.items) && group.items.length > 0),\n ).length > 0\n );\n }, [visibleItems]);\n\n const offset = offsetProp === 'none' ? undefined : offsetProp;\n\n const lengthForVirtualScroll = useMemo(\n () => getLengthElements(visibleItems),\n [visibleItems],\n );\n\n const {\n spaceTop,\n slice: sliceHookProp,\n listRefs,\n scrollElementRef,\n } = useVirtualScroll({\n length: lengthForVirtualScroll,\n isActive: virtualScroll && isListMount,\n onScrollToBottom,\n });\n\n const scrollContainerRef = useForkRef([scrollElementRef, dropdownRefProp]);\n\n const slice: [number, number] =\n sliceHookProp[0] === 0 && virtualScroll ? [0, 50] : sliceHookProp;\n\n const getIndex = fabricIndex();\n const getVirtualIndex = fabricIndex();\n const [zIndex] = useAtom(dropdownZIndexAtom);\n\n return (\n <SelectPopover\n {...otherProps}\n anchorRef={controlRef}\n offset={offset}\n role=\"listbox\"\n className={cnSelectDropdown()}\n size={size}\n controlRef={controlRef}\n openAtom={openAtom}\n form={form}\n onMount={setIsListMount}\n style={{ zIndex }}\n >\n {isListMount && (\n <div\n className={cnSelectDropdown('ScrollContainer', [\n cnMixSpace({\n pV: mapVerticalSpace[size],\n }),\n cnMixScrollBar({ size: 'xs' }),\n ])}\n ref={scrollContainerRef}\n >\n {isLoading && !isListShowed && <SelectLoader />}\n <div\n className={cnSelectDropdown('List')}\n key={cnSelectDropdown('List')}\n style={{ marginTop: spaceTop }}\n >\n {visibleItems.map((group) => {\n if (isOptionForCreate(group)) {\n const index = getIndex();\n return (\n <SelectCreateButton\n size={size}\n key={cnSelectDropdown('List', { key: 'CreateButton' })}\n labelForCreate={labelForCreate}\n indent={indent}\n ref={itemsRefs[index]}\n onClick={onCreate}\n highlightedIndexAtom={highlightedIndexAtom}\n inputValueAtom={inputValueAtom}\n highlightIndex={highlightIndex}\n index={index}\n />\n );\n }\n\n const virtualIndex =\n visibleItems.length > 1 ? getVirtualIndex() : 0;\n\n return (\n <Fragment key={group.key}>\n {group.group &&\n getGroupLabel &&\n isVisible(slice, virtualIndex) && (\n <SelectGroupLabel\n label={getGroupLabel(group.group)}\n size={size}\n indent={indent}\n ref={listRefs[virtualIndex]}\n key={`group-${group.key}-Label`}\n />\n )}\n {group.items.map((item) => {\n if (isOptionForSelectAll(item)) {\n const virtualIndex = getVirtualIndex();\n const index = getIndex();\n\n if (isVisible(slice, virtualIndex)) {\n return (\n <SelectItemAll\n label={selectAllLabel}\n groupId={group.key}\n highlightedIndexAtom={highlightedIndexAtom}\n groupsCounterAtom={groupsCounterAtom}\n key={cnSelectDropdown('SelectItemAll', {\n group: group.key,\n })}\n ref={forkRef([\n listRefs[virtualIndex],\n itemsRefs[index],\n ])}\n indent={indent}\n size={size}\n {...getOptionActions({\n index,\n item,\n })}\n index={index}\n />\n );\n }\n } else {\n const virtualIndex = getVirtualIndex();\n const index = getIndex();\n if (isVisible(slice, virtualIndex)) {\n return (\n <SelectRenderItem\n key={cnSelectDropdown('SelectRenderItem', {\n group: group.key,\n item: getItemKey(item),\n })}\n getItemKeyAtom={getItemKeyAtom}\n highlightedIndexAtom={highlightedIndexAtom}\n rootRef={forkRef([\n listRefs[virtualIndex],\n itemsRefs[index],\n ])}\n renderItem={renderItem}\n item={item}\n {...getOptionActions({\n index,\n item,\n })}\n index={index}\n valueAtom={valueAtom}\n />\n );\n }\n }\n })}\n </Fragment>\n );\n })}\n {isLoading && isListShowed && (\n <ListLoader size={size} innerOffset={indent} />\n )}\n </div>\n {!isLoading && !hasItems && labelForEmptyItems && (\n <ListItem\n size={size}\n label={labelForEmptyItems}\n innerOffset={indent}\n >\n {labelForEmptyItems}\n </ListItem>\n )}\n </div>\n )}\n </SelectPopover>\n );\n});\n"],"mappings":"onBAAA,6BAGA,OAASA,OAAT,KAAwB,mBAAxB,CACA,MAAOC,MAAP,EAAgBC,QAAhB,CAA0BC,IAA1B,CAAgCC,OAAhC,KAA+C,OAA/C,CAGA,OACEC,QADF,CAEEC,UAFF,CAGEC,gBAHF,wBAMA,OAEEC,oBAFF,CAGEC,iBAHF,CAIEC,oBAJF,oBAQA,OAASC,OAAT,CAAkBC,UAAlB,iCACA,OAASC,gBAAT,uCACA,OAASC,cAAT,kCACA,OAASC,UAAT,8BACA,OAASC,QAAQ,GAAIC,GAArB,0BACA,OAASC,WAAT,kCAIA,OAASC,kBAAT,gDACA,OAASC,gBAAT,4CACA,OAASC,aAAT,sCACA,OAASC,YAAT,oCACA,OAASC,aAAT,wBACA,OAASC,gBAAT,2BAGA,MAAO,IAAMC,mBAAkB,CAAG,CAAC,SAAD,CAAY,OAAZ,CAAqB,OAArB,CAA3B,CAEP,MAAO,IAAMC,8BAA6B,CAAGD,kBAAkB,CAAC,CAAD,CAAxD,C,GAmDDE,iBAAgB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FT,CAGE,WAAW,CAAE+B,CAHf,EAKG/B,CALH,CApHJ,CAdJ,CA8IH,CA/N0D,CAApD"}
|
|
1
|
+
{"version":3,"file":"SelectDropdown.js","names":["useAtom","React","Fragment","memo","useMemo","ListItem","ListLoader","mapVerticalSpace","isNotOptionForCreate","isOptionForCreate","isOptionForSelectAll","forkRef","useForkRef","useVirtualScroll","cnMixScrollBar","cnMixSpace","cnCanary","cn","fabricIndex","SelectCreateButton","SelectGroupLabel","SelectItemAll","SelectLoader","SelectPopover","SelectRenderItem","selectDropdownForm","defaultSelectDropdownPropForm","cnSelectDropdown","getLengthElements","elements","length","index","element","items","isVisible","slice","SelectDropdown","props","controlRef","size","getOptionActions","dropdownRefProp","dropdownRef","labelForCreate","className","labelForNotFound","labelForEmptyItems","hasItemsAtom","form","openAtom","offset","offsetProp","renderItem","visibleItemsAtom","isLoading","getGroupLabel","notFound","itemsRefs","virtualScroll","onScrollToBottom","highlightedIndexAtom","valueAtom","getItemKeyAtom","highlightIndex","onCreate","onChange","onChangeAll","inputValueAtom","groupsCounterAtom","dropdownZIndexAtom","selectAllLabel","container","otherProps","visibleItems","hasItems","isListMount","setIsListMount","getItemKey","indent","isListShowed","filter","group","Array","isArray","lengthForVirtualScroll","isActive","spaceTop","sliceHookProp","listRefs","scrollElementRef","scrollContainerRef","getIndex","getVirtualIndex","zIndex","pV","marginTop","map","key","virtualIndex","item"],"sources":["../../../../../../src/components/SelectCanary/SelectDropdown/SelectDropdown.tsx"],"sourcesContent":["import './SelectDropdown.css';\n\nimport { AtomMut } from '@reatom/framework';\nimport { useAtom } from '@reatom/npm-react';\nimport React, { Fragment, memo, useMemo } from 'react';\n\nimport { FieldPropSize } from '##/components/FieldComponents';\nimport {\n ListItem,\n ListLoader,\n mapVerticalSpace,\n} from '##/components/ListCanary';\nimport { PopoverPropOffset } from '##/components/Popover';\nimport {\n GetOptionPropsResult,\n isNotOptionForCreate,\n isOptionForCreate,\n isOptionForSelectAll,\n OptionForCreate,\n OptionProps,\n} from '##/components/SelectCanary/useSelect';\nimport { forkRef, useForkRef } from '##/hooks/useForkRef';\nimport { useVirtualScroll } from '##/hooks/useVirtualScroll';\nimport { cnMixScrollBar } from '##/mixs/MixScrollBar';\nimport { cnMixSpace } from '##/mixs/MixSpace';\nimport { cnCanary as cn } from '##/utils/bem';\nimport { fabricIndex } from '##/utils/fabricIndex';\nimport { SelectAllItem } from '##/utils/getGroups';\nimport { PropsWithJsxAttributes } from '##/utils/types/PropsWithJsxAttributes';\n\nimport { SelectCreateButton } from '../SelectCreateButton/SelectCreateButton';\nimport { SelectGroupLabel } from '../SelectGroupLabel/SelectGroupLabel';\nimport { SelectItemAll } from '../SelectItemAll/SelectItemAll';\nimport { SelectLoader } from '../SelectLoader/SelectLoader';\nimport { SelectPopover } from '../SelectPopover';\nimport { SelectRenderItem } from '../SelectRenderItem';\nimport { CountedGroup } from '../types';\n\nexport const selectDropdownForm = ['default', 'brick', 'round'] as const;\nexport type SelectDropdownPropForm = typeof selectDropdownForm[number];\nexport const defaultSelectDropdownPropForm = selectDropdownForm[0];\n\ntype RenderItemProps<ITEM> = {\n item: ITEM;\n active: boolean;\n hovered: boolean;\n onClick: (e: React.MouseEvent) => void;\n onMouseEnter: (e: React.MouseEvent) => void;\n ref: React.Ref<HTMLDivElement>;\n};\n\ntype Props<ITEM, GROUP> = PropsWithJsxAttributes<{\n size: FieldPropSize;\n controlRef: React.MutableRefObject<HTMLDivElement | null>;\n dropdownRef: React.Ref<HTMLDivElement>;\n getOptionActions(props: OptionProps<ITEM>): GetOptionPropsResult;\n form: SelectDropdownPropForm;\n openAtom: AtomMut<boolean>;\n offset?: PopoverPropOffset | 'none';\n isLoading?: boolean;\n renderItem: (props: RenderItemProps<ITEM>) => React.ReactNode | null;\n highlightedIndexAtom: AtomMut<number>;\n visibleItemsAtom: AtomMut<(OptionForCreate | CountedGroup<ITEM, GROUP>)[]>;\n getGroupLabel?: (group: GROUP) => string;\n labelForCreate?:\n | ((label: string | undefined) => React.ReactNode)\n | React.ReactNode;\n labelForNotFound?: string;\n labelForEmptyItems?: string;\n notFound?: boolean;\n hasItemsAtom: AtomMut<boolean>;\n itemsRefs: React.RefObject<HTMLDivElement>[];\n virtualScroll?: boolean;\n onScrollToBottom?: (length: number) => void;\n valueAtom: AtomMut<ITEM[]>;\n getItemKeyAtom: AtomMut<(item: ITEM) => string | number>;\n onChangeAll: (e: React.SyntheticEvent, items: ITEM[]) => void;\n highlightIndex: (index: number) => void;\n onCreate: (e: React.SyntheticEvent) => void;\n onChange: (e: React.SyntheticEvent, item: ITEM) => void;\n inputValueAtom: AtomMut<string>;\n groupsCounterAtom: AtomMut<Record<string, [number, number]>>;\n dropdownZIndexAtom: AtomMut<number | undefined>;\n selectAllLabel: string;\n viewportRef?: React.RefObject<HTMLElement>;\n container?: Element;\n}>;\n\ntype SelectDropdownComponent = <ITEM, GROUP>(\n props: Props<ITEM, GROUP>,\n) => React.ReactNode | null;\n\nconst cnSelectDropdown = cn('SelectDropdown');\n\nconst getLengthElements = <ITEM, GROUP>(\n elements: (\n | OptionForCreate\n | {\n items: Array<SelectAllItem | ITEM>;\n key: string | number;\n group?: GROUP;\n }\n )[],\n) => {\n let length = elements.length <= 1 ? 0 : elements.length;\n\n for (let index = 0; index < elements.length; index++) {\n const element = elements[index];\n\n if (isNotOptionForCreate(element) && element?.items?.length) {\n length += element.items.length;\n }\n }\n\n return length;\n};\n\nconst isVisible = (slice: [number, number], index: number) => {\n return index >= slice[0] && index < slice[1];\n};\n\nexport const SelectDropdown: SelectDropdownComponent = memo((props) => {\n const {\n controlRef,\n size,\n getOptionActions,\n dropdownRef: dropdownRefProp,\n labelForCreate,\n className,\n labelForNotFound,\n labelForEmptyItems,\n hasItemsAtom,\n form,\n openAtom,\n offset: offsetProp = 'none',\n renderItem,\n visibleItemsAtom,\n isLoading,\n getGroupLabel,\n notFound,\n itemsRefs,\n virtualScroll,\n onScrollToBottom,\n highlightedIndexAtom,\n valueAtom,\n getItemKeyAtom,\n highlightIndex,\n onCreate,\n onChange,\n onChangeAll,\n inputValueAtom,\n groupsCounterAtom,\n dropdownZIndexAtom,\n selectAllLabel,\n container,\n ...otherProps\n } = props;\n\n const [visibleItems] = useAtom(visibleItemsAtom);\n\n const [hasItems] = useAtom(hasItemsAtom);\n const [isListMount, setIsListMount] = useAtom(false);\n const [getItemKey] = useAtom(getItemKeyAtom);\n const indent = form === 'round' ? 'increased' : 'normal';\n\n const isListShowed = useMemo(() => {\n return (\n visibleItems.filter(\n (group) =>\n isOptionForCreate(group) ||\n (Array.isArray(group.items) && group.items.length > 0),\n ).length > 0\n );\n }, [visibleItems]);\n\n const offset = offsetProp === 'none' ? undefined : offsetProp;\n\n const lengthForVirtualScroll = useMemo(\n () => getLengthElements(visibleItems),\n [visibleItems],\n );\n\n const {\n spaceTop,\n slice: sliceHookProp,\n listRefs,\n scrollElementRef,\n } = useVirtualScroll({\n length: lengthForVirtualScroll,\n isActive: virtualScroll && isListMount,\n onScrollToBottom,\n });\n\n const scrollContainerRef = useForkRef([scrollElementRef, dropdownRefProp]);\n\n const slice: [number, number] =\n sliceHookProp[0] === 0 && virtualScroll ? [0, 50] : sliceHookProp;\n\n const getIndex = fabricIndex();\n const getVirtualIndex = fabricIndex();\n const [zIndex] = useAtom(dropdownZIndexAtom);\n\n return (\n <SelectPopover\n {...otherProps}\n anchorRef={controlRef}\n offset={offset}\n role=\"listbox\"\n className={cnSelectDropdown()}\n size={size}\n controlRef={controlRef}\n openAtom={openAtom}\n form={form}\n onMount={setIsListMount}\n style={{ zIndex }}\n container={container}\n >\n {isListMount && (\n <div\n className={cnSelectDropdown('ScrollContainer', [\n cnMixSpace({\n pV: mapVerticalSpace[size],\n }),\n cnMixScrollBar({ size: 'xs' }),\n ])}\n ref={scrollContainerRef}\n >\n {isLoading && !isListShowed && <SelectLoader />}\n <div\n className={cnSelectDropdown('List')}\n key={cnSelectDropdown('List')}\n style={{ marginTop: spaceTop }}\n >\n {visibleItems.map((group) => {\n if (isOptionForCreate(group)) {\n const index = getIndex();\n return (\n <SelectCreateButton\n size={size}\n key={cnSelectDropdown('List', { key: 'CreateButton' })}\n labelForCreate={labelForCreate}\n indent={indent}\n ref={itemsRefs[index]}\n onClick={onCreate}\n highlightedIndexAtom={highlightedIndexAtom}\n inputValueAtom={inputValueAtom}\n highlightIndex={highlightIndex}\n index={index}\n />\n );\n }\n\n const virtualIndex =\n visibleItems.length > 1 ? getVirtualIndex() : 0;\n\n return (\n <Fragment key={group.key}>\n {group.group &&\n getGroupLabel &&\n isVisible(slice, virtualIndex) && (\n <SelectGroupLabel\n label={getGroupLabel(group.group)}\n size={size}\n indent={indent}\n ref={listRefs[virtualIndex]}\n key={`group-${group.key}-Label`}\n />\n )}\n {group.items.map((item) => {\n if (isOptionForSelectAll(item)) {\n const virtualIndex = getVirtualIndex();\n const index = getIndex();\n\n if (isVisible(slice, virtualIndex)) {\n return (\n <SelectItemAll\n label={selectAllLabel}\n groupId={group.key}\n highlightedIndexAtom={highlightedIndexAtom}\n groupsCounterAtom={groupsCounterAtom}\n key={cnSelectDropdown('SelectItemAll', {\n group: group.key,\n })}\n ref={forkRef([\n listRefs[virtualIndex],\n itemsRefs[index],\n ])}\n indent={indent}\n size={size}\n {...getOptionActions({\n index,\n item,\n })}\n index={index}\n />\n );\n }\n } else {\n const virtualIndex = getVirtualIndex();\n const index = getIndex();\n if (isVisible(slice, virtualIndex)) {\n return (\n <SelectRenderItem\n key={cnSelectDropdown('SelectRenderItem', {\n group: group.key,\n item: getItemKey(item),\n })}\n getItemKeyAtom={getItemKeyAtom}\n highlightedIndexAtom={highlightedIndexAtom}\n rootRef={forkRef([\n listRefs[virtualIndex],\n itemsRefs[index],\n ])}\n renderItem={renderItem}\n item={item}\n {...getOptionActions({\n index,\n item,\n })}\n index={index}\n valueAtom={valueAtom}\n />\n );\n }\n }\n })}\n </Fragment>\n );\n })}\n {isLoading && isListShowed && (\n <ListLoader size={size} innerOffset={indent} />\n )}\n </div>\n {!isLoading && !hasItems && labelForEmptyItems && (\n <ListItem\n size={size}\n label={labelForEmptyItems}\n innerOffset={indent}\n >\n {labelForEmptyItems}\n </ListItem>\n )}\n </div>\n )}\n </SelectPopover>\n );\n});\n"],"mappings":"goBAAA,6BAGA,OAASA,OAAT,KAAwB,mBAAxB,CACA,MAAOC,MAAP,EAAgBC,QAAhB,CAA0BC,IAA1B,CAAgCC,OAAhC,KAA+C,OAA/C,CAGA,OACEC,QADF,CAEEC,UAFF,CAGEC,gBAHF,wBAMA,OAEEC,oBAFF,CAGEC,iBAHF,CAIEC,oBAJF,oBAQA,OAASC,OAAT,CAAkBC,UAAlB,iCACA,OAASC,gBAAT,uCACA,OAASC,cAAT,kCACA,OAASC,UAAT,8BACA,OAASC,QAAQ,GAAIC,GAArB,0BACA,OAASC,WAAT,kCAIA,OAASC,kBAAT,gDACA,OAASC,gBAAT,4CACA,OAASC,aAAT,sCACA,OAASC,YAAT,oCACA,OAASC,aAAT,wBACA,OAASC,gBAAT,2BAGA,MAAO,IAAMC,mBAAkB,CAAG,CAAC,SAAD,CAAY,OAAZ,CAAqB,OAArB,CAA3B,CAEP,MAAO,IAAMC,8BAA6B,CAAGD,kBAAkB,CAAC,CAAD,CAAxD,C,GAoDDE,iBAAgB,CAAGV,EAAE,CAAC,gBAAD,C,CAErBW,iBAAiB,CAAG,SACxBC,CADwB,CASrB,CAGH,OAFIC,EAAM,CAAsB,CAAnB,EAAAD,CAAQ,CAACC,MAAT,CAAuB,CAAvB,CAA2BD,CAAQ,CAACC,MAEjD,CAASC,CAAK,CAAG,CAAjB,CAAoBA,CAAK,CAAGF,CAAQ,CAACC,MAArC,CAA6CC,CAAK,EAAlD,CAAsD,OAC9CC,CAAO,CAAGH,CAAQ,CAACE,CAAD,CAD4B,CAGhDvB,oBAAoB,CAACwB,CAAD,CAApB,SAAiCA,CAAjC,WAAiCA,CAAjC,YAAiCA,CAAO,CAAEC,KAA1C,eAAiC,EAAgBH,MAHD,GAIlDA,CAAM,EAAIE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C,EAAD,CAAQ+D,CAAR,CAAb,CACE,MACE,qBAAC,gBAAD,gBACE,GAAG,CAAEvE,gBAAgB,CAAC,kBAAD,CAAqB,CACxCsD,KAAK,CAAEA,CAAK,CAACgB,GAD2B,CAExCE,IAAI,CAAEtB,CAAU,CAACsB,CAAD,CAFwB,CAArB,CADvB,CAKE,cAAc,CAAErC,CALlB,CAME,oBAAoB,CAAEF,CANxB,CAOE,OAAO,CAAEjD,OAAO,CAAC,CACf6E,EAAQ,CAACU,CAAD,CADO,CAEfzC,CAAS,CAAC1B,CAAD,CAFM,CAAD,CAPlB,CAWE,UAAU,CAAEqB,CAXd,CAYE,IAAI,CAAE+C,CAZR,EAaM3D,CAAgB,CAAC,CACnBT,KAAK,CAALA,CADmB,CAEnBoE,IAAI,CAAJA,CAFmB,CAAD,CAbtB,EAiBE,KAAK,CAAEpE,CAjBT,CAkBE,SAAS,CAAE8B,CAlBb,GAsBL,CACF,CAzDA,CAZH,CAwEH,CA/FA,CALH,CAqGGP,CAAS,EAAIyB,CAAb,EACC,oBAAC,UAAD,EAAY,IAAI,CAAExC,CAAlB,CAAwB,WAAW,CAAEuC,CAArC,EAtGJ,CAVF,CAmHG,CAACxB,CAAD,EAAc,CAACoB,CAAf,EAA2B5B,CAA3B,EACC,oBAAC,QAAD,EACE,IAAI,CAAEP,CADR,CAEE,KAAK,CAAEO,CAFT,CAGE,WAAW,CAAEgC,CAHf,EAKGhC,CALH,CApHJ,CAfJ,CA+IH,CAjO0D,CAApD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["form","status","size","disabled","value","renderValue","isLoading","dropdownRef","dropdownForm","renderItem","getGroupLabel","labelForCreate","labelForEmptyItems","virtualScroll","onScrollToBottom","style","className","placeholder","view","iconClear","input","inputValue","inputDefaultValue","inputRef","getGroupKey","getItemDisabled","getItemGroupKey","getItemKey","getItemLabel","items","onChange","dropdownClassName","onFocus","onBlur","onCreate","onInput","multiple","groups","onDropdownOpen","ignoreOutsideClicksRefs","clearButton","selectAll","selectAllLabel","dropdownViewportRef"];import"./SelectMultiple.css";import{useAction}from"@reatom/npm-react";import React,{forwardRef,useRef}from"react";import{FieldArrayValueItem}from"../../FieldComponents";import{SelectDropdown}from"../SelectDropdown";import{SelectItem}from"../SelectItem";import{useForkRef}from"../../../hooks/useForkRef";import{cnCanary as cn}from"../../../utils/bem";import{useSendToAtom}from"../../../utils/state";import{withCtx}from"../../../utils/state/withCtx";import{withDefault}from"../defaultProps";import{SelectControlLayout}from"../SelectControlLayout";import{SelectMultipleValue}from"../SelectMultipleValue";import{useSelect}from"../useSelect";var cnSelectMultiple=cn("SelectMultiple"),SelectMultipleRender=function(a,b){var c=withDefault(a),d=useSendToAtom(c),e=c.form,f=c.status,g=c.size,h=c.disabled,i=c.value,j=c.renderValue,k=c.isLoading,l=c.dropdownRef,m=c.dropdownForm,n=c.renderItem,o=c.getGroupLabel,p=c.labelForCreate,q=c.labelForEmptyItems,r=c.virtualScroll,s=c.onScrollToBottom,t=c.style,u=c.className,v=c.placeholder,w=c.view,x=c.iconClear,y=c.input,z=c.inputValue,A=c.inputDefaultValue,B=c.inputRef,C=c.getGroupKey,D=c.getItemDisabled,E=c.getItemGroupKey,F=c.getItemKey,G=c.getItemLabel,H=c.items,I=c.onChange,J=c.dropdownClassName,K=c.onFocus,L=c.onBlur,M=c.onCreate,N=c.onInput,O=c.multiple,P=c.groups,Q=c.onDropdownOpen,R=c.ignoreOutsideClicksRefs,S=c.clearButton,T=c.selectAll,U=c.selectAllLabel,V=c.dropdownViewportRef,W=_objectWithoutProperties(c,_excluded),
|
|
1
|
+
import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["form","status","size","disabled","value","renderValue","isLoading","dropdownRef","dropdownForm","renderItem","getGroupLabel","labelForCreate","labelForEmptyItems","virtualScroll","onScrollToBottom","style","className","placeholder","view","iconClear","input","inputValue","inputDefaultValue","inputRef","getGroupKey","getItemDisabled","getItemGroupKey","getItemKey","getItemLabel","items","onChange","dropdownClassName","onFocus","onBlur","onCreate","onInput","multiple","groups","onDropdownOpen","ignoreOutsideClicksRefs","clearButton","selectAll","selectAllLabel","dropdownViewportRef","dropdownContainer"];import"./SelectMultiple.css";import{useAction}from"@reatom/npm-react";import React,{forwardRef,useRef}from"react";import{FieldArrayValueItem}from"../../FieldComponents";import{SelectDropdown}from"../SelectDropdown";import{SelectItem}from"../SelectItem";import{useForkRef}from"../../../hooks/useForkRef";import{cnCanary as cn}from"../../../utils/bem";import{useSendToAtom}from"../../../utils/state";import{withCtx}from"../../../utils/state/withCtx";import{withDefault}from"../defaultProps";import{SelectControlLayout}from"../SelectControlLayout";import{SelectMultipleValue}from"../SelectMultipleValue";import{useSelect}from"../useSelect";var cnSelectMultiple=cn("SelectMultiple"),SelectMultipleRender=function(a,b){var c=withDefault(a),d=useSendToAtom(c),e=c.form,f=c.status,g=c.size,h=c.disabled,i=c.value,j=c.renderValue,k=c.isLoading,l=c.dropdownRef,m=c.dropdownForm,n=c.renderItem,o=c.getGroupLabel,p=c.labelForCreate,q=c.labelForEmptyItems,r=c.virtualScroll,s=c.onScrollToBottom,t=c.style,u=c.className,v=c.placeholder,w=c.view,x=c.iconClear,y=c.input,z=c.inputValue,A=c.inputDefaultValue,B=c.inputRef,C=c.getGroupKey,D=c.getItemDisabled,E=c.getItemGroupKey,F=c.getItemKey,G=c.getItemLabel,H=c.items,I=c.onChange,J=c.dropdownClassName,K=c.onFocus,L=c.onBlur,M=c.onCreate,N=c.onInput,O=c.multiple,P=c.groups,Q=c.onDropdownOpen,R=c.ignoreOutsideClicksRefs,S=c.clearButton,T=c.selectAll,U=c.selectAllLabel,V=c.dropdownViewportRef,W=c.dropdownContainer,X=_objectWithoutProperties(c,_excluded),Y=useSelect({propsAtom:d}),Z=Y.getOptionActions,$=Y.openAtom,_=Y.visibleItemsAtom,aa=Y.focusAtom,ba=Y.handleInputFocus,ca=Y.handleInputBlur,da=Y.handleToggleDropdown,ea=Y.inputRef,fa=Y.handleInputClick,ga=Y.handleInputChange,ha=Y.clearValue,ia=Y.optionsRefs,ja=Y.controlRef,ka=Y.dropdownRef,la=Y.clearButtonAtom,ma=Y.highlightedIndexAtom,na=Y.getItemKeyAtom,oa=Y.valueAtom,pa=Y.onChangeAll,qa=Y.highlightIndex,ra=Y.onCreate,sa=Y.onChange,ta=Y.inputValueAtom,ua=Y.getHandleRemoveValue,va=Y.hasItemsAtom,wa=Y.groupsCounterAtom,xa=Y.dropdownZIndexAtom,ya=useRef(null),za=useAction(function(a,b){var c=b.item,d=b.active,e=b.hovered,f=b.onClick,h=b.onMouseEnter,i=b.ref;return React.createElement(SelectItem,{label:G(c),active:d,hovered:e,size:g,indent:"round"===m?"increased":"normal",onClick:f,onMouseEnter:h,disabled:D(c),ref:i,multiple:!0})},[D,g,G,m]),Aa=useAction(function(a,b){return(j||function renderValueDefault(a){var b=a.value,c=a.getRemove;return b.map(function(a){var b=h||D(a);return React.createElement(FieldArrayValueItem,{key:F(a),size:g,label:G(a),disabled:b,onRemove:b?void 0:c(a)})})})({value:b,getRemove:ua})},[h,D,F,g,G,j]);return React.createElement(React.Fragment,null,React.createElement(SelectControlLayout,Object.assign({},X,{style:t,className:cnSelectMultiple(null,[u]),form:e,status:f,size:g,disabled:h,separator:!0,onClear:ha,onDropdownButton:da,openAtom:$,focusAtom:aa,view:w,iconClear:x,clearButtonAtom:la,ref:useForkRef([b,ja])}),React.createElement(SelectMultipleValue,{propsAtom:d,onFocus:ba,onBlur:ca,onClick:fa,onChange:ga,renderValue:Aa,inputRef:useForkRef([ea,B]),ref:ya})),React.createElement(SelectDropdown,{valueAtom:oa,getItemKeyAtom:na,openAtom:$,size:g,controlRef:ja,getOptionActions:Z,dropdownRef:useForkRef([ka,l]),form:m,className:J,renderItem:n||za,getGroupLabel:o,visibleItemsAtom:_,labelForCreate:p,isLoading:k,labelForEmptyItems:q,itemsRefs:ia,virtualScroll:r,onScrollToBottom:s,highlightedIndexAtom:ma,highlightIndex:qa,onChangeAll:pa,onCreate:ra,onChange:sa,inputValueAtom:ta,hasItemsAtom:va,groupsCounterAtom:wa,dropdownZIndexAtom:xa,selectAllLabel:U,viewportRef:V,container:W}))};export var SelectMultiple=withCtx(forwardRef(SelectMultipleRender));
|
|
2
2
|
//# sourceMappingURL=SelectMultiple.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMultiple.js","names":["useAction","React","forwardRef","useRef","FieldArrayValueItem","SelectDropdown","SelectItem","useForkRef","cnCanary","cn","useSendToAtom","withCtx","withDefault","SelectControlLayout","SelectMultipleValue","useSelect","cnSelectMultiple","SelectMultipleRender","props","ref","propsWithDefault","propsAtom","form","status","size","disabled","value","renderValue","isLoading","dropdownRefProp","dropdownRef","dropdownForm","renderItem","getGroupLabel","labelForCreate","labelForEmptyItems","virtualScroll","onScrollToBottom","style","className","placeholder","view","iconClear","input","inputValue","inputDefaultValue","inputRefProp","inputRef","getGroupKey","getItemDisabled","getItemGroupKey","getItemKey","getItemLabel","items","onChangeProp","onChange","dropdownClassName","onFocus","onBlur","onCreateProp","onCreate","onInput","multiple","groups","onDropdownOpen","ignoreOutsideClicksRefs","clearButton","selectAll","selectAllLabel","dropdownViewportRef","otherProps","getOptionActions","openAtom","visibleItemsAtom","focusAtom","handleInputFocus","handleInputBlur","handleToggleDropdown","handleInputClick","handleInputChange","clearValue","optionsRefs","controlRef","clearButtonAtom","highlightedIndexAtom","getItemKeyAtom","valueAtom","onChangeAll","highlightIndex","inputValueAtom","getHandleRemoveValue","hasItemsAtom","groupsCounterAtom","dropdownZIndexAtom","valueContainerRef","renderItemDefault","ctx","item","active","hovered","onClick","onMouseEnter","inlineControlRender","renderValueDefault","getRemove","map","itemDisabled","SelectMultiple"],"sources":["../../../../../../src/components/SelectCanary/SelectMultiple/SelectMultiple.tsx"],"sourcesContent":["import './SelectMultiple.css';\n\nimport { useAction } from '@reatom/npm-react';\nimport React, { forwardRef, useRef } from 'react';\n\nimport { FieldArrayValueItem } from '##/components/FieldComponents';\nimport { SelectDropdown } from '##/components/SelectCanary/SelectDropdown';\nimport { SelectItem } from '##/components/SelectCanary/SelectItem';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { cnCanary as cn } from '##/utils/bem';\nimport { useSendToAtom } from '##/utils/state';\nimport { withCtx } from '##/utils/state/withCtx';\n\nimport {\n RenderItemProps,\n SelectComponent,\n SelectGroupDefault,\n SelectItemDefault,\n SelectPropRenderItem,\n SelectProps,\n} from '..';\nimport { withDefault } from '../defaultProps';\nimport { SelectControlLayout } from '../SelectControlLayout';\nimport { SelectMultipleValue } from '../SelectMultipleValue';\nimport { useSelect } from '../useSelect';\n\nconst cnSelectMultiple = cn('SelectMultiple');\n\nconst SelectMultipleRender = <\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n>(\n props: SelectProps<ITEM, GROUP, true>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const propsWithDefault = withDefault(props);\n\n const propsAtom = useSendToAtom(propsWithDefault);\n\n const {\n form,\n status,\n size,\n disabled,\n value,\n renderValue,\n isLoading,\n dropdownRef: dropdownRefProp,\n dropdownForm,\n renderItem,\n getGroupLabel,\n labelForCreate,\n labelForEmptyItems,\n virtualScroll,\n onScrollToBottom,\n style,\n className,\n placeholder,\n view,\n iconClear,\n input,\n inputValue,\n inputDefaultValue,\n inputRef: inputRefProp,\n\n // исключаем из otherProps\n getGroupKey,\n getItemDisabled,\n getItemGroupKey,\n getItemKey,\n getItemLabel,\n items,\n onChange: onChangeProp,\n dropdownClassName,\n onFocus,\n onBlur,\n onCreate: onCreateProp,\n onInput,\n multiple,\n groups,\n onDropdownOpen,\n ignoreOutsideClicksRefs,\n clearButton,\n selectAll,\n selectAllLabel,\n dropdownViewportRef,\n ...otherProps\n } = propsWithDefault;\n\n const {\n getOptionActions,\n openAtom,\n visibleItemsAtom,\n focusAtom,\n handleInputFocus,\n handleInputBlur,\n handleToggleDropdown,\n inputRef,\n handleInputClick,\n handleInputChange,\n clearValue,\n optionsRefs,\n controlRef,\n dropdownRef,\n clearButtonAtom,\n highlightedIndexAtom,\n getItemKeyAtom,\n valueAtom,\n onChangeAll,\n highlightIndex,\n onCreate,\n onChange,\n inputValueAtom,\n getHandleRemoveValue,\n hasItemsAtom,\n groupsCounterAtom,\n dropdownZIndexAtom,\n } = useSelect<ITEM, GROUP, true>({\n propsAtom,\n });\n\n const valueContainerRef = useRef<HTMLDivElement>(null);\n\n const renderItemDefault: SelectPropRenderItem<ITEM> = useAction(\n (\n ctx,\n {\n item,\n active,\n hovered,\n onClick,\n onMouseEnter,\n ref,\n }: RenderItemProps<ITEM>,\n ) => {\n return (\n <SelectItem\n label={getItemLabel(item)}\n active={active}\n hovered={hovered}\n size={size}\n indent={dropdownForm === 'round' ? 'increased' : 'normal'}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n disabled={getItemDisabled(item)}\n ref={ref}\n multiple\n />\n );\n },\n [getItemDisabled, size, getItemLabel, dropdownForm],\n );\n\n const inlineControlRender = useAction(\n (ctx, value: ITEM[]) => {\n const renderValueDefault = ({\n value,\n getRemove,\n }: {\n value: ITEM[];\n getRemove: (\n item: ITEM,\n ) => (e: React.SyntheticEvent<Element, Event>) => void;\n }) => {\n return value.map((item) => {\n const itemDisabled = disabled || getItemDisabled(item);\n return (\n <FieldArrayValueItem\n key={getItemKey(item)}\n size={size}\n label={getItemLabel(item)}\n disabled={itemDisabled}\n onRemove={itemDisabled ? undefined : getRemove(item)}\n />\n );\n });\n };\n\n return (renderValue || renderValueDefault)({\n value,\n getRemove: getHandleRemoveValue,\n });\n },\n [disabled, getItemDisabled, getItemKey, size, getItemLabel, renderValue],\n );\n\n return (\n <>\n <SelectControlLayout\n {...otherProps}\n style={style}\n className={cnSelectMultiple(null, [className])}\n form={form}\n status={status}\n size={size}\n disabled={disabled}\n separator\n onClear={clearValue}\n onDropdownButton={handleToggleDropdown}\n openAtom={openAtom}\n focusAtom={focusAtom}\n view={view}\n iconClear={iconClear}\n clearButtonAtom={clearButtonAtom}\n ref={useForkRef([ref, controlRef])}\n >\n <SelectMultipleValue\n propsAtom={propsAtom}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onClick={handleInputClick}\n onChange={handleInputChange}\n renderValue={inlineControlRender}\n inputRef={useForkRef([inputRef, inputRefProp])}\n ref={valueContainerRef}\n />\n </SelectControlLayout>\n <SelectDropdown\n valueAtom={valueAtom}\n getItemKeyAtom={getItemKeyAtom}\n openAtom={openAtom}\n size={size}\n controlRef={controlRef}\n getOptionActions={getOptionActions}\n dropdownRef={useForkRef([dropdownRef, dropdownRefProp])}\n form={dropdownForm}\n className={dropdownClassName}\n renderItem={renderItem || renderItemDefault}\n getGroupLabel={getGroupLabel}\n visibleItemsAtom={visibleItemsAtom}\n labelForCreate={labelForCreate}\n isLoading={isLoading}\n labelForEmptyItems={labelForEmptyItems}\n itemsRefs={optionsRefs}\n virtualScroll={virtualScroll}\n onScrollToBottom={onScrollToBottom}\n highlightedIndexAtom={highlightedIndexAtom}\n highlightIndex={highlightIndex}\n onChangeAll={onChangeAll}\n onCreate={onCreate}\n onChange={onChange}\n inputValueAtom={inputValueAtom}\n hasItemsAtom={hasItemsAtom}\n groupsCounterAtom={groupsCounterAtom}\n dropdownZIndexAtom={dropdownZIndexAtom}\n selectAllLabel={selectAllLabel}\n viewportRef={dropdownViewportRef}\n />\n </>\n );\n};\n\nexport const SelectMultiple = withCtx(\n forwardRef(SelectMultipleRender),\n) as SelectComponent;\n"],"mappings":"krBAAA,6BAEA,OAASA,SAAT,KAA0B,mBAA1B,CACA,MAAOC,MAAP,EAAgBC,UAAhB,CAA4BC,MAA5B,KAA0C,OAA1C,CAEA,OAASC,mBAAT,6BACA,OAASC,cAAT,yBACA,OAASC,UAAT,qBACA,OAASC,UAAT,iCACA,OAASC,QAAQ,GAAIC,GAArB,0BACA,OAASC,aAAT,4BACA,OAASC,OAAT,oCAUA,OAASC,W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AqBE,WAAW,CAAED,EArBf,CAsBE,QAAQ,CAAE3B,EAtBZ,CAuBE,QAAQ,CAAEL,EAvBZ,CAwBE,cAAc,CAAEkC,EAxBlB,CAyBE,YAAY,CAAEE,EAzBhB,CA0BE,iBAAiB,CAAEC,EA1BrB,CA2BE,kBAAkB,CAAEC,EA3BtB,CA4BE,cAAc,CAAEzB,CA5BlB,CA6BE,WAAW,CAAEC,CA7Bf,EA9BF,CA+DH,C,CAED,MAAO,IAAMsC,eAAc,CAAGhG,OAAO,CACnCT,UAAU,CAACe,oBAAD,CADyB,CAA9B"}
|
|
1
|
+
{"version":3,"file":"SelectMultiple.js","names":["useAction","React","forwardRef","useRef","FieldArrayValueItem","SelectDropdown","SelectItem","useForkRef","cnCanary","cn","useSendToAtom","withCtx","withDefault","SelectControlLayout","SelectMultipleValue","useSelect","cnSelectMultiple","SelectMultipleRender","props","ref","propsWithDefault","propsAtom","form","status","size","disabled","value","renderValue","isLoading","dropdownRefProp","dropdownRef","dropdownForm","renderItem","getGroupLabel","labelForCreate","labelForEmptyItems","virtualScroll","onScrollToBottom","style","className","placeholder","view","iconClear","input","inputValue","inputDefaultValue","inputRefProp","inputRef","getGroupKey","getItemDisabled","getItemGroupKey","getItemKey","getItemLabel","items","onChangeProp","onChange","dropdownClassName","onFocus","onBlur","onCreateProp","onCreate","onInput","multiple","groups","onDropdownOpen","ignoreOutsideClicksRefs","clearButton","selectAll","selectAllLabel","dropdownViewportRef","dropdownContainer","otherProps","getOptionActions","openAtom","visibleItemsAtom","focusAtom","handleInputFocus","handleInputBlur","handleToggleDropdown","handleInputClick","handleInputChange","clearValue","optionsRefs","controlRef","clearButtonAtom","highlightedIndexAtom","getItemKeyAtom","valueAtom","onChangeAll","highlightIndex","inputValueAtom","getHandleRemoveValue","hasItemsAtom","groupsCounterAtom","dropdownZIndexAtom","valueContainerRef","renderItemDefault","ctx","item","active","hovered","onClick","onMouseEnter","inlineControlRender","renderValueDefault","getRemove","map","itemDisabled","SelectMultiple"],"sources":["../../../../../../src/components/SelectCanary/SelectMultiple/SelectMultiple.tsx"],"sourcesContent":["import './SelectMultiple.css';\n\nimport { useAction } from '@reatom/npm-react';\nimport React, { forwardRef, useRef } from 'react';\n\nimport { FieldArrayValueItem } from '##/components/FieldComponents';\nimport { SelectDropdown } from '##/components/SelectCanary/SelectDropdown';\nimport { SelectItem } from '##/components/SelectCanary/SelectItem';\nimport { useForkRef } from '##/hooks/useForkRef';\nimport { cnCanary as cn } from '##/utils/bem';\nimport { useSendToAtom } from '##/utils/state';\nimport { withCtx } from '##/utils/state/withCtx';\n\nimport {\n RenderItemProps,\n SelectComponent,\n SelectGroupDefault,\n SelectItemDefault,\n SelectPropRenderItem,\n SelectProps,\n} from '..';\nimport { withDefault } from '../defaultProps';\nimport { SelectControlLayout } from '../SelectControlLayout';\nimport { SelectMultipleValue } from '../SelectMultipleValue';\nimport { useSelect } from '../useSelect';\n\nconst cnSelectMultiple = cn('SelectMultiple');\n\nconst SelectMultipleRender = <\n ITEM = SelectItemDefault,\n GROUP = SelectGroupDefault,\n>(\n props: SelectProps<ITEM, GROUP, true>,\n ref: React.Ref<HTMLDivElement>,\n) => {\n const propsWithDefault = withDefault(props);\n\n const propsAtom = useSendToAtom(propsWithDefault);\n\n const {\n form,\n status,\n size,\n disabled,\n value,\n renderValue,\n isLoading,\n dropdownRef: dropdownRefProp,\n dropdownForm,\n renderItem,\n getGroupLabel,\n labelForCreate,\n labelForEmptyItems,\n virtualScroll,\n onScrollToBottom,\n style,\n className,\n placeholder,\n view,\n iconClear,\n input,\n inputValue,\n inputDefaultValue,\n inputRef: inputRefProp,\n\n // исключаем из otherProps\n getGroupKey,\n getItemDisabled,\n getItemGroupKey,\n getItemKey,\n getItemLabel,\n items,\n onChange: onChangeProp,\n dropdownClassName,\n onFocus,\n onBlur,\n onCreate: onCreateProp,\n onInput,\n multiple,\n groups,\n onDropdownOpen,\n ignoreOutsideClicksRefs,\n clearButton,\n selectAll,\n selectAllLabel,\n dropdownViewportRef,\n dropdownContainer,\n ...otherProps\n } = propsWithDefault;\n\n const {\n getOptionActions,\n openAtom,\n visibleItemsAtom,\n focusAtom,\n handleInputFocus,\n handleInputBlur,\n handleToggleDropdown,\n inputRef,\n handleInputClick,\n handleInputChange,\n clearValue,\n optionsRefs,\n controlRef,\n dropdownRef,\n clearButtonAtom,\n highlightedIndexAtom,\n getItemKeyAtom,\n valueAtom,\n onChangeAll,\n highlightIndex,\n onCreate,\n onChange,\n inputValueAtom,\n getHandleRemoveValue,\n hasItemsAtom,\n groupsCounterAtom,\n dropdownZIndexAtom,\n } = useSelect<ITEM, GROUP, true>({\n propsAtom,\n });\n\n const valueContainerRef = useRef<HTMLDivElement>(null);\n\n const renderItemDefault: SelectPropRenderItem<ITEM> = useAction(\n (\n ctx,\n {\n item,\n active,\n hovered,\n onClick,\n onMouseEnter,\n ref,\n }: RenderItemProps<ITEM>,\n ) => {\n return (\n <SelectItem\n label={getItemLabel(item)}\n active={active}\n hovered={hovered}\n size={size}\n indent={dropdownForm === 'round' ? 'increased' : 'normal'}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n disabled={getItemDisabled(item)}\n ref={ref}\n multiple\n />\n );\n },\n [getItemDisabled, size, getItemLabel, dropdownForm],\n );\n\n const inlineControlRender = useAction(\n (ctx, value: ITEM[]) => {\n const renderValueDefault = ({\n value,\n getRemove,\n }: {\n value: ITEM[];\n getRemove: (\n item: ITEM,\n ) => (e: React.SyntheticEvent<Element, Event>) => void;\n }) => {\n return value.map((item) => {\n const itemDisabled = disabled || getItemDisabled(item);\n return (\n <FieldArrayValueItem\n key={getItemKey(item)}\n size={size}\n label={getItemLabel(item)}\n disabled={itemDisabled}\n onRemove={itemDisabled ? undefined : getRemove(item)}\n />\n );\n });\n };\n\n return (renderValue || renderValueDefault)({\n value,\n getRemove: getHandleRemoveValue,\n });\n },\n [disabled, getItemDisabled, getItemKey, size, getItemLabel, renderValue],\n );\n\n return (\n <>\n <SelectControlLayout\n {...otherProps}\n style={style}\n className={cnSelectMultiple(null, [className])}\n form={form}\n status={status}\n size={size}\n disabled={disabled}\n separator\n onClear={clearValue}\n onDropdownButton={handleToggleDropdown}\n openAtom={openAtom}\n focusAtom={focusAtom}\n view={view}\n iconClear={iconClear}\n clearButtonAtom={clearButtonAtom}\n ref={useForkRef([ref, controlRef])}\n >\n <SelectMultipleValue\n propsAtom={propsAtom}\n onFocus={handleInputFocus}\n onBlur={handleInputBlur}\n onClick={handleInputClick}\n onChange={handleInputChange}\n renderValue={inlineControlRender}\n inputRef={useForkRef([inputRef, inputRefProp])}\n ref={valueContainerRef}\n />\n </SelectControlLayout>\n <SelectDropdown\n valueAtom={valueAtom}\n getItemKeyAtom={getItemKeyAtom}\n openAtom={openAtom}\n size={size}\n controlRef={controlRef}\n getOptionActions={getOptionActions}\n dropdownRef={useForkRef([dropdownRef, dropdownRefProp])}\n form={dropdownForm}\n className={dropdownClassName}\n renderItem={renderItem || renderItemDefault}\n getGroupLabel={getGroupLabel}\n visibleItemsAtom={visibleItemsAtom}\n labelForCreate={labelForCreate}\n isLoading={isLoading}\n labelForEmptyItems={labelForEmptyItems}\n itemsRefs={optionsRefs}\n virtualScroll={virtualScroll}\n onScrollToBottom={onScrollToBottom}\n highlightedIndexAtom={highlightedIndexAtom}\n highlightIndex={highlightIndex}\n onChangeAll={onChangeAll}\n onCreate={onCreate}\n onChange={onChange}\n inputValueAtom={inputValueAtom}\n hasItemsAtom={hasItemsAtom}\n groupsCounterAtom={groupsCounterAtom}\n dropdownZIndexAtom={dropdownZIndexAtom}\n selectAllLabel={selectAllLabel}\n viewportRef={dropdownViewportRef}\n container={dropdownContainer}\n />\n </>\n );\n};\n\nexport const SelectMultiple = withCtx(\n forwardRef(SelectMultipleRender),\n) as SelectComponent;\n"],"mappings":"ssBAAA,6BAEA,OAASA,SAAT,KAA0B,mBAA1B,CACA,MAAOC,MAAP,EAAgBC,UAAhB,CAA4BC,MAA5B,KAA0C,OAA1C,CAEA,OAASC,mBAA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AZpB,CAaE,cAAc,CAAExC,CAblB,CAcE,SAAS,CAAEN,CAdb,CAeE,kBAAkB,CAAEO,CAftB,CAgBE,SAAS,CAAE+C,EAhBb,CAiBE,aAAa,CAAE9C,CAjBjB,CAkBE,gBAAgB,CAAEC,CAlBpB,CAmBE,oBAAoB,CAAEgD,EAnBxB,CAoBE,cAAc,CAAEI,EApBlB,CAqBE,WAAW,CAAED,EArBf,CAsBE,QAAQ,CAAE5B,EAtBZ,CAuBE,QAAQ,CAAEL,EAvBZ,CAwBE,cAAc,CAAEmC,EAxBlB,CAyBE,YAAY,CAAEE,EAzBhB,CA0BE,iBAAiB,CAAEC,EA1BrB,CA2BE,kBAAkB,CAAEC,EA3BtB,CA4BE,cAAc,CAAE1B,CA5BlB,CA6BE,WAAW,CAAEC,CA7Bf,CA8BE,SAAS,CAAEC,CA9Bb,EA9BF,CAgEH,C,CAED,MAAO,IAAMsC,eAAc,CAAGjG,OAAO,CACnCT,UAAU,CAACe,oBAAD,CADyB,CAA9B"}
|
package/__internal__/src/components/SelectCanary/SelectMultiple/__test__/SelectMultiple.test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{act,fireEvent,render,screen}from"@testing-library/react";import React from"react";import{createIconMock}from"../../../../../__mocks__/IconMock";import{cnFieldArrayValueInlineControl}from"../../../FieldComponents";import{cnFieldControlLayout}from"../../../FieldComponents/FieldControlLayout";import{cnListBox,cnListItem,cnListLoader}from"../../../ListCanary";import{cnSelectControlLayout}from"../../SelectControlLayout";import{cnSelectCreateButton}from"../../SelectCreateButton";import{cnSelectItemAll}from"../../SelectItemAll";import{SelectMultiple}from"../SelectMultiple";var testId="SelectSingleCanary",animationDuration=200,renderComponent=function(a){return render(React.createElement(React.Fragment,null,React.createElement("div",{"data-testid":"outside"}),React.createElement(SelectMultiple,Object.assign({"data-testid":testId,multiple:!0},a))))},getRender=function(){return screen.getByTestId(testId)},getOutside=function(){return screen.getByTestId("outside")},getInput=function(){return getRender().querySelector("input")},inputClick=function(){return fireEvent.click(getInput())},animateDelay=function(){act(function(){jest.advanceTimersByTime(animationDuration)})},getDropdown=function(){return screen.queryByRole("listbox")},outsideClick=function(){return fireEvent.mouseDown(getOutside())},getValueControl=function(){return getRender().querySelector(".".concat(cnFieldArrayValueInlineControl()))},getItems=function(){return getDropdown().querySelectorAll(".".concat(cnListItem()))},getSelectAllOptions=function(){return getDropdown().querySelectorAll(".".concat(cnSelectItemAll()))},getSelectAllOption=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:0;return getSelectAllOptions()[a]},getItem=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:0;return getItems()[a]},getClearButton=function(){return getRender().querySelector(".".concat(cnSelectControlLayout("ClearButton")))},getLoader=function(){return getDropdown().querySelector(".".concat(cnListLoader()))},getCreateButton=function(){return getDropdown().querySelector(".".concat(cnSelectCreateButton()))},onCreateClick=function(){return fireEvent.click(getCreateButton())},items=[{id:1,label:"Item 1",groupId:1},{id:2,label:"Item 2",groupId:1},{id:3,label:"Item 3",groupId:2}],itemsWithDisabled=[{id:1,label:"Item 1",groupId:1,disabled:!0},{id:2,label:"Item 2",groupId:1},{id:3,label:"Item 3",groupId:2,disabled:!0}],groups=[{id:1,label:"Group 1"},{id:2,label:"Group 2"}];describe("SelectSingle",function(){it("\u0440\u0435\u043D\u0434\u0435\u0440\u0438\u0442\u0441\u044F \u0431\u0435\u0437 \u043E\u0448\u0438\u0431\u043E\u043A",function(){expect(function(){return renderComponent({items:items,onChange:jest.fn()})}).not.toThrow()}),it("\u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043F\u043B\u0435\u0439\u0441\u0445\u043E\u043B\u0434\u0435\u0440, \u0435\u0441\u043B\u0438 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E",function(){renderComponent({items:items,onChange:jest.fn(),placeholder:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442"}),expect(screen.getByPlaceholderText("\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442")).toBeInTheDocument()}),it("\u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",function(){renderComponent({items:items,value:[items[1]],onChange:jest.fn(),placeholder:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442"}),expect(screen.getByText("Item 2")).toBeInTheDocument()}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 ref",function(){var a={current:null};renderComponent({items:items,ref:a,onChange:jest.fn()}),expect(a.current).toBeTruthy()}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 inputRef",function(){var a={current:null};renderComponent({items:items,inputRef:a,onChange:jest.fn()}),expect(a.current).toBeTruthy()}),it("\u041F\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044F \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0439 className",function(){renderComponent({items:items,className:"custom-class",onChange:jest.fn()}),expect(getRender()).toHaveClass("custom-class")}),it("\u041F\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044E\u0442\u0441\u044F \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044B",function(){renderComponent({items:items,onChange:jest.fn(),"aria-placeholder":"test-autocomplete"}),expect(getRender()).toHaveAttribute("aria-placeholder","test-autocomplete")}),it("\u043E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043F\u043E \u043A\u043B\u0438\u043A\u0443",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown()).toBeInTheDocument()}),it("\u043E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043F\u043E \u043A\u043B\u0438\u043A\u0443",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown()).toBeInTheDocument()}),it("\u0437\u0430\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043F\u043E \u043A\u043B\u0438\u043A\u0443 \u0432\u043D\u0435 \u043A\u043E\u043C\u043F\u043E\u043D\u0435\u043D\u0442\u0430",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown()).toBeInTheDocument(),outsideClick(),animateDelay(),expect(getDropdown()).not.toBeInTheDocument()}),it("\u041E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u044E\u0442\u0441\u044F \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn()})}),inputClick(),animateDelay(),items.map(function(a){return expect(screen.getByText(a.label)).toBeInTheDocument()})}),it("\u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043F\u043E \u043A\u043B\u0438\u043A\u0443 \u043F\u0440\u0438 disabled",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn(),disabled:!0})}),inputClick(),animateDelay(),expect(getDropdown()).not.toBeInTheDocument()}),it("value \u0432\u0435\u0440\u043D\u043E \u0440\u0435\u043D\u0434\u0435\u0440\u0438\u0442\u0441\u044F",function(){var a=[items[2]];renderComponent({items:items,value:a,onChange:jest.fn()}),expect(getValueControl().textContent).toEqual(a[0].label)}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onChange",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,onChange:a})}),inputClick(),animateDelay(),fireEvent.click(getItem(0)),expect(a).toHaveBeenCalled(),expect(a).toHaveBeenCalledTimes(1),expect(a).toHaveBeenCalledWith([items[0]],{e:expect.any(Object)})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onFocus",function(){it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onFocus",function(){var a=jest.fn();renderComponent({items:items,onChange:jest.fn(),onFocus:a}),expect(a).toHaveBeenCalledTimes(0),getInput().focus(),expect(a).toHaveBeenCalledTimes(1)})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onBlur",function(){it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onBlur",function(){var a=jest.fn();renderComponent({items:items,onChange:jest.fn(),onBlur:a}),getInput().focus(),expect(a).toHaveBeenCalledTimes(0),getInput().blur(),expect(a).toHaveBeenCalledTimes(1)})}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onDropdownOpen",function(){var a=jest.fn();renderComponent({items:items,onChange:jest.fn(),onDropdownOpen:a}),inputClick(),expect(a).toHaveBeenCalledTimes(2),outsideClick(),expect(a).toHaveBeenCalledTimes(3),inputClick(),expect(a).toHaveBeenCalledTimes(4),outsideClick(),expect(a).toHaveBeenCalledTimes(5)}),it("\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441 \u043A\u043B\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044B",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,onChange:a})});var b=getInput();fireEvent.focus(b),animateDelay(),fireEvent.keyDown(b,{key:"ArrowDown"}),expect(getDropdown()).toBeInTheDocument(),fireEvent.keyDown(b,{key:"ArrowUp"}),fireEvent.keyDown(b,{key:"ArrowDown"}),fireEvent.keyDown(b,{key:"Enter"}),expect(a).toHaveBeenCalledWith([items[1]],{e:expect.any(Object)}),fireEvent.keyDown(b,{key:"Escape"}),animateDelay(),expect(getDropdown()).not.toBeInTheDocument(),fireEvent.keyDown(b,{key:"Enter"}),animateDelay(),expect(getDropdown()).toBeInTheDocument(),fireEvent.keyDown(b,{key:"Tab"}),animateDelay(),expect(getDropdown()).not.toBeInTheDocument(),fireEvent.keyDown(b,{key:"Tab"}),expect(b).not.toHaveFocus()}),it("disable - \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441 \u043A\u043B\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044B \u043D\u0435 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,onChange:a,disabled:!0})});var b=getInput();fireEvent.focus(b),animateDelay(),fireEvent.keyDown(b,{key:"ArrowDown"}),expect(getDropdown()).not.toBeInTheDocument(),expect(b).not.toHaveFocus(),fireEvent.keyDown(b,{key:"ArrowDown"}),expect(getDropdown()).not.toBeInTheDocument(),expect(b).not.toHaveFocus(),fireEvent.keyDown(b,{key:"Enter"}),expect(getDropdown()).not.toBeInTheDocument(),expect(b).not.toHaveFocus()}),it("\u0438\u043C\u0435\u0435\u0442\u0441\u044F \u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E\u0441\u0442\u044C \u0432\u0432\u043E\u0434\u0438\u0442\u044C \u0442\u0435\u043A\u0441\u0442 \u0432 input",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,input:!0});var b=getInput();fireEvent.change(b,{target:{value:"change"}}),expect(b.value).toEqual("change")}),it("\u0438\u043C\u0435\u0435\u0442\u0441\u044F \u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E\u0441\u0442\u044C \u0432\u0432\u043E\u0434\u0438\u0442\u044C \u0442\u0435\u043A\u0441\u0442 \u0432 input",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,input:!0});var b=getInput();fireEvent.change(b,{target:{value:"change"}}),expect(b.value).toEqual("change"),expect(a).toHaveBeenCalledWith("change")}),it("\u043F\u0440\u0438 \u0432\u0432\u043E\u0434\u0435 \u0442\u0435\u043A\u0441\u0442\u0430 \u0432 input \u0441\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 onInput",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,input:!0}),fireEvent.change(getInput(),{target:{value:"change"}}),expect(a).toHaveBeenCalledTimes(1),expect(a).toHaveBeenCalledWith("change")}),it("disabled - \u043F\u0440\u0438 \u0432\u0432\u043E\u0434\u0435 \u0442\u0435\u043A\u0441\u0442\u0430 \u0432 input \u043D\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 onInput",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,disabled:!0,input:!0}),fireEvent.change(getInput(),{target:{value:"change"}}),expect(a).not.toHaveBeenCalled()}),it("\u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F inputValue",function(){var a=jest.fn(),b="\u044F \u0438\u0449\u0443";renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,inputValue:b,input:!0}),expect(getInput().value).toEqual(b)}),it("\u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F inputDefaultValue",function(){renderComponent({items:items,value:[items[0]],onChange:jest.fn(),inputDefaultValue:"\u044F \u0438\u0449\u0443",input:!0}),expect(getInput().value).toEqual("\u044F \u0438\u0449\u0443")}),it("disabled - \u043F\u0440\u0438 \u0443\u0434\u0430\u043B\u0435\u043D\u0438\u0438 \u0442\u0435\u043A\u0441\u0442\u0430 \u043F\u043E Backspace \u043E\u043D \u043D\u0435 \u0443\u0434\u0430\u043B\u044F\u0435\u0442\u0441\u044F",function(){var a=jest.fn(),b="\u044F \u0438\u0449\u0443";renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,inputValue:b,disabled:!0,input:!0}),fireEvent.keyDown(getInput(),{key:"Backspace"}),fireEvent.keyDown(getInput(),{key:"Backspace"}),fireEvent.keyDown(getInput(),{key:"Backspace"}),expect(getInput().value).toEqual(b)}),it("clearButton \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F \u043F\u0440\u0438 \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u043C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0438",function(){renderComponent({items:items,value:[items[0]],onChange:jest.fn(),clearButton:!0});var a=getClearButton();expect(a).toBeInTheDocument()}),it("\u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 \u043E\u0447\u0438\u0441\u0442\u043A\u0438",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0});var b=getClearButton();fireEvent.click(b),expect(a).toHaveBeenCalledWith(null,{e:expect.any(Object)})}),it("\u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 Backspace",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0}),fireEvent.keyDown(getInput(),{key:"Backspace"}),expect(a).toHaveBeenCalledWith(null,{e:expect.any(Object)})}),it("disabled - \u043D\u0435 \u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 \u043E\u0447\u0438\u0441\u0442\u043A\u0438",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0,disabled:!0});var b=getClearButton();fireEvent.click(b),expect(a).not.toHaveBeenCalled()}),it("disabled - \u043D\u0435 \u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 Backspace",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0,disabled:!0}),fireEvent.keyDown(getInput(),{key:"Backspace"}),expect(a).not.toHaveBeenCalled()}),it("disabled - \u043D\u0435 \u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 Backspace",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0,disabled:!0}),fireEvent.keyDown(getInput(),{key:"Backspace"}),expect(a).not.toHaveBeenCalled()}),it("\u0433\u0440\u0443\u043F\u043F\u044B \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u044E\u0442\u0441\u044F",function(){renderComponent({items:items,groups:groups,value:[items[0]],onChange:jest.fn()}),inputClick(),animateDelay(),groups.map(function(a){return expect(screen.getByText(a.label)).toBeInTheDocument()})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 dropdownForm",function(){["default","brick","round"].map(function(a){it("dropdownForm = ".concat(a),function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,dropdownForm:a,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown()).toHaveClass(cnListBox({form:a}).split(" ")[1])})})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 form",function(){["default","defaultClear","defaultBrick","brick","brickDefault","brickClear","brickRound","round","roundClear","roundBrick","clearRound","clearDefault","clearBrick","clear"].map(function(a){it("form = ".concat(a),function(){renderComponent({items:items,form:a,onChange:jest.fn()}),expect(getRender()).toHaveClass(cnFieldControlLayout({form:a}).split(" ")[1])})})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 view",function(){["default","clear"].map(function(a){it("view = ".concat(a),function(){renderComponent({items:items,view:a,onChange:jest.fn()}),expect(getRender()).toHaveClass(cnFieldControlLayout({view:a}).split(" ")[1])})})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 status",function(){["alert","success","warning"].map(function(a){it("status = ".concat(a),function(){renderComponent({items:items,status:a,onChange:jest.fn()}),expect(getRender()).toHaveClass(cnFieldControlLayout({status:a}).split(" ")[1])})})}),it("\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B disabled \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u044E\u0442\u0441\u044F \u0441 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0449\u0435\u043C \u043A\u043B\u0430\u0441\u0441\u043E\u043C",function(){jest.useFakeTimers(),act(function(){renderComponent({items:itemsWithDisabled,onChange:jest.fn()})}),inputClick(),animateDelay(),itemsWithDisabled.map(function(a,b){a.disabled?expect(getItem(b)).toHaveClass(cnListItem({disabled:!0}).split(" ")[1]):expect(getItem(b)).not.toHaveClass(cnListItem({disabled:!0}).split(" ")[1])})}),describe("\u043F\u043E \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u043C disabled \u043D\u0435 \u043E\u0442\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 onChange",function(){itemsWithDisabled.map(function(a,b){it("item ".concat(b," disabled = ").concat(a.disabled),function(){jest.useFakeTimers();var c=jest.fn();act(function(){renderComponent({items:itemsWithDisabled,onChange:c})}),inputClick(),animateDelay(),fireEvent.click(getItem(b)),a.disabled?expect(c).not.toHaveBeenCalled():expect(c).toHaveBeenCalled()})})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 isLoading",function(){it("isLoading = true",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,isLoading:!0,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getLoader()).toBeInTheDocument()}),[!1,void 0].map(function(a){it("isLoading = ".concat(a),function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,isLoading:a,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getLoader()).not.toBeInTheDocument()})})}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onCreate",function(){jest.useFakeTimers();var a=jest.fn(),b="test";act(function(){renderComponent({items:items,onCreate:a,inputValue:b,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getCreateButton()).toBeInTheDocument(),onCreateClick(),expect(a).toHaveBeenCalled(),expect(a).toHaveBeenCalledWith(b,{e:expect.any(Object)})}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 labelForCreate",function(){jest.useFakeTimers();act(function(){renderComponent({items:items,labelForCreate:"\u0421\u043E\u0437\u0434\u0430\u0442\u044C",onCreate:jest.fn(),onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getCreateButton()).toBeInTheDocument()}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 iconClear",function(){jest.useFakeTimers();var a=createIconMock("iconClear");act(function(){renderComponent({items:items,iconClear:a,clearButton:!0,inputValue:"test",onCreate:jest.fn(),onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getClearButton().textContent).toEqual("iconClear")}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 renderItem",function(){jest.useFakeTimers();var a=function(a){var b=a.item;return React.createElement("div",{className:"test"},b.label)};act(function(){renderComponent({items:items,renderItem:a,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown().querySelectorAll(".test")[0]).toBeInTheDocument(),expect(getDropdown().querySelectorAll(".test")[0].textContent).toEqual(items[0].label)}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 renderValue",function(){jest.useFakeTimers();var a=function(a){var b=a.value;return React.createElement(React.Fragment,null,b.map(function(a){return React.createElement("div",{className:"test"},a.label)}))};act(function(){renderComponent({items:items,renderValue:a,value:[items[0]],onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getValueControl().querySelector(".test")).toBeInTheDocument()}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 selectAll",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var b=getItem(0);expect(b).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(b).toHaveClass(cnSelectItemAll())}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 selectAll \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,value:items,groups:groups,selectAll:!0,onChange:a})}),inputClick(),animateDelay(),expect(getSelectAllOptions().length).toEqual(2)}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 selectAllLabel",function(){jest.useFakeTimers();var a=jest.fn(),b="\u0412\u0441\u0435";act(function(){renderComponent({items:items,selectAll:!0,onChange:a,selectAllLabel:b})}),inputClick(),animateDelay();var c=getItem(0);expect(c).toHaveTextContent(b),expect(c).toHaveClass(cnSelectItemAll())}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 \u043A\u043B\u0438\u043A\u0430 selectAll",function(){it("\u0435\u0441\u043B\u0438 \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var b=getItem(0);expect(b).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(b).toHaveClass(cnSelectItemAll()),fireEvent.click(b),expect(a).toHaveBeenCalledWith(items,{e:expect.any(Object)})}),it("\u0435\u0441\u043B\u0438 \u0432\u044B\u0431\u0440\u0430\u043D \u0445\u043E\u0442\u044F \u0431\u044B 1 \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,value:[items[0]],selectAll:!0,onChange:a})}),inputClick(),animateDelay();var b=getItem(0);expect(b).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(b).toHaveClass(cnSelectItemAll()),fireEvent.click(b),expect(a).toHaveBeenCalledWith(items,{e:expect.any(Object)})}),it("\u0435\u0441\u043B\u0438 \u0432\u044B\u0431\u0440\u0430\u043D\u044B \u0432\u0441\u0435 \u0442\u043E \u043E\u0442\u043C\u0435\u043D\u044F\u0435\u0442 \u0432\u0441\u0435 \u0432\u044B\u0431\u043E\u0440\u044B",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,value:items,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var b=getItem(0);expect(b).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(b).toHaveClass(cnSelectItemAll()),fireEvent.click(b),expect(a).toHaveBeenCalledWith([],{e:expect.any(Object)})}),it("c \u0433\u0440\u0443\u043F\u043F\u0430\u043C\u0438, \u0435\u0441\u043B\u0438 \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn(),b=0;act(function(){renderComponent({items:items,groups:groups,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var c=getSelectAllOption(b);expect(c).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(c).toHaveClass(cnSelectItemAll()),fireEvent.click(c),expect(a).toHaveBeenCalledWith(items.filter(function(a){return a.groupId===groups[b].id}),{e:expect.any(Object)})}),it("c \u0433\u0440\u0443\u043F\u043F\u0430\u043C\u0438, \u0435\u0441\u043B\u0438 \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn(),b=0;act(function(){renderComponent({items:items,groups:groups,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var c=getSelectAllOption(b);expect(c).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(c).toHaveClass(cnSelectItemAll()),fireEvent.click(c),expect(a).toHaveBeenCalledWith(items.filter(function(a){return a.groupId===groups[b].id}),{e:expect.any(Object)})}),it("c \u0433\u0440\u0443\u043F\u043F\u0430\u043C\u0438, \u0435\u0441\u043B\u0438 \u0432\u044B\u0431\u0440\u0430\u043D \u0445\u043E\u0442\u044F \u0431\u044B 1 \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn(),b=0;act(function(){renderComponent({items:items,groups:groups,value:[items.filter(function(a){return a.groupId===groups[b].id})[0]],selectAll:!0,onChange:a})}),inputClick(),animateDelay();var c=getSelectAllOption(b);expect(c).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(c).toHaveClass(cnSelectItemAll()),fireEvent.click(c),expect(a).toHaveBeenCalledWith(items.filter(function(a){return a.groupId===groups[b].id}),{e:expect.any(Object)})}),it("c \u0433\u0440\u0443\u043F\u043F\u0430\u043C\u0438, \u0435\u0441\u043B\u0438 \u0432\u044B\u0431\u0440\u0430\u043D\u044B \u0432\u0441\u0435 \u0442\u043E \u043E\u0442\u043C\u0435\u043D\u044F\u0435\u0442 \u0432\u0441\u0435 \u0432\u044B\u0431\u043E\u0440\u044B \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn(),b=0;act(function(){renderComponent({items:items,groups:groups,value:items.filter(function(a){return a.groupId===groups[b].id}),selectAll:!0,onChange:a})}),inputClick(),animateDelay();var c=getSelectAllOption(b);expect(c).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(c).toHaveClass(cnSelectItemAll()),fireEvent.click(c),expect(a).toHaveBeenCalledWith([],{e:expect.any(Object)})})})});
|
|
1
|
+
import{act,fireEvent,render,screen,within}from"@testing-library/react";import React from"react";import{createIconMock}from"../../../../../__mocks__/IconMock";import{cnFieldArrayValueInlineControl}from"../../../FieldComponents";import{cnFieldControlLayout}from"../../../FieldComponents/FieldControlLayout";import{cnListBox,cnListItem,cnListLoader}from"../../../ListCanary";import{cnSelectControlLayout}from"../../SelectControlLayout";import{cnSelectCreateButton}from"../../SelectCreateButton";import{cnSelectItemAll}from"../../SelectItemAll";import{SelectMultiple}from"../SelectMultiple";var testId="SelectMultipleCanary",animationDuration=200,renderComponent=function(a){return render(React.createElement(React.Fragment,null,React.createElement("div",{"data-testid":"outside"}),React.createElement(SelectMultiple,Object.assign({"data-testid":testId,multiple:!0},a))))},getRender=function(){return screen.getByTestId(testId)},getOutside=function(){return screen.getByTestId("outside")},getInput=function(){return getRender().querySelector("input")},inputClick=function(){return fireEvent.click(getInput())},animateDelay=function(){act(function(){jest.advanceTimersByTime(animationDuration)})},getDropdown=function(){return screen.queryByRole("listbox")},outsideClick=function(){return fireEvent.mouseDown(getOutside())},getValueControl=function(){return getRender().querySelector(".".concat(cnFieldArrayValueInlineControl()))},getItems=function(){return getDropdown().querySelectorAll(".".concat(cnListItem()))},getSelectAllOptions=function(){return getDropdown().querySelectorAll(".".concat(cnSelectItemAll()))},getSelectAllOption=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:0;return getSelectAllOptions()[a]},getItem=function(){var a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:0;return getItems()[a]},getClearButton=function(){return getRender().querySelector(".".concat(cnSelectControlLayout("ClearButton")))},getLoader=function(){return getDropdown().querySelector(".".concat(cnListLoader()))},getCreateButton=function(){return getDropdown().querySelector(".".concat(cnSelectCreateButton()))},onCreateClick=function(){return fireEvent.click(getCreateButton())},items=[{id:1,label:"Item 1",groupId:1},{id:2,label:"Item 2",groupId:1},{id:3,label:"Item 3",groupId:2}],itemsWithDisabled=[{id:1,label:"Item 1",groupId:1,disabled:!0},{id:2,label:"Item 2",groupId:1},{id:3,label:"Item 3",groupId:2,disabled:!0}],groups=[{id:1,label:"Group 1"},{id:2,label:"Group 2"}];describe("SelectMultiple",function(){it("\u0440\u0435\u043D\u0434\u0435\u0440\u0438\u0442\u0441\u044F \u0431\u0435\u0437 \u043E\u0448\u0438\u0431\u043E\u043A",function(){expect(function(){return renderComponent({items:items,onChange:jest.fn()})}).not.toThrow()}),it("\u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043F\u043B\u0435\u0439\u0441\u0445\u043E\u043B\u0434\u0435\u0440, \u0435\u0441\u043B\u0438 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E",function(){renderComponent({items:items,onChange:jest.fn(),placeholder:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442"}),expect(screen.getByPlaceholderText("\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442")).toBeInTheDocument()}),it("\u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435",function(){renderComponent({items:items,value:[items[1]],onChange:jest.fn(),placeholder:"\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u044D\u043B\u0435\u043C\u0435\u043D\u0442"}),expect(screen.getByText("Item 2")).toBeInTheDocument()}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 ref",function(){var a={current:null};renderComponent({items:items,ref:a,onChange:jest.fn()}),expect(a.current).toBeTruthy()}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 inputRef",function(){var a={current:null};renderComponent({items:items,inputRef:a,onChange:jest.fn()}),expect(a.current).toBeTruthy()}),it("\u041F\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044F \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0439 className",function(){renderComponent({items:items,className:"custom-class",onChange:jest.fn()}),expect(getRender()).toHaveClass("custom-class")}),it("\u041F\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044E\u0442\u0441\u044F \u0434\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044B",function(){renderComponent({items:items,onChange:jest.fn(),"aria-placeholder":"test-autocomplete"}),expect(getRender()).toHaveAttribute("aria-placeholder","test-autocomplete")}),it("\u043E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043F\u043E \u043A\u043B\u0438\u043A\u0443",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown()).toBeInTheDocument()}),it("\u043E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043F\u043E \u043A\u043B\u0438\u043A\u0443",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown()).toBeInTheDocument()}),it("\u0437\u0430\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043F\u043E \u043A\u043B\u0438\u043A\u0443 \u0432\u043D\u0435 \u043A\u043E\u043C\u043F\u043E\u043D\u0435\u043D\u0442\u0430",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown()).toBeInTheDocument(),outsideClick(),animateDelay(),expect(getDropdown()).not.toBeInTheDocument()}),it("\u041E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u044E\u0442\u0441\u044F \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn()})}),inputClick(),animateDelay(),items.map(function(a){return expect(screen.getByText(a.label)).toBeInTheDocument()})}),it("\u043D\u0435 \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043F\u043E \u043A\u043B\u0438\u043A\u0443 \u043F\u0440\u0438 disabled",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,onChange:jest.fn(),disabled:!0})}),inputClick(),animateDelay(),expect(getDropdown()).not.toBeInTheDocument()}),it("value \u0432\u0435\u0440\u043D\u043E \u0440\u0435\u043D\u0434\u0435\u0440\u0438\u0442\u0441\u044F",function(){var a=[items[2]];renderComponent({items:items,value:a,onChange:jest.fn()}),expect(getValueControl().textContent).toEqual(a[0].label)}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onChange",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,onChange:a})}),inputClick(),animateDelay(),fireEvent.click(getItem(0)),expect(a).toHaveBeenCalled(),expect(a).toHaveBeenCalledTimes(1),expect(a).toHaveBeenCalledWith([items[0]],{e:expect.any(Object)})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onFocus",function(){it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onFocus",function(){var a=jest.fn();renderComponent({items:items,onChange:jest.fn(),onFocus:a}),expect(a).toHaveBeenCalledTimes(0),getInput().focus(),expect(a).toHaveBeenCalledTimes(1)})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onBlur",function(){it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onBlur",function(){var a=jest.fn();renderComponent({items:items,onChange:jest.fn(),onBlur:a}),getInput().focus(),expect(a).toHaveBeenCalledTimes(0),getInput().blur(),expect(a).toHaveBeenCalledTimes(1)})}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onDropdownOpen",function(){var a=jest.fn();renderComponent({items:items,onChange:jest.fn(),onDropdownOpen:a}),inputClick(),expect(a).toHaveBeenCalledTimes(2),outsideClick(),expect(a).toHaveBeenCalledTimes(3),inputClick(),expect(a).toHaveBeenCalledTimes(4),outsideClick(),expect(a).toHaveBeenCalledTimes(5)}),it("\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441 \u043A\u043B\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044B",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,onChange:a})});var b=getInput();fireEvent.focus(b),animateDelay(),fireEvent.keyDown(b,{key:"ArrowDown"}),expect(getDropdown()).toBeInTheDocument(),fireEvent.keyDown(b,{key:"ArrowUp"}),fireEvent.keyDown(b,{key:"ArrowDown"}),fireEvent.keyDown(b,{key:"Enter"}),expect(a).toHaveBeenCalledWith([items[1]],{e:expect.any(Object)}),fireEvent.keyDown(b,{key:"Escape"}),animateDelay(),expect(getDropdown()).not.toBeInTheDocument(),fireEvent.keyDown(b,{key:"Enter"}),animateDelay(),expect(getDropdown()).toBeInTheDocument(),fireEvent.keyDown(b,{key:"Tab"}),animateDelay(),expect(getDropdown()).not.toBeInTheDocument(),fireEvent.keyDown(b,{key:"Tab"}),expect(b).not.toHaveFocus()}),it("disable - \u0443\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441 \u043A\u043B\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044B \u043D\u0435 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,onChange:a,disabled:!0})});var b=getInput();fireEvent.focus(b),animateDelay(),fireEvent.keyDown(b,{key:"ArrowDown"}),expect(getDropdown()).not.toBeInTheDocument(),expect(b).not.toHaveFocus(),fireEvent.keyDown(b,{key:"ArrowDown"}),expect(getDropdown()).not.toBeInTheDocument(),expect(b).not.toHaveFocus(),fireEvent.keyDown(b,{key:"Enter"}),expect(getDropdown()).not.toBeInTheDocument(),expect(b).not.toHaveFocus()}),it("\u0438\u043C\u0435\u0435\u0442\u0441\u044F \u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E\u0441\u0442\u044C \u0432\u0432\u043E\u0434\u0438\u0442\u044C \u0442\u0435\u043A\u0441\u0442 \u0432 input",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,input:!0});var b=getInput();fireEvent.change(b,{target:{value:"change"}}),expect(b.value).toEqual("change")}),it("\u0438\u043C\u0435\u0435\u0442\u0441\u044F \u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E\u0441\u0442\u044C \u0432\u0432\u043E\u0434\u0438\u0442\u044C \u0442\u0435\u043A\u0441\u0442 \u0432 input",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,input:!0});var b=getInput();fireEvent.change(b,{target:{value:"change"}}),expect(b.value).toEqual("change"),expect(a).toHaveBeenCalledWith("change")}),it("\u043F\u0440\u0438 \u0432\u0432\u043E\u0434\u0435 \u0442\u0435\u043A\u0441\u0442\u0430 \u0432 input \u0441\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 onInput",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,input:!0}),fireEvent.change(getInput(),{target:{value:"change"}}),expect(a).toHaveBeenCalledTimes(1),expect(a).toHaveBeenCalledWith("change")}),it("disabled - \u043F\u0440\u0438 \u0432\u0432\u043E\u0434\u0435 \u0442\u0435\u043A\u0441\u0442\u0430 \u0432 input \u043D\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 onInput",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,disabled:!0,input:!0}),fireEvent.change(getInput(),{target:{value:"change"}}),expect(a).not.toHaveBeenCalled()}),it("\u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F inputValue",function(){var a=jest.fn(),b="\u044F \u0438\u0449\u0443";renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,inputValue:b,input:!0}),expect(getInput().value).toEqual(b)}),it("\u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F inputDefaultValue",function(){renderComponent({items:items,value:[items[0]],onChange:jest.fn(),inputDefaultValue:"\u044F \u0438\u0449\u0443",input:!0}),expect(getInput().value).toEqual("\u044F \u0438\u0449\u0443")}),it("disabled - \u043F\u0440\u0438 \u0443\u0434\u0430\u043B\u0435\u043D\u0438\u0438 \u0442\u0435\u043A\u0441\u0442\u0430 \u043F\u043E Backspace \u043E\u043D \u043D\u0435 \u0443\u0434\u0430\u043B\u044F\u0435\u0442\u0441\u044F",function(){var a=jest.fn(),b="\u044F \u0438\u0449\u0443";renderComponent({items:items,value:[items[0]],onChange:jest.fn(),onInput:a,inputValue:b,disabled:!0,input:!0}),fireEvent.keyDown(getInput(),{key:"Backspace"}),fireEvent.keyDown(getInput(),{key:"Backspace"}),fireEvent.keyDown(getInput(),{key:"Backspace"}),expect(getInput().value).toEqual(b)}),it("clearButton \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044F \u043F\u0440\u0438 \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u043C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0438",function(){renderComponent({items:items,value:[items[0]],onChange:jest.fn(),clearButton:!0});var a=getClearButton();expect(a).toBeInTheDocument()}),it("\u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 \u043E\u0447\u0438\u0441\u0442\u043A\u0438",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0});var b=getClearButton();fireEvent.click(b),expect(a).toHaveBeenCalledWith(null,{e:expect.any(Object)})}),it("\u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 Backspace",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0}),fireEvent.keyDown(getInput(),{key:"Backspace"}),expect(a).toHaveBeenCalledWith(null,{e:expect.any(Object)})}),it("disabled - \u043D\u0435 \u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 \u043E\u0447\u0438\u0441\u0442\u043A\u0438",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0,disabled:!0});var b=getClearButton();fireEvent.click(b),expect(a).not.toHaveBeenCalled()}),it("disabled - \u043D\u0435 \u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 Backspace",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0,disabled:!0}),fireEvent.keyDown(getInput(),{key:"Backspace"}),expect(a).not.toHaveBeenCalled()}),it("disabled - \u043D\u0435 \u043E\u0447\u0438\u0449\u0430\u0435\u0442 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u043F\u0440\u0438 \u043D\u0430\u0436\u0430\u0442\u0438\u0438 \u043D\u0430 \u043A\u043D\u043E\u043F\u043A\u0443 Backspace",function(){var a=jest.fn();renderComponent({items:items,value:[items[0]],onChange:a,clearButton:!0,disabled:!0}),fireEvent.keyDown(getInput(),{key:"Backspace"}),expect(a).not.toHaveBeenCalled()}),it("\u0433\u0440\u0443\u043F\u043F\u044B \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u044E\u0442\u0441\u044F",function(){renderComponent({items:items,groups:groups,value:[items[0]],onChange:jest.fn()}),inputClick(),animateDelay(),groups.map(function(a){return expect(screen.getByText(a.label)).toBeInTheDocument()})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 dropdownForm",function(){["default","brick","round"].map(function(a){it("dropdownForm = ".concat(a),function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,dropdownForm:a,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown()).toHaveClass(cnListBox({form:a}).split(" ")[1])})})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 form",function(){["default","defaultClear","defaultBrick","brick","brickDefault","brickClear","brickRound","round","roundClear","roundBrick","clearRound","clearDefault","clearBrick","clear"].map(function(a){it("form = ".concat(a),function(){renderComponent({items:items,form:a,onChange:jest.fn()}),expect(getRender()).toHaveClass(cnFieldControlLayout({form:a}).split(" ")[1])})})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 view",function(){["default","clear"].map(function(a){it("view = ".concat(a),function(){renderComponent({items:items,view:a,onChange:jest.fn()}),expect(getRender()).toHaveClass(cnFieldControlLayout({view:a}).split(" ")[1])})})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 status",function(){["alert","success","warning"].map(function(a){it("status = ".concat(a),function(){renderComponent({items:items,status:a,onChange:jest.fn()}),expect(getRender()).toHaveClass(cnFieldControlLayout({status:a}).split(" ")[1])})})}),it("\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B disabled \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0430\u044E\u0442\u0441\u044F \u0441 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0449\u0435\u043C \u043A\u043B\u0430\u0441\u0441\u043E\u043C",function(){jest.useFakeTimers(),act(function(){renderComponent({items:itemsWithDisabled,onChange:jest.fn()})}),inputClick(),animateDelay(),itemsWithDisabled.map(function(a,b){a.disabled?expect(getItem(b)).toHaveClass(cnListItem({disabled:!0}).split(" ")[1]):expect(getItem(b)).not.toHaveClass(cnListItem({disabled:!0}).split(" ")[1])})}),describe("\u043F\u043E \u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u043C disabled \u043D\u0435 \u043E\u0442\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 onChange",function(){itemsWithDisabled.map(function(a,b){it("item ".concat(b," disabled = ").concat(a.disabled),function(){jest.useFakeTimers();var c=jest.fn();act(function(){renderComponent({items:itemsWithDisabled,onChange:c})}),inputClick(),animateDelay(),fireEvent.click(getItem(b)),a.disabled?expect(c).not.toHaveBeenCalled():expect(c).toHaveBeenCalled()})})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 isLoading",function(){it("isLoading = true",function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,isLoading:!0,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getLoader()).toBeInTheDocument()}),[!1,void 0].map(function(a){it("isLoading = ".concat(a),function(){jest.useFakeTimers(),act(function(){renderComponent({items:items,isLoading:a,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getLoader()).not.toBeInTheDocument()})})}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 onCreate",function(){jest.useFakeTimers();var a=jest.fn(),b="test";act(function(){renderComponent({items:items,onCreate:a,inputValue:b,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getCreateButton()).toBeInTheDocument(),onCreateClick(),expect(a).toHaveBeenCalled(),expect(a).toHaveBeenCalledWith(b,{e:expect.any(Object)})}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 labelForCreate",function(){jest.useFakeTimers();act(function(){renderComponent({items:items,labelForCreate:"\u0421\u043E\u0437\u0434\u0430\u0442\u044C",onCreate:jest.fn(),onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getCreateButton()).toBeInTheDocument()}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 iconClear",function(){jest.useFakeTimers();var a=createIconMock("iconClear");act(function(){renderComponent({items:items,iconClear:a,clearButton:!0,inputValue:"test",onCreate:jest.fn(),onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getClearButton().textContent).toEqual("iconClear")}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 renderItem",function(){jest.useFakeTimers();var a=function(a){var b=a.item;return React.createElement("div",{className:"test"},b.label)};act(function(){renderComponent({items:items,renderItem:a,onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getDropdown().querySelectorAll(".test")[0]).toBeInTheDocument(),expect(getDropdown().querySelectorAll(".test")[0].textContent).toEqual(items[0].label)}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 renderValue",function(){jest.useFakeTimers();var a=function(a){var b=a.value;return React.createElement(React.Fragment,null,b.map(function(a){return React.createElement("div",{className:"test"},a.label)}))};act(function(){renderComponent({items:items,renderValue:a,value:[items[0]],onChange:jest.fn()})}),inputClick(),animateDelay(),expect(getValueControl().querySelector(".test")).toBeInTheDocument()}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 selectAll",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var b=getItem(0);expect(b).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(b).toHaveClass(cnSelectItemAll())}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 selectAll \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,value:items,groups:groups,selectAll:!0,onChange:a})}),inputClick(),animateDelay(),expect(getSelectAllOptions().length).toEqual(2)}),it("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 selectAllLabel",function(){jest.useFakeTimers();var a=jest.fn(),b="\u0412\u0441\u0435";act(function(){renderComponent({items:items,selectAll:!0,onChange:a,selectAllLabel:b})}),inputClick(),animateDelay();var c=getItem(0);expect(c).toHaveTextContent(b),expect(c).toHaveClass(cnSelectItemAll())}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 \u043A\u043B\u0438\u043A\u0430 selectAll",function(){it("\u0435\u0441\u043B\u0438 \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var b=getItem(0);expect(b).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(b).toHaveClass(cnSelectItemAll()),fireEvent.click(b),expect(a).toHaveBeenCalledWith(items,{e:expect.any(Object)})}),it("\u0435\u0441\u043B\u0438 \u0432\u044B\u0431\u0440\u0430\u043D \u0445\u043E\u0442\u044F \u0431\u044B 1 \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,value:[items[0]],selectAll:!0,onChange:a})}),inputClick(),animateDelay();var b=getItem(0);expect(b).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(b).toHaveClass(cnSelectItemAll()),fireEvent.click(b),expect(a).toHaveBeenCalledWith(items,{e:expect.any(Object)})}),it("\u0435\u0441\u043B\u0438 \u0432\u044B\u0431\u0440\u0430\u043D\u044B \u0432\u0441\u0435 \u0442\u043E \u043E\u0442\u043C\u0435\u043D\u044F\u0435\u0442 \u0432\u0441\u0435 \u0432\u044B\u0431\u043E\u0440\u044B",function(){jest.useFakeTimers();var a=jest.fn();act(function(){renderComponent({items:items,value:items,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var b=getItem(0);expect(b).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(b).toHaveClass(cnSelectItemAll()),fireEvent.click(b),expect(a).toHaveBeenCalledWith([],{e:expect.any(Object)})}),it("c \u0433\u0440\u0443\u043F\u043F\u0430\u043C\u0438, \u0435\u0441\u043B\u0438 \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn(),b=0;act(function(){renderComponent({items:items,groups:groups,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var c=getSelectAllOption(b);expect(c).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(c).toHaveClass(cnSelectItemAll()),fireEvent.click(c),expect(a).toHaveBeenCalledWith(items.filter(function(a){return a.groupId===groups[b].id}),{e:expect.any(Object)})}),it("c \u0433\u0440\u0443\u043F\u043F\u0430\u043C\u0438, \u0435\u0441\u043B\u0438 \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u043E \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn(),b=0;act(function(){renderComponent({items:items,groups:groups,selectAll:!0,onChange:a})}),inputClick(),animateDelay();var c=getSelectAllOption(b);expect(c).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(c).toHaveClass(cnSelectItemAll()),fireEvent.click(c),expect(a).toHaveBeenCalledWith(items.filter(function(a){return a.groupId===groups[b].id}),{e:expect.any(Object)})}),it("c \u0433\u0440\u0443\u043F\u043F\u0430\u043C\u0438, \u0435\u0441\u043B\u0438 \u0432\u044B\u0431\u0440\u0430\u043D \u0445\u043E\u0442\u044F \u0431\u044B 1 \u0442\u043E \u0432\u044B\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn(),b=0;act(function(){renderComponent({items:items,groups:groups,value:[items.filter(function(a){return a.groupId===groups[b].id})[0]],selectAll:!0,onChange:a})}),inputClick(),animateDelay();var c=getSelectAllOption(b);expect(c).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(c).toHaveClass(cnSelectItemAll()),fireEvent.click(c),expect(a).toHaveBeenCalledWith(items.filter(function(a){return a.groupId===groups[b].id}),{e:expect.any(Object)})}),it("c \u0433\u0440\u0443\u043F\u043F\u0430\u043C\u0438, \u0435\u0441\u043B\u0438 \u0432\u044B\u0431\u0440\u0430\u043D\u044B \u0432\u0441\u0435 \u0442\u043E \u043E\u0442\u043C\u0435\u043D\u044F\u0435\u0442 \u0432\u0441\u0435 \u0432\u044B\u0431\u043E\u0440\u044B \u0432 \u0433\u0440\u0443\u043F\u043F\u0435",function(){jest.useFakeTimers();var a=jest.fn(),b=0;act(function(){renderComponent({items:items,groups:groups,value:items.filter(function(a){return a.groupId===groups[b].id}),selectAll:!0,onChange:a})}),inputClick(),animateDelay();var c=getSelectAllOption(b);expect(c).toHaveTextContent("\u0412\u044B\u0431\u0440\u0430\u0442\u044C \u0432\u0441\u0435"),expect(c).toHaveClass(cnSelectItemAll()),fireEvent.click(c),expect(a).toHaveBeenCalledWith([],{e:expect.any(Object)})})}),describe("\u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 dropdownContainer",function(){it("\u0440\u0435\u043D\u0434\u0435\u0440\u0438\u0442 dropdown \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E \u0432 document.body",function(){jest.useFakeTimers();var a=document.createElement("div");a.setAttribute("data-testid","container"),document.body.appendChild(a),act(function(){renderComponent({items:items,onChange:jest.fn(),dropdownContainer:void 0})}),inputClick(),animateDelay(),expect(screen.queryByRole("listbox")).not.toBeNull(),expect(within(a).queryByRole("listbox")).not.toBeInTheDocument()}),it("\u0440\u0435\u043D\u0434\u0435\u0440\u0438\u0442 dropdown \u0432\u043D\u0443\u0442\u0440\u0438 \u043F\u0435\u0440\u0435\u0434\u0430\u043D\u043D\u043E\u0433\u043E \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440\u0430",function(){jest.useFakeTimers();var a=document.createElement("div");a.setAttribute("data-testid","container"),document.body.appendChild(a),act(function(){renderComponent({items:items,onChange:jest.fn(),dropdownContainer:a})}),inputClick(),animateDelay(),expect(within(a).getByRole("listbox")).toBeInTheDocument()})})});
|
|
2
2
|
//# sourceMappingURL=SelectMultiple.test.js.map
|