@elementplus-kit/uikit 1.1.0 → 1.2.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.
@@ -94,9 +94,11 @@ export default defineComponent({
94
94
  }, 0);
95
95
  }
96
96
  };
97
-
97
+
98
98
  const showCount = ref(6); // 显示个数
99
- const searchRef = ref<HTMLDivElement>(null);
99
+ const simpleRef = ref<HTMLDivElement>(null);
100
+ const simpleFormRef = ref<HTMLDivElement>(null);
101
+ const simpleBtnRef = ref<HTMLDivElement>(null);
100
102
  const cFormRef = ref<HTMLDivElement>(null);
101
103
  const calcFlg = ref(false); // 计算宽度后再显示表单
102
104
  const childW = ref([]);
@@ -114,9 +116,9 @@ export default defineComponent({
114
116
 
115
117
  // 初次计算显示个数
116
118
  const calcSunInit = () => {
117
- if (searchRef.value) {
119
+ if (simpleFormRef.value) {
118
120
  // 寻找cForm 先写死 后期做成动态寻找
119
- const cFormDom = searchRef.value.children[0];
121
+ const cFormDom = simpleFormRef.value.children[0];
120
122
  const cFormW = cFormDom.offsetWidth;
121
123
  // 收集子元素宽度并保存到数组中
122
124
  const cW = [];
@@ -128,7 +130,7 @@ export default defineComponent({
128
130
  // marginR.push(mgValue);
129
131
  cW.push(child.offsetWidth + mgValue); // 把mg加上 mg 一般不会变 为了避免多次计算
130
132
  });
131
- childW.value = cW;
133
+ childW.value = cW; // 储存子元素宽度
132
134
  childW.value.reduce((pre, cur, index) => {
133
135
  if (pre > cFormW) {
134
136
  return 10000; // 终止累加
@@ -139,19 +141,13 @@ export default defineComponent({
139
141
  }
140
142
  return pre + cur;
141
143
  }, 0);
142
-
143
- // 得到结果后 显示表单
144
- calcFlg.value = true;
145
- // offsetWidth
146
- // clientWidth
147
- // classList
148
144
  }
149
145
  };
150
146
  // 变化时计算显示个数
151
147
  const calcSunResize = () => {
152
- if (searchRef.value) {
148
+ if (simpleFormRef.value) {
153
149
  // 寻找cForm 先写死 后期做成动态寻找
154
- const cFormDom = searchRef.value.children[0];
150
+ const cFormDom = simpleFormRef.value.children[0];
155
151
  const cFormW = cFormDom.offsetWidth;
156
152
  childW.value.reduce((pre, cur, index) => {
157
153
  if (pre > cFormW) {
@@ -182,9 +178,9 @@ export default defineComponent({
182
178
  <div className="c-search">
183
179
  <div
184
180
  className="c-search-simple"
185
- style={calcFlg.value ? "" : "opacity: 0;"}
181
+ ref={simpleRef}
186
182
  >
187
- <div className="c-search-simple-form" ref={searchRef}>
183
+ <div className="c-search-simple-form" ref={simpleFormRef}>
188
184
  <CForm
189
185
  ref={(el) => (cFormRef.value = el)}
190
186
  {...getEvent()}
@@ -197,13 +193,12 @@ export default defineComponent({
197
193
  {getSlot()}
198
194
  </CForm>
199
195
  </div>
200
- <div className="c-search-simple-btn">
196
+ <div className="c-search-simple-btn" ref={simpleBtnRef}>
201
197
  {slots["btn-left"]?.()}
202
198
  {showCount.value < props.formOptions?.length && (
203
199
  <div
204
- className={`c-search-simple-icon ${
205
- showSearchForm.value ? "icon-rotate" : ""
206
- }`}
200
+ className={`c-search-simple-icon ${showSearchForm.value ? "icon-rotate" : ""
201
+ }`}
207
202
  onClick={handleShow}
208
203
  >
209
204
  <el-icon className="el-icon c-search-icon">
@@ -12,7 +12,13 @@
12
12
  justify-content: space-between;
13
13
  }
14
14
  .c-search-simple-form {
15
- flex: 1;
15
+ flex: 1; // 占满剩余空间
16
+ overflow: auto; // 开启滚动条
17
+ // 滚动条宽度
18
+ scrollbar-width: none; // 隐藏滚动条
19
+ > .c-form {
20
+ white-space: nowrap; // 防止表单内容换行
21
+ }
16
22
  }
17
23
  .c-search-simple-btn {
18
24
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementplus-kit/uikit",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "./components/index.ts",
6
6
  "peerDependencies": {