@canlooks/can-ui 0.0.46 → 0.0.48

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.
@@ -27,7 +27,7 @@ const Button = ({ component: Component = 'button', color = 'primary', shape = 's
27
27
  const actualPrefix = prefix ?? icon;
28
28
  const actualChildren = label ?? props.children;
29
29
  const reverseTextColor = variant === 'filled' || variant === 'flatted' ? '#ffffff' : color;
30
- return ((0, jsx_runtime_1.jsxs)(Component, { ...props, css: (0, button_style_1.useStyle)({ color: color || 'primary' }), className: (0, utils_2.clsx)(button_style_1.classes.root, props.className), onPointerUp: onPointerUp, onClick: onClick, "data-variant": variant, "data-orientation": orientation, "data-shape": shape, "data-size": size, "data-loading": loading, "data-read-only": readOnly, children: [loading
30
+ return ((0, jsx_runtime_1.jsxs)(Component, { type: "button", ...props, css: (0, button_style_1.useStyle)({ color: color || 'primary' }), className: (0, utils_2.clsx)(button_style_1.classes.root, props.className), onPointerUp: onPointerUp, onClick: onClick, "data-variant": variant, "data-orientation": orientation, "data-shape": shape, "data-size": size, "data-loading": loading, "data-read-only": readOnly, children: [loading
31
31
  ? actualPrefix
32
32
  ? (0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, { color: reverseTextColor })
33
33
  : (0, jsx_runtime_1.jsx)(transitionBase_1.Collapse, { orientation: "horizontal", in: true, children: (0, jsx_runtime_1.jsx)(loadingIndicator_1.LoadingIndicator, { color: reverseTextColor }) })
@@ -16,128 +16,128 @@ exports.classes = (0, utils_1.defineInnerClasses)('calendar', [
16
16
  'yearItem',
17
17
  'foot'
18
18
  ]);
19
- exports.style = (0, utils_1.defineCss)(({ divider, text, spacing }) => (0, react_1.css) `
20
- .${exports.classes.head} {
21
- height: 40px;
22
- display: flex;
23
- align-items: center;
24
- justify-content: space-between;
25
- border-bottom: 1px solid ${divider};
26
- padding: 0 ${menuItem_style_1.menuListPadding}px;
27
- position: relative;
28
-
29
- .${exports.classes.headSide} {
30
- z-index: 1;
31
- }
32
-
33
- .${exports.classes.headControl} {
34
- color: ${text.placeholder};
35
- }
36
-
37
- .${exports.classes.headCenter} {
38
- display: flex;
39
- align-items: center;
40
- justify-content: center;
41
- position: absolute;
42
- inset: 0;
43
-
44
- .${exports.classes.headButton} {
45
- font-weight: bold;
46
- color: ${text.primary};
47
- }
48
- }
49
- }
50
-
51
- .${exports.classes.body} {
52
- padding: ${spacing[3]}px ${spacing[4]}px;
53
- display: grid;
54
- place-items: center;
55
-
56
- &[data-view-type=date] {
57
- font-size: ${13 / 14}em;
58
- grid-template-columns: repeat(7, 36px);
59
- grid-template-rows: repeat(7, 36px);
60
-
61
- .${exports.classes.dateItem} {
62
- width: 24px;
63
- height: 24px;
64
-
65
- &:not([data-variant=filled]) {
66
- color: ${text.primary};
67
- border-color: ${text.disabled};
68
-
69
- &[data-other-month=true] {
70
- color: ${text.placeholder};
71
- }
72
- }
73
-
74
- &:disabled {
75
- width: 100%;
76
- border-radius: 0;
77
- }
78
- }
79
- }
80
-
81
- &[data-view-type=month], &[data-view-type=year] {
82
- grid-template-columns: repeat(3, 84px);
83
- grid-template-rows: repeat(4, 63px);
84
-
85
- .${exports.classes.monthItem},
86
- .${exports.classes.yearItem} {
87
- width: 72px;
88
- padding-inline: 0;
89
-
90
- &:not([data-variant=filled]) {
91
- color: ${text.primary};
92
- }
93
- }
94
- }
95
- }
96
-
97
- &[data-size=small] {
98
- .${exports.classes.body} {
99
- &[data-view-type=date] {
100
- grid-template-columns: repeat(7, 30px);
101
- grid-template-rows: repeat(7, 30px);
102
- }
103
-
104
- &[data-view-type=month], &[data-view-type=year] {
105
- grid-template-columns: repeat(3, 70px);
106
- grid-template-rows: repeat(4, 52.5px);
107
-
108
- .${exports.classes.monthItem},
109
- .${exports.classes.yearItem} {
110
- width: 60px;
111
- }
112
- }
113
- }
114
- }
115
-
116
- &[data-size=large] {
117
- .${exports.classes.body} {
118
- &[data-view-type=date] {
119
- font-size: 1em;
120
- grid-template-columns: repeat(7, 42px);
121
- grid-template-rows: repeat(7, 42px);
122
-
123
- .${exports.classes.dateItem} {
124
- width: 32px;
125
- height: 32px;
126
- }
127
- }
128
-
129
- &[data-view-type=month], &[data-view-type=year] {
130
- grid-template-columns: repeat(3, 98px);
131
- grid-template-rows: repeat(4, 73.5px);
132
- }
133
- }
134
- }
135
-
136
- .${exports.classes.foot} {
137
- height: 41px;
138
- display: flex;
139
- align-items: center;
140
- justify-content: center;
141
- border-top: 1px solid ${divider};
142
- }
19
+ exports.style = (0, utils_1.defineCss)(({ divider, text, spacing }) => (0, react_1.css) `
20
+ .${exports.classes.head} {
21
+ height: 40px;
22
+ display: flex;
23
+ align-items: center;
24
+ justify-content: space-between;
25
+ border-bottom: 1px solid ${divider};
26
+ padding: 0 ${menuItem_style_1.menuListPadding}px;
27
+ position: relative;
28
+
29
+ .${exports.classes.headSide} {
30
+ z-index: 1;
31
+ }
32
+
33
+ .${exports.classes.headControl} {
34
+ color: ${text.placeholder};
35
+ }
36
+
37
+ .${exports.classes.headCenter} {
38
+ display: flex;
39
+ align-items: center;
40
+ justify-content: center;
41
+ position: absolute;
42
+ inset: 0;
43
+
44
+ .${exports.classes.headButton} {
45
+ font-weight: bold;
46
+ color: ${text.primary};
47
+ }
48
+ }
49
+ }
50
+
51
+ .${exports.classes.body} {
52
+ padding: ${spacing[3]}px ${spacing[4]}px;
53
+ display: grid;
54
+ place-items: center;
55
+
56
+ &[data-view-type=date] {
57
+ font-size: ${13 / 14}em;
58
+ grid-template-columns: repeat(7, 36px);
59
+ grid-template-rows: repeat(7, 36px);
60
+
61
+ .${exports.classes.dateItem} {
62
+ width: 24px;
63
+ height: 24px;
64
+
65
+ &:not([data-variant=filled]) {
66
+ color: ${text.primary};
67
+ border-color: ${text.disabled};
68
+
69
+ &[data-other-month=true] {
70
+ color: ${text.placeholder};
71
+ }
72
+ }
73
+
74
+ &:disabled {
75
+ width: 100%;
76
+ border-radius: 0;
77
+ }
78
+ }
79
+ }
80
+
81
+ &[data-view-type=month], &[data-view-type=year] {
82
+ grid-template-columns: repeat(3, 84px);
83
+ grid-template-rows: repeat(4, 63px);
84
+
85
+ .${exports.classes.monthItem},
86
+ .${exports.classes.yearItem} {
87
+ width: 72px;
88
+ padding-inline: 0;
89
+
90
+ &:not([data-variant=filled]) {
91
+ color: ${text.primary};
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ &[data-size=small] {
98
+ .${exports.classes.body} {
99
+ &[data-view-type=date] {
100
+ grid-template-columns: repeat(7, 30px);
101
+ grid-template-rows: repeat(7, 30px);
102
+ }
103
+
104
+ &[data-view-type=month], &[data-view-type=year] {
105
+ grid-template-columns: repeat(3, 70px);
106
+ grid-template-rows: repeat(4, 52.5px);
107
+
108
+ .${exports.classes.monthItem},
109
+ .${exports.classes.yearItem} {
110
+ width: 60px;
111
+ }
112
+ }
113
+ }
114
+ }
115
+
116
+ &[data-size=large] {
117
+ .${exports.classes.body} {
118
+ &[data-view-type=date] {
119
+ font-size: 1em;
120
+ grid-template-columns: repeat(7, 42px);
121
+ grid-template-rows: repeat(7, 42px);
122
+
123
+ .${exports.classes.dateItem} {
124
+ width: 32px;
125
+ height: 32px;
126
+ }
127
+ }
128
+
129
+ &[data-view-type=month], &[data-view-type=year] {
130
+ grid-template-columns: repeat(3, 98px);
131
+ grid-template-rows: repeat(4, 73.5px);
132
+ }
133
+ }
134
+ }
135
+
136
+ .${exports.classes.foot} {
137
+ height: 41px;
138
+ display: flex;
139
+ align-items: center;
140
+ justify-content: center;
141
+ border-top: 1px solid ${divider};
142
+ }
143
143
  `);
@@ -142,7 +142,7 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
142
142
  onBlurCapture: import("react").FocusEventHandler<HTMLDivElement>;
143
143
  onChange: import("react").FormEventHandler<HTMLDivElement>;
144
144
  onChangeCapture: import("react").FormEventHandler<HTMLDivElement>;
145
- onBeforeInput: import("react").FormEventHandler<HTMLDivElement>;
145
+ onBeforeInput: import("react").InputEventHandler<HTMLDivElement>;
146
146
  onBeforeInputCapture: import("react").FormEventHandler<HTMLDivElement>;
147
147
  onInput: import("react").FormEventHandler<HTMLDivElement>;
148
148
  onInputCapture: import("react").FormEventHandler<HTMLDivElement>;
@@ -192,8 +192,6 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
192
192
  onProgressCapture: import("react").ReactEventHandler<HTMLDivElement>;
193
193
  onRateChange: import("react").ReactEventHandler<HTMLDivElement>;
194
194
  onRateChangeCapture: import("react").ReactEventHandler<HTMLDivElement>;
195
- onResize: import("react").ReactEventHandler<HTMLDivElement>;
196
- onResizeCapture: import("react").ReactEventHandler<HTMLDivElement>;
197
195
  onSeeked: import("react").ReactEventHandler<HTMLDivElement>;
198
196
  onSeekedCapture: import("react").ReactEventHandler<HTMLDivElement>;
199
197
  onSeeking: import("react").ReactEventHandler<HTMLDivElement>;
@@ -22,7 +22,7 @@ size, labelWidth, colon, labelPlacement, disableMargin, disablePadding, span = {
22
22
  const spanNum = (0, utils_1.useResponsiveValue)(span, variant === 'grid');
23
23
  return variant === 'grid'
24
24
  ? (0, jsx_runtime_1.jsxs)(grid_1.GridItem, { ...props, css: descriptions_style_1.gridItemStyle, className: (0, utils_1.clsx)(descriptions_style_1.classes.item, props.className), span: span, "data-size": size, "data-label-placement": labelPlacement, "data-disable-margin": disableMargin, children: [!!label &&
25
- (0, jsx_runtime_1.jsxs)("div", { className: descriptions_style_1.classes.label, style: { width: labelWidth }, children: [label, !!colon && (labelPlacement === 'left' || labelPlacement === 'right') &&
25
+ (0, jsx_runtime_1.jsxs)("div", { className: descriptions_style_1.classes.label, style: { width: labelWidth }, children: [label, !!colon && labelPlacement === 'left' &&
26
26
  (0, jsx_runtime_1.jsx)("div", { className: descriptions_style_1.classes.colon, children: colon })] }), (0, jsx_runtime_1.jsx)("div", { className: descriptions_style_1.classes.content, children: content ?? props.children })] })
27
27
  : labelPlacement === 'top'
28
28
  ? (0, jsx_runtime_1.jsx)("td", { className: descriptions_style_1.classes.vertical, colSpan: spanNum.current, children: (0, jsx_runtime_1.jsxs)("div", { className: descriptions_style_1.classes.verticalColWrap, children: [(0, jsx_runtime_1.jsx)("div", { className: `${descriptions_style_1.classes.col} ${descriptions_style_1.classes.labelCol}`, "data-size": size, children: label }), (0, jsx_runtime_1.jsx)("div", { className: `${descriptions_style_1.classes.col} ${descriptions_style_1.classes.contentCol}`, "data-size": size, "data-disable-padding": disablePadding, children: content ?? props.children })] }) })
@@ -136,18 +136,21 @@ exports.gridItemStyle = (0, utils_1.defineCss)(({ spacing, text }) => (0, react_
136
136
  .${exports.classes.label} {
137
137
  text-align: right;
138
138
  justify-content: flex-end;
139
- }
140
-
141
- .${exports.classes.content} {
142
- margin-left: ${spacing[3]}px;
139
+
140
+ + .${exports.classes.content} {
141
+ margin-left: ${spacing[3]}px;
142
+ }
143
143
  }
144
144
  }
145
145
 
146
146
  &[data-label-placement=right] {
147
147
  .${exports.classes.content} {
148
148
  text-align: right;
149
- margin-right: ${spacing[2]}px;
150
149
  justify-content: flex-end;
151
150
  }
151
+
152
+ .${exports.classes.label} + .${exports.classes.content} {
153
+ margin-right: ${spacing[3]}px;
154
+ }
152
155
  }
153
156
  `);
@@ -43,6 +43,7 @@ inline, columnCount = 1, gap, columnGap, rowGap, ...props }) => {
43
43
  */
44
44
  const itemsContainer = (0, react_1.useRef)(new Map());
45
45
  const submitHandler = async (e) => {
46
+ console.log(e);
46
47
  e?.preventDefault();
47
48
  try {
48
49
  await Promise.all([...itemsContainer.current].map(async ([, item]) => {
@@ -159,7 +159,8 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
159
159
  if (noStyle || variant === 'plain') {
160
160
  return renderedChildren;
161
161
  }
162
- return ((0, jsx_runtime_1.jsxs)(descriptions_1.DescriptionItem, { flex: void 0, ...props, ref: wrapperRef, className: (0, utils_1.clsx)(form_style_1.classes.item, props.className), label: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRequired && !!requiredMark &&
163
- (0, jsx_runtime_1.jsx)("span", { className: form_style_1.classes.requiredMark, children: requiredMark }), label] }), children: [renderedChildren, (0, jsx_runtime_1.jsx)(transitionBase_1.Collapse, { in: innerError.current || !!helperText, children: (0, jsx_runtime_1.jsx)("div", { className: form_style_1.classes.helperText, children: innerHelperText.current }) })] }));
162
+ return ((0, jsx_runtime_1.jsxs)(descriptions_1.DescriptionItem, { flex: void 0, ...props, ref: wrapperRef, className: (0, utils_1.clsx)(form_style_1.classes.item, props.className), label: !!label &&
163
+ (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRequired && !!requiredMark &&
164
+ (0, jsx_runtime_1.jsx)("span", { className: form_style_1.classes.requiredMark, children: requiredMark }), label] }), children: [renderedChildren, (0, jsx_runtime_1.jsx)(transitionBase_1.Collapse, { in: innerError.current || !!helperText, children: (0, jsx_runtime_1.jsx)("div", { className: form_style_1.classes.helperText, children: innerHelperText.current }) })] }));
164
165
  };
165
166
  exports.FormItem = FormItem;
@@ -12,7 +12,7 @@ const __1 = require("../..");
12
12
  const faCircleXmark_1 = require("@fortawesome/free-solid-svg-icons/faCircleXmark");
13
13
  exports.InputBase = (({ variant = 'outlined', size, shape, color = 'primary', children, prefix, suffix, onClear, loading, type, clearable = type !== 'number',
14
14
  // 以下属性传递给<input/>
15
- min = -Infinity, max = Infinity, step, precision, placeholder, disabled, readOnly, autoFocus, defaultValue, value, onChange, ...props }) => {
15
+ min, max, step, precision, placeholder, disabled, readOnly, autoFocus, defaultValue, value, onChange, ...props }) => {
16
16
  const theme = (0, theme_1.useTheme)();
17
17
  size ??= theme.size;
18
18
  const innerInputRef = (0, react_1.useRef)(null);
@@ -28,6 +28,7 @@ function useStyle({ color }) {
28
28
  const c = (0, color_1.default)(colorValue);
29
29
  const selectedBg = c.alpha(.1).string();
30
30
  const selectedAndFocused = c.alpha(.15).string();
31
+ const selectedActive = c.alpha(.08).string();
31
32
  const focusedBg = gray(mode === 'light' ? .05 : .23);
32
33
  const disabledOrActive = gray(mode === 'light' ? .1 : .17);
33
34
  return (0, react_1.css) `
@@ -38,6 +39,7 @@ function useStyle({ color }) {
38
39
  cursor: pointer;
39
40
  color: ${text.primary};
40
41
  padding: ${exports.paddingHorizontal.medium}px 12px;
42
+ position: relative;
41
43
  -webkit-tap-highlight-color: transparent;
42
44
 
43
45
  &[data-size=small] {
@@ -52,8 +54,7 @@ function useStyle({ color }) {
52
54
 
53
55
  transition: background-color .25s ${easing.easeOut};
54
56
 
55
- &:hover,
56
- &[data-focused=true] {
57
+ &:hover, &[data-focused=true] {
57
58
  background-color: ${focusedBg};
58
59
  }
59
60
 
@@ -69,7 +70,7 @@ function useStyle({ color }) {
69
70
  &[data-selected=true] {
70
71
  background-color: ${selectedBg};
71
72
 
72
- &[data-focused=true] {
73
+ &:hover, &[data-focused=true] {
73
74
  background-color: ${selectedAndFocused};
74
75
  }
75
76
 
@@ -77,6 +78,10 @@ function useStyle({ color }) {
77
78
  font-weight: bold;
78
79
  color: ${colorValue};
79
80
  }
81
+
82
+ &:active {
83
+ background-color: ${selectedActive};
84
+ }
80
85
  }
81
86
 
82
87
  &[data-disabled=true] {
@@ -20,10 +20,6 @@ exports.Ripple = (0, react_1.memo)(({ ref, color = 'primary', ...props }) => {
20
20
  (0, react_1.useLayoutEffect)(() => {
21
21
  const wrapper = rippleRef.current?.parentElement;
22
22
  if (wrapper) {
23
- const { position } = getComputedStyle(wrapper);
24
- if (position === 'static') {
25
- wrapper.style.position = 'relative';
26
- }
27
23
  const pointerDown = (e) => {
28
24
  setRipples(o => [
29
25
  ...o,
@@ -24,7 +24,7 @@ export const Button = ({ component: Component = 'button', color = 'primary', sha
24
24
  const actualPrefix = prefix ?? icon;
25
25
  const actualChildren = label ?? props.children;
26
26
  const reverseTextColor = variant === 'filled' || variant === 'flatted' ? '#ffffff' : color;
27
- return (_jsxs(Component, { ...props, css: useStyle({ color: color || 'primary' }), className: clsx(classes.root, props.className), onPointerUp: onPointerUp, onClick: onClick, "data-variant": variant, "data-orientation": orientation, "data-shape": shape, "data-size": size, "data-loading": loading, "data-read-only": readOnly, children: [loading
27
+ return (_jsxs(Component, { type: "button", ...props, css: useStyle({ color: color || 'primary' }), className: clsx(classes.root, props.className), onPointerUp: onPointerUp, onClick: onClick, "data-variant": variant, "data-orientation": orientation, "data-shape": shape, "data-size": size, "data-loading": loading, "data-read-only": readOnly, children: [loading
28
28
  ? actualPrefix
29
29
  ? _jsx(LoadingIndicator, { color: reverseTextColor })
30
30
  : _jsx(Collapse, { orientation: "horizontal", in: true, children: _jsx(LoadingIndicator, { color: reverseTextColor }) })