@canlooks/can-ui 0.0.202 → 0.0.204

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.
@@ -24,7 +24,7 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
24
24
  return promise;
25
25
  }
26
26
  }));
27
- const [innerValue, _setInnerValue] = (0, react_1.useState)(multiple ? [] : null);
27
+ const [innerValue, _setInnerValue] = (0, utils_1.useControlled)(defaultValue || (multiple ? [] : null), value, onChange);
28
28
  const setInnerValue = (value) => {
29
29
  _setInnerValue(value);
30
30
  // 单选模式,值每次改变都触发确认
@@ -32,9 +32,7 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
32
32
  };
33
33
  const clearHandler = () => {
34
34
  onClear?.();
35
- const newValue = multiple ? [] : null;
36
- onChange?.(newValue);
37
- setInnerValue(newValue);
35
+ setInnerValue(multiple ? [] : null);
38
36
  };
39
37
  const [innerOpen, setInnerOpen] = (0, utils_1.useControlled)(props.defaultOpen, props.open);
40
38
  const closeHandler = (reason) => {
@@ -45,12 +43,12 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
45
43
  if (!open) {
46
44
  resolvers.current?.reject({
47
45
  type: 'canceled',
48
- value: innerValue
46
+ value: innerValue.current
49
47
  });
50
48
  }
51
49
  setInnerOpen(false);
52
50
  };
53
- const confirmHandler = (value = innerValue) => {
51
+ const confirmHandler = (value = innerValue.current) => {
54
52
  onConfirm?.(value);
55
53
  resolvers.current?.resolve(value);
56
54
  setInnerOpen(false);
@@ -58,7 +56,7 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
58
56
  const onExited = () => {
59
57
  _setInnerValue(null);
60
58
  };
61
- const selectedCount = (0, utils_1.toArray)(innerValue)?.length || 0;
59
+ const selectedCount = (0, utils_1.toArray)(innerValue.current)?.length || 0;
62
60
  return ((0, jsx_runtime_1.jsx)(selectionContext_1.SelectionContext, { options,
63
61
  primaryKey,
64
62
  childrenKey,
@@ -66,7 +64,7 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
66
64
  integration,
67
65
  disabled,
68
66
  clearable,
69
- multiple, value: innerValue, onChange: setInnerValue, onToggle: onToggle, children: (0, jsx_runtime_1.jsx)(dialog_1.Dialog, { ...(0, utils_1.mergeComponentProps)({
67
+ multiple, value: innerValue.current, onChange: setInnerValue, onToggle: onToggle, children: (0, jsx_runtime_1.jsx)(dialog_1.Dialog, { ...(0, utils_1.mergeComponentProps)({
70
68
  width: multiple ? '90%' : 1080,
71
69
  footer: null,
72
70
  maskClosable: false
@@ -9,7 +9,7 @@ exports.classes = (0, utils_1.defineInnerClasses)('selected-list', [
9
9
  'optionWrap'
10
10
  ]);
11
11
  exports.style = (0, utils_1.defineCss)(({ spacing }) => (0, react_1.css) `
12
- @layer reset {
12
+ @layer override {
13
13
  .${exports.classes.optionWrap} {
14
14
  margin-bottom: ${spacing[3]}px;
15
15
  }
@@ -19,5 +19,9 @@ exports.style = (0, utils_1.defineCss)(({ spacing }) => (0, react_1.css) `
19
19
  text-overflow: ellipsis;
20
20
  overflow: hidden;
21
21
  }
22
+
23
+ .${alert_style_1.classes.description} {
24
+ margin-top: 0;
25
+ }
22
26
  }
23
27
  `);
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- import { useImperativeHandle, useRef, useState } from 'react';
2
+ import { useImperativeHandle, useRef } from 'react';
3
3
  import { Dialog } from '../dialog/index.js';
4
4
  import { clsx, mergeComponentProps, toArray, useControlled } from '../../utils/index.js';
5
5
  import { classes, style } from './pickerDialog.style.js';
@@ -21,7 +21,7 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
21
21
  return promise;
22
22
  }
23
23
  }));
24
- const [innerValue, _setInnerValue] = useState(multiple ? [] : null);
24
+ const [innerValue, _setInnerValue] = useControlled(defaultValue || (multiple ? [] : null), value, onChange);
25
25
  const setInnerValue = (value) => {
26
26
  _setInnerValue(value);
27
27
  // 单选模式,值每次改变都触发确认
@@ -29,9 +29,7 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
29
29
  };
30
30
  const clearHandler = () => {
31
31
  onClear?.();
32
- const newValue = multiple ? [] : null;
33
- onChange?.(newValue);
34
- setInnerValue(newValue);
32
+ setInnerValue(multiple ? [] : null);
35
33
  };
36
34
  const [innerOpen, setInnerOpen] = useControlled(props.defaultOpen, props.open);
37
35
  const closeHandler = (reason) => {
@@ -42,12 +40,12 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
42
40
  if (!open) {
43
41
  resolvers.current?.reject({
44
42
  type: 'canceled',
45
- value: innerValue
43
+ value: innerValue.current
46
44
  });
47
45
  }
48
46
  setInnerOpen(false);
49
47
  };
50
- const confirmHandler = (value = innerValue) => {
48
+ const confirmHandler = (value = innerValue.current) => {
51
49
  onConfirm?.(value);
52
50
  resolvers.current?.resolve(value);
53
51
  setInnerOpen(false);
@@ -55,7 +53,7 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
55
53
  const onExited = () => {
56
54
  _setInnerValue(null);
57
55
  };
58
- const selectedCount = toArray(innerValue)?.length || 0;
56
+ const selectedCount = toArray(innerValue.current)?.length || 0;
59
57
  return (_jsx(SelectionContext, { options,
60
58
  primaryKey,
61
59
  childrenKey,
@@ -63,7 +61,7 @@ options = rows ?? nodes, primaryKey = 'id', childrenKey = 'children', relation =
63
61
  integration,
64
62
  disabled,
65
63
  clearable,
66
- multiple, value: innerValue, onChange: setInnerValue, onToggle: onToggle, children: _jsx(Dialog, { ...mergeComponentProps({
64
+ multiple, value: innerValue.current, onChange: setInnerValue, onToggle: onToggle, children: _jsx(Dialog, { ...mergeComponentProps({
67
65
  width: multiple ? '90%' : 1080,
68
66
  footer: null,
69
67
  maskClosable: false
@@ -6,7 +6,7 @@ export const classes = defineInnerClasses('selected-list', [
6
6
  'optionWrap'
7
7
  ]);
8
8
  export const style = defineCss(({ spacing }) => css `
9
- @layer reset {
9
+ @layer override {
10
10
  .${classes.optionWrap} {
11
11
  margin-bottom: ${spacing[3]}px;
12
12
  }
@@ -16,5 +16,9 @@ export const style = defineCss(({ spacing }) => css `
16
16
  text-overflow: ellipsis;
17
17
  overflow: hidden;
18
18
  }
19
+
20
+ .${alertClasses.description} {
21
+ margin-top: 0;
22
+ }
19
23
  }
20
24
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.202",
3
+ "version": "0.0.204",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",