@snack-uikit/list 0.4.2-preview-3bc93fc3.0 → 0.4.2-preview-da21d728.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,8 +26,9 @@ export function isSelectionSingleProps(props) {
26
26
  return 'mode' in props && props['mode'] === 'single';
27
27
  }
28
28
  function SelectionSingleProvider({ value: valueProp, defaultValue, onChange: onChangeProp, children, }) {
29
- const [value, setValue] = useUncontrolledProp(valueProp, defaultValue, cb => {
30
- onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(cb(value));
29
+ const [value, setValue] = useUncontrolledProp(valueProp, defaultValue, newValue => {
30
+ const result = typeof newValue === 'function' ? newValue(value) : newValue;
31
+ onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(result);
31
32
  });
32
33
  const onChange = useCallback((newValue) => setValue((oldValue) => {
33
34
  if (newValue !== oldValue) {
@@ -45,7 +46,10 @@ function SelectionSingleProvider({ value: valueProp, defaultValue, onChange: onC
45
46
  }, children: children }));
46
47
  }
47
48
  function SelectionMultipleProvider({ value: valueProp, defaultValue, onChange: onChangeProp, children, }) {
48
- const [value, setValue] = useUncontrolledProp(valueProp, defaultValue, onChangeProp);
49
+ const [value, setValue] = useUncontrolledProp(valueProp, defaultValue, newValue => {
50
+ const result = typeof newValue === 'function' ? newValue(value) : newValue;
51
+ onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(result);
52
+ });
49
53
  const onChange = useCallback((newValue) => {
50
54
  setValue((oldValues) => {
51
55
  if (Array.isArray(oldValues)) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "List",
7
- "version": "0.4.2-preview-3bc93fc3.0",
7
+ "version": "0.4.2-preview-da21d728.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -32,7 +32,7 @@
32
32
  "license": "Apache-2.0",
33
33
  "scripts": {},
34
34
  "dependencies": {
35
- "@snack-uikit/divider": "3.0.2-preview-3bc93fc3.0",
35
+ "@snack-uikit/divider": "3.0.2-preview-da21d728.0",
36
36
  "@snack-uikit/dropdown": "0.2.0",
37
37
  "@snack-uikit/icons": "0.20.1",
38
38
  "@snack-uikit/info-block": "0.3.0",
@@ -54,5 +54,5 @@
54
54
  "peerDependencies": {
55
55
  "@snack-uikit/locale": "*"
56
56
  },
57
- "gitHead": "a2fa7717157c8a23fa1fc6b64c67c7b2d9dfc39c"
57
+ "gitHead": "9451c0c01e3175ef35d07864f3189c690f73c268"
58
58
  }
@@ -90,8 +90,10 @@ function SelectionSingleProvider({
90
90
  onChange: onChangeProp,
91
91
  children,
92
92
  }: SelectionSingleProps & Child) {
93
- const [value, setValue] = useUncontrolledProp<SelectionSingleValueType>(valueProp, defaultValue, cb => {
94
- onChangeProp?.(cb(value));
93
+ const [value, setValue] = useUncontrolledProp<SelectionSingleValueType>(valueProp, defaultValue, newValue => {
94
+ const result = typeof newValue === 'function' ? newValue(value) : newValue;
95
+
96
+ onChangeProp?.(result);
95
97
  });
96
98
 
97
99
  const onChange = useCallback(
@@ -128,7 +130,11 @@ function SelectionMultipleProvider({
128
130
  onChange: onChangeProp,
129
131
  children,
130
132
  }: SelectionMultipleProps & Child) {
131
- const [value, setValue] = useUncontrolledProp<SelectionSingleValueType[]>(valueProp, defaultValue, onChangeProp);
133
+ const [value, setValue] = useUncontrolledProp<SelectionSingleValueType[]>(valueProp, defaultValue, newValue => {
134
+ const result = typeof newValue === 'function' ? newValue(value) : newValue;
135
+
136
+ onChangeProp?.(result);
137
+ });
132
138
 
133
139
  const onChange = useCallback(
134
140
  (newValue: SelectionSingleValueType) => {