@truenewx/tnxvue3 3.4.4 → 3.4.6

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 (35) hide show
  1. package/package.json +18 -17
  2. package/src/bootstrap-vue/dialog/Dialog.vue +22 -10
  3. package/src/bootstrap-vue/select/Select.vue +3 -4
  4. package/src/components/ScrollView.vue +69 -0
  5. package/src/css.d.ts +4 -0
  6. package/src/element-plus/aj-captcha/utils/ase.js +4 -4
  7. package/src/element-plus/dialog/Dialog.vue +19 -7
  8. package/src/element-plus/drawer/Drawer.vue +20 -3
  9. package/src/element-plus/fss-upload/FssUpload.vue +1 -1
  10. package/src/element-plus/icon/Icon.vue +3 -0
  11. package/src/element-plus/select/Select.vue +3 -4
  12. package/src/element-plus/tnxel.css +0 -8
  13. package/src/element-plus/tnxel.ts +58 -72
  14. package/src/tdesign/mobile/calendar/Calendar.vue +121 -0
  15. package/src/tdesign/mobile/date-time-picker/DateTimePicker.vue +147 -0
  16. package/src/tdesign/mobile/dialog/Dialog.vue +179 -0
  17. package/src/tdesign/mobile/dialog/DialogContent.vue +13 -0
  18. package/src/tdesign/mobile/drawer/Drawer.vue +197 -0
  19. package/src/tdesign/mobile/drawer/DrawerContent.vue +13 -0
  20. package/src/tdesign/mobile/enum-select/EnumSelect.vue +164 -0
  21. package/src/tdesign/mobile/popup/Popup.vue +106 -0
  22. package/src/tdesign/mobile/region-picker/RegionPicker.vue +223 -0
  23. package/src/tdesign/mobile/select/Select.vue +479 -0
  24. package/src/tdesign/mobile/slide-radio-group/SlideRadioGroup.vue +397 -0
  25. package/src/tdesign/mobile/tnxtdm.css +125 -0
  26. package/src/tdesign/mobile/tnxtdm.ts +305 -1
  27. package/src/tdesign/tnxtd-validator.ts +14 -13
  28. package/src/tdesign/tnxtd.css +98 -0
  29. package/src/tdesign/tnxtd.ts +4 -0
  30. package/src/tnxvue-router.ts +59 -5
  31. package/src/tnxvue.ts +32 -11
  32. package/src/vue.d.ts +6 -0
  33. package/tsconfig.json +4 -7
  34. /package/src/{percent → components}/Percent.vue +0 -0
  35. /package/src/{text → components}/Text.vue +0 -0
@@ -0,0 +1,164 @@
1
+ <template>
2
+ <tnxtdm-select
3
+ ref="select"
4
+ v-model="model"
5
+ :id="id"
6
+ :selector="selector"
7
+ :items="items"
8
+ value-name="key" text-name="caption" index-name="searchIndex"
9
+ :default-value="defaultValue"
10
+ :empty="empty"
11
+ :empty-value="emptyValue"
12
+ :placeholder="placeholder"
13
+ :width="width"
14
+ :disabled="isDisabled"
15
+ :filterable="filterable"
16
+ :theme="theme"
17
+ :size="size"
18
+ :tag-click="tagClick"
19
+ :change="change"
20
+ :data-type="type"
21
+ :data-subtype="subtype"
22
+ >
23
+ <template #option="{item}" v-if="$slots.option">
24
+ <slot name="option" :item="item"></slot>
25
+ </template>
26
+ </tnxtdm-select>
27
+ </template>
28
+
29
+ <script>
30
+ import Select, {isMultiSelector} from '../select/Select.vue';
31
+
32
+ export default {
33
+ name: 'TnxtdmEnumSelect',
34
+ components: {
35
+ 'tnxtdm-select': Select,
36
+ },
37
+ props: {
38
+ id: [Number, String],
39
+ modelValue: [String, Number, Boolean, Array],
40
+ selector: String,
41
+ type: {
42
+ type: String,
43
+ required: true,
44
+ },
45
+ subtype: String,
46
+ defaultValue: String,
47
+ empty: {
48
+ type: [Boolean, String],
49
+ default: false,
50
+ },
51
+ emptyValue: {
52
+ type: [String, Number, Boolean, Array],
53
+ default: '',
54
+ },
55
+ placeholder: String,
56
+ width: String,
57
+ disabled: Boolean,
58
+ tagClick: Function,
59
+ change: Function,
60
+ grouped: {
61
+ type: Boolean,
62
+ default: false,
63
+ },
64
+ filterable: Boolean,
65
+ theme: String,
66
+ size: String,
67
+ },
68
+ emits: ['update:modelValue'],
69
+ data() {
70
+ return {
71
+ model: this.modelValue,
72
+ items: null,
73
+ formDisabled: false,
74
+ };
75
+ },
76
+ computed: {
77
+ isDisabled() {
78
+ return this.disabled || this.formDisabled;
79
+ },
80
+ },
81
+ watch: {
82
+ model(value) {
83
+ this.$emit('update:modelValue', value);
84
+ },
85
+ modelValue() {
86
+ this.initModel();
87
+ },
88
+ type() {
89
+ this.init();
90
+ },
91
+ subtype() {
92
+ this.init();
93
+ }
94
+ },
95
+ mounted() {
96
+ this.init();
97
+ this.initFormDisabled();
98
+ },
99
+ methods: {
100
+ initFormDisabled() {
101
+ let parent = this.$parent;
102
+ while (parent) {
103
+ if (parent.$options && (parent.$options.name === 't-form' || parent.$options.name === 'TForm')) {
104
+ this.$watch(() => parent.disabled || (parent.$props && parent.$props.disabled), (val) => {
105
+ this.formDisabled = val;
106
+ }, {immediate: true});
107
+ break;
108
+ }
109
+ parent = parent.$parent;
110
+ }
111
+ },
112
+ init() {
113
+ if (typeof this.type === 'string') {
114
+ if (this.type.toLowerCase() === 'boolean') {
115
+ this.items = [{
116
+ key: true,
117
+ caption: true.toText(),
118
+ }, {
119
+ key: false,
120
+ caption: false.toText(),
121
+ }];
122
+ this.initModel();
123
+ } else {
124
+ if (window.tnx && window.tnx.meta) {
125
+ window.tnx.meta.resolveEnumItems(this.type, this.subtype).then((items) => {
126
+ this.items = items;
127
+ this.initModel();
128
+ });
129
+ }
130
+ }
131
+ }
132
+ },
133
+ initModel() {
134
+ let oldModel = this.model;
135
+ this.model = this.modelValue;
136
+ if (isMultiSelector(this.selector)) {
137
+ return;
138
+ }
139
+ if ((this.model === undefined || this.model === null) && !this.empty && this.items && this.items.length) {
140
+ let item = this.items[0];
141
+ this.model = item.key;
142
+ if (this.model !== oldModel && this.change) {
143
+ this.change(item);
144
+ }
145
+ }
146
+ },
147
+ getText(value) {
148
+ if (this.$refs.select) {
149
+ return this.$refs.select.getText(value);
150
+ }
151
+ return undefined;
152
+ },
153
+ disableItem(itemKey, disabled, reverseOther) {
154
+ if (this.$refs.select) {
155
+ this.$refs.select.disableItem(itemKey, disabled, reverseOther);
156
+ }
157
+ },
158
+ }
159
+ }
160
+ </script>
161
+
162
+ <style>
163
+
164
+ </style>
@@ -0,0 +1,106 @@
1
+ <template>
2
+ <slot name="trigger" :show="open" :visible="visible"></slot>
3
+ <t-popup
4
+ class="tnxtdm-popup"
5
+ v-model="visible"
6
+ :placement="placement"
7
+ :destroy-on-close="true"
8
+ v-bind="$attrs"
9
+ >
10
+ <div class="tnxtdm-popup-header" v-if="title || $slots.left || $slots.right">
11
+ <div class="tnxtdm-popup-header-left">
12
+ <slot name="left">
13
+ <t-icon name="blank" size="24px"/>
14
+ </slot>
15
+ </div>
16
+ <div class="tnxtdm-popup-header-title">
17
+ <slot name="title">{{ title }}</slot>
18
+ </div>
19
+ <div class="tnxtdm-popup-header-right">
20
+ <slot name="right">
21
+ <t-icon class="text-placeholder" name="close" size="24px" @click="close"/>
22
+ </slot>
23
+ </div>
24
+ </div>
25
+ <div class="tnxtdm-popup-content">
26
+ <slot></slot>
27
+ </div>
28
+ </t-popup>
29
+ </template>
30
+
31
+ <script>
32
+ export default {
33
+ name: 'TnxtdmPopup',
34
+ props: {
35
+ modelValue: Boolean,
36
+ title: String,
37
+ placement: {
38
+ type: String,
39
+ default: 'bottom',
40
+ },
41
+ },
42
+ data() {
43
+ return {
44
+ visible: false,
45
+ }
46
+ },
47
+ watch: {
48
+ modelValue(val) {
49
+ this.visible = val;
50
+ },
51
+ visible(val) {
52
+ this.$emit('update:modelValue', val);
53
+ },
54
+ },
55
+ emits: ['update:modelValue', 'close'],
56
+ mounted() {
57
+ this.visible = this.modelValue;
58
+ },
59
+ methods: {
60
+ open() {
61
+ this.visible = true;
62
+ },
63
+ close() {
64
+ this.visible = false;
65
+ this.$emit('close');
66
+ },
67
+ },
68
+ };
69
+ </script>
70
+
71
+ <style>
72
+ .tnxtdm-popup {
73
+ border-radius: 12px 12px 0 0;
74
+ max-height: 80vh;
75
+ display: flex;
76
+ flex-direction: column;
77
+ }
78
+
79
+ .tnxtdm-popup .tnxtdm-popup-header {
80
+ display: flex;
81
+ justify-content: space-between;
82
+ align-items: center;
83
+ padding: 12px 1rem;
84
+ border-bottom: 1px solid var(--td-border-level-1-color);
85
+ }
86
+
87
+ .tnxtdm-popup .tnxtdm-popup-header .tnxtdm-popup-header-title {
88
+ font-size: 1rem;
89
+ font-weight: 600;
90
+ color: var(--td-text-color-primary);
91
+ flex: 1;
92
+ text-align: center;
93
+ }
94
+
95
+ .tnxtdm-popup .tnxtdm-popup-header .tnxtdm-popup-header-left,
96
+ .tnxtdm-popup .tnxtdm-popup-header .tnxtdm-popup-header-right {
97
+ display: flex;
98
+ align-items: center;
99
+ min-width: 24px;
100
+ }
101
+
102
+ .tnxtdm-popup .tnxtdm-popup-content {
103
+ flex: 1;
104
+ overflow-y: auto;
105
+ }
106
+ </style>
@@ -0,0 +1,223 @@
1
+ <template>
2
+ <TnxtdmPopup class="tnxtdm-region-picker" v-model="pickerVisible">
3
+ <template #trigger="{ show }">
4
+ <div class="flex-v-center" :class="triggerClass">
5
+ <div @click="show">{{ displayValue || placeholder }}</div>
6
+ <t-icon
7
+ class="ml-3 text-secondary"
8
+ name="close-circle-filled"
9
+ @click="onClear"
10
+ v-if="empty && displayValue"
11
+ />
12
+ <t-icon
13
+ class="ml-3 text-secondary"
14
+ :name="iconName"
15
+ @click="show"
16
+ v-else-if="iconName"
17
+ />
18
+ </div>
19
+ </template>
20
+ <t-picker
21
+ v-if="pickerVisible"
22
+ v-model="pickerValue"
23
+ :title="title"
24
+ :columns="pickerColumns"
25
+ :keys="{ label: 'caption', value: 'code' }"
26
+ @pick="onPickerPick"
27
+ @confirm="onPickerConfirm"
28
+ @cancel="onPickerCancel"
29
+ >
30
+ </t-picker>
31
+ </TnxtdmPopup>
32
+ </template>
33
+
34
+ <script>
35
+ import TnxtdmPopup from '../popup/Popup.vue';
36
+
37
+ export default {
38
+ name: 'TnxtdmRegionPicker',
39
+ components: {TnxtdmPopup},
40
+ props: {
41
+ modelValue: {
42
+ type: String,
43
+ required: true,
44
+ },
45
+ code: {
46
+ type: String,
47
+ default: 'CN',
48
+ },
49
+ level: {
50
+ type: Number,
51
+ default: 3,
52
+ },
53
+ title: {
54
+ type: String,
55
+ default: '地区',
56
+ },
57
+ triggerClass: String,
58
+ placeholder: {
59
+ type: String,
60
+ default: '请选择地区',
61
+ },
62
+ empty: [String, Boolean],
63
+ iconName: {
64
+ type: String,
65
+ default: 'location',
66
+ },
67
+ },
68
+ data() {
69
+ return {
70
+ region: null,
71
+ displayValue: '',
72
+ pickerVisible: false,
73
+ pickerValue: [],
74
+ pickerColumns: [],
75
+ };
76
+ },
77
+ watch: {
78
+ modelValue() {
79
+ this.initPicker();
80
+ this.initDisplay();
81
+ },
82
+ pickerVisible(val) {
83
+ if (val) {
84
+ this.initPicker();
85
+ }
86
+ },
87
+ },
88
+ emits: ['update:modelValue', 'change'],
89
+ async mounted() {
90
+ this.region = await window.tnx.meta.loadRegion(this.code, this.level);
91
+ this.initPicker();
92
+ this.initDisplay();
93
+ },
94
+ methods: {
95
+ initDisplay() {
96
+ if (!this.region || !this.modelValue) {
97
+ this.displayValue = '';
98
+ return;
99
+ }
100
+ const path = this.getPath(this.region.subs, this.modelValue);
101
+ if (path && path.length) {
102
+ this.displayValue = path.map(item => item.caption).join(' / ');
103
+ } else {
104
+ this.displayValue = '';
105
+ }
106
+ },
107
+ initPicker() {
108
+ if (!this.region) {
109
+ return;
110
+ }
111
+
112
+ let path = [];
113
+ if (this.modelValue) {
114
+ path = this.getPath(this.region.subs, this.modelValue) || [];
115
+ }
116
+
117
+ this.pickerColumns = [];
118
+ this.pickerValue = [];
119
+
120
+ let currentOptions = this.region.subs || [];
121
+
122
+ for (let i = 0; i < this.level; i++) {
123
+ this.pickerColumns.push(currentOptions);
124
+
125
+ let selectedCode;
126
+ if (i < path.length) {
127
+ selectedCode = path[i].code;
128
+ } else {
129
+ if (currentOptions.length > 0) {
130
+ selectedCode = currentOptions[0].code;
131
+ }
132
+ }
133
+
134
+ if (selectedCode) {
135
+ this.pickerValue.push(selectedCode);
136
+ let selectedOption = currentOptions.find(opt => opt.code === selectedCode);
137
+ if (selectedOption && selectedOption.subs) {
138
+ currentOptions = selectedOption.subs;
139
+ } else {
140
+ currentOptions = [];
141
+ }
142
+ } else {
143
+ this.pickerValue.push(null);
144
+ currentOptions = [];
145
+ }
146
+ }
147
+ },
148
+ getPath(options, code) {
149
+ if (!options) {
150
+ return null;
151
+ }
152
+ for (let item of options) {
153
+ if (item.code === code) {
154
+ return [item];
155
+ }
156
+ if (item.subs) {
157
+ let subPath = this.getPath(item.subs, code);
158
+ if (subPath) {
159
+ return [item, ...subPath];
160
+ }
161
+ }
162
+ }
163
+ return null;
164
+ },
165
+ onPickerPick(values, {column, index}) {
166
+ const newColumns = [];
167
+ const newValues = [];
168
+
169
+ for (let i = 0; i < this.pickerColumns.length; i++) {
170
+ if (i <= column) {
171
+ newColumns.push(this.pickerColumns[i]);
172
+ newValues.push(values[i]);
173
+ } else {
174
+ let region = newColumns[i - 1][index];
175
+ let subs = region.subs || [];
176
+ if (subs.length > 0) {
177
+ newColumns.push(subs);
178
+ if (subs.length > 0) {
179
+ newValues.push(subs[0].code);
180
+ }
181
+ } else if (newColumns.length < this.level) {
182
+ newColumns.push([]);
183
+ newValues.push(null);
184
+ }
185
+ }
186
+ }
187
+
188
+ this.pickerColumns = newColumns;
189
+ this.pickerValue = newValues;
190
+ },
191
+ onPickerConfirm() {
192
+ this.pickerVisible = false;
193
+ this.onConfirm();
194
+ },
195
+ onPickerCancel() {
196
+ this.pickerVisible = false;
197
+ },
198
+ onConfirm() {
199
+ let code = null;
200
+ for (let i = this.pickerValue.length - 1; i >= 0; i--) {
201
+ if (this.pickerValue[i]) {
202
+ code = this.pickerValue[i];
203
+ break;
204
+ }
205
+ }
206
+
207
+ if (code) {
208
+ this.$emit('update:modelValue', code);
209
+ this.$emit('change', code);
210
+ }
211
+ },
212
+ onClear() {
213
+ this.$emit('update:modelValue', '');
214
+ },
215
+ open() {
216
+ this.pickerVisible = true;
217
+ },
218
+ }
219
+ }
220
+ </script>
221
+
222
+ <style>
223
+ </style>