@hh.ru/magritte-ui-tree-selector 1.4.1 → 1.5.1
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/Item.d.ts +4 -1
- package/Item.js +8 -7
- package/Item.js.map +1 -1
- package/{ItemContent-d63a26ba.js → ItemContent-cec51c98.js} +7 -6
- package/ItemContent-cec51c98.js.map +1 -0
- package/ItemContent.d.ts +4 -1
- package/ItemContent.js +3 -2
- package/ItemContent.js.map +1 -1
- package/ItemsList.d.ts +3 -0
- package/ItemsList.js +5 -4
- package/ItemsList.js.map +1 -1
- package/MobileDelimiter.d.ts +2 -0
- package/MobileDelimiter.js +11 -0
- package/MobileDelimiter.js.map +1 -0
- package/MobileItem.d.ts +4 -1
- package/MobileItem.js +5 -3
- package/MobileItem.js.map +1 -1
- package/MobileItemsList.d.ts +5 -2
- package/MobileItemsList.js +24 -12
- package/MobileItemsList.js.map +1 -1
- package/MobileParentItem.d.ts +4 -1
- package/MobileParentItem.js +5 -3
- package/MobileParentItem.js.map +1 -1
- package/TreeSelector.js +5 -3
- package/TreeSelector.js.map +1 -1
- package/TreeSelectorDummy.js +11 -5
- package/TreeSelectorDummy.js.map +1 -1
- package/TreeSelectorItemBase.d.ts +4 -0
- package/TreeSelectorItemBase.js +14 -0
- package/TreeSelectorItemBase.js.map +1 -0
- package/index.css +16 -13
- package/index.d.ts +1 -0
- package/index.js +5 -3
- package/index.js.map +1 -1
- package/package.json +6 -6
- package/types.d.ts +31 -1
- package/ItemContent-d63a26ba.js.map +0 -1
package/Item.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren, ReactElement } from 'react';
|
|
2
2
|
import TreeCollection from './collection/treeCollection';
|
|
3
3
|
import { AdditionalDefault, IdCollectionPredicate, TreeModel } from './collection/types';
|
|
4
|
+
import { RenderItem } from './types';
|
|
4
5
|
interface ItemProps<A extends AdditionalDefault> extends PropsWithChildren {
|
|
5
6
|
collection: TreeCollection<A>;
|
|
6
7
|
parentId?: string;
|
|
@@ -12,8 +13,10 @@ interface ItemProps<A extends AdditionalDefault> extends PropsWithChildren {
|
|
|
12
13
|
isDisabled: boolean;
|
|
13
14
|
singleChoice?: boolean;
|
|
14
15
|
isIndeterminate: boolean;
|
|
16
|
+
isSearch: boolean;
|
|
15
17
|
onExpansion: (id: string) => void;
|
|
16
18
|
onChange: (id: string, isSelected: boolean) => void;
|
|
19
|
+
renderItemForDesktop?: RenderItem;
|
|
17
20
|
}
|
|
18
|
-
export declare const Item: <A extends AdditionalDefault>({ collection, item, parentId, isExpanded, isSelected, isIndeterminate, isDisabled, leavesOnly, singleChoice, checkSelectable, onExpansion, onChange, children, }: ItemProps<A>) => ReactElement;
|
|
21
|
+
export declare const Item: <A extends AdditionalDefault>({ collection, item, parentId, isExpanded, isSelected, isIndeterminate, isDisabled, leavesOnly, singleChoice, isSearch, checkSelectable, onExpansion, onChange, renderItemForDesktop, children, }: ItemProps<A>) => ReactElement;
|
|
19
22
|
export {};
|
package/Item.js
CHANGED
|
@@ -2,18 +2,19 @@ import './index.css';
|
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { s as styles, I as ItemContent } from './ItemContent-
|
|
6
|
-
import '@hh.ru/magritte-ui-cell';
|
|
5
|
+
import { s as styles, I as ItemContent } from './ItemContent-cec51c98.js';
|
|
7
6
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
8
7
|
import './Action.js';
|
|
9
8
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
9
|
+
import './TreeSelectorItemBase.js';
|
|
10
|
+
import '@hh.ru/magritte-ui-cell';
|
|
10
11
|
import '@hh.ru/magritte-ui-typography';
|
|
11
12
|
|
|
12
|
-
const Item = ({ collection, item, parentId, isExpanded, isSelected, isIndeterminate, isDisabled, leavesOnly, singleChoice, checkSelectable, onExpansion, onChange, children, }) => {
|
|
13
|
+
const Item = ({ collection, item, parentId, isExpanded, isSelected, isIndeterminate, isDisabled, leavesOnly, singleChoice, isSearch, checkSelectable, onExpansion, onChange, renderItemForDesktop, children, }) => {
|
|
13
14
|
const modelsOnLevel = useMemo(() => (parentId ? collection.getChildren(parentId) : collection.getTopLevel()), [parentId, collection]);
|
|
14
15
|
const hasLetterOnLevel = useMemo(() => {
|
|
15
|
-
return modelsOnLevel.some((model) => model.additional?.char);
|
|
16
|
-
}, [modelsOnLevel]);
|
|
16
|
+
return !isSearch && modelsOnLevel.some((model) => model.additional?.char);
|
|
17
|
+
}, [modelsOnLevel, isSearch]);
|
|
17
18
|
// максимальное кол-во контролов на уровне, максимум может быть 2 - шеврон + чекбокс/радио
|
|
18
19
|
const maxControlsOnLevel = useMemo(() => {
|
|
19
20
|
return modelsOnLevel.reduce((currentMax, model) => {
|
|
@@ -25,7 +26,7 @@ const Item = ({ collection, item, parentId, isExpanded, isSelected, isIndetermin
|
|
|
25
26
|
}, [modelsOnLevel, checkSelectable, leavesOnly, collection]);
|
|
26
27
|
const hasChildren = collection.hasChildren(item.id);
|
|
27
28
|
const hasAction = !(leavesOnly && hasChildren) && checkSelectable?.(item.id, collection);
|
|
28
|
-
const hasLetter = item.additional?.char;
|
|
29
|
+
const hasLetter = item.additional?.char && !isSearch;
|
|
29
30
|
const realControlsCount = +hasChildren + +!!hasAction;
|
|
30
31
|
// точка заменяет недостающий контрол, если их суммарное кол-во на уровне больше суммарного значения на текущем уровне
|
|
31
32
|
const hasDot = realControlsCount < maxControlsOnLevel && (hasAction || hasChildren);
|
|
@@ -38,7 +39,7 @@ const Item = ({ collection, item, parentId, isExpanded, isSelected, isIndetermin
|
|
|
38
39
|
[styles.withThreeBoxes]: allBoxesCount === 3,
|
|
39
40
|
[styles.withShift]: hasShift && parentId,
|
|
40
41
|
[styles.withIndent]: allBoxesCount === 0,
|
|
41
|
-
}), children: [jsx(ItemContent, { item: item, hasChildren: hasChildren, hasAction: !!hasAction, letter: hasLetter, isExpanded: isExpanded, onExpansion: onExpansion, isSelected: isSelected, onChange: onChange, singleChoice: singleChoice, isIndeterminate: isIndeterminate, isDisabled: isDisabled, hasLetterOnLevel: hasLetterOnLevel, hasDot: hasDot, maxControlsOnLevel: maxControlsOnLevel }), children && jsx("div", { className: styles.children, children: children })] }));
|
|
42
|
+
}), children: [jsx(ItemContent, { item: item, 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 && jsx("div", { className: styles.children, children: children })] }));
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
export { Item };
|
package/Item.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.js","sources":["../src/Item.tsx"],"sourcesContent":["import { PropsWithChildren, ReactElement, useMemo } 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';\n\nimport styles from './tree-selector-item.less';\n\ninterface ItemProps<A extends AdditionalDefault> extends PropsWithChildren {\n collection: TreeCollection<A>;\n parentId?: string;\n item: TreeModel<A>;\n leavesOnly?: boolean;\n checkSelectable?: IdCollectionPredicate;\n isExpanded: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n singleChoice?: boolean;\n isIndeterminate: boolean;\n onExpansion: (id: string) => void;\n onChange: (id: string, isSelected: boolean) => void;\n}\n\nexport const Item = <A extends AdditionalDefault>({\n collection,\n item,\n parentId,\n isExpanded,\n isSelected,\n isIndeterminate,\n isDisabled,\n leavesOnly,\n singleChoice,\n checkSelectable,\n onExpansion,\n onChange,\n children,\n}: ItemProps<A>): ReactElement => {\n const modelsOnLevel = useMemo(\n () => (parentId ? collection.getChildren(parentId) : collection.getTopLevel()),\n [parentId, collection]\n );\n\n const hasLetterOnLevel = useMemo(() => {\n return modelsOnLevel.some((model) => model.additional?.char);\n }, [modelsOnLevel]);\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;\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 ((hasParentAction && (hasLetterOnLevel || hasChildren || hasDot)) || (!hasParentAction && hasLetterOnLevel));\n\n return (\n <div\n className={classnames(styles.item, {\n [styles.withTwoBoxes]: allBoxesCount === 2,\n [styles.withThreeBoxes]: allBoxesCount === 3,\n [styles.withShift]: hasShift && parentId,\n [styles.withIndent]: allBoxesCount === 0,\n })}\n >\n <ItemContent\n item={item}\n hasChildren={hasChildren}\n hasAction={!!hasAction}\n letter={hasLetter}\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 />\n {children && <div className={styles.children}>{children}</div>}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Item.js","sources":["../src/Item.tsx"],"sourcesContent":["import { PropsWithChildren, ReactElement, useMemo } 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\nimport styles from './tree-selector-item.less';\n\ninterface ItemProps<A extends AdditionalDefault> extends PropsWithChildren {\n collection: TreeCollection<A>;\n parentId?: string;\n item: TreeModel<A>;\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;\n}\n\nexport const Item = <A 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 children,\n}: ItemProps<A>): 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 ((hasParentAction && (hasLetterOnLevel || hasChildren || hasDot)) || (!hasParentAction && hasLetterOnLevel));\n\n return (\n <div\n className={classnames(styles.item, {\n [styles.withTwoBoxes]: allBoxesCount === 2,\n [styles.withThreeBoxes]: allBoxesCount === 3,\n [styles.withShift]: hasShift && parentId,\n [styles.withIndent]: allBoxesCount === 0,\n })}\n >\n <ItemContent\n item={item}\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 {children && <div className={styles.children}>{children}</div>}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;AA2Ba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G,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,SAAS,EACrD,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,oBAAoB,EAAA,CAC5C,EACD,QAAQ,IAAIA,aAAK,SAAS,EAAE,MAAM,CAAC,QAAQ,YAAG,QAAQ,EAAA,CAAO,CAC5D,EAAA,CAAA,EACR;AACN;;;;"}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import './index.css';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { Cell, CellText } from '@hh.ru/magritte-ui-cell';
|
|
6
5
|
import { DotFilledSize24, ChevronDownOutlinedSize24, ChevronUpOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';
|
|
7
6
|
import { Action } from './Action.js';
|
|
7
|
+
import { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
|
|
8
8
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
9
9
|
|
|
10
|
-
var styles = {"wrapper":"magritte-wrapper___GHKV6_1-
|
|
10
|
+
var styles = {"wrapper":"magritte-wrapper___GHKV6_1-5-1","letter":"magritte-letter___yZOCU_1-5-1","icon":"magritte-icon___kO3Fj_1-5-1","space":"magritte-space___xTO79_1-5-1","iconActive":"magritte-iconActive___4yrG5_1-5-1","content":"magritte-content___ZRc6R_1-5-1","with-shift":"magritte-with-shift___ZErxZ_1-5-1","withShift":"magritte-with-shift___ZErxZ_1-5-1","with-indent":"magritte-with-indent___MH9Vy_1-5-1","withIndent":"magritte-with-indent___MH9Vy_1-5-1","item":"magritte-item___2LtOL_1-5-1","children":"magritte-children___kq-eq_1-5-1","with-two-boxes":"magritte-with-two-boxes___LWOy2_1-5-1","withTwoBoxes":"magritte-with-two-boxes___LWOy2_1-5-1","with-three-boxes":"magritte-with-three-boxes___cyVao_1-5-1","withThreeBoxes":"magritte-with-three-boxes___cyVao_1-5-1"};
|
|
11
11
|
|
|
12
|
-
const ItemContent = ({ item, hasAction, hasChildren, letter, isExpanded, isDisabled, onExpansion, hasLetterOnLevel, isSelected, onChange, isIndeterminate, singleChoice, hasDot, maxControlsOnLevel, }) => {
|
|
12
|
+
const ItemContent = ({ item, hasAction, hasChildren, letter, isExpanded, isDisabled, onExpansion, hasLetterOnLevel, isSelected, onChange, isIndeterminate, singleChoice, hasDot, maxControlsOnLevel, isSearch, renderItemForDesktop = TreeSelectorItemBase, }) => {
|
|
13
13
|
const handleExpandableClick = useCallback(() => onExpansion && onExpansion(item.id), [item.id, onExpansion]);
|
|
14
14
|
const currentActionCount = +hasDot + +hasAction + +hasChildren;
|
|
15
15
|
const neededSpacesCount = maxControlsOnLevel - currentActionCount;
|
|
16
|
+
const input = hasAction ? (jsx(Action, { selected: isSelected, onChange: onChange, id: item.id, indeterminate: isIndeterminate, singleChoice: singleChoice })) : undefined;
|
|
16
17
|
return (jsxs("div", { className: styles.wrapper, 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 && (jsxs("div", { className: classnames(styles.icon, {
|
|
17
18
|
[styles.iconActive]: hasChildren,
|
|
18
|
-
}), onClick: handleExpandableClick, children: [isExpanded && jsx(ChevronDownOutlinedSize24, { initial: "tertiary" }), !isExpanded && jsx(ChevronUpOutlinedSize24, { initial: "tertiary" })] })),
|
|
19
|
+
}), onClick: handleExpandableClick, children: [isExpanded && jsx(ChevronDownOutlinedSize24, { initial: "tertiary" }), !isExpanded && jsx(ChevronUpOutlinedSize24, { initial: "tertiary" })] })), renderItemForDesktop({ disabled: isDisabled, input, item, isSearch, isParent: hasChildren })] }));
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
export { ItemContent as I, styles as s };
|
|
22
|
-
//# sourceMappingURL=ItemContent-
|
|
23
|
+
//# sourceMappingURL=ItemContent-cec51c98.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemContent-cec51c98.js","sources":["../src/ItemContent.tsx"],"sourcesContent":["import { ReactElement, useCallback } from 'react';\nimport classnames from 'classnames';\n\nimport { ChevronDownOutlinedSize24, ChevronUpOutlinedSize24, DotFilledSize24 } 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<A extends AdditionalDefault> {\n item: TreeModel<A>;\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;\n isSearch: boolean;\n}\n\nconst ItemContent = <A extends AdditionalDefault>({\n item,\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<A>): 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 input = hasAction ? (\n <Action\n selected={isSelected}\n onChange={onChange}\n id={item.id}\n indeterminate={isIndeterminate}\n singleChoice={singleChoice}\n />\n ) : undefined;\n\n return (\n <div className={styles.wrapper}>\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, {\n [styles.iconActive]: hasChildren,\n })}\n onClick={handleExpandableClick}\n >\n {isExpanded && <ChevronDownOutlinedSize24 initial=\"tertiary\" />}\n {!isExpanded && <ChevronUpOutlinedSize24 initial=\"tertiary\" />}\n </div>\n )}\n {renderItemForDesktop({ disabled: isDisabled, input, item, isSearch, isParent: hasChildren })}\n </div>\n );\n};\n\nexport { ItemContent };\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;AA+BA,MAAM,WAAW,GAAG,CAA8B,EAC9C,IAAI,EACJ,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,GAC9B,KAAkB;IAC/B,MAAM,qBAAqB,GAA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C,CAA6B,CAC3C,CAAC,EAED,WAAW,KACRC,IACI,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE;AAC/B,oBAAA,CAAC,MAAM,CAAC,UAAU,GAAG,WAAW;iBACnC,CAAC,EACF,OAAO,EAAE,qBAAqB,aAE7B,UAAU,IAAID,GAAC,CAAA,yBAAyB,EAAC,EAAA,OAAO,EAAC,UAAU,EAAA,CAAG,EAC9D,CAAC,UAAU,IAAIA,GAAC,CAAA,uBAAuB,EAAC,EAAA,OAAO,EAAC,UAAU,GAAG,CAC5D,EAAA,CAAA,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;;;;"}
|
package/ItemContent.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { AdditionalDefault, TreeModel } from './collection/types';
|
|
3
|
+
import { RenderItem } from './types';
|
|
3
4
|
interface ItemContent<A extends AdditionalDefault> {
|
|
4
5
|
item: TreeModel<A>;
|
|
5
6
|
hasChildren: boolean;
|
|
@@ -15,6 +16,8 @@ interface ItemContent<A extends AdditionalDefault> {
|
|
|
15
16
|
hasLetterOnLevel: boolean;
|
|
16
17
|
hasDot: boolean;
|
|
17
18
|
maxControlsOnLevel: number;
|
|
19
|
+
renderItemForDesktop?: RenderItem;
|
|
20
|
+
isSearch: boolean;
|
|
18
21
|
}
|
|
19
|
-
declare const ItemContent: <A extends AdditionalDefault>({ item, hasAction, hasChildren, letter, isExpanded, isDisabled, onExpansion, hasLetterOnLevel, isSelected, onChange, isIndeterminate, singleChoice, hasDot, maxControlsOnLevel, }: ItemContent<A>) => ReactElement;
|
|
22
|
+
declare const ItemContent: <A extends AdditionalDefault>({ item, hasAction, hasChildren, letter, isExpanded, isDisabled, onExpansion, hasLetterOnLevel, isSelected, onChange, isIndeterminate, singleChoice, hasDot, maxControlsOnLevel, isSearch, renderItemForDesktop, }: ItemContent<A>) => ReactElement;
|
|
20
23
|
export { ItemContent };
|
package/ItemContent.js
CHANGED
|
@@ -2,10 +2,11 @@ import './index.css';
|
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'classnames';
|
|
5
|
-
import '@hh.ru/magritte-ui-cell';
|
|
6
5
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
7
6
|
import './Action.js';
|
|
7
|
+
import './TreeSelectorItemBase.js';
|
|
8
8
|
import '@hh.ru/magritte-ui-typography';
|
|
9
|
-
export { I as ItemContent } from './ItemContent-
|
|
9
|
+
export { I as ItemContent } from './ItemContent-cec51c98.js';
|
|
10
10
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
11
|
+
import '@hh.ru/magritte-ui-cell';
|
|
11
12
|
//# sourceMappingURL=ItemContent.js.map
|
package/ItemContent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemContent.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ItemContent.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
package/ItemsList.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import TreeCollection from './collection/treeCollection';
|
|
3
3
|
import { AdditionalDefault, IdCollectionPredicate, TreeModel } from './collection/types';
|
|
4
|
+
import { RenderItem } from './types';
|
|
4
5
|
interface ItemsListProps<A extends AdditionalDefault> {
|
|
5
6
|
items: TreeModel<A>[];
|
|
6
7
|
collection: TreeCollection<A>;
|
|
@@ -14,6 +15,8 @@ interface ItemsListProps<A extends AdditionalDefault> {
|
|
|
14
15
|
onChange: (id: string, isSelected: boolean) => void;
|
|
15
16
|
indeterminate: string[];
|
|
16
17
|
singleChoice?: boolean;
|
|
18
|
+
isSearch: boolean;
|
|
19
|
+
renderItemForDesktop?: RenderItem;
|
|
17
20
|
}
|
|
18
21
|
export declare const ItemsList: <A extends AdditionalDefault>(props: ItemsListProps<A>) => ReactElement;
|
|
19
22
|
export {};
|
package/ItemsList.js
CHANGED
|
@@ -3,19 +3,20 @@ import { jsx, Fragment } from 'react/jsx-runtime';
|
|
|
3
3
|
import { Item } from './Item.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'classnames';
|
|
6
|
-
import './ItemContent-
|
|
7
|
-
import '@hh.ru/magritte-ui-cell';
|
|
6
|
+
import './ItemContent-cec51c98.js';
|
|
8
7
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
9
8
|
import './Action.js';
|
|
10
9
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
10
|
+
import './TreeSelectorItemBase.js';
|
|
11
|
+
import '@hh.ru/magritte-ui-cell';
|
|
11
12
|
import '@hh.ru/magritte-ui-typography';
|
|
12
13
|
|
|
13
14
|
const ItemsList = (props) => {
|
|
14
|
-
const { items, collection, leavesOnly, checkSelectable, selected, parentId, expanded, disabled, onExpansion, indeterminate, onChange, singleChoice, } = props;
|
|
15
|
+
const { items, collection, leavesOnly, checkSelectable, selected, parentId, expanded, disabled, onExpansion, indeterminate, onChange, isSearch, singleChoice, renderItemForDesktop, } = props;
|
|
15
16
|
return (jsx(Fragment, { children: items.map((item) => {
|
|
16
17
|
const isExpanded = expanded.includes(item.id);
|
|
17
18
|
const hasChildren = collection.hasChildren(item.id);
|
|
18
|
-
return (jsx(Item, { collection: collection, checkSelectable: checkSelectable, isSelected: selected.includes(item.id), isExpanded: isExpanded, isIndeterminate: indeterminate.includes(item.id), isDisabled: disabled.includes(item.id), parentId: parentId, item: item, leavesOnly: leavesOnly, singleChoice: singleChoice, onExpansion: onExpansion, onChange: onChange, children: hasChildren && isExpanded && (jsx(ItemsList, { ...props, items: collection.getChildren(item.id), parentId: item.id })) }, item.id));
|
|
19
|
+
return (jsx(Item, { collection: collection, checkSelectable: checkSelectable, isSelected: selected.includes(item.id), isExpanded: isExpanded, isIndeterminate: indeterminate.includes(item.id), isDisabled: disabled.includes(item.id), parentId: parentId, item: item, leavesOnly: leavesOnly, singleChoice: singleChoice, onExpansion: onExpansion, onChange: onChange, isSearch: isSearch, renderItemForDesktop: renderItemForDesktop, children: hasChildren && isExpanded && (jsx(ItemsList, { ...props, items: collection.getChildren(item.id), parentId: item.id })) }, item.id));
|
|
19
20
|
}) }));
|
|
20
21
|
};
|
|
21
22
|
|
package/ItemsList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemsList.js","sources":["../src/ItemsList.tsx"],"sourcesContent":["import { ReactElement } from 'react';\n\nimport { Item } from '@hh.ru/magritte-ui-tree-selector/Item';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, IdCollectionPredicate, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\n\ninterface ItemsListProps<A extends AdditionalDefault> {\n items: TreeModel<A>[];\n collection: TreeCollection<A>;\n leavesOnly?: boolean;\n checkSelectable?: IdCollectionPredicate;\n parentId?: TreeModel<A>['id'];\n onExpansion: (id: string) => void;\n expanded: string[];\n selected: string[];\n disabled: string[];\n onChange: (id: string, isSelected: boolean) => void;\n indeterminate: string[];\n singleChoice?: boolean;\n}\n\nexport const ItemsList = <A extends AdditionalDefault>(props: ItemsListProps<A>): ReactElement => {\n const {\n items,\n collection,\n leavesOnly,\n checkSelectable,\n selected,\n parentId,\n expanded,\n disabled,\n onExpansion,\n indeterminate,\n onChange,\n singleChoice,\n } = props;\n return (\n <>\n {items.map((item) => {\n const isExpanded = expanded.includes(item.id);\n const hasChildren = collection.hasChildren(item.id);\n\n return (\n <Item\n key={item.id}\n collection={collection}\n checkSelectable={checkSelectable}\n isSelected={selected.includes(item.id)}\n isExpanded={isExpanded}\n isIndeterminate={indeterminate.includes(item.id)}\n isDisabled={disabled.includes(item.id)}\n parentId={parentId}\n item={item}\n leavesOnly={leavesOnly}\n singleChoice={singleChoice}\n onExpansion={onExpansion}\n onChange={onChange}\n >\n {hasChildren && isExpanded && (\n <ItemsList {...props} items={collection.getChildren(item.id)} parentId={item.id} />\n )}\n </Item>\n );\n })}\n </>\n );\n};\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ItemsList.js","sources":["../src/ItemsList.tsx"],"sourcesContent":["import { ReactElement } from 'react';\n\nimport { Item } from '@hh.ru/magritte-ui-tree-selector/Item';\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\ninterface ItemsListProps<A extends AdditionalDefault> {\n items: TreeModel<A>[];\n collection: TreeCollection<A>;\n leavesOnly?: boolean;\n checkSelectable?: IdCollectionPredicate;\n parentId?: TreeModel<A>['id'];\n onExpansion: (id: string) => void;\n expanded: string[];\n selected: string[];\n disabled: string[];\n onChange: (id: string, isSelected: boolean) => void;\n indeterminate: string[];\n singleChoice?: boolean;\n isSearch: boolean;\n renderItemForDesktop?: RenderItem;\n}\n\nexport const ItemsList = <A extends AdditionalDefault>(props: ItemsListProps<A>): ReactElement => {\n const {\n items,\n collection,\n leavesOnly,\n checkSelectable,\n selected,\n parentId,\n expanded,\n disabled,\n onExpansion,\n indeterminate,\n onChange,\n isSearch,\n singleChoice,\n renderItemForDesktop,\n } = props;\n return (\n <>\n {items.map((item) => {\n const isExpanded = expanded.includes(item.id);\n const hasChildren = collection.hasChildren(item.id);\n\n return (\n <Item\n key={item.id}\n collection={collection}\n checkSelectable={checkSelectable}\n isSelected={selected.includes(item.id)}\n isExpanded={isExpanded}\n isIndeterminate={indeterminate.includes(item.id)}\n isDisabled={disabled.includes(item.id)}\n parentId={parentId}\n item={item}\n leavesOnly={leavesOnly}\n singleChoice={singleChoice}\n onExpansion={onExpansion}\n onChange={onChange}\n isSearch={isSearch}\n renderItemForDesktop={renderItemForDesktop}\n >\n {hasChildren && isExpanded && (\n <ItemsList {...props} items={collection.getChildren(item.id)} parentId={item.id} />\n )}\n </Item>\n );\n })}\n </>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;AAwBa,MAAA,SAAS,GAAG,CAA8B,KAAwB,KAAkB;AAC7F,IAAA,MAAM,EACF,KAAK,EACL,UAAU,EACV,UAAU,EACV,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,oBAAoB,GACvB,GAAG,KAAK,CAAC;IACV,QACIA,0BACK,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;YAChB,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC9C,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAEpD,QACIA,GAAC,CAAA,IAAI,EAED,EAAA,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACtC,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAChD,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACtC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,oBAAoB,EAAA,QAAA,EAEzC,WAAW,IAAI,UAAU,KACtBA,GAAA,CAAC,SAAS,EAAK,EAAA,GAAA,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAI,CAAA,CACtF,EAlBI,EAAA,IAAI,CAAC,EAAE,CAmBT,EACT;SACL,CAAC,EACH,CAAA,EACL;AACN;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Card } from '@hh.ru/magritte-ui-card';
|
|
4
|
+
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
5
|
+
|
|
6
|
+
const MobileDelimiter = ({ children }) => {
|
|
7
|
+
return (jsx(Card, { padding: 16, paddingTop: 8, paddingBottom: 0, children: jsx(Text, { typography: "label-3-regular", style: "secondary", children: children }) }));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { MobileDelimiter };
|
|
11
|
+
//# sourceMappingURL=MobileDelimiter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileDelimiter.js","sources":["../src/MobileDelimiter.tsx"],"sourcesContent":["import { PropsWithChildren, FC } from 'react';\n\nimport { Card } from '@hh.ru/magritte-ui-card';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nexport const MobileDelimiter: FC<PropsWithChildren> = ({ children }) => {\n return (\n <Card padding={16} paddingTop={8} paddingBottom={0}>\n <Text typography=\"label-3-regular\" style=\"secondary\">\n {children}\n </Text>\n </Card>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;MAKa,eAAe,GAA0B,CAAC,EAAE,QAAQ,EAAE,KAAI;AACnE,IAAA,QACIA,GAAA,CAAC,IAAI,EAAA,EAAC,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAC9C,QAAA,EAAAA,GAAA,CAAC,IAAI,EAAA,EAAC,UAAU,EAAC,iBAAiB,EAAC,KAAK,EAAC,WAAW,EAC/C,QAAA,EAAA,QAAQ,EACN,CAAA,EAAA,CACJ,EACT;AACN;;;;"}
|
package/MobileItem.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { AdditionalDefault, TreeModel } from './collection/types';
|
|
3
|
+
import { RenderItem } from './types';
|
|
3
4
|
interface MobileItemProps<A extends AdditionalDefault> {
|
|
4
5
|
item: TreeModel<A>;
|
|
5
6
|
singleChoice?: boolean;
|
|
@@ -7,6 +8,8 @@ interface MobileItemProps<A extends AdditionalDefault> {
|
|
|
7
8
|
isSelected: boolean;
|
|
8
9
|
isDisabled: boolean;
|
|
9
10
|
onChange: (id: string, isSelected: boolean) => void;
|
|
11
|
+
renderItem?: RenderItem;
|
|
12
|
+
isSearch: boolean;
|
|
10
13
|
}
|
|
11
|
-
export declare const MobileItem: <A extends AdditionalDefault>({ item, isSelected, singleChoice, isSelectable, isDisabled, onChange, }: MobileItemProps<A>) => ReactElement;
|
|
14
|
+
export declare const MobileItem: <A extends AdditionalDefault>({ item, isSelected, singleChoice, isSelectable, isDisabled, onChange, isSearch, renderItem, }: MobileItemProps<A>) => ReactElement;
|
|
12
15
|
export {};
|
package/MobileItem.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { Cell, CellText } from '@hh.ru/magritte-ui-cell';
|
|
4
3
|
import { CheckableCardElement } from '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
|
|
5
4
|
import { Action } from './Action.js';
|
|
5
|
+
import { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
|
|
6
6
|
import 'react';
|
|
7
7
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
8
|
+
import '@hh.ru/magritte-ui-cell';
|
|
8
9
|
|
|
9
|
-
const MobileItem = ({ item, isSelected, singleChoice, isSelectable, isDisabled, onChange, }) => {
|
|
10
|
-
|
|
10
|
+
const MobileItem = ({ item, isSelected, singleChoice, isSelectable, isDisabled, onChange, isSearch, renderItem = TreeSelectorItemBase, }) => {
|
|
11
|
+
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", checked: isSelected, children: renderItem({ input, item, isSearch, isXS: true, disabled: isDisabled }) }));
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
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 {
|
|
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<A extends AdditionalDefault> {\n item: TreeModel<A>;\n singleChoice?: boolean;\n isSelectable?: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n onChange: (id: string, isSelected: boolean) => void;\n renderItem?: RenderItem;\n isSearch: boolean;\n}\n\nexport const MobileItem = <A extends AdditionalDefault>({\n item,\n isSelected,\n singleChoice,\n isSelectable,\n isDisabled,\n onChange,\n isSearch,\n renderItem = TreeSelectorItemBase,\n}: MobileItemProps<A>): ReactElement => {\n const input = isSelectable ? (\n <Action selected={isSelected} onChange={onChange} id={item.id} singleChoice={singleChoice} />\n ) : undefined;\n return (\n <CheckableCardElement padding={16} borderRadius={12} Element=\"label\" checked={isSelected}>\n {renderItem({ input, item, isSearch, isXS: true, disabled: isDisabled })}\n </CheckableCardElement>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;AAmBa,MAAA,UAAU,GAAG,CAA8B,EACpD,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,GAAG,oBAAoB,GAChB,KAAkB;AACnC,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,GAAC,CAAA,oBAAoB,IAAC,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAC,OAAO,EAAC,OAAO,EAAE,UAAU,EAAA,QAAA,EACnF,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,EAAA,CACrD,EACzB;AACN;;;;"}
|
package/MobileItemsList.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import TreeCollection from './collection/treeCollection';
|
|
3
3
|
import { AdditionalDefault, IdCollectionPredicate, TreeModel } from './collection/types';
|
|
4
|
-
import { ListControls } from './types';
|
|
4
|
+
import { ListControls, RenderItem, RenderMobileDelimiter } from './types';
|
|
5
5
|
interface MobileItemsListProps<A extends AdditionalDefault> {
|
|
6
6
|
collection: TreeCollection<A>;
|
|
7
7
|
selected: string[];
|
|
@@ -14,6 +14,9 @@ interface MobileItemsListProps<A extends AdditionalDefault> {
|
|
|
14
14
|
setInputValue: (newValue: string) => void;
|
|
15
15
|
handleChangeInput: (newValue: string) => void;
|
|
16
16
|
contentFilterQuery: string;
|
|
17
|
+
renderItem?: RenderItem;
|
|
18
|
+
renderMobileDelimiter?: RenderMobileDelimiter;
|
|
19
|
+
trlSelectParent: ReactNode;
|
|
17
20
|
}
|
|
18
21
|
export declare const MobileItemsList: import("react").ForwardRefExoticComponent<MobileItemsListProps<AdditionalDefault> & import("react").RefAttributes<ListControls>>;
|
|
19
22
|
export {};
|
package/MobileItemsList.js
CHANGED
|
@@ -4,13 +4,16 @@ import { forwardRef, useRef, useState, useMemo, useEffect, useImperativeHandle }
|
|
|
4
4
|
import { Cell, CellText } from '@hh.ru/magritte-ui-cell';
|
|
5
5
|
import { CheckableCardElement } from '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
|
|
6
6
|
import { Action } from './Action.js';
|
|
7
|
+
import { MobileDelimiter } from './MobileDelimiter.js';
|
|
7
8
|
import { MobileItem } from './MobileItem.js';
|
|
8
9
|
import { MobileParentItem } from './MobileParentItem.js';
|
|
9
10
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
10
11
|
import '@hh.ru/magritte-ui-card';
|
|
12
|
+
import '@hh.ru/magritte-ui-typography';
|
|
13
|
+
import './TreeSelectorItemBase.js';
|
|
11
14
|
|
|
12
15
|
const MobileItemsListComponent = (props, ref) => {
|
|
13
|
-
const { collection, selected, disabled, leavesOnly, singleChoice, onChange, checkSelectable, getSearchItemOrder, setInputValue, handleChangeInput, contentFilterQuery, } = props;
|
|
16
|
+
const { collection, selected, disabled, leavesOnly, singleChoice, onChange, checkSelectable, getSearchItemOrder, setInputValue, handleChangeInput, renderMobileDelimiter, renderItem, contentFilterQuery, trlSelectParent, } = props;
|
|
14
17
|
const prevParentIds = useRef([]);
|
|
15
18
|
const prevQueries = useRef([]);
|
|
16
19
|
const currentQuery = useRef(contentFilterQuery);
|
|
@@ -20,14 +23,14 @@ const MobileItemsListComponent = (props, ref) => {
|
|
|
20
23
|
const { itemsByOrder, sortedOrders } = useMemo(() => {
|
|
21
24
|
const orders = new Set();
|
|
22
25
|
const itemsByOrder = items.reduce((acc, item) => {
|
|
23
|
-
const modelOrder = isSearch ? getSearchItemOrder(item) : 0;
|
|
26
|
+
const modelOrder = isSearch && !currentParentId ? getSearchItemOrder(item) : 0;
|
|
24
27
|
orders.add(modelOrder);
|
|
25
28
|
acc[modelOrder] = acc[modelOrder] || [];
|
|
26
29
|
acc[modelOrder].push(item);
|
|
27
30
|
return acc;
|
|
28
31
|
}, {});
|
|
29
32
|
return { itemsByOrder, sortedOrders: [...orders].sort((a, b) => a - b) };
|
|
30
|
-
}, [items, isSearch, getSearchItemOrder]);
|
|
33
|
+
}, [items, isSearch, currentParentId, getSearchItemOrder]);
|
|
31
34
|
const isSelectable = currentParentId && !leavesOnly && checkSelectable?.(currentParentId, collection);
|
|
32
35
|
useEffect(() => {
|
|
33
36
|
setCurrentParentId(undefined);
|
|
@@ -46,16 +49,25 @@ const MobileItemsListComponent = (props, ref) => {
|
|
|
46
49
|
}
|
|
47
50
|
},
|
|
48
51
|
}), [handleChangeInput, setInputValue]);
|
|
49
|
-
return (jsxs(Fragment, { children: [isSelectable && (jsx(CheckableCardElement, { padding: 16, borderRadius: 12, Element: "label", checked: selected.includes(currentParentId), children: jsx(Cell, { Element: 'div', disabled: disabled.includes(currentParentId), right: jsx(Action, { selected: selected.includes(currentParentId), onChange: onChange, id: currentParentId, singleChoice: singleChoice }), children: jsx(CellText, { children:
|
|
50
|
-
return itemsByOrder[order].map((item) => {
|
|
52
|
+
return (jsxs(Fragment, { children: [isSelectable && (jsx(CheckableCardElement, { padding: 16, borderRadius: 12, Element: "label", checked: selected.includes(currentParentId), children: jsx(Cell, { Element: 'div', disabled: disabled.includes(currentParentId), right: jsx(Action, { selected: selected.includes(currentParentId), onChange: onChange, id: currentParentId, singleChoice: singleChoice }), children: jsx(CellText, { children: trlSelectParent }) }) })), sortedOrders.map((order) => {
|
|
53
|
+
return itemsByOrder[order].map((item, index) => {
|
|
51
54
|
const hasChildren = collection.hasChildren(item.id);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const hasLetter = item.additional?.char && !isSearch;
|
|
56
|
+
const delimiterContent = renderMobileDelimiter?.({
|
|
57
|
+
item,
|
|
58
|
+
order,
|
|
59
|
+
isSearch,
|
|
60
|
+
index,
|
|
61
|
+
isFirstInOrder: index === 0,
|
|
62
|
+
isTopLevel: !currentParentId,
|
|
63
|
+
});
|
|
64
|
+
return (jsxs(Fragment, { children: [hasLetter && jsx(MobileDelimiter, { children: item.additional?.char }), delimiterContent && jsx(MobileDelimiter, { children: delimiterContent }), hasChildren ? (jsx(MobileParentItem, { collection: collection, item: item, selected: selected, onClick: () => {
|
|
65
|
+
prevParentIds.current.push(currentParentId);
|
|
66
|
+
prevQueries.current.push(currentQuery.current);
|
|
67
|
+
setCurrentParentId(item.id);
|
|
68
|
+
setInputValue('');
|
|
69
|
+
currentQuery.current = '';
|
|
70
|
+
}, isSearch: isSearch, renderItem: renderItem }, item.id)) : (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 }, item.id))] }));
|
|
59
71
|
});
|
|
60
72
|
})] }));
|
|
61
73
|
};
|
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} from 'react';\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 { MobileItem } from '@hh.ru/magritte-ui-tree-selector/MobileItem';\nimport { MobileParentItem } from '@hh.ru/magritte-ui-tree-selector/MobileParentItem';\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 { ListControls } from '@hh.ru/magritte-ui-tree-selector/types';\n\ninterface MobileItemsListProps<A extends AdditionalDefault> {\n collection: TreeCollection<A>;\n selected: string[];\n disabled: string[];\n leavesOnly?: boolean;\n singleChoice?: boolean;\n checkSelectable?: IdCollectionPredicate;\n onChange: (id: string, isSelected: boolean) => void;\n getSearchItemOrder: (model: TreeModel<A>) => number;\n setInputValue: (newValue: string) => void;\n handleChangeInput: (newValue: string) => void;\n contentFilterQuery: string;\n}\n\nconst MobileItemsListComponent = <A extends AdditionalDefault>(\n props: MobileItemsListProps<A>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n collection,\n selected,\n disabled,\n leavesOnly,\n singleChoice,\n onChange,\n checkSelectable,\n getSearchItemOrder,\n setInputValue,\n handleChangeInput,\n contentFilterQuery,\n } = props;\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 isSearch = !!contentFilterQuery;\n const items = useMemo(\n () => (currentParentId ? collection.getChildren(currentParentId) : collection.getTopLevel()),\n [currentParentId, collection]\n );\n const { itemsByOrder, sortedOrders } = useMemo(() => {\n const orders = new Set<number>();\n const itemsByOrder = items.reduce<Record<number, TreeModel<A>[]>>((acc, item) => {\n const modelOrder = isSearch ? getSearchItemOrder(item) : 0;\n orders.add(modelOrder);\n acc[modelOrder] = acc[modelOrder] || [];\n acc[modelOrder].push(item);\n return acc;\n }, {});\n return { itemsByOrder, sortedOrders: [...orders].sort((a, b) => a - b) };\n }, [items, isSearch, getSearchItemOrder]);\n\n const isSelectable = currentParentId && !leavesOnly && checkSelectable?.(currentParentId, collection);\n\n useEffect(() => {\n setCurrentParentId(undefined);\n prevParentIds.current = [];\n prevQueries.current = [];\n currentQuery.current = contentFilterQuery;\n }, [contentFilterQuery]);\n\n useImperativeHandle(\n ref,\n () => ({\n back: () => {\n setCurrentParentId(prevParentIds.current.pop());\n if (prevQueries.current.length) {\n setInputValue(prevQueries.current.pop() as string);\n } else {\n handleChangeInput('');\n }\n },\n }),\n [handleChangeInput, setInputValue]\n );\n\n return (\n <>\n {isSelectable && (\n <CheckableCardElement\n padding={16}\n borderRadius={12}\n Element=\"label\"\n checked={selected.includes(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>Выбрать все</CellText>\n </Cell>\n </CheckableCardElement>\n )}\n {sortedOrders.map((order) => {\n return itemsByOrder[order].map((item) => {\n const hasChildren = collection.hasChildren(item.id);\n\n return hasChildren ? (\n <MobileParentItem\n key={item.id}\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 }}\n />\n ) : (\n <MobileItem\n key={item.id}\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 />\n );\n });\n })}\n </>\n );\n};\n\nexport const MobileItemsList = forwardRef(MobileItemsListComponent);\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;AAkCA,MAAM,wBAAwB,GAAG,CAC7B,KAA8B,EAC9B,GAA+B,KACjB;IACd,MAAM,EACF,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,Y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QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EACtC,QAAQ,EAAE,QAAQ,EAAA,EANb,IAAI,CAAC,EAAE,CAOd,CACL,CAAC;AACN,iBAAC,CAAC,CAAC;aACN,CAAC,CACH,EAAA,CAAA,EACL;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 ReactNode,\n} from 'react';\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 TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, IdCollectionPredicate, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { ListControls, RenderItem, RenderMobileDelimiter } from '@hh.ru/magritte-ui-tree-selector/types';\n\ninterface MobileItemsListProps<A extends AdditionalDefault> {\n collection: TreeCollection<A>;\n selected: string[];\n disabled: string[];\n leavesOnly?: boolean;\n singleChoice?: boolean;\n checkSelectable?: IdCollectionPredicate;\n onChange: (id: string, isSelected: boolean) => void;\n getSearchItemOrder: (model: TreeModel<A>) => number;\n setInputValue: (newValue: string) => void;\n handleChangeInput: (newValue: string) => void;\n contentFilterQuery: string;\n renderItem?: RenderItem;\n renderMobileDelimiter?: RenderMobileDelimiter;\n trlSelectParent: ReactNode;\n}\n\nconst MobileItemsListComponent = <A extends AdditionalDefault>(\n props: MobileItemsListProps<A>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n collection,\n selected,\n disabled,\n leavesOnly,\n singleChoice,\n onChange,\n checkSelectable,\n getSearchItemOrder,\n setInputValue,\n handleChangeInput,\n renderMobileDelimiter,\n renderItem,\n contentFilterQuery,\n trlSelectParent,\n } = props;\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 isSearch = !!contentFilterQuery;\n const items = useMemo(\n () => (currentParentId ? collection.getChildren(currentParentId) : collection.getTopLevel()),\n [currentParentId, collection]\n );\n const { itemsByOrder, sortedOrders } = useMemo(() => {\n const orders = new Set<number>();\n const itemsByOrder = items.reduce<Record<number, TreeModel<A>[]>>((acc, item) => {\n const modelOrder = isSearch && !currentParentId ? getSearchItemOrder(item) : 0;\n orders.add(modelOrder);\n acc[modelOrder] = acc[modelOrder] || [];\n acc[modelOrder].push(item);\n return acc;\n }, {});\n return { itemsByOrder, sortedOrders: [...orders].sort((a, b) => a - b) };\n }, [items, isSearch, currentParentId, getSearchItemOrder]);\n\n const isSelectable = currentParentId && !leavesOnly && checkSelectable?.(currentParentId, collection);\n\n useEffect(() => {\n setCurrentParentId(undefined);\n prevParentIds.current = [];\n prevQueries.current = [];\n currentQuery.current = contentFilterQuery;\n }, [contentFilterQuery]);\n\n useImperativeHandle(\n ref,\n () => ({\n back: () => {\n setCurrentParentId(prevParentIds.current.pop());\n if (prevQueries.current.length) {\n setInputValue(prevQueries.current.pop() as string);\n } else {\n handleChangeInput('');\n }\n },\n }),\n [handleChangeInput, setInputValue]\n );\n return (\n <>\n {isSelectable && (\n <CheckableCardElement\n padding={16}\n borderRadius={12}\n Element=\"label\"\n checked={selected.includes(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>{trlSelectParent}</CellText>\n </Cell>\n </CheckableCardElement>\n )}\n {sortedOrders.map((order) => {\n return itemsByOrder[order].map((item, index) => {\n const hasChildren = collection.hasChildren(item.id);\n const hasLetter = item.additional?.char && !isSearch;\n const delimiterContent = renderMobileDelimiter?.({\n item,\n order,\n isSearch,\n index,\n isFirstInOrder: index === 0,\n isTopLevel: !currentParentId,\n });\n return (\n <>\n {hasLetter && <MobileDelimiter>{item.additional?.char}</MobileDelimiter>}\n {delimiterContent && <MobileDelimiter>{delimiterContent}</MobileDelimiter>}\n {hasChildren ? (\n <MobileParentItem\n key={item.id}\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 }}\n isSearch={isSearch}\n renderItem={renderItem}\n />\n ) : (\n <MobileItem\n key={item.id}\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 </>\n );\n });\n })}\n </>\n );\n};\n\nexport const MobileItemsList = forwardRef(MobileItemsListComponent);\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;;;;;AAuCA,MAAM,wBAAwB,GAAG,CAC7B,KAA8B,EAC9B,GAA+B,KACjB;AACd,IAAA,MAAM,EACF,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,eAAe,GAClB,GAAG,KAAK,CAAC;AACV,IAAA,MAAM,aAAa,GAAG,MAAM,CAAyB,EAAE,CAAC,CAAC;AACzD,IAAA,MAAM,WAAW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CAAC,OAAO,GAAG,EAAE,CAAC;AAC9B,iCAAC,EACD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EAZjB,EAAA,IAAI,CAAC,EAAE,CAad,KAEFA,GAAA,CAAC,UAAU,EAAA,EAEP,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,EAAA,EARjB,IAAI,CAAC,EAAE,CASd,CACL,CAAA,EAAA,CACF,EACL;AACN,iBAAC,CAAC,CAAC;aACN,CAAC,CACH,EAAA,CAAA,EACL;AACN,CAAC,CAAC;MAEW,eAAe,GAAG,UAAU,CAAC,wBAAwB;;;;"}
|
package/MobileParentItem.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import TreeCollection from './collection/treeCollection';
|
|
3
3
|
import { AdditionalDefault, TreeModel } from './collection/types';
|
|
4
|
+
import { RenderItem } from './types';
|
|
4
5
|
interface MobileParentItemProps<A extends AdditionalDefault> {
|
|
5
6
|
collection: TreeCollection<A>;
|
|
6
7
|
item: TreeModel<A>;
|
|
7
8
|
selected: string[];
|
|
8
9
|
onClick: () => void;
|
|
10
|
+
renderItem?: RenderItem;
|
|
11
|
+
isSearch: boolean;
|
|
9
12
|
}
|
|
10
|
-
export declare const MobileParentItem: <A extends AdditionalDefault>({ collection, item, selected, onClick, }: MobileParentItemProps<A>) => ReactElement;
|
|
13
|
+
export declare const MobileParentItem: <A extends AdditionalDefault>({ collection, item, selected, onClick, isSearch, renderItem, }: MobileParentItemProps<A>) => ReactElement;
|
|
11
14
|
export {};
|
package/MobileParentItem.js
CHANGED
|
@@ -2,9 +2,10 @@ import './index.css';
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { Card } from '@hh.ru/magritte-ui-card';
|
|
5
|
-
import {
|
|
5
|
+
import { LabelRight } from '@hh.ru/magritte-ui-cell';
|
|
6
|
+
import { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
|
|
6
7
|
|
|
7
|
-
const MobileParentItem = ({ collection, item, selected, onClick, }) => {
|
|
8
|
+
const MobileParentItem = ({ collection, item, selected, onClick, isSearch, renderItem = TreeSelectorItemBase, }) => {
|
|
8
9
|
const childrenSelectedCount = useMemo(() => {
|
|
9
10
|
let count = 0;
|
|
10
11
|
collection.walkChildren(item.id, (model) => {
|
|
@@ -14,7 +15,8 @@ const MobileParentItem = ({ collection, item, selected, onClick, }) => {
|
|
|
14
15
|
});
|
|
15
16
|
return count;
|
|
16
17
|
}, [collection, selected, item.id]);
|
|
17
|
-
|
|
18
|
+
const labelRight = jsx(LabelRight, { badge: childrenSelectedCount ? childrenSelectedCount.toString() : undefined });
|
|
19
|
+
return (jsx(Card, { padding: 16, borderRadius: 12, showBorder: true, actionCard: true, onClick: onClick, children: renderItem({ item, labelRight, childrenSelectedCount, isSearch, isXS: true, isParent: true }) }));
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
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 { Card } from '@hh.ru/magritte-ui-card';\nimport {
|
|
1
|
+
{"version":3,"file":"MobileParentItem.js","sources":["../src/MobileParentItem.tsx"],"sourcesContent":["import { ReactElement, useMemo } from 'react';\n\nimport { Card } from '@hh.ru/magritte-ui-card';\nimport { LabelRight } 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<A extends AdditionalDefault> {\n collection: TreeCollection<A>;\n item: TreeModel<A>;\n selected: string[];\n onClick: () => void;\n renderItem?: RenderItem;\n isSearch: boolean;\n}\n\nexport const MobileParentItem = <A extends AdditionalDefault>({\n collection,\n item,\n selected,\n onClick,\n isSearch,\n renderItem = TreeSelectorItemBase,\n}: MobileParentItemProps<A>): 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 = <LabelRight badge={childrenSelectedCount ? childrenSelectedCount.toString() : undefined} />;\n\n return (\n <Card padding={16} borderRadius={12} showBorder actionCard onClick={onClick}>\n {renderItem({ item, labelRight, childrenSelectedCount, isSearch, isXS: true, isParent: true })}\n </Card>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;MAkBa,gBAAgB,GAAG,CAA8B,EAC1D,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,UAAU,GAAG,oBAAoB,GACV,KAAkB;AACzC,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,GAAGA,GAAC,CAAA,UAAU,IAAC,KAAK,EAAE,qBAAqB,GAAG,qBAAqB,CAAC,QAAQ,EAAE,GAAG,SAAS,GAAI,CAAC;AAE/G,IAAA,QACIA,GAAC,CAAA,IAAI,IAAC,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,UAAU,EAAC,IAAA,EAAA,UAAU,QAAC,OAAO,EAAE,OAAO,EACtE,QAAA,EAAA,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAA,CAC3F,EACT;AACN;;;;"}
|
package/TreeSelector.js
CHANGED
|
@@ -11,17 +11,19 @@ import '@hh.ru/magritte-ui-spacing';
|
|
|
11
11
|
import './ItemsList.js';
|
|
12
12
|
import './Item.js';
|
|
13
13
|
import 'classnames';
|
|
14
|
-
import './ItemContent-
|
|
15
|
-
import '@hh.ru/magritte-ui-cell';
|
|
14
|
+
import './ItemContent-cec51c98.js';
|
|
16
15
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
17
16
|
import './Action.js';
|
|
18
17
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
18
|
+
import './TreeSelectorItemBase.js';
|
|
19
|
+
import '@hh.ru/magritte-ui-cell';
|
|
19
20
|
import '@hh.ru/magritte-ui-typography';
|
|
20
21
|
import './MobileItemsList.js';
|
|
21
22
|
import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
|
|
23
|
+
import './MobileDelimiter.js';
|
|
24
|
+
import '@hh.ru/magritte-ui-card';
|
|
22
25
|
import './MobileItem.js';
|
|
23
26
|
import './MobileParentItem.js';
|
|
24
|
-
import '@hh.ru/magritte-ui-card';
|
|
25
27
|
import './collection/treeCollectionHelper.js';
|
|
26
28
|
import './collection/treeCollection.js';
|
|
27
29
|
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 = <A extends AdditionalDefault>(\n props: TreeSelectorProps<A>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n value,\n collection,\n singleChoice,\n leavesOnly,\n collapseToParentId,\n checkSelectable,\n onChange,\n initialValue,\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 initialValue,\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
|
|
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 = <A extends AdditionalDefault>(\n props: TreeSelectorProps<A>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const {\n value,\n collection,\n singleChoice,\n leavesOnly,\n collapseToParentId,\n checkSelectable,\n onChange,\n initialValue,\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 initialValue,\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);\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,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import { useIndeterminate } from './useIndeterminate.js';
|
|
|
12
12
|
import { useRenderInput } from './useRenderInput.js';
|
|
13
13
|
import './Item.js';
|
|
14
14
|
import 'classnames';
|
|
15
|
-
import './ItemContent-
|
|
16
|
-
import '@hh.ru/magritte-ui-cell';
|
|
15
|
+
import './ItemContent-cec51c98.js';
|
|
17
16
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
18
17
|
import './Action.js';
|
|
19
18
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
19
|
+
import './TreeSelectorItemBase.js';
|
|
20
|
+
import '@hh.ru/magritte-ui-cell';
|
|
20
21
|
import '@hh.ru/magritte-ui-typography';
|
|
21
22
|
import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
|
|
23
|
+
import './MobileDelimiter.js';
|
|
24
|
+
import '@hh.ru/magritte-ui-card';
|
|
22
25
|
import './MobileItem.js';
|
|
23
26
|
import './MobileParentItem.js';
|
|
24
|
-
import '@hh.ru/magritte-ui-card';
|
|
25
27
|
import './collection/treeCollection.js';
|
|
26
28
|
import '@hh.ru/magritte-ui-input';
|
|
27
29
|
|
|
@@ -30,7 +32,7 @@ const defaultArray = [];
|
|
|
30
32
|
const needToApply = (query) => {
|
|
31
33
|
return !!(query && query.length);
|
|
32
34
|
};
|
|
33
|
-
const TreeSelectorDummy = forwardRef(({ collection: initialCollection, checkSelectable = defaultCheckSelectable, initialExpanded = defaultArray, value: selected, leavesOnly, singleChoice, expanded, disabled = defaultArray, treeFilter = filterWithParents, suggestedNotFound = defaultArray, constantlySuggested = defaultArray, onExpand, onChange, onChangeFilterQuery, children, }, ref) => {
|
|
35
|
+
const TreeSelectorDummy = forwardRef(({ collection: initialCollection, checkSelectable = defaultCheckSelectable, initialExpanded = defaultArray, value: selected, leavesOnly, singleChoice, expanded, disabled = defaultArray, treeFilter = filterWithParents, suggestedNotFound = defaultArray, constantlySuggested = defaultArray, renderItemForDesktop, renderItem, renderMobileDelimiter, onExpand, onChange, onChangeFilterQuery, trls, children, }, ref) => {
|
|
34
36
|
const [collection, setCollection] = useState(initialCollection);
|
|
35
37
|
const currentQuery = useRef('');
|
|
36
38
|
const suggestedNotFoundModels = useRef(initialCollection.getExistModels(suggestedNotFound));
|
|
@@ -102,7 +104,7 @@ const TreeSelectorDummy = forwardRef(({ collection: initialCollection, checkSele
|
|
|
102
104
|
onChangeFilterQuery,
|
|
103
105
|
]);
|
|
104
106
|
const renderTreeSelector = useCallback(() => {
|
|
105
|
-
return (jsx(VSpacingContainer, { default: 12, gteM: 0, children: isMobile ? (jsx(MobileItemsList, { getSearchItemOrder: (model) => initialCollection.getModelLevel(model.id), collection: collection, selected: selected, disabled: disabled, onChange: onChange, leavesOnly: leavesOnly, checkSelectable: checkSelectable, singleChoice: singleChoice, ref: ref, setInputValue: setInputValue, handleChangeInput: handleChangeInput, contentFilterQuery: contentFilterQuery.trim() })) : (jsx(ItemsList, { collection: collection, items: collection.getTopLevel(), leavesOnly: leavesOnly, checkSelectable: checkSelectable, expanded: currentExpanded, onExpansion: handleExpansion, selected: selected, onChange: onChange, disabled: disabled, singleChoice: singleChoice, indeterminate: indeterminate })) }));
|
|
107
|
+
return (jsx(VSpacingContainer, { default: 12, gteM: 0, children: isMobile ? (jsx(MobileItemsList, { getSearchItemOrder: (model) => initialCollection.getModelLevel(model.id), 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(), trlSelectParent: trls.selectAllParent })) : (jsx(ItemsList, { collection: collection, items: collection.getTopLevel(), leavesOnly: leavesOnly, checkSelectable: checkSelectable, expanded: currentExpanded, onExpansion: handleExpansion, selected: selected, onChange: onChange, disabled: disabled, singleChoice: singleChoice, indeterminate: indeterminate, isSearch: !!contentFilterQuery.trim(), renderItemForDesktop: renderItemForDesktop })) }));
|
|
106
108
|
}, [
|
|
107
109
|
isMobile,
|
|
108
110
|
collection,
|
|
@@ -119,6 +121,10 @@ const TreeSelectorDummy = forwardRef(({ collection: initialCollection, checkSele
|
|
|
119
121
|
currentExpanded,
|
|
120
122
|
handleExpansion,
|
|
121
123
|
indeterminate,
|
|
124
|
+
renderItemForDesktop,
|
|
125
|
+
renderItem,
|
|
126
|
+
renderMobileDelimiter,
|
|
127
|
+
trls.selectAllParent,
|
|
122
128
|
initialCollection,
|
|
123
129
|
]);
|
|
124
130
|
return jsx(Fragment, { children: children({ renderTreeSelector, renderInput }) });
|
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 } from 'react';\n\nimport { match } from '@hh.ru/magritte-common-fuzzy-search';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { VSpacingContainer } from '@hh.ru/magritte-ui-spacing';\nimport { ItemsList } from '@hh.ru/magritte-ui-tree-selector/ItemsList';\nimport { MobileItemsList } from '@hh.ru/magritte-ui-tree-selector/MobileItemsList';\nimport { filterWithParents } from '@hh.ru/magritte-ui-tree-selector/collection/treeCollectionHelper';\nimport { AdditionalDefault } 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 TreeSelectorDummy = forwardRef(\n <A extends AdditionalDefault>(\n {\n collection: initialCollection,\n checkSelectable = defaultCheckSelectable,\n initialExpanded = defaultArray,\n value: selected,\n leavesOnly,\n singleChoice,\n expanded,\n disabled = defaultArray,\n treeFilter = filterWithParents,\n suggestedNotFound = defaultArray,\n constantlySuggested = defaultArray,\n onExpand,\n onChange,\n onChangeFilterQuery,\n children,\n }: TreeSelectorDummyProps<A>,\n ref: ForwardedRef<ListControls>\n ): ReactElement => {\n const [collection, setCollection] = useState(initialCollection);\n const currentQuery = useRef('');\n const suggestedNotFoundModels = useRef(initialCollection.getExistModels(suggestedNotFound));\n const constantlySuggestedModels = useRef(initialCollection.getExistModels(constantlySuggested));\n\n const { indeterminate } = useIndeterminate({ collection: initialCollection, selected });\n const {\n expanded: currentExpanded,\n setExpanded,\n handleExpansion,\n } = useExpanded({\n initialValue: expanded ? expanded.slice() : initialExpanded.slice(),\n controlledExpanded: expanded,\n onExpand,\n });\n const { isMobile } = useBreakpoint();\n\n const { contentFilterQuery, setInputValue, handleChangeInput, renderInput } = useRenderInput();\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 } 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 setExpanded(newExpanded);\n }\n }, [\n initialCollection,\n contentFilterQuery,\n treeFilter,\n selected,\n initialExpanded,\n setExpanded,\n isMobile,\n onChangeFilterQuery,\n ]);\n\n const renderTreeSelector = useCallback(() => {\n return (\n <VSpacingContainer default={12} gteM={0}>\n {isMobile ? (\n <MobileItemsList\n getSearchItemOrder={(model) => initialCollection.getModelLevel(model.id)}\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 handleChangeInput={handleChangeInput}\n contentFilterQuery={contentFilterQuery.trim()}\n />\n ) : (\n <ItemsList\n collection={collection}\n items={collection.getTopLevel()}\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 />\n )}\n </VSpacingContainer>\n );\n }, [\n isMobile,\n collection,\n selected,\n disabled,\n onChange,\n leavesOnly,\n checkSelectable,\n singleChoice,\n ref,\n setInputValue,\n handleChangeInput,\n contentFilterQuery,\n currentExpanded,\n handleExpansion,\n indeterminate,\n initialCollection,\n ]);\n\n return <>{children({ renderTreeSelector, renderInput })}</>;\n }\n);\n\nTreeSelectorDummy.displayName = 'TreeSelectorDummy';\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;AAEW,MAAA,iBAAiB,GAAG,UAAU,CACvC,CACI,EACI,UAAU,EAAE,iBAAiB,EAC7B,eAAe,GAAG,sBAAsB,EACxC,eAAe,GAAG,YAAY,EAC9B,KAAK,EAAE,QAAQ,EACf,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,GAAG,YAAY,EACvB,UAAU,GAAG,iBAAiB,EAC9B,iBAAiB,GAAG,YAAY,EAChC,mBAAmB,GAAG,YAAY,EAClC,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,QAAQ,GACgB,EAC5B,GAA+B,KACjB;IACd,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAChE,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAChC,MAAM,uBAAuB,GAAG,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC5F,MAAM,yBAAyB,GAAG,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAEhG,IAAA,MAAM,EAAE,aAAa,EAAE,GAAG,gBAAgB,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC,CAAC;IACxF,MAAM,EACF,QAAQ,EAAE,eAAe,EACzB,WAAW,EACX,eAAe,GAClB,G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BAAkB;QAClB,eAAe;QACf,eAAe;QACf,aAAa;QACb,iBAAiB;AACpB,KAAA,CAAC,CAAC;IAEH,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,CAAC,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAC,EAAA,CAAI,CAAC;AAChE,CAAC,EACH;AAEF,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;;;"}
|
|
1
|
+
{"version":3,"file":"TreeSelectorDummy.js","sources":["../src/TreeSelectorDummy.tsx"],"sourcesContent":["import { ReactElement, forwardRef, ForwardedRef, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { match } from '@hh.ru/magritte-common-fuzzy-search';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { VSpacingContainer } from '@hh.ru/magritte-ui-spacing';\nimport { ItemsList } from '@hh.ru/magritte-ui-tree-selector/ItemsList';\nimport { MobileItemsList } from '@hh.ru/magritte-ui-tree-selector/MobileItemsList';\nimport { filterWithParents } from '@hh.ru/magritte-ui-tree-selector/collection/treeCollectionHelper';\nimport { AdditionalDefault } 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 TreeSelectorDummy = forwardRef(\n <A extends AdditionalDefault>(\n {\n collection: initialCollection,\n checkSelectable = defaultCheckSelectable,\n initialExpanded = defaultArray,\n value: selected,\n leavesOnly,\n singleChoice,\n expanded,\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 trls,\n children,\n }: TreeSelectorDummyProps<A>,\n ref: ForwardedRef<ListControls>\n ): ReactElement => {\n const [collection, setCollection] = useState(initialCollection);\n const currentQuery = useRef('');\n const suggestedNotFoundModels = useRef(initialCollection.getExistModels(suggestedNotFound));\n const constantlySuggestedModels = useRef(initialCollection.getExistModels(constantlySuggested));\n\n const { indeterminate } = useIndeterminate({ collection: initialCollection, selected });\n const {\n expanded: currentExpanded,\n setExpanded,\n handleExpansion,\n } = useExpanded({\n initialValue: expanded ? expanded.slice() : initialExpanded.slice(),\n controlledExpanded: expanded,\n onExpand,\n });\n const { isMobile } = useBreakpoint();\n\n const { contentFilterQuery, setInputValue, handleChangeInput, renderInput } = useRenderInput();\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 } 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 setExpanded(newExpanded);\n }\n }, [\n initialCollection,\n contentFilterQuery,\n treeFilter,\n selected,\n initialExpanded,\n setExpanded,\n isMobile,\n onChangeFilterQuery,\n ]);\n\n const renderTreeSelector = useCallback(() => {\n return (\n <VSpacingContainer default={12} gteM={0}>\n {isMobile ? (\n <MobileItemsList\n getSearchItemOrder={(model) => initialCollection.getModelLevel(model.id)}\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 trlSelectParent={trls.selectAllParent}\n />\n ) : (\n <ItemsList\n collection={collection}\n items={collection.getTopLevel()}\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={!!contentFilterQuery.trim()}\n renderItemForDesktop={renderItemForDesktop}\n />\n )}\n </VSpacingContainer>\n );\n }, [\n isMobile,\n collection,\n selected,\n disabled,\n onChange,\n leavesOnly,\n checkSelectable,\n singleChoice,\n ref,\n setInputValue,\n handleChangeInput,\n contentFilterQuery,\n currentExpanded,\n handleExpansion,\n indeterminate,\n renderItemForDesktop,\n renderItem,\n renderMobileDelimiter,\n trls.selectAllParent,\n initialCollection,\n ]);\n\n return <>{children({ renderTreeSelector, renderInput })}</>;\n }\n);\n\nTreeSelectorDummy.displayName = 'TreeSelectorDummy';\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,iBAAiB,GAAG,UAAU,CACvC,CACI,EACI,UAAU,EAAE,iBAAiB,EAC7B,eAAe,GAAG,sBAAsB,EACxC,eAAe,GAAG,YAAY,EAC9B,KAAK,EAAE,QAAQ,EACf,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,GAAG,YAAY,EACvB,UAAU,GAAG,iBAAiB,EAC9B,iBAAiB,GAAG,YAAY,EAChC,mBAAmB,GAAG,YAAY,EAClC,oBAAoB,EACpB,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,IAAI,EACJ,QAAQ,GACgB,EAC5B,GAA+B,KACjB;IACd,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAChE,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAChC,MAAM,uBAAuB,GAAG,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC5F,MAAM,yBAAyB,GAAG,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAEhG,IAAA,MAAM,EAAE,aAAa,EAAE,GAAG,gBAAgB,CAAC,E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a,EAAE,aAAa,EAC5B,QAAQ,EAAE,CAAC,CAAC,kBAAkB,CAAC,IAAI,EAAE,EACrC,oBAAoB,EAAE,oBAAoB,GAC5C,CACL,EAAA,CACe,EACtB;AACN,KAAC,EAAE;QACC,QAAQ;QACR,UAAU;QACV,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,UAAU;QACV,eAAe;QACf,YAAY;QACZ,GAAG;QACH,aAAa;QACb,iBAAiB;QACjB,kBAAkB;QAClB,eAAe;QACf,eAAe;QACf,aAAa;QACb,oBAAoB;QACpB,UAAU;QACV,qBAAqB;AACrB,QAAA,IAAI,CAAC,eAAe;QACpB,iBAAiB;AACpB,KAAA,CAAC,CAAC;IAEH,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,CAAC,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAC,EAAA,CAAI,CAAC;AAChE,CAAC,EACH;AAEF,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { AdditionalDefault } from './collection/types';
|
|
3
|
+
import { RenderItemProps } from './types';
|
|
4
|
+
export declare const TreeSelectorItemBase: <A extends AdditionalDefault>({ disabled, input, item, isXS, labelRight, }: RenderItemProps<A>) => ReactElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './index.css';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Cell, CellText } from '@hh.ru/magritte-ui-cell';
|
|
4
|
+
|
|
5
|
+
const TreeSelectorItemBase = ({ disabled, input, item, isXS, labelRight, }) => {
|
|
6
|
+
const cellProps = {
|
|
7
|
+
[isXS ? 'right' : 'left']: input,
|
|
8
|
+
...(isXS && labelRight && { right: labelRight }),
|
|
9
|
+
};
|
|
10
|
+
return (jsx(Cell, { disabled: disabled, ...cellProps, children: jsx(CellText, { children: item.text }) }));
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { TreeSelectorItemBase };
|
|
14
|
+
//# sourceMappingURL=TreeSelectorItemBase.js.map
|
|
@@ -0,0 +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 = <A extends AdditionalDefault>({\n disabled,\n input,\n item,\n isXS,\n labelRight,\n}: RenderItemProps<A>): ReactElement => {\n const cellProps = {\n [isXS ? 'right' : 'left']: input,\n ...(isXS && labelRight && { right: labelRight }),\n };\n return (\n <Cell disabled={disabled} {...cellProps}>\n <CellText>{item.text}</CellText>\n </Cell>\n );\n};\n"],"names":["_jsx"],"mappings":";;;AAMa,MAAA,oBAAoB,GAAG,CAA8B,EAC9D,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,UAAU,GACO,KAAkB;AACnC,IAAA,MAAM,SAAS,GAAG;QACd,CAAC,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK;QAChC,IAAI,IAAI,IAAI,UAAU,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;KACnD,CAAC;AACF,IAAA,QACIA,GAAC,CAAA,IAAI,IAAC,QAAQ,EAAE,QAAQ,EAAM,GAAA,SAAS,YACnCA,GAAC,CAAA,QAAQ,cAAE,IAAI,CAAC,IAAI,EAAY,CAAA,EAAA,CAC7B,EACT;AACN;;;;"}
|
package/index.css
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
.magritte-wrapper___GHKV6_1-
|
|
1
|
+
.magritte-wrapper___GHKV6_1-5-1{
|
|
2
2
|
display:flex;
|
|
3
3
|
padding:12px 0;
|
|
4
4
|
gap:12px;
|
|
5
|
-
align-items:
|
|
5
|
+
align-items:flex-start;
|
|
6
6
|
}
|
|
7
|
-
.magritte-letter___yZOCU_1-
|
|
7
|
+
.magritte-letter___yZOCU_1-5-1{
|
|
8
8
|
width:24px;
|
|
9
|
+
height:24px;
|
|
10
|
+
display:flex;
|
|
11
|
+
align-items:center;
|
|
12
|
+
justify-content:center;
|
|
9
13
|
flex-shrink:0;
|
|
10
|
-
text-align:center;
|
|
11
14
|
}
|
|
12
|
-
.magritte-icon___kO3Fj_1-
|
|
13
|
-
.magritte-space___xTO79_1-
|
|
15
|
+
.magritte-icon___kO3Fj_1-5-1,
|
|
16
|
+
.magritte-space___xTO79_1-5-1{
|
|
14
17
|
flex-shrink:0;
|
|
15
18
|
line-height:0;
|
|
16
19
|
width:24px;
|
|
17
20
|
}
|
|
18
|
-
.magritte-iconActive___4yrG5_1-
|
|
21
|
+
.magritte-iconActive___4yrG5_1-5-1{
|
|
19
22
|
cursor:pointer;
|
|
20
23
|
}
|
|
21
|
-
.magritte-content___ZRc6R_1-
|
|
24
|
+
.magritte-content___ZRc6R_1-5-1{
|
|
22
25
|
flex-grow:1;
|
|
23
26
|
}
|
|
24
|
-
.magritte-with-shift___ZErxZ_1-
|
|
27
|
+
.magritte-with-shift___ZErxZ_1-5-1{
|
|
25
28
|
margin-left:-36px;
|
|
26
29
|
}
|
|
27
|
-
.magritte-with-indent___MH9Vy_1-
|
|
30
|
+
.magritte-with-indent___MH9Vy_1-5-1{
|
|
28
31
|
margin-left:36px;
|
|
29
32
|
}
|
|
30
|
-
.magritte-item___2LtOL_1-
|
|
33
|
+
.magritte-item___2LtOL_1-5-1 > .magritte-children___kq-eq_1-5-1{
|
|
31
34
|
padding-left:36px;
|
|
32
35
|
}
|
|
33
|
-
.magritte-item___2LtOL_1-
|
|
36
|
+
.magritte-item___2LtOL_1-5-1.magritte-with-two-boxes___LWOy2_1-5-1 > .magritte-children___kq-eq_1-5-1{
|
|
34
37
|
padding-left:72px;
|
|
35
38
|
}
|
|
36
|
-
.magritte-item___2LtOL_1-
|
|
39
|
+
.magritte-item___2LtOL_1-5-1.magritte-with-three-boxes___cyVao_1-5-1 > .magritte-children___kq-eq_1-5-1{
|
|
37
40
|
padding-left:108px;
|
|
38
41
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './index.css';
|
|
2
2
|
export { TreeSelector } from './TreeSelector.js';
|
|
3
3
|
export { TreeSelectorDummy } from './TreeSelectorDummy.js';
|
|
4
|
+
export { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
|
|
4
5
|
import 'react/jsx-runtime';
|
|
5
6
|
import 'react';
|
|
6
7
|
import './strategy/immutableSelectionStrategy.js';
|
|
@@ -18,17 +19,18 @@ import '@hh.ru/magritte-ui-spacing';
|
|
|
18
19
|
import './ItemsList.js';
|
|
19
20
|
import './Item.js';
|
|
20
21
|
import 'classnames';
|
|
21
|
-
import './ItemContent-
|
|
22
|
-
import '@hh.ru/magritte-ui-cell';
|
|
22
|
+
import './ItemContent-cec51c98.js';
|
|
23
23
|
import '@hh.ru/magritte-ui-icon/icon';
|
|
24
24
|
import './Action.js';
|
|
25
25
|
import '@hh.ru/magritte-ui-checkbox-radio';
|
|
26
26
|
import '@hh.ru/magritte-ui-typography';
|
|
27
27
|
import './MobileItemsList.js';
|
|
28
|
+
import '@hh.ru/magritte-ui-cell';
|
|
28
29
|
import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
|
|
30
|
+
import './MobileDelimiter.js';
|
|
31
|
+
import '@hh.ru/magritte-ui-card';
|
|
29
32
|
import './MobileItem.js';
|
|
30
33
|
import './MobileParentItem.js';
|
|
31
|
-
import '@hh.ru/magritte-ui-card';
|
|
32
34
|
import './useExpanded.js';
|
|
33
35
|
import './useIndeterminate.js';
|
|
34
36
|
import './useRenderInput.js';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hh.ru/magritte-ui-tree-selector",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@hh.ru/magritte-common-fuzzy-search": "1.0.4",
|
|
23
23
|
"@hh.ru/magritte-ui-breakpoint": "4.0.2",
|
|
24
|
-
"@hh.ru/magritte-ui-card": "6.0.
|
|
25
|
-
"@hh.ru/magritte-ui-cell": "3.0.
|
|
26
|
-
"@hh.ru/magritte-ui-checkable-card": "3.0.
|
|
24
|
+
"@hh.ru/magritte-ui-card": "6.0.8",
|
|
25
|
+
"@hh.ru/magritte-ui-cell": "3.0.1",
|
|
26
|
+
"@hh.ru/magritte-ui-checkable-card": "3.0.11",
|
|
27
27
|
"@hh.ru/magritte-ui-checkbox-radio": "3.0.4",
|
|
28
28
|
"@hh.ru/magritte-ui-icon": "7.1.8",
|
|
29
|
-
"@hh.ru/magritte-ui-input": "5.0.
|
|
29
|
+
"@hh.ru/magritte-ui-input": "5.0.23",
|
|
30
30
|
"@hh.ru/magritte-ui-mock-component": "1.0.10",
|
|
31
31
|
"@hh.ru/magritte-ui-spacing": "2.0.24",
|
|
32
32
|
"@hh.ru/magritte-ui-theme-provider": "1.1.24",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "4480faadc19af08673481a84a62f77d081e9be2e"
|
|
43
43
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import TreeCollection from './collection/treeCollection';
|
|
3
|
-
import { AdditionalDefault, IdCollectionPredicate, TreeFilter } from './collection/types';
|
|
3
|
+
import { AdditionalDefault, IdCollectionPredicate, TreeFilter, TreeModel } from './collection/types';
|
|
4
4
|
interface ChildrenProps {
|
|
5
5
|
renderTreeSelector: () => ReactElement;
|
|
6
6
|
renderInput: () => ReactElement;
|
|
@@ -8,6 +8,30 @@ interface ChildrenProps {
|
|
|
8
8
|
interface Children {
|
|
9
9
|
(props: ChildrenProps): ReactNode;
|
|
10
10
|
}
|
|
11
|
+
export interface RenderItemProps<A extends AdditionalDefault> {
|
|
12
|
+
item: TreeModel<A>;
|
|
13
|
+
isSearch: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
input?: ReactElement;
|
|
16
|
+
isXS?: boolean;
|
|
17
|
+
isParent?: boolean;
|
|
18
|
+
labelRight?: ReactElement;
|
|
19
|
+
childrenSelectedCount?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface RenderItem {
|
|
22
|
+
<A extends AdditionalDefault>(props: RenderItemProps<A>): ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export interface RenderMobileDelimiterProps<A extends AdditionalDefault> {
|
|
25
|
+
item: TreeModel<A>;
|
|
26
|
+
order: number;
|
|
27
|
+
isSearch: boolean;
|
|
28
|
+
index: number;
|
|
29
|
+
isFirstInOrder: boolean;
|
|
30
|
+
isTopLevel: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface RenderMobileDelimiter {
|
|
33
|
+
<A extends AdditionalDefault>(props: RenderMobileDelimiterProps<A>): ReactNode;
|
|
34
|
+
}
|
|
11
35
|
export interface BaseTreeSelectorProps<A extends AdditionalDefault> {
|
|
12
36
|
collection: TreeCollection<A>;
|
|
13
37
|
singleChoice?: boolean;
|
|
@@ -23,6 +47,12 @@ export interface BaseTreeSelectorProps<A extends AdditionalDefault> {
|
|
|
23
47
|
suggestedNotFound?: string[];
|
|
24
48
|
constantlySuggested?: string[];
|
|
25
49
|
onChangeFilterQuery?: (ids: string[], query: string) => void;
|
|
50
|
+
renderItemForDesktop?: RenderItem;
|
|
51
|
+
renderItem?: RenderItem;
|
|
52
|
+
renderMobileDelimiter?: RenderMobileDelimiter;
|
|
53
|
+
trls: {
|
|
54
|
+
selectAllParent: ReactNode;
|
|
55
|
+
};
|
|
26
56
|
}
|
|
27
57
|
export interface DummyProps {
|
|
28
58
|
value: string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ItemContent-d63a26ba.js","sources":["../src/ItemContent.tsx"],"sourcesContent":["import { ReactElement, useCallback } from 'react';\nimport classnames from 'classnames';\n\nimport { Cell, CellText } from '@hh.ru/magritte-ui-cell';\nimport { ChevronDownOutlinedSize24, ChevronUpOutlinedSize24, DotFilledSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { Action } from '@hh.ru/magritte-ui-tree-selector/Action';\nimport { AdditionalDefault, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './tree-selector-item.less';\n\ninterface ItemContent<A extends AdditionalDefault> {\n item: TreeModel<A>;\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}\n\nconst ItemContent = <A extends AdditionalDefault>({\n item,\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}: ItemContent<A>): 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 return (\n <div className={styles.wrapper}>\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, {\n [styles.iconActive]: hasChildren,\n })}\n onClick={handleExpandableClick}\n >\n {isExpanded && <ChevronDownOutlinedSize24 initial=\"tertiary\" />}\n {!isExpanded && <ChevronUpOutlinedSize24 initial=\"tertiary\" />}\n </div>\n )}\n\n <Cell\n disabled={isDisabled}\n left={\n hasAction ? (\n <Action\n selected={isSelected}\n onChange={onChange}\n id={item.id}\n indeterminate={isIndeterminate}\n singleChoice={singleChoice}\n />\n ) : undefined\n }\n >\n <CellText>{item.text}</CellText>\n </Cell>\n </div>\n );\n};\n\nexport { ItemContent };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AA4BA,MAAM,WAAW,GAAG,CAA8B,EAC9C,IAAI,EACJ,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,GACL,KAAkB;IAC/B,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,WAA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