stellar-ui-plus 1.25.7 → 1.25.8

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ste-radio",
3
3
  "description": "单选框组件, 在一组备选项中进行单选。",
4
- "example": "<ste-checkbox>单选框</ste-checkbox>",
4
+ "example": "<ste-radio>单选框</ste-radio>",
5
5
  "tutorial": "https://stellar-ui.intecloud.com.cn/?projectName=stellar-ui-plus&menu=%E7%BB%84%E4%BB%B6&active=ste-radio",
6
6
  "attributes": [
7
7
  {
@@ -114,11 +114,11 @@
114
114
  },
115
115
  {
116
116
  "name": "[event]click",
117
- "description": "点击复选框时触发的事件",
117
+ "description": "点击单选框时触发的事件",
118
118
  "params": [
119
119
  {
120
120
  "name": "value",
121
- "description": "当前复选框的绑定值"
121
+ "description": "当前单选框的绑定值"
122
122
  },
123
123
  {
124
124
  "name": "suspend",
@@ -140,7 +140,7 @@
140
140
  "params": [
141
141
  {
142
142
  "name": "value",
143
- "description": "当前复选框的绑定值"
143
+ "description": "当前单选框的绑定值"
144
144
  }
145
145
  ]
146
146
  }
@@ -312,12 +312,6 @@
312
312
 
313
313
  ---$
314
314
 
315
- ## API
316
-
317
- ## Props
318
-
319
- 背景之外的颜色属性只支持`16进制`、`RGB`、`RGBA`格式
320
-
321
315
  <!-- props -->
322
316
 
323
317
  ---$
@@ -0,0 +1,61 @@
1
+ # SelectOrder 订单选择
2
+
3
+ - 用于选择订单的下拉选择组件
4
+
5
+ ---$
6
+
7
+ ## 使用示例
8
+
9
+ ## 基础用法
10
+
11
+ - 属性`list`接收一个数组,数组中的每一项为一个对象,对象中包含`label`和`value`两个属性,分别表示节点的显示文本和节点的值
12
+ - 若`label`和`value`属性字段名不同,可通过`labelKey`和`valueKey`属性进行设置
13
+ - 属性`modelValue`接收一个值,表示当前选中的节点值,支持v-model双向绑定
14
+ - 事件`change`在节点值改变时触发,返回当前选中的值和选项对象
15
+
16
+ ```html
17
+ <template>
18
+ <ste-select-order :list="list" v-model="value" @change="onChange"></ste-select-order>
19
+ </template>
20
+ <script lang="ts" setup>
21
+ import { ref } from 'vue';
22
+ const value = ref(null);
23
+ const list = ref([
24
+ { label: '全部订单', value: 'all' },
25
+ { label: '待付款', value: 'pending' },
26
+ { label: '待发货', value: 'unshipped' },
27
+ { label: '待收货', value: 'unreceived' },
28
+ { label: '已完成', value: 'completed' },
29
+ ]);
30
+
31
+ function onChange(val, option) {
32
+ console.log(val, option);
33
+ }
34
+ </script>
35
+ ```
36
+
37
+ ## 禁用状态
38
+
39
+ - 属性`disabled`设置为`true`时,组件将被禁用
40
+
41
+ ```html
42
+ <template>
43
+ <ste-select-order :list="list" v-model="value" disabled></ste-select-order>
44
+ </template>
45
+ <script lang="ts" setup>
46
+ import { ref } from 'vue';
47
+ const value = ref(null);
48
+ const list = ref([
49
+ { label: '全部订单', value: 'all' },
50
+ { label: '待付款', value: 'pending' },
51
+ { label: '待发货', value: 'unshipped' },
52
+ ]);
53
+ </script>
54
+ ```
55
+
56
+ ---$
57
+
58
+ <!-- props -->
59
+
60
+ ---$
61
+ {{xuyajun}}
@@ -0,0 +1,5 @@
1
+ {
2
+ "group": "业务组件",
3
+ "title": "SelectOrder 订单选择",
4
+ "icon": "https://image.whzb.com/chain/StellarUI/%E7%BB%84%E4%BB%B6%E5%9B%BE%E6%A0%87/progress.png"
5
+ }
@@ -0,0 +1,30 @@
1
+ import type { PropType } from 'vue';
2
+
3
+ export interface SelectOption {
4
+ label?: string;
5
+ value: string | number;
6
+ disabled?: boolean;
7
+ [key: string]: any;
8
+ }
9
+
10
+ export type SelectValue = string | number | null | undefined;
11
+
12
+ export interface SteSelectOrderProps {
13
+ modelValue: SelectValue;
14
+ list: SelectOption[];
15
+ placeholder: string;
16
+ labelKey: string;
17
+ valueKey: string;
18
+ disabled: boolean;
19
+ maskClose: boolean;
20
+ }
21
+
22
+ export default {
23
+ modelValue: { type: [String, Number, null, undefined] as PropType<SelectValue>, default: undefined },
24
+ list: { type: Array as PropType<SelectOption[]>, default: () => [] },
25
+ placeholder: { type: String, default: '请选择' },
26
+ labelKey: { type: String, default: 'label' },
27
+ valueKey: { type: String, default: 'value' },
28
+ disabled: { type: Boolean, default: false },
29
+ maskClose: { type: Boolean, default: true },
30
+ };
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "ste-select-order",
3
+ "description": "订单选择",
4
+ "example": "<ste-select-order />",
5
+ "tutorial": "https://stellar-ui.intecloud.com.cn/?projectName=stellar-ui-plus&menu=%E7%BB%84%E4%BB%B6&active=ste-select-order",
6
+ "attributes": [
7
+ {
8
+ "name": "modelValue",
9
+ "description": "绑定的值,支持v-model双向绑定",
10
+ "type": "string | number | null | undefined"
11
+ },
12
+ {
13
+ "name": "list",
14
+ "description": "选项数据,每个选项支持 disabled 属性设置单项禁止选择",
15
+ "type": "SelectOption[]",
16
+ "default": []
17
+ },
18
+ {
19
+ "name": "placeholder",
20
+ "description": "占位符",
21
+ "type": "string",
22
+ "default": "请选择"
23
+ },
24
+ {
25
+ "name": "labelKey",
26
+ "description": "选项标签Key",
27
+ "type": "string",
28
+ "default": "label"
29
+ },
30
+ {
31
+ "name": "valueKey",
32
+ "description": "选项值Key",
33
+ "type": "string",
34
+ "default": "value"
35
+ },
36
+ {
37
+ "name": "disabled",
38
+ "description": "禁用状态",
39
+ "type": "boolean",
40
+ "default": false
41
+ },
42
+ {
43
+ "name": "maskClose",
44
+ "description": "点击遮罩层是否关闭弹窗",
45
+ "type": "boolean",
46
+ "default": true
47
+ },
48
+ {
49
+ "name": "[event]update:modelValue",
50
+ "description": "选中值改变时触发",
51
+ "params": [
52
+ {
53
+ "name": "value",
54
+ "description": "选中的值"
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ "name": "[event]change",
60
+ "description": "选中值改变时触发",
61
+ "params": [
62
+ {
63
+ "name": "value",
64
+ "description": "选中的值"
65
+ },
66
+ {
67
+ "name": "option",
68
+ "description": "选中的选项对象"
69
+ }
70
+ ]
71
+ }
72
+ ]
73
+ }
@@ -0,0 +1,276 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref, watch, nextTick, getCurrentInstance, onMounted } from 'vue';
3
+ import propsData, { type SelectOption } from './props';
4
+ import { useColorStore } from '../../store/color';
5
+ import utils from '../../utils/utils';
6
+
7
+ defineOptions({
8
+ name: 'ste-select-order',
9
+ options: {
10
+ virtualHost: true,
11
+ },
12
+ });
13
+
14
+ const thas = ref()
15
+
16
+ onMounted(() => {
17
+ thas.value = getCurrentInstance()?.proxy
18
+ })
19
+
20
+ const { getColor } = useColorStore();
21
+ const props = defineProps(propsData);
22
+ const emits = defineEmits<{
23
+ (e: 'update:modelValue', value: string | number | undefined): void;
24
+ (e: 'change', value: string | number | undefined, option: SelectOption | undefined): void;
25
+ }>();
26
+
27
+ const open = ref(false);
28
+ const viewValue = ref(props.modelValue);
29
+ const isUpward = ref(false);
30
+
31
+ watch(() => props.modelValue, (newVal) => {
32
+ if (newVal !== viewValue.value) {
33
+ viewValue.value = newVal;
34
+ }
35
+ });
36
+
37
+ const onTouchMove = (e: TouchEvent) => {
38
+ // 只有在展开状态下才阻止动
39
+ if (open.value) {
40
+ e.preventDefault();
41
+ }
42
+ };
43
+
44
+ const cmpRootStyle = computed(() => ({
45
+ '--theme-color': getColor()?.steThemeColor || '#0090FF',
46
+ }));
47
+
48
+ const viewTitle = computed(() => {
49
+ if (!viewValue.value) return '';
50
+ const item = props.list.find(item => item[props.valueKey] === viewValue.value);
51
+ return item ? (item[props.labelKey] as string) || String(item[props.valueKey]) : String(viewValue.value);
52
+ });
53
+
54
+ const calculatePosition = async () => {
55
+ const header = await utils.querySelector(".ste-select-order-header", thas.value)
56
+ if (!header) return;
57
+ const vh = utils.System.getWindowHeight()
58
+ const { top, height } = header as any
59
+ const position = top + height / 2;
60
+ const middle = vh / 2;
61
+ isUpward.value = position > middle;
62
+ };
63
+
64
+ const onTitleClick = async () => {
65
+ if (props.disabled) return;
66
+ if (!open.value) {
67
+ await calculatePosition();
68
+ }
69
+ await nextTick()
70
+ open.value = !open.value;
71
+ };
72
+
73
+ const onShadeClick = () => {
74
+ if (props.maskClose) {
75
+ open.value = false;
76
+ }
77
+ };
78
+
79
+ const onSelect = (item: SelectOption) => {
80
+ if (item.disabled) return;
81
+ const val = item[props.valueKey];
82
+ if (val === viewValue.value || props.disabled) return;
83
+ viewValue.value = val;
84
+ emits('update:modelValue', val);
85
+ emits('change', val, item);
86
+ setTimeout(() => {
87
+ open.value = false;
88
+ }, 300);
89
+ };
90
+ </script>
91
+
92
+ <template>
93
+ <view class="ste-select-order-root" :class="{ open, disabled: props.disabled }" :style="[cmpRootStyle]">
94
+ <view class="ste-select-order-shade" @click="onShadeClick" @touchmove.stop="onTouchMove"></view>
95
+ <view class="ste-select-order-content" :class="{ 'is-upward': isUpward }" @click.stop="onTitleClick"
96
+ @touchmove.stop="onTouchMove">
97
+ <view class="ste-select-order-header">
98
+ <view class="ste-select-order-title" v-if="viewTitle">
99
+ <view class="ste-select-order-title-text">
100
+ {{ viewTitle }}
101
+ </view>
102
+ <ste-icon code="&#xe698;" v-if="open" />
103
+ <ste-icon code="&#xe699;" v-else />
104
+ </view>
105
+ <view class="ste-select-order-placeholder" v-else>{{ placeholder }}</view>
106
+ </view>
107
+ <view class="ste-select-order-list">
108
+ <view v-for="item in props.list" :key="item[props.valueKey]" class="ste-select-order-item"
109
+ :class="{ 'active': item[props.valueKey] === viewValue, 'disabled': item.disabled }"
110
+ @click.stop="onSelect(item)">
111
+ <view>{{ (item[props.labelKey] as string) || item[props.valueKey] }}</view>
112
+ <view class="ste-select-order-item-icon">
113
+ <ste-icon code="&#xe67a;" />
114
+ </view>
115
+ </view>
116
+ </view>
117
+ </view>
118
+ </view>
119
+ </template>
120
+
121
+ <style scoped lang="scss">
122
+ .ste-select-order-root {
123
+ position: relative;
124
+ z-index: 1;
125
+ width: 100%;
126
+ font-size: 32rpx;
127
+ color: #000;
128
+ transition: z-index 0.3s ease;
129
+
130
+ &.open {
131
+ z-index: 998;
132
+
133
+ .ste-select-order-shade {
134
+ display: block;
135
+ opacity: 1;
136
+ }
137
+
138
+ .ste-select-order-content {
139
+
140
+ .ste-select-order-header {
141
+ background-color: #fff;
142
+ border-radius: 16rpx 16rpx 0 0;
143
+ }
144
+
145
+ .ste-select-order-list {
146
+ display: block;
147
+ background-color: #fff;
148
+ border-radius: 0 0 16rpx 16rpx;
149
+ position: absolute;
150
+ left: 0;
151
+ top: 100%;
152
+ width: 100%;
153
+ }
154
+
155
+ &.is-upward {
156
+ .ste-select-order-header {
157
+ border-radius: 0 0 16rpx 16rpx;
158
+ }
159
+
160
+ .ste-select-order-list {
161
+ top: initial;
162
+ bottom: 100%;
163
+ border-radius: 16rpx 16rpx 0 0;
164
+ }
165
+ }
166
+ }
167
+ }
168
+
169
+ &.disabled {
170
+ opacity: 0.6;
171
+
172
+ .ste-select-order-title,
173
+ .ste-select-order-placeholder {
174
+ color: #ccc;
175
+ }
176
+ }
177
+
178
+ .ste-select-order-shade {
179
+ position: fixed;
180
+ top: 0;
181
+ left: 0;
182
+ right: 0;
183
+ bottom: 0;
184
+ background-color: rgba(0, 0, 0, 0.5);
185
+ display: none;
186
+ opacity: 0;
187
+ z-index: 1;
188
+ }
189
+
190
+ .ste-select-order-content {
191
+ width: 100%;
192
+ position: relative;
193
+ z-index: 2;
194
+
195
+ .ste-select-order-header {
196
+ padding: 28rpx 24rpx 24rpx 24rpx;
197
+ font-size: var(--font-size-32, 32rpx);
198
+ line-height: var(--font-size-44, 44rpx);
199
+ font-weight: bold;
200
+
201
+ .ste-select-order-placeholder,
202
+ .ste-select-order-title {
203
+ display: flex;
204
+ align-items: center;
205
+ }
206
+
207
+ .ste-select-order-title {
208
+ color: #0A0A0A;
209
+
210
+ .ste-select-order-title-text {
211
+ margin-right: 12rpx;
212
+ }
213
+ }
214
+
215
+ .ste-select-order-placeholder {
216
+ color: #999;
217
+ }
218
+ }
219
+
220
+ .ste-select-order-list {
221
+ display: none;
222
+
223
+ z-index: 2;
224
+ max-height: 480rpx;
225
+ overflow-y: auto;
226
+ border-top: 1px solid #F9F9F9;
227
+ background-color: #fff;
228
+ padding: 0 24rpx;
229
+
230
+ .ste-select-order-item {
231
+ padding: 24rpx 0;
232
+ font-size: var(--font-size-28, 28rpx);
233
+ line-height: var(--font-size-40, 40rpx);
234
+ display: flex;
235
+ align-items: center;
236
+ justify-content: space-between;
237
+ color: #0A0A0A;
238
+ transition: color 0.2s ease;
239
+
240
+ &+.ste-select-order-item {
241
+ border-top: 1px solid #F9F9F9;
242
+ }
243
+
244
+ .ste-select-order-item-icon {
245
+ width: 36rpx;
246
+ height: 36rpx;
247
+ border-radius: 50%;
248
+ border: 1px solid #CECECE;
249
+ color: #fff;
250
+ display: flex;
251
+ align-items: center;
252
+ justify-content: center;
253
+ }
254
+
255
+ &.active {
256
+ color: var(--theme-color);
257
+
258
+ .ste-select-order-item-icon {
259
+ border-color: var(--theme-color);
260
+ background-color: var(--theme-color);
261
+ }
262
+ }
263
+
264
+ &.disabled {
265
+ color: #999;
266
+
267
+ .ste-select-order-item-icon {
268
+ border-color: #E0E0E0;
269
+ background-color: #F5F5F5;
270
+ }
271
+ }
272
+ }
273
+ }
274
+ }
275
+ }
276
+ </style>
@@ -1,12 +1,12 @@
1
1
  <script lang="ts" setup>
2
- import { computed, watch, ref, type CSSProperties, toRaw, nextTick } from 'vue';
2
+ import { computed, watch, ref, type CSSProperties, toRaw } from 'vue';
3
3
  import propsData, { TABLE_KEY, tableEmits, CHECK_ICON_SIZE, SELECTION_COLOR_CONFIG, type TableProps } from './props';
4
4
  import utils from '../../utils/utils';
5
5
  import { useProvide } from '../../utils/mixin';
6
6
  import useData from './useData';
7
7
  import type { TableColumnProps } from '../ste-table-column/props';
8
8
  import { useColorStore } from '../../store/color';
9
- let { getColor } = useColorStore();
9
+ const { getColor } = useColorStore();
10
10
 
11
11
  const componentName = `ste-table`;
12
12
  defineOptions({
@@ -82,14 +82,14 @@ const cmpRootClass = computed(() => {
82
82
  if (props.stripe) {
83
83
  classArr.push('stripe');
84
84
  }
85
- if (props.height || Number(props.height) > 0) {
85
+ if (Number(props.height) > 0) {
86
86
  classArr.push('scroll-table');
87
87
  }
88
88
  return classArr.join(' ');
89
89
  });
90
90
 
91
91
  const cmpShowFixedPlaceholder = computed(() => {
92
- return props.fixed || props.height || Number(props.height) > 0 || props.maxHeight || Number(props.maxHeight) > 0;
92
+ return props.fixed || Number(props.height) > 0 || Number(props.maxHeight) > 0;
93
93
  });
94
94
 
95
95
  const dataChangeFun = (fullLength: number = 0, val: any) => {
@@ -300,38 +300,7 @@ defineExpose({ clearSelection, toggleAllSelection, toggleRowSelection, getSelect
300
300
  </view>
301
301
  </view>
302
302
  </view>
303
- <template v-if="height || Number(height) > 0">
304
- <scroll-view scroll-y class="ste-table-scroll" @scrolltolower="handleScrollToLower">
305
- <view class="ste-table-body" :class="!tableData.length ? 'no-data' : ''">
306
- <template v-if="tableData.length">
307
- <view
308
- class="ste-table-row"
309
- :class="[getRowClass(row, rowIndex)]"
310
- :style="[getRowStyle(row, rowIndex) as CSSProperties]"
311
- v-for="(row, rowIndex) in tableData"
312
- :key="rowIndex"
313
- @click="rowClick(row, $event)"
314
- >
315
- <slot :row="row" name="default"></slot>
316
- </view>
317
- <view class="ste-table-row sum" v-if="showSummary">
318
- <view class="ste-table-cell" v-for="(column, index) in columns" :key="index" :class="[getHeaderCellClass(column, 0)]">
319
- <view class="cell-box">
320
- <view v-if="index === 0" class="sum-header">{{ sumText }}</view>
321
- <view v-else>
322
- {{ sumData[index] || '-' }}
323
- </view>
324
- </view>
325
- </view>
326
- </view>
327
- </template>
328
- <template v-else>
329
- <text class="no-data-text">- 暂无数据 -</text>
330
- </template>
331
- </view>
332
- </scroll-view>
333
- </template>
334
- <template v-else>
303
+ <scroll-view :scroll-y="Number(height) > 0" class="ste-table-scroll" @scrolltolower="handleScrollToLower">
335
304
  <view class="ste-table-body" :class="!tableData.length ? 'no-data' : ''">
336
305
  <template v-if="tableData.length">
337
306
  <view
@@ -339,6 +308,7 @@ defineExpose({ clearSelection, toggleAllSelection, toggleRowSelection, getSelect
339
308
  :class="[getRowClass(row, rowIndex)]"
340
309
  :style="[getRowStyle(row, rowIndex) as CSSProperties]"
341
310
  v-for="(row, rowIndex) in tableData"
311
+ :key="rowIndex"
342
312
  @click="rowClick(row, $event)"
343
313
  >
344
314
  <slot :row="row"></slot>
@@ -358,7 +328,7 @@ defineExpose({ clearSelection, toggleAllSelection, toggleRowSelection, getSelect
358
328
  <text class="no-data-text">- 暂无数据 -</text>
359
329
  </template>
360
330
  </view>
361
- </template>
331
+ </scroll-view>
362
332
  </view>
363
333
  </view>
364
334
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellar-ui-plus",
3
- "version": "1.25.7",
3
+ "version": "1.25.8",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -11,7 +11,6 @@
11
11
  },
12
12
  "scripts": {
13
13
  "test": "echo \"Error: no test specified\" && exit 1",
14
- "publish-vscode-plugin": "cd ../../../plugins/ste-helper & pnpm run publish",
15
- "prepublishOnly": "pnpm run publish-vscode-plugin"
14
+ "publish-vscode-plugin": "cd ../../../plugins/ste-helper & pnpm run publish"
16
15
  }
17
16
  }
package/utils/System.ts CHANGED
@@ -65,7 +65,7 @@ export default class System {
65
65
  /**
66
66
  * 获取窗口信息(结果已缓存,同一 App 生命周期内只调用一次系统 API)
67
67
  */
68
- static getWindowInfo() {
68
+ static getWindowInfo(): WindowInfo {
69
69
  if (_cachedWindowInfo) return _cachedWindowInfo;
70
70
 
71
71
  // 测试环境判断