@zfqh/uview-x 0.0.0-stage → 0.0.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 (93) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +127 -3
  4. package/components/uv-badge/props.ts +83 -0
  5. package/components/uv-badge/uv-badge.vue +186 -0
  6. package/components/uv-button/props.ts +148 -0
  7. package/components/uv-button/uv-button.vue +565 -0
  8. package/components/uv-checkbox/props.ts +83 -0
  9. package/components/uv-checkbox/uv-checkbox.vue +403 -0
  10. package/components/uv-checkbox-group/props.ts +97 -0
  11. package/components/uv-checkbox-group/uv-checkbox-group.vue +163 -0
  12. package/components/uv-code/props.ts +48 -0
  13. package/components/uv-code/uv-code.vue +156 -0
  14. package/components/uv-dialog/props.ts +56 -0
  15. package/components/uv-dialog/uv-dialog.vue +492 -0
  16. package/components/uv-form/props.ts +59 -0
  17. package/components/uv-form/uv-form.vue +256 -0
  18. package/components/uv-form/valid.ts +1344 -0
  19. package/components/uv-form-item/props.ts +62 -0
  20. package/components/uv-form-item/uv-form-item.vue +335 -0
  21. package/components/uv-icon/icons.ts +161 -0
  22. package/components/uv-icon/props.ts +91 -0
  23. package/components/uv-icon/uv-icon.vue +204 -0
  24. package/components/uv-icon/uvicons.ttf +0 -0
  25. package/components/uv-input/props.ts +185 -0
  26. package/components/uv-input/uv-input.vue +431 -0
  27. package/components/uv-line/props.ts +42 -0
  28. package/components/uv-line/uv-line.vue +75 -0
  29. package/components/uv-line-progress/props.ts +43 -0
  30. package/components/uv-line-progress/uv-line-progress.vue +166 -0
  31. package/components/uv-loading-icon/props.ts +78 -0
  32. package/components/uv-loading-icon/uv-loading-icon.vue +226 -0
  33. package/components/uv-overlay/props.ts +38 -0
  34. package/components/uv-overlay/uv-overlay.vue +120 -0
  35. package/components/uv-popup/props.ts +101 -0
  36. package/components/uv-popup/uv-popup.vue +371 -0
  37. package/components/uv-safe-bottom/props.ts +18 -0
  38. package/components/uv-safe-bottom/uv-safe-bottom.vue +120 -0
  39. package/components/uv-status-bar/props.ts +22 -0
  40. package/components/uv-status-bar/uv-status-bar.vue +121 -0
  41. package/components/uv-tabs/props.ts +84 -0
  42. package/components/uv-tabs/uv-tabs.vue +432 -0
  43. package/components/uv-transition/props.ts +38 -0
  44. package/components/uv-transition/uv-transition.vue +170 -0
  45. package/hooks/index.ts +5 -0
  46. package/hooks/useDebounce.ts +35 -0
  47. package/hooks/useI18n.ts +95 -0
  48. package/hooks/useThrottle.ts +38 -0
  49. package/index.ts +23 -0
  50. package/libs/dayjs/index.ts +217 -0
  51. package/libs/index.ts +4 -0
  52. package/libs/luch-request/adapters/index.ts +133 -0
  53. package/libs/luch-request/core/InterceptorManager.ts +52 -0
  54. package/libs/luch-request/core/Request.ts +202 -0
  55. package/libs/luch-request/core/buildFullPath.ts +21 -0
  56. package/libs/luch-request/core/defaults.ts +34 -0
  57. package/libs/luch-request/core/dispatchRequest.ts +7 -0
  58. package/libs/luch-request/core/mergeConfig.ts +127 -0
  59. package/libs/luch-request/core/settle.ts +17 -0
  60. package/libs/luch-request/helpers/buildURL.ts +65 -0
  61. package/libs/luch-request/helpers/combineURLs.ts +15 -0
  62. package/libs/luch-request/helpers/isAbsoluteURL.ts +15 -0
  63. package/libs/luch-request/index.d.ts +197 -0
  64. package/libs/luch-request/index.ts +3 -0
  65. package/libs/luch-request/utils/clone.ts +265 -0
  66. package/libs/luch-request/utils.ts +136 -0
  67. package/locales/en.ts +78 -0
  68. package/locales/index.ts +169 -0
  69. package/locales/zh-Hans.ts +78 -0
  70. package/package.json +42 -4
  71. package/styles/color.scss +33 -0
  72. package/styles/common.scss +134 -0
  73. package/styles/components.scss +19 -0
  74. package/styles/index.scss +7 -0
  75. package/styles/theme.scss +44 -0
  76. package/styles/var.module.scss +32 -0
  77. package/styles/vue.scss +39 -0
  78. package/theme.scss +2 -0
  79. package/types/index.d.ts +66 -0
  80. package/utils/colorGradient.ts +139 -0
  81. package/utils/compat.ts +165 -0
  82. package/utils/compress.ts +34 -0
  83. package/utils/config.ts +95 -0
  84. package/utils/debounce.ts +7 -0
  85. package/utils/digit.ts +157 -0
  86. package/utils/function.ts +771 -0
  87. package/utils/http.ts +5 -0
  88. package/utils/index.ts +57 -0
  89. package/utils/locale.ts +296 -0
  90. package/utils/platform.ts +71 -0
  91. package/utils/route.ts +142 -0
  92. package/utils/test.ts +256 -0
  93. package/utils/throttle.ts +7 -0
@@ -0,0 +1,204 @@
1
+ <template>
2
+ <view class="uv-icon" :class="['uv-icon--' + p.labelPos, p.customClass]" @tap="clickHandler">
3
+ <image
4
+ v-if="isImg"
5
+ class="uv-icon__img"
6
+ :src="p.name"
7
+ :mode="p.imgMode"
8
+ :style="[imgStyle, $uv.addStyle(p.customStyle)]"
9
+ ></image>
10
+ <text
11
+ v-else
12
+ class="uv-icon__icon"
13
+ :class="uClasses"
14
+ :style="[iconStyle, $uv.addStyle(p.customStyle)]"
15
+ :hover-class="p.hoverClass"
16
+ >{{ icon }}</text
17
+ >
18
+ <text
19
+ v-if="p.label !== ''"
20
+ class="uv-icon__label"
21
+ :style="{
22
+ color: p.labelColor,
23
+ fontSize: $uv.addUnit(p.labelSize),
24
+ marginLeft: p.labelPos === 'right' ? $uv.addUnit(p.space) : 0,
25
+ marginTop: p.labelPos === 'bottom' ? $uv.addUnit(p.space) : 0,
26
+ marginRight: p.labelPos === 'left' ? $uv.addUnit(p.space) : 0,
27
+ marginBottom: p.labelPos === 'top' ? $uv.addUnit(p.space) : 0,
28
+ }"
29
+ >{{ p.label }}</text
30
+ >
31
+ </view>
32
+ </template>
33
+
34
+ <script setup lang="ts">
35
+ import { computed } from 'vue';
36
+ import { $uv } from '../../utils';
37
+ import props from './props';
38
+ import { preventEvent } from '../../utils/compat';
39
+
40
+ // #ifdef APP-NVUE
41
+ import iconUrl from './uvicons.ttf';
42
+ import type { DomPlugin } from '../../utils/compat';
43
+ const dom = uni.requireNativePlugin?.('dom') as DomPlugin | undefined;
44
+ if (dom) {
45
+ dom.addRule('fontFace', {
46
+ fontFamily: 'uvicon-iconfont',
47
+ src: `url('${iconUrl}')`,
48
+ });
49
+ }
50
+ // #endif
51
+
52
+ defineOptions({
53
+ name: 'uv-icon',
54
+ // #ifdef UNI-APP-X
55
+ styleIsolation: 'app-and-page',
56
+ // #endif
57
+ virtualHost: true,
58
+ });
59
+
60
+ /**
61
+ * icon 图标
62
+ * @description 基于字体的图标集,包含了大多数常见场景的图标。
63
+ * @tutorial https://www.uvui.cn/components/icon.html
64
+ * @property {String} name 图标名称,见示例图标集
65
+ * @property {String} color 图标颜色,可接受主题色
66
+ * @property {String | Number} size 图标字体大小,单位px
67
+ * @property {Boolean} bold 是否显示粗体
68
+ * @property {String | Number} index 点击图标的时候传递事件出去的index
69
+ * @property {String} hoverClass 图标按下去的样式类
70
+ * @property {String} customPrefix 自定义扩展前缀
71
+ * @property {String | Number} label 图标右侧/下方的 label 文字
72
+ * @property {String} labelPos label 相对图标的位置:right/bottom/left/top
73
+ * @property {String | Number} labelSize label 字体大小
74
+ * @property {String} labelColor label 文字颜色
75
+ * @property {String | Number} space label 与图标的距离
76
+ * @property {String} imgMode 图片 mode
77
+ * @property {String | Number} width 图片形式时的宽度
78
+ * @property {String | Number} height 图片形式时的高度
79
+ * @property {String | Number} top 垂直方向偏移
80
+ * @property {Boolean} stop 是否阻止事件传播
81
+ * @event {Function} click 点击图标时触发
82
+ * @example <uv-icon name="photo" color="#2979ff" size="28"></uv-icon>
83
+ */
84
+ const p = defineProps(props);
85
+
86
+ const emit = defineEmits(['click']);
87
+
88
+ const colorType = ['primary', 'success', 'info', 'error', 'warning'];
89
+
90
+ const isImg = computed(() => {
91
+ const name = p.name || '';
92
+ const isBase64 = name.indexOf('data:') > -1 && name.indexOf('base64') > -1;
93
+ return name.indexOf('/') !== -1 || isBase64;
94
+ });
95
+
96
+ const icon = computed(() => {
97
+ const code = (p.icons || {})[p.customPrefix + '-' + p.name];
98
+ if (code) {
99
+ return String.fromCharCode(parseInt(code, 16));
100
+ }
101
+ return ['uvicon'].indexOf(p.customPrefix) > -1 ? p.name : '';
102
+ });
103
+
104
+ const uClasses = computed(() => {
105
+ const classes: string[] = [p.customPrefix, p.customPrefix + '-' + p.name];
106
+ if (p.color && colorType.includes(p.color)) {
107
+ classes.push('uv-icon__icon--' + p.color);
108
+ }
109
+ return classes;
110
+ });
111
+
112
+ const iconStyle = computed(() => {
113
+ const style: any = {
114
+ fontSize: $uv.addUnit(p.size),
115
+ lineHeight: $uv.addUnit(p.size),
116
+ fontWeight: p.bold ? 'bold' : 'normal',
117
+ top: $uv.addUnit(p.top),
118
+ };
119
+ if (p.color && !colorType.includes(p.color)) {
120
+ style.color = p.color;
121
+ }
122
+ return style;
123
+ });
124
+
125
+ const imgStyle = computed(() => {
126
+ const style: any = {};
127
+ style.width = p.width ? $uv.addUnit(p.width) : $uv.addUnit(p.size);
128
+ style.height = p.height ? $uv.addUnit(p.height) : $uv.addUnit(p.size);
129
+ return style;
130
+ });
131
+
132
+ const clickHandler = (e: any) => {
133
+ emit('click', p.index);
134
+ if (p.stop) preventEvent(e);
135
+ };
136
+ </script>
137
+
138
+ <style lang="scss">
139
+ @import '../../styles/color.scss';
140
+
141
+ /* #ifndef APP-NVUE */
142
+ @font-face {
143
+ font-family: 'uvicon-iconfont';
144
+ src: url('./uvicons.ttf') format('truetype');
145
+ }
146
+ /* #endif */
147
+
148
+ .uv-icon {
149
+ /* #ifndef APP-NVUE */
150
+ display: flex;
151
+ /* #endif */
152
+ align-items: center;
153
+ }
154
+ .uv-icon--left {
155
+ flex-direction: row-reverse;
156
+ align-items: center;
157
+ }
158
+ .uv-icon--right {
159
+ flex-direction: row;
160
+ align-items: center;
161
+ }
162
+ .uv-icon--top {
163
+ flex-direction: column-reverse;
164
+ justify-content: center;
165
+ }
166
+ .uv-icon--bottom {
167
+ flex-direction: column;
168
+ justify-content: center;
169
+ }
170
+ .uv-icon__icon {
171
+ font-family: uvicon-iconfont;
172
+ position: relative;
173
+ /* #ifndef APP-NVUE */
174
+ display: flex;
175
+ flex-direction: row;
176
+ /* #endif */
177
+ align-items: center;
178
+ }
179
+ .uv-icon__icon--primary {
180
+ color: $uv-primary;
181
+ }
182
+ .uv-icon__icon--success {
183
+ color: $uv-success;
184
+ }
185
+ .uv-icon__icon--error {
186
+ color: $uv-error;
187
+ }
188
+ .uv-icon__icon--warning {
189
+ color: $uv-warning;
190
+ }
191
+ .uv-icon__icon--info {
192
+ color: $uv-info;
193
+ }
194
+ .uv-icon__img {
195
+ /* #ifndef APP-NVUE */
196
+ height: auto;
197
+ /* #endif */
198
+ }
199
+ .uv-icon__label {
200
+ /* #ifndef APP-NVUE */
201
+ line-height: 1;
202
+ /* #endif */
203
+ }
204
+ </style>
Binary file
@@ -0,0 +1,185 @@
1
+ // @ts-nocheck
2
+
3
+ import config from '../../utils/config';
4
+
5
+ const props = {
6
+ value: {
7
+ type: [String, Number],
8
+ default: '',
9
+ },
10
+ modelValue: {
11
+ type: [String, Number],
12
+ default: '',
13
+ },
14
+ // 输入框类型
15
+ // number-数字输入键盘,App 端只能输入整数
16
+ // idcard-身份证输入键盘
17
+ // digit-带小数点的数字键盘
18
+ // text-文本输入键盘
19
+ type: {
20
+ type: String,
21
+ default: 'text',
22
+ },
23
+ // 是否禁用输入框
24
+ disabled: {
25
+ type: Boolean,
26
+ default: false,
27
+ },
28
+ // 禁用状态时的背景色
29
+ disabledColor: {
30
+ type: String,
31
+ default: '#f5f7fa',
32
+ },
33
+ // 是否显示清除控件
34
+ clearable: {
35
+ type: Boolean,
36
+ default: false,
37
+ },
38
+ // 是否密码类型
39
+ password: {
40
+ type: Boolean,
41
+ default: false,
42
+ },
43
+ // 最大输入长度,设置为 -1 的时候不限制最大长度
44
+ maxlength: {
45
+ type: [String, Number],
46
+ default: -1,
47
+ },
48
+ // 输入框为空时的占位符
49
+ placeholder: {
50
+ type: String,
51
+ default: null,
52
+ },
53
+ // 指定placeholder的样式类
54
+ placeholderClass: {
55
+ type: String,
56
+ default: 'input-placeholder',
57
+ },
58
+ // 指定placeholder的样式
59
+ placeholderStyle: {
60
+ type: [String, Object],
61
+ default: 'color: #c0c4cc',
62
+ },
63
+ // 设置右下角按钮的文字,有效值:send|search|next|go|done
64
+ confirmType: {
65
+ type: String,
66
+ default: 'done',
67
+ },
68
+ // 点击键盘右下角按钮时是否保持键盘不收起,H5无效
69
+ confirmHold: {
70
+ type: Boolean,
71
+ default: false,
72
+ },
73
+ // focus时,点击页面的时候不收起键盘,微信小程序有效
74
+ holdKeyboard: {
75
+ type: Boolean,
76
+ default: false,
77
+ },
78
+ // 自动获取焦点
79
+ focus: {
80
+ type: Boolean,
81
+ default: false,
82
+ },
83
+ // 键盘收起时,是否自动失去焦点,目前仅App3.0.0+有效
84
+ autoBlur: {
85
+ type: Boolean,
86
+ default: false,
87
+ },
88
+ // 指定focus时光标的位置
89
+ cursor: {
90
+ type: [String, Number],
91
+ default: -1,
92
+ },
93
+ // 输入框聚焦时底部与键盘的距离
94
+ cursorSpacing: {
95
+ type: [String, Number],
96
+ default: 30,
97
+ },
98
+ // 光标起始位置,自动聚集时有效,需与selection-end搭配使用
99
+ selectionStart: {
100
+ type: [String, Number],
101
+ default: -1,
102
+ },
103
+ // 光标结束位置,自动聚集时有效,需与selection-start搭配使用
104
+ selectionEnd: {
105
+ type: [String, Number],
106
+ default: -1,
107
+ },
108
+ // 键盘弹起时,是否自动上推页面
109
+ adjustPosition: {
110
+ type: Boolean,
111
+ default: true,
112
+ },
113
+ // 输入框内容对齐方式,可选值为:left|center|right
114
+ inputAlign: {
115
+ type: String,
116
+ default: 'left',
117
+ },
118
+ // 输入框字体的大小
119
+ fontSize: {
120
+ type: [String, Number],
121
+ default: '14px',
122
+ },
123
+ // 输入框字体颜色
124
+ color: {
125
+ type: String,
126
+ default: '#303133',
127
+ },
128
+ // 输入框前置图标
129
+ prefixIcon: {
130
+ type: String,
131
+ default: '',
132
+ },
133
+ // 前置图标样式,对象或字符串
134
+ prefixIconStyle: {
135
+ type: [String, Object],
136
+ default: '',
137
+ },
138
+ // 输入框后置图标
139
+ suffixIcon: {
140
+ type: String,
141
+ default: '',
142
+ },
143
+ // 后置图标样式,对象或字符串
144
+ suffixIconStyle: {
145
+ type: [String, Object],
146
+ default: '',
147
+ },
148
+ // 边框类型,surround-四周边框,bottom-底部边框,none-无边框
149
+ border: {
150
+ type: String,
151
+ default: 'surround',
152
+ },
153
+ // 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会
154
+ readonly: {
155
+ type: Boolean,
156
+ default: false,
157
+ },
158
+ // 输入框形状,circle-圆形,square-方形
159
+ shape: {
160
+ type: String,
161
+ default: 'square',
162
+ },
163
+ // 用于处理或者过滤输入框内容的方法
164
+ formatter: {
165
+ type: [Function, null],
166
+ default: null,
167
+ },
168
+ // 是否忽略组件内对文本合成系统事件的处理
169
+ ignoreCompositionEvent: {
170
+ type: Boolean,
171
+ default: true,
172
+ },
173
+ customStyle: {
174
+ type: [Object, String],
175
+ default: () => ({}),
176
+ },
177
+ customClass: {
178
+ type: String,
179
+ default: '',
180
+ },
181
+
182
+ ...config.props.input,
183
+ };
184
+
185
+ export default props;