@snack-uikit/chips 0.13.4 → 0.14.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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.14.1 (2024-05-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **FF-0000:** fix keyboard control ([4fabf88](https://github.com/cloud-ru-tech/snack-uikit/commit/4fabf886d367c8f83648eccae36a7e2d500192da))
12
+
13
+
14
+
15
+
16
+
17
+ # 0.14.0 (2024-05-08)
18
+
19
+
20
+ ### Features
21
+
22
+ * **PDS-135:** support list api update ([57a20c3](https://github.com/cloud-ru-tech/snack-uikit/commit/57a20c303fd7778706bd4a1b322c070e6b0422bb))
23
+
24
+
25
+
26
+
27
+
6
28
  ## 0.13.4 (2024-05-08)
7
29
 
8
30
  ### Only dependencies have been changed
@@ -59,12 +59,17 @@ export function ChipChoiceMultiple(_a) {
59
59
  const items = useMemo(() => transformOptionsToItems(result, contentRender), [contentRender, result]);
60
60
  const clearValue = () => setValue([]);
61
61
  const chipRef = useRef(null);
62
+ const listRef = useRef(null);
62
63
  const handleSelectionChange = useCallback((newValue) => {
64
+ var _a;
63
65
  if (newValue !== undefined) {
64
66
  setValue(newValue);
67
+ if (searchValue) {
68
+ (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.focus();
69
+ }
65
70
  setSearchValue('');
66
71
  }
67
- }, [setValue]);
72
+ }, [searchValue, setValue]);
68
73
  useEffect(() => {
69
74
  if (searchValue && !open) {
70
75
  setSearchValue('');
@@ -74,7 +79,7 @@ export function ChipChoiceMultiple(_a) {
74
79
  value,
75
80
  onChange: handleSelectionChange,
76
81
  mode: 'multiple',
77
- }, trigger: 'clickAndFocusVisible', placement: 'bottom-start', widthStrategy: 'gte', size: DROPLIST_SIZE_MAP[size], "data-test-id": CHIP_CHOICE_TEST_IDS.droplist, open: open, triggerElemRef: chipRef, onOpenChange: open => {
82
+ }, trigger: 'clickAndFocusVisible', placement: 'bottom-start', widthStrategy: 'gte', listRef: listRef, size: DROPLIST_SIZE_MAP[size], "data-test-id": CHIP_CHOICE_TEST_IDS.droplist, open: open, onOpenChange: open => {
78
83
  if (!open) {
79
84
  setSearchValue('');
80
85
  }
@@ -66,7 +66,7 @@ export function ChipChoiceSingle(_a) {
66
66
  value,
67
67
  onChange: handleSelectionChange,
68
68
  mode: 'single',
69
- }, "data-test-id": CHIP_CHOICE_TEST_IDS.droplist, size: DROPLIST_SIZE_MAP[size], trigger: 'click', placement: 'bottom-start', className: dropDownClassName, widthStrategy: 'gte', open: open, triggerElemRef: chipRef, onOpenChange: open => {
69
+ }, "data-test-id": CHIP_CHOICE_TEST_IDS.droplist, size: DROPLIST_SIZE_MAP[size], trigger: 'click', placement: 'bottom-start', className: dropDownClassName, widthStrategy: 'gte', open: open, onOpenChange: open => {
70
70
  if (!open) {
71
71
  setSearchValue('');
72
72
  }
@@ -6,6 +6,7 @@ export type FlattenOption<T extends ContentRenderProps = ContentRenderProps> = {
6
6
  label: ItemId;
7
7
  contentRenderProps?: T;
8
8
  disabled?: boolean;
9
+ hidden?: boolean;
9
10
  afterContent?: ReactNode;
10
11
  beforeContent?: ReactNode;
11
12
  };
@@ -3,7 +3,7 @@ export function kindFlattenOptions({ options, }) {
3
3
  const flattenOptions = {};
4
4
  function flatten(option) {
5
5
  if (isBaseOption(option)) {
6
- const { value, label, contentRenderProps, disabled, afterContent, beforeContent } = option;
6
+ const { value, label, contentRenderProps, disabled, afterContent, beforeContent, hidden } = option;
7
7
  flattenOptions[value] = {
8
8
  value,
9
9
  label,
@@ -11,6 +11,7 @@ export function kindFlattenOptions({ options, }) {
11
11
  disabled,
12
12
  afterContent,
13
13
  beforeContent,
14
+ hidden,
14
15
  };
15
16
  return;
16
17
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Chips",
7
- "version": "0.13.4",
7
+ "version": "0.14.1",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -36,7 +36,7 @@
36
36
  "@snack-uikit/calendar": "0.7.9",
37
37
  "@snack-uikit/dropdown": "0.2.2",
38
38
  "@snack-uikit/icons": "0.21.0",
39
- "@snack-uikit/list": "0.11.5",
39
+ "@snack-uikit/list": "0.13.0",
40
40
  "@snack-uikit/loaders": "0.5.2",
41
41
  "@snack-uikit/utils": "3.3.0",
42
42
  "classnames": "2.3.2",
@@ -50,5 +50,5 @@
50
50
  "peerDependencies": {
51
51
  "@snack-uikit/locale": "*"
52
52
  },
53
- "gitHead": "59bd2ac46a341357d543ada864a34e09745b3e42"
53
+ "gitHead": "d36fe553ce72b92deafee581e70090458827f8ac"
54
54
  }
@@ -90,15 +90,19 @@ export function ChipChoiceMultiple<T extends ContentRenderProps = ContentRenderP
90
90
 
91
91
  const clearValue = () => setValue([]);
92
92
  const chipRef = useRef<HTMLDivElement>(null);
93
+ const listRef = useRef<HTMLElement>(null);
93
94
 
94
95
  const handleSelectionChange = useCallback(
95
96
  (newValue?: SelectionSingleValueType) => {
96
97
  if (newValue !== undefined) {
97
98
  setValue(newValue);
99
+ if (searchValue) {
100
+ listRef.current?.focus();
101
+ }
98
102
  setSearchValue('');
99
103
  }
100
104
  },
101
- [setValue],
105
+ [searchValue, setValue],
102
106
  );
103
107
 
104
108
  useEffect(() => {
@@ -119,10 +123,10 @@ export function ChipChoiceMultiple<T extends ContentRenderProps = ContentRenderP
119
123
  trigger='clickAndFocusVisible'
120
124
  placement='bottom-start'
121
125
  widthStrategy='gte'
126
+ listRef={listRef}
122
127
  size={DROPLIST_SIZE_MAP[size]}
123
128
  data-test-id={CHIP_CHOICE_TEST_IDS.droplist}
124
129
  open={open}
125
- triggerElemRef={chipRef}
126
130
  onOpenChange={open => {
127
131
  if (!open) {
128
132
  setSearchValue('');
@@ -110,7 +110,6 @@ export function ChipChoiceSingle<T extends ContentRenderProps = ContentRenderPro
110
110
  className={dropDownClassName}
111
111
  widthStrategy='gte'
112
112
  open={open}
113
- triggerElemRef={chipRef}
114
113
  onOpenChange={open => {
115
114
  if (!open) {
116
115
  setSearchValue('');
@@ -10,6 +10,7 @@ export type FlattenOption<T extends ContentRenderProps = ContentRenderProps> = {
10
10
  label: ItemId;
11
11
  contentRenderProps?: T;
12
12
  disabled?: boolean;
13
+ hidden?: boolean;
13
14
  afterContent?: ReactNode;
14
15
  beforeContent?: ReactNode;
15
16
  };
@@ -27,7 +28,7 @@ export function kindFlattenOptions<T extends ContentRenderProps = ContentRenderP
27
28
 
28
29
  function flatten(option: FilterOption<T>) {
29
30
  if (isBaseOption<T>(option)) {
30
- const { value, label, contentRenderProps, disabled, afterContent, beforeContent } = option;
31
+ const { value, label, contentRenderProps, disabled, afterContent, beforeContent, hidden } = option;
31
32
 
32
33
  flattenOptions[value] = {
33
34
  value,
@@ -36,6 +37,7 @@ export function kindFlattenOptions<T extends ContentRenderProps = ContentRenderP
36
37
  disabled,
37
38
  afterContent,
38
39
  beforeContent,
40
+ hidden,
39
41
  };
40
42
 
41
43
  return;