@hh.ru/magritte-ui-tree-selector 4.3.9 → 4.3.11

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.js CHANGED
@@ -10,7 +10,7 @@ import '@hh.ru/magritte-ui-checkbox-radio';
10
10
  import './TreeSelectorItemBase.js';
11
11
  import '@hh.ru/magritte-ui-cell';
12
12
  import '@hh.ru/magritte-ui-typography';
13
- import './tree-selector-item-Dm-nL2-C.js';
13
+ import './tree-selector-item-QSj9hgV0.js';
14
14
 
15
15
  const ONE_BOX_MARGIN = 36;
16
16
  const getMargin = (allBoxesCount, hasShift, hasIndent) => {
@@ -60,6 +60,7 @@ const ItemComponent = ({ collection, item, parentId, isExpanded, isSelected, isI
60
60
  const hasIndent = allBoxesCount === 0;
61
61
  useMemo(() => {
62
62
  cache[item.id] = getMargin(allBoxesCount, !!hasShift, hasIndent) + (parentId ? cache[parentId] : 0);
63
+ // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps
63
64
  }, [item.id, parentId]);
64
65
  let margin = parentId ? cache[parentId] : 0;
65
66
  margin = margin + (hasShift ? -ONE_BOX_MARGIN : 0) + (hasIndent ? ONE_BOX_MARGIN : 0);
package/Item.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Item.js","sources":["../src/Item.tsx"],"sourcesContent":["import { PropsWithChildren, ReactElement, useMemo, memo } from 'react';\nimport classnames from 'classnames';\n\nimport { ItemContent } from '@hh.ru/magritte-ui-tree-selector/ItemContent';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, IdCollectionPredicate, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\nconst ONE_BOX_MARGIN = 36;\n\nconst getMargin = (allBoxesCount: number, hasShift: boolean, hasIndent: boolean): number => {\n let margin = 0;\n if (allBoxesCount === 2) {\n margin = ONE_BOX_MARGIN * 2;\n } else if (allBoxesCount === 3) {\n margin = ONE_BOX_MARGIN * 3;\n } else {\n margin = ONE_BOX_MARGIN;\n }\n if (hasIndent) {\n return margin + ONE_BOX_MARGIN;\n }\n\n if (hasShift) {\n return margin - ONE_BOX_MARGIN;\n }\n\n return margin;\n};\n\ninterface ItemProps<Additional extends AdditionalDefault> extends PropsWithChildren {\n collection: TreeCollection<Additional>;\n parentId?: TreeModel<Additional>['id'];\n item: TreeModel<Additional>;\n leavesOnly?: boolean;\n checkSelectable?: IdCollectionPredicate;\n isExpanded: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n singleChoice?: boolean;\n isIndeterminate: boolean;\n isSearch: boolean;\n onExpansion: (id: string) => void;\n onChange: (id: string, isSelected: boolean) => void;\n renderItemForDesktop?: RenderItem<Additional>;\n cache: Record<string, number>;\n}\n\nconst ItemComponent = <Additional extends AdditionalDefault>({\n collection,\n item,\n parentId,\n isExpanded,\n isSelected,\n isIndeterminate,\n isDisabled,\n leavesOnly,\n singleChoice,\n isSearch,\n checkSelectable,\n onExpansion,\n onChange,\n renderItemForDesktop,\n cache,\n children,\n}: ItemProps<Additional>): ReactElement => {\n const modelsOnLevel = useMemo(\n () => (parentId ? collection.getChildren(parentId) : collection.getTopLevel()),\n [parentId, collection]\n );\n\n const hasLetterOnLevel = useMemo(() => {\n return !isSearch && modelsOnLevel.some((model) => model.additional?.char);\n }, [modelsOnLevel, isSearch]);\n\n // максимальное кол-во контролов на уровне, максимум может быть 2 - шеврон + чекбокс/радио\n const maxControlsOnLevel = useMemo(() => {\n return modelsOnLevel.reduce((currentMax, model) => {\n const hasChildren = collection.hasChildren(model.id);\n const hasAction = !(leavesOnly && hasChildren) && checkSelectable?.(model.id, collection);\n const actionCount = +hasChildren + +!!hasAction;\n return Math.max(currentMax, actionCount);\n }, 0);\n }, [modelsOnLevel, checkSelectable, leavesOnly, collection]);\n\n const hasChildren = collection.hasChildren(item.id);\n const hasAction = !(leavesOnly && hasChildren) && checkSelectable?.(item.id, collection);\n const hasLetter = item.additional?.char && !isSearch;\n const realControlsCount = +hasChildren + +!!hasAction;\n\n // точка заменяет недостающий контрол, если их суммарное кол-во на уровне больше суммарного значения на текущем уровне\n const hasDot = realControlsCount < maxControlsOnLevel && (hasAction || hasChildren);\n const hasParentAction = parentId ? !leavesOnly && checkSelectable?.(parentId, collection) : false;\n\n const allBoxesCount = +hasLetterOnLevel + maxControlsOnLevel;\n\n const hasShift =\n allBoxesCount > 1 &&\n parentId &&\n ((hasParentAction && (hasLetterOnLevel || hasChildren || hasDot)) || (!hasParentAction && hasLetterOnLevel));\n\n const hasIndent = allBoxesCount === 0;\n\n useMemo(() => {\n cache[item.id] = getMargin(allBoxesCount, !!hasShift, hasIndent) + (parentId ? cache[parentId] : 0);\n }, [item.id, parentId]);\n\n let margin = parentId ? cache[parentId] : 0;\n\n margin = margin + (hasShift ? -ONE_BOX_MARGIN : 0) + (hasIndent ? ONE_BOX_MARGIN : 0);\n\n return (\n <div\n style={{ paddingLeft: margin }}\n data-qa={classnames('tree-selector-item', `tree-selector-item-${item.id}`, {\n 'tree-selector-item-expanded': isExpanded,\n [`tree-selector-child-${parentId}`]: parentId,\n })}\n >\n <ItemContent\n item={item}\n parentId={parentId}\n hasChildren={hasChildren}\n hasAction={!!hasAction}\n letter={hasLetter ? item.additional?.char : undefined}\n isExpanded={isExpanded}\n onExpansion={onExpansion}\n isSelected={isSelected}\n onChange={onChange}\n singleChoice={singleChoice}\n isIndeterminate={isIndeterminate}\n isDisabled={isDisabled}\n hasLetterOnLevel={hasLetterOnLevel}\n hasDot={hasDot}\n maxControlsOnLevel={maxControlsOnLevel}\n isSearch={isSearch}\n renderItemForDesktop={renderItemForDesktop}\n />\n\n {children}\n </div>\n );\n};\n\nexport const Item = memo(ItemComponent) as <Additional extends AdditionalDefault>(\n props: ItemProps<Additional>\n) => ReactElement;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;AAQA,MAAM,cAAc,GAAG,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B,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,EAED,QAAQ,CAAA,EAAA,CACP,EACR;AACN,CAAC,CAAC;MAEW,IAAI,GAAG,IAAI,CAAC,aAAa;;;;"}
1
+ {"version":3,"file":"Item.js","sources":["../src/Item.tsx"],"sourcesContent":["import { PropsWithChildren, ReactElement, useMemo, memo } from 'react';\nimport classnames from 'classnames';\n\nimport { ItemContent } from '@hh.ru/magritte-ui-tree-selector/ItemContent';\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault, IdCollectionPredicate, TreeModel } from '@hh.ru/magritte-ui-tree-selector/collection/types';\nimport { RenderItem } from '@hh.ru/magritte-ui-tree-selector/types';\n\nconst ONE_BOX_MARGIN = 36;\n\nconst getMargin = (allBoxesCount: number, hasShift: boolean, hasIndent: boolean): number => {\n let margin = 0;\n if (allBoxesCount === 2) {\n margin = ONE_BOX_MARGIN * 2;\n } else if (allBoxesCount === 3) {\n margin = ONE_BOX_MARGIN * 3;\n } else {\n margin = ONE_BOX_MARGIN;\n }\n if (hasIndent) {\n return margin + ONE_BOX_MARGIN;\n }\n\n if (hasShift) {\n return margin - ONE_BOX_MARGIN;\n }\n\n return margin;\n};\n\ninterface ItemProps<Additional extends AdditionalDefault> extends PropsWithChildren {\n collection: TreeCollection<Additional>;\n parentId?: TreeModel<Additional>['id'];\n item: TreeModel<Additional>;\n leavesOnly?: boolean;\n checkSelectable?: IdCollectionPredicate;\n isExpanded: boolean;\n isSelected: boolean;\n isDisabled: boolean;\n singleChoice?: boolean;\n isIndeterminate: boolean;\n isSearch: boolean;\n onExpansion: (id: string) => void;\n onChange: (id: string, isSelected: boolean) => void;\n renderItemForDesktop?: RenderItem<Additional>;\n cache: Record<string, number>;\n}\n\nconst ItemComponent = <Additional extends AdditionalDefault>({\n collection,\n item,\n parentId,\n isExpanded,\n isSelected,\n isIndeterminate,\n isDisabled,\n leavesOnly,\n singleChoice,\n isSearch,\n checkSelectable,\n onExpansion,\n onChange,\n renderItemForDesktop,\n cache,\n children,\n}: ItemProps<Additional>): ReactElement => {\n const modelsOnLevel = useMemo(\n () => (parentId ? collection.getChildren(parentId) : collection.getTopLevel()),\n [parentId, collection]\n );\n\n const hasLetterOnLevel = useMemo(() => {\n return !isSearch && modelsOnLevel.some((model) => model.additional?.char);\n }, [modelsOnLevel, isSearch]);\n\n // максимальное кол-во контролов на уровне, максимум может быть 2 - шеврон + чекбокс/радио\n const maxControlsOnLevel = useMemo(() => {\n return modelsOnLevel.reduce((currentMax, model) => {\n const hasChildren = collection.hasChildren(model.id);\n const hasAction = !(leavesOnly && hasChildren) && checkSelectable?.(model.id, collection);\n const actionCount = +hasChildren + +!!hasAction;\n return Math.max(currentMax, actionCount);\n }, 0);\n }, [modelsOnLevel, checkSelectable, leavesOnly, collection]);\n\n const hasChildren = collection.hasChildren(item.id);\n const hasAction = !(leavesOnly && hasChildren) && checkSelectable?.(item.id, collection);\n const hasLetter = item.additional?.char && !isSearch;\n const realControlsCount = +hasChildren + +!!hasAction;\n\n // точка заменяет недостающий контрол, если их суммарное кол-во на уровне больше суммарного значения на текущем уровне\n const hasDot = realControlsCount < maxControlsOnLevel && (hasAction || hasChildren);\n const hasParentAction = parentId ? !leavesOnly && checkSelectable?.(parentId, collection) : false;\n\n const allBoxesCount = +hasLetterOnLevel + maxControlsOnLevel;\n\n const hasShift =\n allBoxesCount > 1 &&\n parentId &&\n ((hasParentAction && (hasLetterOnLevel || hasChildren || hasDot)) || (!hasParentAction && hasLetterOnLevel));\n\n const hasIndent = allBoxesCount === 0;\n\n useMemo(() => {\n cache[item.id] = getMargin(allBoxesCount, !!hasShift, hasIndent) + (parentId ? cache[parentId] : 0);\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n }, [item.id, parentId]);\n\n let margin = parentId ? cache[parentId] : 0;\n\n margin = margin + (hasShift ? -ONE_BOX_MARGIN : 0) + (hasIndent ? ONE_BOX_MARGIN : 0);\n\n return (\n <div\n style={{ paddingLeft: margin }}\n data-qa={classnames('tree-selector-item', `tree-selector-item-${item.id}`, {\n 'tree-selector-item-expanded': isExpanded,\n [`tree-selector-child-${parentId}`]: parentId,\n })}\n >\n <ItemContent\n item={item}\n parentId={parentId}\n hasChildren={hasChildren}\n hasAction={!!hasAction}\n letter={hasLetter ? item.additional?.char : undefined}\n isExpanded={isExpanded}\n onExpansion={onExpansion}\n isSelected={isSelected}\n onChange={onChange}\n singleChoice={singleChoice}\n isIndeterminate={isIndeterminate}\n isDisabled={isDisabled}\n hasLetterOnLevel={hasLetterOnLevel}\n hasDot={hasDot}\n maxControlsOnLevel={maxControlsOnLevel}\n isSearch={isSearch}\n renderItemForDesktop={renderItemForDesktop}\n />\n\n {children}\n </div>\n );\n};\n\nexport const Item = memo(ItemComponent) as <Additional extends AdditionalDefault>(\n props: ItemProps<Additional>\n) => ReactElement;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;AAQA,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,SAAS,GAAG,CAAC,aAAqB,EAAE,QAAiB,EAAE,SAAkB,KAAY;IACvF,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,aAAa,KAAK,CAAC,EAAE;AACrB,QAAA,MAAM,GAAG,cAAc,GAAG,CAAC,CAAC;AAC/B,KAAA;SAAM,IAAI,aAAa,KAAK,CAAC,EAAE;AAC5B,QAAA,MAAM,GAAG,cAAc,GAAG,CAAC,CAAC;AAC/B,KAAA;AAAM,SAAA;QACH,MAAM,GAAG,cAAc,CAAC;AAC3B,KAAA;AACD,IAAA,IAAI,SAAS,EAAE;QACX,OAAO,MAAM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'@hh.ru/magritte-ui-
7
7
  import { Action } from './Action.js';
8
8
  import { TreeSelectorItemBase } from './TreeSelectorItemBase.js';
9
9
  import { Text } from '@hh.ru/magritte-ui-typography';
10
- import { s as styles } from './tree-selector-item-Dm-nL2-C.js';
10
+ import { s as styles } from './tree-selector-item-QSj9hgV0.js';
11
11
  import '@hh.ru/magritte-ui-checkbox-radio';
12
12
  import '@hh.ru/magritte-ui-cell';
13
13
 
package/ItemsList.js CHANGED
@@ -3,7 +3,7 @@ import { jsx } from 'react/jsx-runtime';
3
3
  import { useRef, useMemo, useCallback, useEffect } from 'react';
4
4
  import { useVirtualizer } from '@tanstack/react-virtual';
5
5
  import { Item } from './Item.js';
6
- import { s as styles } from './tree-selector-item-Dm-nL2-C.js';
6
+ import { s as styles } from './tree-selector-item-QSj9hgV0.js';
7
7
  import 'classnames';
8
8
  import './ItemContent.js';
9
9
  import '@hh.ru/magritte-common-keyboard';
@@ -9,7 +9,7 @@ import { Action } from './Action.js';
9
9
  import { MobileDelimiter } from './MobileDelimiter.js';
10
10
  import { MobileItem } from './MobileItem.js';
11
11
  import { MobileParentItem } from './MobileParentItem.js';
12
- import { s as styles } from './tree-selector-item-Dm-nL2-C.js';
12
+ import { s as styles } from './tree-selector-item-QSj9hgV0.js';
13
13
  import '@hh.ru/magritte-ui-checkbox-radio';
14
14
  import '@hh.ru/magritte-ui-card';
15
15
  import '@hh.ru/magritte-ui-typography';
package/TreeSelector.js CHANGED
@@ -19,7 +19,7 @@ import '@hh.ru/magritte-ui-checkbox-radio';
19
19
  import './TreeSelectorItemBase.js';
20
20
  import '@hh.ru/magritte-ui-cell';
21
21
  import '@hh.ru/magritte-ui-typography';
22
- import './tree-selector-item-Dm-nL2-C.js';
22
+ import './tree-selector-item-QSj9hgV0.js';
23
23
  import './MobileItemsList.js';
24
24
  import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
25
25
  import './MobileDelimiter.js';
@@ -21,7 +21,7 @@ import '@hh.ru/magritte-ui-checkbox-radio';
21
21
  import './TreeSelectorItemBase.js';
22
22
  import '@hh.ru/magritte-ui-cell';
23
23
  import '@hh.ru/magritte-ui-typography';
24
- import './tree-selector-item-Dm-nL2-C.js';
24
+ import './tree-selector-item-QSj9hgV0.js';
25
25
  import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
26
26
  import './MobileDelimiter.js';
27
27
  import '@hh.ru/magritte-ui-card';
package/index.css CHANGED
@@ -4,7 +4,7 @@
4
4
  --magritte-semantic-animation-ease-in-out-200-timing-function-v19-0-0:cubic-bezier(0.25, 0.1, 0.25, 1);
5
5
  --magritte-semantic-animation-ease-in-out-200-duration-v19-0-0:200ms;
6
6
  }
7
- @keyframes magritte-fade-in___yS4Ja_4-3-9{
7
+ @keyframes magritte-fade-in___yS4Ja_4-3-11{
8
8
  0%{
9
9
  opacity:0;
10
10
  }
@@ -12,24 +12,24 @@
12
12
  opacity:1;
13
13
  }
14
14
  }
15
- .magritte-item-animation-timeout___pbOyZ_4-3-9{
16
- animation-name:magritte-fade-in___yS4Ja_4-3-9;
15
+ .magritte-item-animation-timeout___pbOyZ_4-3-11{
16
+ animation-name:magritte-fade-in___yS4Ja_4-3-11;
17
17
  animation-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v19-0-0);
18
18
  --animation-duration:0ms;
19
19
  animation-duration:var(--animation-duration);
20
20
  }
21
21
  @media (prefers-reduced-motion: no-preference){
22
- .magritte-item-animation-timeout___pbOyZ_4-3-9{
22
+ .magritte-item-animation-timeout___pbOyZ_4-3-11{
23
23
  --animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-0-0);
24
24
  }
25
25
  }
26
- .magritte-wrapper___GHKV6_4-3-9{
26
+ .magritte-wrapper___GHKV6_4-3-11{
27
27
  display:flex;
28
28
  padding:12px 0;
29
29
  gap:12px;
30
30
  align-items:flex-start;
31
31
  }
32
- .magritte-letter___yZOCU_4-3-9{
32
+ .magritte-letter___yZOCU_4-3-11{
33
33
  width:24px;
34
34
  height:24px;
35
35
  display:flex;
@@ -37,59 +37,59 @@
37
37
  justify-content:center;
38
38
  flex-shrink:0;
39
39
  }
40
- .magritte-icon___kO3Fj_4-3-9,
41
- .magritte-space___xTO79_4-3-9{
40
+ .magritte-icon___kO3Fj_4-3-11,
41
+ .magritte-space___xTO79_4-3-11{
42
42
  flex-shrink:0;
43
43
  line-height:0;
44
44
  width:24px;
45
45
  }
46
- .magritte-icon___kO3Fj_4-3-9{
46
+ .magritte-icon___kO3Fj_4-3-11{
47
47
  transform:rotate(0);
48
48
  }
49
- .magritte-wrapperActive___Hwk8p_4-3-9,
50
- .magritte-iconActive___4yrG5_4-3-9{
49
+ .magritte-wrapperActive___Hwk8p_4-3-11,
50
+ .magritte-iconActive___4yrG5_4-3-11{
51
51
  cursor:pointer;
52
52
  }
53
- .magritte-iconUp___mpXV6_4-3-9{
53
+ .magritte-iconUp___mpXV6_4-3-11{
54
54
  transform:rotate(90deg);
55
55
  }
56
56
  @media (prefers-reduced-motion: no-preference){
57
- .magritte-icon___kO3Fj_4-3-9{
57
+ .magritte-icon___kO3Fj_4-3-11{
58
58
  transition-property:transform;
59
59
  transition-duration:var(--magritte-semantic-animation-ease-in-out-100-duration-v19-0-0);
60
60
  transition-timing-function:var(--magritte-semantic-animation-ease-in-out-100-timing-function-v19-0-0);
61
61
  }
62
62
  }
63
- .magritte-content___ZRc6R_4-3-9{
63
+ .magritte-content___ZRc6R_4-3-11{
64
64
  flex-grow:1;
65
65
  }
66
- .magritte-mobile-item___ynALC_4-3-9{
66
+ .magritte-mobile-item___ynALC_4-3-11{
67
67
  display:flex;
68
68
  gap:12px;
69
69
  flex-wrap:wrap;
70
70
  }
71
- .magritte-with-gap___gbvGO_4-3-9{
71
+ .magritte-with-gap___gbvGO_4-3-11{
72
72
  padding-top:12px;
73
73
  }
74
- .magritte-virtualized-list___qt2E6_4-3-9{
74
+ .magritte-virtualized-list___qt2E6_4-3-11{
75
75
  width:100%;
76
76
  position:relative;
77
77
  will-change:transform;
78
78
  }
79
- .magritte-virtualized-item___qAYVN_4-3-9{
79
+ .magritte-virtualized-item___qAYVN_4-3-11{
80
80
  position:absolute;
81
81
  top:0;
82
82
  left:0;
83
83
  width:100%;
84
84
  }
85
- .magritte-was-expanded___uCFbW_4-3-9{
86
- animation-name:magritte-fade-in___yS4Ja_4-3-9;
85
+ .magritte-was-expanded___uCFbW_4-3-11{
86
+ animation-name:magritte-fade-in___yS4Ja_4-3-11;
87
87
  animation-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v19-0-0);
88
88
  --animation-duration:0ms;
89
89
  animation-duration:var(--animation-duration);
90
90
  }
91
91
  @media (prefers-reduced-motion: no-preference){
92
- .magritte-was-expanded___uCFbW_4-3-9{
92
+ .magritte-was-expanded___uCFbW_4-3-11{
93
93
  --animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-0-0);
94
94
  }
95
95
  }
@@ -98,7 +98,7 @@
98
98
  --magritte-semantic-animation-ease-in-out-200-timing-function-v19-0-0:cubic-bezier(0.25, 0.1, 0.25, 1);
99
99
  --magritte-semantic-animation-ease-in-out-200-duration-v19-0-0:200ms;
100
100
  }
101
- @keyframes magritte-fade-in___FDoho_4-3-9{
101
+ @keyframes magritte-fade-in___FDoho_4-3-11{
102
102
  0%{
103
103
  opacity:0;
104
104
  }
@@ -106,14 +106,14 @@
106
106
  opacity:1;
107
107
  }
108
108
  }
109
- .magritte-item-animation-timeout___Pdli9_4-3-9{
110
- animation-name:magritte-fade-in___FDoho_4-3-9;
109
+ .magritte-item-animation-timeout___Pdli9_4-3-11{
110
+ animation-name:magritte-fade-in___FDoho_4-3-11;
111
111
  animation-timing-function:var(--magritte-semantic-animation-ease-in-out-200-timing-function-v19-0-0);
112
112
  --animation-duration:0ms;
113
113
  animation-duration:var(--animation-duration);
114
114
  }
115
115
  @media (prefers-reduced-motion: no-preference){
116
- .magritte-item-animation-timeout___Pdli9_4-3-9{
116
+ .magritte-item-animation-timeout___Pdli9_4-3-11{
117
117
  --animation-duration:var(--magritte-semantic-animation-ease-in-out-200-duration-v19-0-0);
118
118
  }
119
119
  }
package/index.js CHANGED
@@ -27,7 +27,7 @@ import '@hh.ru/magritte-ui-icon/icon';
27
27
  import './Action.js';
28
28
  import '@hh.ru/magritte-ui-checkbox-radio';
29
29
  import '@hh.ru/magritte-ui-typography';
30
- import './tree-selector-item-Dm-nL2-C.js';
30
+ import './tree-selector-item-QSj9hgV0.js';
31
31
  import './MobileItemsList.js';
32
32
  import '@hh.ru/magritte-ui-cell';
33
33
  import '@hh.ru/magritte-ui-checkable-card/CheckableCardElement';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hh.ru/magritte-ui-tree-selector",
3
- "version": "4.3.9",
3
+ "version": "4.3.11",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "sideEffects": [
@@ -28,14 +28,14 @@
28
28
  "@hh.ru/magritte-design-tokens": "19.0.0",
29
29
  "@hh.ru/magritte-internal-custom-scroll": "1.2.1",
30
30
  "@hh.ru/magritte-types": "4.0.2",
31
- "@hh.ru/magritte-ui-badge": "2.2.5",
31
+ "@hh.ru/magritte-ui-badge": "2.2.6",
32
32
  "@hh.ru/magritte-ui-breakpoint": "4.0.3",
33
- "@hh.ru/magritte-ui-card": "6.1.4",
34
- "@hh.ru/magritte-ui-cell": "4.0.7",
35
- "@hh.ru/magritte-ui-checkable-card": "3.0.31",
33
+ "@hh.ru/magritte-ui-card": "6.1.5",
34
+ "@hh.ru/magritte-ui-cell": "4.0.8",
35
+ "@hh.ru/magritte-ui-checkable-card": "3.0.33",
36
36
  "@hh.ru/magritte-ui-checkbox-radio": "3.0.16",
37
37
  "@hh.ru/magritte-ui-icon": "7.5.3",
38
- "@hh.ru/magritte-ui-input": "6.0.7",
38
+ "@hh.ru/magritte-ui-input": "6.0.8",
39
39
  "@hh.ru/magritte-ui-mock-component": "1.0.11",
40
40
  "@hh.ru/magritte-ui-spacing": "2.0.28",
41
41
  "@hh.ru/magritte-ui-theme-provider": "1.1.28",
@@ -50,5 +50,5 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "eef119f2d2c4f53cbe93f0f1e8f580b3a4019a70"
53
+ "gitHead": "c123b6295872225b61347997a1db5218776dc1c5"
54
54
  }
@@ -0,0 +1,5 @@
1
+ import './index.css';
2
+ var styles = {"item-animation-timeout":"magritte-item-animation-timeout___pbOyZ_4-3-11","itemAnimationTimeout":"magritte-item-animation-timeout___pbOyZ_4-3-11","fade-in":"magritte-fade-in___yS4Ja_4-3-11","fadeIn":"magritte-fade-in___yS4Ja_4-3-11","wrapper":"magritte-wrapper___GHKV6_4-3-11","letter":"magritte-letter___yZOCU_4-3-11","icon":"magritte-icon___kO3Fj_4-3-11","space":"magritte-space___xTO79_4-3-11","wrapperActive":"magritte-wrapperActive___Hwk8p_4-3-11","iconActive":"magritte-iconActive___4yrG5_4-3-11","iconUp":"magritte-iconUp___mpXV6_4-3-11","content":"magritte-content___ZRc6R_4-3-11","mobile-item":"magritte-mobile-item___ynALC_4-3-11","mobileItem":"magritte-mobile-item___ynALC_4-3-11","with-gap":"magritte-with-gap___gbvGO_4-3-11","withGap":"magritte-with-gap___gbvGO_4-3-11","virtualized-list":"magritte-virtualized-list___qt2E6_4-3-11","virtualizedList":"magritte-virtualized-list___qt2E6_4-3-11","virtualized-item":"magritte-virtualized-item___qAYVN_4-3-11","virtualizedItem":"magritte-virtualized-item___qAYVN_4-3-11","was-expanded":"magritte-was-expanded___uCFbW_4-3-11","wasExpanded":"magritte-was-expanded___uCFbW_4-3-11"};
3
+
4
+ export { styles as s };
5
+ //# sourceMappingURL=tree-selector-item-QSj9hgV0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-selector-item-QSj9hgV0.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,7 +1,7 @@
1
1
  import './index.css';
2
2
  import { useState, useLayoutEffect } from 'react';
3
3
 
4
- var styles = {"item-animation-timeout":"magritte-item-animation-timeout___Pdli9_4-3-9","itemAnimationTimeout":"magritte-item-animation-timeout___Pdli9_4-3-9","fade-in":"magritte-fade-in___FDoho_4-3-9","fadeIn":"magritte-fade-in___FDoho_4-3-9"};
4
+ var styles = {"item-animation-timeout":"magritte-item-animation-timeout___Pdli9_4-3-11","itemAnimationTimeout":"magritte-item-animation-timeout___Pdli9_4-3-11","fade-in":"magritte-fade-in___FDoho_4-3-11","fadeIn":"magritte-fade-in___FDoho_4-3-11"};
5
5
 
6
6
  const useAnimationTimeout = () => {
7
7
  const [animationTimeout, setAnimationTimeout] = useState(0);
package/useExpanded.js CHANGED
@@ -22,7 +22,7 @@ const calculateInitialExpanded = (initialExpanded, selected, expandTreeOnSelecte
22
22
  };
23
23
  const useExpanded = ({ initialValue, selected, expandTreeOnSelected, collection, onExpand, }) => {
24
24
  const calculatedInitialValue = useMemo(() => calculateInitialExpanded(initialValue, selected, expandTreeOnSelected, collection),
25
- // eslint-disable-next-line react-hooks/exhaustive-deps
25
+ // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps
26
26
  []);
27
27
  const [expanded, setExpanded] = useState(calculatedInitialValue);
28
28
  const expandedRef = useRef(calculatedInitialValue);
@@ -51,7 +51,7 @@ const useExpanded = ({ initialValue, selected, expandTreeOnSelected, collection,
51
51
  if (!areEqualArrays(expandedRef.current, calculatedResetValue)) {
52
52
  setExpanded(calculatedResetValue);
53
53
  }
54
- // eslint-disable-next-line react-hooks/exhaustive-deps
54
+ // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps
55
55
  }, []);
56
56
  useEffect(() => {
57
57
  handlerRef.current = onExpand;
@@ -1 +1 @@
1
- {"version":3,"file":"useExpanded.js","sources":["../src/useExpanded.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, useMemo } from 'react';\n\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault } from '@hh.ru/magritte-ui-tree-selector/collection/types';\n\nexport const areEqualArrays = (arr1: string[], arr2: string[]): boolean => {\n if (arr1.length !== arr2.length) {\n return false;\n }\n const sortArr2 = arr2.slice().sort();\n return arr1\n .slice()\n .sort()\n .every((item, index) => item === sortArr2[index]);\n};\n\nexport const calculateInitialExpanded = <Additional extends AdditionalDefault>(\n initialExpanded: string[],\n selected: string[],\n expandTreeOnSelected: boolean,\n collection: TreeCollection<Additional>\n): string[] => {\n let expanded: string[] = initialExpanded.slice();\n if (expandTreeOnSelected) {\n expanded = selected.reduce<string[]>((acc, id) => {\n return acc.concat(collection.getParentIds(id));\n }, expanded);\n }\n return [...new Set(expanded)];\n};\n\ninterface UseExpandedHookProps<Additional extends AdditionalDefault> {\n initialValue: string[];\n onExpand?: (expanded: string[]) => void;\n expandTreeOnSelected: boolean;\n selected: string[];\n collection: TreeCollection<Additional>;\n}\n\ninterface UseExpandedHookReturn {\n expanded: string[];\n setExpanded: (expanded: string[]) => void;\n handleExpansion: (id: string) => void;\n handleResetExpanded: () => void;\n}\ninterface UseExpandedHook {\n <Additional extends AdditionalDefault>(props: UseExpandedHookProps<Additional>): UseExpandedHookReturn;\n}\n\nexport const useExpanded: UseExpandedHook = ({\n initialValue,\n selected,\n expandTreeOnSelected,\n collection,\n onExpand,\n}) => {\n const calculatedInitialValue = useMemo(\n () => calculateInitialExpanded(initialValue, selected, expandTreeOnSelected, collection),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n const [expanded, setExpanded] = useState(calculatedInitialValue);\n const expandedRef = useRef(calculatedInitialValue);\n const selectedRef = useRef(selected);\n selectedRef.current = selected;\n const handlerRef = useRef(onExpand);\n\n const handleSetExpanded = useCallback((updatedExpanded: string[]) => {\n handlerRef.current?.(updatedExpanded.slice());\n\n if (!areEqualArrays(expandedRef.current, updatedExpanded)) {\n setExpanded(updatedExpanded);\n }\n }, []);\n\n const handleExpansion = useCallback(\n (id: string): void => {\n let updatedExpanded;\n if (expandedRef.current.includes(id)) {\n updatedExpanded = expandedRef.current.filter((itemId) => itemId !== id);\n } else {\n updatedExpanded = expandedRef.current.slice();\n updatedExpanded.push(id);\n }\n handleSetExpanded(updatedExpanded);\n },\n [handleSetExpanded]\n );\n\n const handleResetExpanded = useCallback(() => {\n const calculatedResetValue = calculateInitialExpanded(\n initialValue,\n selectedRef.current,\n expandTreeOnSelected,\n collection\n );\n if (!areEqualArrays(expandedRef.current, calculatedResetValue)) {\n setExpanded(calculatedResetValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n handlerRef.current = onExpand;\n }, [onExpand]);\n\n useEffect(() => {\n expandedRef.current = expanded;\n }, [expanded]);\n\n return { expanded, setExpanded: handleSetExpanded, handleExpansion, handleResetExpanded };\n};\n"],"names":[],"mappings":";;MAKa,cAAc,GAAG,CAAC,IAAc,EAAE,IAAc,KAAa;AACtE,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;AAC7B,QAAA,OAAO,KAAK,CAAC;AAChB,KAAA;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;AACrC,IAAA,OAAO,IAAI;AACN,SAAA,KAAK,EAAE;AACP,SAAA,IAAI,EAAE;AACN,SAAA,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1D,EAAE;AAEK,MAAM,wBAAwB,GAAG,CACpC,eAAyB,EACzB,QAAkB,EAClB,oBAA6B,EAC7B,UAAsC,KAC5B;AACV,IAAA,IAAI,QAAQ,GAAa,eAAe,CAAC,KAAK,EAAE,CAAC;AACjD,IAAA,IAAI,oBAAoB,EAAE;QACtB,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAW,CAAC,GAAG,EAAE,EAAE,KAAI;YAC7C,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CA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KAAK,EAAE,CAAC,CAAC;AAC3E,SAAA;AAAM,aAAA;AACH,YAAA,eAAe,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;AAC9C,YAAA,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5B,SAAA;QACD,iBAAiB,CAAC,eAAe,CAAC,CAAC;AACvC,KAAC,EACD,CAAC,iBAAiB,CAAC,CACtB,CAAC;AAEF,IAAA,MAAM,mBAAmB,GAAG,WAAW,CAAC,MAAK;AACzC,QAAA,MAAM,oBAAoB,GAAG,wBAAwB,CACjD,YAAY,EACZ,WAAW,CAAC,OAAO,EACnB,oBAAoB,EACpB,UAAU,CACb,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,CAAC,EAAE;YAC5D,WAAW,CAAC,oBAAoB,CAAC,CAAC;AACrC,SAAA;;KAEJ,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,MAAK;AACX,QAAA,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC;AAClC,KAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,SAAS,CAAC,MAAK;AACX,QAAA,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;AACnC,KAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC;AAC9F;;;;"}
1
+ {"version":3,"file":"useExpanded.js","sources":["../src/useExpanded.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, useMemo } from 'react';\n\nimport TreeCollection from '@hh.ru/magritte-ui-tree-selector/collection/treeCollection';\nimport { AdditionalDefault } from '@hh.ru/magritte-ui-tree-selector/collection/types';\n\nexport const areEqualArrays = (arr1: string[], arr2: string[]): boolean => {\n if (arr1.length !== arr2.length) {\n return false;\n }\n const sortArr2 = arr2.slice().sort();\n return arr1\n .slice()\n .sort()\n .every((item, index) => item === sortArr2[index]);\n};\n\nexport const calculateInitialExpanded = <Additional extends AdditionalDefault>(\n initialExpanded: string[],\n selected: string[],\n expandTreeOnSelected: boolean,\n collection: TreeCollection<Additional>\n): string[] => {\n let expanded: string[] = initialExpanded.slice();\n if (expandTreeOnSelected) {\n expanded = selected.reduce<string[]>((acc, id) => {\n return acc.concat(collection.getParentIds(id));\n }, expanded);\n }\n return [...new Set(expanded)];\n};\n\ninterface UseExpandedHookProps<Additional extends AdditionalDefault> {\n initialValue: string[];\n onExpand?: (expanded: string[]) => void;\n expandTreeOnSelected: boolean;\n selected: string[];\n collection: TreeCollection<Additional>;\n}\n\ninterface UseExpandedHookReturn {\n expanded: string[];\n setExpanded: (expanded: string[]) => void;\n handleExpansion: (id: string) => void;\n handleResetExpanded: () => void;\n}\ninterface UseExpandedHook {\n <Additional extends AdditionalDefault>(props: UseExpandedHookProps<Additional>): UseExpandedHookReturn;\n}\n\nexport const useExpanded: UseExpandedHook = ({\n initialValue,\n selected,\n expandTreeOnSelected,\n collection,\n onExpand,\n}) => {\n const calculatedInitialValue = useMemo(\n () => calculateInitialExpanded(initialValue, selected, expandTreeOnSelected, collection),\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n []\n );\n const [expanded, setExpanded] = useState(calculatedInitialValue);\n const expandedRef = useRef(calculatedInitialValue);\n const selectedRef = useRef(selected);\n selectedRef.current = selected;\n const handlerRef = useRef(onExpand);\n\n const handleSetExpanded = useCallback((updatedExpanded: string[]) => {\n handlerRef.current?.(updatedExpanded.slice());\n\n if (!areEqualArrays(expandedRef.current, updatedExpanded)) {\n setExpanded(updatedExpanded);\n }\n }, []);\n\n const handleExpansion = useCallback(\n (id: string): void => {\n let updatedExpanded;\n if (expandedRef.current.includes(id)) {\n updatedExpanded = expandedRef.current.filter((itemId) => itemId !== id);\n } else {\n updatedExpanded = expandedRef.current.slice();\n updatedExpanded.push(id);\n }\n handleSetExpanded(updatedExpanded);\n },\n [handleSetExpanded]\n );\n\n const handleResetExpanded = useCallback(() => {\n const calculatedResetValue = calculateInitialExpanded(\n initialValue,\n selectedRef.current,\n expandTreeOnSelected,\n collection\n );\n if (!areEqualArrays(expandedRef.current, calculatedResetValue)) {\n setExpanded(calculatedResetValue);\n }\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n handlerRef.current = onExpand;\n }, [onExpand]);\n\n useEffect(() => {\n expandedRef.current = expanded;\n }, [expanded]);\n\n return { expanded, setExpanded: handleSetExpanded, handleExpansion, handleResetExpanded };\n};\n"],"names":[],"mappings":";;MAKa,cAAc,GAAG,CAAC,IAAc,EAAE,IAAc,KAAa;AACtE,IAAA,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;AAC7B,QAAA,OAAO,KAAK,CAAC;AAChB,KAAA;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;AACrC,IAAA,OAAO,IAAI;AACN,SAAA,KAAK,EAAE;AACP,SAAA,IAAI,EAAE;AACN,SAAA,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,KAAK,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1D,EAAE;AAEK,MAAM,wBAAwB,GAAG,CACpC,eAAyB,EACzB,QAAkB,EAClB,oBAA6B,EAC7B,UAAsC,KAC5B;AACV,IAAA,IAAI,QAAQ,GAAa,eAAe,CAAC,KAAK,EAAE,CAAC;AACjD,IAAA,IAAI,oBAAoB,EAAE;QACtB,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAW,CAAC,GAAG,EAAE,EAAE,KAAI;YAC7C,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;SAClD,EAAE,QAAQ,CAAC,CAAC;AAChB,KAAA;IACD,OAAO,CAAC,GAAG,IAAI,GAAG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AC,KAAK,EAAE,CAAC;AAC9C,YAAA,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5B,SAAA;QACD,iBAAiB,CAAC,eAAe,CAAC,CAAC;AACvC,KAAC,EACD,CAAC,iBAAiB,CAAC,CACtB,CAAC;AAEF,IAAA,MAAM,mBAAmB,GAAG,WAAW,CAAC,MAAK;AACzC,QAAA,MAAM,oBAAoB,GAAG,wBAAwB,CACjD,YAAY,EACZ,WAAW,CAAC,OAAO,EACnB,oBAAoB,EACpB,UAAU,CACb,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,CAAC,EAAE;YAC5D,WAAW,CAAC,oBAAoB,CAAC,CAAC;AACrC,SAAA;;KAEJ,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,MAAK;AACX,QAAA,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC;AAClC,KAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,SAAS,CAAC,MAAK;AACX,QAAA,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;AACnC,KAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC;AAC9F;;;;"}
@@ -1,5 +0,0 @@
1
- import './index.css';
2
- var styles = {"item-animation-timeout":"magritte-item-animation-timeout___pbOyZ_4-3-9","itemAnimationTimeout":"magritte-item-animation-timeout___pbOyZ_4-3-9","fade-in":"magritte-fade-in___yS4Ja_4-3-9","fadeIn":"magritte-fade-in___yS4Ja_4-3-9","wrapper":"magritte-wrapper___GHKV6_4-3-9","letter":"magritte-letter___yZOCU_4-3-9","icon":"magritte-icon___kO3Fj_4-3-9","space":"magritte-space___xTO79_4-3-9","wrapperActive":"magritte-wrapperActive___Hwk8p_4-3-9","iconActive":"magritte-iconActive___4yrG5_4-3-9","iconUp":"magritte-iconUp___mpXV6_4-3-9","content":"magritte-content___ZRc6R_4-3-9","mobile-item":"magritte-mobile-item___ynALC_4-3-9","mobileItem":"magritte-mobile-item___ynALC_4-3-9","with-gap":"magritte-with-gap___gbvGO_4-3-9","withGap":"magritte-with-gap___gbvGO_4-3-9","virtualized-list":"magritte-virtualized-list___qt2E6_4-3-9","virtualizedList":"magritte-virtualized-list___qt2E6_4-3-9","virtualized-item":"magritte-virtualized-item___qAYVN_4-3-9","virtualizedItem":"magritte-virtualized-item___qAYVN_4-3-9","was-expanded":"magritte-was-expanded___uCFbW_4-3-9","wasExpanded":"magritte-was-expanded___uCFbW_4-3-9"};
3
-
4
- export { styles as s };
5
- //# sourceMappingURL=tree-selector-item-Dm-nL2-C.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tree-selector-item-Dm-nL2-C.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}