@hh.ru/magritte-ui-tree-selector 1.3.2 → 1.4.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.
Files changed (47) hide show
  1. package/Item.d.ts +2 -1
  2. package/Item.js +3 -3
  3. package/Item.js.map +1 -1
  4. package/ItemContent-d63a26ba.js +22 -0
  5. package/ItemContent-d63a26ba.js.map +1 -0
  6. package/ItemContent.d.ts +5 -4
  7. package/ItemContent.js +1 -1
  8. package/ItemsList.d.ts +1 -0
  9. package/ItemsList.js +3 -3
  10. package/ItemsList.js.map +1 -1
  11. package/MobileItem.d.ts +2 -1
  12. package/MobileItem.js +2 -2
  13. package/MobileItem.js.map +1 -1
  14. package/MobileItemsList.d.ts +1 -0
  15. package/MobileItemsList.js +3 -3
  16. package/MobileItemsList.js.map +1 -1
  17. package/MobileParentItem.js +1 -1
  18. package/MobileParentItem.js.map +1 -1
  19. package/TreeSelector.d.ts +2 -2
  20. package/TreeSelector.js +41 -108
  21. package/TreeSelector.js.map +1 -1
  22. package/TreeSelectorDummy.d.ts +4 -0
  23. package/TreeSelectorDummy.js +129 -0
  24. package/TreeSelectorDummy.js.map +1 -0
  25. package/collection/treeCollectionHelper.d.ts +6 -0
  26. package/collection/treeCollectionHelper.js +16 -1
  27. package/collection/treeCollectionHelper.js.map +1 -1
  28. package/index.css +11 -11
  29. package/index.d.ts +1 -1
  30. package/index.js +11 -10
  31. package/index.js.map +1 -1
  32. package/package.json +11 -11
  33. package/types.d.ts +17 -7
  34. package/useDisabled.d.ts +13 -0
  35. package/useDisabled.js +20 -0
  36. package/useDisabled.js.map +1 -0
  37. package/useExpanded.d.ts +2 -2
  38. package/useExpanded.js +1 -1
  39. package/useExpanded.js.map +1 -1
  40. package/useSelected.d.ts +6 -1
  41. package/useSelected.js +39 -8
  42. package/useSelected.js.map +1 -1
  43. package/ItemContent-1be2cb46.js +0 -22
  44. package/ItemContent-1be2cb46.js.map +0 -1
  45. package/UncontrolledTreeSelector.d.ts +0 -7
  46. package/UncontrolledTreeSelector.js +0 -49
  47. package/UncontrolledTreeSelector.js.map +0 -1
@@ -1,22 +0,0 @@
1
- import './index.css';
2
- import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { useCallback } from 'react';
4
- import classnames from 'classnames';
5
- import { Cell, CellText } from '@hh.ru/magritte-ui-cell';
6
- import { DotFilledSize24, ChevronDownOutlinedSize24, ChevronUpOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';
7
- import { Action } from './Action.js';
8
- import { Text } from '@hh.ru/magritte-ui-typography';
9
-
10
- var styles = {"wrapper":"magritte-wrapper___GHKV6_1-3-2","letter":"magritte-letter___yZOCU_1-3-2","icon":"magritte-icon___kO3Fj_1-3-2","space":"magritte-space___xTO79_1-3-2","iconActive":"magritte-iconActive___4yrG5_1-3-2","content":"magritte-content___ZRc6R_1-3-2","with-shift":"magritte-with-shift___ZErxZ_1-3-2","withShift":"magritte-with-shift___ZErxZ_1-3-2","with-indent":"magritte-with-indent___MH9Vy_1-3-2","withIndent":"magritte-with-indent___MH9Vy_1-3-2","item":"magritte-item___2LtOL_1-3-2","children":"magritte-children___kq-eq_1-3-2","with-two-boxes":"magritte-with-two-boxes___LWOy2_1-3-2","withTwoBoxes":"magritte-with-two-boxes___LWOy2_1-3-2","with-three-boxes":"magritte-with-three-boxes___cyVao_1-3-2","withThreeBoxes":"magritte-with-three-boxes___cyVao_1-3-2"};
11
-
12
- const ItemContent = ({ item, hasAction, hasChildren, letter, expanded, onExpansion, hasLetterOnLevel, selected, onChange, indeterminate, singleChoice, hasDot, maxControlsOnLevel, }) => {
13
- const handleExpandableClick = useCallback(() => onExpansion && onExpansion(item.id), [item.id, onExpansion]);
14
- const currentActionCount = +hasDot + +hasAction + +hasChildren;
15
- const neededSpacesCount = maxControlsOnLevel - currentActionCount;
16
- 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
- [styles.iconActive]: hasChildren,
18
- }), onClick: handleExpandableClick, children: [expanded && jsx(ChevronDownOutlinedSize24, { initial: "tertiary" }), !expanded && jsx(ChevronUpOutlinedSize24, { initial: "tertiary" })] })), jsx(Cell, { left: hasAction ? (jsx(Action, { selected: selected, onChange: onChange, id: item.id, indeterminate: indeterminate, singleChoice: singleChoice })) : undefined, children: jsx(CellText, { children: item.text }) })] }));
19
- };
20
-
21
- export { ItemContent as I, styles as s };
22
- //# sourceMappingURL=ItemContent-1be2cb46.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ItemContent-1be2cb46.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 expanded?: boolean;\n selected: boolean;\n onChange: (id: string, isSelected: boolean) => void;\n indeterminate: 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 expanded,\n onExpansion,\n hasLetterOnLevel,\n selected,\n onChange,\n indeterminate,\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 {expanded && <ChevronDownOutlinedSize24 initial=\"tertiary\" />}\n {!expanded && <ChevronUpOutlinedSize24 initial=\"tertiary\" />}\n </div>\n )}\n\n <Cell\n left={\n hasAction ? (\n <Action\n selected={selected}\n onChange={onChange}\n id={item.id}\n indeterminate={indeterminate}\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":";;;;;;;;;;AA2BA,MAAM,WAAW,GAAG,CAA8B,EAC9C,IAAI,EACJ,SAAS,EACT,WAAW,EACX,MAAM,EACN,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,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,WA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A,GAAC,CAAA,uBAAuB,IAAC,OAAO,EAAC,UAAU,EAAA,CAAG,IAC1D,CACT,EAEDA,GAAC,CAAA,IAAI,IACD,IAAI,EACA,SAAS,IACLA,GAAA,CAAC,MAAM,EAAA,EACH,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,GAC5B,IACF,SAAS,EAGjB,QAAA,EAAAA,GAAA,CAAC,QAAQ,EAAA,EAAA,QAAA,EAAE,IAAI,CAAC,IAAI,GAAY,EAC7B,CAAA,CAAA,EAAA,CACL,EACR;AACN;;;;"}
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { AdditionalDefault } from './collection/types';
3
- import { ListControls } from './types';
4
- export declare const UncontrolledTreeSelector: import("react").ForwardRefExoticComponent<import("./types").TreeSelectorProps<AdditionalDefault> & {
5
- value?: string[] | undefined;
6
- onChange?: ((id: string, isSelected: boolean, allSelected: string[]) => void) | undefined;
7
- } & import("react").RefAttributes<ListControls>>;
@@ -1,49 +0,0 @@
1
- import './index.css';
2
- import { jsx } from 'react/jsx-runtime';
3
- import { forwardRef, useMemo } from 'react';
4
- import { TreeSelector } from './TreeSelector.js';
5
- import ImmutableSelectionStrategy from './strategy/immutableSelectionStrategy.js';
6
- import { useSelected } from './useSelected.js';
7
- import '@hh.ru/magritte-common-fuzzy-search';
8
- import '@hh.ru/magritte-ui-breakpoint';
9
- import '@hh.ru/magritte-ui-spacing';
10
- import './ItemsList.js';
11
- import './Item.js';
12
- import 'classnames';
13
- import './ItemContent-1be2cb46.js';
14
- import '@hh.ru/magritte-ui-cell';
15
- import '@hh.ru/magritte-ui-icon/icon';
16
- import './Action.js';
17
- import '@hh.ru/magritte-ui-checkbox-radio';
18
- import '@hh.ru/magritte-ui-typography';
19
- import './MobileItemsList.js';
20
- import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
21
- import './MobileItem.js';
22
- import './MobileParentItem.js';
23
- import '@hh.ru/magritte-ui-card';
24
- import './collection/treeCollectionHelper.js';
25
- import './collection/treeCollection.js';
26
- import './useExpanded.js';
27
- import './useIndeterminate.js';
28
- import './useRenderInput.js';
29
- import '@hh.ru/magritte-ui-input';
30
- import './strategy/selectionStrategy.js';
31
- import './strategy/createSingleValueToggler.js';
32
- import './strategy/createTreeCollectionToggler.js';
33
- import './strategy/dummyToggle.js';
34
-
35
- const defaultArray = [];
36
- const UncontrolledTreeSelectorComponent = (props, ref) => {
37
- const { value = defaultArray, collection, singleChoice, leavesOnly, checkSelectable, onChange } = props;
38
- const strategy = useMemo(() => new ImmutableSelectionStrategy(collection, {
39
- singleChoice,
40
- leavesOnly,
41
- checkSelectable,
42
- }), [collection, singleChoice, leavesOnly, checkSelectable]);
43
- const { selected, setSelected } = useSelected({ value, strategy, onChange });
44
- return jsx(TreeSelector, { ...props, value: selected, onChange: setSelected, ref: ref });
45
- };
46
- const UncontrolledTreeSelector = forwardRef(UncontrolledTreeSelectorComponent);
47
-
48
- export { UncontrolledTreeSelector };
49
- //# sourceMappingURL=UncontrolledTreeSelector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UncontrolledTreeSelector.js","sources":["../src/UncontrolledTreeSelector.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef, ReactElement, useMemo } from 'react';\n\nimport { TreeSelector } from '@hh.ru/magritte-ui-tree-selector/TreeSelector';\nimport { AdditionalDefault } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport ImmutableSelectionStrategy from '@hh.ru/magritte-ui-tree-selector/strategy/immutableSelectionStrategy';\nimport { UncontrolledTreeSelectorProps, ListControls } from '@hh.ru/magritte-ui-tree-selector/types';\nimport { useSelected } from '@hh.ru/magritte-ui-tree-selector/useSelected';\n\nconst defaultArray: string[] = [];\nconst UncontrolledTreeSelectorComponent = <A extends AdditionalDefault>(\n props: UncontrolledTreeSelectorProps<A>,\n ref: ForwardedRef<ListControls>\n): ReactElement => {\n const { value = defaultArray, collection, singleChoice, leavesOnly, checkSelectable, onChange } = 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 const { selected, setSelected } = useSelected({ value, strategy, onChange });\n return <TreeSelector {...props} value={selected} onChange={setSelected} ref={ref}></TreeSelector>;\n};\n\nexport const UncontrolledTreeSelector = forwardRef(UncontrolledTreeSelectorComponent);\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,YAAY,GAAa,EAAE,CAAC;AAClC,MAAM,iCAAiC,GAAG,CACtC,KAAuC,EACvC,GAA+B,KACjB;AACd,IAAA,MAAM,EAAE,KAAK,GAAG,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACxG,MAAM,QAAQ,GAAG,OAAO,CACpB,MACI,IAAI,0BAA0B,CAAC,UAAU,EAAE;QACvC,YAAY;QACZ,UAAU;QACV,eAAe;KAClB,CAAC,EACN,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,CAAC,CAC1D,CAAC;AAEF,IAAA,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC7E,IAAA,OAAOA,IAAC,YAAY,EAAA,EAAA,GAAK,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,GAAiB,CAAC;AACtG,CAAC,CAAC;MAEW,wBAAwB,GAAG,UAAU,CAAC,iCAAiC;;;;"}