stellar-ui-plus 1.25.7 → 1.25.9

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.
@@ -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/index.ts CHANGED
@@ -120,6 +120,8 @@ import steSearchBox from "./components/ste-search-box/ste-search-box.vue"
120
120
  export const SteSearchBox = steSearchBox
121
121
  import steSelect from "./components/ste-select/ste-select.vue"
122
122
  export const SteSelect = steSelect
123
+ import steSelectOrder from "./components/ste-select-order/ste-select-order.vue"
124
+ export const SteSelectOrder = steSelectOrder
123
125
  import steSelectSeat from "./components/ste-select-seat/ste-select-seat.vue"
124
126
  export const SteSelectSeat = steSelectSeat
125
127
  import steSignature from "./components/ste-signature/ste-signature.vue"
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.9",
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
  }
@@ -59,6 +59,7 @@ import steScrollToItem from "../components/ste-scroll-to-item/ste-scroll-to-item
59
59
  import steSearch from "../components/ste-search/ste-search.vue"
60
60
  import steSearchBox from "../components/ste-search-box/ste-search-box.vue"
61
61
  import steSelect from "../components/ste-select/ste-select.vue"
62
+ import steSelectOrder from "../components/ste-select-order/ste-select-order.vue"
62
63
  import steSelectSeat from "../components/ste-select-seat/ste-select-seat.vue"
63
64
  import steSignature from "../components/ste-signature/ste-signature.vue"
64
65
  import steSimpleCalendar from "../components/ste-simple-calendar/ste-simple-calendar.vue"
@@ -155,6 +156,7 @@ import steWatermark from "../components/ste-watermark/ste-watermark.vue"
155
156
  SteSearch: typeof steSearch;
156
157
  SteSearchBox: typeof steSearchBox;
157
158
  SteSelect: typeof steSelect;
159
+ SteSelectOrder: typeof steSelectOrder;
158
160
  SteSelectSeat: typeof steSelectSeat;
159
161
  SteSignature: typeof steSignature;
160
162
  SteSimpleCalendar: typeof steSimpleCalendar;
@@ -59,6 +59,7 @@ import steScrollToItem from "../components/ste-scroll-to-item/ste-scroll-to-item
59
59
  import steSearch from "../components/ste-search/ste-search.vue"
60
60
  import steSearchBox from "../components/ste-search-box/ste-search-box.vue"
61
61
  import steSelect from "../components/ste-select/ste-select.vue"
62
+ import steSelectOrder from "../components/ste-select-order/ste-select-order.vue"
62
63
  import steSelectSeat from "../components/ste-select-seat/ste-select-seat.vue"
63
64
  import steSignature from "../components/ste-signature/ste-signature.vue"
64
65
  import steSimpleCalendar from "../components/ste-simple-calendar/ste-simple-calendar.vue"
@@ -150,6 +151,7 @@ export type RefScrollToItem = InstanceType<typeof steScrollToItem>
150
151
  export type RefSearch = InstanceType<typeof steSearch>
151
152
  export type RefSearchBox = InstanceType<typeof steSearchBox>
152
153
  export type RefSelect = InstanceType<typeof steSelect>
154
+ export type RefSelectOrder = InstanceType<typeof steSelectOrder>
153
155
  export type RefSelectSeat = InstanceType<typeof steSelectSeat>
154
156
  export type RefSignature = InstanceType<typeof steSignature>
155
157
  export type RefSimpleCalendar = InstanceType<typeof steSimpleCalendar>
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
  // 测试环境判断