@didaoktv/didaoui-uniapp 1.0.0 → 1.2.0

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 (114) hide show
  1. package/README.md +16 -7
  2. package/components/dd-action-sheet/dd-action-sheet.vue +3 -3
  3. package/components/dd-album/album.js +19 -0
  4. package/components/dd-album/dd-album.vue +345 -0
  5. package/components/dd-album/props.js +89 -0
  6. package/components/dd-avatar/avatar.js +19 -0
  7. package/components/dd-avatar/dd-avatar.vue +172 -160
  8. package/components/dd-avatar/props.js +84 -0
  9. package/components/dd-avatar-group/avatarGroup.js +14 -0
  10. package/components/dd-avatar-group/dd-avatar-group.vue +110 -0
  11. package/components/dd-avatar-group/props.js +57 -0
  12. package/components/dd-badge/dd-badge.vue +2 -2
  13. package/components/dd-barcode/dd-barcode.vue +1030 -0
  14. package/components/dd-bill-detail/dd-bill-detail.vue +265 -0
  15. package/components/dd-button/dd-button.vue +17 -17
  16. package/components/dd-calendar/dd-calendar.vue +357 -0
  17. package/components/dd-canvas/dd-canvas.vue +1088 -0
  18. package/components/dd-capsule-button/dd-capsule-button.vue +6 -6
  19. package/components/dd-car-keyboard/carKeyboard.js +6 -0
  20. package/components/dd-car-keyboard/dd-car-keyboard.vue +315 -0
  21. package/components/dd-car-keyboard/props.js +19 -0
  22. package/components/dd-cascader/dd-cascader.vue +405 -0
  23. package/components/dd-cell/dd-cell.vue +50 -23
  24. package/components/dd-cell-group/dd-cell-group.vue +32 -25
  25. package/components/dd-champion-card/dd-champion-card.vue +4 -4
  26. package/components/dd-checkbox/dd-checkbox.vue +30 -39
  27. package/components/dd-checkbox-group/dd-checkbox-group.vue +67 -0
  28. package/components/dd-copy/dd-copy.vue +74 -0
  29. package/components/dd-coupon/dd-coupon.vue +368 -0
  30. package/components/dd-cropper/dd-cropper.vue +1297 -0
  31. package/components/dd-dialog/dd-dialog.vue +1 -1
  32. package/components/dd-divider/dd-divider.vue +3 -3
  33. package/components/dd-dropdown-item/dd-dropdown-item.vue +5 -5
  34. package/components/dd-empty-state/dd-empty-state.vue +1 -1
  35. package/components/dd-field/dd-field.vue +531 -106
  36. package/components/dd-form/dd-form.vue +116 -0
  37. package/components/dd-form/rules.ts +84 -0
  38. package/components/dd-goods-sku/dd-goods-sku.vue +434 -0
  39. package/components/dd-icon/dd-icon.vue +2 -2
  40. package/components/dd-image/dd-image.vue +4 -4
  41. package/components/dd-input/dd-input.vue +5 -5
  42. package/components/dd-keyboard/dd-keyboard.vue +178 -0
  43. package/components/dd-keyboard/keyboard.js +22 -0
  44. package/components/dd-keyboard/props.js +89 -0
  45. package/components/dd-link/dd-link.vue +87 -0
  46. package/components/dd-link/link.js +18 -0
  47. package/components/dd-link/props.js +44 -0
  48. package/components/dd-list-cell/dd-list-cell.vue +4 -4
  49. package/components/dd-loading/dd-loading.vue +1 -1
  50. package/components/dd-loadmore/dd-loadmore.vue +2 -2
  51. package/components/dd-markdown/dd-markdown.vue +344 -0
  52. package/components/dd-markdown/marked.esm.mjs +7 -0
  53. package/components/dd-mini-program-navbar/dd-mini-program-navbar.vue +9 -9
  54. package/components/dd-navigation/dd-navigation.vue +5 -5
  55. package/components/dd-number-keyboard/dd-number-keyboard.vue +200 -0
  56. package/components/dd-number-keyboard/numberKeyboard.js +8 -0
  57. package/components/dd-number-keyboard/props.js +24 -0
  58. package/components/dd-parse/dd-parse.vue +534 -0
  59. package/components/dd-parse/node/handler.wxs +26 -0
  60. package/components/dd-parse/node/node.vue +603 -0
  61. package/components/dd-parse/parse.js +13 -0
  62. package/components/dd-parse/parser.js +1400 -0
  63. package/components/dd-parse/props.js +57 -0
  64. package/components/dd-popover/dd-popover.vue +10 -10
  65. package/components/dd-popover-item/dd-popover-item.vue +3 -3
  66. package/components/dd-popup/dd-popup.vue +5 -5
  67. package/components/dd-poster/dd-poster.vue +695 -0
  68. package/components/dd-progress/dd-progress.vue +3 -3
  69. package/components/dd-pull-refresh/dd-pull-refresh.vue +3 -3
  70. package/components/dd-qrcode/dd-qrcode.vue +509 -0
  71. package/components/dd-qrcode/qrcode.js +1283 -0
  72. package/components/dd-radio/dd-radio.vue +19 -20
  73. package/components/dd-radio-group/dd-radio-group.vue +53 -0
  74. package/components/dd-rate/dd-rate.vue +1 -1
  75. package/components/dd-room-card/dd-room-card.vue +3 -3
  76. package/components/dd-search-bar/dd-search-bar.vue +8 -8
  77. package/components/dd-segmented-tab/dd-segmented-tab.vue +6 -6
  78. package/components/dd-signature/dd-signature.vue +513 -0
  79. package/components/dd-skeleton/dd-skeleton.vue +1 -1
  80. package/components/dd-slider/dd-slider.vue +4 -4
  81. package/components/dd-stat-card/dd-stat-card.vue +5 -5
  82. package/components/dd-step/dd-step.vue +11 -11
  83. package/components/dd-stepper/dd-stepper.vue +6 -6
  84. package/components/dd-swipe-action/dd-swipe-action.vue +1 -1
  85. package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -1
  86. package/components/dd-tabbar-item/dd-tabbar-item.vue +8 -8
  87. package/components/dd-tag/dd-tag.vue +17 -1
  88. package/components/dd-text/dd-text.vue +250 -0
  89. package/components/dd-text/props.js +120 -0
  90. package/components/dd-text/text.js +30 -0
  91. package/components/dd-text/value.js +87 -0
  92. package/components/dd-toast/dd-toast.vue +2 -2
  93. package/components/dd-upload/dd-upload.vue +4 -4
  94. package/components/dd-workorder-card/dd-workorder-card.vue +237 -0
  95. package/index.ts +50 -9
  96. package/libs/config/color.js +16 -0
  97. package/libs/config/config.js +25 -0
  98. package/libs/config/props.js +185 -0
  99. package/libs/config/zIndex.js +20 -0
  100. package/libs/function/digit.js +167 -0
  101. package/libs/function/index.js +932 -0
  102. package/libs/function/test.js +327 -0
  103. package/libs/i18n/index.d.ts +2 -0
  104. package/libs/i18n/index.js +89 -0
  105. package/libs/i18n/locales/zh-Hans.js +86 -0
  106. package/libs/mixin/button.js +18 -0
  107. package/libs/mixin/mixin.js +44 -0
  108. package/libs/mixin/mpMixin.js +13 -0
  109. package/libs/mixin/openType.js +27 -0
  110. package/libs/utils.ts +462 -0
  111. package/libs/vue.js +3 -0
  112. package/package.json +1 -1
  113. package/scss/_dd-shared.scss +40 -0
  114. package/scss/_variables.scss +4 -1
@@ -0,0 +1,167 @@
1
+ let _boundaryCheckingState = true; // 是否进行越界检查的全局开关
2
+
3
+ /**
4
+ * 把错误的数据转正
5
+ * @private
6
+ * @example strip(0.09999999999999998)=0.1
7
+ */
8
+ export function strip(num, precision = 15) {
9
+ return +parseFloat(Number(num).toPrecision(precision));
10
+ }
11
+
12
+ /**
13
+ * Return digits length of a number
14
+ * @private
15
+ * @param {*number} num Input number
16
+ */
17
+ export function digitLength(num) {
18
+ // Get digit length of e
19
+ const eSplit = num.toString().split(/[eE]/);
20
+ const len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
21
+ return len > 0 ? len : 0;
22
+ }
23
+
24
+ /**
25
+ * 把小数转成整数,如果是小数则放大成整数
26
+ * @private
27
+ * @param {*number} num 输入数
28
+ */
29
+ export function float2Fixed(num) {
30
+ if (num.toString().indexOf('e') === -1) {
31
+ return Number(num.toString().replace('.', ''));
32
+ }
33
+ const dLen = digitLength(num);
34
+ return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num);
35
+ }
36
+
37
+ /**
38
+ * 检测数字是否越界,如果越界给出提示
39
+ * @private
40
+ * @param {*number} num 输入数
41
+ */
42
+ export function checkBoundary(num) {
43
+ if (_boundaryCheckingState) {
44
+ if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
45
+ console.warn(`${num} 超出了精度限制,结果可能不正确`);
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * 把递归操作扁平迭代化
52
+ * @param {number[]} arr 要操作的数字数组
53
+ * @param {function} operation 迭代操作
54
+ * @private
55
+ */
56
+ export function iteratorOperation(arr, operation) {
57
+ const [num1, num2, ...others] = arr;
58
+ let res = operation(num1, num2);
59
+
60
+ others.forEach((num) => {
61
+ res = operation(res, num);
62
+ });
63
+
64
+ return res;
65
+ }
66
+
67
+ /**
68
+ * 高精度乘法
69
+ * @export
70
+ */
71
+ export function times(...nums) {
72
+ if (nums.length > 2) {
73
+ return iteratorOperation(nums, times);
74
+ }
75
+
76
+ const [num1, num2] = nums;
77
+ const num1Changed = float2Fixed(num1);
78
+ const num2Changed = float2Fixed(num2);
79
+ const baseNum = digitLength(num1) + digitLength(num2);
80
+ const leftValue = num1Changed * num2Changed;
81
+
82
+ checkBoundary(leftValue);
83
+
84
+ return leftValue / Math.pow(10, baseNum);
85
+ }
86
+
87
+ /**
88
+ * 高精度加法
89
+ * @export
90
+ */
91
+ export function plus(...nums) {
92
+ if (nums.length > 2) {
93
+ return iteratorOperation(nums, plus);
94
+ }
95
+
96
+ const [num1, num2] = nums;
97
+ // 取最大的小数位
98
+ const baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
99
+ // 把小数都转为整数然后再计算
100
+ return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
101
+ }
102
+
103
+ /**
104
+ * 高精度减法
105
+ * @export
106
+ */
107
+ export function minus(...nums) {
108
+ if (nums.length > 2) {
109
+ return iteratorOperation(nums, minus);
110
+ }
111
+
112
+ const [num1, num2] = nums;
113
+ const baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
114
+ return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
115
+ }
116
+
117
+ /**
118
+ * 高精度除法
119
+ * @export
120
+ */
121
+ export function divide(...nums) {
122
+ if (nums.length > 2) {
123
+ return iteratorOperation(nums, divide);
124
+ }
125
+
126
+ const [num1, num2] = nums;
127
+ const num1Changed = float2Fixed(num1);
128
+ const num2Changed = float2Fixed(num2);
129
+ checkBoundary(num1Changed);
130
+ checkBoundary(num2Changed);
131
+ // 重要,这里必须用strip进行修正
132
+ return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
133
+ }
134
+
135
+ /**
136
+ * 四舍五入
137
+ * @export
138
+ */
139
+ export function round(num, ratio) {
140
+ const base = Math.pow(10, ratio);
141
+ let result = divide(Math.round(Math.abs(times(num, base))), base);
142
+ if (num < 0 && result !== 0) {
143
+ result = times(result, -1);
144
+ }
145
+ // 位数不足则补0
146
+ return result;
147
+ }
148
+
149
+ /**
150
+ * 是否进行边界检查,默认开启
151
+ * @param flag 标记开关,true 为开启,false 为关闭,默认为 true
152
+ * @export
153
+ */
154
+ export function enableBoundaryChecking(flag = true) {
155
+ _boundaryCheckingState = flag;
156
+ }
157
+
158
+
159
+ export default {
160
+ times,
161
+ plus,
162
+ minus,
163
+ divide,
164
+ round,
165
+ enableBoundaryChecking,
166
+ };
167
+