@hh.ru/magritte-ui-tree-selector 5.5.3 → 5.5.4
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/Action.js.map +1 -1
- package/Item.js +1 -1
- package/Item.js.map +1 -1
- package/ItemContent.js +1 -1
- package/ItemContent.js.map +1 -1
- package/ItemsList.js +1 -1
- package/ItemsList.js.map +1 -1
- package/MobileDelimiter.js.map +1 -1
- package/MobileItem.js.map +1 -1
- package/MobileItemsList.js +1 -1
- package/MobileItemsList.js.map +1 -1
- package/MobileParentItem.js.map +1 -1
- package/TreeSelector.js +1 -1
- package/TreeSelector.js.map +1 -1
- package/TreeSelectorDummy.js +1 -1
- package/TreeSelectorDummy.js.map +1 -1
- package/TreeSelectorItemBase.js.map +1 -1
- package/TreeSelectorWrapper.js +2 -2
- package/TreeSelectorWrapper.js.map +1 -1
- package/collection/treeCollection.js.map +1 -1
- package/collection/treeCollectionHelper.js.map +1 -1
- package/index.css +45 -45
- package/index.js +1 -1
- package/index.mock.js +1 -1
- package/index.mock.js.map +1 -1
- package/package.json +22 -22
- package/strategy/createSingleValueToggler.js.map +1 -1
- package/strategy/createTreeCollectionToggler.js.map +1 -1
- package/strategy/dummyToggle.js.map +1 -1
- package/strategy/immutableSelectionStrategy.js.map +1 -1
- package/strategy/selectionStrategy.js.map +1 -1
- package/tree-selector-item-CU6wD1FW.js +5 -0
- package/tree-selector-item-CU6wD1FW.js.map +1 -0
- package/useAnimationTimeout.js +1 -1
- package/useAnimationTimeout.js.map +1 -1
- package/useDisabled.js.map +1 -1
- package/useExpanded.js.map +1 -1
- package/useIndeterminate.js.map +1 -1
- package/useRenderInput.js.map +1 -1
- package/useSelected.js.map +1 -1
- package/tree-selector-item-CqHkZG6_.js +0 -5
- package/tree-selector-item-CqHkZG6_.js.map +0 -1
package/useRenderInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRenderInput.js","sources":["
|
|
1
|
+
{"version":3,"file":"useRenderInput.js","sources":["src/useRenderInput.tsx"],"sourcesContent":["import { ReactElement, RefCallback, useCallback, useEffect, useState, RefObject, forwardRef } from 'react';\n\nimport { useDebounce } from '@hh.ru/magritte-common-func-utils';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { SearchInput, SearchInputProps } from '@hh.ru/magritte-ui-input';\nimport { SearchInputPropsWithRef } from '@hh.ru/magritte-ui-tree-selector/types';\nimport { useAnimationTimeout } from '@hh.ru/magritte-ui-tree-selector/useAnimationTimeout';\n\ntype WrapperInputProps = SearchInputProps & {\n value: string;\n onChange: (newValue: string) => void;\n parentRef: RefCallback<HTMLInputElement>;\n};\n\nconst WrapperInput = forwardRef<HTMLInputElement, WrapperInputProps>(({ parentRef, ...props }, ref) => {\n const multiRef = useMultipleRefs(ref, parentRef);\n return <SearchInput {...props} ref={multiRef} data-qa=\"tree-selector-search-input\" />;\n});\n\nWrapperInput.displayName = 'TreeSelectorInput';\n\nexport interface UseRenderInputHook {\n (inputRef: RefObject<HTMLInputElement>): {\n contentFilterQuery: string;\n setInputValue: (newValue: string) => void;\n handleChangeInput: (newValue: string) => void;\n renderInput: (props?: SearchInputPropsWithRef) => ReactElement;\n };\n}\n\nexport const useRenderInput: UseRenderInputHook = (inputRef) => {\n const [contentFilterQuery, setContentFilterQuery] = useState('');\n const { animationTimeout } = useAnimationTimeout();\n const [value, setValue] = useState('');\n const { isMobile } = useBreakpoint();\n\n const inputRefCallback: RefCallback<HTMLInputElement> = useCallback((node) => {\n if (!node) {\n setValue('');\n setContentFilterQuery('');\n }\n }, []);\n\n const ref = useMultipleRefs(inputRef, inputRefCallback);\n\n useEffect(() => {\n setValue('');\n setContentFilterQuery('');\n }, [isMobile]);\n\n const debouncedContentFilterQuery = useDebounce(\n useCallback((newValue: string) => {\n setContentFilterQuery(newValue);\n }, []),\n animationTimeout\n );\n\n const handleChangeInput = useCallback(\n (newValue: string) => {\n debouncedContentFilterQuery(newValue);\n setValue(newValue);\n },\n [debouncedContentFilterQuery]\n );\n\n const setInputValue = useCallback(\n (newValue: string) => {\n setValue(newValue);\n },\n [setValue]\n );\n\n const renderInput = useCallback(\n (props?: SearchInputPropsWithRef) => {\n return <WrapperInput {...props} value={value} onChange={handleChangeInput} parentRef={ref} />;\n },\n [ref, value, handleChangeInput]\n );\n\n return { contentFilterQuery, setInputValue, handleChangeInput, renderInput };\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;AAeA,MAAM,YAAY,GAAG,UAAU,CAAsC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;IAClG,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACjD,OAAOA,GAAA,CAAC,WAAW,EAAA,EAAA,GAAK,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAA,SAAA,EAAU,4BAA4B,EAAA,CAAG,CAAC;AAC1F,CAAC,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,GAAG,mBAAmB,CAAC;AAWlC,MAAA,cAAc,GAAuB,CAAC,QAAQ,KAAI;IAC3D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;AACjE,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,mBAAmB,EAAE,CAAC;IACnD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;AACvC,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;AAErC,IAAA,MAAM,gBAAgB,GAAkC,WAAW,CAAC,CAAC,IAAI,KAAI;QACzE,IAAI,CAAC,IAAI,EAAE;YACP,QAAQ,CAAC,EAAE,CAAC,CAAC;YACb,qBAAqB,CAAC,EAAE,CAAC,CAAC;SAC7B;KACJ,EAAE,EAAE,CA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cesContent":["import { useState, useCallback, useRef, useEffect } from 'react';\n\nimport { getIdsWithNoParentsInSameList } from '@hh.ru/magritte-ui-tree-selector/collection/treeCollectionHelper';\nimport { AdditionalDefault } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport ImmutableSelectionStrategy from '@hh.ru/magritte-ui-tree-selector/strategy/immutableSelectionStrategy';\nimport { TreeSelectorProps } from '@hh.ru/magritte-ui-tree-selector/types';\n\ntype UseSelectedHookProps<Additional extends AdditionalDefault> = {\n strategy: ImmutableSelectionStrategy<Additional>;\n} & Pick<TreeSelectorProps<Additional>, 'value' | 'onChange' | 'collapseToParentId' | 'maxSelected' | 'collection'>;\n\ntype UseSelectedHookReturn = {\n selected: string[];\n setSelected: (id: string, isSelected: boolean) => void;\n};\n\ninterface UseSelectedHook {\n <Additional extends AdditionalDefault>(props: UseSelectedHookProps<Additional>): UseSelectedHookReturn;\n}\n\nexport const useSelected: UseSelectedHook = ({\n value,\n maxSelected,\n strategy,\n collection,\n collapseToParentId,\n onChange,\n}) => {\n const getSelectedFromValue = useCallback((): string[] => {\n let newValue = value.slice();\n if (maxSelected && newValue && newValue.length > maxSelected) {\n newValue = newValue.slice(0, maxSelected);\n }\n return strategy.add([], newValue);\n }, [value, maxSelected, strategy]);\n\n const [selected, setSelectedState] = useState(getSelectedFromValue);\n const firstRender = useRef(true);\n\n const setSelected = useCallback(\n (id: string, isSelected: boolean) => {\n const ids = [id];\n const updatedSelected = isSelected ? strategy.add(selected, ids) : strategy.remove(selected, ids);\n const filteredUpdatedSelected = collapseToParentId\n ? getIdsWithNoParentsInSameList(collection, updatedSelected)\n : updatedSelected;\n if (maxSelected && filteredUpdatedSelected.length > maxSelected) {\n filteredUpdatedSelected.length = maxSelected;\n }\n\n onChange(filteredUpdatedSelected, id, isSelected);\n },\n [strategy, selected, collection, collapseToParentId, onChange, maxSelected]\n );\n\n useEffect(() => {\n if (firstRender.current) {\n firstRender.current = false;\n return;\n }\n\n const selected = getSelectedFromValue();\n\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AAG,WAAW,CAAC;SAChD;AAED,QAAA,QAAQ,CAAC,uBAAuB,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;AACtD,KAAC,EACD,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAC9E,CAAC;IAEF,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,WAAW,CAAC,OAAO,EAAE;AACrB,YAAA,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;YAC5B,OAAO;SACV;AAED,QAAA,MAAM,QAAQ,GAAG,oBAAoB,EAAE,CAAC;QAExC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AAC/B,KAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC;IAExC,OAAO;QACH,QAAQ;QACR,WAAW;KACd,CAAC;AACN;;;;"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
var styles = {"item-animation-timeout":"magritte-item-animation-timeout___pbOyZ_5-5-3","itemAnimationTimeout":"magritte-item-animation-timeout___pbOyZ_5-5-3","fade-in":"magritte-fade-in___yS4Ja_5-5-3","fadeIn":"magritte-fade-in___yS4Ja_5-5-3","wrapper":"magritte-wrapper___GHKV6_5-5-3","letter":"magritte-letter___yZOCU_5-5-3","icon":"magritte-icon___kO3Fj_5-5-3","space":"magritte-space___xTO79_5-5-3","wrapperActive":"magritte-wrapperActive___Hwk8p_5-5-3","iconActive":"magritte-iconActive___4yrG5_5-5-3","iconUp":"magritte-iconUp___mpXV6_5-5-3","content":"magritte-content___ZRc6R_5-5-3","mobile-item":"magritte-mobile-item___ynALC_5-5-3","mobileItem":"magritte-mobile-item___ynALC_5-5-3","with-gap":"magritte-with-gap___gbvGO_5-5-3","withGap":"magritte-with-gap___gbvGO_5-5-3","virtualized-list":"magritte-virtualized-list___qt2E6_5-5-3","virtualizedList":"magritte-virtualized-list___qt2E6_5-5-3","virtualized-item":"magritte-virtualized-item___qAYVN_5-5-3","virtualizedItem":"magritte-virtualized-item___qAYVN_5-5-3","was-expanded":"magritte-was-expanded___uCFbW_5-5-3","wasExpanded":"magritte-was-expanded___uCFbW_5-5-3"};
|
|
3
|
-
|
|
4
|
-
export { styles as s };
|
|
5
|
-
//# sourceMappingURL=tree-selector-item-CqHkZG6_.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tree-selector-item-CqHkZG6_.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|