@rc-component/select 1.2.0-alpha.0 → 1.2.0-alpha.2
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/assets/index.css +6 -0
- package/assets/patch.less +7 -0
- package/es/BaseSelect/index.d.ts +1 -1
- package/es/Select.d.ts +1 -1
- package/es/SelectInput/Content/MultipleContent.js +15 -11
- package/es/SelectInput/Content/Placeholder.d.ts +1 -1
- package/es/SelectInput/Content/Placeholder.js +10 -3
- package/es/SelectInput/Content/SingleContent.js +5 -2
- package/lib/BaseSelect/index.d.ts +1 -1
- package/lib/Select.d.ts +1 -1
- package/lib/SelectInput/Content/MultipleContent.js +15 -11
- package/lib/SelectInput/Content/Placeholder.d.ts +1 -1
- package/lib/SelectInput/Content/Placeholder.js +11 -3
- package/lib/SelectInput/Content/SingleContent.js +5 -2
- package/package.json +2 -2
package/assets/index.css
CHANGED
|
@@ -57,6 +57,12 @@
|
|
|
57
57
|
border-radius: 8px;
|
|
58
58
|
margin-right: 4px;
|
|
59
59
|
}
|
|
60
|
+
.rc-select.rc-select-multiple .rc-select-placeholder {
|
|
61
|
+
position: absolute;
|
|
62
|
+
left: 0;
|
|
63
|
+
top: 50%;
|
|
64
|
+
transform: translateY(-50%);
|
|
65
|
+
}
|
|
60
66
|
.rc-select.rc-select-multiple .rc-select-input {
|
|
61
67
|
width: calc(var(--select-input-width, 10) * 1px);
|
|
62
68
|
min-width: 4px;
|
package/assets/patch.less
CHANGED
|
@@ -75,6 +75,13 @@
|
|
|
75
75
|
margin-right: 4px;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
.@{select-prefix}-placeholder {
|
|
79
|
+
position: absolute;
|
|
80
|
+
left: 0;
|
|
81
|
+
top: 50%;
|
|
82
|
+
transform: translateY(-50%);
|
|
83
|
+
}
|
|
84
|
+
|
|
78
85
|
.@{select-prefix}-input {
|
|
79
86
|
width: calc(var(--select-input-width, 10) * 1px);
|
|
80
87
|
min-width: 4px;
|
package/es/BaseSelect/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ScrollConfig, ScrollTo } from 'rc-virtual-list/lib/List';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import type { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
|
|
5
5
|
import type { ComponentsConfig } from '../hooks/useComponents';
|
|
6
|
-
export type BaseSelectSemanticName = 'prefix' | 'suffix' | 'input' | 'clear';
|
|
6
|
+
export type BaseSelectSemanticName = 'prefix' | 'suffix' | 'input' | 'clear' | 'placeholder' | 'content' | 'item' | 'itemContent' | 'itemRemove';
|
|
7
7
|
/**
|
|
8
8
|
* ZombieJ:
|
|
9
9
|
* We are currently refactoring the semantic structure of the component. Changelog:
|
package/es/Select.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
|
|
|
125
125
|
classNames?: Partial<Record<SemanticName, string>>;
|
|
126
126
|
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
127
127
|
}
|
|
128
|
-
declare const TypedSelect: (<ValueType = any, OptionType extends
|
|
128
|
+
declare const TypedSelect: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
129
129
|
Option: typeof Option;
|
|
130
130
|
OptGroup: typeof OptGroup;
|
|
131
131
|
};
|
|
@@ -35,7 +35,9 @@ export default /*#__PURE__*/React.forwardRef(function MultipleContent({
|
|
|
35
35
|
tagRender: tagRenderFromContext,
|
|
36
36
|
maxTagPlaceholder: maxTagPlaceholderFromContext,
|
|
37
37
|
maxTagTextLength,
|
|
38
|
-
maxTagCount
|
|
38
|
+
maxTagCount,
|
|
39
|
+
classNames,
|
|
40
|
+
styles
|
|
39
41
|
} = useBaseProps();
|
|
40
42
|
const selectionItemPrefixCls = `${prefixCls}-selection-item`;
|
|
41
43
|
|
|
@@ -65,11 +67,14 @@ export default /*#__PURE__*/React.forwardRef(function MultipleContent({
|
|
|
65
67
|
title: getTitle(item),
|
|
66
68
|
className: clsx(selectionItemPrefixCls, {
|
|
67
69
|
[`${selectionItemPrefixCls}-disabled`]: itemDisabled
|
|
68
|
-
})
|
|
70
|
+
}, classNames?.item),
|
|
71
|
+
style: styles?.item
|
|
69
72
|
}, /*#__PURE__*/React.createElement("span", {
|
|
70
|
-
className: `${selectionItemPrefixCls}-content
|
|
73
|
+
className: clsx(`${selectionItemPrefixCls}-content`, classNames?.itemContent),
|
|
74
|
+
style: styles?.itemContent
|
|
71
75
|
}, content), closable && /*#__PURE__*/React.createElement(TransBtn, {
|
|
72
|
-
className: `${selectionItemPrefixCls}-remove`,
|
|
76
|
+
className: clsx(`${selectionItemPrefixCls}-remove`, classNames?.itemRemove),
|
|
77
|
+
style: styles?.itemRemove,
|
|
73
78
|
onMouseDown: onPreventMouseDown,
|
|
74
79
|
onClick: onClose,
|
|
75
80
|
customizeIcon: removeIcon
|
|
@@ -129,15 +134,14 @@ export default /*#__PURE__*/React.forwardRef(function MultipleContent({
|
|
|
129
134
|
};
|
|
130
135
|
|
|
131
136
|
// ======================= Render =======================
|
|
132
|
-
return /*#__PURE__*/React.createElement(
|
|
133
|
-
show: !searchValue || !triggerOpen
|
|
134
|
-
}), /*#__PURE__*/React.createElement(Overflow, {
|
|
137
|
+
return /*#__PURE__*/React.createElement(Overflow, {
|
|
135
138
|
prefixCls: `${prefixCls}-content`,
|
|
139
|
+
className: classNames?.content,
|
|
140
|
+
style: styles?.content,
|
|
141
|
+
prefix: !displayValues.length && (!searchValue || !triggerOpen) ? /*#__PURE__*/React.createElement(Placeholder, null) : null,
|
|
136
142
|
data: displayValues,
|
|
137
143
|
renderItem: renderItem,
|
|
138
|
-
renderRest: renderRest
|
|
139
|
-
// suffix={inputNode}
|
|
140
|
-
,
|
|
144
|
+
renderRest: renderRest,
|
|
141
145
|
suffix: /*#__PURE__*/React.createElement(Input, _extends({
|
|
142
146
|
ref: ref,
|
|
143
147
|
disabled: disabled,
|
|
@@ -148,5 +152,5 @@ export default /*#__PURE__*/React.forwardRef(function MultipleContent({
|
|
|
148
152
|
})),
|
|
149
153
|
itemKey: itemKey,
|
|
150
154
|
maxCount: maxTagCount
|
|
151
|
-
})
|
|
155
|
+
});
|
|
152
156
|
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
2
3
|
import { useSelectInputContext } from "../context";
|
|
4
|
+
import useBaseProps from "../../hooks/useBaseProps";
|
|
3
5
|
export default function Placeholder(props) {
|
|
4
6
|
const {
|
|
5
7
|
prefixCls,
|
|
@@ -7,15 +9,20 @@ export default function Placeholder(props) {
|
|
|
7
9
|
displayValues
|
|
8
10
|
} = useSelectInputContext();
|
|
9
11
|
const {
|
|
10
|
-
|
|
12
|
+
classNames,
|
|
13
|
+
styles
|
|
14
|
+
} = useBaseProps();
|
|
15
|
+
const {
|
|
16
|
+
show = true
|
|
11
17
|
} = props;
|
|
12
18
|
if (displayValues.length) {
|
|
13
19
|
return null;
|
|
14
20
|
}
|
|
15
21
|
return /*#__PURE__*/React.createElement("div", {
|
|
16
|
-
className: `${prefixCls}-placeholder`,
|
|
22
|
+
className: clsx(`${prefixCls}-placeholder`, classNames?.placeholder),
|
|
17
23
|
style: {
|
|
18
|
-
visibility: show ? 'visible' : 'hidden'
|
|
24
|
+
visibility: show ? 'visible' : 'hidden',
|
|
25
|
+
...styles?.placeholder
|
|
19
26
|
}
|
|
20
27
|
}, placeholder);
|
|
21
28
|
}
|
|
@@ -21,7 +21,9 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
21
21
|
const {
|
|
22
22
|
triggerOpen,
|
|
23
23
|
title: rootTitle,
|
|
24
|
-
showSearch
|
|
24
|
+
showSearch,
|
|
25
|
+
classNames,
|
|
26
|
+
styles
|
|
25
27
|
} = useBaseProps();
|
|
26
28
|
const selectContext = React.useContext(SelectContext);
|
|
27
29
|
const [inputChanged, setInputChanged] = React.useState(false);
|
|
@@ -81,7 +83,8 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
81
83
|
}
|
|
82
84
|
}, [combobox, activeValue]);
|
|
83
85
|
return /*#__PURE__*/React.createElement("div", {
|
|
84
|
-
className: `${prefixCls}-content
|
|
86
|
+
className: clsx(`${prefixCls}-content`, classNames?.content),
|
|
87
|
+
style: styles?.content
|
|
85
88
|
}, displayValue ? /*#__PURE__*/React.createElement("div", optionProps, displayValue.label) : /*#__PURE__*/React.createElement(Placeholder, {
|
|
86
89
|
show: !mergedSearchValue
|
|
87
90
|
}), /*#__PURE__*/React.createElement(Input, _extends({
|
|
@@ -3,7 +3,7 @@ import type { ScrollConfig, ScrollTo } from 'rc-virtual-list/lib/List';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import type { DisplayInfoType, DisplayValueType, Mode, Placement, RawValueType, RenderDOMFunc, RenderNode } from '../interface';
|
|
5
5
|
import type { ComponentsConfig } from '../hooks/useComponents';
|
|
6
|
-
export type BaseSelectSemanticName = 'prefix' | 'suffix' | 'input' | 'clear';
|
|
6
|
+
export type BaseSelectSemanticName = 'prefix' | 'suffix' | 'input' | 'clear' | 'placeholder' | 'content' | 'item' | 'itemContent' | 'itemRemove';
|
|
7
7
|
/**
|
|
8
8
|
* ZombieJ:
|
|
9
9
|
* We are currently refactoring the semantic structure of the component. Changelog:
|
package/lib/Select.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
|
|
|
125
125
|
classNames?: Partial<Record<SemanticName, string>>;
|
|
126
126
|
styles?: Partial<Record<SemanticName, React.CSSProperties>>;
|
|
127
127
|
}
|
|
128
|
-
declare const TypedSelect: (<ValueType = any, OptionType extends
|
|
128
|
+
declare const TypedSelect: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: React.PropsWithChildren<SelectProps<ValueType, OptionType>> & React.RefAttributes<BaseSelectRef>) => React.ReactElement) & {
|
|
129
129
|
Option: typeof Option;
|
|
130
130
|
OptGroup: typeof OptGroup;
|
|
131
131
|
};
|
|
@@ -44,7 +44,9 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function Multiple
|
|
|
44
44
|
tagRender: tagRenderFromContext,
|
|
45
45
|
maxTagPlaceholder: maxTagPlaceholderFromContext,
|
|
46
46
|
maxTagTextLength,
|
|
47
|
-
maxTagCount
|
|
47
|
+
maxTagCount,
|
|
48
|
+
classNames,
|
|
49
|
+
styles
|
|
48
50
|
} = (0, _useBaseProps.default)();
|
|
49
51
|
const selectionItemPrefixCls = `${prefixCls}-selection-item`;
|
|
50
52
|
|
|
@@ -74,11 +76,14 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function Multiple
|
|
|
74
76
|
title: (0, _commonUtil.getTitle)(item),
|
|
75
77
|
className: (0, _clsx.clsx)(selectionItemPrefixCls, {
|
|
76
78
|
[`${selectionItemPrefixCls}-disabled`]: itemDisabled
|
|
77
|
-
})
|
|
79
|
+
}, classNames?.item),
|
|
80
|
+
style: styles?.item
|
|
78
81
|
}, /*#__PURE__*/React.createElement("span", {
|
|
79
|
-
className: `${selectionItemPrefixCls}-content
|
|
82
|
+
className: (0, _clsx.clsx)(`${selectionItemPrefixCls}-content`, classNames?.itemContent),
|
|
83
|
+
style: styles?.itemContent
|
|
80
84
|
}, content), closable && /*#__PURE__*/React.createElement(_TransBtn.default, {
|
|
81
|
-
className: `${selectionItemPrefixCls}-remove`,
|
|
85
|
+
className: (0, _clsx.clsx)(`${selectionItemPrefixCls}-remove`, classNames?.itemRemove),
|
|
86
|
+
style: styles?.itemRemove,
|
|
82
87
|
onMouseDown: onPreventMouseDown,
|
|
83
88
|
onClick: onClose,
|
|
84
89
|
customizeIcon: removeIcon
|
|
@@ -138,15 +143,14 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function Multiple
|
|
|
138
143
|
};
|
|
139
144
|
|
|
140
145
|
// ======================= Render =======================
|
|
141
|
-
return /*#__PURE__*/React.createElement(
|
|
142
|
-
show: !searchValue || !triggerOpen
|
|
143
|
-
}), /*#__PURE__*/React.createElement(_rcOverflow.default, {
|
|
146
|
+
return /*#__PURE__*/React.createElement(_rcOverflow.default, {
|
|
144
147
|
prefixCls: `${prefixCls}-content`,
|
|
148
|
+
className: classNames?.content,
|
|
149
|
+
style: styles?.content,
|
|
150
|
+
prefix: !displayValues.length && (!searchValue || !triggerOpen) ? /*#__PURE__*/React.createElement(_Placeholder.default, null) : null,
|
|
145
151
|
data: displayValues,
|
|
146
152
|
renderItem: renderItem,
|
|
147
|
-
renderRest: renderRest
|
|
148
|
-
// suffix={inputNode}
|
|
149
|
-
,
|
|
153
|
+
renderRest: renderRest,
|
|
150
154
|
suffix: /*#__PURE__*/React.createElement(_Input.default, _extends({
|
|
151
155
|
ref: ref,
|
|
152
156
|
disabled: disabled,
|
|
@@ -157,5 +161,5 @@ var _default = exports.default = /*#__PURE__*/React.forwardRef(function Multiple
|
|
|
157
161
|
})),
|
|
158
162
|
itemKey: itemKey,
|
|
159
163
|
maxCount: maxTagCount
|
|
160
|
-
})
|
|
164
|
+
});
|
|
161
165
|
});
|
|
@@ -5,7 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = Placeholder;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _clsx = require("clsx");
|
|
8
9
|
var _context = require("../context");
|
|
10
|
+
var _useBaseProps = _interopRequireDefault(require("../../hooks/useBaseProps"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
14
|
function Placeholder(props) {
|
|
@@ -15,15 +18,20 @@ function Placeholder(props) {
|
|
|
15
18
|
displayValues
|
|
16
19
|
} = (0, _context.useSelectInputContext)();
|
|
17
20
|
const {
|
|
18
|
-
|
|
21
|
+
classNames,
|
|
22
|
+
styles
|
|
23
|
+
} = (0, _useBaseProps.default)();
|
|
24
|
+
const {
|
|
25
|
+
show = true
|
|
19
26
|
} = props;
|
|
20
27
|
if (displayValues.length) {
|
|
21
28
|
return null;
|
|
22
29
|
}
|
|
23
30
|
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
-
className: `${prefixCls}-placeholder`,
|
|
31
|
+
className: (0, _clsx.clsx)(`${prefixCls}-placeholder`, classNames?.placeholder),
|
|
25
32
|
style: {
|
|
26
|
-
visibility: show ? 'visible' : 'hidden'
|
|
33
|
+
visibility: show ? 'visible' : 'hidden',
|
|
34
|
+
...styles?.placeholder
|
|
27
35
|
}
|
|
28
36
|
}, placeholder);
|
|
29
37
|
}
|
|
@@ -30,7 +30,9 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
30
30
|
const {
|
|
31
31
|
triggerOpen,
|
|
32
32
|
title: rootTitle,
|
|
33
|
-
showSearch
|
|
33
|
+
showSearch,
|
|
34
|
+
classNames,
|
|
35
|
+
styles
|
|
34
36
|
} = (0, _useBaseProps.default)();
|
|
35
37
|
const selectContext = React.useContext(_SelectContext.default);
|
|
36
38
|
const [inputChanged, setInputChanged] = React.useState(false);
|
|
@@ -90,7 +92,8 @@ const SingleContent = /*#__PURE__*/React.forwardRef(({
|
|
|
90
92
|
}
|
|
91
93
|
}, [combobox, activeValue]);
|
|
92
94
|
return /*#__PURE__*/React.createElement("div", {
|
|
93
|
-
className: `${prefixCls}-content
|
|
95
|
+
className: (0, _clsx.clsx)(`${prefixCls}-content`, classNames?.content),
|
|
96
|
+
style: styles?.content
|
|
94
97
|
}, displayValue ? /*#__PURE__*/React.createElement("div", optionProps, displayValue.label) : /*#__PURE__*/React.createElement(_Placeholder.default, {
|
|
95
98
|
show: !mergedSearchValue
|
|
96
99
|
}), /*#__PURE__*/React.createElement(_Input.default, _extends({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/select",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.2",
|
|
4
4
|
"description": "React Select",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=8.x"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@rc-component/trigger": "^3.0.0",
|
|
54
54
|
"@rc-component/util": "^1.3.0",
|
|
55
55
|
"clsx": "^2.1.1",
|
|
56
|
-
"rc-overflow": "^1.
|
|
56
|
+
"rc-overflow": "^1.5.0",
|
|
57
57
|
"rc-virtual-list": "^3.5.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|