v-uni-app-ui 1.0.0 → 1.0.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.
Files changed (61) hide show
  1. package/components/config.js +123 -0
  2. package/components/layout/v-card/v-card.vue +108 -0
  3. package/components/layout/v-grid/v-grid.vue +162 -0
  4. package/components/layout/v-icon-grid/v-icon-grid.vue +195 -0
  5. package/components/layout/v-infinite-scroll/v-infinite-scroll.vue +172 -0
  6. package/components/layout/v-list/v-list.vue +43 -0
  7. package/components/layout/v-row/v-row.vue +142 -0
  8. package/components/layout/v-waterfall/v-waterfall.vue +79 -0
  9. package/components/model/compound/v-checkbox-group/v-checkbox-group.vue +96 -0
  10. package/components/model/compound/v-console/v-console.js +20 -0
  11. package/components/model/compound/v-console/v-console.vue +299 -0
  12. package/components/model/compound/v-date-time/v-date-time.vue +261 -0
  13. package/components/model/compound/v-dialog/v-dialog.vue +178 -0
  14. package/components/model/compound/v-drum-select-picker/v-drum-select-picker.vue +83 -0
  15. package/components/model/compound/v-form/v-form.vue +226 -0
  16. package/components/model/compound/v-form-item/v-form-item.vue +255 -0
  17. package/components/model/compound/v-image/v-image.vue +357 -0
  18. package/components/model/compound/v-input-desensitize/v-input-desensitize.vue +101 -0
  19. package/components/model/compound/v-page/v-page.vue +11 -0
  20. package/components/model/compound/v-pages/v-pages.vue +141 -0
  21. package/components/model/compound/v-picker-list/v-picker-list.vue +109 -0
  22. package/components/model/compound/v-popup/v-popup.vue +151 -0
  23. package/components/model/compound/v-radio-group/v-radio-group.vue +86 -0
  24. package/components/model/compound/v-select-picker/v-select-picker.vue +202 -0
  25. package/components/model/compound/v-series-picker-list/v-series-picker-list.vue +221 -0
  26. package/components/model/compound/v-series-select-picker/v-series-select-picker.vue +203 -0
  27. package/components/model/compound/v-switch/v-switch.vue +136 -0
  28. package/components/model/compound/v-tabs-page/v-tabs-page.vue +138 -0
  29. package/components/model/native/v-badge/v-badge.vue +143 -0
  30. package/components/model/native/v-button/v-button.vue +273 -0
  31. package/components/model/native/v-carousel/v-carousel.vue +138 -0
  32. package/components/model/native/v-checkbox/v-checkbox.vue +215 -0
  33. package/components/model/native/v-collapse/v-collapse.vue +190 -0
  34. package/components/model/native/v-header-navigation-bar/v-header-navigation-bar.vue +92 -0
  35. package/components/model/native/v-input/v-input.vue +352 -0
  36. package/components/model/native/v-input-code/v-input-code.vue +146 -0
  37. package/components/model/native/v-loading/v-loading.vue +206 -0
  38. package/components/model/native/v-menu/v-menu.vue +222 -0
  39. package/components/model/native/v-menu-slide/v-menu-slide.vue +364 -0
  40. package/components/model/native/v-min-loading/v-min-loading.vue +80 -0
  41. package/components/model/native/v-null/v-null.vue +97 -0
  42. package/components/model/native/v-overlay/v-overlay.vue +96 -0
  43. package/components/model/native/v-pull-up-refresh/v-pull-up-refresh.vue +157 -0
  44. package/components/model/native/v-radio/v-radio.vue +138 -0
  45. package/components/model/native/v-scroll-list/v-scroll-list.vue +169 -0
  46. package/components/model/native/v-steps/v-steps.vue +253 -0
  47. package/components/model/native/v-table/v-table.vue +203 -0
  48. package/components/model/native/v-tabs/v-tabs.vue +235 -0
  49. package/components/model/native/v-tag/v-tag.vue +206 -0
  50. package/components/model/native/v-text/v-text.vue +187 -0
  51. package/components/model/native/v-text-button/v-text-button.vue +139 -0
  52. package/components/model/native/v-textarea/v-textarea.vue +178 -0
  53. package/components/model/native/v-title/v-title.vue +91 -0
  54. package/components/model/native/v-toast/info.png +0 -0
  55. package/components/model/native/v-toast/success.png +0 -0
  56. package/components/model/native/v-toast/v-toast.vue +198 -0
  57. package/components/model/native/v-toast/warn.png +0 -0
  58. package/components/model/native/v-upload-file-button/v-upload-file-button.vue +296 -0
  59. package/components/model/native/v-video/v-video.vue +175 -0
  60. package/components/model/native/v-window/v-window.vue +158 -0
  61. package/package.json +18 -94
@@ -0,0 +1,215 @@
1
+ <template>
2
+ <label :class="['v-checkbox', { 'v-checkbox--disabled': isDisabled, 'v-checkbox--checked': isChecked, 'v-checkbox--indeterminate': isIndeterminate }]" @click="handleChange">
3
+ <span class="v-checkbox-input">
4
+ <span v-if="isChecked" class="v-checkbox-inner"></span>
5
+ </span>
6
+ <span class="v-checkbox-label">
7
+ <slot>{{ item.label }}</slot>
8
+ </span>
9
+ </label>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { ref, watch, inject, computed } from 'vue';
14
+
15
+ interface CheckboxItem {
16
+ label: string;
17
+ value: string | number | IndeterminateValue;
18
+ }
19
+
20
+ interface IndeterminateValue {
21
+ S: string | number | null;
22
+ A: string | number | null;
23
+ M: string | number | null;
24
+ }
25
+
26
+ const props = defineProps({
27
+ value: {
28
+ type: Array,
29
+ default: () => []
30
+ },
31
+ item: {
32
+ type: Object as () => CheckboxItem,
33
+ required: true
34
+ },
35
+ disabled: {
36
+ type: Boolean,
37
+ default: false
38
+ },
39
+ indeterminate: {
40
+ type: Boolean,
41
+ default: false
42
+ }
43
+ });
44
+
45
+ const emit = defineEmits(['update:value', 'change']);
46
+
47
+ const checkboxGroup = inject('checkboxGroup', null);
48
+
49
+ const isChecked = computed(() => {
50
+ return checkboxGroup ? checkboxGroup.checkedValues.value.some((value: any) => deepEqual(value, props.item.value)) : props.value.some((v) => deepEqual(v, props.item.value));
51
+ });
52
+
53
+ const isDisabled = computed(() => {
54
+ return checkboxGroup ? checkboxGroup.disabled.value || props.disabled : props.disabled;
55
+ });
56
+
57
+ const isIndeterminate = ref(props.indeterminate);
58
+
59
+ const deepEqual = (x: any, y: any): boolean => {
60
+ if (x === y) return true;
61
+
62
+ if (typeof x === 'object' && x !== null && typeof y === 'object' && y !== null) {
63
+ if (Array.isArray(x)) {
64
+ if (!Array.isArray(y) || x.length !== y.length) return false;
65
+ return x.every((item, index) => deepEqual(item, y[index]));
66
+ }
67
+
68
+ const xKeys = Object.keys(x);
69
+ const yKeys = Object.keys(y);
70
+ if (xKeys.length !== yKeys.length) return false;
71
+
72
+ return xKeys.every((key) => {
73
+ return y.hasOwnProperty(key) && deepEqual(x[key], y[key]);
74
+ });
75
+ }
76
+
77
+ return false;
78
+ };
79
+
80
+ watch(
81
+ () => props.value,
82
+ (newVal) => {
83
+ isChecked.value = newVal.some((v) => deepEqual(v, props.item.value));
84
+ },
85
+ { deep: true }
86
+ );
87
+
88
+ watch(
89
+ () => props.indeterminate,
90
+ (newVal) => {
91
+ isIndeterminate.value = newVal;
92
+ }
93
+ );
94
+
95
+ const handleChange = () => {
96
+ if (isDisabled.value) return;
97
+
98
+ let newValues = [...(checkboxGroup ? checkboxGroup.checkedValues.value : props.value)];
99
+ const currentValue = props.item.value;
100
+
101
+ if (checkboxGroup && checkboxGroup.indeterminate) {
102
+ if (!isChecked.value && !isIndeterminate.value) {
103
+ newValues.push(currentValue);
104
+ } else if (isChecked.value && !isIndeterminate.value) {
105
+ newValues = newValues.filter((v) => !deepEqual(v, currentValue));
106
+ }
107
+ } else {
108
+ if (isChecked.value) {
109
+ newValues = newValues.filter((v) => !deepEqual(v, currentValue));
110
+ } else if (isIndeterminate.value) {
111
+ newValues.push(currentValue);
112
+ isIndeterminate.value = false;
113
+ } else {
114
+ isIndeterminate.value = true;
115
+ }
116
+ }
117
+
118
+ if (checkboxGroup) {
119
+ checkboxGroup.checkedValues.value = [...new Set(newValues)];
120
+ } else {
121
+ emit('update:value', [...new Set(newValues)]);
122
+ emit('change', [...new Set(newValues)]);
123
+ }
124
+ };
125
+ </script>
126
+
127
+ <style lang="scss" scoped>
128
+ .v-checkbox {
129
+ display: flex;
130
+ align-items: center;
131
+ cursor: pointer;
132
+ font-size: 14px;
133
+ color: #606266;
134
+ transition: all 0.3s;
135
+ margin-right: 16px;
136
+
137
+ &:last-child {
138
+ margin-right: 0;
139
+ }
140
+
141
+ &--disabled {
142
+ color: #c0c4cc;
143
+ cursor: not-allowed;
144
+
145
+ .v-checkbox-input {
146
+ background-color: #f5f7fa;
147
+ border-color: #e4e7ed;
148
+ cursor: not-allowed;
149
+ }
150
+ }
151
+
152
+ &--checked {
153
+ .v-checkbox-input {
154
+ border-color: #287afa !important;
155
+
156
+ .v-checkbox-inner {
157
+ background-color: #287afa !important;
158
+ display: block !important;
159
+ }
160
+ }
161
+ }
162
+
163
+ &--indeterminate {
164
+ .v-checkbox-input {
165
+ border-color: #287afa !important;
166
+ background-color: #f5f7fa !important;
167
+
168
+ &::after {
169
+ display: block;
170
+ }
171
+ }
172
+ }
173
+
174
+ .v-checkbox-input {
175
+ display: inline-block;
176
+ width: 16px;
177
+ height: 16px;
178
+ border: 1px solid #dcdfe6;
179
+ border-radius: 2px;
180
+ background-color: #fff;
181
+ position: relative;
182
+ margin-right: 8px;
183
+ cursor: pointer;
184
+ transition: all 0.3s;
185
+ vertical-align: middle;
186
+
187
+ .v-checkbox-inner {
188
+ display: none;
189
+ width: 12px;
190
+ height: 12px;
191
+ position: absolute;
192
+ left: 50%;
193
+ top: 50%;
194
+ transform: translate(-50%, -50%);
195
+ }
196
+
197
+ &::after {
198
+ content: '';
199
+ display: none;
200
+ position: absolute;
201
+ left: 5px;
202
+ top: 1px;
203
+ width: 6px;
204
+ height: 12px;
205
+ border: solid #287afa;
206
+ border-width: 0 2px 2px 0;
207
+ transform: rotate(45deg);
208
+ }
209
+ }
210
+
211
+ .v-checkbox-label {
212
+ display: inline-block;
213
+ }
214
+ }
215
+ </style>
@@ -0,0 +1,190 @@
1
+ <template>
2
+ <view class="v-collapse">
3
+ <view v-for="(item, index) in items" :key="index" :class="['collapse-item', { expanded: item.expanded }]">
4
+ <view class="collapse-header" @click="toggleItem(index)">
5
+ <view class="header-title">{{ item.title }}</view>
6
+ <view v-if="!item.isRightIcon" class="header-icon">
7
+ <view class="arrow" :class="{ rotated: item.expanded }"></view>
8
+ </view>
9
+ </view>
10
+ <view class="collapse-content">
11
+ <view class="content-inner">
12
+ <slot name="content" :item="item">
13
+ {{ item.content }}
14
+ </slot>
15
+ </view>
16
+ </view>
17
+ </view>
18
+ </view>
19
+ </template>
20
+
21
+ <script lang="ts" setup>
22
+ import { ref, watch,inject } from 'vue';
23
+
24
+ interface CollapseItem {
25
+ title: string;
26
+ content: string;
27
+ expanded: boolean;
28
+ name?: string;
29
+ isRightIcon?: boolean;
30
+ }
31
+
32
+ const props = defineProps({
33
+ items: {
34
+ type: Array as () => CollapseItem[],
35
+ required: true,
36
+ default: () => []
37
+ },
38
+ accordion: {
39
+ type: Boolean,
40
+ default: true
41
+ },
42
+ activeIndex: {
43
+ type: Number,
44
+ default: 0
45
+ }
46
+ });
47
+
48
+ const emit = defineEmits(['update:activeIndex', 'change']);
49
+
50
+ const config = inject<any>('config');
51
+ const items = ref<CollapseItem[]>([...props.items]);
52
+
53
+ const initExpandedState = () => {
54
+ items.value.forEach((item, index) => {
55
+ item.expanded = index === props.activeIndex;
56
+ });
57
+ };
58
+
59
+ watch(
60
+ () => props.activeIndex,
61
+ (newIndex) => {
62
+ if (props.accordion) {
63
+ items.value.forEach((item, index) => {
64
+ item.expanded = index === newIndex;
65
+ });
66
+ }
67
+ }
68
+ );
69
+
70
+ initExpandedState();
71
+
72
+ const toggleItem = (index: number) => {
73
+ const item = items.value[index];
74
+
75
+ if (props.accordion) {
76
+ items.value.forEach((otherItem, otherIndex) => {
77
+ otherItem.expanded = otherIndex === index ? !item.expanded : false;
78
+ });
79
+ } else {
80
+ item.expanded = !item.expanded;
81
+ }
82
+
83
+ const activeIndex = items.value.findIndex((item) => item.expanded);
84
+ emit('update:activeIndex', activeIndex);
85
+ emit('change', activeIndex);
86
+ };
87
+ </script>
88
+
89
+ <style lang="scss" scoped>
90
+ .v-collapse {
91
+ width: 100%;
92
+ overflow: hidden;
93
+ box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
94
+
95
+ .collapse-item {
96
+ margin-bottom: 12rpx;
97
+ overflow: hidden;
98
+ background: transparent;
99
+ transition: all 0.5s ease;
100
+ border-top: 1rpx solid v-bind("config.border.color");
101
+ border-bottom: 1rpx solid v-bind("config.border.color");
102
+
103
+ &:last-child {
104
+ margin-bottom: 0;
105
+ }
106
+
107
+ .collapse-header {
108
+ display: flex;
109
+ justify-content: space-between;
110
+ align-items: center;
111
+ padding: 18rpx 24rpx;
112
+ font-weight: 600;
113
+ font-size: 24rpx;
114
+ cursor: pointer;
115
+ transition: all 0.3s ease;
116
+ }
117
+
118
+ .header-icon {
119
+ width: 24rpx;
120
+ height: 24rpx;
121
+ display: flex;
122
+ align-items: center;
123
+ justify-content: center;
124
+
125
+ .arrow {
126
+ width: 15rpx;
127
+ height: 15rpx;
128
+ border-right: 4rpx solid v-bind("config.border.color");
129
+ border-bottom: 4rpx solid v-bind("config.border.color");
130
+ transform: rotate(45deg);
131
+ transition: transform 0.5s ease;
132
+ }
133
+
134
+ .rotated {
135
+ transform: rotate(225deg);
136
+ }
137
+ }
138
+
139
+ .collapse-content {
140
+ max-height: 0;
141
+ overflow: hidden;
142
+ transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.5s;
143
+ box-shadow: 0 4rpx 6rpx rgba(0, 0, 0, 0.05);
144
+ }
145
+
146
+ .content-inner {
147
+ padding: 24rpx;
148
+ line-height: 1.7;
149
+ transform: translateY(10rpx);
150
+ opacity: 0;
151
+ transition: transform 0.3s ease, opacity 0.3s ease;
152
+ }
153
+
154
+ &.expanded .collapse-content {
155
+ max-height: 1000rpx;
156
+ }
157
+
158
+ &.expanded .content-inner {
159
+ transform: translateY(0);
160
+ opacity: 1;
161
+ transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
162
+ }
163
+
164
+ // 响应式设计
165
+ @media (max-width: 768px) {
166
+ .collapse-header {
167
+ padding: 16rpx 20rpx;
168
+ font-size: v-bind("config.fontSize.mediumTitle");
169
+ }
170
+
171
+ .content-inner {
172
+ padding: 20rpx;
173
+ font-size: v-bind("config.fontSize.largeText");
174
+ }
175
+ }
176
+
177
+ @media (max-width: 480px) {
178
+ .collapse-header {
179
+ padding: 14rpx 16rpx;
180
+ font-size: v-bind("config.fontSize.smallTitle");
181
+ }
182
+
183
+ .content-inner {
184
+ padding: 16rpx;
185
+ font-size: v-bind("config.fontSize.mediumText");
186
+ }
187
+ }
188
+ }
189
+ }
190
+ </style>
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <view class="v-header-navigation-bar" :style="{ backgroundColor: backgroundColor }">
3
+ <view class="v-header-navigation-bar-left" @click="handleBack">
4
+ <slot name="left">
5
+ <view class="v-header-navigation-bar-back-icon" v-if="showBack"></view>
6
+ </slot>
7
+ </view>
8
+ <view class="v-header-navigation-bar-title">
9
+ <slot>
10
+ <text>{{ title }}</text>
11
+ </slot>
12
+ </view>
13
+ <view class="v-header-navigation-bar-right">
14
+ <slot name="right"></slot>
15
+ </view>
16
+ </view>
17
+ </template>
18
+
19
+ <script lang="ts" setup>
20
+ import { ref,inject } from 'vue';
21
+
22
+ /**
23
+ * v-header-navigation-bar 导航栏
24
+ * title 标题
25
+ * backgroundColor 背景颜色
26
+ * showBack 是否需要返回按钮
27
+ */
28
+ const props = defineProps({
29
+ title: {
30
+ type: String,
31
+ default: ''
32
+ },
33
+ backgroundColor: {
34
+ type: String,
35
+ default: '#ffffff'
36
+ },
37
+ showBack: {
38
+ type: Boolean,
39
+ default: true
40
+ }
41
+ });
42
+
43
+ const emits = defineEmits(['back']);
44
+
45
+ const config = inject<any>('config');
46
+ const handleBack = () => {
47
+ if (props.showBack) {
48
+ emits('back');
49
+ }
50
+ };
51
+ </script>
52
+
53
+ <style lang="scss" scoped>
54
+ .v-header-navigation-bar {
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: space-between;
58
+ padding: 10rpx 16rpx;
59
+ box-sizing: border-box;
60
+ height: 5vh;
61
+ border-bottom: 1px solid v-bind("config.border.color");
62
+ position: relative;
63
+ z-index: 1000;
64
+ }
65
+ .v-header-navigation-bar-left {
66
+ margin-left: 2%;
67
+ }
68
+ .v-header-navigation-bar-left,
69
+ .v-header-navigation-bar-right {
70
+ display: flex;
71
+ align-items: center;
72
+ }
73
+
74
+ .v-header-navigation-bar-back-icon {
75
+ width: 24rpx;
76
+ height: 24rpx;
77
+ border: 4rpx solid v-bind("config.fontColor.mianTitle");
78
+ border-top: none;
79
+ border-right: none;
80
+ transform: rotate(45deg);
81
+ margin-right: 10px;
82
+ cursor: pointer;
83
+ }
84
+
85
+ .v-header-navigation-bar-title {
86
+ flex: 1;
87
+ text-align: center;
88
+ font-size: v-bind("config.fontSize.mediumTitle");
89
+ font-weight: bold;
90
+ color: v-bind("config.fontColor.mianTitle");
91
+ }
92
+ </style>