@tdesign/uniapp 0.8.0 → 0.8.1

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 (91) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +43 -34
  3. package/dist/action-sheet/README.md +8 -3
  4. package/dist/avatar/README.md +3 -1
  5. package/dist/back-top/README.md +3 -1
  6. package/dist/badge/README.md +3 -1
  7. package/dist/button/README.md +3 -1
  8. package/dist/calendar/README.md +3 -1
  9. package/dist/cascader/README.md +3 -1
  10. package/dist/cell/README.md +3 -1
  11. package/dist/checkbox/README.md +3 -1
  12. package/dist/col/README.md +3 -1
  13. package/dist/collapse/README.md +3 -1
  14. package/dist/color-picker/README.md +3 -1
  15. package/dist/common/common.ts +121 -5
  16. package/dist/common/src/index.js +0 -1
  17. package/dist/common/validator.ts +496 -0
  18. package/dist/config-provider/README.md +3 -1
  19. package/dist/count-down/README.md +3 -1
  20. package/dist/date-time-picker/README.md +3 -1
  21. package/dist/dialog/README.md +3 -1
  22. package/dist/divider/README.md +3 -1
  23. package/dist/drawer/README.md +3 -1
  24. package/dist/dropdown-menu/README.md +2 -2
  25. package/dist/empty/README.md +3 -1
  26. package/dist/fab/README.md +3 -1
  27. package/dist/footer/README.md +3 -1
  28. package/dist/form/README.en-US.md +2 -2
  29. package/dist/form/README.md +5 -3
  30. package/dist/form/form.vue +1 -1
  31. package/dist/form/type.ts +3 -3
  32. package/dist/form-item/form-item.css +4 -0
  33. package/dist/form-item/form-item.vue +2 -3
  34. package/dist/form-item/type.ts +2 -2
  35. package/dist/grid/README.md +3 -1
  36. package/dist/guide/README.md +3 -1
  37. package/dist/icon/README.md +10 -7
  38. package/dist/icon/icon.css +1633 -1624
  39. package/dist/image/README.md +3 -1
  40. package/dist/image-viewer/README.md +3 -1
  41. package/dist/index.js +13 -0
  42. package/dist/indexes/README.md +3 -1
  43. package/dist/input/README.md +3 -1
  44. package/dist/input/input.vue +1 -27
  45. package/dist/link/README.md +3 -1
  46. package/dist/loading/README.md +3 -1
  47. package/dist/message/README.md +8 -3
  48. package/dist/mixins/page-scroll.d.ts +19 -0
  49. package/dist/mixins/skyline.js +1 -1
  50. package/dist/navbar/README.md +3 -1
  51. package/dist/notice-bar/README.md +3 -1
  52. package/dist/overlay/README.md +3 -1
  53. package/dist/picker/README.md +3 -1
  54. package/dist/popover/README.md +3 -1
  55. package/dist/popup/README.md +3 -1
  56. package/dist/progress/README.md +2 -2
  57. package/dist/pull-down-refresh/README.md +3 -1
  58. package/dist/qrcode/README.md +3 -1
  59. package/dist/radio/README.md +3 -1
  60. package/dist/rate/README.md +3 -1
  61. package/dist/rate/rate.css +1 -0
  62. package/dist/result/README.md +3 -1
  63. package/dist/script/postinstall.js +49 -24
  64. package/dist/search/README.md +3 -1
  65. package/dist/side-bar/README.md +3 -1
  66. package/dist/skeleton/README.md +3 -1
  67. package/dist/slider/README.md +3 -1
  68. package/dist/stepper/README.md +3 -1
  69. package/dist/steps/README.md +3 -1
  70. package/dist/sticky/README.md +3 -1
  71. package/dist/swipe-cell/README.md +3 -1
  72. package/dist/swiper/README.md +3 -1
  73. package/dist/switch/README.md +3 -1
  74. package/dist/tab-bar/README.md +3 -1
  75. package/dist/tabs/README.md +3 -1
  76. package/dist/tag/README.md +3 -1
  77. package/dist/textarea/README.md +3 -1
  78. package/dist/textarea/textarea.vue +1 -25
  79. package/dist/theme.css +467 -0
  80. package/dist/theme.css.d.ts +2 -0
  81. package/dist/theme.less +1 -0
  82. package/dist/theme.less.d.ts +2 -0
  83. package/dist/toast/README.md +3 -1
  84. package/dist/transition/README.md +4 -6
  85. package/dist/tree-select/README.md +3 -1
  86. package/dist/types/index.d.ts +15 -0
  87. package/dist/upload/README.md +3 -1
  88. package/dist/watermark/README.md +3 -1
  89. package/package.json +37 -3
  90. package/dist/common/src/superComponent.js +0 -5
  91. package/dist/common/validator.js +0 -210
@@ -1,210 +0,0 @@
1
- export function isFunction(val) {
2
- return typeof val === 'function';
3
- }
4
-
5
- export const isString = val => typeof val === 'string';
6
-
7
- export const isNull = value => value === null;
8
-
9
- export const isUndefined = value => value === undefined;
10
-
11
- export function isDef(value) {
12
- return !isUndefined(value) && !isNull(value);
13
- }
14
-
15
- export function isInteger(value) {
16
- return Number.isInteger(value);
17
- }
18
-
19
- export function isNumeric(value) {
20
- return !Number.isNaN(Number(value));
21
- }
22
-
23
- export function isNumber(value) {
24
- return typeof value === 'number';
25
- }
26
-
27
- export function isBoolean(value) {
28
- return typeof value === 'boolean';
29
- }
30
-
31
- export function isObject(x) {
32
- const type = typeof x;
33
- return x !== null && (type === 'object' || type === 'function');
34
- }
35
-
36
- export function isPlainObject(val) {
37
- return val !== null && typeof val === 'object' && Object.prototype.toString.call(val) === '[object Object]';
38
- }
39
-
40
- export function isEmpty(val) {
41
- if (val === null || val === undefined) return true;
42
- if (typeof val === 'string' || Array.isArray(val)) return val.length === 0;
43
- if (val instanceof Map || val instanceof Set) return val.size === 0;
44
- if (typeof val === 'object') return Object.keys(val).length === 0;
45
- return true;
46
- }
47
-
48
- /**
49
- * 验证是否为有效日期
50
- * 支持字符串格式(YYYY/MM/DD、YYYY-MM-DD 等)和 Date 对象
51
- */
52
- export function isDate(input, options) {
53
- const defaultOptions = {
54
- format: 'YYYY/MM/DD',
55
- delimiters: ['/', '-'],
56
- strictMode: false,
57
- };
58
- const opts = { ...defaultOptions, ...options };
59
-
60
- if (typeof input === 'string') {
61
- const delimiter = opts.delimiters.find((d) => opts.format.includes(d));
62
- if (!delimiter) return false;
63
-
64
- const formatParts = opts.format.split(delimiter);
65
- const dateParts = input.split(delimiter);
66
- if (formatParts.length !== dateParts.length) return false;
67
-
68
- let year = '';
69
- let month = '';
70
- let day = '';
71
- for (let i = 0; i < formatParts.length; i += 1) {
72
- const fmt = formatParts[i].toUpperCase();
73
- const val = dateParts[i];
74
- if (fmt.includes('Y')) year = val;
75
- else if (fmt.includes('M')) month = val;
76
- else if (fmt.includes('D')) day = val;
77
- }
78
-
79
- if (month.length === 1) month = `0${month}`;
80
- if (day.length === 1) day = `0${day}`;
81
-
82
- if (year.length === 2) {
83
- const currentYearSuffix = new Date().getFullYear() % 100;
84
- year = Number(year) <= currentYearSuffix ? `20${year}` : `19${year}`;
85
- }
86
-
87
- const date = new Date(`${year}-${month}-${day}T00:00:00.000Z`);
88
- return (
89
- date.getUTCFullYear() === Number(year)
90
- && date.getUTCMonth() + 1 === Number(month)
91
- && date.getUTCDate() === Number(day)
92
- );
93
- }
94
-
95
- if (!opts.strictMode) {
96
- if (Object.prototype.toString.call(input) === '[object Date]' && Number.isFinite(input.getTime())) {
97
- return true;
98
- }
99
- }
100
-
101
- return false;
102
- }
103
-
104
- /**
105
- * 验证是否为有效邮箱地址
106
- */
107
- export function isEmail(str) {
108
- if (typeof str !== 'string') return false;
109
- if (str.length > 254) return false;
110
-
111
- const parts = str.split('@');
112
- if (parts.length !== 2) return false;
113
-
114
- const [user, domain] = parts;
115
- if (!user || user.length > 64) return false;
116
- if (!domain) return false;
117
-
118
- if (/^[-.]/.test(domain) || /[-.]$/.test(domain)) return false;
119
- if (!/^[a-zA-Z0-9.-]+$/.test(domain)) return false;
120
- if (!domain.includes('.')) return false;
121
-
122
- const tld = domain.split('.').pop();
123
- if (!tld || tld.length < 2) return false;
124
-
125
- const emailUserReg = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+$/;
126
- return emailUserReg.test(user);
127
- }
128
-
129
- /**
130
- * 验证是否为有效 URL
131
- */
132
- export function isURL(str, options) {
133
- if (typeof str !== 'string') return false;
134
- if (str.length === 0 || /\s/.test(str)) return false;
135
- if (str.length > 2084) return false;
136
-
137
- const defaultOpts = {
138
- protocols: ['http', 'https', 'ftp'],
139
- require_tld: true,
140
- require_protocol: false,
141
- require_host: true,
142
- allow_protocol_relative_urls: false,
143
- };
144
- const opts = { ...defaultOpts, ...options };
145
-
146
- let url = str;
147
-
148
- const protocolRegex = /^([a-z][a-z0-9+\-.]*):\/\//i;
149
- const protocolMatch = url.match(protocolRegex);
150
- if (protocolMatch) {
151
- const protocol = protocolMatch[1].toLowerCase();
152
- if (!opts.protocols.includes(protocol)) return false;
153
- url = url.slice(protocolMatch[0].length);
154
- } else if (opts.require_protocol) {
155
- if (opts.allow_protocol_relative_urls && str.startsWith('//')) {
156
- url = url.slice(2);
157
- } else {
158
- return false;
159
- }
160
- } else if (str.startsWith('//')) {
161
- if (!opts.allow_protocol_relative_urls) return false;
162
- url = url.slice(2);
163
- }
164
-
165
- if (!url && opts.require_host) return false;
166
-
167
- const [hostPart] = url.split(/[/?#]/);
168
- if (!hostPart && opts.require_host) return false;
169
-
170
- let host = hostPart;
171
- if (host.includes('@')) {
172
- host = host.split('@').pop() || '';
173
- }
174
-
175
- let hostname = host;
176
- const portMatch = host.match(/:(\d+)$/);
177
- if (portMatch) {
178
- const port = Number(portMatch[1]);
179
- if (port < 0 || port > 65535) return false;
180
- hostname = host.slice(0, host.lastIndexOf(':'));
181
- }
182
-
183
- if (!hostname) return false;
184
-
185
- const ipv4Regex = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
186
- const ipv4Match = hostname.match(ipv4Regex);
187
- if (ipv4Match) {
188
- return ipv4Match.slice(1).every((part) => Number(part) >= 0 && Number(part) <= 255);
189
- }
190
-
191
- if (hostname.startsWith('[') && hostname.endsWith(']')) {
192
- return true;
193
- }
194
-
195
- const domainParts = hostname.split('.');
196
- if (opts.require_tld && domainParts.length < 2) return false;
197
- const hasInvalidPart = domainParts.some((part) => {
198
- if (!part || part.length > 63) return true;
199
- if (!/^[a-zA-Z0-9-]+$/.test(part)) return true;
200
- if (part.startsWith('-') || part.endsWith('-')) return true;
201
- return false;
202
- });
203
- if (hasInvalidPart) return false;
204
- if (opts.require_tld) {
205
- const tld = domainParts[domainParts.length - 1];
206
- if (/^\d+$/.test(tld)) return false;
207
- }
208
-
209
- return true;
210
- }