Skip to content

Commit 8cc7836

Browse files
authored
refactor: Semantic structure re-layout (#1166)
* chore: init * of it * chore: of it * chore: fill content * chore: style * chore: style * chore: basic content * chore: blur clear * chore: clear logic * chore: fit logic * chore: connect logic * chore: fix logic * chore: fix logic * chore: adjust omit position * chore: adjust omit position * chore: adjust omit position * test: more test * chore: test config * chore: test config * chore: adjust logic * chore: backfill * chore: lots of logic * chore: lots of logic * chore: connect combobox * test: fix test * chore: add polit * chore: mv code * chore: multiple * chore: multiple of it * chore: clean up * chore: fix logic * chore: fix logic * test: batch update * test: batch update * fix: display logic * fix: display logic * test: update snapshot * chore: more logic * chore: more * chore: more and more * test: update snapshot * test: update snapshot * test: base test * chore: update * chore: update * test: fix test * chore: adjust cls * chore: multiple default search * chore: of it * chore: of it * test: all of multiple * chore: clean up * chore: adjust logic * chore: replace components * chore: support components * chore: of it * chore: new logic of passing * chore: fix input logic * test: fix test * test: fix test * chore: fix combobox logic * chore: fix ref * chore: all test * chore: clean up * chore: clean up * chore: clean up * chore: adjust import * chore: rm useless file * chore: clean up * chore: clean up * test: coverage * test: coverage
1 parent c2dc268 commit 8cc7836

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1999
-2582
lines changed

assets/index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@select-prefix: ~'rc-select';
2+
@import url('./patch.less');
23

34
* {
45
box-sizing: border-box;

assets/patch.less

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// This is used for semantic refactoring
2+
@import (reference) url('./index.less');
3+
4+
.@{select-prefix}.@{select-prefix} {
5+
display: inline-flex;
6+
align-items: center;
7+
user-select: none;
8+
border: 1px solid blue;
9+
position: relative;
10+
11+
// Content 部分自动占据剩余宽度
12+
.@{select-prefix}-content {
13+
flex: auto;
14+
display: flex;
15+
align-items: center;
16+
/* Prevent content from wrapping */
17+
min-width: 0; /* allow flex item to shrink */
18+
white-space: nowrap;
19+
overflow: hidden;
20+
text-overflow: ellipsis;
21+
position: relative;
22+
}
23+
24+
.@{select-prefix}-input {
25+
border: none;
26+
background: transparent;
27+
}
28+
29+
.@{select-prefix}-placeholder {
30+
opacity: 0.5;
31+
32+
&::after {
33+
content: '\00a0'; // nbsp placeholder
34+
width: 0;
35+
overflow: hidden;
36+
}
37+
}
38+
39+
.@{select-prefix}-content,
40+
.@{select-prefix}-input,
41+
.@{select-prefix}-placeholder {
42+
padding: 0;
43+
margin: 0;
44+
line-height: 1.5;
45+
font-size: 14px;
46+
font-weight: normal;
47+
}
48+
49+
// 其他部分禁止自动宽度,使用内容宽度
50+
.@{select-prefix}-prefix,
51+
.@{select-prefix}-suffix,
52+
.@{select-prefix}-clear {
53+
flex: none;
54+
}
55+
56+
.@{select-prefix}-clear {
57+
position: absolute;
58+
top: 0;
59+
right: 0;
60+
}
61+
62+
// ============================= Single =============================
63+
&-single {
64+
.@{select-prefix}-input {
65+
position: absolute;
66+
inset: 0;
67+
}
68+
}
69+
70+
// ============================ Multiple ============================
71+
&-multiple {
72+
.@{select-prefix}-selection-item {
73+
background: rgba(0, 0, 0, 0.1);
74+
border-radius: 8px;
75+
margin-right: 4px;
76+
}
77+
78+
.@{select-prefix}-input {
79+
width: calc(var(--select-input-width, 10) * 1px);
80+
min-width: 4px;
81+
}
82+
}
83+
}

docs/examples/multiple-with-maxCount.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const Test: React.FC = () => {
1414
<>
1515
<h2>Multiple with maxCount</h2>
1616
<Select
17+
showSearch
1718
maxCount={4}
1819
mode="multiple"
1920
value={value}

docs/examples/multiple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Test extends React.Component {
9999
style={{ width: 500 }}
100100
mode="multiple"
101101
loading={loading}
102-
suffixIcon={suffixIcon}
102+
suffix={suffixIcon}
103103
allowClear
104104
optionFilterProp="children"
105105
optionLabelProp="children"

jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
3+
collectCoverage: true,
4+
collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}'],
5+
};

0 commit comments

Comments
 (0)