@hh.ru/magritte-ui-tree-selector 4.0.6 → 4.2.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/Action.js +1 -1
- package/Action.js.map +1 -1
- package/Item.js +6 -3
- package/Item.js.map +1 -1
- package/ItemContent.js +5 -3
- package/ItemContent.js.map +1 -1
- package/ItemsList.js +2 -2
- package/MobileItem.d.ts +2 -1
- package/MobileItem.js +5 -2
- package/MobileItem.js.map +1 -1
- package/MobileItemsList.js +2 -2
- package/MobileItemsList.js.map +1 -1
- package/MobileParentItem.d.ts +2 -1
- package/MobileParentItem.js +5 -2
- package/MobileParentItem.js.map +1 -1
- package/TreeSelector.js +2 -4
- package/TreeSelector.js.map +1 -1
- package/TreeSelectorDummy.js +3 -5
- package/TreeSelectorDummy.js.map +1 -1
- package/TreeSelectorItemBase.js +1 -1
- package/TreeSelectorItemBase.js.map +1 -1
- package/TreeSelectorWrapper.d.ts +8 -4
- package/TreeSelectorWrapper.js +10 -9
- package/TreeSelectorWrapper.js.map +1 -1
- package/index.css +25 -24
- package/index.d.ts +1 -0
- package/index.js +6 -8
- package/index.js.map +1 -1
- package/index.mock.d.ts +1 -0
- package/index.mock.js +6 -0
- package/index.mock.js.map +1 -1
- package/package.json +3 -4
- package/tree-selector-item-C8XcgsRu.js +5 -0
- package/tree-selector-item-C8XcgsRu.js.map +1 -0
- package/useAnimationTimeout.js +1 -1
- package/tree-selector-item-DEDTJUiP.js +0 -5
- package/tree-selector-item-DEDTJUiP.js.map +0 -1
package/Action.js
CHANGED
|
@@ -12,7 +12,7 @@ const Action = memo(({ id, name, singleChoice, indeterminate, selected, onChange
|
|
|
12
12
|
onChange: handleChange,
|
|
13
13
|
name,
|
|
14
14
|
onKeyDown,
|
|
15
|
-
'data-qa': `tree-selector-input-${id}`,
|
|
15
|
+
'data-qa': `tree-selector-input tree-selector-input-${id}`,
|
|
16
16
|
};
|
|
17
17
|
return singleChoice ? jsx(Radio, { ...inputProps }) : jsx(Checkbox, { ...inputProps, indeterminate: indeterminate });
|
|
18
18
|
});
|
package/Action.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Action.js","sources":["../src/Action.tsx"],"sourcesContent":["import { ChangeEventHandler, FC, useCallback, memo, KeyboardEventHandler } from 'react';\n\nimport { Checkbox, Radio } from '@hh.ru/magritte-ui-checkbox-radio';\nimport { TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\n\ninterface ActionProps {\n singleChoice?: boolean;\n onChange: (id: string, isSelected: boolean) => void;\n id: TreeModel['id'];\n name?: string;\n selected: boolean;\n indeterminate?: boolean;\n onKeyDown?: KeyboardEventHandler;\n}\n\nexport const Action: FC<ActionProps> = memo(\n ({ id, name, singleChoice, indeterminate, selected, onChange, onKeyDown }) => {\n const handleChange: ChangeEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n onChange(id, event.target.checked);\n },\n [id, onChange]\n );\n\n const inputProps = {\n checked: selected,\n onChange: handleChange,\n name,\n onKeyDown,\n 'data-qa': `tree-selector-input-${id}`,\n };\n\n return singleChoice ? <Radio {...inputProps} /> : <Checkbox {...inputProps} indeterminate={indeterminate} />;\n }\n);\n\nAction.displayName = 'TreeSelectorAction';\n"],"names":["_jsx"],"mappings":";;;;MAea,MAAM,GAAoB,IAAI,CACvC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAI;AACzE,IAAA,MAAM,YAAY,GAAyC,WAAW,CAClE,CAAC,KAAK,KAAI;QACN,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACvC,KAAC,EACD,CAAC,EAAE,EAAE,QAAQ,CAAC,CACjB,CAAC;AAEF,IAAA,MAAM,UAAU,GAAG;AACf,QAAA,OAAO,EAAE,QAAQ;AACjB,QAAA,QAAQ,EAAE,YAAY;QACtB,IAAI;QACJ,SAAS;QACT,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"Action.js","sources":["../src/Action.tsx"],"sourcesContent":["import { ChangeEventHandler, FC, useCallback, memo, KeyboardEventHandler } from 'react';\n\nimport { Checkbox, Radio } from '@hh.ru/magritte-ui-checkbox-radio';\nimport { TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\n\ninterface ActionProps {\n singleChoice?: boolean;\n onChange: (id: string, isSelected: boolean) => void;\n id: TreeModel['id'];\n name?: string;\n selected: boolean;\n indeterminate?: boolean;\n onKeyDown?: KeyboardEventHandler;\n}\n\nexport const Action: FC<ActionProps> = memo(\n ({ id, name, singleChoice, indeterminate, selected, onChange, onKeyDown }) => {\n const handleChange: ChangeEventHandler<HTMLInputElement> = useCallback(\n (event) => {\n onChange(id, event.target.checked);\n },\n [id, onChange]\n );\n\n const inputProps = {\n checked: selected,\n onChange: handleChange,\n name,\n onKeyDown,\n 'data-qa': `tree-selector-input tree-selector-input-${id}`,\n };\n\n return singleChoice ? <Radio {...inputProps} /> : <Checkbox {...inputProps} indeterminate={indeterminate} />;\n }\n);\n\nAction.displayName = 'TreeSelectorAction';\n"],"names":["_jsx"],"mappings":";;;;MAea,MAAM,GAAoB,IAAI,CACvC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAI;AACzE,IAAA,MAAM,YAAY,GAAyC,WAAW,CAClE,CAAC,KAAK,KAAI;QACN,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACvC,KAAC,EACD,CAAC,EAAE,EAAE,QAAQ,CAAC,CACjB,CAAC;AAEF,IAAA,MAAM,UAAU,GAAG;AACf,QAAA,OAAO,EAAE,QAAQ;AACjB,QAAA,QAAQ,EAAE,YAAY;QACtB,IAAI;QACJ,SAAS;QACT,SAAS,EAAE,CAA2C,wCAAA,EAAA,EAAE,CAAE,CAAA;KAC7D,CAAC;IAEF,OAAO,YAAY,GAAGA,IAAC,KAAK,EAAA,EAAA,GAAK,UAAU,EAAI,CAAA,GAAGA,GAAA,CAAC,QAAQ,EAAK,EAAA,GAAA,UAAU,EAAE,aAAa,EAAE,aAAa,EAAA,CAAI,CAAC;AACjH,CAAC,EACH;AAEF,MAAM,CAAC,WAAW,GAAG,oBAAoB;;;;"}
|
package/Item.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { memo, useMemo } from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
4
5
|
import { ItemContent } from './ItemContent.js';
|
|
5
|
-
import 'classnames';
|
|
6
6
|
import '@hh.ru/magritte-common-keyboard';
|
|
7
7
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
8
8
|
import './Action.js';
|
|
@@ -10,7 +10,7 @@ import '@hh.ru/magritte-ui-checkbox-radio';
|
|
|
10
10
|
import './TreeSelectorItemBase.js';
|
|
11
11
|
import '@hh.ru/magritte-ui-cell';
|
|
12
12
|
import '@hh.ru/magritte-ui-typography';
|
|
13
|
-
import './tree-selector-item-
|
|
13
|
+
import './tree-selector-item-C8XcgsRu.js';
|
|
14
14
|
|
|
15
15
|
const ONE_BOX_MARGIN = 36;
|
|
16
16
|
const getMargin = (allBoxesCount, hasShift, hasIndent) => {
|
|
@@ -63,7 +63,10 @@ const ItemComponent = ({ collection, item, parentId, isExpanded, isSelected, isI
|
|
|
63
63
|
}, [item.id, parentId]);
|
|
64
64
|
let margin = parentId ? cache[parentId] : 0;
|
|
65
65
|
margin = margin + (hasShift ? -ONE_BOX_MARGIN : 0) + (hasIndent ? ONE_BOX_MARGIN : 0);
|
|
66
|
-
return (jsxs("div", { style: { paddingLeft: margin }, "data-qa": `tree-selector-item-${item.id}`,
|
|
66
|
+
return (jsxs("div", { style: { paddingLeft: margin }, "data-qa": classnames('tree-selector-item', `tree-selector-item-${item.id}`, {
|
|
67
|
+
'tree-selector-item-expanded': isExpanded,
|
|
68
|
+
[`tree-selector-child-${parentId}`]: parentId,
|
|
69
|
+
}), children: [jsx(ItemContent, { item: item, parentId: parentId, hasChildren: hasChildren, hasAction: !!hasAction, letter: hasLetter ? item.additional?.char : undefined, isExpanded: isExpanded, onExpansion: onExpansion, isSelected: isSelected, onChange: onChange, singleChoice: singleChoice, isIndeterminate: isIndeterminate, isDisabled: isDisabled, hasLetterOnLevel: hasLetterOnLevel, hasDot: hasDot, maxControlsOnLevel: maxControlsOnLevel, isSearch: isSearch, renderItemForDesktop: renderItemForDesktop }), children] }));
|
|
67
70
|
};
|
|
68
71
|
const Item = memo(ItemComponent);
|
|
69
72
|
|
package/Item.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.js","sources":["../src/Item.tsx"],"sourcesContent":["import { PropsWithChildren, ReactElement, useMemo, memo } from 'react';\n\nimport { ItemContent } from '@hh.ru/magritte-ui-tree-selector/ItemContent';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, IdCollectionPredicate, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\nconst ONE_BOX_MARGIN = 36;\n\nconst getMargin = (allBoxesCount: number, hasShift: boolean, hasIndent: boolean): number => {\n let margin = 0;\n if (allBoxesCount === 2) {\n margin = ONE_BOX_MARGIN * 2;\n } else if (allBoxesCount === 3) {\n margin = ONE_BOX_MARGIN * 3;\n } else {\n margin = ONE_BOX_MARGIN;\n }\n if (hasIndent) {\n return margin + ONE_BOX_MARGIN;\n }\n\n if (hasShift) {\n return margin - ONE_BOX_MARGIN;\n }\n\n return margin;\n};\n\ninterface ItemProps<Additional extends AdditionalDefault> extends PropsWithChildren {\n collection: TreeCollection<Additional>;\n parentId?: TreeModel<Additional>['id'];\n item: TreeModel<Additional>;\n leavesOnly?: boolean;\n checkSelectable?: IdCollectionPredicate;\n isExpanded: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n singleChoice?: boolean;\n isIndeterminate: boolean;\n isSearch: boolean;\n onExpansion: (id: string) => void;\n onChange: (id: string, isSelected: boolean) => void;\n renderItemForDesktop?: RenderItem<Additional>;\n cache: Record<string, number>;\n}\n\nconst ItemComponent = <Additional extends AdditionalDefault>({\n collection,\n item,\n parentId,\n isExpanded,\n isSelected,\n isIndeterminate,\n isDisabled,\n leavesOnly,\n singleChoice,\n isSearch,\n checkSelectable,\n onExpansion,\n onChange,\n renderItemForDesktop,\n cache,\n children,\n}: ItemProps<Additional>): ReactElement => {\n const modelsOnLevel = useMemo(\n () => (parentId ? collection.getChildren(parentId) : collection.getTopLevel()),\n [parentId, collection]\n );\n\n const hasLetterOnLevel = useMemo(() => {\n return !isSearch && modelsOnLevel.some((model) => model.additional?.char);\n }, [modelsOnLevel, isSearch]);\n\n // максимальное кол-во контролов на уровне, максимум может быть 2 - шеврон + чекбокс/радио\n const maxControlsOnLevel = useMemo(() => {\n return modelsOnLevel.reduce((currentMax, model) => {\n const hasChildren = collection.hasChildren(model.id);\n const hasAction = !(leavesOnly && hasChildren) && checkSelectable?.(model.id, collection);\n const actionCount = +hasChildren + +!!hasAction;\n return Math.max(currentMax, actionCount);\n }, 0);\n }, [modelsOnLevel, checkSelectable, leavesOnly, collection]);\n\n const hasChildren = collection.hasChildren(item.id);\n const hasAction = !(leavesOnly && hasChildren) && checkSelectable?.(item.id, collection);\n const hasLetter = item.additional?.char && !isSearch;\n const realControlsCount = +hasChildren + +!!hasAction;\n\n // точка заменяет недостающий контрол, если их суммарное кол-во на уровне больше суммарного значения на текущем уровне\n const hasDot = realControlsCount < maxControlsOnLevel && (hasAction || hasChildren);\n const hasParentAction = parentId ? !leavesOnly && checkSelectable?.(parentId, collection) : false;\n\n const allBoxesCount = +hasLetterOnLevel + maxControlsOnLevel;\n\n const hasShift =\n allBoxesCount > 1 &&\n parentId &&\n ((hasParentAction && (hasLetterOnLevel || hasChildren || hasDot)) || (!hasParentAction && hasLetterOnLevel));\n\n const hasIndent = allBoxesCount === 0;\n\n useMemo(() => {\n cache[item.id] = getMargin(allBoxesCount, !!hasShift, hasIndent) + (parentId ? cache[parentId] : 0);\n }, [item.id, parentId]);\n\n let margin = parentId ? cache[parentId] : 0;\n\n margin = margin + (hasShift ? -ONE_BOX_MARGIN : 0) + (hasIndent ? ONE_BOX_MARGIN : 0);\n\n return (\n <div
|
|
1
|
+
{"version":3,"file":"Item.js","sources":["../src/Item.tsx"],"sourcesContent":["import { PropsWithChildren, ReactElement, useMemo, memo } from 'react';\nimport classnames from 'classnames';\n\nimport { ItemContent } from '@hh.ru/magritte-ui-tree-selector/ItemContent';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, IdCollectionPredicate, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\nconst ONE_BOX_MARGIN = 36;\n\nconst getMargin = (allBoxesCount: number, hasShift: boolean, hasIndent: boolean): number => {\n let margin = 0;\n if (allBoxesCount === 2) {\n margin = ONE_BOX_MARGIN * 2;\n } else if (allBoxesCount === 3) {\n margin = ONE_BOX_MARGIN * 3;\n } else {\n margin = ONE_BOX_MARGIN;\n }\n if (hasIndent) {\n return margin + ONE_BOX_MARGIN;\n }\n\n if (hasShift) {\n return margin - ONE_BOX_MARGIN;\n }\n\n return margin;\n};\n\ninterface ItemProps<Additional extends AdditionalDefault> extends PropsWithChildren {\n collection: TreeCollection<Additional>;\n parentId?: TreeModel<Additional>['id'];\n item: TreeModel<Additional>;\n leavesOnly?: boolean;\n checkSelectable?: IdCollectionPredicate;\n isExpanded: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n singleChoice?: boolean;\n isIndeterminate: boolean;\n isSearch: boolean;\n onExpansion: (id: string) => void;\n onChange: (id: string, isSelected: boolean) => void;\n renderItemForDesktop?: RenderItem<Additional>;\n cache: Record<string, number>;\n}\n\nconst ItemComponent = <Additional extends AdditionalDefault>({\n collection,\n item,\n parentId,\n isExpanded,\n isSelected,\n isIndeterminate,\n isDisabled,\n leavesOnly,\n singleChoice,\n isSearch,\n checkSelectable,\n onExpansion,\n onChange,\n renderItemForDesktop,\n cache,\n children,\n}: ItemProps<Additional>): ReactElement => {\n const modelsOnLevel = useMemo(\n () => (parentId ? collection.getChildren(parentId) : collection.getTopLevel()),\n [parentId, collection]\n );\n\n const hasLetterOnLevel = useMemo(() => {\n return !isSearch && modelsOnLevel.some((model) => model.additional?.char);\n }, [modelsOnLevel, isSearch]);\n\n // максимальное кол-во контролов на уровне, максимум может быть 2 - шеврон + чекбокс/радио\n const maxControlsOnLevel = useMemo(() => {\n return modelsOnLevel.reduce((currentMax, model) => {\n const hasChildren = collection.hasChildren(model.id);\n const hasAction = !(leavesOnly && hasChildren) && checkSelectable?.(model.id, collection);\n const actionCount = +hasChildren + +!!hasAction;\n return Math.max(currentMax, actionCount);\n }, 0);\n }, [modelsOnLevel, checkSelectable, leavesOnly, collection]);\n\n const hasChildren = collection.hasChildren(item.id);\n const hasAction = !(leavesOnly && hasChildren) && checkSelectable?.(item.id, collection);\n const hasLetter = item.additional?.char && !isSearch;\n const realControlsCount = +hasChildren + +!!hasAction;\n\n // точка заменяет недостающий контрол, если их суммарное кол-во на уровне больше суммарного значения на текущем уровне\n const hasDot = realControlsCount < maxControlsOnLevel && (hasAction || hasChildren);\n const hasParentAction = parentId ? !leavesOnly && checkSelectable?.(parentId, collection) : false;\n\n const allBoxesCount = +hasLetterOnLevel + maxControlsOnLevel;\n\n const hasShift =\n allBoxesCount > 1 &&\n parentId &&\n ((hasParentAction && (hasLetterOnLevel || hasChildren || hasDot)) || (!hasParentAction && hasLetterOnLevel));\n\n const hasIndent = allBoxesCount === 0;\n\n useMemo(() => {\n cache[item.id] = getMargin(allBoxesCount, !!hasShift, hasIndent) + (parentId ? cache[parentId] : 0);\n }, [item.id, parentId]);\n\n let margin = parentId ? cache[parentId] : 0;\n\n margin = margin + (hasShift ? -ONE_BOX_MARGIN : 0) + (hasIndent ? ONE_BOX_MARGIN : 0);\n\n return (\n <div\n style={{ paddingLeft: margin }}\n data-qa={classnames('tree-selector-item', `tree-selector-item-${item.id}`, {\n 'tree-selector-item-expanded': isExpanded,\n [`tree-selector-child-${parentId}`]: parentId,\n })}\n >\n <ItemContent\n item={item}\n parentId={parentId}\n hasChildren={hasChildren}\n hasAction={!!hasAction}\n letter={hasLetter ? item.additional?.char : undefined}\n isExpanded={isExpanded}\n onExpansion={onExpansion}\n isSelected={isSelected}\n onChange={onChange}\n singleChoice={singleChoice}\n isIndeterminate={isIndeterminate}\n isDisabled={isDisabled}\n hasLetterOnLevel={hasLetterOnLevel}\n hasDot={hasDot}\n maxControlsOnLevel={maxControlsOnLevel}\n isSearch={isSearch}\n renderItemForDesktop={renderItemForDesktop}\n />\n\n {children}\n </div>\n );\n};\n\nexport const Item = memo(ItemComponent) as <Additional extends AdditionalDefault>(\n props: ItemProps<Additional>\n) => ReactElement;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;AAQA,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,SAAS,GAAG,CAAC,aAAqB,EAAE,QAAiB,EAAE,SAAkB,KAAY;IACvF,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,aAAa,KAAK,CAAC,EAAE;AACrB,QAAA,MAAM,GAAG,cAAc,GAAG,CAAC,CAAC;AAC/B,KAAA;SAAM,IAAI,aAAa,KAAK,CAAC,EAAE;AAC5B,QAAA,MAAM,GAAG,cAAc,GAAG,CAAC,CAAC;AAC/B,KAAA;AAAM,SAAA;QACH,MAAM,GAAG,cAAc,CAAC;AAC3B,KAAA;AACD,IAAA,IAAI,SAAS,EAAE;QACX,OAAO,MAAM,GAAG,cAAc,CAAC;AAClC,KAAA;AAED,IAAA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action } from './Action.js';
|
|
8
8
|
import { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
|
|
9
9
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
10
|
-
import { s as styles } from './tree-selector-item-
|
|
10
|
+
import { s as styles } from './tree-selector-item-C8XcgsRu.js';
|
|
11
11
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
12
12
|
import '@hh.ru/magritte-ui-cell';
|
|
13
13
|
|
|
@@ -27,9 +27,11 @@ const ItemContentComponent = ({ item, parentId, hasAction, hasChildren, letter,
|
|
|
27
27
|
}
|
|
28
28
|
}, [isExpanded, onExpansion, item.id]);
|
|
29
29
|
const input = hasAction ? (jsx(Action, { selected: isSelected, onChange: onChange, id: item.id, onKeyDown: handleExpandableKeyDown, indeterminate: isIndeterminate, singleChoice: singleChoice, name: `tree-selector-item-${parentId || 'top'}-${item.id}` })) : undefined;
|
|
30
|
-
return (jsxs("div", { className:
|
|
30
|
+
return (jsxs("div", { className: classnames(styles.wrapper, {
|
|
31
|
+
[styles.wrapperActive]: hasChildren || hasAction,
|
|
32
|
+
}), onClick: hasChildren && !hasAction ? handleExpandableClick : undefined, children: [(letter || hasLetterOnLevel) && (jsx("div", { className: styles.letter, children: letter && (jsx(Text, { typography: "subtitle-1-semibold", style: "secondary", Element: "span", children: letter })) })), hasDot && (jsx("div", { className: styles.icon, children: jsx(DotFilledSize24, { initial: "tertiary" }) })), [...Array(neededSpacesCount).keys()].map((_, i) => (jsx("div", { className: styles.space }, i))), hasChildren && (jsx("div", { className: classnames(styles.icon, styles.iconActive, {
|
|
31
33
|
[styles.iconUp]: isExpanded,
|
|
32
|
-
}), "data-qa": `tree-selector-chevron-${item.id}`, onClick: hasAction ? handleExpandableClick : undefined, children: jsx(ChevronRightOutlinedSize24, { initial: "tertiary" }) })), renderItemForDesktop({ disabled: isDisabled, input, item, isSearch, isParent: hasChildren })] }));
|
|
34
|
+
}), "data-qa": `tree-selector-chevron tree-selector-chevron-${item.id}`, onClick: hasAction ? handleExpandableClick : undefined, children: jsx(ChevronRightOutlinedSize24, { initial: "tertiary" }) })), renderItemForDesktop({ disabled: isDisabled, input, item, isSearch, isParent: hasChildren })] }));
|
|
33
35
|
};
|
|
34
36
|
const ItemContent = memo(ItemContentComponent);
|
|
35
37
|
|
package/ItemContent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemContent.js","sources":["../src/ItemContent.tsx"],"sourcesContent":["import { ReactElement, useCallback, memo, KeyboardEventHandler } from 'react';\nimport classnames from 'classnames';\n\nimport { keyboardKeys, keyboardMatch } from '@hh.ru/magritte-common-keyboard';\nimport { DotFilledSize24, ChevronRightOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { Action } from '@hh.ru/magritte-ui-tree-selector/Action';\nimport { TreeSelectorItemBase } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorItemBase';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './tree-selector-item.less';\n\ninterface ItemContent<Additional extends AdditionalDefault> {\n item: TreeModel<Additional>;\n parentId?: TreeModel<Additional>['id'];\n hasChildren: boolean;\n hasAction: boolean;\n letter?: string;\n onExpansion: (id: string) => void;\n isExpanded: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n onChange: (id: string, isSelected: boolean) => void;\n isIndeterminate: boolean;\n singleChoice?: boolean;\n hasLetterOnLevel: boolean;\n hasDot: boolean;\n maxControlsOnLevel: number;\n renderItemForDesktop?: RenderItem<Additional>;\n isSearch: boolean;\n}\n\nconst ItemContentComponent = <Additional extends AdditionalDefault>({\n item,\n parentId,\n hasAction,\n hasChildren,\n letter,\n isExpanded,\n isDisabled,\n onExpansion,\n hasLetterOnLevel,\n isSelected,\n onChange,\n isIndeterminate,\n singleChoice,\n hasDot,\n maxControlsOnLevel,\n isSearch,\n renderItemForDesktop = TreeSelectorItemBase,\n}: ItemContent<Additional>): ReactElement => {\n const handleExpandableClick = useCallback(() => onExpansion && onExpansion(item.id), [item.id, onExpansion]);\n const currentActionCount = +hasDot + +hasAction + +hasChildren;\n const neededSpacesCount = maxControlsOnLevel - currentActionCount;\n\n const handleExpandableKeyDown = useCallback<KeyboardEventHandler>(\n (event) => {\n if (keyboardMatch(event.nativeEvent, keyboardKeys.ArrowLeft)) {\n isExpanded && onExpansion(item.id);\n event.preventDefault();\n return;\n }\n if (keyboardMatch(event.nativeEvent, keyboardKeys.ArrowRight)) {\n !isExpanded && onExpansion(item.id);\n event.preventDefault();\n }\n },\n [isExpanded, onExpansion, item.id]\n );\n\n const input = hasAction ? (\n <Action\n selected={isSelected}\n onChange={onChange}\n id={item.id}\n onKeyDown={handleExpandableKeyDown}\n indeterminate={isIndeterminate}\n singleChoice={singleChoice}\n name={`tree-selector-item-${parentId || 'top'}-${item.id}`}\n />\n ) : undefined;\n\n return (\n <div
|
|
1
|
+
{"version":3,"file":"ItemContent.js","sources":["../src/ItemContent.tsx"],"sourcesContent":["import { ReactElement, useCallback, memo, KeyboardEventHandler } from 'react';\nimport classnames from 'classnames';\n\nimport { keyboardKeys, keyboardMatch } from '@hh.ru/magritte-common-keyboard';\nimport { DotFilledSize24, ChevronRightOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { Action } from '@hh.ru/magritte-ui-tree-selector/Action';\nimport { TreeSelectorItemBase } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorItemBase';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './tree-selector-item.less';\n\ninterface ItemContent<Additional extends AdditionalDefault> {\n item: TreeModel<Additional>;\n parentId?: TreeModel<Additional>['id'];\n hasChildren: boolean;\n hasAction: boolean;\n letter?: string;\n onExpansion: (id: string) => void;\n isExpanded: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n onChange: (id: string, isSelected: boolean) => void;\n isIndeterminate: boolean;\n singleChoice?: boolean;\n hasLetterOnLevel: boolean;\n hasDot: boolean;\n maxControlsOnLevel: number;\n renderItemForDesktop?: RenderItem<Additional>;\n isSearch: boolean;\n}\n\nconst ItemContentComponent = <Additional extends AdditionalDefault>({\n item,\n parentId,\n hasAction,\n hasChildren,\n letter,\n isExpanded,\n isDisabled,\n onExpansion,\n hasLetterOnLevel,\n isSelected,\n onChange,\n isIndeterminate,\n singleChoice,\n hasDot,\n maxControlsOnLevel,\n isSearch,\n renderItemForDesktop = TreeSelectorItemBase,\n}: ItemContent<Additional>): ReactElement => {\n const handleExpandableClick = useCallback(() => onExpansion && onExpansion(item.id), [item.id, onExpansion]);\n const currentActionCount = +hasDot + +hasAction + +hasChildren;\n const neededSpacesCount = maxControlsOnLevel - currentActionCount;\n\n const handleExpandableKeyDown = useCallback<KeyboardEventHandler>(\n (event) => {\n if (keyboardMatch(event.nativeEvent, keyboardKeys.ArrowLeft)) {\n isExpanded && onExpansion(item.id);\n event.preventDefault();\n return;\n }\n if (keyboardMatch(event.nativeEvent, keyboardKeys.ArrowRight)) {\n !isExpanded && onExpansion(item.id);\n event.preventDefault();\n }\n },\n [isExpanded, onExpansion, item.id]\n );\n\n const input = hasAction ? (\n <Action\n selected={isSelected}\n onChange={onChange}\n id={item.id}\n onKeyDown={handleExpandableKeyDown}\n indeterminate={isIndeterminate}\n singleChoice={singleChoice}\n name={`tree-selector-item-${parentId || 'top'}-${item.id}`}\n />\n ) : undefined;\n\n return (\n <div\n className={classnames(styles.wrapper, {\n [styles.wrapperActive]: hasChildren || hasAction,\n })}\n onClick={hasChildren && !hasAction ? handleExpandableClick : undefined}\n >\n {(letter || hasLetterOnLevel) && (\n <div className={styles.letter}>\n {letter && (\n <Text typography=\"subtitle-1-semibold\" style=\"secondary\" Element=\"span\">\n {letter}\n </Text>\n )}\n </div>\n )}\n {hasDot && (\n <div className={styles.icon}>\n <DotFilledSize24 initial=\"tertiary\" />\n </div>\n )}\n\n {[...Array(neededSpacesCount).keys()].map((_, i) => (\n <div key={i} className={styles.space} />\n ))}\n\n {hasChildren && (\n <div\n className={classnames(styles.icon, styles.iconActive, {\n [styles.iconUp]: isExpanded,\n })}\n data-qa={`tree-selector-chevron tree-selector-chevron-${item.id}`}\n onClick={hasAction ? handleExpandableClick : undefined}\n >\n <ChevronRightOutlinedSize24 initial=\"tertiary\" />\n </div>\n )}\n {renderItemForDesktop({ disabled: isDisabled, input, item, isSearch, isParent: hasChildren })}\n </div>\n );\n};\n\nexport const ItemContent = memo(ItemContentComponent) as <Additional extends AdditionalDefault>(\n props: ItemContent<Additional>\n) => ReactElement;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;AAiCA,MAAM,oBAAoB,GAAG,CAAuC,EAChE,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,WAAW,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,MAAM,EACN,kBAAkB,EAClB,QAAQ,EACR,oBAAoB,GAAG,oBAAoB,GACrB,KAAkB;IACxC,MAAM,qBAAqB,GAAG,WAAW,CAAC,MAAM,WAAW,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;IAC7G,MAAM,kBAAkB,GAAG,CAAC,MAAM,GAAG,CAAC,SAAS,GAAG,CAAC,WAAW,CAAC;AAC/D,IAAA,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAElE,IAAA,MAAM,uBAAuB,GAAG,WAAW,CACvC,CAAC,KAAK,KAAI;QACN,IAAI,aAAa,CAAC,KAAK,CAAC,WAAW,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE;AAC1D,Y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AA,CACV,EACC,CAAA,CACT,EACA,MAAM,KACHA,GAAK,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,IAAI,EAAA,QAAA,EACvBA,GAAC,CAAA,eAAe,EAAC,EAAA,OAAO,EAAC,UAAU,EAAG,CAAA,EAAA,CACpC,CACT,EAEA,CAAC,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAC3CA,GAAA,CAAA,KAAA,EAAA,EAAa,SAAS,EAAE,MAAM,CAAC,KAAK,EAAA,EAA1B,CAAC,CAA6B,CAC3C,CAAC,EAED,WAAW,KACRA,GACI,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,UAAU,EAAE;AAClD,oBAAA,CAAC,MAAM,CAAC,MAAM,GAAG,UAAU;iBAC9B,CAAC,EAAA,SAAA,EACO,+CAA+C,IAAI,CAAC,EAAE,CAAE,CAAA,EACjE,OAAO,EAAE,SAAS,GAAG,qBAAqB,GAAG,SAAS,EAEtD,QAAA,EAAAA,GAAA,CAAC,0BAA0B,EAAA,EAAC,OAAO,EAAC,UAAU,EAAG,CAAA,EAAA,CAC/C,CACT,EACA,oBAAoB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAC3F,EAAA,CAAA,EACR;AACN,CAAC,CAAC;MAEW,WAAW,GAAG,IAAI,CAAC,oBAAoB;;;;"}
|
package/ItemsList.js
CHANGED
|
@@ -3,9 +3,9 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useRef, useMemo, useCallback, useEffect } from 'react';
|
|
4
4
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
5
5
|
import { Item } from './Item.js';
|
|
6
|
-
import { s as styles } from './tree-selector-item-
|
|
7
|
-
import './ItemContent.js';
|
|
6
|
+
import { s as styles } from './tree-selector-item-C8XcgsRu.js';
|
|
8
7
|
import 'classnames';
|
|
8
|
+
import './ItemContent.js';
|
|
9
9
|
import '@hh.ru/magritte-common-keyboard';
|
|
10
10
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
11
11
|
import './Action.js';
|
package/MobileItem.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ interface MobileItemProps<Additional extends AdditionalDefault> {
|
|
|
10
10
|
onChange: (id: string, isSelected: boolean) => void;
|
|
11
11
|
renderItem?: RenderItem<Additional>;
|
|
12
12
|
isSearch: boolean;
|
|
13
|
+
parentId?: string;
|
|
13
14
|
}
|
|
14
|
-
export declare const MobileItem: <Additional extends AdditionalDefault>({ item, isSelected, singleChoice, isSelectable, isDisabled, onChange, isSearch, renderItem, }: MobileItemProps<Additional>) => ReactElement;
|
|
15
|
+
export declare const MobileItem: <Additional extends AdditionalDefault>({ item, isSelected, singleChoice, isSelectable, isDisabled, onChange, isSearch, parentId, renderItem, }: MobileItemProps<Additional>) => ReactElement;
|
|
15
16
|
export {};
|
package/MobileItem.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import classnames from 'classnames';
|
|
3
4
|
import { CheckableCardElement } from '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
|
|
4
5
|
import { Action } from './Action.js';
|
|
5
6
|
import { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
|
|
@@ -7,9 +8,11 @@ import 'react';
|
|
|
7
8
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
8
9
|
import '@hh.ru/magritte-ui-cell';
|
|
9
10
|
|
|
10
|
-
const MobileItem = ({ item, isSelected, singleChoice, isSelectable, isDisabled, onChange, isSearch, renderItem = TreeSelectorItemBase, }) => {
|
|
11
|
+
const MobileItem = ({ item, isSelected, singleChoice, isSelectable, isDisabled, onChange, isSearch, parentId, renderItem = TreeSelectorItemBase, }) => {
|
|
11
12
|
const input = isSelectable ? (jsx(Action, { selected: isSelected, onChange: onChange, id: item.id, singleChoice: singleChoice })) : undefined;
|
|
12
|
-
return (jsx(CheckableCardElement, { padding: 16, borderRadius: 12, Element: "label", flexible: true, checked: isSelected, "data-qa": `tree-selector-item-${item.id}`,
|
|
13
|
+
return (jsx(CheckableCardElement, { padding: 16, borderRadius: 12, Element: "label", flexible: true, checked: isSelected, "data-qa": classnames('tree-selector-item', `tree-selector-item-${item.id}`, {
|
|
14
|
+
[`tree-selector-child-${parentId}`]: parentId,
|
|
15
|
+
}), children: renderItem({ input, item, isSearch, isXS: true, disabled: isDisabled }) }));
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
export { MobileItem };
|
package/MobileItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileItem.js","sources":["../src/MobileItem.tsx"],"sourcesContent":["import { ReactElement } from 'react';\n\nimport { CheckableCardElement } from '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';\nimport { Action } from '@hh.ru/magritte-ui-tree-selector/Action';\nimport { TreeSelectorItemBase } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorItemBase';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\ninterface MobileItemProps<Additional extends AdditionalDefault> {\n item: TreeModel<Additional>;\n singleChoice?: boolean;\n isSelectable?: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n onChange: (id: string, isSelected: boolean) => void;\n renderItem?: RenderItem<Additional>;\n isSearch: boolean;\n}\n\nexport const MobileItem = <Additional extends AdditionalDefault>({\n item,\n isSelected,\n singleChoice,\n isSelectable,\n isDisabled,\n onChange,\n isSearch,\n renderItem = TreeSelectorItemBase,\n}: MobileItemProps<Additional>): ReactElement => {\n const input = isSelectable ? (\n <Action selected={isSelected} onChange={onChange} id={item.id} singleChoice={singleChoice} />\n ) : undefined;\n return (\n <CheckableCardElement\n padding={16}\n borderRadius={12}\n Element=\"label\"\n flexible\n checked={isSelected}\n data-qa={`tree-selector-item-${item.id}`}\n >\n {renderItem({ input, item, isSearch, isXS: true, disabled: isDisabled })}\n </CheckableCardElement>\n );\n};\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MobileItem.js","sources":["../src/MobileItem.tsx"],"sourcesContent":["import { ReactElement } from 'react';\nimport classnames from 'classnames';\n\nimport { CheckableCardElement } from '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';\nimport { Action } from '@hh.ru/magritte-ui-tree-selector/Action';\nimport { TreeSelectorItemBase } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorItemBase';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\ninterface MobileItemProps<Additional extends AdditionalDefault> {\n item: TreeModel<Additional>;\n singleChoice?: boolean;\n isSelectable?: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n onChange: (id: string, isSelected: boolean) => void;\n renderItem?: RenderItem<Additional>;\n isSearch: boolean;\n parentId?: string;\n}\n\nexport const MobileItem = <Additional extends AdditionalDefault>({\n item,\n isSelected,\n singleChoice,\n isSelectable,\n isDisabled,\n onChange,\n isSearch,\n parentId,\n renderItem = TreeSelectorItemBase,\n}: MobileItemProps<Additional>): ReactElement => {\n const input = isSelectable ? (\n <Action selected={isSelected} onChange={onChange} id={item.id} singleChoice={singleChoice} />\n ) : undefined;\n return (\n <CheckableCardElement\n padding={16}\n borderRadius={12}\n Element=\"label\"\n flexible\n checked={isSelected}\n data-qa={classnames('tree-selector-item', `tree-selector-item-${item.id}`, {\n [`tree-selector-child-${parentId}`]: parentId,\n })}\n >\n {renderItem({ input, item, isSearch, isXS: true, disabled: isDisabled })}\n </CheckableCardElement>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;AAqBa,MAAA,UAAU,GAAG,CAAuC,EAC7D,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,UAAU,GAAG,oBAAoB,GACP,KAAkB;AAC5C,IAAA,MAAM,KAAK,GAAG,YAAY,IACtBA,GAAC,CAAA,MAAM,EAAC,EAAA,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,YAAY,EAAE,YAAY,GAAI,IAC7F,SAAS,CAAC;AACd,IAAA,QACIA,GAAA,CAAC,oBAAoB,EAAA,EACjB,OAAO,EAAE,EAAE,EACX,YAAY,EAAE,EAAE,EAChB,OAAO,EAAC,OAAO,EACf,QAAQ,EACR,IAAA,EAAA,OAAO,EAAE,UAAU,aACV,UAAU,CAAC,oBAAoB,EAAE,CAAsB,mBAAA,EAAA,IAAI,CAAC,EAAE,EAAE,EAAE;AACvE,YAAA,CAAC,CAAuB,oBAAA,EAAA,QAAQ,CAAE,CAAA,GAAG,QAAQ;SAChD,CAAC,EAAA,QAAA,EAED,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,EACrD,CAAA,EACzB;AACN;;;;"}
|
package/MobileItemsList.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Action } from './Action.js';
|
|
|
9
9
|
import { MobileDelimiter } from './MobileDelimiter.js';
|
|
10
10
|
import { MobileItem } from './MobileItem.js';
|
|
11
11
|
import { MobileParentItem } from './MobileParentItem.js';
|
|
12
|
-
import { s as styles } from './tree-selector-item-
|
|
12
|
+
import { s as styles } from './tree-selector-item-C8XcgsRu.js';
|
|
13
13
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
14
14
|
import '@hh.ru/magritte-ui-card';
|
|
15
15
|
import '@hh.ru/magritte-ui-typography';
|
|
@@ -129,7 +129,7 @@ const MobileItemsListComponent = (props, ref) => {
|
|
|
129
129
|
setInputValue('');
|
|
130
130
|
currentQuery.current = '';
|
|
131
131
|
navigationChangeCallback.current?.(item.id);
|
|
132
|
-
}, isSearch: isSearch, renderItem: renderItem })) : (jsx(MobileItem, { item: item, singleChoice: singleChoice, isSelectable: checkSelectable?.(item.id, collection), isSelected: selected.includes(item.id), isDisabled: disabled.includes(item.id), onChange: onChange, isSearch: isSearch, renderItem: renderItem }))] }) }, virtualItem.key));
|
|
132
|
+
}, parentId: currentParentId, isSearch: isSearch, renderItem: renderItem })) : (jsx(MobileItem, { item: item, singleChoice: singleChoice, isSelectable: checkSelectable?.(item.id, collection), isSelected: selected.includes(item.id), isDisabled: disabled.includes(item.id), onChange: onChange, isSearch: isSearch, renderItem: renderItem, parentId: currentParentId }))] }) }, virtualItem.key));
|
|
133
133
|
}) }));
|
|
134
134
|
};
|
|
135
135
|
const MobileItemsList = forwardRef(MobileItemsListComponent);
|
package/MobileItemsList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileItemsList.js","sources":["../src/MobileItemsList.tsx"],"sourcesContent":["import {\n ReactElement,\n useMemo,\n useState,\n useImperativeHandle,\n forwardRef,\n ForwardedRef,\n useRef,\n useEffect,\n RefCallback,\n useCallback,\n} from 'react';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport classnames from 'classnames';\n\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { CheckableCardElement } from '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';\nimport { Action } from '@hh.ru/magritte-ui-tree-selector/Action';\nimport { MobileDelimiter } from '@hh.ru/magritte-ui-tree-selector/MobileDelimiter';\nimport { MobileItem } from '@hh.ru/magritte-ui-tree-selector/MobileItem';\nimport { MobileParentItem } from '@hh.ru/magritte-ui-tree-selector/MobileParentItem';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { ListControls, TreeSelectorDummyProps } from '@hh.ru/magritte-ui-tree-selector/types';\n\nimport styles from './tree-selector-item.less';\n\nconst DEFAULT_ITEM_HEIGHT = 56;\n\ntype MobileItemsListProps<Additional extends AdditionalDefault> = {\n selected: string[];\n disabled: string[];\n getMobileSearchItemOrder: (model: TreeModel<Additional>) => number;\n setInputValue: (newValue: string) => void;\n handleChangeInput: (newValue: string) => void;\n contentFilterQuery: string;\n isSearch: boolean;\n} & Pick<\n TreeSelectorDummyProps<Additional>,\n | 'collection'\n | 'leavesOnly'\n | 'singleChoice'\n | 'checkSelectable'\n | 'onChange'\n | 'renderItem'\n | 'renderMobileDelimiter'\n | 'onMobileNavigationChange'\n | 'getSelectAllParentTrl'\n | 'renderContentBefore'\n>;\n\nconst MobileItemsListComponent = <Additional extends AdditionalDefault>(\n props: MobileItemsListProps<Additional>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n collection,\n selected,\n disabled,\n leavesOnly,\n singleChoice,\n onChange,\n checkSelectable,\n getMobileSearchItemOrder,\n setInputValue,\n handleChangeInput,\n isSearch,\n renderMobileDelimiter,\n renderItem,\n contentFilterQuery,\n getSelectAllParentTrl,\n renderContentBefore,\n onMobileNavigationChange,\n } = props;\n const navigationChangeCallback = useRef(onMobileNavigationChange);\n navigationChangeCallback.current = onMobileNavigationChange;\n const prevParentIds = useRef<(string | undefined)[]>([]);\n const prevQueries = useRef<string[]>([]);\n const currentQuery = useRef(contentFilterQuery);\n const [currentParentId, setCurrentParentId] = useState<string | undefined>();\n const items = useMemo(\n () => (currentParentId ? collection.getChildren(currentParentId) : collection.getTopLevel()),\n [currentParentId, collection]\n );\n const orderHashMap = useMemo(() => {\n return items.reduce<Record<TreeModel<Additional>['id'], number>>((acc, item) => {\n acc[item.id] = isSearch && !currentParentId ? getMobileSearchItemOrder(item) : 0;\n return acc;\n }, {});\n }, [items, isSearch, currentParentId, getMobileSearchItemOrder]);\n\n const sortedItems = useMemo(() => {\n return items.sort((itemA, itemB) => {\n return orderHashMap[itemA.id] - orderHashMap[itemB.id];\n });\n }, [items, orderHashMap]);\n\n const isSelectable = currentParentId && !leavesOnly && checkSelectable?.(currentParentId, collection);\n const withContentBefore = !!renderContentBefore;\n const count = items.length + (isSelectable ? 1 : 0) + (withContentBefore ? 1 : 0);\n const parentRef = useRef<HTMLElement | null>(null);\n\n const getItemKey = (index: number) => {\n if (withContentBefore && index === 0) {\n return 'promo';\n }\n\n const isSelectAllItem =\n isSelectable && ((index === 0 && !withContentBefore) || (index === 1 && withContentBefore));\n\n if (isSelectAllItem) {\n return `current${currentParentId}`;\n }\n\n const itemIndex = index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);\n const item = sortedItems[itemIndex];\n\n return currentParentId ? `${currentParentId}${item.id}` : `${item.id}`;\n };\n\n const virtualizer = useVirtualizer({\n count,\n getScrollElement: () => parentRef.current,\n estimateSize: () => DEFAULT_ITEM_HEIGHT,\n getItemKey,\n });\n\n const itemsVirtualizer = virtualizer.getVirtualItems();\n\n useEffect(() => {\n setCurrentParentId(undefined);\n prevParentIds.current = [];\n prevQueries.current = [];\n navigationChangeCallback.current?.(undefined);\n currentQuery.current = contentFilterQuery;\n }, [contentFilterQuery]);\n\n useImperativeHandle(\n ref,\n () => ({\n back: () => {\n if (!virtualizer.isScrolling) {\n const prevParentId = prevParentIds.current.pop();\n setCurrentParentId(prevParentId);\n navigationChangeCallback.current?.(prevParentId);\n if (prevQueries.current.length) {\n const prevInputValue = prevQueries.current.pop() as string;\n setInputValue(prevInputValue);\n currentQuery.current = prevInputValue;\n } else {\n handleChangeInput('');\n }\n }\n },\n }),\n [handleChangeInput, setInputValue, virtualizer]\n );\n\n const refCallback: RefCallback<HTMLDivElement> = useCallback((node) => {\n parentRef.current = node ? node.parentElement : null;\n }, []);\n\n useEffect(() => {\n virtualizer.scrollToOffset(0);\n }, [currentParentId, sortedItems, virtualizer]);\n\n return (\n <div\n ref={refCallback}\n className={styles.virtualizedList}\n style={{\n height: `${virtualizer.getTotalSize()}px`,\n }}\n >\n {itemsVirtualizer.map((virtualItem) => {\n const isContentBeforeItem = withContentBefore && virtualItem.index === 0;\n const isSelectAllItem =\n isSelectable &&\n ((virtualItem.index === 0 && !withContentBefore) || (virtualItem.index === 1 && withContentBefore));\n\n if (isContentBeforeItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {renderContentBefore(isSearch)}\n </div>\n );\n }\n if (isSelectAllItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n <div className={styles.mobileItem}>\n <CheckableCardElement\n padding={16}\n flexible\n borderRadius={12}\n Element=\"label\"\n checked={selected.includes(currentParentId)}\n data-qa={`tree-selector-select-all-${currentParentId}`}\n >\n <Cell\n Element={'div'}\n disabled={disabled.includes(currentParentId)}\n right={\n <Action\n selected={selected.includes(currentParentId)}\n onChange={onChange}\n id={currentParentId}\n singleChoice={singleChoice}\n />\n }\n >\n <CellText>{getSelectAllParentTrl(currentParentId)}</CellText>\n </Cell>\n </CheckableCardElement>\n </div>\n </div>\n );\n }\n const itemIndex = virtualItem.index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);\n const item = sortedItems[itemIndex];\n const hasChildren = collection.hasChildren(item.id);\n const hasLetter = item.additional?.char && !isSearch;\n const delimiterContent = renderMobileDelimiter?.({\n item,\n order: orderHashMap[item.id],\n isSearch,\n index: itemIndex,\n isTopLevel: !currentParentId,\n });\n const withGap =\n (!!withContentBefore && virtualItem.index !== 1) || (!withContentBefore && virtualItem.index !== 0);\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n className={classnames(styles.virtualizedItem, {\n [styles.withGap]: withGap,\n })}\n >\n <div className={styles.mobileItem}>\n {hasLetter && <MobileDelimiter>{item.additional?.char}</MobileDelimiter>}\n {delimiterContent && <MobileDelimiter>{delimiterContent}</MobileDelimiter>}\n {hasChildren ? (\n <MobileParentItem\n collection={collection}\n item={item}\n selected={selected}\n onClick={() => {\n prevParentIds.current.push(currentParentId);\n prevQueries.current.push(currentQuery.current);\n setCurrentParentId(item.id);\n setInputValue('');\n currentQuery.current = '';\n navigationChangeCallback.current?.(item.id);\n }}\n isSearch={isSearch}\n renderItem={renderItem}\n />\n ) : (\n <MobileItem\n item={item}\n singleChoice={singleChoice}\n isSelectable={checkSelectable?.(item.id, collection)}\n isSelected={selected.includes(item.id)}\n isDisabled={disabled.includes(item.id)}\n onChange={onChange}\n isSearch={isSearch}\n renderItem={renderItem}\n />\n )}\n </div>\n </div>\n );\n })}\n </div>\n );\n};\n\nexport const MobileItemsList = forwardRef(MobileItemsListComponent) as <Additional extends AdditionalDefault>(\n props: MobileItemsListProps<Additional> & { ref?: ForwardedRef<ListControls> }\n) => ReactElement;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAwB/B,MAAM,wBAAwB,GAAG,CAC7B,KAAuC,EACvC,GAA+B,KACjB;AACd,IAAA,MAAM,EACF,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,GAC3B,GAAG,KAAK,CAAC;AACV,IAAA,MAAM,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAClE,IAAA,wBAAwB,CAAC,OAAO,GAAG,wBAAwB,CAAC;AAC5D,IAAA,MAAM,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AAE,CAAC,CAAC;AAClB,gCAAA,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;gCAC1B,wBAAwB,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;AAChD,6BAAC,EACD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACxB,CAAA,KAEFA,GAAA,CAAC,UAAU,EACP,EAAA,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,eAAe,GAAG,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,EACpD,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACtC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACtC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACxB,CAAA,CACL,IACC,EAzCD,EAAA,WAAW,CAAC,GAAG,CA0ClB,EACR;SACL,CAAC,EACA,CAAA,EACR;AACN,CAAC,CAAC;MAEW,eAAe,GAAG,UAAU,CAAC,wBAAwB;;;;"}
|
|
1
|
+
{"version":3,"file":"MobileItemsList.js","sources":["../src/MobileItemsList.tsx"],"sourcesContent":["import {\n ReactElement,\n useMemo,\n useState,\n useImperativeHandle,\n forwardRef,\n ForwardedRef,\n useRef,\n useEffect,\n RefCallback,\n useCallback,\n} from 'react';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport classnames from 'classnames';\n\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { CheckableCardElement } from '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';\nimport { Action } from '@hh.ru/magritte-ui-tree-selector/Action';\nimport { MobileDelimiter } from '@hh.ru/magritte-ui-tree-selector/MobileDelimiter';\nimport { MobileItem } from '@hh.ru/magritte-ui-tree-selector/MobileItem';\nimport { MobileParentItem } from '@hh.ru/magritte-ui-tree-selector/MobileParentItem';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { ListControls, TreeSelectorDummyProps } from '@hh.ru/magritte-ui-tree-selector/types';\n\nimport styles from './tree-selector-item.less';\n\nconst DEFAULT_ITEM_HEIGHT = 56;\n\ntype MobileItemsListProps<Additional extends AdditionalDefault> = {\n selected: string[];\n disabled: string[];\n getMobileSearchItemOrder: (model: TreeModel<Additional>) => number;\n setInputValue: (newValue: string) => void;\n handleChangeInput: (newValue: string) => void;\n contentFilterQuery: string;\n isSearch: boolean;\n} & Pick<\n TreeSelectorDummyProps<Additional>,\n | 'collection'\n | 'leavesOnly'\n | 'singleChoice'\n | 'checkSelectable'\n | 'onChange'\n | 'renderItem'\n | 'renderMobileDelimiter'\n | 'onMobileNavigationChange'\n | 'getSelectAllParentTrl'\n | 'renderContentBefore'\n>;\n\nconst MobileItemsListComponent = <Additional extends AdditionalDefault>(\n props: MobileItemsListProps<Additional>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n collection,\n selected,\n disabled,\n leavesOnly,\n singleChoice,\n onChange,\n checkSelectable,\n getMobileSearchItemOrder,\n setInputValue,\n handleChangeInput,\n isSearch,\n renderMobileDelimiter,\n renderItem,\n contentFilterQuery,\n getSelectAllParentTrl,\n renderContentBefore,\n onMobileNavigationChange,\n } = props;\n const navigationChangeCallback = useRef(onMobileNavigationChange);\n navigationChangeCallback.current = onMobileNavigationChange;\n const prevParentIds = useRef<(string | undefined)[]>([]);\n const prevQueries = useRef<string[]>([]);\n const currentQuery = useRef(contentFilterQuery);\n const [currentParentId, setCurrentParentId] = useState<string | undefined>();\n const items = useMemo(\n () => (currentParentId ? collection.getChildren(currentParentId) : collection.getTopLevel()),\n [currentParentId, collection]\n );\n const orderHashMap = useMemo(() => {\n return items.reduce<Record<TreeModel<Additional>['id'], number>>((acc, item) => {\n acc[item.id] = isSearch && !currentParentId ? getMobileSearchItemOrder(item) : 0;\n return acc;\n }, {});\n }, [items, isSearch, currentParentId, getMobileSearchItemOrder]);\n\n const sortedItems = useMemo(() => {\n return items.sort((itemA, itemB) => {\n return orderHashMap[itemA.id] - orderHashMap[itemB.id];\n });\n }, [items, orderHashMap]);\n\n const isSelectable = currentParentId && !leavesOnly && checkSelectable?.(currentParentId, collection);\n const withContentBefore = !!renderContentBefore;\n const count = items.length + (isSelectable ? 1 : 0) + (withContentBefore ? 1 : 0);\n const parentRef = useRef<HTMLElement | null>(null);\n\n const getItemKey = (index: number) => {\n if (withContentBefore && index === 0) {\n return 'promo';\n }\n\n const isSelectAllItem =\n isSelectable && ((index === 0 && !withContentBefore) || (index === 1 && withContentBefore));\n\n if (isSelectAllItem) {\n return `current${currentParentId}`;\n }\n\n const itemIndex = index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);\n const item = sortedItems[itemIndex];\n\n return currentParentId ? `${currentParentId}${item.id}` : `${item.id}`;\n };\n\n const virtualizer = useVirtualizer({\n count,\n getScrollElement: () => parentRef.current,\n estimateSize: () => DEFAULT_ITEM_HEIGHT,\n getItemKey,\n });\n\n const itemsVirtualizer = virtualizer.getVirtualItems();\n\n useEffect(() => {\n setCurrentParentId(undefined);\n prevParentIds.current = [];\n prevQueries.current = [];\n navigationChangeCallback.current?.(undefined);\n currentQuery.current = contentFilterQuery;\n }, [contentFilterQuery]);\n\n useImperativeHandle(\n ref,\n () => ({\n back: () => {\n if (!virtualizer.isScrolling) {\n const prevParentId = prevParentIds.current.pop();\n setCurrentParentId(prevParentId);\n navigationChangeCallback.current?.(prevParentId);\n if (prevQueries.current.length) {\n const prevInputValue = prevQueries.current.pop() as string;\n setInputValue(prevInputValue);\n currentQuery.current = prevInputValue;\n } else {\n handleChangeInput('');\n }\n }\n },\n }),\n [handleChangeInput, setInputValue, virtualizer]\n );\n\n const refCallback: RefCallback<HTMLDivElement> = useCallback((node) => {\n parentRef.current = node ? node.parentElement : null;\n }, []);\n\n useEffect(() => {\n virtualizer.scrollToOffset(0);\n }, [currentParentId, sortedItems, virtualizer]);\n\n return (\n <div\n ref={refCallback}\n className={styles.virtualizedList}\n style={{\n height: `${virtualizer.getTotalSize()}px`,\n }}\n >\n {itemsVirtualizer.map((virtualItem) => {\n const isContentBeforeItem = withContentBefore && virtualItem.index === 0;\n const isSelectAllItem =\n isSelectable &&\n ((virtualItem.index === 0 && !withContentBefore) || (virtualItem.index === 1 && withContentBefore));\n\n if (isContentBeforeItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {renderContentBefore(isSearch)}\n </div>\n );\n }\n if (isSelectAllItem) {\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n className={styles.virtualizedItem}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n <div className={styles.mobileItem}>\n <CheckableCardElement\n padding={16}\n flexible\n borderRadius={12}\n Element=\"label\"\n checked={selected.includes(currentParentId)}\n data-qa={`tree-selector-select-all-${currentParentId}`}\n >\n <Cell\n Element={'div'}\n disabled={disabled.includes(currentParentId)}\n right={\n <Action\n selected={selected.includes(currentParentId)}\n onChange={onChange}\n id={currentParentId}\n singleChoice={singleChoice}\n />\n }\n >\n <CellText>{getSelectAllParentTrl(currentParentId)}</CellText>\n </Cell>\n </CheckableCardElement>\n </div>\n </div>\n );\n }\n const itemIndex = virtualItem.index - (isSelectable ? 1 : 0) - (withContentBefore ? 1 : 0);\n const item = sortedItems[itemIndex];\n const hasChildren = collection.hasChildren(item.id);\n const hasLetter = item.additional?.char && !isSearch;\n const delimiterContent = renderMobileDelimiter?.({\n item,\n order: orderHashMap[item.id],\n isSearch,\n index: itemIndex,\n isTopLevel: !currentParentId,\n });\n const withGap =\n (!!withContentBefore && virtualItem.index !== 1) || (!withContentBefore && virtualItem.index !== 0);\n return (\n <div\n key={virtualItem.key}\n ref={virtualizer.measureElement}\n data-index={virtualItem.index}\n style={{\n transform: `translateY(${virtualItem.start}px)`,\n }}\n className={classnames(styles.virtualizedItem, {\n [styles.withGap]: withGap,\n })}\n >\n <div className={styles.mobileItem}>\n {hasLetter && <MobileDelimiter>{item.additional?.char}</MobileDelimiter>}\n {delimiterContent && <MobileDelimiter>{delimiterContent}</MobileDelimiter>}\n {hasChildren ? (\n <MobileParentItem\n collection={collection}\n item={item}\n selected={selected}\n onClick={() => {\n prevParentIds.current.push(currentParentId);\n prevQueries.current.push(currentQuery.current);\n setCurrentParentId(item.id);\n setInputValue('');\n currentQuery.current = '';\n navigationChangeCallback.current?.(item.id);\n }}\n parentId={currentParentId}\n isSearch={isSearch}\n renderItem={renderItem}\n />\n ) : (\n <MobileItem\n item={item}\n singleChoice={singleChoice}\n isSelectable={checkSelectable?.(item.id, collection)}\n isSelected={selected.includes(item.id)}\n isDisabled={disabled.includes(item.id)}\n onChange={onChange}\n isSearch={isSearch}\n renderItem={renderItem}\n parentId={currentParentId}\n />\n )}\n </div>\n </div>\n );\n })}\n </div>\n );\n};\n\nexport const MobileItemsList = forwardRef(MobileItemsListComponent) as <Additional extends AdditionalDefault>(\n props: MobileItemsListProps<Additional> & { ref?: ForwardedRef<ListControls> }\n) => ReactElement;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAwB/B,MAAM,wBAAwB,GAAG,CAC7B,KAAuC,EACvC,GAA+B,KACjB;AACd,IAAA,MAAM,EACF,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,GAC3B,GAAG,KAAK,CAAC;AACV,IAAA,MAAM,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAC,C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/C,gCAAA,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gCAC5B,aAAa,CAAC,EAAE,CAAC,CAAC;AAClB,gCAAA,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;gCAC1B,wBAAwB,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;AAChD,6BAAC,EACD,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACxB,CAAA,KAEFA,GAAC,CAAA,UAAU,EACP,EAAA,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,eAAe,GAAG,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,EACpD,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACtC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACtC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,eAAe,EAC3B,CAAA,CACL,IACC,EA3CD,EAAA,WAAW,CAAC,GAAG,CA4ClB,EACR;SACL,CAAC,EACA,CAAA,EACR;AACN,CAAC,CAAC;MAEW,eAAe,GAAG,UAAU,CAAC,wBAAwB;;;;"}
|
package/MobileParentItem.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ interface MobileParentItemProps<Additional extends AdditionalDefault> {
|
|
|
9
9
|
onClick: () => void;
|
|
10
10
|
renderItem?: RenderItem<Additional>;
|
|
11
11
|
isSearch: boolean;
|
|
12
|
+
parentId?: string;
|
|
12
13
|
}
|
|
13
|
-
export declare const MobileParentItem: <Additional extends AdditionalDefault>({ collection, item, selected, onClick, isSearch, renderItem, }: MobileParentItemProps<Additional>) => ReactElement;
|
|
14
|
+
export declare const MobileParentItem: <Additional extends AdditionalDefault>({ collection, item, selected, onClick, isSearch, parentId, renderItem, }: MobileParentItemProps<Additional>) => ReactElement;
|
|
14
15
|
export {};
|
package/MobileParentItem.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
4
5
|
import { Badge } from '@hh.ru/magritte-ui-badge';
|
|
5
6
|
import { Card } from '@hh.ru/magritte-ui-card';
|
|
6
7
|
import { CellRightLabel } from '@hh.ru/magritte-ui-cell';
|
|
7
8
|
import { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
|
|
8
9
|
|
|
9
|
-
const MobileParentItem = ({ collection, item, selected, onClick, isSearch, renderItem = TreeSelectorItemBase, }) => {
|
|
10
|
+
const MobileParentItem = ({ collection, item, selected, onClick, isSearch, parentId, renderItem = TreeSelectorItemBase, }) => {
|
|
10
11
|
const childrenSelectedCount = useMemo(() => {
|
|
11
12
|
let count = 0;
|
|
12
13
|
collection.walkChildren(item.id, (model) => {
|
|
@@ -17,7 +18,9 @@ const MobileParentItem = ({ collection, item, selected, onClick, isSearch, rende
|
|
|
17
18
|
return count;
|
|
18
19
|
}, [collection, selected, item.id]);
|
|
19
20
|
const labelRight = (jsx(CellRightLabel, { badge: childrenSelectedCount ? jsx(Badge, { children: childrenSelectedCount.toString() }) : undefined }));
|
|
20
|
-
return (jsx(Card, { padding: 16, borderRadius: 12, showBorder: true, actionCard: true, stretched: true, onClick: onClick, "data-qa": `tree-selector-item-${item.id}`,
|
|
21
|
+
return (jsx(Card, { padding: 16, borderRadius: 12, showBorder: true, actionCard: true, stretched: true, onClick: onClick, "data-qa": classnames('tree-selector-item', `tree-selector-item-${item.id}`, {
|
|
22
|
+
[`tree-selector-child-${parentId}`]: parentId,
|
|
23
|
+
}), children: renderItem({ item, labelRight, childrenSelectedCount, isSearch, isXS: true, isParent: true }) }));
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
export { MobileParentItem };
|
package/MobileParentItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileParentItem.js","sources":["../src/MobileParentItem.tsx"],"sourcesContent":["import { ReactElement, useMemo } from 'react';\n\nimport { Badge } from '@hh.ru/magritte-ui-badge';\nimport { Card } from '@hh.ru/magritte-ui-card';\nimport { CellRightLabel } from '@hh.ru/magritte-ui-cell';\nimport { TreeSelectorItemBase } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorItemBase';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\ninterface MobileParentItemProps<Additional extends AdditionalDefault> {\n collection: TreeCollection<Additional>;\n item: TreeModel<Additional>;\n selected: string[];\n onClick: () => void;\n renderItem?: RenderItem<Additional>;\n isSearch: boolean;\n}\n\nexport const MobileParentItem = <Additional extends AdditionalDefault>({\n collection,\n item,\n selected,\n onClick,\n isSearch,\n renderItem = TreeSelectorItemBase,\n}: MobileParentItemProps<Additional>): ReactElement => {\n const childrenSelectedCount = useMemo(() => {\n let count = 0;\n collection.walkChildren(item.id, (model) => {\n if (selected.includes(model.id)) {\n count += 1;\n }\n });\n\n return count;\n }, [collection, selected, item.id]);\n\n const labelRight = (\n <CellRightLabel badge={childrenSelectedCount ? <Badge>{childrenSelectedCount.toString()}</Badge> : undefined} />\n );\n\n return (\n <Card\n padding={16}\n borderRadius={12}\n showBorder\n actionCard\n stretched\n onClick={onClick}\n data-qa={`tree-selector-item-${item.id}`}\n >\n {renderItem({ item, labelRight, childrenSelectedCount, isSearch, isXS: true, isParent: true })}\n </Card>\n );\n};\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MobileParentItem.js","sources":["../src/MobileParentItem.tsx"],"sourcesContent":["import { ReactElement, useMemo } from 'react';\nimport classnames from 'classnames';\n\nimport { Badge } from '@hh.ru/magritte-ui-badge';\nimport { Card } from '@hh.ru/magritte-ui-card';\nimport { CellRightLabel } from '@hh.ru/magritte-ui-cell';\nimport { TreeSelectorItemBase } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorItemBase';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\ninterface MobileParentItemProps<Additional extends AdditionalDefault> {\n collection: TreeCollection<Additional>;\n item: TreeModel<Additional>;\n selected: string[];\n onClick: () => void;\n renderItem?: RenderItem<Additional>;\n isSearch: boolean;\n parentId?: string;\n}\n\nexport const MobileParentItem = <Additional extends AdditionalDefault>({\n collection,\n item,\n selected,\n onClick,\n isSearch,\n parentId,\n renderItem = TreeSelectorItemBase,\n}: MobileParentItemProps<Additional>): ReactElement => {\n const childrenSelectedCount = useMemo(() => {\n let count = 0;\n collection.walkChildren(item.id, (model) => {\n if (selected.includes(model.id)) {\n count += 1;\n }\n });\n\n return count;\n }, [collection, selected, item.id]);\n\n const labelRight = (\n <CellRightLabel badge={childrenSelectedCount ? <Badge>{childrenSelectedCount.toString()}</Badge> : undefined} />\n );\n\n return (\n <Card\n padding={16}\n borderRadius={12}\n showBorder\n actionCard\n stretched\n onClick={onClick}\n data-qa={classnames('tree-selector-item', `tree-selector-item-${item.id}`, {\n [`tree-selector-child-${parentId}`]: parentId,\n })}\n >\n {renderItem({ item, labelRight, childrenSelectedCount, isSearch, isXS: true, isParent: true })}\n </Card>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;MAqBa,gBAAgB,GAAG,CAAuC,EACnE,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,GAAG,oBAAoB,GACD,KAAkB;AAClD,IAAA,MAAM,qBAAqB,GAAG,OAAO,CAAC,MAAK;QACvC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,KAAK,KAAI;YACvC,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;gBAC7B,KAAK,IAAI,CAAC,CAAC;AACd,aAAA;AACL,SAAC,CAAC,CAAC;AAEH,QAAA,OAAO,KAAK,CAAC;KAChB,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpC,MAAM,UAAU,IACZA,GAAC,CAAA,cAAc,EAAC,EAAA,KAAK,EAAE,qBAAqB,GAAGA,GAAA,CAAC,KAAK,EAAE,EAAA,QAAA,EAAA,qBAAqB,CAAC,QAAQ,EAAE,EAAA,CAAS,GAAG,SAAS,EAAI,CAAA,CACnH,CAAC;AAEF,IAAA,QACIA,GAAA,CAAC,IAAI,EAAA,EACD,OAAO,EAAE,EAAE,EACX,YAAY,EAAE,EAAE,EAChB,UAAU,EACV,IAAA,EAAA,UAAU,EACV,IAAA,EAAA,SAAS,EACT,IAAA,EAAA,OAAO,EAAE,OAAO,aACP,UAAU,CAAC,oBAAoB,EAAE,CAAsB,mBAAA,EAAA,IAAI,CAAC,EAAE,EAAE,EAAE;AACvE,YAAA,CAAC,CAAuB,oBAAA,EAAA,QAAQ,CAAE,CAAA,GAAG,QAAQ;SAChD,CAAC,EAAA,QAAA,EAED,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAC3F,CAAA,EACT;AACN;;;;"}
|
package/TreeSelector.js
CHANGED
|
@@ -10,8 +10,8 @@ import '@hh.ru/magritte-ui-breakpoint';
|
|
|
10
10
|
import './ItemsList.js';
|
|
11
11
|
import '@tanstack/react-virtual';
|
|
12
12
|
import './Item.js';
|
|
13
|
-
import './ItemContent.js';
|
|
14
13
|
import 'classnames';
|
|
14
|
+
import './ItemContent.js';
|
|
15
15
|
import '@hh.ru/magritte-common-keyboard';
|
|
16
16
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
17
17
|
import './Action.js';
|
|
@@ -19,7 +19,7 @@ import '@hh.ru/magritte-ui-checkbox-radio';
|
|
|
19
19
|
import './TreeSelectorItemBase.js';
|
|
20
20
|
import '@hh.ru/magritte-ui-cell';
|
|
21
21
|
import '@hh.ru/magritte-ui-typography';
|
|
22
|
-
import './tree-selector-item-
|
|
22
|
+
import './tree-selector-item-C8XcgsRu.js';
|
|
23
23
|
import './MobileItemsList.js';
|
|
24
24
|
import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
|
|
25
25
|
import './MobileDelimiter.js';
|
|
@@ -31,8 +31,6 @@ import './TreeSelectorWrapper.js';
|
|
|
31
31
|
import '@hh.ru/magritte-common-resize';
|
|
32
32
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
33
33
|
import '@hh.ru/magritte-internal-custom-scroll';
|
|
34
|
-
import '@hh.ru/magritte-ui-bottom-sheet';
|
|
35
|
-
import '@hh.ru/magritte-ui-modal';
|
|
36
34
|
import './collection/treeCollectionHelper.js';
|
|
37
35
|
import './collection/treeCollection.js';
|
|
38
36
|
import './useExpanded.js';
|
package/TreeSelector.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSelector.js","sources":["../src/TreeSelector.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef, ReactElement, useMemo } from 'react';\n\nimport { TreeSelectorDummy } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorDummy';\nimport { AdditionalDefault } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport ImmutableSelectionStrategy from '@hh.ru/magritte-ui-tree-selector/strategy/immutableSelectionStrategy';\nimport { TreeSelectorProps, ListControls } from '@hh.ru/magritte-ui-tree-selector/types';\nimport { useDisabled } from '@hh.ru/magritte-ui-tree-selector/useDisabled';\nimport { useSelected } from '@hh.ru/magritte-ui-tree-selector/useSelected';\n\nconst TreeSelectorComponent = <Additional extends AdditionalDefault>(\n props: TreeSelectorProps<Additional>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n value,\n collection,\n singleChoice,\n leavesOnly,\n collapseToParentId,\n checkSelectable,\n onChange,\n disabled,\n maxSelected,\n ...rest\n } = props;\n const strategy = useMemo(\n () =>\n new ImmutableSelectionStrategy(collection, {\n singleChoice,\n leavesOnly,\n checkSelectable,\n }),\n [collection, singleChoice, leavesOnly, checkSelectable]\n );\n\n if (maxSelected && !collapseToParentId && !leavesOnly) {\n throw new Error(\n `Magritte component TreeSelector: maxSelected can be used only with collapseToParentId or leavesOnly`\n );\n }\n\n const { selected, setSelected } = useSelected({\n value,\n strategy,\n collection,\n onChange,\n maxSelected,\n collapseToParentId,\n });\n\n const currentDisabled = useDisabled({ selected, disabled, collection, maxSelected });\n\n return (\n <TreeSelectorDummy\n {...rest}\n value={selected}\n disabled={currentDisabled}\n collection={collection}\n singleChoice={singleChoice}\n leavesOnly={leavesOnly}\n checkSelectable={checkSelectable}\n onChange={setSelected}\n ref={ref}\n />\n );\n};\n\nexport const TreeSelector = forwardRef(TreeSelectorComponent) as <Additional extends AdditionalDefault>(\n props: TreeSelectorProps<Additional> & { ref?: ForwardedRef<ListControls> }\n) => ReactElement;\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"TreeSelector.js","sources":["../src/TreeSelector.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef, ReactElement, useMemo } from 'react';\n\nimport { TreeSelectorDummy } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorDummy';\nimport { AdditionalDefault } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport ImmutableSelectionStrategy from '@hh.ru/magritte-ui-tree-selector/strategy/immutableSelectionStrategy';\nimport { TreeSelectorProps, ListControls } from '@hh.ru/magritte-ui-tree-selector/types';\nimport { useDisabled } from '@hh.ru/magritte-ui-tree-selector/useDisabled';\nimport { useSelected } from '@hh.ru/magritte-ui-tree-selector/useSelected';\n\nconst TreeSelectorComponent = <Additional extends AdditionalDefault>(\n props: TreeSelectorProps<Additional>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n value,\n collection,\n singleChoice,\n leavesOnly,\n collapseToParentId,\n checkSelectable,\n onChange,\n disabled,\n maxSelected,\n ...rest\n } = props;\n const strategy = useMemo(\n () =>\n new ImmutableSelectionStrategy(collection, {\n singleChoice,\n leavesOnly,\n checkSelectable,\n }),\n [collection, singleChoice, leavesOnly, checkSelectable]\n );\n\n if (maxSelected && !collapseToParentId && !leavesOnly) {\n throw new Error(\n `Magritte component TreeSelector: maxSelected can be used only with collapseToParentId or leavesOnly`\n );\n }\n\n const { selected, setSelected } = useSelected({\n value,\n strategy,\n collection,\n onChange,\n maxSelected,\n collapseToParentId,\n });\n\n const currentDisabled = useDisabled({ selected, disabled, collection, maxSelected });\n\n return (\n <TreeSelectorDummy\n {...rest}\n value={selected}\n disabled={currentDisabled}\n collection={collection}\n singleChoice={singleChoice}\n leavesOnly={leavesOnly}\n checkSelectable={checkSelectable}\n onChange={setSelected}\n ref={ref}\n />\n );\n};\n\nexport const TreeSelector = forwardRef(TreeSelectorComponent) as <Additional extends AdditionalDefault>(\n props: TreeSelectorProps<Additional> & { ref?: ForwardedRef<ListControls> }\n) => ReactElement;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,qBAAqB,GAAG,CAC1B,KAAoC,EACpC,GAA+B,KACjB;IACd,MAAM,EACF,KAAK,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,GAAG,IAAI,EACV,GAAG,KAAK,CAAC;IACV,MAAM,QAAQ,GAAG,OAAO,CACpB,MACI,IAAI,0BAA0B,CAAC,UAAU,EAAE;QACvC,YAAY;QACZ,UAAU;QACV,eAAe;KAClB,CAAC,EACN,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,CAAC,CAC1D,CAAC;AAEF,IAAA,IAAI,WAAW,IAAI,CAAC,kBAAkB,IAAI,CAAC,UAAU,EAAE;AACnD,QAAA,MAAM,IAAI,KAAK,CACX,CAAA,mGAAA,CAAqG,CACxG,CAAC;AACL,KAAA;AAED,IAAA,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;QAC1C,KAAK;QACL,QAAQ;QACR,UAAU;QACV,QAAQ;QACR,WAAW;QACX,kBAAkB;AACrB,KAAA,CAAC,CAAC;AAEH,IAAA,MAAM,eAAe,GAAG,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;AAErF,IAAA,QACIA,GAAC,CAAA,iBAAiB,EACV,EAAA,GAAA,IAAI,EACR,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,WAAW,EACrB,GAAG,EAAE,GAAG,EAAA,CACV,EACJ;AACN,CAAC,CAAC;MAEW,YAAY,GAAG,UAAU,CAAC,qBAAqB;;;;"}
|
package/TreeSelectorDummy.js
CHANGED
|
@@ -12,8 +12,8 @@ import { useIndeterminate } from './useIndeterminate.js';
|
|
|
12
12
|
import { useRenderInput } from './useRenderInput.js';
|
|
13
13
|
import '@tanstack/react-virtual';
|
|
14
14
|
import './Item.js';
|
|
15
|
-
import './ItemContent.js';
|
|
16
15
|
import 'classnames';
|
|
16
|
+
import './ItemContent.js';
|
|
17
17
|
import '@hh.ru/magritte-common-keyboard';
|
|
18
18
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
19
19
|
import './Action.js';
|
|
@@ -21,7 +21,7 @@ import '@hh.ru/magritte-ui-checkbox-radio';
|
|
|
21
21
|
import './TreeSelectorItemBase.js';
|
|
22
22
|
import '@hh.ru/magritte-ui-cell';
|
|
23
23
|
import '@hh.ru/magritte-ui-typography';
|
|
24
|
-
import './tree-selector-item-
|
|
24
|
+
import './tree-selector-item-C8XcgsRu.js';
|
|
25
25
|
import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
|
|
26
26
|
import './MobileDelimiter.js';
|
|
27
27
|
import '@hh.ru/magritte-ui-card';
|
|
@@ -31,8 +31,6 @@ import '@hh.ru/magritte-ui-badge';
|
|
|
31
31
|
import '@hh.ru/magritte-common-resize';
|
|
32
32
|
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
33
33
|
import '@hh.ru/magritte-internal-custom-scroll';
|
|
34
|
-
import '@hh.ru/magritte-ui-bottom-sheet';
|
|
35
|
-
import '@hh.ru/magritte-ui-modal';
|
|
36
34
|
import './collection/treeCollection.js';
|
|
37
35
|
import '@hh.ru/magritte-common-func-utils';
|
|
38
36
|
import '@hh.ru/magritte-ui-input';
|
|
@@ -136,7 +134,7 @@ const TreeSelectorDummyComponent = ({ collection: initialCollection, checkSelect
|
|
|
136
134
|
]);
|
|
137
135
|
const renderTreeSelector = useCallback(() => {
|
|
138
136
|
const hasModels = collection.getTopLevel().length;
|
|
139
|
-
return (jsx(TreeSelectorWrapper, {
|
|
137
|
+
return (jsx(TreeSelectorWrapper, { forwardRef: treeRefCallback, children: hasModels ? (jsx(Fragment, { children: isMobile ? (jsx(MobileItemsList, { getMobileSearchItemOrder: getMobileSearchItemOrder || getSearchItemOrderDefault, collection: collection, selected: selected, disabled: disabled, onChange: onChange, leavesOnly: leavesOnly, checkSelectable: checkSelectable, singleChoice: singleChoice, ref: ref, setInputValue: setInputValue, renderItem: renderItem, renderMobileDelimiter: renderMobileDelimiter, handleChangeInput: handleChangeInput, contentFilterQuery: contentFilterQuery.trim(), onMobileNavigationChange: onMobileNavigationChange, isSearch: isSearch, getSelectAllParentTrl: getSelectAllParentTrl, renderContentBefore: renderContentBefore })) : (jsx(ItemsList, { collection: collection, leavesOnly: leavesOnly, checkSelectable: checkSelectable, expanded: currentExpanded, onExpansion: handleExpansion, selected: selected, onChange: onChange, disabled: disabled, singleChoice: singleChoice, indeterminate: indeterminate, isSearch: isSearch, renderItemForDesktop: renderItemForDesktop, renderContentBefore: renderContentBefore })) })) : (jsx(Fragment, { children: contentNotFound })) }));
|
|
140
138
|
}, [
|
|
141
139
|
collection,
|
|
142
140
|
treeRefCallback,
|
package/TreeSelectorDummy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSelectorDummy.js","sources":["../src/TreeSelectorDummy.tsx"],"sourcesContent":["import { ReactElement, forwardRef, ForwardedRef, useCallback, useEffect, useRef, useState, RefCallback } from 'react';\n\nimport { match } from '@hh.ru/magritte-common-fuzzy-search';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { ItemsList } from '@hh.ru/magritte-ui-tree-selector/ItemsList';\nimport { MobileItemsList } from '@hh.ru/magritte-ui-tree-selector/MobileItemsList';\nimport { TreeSelectorWrapper } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorWrapper';\nimport { filterWithParents } from '@hh.ru/magritte-ui-tree-selector/collection/treeCollectionHelper';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { ListControls, TreeSelectorDummyProps } from '@hh.ru/magritte-ui-tree-selector/types';\nimport { useExpanded } from '@hh.ru/magritte-ui-tree-selector/useExpanded';\nimport { useIndeterminate } from '@hh.ru/magritte-ui-tree-selector/useIndeterminate';\nimport { useRenderInput } from '@hh.ru/magritte-ui-tree-selector/useRenderInput';\n\nconst defaultCheckSelectable = () => true;\nconst defaultArray: string[] = [];\n\nconst needToApply = (query: string): boolean => {\n return !!(query && query.length);\n};\n\nexport const TreeSelectorDummyComponent = <Additional extends AdditionalDefault>(\n {\n collection: initialCollection,\n checkSelectable = defaultCheckSelectable,\n initialExpanded = defaultArray,\n value: selected,\n leavesOnly,\n singleChoice,\n disabled = defaultArray,\n treeFilter = filterWithParents,\n suggestedNotFound = defaultArray,\n constantlySuggested = defaultArray,\n renderItemForDesktop,\n renderItem,\n renderMobileDelimiter,\n onExpand,\n onChange,\n onChangeFilterQuery,\n contentNotFound,\n onMobileNavigationChange,\n getMobileSearchItemOrder,\n expandTreeOnSelected = true,\n getSelectAllParentTrl,\n renderContentBefore,\n children,\n }: TreeSelectorDummyProps<Additional>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const [collection, setCollection] = useState(initialCollection);\n const [isSearch, setIsSearch] = useState(false);\n const currentQuery = useRef('');\n const inputRef = useRef<HTMLInputElement>(null);\n const suggestedNotFoundModels = useRef(initialCollection.getExistModels(suggestedNotFound));\n const constantlySuggestedModels = useRef(initialCollection.getExistModels(constantlySuggested));\n const getSearchItemOrderDefault = useCallback(\n (model: TreeModel<Additional>) => {\n return initialCollection.getModelLevel(model.id);\n },\n [initialCollection]\n );\n\n const { indeterminate } = useIndeterminate({ collection: initialCollection, selected });\n\n const {\n expanded: currentExpanded,\n setExpanded,\n handleExpansion,\n handleResetExpanded,\n } = useExpanded({\n initialValue: initialExpanded?.slice(),\n selected,\n expandTreeOnSelected,\n collection: initialCollection,\n onExpand,\n });\n const { isMobile } = useBreakpoint();\n\n const { contentFilterQuery, setInputValue, handleChangeInput, renderInput } = useRenderInput(inputRef);\n\n const treeRefCallback: RefCallback<HTMLDivElement> = useCallback(\n (node) => {\n if (!node) {\n handleResetExpanded();\n }\n },\n [handleResetExpanded]\n );\n\n useEffect(() => {\n const contentFilterQueryTrimmed = contentFilterQuery.trim();\n const queryWasChanged = contentFilterQueryTrimmed !== currentQuery.current.trim();\n\n if (queryWasChanged && needToApply(contentFilterQueryTrimmed)) {\n const newExpanded: string[] = [];\n const newCollection = treeFilter(\n initialCollection,\n (item) => match(contentFilterQueryTrimmed, item.text),\n isMobile\n );\n newCollection.toList().forEach((item) => {\n if (newCollection.hasChildren(item.id)) {\n // Если есть в отфильтрованной коллекции есть дочерние элементы,\n // значит они заматчились, и нужно открыть родителя.\n newExpanded.push(item.id);\n } else {\n // Если заматчился только сам родитель, показываем его\n // схлопнутым => нужно добавить его ветку в коллекцию.\n initialCollection.walkChildren(item.id, (child, parents) => {\n newCollection.addModel({ ...child }, parents[0].id);\n });\n }\n });\n\n const filteredIds = newCollection.toList().map((model) => model.id);\n\n // Если в отфильтрованной коллекции нет моделей, но заданы предложенные,\n // то показываем их\n // Если в отфильтрованной коллекции модели есть, то пробуем добавить к ним\n // всегда показывающиеся модели, если их ещё нет в коллекции\n if (!filteredIds.length && suggestedNotFoundModels.current.length) {\n suggestedNotFoundModels.current.forEach((model) => newCollection.addModel({ ...model }));\n } else {\n constantlySuggestedModels.current.forEach((model) => {\n if (!filteredIds.includes(model.id)) {\n newCollection.addModel({ ...model });\n }\n });\n }\n\n setCollection(newCollection);\n currentQuery.current = contentFilterQuery;\n onChangeFilterQuery?.(filteredIds, contentFilterQueryTrimmed);\n setExpanded(newExpanded);\n setIsSearch(true);\n } else if (queryWasChanged) {\n // Запрос не годится для поиска.\n const newExpanded = initialExpanded.slice();\n setCollection(initialCollection);\n\n onChangeFilterQuery?.(\n initialCollection.toList().map((model) => model.id),\n contentFilterQueryTrimmed\n );\n currentQuery.current = contentFilterQuery;\n if (inputRef.current) {\n setExpanded(newExpanded);\n } else {\n handleResetExpanded();\n }\n\n setIsSearch(false);\n }\n }, [\n initialCollection,\n contentFilterQuery,\n treeFilter,\n selected,\n setExpanded,\n isMobile,\n onChangeFilterQuery,\n handleResetExpanded,\n initialExpanded,\n ]);\n\n const renderTreeSelector = useCallback(() => {\n const hasModels = collection.getTopLevel().length;\n return (\n <TreeSelectorWrapper ref={treeRefCallback}>\n {hasModels ? (\n <>\n {isMobile ? (\n <MobileItemsList\n getMobileSearchItemOrder={getMobileSearchItemOrder || getSearchItemOrderDefault}\n collection={collection}\n selected={selected}\n disabled={disabled}\n onChange={onChange}\n leavesOnly={leavesOnly}\n checkSelectable={checkSelectable}\n singleChoice={singleChoice}\n ref={ref}\n setInputValue={setInputValue}\n renderItem={renderItem}\n renderMobileDelimiter={renderMobileDelimiter}\n handleChangeInput={handleChangeInput}\n contentFilterQuery={contentFilterQuery.trim()}\n onMobileNavigationChange={onMobileNavigationChange}\n isSearch={isSearch}\n getSelectAllParentTrl={getSelectAllParentTrl}\n renderContentBefore={renderContentBefore}\n />\n ) : (\n <ItemsList\n collection={collection}\n leavesOnly={leavesOnly}\n checkSelectable={checkSelectable}\n expanded={currentExpanded}\n onExpansion={handleExpansion}\n selected={selected}\n onChange={onChange}\n disabled={disabled}\n singleChoice={singleChoice}\n indeterminate={indeterminate}\n isSearch={isSearch}\n renderItemForDesktop={renderItemForDesktop}\n renderContentBefore={renderContentBefore}\n />\n )}\n </>\n ) : (\n <>{contentNotFound}</>\n )}\n </TreeSelectorWrapper>\n );\n }, [\n collection,\n treeRefCallback,\n isMobile,\n getMobileSearchItemOrder,\n getSearchItemOrderDefault,\n selected,\n disabled,\n onChange,\n leavesOnly,\n checkSelectable,\n singleChoice,\n ref,\n setInputValue,\n renderItem,\n renderMobileDelimiter,\n handleChangeInput,\n contentFilterQuery,\n onMobileNavigationChange,\n isSearch,\n getSelectAllParentTrl,\n renderContentBefore,\n currentExpanded,\n handleExpansion,\n indeterminate,\n renderItemForDesktop,\n contentNotFound,\n ]);\n\n return <>{children({ renderTreeSelector, renderInput })}</>;\n};\n\nexport const TreeSelectorDummy = forwardRef(TreeSelectorDummyComponent) as <Additional extends AdditionalDefault>(\n props: TreeSelectorDummyProps<Additional> & { ref?: ForwardedRef<ListControls> }\n) => ReactElement;\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC;AAC1C,MAAM,YAAY,GAAa,EAAE,CAAC;AAElC,MAAM,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,EAAA,CAAI,CAAC;AAChE,EAAE;MAEW,iBAAiB,GAAG,UAAU,CAAC,0BAA0B;;;;"}
|
|
1
|
+
{"version":3,"file":"TreeSelectorDummy.js","sources":["../src/TreeSelectorDummy.tsx"],"sourcesContent":["import { ReactElement, forwardRef, ForwardedRef, useCallback, useEffect, useRef, useState, RefCallback } from 'react';\n\nimport { match } from '@hh.ru/magritte-common-fuzzy-search';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { ItemsList } from '@hh.ru/magritte-ui-tree-selector/ItemsList';\nimport { MobileItemsList } from '@hh.ru/magritte-ui-tree-selector/MobileItemsList';\nimport { TreeSelectorWrapper } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorWrapper';\nimport { filterWithParents } from '@hh.ru/magritte-ui-tree-selector/collection/treeCollectionHelper';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { ListControls, TreeSelectorDummyProps } from '@hh.ru/magritte-ui-tree-selector/types';\nimport { useExpanded } from '@hh.ru/magritte-ui-tree-selector/useExpanded';\nimport { useIndeterminate } from '@hh.ru/magritte-ui-tree-selector/useIndeterminate';\nimport { useRenderInput } from '@hh.ru/magritte-ui-tree-selector/useRenderInput';\n\nconst defaultCheckSelectable = () => true;\nconst defaultArray: string[] = [];\n\nconst needToApply = (query: string): boolean => {\n return !!(query && query.length);\n};\n\nexport const TreeSelectorDummyComponent = <Additional extends AdditionalDefault>(\n {\n collection: initialCollection,\n checkSelectable = defaultCheckSelectable,\n initialExpanded = defaultArray,\n value: selected,\n leavesOnly,\n singleChoice,\n disabled = defaultArray,\n treeFilter = filterWithParents,\n suggestedNotFound = defaultArray,\n constantlySuggested = defaultArray,\n renderItemForDesktop,\n renderItem,\n renderMobileDelimiter,\n onExpand,\n onChange,\n onChangeFilterQuery,\n contentNotFound,\n onMobileNavigationChange,\n getMobileSearchItemOrder,\n expandTreeOnSelected = true,\n getSelectAllParentTrl,\n renderContentBefore,\n children,\n }: TreeSelectorDummyProps<Additional>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const [collection, setCollection] = useState(initialCollection);\n const [isSearch, setIsSearch] = useState(false);\n const currentQuery = useRef('');\n const inputRef = useRef<HTMLInputElement>(null);\n const suggestedNotFoundModels = useRef(initialCollection.getExistModels(suggestedNotFound));\n const constantlySuggestedModels = useRef(initialCollection.getExistModels(constantlySuggested));\n const getSearchItemOrderDefault = useCallback(\n (model: TreeModel<Additional>) => {\n return initialCollection.getModelLevel(model.id);\n },\n [initialCollection]\n );\n\n const { indeterminate } = useIndeterminate({ collection: initialCollection, selected });\n\n const {\n expanded: currentExpanded,\n setExpanded,\n handleExpansion,\n handleResetExpanded,\n } = useExpanded({\n initialValue: initialExpanded?.slice(),\n selected,\n expandTreeOnSelected,\n collection: initialCollection,\n onExpand,\n });\n const { isMobile } = useBreakpoint();\n\n const { contentFilterQuery, setInputValue, handleChangeInput, renderInput } = useRenderInput(inputRef);\n\n const treeRefCallback: RefCallback<HTMLDivElement> = useCallback(\n (node) => {\n if (!node) {\n handleResetExpanded();\n }\n },\n [handleResetExpanded]\n );\n\n useEffect(() => {\n const contentFilterQueryTrimmed = contentFilterQuery.trim();\n const queryWasChanged = contentFilterQueryTrimmed !== currentQuery.current.trim();\n\n if (queryWasChanged && needToApply(contentFilterQueryTrimmed)) {\n const newExpanded: string[] = [];\n const newCollection = treeFilter(\n initialCollection,\n (item) => match(contentFilterQueryTrimmed, item.text),\n isMobile\n );\n newCollection.toList().forEach((item) => {\n if (newCollection.hasChildren(item.id)) {\n // Если есть в отфильтрованной коллекции есть дочерние элементы,\n // значит они заматчились, и нужно открыть родителя.\n newExpanded.push(item.id);\n } else {\n // Если заматчился только сам родитель, показываем его\n // схлопнутым => нужно добавить его ветку в коллекцию.\n initialCollection.walkChildren(item.id, (child, parents) => {\n newCollection.addModel({ ...child }, parents[0].id);\n });\n }\n });\n\n const filteredIds = newCollection.toList().map((model) => model.id);\n\n // Если в отфильтрованной коллекции нет моделей, но заданы предложенные,\n // то показываем их\n // Если в отфильтрованной коллекции модели есть, то пробуем добавить к ним\n // всегда показывающиеся модели, если их ещё нет в коллекции\n if (!filteredIds.length && suggestedNotFoundModels.current.length) {\n suggestedNotFoundModels.current.forEach((model) => newCollection.addModel({ ...model }));\n } else {\n constantlySuggestedModels.current.forEach((model) => {\n if (!filteredIds.includes(model.id)) {\n newCollection.addModel({ ...model });\n }\n });\n }\n\n setCollection(newCollection);\n currentQuery.current = contentFilterQuery;\n onChangeFilterQuery?.(filteredIds, contentFilterQueryTrimmed);\n setExpanded(newExpanded);\n setIsSearch(true);\n } else if (queryWasChanged) {\n // Запрос не годится для поиска.\n const newExpanded = initialExpanded.slice();\n setCollection(initialCollection);\n\n onChangeFilterQuery?.(\n initialCollection.toList().map((model) => model.id),\n contentFilterQueryTrimmed\n );\n currentQuery.current = contentFilterQuery;\n if (inputRef.current) {\n setExpanded(newExpanded);\n } else {\n handleResetExpanded();\n }\n\n setIsSearch(false);\n }\n }, [\n initialCollection,\n contentFilterQuery,\n treeFilter,\n selected,\n setExpanded,\n isMobile,\n onChangeFilterQuery,\n handleResetExpanded,\n initialExpanded,\n ]);\n\n const renderTreeSelector = useCallback(() => {\n const hasModels = collection.getTopLevel().length;\n return (\n <TreeSelectorWrapper forwardRef={treeRefCallback}>\n {hasModels ? (\n <>\n {isMobile ? (\n <MobileItemsList\n getMobileSearchItemOrder={getMobileSearchItemOrder || getSearchItemOrderDefault}\n collection={collection}\n selected={selected}\n disabled={disabled}\n onChange={onChange}\n leavesOnly={leavesOnly}\n checkSelectable={checkSelectable}\n singleChoice={singleChoice}\n ref={ref}\n setInputValue={setInputValue}\n renderItem={renderItem}\n renderMobileDelimiter={renderMobileDelimiter}\n handleChangeInput={handleChangeInput}\n contentFilterQuery={contentFilterQuery.trim()}\n onMobileNavigationChange={onMobileNavigationChange}\n isSearch={isSearch}\n getSelectAllParentTrl={getSelectAllParentTrl}\n renderContentBefore={renderContentBefore}\n />\n ) : (\n <ItemsList\n collection={collection}\n leavesOnly={leavesOnly}\n checkSelectable={checkSelectable}\n expanded={currentExpanded}\n onExpansion={handleExpansion}\n selected={selected}\n onChange={onChange}\n disabled={disabled}\n singleChoice={singleChoice}\n indeterminate={indeterminate}\n isSearch={isSearch}\n renderItemForDesktop={renderItemForDesktop}\n renderContentBefore={renderContentBefore}\n />\n )}\n </>\n ) : (\n <>{contentNotFound}</>\n )}\n </TreeSelectorWrapper>\n );\n }, [\n collection,\n treeRefCallback,\n isMobile,\n getMobileSearchItemOrder,\n getSearchItemOrderDefault,\n selected,\n disabled,\n onChange,\n leavesOnly,\n checkSelectable,\n singleChoice,\n ref,\n setInputValue,\n renderItem,\n renderMobileDelimiter,\n handleChangeInput,\n contentFilterQuery,\n onMobileNavigationChange,\n isSearch,\n getSelectAllParentTrl,\n renderContentBefore,\n currentExpanded,\n handleExpansion,\n indeterminate,\n renderItemForDesktop,\n contentNotFound,\n ]);\n\n return <>{children({ renderTreeSelector, renderInput })}</>;\n};\n\nexport const TreeSelectorDummy = forwardRef(TreeSelectorDummyComponent) as <Additional extends AdditionalDefault>(\n props: TreeSelectorDummyProps<Additional> & { ref?: ForwardedRef<ListControls> }\n) => ReactElement;\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC;AAC1C,MAAM,YAAY,GAAa,EAAE,CAAC;AAElC,MAAM,WAAW,GAAG,CAAC,KAAa,KAAa;IAC3C,OAAO,CAAC,EAAE,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAEK,MAAM,0BAA0B,GAAG,CACtC,EACI,UAAU,EAAE,iBAAiB,EAC7B,eAAe,GAAG,sBAAsB,EACxC,eAAe,GAAG,YAAY,EAC9B,KAAK,EAAE,QAAQ,EACf,UAAU,EACV,YAAY,EACZ,QAAQ,GAAG,YAAY,EACvB,U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SAAS,EACN,EAAA,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,eAAe,EACzB,WAAW,EAAE,eAAe,EAC5B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,oBAAoB,EAC1C,mBAAmB,EAAE,mBAAmB,EAC1C,CAAA,CACL,GACF,KAEHA,GAAG,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,eAAe,GAAI,CACzB,EAAA,CACiB,EACxB;AACN,KAAC,EAAE;QACC,UAAU;QACV,eAAe;QACf,QAAQ;QACR,wBAAwB;QACxB,yBAAyB;QACzB,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,UAAU;QACV,eAAe;QACf,YAAY;QACZ,GAAG;QACH,aAAa;QACb,UAAU;QACV,qBAAqB;QACrB,iBAAiB;QACjB,kBAAkB;QAClB,wBAAwB;QACxB,QAAQ;QACR,qBAAqB;QACrB,mBAAmB;QACnB,eAAe;QACf,eAAe;QACf,aAAa;QACb,oBAAoB;QACpB,eAAe;AAClB,KAAA,CAAC,CAAC;IAEH,OAAOD,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,CAAC,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAC,EAAA,CAAI,CAAC;AAChE,EAAE;MAEW,iBAAiB,GAAG,UAAU,CAAC,0BAA0B;;;;"}
|
package/TreeSelectorItemBase.js
CHANGED
|
@@ -7,7 +7,7 @@ const TreeSelectorItemBase = ({ disabled, input, item, isXS, labelRight, }) => {
|
|
|
7
7
|
[isXS ? 'right' : 'left']: input,
|
|
8
8
|
...(isXS && labelRight && { right: labelRight }),
|
|
9
9
|
};
|
|
10
|
-
return (jsx(Cell, { disabled: disabled, ...cellProps, Element: isXS || !input ? 'div' : 'label', align: "top", children: jsx(CellText, { children: item.text }) }));
|
|
10
|
+
return (jsx(Cell, { disabled: disabled, ...cellProps, Element: isXS || !input ? 'div' : 'label', align: "top", children: jsx(CellText, { "data-qa": `tree-selector-item-text tree-selector-item-text-${item.id}`, children: item.text }) }));
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export { TreeSelectorItemBase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSelectorItemBase.js","sources":["../src/TreeSelectorItemBase.tsx"],"sourcesContent":["import { ReactElement } from 'react';\n\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { AdditionalDefault } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItemProps } from '@hh.ru/magritte-ui-tree-selector/types';\n\nexport const TreeSelectorItemBase = <Additional extends AdditionalDefault>({\n disabled,\n input,\n item,\n isXS,\n labelRight,\n}: RenderItemProps<Additional>): ReactElement => {\n const cellProps = {\n [isXS ? 'right' : 'left']: input,\n ...(isXS && labelRight && { right: labelRight }),\n };\n return (\n <Cell disabled={disabled} {...cellProps} Element={isXS || !input ? 'div' : 'label'} align=\"top\">\n <CellText>{item.text}</CellText>\n </Cell>\n );\n};\n"],"names":["_jsx"],"mappings":";;;AAMa,MAAA,oBAAoB,GAAG,CAAuC,EACvE,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,UAAU,GACgB,KAAkB;AAC5C,IAAA,MAAM,SAAS,GAAG;QACd,CAAC,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK;QAChC,IAAI,IAAI,IAAI,UAAU,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE;KAClD,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeSelectorItemBase.js","sources":["../src/TreeSelectorItemBase.tsx"],"sourcesContent":["import { ReactElement } from 'react';\n\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { AdditionalDefault } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItemProps } from '@hh.ru/magritte-ui-tree-selector/types';\n\nexport const TreeSelectorItemBase = <Additional extends AdditionalDefault>({\n disabled,\n input,\n item,\n isXS,\n labelRight,\n}: RenderItemProps<Additional>): ReactElement => {\n const cellProps = {\n [isXS ? 'right' : 'left']: input,\n ...(isXS && labelRight && { right: labelRight }),\n };\n return (\n <Cell disabled={disabled} {...cellProps} Element={isXS || !input ? 'div' : 'label'} align=\"top\">\n <CellText data-qa={`tree-selector-item-text tree-selector-item-text-${item.id}`}>{item.text}</CellText>\n </Cell>\n );\n};\n"],"names":["_jsx"],"mappings":";;;AAMa,MAAA,oBAAoB,GAAG,CAAuC,EACvE,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,UAAU,GACgB,KAAkB;AAC5C,IAAA,MAAM,SAAS,GAAG;QACd,CAAC,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK;QAChC,IAAI,IAAI,IAAI,UAAU,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE;KAClD,CAAC;IACF,QACIA,IAAC,IAAI,EAAA,EAAC,QAAQ,EAAE,QAAQ,KAAM,SAAS,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,GAAG,OAAO,EAAE,KAAK,EAAC,KAAK,YAC3FA,GAAC,CAAA,QAAQ,eAAU,CAAmD,gDAAA,EAAA,IAAI,CAAC,EAAE,CAAA,CAAE,YAAG,IAAI,CAAC,IAAI,EAAY,CAAA,EAAA,CACpG,EACT;AACN;;;;"}
|
package/TreeSelectorWrapper.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { ReactNode, PropsWithChildren, ForwardedRef, ReactElement } from 'react';
|
|
2
|
+
import { FcWithFlag } from '@hh.ru/magritte-types';
|
|
3
|
+
interface TreeSelectorWrapperProps extends PropsWithChildren {
|
|
4
|
+
forwardRef: ForwardedRef<HTMLDivElement>;
|
|
5
|
+
}
|
|
6
|
+
export declare const TreeSelectorWrapper: FcWithFlag<TreeSelectorWrapperProps, 'isTreeSelectorWrapper'>;
|
|
7
|
+
export declare const isValidTreeSelectorWrapper: (component: ReactNode) => component is ReactElement<TreeSelectorWrapperProps, string | import("react").JSXElementConstructor<any>>;
|
|
8
|
+
export {};
|
package/TreeSelectorWrapper.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { useState, useRef, useContext, useCallback, useLayoutEffect, useEffect, isValidElement } from 'react';
|
|
4
4
|
import { useResize } from '@hh.ru/magritte-common-resize';
|
|
5
5
|
import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
|
|
6
6
|
import { CustomScrollContext } from '@hh.ru/magritte-internal-custom-scroll';
|
|
7
|
-
import { BottomSheetFullScreenContent } from '@hh.ru/magritte-ui-bottom-sheet';
|
|
8
|
-
import { ModalContentFullHeight } from '@hh.ru/magritte-ui-modal';
|
|
9
7
|
|
|
10
|
-
const TreeSelectorWrapper = forwardRef
|
|
8
|
+
const TreeSelectorWrapper = ({ forwardRef, ...props }) => {
|
|
11
9
|
const [height, setHeight] = useState(0);
|
|
12
10
|
const wrapperRef = useRef(null);
|
|
13
|
-
const wrapperMultiRef = useMultipleRefs(wrapperRef,
|
|
11
|
+
const wrapperMultiRef = useMultipleRefs(wrapperRef, forwardRef);
|
|
14
12
|
const scrollContext = useContext(CustomScrollContext);
|
|
15
13
|
const calcHeight = useCallback(() => {
|
|
16
14
|
if (wrapperRef.current?.parentElement) {
|
|
@@ -36,9 +34,12 @@ const TreeSelectorWrapper = forwardRef((props, ref) => {
|
|
|
36
34
|
return () => wrapperElement.removeEventListener('touchmove', handleTouchMove);
|
|
37
35
|
}, [scrollContext]);
|
|
38
36
|
useResize(calcHeight);
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
TreeSelectorWrapper.
|
|
37
|
+
return jsx("div", { style: { height, overflow: 'auto' }, ref: wrapperMultiRef, ...props });
|
|
38
|
+
};
|
|
39
|
+
TreeSelectorWrapper.isTreeSelectorWrapper = true;
|
|
40
|
+
const isValidTreeSelectorWrapper = (component) => {
|
|
41
|
+
return isValidElement(component) && typeof component.type !== 'string' && 'isTreeSelectorWrapper' in component.type;
|
|
42
|
+
};
|
|
42
43
|
|
|
43
|
-
export { TreeSelectorWrapper };
|
|
44
|
+
export { TreeSelectorWrapper, isValidTreeSelectorWrapper };
|
|
44
45
|
//# sourceMappingURL=TreeSelectorWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSelectorWrapper.js","sources":["../src/TreeSelectorWrapper.tsx"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"file":"TreeSelectorWrapper.js","sources":["../src/TreeSelectorWrapper.tsx"],"sourcesContent":["import {\n ReactNode,\n PropsWithChildren,\n useRef,\n useState,\n useLayoutEffect,\n useCallback,\n useEffect,\n useContext,\n ForwardedRef,\n ReactElement,\n isValidElement,\n} from 'react';\n\nimport { useResize } from '@hh.ru/magritte-common-resize';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { CustomScrollContext } from '@hh.ru/magritte-internal-custom-scroll';\nimport { FcWithFlag } from '@hh.ru/magritte-types';\n\ninterface TreeSelectorWrapperProps extends PropsWithChildren {\n forwardRef: ForwardedRef<HTMLDivElement>;\n}\n\nexport const TreeSelectorWrapper: FcWithFlag<TreeSelectorWrapperProps, 'isTreeSelectorWrapper'> = ({\n forwardRef,\n ...props\n}) => {\n const [height, setHeight] = useState(0);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const wrapperMultiRef = useMultipleRefs(wrapperRef, forwardRef);\n const scrollContext = useContext(CustomScrollContext);\n\n const calcHeight = useCallback(() => {\n if (wrapperRef.current?.parentElement) {\n const style = window.getComputedStyle(wrapperRef.current.parentElement) || {};\n const paddingTop = parseFloat(style.paddingTop || '0');\n const paddingBottom = parseFloat(style.paddingBottom || '0');\n const height = wrapperRef.current.parentElement.offsetHeight - paddingTop - paddingBottom;\n setHeight(height);\n }\n }, []);\n\n useLayoutEffect(() => {\n calcHeight();\n }, [calcHeight]);\n\n useEffect(() => {\n const wrapperElement = wrapperRef.current;\n if (!wrapperElement || !scrollContext) {\n return void 0;\n }\n\n const handleTouchMove = (event: TouchEvent) => {\n event.stopPropagation();\n };\n\n wrapperElement.addEventListener('touchmove', handleTouchMove);\n return () => wrapperElement.removeEventListener('touchmove', handleTouchMove);\n }, [scrollContext]);\n\n useResize(calcHeight);\n\n return <div style={{ height, overflow: 'auto' }} ref={wrapperMultiRef} {...props} />;\n};\n\nTreeSelectorWrapper.isTreeSelectorWrapper = true;\n\nexport const isValidTreeSelectorWrapper = (\n component: ReactNode\n): component is ReactElement<TreeSelectorWrapperProps> => {\n return isValidElement(component) && typeof component.type !== 'string' && 'isTreeSelectorWrapper' in component.type;\n};\n"],"names":["_jsx"],"mappings":";;;;;;AAuBO,MAAM,mBAAmB,GAAkE,CAAC,EAC/F,UAAU,EACV,GAAG,KAAK,EACX,KAAI;IACD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AACxC,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,MAAM,eAAe,GAAG,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAChE,IAAA,MAAM,aAAa,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;AAEtD,IAAA,MAAM,UAAU,GAAG,WAAW,CAAC,MAAK;AAChC,QAAA,IAAI,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE;AACnC,YAAA,MAAM,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE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SAAS,CAAC,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,IAAI,uBAAuB,IAAI,SAAS,CAAC,IAAI,CAAC;AACxH;;;;"}
|
package/index.css
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
--magritte-semantic-animation-ease-in-out-200-timing-function-v18-3-0:cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
5
5
|
--magritte-semantic-animation-ease-in-out-200-duration-v18-3-0:200ms;
|
|
6
6
|
}
|
|
7
|
-
@keyframes magritte-fade-in___yS4Ja_4-0
|
|
7
|
+
@keyframes magritte-fade-in___yS4Ja_4-2-0{
|
|
8
8
|
0%{
|
|
9
9
|
opacity:0;
|
|
10
10
|
}
|
|
@@ -12,24 +12,24 @@
|
|
|
12
12
|
opacity:1;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
.magritte-item-animation-timeout___pbOyZ_4-0
|
|
16
|
-
animation-name:magritte-fade-in___yS4Ja_4-0
|
|
15
|
+
.magritte-item-animation-timeout___pbOyZ_4-2-0{
|
|
16
|
+
animation-name:magritte-fade-in___yS4Ja_4-2-0;
|
|
17
17
|
animation-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v18-3-0);
|
|
18
18
|
--animation-duration:0ms;
|
|
19
19
|
animation-duration:var(--animation-duration);
|
|
20
20
|
}
|
|
21
21
|
@media (prefers-reduced-motion: no-preference){
|
|
22
|
-
.magritte-item-animation-timeout___pbOyZ_4-0
|
|
22
|
+
.magritte-item-animation-timeout___pbOyZ_4-2-0{
|
|
23
23
|
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v18-3-0);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
.magritte-wrapper___GHKV6_4-0
|
|
26
|
+
.magritte-wrapper___GHKV6_4-2-0{
|
|
27
27
|
display:flex;
|
|
28
28
|
padding:12px 0;
|
|
29
29
|
gap:12px;
|
|
30
30
|
align-items:flex-start;
|
|
31
31
|
}
|
|
32
|
-
.magritte-letter___yZOCU_4-0
|
|
32
|
+
.magritte-letter___yZOCU_4-2-0{
|
|
33
33
|
width:24px;
|
|
34
34
|
height:24px;
|
|
35
35
|
display:flex;
|
|
@@ -37,58 +37,59 @@
|
|
|
37
37
|
justify-content:center;
|
|
38
38
|
flex-shrink:0;
|
|
39
39
|
}
|
|
40
|
-
.magritte-icon___kO3Fj_4-0
|
|
41
|
-
.magritte-space___xTO79_4-0
|
|
40
|
+
.magritte-icon___kO3Fj_4-2-0,
|
|
41
|
+
.magritte-space___xTO79_4-2-0{
|
|
42
42
|
flex-shrink:0;
|
|
43
43
|
line-height:0;
|
|
44
44
|
width:24px;
|
|
45
45
|
}
|
|
46
|
-
.magritte-icon___kO3Fj_4-0
|
|
46
|
+
.magritte-icon___kO3Fj_4-2-0{
|
|
47
47
|
transform:rotate(0);
|
|
48
48
|
}
|
|
49
|
-
.magritte-
|
|
49
|
+
.magritte-wrapperActive___Hwk8p_4-2-0,
|
|
50
|
+
.magritte-iconActive___4yrG5_4-2-0{
|
|
50
51
|
cursor:pointer;
|
|
51
52
|
}
|
|
52
|
-
.magritte-iconUp___mpXV6_4-0
|
|
53
|
+
.magritte-iconUp___mpXV6_4-2-0{
|
|
53
54
|
transform:rotate(90deg);
|
|
54
55
|
}
|
|
55
56
|
@media (prefers-reduced-motion: no-preference){
|
|
56
|
-
.magritte-icon___kO3Fj_4-0
|
|
57
|
+
.magritte-icon___kO3Fj_4-2-0{
|
|
57
58
|
transition-property:transform;
|
|
58
59
|
transition-duration:var(--magritte-semantic-animation-ease-in-out-100-duration-v18-3-0);
|
|
59
60
|
transition-timing-function:var(--magritte-semantic-animation-ease-in-out-100-timing-function-v18-3-0);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
.magritte-content___ZRc6R_4-0
|
|
63
|
+
.magritte-content___ZRc6R_4-2-0{
|
|
63
64
|
flex-grow:1;
|
|
64
65
|
}
|
|
65
|
-
.magritte-mobile-item___ynALC_4-0
|
|
66
|
+
.magritte-mobile-item___ynALC_4-2-0{
|
|
66
67
|
display:flex;
|
|
67
68
|
gap:12px;
|
|
68
69
|
flex-wrap:wrap;
|
|
69
70
|
}
|
|
70
|
-
.magritte-with-gap___gbvGO_4-0
|
|
71
|
+
.magritte-with-gap___gbvGO_4-2-0{
|
|
71
72
|
padding-top:12px;
|
|
72
73
|
}
|
|
73
|
-
.magritte-virtualized-list___qt2E6_4-0
|
|
74
|
+
.magritte-virtualized-list___qt2E6_4-2-0{
|
|
74
75
|
width:100%;
|
|
75
76
|
position:relative;
|
|
76
77
|
will-change:transform;
|
|
77
78
|
}
|
|
78
|
-
.magritte-virtualized-item___qAYVN_4-0
|
|
79
|
+
.magritte-virtualized-item___qAYVN_4-2-0{
|
|
79
80
|
position:absolute;
|
|
80
81
|
top:0;
|
|
81
82
|
left:0;
|
|
82
83
|
width:100%;
|
|
83
84
|
}
|
|
84
|
-
.magritte-was-expanded___uCFbW_4-0
|
|
85
|
-
animation-name:magritte-fade-in___yS4Ja_4-0
|
|
85
|
+
.magritte-was-expanded___uCFbW_4-2-0{
|
|
86
|
+
animation-name:magritte-fade-in___yS4Ja_4-2-0;
|
|
86
87
|
animation-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v18-3-0);
|
|
87
88
|
--animation-duration:0ms;
|
|
88
89
|
animation-duration:var(--animation-duration);
|
|
89
90
|
}
|
|
90
91
|
@media (prefers-reduced-motion: no-preference){
|
|
91
|
-
.magritte-was-expanded___uCFbW_4-0
|
|
92
|
+
.magritte-was-expanded___uCFbW_4-2-0{
|
|
92
93
|
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v18-3-0);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
@@ -97,7 +98,7 @@
|
|
|
97
98
|
--magritte-semantic-animation-ease-in-out-200-timing-function-v18-3-0:cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
98
99
|
--magritte-semantic-animation-ease-in-out-200-duration-v18-3-0:200ms;
|
|
99
100
|
}
|
|
100
|
-
@keyframes magritte-fade-in___FDoho_4-0
|
|
101
|
+
@keyframes magritte-fade-in___FDoho_4-2-0{
|
|
101
102
|
0%{
|
|
102
103
|
opacity:0;
|
|
103
104
|
}
|
|
@@ -105,14 +106,14 @@
|
|
|
105
106
|
opacity:1;
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
|
-
.magritte-item-animation-timeout___Pdli9_4-0
|
|
109
|
-
animation-name:magritte-fade-in___FDoho_4-0
|
|
109
|
+
.magritte-item-animation-timeout___Pdli9_4-2-0{
|
|
110
|
+
animation-name:magritte-fade-in___FDoho_4-2-0;
|
|
110
111
|
animation-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v18-3-0);
|
|
111
112
|
--animation-duration:0ms;
|
|
112
113
|
animation-duration:var(--animation-duration);
|
|
113
114
|
}
|
|
114
115
|
@media (prefers-reduced-motion: no-preference){
|
|
115
|
-
.magritte-item-animation-timeout___Pdli9_4-0
|
|
116
|
+
.magritte-item-animation-timeout___Pdli9_4-2-0{
|
|
116
117
|
--animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v18-3-0);
|
|
117
118
|
}
|
|
118
119
|
}
|
package/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export * from '@hh.ru/magritte-ui-tree-selector/TreeSelectorItemBase';
|
|
|
7
7
|
export * from '@hh.ru/magritte-ui-tree-selector/types';
|
|
8
8
|
export * from '@hh.ru/magritte-ui-tree-selector/collection/types';
|
|
9
9
|
export * from '@hh.ru/magritte-ui-tree-selector/collection/treeCollectionHelper';
|
|
10
|
+
export { isValidTreeSelectorWrapper } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorWrapper';
|
|
10
11
|
export { TreeCollection, ImmutableSelectionStrategy };
|
package/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { TreeSelector } from './TreeSelector.js';
|
|
|
6
6
|
export { TreeSelectorDummy, TreeSelectorDummyComponent } from './TreeSelectorDummy.js';
|
|
7
7
|
export { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
|
|
8
8
|
export { filterMissingIds, filterParents, filterUniqueLeavesOnly, filterWithParents, fromTree, getIdsWithNoParentsInSameList, walk } from './collection/treeCollectionHelper.js';
|
|
9
|
+
export { isValidTreeSelectorWrapper } from './TreeSelectorWrapper.js';
|
|
9
10
|
import './strategy/selectionStrategy.js';
|
|
10
11
|
import './strategy/createSingleValueToggler.js';
|
|
11
12
|
import './strategy/createTreeCollectionToggler.js';
|
|
@@ -19,14 +20,14 @@ import '@hh.ru/magritte-ui-breakpoint';
|
|
|
19
20
|
import './ItemsList.js';
|
|
20
21
|
import '@tanstack/react-virtual';
|
|
21
22
|
import './Item.js';
|
|
22
|
-
import './ItemContent.js';
|
|
23
23
|
import 'classnames';
|
|
24
|
+
import './ItemContent.js';
|
|
24
25
|
import '@hh.ru/magritte-common-keyboard';
|
|
25
26
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
26
27
|
import './Action.js';
|
|
27
28
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
28
29
|
import '@hh.ru/magritte-ui-typography';
|
|
29
|
-
import './tree-selector-item-
|
|
30
|
+
import './tree-selector-item-C8XcgsRu.js';
|
|
30
31
|
import './MobileItemsList.js';
|
|
31
32
|
import '@hh.ru/magritte-ui-cell';
|
|
32
33
|
import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
|
|
@@ -35,16 +36,13 @@ import '@hh.ru/magritte-ui-card';
|
|
|
35
36
|
import './MobileItem.js';
|
|
36
37
|
import './MobileParentItem.js';
|
|
37
38
|
import '@hh.ru/magritte-ui-badge';
|
|
38
|
-
import './TreeSelectorWrapper.js';
|
|
39
|
-
import '@hh.ru/magritte-common-resize';
|
|
40
|
-
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
41
|
-
import '@hh.ru/magritte-internal-custom-scroll';
|
|
42
|
-
import '@hh.ru/magritte-ui-bottom-sheet';
|
|
43
|
-
import '@hh.ru/magritte-ui-modal';
|
|
44
39
|
import './useExpanded.js';
|
|
45
40
|
import './useIndeterminate.js';
|
|
46
41
|
import './useRenderInput.js';
|
|
47
42
|
import '@hh.ru/magritte-common-func-utils';
|
|
43
|
+
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
48
44
|
import '@hh.ru/magritte-ui-input';
|
|
49
45
|
import './useAnimationTimeout.js';
|
|
46
|
+
import '@hh.ru/magritte-common-resize';
|
|
47
|
+
import '@hh.ru/magritte-internal-custom-scroll';
|
|
50
48
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/index.mock.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { ThemeProvider };
|
|
|
6
6
|
export * from '@hh.ru/magritte-ui-tree-selector/types';
|
|
7
7
|
export * from '@hh.ru/magritte-ui-tree-selector/collection/types';
|
|
8
8
|
export * from '@hh.ru/magritte-ui-tree-selector/collection/treeCollectionHelper';
|
|
9
|
+
export { isValidTreeSelectorWrapper } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorWrapper';
|
|
9
10
|
export { TreeCollection, ImmutableSelectionStrategy };
|
|
10
11
|
export declare const TreeSelector: ForwardRefExoticComponent<Record<string, unknown>>;
|
|
11
12
|
export declare const TreeSelectorDummy: ForwardRefExoticComponent<Record<string, unknown>>;
|
package/index.mock.js
CHANGED
|
@@ -3,10 +3,16 @@ import { mockComponent } from '@hh.ru/magritte-ui-mock-component';
|
|
|
3
3
|
export { default as TreeCollection } from './collection/treeCollection.js';
|
|
4
4
|
export { default as ImmutableSelectionStrategy } from './strategy/immutableSelectionStrategy.js';
|
|
5
5
|
export { filterMissingIds, filterParents, filterUniqueLeavesOnly, filterWithParents, fromTree, getIdsWithNoParentsInSameList, walk } from './collection/treeCollectionHelper.js';
|
|
6
|
+
export { isValidTreeSelectorWrapper } from './TreeSelectorWrapper.js';
|
|
6
7
|
import './strategy/selectionStrategy.js';
|
|
7
8
|
import './strategy/createSingleValueToggler.js';
|
|
8
9
|
import './strategy/createTreeCollectionToggler.js';
|
|
9
10
|
import './strategy/dummyToggle.js';
|
|
11
|
+
import 'react/jsx-runtime';
|
|
12
|
+
import 'react';
|
|
13
|
+
import '@hh.ru/magritte-common-resize';
|
|
14
|
+
import '@hh.ru/magritte-common-use-multiple-refs';
|
|
15
|
+
import '@hh.ru/magritte-internal-custom-scroll';
|
|
10
16
|
|
|
11
17
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
12
18
|
const { ThemeProvider } = jest.requireActual('@hh.ru/magritte-ui-theme-provider/index');
|
package/index.mock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mock.js","sources":["../src/index.mock.ts"],"sourcesContent":["import { ForwardRefExoticComponent } from 'react';\n\nimport { mockComponent } from '@hh.ru/magritte-ui-mock-component';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport ImmutableSelectionStrategy from '@hh.ru/magritte-ui-tree-selector/strategy/immutableSelectionStrategy';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst { ThemeProvider } = jest.requireActual('@hh.ru/magritte-ui-theme-provider/index');\n\nexport { ThemeProvider };\n\nexport * from '@hh.ru/magritte-ui-tree-selector/types';\nexport * from '@hh.ru/magritte-ui-tree-selector/collection/types';\nexport * from '@hh.ru/magritte-ui-tree-selector/collection/treeCollectionHelper';\nexport { TreeCollection, ImmutableSelectionStrategy };\n\nexport const TreeSelector: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent(\n 'TreeSelector',\n undefined,\n { withChildren: true }\n);\n\nexport const TreeSelectorDummy: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent(\n 'TreeSelectorDummy',\n undefined,\n {\n withChildren: true,\n }\n);\n\nexport const TreeSelectorItemBase = mockComponent('TreeSelectorItemBase');\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mock.js","sources":["../src/index.mock.ts"],"sourcesContent":["import { ForwardRefExoticComponent } from 'react';\n\nimport { mockComponent } from '@hh.ru/magritte-ui-mock-component';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport ImmutableSelectionStrategy from '@hh.ru/magritte-ui-tree-selector/strategy/immutableSelectionStrategy';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst { ThemeProvider } = jest.requireActual('@hh.ru/magritte-ui-theme-provider/index');\n\nexport { ThemeProvider };\n\nexport * from '@hh.ru/magritte-ui-tree-selector/types';\nexport * from '@hh.ru/magritte-ui-tree-selector/collection/types';\nexport * from '@hh.ru/magritte-ui-tree-selector/collection/treeCollectionHelper';\nexport { isValidTreeSelectorWrapper } from '@hh.ru/magritte-ui-tree-selector/TreeSelectorWrapper';\nexport { TreeCollection, ImmutableSelectionStrategy };\n\nexport const TreeSelector: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent(\n 'TreeSelector',\n undefined,\n { withChildren: true }\n);\n\nexport const TreeSelectorDummy: ForwardRefExoticComponent<Record<string, unknown>> = mockComponent(\n 'TreeSelectorDummy',\n undefined,\n {\n withChildren: true,\n }\n);\n\nexport const TreeSelectorItemBase = mockComponent('TreeSelectorItemBase');\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA;AACM,MAAA,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,yCAAyC,EAAE;AAU3E,MAAA,YAAY,GAAuD,aAAa,CACzF,cAAc,EACd,SAAS,EACT,EAAE,YAAY,EAAE,IAAI,EAAE,EACxB;MAEW,iBAAiB,GAAuD,aAAa,CAC9F,mBAAmB,EACnB,SAAS,EACT;AACI,IAAA,YAAY,EAAE,IAAI;AACrB,CAAA,EACH;MAEW,oBAAoB,GAAG,aAAa,CAAC,sBAAsB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-tree-selector",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@hh.ru/magritte-common-use-multiple-refs": "1.1.4",
|
|
28
28
|
"@hh.ru/magritte-design-tokens": "18.3.0",
|
|
29
29
|
"@hh.ru/magritte-internal-custom-scroll": "1.2.0",
|
|
30
|
+
"@hh.ru/magritte-types": "4.0.2",
|
|
30
31
|
"@hh.ru/magritte-ui-badge": "2.2.2",
|
|
31
|
-
"@hh.ru/magritte-ui-bottom-sheet": "5.2.5",
|
|
32
32
|
"@hh.ru/magritte-ui-breakpoint": "4.0.3",
|
|
33
33
|
"@hh.ru/magritte-ui-card": "6.0.12",
|
|
34
34
|
"@hh.ru/magritte-ui-cell": "4.0.1",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"@hh.ru/magritte-ui-icon": "7.4.0",
|
|
38
38
|
"@hh.ru/magritte-ui-input": "5.1.4",
|
|
39
39
|
"@hh.ru/magritte-ui-mock-component": "1.0.11",
|
|
40
|
-
"@hh.ru/magritte-ui-modal": "4.1.2",
|
|
41
40
|
"@hh.ru/magritte-ui-spacing": "2.0.26",
|
|
42
41
|
"@hh.ru/magritte-ui-theme-provider": "1.1.26",
|
|
43
42
|
"@hh.ru/magritte-ui-typography": "3.0.13",
|
|
@@ -51,5 +50,5 @@
|
|
|
51
50
|
"publishConfig": {
|
|
52
51
|
"access": "public"
|
|
53
52
|
},
|
|
54
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "0ea0e3c3d786ef9f240b5d9ac14c305bcfceefb1"
|
|
55
54
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
var styles = {"item-animation-timeout":"magritte-item-animation-timeout___pbOyZ_4-2-0","itemAnimationTimeout":"magritte-item-animation-timeout___pbOyZ_4-2-0","fade-in":"magritte-fade-in___yS4Ja_4-2-0","fadeIn":"magritte-fade-in___yS4Ja_4-2-0","wrapper":"magritte-wrapper___GHKV6_4-2-0","letter":"magritte-letter___yZOCU_4-2-0","icon":"magritte-icon___kO3Fj_4-2-0","space":"magritte-space___xTO79_4-2-0","wrapperActive":"magritte-wrapperActive___Hwk8p_4-2-0","iconActive":"magritte-iconActive___4yrG5_4-2-0","iconUp":"magritte-iconUp___mpXV6_4-2-0","content":"magritte-content___ZRc6R_4-2-0","mobile-item":"magritte-mobile-item___ynALC_4-2-0","mobileItem":"magritte-mobile-item___ynALC_4-2-0","with-gap":"magritte-with-gap___gbvGO_4-2-0","withGap":"magritte-with-gap___gbvGO_4-2-0","virtualized-list":"magritte-virtualized-list___qt2E6_4-2-0","virtualizedList":"magritte-virtualized-list___qt2E6_4-2-0","virtualized-item":"magritte-virtualized-item___qAYVN_4-2-0","virtualizedItem":"magritte-virtualized-item___qAYVN_4-2-0","was-expanded":"magritte-was-expanded___uCFbW_4-2-0","wasExpanded":"magritte-was-expanded___uCFbW_4-2-0"};
|
|
3
|
+
|
|
4
|
+
export { styles as s };
|
|
5
|
+
//# sourceMappingURL=tree-selector-item-C8XcgsRu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-selector-item-C8XcgsRu.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/useAnimationTimeout.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { useState, useLayoutEffect } from 'react';
|
|
3
3
|
|
|
4
|
-
var styles = {"item-animation-timeout":"magritte-item-animation-timeout___Pdli9_4-0
|
|
4
|
+
var styles = {"item-animation-timeout":"magritte-item-animation-timeout___Pdli9_4-2-0","itemAnimationTimeout":"magritte-item-animation-timeout___Pdli9_4-2-0","fade-in":"magritte-fade-in___FDoho_4-2-0","fadeIn":"magritte-fade-in___FDoho_4-2-0"};
|
|
5
5
|
|
|
6
6
|
const useAnimationTimeout = () => {
|
|
7
7
|
const [animationTimeout, setAnimationTimeout] = useState(0);
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
var styles = {"item-animation-timeout":"magritte-item-animation-timeout___pbOyZ_4-0-6","itemAnimationTimeout":"magritte-item-animation-timeout___pbOyZ_4-0-6","fade-in":"magritte-fade-in___yS4Ja_4-0-6","fadeIn":"magritte-fade-in___yS4Ja_4-0-6","wrapper":"magritte-wrapper___GHKV6_4-0-6","letter":"magritte-letter___yZOCU_4-0-6","icon":"magritte-icon___kO3Fj_4-0-6","space":"magritte-space___xTO79_4-0-6","iconActive":"magritte-iconActive___4yrG5_4-0-6","iconUp":"magritte-iconUp___mpXV6_4-0-6","content":"magritte-content___ZRc6R_4-0-6","mobile-item":"magritte-mobile-item___ynALC_4-0-6","mobileItem":"magritte-mobile-item___ynALC_4-0-6","with-gap":"magritte-with-gap___gbvGO_4-0-6","withGap":"magritte-with-gap___gbvGO_4-0-6","virtualized-list":"magritte-virtualized-list___qt2E6_4-0-6","virtualizedList":"magritte-virtualized-list___qt2E6_4-0-6","virtualized-item":"magritte-virtualized-item___qAYVN_4-0-6","virtualizedItem":"magritte-virtualized-item___qAYVN_4-0-6","was-expanded":"magritte-was-expanded___uCFbW_4-0-6","wasExpanded":"magritte-was-expanded___uCFbW_4-0-6"};
|
|
3
|
-
|
|
4
|
-
export { styles as s };
|
|
5
|
-
//# sourceMappingURL=tree-selector-item-DEDTJUiP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tree-selector-item-DEDTJUiP.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|